summaryrefslogtreecommitdiff
authorandyq <andyq>2002-11-09 14:30:46 (UTC)
committer andyq <andyq>2002-11-09 14:30:46 (UTC)
commit98a73d0b6feca9105a0ce8bb57a1308f0317badb (patch) (unidiff)
tree0a1af33c4d8e7eaff05e68fb3cd97ddca88c0a66
parent29758bfcaabf75a3155e8af140c11ca9ed014c42 (diff)
downloadopie-98a73d0b6feca9105a0ce8bb57a1308f0317badb.zip
opie-98a73d0b6feca9105a0ce8bb57a1308f0317badb.tar.gz
opie-98a73d0b6feca9105a0ce8bb57a1308f0317badb.tar.bz2
Added ability to install a remote package (one from the net)
Done by clicking the download button when no packages are selected. Currently can't do it from the LOCAL-IPKGS view.
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
@@ -132,25 +132,25 @@ void NetworkPackageManager :: selectLocalPackage( const QString &pkg )
132 item->setOn( true ); 132 item->setOn( true );
133 break; 133 break;
134 } 134 }
135 } 135 }
136} 136}
137 137
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" );
151 hbox1->addWidget( l ); 151 hbox1->addWidget( l );
152 hbox1->addWidget( serversList ); 152 hbox1->addWidget( serversList );
153 153
154 QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1, "HBox1" ); 154 QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1, "HBox1" );
155 QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1, "HBox1" ); 155 QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1, "HBox1" );
156 156
@@ -276,26 +276,26 @@ void NetworkPackageManager :: serverSelected( int )
276 { 276 {
277 if ( it->isInstalled() ) 277 if ( it->isInstalled() )
278 new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() ); 278 new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() );
279 } 279 }
280 } 280 }
281 packagesList->insertItem( item ); 281 packagesList->insertItem( item );
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" );
296 } 296 }
297 else 297 else
298 { 298 {
299 upgrade->setEnabled( true ); 299 upgrade->setEnabled( true );
300 download->setEnabled( true ); 300 download->setEnabled( true );
301 download->setText( "Download" ); 301 download->setText( "Download" );
@@ -356,24 +356,88 @@ void NetworkPackageManager :: upgradePackages()
356 // Reload data 356 // Reload data
357 dataMgr->reloadServerData(); 357 dataMgr->reloadServerData();
358 serverSelected(-1); 358 serverSelected(-1);
359 } 359 }
360} 360}
361 361
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 = "";
374#ifdef QWS 438#ifdef QWS
375 // read download directory from config file 439 // read download directory from config file
376 Config cfg( "aqpkg" ); 440 Config cfg( "aqpkg" );
377 cfg.setGroup( "settings" ); 441 cfg.setGroup( "settings" );
378 dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); 442 dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" );
379#endif 443#endif
@@ -410,62 +474,58 @@ void NetworkPackageManager :: downloadPackage()
410 name.truncate( pos ); 474 name.truncate( pos );
411 475
412 // if (there is a (installed), remove it 476 // if (there is a (installed), remove it
413 pos = name.find( "(installed)" ); 477 pos = name.find( "(installed)" );
414 if ( pos > 0 ) 478 if ( pos > 0 )
415 name.truncate( pos - 1 ); 479 name.truncate( pos - 1 );
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 = "";
466 526
467 // First, write out ipkg_conf file so that ipkg can use it 527 // First, write out ipkg_conf file so that ipkg can use it
468 dataMgr->writeOutIpkgConf(); 528 dataMgr->writeOutIpkgConf();
469 529
470 // Now for each selected item 530 // Now for each selected item
471 // deal with it 531 // deal with it
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
@@ -54,24 +54,26 @@ private:
54 ProgressDlg *progressDlg; 54 ProgressDlg *progressDlg;
55 QString currentlySelectedServer; 55 QString currentlySelectedServer;
56 QString lastSearchText; 56 QString lastSearchText;
57 57
58 bool showJumpTo; 58 bool showJumpTo;
59 int timerId; 59 int timerId;
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();
72 void upgradePackages(); 74 void upgradePackages();
73 void downloadPackage(); 75 void downloadPackage();
74 void updateServer(); 76 void updateServer();
75 void displayText( const QString &t ); 77 void displayText( const QString &t );
76 void letterPushed( QString t ); 78 void letterPushed( QString t );
77}; 79};