summaryrefslogtreecommitdiff
path: root/noncore/settings/aqpkg
Side-by-side diff
Diffstat (limited to 'noncore/settings/aqpkg') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/installdlgimpl.cpp130
-rw-r--r--noncore/settings/aqpkg/installdlgimpl.h8
-rw-r--r--noncore/settings/aqpkg/ipkg.cpp17
-rw-r--r--noncore/settings/aqpkg/ipkg.h4
-rw-r--r--noncore/settings/aqpkg/mainwin.cpp8
-rw-r--r--noncore/settings/aqpkg/mainwin.h2
6 files changed, 116 insertions, 53 deletions
diff --git a/noncore/settings/aqpkg/installdlgimpl.cpp b/noncore/settings/aqpkg/installdlgimpl.cpp
index 76d0a80..896e370 100644
--- a/noncore/settings/aqpkg/installdlgimpl.cpp
+++ b/noncore/settings/aqpkg/installdlgimpl.cpp
@@ -40,25 +40,25 @@
#include "datamgr.h"
#include "destination.h"
#include "instoptionsimpl.h"
#include "installdlgimpl.h"
#include "ipkg.h"
#include "utils.h"
#include "global.h"
enum {
MAXLINES = 100,
};
-InstallDlgImpl::InstallDlgImpl( QList<InstallData> &packageList, DataManager *dataManager, const char *title )
+InstallDlgImpl::InstallDlgImpl( const QList<InstallData> &packageList, DataManager *dataManager, const char *title )
: QWidget( 0, 0, 0 )
{
setCaption( title );
init( TRUE );
pIpkg = 0;
upgradePackages = false;
dataMgr = dataManager;
QString defaultDest = "root";
#ifdef QWS
Config cfg( "aqpkg" );
@@ -92,54 +92,53 @@ InstallDlgImpl::InstallDlgImpl( QList<InstallData> &packageList, DataManager *da
destination->setCurrentItem( defIndex );
QListIterator<InstallData> it( packageList );
// setup package data
QString remove = tr( "Remove\n" );
QString install = tr( "Install\n" );
QString upgrade = tr( "Upgrade\n" );
for ( ; it.current(); ++it )
{
InstallData *item = it.current();
InstallData *newitem = new InstallData();
-
- newitem->option = item->option;
- newitem->packageName = item->packageName;
- newitem->destination = item->destination;
- newitem->recreateLinks = item->recreateLinks;
-
- if ( item->option == "I" )
+
+ newitem->option = item->option;
+ newitem->packageName = item->packageName;
+ newitem->destination = item->destination;
+ newitem->recreateLinks = item->recreateLinks;
+ packages.append( newitem );
+
+ if ( item->option == "I" )
{
- installList.append( newitem );
install.append( QString( " %1\n" ).arg( item->packageName ) );
}
else if ( item->option == "D" )
{
- removeList.append( newitem );
remove.append( QString( " %1\n" ).arg( item->packageName ) );
}
else if ( item->option == "U" || item->option == "R" )
{
- updateList.append( newitem );
- QString type;
- if ( item->option == "R" )
- type = tr( "(ReInstall)" );
- else
- type = tr( "(Upgrade)" );
- upgrade.append( QString( " %1 %2\n" ).arg( item->packageName ).arg( type ) );
- }
- }
- output->setText( QString( "%1\n%2\n%3\n" ).arg( remove ).arg( install ).arg( upgrade ) );
+ QString type;
+ if ( item->option == "R" )
+ type = tr( "(ReInstall)" );
+ else
+ type = tr( "(Upgrade)" );
+ upgrade.append( QString( " %1 %2\n" ).arg( item->packageName ).arg( type ) );
+ }
+ }
- displayAvailableSpace( destination->currentText() );
+ output->setText( QString( "%1\n%2\n%3\n" ).arg( remove ).arg( install ).arg( upgrade ) );
+
+ displayAvailableSpace( destination->currentText() );
}
InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title )
: QWidget( 0, 0, 0 )
{
setCaption( title );
init( FALSE );
pIpkg = ipkg;
output->setText( initialText );
}
@@ -259,48 +258,54 @@ void InstallDlgImpl :: installSelected()
// Disable buttons
btnOptions->setEnabled( false );
// btnInstall->setEnabled( false );
btnInstall->setText( tr( "Abort" ) );
btnInstall->setIconSet( Resource::loadPixmap( "close" ) );
if ( pIpkg )
{
output->setText( "" );
connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
+ connect( pIpkg, SIGNAL(ipkgFinished()), this, SLOT(ipkgFinished()));
pIpkg->runIpkg();
}
else
{
output->setText( "" );
Destination *d = dataMgr->getDestination( destination->currentText() );
QString dest = d->getDestinationName();
QString destDir = d->getDestinationPath();
int instFlags = flags;
if ( d->linkToRoot() )
instFlags |= MAKE_LINKS;
#ifdef QWS
// Save settings
Config cfg( "aqpkg" );
cfg.setGroup( "settings" );
cfg.writeEntry( "dest", dest );
#endif
pIpkg = new Ipkg;
connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
+ connect( pIpkg, SIGNAL(ipkgFinished()), this, SLOT(ipkgFinished()));
+
+ firstPackage = TRUE;
+ ipkgFinished();
// First run through the remove list, then the install list then the upgrade list
- pIpkg->setOption( "remove" );
+/*
+ pIpkg->setOption( "remove" );
QListIterator<InstallData> it( removeList );
InstallData *idata;
for ( ; it.current(); ++it )
{
idata = it.current();
pIpkg->setDestination( idata->destination->getDestinationName() );
pIpkg->setDestinationDir( idata->destination->getDestinationPath() );
pIpkg->setPackage( idata->packageName );
int tmpFlags = flags;
if ( idata->destination->linkToRoot() )
tmpFlags |= MAKE_LINKS;
@@ -333,36 +338,26 @@ void InstallDlgImpl :: installSelected()
pIpkg->setDestinationDir( idata->destination->getDestinationPath() );
pIpkg->setPackage( idata->packageName );
int tmpFlags = flags;
if ( idata->destination->linkToRoot() && idata->recreateLinks )
tmpFlags |= MAKE_LINKS;
pIpkg->setFlags( tmpFlags, infoLevel );
pIpkg->runIpkg();
}
delete pIpkg;
pIpkg = 0;
+*/
}
-
- btnOptions->setEnabled( true );
-// btnInstall->setEnabled( true );
- btnInstall->setText( tr( "Close" ) );
- btnInstall->setIconSet( Resource::loadPixmap( "enter" ) );
-
- btnOptions->setText( tr( "Save output" ) );
- btnOptions->setIconSet( Resource::loadPixmap( "save" ) );
-
- if ( destination && destination->currentText() != 0 && destination->currentText() != "" )
- displayAvailableSpace( destination->currentText() );
}
void InstallDlgImpl :: displayText(const QString &text )
{
QString newtext = QString( "%1\n%2" ).arg( output->text() ).arg( text );
/* Set a max line count for the QMultiLineEdit, as users have reported
* performance issues when line count gets extreme.
*/
if(output->numLines() >= MAXLINES)
output->removeLine(0);
@@ -391,12 +386,81 @@ void InstallDlgImpl :: displayAvailableSpace( const QString &text )
long avail = availBlocks * mult / div;
// long used = total - avail;
space.sprintf( "%ld Kb", avail );
}
else
space = tr( "Unknown" );
if ( txtAvailableSpace )
txtAvailableSpace->setText( space );
}
+void InstallDlgImpl :: ipkgFinished()
+{
+ InstallData *item;
+ if ( firstPackage )
+ item = packages.first();
+ else
+ {
+ // Create symlinks if necessary before moving on to next package
+ pIpkg->createSymLinks();
+
+ item = packages.next();
+ }
+
+ firstPackage = FALSE;
+ if ( item )
+ {
+ pIpkg->setPackage( item->packageName );
+ int tmpFlags = flags;
+
+ if ( item->option == "I" )
+ {
+ pIpkg->setOption( "install" );
+ Destination *d = dataMgr->getDestination( destination->currentText() );
+ pIpkg->setDestination( d->getDestinationName() );
+ pIpkg->setDestinationDir( d->getDestinationPath() );
+
+ if ( d->linkToRoot() )
+ tmpFlags |= MAKE_LINKS;
+ }
+ else if ( item->option == "D" )
+ {
+ pIpkg->setOption( "remove" );
+ pIpkg->setDestination( item->destination->getDestinationName() );
+ pIpkg->setDestinationDir( item->destination->getDestinationPath() );
+
+ if ( item->destination->linkToRoot() )
+ tmpFlags |= MAKE_LINKS;
+ }
+ else
+ {
+ if ( item->option == "R" )
+ pIpkg->setOption( "reinstall" );
+ else
+ pIpkg->setOption( "upgrade" );
+
+ pIpkg->setDestination( item->destination->getDestinationName() );
+ pIpkg->setDestinationDir( item->destination->getDestinationPath() );
+ pIpkg->setPackage( item->packageName );
+
+ tmpFlags |= FORCE_REINSTALL;
+ if ( item->destination->linkToRoot() && item->recreateLinks )
+ tmpFlags |= MAKE_LINKS;
+ }
+ pIpkg->setFlags( tmpFlags, infoLevel );
+ pIpkg->runIpkg();
+ }
+ else
+ {
+ btnOptions->setEnabled( true );
+ btnInstall->setText( tr( "Close" ) );
+ btnInstall->setIconSet( Resource::loadPixmap( "enter" ) );
+
+ btnOptions->setText( tr( "Save output" ) );
+ btnOptions->setIconSet( Resource::loadPixmap( "save" ) );
+
+ if ( destination && destination->currentText() != 0 && destination->currentText() != "" )
+ displayAvailableSpace( destination->currentText() );
+ }
+} \ No newline at end of file
diff --git a/noncore/settings/aqpkg/installdlgimpl.h b/noncore/settings/aqpkg/installdlgimpl.h
index 15cf427..9a7dbff 100644
--- a/noncore/settings/aqpkg/installdlgimpl.h
+++ b/noncore/settings/aqpkg/installdlgimpl.h
@@ -36,51 +36,51 @@ class InstallData
{
public:
QString option; // I - install, D - delete, R- reinstall U - upgrade
QString packageName;
Destination *destination;
bool recreateLinks;
};
class InstallDlgImpl : public QWidget
{
Q_OBJECT
public:
- InstallDlgImpl( QList<InstallData> &packageList, DataManager *dataManager, const char *title = 0 );
+ InstallDlgImpl( const QList<InstallData> &packageList, DataManager *dataManager, const char *title = 0 );
InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title = 0 );
~InstallDlgImpl();
bool upgradeServer( QString &server );
protected:
private:
DataManager *dataMgr;
- QList<InstallData> installList;
- QList<InstallData> removeList;
- QList<InstallData> updateList;
+ QList<InstallData> packages;
+ bool firstPackage;
int flags;
int infoLevel;
Ipkg *pIpkg;
bool upgradePackages;
QComboBox *destination;
QPushButton *btnInstall;
QPushButton *btnOptions;
QMultiLineEdit *output;
QLabel *txtAvailableSpace;
void init( bool );
bool runIpkg( QString &option, const QString& package, const QString& dest, int flags );
signals:
void reloadData( InstallDlgImpl * );
public slots:
void optionsSelected();
void installSelected();
void displayText(const QString &text );
void displayAvailableSpace( const QString &text);
+ void ipkgFinished();
};
#endif
diff --git a/noncore/settings/aqpkg/ipkg.cpp b/noncore/settings/aqpkg/ipkg.cpp
index e906653..34999ad 100644
--- a/noncore/settings/aqpkg/ipkg.cpp
+++ b/noncore/settings/aqpkg/ipkg.cpp
@@ -46,28 +46,27 @@ Ipkg :: ~Ipkg()
{
}
// Option is what we are going to do - install, upgrade, download, reinstall
// package is the package name to install - either a fully qualified path and ipk
// file (if stored locally) or just the name of the package (for a network package)
// packageName is the package name - (for a network package this will be the same as
// package parameter)
// dest is the destination alias (from ipk.conf)
// destDir is the dir that the destination alias points to (used to link to root)
// flags is the ipkg options flags
// dir is the directory to run ipkg in (defaults to "")
-bool Ipkg :: runIpkg( )
+void Ipkg :: runIpkg()
{
error = false;
- bool ret = false;
QStringList commands;
QDir::setCurrent( "/tmp" );
if ( runtimeDir != "" )
{
commands << "cd ";
commands << runtimeDir;
commands << ";";
}
commands << "ipkg" << "-V" << QString::number( infoLevel ) << "-force-defaults";
@@ -128,29 +127,30 @@ bool Ipkg :: runIpkg( )
if ( flags & MAKE_LINKS )
{
emit outputText( QString( "Removing symbolic links...\n" ) );
linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir );
emit outputText( QString( " " ) );
}
}
// Execute command
dependantPackages = new QList<QString>;
dependantPackages->setAutoDelete( true );
- ret = executeIpkgCommand( commands, option );
+ executeIpkgCommand( commands, option );
- if ( aborted )
- return false;
+}
+void Ipkg :: createSymLinks()
+{
if ( option == "install" || option == "reinstall" || option == "upgrade" )
{
// If we are not removing packages and make links option is selected
// create the links
createLinks = true;
if ( flags & MAKE_LINKS )
{
emit outputText( " " );
emit outputText( QString( "Creating symbolic links for " )+ package );
linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir );
@@ -162,25 +162,24 @@ bool Ipkg :: runIpkg( )
continue;
emit outputText( " " );
emit outputText( QString( "Creating symbolic links for " )+ (*pkg) );
linkPackage( Utils::getPackageNameFromIpkFilename( *pkg ), destination, destDir );
}
}
}
delete dependantPackages;
emit outputText( "Finished" );
emit outputText( "" );
- return ret;
}
void Ipkg :: removeStatusEntry()
{
QString statusFile = destDir;
if ( statusFile.right( 1 ) != "/" )
statusFile.append( "/" );
statusFile.append( "usr/lib/ipkg/status" );
QString outStatusFile = statusFile;
outStatusFile.append( ".tmp" );
emit outputText( "" );
@@ -286,28 +285,24 @@ int Ipkg :: executeIpkgCommand( QStringList &cmd, const QString /*option*/ )
for ( QStringList::Iterator it = cmd.begin(); it != cmd.end(); ++it )
{
*proc << (*it).latin1();
}
// Start the process going
finished = false;
if(!proc->start(OProcess::NotifyOnExit, OProcess::All))
{
emit outputText( QString( "Couldn't start ipkg process" ) );
}
-
- // Now wait for it to finish
- while ( !finished )
- qApp->processEvents();
}
void Ipkg::commandStdout(OProcess*, char *buffer, int buflen)
{
QString lineStr = buffer;
if ( lineStr[buflen-1] == '\n' )
buflen --;
lineStr = lineStr.left( buflen );
emit outputText( lineStr );
// check if we are installing dependant packages
if ( option == "install" || option == "reinstall" )
@@ -345,24 +340,26 @@ void Ipkg::commandStderr(OProcess*, char *buffer, int buflen)
void Ipkg::processFinished()
{
// Finally, if we are removing a package, remove its entry from the <destdir>/usr/lib/ipkg/status file
// to workaround an ipkg bug which stops reinstall to a different location
if ( !error && option == "remove" )
removeStatusEntry();
delete proc;
proc = 0;
finished = true;
+
+ emit ipkgFinished();
}
void Ipkg :: abort()
{
if ( proc )
{
proc->kill();
aborted = true;
}
}
diff --git a/noncore/settings/aqpkg/ipkg.h b/noncore/settings/aqpkg/ipkg.h
index 531bfc0..a0d38e3 100644
--- a/noncore/settings/aqpkg/ipkg.h
+++ b/noncore/settings/aqpkg/ipkg.h
@@ -34,35 +34,37 @@
#define FORCE_OVERWRITE 0x0008
#define MAKE_LINKS 0x0010
#define VERBOSE_WGET 0x0020
class OProcess;
class Ipkg : public QObject
{
Q_OBJECT
public:
Ipkg();
~Ipkg();
- bool runIpkg( );
+ void runIpkg();
+ void createSymLinks();
void setOption( const char *opt ) { option = opt; }
void setPackage( const char *pkg ) { package = pkg; }
void setDestination( const char *dest ) { destination = dest; }
void setDestinationDir( const char *dir ) { destDir = dir; }
void setFlags( int fl, int il ) { flags = fl; infoLevel = il; }
void setRuntimeDirectory( const char *dir ) { runtimeDir = dir; }
signals:
void outputText( const QString &text );
+ void ipkgFinished();
public slots:
void commandStdout(OProcess*, char *buffer, int buflen);
void commandStderr(OProcess*, char *buffer, int buflen);
void processFinished();
void abort();
private:
bool createLinks;
bool aborted;
bool error;
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp
index 1aec6a8..58f6feb 100644
--- a/noncore/settings/aqpkg/mainwin.cpp
+++ b/noncore/settings/aqpkg/mainwin.cpp
@@ -288,25 +288,25 @@ void MainWindow :: init()
connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) );
mgr->loadServers();
showUninstalledPkgs = false;
showInstalledPkgs = false;
showUpgradedPkgs = false;
categoryFilterEnabled = false;
updateData();
stack->raiseWidget( networkPkgWindow );
}
-/*
+
void MainWindow :: setDocument( const QString &doc )
{
// Remove path from package
QString package = Utils::getPackageNameFromIpkFilename( doc );
// std::cout << "Selecting package " << package << std::endl;
// First select local server
for ( int i = 0 ; i < serversList->count() ; ++i )
{
if ( serversList->text( i ) == LOCAL_IPKGS )
{
serversList->setCurrentItem( i );
@@ -318,25 +318,25 @@ void MainWindow :: setDocument( const QString &doc )
// 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( package ) )
{
item->setOn( true );
break;
}
}
}
-*/
+
void MainWindow :: displaySettings()
{
SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true );
if ( dlg->showDlg() )
{
stack->raiseWidget( progressWindow );
updateData();
stack->raiseWidget( networkPkgWindow );
}
delete dlg;
}
@@ -983,32 +983,32 @@ InstallData *MainWindow :: dealWithItem( QCheckListItem *item )
// Get package
Server *s = mgr->getServer( serversList->currentText() );
Package *p = s->getPackage( name );
// If the package has a filename then it is a local file
if ( p->isPackageStoredLocally() )
name = p->getFilename();
QString option;
QString dest = "root";
if ( !p->isInstalled() )
{
- InstallData *newitem = new InstallData();;
+ InstallData *newitem = new InstallData();
newitem->option = "I";
newitem->packageName = name;
return newitem;
}
else
{
- InstallData *newitem = new InstallData();;
+ InstallData *newitem = new InstallData();
newitem->option = "D";
if ( !p->isPackageStoredLocally() )
newitem->packageName = p->getInstalledPackageName();
else
newitem->packageName = name;
if ( p->getInstalledTo() )
{
newitem->destination = p->getInstalledTo();
// cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl;
// cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl;
}
diff --git a/noncore/settings/aqpkg/mainwin.h b/noncore/settings/aqpkg/mainwin.h
index 0295519..c4548b1 100644
--- a/noncore/settings/aqpkg/mainwin.h
+++ b/noncore/settings/aqpkg/mainwin.h
@@ -97,25 +97,25 @@ private:
void downloadSelectedPackages();
void downloadRemotePackage();
InstallData *dealWithItem( QCheckListItem *item );
// Progress widget
QWidget *progressWindow;
QLabel *m_status;
QProgressBar *m_progress;
void initProgressWidget();
public slots:
-// void setDocument( const QString &doc );
+ void setDocument( const QString &doc );
void displayFindBar();
void displayJumpBar();
void repeatFind();
void findPackage( const QString & );
void hideFindBar();
void hideJumpBar();
void displaySettings();
void filterUninstalledPackages();
void filterInstalledPackages();
void filterUpgradedPackages();
void filterCategory();
bool setFilterCategory();