author | zecke <zecke> | 2005-02-14 16:06:11 (UTC) |
---|---|---|
committer | zecke <zecke> | 2005-02-14 16:06:11 (UTC) |
commit | 277adb0af903b8bc2760c20891b664b763b667d9 (patch) (side-by-side diff) | |
tree | 9d6b33b8ed71f9f280981630ad45f3f8ba33eafb | |
parent | 866b55b819809a7bc448ea8b9cf2597051518007 (diff) | |
download | opie-277adb0af903b8bc2760c20891b664b763b667d9.zip opie-277adb0af903b8bc2760c20891b664b763b667d9.tar.gz opie-277adb0af903b8bc2760c20891b664b763b667d9.tar.bz2 |
Remove stupid #ifdef
-rw-r--r-- | noncore/net/opierdesktop/qtwin.cpp | 16 |
1 files changed, 0 insertions, 16 deletions
diff --git a/noncore/net/opierdesktop/qtwin.cpp b/noncore/net/opierdesktop/qtwin.cpp index d2a5ef1..e350bf6 100644 --- a/noncore/net/opierdesktop/qtwin.cpp +++ b/noncore/net/opierdesktop/qtwin.cpp @@ -1,160 +1,152 @@ /* rdesktop: A Remote Desktop Protocol client. User interface services - X Window System Copyright (C) Matthew Chapman 1999-2002 qt.cpp by Jay Sorg 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. */ #include "rdesktop.h" -#ifdef SHARP #include <qpe/qpeapplication.h> -#else -#include <qapplication.h> -#endif #include <qmainwindow.h> #include <qwidget.h> #include <qpainter.h> #include <qimage.h> #include <qsocketnotifier.h> #include <qscrollview.h> #include <qmessagebox.h> #include <qpushbutton.h> #include <qlineedit.h> #include <qcombobox.h> #include <qlabel.h> #include <qfile.h> #include <qcheckbox.h> #include <qpopupmenu.h> #include "qtwin.h" #include <stdlib.h> uint32 flags; char server[64] = ""; char domain[16] = ""; char password[16] = ""; char shell[128] = ""; char directory[32] = ""; extern int g_width; extern int g_height; extern int server_bpp; extern BOOL fullscreen; extern char username[]; int global_sock; QSocketNotifier* SocketNotifier; -#ifdef SHARP QPEApplication* App; -#else -QApplication* App; -#endif QMyMainWindow* MW; QMyScrollView* SV; struct QColorMap { uint32 RGBColors[256]; int NumColors; }; QColorMap* CM; uint8* BS; int clipx; int clipy; int clipcx; int clipcy; struct bitmap { int w; int h; uint8* data; }; BOOL owncolmap = False; //***************************************************************************** void CleanString(QString* Item) { int i; i = Item->length() - 1; while (i >= 0) { if (Item->at(i) == 10 || Item->at(i) == 13) Item->remove(i, 1); i--; } } //***************************************************************************** QMyDialog::QMyDialog(QWidget* parent) : QDialog(parent, "Settings", true) { int i, j; char* home; char Text[256]; QString Line; QString ItemName; QString ItemValue; // resize dialog resize(230, 270); // main list box ListBox = new QListBox(this); ListBox->move(10, 10); ListBox->resize(200, 100); connect(ListBox, SIGNAL(selectionChanged()), this, SLOT(ListBoxChanged())); connect(ListBox, SIGNAL(selected(int)), this, SLOT(ListBoxSelected(int))); // server Label1 = new QLabel(this); Label1->setText("Server Desc"); Label1->move(10, 120); Label1->resize(100, 20); ServerNameEdit = new QLineEdit(this); ServerNameEdit->move(75, 120); ServerNameEdit->resize(100, 20); // username Label2 = new QLabel(this); Label2->setText("User Name"); Label2->move(10, 150); Label2->resize(100, 20); UserNameEdit = new QLineEdit(this); UserNameEdit->move(75, 150); UserNameEdit->resize(100, 20); // ip Label3 = new QLabel(this); Label3->setText("Server IP"); Label3->move(10, 180); Label3->resize(100, 20); IPEdit = new QLineEdit(this); IPEdit->move(75, 180); IPEdit->resize(100, 20); // width and height WidthHeightBox = new QComboBox(this); WidthHeightBox->move(10, 210); WidthHeightBox->resize(100, 20); WidthHeightBox->insertItem("240x320"); WidthHeightBox->insertItem("640x480"); WidthHeightBox->insertItem("800x600"); connect(WidthHeightBox, SIGNAL(activated(int)), this, SLOT(ComboChanged(int))); WidthHeightBox->setCurrentItem(1); WidthEdit = new QLineEdit(this); WidthEdit->move(110, 210); WidthEdit->resize(30, 20); WidthEdit->setText("800"); HeightEdit = new QLineEdit(this); HeightEdit->move(140, 210); HeightEdit->resize(30, 20); HeightEdit->setText("600"); @@ -934,197 +926,193 @@ void set_pixel(int x, int y, uint8 pixel, int op = 0xc) if (x >= 0 && x < g_width && y >= 0 && y < g_height) if (op == 0xc) BS[y * g_width + x] = pixel; else BS[y * g_width + x] = rop(op, pixel, BS[y * g_width + x]); } //****************************************************************************** // adjust coordinates for cliping rect bool WarpCoords(int* x, int* y, int* cx, int* cy, int* srcx, int* srcy) { int dx, dy; QRect InRect(*x, *y, *cx, *cy); QRect OutRect; QRect CRect(clipx, clipy, clipcx, clipcy); OutRect = InRect.intersect(CRect); if (OutRect.isEmpty()) return false; dx = OutRect.x() - InRect.x(); dy = OutRect.y() - InRect.y(); *x = OutRect.x(); *y = OutRect.y(); *cx = OutRect.width(); *cy = OutRect.height(); if (srcx != NULL) *srcx = *srcx + dx; if (srcy != NULL) *srcy = *srcy + dy; return true; } //***************************************************************************** void QMyMainWindow::paintEvent(QPaintEvent* pe) { QImage* Image; QPainter* Painter; QRect Rect; int i, j, w, h, l, t; uint8* data; if (!testWFlags(WRepaintNoErase)) setWFlags(WRepaintNoErase); if (CM != NULL) { Rect = pe->rect(); l = Rect.left(); t = Rect.top(); w = Rect.width(); h = Rect.height(); if (w > 0 && h > 0 && CM->NumColors > 0) { data = (uint8*)xmalloc(w * h); for (i = 0; i < h; i++) for (j = 0; j < w; j++) data[i * w + j] = get_pixel(l + j, t + i); Image = new QImage(data, w, h, 8,(QRgb*)CM->RGBColors, CM->NumColors, QImage::IgnoreEndian); Painter = new QPainter(this); Painter->drawImage(l, t, *Image, 0, 0, w, h); xfree(data); delete Painter; delete Image; } } } //***************************************************************************** void QMyMainWindow::closeEvent(QCloseEvent* e) { e->accept(); } //***************************************************************************** void QMyMainWindow::dataReceived() { if (rdp_main_loop()) return; else SV->close(); } //***************************************************************************** void redraw(int x, int y, int cx, int cy) { if (WarpCoords(&x, &y, &cx, &cy, NULL, NULL)) { MW->update(x, y, cx, cy); } } /* BOOL ui_init(void) { QWidget* d; CM = NULL; BS = NULL; -#ifdef SHARP App = new QPEApplication(g_argc, g_argv); -#else - App = new QApplication(g_argc, g_argv, QApplication::GuiServer); -#endif if (fullscreen) { d = QApplication::desktop(); width = d->width(); // returns screen width height = d->height(); // returns screen height } return True; } */ /* void ui_deinit(void) { delete App; } */ /* BOOL ui_create_window(void) { MW = new QMyMainWindow(); MW->resize(width, height); SV = new QMyScrollView(); SV->resize(width + 4, height + 4); App->setMainWidget(SV); SV->addChild(MW); MW->setMouseTracking(true); SocketNotifier = new QSocketNotifier(global_sock, QSocketNotifier::Read, MW); MW->connect(SocketNotifier, SIGNAL(activated(int)), MW, SLOT(dataReceived())); if (fullscreen) SV->showFullScreen(); else SV->showMaximized(); BS = (uint8*)xmalloc(width * height); memset(BS, 0, width * height); clipx = 0; clipy = 0; clipcx = width; clipcy = height; CM = (QColorMap*)xmalloc(sizeof(struct QColorMap)); memset(CM, 0, sizeof(struct QColorMap)); SV->timer_id = SV->startTimer(1000); return True; } */ /* void ui_destroy_window(void) { delete MW; delete SV; xfree(BS); xfree(CM); } */ //***************************************************************************** /* Returns 0 after user quit, 1 otherwise */ int ui_select(int rdp_socket) { global_sock = rdp_socket; return 1; } //***************************************************************************** void ui_move_pointer(int /*x*/, int /*y*/) { } //***************************************************************************** HBITMAP ui_create_bitmap(int width, int height, uint8 * data) { struct bitmap* the_bitmap; uint8* bitmap_data; int i, j; // printf("width %d height %d times %d\n", width, height, width * height); bitmap_data = (uint8*)xmalloc(width * height); the_bitmap = (struct bitmap*)xmalloc(sizeof(struct bitmap)); the_bitmap->w = width; the_bitmap->h = height; the_bitmap->data = bitmap_data; for (i = 0; i < height; i++) for (j = 0; j < width; j++) bitmap_data[i * width + j] = data[i * width + j]; return the_bitmap; } //***************************************************************************** void ui_paint_bitmap(int x, int y, int cx, int cy, int width, int height, uint8 * data) { int i, j; for (i = 0; i < cy; i++) for (j = 0; j < cx; j++) @@ -1523,197 +1511,193 @@ void ui_draw_text(uint8 font, uint8 flags, int mixmode, FONTGLYPH *glyph; int i, j, xyoffset; DATABLOB *entry; if (boxcx > 1) fill_rect(boxx, boxy, boxcx, boxcy, bgcolour); else if (mixmode == MIX_OPAQUE) fill_rect(clipx, clipy, clipcx, clipcy, bgcolour); /* Paint text, character by character */ for (i = 0; i < length;) { switch (text[i]) { case 0xff: if (i + 2 < length) cache_put_text(text[i + 1], text, text[i + 2]); else { error("this shouldn't be happening\n"); exit(1); } /* this will move pointer from start to first character after FF command */ length -= i + 3; text = &(text[i + 3]); i = 0; break; case 0xfe: entry = cache_get_text(text[i + 1]); if (entry != NULL) { if ((((uint8 *) (entry->data))[1] == 0) && (!(flags & TEXT2_IMPLICIT_X))) { if (flags & TEXT2_VERTICAL) y += text[i + 2]; else x += text[i + 2]; } for (j = 0; j < entry->size; j++) DO_GLYPH(((uint8 *) (entry->data)), j); } if (i + 2 < length) i += 3; else i += 2; length -= i; /* this will move pointer from start to first character after FE command */ text = &(text[i]); i = 0; break; default: DO_GLYPH(text, i); i++; break; } } if (boxcx > 1) redraw(boxx, boxy, boxcx, boxcy); else redraw(clipx, clipy, clipcx, clipcy); } //***************************************************************************** void ui_desktop_save(uint32 offset, int x, int y, int cx, int cy) { uint8* data; int i, j; data = (uint8*)xmalloc(cx * cy); for (i = 0; i < cy; i++) for (j = 0; j < cx; j++) data[i * cx + j] = get_pixel(x + j, y + i); cache_put_desktop(offset, cx, cy, cx, 1, data); xfree(data); } //***************************************************************************** void ui_desktop_restore(uint32 offset, int x, int y, int cx, int cy) { uint8* data; int i, j; data = cache_get_desktop(offset, cx, cy, 1); for (i = 0; i < cy; i++) for (j = 0; j < cx; j++) set_pixel(x + j, y + i, data[i * cx + j]); redraw(x, y, cx, cy); } //***************************************************************************** int main(int argc, char** argv) { CM = NULL; BS = NULL; -#ifdef SHARP App = new QPEApplication(argc, argv); -#else - App = new QApplication(argc, argv, QApplication::GuiServer); -#endif SV = new QMyScrollView(); App->setMainWidget(SV); SV->showMaximized(); SV->timer_id = SV->startTimer(1000); App->exec(); delete SV; delete App; if (CM != NULL) xfree(CM); if (BS !=NULL) xfree(BS); return 0; } /* MW = new QMyMainWindow(); MW->resize(width, height); SV->resize(width + 4, height + 4); App->setMainWidget(SV); SV->addChild(MW); MW->setMouseTracking(true); SocketNotifier = new QSocketNotifier(global_sock, QSocketNotifier::Read, MW); MW->connect(SocketNotifier, SIGNAL(activated(int)), MW, SLOT(dataReceived())); if (fullscreen) SV->showFullScreen(); else SV->showMaximized(); BS = (uint8*)xmalloc(width * height); memset(BS, 0, width * height); clipx = 0; clipy = 0; clipcx = width; clipcy = height; CM = (QColorMap*)xmalloc(sizeof(struct QColorMap)); memset(CM, 0, sizeof(struct QColorMap)); SV->timer_id = SV->startTimer(1000); return True; int main(int argc, char ** argv) { uint32 flags; int i, total_params; char server[64] = "192.168.0.164"; char domain[16] = ""; char password[16] = ""; char shell[128] = ""; char directory[32] = ""; char* p; QString param, s1, s2, s3; flags = RDP_LOGON_NORMAL; g_argc = argc; g_argv = argv; if (!ui_init()) return 1; total_params = App->argc(); for (i = 1; (i + 1) < total_params; i = i + 2) { s1 = App->argv()[i]; s2 = App->argv()[i + 1]; if (s1 == "-g") { width = strtol((const char*)s2, &p, 10); if (*p == 'x') height = strtol(p + 1, NULL, 10); } else if (s1 = "-u") strcpy(username, (const char*)s2); } if (i < total_params) strcpy(server, App->argv()[i]); // printf("server %s width %d height %d\n", server, width, height); if (width == 0 || height == 0) { ui_deinit(); return 1; } if (!rdp_connect(server, flags, domain, password, shell, directory)) { ui_deinit(); return 1; } if (ui_create_window()) { ui_main_loop(); |