fixing qt ssl socket
This commit is contained in:
parent
ee25c1f94b
commit
57f1481a43
8 changed files with 60 additions and 37 deletions
|
@ -82,6 +82,7 @@ bool loginHandler::makeConnection()
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool loginHandler::isLoggedInFlag()
|
||||
{
|
||||
return this->logggedInFlag;
|
||||
|
|
|
@ -34,6 +34,9 @@ private:
|
|||
QLabel *statusLabelPtr;
|
||||
QLineEdit *pswdEditPtr;
|
||||
QLineEdit *usrnmEditPtr;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // LOGINHANDLER_H
|
||||
|
|
|
@ -50,9 +50,18 @@ MainScreen::~MainScreen()
|
|||
delete loginHandel;
|
||||
delete ui;
|
||||
}
|
||||
void MainScreen::on_loginButton_clicked()
|
||||
{
|
||||
if (loginHandel->isLoggedInFlag())
|
||||
uiSetDisconnectMode();
|
||||
|
||||
else
|
||||
uiSetConnectMode();
|
||||
|
||||
}
|
||||
|
||||
void MainScreen::on_ratesButton_clicked()
|
||||
{
|
||||
|
||||
std::string pageString;
|
||||
int status = 0;
|
||||
if (loginHandel->isLoggedInFlag())
|
||||
|
@ -72,7 +81,6 @@ void MainScreen::on_ratesButton_clicked()
|
|||
|
||||
|
||||
}
|
||||
|
||||
void MainScreen::on_spinBoxFromYear_editingFinished()
|
||||
{
|
||||
if (ui->spinBoxFromYear->value() > ui->spinBoxToYear->value())
|
||||
|
@ -128,15 +136,7 @@ void MainScreen::on_coursesTable_itemChanged(QTableWidgetItem *item)
|
|||
QMessageBox::critical(this,"Error","Missmatching data");
|
||||
}
|
||||
|
||||
void MainScreen::on_loginButton_clicked()
|
||||
{
|
||||
if (loginHandel->isLoggedInFlag())
|
||||
uiSetDisconnectMode();
|
||||
|
||||
else
|
||||
uiSetConnectMode();
|
||||
|
||||
}
|
||||
|
||||
void MainScreen::on_checkBox_toggled(bool checked)
|
||||
{
|
||||
|
@ -192,7 +192,6 @@ void MainScreen::uiSetConnectMode() //fix before distrbute
|
|||
userLoginSetting->setPassword(password);
|
||||
|
||||
this->loginHandel->setPointers(statusLabel,ui->pswdLineEdit,ui->usrnmLineEdit);
|
||||
|
||||
if (loginHandel->makeConnection() == true)
|
||||
{
|
||||
setLabelConnectionStatus(jceLogin::jceStatus::JCE_YOU_ARE_IN);
|
||||
|
@ -200,6 +199,7 @@ void MainScreen::uiSetConnectMode() //fix before distrbute
|
|||
this->ui->ratesButton->setEnabled(true);
|
||||
ui->CoursesTab->setEnabled(true);
|
||||
ui->SettingsTab->setEnabled(true);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -293,9 +293,6 @@ font-size: 15px;
|
|||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="1" column="0">
|
||||
<widget class="QTextEdit" name="textEdit"/>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<widget class="QWidget" name="CoursesTab">
|
||||
|
@ -587,9 +584,6 @@ font-size: 15px;
|
|||
<property name="readOnly">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="showGroupSeparator" stdset="0">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
<property name="minimum">
|
||||
<number>2009</number>
|
||||
</property>
|
||||
|
@ -599,6 +593,9 @@ font-size: 15px;
|
|||
<property name="value">
|
||||
<number>2009</number>
|
||||
</property>
|
||||
<property name="showGroupSeparator" stdset="0">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
|
@ -655,7 +652,7 @@ font-size: 15px;
|
|||
<item row="1" column="0">
|
||||
<widget class="QCheckBox" name="checkBox">
|
||||
<property name="text">
|
||||
<string>Only influences Courses</string>
|
||||
<string>Only influence Courses</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
|
@ -678,7 +675,7 @@ font-size: 15px;
|
|||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>855</width>
|
||||
<height>29</height>
|
||||
<height>21</height>
|
||||
</rect>
|
||||
</property>
|
||||
<widget class="QMenu" name="menuA_about">
|
||||
|
|
|
@ -3,29 +3,24 @@
|
|||
|
||||
bool qtsslsocket::makeConnect(std::string server,int port)
|
||||
{
|
||||
if (this->socket != NULL) //already connected?
|
||||
{
|
||||
socket->close();
|
||||
socket = NULL;
|
||||
}
|
||||
|
||||
if (this->socket == NULL) //if was connected, we deleted it and remake it
|
||||
socket = new QSslSocket();
|
||||
if (isCon())
|
||||
socket->abort();
|
||||
|
||||
|
||||
if (this->socket != NULL) //now we will connect it to host
|
||||
{
|
||||
socket->connectToHostEncrypted(server.c_str(), port);
|
||||
if (socket->waitForEncrypted()) //waiting for encryption
|
||||
flag = true;
|
||||
}
|
||||
socket->connectToHostEncrypted(server.c_str(), port);
|
||||
socket->waitForEncrypted();
|
||||
|
||||
return isCon(); //return true/false upon isCon function
|
||||
return true; //return true/false upon isCon function
|
||||
}
|
||||
|
||||
qtsslsocket::qtsslsocket() : flag(false)
|
||||
{
|
||||
socket = new QSslSocket();
|
||||
connect(socket,SIGNAL(error(QAbstractSocket::SocketError)),this,SLOT(checkErrors(QAbstractSocket::SocketError)));
|
||||
connect(socket,SIGNAL(connected()),this,SLOT(setConnected()));
|
||||
connect(socket,SIGNAL(encrypted()),this,SLOT(setEncrypted()));
|
||||
this->flag = true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -72,3 +67,21 @@ bool qtsslsocket::makeDiconnect()
|
|||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void qtsslsocket::checkErrors(QAbstractSocket::SocketError info)
|
||||
{
|
||||
}
|
||||
|
||||
void qtsslsocket::setConnected()
|
||||
{
|
||||
// socket->waitForEncrypted();
|
||||
|
||||
}
|
||||
|
||||
void qtsslsocket::setEncrypted()
|
||||
{
|
||||
|
||||
// this->flag = true;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
#include <QString>
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#define milisTimeOut 3000
|
||||
#define milisTimeOut 3500
|
||||
|
||||
class qtsslsocket : public QObject
|
||||
{
|
||||
|
@ -24,10 +24,18 @@ public:
|
|||
bool makeDiconnect();
|
||||
|
||||
|
||||
private slots:
|
||||
void checkErrors(QAbstractSocket::SocketError);
|
||||
void setConnected();
|
||||
void setEncrypted();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
QSslSocket *socket;
|
||||
bool flag;
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif // QTSSLSOCKET_H
|
||||
|
|
|
@ -5,6 +5,7 @@ jceLogin::jceLogin(user * username)
|
|||
this->recieverPage = new std::string();
|
||||
this->jceA = username;
|
||||
this->JceConnector = new qtsslsocket();
|
||||
|
||||
}
|
||||
|
||||
jceLogin::~jceLogin()
|
||||
|
|
|
@ -9,8 +9,6 @@
|
|||
#include "jceLoginHtmlScripts.h"
|
||||
|
||||
|
||||
|
||||
|
||||
class jceLogin
|
||||
{
|
||||
public:
|
||||
|
@ -43,6 +41,8 @@ public:
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
private:
|
||||
int makeFirstVisit();
|
||||
bool checkValidation();
|
||||
|
|
Loading…
Reference in a new issue