summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/datamgr.cpp34
-rw-r--r--noncore/settings/aqpkg/datamgr.h2
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.cpp32
3 files changed, 36 insertions, 32 deletions
diff --git a/noncore/settings/aqpkg/datamgr.cpp b/noncore/settings/aqpkg/datamgr.cpp
index 089c3e3..f342aff 100644
--- a/noncore/settings/aqpkg/datamgr.cpp
+++ b/noncore/settings/aqpkg/datamgr.cpp
@@ -90,116 +90,116 @@ void DataManager :: loadServers()
90 cout << "Couldn't open " << ipkg_conf << "! err = " << fp << endl; 90 cout << "Couldn't open " << ipkg_conf << "! err = " << fp << endl;
91 return; 91 return;
92 } 92 }
93 else 93 else
94 { 94 {
95 while ( fgets( line, sizeof line, fp) != NULL ) 95 while ( fgets( line, sizeof line, fp) != NULL )
96 { 96 {
97 lineStr = line; 97 lineStr = line;
98 if ( lineStr.startsWith( "src" ) || lineStr.startsWith( "#src" ) || lineStr.startsWith( "# src" ) ) 98 if ( lineStr.startsWith( "src" ) || lineStr.startsWith( "#src" ) || lineStr.startsWith( "# src" ) )
99 { 99 {
100 char alias[20]; 100 char alias[20];
101 char url[100]; 101 char url[100];
102 102
103 103
104 // Looks a little wierd but read up to the r of src (throwing it away), 104 // Looks a little wierd but read up to the r of src (throwing it away),
105 // then read up to the next space and throw that away, the alias 105 // then read up to the next space and throw that away, the alias
106 // is next. 106 // is next.
107 // Should Handle #src, # src, src, and combinations of 107 // Should Handle #src, # src, src, and combinations of
108 sscanf( lineStr, "%*[^r]%*[^ ] %s %s", alias, url ); 108 sscanf( lineStr, "%*[^r]%*[^ ] %s %s", alias, url );
109 Server s( alias, url ); 109 Server s( alias, url );
110 if ( lineStr.startsWith( "src" ) ) 110 if ( lineStr.startsWith( "src" ) )
111 s.setActive( true ); 111 s.setActive( true );
112 else 112 else
113 s.setActive( false ); 113 s.setActive( false );
114 114
115 serverList.push_back( s ); 115 serverList.push_back( s );
116 116
117 } 117 }
118 else if ( lineStr.startsWith( "dest" ) ) 118 else if ( lineStr.startsWith( "dest" ) )
119 { 119 {
120 char alias[20]; 120 char alias[20];
121 char path[50]; 121 char path[50];
122 sscanf( lineStr, "%*[^ ] %s %s", alias, path ); 122 sscanf( lineStr, "%*[^ ] %s %s", alias, path );
123 Destination d( alias, path ); 123 Destination d( alias, path );
124 bool linkToRoot = true; 124 bool linkToRoot = true;
125#ifdef QWS 125#ifdef QWS
126 QString key = alias; 126 QString key = alias;
127 key += "_linkToRoot"; 127 key += "_linkToRoot";
128 linkToRoot = cfg.readBoolEntry( key, true ); 128 linkToRoot = cfg.readBoolEntry( key, true );
129#endif 129#endif
130 d.linkToRoot( linkToRoot ); 130 d.linkToRoot( linkToRoot );
131 131
132 destList.push_back( d ); 132 destList.push_back( d );
133 } 133 }
134 } 134 }
135 } 135 }
136 fclose( fp ); 136 fclose( fp );
137 137
138 vector<Server>::iterator it; 138 reloadServerData( );
139 for ( it = serverList.begin() ; it != serverList.end() ; ++it )
140 reloadServerData( it->getServerName() );
141} 139}
142 140
143void DataManager :: reloadServerData( const char *serverName ) 141void DataManager :: reloadServerData( )
144{ 142{
145 Server *s = getServer( serverName ); 143 vector<Server>::iterator it = serverList.begin();
146 // Now we've read the config file in we need to read the servers 144 for ( it = serverList.begin() ; it != serverList.end() ; ++it )
147 // The local server is a special case. This holds the contents of the 145 {
148 // status files the number of which depends on how many destinations 146 // Now we've read the config file in we need to read the servers
149 // we've set up 147 // The local server is a special case. This holds the contents of the
150 // The other servers files hold the contents of the server package list 148 // status files the number of which depends on how many destinations
151 if ( s->getServerName() == LOCAL_SERVER ) 149 // we've set up
152 s->readStatusFile( destList ); 150 // The other servers files hold the contents of the server package list
153 else if ( s->getServerName() == LOCAL_IPKGS ) 151 if ( it->getServerName() == LOCAL_SERVER )
154 s->readLocalIpks( getServer( LOCAL_SERVER ) ); 152 it->readStatusFile( destList );
155 else 153 else if ( it->getServerName() == LOCAL_IPKGS )
156 s->readPackageFile( getServer( LOCAL_SERVER ) ); 154 it->readLocalIpks( getServer( LOCAL_SERVER ) );
157 155 else
156 it->readPackageFile( getServer( LOCAL_SERVER ) );
157 }
158} 158}
159 159
160void DataManager :: writeOutIpkgConf() 160void DataManager :: writeOutIpkgConf()
161{ 161{
162 QString ipkg_conf = IPKG_CONF; 162 QString ipkg_conf = IPKG_CONF;
163 ofstream out( ipkg_conf ); 163 ofstream out( ipkg_conf );
164 164
165 out << "# Written by AQPkg" << endl; 165 out << "# Written by AQPkg" << endl;
166 out << "# Must have one or more source entries of the form:" << endl; 166 out << "# Must have one or more source entries of the form:" << endl;
167 out << "#" << endl; 167 out << "#" << endl;
168 out << "# src <src-name> <source-url>" << endl; 168 out << "# src <src-name> <source-url>" << endl;
169 out << "#" << endl; 169 out << "#" << endl;
170 out << "# and one or more destination entries of the form:" << endl; 170 out << "# and one or more destination entries of the form:" << endl;
171 out << "#" << endl; 171 out << "#" << endl;
172 out << "# dest <dest-name> <target-path>" << endl; 172 out << "# dest <dest-name> <target-path>" << endl;
173 out << "#" << endl; 173 out << "#" << endl;
174 out << "# where <src-name> and <dest-names> are identifiers that" << endl; 174 out << "# where <src-name> and <dest-names> are identifiers that" << endl;
175 out << "# should match [a-zA-Z0-9._-]+, <source-url> should be a" << endl; 175 out << "# should match [a-zA-Z0-9._-]+, <source-url> should be a" << endl;
176 out << "# URL that points to a directory containing a Familiar" << endl; 176 out << "# URL that points to a directory containing a Familiar" << endl;
177 out << "# Packages file, and <target-path> should be a directory" << endl; 177 out << "# Packages file, and <target-path> should be a directory" << endl;
178 out << "# that exists on the target system." << endl << endl; 178 out << "# that exists on the target system." << endl << endl;
179 179
180 // Write out servers 180 // Write out servers
181 vector<Server>::iterator it = serverList.begin(); 181 vector<Server>::iterator it = serverList.begin();
182 while ( it != serverList.end() ) 182 while ( it != serverList.end() )
183 { 183 {
184 QString alias = it->getServerName(); 184 QString alias = it->getServerName();
185 // Don't write out local as its a dummy 185 // Don't write out local as its a dummy
186 if ( alias != LOCAL_SERVER && alias != LOCAL_IPKGS ) 186 if ( alias != LOCAL_SERVER && alias != LOCAL_IPKGS )
187 { 187 {
188 QString url = it->getServerUrl();; 188 QString url = it->getServerUrl();;
189 189
190 if ( !it->isServerActive() ) 190 if ( !it->isServerActive() )
191 out << "#"; 191 out << "#";
192 out << "src " << alias << " " << url << endl; 192 out << "src " << alias << " " << url << endl;
193 } 193 }
194 194
195 it++; 195 it++;
196 } 196 }
197 197
198 out << endl; 198 out << endl;
199 199
200 // Write out destinations 200 // Write out destinations
201 vector<Destination>::iterator it2 = destList.begin(); 201 vector<Destination>::iterator it2 = destList.begin();
202 while ( it2 != destList.end() ) 202 while ( it2 != destList.end() )
203 { 203 {
204 out << "dest " << it2->getDestinationName() << " " << it2->getDestinationPath() << endl; 204 out << "dest " << it2->getDestinationName() << " " << it2->getDestinationPath() << endl;
205 it2++; 205 it2++;
diff --git a/noncore/settings/aqpkg/datamgr.h b/noncore/settings/aqpkg/datamgr.h
index eb802b5..8c6fb0d 100644
--- a/noncore/settings/aqpkg/datamgr.h
+++ b/noncore/settings/aqpkg/datamgr.h
@@ -4,61 +4,61 @@
4 begin : Thu Aug 29 2002 4 begin : Thu Aug 29 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#ifndef DATAMGR_H 18#ifndef DATAMGR_H
19#define DATAMGR_H 19#define DATAMGR_H
20 20
21#include <map> 21#include <map>
22using namespace std; 22using namespace std;
23 23
24#include "server.h" 24#include "server.h"
25#include "destination.h" 25#include "destination.h"
26 26
27 #define LOCAL_SERVER "Installed Pkgs" 27 #define LOCAL_SERVER "Installed Pkgs"
28 #define LOCAL_IPKGS "local IPKG" 28 #define LOCAL_IPKGS "local IPKG"
29 29
30/** 30/**
31 *@author Andy Qua 31 *@author Andy Qua
32 */ 32 */
33 33
34 34
35class DataManager 35class DataManager
36{ 36{
37public: 37public:
38 DataManager(); 38 DataManager();
39 ~DataManager(); 39 ~DataManager();
40 40
41 void setActiveServer( const QString &act ) { activeServer = act; } 41 void setActiveServer( const QString &act ) { activeServer = act; }
42 QString &getActiveServer( ) { return activeServer; } 42 QString &getActiveServer( ) { return activeServer; }
43 43
44 Server *getLocalServer() { return getServer( LOCAL_SERVER ); } 44 Server *getLocalServer() { return getServer( LOCAL_SERVER ); }
45 vector<Server> &getServerList() { return serverList; } 45 vector<Server> &getServerList() { return serverList; }
46 Server *getServer( const char *name ); 46 Server *getServer( const char *name );
47 47
48 vector<Destination> &getDestinationList() { return destList; } 48 vector<Destination> &getDestinationList() { return destList; }
49 Destination *getDestination( const char *name ); 49 Destination *getDestination( const char *name );
50 50
51 void loadServers(); 51 void loadServers();
52 void reloadServerData( const char *sn ); 52 void reloadServerData( );
53 53
54 void writeOutIpkgConf(); 54 void writeOutIpkgConf();
55 55
56 56
57private: 57private:
58 QString activeServer; 58 QString activeServer;
59 59
60 vector<Server> serverList; 60 vector<Server> serverList;
61 vector<Destination> destList; 61 vector<Destination> destList;
62}; 62};
63 63
64#endif 64#endif
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp
index 02e4e73..b5d7352 100644
--- a/noncore/settings/aqpkg/networkpkgmgr.cpp
+++ b/noncore/settings/aqpkg/networkpkgmgr.cpp
@@ -170,361 +170,365 @@ void NetworkPackageManager :: initGui()
170 hbox4->addWidget( b ); 170 hbox4->addWidget( b );
171 } 171 }
172 } 172 }
173 173
174 vbox->addWidget( packagesList ); 174 vbox->addWidget( packagesList );
175 packagesList->addColumn( "Packages" ); 175 packagesList->addColumn( "Packages" );
176 176
177 QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1, "HBox2" ); 177 QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1, "HBox2" );
178 hbox2->addWidget( update ); 178 hbox2->addWidget( update );
179 hbox2->addWidget( download ); 179 hbox2->addWidget( download );
180 hbox2->addWidget( upgrade ); 180 hbox2->addWidget( upgrade );
181 hbox2->addWidget( apply ); 181 hbox2->addWidget( apply );
182} 182}
183 183
184void NetworkPackageManager :: setupConnections() 184void NetworkPackageManager :: setupConnections()
185{ 185{
186 connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int ))); 186 connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int )));
187 connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) ); 187 connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) );
188 connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) ); 188 connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) );
189 connect( upgrade, SIGNAL( released()), this, SLOT(upgradePackages()) ); 189 connect( upgrade, SIGNAL( released()), this, SLOT(upgradePackages()) );
190 connect( update, SIGNAL(released()), this, SLOT(updateServer()) ); 190 connect( update, SIGNAL(released()), this, SLOT(updateServer()) );
191} 191}
192 192
193void NetworkPackageManager :: showProgressDialog( char *initialText ) 193void NetworkPackageManager :: showProgressDialog( char *initialText )
194{ 194{
195 if ( !progressDlg ) 195 if ( !progressDlg )
196 progressDlg = new ProgressDlg( this, "Progress", false ); 196 progressDlg = new ProgressDlg( this, "Progress", false );
197 progressDlg->setText( initialText ); 197 progressDlg->setText( initialText );
198 progressDlg->show(); 198 progressDlg->show();
199} 199}
200 200
201 201
202void NetworkPackageManager :: serverSelected( int ) 202void NetworkPackageManager :: serverSelected( int )
203{ 203{
204 packagesList->clear(); 204 packagesList->clear();
205 205
206 // display packages 206 // display packages
207 QString serverName = serversList->currentText(); 207 QString serverName = serversList->currentText();
208 currentlySelectedServer = serverName; 208 currentlySelectedServer = serverName;
209 209
210#ifdef QWS 210#ifdef QWS
211 // read download directory from config file 211 // read download directory from config file
212 Config cfg( "aqpkg" ); 212 Config cfg( "aqpkg" );
213 cfg.setGroup( "settings" ); 213 cfg.setGroup( "settings" );
214 cfg.writeEntry( "selectedServer", currentlySelectedServer ); 214 cfg.writeEntry( "selectedServer", currentlySelectedServer );
215#endif 215#endif
216 216
217 Server *s = dataMgr->getServer( serverName ); 217 Server *s = dataMgr->getServer( serverName );
218// dataMgr->setActiveServer( serverName );
219 218
220 vector<Package> &list = s->getPackageList(); 219 vector<Package> &list = s->getPackageList();
221 vector<Package>::iterator it; 220 vector<Package>::iterator it;
222 for ( it = list.begin() ; it != list.end() ; ++it ) 221 for ( it = list.begin() ; it != list.end() ; ++it )
223 { 222 {
223
224 QString text = ""; 224 QString text = "";
225 225
226 // If the local server, only display installed packages 226 // If the local server, only display installed packages
227 if ( serverName == LOCAL_SERVER && !it->isInstalled() ) 227 if ( serverName == LOCAL_SERVER && !it->isInstalled() )
228 continue; 228 continue;
229 229
230 text += it->getPackageName(); 230 text += it->getPackageName();
231 if ( it->isInstalled() ) 231 if ( it->isInstalled() )
232 { 232 {
233 text += " (installed)"; 233 text += " (installed)";
234 234
235 // 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 *
236 if ( it->getVersion() != it->getInstalledVersion() ) 236 if ( it->getVersion() != it->getInstalledVersion() )
237 { 237 {
238
238 if ( compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1 ) 239 if ( compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1 )
239 text += "*"; 240 text += "*";
240 } 241 }
241 } 242 }
242 243
243 QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox ); 244 QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox );
244 245
245 if ( it->isInstalled() ) 246 if ( it->isInstalled() )
246 { 247 {
247 QString destName = ""; 248 QString destName = "";
248 if ( it->getLocalPackage() ) 249 if ( it->getLocalPackage() )
249 { 250 {
250 if ( it->getLocalPackage()->getInstalledTo() ) 251 if ( it->getLocalPackage()->getInstalledTo() )
251 destName = it->getLocalPackage()->getInstalledTo()->getDestinationName(); 252 destName = it->getLocalPackage()->getInstalledTo()->getDestinationName();
252 } 253 }
253 else 254 else
254 { 255 {
255 if ( it->getInstalledTo() ) 256 if ( it->getInstalledTo() )
256 destName = it->getInstalledTo()->getDestinationName(); 257 destName = it->getInstalledTo()->getDestinationName();
257 } 258 }
258 if ( destName != "" ) 259 if ( destName != "" )
259 new QCheckListItem( item, QString( "Installed To - " ) + destName ); 260 new QCheckListItem( item, QString( "Installed To - " ) + destName );
260 } 261 }
261 262
262 if ( !it->isPackageStoredLocally() ) 263 if ( !it->isPackageStoredLocally() )
263 new QCheckListItem( item, QString( "Description - " ) + it->getDescription() ); 264 new QCheckListItem( item, QString( "Description - " ) + it->getDescription() );
264 else 265 else
265 new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() ); 266 new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() );
266 267
267 new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() ); 268 if ( serverName == LOCAL_SERVER )
268 if ( it->getLocalPackage() ) 269 {
269 { 270 new QCheckListItem( item, QString( "V. Installed - " ) + it->getVersion() );
270 if ( it->isInstalled() ) 271 }
271 new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() ); 272 else
273 {
274 new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() );
275 if ( it->getLocalPackage() )
276 {
277 if ( it->isInstalled() )
278 new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() );
279 }
272 } 280 }
273 packagesList->insertItem( item ); 281 packagesList->insertItem( item );
274 } 282 }
275 283
276 // If the local server or the local ipkgs server disable the download button 284 // If the local server or the local ipkgs server disable the download button
277 if ( serverName == LOCAL_SERVER ) 285 if ( serverName == LOCAL_SERVER )
278 { 286 {
279 upgrade->setEnabled( false ); 287 upgrade->setEnabled( false );
280 download->setText( "Download" ); 288 download->setText( "Download" );
281 download->setEnabled( false ); 289 download->setEnabled( false );
282 } 290 }
283 else if ( serverName == LOCAL_IPKGS ) 291 else if ( serverName == LOCAL_IPKGS )
284 { 292 {
285 upgrade->setEnabled( false ); 293 upgrade->setEnabled( false );
286 download->setEnabled( true ); 294 download->setEnabled( true );
287 download->setText( "Remove" ); 295 download->setText( "Remove" );
288 } 296 }
289 else 297 else
290 { 298 {
291 upgrade->setEnabled( true ); 299 upgrade->setEnabled( true );
292 download->setEnabled( true ); 300 download->setEnabled( true );
293 download->setText( "Download" ); 301 download->setText( "Download" );
294 } 302 }
295} 303}
296 304
297void NetworkPackageManager :: updateServer() 305void NetworkPackageManager :: updateServer()
298{ 306{
299 QString serverName = serversList->currentText(); 307 QString serverName = serversList->currentText();
300 308
301 // Update the current server 309 // Update the current server
302 // Display dialog 310 // Display dialog
303// ProgressDlg *progDlg = new ProgressDlg( this ); 311// ProgressDlg *progDlg = new ProgressDlg( this );
304// QString status = "Updating package lists..."; 312// QString status = "Updating package lists...";
305// progDlg->show(); 313// progDlg->show();
306// progDlg->setText( status ); 314// progDlg->setText( status );
307 315
308 // Disable buttons to stop silly people clicking lots on them :) 316 // Disable buttons to stop silly people clicking lots on them :)
309 317
310 // First, write out ipkg_conf file so that ipkg can use it 318 // First, write out ipkg_conf file so that ipkg can use it
311 dataMgr->writeOutIpkgConf(); 319 dataMgr->writeOutIpkgConf();
312 320
313 Ipkg ipkg; 321 Ipkg ipkg;
314 ipkg.setOption( "update" ); 322 ipkg.setOption( "update" );
315 323
316 InstallDlgImpl dlg( &ipkg, "Refreshing server package lists", this, "Upgrade", true ); 324 InstallDlgImpl dlg( &ipkg, "Refreshing server package lists", this, "Upgrade", true );
317 dlg.showDlg(); 325 dlg.showDlg();
318 326
319 // Reload data 327 // Reload data
320 dataMgr->reloadServerData( serversList->currentText() ); 328 dataMgr->reloadServerData();
321 serverSelected(-1); 329 serverSelected(-1);
322// delete progDlg; 330// delete progDlg;
323} 331}
324 332
325void NetworkPackageManager :: upgradePackages() 333void NetworkPackageManager :: upgradePackages()
326{ 334{
327 // We're gonna do an upgrade of all packages 335 // We're gonna do an upgrade of all packages
328 // First warn user that this isn't recommended 336 // First warn user that this isn't recommended
329 QString text = "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n"; 337 QString text = "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n";
330 QMessageBox warn("Warning", text, QMessageBox::Warning, 338 QMessageBox warn("Warning", text, QMessageBox::Warning,
331 QMessageBox::Yes, 339 QMessageBox::Yes,
332 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , 340 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default ,
333 0, this ); 341 0, this );
334 warn.adjustSize(); 342 warn.adjustSize();
335 343
336 if ( warn.exec() == QMessageBox::Yes ) 344 if ( warn.exec() == QMessageBox::Yes )
337 { 345 {
338 // First, write out ipkg_conf file so that ipkg can use it 346 // First, write out ipkg_conf file so that ipkg can use it
339 dataMgr->writeOutIpkgConf(); 347 dataMgr->writeOutIpkgConf();
340 348
341 // Now run upgrade 349 // Now run upgrade
342 Ipkg ipkg; 350 Ipkg ipkg;
343 ipkg.setOption( "upgrade" ); 351 ipkg.setOption( "upgrade" );
344 352
345 InstallDlgImpl dlg( &ipkg, "Upgrading installed packages", this, "Upgrade", true ); 353 InstallDlgImpl dlg( &ipkg, "Upgrading installed packages", this, "Upgrade", true );
346 dlg.showDlg(); 354 dlg.showDlg();
347 355
348 // Reload data 356 // Reload data
349 dataMgr->reloadServerData( LOCAL_SERVER ); 357 dataMgr->reloadServerData();
350
351 dataMgr->reloadServerData( serversList->currentText() );
352 serverSelected(-1); 358 serverSelected(-1);
353 } 359 }
354} 360}
355 361
356 362
357void NetworkPackageManager :: downloadPackage() 363void NetworkPackageManager :: downloadPackage()
358{ 364{
359 if ( download->text() == "Download" ) 365 if ( download->text() == "Download" )
360 { 366 {
361 // First, write out ipkg_conf file so that ipkg can use it 367 // First, write out ipkg_conf file so that ipkg can use it
362 dataMgr->writeOutIpkgConf(); 368 dataMgr->writeOutIpkgConf();
363 369
364 // Display dialog to user asking where to download the files to 370 // Display dialog to user asking where to download the files to
365 bool ok = FALSE; 371 bool ok = FALSE;
366 QString dir = ""; 372 QString dir = "";
367#ifdef QWS 373#ifdef QWS
368 // read download directory from config file 374 // read download directory from config file
369 Config cfg( "aqpkg" ); 375 Config cfg( "aqpkg" );
370 cfg.setGroup( "settings" ); 376 cfg.setGroup( "settings" );
371 dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); 377 dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" );
372#endif 378#endif
373 379
374 QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); 380 QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this );
375 if ( ok && !text.isEmpty() ) 381 if ( ok && !text.isEmpty() )
376 dir = text; // user entered something and pressed ok 382 dir = text; // user entered something and pressed ok
377 else 383 else
378 return; // user entered nothing or pressed cancel 384 return; // user entered nothing or pressed cancel
379 385
380#ifdef QWS 386#ifdef QWS
381 // Store download directory in config file 387 // Store download directory in config file
382 cfg.writeEntry( "downloadDir", dir ); 388 cfg.writeEntry( "downloadDir", dir );
383#endif 389#endif
384 390
385 // Get starting directory 391 // Get starting directory
386 char initDir[PATH_MAX]; 392 char initDir[PATH_MAX];
387 getcwd( initDir, PATH_MAX ); 393 getcwd( initDir, PATH_MAX );
388 394
389 // Download each package 395 // Download each package
390 Ipkg ipkg; 396 Ipkg ipkg;
391 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 397 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
392 398
393 ipkg.setOption( "download" ); 399 ipkg.setOption( "download" );
394 ipkg.setRuntimeDirectory( dir ); 400 ipkg.setRuntimeDirectory( dir );
395 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 401 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
396 item != 0 ; 402 item != 0 ;
397 item = (QCheckListItem *)item->nextSibling() ) 403 item = (QCheckListItem *)item->nextSibling() )
398 { 404 {
399 if ( item->isOn() ) 405 if ( item->isOn() )
400 { 406 {
401 QString name = item->text(); 407 QString name = item->text();
402 int pos = name.find( "*" ); 408 int pos = name.find( "*" );
403 name.truncate( pos ); 409 name.truncate( pos );
404 410
405 // if (there is a (installed), remove it 411 // if (there is a (installed), remove it
406 pos = name.find( "(installed)" ); 412 pos = name.find( "(installed)" );
407 if ( pos > 0 ) 413 if ( pos > 0 )
408 name.truncate( pos - 1 ); 414 name.truncate( pos - 1 );
409 415
410 ipkg.setPackage( name ); 416 ipkg.setPackage( name );
411 ipkg.runIpkg( ); 417 ipkg.runIpkg( );
412 } 418 }
413 } 419 }
414 } 420 }
415 else if ( download->text() == "Remove" ) 421 else if ( download->text() == "Remove" )
416 { 422 {
417 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 423 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
418 item != 0 ; 424 item != 0 ;
419 item = (QCheckListItem *)item->nextSibling() ) 425 item = (QCheckListItem *)item->nextSibling() )
420 { 426 {
421 if ( item->isOn() ) 427 if ( item->isOn() )
422 { 428 {
423 QString name = item->text(); 429 QString name = item->text();
424 int pos = name.find( "*" ); 430 int pos = name.find( "*" );
425 name.truncate( pos ); 431 name.truncate( pos );
426 432
427 // if (there is a (installed), remove it 433 // if (there is a (installed), remove it
428 pos = name.find( "(installed)" ); 434 pos = name.find( "(installed)" );
429 if ( pos > 0 ) 435 if ( pos > 0 )
430 name.truncate( pos - 1 ); 436 name.truncate( pos - 1 );
431 437
432 Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name ); 438 Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name );
433 QFile f( p->getFilename() ); 439 QFile f( p->getFilename() );
434 f.remove(); 440 f.remove();
435 } 441 }
436 } 442 }
437 } 443 }
438 444
439 dataMgr->reloadServerData( LOCAL_IPKGS ); 445 dataMgr->reloadServerData();
440 serverSelected( -1 ); 446 serverSelected( -1 );
441} 447}
442 448
443 449
444void NetworkPackageManager :: applyChanges() 450void NetworkPackageManager :: applyChanges()
445{ 451{
446 stickyOption = ""; 452 stickyOption = "";
447 453
448 // First, write out ipkg_conf file so that ipkg can use it 454 // First, write out ipkg_conf file so that ipkg can use it
449 dataMgr->writeOutIpkgConf(); 455 dataMgr->writeOutIpkgConf();
450 456
451 // Now for each selected item 457 // Now for each selected item
452 // deal with it 458 // deal with it
453 459
454 vector<InstallData> workingPackages; 460 vector<InstallData> workingPackages;
455 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 461 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
456 item != 0 ; 462 item != 0 ;
457 item = (QCheckListItem *)item->nextSibling() ) 463 item = (QCheckListItem *)item->nextSibling() )
458 { 464 {
459 if ( item->isOn() ) 465 if ( item->isOn() )
460 { 466 {
461 InstallData data = dealWithItem( item ); 467 InstallData data = dealWithItem( item );
462 workingPackages.push_back( data ); 468 workingPackages.push_back( data );
463 } 469 }
464 } 470 }
465 471
466 if ( workingPackages.size() == 0 ) 472 if ( workingPackages.size() == 0 )
467 { 473 {
468 // Nothing to do 474 // Nothing to do
469 QMessageBox::information( this, "Nothing to do", 475 QMessageBox::information( this, "Nothing to do",
470 "No packages selected", "OK" ); 476 "No packages selected", "OK" );
471 477
472 return; 478 return;
473 } 479 }
474 480
475 // do the stuff 481 // do the stuff
476 InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true ); 482 InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true );
477 dlg.showDlg(); 483 dlg.showDlg();
478 484
479 // Reload data 485 // Reload data
480 dataMgr->reloadServerData( LOCAL_SERVER ); 486 dataMgr->reloadServerData();
481
482 dataMgr->reloadServerData( serversList->currentText() );
483 serverSelected(-1); 487 serverSelected(-1);
484 488
485#ifdef QWS 489#ifdef QWS
486 // Finally let the main system update itself 490 // Finally let the main system update itself
487 QCopEnvelope e("QPE/System", "linkChanged(QString)"); 491 QCopEnvelope e("QPE/System", "linkChanged(QString)");
488 QString lf = QString::null; 492 QString lf = QString::null;
489 e << lf; 493 e << lf;
490#endif 494#endif
491} 495}
492 496
493// decide what to do - either remove, upgrade or install 497// decide what to do - either remove, upgrade or install
494// Current rules: 498// Current rules:
495// If not installed - install 499// If not installed - install
496// If installed and different version available - upgrade 500// If installed and different version available - upgrade
497// If installed and version up to date - remove 501// If installed and version up to date - remove
498InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item ) 502InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item )
499{ 503{
500 QString name = item->text(); 504 QString name = item->text();
501 int pos = name.find( "*" ); 505 int pos = name.find( "*" );
502 name.truncate( pos ); 506 name.truncate( pos );
503 507
504 // if (there is a (installed), remove it 508 // if (there is a (installed), remove it
505 pos = name.find( "(installed)" ); 509 pos = name.find( "(installed)" );
506 if ( pos > 0 ) 510 if ( pos > 0 )
507 name.truncate( pos - 1 ); 511 name.truncate( pos - 1 );
508 512
509 // Get package 513 // Get package
510 Server *s = dataMgr->getServer( serversList->currentText() ); 514 Server *s = dataMgr->getServer( serversList->currentText() );
511 Package *p = s->getPackage( name ); 515 Package *p = s->getPackage( name );
512 516
513 // If the package has a filename then it is a local file 517 // If the package has a filename then it is a local file
514 if ( p->isPackageStoredLocally() ) 518 if ( p->isPackageStoredLocally() )
515 name = p->getFilename(); 519 name = p->getFilename();
516 QString option; 520 QString option;
517 QString dest = "root"; 521 QString dest = "root";
518 if ( !p->isInstalled() ) 522 if ( !p->isInstalled() )
519 { 523 {
520 InstallData item; 524 InstallData item;
521 item.option = "I"; 525 item.option = "I";
522 item.packageName = name; 526 item.packageName = name;
523 return item; 527 return item;
524 } 528 }
525 else 529 else
526 { 530 {
527 InstallData item; 531 InstallData item;
528 item.option = "D"; 532 item.option = "D";
529 item.packageName = p->getInstalledPackageName(); 533 item.packageName = p->getInstalledPackageName();
530 if ( p->getInstalledTo() ) 534 if ( p->getInstalledTo() )