-
Notifications
You must be signed in to change notification settings - Fork 7
/
MySession.h
207 lines (190 loc) · 5.74 KB
/
MySession.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
// $Id: MySession.h 704 2012-03-14 14:55:15Z felfert $
//
// Copyright (C) 2006 The OpenNX Team
// Author: Fritz Elfert
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU Library General Public License as
// published by the Free Software Foundation; either version 2 of the
// License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU Library General Public
// License along with this program; if not, write to the
// Free Software Foundation, Inc.,
// 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
#ifndef _MYSESSION_H_
#define _MYSESSION_H_
#include <wx/regex.h>
#include "MyXmlConfig.h"
class ConnectDialog;
class MyIPC;
class SessionWatch;
class MyXmlConfig;
class MySession : public wxEvtHandler
{
DECLARE_DYNAMIC_CLASS(MySession);
DECLARE_EVENT_TABLE();
public:
typedef enum {
None,
Client,
Server,
} tSessionType;
typedef enum {
Unknown,
Failed,
Terminated,
Running,
} tSessionStatus;
typedef enum {
XARCH_NONE,
XARCH_CYGWIN,
XARCH_XMING,
} tXarch;
MySession();
MySession(wxString dir, wxString status, wxString stype, wxString host, int port, wxString md5);
MySession(const MySession &src);
virtual ~MySession();
// session admin
wxString sGetCreationTime();
wxString sGetPID() { return wxString::Format(_T("%d"), (int)m_lPid); }
wxString sGetPort() { return wxString::Format(_T("%d"), (int)m_iPort); }
const wxString& sGetHost() { return m_sHost; }
const wxString& sGetMd5() { return m_sMd5; }
const wxString& sGetDir() { return m_sDir; }
tSessionStatus eGetSessionStatus() { return m_eSessionStatus; }
tSessionType eGetSessionType() { return m_eSessionType; }
wxString sGetSessionStatus();
wxString sGetSessionType();
void bSetTouched(bool b) { m_bTouched = b; }
bool bGetTouched() { return m_bTouched; }
long lGetPID() { return m_lPid; }
bool bGetPidFromFile();
void CheckState();
bool IsValid() { return m_bValid; }
MySession &operator =(const MySession &src);
// connection setup
bool Create(MyXmlConfig& cfg, const wxString password, wxWindow *parent = NULL);
private:
// locals for connection setup
typedef enum {
STATE_INIT,
STATE_HELLO,
STATE_SHELLMODE,
STATE_AUTHMODE,
STATE_LOGIN,
STATE_LIST_SESSIONS,
STATE_PARSE_SESSIONS,
STATE_LIST_RESOURCES,
STATE_PARSE_RESOURCES,
STATE_START_SESSION,
STATE_ATTACH_SESSION,
STATE_ATTACH_VIEW_SESSION,
STATE_RESUME_SESSION,
STATE_KILL_SESSION,
STATE_ABORT,
STATE_FINISH,
STATE_WAIT,
} tConnectState;
wxArrayString m_aParseBuffer;
wxString getXauthCookie(int display = 0, wxString = wxT("/unix"));
wxString getXauthPath(tXarch = XARCH_XMING);
wxString formatOptFilename();
unsigned short getFirstFreePort(unsigned short);
void setTurboPath(bool enable);
void checkXarch();
void startProxy();
void startSharing();
void parseSessions(bool moreAllowed);
void parseResources();
void initversion(const wxString &s = wxEmptyString);
bool isCupsRunning();
void printSsh(const wxString &s, bool doLog = true, const wxString &reason = wxT(""));
void cleanupOldSessions();
void clearSshKeys(const wxString &);
ArrayOfShareGroups getActiveCupsPrinters();
virtual void OnSshEvent(wxCommandEvent &);
virtual void OnSessionEvent(wxCommandEvent &);
void SshLog(const wxChar *fmt, ...);
#ifdef __WXMSW__
wxString getXfontPath(tXarch);
bool startXserver();
void unhideNXWin();
void terminateXserver();
#endif
tConnectState m_eConnectState;
tXarch m_eXarch;
bool m_bGotError;
bool m_bAbort;
bool m_bSslTunneling;
bool m_bSessionRunning;
bool m_bEsdRunning;
bool m_bNativePARunning;
bool m_bSessionEstablished;
bool m_bCollectSessions;
bool m_bCollectConfig;
bool m_bCollectResources;
bool m_bIsShadow;
bool m_bInParseSessions;
bool m_bCupsRunning;
bool m_bRemoveKey;
bool m_bNextCmd;
int m_iProgress;
int m_iReader;
int m_iHttpPort;
int m_iXserverPID;
long m_lEsdPort;
long m_lProtocolVersion;
long m_lSrvProtocolVersion;
unsigned long m_nSessionPushLength;
wxLog *m_pSshLog;
MyIPC *m_pNxSsh;
MyXmlConfig *m_pCfg;
ConnectDialog *m_pDlg;
wxString m_sConfigBuffer;
wxString m_sClearPassword;
wxString m_sSessionID;
wxString m_sSessionType;
wxString m_sSessionCache;
wxString m_sSessionDisplay;
wxString m_sProxyCookie;
wxString m_sProxyIP;
wxString m_sProxyPort;
wxString m_sSmbPort;
wxString m_sSubscription;
wxString m_sAgentCookie;
wxString m_sOptFilename;
wxString m_sOffendingKey;
wxString m_sSessionDir;
wxString m_sUserDir;
wxString m_sSysDir;
wxString m_sXauthCookie;
wxString m_sResumeName;
wxString m_sResumeType;
wxString m_sResumeId;
wxString m_sResumePort;
wxString m_sKillId;
wxString m_sTempDir;
wxString m_sProtocolVersion;
wxString m_sShadowGeometry;
wxWindow *m_pParent;
SessionWatch *m_pSessionWatch;
// locals for admin tool
bool m_bTouched;
bool m_bValid;
int m_iPort;
long m_lPid;
tSessionType m_eSessionType;
tSessionStatus m_eSessionStatus;
wxString m_sHost;
wxString m_sMd5;
wxString m_sDir;
wxRegEx m_rePID;
};
#endif