summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp
index 318b26d..3ce7960 100644
--- a/noncore/settings/aqpkg/networkpkgmgr.cpp
+++ b/noncore/settings/aqpkg/networkpkgmgr.cpp
@@ -1,474 +1,480 @@
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>
20using namespace std; 20using 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
46NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name) 46NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name)
47 : QWidget(parent, name) 47 : QWidget(parent, name)
48{ 48{
49 dataMgr = dataManager; 49 dataMgr = dataManager;
50 50
51#ifdef QWS 51#ifdef QWS
52 // read download directory from config file 52 // read download directory from config file
53 Config cfg( "aqpkg" ); 53 Config cfg( "aqpkg" );
54 cfg.setGroup( "settings" ); 54 cfg.setGroup( "settings" );
55 currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); 55 currentlySelectedServer = cfg.readEntry( "selectedServer", "local" );
56#endif 56#endif
57 57
58 58
59 initGui(); 59 initGui();
60 setupConnections(); 60 setupConnections();
61 61
62 progressDlg = 0; 62 progressDlg = 0;
63 timerId = startTimer( 100 ); 63 timerId = startTimer( 100 );
64} 64}
65 65
66NetworkPackageManager::~NetworkPackageManager() 66NetworkPackageManager::~NetworkPackageManager()
67{ 67{
68} 68}
69 69
70void NetworkPackageManager :: timerEvent ( QTimerEvent * ) 70void NetworkPackageManager :: timerEvent ( QTimerEvent * )
71{ 71{
72 killTimer( timerId ); 72 killTimer( timerId );
73 73
74// showProgressDialog(); 74// showProgressDialog();
75 // Add server names to listbox 75 // Add server names to listbox
76 updateData(); 76 updateData();
77 77
78// progressDlg->hide(); 78// progressDlg->hide();
79} 79}
80 80
81void NetworkPackageManager :: updateData() 81void NetworkPackageManager :: updateData()
82{ 82{
83 serversList->clear(); 83 serversList->clear();
84 packagesList->clear(); 84 packagesList->clear();
85 85
86
86 vector<Server>::iterator it; 87 vector<Server>::iterator it;
87 int activeItem = -1; 88 int activeItem = -1;
88 int i; 89 int i;
89 for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i ) 90 for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i )
90 { 91 {
92 if ( !it->isServerActive() )
93 {
94 i--;
95 continue;
96 }
91 serversList->insertItem( it->getServerName() ); 97 serversList->insertItem( it->getServerName() );
92 if ( it->getServerName() == currentlySelectedServer ) 98 if ( it->getServerName() == currentlySelectedServer )
93 activeItem = i; 99 activeItem = i;
94 } 100 }
95 101
96 // set selected server to be active server 102 // set selected server to be active server
97 if ( activeItem != -1 ) 103 if ( activeItem != -1 )
98 serversList->setCurrentItem( activeItem ); 104 serversList->setCurrentItem( activeItem );
99 serverSelected( 0 ); 105 serverSelected( 0 );
100} 106}
101 107
102 108
103void NetworkPackageManager :: initGui() 109void NetworkPackageManager :: initGui()
104{ 110{
105 QLabel *l = new QLabel( "Servers", this ); 111 QLabel *l = new QLabel( "Servers", this );
106 serversList = new QComboBox( this ); 112 serversList = new QComboBox( this );
107 packagesList = new QListView( this ); 113 packagesList = new QListView( this );
108 update = new QPushButton( "Refresh List", this ); 114 update = new QPushButton( "Refresh List", this );
109 download = new QPushButton( "Download", this ); 115 download = new QPushButton( "Download", this );
110 upgrade = new QPushButton( "Upgrade", this ); 116 upgrade = new QPushButton( "Upgrade", this );
111 apply = new QPushButton( "Apply", this ); 117 apply = new QPushButton( "Apply", this );
112 118
113 QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1, "VBox" ); 119 QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1, "VBox" );
114 QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1, "HBox1" ); 120 QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1, "HBox1" );
115 hbox1->addWidget( l ); 121 hbox1->addWidget( l );
116 hbox1->addWidget( serversList ); 122 hbox1->addWidget( serversList );
117 123
118 QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1, "HBox1" ); 124 QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1, "HBox1" );
119 QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1, "HBox1" ); 125 QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1, "HBox1" );
120 126
121 char text[2]; 127 char text[2];
122 text[1] = '\0'; 128 text[1] = '\0';
123 for ( int i = 0 ; i < 26 ; ++i ) 129 for ( int i = 0 ; i < 26 ; ++i )
124 { 130 {
125 text[0] = 'A' + i; 131 text[0] = 'A' + i;
126 LetterPushButton *b = new LetterPushButton( text, this ); 132 LetterPushButton *b = new LetterPushButton( text, this );
127 connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); 133 connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) );
128 if ( i < 16 ) 134 if ( i < 16 )
129 hbox3->addWidget( b ); 135 hbox3->addWidget( b );
130 else 136 else
131 hbox4->addWidget( b ); 137 hbox4->addWidget( b );
132 } 138 }
133 139
134 vbox->addWidget( packagesList ); 140 vbox->addWidget( packagesList );
135 packagesList->addColumn( "Packages" ); 141 packagesList->addColumn( "Packages" );
136 142
137 QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1, "HBox2" ); 143 QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1, "HBox2" );
138 hbox2->addWidget( update ); 144 hbox2->addWidget( update );
139 hbox2->addWidget( download ); 145 hbox2->addWidget( download );
140 hbox2->addWidget( upgrade ); 146 hbox2->addWidget( upgrade );
141 hbox2->addWidget( apply ); 147 hbox2->addWidget( apply );
142} 148}
143 149
144void NetworkPackageManager :: setupConnections() 150void NetworkPackageManager :: setupConnections()
145{ 151{
146 connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int ))); 152 connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int )));
147 connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) ); 153 connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) );
148 connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) ); 154 connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) );
149 connect( upgrade, SIGNAL( released()), this, SLOT(upgradePackages()) ); 155 connect( upgrade, SIGNAL( released()), this, SLOT(upgradePackages()) );
150 connect( update, SIGNAL(released()), this, SLOT(updateServer()) ); 156 connect( update, SIGNAL(released()), this, SLOT(updateServer()) );
151} 157}
152 158
153void NetworkPackageManager :: showProgressDialog( char *initialText ) 159void NetworkPackageManager :: showProgressDialog( char *initialText )
154{ 160{
155 if ( !progressDlg ) 161 if ( !progressDlg )
156 progressDlg = new ProgressDlg( this, "Progress", false ); 162 progressDlg = new ProgressDlg( this, "Progress", false );
157 progressDlg->setText( initialText ); 163 progressDlg->setText( initialText );
158 progressDlg->show(); 164 progressDlg->show();
159} 165}
160 166
161 167
162void NetworkPackageManager :: serverSelected( int ) 168void NetworkPackageManager :: serverSelected( int )
163{ 169{
164 packagesList->clear(); 170 packagesList->clear();
165 171
166 // display packages 172 // display packages
167 QString serverName = serversList->currentText(); 173 QString serverName = serversList->currentText();
168 currentlySelectedServer = serverName; 174 currentlySelectedServer = serverName;
169 175
170#ifdef QWS 176#ifdef QWS
171 // read download directory from config file 177 // read download directory from config file
172 Config cfg( "aqpkg" ); 178 Config cfg( "aqpkg" );
173 cfg.setGroup( "settings" ); 179 cfg.setGroup( "settings" );
174 cfg.writeEntry( "selectedServer", currentlySelectedServer ); 180 cfg.writeEntry( "selectedServer", currentlySelectedServer );
175#endif 181#endif
176 182
177 Server *s = dataMgr->getServer( serverName ); 183 Server *s = dataMgr->getServer( serverName );
178// dataMgr->setActiveServer( serverName ); 184// dataMgr->setActiveServer( serverName );
179 185
180 vector<Package> &list = s->getPackageList(); 186 vector<Package> &list = s->getPackageList();
181 vector<Package>::iterator it; 187 vector<Package>::iterator it;
182 for ( it = list.begin() ; it != list.end() ; ++it ) 188 for ( it = list.begin() ; it != list.end() ; ++it )
183 { 189 {
184 QString text = ""; 190 QString text = "";
185 191
186 // If the local server, only display installed packages 192 // If the local server, only display installed packages
187 if ( serverName == LOCAL_SERVER && !it->isInstalled() ) 193 if ( serverName == LOCAL_SERVER && !it->isInstalled() )
188 continue; 194 continue;
189 195
190 text += it->getPackageName(); 196 text += it->getPackageName();
191 if ( it->isInstalled() ) 197 if ( it->isInstalled() )
192 { 198 {
193 text += " (installed)"; 199 text += " (installed)";
194 200
195 // If a different version of package is available, postfix it with an * 201 // If a different version of package is available, postfix it with an *
196 if ( it->getVersion() != it->getInstalledVersion() ) 202 if ( it->getVersion() != it->getInstalledVersion() )
197 text += "*"; 203 text += "*";
198 } 204 }
199 205
200 QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox ); 206 QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox );
201 if ( !it->isPackageStoredLocally() ) 207 if ( !it->isPackageStoredLocally() )
202 new QCheckListItem( item, QString( "Description - " ) + it->getDescription() ); 208 new QCheckListItem( item, QString( "Description - " ) + it->getDescription() );
203 else 209 else
204 new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() ); 210 new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() );
205 211
206 new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() ); 212 new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() );
207 if ( it->getLocalPackage() ) 213 if ( it->getLocalPackage() )
208 { 214 {
209 if ( it->isInstalled() ) 215 if ( it->isInstalled() )
210 new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() ); 216 new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() );
211 } 217 }
212 packagesList->insertItem( item ); 218 packagesList->insertItem( item );
213 } 219 }
214 220
215 // If the local server or the local ipkgs server disable the download button 221 // If the local server or the local ipkgs server disable the download button
216 if ( serverName == LOCAL_SERVER ) 222 if ( serverName == LOCAL_SERVER )
217 { 223 {
218 upgrade->setEnabled( false ); 224 upgrade->setEnabled( false );
219 download->setText( "Download" ); 225 download->setText( "Download" );
220 download->setEnabled( false ); 226 download->setEnabled( false );
221 } 227 }
222 else if ( serverName == LOCAL_IPKGS ) 228 else if ( serverName == LOCAL_IPKGS )
223 { 229 {
224 upgrade->setEnabled( false ); 230 upgrade->setEnabled( false );
225 download->setEnabled( true ); 231 download->setEnabled( true );
226 download->setText( "Remove" ); 232 download->setText( "Remove" );
227 } 233 }
228 else 234 else
229 { 235 {
230 upgrade->setEnabled( true ); 236 upgrade->setEnabled( true );
231 download->setEnabled( true ); 237 download->setEnabled( true );
232 download->setText( "Download" ); 238 download->setText( "Download" );
233 } 239 }
234} 240}
235 241
236void NetworkPackageManager :: updateServer() 242void NetworkPackageManager :: updateServer()
237{ 243{
238 QString serverName = serversList->currentText(); 244 QString serverName = serversList->currentText();
239 245
240 // Update the current server 246 // Update the current server
241 // Display dialog 247 // Display dialog
242 ProgressDlg *dlg = new ProgressDlg( this ); 248 ProgressDlg *dlg = new ProgressDlg( this );
243 QString status = "Updating package lists..."; 249 QString status = "Updating package lists...";
244 dlg->show(); 250 dlg->show();
245 dlg->setText( status ); 251 dlg->setText( status );
246 252
247 // Disable buttons to stop silly people clicking lots on them :) 253 // Disable buttons to stop silly people clicking lots on them :)
248 254
249 // First, write out ipkg_conf file so that ipkg can use it 255 // First, write out ipkg_conf file so that ipkg can use it
250 dataMgr->writeOutIpkgConf(); 256 dataMgr->writeOutIpkgConf();
251 257
252// if ( serverName == LOCAL_SERVER ) 258// if ( serverName == LOCAL_SERVER )
253// ; 259// ;
254// else if ( serverName == LOCAL_IPKGS ) 260// else if ( serverName == LOCAL_IPKGS )
255// ; 261// ;
256// else 262// else
257 { 263 {
258 QString option = "update"; 264 QString option = "update";
259 QString dummy = ""; 265 QString dummy = "";
260 Ipkg ipkg; 266 Ipkg ipkg;
261 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 267 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
262 ipkg.setOption( option ); 268 ipkg.setOption( option );
263 269
264 ipkg.runIpkg( ); 270 ipkg.runIpkg( );
265 } 271 }
266 272
267 // Reload data 273 // Reload data
268 dataMgr->reloadServerData( serversList->currentText() ); 274 dataMgr->reloadServerData( serversList->currentText() );
269 serverSelected(-1); 275 serverSelected(-1);
270 delete dlg; 276 delete dlg;
271} 277}
272 278
273void NetworkPackageManager :: upgradePackages() 279void NetworkPackageManager :: upgradePackages()
274{ 280{
275 // We're gonna do an upgrade of all packages 281 // We're gonna do an upgrade of all packages
276 // First warn user that this isn't recommended 282 // First warn user that this isn't recommended
277 QString text = "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n"; 283 QString text = "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n";
278 QMessageBox warn("Warning", text, QMessageBox::Warning, 284 QMessageBox warn("Warning", text, QMessageBox::Warning,
279 QMessageBox::Yes, 285 QMessageBox::Yes,
280 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , 286 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default ,
281 0, this ); 287 0, this );
282 warn.adjustSize(); 288 warn.adjustSize();
283 289
284 if ( warn.exec() == QMessageBox::Yes ) 290 if ( warn.exec() == QMessageBox::Yes )
285 { 291 {
286 // First, write out ipkg_conf file so that ipkg can use it 292 // First, write out ipkg_conf file so that ipkg can use it
287 dataMgr->writeOutIpkgConf(); 293 dataMgr->writeOutIpkgConf();
288 294
289 // Now run upgrade 295 // Now run upgrade
290 InstallDlgImpl dlg( this, "Upgrade", true ); 296 InstallDlgImpl dlg( this, "Upgrade", true );
291 dlg.showDlg(); 297 dlg.showDlg();
292 298
293 // Reload data 299 // Reload data
294 dataMgr->reloadServerData( LOCAL_SERVER ); 300 dataMgr->reloadServerData( LOCAL_SERVER );
295 301
296 dataMgr->reloadServerData( serversList->currentText() ); 302 dataMgr->reloadServerData( serversList->currentText() );
297 serverSelected(-1); 303 serverSelected(-1);
298 } 304 }
299} 305}
300 306
301 307
302void NetworkPackageManager :: downloadPackage() 308void NetworkPackageManager :: downloadPackage()
303{ 309{
304 if ( download->text() == "Download" ) 310 if ( download->text() == "Download" )
305 { 311 {
306 // First, write out ipkg_conf file so that ipkg can use it 312 // First, write out ipkg_conf file so that ipkg can use it
307 dataMgr->writeOutIpkgConf(); 313 dataMgr->writeOutIpkgConf();
308 314
309 // Display dialog to user asking where to download the files to 315 // Display dialog to user asking where to download the files to
310 bool ok = FALSE; 316 bool ok = FALSE;
311 QString dir = ""; 317 QString dir = "";
312#ifdef QWS 318#ifdef QWS
313 // read download directory from config file 319 // read download directory from config file
314 Config cfg( "aqpkg" ); 320 Config cfg( "aqpkg" );
315 cfg.setGroup( "settings" ); 321 cfg.setGroup( "settings" );
316 dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); 322 dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" );
317#endif 323#endif
318 324
319 QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); 325 QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this );
320 if ( ok && !text.isEmpty() ) 326 if ( ok && !text.isEmpty() )
321 dir = text; // user entered something and pressed ok 327 dir = text; // user entered something and pressed ok
322 else 328 else
323 return; // user entered nothing or pressed cancel 329 return; // user entered nothing or pressed cancel
324 330
325#ifdef QWS 331#ifdef QWS
326 // Store download directory in config file 332 // Store download directory in config file
327 cfg.writeEntry( "downloadDir", dir ); 333 cfg.writeEntry( "downloadDir", dir );
328#endif 334#endif
329 335
330 // Get starting directory 336 // Get starting directory
331 char initDir[PATH_MAX]; 337 char initDir[PATH_MAX];
332 getcwd( initDir, PATH_MAX ); 338 getcwd( initDir, PATH_MAX );
333 339
334 // Download each package 340 // Download each package
335 Ipkg ipkg; 341 Ipkg ipkg;
336 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 342 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
337 343
338 ipkg.setOption( "download" ); 344 ipkg.setOption( "download" );
339 ipkg.setRuntimeDirectory( dir ); 345 ipkg.setRuntimeDirectory( dir );
340 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 346 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
341 item != 0 ; 347 item != 0 ;
342 item = (QCheckListItem *)item->nextSibling() ) 348 item = (QCheckListItem *)item->nextSibling() )
343 { 349 {
344 if ( item->isOn() ) 350 if ( item->isOn() )
345 { 351 {
346 QString name = item->text(); 352 QString name = item->text();
347 int pos = name.find( "*" ); 353 int pos = name.find( "*" );
348 name.truncate( pos ); 354 name.truncate( pos );
349 355
350 // if (there is a (installed), remove it 356 // if (there is a (installed), remove it
351 pos = name.find( "(installed)" ); 357 pos = name.find( "(installed)" );
352 if ( pos > 0 ) 358 if ( pos > 0 )
353 name.truncate( pos - 1 ); 359 name.truncate( pos - 1 );
354 360
355 ipkg.setPackage( name ); 361 ipkg.setPackage( name );
356 ipkg.runIpkg( ); 362 ipkg.runIpkg( );
357 } 363 }
358 } 364 }
359 } 365 }
360 else if ( download->text() == "Remove" ) 366 else if ( download->text() == "Remove" )
361 { 367 {
362 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 368 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
363 item != 0 ; 369 item != 0 ;
364 item = (QCheckListItem *)item->nextSibling() ) 370 item = (QCheckListItem *)item->nextSibling() )
365 { 371 {
366 if ( item->isOn() ) 372 if ( item->isOn() )
367 { 373 {
368 QString name = item->text(); 374 QString name = item->text();
369 int pos = name.find( "*" ); 375 int pos = name.find( "*" );
370 name.truncate( pos ); 376 name.truncate( pos );
371 377
372 // if (there is a (installed), remove it 378 // if (there is a (installed), remove it
373 pos = name.find( "(installed)" ); 379 pos = name.find( "(installed)" );
374 if ( pos > 0 ) 380 if ( pos > 0 )
375 name.truncate( pos - 1 ); 381 name.truncate( pos - 1 );
376 382
377 Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name ); 383 Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name );
378 QFile f( p->getFilename() ); 384 QFile f( p->getFilename() );
379 f.remove(); 385 f.remove();
380 } 386 }
381 } 387 }
382 } 388 }
383 389
384 dataMgr->reloadServerData( LOCAL_IPKGS ); 390 dataMgr->reloadServerData( LOCAL_IPKGS );
385 serverSelected( -1 ); 391 serverSelected( -1 );
386} 392}
387 393
388 394
389void NetworkPackageManager :: applyChanges() 395void NetworkPackageManager :: applyChanges()
390{ 396{
391 // Disable buttons to stop silly people clicking lots on them :) 397 // Disable buttons to stop silly people clicking lots on them :)
392 398
393 // First, write out ipkg_conf file so that ipkg can use it 399 // First, write out ipkg_conf file so that ipkg can use it
394 dataMgr->writeOutIpkgConf(); 400 dataMgr->writeOutIpkgConf();
395 401
396 // Now for each selected item 402 // Now for each selected item
397 // deal with it 403 // deal with it
398 404
399 vector<QString> workingPackages; 405 vector<QString> workingPackages;
400 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 406 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
401 item != 0 ; 407 item != 0 ;
402 item = (QCheckListItem *)item->nextSibling() ) 408 item = (QCheckListItem *)item->nextSibling() )
403 { 409 {
404 if ( item->isOn() ) 410 if ( item->isOn() )
405 { 411 {
406 QString p = dealWithItem( item ); 412 QString p = dealWithItem( item );
407 workingPackages.push_back( p ); 413 workingPackages.push_back( p );
408 } 414 }
409 } 415 }
410 416
411 // do the stuff 417 // do the stuff
412 InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true ); 418 InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true );
413 dlg.showDlg(); 419 dlg.showDlg();
414 420
415 // Reload data 421 // Reload data
416 dataMgr->reloadServerData( LOCAL_SERVER ); 422 dataMgr->reloadServerData( LOCAL_SERVER );
417 423
418 dataMgr->reloadServerData( serversList->currentText() ); 424 dataMgr->reloadServerData( serversList->currentText() );
419 serverSelected(-1); 425 serverSelected(-1);
420 426
421#ifdef QWS 427#ifdef QWS
422 // Finally let the main system update itself 428 // Finally let the main system update itself
423 QCopEnvelope e("QPE/System", "linkChanged(QString)"); 429 QCopEnvelope e("QPE/System", "linkChanged(QString)");
424 QString lf = QString::null; 430 QString lf = QString::null;
425 e << lf; 431 e << lf;
426#endif 432#endif
427} 433}
428 434
429// decide what to do - either remove, upgrade or install 435// decide what to do - either remove, upgrade or install
430// Current rules: 436// Current rules:
431// If not installed - install 437// If not installed - install
432// If installed and different version available - upgrade 438// If installed and different version available - upgrade
433// If installed and version up to date - remove 439// If installed and version up to date - remove
434QString NetworkPackageManager :: dealWithItem( QCheckListItem *item ) 440QString NetworkPackageManager :: dealWithItem( QCheckListItem *item )
435{ 441{
436 QString name = item->text(); 442 QString name = item->text();
437 int pos = name.find( "*" ); 443 int pos = name.find( "*" );
438 name.truncate( pos ); 444 name.truncate( pos );
439 445
440 // if (there is a (installed), remove it 446 // if (there is a (installed), remove it
441 pos = name.find( "(installed)" ); 447 pos = name.find( "(installed)" );
442 if ( pos > 0 ) 448 if ( pos > 0 )
443 name.truncate( pos - 1 ); 449 name.truncate( pos - 1 );
444 450
445 // Get package 451 // Get package
446 Server *s = dataMgr->getServer( serversList->currentText() ); 452 Server *s = dataMgr->getServer( serversList->currentText() );
447 Package *p = s->getPackage( name ); 453 Package *p = s->getPackage( name );
448 454
449 // If the package has a filename then it is a local file 455 // If the package has a filename then it is a local file
450 if ( p->isPackageStoredLocally() ) 456 if ( p->isPackageStoredLocally() )
451 name = p->getFilename(); 457 name = p->getFilename();
452 QString option; 458 QString option;
453 QString dest = "root"; 459 QString dest = "root";
454 if ( !p->isInstalled() ) 460 if ( !p->isInstalled() )
455 return QString( "I" ) + name; 461 return QString( "I" ) + name;
456 else 462 else
457 { 463 {
458 if ( p->getVersion() == p->getInstalledVersion() ) 464 if ( p->getVersion() == p->getInstalledVersion() )
459 { 465 {
460 QString msgtext; 466 QString msgtext;
461 msgtext.sprintf( "Do you wish to remove or reinstall\n%s?", (const char *)name ); 467 msgtext.sprintf( "Do you wish to remove or reinstall\n%s?", (const char *)name );
462 switch( QMessageBox::information( this, "Remove or ReInstall", 468 switch( QMessageBox::information( this, "Remove or ReInstall",
463 msgtext, "Remove", "ReInstall" ) ) 469 msgtext, "Remove", "ReInstall" ) )
464 { 470 {
465 case 0: // Try again or Enter 471 case 0: // Try again or Enter
466 return QString( "D" ) + name; 472 return QString( "D" ) + name;
467 break; 473 break;
468 case 1: // Quit or Escape 474 case 1: // Quit or Escape
469 return QString( "U" ) + name; 475 return QString( "U" ) + name;
470 break; 476 break;
471 } 477 }
472 478
473 // User hit cancel (on dlg - assume remove) 479 // User hit cancel (on dlg - assume remove)
474 return QString( "D" ) + name; 480 return QString( "D" ) + name;