summaryrefslogtreecommitdiff
path: root/noncore
Side-by-side diff
Diffstat (limited to 'noncore') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/oipkg/.cvsignore11
-rw-r--r--noncore/unsupported/oipkg/TODO8
-rw-r--r--noncore/unsupported/oipkg/debug.h20
-rw-r--r--noncore/unsupported/oipkg/main.cpp19
-rw-r--r--noncore/unsupported/oipkg/mainwindow.cpp264
-rw-r--r--noncore/unsupported/oipkg/mainwindow.h62
-rw-r--r--noncore/unsupported/oipkg/oipkg.pro28
-rw-r--r--noncore/unsupported/oipkg/opie-oipkg.control9
-rw-r--r--noncore/unsupported/oipkg/package.cpp255
-rw-r--r--noncore/unsupported/oipkg/package.h54
-rw-r--r--noncore/unsupported/oipkg/packagelist.cpp215
-rw-r--r--noncore/unsupported/oipkg/packagelist.h63
-rw-r--r--noncore/unsupported/oipkg/packagelistitem.cpp97
-rw-r--r--noncore/unsupported/oipkg/packagelistitem.h31
-rw-r--r--noncore/unsupported/oipkg/pkdesc.ui96
-rw-r--r--noncore/unsupported/oipkg/pkfind.ui51
-rw-r--r--noncore/unsupported/oipkg/pksettings.cpp487
-rw-r--r--noncore/unsupported/oipkg/pksettings.h62
-rw-r--r--noncore/unsupported/oipkg/pksettingsbase.ui744
-rw-r--r--noncore/unsupported/oipkg/pkwindow.ui147
-rw-r--r--noncore/unsupported/oipkg/pmipkg.cpp183
-rw-r--r--noncore/unsupported/oipkg/pmipkg.h42
-rw-r--r--noncore/unsupported/oipkg/runwindow.ui63
-rw-r--r--noncore/unsupported/oipkg/settings.cpp436
-rw-r--r--noncore/unsupported/oipkg/settings.h62
25 files changed, 3501 insertions, 8 deletions
diff --git a/noncore/unsupported/oipkg/.cvsignore b/noncore/unsupported/oipkg/.cvsignore
index 36653ed..9d22b66 100644
--- a/noncore/unsupported/oipkg/.cvsignore
+++ b/noncore/unsupported/oipkg/.cvsignore
@@ -1,10 +1,5 @@
+.cvsignore
Makefile*
moc_*
-pkfind.cpp
-pkfind.h
-pksettings.cpp
-pksettings.h
-pkdesc.cpp
-pkdesc.h
-packagemanagerbase.cpp
-packagemanagerbase.h
+*~
+*.kdev*
diff --git a/noncore/unsupported/oipkg/TODO b/noncore/unsupported/oipkg/TODO
new file mode 100644
index 0000000..714baa4
--- a/dev/null
+++ b/noncore/unsupported/oipkg/TODO
@@ -0,0 +1,8 @@
+* search
+* parse "to install" and "to remove" from status
+* Settings Class
+* Dialog to display ipkg output live
+* install local file
+* make oipkg determine dest of to remove apps
+* error handling
+* manage links
diff --git a/noncore/unsupported/oipkg/debug.h b/noncore/unsupported/oipkg/debug.h
new file mode 100644
index 0000000..c53e36c
--- a/dev/null
+++ b/noncore/unsupported/oipkg/debug.h
@@ -0,0 +1,20 @@
+#ifndef _DEBUG_H_
+#define _DEBUG_H_
+
+#include <stdio.h>
+
+extern int debugLevel;
+
+#define HACK
+
+
+#define pvDebug(I, S) \
+if ( debugLevel < 3 ) \
+{ \
+ if ( I <= debugLevel ) qDebug(S);\
+}else{\
+ if ( I <= debugLevel ) \
+ printf("# %s \t\t(Level: %i)\n",QString(S).latin1(),I);\
+}
+
+#endif \ No newline at end of file
diff --git a/noncore/unsupported/oipkg/main.cpp b/noncore/unsupported/oipkg/main.cpp
new file mode 100644
index 0000000..264fd55
--- a/dev/null
+++ b/noncore/unsupported/oipkg/main.cpp
@@ -0,0 +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 = 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
new file mode 100644
index 0000000..b485a03
--- a/dev/null
+++ b/noncore/unsupported/oipkg/mainwindow.cpp
@@ -0,0 +1,264 @@
+// adadpted form qpe/qipkg
+
+
+#include "mainwindow.h"
+
+#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();
+ 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 );
+
+ 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();
+}
+
+void MainWindow::updateList()
+{
+ ipkg->runIpkg("update");
+ packageList.update();
+}
+
+void MainWindow::newList()
+{
+ packageList.update();
+}
+
+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();
+}
+void MainWindow::showSettingsSrv()
+{
+ if ( settings->showDialog( 1 ) )
+ newList();
+}
+void MainWindow::showSettingsDst()
+{
+ if ( settings->showDialog( 2 ) )
+ newList();
+}
+
+
+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
new file mode 100644
index 0000000..77604fd
--- a/dev/null
+++ b/noncore/unsupported/oipkg/mainwindow.h
@@ -0,0 +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 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
new file mode 100644
index 0000000..9c2cb8d
--- a/dev/null
+++ b/noncore/unsupported/oipkg/oipkg.pro
@@ -0,0 +1,28 @@
+DESTDIR = $(OPIEDIR)/bin
+TEMPLATE = app
+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
+LIBS += -ljpeg
+INTERFACES = pkdesc.ui \
+ pkfind.ui \
+ runwindow.ui \
+ pkwindow.ui \
+ pksettingsbase.ui
+TARGET = oipkg
+
diff --git a/noncore/unsupported/oipkg/opie-oipkg.control b/noncore/unsupported/oipkg/opie-oipkg.control
new file mode 100644
index 0000000..89cc0b4
--- a/dev/null
+++ b/noncore/unsupported/oipkg/opie-oipkg.control
@@ -0,0 +1,9 @@
+Files: bin/oipkg apps/Settings/oipkg.desktop pics/oipkg/
+Priority: optional
+Section: opie/settings
+Maintainer: Patrick S. Vogt <tille@almana.ch>
+Architecture: arm
+Version: $QPE_VERSION-$SUB_VERSION
+Depends: opie-base ($QPE_VERSION)
+Description: Package Manager
+ A GUI front-end to ipkg for the Opie environment.
diff --git a/noncore/unsupported/oipkg/package.cpp b/noncore/unsupported/oipkg/package.cpp
new file mode 100644
index 0000000..82ea1c8
--- a/dev/null
+++ b/noncore/unsupported/oipkg/package.cpp
@@ -0,0 +1,255 @@
+#include "package.h"
+
+#include <qpe/process.h>
+#include <qpe/stringutil.h>
+
+#include "debug.h"
+
+Package::~Package()
+{
+}
+
+Package::Package()
+{
+ _size = "";
+ _section = "";
+ _subsection = "";
+ _shortDesc = "";
+ _desc = "";
+ _name = "";
+ _toProcess = true;
+ _status = "";
+}
+
+Package::Package( QStringList pack )
+{
+ Package();
+ parsePackage( pack );
+ _toProcess = false;
+}
+
+Package::Package( QString n )
+{
+ Package();
+ _name = QString( n );
+ _toProcess = false;
+}
+
+Package::Package( Package *pi )
+{
+ Package();
+ copyValues( pi );
+ _toProcess = false;
+}
+
+
+void Package::setValue( QString n, QString t )
+{
+ if ( n == "Status" && installed() ) return;
+ if ( n == "Package" )
+ {
+ _name = QString( t );
+ }
+ if ( n == "Installed-Size" )
+ {
+ _size = t;
+ }
+ if ( n == "Priority")
+ {
+
+ }
+ if ( n == "Section")
+ {
+ setSection( t );
+ }
+ if ( n == "Maintainer")
+ {
+
+ }
+ if ( n == "Architecture")
+ {
+
+ }
+ if ( n == "Version")
+ {
+
+ }
+ if ( n == "Pre-Depends")
+ {
+
+ }
+ if ( n == "Depends")
+ {
+
+ }else if ( n == "Filename")
+ {
+
+ }else if ( n == "Size")
+ {
+
+ }else if ( n == "MD5Sum")
+ {
+
+ }
+ if ( n == "Description")
+ {
+ setDesc( t );
+ }
+ if ( n == "Status")
+ {
+ if ( installed() ) return;
+ _status = t;
+ }
+ if ( t == "Essential")
+ {
+
+ }
+};
+
+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);
+}
+
+
+
+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 )
+ {
+ QString tag = line.left(sep);
+ QString value = line.mid(sep+2).simplifyWhiteSpace();
+ setValue( tag, value );
+ }else{
+ }
+ }
+ return;
+}
+
+QString Package::details()
+{
+ QString status;
+ Process ipkg_status(QStringList() << "ipkg" << "info" << name() );
+ QString description;
+ if ( ipkg_status.exec("",status) )
+ {
+ QStringList lines = QStringList::split('\n',status,TRUE);
+ for (QStringList::Iterator it = lines.begin(); it!=lines.end(); ++it) {
+ QString line = *it;
+ if ( line == " ." )
+ {
+ description.append("<p>");
+ } else
+ if ( line[0] == ' ' || line[0] == '\t' )
+ {
+ // continuation
+ description.append(" ");
+ description.append(Qtopia::escapeString(line));
+ } else {
+ int sep = line.find(QRegExp(":[\t ]+"));
+ if ( sep >= 0 )
+ {
+ QString tag = line.left(sep);
+ description.append("<br>");
+ description.append("<b>");
+ description.append(Qtopia::escapeString(tag));
+ description.append(":</b> ");
+ description.append(Qtopia::escapeString(line.mid(sep+2)));
+ } else {
+ description.append(" ");
+ description.append(Qtopia::escapeString(line));
+ }
+ }
+ }
+ }
+ return description;
+}
+
diff --git a/noncore/unsupported/oipkg/package.h b/noncore/unsupported/oipkg/package.h
new file mode 100644
index 0000000..08d0c57
--- a/dev/null
+++ b/noncore/unsupported/oipkg/package.h
@@ -0,0 +1,54 @@
+#ifndef PK_ITEM_H
+#define PK_ITEM_H
+
+#include <qstring.h>
+#include <qlistview.h>
+#include <qpainter.h>
+#include <qpixmap.h>
+#include <qdict.h>
+#include <qobject.h>
+
+class Package //: public QObject
+{
+ // Q_OBJECT
+ public:
+ Package();
+ ~Package();
+ Package( QStringList );
+ Package( QString );
+ Package( Package* );
+
+ void setValue( QString, QString );
+ void copyValues( Package* );
+
+ QString name() ;
+ bool installed();
+
+ void setDesc( QString );
+ QString shortDesc();
+ QString desc();
+ QString size();
+ void setSection( QString );
+ QString getSection();
+ QString getSubSection();
+ QString details();
+ bool toProcess();
+ bool toInstall();
+ bool toRemove();
+public slots:
+ void toggleProcess();
+
+private:
+ QString _name;
+ bool _toProcess;
+ QString _status;
+ QString _size;
+ QString _section;
+ QString _subsection;
+ QString _shortDesc;
+ QString _desc;
+ void parsePackage( QStringList );
+};
+
+
+#endif
diff --git a/noncore/unsupported/oipkg/packagelist.cpp b/noncore/unsupported/oipkg/packagelist.cpp
new file mode 100644
index 0000000..d72ef75
--- a/dev/null
+++ b/noncore/unsupported/oipkg/packagelist.cpp
@@ -0,0 +1,215 @@
+#include "packagelist.h"
+
+#include <assert.h>
+#include <qfile.h>
+#include <qfileinfo.h>
+#include <qtextstream.h>
+#include <qpe/config.h>
+
+#include "debug.h"
+
+PackageList::PackageList()
+ : packageIter( packageList )
+{
+ empty=true;
+ {
+ Config cfg( "oipkg", Config::User );
+ cfg.setGroup( "Common" );
+ statusDir = cfg.readEntry( "statusDir", "" );
+ listsDir = cfg.readEntry( "listsDir", "" );
+ if ( statusDir=="" || ! QFileInfo(statusDir+"/status").isFile() )
+ {
+ statusDir="/usr/lib/ipkg/";
+ listsDir="/usr/lib/ipkg/lists/";
+ cfg.writeEntry( "statusDir", statusDir );
+ cfg.writeEntry( "listsDir", listsDir );
+ }
+ }
+ pvDebug( 5, "PackageList::PackageList statusDir "+statusDir);
+ pvDebug( 5, "PackageList::PackageList listsDir "+listsDir);
+ sections << "All";
+ subSections.insert("All", new QStringList() );
+ QStringList *ss = subSections["All"];
+ *ss << "All";
+ aktSection = "All";
+ aktSubSection = "All";
+}
+
+PackageList::PackageList( PackageManagerSettings* s)
+ : packageIter( packageList )
+{
+ settings = s;
+ PackageList();
+}
+
+PackageList::~PackageList()
+{
+}
+
+/** Inserts a package into the list */
+void PackageList::insertPackage( Package* pack )
+{
+ Package* p = packageList.find( pack->name() );
+ if ( p )
+ {
+ p->copyValues( pack );
+ delete pack;
+ pack = p;
+ }else{
+ packageList.insert( pack->name(), pack );
+ origPackageList.insert( pack->name(), pack );
+ empty=false;
+ };
+ updateSections( pack );
+}
+
+void PackageList::filterPackages()
+{
+ packageList.clear();
+ QDictIterator<Package> filterIter( origPackageList );
+ filterIter.toFirst();
+ Package *pack= filterIter.current() ;
+ while ( pack )
+ {
+ if ( ((aktSection=="All")||(pack->getSection()==aktSection)) &&
+ ((aktSubSection=="All")||(pack->getSubSection()==aktSubSection)) )
+ {
+ packageList.insert( pack->name(), pack );
+ }
+ ++filterIter;
+ pack = filterIter.current();
+ }
+}
+
+Package* PackageList::find( QString n )
+{
+ return packageList.find( n );
+}
+
+Package* PackageList::first()
+{
+ packageIter.toFirst();
+ return packageIter.current();
+}
+
+Package* PackageList::next()
+{
+ ++packageIter;
+ return packageIter.current();
+}
+
+QStringList PackageList::getSections()
+{
+ sections.sort();
+ return sections;
+}
+
+QStringList PackageList::getSubSections()
+{
+ QStringList ss;
+ if ( !subSections[aktSection] ) return ss;
+ ss = *subSections[aktSection];
+ ss.sort();
+ return ss;
+}
+
+void PackageList::setSection( QString sec )
+{
+ aktSection = sec;
+}
+
+void PackageList::setSubSection( QString ssec )
+{
+ aktSubSection = ssec;
+}
+
+void PackageList::updateSections( Package* pack )
+{
+ QString s = pack->getSection();
+ if ( s.isEmpty() || s == "") return;
+ if ( sections.contains(s) ) return;
+ sections += s;
+ QString ss = pack->getSubSection();
+ if ( ss.isEmpty() || ss == "" ) return;
+ if ( !subSections[s] ) {
+ subSections.insert( s, new QStringList() );
+ QStringList *subsecs = subSections[s];
+ *subsecs += "All";
+ }
+ QStringList *subsecs = subSections[s];
+ *subsecs += ss;
+ if ( !subSections["All"] ) subSections.insert( "All", new QStringList() );
+ subsecs = subSections["All"];
+ *subsecs += ss;
+}
+
+
+
+/** No descriptions */
+void PackageList::parseStatus()
+{
+ QStringList dests = settings->getDestinationUrls();
+ for ( QStringList::Iterator it = dests.begin(); it != dests.end(); ++it )
+ {
+ pvDebug( 2,"Status Dir: "+*it+statusDir+"/status");
+ readFileEntries( *it+statusDir+"/status" );
+ };
+}
+
+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;
+}
+
diff --git a/noncore/unsupported/oipkg/packagelist.h b/noncore/unsupported/oipkg/packagelist.h
new file mode 100644
index 0000000..eda8d22
--- a/dev/null
+++ b/noncore/unsupported/oipkg/packagelist.h
@@ -0,0 +1,63 @@
+#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();
+
+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/packagelistitem.cpp b/noncore/unsupported/oipkg/packagelistitem.cpp
new file mode 100644
index 0000000..5d08bb1
--- a/dev/null
+++ b/noncore/unsupported/oipkg/packagelistitem.cpp
@@ -0,0 +1,97 @@
+#include "packagelistitem.h"
+
+#include <qpe/resource.h>
+
+static QPixmap *pm_uninstalled=0;
+static QPixmap *pm_installed=0;
+static QPixmap *pm_uninstall=0;
+static QPixmap *pm_install=0;
+
+PackageListItem::PackageListItem(QListView* lv, Package *pi)
+ : QCheckListItem(lv,pi->name(),CheckBox)
+{
+ package = pi;
+ if (!pm_uninstalled) {
+ pm_uninstalled = new QPixmap(Resource::loadPixmap("oipkg/uninstalled"));
+ pm_installed = new QPixmap(Resource::loadPixmap("oipkg/installed"));
+ pm_install = new QPixmap(Resource::loadPixmap("oipkg/install"));
+ pm_uninstall = new QPixmap(Resource::loadPixmap("oipkg/uninstall"));
+ }
+ setText(1, package->shortDesc() );
+ setText(2, package->size() );
+}
+
+void PackageListItem::paintCell( QPainter *p, const QColorGroup & cg,
+ int column, int width, int alignment )
+{
+ if ( !p )
+ return;
+
+ p->fillRect( 0, 0, width, height(),
+ isSelected()? cg.highlight() : cg.base() );
+
+ if ( column != 0 ) {
+ // The rest is text
+ QListViewItem::paintCell( p, cg, column, width, alignment );
+ return;
+ }
+
+ QListView *lv = listView();
+ if ( !lv )
+ return;
+ int marg = lv->itemMargin();
+ int r = marg;
+
+ QPixmap pm = statePixmap();
+ p->drawPixmap(marg,(height()-pm.height())/2,pm);
+ r += pm.width()+1;
+
+ p->translate( r, 0 );
+ QListViewItem::paintCell( p, cg, column, width - r, alignment );
+}
+
+
+void PackageListItem::paintFocus( QPainter *p, const QColorGroup & cg,
+ const QRect & r )
+{
+ // Skip QCheckListItem
+ // (makes you wonder what we're getting from QCheckListItem)
+ QListViewItem::paintFocus(p,cg,r);
+}
+
+QPixmap PackageListItem::statePixmap() const
+{
+ bool installed = package->installed();
+ if ( !package->toProcess() ) {
+ if ( !installed )
+ return *pm_uninstalled;
+ else
+ return *pm_installed;
+ } else {
+ if ( !installed )
+ return *pm_install;
+ else
+ return *pm_uninstall;
+ }
+}
+
+QString PackageListItem::key( int column, bool ascending ) const
+{
+ if ( column == 2 ) {
+ QString t = text(2);
+ double bytes=t.toDouble();
+ if ( t.contains('M') ) bytes*=1024*1024;
+ else if ( t.contains('K') || t.contains('k') ) bytes*=1024;
+ if ( !ascending ) bytes=999999999-bytes;
+ return QString().sprintf("%09d",(int)bytes);
+ } else {
+ return QListViewItem::key(column,ascending);
+ }
+}
+
+void PackageListItem::setOn( bool b )
+{
+ QCheckListItem::setOn( b );
+ package->toggleProcess();
+ repaint();
+}
diff --git a/noncore/unsupported/oipkg/packagelistitem.h b/noncore/unsupported/oipkg/packagelistitem.h
new file mode 100644
index 0000000..6983e58
--- a/dev/null
+++ b/noncore/unsupported/oipkg/packagelistitem.h
@@ -0,0 +1,31 @@
+#ifndef PK_LISTITEM_H
+#define PK_LISTITEM_H
+
+#include "package.h"
+
+#include <qstring.h>
+#include <qlistview.h>
+#include <qpainter.h>
+#include <qpixmap.h>
+#include <qdict.h>
+
+class PackageListItem
+: public QCheckListItem
+{
+public:
+ PackageListItem(QListView*, Package* );
+ void paintCell( QPainter*, const QColorGroup&, int, int, int );
+ void paintFocus( QPainter*, const QColorGroup&, const QRect& );
+ QPixmap statePixmap() const;
+ QString key( int, bool ) const;
+ Package* getPackage() { return package; } ;
+ QString getName() { return package->name(); } ;
+ bool isInstalled(){ return package->installed(); };
+ virtual void setOn ( bool );
+
+private:
+ Package *package;
+};
+
+
+#endif
diff --git a/noncore/unsupported/oipkg/pkdesc.ui b/noncore/unsupported/oipkg/pkdesc.ui
new file mode 100644
index 0000000..494d3d6
--- a/dev/null
+++ b/noncore/unsupported/oipkg/pkdesc.ui
@@ -0,0 +1,96 @@
+<!DOCTYPE UI><UI>
+<class>PackageDetails</class>
+<widget>
+ <class>QDialog</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Form7</cstring>
+ </property>
+ <property stdset="1">
+ <name>geometry</name>
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>221</width>
+ <height>291</height>
+ </rect>
+ </property>
+ <property stdset="1">
+ <name>caption</name>
+ <string>(pkgname)</string>
+ </property>
+ <property>
+ <name>layoutMargin</name>
+ </property>
+ <property>
+ <name>layoutSpacing</name>
+ </property>
+ <vbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>6</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>3</number>
+ </property>
+ <widget>
+ <class>QTextView</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>description</cstring>
+ </property>
+ </widget>
+ <widget>
+ <class>QLayoutWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Layout4</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>QToolButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>install</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Install</string>
+ </property>
+ </widget>
+ <widget>
+ <class>QToolButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>remove</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Remove</string>
+ </property>
+ </widget>
+ <widget>
+ <class>QToolButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>ignore</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Ignore</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ </vbox>
+</widget>
+</UI>
diff --git a/noncore/unsupported/oipkg/pkfind.ui b/noncore/unsupported/oipkg/pkfind.ui
new file mode 100644
index 0000000..7a24c00
--- a/dev/null
+++ b/noncore/unsupported/oipkg/pkfind.ui
@@ -0,0 +1,51 @@
+<!DOCTYPE UI><UI>
+<class>Search</class>
+<widget>
+ <class>QDialog</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Form5</cstring>
+ </property>
+ <property stdset="1">
+ <name>geometry</name>
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>196</width>
+ <height>55</height>
+ </rect>
+ </property>
+ <property stdset="1">
+ <name>caption</name>
+ <string>Search Packages</string>
+ </property>
+ <hbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>11</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>6</number>
+ </property>
+ <widget>
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>TextLabel4</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Find:</string>
+ </property>
+ </widget>
+ <widget>
+ <class>QLineEdit</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>pattern</cstring>
+ </property>
+ </widget>
+ </hbox>
+</widget>
+</UI>
diff --git a/noncore/unsupported/oipkg/pksettings.cpp b/noncore/unsupported/oipkg/pksettings.cpp
new file mode 100644
index 0000000..32224b5
--- a/dev/null
+++ b/noncore/unsupported/oipkg/pksettings.cpp
@@ -0,0 +1,487 @@
+#include "pksettings.h"
+
+#include <qpe/process.h>
+#include <qpe/resource.h>
+#include <qpe/stringutil.h>
+#include <qpe/qpeapplication.h>
+#include <qpe/qcopenvelope_qws.h>
+#include <qpe/applnk.h>
+#include <qpe/config.h>
+
+#include <qprogressbar.h>
+#include <qcombobox.h>
+#include <qdict.h>
+#include <qfile.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+#include <qlistview.h>
+#include <qlistbox.h>
+#include <qcheckbox.h>
+#include <qmessagebox.h>
+#include <qpainter.h>
+#include <qpixmap.h>
+#include <qregexp.h>
+#include <qstring.h>
+#include <qobject.h>
+#include <qtextstream.h>
+#include <qtextview.h>
+#include <qtoolbutton.h>
+#include <qtabwidget.h>
+
+#include <stdlib.h>
+#include <unistd.h>
+#include "debug.h"
+
+PackageManagerSettings::PackageManagerSettings( QWidget* parent, const char* name, WFlags fl )
+ : PackageManagerSettingsBase( parent, name, fl )
+{
+ connect( newserver, SIGNAL(clicked()), this, SLOT(newServer()) );
+ connect( removeserver, SIGNAL(clicked()), this, SLOT(removeServer()) );
+ connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) );
+ connect( newdestination, SIGNAL(clicked()), this, SLOT(newDestination()) );
+ connect( removedestination, SIGNAL(clicked()), this, SLOT(removeDestination()) );
+ connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) );
+ // connect( CheckBoxLink, SIGNAL(toggled(bool)),
+ // activeLinkDestination, SLOT(setEnabled(bool)) );
+
+ connect( settingName, SIGNAL(activated(int)), this, SLOT(installationSettingChange(int)) );
+ connect( settingName, SIGNAL(textChanged(const QString &)), this, SLOT(installationSettingSetName(const QString &)) );
+ connect( newsetting, SIGNAL(clicked()), this, SLOT(newInstallationSetting()) );
+ connect( renamesetting, SIGNAL(clicked()), this, SLOT(renameInstallationSetting()) );
+ connect( removesetting, SIGNAL(clicked()), this, SLOT(removeInstallationSetting()) );
+ servername->setEnabled(FALSE);
+ serverurl->setEnabled(FALSE);
+ serverurlDic.setAutoDelete(TRUE);
+ destinationname->setEnabled(FALSE);
+ destinationurl->setEnabled(FALSE);
+ destinationurlDic.setAutoDelete(TRUE);
+ readSettings();
+}
+
+PackageManagerSettings::~PackageManagerSettings()
+{
+}
+
+
+void PackageManagerSettings::newServer()
+{
+ int i = servers->count();
+ if ( servername->isEnabled() || serverurl->text().isEmpty() ) {
+ serverurlDic.insert(i,new QString("http://"));
+ servers->insertItem(tr("New"));
+ activeServers->insertItem(tr("New"));
+ } else {
+ // allows one-level undo
+ serverurlDic.insert(i,new QString(serverurl->text()));
+ servers->insertItem(servername->text());
+ activeServers->insertItem(servername->text());
+ }
+ servers->setSelected(i,TRUE);
+ editServer(i);
+}
+
+void PackageManagerSettings::newDestination()
+{
+ int i = destinations->count();
+ if ( destinationname->isEnabled() || destinationurl->text().isEmpty() ) {
+ destinationurlDic.insert(i,new QString("/"));
+ destinations->insertItem(tr("New"));
+ activeDestination->insertItem(tr("New"));
+ activeLinkDestination->insertItem(tr("New"));
+ } else {
+ // allows one-level undo
+ destinationurlDic.insert(i,new QString(destinationurl->text()));
+ destinations->insertItem(destinationname->text());
+ activeDestination->insertItem(destinationname->text());
+ activeLinkDestination->insertItem(destinationname->text());
+ }
+ destinations->setSelected(i,TRUE);
+ editDestination(i);
+}
+
+
+void PackageManagerSettings::editServer(int i)
+{
+ if ( servername->isEnabled() ) {
+ disconnect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) );
+ disconnect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) );
+ } else {
+ servername->setEnabled(TRUE);
+ serverurl->setEnabled(TRUE);
+ }
+
+ servername->setText( servers->text(i) );
+ serverurl->setText( *serverurlDic[i] );
+
+ editedserver = i;
+
+ connect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) );
+ connect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) );
+}
+
+
+void PackageManagerSettings::editDestination(int i)
+{
+ if ( destinationname->isEnabled() ) {
+ disconnect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) );
+ disconnect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) );
+ } else {
+ destinationname->setEnabled(TRUE);
+ destinationurl->setEnabled(TRUE);
+ }
+
+ destinationname->setText( destinations->text(i) );
+ destinationurl->setText( *destinationurlDic[i] );
+
+ editeddestination = i;
+
+ connect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) );
+ connect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) );
+}
+
+void PackageManagerSettings::removeServer()
+{
+ disconnect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) );
+ disconnect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) );
+ servername->setText(servers->text(editedserver));
+ serverurl->setText(*serverurlDic[editedserver]);
+ disconnect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) );
+ servers->removeItem(editedserver);
+ activeServers->removeItem(editedserver);
+ connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) );
+ servername->setEnabled(FALSE);
+ serverurl->setEnabled(FALSE);
+}
+
+void PackageManagerSettings::removeDestination()
+{
+ disconnect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) );
+ disconnect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) );
+ destinationname->setText(destinations->text(editedserver));
+ destinationurl->setText(*destinationurlDic[editedserver]);
+ disconnect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) );
+ destinations->removeItem(editeddestination);
+ activeDestination->removeItem(editeddestination);
+ activeLinkDestination->removeItem(editeddestination);
+ connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) );
+ destinationname->setEnabled(FALSE);
+ destinationurl->setEnabled(FALSE);
+}
+
+void PackageManagerSettings::serverNameChanged(const QString& t)
+{
+ disconnect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) );
+ servers->changeItem( t, editedserver );
+ activeServers->changeItem( t, editedserver );
+ connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) );
+}
+
+void PackageManagerSettings::destNameChanged(const QString& t)
+{
+ disconnect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) );
+ destinations->changeItem( t, editeddestination );
+ activeDestination->changeItem( t, editeddestination );
+ activeLinkDestination->changeItem( t, editeddestination );
+ connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) );
+}
+
+void PackageManagerSettings::serverUrlChanged(const QString& t)
+{
+ serverurlDic.replace(editedserver, new QString(t));
+}
+
+void PackageManagerSettings::destUrlChanged(const QString& t)
+{
+ destinationurlDic.replace(editeddestination, new QString(t));
+}
+
+void PackageManagerSettings::writeIpkgConfig(const QString& conffile)
+{
+ QFile conf(conffile);
+ if ( ! conf.open(IO_WriteOnly) ) return;
+ QTextStream s(&conf);
+ s << "# Written by qpie Package Manager\n";
+ for (int i=0; i<(int)activeServers->count(); i++)
+ {
+ QString url = serverurlDic[i] ? *serverurlDic[i] : QString("???");
+ if ( !activeServers->isSelected(i) )
+ s << "#";
+ s << "src " << activeServers->text(i) << " " << url << "\n";
+ }
+ for (int i=0; i<(int)destinations->count(); i++)
+ {
+ QString url = destinationurlDic[i] ? *destinationurlDic[i] : QString("???");
+ s << "dest " << destinations->text(i) << " " << url << "\n";
+ }
+ conf.close();
+}
+
+
+void PackageManagerSettings::readInstallationSettings()
+{
+ Config cfg( "oipkg", Config::User );
+ cfg.setGroup( "Settings" );
+ installationSettingsCount = cfg.readNumEntry( "count", -1 );
+ currentSetting = cfg.readNumEntry( "current", 0 );// o should be -1
+
+ for (int i = 0; i < installationSettingsCount; i++)
+ {
+ cfg.setGroup( "Setting_" + QString::number(i) );
+ settingName->insertItem( cfg.readEntry( "name", "???" ), i );
+ };
+ readInstallationSetting( currentSetting );
+}
+
+
+
+/**
+ * remove from conf file
+ */
+void PackageManagerSettings::removeInstallationSetting()
+{
+ settingName->removeItem( settingName->currentItem() );
+ Config cfg( "oipkg", Config::User );
+ cfg.setGroup( "Setting_" + QString::number( installationSettingsCount ) );
+ cfg.clearGroup();
+ installationSettingsCount--;
+ changed = true;
+ settingName->setEditable( false );
+}
+
+/**
+ * write to confgile
+ */
+void PackageManagerSettings::newInstallationSetting()
+{
+ installationSettingsCount++;
+ settingName->insertItem( "New", installationSettingsCount );
+ settingName->setCurrentItem( installationSettingsCount );
+ settingName->setEditable( true );
+ changed = true;
+}
+
+void PackageManagerSettings::installationSettingChange(int cs)
+{
+ writeCurrentInstallationSetting();
+ currentSetting = cs;
+ readInstallationSetting( cs );
+}
+
+void PackageManagerSettings::writeInstallationSettings()
+{
+ if ( ! changed ) return ;
+ {
+ Config cfg( "oipkg", Config::User );
+ cfg.setGroup( "Settings" );
+ cfg.writeEntry( "count", installationSettingsCount );
+ cfg.writeEntry( "current", currentSetting );
+ }
+ writeCurrentInstallationSetting();
+}
+
+
+void PackageManagerSettings::readInstallationSetting(int setting)
+{
+ if ( setting < 0 ) return;
+ Config cfg( "oipkg", Config::User );
+ cfg.setGroup( "Setting_" + QString::number( setting ) );
+ CheckBoxLink->setChecked( cfg.readBoolEntry( "link", false ) );
+ QString dest = cfg.readEntry( "dest" );
+ QString linkdest = cfg.readEntry( "linkdest" );
+ pvDebug(3, "dest="+dest);
+ pvDebug(3, "linkdest="+linkdest);
+
+ for ( int i = 0; i < activeDestination->count(); i++)
+ {
+ if ( activeDestination->text( i ) == dest )
+ activeDestination->setCurrentItem( i );
+ if ( activeLinkDestination->text( i ) == linkdest )
+ activeLinkDestination->setCurrentItem( i );
+ }
+}
+
+void PackageManagerSettings::writeCurrentInstallationSetting()
+{
+ Config cfg( "oipkg", Config::User );
+ changed = false;
+ cfg.setGroup( "Setting_" + QString::number(currentSetting) );
+ cfg.writeEntry( "link", CheckBoxLink->isChecked() );
+ cfg.writeEntry( "dest", getDestinationName() );
+ cfg.writeEntry( "linkdest" , getLinkDestinationName() );
+ QStringList sers = getActiveServers();
+ int srvc = 0;
+ for ( QStringList::Iterator it = sers.begin(); it != sers.end(); ++it ) {
+ cfg.writeEntry( "server_" + QString::number(srvc++), *it );
+ }
+ cfg.writeEntry( "server_count", srvc );
+}
+
+void PackageManagerSettings::renameInstallationSetting()
+{
+ settingName->setEditable( true );
+ changed = true;
+}
+
+void PackageManagerSettings::installationSettingSetName(const QString &name)
+{
+ settingName->changeItem( name, settingName->currentItem() );
+ changed = true;
+}
+
+
+bool PackageManagerSettings::readIpkgConfig(const QString& conffile)
+{
+ QFile conf(conffile);
+ if ( conf.open(IO_ReadOnly) ) {
+ QTextStream s(&conf);
+ servers->clear();
+ activeServers->clear();
+ activeDestination->clear();
+ activeLinkDestination->clear();
+ serverurlDic.clear();
+ destinationurlDic.clear();
+ ipkg_old=0;
+ int currentserver=0;
+ while ( !s.atEnd() ) {
+ QString l = s.readLine();
+ QStringList token = QStringList::split(' ', l);
+ if ( token[0] == "src" || token[0] == "#src" ) {
+ currentserver=servers->count();
+ serverurlDic.insert(servers->count(),new QString(token[2]));
+ int a = token[0] == "src" ? 1 : 0;
+ int i = servers->count();
+ servers->insertItem(token[1]);
+ activeServers->insertItem( token[1] );
+ activeServers->setSelected(i,a);
+ } else if ( token[0] == "dest" ) {
+ currentserver=destinations->count();
+ destinationurlDic.insert(destinations->count(),new QString(token[2]));
+ destinations->insertItem(token[1]);
+ activeDestination->insertItem( token[1] );
+ activeLinkDestination->insertItem( token[1] );
+
+ } else if ( token[0] == "option" ) {
+ // ### somehow need to use the settings from netsetup
+ // if ( token[1] == "http_proxy" )
+ // http->setText(token[2]);
+ // else if ( token[1] == "ftp_proxy" )
+ // ftp->setText(token[2]);
+ // else if ( token[1] == "proxy_username" )
+ // username->setText(token[2]);
+ // else if ( token[1] == "proxy_password" )
+ // password->setText(token[2]);
+ } else {
+ // Old style?
+ int eq = l.find('=');
+ if ( eq >= 0 ) {
+ QString v = l.mid(eq+1).stripWhiteSpace();
+ if ( v[0] == '"' || v[0] == '\'' ) {
+ int cl=v.find(v[0],1);
+ if ( cl >= 0 )
+ v = v.mid(1,cl-1);
+ }
+ if ( l.left(12) == "IPKG_SOURCE=" ) {
+ ipkg_old=1;
+ currentserver=servers->count();
+ serverurlDic.insert(servers->count(),new QString(v));
+ servers->insertItem(v);
+ } else if ( l.left(13) == "#IPKG_SOURCE=" ) {
+ serverurlDic.insert(servers->count(),new QString(v));
+ servers->insertItem(v);
+ } else if ( l.left(10) == "IPKG_ROOT=" ) {
+ // ### no UI
+ // } else if ( l.left(20) == "IPKG_PROXY_USERNAME=" ) {
+ // username->setText(v);
+ // } else if ( l.left(20) == "IPKG_PROXY_PASSWORD=" ) {
+ // password->setText(v);
+ // } else if ( l.left(16) == "IPKG_PROXY_HTTP=" ) {
+ // http->setText(v);
+ // } else if ( l.left(16) == "IPKG_PROXY_FTP=" ) {
+ // ftp->setText(v);
+ }
+ }
+ }
+ }
+ if ( ipkg_old ) {
+ servers->setSelectionMode(QListBox::Single);
+ servers->setSelected(currentserver,TRUE);
+ }
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
+
+/**
+ * read from config file(s)
+ */
+void PackageManagerSettings::readSettings()
+{
+ readIpkgConfig("/etc/ipkg.conf");
+ readInstallationSettings();
+}
+
+void PackageManagerSettings::writeSettings()
+{
+ writeIpkgConfig("/etc/ipkg.conf");
+ writeInstallationSettings();
+}
+/** shows the setting dialog */
+bool PackageManagerSettings::showDialog( int i )
+{
+ TabWidget->setCurrentPage( i );
+ showMaximized();
+ bool ret = exec();
+ if ( ret ) writeSettings();
+ else readSettings();
+ return ret;
+}
+/** Returns the installation destination */
+QString PackageManagerSettings::getDestinationName()
+{
+ return activeDestination->currentText();
+}
+/** Returns the link destination */
+QString PackageManagerSettings::getLinkDestinationName()
+{
+ return activeLinkDestination->currentText();
+}
+/** Returns the URL of the active destination */
+QString PackageManagerSettings::getDestinationUrl()
+{
+ int dnr = activeDestination->currentItem();
+ return *destinationurlDic.find(dnr);
+}
+/** Should oipkg create links form install destination to link destination */
+bool PackageManagerSettings::createLinks()
+{
+ return CheckBoxLink->isChecked();
+}
+/** get the servers that are active */
+QStringList PackageManagerSettings::getActiveServers()
+{
+ QStringList sl;
+ for (int i=0; i<(int)activeServers->count(); i++)
+ {
+ if ( activeServers->isSelected(i) )
+ sl += activeServers->text(i);
+ }
+ return sl;
+}
+/** returns the destination listed in ipkg.conf */
+QStringList PackageManagerSettings::getDestinationUrls()
+{
+ QStringList sl;
+ for (int i=0; i<(int)destinations->count(); i++)
+ {
+ sl += *destinationurlDic[i];
+ }
+ return sl;
+}
+
+void PackageManagerSettings::linkEnabled( bool b )
+{
+ changed = true;
+ activeLinkDestination->setEnabled( b );
+}
diff --git a/noncore/unsupported/oipkg/pksettings.h b/noncore/unsupported/oipkg/pksettings.h
new file mode 100644
index 0000000..cda352a
--- a/dev/null
+++ b/noncore/unsupported/oipkg/pksettings.h
@@ -0,0 +1,62 @@
+#ifndef PACKAGEMANAGERSETTINGS_H
+#define PACKAGEMANAGERSETTINGS_H
+
+#include "pksettingsbase.h"
+#include <qintdict.h>
+
+
+class PackageManagerSettings : private PackageManagerSettingsBase
+{
+// Q_OBJECT
+public:
+ PackageManagerSettings( QWidget* , const char* , WFlags );
+ ~PackageManagerSettings();
+
+ bool showDialog( int ) ;
+ QString getDestinationUrl();
+ QString getDestinationName();
+ QString getLinkDestinationName();
+ bool createLinks();
+ QStringList getActiveServers();
+ QStringList getDestinationUrls();
+
+private:
+ QIntDict<QString> serverurlDic;
+ QIntDict<QString> destinationurlDic;
+ int ipkg_old;
+ int editedserver;
+ int editeddestination;
+ int currentSetting;
+ int installationSettingsCount;
+ bool changed;
+
+ bool readIpkgConfig(const QString&);
+ void writeIpkgConfig(const QString&);
+ void writeSettings();
+ void readSettings();
+
+public slots:
+ void writeInstallationSettings();
+ void readInstallationSettings();
+ void writeCurrentInstallationSetting();
+ void readInstallationSetting(int);
+ void installationSettingSetName(const QString &);
+
+ void newServer();
+ void editServer(int);
+ void removeDestination();
+ void newDestination();
+ void editDestination(int);
+ void linkEnabled(bool);
+ void removeServer();
+ void serverNameChanged(const QString&);
+ void serverUrlChanged(const QString&);
+ void destNameChanged(const QString&);
+ void destUrlChanged(const QString&);
+ void installationSettingChange(int);
+ void newInstallationSetting();
+ void removeInstallationSetting();
+ void renameInstallationSetting();
+};
+
+#endif
diff --git a/noncore/unsupported/oipkg/pksettingsbase.ui b/noncore/unsupported/oipkg/pksettingsbase.ui
new file mode 100644
index 0000000..2efd2f3
--- a/dev/null
+++ b/noncore/unsupported/oipkg/pksettingsbase.ui
@@ -0,0 +1,744 @@
+<!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>
+ <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>
+ <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>QLayoutWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Layout3_2</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>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Settings</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Installation Setups</string>
+ </property>
+ </widget>
+ <spacer>
+ <property>
+ <name>name</name>
+ <cstring>Spacer2_2_2</cstring>
+ </property>
+ <property stdset="1">
+ <name>orientation</name>
+ <enum>Horizontal</enum>
+ </property>
+ <property stdset="1">
+ <name>sizeType</name>
+ <enum>Expanding</enum>
+ </property>
+ <property>
+ <name>sizeHint</name>
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ <widget row="5" column="0" >
+ <class>QLayoutWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Layout8</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>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>TextLabel1</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Install destination:</string>
+ </property>
+ </widget>
+ <widget>
+ <class>QComboBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>activeDestination</cstring>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget row="6" column="0" >
+ <class>QLayoutWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Layout9</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>QCheckBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>CheckBoxLink</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Link Destination:</string>
+ </property>
+ </widget>
+ <widget>
+ <class>QComboBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>activeLinkDestination</cstring>
+ </property>
+ <property stdset="1">
+ <name>enabled</name>
+ <bool>false</bool>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget row="3" column="0" >
+ <class>QLayoutWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Layout13</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>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>TextLabel1_2</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Used servers:</string>
+ </property>
+ </widget>
+ <spacer>
+ <property>
+ <name>name</name>
+ <cstring>Spacer4</cstring>
+ </property>
+ <property stdset="1">
+ <name>orientation</name>
+ <enum>Horizontal</enum>
+ </property>
+ <property stdset="1">
+ <name>sizeType</name>
+ <enum>Expanding</enum>
+ </property>
+ <property>
+ <name>sizeHint</name>
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ <widget row="4" column="0" >
+ <class>QListBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>activeServers</cstring>
+ </property>
+ <property stdset="1">
+ <name>enabled</name>
+ <bool>true</bool>
+ </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>
+ </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>
+ </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>
+ </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>
+ <widget row="0" column="1" >
+ <class>QLineEdit</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>servername</cstring>
+ </property>
+ </widget>
+ <widget row="0" column="0" >
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>TextLabel1_3</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Name:</string>
+ </property>
+ </widget>
+ <widget row="1" column="1" >
+ <class>QLineEdit</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>serverurl</cstring>
+ </property>
+ </widget>
+ <widget row="1" column="0" >
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>TextLabel2_3</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>URL:</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget row="0" column="0" rowspan="1" colspan="2" >
+ <class>QLayoutWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Layout2</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>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Servers</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Servers</string>
+ </property>
+ </widget>
+ <spacer>
+ <property>
+ <name>name</name>
+ <cstring>Spacer2</cstring>
+ </property>
+ <property stdset="1">
+ <name>orientation</name>
+ <enum>Horizontal</enum>
+ </property>
+ <property stdset="1">
+ <name>sizeType</name>
+ <enum>Expanding</enum>
+ </property>
+ <property>
+ <name>sizeHint</name>
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ <widget row="1" column="0" rowspan="1" colspan="2" >
+ <class>QListBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>servers</cstring>
+ </property>
+ <property stdset="1">
+ <name>selectionMode</name>
+ <enum>Extended</enum>
+ </property>
+ </widget>
+ <widget row="2" column="1" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>removeserver</cstring>
+ </property>
+ <property stdset="1">
+ <name>enabled</name>
+ <bool>true</bool>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Remove</string>
+ </property>
+ <property stdset="1">
+ <name>autoDefault</name>
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget row="2" column="0" >
+ <class>QPushButton</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>newserver</cstring>
+ </property>
+ <property stdset="1">
+ <name>enabled</name>
+ <bool>true</bool>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>New</string>
+ </property>
+ <property stdset="1">
+ <name>autoDefault</name>
+ <bool>false</bool>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ <widget>
+ <class>QWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>tab</cstring>
+ </property>
+ <attribute>
+ <name>title</name>
+ <string>Destinations</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="0" column="0" >
+ <class>QLayoutWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Layout3</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>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Destinations</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Destinations</string>
+ </property>
+ </widget>
+ <spacer>
+ <property>
+ <name>name</name>
+ <cstring>Spacer2_2</cstring>
+ </property>
+ <property stdset="1">
+ <name>orientation</name>
+ <enum>Horizontal</enum>
+ </property>
+ <property stdset="1">
+ <name>sizeType</name>
+ <enum>Expanding</enum>
+ </property>
+ <property>
+ <name>sizeHint</name>
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </hbox>
+ </widget>
+ <widget row="1" column="0" >
+ <class>QListBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>destinations</cstring>
+ </property>
+ <property stdset="1">
+ <name>selectionMode</name>
+ <enum>Single</enum>
+ </property>
+ </widget>
+ <widget row="2" column="0" >
+ <class>QLayoutWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Layout5</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>newdestination</cstring>
+ </property>
+ <property stdset="1">
+ <name>enabled</name>
+ <bool>true</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>removedestination</cstring>
+ </property>
+ <property stdset="1">
+ <name>enabled</name>
+ <bool>true</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>
+ <widget row="3" column="0" >
+ <class>QLayoutWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Layout11</cstring>
+ </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="1" column="0" >
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>TextLabel1_3_2_2</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>URL:</string>
+ </property>
+ </widget>
+ <widget row="0" column="1" >
+ <class>QLineEdit</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>destinationname</cstring>
+ </property>
+ </widget>
+ <widget row="1" column="1" >
+ <class>QLineEdit</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>destinationurl</cstring>
+ </property>
+ </widget>
+ <widget row="0" column="0" >
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>TextLabel1_3_2</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Name:</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+ </widget>
+ </widget>
+ </grid>
+</widget>
+<connections>
+ <connection>
+ <sender>CheckBoxLink</sender>
+ <signal>toggled(bool)</signal>
+ <receiver>Form4</receiver>
+ <slot>linkEnabled(bool)</slot>
+ </connection>
+ <slot access="public">destNameChanged(const QString&amp;)</slot>
+ <slot access="public">destUrlChanged(const QString&amp;)</slot>
+ <slot access="public">editDestination(int)</slot>
+ <slot access="public">editServer(int)</slot>
+ <slot access="public">installationSettingChange(int)</slot>
+ <slot access="public">installationSettingSetName(const QString &amp;)</slot>
+ <slot access="public">linkEnabled(bool)</slot>
+ <slot access="public">newDestination()</slot>
+ <slot access="public">newInstallationSetting()</slot>
+ <slot access="public">newServer()</slot>
+ <slot access="public">removeDestination()</slot>
+ <slot access="public">removeInstallationSetting()</slot>
+ <slot access="public">removeServer()</slot>
+ <slot access="public">renameInstallationSetting()</slot>
+ <slot access="public">serverNameChanged(const QString&amp;)</slot>
+ <slot access="public">serverUrlChanged(const QString&amp;)</slot>
+</connections>
+</UI>
diff --git a/noncore/unsupported/oipkg/pkwindow.ui b/noncore/unsupported/oipkg/pkwindow.ui
new file mode 100644
index 0000000..9e44338
--- a/dev/null
+++ b/noncore/unsupported/oipkg/pkwindow.ui
@@ -0,0 +1,147 @@
+<!DOCTYPE UI><UI>
+<class>PackageWindow</class>
+<widget>
+ <class>QWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>PackageWindow</cstring>
+ </property>
+ <property stdset="1">
+ <name>geometry</name>
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>254</width>
+ <height>298</height>
+ </rect>
+ </property>
+ <property stdset="1">
+ <name>caption</name>
+ <string>PackageWindow</string>
+ </property>
+ <property>
+ <name>layoutMargin</name>
+ </property>
+ <property>
+ <name>layoutSpacing</name>
+ </property>
+ <vbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>2</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>2</number>
+ </property>
+ <widget>
+ <class>QLayoutWidget</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>Layout5</cstring>
+ </property>
+ <property>
+ <name>layoutSpacing</name>
+ </property>
+ <hbox>
+ <property stdset="1">
+ <name>margin</name>
+ <number>0</number>
+ </property>
+ <property stdset="1">
+ <name>spacing</name>
+ <number>1</number>
+ </property>
+ <widget>
+ <class>QLabel</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>LabelSection</cstring>
+ </property>
+ <property stdset="1">
+ <name>text</name>
+ <string>Section:</string>
+ </property>
+ </widget>
+ <widget>
+ <class>QComboBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>section</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ </sizepolicy>
+ </property>
+ </widget>
+ <widget>
+ <class>QComboBox</class>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>subsection</cstring>
+ </property>
+ <property stdset="1">
+ <name>sizePolicy</name>
+ <sizepolicy>
+ <hsizetype>0</hsizetype>
+ <vsizetype>0</vsizetype>
+ </sizepolicy>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget>
+ <class>QListView</class>
+ <column>
+ <property>
+ <name>text</name>
+ <string>Package</string>
+ </property>
+ <property>
+ <name>clickable</name>
+ <bool>true</bool>
+ </property>
+ <property>
+ <name>resizeable</name>
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property>
+ <name>text</name>
+ <string>Description</string>
+ </property>
+ <property>
+ <name>clickable</name>
+ <bool>true</bool>
+ </property>
+ <property>
+ <name>resizeable</name>
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property>
+ <name>text</name>
+ <string>Size</string>
+ </property>
+ <property>
+ <name>clickable</name>
+ <bool>true</bool>
+ </property>
+ <property>
+ <name>resizeable</name>
+ <bool>true</bool>
+ </property>
+ </column>
+ <property stdset="1">
+ <name>name</name>
+ <cstring>ListViewPackages</cstring>
+ </property>
+ </widget>
+ </vbox>
+</widget>
+</UI>
diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp
new file mode 100644
index 0000000..528365e
--- a/dev/null
+++ b/noncore/unsupported/oipkg/pmipkg.cpp
@@ -0,0 +1,183 @@
+#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 )
+{
+ settings = s;
+
+ linkDest = new QCopChannel( "QPE/MakeLinks", this );
+ connect( linkDest, SIGNAL(received(const QCString &, const QByteArray &)),
+ this, SLOT(linkDestination( const QString &, const QString&)) );
+}
+
+PmIpkg::~PmIpkg()
+{
+}
+
+int PmIpkg::runIpkg(const QString& args)
+{
+ pvDebug(4,"PmIpkg::runIpkg");
+ QString cmd = "/usr/bin/ipkg ";
+ 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());
+ QFile f( redirect );
+ 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);
+ }
+
+ return r;
+}
+
+void PmIpkg::makeLinks(QString file)
+{
+ outPut->setText( outPut->text() + "<br>creating links<br>" );
+ QString dest = settings->getDestinationUrl();
+ system(("ipkg -d "+dest+" files "+file+"> /tmp/oipkg.pipe").latin1());
+ QFile f( "/tmp/oipkg.pipe" );
+ if ( ! f.open(IO_ReadOnly) )return;
+ QTextStream t( &f );
+ QString fp;
+ while ( !t.eof() )
+ {
+ processLinkDir( t.readLine(), 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()) ) {
+ processLinkDir( fi->absFilePath(), dest );
+ ++it;
+ }
+ }
+}
+
+void PmIpkg::commit( PackageList pl )
+{
+ showMaximized();
+ exec();
+ outPut->setText( "<b>Starting...</b><br>\n");
+ QStringList to_remove, to_install;
+
+ QString rem="To remove:<br>\n";
+ QString inst="To install:<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";
+ }
+ if ( pack->toRemove() )
+ {
+ to_remove.append( pack->name() );
+ rem += pack->name()+"\n";
+ }
+ }
+ }
+
+ outPut->setText( outPut->text()+inst+rem);
+ 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 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 )
+{
+ 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;
+ }
+}
diff --git a/noncore/unsupported/oipkg/pmipkg.h b/noncore/unsupported/oipkg/pmipkg.h
new file mode 100644
index 0000000..98efaa6
--- a/dev/null
+++ b/noncore/unsupported/oipkg/pmipkg.h
@@ -0,0 +1,42 @@
+#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"
+
+
+#include <qpe/qcopenvelope_qws.h>
+
+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();
+
+ PackageList* getPackageList();
+
+private:
+ PackageManagerSettings* settings;
+ QCopChannel *linkDest;
+ void processLinkDir( QString, QString );
+
+
+public:
+ void makeLinks(QString);
+ int runIpkg(const QString& args);
+ void commit( PackageList );
+
+public slots:
+ void linkDestination( QString, QString );
+};
+
+#endif
diff --git a/noncore/unsupported/oipkg/runwindow.ui b/noncore/unsupported/oipkg/runwindow.ui
new file mode 100644
index 0000000..23f58cf
--- a/dev/null
+++ b/noncore/unsupported/oipkg/runwindow.ui
@@ -0,0 +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>
+ <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>
+ </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>
diff --git a/noncore/unsupported/oipkg/settings.cpp b/noncore/unsupported/oipkg/settings.cpp
new file mode 100644
index 0000000..2b324be
--- a/dev/null
+++ b/noncore/unsupported/oipkg/settings.cpp
@@ -0,0 +1,436 @@
+#include "pksettings.h"
+
+#include <qpe/config.h>
+#include <qcombobox.h>
+#include <qfile.h>
+#include <qlineedit.h>
+#include <qpushbutton.h>
+#include <qlistbox.h>
+#include <qcheckbox.h>
+#include <qstring.h>
+#include <qobject.h>
+#include <qtextstream.h>
+#include <qtabwidget.h>
+
+
+PackageManagerSettings::PackageManagerSettings( QWidget* parent, const char* name, WFlags fl )
+ : PackageManagerSettingsBase( parent, name, fl )
+{
+ connect( newserver, SIGNAL(clicked()), this, SLOT(newServer()) );
+ connect( removeserver, SIGNAL(clicked()), this, SLOT(removeServer()) );
+ connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) );
+ connect( newdestination, SIGNAL(clicked()), this, SLOT(newDestination()) );
+ connect( removedestination, SIGNAL(clicked()), this, SLOT(removeDestination()) );
+ connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) );
+ // connect( CheckBoxLink, SIGNAL(toggled(bool)),
+ // activeLinkDestination, SLOT(setEnabled(bool)) );
+
+ connect( settingName, SIGNAL(activated(int)), this, SLOT(installationSettingChange(int)) );
+ connect( settingName, SIGNAL(textChanged(const QString &)), this, SLOT(installationSettingSetName(const QString &)) );
+ connect( newsetting, SIGNAL(clicked()), this, SLOT(newInstallationSetting()) );
+ connect( renamesetting, SIGNAL(clicked()), this, SLOT(renameInstallationSetting()) );
+ connect( removesetting, SIGNAL(clicked()), this, SLOT(removeInstallationSetting()) );
+ servername->setEnabled(FALSE);
+ serverurl->setEnabled(FALSE);
+ serverurlDic.setAutoDelete(TRUE);
+ destinationname->setEnabled(FALSE);
+ destinationurl->setEnabled(FALSE);
+ destinationurlDic.setAutoDelete(TRUE);
+ readSettings();
+}
+
+PackageManagerSettings::~PackageManagerSettings()
+{
+}
+
+
+void PackageManagerSettings::newServer()
+{
+ int i = servers->count();
+ if ( servername->isEnabled() || serverurl->text().isEmpty() ) {
+ serverurlDic.insert(i,new QString("http://"));
+ servers->insertItem(tr("New"));
+ activeServers->insertItem(tr("New"));
+ } else {
+ // allows one-level undo
+ serverurlDic.insert(i,new QString(serverurl->text()));
+ servers->insertItem(servername->text());
+ activeServers->insertItem(servername->text());
+ }
+ servers->setSelected(i,TRUE);
+ editServer(i);
+}
+
+void PackageManagerSettings::newDestination()
+{
+ int i = destinations->count();
+ if ( destinationname->isEnabled() || destinationurl->text().isEmpty() ) {
+ destinationurlDic.insert(i,new QString("/"));
+ destinations->insertItem(tr("New"));
+ activeDestination->insertItem(tr("New"));
+ activeLinkDestination->insertItem(tr("New"));
+ } else {
+ // allows one-level undo
+ destinationurlDic.insert(i,new QString(destinationurl->text()));
+ destinations->insertItem(destinationname->text());
+ activeDestination->insertItem(destinationname->text());
+ activeLinkDestination->insertItem(destinationname->text());
+ }
+ destinations->setSelected(i,TRUE);
+ editDestination(i);
+}
+
+
+void PackageManagerSettings::editServer(int i)
+{
+ if ( servername->isEnabled() ) {
+ disconnect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) );
+ disconnect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) );
+ } else {
+ servername->setEnabled(TRUE);
+ serverurl->setEnabled(TRUE);
+ }
+
+ servername->setText( servers->text(i) );
+ serverurl->setText( *serverurlDic[i] );
+
+ editedserver = i;
+
+ connect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) );
+ connect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) );
+}
+
+
+void PackageManagerSettings::editDestination(int i)
+{
+ if ( destinationname->isEnabled() ) {
+ disconnect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) );
+ disconnect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) );
+ } else {
+ destinationname->setEnabled(TRUE);
+ destinationurl->setEnabled(TRUE);
+ }
+
+ destinationname->setText( destinations->text(i) );
+ destinationurl->setText( *destinationurlDic[i] );
+
+ editeddestination = i;
+
+ connect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) );
+ connect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) );
+}
+
+void PackageManagerSettings::removeServer()
+{
+ disconnect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) );
+ disconnect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) );
+ servername->setText(servers->text(editedserver));
+ serverurl->setText(*serverurlDic[editedserver]);
+ disconnect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) );
+ servers->removeItem(editedserver);
+ activeServers->removeItem(editedserver);
+ connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) );
+ servername->setEnabled(FALSE);
+ serverurl->setEnabled(FALSE);
+}
+
+void PackageManagerSettings::removeDestination()
+{
+ disconnect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) );
+ disconnect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) );
+ destinationname->setText(destinations->text(editedserver));
+ destinationurl->setText(*destinationurlDic[editedserver]);
+ disconnect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) );
+ destinations->removeItem(editeddestination);
+ activeDestination->removeItem(editeddestination);
+ activeLinkDestination->removeItem(editeddestination);
+ connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) );
+ destinationname->setEnabled(FALSE);
+ destinationurl->setEnabled(FALSE);
+}
+
+void PackageManagerSettings::serverNameChanged(const QString& t)
+{
+ disconnect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) );
+ servers->changeItem( t, editedserver );
+ activeServers->changeItem( t, editedserver );
+ connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) );
+}
+
+void PackageManagerSettings::destNameChanged(const QString& t)
+{
+ disconnect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) );
+ destinations->changeItem( t, editeddestination );
+ activeDestination->changeItem( t, editeddestination );
+ activeLinkDestination->changeItem( t, editeddestination );
+ connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) );
+}
+
+void PackageManagerSettings::serverUrlChanged(const QString& t)
+{
+ serverurlDic.replace(editedserver, new QString(t));
+}
+
+void PackageManagerSettings::destUrlChanged(const QString& t)
+{
+ destinationurlDic.replace(editeddestination, new QString(t));
+}
+
+void PackageManagerSettings::writeIpkgConfig(const QString& conffile)
+{
+ QFile conf(conffile);
+ if ( ! conf.open(IO_WriteOnly) ) return;
+ QTextStream s(&conf);
+ s << "# Written by qpie Package Manager\n";
+ for (int i=0; i<(int)activeServers->count(); i++)
+ {
+ QString url = serverurlDic[i] ? *serverurlDic[i] : QString("???");
+ if ( !activeServers->isSelected(i) )
+ s << "#";
+ s << "src " << activeServers->text(i) << " " << url << "\n";
+ }
+ for (int i=0; i<(int)destinations->count(); i++)
+ {
+ QString url = destinationurlDic[i] ? *destinationurlDic[i] : QString("???");
+ s << "dest " << destinations->text(i) << " " << url << "\n";
+ }
+ conf.close();
+}
+
+
+void PackageManagerSettings::readInstallationSettings()
+{
+ Config cfg( "oipkg", Config::User );
+ cfg.setGroup( "Settings" );
+ installationSettingsCount = cfg.readNumEntry( "count", -1 );
+ currentSetting = cfg.readNumEntry( "current", 0 );
+
+ for (int i = 0; i < installationSettingsCount; i++)
+ {
+ cfg.setGroup( "Setting_" + QString::number(i) );
+ settingName->insertItem( cfg.readEntry( "name", "???" ), i );
+ };
+ readInstallationSetting( currentSetting );
+}
+
+
+void PackageManagerSettings::removeInstallationSetting()
+{
+ settingName->removeItem( settingName->currentItem() );
+ Config cfg( "oipkg", Config::User );
+ cfg.setGroup( "Setting_" + QString::number( installationSettingsCount ) );
+ cfg.clearGroup();
+ installationSettingsCount--;
+ settingName->setEditable( false );
+}
+
+void PackageManagerSettings::newInstallationSetting()
+{
+ installationSettingsCount++;
+ settingName->insertItem( "New", installationSettingsCount );
+ settingName->setCurrentItem( installationSettingsCount );
+ settingName->setEditable( true );
+}
+
+void PackageManagerSettings::installationSettingChange(int cs)
+{
+ writeCurrentInstallationSetting();
+ currentSetting = cs;
+ readInstallationSetting( cs );
+}
+
+void PackageManagerSettings::writeInstallationSettings()
+{
+ {
+ Config cfg( "oipkg", Config::User );
+ cfg.setGroup( "Settings" );
+ cfg.writeEntry( "count", installationSettingsCount );
+ cfg.writeEntry( "current", currentSetting );
+ writeCurrentInstallationSetting();
+ }
+}
+
+
+void PackageManagerSettings::readInstallationSetting(int setting)
+{
+ if ( setting < 0 ) return;
+ Config cfg( "oipkg", Config::User );
+ cfg.setGroup( "Setting_" + QString::number( setting ) );
+ CheckBoxLink->setChecked( cfg.readBoolEntry( "link", false ) );
+ QString dest = cfg.readEntry( "dest" );
+ QString linkdest = cfg.readEntry( "linkdest" );
+
+ for ( int i = 0; i < activeDestination->count(); i++)
+ {
+ QString name = cfg.readEntry( "name" );
+ if ( activeDestination->text( i ) == name )
+ activeDestination->setCurrentItem( i );
+ if ( activeLinkDestination->text( i ) == name )
+ activeLinkDestination->setCurrentItem( i );
+ }
+}
+
+void PackageManagerSettings::writeCurrentInstallationSetting()
+{
+ Config cfg( "oipkg", Config::User );
+ cfg.setGroup( "Setting_" + QString::number(currentSetting) );
+ cfg.writeEntry( "link", CheckBoxLink->isChecked() );
+ cfg.writeEntry( "dest", getDestinationName() );
+ cfg.writeEntry( "linkdest" , getLinkDestinationName() );
+ QStringList sers = getActiveServers();
+ int srvc = 0;
+ for ( QStringList::Iterator it = sers.begin(); it != sers.end(); ++it ) {
+ cfg.writeEntry( "server_" + QString::number(srvc++), *it );
+ }
+ cfg.writeEntry( "server_count", srvc );
+}
+
+void PackageManagerSettings::renameInstallationSetting()
+{
+ settingName->setEditable( true );
+}
+
+void PackageManagerSettings::installationSettingSetName(const QString &name)
+{
+ settingName->changeItem( name, settingName->currentItem() );
+}
+
+
+bool PackageManagerSettings::readIpkgConfig(const QString& conffile)
+{
+ QFile conf(conffile);
+ if ( conf.open(IO_ReadOnly) ) {
+ QTextStream s(&conf);
+ servers->clear();
+ activeServers->clear();
+ activeDestination->clear();
+ activeLinkDestination->clear();
+ serverurlDic.clear();
+ destinationurlDic.clear();
+ ipkg_old=0;
+ int currentserver=0;
+ while ( !s.atEnd() ) {
+ QString l = s.readLine();
+ QStringList token = QStringList::split(' ', l);
+ if ( token[0] == "src" || token[0] == "#src" ) {
+ currentserver=servers->count();
+ serverurlDic.insert(servers->count(),new QString(token[2]));
+ int a = token[0] == "src" ? 1 : 0;
+ int i = servers->count();
+ servers->insertItem(token[1]);
+ activeServers->insertItem( token[1] );
+ activeServers->setSelected(i,a);
+ } else if ( token[0] == "dest" ) {
+ currentserver=destinations->count();
+ destinationurlDic.insert(destinations->count(),new QString(token[2]));
+ destinations->insertItem(token[1]);
+ activeDestination->insertItem( token[1] );
+ activeLinkDestination->insertItem( token[1] );
+
+ } else if ( token[0] == "option" ) {
+ } else {
+ // Old style?
+ int eq = l.find('=');
+ if ( eq >= 0 ) {
+ QString v = l.mid(eq+1).stripWhiteSpace();
+ if ( v[0] == '"' || v[0] == '\'' ) {
+ int cl=v.find(v[0],1);
+ if ( cl >= 0 )
+ v = v.mid(1,cl-1);
+ }
+ if ( l.left(12) == "IPKG_SOURCE=" ) {
+ ipkg_old=1;
+ currentserver=servers->count();
+ serverurlDic.insert(servers->count(),new QString(v));
+ servers->insertItem(v);
+ } else if ( l.left(13) == "#IPKG_SOURCE=" ) {
+ serverurlDic.insert(servers->count(),new QString(v));
+ servers->insertItem(v);
+ } else if ( l.left(10) == "IPKG_ROOT=" ) {
+
+ }
+ }
+ }
+ }
+ if ( ipkg_old ) {
+ servers->setSelectionMode(QListBox::Single);
+ servers->setSelected(currentserver,TRUE);
+ }
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
+void PackageManagerSettings::readSettings()
+{
+ readIpkgConfig("/etc/ipkg.conf");
+ readInstallationSettings();
+}
+
+void PackageManagerSettings::writeSettings()
+{
+ writeIpkgConfig("/etc/ipkg.conf");
+ writeInstallationSettings();
+}
+
+bool PackageManagerSettings::showDialog( int i )
+{
+ TabWidget->setCurrentPage( i );
+ showMaximized();
+ bool ret = exec();
+ if ( ret ) writeSettings();
+ else readSettings();
+ return ret;
+}
+
+QString PackageManagerSettings::getDestinationName()
+{
+ return activeDestination->currentText();
+}
+
+QString PackageManagerSettings::getLinkDestinationName()
+{
+ return activeLinkDestination->currentText();
+}
+
+/** Returns the URL of the active destination */
+QString PackageManagerSettings::getDestinationUrl()
+{
+ int dnr = activeDestination->currentItem();
+ return *destinationurlDic.find(dnr);
+}
+
+/** Should oipkg create links form install destination to link destination */
+bool PackageManagerSettings::createLinks()
+{
+ return CheckBoxLink->isChecked();
+}
+
+/** get the servers that are active */
+QStringList PackageManagerSettings::getActiveServers()
+{
+ QStringList sl;
+ for (int i=0; i<(int)activeServers->count(); i++)
+ {
+ if ( activeServers->isSelected(i) )
+ sl += activeServers->text(i);
+ }
+ return sl;
+}
+
+/** returns the destination listed in ipkg.conf */
+QStringList PackageManagerSettings::getDestinationUrls()
+{
+ QStringList sl;
+ for (int i=0; i<(int)destinations->count(); i++)
+ {
+ sl += *destinationurlDic[i];
+ }
+ return sl;
+}
+
+void PackageManagerSettings::linkEnabled( bool b )
+{
+ activeLinkDestination->setEnabled( b );
+}
diff --git a/noncore/unsupported/oipkg/settings.h b/noncore/unsupported/oipkg/settings.h
new file mode 100644
index 0000000..d4b1072
--- a/dev/null
+++ b/noncore/unsupported/oipkg/settings.h
@@ -0,0 +1,62 @@
+#ifndef PACKAGEMANAGERSETTINGS_H
+#define PACKAGEMANAGERSETTINGS_H
+
+#include "pksettingsbase.h"
+#include <qintdict.h>
+
+
+class PackageManagerSettings : private PackageManagerSettingsBase
+{
+ // Q_OBJECT
+public:
+ PackageManagerSettings( QWidget* , const char* , WFlags );
+ ~PackageManagerSettings();
+
+ bool showDialog( int ) ;
+ QString getDestinationUrl();
+ QString getDestinationName();
+ QString getLinkDestinationName();
+ bool createLinks();
+ QStringList getActiveServers();
+ QStringList getDestinationUrls();
+
+private:
+ QIntDict<QString> serverurlDic;
+ QIntDict<QString> destinationurlDic;
+ int ipkg_old;
+ int editedserver;
+ int editeddestination;
+ int currentSetting;
+ int installationSettingsCount;
+ bool changed;
+
+ bool readIpkgConfig(const QString&);
+ void writeIpkgConfig(const QString&);
+ void writeSettings();
+ void readSettings();
+
+public slots:
+ void writeInstallationSettings();
+ void readInstallationSettings();
+ void writeCurrentInstallationSetting();
+ void readInstallationSetting(int);
+ void installationSettingSetName(const QString &);
+
+ void newServer();
+ void editServer(int);
+ void removeDestination();
+ void newDestination();
+ void editDestination(int);
+ void linkEnabled(bool);
+ void removeServer();
+ void serverNameChanged(const QString&);
+ void serverUrlChanged(const QString&);
+ void destNameChanged(const QString&);
+ void destUrlChanged(const QString&);
+ void installationSettingChange(int);
+ void newInstallationSetting();
+ void removeInstallationSetting();
+ void renameInstallationSetting();
+};
+
+#endif