added relogin, reconnection, changed pointer allocation

This commit is contained in:
liranbg 2014-09-22 05:04:38 +03:00
parent 68bd693dd8
commit 256b9085a9
8 changed files with 263 additions and 296 deletions

View file

@ -1,143 +1,181 @@
#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;
this->pswdEditPtr = pswdEditPtr;
this->usrnmEditPtr = usrnmEditPtr;
qDebug() << Q_FUNC_INFO << "Login with username and password";
if (isLoggedInFlag())
{
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()
{
if (this->jceLog == NULL)
return false;
if (this->jceLog == NULL)
return false;
try
{
jceLog->makeConnection();
}
catch (jceLogin::jceStatus &a)
{
int status = (int)a;
int status = (int)jceLog->makeConnection();
switch (status)
{
case jceLogin::JCE_YOU_ARE_IN:
{
logggedInFlag = true;
return logggedInFlag;
break;
}
case jceLogin::ERROR_ON_VALIDATION:
{
popMessage(QObject::tr("Please Check Your Username & Password"),false);
{
case jceLogin::JCE_YOU_ARE_IN:
{
logggedInFlag = true;
return logggedInFlag;
}
case jceLogin::ERROR_ON_VALIDATION:
{
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);
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;
return false;
}
void loginHandler::readyAfterConnectionLost()
{
qWarning() << Q_FUNC_INFO;
setLoginFlag(false);
login(userPtr->getUsername(),userPtr->getPassword());
}
bool loginHandler::isLoggedInFlag()
{
if (jceLog->isLoginFlag()) //checking connection and then if logged in
return this->logggedInFlag;
else
this->setLoginFlag(false);
return false;
if (jceLog->isLoginFlag()) //checking connection and then if logged in
return this->logggedInFlag;
else
this->setLoginFlag(false);
return false;
}
void loginHandler::setLoginFlag(bool flag)
{
this->logggedInFlag = flag;
this->logggedInFlag = flag;
}
QString loginHandler::getCurrentPageContect()
{
QTextEdit phrase;
if (isLoggedInFlag())
phrase.setText(jceLog->getPage());
else
throw jceLogin::ERROR_ON_GETTING_INFO;
QTextEdit phrase;
if (isLoggedInFlag())
phrase.setText(jceLog->getPage());
else
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)
{
if (isLoggedInFlag())
return jceLog->getGrades(fromYear, toYear, fromSemester, toSemester);
else
return jceLogin::JCE_NOT_CONNECTED;
if (isLoggedInFlag())
return jceLog->getGrades(fromYear, toYear, fromSemester, toSemester);
else
return jceLogin::JCE_NOT_CONNECTED;
}
int loginHandler::makeCalendarRequest(int year, int semester)
{
if (isLoggedInFlag())
return jceLog->getCalendar(year,semester);
else
return jceLogin::JCE_NOT_CONNECTED;
if (isLoggedInFlag())
return jceLog->getCalendar(year,semester);
else
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)
{
if (addInfo)
message.append(QObject::tr("\nIf this message appear without reason, please contact me at liranbg@gmail.com"));
if (addInfo)
message.append(QObject::tr("\nIf this message appear without reason, please contact me at liranbg@gmail.com"));
QMessageBox msgBox;
msgBox.setWindowTitle(QObject::tr("Error"));
msgBox.setText(message);
msgBox.exec();
msgBox.setFocus();
QMessageBox msgBox;
msgBox.setWindowTitle(QObject::tr("Error"));
msgBox.setText(message);
msgBox.exec();
msgBox.setFocus();
}

View file

@ -2,43 +2,55 @@
#define LOGINHANDLER_H
#include <QObject>
#include <QString>
#include <QLabel>
#include <QLineEdit>
#include <QTextEdit>
#include <QLabel>
#include <QMessageBox>
#include <QPixmap>
#include <QStatusBar>
#include <QPushButton>
#include "./src/jceSettings/jcelogin.h"
#include "./src/appDatabase/savedata.h"
class loginHandler
class loginHandler : public QObject
{
Q_OBJECT
public:
loginHandler(user *ptr);
void setPointers(QLabel *statusLabelPtr,QLineEdit *pswdEditPtr,QLineEdit *usrnmEditPtr);
loginHandler(user *ptr, QStatusBar *statusBarPtr,QPushButton *loginButtonPtr);
~loginHandler()
{
delete iconButtomStatusLabel;
delete jceLog;
}
bool login(QString username,QString password);
void logout();
void setIconConnectionStatus(jceLogin::jceStatus statusDescription);
bool makeConnection();
bool isLoggedInFlag();
void setLoginFlag(bool flag);
QString getCurrentPageContect();
int makeGradeRequest(int fromYear, int toYear, int fromSemester, int toSemester);
int makeCalendarRequest(int year,int semester);
void makeDisconnectionRequest();
private slots:
void readyAfterConnectionLost();
private:
void popMessage(QString message, bool addInfo = true);
bool logggedInFlag;
jceLogin *jceLog;
QLabel *statusLabelPtr;
QLineEdit *pswdEditPtr;
QLineEdit *usrnmEditPtr;
jceLogin * jceLog;
user * userPtr;
QStatusBar *statusBar;
QLabel *iconButtomStatusLabel;
QPushButton *loginButtonPtr;
};

View file

@ -15,14 +15,10 @@ MainScreen::MainScreen(QWidget *parent) :QMainWindow(parent), ui(new Ui::MainScr
ui->labelUsrInputStatus->setPixmap(iconPix);
ui->labelPswInputStatus->setPixmap(iconPix);
//Status Bar
//StatusBar
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->addPermanentWidget(ButtomStatusLabel,0);
ui->statusBar->addPermanentWidget(statusLabel,1);
setLabelConnectionStatus(jceLogin::jceStatus::JCE_NOT_CONNECTED);
ui->statusBar->showMessage(tr("Ready"));
//Course, Calendar Tab
calendarSchedule * calendarSchedulePtr = new calendarSchedule();
@ -32,7 +28,7 @@ MainScreen::MainScreen(QWidget *parent) :QMainWindow(parent), ui(new Ui::MainScr
//Pointer allocating
this->userLoginSetting = new user("","");
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->data = new SaveData();
@ -48,11 +44,8 @@ MainScreen::MainScreen(QWidget *parent) :QMainWindow(parent), ui(new Ui::MainScr
checkLocale();
}
MainScreen::~MainScreen()
{
delete ButtomStatusLabel;
delete statusLabel;
delete calendar;
delete courseTableMgr;
delete userLoginSetting;
@ -61,34 +54,48 @@ MainScreen::~MainScreen()
delete ui;
}
//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
void MainScreen::on_loginButton_clicked()
{
if (loginHandel->isLoggedInFlag())
uiSetDisconnectMode();
qDebug() << Q_FUNC_INFO;
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
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()
{
@ -104,74 +111,7 @@ void MainScreen::on_usrnmLineEdit_editingFinished()
{
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
void MainScreen::on_ratesButton_clicked()
{
@ -224,7 +164,6 @@ void MainScreen::on_spinBoxCoursesFromYear_valueChanged(int arg1)
{
ui->spinBoxCoursesFromYear->setValue(arg1);
}
void MainScreen::on_spinBoxCoursesToYear_valueChanged(int arg1)
{
ui->spinBoxCoursesToYear->setValue(arg1);
@ -278,20 +217,19 @@ void MainScreen::on_exportToCVSBtn_clicked()
}
}
//EVENTS ON MENU BAR
void MainScreen::on_actionCredits_triggered()
{
QMessageBox::about(this, "About", tr("CREDITS-ROOL-UP1") + " v1.0<br><br>"
+ tr("CREDITS-ROOL-UP2")+"<br>GNU LESSER GENERAL PUBLIC LICENSE V2<br>"
+ tr("CREDITS-ROOL-UP3")+"<br>"
"<a href='https://github.com/liranbg/jceAverageCalculator'>jceAverageCalculator Repository</a>"
"<br><br>"+tr("CREDITS-ROOL-UP4")+"<a href='https://github.com/liranbg/jceConnection'> Jce Connection</a><br><br>"
"<a href='https://github.com/liranbg/jceAverageCalculator'>jceAverageCalculator Repository</a>"
"<br><br>"+tr("CREDITS-ROOL-UP4")+"<a href='https://github.com/liranbg/jceConnection'> Jce Connection</a><br><br>"
+tr("DevBy")+":"
"<ul>"
"<li><a href='mailto:liranbg@gmail.com'>"+tr("Liran")+"</a></li>"
"<li><a href='mailto:sagidayan@gmail.com'>"+tr("Sagi")+"</a></li>"
"</ul>");
"<ul>"
"<li><a href='mailto:liranbg@gmail.com'>"+tr("Liran")+"</a></li>"
"<li><a href='mailto:sagidayan@gmail.com'>"+tr("Sagi")+"</a></li>"
"</ul>");
}
void MainScreen::on_actionExit_triggered()
{
@ -303,16 +241,12 @@ void MainScreen::on_actionHow_To_triggered()
"<b>How To..</b>"
"<ul>"
"<br><li>"+tr("HELP1")+"</li>"
"<br><li>"+tr("HELP2")+"</li>"
"<br><li>"+tr("HELP3")+"</li>"
"<br><li>"+tr("HELP4")+"</li>"
"<br><li>"+tr("HELP5")+"</li>"
"</ul>");
"<br><li>"+tr("HELP2")+"</li>"
"<br><li>"+tr("HELP3")+"</li>"
"<br><li>"+tr("HELP4")+"</li>"
"<br><li>"+tr("HELP5")+"</li>"
"</ul>");
}
void MainScreen::on_actionHebrew_triggered()
{
if (ui->actionEnglish->isChecked() || ui->actionOS_Default->isChecked())
@ -326,7 +260,6 @@ void MainScreen::on_actionHebrew_triggered()
else
ui->actionHebrew->setChecked(true);
}
void MainScreen::on_actionEnglish_triggered()
{
if (ui->actionHebrew->isChecked() || ui->actionOS_Default->isChecked())
@ -340,8 +273,6 @@ void MainScreen::on_actionEnglish_triggered()
else
ui->actionEnglish->setChecked(true);
}
void MainScreen::on_actionOS_Default_triggered()
{
if (ui->actionHebrew->isChecked() || ui->actionEnglish->isChecked())

View file

@ -70,19 +70,13 @@ private slots:
private:
void uiSetDisconnectMode();
void uiSetConnectMode();
void setLabelConnectionStatus(jceLogin::jceStatus statusDescription);
void checkLocale();
bool checkIfValidDates();
Ui::MainScreen *ui;
QLabel *ButtomStatusLabel;
QLabel *statusLabel;
QPixmap iconPix;
user *userLoginSetting;
SaveData *data;

View file

@ -345,7 +345,7 @@ font-size: 15px;
<item>
<widget class="QPushButton" name="ratesButton">
<property name="enabled">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="whatsThis">
<string>&lt;html&gt;&lt;head/&gt;&lt;body&gt;&lt;p&gt;&lt;span style=&quot; font-weight:600;&quot;&gt;Get your grades&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</string>

View file

@ -17,7 +17,6 @@ jceSSLClient::jceSSLClient() : flag(false), packet(""), networkConf(), reConnect
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.
* @param server - server to connect to
@ -26,6 +25,9 @@ jceSSLClient::jceSSLClient() : flag(false), packet(""), networkConf(), reConnect
*/
bool jceSSLClient::makeConnect(QString server, int port)
{
if (this->networkConf.isOnline() == false)
return false;
if (reConnection) //reset reconnectiong flag
{
qDebug() << Q_FUNC_INFO << "Making Reconnection";
@ -39,7 +41,6 @@ bool jceSSLClient::makeConnect(QString server, int port)
makeDiconnect();
}
qDebug() << Q_FUNC_INFO << "Connection to: " << server << "On Port: " << port;
connectToHostEncrypted(server.toStdString().c_str(), port);
@ -182,12 +183,13 @@ 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
{
//abort() ?
qWarning() << Q_FUNC_INFO << "Online State has been changed. emitting NoInternetLink";
this->makeDiconnect();
emit noInternetLink();
}
@ -212,6 +214,7 @@ void jceSSLClient::setDisconnected()
if (reConnection)
makeConnect();
}
/**
* @brief jceSSLClient::setEncrypted called when signaled with encrypted. setting the buffer size and keeping alive.
@ -348,8 +351,6 @@ void jceSSLClient::showIfErrorMsg()
msgBox.exec();
}
}
/**
* @brief jceSSLClient::checkErrors this function exctuing when socket error has occured
* @param a includes the error enum from QAbstractSocket::SocketError enum list

View file

@ -10,6 +10,7 @@ jceLogin::jceLogin(user* username)
this->jceA = username;
this->JceConnector = new jceSSLClient();
QObject::connect(JceConnector,SIGNAL(serverDisconnectedbyRemote()),this,SLOT(reValidation()));
QObject::connect(JceConnector,SIGNAL(noInternetLink()),this,SLOT(reMakeConnection()));
}
jceLogin::~jceLogin()
@ -24,7 +25,7 @@ jceLogin::~jceLogin()
* @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
*/
void jceLogin::makeConnection() throw (jceStatus)
int jceLogin::makeConnection()
{
qDebug() << "jceLogin::makeConnection(); connection to be make";
@ -37,8 +38,12 @@ void jceLogin::makeConnection() throw (jceStatus)
returnMode = checkConnection(); //checking socket status. is connected?
if (returnMode == false)
{
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
{
@ -88,8 +93,8 @@ void jceLogin::makeConnection() throw (jceStatus)
status = jceStatus::JCE_NOT_CONNECTED;
//we throw status even if we are IN!
qDebug() << "jceLogin::makeConnection(); throw status: " << status;
throw status;
qDebug() << "jceLogin::makeConnection(); return status: " << status;
return status;
}
/**
@ -103,36 +108,35 @@ bool jceLogin::checkConnection() const
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
*/
void jceLogin::closeAll()
{
JceConnector->makeDiconnect();
delete recieverPage;
this->JceConnector->makeDiconnect();
if ((this->recieverPage != NULL) && (!this->recieverPage->isEmpty()))
{
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();
}
/**
@ -309,18 +313,4 @@ void jceLogin::reValidation()
{
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)
*/
}

View file

@ -32,10 +32,7 @@ public:
JCE_GRADE_PAGE_PASSED
};
void makeConnection() throw (jceStatus);
void reConnect() throw (jceStatus);
int makeConnection();
void closeAll();
bool checkConnection() const;
@ -48,6 +45,10 @@ public:
private slots:
void reValidation();
void reMakeConnection();
signals:
void connectionReadyAfterDisconnection();
private: