author | alwin <alwin> | 2004-11-11 21:10:16 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-11-11 21:10:16 (UTC) |
commit | d2d25a3c1e60a34436cd93e5214a35b3edd05c6c (patch) (side-by-side diff) | |
tree | 0c1bd62dd09e7a86292399f68c823b7eb6ae031e | |
parent | e85cf7184c3444e26c1858d0564fa5d3614dd7b5 (diff) | |
download | opie-d2d25a3c1e60a34436cd93e5214a35b3edd05c6c.zip opie-d2d25a3c1e60a34436cd93e5214a35b3edd05c6c.tar.gz opie-d2d25a3c1e60a34436cd93e5214a35b3edd05c6c.tar.bz2 |
- flush icon cache if reloading all documents
- send QCop message when the doctab is enabled/disabled so the
disabled widget appears or the doc-list will reread
-rw-r--r-- | core/launcher/documentlist.cpp | 610 | ||||
-rw-r--r-- | core/launcher/documentlist.h | 3 | ||||
-rw-r--r-- | core/launcher/launcher.cpp | 107 | ||||
-rw-r--r-- | core/launcher/launcher.h | 1 | ||||
-rw-r--r-- | core/launcher/launcherview.cpp | 4 | ||||
-rw-r--r-- | core/launcher/server.cpp | 210 |
6 files changed, 483 insertions, 452 deletions
diff --git a/core/launcher/documentlist.cpp b/core/launcher/documentlist.cpp index d8e7a83..9781a32 100644 --- a/core/launcher/documentlist.cpp +++ b/core/launcher/documentlist.cpp @@ -55,749 +55,757 @@ AppLnkSet *DocumentList::appLnkSet = 0; static const int MAX_SEARCH_DEPTH = 10; class DocumentListPrivate : public QObject { Q_OBJECT public: DocumentListPrivate( ServerInterface *gui ); ~DocumentListPrivate(); void initialize(); const QString nextFile(); const DocLnk *iterate(); bool store( DocLnk* dl ); void estimatedPercentScanned(); void appendDocpath(FileSystem*); DocLnkSet dls; QDict<void> reference; QDictIterator<void> *dit; enum { Find, RemoveKnownFiles, MakeUnknownFiles, Done } state; QStringList docPaths; unsigned int docPathsSearched; int searchDepth; QDir *listDirs[MAX_SEARCH_DEPTH]; const QFileInfoList *lists[MAX_SEARCH_DEPTH]; unsigned int listPositions[MAX_SEARCH_DEPTH]; StorageInfo *storage; int tid; ServerInterface *serverGui; bool needToSendAllDocLinks; bool sendAppLnks; bool sendDocLnks; bool scanDocs; }; /* * scandocs will be read from Config */ DocumentList::DocumentList( ServerInterface *serverGui, bool /*scanDocs*/, - QObject *parent, const char *name ) + QObject *parent, const char *name ) : QObject( parent, name ) { appLnkSet = new AppLnkSet( MimeType::appsFolderName() ); d = new DocumentListPrivate( serverGui ); d->needToSendAllDocLinks = false; Config cfg( "Launcher" ); cfg.setGroup( "DocTab" ); d->scanDocs = cfg.readBoolEntry( "Enable", true ); odebug << "DocumentList::DocumentList() : scanDocs = " << d->scanDocs << "" << oendl; QTimer::singleShot( 10, this, SLOT( startInitialScan() ) ); } void DocumentList::startInitialScan() { reloadAppLnks(); reloadDocLnks(); } DocumentList::~DocumentList() { delete appLnkSet; delete d; } void DocumentList::add( const DocLnk& doc ) { if ( d->serverGui && QFile::exists( doc.file() ) ) - d->serverGui->documentAdded( doc ); + d->serverGui->documentAdded( doc ); } void DocumentList::start() { resume(); } void DocumentList::pause() { //odebug << "pause " << d->tid << "" << oendl; killTimer( d->tid ); d->tid = 0; } void DocumentList::resume() { if ( d->tid == 0 ) { - d->tid = startTimer( 20 ); + d->tid = startTimer( 20 ); //odebug << "resumed " << d->tid << "" << oendl; } } /* void DocumentList::resend() { // Re-emits all the added items to the list (firstly letting everyone know to // clear what they have as it is being sent again) pause(); emit allRemoved(); QTimer::singleShot( 5, this, SLOT( resendWorker() ) ); } void DocumentList::resendWorker() { const QList<DocLnk> &list = d->dls.children(); for ( QListIterator<DocLnk> it( list ); it.current(); ++it ) - add( *(*it) ); + add( *(*it) ); resume(); } */ void DocumentList::rescan() { //odebug << "rescan" << oendl; pause(); d->initialize(); resume(); } void DocumentList::timerEvent( QTimerEvent *te ) { if ( te->timerId() == d->tid ) { - // Do 3 at a time + // Do 3 at a time if ( d->serverGui ) d->serverGui->aboutToAddBegin(); - for (int i = 0; i < 3; i++ ) { - const DocLnk *lnk = d->iterate(); - if ( lnk ) { - add( *lnk ); - } else { - // stop when done - pause(); - if ( d->serverGui ) - d->serverGui->documentScanningProgress( 100 ); - if ( d->needToSendAllDocLinks ) - sendAllDocLinks(); - break; - } + for (int i = 0; i < 3; i++ ) { + const DocLnk *lnk = d->iterate(); + if ( lnk ) { + add( *lnk ); + } else { + // stop when done + pause(); + if ( d->serverGui ) + d->serverGui->documentScanningProgress( 100 ); + if ( d->needToSendAllDocLinks ) + sendAllDocLinks(); + break; + } } if ( d->serverGui ) d->serverGui->aboutToAddEnd(); } } void DocumentList::reloadAppLnks() { if ( d->sendAppLnks && d->serverGui ) { - d->serverGui->applicationScanningProgress( 0 ); - d->serverGui->allApplicationsRemoved(); + d->serverGui->applicationScanningProgress( 0 ); + d->serverGui->allApplicationsRemoved(); } delete appLnkSet; appLnkSet = new AppLnkSet( MimeType::appsFolderName() ); if ( d->sendAppLnks && d->serverGui ) { - static QStringList prevTypeList; - QStringList types = appLnkSet->types(); - for ( QStringList::Iterator ittypes=types.begin(); ittypes!=types.end(); ++ittypes) { - if ( !(*ittypes).isEmpty() ) { - if ( !prevTypeList.contains(*ittypes) ) { - QString name = appLnkSet->typeName(*ittypes); - QPixmap pm = appLnkSet->typePixmap(*ittypes); - QPixmap bgPm = appLnkSet->typeBigPixmap(*ittypes); - - if (pm.isNull()) { - QImage img( Resource::loadImage( "UnknownDocument" ) ); - pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); - bgPm = img.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() ); - } + static QStringList prevTypeList; + QStringList types = appLnkSet->types(); + for ( QStringList::Iterator ittypes=types.begin(); ittypes!=types.end(); ++ittypes) { + if ( !(*ittypes).isEmpty() ) { + if ( !prevTypeList.contains(*ittypes) ) { + QString name = appLnkSet->typeName(*ittypes); + QPixmap pm = appLnkSet->typePixmap(*ittypes); + QPixmap bgPm = appLnkSet->typeBigPixmap(*ittypes); + + if (pm.isNull()) { + QImage img( Resource::loadImage( "UnknownDocument" ) ); + pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); + bgPm = img.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() ); + } //odebug << "adding type " << (*ittypes) << "" << oendl; - // ### our current launcher expects docs tab to be last - d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm ); - } - prevTypeList.remove(*ittypes); - } - } - for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) { + // ### our current launcher expects docs tab to be last + d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm ); + } + prevTypeList.remove(*ittypes); + } + } + for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) { //odebug << "removing type " << (*ittypes) << "" << oendl; - d->serverGui->typeRemoved(*ittypes); - } - prevTypeList = types; + d->serverGui->typeRemoved(*ittypes); + } + prevTypeList = types; } QListIterator<AppLnk> itapp( appLnkSet->children() ); AppLnk* l; while ( (l=itapp.current()) ) { - ++itapp; - if ( d->sendAppLnks && d->serverGui ) - d->serverGui->applicationAdded( l->type(), *l ); + ++itapp; + if ( d->sendAppLnks && d->serverGui ) + d->serverGui->applicationAdded( l->type(), *l ); } if ( d->sendAppLnks && d->serverGui ) - d->serverGui->applicationScanningProgress( 100 ); + d->serverGui->applicationScanningProgress( 100 ); } void DocumentList::reloadDocLnks() { if ( !d->scanDocs ) - return; + return; if ( d->sendDocLnks && d->serverGui ) { - d->serverGui->documentScanningProgress( 0 ); - d->serverGui->allDocumentsRemoved(); + d->serverGui->documentScanningProgress( 0 ); + d->serverGui->allDocumentsRemoved(); } rescan(); } +void DocumentList::reforceDocuments() +{ + Config cfg( "Launcher" ); + cfg.setGroup( "DocTab" ); + d->scanDocs = cfg.readBoolEntry( "Enable", true ); + reloadDocLnks(); +} + void DocumentList::linkChanged( QString arg ) { - //odebug << "linkchanged( " << arg << " )" << oendl; + odebug << "linkchanged( " << arg << " )" << oendl; if ( arg.isNull() || OGlobal::isAppLnkFileName( arg ) ) { - reloadAppLnks(); + reloadAppLnks(); } else { - const QList<DocLnk> &list = d->dls.children(); - QListIterator<DocLnk> it( list ); - while ( it.current() ) { - DocLnk *doc = it.current(); - ++it; - if ( ( doc->linkFileKnown() && doc->linkFile() == arg ) - || ( doc->fileKnown() && doc->file() == arg ) ) { + const QList<DocLnk> &list = d->dls.children(); + QListIterator<DocLnk> it( list ); + while ( it.current() ) { + DocLnk *doc = it.current(); + ++it; + if ( ( doc->linkFileKnown() && doc->linkFile() == arg ) + || ( doc->fileKnown() && doc->file() == arg ) ) { //odebug << "found old link" << oendl; - DocLnk* dl = new DocLnk( arg ); - // add new one if it exists and matches the mimetype - if ( d->store( dl ) ) { - // Existing link has been changed, send old link ref and a ref - // to the new link + DocLnk* dl = new DocLnk( arg ); + // add new one if it exists and matches the mimetype + if ( d->store( dl ) ) { + // Existing link has been changed, send old link ref and a ref + // to the new link //odebug << "change case" << oendl; - if ( d->serverGui ) - d->serverGui->documentChanged( *doc, *dl ); + if ( d->serverGui ) + d->serverGui->documentChanged( *doc, *dl ); - } else { - // Link has been removed or doesn't match the mimetypes any more - // so we aren't interested in it, so take it away from the list + } else { + // Link has been removed or doesn't match the mimetypes any more + // so we aren't interested in it, so take it away from the list //odebug << "removal case" << oendl; - if ( d->serverGui ) - d->serverGui->documentRemoved( *doc ); - - } - d->dls.remove( doc ); // remove old link from docLnkSet - delete doc; - return; - } - } - // Didn't find existing link, must be new - DocLnk* dl = new DocLnk( arg ); - if ( d->store( dl ) ) { - // Add if it's a link we are interested in + if ( d->serverGui ) + d->serverGui->documentRemoved( *doc ); + + } + d->dls.remove( doc ); // remove old link from docLnkSet + delete doc; + return; + } + } + // Didn't find existing link, must be new + DocLnk* dl = new DocLnk( arg ); + if ( d->store( dl ) ) { + // Add if it's a link we are interested in //odebug << "add case" << oendl; - add( *dl ); - } + add( *dl ); + } } } void DocumentList::restoreDone() { reloadAppLnks(); reloadDocLnks(); } void DocumentList::DiffAppLnks() { static AppLnkSet *appLnkSet2; appLnkSet2 = new AppLnkSet( MimeType::appsFolderName() ); if ( d->sendAppLnks && d->serverGui ) { - static QStringList prevTypeList = appLnkSet->types(); - QStringList types = appLnkSet2->types(); - for ( QStringList::Iterator ittypes=types.begin(); ittypes!=types.end(); ++ittypes) { - if ( !(*ittypes).isEmpty() ) { - if ( !prevTypeList.contains(*ittypes) ) { - QString name = appLnkSet2->typeName(*ittypes); - QPixmap pm = appLnkSet2->typePixmap(*ittypes); - QPixmap bgPm = appLnkSet2->typeBigPixmap(*ittypes); - - if (pm.isNull()) { - QImage img( Resource::loadImage( "UnknownDocument" ) ); - pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); - bgPm = img.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() ); - } + static QStringList prevTypeList = appLnkSet->types(); + QStringList types = appLnkSet2->types(); + for ( QStringList::Iterator ittypes=types.begin(); ittypes!=types.end(); ++ittypes) { + if ( !(*ittypes).isEmpty() ) { + if ( !prevTypeList.contains(*ittypes) ) { + QString name = appLnkSet2->typeName(*ittypes); + QPixmap pm = appLnkSet2->typePixmap(*ittypes); + QPixmap bgPm = appLnkSet2->typeBigPixmap(*ittypes); + + if (pm.isNull()) { + QImage img( Resource::loadImage( "UnknownDocument" ) ); + pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); + bgPm = img.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() ); + } odebug << "adding type " << (*ittypes) << "" << oendl; - // ### our current launcher expects docs tab to be last - d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm ); - } - prevTypeList.remove(*ittypes); - } - } - for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) { + // ### our current launcher expects docs tab to be last + d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm ); + } + prevTypeList.remove(*ittypes); + } + } + for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) { odebug << "removing type " << (*ittypes) << "" << oendl; - d->serverGui->typeRemoved(*ittypes); - } - prevTypeList = types; + d->serverGui->typeRemoved(*ittypes); + } + prevTypeList = types; } QListIterator<AppLnk> it1( appLnkSet->children() ); QListIterator<AppLnk> it2( appLnkSet2->children() ); AppLnk *i; AppLnk *j; bool found; while ( (j=it2.current()) ) { - it1 = appLnkSet->children(); - found = false; - while ( (i=it1.current()) ){ - if (strcmp(i->name().ascii(),j->name().ascii()) == 0) - found = true; - ++it1; - } - if (!found) { - odebug << "Item " << j->name().ascii() << " needs to be added" << oendl; - d->serverGui->applicationAdded( j->type(), *j ); - } - ++it2; + it1 = appLnkSet->children(); + found = false; + while ( (i=it1.current()) ){ + if (strcmp(i->name().ascii(),j->name().ascii()) == 0) + found = true; + ++it1; + } + if (!found) { + odebug << "Item " << j->name().ascii() << " needs to be added" << oendl; + d->serverGui->applicationAdded( j->type(), *j ); + } + ++it2; } it1 = appLnkSet->children(); while ( (i=it1.current()) ) { - it2 = appLnkSet2->children(); - found = false; - while ( (j=it2.current()) ){ - if (strcmp(i->name().ascii(),j->name().ascii()) == 0) - found = true; - ++it2; - } - if (!found) { - odebug << "Item " << i->name().ascii() << " needs to be removed" << oendl; - d->serverGui->applicationRemoved( i->type(), *i ); - } + it2 = appLnkSet2->children(); + found = false; + while ( (j=it2.current()) ){ + if (strcmp(i->name().ascii(),j->name().ascii()) == 0) + found = true; + ++it2; + } + if (!found) { + odebug << "Item " << i->name().ascii() << " needs to be removed" << oendl; + d->serverGui->applicationRemoved( i->type(), *i ); + } - ++it1; + ++it1; } delete appLnkSet; appLnkSet = appLnkSet2; } void DocumentList::storageChanged() { QTime t; // ### can implement better t.start(); DiffAppLnks(); // reloadAppLnks(); odebug << "Reload App links took " << t.elapsed() << " ms" << oendl; reloadDocLnks(); // odebug << "Reload links took " << t.elapsed() << " ms " << oendl; odebug << "Reload All links took " << t.elapsed() << " ms" << oendl; // ### Optimization opportunity // Could be a bit more intelligent and somehow work out which // mtab entry has changed and then only scan that and add and remove // links appropriately. // rescan(); } void DocumentList::sendAllDocLinks() { if ( d->tid != 0 ) { - // We are in the middle of scanning, set a flag so - // we do this when we finish our scanning - d->needToSendAllDocLinks = true; - return; + // We are in the middle of scanning, set a flag so + // we do this when we finish our scanning + d->needToSendAllDocLinks = true; + return; } QString contents; Categories cats; for ( QListIterator<DocLnk> it( d->dls.children() ); it.current(); ++it ) { - DocLnk *doc = it.current(); - QFileInfo fi( doc->file() ); - if ( !fi.exists() ) - continue; - - bool fake = !doc->linkFileKnown(); - if ( !fake ) { - QFile f( doc->linkFile() ); - if ( f.open( IO_ReadOnly ) ) { - QTextStream ts( &f ); - ts.setEncoding( QTextStream::UnicodeUTF8 ); - QString docLnk = ts.read(); - // Strip out the (stale) LinkFile entry - int start = docLnk.find( "\nLinkFile = " ) + 1; - if ( start > 0 ) { - int end = docLnk.find( "\n", start + 1 ) + 1; - contents += docLnk.left(start); - contents += docLnk.mid(end); - } else { - contents += docLnk; - } - contents += "LinkFile = " + doc->linkFile() + "\n"; - - f.close(); - } else - fake = TRUE; - } - if (fake) { - contents += "[Desktop Entry]\n"; // No tr - contents += "Categories = " + // No tr - cats.labels("Document View",doc->categories()).join(";") + "\n"; // No tr - contents += "Name = "+doc->name()+"\n"; // No tr - contents += "Type = "+doc->type()+"\n"; // No tr - } - contents += "File = "+doc->file()+"\n"; // No tr // (resolves path) - contents += QString("Size = %1\n").arg( fi.size() ); // No tr + DocLnk *doc = it.current(); + QFileInfo fi( doc->file() ); + if ( !fi.exists() ) + continue; + + bool fake = !doc->linkFileKnown(); + if ( !fake ) { + QFile f( doc->linkFile() ); + if ( f.open( IO_ReadOnly ) ) { + QTextStream ts( &f ); + ts.setEncoding( QTextStream::UnicodeUTF8 ); + QString docLnk = ts.read(); + // Strip out the (stale) LinkFile entry + int start = docLnk.find( "\nLinkFile = " ) + 1; + if ( start > 0 ) { + int end = docLnk.find( "\n", start + 1 ) + 1; + contents += docLnk.left(start); + contents += docLnk.mid(end); + } else { + contents += docLnk; + } + contents += "LinkFile = " + doc->linkFile() + "\n"; + + f.close(); + } else + fake = TRUE; + } + if (fake) { + contents += "[Desktop Entry]\n"; // No tr + contents += "Categories = " + // No tr + cats.labels("Document View",doc->categories()).join(";") + "\n"; // No tr + contents += "Name = "+doc->name()+"\n"; // No tr + contents += "Type = "+doc->type()+"\n"; // No tr + } + contents += "File = "+doc->file()+"\n"; // No tr // (resolves path) + contents += QString("Size = %1\n").arg( fi.size() ); // No tr } //odebug << "sending length " << contents.length() << "" << oendl; #ifndef QT_NO_COP QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); e << contents; #endif //odebug << "================ \n\n" << contents << "\n\n===============" << oendl; d->needToSendAllDocLinks = false; } DocumentListPrivate::DocumentListPrivate( ServerInterface *gui ) { storage = new StorageInfo( this ); serverGui = gui; if ( serverGui ) { - sendAppLnks = serverGui->requiresApplications(); - sendDocLnks = serverGui->requiresDocuments(); + sendAppLnks = serverGui->requiresApplications(); + sendDocLnks = serverGui->requiresDocuments(); } else { - sendAppLnks = false; - sendDocLnks = false; + sendAppLnks = false; + sendDocLnks = false; } for ( int i = 0; i < MAX_SEARCH_DEPTH; i++ ) { - listDirs[i] = 0; - lists[i] = 0; - listPositions[i] = 0; + listDirs[i] = 0; + lists[i] = 0; + listPositions[i] = 0; } initialize(); tid = 0; } void DocumentListPrivate::appendDocpath(FileSystem*fs) { QDir defPath(fs->path()+"/Documents"); QFileInfo f(fs->path()+"/.opiestorage.cf"); if (!f.exists()) { Mediadlg dlg(fs); if (QDialog::Accepted != QPEApplication::execDialog( &dlg )) { return; } } Config conf(f.filePath(), Config::File ); conf.setGroup("main"); if (!conf.readBoolEntry("check",false)) { return; } conf.setGroup("subdirs"); bool read_all = conf.readBoolEntry("wholemedia",true); if (read_all) { docPaths+=fs->path(); return; } QStringList subDirs = conf.readListEntry("subdirs",':'); if (subDirs.isEmpty()) { if (defPath.exists()) { docPaths+=defPath.path(); } return; } for (unsigned c = 0; c < subDirs.count();++c) { QDir docDir(QString(fs->path()+"/"+subDirs[c])); if (docDir.exists()) { docPaths+=docDir.path(); } } } void DocumentListPrivate::initialize() { // Reset dls.clear(); docPaths.clear(); reference.clear(); QDir docDir( QPEApplication::documentDir() ); if ( docDir.exists() ) - docPaths += QPEApplication::documentDir(); + docPaths += QPEApplication::documentDir(); int i = 1; const QList<FileSystem> &fs = storage->fileSystems(); QListIterator<FileSystem> it( fs ); for ( ; it.current(); ++it ) { if ( (*it)->isRemovable() ) { appendDocpath((*it)); ++i; } } for ( int i = 0; i < MAX_SEARCH_DEPTH; ++i ) { - if ( listDirs[i] ) { - delete listDirs[i]; - listDirs[i] = 0; - } - lists[i] = 0; - listPositions[i] = 0; + if ( listDirs[i] ) { + delete listDirs[i]; + listDirs[i] = 0; + } + lists[i] = 0; + listPositions[i] = 0; } docPathsSearched = 0; searchDepth = -1; state = Find; dit = 0; } DocumentListPrivate::~DocumentListPrivate() { for ( int i = 0; i < MAX_SEARCH_DEPTH; i++ ) - if ( listDirs[i] ) - delete listDirs[i]; + if ( listDirs[i] ) + delete listDirs[i]; delete dit; } void DocumentListPrivate::estimatedPercentScanned() { double overallProgress = 0.0; double levelWeight = 75.0; int topCount = docPaths.count(); if ( topCount > 1 ) { - levelWeight = levelWeight / topCount; - overallProgress += (docPathsSearched - 1) * levelWeight; + levelWeight = levelWeight / topCount; + overallProgress += (docPathsSearched - 1) * levelWeight; } for ( int d = 0; d <= searchDepth; d++ ) { - if ( listDirs[d] ) { - int items = lists[d]->count(); - if ( items > 1 ) { - levelWeight = levelWeight / items; - // Take in to account "." and ".." - overallProgress += (listPositions[d] - 3) * levelWeight; - } - } else { - break; - } + if ( listDirs[d] ) { + int items = lists[d]->count(); + if ( items > 1 ) { + levelWeight = levelWeight / items; + // Take in to account "." and ".." + overallProgress += (listPositions[d] - 3) * levelWeight; + } + } else { + break; + } } // odebug << "overallProgress: " << overallProgress << "" << oendl; if ( serverGui ) - serverGui->documentScanningProgress( (int)overallProgress ); + serverGui->documentScanningProgress( (int)overallProgress ); } const QString DocumentListPrivate::nextFile() { while ( TRUE ) { - while ( searchDepth < 0 ) { - // go to next base path - if ( docPathsSearched >= docPaths.count() ) { - // end of base paths - return QString::null; - } else { - QDir dir( docPaths[docPathsSearched] ); + while ( searchDepth < 0 ) { + // go to next base path + if ( docPathsSearched >= docPaths.count() ) { + // end of base paths + return QString::null; + } else { + QDir dir( docPaths[docPathsSearched] ); // odebug << "now using base path: " << docPaths[docPathsSearched] << "" << oendl; - docPathsSearched++; - if ( !dir.exists( ".Qtopia-ignore" ) ) { - listDirs[0] = new QDir( dir ); - lists[0] = listDirs[0]->entryInfoList(); - listPositions[0] = 0; - searchDepth = 0; - } - } - } - - const QFileInfoList *fil = lists[searchDepth]; + docPathsSearched++; + if ( !dir.exists( ".Qtopia-ignore" ) ) { + listDirs[0] = new QDir( dir ); + lists[0] = listDirs[0]->entryInfoList(); + listPositions[0] = 0; + searchDepth = 0; + } + } + } + + const QFileInfoList *fil = lists[searchDepth]; if (!fil) { return QString::null; } - QFileInfoList *fl = (QFileInfoList *)fil; - unsigned int pos = listPositions[searchDepth]; - - if ( pos >= fl->count() ) { - // go up a depth - delete listDirs[searchDepth]; - listDirs[searchDepth] = 0; - lists[searchDepth] = 0; - listPositions[searchDepth] = 0; - searchDepth--; - } else { - const QFileInfo *fi = fl->at(pos); - listPositions[searchDepth]++; - QString bn = fi->fileName(); - if ( bn[0] != '.' ) { - if ( fi->isDir() ) { - if ( bn != "CVS" && bn != "Qtopia" && bn != "QtPalmtop" ) { - // go down a depth - QDir dir( fi->filePath() ); + QFileInfoList *fl = (QFileInfoList *)fil; + unsigned int pos = listPositions[searchDepth]; + + if ( pos >= fl->count() ) { + // go up a depth + delete listDirs[searchDepth]; + listDirs[searchDepth] = 0; + lists[searchDepth] = 0; + listPositions[searchDepth] = 0; + searchDepth--; + } else { + const QFileInfo *fi = fl->at(pos); + listPositions[searchDepth]++; + QString bn = fi->fileName(); + if ( bn[0] != '.' ) { + if ( fi->isDir() ) { + if ( bn != "CVS" && bn != "Qtopia" && bn != "QtPalmtop" ) { + // go down a depth + QDir dir( fi->filePath() ); // odebug << "now going in to path: " << bn << "" << oendl; - if ( !dir.exists( ".Qtopia-ignore" ) ) { - if ( searchDepth < MAX_SEARCH_DEPTH - 1) { - searchDepth++; - listDirs[searchDepth] = new QDir( dir ); - lists[searchDepth] = listDirs[searchDepth]->entryInfoList(); - listPositions[searchDepth] = 0; - } - } - } - } else { - estimatedPercentScanned(); - return fl->at(pos)->filePath(); - } - } - } + if ( !dir.exists( ".Qtopia-ignore" ) ) { + if ( searchDepth < MAX_SEARCH_DEPTH - 1) { + searchDepth++; + listDirs[searchDepth] = new QDir( dir ); + lists[searchDepth] = listDirs[searchDepth]->entryInfoList(); + listPositions[searchDepth] = 0; + } + } + } + } else { + estimatedPercentScanned(); + return fl->at(pos)->filePath(); + } + } + } } return QString::null; } bool DocumentListPrivate::store( DocLnk* dl ) { // if ( dl->fileKnown() && !dl->file().isEmpty() ) { if ( dl && dl->fileKnown() ) { - dls.add( dl ); // store - return TRUE; + dls.add( dl ); // store + return TRUE; } // don't store - delete delete dl; return FALSE; } -#define MAGIC_NUMBER ((void*)2) +#define MAGIC_NUMBER ((void*)2) const DocLnk *DocumentListPrivate::iterate() { if ( state == Find ) { //odebug << "state Find" << oendl; - QString file = nextFile(); - while ( !file.isNull() ) { - if ( file.right(8) == ".desktop" ) { // No tr - DocLnk* dl = new DocLnk( file ); - if ( store(dl) ) - return dl; - } else { - reference.insert( file, MAGIC_NUMBER ); - } - file = nextFile(); - } - state = RemoveKnownFiles; - - if ( serverGui ) - serverGui->documentScanningProgress( 75 ); + QString file = nextFile(); + while ( !file.isNull() ) { + if ( file.right(8) == ".desktop" ) { // No tr + DocLnk* dl = new DocLnk( file ); + if ( store(dl) ) + return dl; + } else { + reference.insert( file, MAGIC_NUMBER ); + } + file = nextFile(); + } + state = RemoveKnownFiles; + + if ( serverGui ) + serverGui->documentScanningProgress( 75 ); } static int iterationI; static int iterationCount; if ( state == RemoveKnownFiles ) { //odebug << "state RemoveKnownFiles" << oendl; - const QList<DocLnk> &list = dls.children(); - for ( QListIterator<DocLnk> it( list ); it.current(); ++it ) { - reference.remove( (*it)->file() ); - // ### does this need to be deleted? - } - dit = new QDictIterator<void>(reference); - state = MakeUnknownFiles; + const QList<DocLnk> &list = dls.children(); + for ( QListIterator<DocLnk> it( list ); it.current(); ++it ) { + reference.remove( (*it)->file() ); + // ### does this need to be deleted? + } + dit = new QDictIterator<void>(reference); + state = MakeUnknownFiles; - iterationI = 0; - iterationCount = dit->count(); + iterationI = 0; + iterationCount = dit->count(); } if ( state == MakeUnknownFiles ) { //odebug << "state MakeUnknownFiles" << oendl; - for (void* c; (c=dit->current()); ++(*dit) ) { - if ( c == MAGIC_NUMBER ) { - DocLnk* dl = new DocLnk; - QFileInfo fi( dit->currentKey() ); - dl->setFile( fi.filePath() ); - dl->setName( fi.baseName() ); - if ( store(dl) ) { - ++*dit; - iterationI++; - if ( serverGui ) - serverGui->documentScanningProgress( 75 + (25*iterationI)/iterationCount ); - return dl; - } - } - iterationI++; - } - - delete dit; - dit = 0; - state = Done; + for (void* c; (c=dit->current()); ++(*dit) ) { + if ( c == MAGIC_NUMBER ) { + DocLnk* dl = new DocLnk; + QFileInfo fi( dit->currentKey() ); + dl->setFile( fi.filePath() ); + dl->setName( fi.baseName() ); + if ( store(dl) ) { + ++*dit; + iterationI++; + if ( serverGui ) + serverGui->documentScanningProgress( 75 + (25*iterationI)/iterationCount ); + return dl; + } + } + iterationI++; + } + + delete dit; + dit = 0; + state = Done; } //odebug << "state Done" << oendl; return NULL; } #include "documentlist.moc" diff --git a/core/launcher/documentlist.h b/core/launcher/documentlist.h index 232bb6a..8b69e95 100644 --- a/core/launcher/documentlist.h +++ b/core/launcher/documentlist.h @@ -1,78 +1,79 @@ /********************************************************************** ** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. ** ** This file is part of the Qtopia Environment. ** ** This file may be distributed and/or modified under the terms of the ** GNU General Public License version 2 as published by the Free Software ** Foundation and appearing in the file LICENSE.GPL included in the ** packaging of this file. ** ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ** ** See http://www.trolltech.com/gpl/ for GPL licensing information. ** ** Contact info@trolltech.com if any conditions of this licensing are ** not clear to you. ** **********************************************************************/ #ifndef DOCUMENT_LIST_H #define DOCUMENT_LIST_H #include <qobject.h> #include <qtopia/applnk.h> class DocumentListPrivate; class ServerInterface; class DocumentList : public QObject { Q_OBJECT public: DocumentList( ServerInterface *serverGui, bool scanDocs = TRUE, - QObject *parent = 0, const char *name = 0 ); + QObject *parent = 0, const char *name = 0 ); ~DocumentList(); void linkChanged( QString link ); void restoreDone(); void storageChanged(); void sendAllDocLinks(); void reloadAppLnks(); void reloadDocLnks(); + void reforceDocuments(); void DiffAppLnks(); // Orig DocList stuff void start(); void pause(); void resume(); void rescan(); static AppLnkSet *appLnkSet; /* void resend(); signals: void added( const DocLnk& doc ); void removed( const DocLnk& doc ); void changed( const DocLnk& oldDoc, const DocLnk& newDoc ); void allRemoved(); void doneForNow(); private slots: void resendWorker(); */ private slots: void startInitialScan(); protected: void timerEvent( QTimerEvent *te ); private: void add( const DocLnk& doc ); DocumentListPrivate *d; }; #endif diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp index ccc2114..970b8cb 100644 --- a/core/launcher/launcher.cpp +++ b/core/launcher/launcher.cpp @@ -343,155 +343,176 @@ void LauncherTabWidget::setProgressStyle() } } /* * FIXME * The following NULL check is triggered by inserting, then removing a tab on the fly * as you would if you had removable media (which I do). Without this check * the first app launched after a tab removal causes qpe to Segfault. * This obviously has a more sinister cause, but this works around it with no * obvious adverse effects. Please FIXME * bkc - 17/6/2004 * */ void LauncherTabWidget::setBusy(bool on) { if ( on ) currentView()->setBusy(TRUE); else { for ( int i = 0; i < categoryBar->count(); i++ ) { if (categoryBar->tab(i)) { LauncherView *view = ((LauncherTab *)categoryBar->tab(i))->view; view->setBusy( FALSE ); } else { odebug << "Averting Disaster with tab " << i << " == NULL! " << oendl; } } } } void LauncherTabWidget::setBusyIndicatorType( const QString& str ) { for (int i = 0; i < categoryBar->count(); i++ ) { LauncherView* view = static_cast<LauncherTab*>( categoryBar->tab(i) )->view; view->setBusyIndicatorType( str ); } } LauncherView *LauncherTabWidget::currentView(void) { return (LauncherView*)stack->visibleWidget(); } void LauncherTabWidget::launcherMessage( const QCString &msg, const QByteArray &data) { QDataStream stream( data, IO_ReadOnly ); if ( msg == "setTabView(QString,int)" ) { - QString id; - stream >> id; - int mode; - stream >> mode; - if ( view(id) ) - view(id)->setViewMode( (LauncherView::ViewMode)mode ); + QString id; + stream >> id; + int mode; + stream >> mode; + if ( view(id) ) + view(id)->setViewMode( (LauncherView::ViewMode)mode ); } else if ( msg == "setTabBackground(QString,int,QString)" ) { - QString id; - stream >> id; - int mode; - stream >> mode; - QString pixmapOrColor; - stream >> pixmapOrColor; - if ( view(id) ) - view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); - if ( id == "Documents" ) - docLoadingWidget->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); + QString id; + stream >> id; + int mode; + stream >> mode; + QString pixmapOrColor; + stream >> pixmapOrColor; + if ( view(id) ) + view(id)->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); + if ( id == "Documents" ) + docLoadingWidget->setBackgroundType( (LauncherView::BackgroundType)mode, pixmapOrColor ); } else if ( msg == "setTextColor(QString,QString)" ) { - QString id; - stream >> id; - QString color; - stream >> color; - if ( view(id) ) - view(id)->setTextColor( QColor(color) ); - if ( id == "Documents" ) - docLoadingWidget->setTextColor( QColor(color) ); + QString id; + stream >> id; + QString color; + stream >> color; + if ( view(id) ) + view(id)->setTextColor( QColor(color) ); + if ( id == "Documents" ) + docLoadingWidget->setTextColor( QColor(color) ); } else if ( msg == "setFont(QString,QString,int,int,int)" ) { - QString id; - stream >> id; - QString fam; - stream >> fam; - int size; - stream >> size; - int weight; - stream >> weight; - int italic; - stream >> italic; - if ( view(id) ) { - if ( !fam.isEmpty() ) { - view(id)->setViewFont( QFont(fam, size, weight, italic!=0) ); - odebug << "setFont: " << fam << ", " << size << ", " << weight << ", " << italic << "" << oendl; - } else { - view(id)->clearViewFont(); + QString id; + stream >> id; + QString fam; + stream >> fam; + int size; + stream >> size; + int weight; + stream >> weight; + int italic; + stream >> italic; + if ( view(id) ) { + if ( !fam.isEmpty() ) { + view(id)->setViewFont( QFont(fam, size, weight, italic!=0) ); + odebug << "setFont: " << fam << ", " << size << ", " << weight << ", " << italic << "" << oendl; + } else { + view(id)->clearViewFont(); + } } - } }else if ( msg == "setBusyIndicatorType(QString)" ) { QString type; stream >> type; setBusyIndicatorType( type ); }else if ( msg == "home()" ) { if ( isVisibleWindow( static_cast<QWidget*>(parent())->winId() ) ) { if (categoryBar) categoryBar->nextTab(); - }else + }else { static_cast<QWidget*>(parent())->raise(); + } + } else if (msg=="doctabEnabled(int)") { + int id; stream >> id; + odebug << "Doctab enabled " << id << oendl; + reCheckDoctab(id); } } - +void LauncherTabWidget::reCheckDoctab(int how) +{ + if ((bool)how == docTabEnabled) { + /* nothing to do */ + return; + } + if (docLoadingWidget) { + stack->removeWidget(docLoadingWidget); + delete docLoadingWidget; + docLoadingWidget = 0; + } + createDocLoadingWidget(); + { + QCopEnvelope( "QPE/System", "reforceDocuments()" ); + odebug << "Sending doc rescan" << oendl; + } +} //--------------------------------------------------------------------------- Launcher::Launcher() : QMainWindow( 0, "PDA User Interface", QWidget::WStyle_Customize | QWidget::WGroupLeader ) { tabs = 0; tb = 0; Config cfg( "Launcher" ); cfg.setGroup( "DocTab" ); docTabEnabled = cfg.readBoolEntry( "Enable", true ); } void Launcher::createGUI() { setCaption( tr("Launcher") ); // we have a pretty good idea how big we'll be setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); tb = new TaskBar; tabs = new LauncherTabWidget( this ); setCentralWidget( tabs ); ServerInterface::dockWidget( tb, ServerInterface::Bottom ); tb->show(); qApp->installEventFilter( this ); connect( tb, SIGNAL(tabSelected(const QString&)), this, SLOT(showTab(const QString&)) ); connect( tabs, SIGNAL(selected(const QString&)), this, SLOT(viewSelected(const QString&)) ); connect( tabs, SIGNAL(clicked(const AppLnk*)), this, SLOT(select(const AppLnk*))); connect( tabs, SIGNAL(rightPressed(AppLnk*)), this, SLOT(properties(AppLnk*))); #if defined(Q_WS_QWS) && !defined(QT_NO_COP) QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); connect( sysChannel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(systemMessage(const QCString&,const QByteArray&)) ); #endif // all documents QImage img( Resource::loadImage( "DocsIcon" ) ); QPixmap pm; pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); diff --git a/core/launcher/launcher.h b/core/launcher/launcher.h index db6ac54..b741064 100644 --- a/core/launcher/launcher.h +++ b/core/launcher/launcher.h @@ -36,96 +36,97 @@ class QWidgetStack; class TaskBar; class Launcher; class LauncherTabWidget : public QVBox { // can't use a QTabWidget, since it won't let us set the frame style. Q_OBJECT public: LauncherTabWidget( Launcher* parent ); void updateDocs(AppLnkSet* docFolder); void setBusy(bool on); LauncherView *currentView(void); LauncherView* newView( const QString&, const QPixmap& pm, const QString& label ); void deleteView( const QString& ); void setTabViewAppearance( LauncherView *v, Config &cfg ); void setTabAppearance( LauncherTab *, Config &cfg ); LauncherView *view( const QString & ); LauncherView *docView(); void createDocLoadingWidget(); void setLoadingWidgetEnabled( bool v ); void setLoadingProgress( int percent ); LauncherTabBar* categoryBar; void setBusyIndicatorType( const QString& type ); signals: void selected(const QString&); void clicked(const AppLnk*); void rightPressed(AppLnk*); protected slots: void raiseTabWidget(); void tabProperties(); void initLayout(); private slots: void launcherMessage( const QCString &, const QByteArray &); void appMessage( const QCString &, const QByteArray &); void setProgressStyle(); protected: void paletteChange( const QPalette &p ); void styleChange( QStyle & ); + void reCheckDoctab(int how); private: Launcher *launcher; LauncherView *docview; QWidgetStack *stack; LauncherView *docLoadingWidget; QProgressBar *docLoadingWidgetProgress; bool docLoadingWidgetEnabled; bool docTabEnabled; int m_DocumentTabId; }; class Launcher : public QMainWindow, public ServerInterface { Q_OBJECT public: Launcher(); ~Launcher(); // implementing ServerInterface void createGUI(); void destroyGUI(); void typeAdded( const QString& type, const QString& name, const QPixmap& pixmap, const QPixmap& bgPixmap ); void typeRemoved( const QString& type ); void applicationAdded( const QString& type, const AppLnk& doc ); void applicationRemoved( const QString& type, const AppLnk& doc ); void allApplicationsRemoved(); void applicationStateChanged( const QString& name, ApplicationState state ); void documentAdded( const DocLnk& doc ); void documentRemoved( const DocLnk& doc ); void aboutToAddBegin(); void aboutToAddEnd(); void allDocumentsRemoved(); void documentChanged( const DocLnk& oldDoc, const DocLnk& newDoc ); void storageChanged( const QList<FileSystem> & ); void applicationScanningProgress( int percent ); void documentScanningProgress( int percent ); bool requiresApplications() const { return TRUE; } bool requiresDocuments() const; void showLoadingDocs(); void showDocTab(); QStringList idList() const { return ids; } public slots: void viewSelected(const QString&); void showTab(const QString&); diff --git a/core/launcher/launcherview.cpp b/core/launcher/launcherview.cpp index c9efacb..2783423 100644 --- a/core/launcher/launcherview.cpp +++ b/core/launcher/launcherview.cpp @@ -287,99 +287,96 @@ LauncherIconView::LauncherIconView( QWidget* parent, const char* name ) m_EyeCallBack = 0; if (!sm_EyeCache) sm_EyeCache = new QMap<QString,QPixmap>(); sortmeth = Name; hidden.setAutoDelete(TRUE); ike = FALSE; calculateGrid( Bottom ); connect(&m_eyeTimer,SIGNAL(timeout()),this,SLOT(stopEyeTimer())); } LauncherIconView::~LauncherIconView() { odebug << "LauncherIconView::~LauncherIconView()" << oendl; #if 0 // debuggery QListIterator<AppLnk> it(hidden); AppLnk* l; while ((l=it.current())) { ++it; //odebug << "" << l << ": hidden (should remove)" << oendl; } #endif } int LauncherIconView::compare(const AppLnk* a, const AppLnk* b) { switch (sortmeth) { case Name: return a->name().lower().compare(b->name().lower()); case Date: { QFileInfo fa(a->linkFileKnown() ? a->linkFile() : a->file()); QFileInfo fb(b->linkFileKnown() ? b->linkFile() : b->file()); return fa.lastModified().secsTo(fb.lastModified()); } case Type: return a->type().compare(b->type()); } return 0; } void LauncherIconView::setSortMethod( SortMethod m ) { if ( sortmeth != m ) { sortmeth = m; sort(); } } void LauncherIconView::setCategoryFilter( int catfilter, bool resort ) { - Categories cat; - cat.load( categoryFileName() ); - QString str; if ( catfilter == -2 ) cf = 0; else cf = catfilter; hideOrShowItems(resort); } void LauncherIconView::setTypeFilter(const QString& typefilter, bool resort) { tf = QRegExp(typefilter,FALSE,TRUE); hideOrShowItems(resort); } void LauncherIconView::setItemTextPos( ItemTextPos pos ) { calculateGrid( pos ); QIconView::setItemTextPos( pos ); } void LauncherIconView::drawBackground( QPainter *p, const QRect &r ) { if ( !bgPixmap.isNull() ) { p->drawTiledPixmap( r, bgPixmap, QPoint( (r.x() + contentsX()) % bgPixmap.width(), (r.y() + contentsY()) % bgPixmap.height() ) ); } else { p->fillRect( r, bgColor ); } } void LauncherIconView::addCatsAndMimes(AppLnk* app) { // QStringList c = app->categories(); // for (QStringList::ConstIterator cit=c.begin(); cit!=c.end(); ++cit) { // cats.replace(*cit,(void*)1); // } QString maj=app->type(); int sl=maj.find('/'); if (sl>=0) { QString k; k = maj.left(12) == "application/" ? maj : maj.left(sl); mimes.replace(k,(void*)1); } } void LauncherIconView::setBusy(bool on) { #ifdef USE_ANIMATED_BUSY_ICON_OVERLAY @@ -1038,96 +1035,97 @@ void LauncherView::resizeEvent(QResizeEvent *e) void LauncherView::selectionChanged() { QIconViewItem* item = icons->currentItem(); if ( item && item->isSelected() ) { AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); if ( icons->inKeyEvent() ) // not for mouse press emit clicked( appLnk ); item->setSelected(FALSE); } } void LauncherView::returnPressed( QIconViewItem *item ) { if ( item ) { AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); emit clicked( appLnk ); } } void LauncherView::itemClicked( int btn, QIconViewItem *item ) { if ( item ) { AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); if ( btn == LeftButton ) { // Make sure it's the item we execute that gets highlighted icons->setCurrentItem( item ); emit clicked( appLnk ); } item->setSelected(FALSE); } } void LauncherView::itemPressed( int btn, QIconViewItem *item ) { if ( item ) { AppLnk *appLnk = ((LauncherItem *)item)->appLnk(); if ( btn == RightButton ) emit rightPressed( appLnk ); else if ( btn == ShiftButton ) emit rightPressed( appLnk ); item->setSelected(FALSE); } } void LauncherView::removeAllItems() { odebug << "LauncherView::removeAllItems()" << oendl; + if (LauncherIconView::sm_EyeCache) LauncherIconView::sm_EyeCache->clear(); icons->clear(); } bool LauncherView::removeLink(const QString& linkfile) { return icons->removeLink(linkfile); } void LauncherView::addItem(AppLnk* app, bool resort) { icons->addItem(app,resort); } void LauncherView::changeItem(const AppLnk&old,AppLnk*nlink) { icons->changeItem(old,nlink); } void LauncherView::setSortEnabled( bool v ) { icons->setSorting( v ); if ( v ) sort(); } void LauncherView::setUpdatesEnabled( bool u ) { icons->setUpdatesEnabled( u ); } void LauncherView::sort() { icons->sort(); } void LauncherView::paletteChange( const QPalette &p ) { icons->unsetPalette(); QVBox::paletteChange( p ); if ( bgType == Ruled ) setBackgroundType( Ruled, QString::null ); QColorGroup cg = icons->colorGroup(); cg.setColor( QColorGroup::Text, textCol ); icons->setPalette( QPalette(cg,cg,cg) ); } void LauncherView::fontChanged(const QFont&) { diff --git a/core/launcher/server.cpp b/core/launcher/server.cpp index 42186d3..15cd686 100644 --- a/core/launcher/server.cpp +++ b/core/launcher/server.cpp @@ -119,162 +119,162 @@ static Global::Command builtins[] = { }; #ifdef QPE_HAVE_DIRECT_ACCESS extern void readyDirectAccess(QString cardInfo, QString installLocations); extern const char *directAccessQueueFile(); #endif //--------------------------------------------------------------------------- //=========================================================================== Server::Server() : QWidget( 0, 0, WStyle_Tool | WStyle_Customize ), qcopBridge( 0 ), transferServer( 0 ), packageHandler( 0 ), syncDialog( 0 ) { Global::setBuiltinCommands(builtins); tid_xfer = 0; /* ### FIXME ### */ /* tid_today = startTimer(3600*2*1000);*/ last_today_show = QDate::currentDate(); #warning FIXME support TempScreenSaverMode #if 0 tsmMonitor = new TempScreenSaverMode(); connect( tsmMonitor, SIGNAL(forceSuspend()), qApp, SIGNAL(power()) ); #endif serverGui = new Launcher; serverGui->createGUI(); docList = new DocumentList( serverGui ); appLauncher = new AppLauncher(this); connect(appLauncher, SIGNAL(launched(int,const QString&)), this, SLOT(applicationLaunched(int,const QString&)) ); connect(appLauncher, SIGNAL(terminated(int,const QString&)), this, SLOT(applicationTerminated(int,const QString&)) ); connect(appLauncher, SIGNAL(connected(const QString&)), this, SLOT(applicationConnected(const QString&)) ); storage = new StorageInfo( this ); connect( storage, SIGNAL(disksChanged()), this, SLOT(storageChanged()) ); #ifdef QPE_HAVE_DIRECT_ACCESS QCopChannel *desktopChannel = new QCopChannel( "QPE/Desktop", this ); connect( desktopChannel, SIGNAL(received( const QCString &, const QByteArray & )), - this, SLOT(desktopMessage( const QCString &, const QByteArray & )) ); + this, SLOT(desktopMessage( const QCString &, const QByteArray & )) ); #endif // start services startTransferServer(); (void) new IrServer( this ); packageHandler = new PackageHandler( this ); connect(qApp, SIGNAL(activate(const Opie::Core::ODeviceButton*,bool)), this,SLOT(activate(const Opie::Core::ODeviceButton*,bool))); setGeometry( -10, -10, 9, 9 ); QCopChannel *channel = new QCopChannel("QPE/System", this); connect(channel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(systemMsg(const QCString&,const QByteArray&)) ); QCopChannel *tbChannel = new QCopChannel( "QPE/TaskBar", this ); connect( tbChannel, SIGNAL(received(const QCString&,const QByteArray&)), this, SLOT(receiveTaskBar(const QCString&,const QByteArray&)) ); connect( qApp, SIGNAL(prepareForRestart()), this, SLOT(terminateServers()) ); connect( qApp, SIGNAL(timeChanged()), this, SLOT(pokeTimeMonitors()) ); preloadApps(); } void Server::show() { ServerApplication::login(TRUE); QWidget::show(); } Server::~Server() { serverGui->destroyGUI(); delete docList; delete qcopBridge; delete transferServer; delete serverGui; #if 0 delete tsmMonitor; #endif } static bool hasVisibleWindow(const QString& clientname, bool partial) { #ifdef QWS const QList<QWSWindow> &list = qwsServer->clientWindows(); QWSWindow* w; for (QListIterator<QWSWindow> it(list); (w=it.current()); ++it) { - if ( w->client()->identity() == clientname ) { - if ( partial && !w->isFullyObscured() ) - return TRUE; - if ( !partial && !w->isFullyObscured() && !w->isPartiallyObscured() ) { + if ( w->client()->identity() == clientname ) { + if ( partial && !w->isFullyObscured() ) + return TRUE; + if ( !partial && !w->isFullyObscured() && !w->isPartiallyObscured() ) { # if QT_VERSION < 0x030000 - QRect mwr = qt_screen->mapToDevice(qt_maxWindowRect, - QSize(qt_screen->width(),qt_screen->height()) ); + QRect mwr = qt_screen->mapToDevice(qt_maxWindowRect, + QSize(qt_screen->width(),qt_screen->height()) ); # else - QRect mwr = qt_maxWindowRect; + QRect mwr = qt_maxWindowRect; # endif - if ( mwr.contains(w->requested().boundingRect()) ) - return TRUE; - } - } + if ( mwr.contains(w->requested().boundingRect()) ) + return TRUE; + } + } } #endif return FALSE; } void Server::activate(const ODeviceButton* button, bool held) { Global::terminateBuiltin("calibrate"); // No tr OQCopMessage om; if ( held ) { om = button->heldAction(); } else { om = button->pressedAction(); } if ( om.channel() != "ignore" ) om.send(); // A button with no action defined, will return a null ServiceRequest. Don't attempt // to send/do anything with this as it will crash /* ### FIXME */ #if 0 if ( !sr.isNull() ) { QString app = sr.app(); bool vis = hasVisibleWindow(app, app != "qpe"); if ( sr.message() == "raise()" && vis ) { sr.setMessage("nextView()"); } else { // "back door" sr << (int)vis; } sr.send(); } #endif } #ifdef Q_WS_QWS typedef struct KeyOverride { ushort scan_code; QWSServer::KeyMap map; }; static const KeyOverride jp109keys[] = { { 0x03, { Qt::Key_2, '2' , 0x22 , 0xffff } }, @@ -297,355 +297,357 @@ static const KeyOverride jp109keys[] = { { 0x7b, { Qt::Key_Muhenkan, 0xffff, 0xffff, 0xffff } }, { 0x7d, { Qt::Key_yen, 0x00a5, '|' , 0xffff } }, { 0x00, { 0, 0xffff, 0xffff, 0xffff } } }; bool Server::setKeyboardLayout( const QString &kb ) { //quick demo version that can be extended QIntDict<QWSServer::KeyMap> *om = 0; if ( kb == "us101" ) { // No tr om = 0; } else if ( kb == "jp109" ) { om = new QIntDict<QWSServer::KeyMap>(37); const KeyOverride *k = jp109keys; while ( k->scan_code ) { om->insert( k->scan_code, &k->map ); k++; } } QWSServer::setOverrideKeys( om ); return TRUE; } #endif void Server::systemMsg(const QCString &msg, const QByteArray &data) { QDataStream stream( data, IO_ReadOnly ); if ( msg == "securityChanged()" ) { if ( transferServer ) transferServer->authorizeConnections(); if ( qcopBridge ) qcopBridge->authorizeConnections(); #warning FIXME support TempScreenSaverMode #if 0 } else if ( msg == "setTempScreenSaverMode(int,int)" ) { int mode, pid; stream >> mode >> pid; tsmMonitor->setTempMode(mode, pid); #endif } else if ( msg == "linkChanged(QString)" ) { QString link; stream >> link; odebug << "desktop.cpp systemMsg -> linkchanged( " << link << " )" << oendl; docList->linkChanged(link); + } else if (msg =="reforceDocuments()") { + docList->reforceDocuments(); } else if ( msg == "serviceChanged(QString)" ) { MimeType::updateApplications(); } else if ( msg == "mkdir(QString)" ) { QString dir; stream >> dir; if ( !dir.isEmpty() ) mkdir( dir ); } else if ( msg == "rdiffGenSig(QString,QString)" ) { QString baseFile, sigFile; stream >> baseFile >> sigFile; QRsync::generateSignature( baseFile, sigFile ); } else if ( msg == "rdiffGenDiff(QString,QString,QString)" ) { QString baseFile, sigFile, deltaFile; stream >> baseFile >> sigFile >> deltaFile; QRsync::generateDiff( baseFile, sigFile, deltaFile ); } else if ( msg == "rdiffApplyPatch(QString,QString)" ) { QString baseFile, deltaFile; stream >> baseFile >> deltaFile; if ( !QFile::exists( baseFile ) ) { QFile f( baseFile ); f.open( IO_WriteOnly ); f.close(); } QRsync::applyDiff( baseFile, deltaFile ); #ifndef QT_NO_COP QCopEnvelope e( "QPE/Desktop", "patchApplied(QString)" ); e << baseFile; #endif } else if ( msg == "rdiffCleanup()" ) { mkdir( "/tmp/rdiff" ); QDir dir; dir.setPath( "/tmp/rdiff" ); QStringList entries = dir.entryList(); for ( QStringList::Iterator it = entries.begin(); it != entries.end(); ++it ) dir.remove( *it ); } else if ( msg == "sendHandshakeInfo()" ) { QString home = getenv( "HOME" ); #ifndef QT_NO_COP QCopEnvelope e( "QPE/Desktop", "handshakeInfo(QString,bool)" ); e << home; int locked = (int) ServerApplication::screenLocked(); e << locked; #endif } else if ( msg == "sendVersionInfo()" ) { /* * @&$*! Qtopiadesktop relies on the major number * to start with 1. (or 2 as the case of version 2.1 will be) * we need to fake 1.7 to be able * to sync with Qtopiadesktop 1.7. * We'll send it Opie's version in the platform string for now, * until such time when QD gets rewritten correctly. */ QCopEnvelope e( "QPE/Desktop", "versionInfo(QString,QString)" ); QString opiename = "Opie "+QString(QPE_VERSION); QString QDVersion="1.7"; e << QDVersion << opiename; } else if ( msg == "sendCardInfo()" ) { #ifndef QT_NO_COP QCopEnvelope e( "QPE/Desktop", "cardInfo(QString)" ); #endif storage->update(); const QList<FileSystem> &fs = storage->fileSystems(); QListIterator<FileSystem> it ( fs ); QString s; QString homeDir = getenv("HOME"); QString homeFs, homeFsPath; for ( ; it.current(); ++it ) { int k4 = (*it)->blockSize()/256; if ( (*it)->isRemovable() ) { s += (*it)->name() + "=" + (*it)->path() + "/Documents " // No tr + QString::number( (*it)->availBlocks() * k4/4 ) + "K " + (*it)->options() + ";"; } else if ( homeDir.contains( (*it)->path() ) && (*it)->path().length() > homeFsPath.length() ) { homeFsPath = (*it)->path(); homeFs = (*it)->name() + "=" + homeDir + "/Documents " // No tr + QString::number( (*it)->availBlocks() * k4/4 ) + "K " + (*it)->options() + ";"; } } if ( !homeFs.isEmpty() ) s += homeFs; #ifndef QT_NO_COP e << s; #endif } else if ( msg == "sendInstallLocations()" ) { #ifndef QT_NO_COP - QCopEnvelope e( "QPE/Desktop", "installLocations(QString)" ); - e << installLocationsString(); + QCopEnvelope e( "QPE/Desktop", "installLocations(QString)" ); + e << installLocationsString(); #endif } else if ( msg == "sendSyncDate(QString)" ) { QString app; stream >> app; Config cfg( "qpe" ); cfg.setGroup("SyncDate"); #ifndef QT_NO_COP QCopEnvelope e( "QPE/Desktop", "syncDate(QString,QString)" ); e << app << cfg.readEntry( app ); #endif //odebug << "QPE/System sendSyncDate for " << app.latin1() << ": response " // << cfg.readEntry( app ).latin1() << oendl; } else if ( msg == "setSyncDate(QString,QString)" ) { QString app, date; stream >> app >> date; Config cfg( "qpe" ); cfg.setGroup("SyncDate"); cfg.writeEntry( app, date ); //odebug << "setSyncDate(QString,QString) " << app << " " << date << "" << oendl; } else if ( msg == "startSync(QString)" ) { QString what; stream >> what; delete syncDialog; syncDialog = new SyncDialog( this, what ); syncDialog->show(); connect( syncDialog, SIGNAL(cancel()), SLOT(cancelSync()) ); } else if ( msg == "stopSync()") { delete syncDialog; syncDialog = 0; } else if (msg == "restoreDone(QString)") { docList->restoreDone(); } else if ( msg == "getAllDocLinks()" ) { docList->sendAllDocLinks(); } #ifdef QPE_HAVE_DIRECT_ACCESS else if ( msg == "prepareDirectAccess()" ) { - prepareDirectAccess(); + prepareDirectAccess(); } else if ( msg == "postDirectAccess()" ) { - postDirectAccess(); + postDirectAccess(); } #endif #ifdef Q_WS_QWS else if ( msg == "setMouseProto(QString)" ) { QString mice; stream >> mice; setenv("QWS_MOUSE_PROTO",mice.latin1(),1); qwsServer->openMouse(); } else if ( msg == "setKeyboard(QString)" ) { QString kb; stream >> kb; setenv("QWS_KEYBOARD",kb.latin1(),1); qwsServer->openKeyboard(); } else if ( msg == "setKeyboardAutoRepeat(int,int)" ) { int delay, period; stream >> delay >> period; qwsSetKeyboardAutoRepeat( delay, period ); Config cfg( "qpe" ); cfg.setGroup("Keyboard"); cfg.writeEntry( "RepeatDelay", delay ); cfg.writeEntry( "RepeatPeriod", period ); } else if ( msg == "setKeyboardLayout(QString)" ) { QString kb; stream >> kb; setKeyboardLayout( kb ); Config cfg( "qpe" ); cfg.setGroup("Keyboard"); cfg.writeEntry( "Layout", kb ); } else if ( msg == "autoStart(QString)" ) { QString appName; stream >> appName; Config cfg( "autostart" ); cfg.setGroup( "AutoStart" ); if ( appName.compare("clear") == 0){ cfg.writeEntry("Apps", ""); } } else if ( msg == "autoStart(QString,QString)" ) { QString modifier, appName; stream >> modifier >> appName; Config cfg( "autostart" ); cfg.setGroup( "AutoStart" ); if ( modifier.compare("add") == 0 ){ // only add if appname is entered if (!appName.isEmpty()) { cfg.writeEntry("Apps", appName); } } else if (modifier.compare("remove") == 0 ) { // need to change for multiple entries // actually remove is right now simular to clear, but in future there // should be multiple apps in autostart possible. QString checkName; checkName = cfg.readEntry("Apps", ""); if (checkName == appName) { cfg.writeEntry("Apps", ""); } } // case the autostart feature should be delayed } else if ( msg == "autoStart(QString,QString,QString)") { QString modifier, appName, delay; stream >> modifier >> appName >> delay; Config cfg( "autostart" ); cfg.setGroup( "AutoStart" ); if ( modifier.compare("add") == 0 ){ // only add it appname is entered if (!appName.isEmpty()) { cfg.writeEntry("Apps", appName); cfg.writeEntry("Delay", delay); } } } #endif } QString Server::cardInfoString() { storage->update(); const QList<FileSystem> &fs = storage->fileSystems(); QListIterator<FileSystem> it ( fs ); QString s; QString homeDir = getenv("HOME"); QString homeFs, homeFsPath; for ( ; it.current(); ++it ) { - int k4 = (*it)->blockSize()/256; - if ( (*it)->isRemovable() ) { - s += (*it)->name() + "=" + (*it)->path() + "/Documents " // No tr - + QString::number( (*it)->availBlocks() * k4/4 ) - + "K " + (*it)->options() + ";"; - } else if ( homeDir.contains( (*it)->path() ) && - (*it)->path().length() > homeFsPath.length() ) { - homeFsPath = (*it)->path(); - homeFs = - (*it)->name() + "=" + homeDir + "/Documents " // No tr - + QString::number( (*it)->availBlocks() * k4/4 ) - + "K " + (*it)->options() + ";"; - } + int k4 = (*it)->blockSize()/256; + if ( (*it)->isRemovable() ) { + s += (*it)->name() + "=" + (*it)->path() + "/Documents " // No tr + + QString::number( (*it)->availBlocks() * k4/4 ) + + "K " + (*it)->options() + ";"; + } else if ( homeDir.contains( (*it)->path() ) && + (*it)->path().length() > homeFsPath.length() ) { + homeFsPath = (*it)->path(); + homeFs = + (*it)->name() + "=" + homeDir + "/Documents " // No tr + + QString::number( (*it)->availBlocks() * k4/4 ) + + "K " + (*it)->options() + ";"; + } } if ( !homeFs.isEmpty() ) - s += homeFs; + s += homeFs; return s; } QString Server::installLocationsString() { storage->update(); const QList<FileSystem> &fs = storage->fileSystems(); QListIterator<FileSystem> it ( fs ); QString s; QString homeDir = getenv("HOME"); QString homeFs, homeFsPath; for ( ; it.current(); ++it ) { - int k4 = (*it)->blockSize()/256; - if ( (*it)->isRemovable() ) { - s += (*it)->name() + "=" + (*it)->path() + " " // No tr - + QString::number( (*it)->availBlocks() * k4/4 ) - + "K " + (*it)->options() + ";"; - } else if ( homeDir.contains( (*it)->path() ) && - (*it)->path().length() > homeFsPath.length() ) { - homeFsPath = (*it)->path(); - homeFs = - (*it)->name() + "=" + homeDir + " " // No tr - + QString::number( (*it)->availBlocks() * k4/4 ) - + "K " + (*it)->options() + ";"; - } + int k4 = (*it)->blockSize()/256; + if ( (*it)->isRemovable() ) { + s += (*it)->name() + "=" + (*it)->path() + " " // No tr + + QString::number( (*it)->availBlocks() * k4/4 ) + + "K " + (*it)->options() + ";"; + } else if ( homeDir.contains( (*it)->path() ) && + (*it)->path().length() > homeFsPath.length() ) { + homeFsPath = (*it)->path(); + homeFs = + (*it)->name() + "=" + homeDir + " " // No tr + + QString::number( (*it)->availBlocks() * k4/4 ) + + "K " + (*it)->options() + ";"; + } } if ( !homeFs.isEmpty() ) - s = homeFs + s; + s = homeFs + s; return s; } void Server::receiveTaskBar(const QCString &msg, const QByteArray &data) { QDataStream stream( data, IO_ReadOnly ); if ( msg == "reloadApps()" ) { docList->reloadAppLnks(); } else if ( msg == "soundAlarm()" ) { ServerApplication::soundAlarm(); } else if ( msg == "setLed(int,bool)" ) { int led, status; stream >> led >> status; QValueList <OLed> ll = ODevice::inst ( )-> ledList ( ); if ( ll. count ( )) { OLed l = ll. contains ( Led_Mail ) ? Led_Mail : ll [0]; bool canblink = ODevice::inst ( )-> ledStateList ( l ). contains ( Led_BlinkSlow ); ODevice::inst ( )-> setLedState ( l, status ? ( canblink ? Led_BlinkSlow : Led_On ) : Led_Off ); } } } void Server::cancelSync() { #ifndef QT_NO_COP QCopEnvelope e( "QPE/Desktop", "cancelSync()" ); #endif delete syncDialog; syncDialog = 0; } bool Server::mkdir(const QString &localPath) { QDir fullDir(localPath); if (fullDir.exists()) return true; // at this point the directory doesn't exist // go through the directory tree and start creating the direcotories // that don't exist; if we can't create the directories, return false QString dirSeps = "/"; int dirIndex = localPath.find(dirSeps); QString checkedPath; @@ -779,206 +781,206 @@ void Server::applicationTerminated(int pid, const QString &app) serverGui->applicationStateChanged( app, ServerInterface::Terminated ); #if 0 tsmMonitor->applicationTerminated( pid ); #else Q_UNUSED( pid ) #endif } void Server::applicationConnected(const QString &app) { serverGui->applicationStateChanged( app, ServerInterface::Running ); } void Server::storageChanged() { system( "opie-update-symlinks" ); serverGui->storageChanged( storage->fileSystems() ); docList->storageChanged(); } void Server::preloadApps() { Config cfg("Launcher"); cfg.setGroup("Preload"); QStringList apps = cfg.readListEntry("Apps",','); for (QStringList::ConstIterator it=apps.begin(); it!=apps.end(); ++it) { #ifndef QT_NO_COP QCopEnvelope e("QPE/Application/"+(*it).local8Bit(), "enablePreload()"); #endif } } // This is only called if QPE_HAVE_DIRECT_ACCESS is defined void Server::prepareDirectAccess() { qDebug( "Server::prepareDirectAccess()" ); // Put up a pretty dialog syncDialog = new SyncDialog( this, tr("USB Lock") ); syncDialog->show(); // Prevent the PDA from acting as a PDA terminateServers(); // suspend the mtab monitor #ifndef QT_NO_COP { - QCopEnvelope e( "QPE/Stabmon", "suspendMonitor()" ); + QCopEnvelope e( "QPE/Stabmon", "suspendMonitor()" ); } #endif // send out a flush message // once flushes are done call runDirectAccess() // We just count the number of apps and set a timer. // Either the timer expires or the correct number of apps responds. // Note: quicklauncher isn't in the runningApps list but it responds // to the flush so we start the counter at 1 pendingFlushes = 1; directAccessRun = FALSE; for ( QMap<int,QString>::ConstIterator it = - appLauncher->runningApplications().begin(); - it != appLauncher->runningApplications().end(); - ++it ) { - pendingFlushes++; + appLauncher->runningApplications().begin(); + it != appLauncher->runningApplications().end(); + ++it ) { + pendingFlushes++; } #ifndef QT_NO_COP QCopEnvelope e1( "QPE/System", "flush()" ); #endif QTimer::singleShot( 10000, this, SLOT(runDirectAccess()) ); #warning FIXME support TempScreenSaverMode #if 0 QPEApplication::setTempScreenSaverMode(QPEApplication::DisableSuspend); #endif } // This is only connected if QPE_HAVE_DIRECT_ACCESS is defined // It fakes the presence of Qtopia Desktop void Server::desktopMessage( const QCString &message, const QByteArray &data ) { QDataStream stream( data, IO_ReadOnly ); if ( message == "flushDone(QString)" ) { - QString app; - stream >> app; - qDebug( "flushDone from %s", app.latin1() ); - if ( --pendingFlushes == 0 ) { - qDebug( "pendingFlushes == 0, all the apps responded" ); - runDirectAccess(); - } + QString app; + stream >> app; + qDebug( "flushDone from %s", app.latin1() ); + if ( --pendingFlushes == 0 ) { + qDebug( "pendingFlushes == 0, all the apps responded" ); + runDirectAccess(); + } } else if ( message == "installStarted(QString)" ) { - QString package; - stream >> package; - qDebug( "\tInstall Started for package %s", package.latin1() ); + QString package; + stream >> package; + qDebug( "\tInstall Started for package %s", package.latin1() ); } else if ( message == "installStep(QString)" ) { - QString step; - stream >> step; - qDebug( "\tInstall Step %s", step.latin1() ); + QString step; + stream >> step; + qDebug( "\tInstall Step %s", step.latin1() ); } else if ( message == "installDone(QString)" ) { - QString package; - stream >> package; - qDebug( "\tInstall Finished for package %s", package.latin1() ); + QString package; + stream >> package; + qDebug( "\tInstall Finished for package %s", package.latin1() ); } else if ( message == "installFailed(QString,int,QString)" ) { - QString package, error; - int status; - stream >> package >> status >> error; - qDebug( "\tInstall Failed for package %s with error code %d and error message %s", - package.latin1(), status, error.latin1() ); + QString package, error; + int status; + stream >> package >> status >> error; + qDebug( "\tInstall Failed for package %s with error code %d and error message %s", + package.latin1(), status, error.latin1() ); } else if ( message == "removeStarted(QString)" ) { - QString package; - stream >> package; - qDebug( "\tRemove Started for package %s", package.latin1() ); + QString package; + stream >> package; + qDebug( "\tRemove Started for package %s", package.latin1() ); } else if ( message == "removeDone(QString)" ) { - QString package; - stream >> package; - qDebug( "\tRemove Finished for package %s", package.latin1() ); + QString package; + stream >> package; + qDebug( "\tRemove Finished for package %s", package.latin1() ); } else if ( message == "removeFailed(QString)" ) { - QString package; - stream >> package; - qDebug( "\tRemove Failed for package %s", package.latin1() ); + QString package; + stream >> package; + qDebug( "\tRemove Failed for package %s", package.latin1() ); } if ( qrr && qrr->waitingForMessages ) - qrr->desktopMessage( message, data ); + qrr->desktopMessage( message, data ); } // This is only connected if QPE_HAVE_DIRECT_ACCESS is defined void Server::runDirectAccess() { #ifdef QPE_HAVE_DIRECT_ACCESS // The timer must have fired after all the apps responded // with flushDone(). Just ignore it. if ( directAccessRun ) - return; + return; directAccessRun = TRUE; ::readyDirectAccess(cardInfoString(), installLocationsString()); #endif } // This is only called if QPE_HAVE_DIRECT_ACCESS is defined void Server::postDirectAccess() { #ifdef QPE_HAVE_DIRECT_ACCESS qDebug( "Server::postDirectAccess()" ); // Categories may have changed QCopEnvelope e1( "QPE/System", "categoriesChanged()" ); // Apps need to reload their data QCopEnvelope e2( "QPE/System", "reload()" ); // Reload DocLinks docList->storageChanged(); // Restart the PDA server stuff startTransferServer(); // restart the mtab monitor #ifndef QT_NO_COP { - QCopEnvelope e( "QPE/Stabmon", "restartMonitor()" ); + QCopEnvelope e( "QPE/Stabmon", "restartMonitor()" ); } #endif // Process queued requests const char *queueFile = ::directAccessQueueFile(); QFile *file = new QFile( queueFile ); if ( !file->exists() ) { - delete file; - // Get rid of the dialog - if ( syncDialog ) { - delete syncDialog; - syncDialog = 0; - } + delete file; + // Get rid of the dialog + if ( syncDialog ) { + delete syncDialog; + syncDialog = 0; + } #warning FIXME support TempScreenSaverMode #if 0 - QPEApplication::setTempScreenSaverMode(QPEApplication::Enable); + QPEApplication::setTempScreenSaverMode(QPEApplication::Enable); #endif } else { - qrr = new QueuedRequestRunner( file, syncDialog ); - connect( qrr, SIGNAL(finished()), - this, SLOT(finishedQueuedRequests()) ); - QTimer::singleShot( 100, qrr, SLOT(process()) ); - // qrr will remove the sync dialog later + qrr = new QueuedRequestRunner( file, syncDialog ); + connect( qrr, SIGNAL(finished()), + this, SLOT(finishedQueuedRequests()) ); + QTimer::singleShot( 100, qrr, SLOT(process()) ); + // qrr will remove the sync dialog later } #endif } void Server::finishedQueuedRequests() { if ( qrr->readyToDelete ) { - delete qrr; - qrr = 0; - // Get rid of the dialog - if ( syncDialog ) { - delete syncDialog; - syncDialog = 0; - } + delete qrr; + qrr = 0; + // Get rid of the dialog + if ( syncDialog ) { + delete syncDialog; + syncDialog = 0; + } #warning FIXME support TempScreenSaverMode #if 0 - QPEApplication::setTempScreenSaverMode(QPEApplication::Enable); + QPEApplication::setTempScreenSaverMode(QPEApplication::Enable); #endif } else { - qrr->readyToDelete = TRUE; - QTimer::singleShot( 0, this, SLOT(finishedQueuedRequests()) ); + qrr->readyToDelete = TRUE; + QTimer::singleShot( 0, this, SLOT(finishedQueuedRequests()) ); } } |