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
@@ -63,32 +63,63 @@
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 {
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;
85} 116}
86 117
87void CategoryTabWidget::prevTab() 118void CategoryTabWidget::prevTab()
88{ 119{
89 if ( categoryBar ) { 120 if ( categoryBar ) {
90 int n = categoryBar->count(); 121 int n = categoryBar->count();
91 int tab = categoryBar->currentTab(); 122 int tab = categoryBar->currentTab();
92 if ( tab >= 0 ) 123 if ( tab >= 0 )
93 categoryBar->setCurrentTab( (tab - 1 + n)%n ); 124 categoryBar->setCurrentTab( (tab - 1 + n)%n );
94 } 125 }
@@ -413,34 +444,34 @@ void CategoryTabBar::paintLabel( QPainter* p, const QRect&,
413 444
414//--------------------------------------------------------------------------- 445//---------------------------------------------------------------------------
415 446
416Launcher::Launcher( QWidget* parent, const char* name, WFlags fl ) 447Launcher::Launcher( QWidget* parent, const char* name, WFlags fl )
417 : QMainWindow( parent, name, fl ) 448 : QMainWindow( parent, name, fl )
418{ 449{
419 setCaption( tr("Launcher") ); 450 setCaption( tr("Launcher") );
420 451
421 syncDialog = 0; 452 syncDialog = 0;
422 453
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
437 connect( tabs, SIGNAL(selected(const QString&)), 468 connect( tabs, SIGNAL(selected(const QString&)),
438 this, SLOT(viewSelected(const QString&)) ); 469 this, SLOT(viewSelected(const QString&)) );
439 connect( tabs, SIGNAL(clicked(const AppLnk*)), 470 connect( tabs, SIGNAL(clicked(const AppLnk*)),
440 this, SLOT(select(const AppLnk*))); 471 this, SLOT(select(const AppLnk*)));
441 connect( tabs, SIGNAL(rightPressed(AppLnk*)), 472 connect( tabs, SIGNAL(rightPressed(AppLnk*)),
442 this, SLOT(properties(AppLnk*))); 473 this, SLOT(properties(AppLnk*)));
443 474
444#if defined(Q_WS_QWS) && !defined(QT_NO_COP) 475#if defined(Q_WS_QWS) && !defined(QT_NO_COP)
445 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this ); 476 QCopChannel* sysChannel = new QCopChannel( "QPE/System", this );
446 connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)), 477 connect( sysChannel, SIGNAL(received(const QCString &, const QByteArray &)),
@@ -498,79 +529,84 @@ void Launcher::updateMimeTypes(AppLnkSet* folder)
498 AppLnk *app = it.current(); 529 AppLnk *app = it.current();
499 if ( app->type() == "Folder" ) 530 if ( app->type() == "Folder" )
500 updateMimeTypes((AppLnkSet *)app); 531 updateMimeTypes((AppLnkSet *)app);
501 else { 532 else {
502 MimeType::registerApp(*app); 533 MimeType::registerApp(*app);
503 } 534 }
504 } 535 }
505} 536}
506 537
507void Launcher::loadDocs() // ok here comes a hack belonging to Global:: 538void 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
567 603
568 delete rootFolder; 604 delete rootFolder;
569 rootFolder = new AppLnkSet( MimeType::appsFolderName() ); 605 rootFolder = new AppLnkSet( MimeType::appsFolderName() );
570 606
571 loadDocs(); 607 loadDocs();
572 608
573 tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems()); 609 tabs->initializeCategories(rootFolder, docsFolder, storage->fileSystems());
574} 610}
575 611
576void Launcher::updateDocs() 612void Launcher::updateDocs()
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
@@ -67,53 +67,55 @@ void MediumMountGui::writeConfig(bool autocheck) {
67 cfg.setGroup("main"); 67 cfg.setGroup("main");
68 cfg.writeEntry("check", AskBox->isChecked() ); 68 cfg.writeEntry("check", AskBox->isChecked() );
69 cfg.writeEntry("autocheck", autocheck ); 69 cfg.writeEntry("autocheck", autocheck );
70 70
71 cfg.setGroup("mimetypes"); 71 cfg.setGroup("mimetypes");
72 72
73 cfg.writeEntry("audio", CheckBoxAudio->isChecked() ); 73 cfg.writeEntry("audio", CheckBoxAudio->isChecked() );
74 cfg.writeEntry("image",CheckBoxImage->isChecked() ); 74 cfg.writeEntry("image",CheckBoxImage->isChecked() );
75 cfg.writeEntry("text",CheckBoxImage->isChecked() ); 75 cfg.writeEntry("text",CheckBoxImage->isChecked() );
76 cfg.writeEntry("video",CheckBoxVideo->isChecked() ); 76 cfg.writeEntry("video",CheckBoxVideo->isChecked() );
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//*");
92 } 93 }
93 if (checkmimevideo) { 94 if (checkmimevideo) {
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
110 Text_2 = new QLabel( this ); 112 Text_2 = new QLabel( this );
111 Text_2->setGeometry( QRect( 10, 15, 40, 40 ) ); 113 Text_2->setGeometry( QRect( 10, 15, 40, 40 ) );
112 Text_2->setPixmap( image ); 114 Text_2->setPixmap( image );
113 115
114 Text = new QLabel( this, "Text" ); 116 Text = new QLabel( this, "Text" );
115 Text->setGeometry( QRect( 55, 11, this->width()-50, 50 ) ); 117 Text->setGeometry( QRect( 55, 11, this->width()-50, 50 ) );
116 Text->setText( tr( "A <b>storage medium</b> was inserted. Should it be scanned for media files?" ) ); 118 Text->setText( tr( "A <b>storage medium</b> was inserted. Should it be scanned for media files?" ) );
117 119
118 // media box 120 // media box
119 GroupBox1 = new QGroupBox( this, "GroupBox1" ); 121 GroupBox1 = new QGroupBox( this, "GroupBox1" );