nxsession.h

00001 /***************************************************************************
00002                                  nxsession.h
00003                              -------------------
00004     begin                : Sat 22nd July 2006
00005     modifications        : July 2007
00006     copyright            : (C) 2006 by George Wright
00007     modifications        : (C) 2007 Embedded Software Foundry Ltd. (U.K.)
00008                          :     Author: Sebastian James
00009                          : (C) 2008 Defuturo Ltd
00010                          :     Author: George Wright
00011     email                : seb@esfnet.co.uk, gwright@kde.org
00012  ***************************************************************************/
00013 
00014 /***************************************************************************
00015  *                                                                         *
00016  *   This program is free software; you can redistribute it and/or modify  *
00017  *   it under the terms of the GNU General Public License as published by  *
00018  *   the Free Software Foundation; either version 2 of the License, or     *
00019  *   (at your option) any later version.                                   *
00020  *                                                                         *
00021  ***************************************************************************/
00022 
00023 #ifndef _NXSESSION_H_
00024 #define _NXSESSION_H_
00025 
00026 #include <sstream>
00027 #include <fstream>
00028 #include <fcntl.h>
00029 #include <unistd.h>
00030 #include "nxdata.h"
00031 #include <list>
00032 
00033 namespace nxcl {
00034 
00039     class NXSessionCallbacks
00040     {
00041         public:
00042             NXSessionCallbacks() {}
00043             virtual ~NXSessionCallbacks() {}
00044             virtual void noSessionsSignal (void) {}
00045             virtual void loginFailedSignal (void) {}
00046             virtual void readyForProxySignal (void) {}
00051             virtual void authenticatedSignal (void) {}
00052             virtual void sessionsSignal (list<NXResumeData>) {}
00053     };
00054 
00059     class NXSession
00060     {
00061         public:
00062             NXSession();
00063             ~NXSession();
00064 
00065             string parseSSH (string);
00066             int parseResponse (string);
00067             void parseResumeSessions (list<string>);
00068             void resetSession (void);
00069             void wipeSessions (void);
00070             bool chooseResumable (int n);
00071             bool terminateSession (int n);
00072             string generateCookie (void);
00073             void runSession (void) { sessionDataSet = true; }
00074 
00079             void setUsername (string& user) { nxUsername = user; }
00080             void setPassword (string& pass) { nxPassword = pass; }
00081             void setResolution (int x, int y) 
00082             {
00083                 this->sessionData->xRes = x;
00084                 this->sessionData->yRes = y;
00085             }
00086 
00087             void setDepth (int d) 
00088             {
00089                 this->sessionData->depth = d;
00090             }
00091 
00092             void setRender (bool isRender)
00093             {
00094                 if (this->sessionDataSet) {
00095                     this->sessionData->render = isRender;
00096                 }
00097             }
00098 
00099             void setEncryption (bool enc)
00100             {
00101                 if (this->sessionDataSet) {
00102                     this->sessionData->encryption = enc;
00103                 }
00104             }
00105 
00106             void setContinue (bool allow)
00107             {
00108                 doSSH = allow;
00109             }
00110 
00111             void setSessionData (NXSessionData*);
00112 
00113             NXSessionData* getSessionData()
00114             {
00115                 return this->sessionData;
00116             }
00117 
00118             bool getSessionDataSet (void)
00119             {
00120                 return this->sessionDataSet;
00121             }
00122 
00123             void setCallbacks (NXSessionCallbacks * cb) 
00124             {
00125                 this->callbacks = cb;
00126             }
00128 
00129         private:
00130             void reset (void);
00131             void fillRand(unsigned char *, size_t);
00132 
00139             bool doSSH;
00144             bool suspendedSessions;
00148             bool sessionDataSet;
00154             int stage;
00158             int devurand_fd;
00162             string nxUsername;
00166             string nxPassword;
00170             list<string> resumeSessions;
00175             list<NXResumeData> runningSessions;
00179             NXSessionData *sessionData;
00183             NXSessionCallbacks * callbacks;
00184     };
00185 
00186 } // namespace
00187 #endif

Generated on Sun Apr 13 19:34:14 2008 for nxcl by  doxygen 1.4.7