summaryrefslogtreecommitdiff
path: root/library/global.cpp
Unidiff
Diffstat (limited to 'library/global.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--library/global.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/library/global.cpp b/library/global.cpp
index 4f1cc38..edb7b85 100644
--- a/library/global.cpp
+++ b/library/global.cpp
@@ -595,118 +595,132 @@ void Global::execute( const QString &c, const QString& document )
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*/
615QString Global::shellQuote(const QString& s) 615QString 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*/
634QString Global::stringQuote(const QString& s) 634QString 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*/
654void Global::findDocuments(DocLnkSet* folder, const QString &mimefilter) 654void 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
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
662 * c) the user wants to check it but not this medium
663 * d) the user wants to check and this medium as well
664 *
665 * In all cases we need to apply a different mimefilter to
666 * the medium.
667 * a) mimefilter.isEmpty() we need to apply the responding filter
668 * either the global or the one on the medium
669 *
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
672 */
659 StorageInfo storage; 673 StorageInfo storage;
660 const QList<FileSystem> &fs = storage.fileSystems(); 674 const QList<FileSystem> &fs = storage.fileSystems();
661 QListIterator<FileSystem> it ( fs ); 675 QListIterator<FileSystem> it ( fs );
662 for ( ; it.current(); ++it ) { 676 for ( ; it.current(); ++it ) {
663 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
664 // 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
665 QString path = (*it)->path(); 679 QString path = (*it)->path();
666 if( !checkStorage((*it)->path() + "/.opiestorage.cf" ) ) 680 if( !checkStorage((*it)->path() + "/.opiestorage.cf" ) )
667 continue; 681 continue;
668 DocLnkSet ide( path, mimefilter ); 682 DocLnkSet ide( path, mimefilter );
669 folder->appendFrom(ide); 683 folder->appendFrom(ide);
670 } 684 }
671 } 685 }
672} 686}
673 687
674QStringList Global::languageList() 688QStringList Global::languageList()
675{ 689{
676 QString lang = getenv("LANG"); 690 QString lang = getenv("LANG");
677 QStringList langs; 691 QStringList langs;
678 langs.append(lang); 692 langs.append(lang);
679 int i = lang.find("."); 693 int i = lang.find(".");
680 if ( i > 0 ) 694 if ( i > 0 )
681 lang = lang.left( i ); 695 lang = lang.left( i );
682 i = lang.find( "_" ); 696 i = lang.find( "_" );
683 if ( i > 0 ) 697 if ( i > 0 )
684 langs.append(lang.left(i)); 698 langs.append(lang.left(i));
685 return langs; 699 return langs;
686} 700}
687 701
688QStringList Global::helpPath() 702QStringList Global::helpPath()
689{ 703{
690 QStringList path; 704 QStringList path;
691 QStringList langs = Global::languageList(); 705 QStringList langs = Global::languageList();
692 for (QStringList::ConstIterator it = langs.fromLast(); it!=langs.end(); --it) { 706 for (QStringList::ConstIterator it = langs.fromLast(); it!=langs.end(); --it) {
693 QString lang = *it; 707 QString lang = *it;
694 if ( !lang.isEmpty() ) 708 if ( !lang.isEmpty() )
695 path += QPEApplication::qpeDir() + "/help/" + lang + "/html"; 709 path += QPEApplication::qpeDir() + "/help/" + lang + "/html";
696 } 710 }
697 path += QPEApplication::qpeDir() + "/pics"; 711 path += QPEApplication::qpeDir() + "/pics";
698 path += QPEApplication::qpeDir() + "/help/en/html"; 712 path += QPEApplication::qpeDir() + "/help/en/html";
699 path += QPEApplication::qpeDir() + "/docs"; 713 path += QPEApplication::qpeDir() + "/docs";
700 QString dir = QDir::current().canonicalPath(); 714 QString dir = QDir::current().canonicalPath();
701 if ( dir == "/" ) 715 if ( dir == "/" )
702 dir += "/docs"; 716 dir += "/docs";
703 else { 717 else {
704 path += dir + "/../pics"; 718 path += dir + "/../pics";
705 dir += "/../docs"; 719 dir += "/../docs";
706 path += dir; 720 path += dir;
707 } 721 }
708 return path; 722 return path;
709} 723}
710 724
711 725
712#include "global.moc" 726#include "global.moc"