summaryrefslogtreecommitdiff
authorandyq <andyq>2002-11-21 20:16:40 (UTC)
committer andyq <andyq>2002-11-21 20:16:40 (UTC)
commit2185394da06d32a3655e71ec022da202477350e7 (patch) (unidiff)
treeb266ddecaa44a1fef5229bb0525c990d5e7cc51a
parent6d302b82aab909da59852d99a31bcc7726ba9f34 (diff)
downloadopie-2185394da06d32a3655e71ec022da202477350e7.zip
opie-2185394da06d32a3655e71ec022da202477350e7.tar.gz
opie-2185394da06d32a3655e71ec022da202477350e7.tar.bz2
Re-applied patch for gcc3.2
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/datamgr.cpp29
-rw-r--r--noncore/settings/aqpkg/datamgr.h8
-rw-r--r--noncore/settings/aqpkg/global.h2
-rw-r--r--noncore/settings/aqpkg/installdlgimpl.cpp2
-rw-r--r--noncore/settings/aqpkg/ipkg.cpp1
-rw-r--r--noncore/settings/aqpkg/letterpushbutton.cpp2
-rw-r--r--noncore/settings/aqpkg/mainwin.cpp5
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.cpp4
-rw-r--r--noncore/settings/aqpkg/server.cpp2
-rw-r--r--noncore/settings/aqpkg/settingsimpl.cpp23
10 files changed, 37 insertions, 41 deletions
diff --git a/noncore/settings/aqpkg/datamgr.cpp b/noncore/settings/aqpkg/datamgr.cpp
index e7fb75a..96c28c0 100644
--- a/noncore/settings/aqpkg/datamgr.cpp
+++ b/noncore/settings/aqpkg/datamgr.cpp
@@ -1,262 +1,255 @@
1/*************************************************************************** 1/***************************************************************************
2 datamgr.cpp - description 2 datamgr.cpp - description
3 ------------------- 3 -------------------
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#include <fstream> 17#include <fstream>
18#include <iostream> 18#include <iostream>
19using namespace std; 19using namespace std;
20 20
21#ifdef QWS 21#ifdef QWS
22#include <qpe/config.h> 22#include <qpe/config.h>
23#endif 23#endif
24 24
25#include <stdio.h> 25#include <stdio.h>
26 26
27#include "datamgr.h" 27#include "datamgr.h"
28#include "global.h" 28#include "global.h"
29 29
30 30
31QString DataManager::availableCategories = ""; 31QString DataManager::availableCategories = "";
32DataManager::DataManager() 32DataManager::DataManager()
33{ 33{
34 activeServer = ""; 34 activeServer = "";
35 availableCategories = "#"; 35 availableCategories = "#";
36} 36}
37 37
38DataManager::~DataManager() 38DataManager::~DataManager()
39{ 39{
40} 40}
41 41
42Server *DataManager :: getServer( const char *name ) 42vector<Server>::iterator DataManager :: getServer( const char *name )
43{ 43{
44 Server *s = 0; 44 vector<Server>::iterator it = serverList.begin();
45 vector<Server>::iterator it = serverList.begin(); 45 while ( it != serverList.end() )
46 while ( it != serverList.end() && s == 0 )
47 { 46 {
48 if ( it->getServerName() == name ) 47 if ( it->getServerName() == name )
49 s = &(*it); 48 return it;
50 49
51 ++it; 50 ++it;
52 } 51 }
53 52
54 return s; 53 return serverList.end();
55} 54}
56 55
57Destination *DataManager :: getDestination( const char *name ) 56vector<Destination>::iterator DataManager :: getDestination( const char *name )
58{ 57{
59 Destination *d = 0;
60 vector<Destination>::iterator it = destList.begin(); 58 vector<Destination>::iterator it = destList.begin();
61 while ( it != destList.end() && d == 0 ) 59 while ( it != destList.end() )
62 { 60 {
63 if ( it->getDestinationName() == name ) 61 if ( it->getDestinationName() == name )
64 d = &(*it); 62 return it;
65 63
66 ++it; 64 ++it;
67 } 65 }
68 66
69 return d; 67 return destList.end();
70} 68}
71 69
72void DataManager :: loadServers() 70void DataManager :: loadServers()
73{ 71{
74 // First add our local server - not really a server but 72 // First add our local server - not really a server but
75 // the local config (which packages are installed) 73 // the local config (which packages are installed)
76 serverList.push_back( Server( LOCAL_SERVER, "" ) ); 74 serverList.push_back( Server( LOCAL_SERVER, "" ) );
77 serverList.push_back( Server( LOCAL_IPKGS, "" ) ); 75 serverList.push_back( Server( LOCAL_IPKGS, "" ) );
78 76
79#ifdef QWS 77#ifdef QWS
80 Config cfg( "aqpkg" ); 78 Config cfg( "aqpkg" );
81 cfg.setGroup( "destinations" ); 79 cfg.setGroup( "destinations" );
82#endif 80#endif
83 81
84 // Read file from /etc/ipkg.conf 82 // Read file from /etc/ipkg.conf
85 QString ipkg_conf = IPKG_CONF; 83 QString ipkg_conf = IPKG_CONF;
86 FILE *fp; 84 FILE *fp;
87 fp = fopen( ipkg_conf, "r" ); 85 fp = fopen( ipkg_conf, "r" );
88 char line[130]; 86 char line[130];
89 QString lineStr; 87 QString lineStr;
90 if ( fp == NULL ) 88 if ( fp == NULL )
91 { 89 {
92 cout << "Couldn't open " << ipkg_conf << "! err = " << fp << endl; 90 cout << "Couldn't open " << ipkg_conf << "! err = " << fp << endl;
93 return; 91 return;
94 } 92 }
95 else 93 else
96 { 94 {
97 while ( fgets( line, sizeof line, fp) != NULL ) 95 while ( fgets( line, sizeof line, fp) != NULL )
98 { 96 {
99 lineStr = line; 97 lineStr = line;
100 if ( lineStr.startsWith( "src" ) || lineStr.startsWith( "#src" ) || lineStr.startsWith( "# src" ) ) 98 if ( lineStr.startsWith( "src" ) || lineStr.startsWith( "#src" ) || lineStr.startsWith( "# src" ) )
101 { 99 {
102 char alias[20]; 100 char alias[20];
103 char url[100]; 101 char url[100];
104 102
105 // Looks a little wierd but read up to the r of src (throwing it away), 103 // Looks a little wierd but read up to the r of src (throwing it away),
106 // then read up to the next space and throw that away, the alias 104 // then read up to the next space and throw that away, the alias
107 // is next. 105 // is next.
108 // Should Handle #src, # src, src, and combinations of 106 // Should Handle #src, # src, src, and combinations of
109 sscanf( lineStr, "%*[^r]%*[^ ] %s %s", alias, url ); 107 sscanf( lineStr, "%*[^r]%*[^ ] %s %s", alias, url );
110 Server s( alias, url ); 108 Server s( alias, url );
111 if ( lineStr.startsWith( "src" ) ) 109 if ( lineStr.startsWith( "src" ) )
112 s.setActive( true ); 110 s.setActive( true );
113 else 111 else
114 s.setActive( false ); 112 s.setActive( false );
115 113
116 serverList.push_back( s ); 114 serverList.push_back( s );
117 115
118 } 116 }
119 else if ( lineStr.startsWith( "dest" ) ) 117 else if ( lineStr.startsWith( "dest" ) )
120 { 118 {
121 char alias[20]; 119 char alias[20];
122 char path[50]; 120 char path[50];
123 sscanf( lineStr, "%*[^ ] %s %s", alias, path ); 121 sscanf( lineStr, "%*[^ ] %s %s", alias, path );
124 Destination d( alias, path ); 122 Destination d( alias, path );
125 bool linkToRoot = true; 123 bool linkToRoot = true;
126#ifdef QWS 124#ifdef QWS
127 QString key = alias; 125 QString key = alias;
128 key += "_linkToRoot"; 126 key += "_linkToRoot";
129 linkToRoot = cfg.readBoolEntry( key, true ); 127 linkToRoot = cfg.readBoolEntry( key, true );
130#endif 128#endif
131 d.linkToRoot( linkToRoot ); 129 d.linkToRoot( linkToRoot );
132 130
133 destList.push_back( d ); 131 destList.push_back( d );
134 } 132 }
135 else if ( lineStr.startsWith( "option" ) ) 133 else if ( lineStr.startsWith( "option" ) )
136 { 134 {
137 char type[20]; 135 char type[20];
138 char val[100]; 136 char val[100];
139 sscanf( lineStr, "%*[^ ] %s %s", type, val ); 137 sscanf( lineStr, "%*[^ ] %s %s", type, val );
140 if ( stricmp( type, "http_proxy" ) == 0 ) 138 if ( stricmp( type, "http_proxy" ) == 0 )
141 httpProxy = val; 139 httpProxy = val;
142 if ( stricmp( type, "ftp_proxy" ) == 0 ) 140 if ( stricmp( type, "ftp_proxy" ) == 0 )
143 ftpProxy = val; 141 ftpProxy = val;
144 if ( stricmp( type, "proxy_username" ) == 0 ) 142 if ( stricmp( type, "proxy_username" ) == 0 )
145 proxyUsername = val; 143 proxyUsername = val;
146 if ( stricmp( type, "proxy_password" ) == 0 ) 144 if ( stricmp( type, "proxy_password" ) == 0 )
147 proxyPassword = val; 145 proxyPassword = val;
148 } 146 }
149 } 147 }
150 } 148 }
151 fclose( fp ); 149 fclose( fp );
152 150
153 cout << "httpProxy = " << httpProxy << endl;
154 cout << "ftpProxy = " << ftpProxy << endl;
155 cout << "proxyUsername = " << proxyUsername << endl;
156 cout << "proxyPassword = " << proxyPassword << endl;
157
158 reloadServerData( ); 151 reloadServerData( );
159} 152}
160 153
161void DataManager :: reloadServerData( ) 154void DataManager :: reloadServerData( )
162{ 155{
163 vector<Server>::iterator it = serverList.begin(); 156 vector<Server>::iterator it = serverList.begin();
164 for ( it = serverList.begin() ; it != serverList.end() ; ++it ) 157 for ( it = serverList.begin() ; it != serverList.end() ; ++it )
165 { 158 {
166 // Now we've read the config file in we need to read the servers 159 // Now we've read the config file in we need to read the servers
167 // The local server is a special case. This holds the contents of the 160 // The local server is a special case. This holds the contents of the
168 // status files the number of which depends on how many destinations 161 // status files the number of which depends on how many destinations
169 // we've set up 162 // we've set up
170 // The other servers files hold the contents of the server package list 163 // The other servers files hold the contents of the server package list
171 if ( it->getServerName() == LOCAL_SERVER ) 164 if ( it->getServerName() == LOCAL_SERVER )
172 it->readStatusFile( destList ); 165 it->readStatusFile( destList );
173 else if ( it->getServerName() == LOCAL_IPKGS ) 166 else if ( it->getServerName() == LOCAL_IPKGS )
174 it->readLocalIpks( getServer( LOCAL_SERVER ) ); 167 it->readLocalIpks( &( *getServer( LOCAL_SERVER ) ) );
175 else 168 else
176 it->readPackageFile( getServer( LOCAL_SERVER ) ); 169 it->readPackageFile( &( *getServer( LOCAL_SERVER ) ) );
177 } 170 }
178} 171}
179 172
180void DataManager :: writeOutIpkgConf() 173void DataManager :: writeOutIpkgConf()
181{ 174{
182 QString ipkg_conf = IPKG_CONF; 175 QString ipkg_conf = IPKG_CONF;
183 ofstream out( ipkg_conf ); 176 ofstream out( ipkg_conf );
184 177
185 out << "# Written by AQPkg" << endl; 178 out << "# Written by AQPkg" << endl;
186 out << "# Must have one or more source entries of the form:" << endl; 179 out << "# Must have one or more source entries of the form:" << endl;
187 out << "#" << endl; 180 out << "#" << endl;
188 out << "# src <src-name> <source-url>" << endl; 181 out << "# src <src-name> <source-url>" << endl;
189 out << "#" << endl; 182 out << "#" << endl;
190 out << "# and one or more destination entries of the form:" << endl; 183 out << "# and one or more destination entries of the form:" << endl;
191 out << "#" << endl; 184 out << "#" << endl;
192 out << "# dest <dest-name> <target-path>" << endl; 185 out << "# dest <dest-name> <target-path>" << endl;
193 out << "#" << endl; 186 out << "#" << endl;
194 out << "# where <src-name> and <dest-names> are identifiers that" << endl; 187 out << "# where <src-name> and <dest-names> are identifiers that" << endl;
195 out << "# should match [a-zA-Z0-9._-]+, <source-url> should be a" << endl; 188 out << "# should match [a-zA-Z0-9._-]+, <source-url> should be a" << endl;
196 out << "# URL that points to a directory containing a Familiar" << endl; 189 out << "# URL that points to a directory containing a Familiar" << endl;
197 out << "# Packages file, and <target-path> should be a directory" << endl; 190 out << "# Packages file, and <target-path> should be a directory" << endl;
198 out << "# that exists on the target system." << endl << endl; 191 out << "# that exists on the target system." << endl << endl;
199 192
200 // Write out servers 193 // Write out servers
201 vector<Server>::iterator it = serverList.begin(); 194 vector<Server>::iterator it = serverList.begin();
202 while ( it != serverList.end() ) 195 while ( it != serverList.end() )
203 { 196 {
204 QString alias = it->getServerName(); 197 QString alias = it->getServerName();
205 // Don't write out local as its a dummy 198 // Don't write out local as its a dummy
206 if ( alias != LOCAL_SERVER && alias != LOCAL_IPKGS ) 199 if ( alias != LOCAL_SERVER && alias != LOCAL_IPKGS )
207 { 200 {
208 QString url = it->getServerUrl();; 201 QString url = it->getServerUrl();;
209 202
210 if ( !it->isServerActive() ) 203 if ( !it->isServerActive() )
211 out << "#"; 204 out << "#";
212 out << "src " << alias << " " << url << endl; 205 out << "src " << alias << " " << url << endl;
213 } 206 }
214 207
215 it++; 208 it++;
216 } 209 }
217 210
218 out << endl; 211 out << endl;
219 212
220 // Write out destinations 213 // Write out destinations
221 vector<Destination>::iterator it2 = destList.begin(); 214 vector<Destination>::iterator it2 = destList.begin();
222 while ( it2 != destList.end() ) 215 while ( it2 != destList.end() )
223 { 216 {
224 out << "dest " << it2->getDestinationName() << " " << it2->getDestinationPath() << endl; 217 out << "dest " << it2->getDestinationName() << " " << it2->getDestinationPath() << endl;
225 it2++; 218 it2++;
226 } 219 }
227 220
228 out << "# Proxy Support" << endl; 221 out << "# Proxy Support" << endl;
229 out << "#" << endl; 222 out << "#" << endl;
230 223
231 if ( httpProxy == "" ) 224 if ( httpProxy == "" )
232 out << "#option http_proxy http://proxy.tld:3128" << endl; 225 out << "#option http_proxy http://proxy.tld:3128" << endl;
233 else 226 else
234 out << "option http_proxy " << httpProxy << endl; 227 out << "option http_proxy " << httpProxy << endl;
235 228
236 if ( ftpProxy == "" ) 229 if ( ftpProxy == "" )
237 out << "#option ftp_proxy http://proxy.tld:3128" << endl; 230 out << "#option ftp_proxy http://proxy.tld:3128" << endl;
238 else 231 else
239 out << "option ftp_proxy " << ftpProxy << endl; 232 out << "option ftp_proxy " << ftpProxy << endl;
240 if ( proxyUsername == "" ) 233 if ( proxyUsername == "" )
241 out << "#option proxy_username <username>" << endl; 234 out << "#option proxy_username <username>" << endl;
242 else 235 else
243 out << "option proxy_username " << proxyUsername << endl; 236 out << "option proxy_username " << proxyUsername << endl;
244 if ( proxyPassword == "" ) 237 if ( proxyPassword == "" )
245 out << "#option proxy_password <password>" << endl << endl; 238 out << "#option proxy_password <password>" << endl << endl;
246 else 239 else
247 out << "option proxy_password " << proxyPassword << endl<< endl; 240 out << "option proxy_password " << proxyPassword << endl<< endl;
248 241
249 out << "# Offline mode (for use in constructing flash images offline)" << endl; 242 out << "# Offline mode (for use in constructing flash images offline)" << endl;
250 out << "#option offline_root target" << endl; 243 out << "#option offline_root target" << endl;
251 244
252 245
253 out.close(); 246 out.close();
254} 247}
255 248
256 249
257void DataManager :: setAvailableCategories( QString section ) 250void DataManager :: setAvailableCategories( QString section )
258{ 251{
259 section = section.lower(); 252 section = section.lower();
260 if ( availableCategories.find( "#" + section + "#" ) == -1 ) 253 if ( availableCategories.find( "#" + section + "#" ) == -1 )
261 availableCategories += section + "#"; 254 availableCategories += section + "#";
262} 255}
diff --git a/noncore/settings/aqpkg/datamgr.h b/noncore/settings/aqpkg/datamgr.h
index 14b0b2f..41833df 100644
--- a/noncore/settings/aqpkg/datamgr.h
+++ b/noncore/settings/aqpkg/datamgr.h
@@ -1,73 +1,73 @@
1/*************************************************************************** 1/***************************************************************************
2 datamgr.h - description 2 datamgr.h - description
3 ------------------- 3 -------------------
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 <qstring.h> 24#include <qstring.h>
25 25
26#include "server.h" 26#include "server.h"
27#include "destination.h" 27#include "destination.h"
28 28
29 #define LOCAL_SERVER "Installed Pkgs" 29 #define LOCAL_SERVER "Installed Pkgs"
30 #define LOCAL_IPKGS "local IPKG" 30 #define LOCAL_IPKGS "local IPKG"
31 31
32/** 32/**
33 *@author Andy Qua 33 *@author Andy Qua
34 */ 34 */
35 35
36 36
37class DataManager 37class DataManager
38{ 38{
39public: 39public:
40 DataManager(); 40 DataManager();
41 ~DataManager(); 41 ~DataManager();
42 42
43 void setActiveServer( const QString &act ) { activeServer = act; } 43 void setActiveServer( const QString &act ) { activeServer = act; }
44 QString &getActiveServer( ) { return activeServer; } 44 QString &getActiveServer( ) { return activeServer; }
45 45
46 Server *getLocalServer() { return getServer( LOCAL_SERVER ); } 46 Server *getLocalServer() { return &( *getServer( LOCAL_SERVER ) ); }
47 vector<Server> &getServerList() { return serverList; } 47 vector<Server> &getServerList() { return serverList; }
48 Server *getServer( const char *name ); 48 vector<Server>::iterator getServer( const char *name );
49 49
50 vector<Destination> &getDestinationList() { return destList; } 50 vector<Destination> &getDestinationList() { return destList; }
51 Destination *getDestination( const char *name ); 51 vector<Destination>::iterator getDestination( const char *name );
52 52
53 void loadServers(); 53 void loadServers();
54 void reloadServerData( ); 54 void reloadServerData( );
55 55
56 void writeOutIpkgConf(); 56 void writeOutIpkgConf();
57 57
58 static QString getAvailableCategories() { return availableCategories; } 58 static QString getAvailableCategories() { return availableCategories; }
59 static void setAvailableCategories( QString section ); 59 static void setAvailableCategories( QString section );
60 60
61private: 61private:
62 static QString availableCategories; 62 static QString availableCategories;
63 QString activeServer; 63 QString activeServer;
64 QString httpProxy; 64 QString httpProxy;
65 QString ftpProxy; 65 QString ftpProxy;
66 QString proxyUsername; 66 QString proxyUsername;
67 QString proxyPassword; 67 QString proxyPassword;
68 68
69 vector<Server> serverList; 69 vector<Server> serverList;
70 vector<Destination> destList; 70 vector<Destination> destList;
71}; 71};
72 72
73#endif 73#endif
diff --git a/noncore/settings/aqpkg/global.h b/noncore/settings/aqpkg/global.h
index fcec643..ddfb3ac 100644
--- a/noncore/settings/aqpkg/global.h
+++ b/noncore/settings/aqpkg/global.h
@@ -1,80 +1,80 @@
1/*************************************************************************** 1/***************************************************************************
2 global.h - description 2 global.h - description
3 ------------------- 3 -------------------
4 begin : Mon Aug 26 2002 4 begin : Mon Aug 26 2002
5 copyright : (C) 2002 by Andy Qua 5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk 6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#ifndef __GLOBAL_H 18#ifndef __GLOBAL_H
19#define __GLOBAL_H 19#define __GLOBAL_H
20 20
21#define VERSION_TEXT "AQPkg Version 1.3" 21#define VERSION_TEXT "AQPkg Version 1.4"
22 22
23// Uncomment the below line to run on a Linux box rather than a Zaurus 23// Uncomment the below line to run on a Linux box rather than a Zaurus
24// box this allows you to change where root is, and where to load config files from 24// box this allows you to change where root is, and where to load config files from
25// #define X86 25// #define X86
26 26
27// Sets up location of ipkg.conf and root directory 27// Sets up location of ipkg.conf and root directory
28#ifdef QWS 28#ifdef QWS
29 29
30#ifndef X86 30#ifndef X86
31 31
32// Running QT/Embedded on an arm processor 32// Running QT/Embedded on an arm processor
33#define IPKG_CONF "/etc/ipkg.conf" 33#define IPKG_CONF "/etc/ipkg.conf"
34#define ROOT "/" 34#define ROOT "/"
35#define IPKG_DIR "/usr/lib/ipkg/" 35#define IPKG_DIR "/usr/lib/ipkg/"
36 36
37#else 37#else
38 38
39// Running QT/Embedded on a X86 linux box 39// Running QT/Embedded on a X86 linux box
40#define IPKG_CONF "/home/andy/projects/aqpkg/aqpkg/data/ipkg.conf" 40#define IPKG_CONF "/home/andy/projects/aqpkg/aqpkg/data/ipkg.conf"
41#define ROOT "/home/andy/projects/aqpkg/aqpkg/data/root" 41#define ROOT "/home/andy/projects/aqpkg/aqpkg/data/root"
42#define IPKG_DIR "/home/andy/projects/aqpkg/aqpkg/data/" 42#define IPKG_DIR "/home/andy/projects/aqpkg/aqpkg/data/"
43 43
44#endif 44#endif
45 45
46#else 46#else
47 47
48// Running QT on a X86 linux box 48// Running QT on a X86 linux box
49#define IPKG_CONF "/home/andy/projects/aqpkg/aqpkg/data/ipkg.conf" 49#define IPKG_CONF "/home/andy/projects/aqpkg/aqpkg/data/ipkg.conf"
50#define ROOT "/home/andy/projects/aqpkg/aqpkg/data/root" 50#define ROOT "/home/andy/projects/aqpkg/aqpkg/data/root"
51#define IPKG_DIR "/home/andy/projects/aqpkg/aqpkg/data/" 51#define IPKG_DIR "/home/andy/projects/aqpkg/aqpkg/data/"
52 52
53#endif 53#endif
54 54
55 55
56// Uncomment the below line to turn on memory checking 56// Uncomment the below line to turn on memory checking
57//#define _DEBUG 1 57//#define _DEBUG 1
58 58
59#ifndef __MEMFILE_C 59#ifndef __MEMFILE_C
60#ifdef _DEBUG 60#ifdef _DEBUG
61void * operator new(unsigned int size,const char *file, int line); 61void * operator new(unsigned int size,const char *file, int line);
62void operator delete(void *p); 62void operator delete(void *p);
63#endif 63#endif
64 64
65#ifdef _DEBUG 65#ifdef _DEBUG
66#define DEBUG_NEW new(__FILE__, __LINE__) 66#define DEBUG_NEW new(__FILE__, __LINE__)
67//#define DEBUG_NEW new 67//#define DEBUG_NEW new
68#else 68#else
69#define DEBUG_NEW new 69#define DEBUG_NEW new
70#endif 70#endif
71 71
72#define new DEBUG_NEW 72#define new DEBUG_NEW
73#endif 73#endif
74 74
75 75
76void AddTrack(long addr, long asize, const char *fname, long lnum); 76void AddTrack(long addr, long asize, const char *fname, long lnum);
77void RemoveTrack(long addr); 77void RemoveTrack(long addr);
78void DumpUnfreed(); 78void DumpUnfreed();
79 79
80#endif 80#endif
diff --git a/noncore/settings/aqpkg/installdlgimpl.cpp b/noncore/settings/aqpkg/installdlgimpl.cpp
index b297437..db9a259 100644
--- a/noncore/settings/aqpkg/installdlgimpl.cpp
+++ b/noncore/settings/aqpkg/installdlgimpl.cpp
@@ -1,242 +1,242 @@
1/*************************************************************************** 1/***************************************************************************
2 installdlgimpl.cpp - description 2 installdlgimpl.cpp - description
3 ------------------- 3 -------------------
4 begin : Mon Aug 26 2002 4 begin : Mon Aug 26 2002
5 copyright : (C) 2002 by Andy Qua 5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk 6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#ifdef QWS 18#ifdef QWS
19#include <qpe/config.h> 19#include <qpe/config.h>
20#endif 20#endif
21 21
22#include <qmultilineedit.h> 22#include <qmultilineedit.h>
23#include <qdialog.h> 23#include <qdialog.h>
24#include <qcombobox.h> 24#include <qcombobox.h>
25#include <qcheckbox.h> 25#include <qcheckbox.h>
26#include <qpushbutton.h> 26#include <qpushbutton.h>
27 27
28 28
29#include "datamgr.h" 29#include "datamgr.h"
30#include "instoptionsimpl.h" 30#include "instoptionsimpl.h"
31#include "destination.h" 31#include "destination.h"
32#include "installdlgimpl.h" 32#include "installdlgimpl.h"
33#include "global.h" 33#include "global.h"
34 34
35InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl ) 35InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl )
36 : InstallDlg( parent, name, modal, fl ) 36 : InstallDlg( parent, name, modal, fl )
37{ 37{
38 pIpkg = 0; 38 pIpkg = 0;
39 upgradePackages = false; 39 upgradePackages = false;
40 dataMgr = dataManager; 40 dataMgr = dataManager;
41 vector<Destination>::iterator dit; 41 vector<Destination>::iterator dit;
42 42
43 QString defaultDest = "root"; 43 QString defaultDest = "root";
44#ifdef QWS 44#ifdef QWS
45 Config cfg( "aqpkg" ); 45 Config cfg( "aqpkg" );
46 cfg.setGroup( "settings" ); 46 cfg.setGroup( "settings" );
47 defaultDest = cfg.readEntry( "dest", "root" ); 47 defaultDest = cfg.readEntry( "dest", "root" );
48 48
49 // Grab flags - Turn MAKE_LINKS on by default (if no flags found) 49 // Grab flags - Turn MAKE_LINKS on by default (if no flags found)
50 flags = cfg.readNumEntry( "installFlags", 0 ); 50 flags = cfg.readNumEntry( "installFlags", 0 );
51#else 51#else
52 flags = 0; 52 flags = 0;
53#endif 53#endif
54 54
55 // Output text is read only 55 // Output text is read only
56 output->setReadOnly( true ); 56 output->setReadOnly( true );
57 QFont f( "helvetica" ); 57 QFont f( "helvetica" );
58 f.setPointSize( 10 ); 58 f.setPointSize( 10 );
59 output->setFont( f ); 59 output->setFont( f );
60 60
61 61
62 // setup destination data 62 // setup destination data
63 int defIndex = 0; 63 int defIndex = 0;
64 int i; 64 int i;
65 for ( i = 0 , dit = dataMgr->getDestinationList().begin() ; dit != dataMgr->getDestinationList().end() ; ++dit, ++i ) 65 for ( i = 0 , dit = dataMgr->getDestinationList().begin() ; dit != dataMgr->getDestinationList().end() ; ++dit, ++i )
66 { 66 {
67 destination->insertItem( dit->getDestinationName() ); 67 destination->insertItem( dit->getDestinationName() );
68 if ( dit->getDestinationName() == defaultDest ) 68 if ( dit->getDestinationName() == defaultDest )
69 defIndex = i; 69 defIndex = i;
70 } 70 }
71 71
72 destination->setCurrentItem( defIndex ); 72 destination->setCurrentItem( defIndex );
73 73
74 vector<InstallData>::iterator it; 74 vector<InstallData>::iterator it;
75 // setup package data 75 // setup package data
76 QString remove = "Remove\n"; 76 QString remove = "Remove\n";
77 QString install = "\nInstall\n"; 77 QString install = "\nInstall\n";
78 QString upgrade = "\nUpgrade\n"; 78 QString upgrade = "\nUpgrade\n";
79 for ( it = packageList.begin() ; it != packageList.end() ; ++it ) 79 for ( it = packageList.begin() ; it != packageList.end() ; ++it )
80 { 80 {
81 InstallData item = *it; 81 InstallData item = *it;
82 if ( item.option == "I" ) 82 if ( item.option == "I" )
83 { 83 {
84 installList.push_back( item ); 84 installList.push_back( item );
85 install += " " + item.packageName + "\n"; 85 install += " " + item.packageName + "\n";
86 } 86 }
87 else if ( item.option == "D" ) 87 else if ( item.option == "D" )
88 { 88 {
89 removeList.push_back( item ); 89 removeList.push_back( item );
90 remove += " " + item.packageName + "\n"; 90 remove += " " + item.packageName + "\n";
91 } 91 }
92 else if ( item.option == "U" || item.option == "R" ) 92 else if ( item.option == "U" || item.option == "R" )
93 { 93 {
94 updateList.push_back( item ); 94 updateList.push_back( item );
95 QString type = " (Upgrade)"; 95 QString type = " (Upgrade)";
96 if ( item.option == "R" ) 96 if ( item.option == "R" )
97 type = " (ReInstall)"; 97 type = " (ReInstall)";
98 upgrade += " " + item.packageName + type + "\n"; 98 upgrade += " " + item.packageName + type + "\n";
99 } 99 }
100 } 100 }
101 101
102 output->setText( remove + install + upgrade ); 102 output->setText( remove + install + upgrade );
103} 103}
104 104
105InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, QWidget *parent, const char *name, bool modal, WFlags fl ) 105InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, QWidget *parent, const char *name, bool modal, WFlags fl )
106 : InstallDlg( parent, name, modal, fl ) 106 : InstallDlg( parent, name, modal, fl )
107{ 107{
108 pIpkg = ipkg; 108 pIpkg = ipkg;
109 output->setText( initialText ); 109 output->setText( initialText );
110} 110}
111 111
112 112
113InstallDlgImpl::~InstallDlgImpl() 113InstallDlgImpl::~InstallDlgImpl()
114{ 114{
115} 115}
116 116
117bool InstallDlgImpl :: showDlg() 117bool InstallDlgImpl :: showDlg()
118{ 118{
119 showMaximized(); 119 showMaximized();
120 bool ret = exec(); 120 bool ret = exec();
121 121
122 return ret; 122 return ret;
123} 123}
124 124
125void InstallDlgImpl :: optionsSelected() 125void InstallDlgImpl :: optionsSelected()
126{ 126{
127 InstallOptionsDlgImpl opt( flags, this, "Option", true ); 127 InstallOptionsDlgImpl opt( flags, this, "Option", true );
128 opt.exec(); 128 opt.exec();
129 129
130 // set options selected from dialog 130 // set options selected from dialog
131 flags = 0; 131 flags = 0;
132 if ( opt.forceDepends->isChecked() ) 132 if ( opt.forceDepends->isChecked() )
133 flags |= FORCE_DEPENDS; 133 flags |= FORCE_DEPENDS;
134 if ( opt.forceReinstall->isChecked() ) 134 if ( opt.forceReinstall->isChecked() )
135 flags |= FORCE_REINSTALL; 135 flags |= FORCE_REINSTALL;
136 if ( opt.forceRemove->isChecked() ) 136 if ( opt.forceRemove->isChecked() )
137 flags |= FORCE_REMOVE; 137 flags |= FORCE_REMOVE;
138 if ( opt.forceOverwrite->isChecked() ) 138 if ( opt.forceOverwrite->isChecked() )
139 flags |= FORCE_OVERWRITE; 139 flags |= FORCE_OVERWRITE;
140 140
141#ifdef QWS 141#ifdef QWS
142 Config cfg( "aqpkg" ); 142 Config cfg( "aqpkg" );
143 cfg.setGroup( "settings" ); 143 cfg.setGroup( "settings" );
144 cfg.writeEntry( "installFlags", flags ); 144 cfg.writeEntry( "installFlags", flags );
145#endif 145#endif
146} 146}
147 147
148void InstallDlgImpl :: installSelected() 148void InstallDlgImpl :: installSelected()
149{ 149{
150 if ( btnInstall->text() == "Close" ) 150 if ( btnInstall->text() == "Close" )
151 { 151 {
152 done( 1 ); 152 done( 1 );
153 return; 153 return;
154 } 154 }
155 155
156 btnInstall->setEnabled( false ); 156 btnInstall->setEnabled( false );
157 157
158 if ( pIpkg ) 158 if ( pIpkg )
159 { 159 {
160 output->setText( "" ); 160 output->setText( "" );
161 161
162 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 162 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
163 pIpkg->runIpkg(); 163 pIpkg->runIpkg();
164 } 164 }
165 else 165 else
166 { 166 {
167 output->setText( "" ); 167 output->setText( "" );
168 Destination *d = dataMgr->getDestination( destination->currentText() ); 168 vector<Destination>::iterator d = dataMgr->getDestination( destination->currentText() );
169 QString dest = d->getDestinationName(); 169 QString dest = d->getDestinationName();
170 QString destDir = d->getDestinationPath(); 170 QString destDir = d->getDestinationPath();
171 int instFlags = flags; 171 int instFlags = flags;
172 if ( d->linkToRoot() ) 172 if ( d->linkToRoot() )
173 instFlags |= MAKE_LINKS; 173 instFlags |= MAKE_LINKS;
174 174
175#ifdef QWS 175#ifdef QWS
176 // Save settings 176 // Save settings
177 Config cfg( "aqpkg" ); 177 Config cfg( "aqpkg" );
178 cfg.setGroup( "settings" ); 178 cfg.setGroup( "settings" );
179 cfg.writeEntry( "dest", dest ); 179 cfg.writeEntry( "dest", dest );
180#endif 180#endif
181 181
182 pIpkg = new Ipkg; 182 pIpkg = new Ipkg;
183 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 183 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
184 184
185 // First run through the remove list, then the install list then the upgrade list 185 // First run through the remove list, then the install list then the upgrade list
186 vector<InstallData>::iterator it; 186 vector<InstallData>::iterator it;
187 pIpkg->setOption( "remove" ); 187 pIpkg->setOption( "remove" );
188 for ( it = removeList.begin() ; it != removeList.end() ; ++it ) 188 for ( it = removeList.begin() ; it != removeList.end() ; ++it )
189 { 189 {
190 pIpkg->setDestination( it->destination->getDestinationName() ); 190 pIpkg->setDestination( it->destination->getDestinationName() );
191 pIpkg->setDestinationDir( it->destination->getDestinationPath() ); 191 pIpkg->setDestinationDir( it->destination->getDestinationPath() );
192 pIpkg->setPackage( it->packageName ); 192 pIpkg->setPackage( it->packageName );
193 193
194 int tmpFlags = flags; 194 int tmpFlags = flags;
195 if ( it->destination->linkToRoot() ) 195 if ( it->destination->linkToRoot() )
196 tmpFlags |= MAKE_LINKS; 196 tmpFlags |= MAKE_LINKS;
197 197
198 pIpkg->setFlags( tmpFlags ); 198 pIpkg->setFlags( tmpFlags );
199 pIpkg->runIpkg(); 199 pIpkg->runIpkg();
200 } 200 }
201 201
202 pIpkg->setOption( "install" ); 202 pIpkg->setOption( "install" );
203 pIpkg->setDestination( dest ); 203 pIpkg->setDestination( dest );
204 pIpkg->setDestinationDir( destDir ); 204 pIpkg->setDestinationDir( destDir );
205 pIpkg->setFlags( instFlags ); 205 pIpkg->setFlags( instFlags );
206 for ( it = installList.begin() ; it != installList.end() ; ++it ) 206 for ( it = installList.begin() ; it != installList.end() ; ++it )
207 { 207 {
208 pIpkg->setPackage( it->packageName ); 208 pIpkg->setPackage( it->packageName );
209 pIpkg->runIpkg(); 209 pIpkg->runIpkg();
210 } 210 }
211 211
212 flags |= FORCE_REINSTALL; 212 flags |= FORCE_REINSTALL;
213 for ( it = updateList.begin() ; it != updateList.end() ; ++it ) 213 for ( it = updateList.begin() ; it != updateList.end() ; ++it )
214 { 214 {
215 if ( it->option == "R" ) 215 if ( it->option == "R" )
216 pIpkg->setOption( "reinstall" ); 216 pIpkg->setOption( "reinstall" );
217 else 217 else
218 pIpkg->setOption( "upgrade" ); 218 pIpkg->setOption( "upgrade" );
219 pIpkg->setDestination( it->destination->getDestinationName() ); 219 pIpkg->setDestination( it->destination->getDestinationName() );
220 pIpkg->setDestinationDir( it->destination->getDestinationPath() ); 220 pIpkg->setDestinationDir( it->destination->getDestinationPath() );
221 pIpkg->setPackage( it->packageName ); 221 pIpkg->setPackage( it->packageName );
222 222
223 int tmpFlags = flags; 223 int tmpFlags = flags;
224 if ( it->destination->linkToRoot() && it->recreateLinks ) 224 if ( it->destination->linkToRoot() && it->recreateLinks )
225 tmpFlags |= MAKE_LINKS; 225 tmpFlags |= MAKE_LINKS;
226 pIpkg->setFlags( tmpFlags ); 226 pIpkg->setFlags( tmpFlags );
227 pIpkg->runIpkg(); 227 pIpkg->runIpkg();
228 } 228 }
229 229
230 delete pIpkg; 230 delete pIpkg;
231 } 231 }
232 232
233 btnInstall->setEnabled( true ); 233 btnInstall->setEnabled( true );
234 btnInstall->setText( tr( "Close" ) ); 234 btnInstall->setText( tr( "Close" ) );
235} 235}
236 236
237void InstallDlgImpl :: displayText(const QString &text ) 237void InstallDlgImpl :: displayText(const QString &text )
238{ 238{
239 QString t = output->text() + "\n" + text; 239 QString t = output->text() + "\n" + text;
240 output->setText( t ); 240 output->setText( t );
241 output->setCursorPosition( output->numLines(), 0 ); 241 output->setCursorPosition( output->numLines(), 0 );
242} 242}
diff --git a/noncore/settings/aqpkg/ipkg.cpp b/noncore/settings/aqpkg/ipkg.cpp
index 452eca3..8de3c48 100644
--- a/noncore/settings/aqpkg/ipkg.cpp
+++ b/noncore/settings/aqpkg/ipkg.cpp
@@ -1,444 +1,445 @@
1/*************************************************************************** 1/***************************************************************************
2 ipkg.cpp - description 2 ipkg.cpp - description
3 ------------------- 3 -------------------
4 begin : Sat Aug 31 2002 4 begin : Sat Aug 31 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>
19using namespace std; 20using namespace std;
20 21
21#include <stdio.h> 22#include <stdio.h>
22#include <unistd.h> 23#include <unistd.h>
23 24
24#ifdef QWS 25#ifdef QWS
25#include <qpe/qpeapplication.h> 26#include <qpe/qpeapplication.h>
26#else 27#else
27#include <qapplication.h> 28#include <qapplication.h>
28#endif 29#endif
29#include <qdir.h> 30#include <qdir.h>
30#include <qtextstream.h> 31#include <qtextstream.h>
31 32
32#include "utils.h" 33#include "utils.h"
33#include "ipkg.h" 34#include "ipkg.h"
34#include "global.h" 35#include "global.h"
35 36
36Ipkg :: Ipkg() 37Ipkg :: Ipkg()
37{ 38{
38} 39}
39 40
40Ipkg :: ~Ipkg() 41Ipkg :: ~Ipkg()
41{ 42{
42} 43}
43 44
44// Option is what we are going to do - install, upgrade, download, reinstall 45// Option is what we are going to do - install, upgrade, download, reinstall
45// package is the package name to install - either a fully qualified path and ipk 46// package is the package name to install - either a fully qualified path and ipk
46// file (if stored locally) or just the name of the package (for a network package) 47// file (if stored locally) or just the name of the package (for a network package)
47// packageName is the package name - (for a network package this will be the same as 48// packageName is the package name - (for a network package this will be the same as
48// package parameter) 49// package parameter)
49// dest is the destination alias (from ipk.conf) 50// dest is the destination alias (from ipk.conf)
50// destDir is the dir that the destination alias points to (used to link to root) 51// destDir is the dir that the destination alias points to (used to link to root)
51// flags is the ipkg options flags 52// flags is the ipkg options flags
52// dir is the directory to run ipkg in (defaults to "") 53// dir is the directory to run ipkg in (defaults to "")
53bool Ipkg :: runIpkg( ) 54bool Ipkg :: runIpkg( )
54{ 55{
55 bool ret = false; 56 bool ret = false;
56 57
57 QDir::setCurrent( "/tmp" ); 58 QDir::setCurrent( "/tmp" );
58 QString cmd = ""; 59 QString cmd = "";
59 60
60 if ( runtimeDir != "" ) 61 if ( runtimeDir != "" )
61 { 62 {
62 cmd += "cd "; 63 cmd += "cd ";
63 cmd += runtimeDir; 64 cmd += runtimeDir;
64 cmd += " ; "; 65 cmd += " ; ";
65 } 66 }
66 cmd += "ipkg -force-defaults"; 67 cmd += "ipkg -force-defaults";
67 68
68 // only set the destination for an install operation 69 // only set the destination for an install operation
69 if ( option == "install" ) 70 if ( option == "install" )
70 cmd += " -dest "+ destination; 71 cmd += " -dest "+ destination;
71 72
72 73
73 if ( option != "update" && option != "download" ) 74 if ( option != "update" && option != "download" )
74 { 75 {
75 if ( flags & FORCE_DEPENDS ) 76 if ( flags & FORCE_DEPENDS )
76 cmd += " -force-depends"; 77 cmd += " -force-depends";
77 if ( flags & FORCE_REINSTALL ) 78 if ( flags & FORCE_REINSTALL )
78 cmd += " -force-reinstall"; 79 cmd += " -force-reinstall";
79 if ( flags & FORCE_REMOVE ) 80 if ( flags & FORCE_REMOVE )
80 cmd += " -force-removal-of-essential-packages"; 81 cmd += " -force-removal-of-essential-packages";
81 if ( flags & FORCE_OVERWRITE ) 82 if ( flags & FORCE_OVERWRITE )
82 cmd += " -force-overwrite"; 83 cmd += " -force-overwrite";
83 84
84 // Handle make links 85 // Handle make links
85 // Rules - If make links is switched on, create links to root 86 // Rules - If make links is switched on, create links to root
86 // if destDir is NOT / 87 // if destDir is NOT /
87 if ( flags & MAKE_LINKS ) 88 if ( flags & MAKE_LINKS )
88 { 89 {
89 // If destDir == / turn off make links as package is being insalled 90 // If destDir == / turn off make links as package is being insalled
90 // to root already. 91 // to root already.
91 if ( destDir == "/" ) 92 if ( destDir == "/" )
92 flags ^= MAKE_LINKS; 93 flags ^= MAKE_LINKS;
93 } 94 }
94 } 95 }
95 96
96#ifdef X86 97#ifdef X86
97 cmd += " -f "; 98 cmd += " -f ";
98 cmd += IPKG_CONF; 99 cmd += IPKG_CONF;
99#endif 100#endif
100 101
101 102
102 if ( option == "reinstall" ) 103 if ( option == "reinstall" )
103 cmd += " install"; 104 cmd += " install";
104 else 105 else
105 cmd += " " + option; 106 cmd += " " + option;
106 if ( package != "" ) 107 if ( package != "" )
107 cmd += " " + package; 108 cmd += " " + package;
108 cmd += " 2>&1"; 109 cmd += " 2>&1";
109 110
110 111
111 if ( package != "" ) 112 if ( package != "" )
112 emit outputText( QString( "Dealing with package " ) + package ); 113 emit outputText( QString( "Dealing with package " ) + package );
113 114
114 qApp->processEvents(); 115 qApp->processEvents();
115 116
116 // If we are removing packages and make links option is selected 117 // If we are removing packages and make links option is selected
117 // create the links 118 // create the links
118 if ( option == "remove" || option == "reinstall" ) 119 if ( option == "remove" || option == "reinstall" )
119 { 120 {
120 createLinks = false; 121 createLinks = false;
121 if ( flags & MAKE_LINKS ) 122 if ( flags & MAKE_LINKS )
122 { 123 {
123 emit outputText( QString( "Removing symbolic links...\n" ) ); 124 emit outputText( QString( "Removing symbolic links...\n" ) );
124 linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir ); 125 linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir );
125 emit outputText( QString( " " ) ); 126 emit outputText( QString( " " ) );
126 } 127 }
127 } 128 }
128 129
129 emit outputText( cmd ); 130 emit outputText( cmd );
130 131
131 // Execute command 132 // Execute command
132 dependantPackages = new QList<QString>; 133 dependantPackages = new QList<QString>;
133 dependantPackages->setAutoDelete( true ); 134 dependantPackages->setAutoDelete( true );
134 135
135 ret = executeIpkgCommand( cmd, option ); 136 ret = executeIpkgCommand( cmd, option );
136 137
137 if ( option == "install" || option == "reinstall" ) 138 if ( option == "install" || option == "reinstall" )
138 { 139 {
139 // If we are not removing packages and make links option is selected 140 // If we are not removing packages and make links option is selected
140 // create the links 141 // create the links
141 createLinks = true; 142 createLinks = true;
142 if ( flags & MAKE_LINKS ) 143 if ( flags & MAKE_LINKS )
143 { 144 {
144 emit outputText( " " ); 145 emit outputText( " " );
145 emit outputText( QString( "Creating symbolic links for " )+ package ); 146 emit outputText( QString( "Creating symbolic links for " )+ package );
146 147
147 linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir ); 148 linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir );
148 149
149 // link dependant packages that were installed with this release 150 // link dependant packages that were installed with this release
150 QString *pkg; 151 QString *pkg;
151 for ( pkg = dependantPackages->first(); pkg != 0; pkg = dependantPackages->next() ) 152 for ( pkg = dependantPackages->first(); pkg != 0; pkg = dependantPackages->next() )
152 { 153 {
153 if ( *pkg == package ) 154 if ( *pkg == package )
154 continue; 155 continue;
155 emit outputText( " " ); 156 emit outputText( " " );
156 emit outputText( QString( "Creating symbolic links for " )+ (*pkg) ); 157 emit outputText( QString( "Creating symbolic links for " )+ (*pkg) );
157 linkPackage( Utils::getPackageNameFromIpkFilename( *pkg ), destination, destDir ); 158 linkPackage( Utils::getPackageNameFromIpkFilename( *pkg ), destination, destDir );
158 } 159 }
159 } 160 }
160 } 161 }
161 162
162 delete dependantPackages; 163 delete dependantPackages;
163 164
164 // Finally, if we are removing a package, remove its entry from the <destdir>/usr/lib/ipkg/status file 165 // Finally, if we are removing a package, remove its entry from the <destdir>/usr/lib/ipkg/status file
165 // to workaround an ipkg bug which stops reinstall to a different location 166 // to workaround an ipkg bug which stops reinstall to a different location
166 if ( option == "remove" ) 167 if ( option == "remove" )
167 removeStatusEntry(); 168 removeStatusEntry();
168 169
169 170
170// emit outputText( QString( "Finished - status=" ) + (ret ? "success" : "failure") ); 171// emit outputText( QString( "Finished - status=" ) + (ret ? "success" : "failure") );
171 emit outputText( "Finished" ); 172 emit outputText( "Finished" );
172 emit outputText( "" ); 173 emit outputText( "" );
173 return ret; 174 return ret;
174} 175}
175 176
176void Ipkg :: removeStatusEntry() 177void Ipkg :: removeStatusEntry()
177{ 178{
178 QString statusFile = destDir; 179 QString statusFile = destDir;
179 if ( statusFile.right( 1 ) != "/" ) 180 if ( statusFile.right( 1 ) != "/" )
180 statusFile += "/"; 181 statusFile += "/";
181 statusFile += "usr/lib/ipkg/status"; 182 statusFile += "usr/lib/ipkg/status";
182 QString outStatusFile = statusFile + ".tmp"; 183 QString outStatusFile = statusFile + ".tmp";
183 184
184 emit outputText( "" ); 185 emit outputText( "" );
185 emit outputText( "Removing status entry..." ); 186 emit outputText( "Removing status entry..." );
186 emit outputText( QString( "status file - " )+ statusFile ); 187 emit outputText( QString( "status file - " )+ statusFile );
187 emit outputText( QString( "package - " )+ package ); 188 emit outputText( QString( "package - " )+ package );
188 189
189 ifstream in( statusFile ); 190 ifstream in( statusFile );
190 ofstream out( outStatusFile ); 191 ofstream out( outStatusFile );
191 if ( !in.is_open() ) 192 if ( !in.is_open() )
192 { 193 {
193 emit outputText( QString( "Couldn't open status file - " )+ statusFile ); 194 emit outputText( QString( "Couldn't open status file - " )+ statusFile );
194 return; 195 return;
195 } 196 }
196 197
197 if ( !out.is_open() ) 198 if ( !out.is_open() )
198 { 199 {
199 emit outputText( QString( "Couldn't create tempory status file - " )+ outStatusFile ); 200 emit outputText( QString( "Couldn't create tempory status file - " )+ outStatusFile );
200 return; 201 return;
201 } 202 }
202 203
203 char line[1001]; 204 char line[1001];
204 char k[21]; 205 char k[21];
205 char v[1001]; 206 char v[1001];
206 QString key; 207 QString key;
207 QString value; 208 QString value;
208 do 209 do
209 { 210 {
210 in.getline( line, 1000 ); 211 in.getline( line, 1000 );
211 if ( in.eof() ) 212 if ( in.eof() )
212 continue; 213 continue;
213 214
214 k[0] = '\0'; 215 k[0] = '\0';
215 v[0] = '\0'; 216 v[0] = '\0';
216 217
217 sscanf( line, "%[^:]: %[^\n]", k, v ); 218 sscanf( line, "%[^:]: %[^\n]", k, v );
218 key = k; 219 key = k;
219 value = v; 220 value = v;
220 key = key.stripWhiteSpace(); 221 key = key.stripWhiteSpace();
221 value = value.stripWhiteSpace(); 222 value = value.stripWhiteSpace();
222 if ( key == "Package" && value == package ) 223 if ( key == "Package" && value == package )
223 { 224 {
224 // Ignore all lines up to next empty 225 // Ignore all lines up to next empty
225 do 226 do
226 { 227 {
227 in.getline( line, 1000 ); 228 in.getline( line, 1000 );
228 if ( in.eof() || QString( line ).stripWhiteSpace() == "" ) 229 if ( in.eof() || QString( line ).stripWhiteSpace() == "" )
229 continue; 230 continue;
230 } while ( !in.eof() && QString( line ).stripWhiteSpace() != "" ); 231 } while ( !in.eof() && QString( line ).stripWhiteSpace() != "" );
231 } 232 }
232 233
233 out << line << endl; 234 out << line << endl;
234 } while ( !in.eof() ); 235 } while ( !in.eof() );
235 236
236 in.close(); 237 in.close();
237 out.close(); 238 out.close();
238 239
239 // Remove old status file and put tmp stats file in its place 240 // Remove old status file and put tmp stats file in its place
240 remove( statusFile ); 241 remove( statusFile );
241 rename( outStatusFile, statusFile ); 242 rename( outStatusFile, statusFile );
242} 243}
243 244
244 245
245int Ipkg :: executeIpkgCommand( QString &cmd, const QString option ) 246int Ipkg :: executeIpkgCommand( QString &cmd, const QString option )
246{ 247{
247 FILE *fp = NULL; 248 FILE *fp = NULL;
248 char line[130]; 249 char line[130];
249 QString lineStr, lineStrOld; 250 QString lineStr, lineStrOld;
250 int ret = false; 251 int ret = false;
251 252
252 fp = popen( (const char *) cmd, "r"); 253 fp = popen( (const char *) cmd, "r");
253 if ( fp == NULL ) 254 if ( fp == NULL )
254 { 255 {
255 cout << "Couldn't execute " << cmd << "! err = " << fp << endl; 256 cout << "Couldn't execute " << cmd << "! err = " << fp << endl;
256 QString text; 257 QString text;
257 text.sprintf( "Couldn't execute %s! See stdout for error code", (const char *)cmd ); 258 text.sprintf( "Couldn't execute %s! See stdout for error code", (const char *)cmd );
258 emit outputText( text ); 259 emit outputText( text );
259 } 260 }
260 else 261 else
261 { 262 {
262 while ( fgets( line, sizeof line, fp) != NULL ) 263 while ( fgets( line, sizeof line, fp) != NULL )
263 { 264 {
264 lineStr = line; 265 lineStr = line;
265 lineStr=lineStr.left( lineStr.length()-1 ); 266 lineStr=lineStr.left( lineStr.length()-1 );
266 267
267 if ( lineStr != lineStrOld ) 268 if ( lineStr != lineStrOld )
268 { 269 {
269 //See if we're finished 270 //See if we're finished
270 if ( option == "install" || option == "reinstall" ) 271 if ( option == "install" || option == "reinstall" )
271 { 272 {
272 // Need to keep track of any dependant packages that get installed 273 // Need to keep track of any dependant packages that get installed
273 // so that we can create links to them as necessary 274 // so that we can create links to them as necessary
274 if ( lineStr.startsWith( "Installing " ) ) 275 if ( lineStr.startsWith( "Installing " ) )
275 { 276 {
276 int start = lineStr.find( " " ) + 1; 277 int start = lineStr.find( " " ) + 1;
277 int end = lineStr.find( " ", start ); 278 int end = lineStr.find( " ", start );
278 QString *package = new QString( lineStr.mid( start, end-start ) ); 279 QString *package = new QString( lineStr.mid( start, end-start ) );
279 dependantPackages->append( package ); 280 dependantPackages->append( package );
280 } 281 }
281 } 282 }
282 283
283 if ( option == "update" ) 284 if ( option == "update" )
284 { 285 {
285 if (lineStr.contains("Updated list")) 286 if (lineStr.contains("Updated list"))
286 ret = true; 287 ret = true;
287 } 288 }
288 else if ( option == "download" ) 289 else if ( option == "download" )
289 { 290 {
290 if (lineStr.contains("Downloaded")) 291 if (lineStr.contains("Downloaded"))
291 ret = true; 292 ret = true;
292 } 293 }
293 else 294 else
294 { 295 {
295 if (lineStr.contains("Done")) 296 if (lineStr.contains("Done"))
296 ret = true; 297 ret = true;
297 } 298 }
298 299
299 emit outputText( lineStr ); 300 emit outputText( lineStr );
300 } 301 }
301 lineStrOld = lineStr; 302 lineStrOld = lineStr;
302 qApp->processEvents(); 303 qApp->processEvents();
303 } 304 }
304 pclose(fp); 305 pclose(fp);
305 } 306 }
306 307
307 return ret; 308 return ret;
308} 309}
309 310
310 311
311void Ipkg :: linkPackage( const QString &packFileName, const QString &dest, const QString &destDir ) 312void Ipkg :: linkPackage( const QString &packFileName, const QString &dest, const QString &destDir )
312{ 313{
313 if ( dest == "root" || dest == "/" ) 314 if ( dest == "root" || dest == "/" )
314 return; 315 return;
315 316
316 qApp->processEvents(); 317 qApp->processEvents();
317 QStringList *fileList = getList( packFileName, destDir ); 318 QStringList *fileList = getList( packFileName, destDir );
318 qApp->processEvents(); 319 qApp->processEvents();
319 processFileList( fileList, destDir ); 320 processFileList( fileList, destDir );
320 delete fileList; 321 delete fileList;
321} 322}
322 323
323QStringList* Ipkg :: getList( const QString &packageFilename, const QString &destDir ) 324QStringList* Ipkg :: getList( const QString &packageFilename, const QString &destDir )
324{ 325{
325 QString packageFileDir = destDir+"/usr/lib/ipkg/info/"+packageFilename+".list"; 326 QString packageFileDir = destDir+"/usr/lib/ipkg/info/"+packageFilename+".list";
326 QFile f( packageFileDir ); 327 QFile f( packageFileDir );
327 328
328 cout << "Try to open " << packageFileDir << endl; 329 cout << "Try to open " << packageFileDir << endl;
329 if ( !f.open(IO_ReadOnly) ) 330 if ( !f.open(IO_ReadOnly) )
330 { 331 {
331 // Couldn't open from dest, try from / 332 // Couldn't open from dest, try from /
332 cout << "Could not open:" << packageFileDir << endl; 333 cout << "Could not open:" << packageFileDir << endl;
333 f.close(); 334 f.close();
334 335
335 packageFileDir = "/usr/lib/ipkg/info/"+packageFilename+".list"; 336 packageFileDir = "/usr/lib/ipkg/info/"+packageFilename+".list";
336 f.setName( packageFileDir ); 337 f.setName( packageFileDir );
337// cout << "Try to open " << packageFileDir.latin1() << endl; 338// cout << "Try to open " << packageFileDir.latin1() << endl;
338 if ( ! f.open(IO_ReadOnly) ) 339 if ( ! f.open(IO_ReadOnly) )
339 { 340 {
340 cout << "Could not open:" << packageFileDir << endl; 341 cout << "Could not open:" << packageFileDir << endl;
341 emit outputText( QString( "Could not open :" ) + packageFileDir ); 342 emit outputText( QString( "Could not open :" ) + packageFileDir );
342 return (QStringList*)0; 343 return (QStringList*)0;
343 } 344 }
344 } 345 }
345 QStringList *fileList = new QStringList(); 346 QStringList *fileList = new QStringList();
346 QTextStream t( &f ); 347 QTextStream t( &f );
347 while ( !t.eof() ) 348 while ( !t.eof() )
348 *fileList += t.readLine(); 349 *fileList += t.readLine();
349 350
350 f.close(); 351 f.close();
351 return fileList; 352 return fileList;
352} 353}
353 354
354void Ipkg :: processFileList( const QStringList *fileList, const QString &destDir ) 355void Ipkg :: processFileList( const QStringList *fileList, const QString &destDir )
355{ 356{
356 if ( !fileList || fileList->isEmpty() ) 357 if ( !fileList || fileList->isEmpty() )
357 return; 358 return;
358 359
359 QString baseDir = ROOT; 360 QString baseDir = ROOT;
360 361
361 if ( createLinks == true ) 362 if ( createLinks == true )
362 { 363 {
363 for ( uint i=0; i < fileList->count(); i++ ) 364 for ( uint i=0; i < fileList->count(); i++ )
364 { 365 {
365 processLinkDir( (*fileList)[i], baseDir, destDir ); 366 processLinkDir( (*fileList)[i], baseDir, destDir );
366 qApp->processEvents(); 367 qApp->processEvents();
367 } 368 }
368 } 369 }
369 else 370 else
370 { 371 {
371 for ( int i = fileList->count()-1; i >= 0 ; i-- ) 372 for ( int i = fileList->count()-1; i >= 0 ; i-- )
372 { 373 {
373 processLinkDir( (*fileList)[i], baseDir, destDir ); 374 processLinkDir( (*fileList)[i], baseDir, destDir );
374 qApp->processEvents(); 375 qApp->processEvents();
375 } 376 }
376 } 377 }
377} 378}
378 379
379void Ipkg :: processLinkDir( const QString &file, const QString &destDir, const QString &baseDir ) 380void Ipkg :: processLinkDir( const QString &file, const QString &destDir, const QString &baseDir )
380{ 381{
381 382
382 QString sourceFile = baseDir + file; 383 QString sourceFile = baseDir + file;
383 384
384 QString linkFile = destDir; 385 QString linkFile = destDir;
385 if ( file.startsWith( "/" ) && destDir.right( 1 ) == "/" ) 386 if ( file.startsWith( "/" ) && destDir.right( 1 ) == "/" )
386 { 387 {
387 linkFile += file.mid( 1 ); 388 linkFile += file.mid( 1 );
388 } 389 }
389 else 390 else
390 { 391 {
391 linkFile += file; 392 linkFile += file;
392 } 393 }
393 QString text; 394 QString text;
394 if ( createLinks ) 395 if ( createLinks )
395 { 396 {
396 // If this file is a directory (ends with a /) and it doesn't exist, 397 // If this file is a directory (ends with a /) and it doesn't exist,
397 // we need to create it 398 // we need to create it
398 if ( file.right(1) == "/" ) 399 if ( file.right(1) == "/" )
399 { 400 {
400 QFileInfo f( linkFile ); 401 QFileInfo f( linkFile );
401 if ( !f.exists() ) 402 if ( !f.exists() )
402 { 403 {
403 emit outputText( QString( "Creating directory " ) + linkFile ); 404 emit outputText( QString( "Creating directory " ) + linkFile );
404 QDir d; 405 QDir d;
405 d.mkdir( linkFile, true ); 406 d.mkdir( linkFile, true );
406 } 407 }
407 else 408 else
408 emit outputText( QString( "Directory " ) + linkFile + " exists" ); 409 emit outputText( QString( "Directory " ) + linkFile + " exists" );
409 410
410 } 411 }
411 else 412 else
412 { 413 {
413 int rc = symlink( sourceFile, linkFile ); 414 int rc = symlink( sourceFile, linkFile );
414 text = (rc == 0 ? "Linked " : "Failed to link "); 415 text = (rc == 0 ? "Linked " : "Failed to link ");
415 text += sourceFile + " to " + linkFile; 416 text += sourceFile + " to " + linkFile;
416 emit outputText( text ); 417 emit outputText( text );
417 } 418 }
418 } 419 }
419 else 420 else
420 { 421 {
421 QFileInfo f( linkFile ); 422 QFileInfo f( linkFile );
422 if ( f.exists() ) 423 if ( f.exists() )
423 { 424 {
424 if ( f.isFile() ) 425 if ( f.isFile() )
425 { 426 {
426 QFile f( linkFile ); 427 QFile f( linkFile );
427 bool rc = f.remove(); 428 bool rc = f.remove();
428 429
429 text = (rc ? "Removed " : "Failed to remove "); 430 text = (rc ? "Removed " : "Failed to remove ");
430 text += linkFile; 431 text += linkFile;
431 emit outputText( text ); 432 emit outputText( text );
432 } 433 }
433 else if ( f.isDir() ) 434 else if ( f.isDir() )
434 { 435 {
435 QDir d; 436 QDir d;
436 bool rc = d.rmdir( linkFile, true ); 437 bool rc = d.rmdir( linkFile, true );
437 text = (rc ? "Removed " : "Failed to remove "); 438 text = (rc ? "Removed " : "Failed to remove ");
438 text += linkFile; 439 text += linkFile;
439 emit outputText( text ); 440 emit outputText( text );
440 } 441 }
441 } 442 }
442 } 443 }
443 444
444} 445}
diff --git a/noncore/settings/aqpkg/letterpushbutton.cpp b/noncore/settings/aqpkg/letterpushbutton.cpp
index afe25d8..ca96c6c 100644
--- a/noncore/settings/aqpkg/letterpushbutton.cpp
+++ b/noncore/settings/aqpkg/letterpushbutton.cpp
@@ -1,34 +1,34 @@
1/*************************************************************************** 1/***************************************************************************
2 letterpushbutton.cpp - description 2 letterpushbutton.cpp - description
3 ------------------- 3 -------------------
4 begin : Wed Oct 16 2002 4 begin : Wed Oct 16 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 "letterpushbutton.h" 18#include "letterpushbutton.h"
19 19
20LetterPushButton :: LetterPushButton( const QString &text, QWidget *parent, const char *name=0 ) 20LetterPushButton :: LetterPushButton( const QString &text, QWidget *parent, const char *name )
21 : QPushButton( text, parent, name ) 21 : QPushButton( text, parent, name )
22{ 22{
23 connect( this, SIGNAL(released()), this, SLOT(released_emmitor()) ); 23 connect( this, SIGNAL(released()), this, SLOT(released_emmitor()) );
24} 24}
25 25
26LetterPushButton :: ~LetterPushButton() 26LetterPushButton :: ~LetterPushButton()
27{ 27{
28} 28}
29 29
30void LetterPushButton :: released_emmitor() 30void LetterPushButton :: released_emmitor()
31{ 31{
32 emit released( text() ); 32 emit released( text() );
33} 33}
34 34
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp
index 0141359..3ddc582 100644
--- a/noncore/settings/aqpkg/mainwin.cpp
+++ b/noncore/settings/aqpkg/mainwin.cpp
@@ -1,209 +1,210 @@
1/*************************************************************************** 1/***************************************************************************
2 mainwin.cpp - description 2 mainwin.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 <iostream> 18#include <iostream>
19using namespace std;
19 20
20#include <qmenubar.h> 21#include <qmenubar.h>
21#include <qpopupmenu.h> 22#include <qpopupmenu.h>
22#include <qmessagebox.h> 23#include <qmessagebox.h>
23 24
24#include "mainwin.h" 25#include "mainwin.h"
25#include "datamgr.h" 26#include "datamgr.h"
26#include "networkpkgmgr.h" 27#include "networkpkgmgr.h"
27#include "settingsimpl.h" 28#include "settingsimpl.h"
28#include "helpwindow.h" 29#include "helpwindow.h"
29#include "utils.h" 30#include "utils.h"
30#include "global.h" 31#include "global.h"
31 32
32MainWindow :: MainWindow( QWidget *p, char *name ) 33MainWindow :: MainWindow( QWidget *p, char *name )
33 :QMainWindow( p, name ) 34 :QMainWindow( p, name )
34{ 35{
35#ifdef QWS 36#ifdef QWS
36 showMaximized(); 37 showMaximized();
37#endif 38#endif
38 39
39 setCaption( "AQPkg - Package Manager" ); 40 setCaption( "AQPkg - Package Manager" );
40 41
41 // Create our menu 42 // Create our menu
42 help = new QPopupMenu( this ); 43 help = new QPopupMenu( this );
43 help->insertItem( "&General", this, SLOT(displayHelp()), Qt::CTRL+Qt::Key_G ); 44 help->insertItem( "&General", this, SLOT(displayHelp()), Qt::CTRL+Qt::Key_G );
44 help->insertItem( "&About", this, SLOT(displayAbout()), Qt::CTRL+Qt::Key_A ); 45 help->insertItem( "&About", this, SLOT(displayAbout()), Qt::CTRL+Qt::Key_A );
45 46
46 settings = new QPopupMenu( this ); 47 settings = new QPopupMenu( this );
47 settings->insertItem( "&Settings", this, SLOT(displaySettings()), Qt::CTRL+Qt::Key_S ); 48 settings->insertItem( "&Settings", this, SLOT(displaySettings()), Qt::CTRL+Qt::Key_S );
48 49
49 edit = new QPopupMenu( this ); 50 edit = new QPopupMenu( this );
50 edit->insertItem( "&Find", this, SLOT(searchForPackage()), Qt::CTRL+Qt::Key_I ); 51 edit->insertItem( "&Find", this, SLOT(searchForPackage()), Qt::CTRL+Qt::Key_I );
51 edit->insertItem( "Find &Next", this, SLOT(repeatSearchForPackage()), Qt::CTRL+Qt::Key_N ); 52 edit->insertItem( "Find &Next", this, SLOT(repeatSearchForPackage()), Qt::CTRL+Qt::Key_N );
52 53
53 filter = new QPopupMenu( this ); 54 filter = new QPopupMenu( this );
54 mnuShowUninstalledPkgsId = filter->insertItem( "Show &Uninstalled Packages", this, SLOT(filterUninstalledPackages()), Qt::CTRL+Qt::Key_U ); 55 mnuShowUninstalledPkgsId = filter->insertItem( "Show &Non-Installed Packages", this, SLOT(filterUninstalledPackages()), Qt::CTRL+Qt::Key_U );
55 mnuShowInstalledPkgsId = filter->insertItem( "Show In&stalled Packages", this, SLOT(filterInstalledPackages()), Qt::CTRL+Qt::Key_S ); 56 mnuShowInstalledPkgsId = filter->insertItem( "Show In&stalled Packages", this, SLOT(filterInstalledPackages()), Qt::CTRL+Qt::Key_S );
56 mnuShowUpgradedPkgsId = filter->insertItem( "Show U&pdated Packages", this, SLOT(filterUpgradedPackages()), Qt::CTRL+Qt::Key_P ); 57 mnuShowUpgradedPkgsId = filter->insertItem( "Show U&pdated Packages", this, SLOT(filterUpgradedPackages()), Qt::CTRL+Qt::Key_P );
57 filter->insertSeparator(); 58 filter->insertSeparator();
58 mnuFilterByCategory = filter->insertItem( "Filter By &Category", this, SLOT(filterCategory()), Qt::CTRL+Qt::Key_C ); 59 mnuFilterByCategory = filter->insertItem( "Filter By &Category", this, SLOT(filterCategory()), Qt::CTRL+Qt::Key_C );
59 mnuSetFilterCategory = filter->insertItem( "Set Filter C&ategory", this, SLOT(setFilterCategory()), Qt::CTRL+Qt::Key_A ); 60 mnuSetFilterCategory = filter->insertItem( "Set Filter C&ategory", this, SLOT(setFilterCategory()), Qt::CTRL+Qt::Key_A );
60 61
61 // Create the main menu 62 // Create the main menu
62 menu = menuBar(); //new QMenuBar( this ); 63 menu = menuBar(); //new QMenuBar( this );
63 menu->insertItem( "&Settings", settings ); 64 menu->insertItem( "&Settings", settings );
64 menu->insertItem( "&Edit", edit ); 65 menu->insertItem( "&Edit", edit );
65 menu->insertItem( "&Filter", filter ); 66 menu->insertItem( "&Filter", filter );
66 menu->insertItem( "&Help", help ); 67 menu->insertItem( "&Help", help );
67 68
68 mgr = new DataManager(); 69 mgr = new DataManager();
69 mgr->loadServers(); 70 mgr->loadServers();
70 71
71 stack = new QWidgetStack( this ); 72 stack = new QWidgetStack( this );
72 73
73 networkPkgWindow = new NetworkPackageManager( mgr, stack ); 74 networkPkgWindow = new NetworkPackageManager( mgr, stack );
74 stack->addWidget( networkPkgWindow, 1 ); 75 stack->addWidget( networkPkgWindow, 1 );
75 76
76 setCentralWidget( stack ); 77 setCentralWidget( stack );
77 stack->raiseWidget( networkPkgWindow ); 78 stack->raiseWidget( networkPkgWindow );
78} 79}
79 80
80MainWindow :: ~MainWindow() 81MainWindow :: ~MainWindow()
81{ 82{
82 delete networkPkgWindow; 83 delete networkPkgWindow;
83} 84}
84 85
85void MainWindow :: setDocument( const QString &doc ) 86void MainWindow :: setDocument( const QString &doc )
86{ 87{
87 // Remove path from package 88 // Remove path from package
88 QString package = Utils::getPackageNameFromIpkFilename( doc ); 89 QString package = Utils::getPackageNameFromIpkFilename( doc );
89 std::cout << "Selecting package " << package << std::endl; 90 std::cout << "Selecting package " << package << std::endl;
90 networkPkgWindow->selectLocalPackage( package ); 91 networkPkgWindow->selectLocalPackage( package );
91} 92}
92 93
93void MainWindow :: displaySettings() 94void MainWindow :: displaySettings()
94{ 95{
95 SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); 96 SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true );
96 if ( dlg->showDlg( 0 ) ) 97 if ( dlg->showDlg( 0 ) )
97 networkPkgWindow->updateData(); 98 networkPkgWindow->updateData();
98 delete dlg; 99 delete dlg;
99} 100}
100 101
101void MainWindow :: displayHelp() 102void MainWindow :: displayHelp()
102{ 103{
103 HelpWindow *dlg = new HelpWindow( this ); 104 HelpWindow *dlg = new HelpWindow( this );
104 dlg->exec(); 105 dlg->exec();
105 delete dlg; 106 delete dlg;
106} 107}
107 108
108void MainWindow :: searchForPackage() 109void MainWindow :: searchForPackage()
109{ 110{
110 networkPkgWindow->searchForPackage( false ); 111 networkPkgWindow->searchForPackage( false );
111} 112}
112 113
113void MainWindow :: repeatSearchForPackage() 114void MainWindow :: repeatSearchForPackage()
114{ 115{
115 networkPkgWindow->searchForPackage( true ); 116 networkPkgWindow->searchForPackage( true );
116} 117}
117 118
118void MainWindow :: displayAbout() 119void MainWindow :: displayAbout()
119{ 120{
120 QMessageBox::about( this, "About AQPkg", VERSION_TEXT ); 121 QMessageBox::about( this, "About AQPkg", VERSION_TEXT );
121} 122}
122 123
123 124
124void MainWindow :: filterUninstalledPackages() 125void MainWindow :: filterUninstalledPackages()
125{ 126{
126 bool val; 127 bool val;
127 if ( filter->isItemChecked( mnuShowUninstalledPkgsId ) ) 128 if ( filter->isItemChecked( mnuShowUninstalledPkgsId ) )
128 { 129 {
129 val = false; 130 val = false;
130 filter->setItemChecked( mnuShowUninstalledPkgsId, false ); 131 filter->setItemChecked( mnuShowUninstalledPkgsId, false );
131 } 132 }
132 else 133 else
133 { 134 {
134 val = true; 135 val = true;
135 filter->setItemChecked( mnuShowUninstalledPkgsId, true ); 136 filter->setItemChecked( mnuShowUninstalledPkgsId, true );
136 } 137 }
137 138
138 filter->setItemChecked( mnuShowInstalledPkgsId, false ); 139 filter->setItemChecked( mnuShowInstalledPkgsId, false );
139 networkPkgWindow->showOnlyInstalledPackages( false ); 140 networkPkgWindow->showOnlyInstalledPackages( false );
140 filter->setItemChecked( mnuShowUpgradedPkgsId, false ); 141 filter->setItemChecked( mnuShowUpgradedPkgsId, false );
141 networkPkgWindow->showUpgradedPackages( false ); 142 networkPkgWindow->showUpgradedPackages( false );
142 143
143 networkPkgWindow->showOnlyUninstalledPackages( val ); 144 networkPkgWindow->showOnlyUninstalledPackages( val );
144 145
145} 146}
146 147
147void MainWindow :: filterInstalledPackages() 148void MainWindow :: filterInstalledPackages()
148{ 149{
149 bool val; 150 bool val;
150 if ( filter->isItemChecked( mnuShowInstalledPkgsId ) ) 151 if ( filter->isItemChecked( mnuShowInstalledPkgsId ) )
151 { 152 {
152 val = false; 153 val = false;
153 filter->setItemChecked( mnuShowInstalledPkgsId, false ); 154 filter->setItemChecked( mnuShowInstalledPkgsId, false );
154 } 155 }
155 else 156 else
156 { 157 {
157 val = true; 158 val = true;
158 filter->setItemChecked( mnuShowInstalledPkgsId, true ); 159 filter->setItemChecked( mnuShowInstalledPkgsId, true );
159 } 160 }
160 161
161 filter->setItemChecked( mnuShowUninstalledPkgsId, false ); 162 filter->setItemChecked( mnuShowUninstalledPkgsId, false );
162 networkPkgWindow->showOnlyUninstalledPackages( false ); 163 networkPkgWindow->showOnlyUninstalledPackages( false );
163 filter->setItemChecked( mnuShowUpgradedPkgsId, false ); 164 filter->setItemChecked( mnuShowUpgradedPkgsId, false );
164 networkPkgWindow->showUpgradedPackages( false ); 165 networkPkgWindow->showUpgradedPackages( false );
165 166
166 networkPkgWindow->showOnlyInstalledPackages( val ); 167 networkPkgWindow->showOnlyInstalledPackages( val );
167} 168}
168 169
169void MainWindow :: filterUpgradedPackages() 170void MainWindow :: filterUpgradedPackages()
170{ 171{
171 bool val; 172 bool val;
172 if ( filter->isItemChecked( mnuShowUpgradedPkgsId ) ) 173 if ( filter->isItemChecked( mnuShowUpgradedPkgsId ) )
173 { 174 {
174 val = false; 175 val = false;
175 filter->setItemChecked( mnuShowUpgradedPkgsId, false ); 176 filter->setItemChecked( mnuShowUpgradedPkgsId, false );
176 } 177 }
177 else 178 else
178 { 179 {
179 val = true; 180 val = true;
180 filter->setItemChecked( mnuShowUpgradedPkgsId, true ); 181 filter->setItemChecked( mnuShowUpgradedPkgsId, true );
181 } 182 }
182 183
183 filter->setItemChecked( mnuShowUninstalledPkgsId, false ); 184 filter->setItemChecked( mnuShowUninstalledPkgsId, false );
184 networkPkgWindow->showOnlyUninstalledPackages( false ); 185 networkPkgWindow->showOnlyUninstalledPackages( false );
185 filter->setItemChecked( mnuShowInstalledPkgsId, false ); 186 filter->setItemChecked( mnuShowInstalledPkgsId, false );
186 networkPkgWindow->showOnlyInstalledPackages( false ); 187 networkPkgWindow->showOnlyInstalledPackages( false );
187 188
188 networkPkgWindow->showUpgradedPackages( val ); 189 networkPkgWindow->showUpgradedPackages( val );
189} 190}
190 191
191void MainWindow :: setFilterCategory() 192void MainWindow :: setFilterCategory()
192{ 193{
193 if ( networkPkgWindow->setFilterCategory( ) ) 194 if ( networkPkgWindow->setFilterCategory( ) )
194 filter->setItemChecked( mnuFilterByCategory, true ); 195 filter->setItemChecked( mnuFilterByCategory, true );
195} 196}
196 197
197void MainWindow :: filterCategory() 198void MainWindow :: filterCategory()
198{ 199{
199 if ( filter->isItemChecked( mnuFilterByCategory ) ) 200 if ( filter->isItemChecked( mnuFilterByCategory ) )
200 { 201 {
201 networkPkgWindow->filterByCategory( false ); 202 networkPkgWindow->filterByCategory( false );
202 filter->setItemChecked( mnuFilterByCategory, false ); 203 filter->setItemChecked( mnuFilterByCategory, false );
203 } 204 }
204 else 205 else
205 { 206 {
206 if ( networkPkgWindow->filterByCategory( true ) ) 207 if ( networkPkgWindow->filterByCategory( true ) )
207 filter->setItemChecked( mnuFilterByCategory, true ); 208 filter->setItemChecked( mnuFilterByCategory, true );
208 } 209 }
209} \ No newline at end of file 210}
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp
index d9e62b6..79a380e 100644
--- a/noncore/settings/aqpkg/networkpkgmgr.cpp
+++ b/noncore/settings/aqpkg/networkpkgmgr.cpp
@@ -1,859 +1,859 @@
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#include "categoryfilterimpl.h" 43#include "categoryfilterimpl.h"
44 44
45#include "global.h" 45#include "global.h"
46 46
47extern int compareVersions( const char *v1, const char *v2 ); 47extern int compareVersions( const char *v1, const char *v2 );
48 48
49NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name) 49NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name)
50 : QWidget(parent, name) 50 : QWidget(parent, name)
51{ 51{
52 dataMgr = dataManager; 52 dataMgr = dataManager;
53 53
54#ifdef QWS 54#ifdef QWS
55 // read download directory from config file 55 // read download directory from config file
56 Config cfg( "aqpkg" ); 56 Config cfg( "aqpkg" );
57 cfg.setGroup( "settings" ); 57 cfg.setGroup( "settings" );
58 currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); 58 currentlySelectedServer = cfg.readEntry( "selectedServer", "local" );
59 showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); 59 showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" );
60 60
61#endif 61#endif
62 62
63 showUninstalledPkgs = false; 63 showUninstalledPkgs = false;
64 showInstalledPkgs = false; 64 showInstalledPkgs = false;
65 showUpgradedPkgs = false; 65 showUpgradedPkgs = false;
66 categoryFilterEnabled = false; 66 categoryFilterEnabled = false;
67 67
68 initGui(); 68 initGui();
69 setupConnections(); 69 setupConnections();
70 70
71 updateData(); 71 updateData();
72} 72}
73 73
74NetworkPackageManager::~NetworkPackageManager() 74NetworkPackageManager::~NetworkPackageManager()
75{ 75{
76} 76}
77 77
78void NetworkPackageManager :: timerEvent ( QTimerEvent * ) 78void NetworkPackageManager :: timerEvent ( QTimerEvent * )
79{ 79{
80 killTimer( timerId ); 80 killTimer( timerId );
81 81
82 // Add server names to listbox 82 // Add server names to listbox
83 updateData(); 83 updateData();
84} 84}
85 85
86void NetworkPackageManager :: updateData() 86void NetworkPackageManager :: updateData()
87{ 87{
88 serversList->clear(); 88 serversList->clear();
89 packagesList->clear(); 89 packagesList->clear();
90 90
91 91
92 vector<Server>::iterator it; 92 vector<Server>::iterator it;
93 int activeItem = -1; 93 int activeItem = -1;
94 int i; 94 int i;
95 for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i ) 95 for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i )
96 { 96 {
97// cout << "Adding " << it->getServerName() << " to combobox" << endl; 97// cout << "Adding " << it->getServerName() << " to combobox" << endl;
98 if ( !it->isServerActive() ) 98 if ( !it->isServerActive() )
99 { 99 {
100 cout << it->getServerName() << " is not active" << endl; 100 cout << it->getServerName() << " is not active" << endl;
101 i--; 101 i--;
102 continue; 102 continue;
103 } 103 }
104 serversList->insertItem( it->getServerName() ); 104 serversList->insertItem( it->getServerName() );
105 if ( it->getServerName() == currentlySelectedServer ) 105 if ( it->getServerName() == currentlySelectedServer )
106 activeItem = i; 106 activeItem = i;
107 } 107 }
108 108
109 // set selected server to be active server 109 // set selected server to be active server
110 if ( activeItem != -1 ) 110 if ( activeItem != -1 )
111 serversList->setCurrentItem( activeItem ); 111 serversList->setCurrentItem( activeItem );
112 serverSelected( 0 ); 112 serverSelected( 0 );
113} 113}
114 114
115void NetworkPackageManager :: selectLocalPackage( const QString &pkg ) 115void NetworkPackageManager :: selectLocalPackage( const QString &pkg )
116{ 116{
117 // First select local server 117 // First select local server
118 for ( int i = 0 ; i < serversList->count() ; ++i ) 118 for ( int i = 0 ; i < serversList->count() ; ++i )
119 { 119 {
120 if ( serversList->text( i ) == LOCAL_IPKGS ) 120 if ( serversList->text( i ) == LOCAL_IPKGS )
121 { 121 {
122 serversList->setCurrentItem( i ); 122 serversList->setCurrentItem( i );
123 break; 123 break;
124 } 124 }
125 } 125 }
126 serverSelected( 0 ); 126 serverSelected( 0 );
127 127
128 // Now set the check box of the selected package 128 // Now set the check box of the selected package
129 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 129 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
130 item != 0 ; 130 item != 0 ;
131 item = (QCheckListItem *)item->nextSibling() ) 131 item = (QCheckListItem *)item->nextSibling() )
132 { 132 {
133 if ( item->text().startsWith( pkg ) ) 133 if ( item->text().startsWith( pkg ) )
134 { 134 {
135 item->setOn( true ); 135 item->setOn( true );
136 break; 136 break;
137 } 137 }
138 } 138 }
139} 139}
140 140
141 141
142void NetworkPackageManager :: initGui() 142void NetworkPackageManager :: initGui()
143{ 143{
144 QLabel *l = new QLabel( "Servers", this ); 144 QLabel *l = new QLabel( "Servers", this );
145 serversList = new QComboBox( this ); 145 serversList = new QComboBox( this );
146 packagesList = new QListView( this ); 146 packagesList = new QListView( this );
147 update = new QPushButton( "Refresh Lists", this ); 147 update = new QPushButton( "Refresh Lists", this );
148 download = new QPushButton( "Download", this ); 148 download = new QPushButton( "Download", this );
149 upgrade = new QPushButton( "Upgrade", this ); 149 upgrade = new QPushButton( "Upgrade", this );
150 apply = new QPushButton( "Apply", this ); 150 apply = new QPushButton( "Apply", this );
151 151
152 QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1, "VBox" ); 152 QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1, "VBox" );
153 QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1, "HBox1" ); 153 QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1, "HBox1" );
154 hbox1->addWidget( l ); 154 hbox1->addWidget( l );
155 hbox1->addWidget( serversList ); 155 hbox1->addWidget( serversList );
156 156
157 QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1, "HBox1" ); 157 QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1, "HBox1" );
158 QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1, "HBox1" ); 158 QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1, "HBox1" );
159 159
160 160
161 if ( showJumpTo ) 161 if ( showJumpTo )
162 { 162 {
163 char text[2]; 163 char text[2];
164 text[1] = '\0'; 164 text[1] = '\0';
165 for ( int i = 0 ; i < 26 ; ++i ) 165 for ( int i = 0 ; i < 26 ; ++i )
166 { 166 {
167 text[0] = 'A' + i; 167 text[0] = 'A' + i;
168 LetterPushButton *b = new LetterPushButton( text, this ); 168 LetterPushButton *b = new LetterPushButton( text, this );
169 connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); 169 connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) );
170 if ( i < 13 ) 170 if ( i < 13 )
171 hbox3->addWidget( b ); 171 hbox3->addWidget( b );
172 else 172 else
173 hbox4->addWidget( b ); 173 hbox4->addWidget( b );
174 } 174 }
175 } 175 }
176 176
177 vbox->addWidget( packagesList ); 177 vbox->addWidget( packagesList );
178 packagesList->addColumn( "Packages" ); 178 packagesList->addColumn( "Packages" );
179 179
180 QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1, "HBox2" ); 180 QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1, "HBox2" );
181 hbox2->addWidget( update ); 181 hbox2->addWidget( update );
182 hbox2->addWidget( download ); 182 hbox2->addWidget( download );
183 hbox2->addWidget( upgrade ); 183 hbox2->addWidget( upgrade );
184 hbox2->addWidget( apply ); 184 hbox2->addWidget( apply );
185} 185}
186 186
187void NetworkPackageManager :: setupConnections() 187void NetworkPackageManager :: setupConnections()
188{ 188{
189 connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int ))); 189 connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int )));
190 connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) ); 190 connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) );
191 connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) ); 191 connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) );
192 connect( upgrade, SIGNAL( released()), this, SLOT(upgradePackages()) ); 192 connect( upgrade, SIGNAL( released()), this, SLOT(upgradePackages()) );
193 connect( update, SIGNAL(released()), this, SLOT(updateServer()) ); 193 connect( update, SIGNAL(released()), this, SLOT(updateServer()) );
194} 194}
195 195
196void NetworkPackageManager :: showProgressDialog( char *initialText ) 196void NetworkPackageManager :: showProgressDialog( char *initialText )
197{ 197{
198 if ( !progressDlg ) 198 if ( !progressDlg )
199 progressDlg = new ProgressDlg( this, "Progress", false ); 199 progressDlg = new ProgressDlg( this, "Progress", false );
200 progressDlg->setText( initialText ); 200 progressDlg->setText( initialText );
201 progressDlg->show(); 201 progressDlg->show();
202} 202}
203 203
204 204
205void NetworkPackageManager :: serverSelected( int ) 205void NetworkPackageManager :: serverSelected( int )
206{ 206{
207 packagesList->clear(); 207 packagesList->clear();
208 208
209 // display packages 209 // display packages
210 QString serverName = serversList->currentText(); 210 QString serverName = serversList->currentText();
211 currentlySelectedServer = serverName; 211 currentlySelectedServer = serverName;
212 212
213#ifdef QWS 213#ifdef QWS
214 // read download directory from config file 214 // read download directory from config file
215 Config cfg( "aqpkg" ); 215 Config cfg( "aqpkg" );
216 cfg.setGroup( "settings" ); 216 cfg.setGroup( "settings" );
217 cfg.writeEntry( "selectedServer", currentlySelectedServer ); 217 cfg.writeEntry( "selectedServer", currentlySelectedServer );
218#endif 218#endif
219 219
220 Server *s = dataMgr->getServer( serverName ); 220 vector<Server>::iterator s = dataMgr->getServer( serverName );
221 221
222 vector<Package> &list = s->getPackageList(); 222 vector<Package> &list = s->getPackageList();
223 vector<Package>::iterator it; 223 vector<Package>::iterator it;
224 for ( it = list.begin() ; it != list.end() ; ++it ) 224 for ( it = list.begin() ; it != list.end() ; ++it )
225 { 225 {
226 226
227 QString text = ""; 227 QString text = "";
228 228
229 // Apply show only uninstalled packages filter 229 // Apply show only uninstalled packages filter
230 if ( showUninstalledPkgs && it->isInstalled() ) 230 if ( showUninstalledPkgs && it->isInstalled() )
231 continue; 231 continue;
232 232
233 // Apply show only installed packages filter 233 // Apply show only installed packages filter
234 if ( showInstalledPkgs && !it->isInstalled() ) 234 if ( showInstalledPkgs && !it->isInstalled() )
235 continue; 235 continue;
236 236
237 // Apply show only new installed packages filter 237 // Apply show only new installed packages filter
238 if ( showUpgradedPkgs ) 238 if ( showUpgradedPkgs )
239 { 239 {
240 if ( !it->isInstalled() || 240 if ( !it->isInstalled() ||
241 compareVersions( it->getInstalledVersion(), it->getVersion() ) != 1 ) 241 compareVersions( it->getInstalledVersion(), it->getVersion() ) != 1 )
242 continue; 242 continue;
243 } 243 }
244 244
245 // Apply the section filter 245 // Apply the section filter
246 if ( categoryFilterEnabled && categoryFilter != "" ) 246 if ( categoryFilterEnabled && categoryFilter != "" )
247 { 247 {
248 if ( it->getSection() == "" || categoryFilter.find( it->getSection().lower() ) == -1 ) 248 if ( it->getSection() == "" || categoryFilter.find( it->getSection().lower() ) == -1 )
249 continue; 249 continue;
250 } 250 }
251 251
252 // If the local server, only display installed packages 252 // If the local server, only display installed packages
253 if ( serverName == LOCAL_SERVER && !it->isInstalled() ) 253 if ( serverName == LOCAL_SERVER && !it->isInstalled() )
254 continue; 254 continue;
255 255
256 256
257 text += it->getPackageName(); 257 text += it->getPackageName();
258 if ( it->isInstalled() ) 258 if ( it->isInstalled() )
259 { 259 {
260 text += " (installed)"; 260 text += " (installed)";
261 261
262 // If a different version of package is available, postfix it with an * 262 // If a different version of package is available, postfix it with an *
263 if ( it->getVersion() != it->getInstalledVersion() ) 263 if ( it->getVersion() != it->getInstalledVersion() )
264 { 264 {
265 265
266 if ( compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1 ) 266 if ( compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1 )
267 text += "*"; 267 text += "*";
268 } 268 }
269 } 269 }
270 270
271 QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox ); 271 QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox );
272 272
273 if ( it->isInstalled() ) 273 if ( it->isInstalled() )
274 { 274 {
275 QString destName = ""; 275 QString destName = "";
276 if ( it->getLocalPackage() ) 276 if ( it->getLocalPackage() )
277 { 277 {
278 if ( it->getLocalPackage()->getInstalledTo() ) 278 if ( it->getLocalPackage()->getInstalledTo() )
279 destName = it->getLocalPackage()->getInstalledTo()->getDestinationName(); 279 destName = it->getLocalPackage()->getInstalledTo()->getDestinationName();
280 } 280 }
281 else 281 else
282 { 282 {
283 if ( it->getInstalledTo() ) 283 if ( it->getInstalledTo() )
284 destName = it->getInstalledTo()->getDestinationName(); 284 destName = it->getInstalledTo()->getDestinationName();
285 } 285 }
286 if ( destName != "" ) 286 if ( destName != "" )
287 new QCheckListItem( item, QString( "Installed To - " ) + destName ); 287 new QCheckListItem( item, QString( "Installed To - " ) + destName );
288 } 288 }
289 289
290 if ( !it->isPackageStoredLocally() ) 290 if ( !it->isPackageStoredLocally() )
291 { 291 {
292 new QCheckListItem( item, QString( "Description - " ) + it->getDescription() ); 292 new QCheckListItem( item, QString( "Description - " ) + it->getDescription() );
293 new QCheckListItem( item, QString( "Size - " ) + it->getPackageSize() ); 293 new QCheckListItem( item, QString( "Size - " ) + it->getPackageSize() );
294 new QCheckListItem( item, QString( "Section - " ) + it->getSection() ); 294 new QCheckListItem( item, QString( "Section - " ) + it->getSection() );
295 } 295 }
296 else 296 else
297 new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() ); 297 new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() );
298 298
299 if ( serverName == LOCAL_SERVER ) 299 if ( serverName == LOCAL_SERVER )
300 { 300 {
301 new QCheckListItem( item, QString( "V. Installed - " ) + it->getVersion() ); 301 new QCheckListItem( item, QString( "V. Installed - " ) + it->getVersion() );
302 } 302 }
303 else 303 else
304 { 304 {
305 new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() ); 305 new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() );
306 if ( it->getLocalPackage() ) 306 if ( it->getLocalPackage() )
307 { 307 {
308 if ( it->isInstalled() ) 308 if ( it->isInstalled() )
309 new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() ); 309 new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() );
310 } 310 }
311 } 311 }
312 312
313 packagesList->insertItem( item ); 313 packagesList->insertItem( item );
314 } 314 }
315 315
316 // If the local server or the local ipkgs server disable the download button 316 // If the local server or the local ipkgs server disable the download button
317 if ( serverName == LOCAL_SERVER ) 317 if ( serverName == LOCAL_SERVER )
318 { 318 {
319 upgrade->setEnabled( false ); 319 upgrade->setEnabled( false );
320 download->setText( "Download" ); 320 download->setText( "Download" );
321 download->setEnabled( true ); 321 download->setEnabled( true );
322 } 322 }
323 else if ( serverName == LOCAL_IPKGS ) 323 else if ( serverName == LOCAL_IPKGS )
324 { 324 {
325 upgrade->setEnabled( false ); 325 upgrade->setEnabled( false );
326 download->setEnabled( true ); 326 download->setEnabled( true );
327 download->setText( "Remove" ); 327 download->setText( "Remove" );
328 } 328 }
329 else 329 else
330 { 330 {
331 upgrade->setEnabled( true ); 331 upgrade->setEnabled( true );
332 download->setEnabled( true ); 332 download->setEnabled( true );
333 download->setText( "Download" ); 333 download->setText( "Download" );
334 } 334 }
335} 335}
336 336
337void NetworkPackageManager :: updateServer() 337void NetworkPackageManager :: updateServer()
338{ 338{
339 QString serverName = serversList->currentText(); 339 QString serverName = serversList->currentText();
340 340
341 // Update the current server 341 // Update the current server
342 // Display dialog 342 // Display dialog
343 343
344 // Disable buttons to stop silly people clicking lots on them :) 344 // Disable buttons to stop silly people clicking lots on them :)
345 345
346 // 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
347 dataMgr->writeOutIpkgConf(); 347 dataMgr->writeOutIpkgConf();
348 348
349 Ipkg ipkg; 349 Ipkg ipkg;
350 ipkg.setOption( "update" ); 350 ipkg.setOption( "update" );
351 351
352 InstallDlgImpl dlg( &ipkg, "Refreshing server package lists", this, "Upgrade", true ); 352 InstallDlgImpl dlg( &ipkg, "Refreshing server package lists", this, "Upgrade", true );
353 dlg.showDlg(); 353 dlg.showDlg();
354 354
355 // Reload data 355 // Reload data
356 dataMgr->reloadServerData(); 356 dataMgr->reloadServerData();
357 serverSelected(-1); 357 serverSelected(-1);
358// delete progDlg; 358// delete progDlg;
359} 359}
360 360
361void NetworkPackageManager :: upgradePackages() 361void NetworkPackageManager :: upgradePackages()
362{ 362{
363 // We're gonna do an upgrade of all packages 363 // We're gonna do an upgrade of all packages
364 // First warn user that this isn't recommended 364 // First warn user that this isn't recommended
365 QString text = "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n"; 365 QString text = "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n";
366 QMessageBox warn("Warning", text, QMessageBox::Warning, 366 QMessageBox warn("Warning", text, QMessageBox::Warning,
367 QMessageBox::Yes, 367 QMessageBox::Yes,
368 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , 368 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default ,
369 0, this ); 369 0, this );
370 warn.adjustSize(); 370 warn.adjustSize();
371 371
372 if ( warn.exec() == QMessageBox::Yes ) 372 if ( warn.exec() == QMessageBox::Yes )
373 { 373 {
374 // First, write out ipkg_conf file so that ipkg can use it 374 // First, write out ipkg_conf file so that ipkg can use it
375 dataMgr->writeOutIpkgConf(); 375 dataMgr->writeOutIpkgConf();
376 376
377 // Now run upgrade 377 // Now run upgrade
378 Ipkg ipkg; 378 Ipkg ipkg;
379 ipkg.setOption( "upgrade" ); 379 ipkg.setOption( "upgrade" );
380 380
381 InstallDlgImpl dlg( &ipkg, "Upgrading installed packages", this, "Upgrade", true ); 381 InstallDlgImpl dlg( &ipkg, "Upgrading installed packages", this, "Upgrade", true );
382 dlg.showDlg(); 382 dlg.showDlg();
383 383
384 // Reload data 384 // Reload data
385 dataMgr->reloadServerData(); 385 dataMgr->reloadServerData();
386 serverSelected(-1); 386 serverSelected(-1);
387 } 387 }
388} 388}
389 389
390 390
391void NetworkPackageManager :: downloadPackage() 391void NetworkPackageManager :: downloadPackage()
392{ 392{
393 bool doUpdate = true; 393 bool doUpdate = true;
394 if ( download->text() == "Download" ) 394 if ( download->text() == "Download" )
395 { 395 {
396 // See if any packages are selected 396 // See if any packages are selected
397 bool found = false; 397 bool found = false;
398 if ( serversList->currentText() != LOCAL_SERVER ) 398 if ( serversList->currentText() != LOCAL_SERVER )
399 { 399 {
400 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 400 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
401 item != 0 && !found; 401 item != 0 && !found;
402 item = (QCheckListItem *)item->nextSibling() ) 402 item = (QCheckListItem *)item->nextSibling() )
403 { 403 {
404 if ( item->isOn() ) 404 if ( item->isOn() )
405 found = true; 405 found = true;
406 } 406 }
407 } 407 }
408 408
409 // If user selected some packages then download the and store the locally 409 // If user selected some packages then download the and store the locally
410 // otherwise, display dialog asking user what package to download from an http server 410 // otherwise, display dialog asking user what package to download from an http server
411 // and whether to install it 411 // and whether to install it
412 if ( found ) 412 if ( found )
413 downloadSelectedPackages(); 413 downloadSelectedPackages();
414 else 414 else
415 downloadRemotePackage(); 415 downloadRemotePackage();
416 416
417 } 417 }
418 else if ( download->text() == "Remove" ) 418 else if ( download->text() == "Remove" )
419 { 419 {
420 doUpdate = false; 420 doUpdate = false;
421 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 421 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
422 item != 0 ; 422 item != 0 ;
423 item = (QCheckListItem *)item->nextSibling() ) 423 item = (QCheckListItem *)item->nextSibling() )
424 { 424 {
425 if ( item->isOn() ) 425 if ( item->isOn() )
426 { 426 {
427 QString name = item->text(); 427 QString name = item->text();
428 int pos = name.find( "*" ); 428 int pos = name.find( "*" );
429 name.truncate( pos ); 429 name.truncate( pos );
430 430
431 // if (there is a (installed), remove it 431 // if (there is a (installed), remove it
432 pos = name.find( "(installed)" ); 432 pos = name.find( "(installed)" );
433 if ( pos > 0 ) 433 if ( pos > 0 )
434 name.truncate( pos - 1 ); 434 name.truncate( pos - 1 );
435 435
436 Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name ); 436 Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name );
437 437
438 QString msgtext; 438 QString msgtext;
439 msgtext.sprintf( "Are you sure you wish to delete\n%s?", (const char *)p->getPackageName() ); 439 msgtext.sprintf( "Are you sure you wish to delete\n%s?", (const char *)p->getPackageName() );
440 if ( QMessageBox::information( this, "Are you sure?", 440 if ( QMessageBox::information( this, "Are you sure?",
441 msgtext, "No", "Yes" ) == 1 ) 441 msgtext, "No", "Yes" ) == 1 )
442 { 442 {
443 doUpdate = true; 443 doUpdate = true;
444 QFile f( p->getFilename() ); 444 QFile f( p->getFilename() );
445 f.remove(); 445 f.remove();
446 } 446 }
447 } 447 }
448 } 448 }
449 } 449 }
450 450
451 if ( doUpdate ) 451 if ( doUpdate )
452 { 452 {
453 dataMgr->reloadServerData(); 453 dataMgr->reloadServerData();
454 serverSelected( -1 ); 454 serverSelected( -1 );
455 } 455 }
456} 456}
457 457
458void NetworkPackageManager :: downloadSelectedPackages() 458void NetworkPackageManager :: downloadSelectedPackages()
459{ 459{
460 // First, write out ipkg_conf file so that ipkg can use it 460 // First, write out ipkg_conf file so that ipkg can use it
461 dataMgr->writeOutIpkgConf(); 461 dataMgr->writeOutIpkgConf();
462 462
463 // Display dialog to user asking where to download the files to 463 // Display dialog to user asking where to download the files to
464 bool ok = FALSE; 464 bool ok = FALSE;
465 QString dir = ""; 465 QString dir = "";
466#ifdef QWS 466#ifdef QWS
467 // read download directory from config file 467 // read download directory from config file
468 Config cfg( "aqpkg" ); 468 Config cfg( "aqpkg" );
469 cfg.setGroup( "settings" ); 469 cfg.setGroup( "settings" );
470 dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); 470 dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" );
471#endif 471#endif
472 472
473 QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); 473 QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this );
474 if ( ok && !text.isEmpty() ) 474 if ( ok && !text.isEmpty() )
475 dir = text; // user entered something and pressed ok 475 dir = text; // user entered something and pressed ok
476 else 476 else
477 return; // user entered nothing or pressed cancel 477 return; // user entered nothing or pressed cancel
478 478
479#ifdef QWS 479#ifdef QWS
480 // Store download directory in config file 480 // Store download directory in config file
481 cfg.writeEntry( "downloadDir", dir ); 481 cfg.writeEntry( "downloadDir", dir );
482#endif 482#endif
483 483
484 // Get starting directory 484 // Get starting directory
485 char initDir[PATH_MAX]; 485 char initDir[PATH_MAX];
486 getcwd( initDir, PATH_MAX ); 486 getcwd( initDir, PATH_MAX );
487 487
488 // Download each package 488 // Download each package
489 Ipkg ipkg; 489 Ipkg ipkg;
490 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 490 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
491 491
492 ipkg.setOption( "download" ); 492 ipkg.setOption( "download" );
493 ipkg.setRuntimeDirectory( dir ); 493 ipkg.setRuntimeDirectory( dir );
494 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 494 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
495 item != 0 ; 495 item != 0 ;
496 item = (QCheckListItem *)item->nextSibling() ) 496 item = (QCheckListItem *)item->nextSibling() )
497 { 497 {
498 if ( item->isOn() ) 498 if ( item->isOn() )
499 { 499 {
500 QString name = item->text(); 500 QString name = item->text();
501 int pos = name.find( "*" ); 501 int pos = name.find( "*" );
502 name.truncate( pos ); 502 name.truncate( pos );
503 503
504 // if (there is a (installed), remove it 504 // if (there is a (installed), remove it
505 pos = name.find( "(installed)" ); 505 pos = name.find( "(installed)" );
506 if ( pos > 0 ) 506 if ( pos > 0 )
507 name.truncate( pos - 1 ); 507 name.truncate( pos - 1 );
508 508
509 ipkg.setPackage( name ); 509 ipkg.setPackage( name );
510 ipkg.runIpkg( ); 510 ipkg.runIpkg( );
511 } 511 }
512 } 512 }
513} 513}
514 514
515void NetworkPackageManager :: downloadRemotePackage() 515void NetworkPackageManager :: downloadRemotePackage()
516{ 516{
517 // Display dialog 517 // Display dialog
518 bool ok; 518 bool ok;
519 QString package = InputDialog::getText( "Install Remote Package", tr( "Enter package location" ), "http://", &ok, this ); 519 QString package = InputDialog::getText( "Install Remote Package", tr( "Enter package location" ), "http://", &ok, this );
520 if ( !ok || package.isEmpty() ) 520 if ( !ok || package.isEmpty() )
521 return; 521 return;
522// DownloadRemoteDlgImpl dlg( this, "Install", true ); 522// DownloadRemoteDlgImpl dlg( this, "Install", true );
523// if ( dlg.exec() == QDialog::Rejected ) 523// if ( dlg.exec() == QDialog::Rejected )
524// return; 524// return;
525 525
526 // grab details from dialog 526 // grab details from dialog
527// QString package = dlg.getPackageLocation(); 527// QString package = dlg.getPackageLocation();
528 528
529 InstallData item; 529 InstallData item;
530 item.option = "I"; 530 item.option = "I";
531 item.packageName = package; 531 item.packageName = package;
532 vector<InstallData> workingPackages; 532 vector<InstallData> workingPackages;
533 workingPackages.push_back( item ); 533 workingPackages.push_back( item );
534 534
535 InstallDlgImpl dlg2( workingPackages, dataMgr, this, "Install", true ); 535 InstallDlgImpl dlg2( workingPackages, dataMgr, this, "Install", true );
536 dlg2.showDlg(); 536 dlg2.showDlg();
537 537
538 // Reload data 538 // Reload data
539 dataMgr->reloadServerData(); 539 dataMgr->reloadServerData();
540 serverSelected(-1); 540 serverSelected(-1);
541 541
542#ifdef QWS 542#ifdef QWS
543 // Finally let the main system update itself 543 // Finally let the main system update itself
544 QCopEnvelope e("QPE/System", "linkChanged(QString)"); 544 QCopEnvelope e("QPE/System", "linkChanged(QString)");
545 QString lf = QString::null; 545 QString lf = QString::null;
546 e << lf; 546 e << lf;
547#endif 547#endif
548} 548}
549 549
550 550
551void NetworkPackageManager :: applyChanges() 551void NetworkPackageManager :: applyChanges()
552{ 552{
553 stickyOption = ""; 553 stickyOption = "";
554 554
555 // First, write out ipkg_conf file so that ipkg can use it 555 // First, write out ipkg_conf file so that ipkg can use it
556 dataMgr->writeOutIpkgConf(); 556 dataMgr->writeOutIpkgConf();
557 557
558 // Now for each selected item 558 // Now for each selected item
559 // deal with it 559 // deal with it
560 560
561 vector<InstallData> workingPackages; 561 vector<InstallData> workingPackages;
562 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 562 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
563 item != 0 ; 563 item != 0 ;
564 item = (QCheckListItem *)item->nextSibling() ) 564 item = (QCheckListItem *)item->nextSibling() )
565 { 565 {
566 if ( item->isOn() ) 566 if ( item->isOn() )
567 { 567 {
568 InstallData data = dealWithItem( item ); 568 InstallData data = dealWithItem( item );
569 workingPackages.push_back( data ); 569 workingPackages.push_back( data );
570 } 570 }
571 } 571 }
572 572
573 if ( workingPackages.size() == 0 ) 573 if ( workingPackages.size() == 0 )
574 { 574 {
575 // Nothing to do 575 // Nothing to do
576 QMessageBox::information( this, "Nothing to do", 576 QMessageBox::information( this, "Nothing to do",
577 "No packages selected", "OK" ); 577 "No packages selected", "OK" );
578 578
579 return; 579 return;
580 } 580 }
581 581
582 // do the stuff 582 // do the stuff
583 InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true ); 583 InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true );
584 dlg.showDlg(); 584 dlg.showDlg();
585 585
586 // Reload data 586 // Reload data
587 dataMgr->reloadServerData(); 587 dataMgr->reloadServerData();
588 serverSelected(-1); 588 serverSelected(-1);
589 589
590#ifdef QWS 590#ifdef QWS
591 // Finally let the main system update itself 591 // Finally let the main system update itself
592 QCopEnvelope e("QPE/System", "linkChanged(QString)"); 592 QCopEnvelope e("QPE/System", "linkChanged(QString)");
593 QString lf = QString::null; 593 QString lf = QString::null;
594 e << lf; 594 e << lf;
595#endif 595#endif
596} 596}
597 597
598// decide what to do - either remove, upgrade or install 598// decide what to do - either remove, upgrade or install
599// Current rules: 599// Current rules:
600// If not installed - install 600// If not installed - install
601// If installed and different version available - upgrade 601// If installed and different version available - upgrade
602// If installed and version up to date - remove 602// If installed and version up to date - remove
603InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item ) 603InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item )
604{ 604{
605 QString name = item->text(); 605 QString name = item->text();
606 int pos = name.find( "*" ); 606 int pos = name.find( "*" );
607 name.truncate( pos ); 607 name.truncate( pos );
608 608
609 // if (there is a (installed), remove it 609 // if (there is a (installed), remove it
610 pos = name.find( "(installed)" ); 610 pos = name.find( "(installed)" );
611 if ( pos > 0 ) 611 if ( pos > 0 )
612 name.truncate( pos - 1 ); 612 name.truncate( pos - 1 );
613 613
614 // Get package 614 // Get package
615 Server *s = dataMgr->getServer( serversList->currentText() ); 615 vector<Server>::iterator s = dataMgr->getServer( serversList->currentText() );
616 Package *p = s->getPackage( name ); 616 Package *p = s->getPackage( name );
617 617
618 // If the package has a filename then it is a local file 618 // If the package has a filename then it is a local file
619 if ( p->isPackageStoredLocally() ) 619 if ( p->isPackageStoredLocally() )
620 name = p->getFilename(); 620 name = p->getFilename();
621 621
622 QString option; 622 QString option;
623 QString dest = "root"; 623 QString dest = "root";
624 if ( !p->isInstalled() ) 624 if ( !p->isInstalled() )
625 { 625 {
626 InstallData item; 626 InstallData item;
627 item.option = "I"; 627 item.option = "I";
628 item.packageName = name; 628 item.packageName = name;
629 return item; 629 return item;
630 } 630 }
631 else 631 else
632 { 632 {
633 InstallData item; 633 InstallData item;
634 item.option = "D"; 634 item.option = "D";
635 if ( !p->isPackageStoredLocally() ) 635 if ( !p->isPackageStoredLocally() )
636 item.packageName = p->getInstalledPackageName(); 636 item.packageName = p->getInstalledPackageName();
637 else 637 else
638 item.packageName = name; 638 item.packageName = name;
639 639
640 if ( p->getInstalledTo() ) 640 if ( p->getInstalledTo() )
641 { 641 {
642 item.destination = p->getInstalledTo(); 642 item.destination = p->getInstalledTo();
643 cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl; 643 cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl;
644 cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl; 644 cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl;
645 } 645 }
646 else 646 else
647 { 647 {
648 item.destination = p->getLocalPackage()->getInstalledTo(); 648 item.destination = p->getLocalPackage()->getInstalledTo();
649 } 649 }
650 650
651 // Now see if version is newer or not 651 // Now see if version is newer or not
652 int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); 652 int val = compareVersions( p->getInstalledVersion(), p->getVersion() );
653 653
654 // If the version requested is older and user selected a local ipk file, then reinstall the file 654 // If the version requested is older and user selected a local ipk file, then reinstall the file
655 if ( p->isPackageStoredLocally() && val == -1 ) 655 if ( p->isPackageStoredLocally() && val == -1 )
656 val = 0; 656 val = 0;
657 657
658 if ( val == -2 ) 658 if ( val == -2 )
659 { 659 {
660 // Error - should handle 660 // Error - should handle
661 } 661 }
662 else if ( val == -1 ) 662 else if ( val == -1 )
663 { 663 {
664 // Version available is older - remove only 664 // Version available is older - remove only
665 item.option = "D"; 665 item.option = "D";
666 } 666 }
667 else 667 else
668 { 668 {
669 QString caption; 669 QString caption;
670 QString text; 670 QString text;
671 QString secondButton; 671 QString secondButton;
672 QString secondOption; 672 QString secondOption;
673 if ( val == 0 ) 673 if ( val == 0 )
674 { 674 {
675 // Version available is the same - option to remove or reinstall 675 // Version available is the same - option to remove or reinstall
676 caption = "Do you wish to remove or reinstall\n%s?"; 676 caption = "Do you wish to remove or reinstall\n%s?";
677 text = "Remove or ReInstall"; 677 text = "Remove or ReInstall";
678 secondButton = "ReInstall"; 678 secondButton = "ReInstall";
679 secondOption = "R"; 679 secondOption = "R";
680 } 680 }
681 else if ( val == 1 ) 681 else if ( val == 1 )
682 { 682 {
683 // Version available is newer - option to remove or upgrade 683 // Version available is newer - option to remove or upgrade
684 caption = "Do you wish to remove or upgrade\n%s?"; 684 caption = "Do you wish to remove or upgrade\n%s?";
685 text = "Remove or Upgrade"; 685 text = "Remove or Upgrade";
686 secondButton = "Upgrade"; 686 secondButton = "Upgrade";
687 secondOption = "U"; 687 secondOption = "U";
688 } 688 }
689 689
690 // Sticky option not implemented yet, but will eventually allow 690 // Sticky option not implemented yet, but will eventually allow
691 // the user to say something like 'remove all' 691 // the user to say something like 'remove all'
692 if ( stickyOption == "" ) 692 if ( stickyOption == "" )
693 { 693 {
694 QString msgtext; 694 QString msgtext;
695 msgtext.sprintf( caption, (const char *)name ); 695 msgtext.sprintf( caption, (const char *)name );
696 switch( QMessageBox::information( this, text, 696 switch( QMessageBox::information( this, text,
697 msgtext, "Remove", secondButton ) ) 697 msgtext, "Remove", secondButton ) )
698 { 698 {
699 case 0: // Try again or Enter 699 case 0: // Try again or Enter
700 // option 0 = Remove 700 // option 0 = Remove
701 item.option = "D"; 701 item.option = "D";
702 break; 702 break;
703 case 1: // Quit or Escape 703 case 1: // Quit or Escape
704 item.option = secondOption; 704 item.option = secondOption;
705 break; 705 break;
706 } 706 }
707 } 707 }
708 else 708 else
709 { 709 {
710// item.option = stickyOption; 710// item.option = stickyOption;
711 } 711 }
712 } 712 }
713 713
714 714
715 // Check if we are reinstalling the same version 715 // Check if we are reinstalling the same version
716 if ( item.option != "R" ) 716 if ( item.option != "R" )
717 item.recreateLinks = true; 717 item.recreateLinks = true;
718 else 718 else
719 item.recreateLinks = false; 719 item.recreateLinks = false;
720 720
721 // User hit cancel (on dlg - assume remove) 721 // User hit cancel (on dlg - assume remove)
722 return item; 722 return item;
723 } 723 }
724} 724}
725 725
726void NetworkPackageManager :: displayText( const QString &t ) 726void NetworkPackageManager :: displayText( const QString &t )
727{ 727{
728 cout << t << endl; 728 cout << t << endl;
729} 729}
730 730
731 731
732void NetworkPackageManager :: letterPushed( QString t ) 732void NetworkPackageManager :: letterPushed( QString t )
733{ 733{
734 QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); 734 QCheckListItem *top = (QCheckListItem *)packagesList->firstChild();
735 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); 735 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem();
736 if ( packagesList->firstChild() == 0 ) 736 if ( packagesList->firstChild() == 0 )
737 return; 737 return;
738 738
739 QCheckListItem *item; 739 QCheckListItem *item;
740 if ( start == 0 ) 740 if ( start == 0 )
741 { 741 {
742 item = (QCheckListItem *)packagesList->firstChild(); 742 item = (QCheckListItem *)packagesList->firstChild();
743 start = top; 743 start = top;
744 } 744 }
745 else 745 else
746 item = (QCheckListItem *)start->nextSibling(); 746 item = (QCheckListItem *)start->nextSibling();
747 747
748 if ( item == 0 ) 748 if ( item == 0 )
749 item = (QCheckListItem *)packagesList->firstChild(); 749 item = (QCheckListItem *)packagesList->firstChild();
750 do 750 do
751 { 751 {
752 if ( item->text().lower().startsWith( t.lower() ) ) 752 if ( item->text().lower().startsWith( t.lower() ) )
753 { 753 {
754 packagesList->setSelected( item, true ); 754 packagesList->setSelected( item, true );
755 packagesList->ensureItemVisible( item ); 755 packagesList->ensureItemVisible( item );
756 break; 756 break;
757 } 757 }
758 758
759 item = (QCheckListItem *)item->nextSibling(); 759 item = (QCheckListItem *)item->nextSibling();
760 if ( !item ) 760 if ( !item )
761 item = (QCheckListItem *)packagesList->firstChild(); 761 item = (QCheckListItem *)packagesList->firstChild();
762 } while ( item != start); 762 } while ( item != start);
763} 763}
764 764
765 765
766void NetworkPackageManager :: searchForPackage( bool findNext ) 766void NetworkPackageManager :: searchForPackage( bool findNext )
767{ 767{
768 bool ok = false; 768 bool ok = false;
769 if ( !findNext || lastSearchText.isEmpty() ) 769 if ( !findNext || lastSearchText.isEmpty() )
770 lastSearchText = InputDialog::getText( "Search for package", "Enter package to search for", lastSearchText, &ok, this ).lower(); 770 lastSearchText = InputDialog::getText( "Search for package", "Enter package to search for", lastSearchText, &ok, this ).lower();
771 else 771 else
772 ok = true; 772 ok = true;
773 773
774 if ( ok && !lastSearchText.isEmpty() ) 774 if ( ok && !lastSearchText.isEmpty() )
775 { 775 {
776 cout << "searching for " << lastSearchText << endl; 776 cout << "searching for " << lastSearchText << endl;
777 // look through package list for text startng at current position 777 // look through package list for text startng at current position
778 vector<InstallData> workingPackages; 778 vector<InstallData> workingPackages;
779 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); 779 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem();
780 if ( start != 0 ) 780 if ( start != 0 )
781 start = (QCheckListItem *)start->nextSibling(); 781 start = (QCheckListItem *)start->nextSibling();
782 782
783 if ( start == 0 ) 783 if ( start == 0 )
784 start = (QCheckListItem *)packagesList->firstChild(); 784 start = (QCheckListItem *)packagesList->firstChild();
785 785
786 for ( QCheckListItem *item = start; item != 0 ; 786 for ( QCheckListItem *item = start; item != 0 ;
787 item = (QCheckListItem *)item->nextSibling() ) 787 item = (QCheckListItem *)item->nextSibling() )
788 { 788 {
789 cout << "checking " << item->text().lower() << endl; 789 cout << "checking " << item->text().lower() << endl;
790 if ( item->text().lower().find( lastSearchText ) != -1 ) 790 if ( item->text().lower().find( lastSearchText ) != -1 )
791 { 791 {
792 cout << "matched " << item->text() << endl; 792 cout << "matched " << item->text() << endl;
793 packagesList->ensureItemVisible( item ); 793 packagesList->ensureItemVisible( item );
794 packagesList->setCurrentItem( item ); 794 packagesList->setCurrentItem( item );
795 break; 795 break;
796 } 796 }
797 } 797 }
798 } 798 }
799} 799}
800 800
801void NetworkPackageManager :: showOnlyUninstalledPackages( bool val ) 801void NetworkPackageManager :: showOnlyUninstalledPackages( bool val )
802{ 802{
803 showUninstalledPkgs = val; 803 showUninstalledPkgs = val;
804 serverSelected( -1 ); 804 serverSelected( -1 );
805} 805}
806 806
807void NetworkPackageManager :: showOnlyInstalledPackages( bool val ) 807void NetworkPackageManager :: showOnlyInstalledPackages( bool val )
808{ 808{
809 showInstalledPkgs = val; 809 showInstalledPkgs = val;
810 serverSelected( -1 ); 810 serverSelected( -1 );
811} 811}
812 812
813void NetworkPackageManager :: showUpgradedPackages( bool val ) 813void NetworkPackageManager :: showUpgradedPackages( bool val )
814{ 814{
815 showUpgradedPkgs = val; 815 showUpgradedPkgs = val;
816 serverSelected( -1 ); 816 serverSelected( -1 );
817} 817}
818 818
819bool NetworkPackageManager :: filterByCategory( bool val ) 819bool NetworkPackageManager :: filterByCategory( bool val )
820{ 820{
821 if ( val ) 821 if ( val )
822 { 822 {
823 if ( categoryFilter == "" ) 823 if ( categoryFilter == "" )
824 { 824 {
825 if ( !setFilterCategory() ) 825 if ( !setFilterCategory() )
826 return false; 826 return false;
827 } 827 }
828 828
829 categoryFilterEnabled = true; 829 categoryFilterEnabled = true;
830 serverSelected( -1 ); 830 serverSelected( -1 );
831 return true; 831 return true;
832 } 832 }
833 else 833 else
834 { 834 {
835 // Turn off filter 835 // Turn off filter
836 categoryFilterEnabled = false; 836 categoryFilterEnabled = false;
837 serverSelected( -1 ); 837 serverSelected( -1 );
838 return false; 838 return false;
839 } 839 }
840} 840}
841 841
842bool NetworkPackageManager :: setFilterCategory( ) 842bool NetworkPackageManager :: setFilterCategory( )
843{ 843{
844 // Get categories; 844 // Get categories;
845 CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this ); 845 CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this );
846 if ( dlg.exec() == QDialog::Accepted ) 846 if ( dlg.exec() == QDialog::Accepted )
847 { 847 {
848 categoryFilter = dlg.getSelectedFilter(); 848 categoryFilter = dlg.getSelectedFilter();
849 849
850 if ( categoryFilter == "" ) 850 if ( categoryFilter == "" )
851 return false; 851 return false;
852 852
853 categoryFilterEnabled = true; 853 categoryFilterEnabled = true;
854 serverSelected( -1 ); 854 serverSelected( -1 );
855 return true; 855 return true;
856 } 856 }
857 857
858 return false; 858 return false;
859} 859}
diff --git a/noncore/settings/aqpkg/server.cpp b/noncore/settings/aqpkg/server.cpp
index 58407d5..2cb0533 100644
--- a/noncore/settings/aqpkg/server.cpp
+++ b/noncore/settings/aqpkg/server.cpp
@@ -1,307 +1,307 @@
1/*************************************************************************** 1/***************************************************************************
2 server.cpp - description 2 server.cpp - description
3 ------------------- 3 -------------------
4 begin : Mon Aug 26 2002 4 begin : Mon Aug 26 2002
5 copyright : (C) 2002 by Andy Qua 5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk 6 email : andy.qua@blueyonder.co.uk
7 description : This class holds details about a server 7 description : This class holds details about a server
8 : e.g. all the packages that contained on the server 8 : e.g. all the packages that contained on the server
9 : the installation status 9 : the installation status
10 ***************************************************************************/ 10 ***************************************************************************/
11 11
12/*************************************************************************** 12/***************************************************************************
13 * * 13 * *
14 * This program is free software; you can redistribute it and/or modify * 14 * This program is free software; you can redistribute it and/or modify *
15 * it under the terms of the GNU General Public License as published by * 15 * it under the terms of the GNU General Public License as published by *
16 * the Free Software Foundation; either version 2 of the License, or * 16 * the Free Software Foundation; either version 2 of the License, or *
17 * (at your option) any later version. * 17 * (at your option) any later version. *
18 * * 18 * *
19 ***************************************************************************/ 19 ***************************************************************************/
20 20
21 21
22#include <stdio.h> 22#include <stdio.h>
23#include <string.h> 23#include <string.h>
24#include <stdlib.h> 24#include <stdlib.h>
25 25
26#include <iostream> 26#include <iostream>
27#include <fstream> 27#include <fstream>
28using namespace std; 28using namespace std;
29 29
30#include "server.h" 30#include "server.h"
31#include "datamgr.h" 31#include "datamgr.h"
32 32
33#ifdef QWS 33#ifdef QWS
34#include <qpe/global.h> 34#include <qpe/global.h>
35#include <qpe/applnk.h> 35#include <qpe/applnk.h>
36#include <qlist.h> 36#include <qlist.h>
37#endif 37#endif
38 38
39#include "utils.h" 39#include "utils.h"
40 40
41#include "global.h" 41#include "global.h"
42 42
43Server :: Server( const char *name, const char *url ) 43Server :: Server( const char *name, const char *url )
44{ 44{
45 serverName = name; 45 serverName = name;
46 serverUrl = url; 46 serverUrl = url;
47 packageFile = IPKG_DIR; 47 packageFile = IPKG_DIR;
48 active = true; 48 active = true;
49 packageFile += "lists/" + serverName; 49 packageFile += "lists/" + serverName;
50} 50}
51 51
52Server :: ~Server() 52Server :: ~Server()
53{ 53{
54 cleanUp(); 54 cleanUp();
55} 55}
56 56
57void Server :: cleanUp() 57void Server :: cleanUp()
58{ 58{
59 packageList.clear(); 59 packageList.clear();
60} 60}
61 61
62void Server :: readStatusFile( vector<Destination> &destList ) 62void Server :: readStatusFile( vector<Destination> &destList )
63{ 63{
64 cleanUp(); 64 cleanUp();
65 65
66 vector<Destination>::iterator dit; 66 vector<Destination>::iterator dit;
67 bool rootRead = false; 67 bool rootRead = false;
68 for ( dit = destList.begin() ; dit != destList.end() ; ++dit ) 68 for ( dit = destList.begin() ; dit != destList.end() ; ++dit )
69 { 69 {
70 bool installingToRoot = false; 70 bool installingToRoot = false;
71 71
72 QString path = dit->getDestinationPath(); 72 QString path = dit->getDestinationPath();
73 if ( path.right( 1 ) != "/" ) 73 if ( path.right( 1 ) != "/" )
74 path += "/"; 74 path += "/";
75 75
76 if ( path == "/" ) 76 if ( path == "/" )
77 { 77 {
78 rootRead = true; 78 rootRead = true;
79 installingToRoot = true; 79 installingToRoot = true;
80 } 80 }
81 81
82 packageFile = path + "usr/lib/ipkg/status"; 82 packageFile = path + "usr/lib/ipkg/status";
83 readPackageFile( 0, false, installingToRoot, dit ); 83 readPackageFile( 0, false, installingToRoot, &( *dit ) );
84 } 84 }
85 85
86 // Ensure that the root status file is read 86 // Ensure that the root status file is read
87 if ( !rootRead ) 87 if ( !rootRead )
88 { 88 {
89 cout << "Reading status file " << "/usr/lib/ipkg/status" << endl; 89 cout << "Reading status file " << "/usr/lib/ipkg/status" << endl;
90 packageFile = "/usr/lib/ipkg/status"; 90 packageFile = "/usr/lib/ipkg/status";
91 readPackageFile( 0, false, true ); 91 readPackageFile( 0, false, true );
92 } 92 }
93} 93}
94 94
95void Server :: readLocalIpks( Server *local ) 95void Server :: readLocalIpks( Server *local )
96{ 96{
97 cleanUp(); 97 cleanUp();
98 98
99#ifdef QWS 99#ifdef QWS
100 // First, get any local IPKGs in the documents area 100 // First, get any local IPKGs in the documents area
101 // Only applicable to Qtopie/Opie 101 // Only applicable to Qtopie/Opie
102 102
103 DocLnkSet files; 103 DocLnkSet files;
104 Global::findDocuments( &files, "application/ipkg" ); 104 Global::findDocuments( &files, "application/ipkg" );
105 105
106 // Now add the items to the list 106 // Now add the items to the list
107 QListIterator<DocLnk> it( files.children() ); 107 QListIterator<DocLnk> it( files.children() );
108 108
109 for ( ; it.current() ; ++it ) 109 for ( ; it.current() ; ++it )
110 { 110 {
111 // OK, we have a local IPK file, I think the standard naming conventions 111 // OK, we have a local IPK file, I think the standard naming conventions
112 // for these are packagename_version_arm.ipk 112 // for these are packagename_version_arm.ipk
113 QString file = (*it)->file(); 113 QString file = (*it)->file();
114 114
115 // Changed to display the filename (excluding the path) 115 // Changed to display the filename (excluding the path)
116 QString packageName = Utils::getFilenameFromIpkFilename( file ); 116 QString packageName = Utils::getFilenameFromIpkFilename( file );
117 QString ver = Utils::getPackageVersionFromIpkFilename( file ); 117 QString ver = Utils::getPackageVersionFromIpkFilename( file );
118 packageList.push_back( Package( packageName ) ); 118 packageList.push_back( Package( packageName ) );
119 packageList.back().setVersion( ver ); 119 packageList.back().setVersion( ver );
120 packageList.back().setFilename( file ); 120 packageList.back().setFilename( file );
121 packageList.back().setPackageStoredLocally( true ); 121 packageList.back().setPackageStoredLocally( true );
122 122
123 } 123 }
124#else 124#else
125 QString names[] = { "advancedfm_0.9.1-20020811_arm.ipk", "libopie_0.9.1-20020811_arm.ipk", "libopieobex_0.9.1-20020811.1_arm.ipk", "opie-addressbook_0.9.1-20020811_arm.ipk" }; 125 QString names[] = { "advancedfm_0.9.1-20020811_arm.ipk", "libopie_0.9.1-20020811_arm.ipk", "libopieobex_0.9.1-20020811.1_arm.ipk", "opie-addressbook_0.9.1-20020811_arm.ipk" };
126 for ( int i = 0 ; i < 4 ; ++i ) 126 for ( int i = 0 ; i < 4 ; ++i )
127 { 127 {
128 // OK, we have a local IPK file, I think the standard naming conventions 128 // OK, we have a local IPK file, I think the standard naming conventions
129 // for these are packagename_version_arm.ipk 129 // for these are packagename_version_arm.ipk
130 QString file = names[i]; 130 QString file = names[i];
131 int p = file.find( "_" ); 131 int p = file.find( "_" );
132 QString tmp = file.mid( 0, p ); 132 QString tmp = file.mid( 0, p );
133 packageList.push_back( Package( tmp ) ); 133 packageList.push_back( Package( tmp ) );
134 int p2 = file.find( "_", p+1 ); 134 int p2 = file.find( "_", p+1 );
135 tmp = file.mid( p+1, p2-(p+1) ); 135 tmp = file.mid( p+1, p2-(p+1) );
136 packageList.back().setVersion( tmp ); 136 packageList.back().setVersion( tmp );
137 packageList.back().setPackageStoredLocally( true ); 137 packageList.back().setPackageStoredLocally( true );
138 } 138 }
139#endif 139#endif
140 140
141 // build local packages 141 // build local packages
142 buildLocalPackages( local ); 142 buildLocalPackages( local );
143} 143}
144 144
145void Server :: readPackageFile( Server *local, bool clearAll, bool installingToRoot, Destination *dest ) 145void Server :: readPackageFile( Server *local, bool clearAll, bool installingToRoot, Destination *dest )
146{ 146{
147 ifstream in( packageFile ); 147 ifstream in( packageFile );
148 if ( !in.is_open() ) 148 if ( !in.is_open() )
149 return; 149 return;
150 150
151 char line[1001]; 151 char line[1001];
152 char k[21]; 152 char k[21];
153 char v[1001]; 153 char v[1001];
154 QString key; 154 QString key;
155 QString value; 155 QString value;
156 156
157 if ( clearAll ) 157 if ( clearAll )
158 cleanUp(); 158 cleanUp();
159 Package *currPackage = 0; 159 Package *currPackage = 0;
160 160
161 bool newPackage = true; 161 bool newPackage = true;
162 do 162 do
163 { 163 {
164 in.getline( line, 1000 ); 164 in.getline( line, 1000 );
165 if ( in.eof() ) 165 if ( in.eof() )
166 continue; 166 continue;
167 167
168 k[0] = '\0'; 168 k[0] = '\0';
169 v[0] = '\0'; 169 v[0] = '\0';
170 170
171 sscanf( line, "%[^:]: %[^\n]", k, v ); 171 sscanf( line, "%[^:]: %[^\n]", k, v );
172 key = k; 172 key = k;
173 value = v; 173 value = v;
174 key = key.stripWhiteSpace(); 174 key = key.stripWhiteSpace();
175 value = value.stripWhiteSpace(); 175 value = value.stripWhiteSpace();
176 if ( key == "Package" && newPackage ) 176 if ( key == "Package" && newPackage )
177 { 177 {
178 newPackage = false; 178 newPackage = false;
179 179
180 currPackage = getPackage( value ); 180 currPackage = getPackage( value );
181 if ( !currPackage ) 181 if ( !currPackage )
182 { 182 {
183 packageList.push_back( Package( value ) ); 183 packageList.push_back( Package( value ) );
184 currPackage = &(packageList.back()); 184 currPackage = &(packageList.back());
185 currPackage->setInstalledTo( dest ); 185 currPackage->setInstalledTo( dest );
186 186
187 if ( installingToRoot ) 187 if ( installingToRoot )
188 currPackage->setInstalledToRoot( true ); 188 currPackage->setInstalledToRoot( true );
189 } 189 }
190 else 190 else
191 { 191 {
192 if (currPackage->getStatus().find( "deinstall" ) != -1 ) 192 if (currPackage->getStatus().find( "deinstall" ) != -1 )
193 currPackage->setInstalledTo( dest ); 193 currPackage->setInstalledTo( dest );
194 } 194 }
195 } 195 }
196 else if ( key == "Version" ) 196 else if ( key == "Version" )
197 { 197 {
198 if ( currPackage ) 198 if ( currPackage )
199 currPackage->setVersion( value ); 199 currPackage->setVersion( value );
200 } 200 }
201 else if ( key == "Status" ) 201 else if ( key == "Status" )
202 { 202 {
203 if ( currPackage ) 203 if ( currPackage )
204 currPackage->setStatus( value ); 204 currPackage->setStatus( value );
205 } 205 }
206 else if ( key == "Description" ) 206 else if ( key == "Description" )
207 { 207 {
208 if ( currPackage ) 208 if ( currPackage )
209 currPackage->setDescription( value ); 209 currPackage->setDescription( value );
210 } 210 }
211 else if ( key == "Filename" ) 211 else if ( key == "Filename" )
212 { 212 {
213 if ( currPackage ) 213 if ( currPackage )
214 currPackage->setFilename( value ); 214 currPackage->setFilename( value );
215 } 215 }
216 else if ( key == "Size" ) 216 else if ( key == "Size" )
217 { 217 {
218 if ( currPackage ) 218 if ( currPackage )
219 currPackage->setPackageSize( value ); 219 currPackage->setPackageSize( value );
220 } 220 }
221 else if ( key == "Section" ) 221 else if ( key == "Section" )
222 { 222 {
223 if ( currPackage ) 223 if ( currPackage )
224 currPackage->setSection( value ); 224 currPackage->setSection( value );
225 225
226 DataManager::setAvailableCategories( value ); 226 DataManager::setAvailableCategories( value );
227 } 227 }
228 else if ( key == "" ) 228 else if ( key == "" )
229 { 229 {
230 newPackage = true; 230 newPackage = true;
231 } 231 }
232 } while ( !in.eof() ); 232 } while ( !in.eof() );
233 233
234 in.close(); 234 in.close();
235 235
236 // build local packages 236 // build local packages
237 buildLocalPackages( local ); 237 buildLocalPackages( local );
238} 238}
239 239
240void Server :: buildLocalPackages( Server *local ) 240void Server :: buildLocalPackages( Server *local )
241{ 241{
242 for ( unsigned int i = 0 ; i < packageList.size() ; ++i ) 242 for ( unsigned int i = 0 ; i < packageList.size() ; ++i )
243 { 243 {
244 QString name = packageList[i].getPackageName(); 244 QString name = packageList[i].getPackageName();
245 245
246 // If the package name is an ipk name, then convert the filename to a package name 246 // If the package name is an ipk name, then convert the filename to a package name
247 if ( name.find( ".ipk" ) != -1 ) 247 if ( name.find( ".ipk" ) != -1 )
248 name = Utils::getPackageNameFromIpkFilename( packageList[i].getFilename() ); 248 name = Utils::getPackageNameFromIpkFilename( packageList[i].getFilename() );
249 249
250 if ( local ) 250 if ( local )
251 { 251 {
252 Package *p = local->getPackage( name ); 252 Package *p = local->getPackage( name );
253 packageList[i].setLocalPackage( p ); 253 packageList[i].setLocalPackage( p );
254 if ( p ) 254 if ( p )
255 { 255 {
256 // Set some default stuff like size and things 256 // Set some default stuff like size and things
257 if ( p->getInstalledVersion() == packageList[i].getVersion() ) 257 if ( p->getInstalledVersion() == packageList[i].getVersion() )
258 { 258 {
259 p->setPackageSize( packageList[i].getPackageSize() ); 259 p->setPackageSize( packageList[i].getPackageSize() );
260 p->setSection( packageList[i].getSection() ); 260 p->setSection( packageList[i].getSection() );
261 p->setDescription( packageList[i].getDescription() ); 261 p->setDescription( packageList[i].getDescription() );
262 } 262 }
263 } 263 }
264 264
265 } 265 }
266 else 266 else
267 packageList[i].setLocalPackage( 0 ); 267 packageList[i].setLocalPackage( 0 );
268 } 268 }
269 269
270} 270}
271 271
272Package *Server :: getPackage( QString &name ) 272Package *Server :: getPackage( QString &name )
273{ 273{
274 return getPackage( (const char *)name ); 274 return getPackage( (const char *)name );
275} 275}
276 276
277Package *Server :: getPackage( const char *name ) 277Package *Server :: getPackage( const char *name )
278{ 278{
279 Package *ret = 0; 279 Package *ret = 0;
280 280
281 for ( unsigned int i = 0 ; i < packageList.size() && ret == 0; ++i ) 281 for ( unsigned int i = 0 ; i < packageList.size() && ret == 0; ++i )
282 { 282 {
283 if ( packageList[i].getPackageName() == name ) 283 if ( packageList[i].getPackageName() == name )
284 ret = &packageList[i]; 284 ret = &packageList[i];
285 } 285 }
286 286
287 return ret; 287 return ret;
288} 288}
289 289
290QString Server :: toString() 290QString Server :: toString()
291{ 291{
292 QString ret = "Server\n name - " + serverName + 292 QString ret = "Server\n name - " + serverName +
293 "\n url - " + serverUrl + 293 "\n url - " + serverUrl +
294 "\n"; 294 "\n";
295 295
296 for ( unsigned int i = 0 ; i < packageList.size() ; ++i ) 296 for ( unsigned int i = 0 ; i < packageList.size() ; ++i )
297 ret += "\n " + packageList[i].toString(); 297 ret += "\n " + packageList[i].toString();
298 298
299 299
300 return ret; 300 return ret;
301} 301}
302 302
303vector<Package> &Server::getPackageList() 303vector<Package> &Server::getPackageList()
304{ 304{
305 return packageList; 305 return packageList;
306} 306}
307 307
diff --git a/noncore/settings/aqpkg/settingsimpl.cpp b/noncore/settings/aqpkg/settingsimpl.cpp
index a18a178..9dd2206 100644
--- a/noncore/settings/aqpkg/settingsimpl.cpp
+++ b/noncore/settings/aqpkg/settingsimpl.cpp
@@ -1,245 +1,246 @@
1/*************************************************************************** 1/***************************************************************************
2 settingsimpl.cpp - description 2 settingsimpl.cpp - description
3 ------------------- 3 -------------------
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#include <fstream> 18#include <fstream>
19#include <algorithm>
19using namespace std; 20using namespace std;
20 21
21#include <qlistbox.h> 22#include <qlistbox.h>
22#include <qlineedit.h> 23#include <qlineedit.h>
23#include <qpushbutton.h> 24#include <qpushbutton.h>
24#include <qtabwidget.h> 25#include <qtabwidget.h>
25#include <qcheckbox.h> 26#include <qcheckbox.h>
26 27
27#ifdef QWS 28#ifdef QWS
28#include <qpe/config.h> 29#include <qpe/config.h>
29#endif 30#endif
30 31
31#include "settingsimpl.h" 32#include "settingsimpl.h"
32 33
33#include "global.h" 34#include "global.h"
34 35
35SettingsImpl :: SettingsImpl( DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl ) 36SettingsImpl :: SettingsImpl( DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl )
36 : SettingsBase( parent, name, modal, fl ) 37 : SettingsBase( parent, name, modal, fl )
37{ 38{
38 dataMgr = dataManager; 39 dataMgr = dataManager;
39 40
40 setupData(); 41 setupData();
41 changed = false; 42 changed = false;
42 newserver = false; 43 newserver = false;
43 newdestination = false; 44 newdestination = false;
44} 45}
45 46
46SettingsImpl :: ~SettingsImpl() 47SettingsImpl :: ~SettingsImpl()
47{ 48{
48 49
49} 50}
50 51
51bool SettingsImpl :: showDlg( int i ) 52bool SettingsImpl :: showDlg( int i )
52{ 53{
53 TabWidget->setCurrentPage( i ); 54 TabWidget->setCurrentPage( i );
54 showMaximized(); 55 showMaximized();
55 exec(); 56 exec();
56 57
57 if ( changed ) 58 if ( changed )
58 dataMgr->writeOutIpkgConf(); 59 dataMgr->writeOutIpkgConf();
59 60
60 return changed; 61 return changed;
61} 62}
62 63
63void SettingsImpl :: setupData() 64void SettingsImpl :: setupData()
64{ 65{
65 // add servers 66 // add servers
66 vector<Server>::iterator it; 67 vector<Server>::iterator it;
67 for ( it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it ) 68 for ( it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it )
68 { 69 {
69 if ( it->getServerName() == LOCAL_SERVER || it->getServerName() == LOCAL_IPKGS ) 70 if ( it->getServerName() == LOCAL_SERVER || it->getServerName() == LOCAL_IPKGS )
70 continue; 71 continue;
71 72
72 servers->insertItem( it->getServerName() ); 73 servers->insertItem( it->getServerName() );
73 } 74 }
74 75
75 // add destinations 76 // add destinations
76 vector<Destination>::iterator it2; 77 vector<Destination>::iterator it2;
77 for ( it2 = dataMgr->getDestinationList().begin() ; it2 != dataMgr->getDestinationList().end() ; ++it2 ) 78 for ( it2 = dataMgr->getDestinationList().begin() ; it2 != dataMgr->getDestinationList().end() ; ++it2 )
78 destinations->insertItem( it2->getDestinationName() ); 79 destinations->insertItem( it2->getDestinationName() );
79 80
80#ifdef QWS 81#ifdef QWS
81 Config cfg( "aqpkg" ); 82 Config cfg( "aqpkg" );
82 cfg.setGroup( "settings" ); 83 cfg.setGroup( "settings" );
83 jumpTo->setChecked( cfg.readBoolEntry( "showJumpTo", "true" ) ); 84 jumpTo->setChecked( cfg.readBoolEntry( "showJumpTo", "true" ) );
84#else 85#else
85 jumpTo->setChecked( true ); 86 jumpTo->setChecked( true );
86#endif 87#endif
87} 88}
88 89
89//------------------ Servers tab ---------------------- 90//------------------ Servers tab ----------------------
90 91
91void SettingsImpl :: editServer( int sel ) 92void SettingsImpl :: editServer( int sel )
92{ 93{
93 currentSelectedServer = sel; 94 currentSelectedServer = sel;
94 Server *s = dataMgr->getServer( servers->currentText() ); 95 vector<Server>::iterator s = dataMgr->getServer( servers->currentText() );
95 serverName = s->getServerName(); 96 serverName = s->getServerName();
96 servername->setText( s->getServerName() ); 97 servername->setText( s->getServerName() );
97 serverurl->setText( s->getServerUrl() ); 98 serverurl->setText( s->getServerUrl() );
98 active->setChecked( s->isServerActive() ); 99 active->setChecked( s->isServerActive() );
99} 100}
100 101
101void SettingsImpl :: newServer() 102void SettingsImpl :: newServer()
102{ 103{
103 newserver = true; 104 newserver = true;
104 servername->setText( "" ); 105 servername->setText( "" );
105 serverurl->setText( "" ); 106 serverurl->setText( "" );
106 servername->setFocus(); 107 servername->setFocus();
107 active->setChecked( true ); 108 active->setChecked( true );
108} 109}
109 110
110void SettingsImpl :: removeServer() 111void SettingsImpl :: removeServer()
111{ 112{
112 changed = true; 113 changed = true;
113 Server *s = dataMgr->getServer( servers->currentText() ); 114 vector<Server>::iterator s = dataMgr->getServer( servers->currentText() );
114 dataMgr->getServerList().erase( s ); 115 dataMgr->getServerList().erase( s );
115 servers->removeItem( currentSelectedServer ); 116 servers->removeItem( currentSelectedServer );
116} 117}
117 118
118void SettingsImpl :: changeServerDetails() 119void SettingsImpl :: changeServerDetails()
119{ 120{
120 changed = true; 121 changed = true;
121 122
122 QString newName = servername->text(); 123 QString newName = servername->text();
123 if ( !newserver ) 124 if ( !newserver )
124 { 125 {
125 Server *s = dataMgr->getServer( serverName ); 126 vector<Server>::iterator s = dataMgr->getServer( servers->currentText() );
126 127
127 // Update url 128 // Update url
128 s->setServerUrl( serverurl->text() ); 129 s->setServerUrl( serverurl->text() );
129 s->setActive( active->isChecked() ); 130 s->setActive( active->isChecked() );
130 131
131 132
132 // Check if server name has changed, if it has then we need to replace the key in the map 133 // Check if server name has changed, if it has then we need to replace the key in the map
133 if ( serverName != newName ) 134 if ( serverName != newName )
134 { 135 {
135 // Update server name 136 // Update server name
136 s->setServerName( newName ); 137 s->setServerName( newName );
137 138
138 // See if this server is the active server 139 // See if this server is the active server
139 // if ( dataMgr->getActiveServer() == serverName ) 140 // if ( dataMgr->getActiveServer() == serverName )
140 // dataMgr->setActiveServer( newName ); 141 // dataMgr->setActiveServer( newName );
141 142
142 // Update list box 143 // Update list box
143 servers->changeItem( newName, currentSelectedServer ); 144 servers->changeItem( newName, currentSelectedServer );
144 } 145 }
145 } 146 }
146 else 147 else
147 { 148 {
148 Server s( newName, serverurl->text() ); 149 Server s( newName, serverurl->text() );
149 dataMgr->getServerList().push_back( Server( newName, serverurl->text() ) ); 150 dataMgr->getServerList().push_back( Server( newName, serverurl->text() ) );
150 dataMgr->getServerList().end()->setActive( active->isChecked() ); 151 dataMgr->getServerList().end()->setActive( active->isChecked() );
151 servers->insertItem( newName ); 152 servers->insertItem( newName );
152 servers->setCurrentItem( servers->count() ); 153 servers->setCurrentItem( servers->count() );
153 newserver = false; 154 newserver = false;
154 } 155 }
155} 156}
156 157
157//------------------ Destinations tab ---------------------- 158//------------------ Destinations tab ----------------------
158 159
159void SettingsImpl :: editDestination( int sel ) 160void SettingsImpl :: editDestination( int sel )
160{ 161{
161 currentSelectedDestination = sel; 162 currentSelectedDestination = sel;
162 Destination *d = dataMgr->getDestination( destinations->currentText() ); 163 vector<Destination>::iterator d = dataMgr->getDestination( destinations->currentText() );
163 destinationName = d->getDestinationName(); 164 destinationName = d->getDestinationName();
164 destinationname->setText( d->getDestinationName() ); 165 destinationname->setText( d->getDestinationName() );
165 destinationurl->setText( d->getDestinationPath() ); 166 destinationurl->setText( d->getDestinationPath() );
166 linkToRoot->setChecked( d->linkToRoot() ); 167 linkToRoot->setChecked( d->linkToRoot() );
167} 168}
168 169
169void SettingsImpl :: newDestination() 170void SettingsImpl :: newDestination()
170{ 171{
171 newdestination = true; 172 newdestination = true;
172 destinationname->setText( "" ); 173 destinationname->setText( "" );
173 destinationurl->setText( "" ); 174 destinationurl->setText( "" );
174 destinationname->setFocus(); 175 destinationname->setFocus();
175 linkToRoot->setChecked( true ); 176 linkToRoot->setChecked( true );
176} 177}
177 178
178void SettingsImpl :: removeDestination() 179void SettingsImpl :: removeDestination()
179{ 180{
180 changed = true; 181 changed = true;
181 Destination *d = dataMgr->getDestination( destinations->currentText() ); 182 vector<Destination>::iterator d = dataMgr->getDestination( destinations->currentText() );
182 dataMgr->getDestinationList().erase( d ); 183 dataMgr->getDestinationList().erase( d );
183 destinations->removeItem( currentSelectedDestination ); 184 destinations->removeItem( currentSelectedDestination );
184} 185}
185 186
186void SettingsImpl :: changeDestinationDetails() 187void SettingsImpl :: changeDestinationDetails()
187{ 188{
188 changed = true; 189 changed = true;
189 190
190#ifdef QWS 191#ifdef QWS
191 Config cfg( "aqpkg" ); 192 Config cfg( "aqpkg" );
192 cfg.setGroup( "destinations" ); 193 cfg.setGroup( "destinations" );
193#endif 194#endif
194 195
195 QString newName = destinationname->text(); 196 QString newName = destinationname->text();
196 if ( !newdestination ) 197 if ( !newdestination )
197 { 198 {
198 Destination *d = dataMgr->getDestination( destinationName ); 199 vector<Destination>::iterator d = dataMgr->getDestination( destinations->currentText() );
199 200
200 // Update url 201 // Update url
201 d->setDestinationPath( destinationurl->text() ); 202 d->setDestinationPath( destinationurl->text() );
202 d->linkToRoot( linkToRoot->isChecked() ); 203 d->linkToRoot( linkToRoot->isChecked() );
203 204
204 // Check if server name has changed, if it has then we need to replace the key in the map 205 // Check if server name has changed, if it has then we need to replace the key in the map
205 if ( destinationName != newName ) 206 if ( destinationName != newName )
206 { 207 {
207 // Update server name 208 // Update server name
208 d->setDestinationName( newName ); 209 d->setDestinationName( newName );
209 210
210 // Update list box 211 // Update list box
211 destinations->changeItem( newName, currentSelectedDestination ); 212 destinations->changeItem( newName, currentSelectedDestination );
212 } 213 }
213#ifdef QWS 214#ifdef QWS
214 QString key = newName; 215 QString key = newName;
215 key += "_linkToRoot"; 216 key += "_linkToRoot";
216 int val = d->linkToRoot(); 217 int val = d->linkToRoot();
217 cfg.writeEntry( key, val ); 218 cfg.writeEntry( key, val );
218#endif 219#endif
219 } 220 }
220 else 221 else
221 { 222 {
222 dataMgr->getDestinationList().push_back( Destination( newName, destinationurl->text() ) ); 223 dataMgr->getDestinationList().push_back( Destination( newName, destinationurl->text() ) );
223 destinations->insertItem( newName ); 224 destinations->insertItem( newName );
224 destinations->setCurrentItem( destinations->count() ); 225 destinations->setCurrentItem( destinations->count() );
225 newdestination = false; 226 newdestination = false;
226 227
227#ifdef QWS 228#ifdef QWS
228 QString key = newName; 229 QString key = newName;
229 key += "_linkToRoot"; 230 key += "_linkToRoot";
230 cfg.writeEntry( key, true ); 231 cfg.writeEntry( key, true );
231#endif 232#endif
232 } 233 }
233} 234}
234 235
235//------------------ General tab ---------------------- 236//------------------ General tab ----------------------
236 237
237void SettingsImpl :: toggleJumpTo( bool val ) 238void SettingsImpl :: toggleJumpTo( bool val )
238{ 239{
239#ifdef QWS 240#ifdef QWS
240 Config cfg( "aqpkg" ); 241 Config cfg( "aqpkg" );
241 cfg.setGroup( "settings" ); 242 cfg.setGroup( "settings" );
242 cfg.writeEntry( "showJumpTo", val ); 243 cfg.writeEntry( "showJumpTo", val );
243#endif 244#endif
244} 245}
245 246