added relogin, reconnection, changed pointer allocation
This commit is contained in:
parent
68bd693dd8
commit
256b9085a9
|
@ -1,14 +1,53 @@
|
||||||
#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()
|
||||||
|
@ -16,72 +55,55 @@ 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);
|
||||||
|
|
||||||
usrnmEditPtr->setDisabled(false);
|
|
||||||
pswdEditPtr->setDisabled(false);
|
|
||||||
|
|
||||||
pswdEditPtr->selectAll();
|
|
||||||
pswdEditPtr->setFocus();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
case jceLogin::ERROR_ON_VALIDATION_USER_BLOCKED:
|
case jceLogin::ERROR_ON_VALIDATION_USER_BLOCKED:
|
||||||
{
|
{
|
||||||
popMessage(QObject::tr("You have been blocked by JCE, please try in a couple of minutes."));
|
popMessage(QObject::tr("You have been blocked by JCE, please try in a couple of minutes."));
|
||||||
jceLog->closeAll();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
case jceLogin::ERROR_ON_OPEN_SOCKET:
|
case jceLogin::ERROR_ON_OPEN_SOCKET:
|
||||||
{
|
{
|
||||||
popMessage(QObject::tr("Please Check Your Internet Connection."));
|
popMessage(QObject::tr("Please Check Your Internet Connection."));
|
||||||
jceLog->closeAll();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
case jceLogin::JCE_NOT_CONNECTED:
|
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;
|
break;
|
||||||
}
|
}
|
||||||
case jceLogin::ERROR_ON_GETTING_INFO:
|
case jceLogin::ERROR_ON_GETTING_INFO:
|
||||||
{
|
{
|
||||||
popMessage(QObject::tr("Receive Request Timeout."));
|
popMessage(QObject::tr("Receive Request Timeout."));
|
||||||
jceLog->closeAll();
|
|
||||||
return false;
|
return false;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
case jceLogin::ERROR_ON_SEND_REQUEST:
|
case jceLogin::ERROR_ON_SEND_REQUEST:
|
||||||
{
|
{
|
||||||
popMessage(QObject::tr("Send Request Timeout."));
|
popMessage(QObject::tr("Send Request Timeout."));
|
||||||
jceLog->closeAll();
|
|
||||||
return false;
|
return false;
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
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
|
||||||
|
@ -90,12 +112,10 @@ bool loginHandler::isLoggedInFlag()
|
||||||
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;
|
||||||
|
@ -106,13 +126,6 @@ QString loginHandler::getCurrentPageContect()
|
||||||
|
|
||||||
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())
|
||||||
|
@ -120,7 +133,6 @@ int loginHandler::makeGradeRequest(int fromYear, int toYear, int fromSemester, i
|
||||||
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())
|
||||||
|
@ -128,6 +140,32 @@ int loginHandler::makeCalendarRequest(int year, int 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)
|
||||||
|
|
|
@ -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;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -15,14 +15,10 @@ 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, Calendar Tab
|
//Course, Calendar Tab
|
||||||
calendarSchedule * calendarSchedulePtr = new calendarSchedule();
|
calendarSchedule * calendarSchedulePtr = new calendarSchedule();
|
||||||
|
@ -32,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();
|
||||||
|
|
||||||
|
@ -48,11 +44,8 @@ MainScreen::MainScreen(QWidget *parent) :QMainWindow(parent), ui(new Ui::MainScr
|
||||||
checkLocale();
|
checkLocale();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MainScreen::~MainScreen()
|
MainScreen::~MainScreen()
|
||||||
{
|
{
|
||||||
delete ButtomStatusLabel;
|
|
||||||
delete statusLabel;
|
|
||||||
delete calendar;
|
delete calendar;
|
||||||
delete courseTableMgr;
|
delete courseTableMgr;
|
||||||
delete userLoginSetting;
|
delete userLoginSetting;
|
||||||
|
@ -61,34 +54,48 @@ MainScreen::~MainScreen()
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
//EVENTS ON STATUS BAR
|
//EVENTS ON STATUS BAR
|
||||||
void MainScreen::setLabelConnectionStatus(jceLogin::jceStatus statusDescription)
|
|
||||||
{
|
|
||||||
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
|
else
|
||||||
uiSetConnectMode();
|
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
|
||||||
|
{
|
||||||
|
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()
|
||||||
{
|
{
|
||||||
|
@ -104,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()
|
||||||
{
|
{
|
||||||
|
@ -224,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);
|
||||||
|
@ -278,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,10 +247,6 @@ void MainScreen::on_actionHow_To_triggered()
|
||||||
"<br><li>"+tr("HELP5")+"</li>"
|
"<br><li>"+tr("HELP5")+"</li>"
|
||||||
"</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())
|
||||||
|
@ -326,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())
|
||||||
|
@ -340,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,19 +70,13 @@ 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;
|
|
||||||
QLabel *statusLabel;
|
|
||||||
QPixmap iconPix;
|
QPixmap iconPix;
|
||||||
|
|
||||||
user *userLoginSetting;
|
user *userLoginSetting;
|
||||||
SaveData *data;
|
SaveData *data;
|
||||||
|
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -17,7 +17,6 @@ jceSSLClient::jceSSLClient() : flag(false), packet(""), networkConf(), reConnect
|
||||||
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
|
||||||
|
@ -26,6 +25,9 @@ jceSSLClient::jceSSLClient() : flag(false), packet(""), networkConf(), reConnect
|
||||||
*/
|
*/
|
||||||
bool jceSSLClient::makeConnect(QString server, int port)
|
bool jceSSLClient::makeConnect(QString server, int port)
|
||||||
{
|
{
|
||||||
|
if (this->networkConf.isOnline() == false)
|
||||||
|
return false;
|
||||||
|
|
||||||
if (reConnection) //reset reconnectiong flag
|
if (reConnection) //reset reconnectiong flag
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << "Making Reconnection";
|
qDebug() << Q_FUNC_INFO << "Making Reconnection";
|
||||||
|
@ -39,7 +41,6 @@ bool jceSSLClient::makeConnect(QString server, int port)
|
||||||
makeDiconnect();
|
makeDiconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
qDebug() << Q_FUNC_INFO << "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);
|
||||||
|
|
||||||
|
@ -182,12 +183,13 @@ void jceSSLClient::setOnlineState(bool isOnline)
|
||||||
qWarning() << Q_FUNC_INFO << "isOnline status change: " << isOnline;
|
qWarning() << Q_FUNC_INFO << "isOnline status change: " << isOnline;
|
||||||
if (isOnline) //to be added later
|
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
|
//we can add here auto reconnect if wifi\ethernet link has appear
|
||||||
//will be added next version
|
//will be added next version
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//abort() ?
|
qWarning() << Q_FUNC_INFO << "Online State has been changed. emitting NoInternetLink";
|
||||||
this->makeDiconnect();
|
this->makeDiconnect();
|
||||||
emit noInternetLink();
|
emit noInternetLink();
|
||||||
}
|
}
|
||||||
|
@ -212,6 +214,7 @@ void jceSSLClient::setDisconnected()
|
||||||
if (reConnection)
|
if (reConnection)
|
||||||
makeConnect();
|
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.
|
||||||
|
@ -348,8 +351,6 @@ void jceSSLClient::showIfErrorMsg()
|
||||||
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
|
||||||
* @param a includes the error enum from QAbstractSocket::SocketError enum list
|
* @param a includes the error enum from QAbstractSocket::SocketError enum list
|
||||||
|
|
|
@ -10,6 +10,7 @@ jceLogin::jceLogin(user* username)
|
||||||
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(serverDisconnectedbyRemote()),this,SLOT(reValidation()));
|
||||||
|
QObject::connect(JceConnector,SIGNAL(noInternetLink()),this,SLOT(reMakeConnection()));
|
||||||
}
|
}
|
||||||
|
|
||||||
jceLogin::~jceLogin()
|
jceLogin::~jceLogin()
|
||||||
|
@ -24,7 +25,7 @@ jceLogin::~jceLogin()
|
||||||
* @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";
|
||||||
|
|
||||||
|
@ -37,8 +38,12 @@ void jceLogin::makeConnection() throw (jceStatus)
|
||||||
returnMode = checkConnection(); //checking socket status. is connected?
|
returnMode = checkConnection(); //checking socket status. is connected?
|
||||||
|
|
||||||
if (returnMode == false)
|
if (returnMode == false)
|
||||||
|
{
|
||||||
if (JceConnector->makeConnect(dst_host,dst_port) == false) //couldnt make a connection
|
if (JceConnector->makeConnect(dst_host,dst_port) == false) //couldnt make a connection
|
||||||
throw jceStatus::ERROR_ON_OPEN_SOCKET;
|
return jceStatus::ERROR_ON_OPEN_SOCKET;
|
||||||
|
else
|
||||||
|
returnMode = true;
|
||||||
|
}
|
||||||
|
|
||||||
if (returnMode == true) //connected to host
|
if (returnMode == true) //connected to host
|
||||||
{
|
{
|
||||||
|
@ -88,8 +93,8 @@ void jceLogin::makeConnection() throw (jceStatus)
|
||||||
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;
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -103,36 +108,35 @@ bool jceLogin::checkConnection() const
|
||||||
|
|
||||||
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();
|
||||||
|
if ((this->recieverPage != NULL) && (!this->recieverPage->isEmpty()))
|
||||||
|
{
|
||||||
delete recieverPage;
|
delete recieverPage;
|
||||||
recieverPage = NULL;
|
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();
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -309,18 +313,4 @@ void jceLogin::reValidation()
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << "Couldnt Validate User";
|
qDebug() << Q_FUNC_INFO << "Couldnt Validate User";
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
delete recieverPage;
|
|
||||||
recieverPage = NULL;
|
|
||||||
if (this->JceConnector != NULL)
|
|
||||||
delete JceConnector;
|
|
||||||
this->recieverPage = new QString();
|
|
||||||
this->JceConnector = new jceSSLClient();
|
|
||||||
if (makeFirstVisit() == true)
|
|
||||||
{
|
|
||||||
if (checkValidation())
|
|
||||||
{
|
|
||||||
if (makeSecondVisit() == true)
|
|
||||||
*/
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,10 +32,7 @@ public:
|
||||||
JCE_GRADE_PAGE_PASSED
|
JCE_GRADE_PAGE_PASSED
|
||||||
};
|
};
|
||||||
|
|
||||||
|
int makeConnection();
|
||||||
|
|
||||||
void makeConnection() throw (jceStatus);
|
|
||||||
void reConnect() throw (jceStatus);
|
|
||||||
void closeAll();
|
void closeAll();
|
||||||
|
|
||||||
bool checkConnection() const;
|
bool checkConnection() const;
|
||||||
|
@ -48,6 +45,10 @@ public:
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void reValidation();
|
void reValidation();
|
||||||
|
void reMakeConnection();
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void connectionReadyAfterDisconnection();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue