Main Page | Class Hierarchy | Class List | Directories | File List | Class Members

nxclientlib.h

00001 /* -*-c++-*- */
00002 /***************************************************************************
00003                                 nxclientlib.h
00004                              -------------------
00005     begin                : Sat 22nd July 2006
00006     remove Qt dependency : Started June 2007
00007     modifications        : June-July 2007
00008     copyright            : (C) 2006 by George Wright
00009     modifications        : (C) 2007 Embedded Software Foundry Ltd. (U.K.)
00010                          :     Author: Sebastian James
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 _NXCLIENTLIB_H_
00024 #define _NXCLIENTLIB_H_
00025 
00026 #include <iostream>
00027 #include "nxsession.h"
00028 #include <list>
00029 #include "notQt.h"
00030 
00031 
00032 using namespace std;
00033 
00034 namespace nxcl {
00035 
00036         struct ProxyData {
00037                 string id;
00038                 int    display;
00039                 string cookie;
00040                 string proxyIP;
00041                 bool   encrypted;
00042                 int    port;
00043                 string server;
00044         };
00045 
00051         class NXClientLibExternalCallbacks
00052         {
00053         public:
00054                 NXClientLibExternalCallbacks () {}
00055                 virtual ~NXClientLibExternalCallbacks () {}
00056                 virtual void write (string msg) {}
00057                 virtual void write (int num, string msg) {}
00058                 virtual void error (string msg) {}
00059                 virtual void debug (string msg) {}
00060                 virtual void stdoutSignal (string msg) {}
00061                 virtual void stderrSignal (string msg) {}
00062                 virtual void stdinSignal (string msg) {}
00063                 virtual void resumeSessionsSignal (list<NXResumeData>) {}
00064                 virtual void noSessionsSignal (void) {}
00065                 virtual void serverCapacitySignal (void) {}
00066 
00067         };
00068 
00080         class NXClientLibBase 
00081         {
00082         public:
00083                 NXClientLibBase() {}
00084                 virtual ~NXClientLibBase() {}
00085 
00086                 virtual void setIsFinished (bool status) {}
00087                 virtual void processParseStdout (void) {}
00088                 virtual void processParseStderr (void) {}
00089                 virtual void loginFailed (void) {}
00090                 virtual void readyproxy (void) {}
00091                 virtual void doneAuth (void) {}
00092 
00099                 NXClientLibExternalCallbacks * externalCallbacks;
00100         };
00101 
00106         class NXClientLibCallbacks : public notQProcessCallbacks, public NXSessionCallbacks
00107         {
00108         public:
00109                 NXClientLibCallbacks();
00110                 ~NXClientLibCallbacks();
00111                 
00120                 void startedSignal (string name);
00121                 void errorSignal (int error);
00122                 void processFinishedSignal (string name);
00123                 void readyReadStandardOutputSignal (void);
00124                 void readyReadStandardErrorSignal (void);
00126 
00130                 void noSessionsSignal (void);
00131                 void loginFailedSignal (void);
00132                 void readyForProxySignal (void);
00133                 void authenticatedSignal (void);
00134                 void sessionsSignal (list<NXResumeData>);
00136 
00137 
00141                 void setParent (NXClientLibBase * p) { this->parent = p; }
00142         private:
00143                 NXClientLibBase * parent;
00144         };
00145 
00146         class NXClientLib : public NXClientLibBase
00147         {
00148         public:
00149                 NXClientLib();
00150                 ~NXClientLib();
00151 
00171                 void invokeNXSSH (string publicKey = "supplied", string serverHost = "",
00172                                   bool encryption = true, string key = "", int port = 22);
00173 
00180                 void write (string data);
00181 
00185                 void allowSSHConnect (bool auth);
00186 
00190                 void invokeProxy (void);
00191 
00199                 string parseSSH (string message);
00200 
00206                 //void checkSession (void);
00207 
00215                 bool chooseResumable (int n); 
00216 
00225                 bool terminateSession (int n); 
00226 
00227                 // public slots:
00229                 void doneAuth (void);
00230                 void loginFailed (void);
00231                 void finished (void) { dbgln ("Finishing up on signal"); this->isFinished = true; }
00232                 void readyproxy (void) { dbgln ("ready for nxproxy"); this->readyForProxy = true; }
00233                 void reset (void);
00234                 void processParseStdout (void);
00235                 void processParseStderr (void);
00236 
00242                 void requestConfirmation (string msg);
00244 
00245                 // Accessors
00247 
00250                 void setUsername (string& user) {
00251                         this->nxuser = user;
00252                         this->session.setUsername (this->nxuser); 
00253                 }
00257                 void setPassword (string& pass) {
00258                         this->nxpass = pass;
00259                         this->session.setPassword (this->nxpass); 
00260                 }
00261 
00262                 void setResolution (int x, int y) { this->session.setResolution(x, y); }
00263                 void setDepth (int depth) { this->session.setDepth(depth); }
00264                 void setRender (bool render) { this->session.setRender(render); }
00265                 void setSessionData (NXSessionData *);
00266                 notQProcess* getNXSSHProcess (void) { return this->pNxsshProcess; }
00267                 notQProcess* getNXProxyProcess (void) { return this->pNxproxyProcess; }
00268                 bool getIsFinished (void) { return this->isFinished; }
00269                 bool getReadyForProxy (void) { return this->readyForProxy; }
00270                 NXSession* getSession (void) { return &this->session; }
00271                 void setIsFinished (bool status) { this->isFinished = status; }
00272                 void setExternalCallbacks (NXClientLibExternalCallbacks * cb) { this->externalCallbacks = cb; }
00273                 bool getSessionRunning (void) { return this->sessionRunning; }
00275 
00276         private:
00286                 string getPath (string prog);
00287 
00293                 bool isFinished;
00297                 bool readyForProxy;
00304                 bool sessionRunning;
00308                 bool password;
00309                 
00310                 // FIXME: I hold the actual data, and a pointer to the
00311                 // data here. I tried to get rid of the pointer, and
00312                 // modify main.cpp in ../nxcl and that didn't work
00313                 // properly - I'm not sure why. I suppose I could get
00314                 // rid of the objects here, and then call
00315                 // pNxsshProcess = new notQProcess; in the
00316                 // constructor...
00320                 notQProcess nxsshProcess;
00321                 notQProcess* pNxsshProcess;
00325                 notQProcess nxproxyProcess;
00326                 notQProcess* pNxproxyProcess;
00332                 NXClientLibCallbacks callbacks;
00336                 notQTemporaryFile *keyFile;
00340                 NXSession session;
00346                 ProxyData proxyData;
00350                 string nxuser;
00354                 string nxpass;
00355         };
00356 
00357 } // namespace
00358 #endif

Generated on Wed Oct 17 10:08:25 2007 for nxcl by  doxygen 1.4.2