-rw-r--r-- | library/global.cpp | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/library/global.cpp b/library/global.cpp index edb7b85..ab27b3f 100644 --- a/library/global.cpp +++ b/library/global.cpp | |||
@@ -300,427 +300,431 @@ void Global::addWords(const QString& dictname, const QStringList& wordlist) | |||
300 | QString Global::applicationFileName(const QString& appname, const QString& filename) | 300 | QString Global::applicationFileName(const QString& appname, const QString& filename) |
301 | { | 301 | { |
302 | QDir d; | 302 | QDir d; |
303 | QString r = getenv("HOME"); | 303 | QString r = getenv("HOME"); |
304 | r += "/Applications/"; | 304 | r += "/Applications/"; |
305 | if ( !QFile::exists( r ) ) | 305 | if ( !QFile::exists( r ) ) |
306 | if ( d.mkdir(r) == false ) | 306 | if ( d.mkdir(r) == false ) |
307 | return QString::null; | 307 | return QString::null; |
308 | r += appname; | 308 | r += appname; |
309 | if ( !QFile::exists( r ) ) | 309 | if ( !QFile::exists( r ) ) |
310 | if ( d.mkdir(r) == false ) | 310 | if ( d.mkdir(r) == false ) |
311 | return QString::null; | 311 | return QString::null; |
312 | r += "/"; r += filename; | 312 | r += "/"; r += filename; |
313 | return r; | 313 | return r; |
314 | } | 314 | } |
315 | 315 | ||
316 | /*! | 316 | /*! |
317 | \internal | 317 | \internal |
318 | */ | 318 | */ |
319 | void Global::createDocDir() | 319 | void Global::createDocDir() |
320 | { | 320 | { |
321 | if ( !docDirCreated ) { | 321 | if ( !docDirCreated ) { |
322 | docDirCreated = TRUE; | 322 | docDirCreated = TRUE; |
323 | mkdir( QPEApplication::documentDir().latin1(), 0755 ); | 323 | mkdir( QPEApplication::documentDir().latin1(), 0755 ); |
324 | } | 324 | } |
325 | } | 325 | } |
326 | 326 | ||
327 | 327 | ||
328 | /*! | 328 | /*! |
329 | Displays a status \a message to the user. This generally appears | 329 | Displays a status \a message to the user. This generally appears |
330 | in the taskbar for some amount of time, then disappears. | 330 | in the taskbar for some amount of time, then disappears. |
331 | */ | 331 | */ |
332 | void Global::statusMessage(const QString& message) | 332 | void Global::statusMessage(const QString& message) |
333 | { | 333 | { |
334 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 334 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
335 | QCopEnvelope e( "QPE/TaskBar", "message(QString)" ); | 335 | QCopEnvelope e( "QPE/TaskBar", "message(QString)" ); |
336 | e << message; | 336 | e << message; |
337 | #endif | 337 | #endif |
338 | } | 338 | } |
339 | 339 | ||
340 | /*! | 340 | /*! |
341 | \internal | 341 | \internal |
342 | */ | 342 | */ |
343 | void Global::applyStyle() | 343 | void Global::applyStyle() |
344 | { | 344 | { |
345 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 345 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
346 | QCopChannel::send( "QPE/System", "applyStyle()" ); | 346 | QCopChannel::send( "QPE/System", "applyStyle()" ); |
347 | #else | 347 | #else |
348 | ((QPEApplication *)qApp)->applyStyle(); // apply without needing QCop for floppy version | 348 | ((QPEApplication *)qApp)->applyStyle(); // apply without needing QCop for floppy version |
349 | #endif | 349 | #endif |
350 | } | 350 | } |
351 | 351 | ||
352 | /*! | 352 | /*! |
353 | \internal | 353 | \internal |
354 | */ | 354 | */ |
355 | QWidget *Global::shutdown( bool ) | 355 | QWidget *Global::shutdown( bool ) |
356 | { | 356 | { |
357 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 357 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
358 | QCopChannel::send( "QPE/System", "shutdown()" ); | 358 | QCopChannel::send( "QPE/System", "shutdown()" ); |
359 | #endif | 359 | #endif |
360 | return 0; | 360 | return 0; |
361 | } | 361 | } |
362 | 362 | ||
363 | /*! | 363 | /*! |
364 | \internal | 364 | \internal |
365 | */ | 365 | */ |
366 | QWidget *Global::restart( bool ) | 366 | QWidget *Global::restart( bool ) |
367 | { | 367 | { |
368 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 368 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
369 | QCopChannel::send( "QPE/System", "restart()" ); | 369 | QCopChannel::send( "QPE/System", "restart()" ); |
370 | #endif | 370 | #endif |
371 | return 0; | 371 | return 0; |
372 | } | 372 | } |
373 | 373 | ||
374 | /*! | 374 | /*! |
375 | Explicitly show the current input method. | 375 | Explicitly show the current input method. |
376 | */ | 376 | */ |
377 | void Global::showInputMethod() | 377 | void Global::showInputMethod() |
378 | { | 378 | { |
379 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 379 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
380 | QCopChannel::send( "QPE/TaskBar", "showInputMethod()" ); | 380 | QCopChannel::send( "QPE/TaskBar", "showInputMethod()" ); |
381 | #endif | 381 | #endif |
382 | } | 382 | } |
383 | 383 | ||
384 | /*! | 384 | /*! |
385 | Explicitly hide the current input method. | 385 | Explicitly hide the current input method. |
386 | */ | 386 | */ |
387 | void Global::hideInputMethod() | 387 | void Global::hideInputMethod() |
388 | { | 388 | { |
389 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 389 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
390 | QCopChannel::send( "QPE/TaskBar", "hideInputMethod()" ); | 390 | QCopChannel::send( "QPE/TaskBar", "hideInputMethod()" ); |
391 | #endif | 391 | #endif |
392 | } | 392 | } |
393 | 393 | ||
394 | 394 | ||
395 | /*! | 395 | /*! |
396 | \internal | 396 | \internal |
397 | */ | 397 | */ |
398 | bool Global::isBuiltinCommand( const QString &name ) | 398 | bool Global::isBuiltinCommand( const QString &name ) |
399 | { | 399 | { |
400 | if(!builtin) | 400 | if(!builtin) |
401 | return FALSE; // yes, it can happen | 401 | return FALSE; // yes, it can happen |
402 | for (int i = 0; builtin[i].file; i++) { | 402 | for (int i = 0; builtin[i].file; i++) { |
403 | if ( builtin[i].file == name ) { | 403 | if ( builtin[i].file == name ) { |
404 | return TRUE; | 404 | return TRUE; |
405 | } | 405 | } |
406 | } | 406 | } |
407 | return FALSE; | 407 | return FALSE; |
408 | } | 408 | } |
409 | 409 | ||
410 | Global::Command* Global::builtin=0; | 410 | Global::Command* Global::builtin=0; |
411 | QGuardedPtr<QWidget> *Global::running=0; | 411 | QGuardedPtr<QWidget> *Global::running=0; |
412 | 412 | ||
413 | /*! | 413 | /*! |
414 | \class Global::Command | 414 | \class Global::Command |
415 | \brief The Global::Command class is internal. | 415 | \brief The Global::Command class is internal. |
416 | \internal | 416 | \internal |
417 | */ | 417 | */ |
418 | 418 | ||
419 | /*! | 419 | /*! |
420 | \internal | 420 | \internal |
421 | */ | 421 | */ |
422 | void Global::setBuiltinCommands( Command* list ) | 422 | void Global::setBuiltinCommands( Command* list ) |
423 | { | 423 | { |
424 | if ( running ) | 424 | if ( running ) |
425 | delete [] running; | 425 | delete [] running; |
426 | 426 | ||
427 | builtin = list; | 427 | builtin = list; |
428 | int count = 0; | 428 | int count = 0; |
429 | if (!builtin) | 429 | if (!builtin) |
430 | return; | 430 | return; |
431 | while ( builtin[count].file ) | 431 | while ( builtin[count].file ) |
432 | count++; | 432 | count++; |
433 | 433 | ||
434 | running = new QGuardedPtr<QWidget> [ count ]; | 434 | running = new QGuardedPtr<QWidget> [ count ]; |
435 | } | 435 | } |
436 | 436 | ||
437 | /*! | 437 | /*! |
438 | \internal | 438 | \internal |
439 | */ | 439 | */ |
440 | void Global::setDocument( QWidget* receiver, const QString& document ) | 440 | void Global::setDocument( QWidget* receiver, const QString& document ) |
441 | { | 441 | { |
442 | Emitter emitter(receiver,document); | 442 | Emitter emitter(receiver,document); |
443 | } | 443 | } |
444 | 444 | ||
445 | /*! | 445 | /*! |
446 | \internal | 446 | \internal |
447 | */ | 447 | */ |
448 | bool Global::terminateBuiltin( const QString& n ) | 448 | bool Global::terminateBuiltin( const QString& n ) |
449 | { | 449 | { |
450 | if (!builtin) | 450 | if (!builtin) |
451 | return FALSE; | 451 | return FALSE; |
452 | for (int i = 0; builtin[i].file; i++) { | 452 | for (int i = 0; builtin[i].file; i++) { |
453 | if ( builtin[i].file == n ) { | 453 | if ( builtin[i].file == n ) { |
454 | delete running[i]; | 454 | delete running[i]; |
455 | return TRUE; | 455 | return TRUE; |
456 | } | 456 | } |
457 | } | 457 | } |
458 | return FALSE; | 458 | return FALSE; |
459 | } | 459 | } |
460 | 460 | ||
461 | /*! | 461 | /*! |
462 | \internal | 462 | \internal |
463 | */ | 463 | */ |
464 | void Global::terminate( const AppLnk* app ) | 464 | void Global::terminate( const AppLnk* app ) |
465 | { | 465 | { |
466 | //if ( terminateBuiltin(app->exec()) ) return; // maybe? haven't tried this | 466 | //if ( terminateBuiltin(app->exec()) ) return; // maybe? haven't tried this |
467 | 467 | ||
468 | QCString channel = "QPE/Application/" + app->exec().utf8(); | 468 | QCString channel = "QPE/Application/" + app->exec().utf8(); |
469 | if ( QCopChannel::isRegistered(channel) ) { | 469 | if ( QCopChannel::isRegistered(channel) ) { |
470 | QCopEnvelope e(channel, "quit()"); | 470 | QCopEnvelope e(channel, "quit()"); |
471 | } | 471 | } |
472 | } | 472 | } |
473 | 473 | ||
474 | /*! | 474 | /*! |
475 | Low-level function to run command \a c. Not recommended. | 475 | Low-level function to run command \a c. Not recommended. |
476 | */ | 476 | */ |
477 | void Global::invoke(const QString &c) | 477 | void Global::invoke(const QString &c) |
478 | { | 478 | { |
479 | // Convert the command line in to a list of arguments | 479 | // Convert the command line in to a list of arguments |
480 | QStringList list = QStringList::split(QRegExp(" *"),c); | 480 | QStringList list = QStringList::split(QRegExp(" *"),c); |
481 | 481 | ||
482 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 482 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
483 | QString ap=list[0]; | 483 | QString ap=list[0]; |
484 | // see if the application is already running | 484 | // see if the application is already running |
485 | // XXX should lock file /tmp/qcop-msg-ap | 485 | // XXX should lock file /tmp/qcop-msg-ap |
486 | if ( QCopChannel::isRegistered( ("QPE/Application/" + ap).latin1() ) ) { | 486 | if ( QCopChannel::isRegistered( ("QPE/Application/" + ap).latin1() ) ) { |
487 | QCopEnvelope e("QPE/System", "notBusy(QString)" ); | 487 | QCopEnvelope e("QPE/System", "notBusy(QString)" ); |
488 | e << ap; | 488 | e << ap; |
489 | return; | 489 | return; |
490 | } | 490 | } |
491 | // XXX should unlock file /tmp/qcop-msg-ap | 491 | // XXX should unlock file /tmp/qcop-msg-ap |
492 | //see if it is being started | 492 | //see if it is being started |
493 | if ( StartingAppList::isStarting( ap ) ) { | 493 | if ( StartingAppList::isStarting( ap ) ) { |
494 | QCopEnvelope e("QPE/System", "notBusy(QString)" ); | 494 | QCopEnvelope e("QPE/System", "notBusy(QString)" ); |
495 | e << ap; | 495 | e << ap; |
496 | return; | 496 | return; |
497 | } | 497 | } |
498 | 498 | ||
499 | #endif | 499 | #endif |
500 | 500 | ||
501 | #ifdef QT_NO_QWS_MULTIPROCESS | 501 | #ifdef QT_NO_QWS_MULTIPROCESS |
502 | QMessageBox::warning( 0, "Error", "Could not find the application " + c, "Ok", 0, 0, 0, 1 ); | 502 | QMessageBox::warning( 0, "Error", "Could not find the application " + c, "Ok", 0, 0, 0, 1 ); |
503 | #else | 503 | #else |
504 | 504 | ||
505 | QStrList slist; | 505 | QStrList slist; |
506 | unsigned int j; | 506 | unsigned int j; |
507 | for ( j = 0; j < list.count(); j++ ) | 507 | for ( j = 0; j < list.count(); j++ ) |
508 | slist.append( list[j].utf8() ); | 508 | slist.append( list[j].utf8() ); |
509 | 509 | ||
510 | const char **args = new (const char *)[slist.count() + 1]; | 510 | const char **args = new (const char *)[slist.count() + 1]; |
511 | for ( j = 0; j < slist.count(); j++ ) | 511 | for ( j = 0; j < slist.count(); j++ ) |
512 | args[j] = slist.at(j); | 512 | args[j] = slist.at(j); |
513 | args[j] = NULL; | 513 | args[j] = NULL; |
514 | 514 | ||
515 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 515 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
516 | // an attempt to show a wait... | 516 | // an attempt to show a wait... |
517 | // more logic should be used, but this will be fine for the moment... | 517 | // more logic should be used, but this will be fine for the moment... |
518 | QCopEnvelope ( "QPE/System", "busy()" ); | 518 | QCopEnvelope ( "QPE/System", "busy()" ); |
519 | #endif | 519 | #endif |
520 | 520 | ||
521 | #ifdef HAVE_QUICKEXEC | 521 | #ifdef HAVE_QUICKEXEC |
522 | QString libexe = qpeDir()+"/binlib/lib"+args[0] + ".so"; | 522 | QString libexe = qpeDir()+"/binlib/lib"+args[0] + ".so"; |
523 | qDebug("libfile = %s", libexe.latin1() ); | 523 | qDebug("libfile = %s", libexe.latin1() ); |
524 | if ( QFile::exists( libexe ) ) { | 524 | if ( QFile::exists( libexe ) ) { |
525 | qDebug("calling quickexec %s", libexe.latin1() ); | 525 | qDebug("calling quickexec %s", libexe.latin1() ); |
526 | quickexecv( libexe.utf8().data(), (const char **)args ); | 526 | quickexecv( libexe.utf8().data(), (const char **)args ); |
527 | } else | 527 | } else |
528 | #endif | 528 | #endif |
529 | { | 529 | { |
530 | if ( !::vfork() ) { | 530 | if ( !::vfork() ) { |
531 | for ( int fd = 3; fd < 100; fd++ ) | 531 | for ( int fd = 3; fd < 100; fd++ ) |
532 | ::close( fd ); | 532 | ::close( fd ); |
533 | ::setpgid( ::getpid(), ::getppid() ); | 533 | ::setpgid( ::getpid(), ::getppid() ); |
534 | // Try bindir first, so that foo/bar works too | 534 | // Try bindir first, so that foo/bar works too |
535 | ::execv( qpeDir()+"/bin/"+args[0], (char * const *)args ); | 535 | ::execv( qpeDir()+"/bin/"+args[0], (char * const *)args ); |
536 | ::execvp( args[0], (char * const *)args ); | 536 | ::execvp( args[0], (char * const *)args ); |
537 | _exit( -1 ); | 537 | _exit( -1 ); |
538 | } | 538 | } |
539 | } | 539 | } |
540 | StartingAppList::add( list[0] ); | 540 | StartingAppList::add( list[0] ); |
541 | #endif //QT_NO_QWS_MULTIPROCESS | 541 | #endif //QT_NO_QWS_MULTIPROCESS |
542 | } | 542 | } |
543 | 543 | ||
544 | /*! | 544 | /*! |
545 | Executes application identfied by \a c, passing \a document. | 545 | Executes application identfied by \a c, passing \a document. |
546 | 546 | ||
547 | Note that you might be better off sending a QCop message to | 547 | Note that you might be better off sending a QCop message to |
548 | the application's QPE/Application/<i>appname</i> channel. | 548 | the application's QPE/Application/<i>appname</i> channel. |
549 | */ | 549 | */ |
550 | void Global::execute( const QString &c, const QString& document ) | 550 | void Global::execute( const QString &c, const QString& document ) |
551 | { | 551 | { |
552 | if ( qApp->type() != QApplication::GuiServer ) { | 552 | if ( qApp->type() != QApplication::GuiServer ) { |
553 | // ask the server to do the work | 553 | // ask the server to do the work |
554 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 554 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
555 | if ( document.isNull() ) { | 555 | if ( document.isNull() ) { |
556 | QCopEnvelope e( "QPE/System", "execute(QString)" ); | 556 | QCopEnvelope e( "QPE/System", "execute(QString)" ); |
557 | e << c; | 557 | e << c; |
558 | } else { | 558 | } else { |
559 | QCopEnvelope e( "QPE/System", "execute(QString,QString)" ); | 559 | QCopEnvelope e( "QPE/System", "execute(QString,QString)" ); |
560 | e << c << document; | 560 | e << c << document; |
561 | } | 561 | } |
562 | #endif | 562 | #endif |
563 | return; | 563 | return; |
564 | } | 564 | } |
565 | 565 | ||
566 | // Attempt to execute the app using a builtin class for the app first | 566 | // Attempt to execute the app using a builtin class for the app first |
567 | // else try and find it in the bin directory | 567 | // else try and find it in the bin directory |
568 | if (builtin) { | 568 | if (builtin) { |
569 | for (int i = 0; builtin[i].file; i++) { | 569 | for (int i = 0; builtin[i].file; i++) { |
570 | if ( builtin[i].file == c ) { | 570 | if ( builtin[i].file == c ) { |
571 | if ( running[i] ) { | 571 | if ( running[i] ) { |
572 | if ( !document.isNull() && builtin[i].documentary ) | 572 | if ( !document.isNull() && builtin[i].documentary ) |
573 | setDocument(running[i], document); | 573 | setDocument(running[i], document); |
574 | running[i]->raise(); | 574 | running[i]->raise(); |
575 | running[i]->show(); | 575 | running[i]->show(); |
576 | running[i]->setActiveWindow(); | 576 | running[i]->setActiveWindow(); |
577 | } else { | 577 | } else { |
578 | running[i] = builtin[i].func( builtin[i].maximized ); | 578 | running[i] = builtin[i].func( builtin[i].maximized ); |
579 | } | 579 | } |
580 | QCopEnvelope e("QPE/System", "notBusy(QString)" ); | 580 | QCopEnvelope e("QPE/System", "notBusy(QString)" ); |
581 | e << c; // that was quick ;-) | 581 | e << c; // that was quick ;-) |
582 | return; | 582 | return; |
583 | } | 583 | } |
584 | } | 584 | } |
585 | } | 585 | } |
586 | 586 | ||
587 | //Global::invoke(c, document); | 587 | //Global::invoke(c, document); |
588 | 588 | ||
589 | // Convert the command line in to a list of arguments | 589 | // Convert the command line in to a list of arguments |
590 | QStringList list = QStringList::split(QRegExp(" *"),c); | 590 | QStringList list = QStringList::split(QRegExp(" *"),c); |
591 | 591 | ||
592 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) | 592 | #if defined(Q_WS_QWS) && !defined(QT_NO_COP) |
593 | QString ap=list[0]; | 593 | QString ap=list[0]; |
594 | 594 | ||
595 | qDebug("executing %s", ap.latin1() ); | 595 | qDebug("executing %s", ap.latin1() ); |
596 | if ( ap == "suspend" ) { | 596 | if ( ap == "suspend" ) { |
597 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); | 597 | QWSServer::sendKeyEvent( 0xffff, Qt::Key_F34, FALSE, TRUE, FALSE ); |
598 | return; | 598 | return; |
599 | } | 599 | } |
600 | 600 | ||
601 | /* if need be, sending a qcop message will result in an invoke, see | 601 | /* if need be, sending a qcop message will result in an invoke, see |
602 | preceeding function */ | 602 | preceeding function */ |
603 | { QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "raise()" ); } | 603 | { QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "raise()" ); } |
604 | if ( !document.isEmpty() ) { | 604 | if ( !document.isEmpty() ) { |
605 | QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "setDocument(QString)" ); | 605 | QCopEnvelope env( ("QPE/Application/" + ap).latin1(), "setDocument(QString)" ); |
606 | env << document; | 606 | env << document; |
607 | } | 607 | } |
608 | #endif | 608 | #endif |
609 | } | 609 | } |
610 | 610 | ||
611 | /*! | 611 | /*! |
612 | Returns the string \a s with the characters backslash, ", and $ | 612 | Returns the string \a s with the characters backslash, ", and $ |
613 | quoted by a preceeding backslash. | 613 | quoted by a preceeding backslash. |
614 | */ | 614 | */ |
615 | QString Global::shellQuote(const QString& s) | 615 | QString Global::shellQuote(const QString& s) |
616 | { | 616 | { |
617 | QString r="\""; | 617 | QString r="\""; |
618 | for (int i=0; i<(int)s.length(); i++) { | 618 | for (int i=0; i<(int)s.length(); i++) { |
619 | char c = s[i].latin1(); | 619 | char c = s[i].latin1(); |
620 | switch (c) { | 620 | switch (c) { |
621 | case '\\': case '"': case '$': | 621 | case '\\': case '"': case '$': |
622 | r+="\\"; | 622 | r+="\\"; |
623 | } | 623 | } |
624 | r += s[i]; | 624 | r += s[i]; |
625 | } | 625 | } |
626 | r += "\""; | 626 | r += "\""; |
627 | return r; | 627 | return r; |
628 | } | 628 | } |
629 | 629 | ||
630 | /*! | 630 | /*! |
631 | Returns the string \a s with the characters backslash and " | 631 | Returns the string \a s with the characters backslash and " |
632 | quoted by a preceeding backslash. | 632 | quoted by a preceeding backslash. |
633 | */ | 633 | */ |
634 | QString Global::stringQuote(const QString& s) | 634 | QString Global::stringQuote(const QString& s) |
635 | { | 635 | { |
636 | QString r="\""; | 636 | QString r="\""; |
637 | for (int i=0; i<(int)s.length(); i++) { | 637 | for (int i=0; i<(int)s.length(); i++) { |
638 | char c = s[i].latin1(); | 638 | char c = s[i].latin1(); |
639 | switch (c) { | 639 | switch (c) { |
640 | case '\\': case '"': | 640 | case '\\': case '"': |
641 | r+="\\"; | 641 | r+="\\"; |
642 | } | 642 | } |
643 | r += s[i]; | 643 | r += s[i]; |
644 | } | 644 | } |
645 | r += "\""; | 645 | r += "\""; |
646 | return r; | 646 | return r; |
647 | } | 647 | } |
648 | 648 | ||
649 | /*! | 649 | /*! |
650 | Finds all documents on the system's document directories which | 650 | Finds all documents on the system's document directories which |
651 | match the filter \a mimefilter, and appends the resulting DocLnk | 651 | match the filter \a mimefilter, and appends the resulting DocLnk |
652 | objects to \a folder. | 652 | objects to \a folder. |
653 | */ | 653 | */ |
654 | void Global::findDocuments(DocLnkSet* folder, const QString &mimefilter) | 654 | void Global::findDocuments(DocLnkSet* folder, const QString &mimefilter) |
655 | { | 655 | { |
656 | QString homedocs = QString(getenv("HOME")) + "/Documents"; | 656 | QString homedocs = QString(getenv("HOME")) + "/Documents"; |
657 | DocLnkSet d(homedocs,mimefilter); | 657 | DocLnkSet d(homedocs,mimefilter); |
658 | folder->appendFrom(d); | 658 | folder->appendFrom(d); |
659 | /** let's do intellegint way of searching these files | 659 | /** let's do intellegint way of searching these files |
660 | * a) the user don't want to check mediums global | 660 | * a) the user don't want to check mediums global |
661 | * b) the user wants to check but use the global options for it | 661 | * b) the user wants to check but use the global options for it |
662 | * c) the user wants to check it but not this medium | 662 | * c) the user wants to check it but not this medium |
663 | * d) the user wants to check and this medium as well | 663 | * d) the user wants to check and this medium as well |
664 | * | 664 | * |
665 | * In all cases we need to apply a different mimefilter to | 665 | * In all cases we need to apply a different mimefilter to |
666 | * the medium. | 666 | * the medium. |
667 | * a) mimefilter.isEmpty() we need to apply the responding filter | 667 | * a) mimefilter.isEmpty() we need to apply the responding filter |
668 | * either the global or the one on the medium | 668 | * either the global or the one on the medium |
669 | * | 669 | * |
670 | * b) mimefilter is set to an application we need to find out if the | 670 | * b) mimefilter is set to an application we need to find out if the |
671 | * mimetypes are included in the mime mask of the medium | 671 | * mimetypes are included in the mime mask of the medium |
672 | */ | 672 | */ |
673 | StorageInfo storage; | 673 | StorageInfo storage; |
674 | const QList<FileSystem> &fs = storage.fileSystems(); | 674 | const QList<FileSystem> &fs = storage.fileSystems(); |
675 | QListIterator<FileSystem> it ( fs ); | 675 | QListIterator<FileSystem> it ( fs ); |
676 | for ( ; it.current(); ++it ) { | 676 | for ( ; it.current(); ++it ) { |
677 | if ( (*it)->isRemovable() ) { // let's find out if we should search on it | 677 | if ( (*it)->isRemovable() ) { // let's find out if we should search on it |
678 | // this is a candidate look at the cf and see if we should search on it | 678 | // this is a candidate look at the cf and see if we should search on it |
679 | QString path = (*it)->path(); | 679 | QString path = (*it)->path(); |
680 | if( !checkStorage((*it)->path() + "/.opiestorage.cf" ) ) | 680 | if( !checkStorage((*it)->path() + "/.opiestorage.cf" ) ) |
681 | continue; | 681 | continue; |
682 | DocLnkSet ide( path, mimefilter ); | 682 | DocLnkSet ide( path, mimefilter ); |
683 | folder->appendFrom(ide); | 683 | folder->appendFrom(ide); |
684 | } else if ( (*it)->disk() == "/dev/mtdblock6" || (*it)->disk() == "tmpfs" ) { | ||
685 | QString path = (*it)->path() + "/Documents"; | ||
686 | DocLnkSet ide( path, mimefilter ); | ||
687 | folder->appendFrom(ide); | ||
684 | } | 688 | } |
685 | } | 689 | } |
686 | } | 690 | } |
687 | 691 | ||
688 | QStringList Global::languageList() | 692 | QStringList Global::languageList() |
689 | { | 693 | { |
690 | QString lang = getenv("LANG"); | 694 | QString lang = getenv("LANG"); |
691 | QStringList langs; | 695 | QStringList langs; |
692 | langs.append(lang); | 696 | langs.append(lang); |
693 | int i = lang.find("."); | 697 | int i = lang.find("."); |
694 | if ( i > 0 ) | 698 | if ( i > 0 ) |
695 | lang = lang.left( i ); | 699 | lang = lang.left( i ); |
696 | i = lang.find( "_" ); | 700 | i = lang.find( "_" ); |
697 | if ( i > 0 ) | 701 | if ( i > 0 ) |
698 | langs.append(lang.left(i)); | 702 | langs.append(lang.left(i)); |
699 | return langs; | 703 | return langs; |
700 | } | 704 | } |
701 | 705 | ||
702 | QStringList Global::helpPath() | 706 | QStringList Global::helpPath() |
703 | { | 707 | { |
704 | QStringList path; | 708 | QStringList path; |
705 | QStringList langs = Global::languageList(); | 709 | QStringList langs = Global::languageList(); |
706 | for (QStringList::ConstIterator it = langs.fromLast(); it!=langs.end(); --it) { | 710 | for (QStringList::ConstIterator it = langs.fromLast(); it!=langs.end(); --it) { |
707 | QString lang = *it; | 711 | QString lang = *it; |
708 | if ( !lang.isEmpty() ) | 712 | if ( !lang.isEmpty() ) |
709 | path += QPEApplication::qpeDir() + "/help/" + lang + "/html"; | 713 | path += QPEApplication::qpeDir() + "/help/" + lang + "/html"; |
710 | } | 714 | } |
711 | path += QPEApplication::qpeDir() + "/pics"; | 715 | path += QPEApplication::qpeDir() + "/pics"; |
712 | path += QPEApplication::qpeDir() + "/help/en/html"; | 716 | path += QPEApplication::qpeDir() + "/help/en/html"; |
713 | path += QPEApplication::qpeDir() + "/docs"; | 717 | path += QPEApplication::qpeDir() + "/docs"; |
714 | QString dir = QDir::current().canonicalPath(); | 718 | QString dir = QDir::current().canonicalPath(); |
715 | if ( dir == "/" ) | 719 | if ( dir == "/" ) |
716 | dir += "/docs"; | 720 | dir += "/docs"; |
717 | else { | 721 | else { |
718 | path += dir + "/../pics"; | 722 | path += dir + "/../pics"; |
719 | dir += "/../docs"; | 723 | dir += "/../docs"; |
720 | path += dir; | 724 | path += dir; |
721 | } | 725 | } |
722 | return path; | 726 | return path; |
723 | } | 727 | } |
724 | 728 | ||
725 | 729 | ||
726 | #include "global.moc" | 730 | #include "global.moc" |