summaryrefslogtreecommitdiff
authorandyq <andyq>2002-10-21 15:52:50 (UTC)
committer andyq <andyq>2002-10-21 15:52:50 (UTC)
commitd9ddcd0eb7608321eb2b94ad427868948ea627c2 (patch) (unidiff)
tree636b771af85cf0b03699fee767d209fadbbd16d3
parent5e2e1e70e6cc7cadce96e42f83951b87e3f2209e (diff)
downloadopie-d9ddcd0eb7608321eb2b94ad427868948ea627c2.zip
opie-d9ddcd0eb7608321eb2b94ad427868948ea627c2.tar.gz
opie-d9ddcd0eb7608321eb2b94ad427868948ea627c2.tar.bz2
If no packages selected and Apply button pushed, displays message - Nothing to do' and doesn't display Install dialog
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp
index d84fb4b..9acaaf1 100644
--- a/noncore/settings/aqpkg/networkpkgmgr.cpp
+++ b/noncore/settings/aqpkg/networkpkgmgr.cpp
@@ -241,329 +241,338 @@ void NetworkPackageManager :: serverSelected( int )
241 packagesList->insertItem( item ); 241 packagesList->insertItem( item );
242 } 242 }
243 243
244 // If the local server or the local ipkgs server disable the download button 244 // If the local server or the local ipkgs server disable the download button
245 if ( serverName == LOCAL_SERVER ) 245 if ( serverName == LOCAL_SERVER )
246 { 246 {
247 upgrade->setEnabled( false ); 247 upgrade->setEnabled( false );
248 download->setText( "Download" ); 248 download->setText( "Download" );
249 download->setEnabled( false ); 249 download->setEnabled( false );
250 } 250 }
251 else if ( serverName == LOCAL_IPKGS ) 251 else if ( serverName == LOCAL_IPKGS )
252 { 252 {
253 upgrade->setEnabled( false ); 253 upgrade->setEnabled( false );
254 download->setEnabled( true ); 254 download->setEnabled( true );
255 download->setText( "Remove" ); 255 download->setText( "Remove" );
256 } 256 }
257 else 257 else
258 { 258 {
259 upgrade->setEnabled( true ); 259 upgrade->setEnabled( true );
260 download->setEnabled( true ); 260 download->setEnabled( true );
261 download->setText( "Download" ); 261 download->setText( "Download" );
262 } 262 }
263} 263}
264 264
265void NetworkPackageManager :: updateServer() 265void NetworkPackageManager :: updateServer()
266{ 266{
267 QString serverName = serversList->currentText(); 267 QString serverName = serversList->currentText();
268 268
269 // Update the current server 269 // Update the current server
270 // Display dialog 270 // Display dialog
271 ProgressDlg *dlg = new ProgressDlg( this ); 271 ProgressDlg *dlg = new ProgressDlg( this );
272 QString status = "Updating package lists..."; 272 QString status = "Updating package lists...";
273 dlg->show(); 273 dlg->show();
274 dlg->setText( status ); 274 dlg->setText( status );
275 275
276 // Disable buttons to stop silly people clicking lots on them :) 276 // Disable buttons to stop silly people clicking lots on them :)
277 277
278 // First, write out ipkg_conf file so that ipkg can use it 278 // First, write out ipkg_conf file so that ipkg can use it
279 dataMgr->writeOutIpkgConf(); 279 dataMgr->writeOutIpkgConf();
280 280
281 QString option = "update"; 281 QString option = "update";
282 QString dummy = ""; 282 QString dummy = "";
283 Ipkg ipkg; 283 Ipkg ipkg;
284 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 284 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
285 ipkg.setOption( option ); 285 ipkg.setOption( option );
286 286
287 ipkg.runIpkg( ); 287 ipkg.runIpkg( );
288 288
289 // Reload data 289 // Reload data
290 dataMgr->reloadServerData( serversList->currentText() ); 290 dataMgr->reloadServerData( serversList->currentText() );
291 serverSelected(-1); 291 serverSelected(-1);
292 delete dlg; 292 delete dlg;
293} 293}
294 294
295void NetworkPackageManager :: upgradePackages() 295void NetworkPackageManager :: upgradePackages()
296{ 296{
297 // We're gonna do an upgrade of all packages 297 // We're gonna do an upgrade of all packages
298 // First warn user that this isn't recommended 298 // First warn user that this isn't recommended
299 QString text = "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n"; 299 QString text = "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n";
300 QMessageBox warn("Warning", text, QMessageBox::Warning, 300 QMessageBox warn("Warning", text, QMessageBox::Warning,
301 QMessageBox::Yes, 301 QMessageBox::Yes,
302 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , 302 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default ,
303 0, this ); 303 0, this );
304 warn.adjustSize(); 304 warn.adjustSize();
305 305
306 if ( warn.exec() == QMessageBox::Yes ) 306 if ( warn.exec() == QMessageBox::Yes )
307 { 307 {
308 // First, write out ipkg_conf file so that ipkg can use it 308 // First, write out ipkg_conf file so that ipkg can use it
309 dataMgr->writeOutIpkgConf(); 309 dataMgr->writeOutIpkgConf();
310 310
311 // Now run upgrade 311 // Now run upgrade
312 InstallDlgImpl dlg( this, "Upgrade", true ); 312 InstallDlgImpl dlg( this, "Upgrade", true );
313 dlg.showDlg(); 313 dlg.showDlg();
314 314
315 // Reload data 315 // Reload data
316 dataMgr->reloadServerData( LOCAL_SERVER ); 316 dataMgr->reloadServerData( LOCAL_SERVER );
317 317
318 dataMgr->reloadServerData( serversList->currentText() ); 318 dataMgr->reloadServerData( serversList->currentText() );
319 serverSelected(-1); 319 serverSelected(-1);
320 } 320 }
321} 321}
322 322
323 323
324void NetworkPackageManager :: downloadPackage() 324void NetworkPackageManager :: downloadPackage()
325{ 325{
326 if ( download->text() == "Download" ) 326 if ( download->text() == "Download" )
327 { 327 {
328 // First, write out ipkg_conf file so that ipkg can use it 328 // First, write out ipkg_conf file so that ipkg can use it
329 dataMgr->writeOutIpkgConf(); 329 dataMgr->writeOutIpkgConf();
330 330
331 // Display dialog to user asking where to download the files to 331 // Display dialog to user asking where to download the files to
332 bool ok = FALSE; 332 bool ok = FALSE;
333 QString dir = ""; 333 QString dir = "";
334#ifdef QWS 334#ifdef QWS
335 // read download directory from config file 335 // read download directory from config file
336 Config cfg( "aqpkg" ); 336 Config cfg( "aqpkg" );
337 cfg.setGroup( "settings" ); 337 cfg.setGroup( "settings" );
338 dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); 338 dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" );
339#endif 339#endif
340 340
341 QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); 341 QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this );
342 if ( ok && !text.isEmpty() ) 342 if ( ok && !text.isEmpty() )
343 dir = text; // user entered something and pressed ok 343 dir = text; // user entered something and pressed ok
344 else 344 else
345 return; // user entered nothing or pressed cancel 345 return; // user entered nothing or pressed cancel
346 346
347#ifdef QWS 347#ifdef QWS
348 // Store download directory in config file 348 // Store download directory in config file
349 cfg.writeEntry( "downloadDir", dir ); 349 cfg.writeEntry( "downloadDir", dir );
350#endif 350#endif
351 351
352 // Get starting directory 352 // Get starting directory
353 char initDir[PATH_MAX]; 353 char initDir[PATH_MAX];
354 getcwd( initDir, PATH_MAX ); 354 getcwd( initDir, PATH_MAX );
355 355
356 // Download each package 356 // Download each package
357 Ipkg ipkg; 357 Ipkg ipkg;
358 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 358 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
359 359
360 ipkg.setOption( "download" ); 360 ipkg.setOption( "download" );
361 ipkg.setRuntimeDirectory( dir ); 361 ipkg.setRuntimeDirectory( dir );
362 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 362 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
363 item != 0 ; 363 item != 0 ;
364 item = (QCheckListItem *)item->nextSibling() ) 364 item = (QCheckListItem *)item->nextSibling() )
365 { 365 {
366 if ( item->isOn() ) 366 if ( item->isOn() )
367 { 367 {
368 QString name = item->text(); 368 QString name = item->text();
369 int pos = name.find( "*" ); 369 int pos = name.find( "*" );
370 name.truncate( pos ); 370 name.truncate( pos );
371 371
372 // if (there is a (installed), remove it 372 // if (there is a (installed), remove it
373 pos = name.find( "(installed)" ); 373 pos = name.find( "(installed)" );
374 if ( pos > 0 ) 374 if ( pos > 0 )
375 name.truncate( pos - 1 ); 375 name.truncate( pos - 1 );
376 376
377 ipkg.setPackage( name ); 377 ipkg.setPackage( name );
378 ipkg.runIpkg( ); 378 ipkg.runIpkg( );
379 } 379 }
380 } 380 }
381 } 381 }
382 else if ( download->text() == "Remove" ) 382 else if ( download->text() == "Remove" )
383 { 383 {
384 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 384 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
385 item != 0 ; 385 item != 0 ;
386 item = (QCheckListItem *)item->nextSibling() ) 386 item = (QCheckListItem *)item->nextSibling() )
387 { 387 {
388 if ( item->isOn() ) 388 if ( item->isOn() )
389 { 389 {
390 QString name = item->text(); 390 QString name = item->text();
391 int pos = name.find( "*" ); 391 int pos = name.find( "*" );
392 name.truncate( pos ); 392 name.truncate( pos );
393 393
394 // if (there is a (installed), remove it 394 // if (there is a (installed), remove it
395 pos = name.find( "(installed)" ); 395 pos = name.find( "(installed)" );
396 if ( pos > 0 ) 396 if ( pos > 0 )
397 name.truncate( pos - 1 ); 397 name.truncate( pos - 1 );
398 398
399 Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name ); 399 Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name );
400 QFile f( p->getFilename() ); 400 QFile f( p->getFilename() );
401 f.remove(); 401 f.remove();
402 } 402 }
403 } 403 }
404 } 404 }
405 405
406 dataMgr->reloadServerData( LOCAL_IPKGS ); 406 dataMgr->reloadServerData( LOCAL_IPKGS );
407 serverSelected( -1 ); 407 serverSelected( -1 );
408} 408}
409 409
410 410
411void NetworkPackageManager :: applyChanges() 411void NetworkPackageManager :: applyChanges()
412{ 412{
413 stickyOption = ""; 413 stickyOption = "";
414 414
415 // First, write out ipkg_conf file so that ipkg can use it 415 // First, write out ipkg_conf file so that ipkg can use it
416 dataMgr->writeOutIpkgConf(); 416 dataMgr->writeOutIpkgConf();
417 417
418 // Now for each selected item 418 // Now for each selected item
419 // deal with it 419 // deal with it
420 420
421 vector<InstallData> workingPackages; 421 vector<InstallData> workingPackages;
422 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 422 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
423 item != 0 ; 423 item != 0 ;
424 item = (QCheckListItem *)item->nextSibling() ) 424 item = (QCheckListItem *)item->nextSibling() )
425 { 425 {
426 if ( item->isOn() ) 426 if ( item->isOn() )
427 { 427 {
428 InstallData data = dealWithItem( item ); 428 InstallData data = dealWithItem( item );
429 workingPackages.push_back( data ); 429 workingPackages.push_back( data );
430 } 430 }
431 } 431 }
432 432
433 if ( workingPackages.size() == 0 )
434 {
435 // Nothing to do
436 QMessageBox::information( this, "Nothing to do",
437 "No packages selected", "OK" );
438
439 return;
440 }
441
433 // do the stuff 442 // do the stuff
434 InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true ); 443 InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true );
435 dlg.showDlg(); 444 dlg.showDlg();
436 445
437 // Reload data 446 // Reload data
438 dataMgr->reloadServerData( LOCAL_SERVER ); 447 dataMgr->reloadServerData( LOCAL_SERVER );
439 448
440 dataMgr->reloadServerData( serversList->currentText() ); 449 dataMgr->reloadServerData( serversList->currentText() );
441 serverSelected(-1); 450 serverSelected(-1);
442 451
443#ifdef QWS 452#ifdef QWS
444 // Finally let the main system update itself 453 // Finally let the main system update itself
445 QCopEnvelope e("QPE/System", "linkChanged(QString)"); 454 QCopEnvelope e("QPE/System", "linkChanged(QString)");
446 QString lf = QString::null; 455 QString lf = QString::null;
447 e << lf; 456 e << lf;
448#endif 457#endif
449} 458}
450 459
451// decide what to do - either remove, upgrade or install 460// decide what to do - either remove, upgrade or install
452// Current rules: 461// Current rules:
453// If not installed - install 462// If not installed - install
454// If installed and different version available - upgrade 463// If installed and different version available - upgrade
455// If installed and version up to date - remove 464// If installed and version up to date - remove
456InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item ) 465InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item )
457{ 466{
458 QString name = item->text(); 467 QString name = item->text();
459 int pos = name.find( "*" ); 468 int pos = name.find( "*" );
460 name.truncate( pos ); 469 name.truncate( pos );
461 470
462 // if (there is a (installed), remove it 471 // if (there is a (installed), remove it
463 pos = name.find( "(installed)" ); 472 pos = name.find( "(installed)" );
464 if ( pos > 0 ) 473 if ( pos > 0 )
465 name.truncate( pos - 1 ); 474 name.truncate( pos - 1 );
466 475
467 // Get package 476 // Get package
468 Server *s = dataMgr->getServer( serversList->currentText() ); 477 Server *s = dataMgr->getServer( serversList->currentText() );
469 Package *p = s->getPackage( name ); 478 Package *p = s->getPackage( name );
470 479
471 // If the package has a filename then it is a local file 480 // If the package has a filename then it is a local file
472 if ( p->isPackageStoredLocally() ) 481 if ( p->isPackageStoredLocally() )
473 name = p->getFilename(); 482 name = p->getFilename();
474 QString option; 483 QString option;
475 QString dest = "root"; 484 QString dest = "root";
476 if ( !p->isInstalled() ) 485 if ( !p->isInstalled() )
477 { 486 {
478 InstallData item; 487 InstallData item;
479 item.option = "I"; 488 item.option = "I";
480 item.packageName = name; 489 item.packageName = name;
481 return item; 490 return item;
482 } 491 }
483 else 492 else
484 { 493 {
485 InstallData item; 494 InstallData item;
486 item.option = "D"; 495 item.option = "D";
487 item.packageName = p->getInstalledPackageName(); 496 item.packageName = p->getInstalledPackageName();
488 if ( p->getInstalledTo() ) 497 if ( p->getInstalledTo() )
489 { 498 {
490 item.destination = p->getInstalledTo(); 499 item.destination = p->getInstalledTo();
491 cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl; 500 cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl;
492 cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl; 501 cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl;
493 } 502 }
494 else 503 else
495 { 504 {
496 item.destination = p->getLocalPackage()->getInstalledTo(); 505 item.destination = p->getLocalPackage()->getInstalledTo();
497 } 506 }
498 507
499 // Sticky option not implemented yet, but will eventually allow 508 // Sticky option not implemented yet, but will eventually allow
500 // the user to say something like 'remove all' 509 // the user to say something like 'remove all'
501 if ( stickyOption == "" ) 510 if ( stickyOption == "" )
502 { 511 {
503 QString msgtext; 512 QString msgtext;
504 msgtext.sprintf( "Do you wish to remove or reinstall\n%s?", (const char *)name ); 513 msgtext.sprintf( "Do you wish to remove or reinstall\n%s?", (const char *)name );
505 switch( QMessageBox::information( this, "Remove or ReInstall", 514 switch( QMessageBox::information( this, "Remove or ReInstall",
506 msgtext, "Remove", "ReInstall" ) ) 515 msgtext, "Remove", "ReInstall" ) )
507 { 516 {
508 case 0: // Try again or Enter 517 case 0: // Try again or Enter
509 item.option = "D"; 518 item.option = "D";
510 break; 519 break;
511 case 1: // Quit or Escape 520 case 1: // Quit or Escape
512 item.option = "U"; 521 item.option = "U";
513 break; 522 break;
514 } 523 }
515 } 524 }
516 else 525 else
517 { 526 {
518// item.option = stickyOption; 527// item.option = stickyOption;
519 } 528 }
520 529
521 // Check if we are reinstalling the same version 530 // Check if we are reinstalling the same version
522 if ( p->getVersion() != p->getInstalledVersion() ) 531 if ( p->getVersion() != p->getInstalledVersion() )
523 item.recreateLinks = true; 532 item.recreateLinks = true;
524 else 533 else
525 item.recreateLinks = false; 534 item.recreateLinks = false;
526 535
527 // User hit cancel (on dlg - assume remove) 536 // User hit cancel (on dlg - assume remove)
528 return item; 537 return item;
529 } 538 }
530} 539}
531 540
532void NetworkPackageManager :: displayText( const QString &t ) 541void NetworkPackageManager :: displayText( const QString &t )
533{ 542{
534 cout << t << endl; 543 cout << t << endl;
535} 544}
536 545
537 546
538void NetworkPackageManager :: letterPushed( QString t ) 547void NetworkPackageManager :: letterPushed( QString t )
539{ 548{
540 QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); 549 QCheckListItem *top = (QCheckListItem *)packagesList->firstChild();
541 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); 550 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem();
542 if ( packagesList->firstChild() == 0 ) 551 if ( packagesList->firstChild() == 0 )
543 return; 552 return;
544 553
545 QCheckListItem *item; 554 QCheckListItem *item;
546 if ( start == 0 ) 555 if ( start == 0 )
547 { 556 {
548 item = (QCheckListItem *)packagesList->firstChild(); 557 item = (QCheckListItem *)packagesList->firstChild();
549 start = top; 558 start = top;
550 } 559 }
551 else 560 else
552 item = (QCheckListItem *)start->nextSibling(); 561 item = (QCheckListItem *)start->nextSibling();
553 562
554 if ( item == 0 ) 563 if ( item == 0 )
555 item = (QCheckListItem *)packagesList->firstChild(); 564 item = (QCheckListItem *)packagesList->firstChild();
556 do 565 do
557 { 566 {
558 if ( item->text().lower().startsWith( t.lower() ) ) 567 if ( item->text().lower().startsWith( t.lower() ) )
559 { 568 {
560 packagesList->setSelected( item, true ); 569 packagesList->setSelected( item, true );
561 packagesList->ensureItemVisible( item ); 570 packagesList->ensureItemVisible( item );
562 break; 571 break;
563 } 572 }
564 573
565 item = (QCheckListItem *)item->nextSibling(); 574 item = (QCheckListItem *)item->nextSibling();
566 if ( !item ) 575 if ( !item )
567 item = (QCheckListItem *)packagesList->firstChild(); 576 item = (QCheckListItem *)packagesList->firstChild();
568 } while ( item != start); 577 } while ( item != start);
569} 578}