summaryrefslogtreecommitdiff
authortille <tille>2002-05-04 17:12:04 (UTC)
committer tille <tille>2002-05-04 17:12:04 (UTC)
commitd510e5a69762c8452b9d7b3d8122bc9fa85ed8b3 (patch) (side-by-side diff)
tree28b9871643caac8c975008677a2a058a62e8f201
parent4fe6b62e42697c68cd54ac3954ffc536e6f2c0f7 (diff)
downloadopie-d510e5a69762c8452b9d7b3d8122bc9fa85ed8b3.zip
opie-d510e5a69762c8452b9d7b3d8122bc9fa85ed8b3.tar.gz
opie-d510e5a69762c8452b9d7b3d8122bc9fa85ed8b3.tar.bz2
popen thanks to ljp
but still does not work from the launcher but only from the command line
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/oipkg/main.cpp6
-rw-r--r--noncore/unsupported/oipkg/mainwindow.cpp4
-rw-r--r--noncore/unsupported/oipkg/pmipkg.cpp153
-rw-r--r--noncore/unsupported/oipkg/pmipkg.h5
-rw-r--r--noncore/unsupported/oipkg/runwindow.ui118
5 files changed, 80 insertions, 206 deletions
diff --git a/noncore/unsupported/oipkg/main.cpp b/noncore/unsupported/oipkg/main.cpp
index d98bcaa..bb3d1db 100644
--- a/noncore/unsupported/oipkg/main.cpp
+++ b/noncore/unsupported/oipkg/main.cpp
@@ -1,24 +1,24 @@
#include "mainwindow.h"
#include <qpe/qpeapplication.h>
#include <qstring.h>
-#include <qmessagebox.h>
+//#include <qmessagebox.h>
int debugLevel;
int main( int argc, char ** argv )
{
debugLevel = 2;
if (argc > 1)
{
debugLevel = QString ( argv[1] ).toInt();
qDebug("setting debug level to %i",debugLevel);
}
QPEApplication a( argc, argv );
MainWindow mw;
- if (argc > 2)
- QMessageBox::information( &mw, "oipkg","While ipkg is working\noipkg is hanging.\nPlease be patient!");
+// if (argc > 2)
+// QMessageBox::information( &mw, "oipkg","While ipkg is working\noipkg is hanging.\nPlease be patient!");
a.showMainDocumentWidget( &mw );
return a.exec();
}
diff --git a/noncore/unsupported/oipkg/mainwindow.cpp b/noncore/unsupported/oipkg/mainwindow.cpp
index 55f915d..2fa91e3 100644
--- a/noncore/unsupported/oipkg/mainwindow.cpp
+++ b/noncore/unsupported/oipkg/mainwindow.cpp
@@ -84,26 +84,26 @@ void MainWindow::makeMenu()
QPopupMenu *viewMenu = new QPopupMenu( menuBar );
QPopupMenu *cfgMenu = new QPopupMenu( menuBar );
// QPopupMenu *sectMenu = new QPopupMenu( menuBar );
setToolBarsMovable( false );
toolBar->setHorizontalStretchable( true );
menuBar->insertItem( tr( "Package" ), srvMenu );
menuBar->insertItem( tr( "View" ), viewMenu );
menuBar->insertItem( tr( "Settings" ), cfgMenu );
// menuBar->insertItem( tr( "Sections" ), sectMenu );
QLabel *spacer = new QLabel( "", toolBar );
- spacer->setBackgroundColor( toolBar->backgroundColor() );
- toolBar->setStretchableWidget( spacer );
+// spacer->setBackgroundColor( toolBar->backgroundColor() );
+// toolBar->setStretchableWidget( spacer );
runAction = new QAction( tr( "Apply" ),
Resource::loadPixmap( "oipkg/install" ),
QString::null, 0, this, 0 );
connect( runAction, SIGNAL( activated() ),
this, SLOT( runIpkg() ) );
runAction->addTo( toolBar );
runAction->addTo( srvMenu );
srvMenu->insertSeparator ();
diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp
index 5996e63..75f93cf 100644
--- a/noncore/unsupported/oipkg/pmipkg.cpp
+++ b/noncore/unsupported/oipkg/pmipkg.cpp
@@ -1,21 +1,22 @@
#include "pmipkg.h"
#include "pksettings.h"
#include "package.h"
#include "packagelistitem.h"
#include <qpe/process.h>
#include <qpe/resource.h>
#include <qpe/config.h>
#include <qpe/stringutil.h>
+#include <qpe/qpeapplication.h>
#include <qdir.h>
#include <qfile.h>
#include <qgroupbox.h>
#include <qmultilineedit.h>
#include <qstring.h>
#include <qcheckbox.h>
#include <qtextstream.h>
#include <qtextview.h>
#include <qprogressbar.h>
#include <qpushbutton.h>
#include <qlayout.h>
@@ -28,115 +29,103 @@
PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlags f )
: QObject ( p )
{
settings = s;
runwindow = new RunWindow( p, name, true, f );
}
PmIpkg::~PmIpkg()
{
}
-//#define PROC
-#define SYSTEM
-#define QT_QPROCESS_DEBUG
-int PmIpkg::runIpkg(const QString& args, const QString& dest )
+bool PmIpkg::runIpkg(const QString& args, const QString& dest )
{
- pvDebug(2,"PmIpkg::runIpkg "+args);
+ bool ret=false;
QDir::setCurrent("/tmp");
-#ifdef PROC
- QString cmd;
-#endif
-#ifdef SYSTEM
QString cmd = "/usr/bin/ipkg ";
-#endif
pvDebug( 3,"PmIpkg::runIpkg got dest="+dest);
if ( dest == "" )
cmd += " -dest "+settings->getDestinationName();
else
cmd += " -dest "+ dest;
cmd += " -force-defaults ";
if (installDialog->_force_depends)
{
if (installDialog->_force_depends->isChecked())
cmd += " -force-depends ";
if (installDialog->_force_reinstall->isChecked())
cmd += " -force-reinstall ";
if (installDialog->_force_remove->isChecked())
cmd += " -force-removal-of-essential-packages ";
}
- out( "<hr><br>Starting to "+ args+"<br>\n");
+ out( "Starting to "+ args+"\n");
cmd += args;
- int r = 0;
-#ifdef PROC
- QString o = "start";
- Process *ipkg = new Process(QStringList() << "ipkg" << cmd );
- out( "running:<br>\n"+ipkg->arguments().join(" ")+"<br>\n" );
- QString description;
- r = ipkg->exec("",o);
- out( o );
-#endif
-#ifdef SYSTEM
- out( "running:<br>\n"+cmd+"<br>\n" );
- QString redirect = "/tmp/oipkg.pipe";
- cmd += " 2>&1 | tee "+redirect+" 2>&1";
- pvDebug(2, "running >"+cmd+"<");
- r = system(cmd.latin1());
- QFile f( redirect );
- QString line;
- QString oldLine;
- while ( ! f.open(IO_ReadOnly) ) {};
- QTextStream t( &f );
- while ( !t.eof() )
- {
- line = t.readLine();
- if ( line != oldLine )
- {
- out( line +"<br>" );
- oldLine = line;
- }
- }
- f.close();
- out( "Finished!<br>");
-#endif
-
- return r;
+ out( "running:\n"+cmd+"\n" );
+ pvDebug(2,"running:"+cmd);
+ qApp->processEvents();
+ FILE *fp;
+ char line[130];
+ QString lineStr, lineStrOld;
+ sleep(1);
+ cmd +=" 2>&1";
+ fp = popen( (const char *) cmd, "r");
+ if ( !fp ) {
+ qDebug("Could not execute '" + cmd + "'! err=%d", fp);
+ pclose(fp);
+ out("\nError while executing "+ cmd+"\n\n");
+ return false;
+ } else {
+ while ( fgets( line, sizeof line, fp)) {
+ lineStr = line;
+ lineStr=lineStr.left(lineStr.length()-1);
+ //Configuring opie-oipkg...Done
+ if (lineStr.contains("Done"))
+ ret = true;
+ if (lineStr!=lineStrOld)
+ out(lineStr);
+ lineStrOld = lineStr;
+ }
+ pclose(fp);
+ }
+ //out( "Finished!");
+ pvDebug(2,QString(ret?"success\n":"failure\n"));
+ return ret;
}
void PmIpkg::makeLinks(Package *pack)
{
pvDebug( 2, "PmIpkg::makeLinks "+ pack->name());
linkPackage( pack->name(), pack->dest() );
}
QStringList* PmIpkg::getList( QString packFileName, QString d )
{
QString dest = settings->getDestinationUrlByName( d );
dest = dest==""?d:dest;
if (dest == "/" ) return 0;
{
Config cfg( "oipkg", Config::User );
cfg.setGroup( "Common" );
QString statusDir = cfg.readEntry( "statusDir", "" );
}
packFileName = dest+"/"+statusDir+"/info/"+packFileName+".list";
QFile f( packFileName );
if ( ! f.open(IO_ReadOnly) )
{
pvDebug(1," Panik! Could not open");
- out( "<b>Panik!</b> Could not open:<br>"+packFileName );
+ out( "Panik!\n Could not open:\n"+packFileName );
return (QStringList*)0;
}
QStringList *fileList = new QStringList();
QTextStream t( &f );
while ( !t.eof() )
{
*fileList += t.readLine();
}
return fileList;
}
void PmIpkg::linkPackage( QString packFileName, QString dest )
@@ -234,95 +223,98 @@ void PmIpkg::commit()
{
sizecount += 1;
toRemoveItem->insertItem( new PackageListItem(installDialog->ListViewPackages, to_remove.at(i),settings) );
}
for (uint i=0; i < to_install.count(); i++)
{
sizecount += to_install.at(i)->size().toInt();
toInstallItem->insertItem( new PackageListItem(installDialog->ListViewPackages, to_install.at(i),settings) );
}
runwindow->progress->setTotalSteps(sizecount);
qDebug("Install size %i",sizecount);
installDialog->showMaximized();
+ installDialog->show();
if ( installDialog->exec() ) doIt();
installDialog->close();
runwindow->showMaximized();
- out(tr("<b>All done.</b>"));
+ runwindow->show();
+ out(tr("\nAll done."));
}
void PmIpkg::doIt()
{
- show( true );
+ runwindow->progress->setProgress(0);
+ show();
remove();
install();
}
void PmIpkg::remove()
{
if ( to_remove.count() == 0 ) return;
- out("<b>"+tr("Removing")+"<br>"+tr("please wait")+"</b><br><hr>");
+ out(tr("Removing")+"\n"+tr("please wait")+"\n\n");
QStringList *fileList;
for (uint i=0; i < to_remove.count(); i++)
{
if ( to_remove.at(i)->link() )fileList = getList( to_remove.at(i)->name(), to_remove.at(i)->dest() );
- if ( runIpkg("remove " + to_remove.at(i)->name(), to_remove.at(i)->dest() ) == 0)
+ if ( runIpkg("remove " + to_remove.at(i)->name(), to_remove.at(i)->dest() ))
{
runwindow->progress->setProgress( 1 );
linkOpp = removeLink;
if ( to_remove.at(i)->link() )
{
- out( "<br>removing links<br>" );
- out( "for package "+to_remove.at(i)->name()+" in "+to_remove.at(i)->dest()+"<br>" );
+ out( "\nremoving links\n" );
+ out( "for package "+to_remove.at(i)->name()+" in "+to_remove.at(i)->dest()+"\n" );
processFileList( fileList, to_remove.at(i)->dest() );
}
to_remove.at(i)->processed();
to_remove.take( i );
- out("<br><hr>");
+ out("\n\n");
}else{
- out("<b>"+tr("Error while removing")+"</b><hr>"+to_remove.at(i)->name());
+ out(tr("Error while removing")+to_remove.at(i)->name()+"\n");
}
if ( to_remove.at(i)->link() )delete fileList;
}
to_remove.clear();
- out("<br>");
+ out("\n");
}
void PmIpkg::install()
{
if ( to_install.count() == 0 ) return;
- out("<b>"+tr("Installing")+"<br>"+tr("please wait")+"</b><br>");
+ out(tr("Installing")+"\n"+tr("please wait")+"\n");
for (uint i=0; i < to_install.count(); i++)
{
- if ( runIpkg("install " + to_install.at(i)->installName(), to_install.at(i)->dest() ) == 0 )
+ if ( runIpkg("install " + to_install.at(i)->installName(), to_install.at(i)->dest() ))
{
runwindow->progress->setProgress( to_install.at(i)->size().toInt() + runwindow->progress->progress());
linkOpp = createLink;
if ( to_install.at(i)->link() )
{
- out( "<br>creating links<br>" );
- out( "for package "+to_install.at(i)->name()+" in "+to_install.at(i)->dest()+"<br>" );
+ out( "\ncreating links\n" );
+ out( "for package "+to_install.at(i)->name()+" in "+to_install.at(i)->dest()+"\n" );
makeLinks( to_install.at(i) );
}
to_install.at(i)->processed();
to_install.take( i );
- out("<br><hr>");
+ out("\n\n");
}else{
- out("<b>"+tr("Error while installing")+"</b><hr>"+to_install.at(i)->name());
+ out(tr("Error while installing")+to_install.at(i)->name()+"\n");
}
}
- out("<br>");
+ out("\n");
to_install.clear();
}
void PmIpkg::createLinks( const QString &dest )
{
pvDebug(2,"PmIpkg::createLinks "+dest);
linkOpp=createLink;
QString url = settings->getDestinationUrlByName( dest );
url = url==""?dest:url;
processLinkDir( "/opt", url );
processLinkDir( "/usr", url );
}
@@ -330,64 +322,51 @@ void PmIpkg::createLinks( const QString &dest )
void PmIpkg::removeLinks( const QString &dest )
{
pvDebug(2,"PmIpkg::removeLinks "+dest);
linkOpp=removeLink;
QString url = settings->getDestinationUrlByName( dest );
url = url==""?dest:url;
processLinkDir( "/opt", url );
processLinkDir( "/usr", url );
}
void PmIpkg::update()
{
- show( false );
+ show();
runIpkg( "update" );
runwindow->close();
}
void PmIpkg::out( QString o )
{
runwindow->outPut->append(o);
- //runwindow->outPut->setCursorPosition(0, runwindow->outPut->contentsHeight());
-// runwindow->outPut->setText( runwindow->outPut->text()+o );
- runwindow->outPut->setContentsPos(0, runwindow->outPut->contentsHeight());
+ runwindow->outPut->setCursorPosition(runwindow->outPut->numLines() + 1,0,FALSE);
}
-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)
+void PmIpkg::show()
{
if (!runwindow->isVisible())
+ {
runwindow->showMaximized();
- showButtons(b);
- if ( !b )
- runwindow->progress->hide();
- else
- runwindow->progress->show();
+ runwindow->show();
+ }
+ runwindow->outPut->setText("");
+// showButtons(b);
+// if ( !b )
+// runwindow->progress->hide();
+// else
+// runwindow->progress->show();
}
void PmIpkg::installFile(const QString &fileName, const QString &dest)
{
to_install.clear();
to_remove.clear();
pvDebug( 2,"PmIpkg::installFile "+ fileName);
Package *p = new Package(fileName,settings);
if ( dest!="") p->setDest( dest );
to_install.append( p );
commit();
diff --git a/noncore/unsupported/oipkg/pmipkg.h b/noncore/unsupported/oipkg/pmipkg.h
index 7bc62f1..f8ac39a 100644
--- a/noncore/unsupported/oipkg/pmipkg.h
+++ b/noncore/unsupported/oipkg/pmipkg.h
@@ -18,47 +18,46 @@
class Package;
class PmIpkg : public QObject
{
Q_OBJECT
public:
PmIpkg( PackageManagerSettings* , QWidget* p=0, const char * name=0, WFlags f=0 );
~PmIpkg();
int linkOpp;
void loadList( PackageList* );
void commit();
void update();
- void showButtons(bool b=true);
- void show( bool buttons=true );
+ void show();
public slots:
void doIt();
void install();
void remove();
void installFile(const QString &fileName, const QString &dest="");
void removeFile(const QString &fileName, const QString &dest="");
void createLinks( const QString &dest );
void removeLinks( const QString &dest );
private:
PackageManagerSettings* settings;
RunWindow *runwindow;
InstallDialog *installDialog;
QList<Package> to_remove;
QList<Package> to_install;
QString fileNameToInstall;
QCheckBox *_force_reinstall;
QCheckBox *_force_remove;
QCheckBox *_force_depends;
void startDialog();
void makeLinks(Package*);
void linkPackage( QString, QString );
void processLinkDir( QString , QString );
- int runIpkg(const QString& args, const QString& dest="" );
+ bool runIpkg(const QString& args, const QString& dest="" );
void out( QString );
QStringList* getList( QString, QString );
void processFileList( QStringList*, QString );
};
#endif
diff --git a/noncore/unsupported/oipkg/runwindow.ui b/noncore/unsupported/oipkg/runwindow.ui
index 8582ce8..839e151 100644
--- a/noncore/unsupported/oipkg/runwindow.ui
+++ b/noncore/unsupported/oipkg/runwindow.ui
@@ -2,25 +2,25 @@
<class>RunWindow</class>
<widget>
<class>QDialog</class>
<property stdset="1">
<name>name</name>
<cstring>RunWindow</cstring>
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>0</x>
<y>0</y>
- <width>344</width>
+ <width>340</width>
<height>442</height>
</rect>
</property>
<property stdset="1">
<name>caption</name>
<string>running...</string>
</property>
<property>
<name>layoutMargin</name>
</property>
<property>
<name>layoutSpacing</name>
@@ -36,136 +36,32 @@
</property>
<widget row="0" column="0" >
<class>QProgressBar</class>
<property stdset="1">
<name>name</name>
<cstring>progress</cstring>
</property>
<property stdset="1">
<name>progress</name>
<number>0</number>
</property>
</widget>
- <widget row="3" column="0" >
- <class>QLayoutWidget</class>
- <property stdset="1">
- <name>name</name>
- <cstring>buttons</cstring>
- </property>
- <hbox>
- <property stdset="1">
- <name>margin</name>
- <number>0</number>
- </property>
- <property stdset="1">
- <name>spacing</name>
- <number>6</number>
- </property>
- <widget>
- <class>QPushButton</class>
- <property stdset="1">
- <name>name</name>
- <cstring>doItButton</cstring>
- </property>
- <property stdset="1">
- <name>sizePolicy</name>
- <sizepolicy>
- <hsizetype>0</hsizetype>
- <vsizetype>0</vsizetype>
- </sizepolicy>
- </property>
- <property stdset="1">
- <name>font</name>
- <font>
- <pointsize>8</pointsize>
- </font>
- </property>
- <property stdset="1">
- <name>text</name>
- <string>Do all </string>
- </property>
- <property stdset="1">
- <name>autoResize</name>
- <bool>false</bool>
- </property>
- </widget>
- <widget>
- <class>QPushButton</class>
- <property stdset="1">
- <name>name</name>
- <cstring>installButton</cstring>
- </property>
- <property stdset="1">
- <name>font</name>
- <font>
- <pointsize>8</pointsize>
- </font>
- </property>
- <property stdset="1">
- <name>text</name>
- <string>Install</string>
- </property>
- <property stdset="1">
- <name>autoResize</name>
- <bool>true</bool>
- </property>
- </widget>
- <widget>
- <class>QPushButton</class>
- <property stdset="1">
- <name>name</name>
- <cstring>removeButton</cstring>
- </property>
- <property stdset="1">
- <name>font</name>
- <font>
- <pointsize>7</pointsize>
- </font>
- </property>
- <property stdset="1">
- <name>text</name>
- <string>Remove</string>
- </property>
- <property stdset="1">
- <name>autoResize</name>
- <bool>true</bool>
- </property>
- </widget>
- <widget>
- <class>QPushButton</class>
- <property stdset="1">
- <name>name</name>
- <cstring>cancelButton</cstring>
- </property>
- <property stdset="1">
- <name>font</name>
- <font>
- <pointsize>8</pointsize>
- </font>
- </property>
- <property stdset="1">
- <name>text</name>
- <string>Cancel</string>
- </property>
- <property stdset="1">
- <name>autoResize</name>
- <bool>true</bool>
- </property>
- </widget>
- </hbox>
- </widget>
<widget row="1" column="0" >
- <class>QTextView</class>
+ <class>QMultiLineEdit</class>
<property stdset="1">
<name>name</name>
<cstring>outPut</cstring>
</property>
<property stdset="1">
<name>font</name>
<font>
- <pointsize>6</pointsize>
+ <pointsize>8</pointsize>
</font>
</property>
+ <property stdset="1">
+ <name>wordWrap</name>
+ <enum>WidgetWidth</enum>
+ </property>
</widget>
</grid>
</widget>
</UI>