/[rdesktop]/sourceforge.net/trunk/rdesktop/uiports/qtwin.cpp
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /sourceforge.net/trunk/rdesktop/uiports/qtwin.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 780 - (show annotations)
Mon Oct 4 03:24:09 2004 UTC (19 years, 9 months ago) by jsorg71
File size: 40554 byte(s)
added 16 bit color and sound and command line params to qte and other cleanups

1 /*
2 rdesktop: A Remote Desktop Protocol client.
3 User interface services - QT Window System
4 Copyright (C) Jay Sorg 2004
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program; if not, write to the Free Software
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21 #include "../rdesktop.h"
22
23 #include <qapplication.h>
24 #include <qmainwindow.h>
25 #include <qwidget.h>
26 #include <qpainter.h>
27 #include <qpixmap.h>
28 #include <qbrush.h>
29 #include <qimage.h>
30 #include <qbitmap.h>
31 #include <qcursor.h>
32 #include <qsocketnotifier.h>
33 #include <qscrollview.h>
34 #include <qfile.h>
35
36 #include "qtwin.h"
37 #include <unistd.h> // gethostname
38 #include <pwd.h> // getpwuid
39 #include <stdarg.h> // va_list va_start va_end
40
41 /* rdesktop globals */
42 extern int g_tcp_port_rdp;
43 int g_use_rdp5 = 0;
44 char g_hostname[16];
45 char g_username[64];
46 int g_height = 600;
47 int g_width = 800;
48 int g_server_bpp = 8;
49 int g_encryption = 1;
50 int g_desktop_save =1;
51 int g_bitmap_cache = 1;
52 int g_bitmap_cache_persist_enable = False;
53 int g_bitmap_cache_precache = True;
54 int g_bitmap_compression = 1;
55 int g_rdp5_performanceflags = 0;
56 int g_console_session = 0;
57 int g_keylayout = 0x409; /* Defaults to US keyboard layout */
58
59 /* hack globals */
60 int g_argc = 0;
61 char** g_argv = 0;
62 int UpAndRunning = 0;
63 int g_sock = 0;
64 int deactivated = 0;
65 uint32 ext_disc_reason = 0;
66 char g_servername[128];
67 char g_title[128] = "";
68
69 /* qt globals */
70 QSocketNotifier* SocketNotifier;
71 QApplication* App;
72 QMyMainWindow* MW;
73 QMyScrollView* SV;
74 QPixmap* BS;
75 QPixmap* DS;
76 QPainter* P1;
77 QPainter* P2;
78 QColor Color1;
79 QColor Color2;
80 struct QColorMap
81 {
82 uint32 RGBColors[256];
83 int NumColors;
84 };
85 QColorMap* CM = 0;
86 QRegion* ClipRect;
87
88 Qt::RasterOp OpCodes[16] = {
89 Qt::ClearROP, // BLACKNESS 0
90 Qt::NorROP, // NOTSRCERASE DSon
91 Qt::NotAndROP, // DSna
92 Qt::NotCopyROP, // NOTSRCCOPY Sn
93 Qt::AndNotROP, // SRCERASE SDna
94 Qt::NotROP, // DSTINVERT Dn
95 Qt::XorROP, // SRCINVERT DSx
96 Qt::NandROP, // DSan
97 Qt::AndROP, // SRCAND DSa
98 Qt::NotXorROP, // DSxn
99 Qt::NopROP, // D
100 Qt::NotOrROP, // MERGEPAINT DSno
101 Qt::CopyROP, // SRCCOPY S
102 Qt::OrNotROP, // SDno
103 Qt::OrROP, // SRCPAINT DSo
104 Qt::SetROP}; // WHITENESS 1
105
106 //*****************************************************************************
107 uint32 Color15to32(uint32 InColor)
108 {
109 uint32 r, g, b;
110 r = (InColor & 0x7c00) >> 10;
111 r = (r * 0xff) / 0x1f;
112 g = (InColor & 0x03e0) >> 5;
113 g = (g * 0xff) / 0x1f;
114 b = (InColor & 0x001f);
115 b = (b * 0xff) / 0x1f;
116 return (r << 16) | (g << 8) | b;
117 }
118
119 //*****************************************************************************
120 uint32 Color16to32(uint32 InColor)
121 {
122 uint32 r, g, b;
123 r = (InColor & 0xf800) >> 11;
124 r = (r * 0xff) / 0x1f;
125 g = (InColor & 0x07e0) >> 5;
126 g = (g * 0xff) / 0x3f;
127 b = (InColor & 0x001f);
128 b = (b * 0xff) / 0x1f;
129 return (r << 16) | (g << 8) | b;
130 }
131
132 //*****************************************************************************
133 uint32 Color24to32(uint32 InColor)
134 {
135 return ((InColor & 0x00ff0000) >> 16) | ((InColor & 0x000000ff) << 16) |
136 (InColor & 0x0000ff00);
137 }
138
139 //*****************************************************************************
140 void SetColorx(QColor* Color, uint32 InColor)
141 {
142 switch (g_server_bpp)
143 {
144 case 8:
145 if (CM == NULL || InColor > 255)
146 {
147 Color->setRgb(0);
148 return;
149 }
150 Color->setRgb(CM->RGBColors[InColor]);
151 break;
152 case 15:
153 Color->setRgb(Color15to32(InColor));
154 break;
155 case 16:
156 Color->setRgb(Color16to32(InColor));
157 break;
158 case 24:
159 Color->setRgb(Color24to32(InColor));
160 break;
161 default:
162 Color->setRgb(0);
163 }
164 }
165
166 //*****************************************************************************
167 void SetOpCode(int opcode)
168 {
169 if (opcode >= 0 && opcode < 16)
170 {
171 Qt::RasterOp op = OpCodes[opcode];
172 if (op != Qt::CopyROP)
173 {
174 P1->setRasterOp(op);
175 P2->setRasterOp(op);
176 }
177 }
178 }
179
180 //*****************************************************************************
181 void ResetOpCode(int opcode)
182 {
183 if (opcode >= 0 && opcode < 16)
184 {
185 Qt::RasterOp op = OpCodes[opcode];
186 if (op != Qt::CopyROP)
187 {
188 P1->setRasterOp(Qt::CopyROP);
189 P2->setRasterOp(Qt::CopyROP);
190 }
191 }
192 }
193
194 /*****************************************************************************/
195 QMyMainWindow::QMyMainWindow() : QWidget()
196 {
197 }
198
199 /*****************************************************************************/
200 QMyMainWindow::~QMyMainWindow()
201 {
202 }
203
204 //*****************************************************************************
205 void QMyMainWindow::mouseMoveEvent(QMouseEvent* e)
206 {
207 if (!UpAndRunning)
208 return;
209 rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_MOVE, e->x(), e->y());
210 }
211
212 //*****************************************************************************
213 void QMyMainWindow::mousePressEvent(QMouseEvent* e)
214 {
215 if (!UpAndRunning)
216 return;
217 if (e->button() == LeftButton)
218 rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON1,
219 e->x(), e->y());
220 else if (e->button() == RightButton)
221 rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON2,
222 e->x(), e->y());
223 else if (e->button() == MidButton)
224 rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON3,
225 e->x(), e->y());
226 }
227
228 //*****************************************************************************
229 void QMyMainWindow::mouseReleaseEvent(QMouseEvent* e)
230 {
231 if (!UpAndRunning)
232 return;
233 if (e->button() == LeftButton)
234 rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1, e->x(), e->y());
235 else if (e->button() == RightButton)
236 rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON2, e->x(), e->y());
237 else if (e->button() == MidButton)
238 rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON3, e->x(), e->y());
239 }
240
241 //*****************************************************************************
242 void QMyMainWindow::wheelEvent(QWheelEvent* e)
243 {
244 if (!UpAndRunning)
245 return;
246 if (e->delta() > 0)
247 rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON4, e->x(), e->y());
248 else if (e->delta() < 0)
249 rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON5, e->x(), e->y());
250 }
251
252 //*****************************************************************************
253 int GetScanCode(QKeyEvent* e)
254 {
255 int Key = e->key();
256 int ScanCode = 0;
257 Qt::ButtonState bs = e->state();
258 if (!(bs & Qt::ShiftButton)) // shift is not down
259 {
260 if (Key == 42) // *
261 return 0x37;
262 if (Key == 43) // +
263 return 0x4e;
264 }
265 switch (Key)
266 {
267 case 4100: ScanCode = 0x1c; break; // enter
268 case 4101: ScanCode = 0x1c; break;
269 case 4117: ScanCode = 0xd0; break; // down arrow
270 case 4115: ScanCode = 0xc8; break; // up arrow
271 case 4114: ScanCode = 0xcb; break; // left arrow
272 case 4116: ScanCode = 0xcd; break; // right arrow
273 case 4112: ScanCode = 0xc7; break; // home
274 case 4113: ScanCode = 0xcf; break; // end
275 case 4102: ScanCode = 0xd2; break; // insert
276 case 4103: ScanCode = 0xd3; break; // delete
277 case 4118: ScanCode = 0xc9; break; // page up
278 case 4119: ScanCode = 0xd1; break; // page down
279 case 4143: ScanCode = 0x00; break; // num lock
280 case 47: ScanCode = 0x35; break; // /
281 case 42: ScanCode = 0x37; break; // *
282 case 45: ScanCode = 0x0c; break; // -
283 case 95: ScanCode = 0x0c; break; // _
284 case 43: ScanCode = 0x0d; break; // +
285 case 46: ScanCode = 0x34; break; // .
286 case 48: ScanCode = 0x0b; break; // 0
287 case 41: ScanCode = 0x0b; break; // )
288 case 49: ScanCode = 0x02; break; // 1
289 case 33: ScanCode = 0x02; break; // !
290 case 50: ScanCode = 0x03; break; // 2
291 case 64: ScanCode = 0x03; break; // @
292 case 51: ScanCode = 0x04; break; // 3
293 case 35: ScanCode = 0x04; break; // #
294 case 52: ScanCode = 0x05; break; // 4
295 case 36: ScanCode = 0x05; break; // $
296 case 53: ScanCode = 0x06; break; // 5
297 case 37: ScanCode = 0x06; break; // %
298 case 54: ScanCode = 0x07; break; // 6
299 case 94: ScanCode = 0x07; break; // ^
300 case 55: ScanCode = 0x08; break; // 7
301 case 38: ScanCode = 0x08; break; // &
302 case 56: ScanCode = 0x09; break; // 8
303 case 57: ScanCode = 0x0a; break; // 9
304 case 40: ScanCode = 0x0a; break; // (
305 case 61: ScanCode = 0x0d; break; // =
306 case 65: ScanCode = 0x1e; break; // a
307 case 66: ScanCode = 0x30; break; // b
308 case 67: ScanCode = 0x2e; break; // c
309 case 68: ScanCode = 0x20; break; // d
310 case 69: ScanCode = 0x12; break; // e
311 case 70: ScanCode = 0x21; break; // f
312 case 71: ScanCode = 0x22; break; // g
313 case 72: ScanCode = 0x23; break; // h
314 case 73: ScanCode = 0x17; break; // i
315 case 74: ScanCode = 0x24; break; // j
316 case 75: ScanCode = 0x25; break; // k
317 case 76: ScanCode = 0x26; break; // l
318 case 77: ScanCode = 0x32; break; // m
319 case 78: ScanCode = 0x31; break; // n
320 case 79: ScanCode = 0x18; break; // o
321 case 80: ScanCode = 0x19; break; // p
322 case 81: ScanCode = 0x10; break; // q
323 case 82: ScanCode = 0x13; break; // r
324 case 83: ScanCode = 0x1f; break; // s
325 case 84: ScanCode = 0x14; break; // t
326 case 85: ScanCode = 0x16; break; // u
327 case 86: ScanCode = 0x2f; break; // v
328 case 87: ScanCode = 0x11; break; // w
329 case 88: ScanCode = 0x2d; break; // x
330 case 89: ScanCode = 0x15; break; // y
331 case 90: ScanCode = 0x2c; break; // z
332 case 32: ScanCode = 0x39; break; // space
333 case 44: ScanCode = 0x33; break; // ,
334 case 60: ScanCode = 0x33; break; // <
335 case 62: ScanCode = 0x34; break; // >
336 case 63: ScanCode = 0x35; break; // ?
337 case 92: ScanCode = 0x2b; break; // backslash
338 case 124: ScanCode = 0x2b; break; // bar
339 case 4097: ScanCode = 0x0f; break; // tab
340 case 4132: ScanCode = 0x3a; break; // caps lock
341 case 4096: ScanCode = 0x01; break; // esc
342 case 59: ScanCode = 0x27; break; // ;
343 case 58: ScanCode = 0x27; break; // :
344 case 39: ScanCode = 0x28; break; // '
345 case 34: ScanCode = 0x28; break; // "
346 case 91: ScanCode = 0x1a; break; // [
347 case 123: ScanCode = 0x1a; break; // {
348 case 93: ScanCode = 0x1b; break; // ]
349 case 125: ScanCode = 0x1b; break; // }
350 case 4144: ScanCode = 0x3b; break; // f1
351 case 4145: ScanCode = 0x3c; break; // f2
352 case 4146: ScanCode = 0x3d; break; // f3
353 case 4147: ScanCode = 0x3e; break; // f4
354 case 4148: ScanCode = 0x3f; break; // f5
355 case 4149: ScanCode = 0x40; break; // f6
356 case 4150: ScanCode = 0x41; break; // f7
357 case 4151: ScanCode = 0x42; break; // f8
358 case 4152: ScanCode = 0x43; break; // f9
359 case 4153: ScanCode = 0x44; break; // f10
360 case 4154: ScanCode = 0x57; break; // f11
361 case 4155: ScanCode = 0x58; break; // f12
362 case 4128: ScanCode = 0x2a; break; // shift
363 case 4131: ScanCode = 0x38; break; // alt
364 case 4129: ScanCode = 0x1d; break; // ctrl
365 case 96: ScanCode = 0x29; break; // `
366 case 126: ScanCode = 0x29; break; // ~
367 case 4099: ScanCode = 0x0e; break; // backspace
368 }
369 // if (ScanCode == 0)
370 // printf("key %d scancode %d\n", Key, ScanCode);
371 return ScanCode;
372 }
373
374 //*****************************************************************************
375 void QMyMainWindow::keyPressEvent(QKeyEvent* e)
376 {
377 if (!UpAndRunning)
378 return;
379 int ScanCode = GetScanCode(e);
380 if (ScanCode != 0)
381 {
382 rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYPRESS, ScanCode, 0);
383 e->accept();
384 }
385 }
386
387 //*****************************************************************************
388 void QMyMainWindow::keyReleaseEvent(QKeyEvent* e)
389 {
390 if (!UpAndRunning)
391 return;
392 int ScanCode = GetScanCode(e);
393 if (ScanCode != 0)
394 {
395 rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, ScanCode, 0);
396 e->accept();
397 }
398 }
399
400 //*****************************************************************************
401 void QMyMainWindow::paintEvent(QPaintEvent* pe)
402 {
403 QRect Rect;
404 Rect = pe->rect();
405 bitBlt(this, Rect.left(), Rect.top(), BS, Rect.left(), Rect.top(),
406 Rect.width(), Rect.height());
407 }
408
409 //*****************************************************************************
410 void QMyMainWindow::closeEvent(QCloseEvent* e)
411 {
412 e->accept();
413 }
414
415 //*****************************************************************************
416 bool QMyMainWindow::event(QEvent* e)
417 {
418 return QWidget::event(e);
419 }
420
421 //*****************************************************************************
422 void QMyMainWindow::dataReceived()
423 {
424 if (!rdp_loop(&deactivated, &ext_disc_reason))
425 SV->close();
426 }
427
428 //*****************************************************************************
429 void QMyScrollView::keyPressEvent(QKeyEvent* e)
430 {
431 MW->keyPressEvent(e);
432 }
433
434 //*****************************************************************************
435 void QMyScrollView::keyReleaseEvent(QKeyEvent* e)
436 {
437 MW->keyReleaseEvent(e);
438 }
439
440
441 //*****************************************************************************
442 void ui_begin_update(void)
443 {
444 P1->begin(MW);
445 P2->begin(BS);
446 }
447
448 //*****************************************************************************
449 void ui_end_update(void)
450 {
451 P1->end();
452 P2->end();
453 }
454
455 /*****************************************************************************/
456 int ui_init(void)
457 {
458 App = new QApplication(g_argc, g_argv);
459 return 1;
460 }
461
462 /*****************************************************************************/
463 void ui_deinit(void)
464 {
465 delete App;
466 }
467
468 /*****************************************************************************/
469 int ui_create_window(void)
470 {
471 int w, h;
472 MW = new QMyMainWindow();
473 SV = new QMyScrollView();
474 SV->addChild(MW);
475 BS = new QPixmap(g_width, g_height);
476 QPainter* P = new QPainter(BS);
477 P->fillRect(0, 0, g_width, g_height, QBrush(QColor("white")));
478 P->fillRect(0, 0, g_width, g_height, QBrush(QBrush::CrossPattern));
479 delete P;
480 DS = new QPixmap(480, 480);
481 P1 = new QPainter();
482 P2 = new QPainter();
483 ClipRect = new QRegion(0, 0, g_width, g_height);
484 QWidget* d = QApplication::desktop();
485 w = d->width(); // returns screen width
486 h = d->height(); // returns screen height
487 MW->resize(g_width, g_height);
488 if (w < g_width || h < g_height)
489 SV->resize(w, h);
490 else
491 SV->resize(g_width + 4, g_height + 4);
492 SV->setMaximumWidth(g_width + 4);
493 SV->setMaximumHeight(g_height + 4);
494 App->setMainWidget(SV);
495 SV->show();
496 MW->setMouseTracking(true);
497 if (g_title[0] != 0)
498 SV->setCaption(g_title);
499
500 /* XGrayKey(0, 64, AnyModifie, SV->winId(), 0, GrabModeAsync, GrabModeAsync);
501 XGrayKey(0, 113, AnyModifie, SV->winId(), 0, GrabModeAsync, GrabModeAsync);
502 XGrayKey(0, 37, AnyModifie, SV-winId(), 0, GrabModeAsync, GrabModeAsync);
503 XGrayKey(0, 109, AnyModifie, SV->winId(), 0, GrabModeAsync, GrabModeAsync);
504 XGrayKey(0, 115, AnyModifie, SV->winId(), 0, GrabModeAsync, GrabModeAsync);
505 XGrayKey(0, 116, AnyModifie, SV->winId(), 0, GrabModeAsync, GrabModeAsync);
506 XGrayKey(0, 117, AnyModifie, SV->winId(), 0, GrabModeAsync, GrabModeAsync);
507 XGrayKey(0, 62, AnyModifie, SV->winId(), 0, GrabModeAsync, GrabModeAsync);
508 XGrayKey(0, 50, AnyModifie, SV->winId(), 0, GrabModeAsync, GrabModeAsync);*/
509
510 return 1;
511 }
512
513 //*****************************************************************************
514 void ui_main_loop(void)
515 {
516 // connect
517 if (!rdp_connect(g_servername, RDP_LOGON_NORMAL, "", "", "", ""))
518 return;
519 // start notifier
520 SocketNotifier = new QSocketNotifier(g_sock, QSocketNotifier::Read, MW);
521 MW->connect(SocketNotifier, SIGNAL(activated(int)), MW, SLOT(dataReceived()));
522 UpAndRunning = 1;
523 // app main loop
524 App->exec();
525 }
526
527 //*****************************************************************************
528 void ui_destroy_window(void)
529 {
530 delete MW;
531 delete SV;
532 delete BS;
533 delete DS;
534 delete P1;
535 delete P2;
536 delete ClipRect;
537 }
538
539 /*****************************************************************************/
540 void ui_bell(void)
541 {
542 }
543
544 /*****************************************************************************/
545 int ui_select(int in_val)
546 {
547 g_sock = in_val;
548 return 1;
549 }
550
551 /*****************************************************************************/
552 void ui_destroy_cursor(void* cursor)
553 {
554 QCursor* Cursor;
555 Cursor = (QCursor*)cursor;
556 if (Cursor != NULL)
557 delete Cursor;
558 }
559
560 /*****************************************************************************/
561 void* ui_create_glyph(int width, int height, uint8* data)
562 {
563 QBitmap* Bitmap;
564 Bitmap = new QBitmap(width, height, data);
565 Bitmap->setMask(*Bitmap);
566 return (HGLYPH)Bitmap;
567 }
568
569 /*****************************************************************************/
570 void ui_destroy_glyph(void* glyph)
571 {
572 QBitmap* Bitmap;
573 Bitmap = (QBitmap*)glyph;
574 delete Bitmap;
575 }
576
577 /*****************************************************************************/
578 void ui_destroy_bitmap(void* bmp)
579 {
580 QPixmap* Pixmap;
581 Pixmap = (QPixmap*)bmp;
582 delete Pixmap;
583 }
584
585 /*****************************************************************************/
586 void ui_reset_clip(void)
587 {
588 P1->setClipRect(0, 0, g_width, g_height);
589 P2->setClipRect(0, 0, g_width, g_height);
590 delete ClipRect;
591 ClipRect = new QRegion(0, 0, g_width, g_height);
592 }
593
594 /*****************************************************************************/
595 void ui_set_clip(int x, int y, int cx, int cy)
596 {
597 P1->setClipRect(x, y, cx, cy);
598 P2->setClipRect(x, y, cx, cy);
599 delete ClipRect;
600 ClipRect = new QRegion(x, y, cx, cy);
601 }
602
603 /*****************************************************************************/
604 void* ui_create_colourmap(COLOURMAP* colours)
605 {
606 QColorMap* LCM;
607 int i, r, g, b;
608 LCM = (QColorMap*)malloc(sizeof(QColorMap));
609 memset(LCM, 0, sizeof(QColorMap));
610 i = 0;
611 while (i < colours->ncolours && i < 256)
612 {
613 r = colours->colours[i].red;
614 g = colours->colours[i].green;
615 b = colours->colours[i].blue;
616 LCM->RGBColors[i] = (r << 16) | (g << 8) | b;
617 i++;
618 }
619 LCM->NumColors = colours->ncolours;
620 return LCM;
621 }
622
623 //*****************************************************************************
624 // todo, does this leak at end of program
625 void ui_destroy_colourmap(HCOLOURMAP map)
626 {
627 QColorMap* LCM;
628 LCM = (QColorMap*)map;
629 if (LCM == NULL)
630 return;
631 free(LCM);
632 }
633
634 /*****************************************************************************/
635 void ui_set_colourmap(void* map)
636 {
637 // destoy old colormap
638 ui_destroy_colourmap(CM);
639 CM = (QColorMap*)map;
640 }
641
642 /*****************************************************************************/
643 HBITMAP ui_create_bitmap(int width, int height, uint8* data)
644 {
645 QImage* Image = NULL;
646 QPixmap* Pixmap;
647 uint32* d = NULL;
648 uint16* s;
649 switch (g_server_bpp)
650 {
651 case 8:
652 Image = new QImage(data, width, height, 8, (QRgb*)&CM->RGBColors,
653 CM->NumColors, QImage::IgnoreEndian);
654 break;
655 case 15:
656 d = (uint32*)malloc(width * height * 4);
657 s = (uint16*)data;
658 for (int i = 0; i < width * height; i++)
659 d[i] = Color15to32(s[i]);
660 Image = new QImage((uint8*)d, width, height, 32, NULL,
661 0, QImage::IgnoreEndian);
662 break;
663 case 16:
664 d = (uint32*)malloc(width * height * 4);
665 s = (uint16*)data;
666 for (int i = 0; i < width * height; i++)
667 d[i] = Color16to32(s[i]);
668 Image = new QImage((uint8*)d, width, height, 32, NULL,
669 0, QImage::IgnoreEndian);
670 break;
671 case 24:
672 d = (uint32*)malloc(width * height * 4);
673 memset(d, 0, width * height * 4);
674 for (int i = 0; i < width * height; i++)
675 memcpy(d + i, data + i * 3, 3);
676 Image = new QImage((uint8*)d, width, height, 32, NULL,
677 0, QImage::IgnoreEndian);
678 //Image = new QImage(data, width, height, 24, NULL,
679 // 0, QImage::IgnoreEndian);
680 break;
681 }
682 if (Image == NULL)
683 return NULL;
684 Pixmap = new QPixmap();
685 Pixmap->convertFromImage(*Image);
686 delete Image;
687 if (d != NULL)
688 free(d);
689 return (HBITMAP)Pixmap;
690 }
691
692 //******************************************************************************
693 // adjust coordinates for cliping rect
694 BOOL WarpCoords(int* x, int* y, int* cx, int* cy, int* srcx, int* srcy)
695 {
696 int dx, dy;
697 QRect InRect(*x, *y, *cx, *cy);
698 QRect OutRect;
699 QRect CRect = ClipRect->boundingRect();
700 OutRect = InRect.intersect(CRect);
701 if (OutRect.isEmpty())
702 return False;
703 dx = OutRect.x() - InRect.x();
704 dy = OutRect.y() - InRect.y();
705 *x = OutRect.x();
706 *y = OutRect.y();
707 *cx = OutRect.width();
708 *cy = OutRect.height();
709 *srcx = *srcx + dx;
710 *srcy = *srcy + dy;
711 return True;
712 }
713
714 //******************************************************************************
715 // needed because bitBlt don't seem to care about clipping rects
716 // also has 2 dsts and src can be nil
717 void bitBltClip(QPaintDevice* dst1, QPaintDevice* dst2, int dx, int dy,
718 QPaintDevice* src, int sx, int sy, int sw, int sh,
719 Qt::RasterOp rop, bool im)
720 {
721 if (WarpCoords(&dx, &dy, &sw, &sh, &sx, &sy))
722 {
723 if (dst1 != NULL)
724 if (src == NULL)
725 bitBlt(dst1, dx, dy, dst1, sx, sy, sw, sh, rop, im);
726 else
727 bitBlt(dst1, dx, dy, src, sx, sy, sw, sh, rop, im);
728 if (dst2 != NULL)
729 if (src == NULL)
730 bitBlt(dst2, dx, dy, dst2, sx, sy, sw, sh, rop, im);
731 else
732 bitBlt(dst2, dx, dy, src, sx, sy, sw, sh, rop, im);
733 }
734 }
735
736 #define DO_GLYPH(ttext,idx) \
737 {\
738 glyph = cache_get_font (font, ttext[idx]);\
739 if (!(flags & TEXT2_IMPLICIT_X))\
740 {\
741 xyoffset = ttext[++idx];\
742 if ((xyoffset & 0x80))\
743 {\
744 if (flags & TEXT2_VERTICAL) \
745 y += ttext[idx+1] | (ttext[idx+2] << 8);\
746 else\
747 x += ttext[idx+1] | (ttext[idx+2] << 8);\
748 idx += 2;\
749 }\
750 else\
751 {\
752 if (flags & TEXT2_VERTICAL) \
753 y += xyoffset;\
754 else\
755 x += xyoffset;\
756 }\
757 }\
758 if (glyph != NULL)\
759 {\
760 P2->drawPixmap(x + glyph->offset, y + glyph->baseline, *((QBitmap*)glyph->pixmap)); \
761 if (flags & TEXT2_IMPLICIT_X)\
762 x += glyph->width;\
763 }\
764 }
765
766 //*****************************************************************************
767 void ui_draw_text(uint8 font, uint8 flags, int mixmode,
768 int x, int y, int clipx, int clipy,
769 int clipcx, int clipcy, int boxx,
770 int boxy, int boxcx, int boxcy, int bgcolour,
771 int fgcolour, uint8 * text, uint8 length)
772 {
773 FONTGLYPH *glyph;
774 int i, j, xyoffset;
775 DATABLOB *entry;
776
777 SetColorx(&Color1, fgcolour);
778 SetColorx(&Color2, bgcolour);
779 P2->setBackgroundColor(Color2);
780 P2->setPen(Color1);
781 if (boxcx > 1)
782 P2->fillRect(boxx, boxy, boxcx, boxcy, QBrush(Color2));
783 else if (mixmode == MIX_OPAQUE)
784 P2->fillRect(clipx, clipy, clipcx, clipcy, QBrush(Color2));
785
786 /* Paint text, character by character */
787 for (i = 0; i < length;)
788 {
789 switch (text[i])
790 {
791 case 0xff:
792 if (i + 2 < length)
793 cache_put_text(text[i + 1], text, text[i + 2]);
794 else
795 {
796 error("this shouldn't be happening\n");
797 exit(1);
798 }
799 /* this will move pointer from start to first character after FF command */
800 length -= i + 3;
801 text = &(text[i + 3]);
802 i = 0;
803 break;
804
805 case 0xfe:
806 entry = cache_get_text(text[i + 1]);
807 if (entry != NULL)
808 {
809 if ((((uint8 *) (entry->data))[1] == 0) && (!(flags & TEXT2_IMPLICIT_X)))
810 {
811 if (flags & TEXT2_VERTICAL)
812 y += text[i + 2];
813 else
814 x += text[i + 2];
815 }
816 for (j = 0; j < entry->size; j++)
817 DO_GLYPH(((uint8 *) (entry->data)), j);
818 }
819 if (i + 2 < length)
820 i += 3;
821 else
822 i += 2;
823 length -= i;
824 /* this will move pointer from start to first character after FE command */
825 text = &(text[i]);
826 i = 0;
827 break;
828
829 default:
830 DO_GLYPH(text, i);
831 i++;
832 break;
833 }
834 }
835 if (boxcx > 1)
836 bitBltClip(MW, NULL, boxx, boxy, BS, boxx, boxy, boxcx, boxcy, Qt::CopyROP, true);
837 else
838 bitBltClip(MW, NULL, clipx, clipy, BS, clipx, clipy, clipcx, clipcy, Qt::CopyROP, true);
839 }
840
841 /*****************************************************************************/
842 void ui_line(uint8 opcode, int startx, int starty, int endx, int endy,
843 PEN* pen)
844 {
845 SetColorx(&Color1, pen->colour);
846 SetOpCode(opcode);
847 P1->setPen(Color1);
848 P1->moveTo(startx, starty);
849 P1->lineTo(endx, endy);
850 P2->setPen(Color1);
851 P2->moveTo(startx, starty);
852 P2->lineTo(endx, endy);
853 ResetOpCode(opcode);
854 }
855
856 /*****************************************************************************/
857 void ui_triblt(uint8 opcode, int x, int y, int cx, int cy,
858 HBITMAP src, int srcx, int srcy,
859 BRUSH* brush, int bgcolour, int fgcolour)
860 {
861 }
862
863 /*****************************************************************************/
864 void ui_memblt(uint8 opcode, int x, int y, int cx, int cy,
865 HBITMAP src, int srcx, int srcy)
866 {
867 QPixmap* Pixmap;
868 Pixmap = (QPixmap*)src;
869 if (Pixmap != NULL)
870 {
871 SetOpCode(opcode);
872 P1->drawPixmap(x, y, *Pixmap, srcx, srcy, cx, cy);
873 P2->drawPixmap(x, y, *Pixmap, srcx, srcy, cx, cy);
874 ResetOpCode(opcode);
875 }
876 }
877
878 //******************************************************************************
879 void CommonDeskSave(QPixmap* Pixmap1, QPixmap* Pixmap2, int Offset, int x,
880 int y, int cx, int cy, int dir)
881 {
882 int lx;
883 int ly;
884 int x1;
885 int y1;
886 int width;
887 int lcx;
888 int right;
889 int bottom;
890 lx = Offset % 480;
891 ly = Offset / 480;
892 y1 = y;
893 right = x + cx;
894 bottom = y + cy;
895 while (y1 < bottom)
896 {
897 x1 = x;
898 lcx = cx;
899 while (x1 < right)
900 {
901 width = 480 - lx;
902 if (width > lcx)
903 width = lcx;
904 if (dir == 0)
905 bitBlt(Pixmap1, lx, ly, Pixmap2, x1, y1, width, 1, Qt::CopyROP, true);
906 else
907 bitBlt(Pixmap2, x1, y1, Pixmap1, lx, ly, width, 1, Qt::CopyROP, true);
908 lx = lx + width;
909 if (lx >= 480)
910 {
911 lx = 0;
912 ly++;
913 if (ly >= 480)
914 ly = 0;
915 }
916 lcx = lcx - width;
917 x1 = x1 + width;
918 }
919 y1++;
920 }
921 }
922
923 /*****************************************************************************/
924 void ui_desktop_restore(uint32 offset, int x, int y, int cx, int cy)
925 {
926 QPixmap* Pixmap;
927 Pixmap = new QPixmap(cx, cy);
928 CommonDeskSave(DS, Pixmap, offset, 0, 0, cx, cy, 1);
929 bitBltClip(MW, BS, x, y, Pixmap, 0, 0, cx, cy, Qt::CopyROP, true);
930 delete Pixmap;
931 }
932
933 /*****************************************************************************/
934 void ui_desktop_save(uint32 offset, int x, int y, int cx, int cy)
935 {
936 CommonDeskSave(DS, BS, offset, x, y, cx, cy, 0);
937 }
938
939 /*****************************************************************************/
940 void ui_rect(int x, int y, int cx, int cy, int colour)
941 {
942 SetColorx(&Color1, colour);
943 P1->fillRect(x, y, cx, cy, QBrush(Color1));
944 P2->fillRect(x, y, cx, cy, QBrush(Color1));
945 }
946
947 /*****************************************************************************/
948 void ui_screenblt(uint8 opcode, int x, int y, int cx, int cy,
949 int srcx, int srcy)
950 {
951 SetOpCode(opcode);
952 bitBltClip(MW, BS, x, y, NULL, srcx, srcy, cx, cy, Qt::CopyROP, true);
953 ResetOpCode(opcode);
954 }
955
956 /*****************************************************************************/
957 void ui_patblt(uint8 opcode, int x, int y, int cx, int cy,
958 BRUSH* brush, int bgcolour, int fgcolour)
959 {
960 QBitmap* Bitmap;
961 QBrush* Brush;
962 uint8 ipattern[8], i;
963 SetOpCode(opcode);
964 switch (brush->style)
965 {
966 case 0:
967 SetColorx(&Color1, fgcolour);
968 P2->fillRect(x, y, cx, cy, QBrush(Color1));
969 break;
970 case 3:
971 SetColorx(&Color1, fgcolour);
972 SetColorx(&Color2, bgcolour);
973 for (i = 0; i != 8; i++)
974 ipattern[7 - i] = ~brush->pattern[i];
975 Bitmap = new QBitmap(8, 8, ipattern);
976 Brush = new QBrush(Color1, *Bitmap);
977 P2->setBackgroundMode(Qt::OpaqueMode);
978 P2->setBrushOrigin(brush->xorigin, brush->yorigin);
979 P2->setBackgroundColor(Color2);
980 P2->fillRect(x, y, cx, cy, *Brush);
981 delete Brush;
982 delete Bitmap;
983 P2->setBackgroundMode(Qt::TransparentMode);
984 P2->setBrushOrigin(0, 0);
985 break;
986 }
987 ResetOpCode(opcode);
988 bitBltClip(MW, NULL, x, y, BS, x, y, cx, cy, Qt::CopyROP, true);
989 }
990
991 /*****************************************************************************/
992 void ui_destblt(uint8 opcode, int x, int y, int cx, int cy)
993 {
994 SetOpCode(opcode);
995 P1->fillRect(x, y, cx, cy, QBrush(QColor("black")));
996 P2->fillRect(x, y, cx, cy, QBrush(QColor("black")));
997 ResetOpCode(opcode);
998 }
999
1000 /*****************************************************************************/
1001 void ui_move_pointer(int x, int y)
1002 {
1003 }
1004
1005 /*****************************************************************************/
1006 void ui_set_null_cursor(void)
1007 {
1008 }
1009
1010 /*****************************************************************************/
1011 void ui_paint_bitmap(int x, int y, int cx, int cy,
1012 int width, int height, uint8* data)
1013 {
1014 QImage* Image = NULL;
1015 QPixmap* Pixmap;
1016 uint32* d = NULL;
1017 uint16* s;
1018 switch (g_server_bpp)
1019 {
1020 case 8:
1021 Image = new QImage(data, width, height, 8, (QRgb*)&CM->RGBColors,
1022 CM->NumColors, QImage::IgnoreEndian);
1023 break;
1024 case 15:
1025 d = (uint32*)malloc(width * height * 4);
1026 s = (uint16*)data;
1027 for (int i = 0; i < width * height; i++)
1028 d[i] = Color15to32(s[i]);
1029 Image = new QImage((uint8*)d, width, height, 32, NULL,
1030 0, QImage::IgnoreEndian);
1031 break;
1032 case 16:
1033 d = (uint32*)malloc(width * height * 4);
1034 s = (uint16*)data;
1035 for (int i = 0; i < width * height; i++)
1036 d[i] = Color16to32(s[i]);
1037 Image = new QImage((uint8*)d, width, height, 32, NULL,
1038 0, QImage::IgnoreEndian);
1039 break;
1040 case 24:
1041 d = (uint32*)malloc(width * height * 4);
1042 memset(d, 0, width * height * 4);
1043 for (int i = 0; i < width * height; i++)
1044 memcpy(d + i, data + i * 3, 3);
1045 Image = new QImage((uint8*)d, width, height, 32, NULL,
1046 0, QImage::IgnoreEndian);
1047 break;
1048 }
1049 if (Image == NULL)
1050 return;
1051 Pixmap = new QPixmap();
1052 Pixmap->convertFromImage(*Image);
1053 P1->drawPixmap(x, y, *Pixmap, 0, 0, cx, cy);
1054 P2->drawPixmap(x, y, *Pixmap, 0, 0, cx, cy);
1055 delete Image;
1056 delete Pixmap;
1057 if (d != NULL)
1058 free(d);
1059 }
1060
1061 //******************************************************************************
1062 BOOL Is24On(uint8* Data, int X, int Y)
1063 {
1064 uint8 R, G, B;
1065 int Start;
1066 Start = Y * 32 * 3 + X * 3;
1067 R = Data[Start];
1068 G = Data[Start + 1];
1069 B = Data[Start + 2];
1070 return !((R == 0) && (G == 0) && (B == 0));
1071 }
1072
1073 //******************************************************************************
1074 BOOL Is1On(uint8* Data, int X, int Y)
1075 {
1076 int Start;
1077 int Shift;
1078 Start = (Y * 32) / 8 + X / 8;
1079 Shift = X % 8;
1080 return (Data[Start] & (0x80 >> Shift)) == 0;
1081 }
1082
1083 //******************************************************************************
1084 void Set1(uint8* Data, int X, int Y)
1085 {
1086 int Start;
1087 int Shift;
1088 Start = (Y * 32) / 8 + X / 8;
1089 Shift = X % 8;
1090 Data[Start] = Data[Start] | (0x80 >> Shift);
1091 }
1092
1093 //******************************************************************************
1094 void FlipOver(uint8* Data)
1095 {
1096 uint8 AData[128];
1097 int Index;
1098 memcpy(AData, Data, 128);
1099 for (Index = 0; Index <= 31; Index++)
1100 {
1101 Data[127 - (Index * 4 + 3)] = AData[Index * 4];
1102 Data[127 - (Index * 4 + 2)] = AData[Index * 4 + 1];
1103 Data[127 - (Index * 4 + 1)] = AData[Index * 4 + 2];
1104 Data[127 - Index * 4] = AData[Index * 4 + 3];
1105 }
1106 }
1107
1108 /*****************************************************************************/
1109 void ui_set_cursor(HCURSOR cursor)
1110 {
1111 QCursor* Cursor;
1112 Cursor = (QCursor*)cursor;
1113 if (Cursor != NULL)
1114 MW->setCursor(*Cursor);
1115 }
1116
1117 /*****************************************************************************/
1118 HCURSOR ui_create_cursor(unsigned int x, unsigned int y,
1119 int width, int height,
1120 uint8* andmask, uint8* xormask)
1121 {
1122 uint8 AData[128];
1123 uint8 AMask[128];
1124 QBitmap* DataBitmap;
1125 QBitmap* MaskBitmap;
1126 QCursor* Cursor;
1127 int I1;
1128 int I2;
1129 BOOL BOn;
1130 BOOL MOn;
1131 if (width != 32 || height != 32)
1132 return 0;
1133 memset(AData, 0, 128);
1134 memset(AMask, 0, 128);
1135 for (I1 = 0; I1 <= 31; I1++)
1136 for (I2 = 0; I2 <= 31; I2++)
1137 {
1138 MOn = Is24On(xormask, I1, I2);
1139 BOn = Is1On(andmask, I1, I2);
1140 if (BOn ^ MOn) // xor
1141 {
1142 Set1(AData, I1, I2);
1143 if (!MOn)
1144 Set1(AMask, I1, I2);
1145 }
1146 if (MOn)
1147 Set1(AMask, I1, I2);
1148 }
1149 FlipOver(AData);
1150 FlipOver(AMask);
1151 DataBitmap = new QBitmap(32, 32, AData);
1152 MaskBitmap = new QBitmap(32, 32, AMask);
1153 Cursor = new QCursor(*DataBitmap, *MaskBitmap, x, y);
1154 delete DataBitmap;
1155 delete MaskBitmap;
1156 return Cursor;
1157 }
1158
1159 /*****************************************************************************/
1160 uint16 ui_get_numlock_state(unsigned int state)
1161 {
1162 return 0;
1163 }
1164
1165 /*****************************************************************************/
1166 unsigned int read_keyboard_state(void)
1167 {
1168 return 0;
1169 }
1170
1171 /*****************************************************************************/
1172 void ui_resize_window(void)
1173 {
1174 }
1175
1176 /*****************************************************************************/
1177 void generate_random(uint8* random)
1178 {
1179 QFile File("/dev/random");
1180 File.open(IO_ReadOnly);
1181 if (File.readBlock((char*)random, 32) == 32)
1182 return;
1183 warning("no /dev/random\n");
1184 memcpy(random, "12345678901234567890123456789012", 32);
1185 }
1186
1187 /*****************************************************************************/
1188 void save_licence(uint8* data, int length)
1189 {
1190 }
1191
1192 /*****************************************************************************/
1193 int load_licence(uint8** data)
1194 {
1195 return 0;
1196 }
1197
1198 /*****************************************************************************/
1199 void* xrealloc(void* in_val, int size)
1200 {
1201 return realloc(in_val, size);
1202 }
1203
1204 /*****************************************************************************/
1205 void* xmalloc(int size)
1206 {
1207 return malloc(size);
1208 }
1209
1210 /*****************************************************************************/
1211 void xfree(void* in_val)
1212 {
1213 free(in_val);
1214 }
1215
1216 /*****************************************************************************/
1217 void warning(char* format, ...)
1218 {
1219 va_list ap;
1220
1221 fprintf(stderr, "WARNING: ");
1222 va_start(ap, format);
1223 vfprintf(stderr, format, ap);
1224 va_end(ap);
1225 }
1226
1227 /*****************************************************************************/
1228 void unimpl(char* format, ...)
1229 {
1230 va_list ap;
1231
1232 fprintf(stderr, "NOT IMPLEMENTED: ");
1233 va_start(ap, format);
1234 vfprintf(stderr, format, ap);
1235 va_end(ap);
1236 }
1237
1238 /*****************************************************************************/
1239 void error(char* format, ...)
1240 {
1241 va_list ap;
1242
1243 fprintf(stderr, "ERROR: ");
1244 va_start(ap, format);
1245 vfprintf(stderr, format, ap);
1246 va_end(ap);
1247 }
1248
1249 /*****************************************************************************/
1250 void out_params(void)
1251 {
1252 fprintf(stderr, "rdesktop: A Remote Desktop Protocol client.\n");
1253 fprintf(stderr, "Version " VERSION ". Copyright (C) 1999-2003 Matt Chapman.\n");
1254 fprintf(stderr, "See http://www.rdesktop.org/ for more information.\n\n");
1255 fprintf(stderr, "Usage: qtrdesktop [options] server\n");
1256 fprintf(stderr, " -g: desktop geometry (WxH)\n");
1257 fprintf(stderr, " -4: use RDP version 4\n");
1258 fprintf(stderr, " -5: use RDP version 5 (default)\n");
1259 fprintf(stderr, " -t: tcp port)\n");
1260 fprintf(stderr, " -a: connection colour depth\n");
1261 fprintf(stderr, " -T: window title\n");
1262 fprintf(stderr, "\n");
1263 }
1264
1265 /*****************************************************************************/
1266 /* produce a hex dump */
1267 void hexdump(unsigned char *p, unsigned int len)
1268 {
1269 unsigned char *line = p;
1270 int i, thisline;
1271 unsigned int offset = 0;
1272
1273 while (offset < len)
1274 {
1275 printf("%04x ", offset);
1276 thisline = len - offset;
1277 if (thisline > 16)
1278 thisline = 16;
1279 for (i = 0; i < thisline; i++)
1280 printf("%02x ", line[i]);
1281 for (; i < 16; i++)
1282 printf(" ");
1283 for (i = 0; i < thisline; i++)
1284 printf("%c", (line[i] >= 0x20 && line[i] < 0x7f) ? line[i] : '.');
1285 printf("\n");
1286 offset += thisline;
1287 line += thisline;
1288 }
1289 }
1290
1291 BOOL rd_pstcache_mkdir(void)
1292 {
1293 return 0;
1294 }
1295
1296 /*****************************************************************************/
1297 int rd_open_file(char *filename)
1298 {
1299 return 0;
1300 }
1301
1302 /*****************************************************************************/
1303 void rd_close_file(int fd)
1304 {
1305 return;
1306 }
1307
1308 /*****************************************************************************/
1309 int rd_read_file(int fd, void *ptr, int len)
1310 {
1311 return 0;
1312 }
1313
1314 /*****************************************************************************/
1315 int rd_write_file(int fd, void* ptr, int len)
1316 {
1317 return 0;
1318 }
1319
1320 /*****************************************************************************/
1321 int rd_lseek_file(int fd, int offset)
1322 {
1323 return 0;
1324 }
1325
1326 /*****************************************************************************/
1327 BOOL rd_lock_file(int fd, int start, int len)
1328 {
1329 return False;
1330 }
1331
1332 /*****************************************************************************/
1333 void get_username_and_hostname(void)
1334 {
1335 char fullhostname[64];
1336 char* p;
1337 struct passwd* pw;
1338
1339 STRNCPY(g_username, "unknown", sizeof(g_username));
1340 STRNCPY(g_hostname, "unknown", sizeof(g_hostname));
1341 pw = getpwuid(getuid());
1342 if (pw != NULL && pw->pw_name != NULL)
1343 {
1344 STRNCPY(g_username, pw->pw_name, sizeof(g_username));
1345 }
1346 if (gethostname(fullhostname, sizeof(fullhostname)) != -1)
1347 {
1348 p = strchr(fullhostname, '.');
1349 if (p != NULL)
1350 *p = 0;
1351 STRNCPY(g_hostname, fullhostname, sizeof(g_hostname));
1352 }
1353 }
1354
1355 /*****************************************************************************/
1356 int parse_parameters(int in_argc, char** in_argv)
1357 {
1358 int i;
1359 char* p;
1360
1361 if (in_argc <= 1)
1362 {
1363 out_params();
1364 return 0;
1365 }
1366 g_argc = in_argc;
1367 g_argv = in_argv;
1368 for (i = 1; i < in_argc; i++)
1369 {
1370 strcpy(g_servername, in_argv[i]);
1371 if (strcmp(in_argv[i], "-g") == 0)
1372 {
1373 g_width = strtol(in_argv[i + 1], &p, 10);
1374 if (g_width <= 0)
1375 {
1376 error("invalid geometry\n");
1377 return 0;
1378 }
1379 if (*p == 'x')
1380 g_height = strtol(p + 1, NULL, 10);
1381 if (g_height <= 0)
1382 {
1383 error("invalid geometry\n");
1384 return 0;
1385 }
1386 g_width = (g_width + 3) & ~3;
1387 }
1388 else if (strcmp(in_argv[i], "-T") == 0)
1389 strcpy(g_title, in_argv[i + 1]);
1390 else if (strcmp(in_argv[i], "-4") == 0)
1391 g_use_rdp5 = 0;
1392 else if (strcmp(in_argv[i], "-5") == 0)
1393 g_use_rdp5 = 1;
1394 else if (strcmp(in_argv[i], "-a") == 0)
1395 {
1396 g_server_bpp = strtol(in_argv[i + 1], &p, 10);
1397 if (g_server_bpp != 8 && g_server_bpp != 15 &&
1398 g_server_bpp != 16 && g_server_bpp != 24)
1399 {
1400 error("invalid bpp\n");
1401 return 0;
1402 }
1403 }
1404 else if (strcmp(in_argv[i], "-t") == 0)
1405 g_tcp_port_rdp = strtol(in_argv[i + 1], &p, 10);
1406 }
1407 return 1;
1408 }
1409
1410 /*****************************************************************************/
1411 int main(int in_argc, char** in_argv)
1412 {
1413 get_username_and_hostname();
1414 if (!parse_parameters(in_argc, in_argv))
1415 return 0;
1416 if (!ui_init())
1417 return 1;
1418 if (!ui_create_window())
1419 return 1;
1420 ui_main_loop();
1421 ui_destroy_window();
1422 ui_deinit();
1423 return 0;
1424 }

Properties

Name Value
svn:executable *

  ViewVC Help
Powered by ViewVC 1.1.26