summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/oipkg/TODO6
-rw-r--r--noncore/unsupported/oipkg/main.cpp4
-rw-r--r--noncore/unsupported/oipkg/mainwindow.cpp26
-rw-r--r--noncore/unsupported/oipkg/mainwindow.h2
-rw-r--r--noncore/unsupported/oipkg/oipkg.pro4
-rw-r--r--noncore/unsupported/oipkg/package.cpp2
-rw-r--r--noncore/unsupported/oipkg/packagelist.cpp7
-rw-r--r--noncore/unsupported/oipkg/packagelist.h2
-rw-r--r--noncore/unsupported/oipkg/pksettingsbase.ui8
-rw-r--r--noncore/unsupported/oipkg/pmipkg.cpp178
-rw-r--r--noncore/unsupported/oipkg/pmipkg.h18
-rw-r--r--noncore/unsupported/oipkg/runwindow.ui4
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
@@ -1,19 +1,19 @@
#include "mainwindow.h"
#include <qpe/qpeapplication.h>
#include <qstring.h>
int debugLevel;
int main( int argc, char ** argv )
{
- debugLevel = 1;
- if (argc > 2)
+ debugLevel = 2;
+ if (argc > 0)
{
debugLevel = QString ( argv[1] ).toInt();
}
QPEApplication a( argc, argv );
MainWindow mw;
a.showMainDocumentWidget( &mw );
return a.exec();
}
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
@@ -6,259 +6,267 @@
#include <qpe/qpemenubar.h>
#include <qpe/qpemessagebox.h>
#include <qpe/resource.h>
#include <qpe/qpetoolbar.h>
#include <qaction.h>
#include <qmessagebox.h>
#include <qpopupmenu.h>
#include <qtoolbutton.h>
#include <qstring.h>
#include <qlistview.h>
#include <qtextview.h>
#include <qtabwidget.h>
#include <qcombobox.h>
#include <qlayout.h>
#include "pksettingsbase.h"
#include "packagelistitem.h"
MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f = 0 ) :
QMainWindow( parent, name, f )
{
setCaption( tr("Package Manager") );
table = new PackageWindow( this,0,0 );
setCentralWidget( table );
makeMenu();
QFontMetrics fm = fontMetrics();
int w0 = fm.width(tr("Package"))+30;
int w2 = fm.width("00000")+4;
table->ListViewPackages->setColumnWidth(0,w0);
table->ListViewPackages->setColumnWidth(1,228-w2-w0); // ### screen-biased
table->ListViewPackages->setColumnWidth(2,w2);
table->ListViewPackages->setColumnWidthMode(0,QListView::Manual);
table->ListViewPackages->setColumnWidthMode(1,QListView::Manual);
table->ListViewPackages->setColumnWidthMode(2,QListView::Manual);
table->ListViewPackages->setSelectionMode( QListView::Multi );
connect( table->section, SIGNAL( activated(int) ),
this, SLOT( sectionChanged() ) );
connect( table->subsection, SIGNAL(activated(int) ),
this, SLOT( subSectionChanged() ) );
connect( table->ListViewPackages, SIGNAL( clicked( QListViewItem* ) ),
this, SLOT( setCurrent( QListViewItem* ) ) );
settings = new PackageManagerSettings(this,0,TRUE);
ipkg = new PmIpkg( settings, this );
packageList.setSettings( settings );
- newList();
+ getList();
setSections();
setSubSections();
displayList();
}
void MainWindow::makeMenu()
{
QPEToolBar *toolBar = new QPEToolBar( this );
QPEMenuBar *menuBar = new QPEMenuBar( toolBar );
QPopupMenu *srvMenu = new QPopupMenu( menuBar );
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 );
toolBar->setHorizontalStretchable( true );
menuBar->insertItem( tr( "Package" ), srvMenu );
menuBar->insertItem( tr( "Settings" ), cfgMenu );
// menuBar->insertItem( tr( "Sections" ), sectMenu );
toolBar->setStretchableWidget (srvMenu);
runAction = new QAction( tr( "Run" ),
Resource::loadPixmap( "oipkg/install" ),
QString::null, 0, this, 0 );
connect( runAction, SIGNAL( activated() ),
this, SLOT( runIpkg() ) );
runAction->addTo( toolBar );
runAction->addTo( srvMenu );
srvMenu->insertSeparator ();
updateAction = new QAction( tr( "Update" ),
Resource::loadIconSet( "oipkg/repeat" ),
QString::null, 0, this, 0 );
connect( updateAction, SIGNAL( activated() ),
this , SLOT( updateList() ) );
updateAction->addTo( toolBar );
updateAction->addTo( srvMenu );
// detailsAction = new QAction( tr( "Details" ),
// Resource::loadIconSet( "oipkg/details" ),
// QString::null, 0, this, 0 );
// connect( detailsAction, SIGNAL( activated() ),
// this , SLOT( showDetails() ) );
// detailsAction->addTo( toolBar );
// detailsAction->addTo( srvMenu );
QAction *cfgact;
cfgact = new QAction( tr( "Setups" ),
Resource::loadIconSet( "" ),
QString::null, 0, this, 0 );
connect( cfgact, SIGNAL( activated() ),
SLOT( showSettings() ) );
cfgact->addTo( cfgMenu );
cfgact = new QAction( tr( "Servers" ),
Resource::loadIconSet( "" ),
QString::null, 0, this, 0 );
connect( cfgact, SIGNAL( activated() ),
SLOT( showSettingsSrv() ) );
cfgact->addTo( cfgMenu );
cfgact = new QAction( tr( "Destinations" ),
Resource::loadIconSet( "" ),
QString::null, 0, this, 0 );
connect( cfgact, SIGNAL( activated() ),
SLOT( showSettingsDst() ) );
cfgact->addTo( cfgMenu );
}
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()
{
packageList.filterPackages();
}
void MainWindow::displayList()
{
table->ListViewPackages->clear();
Package *pack = packageList.first();
while( pack )
{
if ( pack && (pack->name() != "") )
{
table->ListViewPackages->insertItem(
new PackageListItem( table->ListViewPackages, pack ) );
}
pack = packageList.next();
}
}
void MainWindow::sectionChanged()
{
disconnect( table->section, SIGNAL( activated(int) ),
this, SLOT( sectionChanged() ) );
disconnect( table->subsection, SIGNAL(activated(int) ),
this, SLOT( subSectionChanged() ) );
table->subsection->clear();
packageList.setSection( table->section->currentText() );
setSubSections();
filterList();
connect( table->section, SIGNAL( activated(int) ),
this, SLOT( sectionChanged() ) );
connect( table->subsection, SIGNAL(activated(int) ),
this, SLOT( subSectionChanged() ) );
displayList();
}
void MainWindow::subSectionChanged()
{
disconnect( table->section, SIGNAL( activated(int) ),
this, SLOT( sectionChanged() ) );
disconnect( table->subsection, SIGNAL(activated(int) ),
this, SLOT( subSectionChanged() ) );
packageList.setSubSection( table->subsection->currentText() );
filterList();
connect( table->section, SIGNAL( activated(int) ),
this, SLOT( sectionChanged() ) );
connect( table->subsection, SIGNAL(activated(int) ),
this, SLOT( subSectionChanged() ) );
displayList();
}
void MainWindow::setSections()
{
table->section->clear();
table->section->insertStringList( packageList.getSections() );
}
void MainWindow::setSubSections()
{
table->subsection->clear();
table->subsection->insertStringList( packageList.getSubSections() );
}
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();
}
void MainWindow::showDetails()
{
if ( activePackage ) return;
if ( details )
{
details = new PackageDetails( this );
connect( details->install, SIGNAL(clicked()), SLOT( toggleActivePackage() ) );
connect( details->remove, SIGNAL(clicked()), SLOT( toggleActivePackage() ) );
connect( details->ignore, SIGNAL(clicked()), details, SLOT(close()));
details->description->setTextFormat(RichText);
}
details->setCaption("Package: " + activePackage->name());
details->description->setText(activePackage->details() );
details->install->setEnabled(!activePackage->installed());
details->remove->setEnabled(activePackage->installed());
details->showMaximized();
}
void MainWindow::toggleActivePackage()
{
activePackage->toggleProcess();
if ( details ) details->close();
}
void MainWindow::setCurrent( QListViewItem* p )
{
pvDebug(2, "MainWindow::setCurrent ");
//+((Package*)p)->name());
activePackage = (Package*)p;
}
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
@@ -1,62 +1,62 @@
#ifndef MAINWINDOW_H
#define MAINWINDOW_H
#include <qmainwindow.h>
#include <qaction.h>
#include <qpopupmenu.h>
#include "packagelist.h"
#include "pmipkg.h"
#include "pksettings.h"
#include "pkdesc.h"
#include "pkwindow.h"
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
~MainWindow();
protected:
PackageWindow *table;
protected slots:
void runIpkg();
- void newList();
+ void getList();
void updateList();
void filterList();
void displayList();
void subSectionChanged();
void sectionChanged();
void showSettings();
void showSettingsSrv();
void showSettingsDst();
public slots:
void showDetails();
void toggleActivePackage();
void setCurrent( QListViewItem* );
private:
void makeMenu();
void setSections();
void setSubSections();
PmIpkg* ipkg;
PackageManagerSettings *settings;
PackageDetails* details;
PackageList packageList;
Package *activePackage;
QAction *runAction;
QAction *detailsAction;
QAction *updateAction;
QPopupMenu *contextMenu;
};
#endif
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,27 +1,27 @@
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 \
packagelistitem.h \
packagelist.h \
package.h
SOURCES = main.cpp \
mainwindow.cpp \
pksettings.cpp \
pmipkg.cpp \
packagelistitem.cpp \
packagelist.cpp \
package.cpp
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
LIBS += -lqpe
INTERFACES = pkdesc.ui \
pkfind.ui \
runwindow.ui \
pkwindow.ui \
pksettingsbase.ui
TARGET = oipkg
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
@@ -111,97 +111,97 @@ QString Package::name()
return _name;
}
bool Package::installed()
{
return _status.contains("installed");
}
void Package::setDesc( QString s )
{
_desc = s;
_shortDesc = s.left( s.find("\n") );
}
QString Package::desc()
{
return _desc;
}
QString Package::shortDesc()
{
return _shortDesc;
}
QString Package::size()
{
return _size;
}
bool Package::toProcess()
{
return _toProcess;
}
bool Package::toRemove()
{
if ( _toProcess && installed() ) return true;
else return false;
}
bool Package::toInstall()
{
if ( _toProcess && !installed() ) return true;
else return false;
}
void Package::toggleProcess()
{
- _toProcess = !(_toProcess);
+ _toProcess = ! _toProcess;
}
void Package::copyValues( Package* pack )
{
if (_size.isEmpty() && !pack->_size.isEmpty()) _size = QString( pack->_size );
if (_section.isEmpty() && !pack->_section.isEmpty()) _section = QString( pack->_section );
if (_subsection.isEmpty()&& !pack->_subsection.isEmpty()) _subsection = QString( pack->_subsection );
if (_shortDesc.isEmpty() && !pack->_shortDesc.isEmpty()) _shortDesc = QString( pack->_shortDesc );
if (_desc.isEmpty() && !pack->_desc.isEmpty()) _desc = QString( pack->_desc );
if (_name.isEmpty() && !pack->_name.isEmpty()) _name = QString( pack->_name );
if (!installed() && _status.isEmpty() && !pack->_status.isEmpty()) _status = QString( pack->_status );
}
QString Package::getSection()
{
return _section;
}
void Package::setSection( QString s)
{
int i = s.find("/");
if ( i > 0 )
{
_section = s.left(i);
_subsection = s.mid(i+1);
}else{
_section = s;
_subsection = "";
}
}
QString Package::getSubSection()
{
return _subsection;
}
void Package::parsePackage( QStringList pack )
{
if ( pack.isEmpty() ) return;
int count = pack.count();
for( int i = 0; i < count; i++ )
{
QString line = pack[i];
int sep = line.find( QRegExp(":[\t ]+") );
if ( sep >= 0 )
{
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
@@ -160,56 +160,57 @@ void PackageList::parseList()
{
QStringList srvs = settings->getActiveServers();
for ( QStringList::Iterator it = srvs.begin(); it != srvs.end(); ++it )
{
pvDebug( 2, "List Dir: "+listsDir+"/"+*it);
readFileEntries( listsDir+"/"+*it );
}
}
void PackageList::readFileEntries( QString filename )
{
QStringList packEntry;
QFile f( filename );
if ( !f.open(IO_ReadOnly) ) return;
QTextStream *statusStream = new QTextStream( &f );
while ( !statusStream ->eof() )
{
QString line = statusStream->readLine();
if ( line.find(QRegExp("[\n\t ]*")) || line == "" )
{
//end of package
if ( ! packEntry.isEmpty() )
{
Package *p = new Package( packEntry );
if ( p )
{
insertPackage( p );
packEntry.clear();
}
}
}else{
packEntry << line;
};
}
return;
}
void PackageList::update()
{
pvDebug( 3, "parseStatus");
parseStatus();
pvDebug( 3, "parseList");
parseList();
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
@@ -1,63 +1,65 @@
#ifndef PACKAGELIST_H
#define PACKAGELIST_H
#include <qdict.h>
#include "package.h"
#include "pksettings.h"
#include "debug.h"
#define HACK
#ifdef HACK
static QString listsDir="/usr/lib/ipkg/";
static QString statusDir="/usr/lib/ipkg/";
#endif
class PackageList {
public:
PackageList();
PackageList( PackageManagerSettings* );
~PackageList();
void insertPackage( Package* );
Package* find( QString );
Package* next();
Package* first();
QStringList getSections();
QStringList getSubSections();
void setSettings( PackageManagerSettings* );
void filterPackages();
+ /** No descriptions */
+ Package* getByName( QString );
public slots:
void setSection(QString);
void setSubSection(QString);
void update();
private:
int currentPackage;
int packageCount;
PackageManagerSettings *settings;
QDict<Package> packageList;
QDict<Package> origPackageList;
QDictIterator<Package> packageIter;
bool empty;
#ifndef HACK
QString listsDir;
QString statusDir;
#endif
QString aktSection;
QString aktSubSection;
QStringList sections;
QDict<QStringList> subSections;
QDict<bool> sectionsDict;
void updateSections( Package* );
void parseStatus();
void parseList();
void readFileEntries( QString );
};
#endif
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
@@ -1,62 +1,62 @@
<!DOCTYPE UI><UI>
<class>PackageManagerSettingsBase</class>
<widget>
<class>QDialog</class>
<property stdset="1">
<name>name</name>
<cstring>Form4</cstring>
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>0</x>
<y>0</y>
- <width>357</width>
+ <width>353</width>
<height>454</height>
</rect>
</property>
<property stdset="1">
<name>caption</name>
<string>Package Servers</string>
</property>
<property>
<name>layoutMargin</name>
</property>
<property>
<name>layoutSpacing</name>
</property>
<grid>
<property stdset="1">
<name>margin</name>
<number>3</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>3</number>
</property>
<widget row="0" column="0" >
<class>QTabWidget</class>
<property stdset="1">
<name>name</name>
<cstring>TabWidget</cstring>
</property>
<property stdset="1">
<name>enabled</name>
<bool>true</bool>
</property>
<property>
<name>layoutMargin</name>
</property>
<property>
<name>layoutSpacing</name>
</property>
<widget>
<class>QWidget</class>
<property stdset="1">
<name>name</name>
<cstring>tab</cstring>
</property>
<attribute>
<name>title</name>
<string>Settings</string>
</attribute>
@@ -253,131 +253,131 @@
</property>
<property stdset="1">
<name>selectionMode</name>
<enum>Multi</enum>
</property>
</widget>
<widget row="1" column="0" >
<class>QComboBox</class>
<property stdset="1">
<name>name</name>
<cstring>settingName</cstring>
</property>
<property stdset="1">
<name>enabled</name>
<bool>true</bool>
</property>
<property stdset="1">
<name>focusPolicy</name>
<enum>NoFocus</enum>
</property>
<property stdset="1">
<name>editable</name>
<bool>false</bool>
</property>
</widget>
<widget row="2" column="0" >
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Layout11</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>newsetting</cstring>
</property>
<property stdset="1">
<name>enabled</name>
- <bool>true</bool>
+ <bool>false</bool>
</property>
<property stdset="1">
<name>text</name>
<string>New</string>
</property>
<property stdset="1">
<name>autoDefault</name>
<bool>false</bool>
</property>
</widget>
<widget>
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>renamesetting</cstring>
</property>
<property stdset="1">
<name>enabled</name>
- <bool>true</bool>
+ <bool>false</bool>
</property>
<property stdset="1">
<name>text</name>
<string>Rename</string>
</property>
</widget>
<widget>
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>removesetting</cstring>
</property>
<property stdset="1">
<name>enabled</name>
- <bool>true</bool>
+ <bool>false</bool>
</property>
<property stdset="1">
<name>text</name>
<string>Remove</string>
</property>
<property stdset="1">
<name>autoDefault</name>
<bool>false</bool>
</property>
</widget>
</hbox>
</widget>
</grid>
</widget>
<widget>
<class>QWidget</class>
<property stdset="1">
<name>name</name>
<cstring>tab</cstring>
</property>
<attribute>
<name>title</name>
<string>Servers</string>
</attribute>
<grid>
<property stdset="1">
<name>margin</name>
<number>3</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>3</number>
</property>
<widget row="3" column="0" rowspan="1" colspan="2" >
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>Layout4</cstring>
</property>
<grid>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
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
@@ -1,183 +1,219 @@
#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>
#include <qpe/stringutil.h>
#include <qpe/qcopenvelope_qws.h>
#include <qdir.h>
#include <qfile.h>
#include <qmultilineedit.h>
#include <qstring.h>
#include <qtextstream.h>
#include <qtextview.h>
#include <stdlib.h>
#include <unistd.h>
#include "mainwindow.h"
#include "runwindow.h"
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();
}
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)
{
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());
int jobs = to_remove.count()+to_install.count();
if ( jobs < 1 ) return;
if ( to_remove.count() )
for (QStringList::ConstIterator it=to_remove.begin(); it!=to_remove.end(); ++it)
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".
QCopEnvelope e("QPE/System", "linkChanged(QString)");
QString lf = QString::null;
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
@@ -1,42 +1,46 @@
#ifndef PMIPKG_H
#define PMIPKG_H
#include <qobject.h>
#include <qstring.h>
#include <qwidget.h>
#include "pksettings.h"
#include "runwindow.h"
#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:
PmIpkg( PackageManagerSettings* , QWidget* p=0, const char * name=0, WFlags f=0 );
// 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
@@ -1,63 +1,63 @@
<!DOCTYPE UI><UI>
<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>201</width>
+ <width>197</width>
<height>291</height>
</rect>
</property>
<property stdset="1">
<name>caption</name>
<string>running...</string>
</property>
<property>
<name>layoutMargin</name>
</property>
<property>
<name>layoutSpacing</name>
</property>
<grid>
<property stdset="1">
<name>margin</name>
<number>5</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>2</number>
</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>
+ <number>42</number>
</property>
</widget>
<widget row="1" column="0" >
<class>QTextView</class>
<property stdset="1">
<name>name</name>
<cstring>outPut</cstring>
</property>
<property stdset="1">
<name>font</name>
<font>
<pointsize>6</pointsize>
</font>
</property>
</widget>
</grid>
</widget>
</UI>