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