update statusbar

This commit is contained in:
liranbg 2014-10-13 01:14:26 +03:00
parent 1032c32013
commit 71d5e9b8b3
9 changed files with 79 additions and 58 deletions

View file

@ -24,19 +24,18 @@ bool loginHandler::login(QString username,QString password)
logout(); logout();
return false; return false;
} }
statusBar->setIconConnectionStatus(jceStatusBar::Connecting);
userPtr->setUsername(username); userPtr->setUsername(username);
userPtr->setPassword(password); userPtr->setPassword(password);
if (makeConnection() == true) if (makeConnection() == true)
{ {
statusBar->setIconConnectionStatus(jceStatusBar::LoggedIn);
loginButtonPtr->setText(QObject::tr("Logout")); loginButtonPtr->setText(QObject::tr("Logout"));
return isLoggedInFlag(); return isLoggedInFlag();
} }
else else
{ {
logout(); logout();
return false; return false;
} }
@ -101,6 +100,7 @@ void loginHandler::readyAfterConnectionLost()
{ {
qWarning() << Q_FUNC_INFO; qWarning() << Q_FUNC_INFO;
setLoginFlag(false); setLoginFlag(false);
statusBar->setIconConnectionStatus(jceStatusBar::Disconnected);
login(userPtr->getUsername(),userPtr->getPassword()); login(userPtr->getUsername(),userPtr->getPassword());
} }
@ -128,22 +128,32 @@ QString loginHandler::getCurrentPageContect()
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())
{
statusBar->setIconConnectionStatus(jceStatusBar::Sending);
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())
{
statusBar->setIconConnectionStatus(jceStatusBar::Sending);
return jceLog->getCalendar(year,semester); return jceLog->getCalendar(year,semester);
}
else else
return jceLogin::JCE_NOT_CONNECTED; return jceLogin::JCE_NOT_CONNECTED;
} }
int loginHandler::makeExamsScheduleRequest(int year, int semester) int loginHandler::makeExamsScheduleRequest(int year, int semester)
{ {
if (isLoggedInFlag()) if (isLoggedInFlag())
{
statusBar->setIconConnectionStatus(jceStatusBar::Sending);
return jceLog->getExams(year,semester); return jceLog->getExams(year,semester);
}
else else
return jceLogin::JCE_NOT_CONNECTED; return jceLogin::JCE_NOT_CONNECTED;
} }

View file

