-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp index 91a318c..ff8f182 100644 --- a/noncore/settings/aqpkg/networkpkgmgr.cpp +++ b/noncore/settings/aqpkg/networkpkgmgr.cpp | |||
@@ -1,395 +1,396 @@ | |||
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 | 25 | ||
25 | #ifdef QWS | 26 | #ifdef QWS |
26 | #include <qpe/qpeapplication.h> | 27 | #include <qpe/qpeapplication.h> |
27 | #include <qpe/qcopenvelope_qws.h> | 28 | #include <qpe/qcopenvelope_qws.h> |
28 | #include <qpe/config.h> | 29 | #include <qpe/config.h> |
29 | #else | 30 | #else |
30 | #include <qapplication.h> | 31 | #include <qapplication.h> |
31 | #endif | 32 | #endif |
32 | #include <qlabel.h> | 33 | #include <qlabel.h> |
33 | #include <qfile.h> | 34 | #include <qfile.h> |
34 | 35 | ||
35 | #include "datamgr.h" | 36 | #include "datamgr.h" |
36 | #include "networkpkgmgr.h" | 37 | #include "networkpkgmgr.h" |
37 | #include "installdlgimpl.h" | 38 | #include "installdlgimpl.h" |
38 | #include "ipkg.h" | 39 | #include "ipkg.h" |
39 | #include "inputdlg.h" | 40 | #include "inputdlg.h" |
40 | 41 | ||
41 | #include "global.h" | 42 | #include "global.h" |
42 | 43 | ||
43 | NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name) | 44 | NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name) |
44 | : QWidget(parent, name) | 45 | : QWidget(parent, name) |
45 | { | 46 | { |
46 | dataMgr = dataManager; | 47 | dataMgr = dataManager; |
47 | 48 | ||
48 | initGui(); | 49 | initGui(); |
49 | setupConnections(); | 50 | setupConnections(); |
50 | 51 | ||
51 | progressDlg = 0; | 52 | progressDlg = 0; |
52 | timerId = startTimer( 100 ); | 53 | timerId = startTimer( 100 ); |
53 | } | 54 | } |
54 | 55 | ||
55 | NetworkPackageManager::~NetworkPackageManager() | 56 | NetworkPackageManager::~NetworkPackageManager() |
56 | { | 57 | { |
57 | } | 58 | } |
58 | 59 | ||
59 | void NetworkPackageManager :: timerEvent ( QTimerEvent * ) | 60 | void NetworkPackageManager :: timerEvent ( QTimerEvent * ) |
60 | { | 61 | { |
61 | killTimer( timerId ); | 62 | killTimer( timerId ); |
62 | 63 | ||
63 | // showProgressDialog(); | 64 | // showProgressDialog(); |
64 | // Add server names to listbox | 65 | // Add server names to listbox |
65 | updateData(); | 66 | updateData(); |
66 | 67 | ||
67 | // progressDlg->hide(); | 68 | // progressDlg->hide(); |
68 | } | 69 | } |
69 | 70 | ||
70 | void NetworkPackageManager :: updateData() | 71 | void NetworkPackageManager :: updateData() |
71 | { | 72 | { |
72 | serversList->clear(); | 73 | serversList->clear(); |
73 | packagesList->clear(); | 74 | packagesList->clear(); |
74 | 75 | ||
75 | vector<Server>::iterator it; | 76 | vector<Server>::iterator it; |
76 | int activeItem = -1; | 77 | int activeItem = -1; |
77 | int i; | 78 | int i; |
78 | for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i ) | 79 | for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i ) |
79 | { | 80 | { |
80 | serversList->insertItem( it->getServerName() ); | 81 | serversList->insertItem( it->getServerName() ); |
81 | if ( it->getServerName() == dataMgr->getActiveServer() ) | 82 | if ( it->getServerName() == dataMgr->getActiveServer() ) |
82 | activeItem = i; | 83 | activeItem = i; |
83 | } | 84 | } |
84 | 85 | ||
85 | // set selected server to be active server | 86 | // set selected server to be active server |
86 | if ( activeItem != -1 ) | 87 | if ( activeItem != -1 ) |
87 | serversList->setCurrentItem( activeItem ); | 88 | serversList->setCurrentItem( activeItem ); |
88 | serverSelected( 0 ); | 89 | serverSelected( 0 ); |
89 | } | 90 | } |
90 | 91 | ||
91 | 92 | ||
92 | void NetworkPackageManager :: initGui() | 93 | void NetworkPackageManager :: initGui() |
93 | { | 94 | { |
94 | QLabel *l = new QLabel( "Servers", this ); | 95 | QLabel *l = new QLabel( "Servers", this ); |
95 | serversList = new QComboBox( this ); | 96 | serversList = new QComboBox( this ); |
96 | packagesList = new QListView( this ); | 97 | packagesList = new QListView( this ); |
97 | update = new QPushButton( "Refresh List", this ); | 98 | update = new QPushButton( "Refresh List", this ); |
98 | download = new QPushButton( "Download", this ); | 99 | download = new QPushButton( "Download", this ); |
99 | apply = new QPushButton( "Apply", this ); | 100 | apply = new QPushButton( "Apply", this ); |
100 | 101 | ||
101 | QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1, "VBox" ); | 102 | QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1, "VBox" ); |
102 | QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1, "HBox1" ); | 103 | QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1, "HBox1" ); |
103 | hbox1->addWidget( l ); | 104 | hbox1->addWidget( l ); |
104 | hbox1->addWidget( serversList ); | 105 | hbox1->addWidget( serversList ); |
105 | 106 | ||
106 | vbox->addWidget( packagesList ); | 107 | vbox->addWidget( packagesList ); |
107 | packagesList->addColumn( "Packages" ); | 108 | packagesList->addColumn( "Packages" ); |
108 | 109 | ||
109 | QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1, "HBox2" ); | 110 | QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1, "HBox2" ); |
110 | hbox2->addWidget( update ); | 111 | hbox2->addWidget( update ); |
111 | hbox2->addWidget( download ); | 112 | hbox2->addWidget( download ); |
112 | hbox2->addWidget( apply ); | 113 | hbox2->addWidget( apply ); |
113 | } | 114 | } |
114 | 115 | ||
115 | void NetworkPackageManager :: setupConnections() | 116 | void NetworkPackageManager :: setupConnections() |
116 | { | 117 | { |
117 | connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int ))); | 118 | connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int ))); |
118 | connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) ); | 119 | connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) ); |
119 | connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) ); | 120 | connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) ); |
120 | connect( update, SIGNAL(released()), this, SLOT(updateServer()) ); | 121 | connect( update, SIGNAL(released()), this, SLOT(updateServer()) ); |
121 | } | 122 | } |
122 | 123 | ||
123 | void NetworkPackageManager :: showProgressDialog() | 124 | void NetworkPackageManager :: showProgressDialog() |
124 | { | 125 | { |
125 | if ( !progressDlg ) | 126 | if ( !progressDlg ) |
126 | progressDlg = new ProgressDlg( this, "Progress", false ); | 127 | progressDlg = new ProgressDlg( this, "Progress", false ); |
127 | progressDlg->setText( "Reading installed packages" ); | 128 | progressDlg->setText( "Reading installed packages" ); |
128 | progressDlg->show(); | 129 | progressDlg->show(); |
129 | } | 130 | } |
130 | 131 | ||
131 | 132 | ||
132 | void NetworkPackageManager :: serverSelected( int ) | 133 | void NetworkPackageManager :: serverSelected( int ) |
133 | { | 134 | { |
134 | packagesList->clear(); | 135 | packagesList->clear(); |
135 | 136 | ||
136 | // display packages | 137 | // display packages |
137 | QString serverName = serversList->currentText(); | 138 | QString serverName = serversList->currentText(); |
138 | Server *s = dataMgr->getServer( serverName ); | 139 | Server *s = dataMgr->getServer( serverName ); |
139 | dataMgr->setActiveServer( serverName ); | 140 | dataMgr->setActiveServer( serverName ); |
140 | 141 | ||
141 | vector<Package> &list = s->getPackageList(); | 142 | vector<Package> &list = s->getPackageList(); |
142 | vector<Package>::iterator it; | 143 | vector<Package>::iterator it; |
143 | for ( it = list.begin() ; it != list.end() ; ++it ) | 144 | for ( it = list.begin() ; it != list.end() ; ++it ) |
144 | { | 145 | { |
145 | QString text = ""; | 146 | QString text = ""; |
146 | 147 | ||
147 | // If the local server, only display installed packages | 148 | // If the local server, only display installed packages |
148 | if ( serverName == LOCAL_SERVER && !it->isInstalled() ) | 149 | if ( serverName == LOCAL_SERVER && !it->isInstalled() ) |
149 | continue; | 150 | continue; |
150 | 151 | ||
151 | text += it->getPackageName(); | 152 | text += it->getPackageName(); |
152 | if ( it->isInstalled() ) | 153 | if ( it->isInstalled() ) |
153 | { | 154 | { |
154 | text += " (installed)"; | 155 | text += " (installed)"; |
155 | 156 | ||
156 | // If a different version of package is available, postfix it with an * | 157 | // If a different version of package is available, postfix it with an * |
157 | if ( it->getVersion() != it->getInstalledVersion() ) | 158 | if ( it->getVersion() != it->getInstalledVersion() ) |
158 | text += "*"; | 159 | text += "*"; |
159 | } | 160 | } |
160 | 161 | ||
161 | QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox ); | 162 | QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox ); |
162 | if ( !it->isPackageStoredLocally() ) | 163 | if ( !it->isPackageStoredLocally() ) |
163 | new QCheckListItem( item, QString( "Description - " ) + it->getDescription() ); | 164 | new QCheckListItem( item, QString( "Description - " ) + it->getDescription() ); |
164 | else | 165 | else |
165 | new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() ); | 166 | new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() ); |
166 | 167 | ||
167 | new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() ); | 168 | new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() ); |
168 | if ( it->getLocalPackage() ) | 169 | if ( it->getLocalPackage() ) |
169 | { | 170 | { |
170 | if ( it->isInstalled() ) | 171 | if ( it->isInstalled() ) |
171 | new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() ); | 172 | new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() ); |
172 | } | 173 | } |
173 | packagesList->insertItem( item ); | 174 | packagesList->insertItem( item ); |
174 | } | 175 | } |
175 | 176 | ||
176 | // If the local server or the local ipkgs server disable the download button | 177 | // If the local server or the local ipkgs server disable the download button |
177 | download->setText( "Download" ); | 178 | download->setText( "Download" ); |
178 | if ( serverName == LOCAL_SERVER ) | 179 | if ( serverName == LOCAL_SERVER ) |
179 | download->setEnabled( false ); | 180 | download->setEnabled( false ); |
180 | else if ( serverName == LOCAL_IPKGS ) | 181 | else if ( serverName == LOCAL_IPKGS ) |
181 | { | 182 | { |
182 | download->setEnabled( true ); | 183 | download->setEnabled( true ); |
183 | download->setText( "Remove" ); | 184 | download->setText( "Remove" ); |
184 | } | 185 | } |
185 | else | 186 | else |
186 | download->setEnabled( true ); | 187 | download->setEnabled( true ); |
187 | } | 188 | } |
188 | 189 | ||
189 | void NetworkPackageManager :: updateServer() | 190 | void NetworkPackageManager :: updateServer() |
190 | { | 191 | { |
191 | QString serverName = serversList->currentText(); | 192 | QString serverName = serversList->currentText(); |
192 | 193 | ||
193 | // Update the current server | 194 | // Update the current server |
194 | // Display dialog | 195 | // Display dialog |
195 | ProgressDlg *dlg = new ProgressDlg( this ); | 196 | ProgressDlg *dlg = new ProgressDlg( this ); |
196 | QString status = "Updating package list for "; | 197 | QString status = "Updating package list for "; |
197 | status += serverName; | 198 | status += serverName; |
198 | dlg->show(); | 199 | dlg->show(); |
199 | dlg->setText( status ); | 200 | dlg->setText( status ); |
200 | 201 | ||
201 | // Disable buttons to stop silly people clicking lots on them :) | 202 | // Disable buttons to stop silly people clicking lots on them :) |
202 | 203 | ||
203 | // First, write out ipkg_conf file so that ipkg can use it | 204 | // First, write out ipkg_conf file so that ipkg can use it |
204 | dataMgr->writeOutIpkgConf(); | 205 | dataMgr->writeOutIpkgConf(); |
205 | 206 | ||
206 | if ( serverName == LOCAL_SERVER ) | 207 | if ( serverName == LOCAL_SERVER ) |
207 | ; | 208 | ; |
208 | else if ( serverName == LOCAL_IPKGS ) | 209 | else if ( serverName == LOCAL_IPKGS ) |
209 | ; | 210 | ; |
210 | else | 211 | else |
211 | { | 212 | { |
212 | QString option = "update"; | 213 | QString option = "update"; |
213 | QString dummy = ""; | 214 | QString dummy = ""; |
214 | Ipkg ipkg; | 215 | Ipkg ipkg; |
215 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); | 216 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); |
216 | ipkg.setOption( option ); | 217 | ipkg.setOption( option ); |
217 | 218 | ||
218 | ipkg.runIpkg( ); | 219 | ipkg.runIpkg( ); |
219 | } | 220 | } |
220 | 221 | ||
221 | // Reload data | 222 | // Reload data |
222 | dataMgr->reloadServerData( serversList->currentText() ); | 223 | dataMgr->reloadServerData( serversList->currentText() ); |
223 | serverSelected(-1); | 224 | serverSelected(-1); |
224 | delete dlg; | 225 | delete dlg; |
225 | } | 226 | } |
226 | 227 | ||
227 | 228 | ||
228 | void NetworkPackageManager :: downloadPackage() | 229 | void NetworkPackageManager :: downloadPackage() |
229 | { | 230 | { |
230 | if ( download->text() == "Download" ) | 231 | if ( download->text() == "Download" ) |
231 | { | 232 | { |
232 | // First, write out ipkg_conf file so that ipkg can use it | 233 | // First, write out ipkg_conf file so that ipkg can use it |
233 | dataMgr->writeOutIpkgConf(); | 234 | dataMgr->writeOutIpkgConf(); |
234 | 235 | ||
235 | // Display dialog to user asking where to download the files to | 236 | // Display dialog to user asking where to download the files to |
236 | bool ok = FALSE; | 237 | bool ok = FALSE; |
237 | QString dir = ""; | 238 | QString dir = ""; |
238 | #ifdef QWS | 239 | #ifdef QWS |
239 | // read download directory from config file | 240 | // read download directory from config file |
240 | Config cfg( "aqpkg" ); | 241 | Config cfg( "aqpkg" ); |
241 | cfg.setGroup( "settings" ); | 242 | cfg.setGroup( "settings" ); |
242 | dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); | 243 | dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); |
243 | #endif | 244 | #endif |
244 | 245 | ||
245 | QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); | 246 | QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); |
246 | if ( ok && !text.isEmpty() ) | 247 | if ( ok && !text.isEmpty() ) |
247 | dir = text; // user entered something and pressed ok | 248 | dir = text; // user entered something and pressed ok |
248 | else | 249 | else |
249 | return; // user entered nothing or pressed cancel | 250 | return; // user entered nothing or pressed cancel |
250 | 251 | ||
251 | #ifdef QWS | 252 | #ifdef QWS |
252 | // Store download directory in config file | 253 | // Store download directory in config file |
253 | cfg.writeEntry( "downloadDir", dir ); | 254 | cfg.writeEntry( "downloadDir", dir ); |
254 | #endif | 255 | #endif |
255 | 256 | ||
256 | // Get starting directory | 257 | // Get starting directory |
257 | char initDir[PATH_MAX]; | 258 | char initDir[PATH_MAX]; |
258 | getcwd( initDir, PATH_MAX ); | 259 | getcwd( initDir, PATH_MAX ); |
259 | 260 | ||
260 | // Download each package | 261 | // Download each package |
261 | Ipkg ipkg; | 262 | Ipkg ipkg; |
262 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); | 263 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); |
263 | 264 | ||
264 | QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 265 | QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
265 | ipkg.setOption( "download" ); | 266 | ipkg.setOption( "download" ); |
266 | ipkg.setRuntimeDirectory( initDir ); | 267 | ipkg.setRuntimeDirectory( initDir ); |
267 | do | 268 | do |
268 | { | 269 | { |
269 | if ( item->isOn() ) | 270 | if ( item->isOn() ) |
270 | { | 271 | { |
271 | QString name = item->text(); | 272 | QString name = item->text(); |
272 | int pos = name.find( "*" ); | 273 | int pos = name.find( "*" ); |
273 | name.truncate( pos ); | 274 | name.truncate( pos ); |
274 | 275 | ||
275 | // if (there is a (installed), remove it | 276 | // if (there is a (installed), remove it |
276 | pos = name.find( "(installed)" ); | 277 | pos = name.find( "(installed)" ); |
277 | if ( pos > 0 ) | 278 | if ( pos > 0 ) |
278 | name.truncate( pos - 1 ); | 279 | name.truncate( pos - 1 ); |
279 | 280 | ||
280 | ipkg.setPackage( name ); | 281 | ipkg.setPackage( name ); |
281 | ipkg.runIpkg( ); | 282 | ipkg.runIpkg( ); |
282 | } | 283 | } |
283 | 284 | ||
284 | item = (QCheckListItem *)item->nextSibling(); | 285 | item = (QCheckListItem *)item->nextSibling(); |
285 | } while ( item ); | 286 | } while ( item ); |
286 | } | 287 | } |
287 | else if ( download->text() == "Remove" ) | 288 | else if ( download->text() == "Remove" ) |
288 | { | 289 | { |
289 | QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 290 | QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
290 | do | 291 | do |
291 | { | 292 | { |
292 | if ( item->isOn() ) | 293 | if ( item->isOn() ) |
293 | { | 294 | { |
294 | QString name = item->text(); | 295 | QString name = item->text(); |
295 | int pos = name.find( "*" ); | 296 | int pos = name.find( "*" ); |
296 | name.truncate( pos ); | 297 | name.truncate( pos ); |
297 | 298 | ||
298 | // if (there is a (installed), remove it | 299 | // if (there is a (installed), remove it |
299 | pos = name.find( "(installed)" ); | 300 | pos = name.find( "(installed)" ); |
300 | if ( pos > 0 ) | 301 | if ( pos > 0 ) |
301 | name.truncate( pos - 1 ); | 302 | name.truncate( pos - 1 ); |
302 | 303 | ||
303 | Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name ); | 304 | Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name ); |
304 | QFile f( p->getFilename() ); | 305 | QFile f( p->getFilename() ); |
305 | f.remove(); | 306 | f.remove(); |
306 | } | 307 | } |
307 | item = (QCheckListItem *)item->nextSibling(); | 308 | item = (QCheckListItem *)item->nextSibling(); |
308 | } while ( item ); | 309 | } while ( item ); |
309 | } | 310 | } |
310 | 311 | ||
311 | dataMgr->reloadServerData( LOCAL_IPKGS ); | 312 | dataMgr->reloadServerData( LOCAL_IPKGS ); |
312 | serverSelected( -1 ); | 313 | serverSelected( -1 ); |
313 | } | 314 | } |
314 | 315 | ||
315 | 316 | ||
316 | void NetworkPackageManager :: applyChanges() | 317 | void NetworkPackageManager :: applyChanges() |
317 | { | 318 | { |
318 | // Disable buttons to stop silly people clicking lots on them :) | 319 | // Disable buttons to stop silly people clicking lots on them :) |
319 | 320 | ||
320 | // First, write out ipkg_conf file so that ipkg can use it | 321 | // First, write out ipkg_conf file so that ipkg can use it |
321 | dataMgr->writeOutIpkgConf(); | 322 | dataMgr->writeOutIpkgConf(); |
322 | 323 | ||
323 | // Now for each selected item | 324 | // Now for each selected item |
324 | // deal with it | 325 | // deal with it |
325 | 326 | ||
326 | vector<QString> workingPackages; | 327 | vector<QString> workingPackages; |
327 | QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 328 | QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
328 | do | 329 | do |
329 | { | 330 | { |
330 | if ( item->isOn() ) | 331 | if ( item->isOn() ) |
331 | { | 332 | { |
332 | QString p = dealWithItem( item ); | 333 | QString p = dealWithItem( item ); |
333 | workingPackages.push_back( p ); | 334 | workingPackages.push_back( p ); |
334 | } | 335 | } |
335 | 336 | ||
336 | item = (QCheckListItem *)item->nextSibling(); | 337 | item = (QCheckListItem *)item->nextSibling(); |
337 | } while ( item ); | 338 | } while ( item ); |
338 | 339 | ||
339 | // do the stuff | 340 | // do the stuff |
340 | InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true ); | 341 | InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true ); |
341 | dlg.showDlg(); | 342 | dlg.showDlg(); |
342 | 343 | ||
343 | // Reload data | 344 | // Reload data |
344 | dataMgr->reloadServerData( LOCAL_SERVER ); | 345 | dataMgr->reloadServerData( LOCAL_SERVER ); |
345 | dataMgr->reloadServerData( serversList->currentText() ); | 346 | dataMgr->reloadServerData( serversList->currentText() ); |
346 | serverSelected(-1); | 347 | serverSelected(-1); |
347 | 348 | ||
348 | #ifdef QWS | 349 | #ifdef QWS |
349 | // Finally let the main system update itself | 350 | // Finally let the main system update itself |
350 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 351 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
351 | QString lf = QString::null; | 352 | QString lf = QString::null; |
352 | e << lf; | 353 | e << lf; |
353 | #endif | 354 | #endif |
354 | } | 355 | } |
355 | 356 | ||
356 | // decide what to do - either remove, upgrade or install | 357 | // decide what to do - either remove, upgrade or install |
357 | // Current rules: | 358 | // Current rules: |
358 | // If not installed - install | 359 | // If not installed - install |
359 | // If installed and different version available - upgrade | 360 | // If installed and different version available - upgrade |
360 | // If installed and version up to date - remove | 361 | // If installed and version up to date - remove |
361 | QString NetworkPackageManager :: dealWithItem( QCheckListItem *item ) | 362 | QString NetworkPackageManager :: dealWithItem( QCheckListItem *item ) |
362 | { | 363 | { |
363 | QString name = item->text(); | 364 | QString name = item->text(); |
364 | int pos = name.find( "*" ); | 365 | int pos = name.find( "*" ); |
365 | name.truncate( pos ); | 366 | name.truncate( pos ); |
366 | 367 | ||
367 | // if (there is a (installed), remove it | 368 | // if (there is a (installed), remove it |
368 | pos = name.find( "(installed)" ); | 369 | pos = name.find( "(installed)" ); |
369 | if ( pos > 0 ) | 370 | if ( pos > 0 ) |
370 | name.truncate( pos - 1 ); | 371 | name.truncate( pos - 1 ); |
371 | 372 | ||
372 | // Get package | 373 | // Get package |
373 | Server *s = dataMgr->getServer( serversList->currentText() ); | 374 | Server *s = dataMgr->getServer( serversList->currentText() ); |
374 | Package *p = s->getPackage( name ); | 375 | Package *p = s->getPackage( name ); |
375 | 376 | ||
376 | // If the package has a filename then it is a local file | 377 | // If the package has a filename then it is a local file |
377 | if ( p->isPackageStoredLocally() ) | 378 | if ( p->isPackageStoredLocally() ) |
378 | name = p->getFilename(); | 379 | name = p->getFilename(); |
379 | QString option; | 380 | QString option; |
380 | QString dest = "root"; | 381 | QString dest = "root"; |
381 | if ( !p->isInstalled() ) | 382 | if ( !p->isInstalled() ) |
382 | return QString( "I" ) + name; | 383 | return QString( "I" ) + name; |
383 | else | 384 | else |
384 | { | 385 | { |
385 | if ( p->getVersion() == p->getInstalledVersion() ) | 386 | if ( p->getVersion() == p->getInstalledVersion() ) |
386 | return QString( "D" ) + name; | 387 | return QString( "D" ) + name; |
387 | else | 388 | else |
388 | return QString( "U" ) + name; | 389 | return QString( "U" ) + name; |
389 | } | 390 | } |
390 | } | 391 | } |
391 | 392 | ||
392 | void NetworkPackageManager :: displayText( const QString &t ) | 393 | void NetworkPackageManager :: displayText( const QString &t ) |
393 | { | 394 | { |
394 | cout << t << endl; | 395 | cout << t << endl; |
395 | } | 396 | } |