changing socket engine
This commit is contained in:
parent
0246b8bcef
commit
01f49ddfc7
5 changed files with 173 additions and 152 deletions
|
@ -64,7 +64,7 @@ background: qlineargradient(spread:pad, x1:0.496, y1:0, x2:0.508, y2:1, stop:0 r
|
||||||
<enum>QTabWidget::Rounded</enum>
|
<enum>QTabWidget::Rounded</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>2</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<property name="documentMode">
|
<property name="documentMode">
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
/**
|
/**
|
||||||
* @brief jceSSLClient::jceSSLClient Constructer, setting the signals
|
* @brief jceSSLClient::jceSSLClient Constructer, setting the signals
|
||||||
*/
|
*/
|
||||||
jceSSLClient::jceSSLClient(QProgressBar *progressbarPtr) : flag(false), packet(""),networkConf(), reConnection(false)
|
jceSSLClient::jceSSLClient(QProgressBar *progressbarPtr) : loggedIAndConnectedFlag(false), readingFlag(false),
|
||||||
|
reConnectionFlag(false), networkConf(), packet(""), recieveLastPacket(false), packetSizeRecieved(0)
|
||||||
{
|
{
|
||||||
this->progressBar = progressbarPtr;
|
this->progressBar = progressbarPtr;
|
||||||
//setting signals
|
//setting signals
|
||||||
|
@ -14,8 +15,8 @@ jceSSLClient::jceSSLClient(QProgressBar *progressbarPtr) : flag(false), packet("
|
||||||
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()), &loginThreadLoop, SLOT(quit()));
|
||||||
connect(this, SIGNAL(error(QAbstractSocket::SocketError)),&loop,SLOT(quit()));
|
connect(this, SIGNAL(error(QAbstractSocket::SocketError)),&loginThreadLoop,SLOT(quit()));
|
||||||
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
|
@ -43,7 +44,7 @@ bool jceSSLClient::makeConnect(QString server, int port)
|
||||||
qDebug() << Q_FUNC_INFO << "we're online";
|
qDebug() << Q_FUNC_INFO << "we're online";
|
||||||
|
|
||||||
|
|
||||||
if (reConnection) //reset reconnectiong flag
|
if (reConnectionFlag) //reset reconnectiong flag
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << "Making Reconnection";
|
qDebug() << Q_FUNC_INFO << "Making Reconnection";
|
||||||
}
|
}
|
||||||
|
@ -59,12 +60,12 @@ bool jceSSLClient::makeConnect(QString server, int port)
|
||||||
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);
|
||||||
|
|
||||||
loop.exec(); //starting connection, waiting to encryption and then it ends
|
loginThreadLoop.exec(); //starting connection, waiting to encryption and then it ends
|
||||||
|
|
||||||
qDebug() << Q_FUNC_INFO << "returning the connection status: " << isConnected();
|
qDebug() << Q_FUNC_INFO << "returning the connection status: " << isConnected();
|
||||||
if (reConnection)
|
if (reConnectionFlag)
|
||||||
{
|
{
|
||||||
reConnection = false;
|
reConnectionFlag = false;
|
||||||
emit serverDisconnectedbyRemote();
|
emit serverDisconnectedbyRemote();
|
||||||
}
|
}
|
||||||
return isConnected();
|
return isConnected();
|
||||||
|
@ -76,10 +77,10 @@ bool jceSSLClient::makeConnect(QString server, int port)
|
||||||
*/
|
*/
|
||||||
bool jceSSLClient::makeDiconnect()
|
bool jceSSLClient::makeDiconnect()
|
||||||
{
|
{
|
||||||
if (loop.isRunning())
|
if (loginThreadLoop.isRunning())
|
||||||
{
|
{
|
||||||
qWarning() << Q_FUNC_INFO << "Killing connection thread";
|
qWarning() << Q_FUNC_INFO << "Killing connection thread";
|
||||||
loop.exit();
|
loginThreadLoop.exit();
|
||||||
}
|
}
|
||||||
qDebug() << Q_FUNC_INFO << "disconnecting from host and emitting disconnected()";
|
qDebug() << Q_FUNC_INFO << "disconnecting from host and emitting disconnected()";
|
||||||
this->disconnectFromHost(); //emits disconnected > setDisconnected
|
this->disconnectFromHost(); //emits disconnected > setDisconnected
|
||||||
|
@ -117,7 +118,7 @@ bool jceSSLClient::isConnected()
|
||||||
}
|
}
|
||||||
if (!isConnectedToNetwork()) //no link, ethernet\wifi
|
if (!isConnectedToNetwork()) //no link, ethernet\wifi
|
||||||
tempFlag = false;
|
tempFlag = false;
|
||||||
return ((flag) && (tempFlag));
|
return ((loggedIAndConnectedFlag) && (tempFlag));
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* @brief jceSSLClient::sendData - given string, send it to server
|
* @brief jceSSLClient::sendData - given string, send it to server
|
||||||
|
@ -127,11 +128,17 @@ bool jceSSLClient::isConnected()
|
||||||
bool jceSSLClient::sendData(QString str)
|
bool jceSSLClient::sendData(QString str)
|
||||||
{
|
{
|
||||||
bool sendDataFlag = false;
|
bool sendDataFlag = false;
|
||||||
|
int amount = 0;
|
||||||
if (isConnected()) //if connected
|
if (isConnected()) //if connected
|
||||||
{
|
{
|
||||||
write(str.toStdString().c_str(),str.length());
|
amount = write(str.toStdString().c_str(),str.length());
|
||||||
if (waitForBytesWritten())
|
qDebug() << Q_FUNC_INFO << "lenght send: " << str.length() << "lenght recieved: " << amount;
|
||||||
|
if (amount == -1)
|
||||||
|
{
|
||||||
|
qCritical() << Q_FUNC_INFO << "SendData ended with -1";
|
||||||
|
sendDataFlag = false;
|
||||||
|
}
|
||||||
|
else if (waitForBytesWritten())
|
||||||
sendDataFlag = true;
|
sendDataFlag = true;
|
||||||
}
|
}
|
||||||
qDebug() << Q_FUNC_INFO << "Sending Data status is: " << sendDataFlag;
|
qDebug() << Q_FUNC_INFO << "Sending Data status is: " << sendDataFlag;
|
||||||
|
@ -143,42 +150,35 @@ bool jceSSLClient::sendData(QString str)
|
||||||
* @param fast true for LOGIN ONLY, false to retrieve all data
|
* @param fast true for LOGIN ONLY, false to retrieve all data
|
||||||
* @return true if recieved data bigger than zero
|
* @return true if recieved data bigger than zero
|
||||||
*/
|
*/
|
||||||
bool jceSSLClient::recieveData(QString &str, bool fast)
|
bool jceSSLClient::recieveData(QString *str)
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << "Data receiving!";
|
qDebug() << Q_FUNC_INFO << "Data receiving!";
|
||||||
|
bool sflag = false; //success on recieving flag
|
||||||
|
str->clear();
|
||||||
packet = "";
|
packet = "";
|
||||||
bool sflag = false;
|
recieveLastPacket = false;
|
||||||
|
packetSizeRecieved = 0; //counting packet size
|
||||||
|
readingFlag = true; //to ignore timeout socket error
|
||||||
|
|
||||||
if (fast) //fast mode connection, good only for login step!!!!
|
timer.setSingleShot(true);
|
||||||
{
|
timer.start(milisTimeOut); //if timer is timeout -> it means the connection takes long time
|
||||||
qDebug() << Q_FUNC_INFO << "login step receiving";
|
|
||||||
//loop will exit after first read packet.
|
|
||||||
//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()));
|
|
||||||
readerLoop.exec();
|
|
||||||
disconnect(this, SIGNAL(readyRead()), &readerLoop, SLOT(quit()));
|
|
||||||
disconnect(this, SIGNAL(readyRead()), this, SLOT(readIt()));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
qDebug() << Q_FUNC_INFO << "normal receiving";
|
|
||||||
//loop will exit after timeout \ full data
|
|
||||||
connect(this, SIGNAL(packetHasData()), &readerLoop, SLOT(quit()));
|
|
||||||
|
|
||||||
timer.setSingleShot(true);
|
connect(this, SIGNAL(readyRead()), this, SLOT(readIt())); //we have something to read
|
||||||
connect(&timer, SIGNAL(timeout()), &readerLoop, SLOT(quit()));
|
connect(&timer, SIGNAL(timeout()), &readerLoop, SLOT(quit())); //if timer timeout > exiting event
|
||||||
connect(this, SIGNAL(readyRead()), this, SLOT(readItAll()));
|
|
||||||
timer.start(5000);
|
|
||||||
readerLoop.exec();
|
|
||||||
|
|
||||||
}
|
readerLoop.exec();
|
||||||
str = packet;
|
|
||||||
qDebug() << Q_FUNC_INFO << "received bytes: " << str.length() ;
|
disconnect(&timer, SIGNAL(timeout()), &readerLoop, SLOT(quit()));
|
||||||
if (str.length() > 0)
|
disconnect(this, SIGNAL(readyRead()), this, SLOT(readIt()));
|
||||||
|
|
||||||
|
str->append(packet);
|
||||||
|
qDebug() << *str;
|
||||||
|
|
||||||
|
qDebug() << Q_FUNC_INFO << "packet size: " << packetSizeRecieved << "received data lenght: " << str->length();
|
||||||
|
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()));
|
readingFlag = false;
|
||||||
return sflag;
|
return sflag;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -187,33 +187,41 @@ bool jceSSLClient::recieveData(QString &str, bool fast)
|
||||||
*/
|
*/
|
||||||
void jceSSLClient::readIt()
|
void jceSSLClient::readIt()
|
||||||
{
|
{
|
||||||
QString p;
|
int packSize = bytesAvailable();
|
||||||
do
|
int doTimes=0;
|
||||||
{
|
QByteArray tempPacket;
|
||||||
p = readAll();
|
|
||||||
packet.append(p);
|
|
||||||
this->progressBar->setValue(this->progressBar->value() + 6);
|
|
||||||
}while (p.size() > 0);
|
|
||||||
|
|
||||||
}
|
|
||||||
void jceSSLClient::readItAll()
|
|
||||||
{
|
|
||||||
QString p;
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
p = "";
|
qDebug() << Q_FUNC_INFO << "packet size" << packSize;
|
||||||
p = read(bytesAvailable());
|
|
||||||
if (p.contains("</tbody>") == true)
|
if (doTimes++ > 0) //for debbuging, checking thread looping times
|
||||||
{
|
qDebug() << Q_FUNC_INFO << "do loop" << doTimes;
|
||||||
//we recieved the end of table. we can stop recieving
|
|
||||||
timer.setInterval(1000);
|
waitForReadyRead(100);
|
||||||
}
|
tempPacket = read(packSize);
|
||||||
this->progressBar->setValue(this->progressBar->value() + 6);
|
|
||||||
packet.append(p);
|
readerAppendingLocker.lock();
|
||||||
|
packetSizeRecieved += packSize;
|
||||||
|
packet.append(tempPacket);
|
||||||
packet.append("\0");
|
packet.append("\0");
|
||||||
}while (p.size() > 0);
|
readerAppendingLocker.unlock();
|
||||||
}
|
|
||||||
|
|
||||||
|
progressBar->setValue(this->progressBar->value() + 6);
|
||||||
|
|
||||||
|
if (tempPacket.contains("Go_To_system_After_Login.htm") || tempPacket.contains("</html>"))
|
||||||
|
{
|
||||||
|
//we have the last packet. (uses only in login first step
|
||||||
|
recieveLastPacket = true;
|
||||||
|
timer.setInterval(200);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//just a packet with data
|
||||||
|
}
|
||||||
|
|
||||||
|
}while ((packSize = bytesAvailable()) > 0);
|
||||||
|
}
|
||||||
void jceSSLClient::setOnlineState(bool isOnline)
|
void jceSSLClient::setOnlineState(bool isOnline)
|
||||||
{
|
{
|
||||||
qWarning() << Q_FUNC_INFO << "isOnline status change: " << isOnline;
|
qWarning() << Q_FUNC_INFO << "isOnline status change: " << isOnline;
|
||||||
|
@ -246,8 +254,8 @@ void jceSSLClient::setDisconnected()
|
||||||
qDebug() << Q_FUNC_INFO << "connection has been DISCONNECTED";
|
qDebug() << Q_FUNC_INFO << "connection has been DISCONNECTED";
|
||||||
this->setSocketState(QAbstractSocket::SocketState::UnconnectedState);
|
this->setSocketState(QAbstractSocket::SocketState::UnconnectedState);
|
||||||
packet.clear();
|
packet.clear();
|
||||||
flag = false;
|
loggedIAndConnectedFlag = false;
|
||||||
if (reConnection)
|
if (reConnectionFlag)
|
||||||
makeConnect();
|
makeConnect();
|
||||||
|
|
||||||
|
|
||||||
|
@ -260,11 +268,11 @@ void jceSSLClient::setEncrypted()
|
||||||
qDebug() << Q_FUNC_INFO << "connection has been ENCRYPTED";
|
qDebug() << Q_FUNC_INFO << "connection has been ENCRYPTED";
|
||||||
setReadBufferSize(packetSize);
|
setReadBufferSize(packetSize);
|
||||||
setSocketOption(QAbstractSocket::KeepAliveOption,true);
|
setSocketOption(QAbstractSocket::KeepAliveOption,true);
|
||||||
flag = true;
|
loggedIAndConnectedFlag = true;
|
||||||
if (!isConnected())
|
if (!isConnected())
|
||||||
{
|
{
|
||||||
qWarning() << Q_FUNC_INFO << "Connection status didnt change! reseting flag to false";
|
qWarning() << Q_FUNC_INFO << "Connection status didnt change! reseting flag to false";
|
||||||
flag = false;
|
loggedIAndConnectedFlag = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -291,7 +299,7 @@ void jceSSLClient::showIfErrorMsg()
|
||||||
//The remote host closed the connection
|
//The remote host closed the connection
|
||||||
if (isConnectedToNetwork()) //we can reconnect
|
if (isConnectedToNetwork()) //we can reconnect
|
||||||
{
|
{
|
||||||
reConnection = true;
|
reConnectionFlag = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
relevantError = true;
|
relevantError = true;
|
||||||
|
@ -402,19 +410,23 @@ void jceSSLClient::checkErrors(QAbstractSocket::SocketError a)
|
||||||
qWarning() << Q_FUNC_INFO << "Var Error: " << a;
|
qWarning() << Q_FUNC_INFO << "Var Error: " << a;
|
||||||
qWarning() << Q_FUNC_INFO << "Error: " << errorString();
|
qWarning() << Q_FUNC_INFO << "Error: " << errorString();
|
||||||
}
|
}
|
||||||
|
else if (!readingFlag)
|
||||||
|
{
|
||||||
|
qWarning() << Q_FUNC_INFO << "isConnected?: " << isConnected() << "is timeout?" << timeout;
|
||||||
|
qWarning() << Q_FUNC_INFO << "isOnline?: " << isConnectedToNetwork() << "state is: " << state();
|
||||||
|
qWarning() << Q_FUNC_INFO << "Error: " << errorString();
|
||||||
|
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
qDebug() << Q_FUNC_INFO << "isConnected?: " << isConnected() << "is timeout?" << timeout;
|
//timeout when reading
|
||||||
qWarning() << Q_FUNC_INFO << "isOnline?: " << isConnectedToNetwork();
|
|
||||||
qWarning() << Q_FUNC_INFO << "state is: " << state();
|
|
||||||
qWarning() << Q_FUNC_INFO << "Var Error: " << a;
|
|
||||||
qWarning() << Q_FUNC_INFO << "Error: " << errorString();
|
|
||||||
}
|
}
|
||||||
showIfErrorMsg();
|
showIfErrorMsg();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** written by KARAN BALKAR
|
/** written by KARAN BALKAR
|
||||||
* @brief jceSSLClient::isConnectedToNetwork
|
* @brief jceSSLClient::isConnectedToNetwork
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
bool jceSSLClient::isConnectedToNetwork(){
|
bool jceSSLClient::isConnectedToNetwork(){
|
||||||
|
|
|
@ -5,54 +5,66 @@
|
||||||
#include <QSslSocket>
|
#include <QSslSocket>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
#include <QEventLoop>
|
#include <QEventLoop>
|
||||||
|
#include <QTimer>
|
||||||
|
#include <QMutex>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QNetworkConfigurationManager>
|
#include <QNetworkConfigurationManager>
|
||||||
#include <QtNetwork/QNetworkInterface>
|
#include <QtNetwork/QNetworkInterface>
|
||||||
#include <QTimer>
|
|
||||||
#include <QProgressBar>
|
#include <QProgressBar>
|
||||||
|
|
||||||
#define packetSize 10000
|
#define packetSize 4096 //4k
|
||||||
#define milisTimeOut 4000
|
#define milisTimeOut 5000 //4 seconds
|
||||||
|
|
||||||
class jceSSLClient : public QSslSocket
|
class jceSSLClient : public QSslSocket
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
jceSSLClient(QProgressBar *progressbarPtr);
|
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();
|
||||||
bool isConnected();
|
bool isConnected();
|
||||||
bool sendData(QString str);
|
bool sendData(QString str);
|
||||||
bool recieveData(QString &str, bool fast);
|
bool recieveData(QString *str);
|
||||||
void showIfErrorMsg();
|
void showIfErrorMsg();
|
||||||
|
|
||||||
signals:
|
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);
|
||||||
void setConnected();
|
void setConnected();
|
||||||
void setEncrypted();
|
void setEncrypted();
|
||||||
void setDisconnected();
|
void setDisconnected();
|
||||||
void readIt();
|
void readIt();
|
||||||
void readItAll();
|
void setOnlineState(bool isOnline);
|
||||||
void setOnlineState(bool isOnline);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool isConnectedToNetwork(); //checking if online
|
|
||||||
bool flag;
|
|
||||||
QString packet;
|
|
||||||
QEventLoop loop; //handle the connection as thread
|
|
||||||
QEventLoop readerLoop;
|
|
||||||
QTimer timer;
|
|
||||||
QNetworkConfigurationManager networkConf; //checking if online
|
|
||||||
bool reConnection; //used for remote host disconnecting
|
|
||||||
|
|
||||||
QProgressBar *progressBar; //
|
bool isConnectedToNetwork(); //checking if online
|
||||||
|
|
||||||
|
bool loggedIAndConnectedFlag;
|
||||||
|
bool readingFlag;
|
||||||
|
bool reConnectionFlag; //used for remote host disconnecting
|
||||||
|
|
||||||
|
QNetworkConfigurationManager networkConf; //checking if online
|
||||||
|
|
||||||
|
QString packet;
|
||||||
|
bool recieveLastPacket;
|
||||||
|
int packetSizeRecieved;
|
||||||
|
|
||||||
|
QEventLoop loginThreadLoop; //handle the connection as thread
|
||||||
|
QEventLoop readerLoop;
|
||||||
|
|
||||||
|
QMutex readerAppendingLocker; //locking packet when appending
|
||||||
|
QTimer timer; //uses to check if reading has reached its timeout
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
QProgressBar *progressBar; //progressbar pointer
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ void CalendarPage::setPage(QString html)
|
||||||
|
|
||||||
courses = new std::list<calendarCourse*>();
|
courses = new std::list<calendarCourse*>();
|
||||||
tempHtml = getString(html);
|
tempHtml = getString(html);
|
||||||
|
qDebug() << "starting ..";
|
||||||
calendarListInit(tempHtml);
|
calendarListInit(tempHtml);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,23 +19,19 @@ void CalendarPage::setPage(QString html)
|
||||||
*/
|
*/
|
||||||
void CalendarPage::calendarListInit(QString &linesTokinzedString)
|
void CalendarPage::calendarListInit(QString &linesTokinzedString)
|
||||||
{
|
{
|
||||||
std::list<QString> stringHolder;
|
QString tempToken;
|
||||||
QString temp;
|
|
||||||
calendarCourse * cTemp = NULL;
|
QStringList holder = linesTokinzedString.split("\n");
|
||||||
char* tok;
|
QStringList::iterator iterator;
|
||||||
char* textToTok = strdup(linesTokinzedString.toStdString().c_str());
|
for (iterator = holder.begin(); iterator != holder.end(); ++iterator)
|
||||||
tok = strtok(textToTok,"\n");
|
|
||||||
while (tok != NULL)
|
|
||||||
{
|
{
|
||||||
temp = tok;
|
tempToken = (*iterator);
|
||||||
stringHolder.push_back(temp);
|
if (!tempToken.isEmpty())
|
||||||
tok = strtok(NULL, "\n");
|
{
|
||||||
}
|
calendarCourse *cTemp = lineToCourse(tempToken);
|
||||||
for (QString temp: stringHolder)
|
if (cTemp != NULL)
|
||||||
{
|
this->courses->push_back(cTemp);
|
||||||
cTemp = lineToCourse(temp);
|
}
|
||||||
if (cTemp != NULL)
|
|
||||||
courses->push_back(cTemp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,27 +48,27 @@ calendarCourse *CalendarPage::lineToCourse(QString line)
|
||||||
int serial;
|
int serial;
|
||||||
double points,semesterHours;
|
double points,semesterHours;
|
||||||
QString name,type, lecturer,dayAndHour,room;
|
QString name,type, lecturer,dayAndHour,room;
|
||||||
QString tempS = "";
|
|
||||||
int i = 0;
|
|
||||||
char* tok;
|
|
||||||
char* cLine = strdup(line.toStdString().c_str());
|
|
||||||
tok = strtok(cLine, "\t");
|
|
||||||
while(tok != NULL)
|
|
||||||
{
|
|
||||||
tempS = QString(tok);
|
|
||||||
|
|
||||||
|
QString tempToken;
|
||||||
|
int i = 0;
|
||||||
|
QStringList holder = line.split("\t");
|
||||||
|
QStringList::iterator iterator;
|
||||||
|
for (iterator = holder.begin(); iterator != holder.end(); ++iterator)
|
||||||
|
{
|
||||||
|
|
||||||
|
tempToken = (*iterator);
|
||||||
if (i >= 1) //skips on semester character
|
if (i >= 1) //skips on semester character
|
||||||
{
|
{
|
||||||
templinearray[i-1] = tempS.trimmed();
|
templinearray[i] = tempToken.trimmed();
|
||||||
}
|
}
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
if (i > 8)
|
if (i >= CALENDAR_COURSE_FIELDS)
|
||||||
break;
|
break;
|
||||||
tok=strtok(NULL, "\t");
|
}
|
||||||
}
|
|
||||||
if (templinearray[0] == "") //empty parsing
|
if (templinearray[0] == "") //empty parsing
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
||||||
serial = templinearray[calendarCourse::CourseScheme::SERIAL].toInt();
|
serial = templinearray[calendarCourse::CourseScheme::SERIAL].toInt();
|
||||||
name = templinearray[calendarCourse::CourseScheme::NAME];
|
name = templinearray[calendarCourse::CourseScheme::NAME];
|
||||||
|
@ -101,16 +98,16 @@ calendarCourse *CalendarPage::lineToCourse(QString line)
|
||||||
|
|
||||||
|
|
||||||
tempC = new calendarCourse(serial,name,type,lecturer,points,semesterHours,dayAndHour,room);
|
tempC = new calendarCourse(serial,name,type,lecturer,points,semesterHours,dayAndHour,room);
|
||||||
// qDebug() << "serial is: " << tempC->getSerialNum();
|
qDebug() << "serial is: " << tempC->getSerialNum();
|
||||||
// qDebug() << tempC->getName();
|
qDebug() << tempC->getName();
|
||||||
// qDebug() << tempC->getType();
|
qDebug() << tempC->getType();
|
||||||
// qDebug() << tempC->getLecturer();
|
qDebug() << tempC->getLecturer();
|
||||||
// qDebug() << tempC->getPoints();
|
qDebug() << tempC->getPoints();
|
||||||
// qDebug() << tempC->getHourBegin() << ":" << tempC->getMinutesBegin();
|
qDebug() << tempC->getHourBegin() << ":" << tempC->getMinutesBegin();
|
||||||
// qDebug() << tempC->getHourEnd() << ":" << tempC->getMinutesEnd();
|
qDebug() << tempC->getHourEnd() << ":" << tempC->getMinutesEnd();
|
||||||
|
|
||||||
// qDebug() << tempC->getDay();
|
qDebug() << tempC->getDay();
|
||||||
// qDebug() << tempC->getRoom();
|
qDebug() << tempC->getRoom();
|
||||||
|
|
||||||
return tempC;
|
return tempC;
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,7 +59,7 @@ int jceLogin::makeConnection()
|
||||||
returnMode = makeSecondVisit();
|
returnMode = makeSecondVisit();
|
||||||
if (returnMode == true) //siging in the website
|
if (returnMode == true) //siging in the website
|
||||||
{
|
{
|
||||||
qDebug() << "jceLogin::makeConnection(); Signed in succeesfully";
|
qDebug() << Q_FUNC_INFO << "Signed in succeesfully";
|
||||||
status = jceStatus::JCE_YOU_ARE_IN;
|
status = jceStatus::JCE_YOU_ARE_IN;
|
||||||
setLoginFlag(true);
|
setLoginFlag(true);
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ int jceLogin::makeConnection()
|
||||||
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(); return status: " << status;
|
qDebug() << Q_FUNC_INFO << "return status: " << status;
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -150,7 +150,7 @@ int jceLogin::makeFirstVisit()
|
||||||
QString psw = jceA->getPassword();
|
QString psw = jceA->getPassword();
|
||||||
if (JceConnector->sendData(jceLoginHtmlScripts::makeRequest(jceLoginHtmlScripts::getFirstValidationStep(*jceA))))
|
if (JceConnector->sendData(jceLoginHtmlScripts::makeRequest(jceLoginHtmlScripts::getFirstValidationStep(*jceA))))
|
||||||
{
|
{
|
||||||
if (!JceConnector->recieveData(*recieverPage,true))
|
if (!JceConnector->recieveData(recieverPage))
|
||||||
return jceLogin::ERROR_ON_GETTING_INFO;
|
return jceLogin::ERROR_ON_GETTING_INFO;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -168,7 +168,7 @@ int jceLogin::makeSecondVisit()
|
||||||
QString pswid=jceA->getHashedPassword();
|
QString pswid=jceA->getHashedPassword();
|
||||||
if ((JceConnector->sendData(jceLoginHtmlScripts::makeRequest(jceLoginHtmlScripts::getSecondValidationStep(*jceA)))))
|
if ((JceConnector->sendData(jceLoginHtmlScripts::makeRequest(jceLoginHtmlScripts::getSecondValidationStep(*jceA)))))
|
||||||
{
|
{
|
||||||
if (!(JceConnector->recieveData(*recieverPage,true)))
|
if (!(JceConnector->recieveData(recieverPage)))
|
||||||
return jceLogin::ERROR_ON_GETTING_INFO;
|
return jceLogin::ERROR_ON_GETTING_INFO;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
@ -188,7 +188,7 @@ int jceLogin::getCalendar(int year, int semester)
|
||||||
{
|
{
|
||||||
if ((JceConnector->sendData(jceLoginHtmlScripts::makeRequest(jceLoginHtmlScripts::getCalendar(*jceA,year,semester)))))
|
if ((JceConnector->sendData(jceLoginHtmlScripts::makeRequest(jceLoginHtmlScripts::getCalendar(*jceA,year,semester)))))
|
||||||
{
|
{
|
||||||
if (!(JceConnector->recieveData(*recieverPage,false)))
|
if (!(JceConnector->recieveData(recieverPage)))
|
||||||
return jceLogin::ERROR_ON_GETTING_PAGE;
|
return jceLogin::ERROR_ON_GETTING_PAGE;
|
||||||
else
|
else
|
||||||
return jceLogin::JCE_PAGE_PASSED;
|
return jceLogin::JCE_PAGE_PASSED;
|
||||||
|
@ -203,7 +203,7 @@ int jceLogin::getExams(int year, int semester)
|
||||||
{
|
{
|
||||||
if ((JceConnector->sendData(jceLoginHtmlScripts::makeRequest(jceLoginHtmlScripts::getExamSchedule(*jceA,year,semester)))))
|
if ((JceConnector->sendData(jceLoginHtmlScripts::makeRequest(jceLoginHtmlScripts::getExamSchedule(*jceA,year,semester)))))
|
||||||
{
|
{
|
||||||
if (!(JceConnector->recieveData(*recieverPage,false)))
|
if (!(JceConnector->recieveData(recieverPage)))
|
||||||
return jceLogin::ERROR_ON_GETTING_PAGE;
|
return jceLogin::ERROR_ON_GETTING_PAGE;
|
||||||
else
|
else
|
||||||
return jceLogin::JCE_PAGE_PASSED;
|
return jceLogin::JCE_PAGE_PASSED;
|
||||||
|
@ -225,7 +225,7 @@ int jceLogin::getGrades(int fromYear, int toYear, int fromSemester, int toSemest
|
||||||
{
|
{
|
||||||
if ((JceConnector->sendData(jceLoginHtmlScripts::makeRequest(jceLoginHtmlScripts::getGradesPath(*jceA,fromYear, toYear, fromSemester, toSemester)))))
|
if ((JceConnector->sendData(jceLoginHtmlScripts::makeRequest(jceLoginHtmlScripts::getGradesPath(*jceA,fromYear, toYear, fromSemester, toSemester)))))
|
||||||
{
|
{
|
||||||
if (!(JceConnector->recieveData(*recieverPage,false)))
|
if (!(JceConnector->recieveData(recieverPage)))
|
||||||
return jceLogin::ERROR_ON_GETTING_PAGE;
|
return jceLogin::ERROR_ON_GETTING_PAGE;
|
||||||
else
|
else
|
||||||
return jceLogin::JCE_PAGE_PASSED;
|
return jceLogin::JCE_PAGE_PASSED;
|
||||||
|
|
Loading…
Reference in a new issue