author | simon <simon> | 2002-04-30 14:19:15 (UTC) |
---|---|---|
committer | simon <simon> | 2002-04-30 14:19:15 (UTC) |
commit | aa2118f85ef44f5eb22babe5cc53421d7d981a94 (patch) (unidiff) | |
tree | 9bf42c8750d0ad5efb789e5fb3e1b2c43cdea25d | |
parent | 19d341250ca5c5f21ea278ebdc7050c5400e951f (diff) | |
download | opie-aa2118f85ef44f5eb22babe5cc53421d7d981a94.zip opie-aa2118f85ef44f5eb22babe5cc53421d7d981a94.tar.gz opie-aa2118f85ef44f5eb22babe5cc53421d7d981a94.tar.bz2 |
- no default args in method impls
- don't unconditionally define _XOPEN_SOURCE (added comment about this
being wrong)
- fixed parameter shadowing problem in DesktopApplication ctor
-rw-r--r-- | core/launcher/desktop.cpp | 4 | ||||
-rw-r--r-- | core/launcher/qcopbridge.cpp | 10 | ||||
-rw-r--r-- | core/launcher/transferserver.cpp | 10 |
3 files changed, 14 insertions, 10 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index 43006f1..d5c16b3 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp | |||
@@ -1,396 +1,396 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "desktop.h" | 21 | #include "desktop.h" |
22 | #include "info.h" | 22 | #include "info.h" |
23 | #include "launcher.h" | 23 | #include "launcher.h" |
24 | #include "mrulist.h" | 24 | #include "mrulist.h" |
25 | #include "qcopbridge.h" | 25 | #include "qcopbridge.h" |
26 | #include "shutdownimpl.h" | 26 | #include "shutdownimpl.h" |
27 | #include "startmenu.h" | 27 | #include "startmenu.h" |
28 | #include "taskbar.h" | 28 | #include "taskbar.h" |
29 | #include "transferserver.h" | 29 | #include "transferserver.h" |
30 | #include "irserver.h" | 30 | #include "irserver.h" |
31 | #include "packageslave.h" | 31 | #include "packageslave.h" |
32 | 32 | ||
33 | #include <qpe/applnk.h> | 33 | #include <qpe/applnk.h> |
34 | #include <qpe/mimetype.h> | 34 | #include <qpe/mimetype.h> |
35 | #include <qpe/password.h> | 35 | #include <qpe/password.h> |
36 | #include <qpe/config.h> | 36 | #include <qpe/config.h> |
37 | #include <qpe/power.h> | 37 | #include <qpe/power.h> |
38 | #include <qpe/timeconversion.h> | 38 | #include <qpe/timeconversion.h> |
39 | #include <qpe/qcopenvelope_qws.h> | 39 | #include <qpe/qcopenvelope_qws.h> |
40 | #include <qpe/global.h> | 40 | #include <qpe/global.h> |
41 | #ifdef QT_QWS_CUSTOM | 41 | #ifdef QT_QWS_CUSTOM |
42 | #include "qpe/custom.h" | 42 | #include "qpe/custom.h" |
43 | #endif | 43 | #endif |
44 | 44 | ||
45 | #include <qgfx_qws.h> | 45 | #include <qgfx_qws.h> |
46 | #include <qmainwindow.h> | 46 | #include <qmainwindow.h> |
47 | #include <qmessagebox.h> | 47 | #include <qmessagebox.h> |
48 | #include <qtimer.h> | 48 | #include <qtimer.h> |
49 | #include <qwindowsystem_qws.h> | 49 | #include <qwindowsystem_qws.h> |
50 | 50 | ||
51 | #include <qvaluelist.h> | 51 | #include <qvaluelist.h> |
52 | 52 | ||
53 | #include <stdlib.h> | 53 | #include <stdlib.h> |
54 | #include <unistd.h> | 54 | #include <unistd.h> |
55 | 55 | ||
56 | class QCopKeyRegister | 56 | class QCopKeyRegister |
57 | { | 57 | { |
58 | public: | 58 | public: |
59 | QCopKeyRegister() : keyCode(0) { } | 59 | QCopKeyRegister() : keyCode(0) { } |
60 | QCopKeyRegister(int k, const QString &c, const QString &m) | 60 | QCopKeyRegister(int k, const QString &c, const QString &m) |
61 | : keyCode(k), channel(c), message(m) { } | 61 | : keyCode(k), channel(c), message(m) { } |
62 | 62 | ||
63 | int getKeyCode() const { return keyCode; } | 63 | int getKeyCode() const { return keyCode; } |
64 | QString getChannel() const { return channel; } | 64 | QString getChannel() const { return channel; } |
65 | QString getMessage() const { return message; } | 65 | QString getMessage() const { return message; } |
66 | 66 | ||
67 | private: | 67 | private: |
68 | int keyCode; | 68 | int keyCode; |
69 | QString channel, message; | 69 | QString channel, message; |
70 | }; | 70 | }; |
71 | 71 | ||
72 | typedef QValueList<QCopKeyRegister> KeyRegisterList; | 72 | typedef QValueList<QCopKeyRegister> KeyRegisterList; |
73 | KeyRegisterList keyRegisterList; | 73 | KeyRegisterList keyRegisterList; |
74 | 74 | ||
75 | static Desktop* qpedesktop = 0; | 75 | static Desktop* qpedesktop = 0; |
76 | static int loggedin=0; | 76 | static int loggedin=0; |
77 | static void login(bool at_poweron) | 77 | static void login(bool at_poweron) |
78 | { | 78 | { |
79 | if ( !loggedin ) { | 79 | if ( !loggedin ) { |
80 | Global::terminateBuiltin("calibrate"); | 80 | Global::terminateBuiltin("calibrate"); |
81 | Password::authenticate(at_poweron); | 81 | Password::authenticate(at_poweron); |
82 | loggedin=1; | 82 | loggedin=1; |
83 | QCopEnvelope e( "QPE/Desktop", "unlocked()" ); | 83 | QCopEnvelope e( "QPE/Desktop", "unlocked()" ); |
84 | } | 84 | } |
85 | } | 85 | } |
86 | 86 | ||
87 | bool Desktop::screenLocked() | 87 | bool Desktop::screenLocked() |
88 | { | 88 | { |
89 | return loggedin == 0; | 89 | return loggedin == 0; |
90 | } | 90 | } |
91 | 91 | ||
92 | /* | 92 | /* |
93 | Priority is number of alerts that are needed to pop up | 93 | Priority is number of alerts that are needed to pop up |
94 | alert. | 94 | alert. |
95 | */ | 95 | */ |
96 | class DesktopPowerAlerter : public QMessageBox | 96 | class DesktopPowerAlerter : public QMessageBox |
97 | { | 97 | { |
98 | public: | 98 | public: |
99 | DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) | 99 | DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) |
100 | : QMessageBox( tr("Battery Status"), "Low Battery", | 100 | : QMessageBox( tr("Battery Status"), "Low Battery", |
101 | QMessageBox::Critical, | 101 | QMessageBox::Critical, |
102 | QMessageBox::Ok | QMessageBox::Default, | 102 | QMessageBox::Ok | QMessageBox::Default, |
103 | QMessageBox::NoButton, QMessageBox::NoButton, | 103 | QMessageBox::NoButton, QMessageBox::NoButton, |
104 | parent, name, FALSE ) | 104 | parent, name, FALSE ) |
105 | { | 105 | { |
106 | currentPriority = INT_MAX; | 106 | currentPriority = INT_MAX; |
107 | alertCount = 0; | 107 | alertCount = 0; |
108 | } | 108 | } |
109 | 109 | ||
110 | void alert( const QString &text, int priority ); | 110 | void alert( const QString &text, int priority ); |
111 | void hideEvent( QHideEvent * ); | 111 | void hideEvent( QHideEvent * ); |
112 | private: | 112 | private: |
113 | int currentPriority; | 113 | int currentPriority; |
114 | int alertCount; | 114 | int alertCount; |
115 | }; | 115 | }; |
116 | 116 | ||
117 | void DesktopPowerAlerter::alert( const QString &text, int priority ) | 117 | void DesktopPowerAlerter::alert( const QString &text, int priority ) |
118 | { | 118 | { |
119 | alertCount++; | 119 | alertCount++; |
120 | if ( alertCount < priority ) | 120 | if ( alertCount < priority ) |
121 | return; | 121 | return; |
122 | if ( priority > currentPriority ) | 122 | if ( priority > currentPriority ) |
123 | return; | 123 | return; |
124 | currentPriority = priority; | 124 | currentPriority = priority; |
125 | setText( text ); | 125 | setText( text ); |
126 | show(); | 126 | show(); |
127 | } | 127 | } |
128 | 128 | ||
129 | 129 | ||
130 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) | 130 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) |
131 | { | 131 | { |
132 | QMessageBox::hideEvent( e ); | 132 | QMessageBox::hideEvent( e ); |
133 | alertCount = 0; | 133 | alertCount = 0; |
134 | currentPriority = INT_MAX; | 134 | currentPriority = INT_MAX; |
135 | } | 135 | } |
136 | 136 | ||
137 | 137 | ||
138 | 138 | ||
139 | DesktopApplication::DesktopApplication( int& argc, char **argv, Type t ) | 139 | DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) |
140 | : QPEApplication( argc, argv, t ) | 140 | : QPEApplication( argc, argv, appType ) |
141 | { | 141 | { |
142 | 142 | ||
143 | QTimer *t = new QTimer( this ); | 143 | QTimer *t = new QTimer( this ); |
144 | connect( t, SIGNAL(timeout()), this, SLOT(psTimeout()) ); | 144 | connect( t, SIGNAL(timeout()), this, SLOT(psTimeout()) ); |
145 | t->start( 10000 ); | 145 | t->start( 10000 ); |
146 | ps = new PowerStatus; | 146 | ps = new PowerStatus; |
147 | pa = new DesktopPowerAlerter( 0 ); | 147 | pa = new DesktopPowerAlerter( 0 ); |
148 | 148 | ||
149 | channel = new QCopChannel( "QPE/Desktop", this ); | 149 | channel = new QCopChannel( "QPE/Desktop", this ); |
150 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 150 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
151 | this, SLOT(receive(const QCString&, const QByteArray&)) ); | 151 | this, SLOT(receive(const QCString&, const QByteArray&)) ); |
152 | } | 152 | } |
153 | 153 | ||
154 | 154 | ||
155 | DesktopApplication::~DesktopApplication() | 155 | DesktopApplication::~DesktopApplication() |
156 | { | 156 | { |
157 | delete ps; | 157 | delete ps; |
158 | delete pa; | 158 | delete pa; |
159 | } | 159 | } |
160 | 160 | ||
161 | void DesktopApplication::receive( const QCString &msg, const QByteArray &data ) | 161 | void DesktopApplication::receive( const QCString &msg, const QByteArray &data ) |
162 | { | 162 | { |
163 | QDataStream stream( data, IO_ReadOnly ); | 163 | QDataStream stream( data, IO_ReadOnly ); |
164 | if (msg == "keyRegister(int key, QString channel, QString message)") | 164 | if (msg == "keyRegister(int key, QString channel, QString message)") |
165 | { | 165 | { |
166 | int k; | 166 | int k; |
167 | QString c, m; | 167 | QString c, m; |
168 | 168 | ||
169 | stream >> k; | 169 | stream >> k; |
170 | stream >> c; | 170 | stream >> c; |
171 | stream >> m; | 171 | stream >> m; |
172 | 172 | ||
173 | qWarning("KeyRegisterRecieved: %i, %s, %s", k, (const char*)c, (const char *)m); | 173 | qWarning("KeyRegisterRecieved: %i, %s, %s", k, (const char*)c, (const char *)m); |
174 | keyRegisterList.append(QCopKeyRegister(k,c,m)); | 174 | keyRegisterList.append(QCopKeyRegister(k,c,m)); |
175 | } | 175 | } |
176 | else if (msg == "suspend()"){ | 176 | else if (msg == "suspend()"){ |
177 | emit power(); | 177 | emit power(); |
178 | } | 178 | } |
179 | 179 | ||
180 | } | 180 | } |
181 | 181 | ||
182 | enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown; | 182 | enum MemState { Unknown, VeryLow, Low, Normal } memstate=Unknown; |
183 | 183 | ||
184 | #ifdef Q_WS_QWS | 184 | #ifdef Q_WS_QWS |
185 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) | 185 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) |
186 | { | 186 | { |
187 | qpedesktop->checkMemory(); | 187 | qpedesktop->checkMemory(); |
188 | 188 | ||
189 | if ( e->type == QWSEvent::Key ) { | 189 | if ( e->type == QWSEvent::Key ) { |
190 | QWSKeyEvent *ke = (QWSKeyEvent *)e; | 190 | QWSKeyEvent *ke = (QWSKeyEvent *)e; |
191 | if ( !loggedin && ke->simpleData.keycode != Key_F34 ) | 191 | if ( !loggedin && ke->simpleData.keycode != Key_F34 ) |
192 | return TRUE; | 192 | return TRUE; |
193 | bool press = ke->simpleData.is_press; | 193 | bool press = ke->simpleData.is_press; |
194 | 194 | ||
195 | if (!keyRegisterList.isEmpty()) | 195 | if (!keyRegisterList.isEmpty()) |
196 | { | 196 | { |
197 | KeyRegisterList::Iterator it; | 197 | KeyRegisterList::Iterator it; |
198 | for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) | 198 | for( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) |
199 | { | 199 | { |
200 | if ((*it).getKeyCode() == ke->simpleData.keycode) | 200 | if ((*it).getKeyCode() == ke->simpleData.keycode) |
201 | QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8()); | 201 | QCopEnvelope((*it).getChannel().utf8(), (*it).getMessage().utf8()); |
202 | } | 202 | } |
203 | } | 203 | } |
204 | 204 | ||
205 | if ( !keyboardGrabbed() ) { | 205 | if ( !keyboardGrabbed() ) { |
206 | if ( ke->simpleData.keycode == Key_F9 ) { | 206 | if ( ke->simpleData.keycode == Key_F9 ) { |
207 | if ( press ) emit datebook(); | 207 | if ( press ) emit datebook(); |
208 | return TRUE; | 208 | return TRUE; |
209 | } | 209 | } |
210 | if ( ke->simpleData.keycode == Key_F10 ) { | 210 | if ( ke->simpleData.keycode == Key_F10 ) { |
211 | if ( !press && cardSendTimer ) { | 211 | if ( !press && cardSendTimer ) { |
212 | emit contacts(); | 212 | emit contacts(); |
213 | delete cardSendTimer; | 213 | delete cardSendTimer; |
214 | } else if ( press ) { | 214 | } else if ( press ) { |
215 | cardSendTimer = new QTimer(); | 215 | cardSendTimer = new QTimer(); |
216 | cardSendTimer->start( 2000, TRUE ); | 216 | cardSendTimer->start( 2000, TRUE ); |
217 | connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); | 217 | connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); |
218 | } | 218 | } |
219 | return TRUE; | 219 | return TRUE; |
220 | } | 220 | } |
221 | /* menu key now opens application menu/toolbar | 221 | /* menu key now opens application menu/toolbar |
222 | if ( ke->simpleData.keycode == Key_F11 ) { | 222 | if ( ke->simpleData.keycode == Key_F11 ) { |
223 | if ( press ) emit menu(); | 223 | if ( press ) emit menu(); |
224 | return TRUE; | 224 | return TRUE; |
225 | } | 225 | } |
226 | */ | 226 | */ |
227 | if ( ke->simpleData.keycode == Key_F12 ) { | 227 | if ( ke->simpleData.keycode == Key_F12 ) { |
228 | while( activePopupWidget() ) | 228 | while( activePopupWidget() ) |
229 | activePopupWidget()->close(); | 229 | activePopupWidget()->close(); |
230 | if ( press ) emit launch(); | 230 | if ( press ) emit launch(); |
231 | return TRUE; | 231 | return TRUE; |
232 | } | 232 | } |
233 | if ( ke->simpleData.keycode == Key_F13 ) { | 233 | if ( ke->simpleData.keycode == Key_F13 ) { |
234 | if ( press ) emit email(); | 234 | if ( press ) emit email(); |
235 | return TRUE; | 235 | return TRUE; |
236 | } | 236 | } |
237 | } | 237 | } |
238 | 238 | ||
239 | if ( ke->simpleData.keycode == Key_F34 ) { | 239 | if ( ke->simpleData.keycode == Key_F34 ) { |
240 | if ( press ) emit power(); | 240 | if ( press ) emit power(); |
241 | return TRUE; | 241 | return TRUE; |
242 | } | 242 | } |
243 | if ( ke->simpleData.keycode == Key_SysReq ) { | 243 | if ( ke->simpleData.keycode == Key_SysReq ) { |
244 | if ( press ) emit power(); | 244 | if ( press ) emit power(); |
245 | return TRUE; | 245 | return TRUE; |
246 | } | 246 | } |
247 | if ( ke->simpleData.keycode == Key_F35 ) { | 247 | if ( ke->simpleData.keycode == Key_F35 ) { |
248 | if ( press ) emit backlight(); | 248 | if ( press ) emit backlight(); |
249 | return TRUE; | 249 | return TRUE; |
250 | } | 250 | } |
251 | if ( ke->simpleData.keycode == Key_F32 ) { | 251 | if ( ke->simpleData.keycode == Key_F32 ) { |
252 | if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); | 252 | if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); |
253 | return TRUE; | 253 | return TRUE; |
254 | } | 254 | } |
255 | if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { | 255 | if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { |
256 | if ( press ) emit symbol(); | 256 | if ( press ) emit symbol(); |
257 | return TRUE; | 257 | return TRUE; |
258 | } | 258 | } |
259 | if ( ke->simpleData.keycode == Key_NumLock ) { | 259 | if ( ke->simpleData.keycode == Key_NumLock ) { |
260 | if ( press ) emit numLockStateToggle(); | 260 | if ( press ) emit numLockStateToggle(); |
261 | } | 261 | } |
262 | if ( ke->simpleData.keycode == Key_CapsLock ) { | 262 | if ( ke->simpleData.keycode == Key_CapsLock ) { |
263 | if ( press ) emit capsLockStateToggle(); | 263 | if ( press ) emit capsLockStateToggle(); |
264 | } | 264 | } |
265 | if ( press ) | 265 | if ( press ) |
266 | qpedesktop->keyClick(); | 266 | qpedesktop->keyClick(); |
267 | } else { | 267 | } else { |
268 | if ( e->type == QWSEvent::Mouse ) { | 268 | if ( e->type == QWSEvent::Mouse ) { |
269 | QWSMouseEvent *me = (QWSMouseEvent *)e; | 269 | QWSMouseEvent *me = (QWSMouseEvent *)e; |
270 | static bool up = TRUE; | 270 | static bool up = TRUE; |
271 | if ( me->simpleData.state&LeftButton ) { | 271 | if ( me->simpleData.state&LeftButton ) { |
272 | if ( up ) { | 272 | if ( up ) { |
273 | up = FALSE; | 273 | up = FALSE; |
274 | qpedesktop->screenClick(); | 274 | qpedesktop->screenClick(); |
275 | } | 275 | } |
276 | } else { | 276 | } else { |
277 | up = TRUE; | 277 | up = TRUE; |
278 | } | 278 | } |
279 | } | 279 | } |
280 | } | 280 | } |
281 | 281 | ||
282 | return QPEApplication::qwsEventFilter( e ); | 282 | return QPEApplication::qwsEventFilter( e ); |
283 | } | 283 | } |
284 | #endif | 284 | #endif |
285 | 285 | ||
286 | void DesktopApplication::psTimeout() | 286 | void DesktopApplication::psTimeout() |
287 | { | 287 | { |
288 | qpedesktop->checkMemory(); // in case no events are being generated | 288 | qpedesktop->checkMemory(); // in case no events are being generated |
289 | 289 | ||
290 | *ps = PowerStatusManager::readStatus(); | 290 | *ps = PowerStatusManager::readStatus(); |
291 | 291 | ||
292 | if ( (ps->batteryStatus() == PowerStatus::VeryLow ) ) { | 292 | if ( (ps->batteryStatus() == PowerStatus::VeryLow ) ) { |
293 | pa->alert( tr( "Battery is running very low." ), 6 ); | 293 | pa->alert( tr( "Battery is running very low." ), 6 ); |
294 | } | 294 | } |
295 | 295 | ||
296 | if ( ps->batteryStatus() == PowerStatus::Critical ) { | 296 | if ( ps->batteryStatus() == PowerStatus::Critical ) { |
297 | pa->alert( tr( "Battery level is critical!\n" | 297 | pa->alert( tr( "Battery level is critical!\n" |
298 | "Keep power off until power restored!" ), 1 ); | 298 | "Keep power off until power restored!" ), 1 ); |
299 | } | 299 | } |
300 | 300 | ||
301 | if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { | 301 | if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { |
302 | pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 ); | 302 | pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 ); |
303 | } | 303 | } |
304 | } | 304 | } |
305 | 305 | ||
306 | 306 | ||
307 | void DesktopApplication::sendCard() | 307 | void DesktopApplication::sendCard() |
308 | { | 308 | { |
309 | delete cardSendTimer; | 309 | delete cardSendTimer; |
310 | cardSendTimer = 0; | 310 | cardSendTimer = 0; |
311 | QString card = getenv("HOME"); | 311 | QString card = getenv("HOME"); |
312 | card += "/Applications/addressbook/businesscard.vcf"; | 312 | card += "/Applications/addressbook/businesscard.vcf"; |
313 | 313 | ||
314 | if ( QFile::exists( card ) ) { | 314 | if ( QFile::exists( card ) ) { |
315 | QCopEnvelope e("QPE/Obex", "send(QString,QString,QString)"); | 315 | QCopEnvelope e("QPE/Obex", "send(QString,QString,QString)"); |
316 | QString mimetype = "text/x-vCard"; | 316 | QString mimetype = "text/x-vCard"; |
317 | e << tr("business card") << card << mimetype; | 317 | e << tr("business card") << card << mimetype; |
318 | } | 318 | } |
319 | } | 319 | } |
320 | 320 | ||
321 | #if defined(QPE_HAVE_MEMALERTER) | 321 | #if defined(QPE_HAVE_MEMALERTER) |
322 | QPE_MEMALERTER_IMPL | 322 | QPE_MEMALERTER_IMPL |
323 | #endif | 323 | #endif |
324 | 324 | ||
325 | #if defined(CUSTOM_SOUND_IMPL) | 325 | #if defined(CUSTOM_SOUND_IMPL) |
326 | CUSTOM_SOUND_IMPL | 326 | CUSTOM_SOUND_IMPL |
327 | #endif | 327 | #endif |
328 | 328 | ||
329 | //=========================================================================== | 329 | //=========================================================================== |
330 | 330 | ||
331 | Desktop::Desktop() : | 331 | Desktop::Desktop() : |
332 | QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), | 332 | QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), |
333 | qcopBridge( 0 ), | 333 | qcopBridge( 0 ), |
334 | transferServer( 0 ), | 334 | transferServer( 0 ), |
335 | packageSlave( 0 ) | 335 | packageSlave( 0 ) |
336 | { | 336 | { |
337 | #ifdef CUSTOM_SOUND_INIT | 337 | #ifdef CUSTOM_SOUND_INIT |
338 | CUSTOM_SOUND_INIT; | 338 | CUSTOM_SOUND_INIT; |
339 | #endif | 339 | #endif |
340 | 340 | ||
341 | qpedesktop = this; | 341 | qpedesktop = this; |
342 | 342 | ||
343 | // bg = new Info( this ); | 343 | // bg = new Info( this ); |
344 | tb = new TaskBar; | 344 | tb = new TaskBar; |
345 | 345 | ||
346 | launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); | 346 | launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); |
347 | 347 | ||
348 | connect(launcher, SIGNAL(busy()), tb, SLOT(startWait())); | 348 | connect(launcher, SIGNAL(busy()), tb, SLOT(startWait())); |
349 | connect(launcher, SIGNAL(notBusy(const QString&)), tb, SLOT(stopWait(const QString&))); | 349 | connect(launcher, SIGNAL(notBusy(const QString&)), tb, SLOT(stopWait(const QString&))); |
350 | 350 | ||
351 | int displayw = qApp->desktop()->width(); | 351 | int displayw = qApp->desktop()->width(); |
352 | int displayh = qApp->desktop()->height(); | 352 | int displayh = qApp->desktop()->height(); |
353 | 353 | ||
354 | 354 | ||
355 | QSize sz = tb->sizeHint(); | 355 | QSize sz = tb->sizeHint(); |
356 | 356 | ||
357 | setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); | 357 | setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); |
358 | tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); | 358 | tb->setGeometry( 0, displayh-sz.height(), displayw, sz.height() ); |
359 | 359 | ||
360 | tb->show(); | 360 | tb->show(); |
361 | launcher->showMaximized(); | 361 | launcher->showMaximized(); |
362 | launcher->show(); | 362 | launcher->show(); |
363 | launcher->raise(); | 363 | launcher->raise(); |
364 | #if defined(QPE_HAVE_MEMALERTER) | 364 | #if defined(QPE_HAVE_MEMALERTER) |
365 | initMemalerter(); | 365 | initMemalerter(); |
366 | #endif | 366 | #endif |
367 | // start services | 367 | // start services |
368 | startTransferServer(); | 368 | startTransferServer(); |
369 | (void) new IrServer( this ); | 369 | (void) new IrServer( this ); |
370 | rereadVolumes(); | 370 | rereadVolumes(); |
371 | 371 | ||
372 | packageSlave = new PackageSlave( this ); | 372 | packageSlave = new PackageSlave( this ); |
373 | connect(qApp, SIGNAL(volumeChanged(bool)), this, SLOT(rereadVolumes())); | 373 | connect(qApp, SIGNAL(volumeChanged(bool)), this, SLOT(rereadVolumes())); |
374 | 374 | ||
375 | qApp->installEventFilter( this ); | 375 | qApp->installEventFilter( this ); |
376 | } | 376 | } |
377 | 377 | ||
378 | void Desktop::show() | 378 | void Desktop::show() |
379 | { | 379 | { |
380 | login(TRUE); | 380 | login(TRUE); |
381 | QWidget::show(); | 381 | QWidget::show(); |
382 | } | 382 | } |
383 | 383 | ||
384 | Desktop::~Desktop() | 384 | Desktop::~Desktop() |
385 | { | 385 | { |
386 | delete launcher; | 386 | delete launcher; |
387 | delete tb; | 387 | delete tb; |
388 | delete qcopBridge; | 388 | delete qcopBridge; |
389 | delete transferServer; | 389 | delete transferServer; |
390 | } | 390 | } |
391 | 391 | ||
392 | bool Desktop::recoverMemory() | 392 | bool Desktop::recoverMemory() |
393 | { | 393 | { |
394 | return tb->recoverMemory(); | 394 | return tb->recoverMemory(); |
395 | } | 395 | } |
396 | 396 | ||
diff --git a/core/launcher/qcopbridge.cpp b/core/launcher/qcopbridge.cpp index c8af919..2d084fc 100644 --- a/core/launcher/qcopbridge.cpp +++ b/core/launcher/qcopbridge.cpp | |||
@@ -1,416 +1,420 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | 20 | ||
21 | #include "qcopbridge.h" | 21 | #include "qcopbridge.h" |
22 | #include "transferserver.h" | 22 | #include "transferserver.h" |
23 | 23 | ||
24 | #include <qpe/qcopenvelope_qws.h> | 24 | #include <qpe/qcopenvelope_qws.h> |
25 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
26 | 26 | ||
27 | #include <qdir.h> | 27 | #include <qdir.h> |
28 | #include <qfile.h> | 28 | #include <qfile.h> |
29 | #include <qtextstream.h> | 29 | #include <qtextstream.h> |
30 | #include <qdatastream.h> | 30 | #include <qdatastream.h> |
31 | #include <qstringlist.h> | 31 | #include <qstringlist.h> |
32 | #include <qfileinfo.h> | 32 | #include <qfileinfo.h> |
33 | #include <qregexp.h> | 33 | #include <qregexp.h> |
34 | #include <qcopchannel_qws.h> | 34 | #include <qcopchannel_qws.h> |
35 | 35 | ||
36 | // actually this is wrong, _XOPEN_SOURCE should get defined on the commandline | ||
37 | // and it should have a proper value assigned. (Simon) | ||
38 | #if !defined(_XOPEN_SOURCE) | ||
36 | #define _XOPEN_SOURCE | 39 | #define _XOPEN_SOURCE |
40 | #endif | ||
37 | #include <pwd.h> | 41 | #include <pwd.h> |
38 | #include <sys/types.h> | 42 | #include <sys/types.h> |
39 | #include <unistd.h> | 43 | #include <unistd.h> |
40 | 44 | ||
41 | #if defined(_OS_LINUX_) | 45 | #if defined(_OS_LINUX_) |
42 | #include <shadow.h> | 46 | #include <shadow.h> |
43 | #endif | 47 | #endif |
44 | 48 | ||
45 | //#define INSECURE | 49 | //#define INSECURE |
46 | 50 | ||
47 | const int block_size = 51200; | 51 | const int block_size = 51200; |
48 | 52 | ||
49 | QCopBridge::QCopBridge( Q_UINT16 port, QObject *parent = 0, | 53 | QCopBridge::QCopBridge( Q_UINT16 port, QObject *parent, |
50 | const char* name = 0) | 54 | const char* name ) |
51 | : QServerSocket( port, 1, parent, name ), | 55 | : QServerSocket( port, 1, parent, name ), |
52 | desktopChannel( 0 ), | 56 | desktopChannel( 0 ), |
53 | cardChannel( 0 ) | 57 | cardChannel( 0 ) |
54 | { | 58 | { |
55 | if ( !ok() ) | 59 | if ( !ok() ) |
56 | qWarning( "Failed to bind to port %d", port ); | 60 | qWarning( "Failed to bind to port %d", port ); |
57 | else { | 61 | else { |
58 | desktopChannel = new QCopChannel( "QPE/Desktop", this ); | 62 | desktopChannel = new QCopChannel( "QPE/Desktop", this ); |
59 | connect( desktopChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 63 | connect( desktopChannel, SIGNAL(received(const QCString &, const QByteArray &)), |
60 | this, SLOT(desktopMessage( const QCString &, const QByteArray &)) ); | 64 | this, SLOT(desktopMessage( const QCString &, const QByteArray &)) ); |
61 | cardChannel = new QCopChannel( "QPE/Card", this ); | 65 | cardChannel = new QCopChannel( "QPE/Card", this ); |
62 | connect( cardChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 66 | connect( cardChannel, SIGNAL(received(const QCString &, const QByteArray &)), |
63 | this, SLOT(desktopMessage( const QCString &, const QByteArray &)) ); | 67 | this, SLOT(desktopMessage( const QCString &, const QByteArray &)) ); |
64 | } | 68 | } |
65 | sendSync = FALSE; | 69 | sendSync = FALSE; |
66 | } | 70 | } |
67 | 71 | ||
68 | QCopBridge::~QCopBridge() | 72 | QCopBridge::~QCopBridge() |
69 | { | 73 | { |
70 | delete desktopChannel; | 74 | delete desktopChannel; |
71 | } | 75 | } |
72 | 76 | ||
73 | void QCopBridge::newConnection( int socket ) | 77 | void QCopBridge::newConnection( int socket ) |
74 | { | 78 | { |
75 | QCopBridgePI *pi = new QCopBridgePI( socket, this ); | 79 | QCopBridgePI *pi = new QCopBridgePI( socket, this ); |
76 | openConnections.append( pi ); | 80 | openConnections.append( pi ); |
77 | connect ( pi, SIGNAL( connectionClosed( QCopBridgePI *) ), this, SLOT( connectionClosed( QCopBridgePI *) ) ); | 81 | connect ( pi, SIGNAL( connectionClosed( QCopBridgePI *) ), this, SLOT( connectionClosed( QCopBridgePI *) ) ); |
78 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; | 82 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; |
79 | 83 | ||
80 | if ( sendSync ) { | 84 | if ( sendSync ) { |
81 | pi ->startSync(); | 85 | pi ->startSync(); |
82 | sendSync = FALSE; | 86 | sendSync = FALSE; |
83 | } | 87 | } |
84 | } | 88 | } |
85 | 89 | ||
86 | void QCopBridge::connectionClosed( QCopBridgePI *pi ) | 90 | void QCopBridge::connectionClosed( QCopBridgePI *pi ) |
87 | { | 91 | { |
88 | openConnections.remove( pi ); | 92 | openConnections.remove( pi ); |
89 | if ( openConnections.count() == 0 ) { | 93 | if ( openConnections.count() == 0 ) { |
90 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 94 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
91 | } | 95 | } |
92 | } | 96 | } |
93 | 97 | ||
94 | void QCopBridge::closeOpenConnections() | 98 | void QCopBridge::closeOpenConnections() |
95 | { | 99 | { |
96 | QCopBridgePI *pi; | 100 | QCopBridgePI *pi; |
97 | for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() ) | 101 | for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() ) |
98 | pi->close(); | 102 | pi->close(); |
99 | } | 103 | } |
100 | 104 | ||
101 | 105 | ||
102 | void QCopBridge::desktopMessage( const QCString &command, const QByteArray &args ) | 106 | void QCopBridge::desktopMessage( const QCString &command, const QByteArray &args ) |
103 | { | 107 | { |
104 | command.stripWhiteSpace(); | 108 | command.stripWhiteSpace(); |
105 | 109 | ||
106 | int paren = command.find( "(" ); | 110 | int paren = command.find( "(" ); |
107 | if ( paren <= 0 ) { | 111 | if ( paren <= 0 ) { |
108 | qDebug("DesktopMessage: bad qcop syntax"); | 112 | qDebug("DesktopMessage: bad qcop syntax"); |
109 | return; | 113 | return; |
110 | } | 114 | } |
111 | 115 | ||
112 | QString params = command.mid( paren + 1 ); | 116 | QString params = command.mid( paren + 1 ); |
113 | if ( params[params.length()-1] != ')' ) { | 117 | if ( params[params.length()-1] != ')' ) { |
114 | qDebug("DesktopMessage: bad qcop syntax"); | 118 | qDebug("DesktopMessage: bad qcop syntax"); |
115 | return; | 119 | return; |
116 | } | 120 | } |
117 | 121 | ||
118 | params.truncate( params.length()-1 ); | 122 | params.truncate( params.length()-1 ); |
119 | 123 | ||
120 | QStringList paramList = QStringList::split( ",", params ); | 124 | QStringList paramList = QStringList::split( ",", params ); |
121 | QString data; | 125 | QString data; |
122 | if ( paramList.count() ) { | 126 | if ( paramList.count() ) { |
123 | QDataStream stream( args, IO_ReadOnly ); | 127 | QDataStream stream( args, IO_ReadOnly ); |
124 | for ( QStringList::Iterator it = paramList.begin(); it != paramList.end(); ++it ) { | 128 | for ( QStringList::Iterator it = paramList.begin(); it != paramList.end(); ++it ) { |
125 | QString str; | 129 | QString str; |
126 | if ( *it == "QString" ) { | 130 | if ( *it == "QString" ) { |
127 | stream >> str; | 131 | stream >> str; |
128 | } else if ( *it == "QCString" ) { | 132 | } else if ( *it == "QCString" ) { |
129 | QCString cstr; | 133 | QCString cstr; |
130 | stream >> cstr; | 134 | stream >> cstr; |
131 | str = QString::fromLocal8Bit( cstr ); | 135 | str = QString::fromLocal8Bit( cstr ); |
132 | } else if ( *it == "int" ) { | 136 | } else if ( *it == "int" ) { |
133 | int i; | 137 | int i; |
134 | stream >> i; | 138 | stream >> i; |
135 | str = QString::number( i ); | 139 | str = QString::number( i ); |
136 | } else if ( *it == "bool" ) { | 140 | } else if ( *it == "bool" ) { |
137 | int i; | 141 | int i; |
138 | stream >> i; | 142 | stream >> i; |
139 | str = QString::number( i ); | 143 | str = QString::number( i ); |
140 | } else { | 144 | } else { |
141 | qDebug(" cannot route the argument type %s through the qcop bridge", (*it).latin1() ); | 145 | qDebug(" cannot route the argument type %s through the qcop bridge", (*it).latin1() ); |
142 | return; | 146 | return; |
143 | } | 147 | } |
144 | str.replace( QRegExp("&"), "&" ); | 148 | str.replace( QRegExp("&"), "&" ); |
145 | str.replace( QRegExp(" "), "&0x20;" ); | 149 | str.replace( QRegExp(" "), "&0x20;" ); |
146 | str.replace( QRegExp("\n"), "&0x0d;" ); | 150 | str.replace( QRegExp("\n"), "&0x0d;" ); |
147 | str.replace( QRegExp("\r"), "&0x0a;" ); | 151 | str.replace( QRegExp("\r"), "&0x0a;" ); |
148 | data += " " + str; | 152 | data += " " + str; |
149 | } | 153 | } |
150 | } | 154 | } |
151 | QString sendCommand = QString(command.data()) + data; | 155 | QString sendCommand = QString(command.data()) + data; |
152 | // send the command to all open connections | 156 | // send the command to all open connections |
153 | if ( command == "startSync()" ) { | 157 | if ( command == "startSync()" ) { |
154 | // we need to buffer it a bit | 158 | // we need to buffer it a bit |
155 | sendSync = TRUE; | 159 | sendSync = TRUE; |
156 | startTimer( 20000 ); | 160 | startTimer( 20000 ); |
157 | } | 161 | } |
158 | 162 | ||
159 | QCopBridgePI *pi; | 163 | QCopBridgePI *pi; |
160 | for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() ) { | 164 | for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() ) { |
161 | pi->sendDesktopMessage( sendCommand ); | 165 | pi->sendDesktopMessage( sendCommand ); |
162 | } | 166 | } |
163 | } | 167 | } |
164 | 168 | ||
165 | void QCopBridge::timerEvent( QTimerEvent * ) | 169 | void QCopBridge::timerEvent( QTimerEvent * ) |
166 | { | 170 | { |
167 | sendSync = FALSE; | 171 | sendSync = FALSE; |
168 | killTimers(); | 172 | killTimers(); |
169 | } | 173 | } |
170 | 174 | ||
171 | 175 | ||
172 | QCopBridgePI::QCopBridgePI( int socket, QObject *parent = 0, const char* name = 0 ) | 176 | QCopBridgePI::QCopBridgePI( int socket, QObject *parent, const char* name ) |
173 | : QSocket( parent, name ) | 177 | : QSocket( parent, name ) |
174 | { | 178 | { |
175 | setSocket( socket ); | 179 | setSocket( socket ); |
176 | 180 | ||
177 | peerport = peerPort(); | 181 | peerport = peerPort(); |
178 | peeraddress = peerAddress(); | 182 | peeraddress = peerAddress(); |
179 | 183 | ||
180 | #ifndef INSECURE | 184 | #ifndef INSECURE |
181 | if ( !accessAuthorized(peeraddress) ) { | 185 | if ( !accessAuthorized(peeraddress) ) { |
182 | state = Forbidden; | 186 | state = Forbidden; |
183 | startTimer( 0 ); | 187 | startTimer( 0 ); |
184 | } else | 188 | } else |
185 | #endif | 189 | #endif |
186 | { | 190 | { |
187 | state = Connected; | 191 | state = Connected; |
188 | sendSync = FALSE; | 192 | sendSync = FALSE; |
189 | connect( this, SIGNAL( readyRead() ), SLOT( read() ) ); | 193 | connect( this, SIGNAL( readyRead() ), SLOT( read() ) ); |
190 | connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) ); | 194 | connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) ); |
191 | 195 | ||
192 | send( "220 Qtopia QCop bridge ready!" ); | 196 | send( "220 Qtopia QCop bridge ready!" ); |
193 | state = Wait_USER; | 197 | state = Wait_USER; |
194 | 198 | ||
195 | // idle timer to close connections when not used anymore | 199 | // idle timer to close connections when not used anymore |
196 | startTimer( 60000 ); | 200 | startTimer( 60000 ); |
197 | connected = TRUE; | 201 | connected = TRUE; |
198 | } | 202 | } |
199 | } | 203 | } |
200 | 204 | ||
201 | 205 | ||
202 | QCopBridgePI::~QCopBridgePI() | 206 | QCopBridgePI::~QCopBridgePI() |
203 | { | 207 | { |
204 | 208 | ||
205 | } | 209 | } |
206 | 210 | ||
207 | void QCopBridgePI::connectionClosed() | 211 | void QCopBridgePI::connectionClosed() |
208 | { | 212 | { |
209 | emit connectionClosed( this ); | 213 | emit connectionClosed( this ); |
210 | // qDebug( "Debug: Connection closed" ); | 214 | // qDebug( "Debug: Connection closed" ); |
211 | delete this; | 215 | delete this; |
212 | } | 216 | } |
213 | 217 | ||
214 | void QCopBridgePI::sendDesktopMessage( const QString &msg ) | 218 | void QCopBridgePI::sendDesktopMessage( const QString &msg ) |
215 | { | 219 | { |
216 | QString str = "CALL QPE/Desktop " + msg; | 220 | QString str = "CALL QPE/Desktop " + msg; |
217 | send ( str ); | 221 | send ( str ); |
218 | } | 222 | } |
219 | 223 | ||
220 | 224 | ||
221 | void QCopBridgePI::send( const QString& msg ) | 225 | void QCopBridgePI::send( const QString& msg ) |
222 | { | 226 | { |
223 | QTextStream os( this ); | 227 | QTextStream os( this ); |
224 | os << msg << endl; | 228 | os << msg << endl; |
225 | //qDebug( "sending qcop message: %s", msg.latin1() ); | 229 | //qDebug( "sending qcop message: %s", msg.latin1() ); |
226 | } | 230 | } |
227 | 231 | ||
228 | void QCopBridgePI::read() | 232 | void QCopBridgePI::read() |
229 | { | 233 | { |
230 | while ( canReadLine() ) | 234 | while ( canReadLine() ) |
231 | process( readLine().stripWhiteSpace() ); | 235 | process( readLine().stripWhiteSpace() ); |
232 | } | 236 | } |
233 | 237 | ||
234 | bool QCopBridgePI::checkUser( const QString& user ) | 238 | bool QCopBridgePI::checkUser( const QString& user ) |
235 | { | 239 | { |
236 | if ( user.isEmpty() ) return FALSE; | 240 | if ( user.isEmpty() ) return FALSE; |
237 | 241 | ||
238 | struct passwd *pw; | 242 | struct passwd *pw; |
239 | pw = getpwuid( geteuid() ); | 243 | pw = getpwuid( geteuid() ); |
240 | QString euser = QString::fromLocal8Bit( pw->pw_name ); | 244 | QString euser = QString::fromLocal8Bit( pw->pw_name ); |
241 | return user == euser; | 245 | return user == euser; |
242 | } | 246 | } |
243 | 247 | ||
244 | bool QCopBridgePI::checkPassword( const QString& password ) | 248 | bool QCopBridgePI::checkPassword( const QString& password ) |
245 | { | 249 | { |
246 | // ### HACK for testing on local host | 250 | // ### HACK for testing on local host |
247 | return true; | 251 | return true; |
248 | 252 | ||
249 | /* | 253 | /* |
250 | struct passwd *pw = 0; | 254 | struct passwd *pw = 0; |
251 | struct spwd *spw = 0; | 255 | struct spwd *spw = 0; |
252 | 256 | ||
253 | pw = getpwuid( geteuid() ); | 257 | pw = getpwuid( geteuid() ); |
254 | spw = getspnam( pw->pw_name ); | 258 | spw = getspnam( pw->pw_name ); |
255 | 259 | ||
256 | QString cpwd = QString::fromLocal8Bit( pw->pw_passwd ); | 260 | QString cpwd = QString::fromLocal8Bit( pw->pw_passwd ); |
257 | if ( cpwd == "x" && spw ) | 261 | if ( cpwd == "x" && spw ) |
258 | cpwd = QString::fromLocal8Bit( spw->sp_pwdp ); | 262 | cpwd = QString::fromLocal8Bit( spw->sp_pwdp ); |
259 | 263 | ||
260 | QString cpassword = QString::fromLocal8Bit( crypt( password.local8Bit(), cpwd.local8Bit() ) ); | 264 | QString cpassword = QString::fromLocal8Bit( crypt( password.local8Bit(), cpwd.local8Bit() ) ); |
261 | return cpwd == cpassword; | 265 | return cpwd == cpassword; |
262 | */ | 266 | */ |
263 | } | 267 | } |
264 | 268 | ||
265 | void QCopBridgePI::process( const QString& message ) | 269 | void QCopBridgePI::process( const QString& message ) |
266 | { | 270 | { |
267 | //qDebug( "Command: %s", message.latin1() ); | 271 | //qDebug( "Command: %s", message.latin1() ); |
268 | 272 | ||
269 | // split message using "," as separator | 273 | // split message using "," as separator |
270 | QStringList msg = QStringList::split( " ", message ); | 274 | QStringList msg = QStringList::split( " ", message ); |
271 | if ( msg.isEmpty() ) return; | 275 | if ( msg.isEmpty() ) return; |
272 | 276 | ||
273 | // command token | 277 | // command token |
274 | QString cmd = msg[0].upper(); | 278 | QString cmd = msg[0].upper(); |
275 | 279 | ||
276 | // argument token | 280 | // argument token |
277 | QString arg; | 281 | QString arg; |
278 | if ( msg.count() >= 2 ) | 282 | if ( msg.count() >= 2 ) |
279 | arg = msg[1]; | 283 | arg = msg[1]; |
280 | 284 | ||
281 | // we always respond to QUIT, regardless of state | 285 | // we always respond to QUIT, regardless of state |
282 | if ( cmd == "QUIT" ) { | 286 | if ( cmd == "QUIT" ) { |
283 | send( "211 Have a nice day!" ); | 287 | send( "211 Have a nice day!" ); |
284 | delete this; | 288 | delete this; |
285 | return; | 289 | return; |
286 | } | 290 | } |
287 | 291 | ||
288 | // connected to client | 292 | // connected to client |
289 | if ( Connected == state ) | 293 | if ( Connected == state ) |
290 | return; | 294 | return; |
291 | 295 | ||
292 | // waiting for user name | 296 | // waiting for user name |
293 | if ( Wait_USER == state ) { | 297 | if ( Wait_USER == state ) { |
294 | 298 | ||
295 | if ( cmd != "USER" || msg.count() < 2 || !checkUser( arg ) ) { | 299 | if ( cmd != "USER" || msg.count() < 2 || !checkUser( arg ) ) { |
296 | send( "530 Please login with USER and PASS" ); | 300 | send( "530 Please login with USER and PASS" ); |
297 | return; | 301 | return; |
298 | } | 302 | } |
299 | send( "331 User name ok, need password" ); | 303 | send( "331 User name ok, need password" ); |
300 | state = Wait_PASS; | 304 | state = Wait_PASS; |
301 | return; | 305 | return; |
302 | } | 306 | } |
303 | 307 | ||
304 | // waiting for password | 308 | // waiting for password |
305 | if ( Wait_PASS == state ) { | 309 | if ( Wait_PASS == state ) { |
306 | 310 | ||
307 | if ( cmd != "PASS" || !checkPassword( arg ) ) { | 311 | if ( cmd != "PASS" || !checkPassword( arg ) ) { |
308 | //if ( cmd != "PASS" || msg.count() < 2 || !checkPassword( arg ) ) { | 312 | //if ( cmd != "PASS" || msg.count() < 2 || !checkPassword( arg ) ) { |
309 | send( "530 Please login with USER and PASS" ); | 313 | send( "530 Please login with USER and PASS" ); |
310 | return; | 314 | return; |
311 | } | 315 | } |
312 | send( "230 User logged in, proceed" ); | 316 | send( "230 User logged in, proceed" ); |
313 | state = Ready; | 317 | state = Ready; |
314 | if ( sendSync ) { | 318 | if ( sendSync ) { |
315 | sendDesktopMessage( "startSync()" ); | 319 | sendDesktopMessage( "startSync()" ); |
316 | sendSync = FALSE; | 320 | sendSync = FALSE; |
317 | } | 321 | } |
318 | return; | 322 | return; |
319 | } | 323 | } |
320 | 324 | ||
321 | // noop (NOOP) | 325 | // noop (NOOP) |
322 | else if ( cmd == "NOOP" ) { | 326 | else if ( cmd == "NOOP" ) { |
323 | connected = TRUE; | 327 | connected = TRUE; |
324 | send( "200 Command okay" ); | 328 | send( "200 Command okay" ); |
325 | } | 329 | } |
326 | 330 | ||
327 | // call (CALL) | 331 | // call (CALL) |
328 | else if ( cmd == "CALL" ) { | 332 | else if ( cmd == "CALL" ) { |
329 | 333 | ||
330 | // example: call QPE/System execute(QString) addressbook | 334 | // example: call QPE/System execute(QString) addressbook |
331 | 335 | ||
332 | if ( msg.count() < 3 ) { | 336 | if ( msg.count() < 3 ) { |
333 | send( "500 Syntax error, command unrecognized" ); | 337 | send( "500 Syntax error, command unrecognized" ); |
334 | } | 338 | } |
335 | else { | 339 | else { |
336 | 340 | ||
337 | QString channel = msg[1]; | 341 | QString channel = msg[1]; |
338 | QString command = msg[2]; | 342 | QString command = msg[2]; |
339 | 343 | ||
340 | command.stripWhiteSpace(); | 344 | command.stripWhiteSpace(); |
341 | 345 | ||
342 | int paren = command.find( "(" ); | 346 | int paren = command.find( "(" ); |
343 | if ( paren <= 0 ) { | 347 | if ( paren <= 0 ) { |
344 | send( "500 Syntax error, command unrecognized" ); | 348 | send( "500 Syntax error, command unrecognized" ); |
345 | return; | 349 | return; |
346 | } | 350 | } |
347 | 351 | ||
348 | QString params = command.mid( paren + 1 ); | 352 | QString params = command.mid( paren + 1 ); |
349 | if ( params[params.length()-1] != ')' ) { | 353 | if ( params[params.length()-1] != ')' ) { |
350 | send( "500 Syntax error, command unrecognized" ); | 354 | send( "500 Syntax error, command unrecognized" ); |
351 | return; | 355 | return; |
352 | } | 356 | } |
353 | 357 | ||
354 | params.truncate( params.length()-1 ); | 358 | params.truncate( params.length()-1 ); |
355 | QByteArray buffer; | 359 | QByteArray buffer; |
356 | QDataStream ds( buffer, IO_WriteOnly ); | 360 | QDataStream ds( buffer, IO_WriteOnly ); |
357 | 361 | ||
358 | int msgId = 3; | 362 | int msgId = 3; |
359 | 363 | ||
360 | QStringList paramList = QStringList::split( ",", params ); | 364 | QStringList paramList = QStringList::split( ",", params ); |
361 | if ( paramList.count() > msg.count() - 3 ) { | 365 | if ( paramList.count() > msg.count() - 3 ) { |
362 | send( "500 Syntax error, command unrecognized" ); | 366 | send( "500 Syntax error, command unrecognized" ); |
363 | return; | 367 | return; |
364 | } | 368 | } |
365 | 369 | ||
366 | for ( QStringList::Iterator it = paramList.begin(); it != paramList.end(); ++it ) { | 370 | for ( QStringList::Iterator it = paramList.begin(); it != paramList.end(); ++it ) { |
367 | 371 | ||
368 | QString arg = msg[msgId]; | 372 | QString arg = msg[msgId]; |
369 | arg.replace( QRegExp("&0x20;"), " " ); | 373 | arg.replace( QRegExp("&0x20;"), " " ); |
370 | arg.replace( QRegExp("&"), "&" ); | 374 | arg.replace( QRegExp("&"), "&" ); |
371 | arg.replace( QRegExp("&0x0d;"), "\n" ); | 375 | arg.replace( QRegExp("&0x0d;"), "\n" ); |
372 | arg.replace( QRegExp("&0x0a;"), "\r" ); | 376 | arg.replace( QRegExp("&0x0a;"), "\r" ); |
373 | if ( *it == "QString" ) | 377 | if ( *it == "QString" ) |
374 | ds << arg; | 378 | ds << arg; |
375 | else if ( *it == "QCString" ) | 379 | else if ( *it == "QCString" ) |
376 | ds << arg.local8Bit(); | 380 | ds << arg.local8Bit(); |
377 | else if ( *it == "int" ) | 381 | else if ( *it == "int" ) |
378 | ds << arg.toInt(); | 382 | ds << arg.toInt(); |
379 | else if ( *it == "bool" ) | 383 | else if ( *it == "bool" ) |
380 | ds << arg.toInt(); | 384 | ds << arg.toInt(); |
381 | else { | 385 | else { |
382 | send( "500 Syntax error, command unrecognized" ); | 386 | send( "500 Syntax error, command unrecognized" ); |
383 | return; | 387 | return; |
384 | } | 388 | } |
385 | msgId++; | 389 | msgId++; |
386 | } | 390 | } |
387 | 391 | ||
388 | if ( !QCopChannel::isRegistered( channel.latin1() ) ) { | 392 | if ( !QCopChannel::isRegistered( channel.latin1() ) ) { |
389 | // send message back about it | 393 | // send message back about it |
390 | QString answer = "599 ChannelNotRegistered " + channel; | 394 | QString answer = "599 ChannelNotRegistered " + channel; |
391 | send( answer ); | 395 | send( answer ); |
392 | return; | 396 | return; |
393 | } | 397 | } |
394 | 398 | ||
395 | if ( paramList.count() ) | 399 | if ( paramList.count() ) |
396 | QCopChannel::send( channel.latin1(), command.latin1(), buffer ); | 400 | QCopChannel::send( channel.latin1(), command.latin1(), buffer ); |
397 | else | 401 | else |
398 | QCopChannel::send( channel.latin1(), command.latin1() ); | 402 | QCopChannel::send( channel.latin1(), command.latin1() ); |
399 | 403 | ||
400 | send( "200 Command okay" ); | 404 | send( "200 Command okay" ); |
401 | } | 405 | } |
402 | } | 406 | } |
403 | // not implemented | 407 | // not implemented |
404 | else | 408 | else |
405 | send( "502 Command not implemented" ); | 409 | send( "502 Command not implemented" ); |
406 | } | 410 | } |
407 | 411 | ||
408 | 412 | ||
409 | 413 | ||
410 | void QCopBridgePI::timerEvent( QTimerEvent * ) | 414 | void QCopBridgePI::timerEvent( QTimerEvent * ) |
411 | { | 415 | { |
412 | if ( connected ) | 416 | if ( connected ) |
413 | connected = FALSE; | 417 | connected = FALSE; |
414 | else | 418 | else |
415 | connectionClosed(); | 419 | connectionClosed(); |
416 | } | 420 | } |
diff --git a/core/launcher/transferserver.cpp b/core/launcher/transferserver.cpp index 87a49eb..7294f9c 100644 --- a/core/launcher/transferserver.cpp +++ b/core/launcher/transferserver.cpp | |||
@@ -1,340 +1,340 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of Qtopia Environment. | 4 | ** This file is part of Qtopia Environment. |
5 | ** | 5 | ** |
6 | ** This file may be distributed and/or modified under the terms of the | 6 | ** This file may be distributed and/or modified under the terms of the |
7 | ** GNU General Public License version 2 as published by the Free Software | 7 | ** GNU General Public License version 2 as published by the Free Software |
8 | ** Foundation and appearing in the file LICENSE.GPL included in the | 8 | ** Foundation and appearing in the file LICENSE.GPL included in the |
9 | ** packaging of this file. | 9 | ** packaging of this file. |
10 | ** | 10 | ** |
11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | 11 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE |
12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | 12 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. |
13 | ** | 13 | ** |
14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | 14 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. |
15 | ** | 15 | ** |
16 | ** Contact info@trolltech.com if any conditions of this licensing are | 16 | ** Contact info@trolltech.com if any conditions of this licensing are |
17 | ** not clear to you. | 17 | ** not clear to you. |
18 | ** | 18 | ** |
19 | **********************************************************************/ | 19 | **********************************************************************/ |
20 | #define _XOPEN_SOURCE | 20 | #define _XOPEN_SOURCE |
21 | #include <pwd.h> | 21 | #include <pwd.h> |
22 | #include <sys/types.h> | 22 | #include <sys/types.h> |
23 | #include <unistd.h> | 23 | #include <unistd.h> |
24 | #include <stdlib.h> | 24 | #include <stdlib.h> |
25 | 25 | ||
26 | #if defined(_OS_LINUX_) | 26 | #if defined(_OS_LINUX_) |
27 | #include <shadow.h> | 27 | #include <shadow.h> |
28 | #endif | 28 | #endif |
29 | 29 | ||
30 | #include <qdir.h> | 30 | #include <qdir.h> |
31 | #include <qfile.h> | 31 | #include <qfile.h> |
32 | #include <qtextstream.h> | 32 | #include <qtextstream.h> |
33 | #include <qdatastream.h> | 33 | #include <qdatastream.h> |
34 | #include <qmessagebox.h> | 34 | #include <qmessagebox.h> |
35 | #include <qstringlist.h> | 35 | #include <qstringlist.h> |
36 | #include <qfileinfo.h> | 36 | #include <qfileinfo.h> |
37 | #include <qregexp.h> | 37 | #include <qregexp.h> |
38 | //#include <qpe/qcopchannel_qws.h> | 38 | //#include <qpe/qcopchannel_qws.h> |
39 | #include <qpe/qprocess.h> | ||
40 | #include <qpe/process.h> | 39 | #include <qpe/process.h> |
41 | #include <qpe/config.h> | 40 | #include <qpe/config.h> |
42 | #include <qpe/qcopenvelope_qws.h> | 41 | #include <qpe/qcopenvelope_qws.h> |
43 | 42 | ||
44 | #include "transferserver.h" | 43 | #include "transferserver.h" |
44 | #include "qprocess.h" | ||
45 | 45 | ||
46 | const int block_size = 51200; | 46 | const int block_size = 51200; |
47 | 47 | ||
48 | TransferServer::TransferServer( Q_UINT16 port, QObject *parent = 0, | 48 | TransferServer::TransferServer( Q_UINT16 port, QObject *parent, |
49 | const char* name = 0) | 49 | const char* name ) |
50 | : QServerSocket( port, 1, parent, name ) | 50 | : QServerSocket( port, 1, parent, name ) |
51 | { | 51 | { |
52 | if ( !ok() ) | 52 | if ( !ok() ) |
53 | qWarning( "Failed to bind to port %d", port ); | 53 | qWarning( "Failed to bind to port %d", port ); |
54 | } | 54 | } |
55 | 55 | ||
56 | TransferServer::~TransferServer() | 56 | TransferServer::~TransferServer() |
57 | { | 57 | { |
58 | 58 | ||
59 | } | 59 | } |
60 | 60 | ||
61 | void TransferServer::newConnection( int socket ) | 61 | void TransferServer::newConnection( int socket ) |
62 | { | 62 | { |
63 | (void) new ServerPI( socket, this ); | 63 | (void) new ServerPI( socket, this ); |
64 | } | 64 | } |
65 | 65 | ||
66 | bool accessAuthorized(QHostAddress peeraddress) | 66 | bool accessAuthorized(QHostAddress peeraddress) |
67 | { | 67 | { |
68 | Config cfg("Security"); | 68 | Config cfg("Security"); |
69 | cfg.setGroup("Sync"); | 69 | cfg.setGroup("Sync"); |
70 | uint auth_peer = cfg.readNumEntry("auth_peer",0xc0a80100); | 70 | uint auth_peer = cfg.readNumEntry("auth_peer",0xc0a80100); |
71 | uint auth_peer_bits = cfg.readNumEntry("auth_peer_bits",24); | 71 | uint auth_peer_bits = cfg.readNumEntry("auth_peer_bits",24); |
72 | bool ok = (peeraddress.ip4Addr() & (((1<<auth_peer_bits)-1)<<(32-auth_peer_bits))) | 72 | bool ok = (peeraddress.ip4Addr() & (((1<<auth_peer_bits)-1)<<(32-auth_peer_bits))) |
73 | == auth_peer; | 73 | == auth_peer; |
74 | /* Allows denial-of-service attack. | 74 | /* Allows denial-of-service attack. |
75 | if ( !ok ) { | 75 | if ( !ok ) { |
76 | QMessageBox::warning(0,tr("Security"), | 76 | QMessageBox::warning(0,tr("Security"), |
77 | tr("<p>An attempt to access this device from %1 has been denied.") | 77 | tr("<p>An attempt to access this device from %1 has been denied.") |
78 | .arg(peeraddress.toString())); | 78 | .arg(peeraddress.toString())); |
79 | } | 79 | } |
80 | */ | 80 | */ |
81 | return ok; | 81 | return ok; |
82 | } | 82 | } |
83 | 83 | ||
84 | ServerPI::ServerPI( int socket, QObject *parent = 0, const char* name = 0 ) | 84 | ServerPI::ServerPI( int socket, QObject *parent, const char* name ) |
85 | : QSocket( parent, name ) , dtp( 0 ), serversocket( 0 ), waitsocket( 0 ) | 85 | : QSocket( parent, name ) , dtp( 0 ), serversocket( 0 ), waitsocket( 0 ) |
86 | { | 86 | { |
87 | state = Connected; | 87 | state = Connected; |
88 | 88 | ||
89 | setSocket( socket ); | 89 | setSocket( socket ); |
90 | 90 | ||
91 | peerport = peerPort(); | 91 | peerport = peerPort(); |
92 | peeraddress = peerAddress(); | 92 | peeraddress = peerAddress(); |
93 | 93 | ||
94 | #ifndef INSECURE | 94 | #ifndef INSECURE |
95 | if ( !accessAuthorized(peeraddress) ) { | 95 | if ( !accessAuthorized(peeraddress) ) { |
96 | state = Forbidden; | 96 | state = Forbidden; |
97 | startTimer( 0 ); | 97 | startTimer( 0 ); |
98 | } else | 98 | } else |
99 | #endif | 99 | #endif |
100 | { | 100 | { |
101 | connect( this, SIGNAL( readyRead() ), SLOT( read() ) ); | 101 | connect( this, SIGNAL( readyRead() ), SLOT( read() ) ); |
102 | connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) ); | 102 | connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) ); |
103 | 103 | ||
104 | passiv = FALSE; | 104 | passiv = FALSE; |
105 | for( int i = 0; i < 4; i++ ) | 105 | for( int i = 0; i < 4; i++ ) |
106 | wait[i] = FALSE; | 106 | wait[i] = FALSE; |
107 | 107 | ||
108 | send( "220 Qtopia transfer service ready!" ); | 108 | send( "220 Qtopia transfer service ready!" ); |
109 | state = Wait_USER; | 109 | state = Wait_USER; |
110 | 110 | ||
111 | dtp = new ServerDTP( this ); | 111 | dtp = new ServerDTP( this ); |
112 | connect( dtp, SIGNAL( completed() ), SLOT( dtpCompleted() ) ); | 112 | connect( dtp, SIGNAL( completed() ), SLOT( dtpCompleted() ) ); |
113 | connect( dtp, SIGNAL( failed() ), SLOT( dtpFailed() ) ); | 113 | connect( dtp, SIGNAL( failed() ), SLOT( dtpFailed() ) ); |
114 | connect( dtp, SIGNAL( error( int ) ), SLOT( dtpError( int ) ) ); | 114 | connect( dtp, SIGNAL( error( int ) ), SLOT( dtpError( int ) ) ); |
115 | 115 | ||
116 | 116 | ||
117 | directory = QDir::currentDirPath(); | 117 | directory = QDir::currentDirPath(); |
118 | 118 | ||
119 | static int p = 1024; | 119 | static int p = 1024; |
120 | 120 | ||
121 | while ( !serversocket || !serversocket->ok() ) { | 121 | while ( !serversocket || !serversocket->ok() ) { |
122 | delete serversocket; | 122 | delete serversocket; |
123 | serversocket = new ServerSocket( ++p, this ); | 123 | serversocket = new ServerSocket( ++p, this ); |
124 | } | 124 | } |
125 | connect( serversocket, SIGNAL( newIncomming( int ) ), | 125 | connect( serversocket, SIGNAL( newIncomming( int ) ), |
126 | SLOT( newConnection( int ) ) ); | 126 | SLOT( newConnection( int ) ) ); |
127 | } | 127 | } |
128 | } | 128 | } |
129 | 129 | ||
130 | ServerPI::~ServerPI() | 130 | ServerPI::~ServerPI() |
131 | { | 131 | { |
132 | 132 | ||
133 | } | 133 | } |
134 | 134 | ||
135 | void ServerPI::connectionClosed() | 135 | void ServerPI::connectionClosed() |
136 | { | 136 | { |
137 | // qDebug( "Debug: Connection closed" ); | 137 | // qDebug( "Debug: Connection closed" ); |
138 | delete this; | 138 | delete this; |
139 | } | 139 | } |
140 | 140 | ||
141 | void ServerPI::send( const QString& msg ) | 141 | void ServerPI::send( const QString& msg ) |
142 | { | 142 | { |
143 | QTextStream os( this ); | 143 | QTextStream os( this ); |
144 | os << msg << endl; | 144 | os << msg << endl; |
145 | //qDebug( "Reply: %s", msg.latin1() ); | 145 | //qDebug( "Reply: %s", msg.latin1() ); |
146 | } | 146 | } |
147 | 147 | ||
148 | void ServerPI::read() | 148 | void ServerPI::read() |
149 | { | 149 | { |
150 | while ( canReadLine() ) | 150 | while ( canReadLine() ) |
151 | process( readLine().stripWhiteSpace() ); | 151 | process( readLine().stripWhiteSpace() ); |
152 | } | 152 | } |
153 | 153 | ||
154 | bool ServerPI::checkUser( const QString& user ) | 154 | bool ServerPI::checkUser( const QString& user ) |
155 | { | 155 | { |
156 | if ( user.isEmpty() ) return FALSE; | 156 | if ( user.isEmpty() ) return FALSE; |
157 | 157 | ||
158 | struct passwd *pw; | 158 | struct passwd *pw; |
159 | pw = getpwuid( geteuid() ); | 159 | pw = getpwuid( geteuid() ); |
160 | QString euser = QString::fromLocal8Bit( pw->pw_name ); | 160 | QString euser = QString::fromLocal8Bit( pw->pw_name ); |
161 | return user == euser; | 161 | return user == euser; |
162 | } | 162 | } |
163 | 163 | ||
164 | bool ServerPI::checkPassword( const QString& /* password */ ) | 164 | bool ServerPI::checkPassword( const QString& /* password */ ) |
165 | { | 165 | { |
166 | // ### HACK for testing on local host | 166 | // ### HACK for testing on local host |
167 | return true; | 167 | return true; |
168 | 168 | ||
169 | /* | 169 | /* |
170 | struct passwd *pw = 0; | 170 | struct passwd *pw = 0; |
171 | struct spwd *spw = 0; | 171 | struct spwd *spw = 0; |
172 | 172 | ||
173 | pw = getpwuid( geteuid() ); | 173 | pw = getpwuid( geteuid() ); |
174 | spw = getspnam( pw->pw_name ); | 174 | spw = getspnam( pw->pw_name ); |
175 | 175 | ||
176 | QString cpwd = QString::fromLocal8Bit( pw->pw_passwd ); | 176 | QString cpwd = QString::fromLocal8Bit( pw->pw_passwd ); |
177 | if ( cpwd == "x" && spw ) | 177 | if ( cpwd == "x" && spw ) |
178 | cpwd = QString::fromLocal8Bit( spw->sp_pwdp ); | 178 | cpwd = QString::fromLocal8Bit( spw->sp_pwdp ); |
179 | 179 | ||
180 | QString cpassword = QString::fromLocal8Bit( crypt( password.local8Bit(), cpwd.local8Bit() ) ); | 180 | QString cpassword = QString::fromLocal8Bit( crypt( password.local8Bit(), cpwd.local8Bit() ) ); |
181 | return cpwd == cpassword; | 181 | return cpwd == cpassword; |
182 | */ | 182 | */ |
183 | } | 183 | } |
184 | 184 | ||
185 | bool ServerPI::checkReadFile( const QString& file ) | 185 | bool ServerPI::checkReadFile( const QString& file ) |
186 | { | 186 | { |
187 | QString filename; | 187 | QString filename; |
188 | 188 | ||
189 | if ( file[0] != "/" ) | 189 | if ( file[0] != "/" ) |
190 | filename = directory.path() + "/" + file; | 190 | filename = directory.path() + "/" + file; |
191 | else | 191 | else |
192 | filename = file; | 192 | filename = file; |
193 | 193 | ||
194 | QFileInfo fi( filename ); | 194 | QFileInfo fi( filename ); |
195 | return ( fi.exists() && fi.isReadable() ); | 195 | return ( fi.exists() && fi.isReadable() ); |
196 | } | 196 | } |
197 | 197 | ||
198 | bool ServerPI::checkWriteFile( const QString& file ) | 198 | bool ServerPI::checkWriteFile( const QString& file ) |
199 | { | 199 | { |
200 | QString filename; | 200 | QString filename; |
201 | 201 | ||
202 | if ( file[0] != "/" ) | 202 | if ( file[0] != "/" ) |
203 | filename = directory.path() + "/" + file; | 203 | filename = directory.path() + "/" + file; |
204 | else | 204 | else |
205 | filename = file; | 205 | filename = file; |
206 | 206 | ||
207 | QFileInfo fi( filename ); | 207 | QFileInfo fi( filename ); |
208 | 208 | ||
209 | if ( fi.exists() ) | 209 | if ( fi.exists() ) |
210 | if ( !QFile( filename ).remove() ) | 210 | if ( !QFile( filename ).remove() ) |
211 | return FALSE; | 211 | return FALSE; |
212 | return TRUE; | 212 | return TRUE; |
213 | } | 213 | } |
214 | 214 | ||
215 | void ServerPI::process( const QString& message ) | 215 | void ServerPI::process( const QString& message ) |
216 | { | 216 | { |
217 | //qDebug( "Command: %s", message.latin1() ); | 217 | //qDebug( "Command: %s", message.latin1() ); |
218 | 218 | ||
219 | // split message using "," as separator | 219 | // split message using "," as separator |
220 | QStringList msg = QStringList::split( " ", message ); | 220 | QStringList msg = QStringList::split( " ", message ); |
221 | if ( msg.isEmpty() ) return; | 221 | if ( msg.isEmpty() ) return; |
222 | 222 | ||
223 | // command token | 223 | // command token |
224 | QString cmd = msg[0].upper(); | 224 | QString cmd = msg[0].upper(); |
225 | 225 | ||
226 | // argument token | 226 | // argument token |
227 | QString arg; | 227 | QString arg; |
228 | if ( msg.count() >= 2 ) | 228 | if ( msg.count() >= 2 ) |
229 | arg = msg[1]; | 229 | arg = msg[1]; |
230 | 230 | ||
231 | // full argument string | 231 | // full argument string |
232 | QString args; | 232 | QString args; |
233 | if ( msg.count() >= 2 ) { | 233 | if ( msg.count() >= 2 ) { |
234 | QStringList copy( msg ); | 234 | QStringList copy( msg ); |
235 | // FIXME: for Qt3 | 235 | // FIXME: for Qt3 |
236 | // copy.pop_front() | 236 | // copy.pop_front() |
237 | copy.remove( copy.begin() ); | 237 | copy.remove( copy.begin() ); |
238 | args = copy.join( " " ); | 238 | args = copy.join( " " ); |
239 | } | 239 | } |
240 | 240 | ||
241 | //qDebug( "args: %s", args.latin1() ); | 241 | //qDebug( "args: %s", args.latin1() ); |
242 | 242 | ||
243 | // we always respond to QUIT, regardless of state | 243 | // we always respond to QUIT, regardless of state |
244 | if ( cmd == "QUIT" ) { | 244 | if ( cmd == "QUIT" ) { |
245 | send( "211 Good bye!" ); | 245 | send( "211 Good bye!" ); |
246 | delete this; | 246 | delete this; |
247 | return; | 247 | return; |
248 | } | 248 | } |
249 | 249 | ||
250 | // connected to client | 250 | // connected to client |
251 | if ( Connected == state ) | 251 | if ( Connected == state ) |
252 | return; | 252 | return; |
253 | 253 | ||
254 | // waiting for user name | 254 | // waiting for user name |
255 | if ( Wait_USER == state ) { | 255 | if ( Wait_USER == state ) { |
256 | 256 | ||
257 | if ( cmd != "USER" || msg.count() < 2 || !checkUser( arg ) ) { | 257 | if ( cmd != "USER" || msg.count() < 2 || !checkUser( arg ) ) { |
258 | send( "530 Please login with USER and PASS" ); | 258 | send( "530 Please login with USER and PASS" ); |
259 | return; | 259 | return; |
260 | } | 260 | } |
261 | send( "331 User name ok, need password" ); | 261 | send( "331 User name ok, need password" ); |
262 | state = Wait_PASS; | 262 | state = Wait_PASS; |
263 | return; | 263 | return; |
264 | } | 264 | } |
265 | 265 | ||
266 | // waiting for password | 266 | // waiting for password |
267 | if ( Wait_PASS == state ) { | 267 | if ( Wait_PASS == state ) { |
268 | 268 | ||
269 | if ( cmd != "PASS" || !checkPassword( arg ) ) { | 269 | if ( cmd != "PASS" || !checkPassword( arg ) ) { |
270 | //if ( cmd != "PASS" || msg.count() < 2 || !checkPassword( arg ) ) { | 270 | //if ( cmd != "PASS" || msg.count() < 2 || !checkPassword( arg ) ) { |
271 | send( "530 Please login with USER and PASS" ); | 271 | send( "530 Please login with USER and PASS" ); |
272 | return; | 272 | return; |
273 | } | 273 | } |
274 | send( "230 User logged in, proceed" ); | 274 | send( "230 User logged in, proceed" ); |
275 | state = Ready; | 275 | state = Ready; |
276 | return; | 276 | return; |
277 | } | 277 | } |
278 | 278 | ||
279 | // ACCESS CONTROL COMMANDS | 279 | // ACCESS CONTROL COMMANDS |
280 | 280 | ||
281 | 281 | ||
282 | // account (ACCT) | 282 | // account (ACCT) |
283 | if ( cmd == "ACCT" ) { | 283 | if ( cmd == "ACCT" ) { |
284 | // even wu-ftp does not support it | 284 | // even wu-ftp does not support it |
285 | send( "502 Command not implemented" ); | 285 | send( "502 Command not implemented" ); |
286 | } | 286 | } |
287 | 287 | ||
288 | // change working directory (CWD) | 288 | // change working directory (CWD) |
289 | else if ( cmd == "CWD" ) { | 289 | else if ( cmd == "CWD" ) { |
290 | 290 | ||
291 | if ( !args.isEmpty() ) { | 291 | if ( !args.isEmpty() ) { |
292 | if ( directory.cd( args, TRUE ) ) | 292 | if ( directory.cd( args, TRUE ) ) |
293 | send( "250 Requested file action okay, completed" ); | 293 | send( "250 Requested file action okay, completed" ); |
294 | else | 294 | else |
295 | send( "550 Requested action not taken" ); | 295 | send( "550 Requested action not taken" ); |
296 | } | 296 | } |
297 | else | 297 | else |
298 | send( "500 Syntax error, command unrecognized" ); | 298 | send( "500 Syntax error, command unrecognized" ); |
299 | } | 299 | } |
300 | 300 | ||
301 | // change to parent directory (CDUP) | 301 | // change to parent directory (CDUP) |
302 | else if ( cmd == "CDUP" ) { | 302 | else if ( cmd == "CDUP" ) { |
303 | if ( directory.cdUp() ) | 303 | if ( directory.cdUp() ) |
304 | send( "250 Requested file action okay, completed" ); | 304 | send( "250 Requested file action okay, completed" ); |
305 | else | 305 | else |
306 | send( "550 Requested action not taken" ); | 306 | send( "550 Requested action not taken" ); |
307 | } | 307 | } |
308 | 308 | ||
309 | // structure mount (SMNT) | 309 | // structure mount (SMNT) |
310 | else if ( cmd == "SMNT" ) { | 310 | else if ( cmd == "SMNT" ) { |
311 | // even wu-ftp does not support it | 311 | // even wu-ftp does not support it |
312 | send( "502 Command not implemented" ); | 312 | send( "502 Command not implemented" ); |
313 | } | 313 | } |
314 | 314 | ||
315 | // reinitialize (REIN) | 315 | // reinitialize (REIN) |
316 | else if ( cmd == "REIN" ) { | 316 | else if ( cmd == "REIN" ) { |
317 | // even wu-ftp does not support it | 317 | // even wu-ftp does not support it |
318 | send( "502 Command not implemented" ); | 318 | send( "502 Command not implemented" ); |
319 | } | 319 | } |
320 | 320 | ||
321 | 321 | ||
322 | // TRANSFER PARAMETER COMMANDS | 322 | // TRANSFER PARAMETER COMMANDS |
323 | 323 | ||
324 | 324 | ||
325 | // data port (PORT) | 325 | // data port (PORT) |
326 | else if ( cmd == "PORT" ) { | 326 | else if ( cmd == "PORT" ) { |
327 | if ( parsePort( arg ) ) | 327 | if ( parsePort( arg ) ) |
328 | send( "200 Command okay" ); | 328 | send( "200 Command okay" ); |
329 | else | 329 | else |
330 | send( "500 Syntax error, command unrecognized" ); | 330 | send( "500 Syntax error, command unrecognized" ); |
331 | } | 331 | } |
332 | 332 | ||
333 | // passive (PASV) | 333 | // passive (PASV) |
334 | else if ( cmd == "PASV" ) { | 334 | else if ( cmd == "PASV" ) { |
335 | passiv = TRUE; | 335 | passiv = TRUE; |
336 | send( "227 Entering Passive Mode (" | 336 | send( "227 Entering Passive Mode (" |
337 | + address().toString().replace( QRegExp( "\\." ), "," ) + "," | 337 | + address().toString().replace( QRegExp( "\\." ), "," ) + "," |
338 | + QString::number( ( serversocket->port() ) >> 8 ) + "," | 338 | + QString::number( ( serversocket->port() ) >> 8 ) + "," |
339 | + QString::number( ( serversocket->port() ) & 0xFF ) +")" ); | 339 | + QString::number( ( serversocket->port() ) & 0xFF ) +")" ); |
340 | } | 340 | } |
@@ -599,513 +599,513 @@ void ServerPI::sendFile( const QString& file ) | |||
599 | QStringList targets; | 599 | QStringList targets; |
600 | if ( backupRestoreGzip( file, targets ) ) | 600 | if ( backupRestoreGzip( file, targets ) ) |
601 | dtp->sendGzipFile( file, targets, peeraddress, peerport ); | 601 | dtp->sendGzipFile( file, targets, peeraddress, peerport ); |
602 | else dtp->sendFile( file, peeraddress, peerport ); | 602 | else dtp->sendFile( file, peeraddress, peerport ); |
603 | } | 603 | } |
604 | } | 604 | } |
605 | 605 | ||
606 | void ServerPI::retrieveFile( const QString& file ) | 606 | void ServerPI::retrieveFile( const QString& file ) |
607 | { | 607 | { |
608 | if ( passiv ) { | 608 | if ( passiv ) { |
609 | wait[RetrieveFile] = TRUE; | 609 | wait[RetrieveFile] = TRUE; |
610 | waitfile = file; | 610 | waitfile = file; |
611 | if ( waitsocket ) | 611 | if ( waitsocket ) |
612 | newConnection( waitsocket ); | 612 | newConnection( waitsocket ); |
613 | } | 613 | } |
614 | else { | 614 | else { |
615 | QStringList targets; | 615 | QStringList targets; |
616 | if ( backupRestoreGzip( file, targets ) ) | 616 | if ( backupRestoreGzip( file, targets ) ) |
617 | dtp->retrieveGzipFile( file, peeraddress, peerport ); | 617 | dtp->retrieveGzipFile( file, peeraddress, peerport ); |
618 | else | 618 | else |
619 | dtp->retrieveFile( file, peeraddress, peerport ); | 619 | dtp->retrieveFile( file, peeraddress, peerport ); |
620 | } | 620 | } |
621 | } | 621 | } |
622 | 622 | ||
623 | bool ServerPI::parsePort( const QString& pp ) | 623 | bool ServerPI::parsePort( const QString& pp ) |
624 | { | 624 | { |
625 | QStringList p = QStringList::split( ",", pp ); | 625 | QStringList p = QStringList::split( ",", pp ); |
626 | if ( p.count() != 6 ) return FALSE; | 626 | if ( p.count() != 6 ) return FALSE; |
627 | 627 | ||
628 | // h1,h2,h3,h4,p1,p2 | 628 | // h1,h2,h3,h4,p1,p2 |
629 | peeraddress = QHostAddress( ( p[0].toInt() << 24 ) + ( p[1].toInt() << 16 ) + | 629 | peeraddress = QHostAddress( ( p[0].toInt() << 24 ) + ( p[1].toInt() << 16 ) + |
630 | ( p[2].toInt() << 8 ) + p[3].toInt() ); | 630 | ( p[2].toInt() << 8 ) + p[3].toInt() ); |
631 | peerport = ( p[4].toInt() << 8 ) + p[5].toInt(); | 631 | peerport = ( p[4].toInt() << 8 ) + p[5].toInt(); |
632 | return TRUE; | 632 | return TRUE; |
633 | } | 633 | } |
634 | 634 | ||
635 | void ServerPI::dtpCompleted() | 635 | void ServerPI::dtpCompleted() |
636 | { | 636 | { |
637 | dtp->close(); | 637 | dtp->close(); |
638 | waitsocket = 0; | 638 | waitsocket = 0; |
639 | send( "226 Closing data connection, file transfer successful" ); | 639 | send( "226 Closing data connection, file transfer successful" ); |
640 | } | 640 | } |
641 | 641 | ||
642 | void ServerPI::dtpFailed() | 642 | void ServerPI::dtpFailed() |
643 | { | 643 | { |
644 | dtp->close(); | 644 | dtp->close(); |
645 | waitsocket = 0; | 645 | waitsocket = 0; |
646 | send( "451 Requested action aborted: local error in processing" ); | 646 | send( "451 Requested action aborted: local error in processing" ); |
647 | } | 647 | } |
648 | 648 | ||
649 | void ServerPI::dtpError( int ) | 649 | void ServerPI::dtpError( int ) |
650 | { | 650 | { |
651 | dtp->close(); | 651 | dtp->close(); |
652 | waitsocket = 0; | 652 | waitsocket = 0; |
653 | send( "451 Requested action aborted: local error in processing" ); | 653 | send( "451 Requested action aborted: local error in processing" ); |
654 | } | 654 | } |
655 | 655 | ||
656 | bool ServerPI::sendList( const QString& arg ) | 656 | bool ServerPI::sendList( const QString& arg ) |
657 | { | 657 | { |
658 | QByteArray listing; | 658 | QByteArray listing; |
659 | QBuffer buffer( listing ); | 659 | QBuffer buffer( listing ); |
660 | 660 | ||
661 | if ( !buffer.open( IO_WriteOnly ) ) | 661 | if ( !buffer.open( IO_WriteOnly ) ) |
662 | return FALSE; | 662 | return FALSE; |
663 | 663 | ||
664 | QTextStream ts( &buffer ); | 664 | QTextStream ts( &buffer ); |
665 | QString fn = arg; | 665 | QString fn = arg; |
666 | 666 | ||
667 | if ( fn.isEmpty() ) | 667 | if ( fn.isEmpty() ) |
668 | fn = directory.path(); | 668 | fn = directory.path(); |
669 | 669 | ||
670 | QFileInfo fi( fn ); | 670 | QFileInfo fi( fn ); |
671 | if ( !fi.exists() ) return FALSE; | 671 | if ( !fi.exists() ) return FALSE; |
672 | 672 | ||
673 | // return file listing | 673 | // return file listing |
674 | if ( fi.isFile() ) { | 674 | if ( fi.isFile() ) { |
675 | ts << fileListing( &fi ) << endl; | 675 | ts << fileListing( &fi ) << endl; |
676 | } | 676 | } |
677 | 677 | ||
678 | // return directory listing | 678 | // return directory listing |
679 | else if ( fi.isDir() ) { | 679 | else if ( fi.isDir() ) { |
680 | QDir dir( fn ); | 680 | QDir dir( fn ); |
681 | const QFileInfoList *list = dir.entryInfoList( QDir::All | QDir::Hidden ); | 681 | const QFileInfoList *list = dir.entryInfoList( QDir::All | QDir::Hidden ); |
682 | 682 | ||
683 | QFileInfoListIterator it( *list ); | 683 | QFileInfoListIterator it( *list ); |
684 | QFileInfo *info; | 684 | QFileInfo *info; |
685 | 685 | ||
686 | unsigned long total = 0; | 686 | unsigned long total = 0; |
687 | while ( ( info = it.current() ) ) { | 687 | while ( ( info = it.current() ) ) { |
688 | if ( info->fileName() != "." && info->fileName() != ".." ) | 688 | if ( info->fileName() != "." && info->fileName() != ".." ) |
689 | total += info->size(); | 689 | total += info->size(); |
690 | ++it; | 690 | ++it; |
691 | } | 691 | } |
692 | 692 | ||
693 | ts << "total " << QString::number( total / 1024 ) << endl; | 693 | ts << "total " << QString::number( total / 1024 ) << endl; |
694 | 694 | ||
695 | it.toFirst(); | 695 | it.toFirst(); |
696 | while ( ( info = it.current() ) ) { | 696 | while ( ( info = it.current() ) ) { |
697 | if ( info->fileName() == "." || info->fileName() == ".." ) { | 697 | if ( info->fileName() == "." || info->fileName() == ".." ) { |
698 | ++it; | 698 | ++it; |
699 | continue; | 699 | continue; |
700 | } | 700 | } |
701 | ts << fileListing( info ) << endl; | 701 | ts << fileListing( info ) << endl; |
702 | ++it; | 702 | ++it; |
703 | } | 703 | } |
704 | } | 704 | } |
705 | 705 | ||
706 | if ( passiv ) { | 706 | if ( passiv ) { |
707 | waitarray = buffer.buffer(); | 707 | waitarray = buffer.buffer(); |
708 | wait[SendByteArray] = TRUE; | 708 | wait[SendByteArray] = TRUE; |
709 | if ( waitsocket ) | 709 | if ( waitsocket ) |
710 | newConnection( waitsocket ); | 710 | newConnection( waitsocket ); |
711 | } | 711 | } |
712 | else | 712 | else |
713 | dtp->sendByteArray( buffer.buffer(), peeraddress, peerport ); | 713 | dtp->sendByteArray( buffer.buffer(), peeraddress, peerport ); |
714 | return TRUE; | 714 | return TRUE; |
715 | } | 715 | } |
716 | 716 | ||
717 | QString ServerPI::fileListing( QFileInfo *info ) | 717 | QString ServerPI::fileListing( QFileInfo *info ) |
718 | { | 718 | { |
719 | if ( !info ) return QString::null; | 719 | if ( !info ) return QString::null; |
720 | QString s; | 720 | QString s; |
721 | 721 | ||
722 | // type char | 722 | // type char |
723 | if ( info->isDir() ) | 723 | if ( info->isDir() ) |
724 | s += "d"; | 724 | s += "d"; |
725 | else if ( info->isSymLink() ) | 725 | else if ( info->isSymLink() ) |
726 | s += "l"; | 726 | s += "l"; |
727 | else | 727 | else |
728 | s += "-"; | 728 | s += "-"; |
729 | 729 | ||
730 | // permisson string | 730 | // permisson string |
731 | s += permissionString( info ) + " "; | 731 | s += permissionString( info ) + " "; |
732 | 732 | ||
733 | // number of hardlinks | 733 | // number of hardlinks |
734 | int subdirs = 1; | 734 | int subdirs = 1; |
735 | 735 | ||
736 | if ( info->isDir() ) | 736 | if ( info->isDir() ) |
737 | subdirs = 2; | 737 | subdirs = 2; |
738 | // FIXME : this is to slow | 738 | // FIXME : this is to slow |
739 | //if ( info->isDir() ) | 739 | //if ( info->isDir() ) |
740 | //subdirs = QDir( info->absFilePath() ).entryList( QDir::Dirs ).count(); | 740 | //subdirs = QDir( info->absFilePath() ).entryList( QDir::Dirs ).count(); |
741 | 741 | ||
742 | s += QString::number( subdirs ).rightJustify( 3, ' ', TRUE ) + " "; | 742 | s += QString::number( subdirs ).rightJustify( 3, ' ', TRUE ) + " "; |
743 | 743 | ||
744 | // owner | 744 | // owner |
745 | s += info->owner().leftJustify( 8, ' ', TRUE ) + " "; | 745 | s += info->owner().leftJustify( 8, ' ', TRUE ) + " "; |
746 | 746 | ||
747 | // group | 747 | // group |
748 | s += info->group().leftJustify( 8, ' ', TRUE ) + " "; | 748 | s += info->group().leftJustify( 8, ' ', TRUE ) + " "; |
749 | 749 | ||
750 | // file size in bytes | 750 | // file size in bytes |
751 | s += QString::number( info->size() ).rightJustify( 9, ' ', TRUE ) + " "; | 751 | s += QString::number( info->size() ).rightJustify( 9, ' ', TRUE ) + " "; |
752 | 752 | ||
753 | // last modified date | 753 | // last modified date |
754 | QDate date = info->lastModified().date(); | 754 | QDate date = info->lastModified().date(); |
755 | QTime time = info->lastModified().time(); | 755 | QTime time = info->lastModified().time(); |
756 | s += date.monthName( date.month() ) + " " | 756 | s += date.monthName( date.month() ) + " " |
757 | + QString::number( date.day() ).rightJustify( 2, ' ', TRUE ) + " " | 757 | + QString::number( date.day() ).rightJustify( 2, ' ', TRUE ) + " " |
758 | + QString::number( time.hour() ).rightJustify( 2, '0', TRUE ) + ":" | 758 | + QString::number( time.hour() ).rightJustify( 2, '0', TRUE ) + ":" |
759 | + QString::number( time.minute() ).rightJustify( 2,'0', TRUE ) + " "; | 759 | + QString::number( time.minute() ).rightJustify( 2,'0', TRUE ) + " "; |
760 | 760 | ||
761 | // file name | 761 | // file name |
762 | s += info->fileName(); | 762 | s += info->fileName(); |
763 | 763 | ||
764 | return s; | 764 | return s; |
765 | } | 765 | } |
766 | 766 | ||
767 | QString ServerPI::permissionString( QFileInfo *info ) | 767 | QString ServerPI::permissionString( QFileInfo *info ) |
768 | { | 768 | { |
769 | if ( !info ) return QString( "---------" ); | 769 | if ( !info ) return QString( "---------" ); |
770 | QString s; | 770 | QString s; |
771 | 771 | ||
772 | // user | 772 | // user |
773 | if ( info->permission( QFileInfo::ReadUser ) ) s += "r"; | 773 | if ( info->permission( QFileInfo::ReadUser ) ) s += "r"; |
774 | else s += "-"; | 774 | else s += "-"; |
775 | if ( info->permission( QFileInfo::WriteUser ) ) s += "w"; | 775 | if ( info->permission( QFileInfo::WriteUser ) ) s += "w"; |
776 | else s += "-"; | 776 | else s += "-"; |
777 | if ( info->permission( QFileInfo::ExeUser ) ) s += "x"; | 777 | if ( info->permission( QFileInfo::ExeUser ) ) s += "x"; |
778 | else s += "-"; | 778 | else s += "-"; |
779 | 779 | ||
780 | // group | 780 | // group |
781 | if ( info->permission( QFileInfo::ReadGroup ) ) s += "r"; | 781 | if ( info->permission( QFileInfo::ReadGroup ) ) s += "r"; |
782 | else s += "-"; | 782 | else s += "-"; |
783 | if ( info->permission( QFileInfo::WriteGroup ) )s += "w"; | 783 | if ( info->permission( QFileInfo::WriteGroup ) )s += "w"; |
784 | else s += "-"; | 784 | else s += "-"; |
785 | if ( info->permission( QFileInfo::ExeGroup ) ) s += "x"; | 785 | if ( info->permission( QFileInfo::ExeGroup ) ) s += "x"; |
786 | else s += "-"; | 786 | else s += "-"; |
787 | 787 | ||
788 | // exec | 788 | // exec |
789 | if ( info->permission( QFileInfo::ReadOther ) ) s += "r"; | 789 | if ( info->permission( QFileInfo::ReadOther ) ) s += "r"; |
790 | else s += "-"; | 790 | else s += "-"; |
791 | if ( info->permission( QFileInfo::WriteOther ) ) s += "w"; | 791 | if ( info->permission( QFileInfo::WriteOther ) ) s += "w"; |
792 | else s += "-"; | 792 | else s += "-"; |
793 | if ( info->permission( QFileInfo::ExeOther ) ) s += "x"; | 793 | if ( info->permission( QFileInfo::ExeOther ) ) s += "x"; |
794 | else s += "-"; | 794 | else s += "-"; |
795 | 795 | ||
796 | return s; | 796 | return s; |
797 | } | 797 | } |
798 | 798 | ||
799 | void ServerPI::newConnection( int socket ) | 799 | void ServerPI::newConnection( int socket ) |
800 | { | 800 | { |
801 | //qDebug( "New incomming connection" ); | 801 | //qDebug( "New incomming connection" ); |
802 | 802 | ||
803 | if ( !passiv ) return; | 803 | if ( !passiv ) return; |
804 | 804 | ||
805 | if ( wait[SendFile] ) { | 805 | if ( wait[SendFile] ) { |
806 | QStringList targets; | 806 | QStringList targets; |
807 | if ( backupRestoreGzip( waitfile, targets ) ) | 807 | if ( backupRestoreGzip( waitfile, targets ) ) |
808 | dtp->sendGzipFile( waitfile, targets ); | 808 | dtp->sendGzipFile( waitfile, targets ); |
809 | else | 809 | else |
810 | dtp->sendFile( waitfile ); | 810 | dtp->sendFile( waitfile ); |
811 | dtp->setSocket( socket ); | 811 | dtp->setSocket( socket ); |
812 | } | 812 | } |
813 | else if ( wait[RetrieveFile] ) { | 813 | else if ( wait[RetrieveFile] ) { |
814 | qDebug("check retrieve file"); | 814 | qDebug("check retrieve file"); |
815 | if ( backupRestoreGzip( waitfile ) ) | 815 | if ( backupRestoreGzip( waitfile ) ) |
816 | dtp->retrieveGzipFile( waitfile ); | 816 | dtp->retrieveGzipFile( waitfile ); |
817 | else | 817 | else |
818 | dtp->retrieveFile( waitfile ); | 818 | dtp->retrieveFile( waitfile ); |
819 | dtp->setSocket( socket ); | 819 | dtp->setSocket( socket ); |
820 | } | 820 | } |
821 | else if ( wait[SendByteArray] ) { | 821 | else if ( wait[SendByteArray] ) { |
822 | dtp->sendByteArray( waitarray ); | 822 | dtp->sendByteArray( waitarray ); |
823 | dtp->setSocket( socket ); | 823 | dtp->setSocket( socket ); |
824 | } | 824 | } |
825 | else if ( wait[RetrieveByteArray] ) { | 825 | else if ( wait[RetrieveByteArray] ) { |
826 | qDebug("retrieve byte array"); | 826 | qDebug("retrieve byte array"); |
827 | dtp->retrieveByteArray(); | 827 | dtp->retrieveByteArray(); |
828 | dtp->setSocket( socket ); | 828 | dtp->setSocket( socket ); |
829 | } | 829 | } |
830 | else | 830 | else |
831 | waitsocket = socket; | 831 | waitsocket = socket; |
832 | 832 | ||
833 | for( int i = 0; i < 4; i++ ) | 833 | for( int i = 0; i < 4; i++ ) |
834 | wait[i] = FALSE; | 834 | wait[i] = FALSE; |
835 | } | 835 | } |
836 | 836 | ||
837 | QString ServerPI::absFilePath( const QString& file ) | 837 | QString ServerPI::absFilePath( const QString& file ) |
838 | { | 838 | { |
839 | if ( file.isEmpty() ) return file; | 839 | if ( file.isEmpty() ) return file; |
840 | 840 | ||
841 | QString filepath( file ); | 841 | QString filepath( file ); |
842 | if ( file[0] != "/" ) | 842 | if ( file[0] != "/" ) |
843 | filepath = directory.path() + "/" + file; | 843 | filepath = directory.path() + "/" + file; |
844 | 844 | ||
845 | return filepath; | 845 | return filepath; |
846 | } | 846 | } |
847 | 847 | ||
848 | 848 | ||
849 | void ServerPI::timerEvent( QTimerEvent * ) | 849 | void ServerPI::timerEvent( QTimerEvent * ) |
850 | { | 850 | { |
851 | connectionClosed(); | 851 | connectionClosed(); |
852 | } | 852 | } |
853 | 853 | ||
854 | 854 | ||
855 | ServerDTP::ServerDTP( QObject *parent = 0, const char* name = 0) | 855 | ServerDTP::ServerDTP( QObject *parent, const char* name ) |
856 | : QSocket( parent, name ), mode( Idle ), createTargzProc( 0 ), | 856 | : QSocket( parent, name ), mode( Idle ), createTargzProc( 0 ), |
857 | retrieveTargzProc( 0 ), gzipProc( 0 ) | 857 | retrieveTargzProc( 0 ), gzipProc( 0 ) |
858 | { | 858 | { |
859 | 859 | ||
860 | connect( this, SIGNAL( connected() ), SLOT( connected() ) ); | 860 | connect( this, SIGNAL( connected() ), SLOT( connected() ) ); |
861 | connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) ); | 861 | connect( this, SIGNAL( connectionClosed() ), SLOT( connectionClosed() ) ); |
862 | connect( this, SIGNAL( bytesWritten( int ) ), SLOT( bytesWritten( int ) ) ); | 862 | connect( this, SIGNAL( bytesWritten( int ) ), SLOT( bytesWritten( int ) ) ); |
863 | connect( this, SIGNAL( readyRead() ), SLOT( readyRead() ) ); | 863 | connect( this, SIGNAL( readyRead() ), SLOT( readyRead() ) ); |
864 | 864 | ||
865 | gzipProc = new QProcess( this, "gzipProc" ); | 865 | gzipProc = new QProcess( this, "gzipProc" ); |
866 | gzipProc->setCommunication( QProcess::Stdin | QProcess::Stdout ); | 866 | gzipProc->setCommunication( QProcess::Stdin | QProcess::Stdout ); |
867 | 867 | ||
868 | createTargzProc = new QProcess( QString("tar"), this, "createTargzProc"); | 868 | createTargzProc = new QProcess( QString("tar"), this, "createTargzProc"); |
869 | createTargzProc->setCommunication( QProcess::Stdout ); | 869 | createTargzProc->setCommunication( QProcess::Stdout ); |
870 | createTargzProc->setWorkingDirectory( QDir::rootDirPath() ); | 870 | createTargzProc->setWorkingDirectory( QDir::rootDirPath() ); |
871 | connect( createTargzProc, SIGNAL( processExited() ), SLOT( targzDone() ) ); | 871 | connect( createTargzProc, SIGNAL( processExited() ), SLOT( targzDone() ) ); |
872 | 872 | ||
873 | QStringList args = "tar"; | 873 | QStringList args = "tar"; |
874 | args += "-xv"; | 874 | args += "-xv"; |
875 | retrieveTargzProc = new QProcess( args, this, "retrieveTargzProc" ); | 875 | retrieveTargzProc = new QProcess( args, this, "retrieveTargzProc" ); |
876 | retrieveTargzProc->setCommunication( QProcess::Stdin ); | 876 | retrieveTargzProc->setCommunication( QProcess::Stdin ); |
877 | retrieveTargzProc->setWorkingDirectory( QDir::rootDirPath() ); | 877 | retrieveTargzProc->setWorkingDirectory( QDir::rootDirPath() ); |
878 | connect( retrieveTargzProc, SIGNAL( processExited() ), | 878 | connect( retrieveTargzProc, SIGNAL( processExited() ), |
879 | SIGNAL( completed() ) ); | 879 | SIGNAL( completed() ) ); |
880 | connect( retrieveTargzProc, SIGNAL( processExited() ), | 880 | connect( retrieveTargzProc, SIGNAL( processExited() ), |
881 | SLOT( extractTarDone() ) ); | 881 | SLOT( extractTarDone() ) ); |
882 | } | 882 | } |
883 | 883 | ||
884 | ServerDTP::~ServerDTP() | 884 | ServerDTP::~ServerDTP() |
885 | { | 885 | { |
886 | buf.close(); | 886 | buf.close(); |
887 | file.close(); | 887 | file.close(); |
888 | createTargzProc->kill(); | 888 | createTargzProc->kill(); |
889 | } | 889 | } |
890 | 890 | ||
891 | void ServerDTP::extractTarDone() | 891 | void ServerDTP::extractTarDone() |
892 | { | 892 | { |
893 | qDebug("extract done"); | 893 | qDebug("extract done"); |
894 | QCopEnvelope e( "QPE/Desktop", "restoreDone(QString)" ); | 894 | QCopEnvelope e( "QPE/Desktop", "restoreDone(QString)" ); |
895 | e << file.name(); | 895 | e << file.name(); |
896 | } | 896 | } |
897 | 897 | ||
898 | void ServerDTP::connected() | 898 | void ServerDTP::connected() |
899 | { | 899 | { |
900 | // send file mode | 900 | // send file mode |
901 | switch ( mode ) { | 901 | switch ( mode ) { |
902 | case SendFile : | 902 | case SendFile : |
903 | if ( !file.exists() || !file.open( IO_ReadOnly) ) { | 903 | if ( !file.exists() || !file.open( IO_ReadOnly) ) { |
904 | emit failed(); | 904 | emit failed(); |
905 | mode = Idle; | 905 | mode = Idle; |
906 | return; | 906 | return; |
907 | } | 907 | } |
908 | 908 | ||
909 | //qDebug( "Debug: Sending file '%s'", file.name().latin1() ); | 909 | //qDebug( "Debug: Sending file '%s'", file.name().latin1() ); |
910 | 910 | ||
911 | bytes_written = 0; | 911 | bytes_written = 0; |
912 | if ( file.size() == 0 ) { | 912 | if ( file.size() == 0 ) { |
913 | //make sure it doesn't hang on empty files | 913 | //make sure it doesn't hang on empty files |
914 | file.close(); | 914 | file.close(); |
915 | emit completed(); | 915 | emit completed(); |
916 | mode = Idle; | 916 | mode = Idle; |
917 | } else { | 917 | } else { |
918 | 918 | ||
919 | if( !file.atEnd() ) { | 919 | if( !file.atEnd() ) { |
920 | QCString s; | 920 | QCString s; |
921 | s.resize( block_size ); | 921 | s.resize( block_size ); |
922 | int bytes = file.readBlock( s.data(), block_size ); | 922 | int bytes = file.readBlock( s.data(), block_size ); |
923 | writeBlock( s.data(), bytes ); | 923 | writeBlock( s.data(), bytes ); |
924 | } | 924 | } |
925 | } | 925 | } |
926 | break; | 926 | break; |
927 | case SendGzipFile: | 927 | case SendGzipFile: |
928 | if ( createTargzProc->isRunning() ) { | 928 | if ( createTargzProc->isRunning() ) { |
929 | // SHOULDN'T GET HERE, BUT DOING A SAFETY CHECK ANYWAY | 929 | // SHOULDN'T GET HERE, BUT DOING A SAFETY CHECK ANYWAY |
930 | qWarning("Previous tar --gzip process is still running; killing it..."); | 930 | qWarning("Previous tar --gzip process is still running; killing it..."); |
931 | createTargzProc->kill(); | 931 | createTargzProc->kill(); |
932 | } | 932 | } |
933 | 933 | ||
934 | bytes_written = 0; | 934 | bytes_written = 0; |
935 | qDebug("==>start send tar process"); | 935 | qDebug("==>start send tar process"); |
936 | if ( !createTargzProc->start() ) | 936 | if ( !createTargzProc->start() ) |
937 | qWarning("Error starting %s or %s", | 937 | qWarning("Error starting %s or %s", |
938 | createTargzProc->arguments().join(" ").latin1(), | 938 | createTargzProc->arguments().join(" ").latin1(), |
939 | gzipProc->arguments().join(" ").latin1() ); | 939 | gzipProc->arguments().join(" ").latin1() ); |
940 | break; | 940 | break; |
941 | case SendBuffer: | 941 | case SendBuffer: |
942 | if ( !buf.open( IO_ReadOnly) ) { | 942 | if ( !buf.open( IO_ReadOnly) ) { |
943 | emit failed(); | 943 | emit failed(); |
944 | mode = Idle; | 944 | mode = Idle; |
945 | return; | 945 | return; |
946 | } | 946 | } |
947 | 947 | ||
948 | // qDebug( "Debug: Sending byte array" ); | 948 | // qDebug( "Debug: Sending byte array" ); |
949 | bytes_written = 0; | 949 | bytes_written = 0; |
950 | while( !buf.atEnd() ) | 950 | while( !buf.atEnd() ) |
951 | putch( buf.getch() ); | 951 | putch( buf.getch() ); |
952 | buf.close(); | 952 | buf.close(); |
953 | break; | 953 | break; |
954 | case RetrieveFile: | 954 | case RetrieveFile: |
955 | // retrieve file mode | 955 | // retrieve file mode |
956 | if ( file.exists() && !file.remove() ) { | 956 | if ( file.exists() && !file.remove() ) { |
957 | emit failed(); | 957 | emit failed(); |
958 | mode = Idle; | 958 | mode = Idle; |
959 | return; | 959 | return; |
960 | } | 960 | } |
961 | 961 | ||
962 | if ( !file.open( IO_WriteOnly) ) { | 962 | if ( !file.open( IO_WriteOnly) ) { |
963 | emit failed(); | 963 | emit failed(); |
964 | mode = Idle; | 964 | mode = Idle; |
965 | return; | 965 | return; |
966 | } | 966 | } |
967 | // qDebug( "Debug: Retrieving file %s", file.name().latin1() ); | 967 | // qDebug( "Debug: Retrieving file %s", file.name().latin1() ); |
968 | break; | 968 | break; |
969 | case RetrieveGzipFile: | 969 | case RetrieveGzipFile: |
970 | qDebug("=-> starting tar process to receive .tgz file"); | 970 | qDebug("=-> starting tar process to receive .tgz file"); |
971 | break; | 971 | break; |
972 | case RetrieveBuffer: | 972 | case RetrieveBuffer: |
973 | // retrieve buffer mode | 973 | // retrieve buffer mode |
974 | if ( !buf.open( IO_WriteOnly) ) { | 974 | if ( !buf.open( IO_WriteOnly) ) { |
975 | emit failed(); | 975 | emit failed(); |
976 | mode = Idle; | 976 | mode = Idle; |
977 | return; | 977 | return; |
978 | } | 978 | } |
979 | // qDebug( "Debug: Retrieving byte array" ); | 979 | // qDebug( "Debug: Retrieving byte array" ); |
980 | break; | 980 | break; |
981 | case Idle: | 981 | case Idle: |
982 | qDebug("connection established but mode set to Idle; BUG!"); | 982 | qDebug("connection established but mode set to Idle; BUG!"); |
983 | break; | 983 | break; |
984 | } | 984 | } |
985 | } | 985 | } |
986 | 986 | ||
987 | void ServerDTP::connectionClosed() | 987 | void ServerDTP::connectionClosed() |
988 | { | 988 | { |
989 | //qDebug( "Debug: Data connection closed %ld bytes written", bytes_written ); | 989 | //qDebug( "Debug: Data connection closed %ld bytes written", bytes_written ); |
990 | 990 | ||
991 | // send file mode | 991 | // send file mode |
992 | if ( SendFile == mode ) { | 992 | if ( SendFile == mode ) { |
993 | if ( bytes_written == file.size() ) | 993 | if ( bytes_written == file.size() ) |
994 | emit completed(); | 994 | emit completed(); |
995 | else | 995 | else |
996 | emit failed(); | 996 | emit failed(); |
997 | } | 997 | } |
998 | 998 | ||
999 | // send buffer mode | 999 | // send buffer mode |
1000 | else if ( SendBuffer == mode ) { | 1000 | else if ( SendBuffer == mode ) { |
1001 | if ( bytes_written == buf.size() ) | 1001 | if ( bytes_written == buf.size() ) |
1002 | emit completed(); | 1002 | emit completed(); |
1003 | else | 1003 | else |
1004 | emit failed(); | 1004 | emit failed(); |
1005 | } | 1005 | } |
1006 | 1006 | ||
1007 | // retrieve file mode | 1007 | // retrieve file mode |
1008 | else if ( RetrieveFile == mode ) { | 1008 | else if ( RetrieveFile == mode ) { |
1009 | file.close(); | 1009 | file.close(); |
1010 | emit completed(); | 1010 | emit completed(); |
1011 | } | 1011 | } |
1012 | 1012 | ||
1013 | else if ( RetrieveGzipFile == mode ) { | 1013 | else if ( RetrieveGzipFile == mode ) { |
1014 | qDebug("Done writing ungzip file; closing input"); | 1014 | qDebug("Done writing ungzip file; closing input"); |
1015 | gzipProc->flushStdin(); | 1015 | gzipProc->flushStdin(); |
1016 | gzipProc->closeStdin(); | 1016 | gzipProc->closeStdin(); |
1017 | } | 1017 | } |
1018 | 1018 | ||
1019 | // retrieve buffer mode | 1019 | // retrieve buffer mode |
1020 | else if ( RetrieveBuffer == mode ) { | 1020 | else if ( RetrieveBuffer == mode ) { |
1021 | buf.close(); | 1021 | buf.close(); |
1022 | emit completed(); | 1022 | emit completed(); |
1023 | } | 1023 | } |
1024 | 1024 | ||
1025 | mode = Idle; | 1025 | mode = Idle; |
1026 | } | 1026 | } |
1027 | 1027 | ||
1028 | void ServerDTP::bytesWritten( int bytes ) | 1028 | void ServerDTP::bytesWritten( int bytes ) |
1029 | { | 1029 | { |
1030 | bytes_written += bytes; | 1030 | bytes_written += bytes; |
1031 | 1031 | ||
1032 | // send file mode | 1032 | // send file mode |
1033 | if ( SendFile == mode ) { | 1033 | if ( SendFile == mode ) { |
1034 | 1034 | ||
1035 | if ( bytes_written == file.size() ) { | 1035 | if ( bytes_written == file.size() ) { |
1036 | // qDebug( "Debug: Sending complete: %d bytes", file.size() ); | 1036 | // qDebug( "Debug: Sending complete: %d bytes", file.size() ); |
1037 | file.close(); | 1037 | file.close(); |
1038 | emit completed(); | 1038 | emit completed(); |
1039 | mode = Idle; | 1039 | mode = Idle; |
1040 | } | 1040 | } |
1041 | else if( !file.atEnd() ) { | 1041 | else if( !file.atEnd() ) { |
1042 | QCString s; | 1042 | QCString s; |
1043 | s.resize( block_size ); | 1043 | s.resize( block_size ); |
1044 | int bytes = file.readBlock( s.data(), block_size ); | 1044 | int bytes = file.readBlock( s.data(), block_size ); |
1045 | writeBlock( s.data(), bytes ); | 1045 | writeBlock( s.data(), bytes ); |
1046 | } | 1046 | } |
1047 | } | 1047 | } |
1048 | 1048 | ||
1049 | // send buffer mode | 1049 | // send buffer mode |
1050 | if ( SendBuffer == mode ) { | 1050 | if ( SendBuffer == mode ) { |
1051 | 1051 | ||
1052 | if ( bytes_written == buf.size() ) { | 1052 | if ( bytes_written == buf.size() ) { |
1053 | // qDebug( "Debug: Sending complete: %d bytes", buf.size() ); | 1053 | // qDebug( "Debug: Sending complete: %d bytes", buf.size() ); |
1054 | emit completed(); | 1054 | emit completed(); |
1055 | mode = Idle; | 1055 | mode = Idle; |
1056 | } | 1056 | } |
1057 | } | 1057 | } |
1058 | } | 1058 | } |
1059 | 1059 | ||
1060 | void ServerDTP::readyRead() | 1060 | void ServerDTP::readyRead() |
1061 | { | 1061 | { |
1062 | // retrieve file mode | 1062 | // retrieve file mode |
1063 | if ( RetrieveFile == mode ) { | 1063 | if ( RetrieveFile == mode ) { |
1064 | QCString s; | 1064 | QCString s; |
1065 | s.resize( bytesAvailable() ); | 1065 | s.resize( bytesAvailable() ); |
1066 | readBlock( s.data(), bytesAvailable() ); | 1066 | readBlock( s.data(), bytesAvailable() ); |
1067 | file.writeBlock( s.data(), s.size() ); | 1067 | file.writeBlock( s.data(), s.size() ); |
1068 | } | 1068 | } |
1069 | else if ( RetrieveGzipFile == mode ) { | 1069 | else if ( RetrieveGzipFile == mode ) { |
1070 | if ( !gzipProc->isRunning() ) | 1070 | if ( !gzipProc->isRunning() ) |
1071 | gzipProc->start(); | 1071 | gzipProc->start(); |
1072 | 1072 | ||
1073 | QByteArray s; | 1073 | QByteArray s; |
1074 | s.resize( bytesAvailable() ); | 1074 | s.resize( bytesAvailable() ); |
1075 | readBlock( s.data(), bytesAvailable() ); | 1075 | readBlock( s.data(), bytesAvailable() ); |
1076 | gzipProc->writeToStdin( s ); | 1076 | gzipProc->writeToStdin( s ); |
1077 | qDebug("wrote %d bytes to ungzip ", s.size() ); | 1077 | qDebug("wrote %d bytes to ungzip ", s.size() ); |
1078 | } | 1078 | } |
1079 | // retrieve buffer mode | 1079 | // retrieve buffer mode |
1080 | else if ( RetrieveBuffer == mode ) { | 1080 | else if ( RetrieveBuffer == mode ) { |
1081 | QCString s; | 1081 | QCString s; |
1082 | s.resize( bytesAvailable() ); | 1082 | s.resize( bytesAvailable() ); |
1083 | readBlock( s.data(), bytesAvailable() ); | 1083 | readBlock( s.data(), bytesAvailable() ); |
1084 | buf.writeBlock( s.data(), s.size() ); | 1084 | buf.writeBlock( s.data(), s.size() ); |
1085 | } | 1085 | } |
1086 | } | 1086 | } |
1087 | 1087 | ||
1088 | void ServerDTP::writeTargzBlock() | 1088 | void ServerDTP::writeTargzBlock() |
1089 | { | 1089 | { |
1090 | QByteArray block = gzipProc->readStdout(); | 1090 | QByteArray block = gzipProc->readStdout(); |
1091 | writeBlock( block.data(), block.size() ); | 1091 | writeBlock( block.data(), block.size() ); |
1092 | qDebug("writeTargzBlock %d", block.size()); | 1092 | qDebug("writeTargzBlock %d", block.size()); |
1093 | if ( !createTargzProc->isRunning() ) { | 1093 | if ( !createTargzProc->isRunning() ) { |
1094 | qDebug("tar and gzip done"); | 1094 | qDebug("tar and gzip done"); |
1095 | emit completed(); | 1095 | emit completed(); |
1096 | mode = Idle; | 1096 | mode = Idle; |
1097 | disconnect( gzipProc, SIGNAL( readyReadStdout() ), | 1097 | disconnect( gzipProc, SIGNAL( readyReadStdout() ), |
1098 | this, SLOT( writeTargzBlock() ) ); | 1098 | this, SLOT( writeTargzBlock() ) ); |
1099 | } | 1099 | } |
1100 | } | 1100 | } |
1101 | 1101 | ||
1102 | void ServerDTP::targzDone() | 1102 | void ServerDTP::targzDone() |
1103 | { | 1103 | { |
1104 | //qDebug("targz done"); | 1104 | //qDebug("targz done"); |
1105 | disconnect( createTargzProc, SIGNAL( readyReadStdout() ), | 1105 | disconnect( createTargzProc, SIGNAL( readyReadStdout() ), |
1106 | this, SLOT( gzipTarBlock() ) ); | 1106 | this, SLOT( gzipTarBlock() ) ); |
1107 | gzipProc->closeStdin(); | 1107 | gzipProc->closeStdin(); |
1108 | } | 1108 | } |
1109 | 1109 | ||
1110 | void ServerDTP::gzipTarBlock() | 1110 | void ServerDTP::gzipTarBlock() |
1111 | { | 1111 | { |