added progress bar
;
This commit is contained in:
parent
26cbfbd576
commit
2ef44eff00
|
@ -1,19 +1,26 @@
|
||||||
#include "loginhandler.h"
|
#include "loginhandler.h"
|
||||||
|
|
||||||
loginHandler::loginHandler(user *ptr, QStatusBar *statusBarPtr,QPushButton *loginButtonPtr): logggedInFlag(false)
|
loginHandler::loginHandler(user *ptr, QStatusBar *statusBarPtr,QPushButton *loginButtonPtr,QProgressBar *progressbarPtr): logggedInFlag(false)
|
||||||
{
|
{
|
||||||
this->loginButtonPtr = loginButtonPtr;
|
this->loginButtonPtr = loginButtonPtr;
|
||||||
|
this->progressBar = progressbarPtr;
|
||||||
|
|
||||||
//statusBar
|
//statusBar
|
||||||
statusBar = statusBarPtr;
|
statusBar = statusBarPtr;
|
||||||
iconButtomStatusLabel = new QLabel();
|
iconButtomStatusLabel = new QLabel(statusBarPtr);
|
||||||
|
iconButtomStatusLabel->setAlignment(Qt::AlignHCenter);
|
||||||
|
|
||||||
|
//display progressbar and then ball icon.
|
||||||
|
statusBar->addPermanentWidget(progressBar,0);
|
||||||
statusBar->addPermanentWidget(iconButtomStatusLabel,0);
|
statusBar->addPermanentWidget(iconButtomStatusLabel,0);
|
||||||
|
|
||||||
setIconConnectionStatus(jceLogin::jceStatus::JCE_NOT_CONNECTED);
|
setIconConnectionStatus(jceLogin::jceStatus::JCE_NOT_CONNECTED);
|
||||||
|
|
||||||
//user settings
|
//user settings
|
||||||
userPtr = ptr;
|
userPtr = ptr;
|
||||||
this->jceLog = new jceLogin(userPtr);
|
this->jceLog = new jceLogin(userPtr,progressBar);
|
||||||
QObject::connect(this->jceLog,SIGNAL(connectionReadyAfterDisconnection()),this,SLOT(readyAfterConnectionLost()));
|
QObject::connect(this->jceLog,SIGNAL(connectionReadyAfterDisconnection()),this,SLOT(readyAfterConnectionLost()));
|
||||||
|
|
||||||
}
|
}
|
||||||
bool loginHandler::login(QString username,QString password)
|
bool loginHandler::login(QString username,QString password)
|
||||||
{
|
{
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QStatusBar>
|
#include <QStatusBar>
|
||||||
|
#include <QProgressBar>
|
||||||
#include <QPushButton>
|
#include <QPushButton>
|
||||||
|
|
||||||
#include "./src/jceSettings/jcelogin.h"
|
#include "./src/jceSettings/jcelogin.h"
|
||||||
|
@ -17,7 +18,7 @@ class loginHandler : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
loginHandler(user *ptr, QStatusBar *statusBarPtr,QPushButton *loginButtonPtr);
|
loginHandler(user *ptr, QStatusBar *statusBarPtr, QPushButton *loginButtonPtr, QProgressBar *progressbarPtr);
|
||||||
~loginHandler()
|
~loginHandler()
|
||||||
{
|
{
|
||||||
delete iconButtomStatusLabel;
|
delete iconButtomStatusLabel;
|
||||||
|
@ -51,6 +52,7 @@ private:
|
||||||
QStatusBar *statusBar;
|
QStatusBar *statusBar;
|
||||||
QLabel *iconButtomStatusLabel;
|
QLabel *iconButtomStatusLabel;
|
||||||
QPushButton *loginButtonPtr;
|
QPushButton *loginButtonPtr;
|
||||||
|
QProgressBar *progressBar;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -9,13 +9,13 @@
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
#ifdef QT_DEBUG // Incase QtCreator is in Debug mode all qDebug messages will go to terminal
|
#ifdef QT_DEBUG // Incase QtCreator is in Debug mode all qDebug messages will go to terminal
|
||||||
qDebug() << "Running a debug build";
|
qDebug() << Q_FUNC_INFO << "Running a debug build";
|
||||||
#else // If QtCreator is on Release mode , qDebug messages will be logged in a log file.
|
#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";
|
qDebug() << Q_FUNC_INFO << "Start : JCE Manager Launched";
|
||||||
|
|
||||||
QApplication a(argc, argv);
|
QApplication a(argc, argv);
|
||||||
QTranslator translator;
|
QTranslator translator;
|
||||||
|
@ -27,13 +27,13 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
QString locale = QLocale::system().name();
|
QString locale = QLocale::system().name();
|
||||||
translator.load("jce_"+locale , a.applicationDirPath());
|
translator.load("jce_"+locale , a.applicationDirPath());
|
||||||
qDebug() << "Local : Default Local Loaded";
|
qDebug() << Q_FUNC_INFO << "Local : Default Local Loaded";
|
||||||
}else if(loco == "he"){
|
}else if(loco == "he"){
|
||||||
translator.load("jce_he" , a.applicationDirPath());
|
translator.load("jce_he" , a.applicationDirPath());
|
||||||
qDebug() << "Local : Hebrew Local Loaded";
|
qDebug() << Q_FUNC_INFO << "Local : Hebrew Local Loaded";
|
||||||
}else{
|
}else{
|
||||||
translator.load("jce_en" , a.applicationDirPath());
|
translator.load("jce_en" , a.applicationDirPath());
|
||||||
qDebug() << "Local : English Local Loaded";
|
qDebug() << Q_FUNC_INFO << "Local : English Local Loaded";
|
||||||
}
|
}
|
||||||
a.installTranslator(&translator); //Setting local
|
a.installTranslator(&translator); //Setting local
|
||||||
MainScreen w;
|
MainScreen w;
|
||||||
|
@ -42,8 +42,8 @@ int main(int argc, char *argv[])
|
||||||
//Getting the exit code from QApplication. for debug reasons
|
//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() << Q_FUNC_INFO << "End : JCE Manager Ended Successfully With A Return Code: " << returnCode;
|
||||||
else
|
else
|
||||||
qCritical() << "End : JCE Manager Ended Unusccessfully With A Return Code: " << returnCode;
|
qCritical() << Q_FUNC_INFO << "End : JCE Manager Ended Unusccessfully With A Return Code: " << returnCode;
|
||||||
return returnCode;
|
return returnCode;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,9 @@
|
||||||
#include "ui_mainscreen.h"
|
#include "ui_mainscreen.h"
|
||||||
|
|
||||||
|
|
||||||
MainScreen::MainScreen(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainScreen)
|
MainScreen::MainScreen(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainScreen), busyFlag()
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
//this->setFixedSize(this->size()); //main not resizeable
|
|
||||||
|
|
||||||
ui->labelMadeBy->setOpenExternalLinks(true);
|
ui->labelMadeBy->setOpenExternalLinks(true);
|
||||||
|
|
||||||
|
@ -17,9 +16,11 @@ MainScreen::MainScreen(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainSc
|
||||||
ui->labelUsrInputStatus->setPixmap(iconPix);
|
ui->labelUsrInputStatus->setPixmap(iconPix);
|
||||||
ui->labelPswInputStatus->setPixmap(iconPix);
|
ui->labelPswInputStatus->setPixmap(iconPix);
|
||||||
|
|
||||||
//StatusBar
|
|
||||||
|
//StatusBar & progressbar
|
||||||
|
ui->progressBar->setFixedHeight(STATUS_ICON_HEIGH);
|
||||||
ui->statusBar->setStyleSheet("QStatusBar::item { border: 0px solid black };");
|
ui->statusBar->setStyleSheet("QStatusBar::item { border: 0px solid black };");
|
||||||
ui->statusBar->setFixedHeight(STATUS_ICON_HEIGH);
|
ui->statusBar->setFixedHeight(STATUS_ICON_HEIGH+5);
|
||||||
ui->statusBar->showMessage(tr("Ready"));
|
ui->statusBar->showMessage(tr("Ready"));
|
||||||
|
|
||||||
//GPA Tab
|
//GPA Tab
|
||||||
|
@ -29,9 +30,10 @@ MainScreen::MainScreen(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainSc
|
||||||
qDebug() << Q_FUNC_INFO << "Allocating pointers";
|
qDebug() << Q_FUNC_INFO << "Allocating pointers";
|
||||||
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,ui->statusBar,ui->loginButton);
|
this->loginHandel = new loginHandler(userLoginSetting,ui->statusBar,ui->loginButton,ui->progressBar);
|
||||||
this->calendar = new CalendarManager(ui->calendarGridLayoutMain);
|
this->calendar = new CalendarManager(ui->calendarGridLayoutMain);
|
||||||
this->data = new SaveData();
|
this->data = new SaveData();
|
||||||
|
busyFlag = false;
|
||||||
|
|
||||||
//check login File
|
//check login File
|
||||||
if (data->isSaved())
|
if (data->isSaved())
|
||||||
|
@ -45,6 +47,7 @@ MainScreen::MainScreen(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainSc
|
||||||
//language
|
//language
|
||||||
qDebug() << Q_FUNC_INFO << "Checking locale";
|
qDebug() << Q_FUNC_INFO << "Checking locale";
|
||||||
checkLocale();
|
checkLocale();
|
||||||
|
ui->statusBar->repaint();
|
||||||
qDebug() << Q_FUNC_INFO << "Ready.";
|
qDebug() << Q_FUNC_INFO << "Ready.";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -61,6 +64,7 @@ MainScreen::~MainScreen()
|
||||||
//EVENTS ON LOGIN TAB
|
//EVENTS ON LOGIN TAB
|
||||||
void MainScreen::on_loginButton_clicked()
|
void MainScreen::on_loginButton_clicked()
|
||||||
{
|
{
|
||||||
|
ui->progressBar->setValue(0);
|
||||||
qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName();
|
qDebug() << Q_FUNC_INFO << "in: " << ui->tabWidget->currentWidget()->objectName();
|
||||||
if ((ui->usrnmLineEdit->text().isEmpty()) || (ui->pswdLineEdit->text().isEmpty()))
|
if ((ui->usrnmLineEdit->text().isEmpty()) || (ui->pswdLineEdit->text().isEmpty()))
|
||||||
{
|
{
|
||||||
|
@ -89,6 +93,7 @@ void MainScreen::on_loginButton_clicked()
|
||||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||||
if (this->loginHandel->login(ui->usrnmLineEdit->text(),ui->pswdLineEdit->text()) == true)
|
if (this->loginHandel->login(ui->usrnmLineEdit->text(),ui->pswdLineEdit->text()) == true)
|
||||||
{
|
{
|
||||||
|
ui->progressBar->setValue(100);
|
||||||
qDebug() << Q_FUNC_INFO << "login session end with true";
|
qDebug() << Q_FUNC_INFO << "login session end with true";
|
||||||
ui->pswdLineEdit->setDisabled(true);
|
ui->pswdLineEdit->setDisabled(true);
|
||||||
ui->usrnmLineEdit->setDisabled(true);
|
ui->usrnmLineEdit->setDisabled(true);
|
||||||
|
@ -129,6 +134,7 @@ 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())
|
||||||
{
|
{
|
||||||
|
@ -139,16 +145,20 @@ void MainScreen::on_ratesButton_clicked()
|
||||||
QString pageString;
|
QString pageString;
|
||||||
int status = 0;
|
int status = 0;
|
||||||
QApplication::setOverrideCursor(Qt::WaitCursor);
|
QApplication::setOverrideCursor(Qt::WaitCursor);
|
||||||
if (loginHandel->isLoggedInFlag())
|
if (loginHandel->isLoggedInFlag() && !busyFlag)
|
||||||
{
|
{
|
||||||
|
ui->statusBar->showMessage(tr("Getting grades..."));
|
||||||
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);
|
||||||
pageString = loginHandel->getCurrentPageContect();
|
pageString = loginHandel->getCurrentPageContect();
|
||||||
courseTableMgr->setCoursesList(pageString);
|
courseTableMgr->setCoursesList(pageString);
|
||||||
courseTableMgr->insertJceCoursesIntoTable();
|
courseTableMgr->insertJceCoursesIntoTable();
|
||||||
|
ui->progressBar->setValue(100);
|
||||||
|
ui->statusBar->showMessage(tr("Done"));
|
||||||
}
|
}
|
||||||
else if (status == jceLogin::JCE_NOT_CONNECTED)
|
else if (status == jceLogin::JCE_NOT_CONNECTED)
|
||||||
{
|
{
|
||||||
|
@ -160,6 +170,7 @@ void MainScreen::on_ratesButton_clicked()
|
||||||
{
|
{
|
||||||
qCritical() << Q_FUNC_INFO << "grade get ended with" << status;
|
qCritical() << Q_FUNC_INFO << "grade get ended with" << status;
|
||||||
}
|
}
|
||||||
|
busyFlag = true;
|
||||||
}
|
}
|
||||||
QApplication::restoreOverrideCursor();
|
QApplication::restoreOverrideCursor();
|
||||||
}
|
}
|
||||||
|
@ -221,18 +232,24 @@ void MainScreen::on_clearTableButton_clicked()
|
||||||
//EVENTS ON CALENDAR TAB
|
//EVENTS ON CALENDAR TAB
|
||||||
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;
|
||||||
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)
|
||||||
{
|
{
|
||||||
|
|
||||||
//Use it for debug. add plain text and change the object name to 'plainTextEdit' so you will get the html request
|
//Use it for debug. add plain text and change the object name to 'plainTextEdit' so you will get the html request
|
||||||
//ui->plainTextEdit->setPlainText(loginHandel->getCurrentPageContect());
|
//ui->plainTextEdit->setPlainText(loginHandel->getCurrentPageContect());
|
||||||
calendar->resetTable();
|
calendar->resetTable();
|
||||||
|
ui->statusBar->showMessage(tr("Done. Inserting schdule into table..."),1000);
|
||||||
calendar->setCalendar(loginHandel->getCurrentPageContect());
|
calendar->setCalendar(loginHandel->getCurrentPageContect());
|
||||||
|
ui->progressBar->setValue(100);
|
||||||
qDebug() << Q_FUNC_INFO << "calendar is loaded";
|
qDebug() << Q_FUNC_INFO << "calendar is loaded";
|
||||||
|
ui->statusBar->showMessage(tr("Done"));
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (status == jceLogin::JCE_NOT_CONNECTED)
|
else if (status == jceLogin::JCE_NOT_CONNECTED)
|
||||||
|
|
|
@ -83,6 +83,8 @@ private:
|
||||||
coursesTableManager *courseTableMgr;
|
coursesTableManager *courseTableMgr;
|
||||||
loginHandler *loginHandel;
|
loginHandler *loginHandel;
|
||||||
|
|
||||||
|
bool busyFlag;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // MAINSCREEN_H
|
#endif // MAINSCREEN_H
|
||||||
|
|
|
@ -626,6 +626,45 @@ font-size: 15px;
|
||||||
</widget>
|
</widget>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<widget class="QProgressBar" name="progressBar">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Minimum">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="styleSheet">
|
||||||
|
<string notr="true">#progressBar::horizontal {
|
||||||
|
border: 1px solid gray;
|
||||||
|
border-radius: 3px;
|
||||||
|
background: white;
|
||||||
|
padding: 1px;
|
||||||
|
}
|
||||||
|
#progressBar::chunk:horizontal {
|
||||||
|
background: qlineargradient(x1: 0, y1: 0.5, x2: 1, y2: 0.5, stop: 0 green, stop: 1 white);
|
||||||
|
}</string>
|
||||||
|
</property>
|
||||||
|
<property name="value">
|
||||||
|
<number>0</number>
|
||||||
|
</property>
|
||||||
|
<property name="alignment">
|
||||||
|
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
|
<property name="textVisible">
|
||||||
|
<bool>true</bool>
|
||||||
|
</property>
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="invertedAppearance">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
<property name="textDirection">
|
||||||
|
<enum>QProgressBar::TopToBottom</enum>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="labelMadeBy">
|
<widget class="QLabel" name="labelMadeBy">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
|
|
@ -3,14 +3,16 @@
|
||||||
/**
|
/**
|
||||||
* @brief jceSSLClient::jceSSLClient Constructer, setting the signals
|
* @brief jceSSLClient::jceSSLClient Constructer, setting the signals
|
||||||
*/
|
*/
|
||||||
jceSSLClient::jceSSLClient() : flag(false), packet(""),networkConf(), reConnection(false)
|
jceSSLClient::jceSSLClient(QProgressBar *progressbarPtr) : flag(false), packet(""),networkConf(), reConnection(false)
|
||||||
{
|
{
|
||||||
|
this->progressBar = progressbarPtr;
|
||||||
//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)));
|
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()));
|
||||||
|
@ -149,32 +151,34 @@ bool jceSSLClient::recieveData(QString &str, bool fast)
|
||||||
|
|
||||||
if (fast) //fast mode connection, good only for login step!!!!
|
if (fast) //fast mode connection, good only for login step!!!!
|
||||||
{
|
{
|
||||||
qDebug() << "jceSSLClient::recieveData login step receiving";
|
qDebug() << Q_FUNC_INFO << "login step receiving";
|
||||||
QEventLoop loop;
|
//loop will exit after first read packet.
|
||||||
connect(this, SIGNAL(readyRead()), &loop, SLOT(quit()));
|
//meanwhile packet will gain data. good for small amount of data - fast connection!
|
||||||
|
connect(this, SIGNAL(readyRead()), &readerLoop, SLOT(quit()));
|
||||||
connect(this, SIGNAL(readyRead()), this, SLOT(readIt()));
|
connect(this, SIGNAL(readyRead()), this, SLOT(readIt()));
|
||||||
loop.exec();
|
readerLoop.exec();
|
||||||
disconnect(this, SIGNAL(readyRead()), &loop, SLOT(quit()));
|
disconnect(this, SIGNAL(readyRead()), &readerLoop, SLOT(quit()));
|
||||||
disconnect(this, SIGNAL(readyRead()), this, SLOT(readIt()));
|
disconnect(this, SIGNAL(readyRead()), this, SLOT(readIt()));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug() << "jceSSLClient::recieveData normal receiving";
|
qDebug() << Q_FUNC_INFO << "normal receiving";
|
||||||
QString p;
|
//loop will exit after timeout \ full data
|
||||||
while (waitForReadyRead(milisTimeOut))
|
connect(this, SIGNAL(packetHasData()), &readerLoop, SLOT(quit()));
|
||||||
{
|
|
||||||
do
|
timer.setSingleShot(true);
|
||||||
{
|
connect(&timer, SIGNAL(timeout()), &readerLoop, SLOT(quit()));
|
||||||
p = readAll();
|
connect(this, SIGNAL(readyRead()), this, SLOT(readItAll()));
|
||||||
packet.append(p);
|
timer.start(5000);
|
||||||
}while (p.size() > 0);
|
readerLoop.exec();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
str = packet;
|
str = packet;
|
||||||
qDebug() << Q_FUNC_INFO << "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() << Q_FUNC_INFO << "return with flag: " << sflag;
|
qDebug() << Q_FUNC_INFO << "return with flag: " << sflag;
|
||||||
|
disconnect(this, SIGNAL(readyRead()), this, SLOT(readItAll()));
|
||||||
return sflag;
|
return sflag;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -188,9 +192,27 @@ void jceSSLClient::readIt()
|
||||||
{
|
{
|
||||||
p = readAll();
|
p = readAll();
|
||||||
packet.append(p);
|
packet.append(p);
|
||||||
|
this->progressBar->setValue(this->progressBar->value() + 6);
|
||||||
}while (p.size() > 0);
|
}while (p.size() > 0);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
void jceSSLClient::readItAll()
|
||||||
|
{
|
||||||
|
QString p;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
p = "";
|
||||||
|
p = read(bytesAvailable());
|
||||||
|
if (p.contains("</tbody>") == true)
|
||||||
|
{
|
||||||
|
qDebug() << "we have the end!";
|
||||||
|
timer.setInterval(1000);
|
||||||
|
}
|
||||||
|
this->progressBar->setValue(this->progressBar->value() + 6);
|
||||||
|
// qDebug() << "p lenght" << p.length();
|
||||||
|
packet.append(p);
|
||||||
|
}while (p.size() > 0);
|
||||||
|
}
|
||||||
|
|
||||||
void jceSSLClient::setOnlineState(bool isOnline)
|
void jceSSLClient::setOnlineState(bool isOnline)
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QNetworkConfigurationManager>
|
#include <QNetworkConfigurationManager>
|
||||||
#include <QtNetwork/QNetworkInterface>
|
#include <QtNetwork/QNetworkInterface>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QProgressBar>
|
||||||
|
|
||||||
#define milisTimeOut 4000
|
#define milisTimeOut 4000
|
||||||
|
|
||||||
|
@ -15,7 +17,7 @@ class jceSSLClient : public QSslSocket
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
jceSSLClient();
|
jceSSLClient(QProgressBar *progressbarPtr);
|
||||||
|
|
||||||
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();
|
||||||
|
@ -28,6 +30,7 @@ signals:
|
||||||
void serverDisconnectedbyRemote();
|
void serverDisconnectedbyRemote();
|
||||||
void noInternetLink();
|
void noInternetLink();
|
||||||
void socketDisconnected();
|
void socketDisconnected();
|
||||||
|
void packetHasData();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void checkErrors(QAbstractSocket::SocketError a);
|
void checkErrors(QAbstractSocket::SocketError a);
|
||||||
|
@ -35,6 +38,7 @@ private slots:
|
||||||
void setEncrypted();
|
void setEncrypted();
|
||||||
void setDisconnected();
|
void setDisconnected();
|
||||||
void readIt();
|
void readIt();
|
||||||
|
void readItAll();
|
||||||
void setOnlineState(bool isOnline);
|
void setOnlineState(bool isOnline);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -42,9 +46,13 @@ private:
|
||||||
bool flag;
|
bool flag;
|
||||||
QString packet;
|
QString packet;
|
||||||
QEventLoop loop; //handle the connection as thread
|
QEventLoop loop; //handle the connection as thread
|
||||||
|
QEventLoop readerLoop;
|
||||||
|
QTimer timer;
|
||||||
QNetworkConfigurationManager networkConf; //checking if online
|
QNetworkConfigurationManager networkConf; //checking if online
|
||||||
bool reConnection; //used for remote host disconnecting
|
bool reConnection; //used for remote host disconnecting
|
||||||
|
|
||||||
|
QProgressBar *progressBar; //
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // JCESSLCLIENT_H
|
#endif // JCESSLCLIENT_H
|
||||||
|
|
|
@ -4,11 +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)
|
jceLogin::jceLogin(user* username, QProgressBar *progressbarPtr)
|
||||||
{
|
{
|
||||||
|
this->progressBar = progressbarPtr;
|
||||||
this->recieverPage = new QString();
|
this->recieverPage = new QString();
|
||||||
this->jceA = username;
|
this->jceA = username;
|
||||||
this->JceConnector = new jceSSLClient();
|
this->JceConnector = new jceSSLClient(progressBar);
|
||||||
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()));
|
||||||
}
|
}
|
||||||
|
@ -133,7 +134,7 @@ void jceLogin::reMakeConnection()
|
||||||
recieverPage = NULL;
|
recieverPage = NULL;
|
||||||
JceConnector = NULL;
|
JceConnector = NULL;
|
||||||
this->recieverPage = new QString();
|
this->recieverPage = new QString();
|
||||||
this->JceConnector = new jceSSLClient();
|
this->JceConnector = new jceSSLClient(progressBar);
|
||||||
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();
|
||||||
|
@ -297,6 +298,7 @@ QString jceLogin::getPage()
|
||||||
void jceLogin::reValidation()
|
void jceLogin::reValidation()
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << "Revalidating user";
|
qDebug() << Q_FUNC_INFO << "Revalidating user";
|
||||||
|
|
||||||
if (makeFirstVisit() == true)
|
if (makeFirstVisit() == true)
|
||||||
{
|
{
|
||||||
if (checkValidation())
|
if (checkValidation())
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
#include "jceLoginHtmlScripts.h"
|
#include "jceLoginHtmlScripts.h"
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
#include <QProgressBar>
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
|
|
||||||
|
@ -13,8 +14,8 @@ class jceLogin : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
jceLogin() {}
|
|
||||||
jceLogin(user* username);
|
jceLogin(user* username,QProgressBar *progressbarPtr);
|
||||||
~jceLogin();
|
~jceLogin();
|
||||||
|
|
||||||
enum jceStatus {
|
enum jceStatus {
|
||||||
|
@ -61,6 +62,7 @@ private:
|
||||||
QString * recieverPage;
|
QString * recieverPage;
|
||||||
user * jceA;
|
user * jceA;
|
||||||
jceSSLClient * JceConnector;
|
jceSSLClient * JceConnector;
|
||||||
|
QProgressBar *progressBar;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue