author | andyq <andyq> | 2002-11-09 14:30:46 (UTC) |
---|---|---|
committer | andyq <andyq> | 2002-11-09 14:30:46 (UTC) |
commit | 98a73d0b6feca9105a0ce8bb57a1308f0317badb (patch) (unidiff) | |
tree | 0a1af33c4d8e7eaff05e68fb3cd97ddca88c0a66 /noncore/settings/aqpkg/networkpkgmgr.cpp | |
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.
Diffstat (limited to 'noncore/settings/aqpkg/networkpkgmgr.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.cpp | 166 |
1 files changed, 113 insertions, 53 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() | |||
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 ); |
@@ -287,4 +287,4 @@ void NetworkPackageManager :: serverSelected( int ) | |||
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 | } |
@@ -367,55 +367,23 @@ void NetworkPackageManager :: downloadPackage() | |||
367 | { | 367 | { |
368 | // First, write out ipkg_conf file so that ipkg can use it | 368 | // See if any packages are selected |
369 | dataMgr->writeOutIpkgConf(); | 369 | bool found = false; |
370 | 370 | if ( serversList->currentText() != LOCAL_SERVER ) | |
371 | // Display dialog to user asking where to download the files to | ||
372 | bool ok = FALSE; | ||
373 | QString dir = ""; | ||
374 | #ifdef QWS | ||
375 | // read download directory from config file | ||
376 | Config cfg( "aqpkg" ); | ||
377 | cfg.setGroup( "settings" ); | ||
378 | dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); | ||
379 | #endif | ||
380 | |||
381 | QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); | ||
382 | if ( ok && !text.isEmpty() ) | ||
383 | dir = text; // user entered something and pressed ok | ||
384 | else | ||
385 | return; // user entered nothing or pressed cancel | ||
386 | |||
387 | #ifdef QWS | ||
388 | // Store download directory in config file | ||
389 | cfg.writeEntry( "downloadDir", dir ); | ||
390 | #endif | ||
391 | |||
392 | // Get starting directory | ||
393 | char initDir[PATH_MAX]; | ||
394 | getcwd( initDir, PATH_MAX ); | ||
395 | |||
396 | // Download each package | ||
397 | Ipkg ipkg; | ||
398 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); | ||
399 | |||
400 | ipkg.setOption( "download" ); | ||
401 | ipkg.setRuntimeDirectory( dir ); | ||
402 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | ||
403 | item != 0 ; | ||
404 | item = (QCheckListItem *)item->nextSibling() ) | ||
405 | { | 371 | { |
406 | if ( item->isOn() ) | 372 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
373 | item != 0 && !found; | ||
374 | item = (QCheckListItem *)item->nextSibling() ) | ||
407 | { | 375 | { |
408 | QString name = item->text(); | 376 | if ( item->isOn() ) |
409 | int pos = name.find( "*" ); | 377 | found = true; |
410 | name.truncate( pos ); | ||
411 | |||
412 | // if (there is a (installed), remove it | ||
413 | pos = name.find( "(installed)" ); | ||
414 | if ( pos > 0 ) | ||
415 | name.truncate( pos - 1 ); | ||
416 | |||
417 | ipkg.setPackage( name ); | ||
418 | ipkg.runIpkg( ); | ||
419 | } | 378 | } |
420 | } | 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 | |||
421 | } | 389 | } |
@@ -461,2 +429,94 @@ void NetworkPackageManager :: downloadPackage() | |||
461 | 429 | ||
430 | void NetworkPackageManager :: downloadSelectedPackages() | ||
431 | { | ||
432 | // First, write out ipkg_conf file so that ipkg can use it | ||
433 | dataMgr->writeOutIpkgConf(); | ||
434 | |||
435 | // Display dialog to user asking where to download the files to | ||
436 | bool ok = FALSE; | ||
437 | QString dir = ""; | ||
438 | #ifdef QWS | ||
439 | // read download directory from config file | ||
440 | Config cfg( "aqpkg" ); | ||
441 | cfg.setGroup( "settings" ); | ||
442 | dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); | ||
443 | #endif | ||
444 | |||
445 | QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); | ||
446 | if ( ok && !text.isEmpty() ) | ||
447 | dir = text; // user entered something and pressed ok | ||
448 | else | ||
449 | return; // user entered nothing or pressed cancel | ||
450 | |||
451 | #ifdef QWS | ||
452 | // Store download directory in config file | ||
453 | cfg.writeEntry( "downloadDir", dir ); | ||
454 | #endif | ||
455 | |||
456 | // Get starting directory | ||
457 | char initDir[PATH_MAX]; | ||
458 | getcwd( initDir, PATH_MAX ); | ||
459 | |||
460 | // Download each package | ||
461 | Ipkg ipkg; | ||
462 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); | ||
463 | |||
464 | ipkg.setOption( "download" ); | ||
465 | ipkg.setRuntimeDirectory( dir ); | ||
466 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | ||
467 | item != 0 ; | ||
468 | item = (QCheckListItem *)item->nextSibling() ) | ||
469 | { | ||
470 | if ( item->isOn() ) | ||
471 | { | ||
472 | QString name = item->text(); | ||
473 | int pos = name.find( "*" ); | ||
474 | name.truncate( pos ); | ||
475 | |||
476 | // if (there is a (installed), remove it | ||
477 | pos = name.find( "(installed)" ); | ||
478 | if ( pos > 0 ) | ||
479 | name.truncate( pos - 1 ); | ||
480 | |||
481 | ipkg.setPackage( name ); | ||
482 | ipkg.runIpkg( ); | ||
483 | } | ||
484 | } | ||
485 | } | ||
486 | |||
487 | void NetworkPackageManager :: downloadRemotePackage() | ||
488 | { | ||
489 | // Display dialog | ||
490 | bool ok; | ||
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; | ||
497 | |||
498 | // grab details from dialog | ||
499 | // QString package = dlg.getPackageLocation(); | ||
500 | |||
501 | InstallData item; | ||
502 | item.option = "I"; | ||
503 | item.packageName = package; | ||
504 | vector<InstallData> workingPackages; | ||
505 | workingPackages.push_back( item ); | ||
506 | |||
507 | InstallDlgImpl dlg2( workingPackages, dataMgr, this, "Install", true ); | ||
508 | dlg2.showDlg(); | ||
509 | |||
510 | // Reload data | ||
511 | dataMgr->reloadServerData(); | ||
512 | serverSelected(-1); | ||
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 | ||
520 | } | ||
521 | |||
462 | 522 | ||
@@ -710,2 +770,2 @@ void NetworkPackageManager :: searchForPackage( bool findNext ) | |||
710 | } | 770 | } |
711 | } \ No newline at end of file | 771 | } |