author | zecke <zecke> | 2002-04-27 17:39:49 (UTC) |
---|---|---|
committer | zecke <zecke> | 2002-04-27 17:39:49 (UTC) |
commit | f3ee6db944094c61ecf803f07ff736bf6d70141d (patch) (side-by-side diff) | |
tree | 590ce81223de721a2d4fdfa0d807e0e2e62ecea1 | |
parent | 1096acae0705c6679a918dafaa7c7388da3828cb (diff) | |
download | opie-f3ee6db944094c61ecf803f07ff736bf6d70141d.zip opie-f3ee6db944094c61ecf803f07ff736bf6d70141d.tar.gz opie-f3ee6db944094c61ecf803f07ff736bf6d70141d.tar.bz2 |
restore original behaviour this can be changed by the MediumMountSettings app
-rw-r--r-- | core/launcher/launcher.cpp | 49 |
1 files changed, 40 insertions, 9 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 @@ -66,35 +66,35 @@ #if defined(_OS_LINUX_) || defined(Q_OS_LINUX) #include <stdio.h> #include <sys/vfs.h> #include <mntent.h> #endif #include <qpe/storage.h> #include "mediummountgui.h" //#define SHOW_ALL // uidGen // uidGen namespace { QStringList configToMime( Config *cfg ){ QStringList mimes; - bool tmpMime; + bool tmpMime = true; cfg->setGroup("mimetypes" ); - tmpMime = cfg->readBoolEntry("all" ,false); + tmpMime = cfg->readBoolEntry("all" ,true); if( tmpMime ){ mimes << QString::null; return mimes; }else{ tmpMime = cfg->readBoolEntry("audio", true ); if(tmpMime ) mimes.append("audio/*" ); tmpMime = cfg->readBoolEntry("image", true ); if(tmpMime ) mimes.append("image/*" ); tmpMime = cfg->readBoolEntry("text", true ); if(tmpMime ) mimes.append("text/*"); @@ -521,84 +521,115 @@ void Launcher::updateMimeTypes() { MimeType::clear(); updateMimeTypes(rootFolder); } void Launcher::updateMimeTypes(AppLnkSet* folder) { for ( QListIterator<AppLnk> it( folder->children() ); it.current(); ++it ) { AppLnk *app = it.current(); if ( app->type() == "Folder" ) updateMimeTypes((AppLnkSet *)app); else { MimeType::registerApp(*app); } } } - +/** This is a HACK.... + * Reason: scanning huge mediums, microdirvers for examples + * consomes time. To avoid that we invented the MediumMountCheck + * + * a) the user globally disabled medium checking. We can ignore + * all removable medium + * b) the user enabled medium checking globally and we need to use this mimefilter + * c) the user enabled medium checking on a per medium bases + * c1) we already checked and its not ask again turns + * c2) we need to ask and then apply the mimefilter + */ void Launcher::loadDocs() // ok here comes a hack belonging to Global:: { - qWarning("loading Documents" ); - qWarning("The currentTimeStamp is: %s", m_timeStamp.latin1() ); delete docsFolder; docsFolder = new DocLnkSet; - qWarning("new DocLnkSet" ); + DocLnkSet *tmp = 0; QString home = QString(getenv("HOME")) + "/Documents"; tmp = new DocLnkSet( home , QString::null); docsFolder->appendFrom( *tmp ); delete tmp; + + Config mediumCfg( "medium"); + mediumCfg.setGroup("main"); + // a) -zecke we don't want to check + if(!mediumCfg.readBoolEntry("use", true ) ) + return; + // find out wich filesystems are new in this round // We will do this by having a timestamp inside each mountpoint // if the current timestamp doesn't match this is a new file system and // come up with our MediumMountGui :) let the hacking begin int stamp = uidgen.generate(); QString newStamp = QString::number( stamp ); // generates newtime Stamp StorageInfo storage; const QList<FileSystem> &fileSystems = storage.fileSystems(); QListIterator<FileSystem> it ( fileSystems ); - + // b) + if( mediumCfg.readBoolEntry("global", true ) ){ + QString mime = configToMime(&mediumCfg).join(";"); + for( ; it.current(); ++it ){ + if( (*it)->isRemovable() ){ + tmp = new DocLnkSet( (*it)->path(), mime ); + docsFolder->appendFrom( *tmp ); + delete tmp; + } + } // done + return; // save the else + } + // c) zecke for ( ; it.current(); ++it ) { if ( (*it)->isRemovable() ) { // let's find out if we should search on it - qWarning("%s is removeable", (*it)->path().latin1() ); - OConfig cfg( (*it)->path() + "/.opiestorage.cf"); + Config cfg( (*it)->path() + "/.opiestorage.cf", Config::File); cfg.setGroup("main"); QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() ); + /** This medium is uptodate + */ if( stamp == m_timeStamp ){ // ok we know this card cfg.writeEntry("timestamp", newStamp ); //just write a new timestamp // we need to scan the list now. Hopefully the cache will be there // read the mimetypes from the config and search for documents QStringList mimetypes = configToMime( &cfg); tmp = new DocLnkSet( (*it)->path(), mimetypes.join(";") ); docsFolder->appendFrom( *tmp ); delete tmp; }else{ // come up with the gui cause this a new card MediumMountGui medium(&cfg, (*it)->path() ); if( medium.check() ){ // we did not ask before or ask again is off + /** c2) */ if( medium.exec() ){ // he clicked yes so search it // speicher //cfg.read(); // cause of a race we need to reread - fixed + cfg.setGroup("main"); cfg.writeEntry("timestamp", newStamp ); cfg.write(); tmp = new DocLnkSet( (*it)->path(), medium.mimeTypes().join(";" ) ); docsFolder->appendFrom( *tmp ); delete tmp; }// no else + /** c1) */ }else{ // we checked // do something different see what we need to do // let's see if we should check the device cfg.setGroup("main" ); bool check = cfg.readBoolEntry("autocheck", true ); if( check ){ // find the documents tmp = new DocLnkSet( (*it)->path(), configToMime(&cfg ).join(";") ); docsFolder->appendFrom( *tmp ); delete tmp; } } } } } m_timeStamp = newStamp; } |