summaryrefslogtreecommitdiff
authorzecke <zecke>2002-04-27 17:39:49 (UTC)
committer zecke <zecke>2002-04-27 17:39:49 (UTC)
commitf3ee6db944094c61ecf803f07ff736bf6d70141d (patch) (unidiff)
tree590ce81223de721a2d4fdfa0d807e0e2e62ecea1
parent1096acae0705c6679a918dafaa7c7388da3828cb (diff)
downloadopie-f3ee6db944094c61ecf803f07ff736bf6d70141d.zip
opie-f3ee6db944094c61ecf803f07ff736bf6d70141d.tar.gz
opie-f3ee6db944094c61ecf803f07ff736bf6d70141d.tar.bz2
restore original behaviour this can be changed by the MediumMountSettings app
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcher.cpp53
1 files changed, 42 insertions, 11 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp
index f9c6c02..1a52f69 100644
--- a/core/launcher/launcher.cpp
+++ b/core/launcher/launcher.cpp
@@ -18,131 +18,131 @@
18** not clear to you. 18** not clear to you.
19** 19**
20**********************************************************************/ 20**********************************************************************/
21 21
22// WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT 22// WARNING: Do *NOT* define this yourself. The SL5xxx from SHARP does NOT
23// have this class. 23// have this class.
24#define QTOPIA_INTERNAL_FSLP 24#define QTOPIA_INTERNAL_FSLP
25 25
26#include <opie/oconfig.h> 26#include <opie/oconfig.h>
27#include <qpe/qcopenvelope_qws.h> 27#include <qpe/qcopenvelope_qws.h>
28#include <qpe/resource.h> 28#include <qpe/resource.h>
29#include <qpe/applnk.h> 29#include <qpe/applnk.h>
30#include <qpe/config.h> 30#include <qpe/config.h>
31#include <qpe/global.h> 31#include <qpe/global.h>
32#include <qpe/qpeapplication.h> 32#include <qpe/qpeapplication.h>
33#include <qpe/mimetype.h> 33#include <qpe/mimetype.h>
34#include <qpe/storage.h> 34#include <qpe/storage.h>
35#include <qpe/palmtoprecord.h> 35#include <qpe/palmtoprecord.h>
36 36
37#include <qdatetime.h> 37#include <qdatetime.h>
38#include <qdir.h> 38#include <qdir.h>
39#include <qwindowsystem_qws.h> 39#include <qwindowsystem_qws.h>
40#include <qtimer.h> 40#include <qtimer.h>
41#include <qcombobox.h> 41#include <qcombobox.h>
42#include <qvbox.h> 42#include <qvbox.h>
43#include <qlayout.h> 43#include <qlayout.h>
44#include <qstyle.h> 44#include <qstyle.h>
45#include <qpushbutton.h> 45#include <qpushbutton.h>
46#include <qtabbar.h> 46#include <qtabbar.h>
47#include <qwidgetstack.h> 47#include <qwidgetstack.h>
48#include <qlayout.h> 48#include <qlayout.h>
49#include <qregexp.h> 49#include <qregexp.h>
50#include <qmessagebox.h> 50#include <qmessagebox.h>
51#include <qframe.h> 51#include <qframe.h>
52#include <qpainter.h> 52#include <qpainter.h>
53#include <qlabel.h> 53#include <qlabel.h>
54#include <qtextstream.h> 54#include <qtextstream.h>
55 55
56#include "launcherview.h" 56#include "launcherview.h"
57#include "launcher.h" 57#include "launcher.h"
58#include "syncdialog.h" 58#include "syncdialog.h"
59#include "desktop.h" 59#include "desktop.h"
60#include <qpe/lnkproperties.h> 60#include <qpe/lnkproperties.h>
61#include "mrulist.h" 61#include "mrulist.h"
62#include "qrsync.h" 62#include "qrsync.h"
63#include <stdlib.h> 63#include <stdlib.h>
64#include <unistd.h> 64#include <unistd.h>
65 65
66#if defined(_OS_LINUX_) || defined(Q_OS_LINUX) 66#if defined(_OS_LINUX_) || defined(Q_OS_LINUX)
67#include <stdio.h> 67#include <stdio.h>
68#include <sys/vfs.h> 68#include <sys/vfs.h>
69#include <mntent.h> 69#include <mntent.h>
70#endif 70#endif
71 71
72#include <qpe/storage.h> 72#include <qpe/storage.h>
73#include "mediummountgui.h" 73#include "mediummountgui.h"
74//#define SHOW_ALL 74//#define SHOW_ALL
75 75
76// uidGen 76// uidGen
77 77
78// uidGen 78// uidGen
79namespace { 79namespace {
80 QStringList configToMime( Config *cfg ){ 80 QStringList configToMime( Config *cfg ){
81 QStringList mimes; 81 QStringList mimes;
82 bool tmpMime; 82 bool tmpMime = true;
83 cfg->setGroup("mimetypes" ); 83 cfg->setGroup("mimetypes" );
84 tmpMime = cfg->readBoolEntry("all" ,false); 84 tmpMime = cfg->readBoolEntry("all" ,true);
85 if( tmpMime ){ 85 if( tmpMime ){
86 mimes << QString::null; 86 mimes << QString::null;
87 return mimes; 87 return mimes;
88 }else{ 88 }else{
89 tmpMime = cfg->readBoolEntry("audio", true ); 89 tmpMime = cfg->readBoolEntry("audio", true );
90 if(tmpMime ) 90 if(tmpMime )
91 mimes.append("audio/*" ); 91 mimes.append("audio/*" );
92 92
93 tmpMime = cfg->readBoolEntry("image", true ); 93 tmpMime = cfg->readBoolEntry("image", true );
94 if(tmpMime ) 94 if(tmpMime )
95 mimes.append("image/*" ); 95 mimes.append("image/*" );
96 96
97 tmpMime = cfg->readBoolEntry("text", true ); 97 tmpMime = cfg->readBoolEntry("text", true );
98 if(tmpMime ) 98 if(tmpMime )
99 mimes.append("text/*"); 99 mimes.append("text/*");
100 100
101 tmpMime = cfg->readBoolEntry("video", true ); 101 tmpMime = cfg->readBoolEntry("video", true );
102 if(tmpMime ) 102 if(tmpMime )
103 mimes.append("video/*" ); 103 mimes.append("video/*" );
104 } 104 }
105 return mimes; 105 return mimes;
106 } 106 }
107 107
108} 108}
109 109
110 110
111CategoryTabWidget::CategoryTabWidget( QWidget* parent ) : 111CategoryTabWidget::CategoryTabWidget( QWidget* parent ) :
112 QVBox( parent ) 112 QVBox( parent )
113{ 113{
114 categoryBar = 0; 114 categoryBar = 0;
115 stack = 0; 115 stack = 0;
116} 116}
117 117
118void CategoryTabWidget::prevTab() 118void CategoryTabWidget::prevTab()
119{ 119{
120 if ( categoryBar ) { 120 if ( categoryBar ) {
121 int n = categoryBar->count(); 121 int n = categoryBar->count();
122 int tab = categoryBar->currentTab(); 122 int tab = categoryBar->currentTab();
123 if ( tab >= 0 ) 123 if ( tab >= 0 )
124 categoryBar->setCurrentTab( (tab - 1 + n)%n ); 124 categoryBar->setCurrentTab( (tab - 1 + n)%n );
125 } 125 }
126} 126}
127 127
128void CategoryTabWidget::nextTab() 128void CategoryTabWidget::nextTab()
129{ 129{
130 if ( categoryBar ) { 130 if ( categoryBar ) {
131 int n = categoryBar->count(); 131 int n = categoryBar->count();
132 int tab = categoryBar->currentTab(); 132 int tab = categoryBar->currentTab();
133 categoryBar->setCurrentTab( (tab + 1)%n ); 133 categoryBar->setCurrentTab( (tab + 1)%n );
134 } 134 }
135} 135}
136 136
137void CategoryTabWidget::addItem( const QString& linkfile ) 137void CategoryTabWidget::addItem( const QString& linkfile )
138{ 138{
139 int i=0; 139 int i=0;
140 AppLnk *app = new AppLnk(linkfile); 140 AppLnk *app = new AppLnk(linkfile);
141 if ( !app->isValid() ) { 141 if ( !app->isValid() ) {
142 delete app; 142 delete app;
143 return; 143 return;
144 } 144 }
145 if ( !app->file().isEmpty() ) { 145 if ( !app->file().isEmpty() ) {
146 // A document 146 // A document
147 delete app; 147 delete app;
148 app = new DocLnk(linkfile); 148 app = new DocLnk(linkfile);
@@ -473,180 +473,211 @@ Launcher::Launcher( QWidget* parent, const char* name, WFlags fl )
473 this, SLOT(properties(AppLnk*))); 473 this, SLOT(properties(AppLnk*)));
474 474
475#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 475#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
476 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); 476 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this );
477 connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), 477 connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)),
478 this, SLOT(systemMessage( const QCString &, const QByteArray &)) ); 478 this, SLOT(systemMessage( const QCString &, const QByteArray &)) );
479#endif 479#endif
480 480
481 storage = new StorageInfo( this ); 481 storage = new StorageInfo( this );
482 connect( storage, SIGNAL( disksChanged() ), SLOT( storageChanged() ) ); 482 connect( storage, SIGNAL( disksChanged() ), SLOT( storageChanged() ) );
483 483
484 updateTabs(); 484 updateTabs();
485 485
486 preloadApps(); 486 preloadApps();
487 487
488 in_lnk_props = FALSE; 488 in_lnk_props = FALSE;
489 got_lnk_change = FALSE; 489 got_lnk_change = FALSE;
490} 490}
491 491
492Launcher::~Launcher() 492Launcher::~Launcher()
493{ 493{
494} 494}
495 495
496static bool isVisibleWindow(int wid) 496static bool isVisibleWindow(int wid)
497{ 497{
498 const QList<QWSWindow> &list = qwsServer->clientWindows(); 498 const QList<QWSWindow> &list = qwsServer->clientWindows();
499 QWSWindow* w; 499 QWSWindow* w;
500 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { 500 for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) {
501 if ( w->winId() == wid ) 501 if ( w->winId() == wid )
502 return !w->isFullyObscured(); 502 return !w->isFullyObscured();
503 } 503 }
504 return FALSE; 504 return FALSE;
505} 505}
506 506
507void Launcher::showMaximized() 507void Launcher::showMaximized()
508{ 508{
509 if ( isVisibleWindow( winId() ) ) 509 if ( isVisibleWindow( winId() ) )
510 doMaximize(); 510 doMaximize();
511 else 511 else
512 QTimer::singleShot( 20, this, SLOT(doMaximize()) ); 512 QTimer::singleShot( 20, this, SLOT(doMaximize()) );
513} 513}
514 514
515void Launcher::doMaximize() 515void Launcher::doMaximize()
516{ 516{
517 QMainWindow::showMaximized(); 517 QMainWindow::showMaximized();
518} 518}
519 519
520void Launcher::updateMimeTypes() 520void Launcher::updateMimeTypes()
521{ 521{
522 MimeType::clear(); 522 MimeType::clear();
523 updateMimeTypes(rootFolder); 523 updateMimeTypes(rootFolder);
524} 524}
525 525
526void Launcher::updateMimeTypes(AppLnkSet* folder) 526void Launcher::updateMimeTypes(AppLnkSet* folder)
527{ 527{
528 for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) { 528 for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) {
529 AppLnk *app = it.current(); 529 AppLnk *app = it.current();
530 if ( app->type() == "Folder" ) 530 if ( app->type() == "Folder" )
531 updateMimeTypes((AppLnkSet *)app); 531 updateMimeTypes((AppLnkSet *)app);
532 else { 532 else {
533 MimeType::registerApp(*app); 533 MimeType::registerApp(*app);
534 } 534 }
535 } 535 }
536} 536}
537 537/** This is a HACK....
538 * Reason: scanning huge mediums, microdirvers for examples
539 * consomes time. To avoid that we invented the MediumMountCheck
540 *
541 * a) the user globally disabled medium checking. We can ignore
542 * all removable medium
543 * b) the user enabled medium checking globally and we need to use this mimefilter
544 * c) the user enabled medium checking on a per medium bases
545 * c1) we already checked and its not ask again turns
546 * c2) we need to ask and then apply the mimefilter
547 */
538void Launcher::loadDocs() // ok here comes a hack belonging to Global:: 548void Launcher::loadDocs() // ok here comes a hack belonging to Global::
539{ 549{
540 qWarning("loading Documents" );
541 qWarning("The currentTimeStamp is: %s", m_timeStamp.latin1() );
542 delete docsFolder; 550 delete docsFolder;
543 docsFolder = new DocLnkSet; 551 docsFolder = new DocLnkSet;
544 qWarning("new DocLnkSet" ); 552
545 DocLnkSet *tmp = 0; 553 DocLnkSet *tmp = 0;
546 QString home = QString(getenv("HOME")) + "/Documents"; 554 QString home = QString(getenv("HOME")) + "/Documents";
547 tmp = new DocLnkSet( home , QString::null); 555 tmp = new DocLnkSet( home , QString::null);
548 docsFolder->appendFrom( *tmp ); 556 docsFolder->appendFrom( *tmp );
549 delete tmp; 557 delete tmp;
558
559 Config mediumCfg( "medium");
560 mediumCfg.setGroup("main");
561 // a) -zecke we don't want to check
562 if(!mediumCfg.readBoolEntry("use", true ) )
563 return;
564
550 // find out wich filesystems are new in this round 565 // find out wich filesystems are new in this round
551 // We will do this by having a timestamp inside each mountpoint 566 // We will do this by having a timestamp inside each mountpoint
552 // if the current timestamp doesn't match this is a new file system and 567 // if the current timestamp doesn't match this is a new file system and
553 // come up with our MediumMountGui :) let the hacking begin 568 // come up with our MediumMountGui :) let the hacking begin
554 int stamp = uidgen.generate(); 569 int stamp = uidgen.generate();
555 570
556 QString newStamp = QString::number( stamp ); // generates newtime Stamp 571 QString newStamp = QString::number( stamp ); // generates newtime Stamp
557 StorageInfo storage; 572 StorageInfo storage;
558 const QList<FileSystem> &fileSystems = storage.fileSystems(); 573 const QList<FileSystem> &fileSystems = storage.fileSystems();
559 QListIterator<FileSystem> it ( fileSystems ); 574 QListIterator<FileSystem> it ( fileSystems );
560 575
561 576 // b)
577 if( mediumCfg.readBoolEntry("global", true ) ){
578 QString mime = configToMime(&mediumCfg).join(";");
579 for( ; it.current(); ++it ){
580 if( (*it)->isRemovable() ){
581 tmp = new DocLnkSet( (*it)->path(), mime );
582 docsFolder->appendFrom( *tmp );
583 delete tmp;
584 }
585 } // done
586 return; // save the else
587 }
588 // c) zecke
562 for ( ; it.current(); ++it ) { 589 for ( ; it.current(); ++it ) {
563 if ( (*it)->isRemovable() ) { // let's find out if we should search on it 590 if ( (*it)->isRemovable() ) { // let's find out if we should search on it
564 qWarning("%s is removeable", (*it)->path().latin1() ); 591 Config cfg( (*it)->path() + "/.opiestorage.cf", Config::File);
565 OConfig cfg( (*it)->path() + "/.opiestorage.cf");
566 cfg.setGroup("main"); 592 cfg.setGroup("main");
567 QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() ); 593 QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() );
594 /** This medium is uptodate
595 */
568 if( stamp == m_timeStamp ){ // ok we know this card 596 if( stamp == m_timeStamp ){ // ok we know this card
569 cfg.writeEntry("timestamp", newStamp ); //just write a new timestamp 597 cfg.writeEntry("timestamp", newStamp ); //just write a new timestamp
570 // we need to scan the list now. Hopefully the cache will be there 598 // we need to scan the list now. Hopefully the cache will be there
571 // read the mimetypes from the config and search for documents 599 // read the mimetypes from the config and search for documents
572 QStringList mimetypes = configToMime( &cfg); 600 QStringList mimetypes = configToMime( &cfg);
573 tmp = new DocLnkSet( (*it)->path(), mimetypes.join(";") ); 601 tmp = new DocLnkSet( (*it)->path(), mimetypes.join(";") );
574 docsFolder->appendFrom( *tmp ); 602 docsFolder->appendFrom( *tmp );
575 delete tmp; 603 delete tmp;
576 604
577 }else{ // come up with the gui cause this a new card 605 }else{ // come up with the gui cause this a new card
578 MediumMountGui medium(&cfg, (*it)->path() ); 606 MediumMountGui medium(&cfg, (*it)->path() );
579 if( medium.check() ){ // we did not ask before or ask again is off 607 if( medium.check() ){ // we did not ask before or ask again is off
608 /** c2) */
580 if( medium.exec() ){ // he clicked yes so search it 609 if( medium.exec() ){ // he clicked yes so search it
581 // speicher 610 // speicher
582 //cfg.read(); // cause of a race we need to reread - fixed 611 //cfg.read(); // cause of a race we need to reread - fixed
612 cfg.setGroup("main");
583 cfg.writeEntry("timestamp", newStamp ); 613 cfg.writeEntry("timestamp", newStamp );
584 cfg.write(); 614 cfg.write();
585 tmp = new DocLnkSet( (*it)->path(), medium.mimeTypes().join(";" ) ); 615 tmp = new DocLnkSet( (*it)->path(), medium.mimeTypes().join(";" ) );
586 docsFolder->appendFrom( *tmp ); 616 docsFolder->appendFrom( *tmp );
587 delete tmp; 617 delete tmp;
588 }// no else 618 }// no else
619 /** c1) */
589 }else{ // we checked 620 }else{ // we checked
590 // do something different see what we need to do 621 // do something different see what we need to do
591 // let's see if we should check the device 622 // let's see if we should check the device
592 cfg.setGroup("main" ); 623 cfg.setGroup("main" );
593 bool check = cfg.readBoolEntry("autocheck", true ); 624 bool check = cfg.readBoolEntry("autocheck", true );
594 if( check ){ // find the documents 625 if( check ){ // find the documents
595 tmp = new DocLnkSet( (*it)->path(), configToMime(&cfg ).join(";") ); 626 tmp = new DocLnkSet( (*it)->path(), configToMime(&cfg ).join(";") );
596 docsFolder->appendFrom( *tmp ); 627 docsFolder->appendFrom( *tmp );
597 delete tmp; 628 delete tmp;
598 } 629 }
599 } 630 }
600 } 631 }
601 } 632 }
602 } 633 }
603 m_timeStamp = newStamp; 634 m_timeStamp = newStamp;
604} 635}
605 636
606void Launcher::updateTabs() 637void Launcher::updateTabs()
607{ 638{
608 MimeType::updateApplications(); // ### reads all applnks twice 639 MimeType::updateApplications(); // ### reads all applnks twice
609 640
610 delete rootFolder; 641 delete rootFolder;
611 rootFolder = new AppLnkSet( MimeType::appsFolderName() ); 642 rootFolder = new AppLnkSet( MimeType::appsFolderName() );
612 643
613 loadDocs(); 644 loadDocs();
614 645
615 tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems()); 646 tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems());
616} 647}
617 648
618void Launcher::updateDocs() 649void Launcher::updateDocs()
619{ 650{
620 loadDocs(); 651 loadDocs();
621 tabs->updateDocs(docsFolder,storage->fileSystems()); 652 tabs->updateDocs(docsFolder,storage->fileSystems());
622} 653}
623 654
624void Launcher::viewSelected(const QString& s) 655void Launcher::viewSelected(const QString& s)
625{ 656{
626 setCaption( s + tr(" - Launcher") ); 657 setCaption( s + tr(" - Launcher") );
627} 658}
628 659
629void Launcher::nextView() 660void Launcher::nextView()
630{ 661{
631 tabs->nextTab(); 662 tabs->nextTab();
632} 663}
633 664
634 665
635void Launcher::select( const AppLnk *appLnk ) 666void Launcher::select( const AppLnk *appLnk )
636{ 667{
637 if ( appLnk->type() == "Folder" ) { 668 if ( appLnk->type() == "Folder" ) {
638 // Not supported: flat is simpler for the user 669 // Not supported: flat is simpler for the user
639 } else { 670 } else {
640 if ( appLnk->exec().isNull() ) { 671 if ( appLnk->exec().isNull() ) {
641 QMessageBox::information(this,tr("No application"), 672 QMessageBox::information(this,tr("No application"),
642 tr("<p>No application is defined for this document." 673 tr("<p>No application is defined for this document."
643 "<p>Type is %1.").arg(appLnk->type())); 674 "<p>Type is %1.").arg(appLnk->type()));
644 return; 675 return;
645 } 676 }
646 tabs->setBusy(TRUE); 677 tabs->setBusy(TRUE);
647 emit executing( appLnk ); 678 emit executing( appLnk );
648 appLnk->execute(); 679 appLnk->execute();
649 } 680 }
650} 681}
651 682
652void Launcher::externalSelected(const AppLnk *appLnk) 683void Launcher::externalSelected(const AppLnk *appLnk)