-rw-r--r-- | core/launcher/server.cpp | 467 |
1 files changed, 255 insertions, 212 deletions
diff --git a/core/launcher/server.cpp b/core/launcher/server.cpp index 5ae517b..3bef36e 100644 --- a/core/launcher/server.cpp +++ b/core/launcher/server.cpp | |||
@@ -203,465 +203,509 @@ void Server::activate(const ODeviceButton* button, bool held) | |||
203 | OQCopMessage om; | 203 | OQCopMessage om; |
204 | if ( held ) { | 204 | if ( held ) { |
205 | om = button->heldAction(); | 205 | om = button->heldAction(); |
206 | } else { | 206 | } else { |
207 | om = button->pressedAction(); | 207 | om = button->pressedAction(); |
208 | } | 208 | } |
209 | 209 | ||
210 | if ( om.channel() != "ignore" ) | 210 | if ( om.channel() != "ignore" ) |
211 | om.send(); | 211 | om.send(); |
212 | 212 | ||
213 | // A button with no action defined, will return a null ServiceRequest. Don't attempt | 213 | // A button with no action defined, will return a null ServiceRequest. Don't attempt |
214 | // to send/do anything with this as it will crash | 214 | // to send/do anything with this as it will crash |
215 | /* ### FIXME */ | 215 | /* ### FIXME */ |
216 | #if 0 | 216 | #if 0 |
217 | if ( !sr.isNull() ) { | 217 | if ( !sr.isNull() ) { |
218 | QString app = sr.app(); | 218 | QString app = sr.app(); |
219 | bool vis = hasVisibleWindow(app, app != "qpe"); | 219 | bool vis = hasVisibleWindow(app, app != "qpe"); |
220 | if ( sr.message() == "raise()" && vis ) { | 220 | if ( sr.message() == "raise()" && vis ) { |
221 | sr.setMessage("nextView()"); | 221 | sr.setMessage("nextView()"); |
222 | } else { | 222 | } else { |
223 | // "back door" | 223 | // "back door" |
224 | sr << (int)vis; | 224 | sr << (int)vis; |
225 | } | 225 | } |
226 | 226 | ||
227 | sr.send(); | 227 | sr.send(); |
228 | } | 228 | } |
229 | #endif | 229 | #endif |
230 | } | 230 | } |
231 | 231 | ||
232 | 232 | ||
233 | #ifdef Q_WS_QWS | 233 | #ifdef Q_WS_QWS |
234 | 234 | ||
235 | |||
236 | typedef struct KeyOverride { | 235 | typedef struct KeyOverride { |
237 | ushort scan_code; | 236 | ushort scan_code; |
238 | QWSServer::KeyMap map; | 237 | QWSServer::KeyMap map; |
239 | }; | 238 | }; |
240 | 239 | ||
241 | 240 | ||
242 | static const KeyOverride jp109keys[] = { | 241 | static const KeyOverride jp109keys[] = { |
243 | { 0x03, { Qt::Key_2, '2' , 0x22 , 0xffff } }, | 242 | { 0x03, { Qt::Key_2, '2' , 0x22 , 0xffff } }, |
244 | { 0x07, { Qt::Key_6, '6' , '&' , 0xffff } }, | 243 | { 0x07, { Qt::Key_6, '6' , '&' , 0xffff } }, |
245 | { 0x08, { Qt::Key_7, '7' , '\'' , 0xffff } }, | 244 | { 0x08, { Qt::Key_7, '7' , '\'' , 0xffff } }, |
246 | { 0x09, { Qt::Key_8, '8' , '(' , 0xffff } }, | 245 | { 0x09, { Qt::Key_8, '8' , '(' , 0xffff } }, |
247 | { 0x0a, { Qt::Key_9, '9' , ')' , 0xffff } }, | 246 | { 0x0a, { Qt::Key_9, '9' , ')' , 0xffff } }, |
248 | { 0x0b, { Qt::Key_0, '0' , 0xffff , 0xffff } }, | 247 | { 0x0b, { Qt::Key_0, '0' , 0xffff, 0xffff } }, |
249 | { 0x0c, { Qt::Key_Minus, '-' , '=' , 0xffff } }, | 248 | { 0x0c, { Qt::Key_Minus, '-' , '=' , 0xffff } }, |
250 | { 0x0d, { Qt::Key_AsciiCircum,'^' , '~' , '^' - 64 } }, | 249 | { 0x0d, { Qt::Key_AsciiCircum, '^' , '~' , '^'-64 } }, |
251 | { 0x1a, { Qt::Key_At, '@' , '`' , 0xffff } }, | 250 | { 0x1a, { Qt::Key_At, '@' , '`' , 0xffff } }, |
252 | { 0x1b, { Qt::Key_BraceLeft, '[' , '{' , '[' - 64 } }, | 251 | { 0x1b, { Qt::Key_BraceLeft, '[' , '{' , '['-64 } }, |
253 | { 0x27, { Qt::Key_Semicolon, ';' , '+' , 0xffff } }, | 252 | { 0x27, { Qt::Key_Semicolon, ';' , '+' , 0xffff } }, |
254 | { 0x28, { Qt::Key_Colon, ':' , '*' , 0xffff } }, | 253 | { 0x28, { Qt::Key_Colon, ':' , '*' , 0xffff } }, |
255 | { 0x29, { Qt::Key_Zenkaku_Hankaku, 0xffff , 0xffff , 0xffff } }, | 254 | { 0x29, { Qt::Key_Zenkaku_Hankaku, 0xffff, 0xffff, 0xffff } }, |
256 | { 0x2b, { Qt::Key_BraceRight, ']' , '}' , ']'-64 } }, | 255 | { 0x2b, { Qt::Key_BraceRight, ']' , '}' , ']'-64 } }, |
257 | { 0x70, { Qt::Key_Hiragana_Katakana, 0xffff , 0xffff , 0xffff } }, | 256 | { 0x70, { Qt::Key_Hiragana_Katakana, 0xffff, 0xffff, 0xffff } }, |
258 | { 0x73, { Qt::Key_Backslash, '\\' , '_' , 0xffff } }, | 257 | { 0x73, { Qt::Key_Backslash, '\\' , '_' , 0xffff } }, |
259 | { 0x79, { Qt::Key_Henkan, 0xffff , 0xffff , 0xffff } }, | 258 | { 0x79, { Qt::Key_Henkan, 0xffff, 0xffff, 0xffff } }, |
260 | { 0x7b, { Qt::Key_Muhenkan, 0xffff , 0xffff , 0xffff } }, | 259 | { 0x7b, { Qt::Key_Muhenkan, 0xffff, 0xffff, 0xffff } }, |
261 | { 0x7d, { Qt::Key_yen, 0x00a5 , '|' , 0xffff } }, | 260 | { 0x7d, { Qt::Key_yen, 0x00a5, '|' , 0xffff } }, |
262 | { 0x00, { 0, 0xffff , 0xffff , 0xffff } } | 261 | { 0x00, { 0, 0xffff, 0xffff, 0xffff } } |
263 | }; | 262 | }; |
264 | 263 | ||
265 | bool Server::setKeyboardLayout( const QString &kb ) | 264 | bool Server::setKeyboardLayout( const QString &kb ) |
266 | { | 265 | { |
267 | //quick demo version that can be extended | 266 | //quick demo version that can be extended |
268 | 267 | ||
269 | QIntDict<QWSServer::KeyMap> *om = 0; | 268 | QIntDict<QWSServer::KeyMap> *om = 0; |
270 | if ( kb == "us101" ) { // No tr | 269 | if ( kb == "us101" ) { // No tr |
271 | om = 0; | 270 | om = 0; |
272 | } else if ( kb == "jp109" ) { | 271 | } else if ( kb == "jp109" ) { |
273 | om = new QIntDict<QWSServer::KeyMap>(37); | 272 | om = new QIntDict<QWSServer::KeyMap>(37); |
274 | const KeyOverride *k = jp109keys; | 273 | const KeyOverride *k = jp109keys; |
275 | while ( k->scan_code ) { | 274 | while ( k->scan_code ) { |
276 | om->insert( k->scan_code, &k->map ); | 275 | om->insert( k->scan_code, &k->map ); |
277 | k++; | 276 | k++; |
278 | } | 277 | } |
279 | } | 278 | } |
280 | QWSServer::setOverrideKeys( om ); | 279 | QWSServer::setOverrideKeys( om ); |
281 | 280 | ||
282 | return TRUE; | 281 | return TRUE; |
283 | } | 282 | } |
284 | |||
285 | #endif | 283 | #endif |
286 | 284 | ||
287 | void Server::systemMsg(const QCString &msg, const QByteArray &data) | 285 | void Server::systemMsg(const QCString &msg, const QByteArray &data) |
288 | { | 286 | { |
289 | QDataStream stream( data, IO_ReadOnly ); | 287 | QDataStream stream( data, IO_ReadOnly ); |
290 | 288 | ||
291 | if ( msg == "securityChanged()" ) { | 289 | if ( msg == "securityChanged()" ) { |
292 | if ( transferServer ) | 290 | if ( transferServer ) |
293 | transferServer->authorizeConnections(); | 291 | transferServer->authorizeConnections(); |
292 | |||
294 | if ( qcopBridge ) | 293 | if ( qcopBridge ) |
295 | qcopBridge->authorizeConnections(); | 294 | qcopBridge->authorizeConnections(); |
296 | } | 295 | } else |
297 | /* ### FIXME support TempScreenSaverMode */ | 296 | |
298 | #if 0 | 297 | #if 0 |
299 | else if ( msg == "setTempScreenSaverMode(int,int)" ) { | 298 | /* ### FIXME support TempScreenSaverMode */ |
300 | int mode, pid; | 299 | if ( msg == "setTempScreenSaverMode(int,int)" ) { |
301 | stream >> mode >> pid; | 300 | int mode, pid; |
302 | tsmMonitor->setTempMode(mode, pid); | 301 | stream >> mode >> pid; |
303 | } | 302 | tsmMonitor->setTempMode(mode, pid); |
303 | } else | ||
304 | #endif | 304 | #endif |
305 | else if ( msg == "linkChanged(QString)" ) { | 305 | |
306 | QString link; | 306 | if ( msg == "linkChanged(QString)" ) { |
307 | stream >> link; | 307 | QString link; |
308 | odebug << "desktop.cpp systemMsg -> linkchanged( " << link << " )" << oendl; | 308 | stream >> link; |
309 | docList->linkChanged(link); | 309 | odebug << "desktop.cpp systemMsg -> linkchanged( " << link << " )" << oendl; |
310 | } else if ( msg == "serviceChanged(QString)" ) { | 310 | docList->linkChanged(link); |
311 | MimeType::updateApplications(); | 311 | } else |
312 | } else if ( msg == "mkdir(QString)" ) { | 312 | |
313 | QString dir; | 313 | if ( msg == "serviceChanged(QString)" ) { |
314 | stream >> dir; | 314 | MimeType::updateApplications(); |
315 | if ( !dir.isEmpty() ) | 315 | } else |
316 | mkdir( dir ); | 316 | |
317 | } else if ( msg == "rdiffGenSig(QString,QString)" ) { | 317 | if ( msg == "mkdir(QString)" ) { |
318 | QString baseFile, sigFile; | 318 | QString dir; |
319 | stream >> baseFile >> sigFile; | 319 | stream >> dir; |
320 | QRsync::generateSignature( baseFile, sigFile ); | 320 | if ( !dir.isEmpty() ) |
321 | } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { | 321 | mkdir( dir ); |
322 | QString baseFile, sigFile, deltaFile; | 322 | } else |
323 | stream >> baseFile >> sigFile >> deltaFile; | 323 | |
324 | QRsync::generateDiff( baseFile, sigFile, deltaFile ); | 324 | if ( msg == "rdiffGenSig(QString,QString)" ) { |
325 | } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { | 325 | QString baseFile, sigFile; |
326 | QString baseFile, deltaFile; | 326 | stream >> baseFile >> sigFile; |
327 | stream >> baseFile >> deltaFile; | 327 | QRsync::generateSignature( baseFile, sigFile ); |
328 | if ( !QFile::exists( baseFile ) ) { | 328 | } else |
329 | QFile f( baseFile ); | 329 | |
330 | f.open( IO_WriteOnly ); | 330 | if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { |
331 | f.close(); | 331 | QString baseFile, sigFile, deltaFile; |
332 | } | 332 | stream >> baseFile >> sigFile >> deltaFile; |
333 | QRsync::applyDiff( baseFile, deltaFile ); | 333 | QRsync::generateDiff( baseFile, sigFile, deltaFile ); |
334 | } else | ||
335 | |||
336 | if ( msg == "rdiffApplyPatch(QString,QString)" ) { | ||
337 | QString baseFile, deltaFile; | ||
338 | stream >> baseFile >> deltaFile; | ||
339 | if ( !QFile::exists( baseFile ) ) { | ||
340 | QFile f( baseFile ); | ||
341 | f.open( IO_WriteOnly ); | ||
342 | f.close(); | ||
343 | } | ||
344 | QRsync::applyDiff( baseFile, deltaFile ); | ||
334 | #ifndef QT_NO_COP | 345 | #ifndef QT_NO_COP |
335 | QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); | 346 | QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); |
336 | e << baseFile; | 347 | e << baseFile; |
337 | #endif | 348 | #endif |
338 | } else if ( msg == "rdiffCleanup()" ) { | 349 | } else |
339 | mkdir( "/tmp/rdiff" ); | 350 | |
340 | QDir dir; | 351 | if ( msg == "rdiffCleanup()" ) { |
341 | dir.setPath( "/tmp/rdiff" ); | 352 | mkdir( "/tmp/rdiff" ); |
342 | QStringList entries = dir.entryList(); | 353 | QDir dir; |
343 | for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) | 354 | dir.setPath( "/tmp/rdiff" ); |
344 | dir.remove( *it ); | 355 | QStringList entries = dir.entryList(); |
345 | } else if ( msg == "sendHandshakeInfo()" ) { | 356 | for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) |
346 | QString home = getenv( "HOME" ); | 357 | dir.remove( *it ); |
358 | } else | ||
359 | |||
360 | if ( msg == "sendHandshakeInfo()" ) { | ||
361 | QString home = getenv( "HOME" ); | ||
347 | #ifndef QT_NO_COP | 362 | #ifndef QT_NO_COP |
348 | QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); | 363 | QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); |
349 | e << home; | 364 | e << home; |
350 | int locked = (int) ServerApplication::screenLocked(); | 365 | int locked = (int) ServerApplication::screenLocked(); |
351 | e << locked; | 366 | e << locked; |
352 | #endif | 367 | #endif |
368 | } else | ||
353 | 369 | ||
354 | } | ||
355 | /* | 370 | /* |
356 | * QtopiaDesktop relies on the major number | 371 | * QtopiaDesktop relies on the major number |
357 | * to start with 1. We're at 0.9 | 372 | * to start with 1. We're at 0.9 |
358 | * so wee need to fake at least 1.4 to be able | 373 | * so wee need to fake at least 1.4 to be able |
359 | * to sync with QtopiaDesktop1.6 | 374 | * to sync with QtopiaDesktop1.6 |
360 | */ | 375 | */ |
361 | else if ( msg == "sendVersionInfo()" ) { | 376 | if ( msg == "sendVersionInfo()" ) { |
362 | QCopEnvelope e( "QPE/Desktop", "versionInfo(QString,QString)" ); | 377 | QCopEnvelope e( "QPE/Desktop", "versionInfo(QString,QString)" ); |
363 | /* ### FIXME Architecture ### */ | 378 | /* ### FIXME Architecture ### */ |
364 | e << QString::fromLatin1("1.7") << "Uncustomized Device"; | 379 | e << QString::fromLatin1("1.7") << "Uncustomized Device"; |
365 | } else if ( msg == "sendCardInfo()" ) { | 380 | } else |
381 | |||
382 | if ( msg == "sendCardInfo()" ) { | ||
366 | #ifndef QT_NO_COP | 383 | #ifndef QT_NO_COP |
367 | QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); | 384 | QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); |
368 | #endif | 385 | #endif |
369 | storage->update(); | 386 | storage->update(); |
370 | const QList<FileSystem> &fs = storage->fileSystems(); | 387 | const QList<FileSystem> &fs = storage->fileSystems(); |
371 | QListIterator<FileSystem> it ( fs ); | 388 | QListIterator<FileSystem> it ( fs ); |
372 | QString s; | 389 | QString s; |
373 | QString homeDir = getenv("HOME"); | 390 | QString homeDir = getenv("HOME"); |
374 | QString homeFs, homeFsPath; | 391 | QString homeFs, homeFsPath; |
375 | for ( ; it.current(); ++it ) { | 392 | for ( ; it.current(); ++it ) { |
376 | int k4 = (*it)->blockSize()/256; | 393 | int k4 = (*it)->blockSize()/256; |
377 | if ( (*it)->isRemovable() ) { | 394 | if ( (*it)->isRemovable() ) { |
378 | s += (*it)->name() + "=" + (*it)->path() + "/Documents " // No tr | 395 | s += (*it)->name() + "=" + (*it)->path() + "/Documents " // No tr |
379 | + QString::number( (*it)->availBlocks() * k4/4 ) | 396 | + QString::number( (*it)->availBlocks() * k4/4 ) |
380 | + "K " + (*it)->options() + ";"; | 397 | + "K " + (*it)->options() + ";"; |
381 | } else if ( homeDir.contains( (*it)->path() ) && | 398 | } else if ( homeDir.contains( (*it)->path() ) && |
382 | (*it)->path().length() > homeFsPath.length() ) { | 399 | (*it)->path().length() > homeFsPath.length() ) { |
383 | homeFsPath = (*it)->path(); | 400 | homeFsPath = (*it)->path(); |
384 | homeFs = | 401 | homeFs = |
385 | (*it)->name() + "=" + homeDir + "/Documents " // No tr | 402 | (*it)->name() + "=" + homeDir + "/Documents " // No tr |
386 | + QString::number( (*it)->availBlocks() * k4/4 ) | 403 | + QString::number( (*it)->availBlocks() * k4/4 ) |
387 | + "K " + (*it)->options() + ";"; | 404 | + "K " + (*it)->options() + ";"; |
405 | } | ||
388 | } | 406 | } |
389 | } | 407 | if ( !homeFs.isEmpty() ) |
390 | if ( !homeFs.isEmpty() ) | 408 | s += homeFs; |
391 | s += homeFs; | ||
392 | |||
393 | #ifndef QT_NO_COP | 409 | #ifndef QT_NO_COP |
394 | e << s; | 410 | e << s; |
395 | #endif | 411 | #endif |
396 | } else if ( msg == "sendSyncDate(QString)" ) { | 412 | } else |
397 | QString app; | 413 | |
398 | stream >> app; | 414 | if ( msg == "sendSyncDate(QString)" ) { |
399 | Config cfg( "qpe" ); | 415 | QString app; |
400 | cfg.setGroup("SyncDate"); | 416 | stream >> app; |
417 | Config cfg( "qpe" ); | ||
418 | cfg.setGroup("SyncDate"); | ||
401 | #ifndef QT_NO_COP | 419 | #ifndef QT_NO_COP |
402 | QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); | 420 | QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); |
403 | e << app << cfg.readEntry( app ); | 421 | e << app << cfg.readEntry( app ); |
404 | #endif | 422 | #endif |
405 | //odebug << "QPE/System sendSyncDate for " << app.latin1() << ": response " | 423 | //odebug << "QPE/System sendSyncDate for " << app.latin1() << ": response " |
406 | // << cfg.readEntry( app ).latin1() << oendl; | 424 | // << cfg.readEntry( app ).latin1() << oendl; |
407 | } else if ( msg == "setSyncDate(QString,QString)" ) { | 425 | } else |
408 | QString app, date; | 426 | |
409 | stream >> app >> date; | 427 | if ( msg == "setSyncDate(QString,QString)" ) { |
410 | Config cfg( "qpe" ); | 428 | QString app, date; |
411 | cfg.setGroup("SyncDate"); | 429 | stream >> app >> date; |
412 | cfg.writeEntry( app, date ); | 430 | Config cfg( "qpe" ); |
413 | //odebug << "setSyncDate(QString,QString) " << app << " " << date << "" << oendl; | 431 | cfg.setGroup("SyncDate"); |
414 | } else if ( msg == "startSync(QString)" ) { | 432 | cfg.writeEntry( app, date ); |
415 | QString what; | 433 | //odebug << "setSyncDate(QString,QString) " << app << " " << date << "" << oendl; |
416 | stream >> what; | 434 | } else |
417 | delete syncDialog; | 435 | |
418 | syncDialog = new SyncDialog( this, what ); | 436 | if ( msg == "startSync(QString)" ) { |
419 | syncDialog->show(); | 437 | QString what; |
420 | connect( syncDialog, SIGNAL(cancel()), SLOT(cancelSync()) ); | 438 | stream >> what; |
421 | } else if ( msg == "stopSync()") { | 439 | delete syncDialog; |
422 | delete syncDialog; | 440 | syncDialog = new SyncDialog( this, what ); |
423 | syncDialog = 0; | 441 | syncDialog->show(); |
424 | } else if (msg == "restoreDone(QString)") { | 442 | connect( syncDialog, SIGNAL(cancel()), SLOT(cancelSync()) ); |
425 | docList->restoreDone(); | 443 | } else |
426 | } else if ( msg == "getAllDocLinks()" ) { | 444 | |
427 | docList->sendAllDocLinks(); | 445 | if ( msg == "stopSync()") { |
428 | } | 446 | delete syncDialog; |
447 | syncDialog = 0; | ||
448 | } else | ||
449 | |||
450 | if (msg == "restoreDone(QString)") { | ||
451 | docList->restoreDone(); | ||
452 | } else | ||
453 | |||
454 | if ( msg == "getAllDocLinks()" ) { | ||
455 | docList->sendAllDocLinks(); | ||
456 | } else | ||
457 | |||
429 | #ifdef Q_WS_QWS | 458 | #ifdef Q_WS_QWS |
430 | else if ( msg == "setMouseProto(QString)" ) { | 459 | if ( msg == "setMouseProto(QString)" ) { |
431 | QString mice; | 460 | QString mice; |
432 | stream >> mice; | 461 | stream >> mice; |
433 | setenv("QWS_MOUSE_PROTO",mice.latin1(),1); | 462 | setenv("QWS_MOUSE_PROTO",mice.latin1(),1); |
434 | qwsServer->openMouse(); | 463 | qwsServer->openMouse(); |
435 | } else if ( msg == "setKeyboard(QString)" ) { | 464 | } else |
436 | QString kb; | 465 | |
437 | stream >> kb; | 466 | if ( msg == "setKeyboard(QString)" ) { |
438 | setenv("QWS_KEYBOARD",kb.latin1(),1); | 467 | QString kb; |
439 | qwsServer->openKeyboard(); | 468 | stream >> kb; |
440 | 469 | setenv("QWS_KEYBOARD",kb.latin1(),1); | |
441 | } else if ( msg == "setKeyboardAutoRepeat(int,int)" ) { | 470 | qwsServer->openKeyboard(); |
442 | int delay, period; | 471 | } else |
443 | stream >> delay >> period; | 472 | |
444 | qwsSetKeyboardAutoRepeat( delay, period ); | 473 | if ( msg == "setKeyboardAutoRepeat(int,int)" ) { |
445 | Config cfg( "qpe" ); | 474 | int delay, period; |
446 | cfg.setGroup("Keyboard"); | 475 | stream >> delay >> period; |
447 | cfg.writeEntry( "RepeatDelay", delay ); | 476 | qwsSetKeyboardAutoRepeat( delay, period ); |
448 | cfg.writeEntry( "RepeatPeriod", period ); | 477 | Config cfg( "qpe" ); |
449 | } else if ( msg == "setKeyboardLayout(QString)" ) { | 478 | cfg.setGroup("Keyboard"); |
450 | QString kb; | 479 | cfg.writeEntry( "RepeatDelay", delay ); |
451 | stream >> kb; | 480 | cfg.writeEntry( "RepeatPeriod", period ); |
452 | setKeyboardLayout( kb ); | 481 | } else |
453 | Config cfg( "qpe" ); | 482 | |
454 | cfg.setGroup("Keyboard"); | 483 | if ( msg == "setKeyboardLayout(QString)" ) { |
455 | cfg.writeEntry( "Layout", kb ); | 484 | QString kb; |
456 | } else if ( msg == "autoStart(QString)" ) { | 485 | stream >> kb; |
486 | setKeyboardLayout( kb ); | ||
487 | Config cfg( "qpe" ); | ||
488 | cfg.setGroup("Keyboard"); | ||
489 | cfg.writeEntry( "Layout", kb ); | ||
490 | } else | ||
491 | |||
492 | if ( msg == "autoStart(QString)" ) { | ||
457 | QString appName; | 493 | QString appName; |
458 | stream >> appName; | 494 | stream >> appName; |
459 | Config cfg( "autostart" ); | 495 | Config cfg( "autostart" ); |
460 | cfg.setGroup( "AutoStart" ); | 496 | cfg.setGroup( "AutoStart" ); |
461 | if ( appName.compare("clear") == 0){ | 497 | if ( appName.compare("clear") == 0){ |
462 | cfg.writeEntry("Apps", ""); | 498 | cfg.writeEntry("Apps", ""); |
463 | } | 499 | } |
464 | } else if ( msg == "autoStart(QString,QString)" ) { | 500 | } else |
501 | |||
502 | if ( msg == "autoStart(QString,QString)" ) { | ||
465 | QString modifier, appName; | 503 | QString modifier, appName; |
466 | stream >> modifier >> appName; | 504 | stream >> modifier >> appName; |
467 | Config cfg( "autostart" ); | 505 | Config cfg( "autostart" ); |
468 | cfg.setGroup( "AutoStart" ); | 506 | cfg.setGroup( "AutoStart" ); |
469 | if ( modifier.compare("add") == 0 ){ | 507 | if ( modifier.compare("add") == 0 ){ |
470 | // only add if appname is entered | 508 | // only add if appname is entered |
471 | if (!appName.isEmpty()) { | 509 | if (!appName.isEmpty()) { |
472 | cfg.writeEntry("Apps", appName); | 510 | cfg.writeEntry("Apps", appName); |
473 | } | 511 | } |
474 | } else if (modifier.compare("remove") == 0 ) { | 512 | } else if (modifier.compare("remove") == 0 ) { |
475 | // need to change for multiple entries | 513 | // need to change for multiple entries |
476 | // actually remove is right now simular to clear, but in future there | 514 | // actually remove is right now simular to clear, but in future there |
477 | // should be multiple apps in autostart possible. | 515 | // should be multiple apps in autostart possible. |
478 | QString checkName; | 516 | QString checkName; |
479 | checkName = cfg.readEntry("Apps", ""); | 517 | checkName = cfg.readEntry("Apps", ""); |
480 | if (checkName == appName) { | 518 | if (checkName == appName) { |
481 | cfg.writeEntry("Apps", ""); | 519 | cfg.writeEntry("Apps", ""); |
482 | } | 520 | } |
483 | } | 521 | } |
484 | // case the autostart feature should be delayed | 522 | // case the autostart feature should be delayed |
485 | } else if ( msg == "autoStart(QString,QString,QString)") { | 523 | } else |
486 | QString modifier, appName, delay; | 524 | |
487 | stream >> modifier >> appName >> delay; | 525 | if ( msg == "autoStart(QString,QString,QString)") { |
526 | QString modifier, appName, delay; | ||
527 | stream >> modifier >> appName >> delay; | ||
488 | Config cfg( "autostart" ); | 528 | Config cfg( "autostart" ); |
489 | 529 | ||
490 | cfg.setGroup( "AutoStart" ); | 530 | cfg.setGroup( "AutoStart" ); |
491 | if ( modifier.compare("add") == 0 ){ | 531 | if ( modifier.compare("add") == 0 ){ |
492 | // only add it appname is entered | 532 | // only add it appname is entered |
493 | if (!appName.isEmpty()) { | 533 | if (!appName.isEmpty()) { |
494 | cfg.writeEntry("Apps", appName); | 534 | cfg.writeEntry("Apps", appName); |
495 | cfg.writeEntry("Delay", delay); | 535 | cfg.writeEntry("Delay", delay); |
496 | } | 536 | } |
497 | } else { | ||
498 | } | 537 | } |
499 | } | 538 | } |
500 | #endif | 539 | #endif |
501 | } | 540 | } |
502 | 541 | ||
503 | void Server::receiveTaskBar(const QCString &msg, const QByteArray &data) | 542 | void Server::receiveTaskBar(const QCString &msg, const QByteArray &data) |
504 | { | 543 | { |
505 | QDataStream stream( data, IO_ReadOnly ); | 544 | QDataStream stream( data, IO_ReadOnly ); |
506 | 545 | ||
507 | if ( msg == "reloadApps()" ) { | 546 | if ( msg == "reloadApps()" ) { |
508 | docList->reloadAppLnks(); | 547 | docList->reloadAppLnks(); |
509 | } else if ( msg == "soundAlarm()" ) { | 548 | } else |
510 | ServerApplication::soundAlarm(); | 549 | |
511 | } | 550 | if ( msg == "soundAlarm()" ) { |
512 | else if ( msg == "setLed(int,bool)" ) { | 551 | ServerApplication::soundAlarm(); |
513 | int led, status; | 552 | } else |
514 | stream >> led >> status; | 553 | |
554 | if ( msg == "setLed(int,bool)" ) { | ||
555 | int led, status; | ||
556 | stream >> led >> status; | ||
515 | 557 | ||
516 | QValueList <OLed> ll = ODevice::inst ( )-> ledList ( ); | 558 | QValueList <OLed> ll = ODevice::inst ( )-> ledList ( ); |
517 | if ( ll. count ( )) { | 559 | if ( ll. count ( )) { |
518 | OLed l = ll. contains ( Led_Mail ) ? Led_Mail : ll [0]; | 560 | OLed l = ll. contains ( Led_Mail ) ? Led_Mail : ll [0]; |
519 | bool canblink = ODevice::inst ( )-> ledStateList ( l ). contains ( Led_BlinkSlow ); | 561 | bool canblink = ODevice::inst ( )-> ledStateList ( l ). contains ( Led_BlinkSlow ); |
520 | 562 | ||
521 | ODevice::inst ( )-> setLedState ( l, status ? ( canblink ? Led_BlinkSlow : Led_On ) : Led_Off ); | 563 | ODevice::inst ( )-> setLedState ( l, status ? ( canblink ? Led_BlinkSlow : Led_On ) : Led_Off ); |
522 | } | 564 | } |
523 | } | 565 | } |
524 | } | 566 | } |
525 | 567 | ||
526 | void Server::cancelSync() | 568 | void Server::cancelSync() |
527 | { | 569 | { |
528 | #ifndef QT_NO_COP | 570 | #ifndef QT_NO_COP |
529 | QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); | 571 | QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); |
530 | #endif | 572 | #endif |
531 | delete syncDialog; | 573 | delete syncDialog; |
532 | syncDialog = 0; | 574 | syncDialog = 0; |
533 | } | 575 | } |
534 | 576 | ||
535 | bool Server::mkdir(const QString &localPath) | 577 | bool Server::mkdir(const QString &localPath) |
536 | { | 578 | { |
537 | QDir fullDir(localPath); | 579 | QDir fullDir(localPath); |
538 | if (fullDir.exists()) | 580 | if (fullDir.exists()) |
539 | return true; | 581 | return true; |
540 | 582 | ||
541 | // at this point the directory doesn't exist | 583 | // at this point the directory doesn't exist |
542 | // go through the directory tree and start creating the direcotories | 584 | // go through the directory tree and start creating the direcotories |
543 | // that don't exist; if we can't create the directories, return false | 585 | // that don't exist; if we can't create the directories, return false |
544 | 586 | ||
545 | QString dirSeps = "/"; | 587 | QString dirSeps = "/"; |
546 | int dirIndex = localPath.find(dirSeps); | 588 | int dirIndex = localPath.find(dirSeps); |
547 | QString checkedPath; | 589 | QString checkedPath; |
548 | 590 | ||
549 | // didn't find any seps; weird, use the cur dir instead | 591 | // didn't find any seps; weird, use the cur dir instead |
550 | if (dirIndex == -1) { | 592 | if (dirIndex == -1) { |
551 | //odebug << "No seperators found in path " << localPath << "" << oendl; | 593 | //odebug << "No seperators found in path " << localPath << "" << oendl; |
552 | checkedPath = QDir::currentDirPath(); | 594 | checkedPath = QDir::currentDirPath(); |
553 | } | 595 | } |
554 | 596 | ||
555 | while (checkedPath != localPath) { | 597 | while (checkedPath != localPath) { |
556 | // no more seperators found, use the local path | 598 | // no more seperators found, use the local path |
557 | if (dirIndex == -1) | 599 | if (dirIndex == -1) { |
558 | checkedPath = localPath; | 600 | checkedPath = localPath; |
559 | else { | 601 | } else { |
560 | // the next directory to check | 602 | // the next directory to check |
561 | checkedPath = localPath.left(dirIndex) + "/"; | 603 | checkedPath = localPath.left(dirIndex) + "/"; |
562 | // advance the iterator; the next dir seperator | 604 | // advance the iterator; the next dir seperator |
563 | dirIndex = localPath.find(dirSeps, dirIndex+1); | 605 | dirIndex = localPath.find(dirSeps, dirIndex+1); |
564 | } | 606 | } |
565 | 607 | ||
566 | QDir checkDir(checkedPath); | 608 | QDir checkDir(checkedPath); |
567 | if (!checkDir.exists()) { | 609 | if (!checkDir.exists()) { |
568 | //odebug << "mkdir making dir " << checkedPath << "" << oendl; | 610 | //odebug << "mkdir making dir " << checkedPath << "" << oendl; |
569 | 611 | ||
570 | if (!checkDir.mkdir(checkedPath)) { | 612 | if (!checkDir.mkdir(checkedPath)) { |
571 | odebug << "Unable to make directory " << checkedPath << "" << oendl; | 613 | odebug << "Unable to make directory " << checkedPath << "" << oendl; |
572 | return FALSE; | 614 | return FALSE; |
573 | } | 615 | } |
574 | } | 616 | } |
575 | 617 | ||
576 | } | 618 | } |
577 | return TRUE; | 619 | return TRUE; |
578 | } | 620 | } |
579 | 621 | ||
580 | void Server::styleChange( QStyle &s ) | 622 | void Server::styleChange( QStyle &s ) |
581 | { | 623 | { |
582 | QWidget::styleChange( s ); | 624 | QWidget::styleChange( s ); |
583 | } | 625 | } |
584 | 626 | ||
585 | void Server::startTransferServer() | 627 | void Server::startTransferServer() |
586 | { | 628 | { |
587 | if ( !qcopBridge ) { | 629 | if ( !qcopBridge ) { |
588 | // start qcop bridge server | 630 | // start qcop bridge server |
589 | qcopBridge = new QCopBridge( 4243 ); | 631 | qcopBridge = new QCopBridge( 4243 ); |
590 | if ( qcopBridge->ok() ) { | 632 | if ( qcopBridge->ok() ) { |
591 | // ... OK | 633 | // ... OK |
592 | connect( qcopBridge, SIGNAL(connectionClosed(const QHostAddress&)), | 634 | connect( qcopBridge, SIGNAL(connectionClosed(const QHostAddress&)), |
593 | this, SLOT(syncConnectionClosed(const QHostAddress&)) ); | 635 | this, SLOT(syncConnectionClosed(const QHostAddress&)) ); |
594 | } else { | 636 | } else { |
595 | delete qcopBridge; | 637 | delete qcopBridge; |
596 | qcopBridge = 0; | 638 | qcopBridge = 0; |
597 | } | 639 | } |
598 | } | 640 | } |
641 | |||
599 | if ( !transferServer ) { | 642 | if ( !transferServer ) { |
600 | // start transfer server | 643 | // start transfer server |
601 | transferServer = new TransferServer( 4242 ); | 644 | transferServer = new TransferServer( 4242 ); |
602 | if ( transferServer->ok() ) { | 645 | if ( transferServer->ok() ) { |
603 | // ... OK | 646 | // ... OK |
604 | } else { | 647 | } else { |
605 | delete transferServer; | 648 | delete transferServer; |
606 | transferServer = 0; | 649 | transferServer = 0; |
607 | } | 650 | } |
651 | |||
652 | if ( !qcopBridge ) | ||
653 | tid_xfer = startTimer( 2000 ); | ||
608 | } | 654 | } |
609 | if ( !transferServer || !qcopBridge ) | ||
610 | tid_xfer = startTimer( 2000 ); | ||
611 | } | 655 | } |
612 | 656 | ||
613 | void Server::timerEvent( QTimerEvent *e ) | 657 | void Server::timerEvent( QTimerEvent *e ) |
614 | { | 658 | { |
615 | if ( e->timerId() == tid_xfer ) { | 659 | if ( e->timerId() == tid_xfer ) { |
616 | killTimer( tid_xfer ); | 660 | killTimer( tid_xfer ); |
617 | tid_xfer = 0; | 661 | tid_xfer = 0; |
618 | startTransferServer(); | 662 | startTransferServer(); |
619 | } | 663 | } |
620 | /* ### FIXME today startin */ | ||
621 | #if 0 | 664 | #if 0 |
665 | /* ### FIXME today startin */ | ||
622 | else if ( e->timerId() == tid_today ) { | 666 | else if ( e->timerId() == tid_today ) { |
623 | QDate today = QDate::currentDate(); | 667 | QDate today = QDate::currentDate(); |
624 | if ( today != last_today_show ) { | 668 | if ( today != last_today_show ) { |
625 | last_today_show = today; | 669 | last_today_show = today; |
626 | Config cfg("today"); | 670 | Config cfg("today"); |
627 | cfg.setGroup("Start"); | 671 | cfg.setGroup("Start"); |
628 | #ifndef QPE_DEFAULT_TODAY_MODE | 672 | #ifndef QPE_DEFAULT_TODAY_MODE |
629 | #define QPE_DEFAULT_TODAY_MODE "Never" | 673 | #define QPE_DEFAULT_TODAY_MODE "Never" |
630 | #endif | 674 | #endif |
631 | if ( cfg.readEntry("Mode",QPE_DEFAULT_TODAY_MODE) == "Daily" ) { | 675 | if ( cfg.readEntry("Mode",QPE_DEFAULT_TODAY_MODE) == "Daily" ) { |
632 | QCopEnvelope env(Service::channel("today"),"raise()"); | 676 | QCopEnvelope env(Service::channel("today"),"raise()"); |
677 | } | ||
633 | } | 678 | } |
634 | } | 679 | } |
635 | } | ||
636 | #endif | 680 | #endif |
637 | } | 681 | } |
638 | 682 | ||
639 | void Server::terminateServers() | 683 | void Server::terminateServers() |
640 | { | 684 | { |
641 | delete transferServer; | 685 | delete transferServer; |
642 | delete qcopBridge; | 686 | delete qcopBridge; |
643 | transferServer = 0; | 687 | transferServer = 0; |
644 | qcopBridge = 0; | 688 | qcopBridge = 0; |
645 | } | 689 | } |
646 | 690 | ||
647 | void Server::syncConnectionClosed( const QHostAddress & ) | 691 | void Server::syncConnectionClosed( const QHostAddress & ) |
648 | { | 692 | { |
649 | odebug << "Lost sync connection" << oendl; | 693 | odebug << "Lost sync connection" << oendl; |
650 | delete syncDialog; | 694 | delete syncDialog; |
651 | syncDialog = 0; | 695 | syncDialog = 0; |
652 | } | 696 | } |
653 | 697 | ||
654 | void Server::pokeTimeMonitors() | 698 | void Server::pokeTimeMonitors() |
655 | { | 699 | { |
656 | #if 0 | 700 | #if 0 |
657 | // inform all TimeMonitors | 701 | // inform all TimeMonitors |
658 | QStrList tms = Service::channels("TimeMonitor"); | 702 | QStrList tms = Service::channels("TimeMonitor"); |
659 | for (const char* ch = tms.first(); ch; ch=tms.next()) { | 703 | for (const char* ch = tms.first(); ch; ch=tms.next()) { |
660 | QString t = getenv("TZ"); | 704 | QString t = getenv("TZ"); |
661 | QCopEnvelope e(ch, "timeChange(QString)"); | 705 | QCopEnvelope e(ch, "timeChange(QString)"); |
662 | e << t; | 706 | e << t; |
663 | } | 707 | } |
664 | #endif | 708 | #endif |
665 | } | 709 | } |
666 | 710 | ||
667 | void Server::applicationLaunched(int, const QString &app) | 711 | void Server::applicationLaunched(int, const QString &app) |
@@ -671,37 +715,36 @@ void Server::applicationLaunched(int, const QString &app) | |||
671 | 715 | ||
672 | void Server::applicationTerminated(int pid, const QString &app) | 716 | void Server::applicationTerminated(int pid, const QString &app) |
673 | { | 717 | { |
674 | serverGui->applicationStateChanged( app, ServerInterface::Terminated ); | 718 | serverGui->applicationStateChanged( app, ServerInterface::Terminated ); |
675 | #if 0 | 719 | #if 0 |
676 | tsmMonitor->applicationTerminated( pid ); | 720 | tsmMonitor->applicationTerminated( pid ); |
677 | #else | 721 | #else |
678 | Q_UNUSED( pid ) | 722 | Q_UNUSED( pid ) |
679 | #endif | 723 | #endif |
680 | } | 724 | } |
681 | 725 | ||
682 | void Server::applicationConnected(const QString &app) | 726 | void Server::applicationConnected(const QString &app) |
683 | { | 727 | { |
684 | serverGui->applicationStateChanged( app, ServerInterface::Running ); | 728 | serverGui->applicationStateChanged( app, ServerInterface::Running ); |
685 | } | 729 | } |
686 | 730 | ||
687 | void Server::storageChanged() | 731 | void Server::storageChanged() |
688 | { | 732 | { |
689 | system( "opie-update-symlinks" ); | 733 | system( "opie-update-symlinks" ); |
690 | serverGui->storageChanged( storage->fileSystems() ); | 734 | serverGui->storageChanged( storage->fileSystems() ); |
691 | docList->storageChanged(); | 735 | docList->storageChanged(); |
692 | } | 736 | } |
693 | 737 | ||
694 | 738 | ||
695 | 739 | ||
696 | void Server::preloadApps() | 740 | void Server::preloadApps() |
697 | { | 741 | { |
698 | Config cfg("Launcher"); | 742 | Config cfg("Launcher"); |
699 | cfg.setGroup("Preload"); | 743 | cfg.setGroup("Preload"); |
700 | QStringList apps = cfg.readListEntry("Apps",','); | 744 | QStringList apps = cfg.readListEntry("Apps",','); |
701 | for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { | 745 | for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { |
702 | #ifndef QT_NO_COP | 746 | #ifndef QT_NO_COP |
703 | QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); | 747 | QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); |
704 | #endif | 748 | #endif |
705 | } | 749 | } |
706 | } | 750 | } |
707 | |||