summaryrefslogtreecommitdiff
authorzecke <zecke>2005-02-14 16:08:36 (UTC)
committer zecke <zecke>2005-02-14 16:08:36 (UTC)
commit0e6780c400fbae2ccd8895e40480adb4273906ae (patch) (unidiff)
tree1cc48cfef9c0542272da51071ebda0e27b9e3cfc
parent277adb0af903b8bc2760c20891b664b763b667d9 (diff)
downloadopie-0e6780c400fbae2ccd8895e40480adb4273906ae.zip
opie-0e6780c400fbae2ccd8895e40480adb4273906ae.tar.gz
opie-0e6780c400fbae2ccd8895e40480adb4273906ae.tar.bz2
Set a Caption
File a Bug and propose a better name
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/opierdesktop/qtwin.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/noncore/net/opierdesktop/qtwin.cpp b/noncore/net/opierdesktop/qtwin.cpp
index e350bf6..181d275 100644
--- a/noncore/net/opierdesktop/qtwin.cpp
+++ b/noncore/net/opierdesktop/qtwin.cpp
@@ -1,1709 +1,1711 @@
1/* 1/*
2 rdesktop: A Remote Desktop Protocol client. 2 rdesktop: A Remote Desktop Protocol client.
3 User interface services - X Window System 3 User interface services - X Window System
4 Copyright (C) Matthew Chapman 1999-2002 4 Copyright (C) Matthew Chapman 1999-2002
5 qt.cpp by Jay Sorg 5 qt.cpp by Jay Sorg
6 6
7 This program is free software; you can redistribute it and/or modify 7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by 8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or 9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version. 10 (at your option) any later version.
11 11
12 This program is distributed in the hope that it will be useful, 12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details. 15 GNU General Public License for more details.
16 16
17 You should have received a copy of the GNU General Public License 17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software 18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 19 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20*/ 20*/
21 21
22#include "rdesktop.h" 22#include "rdesktop.h"
23#include <qpe/qpeapplication.h> 23#include <qpe/qpeapplication.h>
24#include <qmainwindow.h> 24#include <qmainwindow.h>
25#include <qwidget.h> 25#include <qwidget.h>
26#include <qpainter.h> 26#include <qpainter.h>
27#include <qimage.h> 27#include <qimage.h>
28#include <qsocketnotifier.h> 28#include <qsocketnotifier.h>
29#include <qscrollview.h> 29#include <qscrollview.h>
30#include <qmessagebox.h> 30#include <qmessagebox.h>
31#include <qpushbutton.h> 31#include <qpushbutton.h>
32#include <qlineedit.h> 32#include <qlineedit.h>
33#include <qcombobox.h> 33#include <qcombobox.h>
34#include <qlabel.h> 34#include <qlabel.h>
35#include <qfile.h> 35#include <qfile.h>
36#include <qcheckbox.h> 36#include <qcheckbox.h>
37#include <qpopupmenu.h> 37#include <qpopupmenu.h>
38#include "qtwin.h" 38#include "qtwin.h"
39#include <stdlib.h> 39#include <stdlib.h>
40 40
41uint32 flags; 41uint32 flags;
42char server[64] = ""; 42char server[64] = "";
43char domain[16] = ""; 43char domain[16] = "";
44char password[16] = ""; 44char password[16] = "";
45char shell[128] = ""; 45char shell[128] = "";
46char directory[32] = ""; 46char directory[32] = "";
47 47
48extern int g_width; 48extern int g_width;
49extern int g_height; 49extern int g_height;
50extern int server_bpp; 50extern int server_bpp;
51extern BOOL fullscreen; 51extern BOOL fullscreen;
52extern char username[]; 52extern char username[];
53int global_sock; 53int global_sock;
54 54
55QSocketNotifier* SocketNotifier; 55QSocketNotifier* SocketNotifier;
56QPEApplication* App; 56QPEApplication* App;
57QMyMainWindow* MW; 57QMyMainWindow* MW;
58QMyScrollView* SV; 58QMyScrollView* SV;
59struct QColorMap 59struct QColorMap
60{ 60{
61 uint32 RGBColors[256]; 61 uint32 RGBColors[256];
62 int NumColors; 62 int NumColors;
63}; 63};
64QColorMap* CM; 64QColorMap* CM;
65uint8* BS; 65uint8* BS;
66int clipx; 66int clipx;
67int clipy; 67int clipy;
68int clipcx; 68int clipcx;
69int clipcy; 69int clipcy;
70 70
71struct bitmap 71struct bitmap
72{ 72{
73 int w; 73 int w;
74 int h; 74 int h;
75 uint8* data; 75 uint8* data;
76}; 76};
77 77
78BOOL owncolmap = False; 78BOOL owncolmap = False;
79 79
80//***************************************************************************** 80//*****************************************************************************
81void CleanString(QString* Item) 81void CleanString(QString* Item)
82{ 82{
83 int i; 83 int i;
84 84
85 i = Item->length() - 1; 85 i = Item->length() - 1;
86 while (i >= 0) 86 while (i >= 0)
87 { 87 {
88 if (Item->at(i) == 10 || Item->at(i) == 13) 88 if (Item->at(i) == 10 || Item->at(i) == 13)
89 Item->remove(i, 1); 89 Item->remove(i, 1);
90 i--; 90 i--;
91 } 91 }
92} 92}
93 93
94//***************************************************************************** 94//*****************************************************************************
95QMyDialog::QMyDialog(QWidget* parent) : QDialog(parent, "Settings", true) 95QMyDialog::QMyDialog(QWidget* parent) : QDialog(parent, "Settings", true)
96{ 96{
97 setCaption( tr( "Configuration" ) );
97 int i, j; 98 int i, j;
98 char* home; 99 char* home;
99 char Text[256]; 100 char Text[256];
100 QString Line; 101 QString Line;
101 QString ItemName; 102 QString ItemName;
102 QString ItemValue; 103 QString ItemValue;
103 104
104 // resize dialog 105 // resize dialog
105 resize(230, 270); 106 resize(230, 270);
106 // main list box 107 // main list box
107 ListBox = new QListBox(this); 108 ListBox = new QListBox(this);
108 ListBox->move(10, 10); 109 ListBox->move(10, 10);
109 ListBox->resize(200, 100); 110 ListBox->resize(200, 100);
110 connect(ListBox, SIGNAL(selectionChanged()), this, SLOT(ListBoxChanged())); 111 connect(ListBox, SIGNAL(selectionChanged()), this, SLOT(ListBoxChanged()));
111 connect(ListBox, SIGNAL(selected(int)), this, SLOT(ListBoxSelected(int))); 112 connect(ListBox, SIGNAL(selected(int)), this, SLOT(ListBoxSelected(int)));
112 // server 113 // server
113 Label1 = new QLabel(this); 114 Label1 = new QLabel(this);
114 Label1->setText("Server Desc"); 115 Label1->setText("Server Desc");
115 Label1->move(10, 120); 116 Label1->move(10, 120);
116 Label1->resize(100, 20); 117 Label1->resize(100, 20);
117 ServerNameEdit = new QLineEdit(this); 118 ServerNameEdit = new QLineEdit(this);
118 ServerNameEdit->move(75, 120); 119 ServerNameEdit->move(75, 120);
119 ServerNameEdit->resize(100, 20); 120 ServerNameEdit->resize(100, 20);
120 // username 121 // username
121 Label2 = new QLabel(this); 122 Label2 = new QLabel(this);
122 Label2->setText("User Name"); 123 Label2->setText("User Name");
123 Label2->move(10, 150); 124 Label2->move(10, 150);
124 Label2->resize(100, 20); 125 Label2->resize(100, 20);
125 UserNameEdit = new QLineEdit(this); 126 UserNameEdit = new QLineEdit(this);
126 UserNameEdit->move(75, 150); 127 UserNameEdit->move(75, 150);
127 UserNameEdit->resize(100, 20); 128 UserNameEdit->resize(100, 20);
128 // ip 129 // ip
129 Label3 = new QLabel(this); 130 Label3 = new QLabel(this);
130 Label3->setText("Server IP"); 131 Label3->setText("Server IP");
131 Label3->move(10, 180); 132 Label3->move(10, 180);
132 Label3->resize(100, 20); 133 Label3->resize(100, 20);
133 IPEdit = new QLineEdit(this); 134 IPEdit = new QLineEdit(this);
134 IPEdit->move(75, 180); 135 IPEdit->move(75, 180);
135 IPEdit->resize(100, 20); 136 IPEdit->resize(100, 20);
136 // width and height 137 // width and height
137 WidthHeightBox = new QComboBox(this); 138 WidthHeightBox = new QComboBox(this);
138 WidthHeightBox->move(10, 210); 139 WidthHeightBox->move(10, 210);
139 WidthHeightBox->resize(100, 20); 140 WidthHeightBox->resize(100, 20);
140 WidthHeightBox->insertItem("240x320"); 141 WidthHeightBox->insertItem("240x320");
141 WidthHeightBox->insertItem("640x480"); 142 WidthHeightBox->insertItem("640x480");
142 WidthHeightBox->insertItem("800x600"); 143 WidthHeightBox->insertItem("800x600");
143 connect(WidthHeightBox, SIGNAL(activated(int)), this, SLOT(ComboChanged(int))); 144 connect(WidthHeightBox, SIGNAL(activated(int)), this, SLOT(ComboChanged(int)));
144 WidthHeightBox->setCurrentItem(1); 145 WidthHeightBox->setCurrentItem(1);
145 WidthEdit = new QLineEdit(this); 146 WidthEdit = new QLineEdit(this);
146 WidthEdit->move(110, 210); 147 WidthEdit->move(110, 210);
147 WidthEdit->resize(30, 20); 148 WidthEdit->resize(30, 20);
148 WidthEdit->setText("800"); 149 WidthEdit->setText("800");
149 HeightEdit = new QLineEdit(this); 150 HeightEdit = new QLineEdit(this);
150 HeightEdit->move(140, 210); 151 HeightEdit->move(140, 210);
151 HeightEdit->resize(30, 20); 152 HeightEdit->resize(30, 20);
152 HeightEdit->setText("600"); 153 HeightEdit->setText("600");
153 // add to list button 154 // add to list button
154 AddButton = new QPushButton(this); 155 AddButton = new QPushButton(this);
155 AddButton->move(180, 120); 156 AddButton->move(180, 120);
156 AddButton->resize(50, 20); 157 AddButton->resize(50, 20);
157 AddButton->setText("Add"); 158 AddButton->setText("Add");
158 connect(AddButton, SIGNAL(clicked()), this, SLOT(AddClicked())); 159 connect(AddButton, SIGNAL(clicked()), this, SLOT(AddClicked()));
159 // change list item button 160 // change list item button
160 EditButton = new QPushButton(this); 161 EditButton = new QPushButton(this);
161 EditButton->move(180, 140); 162 EditButton->move(180, 140);
162 EditButton->resize(50, 20); 163 EditButton->resize(50, 20);
163 EditButton->setText("Edit"); 164 EditButton->setText("Edit");
164 connect(EditButton, SIGNAL(clicked()), this, SLOT(EditClicked())); 165 connect(EditButton, SIGNAL(clicked()), this, SLOT(EditClicked()));
165 // save to file button 166 // save to file button
166 SaveButton = new QPushButton(this); 167 SaveButton = new QPushButton(this);
167 SaveButton->move(180, 160); 168 SaveButton->move(180, 160);
168 SaveButton->resize(50, 20); 169 SaveButton->resize(50, 20);
169 SaveButton->setText("Save"); 170 SaveButton->setText("Save");
170 connect(SaveButton, SIGNAL(clicked()), this, SLOT(SaveClicked())); 171 connect(SaveButton, SIGNAL(clicked()), this, SLOT(SaveClicked()));
171 // remove an item button 172 // remove an item button
172 RemoveButton = new QPushButton(this); 173 RemoveButton = new QPushButton(this);
173 RemoveButton->move(180, 180); 174 RemoveButton->move(180, 180);
174 RemoveButton->resize(50, 20); 175 RemoveButton->resize(50, 20);
175 RemoveButton->setText("Remove"); 176 RemoveButton->setText("Remove");
176 connect(RemoveButton, SIGNAL(clicked()), this, SLOT(RemoveClicked())); 177 connect(RemoveButton, SIGNAL(clicked()), this, SLOT(RemoveClicked()));
177 // full screen check box 178 // full screen check box
178 FullScreenCheckBox = new QCheckBox(this, "Full Screen"); 179 FullScreenCheckBox = new QCheckBox(this, "Full Screen");
179 FullScreenCheckBox->setText("Full Screen"); 180 FullScreenCheckBox->setText("Full Screen");
180 FullScreenCheckBox->move(10, 230); 181 FullScreenCheckBox->move(10, 230);
181 // ok button 182 // ok button
182 OKButton = new QPushButton(this); 183 OKButton = new QPushButton(this);
183 OKButton->setText("OK"); 184 OKButton->setText("OK");
184 OKButton->move(100, 240); 185 OKButton->move(100, 240);
185 OKButton->resize(50, 20); 186 OKButton->resize(50, 20);
186 connect(OKButton, SIGNAL(clicked()), this, SLOT(OKClicked())); 187 connect(OKButton, SIGNAL(clicked()), this, SLOT(OKClicked()));
187 // cancel button 188 // cancel button
188 CancelButton = new QPushButton(this); 189 CancelButton = new QPushButton(this);
189 CancelButton->setText("Cancel"); 190 CancelButton->setText("Cancel");
190 CancelButton->move(160, 240); 191 CancelButton->move(160, 240);
191 CancelButton->resize(50, 20); 192 CancelButton->resize(50, 20);
192 connect(CancelButton, SIGNAL(clicked()), this, SLOT(CancelClicked())); 193 connect(CancelButton, SIGNAL(clicked()), this, SLOT(CancelClicked()));
193 194
194 for (i = 0; i < 10; i++) 195 for (i = 0; i < 10; i++)
195 { 196 {
196 ConnectionList[i] = new QMyConnectionItem; 197 ConnectionList[i] = new QMyConnectionItem;
197 ConnectionList[i]->ServerName = ""; 198 ConnectionList[i]->ServerName = "";
198 ConnectionList[i]->UserName = ""; 199 ConnectionList[i]->UserName = "";
199 ConnectionList[i]->ServerIP = ""; 200 ConnectionList[i]->ServerIP = "";
200 ConnectionList[i]->Width = 0; 201 ConnectionList[i]->Width = 0;
201 ConnectionList[i]->Height = 0; 202 ConnectionList[i]->Height = 0;
202 ConnectionList[i]->FullScreen = 0; 203 ConnectionList[i]->FullScreen = 0;
203 } 204 }
204 home = getenv("HOME"); 205 home = getenv("HOME");
205 if (home != NULL) 206 if (home != NULL)
206 { 207 {
207 sprintf(Text, "%s/rdesktop.ini", home); 208 sprintf(Text, "%s/rdesktop.ini", home);
208 QFile* File = new QFile(Text); 209 QFile* File = new QFile(Text);
209 if (File->open(IO_ReadOnly)) 210 if (File->open(IO_ReadOnly))
210 { 211 {
211 i = -1; 212 i = -1;
212 while (!File->atEnd()) 213 while (!File->atEnd())
213 { 214 {
214 File->readLine(Line, 255); 215 File->readLine(Line, 255);
215 j = Line.find("="); 216 j = Line.find("=");
216 if (j > 0) 217 if (j > 0)
217 { 218 {
218 ItemName = Line.mid(0, j); 219 ItemName = Line.mid(0, j);
219 CleanString(&ItemName); 220 CleanString(&ItemName);
220 ItemValue = Line.mid(j + 1); 221 ItemValue = Line.mid(j + 1);
221 CleanString(&ItemValue); 222 CleanString(&ItemValue);
222 if (ItemName == "Server") 223 if (ItemName == "Server")
223 { 224 {
224 i++; 225 i++;
225 ConnectionList[i]->ServerName = ItemValue; 226 ConnectionList[i]->ServerName = ItemValue;
226 ListBox->insertItem(ItemValue); 227 ListBox->insertItem(ItemValue);
227 } 228 }
228 else if (ItemName == "UserName") 229 else if (ItemName == "UserName")
229 ConnectionList[i]->UserName = ItemValue; 230 ConnectionList[i]->UserName = ItemValue;
230 else if (ItemName == "Width") 231 else if (ItemName == "Width")
231 ConnectionList[i]->Width = ItemValue.toInt(); 232 ConnectionList[i]->Width = ItemValue.toInt();
232 else if (ItemName == "Height") 233 else if (ItemName == "Height")
233 ConnectionList[i]->Height = ItemValue.toInt(); 234 ConnectionList[i]->Height = ItemValue.toInt();
234 else if (ItemName == "IP") 235 else if (ItemName == "IP")
235 ConnectionList[i]->ServerIP = ItemValue; 236 ConnectionList[i]->ServerIP = ItemValue;
236 else if (ItemName == "FullScreen") 237 else if (ItemName == "FullScreen")
237 ConnectionList[i]->FullScreen = (ItemValue != "0"); 238 ConnectionList[i]->FullScreen = (ItemValue != "0");
238 } 239 }
239 } 240 }
240 } 241 }
241 delete File; 242 delete File;
242 } 243 }
243} 244}
244 245
245//***************************************************************************** 246//*****************************************************************************
246QMyDialog::~QMyDialog() 247QMyDialog::~QMyDialog()
247{ 248{
248 QMyConnectionItem* Item; 249 QMyConnectionItem* Item;
249 int i; 250 int i;
250 251
251 for (i = 0; i < 10; i++) 252 for (i = 0; i < 10; i++)
252 { 253 {
253 Item = ConnectionList[i]; 254 Item = ConnectionList[i];
254 delete Item; 255 delete Item;
255 } 256 }
256} 257}
257 258
258//***************************************************************************** 259//*****************************************************************************
259void QMyDialog::ComboChanged(int index) 260void QMyDialog::ComboChanged(int index)
260{ 261{
261 if (index == 0) 262 if (index == 0)
262 { 263 {
263 WidthEdit->setText("240"); 264 WidthEdit->setText("240");
264 HeightEdit->setText("320"); 265 HeightEdit->setText("320");
265 } 266 }
266 if (index == 1) 267 if (index == 1)
267 { 268 {
268 WidthEdit->setText("640"); 269 WidthEdit->setText("640");
269 HeightEdit->setText("480"); 270 HeightEdit->setText("480");
270 } 271 }
271 else if (index == 2) 272 else if (index == 2)
272 { 273 {
273 WidthEdit->setText("800"); 274 WidthEdit->setText("800");
274 HeightEdit->setText("600"); 275 HeightEdit->setText("600");
275 } 276 }
276} 277}
277 278
278//***************************************************************************** 279//*****************************************************************************
279void QMyDialog::OKClicked() 280void QMyDialog::OKClicked()
280{ 281{
281 ServerName = ServerNameEdit->text(); 282 ServerName = ServerNameEdit->text();
282 UserName = UserNameEdit->text(); 283 UserName = UserNameEdit->text();
283 Width = WidthEdit->text().toInt(); 284 Width = WidthEdit->text().toInt();
284 Height = HeightEdit->text().toInt(); 285 Height = HeightEdit->text().toInt();
285 ServerIP = IPEdit->text(); 286 ServerIP = IPEdit->text();
286 FullScreen = FullScreenCheckBox->isChecked(); 287 FullScreen = FullScreenCheckBox->isChecked();
287 done(1); 288 done(1);
288} 289}
289 290
290//***************************************************************************** 291//*****************************************************************************
291void QMyDialog::CancelClicked() 292void QMyDialog::CancelClicked()
292{ 293{
293 done(0); 294 done(0);
294} 295}
295 296
296//***************************************************************************** 297//*****************************************************************************
297void QMyDialog::AddClicked() 298void QMyDialog::AddClicked()
298{ 299{
299 int i; 300 int i;
300 QMyConnectionItem* Item; 301 QMyConnectionItem* Item;
301 302
302 i = ListBox->count(); 303 i = ListBox->count();
303 if (i < 10) 304 if (i < 10)
304 { 305 {
305 ListBox->insertItem(ServerNameEdit->text()); 306 ListBox->insertItem(ServerNameEdit->text());
306 Item = ConnectionList[i]; 307 Item = ConnectionList[i];
307 Item->ServerName = ServerNameEdit->text(); 308 Item->ServerName = ServerNameEdit->text();
308 Item->UserName = UserNameEdit->text(); 309 Item->UserName = UserNameEdit->text();
309 Item->Width = WidthEdit->text().toInt(); 310 Item->Width = WidthEdit->text().toInt();
310 Item->Height = HeightEdit->text().toInt(); 311 Item->Height = HeightEdit->text().toInt();
311 Item->ServerIP = IPEdit->text(); 312 Item->ServerIP = IPEdit->text();
312 Item->FullScreen = FullScreenCheckBox->isChecked(); 313 Item->FullScreen = FullScreenCheckBox->isChecked();
313 } 314 }
314} 315}
315 316
316//***************************************************************************** 317//*****************************************************************************
317void QMyDialog::EditClicked() 318void QMyDialog::EditClicked()
318{ 319{
319 int i; 320 int i;
320 QMyConnectionItem* Item; 321 QMyConnectionItem* Item;
321 322
322 i = ListBox->currentItem(); 323 i = ListBox->currentItem();
323 if (i >= 0) 324 if (i >= 0)
324 { 325 {
325 Item = ConnectionList[i]; 326 Item = ConnectionList[i];
326 Item->ServerName = ServerNameEdit->text(); 327 Item->ServerName = ServerNameEdit->text();
327 Item->UserName = UserNameEdit->text(); 328 Item->UserName = UserNameEdit->text();
328 Item->Width = WidthEdit->text().toInt(); 329 Item->Width = WidthEdit->text().toInt();
329 Item->Height = HeightEdit->text().toInt(); 330 Item->Height = HeightEdit->text().toInt();
330 Item->ServerIP = IPEdit->text(); 331 Item->ServerIP = IPEdit->text();
331 Item->FullScreen = FullScreenCheckBox->isChecked(); 332 Item->FullScreen = FullScreenCheckBox->isChecked();
332 ListBox->changeItem(ServerNameEdit->text(), i); 333 ListBox->changeItem(ServerNameEdit->text(), i);
333 } 334 }
334} 335}
335 336
336//***************************************************************************** 337//*****************************************************************************
337void WriteString(QFile* File, QString* Line) 338void WriteString(QFile* File, QString* Line)
338{ 339{
339 File->writeBlock((const char*)(*Line), Line->length()); 340 File->writeBlock((const char*)(*Line), Line->length());
340} 341}
341 342
342//***************************************************************************** 343//*****************************************************************************
343void QMyDialog::SaveClicked() 344void QMyDialog::SaveClicked()
344{ 345{
345 int i, j; 346 int i, j;
346 QMyConnectionItem* Item; 347 QMyConnectionItem* Item;
347 QString Line; 348 QString Line;
348 char* home; 349 char* home;
349 char Text[256]; 350 char Text[256];
350 QFile* File; 351 QFile* File;
351 352
352 home = getenv("HOME"); 353 home = getenv("HOME");
353 if (home != NULL) 354 if (home != NULL)
354 { 355 {
355 sprintf(Text, "%s/rdesktop.ini", home); 356 sprintf(Text, "%s/rdesktop.ini", home);
356 File = new QFile(Text); 357 File = new QFile(Text);
357 if (File->open(IO_Truncate | IO_ReadWrite)) 358 if (File->open(IO_Truncate | IO_ReadWrite))
358 { 359 {
359 i = ListBox->count(); 360 i = ListBox->count();
360 for (j = 0; j < i; j++) 361 for (j = 0; j < i; j++)
361 { 362 {
362 Item = ConnectionList[j]; 363 Item = ConnectionList[j];
363 Line = "Server="; 364 Line = "Server=";
364 Line += Item->ServerName; 365 Line += Item->ServerName;
365 Line += (char)10; 366 Line += (char)10;
366 WriteString(File, &Line); 367 WriteString(File, &Line);
367 Line = "UserName="; 368 Line = "UserName=";
368 Line += Item->UserName; 369 Line += Item->UserName;
369 Line += (char)10; 370 Line += (char)10;
370 WriteString(File, &Line); 371 WriteString(File, &Line);
371 Line = "Width="; 372 Line = "Width=";
372 sprintf(Text, "%d", Item->Width); 373 sprintf(Text, "%d", Item->Width);
373 Line += Text; 374 Line += Text;
374 Line += (char)10; 375 Line += (char)10;
375 WriteString(File, &Line); 376 WriteString(File, &Line);
376 Line = "Height="; 377 Line = "Height=";
377 sprintf(Text, "%d", Item->Height); 378 sprintf(Text, "%d", Item->Height);
378 Line += Text; 379 Line += Text;
379 Line += (char)10; 380 Line += (char)10;
380 WriteString(File, &Line); 381 WriteString(File, &Line);
381 Line = "IP="; 382 Line = "IP=";
382 Line += Item->ServerIP; 383 Line += Item->ServerIP;
383 Line += (char)10; 384 Line += (char)10;
384 WriteString(File, &Line); 385 WriteString(File, &Line);
385 Line = "FullScreen="; 386 Line = "FullScreen=";
386 if (Item->FullScreen) 387 if (Item->FullScreen)
387 Line += "1"; 388 Line += "1";
388 else 389 else
389 Line += "0"; 390 Line += "0";
390 Line += (char)10; 391 Line += (char)10;
391 WriteString(File, &Line); 392 WriteString(File, &Line);
392 } 393 }
393 } 394 }
394 File->flush(); 395 File->flush();
395 File->close(); 396 File->close();
396 delete File; 397 delete File;
397 } 398 }
398} 399}
399 400
400//***************************************************************************** 401//*****************************************************************************
401void QMyDialog::RemoveClicked() 402void QMyDialog::RemoveClicked()
402{ 403{
403 int i, j, c; 404 int i, j, c;
404 QMyConnectionItem* Item1; 405 QMyConnectionItem* Item1;
405 QMyConnectionItem* Item2; 406 QMyConnectionItem* Item2;
406 407
407 i = ListBox->currentItem(); 408 i = ListBox->currentItem();
408 if (i >= 0) 409 if (i >= 0)
409 { 410 {
410 c = ListBox->count(); 411 c = ListBox->count();
411 for (j = i; j < c - 1; j++) 412 for (j = i; j < c - 1; j++)
412 { 413 {
413 Item1 = ConnectionList[i]; 414 Item1 = ConnectionList[i];
414 Item2 = ConnectionList[i + 1]; 415 Item2 = ConnectionList[i + 1];
415 Item1->ServerName = Item2->ServerName; 416 Item1->ServerName = Item2->ServerName;
416 Item1->UserName = Item2->UserName; 417 Item1->UserName = Item2->UserName;
417 Item1->Width = Item2->Width; 418 Item1->Width = Item2->Width;
418 Item1->Height = Item2->Height; 419 Item1->Height = Item2->Height;
419 Item1->ServerIP = Item2->ServerIP; 420 Item1->ServerIP = Item2->ServerIP;
420 Item1->FullScreen = Item2->FullScreen; 421 Item1->FullScreen = Item2->FullScreen;
421 } 422 }
422 ListBox->removeItem(i); 423 ListBox->removeItem(i);
423 } 424 }
424} 425}
425 426
426//***************************************************************************** 427//*****************************************************************************
427void QMyDialog::ListBoxChanged() 428void QMyDialog::ListBoxChanged()
428{ 429{
429 int i; 430 int i;
430 QMyConnectionItem* Item; 431 QMyConnectionItem* Item;
431 char Text[100]; 432 char Text[100];
432 433
433 i = ListBox->currentItem(); 434 i = ListBox->currentItem();
434 if (i >= 0 && i < 10) 435 if (i >= 0 && i < 10)
435 { 436 {
436 Item = ConnectionList[i]; 437 Item = ConnectionList[i];
437 ServerNameEdit->setText(Item->ServerName); 438 ServerNameEdit->setText(Item->ServerName);
438 UserNameEdit->setText(Item->UserName); 439 UserNameEdit->setText(Item->UserName);
439 sprintf(Text, "%d", Item->Width); 440 sprintf(Text, "%d", Item->Width);
440 WidthEdit->setText(Text); 441 WidthEdit->setText(Text);
441 sprintf(Text, "%d", Item->Height); 442 sprintf(Text, "%d", Item->Height);
442 HeightEdit->setText(Text); 443 HeightEdit->setText(Text);
443 IPEdit->setText(Item->ServerIP); 444 IPEdit->setText(Item->ServerIP);
444 FullScreenCheckBox->setChecked(Item->FullScreen != 0); 445 FullScreenCheckBox->setChecked(Item->FullScreen != 0);
445 } 446 }
446} 447}
447 448
448//***************************************************************************** 449//*****************************************************************************
449void QMyDialog::ListBoxSelected(int /*index*/) 450void QMyDialog::ListBoxSelected(int /*index*/)
450{ 451{
451} 452}
452 453
453//***************************************************************************** 454//*****************************************************************************
454void GetScanCode(QKeyEvent* e, int* ScanCode, int* code) 455void GetScanCode(QKeyEvent* e, int* ScanCode, int* code)
455{ 456{
456 int key; 457 int key;
457 int mod; 458 int mod;
458 int ascii; 459 int ascii;
459 460
460 key = e->key(); 461 key = e->key();
461 mod = e->state(); 462 mod = e->state();
462 ascii = e->ascii(); 463 ascii = e->ascii();
463 464
464 *ScanCode = 0; 465 *ScanCode = 0;
465 *code = mod; // 8 shift, 16 control, 32 alt 466 *code = mod; // 8 shift, 16 control, 32 alt
466 467
467 switch (key) 468 switch (key)
468 { 469 {
469 case 4096: // esc 470 case 4096: // esc
470 case 4097: // tab 471 case 4097: // tab
471 case 4099: // backspace 472 case 4099: // backspace
472 case 4100: // enter 473 case 4100: // enter
473 case 4101: // enter 474 case 4101: // enter
474 case 4103: // delete 475 case 4103: // delete
475 ascii = 0; 476 ascii = 0;
476 } 477 }
477 478
478 if (ascii == 0) 479 if (ascii == 0)
479 { 480 {
480 switch (key) 481 switch (key)
481 { 482 {
482 case 4096: *ScanCode = 0x01; break; // esc 483 case 4096: *ScanCode = 0x01; break; // esc
483 case 4097: *ScanCode = 0x0f; break; // tab 484 case 4097: *ScanCode = 0x0f; break; // tab
484 case 4099: *ScanCode = 0x0e; break; // backspace 485 case 4099: *ScanCode = 0x0e; break; // backspace
485 case 4100: *ScanCode = 0x1c; break; // enter 486 case 4100: *ScanCode = 0x1c; break; // enter
486 case 4101: *ScanCode = 0x1c; break; // enter 487 case 4101: *ScanCode = 0x1c; break; // enter
487 case 4112: *ScanCode = 0xc7; break; // home 488 case 4112: *ScanCode = 0xc7; break; // home
488 case 4113: *ScanCode = 0xcf; break; // end 489 case 4113: *ScanCode = 0xcf; break; // end
489 case 4102: *ScanCode = 0xd2; break; // insert 490 case 4102: *ScanCode = 0xd2; break; // insert
490 case 4103: *ScanCode = 0xd3; break; // delete 491 case 4103: *ScanCode = 0xd3; break; // delete
491 case 4118: *ScanCode = 0xc9; break; // page up 492 case 4118: *ScanCode = 0xc9; break; // page up
492 case 4119: *ScanCode = 0xd1; break; // page down 493 case 4119: *ScanCode = 0xd1; break; // page down
493 case 4117: *ScanCode = 0xd0; break; // down arrow 494 case 4117: *ScanCode = 0xd0; break; // down arrow
494 case 4115: *ScanCode = 0xc8; break; // up arrow 495 case 4115: *ScanCode = 0xc8; break; // up arrow
495 case 4114: *ScanCode = 0xcb; break; // left arrow 496 case 4114: *ScanCode = 0xcb; break; // left arrow
496 case 4116: *ScanCode = 0xcd; break; // right arrow 497 case 4116: *ScanCode = 0xcd; break; // right arrow
497 case 4128: *ScanCode = 0x2a; break; // shift 498 case 4128: *ScanCode = 0x2a; break; // shift
498 case 4131: *ScanCode = 0x38; break; // alt 499 case 4131: *ScanCode = 0x38; break; // alt
499 case 4129: *ScanCode = 0x1d; break; // ctrl 500 case 4129: *ScanCode = 0x1d; break; // ctrl
500 } 501 }
501 if (*ScanCode != 0) 502 if (*ScanCode != 0)
502 return; 503 return;
503 } 504 }
504 505
505 switch (ascii) 506 switch (ascii)
506 { 507 {
507 // first row 508 // first row
508 case 'q': *ScanCode = 0x10; break; 509 case 'q': *ScanCode = 0x10; break;
509 case 'Q': *ScanCode = 0x10; *code |= 8; break; 510 case 'Q': *ScanCode = 0x10; *code |= 8; break;
510 case '1': *ScanCode = 0x02; break; 511 case '1': *ScanCode = 0x02; break;
511 case 'w': *ScanCode = 0x11; break; 512 case 'w': *ScanCode = 0x11; break;
512 case 'W': *ScanCode = 0x11; *code |= 8; break; 513 case 'W': *ScanCode = 0x11; *code |= 8; break;
513 case '2': *ScanCode = 0x03; break; 514 case '2': *ScanCode = 0x03; break;
514 case 'e': *ScanCode = 0x12; break; 515 case 'e': *ScanCode = 0x12; break;
515 case 'E': *ScanCode = 0x12; *code |= 8; break; 516 case 'E': *ScanCode = 0x12; *code |= 8; break;
516 case '3': *ScanCode = 0x04; break; 517 case '3': *ScanCode = 0x04; break;
517 case 'r': *ScanCode = 0x13; break; 518 case 'r': *ScanCode = 0x13; break;
518 case 'R': *ScanCode = 0x13; *code |= 8; break; 519 case 'R': *ScanCode = 0x13; *code |= 8; break;
519 case '4': *ScanCode = 0x05; break; 520 case '4': *ScanCode = 0x05; break;
520 case 't': *ScanCode = 0x14; break; 521 case 't': *ScanCode = 0x14; break;
521 case 'T': *ScanCode = 0x14; *code |= 8; break; 522 case 'T': *ScanCode = 0x14; *code |= 8; break;
522 case '5': *ScanCode = 0x06; break; 523 case '5': *ScanCode = 0x06; break;
523 case 'y': *ScanCode = 0x15; break; 524 case 'y': *ScanCode = 0x15; break;
524 case 'Y': *ScanCode = 0x15; *code |= 8; break; 525 case 'Y': *ScanCode = 0x15; *code |= 8; break;
525 case '6': *ScanCode = 0x07; break; 526 case '6': *ScanCode = 0x07; break;
526 case 'u': *ScanCode = 0x16; break; 527 case 'u': *ScanCode = 0x16; break;
527 case 'U': *ScanCode = 0x16; *code |= 8; break; 528 case 'U': *ScanCode = 0x16; *code |= 8; break;
528 case '7': *ScanCode = 0x08; break; 529 case '7': *ScanCode = 0x08; break;
529 case 'i': *ScanCode = 0x17; break; 530 case 'i': *ScanCode = 0x17; break;
530 case 'I': *ScanCode = 0x17; *code |= 8; break; 531 case 'I': *ScanCode = 0x17; *code |= 8; break;
531 case '8': *ScanCode = 0x09; break; 532 case '8': *ScanCode = 0x09; break;
532 case 'o': *ScanCode = 0x18; break; 533 case 'o': *ScanCode = 0x18; break;
533 case 'O': *ScanCode = 0x18; *code |= 8; break; 534 case 'O': *ScanCode = 0x18; *code |= 8; break;
534 case '9': *ScanCode = 0x0a; break; 535 case '9': *ScanCode = 0x0a; break;
535 case 'p': *ScanCode = 0x19; break; 536 case 'p': *ScanCode = 0x19; break;
536 case 'P': *ScanCode = 0x19; *code |= 8; break; 537 case 'P': *ScanCode = 0x19; *code |= 8; break;
537 case '0': *ScanCode = 0x0b; break; 538 case '0': *ScanCode = 0x0b; break;
538 // second row 539 // second row
539 case 'a': *ScanCode = 0x1e; break; 540 case 'a': *ScanCode = 0x1e; break;
540 case 'A': *ScanCode = 0x1e; *code |= 8; break; 541 case 'A': *ScanCode = 0x1e; *code |= 8; break;
541 case '!': *ScanCode = 0x02; *code |= 8; break; 542 case '!': *ScanCode = 0x02; *code |= 8; break;
542 case 's': *ScanCode = 0x1f; break; 543 case 's': *ScanCode = 0x1f; break;
543 case 'S': *ScanCode = 0x1f; *code |= 8; break; 544 case 'S': *ScanCode = 0x1f; *code |= 8; break;
544 case '@': *ScanCode = 0x03; *code |= 8; break; 545 case '@': *ScanCode = 0x03; *code |= 8; break;
545 case 'd': *ScanCode = 0x20; break; 546 case 'd': *ScanCode = 0x20; break;
546 case 'D': *ScanCode = 0x20; *code |= 8; break; 547 case 'D': *ScanCode = 0x20; *code |= 8; break;
547 case '#': *ScanCode = 0x04; *code |= 8; break; 548 case '#': *ScanCode = 0x04; *code |= 8; break;
548 case 'f': *ScanCode = 0x21; break; 549 case 'f': *ScanCode = 0x21; break;
549 case 'F': *ScanCode = 0x21; *code |= 8; break; 550 case 'F': *ScanCode = 0x21; *code |= 8; break;
550 case '$': *ScanCode = 0x05; *code |= 8; break; 551 case '$': *ScanCode = 0x05; *code |= 8; break;
551 case 'g': *ScanCode = 0x22; break; 552 case 'g': *ScanCode = 0x22; break;
552 case 'G': *ScanCode = 0x22; *code |= 8; break; 553 case 'G': *ScanCode = 0x22; *code |= 8; break;
553 case '%': *ScanCode = 0x06; *code |= 8; break; 554 case '%': *ScanCode = 0x06; *code |= 8; break;
554 case 'h': *ScanCode = 0x23; break; 555 case 'h': *ScanCode = 0x23; break;
555 case 'H': *ScanCode = 0x23; *code |= 8; break; 556 case 'H': *ScanCode = 0x23; *code |= 8; break;
556 case '_': *ScanCode = 0x0c; *code |= 8; break; 557 case '_': *ScanCode = 0x0c; *code |= 8; break;
557 case 'j': *ScanCode = 0x24; break; 558 case 'j': *ScanCode = 0x24; break;
558 case 'J': *ScanCode = 0x24; *code |= 8; break; 559 case 'J': *ScanCode = 0x24; *code |= 8; break;
559 case '&': *ScanCode = 0x08; *code |= 8; break; 560 case '&': *ScanCode = 0x08; *code |= 8; break;
560 case 'k': *ScanCode = 0x25; break; 561 case 'k': *ScanCode = 0x25; break;
561 case 'K': *ScanCode = 0x25; *code |= 8; break; 562 case 'K': *ScanCode = 0x25; *code |= 8; break;
562 case '*': *ScanCode = 0x09; *code |= 8; break; 563 case '*': *ScanCode = 0x09; *code |= 8; break;
563 case 'l': *ScanCode = 0x26; break; 564 case 'l': *ScanCode = 0x26; break;
564 case 'L': *ScanCode = 0x26; *code |= 8; break; 565 case 'L': *ScanCode = 0x26; *code |= 8; break;
565 case '(': *ScanCode = 0x0a; *code |= 8; break; 566 case '(': *ScanCode = 0x0a; *code |= 8; break;
566// case 8: *ScanCode = 0x0e; break; // backspace 567// case 8: *ScanCode = 0x0e; break; // backspace
567 // third row 568 // third row
568 case 'z': *ScanCode = 0x2c; break; 569 case 'z': *ScanCode = 0x2c; break;
569 case 'Z': *ScanCode = 0x2c; *code |= 8; break; 570 case 'Z': *ScanCode = 0x2c; *code |= 8; break;
570 case 'x': *ScanCode = 0x2d; break; 571 case 'x': *ScanCode = 0x2d; break;
571 case 'X': *ScanCode = 0x2d; *code |= 8; break; 572 case 'X': *ScanCode = 0x2d; *code |= 8; break;
572 case 'c': *ScanCode = 0x2e; break; 573 case 'c': *ScanCode = 0x2e; break;
573 case 'C': *ScanCode = 0x2e; *code |= 8; break; 574 case 'C': *ScanCode = 0x2e; *code |= 8; break;
574 case 'v': *ScanCode = 0x2f; break; 575 case 'v': *ScanCode = 0x2f; break;
575 case 'V': *ScanCode = 0x2f; *code |= 8; break; 576 case 'V': *ScanCode = 0x2f; *code |= 8; break;
576 case 'b': *ScanCode = 0x30; break; 577 case 'b': *ScanCode = 0x30; break;
577 case 'B': *ScanCode = 0x30; *code |= 8; break; 578 case 'B': *ScanCode = 0x30; *code |= 8; break;
578 case '-': *ScanCode = 0x0c; break; 579 case '-': *ScanCode = 0x0c; break;
579 case 'n': *ScanCode = 0x31; break; 580 case 'n': *ScanCode = 0x31; break;
580 case 'N': *ScanCode = 0x31; *code |= 8; break; 581 case 'N': *ScanCode = 0x31; *code |= 8; break;
581 case '+': *ScanCode = 0x0d; *code |= 8; break; 582 case '+': *ScanCode = 0x0d; *code |= 8; break;
582 case 'm': *ScanCode = 0x32; break; 583 case 'm': *ScanCode = 0x32; break;
583 case 'M': *ScanCode = 0x32; *code |= 8; break; 584 case 'M': *ScanCode = 0x32; *code |= 8; break;
584 case '=': *ScanCode = 0x0d; break; 585 case '=': *ScanCode = 0x0d; break;
585 case ',': *ScanCode = 0x33; break; 586 case ',': *ScanCode = 0x33; break;
586 case ';': *ScanCode = 0x27; break; 587 case ';': *ScanCode = 0x27; break;
587 case ')': *ScanCode = 0x0b; *code |= 8; break; 588 case ')': *ScanCode = 0x0b; *code |= 8; break;
588 // fourth row 589 // fourth row
589// case 9: *ScanCode = 0x0f; break; // tab 590// case 9: *ScanCode = 0x0f; break; // tab
590 case '/': *ScanCode = 0x35; break; 591 case '/': *ScanCode = 0x35; break;
591 case '?': *ScanCode = 0x35; *code |= 8; break; 592 case '?': *ScanCode = 0x35; *code |= 8; break;
592 case ' ': *ScanCode = 0x39; break; 593 case ' ': *ScanCode = 0x39; break;
593 case '\'': *ScanCode = 0x28; break; 594 case '\'': *ScanCode = 0x28; break;
594 case '"': *ScanCode = 0x28; *code |= 8; break; 595 case '"': *ScanCode = 0x28; *code |= 8; break;
595 case '~': *ScanCode = 0x29; *code |= 8; break; 596 case '~': *ScanCode = 0x29; *code |= 8; break;
596 case '.': *ScanCode = 0x34; break; 597 case '.': *ScanCode = 0x34; break;
597 case ':': *ScanCode = 0x27; *code |= 8; break; 598 case ':': *ScanCode = 0x27; *code |= 8; break;
598 case '<': *ScanCode = 0x33; *code |= 8; break; 599 case '<': *ScanCode = 0x33; *code |= 8; break;
599// case 13: *ScanCode = 0x1c; break; // enter 600// case 13: *ScanCode = 0x1c; break; // enter
600 case '>': *ScanCode = 0x34; *code |= 8; break; 601 case '>': *ScanCode = 0x34; *code |= 8; break;
601 // others 602 // others
602// case 27: *ScanCode = 0x01; break; // esc 603// case 27: *ScanCode = 0x01; break; // esc
603 case '`': *ScanCode = 0x29; break; 604 case '`': *ScanCode = 0x29; break;
604 case '^': *ScanCode = 0x07; *code |= 8; break; 605 case '^': *ScanCode = 0x07; *code |= 8; break;
605 case '[': *ScanCode = 0x1a; break; 606 case '[': *ScanCode = 0x1a; break;
606 case '{': *ScanCode = 0x1a; *code |= 8; break; 607 case '{': *ScanCode = 0x1a; *code |= 8; break;
607 case ']': *ScanCode = 0x1b; break; 608 case ']': *ScanCode = 0x1b; break;
608 case '}': *ScanCode = 0x1b; *code |= 8; break; 609 case '}': *ScanCode = 0x1b; *code |= 8; break;
609 case '\\': *ScanCode = 0x2b; break; 610 case '\\': *ScanCode = 0x2b; break;
610 case '|': *ScanCode = 0x2b; *code |= 8; break; 611 case '|': *ScanCode = 0x2b; *code |= 8; break;
611 // ctrl keys 612 // ctrl keys
612 case 1: *ScanCode = 0x1e; *code |= 16; break; // a 613 case 1: *ScanCode = 0x1e; *code |= 16; break; // a
613 case 2: *ScanCode = 0x30; *code |= 16; break; // b 614 case 2: *ScanCode = 0x30; *code |= 16; break; // b
614 } 615 }
615 616
616 if (*ScanCode == 0 && key < 3000) 617 if (*ScanCode == 0 && key < 3000)
617 printf("unknown key %d mod %d ascii %d\n", key, mod, ascii); 618 printf("unknown key %d mod %d ascii %d\n", key, mod, ascii);
618 619
619} 620}
620 621
621//***************************************************************************** 622//*****************************************************************************
622QMyScrollView::QMyScrollView() : QScrollView() 623QMyScrollView::QMyScrollView() : QScrollView()
623{ 624{
624} 625}
625 626
626//***************************************************************************** 627//*****************************************************************************
627QMyScrollView::~QMyScrollView() 628QMyScrollView::~QMyScrollView()
628{ 629{
629} 630}
630 631
631//***************************************************************************** 632//*****************************************************************************
632void QMyScrollView::keyPressEvent(QKeyEvent* e) 633void QMyScrollView::keyPressEvent(QKeyEvent* e)
633{ 634{
634 int ScanCode, code; 635 int ScanCode, code;
635 GetScanCode(e, &ScanCode, &code); 636 GetScanCode(e, &ScanCode, &code);
636 if (ScanCode != 0) 637 if (ScanCode != 0)
637 { 638 {
638 if (code & 8) // send shift 639 if (code & 8) // send shift
639 rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0x2a, 0); 640 rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0x2a, 0);
640 if (code & 16) // send control 641 if (code & 16) // send control
641 rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0x1d, 0); 642 rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0x1d, 0);
642 if (code & 32) // send alt 643 if (code & 32) // send alt
643 rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0x38, 0); 644 rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYPRESS, 0x38, 0);
644 rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYPRESS, ScanCode, 0); 645 rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYPRESS, ScanCode, 0);
645 e->accept(); 646 e->accept();
646 } 647 }
647} 648}
648 649
649//***************************************************************************** 650//*****************************************************************************
650void QMyScrollView::keyReleaseEvent(QKeyEvent* e) 651void QMyScrollView::keyReleaseEvent(QKeyEvent* e)
651{ 652{
652 int ScanCode, code; 653 int ScanCode, code;
653 GetScanCode(e, &ScanCode, &code); 654 GetScanCode(e, &ScanCode, &code);
654 if (ScanCode != 0) 655 if (ScanCode != 0)
655 { 656 {
656 rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, ScanCode, 0); 657 rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, ScanCode, 0);
657 if (code & 8) // send shift 658 if (code & 8) // send shift
658 rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, 0x2a, 0); 659 rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, 0x2a, 0);
659 if (code & 16) // send control 660 if (code & 16) // send control
660 rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, 0x1d, 0); 661 rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, 0x1d, 0);
661 if (code & 32) // send alt 662 if (code & 32) // send alt
662 rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, 0x38, 0); 663 rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, 0x38, 0);
663 e->accept(); 664 e->accept();
664 } 665 }
665} 666}
666 667
667//***************************************************************************** 668//*****************************************************************************
668void QMyScrollView::showEvent(QShowEvent* e) 669void QMyScrollView::showEvent(QShowEvent* e)
669{ 670{
670 QScrollView::showEvent(e); 671 QScrollView::showEvent(e);
671} 672}
672 673
673//***************************************************************************** 674//*****************************************************************************
674void QMyScrollView::show() 675void QMyScrollView::show()
675{ 676{
676 QScrollView::show(); 677 QScrollView::show();
677} 678}
678 679
679//***************************************************************************** 680//*****************************************************************************
680void QMyScrollView::polish() 681void QMyScrollView::polish()
681{ 682{
682 QScrollView::polish(); 683 QScrollView::polish();
683} 684}
684 685
685//***************************************************************************** 686//*****************************************************************************
686void QMyScrollView::timerEvent(QTimerEvent* e) 687void QMyScrollView::timerEvent(QTimerEvent* e)
687{ 688{
688 QScrollView::timerEvent(e); 689 QScrollView::timerEvent(e);
689 killTimer(timer_id); 690 killTimer(timer_id);
690 QMyDialog* d; 691 QMyDialog* d;
691 QWidget* Desktop; 692 QWidget* Desktop;
692 int dw; 693 int dw;
693 int dh; 694 int dh;
694 695
695 d = new QMyDialog(this); 696 d = new QMyDialog(this);
696 if (d->exec() == 1) // ok clicked 697 if (d->exec() == 1) // ok clicked
697 { 698 {
698 flags = RDP_LOGON_NORMAL; 699 flags = RDP_LOGON_NORMAL;
699 g_width = d->Width; 700 g_width = d->Width;
700 g_height = d->Height; 701 g_height = d->Height;
701 fullscreen = d->FullScreen; 702 fullscreen = d->FullScreen;
702 sprintf(server, "%s", (const char*)d->ServerIP); 703 sprintf(server, "%s", (const char*)d->ServerIP);
703 sprintf(username, "%s", (const char*)d->UserName); 704 sprintf(username, "%s", (const char*)d->UserName);
704 if (!rdp_connect(server, flags, domain, password, shell, directory)) 705 if (!rdp_connect(server, flags, domain, password, shell, directory))
705 { 706 {
706 delete d; 707 delete d;
707 SV->close(); 708 SV->close();
708 return; 709 return;
709 } 710 }
710 BS = (uint8*)xmalloc(g_width * g_height); 711 BS = (uint8*)xmalloc(g_width * g_height);
711 memset(BS, 0, g_width * g_height); 712 memset(BS, 0, g_width * g_height);
712 clipx = 0; 713 clipx = 0;
713 clipy = 0; 714 clipy = 0;
714 clipcx = g_width; 715 clipcx = g_width;
715 clipcy = g_height; 716 clipcy = g_height;
716 CM = (QColorMap*)xmalloc(sizeof(struct QColorMap)); 717 CM = (QColorMap*)xmalloc(sizeof(struct QColorMap));
717 memset(CM, 0, sizeof(struct QColorMap)); 718 memset(CM, 0, sizeof(struct QColorMap));
718 CM->NumColors = 256; 719 CM->NumColors = 256;
719 MW = new QMyMainWindow(); 720 MW = new QMyMainWindow();
720 MW->resize(g_width, g_height); 721 MW->resize(g_width, g_height);
721 MW->show(); 722 MW->show();
722 SV->addChild(MW); 723 SV->addChild(MW);
723 MW->setMouseTracking(true); 724 MW->setMouseTracking(true);
724 SocketNotifier = new QSocketNotifier(global_sock, QSocketNotifier::Read, MW); 725 SocketNotifier = new QSocketNotifier(global_sock, QSocketNotifier::Read, MW);
725 MW->connect(SocketNotifier, SIGNAL(activated(int)), MW, SLOT(dataReceived())); 726 MW->connect(SocketNotifier, SIGNAL(activated(int)), MW, SLOT(dataReceived()));
726 if (fullscreen) 727 if (fullscreen)
727 { 728 {
728 Desktop = App->desktop(); 729 Desktop = App->desktop();
729 dw = Desktop->width(); 730 dw = Desktop->width();
730 dh = Desktop->height(); 731 dh = Desktop->height();
731 if (dw == g_width && dh == g_height) 732 if (dw == g_width && dh == g_height)
732 MW->resize(g_width - 4, g_height - 4); 733 MW->resize(g_width - 4, g_height - 4);
733 SV->showFullScreen(); 734 SV->showFullScreen();
734 } 735 }
735 delete d; 736 delete d;
736 } 737 }
737 else // cancel clicked 738 else // cancel clicked
738 { 739 {
739 delete d; 740 delete d;
740 SV->close(); 741 SV->close();
741 } 742 }
742} 743}
743 744
744//***************************************************************************** 745//*****************************************************************************
745QMyMainWindow::QMyMainWindow() : QWidget(SV->viewport()) 746QMyMainWindow::QMyMainWindow() : QWidget(SV->viewport())
746{ 747{
747 PopupMenu = new QPopupMenu(this); 748 PopupMenu = new QPopupMenu(this);
748 PopupMenu->insertItem("Right click", 1, 0); 749 PopupMenu->insertItem("Right click", 1, 0);
749 PopupMenu->insertItem("Toggle fullscreen", 2, 1); 750 PopupMenu->insertItem("Toggle fullscreen", 2, 1);
750 PopupMenu->insertItem("Reset keyboard", 3, 2); 751 PopupMenu->insertItem("Reset keyboard", 3, 2);
751 PopupMenu->insertItem("Double click", 4, 3); 752 PopupMenu->insertItem("Double click", 4, 3);
752 connect(PopupMenu, SIGNAL(activated(int)), this, SLOT(MemuClicked(int))); 753 connect(PopupMenu, SIGNAL(activated(int)), this, SLOT(MemuClicked(int)));
753} 754}
754 755
755//***************************************************************************** 756//*****************************************************************************
756QMyMainWindow::~QMyMainWindow() 757QMyMainWindow::~QMyMainWindow()
757{ 758{
758 delete PopupMenu; 759 delete PopupMenu;
759} 760}
760 761
761//***************************************************************************** 762//*****************************************************************************
762void QMyMainWindow::timerEvent(QTimerEvent* e) 763void QMyMainWindow::timerEvent(QTimerEvent* e)
763{ 764{
764 QWidget::timerEvent(e); 765 QWidget::timerEvent(e);
765 if (e->timerId() == timer_id) 766 if (e->timerId() == timer_id)
766 { 767 {
767 // send mouse up 768 // send mouse up
768 rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1, mx, my); 769 rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1, mx, my);
769 // if in fullscreen, take it out or the menu won't work 770 // if in fullscreen, take it out or the menu won't work
770 if (fullscreen) 771 if (fullscreen)
771 { 772 {
772 fullscreen = 0; 773 fullscreen = 0;
773 SV->showNormal(); 774 SV->showNormal();
774 SV->showMaximized(); 775 SV->showMaximized();
775 } 776 }
776 else 777 else
777 PopupMenu->popup(mapToGlobal(QPoint(mx, my))); 778 PopupMenu->popup(mapToGlobal(QPoint(mx, my)));
778 } 779 }
779 killTimer(timer_id); 780 killTimer(timer_id);
780} 781}
781 782
782//***************************************************************************** 783//*****************************************************************************
783void QMyMainWindow::MemuClicked(int MenuID) 784void QMyMainWindow::MemuClicked(int MenuID)
784{ 785{
785 QWidget* Desktop; 786 QWidget* Desktop;
786 int dw; 787 int dw;
787 int dh; 788 int dh;
788 789
789 if (MenuID == 1) // right click 790 if (MenuID == 1) // right click
790 { 791 {
791 rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON2, mx, my); 792 rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON2, mx, my);
792 rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON2, mx, my); 793 rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON2, mx, my);
793 } 794 }
794 else if (MenuID == 2) // toggle full screen 795 else if (MenuID == 2) // toggle full screen
795 { 796 {
796 fullscreen = ~fullscreen; 797 fullscreen = ~fullscreen;
797 if (fullscreen) 798 if (fullscreen)
798 { 799 {
799 Desktop = App->desktop(); 800 Desktop = App->desktop();
800 dw = Desktop->width(); 801 dw = Desktop->width();
801 dh = Desktop->height(); 802 dh = Desktop->height();
802 if (dw == g_width && dh == g_height) 803 if (dw == g_width && dh == g_height)
803 MW->resize(g_width - 4, g_height - 4); 804 MW->resize(g_width - 4, g_height - 4);
804 SV->showFullScreen(); 805 SV->showFullScreen();
805 } 806 }
806 else 807 else
807 { 808 {
808 SV->showNormal(); 809 SV->showNormal();
809 SV->showMaximized(); 810 SV->showMaximized();
810 MW->resize(g_width, g_height); 811 MW->resize(g_width, g_height);
811 } 812 }
812 } 813 }
813 else if (MenuID == 3) // reset keyboard 814 else if (MenuID == 3) // reset keyboard
814 { 815 {
815 rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, 0x2a, 0); // shift 816 rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, 0x2a, 0); // shift
816 rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, 0x1d, 0); // control 817 rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, 0x1d, 0); // control
817 rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, 0x38, 0); // alt 818 rdp_send_input(0, RDP_INPUT_SCANCODE, RDP_KEYRELEASE, 0x38, 0); // alt
818 } 819 }
819 else if (MenuID == 4) // double click 820 else if (MenuID == 4) // double click
820 { 821 {
821 rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON1, mx, my); 822 rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON1, mx, my);
822 rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1, mx, my); 823 rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1, mx, my);
823 rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON1, mx, my); 824 rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON1, mx, my);
824 rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1, mx, my); 825 rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1, mx, my);
825 } 826 }
826} 827}
827 828
828//***************************************************************************** 829//*****************************************************************************
829void QMyMainWindow::mouseMoveEvent(QMouseEvent* e) 830void QMyMainWindow::mouseMoveEvent(QMouseEvent* e)
830{ 831{
831 int x; 832 int x;
832 int y; 833 int y;
833 834
834 x = e->x(); 835 x = e->x();
835 y = e->y(); 836 y = e->y();
836 837
837 if (timer_id) 838 if (timer_id)
838 { 839 {
839 x = x - mx; 840 x = x - mx;
840 y = y - my; 841 y = y - my;
841 if (x < -10 || x > 10 || y < -10 || y > 10) 842 if (x < -10 || x > 10 || y < -10 || y > 10)
842 { 843 {
843 killTimer(timer_id); 844 killTimer(timer_id);
844 timer_id = 0; 845 timer_id = 0;
845 } 846 }
846 } 847 }
847 rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_MOVE, e->x(), e->y()); 848 rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_MOVE, e->x(), e->y());
848} 849}
849 850
850//***************************************************************************** 851//*****************************************************************************
851void QMyMainWindow::mousePressEvent(QMouseEvent* e) 852void QMyMainWindow::mousePressEvent(QMouseEvent* e)
852{ 853{
853 timer_id = startTimer(1000); 854 timer_id = startTimer(1000);
854 mx = e->x(); 855 mx = e->x();
855 my = e->y(); 856 my = e->y();
856 if (e->button() == LeftButton) 857 if (e->button() == LeftButton)
857 rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON1, e->x(), e->y()); 858 rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON1, e->x(), e->y());
858 else if (e->button() == RightButton) 859 else if (e->button() == RightButton)
859 rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON2, e->x(), e->y()); 860 rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON2, e->x(), e->y());
860 else if (e->button() == MidButton) 861 else if (e->button() == MidButton)
861 rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON3, e->x(), e->y()); 862 rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_DOWN | MOUSE_FLAG_BUTTON3, e->x(), e->y());
862} 863}
863 864
864//***************************************************************************** 865//*****************************************************************************
865void QMyMainWindow::mouseReleaseEvent(QMouseEvent* e) 866void QMyMainWindow::mouseReleaseEvent(QMouseEvent* e)
866{ 867{
867 killTimer(timer_id); 868 killTimer(timer_id);
868 timer_id = 0; 869 timer_id = 0;
869 if (e->button() == LeftButton) 870 if (e->button() == LeftButton)
870 rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1, e->x(), e->y()); 871 rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON1, e->x(), e->y());
871 else if (e->button() == RightButton) 872 else if (e->button() == RightButton)
872 rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON2, e->x(), e->y()); 873 rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON2, e->x(), e->y());
873 else if (e->button() == MidButton) 874 else if (e->button() == MidButton)
874 rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON3, e->x(), e->y()); 875 rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON3, e->x(), e->y());
875} 876}
876 877
877//***************************************************************************** 878//*****************************************************************************
878void QMyMainWindow::wheelEvent(QWheelEvent* e) 879void QMyMainWindow::wheelEvent(QWheelEvent* e)
879{ 880{
880 if (e->delta() > 0) 881 if (e->delta() > 0)
881 rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON4, e->x(), e->y()); 882 rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON4, e->x(), e->y());
882 else if (e->delta() < 0) 883 else if (e->delta() < 0)
883 rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON5, e->x(), e->y()); 884 rdp_send_input(0, RDP_INPUT_MOUSE, MOUSE_FLAG_BUTTON5, e->x(), e->y());
884} 885}
885 886
886#define NOT(x) (255-(x)) 887#define NOT(x) (255-(x))
887 888
888//***************************************************************************** 889//*****************************************************************************
889uint8 rop(int rop, uint8 src, uint8 dst) 890uint8 rop(int rop, uint8 src, uint8 dst)
890{ 891{
891 switch (rop) 892 switch (rop)
892 { 893 {
893 case 0x0: return 0; 894 case 0x0: return 0;
894 case 0x1: return NOT (src | dst); 895 case 0x1: return NOT (src | dst);
895 case 0x2: return NOT (src) & dst; 896 case 0x2: return NOT (src) & dst;
896 case 0x3: return NOT (src); 897 case 0x3: return NOT (src);
897 case 0x4: return src & NOT (dst); 898 case 0x4: return src & NOT (dst);
898 case 0x5: return NOT (dst); 899 case 0x5: return NOT (dst);
899 case 0x6: return src ^ dst; 900 case 0x6: return src ^ dst;
900 case 0x7: return NOT (src & dst); 901 case 0x7: return NOT (src & dst);
901 case 0x8: return src & dst; 902 case 0x8: return src & dst;
902 case 0x9: return NOT (src) ^ dst; 903 case 0x9: return NOT (src) ^ dst;
903 case 0xa: return dst; 904 case 0xa: return dst;
904 case 0xb: return NOT (src) | dst; 905 case 0xb: return NOT (src) | dst;
905 case 0xc: return src; 906 case 0xc: return src;
906 case 0xd: return src | NOT (dst); 907 case 0xd: return src | NOT (dst);
907 case 0xe: return src | dst; 908 case 0xe: return src | dst;
908 case 0xf: return NOT (0); 909 case 0xf: return NOT (0);
909 } 910 }
910 return dst; 911 return dst;
911} 912}
912 913
913//***************************************************************************** 914//*****************************************************************************
914uint8 get_pixel(int x, int y) 915uint8 get_pixel(int x, int y)
915{ 916{
916 if (x >= 0 && x < g_width && y >= 0 && y < g_height) 917 if (x >= 0 && x < g_width && y >= 0 && y < g_height)
917 return BS[y * g_width + x]; 918 return BS[y * g_width + x];
918 else 919 else
919 return 0; 920 return 0;
920} 921}
921 922
922//***************************************************************************** 923//*****************************************************************************
923void set_pixel(int x, int y, uint8 pixel, int op = 0xc) 924void set_pixel(int x, int y, uint8 pixel, int op = 0xc)
924{ 925{
925 if (x >= clipx && x < (clipx + clipcx) && y >= clipy && y < (clipy + clipcy)) 926 if (x >= clipx && x < (clipx + clipcx) && y >= clipy && y < (clipy + clipcy))
926 if (x >= 0 && x < g_width && y >= 0 && y < g_height) 927 if (x >= 0 && x < g_width && y >= 0 && y < g_height)
927 if (op == 0xc) 928 if (op == 0xc)
928 BS[y * g_width + x] = pixel; 929 BS[y * g_width + x] = pixel;
929 else 930 else
930 BS[y * g_width + x] = rop(op, pixel, BS[y * g_width + x]); 931 BS[y * g_width + x] = rop(op, pixel, BS[y * g_width + x]);
931} 932}
932 933
933//****************************************************************************** 934//******************************************************************************
934// adjust coordinates for cliping rect 935// adjust coordinates for cliping rect
935bool WarpCoords(int* x, int* y, int* cx, int* cy, int* srcx, int* srcy) 936bool WarpCoords(int* x, int* y, int* cx, int* cy, int* srcx, int* srcy)
936{ 937{
937 int dx, dy; 938 int dx, dy;
938 QRect InRect(*x, *y, *cx, *cy); 939 QRect InRect(*x, *y, *cx, *cy);
939 QRect OutRect; 940 QRect OutRect;
940 QRect CRect(clipx, clipy, clipcx, clipcy); 941 QRect CRect(clipx, clipy, clipcx, clipcy);
941 OutRect = InRect.intersect(CRect); 942 OutRect = InRect.intersect(CRect);
942 if (OutRect.isEmpty()) 943 if (OutRect.isEmpty())
943 return false; 944 return false;
944 dx = OutRect.x() - InRect.x(); 945 dx = OutRect.x() - InRect.x();
945 dy = OutRect.y() - InRect.y(); 946 dy = OutRect.y() - InRect.y();
946 *x = OutRect.x(); 947 *x = OutRect.x();
947 *y = OutRect.y(); 948 *y = OutRect.y();
948 *cx = OutRect.width(); 949 *cx = OutRect.width();
949 *cy = OutRect.height(); 950 *cy = OutRect.height();
950 if (srcx != NULL) 951 if (srcx != NULL)
951 *srcx = *srcx + dx; 952 *srcx = *srcx + dx;
952 if (srcy != NULL) 953 if (srcy != NULL)
953 *srcy = *srcy + dy; 954 *srcy = *srcy + dy;
954 return true; 955 return true;
955} 956}
956 957
957//***************************************************************************** 958//*****************************************************************************
958void QMyMainWindow::paintEvent(QPaintEvent* pe) 959void QMyMainWindow::paintEvent(QPaintEvent* pe)
959{ 960{
960 QImage* Image; 961 QImage* Image;
961 QPainter* Painter; 962 QPainter* Painter;
962 QRect Rect; 963 QRect Rect;
963 int i, j, w, h, l, t; 964 int i, j, w, h, l, t;
964 uint8* data; 965 uint8* data;
965 966
966 if (!testWFlags(WRepaintNoErase)) 967 if (!testWFlags(WRepaintNoErase))
967 setWFlags(WRepaintNoErase); 968 setWFlags(WRepaintNoErase);
968 if (CM != NULL) 969 if (CM != NULL)
969 { 970 {
970 Rect = pe->rect(); 971 Rect = pe->rect();
971 l = Rect.left(); 972 l = Rect.left();
972 t = Rect.top(); 973 t = Rect.top();
973 w = Rect.width(); 974 w = Rect.width();
974 h = Rect.height(); 975 h = Rect.height();
975 if (w > 0 && h > 0 && CM->NumColors > 0) 976 if (w > 0 && h > 0 && CM->NumColors > 0)
976 { 977 {
977 data = (uint8*)xmalloc(w * h); 978 data = (uint8*)xmalloc(w * h);
978 for (i = 0; i < h; i++) 979 for (i = 0; i < h; i++)
979 for (j = 0; j < w; j++) 980 for (j = 0; j < w; j++)
980 data[i * w + j] = get_pixel(l + j, t + i); 981 data[i * w + j] = get_pixel(l + j, t + i);
981 Image = new QImage(data, w, h, 8,(QRgb*)CM->RGBColors, CM->NumColors, QImage::IgnoreEndian); 982 Image = new QImage(data, w, h, 8,(QRgb*)CM->RGBColors, CM->NumColors, QImage::IgnoreEndian);
982 Painter = new QPainter(this); 983 Painter = new QPainter(this);
983 Painter->drawImage(l, t, *Image, 0, 0, w, h); 984 Painter->drawImage(l, t, *Image, 0, 0, w, h);
984 xfree(data); 985 xfree(data);
985 delete Painter; 986 delete Painter;
986 delete Image; 987 delete Image;
987 } 988 }
988 } 989 }
989} 990}
990 991
991//***************************************************************************** 992//*****************************************************************************
992void QMyMainWindow::closeEvent(QCloseEvent* e) 993void QMyMainWindow::closeEvent(QCloseEvent* e)
993{ 994{
994 e->accept(); 995 e->accept();
995} 996}
996 997
997//***************************************************************************** 998//*****************************************************************************
998void QMyMainWindow::dataReceived() 999void QMyMainWindow::dataReceived()
999{ 1000{
1000 if (rdp_main_loop()) 1001 if (rdp_main_loop())
1001 return; 1002 return;
1002 else 1003 else
1003 SV->close(); 1004 SV->close();
1004} 1005}
1005 1006
1006//***************************************************************************** 1007//*****************************************************************************
1007void redraw(int x, int y, int cx, int cy) 1008void redraw(int x, int y, int cx, int cy)
1008{ 1009{
1009 if (WarpCoords(&x, &y, &cx, &cy, NULL, NULL)) 1010 if (WarpCoords(&x, &y, &cx, &cy, NULL, NULL))
1010 { 1011 {
1011 MW->update(x, y, cx, cy); 1012 MW->update(x, y, cx, cy);
1012 } 1013 }
1013} 1014}
1014 1015
1015/* 1016/*
1016BOOL ui_init(void) 1017BOOL ui_init(void)
1017{ 1018{
1018 QWidget* d; 1019 QWidget* d;
1019 1020
1020 CM = NULL; 1021 CM = NULL;
1021 BS = NULL; 1022 BS = NULL;
1022 App = new QPEApplication(g_argc, g_argv); 1023 App = new QPEApplication(g_argc, g_argv);
1023 if (fullscreen) 1024 if (fullscreen)
1024 { 1025 {
1025 d = QApplication::desktop(); 1026 d = QApplication::desktop();
1026 width = d->width(); // returns screen width 1027 width = d->width(); // returns screen width
1027 height = d->height(); // returns screen height 1028 height = d->height(); // returns screen height
1028 } 1029 }
1029 return True; 1030 return True;
1030} 1031}
1031*/ 1032*/
1032 1033
1033/* 1034/*
1034void ui_deinit(void) 1035void ui_deinit(void)
1035{ 1036{
1036 delete App; 1037 delete App;
1037} 1038}
1038*/ 1039*/
1039 1040
1040/* 1041/*
1041BOOL ui_create_window(void) 1042BOOL ui_create_window(void)
1042{ 1043{
1043 MW = new QMyMainWindow(); 1044 MW = new QMyMainWindow();
1044 MW->resize(width, height); 1045 MW->resize(width, height);
1045 SV = new QMyScrollView(); 1046 SV = new QMyScrollView();
1046 SV->resize(width + 4, height + 4); 1047 SV->resize(width + 4, height + 4);
1047 App->setMainWidget(SV); 1048 App->setMainWidget(SV);
1048 SV->addChild(MW); 1049 SV->addChild(MW);
1049 MW->setMouseTracking(true); 1050 MW->setMouseTracking(true);
1050 SocketNotifier = new QSocketNotifier(global_sock, QSocketNotifier::Read, MW); 1051 SocketNotifier = new QSocketNotifier(global_sock, QSocketNotifier::Read, MW);
1051 MW->connect(SocketNotifier, SIGNAL(activated(int)), MW, SLOT(dataReceived())); 1052 MW->connect(SocketNotifier, SIGNAL(activated(int)), MW, SLOT(dataReceived()));
1052 if (fullscreen) 1053 if (fullscreen)
1053 SV->showFullScreen(); 1054 SV->showFullScreen();
1054 else 1055 else
1055 SV->showMaximized(); 1056 SV->showMaximized();
1056 BS = (uint8*)xmalloc(width * height); 1057 BS = (uint8*)xmalloc(width * height);
1057 memset(BS, 0, width * height); 1058 memset(BS, 0, width * height);
1058 clipx = 0; 1059 clipx = 0;
1059 clipy = 0; 1060 clipy = 0;
1060 clipcx = width; 1061 clipcx = width;
1061 clipcy = height; 1062 clipcy = height;
1062 CM = (QColorMap*)xmalloc(sizeof(struct QColorMap)); 1063 CM = (QColorMap*)xmalloc(sizeof(struct QColorMap));
1063 memset(CM, 0, sizeof(struct QColorMap)); 1064 memset(CM, 0, sizeof(struct QColorMap));
1064 SV->timer_id = SV->startTimer(1000); 1065 SV->timer_id = SV->startTimer(1000);
1065 return True; 1066 return True;
1066} 1067}
1067*/ 1068*/
1068 1069
1069/* 1070/*
1070void ui_destroy_window(void) 1071void ui_destroy_window(void)
1071{ 1072{
1072 delete MW; 1073 delete MW;
1073 delete SV; 1074 delete SV;
1074 xfree(BS); 1075 xfree(BS);
1075 xfree(CM); 1076 xfree(CM);
1076} 1077}
1077*/ 1078*/
1078 1079
1079//***************************************************************************** 1080//*****************************************************************************
1080/* Returns 0 after user quit, 1 otherwise */ 1081/* Returns 0 after user quit, 1 otherwise */
1081int ui_select(int rdp_socket) 1082int ui_select(int rdp_socket)
1082{ 1083{
1083 global_sock = rdp_socket; 1084 global_sock = rdp_socket;
1084 return 1; 1085 return 1;
1085} 1086}
1086 1087
1087//***************************************************************************** 1088//*****************************************************************************
1088void ui_move_pointer(int /*x*/, int /*y*/) 1089void ui_move_pointer(int /*x*/, int /*y*/)
1089{ 1090{
1090} 1091}
1091 1092
1092//***************************************************************************** 1093//*****************************************************************************
1093HBITMAP ui_create_bitmap(int width, int height, uint8 * data) 1094HBITMAP ui_create_bitmap(int width, int height, uint8 * data)
1094{ 1095{
1095 struct bitmap* the_bitmap; 1096 struct bitmap* the_bitmap;
1096 uint8* bitmap_data; 1097 uint8* bitmap_data;
1097 int i, j; 1098 int i, j;
1098 1099
1099// printf("width %d height %d times %d\n", width, height, width * height); 1100// printf("width %d height %d times %d\n", width, height, width * height);
1100 bitmap_data = (uint8*)xmalloc(width * height); 1101 bitmap_data = (uint8*)xmalloc(width * height);
1101 the_bitmap = (struct bitmap*)xmalloc(sizeof(struct bitmap)); 1102 the_bitmap = (struct bitmap*)xmalloc(sizeof(struct bitmap));
1102 the_bitmap->w = width; 1103 the_bitmap->w = width;
1103 the_bitmap->h = height; 1104 the_bitmap->h = height;
1104 the_bitmap->data = bitmap_data; 1105 the_bitmap->data = bitmap_data;
1105 for (i = 0; i < height; i++) 1106 for (i = 0; i < height; i++)
1106 for (j = 0; j < width; j++) 1107 for (j = 0; j < width; j++)
1107 bitmap_data[i * width + j] = data[i * width + j]; 1108 bitmap_data[i * width + j] = data[i * width + j];
1108 return the_bitmap; 1109 return the_bitmap;
1109} 1110}
1110 1111
1111//***************************************************************************** 1112//*****************************************************************************
1112void ui_paint_bitmap(int x, int y, int cx, int cy, int width, 1113void ui_paint_bitmap(int x, int y, int cx, int cy, int width,
1113 int height, uint8 * data) 1114 int height, uint8 * data)
1114{ 1115{
1115 int i, j; 1116 int i, j;
1116 1117
1117 for (i = 0; i < cy; i++) 1118 for (i = 0; i < cy; i++)
1118 for (j = 0; j < cx; j++) 1119 for (j = 0; j < cx; j++)
1119 if (i < height) 1120 if (i < height)
1120 if (j < width) 1121 if (j < width)
1121 set_pixel(x + j, y + i, data[i * width + j]); 1122 set_pixel(x + j, y + i, data[i * width + j]);
1122 redraw(x, y, cx, cy); 1123 redraw(x, y, cx, cy);
1123} 1124}
1124 1125
1125//***************************************************************************** 1126//*****************************************************************************
1126void ui_destroy_bitmap(HBITMAP bmp) 1127void ui_destroy_bitmap(HBITMAP bmp)
1127{ 1128{
1128 struct bitmap* the_bitmap; 1129 struct bitmap* the_bitmap;
1129 1130
1130 the_bitmap = (struct bitmap*)bmp; 1131 the_bitmap = (struct bitmap*)bmp;
1131 if (the_bitmap != NULL) 1132 if (the_bitmap != NULL)
1132 { 1133 {
1133 if (the_bitmap->data != NULL) 1134 if (the_bitmap->data != NULL)
1134 xfree(the_bitmap->data); 1135 xfree(the_bitmap->data);
1135 xfree(the_bitmap); 1136 xfree(the_bitmap);
1136 } 1137 }
1137} 1138}
1138 1139
1139//***************************************************************************** 1140//*****************************************************************************
1140bool is_pixel_on(uint8* data, int x, int y, int width, int bpp) 1141bool is_pixel_on(uint8* data, int x, int y, int width, int bpp)
1141{ 1142{
1142 int start, shift; 1143 int start, shift;
1143 1144
1144 if (bpp == 1) 1145 if (bpp == 1)
1145 { 1146 {
1146 width = (width + 7) / 8; 1147 width = (width + 7) / 8;
1147 start = (y * width) + x / 8; 1148 start = (y * width) + x / 8;
1148 shift = x % 8; 1149 shift = x % 8;
1149 return (data[start] & (0x80 >> shift)) != 0; 1150 return (data[start] & (0x80 >> shift)) != 0;
1150 } 1151 }
1151 else if (bpp == 8) 1152 else if (bpp == 8)
1152 return data[y * width + x] != 0; 1153 return data[y * width + x] != 0;
1153 else 1154 else
1154 return false; 1155 return false;
1155} 1156}
1156 1157
1157//***************************************************************************** 1158//*****************************************************************************
1158void set_pixel_on(uint8* data, int x, int y, int width, int bpp, uint8 pixel) 1159void set_pixel_on(uint8* data, int x, int y, int width, int bpp, uint8 pixel)
1159{ 1160{
1160 if (bpp == 8) 1161 if (bpp == 8)
1161 data[y * width + x] = pixel; 1162 data[y * width + x] = pixel;
1162} 1163}
1163 1164
1164//***************************************************************************** 1165//*****************************************************************************
1165HGLYPH ui_create_glyph(int width, int height, uint8 * data) 1166HGLYPH ui_create_glyph(int width, int height, uint8 * data)
1166{ 1167{
1167 int i, j; 1168 int i, j;
1168 uint8* glyph_data; 1169 uint8* glyph_data;
1169 struct bitmap* the_glyph; 1170 struct bitmap* the_glyph;
1170 1171
1171 glyph_data = (uint8*)xmalloc(width * height); 1172 glyph_data = (uint8*)xmalloc(width * height);
1172 the_glyph = (struct bitmap*)xmalloc(sizeof(struct bitmap)); 1173 the_glyph = (struct bitmap*)xmalloc(sizeof(struct bitmap));
1173 the_glyph->w = width; 1174 the_glyph->w = width;
1174 the_glyph->h = height; 1175 the_glyph->h = height;
1175 the_glyph->data = glyph_data; 1176 the_glyph->data = glyph_data;
1176 memset(glyph_data, 0, width * height); 1177 memset(glyph_data, 0, width * height);
1177 for (i = 0; i < height; i++) 1178 for (i = 0; i < height; i++)
1178 for (j = 0; j < width; j++) 1179 for (j = 0; j < width; j++)
1179 if (is_pixel_on(data, j, i, width, 1)) 1180 if (is_pixel_on(data, j, i, width, 1))
1180 set_pixel_on(glyph_data, j, i, width, 8, 255); 1181 set_pixel_on(glyph_data, j, i, width, 8, 255);
1181 return the_glyph; 1182 return the_glyph;
1182} 1183}
1183 1184
1184//***************************************************************************** 1185//*****************************************************************************
1185void ui_destroy_glyph(HGLYPH glyph) 1186void ui_destroy_glyph(HGLYPH glyph)
1186{ 1187{
1187 struct bitmap* the_glyph; 1188 struct bitmap* the_glyph;
1188 1189
1189 the_glyph = (struct bitmap*)glyph; 1190 the_glyph = (struct bitmap*)glyph;
1190 if (the_glyph != NULL) 1191 if (the_glyph != NULL)
1191 { 1192 {
1192 if (the_glyph->data != NULL) 1193 if (the_glyph->data != NULL)
1193 xfree(the_glyph->data); 1194 xfree(the_glyph->data);
1194 xfree(the_glyph); 1195 xfree(the_glyph);
1195 } 1196 }
1196} 1197}
1197 1198
1198//***************************************************************************** 1199//*****************************************************************************
1199HCURSOR ui_create_cursor(unsigned int /*x*/, unsigned int /*y*/, 1200HCURSOR ui_create_cursor(unsigned int /*x*/, unsigned int /*y*/,
1200 int /*width*/, int /*height*/, uint8 * /*andmask*/, 1201 int /*width*/, int /*height*/, uint8 * /*andmask*/,
1201 uint8 * /*xormask*/) 1202 uint8 * /*xormask*/)
1202{ 1203{
1203 return (void*)1; 1204 return (void*)1;
1204} 1205}
1205 1206
1206//***************************************************************************** 1207//*****************************************************************************
1207void ui_set_cursor(HCURSOR /*cursor*/) 1208void ui_set_cursor(HCURSOR /*cursor*/)
1208{ 1209{
1209} 1210}
1210 1211
1211//***************************************************************************** 1212//*****************************************************************************
1212void ui_destroy_cursor(HCURSOR /*cursor*/) 1213void ui_destroy_cursor(HCURSOR /*cursor*/)
1213{ 1214{
1214} 1215}
1215 1216
1216//***************************************************************************** 1217//*****************************************************************************
1217HCOLOURMAP ui_create_colourmap(COLOURMAP * colours) 1218HCOLOURMAP ui_create_colourmap(COLOURMAP * colours)
1218{ 1219{
1219 int i; 1220 int i;
1220 int x; 1221 int x;
1221 uint8 r, g, b; 1222 uint8 r, g, b;
1222 i = 0; 1223 i = 0;
1223 while (i < colours->ncolours && i < 256) 1224 while (i < colours->ncolours && i < 256)
1224 { 1225 {
1225 r = colours->colours[i].red; 1226 r = colours->colours[i].red;
1226 g = colours->colours[i].green; 1227 g = colours->colours[i].green;
1227 b = colours->colours[i].blue; 1228 b = colours->colours[i].blue;
1228 x = (r << 16) | (g << 8) | b; 1229 x = (r << 16) | (g << 8) | b;
1229 CM->RGBColors[i] = x; 1230 CM->RGBColors[i] = x;
1230 i++; 1231 i++;
1231 } 1232 }
1232 CM->NumColors = colours->ncolours; 1233 CM->NumColors = colours->ncolours;
1233 return CM; 1234 return CM;
1234} 1235}
1235 1236
1236//***************************************************************************** 1237//*****************************************************************************
1237void ui_destroy_colourmap(HCOLOURMAP /*map*/) 1238void ui_destroy_colourmap(HCOLOURMAP /*map*/)
1238{ 1239{
1239} 1240}
1240 1241
1241//***************************************************************************** 1242//*****************************************************************************
1242void ui_set_colourmap(HCOLOURMAP /*map*/) 1243void ui_set_colourmap(HCOLOURMAP /*map*/)
1243{ 1244{
1244} 1245}
1245 1246
1246//***************************************************************************** 1247//*****************************************************************************
1247void ui_begin_update(void) 1248void ui_begin_update(void)
1248{ 1249{
1249} 1250}
1250 1251
1251//***************************************************************************** 1252//*****************************************************************************
1252void ui_end_update(void) 1253void ui_end_update(void)
1253{ 1254{
1254} 1255}
1255 1256
1256//***************************************************************************** 1257//*****************************************************************************
1257void ui_set_clip(int x, int y, int cx, int cy) 1258void ui_set_clip(int x, int y, int cx, int cy)
1258{ 1259{
1259 clipx = x; 1260 clipx = x;
1260 clipy = y; 1261 clipy = y;
1261 clipcx = cx; 1262 clipcx = cx;
1262 clipcy = cy; 1263 clipcy = cy;
1263} 1264}
1264 1265
1265//***************************************************************************** 1266//*****************************************************************************
1266void ui_reset_clip(void) 1267void ui_reset_clip(void)
1267{ 1268{
1268 clipx = 0; 1269 clipx = 0;
1269 clipy = 0; 1270 clipy = 0;
1270 clipcx = g_width; 1271 clipcx = g_width;
1271 clipcy = g_height; 1272 clipcy = g_height;
1272} 1273}
1273 1274
1274//***************************************************************************** 1275//*****************************************************************************
1275void ui_bell(void) 1276void ui_bell(void)
1276{ 1277{
1277 App->beep(); 1278 App->beep();
1278} 1279}
1279 1280
1280//***************************************************************************** 1281//*****************************************************************************
1281void ui_destblt(uint8 opcode, int x, int y, int cx, int cy) 1282void ui_destblt(uint8 opcode, int x, int y, int cx, int cy)
1282{ 1283{
1283 int i, j; 1284 int i, j;
1284 1285
1285 for (i = 0; i < cy; i++) 1286 for (i = 0; i < cy; i++)
1286 for (j = 0; j < cx; j++) 1287 for (j = 0; j < cx; j++)
1287 set_pixel(x + j, y + i, get_pixel(x + j, y + i), opcode); 1288 set_pixel(x + j, y + i, get_pixel(x + j, y + i), opcode);
1288 redraw(x, y, cx, cy); 1289 redraw(x, y, cx, cy);
1289} 1290}
1290 1291
1291//***************************************************************************** 1292//*****************************************************************************
1292// does not repaint 1293// does not repaint
1293void fill_rect(int x, int y, int cx, int cy, int colour, int opcode = 0xc) 1294void fill_rect(int x, int y, int cx, int cy, int colour, int opcode = 0xc)
1294{ 1295{
1295 int i, j; 1296 int i, j;
1296 1297
1297 for (i = 0; i < cy; i++) 1298 for (i = 0; i < cy; i++)
1298 for (j = 0; j < cx; j++) 1299 for (j = 0; j < cx; j++)
1299 set_pixel(x + j, y + i, colour, opcode); 1300 set_pixel(x + j, y + i, colour, opcode);
1300} 1301}
1301 1302
1302//***************************************************************************** 1303//*****************************************************************************
1303void ui_rect(int x, int y, int cx, int cy, int colour) 1304void ui_rect(int x, int y, int cx, int cy, int colour)
1304{ 1305{
1305 fill_rect(x, y, cx, cy, colour); 1306 fill_rect(x, y, cx, cy, colour);
1306 redraw(x, y, cx, cy); 1307 redraw(x, y, cx, cy);
1307} 1308}
1308 1309
1309//***************************************************************************** 1310//*****************************************************************************
1310void ui_patblt(uint8 opcode, int x, int y, int cx, int cy, 1311void ui_patblt(uint8 opcode, int x, int y, int cx, int cy,
1311 BRUSH * brush, int bgcolour, int fgcolour) 1312 BRUSH * brush, int bgcolour, int fgcolour)
1312{ 1313{
1313 int i, j; 1314 int i, j;
1314 uint8 ipattern[8]; 1315 uint8 ipattern[8];
1315 1316
1316 switch (brush->style) 1317 switch (brush->style)
1317 { 1318 {
1318 case 0: 1319 case 0:
1319 fill_rect(x, y, cx, cy, fgcolour, opcode); 1320 fill_rect(x, y, cx, cy, fgcolour, opcode);
1320 break; 1321 break;
1321 case 3: 1322 case 3:
1322 for (i = 0; i < 8; i++) 1323 for (i = 0; i < 8; i++)
1323 ipattern[i] = ~brush->pattern[7 - i]; 1324 ipattern[i] = ~brush->pattern[7 - i];
1324 for (i = 0; i < cy; i++) 1325 for (i = 0; i < cy; i++)
1325 for (j = 0; j < cx; j++) 1326 for (j = 0; j < cx; j++)
1326 if (is_pixel_on(ipattern, (x + j + brush->xorigin) % 8, 1327 if (is_pixel_on(ipattern, (x + j + brush->xorigin) % 8,
1327 (y + i + brush->yorigin) % 8, 8, 1)) 1328 (y + i + brush->yorigin) % 8, 8, 1))
1328 set_pixel(x + j, y + i, fgcolour, opcode); 1329 set_pixel(x + j, y + i, fgcolour, opcode);
1329 else 1330 else
1330 set_pixel(x + j, y + i, bgcolour, opcode); 1331 set_pixel(x + j, y + i, bgcolour, opcode);
1331 break; 1332 break;
1332 } 1333 }
1333 redraw(x, y, cx, cy); 1334 redraw(x, y, cx, cy);
1334} 1335}
1335 1336
1336//***************************************************************************** 1337//*****************************************************************************
1337void ui_screenblt(uint8 opcode, int x, int y, int cx, int cy, 1338void ui_screenblt(uint8 opcode, int x, int y, int cx, int cy,
1338 int srcx, int srcy) 1339 int srcx, int srcy)
1339{ 1340{
1340 int i, j; 1341 int i, j;
1341 uint8* temp; 1342 uint8* temp;
1342 1343
1343 temp = (uint8*)xmalloc(cx * cy); 1344 temp = (uint8*)xmalloc(cx * cy);
1344 for (i = 0; i < cy; i++) 1345 for (i = 0; i < cy; i++)
1345 for (j = 0; j < cx; j++) 1346 for (j = 0; j < cx; j++)
1346 temp[i * cx + j] = get_pixel(srcx + j, srcy + i); 1347 temp[i * cx + j] = get_pixel(srcx + j, srcy + i);
1347 for (i = 0; i < cy; i++) 1348 for (i = 0; i < cy; i++)
1348 for (j = 0; j < cx; j++) 1349 for (j = 0; j < cx; j++)
1349 set_pixel(x + j, y + i, temp[i * cx + j], opcode); 1350 set_pixel(x + j, y + i, temp[i * cx + j], opcode);
1350 xfree(temp); 1351 xfree(temp);
1351 redraw(x, y, cx, cy); 1352 redraw(x, y, cx, cy);
1352} 1353}
1353 1354
1354//***************************************************************************** 1355//*****************************************************************************
1355void ui_memblt(uint8 opcode, int x, int y, int cx, int cy, 1356void ui_memblt(uint8 opcode, int x, int y, int cx, int cy,
1356 HBITMAP src, int srcx, int srcy) 1357 HBITMAP src, int srcx, int srcy)
1357{ 1358{
1358 int i, j; 1359 int i, j;
1359 struct bitmap* the_bitmap; 1360 struct bitmap* the_bitmap;
1360 1361
1361 the_bitmap = (struct bitmap*)src; 1362 the_bitmap = (struct bitmap*)src;
1362 if (the_bitmap == NULL) 1363 if (the_bitmap == NULL)
1363 return; 1364 return;
1364 for (i = 0; i < cy; i++) 1365 for (i = 0; i < cy; i++)
1365 for (j = 0; j < cx; j++) 1366 for (j = 0; j < cx; j++)
1366 if ((i + srcy) < the_bitmap->h && (j + srcx) < the_bitmap->w) 1367 if ((i + srcy) < the_bitmap->h && (j + srcx) < the_bitmap->w)
1367 set_pixel(x + j, y + i, the_bitmap->data[(i + srcy) * the_bitmap->w + (j + srcx)], opcode); 1368 set_pixel(x + j, y + i, the_bitmap->data[(i + srcy) * the_bitmap->w + (j + srcx)], opcode);
1368 redraw(x, y, cx, cy); 1369 redraw(x, y, cx, cy);
1369} 1370}
1370 1371
1371//***************************************************************************** 1372//*****************************************************************************
1372// not used 1373// not used
1373void ui_triblt(uint8 /*opcode*/, int /*x*/, int /*y*/, int /*cx*/, int /*cy*/, 1374void ui_triblt(uint8 /*opcode*/, int /*x*/, int /*y*/, int /*cx*/, int /*cy*/,
1374 HBITMAP /*src*/, int /*srcx*/, int /*srcy*/, BRUSH * /*brush*/, 1375 HBITMAP /*src*/, int /*srcx*/, int /*srcy*/, BRUSH * /*brush*/,
1375 int /*bgcolour*/, int /*fgcolour*/) 1376 int /*bgcolour*/, int /*fgcolour*/)
1376{ 1377{
1377} 1378}
1378 1379
1379//***************************************************************************** 1380//*****************************************************************************
1380// Bresenham's line drawing algorithm 1381// Bresenham's line drawing algorithm
1381void ui_line(uint8 opcode, int startx, int starty, int endx, 1382void ui_line(uint8 opcode, int startx, int starty, int endx,
1382 int endy, PEN * pen) 1383 int endy, PEN * pen)
1383{ 1384{
1384 int dx, dy, incx, incy, dpr, dpru, p, left, top, right, bottom; 1385 int dx, dy, incx, incy, dpr, dpru, p, left, top, right, bottom;
1385 1386
1386 if (startx > endx) 1387 if (startx > endx)
1387 { 1388 {
1388 dx = startx - endx; 1389 dx = startx - endx;
1389 incx = -1; 1390 incx = -1;
1390 left = endx; 1391 left = endx;
1391 right = startx; 1392 right = startx;
1392 } 1393 }
1393 else 1394 else
1394 { 1395 {
1395 dx = endx - startx; 1396 dx = endx - startx;
1396 incx = 1; 1397 incx = 1;
1397 left = startx; 1398 left = startx;
1398 right = endx; 1399 right = endx;
1399 } 1400 }
1400 if (starty > endy) 1401 if (starty > endy)
1401 { 1402 {
1402 dy = starty - endy; 1403 dy = starty - endy;
1403 incy = -1; 1404 incy = -1;
1404 top = endy; 1405 top = endy;
1405 bottom = starty; 1406 bottom = starty;
1406 } 1407 }
1407 else 1408 else
1408 { 1409 {
1409 dy = endy - starty; 1410 dy = endy - starty;
1410 incy = 1; 1411 incy = 1;
1411 top = starty; 1412 top = starty;
1412 bottom = endy; 1413 bottom = endy;
1413 } 1414 }
1414 if (dx >= dy) 1415 if (dx >= dy)
1415 { 1416 {
1416 dpr = dy << 1; 1417 dpr = dy << 1;
1417 dpru = dpr - (dx << 1); 1418 dpru = dpr - (dx << 1);
1418 p = dpr - dx; 1419 p = dpr - dx;
1419 for (; dx >= 0; dx--) 1420 for (; dx >= 0; dx--)
1420 { 1421 {
1421 set_pixel(startx, starty, pen->colour, opcode); 1422 set_pixel(startx, starty, pen->colour, opcode);
1422 if (p > 0) 1423 if (p > 0)
1423 { 1424 {
1424 startx += incx; 1425 startx += incx;
1425 starty += incy; 1426 starty += incy;
1426 p += dpru; 1427 p += dpru;
1427 } 1428 }
1428 else 1429 else
1429 { 1430 {
1430 startx += incx; 1431 startx += incx;
1431 p += dpr; 1432 p += dpr;
1432 } 1433 }
1433 } 1434 }
1434 } 1435 }
1435 else 1436 else
1436 { 1437 {
1437 dpr = dx << 1; 1438 dpr = dx << 1;
1438 dpru = dpr - (dy << 1); 1439 dpru = dpr - (dy << 1);
1439 p = dpr - dy; 1440 p = dpr - dy;
1440 for (; dy >= 0; dy--) 1441 for (; dy >= 0; dy--)
1441 { 1442 {
1442 set_pixel(startx, starty, pen->colour, opcode); 1443 set_pixel(startx, starty, pen->colour, opcode);
1443 if (p > 0) 1444 if (p > 0)
1444 { 1445 {
1445 startx += incx; 1446 startx += incx;
1446 starty += incy; 1447 starty += incy;
1447 p += dpru; 1448 p += dpru;
1448 } 1449 }
1449 else 1450 else
1450 { 1451 {
1451 starty += incy; 1452 starty += incy;
1452 p += dpr; 1453 p += dpr;
1453 } 1454 }
1454 } 1455 }
1455 } 1456 }
1456 redraw(left, top, (right - left) + 1, (bottom - top) + 1); 1457 redraw(left, top, (right - left) + 1, (bottom - top) + 1);
1457} 1458}
1458 1459
1459//***************************************************************************** 1460//*****************************************************************************
1460void draw_glyph (int x, int y, HGLYPH glyph, int fgcolour) 1461void draw_glyph (int x, int y, HGLYPH glyph, int fgcolour)
1461{ 1462{
1462 struct bitmap* the_glyph; 1463 struct bitmap* the_glyph;
1463 int i, j; 1464 int i, j;
1464 1465
1465 the_glyph = (struct bitmap*)glyph; 1466 the_glyph = (struct bitmap*)glyph;
1466 if (the_glyph == NULL) 1467 if (the_glyph == NULL)
1467 return; 1468 return;
1468 for (i = 0; i < the_glyph->h; i++) 1469 for (i = 0; i < the_glyph->h; i++)
1469 for (j = 0; j < the_glyph->w; j++) 1470 for (j = 0; j < the_glyph->w; j++)
1470 if (is_pixel_on(the_glyph->data, j, i, the_glyph->w, 8)) 1471 if (is_pixel_on(the_glyph->data, j, i, the_glyph->w, 8))
1471 set_pixel(x + j, y + i, fgcolour); 1472 set_pixel(x + j, y + i, fgcolour);
1472} 1473}
1473 1474
1474#define DO_GLYPH(ttext,idx) \ 1475#define DO_GLYPH(ttext,idx) \
1475{\ 1476{\
1476 glyph = cache_get_font (font, ttext[idx]);\ 1477 glyph = cache_get_font (font, ttext[idx]);\
1477 if (!(flags & TEXT2_IMPLICIT_X))\ 1478 if (!(flags & TEXT2_IMPLICIT_X))\
1478 {\ 1479 {\
1479 xyoffset = ttext[++idx];\ 1480 xyoffset = ttext[++idx];\
1480 if ((xyoffset & 0x80))\ 1481 if ((xyoffset & 0x80))\
1481 {\ 1482 {\
1482 if (flags & TEXT2_VERTICAL) \ 1483 if (flags & TEXT2_VERTICAL) \
1483 y += ttext[idx+1] | (ttext[idx+2] << 8);\ 1484 y += ttext[idx+1] | (ttext[idx+2] << 8);\
1484 else\ 1485 else\
1485 x += ttext[idx+1] | (ttext[idx+2] << 8);\ 1486 x += ttext[idx+1] | (ttext[idx+2] << 8);\
1486 idx += 2;\ 1487 idx += 2;\
1487 }\ 1488 }\
1488 else\ 1489 else\
1489 {\ 1490 {\
1490 if (flags & TEXT2_VERTICAL) \ 1491 if (flags & TEXT2_VERTICAL) \
1491 y += xyoffset;\ 1492 y += xyoffset;\
1492 else\ 1493 else\
1493 x += xyoffset;\ 1494 x += xyoffset;\
1494 }\ 1495 }\
1495 }\ 1496 }\
1496 if (glyph != NULL)\ 1497 if (glyph != NULL)\
1497 {\ 1498 {\
1498 draw_glyph (x + glyph->offset, y + glyph->baseline, glyph->pixmap, fgcolour);\ 1499 draw_glyph (x + glyph->offset, y + glyph->baseline, glyph->pixmap, fgcolour);\
1499 if (flags & TEXT2_IMPLICIT_X)\ 1500 if (flags & TEXT2_IMPLICIT_X)\
1500 x += glyph->width;\ 1501 x += glyph->width;\
1501 }\ 1502 }\
1502} 1503}
1503 1504
1504//***************************************************************************** 1505//*****************************************************************************
1505void ui_draw_text(uint8 font, uint8 flags, int mixmode, 1506void ui_draw_text(uint8 font, uint8 flags, int mixmode,
1506 int x, int y, int clipx, int clipy, 1507 int x, int y, int clipx, int clipy,
1507 int clipcx, int clipcy, int boxx, 1508 int clipcx, int clipcy, int boxx,
1508 int boxy, int boxcx, int boxcy, int bgcolour, 1509 int boxy, int boxcx, int boxcy, int bgcolour,
1509 int fgcolour, uint8 * text, uint8 length) 1510 int fgcolour, uint8 * text, uint8 length)
1510{ 1511{
1511 FONTGLYPH *glyph; 1512 FONTGLYPH *glyph;
1512 int i, j, xyoffset; 1513 int i, j, xyoffset;
1513 DATABLOB *entry; 1514 DATABLOB *entry;
1514 1515
1515 if (boxcx > 1) 1516 if (boxcx > 1)
1516 fill_rect(boxx, boxy, boxcx, boxcy, bgcolour); 1517 fill_rect(boxx, boxy, boxcx, boxcy, bgcolour);
1517 else if (mixmode == MIX_OPAQUE) 1518 else if (mixmode == MIX_OPAQUE)
1518 fill_rect(clipx, clipy, clipcx, clipcy, bgcolour); 1519 fill_rect(clipx, clipy, clipcx, clipcy, bgcolour);
1519 1520
1520 /* Paint text, character by character */ 1521 /* Paint text, character by character */
1521 for (i = 0; i < length;) 1522 for (i = 0; i < length;)
1522 { 1523 {
1523 switch (text[i]) 1524 switch (text[i])
1524 { 1525 {
1525 case 0xff: 1526 case 0xff:
1526 if (i + 2 < length) 1527 if (i + 2 < length)
1527 cache_put_text(text[i + 1], text, text[i + 2]); 1528 cache_put_text(text[i + 1], text, text[i + 2]);
1528 else 1529 else
1529 { 1530 {
1530 error("this shouldn't be happening\n"); 1531 error("this shouldn't be happening\n");
1531 exit(1); 1532 exit(1);
1532 } 1533 }
1533 /* this will move pointer from start to first character after FF command */ 1534 /* this will move pointer from start to first character after FF command */
1534 length -= i + 3; 1535 length -= i + 3;
1535 text = &(text[i + 3]); 1536 text = &(text[i + 3]);
1536 i = 0; 1537 i = 0;
1537 break; 1538 break;
1538 1539
1539 case 0xfe: 1540 case 0xfe:
1540 entry = cache_get_text(text[i + 1]); 1541 entry = cache_get_text(text[i + 1]);
1541 if (entry != NULL) 1542 if (entry != NULL)
1542 { 1543 {
1543 if ((((uint8 *) (entry->data))[1] == 0) && (!(flags & TEXT2_IMPLICIT_X))) 1544 if ((((uint8 *) (entry->data))[1] == 0) && (!(flags & TEXT2_IMPLICIT_X)))
1544 { 1545 {
1545 if (flags & TEXT2_VERTICAL) 1546 if (flags & TEXT2_VERTICAL)
1546 y += text[i + 2]; 1547 y += text[i + 2];
1547 else 1548 else
1548 x += text[i + 2]; 1549 x += text[i + 2];
1549 } 1550 }
1550 for (j = 0; j < entry->size; j++) 1551 for (j = 0; j < entry->size; j++)
1551 DO_GLYPH(((uint8 *) (entry->data)), j); 1552 DO_GLYPH(((uint8 *) (entry->data)), j);
1552 } 1553 }
1553 if (i + 2 < length) 1554 if (i + 2 < length)
1554 i += 3; 1555 i += 3;
1555 else 1556 else
1556 i += 2; 1557 i += 2;
1557 length -= i; 1558 length -= i;
1558 /* this will move pointer from start to first character after FE command */ 1559 /* this will move pointer from start to first character after FE command */
1559 text = &(text[i]); 1560 text = &(text[i]);
1560 i = 0; 1561 i = 0;
1561 break; 1562 break;
1562 1563
1563 default: 1564 default:
1564 DO_GLYPH(text, i); 1565 DO_GLYPH(text, i);
1565 i++; 1566 i++;
1566 break; 1567 break;
1567 } 1568 }
1568 } 1569 }
1569 if (boxcx > 1) 1570 if (boxcx > 1)
1570 redraw(boxx, boxy, boxcx, boxcy); 1571 redraw(boxx, boxy, boxcx, boxcy);
1571 else 1572 else
1572 redraw(clipx, clipy, clipcx, clipcy); 1573 redraw(clipx, clipy, clipcx, clipcy);
1573} 1574}
1574 1575
1575//***************************************************************************** 1576//*****************************************************************************
1576void ui_desktop_save(uint32 offset, int x, int y, int cx, int cy) 1577void ui_desktop_save(uint32 offset, int x, int y, int cx, int cy)
1577{ 1578{
1578 uint8* data; 1579 uint8* data;
1579 int i, j; 1580 int i, j;
1580 1581
1581 data = (uint8*)xmalloc(cx * cy); 1582 data = (uint8*)xmalloc(cx * cy);
1582 for (i = 0; i < cy; i++) 1583 for (i = 0; i < cy; i++)
1583 for (j = 0; j < cx; j++) 1584 for (j = 0; j < cx; j++)
1584 data[i * cx + j] = get_pixel(x + j, y + i); 1585 data[i * cx + j] = get_pixel(x + j, y + i);
1585 cache_put_desktop(offset, cx, cy, cx, 1, data); 1586 cache_put_desktop(offset, cx, cy, cx, 1, data);
1586 xfree(data); 1587 xfree(data);
1587} 1588}
1588 1589
1589//***************************************************************************** 1590//*****************************************************************************
1590void ui_desktop_restore(uint32 offset, int x, int y, int cx, int cy) 1591void ui_desktop_restore(uint32 offset, int x, int y, int cx, int cy)
1591{ 1592{
1592 uint8* data; 1593 uint8* data;
1593 int i, j; 1594 int i, j;
1594 1595
1595 data = cache_get_desktop(offset, cx, cy, 1); 1596 data = cache_get_desktop(offset, cx, cy, 1);
1596 for (i = 0; i < cy; i++) 1597 for (i = 0; i < cy; i++)
1597 for (j = 0; j < cx; j++) 1598 for (j = 0; j < cx; j++)
1598 set_pixel(x + j, y + i, data[i * cx + j]); 1599 set_pixel(x + j, y + i, data[i * cx + j]);
1599 redraw(x, y, cx, cy); 1600 redraw(x, y, cx, cy);
1600} 1601}
1601 1602
1602//***************************************************************************** 1603//*****************************************************************************
1603int main(int argc, char** argv) 1604int main(int argc, char** argv)
1604{ 1605{
1605 CM = NULL; 1606 CM = NULL;
1606 BS = NULL; 1607 BS = NULL;
1607 App = new QPEApplication(argc, argv); 1608 App = new QPEApplication(argc, argv);
1608 SV = new QMyScrollView(); 1609 SV = new QMyScrollView();
1609 App->setMainWidget(SV); 1610 App->setMainWidget(SV);
1610 SV->showMaximized(); 1611 SV->showMaximized();
1612 SV->setCaption( QMyScrollView::tr("Remote Desktop Client (RDP)") );
1611 SV->timer_id = SV->startTimer(1000); 1613 SV->timer_id = SV->startTimer(1000);
1612 App->exec(); 1614 App->exec();
1613 delete SV; 1615 delete SV;
1614 delete App; 1616 delete App;
1615 if (CM != NULL) 1617 if (CM != NULL)
1616 xfree(CM); 1618 xfree(CM);
1617 if (BS !=NULL) 1619 if (BS !=NULL)
1618 xfree(BS); 1620 xfree(BS);
1619 return 0; 1621 return 0;
1620} 1622}
1621 1623
1622/* 1624/*
1623 MW = new QMyMainWindow(); 1625 MW = new QMyMainWindow();
1624 MW->resize(width, height); 1626 MW->resize(width, height);
1625 SV->resize(width + 4, height + 4); 1627 SV->resize(width + 4, height + 4);
1626 App->setMainWidget(SV); 1628 App->setMainWidget(SV);
1627 SV->addChild(MW); 1629 SV->addChild(MW);
1628 MW->setMouseTracking(true); 1630 MW->setMouseTracking(true);
1629 SocketNotifier = new QSocketNotifier(global_sock, QSocketNotifier::Read, MW); 1631 SocketNotifier = new QSocketNotifier(global_sock, QSocketNotifier::Read, MW);
1630 MW->connect(SocketNotifier, SIGNAL(activated(int)), MW, SLOT(dataReceived())); 1632 MW->connect(SocketNotifier, SIGNAL(activated(int)), MW, SLOT(dataReceived()));
1631 if (fullscreen) 1633 if (fullscreen)
1632 SV->showFullScreen(); 1634 SV->showFullScreen();
1633 else 1635 else
1634 SV->showMaximized(); 1636 SV->showMaximized();
1635 BS = (uint8*)xmalloc(width * height); 1637 BS = (uint8*)xmalloc(width * height);
1636 memset(BS, 0, width * height); 1638 memset(BS, 0, width * height);
1637 clipx = 0; 1639 clipx = 0;
1638 clipy = 0; 1640 clipy = 0;
1639 clipcx = width; 1641 clipcx = width;
1640 clipcy = height; 1642 clipcy = height;
1641 CM = (QColorMap*)xmalloc(sizeof(struct QColorMap)); 1643 CM = (QColorMap*)xmalloc(sizeof(struct QColorMap));
1642 memset(CM, 0, sizeof(struct QColorMap)); 1644 memset(CM, 0, sizeof(struct QColorMap));
1643 SV->timer_id = SV->startTimer(1000); 1645 SV->timer_id = SV->startTimer(1000);
1644 return True; 1646 return True;
1645 1647
1646 1648
1647 1649
1648 1650
1649 1651
1650int main(int argc, char ** argv) 1652int main(int argc, char ** argv)
1651{ 1653{
1652 uint32 flags; 1654 uint32 flags;
1653 int i, total_params; 1655 int i, total_params;
1654 char server[64] = "192.168.0.164"; 1656 char server[64] = "192.168.0.164";
1655 char domain[16] = ""; 1657 char domain[16] = "";
1656 char password[16] = ""; 1658 char password[16] = "";
1657 char shell[128] = ""; 1659 char shell[128] = "";
1658 char directory[32] = ""; 1660 char directory[32] = "";
1659 char* p; 1661 char* p;
1660 QString param, s1, s2, s3; 1662 QString param, s1, s2, s3;
1661 1663
1662 flags = RDP_LOGON_NORMAL; 1664 flags = RDP_LOGON_NORMAL;
1663 1665
1664 g_argc = argc; 1666 g_argc = argc;
1665 g_argv = argv; 1667 g_argv = argv;
1666 1668
1667 if (!ui_init()) 1669 if (!ui_init())
1668 return 1; 1670 return 1;
1669 1671
1670 total_params = App->argc(); 1672 total_params = App->argc();
1671 1673
1672 for (i = 1; (i + 1) < total_params; i = i + 2) 1674 for (i = 1; (i + 1) < total_params; i = i + 2)
1673 { 1675 {
1674 s1 = App->argv()[i]; 1676 s1 = App->argv()[i];
1675 s2 = App->argv()[i + 1]; 1677 s2 = App->argv()[i + 1];
1676 if (s1 == "-g") 1678 if (s1 == "-g")
1677 { 1679 {
1678 width = strtol((const char*)s2, &p, 10); 1680 width = strtol((const char*)s2, &p, 10);
1679 if (*p == 'x') 1681 if (*p == 'x')
1680 height = strtol(p + 1, NULL, 10); 1682 height = strtol(p + 1, NULL, 10);
1681 } 1683 }
1682 else if (s1 = "-u") 1684 else if (s1 = "-u")
1683 strcpy(username, (const char*)s2); 1685 strcpy(username, (const char*)s2);
1684 } 1686 }
1685 if (i < total_params) 1687 if (i < total_params)
1686 strcpy(server, App->argv()[i]); 1688 strcpy(server, App->argv()[i]);
1687 1689
1688// printf("server %s width %d height %d\n", server, width, height); 1690// printf("server %s width %d height %d\n", server, width, height);
1689 1691
1690 if (width == 0 || height == 0) 1692 if (width == 0 || height == 0)
1691 { 1693 {
1692 ui_deinit(); 1694 ui_deinit();
1693 return 1; 1695 return 1;
1694 } 1696 }
1695 1697
1696 if (!rdp_connect(server, flags, domain, password, shell, directory)) 1698 if (!rdp_connect(server, flags, domain, password, shell, directory))
1697 { 1699 {
1698 ui_deinit(); 1700 ui_deinit();
1699 return 1; 1701 return 1;
1700 } 1702 }
1701 if (ui_create_window()) 1703 if (ui_create_window())
1702 { 1704 {
1703 ui_main_loop(); 1705 ui_main_loop();
1704 ui_destroy_window(); 1706 ui_destroy_window();
1705 } 1707 }
1706 rdp_disconnect(); 1708 rdp_disconnect();
1707 ui_deinit(); 1709 ui_deinit();
1708} 1710}
1709*/ 1711*/