From ce3329047d378a14006ce74ec273ac59e3375303 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Wed, 12 May 2010 19:42:27 +0200 Subject: initial import of latest svn version --- src/core/pvsConnectionManager.h | 118 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 src/core/pvsConnectionManager.h (limited to 'src/core/pvsConnectionManager.h') diff --git a/src/core/pvsConnectionManager.h b/src/core/pvsConnectionManager.h new file mode 100644 index 0000000..5f5fcca --- /dev/null +++ b/src/core/pvsConnectionManager.h @@ -0,0 +1,118 @@ +/** + * The PVSConnection Manager is the heart and core of the PVS. He creates, updates, delivers and deletes the connections. + * + */ + + + +// TODO: +// make it look good ;-) + + + +#include +#include +#include +#include +#include +#include +#include +#ifndef _PVSCONNECTIONMANAGER_H_ +#define _PVSCONNECTIONMANAGER_H_ +#ifndef RFBCLIENT_H +extern "C" +{ +#include +} +#endif + +#define PROFILE +#include +#include +#include "src/net/pvsServiceBroadcast.h" + + + +class PVSConnectionManager; //forward declaration +class PVSClient; +class PVSListenSever; +class MainWindow; + +class PVSConnectionManager : public QObject +{ +public: + // singleton getter + static PVSConnectionManager* getManager(); + + ~PVSConnectionManager(); + + // PVSServer control/get/set methods + PVSServer* getServer() + { + return &_pvsServer; + }; + + // VNCConnection related static method + //static void onFBUpdate(rfbClient* client, int x, int y, int w, int h); + + + // gui update frequency + void setUpdateRate(int newRate); + + + // PVSConnection control/get/set methods + std::list getConnections() + { + return _listClients; + }; + void onClientNew(PVSClientConnection* newConnection); // called by the server when a new client connects + void onClientRemove(PVSClientConnection* removedConnection); // called by the server when a new client disconnects (on its own) + PVSClient* getClientFromConnection(PVSClientConnection* client); + PVSClient* getClientFromConnectionId(int id); + PVSClient* getClientFromVNCConnection(VNCConnection* client); + PVSClient* getClientFromIp(QString ip); // returns connection with hostname 'host' + PVSClient* getClientFromUsername(QString name); // returns connection with username 'name' + // these methods are called by the PVSServer which forwards the command/etc handling to the CM + void onCommand(PVSMsg command); + void onChat(PVSMsg chatMsg); + void onVncPassword(PVSMsg command); + void onVncRwPassword(PVSMsg command); + void onLoginUsername(PVSMsg command); + void onLoginPassword(PVSMsg command); + void onVncAllow(PVSMsg command); + void onVncPort(PVSMsg command); + void onVncProjection(PVSMsg command); + + void sendEventToClients(QString event, PVSClientConnection* newConnection, QString newClientName); // informs every connected clients about a new client or a removed client. + + void removeConnection(PVSClient* removedConnection); // removes and deletes the connection !DOES NOT DISCONNECT DIRECTLY! + PVSClient* getNewConnection(VNCConnectInfo* newConInfo); // returns a new connection object based on the VNCConnectInfo or NULL + + bool isBusy() { return _busy; } + + QString setNeedPassword(bool enabled); + QString getSessionName(); + +protected: + void timerEvent(QTimerEvent *event); + +private: + // C'Tor + PVSConnectionManager(); // private due to singleton pattern + // internal control methods + bool update(); // does the update and cleaning routines and makes sure the framebuffers in the connection objects are up to date + void loadCommands(); + + // Member + std::list _listClients; // list of all verified clients + PVSServer _pvsServer; // the server that handles the pvsConnections + static PVSConnectionManager* singleCM; // the CM itself + bool _busy; // to keep timed calls from starting another update before the old one is thru. + PVSServiceBroadcast _sdBroadcaster; ///< Service discovery handling + + QString _password; ///< Password required to connect (can be empty) + bool _needPassword; + int _timerId; +}; + +#endif -- cgit v1.2.3-55-g7522