summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launcher.cpp84
-rw-r--r--core/launcher/mediummountgui.cpp10
2 files changed, 66 insertions, 28 deletions
diff --git a/core/launcher/launcher.cpp b/core/launcher/launcher.cpp
index 1c38a05..cf1a3c8 100644
--- a/core/launcher/launcher.cpp
+++ b/core/launcher/launcher.cpp
@@ -73,12 +73,43 @@
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 {
80 QStringList configToMime( Config *cfg ){
81 QStringList mimes;
82 bool tmpMime;
83 cfg->setGroup("mimetypes" );
84 tmpMime = cfg->readBoolEntry("all" ,false);
85 if( tmpMime ){
86 mimes << QString::null;
87 return mimes;
88 }else{
89 tmpMime = cfg->readBoolEntry("audio", true );
90 if(tmpMime )
91 mimes.append("audio//*" );
92
93 tmpMime = cfg->readBoolEntry("image", true );
94 if(tmpMime )
95 mimes.append("image//*" );
96
97 tmpMime = cfg->readBoolEntry("text", true );
98 if(tmpMime )
99 mimes.append("text//*");
100
101 tmpMime = cfg->readBoolEntry("video", true );
102 if(tmpMime )
103 mimes.append("video//*" );
104 }
105 return mimes;
106 }
107
108}
109
79 110
80CategoryTabWidget::CategoryTabWidget( QWidget* parent ) : 111CategoryTabWidget::CategoryTabWidget( QWidget* parent ) :
81 QVBox( parent ) 112 QVBox( parent )
82{ 113{
83 categoryBar = 0; 114 categoryBar = 0;
84 stack = 0; 115 stack = 0;
@@ -423,14 +454,14 @@ Launcher::Launcher( QWidget* parent, const char* name, WFlags fl )
423 // we have a pretty good idea how big we'll be 454 // we have a pretty good idea how big we'll be
424 setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() ); 455 setGeometry( 0, 0, qApp->desktop()->width(), qApp->desktop()->height() );
425 456
426 tabs = 0; 457 tabs = 0;
427 rootFolder = 0; 458 rootFolder = 0;
428 docsFolder = 0; 459 docsFolder = 0;
429 int stamp = uidgen.generate(); 460 int stamp = uidgen.generate(); // this is our timestamp to see which devices we know
430 uidgen.store( stamp ); 461 //uidgen.store( stamp );
431 m_timeStamp = QString::number( stamp ); 462 m_timeStamp = QString::number( stamp );
432 463
433 tabs = new CategoryTabWidget( this ); 464 tabs = new CategoryTabWidget( this );
434 tabs->setMaximumWidth( qApp->desktop()->width() ); 465 tabs->setMaximumWidth( qApp->desktop()->width() );
435 setCentralWidget( tabs ); 466 setCentralWidget( tabs );
436 467
@@ -508,59 +539,64 @@ void Launcher::loadDocs() // ok here comes a hack belonging to Global::
508{ 539{
509 qWarning("loading Documents" ); 540 qWarning("loading Documents" );
510 qWarning("The currentTimeStamp is: %s", m_timeStamp.latin1() ); 541 qWarning("The currentTimeStamp is: %s", m_timeStamp.latin1() );
511 delete docsFolder; 542 delete docsFolder;
512 docsFolder = new DocLnkSet; 543 docsFolder = new DocLnkSet;
513 qWarning("new DocLnkSet" ); 544 qWarning("new DocLnkSet" );
545 DocLnkSet *tmp = 0;
546 QString home = QString(getenv("HOME")) + "/Documents";
547 tmp = new DocLnkSet( home , QString::null);
548 docsFolder->appendFrom( *tmp );
549 delete tmp;
514 // find out wich filesystems are new in this round 550 // find out wich filesystems are new in this round
515 // We will do this by having a timestamp inside each mountpoint 551 // We will do this by having a timestamp inside each mountpoint
516 // if the current timestamp doesn't match this is a new file system and 552 // if the current timestamp doesn't match this is a new file system and
517 // come up with our MediumMountGui :) let the hacking begin 553 // come up with our MediumMountGui :) let the hacking begin
518 int stamp = uidgen.generate(); 554 int stamp = uidgen.generate();
519 555
520 QString newStamp = QString::number( stamp ); 556 QString newStamp = QString::number( stamp ); // generates newtime Stamp
521 qWarning("new time stamp is: %s", newStamp.latin1() );
522 StorageInfo storage; 557 StorageInfo storage;
523 const QList<FileSystem> &fileSystems = storage.fileSystems(); 558 const QList<FileSystem> &fileSystems = storage.fileSystems();
524 qWarning("QList<FileSystem>" );
525 QListIterator<FileSystem> it ( fileSystems ); 559 QListIterator<FileSystem> it ( fileSystems );
526 qWarning("iterator initiliazed" );
527 for ( ; it.current(); ++it ) { 560 for ( ; it.current(); ++it ) {
528 qWarning("inside for loop" );
529 qWarning("checking device %s", (*it)->path().latin1() );
530 if ( (*it)->isRemovable() ) { // let's find out if we should search on it 561 if ( (*it)->isRemovable() ) { // let's find out if we should search on it
531 qWarning("%s is removeable", (*it)->path().latin1() ); 562 qWarning("%s is removeable", (*it)->path().latin1() );
532 OConfig cfg( (*it)->path() + "/.opiestorage.cf"); 563 OConfig cfg( (*it)->path() + "/.opiestorage.cf");
533 cfg.setGroup("main"); 564 cfg.setGroup("main");
534 QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() ); 565 QString stamp = cfg.readEntry("timestamp", QDateTime::currentDateTime().toString() );
535 if( stamp == m_timeStamp ){ // ok we know this card 566 if( stamp == m_timeStamp ){ // ok we know this card
536 qWarning("time stamp match" ); 567 cfg.writeEntry("timestamp", newStamp ); //just write a new timestamp
537 cfg.writeEntry("timestamp", newStamp );
538 // we need to scan the list now. Hopefully the cache will be there 568 // we need to scan the list now. Hopefully the cache will be there
539 }else{ // come up with the gui 569 // read the mimetypes from the config and search for documents
540 qWarning("time stamp doesn't match" ); 570 QStringList mimetypes = configToMime( &cfg);
571 tmp = new DocLnkSet( (*it)->path(), mimetypes.join(";") );
572 docsFolder->appendFrom( *tmp );
573 delete tmp;
574
575 }else{ // come up with the gui cause this a new card
541 MediumMountGui medium((*it)->path() ); 576 MediumMountGui medium((*it)->path() );
542 qWarning("medium mount gui created" ); 577 if( medium.check() ){ // we did not ask before or ask again is off
543 if( medium.check() ){ 578 if( medium.exec() ){ // he clicked yes so search it
544 qWarning("need to check this device" );
545 if( medium.exec() ){ //ok
546 // speicher 579 // speicher
547 qWarning("execed" ); 580 cfg.read(); // cause of a race we need to reread
548 cfg.read();
549 cfg.writeEntry("timestamp", newStamp ); 581 cfg.writeEntry("timestamp", newStamp );
550 } 582 }// no else
551 }else{ 583 }else{ // we checked
552 qWarning("wrong :(" );
553 // do something different see what we need to do 584 // do something different see what we need to do
585 // let's see if we should check the device
586 cfg.setGroup("main" );
587 bool check = cfg.readBoolEntry("autocheck", true );
588 if( check ){ // find the documents
589 tmp = new DocLnkSet( (*it)->path(), configToMime(&cfg ).join(";") );
590 docsFolder->appendFrom( *tmp );
591 delete tmp;
592 }
554 } 593 }
555 } 594 }
556 } 595 }
557 } 596 }
558 qWarning("findDocuments" );
559 Global::findDocuments(docsFolder); // get rid of this call later
560 qWarning("done" );
561 m_timeStamp = newStamp; 597 m_timeStamp = newStamp;
562} 598}
563 599
564void Launcher::updateTabs() 600void Launcher::updateTabs()
565{ 601{
566 MimeType::updateApplications(); // ### reads all applnks twice 602 MimeType::updateApplications(); // ### reads all applnks twice
diff --git a/core/launcher/mediummountgui.cpp b/core/launcher/mediummountgui.cpp
index e3fa5bd..f0de85b 100644
--- a/core/launcher/mediummountgui.cpp
+++ b/core/launcher/mediummountgui.cpp
@@ -77,15 +77,16 @@ void MediumMountGui::writeConfig(bool autocheck) {
77 cfg.writeEntry("all",CheckBoxAll->isChecked() ); 77 cfg.writeEntry("all",CheckBoxAll->isChecked() );
78 78
79 cfg.setGroup("dirs"); 79 cfg.setGroup("dirs");
80 cfg.writeEntry("dirs", ""); 80 cfg.writeEntry("dirs", "");
81 81
82 82
83 // if all is checked then add only "null" to the list. 83 // if all is checked then add only "QString::null" to the list.
84 if (checkmimeall) { 84 if (checkmimeall) {
85 mimeTypeList += ("null"); 85 mimeTypeList.clear();
86 mimeTypeList += QString::null;
86 } else { 87 } else {
87 if (checkmimeaudio) { 88 if (checkmimeaudio) {
88 mimeTypeList += ("audio//*"); 89 mimeTypeList += ("audio//*");
89 } 90 }
90 if (checkmimetext) { 91 if (checkmimetext) {
91 mimeTypeList += ("text//*"); 92 mimeTypeList += ("text//*");
@@ -94,16 +95,17 @@ void MediumMountGui::writeConfig(bool autocheck) {
94 mimeTypeList += ("video//*"); 95 mimeTypeList += ("video//*");
95 } 96 }
96 if (checkmimeimage) { 97 if (checkmimeimage) {
97 mimeTypeList += ("image//*"); 98 mimeTypeList += ("image//*");
98 } 99 }
99 if (checkmimeall) { 100 if (checkmimeall) {
100 mimeTypeList << ("null"); 101 mimeTypeList.clear();
102 mimeTypeList << QString::null;
101 } 103 }
102 } 104 }
103 cfg.write(); 105 cfg.write(); // not really needed here but just to be sure
104} 106}
105 107
106void MediumMountGui::startGui() { 108void MediumMountGui::startGui() {
107 109
108 QPixmap image = Resource::loadPixmap( "HelpBrowser"); 110 QPixmap image = Resource::loadPixmap( "HelpBrowser");
109 111