author | tille <tille> | 2002-04-23 22:41:02 (UTC) |
---|---|---|
committer | tille <tille> | 2002-04-23 22:41:02 (UTC) |
commit | f90935204b16126b40d4c562b26e37148ca03536 (patch) (side-by-side diff) | |
tree | 40a3e25d9e5078a3871ae7ba5b1fb86245ead187 /noncore | |
parent | ab7037fb8c10cc2ee37a3728caab7d4da4cdc1b3 (diff) | |
download | opie-f90935204b16126b40d4c562b26e37148ca03536.zip opie-f90935204b16126b40d4c562b26e37148ca03536.tar.gz opie-f90935204b16126b40d4c562b26e37148ca03536.tar.bz2 |
fixes: update and link creation
-rw-r--r-- | noncore/unsupported/oipkg/TODO | 6 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/main.cpp | 4 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/mainwindow.cpp | 26 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/mainwindow.h | 2 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/oipkg.pro | 4 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/package.cpp | 2 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/packagelist.cpp | 7 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/packagelist.h | 2 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/pksettingsbase.ui | 8 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/pmipkg.cpp | 178 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/pmipkg.h | 18 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/runwindow.ui | 4 |
12 files changed, 157 insertions, 104 deletions
diff --git a/noncore/unsupported/oipkg/TODO b/noncore/unsupported/oipkg/TODO index 714baa4..d81e873 100644 --- a/noncore/unsupported/oipkg/TODO +++ b/noncore/unsupported/oipkg/TODO @@ -1,8 +1,10 @@ * search -* parse "to install" and "to remove" from status * Settings Class +* make oipkg determine dest of "to remove" apps +* tr() ;) * Dialog to display ipkg output live +* parse "to install" and "to remove" from status * install local file -* make oipkg determine dest of to remove apps +* install to dest with click on packet * error handling * manage links diff --git a/noncore/unsupported/oipkg/main.cpp b/noncore/unsupported/oipkg/main.cpp index 264fd55..4af59b0 100644 --- a/noncore/unsupported/oipkg/main.cpp +++ b/noncore/unsupported/oipkg/main.cpp @@ -7,8 +7,8 @@ int debugLevel; int main( int argc, char ** argv ) { - debugLevel = 1; - if (argc > 2) + debugLevel = 2; + if (argc > 0) { debugLevel = QString ( argv[1] ).toInt(); } diff --git a/noncore/unsupported/oipkg/mainwindow.cpp b/noncore/unsupported/oipkg/mainwindow.cpp index b485a03..cb2b4cd 100644 --- a/noncore/unsupported/oipkg/mainwindow.cpp +++ b/noncore/unsupported/oipkg/mainwindow.cpp @@ -51,7 +51,7 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f = 0 ) : ipkg = new PmIpkg( settings, this ); packageList.setSettings( settings ); - newList(); + getList(); setSections(); setSubSections(); displayList(); @@ -66,6 +66,13 @@ void MainWindow::makeMenu() QPopupMenu *cfgMenu = new QPopupMenu( menuBar ); // QPopupMenu *sectMenu = new QPopupMenu( menuBar ); +//#define TOOLBAR +#ifdef TOOLBAR + QPEToolBar *secBar = new QPEToolBar( this ); + QComboBox *sections = new QComboBox( false, this ); + secBar->addTo( sections ); +#endif + contextMenu = new QPopupMenu( this ); setToolBarsMovable( false ); @@ -134,19 +141,20 @@ MainWindow::~MainWindow() void MainWindow::runIpkg() { ipkg->commit( packageList ); - ipkg->runIpkg("update"); - packageList.update(); + updateList(); } void MainWindow::updateList() { - ipkg->runIpkg("update"); - packageList.update(); + // todo: packageList.clear(); + ipkg->update(); + getList(); } -void MainWindow::newList() +void MainWindow::getList() { packageList.update(); + displayList(); } void MainWindow::filterList() @@ -217,17 +225,17 @@ void MainWindow::setSubSections() void MainWindow::showSettings() { if ( settings->showDialog( 0 ) ) - newList(); + getList(); } void MainWindow::showSettingsSrv() { if ( settings->showDialog( 1 ) ) - newList(); + getList(); } void MainWindow::showSettingsDst() { if ( settings->showDialog( 2 ) ) - newList(); + getList(); } diff --git a/noncore/unsupported/oipkg/mainwindow.h b/noncore/unsupported/oipkg/mainwindow.h index 77604fd..95dcc90 100644 --- a/noncore/unsupported/oipkg/mainwindow.h +++ b/noncore/unsupported/oipkg/mainwindow.h @@ -28,7 +28,7 @@ protected: protected slots: void runIpkg(); - void newList(); + void getList(); void updateList(); void filterList(); void displayList(); diff --git a/noncore/unsupported/oipkg/oipkg.pro b/noncore/unsupported/oipkg/oipkg.pro index 04230f5..c61af0f 100644 --- a/noncore/unsupported/oipkg/oipkg.pro +++ b/noncore/unsupported/oipkg/oipkg.pro @@ -1,7 +1,7 @@ DESTDIR = $(OPIEDIR)/bin TEMPLATE = app -CONFIG = qt warn_on release -#CONFIG = qt warn_on debug +#CONFIG = qt warn_on release +CONFIG = qt warn_on debug HEADERS = mainwindow.h \ pksettings.h \ pmipkg.h \ diff --git a/noncore/unsupported/oipkg/package.cpp b/noncore/unsupported/oipkg/package.cpp index 82ea1c8..e317308 100644 --- a/noncore/unsupported/oipkg/package.cpp +++ b/noncore/unsupported/oipkg/package.cpp @@ -156,7 +156,7 @@ bool Package::toInstall() void Package::toggleProcess() { - _toProcess = !(_toProcess); + _toProcess = ! _toProcess; } diff --git a/noncore/unsupported/oipkg/packagelist.cpp b/noncore/unsupported/oipkg/packagelist.cpp index d72ef75..5f6934d 100644 --- a/noncore/unsupported/oipkg/packagelist.cpp +++ b/noncore/unsupported/oipkg/packagelist.cpp @@ -205,11 +205,12 @@ void PackageList::update() pvDebug( 3, "finished parsing"); } - - -/** No descriptions */ void PackageList::setSettings( PackageManagerSettings *s ) { settings = s; } +Package* PackageList::getByName( QString n ) +{ + origPackageList[n]; +} diff --git a/noncore/unsupported/oipkg/packagelist.h b/noncore/unsupported/oipkg/packagelist.h index eda8d22..68b89f0 100644 --- a/noncore/unsupported/oipkg/packagelist.h +++ b/noncore/unsupported/oipkg/packagelist.h @@ -26,6 +26,8 @@ public: QStringList getSubSections(); void setSettings( PackageManagerSettings* ); void filterPackages(); + /** No descriptions */ + Package* getByName( QString ); public slots: void setSection(QString); diff --git a/noncore/unsupported/oipkg/pksettingsbase.ui b/noncore/unsupported/oipkg/pksettingsbase.ui index 2efd2f3..ea507a8 100644 --- a/noncore/unsupported/oipkg/pksettingsbase.ui +++ b/noncore/unsupported/oipkg/pksettingsbase.ui @@ -11,7 +11,7 @@ <rect> <x>0</x> <y>0</y> - <width>357</width> + <width>353</width> <height>454</height> </rect> </property> @@ -298,7 +298,7 @@ </property> <property stdset="1"> <name>enabled</name> - <bool>true</bool> + <bool>false</bool> </property> <property stdset="1"> <name>text</name> @@ -317,7 +317,7 @@ </property> <property stdset="1"> <name>enabled</name> - <bool>true</bool> + <bool>false</bool> </property> <property stdset="1"> <name>text</name> @@ -332,7 +332,7 @@ </property> <property stdset="1"> <name>enabled</name> - <bool>true</bool> + <bool>false</bool> </property> <property stdset="1"> <name>text</name> diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp index 528365e..681f2d4 100644 --- a/noncore/unsupported/oipkg/pmipkg.cpp +++ b/noncore/unsupported/oipkg/pmipkg.cpp @@ -24,70 +24,81 @@ PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlags f ) - : RunWindow ( p, name, f ) - // : QObject ( p ) +// : RunWindow ( p, name, f ) + : QObject ( p ) { settings = s; - + runwindow = new RunWindow ( p, name, f ); linkDest = new QCopChannel( "QPE/MakeLinks", this ); connect( linkDest, SIGNAL(received(const QCString &, const QByteArray &)), - this, SLOT(linkDestination( const QString &, const QString&)) ); + this, SLOT(linkDestination( const QString &, const QByteArray&)) ); } PmIpkg::~PmIpkg() { } +//#define PROC +#define SYSTEM int PmIpkg::runIpkg(const QString& args) { - pvDebug(4,"PmIpkg::runIpkg"); + pvDebug(2,"PmIpkg::runIpkg "+args); +#ifdef PROC + QStringList cmd = "/usr/bin/ipkg "; +#endif +#ifdef SYSTEM QString cmd = "/usr/bin/ipkg "; +#endif cmd += " -dest "+settings->getDestinationName(); - cmd += " -force-defaults "; - - outPut->setText( outPut->text()+"<br><br>Starting to "+ args+"<br>\n"); - QString redirect = "/tmp/ipkg.pipe"; - cmd += args+" | tee "+redirect+" 2>&1&"; - - outPut->setText( outPut->text() + "running:<br>\n"+cmd+"<br>\n" ); - pvDebug( 0, "Execute >"+cmd+"<" ); - int r = system(cmd.latin1()); + cmd += " -force-defaults "; + + out( "Starting to "+ args+"<br>\n"); + cmd += args; + out( "running:<br>\n"+cmd+"<br>\n" ); + int r = 0; +#ifdef PROC + QString o = "start"; + Process ipkg( cmd ); + QString description; + ipkg.exec("",o); + out( o ); +#endif +#ifdef SYSTEM + QString redirect = "/tmp/oipkg.pipe"; + cmd += " | tee "+redirect+" 2>&1"; + r = system(cmd.latin1()); QFile f( redirect ); - if ( f.open(IO_ReadOnly) ) { + while ( ! f.open(IO_ReadOnly) ) {}; + // if ( f.open(IO_ReadOnly) ) {}; + { QTextStream t( &f ); QString fp; while ( !t.eof() ) - { - outPut->setText( outPut->text() + t.readLine() +"\n<br>" ); - } - } - f.close(); - outPut->setText( outPut->text() + "\n<br><br>Finished!"); - outPut->setContentsPos(0,outPut->contentsHeight()); - - if ( r == 0 ) { - QString param = args.left( args.find(" ") ); - QString file = args.right( args.length() - args.find(" ") ); - if ( param == "install" && settings->createLinks() ) - makeLinks( file); + out( t.readLine() +"<br>" ); } + } + f.close(); + out( "Finished!<br>"); +#endif return r; } void PmIpkg::makeLinks(QString file) { - outPut->setText( outPut->text() + "<br>creating links<br>" ); + out( "<br>creating links<br>" ); QString dest = settings->getDestinationUrl(); - system(("ipkg -d "+dest+" files "+file+"> /tmp/oipkg.pipe").latin1()); + out("for package "+file+" in "+dest+"<br>"); + system(("ipkg -d "+dest+" files "+file+"> /tmp/oipkg.pipe 2>&1").latin1()); QFile f( "/tmp/oipkg.pipe" ); - if ( ! f.open(IO_ReadOnly) )return; + while ( ! f.open(IO_ReadOnly) ) {}; QTextStream t( &f ); QString fp; while ( !t.eof() ) { - processLinkDir( t.readLine(), dest ); + fp = t.readLine(); + processLinkDir( fp, dest ); } f.close(); } @@ -96,39 +107,42 @@ void PmIpkg::processLinkDir( QString file, QString dest ) { QString destFile = file.right( file.length() - dest.length() ); QFileInfo fileInfo( file ); - if ( fileInfo.isFile() ) - { - const char *instFile = strdup( (file).ascii() ); - const char *linkFile = strdup( (destFile).ascii()); - outPut->setText( outPut->text() + "linking: "+file+" -> "+destFile ); - symlink( instFile, linkFile ); - } 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()) ) { - 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()) ) { - processLinkDir( fi->absFilePath(), dest ); - ++it; - } + 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 ); + qDebug( "linking: %s -> %s", instFile, linkFile ); + symlink( instFile, linkFile ); + } } void PmIpkg::commit( PackageList pl ) { - showMaximized(); - exec(); - outPut->setText( "<b>Starting...</b><br>\n"); + runwindow->showMaximized(); +// exec(); + runwindow->outPut->setText(""); + out( "<h1>Starting...</h1><br>\n"); QStringList to_remove, to_install; - QString rem="To remove:<br>\n"; - QString inst="To install:<br>\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) @@ -136,17 +150,17 @@ void PmIpkg::commit( PackageList pl ) if ( pack->toInstall() ) { to_install.append( pack->name() ); - inst += pack->name()+"\n"; + inst += pack->name()+"<br>"; } if ( pack->toRemove() ) { to_remove.append( pack->name() ); - rem += pack->name()+"\n"; + rem += pack->name()+"<br>"; } } } - outPut->setText( outPut->text()+inst+rem); + out("<p>"+inst+"</p>"+"<p>"+rem+"</p>"); bool ok=TRUE; qDebug("to remove=%i; to install=%i",to_remove.count(),to_install.count()); @@ -159,7 +173,15 @@ void PmIpkg::commit( PackageList pl ) if ( runIpkg("remove " + *it) != 0 ) ok = false; if ( to_install.count() ) for (QStringList::ConstIterator it=to_install.begin(); it!=to_install.end(); ++it) - if ( runIpkg("install " + *it) != 0 ) ok = false; + { + if ( runIpkg("install " + *it) == 0 ) + { + if ( settings->createLinks() ) + makeLinks( *it ); + }else{ + ok = false; + } + } // ##### 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". @@ -168,16 +190,30 @@ void PmIpkg::commit( PackageList pl ) e << lf; } -void PmIpkg::linkDestination( QString src, QString dest ) +void PmIpkg::linkDestination( const QString msg, const QByteArray dest ) +// add 3rd package parameter { - QDir d( src ); - d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks ); - if (! d.exists() ) return; - const QFileInfoList *list = d.entryInfoList(); - QFileInfoListIterator it( *list ); - QFileInfo *fi; - while ( (fi=it.current()) ) { - processLinkDir( fi->absFilePath(), dest ); - ++it; - } + qDebug("msg="+msg+" -- "+QString(dest) ); +// QDir d( src ); +// d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks ); +//// if (! d.exists() ) return; +// const QFileInfoList *list = d.entryInfoList(); +// QFileInfoListIterator it( *list ); +// QFileInfo *fi; +// while ( (fi=it.current()) ) { +// processLinkDir( fi->absFilePath(), dest ); +// ++it; +// } +} + +void PmIpkg::update() +{ + runwindow->showMaximized(); + runIpkg( "update" ); +} + +void PmIpkg::out( QString o ) +{ + runwindow->outPut->setText( runwindow->outPut->text()+o ); + runwindow->outPut->setContentsPos(0,runwindow->outPut->contentsHeight()); } diff --git a/noncore/unsupported/oipkg/pmipkg.h b/noncore/unsupported/oipkg/pmipkg.h index 98efaa6..e6486ff 100644 --- a/noncore/unsupported/oipkg/pmipkg.h +++ b/noncore/unsupported/oipkg/pmipkg.h @@ -10,11 +10,13 @@ #include "packagelist.h" #include "debug.h" +//#define DIA #include <qpe/qcopenvelope_qws.h> -class PmIpkg : public RunWindow -//class PmIpkg : public QObject + +//class PmIpkg : public RunWindow +class PmIpkg : public QObject { Q_OBJECT public: @@ -22,21 +24,23 @@ public: // PmIpkg( QObject*, PackageManagerSettings* ); ~PmIpkg(); + void commit( PackageList ); + void update(); PackageList* getPackageList(); private: PackageManagerSettings* settings; + RunWindow *runwindow; QCopChannel *linkDest; - void processLinkDir( QString, QString ); - -public: void makeLinks(QString); + void processLinkDir( QString, QString ); + int runIpkg(const QString& args); - void commit( PackageList ); + void out( QString ); public slots: - void linkDestination( QString, QString ); + void linkDestination( const QString, const QByteArray ); }; #endif diff --git a/noncore/unsupported/oipkg/runwindow.ui b/noncore/unsupported/oipkg/runwindow.ui index 23f58cf..9113f2d 100644 --- a/noncore/unsupported/oipkg/runwindow.ui +++ b/noncore/unsupported/oipkg/runwindow.ui @@ -11,7 +11,7 @@ <rect> <x>0</x> <y>0</y> - <width>201</width> + <width>197</width> <height>291</height> </rect> </property> @@ -42,7 +42,7 @@ </property> <property stdset="1"> <name>progress</name> - <number>0</number> + <number>42</number> </property> </widget> <widget row="1" column="0" > |