author | zecke <zecke> | 2002-10-17 16:45:38 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-10-17 16:45:38 (UTC) |
commit | 0655456f68849bfad9019a7760dec961792d7519 (patch) (unidiff) | |
tree | 4651cad54a144385442a26e78f4a83b57501830f | |
parent | 8511273d7122d50ffea27f78ba13ab72af60326d (diff) | |
download | opie-0655456f68849bfad9019a7760dec961792d7519.zip opie-0655456f68849bfad9019a7760dec961792d7519.tar.gz opie-0655456f68849bfad9019a7760dec961792d7519.tar.bz2 |
Move around some #ifdefs to be able to be built with Qt2/X11
-rw-r--r-- | core/launcher/desktop.cpp | 10 | ||||
-rw-r--r-- | core/launcher/launcher.cpp | 2 | ||||
-rw-r--r-- | core/launcher/main.cpp | 7 | ||||
-rw-r--r-- | core/launcher/qcopbridge.cpp | 2 | ||||
-rw-r--r-- | core/launcher/runningappbar.cpp | 2 | ||||
-rw-r--r-- | core/launcher/transferserver.cpp | 2 |
6 files changed, 12 insertions, 13 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index d74b745..1fd3f6a 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp | |||
@@ -1,940 +1,942 @@ | |||
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/network.h> | 40 | #include <qpe/network.h> |
41 | #include <qpe/global.h> | 41 | #include <qpe/global.h> |
42 | 42 | ||
43 | #if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ ) | 43 | #if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ ) |
44 | #include <qpe/custom.h> | 44 | #include <qpe/custom.h> |
45 | #endif | 45 | #endif |
46 | 46 | ||
47 | #include <opie/odevice.h> | 47 | #include <opie/odevice.h> |
48 | 48 | ||
49 | #include <qgfx_qws.h> | 49 | #include <qgfx_qws.h> |
50 | #include <qmainwindow.h> | 50 | #include <qmainwindow.h> |
51 | #include <qmessagebox.h> | 51 | #include <qmessagebox.h> |
52 | #include <qtimer.h> | 52 | #include <qtimer.h> |
53 | #include <qwindowsystem_qws.h> | 53 | #include <qwindowsystem_qws.h> |
54 | 54 | ||
55 | #include <qvaluelist.h> | 55 | #include <qvaluelist.h> |
56 | 56 | ||
57 | #include <stdlib.h> | 57 | #include <stdlib.h> |
58 | #include <unistd.h> | 58 | #include <unistd.h> |
59 | #include <fcntl.h> | 59 | #include <fcntl.h> |
60 | 60 | ||
61 | using namespace Opie; | 61 | using namespace Opie; |
62 | 62 | ||
63 | class QCopKeyRegister | 63 | class QCopKeyRegister |
64 | { | 64 | { |
65 | public: | 65 | public: |
66 | QCopKeyRegister() : keyCode( 0 ) | 66 | QCopKeyRegister() : keyCode( 0 ) |
67 | { } | 67 | { } |
68 | QCopKeyRegister( int k, const QString &c, const QString &m ) | 68 | QCopKeyRegister( int k, const QString &c, const QString &m ) |
69 | : keyCode( k ), channel( c ), message( m ) | 69 | : keyCode( k ), channel( c ), message( m ) |
70 | { } | 70 | { } |
71 | 71 | ||
72 | int getKeyCode() const | 72 | int getKeyCode() const |
73 | { | 73 | { |
74 | return keyCode; | 74 | return keyCode; |
75 | } | 75 | } |
76 | QString getChannel() const | 76 | QString getChannel() const |
77 | { | 77 | { |
78 | return channel; | 78 | return channel; |
79 | } | 79 | } |
80 | QString getMessage() const | 80 | QString getMessage() const |
81 | { | 81 | { |
82 | return message; | 82 | return message; |
83 | } | 83 | } |
84 | 84 | ||
85 | private: | 85 | private: |
86 | int keyCode; | 86 | int keyCode; |
87 | QString channel, message; | 87 | QString channel, message; |
88 | }; | 88 | }; |
89 | 89 | ||
90 | typedef QValueList<QCopKeyRegister> KeyRegisterList; | 90 | typedef QValueList<QCopKeyRegister> KeyRegisterList; |
91 | KeyRegisterList keyRegisterList; | 91 | KeyRegisterList keyRegisterList; |
92 | 92 | ||
93 | static Desktop* qpedesktop = 0; | 93 | static Desktop* qpedesktop = 0; |
94 | static int loggedin = 0; | 94 | static int loggedin = 0; |
95 | static void login( bool at_poweron ) | 95 | static void login( bool at_poweron ) |
96 | { | 96 | { |
97 | if ( !loggedin ) { | 97 | if ( !loggedin ) { |
98 | Global::terminateBuiltin( "calibrate" ); | 98 | Global::terminateBuiltin( "calibrate" ); |
99 | Password::authenticate( at_poweron ); | 99 | Password::authenticate( at_poweron ); |
100 | loggedin = 1; | 100 | loggedin = 1; |
101 | QCopEnvelope e( "QPE/Desktop", "unlocked()" ); | 101 | QCopEnvelope e( "QPE/Desktop", "unlocked()" ); |
102 | } | 102 | } |
103 | } | 103 | } |
104 | 104 | ||
105 | bool Desktop::screenLocked() | 105 | bool Desktop::screenLocked() |
106 | { | 106 | { |
107 | return loggedin == 0; | 107 | return loggedin == 0; |
108 | } | 108 | } |
109 | 109 | ||
110 | /* | 110 | /* |
111 | Priority is number of alerts that are needed to pop up | 111 | Priority is number of alerts that are needed to pop up |
112 | alert. | 112 | alert. |
113 | */ | 113 | */ |
114 | class DesktopPowerAlerter : public QMessageBox | 114 | class DesktopPowerAlerter : public QMessageBox |
115 | { | 115 | { |
116 | public: | 116 | public: |
117 | DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) | 117 | DesktopPowerAlerter( QWidget *parent, const char *name = 0 ) |
118 | : QMessageBox( tr( "Battery Status" ), "Low Battery", | 118 | : QMessageBox( tr( "Battery Status" ), "Low Battery", |
119 | QMessageBox::Critical, | 119 | QMessageBox::Critical, |
120 | QMessageBox::Ok | QMessageBox::Default, | 120 | QMessageBox::Ok | QMessageBox::Default, |
121 | QMessageBox::NoButton, QMessageBox::NoButton, | 121 | QMessageBox::NoButton, QMessageBox::NoButton, |
122 | parent, name, FALSE ) | 122 | parent, name, FALSE ) |
123 | { | 123 | { |
124 | currentPriority = INT_MAX; | 124 | currentPriority = INT_MAX; |
125 | alertCount = 0; | 125 | alertCount = 0; |
126 | } | 126 | } |
127 | 127 | ||
128 | void alert( const QString &text, int priority ); | 128 | void alert( const QString &text, int priority ); |
129 | void hideEvent( QHideEvent * ); | 129 | void hideEvent( QHideEvent * ); |
130 | private: | 130 | private: |
131 | int currentPriority; | 131 | int currentPriority; |
132 | int alertCount; | 132 | int alertCount; |
133 | }; | 133 | }; |
134 | 134 | ||
135 | void DesktopPowerAlerter::alert( const QString &text, int priority ) | 135 | void DesktopPowerAlerter::alert( const QString &text, int priority ) |
136 | { | 136 | { |
137 | alertCount++; | 137 | alertCount++; |
138 | if ( alertCount < priority ) | 138 | if ( alertCount < priority ) |
139 | return ; | 139 | return ; |
140 | if ( priority > currentPriority ) | 140 | if ( priority > currentPriority ) |
141 | return ; | 141 | return ; |
142 | currentPriority = priority; | 142 | currentPriority = priority; |
143 | setText( text ); | 143 | setText( text ); |
144 | show(); | 144 | show(); |
145 | } | 145 | } |
146 | 146 | ||
147 | 147 | ||
148 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) | 148 | void DesktopPowerAlerter::hideEvent( QHideEvent *e ) |
149 | { | 149 | { |
150 | QMessageBox::hideEvent( e ); | 150 | QMessageBox::hideEvent( e ); |
151 | alertCount = 0; | 151 | alertCount = 0; |
152 | currentPriority = INT_MAX; | 152 | currentPriority = INT_MAX; |
153 | } | 153 | } |
154 | 154 | ||
155 | |||
156 | class QPEScreenSaver : public QWSScreenSaver | 155 | class QPEScreenSaver : public QWSScreenSaver |
157 | { | 156 | { |
158 | private: | 157 | private: |
159 | int LcdOn; | 158 | int LcdOn; |
160 | 159 | ||
161 | public: | 160 | public: |
162 | QPEScreenSaver() | 161 | QPEScreenSaver() |
163 | { | 162 | { |
164 | m_disable_suspend = 100; | 163 | m_disable_suspend = 100; |
165 | m_enable_dim = false; | 164 | m_enable_dim = false; |
166 | m_enable_lightoff = false; | 165 | m_enable_lightoff = false; |
167 | m_enable_onlylcdoff = false; | 166 | m_enable_onlylcdoff = false; |
168 | 167 | ||
169 | m_lcd_status = true; | 168 | m_lcd_status = true; |
170 | 169 | ||
171 | m_backlight_bright = -1; | 170 | m_backlight_bright = -1; |
172 | m_backlight_forcedoff = false; | 171 | m_backlight_forcedoff = false; |
173 | 172 | ||
174 | // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) | 173 | // Make sure the LCD is in fact on, (if opie was killed while the LCD is off it would still be off) |
175 | ODevice::inst ( ) -> setDisplayStatus ( true ); | 174 | ODevice::inst ( ) -> setDisplayStatus ( true ); |
176 | } | 175 | } |
177 | void restore() | 176 | void restore() |
178 | { | 177 | { |
179 | if ( !m_lcd_status ) { // We must have turned it off | 178 | if ( !m_lcd_status ) { // We must have turned it off |
180 | ODevice::inst ( ) -> setDisplayStatus ( true ); | 179 | ODevice::inst ( ) -> setDisplayStatus ( true ); |
181 | m_lcd_status = true; | 180 | m_lcd_status = true; |
182 | } | 181 | } |
183 | 182 | ||
184 | setBacklight ( -1 ); | 183 | setBacklight ( -1 ); |
185 | } | 184 | } |
186 | bool save( int level ) | 185 | bool save( int level ) |
187 | { | 186 | { |
188 | switch ( level ) { | 187 | switch ( level ) { |
189 | case 0: | 188 | case 0: |
190 | if ( m_disable_suspend > 0 && m_enable_dim ) { | 189 | if ( m_disable_suspend > 0 && m_enable_dim ) { |
191 | if ( backlight() > 1 ) | 190 | if ( backlight() > 1 ) |
192 | setBacklight( 1 ); // lowest non-off | 191 | setBacklight( 1 ); // lowest non-off |
193 | } | 192 | } |
194 | return true; | 193 | return true; |
195 | break; | 194 | break; |
196 | case 1: | 195 | case 1: |
197 | if ( m_disable_suspend > 1 && m_enable_lightoff ) { | 196 | if ( m_disable_suspend > 1 && m_enable_lightoff ) { |
198 | setBacklight( 0 ); // off | 197 | setBacklight( 0 ); // off |
199 | } | 198 | } |
200 | return true; | 199 | return true; |
201 | break; | 200 | break; |
202 | case 2: | 201 | case 2: |
203 | if ( m_enable_onlylcdoff ) { | 202 | if ( m_enable_onlylcdoff ) { |
204 | ODevice::inst ( ) -> setDisplayStatus ( false ); | 203 | ODevice::inst ( ) -> setDisplayStatus ( false ); |
205 | m_lcd_status = false; | 204 | m_lcd_status = false; |
206 | return true; | 205 | return true; |
207 | } | 206 | } |
208 | else // We're going to suspend the whole machine | 207 | else // We're going to suspend the whole machine |
209 | { | 208 | { |
210 | if ( ( m_disable_suspend > 2 ) && | 209 | if ( ( m_disable_suspend > 2 ) && |
211 | ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) && | 210 | ( PowerStatusManager::readStatus().acStatus() != PowerStatus::Online ) && |
212 | ( !Network::networkOnline ( ) ) ) { | 211 | ( !Network::networkOnline ( ) ) ) { |
213 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); | 212 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); |
214 | return true; | 213 | return true; |
215 | } | 214 | } |
216 | } | 215 | } |
217 | break; | 216 | break; |
218 | } | 217 | } |
219 | return false; | 218 | return false; |
220 | } | 219 | } |
221 | 220 | ||
222 | private: | 221 | private: |
223 | static int ssi( int interval, Config & config, const QString & enable, const QString & value, int def ) | 222 | static int ssi( int interval, Config & config, const QString & enable, const QString & value, int def ) |
224 | { | 223 | { |
225 | if ( !enable.isEmpty() && config.readNumEntry( enable, 0 ) == 0 ) | 224 | if ( !enable.isEmpty() && config.readNumEntry( enable, 0 ) == 0 ) |
226 | return 0; | 225 | return 0; |
227 | 226 | ||
228 | if ( interval < 0 ) { | 227 | if ( interval < 0 ) { |
229 | // Restore screen blanking and power saving state | 228 | // Restore screen blanking and power saving state |
230 | interval = config.readNumEntry( value, def ); | 229 | interval = config.readNumEntry( value, def ); |
231 | } | 230 | } |
232 | return interval; | 231 | return interval; |
233 | } | 232 | } |
234 | 233 | ||
235 | public: | 234 | public: |
236 | void setIntervals( int i1, int i2, int i3 ) | 235 | void setIntervals( int i1, int i2, int i3 ) |
237 | { | 236 | { |
238 | Config config( "qpe" ); | 237 | Config config( "qpe" ); |
239 | config.setGroup( "Screensaver" ); | 238 | config.setGroup( "Screensaver" ); |
240 | 239 | ||
241 | int v[ 4 ]; | 240 | int v[ 4 ]; |
242 | i1 = ssi( i1, config, "Dim", "Interval_Dim", 30 ); | 241 | i1 = ssi( i1, config, "Dim", "Interval_Dim", 30 ); |
243 | i2 = ssi( i2, config, "LightOff", "Interval_LightOff", 20 ); | 242 | i2 = ssi( i2, config, "LightOff", "Interval_LightOff", 20 ); |
244 | i3 = ssi( i3, config, "", "Interval", 60 ); | 243 | i3 = ssi( i3, config, "", "Interval", 60 ); |
245 | 244 | ||
246 | //qDebug("screen saver intervals: %d %d %d", i1, i2, i3); | 245 | //qDebug("screen saver intervals: %d %d %d", i1, i2, i3); |
247 | 246 | ||
248 | v [ 0 ] = QMAX( 1000 * i1, 100 ); | 247 | v [ 0 ] = QMAX( 1000 * i1, 100 ); |
249 | v [ 1 ] = QMAX( 1000 * i2, 100 ); | 248 | v [ 1 ] = QMAX( 1000 * i2, 100 ); |
250 | v [ 2 ] = QMAX( 1000 * i3, 100 ); | 249 | v [ 2 ] = QMAX( 1000 * i3, 100 ); |
251 | v [ 3 ] = 0; | 250 | v [ 3 ] = 0; |
252 | m_enable_dim = ( ( i1 != 0 ) ? config. readNumEntry ( "Dim", 1 ) : false ); | 251 | m_enable_dim = ( ( i1 != 0 ) ? config. readNumEntry ( "Dim", 1 ) : false ); |
253 | m_enable_lightoff = ( ( i2 != 0 ) ? config. readNumEntry ( "LightOff", 1 ) : false ); | 252 | m_enable_lightoff = ( ( i2 != 0 ) ? config. readNumEntry ( "LightOff", 1 ) : false ); |
254 | m_enable_onlylcdoff = config. readNumEntry ( "LcdOffOnly", 0 ); | 253 | m_enable_onlylcdoff = config. readNumEntry ( "LcdOffOnly", 0 ); |
255 | 254 | ||
256 | if ( !i1 && !i2 && !i3 ) | 255 | if ( !i1 && !i2 && !i3 ) |
257 | QWSServer::setScreenSaverInterval( 0 ); | 256 | QWSServer::setScreenSaverInterval( 0 ); |
258 | else | 257 | else |
259 | QWSServer::setScreenSaverIntervals( v ); | 258 | QWSServer::setScreenSaverIntervals( v ); |
260 | } | 259 | } |
261 | 260 | ||
262 | void setInterval ( int interval ) | 261 | void setInterval ( int interval ) |
263 | { | 262 | { |
264 | setIntervals ( -1, -1, interval ); | 263 | setIntervals ( -1, -1, interval ); |
265 | } | 264 | } |
266 | 265 | ||
267 | void setMode ( int mode ) | 266 | void setMode ( int mode ) |
268 | { | 267 | { |
269 | if ( mode > m_disable_suspend ) | 268 | if ( mode > m_disable_suspend ) |
270 | setInterval( -1 ); | 269 | setInterval( -1 ); |
271 | m_disable_suspend = mode; | 270 | m_disable_suspend = mode; |
272 | } | 271 | } |
273 | 272 | ||
274 | int backlight ( ) | 273 | int backlight ( ) |
275 | { | 274 | { |
276 | if ( m_backlight_bright == -1 ) { | 275 | if ( m_backlight_bright == -1 ) { |
277 | // Read from config | 276 | // Read from config |
278 | Config config ( "qpe" ); | 277 | Config config ( "qpe" ); |
279 | config. setGroup ( "Screensaver" ); | 278 | config. setGroup ( "Screensaver" ); |
280 | m_backlight_bright = config. readNumEntry ( "Brightness", 255 ); | 279 | m_backlight_bright = config. readNumEntry ( "Brightness", 255 ); |
281 | } | 280 | } |
282 | return m_backlight_bright; | 281 | return m_backlight_bright; |
283 | } | 282 | } |
284 | 283 | ||
285 | void setBacklight ( int bright ) | 284 | void setBacklight ( int bright ) |
286 | { | 285 | { |
287 | if ( bright == -3 ) { | 286 | if ( bright == -3 ) { |
288 | // Forced on | 287 | // Forced on |
289 | m_backlight_forcedoff = false; | 288 | m_backlight_forcedoff = false; |
290 | bright = -1; | 289 | bright = -1; |
291 | } | 290 | } |
292 | if ( m_backlight_forcedoff && bright != -2 ) | 291 | if ( m_backlight_forcedoff && bright != -2 ) |
293 | return ; | 292 | return ; |
294 | if ( bright == -2 ) { | 293 | if ( bright == -2 ) { |
295 | // Toggle between off and on | 294 | // Toggle between off and on |
296 | bright = m_backlight_bright ? 0 : -1; | 295 | bright = m_backlight_bright ? 0 : -1; |
297 | m_backlight_forcedoff = !bright; | 296 | m_backlight_forcedoff = !bright; |
298 | } | 297 | } |
299 | 298 | ||
300 | m_backlight_bright = bright; | 299 | m_backlight_bright = bright; |
301 | 300 | ||
302 | bright = backlight ( ); | 301 | bright = backlight ( ); |
303 | ODevice::inst ( ) -> setDisplayBrightness ( bright ); | 302 | ODevice::inst ( ) -> setDisplayBrightness ( bright ); |
304 | 303 | ||
305 | m_backlight_bright = bright; | 304 | m_backlight_bright = bright; |
306 | } | 305 | } |
307 | 306 | ||
308 | void setDisplayState ( bool on ) | 307 | void setDisplayState ( bool on ) |
309 | { | 308 | { |
310 | if ( m_lcd_status != on ) { | 309 | if ( m_lcd_status != on ) { |
311 | ODevice::inst ( ) -> setDisplayStatus ( on ); | 310 | ODevice::inst ( ) -> setDisplayStatus ( on ); |
312 | m_lcd_status = on; | 311 | m_lcd_status = on; |
313 | } | 312 | } |
314 | } | 313 | } |
315 | 314 | ||
316 | private: | 315 | private: |
317 | int m_disable_suspend; | 316 | int m_disable_suspend; |
318 | bool m_enable_dim; | 317 | bool m_enable_dim; |
319 | bool m_enable_lightoff; | 318 | bool m_enable_lightoff; |
320 | bool m_enable_onlylcdoff; | 319 | bool m_enable_onlylcdoff; |
321 | 320 | ||
322 | bool m_lcd_status; | 321 | bool m_lcd_status; |
323 | 322 | ||
324 | int m_backlight_bright; | 323 | int m_backlight_bright; |
325 | bool m_backlight_forcedoff; | 324 | bool m_backlight_forcedoff; |
326 | }; | 325 | }; |
327 | 326 | ||
328 | |||
329 | void DesktopApplication::switchLCD ( bool on ) | 327 | void DesktopApplication::switchLCD ( bool on ) |
330 | { | 328 | { |
331 | if ( qApp ) { | 329 | if ( qApp ) { |
332 | DesktopApplication *dapp = (DesktopApplication *) qApp; | 330 | DesktopApplication *dapp = (DesktopApplication *) qApp; |
333 | 331 | ||
334 | if ( dapp-> m_screensaver ) { | 332 | if ( dapp-> m_screensaver ) { |
335 | if ( on ) { | 333 | if ( on ) { |
336 | dapp-> m_screensaver-> setDisplayState ( true ); | 334 | dapp-> m_screensaver-> setDisplayState ( true ); |
337 | dapp-> m_screensaver-> setBacklight ( -3 ); | 335 | dapp-> m_screensaver-> setBacklight ( -3 ); |
338 | } | 336 | } |
339 | else { | 337 | else { |
340 | dapp-> m_screensaver-> setDisplayState ( false ); | 338 | dapp-> m_screensaver-> setDisplayState ( false ); |
341 | } | 339 | } |
342 | } | 340 | } |
343 | } | 341 | } |
344 | } | 342 | } |
345 | 343 | ||
346 | 344 | ||
347 | DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) | 345 | DesktopApplication::DesktopApplication( int& argc, char **argv, Type appType ) |
348 | : QPEApplication( argc, argv, appType ) | 346 | : QPEApplication( argc, argv, appType ) |
349 | { | 347 | { |
350 | 348 | ||
351 | QTimer * t = new QTimer( this ); | 349 | QTimer * t = new QTimer( this ); |
352 | connect( t, SIGNAL( timeout() ), this, SLOT( psTimeout() ) ); | 350 | connect( t, SIGNAL( timeout() ), this, SLOT( psTimeout() ) ); |
353 | t->start( 10000 ); | 351 | t->start( 10000 ); |
354 | ps = new PowerStatus; | 352 | ps = new PowerStatus; |
355 | pa = new DesktopPowerAlerter( 0 ); | 353 | pa = new DesktopPowerAlerter( 0 ); |
356 | 354 | ||
357 | channel = new QCopChannel( "QPE/Desktop", this ); | 355 | channel = new QCopChannel( "QPE/Desktop", this ); |
358 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), | 356 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), |
359 | this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) ); | 357 | this, SLOT( desktopMessage( const QCString&, const QByteArray& ) ) ); |
360 | 358 | ||
361 | channel = new QCopChannel( "QPE/System", this ); | 359 | channel = new QCopChannel( "QPE/System", this ); |
362 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), | 360 | connect( channel, SIGNAL( received( const QCString&, const QByteArray& ) ), |
363 | this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); | 361 | this, SLOT( systemMessage( const QCString&, const QByteArray& ) ) ); |
364 | 362 | ||
365 | m_screensaver = new QPEScreenSaver; | 363 | m_screensaver = new QPEScreenSaver; |
366 | 364 | ||
367 | m_screensaver-> setInterval ( -1 ); | 365 | m_screensaver-> setInterval ( -1 ); |
368 | QWSServer::setScreenSaver( m_screensaver ); | 366 | QWSServer::setScreenSaver( m_screensaver ); |
369 | } | 367 | } |
370 | 368 | ||
371 | 369 | ||
372 | DesktopApplication::~DesktopApplication() | 370 | DesktopApplication::~DesktopApplication() |
373 | { | 371 | { |
374 | delete ps; | 372 | delete ps; |
375 | delete pa; | 373 | delete pa; |
376 | } | 374 | } |
377 | 375 | ||
378 | void DesktopApplication::desktopMessage( const QCString &msg, const QByteArray &data ) | 376 | void DesktopApplication::desktopMessage( const QCString &msg, const QByteArray &data ) |
379 | { | 377 | { |
380 | #ifdef Q_WS_QWS | 378 | #ifdef Q_WS_QWS |
381 | QDataStream stream( data, IO_ReadOnly ); | 379 | QDataStream stream( data, IO_ReadOnly ); |
382 | if ( msg == "keyRegister(int key, QString channel, QString message)" ) { | 380 | if ( msg == "keyRegister(int key, QString channel, QString message)" ) { |
383 | int k; | 381 | int k; |
384 | QString c, m; | 382 | QString c, m; |
385 | stream >> k; | 383 | stream >> k; |
386 | stream >> c; | 384 | stream >> c; |
387 | stream >> m; | 385 | stream >> m; |
388 | 386 | ||
389 | qWarning( "KeyRegisterReceived: %i, %s, %s", k, ( const char* ) c, ( const char * ) m ); | 387 | qWarning( "KeyRegisterReceived: %i, %s, %s", k, ( const char* ) c, ( const char * ) m ); |
390 | keyRegisterList.append( QCopKeyRegister( k, c, m ) ); | 388 | keyRegisterList.append( QCopKeyRegister( k, c, m ) ); |
391 | } | 389 | } |
392 | #endif | 390 | #endif |
393 | } | 391 | } |
394 | 392 | ||
395 | 393 | ||
396 | void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data ) | 394 | void DesktopApplication::systemMessage( const QCString & msg, const QByteArray & data ) |
397 | { | 395 | { |
398 | #ifdef Q_WS_QWS | 396 | #ifdef Q_WS_QWS |
399 | QDataStream stream ( data, IO_ReadOnly ); | 397 | QDataStream stream ( data, IO_ReadOnly ); |
400 | 398 | ||
401 | if ( msg == "setScreenSaverInterval(int)" ) { | 399 | if ( msg == "setScreenSaverInterval(int)" ) { |
402 | int time; | 400 | int time; |
403 | stream >> time; | 401 | stream >> time; |
404 | m_screensaver-> setInterval( time ); | 402 | m_screensaver-> setInterval( time ); |
405 | } | 403 | } |
406 | else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { | 404 | else if ( msg == "setScreenSaverIntervals(int,int,int)" ) { |
407 | int t1, t2, t3; | 405 | int t1, t2, t3; |
408 | stream >> t1 >> t2 >> t3; | 406 | stream >> t1 >> t2 >> t3; |
409 | m_screensaver-> setIntervals( t1, t2, t3 ); | 407 | m_screensaver-> setIntervals( t1, t2, t3 ); |
410 | } | 408 | } |
411 | else if ( msg == "setBacklight(int)" ) { | 409 | else if ( msg == "setBacklight(int)" ) { |
412 | int bright; | 410 | int bright; |
413 | stream >> bright; | 411 | stream >> bright; |
414 | m_screensaver-> setBacklight( bright ); | 412 | m_screensaver-> setBacklight( bright ); |
415 | } | 413 | } |
416 | else if ( msg == "setScreenSaverMode(int)" ) { | 414 | else if ( msg == "setScreenSaverMode(int)" ) { |
417 | int mode; | 415 | int mode; |
418 | stream >> mode; | 416 | stream >> mode; |
419 | m_screensaver-> setMode ( mode ); | 417 | m_screensaver-> setMode ( mode ); |
420 | } | 418 | } |
421 | else if ( msg == "setDisplayState(int)" ) { | 419 | else if ( msg == "setDisplayState(int)" ) { |
422 | int state; | 420 | int state; |
423 | stream >> state; | 421 | stream >> state; |
424 | m_screensaver-> setDisplayState ( state != 0 ); | 422 | m_screensaver-> setDisplayState ( state != 0 ); |
425 | } | 423 | } |
426 | else if ( msg == "suspend()" ) { | 424 | else if ( msg == "suspend()" ) { |
427 | emit power(); | 425 | emit power(); |
428 | } | 426 | } |
429 | #endif | 427 | #endif |
430 | } | 428 | } |
431 | 429 | ||
432 | enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown; | 430 | enum MemState { Unknown, VeryLow, Low, Normal } memstate = Unknown; |
433 | 431 | ||
434 | #ifdef Q_WS_QWS | 432 | #ifdef Q_WS_QWS |
435 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) | 433 | bool DesktopApplication::qwsEventFilter( QWSEvent *e ) |
436 | { | 434 | { |
437 | qpedesktop->checkMemory(); | 435 | qpedesktop->checkMemory(); |
438 | 436 | ||
439 | if ( e->type == QWSEvent::Key ) { | 437 | if ( e->type == QWSEvent::Key ) { |
440 | QWSKeyEvent * ke = ( QWSKeyEvent * ) e; | 438 | QWSKeyEvent * ke = ( QWSKeyEvent * ) e; |
441 | if ( !loggedin && ke->simpleData.keycode != Key_F34 ) | 439 | if ( !loggedin && ke->simpleData.keycode != Key_F34 ) |
442 | return TRUE; | 440 | return TRUE; |
443 | bool press = ke->simpleData.is_press; | 441 | bool press = ke->simpleData.is_press; |
444 | bool autoRepeat = ke->simpleData.is_auto_repeat; | 442 | bool autoRepeat = ke->simpleData.is_auto_repeat; |
445 | 443 | ||
446 | /* | 444 | /* |
447 | app that registers key/message to be sent back to the app, when it doesn't have focus, | 445 | app that registers key/message to be sent back to the app, when it doesn't have focus, |
448 | when user presses key, unless keyboard has been requested from app. | 446 | when user presses key, unless keyboard has been requested from app. |
449 | will not send multiple repeats if user holds key | 447 | will not send multiple repeats if user holds key |
450 | i.e. one shot | 448 | i.e. one shot |
451 | */ | 449 | */ |
452 | if ( !keyRegisterList.isEmpty() && ke->simpleData.keycode !=0 && press) { | 450 | if ( !keyRegisterList.isEmpty() && ke->simpleData.keycode !=0 && press) { |
453 | // qDebug("<<<<<<<<<<<<<keycode %d", ke->simpleData.keycode); | 451 | // qDebug("<<<<<<<<<<<<<keycode %d", ke->simpleData.keycode); |
454 | KeyRegisterList::Iterator it; | 452 | KeyRegisterList::Iterator it; |
455 | for ( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { | 453 | for ( it = keyRegisterList.begin(); it != keyRegisterList.end(); ++it ) { |
456 | if ( ( *it ).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() ) { | 454 | if ( ( *it ).getKeyCode() == ke->simpleData.keycode && !autoRepeat && !keyboardGrabbed() ) { |
457 | if ( press ) | 455 | if ( press ) |
458 | qDebug( "press" ); | 456 | qDebug( "press" ); |
459 | else | 457 | else |
460 | qDebug( "release" ); | 458 | qDebug( "release" ); |
461 | QCopEnvelope( ( *it ).getChannel().utf8(), ( *it ).getMessage().utf8() ); | 459 | QCopEnvelope( ( *it ).getChannel().utf8(), ( *it ).getMessage().utf8() ); |
462 | } | 460 | } |
463 | } | 461 | } |
464 | } | 462 | } |
465 | 463 | ||
466 | if ( !keyboardGrabbed() ) { | 464 | if ( !keyboardGrabbed() ) { |
467 | if ( ke->simpleData.keycode == Key_F9 ) { | 465 | if ( ke->simpleData.keycode == Key_F9 ) { |
468 | if ( press ) | 466 | if ( press ) |
469 | emit datebook(); | 467 | emit datebook(); |
470 | return TRUE; | 468 | return TRUE; |
471 | } | 469 | } |
472 | if ( ke->simpleData.keycode == Key_F10 ) { | 470 | if ( ke->simpleData.keycode == Key_F10 ) { |
473 | if ( !press && cardSendTimer ) { | 471 | if ( !press && cardSendTimer ) { |
474 | emit contacts(); | 472 | emit contacts(); |
475 | delete cardSendTimer; | 473 | delete cardSendTimer; |
476 | } | 474 | } |
477 | else if ( press ) { | 475 | else if ( press ) { |
478 | cardSendTimer = new QTimer(); | 476 | cardSendTimer = new QTimer(); |
479 | cardSendTimer->start( 2000, TRUE ); | 477 | cardSendTimer->start( 2000, TRUE ); |
480 | connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); | 478 | connect( cardSendTimer, SIGNAL( timeout() ), this, SLOT( sendCard() ) ); |
481 | } | 479 | } |
482 | return TRUE; | 480 | return TRUE; |
483 | } | 481 | } |
484 | /* menu key now opens application menu/toolbar | 482 | /* menu key now opens application menu/toolbar |
485 | if ( ke->simpleData.keycode == Key_F11 ) { | 483 | if ( ke->simpleData.keycode == Key_F11 ) { |
486 | if ( press ) emit menu(); | 484 | if ( press ) emit menu(); |
487 | return TRUE; | 485 | return TRUE; |
488 | } | 486 | } |
489 | */ | 487 | */ |
490 | if ( ke->simpleData.keycode == Key_F12 ) { | 488 | if ( ke->simpleData.keycode == Key_F12 ) { |
491 | while ( activePopupWidget() ) | 489 | while ( activePopupWidget() ) |
492 | activePopupWidget() ->close(); | 490 | activePopupWidget() ->close(); |
493 | if ( press ) | 491 | if ( press ) |
494 | emit launch(); | 492 | emit launch(); |
495 | return TRUE; | 493 | return TRUE; |
496 | } | 494 | } |
497 | if ( ke->simpleData.keycode == Key_F13 ) { | 495 | if ( ke->simpleData.keycode == Key_F13 ) { |
498 | if ( press ) | 496 | if ( press ) |
499 | emit email(); | 497 | emit email(); |
500 | return TRUE; | 498 | return TRUE; |
501 | } | 499 | } |
502 | } | 500 | } |
503 | 501 | ||
504 | if ( ke->simpleData.keycode == Key_F34 ) { | 502 | if ( ke->simpleData.keycode == Key_F34 ) { |
505 | if ( press ) | 503 | if ( press ) |
506 | emit power(); | 504 | emit power(); |
507 | return TRUE; | 505 | return TRUE; |
508 | } | 506 | } |
509 | // This was used for the iPAQ PowerButton | 507 | // This was used for the iPAQ PowerButton |
510 | // See main.cpp for new KeyboardFilter | 508 | // See main.cpp for new KeyboardFilter |
511 | // | 509 | // |
512 | // if ( ke->simpleData.keycode == Key_SysReq ) { | 510 | // if ( ke->simpleData.keycode == Key_SysReq ) { |
513 | // if ( press ) emit power(); | 511 | // if ( press ) emit power(); |
514 | // return TRUE; | 512 | // return TRUE; |
515 | // } | 513 | // } |
516 | if ( ke->simpleData.keycode == Key_F35 ) { | 514 | if ( ke->simpleData.keycode == Key_F35 ) { |
517 | if ( press ) | 515 | if ( press ) |
518 | emit backlight(); | 516 | emit backlight(); |
519 | return TRUE; | 517 | return TRUE; |
520 | } | 518 | } |
521 | if ( ke->simpleData.keycode == Key_F32 ) { | 519 | if ( ke->simpleData.keycode == Key_F32 ) { |
522 | if ( press ) | 520 | if ( press ) |
523 | QCopEnvelope e( "QPE/Desktop", "startSync()" ); | 521 | QCopEnvelope e( "QPE/Desktop", "startSync()" ); |
524 | return TRUE; | 522 | return TRUE; |
525 | } | 523 | } |
526 | if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { | 524 | if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { |
527 | if ( press ) | 525 | if ( press ) |
528 | emit symbol(); | 526 | emit symbol(); |
529 | return TRUE; | 527 | return TRUE; |
530 | } | 528 | } |
531 | if ( ke->simpleData.keycode == Key_NumLock ) { | 529 | if ( ke->simpleData.keycode == Key_NumLock ) { |
532 | if ( press ) | 530 | if ( press ) |
533 | emit numLockStateToggle(); | 531 | emit numLockStateToggle(); |
534 | } | 532 | } |
535 | if ( ke->simpleData.keycode == Key_CapsLock ) { | 533 | if ( ke->simpleData.keycode == Key_CapsLock ) { |
536 | if ( press ) | 534 | if ( press ) |
537 | emit capsLockStateToggle(); | 535 | emit capsLockStateToggle(); |
538 | } | 536 | } |
539 | if ( ( press && !autoRepeat ) || ( !press && autoRepeat ) ) | 537 | if ( ( press && !autoRepeat ) || ( !press && autoRepeat ) ) |
540 | qpedesktop->keyClick(); | 538 | qpedesktop->keyClick(); |
541 | } | 539 | } |
542 | else { | 540 | else { |
543 | if ( e->type == QWSEvent::Mouse ) { | 541 | if ( e->type == QWSEvent::Mouse ) { |
544 | QWSMouseEvent * me = ( QWSMouseEvent * ) e; | 542 | QWSMouseEvent * me = ( QWSMouseEvent * ) e; |
545 | static bool up = TRUE; | 543 | static bool up = TRUE; |
546 | if ( me->simpleData.state & LeftButton ) { | 544 | if ( me->simpleData.state & LeftButton ) { |
547 | if ( up ) { | 545 | if ( up ) { |
548 | up = FALSE; | 546 | up = FALSE; |
549 | qpedesktop->screenClick(); | 547 | qpedesktop->screenClick(); |
550 | } | 548 | } |
551 | } | 549 | } |
552 | else { | 550 | else { |
553 | up = TRUE; | 551 | up = TRUE; |
554 | } | 552 | } |
555 | } | 553 | } |
556 | } | 554 | } |
557 | 555 | ||
558 | return QPEApplication::qwsEventFilter( e ); | 556 | return QPEApplication::qwsEventFilter( e ); |
559 | } | 557 | } |
560 | #endif | 558 | #endif |
561 | 559 | ||
562 | void DesktopApplication::psTimeout() | 560 | void DesktopApplication::psTimeout() |
563 | { | 561 | { |
564 | qpedesktop->checkMemory(); // in case no events are being generated | 562 | qpedesktop->checkMemory(); // in case no events are being generated |
565 | 563 | ||
566 | *ps = PowerStatusManager::readStatus(); | 564 | *ps = PowerStatusManager::readStatus(); |
567 | 565 | ||
568 | if ( ( ps->batteryStatus() == PowerStatus::VeryLow ) ) { | 566 | if ( ( ps->batteryStatus() == PowerStatus::VeryLow ) ) { |
569 | pa->alert( tr( "Battery is running very low." ), 6 ); | 567 | pa->alert( tr( "Battery is running very low." ), 6 ); |
570 | } | 568 | } |
571 | 569 | ||
572 | if ( ps->batteryStatus() == PowerStatus::Critical ) { | 570 | if ( ps->batteryStatus() == PowerStatus::Critical ) { |
573 | pa->alert( tr( "Battery level is critical!\n" | 571 | pa->alert( tr( "Battery level is critical!\n" |
574 | "Keep power off until power restored!" ), 1 ); | 572 | "Keep power off until power restored!" ), 1 ); |
575 | } | 573 | } |
576 | 574 | ||
577 | if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { | 575 | if ( ps->backupBatteryStatus() == PowerStatus::VeryLow ) { |
578 | pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 ); | 576 | pa->alert( tr( "The Back-up battery is very low.\nPlease charge the back-up battery." ), 3 ); |
579 | } | 577 | } |
580 | } | 578 | } |
581 | 579 | ||
582 | 580 | ||
583 | void DesktopApplication::sendCard() | 581 | void DesktopApplication::sendCard() |
584 | { | 582 | { |
585 | delete cardSendTimer; | 583 | delete cardSendTimer; |
586 | cardSendTimer = 0; | 584 | cardSendTimer = 0; |
587 | QString card = getenv( "HOME" ); | 585 | QString card = getenv( "HOME" ); |
588 | card += "/Applications/addressbook/businesscard.vcf"; | 586 | card += "/Applications/addressbook/businesscard.vcf"; |
589 | 587 | ||
590 | if ( QFile::exists( card ) ) { | 588 | if ( QFile::exists( card ) ) { |
591 | QCopEnvelope e( "QPE/Obex", "send(QString,QString,QString)" ); | 589 | QCopEnvelope e( "QPE/Obex", "send(QString,QString,QString)" ); |
592 | QString mimetype = "text/x-vCard"; | 590 | QString mimetype = "text/x-vCard"; |
593 | e << tr( "business card" ) << card << mimetype; | 591 | e << tr( "business card" ) << card << mimetype; |
594 | } | 592 | } |
595 | } | 593 | } |
596 | 594 | ||
597 | #if defined(QPE_HAVE_MEMALERTER) | 595 | #if defined(QPE_HAVE_MEMALERTER) |
598 | QPE_MEMALERTER_IMPL | 596 | QPE_MEMALERTER_IMPL |
599 | #endif | 597 | #endif |
600 | 598 | ||
601 | //=========================================================================== | 599 | //=========================================================================== |
602 | 600 | ||
603 | Desktop::Desktop() : | 601 | Desktop::Desktop() : |
604 | QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), | 602 | QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), |
605 | qcopBridge( 0 ), | 603 | qcopBridge( 0 ), |
606 | transferServer( 0 ), | 604 | transferServer( 0 ), |
607 | packageSlave( 0 ) | 605 | packageSlave( 0 ) |
608 | { | 606 | { |
609 | qpedesktop = this; | 607 | qpedesktop = this; |
610 | 608 | ||
611 | // bg = new Info( this ); | 609 | // bg = new Info( this ); |
612 | tb = new TaskBar; | 610 | tb = new TaskBar; |
613 | 611 | ||
614 | launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); | 612 | launcher = new Launcher( 0, 0, WStyle_Customize | QWidget::WGroupLeader ); |
615 | 613 | ||
616 | connect( launcher, SIGNAL( busy() ), tb, SLOT( startWait() ) ); | 614 | connect( launcher, SIGNAL( busy() ), tb, SLOT( startWait() ) ); |
617 | connect( launcher, SIGNAL( notBusy( const QString& ) ), tb, SLOT( stopWait( const QString& ) ) ); | 615 | connect( launcher, SIGNAL( notBusy( const QString& ) ), tb, SLOT( stopWait( const QString& ) ) ); |
618 | 616 | ||
619 | int displayw = qApp->desktop() ->width(); | 617 | int displayw = qApp->desktop() ->width(); |
620 | int displayh = qApp->desktop() ->height(); | 618 | int displayh = qApp->desktop() ->height(); |
621 | 619 | ||
622 | 620 | ||
623 | QSize sz = tb->sizeHint(); | 621 | QSize sz = tb->sizeHint(); |
624 | 622 | ||
625 | setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); | 623 | setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); |
626 | tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); | 624 | tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); |
627 | 625 | ||
628 | tb->show(); | 626 | tb->show(); |
629 | launcher->showMaximized(); | 627 | launcher->showMaximized(); |
630 | launcher->show(); | 628 | launcher->show(); |
631 | launcher->raise(); | 629 | launcher->raise(); |
632 | #if defined(QPE_HAVE_MEMALERTER) | 630 | #if defined(QPE_HAVE_MEMALERTER) |
633 | 631 | ||
634 | initMemalerter(); | 632 | initMemalerter(); |
635 | #endif | 633 | #endif |
636 | // start services | 634 | // start services |
637 | startTransferServer(); | 635 | startTransferServer(); |
638 | ( void ) new IrServer( this ); | 636 | ( void ) new IrServer( this ); |
639 | rereadVolumes(); | 637 | rereadVolumes(); |
640 | 638 | ||
641 | packageSlave = new PackageSlave( this ); | 639 | packageSlave = new PackageSlave( this ); |
642 | connect( qApp, SIGNAL( volumeChanged( bool ) ), this, SLOT( rereadVolumes() ) ); | 640 | connect( qApp, SIGNAL( volumeChanged( bool ) ), this, SLOT( rereadVolumes() ) ); |
643 | 641 | ||
644 | qApp->installEventFilter( this ); | 642 | qApp->installEventFilter( this ); |
645 | 643 | ||
646 | qApp-> setMainWidget ( launcher ); | 644 | qApp-> setMainWidget ( launcher ); |
647 | } | 645 | } |
648 | 646 | ||
649 | void Desktop::show() | 647 | void Desktop::show() |
650 | { | 648 | { |
651 | login( TRUE ); | 649 | login( TRUE ); |
652 | QWidget::show(); | 650 | QWidget::show(); |
653 | } | 651 | } |
654 | 652 | ||
655 | Desktop::~Desktop() | 653 | Desktop::~Desktop() |
656 | { | 654 | { |
657 | delete launcher; | 655 | delete launcher; |
658 | delete tb; | 656 | delete tb; |
659 | delete qcopBridge; | 657 | delete qcopBridge; |
660 | delete transferServer; | 658 | delete transferServer; |
661 | } | 659 | } |
662 | 660 | ||
663 | bool Desktop::recoverMemory() | 661 | bool Desktop::recoverMemory() |
664 | { | 662 | { |
665 | return tb->recoverMemory(); | 663 | return tb->recoverMemory(); |
666 | } | 664 | } |
667 | 665 | ||
668 | void Desktop::checkMemory() | 666 | void Desktop::checkMemory() |
669 | { | 667 | { |
670 | #if defined(QPE_HAVE_MEMALERTER) | 668 | #if defined(QPE_HAVE_MEMALERTER) |
671 | static bool ignoreNormal = FALSE; | 669 | static bool ignoreNormal = FALSE; |
672 | static bool existingMessage = FALSE; | 670 | static bool existingMessage = FALSE; |
673 | 671 | ||
674 | if ( existingMessage ) | 672 | if ( existingMessage ) |
675 | return ; // don't show a second message while still on first | 673 | return ; // don't show a second message while still on first |
676 | 674 | ||
677 | existingMessage = TRUE; | 675 | existingMessage = TRUE; |
678 | switch ( memstate ) { | 676 | switch ( memstate ) { |
679 | case Unknown: | 677 | case Unknown: |
680 | break; | 678 | break; |
681 | case Low: | 679 | case Low: |
682 | memstate = Unknown; | 680 | memstate = Unknown; |
683 | if ( recoverMemory() ) | 681 | if ( recoverMemory() ) |
684 | ignoreNormal = TRUE; | 682 | ignoreNormal = TRUE; |
685 | else | 683 | else |
686 | QMessageBox::warning( 0 , "Memory Status", | 684 | QMessageBox::warning( 0 , "Memory Status", |
687 | "The memory smacks of shortage. \n" | 685 | "The memory smacks of shortage. \n" |
688 | "Please save data. " ); | 686 | "Please save data. " ); |
689 | break; | 687 | break; |
690 | case Normal: | 688 | case Normal: |
691 | memstate = Unknown; | 689 | memstate = Unknown; |
692 | if ( ignoreNormal ) | 690 | if ( ignoreNormal ) |
693 | ignoreNormal = FALSE; | 691 | ignoreNormal = FALSE; |
694 | // else | 692 | // else |
695 | // QMessageBox::information ( 0 , "Memory Status", | 693 | // QMessageBox::information ( 0 , "Memory Status", |
696 | // "There is enough memory again." ); | 694 | // "There is enough memory again." ); |
697 | break; | 695 | break; |
698 | case VeryLow: | 696 | case VeryLow: |
699 | memstate = Unknown; | 697 | memstate = Unknown; |
700 | QMessageBox::critical( 0 , "Memory Status", | 698 | QMessageBox::critical( 0 , "Memory Status", |
701 | "The memory is very low. \n" | 699 | "The memory is very low. \n" |
702 | "Please end this application \n" | 700 | "Please end this application \n" |
703 | "immediately." ); | 701 | "immediately." ); |
704 | recoverMemory(); | 702 | recoverMemory(); |
705 | } | 703 | } |
706 | existingMessage = FALSE; | 704 | existingMessage = FALSE; |
707 | #endif | 705 | #endif |
708 | } | 706 | } |
709 | 707 | ||
710 | static bool isVisibleWindow( int wid ) | 708 | static bool isVisibleWindow( int wid ) |
711 | { | 709 | { |
710 | #ifdef QWS | ||
712 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 711 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
713 | QWSWindow* w; | 712 | QWSWindow* w; |
714 | for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { | 713 | for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { |
715 | if ( w->winId() == wid ) | 714 | if ( w->winId() == wid ) |
716 | return !w->isFullyObscured(); | 715 | return !w->isFullyObscured(); |
717 | } | 716 | } |
717 | #endif | ||
718 | return FALSE; | 718 | return FALSE; |
719 | } | 719 | } |
720 | 720 | ||
721 | static bool hasVisibleWindow( const QString& clientname ) | 721 | static bool hasVisibleWindow( const QString& clientname ) |
722 | { | 722 | { |
723 | #ifdef QWS | ||
723 | const QList<QWSWindow> &list = qwsServer->clientWindows(); | 724 | const QList<QWSWindow> &list = qwsServer->clientWindows(); |
724 | QWSWindow* w; | 725 | QWSWindow* w; |
725 | for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { | 726 | for ( QListIterator<QWSWindow> it( list ); ( w = it.current() ); ++it ) { |
726 | if ( w->client() ->identity() == clientname && !w->isFullyObscured() ) | 727 | if ( w->client() ->identity() == clientname && !w->isFullyObscured() ) |
727 | return TRUE; | 728 | return TRUE; |
728 | } | 729 | } |
730 | #endif | ||
729 | return FALSE; | 731 | return FALSE; |
730 | } | 732 | } |
731 | 733 | ||
732 | void Desktop::raiseLauncher() | 734 | void Desktop::raiseLauncher() |
733 | { | 735 | { |
734 | Config cfg( "qpe" ); //F12 'Home' | 736 | Config cfg( "qpe" ); //F12 'Home' |
735 | cfg.setGroup( "AppsKey" ); | 737 | cfg.setGroup( "AppsKey" ); |
736 | QString tempItem; | 738 | QString tempItem; |
737 | tempItem = cfg.readEntry( "Middle", "Home" ); | 739 | tempItem = cfg.readEntry( "Middle", "Home" ); |
738 | if ( tempItem == "Home" || tempItem.isEmpty() ) { | 740 | if ( tempItem == "Home" || tempItem.isEmpty() ) { |
739 | home ( ); | 741 | home ( ); |
740 | } | 742 | } |
741 | else { | 743 | else { |
742 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 744 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
743 | e << tempItem; | 745 | e << tempItem; |
744 | } | 746 | } |
745 | } | 747 | } |
746 | 748 | ||
747 | void Desktop::home ( ) | 749 | void Desktop::home ( ) |
748 | { | 750 | { |
749 | if ( isVisibleWindow( launcher->winId() ) ) | 751 | if ( isVisibleWindow( launcher->winId() ) ) |
750 | launcher->nextView(); | 752 | launcher->nextView(); |
751 | else | 753 | else |
752 | launcher->raise(); | 754 | launcher->raise(); |
753 | } | 755 | } |
754 | 756 | ||
755 | void Desktop::executeOrModify( const QString& appLnkFile ) | 757 | void Desktop::executeOrModify( const QString& appLnkFile ) |
756 | { | 758 | { |
757 | AppLnk lnk( MimeType::appsFolderName() + "/" + appLnkFile ); | 759 | AppLnk lnk( MimeType::appsFolderName() + "/" + appLnkFile ); |
758 | if ( lnk.isValid() ) { | 760 | if ( lnk.isValid() ) { |
759 | QCString app = lnk.exec().utf8(); | 761 | QCString app = lnk.exec().utf8(); |
760 | Global::terminateBuiltin( "calibrate" ); | 762 | Global::terminateBuiltin( "calibrate" ); |
761 | if ( QCopChannel::isRegistered( "QPE/Application/" + app ) ) { | 763 | if ( QCopChannel::isRegistered( "QPE/Application/" + app ) ) { |
762 | // MRUList::addTask( &lnk ); | 764 | // MRUList::addTask( &lnk ); |
763 | if ( hasVisibleWindow( app ) ) | 765 | if ( hasVisibleWindow( app ) ) |
764 | QCopChannel::send( "QPE/Application/" + app, "nextView()" ); | 766 | QCopChannel::send( "QPE/Application/" + app, "nextView()" ); |
765 | else | 767 | else |
766 | QCopChannel::send( "QPE/Application/" + app, "raise()" ); | 768 | QCopChannel::send( "QPE/Application/" + app, "raise()" ); |
767 | } | 769 | } |
768 | else { | 770 | else { |
769 | lnk.execute(); | 771 | lnk.execute(); |
770 | } | 772 | } |
771 | } | 773 | } |
772 | } | 774 | } |
773 | 775 | ||
774 | void Desktop::raiseDatebook() | 776 | void Desktop::raiseDatebook() |
775 | { | 777 | { |
776 | Config cfg( "qpe" ); //F9 'Activity' | 778 | Config cfg( "qpe" ); //F9 'Activity' |
777 | cfg.setGroup( "AppsKey" ); | 779 | cfg.setGroup( "AppsKey" ); |
778 | QString tempItem; | 780 | QString tempItem; |
779 | tempItem = cfg.readEntry( "LeftEnd" , "Calendar" ); | 781 | tempItem = cfg.readEntry( "LeftEnd" , "Calendar" ); |
780 | if ( tempItem == "Calendar" || tempItem.isEmpty() ) { | 782 | if ( tempItem == "Calendar" || tempItem.isEmpty() ) { |
781 | tempItem = "datebook"; | 783 | tempItem = "datebook"; |
782 | } | 784 | } |
783 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 785 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
784 | e << tempItem; | 786 | e << tempItem; |
785 | } | 787 | } |
786 | 788 | ||
787 | void Desktop::raiseContacts() | 789 | void Desktop::raiseContacts() |
788 | { | 790 | { |
789 | Config cfg( "qpe" ); //F10, 'Contacts' | 791 | Config cfg( "qpe" ); //F10, 'Contacts' |
790 | cfg.setGroup( "AppsKey" ); | 792 | cfg.setGroup( "AppsKey" ); |
791 | QString tempItem; | 793 | QString tempItem; |
792 | tempItem = cfg.readEntry( "Left2nd", "Address Book" ); | 794 | tempItem = cfg.readEntry( "Left2nd", "Address Book" ); |
793 | if ( tempItem == "Address Book" || tempItem.isEmpty() ) { | 795 | if ( tempItem == "Address Book" || tempItem.isEmpty() ) { |
794 | tempItem = "addressbook"; | 796 | tempItem = "addressbook"; |
795 | } | 797 | } |
796 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 798 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
797 | e << tempItem; | 799 | e << tempItem; |
798 | } | 800 | } |
799 | 801 | ||
800 | void Desktop::raiseMenu() | 802 | void Desktop::raiseMenu() |
801 | { | 803 | { |
802 | Config cfg( "qpe" ); //F11, 'Menu | 804 | Config cfg( "qpe" ); //F11, 'Menu |
803 | cfg.setGroup( "AppsKey" ); | 805 | cfg.setGroup( "AppsKey" ); |
804 | QString tempItem; | 806 | QString tempItem; |
805 | tempItem = cfg.readEntry( "Right2nd" , "Popup Menu" ); | 807 | tempItem = cfg.readEntry( "Right2nd" , "Popup Menu" ); |
806 | if ( tempItem == "Popup Menu" || tempItem.isEmpty() ) { | 808 | if ( tempItem == "Popup Menu" || tempItem.isEmpty() ) { |
807 | Global::terminateBuiltin( "calibrate" ); | 809 | Global::terminateBuiltin( "calibrate" ); |
808 | tb->startMenu() ->launch(); | 810 | tb->startMenu() ->launch(); |
809 | } | 811 | } |
810 | else { | 812 | else { |
811 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 813 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
812 | e << tempItem; | 814 | e << tempItem; |
813 | } | 815 | } |
814 | } | 816 | } |
815 | 817 | ||
816 | void Desktop::raiseEmail() | 818 | void Desktop::raiseEmail() |
817 | { | 819 | { |
818 | Config cfg( "qpe" ); //F13, 'Mail' // only in zaurus, on ipaq mail key is F11 | 820 | Config cfg( "qpe" ); //F13, 'Mail' // only in zaurus, on ipaq mail key is F11 |
819 | cfg.setGroup( "AppsKey" ); | 821 | cfg.setGroup( "AppsKey" ); |
820 | QString tempItem; | 822 | QString tempItem; |
821 | tempItem = cfg.readEntry( "RightEnd", "Mail" ); | 823 | tempItem = cfg.readEntry( "RightEnd", "Mail" ); |
822 | if ( tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty() ) { | 824 | if ( tempItem == "Mail" || tempItem == "qtmail" || tempItem.isEmpty() ) { |
823 | tempItem = "mail"; | 825 | tempItem = "mail"; |
824 | } | 826 | } |
825 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 827 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
826 | e << tempItem; | 828 | e << tempItem; |
827 | } | 829 | } |
828 | 830 | ||
829 | // autoStarts apps on resume and start | 831 | // autoStarts apps on resume and start |
830 | void Desktop::execAutoStart() | 832 | void Desktop::execAutoStart() |
831 | { | 833 | { |
832 | QString appName; | 834 | QString appName; |
833 | int delay; | 835 | int delay; |
834 | QDateTime now = QDateTime::currentDateTime(); | 836 | QDateTime now = QDateTime::currentDateTime(); |
835 | Config cfg( "autostart" ); | 837 | Config cfg( "autostart" ); |
836 | cfg.setGroup( "AutoStart" ); | 838 | cfg.setGroup( "AutoStart" ); |
837 | appName = cfg.readEntry( "Apps", "" ); | 839 | appName = cfg.readEntry( "Apps", "" ); |
838 | delay = ( cfg.readEntry( "Delay", "0" ) ).toInt(); | 840 | delay = ( cfg.readEntry( "Delay", "0" ) ).toInt(); |
839 | // If the time between suspend and resume was longer then the | 841 | // If the time between suspend and resume was longer then the |
840 | // value saved as delay, start the app | 842 | // value saved as delay, start the app |
841 | if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { | 843 | if ( suspendTime.secsTo( now ) >= ( delay * 60 ) && !appName.isEmpty() ) { |
842 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 844 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
843 | e << QString( appName ); | 845 | e << QString( appName ); |
844 | } | 846 | } |
845 | } | 847 | } |
846 | 848 | ||
847 | #if defined(QPE_HAVE_TOGGLELIGHT) | 849 | #if defined(QPE_HAVE_TOGGLELIGHT) |
848 | #include <qpe/config.h> | 850 | #include <qpe/config.h> |
849 | 851 | ||
850 | #include <sys/ioctl.h> | 852 | #include <sys/ioctl.h> |
851 | #include <sys/types.h> | 853 | #include <sys/types.h> |
852 | #include <fcntl.h> | 854 | #include <fcntl.h> |
853 | #include <unistd.h> | 855 | #include <unistd.h> |
854 | #include <errno.h> | 856 | #include <errno.h> |
855 | #include <linux/ioctl.h> | 857 | #include <linux/ioctl.h> |
856 | #include <time.h> | 858 | #include <time.h> |
857 | #endif | 859 | #endif |
858 | 860 | ||
859 | 861 | ||
860 | void Desktop::togglePower() | 862 | void Desktop::togglePower() |
861 | { | 863 | { |
862 | static bool excllock = false; | 864 | static bool excllock = false; |
863 | 865 | ||
864 | qDebug ( "togglePower (locked == %d)", excllock ? 1 : 0 ); | 866 | qDebug ( "togglePower (locked == %d)", excllock ? 1 : 0 ); |
865 | 867 | ||
866 | if ( excllock ) | 868 | if ( excllock ) |
867 | return; | 869 | return; |
868 | 870 | ||
869 | excllock = true; | 871 | excllock = true; |
870 | 872 | ||
871 | bool wasloggedin = loggedin; | 873 | bool wasloggedin = loggedin; |
872 | loggedin = 0; | 874 | loggedin = 0; |
873 | suspendTime = QDateTime::currentDateTime(); | 875 | suspendTime = QDateTime::currentDateTime(); |
874 | 876 | ||
875 | #ifdef QWS | 877 | #ifdef QWS |
876 | if ( Password::needToAuthenticate ( true ) && qt_screen ) { | 878 | if ( Password::needToAuthenticate ( true ) && qt_screen ) { |
877 | // Should use a big black window instead. | 879 | // Should use a big black window instead. |
878 | // But this would not show up fast enough | 880 | // But this would not show up fast enough |
879 | QGfx *g = qt_screen-> screenGfx ( ); | 881 | QGfx *g = qt_screen-> screenGfx ( ); |
880 | g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( )); | 882 | g-> fillRect ( 0, 0, qt_screen-> width ( ), qt_screen-> height ( )); |
881 | delete g; | 883 | delete g; |
882 | } | 884 | } |
883 | #endif | 885 | #endif |
884 | 886 | ||
885 | ODevice::inst ( )-> suspend ( ); | 887 | ODevice::inst ( )-> suspend ( ); |
886 | 888 | ||
887 | DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call | 889 | DesktopApplication::switchLCD ( true ); // force LCD on without slow qcop call |
888 | QWSServer::screenSaverActivate ( false ); | 890 | QWSServer::screenSaverActivate ( false ); |
889 | 891 | ||
890 | { | 892 | { |
891 | QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep | 893 | QCopEnvelope( "QPE/Card", "mtabChanged()" ); // might have changed while asleep |
892 | } | 894 | } |
893 | 895 | ||
894 | if ( wasloggedin ) | 896 | if ( wasloggedin ) |
895 | login ( true ); | 897 | login ( true ); |
896 | 898 | ||
897 | execAutoStart(); | 899 | execAutoStart(); |
898 | //qcopBridge->closeOpenConnections(); | 900 | //qcopBridge->closeOpenConnections(); |
899 | 901 | ||
900 | excllock = false; | 902 | excllock = false; |
901 | } | 903 | } |
902 | 904 | ||
903 | void Desktop::toggleLight() | 905 | void Desktop::toggleLight() |
904 | { | 906 | { |
905 | QCopEnvelope e( "QPE/System", "setBacklight(int)" ); | 907 | QCopEnvelope e( "QPE/System", "setBacklight(int)" ); |
906 | e << -2; // toggle | 908 | e << -2; // toggle |
907 | } | 909 | } |
908 | 910 | ||
909 | void Desktop::toggleSymbolInput() | 911 | void Desktop::toggleSymbolInput() |
910 | { | 912 | { |
911 | tb->toggleSymbolInput(); | 913 | tb->toggleSymbolInput(); |
912 | } | 914 | } |
913 | 915 | ||
914 | void Desktop::toggleNumLockState() | 916 | void Desktop::toggleNumLockState() |
915 | { | 917 | { |
916 | tb->toggleNumLockState(); | 918 | tb->toggleNumLockState(); |
917 | } | 919 | } |
918 | 920 | ||
919 | void Desktop::toggleCapsLockState() | 921 | void Desktop::toggleCapsLockState() |
920 | { | 922 | { |
921 | tb->toggleCapsLockState(); | 923 | tb->toggleCapsLockState(); |
922 | } | 924 | } |
923 | 925 | ||
924 | void Desktop::styleChange( QStyle &s ) | 926 | void Desktop::styleChange( QStyle &s ) |
925 | { | 927 | { |
926 | QWidget::styleChange( s ); | 928 | QWidget::styleChange( s ); |
927 | int displayw = qApp->desktop() ->width(); | 929 | int displayw = qApp->desktop() ->width(); |
928 | int displayh = qApp->desktop() ->height(); | 930 | int displayh = qApp->desktop() ->height(); |
929 | 931 | ||
930 | QSize sz = tb->sizeHint(); | 932 | QSize sz = tb->sizeHint(); |
931 | 933 | ||
932 | tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); | 934 | tb->setGeometry( 0, displayh - sz.height(), displayw, sz.height() ); |
933 | } | 935 | } |
934 | 936 | ||
935 | void DesktopApplication::shutdown() | 937 | void DesktopApplication::shutdown() |
936 | { | 938 | { |
937 | if ( type() != GuiServer ) | 939 | if ( type() != GuiServer ) |
938 | return ; | 940 | return ; |
939 | ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); | 941 | ShutdownImpl *sd = new ShutdownImpl( 0, 0, WDestructiveClose ); |
940 | connect( sd, SIGNAL( shutdown( ShutdownImpl::Type ) ), | 942 | connect( sd, SIGNAL( shutdown( ShutdownImpl::Type ) ), |
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp index 66cc3e6..a5955a4 100644 --- a/core/launcher/launcher.cpp +++ b/core/launcher/launcher.cpp | |||
@@ -1,219 +1,217 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the 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 | // WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT | 21 | // WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT |
22 | // have this class. | 22 | // have this class. |
23 | #define QTOPIA_INTERNAL_FSLP | 23 | #define QTOPIA_INTERNAL_FSLP |
24 | 24 | ||
25 | #ifdef QWS | ||
26 | #include <qpe/qcopenvelope_qws.h> | 25 | #include <qpe/qcopenvelope_qws.h> |
27 | #endif | ||
28 | #include <qpe/resource.h> | 26 | #include <qpe/resource.h> |
29 | #include <qpe/applnk.h> | 27 | #include <qpe/applnk.h> |
30 | #include <qpe/config.h> | 28 | #include <qpe/config.h> |
31 | #include <qpe/global.h> | 29 | #include <qpe/global.h> |
32 | #include <qpe/qpeapplication.h> | 30 | #include <qpe/qpeapplication.h> |
33 | #include <qpe/mimetype.h> | 31 | #include <qpe/mimetype.h> |
34 | #include <qpe/storage.h> | 32 | #include <qpe/storage.h> |
35 | #include <qpe/palmtoprecord.h> | 33 | #include <qpe/palmtoprecord.h> |
36 | 34 | ||
37 | #include <qpe/version.h> | 35 | #include <qpe/version.h> |
38 | 36 | ||
39 | #include <qdir.h> | 37 | #include <qdir.h> |
40 | #ifdef QWS | 38 | #ifdef QWS |
41 | #include <qwindowsystem_qws.h> | 39 | #include <qwindowsystem_qws.h> |
42 | #endif | 40 | #endif |
43 | #include <qtimer.h> | 41 | #include <qtimer.h> |
44 | #include <qcombobox.h> | 42 | #include <qcombobox.h> |
45 | #include <qvbox.h> | 43 | #include <qvbox.h> |
46 | #include <qlayout.h> | 44 | #include <qlayout.h> |
47 | #include <qstyle.h> | 45 | #include <qstyle.h> |
48 | #include <qpushbutton.h> | 46 | #include <qpushbutton.h> |
49 | #include <qtabbar.h> | 47 | #include <qtabbar.h> |
50 | #include <qwidgetstack.h> | 48 | #include <qwidgetstack.h> |
51 | #include <qlayout.h> | 49 | #include <qlayout.h> |
52 | #include <qregexp.h> | 50 | #include <qregexp.h> |
53 | #include <qmessagebox.h> | 51 | #include <qmessagebox.h> |
54 | #include <qframe.h> | 52 | #include <qframe.h> |
55 | #include <qpainter.h> | 53 | #include <qpainter.h> |
56 | #include <qlabel.h> | 54 | #include <qlabel.h> |
57 | #include <qtextstream.h> | 55 | #include <qtextstream.h> |
58 | #include <qpopupmenu.h> | 56 | #include <qpopupmenu.h> |
59 | 57 | ||
60 | #include "launcherview.h" | 58 | #include "launcherview.h" |
61 | #include "launcher.h" | 59 | #include "launcher.h" |
62 | #include "syncdialog.h" | 60 | #include "syncdialog.h" |
63 | #include "desktop.h" | 61 | #include "desktop.h" |
64 | #include <qpe/lnkproperties.h> | 62 | #include <qpe/lnkproperties.h> |
65 | //#include "mrulist.h" | 63 | //#include "mrulist.h" |
66 | #include "qrsync.h" | 64 | #include "qrsync.h" |
67 | #include <stdlib.h> | 65 | #include <stdlib.h> |
68 | #include <unistd.h> | 66 | #include <unistd.h> |
69 | 67 | ||
70 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) | 68 | #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) |
71 | #include <stdio.h> | 69 | #include <stdio.h> |
72 | #include <sys/vfs.h> | 70 | #include <sys/vfs.h> |
73 | #include <mntent.h> | 71 | #include <mntent.h> |
74 | #endif | 72 | #endif |
75 | 73 | ||
76 | #include <qpe/storage.h> | 74 | #include <qpe/storage.h> |
77 | #include "mediummountgui.h" | 75 | #include "mediummountgui.h" |
78 | 76 | ||
79 | namespace { | 77 | namespace { |
80 | QStringList configToMime( Config *cfg ){ | 78 | QStringList configToMime( Config *cfg ){ |
81 | QStringList mimes; | 79 | QStringList mimes; |
82 | bool tmpMime = true; | 80 | bool tmpMime = true; |
83 | cfg->setGroup("mimetypes" ); | 81 | cfg->setGroup("mimetypes" ); |
84 | tmpMime = cfg->readBoolEntry("all" ,true); | 82 | tmpMime = cfg->readBoolEntry("all" ,true); |
85 | if( tmpMime ){ | 83 | if( tmpMime ){ |
86 | mimes << QString::null; | 84 | mimes << QString::null; |
87 | return mimes; | 85 | return mimes; |
88 | }else{ | 86 | }else{ |
89 | tmpMime = cfg->readBoolEntry("audio", true ); | 87 | tmpMime = cfg->readBoolEntry("audio", true ); |
90 | if(tmpMime ) | 88 | if(tmpMime ) |
91 | mimes.append("audio/*" ); | 89 | mimes.append("audio/*" ); |
92 | 90 | ||
93 | tmpMime = cfg->readBoolEntry("image", true ); | 91 | tmpMime = cfg->readBoolEntry("image", true ); |
94 | if(tmpMime ) | 92 | if(tmpMime ) |
95 | mimes.append("image/*" ); | 93 | mimes.append("image/*" ); |
96 | 94 | ||
97 | tmpMime = cfg->readBoolEntry("text", true ); | 95 | tmpMime = cfg->readBoolEntry("text", true ); |
98 | if(tmpMime ) | 96 | if(tmpMime ) |
99 | mimes.append("text/*"); | 97 | mimes.append("text/*"); |
100 | 98 | ||
101 | tmpMime = cfg->readBoolEntry("video", true ); | 99 | tmpMime = cfg->readBoolEntry("video", true ); |
102 | if(tmpMime ) | 100 | if(tmpMime ) |
103 | mimes.append("video/*" ); | 101 | mimes.append("video/*" ); |
104 | } | 102 | } |
105 | return mimes; | 103 | return mimes; |
106 | } | 104 | } |
107 | 105 | ||
108 | } | 106 | } |
109 | 107 | ||
110 | 108 | ||
111 | 109 | ||
112 | //#define SHOW_ALL | 110 | //#define SHOW_ALL |
113 | 111 | ||
114 | class CategoryTab : public QTab | 112 | class CategoryTab : public QTab |
115 | { | 113 | { |
116 | public: | 114 | public: |
117 | CategoryTab( const QIconSet &icon, const QString &text=QString::null ) | 115 | CategoryTab( const QIconSet &icon, const QString &text=QString::null ) |
118 | : QTab( icon, text ) | 116 | : QTab( icon, text ) |
119 | { | 117 | { |
120 | } | 118 | } |
121 | 119 | ||
122 | QColor bgColor; | 120 | QColor bgColor; |
123 | QColor fgColor; | 121 | QColor fgColor; |
124 | }; | 122 | }; |
125 | 123 | ||
126 | //=========================================================================== | 124 | //=========================================================================== |
127 | 125 | ||
128 | CategoryTabWidget::CategoryTabWidget( QWidget* parent ) : | 126 | CategoryTabWidget::CategoryTabWidget( QWidget* parent ) : |
129 | QVBox( parent ) | 127 | QVBox( parent ) |
130 | { | 128 | { |
131 | categoryBar = 0; | 129 | categoryBar = 0; |
132 | stack = 0; | 130 | stack = 0; |
133 | } | 131 | } |
134 | 132 | ||
135 | void CategoryTabWidget::prevTab() | 133 | void CategoryTabWidget::prevTab() |
136 | { | 134 | { |
137 | if ( categoryBar ) { | 135 | if ( categoryBar ) { |
138 | int n = categoryBar->count(); | 136 | int n = categoryBar->count(); |
139 | int tab = categoryBar->currentTab(); | 137 | int tab = categoryBar->currentTab(); |
140 | if ( tab >= 0 ) | 138 | if ( tab >= 0 ) |
141 | categoryBar->setCurrentTab( (tab - 1 + n)%n ); | 139 | categoryBar->setCurrentTab( (tab - 1 + n)%n ); |
142 | } | 140 | } |
143 | } | 141 | } |
144 | 142 | ||
145 | void CategoryTabWidget::nextTab() | 143 | void CategoryTabWidget::nextTab() |
146 | { | 144 | { |
147 | if ( categoryBar ) { | 145 | if ( categoryBar ) { |
148 | int n = categoryBar->count(); | 146 | int n = categoryBar->count(); |
149 | int tab = categoryBar->currentTab(); | 147 | int tab = categoryBar->currentTab(); |
150 | categoryBar->setCurrentTab( (tab + 1)%n ); | 148 | categoryBar->setCurrentTab( (tab + 1)%n ); |
151 | } | 149 | } |
152 | } | 150 | } |
153 | 151 | ||
154 | void CategoryTabWidget::addItem( const QString& linkfile ) | 152 | void CategoryTabWidget::addItem( const QString& linkfile ) |
155 | { | 153 | { |
156 | int i=0; | 154 | int i=0; |
157 | AppLnk *app = new AppLnk(linkfile); | 155 | AppLnk *app = new AppLnk(linkfile); |
158 | if ( !app->isValid() ) { | 156 | if ( !app->isValid() ) { |
159 | delete app; | 157 | delete app; |
160 | app=0; | 158 | app=0; |
161 | } | 159 | } |
162 | if ( !app || !app->file().isEmpty() ) { | 160 | if ( !app || !app->file().isEmpty() ) { |
163 | // A document | 161 | // A document |
164 | delete app; | 162 | delete app; |
165 | app = new DocLnk(linkfile); | 163 | app = new DocLnk(linkfile); |
166 | if ( app->fileKnown() ) { | 164 | if ( app->fileKnown() ) { |
167 | ((LauncherView*)(stack->widget(ids.count()-1)))->addItem(app); | 165 | ((LauncherView*)(stack->widget(ids.count()-1)))->addItem(app); |
168 | } else { | 166 | } else { |
169 | ((LauncherView*)(stack->widget(ids.count()-1)))->sort(); | 167 | ((LauncherView*)(stack->widget(ids.count()-1)))->sort(); |
170 | delete app; | 168 | delete app; |
171 | } | 169 | } |
172 | return; | 170 | return; |
173 | } | 171 | } |
174 | // An application | 172 | // An application |
175 | for ( QStringList::Iterator it=ids.begin(); it!=ids.end(); ++it) { | 173 | for ( QStringList::Iterator it=ids.begin(); it!=ids.end(); ++it) { |
176 | if ( !(*it).isEmpty() ) { | 174 | if ( !(*it).isEmpty() ) { |
177 | QRegExp tf(*it,FALSE,TRUE); | 175 | QRegExp tf(*it,FALSE,TRUE); |
178 | if ( tf.match(app->type()) >= 0 ) { | 176 | if ( tf.match(app->type()) >= 0 ) { |
179 | ((LauncherView*)stack->widget(i))->addItem(app); | 177 | ((LauncherView*)stack->widget(i))->addItem(app); |
180 | return; | 178 | return; |
181 | } | 179 | } |
182 | i++; | 180 | i++; |
183 | } | 181 | } |
184 | } | 182 | } |
185 | 183 | ||
186 | QCopEnvelope e("QPE/TaskBar","reloadApps()"); | 184 | QCopEnvelope e("QPE/TaskBar","reloadApps()"); |
187 | } | 185 | } |
188 | 186 | ||
189 | void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder, | 187 | void CategoryTabWidget::initializeCategories(AppLnkSet* rootFolder, |
190 | AppLnkSet* docFolder, const QList<FileSystem> &fs) | 188 | AppLnkSet* docFolder, const QList<FileSystem> &fs) |
191 | { | 189 | { |
192 | delete categoryBar; | 190 | delete categoryBar; |
193 | categoryBar = new CategoryTabBar( this ); | 191 | categoryBar = new CategoryTabBar( this ); |
194 | QPalette pal = categoryBar->palette(); | 192 | QPalette pal = categoryBar->palette(); |
195 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); | 193 | pal.setColor( QColorGroup::Light, pal.color(QPalette::Active,QColorGroup::Shadow) ); |
196 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); | 194 | pal.setColor( QColorGroup::Background, pal.active().background().light(110) ); |
197 | categoryBar->setPalette( pal ); | 195 | categoryBar->setPalette( pal ); |
198 | 196 | ||
199 | delete stack; | 197 | delete stack; |
200 | stack = new QWidgetStack(this); | 198 | stack = new QWidgetStack(this); |
201 | tabs=0; | 199 | tabs=0; |
202 | 200 | ||
203 | ids.clear(); | 201 | ids.clear(); |
204 | 202 | ||
205 | Config cfg("Launcher"); | 203 | Config cfg("Launcher"); |
206 | 204 | ||
207 | QStringList types = rootFolder->types(); | 205 | QStringList types = rootFolder->types(); |
208 | for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { | 206 | for ( QStringList::Iterator it=types.begin(); it!=types.end(); ++it) { |
209 | if ( !(*it).isEmpty() ) { | 207 | if ( !(*it).isEmpty() ) { |
210 | (void)newView(*it,rootFolder->typePixmap(*it),rootFolder->typeName(*it)); | 208 | (void)newView(*it,rootFolder->typePixmap(*it),rootFolder->typeName(*it)); |
211 | setTabAppearance( *it, cfg ); | 209 | setTabAppearance( *it, cfg ); |
212 | } | 210 | } |
213 | } | 211 | } |
214 | QListIterator<AppLnk> it( rootFolder->children() ); | 212 | QListIterator<AppLnk> it( rootFolder->children() ); |
215 | AppLnk* l; | 213 | AppLnk* l; |
216 | while ( (l=it.current()) ) { | 214 | while ( (l=it.current()) ) { |
217 | if ( l->type() == "Separator" ) { // No tr | 215 | if ( l->type() == "Separator" ) { // No tr |
218 | rootFolder->remove(l); | 216 | rootFolder->remove(l); |
219 | delete l; | 217 | delete l; |
diff --git a/core/launcher/main.cpp b/core/launcher/main.cpp index 073e19a..762a596 100644 --- a/core/launcher/main.cpp +++ b/core/launcher/main.cpp | |||
@@ -1,172 +1,173 @@ | |||
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 "taskbar.h" | 22 | #include "taskbar.h" |
23 | #include "stabmon.h" | 23 | #include "stabmon.h" |
24 | 24 | ||
25 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
26 | #include <qpe/network.h> | 26 | #include <qpe/network.h> |
27 | #include <qpe/config.h> | 27 | #include <qpe/config.h> |
28 | #if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ ) | 28 | #if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ ) |
29 | #include <qpe/custom.h> | 29 | #include <qpe/custom.h> |
30 | #endif | 30 | #endif |
31 | 31 | ||
32 | #include <opie/odevice.h> | 32 | #include <opie/odevice.h> |
33 | 33 | ||
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qimage.h> | ||
35 | #include <qwindowsystem_qws.h> | 36 | #include <qwindowsystem_qws.h> |
36 | #include <qpe/qcopenvelope_qws.h> | 37 | #include <qpe/qcopenvelope_qws.h> |
37 | #include <qpe/alarmserver.h> | 38 | #include <qpe/alarmserver.h> |
38 | 39 | ||
39 | #include <stdlib.h> | 40 | #include <stdlib.h> |
40 | #include <stdio.h> | 41 | #include <stdio.h> |
41 | #include <signal.h> | 42 | #include <signal.h> |
42 | #include <unistd.h> | 43 | #include <unistd.h> |
43 | 44 | ||
44 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) | 45 | #if defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) |
45 | #include "../calibrate/calibrate.h" | 46 | #include "../calibrate/calibrate.h" |
46 | #endif | 47 | #endif |
47 | 48 | ||
48 | using namespace Opie; | 49 | using namespace Opie; |
49 | 50 | ||
50 | void initEnvironment() | 51 | void initEnvironment() |
51 | { | 52 | { |
52 | Config config("locale"); | 53 | Config config("locale"); |
53 | config.setGroup( "Location" ); | 54 | config.setGroup( "Location" ); |
54 | QString tz = config.readEntry( "Timezone", getenv("TZ") ); | 55 | QString tz = config.readEntry( "Timezone", getenv("TZ") ); |
55 | 56 | ||
56 | // if not timezone set, pick New York | 57 | // if not timezone set, pick New York |
57 | if (tz.isNull()) | 58 | if (tz.isNull()) |
58 | tz = "America/New_York"; | 59 | tz = "America/New_York"; |
59 | 60 | ||
60 | setenv( "TZ", tz, 1 ); | 61 | setenv( "TZ", tz, 1 ); |
61 | config.writeEntry( "Timezone", tz); | 62 | config.writeEntry( "Timezone", tz); |
62 | 63 | ||
63 | config.setGroup( "Language" ); | 64 | config.setGroup( "Language" ); |
64 | QString lang = config.readEntry( "Language", getenv("LANG") ); | 65 | QString lang = config.readEntry( "Language", getenv("LANG") ); |
65 | if ( !lang.isNull() ) | 66 | if ( !lang.isNull() ) |
66 | setenv( "LANG", lang, 1 ); | 67 | setenv( "LANG", lang, 1 ); |
67 | } | 68 | } |
68 | 69 | ||
69 | 70 | ||
70 | int initApplication( int argc, char ** argv ) | 71 | int initApplication( int argc, char ** argv ) |
71 | { | 72 | { |
72 | initEnvironment(); | 73 | initEnvironment(); |
73 | 74 | ||
74 | #if !defined(QT_QWS_CASSIOPEIA) && !defined(QT_QWS_IPAQ) && !defined(QT_QWS_EBX) | 75 | #if !defined(QT_QWS_CASSIOPEIA) && !defined(QT_QWS_IPAQ) && !defined(QT_QWS_EBX) |
75 | setenv( "QWS_SIZE", "240x320", 0 ); | 76 | setenv( "QWS_SIZE", "240x320", 0 ); |
76 | #endif | 77 | #endif |
77 | 78 | ||
78 | //Don't flicker at startup: | 79 | //Don't flicker at startup: |
79 | QWSServer::setDesktopBackground( QImage() ); | 80 | QWSServer::setDesktopBackground( QImage() ); |
80 | DesktopApplication a( argc, argv, QApplication::GuiServer ); | 81 | DesktopApplication a( argc, argv, QApplication::GuiServer ); |
81 | 82 | ||
82 | ODevice::inst ( )-> setSoftSuspend ( true ); | 83 | ODevice::inst ( )-> setSoftSuspend ( true ); |
83 | 84 | ||
84 | { // init backlight | 85 | { // init backlight |
85 | QCopEnvelope e("QPE/System", "setBacklight(int)" ); | 86 | QCopEnvelope e("QPE/System", "setBacklight(int)" ); |
86 | e << -3; // Forced on | 87 | e << -3; // Forced on |
87 | } | 88 | } |
88 | 89 | ||
89 | AlarmServer::initialize(); | 90 | AlarmServer::initialize(); |
90 | 91 | ||
91 | Desktop *d = new Desktop(); | 92 | Desktop *d = new Desktop(); |
92 | 93 | ||
93 | QObject::connect( &a, SIGNAL(datebook()), d, SLOT(raiseDatebook()) ); | 94 | QObject::connect( &a, SIGNAL(datebook()), d, SLOT(raiseDatebook()) ); |
94 | QObject::connect( &a, SIGNAL(contacts()), d, SLOT(raiseContacts()) ); | 95 | QObject::connect( &a, SIGNAL(contacts()), d, SLOT(raiseContacts()) ); |
95 | QObject::connect( &a, SIGNAL(launch()), d, SLOT(raiseLauncher()) ); | 96 | QObject::connect( &a, SIGNAL(launch()), d, SLOT(raiseLauncher()) ); |
96 | QObject::connect( &a, SIGNAL(email()), d, SLOT(raiseEmail()) ); | 97 | QObject::connect( &a, SIGNAL(email()), d, SLOT(raiseEmail()) ); |
97 | QObject::connect( &a, SIGNAL(power()), d, SLOT(togglePower()) ); | 98 | QObject::connect( &a, SIGNAL(power()), d, SLOT(togglePower()) ); |
98 | QObject::connect( &a, SIGNAL(backlight()), d, SLOT(toggleLight()) ); | 99 | QObject::connect( &a, SIGNAL(backlight()), d, SLOT(toggleLight()) ); |
99 | QObject::connect( &a, SIGNAL(symbol()), d, SLOT(toggleSymbolInput()) ); | 100 | QObject::connect( &a, SIGNAL(symbol()), d, SLOT(toggleSymbolInput()) ); |
100 | QObject::connect( &a, SIGNAL(numLockStateToggle()), d, SLOT(toggleNumLockState()) ); | 101 | QObject::connect( &a, SIGNAL(numLockStateToggle()), d, SLOT(toggleNumLockState()) ); |
101 | QObject::connect( &a, SIGNAL(capsLockStateToggle()), d, SLOT(toggleCapsLockState()) ); | 102 | QObject::connect( &a, SIGNAL(capsLockStateToggle()), d, SLOT(toggleCapsLockState()) ); |
102 | QObject::connect( &a, SIGNAL(prepareForRestart()), d, SLOT(terminateServers()) ); | 103 | QObject::connect( &a, SIGNAL(prepareForRestart()), d, SLOT(terminateServers()) ); |
103 | 104 | ||
104 | (void)new SysFileMonitor(d); | 105 | (void)new SysFileMonitor(d); |
105 | Network::createServer(d); | 106 | Network::createServer(d); |
106 | 107 | ||
107 | #if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) | 108 | #if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) |
108 | if ( !QFile::exists( "/etc/pointercal" ) ) { | 109 | if ( !QFile::exists( "/etc/pointercal" ) ) { |
109 | // Make sure calibration widget starts on top. | 110 | // Make sure calibration widget starts on top. |
110 | Calibrate *cal = new Calibrate; | 111 | Calibrate *cal = new Calibrate; |
111 | cal->exec(); | 112 | cal->exec(); |
112 | delete cal; | 113 | delete cal; |
113 | } | 114 | } |
114 | #endif | 115 | #endif |
115 | 116 | ||
116 | d->show(); | 117 | d->show(); |
117 | 118 | ||
118 | int rv = a.exec(); | 119 | int rv = a.exec(); |
119 | 120 | ||
120 | delete d; | 121 | delete d; |
121 | 122 | ||
122 | ODevice::inst ( )-> setSoftSuspend ( false ); | 123 | ODevice::inst ( )-> setSoftSuspend ( false ); |
123 | 124 | ||
124 | return rv; | 125 | return rv; |
125 | } | 126 | } |
126 | 127 | ||
127 | static const char *pidfile_path = "/var/run/opie.pid"; | 128 | static const char *pidfile_path = "/var/run/opie.pid"; |
128 | 129 | ||
129 | void create_pidfile ( ) | 130 | void create_pidfile ( ) |
130 | { | 131 | { |
131 | FILE *f; | 132 | FILE *f; |
132 | 133 | ||
133 | if (( f = ::fopen ( pidfile_path, "w" ))) { | 134 | if (( f = ::fopen ( pidfile_path, "w" ))) { |
134 | ::fprintf ( f, "%d", getpid ( )); | 135 | ::fprintf ( f, "%d", getpid ( )); |
135 | ::fclose ( f ); | 136 | ::fclose ( f ); |
136 | } | 137 | } |
137 | } | 138 | } |
138 | 139 | ||
139 | void remove_pidfile ( ) | 140 | void remove_pidfile ( ) |
140 | { | 141 | { |
141 | ::unlink ( pidfile_path ); | 142 | ::unlink ( pidfile_path ); |
142 | } | 143 | } |
143 | 144 | ||
144 | void handle_sigterm ( int /* sig */ ) | 145 | void handle_sigterm ( int /* sig */ ) |
145 | { | 146 | { |
146 | if ( qApp ) | 147 | if ( qApp ) |
147 | qApp-> quit ( ); | 148 | qApp-> quit ( ); |
148 | } | 149 | } |
149 | 150 | ||
150 | int main( int argc, char ** argv ) | 151 | int main( int argc, char ** argv ) |
151 | { | 152 | { |
152 | ::signal ( SIGCHLD, SIG_IGN ); | 153 | ::signal ( SIGCHLD, SIG_IGN ); |
153 | 154 | ||
154 | ::signal ( SIGTERM, handle_sigterm ); | 155 | ::signal ( SIGTERM, handle_sigterm ); |
155 | ::signal ( SIGINT, handle_sigterm ); | 156 | ::signal ( SIGINT, handle_sigterm ); |
156 | 157 | ||
157 | ::setsid ( ); | 158 | ::setsid ( ); |
158 | ::setpgid ( 0, 0 ); | 159 | ::setpgid ( 0, 0 ); |
159 | 160 | ||
160 | ::atexit ( remove_pidfile ); | 161 | ::atexit ( remove_pidfile ); |
161 | create_pidfile ( ); | 162 | create_pidfile ( ); |
162 | 163 | ||
163 | int retVal = initApplication ( argc, argv ); | 164 | int retVal = initApplication ( argc, argv ); |
164 | 165 | ||
165 | // Kill them. Kill them all. | 166 | // Kill them. Kill them all. |
166 | ::kill ( 0, SIGTERM ); | 167 | ::kill ( 0, SIGTERM ); |
167 | ::sleep ( 1 ); | 168 | ::sleep ( 1 ); |
168 | ::kill ( 0, SIGKILL ); | 169 | ::kill ( 0, SIGKILL ); |
169 | 170 | ||
170 | return retVal; | 171 | return retVal; |
171 | } | 172 | } |
172 | 173 | ||
diff --git a/core/launcher/qcopbridge.cpp b/core/launcher/qcopbridge.cpp index 85993ee..6177a7c 100644 --- a/core/launcher/qcopbridge.cpp +++ b/core/launcher/qcopbridge.cpp | |||
@@ -1,218 +1,216 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the 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 | #ifdef QWS | ||
25 | #include <qpe/qcopenvelope_qws.h> | 24 | #include <qpe/qcopenvelope_qws.h> |
26 | #endif | ||
27 | #include <qpe/qpeapplication.h> | 25 | #include <qpe/qpeapplication.h> |
28 | #include <qpe/version.h> | 26 | #include <qpe/version.h> |
29 | 27 | ||
30 | #include <qdir.h> | 28 | #include <qdir.h> |
31 | #include <qfile.h> | 29 | #include <qfile.h> |
32 | #include <qtextstream.h> | 30 | #include <qtextstream.h> |
33 | #include <qdatastream.h> | 31 | #include <qdatastream.h> |
34 | #include <qstringlist.h> | 32 | #include <qstringlist.h> |
35 | #include <qfileinfo.h> | 33 | #include <qfileinfo.h> |
36 | #include <qregexp.h> | 34 | #include <qregexp.h> |
37 | #ifdef QWS | 35 | #ifdef QWS |
38 | #include <qcopchannel_qws.h> | 36 | #include <qcopchannel_qws.h> |
39 | #endif | 37 | #endif |
40 | 38 | ||
41 | #define _XOPEN_SOURCE | 39 | #define _XOPEN_SOURCE |
42 | #include <pwd.h> | 40 | #include <pwd.h> |
43 | #include <sys/types.h> | 41 | #include <sys/types.h> |
44 | #include <unistd.h> | 42 | #include <unistd.h> |
45 | 43 | ||
46 | #if defined(_OS_LINUX_) | 44 | #if defined(_OS_LINUX_) |
47 | #include <shadow.h> | 45 | #include <shadow.h> |
48 | #endif | 46 | #endif |
49 | 47 | ||
50 | //#define INSECURE | 48 | //#define INSECURE |
51 | 49 | ||
52 | const int block_size = 51200; | 50 | const int block_size = 51200; |
53 | 51 | ||
54 | QCopBridge::QCopBridge( Q_UINT16 port, QObject *parent , | 52 | QCopBridge::QCopBridge( Q_UINT16 port, QObject *parent , |
55 | const char* name ) | 53 | const char* name ) |
56 | : QServerSocket( port, 1, parent, name ), | 54 | : QServerSocket( port, 1, parent, name ), |
57 | desktopChannel( 0 ), | 55 | desktopChannel( 0 ), |
58 | cardChannel( 0 ) | 56 | cardChannel( 0 ) |
59 | { | 57 | { |
60 | if ( !ok() ) | 58 | if ( !ok() ) |
61 | qWarning( "Failed to bind to port %d", port ); | 59 | qWarning( "Failed to bind to port %d", port ); |
62 | else { | 60 | else { |
63 | #ifndef QT_NO_COP | 61 | #ifndef QT_NO_COP |
64 | desktopChannel = new QCopChannel( "QPE/Desktop", this ); | 62 | desktopChannel = new QCopChannel( "QPE/Desktop", this ); |
65 | connect( desktopChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 63 | connect( desktopChannel, SIGNAL(received(const QCString &, const QByteArray &)), |
66 | this, SLOT(desktopMessage( const QCString &, const QByteArray &)) ); | 64 | this, SLOT(desktopMessage( const QCString &, const QByteArray &)) ); |
67 | cardChannel = new QCopChannel( "QPE/Card", this ); | 65 | cardChannel = new QCopChannel( "QPE/Card", this ); |
68 | connect( cardChannel, SIGNAL(received(const QCString &, const QByteArray &)), | 66 | connect( cardChannel, SIGNAL(received(const QCString &, const QByteArray &)), |
69 | this, SLOT(desktopMessage( const QCString &, const QByteArray &)) ); | 67 | this, SLOT(desktopMessage( const QCString &, const QByteArray &)) ); |
70 | #endif | 68 | #endif |
71 | } | 69 | } |
72 | sendSync = FALSE; | 70 | sendSync = FALSE; |
73 | } | 71 | } |
74 | 72 | ||
75 | QCopBridge::~QCopBridge() | 73 | QCopBridge::~QCopBridge() |
76 | { | 74 | { |
77 | #ifndef QT_NO_COP | 75 | #ifndef QT_NO_COP |
78 | delete desktopChannel; | 76 | delete desktopChannel; |
79 | #endif | 77 | #endif |
80 | } | 78 | } |
81 | 79 | ||
82 | void QCopBridge::newConnection( int socket ) | 80 | void QCopBridge::newConnection( int socket ) |
83 | { | 81 | { |
84 | QCopBridgePI *pi = new QCopBridgePI( socket, this ); | 82 | QCopBridgePI *pi = new QCopBridgePI( socket, this ); |
85 | openConnections.append( pi ); | 83 | openConnections.append( pi ); |
86 | connect ( pi, SIGNAL( connectionClosed( QCopBridgePI *) ), this, SLOT( connectionClosed( QCopBridgePI *) ) ); | 84 | connect ( pi, SIGNAL( connectionClosed( QCopBridgePI *) ), this, SLOT( connectionClosed( QCopBridgePI *) ) ); |
87 | #ifndef QT_NO_COP | 85 | #ifndef QT_NO_COP |
88 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; | 86 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; |
89 | #endif | 87 | #endif |
90 | 88 | ||
91 | if ( sendSync ) { | 89 | if ( sendSync ) { |
92 | pi ->startSync(); | 90 | pi ->startSync(); |
93 | sendSync = FALSE; | 91 | sendSync = FALSE; |
94 | } | 92 | } |
95 | } | 93 | } |
96 | 94 | ||
97 | void QCopBridge::connectionClosed( QCopBridgePI *pi ) | 95 | void QCopBridge::connectionClosed( QCopBridgePI *pi ) |
98 | { | 96 | { |
99 | openConnections.remove( pi ); | 97 | openConnections.remove( pi ); |
100 | if ( openConnections.count() == 0 ) { | 98 | if ( openConnections.count() == 0 ) { |
101 | #ifndef QT_NO_COP | 99 | #ifndef QT_NO_COP |
102 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 100 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
103 | #endif | 101 | #endif |
104 | } | 102 | } |
105 | } | 103 | } |
106 | 104 | ||
107 | void QCopBridge::closeOpenConnections() | 105 | void QCopBridge::closeOpenConnections() |
108 | { | 106 | { |
109 | QCopBridgePI *pi; | 107 | QCopBridgePI *pi; |
110 | for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() ) | 108 | for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() ) |
111 | pi->close(); | 109 | pi->close(); |
112 | } | 110 | } |
113 | 111 | ||
114 | 112 | ||
115 | void QCopBridge::desktopMessage( const QCString &command, const QByteArray &args ) | 113 | void QCopBridge::desktopMessage( const QCString &command, const QByteArray &args ) |
116 | { | 114 | { |
117 | command.stripWhiteSpace(); | 115 | command.stripWhiteSpace(); |
118 | 116 | ||
119 | int paren = command.find( "(" ); | 117 | int paren = command.find( "(" ); |
120 | if ( paren <= 0 ) { | 118 | if ( paren <= 0 ) { |
121 | qDebug("DesktopMessage: bad qcop syntax"); | 119 | qDebug("DesktopMessage: bad qcop syntax"); |
122 | return; | 120 | return; |
123 | } | 121 | } |
124 | 122 | ||
125 | QString params = command.mid( paren + 1 ); | 123 | QString params = command.mid( paren + 1 ); |
126 | if ( params[params.length()-1] != ')' ) { | 124 | if ( params[params.length()-1] != ')' ) { |
127 | qDebug("DesktopMessage: bad qcop syntax"); | 125 | qDebug("DesktopMessage: bad qcop syntax"); |
128 | return; | 126 | return; |
129 | } | 127 | } |
130 | 128 | ||
131 | params.truncate( params.length()-1 ); | 129 | params.truncate( params.length()-1 ); |
132 | 130 | ||
133 | QStringList paramList = QStringList::split( ",", params ); | 131 | QStringList paramList = QStringList::split( ",", params ); |
134 | QString data; | 132 | QString data; |
135 | if ( paramList.count() ) { | 133 | if ( paramList.count() ) { |
136 | QDataStream stream( args, IO_ReadOnly ); | 134 | QDataStream stream( args, IO_ReadOnly ); |
137 | for ( QStringList::Iterator it = paramList.begin(); it != paramList.end(); ++it ) { | 135 | for ( QStringList::Iterator it = paramList.begin(); it != paramList.end(); ++it ) { |
138 | QString str; | 136 | QString str; |
139 | if ( *it == "QString" ) { | 137 | if ( *it == "QString" ) { |
140 | stream >> str; | 138 | stream >> str; |
141 | } else if ( *it == "QCString" ) { | 139 | } else if ( *it == "QCString" ) { |
142 | QCString cstr; | 140 | QCString cstr; |
143 | stream >> cstr; | 141 | stream >> cstr; |
144 | str = QString::fromLocal8Bit( cstr ); | 142 | str = QString::fromLocal8Bit( cstr ); |
145 | } else if ( *it == "int" ) { | 143 | } else if ( *it == "int" ) { |
146 | int i; | 144 | int i; |
147 | stream >> i; | 145 | stream >> i; |
148 | str = QString::number( i ); | 146 | str = QString::number( i ); |
149 | } else if ( *it == "bool" ) { | 147 | } else if ( *it == "bool" ) { |
150 | int i; | 148 | int i; |
151 | stream >> i; | 149 | stream >> i; |
152 | str = QString::number( i ); | 150 | str = QString::number( i ); |
153 | } else { | 151 | } else { |
154 | qDebug(" cannot route the argument type %s throught the qcop bridge", (*it).latin1() ); | 152 | qDebug(" cannot route the argument type %s throught the qcop bridge", (*it).latin1() ); |
155 | return; | 153 | return; |
156 | } | 154 | } |
157 | QString estr; | 155 | QString estr; |
158 | for (int i=0; i<(int)str.length(); i++) { | 156 | for (int i=0; i<(int)str.length(); i++) { |
159 | QChar ch = str[i]; | 157 | QChar ch = str[i]; |
160 | if ( ch.row() ) | 158 | if ( ch.row() ) |
161 | goto quick; | 159 | goto quick; |
162 | switch (ch.cell()) { | 160 | switch (ch.cell()) { |
163 | case '&': | 161 | case '&': |
164 | estr.append( "&" ); | 162 | estr.append( "&" ); |
165 | break; | 163 | break; |
166 | case ' ': | 164 | case ' ': |
167 | estr.append( "&0x20;" ); | 165 | estr.append( "&0x20;" ); |
168 | break; | 166 | break; |
169 | case '\n': | 167 | case '\n': |
170 | estr.append( "&0x0d;" ); | 168 | estr.append( "&0x0d;" ); |
171 | break; | 169 | break; |
172 | case '\r': | 170 | case '\r': |
173 | estr.append( "&0x0a;" ); | 171 | estr.append( "&0x0a;" ); |
174 | break; | 172 | break; |
175 | default: quick: | 173 | default: quick: |
176 | estr.append(ch); | 174 | estr.append(ch); |
177 | } | 175 | } |
178 | } | 176 | } |
179 | data += " " + estr; | 177 | data += " " + estr; |
180 | } | 178 | } |
181 | } | 179 | } |
182 | QString sendCommand = QString(command.data()) + data; | 180 | QString sendCommand = QString(command.data()) + data; |
183 | // send the command to all open connections | 181 | // send the command to all open connections |
184 | if ( command == "startSync()" ) { | 182 | if ( command == "startSync()" ) { |
185 | // we need to buffer it a bit | 183 | // we need to buffer it a bit |
186 | sendSync = TRUE; | 184 | sendSync = TRUE; |
187 | startTimer( 20000 ); | 185 | startTimer( 20000 ); |
188 | } | 186 | } |
189 | 187 | ||
190 | QCopBridgePI *pi; | 188 | QCopBridgePI *pi; |
191 | for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() ) { | 189 | for ( pi = openConnections.first(); pi != 0; pi = openConnections.next() ) { |
192 | pi->sendDesktopMessage( sendCommand ); | 190 | pi->sendDesktopMessage( sendCommand ); |
193 | } | 191 | } |
194 | } | 192 | } |
195 | 193 | ||
196 | void QCopBridge::timerEvent( QTimerEvent * ) | 194 | void QCopBridge::timerEvent( QTimerEvent * ) |
197 | { | 195 | { |
198 | sendSync = FALSE; | 196 | sendSync = FALSE; |
199 | killTimers(); | 197 | killTimers(); |
200 | } | 198 | } |
201 | 199 | ||
202 | 200 | ||
203 | QCopBridgePI::QCopBridgePI( int socket, QObject *parent , const char* name ) | 201 | QCopBridgePI::QCopBridgePI( int socket, QObject *parent , const char* name ) |
204 | : QSocket( parent, name ) | 202 | : QSocket( parent, name ) |
205 | { | 203 | { |
206 | setSocket( socket ); | 204 | setSocket( socket ); |
207 | 205 | ||
208 | peerport = peerPort(); | 206 | peerport = peerPort(); |
209 | peeraddress = peerAddress(); | 207 | peeraddress = peerAddress(); |
210 | 208 | ||
211 | #ifndef INSECURE | 209 | #ifndef INSECURE |
212 | if ( !SyncAuthentication::isAuthorized(peeraddress) ) { | 210 | if ( !SyncAuthentication::isAuthorized(peeraddress) ) { |
213 | state = Forbidden; | 211 | state = Forbidden; |
214 | startTimer( 0 ); | 212 | startTimer( 0 ); |
215 | } else | 213 | } else |
216 | #endif | 214 | #endif |
217 | { | 215 | { |
218 | state = Connected; | 216 | state = Connected; |
diff --git a/core/launcher/runningappbar.cpp b/core/launcher/runningappbar.cpp index b830d1b..c8f45d5 100644 --- a/core/launcher/runningappbar.cpp +++ b/core/launcher/runningappbar.cpp | |||
@@ -1,240 +1,242 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the 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 | 21 | ||
22 | #define QTOPIA_INTERNAL_PRELOADACCESS | 22 | #define QTOPIA_INTERNAL_PRELOADACCESS |
23 | 23 | ||
24 | // For "kill" | 24 | // For "kill" |
25 | #include <sys/types.h> | 25 | #include <sys/types.h> |
26 | #include <signal.h> | 26 | #include <signal.h> |
27 | 27 | ||
28 | #include <qtimer.h> | 28 | #include <qtimer.h> |
29 | #include <qpopupmenu.h> | 29 | #include <qpopupmenu.h> |
30 | #include <qmessagebox.h> | 30 | #include <qmessagebox.h> |
31 | #include <qpainter.h> | 31 | #include <qpainter.h> |
32 | #include "qprocess.h" | 32 | #include "qprocess.h" |
33 | #include <qpe/qpeapplication.h> | 33 | #include <qpe/qpeapplication.h> |
34 | #include <qpe/applnk.h> | 34 | #include <qpe/applnk.h> |
35 | #include <qpe/qcopenvelope_qws.h> | 35 | #include <qpe/qcopenvelope_qws.h> |
36 | #include <qpe/global.h> | 36 | #include <qpe/global.h> |
37 | #include <qwindowsystem_qws.h> | 37 | #include <qwindowsystem_qws.h> |
38 | #include "runningappbar.h" | 38 | #include "runningappbar.h" |
39 | 39 | ||
40 | RunningAppBar::RunningAppBar(QWidget* parent) | 40 | RunningAppBar::RunningAppBar(QWidget* parent) |
41 | : QFrame(parent), m_AppLnkSet(0L), m_SelectedAppIndex(-1) | 41 | : QFrame(parent), m_AppLnkSet(0L), m_SelectedAppIndex(-1) |
42 | { | 42 | { |
43 | setBackgroundMode( PaletteBackground ); | 43 | setBackgroundMode( PaletteBackground ); |
44 | 44 | ||
45 | m_AppLnkSet = new AppLnkSet( QPEApplication::qpeDir() + "apps" ); | 45 | m_AppLnkSet = new AppLnkSet( QPEApplication::qpeDir() + "apps" ); |
46 | 46 | ||
47 | #ifdef QWS | ||
47 | connect(qwsServer, SIGNAL(newChannel(const QString&)), this, SLOT(newQcopChannel(const QString&))); | 48 | connect(qwsServer, SIGNAL(newChannel(const QString&)), this, SLOT(newQcopChannel(const QString&))); |
48 | connect(qwsServer, SIGNAL(removedChannel(const QString&)), this, SLOT(removedQcopChannel(const QString&))); | 49 | connect(qwsServer, SIGNAL(removedChannel(const QString&)), this, SLOT(removedQcopChannel(const QString&))); |
50 | #endif | ||
49 | QCopChannel* channel = new QCopChannel( "QPE/System", this ); | 51 | QCopChannel* channel = new QCopChannel( "QPE/System", this ); |
50 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 52 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
51 | this, SLOT(received(const QCString&, const QByteArray&)) ); | 53 | this, SLOT(received(const QCString&, const QByteArray&)) ); |
52 | 54 | ||
53 | spacing = AppLnk::smallIconSize()+3; | 55 | spacing = AppLnk::smallIconSize()+3; |
54 | } | 56 | } |
55 | 57 | ||
56 | RunningAppBar::~RunningAppBar() { | 58 | RunningAppBar::~RunningAppBar() { |
57 | } | 59 | } |
58 | 60 | ||
59 | void RunningAppBar::newQcopChannel(const QString& channelName) { | 61 | void RunningAppBar::newQcopChannel(const QString& channelName) { |
60 | QString prefix("QPE/Application/"); | 62 | QString prefix("QPE/Application/"); |
61 | if (channelName.startsWith(prefix)) { | 63 | if (channelName.startsWith(prefix)) { |
62 | QString appName = channelName.mid(prefix.length()); | 64 | QString appName = channelName.mid(prefix.length()); |
63 | // qDebug("App %s just connected!", appName.latin1()); | 65 | // qDebug("App %s just connected!", appName.latin1()); |
64 | const AppLnk* newGuy = m_AppLnkSet->findExec(appName); | 66 | const AppLnk* newGuy = m_AppLnkSet->findExec(appName); |
65 | if (newGuy && !newGuy->isPreloaded()) { | 67 | if (newGuy && !newGuy->isPreloaded()) { |
66 | addTask(*newGuy); | 68 | addTask(*newGuy); |
67 | } | 69 | } |
68 | } | 70 | } |
69 | } | 71 | } |
70 | 72 | ||
71 | void RunningAppBar::removedQcopChannel(const QString& channelName) { | 73 | void RunningAppBar::removedQcopChannel(const QString& channelName) { |
72 | QString prefix("QPE/Application/"); | 74 | QString prefix("QPE/Application/"); |
73 | if (channelName.startsWith(prefix)) { | 75 | if (channelName.startsWith(prefix)) { |
74 | QString appName = channelName.mid(prefix.length()); | 76 | QString appName = channelName.mid(prefix.length()); |
75 | qDebug("App %s just disconnected!", appName.latin1()); | 77 | qDebug("App %s just disconnected!", appName.latin1()); |
76 | const AppLnk* newGuy = m_AppLnkSet->findExec(appName); | 78 | const AppLnk* newGuy = m_AppLnkSet->findExec(appName); |
77 | if (newGuy) { | 79 | if (newGuy) { |
78 | removeTask(*newGuy); | 80 | removeTask(*newGuy); |
79 | } | 81 | } |
80 | } | 82 | } |
81 | } | 83 | } |
82 | 84 | ||
83 | void RunningAppBar::received(const QCString& msg, const QByteArray& data) { | 85 | void RunningAppBar::received(const QCString& msg, const QByteArray& data) { |
84 | // Since fast apps appear and disappear without disconnecting from their | 86 | // Since fast apps appear and disappear without disconnecting from their |
85 | // channel we need to watch for the showing/hiding events and update according. | 87 | // channel we need to watch for the showing/hiding events and update according. |
86 | QDataStream stream( data, IO_ReadOnly ); | 88 | QDataStream stream( data, IO_ReadOnly ); |
87 | if ( msg == "fastAppShowing(QString)") { | 89 | if ( msg == "fastAppShowing(QString)") { |
88 | QString appName; | 90 | QString appName; |
89 | stream >> appName; | 91 | stream >> appName; |
90 | addTask(*m_AppLnkSet->findExec(appName)); | 92 | addTask(*m_AppLnkSet->findExec(appName)); |
91 | } else if ( msg == "fastAppHiding(QString)") { | 93 | } else if ( msg == "fastAppHiding(QString)") { |
92 | QString appName; | 94 | QString appName; |
93 | stream >> appName; | 95 | stream >> appName; |
94 | removeTask(*m_AppLnkSet->findExec(appName)); | 96 | removeTask(*m_AppLnkSet->findExec(appName)); |
95 | } | 97 | } |
96 | } | 98 | } |
97 | 99 | ||
98 | void RunningAppBar::addTask(const AppLnk& appLnk) { | 100 | void RunningAppBar::addTask(const AppLnk& appLnk) { |
99 | // qDebug("Added %s to app list.", appLnk.name().latin1()); | 101 | // qDebug("Added %s to app list.", appLnk.name().latin1()); |
100 | AppLnk* newApp = new AppLnk(appLnk); | 102 | AppLnk* newApp = new AppLnk(appLnk); |
101 | newApp->setExec(appLnk.exec()); | 103 | newApp->setExec(appLnk.exec()); |
102 | m_AppList.prepend(newApp); | 104 | m_AppList.prepend(newApp); |
103 | update(); | 105 | update(); |
104 | } | 106 | } |
105 | 107 | ||
106 | void RunningAppBar::removeTask(const AppLnk& appLnk) { | 108 | void RunningAppBar::removeTask(const AppLnk& appLnk) { |
107 | unsigned int i = 0; | 109 | unsigned int i = 0; |
108 | for (; i < m_AppList.count() ; i++) { | 110 | for (; i < m_AppList.count() ; i++) { |
109 | AppLnk* target = m_AppList.at(i); | 111 | AppLnk* target = m_AppList.at(i); |
110 | if (target->exec() == appLnk.exec()) { | 112 | if (target->exec() == appLnk.exec()) { |
111 | qDebug("Removing %s from app list.", appLnk.name().latin1()); | 113 | qDebug("Removing %s from app list.", appLnk.name().latin1()); |
112 | m_AppList.remove(); | 114 | m_AppList.remove(); |
113 | delete target; | 115 | delete target; |
114 | } | 116 | } |
115 | } | 117 | } |
116 | update(); | 118 | update(); |
117 | } | 119 | } |
118 | 120 | ||
119 | void RunningAppBar::mousePressEvent(QMouseEvent *e) | 121 | void RunningAppBar::mousePressEvent(QMouseEvent *e) |
120 | { | 122 | { |
121 | // Find out if the user is clicking on an app icon... | 123 | // Find out if the user is clicking on an app icon... |
122 | // If so, snag the index so when we repaint we show it | 124 | // If so, snag the index so when we repaint we show it |
123 | // as highlighed. | 125 | // as highlighed. |
124 | m_SelectedAppIndex = 0; | 126 | m_SelectedAppIndex = 0; |
125 | int x=0; | 127 | int x=0; |
126 | QListIterator<AppLnk> it( m_AppList ); | 128 | QListIterator<AppLnk> it( m_AppList ); |
127 | for ( ; it.current(); ++it,++m_SelectedAppIndex,x+=spacing ) { | 129 | for ( ; it.current(); ++it,++m_SelectedAppIndex,x+=spacing ) { |
128 | if ( x + spacing <= width() ) { | 130 | if ( x + spacing <= width() ) { |
129 | if ( e->x() >= x && e->x() < x+spacing ) { | 131 | if ( e->x() >= x && e->x() < x+spacing ) { |
130 | if ( m_SelectedAppIndex < (int)m_AppList.count() ) { | 132 | if ( m_SelectedAppIndex < (int)m_AppList.count() ) { |
131 | repaint(FALSE); | 133 | repaint(FALSE); |
132 | return; | 134 | return; |
133 | } | 135 | } |
134 | } | 136 | } |
135 | } else { | 137 | } else { |
136 | break; | 138 | break; |
137 | } | 139 | } |
138 | } | 140 | } |
139 | m_SelectedAppIndex = -1; | 141 | m_SelectedAppIndex = -1; |
140 | repaint( FALSE ); | 142 | repaint( FALSE ); |
141 | } | 143 | } |
142 | 144 | ||
143 | void RunningAppBar::mouseReleaseEvent(QMouseEvent *e) | 145 | void RunningAppBar::mouseReleaseEvent(QMouseEvent *e) |
144 | { | 146 | { |
145 | if (e->button() == QMouseEvent::RightButton) { | 147 | if (e->button() == QMouseEvent::RightButton) { |
146 | return; | 148 | return; |
147 | } | 149 | } |
148 | if ( m_SelectedAppIndex >= 0 ) { | 150 | if ( m_SelectedAppIndex >= 0 ) { |
149 | QString channel = QString("QPE/Application/") + m_AppList.at(m_SelectedAppIndex)->exec(); | 151 | QString channel = QString("QPE/Application/") + m_AppList.at(m_SelectedAppIndex)->exec(); |
150 | if (QCopChannel::isRegistered(channel.latin1())) { | 152 | if (QCopChannel::isRegistered(channel.latin1())) { |
151 | // qDebug("%s is running!", m_AppList.at(m_SelectedAppIndex)->exec().latin1()); | 153 | // qDebug("%s is running!", m_AppList.at(m_SelectedAppIndex)->exec().latin1()); |
152 | QCopEnvelope e(channel.latin1(), "raise()"); | 154 | QCopEnvelope e(channel.latin1(), "raise()"); |
153 | // This class will delete itself after hearing from the app or the timer expiring | 155 | // This class will delete itself after hearing from the app or the timer expiring |
154 | (void)new AppMonitor(*m_AppList.at(m_SelectedAppIndex), *this); | 156 | (void)new AppMonitor(*m_AppList.at(m_SelectedAppIndex), *this); |
155 | } | 157 | } |
156 | else { | 158 | else { |
157 | removeTask(*m_AppList.at(m_SelectedAppIndex)); | 159 | removeTask(*m_AppList.at(m_SelectedAppIndex)); |
158 | } | 160 | } |
159 | 161 | ||
160 | m_SelectedAppIndex = -1; | 162 | m_SelectedAppIndex = -1; |
161 | update(); | 163 | update(); |
162 | } | 164 | } |
163 | } | 165 | } |
164 | 166 | ||
165 | void RunningAppBar::paintEvent( QPaintEvent * ) | 167 | void RunningAppBar::paintEvent( QPaintEvent * ) |
166 | { | 168 | { |
167 | QPainter p( this ); | 169 | QPainter p( this ); |
168 | AppLnk *curApp; | 170 | AppLnk *curApp; |
169 | int x = 0; | 171 | int x = 0; |
170 | int y = (height() - AppLnk::smallIconSize()) / 2; | 172 | int y = (height() - AppLnk::smallIconSize()) / 2; |
171 | int i = 0; | 173 | int i = 0; |
172 | 174 | ||
173 | //p.fillRect( 0, 0, width(), height(), colorGroup().background() ); | 175 | //p.fillRect( 0, 0, width(), height(), colorGroup().background() ); |
174 | 176 | ||
175 | QListIterator<AppLnk> it(m_AppList); | 177 | QListIterator<AppLnk> it(m_AppList); |
176 | 178 | ||
177 | for (; it.current(); i++, ++it ) { | 179 | for (; it.current(); i++, ++it ) { |
178 | if ( x + spacing <= width() ) { | 180 | if ( x + spacing <= width() ) { |
179 | curApp = it.current(); | 181 | curApp = it.current(); |
180 | if ( (int)i == m_SelectedAppIndex ) | 182 | if ( (int)i == m_SelectedAppIndex ) |
181 | p.fillRect( x, y, spacing, curApp->pixmap().height()+1, colorGroup().highlight() ); | 183 | p.fillRect( x, y, spacing, curApp->pixmap().height()+1, colorGroup().highlight() ); |
182 | else | 184 | else |
183 | // p.eraseRect( x, y, spacing, curApp->pixmap().height()+1 ); | 185 | // p.eraseRect( x, y, spacing, curApp->pixmap().height()+1 ); |
184 | p.drawPixmap( x, y, curApp->pixmap() ); | 186 | p.drawPixmap( x, y, curApp->pixmap() ); |
185 | x += spacing; | 187 | x += spacing; |
186 | } | 188 | } |
187 | } | 189 | } |
188 | } | 190 | } |
189 | 191 | ||
190 | QSize RunningAppBar::sizeHint() const | 192 | QSize RunningAppBar::sizeHint() const |
191 | { | 193 | { |
192 | return QSize( frameWidth(), AppLnk::smallIconSize()+frameWidth()*2+3 ); | 194 | return QSize( frameWidth(), AppLnk::smallIconSize()+frameWidth()*2+3 ); |
193 | } | 195 | } |
194 | 196 | ||
195 | const int AppMonitor::RAISE_TIMEOUT_MS = 500; | 197 | const int AppMonitor::RAISE_TIMEOUT_MS = 500; |
196 | 198 | ||
197 | AppMonitor::AppMonitor(const AppLnk& app, RunningAppBar& owner) | 199 | AppMonitor::AppMonitor(const AppLnk& app, RunningAppBar& owner) |
198 | : QObject(0L), m_Owner(owner), m_App(app), m_PsProc(0L), m_AppKillerBox(0L) { | 200 | : QObject(0L), m_Owner(owner), m_App(app), m_PsProc(0L), m_AppKillerBox(0L) { |
199 | QCopChannel* channel = new QCopChannel( "QPE/System", this ); | 201 | QCopChannel* channel = new QCopChannel( "QPE/System", this ); |
200 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), | 202 | connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), |
201 | this, SLOT(received(const QCString&, const QByteArray&)) ); | 203 | this, SLOT(received(const QCString&, const QByteArray&)) ); |
202 | connect(&m_Timer, SIGNAL(timeout()), this, SLOT(timerExpired())); | 204 | connect(&m_Timer, SIGNAL(timeout()), this, SLOT(timerExpired())); |
203 | m_Timer.start(RAISE_TIMEOUT_MS, TRUE); | 205 | m_Timer.start(RAISE_TIMEOUT_MS, TRUE); |
204 | } | 206 | } |
205 | 207 | ||
206 | AppMonitor::~AppMonitor() { | 208 | AppMonitor::~AppMonitor() { |
207 | if (m_AppKillerBox) { | 209 | if (m_AppKillerBox) { |
208 | delete m_AppKillerBox; | 210 | delete m_AppKillerBox; |
209 | m_AppKillerBox = 0L; | 211 | m_AppKillerBox = 0L; |
210 | } | 212 | } |
211 | } | 213 | } |
212 | 214 | ||
213 | void AppMonitor::received(const QCString& msg, const QByteArray& data) { | 215 | void AppMonitor::received(const QCString& msg, const QByteArray& data) { |
214 | QDataStream stream( data, IO_ReadOnly ); | 216 | QDataStream stream( data, IO_ReadOnly ); |
215 | 217 | ||
216 | if (msg == "appRaised(QString)") { | 218 | if (msg == "appRaised(QString)") { |
217 | QString appName; | 219 | QString appName; |
218 | stream >> appName; | 220 | stream >> appName; |
219 | if (appName == m_App.exec()) { | 221 | if (appName == m_App.exec()) { |
220 | // qDebug("Got a heartbeat from %s", appName.latin1()); | 222 | // qDebug("Got a heartbeat from %s", appName.latin1()); |
221 | m_Timer.stop(); | 223 | m_Timer.stop(); |
222 | // Check to make sure we're not waiting on user input... | 224 | // Check to make sure we're not waiting on user input... |
223 | if (m_AppKillerBox) { | 225 | if (m_AppKillerBox) { |
224 | // If we are, we kill the dialog box, and the code waiting on the result | 226 | // If we are, we kill the dialog box, and the code waiting on the result |
225 | // will clean us up (basically the user said "no"). | 227 | // will clean us up (basically the user said "no"). |
226 | delete m_AppKillerBox; | 228 | delete m_AppKillerBox; |
227 | m_AppKillerBox = 0L; | 229 | m_AppKillerBox = 0L; |
228 | } | 230 | } |
229 | else { | 231 | else { |
230 | // Ok, we're not waiting on user input, so clean us up now. | 232 | // Ok, we're not waiting on user input, so clean us up now. |
231 | // WE DELETE OURSELVES HERE! Don't do anything else!! | 233 | // WE DELETE OURSELVES HERE! Don't do anything else!! |
232 | delete this; | 234 | delete this; |
233 | } | 235 | } |
234 | } | 236 | } |
235 | } | 237 | } |
236 | } | 238 | } |
237 | 239 | ||
238 | void AppMonitor::timerExpired() { | 240 | void AppMonitor::timerExpired() { |
239 | // qDebug("Checking in on %s", m_App.name().latin1()); | 241 | // qDebug("Checking in on %s", m_App.name().latin1()); |
240 | // We store this incase the application responds while we're | 242 | // We store this incase the application responds while we're |
diff --git a/core/launcher/transferserver.cpp b/core/launcher/transferserver.cpp index d2f5501..dea140d 100644 --- a/core/launcher/transferserver.cpp +++ b/core/launcher/transferserver.cpp | |||
@@ -1,253 +1,251 @@ | |||
1 | /********************************************************************** | 1 | /********************************************************************** |
2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. | 2 | ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. |
3 | ** | 3 | ** |
4 | ** This file is part of the Qtopia Environment. | 4 | ** This file is part of the 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 | #include <time.h> | 25 | #include <time.h> |
26 | #include <shadow.h> | 26 | #include <shadow.h> |
27 | 27 | ||
28 | /* we need the _OS_LINUX stuff first ! */ | 28 | /* we need the _OS_LINUX stuff first ! */ |
29 | #include <qglobal.h> | 29 | #include <qglobal.h> |
30 | 30 | ||
31 | #ifndef _OS_LINUX_ | 31 | #ifndef _OS_LINUX_ |
32 | 32 | ||
33 | extern "C" { | 33 | extern "C" { |
34 | #include <uuid/uuid.h> | 34 | #include <uuid/uuid.h> |
35 | #define UUID_H_INCLUDED | 35 | #define UUID_H_INCLUDED |
36 | } | 36 | } |
37 | 37 | ||
38 | #endif // not defined linux | 38 | #endif // not defined linux |
39 | 39 | ||
40 | #if defined(_OS_LINUX_) | 40 | #if defined(_OS_LINUX_) |
41 | #include <shadow.h> | 41 | #include <shadow.h> |
42 | #endif | 42 | #endif |
43 | 43 | ||
44 | #include <qdir.h> | 44 | #include <qdir.h> |
45 | #include <qfile.h> | 45 | #include <qfile.h> |
46 | #include <qtextstream.h> | 46 | #include <qtextstream.h> |
47 | #include <qdatastream.h> | 47 | #include <qdatastream.h> |
48 | #include <qmessagebox.h> | 48 | #include <qmessagebox.h> |
49 | #include <qstringlist.h> | 49 | #include <qstringlist.h> |
50 | #include <qfileinfo.h> | 50 | #include <qfileinfo.h> |
51 | #include <qregexp.h> | 51 | #include <qregexp.h> |
52 | //#include <qpe/qcopchannel_qws.h> | 52 | //#include <qpe/qcopchannel_qws.h> |
53 | #include <qpe/process.h> | 53 | #include <qpe/process.h> |
54 | #include <qpe/global.h> | 54 | #include <qpe/global.h> |
55 | #include <qpe/config.h> | 55 | #include <qpe/config.h> |
56 | #include <qpe/contact.h> | 56 | #include <qpe/contact.h> |
57 | #include <qpe/quuid.h> | 57 | #include <qpe/quuid.h> |
58 | #include <qpe/version.h> | 58 | #include <qpe/version.h> |
59 | #ifdef QWS | ||
60 | #include <qpe/qcopenvelope_qws.h> | 59 | #include <qpe/qcopenvelope_qws.h> |
61 | #endif | ||
62 | 60 | ||
63 | #include "transferserver.h" | 61 | #include "transferserver.h" |
64 | #include "qprocess.h" | 62 | #include "qprocess.h" |
65 | 63 | ||
66 | const int block_size = 51200; | 64 | const int block_size = 51200; |
67 | 65 | ||
68 | TransferServer::TransferServer( Q_UINT16 port, QObject *parent , | 66 | TransferServer::TransferServer( Q_UINT16 port, QObject *parent , |
69 | const char* name ) | 67 | const char* name ) |
70 | : QServerSocket( port, 1, parent, name ) | 68 | : QServerSocket( port, 1, parent, name ) |
71 | { | 69 | { |
72 | if ( !ok() ) | 70 | if ( !ok() ) |
73 | qWarning( "Failed to bind to port %d", port ); | 71 | qWarning( "Failed to bind to port %d", port ); |
74 | } | 72 | } |
75 | 73 | ||
76 | TransferServer::~TransferServer() | 74 | TransferServer::~TransferServer() |
77 | { | 75 | { |
78 | 76 | ||
79 | } | 77 | } |
80 | 78 | ||
81 | void TransferServer::newConnection( int socket ) | 79 | void TransferServer::newConnection( int socket ) |
82 | { | 80 | { |
83 | (void) new ServerPI( socket, this ); | 81 | (void) new ServerPI( socket, this ); |
84 | } | 82 | } |
85 | 83 | ||
86 | /* | 84 | /* |
87 | * small class in anonymous namespace | 85 | * small class in anonymous namespace |
88 | * to generate a QUUid for us | 86 | * to generate a QUUid for us |
89 | */ | 87 | */ |
90 | namespace { | 88 | namespace { |
91 | struct UidGen { | 89 | struct UidGen { |
92 | QString uuid(); | 90 | QString uuid(); |
93 | }; | 91 | }; |
94 | #if !defined(_OS_LINUX_) | 92 | #if !defined(_OS_LINUX_) |
95 | QString UidGen::uuid() { | 93 | QString UidGen::uuid() { |
96 | uuid_t uuid; | 94 | uuid_t uuid; |
97 | uuid_generate( uuid ); | 95 | uuid_generate( uuid ); |
98 | return QUUid( uuid ).toString(); | 96 | return QUUid( uuid ).toString(); |
99 | } | 97 | } |
100 | #else | 98 | #else |
101 | /* | 99 | /* |
102 | * linux got a /proc/sys/kernel/random/uuid file | 100 | * linux got a /proc/sys/kernel/random/uuid file |
103 | * it'll generate the uuids for us | 101 | * it'll generate the uuids for us |
104 | */ | 102 | */ |
105 | QString UidGen::uuid() { | 103 | QString UidGen::uuid() { |
106 | QFile file( "/proc/sys/kernel/random/uuid" ); | 104 | QFile file( "/proc/sys/kernel/random/uuid" ); |
107 | if (!file.open(IO_ReadOnly ) ) | 105 | if (!file.open(IO_ReadOnly ) ) |
108 | return QString::null; | 106 | return QString::null; |
109 | 107 | ||
110 | QTextStream stream(&file); | 108 | QTextStream stream(&file); |
111 | 109 | ||
112 | return "{" + stream.read().stripWhiteSpace() + "}"; | 110 | return "{" + stream.read().stripWhiteSpace() + "}"; |
113 | } | 111 | } |
114 | #endif | 112 | #endif |
115 | } | 113 | } |
116 | 114 | ||
117 | QString SyncAuthentication::serverId() | 115 | QString SyncAuthentication::serverId() |
118 | { | 116 | { |
119 | Config cfg("Security"); | 117 | Config cfg("Security"); |
120 | cfg.setGroup("Sync"); | 118 | cfg.setGroup("Sync"); |
121 | QString r=cfg.readEntry("serverid"); | 119 | QString r=cfg.readEntry("serverid"); |
122 | if ( r.isEmpty() ) { | 120 | if ( r.isEmpty() ) { |
123 | UidGen gen; | 121 | UidGen gen; |
124 | r = gen.uuid(); | 122 | r = gen.uuid(); |
125 | cfg.writeEntry("serverid", r ); | 123 | cfg.writeEntry("serverid", r ); |
126 | } | 124 | } |
127 | return r; | 125 | return r; |
128 | } | 126 | } |
129 | 127 | ||
130 | QString SyncAuthentication::ownerName() | 128 | QString SyncAuthentication::ownerName() |
131 | { | 129 | { |
132 | QString vfilename = Global::applicationFileName("addressbook", | 130 | QString vfilename = Global::applicationFileName("addressbook", |
133 | "businesscard.vcf"); | 131 | "businesscard.vcf"); |
134 | if (QFile::exists(vfilename)) { | 132 | if (QFile::exists(vfilename)) { |
135 | Contact c; | 133 | Contact c; |
136 | c = Contact::readVCard( vfilename )[0]; | 134 | c = Contact::readVCard( vfilename )[0]; |
137 | return c.fullName(); | 135 | return c.fullName(); |
138 | } | 136 | } |
139 | 137 | ||
140 | return ""; | 138 | return ""; |
141 | } | 139 | } |
142 | 140 | ||
143 | QString SyncAuthentication::loginName() | 141 | QString SyncAuthentication::loginName() |
144 | { | 142 | { |
145 | struct passwd *pw; | 143 | struct passwd *pw; |
146 | pw = getpwuid( geteuid() ); | 144 | pw = getpwuid( geteuid() ); |
147 | return QString::fromLocal8Bit( pw->pw_name ); | 145 | return QString::fromLocal8Bit( pw->pw_name ); |
148 | } | 146 | } |
149 | 147 | ||
150 | int SyncAuthentication::isAuthorized(QHostAddress peeraddress) | 148 | int SyncAuthentication::isAuthorized(QHostAddress peeraddress) |
151 | { | 149 | { |
152 | Config cfg("Security"); | 150 | Config cfg("Security"); |
153 | cfg.setGroup("Sync"); | 151 | cfg.setGroup("Sync"); |
154 | // QString allowedstr = cfg.readEntry("auth_peer","192.168.1.0"); | 152 | // QString allowedstr = cfg.readEntry("auth_peer","192.168.1.0"); |
155 | uint auth_peer = cfg.readNumEntry("auth_peer",0xc0a80100); | 153 | uint auth_peer = cfg.readNumEntry("auth_peer",0xc0a80100); |
156 | 154 | ||
157 | // QHostAddress allowed; | 155 | // QHostAddress allowed; |
158 | // allowed.setAddress(allowedstr); | 156 | // allowed.setAddress(allowedstr); |
159 | // uint auth_peer = allowed.ip4Addr(); | 157 | // uint auth_peer = allowed.ip4Addr(); |
160 | uint auth_peer_bits = cfg.readNumEntry("auth_peer_bits",24); | 158 | uint auth_peer_bits = cfg.readNumEntry("auth_peer_bits",24); |
161 | uint mask = auth_peer_bits >= 32 // shifting by 32 is not defined | 159 | uint mask = auth_peer_bits >= 32 // shifting by 32 is not defined |
162 | ? 0xffffffff : (((1<<auth_peer_bits)-1)<<(32-auth_peer_bits)); | 160 | ? 0xffffffff : (((1<<auth_peer_bits)-1)<<(32-auth_peer_bits)); |
163 | return (peeraddress.ip4Addr() & mask) == auth_peer; | 161 | return (peeraddress.ip4Addr() & mask) == auth_peer; |
164 | } | 162 | } |
165 | 163 | ||
166 | bool SyncAuthentication::checkUser( const QString& user ) | 164 | bool SyncAuthentication::checkUser( const QString& user ) |
167 | { | 165 | { |
168 | if ( user.isEmpty() ) return FALSE; | 166 | if ( user.isEmpty() ) return FALSE; |
169 | QString euser = loginName(); | 167 | QString euser = loginName(); |
170 | return user == euser; | 168 | return user == euser; |
171 | } | 169 | } |
172 | 170 | ||
173 | bool SyncAuthentication::checkPassword( const QString& password ) | 171 | bool SyncAuthentication::checkPassword( const QString& password ) |
174 | { | 172 | { |
175 | #ifdef ALLOW_UNIX_USER_FTP | 173 | #ifdef ALLOW_UNIX_USER_FTP |
176 | // First, check system password... | 174 | // First, check system password... |
177 | 175 | ||
178 | struct passwd *pw = 0; | 176 | struct passwd *pw = 0; |
179 | struct spwd *spw = 0; | 177 | struct spwd *spw = 0; |
180 | 178 | ||
181 | pw = getpwuid( geteuid() ); | 179 | pw = getpwuid( geteuid() ); |
182 | spw = getspnam( pw->pw_name ); | 180 | spw = getspnam( pw->pw_name ); |
183 | 181 | ||
184 | QString cpwd = QString::fromLocal8Bit( pw->pw_passwd ); | 182 | QString cpwd = QString::fromLocal8Bit( pw->pw_passwd ); |
185 | if ( cpwd == "x" && spw ) | 183 | if ( cpwd == "x" && spw ) |
186 | cpwd = QString::fromLocal8Bit( spw->sp_pwdp ); | 184 | cpwd = QString::fromLocal8Bit( spw->sp_pwdp ); |
187 | 185 | ||
188 | // Note: some systems use more than crypt for passwords. | 186 | // Note: some systems use more than crypt for passwords. |
189 | QString cpassword = QString::fromLocal8Bit( crypt( password.local8Bit(), cpwd.local8Bit() ) ); | 187 | QString cpassword = QString::fromLocal8Bit( crypt( password.local8Bit(), cpwd.local8Bit() ) ); |
190 | if ( cpwd == cpassword ) | 188 | if ( cpwd == cpassword ) |
191 | return TRUE; | 189 | return TRUE; |
192 | #endif | 190 | #endif |
193 | 191 | ||
194 | static int lastdenial=0; | 192 | static int lastdenial=0; |
195 | static int denials=0; | 193 | static int denials=0; |
196 | int now = time(0); | 194 | int now = time(0); |
197 | 195 | ||
198 | // Detect old Qtopia Desktop (no password) | 196 | // Detect old Qtopia Desktop (no password) |
199 | if ( password.isEmpty() ) { | 197 | if ( password.isEmpty() ) { |
200 | if ( denials < 1 || now > lastdenial+600 ) { | 198 | if ( denials < 1 || now > lastdenial+600 ) { |
201 | QMessageBox::warning( 0,tr("Sync Connection"), | 199 | QMessageBox::warning( 0,tr("Sync Connection"), |
202 | tr("<p>An unauthorized system is requesting access to this device." | 200 | tr("<p>An unauthorized system is requesting access to this device." |
203 | "<p>If you are using a version of Qtopia Desktop older than 1.5.1, " | 201 | "<p>If you are using a version of Qtopia Desktop older than 1.5.1, " |
204 | "please upgrade."), | 202 | "please upgrade."), |
205 | tr("Deny") ); | 203 | tr("Deny") ); |
206 | denials++; | 204 | denials++; |
207 | lastdenial=now; | 205 | lastdenial=now; |
208 | } | 206 | } |
209 | return FALSE; | 207 | return FALSE; |
210 | } | 208 | } |
211 | 209 | ||
212 | // Second, check sync password... | 210 | // Second, check sync password... |
213 | QString pass = password.left(6); | 211 | QString pass = password.left(6); |
214 | /* old QtopiaDesktops are sending | 212 | /* old QtopiaDesktops are sending |
215 | * rootme newer versions got a Qtopia | 213 | * rootme newer versions got a Qtopia |
216 | * prefixed. Qtopia prefix will suceed | 214 | * prefixed. Qtopia prefix will suceed |
217 | * until the sync software syncs up | 215 | * until the sync software syncs up |
218 | * FIXME | 216 | * FIXME |
219 | */ | 217 | */ |
220 | if ( pass == "rootme" || pass == "Qtopia") { | 218 | if ( pass == "rootme" || pass == "Qtopia") { |
221 | 219 | ||
222 | QString cpassword = QString::fromLocal8Bit( crypt( password.mid(8).local8Bit(), "qp" ) ); | 220 | QString cpassword = QString::fromLocal8Bit( crypt( password.mid(8).local8Bit(), "qp" ) ); |
223 | Config cfg("Security"); | 221 | Config cfg("Security"); |
224 | cfg.setGroup("Sync"); | 222 | cfg.setGroup("Sync"); |
225 | QString pwds = cfg.readEntry("Passwords"); | 223 | QString pwds = cfg.readEntry("Passwords"); |
226 | if ( QStringList::split(QChar(' '),pwds).contains(cpassword) ) | 224 | if ( QStringList::split(QChar(' '),pwds).contains(cpassword) ) |
227 | return TRUE; | 225 | return TRUE; |
228 | 226 | ||
229 | // Unrecognized system. Be careful... | 227 | // Unrecognized system. Be careful... |
230 | 228 | ||
231 | if ( (denials > 2 && now < lastdenial+600) | 229 | if ( (denials > 2 && now < lastdenial+600) |
232 | || QMessageBox::warning(0,tr("Sync Connection"), | 230 | || QMessageBox::warning(0,tr("Sync Connection"), |
233 | tr("<p>An unrecognized system is requesting access to this device." | 231 | tr("<p>An unrecognized system is requesting access to this device." |
234 | "<p>If you have just initiated a Sync for the first time, this is normal."), | 232 | "<p>If you have just initiated a Sync for the first time, this is normal."), |
235 | tr("Allow"),tr("Deny"))==1 ) | 233 | tr("Allow"),tr("Deny"))==1 ) |
236 | { | 234 | { |
237 | denials++; | 235 | denials++; |
238 | lastdenial=now; | 236 | lastdenial=now; |
239 | return FALSE; | 237 | return FALSE; |
240 | } else { | 238 | } else { |
241 | denials=0; | 239 | denials=0; |
242 | cfg.writeEntry("Passwords",pwds+" "+cpassword); | 240 | cfg.writeEntry("Passwords",pwds+" "+cpassword); |
243 | return TRUE; | 241 | return TRUE; |
244 | } | 242 | } |
245 | } | 243 | } |
246 | 244 | ||
247 | return FALSE; | 245 | return FALSE; |
248 | } | 246 | } |
249 | 247 | ||
250 | ServerPI::ServerPI( int socket, QObject *parent , const char* name ) | 248 | ServerPI::ServerPI( int socket, QObject *parent , const char* name ) |
251 | : QSocket( parent, name ) , dtp( 0 ), serversocket( 0 ), waitsocket( 0 ) | 249 | : QSocket( parent, name ) , dtp( 0 ), serversocket( 0 ), waitsocket( 0 ) |
252 | { | 250 | { |
253 | state = Connected; | 251 | state = Connected; |