summaryrefslogtreecommitdiff
path: root/noncore/settings
Side-by-side diff
Diffstat (limited to 'noncore/settings') (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
@@ -96,97 +96,97 @@ void NetworkPackageManager :: updateData()
if ( !it->isServerActive() )
{
i--;
continue;
}
serversList->insertItem( it->getServerName() );
if ( it->getServerName() == currentlySelectedServer )
activeItem = i;
}
// set selected server to be active server
if ( activeItem != -1 )
serversList->setCurrentItem( activeItem );
serverSelected( 0 );
}
void NetworkPackageManager :: selectLocalPackage( const QString &pkg )
{
// First select local server
for ( int i = 0 ; i < serversList->count() ; ++i )
{
if ( serversList->text( i ) == LOCAL_IPKGS )
{
serversList->setCurrentItem( i );
break;
}
}
serverSelected( 0 );
// Now set the check box of the selected package
for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
item != 0 ;
item = (QCheckListItem *)item->nextSibling() )
{
if ( item->text().startsWith( pkg ) )
{
item->setOn( true );
break;
}
}
}
void NetworkPackageManager :: initGui()
{
QLabel *l = new QLabel( "Servers", this );
serversList = new QComboBox( this );
packagesList = new QListView( this );
- update = new QPushButton( "Refresh List", this );
+ update = new QPushButton( "Refresh Lists", this );
download = new QPushButton( "Download", this );
upgrade = new QPushButton( "Upgrade", this );
apply = new QPushButton( "Apply", this );
QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1, "VBox" );
QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1, "HBox1" );
hbox1->addWidget( l );
hbox1->addWidget( serversList );
QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1, "HBox1" );
QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1, "HBox1" );
if ( showJumpTo )
{
char text[2];
text[1] = '\0';
for ( int i = 0 ; i < 26 ; ++i )
{
text[0] = 'A' + i;
LetterPushButton *b = new LetterPushButton( text, this );
connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) );
if ( i < 13 )
hbox3->addWidget( b );
else
hbox4->addWidget( b );
}
}
vbox->addWidget( packagesList );
packagesList->addColumn( "Packages" );
QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1, "HBox2" );
hbox2->addWidget( update );
hbox2->addWidget( download );
hbox2->addWidget( upgrade );
hbox2->addWidget( apply );
}
void NetworkPackageManager :: setupConnections()
{
connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int )));
connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) );
connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) );
connect( upgrade, SIGNAL( released()), this, SLOT(upgradePackages()) );
connect( update, SIGNAL(released()), this, SLOT(updateServer()) );
}
@@ -240,268 +240,328 @@ void NetworkPackageManager :: serverSelected( int )
text += "*";
}
}
QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox );
if ( it->isInstalled() )
{
QString destName = "";
if ( it->getLocalPackage() )
{
if ( it->getLocalPackage()->getInstalledTo() )
destName = it->getLocalPackage()->getInstalledTo()->getDestinationName();
}
else
{
if ( it->getInstalledTo() )
destName = it->getInstalledTo()->getDestinationName();
}
if ( destName != "" )
new QCheckListItem( item, QString( "Installed To - " ) + destName );
}
if ( !it->isPackageStoredLocally() )
new QCheckListItem( item, QString( "Description - " ) + it->getDescription() );
else
new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() );
if ( serverName == LOCAL_SERVER )
{
new QCheckListItem( item, QString( "V. Installed - " ) + it->getVersion() );
}
else
{
new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() );
if ( it->getLocalPackage() )
{
if ( it->isInstalled() )
new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() );
}
}
packagesList->insertItem( item );
}
// If the local server or the local ipkgs server disable the download button
if ( serverName == LOCAL_SERVER )
{
upgrade->setEnabled( false );
- download->setText( "Download" );
- download->setEnabled( false );
+ download->setText( "Install Remote" );
+ download->setEnabled( true );
}
else if ( serverName == LOCAL_IPKGS )
{
upgrade->setEnabled( false );
download->setEnabled( true );
download->setText( "Remove" );
}
else
{
upgrade->setEnabled( true );
download->setEnabled( true );
download->setText( "Download" );
}
}
void NetworkPackageManager :: updateServer()
{
QString serverName = serversList->currentText();
// Update the current server
// Display dialog
// ProgressDlg *progDlg = new ProgressDlg( this );
// QString status = "Updating package lists...";
// progDlg->show();
// progDlg->setText( status );
// Disable buttons to stop silly people clicking lots on them :)
// First, write out ipkg_conf file so that ipkg can use it
dataMgr->writeOutIpkgConf();
Ipkg ipkg;
ipkg.setOption( "update" );
InstallDlgImpl dlg( &ipkg, "Refreshing server package lists", this, "Upgrade", true );
dlg.showDlg();
// Reload data
dataMgr->reloadServerData();
serverSelected(-1);
// delete progDlg;
}
void NetworkPackageManager :: upgradePackages()
{
// We're gonna do an upgrade of all packages
// First warn user that this isn't recommended
QString text = "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n";
QMessageBox warn("Warning", text, QMessageBox::Warning,
QMessageBox::Yes,
QMessageBox::No | QMessageBox::Escape | QMessageBox::Default ,
0, this );
warn.adjustSize();
if ( warn.exec() == QMessageBox::Yes )
{
// First, write out ipkg_conf file so that ipkg can use it
dataMgr->writeOutIpkgConf();
// Now run upgrade
Ipkg ipkg;
ipkg.setOption( "upgrade" );
InstallDlgImpl dlg( &ipkg, "Upgrading installed packages", this, "Upgrade", true );
dlg.showDlg();
// Reload data
dataMgr->reloadServerData();
serverSelected(-1);
}
}
void NetworkPackageManager :: downloadPackage()
{
bool doUpdate = true;
if ( download->text() == "Download" )
{
+ // 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
dataMgr->writeOutIpkgConf();
// Display dialog to user asking where to download the files to
bool ok = FALSE;
QString dir = "";
#ifdef QWS
// read download directory from config file
Config cfg( "aqpkg" );
cfg.setGroup( "settings" );
dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" );
#endif
QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this );
if ( ok && !text.isEmpty() )
dir = text; // user entered something and pressed ok
else
return; // user entered nothing or pressed cancel
#ifdef QWS
// Store download directory in config file
cfg.writeEntry( "downloadDir", dir );
#endif
// Get starting directory
char initDir[PATH_MAX];
getcwd( initDir, PATH_MAX );
// Download each package
Ipkg ipkg;
connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
ipkg.setOption( "download" );
ipkg.setRuntimeDirectory( dir );
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 );
ipkg.setPackage( name );
ipkg.runIpkg( );
}
}
}
- 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
}
void NetworkPackageManager :: applyChanges()
{
stickyOption = "";
// First, write out ipkg_conf file so that ipkg can use it
dataMgr->writeOutIpkgConf();
// Now for each selected item
// deal with it
vector<InstallData> workingPackages;
for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
item != 0 ;
item = (QCheckListItem *)item->nextSibling() )
{
if ( item->isOn() )
{
InstallData data = dealWithItem( item );
workingPackages.push_back( data );
}
}
if ( workingPackages.size() == 0 )
{
// Nothing to do
QMessageBox::information( this, "Nothing to do",
"No packages selected", "OK" );
return;
}
// do the stuff
InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true );
dlg.showDlg();
// 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
@@ -18,62 +18,64 @@
#ifndef NETWORKPKGMGR_H
#define NETWORKPKGMGR_H
#include <qlayout.h>
#include <qpushbutton.h>
#include <qwidget.h>
#include <qcombobox.h>
#include <qlistview.h>
#include "datamgr.h"
#include "progressdlg.h"
class InstallData;
/** NetworkPackageManager is the base class of the project */
class NetworkPackageManager : public QWidget
{
Q_OBJECT
public:
/** construtor */
NetworkPackageManager( DataManager *dataManager, QWidget* parent=0, const char *name=0);
/** destructor */
~NetworkPackageManager();
void selectLocalPackage( const QString &pkg );
void updateData();
void searchForPackage( bool findNext );
private:
DataManager *dataMgr;
QComboBox *serversList;
QListView *packagesList;
QPushButton *update;
QPushButton *upgrade;
QPushButton *download;
QPushButton *apply;
ProgressDlg *progressDlg;
QString currentlySelectedServer;
QString lastSearchText;
bool showJumpTo;
int timerId;
void timerEvent ( QTimerEvent * );
void initGui();
void setupConnections();
void showProgressDialog( char *initialText );
+ void downloadSelectedPackages();
+ void downloadRemotePackage();
InstallData dealWithItem( QCheckListItem *item );
QString stickyOption;
public slots:
void serverSelected( int index );
void applyChanges();
void upgradePackages();
void downloadPackage();
void updateServer();
void displayText( const QString &t );
void letterPushed( QString t );
};
#endif