summaryrefslogtreecommitdiff
authortille <tille>2002-07-09 13:17:05 (UTC)
committer tille <tille>2002-07-09 13:17:05 (UTC)
commite99adc2029808f6276474c95e8587607a4bd8091 (patch) (unidiff)
treeff1d4fc802b9cb581cb01466777f564ca7390512
parent0faf1ec599a30432169486aea8a117cf9f1627b8 (diff)
downloadopie-e99adc2029808f6276474c95e8587607a4bd8091.zip
opie-e99adc2029808f6276474c95e8587607a4bd8091.tar.gz
opie-e99adc2029808f6276474c95e8587607a4bd8091.tar.bz2
weg mit dem scheiss...
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/oipkg/settings.cpp450
-rw-r--r--noncore/unsupported/oipkg/settings.h75
2 files changed, 0 insertions, 525 deletions
diff --git a/noncore/unsupported/oipkg/settings.cpp b/noncore/unsupported/oipkg/settings.cpp
deleted file mode 100644
index 4bd60c0..0000000
--- a/noncore/unsupported/oipkg/settings.cpp
+++ b/dev/null
@@ -1,450 +0,0 @@
1/***************************************************************************
2 * *
3 * This program is free software; you can redistribute it and/or modify *
4 * it under the terms of the GNU General Public License as published by *
5 * the Free Software Foundation; either version 2 of the License, or *
6 * (at your option) any later version. *
7 * *
8 ***************************************************************************/
9// (c) 2002 Patrick S. Vogt <tille@handhelds.org>
10#include "pksettings.h"
11
12#include <qpe/config.h>
13#include <qcombobox.h>
14#include <qfile.h>
15#include <qlineedit.h>
16#include <qpushbutton.h>
17#include <qlistbox.h>
18#include <qcheckbox.h>
19#include <qstring.h>
20#include <qobject.h>
21#include <qtextstream.h>
22#include <qtabwidget.h>
23
24
25PackageManagerSettings::PackageManagerSettings( QWidget* parent, const char* name, WFlags fl )
26 : PackageManagerSettingsBase( parent, name, fl )
27{
28 connect( newserver, SIGNAL(clicked()), this, SLOT(newServer()) );
29 connect( removeserver, SIGNAL(clicked()), this, SLOT(removeServer()) );
30 connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) );
31 connect( newdestination, SIGNAL(clicked()), this, SLOT(newDestination()) );
32 connect( removedestination, SIGNAL(clicked()), this, SLOT(removeDestination()) );
33 connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) );
34 // connect( CheckBoxLink, SIGNAL(toggled(bool)),
35 // activeLinkDestination, SLOT(setEnabled(bool)) );
36
37 connect( settingName, SIGNAL(activated(int)), this, SLOT(installationSettingChange(int)) );
38 connect( settingName, SIGNAL(textChanged(const QString &)), this, SLOT(installationSettingSetName(const QString &)) );
39 connect( newsetting, SIGNAL(clicked()), this, SLOT(newInstallationSetting()) );
40 connect( renamesetting, SIGNAL(clicked()), this, SLOT(renameInstallationSetting()) );
41 connect( removesetting, SIGNAL(clicked()), this, SLOT(removeInstallationSetting()) );
42 servername->setEnabled(FALSE);
43 serverurl->setEnabled(FALSE);
44 serverurlDic.setAutoDelete(TRUE);
45 destinationname->setEnabled(FALSE);
46 destinationurl->setEnabled(FALSE);
47 destinationurlDic.setAutoDelete(TRUE);
48 readSettings();
49}
50
51PackageManagerSettings::~PackageManagerSettings()
52{
53}
54
55
56void PackageManagerSettings::newServer()
57{
58 int i = servers->count();
59 if ( servername->isEnabled() || serverurl->text().isEmpty() ) {
60 serverurlDic.insert(i,new QString("http://"));
61 servers->insertItem(tr("New"));
62 activeServers->insertItem(tr("New"));
63 } else {
64 // allows one-level undo
65 serverurlDic.insert(i,new QString(serverurl->text()));
66 servers->insertItem(servername->text());
67 activeServers->insertItem(servername->text());
68 }
69 servers->setSelected(i,TRUE);
70 editServer(i);
71}
72
73void PackageManagerSettings::newDestination()
74{
75 int i = destinations->count();
76 if ( destinationname->isEnabled() || destinationurl->text().isEmpty() ) {
77 destinationurlDic.insert(i,new QString("/"));
78 destinations->insertItem(tr("New"));
79 activeDestination->insertItem(tr("New"));
80 activeLinkDestination->insertItem(tr("New"));
81 } else {
82 // allows one-level undo
83 destinationurlDic.insert(i,new QString(destinationurl->text()));
84 destinations->insertItem(destinationname->text());
85 activeDestination->insertItem(destinationname->text());
86 activeLinkDestination->insertItem(destinationname->text());
87 }
88 destinations->setSelected(i,TRUE);
89 editDestination(i);
90}
91
92
93void PackageManagerSettings::editServer(int i)
94{
95 if ( servername->isEnabled() ) {
96 disconnect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) );
97 disconnect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) );
98 } else {
99 servername->setEnabled(TRUE);
100 serverurl->setEnabled(TRUE);
101 }
102
103 servername->setText( servers->text(i) );
104 serverurl->setText( *serverurlDic[i] );
105
106 editedserver = i;
107
108 connect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) );
109 connect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) );
110}
111
112
113void PackageManagerSettings::editDestination(int i)
114{
115 if ( destinationname->isEnabled() ) {
116 disconnect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) );
117 disconnect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) );
118 } else {
119 destinationname->setEnabled(TRUE);
120 destinationurl->setEnabled(TRUE);
121 }
122
123 destinationname->setText( destinations->text(i) );
124 destinationurl->setText( *destinationurlDic[i] );
125
126 editeddestination = i;
127
128 connect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) );
129 connect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) );
130}
131
132void PackageManagerSettings::removeServer()
133{
134 disconnect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) );
135 disconnect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) );
136 servername->setText(servers->text(editedserver));
137 serverurl->setText(*serverurlDic[editedserver]);
138 disconnect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) );
139 servers->removeItem(editedserver);
140 activeServers->removeItem(editedserver);
141 connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) );
142 servername->setEnabled(FALSE);
143 serverurl->setEnabled(FALSE);
144}
145
146void PackageManagerSettings::removeDestination()
147{
148 disconnect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) );
149 disconnect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) );
150 destinationname->setText(destinations->text(editedserver));
151 destinationurl->setText(*destinationurlDic[editedserver]);
152 disconnect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) );
153 destinations->removeItem(editeddestination);
154 activeDestination->removeItem(editeddestination);
155 activeLinkDestination->removeItem(editeddestination);
156 connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) );
157 destinationname->setEnabled(FALSE);
158 destinationurl->setEnabled(FALSE);
159}
160
161void PackageManagerSettings::serverNameChanged(const QString& t)
162{
163 disconnect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) );
164 servers->changeItem( t, editedserver );
165 activeServers->changeItem( t, editedserver );
166 connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) );
167}
168
169void PackageManagerSettings::destNameChanged(const QString& t)
170{
171 disconnect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) );
172 destinations->changeItem( t, editeddestination );
173 activeDestination->changeItem( t, editeddestination );
174 activeLinkDestination->changeItem( t, editeddestination );
175 connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) );
176}
177
178void PackageManagerSettings::serverUrlChanged(const QString& t)
179{
180 serverurlDic.replace(editedserver, new QString(t));
181}
182
183void PackageManagerSettings::destUrlChanged(const QString& t)
184{
185 destinationurlDic.replace(editeddestination, new QString(t));
186}
187
188void PackageManagerSettings::writeIpkgConfig(const QString& conffile)
189{
190 QFile conf(conffile);
191 if ( ! conf.open(IO_WriteOnly) ) return;
192 QTextStream s(&conf);
193 s << "# "+tr("Written by Opie Package Manager")+"\n";
194 for (int i=0; i<(int)activeServers->count(); i++)
195 {
196 QString url = serverurlDic[i] ? *serverurlDic[i] : QString("???");
197 if ( !activeServers->isSelected(i) )
198 s << "#";
199 s << "src " << activeServers->text(i) << " " << url << "\n";
200 }
201 for (int i=0; i<(int)destinations->count(); i++)
202 {
203 QString url = destinationurlDic[i] ? *destinationurlDic[i] : QString("???");
204 s << "dest " << destinations->text(i) << " " << url << "\n";
205 }
206 conf.close();
207}
208
209
210void PackageManagerSettings::readInstallationSettings()
211{
212 Config cfg( "oipkg", Config::User );
213 cfg.setGroup( "Settings" );
214 installationSettingsCount = cfg.readNumEntry( "count", -1 );
215 currentSetting = cfg.readNumEntry( "current", 0 );
216
217 for (int i = 0; i < installationSettingsCount; i++)
218 {
219 cfg.setGroup( "Setting_" + QString::number(i) );
220 settingName->insertItem( cfg.readEntry( "name", "???" ), i );
221 };
222 readInstallationSetting( currentSetting );
223}
224
225
226void PackageManagerSettings::removeInstallationSetting()
227{
228 settingName->removeItem( settingName->currentItem() );
229 Config cfg( "oipkg", Config::User );
230 cfg.setGroup( "Setting_" + QString::number( installationSettingsCount ) );
231 cfg.clearGroup();
232 installationSettingsCount--;
233 settingName->setEditable( false );
234}
235
236void PackageManagerSettings::newInstallationSetting()
237{
238 installationSettingsCount++;
239 settingName->insertItem( "New", installationSettingsCount );
240 settingName->setCurrentItem( installationSettingsCount );
241 settingName->setEditable( true );
242}
243
244void PackageManagerSettings::installationSettingChange(int cs)
245{
246 writeCurrentInstallationSetting();
247 currentSetting = cs;
248 readInstallationSetting( cs );
249}
250
251void PackageManagerSettings::writeInstallationSettings()
252{
253 {
254 Config cfg( "oipkg", Config::User );
255 cfg.setGroup( "Settings" );
256 cfg.writeEntry( "count", installationSettingsCount );
257 cfg.writeEntry( "current", currentSetting );
258 writeCurrentInstallationSetting();
259 }
260}
261
262
263void PackageManagerSettings::readInstallationSetting(int setting)
264{
265 if ( setting < 0 ) return;
266 Config cfg( "oipkg", Config::User );
267 cfg.setGroup( "Setting_" + QString::number( setting ) );
268 CheckBoxLink->setChecked( cfg.readBoolEntry( "link", false ) );
269 QString dest = cfg.readEntry( "dest" );
270 QString linkdest = cfg.readEntry( "linkdest" );
271
272 for ( int i = 0; i < activeDestination->count(); i++)
273 {
274 QString name = cfg.readEntry( "name" );
275 if ( activeDestination->text( i ) == name )
276 activeDestination->setCurrentItem( i );
277 if ( activeLinkDestination->text( i ) == name )
278 activeLinkDestination->setCurrentItem( i );
279 }
280}
281
282void PackageManagerSettings::writeCurrentInstallationSetting()
283{
284 Config cfg( "oipkg", Config::User );
285 cfg.setGroup( "Setting_" + QString::number(currentSetting) );
286 cfg.writeEntry( "link", CheckBoxLink->isChecked() );
287 cfg.writeEntry( "dest", getDestinationName() );
288 cfg.writeEntry( "linkdest" , getLinkDestinationName() );
289 QStringList sers = getActiveServers();
290 int srvc = 0;
291 for ( QStringList::Iterator it = sers.begin(); it != sers.end(); ++it ) {
292 cfg.writeEntry( "server_" + QString::number(srvc++), *it );
293 }
294 cfg.writeEntry( "server_count", srvc );
295}
296
297void PackageManagerSettings::renameInstallationSetting()
298{
299 settingName->setEditable( true );
300}
301
302void PackageManagerSettings::installationSettingSetName(const QString &name)
303{
304 settingName->changeItem( name, settingName->currentItem() );
305}
306
307
308bool PackageManagerSettings::readIpkgConfig(const QString& conffile)
309{
310 QFile conf(conffile);
311 if ( conf.open(IO_ReadOnly) ) {
312 QTextStream s(&conf);
313 servers->clear();
314 activeServers->clear();
315 activeDestination->clear();
316 activeLinkDestination->clear();
317 serverurlDic.clear();
318 destinationurlDic.clear();
319 ipkg_old=0;
320 int currentserver=0;
321 while ( !s.atEnd() ) {
322 QString l = s.readLine();
323 QStringList token = QStringList::split(' ', l);
324 if ( token[0] == "src" || token[0] == "#src" ) {
325 currentserver=servers->count();
326 serverurlDic.insert(servers->count(),new QString(token[2]));
327 int a = token[0] == "src" ? 1 : 0;
328 int i = servers->count();
329 servers->insertItem(token[1]);
330 activeServers->insertItem( token[1] );
331 activeServers->setSelected(i,a);
332 } else if ( token[0] == "dest" ) {
333 currentserver=destinations->count();
334 destinationurlDic.insert(destinations->count(),new QString(token[2]));
335 destinations->insertItem(token[1]);
336 activeDestination->insertItem( token[1] );
337 activeLinkDestination->insertItem( token[1] );
338
339 } else if ( token[0] == "option" ) {
340 } else {
341 // Old style?
342 int eq = l.find('=');
343 if ( eq >= 0 ) {
344 QString v = l.mid(eq+1).stripWhiteSpace();
345 if ( v[0] == '"' || v[0] == '\'' ) {
346 int cl=v.find(v[0],1);
347 if ( cl >= 0 )
348 v = v.mid(1,cl-1);
349 }
350 if ( l.left(12) == "IPKG_SOURCE=" ) {
351 ipkg_old=1;
352 currentserver=servers->count();
353 serverurlDic.insert(servers->count(),new QString(v));
354 servers->insertItem(v);
355 } else if ( l.left(13) == "#IPKG_SOURCE=" ) {
356 serverurlDic.insert(servers->count(),new QString(v));
357 servers->insertItem(v);
358 } else if ( l.left(10) == "IPKG_ROOT=" ) {
359
360 }
361 }
362 }
363 }
364 if ( ipkg_old ) {
365 servers->setSelectionMode(QListBox::Single);
366 servers->setSelected(currentserver,TRUE);
367 }
368 return TRUE;
369 } else {
370 return FALSE;
371 }
372}
373
374void PackageManagerSettings::readSettings()
375{
376 readIpkgConfig("/etc/ipkg.conf");
377 readInstallationSettings();
378}
379
380void PackageManagerSettings::writeSettings()
381{
382 writeIpkgConfig("/etc/ipkg.conf");
383 writeInstallationSettings();
384}
385
386bool PackageManagerSettings::showDialog( int i )
387{
388 TabWidget->setCurrentPage( i );
389 showMaximized();
390 bool ret = exec();
391 if ( ret ) writeSettings();
392 else readSettings();
393 return ret;
394}
395
396QString PackageManagerSettings::getDestinationName()
397{
398 return activeDestination->currentText();
399}
400
401QString PackageManagerSettings::getLinkDestinationName()
402{
403 return activeLinkDestination->currentText();
404}
405
406/** Returns the URL of the active destination */
407QString PackageManagerSettings::getDestinationUrl()
408{
409 int dnr = activeDestination->currentItem();
410 return *destinationurlDic.find(dnr);
411}
412
413/** Should oipkg create links form install destination to link destination */
414bool PackageManagerSettings::createLinks()
415{
416 return CheckBoxLink->isChecked();
417}
418
419/** get the servers that are active */
420QStringList PackageManagerSettings::getActiveServers()
421{
422 QStringList sl;
423 for (int i=0; i<(int)activeServers->count(); i++)
424 {
425 if ( activeServers->isSelected(i) )
426 sl += activeServers->text(i);
427 }
428 return sl;
429}
430
431/** returns the destination listed in ipkg.conf */
432QStringList PackageManagerSettings::getDestinationUrls()
433{
434 QStringList sl;
435 for (int i=0; i<(int)destinations->count(); i++)
436 {
437 sl += *destinationurlDic[i];
438 }
439 return sl;
440}
441
442void PackageManagerSettings::linkEnabled( bool b )
443{
444 activeLinkDestination->setEnabled( b );
445}
446
447void PackageManagerSettings::activeDestinationChange(int i)
448{
449 activeLinkDestination->setCurrentItem( i );
450} \ No newline at end of file
diff --git a/noncore/unsupported/oipkg/settings.h b/noncore/unsupported/oipkg/settings.h
deleted file mode 100644
index 44459b2..0000000
--- a/noncore/unsupported/oipkg/settings.h
+++ b/dev/null
@@ -1,75 +0,0 @@
1/***************************************************************************
2 * *
3 * This program is free software; you can redistribute it and/or modify *
4 * it under the terms of the GNU General Public License as published by *
5 * the Free Software Foundation; either version 2 of the License, or *
6 * (at your option) any later version. *
7 * *
8 ***************************************************************************/
9// (c) 2002 Patrick S. Vogt <tille@handhelds.org>
10#ifndef PACKAGEMANAGERSETTINGS_H
11#define PACKAGEMANAGERSETTINGS_H
12
13#include "pksettingsbase.h"
14#include <qintdict.h>
15
16
17class PackageManagerSettings : public PackageManagerSettingsBase
18{
19 Q_OBJECT
20public:
21 PackageManagerSettings( QWidget* , const char* , WFlags );
22 ~PackageManagerSettings();
23
24 bool showDialog( int ) ;
25 QString getDestinationUrl();
26 QString getDestinationName();
27 QString getLinkDestinationName();
28 bool createLinks();
29 QStringList getActiveServers();
30 QStringList getDestinationUrls();
31
32public slots: /** No descriptions */
33 void createLinks();
34 void removeLinks();
35 void writeInstallationSettings();
36 void readInstallationSettings();
37 void writeCurrentInstallationSetting();
38 void readInstallationSetting(int);
39 void installationSettingSetName(const QString &);
40 void activeDestinationChange(int)
41 void newServer();
42 void editServer(int);
43 void removeDestination();
44 void newDestination();
45 void editDestination(int);
46 void linkEnabled(bool);
47 void removeServer();
48 void serverNameChanged(const QString&);
49 void serverUrlChanged(const QString&);
50 void destNameChanged(const QString&);
51 void destUrlChanged(const QString&);
52 void installationSettingChange(int);
53 void newInstallationSetting();
54 void removeInstallationSetting();
55 void renameInstallationSetting();
56
57private:
58 QIntDict<QString> serverurlDic;
59 QIntDict<QString> destinationurlDic;
60 int ipkg_old;
61 int editedserver;
62 int editeddestination;
63 int currentSetting;
64 int installationSettingsCount;
65 bool changed;
66 bool serverChanged;
67
68 bool readIpkgConfig(const QString&);
69 void writeIpkgConfig(const QString&);
70 void writeSettings();
71 void readSettings();
72};
73
74#endif
75