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
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
|
/*
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU 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 General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
xrdp: A Remote Desktop Protocol server.
Copyright (C) Jay Sorg 2004-2006
interface
*/
#include "xrdp.h"
/*****************************************************************************/
/* this is the log windows nofity function */
int DEFAULT_CC
xrdp_wm_log_wnd_notify(struct xrdp_bitmap* wnd,
struct xrdp_bitmap* sender,
int msg, long param1, long param2)
{
struct xrdp_painter* painter;
struct xrdp_wm* wm;
struct xrdp_rect rect;
int index;
char* text;
if (wnd == 0)
{
return 0;
}
if (sender == 0)
{
return 0;
}
if (wnd->owner == 0)
{
return 0;
}
wm = wnd->wm;
if (msg == 1) /* click */
{
if (sender->id == 1) /* ok button */
{
/* close the log window */
MAKERECT(rect, wnd->left, wnd->top, wnd->width, wnd->height);
xrdp_bitmap_delete(wnd);
xrdp_bitmap_invalidate(wm->screen, &rect);
if (wm->mod_handle == 0)
{
wm->pro_layer->term = 1; /* kill session */
}
}
}
else if (msg == WM_PAINT) /* 3 */
{
painter = (struct xrdp_painter*)param1;
if (painter != 0)
{
painter->font->color = wnd->wm->black;
for (index = 0; index < wnd->wm->log->count; index++)
{
text = (char*)list_get_item(wnd->wm->log, index);
xrdp_painter_draw_text(painter, wnd, 10, 30 + index * 15, text);
}
}
}
return 0;
}
/*****************************************************************************/
int DEFAULT_CC
server_begin_update(struct xrdp_mod* mod)
{
struct xrdp_wm* wm;
struct xrdp_painter* p;
wm = (struct xrdp_wm*)mod->wm;
p = xrdp_painter_create(wm, wm->session);
xrdp_painter_begin_update(p);
mod->painter = (long)p;
return 0;
}
/*****************************************************************************/
int DEFAULT_CC
server_end_update(struct xrdp_mod* mod)
{
struct xrdp_painter* p;
p = (struct xrdp_painter*)mod->painter;
xrdp_painter_end_update(p);
xrdp_painter_delete(p);
mod->painter = 0;
return 0;
}
/*****************************************************************************/
int DEFAULT_CC
server_fill_rect(struct xrdp_mod* mod, int x, int y, int cx, int cy)
{
struct xrdp_wm* wm;
struct xrdp_painter* p;
wm = (struct xrdp_wm*)mod->wm;
p = (struct xrdp_painter*)mod->painter;
xrdp_painter_fill_rect(p, wm->screen, x, y, cx, cy);
return 0;
}
/*****************************************************************************/
int DEFAULT_CC
server_screen_blt(struct xrdp_mod* mod, int x, int y, int cx, int cy,
int srcx, int srcy)
{
struct xrdp_wm* wm;
struct xrdp_painter* p;
wm = (struct xrdp_wm*)mod->wm;
p = (struct xrdp_painter*)mod->painter;
p->rop = 0xcc;
xrdp_painter_copy(p, wm->screen, wm->screen, x, y, cx, cy, srcx, srcy);
return 0;
}
/*****************************************************************************/
int DEFAULT_CC
server_paint_rect(struct xrdp_mod* mod, int x, int y, int cx, int cy,
char* data, int width, int height, int srcx, int srcy)
{
struct xrdp_wm* wm;
struct xrdp_bitmap* b;
struct xrdp_painter* p;
wm = (struct xrdp_wm*)mod->wm;
p = (struct xrdp_painter*)mod->painter;
b = xrdp_bitmap_create_with_data(width, height, wm->screen->bpp, data, wm);
xrdp_painter_copy(p, b, wm->screen, x, y, cx, cy, srcx, srcy);
xrdp_bitmap_delete(b);
return 0;
}
/*****************************************************************************/
int DEFAULT_CC
server_set_pointer(struct xrdp_mod* mod, int x, int y,
char* data, char* mask)
{
struct xrdp_wm* wm;
wm = (struct xrdp_wm*)mod->wm;
xrdp_wm_pointer(wm, data, mask, x, y);
return 0;
}
/*****************************************************************************/
int DEFAULT_CC
server_palette(struct xrdp_mod* mod, int* palette)
{
struct xrdp_wm* wm;
wm = (struct xrdp_wm*)mod->wm;
if (g_memcmp(wm->palette, palette, 255 * sizeof(int)) != 0)
{
g_memcpy(wm->palette, palette, 256 * sizeof(int));
xrdp_wm_send_palette(wm);
}
return 0;
}
/*****************************************************************************/
int DEFAULT_CC
server_msg(struct xrdp_mod* mod, char* msg, int code)
{
struct xrdp_wm* wm;
struct xrdp_bitmap* but;
if (code == 1)
{
g_printf(msg);
g_printf("\r\n");
return 0;
}
wm = (struct xrdp_wm*)mod->wm;
list_add_item(wm->log, (long)g_strdup(msg));
if (wm->log_wnd == 0)
{
/* log window */
wm->log_wnd = xrdp_bitmap_create(400, 400, wm->screen->bpp,
WND_TYPE_WND, wm);
list_add_item(wm->screen->child_list, (long)wm->log_wnd);
wm->log_wnd->parent = wm->screen;
wm->log_wnd->owner = wm->screen;
wm->log_wnd->bg_color = wm->grey;
wm->log_wnd->left = 10;
wm->log_wnd->top = 10;
set_string(&wm->log_wnd->caption1, "Connection Log");
/* ok button */
but = xrdp_bitmap_create(60, 25, wm->screen->bpp, WND_TYPE_BUTTON, wm);
list_insert_item(wm->log_wnd->child_list, 0, (long)but);
but->parent = wm->log_wnd;
but->owner = wm->log_wnd;
but->left = (400 - 60) - 10;
but->top = (400 - 25) - 10;
but->id = 1;
but->tab_stop = 1;
set_string(&but->caption1, "OK");
wm->log_wnd->focused_control = but;
/* set notify function */
wm->log_wnd->notify = xrdp_wm_log_wnd_notify;
}
xrdp_bitmap_invalidate(wm->log_wnd, 0);
g_sleep(100);
return 0;
}
/*****************************************************************************/
int DEFAULT_CC
server_is_term(struct xrdp_mod* mod)
{
return g_is_term();
}
/*****************************************************************************/
int DEFAULT_CC
server_set_clip(struct xrdp_mod* mod, int x, int y, int cx, int cy)
{
struct xrdp_painter* p;
p = (struct xrdp_painter*)mod->painter;
return xrdp_painter_set_clip(p, x, y, cx, cy);
}
/*****************************************************************************/
int DEFAULT_CC
server_reset_clip(struct xrdp_mod* mod)
{
struct xrdp_painter* p;
p = (struct xrdp_painter*)mod->painter;
return xrdp_painter_clr_clip(p);
}
/*****************************************************************************/
int DEFAULT_CC
server_set_fgcolor(struct xrdp_mod* mod, int fgcolor)
{
struct xrdp_painter* p;
p = (struct xrdp_painter*)mod->painter;
p->fg_color = fgcolor;
p->pen.color = p->fg_color;
return 0;
}
/*****************************************************************************/
int DEFAULT_CC
server_set_bgcolor(struct xrdp_mod* mod, int bgcolor)
{
struct xrdp_painter* p;
p = (struct xrdp_painter*)mod->painter;
p->bg_color = bgcolor;
return 0;
}
/*****************************************************************************/
int DEFAULT_CC
server_set_opcode(struct xrdp_mod* mod, int opcode)
{
struct xrdp_painter* p;
p = (struct xrdp_painter*)mod->painter;
p->rop = opcode;
return 0;
}
/*****************************************************************************/
int DEFAULT_CC
server_set_mixmode(struct xrdp_mod* mod, int mixmode)
{
struct xrdp_painter* p;
p = (struct xrdp_painter*)mod->painter;
p->mix_mode = mixmode;
return 0;
}
/*****************************************************************************/
int DEFAULT_CC
server_set_brush(struct xrdp_mod* mod, int x_orgin, int y_orgin,
int style, char* pattern)
{
struct xrdp_painter* p;
p = (struct xrdp_painter*)mod->painter;
p->brush.x_orgin = x_orgin;
p->brush.y_orgin = y_orgin;
p->brush.style = style;
g_memcpy(p->brush.pattern, pattern, 8);
return 0;
}
/*****************************************************************************/
int DEFAULT_CC
server_set_pen(struct xrdp_mod* mod, int style, int width)
{
struct xrdp_painter* p;
p = (struct xrdp_painter*)mod->painter;
p->pen.style = style;
p->pen.width = width;
return 0;
}
/*****************************************************************************/
int DEFAULT_CC
server_draw_line(struct xrdp_mod* mod, int x1, int y1, int x2, int y2)
{
struct xrdp_wm* wm;
struct xrdp_painter* p;
wm = (struct xrdp_wm*)mod->wm;
p = (struct xrdp_painter*)mod->painter;
return xrdp_painter_line(p, wm->screen, x1, y1, x2, y2);
}
/*****************************************************************************/
int DEFAULT_CC
server_add_char(struct xrdp_mod* mod, int font, int charactor,
int offset, int baseline,
int width, int height, char* data)
{
struct xrdp_font_char fi;
fi.offset = offset;
fi.baseline = baseline;
fi.width = width;
fi.height = height;
fi.incby = 0;
fi.data = data;
return libxrdp_orders_send_font(((struct xrdp_wm*)mod->wm)->session,
&fi, font, charactor);
}
/*****************************************************************************/
int DEFAULT_CC
server_draw_text(struct xrdp_mod* mod, int font,
int flags, int mixmode, int clip_left, int clip_top,
int clip_right, int clip_bottom,
int box_left, int box_top,
int box_right, int box_bottom,
int x, int y, char* data, int data_len)
{
struct xrdp_wm* wm;
struct xrdp_painter* p;
wm = (struct xrdp_wm*)mod->wm;
p = (struct xrdp_painter*)mod->painter;
return xrdp_painter_draw_text2(p, wm->screen, font, flags,
mixmode, clip_left, clip_top,
clip_right, clip_bottom,
box_left, box_top,
box_right, box_bottom,
x, y, data, data_len);
}
/*****************************************************************************/
int DEFAULT_CC
server_reset(struct xrdp_mod* mod, int width, int height, int bpp)
{
struct xrdp_wm* wm;
wm = (struct xrdp_wm*)mod->wm;
if (wm->client_info == 0)
{
return 1;
}
/* older client can't resize */
if (wm->client_info->build <= 419)
{
return 0;
}
/* if same, don't need to do anything */
if (wm->client_info->width == width &&
wm->client_info->height == height &&
wm->client_info->bpp == bpp)
{
return 0;
}
/* reset lib, client_info gets updated in libxrdp_reset */
if (libxrdp_reset(wm->session, width, height, bpp) != 0)
{
return 1;
}
/* reset cache */
xrdp_cache_reset(wm->cache, wm->client_info);
/* resize the main window */
xrdp_bitmap_resize(wm->screen, wm->client_info->width,
wm->client_info->height);
/* load some stuff */
xrdp_wm_load_static_colors(wm);
xrdp_wm_load_static_pointers(wm);
return 0;
}
|