-rw-r--r-- | library/global.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/library/global.cpp b/library/global.cpp index e5fc2b3..fd7579a 100644 --- a/library/global.cpp +++ b/library/global.cpp | |||
@@ -252,393 +252,393 @@ void Global::addWords(const QString& dictname, const QStringList& wordlist) | |||
252 | QFile dawgfile(dawgfilename); | 252 | QFile dawgfile(dawgfilename); |
253 | if ( dawgfile.open(IO_WriteOnly) ) { | 253 | if ( dawgfile.open(IO_WriteOnly) ) { |
254 | d.write(&dawgfile); | 254 | d.write(&dawgfile); |
255 | dawgfile.close(); | 255 | dawgfile.close(); |
256 | } | 256 | } |
257 | 257 | ||
258 | // #### Re-read the dawg here if we use mmap(). | 258 | // #### Re-read the dawg here if we use mmap(). |
259 | 259 | ||
260 | // #### Signal other processes to re-read. | 260 | // #### Signal other processes to re-read. |
261 | } | 261 | } |
262 | 262 | ||
263 | 263 | ||
264 | /*! | 264 | /*! |
265 | Returns a full path for the application named \a appname, with the | 265 | Returns a full path for the application named \a appname, with the |
266 | given \a filename or QString::null if there was a problem creating | 266 | given \a filename or QString::null if there was a problem creating |
267 | the directory tree for \a appname. | 267 | the directory tree for \a appname. |
268 | If \a filename contains "/", it is the caller's responsibility to | 268 | If \a filename contains "/", it is the caller's responsibility to |
269 | ensure those directories exist. | 269 | ensure those directories exist. |
270 | */ | 270 | */ |
271 | QString Global::applicationFileName(const QString& appname, const QString& filename) | 271 | QString Global::applicationFileName(const QString& appname, const QString& filename) |
272 | { | 272 | { |
273 | QDir d; | 273 | QDir d; |
274 | QString r = getenv("HOME"); | 274 | QString r = getenv("HOME"); |
275 | r += "/Applications/"; | 275 | r += "/Applications/"; |
276 | if ( !QFile::exists( r ) ) | 276 | if ( !QFile::exists( r ) ) |
277 | if ( d.mkdir(r) == false ) | 277 | if ( d.mkdir(r) == false ) |
278 | return QString::null; | 278 | return QString::null; |
279 | r += appname; | 279 | r += appname; |
280 | if ( !QFile::exists( r ) ) | 280 | if ( !QFile::exists( r ) ) |
281 | if ( d.mkdir(r) == false ) | 281 | if ( d.mkdir(r) == false ) |
282 | return QString::null; | 282 | return QString::null; |
283 | r += "/"; r += filename; | 283 | r += "/"; r += filename; |
284 | return r; | 284 | return r; |
285 | } | 285 | } |
286 | 286 | ||
287 | /*! | 287 | /*! |
288 | \internal | 288 | \internal |
289 | */ | 289 | */ |
290 | void Global::createDocDir() | 290 | void Global::createDocDir() |
291 | { | 291 | { |
292 | if ( !docDirCreated ) { | 292 | if ( !docDirCreated ) { |
293 | docDirCreated = TRUE; | 293 | docDirCreated = TRUE; |
294 | mkdir( QPEApplication::documentDir().latin1(), 0755 ); | 294 | mkdir( QPEApplication::documentDir().latin1(), 0755 ); |
295 | } | 295 | } |
296 | } | 296 | } |
297 | 297 | ||
298 | 298 | ||
299 | /*! | 299 | /*! |
300 | Displays a status \a message to the user. This generally appears | 300 | Displays a status \a message to the user. This generally appears |
301 | in the taskbar for some amount of time, then disappears. | 301 | in the taskbar for some amount of time, then disappears. |
302 | */ | 302 | */ |
303 | void Global::statusMessage(const QString& message) | 303 | void Global::statusMessage(const QString& message) |
304 | { | 304 | { |
305 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 305 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
306 | QCopEnvelope e( "QPE/TaskBar", "message(QString)" ); | 306 | QCopEnvelope e( "QPE/TaskBar", "message(QString)" ); |
307 | e << message; | 307 | e << message; |
308 | #endif | 308 | #endif |
309 | } | 309 | } |
310 | 310 | ||
311 | /*! | 311 | /*! |
312 | \internal | 312 | \internal |
313 | */ | 313 | */ |
314 | void Global::applyStyle() | 314 | void Global::applyStyle() |
315 | { | 315 | { |
316 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 316 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
317 | QCopChannel::send( "QPE/System", "applyStyle()" ); | 317 | QCopChannel::send( "QPE/System", "applyStyle()" ); |
318 | #else | 318 | #else |
319 | ((QPEApplication *)qApp)->applyStyle(); // apply without needing QCop for floppy version | 319 | ((QPEApplication *)qApp)->applyStyle(); // apply without needing QCop for floppy version |
320 | #endif | 320 | #endif |
321 | } | 321 | } |
322 | 322 | ||
323 | /*! | 323 | /*! |
324 | \internal | 324 | \internal |
325 | */ | 325 | */ |
326 | QWidget *Global::shutdown( bool ) | 326 | QWidget *Global::shutdown( bool ) |
327 | { | 327 | { |
328 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 328 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
329 | QCopChannel::send( "QPE/System", "shutdown()" ); | 329 | QCopChannel::send( "QPE/System", "shutdown()" ); |
330 | #endif | 330 | #endif |
331 | return 0; | 331 | return 0; |
332 | } | 332 | } |
333 | 333 | ||
334 | /*! | 334 | /*! |
335 | \internal | 335 | \internal |
336 | */ | 336 | */ |
337 | QWidget *Global::restart( bool ) | 337 | QWidget *Global::restart( bool ) |
338 | { | 338 | { |
339 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 339 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
340 | QCopChannel::send( "QPE/System", "restart()" ); | 340 | QCopChannel::send( "QPE/System", "restart()" ); |
341 | #endif | 341 | #endif |
342 | return 0; | 342 | return 0; |
343 | } | 343 | } |
344 | 344 | ||
345 | /*! | 345 | /*! |
346 | Explicitly show the current input method. | 346 | Explicitly show the current input method. |
347 | */ | 347 | */ |
348 | void Global::showInputMethod() | 348 | void Global::showInputMethod() |
349 | { | 349 | { |
350 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 350 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
351 | QCopChannel::send( "QPE/TaskBar", "showInputMethod()" ); | 351 | QCopChannel::send( "QPE/TaskBar", "showInputMethod()" ); |
352 | #endif | 352 | #endif |
353 | } | 353 | } |
354 | 354 | ||
355 | /*! | 355 | /*! |
356 | Explicitly hide the current input method. | 356 | Explicitly hide the current input method. |
357 | */ | 357 | */ |
358 | void Global::hideInputMethod() | 358 | void Global::hideInputMethod() |
359 | { | 359 | { |
360 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 360 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
361 | QCopChannel::send( "QPE/TaskBar", "hideInputMethod()" ); | 361 | QCopChannel::send( "QPE/TaskBar", "hideInputMethod()" ); |
362 | #endif | 362 | #endif |
363 | } | 363 | } |
364 | 364 | ||
365 | 365 | ||
366 | /*! | 366 | /*! |
367 | \internal | 367 | \internal |
368 | */ | 368 | */ |
369 | bool Global::isBuiltinCommand( const QString &name ) | 369 | bool Global::isBuiltinCommand( const QString &name ) |
370 | { | 370 | { |
371 | if(!builtin) | 371 | if(!builtin) |
372 | return FALSE; // yes, it can happen | 372 | return FALSE; // yes, it can happen |
373 | for (int i = 0; builtin[i].file; i++) { | 373 | for (int i = 0; builtin[i].file; i++) { |
374 | if ( builtin[i].file == name ) { | 374 | if ( builtin[i].file == name ) { |
375 | return TRUE; | 375 | return TRUE; |
376 | } | 376 | } |
377 | } | 377 | } |
378 | return FALSE; | 378 | return FALSE; |
379 | } | 379 | } |
380 | 380 | ||
381 | Global::Command* Global::builtin=0; | 381 | Global::Command* Global::builtin=0; |
382 | QGuardedPtr<QWidget> *Global::running=0; | 382 | QGuardedPtr<QWidget> *Global::running=0; |
383 | 383 | ||
384 | /*! | 384 | /*! |
385 | \class Global::Command | 385 | \class Global::Command |
386 | \brief The Global::Command class is internal. | 386 | \brief The Global::Command class is internal. |
387 | \internal | 387 | \internal |
388 | */ | 388 | */ |
389 | 389 | ||
390 | /*! | 390 | /*! |
391 | \internal | 391 | \internal |
392 | */ | 392 | */ |
393 | void Global::setBuiltinCommands( Command* list ) | 393 | void Global::setBuiltinCommands( Command* list ) |
394 | { | 394 | { |
395 | if ( running ) | 395 | if ( running ) |
396 | delete [] running; | 396 | delete [] running; |
397 | 397 | ||
398 | builtin = list; | 398 | builtin = list; |
399 | int count = 0; | 399 | int count = 0; |
400 | if (!builtin) | 400 | if (!builtin) |
401 | return; | 401 | return; |
402 | while ( builtin[count].file ) | 402 | while ( builtin[count].file ) |
403 | count++; | 403 | count++; |
404 | 404 | ||
405 | running = new QGuardedPtr<QWidget> [ count ]; | 405 | running = new QGuardedPtr<QWidget> [ count ]; |
406 | } | 406 | } |
407 | 407 | ||
408 | /*! | 408 | /*! |
409 | \internal | 409 | \internal |
410 | */ | 410 | */ |
411 | void Global::setDocument( QWidget* receiver, const QString& document ) | 411 | void Global::setDocument( QWidget* receiver, const QString& document ) |
412 | { | 412 | { |
413 | Emitter emitter(receiver,document); | 413 | Emitter emitter(receiver,document); |
414 | } | 414 | } |
415 | 415 | ||
416 | /*! | 416 | /*! |
417 | \internal | 417 | \internal |
418 | */ | 418 | */ |
419 | bool Global::terminateBuiltin( const QString& n ) | 419 | bool Global::terminateBuiltin( const QString& n ) |
420 | { | 420 | { |
421 | if (!builtin) | 421 | if (!builtin) |
422 | return FALSE; | 422 | return FALSE; |
423 | for (int i = 0; builtin[i].file; i++) { | 423 | for (int i = 0; builtin[i].file; i++) { |
424 | if ( builtin[i].file == n ) { | 424 | if ( builtin[i].file == n ) { |
425 | delete running[i]; | 425 | delete running[i]; |
426 | return TRUE; | 426 | return TRUE; |
427 | } | 427 | } |
428 | } | 428 | } |
429 | return FALSE; | 429 | return FALSE; |
430 | } | 430 | } |
431 | 431 | ||
432 | /*! | 432 | /*! |
433 | \internal | 433 | \internal |
434 | */ | 434 | */ |
435 | void Global::terminate( const AppLnk* app ) | 435 | void Global::terminate( const AppLnk* app ) |
436 | { | 436 | { |
437 | //if ( terminateBuiltin(app->exec()) ) return; // maybe? haven't tried this | 437 | //if ( terminateBuiltin(app->exec()) ) return; // maybe? haven't tried this |
438 | 438 | ||
439 | QCString channel = "QPE/Application/" + app->exec().utf8(); | 439 | QCString channel = "QPE/Application/" + app->exec().utf8(); |
440 | if ( QCopChannel::isRegistered(channel) ) { | 440 | if ( QCopChannel::isRegistered(channel) ) { |
441 | QCopEnvelope e(channel, "quit()"); | 441 | QCopEnvelope e(channel, "quit()"); |
442 | } | 442 | } |
443 | } | 443 | } |
444 | 444 | ||
445 | /*! | 445 | /*! |
446 | Low-level function to run command \a c. Not recommended. | 446 | Low-level function to run command \a c. Not recommended. |
447 | */ | 447 | */ |
448 | void Global::invoke(const QString &c) | 448 | void Global::invoke(const QString &c) |
449 | { | 449 | { |
450 | // Convert the command line in to a list of arguments | 450 | // Convert the command line in to a list of arguments |
451 | QStringList list = QStringList::split(QRegExp(" *"),c); | 451 | QStringList list = QStringList::split(QRegExp(" *"),c); |
452 | 452 | ||
453 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 453 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
454 | QString ap=list[0]; | 454 | QString ap=list[0]; |
455 | // see if the application is already running | 455 | // see if the application is already running |
456 | // XXX should lock file /tmp/qcop-msg-ap | 456 | // XXX should lock file /tmp/qcop-msg-ap |
457 | if ( QCopChannel::isRegistered( ("QPE/Application/" + ap).latin1() ) ) { | 457 | if ( QCopChannel::isRegistered( ("QPE/Application/" + ap).latin1() ) ) { |
458 | QCopEnvelope e("QPE/System", "notBusy(QString)" ); | 458 | QCopEnvelope e("QPE/System", "notBusy(QString)" ); |
459 | e << ap; | 459 | e << ap; |
460 | return; | 460 | return; |
461 | } | 461 | } |
462 | // XXX should unlock file /tmp/qcop-msg-ap | 462 | // XXX should unlock file /tmp/qcop-msg-ap |
463 | //see if it is being started | 463 | //see if it is being started |
464 | if ( StartingAppList::isStarting( ap ) ) { | 464 | if ( StartingAppList::isStarting( ap ) ) { |
465 | QCopEnvelope e("QPE/System", "notBusy(QString)" ); | 465 | QCopEnvelope e("QPE/System", "notBusy(QString)" ); |
466 | e << ap; | 466 | e << ap; |
467 | return; | 467 | return; |
468 | } | 468 | } |
469 | 469 | ||
470 | #endif | 470 | #endif |
471 | 471 | ||
472 | #ifdef QT_NO_QWS_MULTIPROCESS | 472 | #ifdef QT_NO_QWS_MULTIPROCESS |
473 | QMessageBox::warning( 0, "Error", "Could not find the application " + c, "Ok", 0, 0, 0, 1 ); | 473 | QMessageBox::warning( 0, "Error", "Could not find the application " + c, "Ok", 0, 0, 0, 1 ); |
474 | #else | 474 | #else |
475 | 475 | ||
476 | QStrList slist; | 476 | QStrList slist; |
477 | unsigned int j; | 477 | unsigned int j; |
478 | for ( j = 0; j < list.count(); j++ ) | 478 | for ( j = 0; j < list.count(); j++ ) |
479 | slist.append( list[j].utf8() ); | 479 | slist.append( list[j].utf8() ); |
480 | 480 | ||
481 | const char **args = new (const char *)[slist.count() + 1]; | 481 | const char **args = new (const char *)[slist.count() + 1]; |
482 | for ( j = 0; j < slist.count(); j++ ) | 482 | for ( j = 0; j < slist.count(); j++ ) |
483 | args[j] = slist.at(j); | 483 | args[j] = slist.at(j); |
484 | args[j] = NULL; | 484 | args[j] = NULL; |
485 | 485 | ||
486 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 486 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
487 | // an attempt to show a wait... | 487 | // an attempt to show a wait... |
488 | // more logic should be used, but this will be fine for the moment... | 488 | // more logic should be used, but this will be fine for the moment... |
489 | QCopEnvelope ( "QPE/System", "busy()" ); | 489 | QCopEnvelope ( "QPE/System", "busy()" ); |
490 | #endif | 490 | #endif |
491 | 491 | ||
492 | #ifdef HAVE_QUICKEXEC | 492 | #ifdef HAVE_QUICKEXEC |
493 | QString libexe = qpeDir()+"/binlib/lib"+args[0] + ".so"; | 493 | QString libexe = qpeDir()+"/binlib/lib"+args[0] + ".so"; |
494 | qDebug("libfile = %s", libexe.latin1() ); | 494 | qDebug("libfile = %s", libexe.latin1() ); |
495 | if ( QFile::exists( libexe ) ) { | 495 | if ( QFile::exists( libexe ) ) { |
496 | qDebug("calling quickexec %s", libexe.latin1() ); | 496 | qDebug("calling quickexec %s", libexe.latin1() ); |
497 | quickexecv( libexe.utf8().data(), (const char **)args ); | 497 | quickexecv( libexe.utf8().data(), (const char **)args ); |
498 | } else | 498 | } else |
499 | #endif | 499 | #endif |
500 | { | 500 | { |
501 | if ( !::vfork() ) { | 501 | if ( !::vfork() ) { |
502 | for ( int fd = 3; fd < 100; fd++ ) | 502 | for ( int fd = 3; fd < 100; fd++ ) |
503 | ::close( fd ); | 503 | ::close( fd ); |
504 | ::setpgid( ::getpid(), ::getppid() ); | 504 | ::setpgid( ::getpid(), ::getppid() ); |
505 | // Try bindir first, so that foo/bar works too | 505 | // Try bindir first, so that foo/bar works too |
506 | ::execv( qpeDir()+"/bin/"+args[0], (char * const *)args ); | 506 | ::execv( qpeDir()+"/bin/"+args[0], (char * const *)args ); |
507 | ::execvp( args[0], (char * const *)args ); | 507 | ::execvp( args[0], (char * const *)args ); |
508 | exit( -1 ); | 508 | _exit( -1 ); |
509 | } | 509 | } |
510 | } | 510 | } |
511 | StartingAppList::add( list[0] ); | 511 | StartingAppList::add( list[0] ); |
512 | #endif //QT_NO_QWS_MULTIPROCESS | 512 | #endif //QT_NO_QWS_MULTIPROCESS |
513 | } | 513 | } |
514 | 514 | ||
515 | /*! | 515 | /*! |
516 | Executes application identfied by \a c, passing \a document. | 516 | Executes application identfied by \a c, passing \a document. |
517 | 517 | ||
518 | Note that you might be better off sending a QCop message to | 518 | Note that you might be better off sending a QCop message to |
519 | the application's QPE/Application/<i>appname</i> channel. | 519 | the application's QPE/Application/<i>appname</i> channel. |
520 | */ | 520 | */ |
521 | void Global::execute( const QString &c, const QString& document ) | 521 | void Global::execute( const QString &c, const QString& document ) |
522 | { | 522 | { |
523 | if ( qApp->type() != QApplication::GuiServer ) { | 523 | if ( qApp->type() != QApplication::GuiServer ) { |
524 | // ask the server to do the work | 524 | // ask the server to do the work |
525 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 525 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
526 | if ( document.isNull() ) { | 526 | if ( document.isNull() ) { |
527 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 527 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
528 | e << c; | 528 | e << c; |
529 | } else { | 529 | } else { |
530 | QCopEnvelope e( "QPE/System", "execute(QString,QString)" ); | 530 | QCopEnvelope e( "QPE/System", "execute(QString,QString)" ); |
531 | e << c << document; | 531 | e << c << document; |
532 | } | 532 | } |
533 | #endif | 533 | #endif |
534 | return; | 534 | return; |
535 | } | 535 | } |
536 | 536 | ||
537 | // Attempt to execute the app using a builtin class for the app first | 537 | // Attempt to execute the app using a builtin class for the app first |
538 | // else try and find it in the bin directory | 538 | // else try and find it in the bin directory |
539 | if (builtin) { | 539 | if (builtin) { |
540 | for (int i = 0; builtin[i].file; i++) { | 540 | for (int i = 0; builtin[i].file; i++) { |
541 | if ( builtin[i].file == c ) { | 541 | if ( builtin[i].file == c ) { |
542 | if ( running[i] ) { | 542 | if ( running[i] ) { |
543 | if ( !document.isNull() && builtin[i].documentary ) | 543 | if ( !document.isNull() && builtin[i].documentary ) |
544 | setDocument(running[i], document); | 544 | setDocument(running[i], document); |
545 | running[i]->raise(); | 545 | running[i]->raise(); |
546 | running[i]->show(); | 546 | running[i]->show(); |
547 | running[i]->setActiveWindow(); | 547 | running[i]->setActiveWindow(); |
548 | } else { | 548 | } else { |
549 | running[i] = builtin[i].func( builtin[i].maximized ); | 549 | running[i] = builtin[i].func( builtin[i].maximized ); |
550 | } | 550 | } |
551 | QCopEnvelope e("QPE/System", "notBusy(QString)" ); | 551 | QCopEnvelope e("QPE/System", "notBusy(QString)" ); |
552 | e << c; // that was quick ;-) | 552 | e << c; // that was quick ;-) |
553 | return; | 553 | return; |
554 | } | 554 | } |
555 | } | 555 | } |
556 | } | 556 | } |
557 | 557 | ||
558 | //Global::invoke(c, document); | 558 | //Global::invoke(c, document); |
559 | 559 | ||
560 | // Convert the command line in to a list of arguments | 560 | // Convert the command line in to a list of arguments |
561 | QStringList list = QStringList::split(QRegExp(" *"),c); | 561 | QStringList list = QStringList::split(QRegExp(" *"),c); |
562 | 562 | ||
563 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 563 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
564 | QString ap=list[0]; | 564 | QString ap=list[0]; |
565 | 565 | ||
566 | qDebug("executing %s", ap.latin1() ); | 566 | qDebug("executing %s", ap.latin1() ); |
567 | if ( ap == "suspend" ) { | 567 | if ( ap == "suspend" ) { |
568 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); | 568 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); |
569 | return; | 569 | return; |
570 | } | 570 | } |
571 | 571 | ||
572 | /* if need be, sending a qcop message will result in an invoke, see | 572 | /* if need be, sending a qcop message will result in an invoke, see |
573 | preceeding function */ | 573 | preceeding function */ |
574 | { QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "raise()" ); } | 574 | { QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "raise()" ); } |
575 | if ( !document.isEmpty() ) { | 575 | if ( !document.isEmpty() ) { |
576 | QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "setDocument(QString)" ); | 576 | QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "setDocument(QString)" ); |
577 | env << document; | 577 | env << document; |
578 | } | 578 | } |
579 | #endif | 579 | #endif |
580 | } | 580 | } |
581 | 581 | ||
582 | /*! | 582 | /*! |
583 | Returns the string \a s with the characters backslash, ", and $ | 583 | Returns the string \a s with the characters backslash, ", and $ |
584 | quoted by a preceeding backslash. | 584 | quoted by a preceeding backslash. |
585 | */ | 585 | */ |
586 | QString Global::shellQuote(const QString& s) | 586 | QString Global::shellQuote(const QString& s) |
587 | { | 587 | { |
588 | QString r="\""; | 588 | QString r="\""; |
589 | for (int i=0; i<(int)s.length(); i++) { | 589 | for (int i=0; i<(int)s.length(); i++) { |
590 | char c = s[i].latin1(); | 590 | char c = s[i].latin1(); |
591 | switch (c) { | 591 | switch (c) { |
592 | case '\\': case '"': case '$': | 592 | case '\\': case '"': case '$': |
593 | r+="\\"; | 593 | r+="\\"; |
594 | } | 594 | } |
595 | r += s[i]; | 595 | r += s[i]; |
596 | } | 596 | } |
597 | r += "\""; | 597 | r += "\""; |
598 | return r; | 598 | return r; |
599 | } | 599 | } |
600 | 600 | ||
601 | /*! | 601 | /*! |
602 | Returns the string \a s with the characters backslash and " | 602 | Returns the string \a s with the characters backslash and " |
603 | quoted by a preceeding backslash. | 603 | quoted by a preceeding backslash. |
604 | */ | 604 | */ |
605 | QString Global::stringQuote(const QString& s) | 605 | QString Global::stringQuote(const QString& s) |
606 | { | 606 | { |
607 | QString r="\""; | 607 | QString r="\""; |
608 | for (int i=0; i<(int)s.length(); i++) { | 608 | for (int i=0; i<(int)s.length(); i++) { |
609 | char c = s[i].latin1(); | 609 | char c = s[i].latin1(); |
610 | switch (c) { | 610 | switch (c) { |
611 | case '\\': case '"': | 611 | case '\\': case '"': |
612 | r+="\\"; | 612 | r+="\\"; |
613 | } | 613 | } |
614 | r += s[i]; | 614 | r += s[i]; |
615 | } | 615 | } |
616 | r += "\""; | 616 | r += "\""; |
617 | return r; | 617 | return r; |
618 | } | 618 | } |
619 | 619 | ||
620 | /*! | 620 | /*! |
621 | Finds all documents on the system's document directories which | 621 | Finds all documents on the system's document directories which |
622 | match the filter \a mimefilter, and appends the resulting DocLnk | 622 | match the filter \a mimefilter, and appends the resulting DocLnk |
623 | objects to \a folder. | 623 | objects to \a folder. |
624 | */ | 624 | */ |
625 | void Global::findDocuments(DocLnkSet* folder, const QString &mimefilter) | 625 | void Global::findDocuments(DocLnkSet* folder, const QString &mimefilter) |
626 | { | 626 | { |
627 | QString homedocs = QString(getenv("HOME")) + "/Documents"; | 627 | QString homedocs = QString(getenv("HOME")) + "/Documents"; |
628 | DocLnkSet d(homedocs,mimefilter); | 628 | DocLnkSet d(homedocs,mimefilter); |
629 | folder->appendFrom(d); | 629 | folder->appendFrom(d); |
630 | StorageInfo storage; | 630 | StorageInfo storage; |
631 | const QList<FileSystem> &fs = storage.fileSystems(); | 631 | const QList<FileSystem> &fs = storage.fileSystems(); |
632 | QListIterator<FileSystem> it ( fs ); | 632 | QListIterator<FileSystem> it ( fs ); |
633 | for ( ; it.current(); ++it ) { | 633 | for ( ; it.current(); ++it ) { |
634 | if ( (*it)->isRemovable() ) { | 634 | if ( (*it)->isRemovable() ) { |
635 | QString path = (*it)->path(); | 635 | QString path = (*it)->path(); |
636 | DocLnkSet ide( path, mimefilter ); | 636 | DocLnkSet ide( path, mimefilter ); |
637 | folder->appendFrom(ide); | 637 | folder->appendFrom(ide); |
638 | } | 638 | } |
639 | } | 639 | } |
640 | } | 640 | } |
641 | 641 | ||
642 | 642 | ||
643 | 643 | ||
644 | #include "global.moc" | 644 | #include "global.moc" |