forked from team-unstablers/ulalaca-xrdp
-
Notifications
You must be signed in to change notification settings - Fork 1
/
XrdpUlalacaPrivate.xrdpmodule.cpp
158 lines (124 loc) · 4.02 KB
/
XrdpUlalacaPrivate.xrdpmodule.cpp
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
#include "XrdpUlalacaPrivate.hpp"
#include "ulalaca.hpp"
#include "SessionBrokerClient.hpp"
#include "ProjectorClient.hpp"
int XrdpUlalacaPrivate::libModStart(int width, int height, int bpp) {
// #517eb9
constexpr const unsigned int BACKGROUND_COLOR = 0xb97e51;
_screenLayouts.clear();
_screenLayouts.emplace_back(ULIPCRect {
0, 0, (short) width, (short) height
});
calculateSessionSize();
_mod->server_begin_update(_mod);
_mod->server_set_fgcolor(_mod, (int) BACKGROUND_COLOR);
_mod->server_fill_rect(_mod, 0, 0, width, height);
_mod->server_end_update(_mod);
/*
if (!isBPPSupported(bpp)) {
return 1;
}
*/
_bpp = bpp;
// _this->updateBpp(bpp);
return 0;
}
int XrdpUlalacaPrivate::libModConnect() {
const std::string sessionBrokerIPCPath("/var/run/ulalaca_broker.sock");
SessionBrokerClient brokerClient(sessionBrokerIPCPath);
auto response = brokerClient.requestSession(_username, _password);
std::fill(_password.begin(), _password.end(), '\0');
_password.clear();
if (!response.isSuccessful) {
serverMessage("failed to request session", response.reason);
LOG(LOG_LEVEL_ERROR, "failed to request session: code %d (user %s)", response.reason, _username.c_str());
return 1;
}
// TODO: try-catch
attachToSession(response.sessionPath);
return 0;
}
int XrdpUlalacaPrivate::libModEvent(int type, long arg1, long arg2, long arg3, long arg4) {
XrdpEvent event {
(XrdpEvent::Type) type,
arg1, arg2, arg3, arg4
};
if (_projectorClient != nullptr) {
_projectorClient->handleEvent(event);
}
return 0;
}
int XrdpUlalacaPrivate::libModSignal() {
LOG(LOG_LEVEL_INFO, "lib_mod_signal() called");
return 0;
}
int XrdpUlalacaPrivate::libModEnd() {
LOG(LOG_LEVEL_INFO, "lib_mod_end() called");
if (_projectorClient != nullptr) {
_projectorClient->stop();
}
return 0;
}
int XrdpUlalacaPrivate::libModSetParam(const char *cstrName, const char *cstrValue) {
std::string name(cstrName);
std::string value(cstrValue);
if (name == "username") {
_username = value;
} else if (name == "password") {
_password = value;
} else if (name == "ip") {
_ip = value;
} else if (name == "port") {
_port = value;
} else if (name == "keylayout") {
_keyLayout = std::stoi(value);
} else if (name == "delay_ms") {
_delayMs = std::stoi(value);
} else if (name == "guid") {
auto *guid = reinterpret_cast<const struct guid *>(cstrValue);
_guid = *guid;
} else if (name == "disabled_encodings_mask") {
_encodingsMask = ~std::stoi(value);
} else if (name == "client_info") {
auto *clientInfo = reinterpret_cast<const struct xrdp_client_info *>(cstrValue);
_clientInfo = *clientInfo;
}
return 0;
}
int XrdpUlalacaPrivate::libModSessionChange(int, int) {
return 0;
}
int XrdpUlalacaPrivate::libModGetWaitObjs(tbus *readObjs, int *rcount, tbus *writeObjs, int *wcount, int *timeout) {
// FIXME
if (!_isUpdateThreadRunning) {
return 0;
}
if (_error != 0) {
return 1;
}
readObjs[(*rcount)++] = _projectorClient->descriptor();
writeObjs[(*wcount)++] = _projectorClient->descriptor();
return 0;
}
int XrdpUlalacaPrivate::libModCheckWaitObjs() {
// TODO: move ipcConnection.read()/write() to here..?
return 0;
}
int XrdpUlalacaPrivate::libModFrameAck(int flags, int frameId) {
LOG(LOG_LEVEL_TRACE, "lib_mod_frame_ack() called: %d", frameId);
_ackFrameId = frameId;
return 0;
}
int XrdpUlalacaPrivate::libModSuppressOutput(int suppress, int left, int top, int right, int bottom) {
return 0;
}
int XrdpUlalacaPrivate::libModServerMonitorResize(int width, int height) {
return 0;
}
int XrdpUlalacaPrivate::libModServerMonitorFullInvalidate(int width, int height) {
_fullInvalidate = true;
return 0;
}
int XrdpUlalacaPrivate::libModServerVersionMessage() {
return 0;
}