@ -3,8 +3,7 @@
jceStatusBar::jceStatusBar(QWidget *parent) : jceStatusBar::jceStatusBar(QWidget *parent) :
QStatusBar(parent) QStatusBar(parent)
{ {
this->setStyleSheet("QStatusBar { border: 0px solid black };");
this->setStyleSheet("QStatusBar::item { border: 0px solid black };");
this->setFixedHeight(STATUS_ICON_HEIGH+5); this->setFixedHeight(STATUS_ICON_HEIGH+5);
this->showMessage(tr("Ready")); this->showMessage(tr("Ready"));
@ -20,20 +19,21 @@ jceStatusBar::jceStatusBar(QWidget *parent) :
progressBar->setFixedWidth(120); progressBar->setFixedWidth(120);
progressBar->setFixedHeight(STATUS_ICON_HEIGH); progressBar->setFixedHeight(STATUS_ICON_HEIGH);
progressBar->setStyleSheet("#progressBar::horizontal {" progressBar->setStyleSheet("QProgressBar {"
"border: 1px solid gray;" "border: 1px solid gray;"
"border-radius: 3px;" "border-radius: 3px;"
"background: transparent;" "background: transparent;"
"padding: 1px;" "padding: 1px;"
"}" "}"
"#progressBar::chunk:horizontal {" "QProgressBar::chunk {"
"background: qlineargradient(x1: 0, y1: 0.5, x2: 1, y2: 0.5, stop: 0 green, stop: 1 white);" "background: qlineargradient(x1: 0, y1: 0.5, x2: 1, y2: 0.5, stop: 0 #b4e391 , stop: 1 #61c419);"
"}"); "}");
progressBar->setRange(0,100); progressBar->setRange(0,100);
progressBar->setValue(0); progressBar->setValue(0);
progressBar->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); progressBar->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
progressBar->setTextVisible(true); progressBar->setTextVisible(true);
progressBar->setFormat("%p%"); progressBar->setFormat("%p%");
progressBar->setOrientation(Qt::Horizontal);
addPermanentWidget(progressBar,0); addPermanentWidget(progressBar,0);
@ -46,29 +46,40 @@ void jceStatusBar::setIconConnectionStatus(jceProgressStatus update)
QPixmap iconPix; QPixmap iconPix;
switch (update) switch (update)
{ {
case jceProgressStatus::ERROR:
setProgressValue(0);
iconPix.load(":/icons/redStatusIcon.png");
showMessage(tr("Error"));
break;
case jceProgressStatus::Disconnected: case jceProgressStatus::Disconnected:
setProgressValue(0);
iconPix.load(":/icons/redStatusIcon.png"); iconPix.load(":/icons/redStatusIcon.png");
showMessage(tr("Disconnected")); showMessage(tr("Disconnected"));
break; break;
case jceProgressStatus::Ready: case jceProgressStatus::Ready:
setProgressValue(100);
iconPix.load(":/icons/redStatusIcon.png"); iconPix.load(":/icons/redStatusIcon.png");
showMessage(tr("Ready.")); showMessage(tr("Ready"));
break; break;
case jceProgressStatus::Connecting: case jceProgressStatus::Connecting:
setProgressValue(5);
iconPix.load(":/icons/blueStatusIcon.png"); iconPix.load(":/icons/blueStatusIcon.png");
showMessage(tr("Connecting...")); showMessage(tr("Connecting..."));
break; break;
case jceProgressStatus::Sending: case jceProgressStatus::Sending:
setProgressValue(10);
iconPix.load(":/icons/blueStatusIcon.png"); iconPix.load(":/icons/blueStatusIcon.png");
showMessage(tr("Sending.")); showMessage(tr("Sending..."));
break; break;
case jceProgressStatus::Recieving: case jceProgressStatus::Recieving:
setProgressValue(15);
iconPix.load(":/icons/blueStatusIcon.png"); iconPix.load(":/icons/blueStatusIcon.png");
showMessage(tr("Recieving.")); showMessage(tr("Recieving..."));
break; break;
case jceProgressStatus::Inserting: case jceProgressStatus::Inserting:
setProgressValue(80);
iconPix.load(":/icons/blueStatusIcon.png"); iconPix.load(":/icons/blueStatusIcon.png");
showMessage(tr("Inserting.")); showMessage(tr("Inserting"));
break; break;
case jceProgressStatus::LoggedIn: case jceProgressStatus::LoggedIn:
setProgressValue(100); setProgressValue(100);
@ -78,7 +89,7 @@ void jceStatusBar::setIconConnectionStatus(jceProgressStatus update)
case jceProgressStatus::Done: case jceProgressStatus::Done:
setProgressValue(100); setProgressValue(100);
iconPix.load(":/icons/greenStatusIcon.png"); iconPix.load(":/icons/greenStatusIcon.png");
showMessage(tr("Done.")); showMessage(tr("Done"));
break; break;
case jceProgressStatus::Connected: case jceProgressStatus::Connected:
setProgressValue(100); setProgressValue(100);
@ -97,7 +108,6 @@ void jceStatusBar::setIconConnectionStatus(jceProgressStatus update)
*/ */
void jceStatusBar::setProgressValue(int value) void jceStatusBar::setProgressValue(int value)
{ {
if (value == 0) if (value == 0)
{ {
progressBar->setVisible(false); progressBar->setVisible(false);

View file

@ -2,7 +2,7 @@
#define JCESTATUSBAR_H #define JCESTATUSBAR_H
#include <QDebug>
#include <QStatusBar> #include <QStatusBar>
#include <QProgressBar> #include <QProgressBar>
#include <QLabel> #include <QLabel>
@ -24,7 +24,8 @@ public:
Sending, Sending,
Recieving, Recieving,
Inserting, Inserting,
Done Done,
ERROR
}; };
jceStatusBar(QWidget *parent = 0); jceStatusBar(QWidget *parent = 0);

View file

@ -6,10 +6,6 @@ MainScreen::MainScreen(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainSc
{ {
ui->setupUi(this); ui->setupUi(this);
ui->labelMadeBy->setOpenExternalLinks(true);
//Login Tab //Login Tab
iconPix.load(":/icons/iconX.png"); iconPix.load(":/icons/iconX.png");
ui->pswdLineEdit->setEchoMode((QLineEdit::Password)); ui->pswdLineEdit->setEchoMode((QLineEdit::Password));
@ -129,8 +125,6 @@ void MainScreen::on_usrnmLineEdit_editingFinished()
//EVENTS ON GPA TAB //EVENTS ON GPA TAB
void MainScreen::on_ratesButton_clicked() void MainScreen::on_ratesButton_clicked()
{ {
// ui->progressBar->setValue(0);
qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName(); qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName();
if (!checkIfValidDates()) if (!checkIfValidDates())
{ {
@ -143,27 +137,28 @@ void MainScreen::on_ratesButton_clicked()
QApplication::setOverrideCursor(Qt::WaitCursor); QApplication::setOverrideCursor(Qt::WaitCursor);
if (loginHandel->isLoggedInFlag()) if (loginHandel->isLoggedInFlag())
{ {
// ui->statusBar->showMessage(tr("Getting grades...")); statusBar->setIconConnectionStatus(jceStatusBar::Ready);
if ((status = loginHandel->makeGradeRequest(ui->spinBoxCoursesFromYear->value(), if ((status = loginHandel->makeGradeRequest(ui->spinBoxCoursesFromYear->value(),
ui->spinBoxCoursesToYear->value(),ui->spinBoxCoursesFromSemester->value(), ui->spinBoxCoursesToYear->value(),ui->spinBoxCoursesFromSemester->value(),
ui->spinBoxCoursesToSemester->value())) == jceLogin::JCE_PAGE_PASSED) ui->spinBoxCoursesToSemester->value())) == jceLogin::JCE_PAGE_PASSED)
{ {
qDebug() << Q_FUNC_INFO << "grade page is ready"; qDebug() << Q_FUNC_INFO << "grade page is ready";
// ui->statusBar->showMessage(tr("Done. Inserting data into table..."),1000); statusBar->setIconConnectionStatus(jceStatusBar::Inserting);
pageString = loginHandel->getCurrentPageContect(); pageString = loginHandel->getCurrentPageContect();
courseTableMgr->setCoursesList(pageString); courseTableMgr->setCoursesList(pageString);
courseTableMgr->insertJceCoursesIntoTable(); courseTableMgr->insertJceCoursesIntoTable();
// ui->progressBar->setValue(100); statusBar->setIconConnectionStatus(jceStatusBar::Done);
// ui->statusBar->showMessage(tr("Done"));
} }
else if (status == jceLogin::JCE_NOT_CONNECTED) else if (status == jceLogin::JCE_NOT_CONNECTED)
{ {
qWarning() << Q_FUNC_INFO << "not connected"; qWarning() << Q_FUNC_INFO << "not connected";
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
QMessageBox::critical(this,tr("Error"),tr("Not Connected")); QMessageBox::critical(this,tr("Error"),tr("Not Connected"));
statusBar->setIconConnectionStatus(jceStatusBar::Disconnected);
} }
else else
{ {
statusBar->setIconConnectionStatus(jceStatusBar::ERROR);
qCritical() << Q_FUNC_INFO << "grade get ended with" << status; qCritical() << Q_FUNC_INFO << "grade get ended with" << status;
} }
} }
@ -241,18 +236,16 @@ void MainScreen::on_examsBtn_clicked()
} }
void MainScreen::on_getCalendarBtn_clicked() void MainScreen::on_getCalendarBtn_clicked()
{ {
// ui->progressBar->setValue(0);
qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName(); qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName();
int status = 0; int status = 0;
QString page; QString page;
QApplication::setOverrideCursor(Qt::WaitCursor); QApplication::setOverrideCursor(Qt::WaitCursor);
if (loginHandel->isLoggedInFlag()) if (loginHandel->isLoggedInFlag())
{ {
// ui->statusBar->showMessage(tr("Getting schedule..."));
if ((status = loginHandel->makeCalendarRequest(ui->spinBoxYear->value(),ui->spinBoxSemester->value())) == jceLogin::JCE_PAGE_PASSED) if ((status = loginHandel->makeCalendarRequest(ui->spinBoxYear->value(),ui->spinBoxSemester->value())) == jceLogin::JCE_PAGE_PASSED)
{ {
statusBar->setIconConnectionStatus(jceStatusBar::Inserting);
calendar->resetTable(); calendar->resetTable();
// ui->statusBar->showMessage(tr("Done. Inserting schdule into table..."),1000);
page = loginHandel->getCurrentPageContect(); page = loginHandel->getCurrentPageContect();
calendar->setCalendar(page); calendar->setCalendar(page);
@ -261,32 +254,29 @@ void MainScreen::on_getCalendarBtn_clicked()
//auto getting exam //auto getting exam
if (loginHandel->isLoggedInFlag()) if (loginHandel->isLoggedInFlag())
{ {
// ui->statusBar->showMessage(tr("Getting exams..."));
if ((status = loginHandel->makeExamsScheduleRequest(ui->spinBoxYear->value(),ui->spinBoxSemester->value())) == jceLogin::JCE_PAGE_PASSED) if ((status = loginHandel->makeExamsScheduleRequest(ui->spinBoxYear->value(),ui->spinBoxSemester->value())) == jceLogin::JCE_PAGE_PASSED)
{ {
// ui->statusBar->showMessage(tr("Done."),1000);
page = loginHandel->getCurrentPageContect(); page = loginHandel->getCurrentPageContect();
calendar->setExamsSchedule(page); calendar->setExamsSchedule(page);
qDebug() << Q_FUNC_INFO << "exams schedule is loaded"; qDebug() << Q_FUNC_INFO << "exams schedule is loaded";
statusBar->setIconConnectionStatus(jceStatusBar::Done);
} }
else if (status == jceLogin::JCE_NOT_CONNECTED) else if (status == jceLogin::JCE_NOT_CONNECTED)
{ {
qWarning() << Q_FUNC_INFO << "not connected"; qWarning() << Q_FUNC_INFO << "not connected";
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
QMessageBox::critical(this,tr("Error"),tr("Not Connected")); QMessageBox::critical(this,tr("Error"),tr("Not Connected"));
statusBar->setIconConnectionStatus(jceStatusBar::Disconnected);
} }
else else
qCritical() << Q_FUNC_INFO << "exams request get ended with" << status; qCritical() << Q_FUNC_INFO << "exams request get ended with" << status;
// ui->progressBar->setValue(100);
// ui->statusBar->showMessage(tr("Done"));
} }
else if (status == jceLogin::JCE_NOT_CONNECTED) else if (status == jceLogin::JCE_NOT_CONNECTED)
{ {
qWarning() << Q_FUNC_INFO << "not connected"; qWarning() << Q_FUNC_INFO << "not connected";
QApplication::restoreOverrideCursor(); QApplication::restoreOverrideCursor();
QMessageBox::critical(this,tr("Error"),tr("Not Connected")); QMessageBox::critical(this,tr("Error"),tr("Not Connected"));
statusBar->setIconConnectionStatus(jceStatusBar::Disconnected);
} }
else else
qCritical() << Q_FUNC_INFO << "calendar get ended with" << status; qCritical() << Q_FUNC_INFO << "calendar get ended with" << status;
@ -405,8 +395,6 @@ void MainScreen::checkLocale()
void MainScreen::on_labelMadeBy_linkActivated(const QString &link) void MainScreen::on_labelMadeBy_linkActivated(const QString &link)
{ {
qDebug() << Q_FUNC_INFO << "link: " << link; qDebug() << Q_FUNC_INFO << "link: " << link;
} }

View file

@ -49,6 +49,16 @@ background: qlineargradient(spread:pad, x1:0.496, y1:0, x2:0.508, y2:1, stop:0 r
<string notr="true"/> <string notr="true"/>
</property> </property>
<layout class="QGridLayout" name="gridLayout_13"> <layout class="QGridLayout" name="gridLayout_13">
<item row="1" column="0">
<widget class="QLabel" name="labelMadeBy">
<property name="text">
<string>&lt;p align=&quot;center&quot;&gt;Made By &lt;a href=&quot;http://liranbg.github.io/JceManager/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;JceManager&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0"> <item row="0" column="0">
<widget class="QTabWidget" name="tabWidget"> <widget class="QTabWidget" name="tabWidget">
<property name="enabled"> <property name="enabled">
@ -899,13 +909,6 @@ font-size: 15px;
</widget> </widget>
</widget> </widget>
</item> </item>
<item row="1" column="0">
<widget class="QLabel" name="labelMadeBy">
<property name="text">
<string>&lt;p align=&quot;center&quot;&gt;Made By &lt;a href=&quot;http://liranbg.github.io/JceManager/&quot;&gt;&lt;span style=&quot; text-decoration: underline; color:#0000ff;&quot;&gt;JceManager&lt;/span&gt;&lt;/a&gt;&lt;/p&gt;</string>
</property>
</widget>
</item>
</layout> </layout>
</widget> </widget>
<widget class="QMenuBar" name="menuBar"> <widget class="QMenuBar" name="menuBar">
@ -914,7 +917,7 @@ font-size: 15px;
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1133</width> <width>1133</width>
<height>21</height> <height>22</height>
</rect> </rect>
</property> </property>
<widget class="QMenu" name="menuA_about"> <widget class="QMenu" name="menuA_about">

View file

@ -3,10 +3,10 @@
/** /**
* @brief jceSSLClient::jceSSLClient Constructer, setting the signals * @brief jceSSLClient::jceSSLClient Constructer, setting the signals
*/ */
jceSSLClient::jceSSLClient(jceStatusBar *progressbarPtr) : loggedIAndConnectedFlag(false), readingFlag(false), jceSSLClient::jceSSLClient(jceStatusBar *statusBar) : loggedIAndConnectedFlag(false), readingFlag(false),
reConnectionFlag(false), networkConf(), packet(""), recieveLastPacket(false), packetSizeRecieved(0) reConnectionFlag(false), networkConf(), packet(""), recieveLastPacket(false), packetSizeRecieved(0)
{ {
this->progressBar = progressbarPtr; this->statusBar = statusBar;
//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()));
@ -131,6 +131,7 @@ bool jceSSLClient::sendData(QString str)
int amount = 0; int amount = 0;
if (isConnected()) //if connected if (isConnected()) //if connected
{ {
statusBar->setIconConnectionStatus(jceStatusBar::Sending);
amount = write(str.toStdString().c_str(),str.length()); amount = write(str.toStdString().c_str(),str.length());
qDebug() << Q_FUNC_INFO << "lenght send: " << str.length() << "lenght recieved: " << amount; qDebug() << Q_FUNC_INFO << "lenght send: " << str.length() << "lenght recieved: " << amount;
if (amount == -1) if (amount == -1)
@ -151,6 +152,7 @@ bool jceSSLClient::sendData(QString str)
*/ */
bool jceSSLClient::recieveData(QString *str) bool jceSSLClient::recieveData(QString *str)
{ {
statusBar->setIconConnectionStatus(jceStatusBar::Recieving);
qDebug() << Q_FUNC_INFO << "Data receiving!"; qDebug() << Q_FUNC_INFO << "Data receiving!";
str->clear(); str->clear();
packet = ""; packet = "";
@ -208,7 +210,7 @@ void jceSSLClient::readIt()
packet.append("\0"); packet.append("\0");
readerAppendingLocker.unlock(); readerAppendingLocker.unlock();
emit progressBar->progressHasPacket(6); emit statusBar->progressHasPacket(10);
if (tempPacket.contains("Go_To_system_After_Login.htm") || tempPacket.contains("</html>")) if (tempPacket.contains("Go_To_system_After_Login.htm") || tempPacket.contains("</html>"))
{ {

View file

@ -20,7 +20,7 @@ class jceSSLClient : public QSslSocket
{ {
Q_OBJECT Q_OBJECT
public: public:
jceSSLClient(jceStatusBar *progressbarPtr); jceSSLClient(jceStatusBar *statusBar);
bool makeConnect(QString server = "yedion.jce.ac.il", int port = 443); bool makeConnect(QString server = "yedion.jce.ac.il", int port = 443);
bool makeDiconnect(); bool makeDiconnect();
@ -64,7 +64,7 @@ private:
jceStatusBar *progressBar; //progressbar pointer jceStatusBar *statusBar; //progressbar pointer
}; };

View file

@ -4,12 +4,12 @@
* @brief jceLogin::jceLogin * @brief jceLogin::jceLogin
* @param username pointer to allocated user settings * @param username pointer to allocated user settings
*/ */
jceLogin::jceLogin(user* username, jceStatusBar *progressbarPtr) jceLogin::jceLogin(user* username, jceStatusBar *statusBar)
{ {
this->progressBar = progressbarPtr; this->statusBar = statusBar;
this->recieverPage = new QString(); this->recieverPage = new QString();
this->jceA = username; this->jceA = username;
this->JceConnector = new jceSSLClient(progressBar); this->JceConnector = new jceSSLClient(statusBar);
QObject::connect(JceConnector,SIGNAL(serverDisconnectedbyRemote()),this,SLOT(reValidation())); QObject::connect(JceConnector,SIGNAL(serverDisconnectedbyRemote()),this,SLOT(reValidation()));
QObject::connect(JceConnector,SIGNAL(noInternetLink()),this,SLOT(reMakeConnection())); QObject::connect(JceConnector,SIGNAL(noInternetLink()),this,SLOT(reMakeConnection()));
} }
@ -28,7 +28,7 @@ jceLogin::~jceLogin()
*/ */
int jceLogin::makeConnection() int jceLogin::makeConnection()
{ {
qDebug() << "jceLogin::makeConnection(); connection to be make"; qDebug() << Q_FUNC_INFO << "connection to be make";
if (this->recieverPage == NULL) if (this->recieverPage == NULL)
this->recieverPage = new QString(); this->recieverPage = new QString();
@ -40,6 +40,7 @@ int jceLogin::makeConnection()
if (returnMode == false) if (returnMode == false)
{ {
statusBar->setIconConnectionStatus(jceStatusBar::Connecting);
if (JceConnector->makeConnect(dst_host,dst_port) == false) //couldnt make a connection if (JceConnector->makeConnect(dst_host,dst_port) == false) //couldnt make a connection
return jceStatus::ERROR_ON_OPEN_SOCKET; return jceStatus::ERROR_ON_OPEN_SOCKET;
else else
@ -48,6 +49,7 @@ int jceLogin::makeConnection()
if (returnMode == true) //connected to host if (returnMode == true) //connected to host
{ {
statusBar->setIconConnectionStatus(jceStatusBar::Connected);
returnMode = makeFirstVisit(); returnMode = makeFirstVisit();
if (returnMode == true) //requst and send first validation if (returnMode == true) //requst and send first validation
{ {
@ -62,6 +64,7 @@ int jceLogin::makeConnection()
qDebug() << Q_FUNC_INFO << "Signed in succeesfully"; qDebug() << Q_FUNC_INFO << "Signed in succeesfully";
status = jceStatus::JCE_YOU_ARE_IN; status = jceStatus::JCE_YOU_ARE_IN;
setLoginFlag(true); setLoginFlag(true);
statusBar->setIconConnectionStatus(jceStatusBar::LoggedIn);
} }
else if (returnMode == jceLogin::ERROR_ON_GETTING_INFO) else if (returnMode == jceLogin::ERROR_ON_GETTING_INFO)
{ {
@ -93,6 +96,8 @@ int jceLogin::makeConnection()
else else
status = jceStatus::JCE_NOT_CONNECTED; status = jceStatus::JCE_NOT_CONNECTED;
if (status != jceStatus::JCE_YOU_ARE_IN)
statusBar->setIconConnectionStatus(jceStatusBar::ERROR);
//we throw status even if we are IN! //we throw status even if we are IN!
qDebug() << Q_FUNC_INFO << "return status: " << status; qDebug() << Q_FUNC_INFO << "return status: " << status;
return status; return status;
@ -114,6 +119,7 @@ bool jceLogin::checkConnection() const
*/ */
void jceLogin::closeAll() void jceLogin::closeAll()
{ {
statusBar->setIconConnectionStatus(jceStatusBar::Disconnected);
this->JceConnector->makeDiconnect(); this->JceConnector->makeDiconnect();
if ((this->recieverPage != NULL) && (!this->recieverPage->isEmpty())) if ((this->recieverPage != NULL) && (!this->recieverPage->isEmpty()))
{ {
@ -134,7 +140,7 @@ void jceLogin::reMakeConnection()
recieverPage = NULL; recieverPage = NULL;
JceConnector = NULL; JceConnector = NULL;
this->recieverPage = new QString(); this->recieverPage = new QString();
this->JceConnector = new jceSSLClient(progressBar); this->JceConnector = new jceSSLClient(statusBar);
QObject::connect(JceConnector,SIGNAL(serverDisconnectedbyRemote()),this,SLOT(reValidation())); QObject::connect(JceConnector,SIGNAL(serverDisconnectedbyRemote()),this,SLOT(reValidation()));
QObject::connect(JceConnector,SIGNAL(noInternetLink()),this,SLOT(reMakeConnection())); QObject::connect(JceConnector,SIGNAL(noInternetLink()),this,SLOT(reMakeConnection()));
emit connectionReadyAfterDisconnection(); emit connectionReadyAfterDisconnection();
@ -148,6 +154,7 @@ 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)) if (!JceConnector->recieveData(recieverPage))

View file

@ -16,7 +16,7 @@ class jceLogin : public QObject
Q_OBJECT Q_OBJECT
public: public:
jceLogin(user* username,jceStatusBar *progressbarPtr); jceLogin(user* username, jceStatusBar *statusBar);
~jceLogin(); ~jceLogin();
enum jceStatus { enum jceStatus {
@ -65,7 +65,7 @@ private:
QString * recieverPage; QString * recieverPage;
user * jceA; user * jceA;
jceSSLClient * JceConnector; jceSSLClient * JceConnector;
jceStatusBar *progressBar; jceStatusBar *statusBar;
}; };