1 |
/* |
/* -*- c-basic-offset: 8 -*- |
2 |
rdesktop: A Remote Desktop Protocol client. |
rdesktop: A Remote Desktop Protocol client. |
3 |
User interface services - QT Emb System |
User interface services - QT Emb System |
4 |
Copyright (C) Jay Sorg 2004 |
Copyright (C) Jay Sorg 2004-2005 |
5 |
|
|
6 |
This program is free software; you can redistribute it and/or modify |
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 |
it under the terms of the GNU General Public License as published by |
40 |
#include <qfile.h> |
#include <qfile.h> |
41 |
#include <qcheckbox.h> |
#include <qcheckbox.h> |
42 |
#include <qpopupmenu.h> |
#include <qpopupmenu.h> |
43 |
|
|
44 |
#include <stdlib.h> |
#include <stdlib.h> |
45 |
#include <stdarg.h> // va_list va_start va_end |
#include <stdarg.h> // va_list va_start va_end |
46 |
#include <unistd.h> // gethostname |
#include <unistd.h> // gethostname |
51 |
|
|
52 |
#define QT_OPTI |
#define QT_OPTI |
53 |
|
|
|
/* types */ |
|
|
struct QColorMap |
|
|
{ |
|
|
uint32 RGBColors[256]; |
|
|
uint32 NumColors; |
|
|
}; |
|
|
|
|
|
struct bitmap |
|
|
{ |
|
|
int w; |
|
|
int h; |
|
|
uint8 * data; |
|
|
}; |
|
|
|
|
54 |
extern int g_tcp_port_rdp; |
extern int g_tcp_port_rdp; |
|
extern int g_dsp_fd; |
|
|
|
|
|
#ifdef WITH_RDPSND |
|
|
BOOL g_rdpsnd = True; |
|
|
extern int g_dsp_busy; |
|
|
#endif |
|
55 |
int g_encryption = 1; |
int g_encryption = 1; |
56 |
int g_bitmap_cache = 1; |
int g_bitmap_cache = 1; |
57 |
int g_bitmap_cache_persist_enable = 0; |
int g_bitmap_cache_persist_enable = 0; |
59 |
int g_use_rdp5 = 1; |
int g_use_rdp5 = 1; |
60 |
int g_desktop_save = 1; |
int g_desktop_save = 1; |
61 |
int g_bitmap_compression = 1; |
int g_bitmap_compression = 1; |
62 |
int g_rdp5_performanceflags = 0; |
int g_polygon_ellipse_orders = 0; |
63 |
|
int g_rdp5_performanceflags = |
64 |
|
RDP5_NO_WALLPAPER | RDP5_NO_FULLWINDOWDRAG | RDP5_NO_MENUANIMATIONS; |
65 |
int g_console_session = 0; |
int g_console_session = 0; |
66 |
int g_keylayout = 0x409; /* Defaults to US keyboard layout */ |
int g_keylayout = 0x409; /* Defaults to US keyboard layout */ |
67 |
|
int g_keyboard_type = 0x4; /* Defaults to US keyboard layout */ |
68 |
|
int g_keyboard_subtype = 0x0; /* Defaults to US keyboard layout */ |
69 |
|
int g_keyboard_functionkeys = 0xc; /* Defaults to US keyboard layout */ |
70 |
int g_width = 640; |
int g_width = 640; |
71 |
int g_height = 480; |
int g_height = 480; |
72 |
int g_server_bpp = 8; |
int g_server_bpp = 8; |
73 |
char g_hostname[16] = ""; |
char g_hostname[16] = ""; |
74 |
char g_username[100] = ""; |
char g_username[100] = ""; |
75 |
|
|
76 |
|
#ifdef WITH_RDPSND |
77 |
|
extern int g_dsp_busy; |
78 |
|
extern int g_dsp_fd; |
79 |
|
int g_rdpsnd = 0; |
80 |
|
static QSocketNotifier * g_SoundNotifier = 0; |
81 |
|
#endif |
82 |
|
|
83 |
|
/* types */ |
84 |
|
struct QColorMap |
85 |
|
{ |
86 |
|
uint32 RGBColors[256]; |
87 |
|
uint32 NumColors; |
88 |
|
}; |
89 |
|
|
90 |
|
struct bitmap |
91 |
|
{ |
92 |
|
int w; |
93 |
|
int h; |
94 |
|
uint8 * data; |
95 |
|
}; |
96 |
|
|
97 |
static int g_client_width = 640; |
static int g_client_width = 640; |
98 |
static int g_client_height = 480; |
static int g_client_height = 480; |
99 |
static uint32 g_flags = RDP_LOGON_NORMAL; |
static uint32 g_flags = RDP_LOGON_NORMAL; |
108 |
static uint32 g_ext_disc_reason = 0; |
static uint32 g_ext_disc_reason = 0; |
109 |
|
|
110 |
static QSocketNotifier * g_SocketNotifier = 0; |
static QSocketNotifier * g_SocketNotifier = 0; |
|
static QSocketNotifier * g_SoundNotifier = 0; |
|
111 |
#ifdef SHARP |
#ifdef SHARP |
112 |
static QPEApplication * g_App = 0; |
static QPEApplication * g_App = 0; |
113 |
#else |
#else |
122 |
static int g_clipcx = 0; |
static int g_clipcx = 0; |
123 |
static int g_clipcy = 0; |
static int g_clipcy = 0; |
124 |
|
|
125 |
|
/* Session Directory redirection */ |
126 |
|
BOOL g_redirect = False; |
127 |
|
char g_redirect_server[64]; |
128 |
|
char g_redirect_domain[16]; |
129 |
|
char g_redirect_password[64]; |
130 |
|
char g_redirect_username[64]; |
131 |
|
char g_redirect_cookie[128]; |
132 |
|
uint32 g_redirect_flags = 0; |
133 |
|
|
134 |
#define BPP ((g_server_bpp + 7) / 8) |
#define BPP ((g_server_bpp + 7) / 8) |
135 |
#define GETPIXEL8(d, x, y, w) (*(((uint8*)d) + ((y) * (w) + (x)))) |
#define GETPIXEL8(d, x, y, w) (*(((uint8*)d) + ((y) * (w) + (x)))) |
136 |
#define GETPIXEL16(d, x, y, w) (*(((uint16*)d) + ((y) * (w) + (x)))) |
#define GETPIXEL16(d, x, y, w) (*(((uint16*)d) + ((y) * (w) + (x)))) |
148 |
while (i >= 0) |
while (i >= 0) |
149 |
{ |
{ |
150 |
if (Item->at(i) == 10 || Item->at(i) == 13) |
if (Item->at(i) == 10 || Item->at(i) == 13) |
151 |
|
{ |
152 |
Item->remove(i, 1); |
Item->remove(i, 1); |
153 |
|
} |
154 |
i--; |
i--; |
155 |
} |
} |
156 |
} |
} |
749 |
/******************************************************************************/ |
/******************************************************************************/ |
750 |
void QMyScrollView::timerEvent(QTimerEvent * e) |
void QMyScrollView::timerEvent(QTimerEvent * e) |
751 |
{ |
{ |
|
QScrollView::timerEvent(e); |
|
|
killTimer(timer_id); |
|
752 |
QMyDialog * d; |
QMyDialog * d; |
753 |
QWidget * Desktop; |
QWidget * Desktop; |
754 |
int dw; |
int dw; |
755 |
int dh; |
int dh; |
756 |
|
|
757 |
|
QScrollView::timerEvent(e); |
758 |
|
killTimer(timer_id); |
759 |
d = new QMyDialog(this); |
d = new QMyDialog(this); |
760 |
if (d->exec() == 1) // ok clicked |
if (d->exec() == 1) // ok clicked |
761 |
{ |
{ |
766 |
g_fullscreen = d->FullScreen; |
g_fullscreen = d->FullScreen; |
767 |
sprintf(g_server, "%s", (const char*)d->ServerIP); |
sprintf(g_server, "%s", (const char*)d->ServerIP); |
768 |
sprintf(g_username, "%s", (const char*)d->UserName); |
sprintf(g_username, "%s", (const char*)d->UserName); |
769 |
|
#ifdef WITH_RDPSND |
770 |
|
// init sound |
771 |
|
if (g_rdpsnd) |
772 |
|
{ |
773 |
|
rdpsnd_init(); |
774 |
|
} |
775 |
|
#endif |
776 |
if (!rdp_connect(g_server, g_flags, g_domain, g_password, g_shell, |
if (!rdp_connect(g_server, g_flags, g_domain, g_password, g_shell, |
777 |
g_directory)) |
g_directory)) |
778 |
{ |
{ |
794 |
g_MW->show(); |
g_MW->show(); |
795 |
g_SV->addChild(g_MW); |
g_SV->addChild(g_MW); |
796 |
g_MW->setMouseTracking(true); |
g_MW->setMouseTracking(true); |
797 |
|
g_MW->setCursor((int)10); /* Qt::BlankCursor */ |
798 |
g_SocketNotifier = new QSocketNotifier(g_global_sock, |
g_SocketNotifier = new QSocketNotifier(g_global_sock, |
799 |
QSocketNotifier::Read, |
QSocketNotifier::Read, |
800 |
g_MW); |
g_MW); |
806 |
dw = Desktop->width(); |
dw = Desktop->width(); |
807 |
dh = Desktop->height(); |
dh = Desktop->height(); |
808 |
if (dw == g_client_width && dh == g_client_height) |
if (dw == g_client_width && dh == g_client_height) |
809 |
|
{ |
810 |
g_MW->resize(g_client_width - 4, g_client_height - 4); |
g_MW->resize(g_client_width - 4, g_client_height - 4); |
811 |
|
} |
812 |
g_SV->showFullScreen(); |
g_SV->showFullScreen(); |
813 |
} |
} |
814 |
delete d; |
delete d; |
1234 |
/******************************************************************************/ |
/******************************************************************************/ |
1235 |
void QMyMainWindow::soundSend() |
void QMyMainWindow::soundSend() |
1236 |
{ |
{ |
|
g_SoundNotifier->setEnabled(false); |
|
1237 |
#ifdef WITH_RDPSND |
#ifdef WITH_RDPSND |
1238 |
|
g_SoundNotifier->setEnabled(false); |
1239 |
wave_out_play(); |
wave_out_play(); |
1240 |
if (g_dsp_busy) |
if (g_dsp_busy) |
1241 |
|
{ |
1242 |
g_SoundNotifier->setEnabled(true); |
g_SoundNotifier->setEnabled(true); |
1243 |
|
} |
1244 |
#endif |
#endif |
1245 |
} |
} |
1246 |
|
|
1464 |
{ |
{ |
1465 |
} |
} |
1466 |
|
|
1467 |
|
/*****************************************************************************/ |
1468 |
|
void ui_polygon(uint8 opcode, uint8 fillmode, POINT * point, int npoints, |
1469 |
|
BRUSH * brush, int bgcolour, int fgcolour) |
1470 |
|
{ |
1471 |
|
} |
1472 |
|
|
1473 |
|
/*****************************************************************************/ |
1474 |
|
/* todo, use qt function for this (QPainter::drawPolyline) */ |
1475 |
|
void ui_polyline(uint8 opcode, POINT * points, int npoints, PEN * pen) |
1476 |
|
{ |
1477 |
|
int i, x, y, dx, dy; |
1478 |
|
|
1479 |
|
if (npoints > 0) |
1480 |
|
{ |
1481 |
|
x = points[0].x; |
1482 |
|
y = points[0].y; |
1483 |
|
for (i = 1; i < npoints; i++) |
1484 |
|
{ |
1485 |
|
dx = points[i].x; |
1486 |
|
dy = points[i].y; |
1487 |
|
ui_line(opcode, x, y, x + dx, y + dy, pen); |
1488 |
|
x = x + dx; |
1489 |
|
y = y + dy; |
1490 |
|
} |
1491 |
|
} |
1492 |
|
} |
1493 |
|
|
1494 |
|
/*****************************************************************************/ |
1495 |
|
void ui_ellipse(uint8 opcode, uint8 fillmode, |
1496 |
|
int x, int y, int cx, int cy, |
1497 |
|
BRUSH * brush, int bgcolour, int fgcolour) |
1498 |
|
{ |
1499 |
|
} |
1500 |
|
|
1501 |
/******************************************************************************/ |
/******************************************************************************/ |
1502 |
void ui_destroy_cursor(HCURSOR /*cursor*/) |
void ui_destroy_cursor(HCURSOR /*cursor*/) |
1503 |
{ |
{ |
1572 |
{ |
{ |
1573 |
int i, j; |
int i, j; |
1574 |
|
|
1575 |
for (i = 0; i < cy; i++) |
|
1576 |
for (j = 0; j < cx; j++) |
if (opcode == 0x0) /* black */ |
1577 |
set_pixel(x + j, y + i, get_pixel(x + j, y + i), opcode); |
{ |
1578 |
|
for (i = 0; i < cy; i++) |
1579 |
|
for (j = 0; j < cx; j++) |
1580 |
|
set_pixel(x + j, y + i, 0, 0xc); |
1581 |
|
} |
1582 |
|
else if (opcode == 0xf) /* white */ |
1583 |
|
{ |
1584 |
|
for (i = 0; i < cy; i++) |
1585 |
|
for (j = 0; j < cx; j++) |
1586 |
|
set_pixel(x + j, y + i, 0xffffff, 0xc); |
1587 |
|
} |
1588 |
|
else |
1589 |
|
{ |
1590 |
|
for (i = 0; i < cy; i++) |
1591 |
|
for (j = 0; j < cx; j++) |
1592 |
|
set_pixel(x + j, y + i, get_pixel(x + j, y + i), opcode); |
1593 |
|
} |
1594 |
redraw(x, y, cx, cy); |
redraw(x, y, cx, cy); |
1595 |
} |
} |
1596 |
|
|
1680 |
uint8 * temp; |
uint8 * temp; |
1681 |
|
|
1682 |
temp = (uint8*)xmalloc(cx * cy * 4); |
temp = (uint8*)xmalloc(cx * cy * 4); |
1683 |
if (g_server_bpp == 8) |
#ifdef QT_OPTI |
1684 |
{ |
if (opcode == 0xc) |
|
for (i = 0; i < cy; i++) |
|
|
for (j = 0; j < cx; j++) |
|
|
temp[i * cx + j] = get_pixel(srcx + j, srcy + i); |
|
|
for (i = 0; i < cy; i++) |
|
|
for (j = 0; j < cx; j++) |
|
|
set_pixel(x + j, y + i, temp[i * cx + j], opcode); |
|
|
} |
|
|
else if (g_server_bpp == 16) |
|
1685 |
{ |
{ |
1686 |
for (i = 0; i < cy; i++) |
if (WarpCoords(&x, &y, &cx, &cy, &srcx, &srcy)) |
1687 |
for (j = 0; j < cx; j++) |
{ |
1688 |
|
if (g_server_bpp == 8) |
1689 |
{ |
{ |
1690 |
pixel = get_pixel(srcx + j, srcy + i); |
for (i = 0; i < cy; i++) |
1691 |
SETPIXEL16(temp, j, i, cx, pixel); |
for (j = 0; j < cx; j++) |
1692 |
|
{ |
1693 |
|
pixel = GETPIXEL8(g_BS, srcx + j, srcy + i, g_width); |
1694 |
|
SETPIXEL8(temp, j, i, cx, pixel); |
1695 |
|
} |
1696 |
|
for (i = 0; i < cy; i++) |
1697 |
|
for (j = 0; j < cx; j++) |
1698 |
|
{ |
1699 |
|
pixel = GETPIXEL8(temp, j, i, cx); |
1700 |
|
SETPIXEL8(g_BS, x + j, y + i, g_width, pixel); |
1701 |
|
} |
1702 |
} |
} |
1703 |
for (i = 0; i < cy; i++) |
else if (g_server_bpp == 16) |
1704 |
for (j = 0; j < cx; j++) |
{ |
1705 |
|
for (i = 0; i < cy; i++) |
1706 |
|
for (j = 0; j < cx; j++) |
1707 |
|
{ |
1708 |
|
pixel = GETPIXEL16(g_BS, srcx + j, srcy + i, g_width); |
1709 |
|
SETPIXEL16(temp, j, i, cx, pixel); |
1710 |
|
} |
1711 |
|
for (i = 0; i < cy; i++) |
1712 |
|
for (j = 0; j < cx; j++) |
1713 |
|
{ |
1714 |
|
pixel = GETPIXEL16(temp, j, i, cx); |
1715 |
|
SETPIXEL16(g_BS, x + j, y + i, g_width, pixel); |
1716 |
|
} |
1717 |
|
} |
1718 |
|
else if (g_server_bpp == 24) |
1719 |
{ |
{ |
1720 |
pixel = GETPIXEL16(temp, j, i, cx); |
for (i = 0; i < cy; i++) |
1721 |
set_pixel(x + j, y + i, pixel, opcode); |
for (j = 0; j < cx; j++) |
1722 |
|
{ |
1723 |
|
pixel = GETPIXEL32(g_BS, srcx + j, srcy + i, g_width); |
1724 |
|
SETPIXEL32(temp, j, i, cx, pixel); |
1725 |
|
} |
1726 |
|
for (i = 0; i < cy; i++) |
1727 |
|
for (j = 0; j < cx; j++) |
1728 |
|
{ |
1729 |
|
pixel = GETPIXEL32(temp, j, i, cx); |
1730 |
|
SETPIXEL32(g_BS, x + j, y + i, g_width, pixel); |
1731 |
|
} |
1732 |
} |
} |
1733 |
|
} |
1734 |
} |
} |
1735 |
else if (g_server_bpp == 24) |
else |
1736 |
|
#endif |
1737 |
{ |
{ |
1738 |
for (i = 0; i < cy; i++) |
if (g_server_bpp == 8) |
1739 |
for (j = 0; j < cx; j++) |
{ |
1740 |
*(((uint32*)temp) + (i * cx + j)) = get_pixel(srcx + j, srcy + i); |
for (i = 0; i < cy; i++) |
1741 |
for (i = 0; i < cy; i++) |
for (j = 0; j < cx; j++) |
1742 |
for (j = 0; j < cx; j++) |
temp[i * cx + j] = get_pixel(srcx + j, srcy + i); |
1743 |
set_pixel(x + j, y + i, *(((uint32*)temp) + (i * cx + j)), opcode); |
for (i = 0; i < cy; i++) |
1744 |
|
for (j = 0; j < cx; j++) |
1745 |
|
set_pixel(x + j, y + i, temp[i * cx + j], opcode); |
1746 |
|
} |
1747 |
|
else if (g_server_bpp == 16) |
1748 |
|
{ |
1749 |
|
for (i = 0; i < cy; i++) |
1750 |
|
for (j = 0; j < cx; j++) |
1751 |
|
{ |
1752 |
|
pixel = get_pixel(srcx + j, srcy + i); |
1753 |
|
SETPIXEL16(temp, j, i, cx, pixel); |
1754 |
|
} |
1755 |
|
for (i = 0; i < cy; i++) |
1756 |
|
for (j = 0; j < cx; j++) |
1757 |
|
{ |
1758 |
|
pixel = GETPIXEL16(temp, j, i, cx); |
1759 |
|
set_pixel(x + j, y + i, pixel, opcode); |
1760 |
|
} |
1761 |
|
} |
1762 |
|
else if (g_server_bpp == 24) |
1763 |
|
{ |
1764 |
|
for (i = 0; i < cy; i++) |
1765 |
|
for (j = 0; j < cx; j++) |
1766 |
|
*(((uint32*)temp) + (i * cx + j)) = get_pixel(srcx + j, srcy + i); |
1767 |
|
for (i = 0; i < cy; i++) |
1768 |
|
for (j = 0; j < cx; j++) |
1769 |
|
set_pixel(x + j, y + i, *(((uint32*)temp) + (i * cx + j)), opcode); |
1770 |
|
} |
1771 |
} |
} |
1772 |
xfree(temp); |
xfree(temp); |
1773 |
redraw(x, y, cx, cy); |
redraw(x, y, cx, cy); |
1985 |
} |
} |
1986 |
|
|
1987 |
/******************************************************************************/ |
/******************************************************************************/ |
1988 |
void ui_draw_text(uint8 font, uint8 flags, int mixmode, |
//***************************************************************************** |
1989 |
|
void ui_draw_text(uint8 font, uint8 flags, uint8 opcode, int mixmode, |
1990 |
int x, int y, int clipx, int clipy, |
int x, int y, int clipx, int clipy, |
1991 |
int clipcx, int clipcy, int boxx, |
int clipcx, int clipcy, int boxx, |
1992 |
int boxy, int boxcx, int boxcy, int bgcolour, |
int boxy, int boxcx, int boxcy, BRUSH * brush, |
1993 |
int fgcolour, uint8 * text, uint8 length) |
int bgcolour, int fgcolour, uint8 * text, uint8 length) |
1994 |
{ |
{ |
1995 |
FONTGLYPH * glyph; |
FONTGLYPH * glyph; |
1996 |
int i, j, xyoffset; |
int i, j, xyoffset; |
2142 |
} |
} |
2143 |
|
|
2144 |
/*****************************************************************************/ |
/*****************************************************************************/ |
2145 |
void* xrealloc(void * in_val, int size) |
void * xrealloc(void * in_val, int size) |
2146 |
{ |
{ |
2147 |
if (size < 1) |
if (size < 1) |
2148 |
|
{ |
2149 |
size = 1; |
size = 1; |
2150 |
|
} |
2151 |
return realloc(in_val, size); |
return realloc(in_val, size); |
2152 |
} |
} |
2153 |
|
|
2154 |
/*****************************************************************************/ |
/*****************************************************************************/ |
2155 |
void* xmalloc(int size) |
void * xmalloc(int size) |
2156 |
{ |
{ |
2157 |
return malloc(size); |
return malloc(size); |
2158 |
} |
} |
2161 |
void xfree(void * in_val) |
void xfree(void * in_val) |
2162 |
{ |
{ |
2163 |
if (in_val != NULL) |
if (in_val != NULL) |
2164 |
|
{ |
2165 |
free(in_val); |
free(in_val); |
2166 |
|
} |
2167 |
|
} |
2168 |
|
|
2169 |
|
/*****************************************************************************/ |
2170 |
|
char * xstrdup(const char * s) |
2171 |
|
{ |
2172 |
|
char * mem = strdup(s); |
2173 |
|
if (mem == NULL) |
2174 |
|
{ |
2175 |
|
perror("strdup"); |
2176 |
|
exit(1); |
2177 |
|
} |
2178 |
|
return mem; |
2179 |
} |
} |
2180 |
|
|
2181 |
/*****************************************************************************/ |
/*****************************************************************************/ |
2270 |
QFile File("/dev/random"); |
QFile File("/dev/random"); |
2271 |
File.open(IO_ReadOnly); |
File.open(IO_ReadOnly); |
2272 |
if (File.readBlock((char*)random, 32) == 32) |
if (File.readBlock((char*)random, 32) == 32) |
2273 |
|
{ |
2274 |
return; |
return; |
2275 |
|
} |
2276 |
warning("no /dev/random\n"); |
warning("no /dev/random\n"); |
2277 |
memcpy(random, "12345678901234567890123456789012", 32); |
memcpy(random, "12345678901234567890123456789012", 32); |
2278 |
} |
} |
2290 |
printf("%04x ", offset); |
printf("%04x ", offset); |
2291 |
thisline = len - offset; |
thisline = len - offset; |
2292 |
if (thisline > 16) |
if (thisline > 16) |
2293 |
|
{ |
2294 |
thisline = 16; |
thisline = 16; |
2295 |
|
} |
2296 |
for (i = 0; i < thisline; i++) |
for (i = 0; i < thisline; i++) |
2297 |
|
{ |
2298 |
printf("%02x ", line[i]); |
printf("%02x ", line[i]); |
2299 |
|
} |
2300 |
for (; i < 16; i++) |
for (; i < 16; i++) |
2301 |
|
{ |
2302 |
printf(" "); |
printf(" "); |
2303 |
|
} |
2304 |
for (i = 0; i < thisline; i++) |
for (i = 0; i < thisline; i++) |
2305 |
|
{ |
2306 |
printf("%c", (line[i] >= 0x20 && line[i] < 0x7f) ? line[i] : '.'); |
printf("%c", (line[i] >= 0x20 && line[i] < 0x7f) ? line[i] : '.'); |
2307 |
|
} |
2308 |
printf("\n"); |
printf("\n"); |
2309 |
offset += thisline; |
offset += thisline; |
2310 |
line += thisline; |
line += thisline; |
2329 |
{ |
{ |
2330 |
p = strchr(fullhostname, '.'); |
p = strchr(fullhostname, '.'); |
2331 |
if (p != NULL) |
if (p != NULL) |
2332 |
|
{ |
2333 |
*p = 0; |
*p = 0; |
2334 |
|
} |
2335 |
STRNCPY(g_hostname, fullhostname, sizeof(g_hostname)); |
STRNCPY(g_hostname, fullhostname, sizeof(g_hostname)); |
2336 |
} |
} |
2337 |
} |
} |
2348 |
fprintf(stderr, " -5: use RDP version 5 (default)\n"); |
fprintf(stderr, " -5: use RDP version 5 (default)\n"); |
2349 |
fprintf(stderr, " -t: tcp port)\n"); |
fprintf(stderr, " -t: tcp port)\n"); |
2350 |
fprintf(stderr, " -a: connection colour depth\n"); |
fprintf(stderr, " -a: connection colour depth\n"); |
|
|
|
2351 |
fprintf(stderr, " -u: user name\n"); |
fprintf(stderr, " -u: user name\n"); |
2352 |
fprintf(stderr, " -d: domain\n"); |
fprintf(stderr, " -d: domain\n"); |
2353 |
fprintf(stderr, " -s: shell\n"); |
fprintf(stderr, " -s: shell\n"); |
2355 |
fprintf(stderr, " -p: password (- to prompt)\n"); |
fprintf(stderr, " -p: password (- to prompt)\n"); |
2356 |
fprintf(stderr, " -n: client hostname\n"); |
fprintf(stderr, " -n: client hostname\n"); |
2357 |
fprintf(stderr, " -f: full screen\n"); |
fprintf(stderr, " -f: full screen\n"); |
2358 |
|
fprintf(stderr, " -r sound: enable sound\n"); |
2359 |
fprintf(stderr, "\n"); |
fprintf(stderr, "\n"); |
2360 |
} |
} |
2361 |
|
|
2377 |
{ |
{ |
2378 |
g_width = strtol(in_argv[i + 1], &p, 10); |
g_width = strtol(in_argv[i + 1], &p, 10); |
2379 |
if (*p == 'x') |
if (*p == 'x') |
2380 |
|
{ |
2381 |
g_height = strtol(p + 1, &p, 10); |
g_height = strtol(p + 1, &p, 10); |
2382 |
|
} |
2383 |
if (*p == '-') |
if (*p == '-') |
2384 |
|
{ |
2385 |
g_client_width = strtol(p + 1, &p, 10); |
g_client_width = strtol(p + 1, &p, 10); |
2386 |
|
} |
2387 |
else |
else |
2388 |
{ |
{ |
2389 |
g_client_width = g_width; |
g_client_width = g_width; |
2390 |
g_client_height = g_height; |
g_client_height = g_height; |
2391 |
} |
} |
2392 |
if (*p == 'x') |
if (*p == 'x') |
2393 |
|
{ |
2394 |
g_client_height = strtol(p + 1, NULL, 10); |
g_client_height = strtol(p + 1, NULL, 10); |
2395 |
|
} |
2396 |
g_width = (g_width + 3) & ~3; |
g_width = (g_width + 3) & ~3; |
2397 |
g_height = (g_height + 3) & ~3; |
g_height = (g_height + 3) & ~3; |
2398 |
g_client_width = (g_client_width + 3) & ~3; |
g_client_width = (g_client_width + 3) & ~3; |
2399 |
g_client_height = (g_client_height + 3) & ~3; |
g_client_height = (g_client_height + 3) & ~3; |
2400 |
//printf("%d %d %d %d\n", g_width, g_height, g_client_width, g_client_height); |
i++; |
2401 |
} |
} |
2402 |
else if (strcmp(in_argv[i], "-4") == 0) |
else if (strcmp(in_argv[i], "-4") == 0) |
2403 |
|
{ |
2404 |
g_use_rdp5 = 0; |
g_use_rdp5 = 0; |
2405 |
|
} |
2406 |
else if (strcmp(in_argv[i], "-5") == 0) |
else if (strcmp(in_argv[i], "-5") == 0) |
2407 |
|
{ |
2408 |
g_use_rdp5 = 1; |
g_use_rdp5 = 1; |
2409 |
|
} |
2410 |
else if (strcmp(in_argv[i], "-a") == 0) |
else if (strcmp(in_argv[i], "-a") == 0) |
2411 |
{ |
{ |
2412 |
g_server_bpp = strtol(in_argv[i + 1], &p, 10); |
g_server_bpp = strtol(in_argv[i + 1], &p, 10); |
2416 |
error("invalid bpp\n"); |
error("invalid bpp\n"); |
2417 |
return 0; |
return 0; |
2418 |
} |
} |
2419 |
|
i++; |
2420 |
} |
} |
2421 |
else if (strcmp(in_argv[i], "-t") == 0) |
else if (strcmp(in_argv[i], "-t") == 0) |
2422 |
|
{ |
2423 |
g_tcp_port_rdp = strtol(in_argv[i + 1], &p, 10); |
g_tcp_port_rdp = strtol(in_argv[i + 1], &p, 10); |
2424 |
|
i++; |
2425 |
|
} |
2426 |
else if (strcmp(in_argv[i], "-u") == 0) |
else if (strcmp(in_argv[i], "-u") == 0) |
2427 |
{ |
{ |
2428 |
STRNCPY(g_username, in_argv[i + 1], sizeof(g_username)); |
STRNCPY(g_username, in_argv[i + 1], sizeof(g_username)); |
2429 |
|
i++; |
2430 |
} |
} |
2431 |
else if (strcmp(in_argv[i], "-d") == 0) |
else if (strcmp(in_argv[i], "-d") == 0) |
2432 |
{ |
{ |
2433 |
STRNCPY(g_domain, in_argv[i + 1], sizeof(g_domain)); |
STRNCPY(g_domain, in_argv[i + 1], sizeof(g_domain)); |
2434 |
|
i++; |
2435 |
} |
} |
2436 |
else if (strcmp(in_argv[i], "-s") == 0) |
else if (strcmp(in_argv[i], "-s") == 0) |
2437 |
{ |
{ |
2438 |
STRNCPY(g_shell, in_argv[i + 1], sizeof(g_shell)); |
STRNCPY(g_shell, in_argv[i + 1], sizeof(g_shell)); |
2439 |
|
i++; |
2440 |
} |
} |
2441 |
else if (strcmp(in_argv[i], "-c") == 0) |
else if (strcmp(in_argv[i], "-c") == 0) |
2442 |
{ |
{ |
2443 |
STRNCPY(g_directory, in_argv[i + 1], sizeof(g_directory)); |
STRNCPY(g_directory, in_argv[i + 1], sizeof(g_directory)); |
2444 |
|
i++; |
2445 |
} |
} |
2446 |
else if (strcmp(in_argv[i], "-p") == 0) |
else if (strcmp(in_argv[i], "-p") == 0) |
2447 |
{ |
{ |
2448 |
STRNCPY(g_password, in_argv[i + 1], sizeof(g_password)); |
STRNCPY(g_password, in_argv[i + 1], sizeof(g_password)); |
2449 |
g_flags |= RDP_LOGON_AUTO; |
g_flags |= RDP_LOGON_AUTO; |
2450 |
|
i++; |
2451 |
} |
} |
2452 |
else if (strcmp(in_argv[i], "-n") == 0) |
else if (strcmp(in_argv[i], "-n") == 0) |
2453 |
{ |
{ |
2454 |
STRNCPY(g_hostname, in_argv[i + 1], sizeof(g_hostname)); |
STRNCPY(g_hostname, in_argv[i + 1], sizeof(g_hostname)); |
2455 |
|
i++; |
2456 |
} |
} |
2457 |
else if (strcmp(in_argv[i], "-f") == 0) |
else if (strcmp(in_argv[i], "-f") == 0) |
2458 |
{ |
{ |
2459 |
g_fullscreen = 1; |
g_fullscreen = 1; |
2460 |
} |
} |
2461 |
|
else if (strcmp(in_argv[i], "-r") == 0) |
2462 |
|
{ |
2463 |
|
if (strcmp(in_argv[i + 1], "sound") == 0) |
2464 |
|
{ |
2465 |
|
#ifdef WITH_RDPSND |
2466 |
|
g_rdpsnd = 1; |
2467 |
|
#endif |
2468 |
|
} |
2469 |
|
i++; |
2470 |
|
} |
2471 |
} |
} |
2472 |
return 1; |
return 1; |
2473 |
} |
} |
2479 |
int dw, dh; |
int dw, dh; |
2480 |
|
|
2481 |
#ifdef WITH_RDPSND |
#ifdef WITH_RDPSND |
2482 |
rdpsnd_init(); |
// init sound |
2483 |
|
if (g_rdpsnd) |
2484 |
|
{ |
2485 |
|
rdpsnd_init(); |
2486 |
|
} |
2487 |
#endif |
#endif |
2488 |
if (rdp_connect(g_server, g_flags, g_domain, g_password, g_shell, |
if (rdp_connect(g_server, g_flags, g_domain, g_password, g_shell, |
2489 |
g_directory)) |
g_directory)) |
2513 |
dw = Desktop->width(); |
dw = Desktop->width(); |
2514 |
dh = Desktop->height(); |
dh = Desktop->height(); |
2515 |
if (dw == g_client_width && dh == g_client_height) |
if (dw == g_client_width && dh == g_client_height) |
2516 |
|
{ |
2517 |
g_MW->resize(g_client_width - 4, g_client_height - 4); |
g_MW->resize(g_client_width - 4, g_client_height - 4); |
2518 |
|
} |
2519 |
g_SV->showFullScreen(); |
g_SV->showFullScreen(); |
2520 |
} |
} |
2521 |
g_MW->setCursor((int)10); /* Qt::BlankCursor */ |
g_MW->setCursor((int)10); /* Qt::BlankCursor */ |
2530 |
#ifdef SHARP |
#ifdef SHARP |
2531 |
g_App = new QPEApplication(argc, argv); |
g_App = new QPEApplication(argc, argv); |
2532 |
#else |
#else |
2533 |
//g_App = new QApplication(argc, argv, QApplication::GuiServer); |
g_App = new QApplication(argc, argv, QApplication::GuiServer); |
2534 |
g_App = new QApplication(argc, argv); |
//g_App = new QApplication(argc, argv); |
2535 |
#endif |
#endif |
2536 |
g_SV = new QMyScrollView(); |
g_SV = new QMyScrollView(); |
2537 |
g_App->setMainWidget(g_SV); |
g_App->setMainWidget(g_SV); |
2540 |
{ |
{ |
2541 |
get_username_and_hostname(); |
get_username_and_hostname(); |
2542 |
if (parse_parameters(argc, argv)) |
if (parse_parameters(argc, argv)) |
2543 |
|
{ |
2544 |
param_connect(); |
param_connect(); |
2545 |
|
} |
2546 |
} |
} |
2547 |
else |
else |
2548 |
{ |
{ |
2549 |
g_SV->timer_id = g_SV->startTimer(1000); /* one sec delay, then dialog */ |
g_SV->timer_id = g_SV->startTimer(1000); /* one sec delay, then dialog */ |
|
g_MW->setCursor((int)10); /* Qt::BlankCursor */ |
|
2550 |
g_App->exec(); |
g_App->exec(); |
2551 |
} |
} |
2552 |
delete g_SV; |
delete g_SV; |