author | andyq <andyq> | 2002-11-09 14:30:46 (UTC) |
---|---|---|
committer | andyq <andyq> | 2002-11-09 14:30:46 (UTC) |
commit | 98a73d0b6feca9105a0ce8bb57a1308f0317badb (patch) (side-by-side diff) | |
tree | 0a1af33c4d8e7eaff05e68fb3cd97ddca88c0a66 | |
parent | 29758bfcaabf75a3155e8af140c11ca9ed014c42 (diff) | |
download | opie-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.
-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.cpp | 128 | ||||
-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.h | 2 |
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 @@ -143,3 +143,3 @@ void NetworkPackageManager :: initGui() packagesList = new QListView( this ); - update = new QPushButton( "Refresh List", this ); + update = new QPushButton( "Refresh Lists", this ); download = new QPushButton( "Download", this ); @@ -287,4 +287,4 @@ void NetworkPackageManager :: serverSelected( int ) upgrade->setEnabled( false ); - download->setText( "Download" ); - download->setEnabled( false ); + download->setText( "Install Remote" ); + download->setEnabled( true ); } @@ -367,2 +367,66 @@ void NetworkPackageManager :: downloadPackage() { + // See if any packages are selected + bool found = false; + if ( serversList->currentText() != LOCAL_SERVER ) + { + for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); + item != 0 && !found; + item = (QCheckListItem *)item->nextSibling() ) + { + if ( item->isOn() ) + found = true; + } + } + + // If user selected some packages then download the and store the locally + // otherwise, display dialog asking user what package to download from an http server + // and whether to install it + if ( found ) + downloadSelectedPackages(); + else + downloadRemotePackage(); + + } + else if ( download->text() == "Remove" ) + { + doUpdate = false; + for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); + item != 0 ; + item = (QCheckListItem *)item->nextSibling() ) + { + if ( item->isOn() ) + { + QString name = item->text(); + int pos = name.find( "*" ); + name.truncate( pos ); + + // if (there is a (installed), remove it + pos = name.find( "(installed)" ); + if ( pos > 0 ) + name.truncate( pos - 1 ); + + Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name ); + + QString msgtext; + msgtext.sprintf( "Are you sure you wish to delete\n%s?", (const char *)p->getPackageName() ); + if ( QMessageBox::information( this, "Are you sure?", + msgtext, "No", "Yes" ) == 1 ) + { + doUpdate = true; + QFile f( p->getFilename() ); + f.remove(); + } + } + } + } + + if ( doUpdate ) + { + dataMgr->reloadServerData(); + serverSelected( -1 ); + } +} + +void NetworkPackageManager :: downloadSelectedPackages() +{ // First, write out ipkg_conf file so that ipkg can use it @@ -421,40 +485,36 @@ void NetworkPackageManager :: downloadPackage() } - else if ( download->text() == "Remove" ) - { - doUpdate = false; - for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); - item != 0 ; - item = (QCheckListItem *)item->nextSibling() ) - { - if ( item->isOn() ) + +void NetworkPackageManager :: downloadRemotePackage() { - QString name = item->text(); - int pos = name.find( "*" ); - name.truncate( pos ); + // Display dialog + bool ok; + QString package = InputDialog::getText( "Install Remote Package", tr( "Enter package location" ), "http://", &ok, this ); + if ( !ok || package.isEmpty() ) + return; +// DownloadRemoteDlgImpl dlg( this, "Install", true ); +// if ( dlg.exec() == QDialog::Rejected ) +// return; - // if (there is a (installed), remove it - pos = name.find( "(installed)" ); - if ( pos > 0 ) - name.truncate( pos - 1 ); + // grab details from dialog +// QString package = dlg.getPackageLocation(); - Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name ); + InstallData item; + item.option = "I"; + item.packageName = package; + vector<InstallData> workingPackages; + workingPackages.push_back( item ); - QString msgtext; - msgtext.sprintf( "Are you sure you wish to delete\n%s?", (const char *)p->getPackageName() ); - if ( QMessageBox::information( this, "Are you sure?", - msgtext, "No", "Yes" ) == 1 ) - { - doUpdate = true; - QFile f( p->getFilename() ); - f.remove(); - } - } - } - } + InstallDlgImpl dlg2( workingPackages, dataMgr, this, "Install", true ); + dlg2.showDlg(); - if ( doUpdate ) - { + // Reload data dataMgr->reloadServerData(); serverSelected( -1 ); - } + +#ifdef QWS + // Finally let the main system update itself + QCopEnvelope e("QPE/System", "linkChanged(QString)"); + QString lf = QString::null; + e << lf; +#endif } 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 @@ -65,2 +65,4 @@ private: void showProgressDialog( char *initialText ); + void downloadSelectedPackages(); + void downloadRemotePackage(); InstallData dealWithItem( QCheckListItem *item ); |