Diffstat (limited to 'noncore/unsupported/oipkg/pmipkg.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/unsupported/oipkg/pmipkg.cpp | 142 |
1 files changed, 96 insertions, 46 deletions
diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp index b2ddf95..b23b9ea 100644 --- a/noncore/unsupported/oipkg/pmipkg.cpp +++ b/noncore/unsupported/oipkg/pmipkg.cpp @@ -2,3 +2,2 @@ #include "pkdesc.h" -#include "pkfind.h" #include "pksettings.h" @@ -19,2 +18,6 @@ +#include <qprogressbar.h> +#include <qpushbutton.h> +#include <qlayout.h> + #include <stdlib.h> @@ -23,10 +26,5 @@ #include "mainwindow.h" -#include "runwindow.h" - -#define PARSE_FILELIST -// #define IPKG_FILELIST PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlags f ) -// : RunWindow ( p, name, f ) : QObject ( p ) @@ -34,6 +32,4 @@ PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlag settings = s; - runwindow = new RunWindow ( p, name, f ); - linkDest = new QCopChannel( "QPE/oipkg", this ); - connect( linkDest, SIGNAL(received(const QCString &, const QByteArray &)), - this, SLOT(linkDestination( const QString &, const QByteArray&)) ); + runwindowopen = false; + runwindow = new RunWindow( p, name, true, f ); } @@ -75,10 +71,13 @@ int PmIpkg::runIpkg(const QString& args) QFile f( redirect ); + QString line; + QString oldLine; while ( ! f.open(IO_ReadOnly) ) {}; - // if ( f.open(IO_ReadOnly) ) {}; { QTextStream t( &f ); - QString fp; + // QString fp; while ( !t.eof() ) { - out( t.readLine() +"<br>" ); + line = t.readLine(); + if ( line != oldLine ) out( line +"<br>" ); + oldLine = line; } @@ -98,8 +97,2 @@ void PmIpkg::makeLinks(QString pack) out("for package "+pack+" in "+dest+"<br>"); -#ifdef IPKG_FILELIST - system(("ipkg -d "+dest+" files "+pack+"> /tmp/oipkg.pipe 2>&1").latin1()); - QFile f( "/tmp/oipkg.pipe" ); - while ( ! f.open(IO_ReadOnly) ) {}; -#endif -#ifdef PARSE_FILELIST { @@ -115,3 +108,2 @@ void PmIpkg::makeLinks(QString pack) }; -#endif QTextStream t( &f ); @@ -128,10 +120,4 @@ void PmIpkg::processLinkDir( QString file, QString dest ) { - -#ifdef PARSE_FILELIST QString destFile = file; file = dest+"/"+file; -#endif -#ifdef IPKG_FILELIST - QString destFile = file.right( file.length() - dest.length() ); -#endif QFileInfo fileInfo( file ); @@ -148,3 +134,3 @@ void PmIpkg::processLinkDir( QString file, QString dest ) { - out( "<b>"+fi->absFilePath()+"</b>" ); + // out( "<b>"+fi->absFilePath()+"</b>" ); processLinkDir( fi->absFilePath(), dest ); @@ -157,3 +143,3 @@ void PmIpkg::processLinkDir( QString file, QString dest ) const char *linkFile = strdup( (destFile).ascii()); - out( "linking: "+file+" -> "+destFile ); +// out( "linking: "+file+" -> "+destFile ); qDebug( "linking: %s -> %s", instFile, linkFile ); @@ -165,7 +151,5 @@ void PmIpkg::commit( PackageList pl ) { - runwindow->showMaximized(); -// exec(); + show( false ); runwindow->outPut->setText(""); - out( "<h1>Starting...</h1><br>\n"); - QStringList to_remove, to_install; + out( "<h1>"+tr("Todo")+"</h1>\n"); @@ -190,4 +174,3 @@ void PmIpkg::commit( PackageList pl ) - out("<p>"+inst+"</p>"+"<p>"+rem+"</p>"); - bool ok=TRUE; + out("<p>"+inst+"</p>"+"<p>"+rem+"</p><hl>"); @@ -195,8 +178,50 @@ void PmIpkg::commit( PackageList pl ) - int jobs = to_remove.count()+to_install.count(); - if ( jobs < 1 ) return; + connect( runwindow->doItButton, SIGNAL( clicked() ), + SLOT( doIt() ) ); + connect( runwindow->installButton, SIGNAL( clicked() ), + this, SLOT( install() ) ); + connect( runwindow->removeButton, SIGNAL( clicked() ), + this, SLOT( remove() ) ); + connect( runwindow->cancelButton, SIGNAL( clicked() ), + runwindow, SLOT( close() ) ); + + runwindow->exec(); + // ##### If we looked in the list of files, we could send out accurate + // ##### messages. But we don't bother yet, and just do an "all". + QCopEnvelope e("QPE/System", "linkChanged(QString)"); + QString lf = QString::null; + e << lf; + return; +} + +void PmIpkg::doIt() +{ + remove(); + install(); +} + - if ( to_remove.count() ) +void PmIpkg::remove() +{ + if ( to_remove.count() == 0 ) return; + show( true ); + + out("<hr><hr><b>"+tr("Removing")+"<br>"+tr("please wait")+"</b><br>"); for (QStringList::ConstIterator it=to_remove.begin(); it!=to_remove.end(); ++it) - if ( runIpkg("remove " + *it) != 0 ) ok = false; + { + if ( runIpkg("remove " + *it) == 0) + { + + }else{ + out("<b>"+tr("Error while removing")+"</b>"+*it); + } + } +} + + +void PmIpkg::install() +{ + if ( to_install.count() == 0 ) return; + show( true ); + out("<hr><hr><b>"+tr("Installing")+"<br>"+tr("please wait")+"<b><br>"); if ( to_install.count() ) @@ -209,3 +234,3 @@ void PmIpkg::commit( PackageList pl ) }else{ - ok = false; + out("<b>"+tr("Error while installing")+"</b>"+*it); } @@ -213,7 +238,2 @@ void PmIpkg::commit( PackageList pl ) - // ##### If we looked in the list of files, we could send out accurate - // ##### messages. But we don't bother yet, and just do an "all". - QCopEnvelope e("QPE/System", "linkChanged(QString)"); - QString lf = QString::null; - e << lf; } @@ -238,4 +258,5 @@ void PmIpkg::update() { - runwindow->showMaximized(); + show( false ); runIpkg( "update" ); + runwindow->close(); } @@ -245,3 +266,32 @@ void PmIpkg::out( QString o ) runwindow->outPut->setText( runwindow->outPut->text()+o ); - runwindow->outPut->setContentsPos(0,runwindow->outPut->contentsHeight()); + runwindow->outPut->setContentsPos(0, runwindow->outPut->contentsHeight()); +} + + +void PmIpkg::showButtons(bool b) +{ + if ( b ) + { + runwindow->cancelButton->hide(); + runwindow->doItButton->hide(); + runwindow->removeButton->hide(); + runwindow->installButton->hide(); + }else{ + runwindow->cancelButton->show(); + runwindow->doItButton->show(); + runwindow->removeButton->show(); + runwindow->installButton->show(); + + } +} + +void PmIpkg::show(bool b) +{ + if (!runwindow->isVisible()) + runwindow->showMaximized(); + showButtons(b); + if ( b ) + runwindow->progress->show(); + else + runwindow->progress->show(); } |