Merge branch 'master' into sagi_dev
This commit is contained in:
commit
b7a91fdbe8
14 changed files with 775 additions and 660 deletions
|
@ -1,143 +1,181 @@
|
||||||
#include "loginhandler.h"
|
#include "loginhandler.h"
|
||||||
|
|
||||||
loginHandler::loginHandler(user *ptr): logggedInFlag(false)
|
loginHandler::loginHandler(user *ptr, QStatusBar *statusBarPtr,QPushButton *loginButtonPtr): logggedInFlag(false)
|
||||||
{
|
{
|
||||||
this->jceLog = new jceLogin(ptr);
|
this->loginButtonPtr = loginButtonPtr;
|
||||||
|
|
||||||
|
//statusBar
|
||||||
|
statusBar = statusBarPtr;
|
||||||
|
iconButtomStatusLabel = new QLabel();
|
||||||
|
statusBar->addPermanentWidget(iconButtomStatusLabel,0);
|
||||||
|
setIconConnectionStatus(jceLogin::jceStatus::JCE_NOT_CONNECTED);
|
||||||
|
|
||||||
|
//user settings
|
||||||
|
userPtr = ptr;
|
||||||
|
this->jceLog = new jceLogin(userPtr);
|
||||||
|
QObject::connect(this->jceLog,SIGNAL(connectionReadyAfterDisconnection()),this,SLOT(readyAfterConnectionLost()));
|
||||||
}
|
}
|
||||||
void loginHandler::setPointers(QLabel *statusLabelPtr,QLineEdit *pswdEditPtr,QLineEdit *usrnmEditPtr)
|
bool loginHandler::login(QString username,QString password)
|
||||||
{
|
{
|
||||||
this->statusLabelPtr = statusLabelPtr;
|
qDebug() << Q_FUNC_INFO << "Login with username and password";
|
||||||
this->pswdEditPtr = pswdEditPtr;
|
if (isLoggedInFlag())
|
||||||
this->usrnmEditPtr = usrnmEditPtr;
|
{
|
||||||
|
qDebug() << Q_FUNC_INFO << "Loging out";
|
||||||
|
logout();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
setIconConnectionStatus(jceLogin::jceStatus::JCE_START_VALIDATING_PROGRESS);
|
||||||
|
|
||||||
|
userPtr->setUsername(username);
|
||||||
|
userPtr->setPassword(password);
|
||||||
|
|
||||||
|
if (makeConnection() == true)
|
||||||
|
{
|
||||||
|
setIconConnectionStatus(jceLogin::jceStatus::JCE_YOU_ARE_IN);
|
||||||
|
loginButtonPtr->setText(QObject::tr("Logout"));
|
||||||
|
return isLoggedInFlag();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
logout();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void loginHandler::logout()
|
||||||
|
{
|
||||||
|
loginButtonPtr->setText(QObject::tr("Login"));
|
||||||
|
setIconConnectionStatus(jceLogin::jceStatus::JCE_NOT_CONNECTED);
|
||||||
|
jceLog->closeAll();
|
||||||
|
logggedInFlag = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool loginHandler::makeConnection()
|
bool loginHandler::makeConnection()
|
||||||
{
|
{
|
||||||
if (this->jceLog == NULL)
|
if (this->jceLog == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
try
|
int status = (int)jceLog->makeConnection();
|
||||||
{
|
|
||||||
jceLog->makeConnection();
|
|
||||||
}
|
|
||||||
catch (jceLogin::jceStatus &a)
|
|
||||||
{
|
|
||||||
int status = (int)a;
|
|
||||||
switch (status)
|
switch (status)
|
||||||
{
|
{
|
||||||
case jceLogin::JCE_YOU_ARE_IN:
|
case jceLogin::JCE_YOU_ARE_IN:
|
||||||
{
|
{
|
||||||
logggedInFlag = true;
|
logggedInFlag = true;
|
||||||
return logggedInFlag;
|
return logggedInFlag;
|
||||||
break;
|
}
|
||||||
}
|
case jceLogin::ERROR_ON_VALIDATION:
|
||||||
case jceLogin::ERROR_ON_VALIDATION:
|
{
|
||||||
{
|
popMessage(QObject::tr("Please Check Your Username & Password"),false);
|
||||||
popMessage(QObject::tr("Please Check Your Username & Password"),false);
|
return false;
|
||||||
|
}
|
||||||
|
case jceLogin::ERROR_ON_VALIDATION_USER_BLOCKED:
|
||||||
|
{
|
||||||
|
popMessage(QObject::tr("You have been blocked by JCE, please try in a couple of minutes."));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
case jceLogin::ERROR_ON_OPEN_SOCKET:
|
||||||
|
{
|
||||||
|
popMessage(QObject::tr("Please Check Your Internet Connection."));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
case jceLogin::JCE_NOT_CONNECTED:
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case jceLogin::ERROR_ON_GETTING_INFO:
|
||||||
|
{
|
||||||
|
popMessage(QObject::tr("Receive Request Timeout."));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
case jceLogin::ERROR_ON_SEND_REQUEST:
|
||||||
|
{
|
||||||
|
popMessage(QObject::tr("Send Request Timeout."));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
usrnmEditPtr->setDisabled(false);
|
return false;
|
||||||
pswdEditPtr->setDisabled(false);
|
|
||||||
|
|
||||||
pswdEditPtr->selectAll();
|
|
||||||
pswdEditPtr->setFocus();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
case jceLogin::ERROR_ON_VALIDATION_USER_BLOCKED:
|
|
||||||
{
|
|
||||||
popMessage(QObject::tr("You have been blocked by JCE, please try in a couple of minutes."));
|
|
||||||
jceLog->closeAll();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
case jceLogin::ERROR_ON_OPEN_SOCKET:
|
|
||||||
{
|
|
||||||
popMessage(QObject::tr("Please Check Your Internet Connection."));
|
|
||||||
jceLog->closeAll();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
case jceLogin::JCE_NOT_CONNECTED:
|
|
||||||
{
|
|
||||||
jceLog->reConnect();
|
|
||||||
/*
|
|
||||||
* Fix: need to add a prompte window to ask user whether he wants to reconnect or not
|
|
||||||
*/
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case jceLogin::ERROR_ON_GETTING_INFO:
|
|
||||||
{
|
|
||||||
popMessage(QObject::tr("Receive Request Timeout."));
|
|
||||||
jceLog->closeAll();
|
|
||||||
return false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case jceLogin::ERROR_ON_SEND_REQUEST:
|
|
||||||
{
|
|
||||||
popMessage(QObject::tr("Send Request Timeout."));
|
|
||||||
jceLog->closeAll();
|
|
||||||
return false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void loginHandler::readyAfterConnectionLost()
|
||||||
|
{
|
||||||
|
qWarning() << Q_FUNC_INFO;
|
||||||
|
setLoginFlag(false);
|
||||||
|
login(userPtr->getUsername(),userPtr->getPassword());
|
||||||
|
|
||||||
|
}
|
||||||
bool loginHandler::isLoggedInFlag()
|
bool loginHandler::isLoggedInFlag()
|
||||||
{
|
{
|
||||||
if (jceLog->isLoginFlag()) //checking connection and then if logged in
|
if (jceLog->isLoginFlag()) //checking connection and then if logged in
|
||||||
return this->logggedInFlag;
|
return this->logggedInFlag;
|
||||||
else
|
else
|
||||||
this->setLoginFlag(false);
|
this->setLoginFlag(false);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void loginHandler::setLoginFlag(bool flag)
|
void loginHandler::setLoginFlag(bool flag)
|
||||||
{
|
{
|
||||||
this->logggedInFlag = flag;
|
this->logggedInFlag = flag;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString loginHandler::getCurrentPageContect()
|
QString loginHandler::getCurrentPageContect()
|
||||||
{
|
{
|
||||||
QTextEdit phrase;
|
QTextEdit phrase;
|
||||||
if (isLoggedInFlag())
|
if (isLoggedInFlag())
|
||||||
phrase.setText(jceLog->getPage());
|
phrase.setText(jceLog->getPage());
|
||||||
else
|
else
|
||||||
throw jceLogin::ERROR_ON_GETTING_INFO;
|
throw jceLogin::ERROR_ON_GETTING_INFO;
|
||||||
|
|
||||||
return phrase.toPlainText();
|
return phrase.toPlainText();
|
||||||
}
|
}
|
||||||
|
|
||||||
void loginHandler::makeDisconnectionRequest()
|
|
||||||
{
|
|
||||||
jceLog->closeAll();
|
|
||||||
this->logggedInFlag = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
int loginHandler::makeGradeRequest(int fromYear, int toYear, int fromSemester, int toSemester)
|
int loginHandler::makeGradeRequest(int fromYear, int toYear, int fromSemester, int toSemester)
|
||||||
{
|
{
|
||||||
if (isLoggedInFlag())
|
if (isLoggedInFlag())
|
||||||
return jceLog->getGrades(fromYear, toYear, fromSemester, toSemester);
|
return jceLog->getGrades(fromYear, toYear, fromSemester, toSemester);
|
||||||
else
|
else
|
||||||
return jceLogin::JCE_NOT_CONNECTED;
|
return jceLogin::JCE_NOT_CONNECTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
int loginHandler::makeCalendarRequest(int year, int semester)
|
int loginHandler::makeCalendarRequest(int year, int semester)
|
||||||
{
|
{
|
||||||
if (isLoggedInFlag())
|
if (isLoggedInFlag())
|
||||||
return jceLog->getCalendar(year,semester);
|
return jceLog->getCalendar(year,semester);
|
||||||
else
|
else
|
||||||
return jceLogin::JCE_NOT_CONNECTED;
|
return jceLogin::JCE_NOT_CONNECTED;
|
||||||
|
}
|
||||||
|
void loginHandler::setIconConnectionStatus(jceLogin::jceStatus statusDescription)
|
||||||
|
{
|
||||||
|
QPixmap iconPix;
|
||||||
|
switch (statusDescription)
|
||||||
|
{
|
||||||
|
case jceLogin::jceStatus::JCE_START_VALIDATING_PROGRESS:
|
||||||
|
iconPix.load(":/icons/blueStatusIcon.png");
|
||||||
|
statusBar->showMessage(tr("Connecting..."));
|
||||||
|
break;
|
||||||
|
case jceLogin::jceStatus::JCE_YOU_ARE_IN:
|
||||||
|
iconPix.load(":/icons/greenStatusIcon.png");
|
||||||
|
statusBar->showMessage(tr("Connected"));
|
||||||
|
break;
|
||||||
|
case jceLogin::jceStatus::JCE_NOT_CONNECTED:
|
||||||
|
iconPix.load(":/icons/redStatusIcon.png");
|
||||||
|
statusBar->showMessage(tr("Disconnected"));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
iconPix.load(":/icons/redStatusIcon.png");
|
||||||
|
statusBar->showMessage(tr("Ready."));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
iconButtomStatusLabel->setPixmap(iconPix);
|
||||||
|
|
||||||
|
this->statusBar->repaint();
|
||||||
}
|
}
|
||||||
void loginHandler::popMessage(QString message,bool addInfo)
|
void loginHandler::popMessage(QString message,bool addInfo)
|
||||||
{
|
{
|
||||||
if (addInfo)
|
if (addInfo)
|
||||||
message.append(QObject::tr("\nIf this message appear without reason, please contact me at liranbg@gmail.com"));
|
message.append(QObject::tr("\nIf this message appear without reason, please contact me at liranbg@gmail.com"));
|
||||||
|
|
||||||
QMessageBox msgBox;
|
QMessageBox msgBox;
|
||||||
msgBox.setWindowTitle(QObject::tr("Error"));
|
msgBox.setWindowTitle(QObject::tr("Error"));
|
||||||
msgBox.setText(message);
|
msgBox.setText(message);
|
||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
msgBox.setFocus();
|
msgBox.setFocus();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,43 +2,55 @@
|
||||||
#define LOGINHANDLER_H
|
#define LOGINHANDLER_H
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
#include <QLabel>
|
|
||||||
#include <QLineEdit>
|
|
||||||
#include <QTextEdit>
|
#include <QTextEdit>
|
||||||
|
#include <QLabel>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
|
#include <QStatusBar>
|
||||||
|
#include <QPushButton>
|
||||||
|
|
||||||
#include "./src/jceSettings/jcelogin.h"
|
#include "./src/jceSettings/jcelogin.h"
|
||||||
#include "./src/appDatabase/savedata.h"
|
#include "./src/appDatabase/savedata.h"
|
||||||
|
|
||||||
|
|
||||||
class loginHandler
|
class loginHandler : public QObject
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
loginHandler(user *ptr);
|
loginHandler(user *ptr, QStatusBar *statusBarPtr,QPushButton *loginButtonPtr);
|
||||||
void setPointers(QLabel *statusLabelPtr,QLineEdit *pswdEditPtr,QLineEdit *usrnmEditPtr);
|
~loginHandler()
|
||||||
|
{
|
||||||
|
delete iconButtomStatusLabel;
|
||||||
|
delete jceLog;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool login(QString username,QString password);
|
||||||
|
void logout();
|
||||||
|
void setIconConnectionStatus(jceLogin::jceStatus statusDescription);
|
||||||
|
|
||||||
bool makeConnection();
|
bool makeConnection();
|
||||||
|
|
||||||
bool isLoggedInFlag();
|
bool isLoggedInFlag();
|
||||||
void setLoginFlag(bool flag);
|
void setLoginFlag(bool flag);
|
||||||
|
|
||||||
QString getCurrentPageContect();
|
QString getCurrentPageContect();
|
||||||
|
|
||||||
int makeGradeRequest(int fromYear, int toYear, int fromSemester, int toSemester);
|
int makeGradeRequest(int fromYear, int toYear, int fromSemester, int toSemester);
|
||||||
int makeCalendarRequest(int year,int semester);
|
int makeCalendarRequest(int year,int semester);
|
||||||
|
|
||||||
void makeDisconnectionRequest();
|
private slots:
|
||||||
|
void readyAfterConnectionLost();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void popMessage(QString message, bool addInfo = true);
|
void popMessage(QString message, bool addInfo = true);
|
||||||
|
|
||||||
bool logggedInFlag;
|
bool logggedInFlag;
|
||||||
jceLogin *jceLog;
|
jceLogin * jceLog;
|
||||||
|
user * userPtr;
|
||||||
QLabel *statusLabelPtr;
|
|
||||||
QLineEdit *pswdEditPtr;
|
|
||||||
QLineEdit *usrnmEditPtr;
|
|
||||||
|
|
||||||
|
QStatusBar *statusBar;
|
||||||
|
QLabel *iconButtomStatusLabel;
|
||||||
|
QPushButton *loginButtonPtr;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -8,19 +8,21 @@
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
#ifdef QT_DEBUG
|
#ifdef QT_DEBUG // Incase QtCreator is in Debug mode all qDebug messages will go to terminal
|
||||||
qDebug() << "Running a debug build";
|
qDebug() << "Running a debug build";
|
||||||
#else
|
#else // If QtCreator is on Release mode , qDebug messages will be logged in a log file.
|
||||||
qDebug() << "Running a release build";
|
qDebug() << "Running a release build";
|
||||||
qInstallMessageHandler(jce_logger::customMessageHandler);
|
qInstallMessageHandler(jce_logger::customMessageHandler);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
qDebug() << "Start : JCE Manager Launched" << Q_FUNC_INFO;
|
qDebug() << "Start : JCE Manager Launched";
|
||||||
|
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
QTranslator translator;
|
QTranslator translator;
|
||||||
QString loco;
|
QString loco;
|
||||||
SaveData data;
|
SaveData data;
|
||||||
loco = data.getLocal();
|
loco = data.getLocal();
|
||||||
|
//Loading Local (From Settings file (SaveData.cpp)
|
||||||
if(loco == "default")
|
if(loco == "default")
|
||||||
{
|
{
|
||||||
QString locale = QLocale::system().name();
|
QString locale = QLocale::system().name();
|
||||||
|
@ -33,10 +35,11 @@ int main(int argc, char *argv[])
|
||||||
translator.load("jce_en" , a.applicationDirPath());
|
translator.load("jce_en" , a.applicationDirPath());
|
||||||
qDebug() << "Local : English Local Loaded";
|
qDebug() << "Local : English Local Loaded";
|
||||||
}
|
}
|
||||||
a.installTranslator(&translator);
|
a.installTranslator(&translator); //Setting local
|
||||||
MainScreen w;
|
MainScreen w;
|
||||||
w.show();
|
w.show();
|
||||||
|
|
||||||
|
//Getting the exit code from QApplication. for debug reasons
|
||||||
int returnCode = a.exec();
|
int returnCode = a.exec();
|
||||||
if(returnCode == 0)
|
if(returnCode == 0)
|
||||||
qDebug() << "End : JCE Manager Ended Successfully With A Return Code: " << returnCode;
|
qDebug() << "End : JCE Manager Ended Successfully With A Return Code: " << returnCode;
|
||||||
|
|
|
@ -8,7 +8,6 @@ MainScreen::MainScreen(QWidget *parent) :QMainWindow(parent), ui(new Ui::MainScr
|
||||||
//this->setFixedSize(this->size()); //main not resizeable
|
//this->setFixedSize(this->size()); //main not resizeable
|
||||||
|
|
||||||
//Login Tab
|
//Login Tab
|
||||||
QPixmap iconPix;
|
|
||||||
iconPix.load(":/icons/iconX.png");
|
iconPix.load(":/icons/iconX.png");
|
||||||
ui->pswdLineEdit->setEchoMode((QLineEdit::Password));
|
ui->pswdLineEdit->setEchoMode((QLineEdit::Password));
|
||||||
ui->labelUsrInputStatus->setVisible(false);
|
ui->labelUsrInputStatus->setVisible(false);
|
||||||
|
@ -16,16 +15,12 @@ MainScreen::MainScreen(QWidget *parent) :QMainWindow(parent), ui(new Ui::MainScr
|
||||||
ui->labelUsrInputStatus->setPixmap(iconPix);
|
ui->labelUsrInputStatus->setPixmap(iconPix);
|
||||||
ui->labelPswInputStatus->setPixmap(iconPix);
|
ui->labelPswInputStatus->setPixmap(iconPix);
|
||||||
|
|
||||||
//Status Bar
|
//StatusBar
|
||||||
ui->statusBar->setStyleSheet("QStatusBar::item { border: 0px solid black };");
|
ui->statusBar->setStyleSheet("QStatusBar::item { border: 0px solid black };");
|
||||||
ButtomStatusLabel = new QLabel(this);
|
|
||||||
statusLabel = new QLabel(this);
|
|
||||||
ui->statusBar->setMaximumSize(this->geometry().width(),STATUS_ICON_HEIGH);
|
ui->statusBar->setMaximumSize(this->geometry().width(),STATUS_ICON_HEIGH);
|
||||||
ui->statusBar->addPermanentWidget(ButtomStatusLabel,0);
|
ui->statusBar->showMessage(tr("Ready"));
|
||||||
ui->statusBar->addPermanentWidget(statusLabel,1);
|
|
||||||
setLabelConnectionStatus(jceLogin::jceStatus::JCE_NOT_CONNECTED);
|
|
||||||
|
|
||||||
//Course, Setting, Calendar Tab
|
//Course, Calendar Tab
|
||||||
calendarSchedule * calendarSchedulePtr = new calendarSchedule();
|
calendarSchedule * calendarSchedulePtr = new calendarSchedule();
|
||||||
ui->calendarGridLayoutMain->addWidget(calendarSchedulePtr);
|
ui->calendarGridLayoutMain->addWidget(calendarSchedulePtr);
|
||||||
ui->avgLCD->setPalette(QPalette(QPalette::WindowText,Qt::blue));
|
ui->avgLCD->setPalette(QPalette(QPalette::WindowText,Qt::blue));
|
||||||
|
@ -33,7 +28,7 @@ MainScreen::MainScreen(QWidget *parent) :QMainWindow(parent), ui(new Ui::MainScr
|
||||||
//Pointer allocating
|
//Pointer allocating
|
||||||
this->userLoginSetting = new user("","");
|
this->userLoginSetting = new user("","");
|
||||||
this->courseTableMgr = new coursesTableManager(ui->coursesTable,userLoginSetting);
|
this->courseTableMgr = new coursesTableManager(ui->coursesTable,userLoginSetting);
|
||||||
this->loginHandel = new loginHandler(userLoginSetting);
|
this->loginHandel = new loginHandler(userLoginSetting,ui->statusBar,ui->loginButton);
|
||||||
this->calendar = new CalendarManager(calendarSchedulePtr);
|
this->calendar = new CalendarManager(calendarSchedulePtr);
|
||||||
this->data = new SaveData();
|
this->data = new SaveData();
|
||||||
|
|
||||||
|
@ -45,54 +40,62 @@ MainScreen::MainScreen(QWidget *parent) :QMainWindow(parent), ui(new Ui::MainScr
|
||||||
ui->keepLogin->setChecked(true);
|
ui->keepLogin->setChecked(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Local Check and ui setting.
|
//language
|
||||||
checkLocale();
|
checkLocale();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MainScreen::~MainScreen()
|
MainScreen::~MainScreen()
|
||||||
{
|
{
|
||||||
delete ButtomStatusLabel;
|
|
||||||
delete statusLabel;
|
|
||||||
delete calendar;
|
delete calendar;
|
||||||
delete courseTableMgr;
|
delete courseTableMgr;
|
||||||
delete userLoginSetting;
|
delete userLoginSetting;
|
||||||
delete loginHandel;
|
delete loginHandel;
|
||||||
delete ui;
|
|
||||||
delete data;
|
delete data;
|
||||||
|
delete ui;
|
||||||
}
|
}
|
||||||
//EVENTS ON STATUS BAR
|
//EVENTS ON STATUS BAR
|
||||||
void MainScreen::setLabelConnectionStatus(jceLogin::jceStatus statusDescription)
|
|
||||||
{
|
|
||||||
QPixmap iconPix;
|
|
||||||
switch (statusDescription)
|
|
||||||
{
|
|
||||||
case jceLogin::jceStatus::JCE_START_VALIDATING_PROGRESS:
|
|
||||||
iconPix.load(":/icons/blueStatusIcon.png");
|
|
||||||
statusLabel->setText(tr("Connecting"));
|
|
||||||
break;
|
|
||||||
case jceLogin::jceStatus::JCE_YOU_ARE_IN:
|
|
||||||
iconPix.load(":/icons/greenStatusIcon.png");
|
|
||||||
statusLabel->setText(tr("Connected"));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
iconPix.load(":/icons/redStatusIcon.png");
|
|
||||||
statusLabel->setText(tr("Disconnected"));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ButtomStatusLabel->setPixmap(iconPix);
|
|
||||||
|
|
||||||
this->repaint();
|
|
||||||
}
|
|
||||||
//EVENTS ON LOGIN TAB
|
//EVENTS ON LOGIN TAB
|
||||||
void MainScreen::on_loginButton_clicked()
|
void MainScreen::on_loginButton_clicked()
|
||||||
{
|
{
|
||||||
if (loginHandel->isLoggedInFlag())
|
qDebug() << Q_FUNC_INFO;
|
||||||
uiSetDisconnectMode();
|
bool isSettingsOk = false;
|
||||||
|
if ((ui->usrnmLineEdit->text().isEmpty()) || (ui->pswdLineEdit->text().isEmpty()))
|
||||||
|
{
|
||||||
|
if (ui->usrnmLineEdit->text().isEmpty())
|
||||||
|
{
|
||||||
|
ui->labelUsrInputStatus->setVisible(true);
|
||||||
|
qDebug() << Q_FUNC_INFO << "username input is empty";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ui->labelUsrInputStatus->setVisible(false);
|
||||||
|
if (ui->pswdLineEdit->text().isEmpty())
|
||||||
|
{
|
||||||
|
ui->labelPswInputStatus->setVisible(true);
|
||||||
|
qDebug() << Q_FUNC_INFO << "password input is empty";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
ui->labelPswInputStatus->setVisible(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
uiSetConnectMode();
|
{
|
||||||
|
isSettingsOk = true;
|
||||||
|
ui->labelUsrInputStatus->setVisible(false);
|
||||||
|
ui->labelPswInputStatus->setVisible(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this->loginHandel->login(ui->usrnmLineEdit->text(),ui->pswdLineEdit->text()) == true)
|
||||||
|
{
|
||||||
|
ui->pswdLineEdit->setDisabled(true);
|
||||||
|
ui->usrnmLineEdit->setDisabled(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ui->pswdLineEdit->setDisabled(false);
|
||||||
|
ui->usrnmLineEdit->setDisabled(false);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void MainScreen::on_keepLogin_clicked()
|
void MainScreen::on_keepLogin_clicked()
|
||||||
{
|
{
|
||||||
|
@ -108,74 +111,7 @@ void MainScreen::on_usrnmLineEdit_editingFinished()
|
||||||
{
|
{
|
||||||
ui->usrnmLineEdit->setText(ui->usrnmLineEdit->text().toLower());
|
ui->usrnmLineEdit->setText(ui->usrnmLineEdit->text().toLower());
|
||||||
}
|
}
|
||||||
void MainScreen::uiSetDisconnectMode()
|
|
||||||
{
|
|
||||||
setLabelConnectionStatus(jceLogin::jceStatus::JCE_NOT_CONNECTED);
|
|
||||||
ui->usrnmLineEdit->setText("");
|
|
||||||
ui->pswdLineEdit->setText("");
|
|
||||||
ui->usrnmLineEdit->setEnabled(true);
|
|
||||||
ui->pswdLineEdit->setEnabled(true);
|
|
||||||
|
|
||||||
loginHandel->makeDisconnectionRequest();
|
|
||||||
ui->loginButton->setText(tr("&Login"));
|
|
||||||
ui->getCalendarBtn->setDisabled(true);
|
|
||||||
ui->exportToCVSBtn->setDisabled(true);
|
|
||||||
ui->ratesButton->setDisabled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
void MainScreen::uiSetConnectMode()
|
|
||||||
{
|
|
||||||
QString username;
|
|
||||||
QString password;
|
|
||||||
if ((ui->usrnmLineEdit->text().isEmpty()) || (ui->pswdLineEdit->text().isEmpty()))
|
|
||||||
{
|
|
||||||
if (ui->usrnmLineEdit->text().isEmpty())
|
|
||||||
{
|
|
||||||
ui->labelUsrInputStatus->setVisible(true);
|
|
||||||
qDebug() << "error, username input is empty";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
ui->labelUsrInputStatus->setVisible(false);
|
|
||||||
if (ui->pswdLineEdit->text().isEmpty())
|
|
||||||
{
|
|
||||||
ui->labelPswInputStatus->setVisible(true);
|
|
||||||
qDebug() << "error, password input is empty";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
ui->labelPswInputStatus->setVisible(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ui->labelUsrInputStatus->setVisible(false);
|
|
||||||
ui->labelPswInputStatus->setVisible(false);
|
|
||||||
}
|
|
||||||
setLabelConnectionStatus(jceLogin::jceStatus::JCE_START_VALIDATING_PROGRESS);
|
|
||||||
|
|
||||||
username = ui->usrnmLineEdit->text();
|
|
||||||
password = ui->pswdLineEdit->text();
|
|
||||||
|
|
||||||
ui->usrnmLineEdit->setDisabled(true);
|
|
||||||
ui->pswdLineEdit->setDisabled(true);
|
|
||||||
|
|
||||||
userLoginSetting->setUsername(username);
|
|
||||||
userLoginSetting->setPassword(password);
|
|
||||||
|
|
||||||
this->loginHandel->setPointers(statusLabel,ui->pswdLineEdit,ui->usrnmLineEdit);
|
|
||||||
if (loginHandel->makeConnection() == true)
|
|
||||||
{
|
|
||||||
setLabelConnectionStatus(jceLogin::jceStatus::JCE_YOU_ARE_IN);
|
|
||||||
ui->loginButton->setText(tr("&Logout"));
|
|
||||||
ui->ratesButton->setEnabled(true);
|
|
||||||
ui->CoursesTab->setEnabled(true);
|
|
||||||
ui->exportToCVSBtn->setEnabled(true);
|
|
||||||
ui->getCalendarBtn->setEnabled(true);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
uiSetDisconnectMode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
//EVENTS ON GPA TAB
|
//EVENTS ON GPA TAB
|
||||||
void MainScreen::on_ratesButton_clicked()
|
void MainScreen::on_ratesButton_clicked()
|
||||||
{
|
{
|
||||||
|
@ -189,7 +125,9 @@ void MainScreen::on_ratesButton_clicked()
|
||||||
int status = 0;
|
int status = 0;
|
||||||
if (loginHandel->isLoggedInFlag())
|
if (loginHandel->isLoggedInFlag())
|
||||||
{
|
{
|
||||||
if ((status = loginHandel->makeGradeRequest(ui->spinBoxCoursesFromYear->value(),ui->spinBoxCoursesToYear->value(),ui->spinBoxCoursesFromSemester->value(),ui->spinBoxCoursesToSemester->value())) == jceLogin::JCE_GRADE_PAGE_PASSED)
|
if ((status = loginHandel->makeGradeRequest(ui->spinBoxCoursesFromYear->value(),
|
||||||
|
ui->spinBoxCoursesToYear->value(),ui->spinBoxCoursesFromSemester->value(),
|
||||||
|
ui->spinBoxCoursesToSemester->value())) == jceLogin::JCE_GRADE_PAGE_PASSED)
|
||||||
{
|
{
|
||||||
pageString = loginHandel->getCurrentPageContect();
|
pageString = loginHandel->getCurrentPageContect();
|
||||||
courseTableMgr->setCoursesList(pageString);
|
courseTableMgr->setCoursesList(pageString);
|
||||||
|
@ -226,7 +164,6 @@ void MainScreen::on_spinBoxCoursesFromYear_valueChanged(int arg1)
|
||||||
{
|
{
|
||||||
ui->spinBoxCoursesFromYear->setValue(arg1);
|
ui->spinBoxCoursesFromYear->setValue(arg1);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainScreen::on_spinBoxCoursesToYear_valueChanged(int arg1)
|
void MainScreen::on_spinBoxCoursesToYear_valueChanged(int arg1)
|
||||||
{
|
{
|
||||||
ui->spinBoxCoursesToYear->setValue(arg1);
|
ui->spinBoxCoursesToYear->setValue(arg1);
|
||||||
|
@ -280,7 +217,6 @@ void MainScreen::on_exportToCVSBtn_clicked()
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//EVENTS ON MENU BAR
|
//EVENTS ON MENU BAR
|
||||||
void MainScreen::on_actionCredits_triggered()
|
void MainScreen::on_actionCredits_triggered()
|
||||||
{
|
{
|
||||||
|
@ -309,14 +245,8 @@ void MainScreen::on_actionHow_To_triggered()
|
||||||
"<br><li>"+tr("HELP3")+"</li>"
|
"<br><li>"+tr("HELP3")+"</li>"
|
||||||
"<br><li>"+tr("HELP4")+"</li>"
|
"<br><li>"+tr("HELP4")+"</li>"
|
||||||
"<br><li>"+tr("HELP5")+"</li>"
|
"<br><li>"+tr("HELP5")+"</li>"
|
||||||
"<br><br>"+tr("HELP6")+
|
"</ul>");
|
||||||
"</ul>");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void MainScreen::on_actionHebrew_triggered()
|
void MainScreen::on_actionHebrew_triggered()
|
||||||
{
|
{
|
||||||
if (ui->actionEnglish->isChecked() || ui->actionOS_Default->isChecked())
|
if (ui->actionEnglish->isChecked() || ui->actionOS_Default->isChecked())
|
||||||
|
@ -330,7 +260,6 @@ void MainScreen::on_actionHebrew_triggered()
|
||||||
else
|
else
|
||||||
ui->actionHebrew->setChecked(true);
|
ui->actionHebrew->setChecked(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainScreen::on_actionEnglish_triggered()
|
void MainScreen::on_actionEnglish_triggered()
|
||||||
{
|
{
|
||||||
if (ui->actionHebrew->isChecked() || ui->actionOS_Default->isChecked())
|
if (ui->actionHebrew->isChecked() || ui->actionOS_Default->isChecked())
|
||||||
|
@ -344,8 +273,6 @@ void MainScreen::on_actionEnglish_triggered()
|
||||||
else
|
else
|
||||||
ui->actionEnglish->setChecked(true);
|
ui->actionEnglish->setChecked(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void MainScreen::on_actionOS_Default_triggered()
|
void MainScreen::on_actionOS_Default_triggered()
|
||||||
{
|
{
|
||||||
if (ui->actionHebrew->isChecked() || ui->actionEnglish->isChecked())
|
if (ui->actionHebrew->isChecked() || ui->actionEnglish->isChecked())
|
||||||
|
|
|
@ -70,25 +70,20 @@ private slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
void uiSetDisconnectMode();
|
|
||||||
void uiSetConnectMode();
|
|
||||||
void setLabelConnectionStatus(jceLogin::jceStatus statusDescription);
|
|
||||||
void checkLocale();
|
void checkLocale();
|
||||||
|
|
||||||
bool checkIfValidDates();
|
bool checkIfValidDates();
|
||||||
|
|
||||||
Ui::MainScreen *ui;
|
Ui::MainScreen *ui;
|
||||||
|
|
||||||
QLabel *ButtomStatusLabel;
|
QPixmap iconPix;
|
||||||
QLabel *statusLabel;
|
|
||||||
|
|
||||||
user *userLoginSetting;
|
user *userLoginSetting;
|
||||||
SaveData *data;
|
SaveData *data;
|
||||||
|
|
||||||
CalendarManager * calendar;
|
CalendarManager * calendar;
|
||||||
coursesTableManager *courseTableMgr;
|
coursesTableManager *courseTableMgr;
|
||||||
loginHandler *loginHandel;
|
|
||||||
|
|
||||||
bool calendarLoaded;
|
loginHandler *loginHandel;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -345,7 +345,7 @@ font-size: 15px;
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="ratesButton">
|
<widget class="QPushButton" name="ratesButton">
|
||||||
<property name="enabled">
|
<property name="enabled">
|
||||||
<bool>false</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="whatsThis">
|
<property name="whatsThis">
|
||||||
<string><html><head/><body><p><span style=" font-weight:600;">Get your grades</span></p></body></html></string>
|
<string><html><head/><body><p><span style=" font-weight:600;">Get your grades</span></p></body></html></string>
|
||||||
|
|
|
@ -1,21 +1,22 @@
|
||||||
#include "jcesslclient.h"
|
#include "jcesslclient.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief jceSSLClient::jceSSLClient Constructer, setting the signals
|
* @brief jceSSLClient::jceSSLClient Constructer, setting the signals
|
||||||
*/
|
*/
|
||||||
jceSSLClient::jceSSLClient() : flag(false), packet("")
|
jceSSLClient::jceSSLClient() : flag(false), packet(""), networkConf(), reConnection(false)
|
||||||
{
|
{
|
||||||
//setting signals
|
//setting signals
|
||||||
connect(this,SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(checkErrors(QAbstractSocket::SocketError)));
|
connect(this,SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(checkErrors(QAbstractSocket::SocketError)));
|
||||||
connect(this,SIGNAL(connected()),this,SLOT(setConnected()));
|
connect(this,SIGNAL(connected()),this,SLOT(setConnected()));
|
||||||
connect(this,SIGNAL(encrypted()),this,SLOT(setEncrypted()));
|
connect(this,SIGNAL(encrypted()),this,SLOT(setEncrypted()));
|
||||||
connect(this,SIGNAL(disconnected()),this,SLOT(setDisconnected()));
|
connect(this,SIGNAL(disconnected()),this,SLOT(setDisconnected()));
|
||||||
|
connect(&networkConf,SIGNAL(onlineStateChanged(bool)),this,SLOT(setOnlineState(bool)));
|
||||||
|
|
||||||
//loop event will connect the server, and when it is connected, it will quit - but connection will be open
|
//loop event will connect the server, and when it is connected, it will quit - but connection will be open
|
||||||
connect(this, SIGNAL(encrypted()), &loop, SLOT(quit()));
|
connect(this, SIGNAL(encrypted()), &loop, SLOT(quit()));
|
||||||
connect(this,SIGNAL(error(QAbstractSocket::SocketError)),&loop,SLOT(quit()));
|
connect(this, SIGNAL(error(QAbstractSocket::SocketError)),&loop,SLOT(quit()));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief jceSSLClient::makeConnect connecting to server with given port. using eventloop to assure it wont stuck the application.
|
* @brief jceSSLClient::makeConnect connecting to server with given port. using eventloop to assure it wont stuck the application.
|
||||||
* @param server - server to connect to
|
* @param server - server to connect to
|
||||||
|
@ -24,24 +25,33 @@ jceSSLClient::jceSSLClient() : flag(false), packet("")
|
||||||
*/
|
*/
|
||||||
bool jceSSLClient::makeConnect(QString server, int port)
|
bool jceSSLClient::makeConnect(QString server, int port)
|
||||||
{
|
{
|
||||||
qDebug() << "jceSSLClient::makeConnect; Making connection";
|
if (this->networkConf.isOnline() == false)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (reConnection) //reset reconnectiong flag
|
||||||
|
{
|
||||||
|
qDebug() << Q_FUNC_INFO << "Making Reconnection";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
qDebug() << Q_FUNC_INFO << "Making Connection";
|
||||||
|
|
||||||
if (isConnected())
|
if (isConnected())
|
||||||
{
|
{
|
||||||
qWarning() << "jceSSLClient::makeConnect; Was already connected. Aborting.";
|
qDebug() << Q_FUNC_INFO << "flag=true, calling makeDisconnect()";
|
||||||
makeDiconnect();
|
|
||||||
}
|
|
||||||
if (isOpen())
|
|
||||||
{
|
|
||||||
qWarning() << "jceSSLClient::makeConnect; IsO pen. Aborting.";
|
|
||||||
makeDiconnect();
|
makeDiconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << "jceSSLClient::makeConnect; Connection to: " << server << "On Port: " << port;
|
qDebug() << Q_FUNC_INFO << "Connection to: " << server << "On Port: " << port;
|
||||||
connectToHostEncrypted(server.toStdString().c_str(), port);
|
connectToHostEncrypted(server.toStdString().c_str(), port);
|
||||||
|
|
||||||
loop.exec(); //starting connection, waiting to encryption and then it ends
|
loop.exec(); //starting connection, waiting to encryption and then it ends
|
||||||
|
|
||||||
qDebug() << "jceSSLClient::makeConnect; returning the connection status: " << isConnected();
|
qDebug() << Q_FUNC_INFO << "returning the connection status: " << isConnected();
|
||||||
|
if (reConnection)
|
||||||
|
{
|
||||||
|
reConnection = false;
|
||||||
|
emit serverDisconnectedbyRemote();
|
||||||
|
}
|
||||||
return isConnected();
|
return isConnected();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -51,37 +61,16 @@ bool jceSSLClient::makeConnect(QString server, int port)
|
||||||
*/
|
*/
|
||||||
bool jceSSLClient::makeDiconnect()
|
bool jceSSLClient::makeDiconnect()
|
||||||
{
|
{
|
||||||
qDebug() << "jceSSLClient::makeDiconnect;";
|
|
||||||
if (loop.isRunning())
|
if (loop.isRunning())
|
||||||
{
|
{
|
||||||
qWarning() << "jceSSLClient::makeDiconnect; Killing connection thread";
|
qWarning() << Q_FUNC_INFO << "Killing connection thread";
|
||||||
loop.exit();
|
loop.exit();
|
||||||
}
|
|
||||||
if (state() == QAbstractSocket::SocketState::UnconnectedState)
|
|
||||||
{
|
|
||||||
qDebug() << "jceSSLClient::makeDiconnect; Disconnected with [UnconnectedState]";
|
|
||||||
flag = false;
|
|
||||||
}
|
}
|
||||||
else if (state() == QAbstractSocket::SocketState::ConnectedState)
|
qDebug() << Q_FUNC_INFO << "disconnecting from host and emitting disconnected()";
|
||||||
{
|
this->disconnectFromHost(); //emits disconnected > setDisconnected
|
||||||
qWarning() << "jceSSLClient::makeDiconnect; Disconnecting with [ConnectedState] ";
|
setSocketState(QAbstractSocket::SocketState::UnconnectedState);
|
||||||
abort();
|
return (!isConnected());
|
||||||
if (state() != QAbstractSocket::SocketState::UnconnectedState)
|
|
||||||
{
|
|
||||||
qWarning() << "jceSSLClient::makeDiconnect; still open! recursion call to disconnect";
|
|
||||||
abort();//still connected? ensure the disconnection
|
|
||||||
flag = makeDiconnect(); //recursion call!
|
|
||||||
}
|
|
||||||
flag = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
qWarning() << "jceSSLClient::makeDiconnect; Disconnecting [else] ";
|
|
||||||
abort(); //ensure the disconnection
|
|
||||||
flag = false;
|
|
||||||
}
|
|
||||||
qDebug() << "jceSSLClient::makeDiconnect; disconnect return with " << flag;
|
|
||||||
return flag;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -90,20 +79,30 @@ bool jceSSLClient::makeDiconnect()
|
||||||
*/
|
*/
|
||||||
bool jceSSLClient::isConnected()
|
bool jceSSLClient::isConnected()
|
||||||
{
|
{
|
||||||
|
bool tempFlag;
|
||||||
//checking state before returning flag!
|
//checking state before returning flag!
|
||||||
if (state() == QAbstractSocket::SocketState::UnconnectedState)
|
if (state() == QAbstractSocket::SocketState::UnconnectedState)
|
||||||
{
|
{
|
||||||
flag = false;
|
tempFlag = false;
|
||||||
}
|
}
|
||||||
else if (state() == QAbstractSocket::SocketState::ClosingState)
|
else if (state() == QAbstractSocket::SocketState::ClosingState)
|
||||||
{
|
{
|
||||||
flag = false;
|
tempFlag = false;
|
||||||
}
|
}
|
||||||
else if (state() == QAbstractSocket::SocketState::ConnectedState)
|
else if (state() == QAbstractSocket::SocketState::ConnectedState)
|
||||||
{
|
{
|
||||||
flag = true;
|
if (this->networkConf.isOnline())
|
||||||
|
tempFlag = true;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this->setSocketState(QAbstractSocket::SocketState::UnconnectedState);
|
||||||
|
tempFlag = false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
return flag;
|
if (!this->networkConf.isOnline()) //no link, ethernet\wifi
|
||||||
|
tempFlag = false;
|
||||||
|
return ((flag) && (tempFlag));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief jceSSLClient::sendData - given string, send it to server
|
* @brief jceSSLClient::sendData - given string, send it to server
|
||||||
|
@ -119,7 +118,7 @@ bool jceSSLClient::sendData(QString str)
|
||||||
if (waitForBytesWritten())
|
if (waitForBytesWritten())
|
||||||
sendDataFlag = true;
|
sendDataFlag = true;
|
||||||
}
|
}
|
||||||
qDebug() << "jceSSLClient::sendData; Sending Data status is: " << sendDataFlag;
|
qDebug() << Q_FUNC_INFO << "Sending Data status is: " << sendDataFlag;
|
||||||
return sendDataFlag;
|
return sendDataFlag;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -130,7 +129,7 @@ bool jceSSLClient::sendData(QString str)
|
||||||
*/
|
*/
|
||||||
bool jceSSLClient::recieveData(QString &str, bool fast)
|
bool jceSSLClient::recieveData(QString &str, bool fast)
|
||||||
{
|
{
|
||||||
qDebug() << "jceSSLClient::recieveData Data receiving!";
|
qDebug() << Q_FUNC_INFO << "Data receiving!";
|
||||||
packet = "";
|
packet = "";
|
||||||
bool sflag = false;
|
bool sflag = false;
|
||||||
|
|
||||||
|
@ -158,10 +157,10 @@ bool jceSSLClient::recieveData(QString &str, bool fast)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
str = packet;
|
str = packet;
|
||||||
qDebug() << "jceSSLClient::recieveData received bytes: " << str.length() ;
|
qDebug() << Q_FUNC_INFO << "received bytes: " << str.length() ;
|
||||||
if (str.length() > 0)
|
if (str.length() > 0)
|
||||||
sflag = true;
|
sflag = true;
|
||||||
qDebug() << "jceSSLClient::recieveData return with flag: " << sflag;
|
qDebug() << Q_FUNC_INFO << "return with flag: " << sflag;
|
||||||
return sflag;
|
return sflag;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -177,6 +176,24 @@ void jceSSLClient::readIt()
|
||||||
packet.append(p);
|
packet.append(p);
|
||||||
}while (p.size() > 0);
|
}while (p.size() > 0);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void jceSSLClient::setOnlineState(bool isOnline)
|
||||||
|
{
|
||||||
|
qWarning() << Q_FUNC_INFO << "isOnline status change: " << isOnline;
|
||||||
|
if (isOnline) //to be added later
|
||||||
|
{
|
||||||
|
qDebug() << Q_FUNC_INFO << "Online Statue has been changed. we are online";
|
||||||
|
//we can add here auto reconnect if wifi\ethernet link has appear
|
||||||
|
//will be added next version
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qWarning() << Q_FUNC_INFO << "Online State has been changed. emitting NoInternetLink";
|
||||||
|
this->makeDiconnect();
|
||||||
|
emit noInternetLink();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief jceSSLClient::setConnected called when signaled with connected, calling the encryption function
|
* @brief jceSSLClient::setConnected called when signaled with connected, calling the encryption function
|
||||||
|
@ -186,26 +203,34 @@ void jceSSLClient::setConnected()
|
||||||
waitForEncrypted();
|
waitForEncrypted();
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief jceSSLClient::setDisconnected called when signaled with disconnected, setting flag to false
|
* @brief jceSSLClient::setDisconnected closing socket, updating state and setting flag to false
|
||||||
*/
|
*/
|
||||||
void jceSSLClient::setDisconnected()
|
void jceSSLClient::setDisconnected()
|
||||||
{
|
{
|
||||||
|
qDebug() << Q_FUNC_INFO << "connection has been DISCONNECTED";
|
||||||
|
this->setSocketState(QAbstractSocket::SocketState::UnconnectedState);
|
||||||
|
packet.clear();
|
||||||
flag = false;
|
flag = false;
|
||||||
|
if (reConnection)
|
||||||
|
makeConnect();
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief jceSSLClient::setEncrypted called when signaled with encrypted. setting the buffer size and keeping alive.
|
* @brief jceSSLClient::setEncrypted called when signaled with encrypted. setting the buffer size and keeping alive.
|
||||||
*/
|
*/
|
||||||
void jceSSLClient::setEncrypted()
|
void jceSSLClient::setEncrypted()
|
||||||
{
|
{
|
||||||
|
qDebug() << Q_FUNC_INFO << "connection has been ENCRYPTED";
|
||||||
setReadBufferSize(10000);
|
setReadBufferSize(10000);
|
||||||
setSocketOption(QAbstractSocket::KeepAliveOption,1);
|
setSocketOption(QAbstractSocket::KeepAliveOption,true);
|
||||||
if (state() == QAbstractSocket::SocketState::ConnectedState)
|
flag = true;
|
||||||
flag = true;
|
if (!isConnected())
|
||||||
else
|
|
||||||
{
|
{
|
||||||
qWarning() << "jceSSLClient::setEncrypted(); Connection status didnt change!";
|
qWarning() << Q_FUNC_INFO << "Connection status didnt change! reseting flag to false";
|
||||||
flag = false;
|
flag = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief jceSSLClient::showIfErrorMsg message box to show the error occured according to socket
|
* @brief jceSSLClient::showIfErrorMsg message box to show the error occured according to socket
|
||||||
|
@ -220,94 +245,111 @@ void jceSSLClient::showIfErrorMsg()
|
||||||
bool relevantError = false;
|
bool relevantError = false;
|
||||||
switch (enumError)
|
switch (enumError)
|
||||||
{
|
{
|
||||||
case QAbstractSocket::SocketError::ConnectionRefusedError:
|
case QAbstractSocket::SocketError::ConnectionRefusedError: /**/
|
||||||
errorString = QObject::tr("ConnectionRefusedError");
|
errorString = QObject::tr("ConnectionRefusedError");
|
||||||
|
//The connection was refused by the peer (or timed out).
|
||||||
relevantError = true;
|
relevantError = true;
|
||||||
break;
|
break;
|
||||||
case QAbstractSocket::SocketError::RemoteHostClosedError:
|
case QAbstractSocket::SocketError::RemoteHostClosedError: /**/
|
||||||
errorString = QObject::tr("RemoteHostClosedError");
|
errorString = QObject::tr("RemoteHostClosedError");
|
||||||
relevantError = true;
|
//The remote host closed the connection
|
||||||
break;
|
if (networkConf.isOnline()) //we can reconnect
|
||||||
case QAbstractSocket::SocketError::HostNotFoundError:
|
{
|
||||||
errorString = QObject::tr("HostNotFoundError");
|
reConnection = true;
|
||||||
relevantError = true;
|
}
|
||||||
break;
|
else
|
||||||
case QAbstractSocket::SocketError::SocketAccessError:
|
|
||||||
errorString = QObject::tr("SocketAccessError");
|
|
||||||
break;
|
|
||||||
case QAbstractSocket::SocketError::SocketResourceError:
|
|
||||||
errorString = QObject::tr("SocketResourceError");
|
|
||||||
break;
|
|
||||||
case QAbstractSocket::SocketError::SocketTimeoutError:
|
|
||||||
errorString = QObject::tr("SocketTimeoutError");
|
|
||||||
if (!isConnected())
|
|
||||||
relevantError = true;
|
relevantError = true;
|
||||||
break;
|
break;
|
||||||
case QAbstractSocket::SocketError::DatagramTooLargeError:
|
case QAbstractSocket::SocketError::HostNotFoundError: /**/
|
||||||
errorString = QObject::tr("DatagramTooLargeError");
|
errorString = QObject::tr("HostNotFoundError");
|
||||||
break;
|
//The host address was not found.
|
||||||
case QAbstractSocket::SocketError::NetworkError:
|
|
||||||
errorString = QObject::tr("NetworkError");
|
|
||||||
relevantError = true;
|
relevantError = true;
|
||||||
break;
|
break;
|
||||||
case QAbstractSocket::SocketError::AddressInUseError:
|
case QAbstractSocket::SocketError::SocketAccessError: /**/
|
||||||
errorString = QObject::tr("AddressInUseError");
|
errorString = QObject::tr("SocketAccessError");
|
||||||
|
//The socket operation failed because the application lacked the required privileges.
|
||||||
break;
|
break;
|
||||||
case QAbstractSocket::SocketError::SocketAddressNotAvailableError:
|
case QAbstractSocket::SocketError::SocketTimeoutError: /**/
|
||||||
errorString = QObject::tr("SocketAddressNotAvailableError");
|
errorString = QObject::tr("SocketTimeoutError");
|
||||||
|
//The socket operation timed out.
|
||||||
|
if (isConnected()); //ignore it if connected.
|
||||||
|
else
|
||||||
|
relevantError = true;
|
||||||
break;
|
break;
|
||||||
case QAbstractSocket::SocketError::UnsupportedSocketOperationError:
|
case QAbstractSocket::SocketError::NetworkError: /**/
|
||||||
errorString = QObject::tr("UnsupportedSocketOperationError");
|
errorString = QObject::tr("NetworkError");
|
||||||
|
//An error occurred with the network (e.g., the network cable was accidentally plugged out).
|
||||||
|
if (networkConf.isOnline()) //we can reconnect
|
||||||
|
{
|
||||||
|
}
|
||||||
|
else
|
||||||
|
relevantError = true;
|
||||||
break;
|
break;
|
||||||
case QAbstractSocket::SocketError::ProxyAuthenticationRequiredError:
|
case QAbstractSocket::SocketError::SslHandshakeFailedError: /**/
|
||||||
errorString = QObject::tr("ProxyAuthenticationRequiredError");
|
|
||||||
break;
|
|
||||||
case QAbstractSocket::SocketError::SslHandshakeFailedError:
|
|
||||||
errorString = QObject::tr("SslHandshakeFailedError");
|
errorString = QObject::tr("SslHandshakeFailedError");
|
||||||
|
relevantError = true;
|
||||||
break;
|
break;
|
||||||
case QAbstractSocket::SocketError::ProxyConnectionRefusedError:
|
case QAbstractSocket::SocketError::SslInternalError: /**/
|
||||||
errorString = QObject::tr("ProxyConnectionRefusedError");
|
errorString = QObject::tr("SslInternalError");
|
||||||
|
relevantError = true;
|
||||||
break;
|
break;
|
||||||
case QAbstractSocket::SocketError::UnfinishedSocketOperationError:
|
case QAbstractSocket::SocketError::SslInvalidUserDataError: /**/
|
||||||
errorString = QObject::tr("UnfinishedSocketOperationError");
|
errorString = QObject::tr("SslInvalidUserDataError");
|
||||||
|
relevantError = true;
|
||||||
break;
|
break;
|
||||||
case QAbstractSocket::SocketError::ProxyConnectionClosedError:
|
case QAbstractSocket::SocketError::DatagramTooLargeError: //not relevant to us
|
||||||
errorString = QObject::tr("ProxyConnectionClosedError");
|
errorString = QObject::tr("DatagramTooLargeError");
|
||||||
break;
|
break;
|
||||||
case QAbstractSocket::SocketError::ProxyConnectionTimeoutError:
|
case QAbstractSocket::SocketError::SocketResourceError: //not relevant to us
|
||||||
errorString = QObject::tr("ProxyConnectionTimeoutError");
|
|
||||||
break;
|
break;
|
||||||
case QAbstractSocket::SocketError::ProxyNotFoundError:
|
case QAbstractSocket::SocketError::OperationError: //not relevant, except for debug
|
||||||
errorString = QObject::tr("ProxyNotFoundError");
|
|
||||||
break;
|
|
||||||
case QAbstractSocket::SocketError::ProxyProtocolError:
|
|
||||||
errorString = QObject::tr("ProxyProtocolError");
|
|
||||||
break;
|
|
||||||
case QAbstractSocket::SocketError::OperationError:
|
|
||||||
errorString = QObject::tr("OperationError");
|
errorString = QObject::tr("OperationError");
|
||||||
break;
|
break;
|
||||||
case QAbstractSocket::SocketError::SslInternalError:
|
case QAbstractSocket::SocketError::AddressInUseError: //not relevant to us
|
||||||
errorString = QObject::tr("SslInternalError");
|
errorString = QObject::tr("AddressInUseError");
|
||||||
break;
|
break;
|
||||||
case QAbstractSocket::SocketError::SslInvalidUserDataError:
|
case QAbstractSocket::SocketError::SocketAddressNotAvailableError: //not relevant to us
|
||||||
errorString = QObject::tr("SslInvalidUserDataError");
|
errorString = QObject::tr("SocketAddressNotAvailableError");
|
||||||
break;
|
break;
|
||||||
case QAbstractSocket::SocketError::TemporaryError:
|
case QAbstractSocket::SocketError::UnsupportedSocketOperationError: //for very old computers, not relevant to us
|
||||||
|
errorString = QObject::tr("UnsupportedSocketOperationError");
|
||||||
|
break;
|
||||||
|
case QAbstractSocket::SocketError::ProxyAuthenticationRequiredError: //not relevant to us
|
||||||
|
errorString = QObject::tr("ProxyAuthenticationRequiredError");
|
||||||
|
break;
|
||||||
|
case QAbstractSocket::SocketError::ProxyConnectionRefusedError: //not relevant to us
|
||||||
|
errorString = QObject::tr("ProxyConnectionRefusedError");
|
||||||
|
break;
|
||||||
|
case QAbstractSocket::SocketError::UnfinishedSocketOperationError: //not relevant to us
|
||||||
|
errorString = QObject::tr("UnfinishedSocketOperationError");
|
||||||
|
break;
|
||||||
|
case QAbstractSocket::SocketError::ProxyConnectionClosedError: //not relevant to us
|
||||||
|
errorString = QObject::tr("ProxyConnectionClosedError");
|
||||||
|
break;
|
||||||
|
case QAbstractSocket::SocketError::ProxyConnectionTimeoutError: //not relevant to us
|
||||||
|
errorString = QObject::tr("ProxyConnectionTimeoutError");
|
||||||
|
break;
|
||||||
|
case QAbstractSocket::SocketError::ProxyNotFoundError: //not relevant to us
|
||||||
|
errorString = QObject::tr("ProxyNotFoundError");
|
||||||
|
break;
|
||||||
|
case QAbstractSocket::SocketError::ProxyProtocolError: //not relevant to us
|
||||||
|
errorString = QObject::tr("ProxyProtocolError");
|
||||||
|
break;
|
||||||
|
case QAbstractSocket::SocketError::TemporaryError: //not relevant to us
|
||||||
errorString = QObject::tr("TemporaryError");
|
errorString = QObject::tr("TemporaryError");
|
||||||
break;
|
break;
|
||||||
case QAbstractSocket::SocketError::UnknownSocketError:
|
case QAbstractSocket::SocketError::UnknownSocketError: //not relevant, except for debug
|
||||||
errorString = QObject::tr("UnknownSocketError");
|
errorString = QObject::tr("UnknownSocketError");
|
||||||
relevantError = true;
|
relevantError = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (relevantError) //informative string to be shown
|
if (relevantError) //informative string to be shown
|
||||||
{
|
{
|
||||||
qDebug() << "jceSSLClient::showIfErrorMsg(); relevant error. msgbox popped";
|
qDebug() << Q_FUNC_INFO << "relevant error.";
|
||||||
msgBox.setIcon(QMessageBox::Warning);
|
msgBox.setIcon(QMessageBox::Warning);
|
||||||
msgBox.setText(errorString);
|
msgBox.setText(errorString);
|
||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief jceSSLClient::checkErrors this function exctuing when socket error has occured
|
* @brief jceSSLClient::checkErrors this function exctuing when socket error has occured
|
||||||
|
@ -315,8 +357,14 @@ void jceSSLClient::showIfErrorMsg()
|
||||||
*/
|
*/
|
||||||
void jceSSLClient::checkErrors(QAbstractSocket::SocketError a)
|
void jceSSLClient::checkErrors(QAbstractSocket::SocketError a)
|
||||||
{
|
{
|
||||||
qWarning() << "jceSSLClient::checkErrors; Var Error: " << a;
|
//ignore this stupid error
|
||||||
qWarning() << "jceSSLClient::checkErrors; Error: " << this->errorString();
|
if (!((isConnected()) && (a == QAbstractSocket::SocketError::SocketTimeoutError)))
|
||||||
|
{
|
||||||
|
qWarning() << Q_FUNC_INFO << "isOnline?: " << this->networkConf.isOnline();
|
||||||
|
qWarning() << Q_FUNC_INFO << "state is: " << state();
|
||||||
|
qWarning() << Q_FUNC_INFO << "Var Error: " << a;
|
||||||
|
qWarning() << Q_FUNC_INFO << "Error: " << errorString();
|
||||||
|
}
|
||||||
showIfErrorMsg();
|
showIfErrorMsg();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,36 +6,42 @@
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QEventLoop>
|
#include <QEventLoop>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QNetworkConfigurationManager>
|
||||||
|
|
||||||
#include <iostream>
|
#define milisTimeOut 4000
|
||||||
#include <string>
|
|
||||||
#define milisTimeOut 3500
|
|
||||||
|
|
||||||
class jceSSLClient : QSslSocket
|
class jceSSLClient : public QSslSocket
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
jceSSLClient();
|
jceSSLClient();
|
||||||
|
|
||||||
bool makeConnect(QString server, int port);
|
bool makeConnect(QString server = "yedion.jce.ac.il", int port = 443);
|
||||||
|
bool makeDiconnect();
|
||||||
bool isConnected();
|
bool isConnected();
|
||||||
bool sendData(QString str);
|
bool sendData(QString str);
|
||||||
bool recieveData(QString &str, bool fast);
|
bool recieveData(QString &str, bool fast);
|
||||||
bool makeDiconnect();
|
|
||||||
void showIfErrorMsg();
|
void showIfErrorMsg();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void serverDisconnectedbyRemote();
|
||||||
|
void noInternetLink();
|
||||||
|
void socketDisconnected();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void checkErrors(QAbstractSocket::SocketError a);
|
void checkErrors(QAbstractSocket::SocketError a);
|
||||||
void setConnected();
|
void setConnected();
|
||||||
void setEncrypted();
|
void setEncrypted();
|
||||||
void setDisconnected();
|
void setDisconnected();
|
||||||
void readIt();
|
void readIt();
|
||||||
|
void setOnlineState(bool isOnline);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
bool flag;
|
bool flag;
|
||||||
QString packet;
|
QString packet;
|
||||||
QEventLoop loop; //handle the connection as thread
|
QEventLoop loop; //handle the connection as thread
|
||||||
|
QNetworkConfigurationManager networkConf; //checking if online
|
||||||
|
bool reConnection; //used for remote host disconnecting
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,25 @@
|
||||||
#include "csv_exporter.h"
|
#include "csv_exporter.h"
|
||||||
|
|
||||||
|
/*
|
||||||
|
*
|
||||||
|
* Class doc can be bound in csv_exporter.h
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
CSV_Exporter::CSV_Exporter()
|
CSV_Exporter::CSV_Exporter()
|
||||||
{
|
{
|
||||||
|
/* EMPTY - NO NEED */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This method will generate the CSV file (Targeting google calendar import)
|
||||||
|
* it will create a full Semester calendar based on the users input (@param cal)
|
||||||
|
* and the @calSched wich holdes all the courses in "this" semester.
|
||||||
|
* @param calSched - Holdes all the Courses and there info
|
||||||
|
* @param cal - The Calendar dialog witch holdes the starting date and the eand date.
|
||||||
|
* @return - True if *all* went well, false if something on the way went wrong.
|
||||||
|
*/
|
||||||
bool CSV_Exporter::exportCalendar(calendarSchedule *calSched, CalendarDialog *cal)
|
bool CSV_Exporter::exportCalendar(calendarSchedule *calSched, CalendarDialog *cal)
|
||||||
{
|
{
|
||||||
if ((cal == NULL) || (calSched == NULL)) //pointers checking!
|
if ((cal == NULL) || (calSched == NULL)) //pointers checking!
|
||||||
|
@ -16,7 +31,7 @@ bool CSV_Exporter::exportCalendar(calendarSchedule *calSched, CalendarDialog *ca
|
||||||
qDebug() << "Getting path for csv file from user...";
|
qDebug() << "Getting path for csv file from user...";
|
||||||
|
|
||||||
QString filePath = getFileFath();
|
QString filePath = getFileFath();
|
||||||
if (filePath == NULL) //User canceled
|
if(filePath == NULL) //User canceled from the file explorer popup
|
||||||
{
|
{
|
||||||
qDebug() << "CSV : User pressed Cancel... returning false";
|
qDebug() << "CSV : User pressed Cancel... returning false";
|
||||||
return false;
|
return false;
|
||||||
|
@ -25,7 +40,7 @@ bool CSV_Exporter::exportCalendar(calendarSchedule *calSched, CalendarDialog *ca
|
||||||
qDebug() << "CSV : Atempting to export the Schedule...";
|
qDebug() << "CSV : Atempting to export the Schedule...";
|
||||||
|
|
||||||
QFile file(filePath);
|
QFile file(filePath);
|
||||||
if(!file.open(QIODevice::ReadWrite | QIODevice::Truncate))
|
if(!file.open(QIODevice::ReadWrite | QIODevice::Truncate)) //Incase unable to open the file (binary mode - \n will not be converted on "Windows")
|
||||||
{
|
{
|
||||||
QMessageBox msgBox;
|
QMessageBox msgBox;
|
||||||
msgBox.setIcon(QMessageBox::Critical);
|
msgBox.setIcon(QMessageBox::Critical);
|
||||||
|
@ -33,13 +48,16 @@ bool CSV_Exporter::exportCalendar(calendarSchedule *calSched, CalendarDialog *ca
|
||||||
msgBox.exec();
|
msgBox.exec();
|
||||||
qCritical() << "unable to open/create the file... maybe permissions error.";
|
qCritical() << "unable to open/create the file... maybe permissions error.";
|
||||||
return false;
|
return false;
|
||||||
}//else
|
}
|
||||||
//Delete the file
|
|
||||||
QTextStream out(&file);
|
QTextStream out(&file); //The output streem.
|
||||||
out << CSV_CALENDAR_HEADER << "\n";
|
out.setCodec("UTF-8"); //Unicode 8
|
||||||
for (calendarCourse *coursePtr: *(calSched->getCourses()))
|
|
||||||
|
out << CSV_CALENDAR_HEADER << "\n"; // macro in header file
|
||||||
|
|
||||||
|
for (calendarCourse *coursePtr: *(calSched->getCourses())) //main loop - running though all courses
|
||||||
{
|
{
|
||||||
// Subject,Start Date,Start Time,End Date,End Time,Description,Location
|
// Getting course info - store in vars for easy access
|
||||||
int day = coursePtr->getDay();
|
int day = coursePtr->getDay();
|
||||||
int startH = coursePtr->getHourBegin();
|
int startH = coursePtr->getHourBegin();
|
||||||
int startM = coursePtr->getMinutesBegin();
|
int startM = coursePtr->getMinutesBegin();
|
||||||
|
@ -50,11 +68,15 @@ bool CSV_Exporter::exportCalendar(calendarSchedule *calSched, CalendarDialog *ca
|
||||||
QString name = coursePtr->getName();
|
QString name = coursePtr->getName();
|
||||||
QString room = coursePtr->getRoom();
|
QString room = coursePtr->getRoom();
|
||||||
|
|
||||||
QDate currentDate = cal->getStartDate();
|
QDate currentDate = cal->getStartDate(); // currentDate will iterate throuh the semester
|
||||||
|
|
||||||
currentDate = currentDate.addDays(day-1);
|
currentDate = currentDate.addDays(day-1); //selecting the REAL starting day of that course
|
||||||
|
|
||||||
for (;currentDate <= cal->getEndDate(); currentDate = currentDate.addDays(7))
|
/*
|
||||||
|
* secondary loop - We have course info and starting day.
|
||||||
|
* evrey loop enterence we add the course and moving one week forward.
|
||||||
|
*/
|
||||||
|
for(;currentDate <= cal->getEndDate(); currentDate = currentDate.addDays(7))
|
||||||
{
|
{
|
||||||
QString line = makeLine(name, ¤tDate, startH, startM, endH, endM, lecturer, room, type);
|
QString line = makeLine(name, ¤tDate, startH, startM, endH, endM, lecturer, room, type);
|
||||||
if(line != NULL)
|
if(line != NULL)
|
||||||
|
@ -72,6 +94,10 @@ bool CSV_Exporter::exportCalendar(calendarSchedule *calSched, CalendarDialog *ca
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Get the file path according to user via a file explorer dialog
|
||||||
|
* @return - QString: the file path.
|
||||||
|
*/
|
||||||
QString CSV_Exporter::getFileFath()
|
QString CSV_Exporter::getFileFath()
|
||||||
{
|
{
|
||||||
QString fileName = QFileDialog::getSaveFileName();
|
QString fileName = QFileDialog::getSaveFileName();
|
||||||
|
@ -82,6 +108,20 @@ QString CSV_Exporter::getFileFath()
|
||||||
return fileName;
|
return fileName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Returning a CSV formated ling in QString.
|
||||||
|
* @param name
|
||||||
|
* @param date
|
||||||
|
* @param startH
|
||||||
|
* @param startM
|
||||||
|
* @param endH
|
||||||
|
* @param endM
|
||||||
|
* @param lecturer
|
||||||
|
* @param room
|
||||||
|
* @param type
|
||||||
|
* @return a CSV formated ling in QString.
|
||||||
|
*/
|
||||||
QString CSV_Exporter::makeLine(QString name, QDate *date, int startH, int startM, int endH, int endM, QString lecturer, QString room, QString type)
|
QString CSV_Exporter::makeLine(QString name, QDate *date, int startH, int startM, int endH, int endM, QString lecturer, QString room, QString type)
|
||||||
{
|
{
|
||||||
//Creating a CSV text line for Google Calendar/iCal/Outlook
|
//Creating a CSV text line for Google Calendar/iCal/Outlook
|
||||||
|
@ -114,7 +154,7 @@ QString CSV_Exporter::makeLine(QString name, QDate *date, int startH, int startM
|
||||||
description.append("\n");
|
description.append("\n");
|
||||||
description.append(" ב");
|
description.append(" ב");
|
||||||
description.append(room);
|
description.append(room);
|
||||||
description.append("\"");
|
description.append("\n Created with JCE Manager.\"");
|
||||||
|
|
||||||
//Create the Fucking Line
|
//Create the Fucking Line
|
||||||
//Header: Subject,Start Date,Start Time,End Date,End Time,Description,Location
|
//Header: Subject,Start Date,Start Time,End Date,End Time,Description,Location
|
||||||
|
|
|
@ -4,90 +4,97 @@
|
||||||
* @brief jceLogin::jceLogin
|
* @brief jceLogin::jceLogin
|
||||||
* @param username pointer to allocated user settings
|
* @param username pointer to allocated user settings
|
||||||
*/
|
*/
|
||||||
jceLogin::jceLogin(user * username)
|
jceLogin::jceLogin(user* username)
|
||||||
{
|
{
|
||||||
this->recieverPage = new QString();
|
this->recieverPage = new QString();
|
||||||
this->jceA = username;
|
this->jceA = username;
|
||||||
this->JceConnector = new jceSSLClient();
|
this->JceConnector = new jceSSLClient();
|
||||||
|
QObject::connect(JceConnector,SIGNAL(serverDisconnectedbyRemote()),this,SLOT(reValidation()));
|
||||||
|
QObject::connect(JceConnector,SIGNAL(noInternetLink()),this,SLOT(reMakeConnection()));
|
||||||
}
|
}
|
||||||
|
|
||||||
jceLogin::~jceLogin()
|
jceLogin::~jceLogin()
|
||||||
{
|
{
|
||||||
this->jceA = NULL;
|
this->jceA = NULL;
|
||||||
delete recieverPage;
|
delete recieverPage;
|
||||||
delete JceConnector;
|
delete JceConnector;
|
||||||
JceConnector = NULL;
|
JceConnector = NULL;
|
||||||
recieverPage = NULL;
|
recieverPage = NULL;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief jceLogin::makeConnection Connecting to JCE student web site with JceA (username object) and validate it.
|
* @brief jceLogin::makeConnection Connecting to JCE student web site with JceA (username object) and validate it.
|
||||||
* throws error upon the given error from JCE website or Socket error
|
* throws error upon the given error from JCE website or Socket error
|
||||||
*/
|
*/
|
||||||
void jceLogin::makeConnection() throw (jceStatus)
|
int jceLogin::makeConnection()
|
||||||
{
|
{
|
||||||
qDebug() << "jceLogin::makeConnection(); connection to be make";
|
qDebug() << "jceLogin::makeConnection(); connection to be make";
|
||||||
|
|
||||||
if (this->recieverPage == NULL)
|
if (this->recieverPage == NULL)
|
||||||
this->recieverPage = new QString();
|
this->recieverPage = new QString();
|
||||||
|
|
||||||
if (JceConnector->makeConnect(dst_host,dst_port) == false) //couldnt make a connection
|
int returnMode; //gets status according to called function of validation step
|
||||||
throw jceStatus::ERROR_ON_OPEN_SOCKET;
|
jceStatus status = jceStatus::JCE_NOT_CONNECTED;
|
||||||
|
|
||||||
int returnMode; //gets status according to called function of validation step
|
returnMode = checkConnection(); //checking socket status. is connected?
|
||||||
jceStatus status = jceStatus::JCE_NOT_CONNECTED;
|
|
||||||
|
|
||||||
returnMode = checkConnection(); //checking socket status. is connected?
|
if (returnMode == false)
|
||||||
|
|
||||||
if (returnMode == true) //connected to host
|
|
||||||
{
|
{
|
||||||
returnMode = makeFirstVisit();
|
if (JceConnector->makeConnect(dst_host,dst_port) == false) //couldnt make a connection
|
||||||
if (returnMode == true) //requst and send first validation
|
return jceStatus::ERROR_ON_OPEN_SOCKET;
|
||||||
|
else
|
||||||
|
returnMode = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (returnMode == true) //connected to host
|
||||||
|
{
|
||||||
|
returnMode = makeFirstVisit();
|
||||||
|
if (returnMode == true) //requst and send first validation
|
||||||
{
|
{
|
||||||
status = jceStatus::JCE_START_VALIDATING_PROGRESS;
|
status = jceStatus::JCE_START_VALIDATING_PROGRESS;
|
||||||
returnMode = checkValidation();
|
returnMode = checkValidation();
|
||||||
if (returnMode == true) //check if username and password are matching
|
if (returnMode == true) //check if username and password are matching
|
||||||
{
|
{
|
||||||
status = jceStatus::JCE_VALIDATION_PASSED;
|
status = jceStatus::JCE_VALIDATION_PASSED;
|
||||||
returnMode = makeSecondVisit();
|
returnMode = makeSecondVisit();
|
||||||
if (returnMode == true) //siging in the website
|
if (returnMode == true) //siging in the website
|
||||||
{
|
{
|
||||||
qDebug() << "jceLogin::makeConnection(); Signed in succeesfully";
|
qDebug() << "jceLogin::makeConnection(); Signed in succeesfully";
|
||||||
status = jceStatus::JCE_YOU_ARE_IN;
|
status = jceStatus::JCE_YOU_ARE_IN;
|
||||||
setLoginFlag(true);
|
setLoginFlag(true);
|
||||||
}
|
}
|
||||||
else if (returnMode == jceLogin::ERROR_ON_GETTING_INFO)
|
else if (returnMode == jceLogin::ERROR_ON_GETTING_INFO)
|
||||||
{
|
{
|
||||||
status = jceLogin::ERROR_ON_GETTING_INFO;
|
status = jceLogin::ERROR_ON_GETTING_INFO;
|
||||||
}
|
}
|
||||||
else if (returnMode == jceLogin::ERROR_ON_SEND_REQUEST)
|
else if (returnMode == jceLogin::ERROR_ON_SEND_REQUEST)
|
||||||
{
|
{
|
||||||
status = jceLogin::ERROR_ON_SEND_REQUEST;
|
status = jceLogin::ERROR_ON_SEND_REQUEST;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
status = jceStatus::ERROR_ON_VALIDATION;
|
status = jceStatus::ERROR_ON_VALIDATION;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
status = jceStatus::ERROR_ON_VALIDATION;
|
status = jceStatus::ERROR_ON_VALIDATION;
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (returnMode == jceLogin::ERROR_ON_GETTING_INFO)
|
else if (returnMode == jceLogin::ERROR_ON_GETTING_INFO)
|
||||||
{
|
{
|
||||||
status = jceLogin::ERROR_ON_GETTING_INFO;
|
status = jceLogin::ERROR_ON_GETTING_INFO;
|
||||||
}
|
}
|
||||||
else if (returnMode == jceLogin::ERROR_ON_SEND_REQUEST)
|
else if (returnMode == jceLogin::ERROR_ON_SEND_REQUEST)
|
||||||
{
|
{
|
||||||
status = jceLogin::ERROR_ON_SEND_REQUEST;
|
status = jceLogin::ERROR_ON_SEND_REQUEST;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
status = jceStatus::ERROR_ON_VALIDATION_USER_BLOCKED;
|
status = jceStatus::ERROR_ON_VALIDATION_USER_BLOCKED;
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
status = jceStatus::JCE_NOT_CONNECTED;
|
status = jceStatus::JCE_NOT_CONNECTED;
|
||||||
|
|
||||||
//we throw status even if we are IN!
|
//we throw status even if we are IN!
|
||||||
qDebug() << "jceLogin::makeConnection(); throw status: " << status;
|
qDebug() << "jceLogin::makeConnection(); return status: " << status;
|
||||||
throw status;
|
return status;
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -96,41 +103,40 @@ void jceLogin::makeConnection() throw (jceStatus)
|
||||||
*/
|
*/
|
||||||
bool jceLogin::checkConnection() const
|
bool jceLogin::checkConnection() const
|
||||||
{
|
{
|
||||||
if (JceConnector->isConnected())
|
if (JceConnector->isConnected())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @brief jceLogin::reConnect
|
|
||||||
* closing connection and deleting pointers.
|
|
||||||
* calling class's makeConnection function and throw the exception of it.
|
|
||||||
*/
|
|
||||||
void jceLogin::reConnect() throw (jceStatus)
|
|
||||||
{
|
|
||||||
closeAll();
|
|
||||||
if (this->JceConnector != NULL)
|
|
||||||
delete JceConnector;
|
|
||||||
this->recieverPage = new QString();
|
|
||||||
this->JceConnector = new jceSSLClient();
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
makeConnection();
|
|
||||||
}
|
|
||||||
catch (jceLogin::jceStatus &a)
|
|
||||||
{
|
|
||||||
throw a;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief jceLogin::closeAll
|
* @brief jceLogin::closeAll
|
||||||
*/
|
*/
|
||||||
void jceLogin::closeAll()
|
void jceLogin::closeAll()
|
||||||
{
|
{
|
||||||
JceConnector->makeDiconnect();
|
this->JceConnector->makeDiconnect();
|
||||||
delete recieverPage;
|
if ((this->recieverPage != NULL) && (!this->recieverPage->isEmpty()))
|
||||||
recieverPage = NULL;
|
{
|
||||||
|
delete recieverPage;
|
||||||
|
recieverPage = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @brief jceLogin::reMakeConnection
|
||||||
|
*/
|
||||||
|
void jceLogin::reMakeConnection()
|
||||||
|
{
|
||||||
|
if (this->JceConnector != NULL)
|
||||||
|
delete JceConnector;
|
||||||
|
if (this->recieverPage != NULL)
|
||||||
|
delete recieverPage;
|
||||||
|
recieverPage = NULL;
|
||||||
|
JceConnector = NULL;
|
||||||
|
this->recieverPage = new QString();
|
||||||
|
this->JceConnector = new jceSSLClient();
|
||||||
|
QObject::connect(JceConnector,SIGNAL(serverDisconnectedbyRemote()),this,SLOT(reValidation()));
|
||||||
|
QObject::connect(JceConnector,SIGNAL(noInternetLink()),this,SLOT(reMakeConnection()));
|
||||||
|
emit connectionReadyAfterDisconnection();
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -139,17 +145,17 @@ void jceLogin::closeAll()
|
||||||
*/
|
*/
|
||||||
int jceLogin::makeFirstVisit()
|
int jceLogin::makeFirstVisit()
|
||||||
{
|
{
|
||||||
QString usr = jceA->getUsername();
|
QString usr = jceA->getUsername();
|
||||||
QString psw = jceA->getPassword();
|
QString psw = jceA->getPassword();
|
||||||
if (JceConnector->sendData(jceLoginHtmlScripts::makeRequest(jceLoginHtmlScripts::getFirstValidationStep(*jceA))))
|
if (JceConnector->sendData(jceLoginHtmlScripts::makeRequest(jceLoginHtmlScripts::getFirstValidationStep(*jceA))))
|
||||||
{
|
{
|
||||||
if (!JceConnector->recieveData(*recieverPage,true))
|
if (!JceConnector->recieveData(*recieverPage,true))
|
||||||
return jceLogin::ERROR_ON_GETTING_INFO;
|
return jceLogin::ERROR_ON_GETTING_INFO;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return jceLogin::ERROR_ON_SEND_REQUEST;
|
return jceLogin::ERROR_ON_SEND_REQUEST;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief jceLogin::makeSecondVisit making the second validation step of jce student portal login
|
* @brief jceLogin::makeSecondVisit making the second validation step of jce student portal login
|
||||||
|
@ -157,19 +163,19 @@ int jceLogin::makeFirstVisit()
|
||||||
*/
|
*/
|
||||||
int jceLogin::makeSecondVisit()
|
int jceLogin::makeSecondVisit()
|
||||||
{
|
{
|
||||||
QString usrid=jceA->getUserID();
|
QString usrid=jceA->getUserID();
|
||||||
QString pswid=jceA->getHashedPassword();
|
QString pswid=jceA->getHashedPassword();
|
||||||
if ((JceConnector->sendData(jceLoginHtmlScripts::makeRequest(jceLoginHtmlScripts::getSecondValidationStep(*jceA)))))
|
if ((JceConnector->sendData(jceLoginHtmlScripts::makeRequest(jceLoginHtmlScripts::getSecondValidationStep(*jceA)))))
|
||||||
{
|
{
|
||||||
if (!(JceConnector->recieveData(*recieverPage,true)))
|
if (!(JceConnector->recieveData(*recieverPage,true)))
|
||||||
return jceLogin::ERROR_ON_GETTING_INFO;
|
return jceLogin::ERROR_ON_GETTING_INFO;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return jceLogin::ERROR_ON_SEND_REQUEST;
|
return jceLogin::ERROR_ON_SEND_REQUEST;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief jceLogin::getCalendar according to parameters, we make an HTML request and send it over socket to server
|
* @brief jceLogin::getCalendar according to parameters, we make an HTML request and send it over socket to server
|
||||||
|
@ -179,17 +185,17 @@ int jceLogin::makeSecondVisit()
|
||||||
*/
|
*/
|
||||||
int jceLogin::getCalendar(int year, int semester)
|
int jceLogin::getCalendar(int year, int semester)
|
||||||
{
|
{
|
||||||
if ((JceConnector->sendData(jceLoginHtmlScripts::makeRequest(jceLoginHtmlScripts::getCalendar(*jceA,year,semester)))))
|
if ((JceConnector->sendData(jceLoginHtmlScripts::makeRequest(jceLoginHtmlScripts::getCalendar(*jceA,year,semester)))))
|
||||||
{
|
{
|
||||||
if (!(JceConnector->recieveData(*recieverPage,false)))
|
if (!(JceConnector->recieveData(*recieverPage,false)))
|
||||||
return jceLogin::ERROR_ON_GETTING_GRADES;
|
return jceLogin::ERROR_ON_GETTING_GRADES;
|
||||||
else
|
else
|
||||||
return jceLogin::JCE_GRADE_PAGE_PASSED;
|
return jceLogin::JCE_GRADE_PAGE_PASSED;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return jceLogin::ERROR_ON_SEND_REQUEST;
|
return jceLogin::ERROR_ON_SEND_REQUEST;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -202,18 +208,17 @@ int jceLogin::getCalendar(int year, int semester)
|
||||||
*/
|
*/
|
||||||
int jceLogin::getGrades(int fromYear, int toYear, int fromSemester, int toSemester)
|
int jceLogin::getGrades(int fromYear, int toYear, int fromSemester, int toSemester)
|
||||||
{
|
{
|
||||||
std::cout << fromYear << " " << toYear << " " << fromSemester << " " << toSemester << std::endl;
|
if ((JceConnector->sendData(jceLoginHtmlScripts::makeRequest(jceLoginHtmlScripts::getGradesPath(*jceA,fromYear, toYear, fromSemester, toSemester)))))
|
||||||
if ((JceConnector->sendData(jceLoginHtmlScripts::makeRequest(jceLoginHtmlScripts::getGradesPath(*jceA,fromYear, toYear, fromSemester, toSemester)))))
|
|
||||||
{
|
{
|
||||||
if (!(JceConnector->recieveData(*recieverPage,false)))
|
if (!(JceConnector->recieveData(*recieverPage,false)))
|
||||||
return jceLogin::ERROR_ON_GETTING_GRADES;
|
return jceLogin::ERROR_ON_GETTING_GRADES;
|
||||||
else
|
else
|
||||||
return jceLogin::JCE_GRADE_PAGE_PASSED;
|
return jceLogin::JCE_GRADE_PAGE_PASSED;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return jceLogin::ERROR_ON_SEND_REQUEST;
|
return jceLogin::ERROR_ON_SEND_REQUEST;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -223,43 +228,43 @@ int jceLogin::getGrades(int fromYear, int toYear, int fromSemester, int toSemest
|
||||||
bool jceLogin::checkValidation()
|
bool jceLogin::checkValidation()
|
||||||
{
|
{
|
||||||
|
|
||||||
//finds the hashed password
|
//finds the hashed password
|
||||||
QString constUserID_TAG = "value=\"-N";
|
QString constUserID_TAG = "value=\"-N";
|
||||||
QString constHassID_TAG = "-A,-N";
|
QString constHassID_TAG = "-A,-N";
|
||||||
QString hasspass,hassid;
|
QString hasspass,hassid;
|
||||||
std::size_t hasspass_position1,hasspass_position2;
|
std::size_t hasspass_position1,hasspass_position2;
|
||||||
std::size_t id_position1,id_position2;
|
std::size_t id_position1,id_position2;
|
||||||
|
|
||||||
hasspass_position1 = this->recieverPage->toStdString().find(constHassID_TAG.toStdString()); //looking for hasspass index
|
hasspass_position1 = this->recieverPage->toStdString().find(constHassID_TAG.toStdString()); //looking for hasspass index
|
||||||
if (hasspass_position1 == std::string::npos) //didnt find the tag
|
if (hasspass_position1 == std::string::npos) //didnt find the tag
|
||||||
return false;
|
return false;
|
||||||
else
|
else
|
||||||
hasspass_position1 += constHassID_TAG.length(); //skip the index of tag
|
hasspass_position1 += constHassID_TAG.length(); //skip the index of tag
|
||||||
hasspass_position2 = this->recieverPage->toStdString().find(",-A,-A", hasspass_position1);
|
hasspass_position2 = this->recieverPage->toStdString().find(",-A,-A", hasspass_position1);
|
||||||
//finds the hass pass
|
//finds the hass pass
|
||||||
if (hasspass_position2 != std::string::npos) //found the hasspass! storing it
|
if (hasspass_position2 != std::string::npos) //found the hasspass! storing it
|
||||||
hasspass = recieverPage->mid(hasspass_position1,hasspass_position2-hasspass_position1);
|
hasspass = recieverPage->mid(hasspass_position1,hasspass_position2-hasspass_position1);
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
//finds the user id
|
//finds the user id
|
||||||
id_position1 = this->recieverPage->toStdString().find(constUserID_TAG.toStdString(), 0); //looking for hassid index
|
id_position1 = this->recieverPage->toStdString().find(constUserID_TAG.toStdString(), 0); //looking for hassid index
|
||||||
if (id_position1 == std::string::npos) //didnt find the tag
|
if (id_position1 == std::string::npos) //didnt find the tag
|
||||||
return false;
|
return false;
|
||||||
else
|
else
|
||||||
id_position1 += constUserID_TAG.length(); //skip the index of tag
|
id_position1 += constUserID_TAG.length(); //skip the index of tag
|
||||||
id_position2 = this->recieverPage->toStdString().find(",-A", id_position1);
|
id_position2 = this->recieverPage->toStdString().find(",-A", id_position1);
|
||||||
if (id_position2 != std::string::npos) //found the hassid! storing it
|
if (id_position2 != std::string::npos) //found the hassid! storing it
|
||||||
hassid = recieverPage->mid(id_position1,id_position2-id_position1);
|
hassid = recieverPage->mid(id_position1,id_position2-id_position1);
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
//setting user information with given data hassid and hasspass
|
//setting user information with given data hassid and hasspass
|
||||||
jceA->setHashedPassword(hasspass);
|
jceA->setHashedPassword(hasspass);
|
||||||
jceA->setUserID(hassid);
|
jceA->setUserID(hassid);
|
||||||
|
|
||||||
qDebug() << "jceLogin::checkValidation(); Found Hashed: " << hasspass << "And ID: " << hassid;
|
qDebug() << "jceLogin::checkValidation(); Found Hashed: " << hasspass << "And ID: " << hassid;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief jceLogin::setLoginFlag
|
* @brief jceLogin::setLoginFlag
|
||||||
|
@ -267,7 +272,7 @@ bool jceLogin::checkValidation()
|
||||||
*/
|
*/
|
||||||
void jceLogin::setLoginFlag(bool x)
|
void jceLogin::setLoginFlag(bool x)
|
||||||
{
|
{
|
||||||
this->loginFlag = x;
|
this->loginFlag = x;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief jceLogin::isLoginFlag checking if there is a connection, if true - > return if we signed in. otherwise, return not (not connected dough)
|
* @brief jceLogin::isLoginFlag checking if there is a connection, if true - > return if we signed in. otherwise, return not (not connected dough)
|
||||||
|
@ -275,9 +280,9 @@ void jceLogin::setLoginFlag(bool x)
|
||||||
*/
|
*/
|
||||||
bool jceLogin::isLoginFlag() const
|
bool jceLogin::isLoginFlag() const
|
||||||
{
|
{
|
||||||
if (checkConnection())
|
if (checkConnection())
|
||||||
return this->loginFlag;
|
return this->loginFlag;
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -286,5 +291,26 @@ bool jceLogin::isLoginFlag() const
|
||||||
*/
|
*/
|
||||||
QString jceLogin::getPage()
|
QString jceLogin::getPage()
|
||||||
{
|
{
|
||||||
return *recieverPage;
|
return *recieverPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
void jceLogin::reValidation()
|
||||||
|
{
|
||||||
|
qDebug() << Q_FUNC_INFO << "Revalidating user";
|
||||||
|
if (makeFirstVisit() == true)
|
||||||
|
{
|
||||||
|
if (checkValidation())
|
||||||
|
{
|
||||||
|
if (makeSecondVisit() == true)
|
||||||
|
qDebug() << Q_FUNC_INFO << "Validated";
|
||||||
|
else
|
||||||
|
qWarning() << Q_FUNC_INFO << "Second visit finished with an error";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
qDebug() << Q_FUNC_INFO << "checking validation ended with an error";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug() << Q_FUNC_INFO << "Couldnt Validate User";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,11 +5,17 @@
|
||||||
#include "./src/jceSettings/user.h"
|
#include "./src/jceSettings/user.h"
|
||||||
#include "jceLoginHtmlScripts.h"
|
#include "jceLoginHtmlScripts.h"
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
class jceLogin
|
|
||||||
|
class jceLogin : public QObject
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
jceLogin() {}
|
||||||
|
jceLogin(user* username);
|
||||||
|
~jceLogin();
|
||||||
|
|
||||||
enum jceStatus {
|
enum jceStatus {
|
||||||
JCE_NOT_CONNECTED,
|
JCE_NOT_CONNECTED,
|
||||||
|
@ -26,11 +32,7 @@ public:
|
||||||
JCE_GRADE_PAGE_PASSED
|
JCE_GRADE_PAGE_PASSED
|
||||||
};
|
};
|
||||||
|
|
||||||
jceLogin(user* username);
|
int makeConnection();
|
||||||
~jceLogin();
|
|
||||||
|
|
||||||
void makeConnection() throw (jceStatus);
|
|
||||||
void reConnect() throw (jceStatus);
|
|
||||||
void closeAll();
|
void closeAll();
|
||||||
|
|
||||||
bool checkConnection() const;
|
bool checkConnection() const;
|
||||||
|
@ -41,6 +43,13 @@ public:
|
||||||
|
|
||||||
QString getPage();
|
QString getPage();
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void reValidation();
|
||||||
|
void reMakeConnection();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void connectionReadyAfterDisconnection();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
int makeFirstVisit();
|
int makeFirstVisit();
|
||||||
|
|
|
@ -4,6 +4,15 @@
|
||||||
* This Static method will help parsing our debug messages to a readable Log file
|
* This Static method will help parsing our debug messages to a readable Log file
|
||||||
*
|
*
|
||||||
* timestamp - Message type - message
|
* timestamp - Message type - message
|
||||||
|
*
|
||||||
|
* Message types cam be:
|
||||||
|
*
|
||||||
|
* - DEBUG
|
||||||
|
* - WARNING
|
||||||
|
* - CRITICAL
|
||||||
|
* - FATAL
|
||||||
|
*
|
||||||
|
* Logs stored in a log file. File name is Stored in the Macro in Header file
|
||||||
*/
|
*/
|
||||||
void jce_logger::customMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
void jce_logger::customMessageHandler(QtMsgType type, const QMessageLogContext &context, const QString &msg)
|
||||||
{
|
{
|
||||||
|
@ -29,7 +38,7 @@ void jce_logger::customMessageHandler(QtMsgType type, const QMessageLogContext &
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
QFile outFile("J_M_Log.log");
|
QFile outFile(LOG_FILE_NAME);
|
||||||
outFile.open(QIODevice::WriteOnly | QIODevice::Append);
|
outFile.open(QIODevice::WriteOnly | QIODevice::Append);
|
||||||
|
|
||||||
QTextStream textStream(&outFile);
|
QTextStream textStream(&outFile);
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
|
|
||||||
|
#define LOG_FILE_NAME "J_M_Log.log"
|
||||||
|
|
||||||
class jce_logger
|
class jce_logger
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in a new issue