author | tille <tille> | 2002-04-25 21:06:23 (UTC) |
---|---|---|
committer | tille <tille> | 2002-04-25 21:06:23 (UTC) |
commit | 054b0f3268189d6f8f06135960042a7f51117223 (patch) (side-by-side diff) | |
tree | 2ab5eef44d4e6604d6c0a45e51608390c8b3a521 /noncore/unsupported/oipkg/pmipkg.cpp | |
parent | c06667cd62b945a05edce621aab34358ee0e964f (diff) | |
download | opie-054b0f3268189d6f8f06135960042a7f51117223.zip opie-054b0f3268189d6f8f06135960042a7f51117223.tar.gz opie-054b0f3268189d6f8f06135960042a7f51117223.tar.bz2 |
installation messages working
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 @@ -1,9 +1,8 @@ #include "pmipkg.h" #include "pkdesc.h" -#include "pkfind.h" #include "pksettings.h" #include "package.h" #include "packagelistitem.h" #include <qpe/process.h> #include <qpe/resource.h> @@ -14,31 +13,28 @@ #include <qfile.h> #include <qmultilineedit.h> #include <qstring.h> #include <qtextstream.h> #include <qtextview.h> +#include <qprogressbar.h> +#include <qpushbutton.h> +#include <qlayout.h> + #include <stdlib.h> #include <unistd.h> #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 ) { 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 ); } PmIpkg::~PmIpkg() { } @@ -70,20 +66,23 @@ int PmIpkg::runIpkg(const QString& args) #ifdef SYSTEM QString redirect = "/tmp/oipkg.pipe"; cmd += " | tee "+redirect+" 2>&1"; pvDebug(2, "running >"+cmd+"<"); r = system(cmd.latin1()); 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; } } f.close(); out( "Finished!<br>"); #endif @@ -93,84 +92,69 @@ int PmIpkg::runIpkg(const QString& args) void PmIpkg::makeLinks(QString pack) { pvDebug( 2, "PmIpkg::makeLinks "+ pack); out( "<br>creating links<br>" ); QString dest = settings->getDestinationUrl(); 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 { Config cfg( "oipkg", Config::User ); cfg.setGroup( "Common" ); QString statusDir = cfg.readEntry( "statusDir", "" ); } QString fn = dest+"/"+statusDir+"/info/"+pack+".list"; QFile f( fn ); if ( ! f.open(IO_ReadOnly) ) { out( "<b>Panik!</b> Could not open:<br>"+fn ); }; -#endif QTextStream t( &f ); QString fp; while ( !t.eof() ) { fp = t.readLine(); processLinkDir( fp, dest ); } f.close(); } 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 ); if ( fileInfo.isDir() ) { QDir destDir( destFile ); destDir.mkdir( destFile, true ); QDir d( file ); d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks ); const QFileInfoList *list = d.entryInfoList(); QFileInfoListIterator it( *list ); QFileInfo *fi; while ( (fi=it.current()) ) { - out( "<b>"+fi->absFilePath()+"</b>" ); + // out( "<b>"+fi->absFilePath()+"</b>" ); processLinkDir( fi->absFilePath(), dest ); ++it; } } else if ( fileInfo.isFile() ) { const char *instFile = strdup( (file).ascii() ); const char *linkFile = strdup( (destFile).ascii()); - out( "linking: "+file+" -> "+destFile ); +// out( "linking: "+file+" -> "+destFile ); qDebug( "linking: %s -> %s", instFile, linkFile ); symlink( instFile, linkFile ); } } 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"); QString rem="<b>To remove:</b><br>\n"; QString inst="<b>To install:</b><br>\n";; for( Package *pack = pl.first();pack ; (pack = pl.next()) ) { if ( pack && (pack->name() != "") && pack) @@ -185,40 +169,76 @@ void PmIpkg::commit( PackageList pl ) to_remove.append( pack->name() ); rem += pack->name()+"<br>"; } } } - out("<p>"+inst+"</p>"+"<p>"+rem+"</p>"); - bool ok=TRUE; + out("<p>"+inst+"</p>"+"<p>"+rem+"</p><hl>"); qDebug("to remove=%i; to install=%i",to_remove.count(),to_install.count()); - 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() ) for (QStringList::ConstIterator it=to_install.begin(); it!=to_install.end(); ++it) { if ( runIpkg("install " + *it) == 0 ) { if ( settings->createLinks() ) makeLinks( *it ); }else{ - ok = false; + out("<b>"+tr("Error while installing")+"</b>"+*it); } } - // ##### 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; } void PmIpkg::linkDestination( const QString msg, const QByteArray dest ) // add 3rd package parameter { qDebug("msg="+msg+" -- "+QString(dest) ); @@ -233,15 +253,45 @@ void PmIpkg::linkDestination( const QString msg, const QByteArray dest ) // ++it; // } } void PmIpkg::update() { - runwindow->showMaximized(); + show( false ); runIpkg( "update" ); + runwindow->close(); } 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(); } |