-rw-r--r-- | noncore/net/opierdesktop/qtwin.cpp | 2 |
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,352 +1,353 @@ | |||
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 | ||
41 | uint32 flags; | 41 | uint32 flags; |
42 | char server[64] = ""; | 42 | char server[64] = ""; |
43 | char domain[16] = ""; | 43 | char domain[16] = ""; |
44 | char password[16] = ""; | 44 | char password[16] = ""; |
45 | char shell[128] = ""; | 45 | char shell[128] = ""; |
46 | char directory[32] = ""; | 46 | char directory[32] = ""; |
47 | 47 | ||
48 | extern int g_width; | 48 | extern int g_width; |
49 | extern int g_height; | 49 | extern int g_height; |
50 | extern int server_bpp; | 50 | extern int server_bpp; |
51 | extern BOOL fullscreen; | 51 | extern BOOL fullscreen; |
52 | extern char username[]; | 52 | extern char username[]; |
53 | int global_sock; | 53 | int global_sock; |
54 | 54 | ||
55 | QSocketNotifier* SocketNotifier; | 55 | QSocketNotifier* SocketNotifier; |
56 | QPEApplication* App; | 56 | QPEApplication* App; |
57 | QMyMainWindow* MW; | 57 | QMyMainWindow* MW; |
58 | QMyScrollView* SV; | 58 | QMyScrollView* SV; |
59 | struct QColorMap | 59 | struct QColorMap |
60 | { | 60 | { |
61 | uint32 RGBColors[256]; | 61 | uint32 RGBColors[256]; |
62 | int NumColors; | 62 | int NumColors; |
63 | }; | 63 | }; |
64 | QColorMap* CM; | 64 | QColorMap* CM; |
65 | uint8* BS; | 65 | uint8* BS; |
66 | int clipx; | 66 | int clipx; |
67 | int clipy; | 67 | int clipy; |
68 | int clipcx; | 68 | int clipcx; |
69 | int clipcy; | 69 | int clipcy; |
70 | 70 | ||
71 | struct bitmap | 71 | struct 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 | ||
78 | BOOL owncolmap = False; | 78 | BOOL owncolmap = False; |
79 | 79 | ||
80 | //***************************************************************************** | 80 | //***************************************************************************** |
81 | void CleanString(QString* Item) | 81 | void 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 | //***************************************************************************** |
95 | QMyDialog::QMyDialog(QWidget* parent) : QDialog(parent, "Settings", true) | 95 | QMyDialog::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 | //***************************************************************************** |
246 | QMyDialog::~QMyDialog() | 247 | QMyDialog::~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 | //***************************************************************************** |
259 | void QMyDialog::ComboChanged(int index) | 260 | void 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 | //***************************************************************************** |
279 | void QMyDialog::OKClicked() | 280 | void 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 | //***************************************************************************** |
291 | void QMyDialog::CancelClicked() | 292 | void QMyDialog::CancelClicked() |
292 | { | 293 | { |
293 | done(0); | 294 | done(0); |
294 | } | 295 | } |
295 | 296 | ||
296 | //***************************************************************************** | 297 | //***************************************************************************** |
297 | void QMyDialog::AddClicked() | 298 | void 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 | //***************************************************************************** |
317 | void QMyDialog::EditClicked() | 318 | void 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 | //***************************************************************************** |
337 | void WriteString(QFile* File, QString* Line) | 338 | void 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 | //***************************************************************************** |
343 | void QMyDialog::SaveClicked() | 344 | void 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"); |
@@ -1355,355 +1356,356 @@ void ui_screenblt(uint8 opcode, int x, int y, int cx, int cy, | |||
1355 | void ui_memblt(uint8 opcode, int x, int y, int cx, int cy, | 1356 | void 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 |
1373 | void ui_triblt(uint8 /*opcode*/, int /*x*/, int /*y*/, int /*cx*/, int /*cy*/, | 1374 | void 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 |
1381 | void ui_line(uint8 opcode, int startx, int starty, int endx, | 1382 | void 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 | //***************************************************************************** |
1460 | void draw_glyph (int x, int y, HGLYPH glyph, int fgcolour) | 1461 | void 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 | //***************************************************************************** |
1505 | void ui_draw_text(uint8 font, uint8 flags, int mixmode, | 1506 | void 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 | //***************************************************************************** |
1576 | void ui_desktop_save(uint32 offset, int x, int y, int cx, int cy) | 1577 | void 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 | //***************************************************************************** |
1590 | void ui_desktop_restore(uint32 offset, int x, int y, int cx, int cy) | 1591 | void 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 | //***************************************************************************** |
1603 | int main(int argc, char** argv) | 1604 | int 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 | ||
1650 | int main(int argc, char ** argv) | 1652 | int 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 | */ |