nxcl  @VERSION@
nxsession.h
1 /***************************************************************************
2  nxsession.h
3  -------------------
4  begin : Sat 22nd July 2006
5  modifications : July 2007
6  copyright : (C) 2006 by George Wright
7  modifications : (C) 2007 Embedded Software Foundry Ltd. (U.K.)
8  : Author: Sebastian James
9  : (C) 2008 Defuturo Ltd
10  : Author: George Wright
11  email : seb@esfnet.co.uk, gwright@kde.org
12  ***************************************************************************/
13 
14 /***************************************************************************
15  * *
16  * This program is free software; you can redistribute it and/or modify *
17  * it under the terms of the GNU General Public License as published by *
18  * the Free Software Foundation; either version 2 of the License, or *
19  * (at your option) any later version. *
20  * *
21  ***************************************************************************/
22 
23 #ifndef _NXSESSION_H_
24 #define _NXSESSION_H_
25 
26 #include <sstream>
27 #include <fstream>
28 #include <fcntl.h>
29 #include <unistd.h>
30 #include "nxdata.h"
31 #include <list>
32 
33 namespace nxcl {
34 
40  {
41  public:
43  virtual ~NXSessionCallbacks() {}
44  virtual void noSessionsSignal (void) {}
45  virtual void loginFailedSignal (void) {}
46  virtual void readyForProxySignal (void) {}
51  virtual void authenticatedSignal (void) {}
52  virtual void sessionsSignal (list<NXResumeData>) {}
53  };
54 
59  class NXSession
60  {
61  public:
62  NXSession();
63  ~NXSession();
64 
65  string parseSSH (string);
66  int parseResponse (string);
67  void parseResumeSessions (list<string>);
68  void resetSession (void);
69  void wipeSessions (void);
70  bool chooseResumable (int n);
71  bool terminateSession (int n);
72  string generateCookie (void);
73  void runSession (void) { sessionDataSet = true; }
74 
79  void setUsername (string& user) { nxUsername = user; }
80  void setPassword (string& pass) { nxPassword = pass; }
81  void setResolution (int x, int y)
82  {
83  this->sessionData->xRes = x;
84  this->sessionData->yRes = y;
85  }
86 
87  void setDepth (int d)
88  {
89  this->sessionData->depth = d;
90  }
91 
92  void setRender (bool isRender)
93  {
94  if (this->sessionDataSet) {
95  this->sessionData->render = isRender;
96  }
97  }
98 
99  void setEncryption (bool enc)
100  {
101  if (this->sessionDataSet) {
102  this->sessionData->encryption = enc;
103  }
104  }
105 
106  void setContinue (bool allow)
107  {
108  doSSH = allow;
109  }
110 
111  void setSessionData (NXSessionData*);
112 
113  NXSessionData* getSessionData()
114  {
115  return this->sessionData;
116  }
117 
118  bool getSessionDataSet (void)
119  {
120  return this->sessionDataSet;
121  }
122 
123  void setCallbacks (NXSessionCallbacks * cb)
124  {
125  this->callbacks = cb;
126  }
128 
129  private:
130  void reset (void);
131  void fillRand(unsigned char *, size_t);
132 
139  bool doSSH;
144  bool suspendedSessions;
148  bool sessionDataSet;
154  int stage;
158  int devurand_fd;
162  string nxUsername;
166  string nxPassword;
170  list<string> resumeSessions;
175  list<NXResumeData> runningSessions;
179  NXSessionData *sessionData;
183  NXSessionCallbacks * callbacks;
184  };
185 
186 } // namespace
187 #endif
nxcl::NXSession::setUsername
void setUsername(string &user)
Definition: nxsession.h:79
nxcl::NXSessionCallbacks
Definition: nxsession.h:40
nxcl::NXSession
Definition: nxsession.h:60
nxcl::NXSessionCallbacks::authenticatedSignal
virtual void authenticatedSignal(void)
Definition: nxsession.h:51