summaryrefslogtreecommitdiff
path: root/noncore
Unidiff
Diffstat (limited to 'noncore') (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
@@ -138,13 +138,13 @@ void NetworkPackageManager :: selectLocalPackage( const QString &pkg )
138 138
139void NetworkPackageManager :: initGui() 139void NetworkPackageManager :: initGui()
140{ 140{
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 );
148 148
149 QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1, "VBox" ); 149 QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1, "VBox" );
150 QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1, "HBox1" ); 150 QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1, "HBox1" );
@@ -282,14 +282,14 @@ void NetworkPackageManager :: serverSelected( int )
282 } 282 }
283 283
284 // If the local server or the local ipkgs server disable the download button 284 // If the local server or the local ipkgs server disable the download button
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 {
293 upgrade->setEnabled( false ); 293 upgrade->setEnabled( false );
294 download->setEnabled( true ); 294 download->setEnabled( true );
295 download->setText( "Remove" ); 295 download->setText( "Remove" );
@@ -362,12 +362,76 @@ void NetworkPackageManager :: upgradePackages()
362 362
363void NetworkPackageManager :: downloadPackage() 363void NetworkPackageManager :: downloadPackage()
364{ 364{
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
371 // Display dialog to user asking where to download the files to 435 // Display dialog to user asking where to download the files to
372 bool ok = FALSE; 436 bool ok = FALSE;
373 QString dir = ""; 437 QString dir = "";
@@ -416,50 +480,46 @@ void NetworkPackageManager :: downloadPackage()
416 480
417 ipkg.setPackage( name ); 481 ipkg.setPackage( name );
418 ipkg.runIpkg( ); 482 ipkg.runIpkg( );
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
463void NetworkPackageManager :: applyChanges() 523void NetworkPackageManager :: applyChanges()
464{ 524{
465 stickyOption = ""; 525 stickyOption = "";
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
@@ -60,12 +60,14 @@ private:
60 60
61 void timerEvent ( QTimerEvent * ); 61 void timerEvent ( QTimerEvent * );
62 62
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
69public slots: 71public slots:
70 void serverSelected( int index ); 72 void serverSelected( int index );
71 void applyChanges(); 73 void applyChanges();