jce-manager/src/jceConnection/jcesslclient.h

72 lines
1.6 KiB
C
Raw Normal View History

2014-09-08 15:54:52 +00:00
#ifndef JCESSLCLIENT_H
#define JCESSLCLIENT_H
#include <QObject>
#include <QSslSocket>
#include <QThread>
#include <QEventLoop>
2014-10-10 15:20:33 +00:00
#include <QTimer>
#include <QMutex>
#include <QMessageBox>
#include <QNetworkConfigurationManager>
#include <QtNetwork/QNetworkInterface>
2014-10-10 15:20:33 +00:00
2014-10-12 19:19:43 +00:00
#include "./main/jceWidgets/jcestatusbar.h"
2014-09-08 15:54:52 +00:00
2014-10-10 15:20:33 +00:00
#define packetSize 4096 //4k
#define milisTimeOut 5000 //4 seconds
2014-09-08 15:54:52 +00:00
2014-09-21 10:31:26 +00:00
class jceSSLClient : public QSslSocket
2014-09-08 15:54:52 +00:00
{
2014-10-10 15:20:33 +00:00
Q_OBJECT
2014-09-08 15:54:52 +00:00
public:
2014-10-12 22:14:26 +00:00
jceSSLClient(jceStatusBar *statusBar);
2014-09-08 15:54:52 +00:00
2014-10-10 15:20:33 +00:00
bool makeConnect(QString server = "yedion.jce.ac.il", int port = 443);
bool makeDiconnect();
bool isConnected();
bool sendData(QString str);
bool recieveData(QString *str);
void showIfErrorMsg();
2014-09-08 15:54:52 +00:00
signals:
2014-10-10 15:20:33 +00:00
void serverDisconnectedbyRemote();
void noInternetLink();
void socketDisconnected();
2014-09-08 15:54:52 +00:00
private slots:
2014-10-10 15:20:33 +00:00
void checkErrors(QAbstractSocket::SocketError a);
void setConnected();
void setEncrypted();
void setDisconnected();
void readIt();
void setOnlineState(bool isOnline);
2014-09-08 15:54:52 +00:00
private:
2014-10-10 15:20:33 +00:00
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
2014-10-12 22:14:26 +00:00
jceStatusBar *statusBar; //progressbar pointer
2014-10-04 00:54:27 +00:00
2014-09-08 15:54:52 +00:00
};
#endif // JCESSLCLIENT_H