summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.cpp128
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.h2
2 files changed, 96 insertions, 34 deletions
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp
index a058285..76c7a9c 100644
--- a/noncore/settings/aqpkg/networkpkgmgr.cpp
+++ b/noncore/settings/aqpkg/networkpkgmgr.cpp
@@ -141,7 +141,7 @@ void NetworkPackageManager :: initGui()
141 QLabel *l = new QLabel( "Servers", this ); 141 QLabel *l = new QLabel( "Servers", this );
142 serversList = new QComboBox( this ); 142 serversList = new QComboBox( this );
143 packagesList = new QListView( this ); 143 packagesList = new QListView( this );
144 update = new QPushButton( "Refresh List", this ); 144 update = new QPushButton( "Refresh Lists", this );
145 download = new QPushButton( "Download", this ); 145 download = new QPushButton( "Download", this );
146 upgrade = new QPushButton( "Upgrade", this ); 146 upgrade = new QPushButton( "Upgrade", this );
147 apply = new QPushButton( "Apply", this ); 147 apply = new QPushButton( "Apply", this );
@@ -285,8 +285,8 @@ void NetworkPackageManager :: serverSelected( int )
285 if ( serverName == LOCAL_SERVER ) 285 if ( serverName == LOCAL_SERVER )
286 { 286 {
287 upgrade->setEnabled( false ); 287 upgrade->setEnabled( false );
288 download->setText( "Download" ); 288 download->setText( "Install Remote" );
289 download->setEnabled( false ); 289 download->setEnabled( true );
290 } 290 }
291 else if ( serverName == LOCAL_IPKGS ) 291 else if ( serverName == LOCAL_IPKGS )
292 { 292 {
@@ -365,6 +365,70 @@ void NetworkPackageManager :: downloadPackage()
365 bool doUpdate = true; 365 bool doUpdate = true;
366 if ( download->text() == "Download" ) 366 if ( download->text() == "Download" )
367 { 367 {
368 // See if any packages are selected
369 bool found = false;
370 if ( serversList->currentText() != LOCAL_SERVER )
371 {
372 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
373 item != 0 && !found;
374 item = (QCheckListItem *)item->nextSibling() )
375 {
376 if ( item->isOn() )
377 found = true;
378 }
379 }
380
381 // If user selected some packages then download the and store the locally
382 // otherwise, display dialog asking user what package to download from an http server
383 // and whether to install it
384 if ( found )
385 downloadSelectedPackages();
386 else
387 downloadRemotePackage();
388
389 }
390 else if ( download->text() == "Remove" )
391 {
392 doUpdate = false;
393 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
394 item != 0 ;
395 item = (QCheckListItem *)item->nextSibling() )
396 {
397 if ( item->isOn() )
398 {
399 QString name = item->text();
400 int pos = name.find( "*" );
401 name.truncate( pos );
402
403 // if (there is a (installed), remove it
404 pos = name.find( "(installed)" );
405 if ( pos > 0 )
406 name.truncate( pos - 1 );
407
408 Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name );
409
410 QString msgtext;
411 msgtext.sprintf( "Are you sure you wish to delete\n%s?", (const char *)p->getPackageName() );
412 if ( QMessageBox::information( this, "Are you sure?",
413 msgtext, "No", "Yes" ) == 1 )
414 {
415 doUpdate = true;
416 QFile f( p->getFilename() );
417 f.remove();
418 }
419 }
420 }
421 }
422
423 if ( doUpdate )
424 {
425 dataMgr->reloadServerData();
426 serverSelected( -1 );
427 }
428}
429
430void NetworkPackageManager :: downloadSelectedPackages()
431{
368 // First, write out ipkg_conf file so that ipkg can use it 432 // First, write out ipkg_conf file so that ipkg can use it
369 dataMgr->writeOutIpkgConf(); 433 dataMgr->writeOutIpkgConf();
370 434
@@ -419,44 +483,40 @@ void NetworkPackageManager :: downloadPackage()
419 } 483 }
420 } 484 }
421 } 485 }
422 else if ( download->text() == "Remove" ) 486
423 { 487void NetworkPackageManager :: downloadRemotePackage()
424 doUpdate = false;
425 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
426 item != 0 ;
427 item = (QCheckListItem *)item->nextSibling() )
428 {
429 if ( item->isOn() )
430 { 488 {
431 QString name = item->text(); 489 // Display dialog
432 int pos = name.find( "*" ); 490 bool ok;
433 name.truncate( pos ); 491 QString package = InputDialog::getText( "Install Remote Package", tr( "Enter package location" ), "http://", &ok, this );
492 if ( !ok || package.isEmpty() )
493 return;
494// DownloadRemoteDlgImpl dlg( this, "Install", true );
495// if ( dlg.exec() == QDialog::Rejected )
496// return;
434 497
435 // if (there is a (installed), remove it 498 // grab details from dialog
436 pos = name.find( "(installed)" ); 499// QString package = dlg.getPackageLocation();
437 if ( pos > 0 )
438 name.truncate( pos - 1 );
439 500
440 Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name ); 501 InstallData item;
502 item.option = "I";
503 item.packageName = package;
504 vector<InstallData> workingPackages;
505 workingPackages.push_back( item );
441 506
442 QString msgtext; 507 InstallDlgImpl dlg2( workingPackages, dataMgr, this, "Install", true );
443 msgtext.sprintf( "Are you sure you wish to delete\n%s?", (const char *)p->getPackageName() ); 508 dlg2.showDlg();
444 if ( QMessageBox::information( this, "Are you sure?",
445 msgtext, "No", "Yes" ) == 1 )
446 {
447 doUpdate = true;
448 QFile f( p->getFilename() );
449 f.remove();
450 }
451 }
452 }
453 }
454 509
455 if ( doUpdate ) 510 // Reload data
456 {
457 dataMgr->reloadServerData(); 511 dataMgr->reloadServerData();
458 serverSelected( -1 ); 512 serverSelected( -1 );
459 } 513
514#ifdef QWS
515 // Finally let the main system update itself
516 QCopEnvelope e("QPE/System", "linkChanged(QString)");
517 QString lf = QString::null;
518 e << lf;
519#endif
460} 520}
461 521
462 522
diff --git a/noncore/settings/aqpkg/networkpkgmgr.h b/noncore/settings/aqpkg/networkpkgmgr.h
index 20f6e2d..66a8903 100644
--- a/noncore/settings/aqpkg/networkpkgmgr.h
+++ b/noncore/settings/aqpkg/networkpkgmgr.h
@@ -63,6 +63,8 @@ private:
63 void initGui(); 63 void initGui();
64 void setupConnections(); 64 void setupConnections();
65 void showProgressDialog( char *initialText ); 65 void showProgressDialog( char *initialText );
66 void downloadSelectedPackages();
67 void downloadRemotePackage();
66 InstallData dealWithItem( QCheckListItem *item ); 68 InstallData dealWithItem( QCheckListItem *item );
67 QString stickyOption; 69 QString stickyOption;
68 70