-rw-r--r-- | noncore/settings/aqpkg/aqpkg.pro | 4 | ||||
-rw-r--r-- | noncore/settings/aqpkg/installdlgimpl.cpp | 5 | ||||
-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.cpp | 81 | ||||
-rw-r--r-- | noncore/settings/aqpkg/version.cpp | 214 |
4 files changed, 279 insertions, 25 deletions
diff --git a/noncore/settings/aqpkg/aqpkg.pro b/noncore/settings/aqpkg/aqpkg.pro index b869f32..99b82a1 100644 --- a/noncore/settings/aqpkg/aqpkg.pro +++ b/noncore/settings/aqpkg/aqpkg.pro | |||
@@ -1,44 +1,44 @@ | |||
1 | TEMPLATE= app | 1 | TEMPLATE= app |
2 | CONFIG = qt warn_on debug | 2 | CONFIG = qt warn_on debug |
3 | HEADERS = global.h \ | 3 | HEADERS = global.h \ |
4 | mainwin.h \ | 4 | mainwin.h \ |
5 | datamgr.h \ | 5 | datamgr.h \ |
6 | settingsimpl.h \ | 6 | settingsimpl.h \ |
7 | ipkg.h \ | 7 | ipkg.h \ |
8 | networkpkgmgr.h \ | 8 | networkpkgmgr.h \ |
9 | package.h \ | 9 | package.h \ |
10 | progressdlg.h \ | 10 | progressdlg.h \ |
11 | installdlgimpl.h \ | 11 | installdlgimpl.h \ |
12 | instoptionsimpl.h \ | 12 | instoptionsimpl.h \ |
13 | destination.h \ | 13 | destination.h \ |
14 | utils.h \ | 14 | utils.h \ |
15 | server.h \ | 15 | server.h \ |
16 | helpwindow.h \ | 16 | helpwindow.h \ |
17 | letterpushbutton.h \ | 17 | letterpushbutton.h \ |
18 | inputdlg.h | 18 | inputdlg.h |
19 | SOURCES = mainwin.cpp \ | 19 | SOURCES = mainwin.cpp \ |
20 | datamgr.cpp \ | 20 | datamgr.cpp \ |
21 | mem.cpp \ | 21 | mem.cpp \ |
22 | settingsimpl.cpp \ | 22 | settingsimpl.cpp \ |
23 | ipkg.cpp \ | 23 | ipkg.cpp \ |
24 | networkpkgmgr.cpp \ | 24 | networkpkgmgr.cpp \ |
25 | main.cpp \ | 25 | main.cpp \ |
26 | package.cpp \ | 26 | package.cpp \ |
27 | progressdlg.cpp \ | 27 | progressdlg.cpp \ |
28 | installdlgimpl.cpp \ | 28 | installdlgimpl.cpp \ |
29 | instoptionsimpl.cpp \ | 29 | instoptionsimpl.cpp \ |
30 | destination.cpp \ | 30 | destination.cpp \ |
31 | utils.cpp \ | 31 | utils.cpp \ |
32 | server.cpp \ | 32 | server.cpp \ |
33 | helpwindow.cpp \ | 33 | helpwindow.cpp \ |
34 | letterpushbutton.cpp \ | 34 | letterpushbutton.cpp \ |
35 | inputdlg.cpp | 35 | inputdlg.cpp \ |
36 | version.cpp | ||
36 | INTERFACES= settings.ui \ | 37 | INTERFACES= settings.ui \ |
37 | install.ui \ | 38 | install.ui \ |
38 | instoptions.ui | 39 | instoptions.ui |
39 | TARGET = aqpkg | 40 | TARGET = aqpkg |
40 | DESTDIR=$(OPIEDIR)/bin | ||
41 | INCLUDEPATH += $(OPIEDIR)/include | 41 | INCLUDEPATH += $(OPIEDIR)/include |
42 | DEPENDPATH += $(OPIEDIR)/include | 42 | DEPENDPATH += $(OPIEDIR)/include |
43 | LIBS += -lqpe -lstdc++ | 43 | LIBS += -lqpe -lstdc++ |
44 | 44 | ||
diff --git a/noncore/settings/aqpkg/installdlgimpl.cpp b/noncore/settings/aqpkg/installdlgimpl.cpp index 2ea70e0..b297437 100644 --- a/noncore/settings/aqpkg/installdlgimpl.cpp +++ b/noncore/settings/aqpkg/installdlgimpl.cpp | |||
@@ -1,223 +1,226 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | installdlgimpl.cpp - description | 2 | installdlgimpl.cpp - description |
3 | ------------------- | 3 | ------------------- |
4 | begin : Mon Aug 26 2002 | 4 | begin : Mon Aug 26 2002 |
5 | copyright : (C) 2002 by Andy Qua | 5 | copyright : (C) 2002 by Andy Qua |
6 | email : andy.qua@blueyonder.co.uk | 6 | email : andy.qua@blueyonder.co.uk |
7 | ***************************************************************************/ | 7 | ***************************************************************************/ |
8 | 8 | ||
9 | /*************************************************************************** | 9 | /*************************************************************************** |
10 | * * | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation; either version 2 of the License, or * | 13 | * the Free Software Foundation; either version 2 of the License, or * |
14 | * (at your option) any later version. * | 14 | * (at your option) any later version. * |
15 | * * | 15 | * * |
16 | ***************************************************************************/ | 16 | ***************************************************************************/ |
17 | 17 | ||
18 | #ifdef QWS | 18 | #ifdef QWS |
19 | #include <qpe/config.h> | 19 | #include <qpe/config.h> |
20 | #endif | 20 | #endif |
21 | 21 | ||
22 | #include <qmultilineedit.h> | 22 | #include <qmultilineedit.h> |
23 | #include <qdialog.h> | 23 | #include <qdialog.h> |
24 | #include <qcombobox.h> | 24 | #include <qcombobox.h> |
25 | #include <qcheckbox.h> | 25 | #include <qcheckbox.h> |
26 | #include <qpushbutton.h> | 26 | #include <qpushbutton.h> |
27 | 27 | ||
28 | 28 | ||
29 | #include "datamgr.h" | 29 | #include "datamgr.h" |
30 | #include "instoptionsimpl.h" | 30 | #include "instoptionsimpl.h" |
31 | #include "destination.h" | 31 | #include "destination.h" |
32 | #include "installdlgimpl.h" | 32 | #include "installdlgimpl.h" |
33 | #include "global.h" | 33 | #include "global.h" |
34 | 34 | ||
35 | InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl ) | 35 | InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl ) |
36 | : InstallDlg( parent, name, modal, fl ) | 36 | : InstallDlg( parent, name, modal, fl ) |
37 | { | 37 | { |
38 | pIpkg = 0; | 38 | pIpkg = 0; |
39 | upgradePackages = false; | 39 | upgradePackages = false; |
40 | dataMgr = dataManager; | 40 | dataMgr = dataManager; |
41 | vector<Destination>::iterator dit; | 41 | vector<Destination>::iterator dit; |
42 | 42 | ||
43 | QString defaultDest = "root"; | 43 | QString defaultDest = "root"; |
44 | #ifdef QWS | 44 | #ifdef QWS |
45 | Config cfg( "aqpkg" ); | 45 | Config cfg( "aqpkg" ); |
46 | cfg.setGroup( "settings" ); | 46 | cfg.setGroup( "settings" ); |
47 | defaultDest = cfg.readEntry( "dest", "root" ); | 47 | defaultDest = cfg.readEntry( "dest", "root" ); |
48 | 48 | ||
49 | // Grab flags - Turn MAKE_LINKS on by default (if no flags found) | 49 | // Grab flags - Turn MAKE_LINKS on by default (if no flags found) |
50 | flags = cfg.readNumEntry( "installFlags", 0 ); | 50 | flags = cfg.readNumEntry( "installFlags", 0 ); |
51 | #else | 51 | #else |
52 | flags = 0; | 52 | flags = 0; |
53 | #endif | 53 | #endif |
54 | 54 | ||
55 | // Output text is read only | 55 | // Output text is read only |
56 | output->setReadOnly( true ); | 56 | output->setReadOnly( true ); |
57 | QFont f( "helvetica" ); | 57 | QFont f( "helvetica" ); |
58 | f.setPointSize( 10 ); | 58 | f.setPointSize( 10 ); |
59 | output->setFont( f ); | 59 | output->setFont( f ); |
60 | 60 | ||
61 | 61 | ||
62 | // setup destination data | 62 | // setup destination data |
63 | int defIndex = 0; | 63 | int defIndex = 0; |
64 | int i; | 64 | int i; |
65 | for ( i = 0 , dit = dataMgr->getDestinationList().begin() ; dit != dataMgr->getDestinationList().end() ; ++dit, ++i ) | 65 | for ( i = 0 , dit = dataMgr->getDestinationList().begin() ; dit != dataMgr->getDestinationList().end() ; ++dit, ++i ) |
66 | { | 66 | { |
67 | destination->insertItem( dit->getDestinationName() ); | 67 | destination->insertItem( dit->getDestinationName() ); |
68 | if ( dit->getDestinationName() == defaultDest ) | 68 | if ( dit->getDestinationName() == defaultDest ) |
69 | defIndex = i; | 69 | defIndex = i; |
70 | } | 70 | } |
71 | 71 | ||
72 | destination->setCurrentItem( defIndex ); | 72 | destination->setCurrentItem( defIndex ); |
73 | 73 | ||
74 | vector<InstallData>::iterator it; | 74 | vector<InstallData>::iterator it; |
75 | // setup package data | 75 | // setup package data |
76 | QString remove = "Remove\n"; | 76 | QString remove = "Remove\n"; |
77 | QString install = "\nInstall\n"; | 77 | QString install = "\nInstall\n"; |
78 | QString upgrade = "\nUpgrade\n"; | 78 | QString upgrade = "\nUpgrade\n"; |
79 | for ( it = packageList.begin() ; it != packageList.end() ; ++it ) | 79 | for ( it = packageList.begin() ; it != packageList.end() ; ++it ) |
80 | { | 80 | { |
81 | InstallData item = *it; | 81 | InstallData item = *it; |
82 | if ( item.option == "I" ) | 82 | if ( item.option == "I" ) |
83 | { | 83 | { |
84 | installList.push_back( item ); | 84 | installList.push_back( item ); |
85 | install += " " + item.packageName + "\n"; | 85 | install += " " + item.packageName + "\n"; |
86 | } | 86 | } |
87 | else if ( item.option == "D" ) | 87 | else if ( item.option == "D" ) |
88 | { | 88 | { |
89 | removeList.push_back( item ); | 89 | removeList.push_back( item ); |
90 | remove += " " + item.packageName + "\n"; | 90 | remove += " " + item.packageName + "\n"; |
91 | } | 91 | } |
92 | else if ( item.option == "U" || item.option == "R" ) | 92 | else if ( item.option == "U" || item.option == "R" ) |
93 | { | 93 | { |
94 | updateList.push_back( item ); | 94 | updateList.push_back( item ); |
95 | upgrade += " " + item.packageName + "\n"; | 95 | QString type = " (Upgrade)"; |
96 | if ( item.option == "R" ) | ||
97 | type = " (ReInstall)"; | ||
98 | upgrade += " " + item.packageName + type + "\n"; | ||
96 | } | 99 | } |
97 | } | 100 | } |
98 | 101 | ||
99 | output->setText( remove + install + upgrade ); | 102 | output->setText( remove + install + upgrade ); |
100 | } | 103 | } |
101 | 104 | ||
102 | InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, QWidget *parent, const char *name, bool modal, WFlags fl ) | 105 | InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, QWidget *parent, const char *name, bool modal, WFlags fl ) |
103 | : InstallDlg( parent, name, modal, fl ) | 106 | : InstallDlg( parent, name, modal, fl ) |
104 | { | 107 | { |
105 | pIpkg = ipkg; | 108 | pIpkg = ipkg; |
106 | output->setText( initialText ); | 109 | output->setText( initialText ); |
107 | } | 110 | } |
108 | 111 | ||
109 | 112 | ||
110 | InstallDlgImpl::~InstallDlgImpl() | 113 | InstallDlgImpl::~InstallDlgImpl() |
111 | { | 114 | { |
112 | } | 115 | } |
113 | 116 | ||
114 | bool InstallDlgImpl :: showDlg() | 117 | bool InstallDlgImpl :: showDlg() |
115 | { | 118 | { |
116 | showMaximized(); | 119 | showMaximized(); |
117 | bool ret = exec(); | 120 | bool ret = exec(); |
118 | 121 | ||
119 | return ret; | 122 | return ret; |
120 | } | 123 | } |
121 | 124 | ||
122 | void InstallDlgImpl :: optionsSelected() | 125 | void InstallDlgImpl :: optionsSelected() |
123 | { | 126 | { |
124 | InstallOptionsDlgImpl opt( flags, this, "Option", true ); | 127 | InstallOptionsDlgImpl opt( flags, this, "Option", true ); |
125 | opt.exec(); | 128 | opt.exec(); |
126 | 129 | ||
127 | // set options selected from dialog | 130 | // set options selected from dialog |
128 | flags = 0; | 131 | flags = 0; |
129 | if ( opt.forceDepends->isChecked() ) | 132 | if ( opt.forceDepends->isChecked() ) |
130 | flags |= FORCE_DEPENDS; | 133 | flags |= FORCE_DEPENDS; |
131 | if ( opt.forceReinstall->isChecked() ) | 134 | if ( opt.forceReinstall->isChecked() ) |
132 | flags |= FORCE_REINSTALL; | 135 | flags |= FORCE_REINSTALL; |
133 | if ( opt.forceRemove->isChecked() ) | 136 | if ( opt.forceRemove->isChecked() ) |
134 | flags |= FORCE_REMOVE; | 137 | flags |= FORCE_REMOVE; |
135 | if ( opt.forceOverwrite->isChecked() ) | 138 | if ( opt.forceOverwrite->isChecked() ) |
136 | flags |= FORCE_OVERWRITE; | 139 | flags |= FORCE_OVERWRITE; |
137 | 140 | ||
138 | #ifdef QWS | 141 | #ifdef QWS |
139 | Config cfg( "aqpkg" ); | 142 | Config cfg( "aqpkg" ); |
140 | cfg.setGroup( "settings" ); | 143 | cfg.setGroup( "settings" ); |
141 | cfg.writeEntry( "installFlags", flags ); | 144 | cfg.writeEntry( "installFlags", flags ); |
142 | #endif | 145 | #endif |
143 | } | 146 | } |
144 | 147 | ||
145 | void InstallDlgImpl :: installSelected() | 148 | void InstallDlgImpl :: installSelected() |
146 | { | 149 | { |
147 | if ( btnInstall->text() == "Close" ) | 150 | if ( btnInstall->text() == "Close" ) |
148 | { | 151 | { |
149 | done( 1 ); | 152 | done( 1 ); |
150 | return; | 153 | return; |
151 | } | 154 | } |
152 | 155 | ||
153 | btnInstall->setEnabled( false ); | 156 | btnInstall->setEnabled( false ); |
154 | 157 | ||
155 | if ( pIpkg ) | 158 | if ( pIpkg ) |
156 | { | 159 | { |
157 | output->setText( "" ); | 160 | output->setText( "" ); |
158 | 161 | ||
159 | connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); | 162 | connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); |
160 | pIpkg->runIpkg(); | 163 | pIpkg->runIpkg(); |
161 | } | 164 | } |
162 | else | 165 | else |
163 | { | 166 | { |
164 | output->setText( "" ); | 167 | output->setText( "" ); |
165 | Destination *d = dataMgr->getDestination( destination->currentText() ); | 168 | Destination *d = dataMgr->getDestination( destination->currentText() ); |
166 | QString dest = d->getDestinationName(); | 169 | QString dest = d->getDestinationName(); |
167 | QString destDir = d->getDestinationPath(); | 170 | QString destDir = d->getDestinationPath(); |
168 | int instFlags = flags; | 171 | int instFlags = flags; |
169 | if ( d->linkToRoot() ) | 172 | if ( d->linkToRoot() ) |
170 | instFlags |= MAKE_LINKS; | 173 | instFlags |= MAKE_LINKS; |
171 | 174 | ||
172 | #ifdef QWS | 175 | #ifdef QWS |
173 | // Save settings | 176 | // Save settings |
174 | Config cfg( "aqpkg" ); | 177 | Config cfg( "aqpkg" ); |
175 | cfg.setGroup( "settings" ); | 178 | cfg.setGroup( "settings" ); |
176 | cfg.writeEntry( "dest", dest ); | 179 | cfg.writeEntry( "dest", dest ); |
177 | #endif | 180 | #endif |
178 | 181 | ||
179 | pIpkg = new Ipkg; | 182 | pIpkg = new Ipkg; |
180 | connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); | 183 | connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); |
181 | 184 | ||
182 | // First run through the remove list, then the install list then the upgrade list | 185 | // First run through the remove list, then the install list then the upgrade list |
183 | vector<InstallData>::iterator it; | 186 | vector<InstallData>::iterator it; |
184 | pIpkg->setOption( "remove" ); | 187 | pIpkg->setOption( "remove" ); |
185 | for ( it = removeList.begin() ; it != removeList.end() ; ++it ) | 188 | for ( it = removeList.begin() ; it != removeList.end() ; ++it ) |
186 | { | 189 | { |
187 | pIpkg->setDestination( it->destination->getDestinationName() ); | 190 | pIpkg->setDestination( it->destination->getDestinationName() ); |
188 | pIpkg->setDestinationDir( it->destination->getDestinationPath() ); | 191 | pIpkg->setDestinationDir( it->destination->getDestinationPath() ); |
189 | pIpkg->setPackage( it->packageName ); | 192 | pIpkg->setPackage( it->packageName ); |
190 | 193 | ||
191 | int tmpFlags = flags; | 194 | int tmpFlags = flags; |
192 | if ( it->destination->linkToRoot() ) | 195 | if ( it->destination->linkToRoot() ) |
193 | tmpFlags |= MAKE_LINKS; | 196 | tmpFlags |= MAKE_LINKS; |
194 | 197 | ||
195 | pIpkg->setFlags( tmpFlags ); | 198 | pIpkg->setFlags( tmpFlags ); |
196 | pIpkg->runIpkg(); | 199 | pIpkg->runIpkg(); |
197 | } | 200 | } |
198 | 201 | ||
199 | pIpkg->setOption( "install" ); | 202 | pIpkg->setOption( "install" ); |
200 | pIpkg->setDestination( dest ); | 203 | pIpkg->setDestination( dest ); |
201 | pIpkg->setDestinationDir( destDir ); | 204 | pIpkg->setDestinationDir( destDir ); |
202 | pIpkg->setFlags( instFlags ); | 205 | pIpkg->setFlags( instFlags ); |
203 | for ( it = installList.begin() ; it != installList.end() ; ++it ) | 206 | for ( it = installList.begin() ; it != installList.end() ; ++it ) |
204 | { | 207 | { |
205 | pIpkg->setPackage( it->packageName ); | 208 | pIpkg->setPackage( it->packageName ); |
206 | pIpkg->runIpkg(); | 209 | pIpkg->runIpkg(); |
207 | } | 210 | } |
208 | 211 | ||
209 | flags |= FORCE_REINSTALL; | 212 | flags |= FORCE_REINSTALL; |
210 | for ( it = updateList.begin() ; it != updateList.end() ; ++it ) | 213 | for ( it = updateList.begin() ; it != updateList.end() ; ++it ) |
211 | { | 214 | { |
212 | if ( it->option == "R" ) | 215 | if ( it->option == "R" ) |
213 | pIpkg->setOption( "reinstall" ); | 216 | pIpkg->setOption( "reinstall" ); |
214 | else | 217 | else |
215 | pIpkg->setOption( "upgrade" ); | 218 | pIpkg->setOption( "upgrade" ); |
216 | pIpkg->setDestination( it->destination->getDestinationName() ); | 219 | pIpkg->setDestination( it->destination->getDestinationName() ); |
217 | pIpkg->setDestinationDir( it->destination->getDestinationPath() ); | 220 | pIpkg->setDestinationDir( it->destination->getDestinationPath() ); |
218 | pIpkg->setPackage( it->packageName ); | 221 | pIpkg->setPackage( it->packageName ); |
219 | 222 | ||
220 | int tmpFlags = flags; | 223 | int tmpFlags = flags; |
221 | if ( it->destination->linkToRoot() && it->recreateLinks ) | 224 | if ( it->destination->linkToRoot() && it->recreateLinks ) |
222 | tmpFlags |= MAKE_LINKS; | 225 | tmpFlags |= MAKE_LINKS; |
223 | pIpkg->setFlags( tmpFlags ); | 226 | pIpkg->setFlags( tmpFlags ); |
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp index 3971aea..02e4e73 100644 --- a/noncore/settings/aqpkg/networkpkgmgr.cpp +++ b/noncore/settings/aqpkg/networkpkgmgr.cpp | |||
@@ -1,363 +1,368 @@ | |||
1 | /*************************************************************************** | 1 | /*************************************************************************** |
2 | networkpkgmgr.cpp - description | 2 | networkpkgmgr.cpp - description |
3 | ------------------- | 3 | ------------------- |
4 | begin : Mon Aug 26 13:32:30 BST 2002 | 4 | begin : Mon Aug 26 13:32:30 BST 2002 |
5 | copyright : (C) 2002 by Andy Qua | 5 | copyright : (C) 2002 by Andy Qua |
6 | email : andy.qua@blueyonder.co.uk | 6 | email : andy.qua@blueyonder.co.uk |
7 | ***************************************************************************/ | 7 | ***************************************************************************/ |
8 | 8 | ||
9 | /*************************************************************************** | 9 | /*************************************************************************** |
10 | * * | 10 | * * |
11 | * This program is free software; you can redistribute it and/or modify * | 11 | * This program is free software; you can redistribute it and/or modify * |
12 | * it under the terms of the GNU General Public License as published by * | 12 | * it under the terms of the GNU General Public License as published by * |
13 | * the Free Software Foundation; either version 2 of the License, or * | 13 | * the Free Software Foundation; either version 2 of the License, or * |
14 | * (at your option) any later version. * | 14 | * (at your option) any later version. * |
15 | * * | 15 | * * |
16 | ***************************************************************************/ | 16 | ***************************************************************************/ |
17 | 17 | ||
18 | #include <fstream> | 18 | #include <fstream> |
19 | #include <iostream> | 19 | #include <iostream> |
20 | using namespace std; | 20 | using namespace std; |
21 | 21 | ||
22 | #include <unistd.h> | 22 | #include <unistd.h> |
23 | #include <stdlib.h> | 23 | #include <stdlib.h> |
24 | #include <linux/limits.h> | 24 | #include <linux/limits.h> |
25 | 25 | ||
26 | #ifdef QWS | 26 | #ifdef QWS |
27 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
28 | #include <qpe/qcopenvelope_qws.h> | 28 | #include <qpe/qcopenvelope_qws.h> |
29 | #include <qpe/config.h> | 29 | #include <qpe/config.h> |
30 | #else | 30 | #else |
31 | #include <qapplication.h> | 31 | #include <qapplication.h> |
32 | #endif | 32 | #endif |
33 | #include <qlabel.h> | 33 | #include <qlabel.h> |
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qmessagebox.h> | 35 | #include <qmessagebox.h> |
36 | 36 | ||
37 | #include "datamgr.h" | 37 | #include "datamgr.h" |
38 | #include "networkpkgmgr.h" | 38 | #include "networkpkgmgr.h" |
39 | #include "installdlgimpl.h" | 39 | #include "installdlgimpl.h" |
40 | #include "ipkg.h" | 40 | #include "ipkg.h" |
41 | #include "inputdlg.h" | 41 | #include "inputdlg.h" |
42 | #include "letterpushbutton.h" | 42 | #include "letterpushbutton.h" |
43 | 43 | ||
44 | #include "global.h" | 44 | #include "global.h" |
45 | 45 | ||
46 | extern int compareVersions( const char *v1, const char *v2 ); | ||
47 | |||
46 | NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name) | 48 | NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name) |
47 | : QWidget(parent, name) | 49 | : QWidget(parent, name) |
48 | { | 50 | { |
49 | dataMgr = dataManager; | 51 | dataMgr = dataManager; |
50 | 52 | ||
51 | #ifdef QWS | 53 | #ifdef QWS |
52 | // read download directory from config file | 54 | // read download directory from config file |
53 | Config cfg( "aqpkg" ); | 55 | Config cfg( "aqpkg" ); |
54 | cfg.setGroup( "settings" ); | 56 | cfg.setGroup( "settings" ); |
55 | currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); | 57 | currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); |
56 | showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); | 58 | showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); |
57 | #endif | 59 | #endif |
58 | 60 | ||
59 | 61 | ||
60 | initGui(); | 62 | initGui(); |
61 | setupConnections(); | 63 | setupConnections(); |
62 | 64 | ||
63 | updateData(); | 65 | updateData(); |
64 | // progressDlg = 0; | 66 | // progressDlg = 0; |
65 | // timerId = startTimer( 100 ); | 67 | // timerId = startTimer( 100 ); |
66 | } | 68 | } |
67 | 69 | ||
68 | NetworkPackageManager::~NetworkPackageManager() | 70 | NetworkPackageManager::~NetworkPackageManager() |
69 | { | 71 | { |
70 | } | 72 | } |
71 | 73 | ||
72 | void NetworkPackageManager :: timerEvent ( QTimerEvent * ) | 74 | void NetworkPackageManager :: timerEvent ( QTimerEvent * ) |
73 | { | 75 | { |
74 | killTimer( timerId ); | 76 | killTimer( timerId ); |
75 | 77 | ||
76 | // showProgressDialog(); | 78 | // showProgressDialog(); |
77 | // Add server names to listbox | 79 | // Add server names to listbox |
78 | updateData(); | 80 | updateData(); |
79 | 81 | ||
80 | // progressDlg->hide(); | 82 | // progressDlg->hide(); |
81 | } | 83 | } |
82 | 84 | ||
83 | void NetworkPackageManager :: updateData() | 85 | void NetworkPackageManager :: updateData() |
84 | { | 86 | { |
85 | serversList->clear(); | 87 | serversList->clear(); |
86 | packagesList->clear(); | 88 | packagesList->clear(); |
87 | 89 | ||
88 | 90 | ||
89 | vector<Server>::iterator it; | 91 | vector<Server>::iterator it; |
90 | int activeItem = -1; | 92 | int activeItem = -1; |
91 | int i; | 93 | int i; |
92 | for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i ) | 94 | for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i ) |
93 | { | 95 | { |
94 | if ( !it->isServerActive() ) | 96 | if ( !it->isServerActive() ) |
95 | { | 97 | { |
96 | i--; | 98 | i--; |
97 | continue; | 99 | continue; |
98 | } | 100 | } |
99 | serversList->insertItem( it->getServerName() ); | 101 | serversList->insertItem( it->getServerName() ); |
100 | if ( it->getServerName() == currentlySelectedServer ) | 102 | if ( it->getServerName() == currentlySelectedServer ) |
101 | activeItem = i; | 103 | activeItem = i; |
102 | } | 104 | } |
103 | 105 | ||
104 | // set selected server to be active server | 106 | // set selected server to be active server |
105 | if ( activeItem != -1 ) | 107 | if ( activeItem != -1 ) |
106 | serversList->setCurrentItem( activeItem ); | 108 | serversList->setCurrentItem( activeItem ); |
107 | serverSelected( 0 ); | 109 | serverSelected( 0 ); |
108 | } | 110 | } |
109 | 111 | ||
110 | void NetworkPackageManager :: selectLocalPackage( const QString &pkg ) | 112 | void NetworkPackageManager :: selectLocalPackage( const QString &pkg ) |
111 | { | 113 | { |
112 | // First select local server | 114 | // First select local server |
113 | for ( int i = 0 ; i < serversList->count() ; ++i ) | 115 | for ( int i = 0 ; i < serversList->count() ; ++i ) |
114 | { | 116 | { |
115 | if ( serversList->text( i ) == LOCAL_IPKGS ) | 117 | if ( serversList->text( i ) == LOCAL_IPKGS ) |
116 | { | 118 | { |
117 | serversList->setCurrentItem( i ); | 119 | serversList->setCurrentItem( i ); |
118 | break; | 120 | break; |
119 | } | 121 | } |
120 | } | 122 | } |
121 | serverSelected( 0 ); | 123 | serverSelected( 0 ); |
122 | 124 | ||
123 | // Now set the check box of the selected package | 125 | // Now set the check box of the selected package |
124 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 126 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
125 | item != 0 ; | 127 | item != 0 ; |
126 | item = (QCheckListItem *)item->nextSibling() ) | 128 | item = (QCheckListItem *)item->nextSibling() ) |
127 | { | 129 | { |
128 | if ( item->text().startsWith( pkg ) ) | 130 | if ( item->text().startsWith( pkg ) ) |
129 | { | 131 | { |
130 | item->setOn( true ); | 132 | item->setOn( true ); |
131 | break; | 133 | break; |
132 | } | 134 | } |
133 | } | 135 | } |
134 | } | 136 | } |
135 | 137 | ||
136 | 138 | ||
137 | void NetworkPackageManager :: initGui() | 139 | void NetworkPackageManager :: initGui() |
138 | { | 140 | { |
139 | QLabel *l = new QLabel( "Servers", this ); | 141 | QLabel *l = new QLabel( "Servers", this ); |
140 | serversList = new QComboBox( this ); | 142 | serversList = new QComboBox( this ); |
141 | packagesList = new QListView( this ); | 143 | packagesList = new QListView( this ); |
142 | update = new QPushButton( "Refresh List", this ); | 144 | update = new QPushButton( "Refresh List", this ); |
143 | download = new QPushButton( "Download", this ); | 145 | download = new QPushButton( "Download", this ); |
144 | upgrade = new QPushButton( "Upgrade", this ); | 146 | upgrade = new QPushButton( "Upgrade", this ); |
145 | apply = new QPushButton( "Apply", this ); | 147 | apply = new QPushButton( "Apply", this ); |
146 | 148 | ||
147 | QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1, "VBox" ); | 149 | QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1, "VBox" ); |
148 | QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1, "HBox1" ); | 150 | QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1, "HBox1" ); |
149 | hbox1->addWidget( l ); | 151 | hbox1->addWidget( l ); |
150 | hbox1->addWidget( serversList ); | 152 | hbox1->addWidget( serversList ); |
151 | 153 | ||
152 | QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1, "HBox1" ); | 154 | QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1, "HBox1" ); |
153 | QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1, "HBox1" ); | 155 | QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1, "HBox1" ); |
154 | 156 | ||
155 | 157 | ||
156 | if ( showJumpTo ) | 158 | if ( showJumpTo ) |
157 | { | 159 | { |
158 | char text[2]; | 160 | char text[2]; |
159 | text[1] = '\0'; | 161 | text[1] = '\0'; |
160 | for ( int i = 0 ; i < 26 ; ++i ) | 162 | for ( int i = 0 ; i < 26 ; ++i ) |
161 | { | 163 | { |
162 | text[0] = 'A' + i; | 164 | text[0] = 'A' + i; |
163 | LetterPushButton *b = new LetterPushButton( text, this ); | 165 | LetterPushButton *b = new LetterPushButton( text, this ); |
164 | connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); | 166 | connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); |
165 | if ( i < 13 ) | 167 | if ( i < 13 ) |
166 | hbox3->addWidget( b ); | 168 | hbox3->addWidget( b ); |
167 | else | 169 | else |
168 | hbox4->addWidget( b ); | 170 | hbox4->addWidget( b ); |
169 | } | 171 | } |
170 | } | 172 | } |
171 | 173 | ||
172 | vbox->addWidget( packagesList ); | 174 | vbox->addWidget( packagesList ); |
173 | packagesList->addColumn( "Packages" ); | 175 | packagesList->addColumn( "Packages" ); |
174 | 176 | ||
175 | QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1, "HBox2" ); | 177 | QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1, "HBox2" ); |
176 | hbox2->addWidget( update ); | 178 | hbox2->addWidget( update ); |
177 | hbox2->addWidget( download ); | 179 | hbox2->addWidget( download ); |
178 | hbox2->addWidget( upgrade ); | 180 | hbox2->addWidget( upgrade ); |
179 | hbox2->addWidget( apply ); | 181 | hbox2->addWidget( apply ); |
180 | } | 182 | } |
181 | 183 | ||
182 | void NetworkPackageManager :: setupConnections() | 184 | void NetworkPackageManager :: setupConnections() |
183 | { | 185 | { |
184 | connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int ))); | 186 | connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int ))); |
185 | connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) ); | 187 | connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) ); |
186 | connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) ); | 188 | connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) ); |
187 | connect( upgrade, SIGNAL( released()), this, SLOT(upgradePackages()) ); | 189 | connect( upgrade, SIGNAL( released()), this, SLOT(upgradePackages()) ); |
188 | connect( update, SIGNAL(released()), this, SLOT(updateServer()) ); | 190 | connect( update, SIGNAL(released()), this, SLOT(updateServer()) ); |
189 | } | 191 | } |
190 | 192 | ||
191 | void NetworkPackageManager :: showProgressDialog( char *initialText ) | 193 | void NetworkPackageManager :: showProgressDialog( char *initialText ) |
192 | { | 194 | { |
193 | if ( !progressDlg ) | 195 | if ( !progressDlg ) |
194 | progressDlg = new ProgressDlg( this, "Progress", false ); | 196 | progressDlg = new ProgressDlg( this, "Progress", false ); |
195 | progressDlg->setText( initialText ); | 197 | progressDlg->setText( initialText ); |
196 | progressDlg->show(); | 198 | progressDlg->show(); |
197 | } | 199 | } |
198 | 200 | ||
199 | 201 | ||
200 | void NetworkPackageManager :: serverSelected( int ) | 202 | void NetworkPackageManager :: serverSelected( int ) |
201 | { | 203 | { |
202 | packagesList->clear(); | 204 | packagesList->clear(); |
203 | 205 | ||
204 | // display packages | 206 | // display packages |
205 | QString serverName = serversList->currentText(); | 207 | QString serverName = serversList->currentText(); |
206 | currentlySelectedServer = serverName; | 208 | currentlySelectedServer = serverName; |
207 | 209 | ||
208 | #ifdef QWS | 210 | #ifdef QWS |
209 | // read download directory from config file | 211 | // read download directory from config file |
210 | Config cfg( "aqpkg" ); | 212 | Config cfg( "aqpkg" ); |
211 | cfg.setGroup( "settings" ); | 213 | cfg.setGroup( "settings" ); |
212 | cfg.writeEntry( "selectedServer", currentlySelectedServer ); | 214 | cfg.writeEntry( "selectedServer", currentlySelectedServer ); |
213 | #endif | 215 | #endif |
214 | 216 | ||
215 | Server *s = dataMgr->getServer( serverName ); | 217 | Server *s = dataMgr->getServer( serverName ); |
216 | // dataMgr->setActiveServer( serverName ); | 218 | // dataMgr->setActiveServer( serverName ); |
217 | 219 | ||
218 | vector<Package> &list = s->getPackageList(); | 220 | vector<Package> &list = s->getPackageList(); |
219 | vector<Package>::iterator it; | 221 | vector<Package>::iterator it; |
220 | for ( it = list.begin() ; it != list.end() ; ++it ) | 222 | for ( it = list.begin() ; it != list.end() ; ++it ) |
221 | { | 223 | { |
222 | QString text = ""; | 224 | QString text = ""; |
223 | 225 | ||
224 | // If the local server, only display installed packages | 226 | // If the local server, only display installed packages |
225 | if ( serverName == LOCAL_SERVER && !it->isInstalled() ) | 227 | if ( serverName == LOCAL_SERVER && !it->isInstalled() ) |
226 | continue; | 228 | continue; |
227 | 229 | ||
228 | text += it->getPackageName(); | 230 | text += it->getPackageName(); |
229 | if ( it->isInstalled() ) | 231 | if ( it->isInstalled() ) |
230 | { | 232 | { |
231 | text += " (installed)"; | 233 | text += " (installed)"; |
232 | 234 | ||
233 | // If a different version of package is available, postfix it with an * | 235 | // If a different version of package is available, postfix it with an * |
234 | if ( it->getVersion() != it->getInstalledVersion() ) | 236 | if ( it->getVersion() != it->getInstalledVersion() ) |
235 | text += "*"; | 237 | { |
238 | if ( compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1 ) | ||
239 | text += "*"; | ||
240 | } | ||
236 | } | 241 | } |
237 | 242 | ||
238 | QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox ); | 243 | QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox ); |
239 | 244 | ||
240 | if ( it->isInstalled() ) | 245 | if ( it->isInstalled() ) |
241 | { | 246 | { |
242 | QString destName = ""; | 247 | QString destName = ""; |
243 | if ( it->getLocalPackage() ) | 248 | if ( it->getLocalPackage() ) |
244 | { | 249 | { |
245 | if ( it->getLocalPackage()->getInstalledTo() ) | 250 | if ( it->getLocalPackage()->getInstalledTo() ) |
246 | destName = it->getLocalPackage()->getInstalledTo()->getDestinationName(); | 251 | destName = it->getLocalPackage()->getInstalledTo()->getDestinationName(); |
247 | } | 252 | } |
248 | else | 253 | else |
249 | { | 254 | { |
250 | if ( it->getInstalledTo() ) | 255 | if ( it->getInstalledTo() ) |
251 | destName = it->getInstalledTo()->getDestinationName(); | 256 | destName = it->getInstalledTo()->getDestinationName(); |
252 | } | 257 | } |
253 | if ( destName != "" ) | 258 | if ( destName != "" ) |
254 | new QCheckListItem( item, QString( "Installed To - " ) + destName ); | 259 | new QCheckListItem( item, QString( "Installed To - " ) + destName ); |
255 | } | 260 | } |
256 | 261 | ||
257 | if ( !it->isPackageStoredLocally() ) | 262 | if ( !it->isPackageStoredLocally() ) |
258 | new QCheckListItem( item, QString( "Description - " ) + it->getDescription() ); | 263 | new QCheckListItem( item, QString( "Description - " ) + it->getDescription() ); |
259 | else | 264 | else |
260 | new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() ); | 265 | new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() ); |
261 | 266 | ||
262 | new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() ); | 267 | new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() ); |
263 | if ( it->getLocalPackage() ) | 268 | if ( it->getLocalPackage() ) |
264 | { | 269 | { |
265 | if ( it->isInstalled() ) | 270 | if ( it->isInstalled() ) |
266 | new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() ); | 271 | new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() ); |
267 | } | 272 | } |
268 | packagesList->insertItem( item ); | 273 | packagesList->insertItem( item ); |
269 | } | 274 | } |
270 | 275 | ||
271 | // If the local server or the local ipkgs server disable the download button | 276 | // If the local server or the local ipkgs server disable the download button |
272 | if ( serverName == LOCAL_SERVER ) | 277 | if ( serverName == LOCAL_SERVER ) |
273 | { | 278 | { |
274 | upgrade->setEnabled( false ); | 279 | upgrade->setEnabled( false ); |
275 | download->setText( "Download" ); | 280 | download->setText( "Download" ); |
276 | download->setEnabled( false ); | 281 | download->setEnabled( false ); |
277 | } | 282 | } |
278 | else if ( serverName == LOCAL_IPKGS ) | 283 | else if ( serverName == LOCAL_IPKGS ) |
279 | { | 284 | { |
280 | upgrade->setEnabled( false ); | 285 | upgrade->setEnabled( false ); |
281 | download->setEnabled( true ); | 286 | download->setEnabled( true ); |
282 | download->setText( "Remove" ); | 287 | download->setText( "Remove" ); |
283 | } | 288 | } |
284 | else | 289 | else |
285 | { | 290 | { |
286 | upgrade->setEnabled( true ); | 291 | upgrade->setEnabled( true ); |
287 | download->setEnabled( true ); | 292 | download->setEnabled( true ); |
288 | download->setText( "Download" ); | 293 | download->setText( "Download" ); |
289 | } | 294 | } |
290 | } | 295 | } |
291 | 296 | ||
292 | void NetworkPackageManager :: updateServer() | 297 | void NetworkPackageManager :: updateServer() |
293 | { | 298 | { |
294 | QString serverName = serversList->currentText(); | 299 | QString serverName = serversList->currentText(); |
295 | 300 | ||
296 | // Update the current server | 301 | // Update the current server |
297 | // Display dialog | 302 | // Display dialog |
298 | // ProgressDlg *progDlg = new ProgressDlg( this ); | 303 | // ProgressDlg *progDlg = new ProgressDlg( this ); |
299 | // QString status = "Updating package lists..."; | 304 | // QString status = "Updating package lists..."; |
300 | // progDlg->show(); | 305 | // progDlg->show(); |
301 | // progDlg->setText( status ); | 306 | // progDlg->setText( status ); |
302 | 307 | ||
303 | // Disable buttons to stop silly people clicking lots on them :) | 308 | // Disable buttons to stop silly people clicking lots on them :) |
304 | 309 | ||
305 | // First, write out ipkg_conf file so that ipkg can use it | 310 | // First, write out ipkg_conf file so that ipkg can use it |
306 | dataMgr->writeOutIpkgConf(); | 311 | dataMgr->writeOutIpkgConf(); |
307 | 312 | ||
308 | Ipkg ipkg; | 313 | Ipkg ipkg; |
309 | ipkg.setOption( "update" ); | 314 | ipkg.setOption( "update" ); |
310 | 315 | ||
311 | InstallDlgImpl dlg( &ipkg, "Refreshing server package lists", this, "Upgrade", true ); | 316 | InstallDlgImpl dlg( &ipkg, "Refreshing server package lists", this, "Upgrade", true ); |
312 | dlg.showDlg(); | 317 | dlg.showDlg(); |
313 | 318 | ||
314 | // Reload data | 319 | // Reload data |
315 | dataMgr->reloadServerData( serversList->currentText() ); | 320 | dataMgr->reloadServerData( serversList->currentText() ); |
316 | serverSelected(-1); | 321 | serverSelected(-1); |
317 | // delete progDlg; | 322 | // delete progDlg; |
318 | } | 323 | } |
319 | 324 | ||
320 | void NetworkPackageManager :: upgradePackages() | 325 | void NetworkPackageManager :: upgradePackages() |
321 | { | 326 | { |
322 | // We're gonna do an upgrade of all packages | 327 | // We're gonna do an upgrade of all packages |
323 | // First warn user that this isn't recommended | 328 | // First warn user that this isn't recommended |
324 | QString text = "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n"; | 329 | QString text = "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n"; |
325 | QMessageBox warn("Warning", text, QMessageBox::Warning, | 330 | QMessageBox warn("Warning", text, QMessageBox::Warning, |
326 | QMessageBox::Yes, | 331 | QMessageBox::Yes, |
327 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , | 332 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , |
328 | 0, this ); | 333 | 0, this ); |
329 | warn.adjustSize(); | 334 | warn.adjustSize(); |
330 | 335 | ||
331 | if ( warn.exec() == QMessageBox::Yes ) | 336 | if ( warn.exec() == QMessageBox::Yes ) |
332 | { | 337 | { |
333 | // First, write out ipkg_conf file so that ipkg can use it | 338 | // First, write out ipkg_conf file so that ipkg can use it |
334 | dataMgr->writeOutIpkgConf(); | 339 | dataMgr->writeOutIpkgConf(); |
335 | 340 | ||
336 | // Now run upgrade | 341 | // Now run upgrade |
337 | Ipkg ipkg; | 342 | Ipkg ipkg; |
338 | ipkg.setOption( "upgrade" ); | 343 | ipkg.setOption( "upgrade" ); |
339 | 344 | ||
340 | InstallDlgImpl dlg( &ipkg, "Upgrading installed packages", this, "Upgrade", true ); | 345 | InstallDlgImpl dlg( &ipkg, "Upgrading installed packages", this, "Upgrade", true ); |
341 | dlg.showDlg(); | 346 | dlg.showDlg(); |
342 | 347 | ||
343 | // Reload data | 348 | // Reload data |
344 | dataMgr->reloadServerData( LOCAL_SERVER ); | 349 | dataMgr->reloadServerData( LOCAL_SERVER ); |
345 | 350 | ||
346 | dataMgr->reloadServerData( serversList->currentText() ); | 351 | dataMgr->reloadServerData( serversList->currentText() ); |
347 | serverSelected(-1); | 352 | serverSelected(-1); |
348 | } | 353 | } |
349 | } | 354 | } |
350 | 355 | ||
351 | 356 | ||
352 | void NetworkPackageManager :: downloadPackage() | 357 | void NetworkPackageManager :: downloadPackage() |
353 | { | 358 | { |
354 | if ( download->text() == "Download" ) | 359 | if ( download->text() == "Download" ) |
355 | { | 360 | { |
356 | // First, write out ipkg_conf file so that ipkg can use it | 361 | // First, write out ipkg_conf file so that ipkg can use it |
357 | dataMgr->writeOutIpkgConf(); | 362 | dataMgr->writeOutIpkgConf(); |
358 | 363 | ||
359 | // Display dialog to user asking where to download the files to | 364 | // Display dialog to user asking where to download the files to |
360 | bool ok = FALSE; | 365 | bool ok = FALSE; |
361 | QString dir = ""; | 366 | QString dir = ""; |
362 | #ifdef QWS | 367 | #ifdef QWS |
363 | // read download directory from config file | 368 | // read download directory from config file |
@@ -408,203 +413,235 @@ void NetworkPackageManager :: downloadPackage() | |||
408 | } | 413 | } |
409 | } | 414 | } |
410 | else if ( download->text() == "Remove" ) | 415 | else if ( download->text() == "Remove" ) |
411 | { | 416 | { |
412 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 417 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
413 | item != 0 ; | 418 | item != 0 ; |
414 | item = (QCheckListItem *)item->nextSibling() ) | 419 | item = (QCheckListItem *)item->nextSibling() ) |
415 | { | 420 | { |
416 | if ( item->isOn() ) | 421 | if ( item->isOn() ) |
417 | { | 422 | { |
418 | QString name = item->text(); | 423 | QString name = item->text(); |
419 | int pos = name.find( "*" ); | 424 | int pos = name.find( "*" ); |
420 | name.truncate( pos ); | 425 | name.truncate( pos ); |
421 | 426 | ||
422 | // if (there is a (installed), remove it | 427 | // if (there is a (installed), remove it |
423 | pos = name.find( "(installed)" ); | 428 | pos = name.find( "(installed)" ); |
424 | if ( pos > 0 ) | 429 | if ( pos > 0 ) |
425 | name.truncate( pos - 1 ); | 430 | name.truncate( pos - 1 ); |
426 | 431 | ||
427 | Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name ); | 432 | Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name ); |
428 | QFile f( p->getFilename() ); | 433 | QFile f( p->getFilename() ); |
429 | f.remove(); | 434 | f.remove(); |
430 | } | 435 | } |
431 | } | 436 | } |
432 | } | 437 | } |
433 | 438 | ||
434 | dataMgr->reloadServerData( LOCAL_IPKGS ); | 439 | dataMgr->reloadServerData( LOCAL_IPKGS ); |
435 | serverSelected( -1 ); | 440 | serverSelected( -1 ); |
436 | } | 441 | } |
437 | 442 | ||
438 | 443 | ||
439 | void NetworkPackageManager :: applyChanges() | 444 | void NetworkPackageManager :: applyChanges() |
440 | { | 445 | { |
441 | stickyOption = ""; | 446 | stickyOption = ""; |
442 | 447 | ||
443 | // First, write out ipkg_conf file so that ipkg can use it | 448 | // First, write out ipkg_conf file so that ipkg can use it |
444 | dataMgr->writeOutIpkgConf(); | 449 | dataMgr->writeOutIpkgConf(); |
445 | 450 | ||
446 | // Now for each selected item | 451 | // Now for each selected item |
447 | // deal with it | 452 | // deal with it |
448 | 453 | ||
449 | vector<InstallData> workingPackages; | 454 | vector<InstallData> workingPackages; |
450 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 455 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
451 | item != 0 ; | 456 | item != 0 ; |
452 | item = (QCheckListItem *)item->nextSibling() ) | 457 | item = (QCheckListItem *)item->nextSibling() ) |
453 | { | 458 | { |
454 | if ( item->isOn() ) | 459 | if ( item->isOn() ) |
455 | { | 460 | { |
456 | InstallData data = dealWithItem( item ); | 461 | InstallData data = dealWithItem( item ); |
457 | workingPackages.push_back( data ); | 462 | workingPackages.push_back( data ); |
458 | } | 463 | } |
459 | } | 464 | } |
460 | 465 | ||
461 | if ( workingPackages.size() == 0 ) | 466 | if ( workingPackages.size() == 0 ) |
462 | { | 467 | { |
463 | // Nothing to do | 468 | // Nothing to do |
464 | QMessageBox::information( this, "Nothing to do", | 469 | QMessageBox::information( this, "Nothing to do", |
465 | "No packages selected", "OK" ); | 470 | "No packages selected", "OK" ); |
466 | 471 | ||
467 | return; | 472 | return; |
468 | } | 473 | } |
469 | 474 | ||
470 | // do the stuff | 475 | // do the stuff |
471 | InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true ); | 476 | InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true ); |
472 | dlg.showDlg(); | 477 | dlg.showDlg(); |
473 | 478 | ||
474 | // Reload data | 479 | // Reload data |
475 | dataMgr->reloadServerData( LOCAL_SERVER ); | 480 | dataMgr->reloadServerData( LOCAL_SERVER ); |
476 | 481 | ||
477 | dataMgr->reloadServerData( serversList->currentText() ); | 482 | dataMgr->reloadServerData( serversList->currentText() ); |
478 | serverSelected(-1); | 483 | serverSelected(-1); |
479 | 484 | ||
480 | #ifdef QWS | 485 | #ifdef QWS |
481 | // Finally let the main system update itself | 486 | // Finally let the main system update itself |
482 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 487 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
483 | QString lf = QString::null; | 488 | QString lf = QString::null; |
484 | e << lf; | 489 | e << lf; |
485 | #endif | 490 | #endif |
486 | } | 491 | } |
487 | 492 | ||
488 | // decide what to do - either remove, upgrade or install | 493 | // decide what to do - either remove, upgrade or install |
489 | // Current rules: | 494 | // Current rules: |
490 | // If not installed - install | 495 | // If not installed - install |
491 | // If installed and different version available - upgrade | 496 | // If installed and different version available - upgrade |
492 | // If installed and version up to date - remove | 497 | // If installed and version up to date - remove |
493 | InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item ) | 498 | InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item ) |
494 | { | 499 | { |
495 | QString name = item->text(); | 500 | QString name = item->text(); |
496 | int pos = name.find( "*" ); | 501 | int pos = name.find( "*" ); |
497 | name.truncate( pos ); | 502 | name.truncate( pos ); |
498 | 503 | ||
499 | // if (there is a (installed), remove it | 504 | // if (there is a (installed), remove it |
500 | pos = name.find( "(installed)" ); | 505 | pos = name.find( "(installed)" ); |
501 | if ( pos > 0 ) | 506 | if ( pos > 0 ) |
502 | name.truncate( pos - 1 ); | 507 | name.truncate( pos - 1 ); |
503 | 508 | ||
504 | // Get package | 509 | // Get package |
505 | Server *s = dataMgr->getServer( serversList->currentText() ); | 510 | Server *s = dataMgr->getServer( serversList->currentText() ); |
506 | Package *p = s->getPackage( name ); | 511 | Package *p = s->getPackage( name ); |
507 | 512 | ||
508 | // If the package has a filename then it is a local file | 513 | // If the package has a filename then it is a local file |
509 | if ( p->isPackageStoredLocally() ) | 514 | if ( p->isPackageStoredLocally() ) |
510 | name = p->getFilename(); | 515 | name = p->getFilename(); |
511 | QString option; | 516 | QString option; |
512 | QString dest = "root"; | 517 | QString dest = "root"; |
513 | if ( !p->isInstalled() ) | 518 | if ( !p->isInstalled() ) |
514 | { | 519 | { |
515 | InstallData item; | 520 | InstallData item; |
516 | item.option = "I"; | 521 | item.option = "I"; |
517 | item.packageName = name; | 522 | item.packageName = name; |
518 | return item; | 523 | return item; |
519 | } | 524 | } |
520 | else | 525 | else |
521 | { | 526 | { |
522 | InstallData item; | 527 | InstallData item; |
523 | item.option = "D"; | 528 | item.option = "D"; |
524 | item.packageName = p->getInstalledPackageName(); | 529 | item.packageName = p->getInstalledPackageName(); |
525 | if ( p->getInstalledTo() ) | 530 | if ( p->getInstalledTo() ) |
526 | { | 531 | { |
527 | item.destination = p->getInstalledTo(); | 532 | item.destination = p->getInstalledTo(); |
528 | cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl; | 533 | cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl; |
529 | cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl; | 534 | cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl; |
530 | } | 535 | } |
531 | else | 536 | else |
532 | { | 537 | { |
533 | item.destination = p->getLocalPackage()->getInstalledTo(); | 538 | item.destination = p->getLocalPackage()->getInstalledTo(); |
534 | } | 539 | } |
535 | 540 | ||
536 | // Sticky option not implemented yet, but will eventually allow | 541 | // Now see if version is newer or not |
537 | // the user to say something like 'remove all' | 542 | int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); |
538 | if ( stickyOption == "" ) | 543 | if ( val == -2 ) |
539 | { | 544 | { |
540 | QString msgtext; | 545 | // Error - should handle |
541 | msgtext.sprintf( "Do you wish to remove or reinstall\n%s?", (const char *)name ); | 546 | } |
542 | switch( QMessageBox::information( this, "Remove or ReInstall", | 547 | else if ( val == -1 ) |
543 | msgtext, "Remove", "ReInstall" ) ) | 548 | { |
544 | { | 549 | // Version available is older - remove only |
545 | case 0: // Try again or Enter | 550 | item.option = "R"; |
546 | item.option = "D"; | ||
547 | break; | ||
548 | case 1: // Quit or Escape | ||
549 | item.option = "U"; | ||
550 | break; | ||
551 | } | ||
552 | } | 551 | } |
553 | else | 552 | else |
554 | { | 553 | { |
555 | // item.option = stickyOption; | 554 | QString caption; |
555 | QString text; | ||
556 | QString secondButton; | ||
557 | QString secondOption; | ||
558 | if ( val == 0 ) | ||
559 | { | ||
560 | // Version available is the same - option to remove or reinstall | ||
561 | caption = "Do you wish to remove or reinstall\n%s?"; | ||
562 | text = "Remove or ReInstall"; | ||
563 | secondButton = "ReInstall"; | ||
564 | secondOption = "R"; | ||
565 | } | ||
566 | else if ( val == 1 ) | ||
567 | { | ||
568 | // Version available is newer - option to remove or upgrade | ||
569 | caption = "Do you wish to remove or upgrade\n%s?"; | ||
570 | text = "Remove or Upgrade"; | ||
571 | secondButton = "Upgrade"; | ||
572 | secondOption = "U"; | ||
573 | } | ||
574 | |||
575 | // Sticky option not implemented yet, but will eventually allow | ||
576 | // the user to say something like 'remove all' | ||
577 | if ( stickyOption == "" ) | ||
578 | { | ||
579 | QString msgtext; | ||
580 | msgtext.sprintf( caption, (const char *)name ); | ||
581 | switch( QMessageBox::information( this, text, | ||
582 | msgtext, "Remove", secondButton ) ) | ||
583 | { | ||
584 | case 0: // Try again or Enter | ||
585 | item.option = "D"; | ||
586 | break; | ||
587 | case 1: // Quit or Escape | ||
588 | item.option = secondOption; | ||
589 | break; | ||
590 | } | ||
591 | } | ||
592 | else | ||
593 | { | ||
594 | // item.option = stickyOption; | ||
595 | } | ||
556 | } | 596 | } |
597 | |||
557 | 598 | ||
558 | // Check if we are reinstalling the same version | 599 | // Check if we are reinstalling the same version |
559 | if ( p->getVersion() != p->getInstalledVersion() ) | 600 | if ( item.option != "R" ) |
560 | item.recreateLinks = true; | 601 | item.recreateLinks = true; |
561 | else | 602 | else |
562 | { | ||
563 | if ( item.option == "U" ) | ||
564 | item.option = "R"; | ||
565 | item.recreateLinks = false; | 603 | item.recreateLinks = false; |
566 | } | ||
567 | 604 | ||
568 | // User hit cancel (on dlg - assume remove) | 605 | // User hit cancel (on dlg - assume remove) |
569 | return item; | 606 | return item; |
570 | } | 607 | } |
571 | } | 608 | } |
572 | 609 | ||
573 | void NetworkPackageManager :: displayText( const QString &t ) | 610 | void NetworkPackageManager :: displayText( const QString &t ) |
574 | { | 611 | { |
575 | cout << t << endl; | 612 | cout << t << endl; |
576 | } | 613 | } |
577 | 614 | ||
578 | 615 | ||
579 | void NetworkPackageManager :: letterPushed( QString t ) | 616 | void NetworkPackageManager :: letterPushed( QString t ) |
580 | { | 617 | { |
581 | QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); | 618 | QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); |
582 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); | 619 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); |
583 | if ( packagesList->firstChild() == 0 ) | 620 | if ( packagesList->firstChild() == 0 ) |
584 | return; | 621 | return; |
585 | 622 | ||
586 | QCheckListItem *item; | 623 | QCheckListItem *item; |
587 | if ( start == 0 ) | 624 | if ( start == 0 ) |
588 | { | 625 | { |
589 | item = (QCheckListItem *)packagesList->firstChild(); | 626 | item = (QCheckListItem *)packagesList->firstChild(); |
590 | start = top; | 627 | start = top; |
591 | } | 628 | } |
592 | else | 629 | else |
593 | item = (QCheckListItem *)start->nextSibling(); | 630 | item = (QCheckListItem *)start->nextSibling(); |
594 | 631 | ||
595 | if ( item == 0 ) | 632 | if ( item == 0 ) |
596 | item = (QCheckListItem *)packagesList->firstChild(); | 633 | item = (QCheckListItem *)packagesList->firstChild(); |
597 | do | 634 | do |
598 | { | 635 | { |
599 | if ( item->text().lower().startsWith( t.lower() ) ) | 636 | if ( item->text().lower().startsWith( t.lower() ) ) |
600 | { | 637 | { |
601 | packagesList->setSelected( item, true ); | 638 | packagesList->setSelected( item, true ); |
602 | packagesList->ensureItemVisible( item ); | 639 | packagesList->ensureItemVisible( item ); |
603 | break; | 640 | break; |
604 | } | 641 | } |
605 | 642 | ||
606 | item = (QCheckListItem *)item->nextSibling(); | 643 | item = (QCheckListItem *)item->nextSibling(); |
607 | if ( !item ) | 644 | if ( !item ) |
608 | item = (QCheckListItem *)packagesList->firstChild(); | 645 | item = (QCheckListItem *)packagesList->firstChild(); |
609 | } while ( item != start); | 646 | } while ( item != start); |
610 | } | 647 | } |
diff --git a/noncore/settings/aqpkg/version.cpp b/noncore/settings/aqpkg/version.cpp new file mode 100644 index 0000000..e836da1 --- a/dev/null +++ b/noncore/settings/aqpkg/version.cpp | |||
@@ -0,0 +1,214 @@ | |||
1 | /* | ||
2 | * libdpkg - Debian packaging suite library routines | ||
3 | * vercmp.c - comparison of version numbers | ||
4 | * | ||
5 | * Copyright (C) 1995 Ian Jackson <iwj10@cus.cam.ac.uk> | ||
6 | * | ||
7 | * This is free software; you can redistribute it and/or modify | ||
8 | * it under the terms of the GNU General Public License as | ||
9 | * published by the Free Software Foundation; either version 2, | ||
10 | * or (at your option) any later version. | ||
11 | * | ||
12 | * This is distributed in the hope that it will be useful, but | ||
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
15 | * GNU General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public | ||
18 | * License along with dpkg; if not, write to the Free Software | ||
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | ||
20 | */ | ||
21 | #include <stdio.h> | ||
22 | #include <stdlib.h> | ||
23 | #include <ctype.h> | ||
24 | #include <string.h> | ||
25 | |||
26 | # define _(Text) Text | ||
27 | |||
28 | class versionrevision | ||
29 | { | ||
30 | public: | ||
31 | versionrevision() | ||
32 | { | ||
33 | version = 0; | ||
34 | } | ||
35 | |||
36 | ~versionrevision() | ||
37 | { | ||
38 | if ( version ) | ||
39 | delete version; | ||
40 | } | ||
41 | |||
42 | void setVersion( const char *str ) | ||
43 | { | ||
44 | version = new char[(strlen(str)+1)]; | ||
45 | strcpy( version, str ); | ||
46 | } | ||
47 | |||
48 | unsigned long epoch; | ||
49 | char *version; | ||
50 | const char *revision; | ||
51 | const char *familiar_revision; | ||
52 | }; | ||
53 | |||
54 | static int verrevcmp(const char *val, const char *ref) | ||
55 | { | ||
56 | int vc, rc; | ||
57 | long vl, rl; | ||
58 | const char *vp, *rp; | ||
59 | |||
60 | if (!val) val= ""; | ||
61 | if (!ref) ref= ""; | ||
62 | for (;;) { | ||
63 | vp= val; while (*vp && !isdigit(*vp)) vp++; | ||
64 | rp= ref; while (*rp && !isdigit(*rp)) rp++; | ||
65 | for (;;) { | ||
66 | vc= val == vp ? 0 : *val++; | ||
67 | rc= ref == rp ? 0 : *ref++; | ||
68 | if (!rc && !vc) break; | ||
69 | if (vc && !isalpha(vc)) vc += 256; /* assumes ASCII character set */ | ||
70 | if (rc && !isalpha(rc)) rc += 256; | ||
71 | if (vc != rc) return vc - rc; | ||
72 | } | ||
73 | val= vp; | ||
74 | ref= rp; | ||
75 | vl=0; if (isdigit(*vp)) vl= strtol(val,(char**)&val,10); | ||
76 | rl=0; if (isdigit(*rp)) rl= strtol(ref,(char**)&ref,10); | ||
77 | if (vl != rl) return vl - rl; | ||
78 | if (!*val && !*ref) return 0; | ||
79 | if (!*val) return -1; | ||
80 | if (!*ref) return +1; | ||
81 | } | ||
82 | } | ||
83 | |||
84 | int versioncompare(const struct versionrevision *version, | ||
85 | const struct versionrevision *refversion) | ||
86 | { | ||
87 | int r; | ||
88 | |||
89 | if (version->epoch > refversion->epoch) return 1; | ||
90 | if (version->epoch < refversion->epoch) return -1; | ||
91 | r= verrevcmp(version->version,refversion->version); if (r) return r; | ||
92 | r= verrevcmp(version->revision,refversion->revision); if (r) return r; | ||
93 | return verrevcmp(version->familiar_revision,refversion->familiar_revision); | ||
94 | } | ||
95 | |||
96 | int versionsatisfied3(const struct versionrevision *it, | ||
97 | const struct versionrevision *ref, | ||
98 | const char *op) | ||
99 | { | ||
100 | int r; | ||
101 | r= versioncompare(it,ref); | ||
102 | if (strcmp(op, "<=") == 0 || strcmp(op, "<") == 0) | ||
103 | return r <= 0; | ||
104 | if (strcmp(op, ">=") == 0 || strcmp(op, ">") == 0) | ||
105 | return r >= 0; | ||
106 | if (strcmp(op, "<<") == 0) | ||
107 | return r < 0; | ||
108 | if (strcmp(op, ">>") == 0) | ||
109 | return r > 0; | ||
110 | if (strcmp(op, "=") == 0) | ||
111 | return r == 0; | ||
112 | fprintf(stderr, "unknown operator: %s", op); | ||
113 | |||
114 | exit(1); | ||
115 | } | ||
116 | |||
117 | const char *parseversion(struct versionrevision *rversion, const char *string) | ||
118 | { | ||
119 | char *hyphen, *colon, *eepochcolon; | ||
120 | unsigned long epoch; | ||
121 | |||
122 | if (!*string) return _("version string is empty"); | ||
123 | |||
124 | colon= strchr(string,':'); | ||
125 | if (colon) { | ||
126 | epoch= strtoul(string,&eepochcolon,10); | ||
127 | if (colon != eepochcolon) return _("epoch in version is not number"); | ||
128 | if (!*++colon) return _("nothing after colon in version number"); | ||
129 | string= colon; | ||
130 | rversion->epoch= epoch; | ||
131 | } else { | ||
132 | rversion->epoch= 0; | ||
133 | } | ||
134 | |||
135 | rversion->revision = ""; | ||
136 | rversion->familiar_revision = ""; | ||
137 | |||
138 | rversion->setVersion( string ); | ||
139 | hyphen= strrchr(rversion->version,'-'); | ||
140 | if (hyphen) { | ||
141 | *hyphen++= 0; | ||
142 | if (strncmp("fam", hyphen, 3) == 0) { | ||
143 | rversion->familiar_revision=hyphen+3; | ||
144 | hyphen= strrchr(rversion->version,'-'); | ||
145 | if (hyphen) { | ||
146 | *hyphen++= 0; | ||
147 | rversion->revision = hyphen; | ||
148 | } | ||
149 | } else { | ||
150 | rversion->revision = hyphen; | ||
151 | } | ||
152 | } | ||
153 | /* | ||
154 | fprintf(stderr,"Parsed version: %lu, %s, %s, %s\n", | ||
155 | rversion->epoch, | ||
156 | rversion->version, | ||
157 | rversion->revision, | ||
158 | rversion->familiar_revision); | ||
159 | */ | ||
160 | return 0; | ||
161 | } | ||
162 | |||
163 | int compareVersions( const char *v1, const char *v2 ) | ||
164 | { | ||
165 | const char *err; | ||
166 | versionrevision ver, ref; | ||
167 | |||
168 | err = parseversion(&ref, v1); | ||
169 | if (err) { | ||
170 | fprintf(stderr, "Invalid version `%s': %s\n", v2, err); | ||
171 | return -2; | ||
172 | } | ||
173 | |||
174 | err = parseversion(&ver, v2); | ||
175 | if (err) { | ||
176 | fprintf(stderr, "Invalid version `%s': %s\n", v1, err); | ||
177 | return -2; | ||
178 | } | ||
179 | |||
180 | if ( versionsatisfied3( &ver, &ref, "=" ) ) | ||
181 | return 0; | ||
182 | else if ( versionsatisfied3( &ver, &ref, "<" ) ) | ||
183 | return -1; | ||
184 | else | ||
185 | return 1; | ||
186 | } | ||
187 | |||
188 | /* | ||
189 | int main(int argc, char *argv[]) | ||
190 | { | ||
191 | const char *err; | ||
192 | versionrevision ver, ref; | ||
193 | |||
194 | if (argc < 4) { | ||
195 | fprintf(stderr, "usage: %s: version op refversion\n", argv[0]); | ||
196 | return 2; | ||
197 | } | ||
198 | |||
199 | err = parseversion(&ver, argv[1]); | ||
200 | if (err) { | ||
201 | fprintf(stderr, "Invalid version `%s': %s\n", argv[1], err); | ||
202 | return 2; | ||
203 | } | ||
204 | |||
205 | err = parseversion(&ref, argv[3]); | ||
206 | if (err) { | ||
207 | fprintf(stderr, "Invalid version `%s': %s\n", argv[3], err); | ||
208 | return 2; | ||
209 | } | ||
210 | |||
211 | printf( "Result: %d\n", versionsatisfied3(&ver, &ref, argv[2]) ); | ||
212 | } | ||
213 | |||
214 | */ | ||