23#include <qapplication.h>
24#include <qmainwindow.h>
32#include <qsocketnotifier.h>
33#include <qscrollview.h>
81static int g_rdpsnd = 0;
82static QSocketNotifier * g_SoundNotifier = 0;
137 r = (InColor & 0x7c00) >> 10;
138 r = (
r * 0xff) / 0x1f;
139 g = (InColor & 0x03e0) >> 5;
140 g = (
g * 0xff) / 0x1f;
141 b = (InColor & 0x001f);
142 b = (
b * 0xff) / 0x1f;
143 return (
r << 16) | (
g << 8) |
b;
151 r = (InColor & 0xf800) >> 11;
152 r = (
r * 0xff) / 0x1f;
153 g = (InColor & 0x07e0) >> 5;
154 g = (
g * 0xff) / 0x3f;
155 b = (InColor & 0x001f);
156 b = (
b * 0xff) / 0x1f;
157 return (
r << 16) | (
g << 8) |
b;
163 return ((InColor & 0x00ff0000) >> 16) |
164 ((InColor & 0x000000ff) << 16) |
165 (InColor & 0x0000ff00);
198 if (opcode >= 0 && opcode < 16)
201 if (
op != Qt::CopyROP)
212 if (opcode >= 0 && opcode < 16)
215 if (
op != Qt::CopyROP)
217 g_P1->setRasterOp(Qt::CopyROP);
218 g_P2->setRasterOp(Qt::CopyROP);
250 if (
e->button() == LeftButton)
255 else if (
e->button() == RightButton)
260 else if (
e->button() == MidButton)
274 if (
e->button() == LeftButton)
278 else if (
e->button() == RightButton)
282 else if (
e->button() == MidButton)
299 else if (
e->delta() < 0)
310 Qt::ButtonState
bs =
e->state();
311 if (!(
bs & Qt::ShiftButton))
474 return QWidget::event(
e);
487 if (g_SoundNotifier == 0)
489 g_SoundNotifier =
new QSocketNotifier(g_dsp_fd, QSocketNotifier::Write,
496 if (!g_SoundNotifier->isEnabled())
498 g_SoundNotifier->setEnabled(
true);
509 g_SoundNotifier->setEnabled(
false);
513 g_SoundNotifier->setEnabled(
true);
569 painter =
new QPainter(
g_BS);
571 painter->fillRect(0, 0,
g_width,
g_height, QBrush(QBrush::CrossPattern));
573 g_DS =
new QPixmap(480, 480);
574 g_P1 =
new QPainter();
575 g_P2 =
new QPainter();
577 desktop = QApplication::desktop();
578 w = desktop->width();
579 h = desktop->height();
593 g_MW->setMouseTracking(
true);
630 g_MW, SLOT(dataReceived()));
667 Cursor = (QCursor*)
cursor;
695 Pixmap = (QPixmap*)
bmp;
725 while (i < colours->ncolours &&
i < 256)
769 g_CM->NumColors, QImage::IgnoreEndian);
779 0, QImage::IgnoreEndian);
789 0, QImage::IgnoreEndian);
799 0, QImage::IgnoreEndian);
806 Pixmap =
new QPixmap();
807 Pixmap->convertFromImage(*
Image);
821 QRect InRect(*
x, *
y, *
cx, *
cy);
824 OutRect = InRect.intersect(
CRect);
825 if (OutRect.isEmpty())
829 dx = OutRect.x() - InRect.x();
830 dy = OutRect.y() - InRect.y();
833 *
cx = OutRect.width();
834 *
cy = OutRect.height();
844 QPaintDevice *
src,
int sx,
int sy,
int sw,
int sh,
845 Qt::RasterOp
rop,
bool im)
853 bitBlt(dst1,
dx,
dy, dst1, sx, sy, sw,
sh,
rop, im);
864 bitBlt(dst2,
dx,
dy, dst2, sx, sy, sw,
sh,
rop, im);
874#define DO_GLYPH(ttext,idx) \
876 glyph = cache_get_font (font, ttext[idx]); \
877 if (!(flags & TEXT2_IMPLICIT_X)) \
879 xyoffset = ttext[++idx]; \
880 if ((xyoffset & 0x80)) \
882 if (flags & TEXT2_VERTICAL) \
883 y += ttext[idx+1] | (ttext[idx+2] << 8); \
885 x += ttext[idx+1] | (ttext[idx+2] << 8); \
890 if (flags & TEXT2_VERTICAL) \
898 g_P2->drawPixmap(x + glyph->offset, y + glyph->baseline, \
899 *((QBitmap*)glyph->pixmap)); \
900 if (flags & TEXT2_IMPLICIT_X) \
907 int x,
int y,
int clipx,
int clipy,
908 int clipcx,
int clipcy,
int boxx,
909 int boxy,
int boxcx,
int boxcy,
BRUSH * brush,
922 g_P2->fillRect(boxx, boxy, boxcx, boxcy, QBrush(
g_Color2));
926 g_P2->fillRect(clipx, clipy, clipcx, clipcy, QBrush(
g_Color2));
941 error(
"this shouldn't be happening\n");
1001 clipcy, Qt::CopyROP,
true);
1012 g_P1->moveTo(startx, starty);
1013 g_P1->lineTo(endx, endy);
1015 g_P2->moveTo(startx, starty);
1016 g_P2->lineTo(endx, endy);
1024 BRUSH* brush,
int bgcolour,
int fgcolour)
1033 Pixmap = (QPixmap*)
src;
1037 g_P1->drawPixmap(
x,
y, *Pixmap, srcx, srcy,
cx,
cy);
1038 g_P2->drawPixmap(
x,
y, *Pixmap, srcx, srcy,
cx,
cy);
1070 bitBlt(Pixmap1, lx, ly, Pixmap2,
x1,
y1,
width, 1, Qt::CopyROP,
true);
1072 bitBlt(Pixmap2,
x1,
y1, Pixmap1, lx, ly,
width, 1, Qt::CopyROP,
true);
1093 Pixmap =
new QPixmap(
cx,
cy);
1095 bitBltClip(
g_MW,
g_BS,
x,
y, Pixmap, 0, 0,
cx,
cy, Qt::CopyROP,
true);
1118 bitBltClip(
g_MW,
g_BS,
x,
y,
NULL, srcx, srcy,
cx,
cy, Qt::CopyROP,
true);
1124 BRUSH* brush,
int bgcolour,
int fgcolour)
1130 switch (brush->style)
1139 for (
i = 0;
i != 8;
i++)
1141 ipattern[7 -
i] = ~brush->pattern[
i];
1143 Bitmap =
new QBitmap(8, 8, ipattern);
1145 g_P2->setBackgroundMode(Qt::OpaqueMode);
1146 g_P2->setBrushOrigin(brush->xorigin, brush->yorigin);
1151 g_P2->setBackgroundMode(Qt::TransparentMode);
1152 g_P2->setBrushOrigin(0, 0);
1156 bitBltClip(
g_MW,
NULL,
x,
y,
g_BS,
x,
y,
cx,
cy, Qt::CopyROP,
true);
1163 g_P1->fillRect(
x,
y,
cx,
cy, QBrush(QColor(
"black")));
1164 g_P2->fillRect(
x,
y,
cx,
cy, QBrush(QColor(
"black")));
1176 g_MW->setCursor(10);
1193 g_CM->NumColors, QImage::IgnoreEndian);
1203 0, QImage::IgnoreEndian);
1213 0, QImage::IgnoreEndian);
1223 0, QImage::IgnoreEndian);
1230 Pixmap =
new QPixmap();
1231 Pixmap->convertFromImage(*
Image);
1232 g_P1->drawPixmap(
x,
y, *Pixmap, 0, 0,
cx,
cy);
1233 g_P2->drawPixmap(
x,
y, *Pixmap, 0, 0,
cx,
cy);
1251 return !((
R == 0) && (
G == 0) && (
B == 0));
1293 Cursor = (QCursor*)
cursor;
1295 g_MW->setCursor(*Cursor);
1305 QBitmap* DataBitmap;
1306 QBitmap* MaskBitmap;
1308 int I1, I2, BOn, MOn;
1316 for (I1 = 0; I1 <= 31; I1++)
1318 for (I2 = 0; I2 <= 31; I2++)
1320 MOn =
Is24On(xormask, I1, I2);
1321 BOn =
Is1On(andmask, I1, I2);
1324 Set1(AData, I1, I2);
1327 Set1(AMask, I1, I2);
1332 Set1(AMask, I1, I2);
1338 DataBitmap =
new QBitmap(32, 32, AData);
1339 MaskBitmap =
new QBitmap(32, 32, AMask);
1340 Cursor =
new QCursor(*DataBitmap, *MaskBitmap,
x,
y);
1365 BRUSH * brush,
int bgcolour,
int fgcolour)
1379 for (
i = 1;
i < npoints;
i++)
1392 int x,
int y,
int cx,
int cy,
1393 BRUSH * brush,
int bgcolour,
int fgcolour)
1400 QFile
File(
"/dev/random");
1407 memcpy(
random,
"12345678901234567890123456789012", 32);
1422 sizeof(
"/.rdesktop/licence."));
1469 sizeof(
"/.rdesktop/licence."));
1558 fprintf(
stderr,
"rdesktop: A Remote Desktop Protocol client.\n");
1561 fprintf(
stderr,
"See http://www.rdesktop.org/ for more information.\n\n");
1592 for (
i = 0;
i < thisline;
i++)
1600 for (
i = 0;
i < thisline;
i++)
1614 char bmpcache_dir[256];
1621 sprintf(bmpcache_dir,
"%s/%s",
home,
".rdesktop");
1627 sprintf(bmpcache_dir,
"%s/%s",
home,
".rdesktop/cache");
1686 lock.l_type = F_WRLCK;
1690 if (fcntl(
fd, F_SETLK, &
lock) == -1)
1700 char fullhostname[64];
1707 if (pw !=
NULL && pw->pw_name !=
NULL)
1711 if (
gethostname(fullhostname,
sizeof(fullhostname)) != -1)
1713 p =
strchr(fullhostname,
'.');
1735 for (
i = 1;
i < in_argc;
i++)
1738 if (
strcmp(in_argv[
i],
"-g") == 0)
1743 error(
"invalid geometry\n");
1752 error(
"invalid geometry\n");
1757 else if (
strcmp(in_argv[
i],
"-T") == 0)
1761 else if (
strcmp(in_argv[
i],
"-4") == 0)
1765 else if (
strcmp(in_argv[
i],
"-5") == 0)
1769 else if (
strcmp(in_argv[
i],
"-a") == 0)
1775 error(
"invalid bpp\n");
1779 else if (
strcmp(in_argv[
i],
"-t") == 0)
1783 else if (
strcmp(in_argv[
i],
"-P") == 0)
1787 else if (
strcmp(in_argv[
i],
"-0") == 0)
1791 else if (
strcmp(in_argv[
i],
"-z") == 0)
1795 else if (
strcmp(in_argv[
i],
"-r") == 0)
1797 if (
strcmp(in_argv[
i + 1],
"sound") == 0)
1809int main(
int in_argc,
char** in_argv)
char * strcat(char *DstString, const char *SrcString)
int strcmp(const char *String1, const char *String2)
ACPI_SIZE strlen(const char *String)
char * strcpy(char *DstString, const char *SrcString)
char * strchr(const char *String, int ch)
void cache_put_text(uint8 cache_id, void *data, int length)
DATABLOB * cache_get_text(uint8 cache_id)
#define MOUSE_FLAG_BUTTON5
#define MOUSE_FLAG_BUTTON1
#define MOUSE_FLAG_BUTTON2
#define MOUSE_FLAG_BUTTON4
#define MOUSE_FLAG_BUTTON3
void rdp_send_input(uint32 time, uint16 message_type, uint16 device_flags, uint16 param1, uint16 param2)
RD_BOOL rdp_connect(char *server, uint32 flags, char *domain, char *password, char *command, char *directory, RD_BOOL reconnect)
RD_BOOL rdp_loop(RD_BOOL *deactivated, uint32 *ext_disc_reason)
RD_BOOL rdpsnd_init(char *optarg)
#define STRNCPY(dst, src, n)
#define G(r, i, a, b, c, d)
bool open(const char *filename, const char *mode)
void mouseReleaseEvent(QMouseEvent *)
void wheelEvent(QWheelEvent *)
void closeEvent(QCloseEvent *)
void mousePressEvent(QMouseEvent *)
void mouseMoveEvent(QMouseEvent *)
void keyPressEvent(QKeyEvent *)
void keyReleaseEvent(QKeyEvent *)
void paintEvent(QPaintEvent *)
INT WSAAPI gethostname(OUT char FAR *name, IN INT namelen)
GLint GLint GLint GLint GLint x
GLint GLint GLint GLint GLint GLint y
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLint GLint GLsizei GLsizei height
GLdouble GLdouble GLdouble r
GLint GLint GLsizei width
GLboolean GLboolean GLboolean b
GLuint GLsizei GLsizei * length
GLubyte GLubyte GLubyte GLubyte w
GLsizei const GLfloat * points
GLfloat GLfloat GLfloat GLfloat h
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
_CRTIMP void __cdecl perror(_In_opt_z_ const char *_ErrMsg)
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
_Check_return_opt_ _CRTIMP int __cdecl vfprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format, va_list _ArgList)
_Check_return_ long __cdecl strtol(_In_z_ const char *_Str, _Out_opt_ _Deref_post_z_ char **_EndPtr, _In_ int _Radix)
_Check_return_ char *__cdecl getenv(_In_z_ const char *_VarName)
static struct msdos_boot_sector bs
#define memcpy(s1, s2, n)
#define RDP_LOGON_COMPRESSION
#define RDP_LOGON_COMPRESSION2
#define sprintf(buf, format,...)
static int rop(int rop, int src, int dst)
_In_ ULONG _In_ ULONG Offset
_Out_opt_ int _Out_opt_ int * cy
static QMyScrollView * g_SV
void GetScanCode(QKeyEvent *e, int *ScanCode, int *code)
static QMyMainWindow * g_MW
HBITMAP ui_create_bitmap(int width, int height, uint8 *data)
char g_redirect_cookie[128]
void CommonDeskSave(QPixmap *Pixmap1, QPixmap *Pixmap2, int Offset, int x, int y, int cx, int cy, int dir)
void ui_polygon(uint8 opcode, uint8 fillmode, POINT *point, int npoints, BRUSH *brush, int bgcolour, int fgcolour)
void ui_rect(int x, int y, int cx, int cy, int colour)
void bitBltClip(QPaintDevice *dst1, QPaintDevice *dst2, int dx, int dy, QPaintDevice *src, int sx, int sy, int sw, int sh, Qt::RasterOp rop, bool im)
void * ui_create_colourmap(COLOURMAP *colours)
void ui_patblt(uint8 opcode, int x, int y, int cx, int cy, BRUSH *brush, int bgcolour, int fgcolour)
HCURSOR ui_create_cursor(unsigned int x, unsigned int y, int width, int height, uint8 *andmask, uint8 *xormask)
#define DO_GLYPH(ttext, idx)
void ui_destroy_bitmap(void *bmp)
int g_rdp5_performanceflags
int parse_parameters(int in_argc, char **in_argv)
int rd_write_file(int fd, void *ptr, int len)
static int g_UpAndRunning
static struct QColorMap * g_CM
char g_redirect_username[64]
void ui_destroy_cursor(void *cursor)
char * xstrdup(const char *s)
void ui_screenblt(uint8 opcode, int x, int y, int cx, int cy, int srcx, int srcy)
int ui_create_window(void)
void Set1(uint8 *Data, int X, int Y)
int rd_read_file(int fd, void *ptr, int len)
void ui_set_null_cursor(void)
void ui_paint_bitmap(int x, int y, int cx, int cy, int width, int height, uint8 *data)
void ui_desktop_save(uint32 offset, int x, int y, int cx, int cy)
void ui_destroy_window(void)
void ui_ellipse(uint8 opcode, uint8 fillmode, int x, int y, int cx, int cy, BRUSH *brush, int bgcolour, int fgcolour)
void ui_polyline(uint8 opcode, POINT *points, int npoints, PEN *pen)
char g_redirect_domain[16]
static Qt::RasterOp g_OpCodes[16]
int g_keyboard_functionkeys
static char g_servername[128]
void ui_triblt(uint8 opcode, int x, int y, int cx, int cy, HBITMAP src, int srcx, int srcy, BRUSH *brush, int bgcolour, int fgcolour)
int load_licence(uint8 **data)
int Is1On(uint8 *Data, int X, int Y)
void rd_close_file(int fd)
void ui_draw_text(uint8 font, uint8 flags, uint8 opcode, int mixmode, int x, int y, int clipx, int clipy, int clipcx, int clipcy, int boxx, int boxy, int boxcx, int boxcy, BRUSH *brush, int bgcolour, int fgcolour, uint8 *text, uint8 length)
void ui_set_colourmap(void *map)
static QApplication * g_App
void SetOpCode(int opcode)
void unimpl(char *format,...)
uint32 Color15to32(uint32 InColor)
uint16 ui_get_numlock_state(uint32 state)
void ui_line(uint8 opcode, int startx, int starty, int endx, int endy, PEN *pen)
char g_redirect_password[64]
void ui_set_cursor(HCURSOR cursor)
static uint32 g_ext_disc_reason
uint32 Color16to32(uint32 InColor)
void ui_destblt(uint8 opcode, int x, int y, int cx, int cy)
static QSocketNotifier * g_SocketNotifier
void ui_desktop_restore(uint32 offset, int x, int y, int cx, int cy)
void * xrealloc(void *in_val, int size)
int rd_lock_file(int fd, int start, int len)
static QRegion * g_ClipRect
void ui_set_clip(int x, int y, int cx, int cy)
int GetScanCode(QKeyEvent *e)
int rd_pstcache_mkdir(void)
uint32 Color24to32(uint32 InColor)
void ui_resize_window(void)
void ui_destroy_colourmap(HCOLOURMAP map)
void SetColorx(QColor *Color, uint32 InColor)
int WarpCoords(int *x, int *y, int *cx, int *cy, int *srcx, int *srcy)
void * ui_create_glyph(int width, int height, uint8 *data)
int Is24On(uint8 *Data, int X, int Y)
static QMyScrollView * g_SV
int g_bitmap_cache_precache
int g_bitmap_cache_persist_enable
void hexdump(uint8 *p, uint32 len)
void save_licence(uint8 *data, int length)
void ui_memblt(uint8 opcode, int x, int y, int cx, int cy, HBITMAP src, int srcx, int srcy)
void ui_begin_update(void)
char g_redirect_server[64]
int rd_lseek_file(int fd, int offset)
int ui_select(int in_val)
uint32 read_keyboard_state(void)
int rd_open_file(char *filename)
void ui_move_pointer(int x, int y)
void generate_random(uint8 *random)
int g_polygon_ellipse_orders
void ResetOpCode(int opcode)
void ui_destroy_glyph(void *glyph)
static QMyMainWindow * g_MW
void get_username_and_hostname(void)
void FlipOver(uint8 *Data)
_Check_return_ int __cdecl rename(_In_z_ const char *_OldFilename, _In_z_ const char *_NewFilename)
_Check_return_ _CRTIMP char *__cdecl strdup(_In_opt_z_ const char *_Src)
static uint32 g_ext_disc_reason
_In_ WDFCOLLECTION _In_ ULONG Index
static GLenum _GLUfuncptr fn
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG y1
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG x1
void int int ULONGLONG int va_list * ap