summaryrefslogtreecommitdiff
authoralwin <alwin>2005-03-07 13:03:38 (UTC)
committer alwin <alwin>2005-03-07 13:03:38 (UTC)
commitc26df8eafe66bded4a4af4f95830fd2187bfa2ca (patch) (unidiff)
tree561f0da611b70fe5c415bf636307289b9507e6e6
parent4515ff72db76ba63dcf3b29b19d930b7e083d508 (diff)
downloadopie-c26df8eafe66bded4a4af4f95830fd2187bfa2ca.zip
opie-c26df8eafe66bded4a4af4f95830fd2187bfa2ca.tar.gz
opie-c26df8eafe66bded4a4af4f95830fd2187bfa2ca.tar.bz2
fixed a very interesting crasher.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/documentlist.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/core/launcher/documentlist.cpp b/core/launcher/documentlist.cpp
index d2b9afa..b8bf4e0 100644
--- a/core/launcher/documentlist.cpp
+++ b/core/launcher/documentlist.cpp
@@ -201,401 +201,401 @@ void DocumentList::timerEvent( QTimerEvent *te )
201 pause(); 201 pause();
202 if ( d->serverGui ) 202 if ( d->serverGui )
203 d->serverGui->documentScanningProgress( 100 ); 203 d->serverGui->documentScanningProgress( 100 );
204 if ( d->needToSendAllDocLinks ) 204 if ( d->needToSendAllDocLinks )
205 sendAllDocLinks(); 205 sendAllDocLinks();
206 break; 206 break;
207 } 207 }
208 } 208 }
209 if ( d->serverGui ) 209 if ( d->serverGui )
210 d->serverGui->aboutToAddEnd(); 210 d->serverGui->aboutToAddEnd();
211 } 211 }
212} 212}
213 213
214 214
215void DocumentList::reloadAppLnks() 215void DocumentList::reloadAppLnks()
216{ 216{
217 if ( d->sendAppLnks && d->serverGui ) { 217 if ( d->sendAppLnks && d->serverGui ) {
218 d->serverGui->applicationScanningProgress( 0 ); 218 d->serverGui->applicationScanningProgress( 0 );
219 d->serverGui->allApplicationsRemoved(); 219 d->serverGui->allApplicationsRemoved();
220 } 220 }
221 221
222 delete appLnkSet; 222 delete appLnkSet;
223 appLnkSet = new AppLnkSet( MimeType::appsFolderName() ); 223 appLnkSet = new AppLnkSet( MimeType::appsFolderName() );
224 224
225 if ( d->sendAppLnks && d->serverGui ) { 225 if ( d->sendAppLnks && d->serverGui ) {
226 static QStringList prevTypeList; 226 static QStringList prevTypeList;
227 QStringList types = appLnkSet->types(); 227 QStringList types = appLnkSet->types();
228 for ( QStringList::Iterator ittypes=types.begin(); ittypes!=types.end(); ++ittypes) { 228 for ( QStringList::Iterator ittypes=types.begin(); ittypes!=types.end(); ++ittypes) {
229 if ( !(*ittypes).isEmpty() ) { 229 if ( !(*ittypes).isEmpty() ) {
230 if ( !prevTypeList.contains(*ittypes) ) { 230 if ( !prevTypeList.contains(*ittypes) ) {
231 QString name = appLnkSet->typeName(*ittypes); 231 QString name = appLnkSet->typeName(*ittypes);
232 QPixmap pm = appLnkSet->typePixmap(*ittypes); 232 QPixmap pm = appLnkSet->typePixmap(*ittypes);
233 QPixmap bgPm = appLnkSet->typeBigPixmap(*ittypes); 233 QPixmap bgPm = appLnkSet->typeBigPixmap(*ittypes);
234 234
235 if (pm.isNull()) { 235 if (pm.isNull()) {
236 QImage img( Resource::loadImage( "UnknownDocument" ) ); 236 QImage img( Resource::loadImage( "UnknownDocument" ) );
237 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); 237 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() );
238 bgPm = img.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() ); 238 bgPm = img.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() );
239 } 239 }
240 240
241 //odebug << "adding type " << (*ittypes) << "" << oendl; 241 //odebug << "adding type " << (*ittypes) << "" << oendl;
242 242
243 // ### our current launcher expects docs tab to be last 243 // ### our current launcher expects docs tab to be last
244 d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm ); 244 d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm );
245 } 245 }
246 prevTypeList.remove(*ittypes); 246 prevTypeList.remove(*ittypes);
247 } 247 }
248 } 248 }
249 for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) { 249 for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) {
250 //odebug << "removing type " << (*ittypes) << "" << oendl; 250 //odebug << "removing type " << (*ittypes) << "" << oendl;
251 d->serverGui->typeRemoved(*ittypes); 251 d->serverGui->typeRemoved(*ittypes);
252 } 252 }
253 prevTypeList = types; 253 prevTypeList = types;
254 } 254 }
255 255
256 QListIterator<AppLnk> itapp( appLnkSet->children() ); 256 QListIterator<AppLnk> itapp( appLnkSet->children() );
257 AppLnk* l; 257 AppLnk* l;
258 while ( (l=itapp.current()) ) { 258 while ( (l=itapp.current()) ) {
259 ++itapp; 259 ++itapp;
260 if ( d->sendAppLnks && d->serverGui ) 260 if ( d->sendAppLnks && d->serverGui )
261 d->serverGui->applicationAdded( l->type(), *l ); 261 d->serverGui->applicationAdded( l->type(), *l );
262 } 262 }
263 263
264 if ( d->sendAppLnks && d->serverGui ) 264 if ( d->sendAppLnks && d->serverGui )
265 d->serverGui->applicationScanningProgress( 100 ); 265 d->serverGui->applicationScanningProgress( 100 );
266} 266}
267 267
268void DocumentList::reloadDocLnks() 268void DocumentList::reloadDocLnks()
269{ 269{
270 if ( !d->scanDocs ) 270 if ( !d->scanDocs )
271 return; 271 return;
272 272
273 if ( d->sendDocLnks && d->serverGui ) { 273 if ( d->sendDocLnks && d->serverGui ) {
274 d->serverGui->documentScanningProgress( 0 ); 274 d->serverGui->documentScanningProgress( 0 );
275 d->serverGui->allDocumentsRemoved(); 275 d->serverGui->allDocumentsRemoved();
276 } 276 }
277 277
278 rescan(); 278 rescan();
279} 279}
280 280
281void DocumentList::reforceDocuments() 281void DocumentList::reforceDocuments()
282{ 282{
283 Config cfg( "Launcher" ); 283 Config cfg( "Launcher" );
284 cfg.setGroup( "DocTab" ); 284 cfg.setGroup( "DocTab" );
285 d->scanDocs = cfg.readBoolEntry( "Enable", true ); 285 d->scanDocs = cfg.readBoolEntry( "Enable", true );
286 reloadDocLnks(); 286 reloadDocLnks();
287} 287}
288 288
289void DocumentList::linkChanged( QString arg ) 289void DocumentList::linkChanged( QString arg )
290{ 290{
291 odebug << "linkchanged( " << arg << " )" << oendl; 291 odebug << "linkchanged( " << arg << " )" << oendl;
292 292
293 if ( arg.isNull() || OGlobal::isAppLnkFileName( arg ) ) { 293 if ( arg.isNull() || OGlobal::isAppLnkFileName( arg ) ) {
294 reloadAppLnks(); 294 reloadAppLnks();
295 } else { 295 } else {
296 296
297 const QList<DocLnk> &list = d->dls.children(); 297 const QList<DocLnk> &list = d->dls.children();
298 QListIterator<DocLnk> it( list ); 298 QListIterator<DocLnk> it( list );
299 while ( it.current() ) { 299 while ( it.current() ) {
300 DocLnk *doc = it.current(); 300 DocLnk *doc = it.current();
301 ++it; 301 ++it;
302 if ( ( doc->linkFileKnown() && doc->linkFile() == arg ) 302 if ( ( doc->linkFileKnown() && doc->linkFile() == arg )
303 || ( doc->fileKnown() && doc->file() == arg ) ) { 303 || ( doc->fileKnown() && doc->file() == arg ) ) {
304 //odebug << "found old link" << oendl; 304 //odebug << "found old link" << oendl;
305 DocLnk* dl = new DocLnk( arg ); 305 DocLnk* dl = new DocLnk( arg );
306 // add new one if it exists and matches the mimetype 306 // add new one if it exists and matches the mimetype
307 if ( d->store( dl ) ) { 307 if ( d->store( dl ) ) {
308 // Existing link has been changed, send old link ref and a ref 308 // Existing link has been changed, send old link ref and a ref
309 // to the new link 309 // to the new link
310 //odebug << "change case" << oendl; 310 //odebug << "change case" << oendl;
311 if ( d->serverGui ) 311 if ( d->serverGui )
312 d->serverGui->documentChanged( *doc, *dl ); 312 d->serverGui->documentChanged( *doc, *dl );
313 313
314 } else { 314 } else {
315 // Link has been removed or doesn't match the mimetypes any more 315 // Link has been removed or doesn't match the mimetypes any more
316 // so we aren't interested in it, so take it away from the list 316 // so we aren't interested in it, so take it away from the list
317 //odebug << "removal case" << oendl; 317 //odebug << "removal case" << oendl;
318 if ( d->serverGui ) 318 if ( d->serverGui )
319 d->serverGui->documentRemoved( *doc ); 319 d->serverGui->documentRemoved( *doc );
320 320
321 } 321 }
322 d->dls.remove( doc ); // remove old link from docLnkSet 322 d->dls.remove( doc ); // remove old link from docLnkSet
323 delete doc; 323 delete doc;
324 return; 324 return;
325 } 325 }
326 } 326 }
327 // Didn't find existing link, must be new 327 // Didn't find existing link, must be new
328 DocLnk* dl = new DocLnk( arg ); 328 DocLnk* dl = new DocLnk( arg );
329 if ( d->store( dl ) ) { 329 if ( d->store( dl ) ) {
330 // Add if it's a link we are interested in 330 // Add if it's a link we are interested in
331 //odebug << "add case" << oendl; 331 //odebug << "add case" << oendl;
332 add( *dl ); 332 add( *dl );
333 } 333 }
334 334
335 } 335 }
336} 336}
337 337
338void DocumentList::restoreDone() 338void DocumentList::restoreDone()
339{ 339{
340 reloadAppLnks(); 340 reloadAppLnks();
341 reloadDocLnks(); 341 reloadDocLnks();
342} 342}
343 343
344void DocumentList::DiffAppLnks() 344void DocumentList::DiffAppLnks()
345{ 345{
346 static AppLnkSet *appLnkSet2; 346 static AppLnkSet *appLnkSet2;
347 347
348 appLnkSet2 = new AppLnkSet( MimeType::appsFolderName() ); 348 appLnkSet2 = new AppLnkSet( MimeType::appsFolderName() );
349 349
350 if ( d->sendAppLnks && d->serverGui ) { 350 if ( d->sendAppLnks && d->serverGui ) {
351 static QStringList prevTypeList = appLnkSet->types(); 351 static QStringList prevTypeList = appLnkSet->types();
352 QStringList types = appLnkSet2->types(); 352 QStringList types = appLnkSet2->types();
353 for ( QStringList::Iterator ittypes=types.begin(); ittypes!=types.end(); ++ittypes) { 353 for ( QStringList::Iterator ittypes=types.begin(); ittypes!=types.end(); ++ittypes) {
354 if ( !(*ittypes).isEmpty() ) { 354 if ( !(*ittypes).isEmpty() ) {
355 if ( !prevTypeList.contains(*ittypes) ) { 355 if ( !prevTypeList.contains(*ittypes) ) {
356 QString name = appLnkSet2->typeName(*ittypes); 356 QString name = appLnkSet2->typeName(*ittypes);
357 QPixmap pm = appLnkSet2->typePixmap(*ittypes); 357 QPixmap pm = appLnkSet2->typePixmap(*ittypes);
358 QPixmap bgPm = appLnkSet2->typeBigPixmap(*ittypes); 358 QPixmap bgPm = appLnkSet2->typeBigPixmap(*ittypes);
359 359
360 if (pm.isNull()) { 360 if (pm.isNull()) {
361 QImage img( Resource::loadImage( "UnknownDocument" ) ); 361 QImage img( Resource::loadImage( "UnknownDocument" ) );
362 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() ); 362 pm = img.smoothScale( AppLnk::smallIconSize(), AppLnk::smallIconSize() );
363 bgPm = img.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() ); 363 bgPm = img.smoothScale( AppLnk::bigIconSize(), AppLnk::bigIconSize() );
364 } 364 }
365 365
366 odebug << "adding type " << (*ittypes) << "" << oendl; 366 odebug << "adding type " << (*ittypes) << "" << oendl;
367 367
368 // ### our current launcher expects docs tab to be last 368 // ### our current launcher expects docs tab to be last
369 d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm ); 369 d->serverGui->typeAdded( *ittypes, name.isNull() ? (*ittypes) : name, pm, bgPm );
370 } 370 }
371 prevTypeList.remove(*ittypes); 371 prevTypeList.remove(*ittypes);
372 } 372 }
373 } 373 }
374 for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) { 374 for ( QStringList::Iterator ittypes=prevTypeList.begin(); ittypes!=prevTypeList.end(); ++ittypes) {
375 odebug << "removing type " << (*ittypes) << "" << oendl; 375 odebug << "removing type " << (*ittypes) << "" << oendl;
376 d->serverGui->typeRemoved(*ittypes); 376 d->serverGui->typeRemoved(*ittypes);
377 } 377 }
378 prevTypeList = types; 378 prevTypeList = types;
379 } 379 }
380 380
381 381
382 QListIterator<AppLnk> it1( appLnkSet->children() ); 382 QListIterator<AppLnk> it1( appLnkSet->children() );
383 QListIterator<AppLnk> it2( appLnkSet2->children() ); 383 QListIterator<AppLnk> it2( appLnkSet2->children() );
384 384
385 AppLnk *i; 385 AppLnk *i;
386 AppLnk *j; 386 AppLnk *j;
387 bool found; 387 bool found;
388 388
389 while ( (j=it2.current()) ) { 389 while ( (j=it2.current()) ) {
390 it1 = appLnkSet->children(); 390 it1 = appLnkSet->children();
391 found = false; 391 found = false;
392 while ( (i=it1.current()) ){ 392 while ( (i=it1.current()) ){
393 if (strcmp(i->name().ascii(),j->name().ascii()) == 0) 393 if (j->name().ascii() && i->name().ascii() && strcmp(i->name().ascii(),j->name().ascii()) == 0)
394 found = true; 394 found = true;
395 ++it1; 395 ++it1;
396 } 396 }
397 if (!found) { 397 if (!found) {
398 odebug << "Item " << j->name().ascii() << " needs to be added" << oendl; 398 odebug << "Item " << j->name().ascii() << " needs to be added" << oendl;
399 d->serverGui->applicationAdded( j->type(), *j ); 399 d->serverGui->applicationAdded( j->type(), *j );
400 } 400 }
401 ++it2; 401 ++it2;
402 } 402 }
403 403
404 it1 = appLnkSet->children(); 404 it1 = appLnkSet->children();
405 while ( (i=it1.current()) ) { 405 while ( (i=it1.current()) ) {
406 it2 = appLnkSet2->children(); 406 it2 = appLnkSet2->children();
407 found = false; 407 found = false;
408 while ( (j=it2.current()) ){ 408 while ( (j=it2.current()) ){
409 if (strcmp(i->name().ascii(),j->name().ascii()) == 0) 409 if (j->name().ascii() && i->name().ascii() && strcmp(i->name().ascii(),j->name().ascii()) == 0)
410 found = true; 410 found = true;
411 ++it2; 411 ++it2;
412 } 412 }
413 if (!found) { 413 if (!found) {
414 odebug << "Item " << i->name().ascii() << " needs to be removed" << oendl; 414 odebug << "Item " << i->name().ascii() << " needs to be removed" << oendl;
415 d->serverGui->applicationRemoved( i->type(), *i ); 415 d->serverGui->applicationRemoved( i->type(), *i );
416 } 416 }
417 417
418 ++it1; 418 ++it1;
419 } 419 }
420 420
421 delete appLnkSet; 421 delete appLnkSet;
422 appLnkSet = appLnkSet2; 422 appLnkSet = appLnkSet2;
423 423
424} 424}
425void DocumentList::storageChanged() 425void DocumentList::storageChanged()
426{ 426{
427 QTime t; 427 QTime t;
428 // ### can implement better 428 // ### can implement better
429 429
430 t.start(); 430 t.start();
431 DiffAppLnks(); 431 DiffAppLnks();
432// reloadAppLnks(); 432// reloadAppLnks();
433 odebug << "Reload App links took " << t.elapsed() << " ms" << oendl; 433 odebug << "Reload App links took " << t.elapsed() << " ms" << oendl;
434 reloadDocLnks(); 434 reloadDocLnks();
435// odebug << "Reload links took " << t.elapsed() << " ms " << oendl; 435// odebug << "Reload links took " << t.elapsed() << " ms " << oendl;
436 odebug << "Reload All links took " << t.elapsed() << " ms" << oendl; 436 odebug << "Reload All links took " << t.elapsed() << " ms" << oendl;
437// ### Optimization opportunity 437// ### Optimization opportunity
438 // Could be a bit more intelligent and somehow work out which 438 // Could be a bit more intelligent and somehow work out which
439 // mtab entry has changed and then only scan that and add and remove 439 // mtab entry has changed and then only scan that and add and remove
440 // links appropriately. 440 // links appropriately.
441// rescan(); 441// rescan();
442} 442}
443 443
444void DocumentList::sendAllDocLinks() 444void DocumentList::sendAllDocLinks()
445{ 445{
446 if ( d->tid != 0 ) { 446 if ( d->tid != 0 ) {
447 // We are in the middle of scanning, set a flag so 447 // We are in the middle of scanning, set a flag so
448 // we do this when we finish our scanning 448 // we do this when we finish our scanning
449 d->needToSendAllDocLinks = true; 449 d->needToSendAllDocLinks = true;
450 return; 450 return;
451 } 451 }
452 452
453 QString contents; 453 QString contents;
454 Categories cats; 454 Categories cats;
455 for ( QListIterator<DocLnk> it( d->dls.children() ); it.current(); ++it ) { 455 for ( QListIterator<DocLnk> it( d->dls.children() ); it.current(); ++it ) {
456 DocLnk *doc = it.current(); 456 DocLnk *doc = it.current();
457 QFileInfo fi( doc->file() ); 457 QFileInfo fi( doc->file() );
458 if ( !fi.exists() ) 458 if ( !fi.exists() )
459 continue; 459 continue;
460 460
461 bool fake = !doc->linkFileKnown(); 461 bool fake = !doc->linkFileKnown();
462 if ( !fake ) { 462 if ( !fake ) {
463 QFile f( doc->linkFile() ); 463 QFile f( doc->linkFile() );
464 if ( f.open( IO_ReadOnly ) ) { 464 if ( f.open( IO_ReadOnly ) ) {
465 QTextStream ts( &f ); 465 QTextStream ts( &f );
466 ts.setEncoding( QTextStream::UnicodeUTF8 ); 466 ts.setEncoding( QTextStream::UnicodeUTF8 );
467 QString docLnk = ts.read(); 467 QString docLnk = ts.read();
468 // Strip out the (stale) LinkFile entry 468 // Strip out the (stale) LinkFile entry
469 int start = docLnk.find( "\nLinkFile = " ) + 1; 469 int start = docLnk.find( "\nLinkFile = " ) + 1;
470 if ( start > 0 ) { 470 if ( start > 0 ) {
471 int end = docLnk.find( "\n", start + 1 ) + 1; 471 int end = docLnk.find( "\n", start + 1 ) + 1;
472 contents += docLnk.left(start); 472 contents += docLnk.left(start);
473 contents += docLnk.mid(end); 473 contents += docLnk.mid(end);
474 } else { 474 } else {
475 contents += docLnk; 475 contents += docLnk;
476 } 476 }
477 contents += "LinkFile = " + doc->linkFile() + "\n"; 477 contents += "LinkFile = " + doc->linkFile() + "\n";
478 478
479 f.close(); 479 f.close();
480 } else 480 } else
481 fake = TRUE; 481 fake = TRUE;
482 } 482 }
483 if (fake) { 483 if (fake) {
484 contents += "[Desktop Entry]\n"; // No tr 484 contents += "[Desktop Entry]\n"; // No tr
485 contents += "Categories = " + // No tr 485 contents += "Categories = " + // No tr
486 cats.labels("Document View",doc->categories()).join(";") + "\n"; // No tr 486 cats.labels("Document View",doc->categories()).join(";") + "\n"; // No tr
487 contents += "Name = "+doc->name()+"\n"; // No tr 487 contents += "Name = "+doc->name()+"\n"; // No tr
488 contents += "Type = "+doc->type()+"\n"; // No tr 488 contents += "Type = "+doc->type()+"\n"; // No tr
489 } 489 }
490 contents += "File = "+doc->file()+"\n"; // No tr // (resolves path) 490 contents += "File = "+doc->file()+"\n"; // No tr // (resolves path)
491 contents += QString("Size = %1\n").arg( fi.size() ); // No tr 491 contents += QString("Size = %1\n").arg( fi.size() ); // No tr
492 } 492 }
493 493
494 //odebug << "sending length " << contents.length() << "" << oendl; 494 //odebug << "sending length " << contents.length() << "" << oendl;
495#ifndef QT_NO_COP 495#ifndef QT_NO_COP
496 QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" ); 496 QCopEnvelope e( "QPE/Desktop", "docLinks(QString)" );
497 e << contents; 497 e << contents;
498#endif 498#endif
499 //odebug << "================ \n\n" << contents << "\n\n===============" << oendl; 499 //odebug << "================ \n\n" << contents << "\n\n===============" << oendl;
500 500
501 d->needToSendAllDocLinks = false; 501 d->needToSendAllDocLinks = false;
502} 502}
503 503
504 504
505 505
506 506
507 507
508 508
509 509
510 510
511 511
512 512
513 513
514 514
515 515
516 516
517 517
518 518
519 519
520 520
521 521
522 522
523 523
524 524
525 525
526 526
527DocumentListPrivate::DocumentListPrivate( ServerInterface *gui ) 527DocumentListPrivate::DocumentListPrivate( ServerInterface *gui )
528{ 528{
529 storage = new StorageInfo( this ); 529 storage = new StorageInfo( this );
530 serverGui = gui; 530 serverGui = gui;
531 if ( serverGui ) { 531 if ( serverGui ) {
532 sendAppLnks = serverGui->requiresApplications(); 532 sendAppLnks = serverGui->requiresApplications();
533 sendDocLnks = serverGui->requiresDocuments(); 533 sendDocLnks = serverGui->requiresDocuments();
534 } else { 534 } else {
535 sendAppLnks = false; 535 sendAppLnks = false;
536 sendDocLnks = false; 536 sendDocLnks = false;
537 } 537 }
538 for ( int i = 0; i < MAX_SEARCH_DEPTH; i++ ) { 538 for ( int i = 0; i < MAX_SEARCH_DEPTH; i++ ) {
539 listDirs[i] = 0; 539 listDirs[i] = 0;
540 lists[i] = 0; 540 lists[i] = 0;
541 listPositions[i] = 0; 541 listPositions[i] = 0;
542 } 542 }
543 initialize(); 543 initialize();
544 tid = 0; 544 tid = 0;
545} 545}
546 546
547void DocumentListPrivate::appendDocpath(FileSystem*fs) 547void DocumentListPrivate::appendDocpath(FileSystem*fs)
548{ 548{
549 Config c( "qpe" ); 549 Config c( "qpe" );
550 c.setGroup( "Startup" ); 550 c.setGroup( "Startup" );
551 QDir defPath(fs->path()+"/Documents"); 551 QDir defPath(fs->path()+"/Documents");
552 QFileInfo f(fs->path()+"/.opiestorage.cf"); 552 QFileInfo f(fs->path()+"/.opiestorage.cf");
553 if ( c.readNumEntry( "FirstUse", 42 ) == 0 && !f.exists()) { 553 if ( c.readNumEntry( "FirstUse", 42 ) == 0 && !f.exists()) {
554 Mediadlg dlg(fs); 554 Mediadlg dlg(fs);
555 if (QDialog::Accepted != QPEApplication::execDialog( &dlg )) { 555 if (QDialog::Accepted != QPEApplication::execDialog( &dlg )) {
556 return; 556 return;
557 } 557 }
558 } 558 }
559 Config conf(f.filePath(), Config::File ); 559 Config conf(f.filePath(), Config::File );
560 conf.setGroup("main"); 560 conf.setGroup("main");
561 if (!conf.readBoolEntry("check",false)) { 561 if (!conf.readBoolEntry("check",false)) {
562 return; 562 return;
563 } 563 }
564 conf.setGroup("subdirs"); 564 conf.setGroup("subdirs");
565 bool read_all = conf.readBoolEntry("wholemedia",true); 565 bool read_all = conf.readBoolEntry("wholemedia",true);
566 if (read_all) { 566 if (read_all) {
567 docPaths+=fs->path(); 567 docPaths+=fs->path();
568 return; 568 return;
569 } 569 }
570 QStringList subDirs = conf.readListEntry("subdirs",':'); 570 QStringList subDirs = conf.readListEntry("subdirs",':');
571 if (subDirs.isEmpty()) { 571 if (subDirs.isEmpty()) {
572 if (defPath.exists()) { 572 if (defPath.exists()) {
573 docPaths+=defPath.path(); 573 docPaths+=defPath.path();
574 } 574 }
575 return; 575 return;
576 } 576 }
577 for (unsigned c = 0; c < subDirs.count();++c) { 577 for (unsigned c = 0; c < subDirs.count();++c) {
578 QDir docDir(QString(fs->path()+"/"+subDirs[c])); 578 QDir docDir(QString(fs->path()+"/"+subDirs[c]));
579 if (docDir.exists()) { 579 if (docDir.exists()) {
580 docPaths+=docDir.path(); 580 docPaths+=docDir.path();
581 } 581 }
582 } 582 }
583} 583}
584 584
585void DocumentListPrivate::initialize() 585void DocumentListPrivate::initialize()
586{ 586{
587 // Reset 587 // Reset
588 dls.clear(); 588 dls.clear();
589 docPaths.clear(); 589 docPaths.clear();
590 reference.clear(); 590 reference.clear();
591 591
592 QDir docDir( QPEApplication::documentDir() ); 592 QDir docDir( QPEApplication::documentDir() );
593 if ( docDir.exists() ) 593 if ( docDir.exists() )
594 docPaths += QPEApplication::documentDir(); 594 docPaths += QPEApplication::documentDir();
595 int i = 1; 595 int i = 1;
596 const QList<FileSystem> &fs = storage->fileSystems(); 596 const QList<FileSystem> &fs = storage->fileSystems();
597 QListIterator<FileSystem> it( fs ); 597 QListIterator<FileSystem> it( fs );
598 for ( ; it.current(); ++it ) { 598 for ( ; it.current(); ++it ) {
599 if ( (*it)->isRemovable() ) { 599 if ( (*it)->isRemovable() ) {
600 appendDocpath((*it)); 600 appendDocpath((*it));
601 ++i; 601 ++i;