author | alwin <alwin> | 2004-02-24 02:47:03 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-02-24 02:47:03 (UTC) |
commit | f196130d43642f2397ddadeed72e3ea062cda281 (patch) (unidiff) | |
tree | 1916d2e66a8ea4fb149397b71888057c62156091 | |
parent | 4baf741237a4c4575b3efe0bff6c4e143902b7ec (diff) | |
download | opie-f196130d43642f2397ddadeed72e3ea062cda281.zip opie-f196130d43642f2397ddadeed72e3ea062cda281.tar.gz opie-f196130d43642f2397ddadeed72e3ea062cda281.tar.bz2 |
- check now for the storage media flag "check =" in DocumentListPrivate::appendDocpath
- fixed a possible segmentation fault in DocumentListPrivate::nextFile
-rw-r--r-- | core/launcher/documentlist.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/core/launcher/documentlist.cpp b/core/launcher/documentlist.cpp index 39dc7c9..63f853e 100644 --- a/core/launcher/documentlist.cpp +++ b/core/launcher/documentlist.cpp | |||
@@ -412,64 +412,68 @@ void DocumentList::sendAllDocLinks() | |||
412 | 412 | ||
413 | DocumentListPrivate::DocumentListPrivate( ServerInterface *gui ) | 413 | DocumentListPrivate::DocumentListPrivate( ServerInterface *gui ) |
414 | { | 414 | { |
415 | storage = new StorageInfo( this ); | 415 | storage = new StorageInfo( this ); |
416 | serverGui = gui; | 416 | serverGui = gui; |
417 | if ( serverGui ) { | 417 | if ( serverGui ) { |
418 | sendAppLnks = serverGui->requiresApplications(); | 418 | sendAppLnks = serverGui->requiresApplications(); |
419 | sendDocLnks = serverGui->requiresDocuments(); | 419 | sendDocLnks = serverGui->requiresDocuments(); |
420 | } else { | 420 | } else { |
421 | sendAppLnks = false; | 421 | sendAppLnks = false; |
422 | sendDocLnks = false; | 422 | sendDocLnks = false; |
423 | } | 423 | } |
424 | for ( int i = 0; i < MAX_SEARCH_DEPTH; i++ ) { | 424 | for ( int i = 0; i < MAX_SEARCH_DEPTH; i++ ) { |
425 | listDirs[i] = 0; | 425 | listDirs[i] = 0; |
426 | lists[i] = 0; | 426 | lists[i] = 0; |
427 | listPositions[i] = 0; | 427 | listPositions[i] = 0; |
428 | } | 428 | } |
429 | initialize(); | 429 | initialize(); |
430 | tid = 0; | 430 | tid = 0; |
431 | } | 431 | } |
432 | 432 | ||
433 | void DocumentListPrivate::appendDocpath(FileSystem*fs) | 433 | void DocumentListPrivate::appendDocpath(FileSystem*fs) |
434 | { | 434 | { |
435 | QDir defPath(fs->path()+"/Documents"); | 435 | QDir defPath(fs->path()+"/Documents"); |
436 | QFileInfo f(fs->path()+"/.opiestorage.cf"); | 436 | QFileInfo f(fs->path()+"/.opiestorage.cf"); |
437 | if (!f.exists()) { | 437 | if (!f.exists()) { |
438 | Mediadlg dlg(fs); | 438 | Mediadlg dlg(fs); |
439 | if (QDialog::Accepted != QPEApplication::execDialog( &dlg )) { | 439 | if (QDialog::Accepted != QPEApplication::execDialog( &dlg )) { |
440 | return; | 440 | return; |
441 | } | 441 | } |
442 | } | 442 | } |
443 | Config conf(f.filePath(), Config::File ); | 443 | Config conf(f.filePath(), Config::File ); |
444 | conf.setGroup("main"); | ||
445 | if (!conf.readBoolEntry("check",false)) { | ||
446 | return; | ||
447 | } | ||
444 | conf.setGroup("subdirs"); | 448 | conf.setGroup("subdirs"); |
445 | bool read_all = conf.readBoolEntry("wholemedia",true); | 449 | bool read_all = conf.readBoolEntry("wholemedia",true); |
446 | if (read_all) { | 450 | if (read_all) { |
447 | docPaths+=fs->path(); | 451 | docPaths+=fs->path(); |
448 | return; | 452 | return; |
449 | } | 453 | } |
450 | QStringList subDirs = conf.readListEntry("subdirs",':'); | 454 | QStringList subDirs = conf.readListEntry("subdirs",':'); |
451 | if (subDirs.isEmpty()) { | 455 | if (subDirs.isEmpty()) { |
452 | if (defPath.exists()) { | 456 | if (defPath.exists()) { |
453 | docPaths+=defPath.path(); | 457 | docPaths+=defPath.path(); |
454 | } | 458 | } |
455 | return; | 459 | return; |
456 | } | 460 | } |
457 | for (unsigned c = 0; c < subDirs.count();++c) { | 461 | for (unsigned c = 0; c < subDirs.count();++c) { |
458 | QDir docDir(QString(fs->path()+"/"+subDirs[c])); | 462 | QDir docDir(QString(fs->path()+"/"+subDirs[c])); |
459 | if (docDir.exists()) { | 463 | if (docDir.exists()) { |
460 | docPaths+=docDir.path(); | 464 | docPaths+=docDir.path(); |
461 | } | 465 | } |
462 | } | 466 | } |
463 | } | 467 | } |
464 | 468 | ||
465 | void DocumentListPrivate::initialize() | 469 | void DocumentListPrivate::initialize() |
466 | { | 470 | { |
467 | // Reset | 471 | // Reset |
468 | dls.clear(); | 472 | dls.clear(); |
469 | docPaths.clear(); | 473 | docPaths.clear(); |
470 | reference.clear(); | 474 | reference.clear(); |
471 | 475 | ||
472 | QDir docDir( QPEApplication::documentDir() ); | 476 | QDir docDir( QPEApplication::documentDir() ); |
473 | if ( docDir.exists() ) | 477 | if ( docDir.exists() ) |
474 | docPaths += QPEApplication::documentDir(); | 478 | docPaths += QPEApplication::documentDir(); |
475 | int i = 1; | 479 | int i = 1; |
@@ -531,64 +535,67 @@ void DocumentListPrivate::estimatedPercentScanned() | |||
531 | } | 535 | } |
532 | } | 536 | } |
533 | 537 | ||
534 | // qDebug( "overallProgress: %f", overallProgress ); | 538 | // qDebug( "overallProgress: %f", overallProgress ); |
535 | 539 | ||
536 | if ( serverGui ) | 540 | if ( serverGui ) |
537 | serverGui->documentScanningProgress( (int)overallProgress ); | 541 | serverGui->documentScanningProgress( (int)overallProgress ); |
538 | } | 542 | } |
539 | 543 | ||
540 | 544 | ||
541 | const QString DocumentListPrivate::nextFile() | 545 | const QString DocumentListPrivate::nextFile() |
542 | { | 546 | { |
543 | while ( TRUE ) { | 547 | while ( TRUE ) { |
544 | while ( searchDepth < 0 ) { | 548 | while ( searchDepth < 0 ) { |
545 | // go to next base path | 549 | // go to next base path |
546 | if ( docPathsSearched >= docPaths.count() ) { | 550 | if ( docPathsSearched >= docPaths.count() ) { |
547 | // end of base paths | 551 | // end of base paths |
548 | return QString::null; | 552 | return QString::null; |
549 | } else { | 553 | } else { |
550 | QDir dir( docPaths[docPathsSearched] ); | 554 | QDir dir( docPaths[docPathsSearched] ); |
551 | // qDebug("now using base path: %s", docPaths[docPathsSearched].latin1() ); | 555 | // qDebug("now using base path: %s", docPaths[docPathsSearched].latin1() ); |
552 | docPathsSearched++; | 556 | docPathsSearched++; |
553 | if ( !dir.exists( ".Qtopia-ignore" ) ) { | 557 | if ( !dir.exists( ".Qtopia-ignore" ) ) { |
554 | listDirs[0] = new QDir( dir ); | 558 | listDirs[0] = new QDir( dir ); |
555 | lists[0] = listDirs[0]->entryInfoList(); | 559 | lists[0] = listDirs[0]->entryInfoList(); |
556 | listPositions[0] = 0; | 560 | listPositions[0] = 0; |
557 | searchDepth = 0; | 561 | searchDepth = 0; |
558 | } | 562 | } |
559 | } | 563 | } |
560 | } | 564 | } |
561 | 565 | ||
562 | const QFileInfoList *fil = lists[searchDepth]; | 566 | const QFileInfoList *fil = lists[searchDepth]; |
567 | if (!fil) { | ||
568 | return QString::null; | ||
569 | } | ||
563 | QFileInfoList *fl = (QFileInfoList *)fil; | 570 | QFileInfoList *fl = (QFileInfoList *)fil; |
564 | unsigned int pos = listPositions[searchDepth]; | 571 | unsigned int pos = listPositions[searchDepth]; |
565 | 572 | ||
566 | if ( pos >= fl->count() ) { | 573 | if ( pos >= fl->count() ) { |
567 | // go up a depth | 574 | // go up a depth |
568 | delete listDirs[searchDepth]; | 575 | delete listDirs[searchDepth]; |
569 | listDirs[searchDepth] = 0; | 576 | listDirs[searchDepth] = 0; |
570 | lists[searchDepth] = 0; | 577 | lists[searchDepth] = 0; |
571 | listPositions[searchDepth] = 0; | 578 | listPositions[searchDepth] = 0; |
572 | searchDepth--; | 579 | searchDepth--; |
573 | } else { | 580 | } else { |
574 | const QFileInfo *fi = fl->at(pos); | 581 | const QFileInfo *fi = fl->at(pos); |
575 | listPositions[searchDepth]++; | 582 | listPositions[searchDepth]++; |
576 | QString bn = fi->fileName(); | 583 | QString bn = fi->fileName(); |
577 | if ( bn[0] != '.' ) { | 584 | if ( bn[0] != '.' ) { |
578 | if ( fi->isDir() ) { | 585 | if ( fi->isDir() ) { |
579 | if ( bn != "CVS" && bn != "Qtopia" && bn != "QtPalmtop" ) { | 586 | if ( bn != "CVS" && bn != "Qtopia" && bn != "QtPalmtop" ) { |
580 | // go down a depth | 587 | // go down a depth |
581 | QDir dir( fi->filePath() ); | 588 | QDir dir( fi->filePath() ); |
582 | // qDebug("now going in to path: %s", bn.latin1() ); | 589 | // qDebug("now going in to path: %s", bn.latin1() ); |
583 | if ( !dir.exists( ".Qtopia-ignore" ) ) { | 590 | if ( !dir.exists( ".Qtopia-ignore" ) ) { |
584 | if ( searchDepth < MAX_SEARCH_DEPTH - 1) { | 591 | if ( searchDepth < MAX_SEARCH_DEPTH - 1) { |
585 | searchDepth++; | 592 | searchDepth++; |
586 | listDirs[searchDepth] = new QDir( dir ); | 593 | listDirs[searchDepth] = new QDir( dir ); |
587 | lists[searchDepth] = listDirs[searchDepth]->entryInfoList(); | 594 | lists[searchDepth] = listDirs[searchDepth]->entryInfoList(); |
588 | listPositions[searchDepth] = 0; | 595 | listPositions[searchDepth] = 0; |
589 | } | 596 | } |
590 | } | 597 | } |
591 | } | 598 | } |
592 | } else { | 599 | } else { |
593 | estimatedPercentScanned(); | 600 | estimatedPercentScanned(); |
594 | return fl->at(pos)->filePath(); | 601 | return fl->at(pos)->filePath(); |