summaryrefslogtreecommitdiff
authortille <tille>2002-04-23 11:16:45 (UTC)
committer tille <tille>2002-04-23 11:16:45 (UTC)
commita3205d9bf5570af8441ed81cd6d9eeadf22319c9 (patch) (unidiff)
treee2403e5dcc46906570cb070b852ee83d9a8af0b8
parent7e8db7f310d7a43326337a7960e59d9e313b8534 (diff)
downloadopie-a3205d9bf5570af8441ed81cd6d9eeadf22319c9.zip
opie-a3205d9bf5570af8441ed81cd6d9eeadf22319c9.tar.gz
opie-a3205d9bf5570af8441ed81cd6d9eeadf22319c9.tar.bz2
... mostly rewritten.
Diffstat (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 @@
1.cvsignore
1Makefile* 2Makefile*
2moc_* 3moc_*
3pkfind.cpp 4*~
4pkfind.h 5*.kdev*
5pksettings.cpp
6pksettings.h
7pkdesc.cpp
8pkdesc.h
9packagemanagerbase.cpp
10packagemanagerbase.h
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 @@
1* search
2* parse "to install" and "to remove" from status
3* Settings Class
4* Dialog to display ipkg output live
5* install local file
6* make oipkg determine dest of to remove apps
7* error handling
8* 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 @@
1#ifndef _DEBUG_H_
2#define _DEBUG_H_
3
4#include <stdio.h>
5
6extern int debugLevel;
7
8#define HACK
9
10
11#define pvDebug(I, S) \
12if ( debugLevel < 3 ) \
13{ \
14 if ( I <= debugLevel ) qDebug(S);\
15}else{\
16 if ( I <= debugLevel ) \
17 printf("# %s \t\t(Level: %i)\n",QString(S).latin1(),I);\
18}
19
20#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 @@
1
2#include "mainwindow.h"
3
4#include <qpe/qpeapplication.h>
5#include <qstring.h>
6int debugLevel;
7
8int main( int argc, char ** argv )
9{
10 debugLevel = 1;
11 if (argc > 2)
12 {
13 debugLevel = QString ( argv[1] ).toInt();
14 }
15 QPEApplication a( argc, argv );
16 MainWindow mw;
17 a.showMainDocumentWidget( &mw );
18 return a.exec();
19}
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 @@
1// adadpted form qpe/qipkg
2
3
4#include "mainwindow.h"
5
6#include <qpe/qpemenubar.h>
7#include <qpe/qpemessagebox.h>
8#include <qpe/resource.h>
9#include <qpe/qpetoolbar.h>
10#include <qaction.h>
11#include <qmessagebox.h>
12#include <qpopupmenu.h>
13#include <qtoolbutton.h>
14#include <qstring.h>
15#include <qlistview.h>
16#include <qtextview.h>
17#include <qtabwidget.h>
18#include <qcombobox.h>
19#include <qlayout.h>
20
21#include "pksettingsbase.h"
22#include "packagelistitem.h"
23
24MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f = 0 ) :
25 QMainWindow( parent, name, f )
26 {
27 setCaption( tr("Package Manager") );
28 table = new PackageWindow( this,0,0 );
29 setCentralWidget( table );
30 makeMenu();
31
32 QFontMetrics fm = fontMetrics();
33 int w0 = fm.width(tr("Package"))+30;
34 int w2 = fm.width("00000")+4;
35 table->ListViewPackages->setColumnWidth(0,w0);
36 table->ListViewPackages->setColumnWidth(1,228-w2-w0); // ### screen-biased
37 table->ListViewPackages->setColumnWidth(2,w2);
38 table->ListViewPackages->setColumnWidthMode(0,QListView::Manual);
39 table->ListViewPackages->setColumnWidthMode(1,QListView::Manual);
40 table->ListViewPackages->setColumnWidthMode(2,QListView::Manual);
41 table->ListViewPackages->setSelectionMode( QListView::Multi );
42
43 connect( table->section, SIGNAL( activated(int) ),
44 this, SLOT( sectionChanged() ) );
45 connect( table->subsection, SIGNAL(activated(int) ),
46 this, SLOT( subSectionChanged() ) );
47 connect( table->ListViewPackages, SIGNAL( clicked( QListViewItem* ) ),
48 this, SLOT( setCurrent( QListViewItem* ) ) );
49
50 settings = new PackageManagerSettings(this,0,TRUE);
51
52 ipkg = new PmIpkg( settings, this );
53 packageList.setSettings( settings );
54 newList();
55 setSections();
56 setSubSections();
57 displayList();
58}
59
60void MainWindow::makeMenu()
61{
62
63 QPEToolBar *toolBar = new QPEToolBar( this );
64 QPEMenuBar *menuBar = new QPEMenuBar( toolBar );
65 QPopupMenu *srvMenu = new QPopupMenu( menuBar );
66 QPopupMenu *cfgMenu = new QPopupMenu( menuBar );
67 // QPopupMenu *sectMenu = new QPopupMenu( menuBar );
68
69 contextMenu = new QPopupMenu( this );
70
71 setToolBarsMovable( false );
72 toolBar->setHorizontalStretchable( true );
73 menuBar->insertItem( tr( "Package" ), srvMenu );
74 menuBar->insertItem( tr( "Settings" ), cfgMenu );
75 // menuBar->insertItem( tr( "Sections" ), sectMenu );
76
77 toolBar->setStretchableWidget (srvMenu);
78
79
80 runAction = new QAction( tr( "Run" ),
81 Resource::loadPixmap( "oipkg/install" ),
82 QString::null, 0, this, 0 );
83 connect( runAction, SIGNAL( activated() ),
84 this, SLOT( runIpkg() ) );
85 runAction->addTo( toolBar );
86 runAction->addTo( srvMenu );
87
88 srvMenu->insertSeparator ();
89
90 updateAction = new QAction( tr( "Update" ),
91 Resource::loadIconSet( "oipkg/repeat" ),
92 QString::null, 0, this, 0 );
93 connect( updateAction, SIGNAL( activated() ),
94 this , SLOT( updateList() ) );
95 updateAction->addTo( toolBar );
96 updateAction->addTo( srvMenu );
97
98 // detailsAction = new QAction( tr( "Details" ),
99 // Resource::loadIconSet( "oipkg/details" ),
100 // QString::null, 0, this, 0 );
101 // connect( detailsAction, SIGNAL( activated() ),
102 // this , SLOT( showDetails() ) );
103 // detailsAction->addTo( toolBar );
104 // detailsAction->addTo( srvMenu );
105
106 QAction *cfgact;
107
108 cfgact = new QAction( tr( "Setups" ),
109 Resource::loadIconSet( "" ),
110 QString::null, 0, this, 0 );
111 connect( cfgact, SIGNAL( activated() ),
112 SLOT( showSettings() ) );
113 cfgact->addTo( cfgMenu );
114
115 cfgact = new QAction( tr( "Servers" ),
116 Resource::loadIconSet( "" ),
117 QString::null, 0, this, 0 );
118 connect( cfgact, SIGNAL( activated() ),
119 SLOT( showSettingsSrv() ) );
120 cfgact->addTo( cfgMenu );
121 cfgact = new QAction( tr( "Destinations" ),
122 Resource::loadIconSet( "" ),
123 QString::null, 0, this, 0 );
124 connect( cfgact, SIGNAL( activated() ),
125 SLOT( showSettingsDst() ) );
126 cfgact->addTo( cfgMenu );
127
128}
129
130MainWindow::~MainWindow()
131{
132}
133
134void MainWindow::runIpkg()
135{
136 ipkg->commit( packageList );
137 ipkg->runIpkg("update");
138 packageList.update();
139}
140
141void MainWindow::updateList()
142{
143 ipkg->runIpkg("update");
144 packageList.update();
145}
146
147void MainWindow::newList()
148{
149 packageList.update();
150}
151
152void MainWindow::filterList()
153{
154 packageList.filterPackages();
155}
156
157void MainWindow::displayList()
158{
159 table->ListViewPackages->clear();
160 Package *pack = packageList.first();
161 while( pack )
162 {
163 if ( pack && (pack->name() != "") )
164 {
165 table->ListViewPackages->insertItem(
166 new PackageListItem( table->ListViewPackages, pack ) );
167 }
168 pack = packageList.next();
169 }
170}
171
172void MainWindow::sectionChanged()
173{
174 disconnect( table->section, SIGNAL( activated(int) ),
175 this, SLOT( sectionChanged() ) );
176 disconnect( table->subsection, SIGNAL(activated(int) ),
177 this, SLOT( subSectionChanged() ) );
178 table->subsection->clear();
179 packageList.setSection( table->section->currentText() );
180 setSubSections();
181 filterList();
182 connect( table->section, SIGNAL( activated(int) ),
183 this, SLOT( sectionChanged() ) );
184 connect( table->subsection, SIGNAL(activated(int) ),
185 this, SLOT( subSectionChanged() ) );
186 displayList();
187}
188
189void MainWindow::subSectionChanged()
190{
191 disconnect( table->section, SIGNAL( activated(int) ),
192 this, SLOT( sectionChanged() ) );
193 disconnect( table->subsection, SIGNAL(activated(int) ),
194 this, SLOT( subSectionChanged() ) );
195 packageList.setSubSection( table->subsection->currentText() );
196 filterList();
197 connect( table->section, SIGNAL( activated(int) ),
198 this, SLOT( sectionChanged() ) );
199 connect( table->subsection, SIGNAL(activated(int) ),
200 this, SLOT( subSectionChanged() ) );
201 displayList();
202}
203
204void MainWindow::setSections()
205{
206 table->section->clear();
207 table->section->insertStringList( packageList.getSections() );
208}
209
210void MainWindow::setSubSections()
211{
212 table->subsection->clear();
213 table->subsection->insertStringList( packageList.getSubSections() );
214}
215
216
217void MainWindow::showSettings()
218{
219 if ( settings->showDialog( 0 ) )
220 newList();
221}
222void MainWindow::showSettingsSrv()
223{
224 if ( settings->showDialog( 1 ) )
225 newList();
226}
227void MainWindow::showSettingsDst()
228{
229 if ( settings->showDialog( 2 ) )
230 newList();
231}
232
233
234void MainWindow::showDetails()
235{
236 if ( activePackage ) return;
237 if ( details )
238 {
239 details = new PackageDetails( this );
240 connect( details->install, SIGNAL(clicked()), SLOT( toggleActivePackage() ) );
241 connect( details->remove, SIGNAL(clicked()), SLOT( toggleActivePackage() ) );
242 connect( details->ignore, SIGNAL(clicked()), details, SLOT(close()));
243 details->description->setTextFormat(RichText);
244 }
245
246 details->setCaption("Package: " + activePackage->name());
247 details->description->setText(activePackage->details() );
248 details->install->setEnabled(!activePackage->installed());
249 details->remove->setEnabled(activePackage->installed());
250 details->showMaximized();
251}
252
253void MainWindow::toggleActivePackage()
254{
255 activePackage->toggleProcess();
256 if ( details ) details->close();
257}
258
259void MainWindow::setCurrent( QListViewItem* p )
260{
261 pvDebug(2, "MainWindow::setCurrent ");
262 //+((Package*)p)->name());
263 activePackage = (Package*)p;
264}
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 @@
1#ifndef MAINWINDOW_H
2#define MAINWINDOW_H
3
4#include <qmainwindow.h>
5#include <qaction.h>
6#include <qpopupmenu.h>
7
8#include "packagelist.h"
9#include "pmipkg.h"
10#include "pksettings.h"
11#include "pkdesc.h"
12
13#include "pkwindow.h"
14
15class MainWindow : public QMainWindow
16{
17 Q_OBJECT
18
19
20public:
21 MainWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
22 ~MainWindow();
23
24
25protected:
26 PackageWindow *table;
27
28
29protected slots:
30 void runIpkg();
31 void newList();
32 void updateList();
33 void filterList();
34 void displayList();
35 void subSectionChanged();
36 void sectionChanged();
37 void showSettings();
38 void showSettingsSrv();
39 void showSettingsDst();
40
41public slots:
42 void showDetails();
43 void toggleActivePackage();
44 void setCurrent( QListViewItem* );
45
46private:
47 void makeMenu();
48 void setSections();
49 void setSubSections();
50
51 PmIpkg* ipkg;
52 PackageManagerSettings *settings;
53 PackageDetails* details;
54 PackageList packageList;
55 Package *activePackage;
56 QAction *runAction;
57 QAction *detailsAction;
58 QAction *updateAction;
59 QPopupMenu *contextMenu;
60};
61
62#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 @@
1 DESTDIR = $(OPIEDIR)/bin
2 TEMPLATE= app
3 CONFIG = qt warn_on release
4 #CONFIG = qt warn_on debug
5 HEADERS = mainwindow.h \
6 pksettings.h \
7 pmipkg.h \
8 packagelistitem.h \
9 packagelist.h \
10 package.h
11 SOURCES = main.cpp \
12 mainwindow.cpp \
13 pksettings.cpp \
14 pmipkg.cpp \
15 packagelistitem.cpp \
16 packagelist.cpp \
17 package.cpp
18INCLUDEPATH += $(OPIEDIR)/include
19 DEPENDPATH+= $(OPIEDIR)/include
20LIBS += -lqpe
21LIBS += -ljpeg
22 INTERFACES= pkdesc.ui \
23 pkfind.ui \
24 runwindow.ui \
25 pkwindow.ui \
26 pksettingsbase.ui
27 TARGET = oipkg
28
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 @@
1Files: bin/oipkg apps/Settings/oipkg.desktop pics/oipkg/
2Priority: optional
3Section: opie/settings
4Maintainer: Patrick S. Vogt <tille@almana.ch>
5Architecture: arm
6Version: $QPE_VERSION-$SUB_VERSION
7Depends: opie-base ($QPE_VERSION)
8Description: Package Manager
9 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 @@
1#include "package.h"
2
3#include <qpe/process.h>
4#include <qpe/stringutil.h>
5
6#include "debug.h"
7
8Package::~Package()
9{
10}
11
12Package::Package()
13{
14 _size = "";
15 _section = "";
16 _subsection = "";
17 _shortDesc = "";
18 _desc = "";
19 _name = "";
20 _toProcess = true;
21 _status = "";
22}
23
24Package::Package( QStringList pack )
25 {
26 Package();
27 parsePackage( pack );
28 _toProcess = false;
29}
30
31Package::Package( QString n )
32 {
33 Package();
34 _name = QString( n );
35 _toProcess = false;
36}
37
38Package::Package( Package *pi )
39{
40 Package();
41 copyValues( pi );
42 _toProcess = false;
43}
44
45
46void Package::setValue( QString n, QString t )
47{
48 if ( n == "Status" && installed() ) return;
49 if ( n == "Package" )
50 {
51 _name = QString( t );
52 }
53 if ( n == "Installed-Size" )
54 {
55 _size = t;
56 }
57 if ( n == "Priority")
58 {
59
60 }
61 if ( n == "Section")
62 {
63 setSection( t );
64 }
65 if ( n == "Maintainer")
66 {
67
68 }
69 if ( n == "Architecture")
70 {
71
72 }
73 if ( n == "Version")
74 {
75
76 }
77 if ( n == "Pre-Depends")
78 {
79
80 }
81 if ( n == "Depends")
82 {
83
84 }else if ( n == "Filename")
85 {
86
87 }else if ( n == "Size")
88 {
89
90 }else if ( n == "MD5Sum")
91 {
92
93 }
94 if ( n == "Description")
95 {
96 setDesc( t );
97 }
98 if ( n == "Status")
99 {
100 if ( installed() ) return;
101 _status = t;
102 }
103 if ( t == "Essential")
104 {
105
106 }
107};
108
109QString Package::name()
110{
111 return _name;
112}
113
114bool Package::installed()
115{
116 return _status.contains("installed");
117}
118
119void Package::setDesc( QString s )
120{
121 _desc = s;
122 _shortDesc = s.left( s.find("\n") );
123}
124
125QString Package::desc()
126{
127 return _desc;
128}
129
130QString Package::shortDesc()
131{
132 return _shortDesc;
133}
134
135QString Package::size()
136{
137 return _size;
138}
139
140bool Package::toProcess()
141{
142 return _toProcess;
143}
144
145bool Package::toRemove()
146{
147 if ( _toProcess && installed() ) return true;
148 else return false;
149}
150
151bool Package::toInstall()
152{
153 if ( _toProcess && !installed() ) return true;
154 else return false;
155}
156
157void Package::toggleProcess()
158{
159 _toProcess = !(_toProcess);
160}
161
162
163
164void Package::copyValues( Package* pack )
165{
166 if (_size.isEmpty() && !pack->_size.isEmpty()) _size = QString( pack->_size );
167 if (_section.isEmpty() && !pack->_section.isEmpty()) _section = QString( pack->_section );
168 if (_subsection.isEmpty()&& !pack->_subsection.isEmpty()) _subsection = QString( pack->_subsection );
169 if (_shortDesc.isEmpty() && !pack->_shortDesc.isEmpty()) _shortDesc = QString( pack->_shortDesc );
170 if (_desc.isEmpty() && !pack->_desc.isEmpty()) _desc = QString( pack->_desc );
171 if (_name.isEmpty() && !pack->_name.isEmpty()) _name = QString( pack->_name );
172 if (!installed() && _status.isEmpty() && !pack->_status.isEmpty()) _status = QString( pack->_status );
173}
174
175QString Package::getSection()
176{
177 return _section;
178}
179
180void Package::setSection( QString s)
181{
182 int i = s.find("/");
183 if ( i > 0 )
184 {
185 _section = s.left(i);
186 _subsection = s.mid(i+1);
187 }else{
188 _section = s;
189 _subsection = "";
190 }
191}
192
193QString Package::getSubSection()
194{
195 return _subsection;
196}
197
198void Package::parsePackage( QStringList pack )
199{
200 if ( pack.isEmpty() ) return;
201 int count = pack.count();
202 for( int i = 0; i < count; i++ )
203 {
204 QString line = pack[i];
205 int sep = line.find( QRegExp(":[\t ]+") );
206 if ( sep >= 0 )
207 {
208 QString tag = line.left(sep);
209 QString value = line.mid(sep+2).simplifyWhiteSpace();
210 setValue( tag, value );
211 }else{
212 }
213 }
214 return;
215}
216
217QString Package::details()
218{
219 QString status;
220 Process ipkg_status(QStringList() << "ipkg" << "info" << name() );
221 QString description;
222 if ( ipkg_status.exec("",status) )
223 {
224 QStringList lines = QStringList::split('\n',status,TRUE);
225 for (QStringList::Iterator it = lines.begin(); it!=lines.end(); ++it) {
226 QString line = *it;
227 if ( line == " ." )
228 {
229 description.append("<p>");
230 } else
231 if ( line[0] == ' ' || line[0] == '\t' )
232 {
233 // continuation
234 description.append(" ");
235 description.append(Qtopia::escapeString(line));
236 } else {
237 int sep = line.find(QRegExp(":[\t ]+"));
238 if ( sep >= 0 )
239 {
240 QString tag = line.left(sep);
241 description.append("<br>");
242 description.append("<b>");
243 description.append(Qtopia::escapeString(tag));
244 description.append(":</b> ");
245 description.append(Qtopia::escapeString(line.mid(sep+2)));
246 } else {
247 description.append(" ");
248 description.append(Qtopia::escapeString(line));
249 }
250 }
251 }
252 }
253 return description;
254}
255
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 @@
1#ifndef PK_ITEM_H
2#define PK_ITEM_H
3
4#include <qstring.h>
5#include <qlistview.h>
6#include <qpainter.h>
7#include <qpixmap.h>
8#include <qdict.h>
9#include <qobject.h>
10
11class Package //: public QObject
12{
13 //Q_OBJECT
14 public:
15 Package();
16 ~Package();
17 Package( QStringList );
18 Package( QString );
19 Package( Package* );
20
21 void setValue( QString, QString );
22 void copyValues( Package* );
23
24 QString name() ;
25 bool installed();
26
27 void setDesc( QString );
28 QString shortDesc();
29 QString desc();
30 QString size();
31 void setSection( QString );
32 QString getSection();
33 QString getSubSection();
34 QString details();
35 bool toProcess();
36 bool toInstall();
37 bool toRemove();
38public slots:
39 void toggleProcess();
40
41private:
42 QString _name;
43 bool _toProcess;
44 QString _status;
45 QString _size;
46 QString _section;
47 QString _subsection;
48 QString _shortDesc;
49 QString _desc;
50 void parsePackage( QStringList );
51};
52
53
54#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 @@
1#include "packagelist.h"
2
3#include <assert.h>
4#include <qfile.h>
5#include <qfileinfo.h>
6#include <qtextstream.h>
7#include <qpe/config.h>
8
9#include "debug.h"
10
11PackageList::PackageList()
12 : packageIter( packageList )
13{
14 empty=true;
15 {
16 Config cfg( "oipkg", Config::User );
17 cfg.setGroup( "Common" );
18 statusDir = cfg.readEntry( "statusDir", "" );
19 listsDir = cfg.readEntry( "listsDir", "" );
20 if ( statusDir=="" || ! QFileInfo(statusDir+"/status").isFile() )
21 {
22 statusDir="/usr/lib/ipkg/";
23 listsDir="/usr/lib/ipkg/lists/";
24 cfg.writeEntry( "statusDir", statusDir );
25 cfg.writeEntry( "listsDir", listsDir );
26 }
27 }
28 pvDebug( 5, "PackageList::PackageList statusDir "+statusDir);
29 pvDebug( 5, "PackageList::PackageList listsDir "+listsDir);
30 sections << "All";
31 subSections.insert("All", new QStringList() );
32 QStringList *ss = subSections["All"];
33 *ss << "All";
34 aktSection = "All";
35 aktSubSection = "All";
36}
37
38PackageList::PackageList( PackageManagerSettings* s)
39 : packageIter( packageList )
40{
41 settings = s;
42 PackageList();
43}
44
45PackageList::~PackageList()
46{
47}
48
49/** Inserts a package into the list */
50void PackageList::insertPackage( Package* pack )
51{
52 Package* p = packageList.find( pack->name() );
53 if ( p )
54 {
55 p->copyValues( pack );
56 delete pack;
57 pack = p;
58 }else{
59 packageList.insert( pack->name(), pack );
60 origPackageList.insert( pack->name(), pack );
61 empty=false;
62 };
63 updateSections( pack );
64}
65
66void PackageList::filterPackages()
67 {
68 packageList.clear();
69 QDictIterator<Package> filterIter( origPackageList );
70 filterIter.toFirst();
71 Package *pack= filterIter.current() ;
72 while ( pack )
73 {
74 if ( ((aktSection=="All")||(pack->getSection()==aktSection)) &&
75 ((aktSubSection=="All")||(pack->getSubSection()==aktSubSection)) )
76 {
77 packageList.insert( pack->name(), pack );
78 }
79 ++filterIter;
80 pack = filterIter.current();
81 }
82}
83
84Package* PackageList::find( QString n )
85{
86 return packageList.find( n );
87}
88
89Package* PackageList::first()
90 {
91 packageIter.toFirst();
92 return packageIter.current();
93}
94
95Package* PackageList::next()
96{
97 ++packageIter;
98 return packageIter.current();
99}
100
101QStringList PackageList::getSections()
102{
103 sections.sort();
104 return sections;
105}
106
107QStringList PackageList::getSubSections()
108{
109 QStringList ss;
110 if ( !subSections[aktSection] ) return ss;
111 ss = *subSections[aktSection];
112 ss.sort();
113 return ss;
114}
115
116void PackageList::setSection( QString sec )
117{
118 aktSection = sec;
119}
120
121void PackageList::setSubSection( QString ssec )
122{
123 aktSubSection = ssec;
124}
125
126void PackageList::updateSections( Package* pack )
127{
128 QString s = pack->getSection();
129 if ( s.isEmpty() || s == "") return;
130 if ( sections.contains(s) ) return;
131 sections += s;
132 QString ss = pack->getSubSection();
133 if ( ss.isEmpty() || ss == "" ) return;
134 if ( !subSections[s] ) {
135 subSections.insert( s, new QStringList() );
136 QStringList *subsecs = subSections[s];
137 *subsecs += "All";
138 }
139 QStringList *subsecs = subSections[s];
140 *subsecs += ss;
141 if ( !subSections["All"] ) subSections.insert( "All", new QStringList() );
142 subsecs = subSections["All"];
143 *subsecs += ss;
144}
145
146
147
148/** No descriptions */
149void PackageList::parseStatus()
150{
151 QStringList dests = settings->getDestinationUrls();
152 for ( QStringList::Iterator it = dests.begin(); it != dests.end(); ++it )
153 {
154 pvDebug( 2,"Status Dir: "+*it+statusDir+"/status");
155 readFileEntries( *it+statusDir+"/status" );
156 };
157}
158
159void PackageList::parseList()
160{
161 QStringList srvs = settings->getActiveServers();
162
163 for ( QStringList::Iterator it = srvs.begin(); it != srvs.end(); ++it )
164 {
165 pvDebug( 2, "List Dir: "+listsDir+"/"+*it);
166 readFileEntries( listsDir+"/"+*it );
167 }
168}
169
170void PackageList::readFileEntries( QString filename )
171 {
172 QStringList packEntry;
173 QFile f( filename );
174 if ( !f.open(IO_ReadOnly) ) return;
175 QTextStream *statusStream = new QTextStream( &f );
176 while ( !statusStream ->eof() )
177 {
178 QString line = statusStream->readLine();
179 if ( line.find(QRegExp("[\n\t ]*")) || line == "" )
180 {
181 //end of package
182 if ( ! packEntry.isEmpty() )
183 {
184 Package *p = new Package( packEntry );
185 if ( p )
186 {
187 insertPackage( p );
188 packEntry.clear();
189 }
190 }
191 }else{
192 packEntry << line;
193 };
194 }
195 return;
196}
197
198
199void PackageList::update()
200{
201 pvDebug( 3, "parseStatus");
202 parseStatus();
203 pvDebug( 3, "parseList");
204 parseList();
205 pvDebug( 3, "finished parsing");
206}
207
208
209
210/** No descriptions */
211void PackageList::setSettings( PackageManagerSettings *s )
212{
213 settings = s;
214}
215
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 @@
1#ifndef PACKAGELIST_H
2#define PACKAGELIST_H
3
4#include <qdict.h>
5#include "package.h"
6#include "pksettings.h"
7#include "debug.h"
8
9#define HACK
10#ifdef HACK
11 static QString listsDir="/usr/lib/ipkg/";
12 static QString statusDir="/usr/lib/ipkg/";
13#endif
14
15class PackageList {
16public:
17 PackageList();
18 PackageList( PackageManagerSettings* );
19 ~PackageList();
20 void insertPackage( Package* );
21 Package* find( QString );
22 Package* next();
23 Package* first();
24
25 QStringList getSections();
26 QStringList getSubSections();
27 void setSettings( PackageManagerSettings* );
28 void filterPackages();
29
30public slots:
31 void setSection(QString);
32 void setSubSection(QString);
33 void update();
34
35private:
36 int currentPackage;
37 int packageCount;
38
39 PackageManagerSettings *settings;
40 QDict<Package> packageList;
41 QDict<Package> origPackageList;
42 QDictIterator<Package> packageIter;
43
44 bool empty;
45#ifndef HACK
46 QString listsDir;
47 QString statusDir;
48#endif
49 QString aktSection;
50 QString aktSubSection;
51 QStringList sections;
52 QDict<QStringList> subSections;
53 QDict<bool> sectionsDict;
54
55
56 void updateSections( Package* );
57 void parseStatus();
58 void parseList();
59 void readFileEntries( QString );
60};
61
62
63#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 @@
1#include "packagelistitem.h"
2
3#include <qpe/resource.h>
4
5static QPixmap *pm_uninstalled=0;
6static QPixmap *pm_installed=0;
7static QPixmap *pm_uninstall=0;
8static QPixmap *pm_install=0;
9
10PackageListItem::PackageListItem(QListView* lv, Package *pi)
11 :QCheckListItem(lv,pi->name(),CheckBox)
12{
13 package = pi;
14 if (!pm_uninstalled) {
15 pm_uninstalled = new QPixmap(Resource::loadPixmap("oipkg/uninstalled"));
16 pm_installed = new QPixmap(Resource::loadPixmap("oipkg/installed"));
17 pm_install = new QPixmap(Resource::loadPixmap("oipkg/install"));
18 pm_uninstall = new QPixmap(Resource::loadPixmap("oipkg/uninstall"));
19 }
20 setText(1, package->shortDesc() );
21 setText(2, package->size() );
22}
23
24void PackageListItem::paintCell( QPainter *p, const QColorGroup & cg,
25 int column, int width, int alignment )
26{
27 if ( !p )
28 return;
29
30 p->fillRect( 0, 0, width, height(),
31 isSelected()? cg.highlight() : cg.base() );
32
33 if ( column != 0 ) {
34 // The rest is text
35 QListViewItem::paintCell( p, cg, column, width, alignment );
36 return;
37 }
38
39 QListView *lv = listView();
40 if ( !lv )
41 return;
42 int marg = lv->itemMargin();
43 int r = marg;
44
45 QPixmap pm = statePixmap();
46 p->drawPixmap(marg,(height()-pm.height())/2,pm);
47 r += pm.width()+1;
48
49 p->translate( r, 0 );
50 QListViewItem::paintCell( p, cg, column, width - r, alignment );
51}
52
53
54void PackageListItem::paintFocus( QPainter *p, const QColorGroup & cg,
55 const QRect & r )
56{
57 // Skip QCheckListItem
58 // (makes you wonder what we're getting from QCheckListItem)
59 QListViewItem::paintFocus(p,cg,r);
60}
61
62QPixmap PackageListItem::statePixmap() const
63{
64 bool installed = package->installed();
65 if ( !package->toProcess() ) {
66 if ( !installed )
67 return *pm_uninstalled;
68 else
69 return *pm_installed;
70 } else {
71 if ( !installed )
72 return *pm_install;
73 else
74 return *pm_uninstall;
75 }
76}
77
78QString PackageListItem::key( int column, bool ascending ) const
79{
80 if ( column == 2 ) {
81 QString t = text(2);
82 double bytes=t.toDouble();
83 if ( t.contains('M') ) bytes*=1024*1024;
84 else if ( t.contains('K') || t.contains('k') ) bytes*=1024;
85 if ( !ascending ) bytes=999999999-bytes;
86 return QString().sprintf("%09d",(int)bytes);
87 } else {
88 return QListViewItem::key(column,ascending);
89 }
90}
91
92void PackageListItem::setOn( bool b )
93{
94 QCheckListItem::setOn( b );
95 package->toggleProcess();
96 repaint();
97}
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 @@
1#ifndef PK_LISTITEM_H
2#define PK_LISTITEM_H
3
4#include "package.h"
5
6#include <qstring.h>
7#include <qlistview.h>
8#include <qpainter.h>
9#include <qpixmap.h>
10#include <qdict.h>
11
12class PackageListItem
13: public QCheckListItem
14{
15public:
16 PackageListItem(QListView*, Package* );
17 void paintCell( QPainter*, const QColorGroup&, int, int, int );
18 void paintFocus( QPainter*, const QColorGroup&, const QRect& );
19 QPixmap statePixmap() const;
20 QString key( int, bool ) const;
21 Package* getPackage() { return package; } ;
22 QString getName() { return package->name(); } ;
23 bool isInstalled(){ return package->installed(); };
24 virtual void setOn ( bool );
25
26private:
27 Package *package;
28};
29
30
31#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 @@
1<!DOCTYPE UI><UI>
2<class>PackageDetails</class>
3<widget>
4 <class>QDialog</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>Form7</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>221</width>
15 <height>291</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>(pkgname)</string>
21 </property>
22 <property>
23 <name>layoutMargin</name>
24 </property>
25 <property>
26 <name>layoutSpacing</name>
27 </property>
28 <vbox>
29 <property stdset="1">
30 <name>margin</name>
31 <number>6</number>
32 </property>
33 <property stdset="1">
34 <name>spacing</name>
35 <number>3</number>
36 </property>
37 <widget>
38 <class>QTextView</class>
39 <property stdset="1">
40 <name>name</name>
41 <cstring>description</cstring>
42 </property>
43 </widget>
44 <widget>
45 <class>QLayoutWidget</class>
46 <property stdset="1">
47 <name>name</name>
48 <cstring>Layout4</cstring>
49 </property>
50 <hbox>
51 <property stdset="1">
52 <name>margin</name>
53 <number>0</number>
54 </property>
55 <property stdset="1">
56 <name>spacing</name>
57 <number>6</number>
58 </property>
59 <widget>
60 <class>QToolButton</class>
61 <property stdset="1">
62 <name>name</name>
63 <cstring>install</cstring>
64 </property>
65 <property stdset="1">
66 <name>text</name>
67 <string>Install</string>
68 </property>
69 </widget>
70 <widget>
71 <class>QToolButton</class>
72 <property stdset="1">
73 <name>name</name>
74 <cstring>remove</cstring>
75 </property>
76 <property stdset="1">
77 <name>text</name>
78 <string>Remove</string>
79 </property>
80 </widget>
81 <widget>
82 <class>QToolButton</class>
83 <property stdset="1">
84 <name>name</name>
85 <cstring>ignore</cstring>
86 </property>
87 <property stdset="1">
88 <name>text</name>
89 <string>Ignore</string>
90 </property>
91 </widget>
92 </hbox>
93 </widget>
94 </vbox>
95</widget>
96</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 @@
1<!DOCTYPE UI><UI>
2<class>Search</class>
3<widget>
4 <class>QDialog</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>Form5</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>196</width>
15 <height>55</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>Search Packages</string>
21 </property>
22 <hbox>
23 <property stdset="1">
24 <name>margin</name>
25 <number>11</number>
26 </property>
27 <property stdset="1">
28 <name>spacing</name>
29 <number>6</number>
30 </property>
31 <widget>
32 <class>QLabel</class>
33 <property stdset="1">
34 <name>name</name>
35 <cstring>TextLabel4</cstring>
36 </property>
37 <property stdset="1">
38 <name>text</name>
39 <string>Find:</string>
40 </property>
41 </widget>
42 <widget>
43 <class>QLineEdit</class>
44 <property stdset="1">
45 <name>name</name>
46 <cstring>pattern</cstring>
47 </property>
48 </widget>
49 </hbox>
50</widget>
51</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 @@
1#include "pksettings.h"
2
3#include <qpe/process.h>
4#include <qpe/resource.h>
5#include <qpe/stringutil.h>
6#include <qpe/qpeapplication.h>
7#include <qpe/qcopenvelope_qws.h>
8#include <qpe/applnk.h>
9#include <qpe/config.h>
10
11#include <qprogressbar.h>
12#include <qcombobox.h>
13#include <qdict.h>
14#include <qfile.h>
15#include <qlineedit.h>
16#include <qpushbutton.h>
17#include <qlistview.h>
18#include <qlistbox.h>
19#include <qcheckbox.h>
20#include <qmessagebox.h>
21#include <qpainter.h>
22#include <qpixmap.h>
23#include <qregexp.h>
24#include <qstring.h>
25#include <qobject.h>
26#include <qtextstream.h>
27#include <qtextview.h>
28#include <qtoolbutton.h>
29#include <qtabwidget.h>
30
31#include <stdlib.h>
32#include <unistd.h>
33#include "debug.h"
34
35PackageManagerSettings::PackageManagerSettings( QWidget* parent, const char* name, WFlags fl )
36 : PackageManagerSettingsBase( parent, name, fl )
37{
38 connect( newserver, SIGNAL(clicked()), this, SLOT(newServer()) );
39 connect( removeserver, SIGNAL(clicked()), this, SLOT(removeServer()) );
40 connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) );
41 connect( newdestination, SIGNAL(clicked()), this, SLOT(newDestination()) );
42 connect( removedestination, SIGNAL(clicked()), this, SLOT(removeDestination()) );
43 connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) );
44 // connect( CheckBoxLink, SIGNAL(toggled(bool)),
45 // activeLinkDestination, SLOT(setEnabled(bool)) );
46
47 connect( settingName, SIGNAL(activated(int)), this, SLOT(installationSettingChange(int)) );
48 connect( settingName, SIGNAL(textChanged(const QString &)), this, SLOT(installationSettingSetName(const QString &)) );
49 connect( newsetting, SIGNAL(clicked()), this, SLOT(newInstallationSetting()) );
50 connect( renamesetting, SIGNAL(clicked()), this, SLOT(renameInstallationSetting()) );
51 connect( removesetting, SIGNAL(clicked()), this, SLOT(removeInstallationSetting()) );
52 servername->setEnabled(FALSE);
53 serverurl->setEnabled(FALSE);
54 serverurlDic.setAutoDelete(TRUE);
55 destinationname->setEnabled(FALSE);
56 destinationurl->setEnabled(FALSE);
57 destinationurlDic.setAutoDelete(TRUE);
58 readSettings();
59}
60
61PackageManagerSettings::~PackageManagerSettings()
62{
63}
64
65
66void PackageManagerSettings::newServer()
67{
68 int i = servers->count();
69 if ( servername->isEnabled() || serverurl->text().isEmpty() ) {
70 serverurlDic.insert(i,new QString("http://"));
71 servers->insertItem(tr("New"));
72 activeServers->insertItem(tr("New"));
73 } else {
74 // allows one-level undo
75 serverurlDic.insert(i,new QString(serverurl->text()));
76 servers->insertItem(servername->text());
77 activeServers->insertItem(servername->text());
78 }
79 servers->setSelected(i,TRUE);
80 editServer(i);
81}
82
83void PackageManagerSettings::newDestination()
84{
85 int i = destinations->count();
86 if ( destinationname->isEnabled() || destinationurl->text().isEmpty() ) {
87 destinationurlDic.insert(i,new QString("/"));
88 destinations->insertItem(tr("New"));
89 activeDestination->insertItem(tr("New"));
90 activeLinkDestination->insertItem(tr("New"));
91 } else {
92 // allows one-level undo
93 destinationurlDic.insert(i,new QString(destinationurl->text()));
94 destinations->insertItem(destinationname->text());
95 activeDestination->insertItem(destinationname->text());
96 activeLinkDestination->insertItem(destinationname->text());
97 }
98 destinations->setSelected(i,TRUE);
99 editDestination(i);
100}
101
102
103void PackageManagerSettings::editServer(int i)
104{
105 if ( servername->isEnabled() ) {
106 disconnect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) );
107 disconnect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) );
108 } else {
109 servername->setEnabled(TRUE);
110 serverurl->setEnabled(TRUE);
111 }
112
113 servername->setText( servers->text(i) );
114 serverurl->setText( *serverurlDic[i] );
115
116 editedserver = i;
117
118 connect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) );
119 connect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) );
120}
121
122
123void PackageManagerSettings::editDestination(int i)
124{
125 if ( destinationname->isEnabled() ) {
126 disconnect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) );
127 disconnect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) );
128 } else {
129 destinationname->setEnabled(TRUE);
130 destinationurl->setEnabled(TRUE);
131 }
132
133 destinationname->setText( destinations->text(i) );
134 destinationurl->setText( *destinationurlDic[i] );
135
136 editeddestination = i;
137
138 connect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) );
139 connect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) );
140}
141
142void PackageManagerSettings::removeServer()
143{
144 disconnect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) );
145 disconnect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) );
146 servername->setText(servers->text(editedserver));
147 serverurl->setText(*serverurlDic[editedserver]);
148 disconnect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) );
149 servers->removeItem(editedserver);
150 activeServers->removeItem(editedserver);
151 connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) );
152 servername->setEnabled(FALSE);
153 serverurl->setEnabled(FALSE);
154}
155
156void PackageManagerSettings::removeDestination()
157{
158 disconnect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) );
159 disconnect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) );
160 destinationname->setText(destinations->text(editedserver));
161 destinationurl->setText(*destinationurlDic[editedserver]);
162 disconnect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) );
163 destinations->removeItem(editeddestination);
164 activeDestination->removeItem(editeddestination);
165 activeLinkDestination->removeItem(editeddestination);
166 connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) );
167 destinationname->setEnabled(FALSE);
168 destinationurl->setEnabled(FALSE);
169}
170
171void PackageManagerSettings::serverNameChanged(const QString& t)
172{
173 disconnect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) );
174 servers->changeItem( t, editedserver );
175 activeServers->changeItem( t, editedserver );
176 connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) );
177}
178
179void PackageManagerSettings::destNameChanged(const QString& t)
180{
181 disconnect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) );
182 destinations->changeItem( t, editeddestination );
183 activeDestination->changeItem( t, editeddestination );
184 activeLinkDestination->changeItem( t, editeddestination );
185 connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) );
186}
187
188void PackageManagerSettings::serverUrlChanged(const QString& t)
189{
190 serverurlDic.replace(editedserver, new QString(t));
191}
192
193void PackageManagerSettings::destUrlChanged(const QString& t)
194{
195 destinationurlDic.replace(editeddestination, new QString(t));
196}
197
198void PackageManagerSettings::writeIpkgConfig(const QString& conffile)
199{
200 QFile conf(conffile);
201 if ( ! conf.open(IO_WriteOnly) ) return;
202 QTextStream s(&conf);
203 s << "# Written by qpie Package Manager\n";
204 for (int i=0; i<(int)activeServers->count(); i++)
205 {
206 QString url = serverurlDic[i] ? *serverurlDic[i] : QString("???");
207 if ( !activeServers->isSelected(i) )
208 s << "#";
209 s << "src " << activeServers->text(i) << " " << url << "\n";
210 }
211 for (int i=0; i<(int)destinations->count(); i++)
212 {
213 QString url = destinationurlDic[i] ? *destinationurlDic[i] : QString("???");
214 s << "dest " << destinations->text(i) << " " << url << "\n";
215 }
216 conf.close();
217}
218
219
220void PackageManagerSettings::readInstallationSettings()
221{
222 Config cfg( "oipkg", Config::User );
223 cfg.setGroup( "Settings" );
224 installationSettingsCount = cfg.readNumEntry( "count", -1 );
225 currentSetting = cfg.readNumEntry( "current", 0 );// o should be -1
226
227 for (int i = 0; i < installationSettingsCount; i++)
228 {
229 cfg.setGroup( "Setting_" + QString::number(i) );
230 settingName->insertItem( cfg.readEntry( "name", "???" ), i );
231 };
232 readInstallationSetting( currentSetting );
233}
234
235
236
237/**
238 * remove from conf file
239 */
240void PackageManagerSettings::removeInstallationSetting()
241{
242 settingName->removeItem( settingName->currentItem() );
243 Config cfg( "oipkg", Config::User );
244 cfg.setGroup( "Setting_" + QString::number( installationSettingsCount ) );
245 cfg.clearGroup();
246 installationSettingsCount--;
247 changed = true;
248 settingName->setEditable( false );
249}
250
251/**
252 * write to confgile
253 */
254void PackageManagerSettings::newInstallationSetting()
255{
256 installationSettingsCount++;
257 settingName->insertItem( "New", installationSettingsCount );
258 settingName->setCurrentItem( installationSettingsCount );
259 settingName->setEditable( true );
260 changed = true;
261}
262
263void PackageManagerSettings::installationSettingChange(int cs)
264{
265 writeCurrentInstallationSetting();
266 currentSetting = cs;
267 readInstallationSetting( cs );
268}
269
270void PackageManagerSettings::writeInstallationSettings()
271{
272 if ( ! changed ) return ;
273 {
274 Config cfg( "oipkg", Config::User );
275 cfg.setGroup( "Settings" );
276 cfg.writeEntry( "count", installationSettingsCount );
277 cfg.writeEntry( "current", currentSetting );
278 }
279 writeCurrentInstallationSetting();
280}
281
282
283void PackageManagerSettings::readInstallationSetting(int setting)
284{
285 if ( setting < 0 ) return;
286 Config cfg( "oipkg", Config::User );
287 cfg.setGroup( "Setting_" + QString::number( setting ) );
288 CheckBoxLink->setChecked( cfg.readBoolEntry( "link", false ) );
289 QString dest = cfg.readEntry( "dest" );
290 QString linkdest = cfg.readEntry( "linkdest" );
291 pvDebug(3, "dest="+dest);
292 pvDebug(3, "linkdest="+linkdest);
293
294 for ( int i = 0; i < activeDestination->count(); i++)
295 {
296 if ( activeDestination->text( i ) == dest )
297 activeDestination->setCurrentItem( i );
298 if ( activeLinkDestination->text( i ) == linkdest )
299 activeLinkDestination->setCurrentItem( i );
300 }
301}
302
303void PackageManagerSettings::writeCurrentInstallationSetting()
304{
305 Config cfg( "oipkg", Config::User );
306 changed = false;
307 cfg.setGroup( "Setting_" + QString::number(currentSetting) );
308 cfg.writeEntry( "link", CheckBoxLink->isChecked() );
309 cfg.writeEntry( "dest", getDestinationName() );
310 cfg.writeEntry( "linkdest" , getLinkDestinationName() );
311 QStringList sers = getActiveServers();
312 int srvc = 0;
313 for ( QStringList::Iterator it = sers.begin(); it != sers.end(); ++it ) {
314 cfg.writeEntry( "server_" + QString::number(srvc++), *it );
315 }
316 cfg.writeEntry( "server_count", srvc );
317}
318
319void PackageManagerSettings::renameInstallationSetting()
320{
321 settingName->setEditable( true );
322 changed = true;
323}
324
325void PackageManagerSettings::installationSettingSetName(const QString &name)
326{
327 settingName->changeItem( name, settingName->currentItem() );
328 changed = true;
329}
330
331
332bool PackageManagerSettings::readIpkgConfig(const QString& conffile)
333{
334 QFile conf(conffile);
335 if ( conf.open(IO_ReadOnly) ) {
336 QTextStream s(&conf);
337 servers->clear();
338 activeServers->clear();
339 activeDestination->clear();
340 activeLinkDestination->clear();
341 serverurlDic.clear();
342 destinationurlDic.clear();
343 ipkg_old=0;
344 int currentserver=0;
345 while ( !s.atEnd() ) {
346 QString l = s.readLine();
347 QStringList token = QStringList::split(' ', l);
348 if ( token[0] == "src" || token[0] == "#src" ) {
349 currentserver=servers->count();
350 serverurlDic.insert(servers->count(),new QString(token[2]));
351 int a = token[0] == "src" ? 1 : 0;
352 int i = servers->count();
353 servers->insertItem(token[1]);
354 activeServers->insertItem( token[1] );
355 activeServers->setSelected(i,a);
356 } else if ( token[0] == "dest" ) {
357 currentserver=destinations->count();
358 destinationurlDic.insert(destinations->count(),new QString(token[2]));
359 destinations->insertItem(token[1]);
360 activeDestination->insertItem( token[1] );
361 activeLinkDestination->insertItem( token[1] );
362
363 } else if ( token[0] == "option" ) {
364 // ### somehow need to use the settings from netsetup
365 // if ( token[1] == "http_proxy" )
366 // http->setText(token[2]);
367 // else if ( token[1] == "ftp_proxy" )
368 // ftp->setText(token[2]);
369 // else if ( token[1] == "proxy_username" )
370 // username->setText(token[2]);
371 // else if ( token[1] == "proxy_password" )
372 // password->setText(token[2]);
373 } else {
374 // Old style?
375 int eq = l.find('=');
376 if ( eq >= 0 ) {
377 QString v = l.mid(eq+1).stripWhiteSpace();
378 if ( v[0] == '"' || v[0] == '\'' ) {
379 int cl=v.find(v[0],1);
380 if ( cl >= 0 )
381 v = v.mid(1,cl-1);
382 }
383 if ( l.left(12) == "IPKG_SOURCE=" ) {
384 ipkg_old=1;
385 currentserver=servers->count();
386 serverurlDic.insert(servers->count(),new QString(v));
387 servers->insertItem(v);
388 } else if ( l.left(13) == "#IPKG_SOURCE=" ) {
389 serverurlDic.insert(servers->count(),new QString(v));
390 servers->insertItem(v);
391 } else if ( l.left(10) == "IPKG_ROOT=" ) {
392 // ### no UI
393 // } else if ( l.left(20) == "IPKG_PROXY_USERNAME=" ) {
394 // username->setText(v);
395 // } else if ( l.left(20) == "IPKG_PROXY_PASSWORD=" ) {
396 // password->setText(v);
397 // } else if ( l.left(16) == "IPKG_PROXY_HTTP=" ) {
398 // http->setText(v);
399 // } else if ( l.left(16) == "IPKG_PROXY_FTP=" ) {
400 // ftp->setText(v);
401 }
402 }
403 }
404 }
405 if ( ipkg_old ) {
406 servers->setSelectionMode(QListBox::Single);
407 servers->setSelected(currentserver,TRUE);
408 }
409 return TRUE;
410 } else {
411 return FALSE;
412 }
413}
414
415
416/**
417 * read from config file(s)
418 */
419void PackageManagerSettings::readSettings()
420{
421 readIpkgConfig("/etc/ipkg.conf");
422 readInstallationSettings();
423}
424
425void PackageManagerSettings::writeSettings()
426{
427 writeIpkgConfig("/etc/ipkg.conf");
428 writeInstallationSettings();
429}
430/** shows the setting dialog */
431bool PackageManagerSettings::showDialog( int i )
432{
433 TabWidget->setCurrentPage( i );
434 showMaximized();
435 bool ret = exec();
436 if ( ret ) writeSettings();
437 else readSettings();
438 return ret;
439}
440/** Returns the installation destination */
441QString PackageManagerSettings::getDestinationName()
442{
443 return activeDestination->currentText();
444}
445/** Returns the link destination */
446QString PackageManagerSettings::getLinkDestinationName()
447{
448 return activeLinkDestination->currentText();
449}
450/** Returns the URL of the active destination */
451QString PackageManagerSettings::getDestinationUrl()
452{
453 int dnr = activeDestination->currentItem();
454 return *destinationurlDic.find(dnr);
455}
456/** Should oipkg create links form install destination to link destination */
457bool PackageManagerSettings::createLinks()
458{
459 return CheckBoxLink->isChecked();
460}
461/** get the servers that are active */
462QStringList PackageManagerSettings::getActiveServers()
463{
464 QStringList sl;
465 for (int i=0; i<(int)activeServers->count(); i++)
466 {
467 if ( activeServers->isSelected(i) )
468 sl += activeServers->text(i);
469 }
470 return sl;
471}
472/** returns the destination listed in ipkg.conf */
473QStringList PackageManagerSettings::getDestinationUrls()
474{
475 QStringList sl;
476 for (int i=0; i<(int)destinations->count(); i++)
477 {
478 sl += *destinationurlDic[i];
479 }
480 return sl;
481}
482
483void PackageManagerSettings::linkEnabled( bool b )
484{
485 changed = true;
486 activeLinkDestination->setEnabled( b );
487}
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 @@
1#ifndef PACKAGEMANAGERSETTINGS_H
2#define PACKAGEMANAGERSETTINGS_H
3
4#include "pksettingsbase.h"
5#include <qintdict.h>
6
7
8class PackageManagerSettings : private PackageManagerSettingsBase
9{
10 // Q_OBJECT
11public:
12 PackageManagerSettings( QWidget* , const char* , WFlags );
13 ~PackageManagerSettings();
14
15 bool showDialog( int ) ;
16 QString getDestinationUrl();
17 QString getDestinationName();
18 QString getLinkDestinationName();
19 bool createLinks();
20 QStringList getActiveServers();
21 QStringList getDestinationUrls();
22
23private:
24 QIntDict<QString> serverurlDic;
25 QIntDict<QString> destinationurlDic;
26 int ipkg_old;
27 int editedserver;
28 int editeddestination;
29 int currentSetting;
30 int installationSettingsCount;
31 bool changed;
32
33 bool readIpkgConfig(const QString&);
34 void writeIpkgConfig(const QString&);
35 void writeSettings();
36 void readSettings();
37
38public slots:
39 void writeInstallationSettings();
40 void readInstallationSettings();
41 void writeCurrentInstallationSetting();
42 void readInstallationSetting(int);
43 void installationSettingSetName(const QString &);
44
45 void newServer();
46 void editServer(int);
47 void removeDestination();
48 void newDestination();
49 void editDestination(int);
50 void linkEnabled(bool);
51 void removeServer();
52 void serverNameChanged(const QString&);
53 void serverUrlChanged(const QString&);
54 void destNameChanged(const QString&);
55 void destUrlChanged(const QString&);
56 void installationSettingChange(int);
57 void newInstallationSetting();
58 void removeInstallationSetting();
59 void renameInstallationSetting();
60};
61
62#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 @@
1<!DOCTYPE UI><UI>
2<class>PackageManagerSettingsBase</class>
3<widget>
4 <class>QDialog</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>Form4</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>357</width>
15 <height>454</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>Package Servers</string>
21 </property>
22 <property>
23 <name>layoutMargin</name>
24 </property>
25 <property>
26 <name>layoutSpacing</name>
27 </property>
28 <grid>
29 <property stdset="1">
30 <name>margin</name>
31 <number>3</number>
32 </property>
33 <property stdset="1">
34 <name>spacing</name>
35 <number>3</number>
36 </property>
37 <widget row="0" column="0" >
38 <class>QTabWidget</class>
39 <property stdset="1">
40 <name>name</name>
41 <cstring>TabWidget</cstring>
42 </property>
43 <property stdset="1">
44 <name>enabled</name>
45 <bool>true</bool>
46 </property>
47 <property>
48 <name>layoutMargin</name>
49 </property>
50 <property>
51 <name>layoutSpacing</name>
52 </property>
53 <widget>
54 <class>QWidget</class>
55 <property stdset="1">
56 <name>name</name>
57 <cstring>tab</cstring>
58 </property>
59 <attribute>
60 <name>title</name>
61 <string>Settings</string>
62 </attribute>
63 <grid>
64 <property stdset="1">
65 <name>margin</name>
66 <number>3</number>
67 </property>
68 <property stdset="1">
69 <name>spacing</name>
70 <number>3</number>
71 </property>
72 <widget row="0" column="0" >
73 <class>QLayoutWidget</class>
74 <property stdset="1">
75 <name>name</name>
76 <cstring>Layout3_2</cstring>
77 </property>
78 <hbox>
79 <property stdset="1">
80 <name>margin</name>
81 <number>0</number>
82 </property>
83 <property stdset="1">
84 <name>spacing</name>
85 <number>6</number>
86 </property>
87 <widget>
88 <class>QLabel</class>
89 <property stdset="1">
90 <name>name</name>
91 <cstring>Settings</cstring>
92 </property>
93 <property stdset="1">
94 <name>text</name>
95 <string>Installation Setups</string>
96 </property>
97 </widget>
98 <spacer>
99 <property>
100 <name>name</name>
101 <cstring>Spacer2_2_2</cstring>
102 </property>
103 <property stdset="1">
104 <name>orientation</name>
105 <enum>Horizontal</enum>
106 </property>
107 <property stdset="1">
108 <name>sizeType</name>
109 <enum>Expanding</enum>
110 </property>
111 <property>
112 <name>sizeHint</name>
113 <size>
114 <width>20</width>
115 <height>20</height>
116 </size>
117 </property>
118 </spacer>
119 </hbox>
120 </widget>
121 <widget row="5" column="0" >
122 <class>QLayoutWidget</class>
123 <property stdset="1">
124 <name>name</name>
125 <cstring>Layout8</cstring>
126 </property>
127 <hbox>
128 <property stdset="1">
129 <name>margin</name>
130 <number>0</number>
131 </property>
132 <property stdset="1">
133 <name>spacing</name>
134 <number>6</number>
135 </property>
136 <widget>
137 <class>QLabel</class>
138 <property stdset="1">
139 <name>name</name>
140 <cstring>TextLabel1</cstring>
141 </property>
142 <property stdset="1">
143 <name>text</name>
144 <string>Install destination:</string>
145 </property>
146 </widget>
147 <widget>
148 <class>QComboBox</class>
149 <property stdset="1">
150 <name>name</name>
151 <cstring>activeDestination</cstring>
152 </property>
153 </widget>
154 </hbox>
155 </widget>
156 <widget row="6" column="0" >
157 <class>QLayoutWidget</class>
158 <property stdset="1">
159 <name>name</name>
160 <cstring>Layout9</cstring>
161 </property>
162 <hbox>
163 <property stdset="1">
164 <name>margin</name>
165 <number>0</number>
166 </property>
167 <property stdset="1">
168 <name>spacing</name>
169 <number>6</number>
170 </property>
171 <widget>
172 <class>QCheckBox</class>
173 <property stdset="1">
174 <name>name</name>
175 <cstring>CheckBoxLink</cstring>
176 </property>
177 <property stdset="1">
178 <name>text</name>
179 <string>Link Destination:</string>
180 </property>
181 </widget>
182 <widget>
183 <class>QComboBox</class>
184 <property stdset="1">
185 <name>name</name>
186 <cstring>activeLinkDestination</cstring>
187 </property>
188 <property stdset="1">
189 <name>enabled</name>
190 <bool>false</bool>
191 </property>
192 </widget>
193 </hbox>
194 </widget>
195 <widget row="3" column="0" >
196 <class>QLayoutWidget</class>
197 <property stdset="1">
198 <name>name</name>
199 <cstring>Layout13</cstring>
200 </property>
201 <hbox>
202 <property stdset="1">
203 <name>margin</name>
204 <number>0</number>
205 </property>
206 <property stdset="1">
207 <name>spacing</name>
208 <number>6</number>
209 </property>
210 <widget>
211 <class>QLabel</class>
212 <property stdset="1">
213 <name>name</name>
214 <cstring>TextLabel1_2</cstring>
215 </property>
216 <property stdset="1">
217 <name>text</name>
218 <string>Used servers:</string>
219 </property>
220 </widget>
221 <spacer>
222 <property>
223 <name>name</name>
224 <cstring>Spacer4</cstring>
225 </property>
226 <property stdset="1">
227 <name>orientation</name>
228 <enum>Horizontal</enum>
229 </property>
230 <property stdset="1">
231 <name>sizeType</name>
232 <enum>Expanding</enum>
233 </property>
234 <property>
235 <name>sizeHint</name>
236 <size>
237 <width>20</width>
238 <height>20</height>
239 </size>
240 </property>
241 </spacer>
242 </hbox>
243 </widget>
244 <widget row="4" column="0" >
245 <class>QListBox</class>
246 <property stdset="1">
247 <name>name</name>
248 <cstring>activeServers</cstring>
249 </property>
250 <property stdset="1">
251 <name>enabled</name>
252 <bool>true</bool>
253 </property>
254 <property stdset="1">
255 <name>selectionMode</name>
256 <enum>Multi</enum>
257 </property>
258 </widget>
259 <widget row="1" column="0" >
260 <class>QComboBox</class>
261 <property stdset="1">
262 <name>name</name>
263 <cstring>settingName</cstring>
264 </property>
265 <property stdset="1">
266 <name>enabled</name>
267 <bool>true</bool>
268 </property>
269 <property stdset="1">
270 <name>focusPolicy</name>
271 <enum>NoFocus</enum>
272 </property>
273 <property stdset="1">
274 <name>editable</name>
275 <bool>false</bool>
276 </property>
277 </widget>
278 <widget row="2" column="0" >
279 <class>QLayoutWidget</class>
280 <property stdset="1">
281 <name>name</name>
282 <cstring>Layout11</cstring>
283 </property>
284 <hbox>
285 <property stdset="1">
286 <name>margin</name>
287 <number>0</number>
288 </property>
289 <property stdset="1">
290 <name>spacing</name>
291 <number>6</number>
292 </property>
293 <widget>
294 <class>QPushButton</class>
295 <property stdset="1">
296 <name>name</name>
297 <cstring>newsetting</cstring>
298 </property>
299 <property stdset="1">
300 <name>enabled</name>
301 <bool>true</bool>
302 </property>
303 <property stdset="1">
304 <name>text</name>
305 <string>New</string>
306 </property>
307 <property stdset="1">
308 <name>autoDefault</name>
309 <bool>false</bool>
310 </property>
311 </widget>
312 <widget>
313 <class>QPushButton</class>
314 <property stdset="1">
315 <name>name</name>
316 <cstring>renamesetting</cstring>
317 </property>
318 <property stdset="1">
319 <name>enabled</name>
320 <bool>true</bool>
321 </property>
322 <property stdset="1">
323 <name>text</name>
324 <string>Rename</string>
325 </property>
326 </widget>
327 <widget>
328 <class>QPushButton</class>
329 <property stdset="1">
330 <name>name</name>
331 <cstring>removesetting</cstring>
332 </property>
333 <property stdset="1">
334 <name>enabled</name>
335 <bool>true</bool>
336 </property>
337 <property stdset="1">
338 <name>text</name>
339 <string>Remove</string>
340 </property>
341 <property stdset="1">
342 <name>autoDefault</name>
343 <bool>false</bool>
344 </property>
345 </widget>
346 </hbox>
347 </widget>
348 </grid>
349 </widget>
350 <widget>
351 <class>QWidget</class>
352 <property stdset="1">
353 <name>name</name>
354 <cstring>tab</cstring>
355 </property>
356 <attribute>
357 <name>title</name>
358 <string>Servers</string>
359 </attribute>
360 <grid>
361 <property stdset="1">
362 <name>margin</name>
363 <number>3</number>
364 </property>
365 <property stdset="1">
366 <name>spacing</name>
367 <number>3</number>
368 </property>
369 <widget row="3" column="0" rowspan="1" colspan="2" >
370 <class>QLayoutWidget</class>
371 <property stdset="1">
372 <name>name</name>
373 <cstring>Layout4</cstring>
374 </property>
375 <grid>
376 <property stdset="1">
377 <name>margin</name>
378 <number>0</number>
379 </property>
380 <property stdset="1">
381 <name>spacing</name>
382 <number>6</number>
383 </property>
384 <widget row="0" column="1" >
385 <class>QLineEdit</class>
386 <property stdset="1">
387 <name>name</name>
388 <cstring>servername</cstring>
389 </property>
390 </widget>
391 <widget row="0" column="0" >
392 <class>QLabel</class>
393 <property stdset="1">
394 <name>name</name>
395 <cstring>TextLabel1_3</cstring>
396 </property>
397 <property stdset="1">
398 <name>text</name>
399 <string>Name:</string>
400 </property>
401 </widget>
402 <widget row="1" column="1" >
403 <class>QLineEdit</class>
404 <property stdset="1">
405 <name>name</name>
406 <cstring>serverurl</cstring>
407 </property>
408 </widget>
409 <widget row="1" column="0" >
410 <class>QLabel</class>
411 <property stdset="1">
412 <name>name</name>
413 <cstring>TextLabel2_3</cstring>
414 </property>
415 <property stdset="1">
416 <name>text</name>
417 <string>URL:</string>
418 </property>
419 </widget>
420 </grid>
421 </widget>
422 <widget row="0" column="0" rowspan="1" colspan="2" >
423 <class>QLayoutWidget</class>
424 <property stdset="1">
425 <name>name</name>
426 <cstring>Layout2</cstring>
427 </property>
428 <hbox>
429 <property stdset="1">
430 <name>margin</name>
431 <number>0</number>
432 </property>
433 <property stdset="1">
434 <name>spacing</name>
435 <number>6</number>
436 </property>
437 <widget>
438 <class>QLabel</class>
439 <property stdset="1">
440 <name>name</name>
441 <cstring>Servers</cstring>
442 </property>
443 <property stdset="1">
444 <name>text</name>
445 <string>Servers</string>
446 </property>
447 </widget>
448 <spacer>
449 <property>
450 <name>name</name>
451 <cstring>Spacer2</cstring>
452 </property>
453 <property stdset="1">
454 <name>orientation</name>
455 <enum>Horizontal</enum>
456 </property>
457 <property stdset="1">
458 <name>sizeType</name>
459 <enum>Expanding</enum>
460 </property>
461 <property>
462 <name>sizeHint</name>
463 <size>
464 <width>20</width>
465 <height>20</height>
466 </size>
467 </property>
468 </spacer>
469 </hbox>
470 </widget>
471 <widget row="1" column="0" rowspan="1" colspan="2" >
472 <class>QListBox</class>
473 <property stdset="1">
474 <name>name</name>
475 <cstring>servers</cstring>
476 </property>
477 <property stdset="1">
478 <name>selectionMode</name>
479 <enum>Extended</enum>
480 </property>
481 </widget>
482 <widget row="2" column="1" >
483 <class>QPushButton</class>
484 <property stdset="1">
485 <name>name</name>
486 <cstring>removeserver</cstring>
487 </property>
488 <property stdset="1">
489 <name>enabled</name>
490 <bool>true</bool>
491 </property>
492 <property stdset="1">
493 <name>text</name>
494 <string>Remove</string>
495 </property>
496 <property stdset="1">
497 <name>autoDefault</name>
498 <bool>false</bool>
499 </property>
500 </widget>
501 <widget row="2" column="0" >
502 <class>QPushButton</class>
503 <property stdset="1">
504 <name>name</name>
505 <cstring>newserver</cstring>
506 </property>
507 <property stdset="1">
508 <name>enabled</name>
509 <bool>true</bool>
510 </property>
511 <property stdset="1">
512 <name>text</name>
513 <string>New</string>
514 </property>
515 <property stdset="1">
516 <name>autoDefault</name>
517 <bool>false</bool>
518 </property>
519 </widget>
520 </grid>
521 </widget>
522 <widget>
523 <class>QWidget</class>
524 <property stdset="1">
525 <name>name</name>
526 <cstring>tab</cstring>
527 </property>
528 <attribute>
529 <name>title</name>
530 <string>Destinations</string>
531 </attribute>
532 <grid>
533 <property stdset="1">
534 <name>margin</name>
535 <number>3</number>
536 </property>
537 <property stdset="1">
538 <name>spacing</name>
539 <number>3</number>
540 </property>
541 <widget row="0" column="0" >
542 <class>QLayoutWidget</class>
543 <property stdset="1">
544 <name>name</name>
545 <cstring>Layout3</cstring>
546 </property>
547 <hbox>
548 <property stdset="1">
549 <name>margin</name>
550 <number>0</number>
551 </property>
552 <property stdset="1">
553 <name>spacing</name>
554 <number>6</number>
555 </property>
556 <widget>
557 <class>QLabel</class>
558 <property stdset="1">
559 <name>name</name>
560 <cstring>Destinations</cstring>
561 </property>
562 <property stdset="1">
563 <name>text</name>
564 <string>Destinations</string>
565 </property>
566 </widget>
567 <spacer>
568 <property>
569 <name>name</name>
570 <cstring>Spacer2_2</cstring>
571 </property>
572 <property stdset="1">
573 <name>orientation</name>
574 <enum>Horizontal</enum>
575 </property>
576 <property stdset="1">
577 <name>sizeType</name>
578 <enum>Expanding</enum>
579 </property>
580 <property>
581 <name>sizeHint</name>
582 <size>
583 <width>20</width>
584 <height>20</height>
585 </size>
586 </property>
587 </spacer>
588 </hbox>
589 </widget>
590 <widget row="1" column="0" >
591 <class>QListBox</class>
592 <property stdset="1">
593 <name>name</name>
594 <cstring>destinations</cstring>
595 </property>
596 <property stdset="1">
597 <name>selectionMode</name>
598 <enum>Single</enum>
599 </property>
600 </widget>
601 <widget row="2" column="0" >
602 <class>QLayoutWidget</class>
603 <property stdset="1">
604 <name>name</name>
605 <cstring>Layout5</cstring>
606 </property>
607 <hbox>
608 <property stdset="1">
609 <name>margin</name>
610 <number>0</number>
611 </property>
612 <property stdset="1">
613 <name>spacing</name>
614 <number>6</number>
615 </property>
616 <widget>
617 <class>QPushButton</class>
618 <property stdset="1">
619 <name>name</name>
620 <cstring>newdestination</cstring>
621 </property>
622 <property stdset="1">
623 <name>enabled</name>
624 <bool>true</bool>
625 </property>
626 <property stdset="1">
627 <name>text</name>
628 <string>New</string>
629 </property>
630 <property stdset="1">
631 <name>autoDefault</name>
632 <bool>false</bool>
633 </property>
634 </widget>
635 <widget>
636 <class>QPushButton</class>
637 <property stdset="1">
638 <name>name</name>
639 <cstring>removedestination</cstring>
640 </property>
641 <property stdset="1">
642 <name>enabled</name>
643 <bool>true</bool>
644 </property>
645 <property stdset="1">
646 <name>text</name>
647 <string>Remove</string>
648 </property>
649 <property stdset="1">
650 <name>autoDefault</name>
651 <bool>false</bool>
652 </property>
653 </widget>
654 </hbox>
655 </widget>
656 <widget row="3" column="0" >
657 <class>QLayoutWidget</class>
658 <property stdset="1">
659 <name>name</name>
660 <cstring>Layout11</cstring>
661 </property>
662 <property>
663 <name>layoutMargin</name>
664 </property>
665 <property>
666 <name>layoutSpacing</name>
667 </property>
668 <grid>
669 <property stdset="1">
670 <name>margin</name>
671 <number>3</number>
672 </property>
673 <property stdset="1">
674 <name>spacing</name>
675 <number>3</number>
676 </property>
677 <widget row="1" column="0" >
678 <class>QLabel</class>
679 <property stdset="1">
680 <name>name</name>
681 <cstring>TextLabel1_3_2_2</cstring>
682 </property>
683 <property stdset="1">
684 <name>text</name>
685 <string>URL:</string>
686 </property>
687 </widget>
688 <widget row="0" column="1" >
689 <class>QLineEdit</class>
690 <property stdset="1">
691 <name>name</name>
692 <cstring>destinationname</cstring>
693 </property>
694 </widget>
695 <widget row="1" column="1" >
696 <class>QLineEdit</class>
697 <property stdset="1">
698 <name>name</name>
699 <cstring>destinationurl</cstring>
700 </property>
701 </widget>
702 <widget row="0" column="0" >
703 <class>QLabel</class>
704 <property stdset="1">
705 <name>name</name>
706 <cstring>TextLabel1_3_2</cstring>
707 </property>
708 <property stdset="1">
709 <name>text</name>
710 <string>Name:</string>
711 </property>
712 </widget>
713 </grid>
714 </widget>
715 </grid>
716 </widget>
717 </widget>
718 </grid>
719</widget>
720<connections>
721 <connection>
722 <sender>CheckBoxLink</sender>
723 <signal>toggled(bool)</signal>
724 <receiver>Form4</receiver>
725 <slot>linkEnabled(bool)</slot>
726 </connection>
727 <slot access="public">destNameChanged(const QString&amp;)</slot>
728 <slot access="public">destUrlChanged(const QString&amp;)</slot>
729 <slot access="public">editDestination(int)</slot>
730 <slot access="public">editServer(int)</slot>
731 <slot access="public">installationSettingChange(int)</slot>
732 <slot access="public">installationSettingSetName(const QString &amp;)</slot>
733 <slot access="public">linkEnabled(bool)</slot>
734 <slot access="public">newDestination()</slot>
735 <slot access="public">newInstallationSetting()</slot>
736 <slot access="public">newServer()</slot>
737 <slot access="public">removeDestination()</slot>
738 <slot access="public">removeInstallationSetting()</slot>
739 <slot access="public">removeServer()</slot>
740 <slot access="public">renameInstallationSetting()</slot>
741 <slot access="public">serverNameChanged(const QString&amp;)</slot>
742 <slot access="public">serverUrlChanged(const QString&amp;)</slot>
743</connections>
744</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 @@
1<!DOCTYPE UI><UI>
2<class>PackageWindow</class>
3<widget>
4 <class>QWidget</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>PackageWindow</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>254</width>
15 <height>298</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>PackageWindow</string>
21 </property>
22 <property>
23 <name>layoutMargin</name>
24 </property>
25 <property>
26 <name>layoutSpacing</name>
27 </property>
28 <vbox>
29 <property stdset="1">
30 <name>margin</name>
31 <number>2</number>
32 </property>
33 <property stdset="1">
34 <name>spacing</name>
35 <number>2</number>
36 </property>
37 <widget>
38 <class>QLayoutWidget</class>
39 <property stdset="1">
40 <name>name</name>
41 <cstring>Layout5</cstring>
42 </property>
43 <property>
44 <name>layoutSpacing</name>
45 </property>
46 <hbox>
47 <property stdset="1">
48 <name>margin</name>
49 <number>0</number>
50 </property>
51 <property stdset="1">
52 <name>spacing</name>
53 <number>1</number>
54 </property>
55 <widget>
56 <class>QLabel</class>
57 <property stdset="1">
58 <name>name</name>
59 <cstring>LabelSection</cstring>
60 </property>
61 <property stdset="1">
62 <name>text</name>
63 <string>Section:</string>
64 </property>
65 </widget>
66 <widget>
67 <class>QComboBox</class>
68 <property stdset="1">
69 <name>name</name>
70 <cstring>section</cstring>
71 </property>
72 <property stdset="1">
73 <name>sizePolicy</name>
74 <sizepolicy>
75 <hsizetype>0</hsizetype>
76 <vsizetype>0</vsizetype>
77 </sizepolicy>
78 </property>
79 </widget>
80 <widget>
81 <class>QComboBox</class>
82 <property stdset="1">
83 <name>name</name>
84 <cstring>subsection</cstring>
85 </property>
86 <property stdset="1">
87 <name>sizePolicy</name>
88 <sizepolicy>
89 <hsizetype>0</hsizetype>
90 <vsizetype>0</vsizetype>
91 </sizepolicy>
92 </property>
93 </widget>
94 </hbox>
95 </widget>
96 <widget>
97 <class>QListView</class>
98 <column>
99 <property>
100 <name>text</name>
101 <string>Package</string>
102 </property>
103 <property>
104 <name>clickable</name>
105 <bool>true</bool>
106 </property>
107 <property>
108 <name>resizeable</name>
109 <bool>true</bool>
110 </property>
111 </column>
112 <column>
113 <property>
114 <name>text</name>
115 <string>Description</string>
116 </property>
117 <property>
118 <name>clickable</name>
119 <bool>true</bool>
120 </property>
121 <property>
122 <name>resizeable</name>
123 <bool>true</bool>
124 </property>
125 </column>
126 <column>
127 <property>
128 <name>text</name>
129 <string>Size</string>
130 </property>
131 <property>
132 <name>clickable</name>
133 <bool>true</bool>
134 </property>
135 <property>
136 <name>resizeable</name>
137 <bool>true</bool>
138 </property>
139 </column>
140 <property stdset="1">
141 <name>name</name>
142 <cstring>ListViewPackages</cstring>
143 </property>
144 </widget>
145 </vbox>
146</widget>
147</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 @@
1#include "pmipkg.h"
2#include "pkdesc.h"
3#include "pkfind.h"
4#include "pksettings.h"
5#include "package.h"
6#include "packagelistitem.h"
7
8#include <qpe/process.h>
9#include <qpe/resource.h>
10#include <qpe/stringutil.h>
11#include <qpe/qcopenvelope_qws.h>
12#include <qdir.h>
13#include <qfile.h>
14#include <qmultilineedit.h>
15#include <qstring.h>
16#include <qtextstream.h>
17#include <qtextview.h>
18
19#include <stdlib.h>
20#include <unistd.h>
21
22#include "mainwindow.h"
23#include "runwindow.h"
24
25
26PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlags f )
27 : RunWindow ( p, name, f )
28 //: QObject ( p )
29{
30 settings = s;
31
32 linkDest = new QCopChannel( "QPE/MakeLinks", this );
33 connect( linkDest, SIGNAL(received(const QCString &, const QByteArray &)),
34 this, SLOT(linkDestination( const QString &, const QString&)) );
35}
36
37PmIpkg::~PmIpkg()
38{
39}
40
41int PmIpkg::runIpkg(const QString& args)
42{
43 pvDebug(4,"PmIpkg::runIpkg");
44 QString cmd = "/usr/bin/ipkg ";
45 cmd += " -dest "+settings->getDestinationName();
46 cmd += " -force-defaults ";
47
48 outPut->setText( outPut->text()+"<br><br>Starting to "+ args+"<br>\n");
49 QString redirect = "/tmp/ipkg.pipe";
50 cmd += args+" | tee "+redirect+" 2>&1&";
51
52 outPut->setText( outPut->text() + "running:<br>\n"+cmd+"<br>\n" );
53 pvDebug( 0, "Execute >"+cmd+"<" );
54 int r = system(cmd.latin1());
55 QFile f( redirect );
56 if ( f.open(IO_ReadOnly) ) {
57 QTextStream t( &f );
58 QString fp;
59 while ( !t.eof() )
60 {
61 outPut->setText( outPut->text() + t.readLine() +"\n<br>" );
62 }
63 }
64 f.close();
65 outPut->setText( outPut->text() + "\n<br><br>Finished!");
66 outPut->setContentsPos(0,outPut->contentsHeight());
67
68 if ( r == 0 )
69 {
70 QString param = args.left( args.find(" ") );
71 QString file = args.right( args.length() - args.find(" ") );
72 if ( param == "install" && settings->createLinks() )
73 makeLinks( file);
74 }
75
76 return r;
77}
78
79void PmIpkg::makeLinks(QString file)
80{
81 outPut->setText( outPut->text() + "<br>creating links<br>" );
82 QString dest = settings->getDestinationUrl();
83 system(("ipkg -d "+dest+" files "+file+"> /tmp/oipkg.pipe").latin1());
84 QFile f( "/tmp/oipkg.pipe" );
85 if ( ! f.open(IO_ReadOnly) )return;
86 QTextStream t( &f );
87 QString fp;
88 while ( !t.eof() )
89 {
90 processLinkDir( t.readLine(), dest );
91 }
92 f.close();
93}
94
95void PmIpkg::processLinkDir( QString file, QString dest )
96{
97 QString destFile = file.right( file.length() - dest.length() );
98 QFileInfo fileInfo( file );
99 if ( fileInfo.isFile() )
100 {
101 const char *instFile = strdup( (file).ascii() );
102 const char *linkFile = strdup( (destFile).ascii());
103 outPut->setText( outPut->text() + "linking: "+file+" -> "+destFile );
104 symlink( instFile, linkFile );
105 }
106 if ( fileInfo.isDir() )
107 {
108 QDir destDir( destFile );
109 destDir.mkdir( destFile, true );
110 QDir d( file );
111 d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks );
112
113 const QFileInfoList *list = d.entryInfoList();
114 QFileInfoListIterator it( *list );
115 QFileInfo *fi;
116 while ( (fi=it.current()) ) {
117 processLinkDir( fi->absFilePath(), dest );
118 ++it;
119 }
120 }
121}
122
123void PmIpkg::commit( PackageList pl )
124 {
125 showMaximized();
126 exec();
127 outPut->setText( "<b>Starting...</b><br>\n");
128 QStringList to_remove, to_install;
129
130 QString rem="To remove:<br>\n";
131 QString inst="To install:<br>\n";;
132 for( Package *pack = pl.first();pack ; (pack = pl.next()) )
133 {
134 if ( pack && (pack->name() != "") && pack)
135 {
136 if ( pack->toInstall() )
137 {
138 to_install.append( pack->name() );
139 inst += pack->name()+"\n";
140 }
141 if ( pack->toRemove() )
142 {
143 to_remove.append( pack->name() );
144 rem += pack->name()+"\n";
145 }
146 }
147 }
148
149 outPut->setText( outPut->text()+inst+rem);
150 bool ok=TRUE;
151
152 qDebug("to remove=%i; to install=%i",to_remove.count(),to_install.count());
153
154 int jobs = to_remove.count()+to_install.count();
155 if ( jobs < 1 ) return;
156
157 if ( to_remove.count() )
158 for (QStringList::ConstIterator it=to_remove.begin(); it!=to_remove.end(); ++it)
159 if ( runIpkg("remove " + *it) != 0 ) ok = false;
160 if ( to_install.count() )
161 for (QStringList::ConstIterator it=to_install.begin(); it!=to_install.end(); ++it)
162 if ( runIpkg("install " + *it) != 0 ) ok = false;
163
164 // ##### If we looked in the list of files, we could send out accurate
165 // ##### messages. But we don't bother yet, and just do an "all".
166 QCopEnvelope e("QPE/System", "linkChanged(QString)");
167 QString lf = QString::null;
168 e << lf;
169}
170
171void PmIpkg::linkDestination( QString src, QString dest )
172{
173 QDir d( src );
174 d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks );
175 if (! d.exists() ) return;
176 const QFileInfoList *list = d.entryInfoList();
177 QFileInfoListIterator it( *list );
178 QFileInfo *fi;
179 while ( (fi=it.current()) ) {
180 processLinkDir( fi->absFilePath(), dest );
181 ++it;
182 }
183}
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 @@
1#ifndef PMIPKG_H
2#define PMIPKG_H
3
4
5#include <qobject.h>
6#include <qstring.h>
7#include <qwidget.h>
8#include "pksettings.h"
9#include "runwindow.h"
10#include "packagelist.h"
11#include "debug.h"
12
13
14#include <qpe/qcopenvelope_qws.h>
15
16class PmIpkg : public RunWindow
17//class PmIpkg : public QObject
18{
19 Q_OBJECT
20public:
21 PmIpkg( PackageManagerSettings* , QWidget* p=0, const char * name=0, WFlags f=0 );
22 //PmIpkg( QObject*, PackageManagerSettings* );
23 ~PmIpkg();
24
25 PackageList* getPackageList();
26
27private:
28 PackageManagerSettings* settings;
29 QCopChannel *linkDest;
30 void processLinkDir( QString, QString );
31
32
33public:
34 void makeLinks(QString);
35 int runIpkg(const QString& args);
36 void commit( PackageList );
37
38public slots:
39 void linkDestination( QString, QString );
40};
41
42#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 @@
1<!DOCTYPE UI><UI>
2<class>RunWindow</class>
3<widget>
4 <class>QDialog</class>
5 <property stdset="1">
6 <name>name</name>
7 <cstring>RunWindow</cstring>
8 </property>
9 <property stdset="1">
10 <name>geometry</name>
11 <rect>
12 <x>0</x>
13 <y>0</y>
14 <width>201</width>
15 <height>291</height>
16 </rect>
17 </property>
18 <property stdset="1">
19 <name>caption</name>
20 <string>running...</string>
21 </property>
22 <property>
23 <name>layoutMargin</name>
24 </property>
25 <property>
26 <name>layoutSpacing</name>
27 </property>
28 <grid>
29 <property stdset="1">
30 <name>margin</name>
31 <number>5</number>
32 </property>
33 <property stdset="1">
34 <name>spacing</name>
35 <number>2</number>
36 </property>
37 <widget row="0" column="0" >
38 <class>QProgressBar</class>
39 <property stdset="1">
40 <name>name</name>
41 <cstring>progress</cstring>
42 </property>
43 <property stdset="1">
44 <name>progress</name>
45 <number>0</number>
46 </property>
47 </widget>
48 <widget row="1" column="0" >
49 <class>QTextView</class>
50 <property stdset="1">
51 <name>name</name>
52 <cstring>outPut</cstring>
53 </property>
54 <property stdset="1">
55 <name>font</name>
56 <font>
57 <pointsize>6</pointsize>
58 </font>
59 </property>
60 </widget>
61 </grid>
62</widget>
63</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 @@
1#include "pksettings.h"
2
3#include <qpe/config.h>
4#include <qcombobox.h>
5#include <qfile.h>
6#include <qlineedit.h>
7#include <qpushbutton.h>
8#include <qlistbox.h>
9#include <qcheckbox.h>
10#include <qstring.h>
11#include <qobject.h>
12#include <qtextstream.h>
13#include <qtabwidget.h>
14
15
16PackageManagerSettings::PackageManagerSettings( QWidget* parent, const char* name, WFlags fl )
17 : PackageManagerSettingsBase( parent, name, fl )
18{
19 connect( newserver, SIGNAL(clicked()), this, SLOT(newServer()) );
20 connect( removeserver, SIGNAL(clicked()), this, SLOT(removeServer()) );
21 connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) );
22 connect( newdestination, SIGNAL(clicked()), this, SLOT(newDestination()) );
23 connect( removedestination, SIGNAL(clicked()), this, SLOT(removeDestination()) );
24 connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) );
25 // connect( CheckBoxLink, SIGNAL(toggled(bool)),
26 // activeLinkDestination, SLOT(setEnabled(bool)) );
27
28 connect( settingName, SIGNAL(activated(int)), this, SLOT(installationSettingChange(int)) );
29 connect( settingName, SIGNAL(textChanged(const QString &)), this, SLOT(installationSettingSetName(const QString &)) );
30 connect( newsetting, SIGNAL(clicked()), this, SLOT(newInstallationSetting()) );
31 connect( renamesetting, SIGNAL(clicked()), this, SLOT(renameInstallationSetting()) );
32 connect( removesetting, SIGNAL(clicked()), this, SLOT(removeInstallationSetting()) );
33 servername->setEnabled(FALSE);
34 serverurl->setEnabled(FALSE);
35 serverurlDic.setAutoDelete(TRUE);
36 destinationname->setEnabled(FALSE);
37 destinationurl->setEnabled(FALSE);
38 destinationurlDic.setAutoDelete(TRUE);
39 readSettings();
40}
41
42PackageManagerSettings::~PackageManagerSettings()
43{
44}
45
46
47void PackageManagerSettings::newServer()
48{
49 int i = servers->count();
50 if ( servername->isEnabled() || serverurl->text().isEmpty() ) {
51 serverurlDic.insert(i,new QString("http://"));
52 servers->insertItem(tr("New"));
53 activeServers->insertItem(tr("New"));
54 } else {
55 // allows one-level undo
56 serverurlDic.insert(i,new QString(serverurl->text()));
57 servers->insertItem(servername->text());
58 activeServers->insertItem(servername->text());
59 }
60 servers->setSelected(i,TRUE);
61 editServer(i);
62}
63
64void PackageManagerSettings::newDestination()
65{
66 int i = destinations->count();
67 if ( destinationname->isEnabled() || destinationurl->text().isEmpty() ) {
68 destinationurlDic.insert(i,new QString("/"));
69 destinations->insertItem(tr("New"));
70 activeDestination->insertItem(tr("New"));
71 activeLinkDestination->insertItem(tr("New"));
72 } else {
73 // allows one-level undo
74 destinationurlDic.insert(i,new QString(destinationurl->text()));
75 destinations->insertItem(destinationname->text());
76 activeDestination->insertItem(destinationname->text());
77 activeLinkDestination->insertItem(destinationname->text());
78 }
79 destinations->setSelected(i,TRUE);
80 editDestination(i);
81}
82
83
84void PackageManagerSettings::editServer(int i)
85{
86 if ( servername->isEnabled() ) {
87 disconnect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) );
88 disconnect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) );
89 } else {
90 servername->setEnabled(TRUE);
91 serverurl->setEnabled(TRUE);
92 }
93
94 servername->setText( servers->text(i) );
95 serverurl->setText( *serverurlDic[i] );
96
97 editedserver = i;
98
99 connect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) );
100 connect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) );
101}
102
103
104void PackageManagerSettings::editDestination(int i)
105{
106 if ( destinationname->isEnabled() ) {
107 disconnect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) );
108 disconnect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) );
109 } else {
110 destinationname->setEnabled(TRUE);
111 destinationurl->setEnabled(TRUE);
112 }
113
114 destinationname->setText( destinations->text(i) );
115 destinationurl->setText( *destinationurlDic[i] );
116
117 editeddestination = i;
118
119 connect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) );
120 connect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) );
121}
122
123void PackageManagerSettings::removeServer()
124{
125 disconnect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) );
126 disconnect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) );
127 servername->setText(servers->text(editedserver));
128 serverurl->setText(*serverurlDic[editedserver]);
129 disconnect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) );
130 servers->removeItem(editedserver);
131 activeServers->removeItem(editedserver);
132 connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) );
133 servername->setEnabled(FALSE);
134 serverurl->setEnabled(FALSE);
135}
136
137void PackageManagerSettings::removeDestination()
138{
139 disconnect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) );
140 disconnect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) );
141 destinationname->setText(destinations->text(editedserver));
142 destinationurl->setText(*destinationurlDic[editedserver]);
143 disconnect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) );
144 destinations->removeItem(editeddestination);
145 activeDestination->removeItem(editeddestination);
146 activeLinkDestination->removeItem(editeddestination);
147 connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) );
148 destinationname->setEnabled(FALSE);
149 destinationurl->setEnabled(FALSE);
150}
151
152void PackageManagerSettings::serverNameChanged(const QString& t)
153{
154 disconnect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) );
155 servers->changeItem( t, editedserver );
156 activeServers->changeItem( t, editedserver );
157 connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) );
158}
159
160void PackageManagerSettings::destNameChanged(const QString& t)
161{
162 disconnect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) );
163 destinations->changeItem( t, editeddestination );
164 activeDestination->changeItem( t, editeddestination );
165 activeLinkDestination->changeItem( t, editeddestination );
166 connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) );
167}
168
169void PackageManagerSettings::serverUrlChanged(const QString& t)
170{
171 serverurlDic.replace(editedserver, new QString(t));
172}
173
174void PackageManagerSettings::destUrlChanged(const QString& t)
175{
176 destinationurlDic.replace(editeddestination, new QString(t));
177}
178
179void PackageManagerSettings::writeIpkgConfig(const QString& conffile)
180{
181 QFile conf(conffile);
182 if ( ! conf.open(IO_WriteOnly) ) return;
183 QTextStream s(&conf);
184 s << "# Written by qpie Package Manager\n";
185 for (int i=0; i<(int)activeServers->count(); i++)
186 {
187 QString url = serverurlDic[i] ? *serverurlDic[i] : QString("???");
188 if ( !activeServers->isSelected(i) )
189 s << "#";
190 s << "src " << activeServers->text(i) << " " << url << "\n";
191 }
192 for (int i=0; i<(int)destinations->count(); i++)
193 {
194 QString url = destinationurlDic[i] ? *destinationurlDic[i] : QString("???");
195 s << "dest " << destinations->text(i) << " " << url << "\n";
196 }
197 conf.close();
198}
199
200
201void PackageManagerSettings::readInstallationSettings()
202{
203 Config cfg( "oipkg", Config::User );
204 cfg.setGroup( "Settings" );
205 installationSettingsCount = cfg.readNumEntry( "count", -1 );
206 currentSetting = cfg.readNumEntry( "current", 0 );
207
208 for (int i = 0; i < installationSettingsCount; i++)
209 {
210 cfg.setGroup( "Setting_" + QString::number(i) );
211 settingName->insertItem( cfg.readEntry( "name", "???" ), i );
212 };
213 readInstallationSetting( currentSetting );
214}
215
216
217void PackageManagerSettings::removeInstallationSetting()
218{
219 settingName->removeItem( settingName->currentItem() );
220 Config cfg( "oipkg", Config::User );
221 cfg.setGroup( "Setting_" + QString::number( installationSettingsCount ) );
222 cfg.clearGroup();
223 installationSettingsCount--;
224 settingName->setEditable( false );
225}
226
227void PackageManagerSettings::newInstallationSetting()
228{
229 installationSettingsCount++;
230 settingName->insertItem( "New", installationSettingsCount );
231 settingName->setCurrentItem( installationSettingsCount );
232 settingName->setEditable( true );
233}
234
235void PackageManagerSettings::installationSettingChange(int cs)
236{
237 writeCurrentInstallationSetting();
238 currentSetting = cs;
239 readInstallationSetting( cs );
240}
241
242void PackageManagerSettings::writeInstallationSettings()
243{
244 {
245 Config cfg( "oipkg", Config::User );
246 cfg.setGroup( "Settings" );
247 cfg.writeEntry( "count", installationSettingsCount );
248 cfg.writeEntry( "current", currentSetting );
249 writeCurrentInstallationSetting();
250 }
251}
252
253
254void PackageManagerSettings::readInstallationSetting(int setting)
255{
256 if ( setting < 0 ) return;
257 Config cfg( "oipkg", Config::User );
258 cfg.setGroup( "Setting_" + QString::number( setting ) );
259 CheckBoxLink->setChecked( cfg.readBoolEntry( "link", false ) );
260 QString dest = cfg.readEntry( "dest" );
261 QString linkdest = cfg.readEntry( "linkdest" );
262
263 for ( int i = 0; i < activeDestination->count(); i++)
264 {
265 QString name = cfg.readEntry( "name" );
266 if ( activeDestination->text( i ) == name )
267 activeDestination->setCurrentItem( i );
268 if ( activeLinkDestination->text( i ) == name )
269 activeLinkDestination->setCurrentItem( i );
270 }
271}
272
273void PackageManagerSettings::writeCurrentInstallationSetting()
274{
275 Config cfg( "oipkg", Config::User );
276 cfg.setGroup( "Setting_" + QString::number(currentSetting) );
277 cfg.writeEntry( "link", CheckBoxLink->isChecked() );
278 cfg.writeEntry( "dest", getDestinationName() );
279 cfg.writeEntry( "linkdest" , getLinkDestinationName() );
280 QStringList sers = getActiveServers();
281 int srvc = 0;
282 for ( QStringList::Iterator it = sers.begin(); it != sers.end(); ++it ) {
283 cfg.writeEntry( "server_" + QString::number(srvc++), *it );
284 }
285 cfg.writeEntry( "server_count", srvc );
286}
287
288void PackageManagerSettings::renameInstallationSetting()
289{
290 settingName->setEditable( true );
291}
292
293void PackageManagerSettings::installationSettingSetName(const QString &name)
294{
295 settingName->changeItem( name, settingName->currentItem() );
296}
297
298
299bool PackageManagerSettings::readIpkgConfig(const QString& conffile)
300{
301 QFile conf(conffile);
302 if ( conf.open(IO_ReadOnly) ) {
303 QTextStream s(&conf);
304 servers->clear();
305 activeServers->clear();
306 activeDestination->clear();
307 activeLinkDestination->clear();
308 serverurlDic.clear();
309 destinationurlDic.clear();
310 ipkg_old=0;
311 int currentserver=0;
312 while ( !s.atEnd() ) {
313 QString l = s.readLine();
314 QStringList token = QStringList::split(' ', l);
315 if ( token[0] == "src" || token[0] == "#src" ) {
316 currentserver=servers->count();
317 serverurlDic.insert(servers->count(),new QString(token[2]));
318 int a = token[0] == "src" ? 1 : 0;
319 int i = servers->count();
320 servers->insertItem(token[1]);
321 activeServers->insertItem( token[1] );
322 activeServers->setSelected(i,a);
323 } else if ( token[0] == "dest" ) {
324 currentserver=destinations->count();
325 destinationurlDic.insert(destinations->count(),new QString(token[2]));
326 destinations->insertItem(token[1]);
327 activeDestination->insertItem( token[1] );
328 activeLinkDestination->insertItem( token[1] );
329
330 } else if ( token[0] == "option" ) {
331 } else {
332 // Old style?
333 int eq = l.find('=');
334 if ( eq >= 0 ) {
335 QString v = l.mid(eq+1).stripWhiteSpace();
336 if ( v[0] == '"' || v[0] == '\'' ) {
337 int cl=v.find(v[0],1);
338 if ( cl >= 0 )
339 v = v.mid(1,cl-1);
340 }
341 if ( l.left(12) == "IPKG_SOURCE=" ) {
342 ipkg_old=1;
343 currentserver=servers->count();
344 serverurlDic.insert(servers->count(),new QString(v));
345 servers->insertItem(v);
346 } else if ( l.left(13) == "#IPKG_SOURCE=" ) {
347 serverurlDic.insert(servers->count(),new QString(v));
348 servers->insertItem(v);
349 } else if ( l.left(10) == "IPKG_ROOT=" ) {
350
351 }
352 }
353 }
354 }
355 if ( ipkg_old ) {
356 servers->setSelectionMode(QListBox::Single);
357 servers->setSelected(currentserver,TRUE);
358 }
359 return TRUE;
360 } else {
361 return FALSE;
362 }
363}
364
365void PackageManagerSettings::readSettings()
366{
367 readIpkgConfig("/etc/ipkg.conf");
368 readInstallationSettings();
369}
370
371void PackageManagerSettings::writeSettings()
372{
373 writeIpkgConfig("/etc/ipkg.conf");
374 writeInstallationSettings();
375}
376
377bool PackageManagerSettings::showDialog( int i )
378{
379 TabWidget->setCurrentPage( i );
380 showMaximized();
381 bool ret = exec();
382 if ( ret ) writeSettings();
383 else readSettings();
384 return ret;
385}
386
387QString PackageManagerSettings::getDestinationName()
388{
389 return activeDestination->currentText();
390}
391
392QString PackageManagerSettings::getLinkDestinationName()
393{
394 return activeLinkDestination->currentText();
395}
396
397/** Returns the URL of the active destination */
398QString PackageManagerSettings::getDestinationUrl()
399{
400 int dnr = activeDestination->currentItem();
401 return *destinationurlDic.find(dnr);
402}
403
404/** Should oipkg create links form install destination to link destination */
405bool PackageManagerSettings::createLinks()
406{
407 return CheckBoxLink->isChecked();
408}
409
410/** get the servers that are active */
411QStringList PackageManagerSettings::getActiveServers()
412{
413 QStringList sl;
414 for (int i=0; i<(int)activeServers->count(); i++)
415 {
416 if ( activeServers->isSelected(i) )
417 sl += activeServers->text(i);
418 }
419 return sl;
420}
421
422/** returns the destination listed in ipkg.conf */
423QStringList PackageManagerSettings::getDestinationUrls()
424{
425 QStringList sl;
426 for (int i=0; i<(int)destinations->count(); i++)
427 {
428 sl += *destinationurlDic[i];
429 }
430 return sl;
431}
432
433void PackageManagerSettings::linkEnabled( bool b )
434{
435 activeLinkDestination->setEnabled( b );
436}
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 @@
1#ifndef PACKAGEMANAGERSETTINGS_H
2#define PACKAGEMANAGERSETTINGS_H
3
4#include "pksettingsbase.h"
5#include <qintdict.h>
6
7
8class PackageManagerSettings : private PackageManagerSettingsBase
9{
10 // Q_OBJECT
11public:
12 PackageManagerSettings( QWidget* , const char* , WFlags );
13 ~PackageManagerSettings();
14
15 bool showDialog( int ) ;
16 QString getDestinationUrl();
17 QString getDestinationName();
18 QString getLinkDestinationName();
19 bool createLinks();
20 QStringList getActiveServers();
21 QStringList getDestinationUrls();
22
23private:
24 QIntDict<QString> serverurlDic;
25 QIntDict<QString> destinationurlDic;
26 int ipkg_old;
27 int editedserver;
28 int editeddestination;
29 int currentSetting;
30 int installationSettingsCount;
31 bool changed;
32
33 bool readIpkgConfig(const QString&);
34 void writeIpkgConfig(const QString&);
35 void writeSettings();
36 void readSettings();
37
38public slots:
39 void writeInstallationSettings();
40 void readInstallationSettings();
41 void writeCurrentInstallationSetting();
42 void readInstallationSetting(int);
43 void installationSettingSetName(const QString &);
44
45 void newServer();
46 void editServer(int);
47 void removeDestination();
48 void newDestination();
49 void editDestination(int);
50 void linkEnabled(bool);
51 void removeServer();
52 void serverNameChanged(const QString&);
53 void serverUrlChanged(const QString&);
54 void destNameChanged(const QString&);
55 void destUrlChanged(const QString&);
56 void installationSettingChange(int);
57 void newInstallationSetting();
58 void removeInstallationSetting();
59 void renameInstallationSetting();
60};
61
62#endif