-
Notifications
You must be signed in to change notification settings - Fork 3
/
desktop.hh
207 lines (170 loc) · 6.97 KB
/
desktop.hh
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
/*********************************************************
* Copyright (C) 2008 VMware, Inc. All rights reserved.
*
* This file is part of VMware View Open Client.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation version 2.1 and no later version.
*
* This program is released with an additional exemption that
* compiling, linking, and/or using the OpenSSL libraries with this
* program is allowed.
*
* 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 Lesser GNU General Public
* License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
*********************************************************/
/*
* desktop.hh --
*
* Desktop info representing a possibly connected desktop exposed by the Broker.
*/
#ifndef DESKTOP_HH
#define DESKTOP_HH
#include <boost/signal.hpp>
#include "brokerXml.hh"
#include "usb.hh"
namespace cdk {
class Desktop
{
public:
/*
* This enum captures various states of connection as well as in-flight
* commands being executed on the desktop (reset, logout, rollback).
* These commands are remembered here because they're asynchronous, and
* we can't always tell what's going on otherwise.
*/
enum ConnectionState {
STATE_DISCONNECTED,
STATE_CONNECTING,
STATE_CONNECTED,
STATE_RESETTING,
STATE_KILLING_SESSION,
STATE_ROLLING_BACK
};
/*
* This enum represents the various statii the desktop can be in. This is
* used for status messages and icons.
*/
enum Status {
/* We could not determine the status. */
STATUS_UNKNOWN,
/* The server reported an offline state we do not understand. */
STATUS_UNKNOWN_OFFLINE_STATE,
/* We are current resetting the desktop. */
STATUS_RESETTING,
/* We are currently logging off from the desktop. */
STATUS_LOGGING_OFF,
/* We are currently rolling back the desktop. */
STATUS_ROLLING_BACK,
/*
* The administrator has initiated a rollback of the desktop that has not
* yet completed.
*/
STATUS_SERVER_ROLLBACK,
/*
* We are in the process of doing local processing in response to a
* a server side rollback.
*/
STATUS_HANDLING_SERVER_ROLLBACK,
/* The desktop is checked out here but is currently disabled. */
STATUS_CHECKED_OUT_DISABLED,
/* The desktop is checked out by another user. */
STATUS_CHECKED_OUT_BY_OTHER,
/* The desktop is checked out, but unavailable. */
STATUS_CHECKED_OUT_UNAVAILABLE,
/* The desktop is currently being checked in. */
STATUS_NONBACKGROUND_TRANSFER_CHECKING_IN,
/* The desktop is currently being checked out. */
STATUS_NONBACKGROUND_TRANSFER_CHECKING_OUT,
/* We are currently discarding the desktop's checkout. */
STATUS_DISCARDING_CHECKOUT,
/* The desktop is in maintenance mode. */
STATUS_MAINTENANCE_MODE,
/* The desktop currently has a login session. */
STATUS_LOGGED_ON,
/* The desktop is available for remote use. */
STATUS_AVAILABLE_REMOTE,
/* The desktop is available for local use. */
STATUS_AVAILABLE_LOCAL,
/* The desktop is expired. */
STATUS_EXPIRED
};
Desktop(BrokerXml &xml, BrokerXml::Desktop &desktopInfo);
~Desktop();
void SetInfo(BrokerXml::Desktop &desktopInfo);
ConnectionState GetConnectionState() const { return mConnectionState; }
void Connect(Util::AbortSlot onAbort, Util::DoneSlot onDone,
const Util::ClientInfoMap &info);
void Disconnect();
bool CanConnect() const;
bool CanReset() const { return mDesktopInfo.resetAllowed; }
bool CanResetSession() const { return mDesktopInfo.resetAllowedOnSession; }
void ResetDesktop(Util::AbortSlot onAbort, Util::DoneSlot onDone);
Util::string GetID() const { return mDesktopInfo.id; }
Util::string GetName() const { return mDesktopInfo.name; }
Util::string GetSessionID() const { return mDesktopInfo.sessionId; }
void KillSession(Util::AbortSlot onAbort, Util::DoneSlot onDone);
void Rollback(Util::AbortSlot onAbort, Util::DoneSlot onDone);
Util::string GetState() const { return mDesktopInfo.state; }
bool GetOfflineEnabled() const { return mDesktopInfo.offlineEnabled; }
bool GetEndpointEnabled() const { return mDesktopInfo.endpointEnabled; }
BrokerXml::OfflineState GetOfflineState() const
{ return mDesktopInfo.offlineState; }
bool GetCheckedOutUnavailable() const;
bool GetCheckedOutByOther() const { return mDesktopInfo.checkedOutByOther; }
bool InMaintenanceMode() const { return mDesktopInfo.inMaintenance; }
bool IsCheckedOutHereAndDisabled() const;
bool InNonBackgroundDesktopTransfer() const;
bool IsExpired() const { return mDesktopInfo.expired; }
bool GetIsUSBEnabled() const { return mDesktopConn.enableUSB; }
bool GetIsMMREnabled() const { return mDesktopConn.enableMMR; }
std::vector<Util::string> GetProtocols() const
{ return mDesktopInfo.protocols; }
Util::string GetProtocol() const { return mProtocol; }
void SetProtocol(const Util::string &protocol);
bool GetAutoConnect() const;
Status GetStatus() const;
Util::string GetStatusMsg(bool isOffline) const;
bool IsCVP() const;
bool GetRequiresDownload() const;
void StartUsb();
const BrokerXml::DesktopConnection &GetConnection() const
{ return mDesktopConn; }
void SetForcedStatus(Status status)
{ mForcedStatus = status; }
void ClearForcedStatus()
{ mForcedStatus = STATUS_UNKNOWN; }
bool HasForcedStatus() const
{ return STATUS_UNKNOWN != mForcedStatus; }
boost::signal0<void> changed;
private:
void SetConnectionState(ConnectionState state);
void OnGetDesktopConnectionDone(BrokerXml::Result &result,
BrokerXml::DesktopConnection &conn,
Util::DoneSlot onDone);
void OnGetDesktopConnectionAbort(bool cancelled, Util::exception err,
Util::AbortSlot onAbort);
void OnResetDesktopAbort(bool canceled, Util::exception err,
Util::AbortSlot onAbort);
void OnKillSessionAbort(bool canceled, Util::exception err,
Util::AbortSlot onAbort);
void OnRollbackAbort(bool canceled, Util::exception err,
Util::AbortSlot onAbort);
BrokerXml &mXml;
BrokerXml::Desktop mDesktopInfo;
ConnectionState mConnectionState;
BrokerXml::DesktopConnection mDesktopConn;
Usb mUsb;
Util::string mProtocol;
Status mForcedStatus;
};
} // namespace cdk
#endif // DESKTOP_HH