author | drw <drw> | 2003-06-11 02:04:00 (UTC) |
---|---|---|
committer | drw <drw> | 2003-06-11 02:04:00 (UTC) |
commit | d47a08d2f8944deb1ee0945075c3443de82442ea (patch) (unidiff) | |
tree | 807387a6bf5cfd9b445f14e6560118cc652e1868 | |
parent | 57d61689f8212e317d8f578dc29cb63f572caf81 (diff) | |
download | opie-d47a08d2f8944deb1ee0945075c3443de82442ea.zip opie-d47a08d2f8944deb1ee0945075c3443de82442ea.tar.gz opie-d47a08d2f8944deb1ee0945075c3443de82442ea.tar.bz2 |
Some missing/fixed tr()s for HEAD
-rw-r--r-- | noncore/settings/aqpkg/datamgr.cpp | 19 | ||||
-rw-r--r-- | noncore/settings/aqpkg/datamgr.h | 8 | ||||
-rw-r--r-- | noncore/settings/aqpkg/global.h | 4 | ||||
-rw-r--r-- | noncore/settings/aqpkg/installdlgimpl.cpp | 4 | ||||
-rw-r--r-- | noncore/settings/aqpkg/ipkg.cpp | 139 | ||||
-rw-r--r-- | noncore/settings/aqpkg/main.cpp | 9 | ||||
-rw-r--r-- | noncore/settings/aqpkg/mainwin.cpp | 6 | ||||
-rw-r--r-- | noncore/settings/aqpkg/mem.cpp | 2 | ||||
-rw-r--r-- | noncore/settings/aqpkg/package.cpp | 35 | ||||
-rw-r--r-- | noncore/settings/aqpkg/version.cpp | 39 |
10 files changed, 107 insertions, 158 deletions
diff --git a/noncore/settings/aqpkg/datamgr.cpp b/noncore/settings/aqpkg/datamgr.cpp index cd0c78f..67f90a3 100644 --- a/noncore/settings/aqpkg/datamgr.cpp +++ b/noncore/settings/aqpkg/datamgr.cpp | |||
@@ -1,312 +1,315 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | 3 | ||
4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> | 4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> |
5 | .=l. Dan Williams <drw@handhelds.org> | 5 | .=l. Dan Williams <drw@handhelds.org> |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This file is free software; you can | 7 | _;:, .> :=|. This file is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
19 | ..}^=.= = ; Public License for more details. | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | 20 | ++= -. .` .: |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | : = ...= . :.=- You should have received a copy of the GNU |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #ifdef QWS | 30 | #ifdef QWS |
31 | #include <qpe/config.h> | 31 | #include <qpe/config.h> |
32 | #include <qpe/qpeapplication.h> | 32 | #include <qpe/qpeapplication.h> |
33 | #else | 33 | #else |
34 | #include <qapplication.h> | 34 | #include <qapplication.h> |
35 | #endif | 35 | #endif |
36 | 36 | ||
37 | #include <qfile.h> | 37 | #include <qfile.h> |
38 | #include <qtextstream.h> | 38 | #include <qtextstream.h> |
39 | 39 | ||
40 | #include "datamgr.h" | 40 | #include "datamgr.h" |
41 | #include "global.h" | 41 | #include "global.h" |
42 | 42 | ||
43 | QString LOCAL_SERVER; | ||
44 | QString LOCAL_IPKGS; | ||
45 | |||
43 | 46 | ||
44 | QString DataManager::availableCategories = ""; | 47 | QString DataManager::availableCategories = ""; |
45 | DataManager::DataManager() | 48 | DataManager::DataManager() |
46 | : QObject( 0x0, 0x0 ) | 49 | : QObject( 0x0, 0x0 ) |
47 | { | 50 | { |
48 | activeServer = ""; | 51 | activeServer = ""; |
49 | availableCategories = "#"; | 52 | availableCategories = "#"; |
50 | 53 | ||
51 | serverList.setAutoDelete( TRUE ); | 54 | serverList.setAutoDelete( TRUE ); |
52 | destList.setAutoDelete( TRUE ); | 55 | destList.setAutoDelete( TRUE ); |
53 | } | 56 | } |
54 | 57 | ||
55 | DataManager::~DataManager() | 58 | DataManager::~DataManager() |
56 | { | 59 | { |
57 | } | 60 | } |
58 | 61 | ||
59 | Server *DataManager :: getServer( const char *name ) | 62 | Server *DataManager :: getServer( const char *name ) |
60 | { | 63 | { |
61 | QListIterator<Server> it( serverList ); | 64 | QListIterator<Server> it( serverList ); |
62 | while ( it.current() && it.current()->getServerName() != name ) | 65 | while ( it.current() && it.current()->getServerName() != name ) |
63 | { | 66 | { |
64 | ++it; | 67 | ++it; |
65 | } | 68 | } |
66 | 69 | ||
67 | return it.current(); | 70 | return it.current(); |
68 | } | 71 | } |
69 | 72 | ||
70 | Destination *DataManager :: getDestination( const char *name ) | 73 | Destination *DataManager :: getDestination( const char *name ) |
71 | { | 74 | { |
72 | QListIterator<Destination> it( destList ); | 75 | QListIterator<Destination> it( destList ); |
73 | while ( it.current() && it.current()->getDestinationName() != name ) | 76 | while ( it.current() && it.current()->getDestinationName() != name ) |
74 | { | 77 | { |
75 | ++it; | 78 | ++it; |
76 | } | 79 | } |
77 | 80 | ||
78 | return it.current(); | 81 | return it.current(); |
79 | } | 82 | } |
80 | 83 | ||
81 | void DataManager :: loadServers() | 84 | void DataManager :: loadServers() |
82 | { | 85 | { |
83 | // First add our local server - not really a server but | 86 | // First add our local server - not really a server but |
84 | // the local config (which packages are installed) | 87 | // the local config (which packages are installed) |
85 | serverList.append( new Server( LOCAL_SERVER, "" ) ); | 88 | serverList.append( new Server( LOCAL_SERVER, "" ) ); |
86 | serverList.append( new Server( LOCAL_IPKGS, "" ) ); | 89 | serverList.append( new Server( LOCAL_IPKGS, "" ) ); |
87 | 90 | ||
88 | #ifdef QWS | 91 | #ifdef QWS |
89 | Config cfg( "aqpkg" ); | 92 | Config cfg( "aqpkg" ); |
90 | cfg.setGroup( "destinations" ); | 93 | cfg.setGroup( "destinations" ); |
91 | #endif | 94 | #endif |
92 | 95 | ||
93 | // Read file from /etc/ipkg.conf | 96 | // Read file from /etc/ipkg.conf |
94 | QString ipkg_conf = IPKG_CONF; | 97 | QString ipkg_conf = IPKG_CONF; |
95 | FILE *fp; | 98 | FILE *fp; |
96 | fp = fopen( ipkg_conf, "r" ); | 99 | fp = fopen( ipkg_conf, "r" ); |
97 | char line[130]; | 100 | char line[130]; |
98 | QString lineStr; | 101 | QString lineStr; |
99 | if ( fp == NULL ) | 102 | if ( fp == NULL ) |
100 | { | 103 | { |
101 | return; | 104 | return; |
102 | } | 105 | } |
103 | else | 106 | else |
104 | { | 107 | { |
105 | while ( fgets( line, sizeof line, fp) != NULL ) | 108 | while ( fgets( line, sizeof line, fp) != NULL ) |
106 | { | 109 | { |
107 | lineStr = line; | 110 | lineStr = line; |
108 | if ( lineStr.startsWith( "src" ) || lineStr.startsWith( "#src" ) || lineStr.startsWith( "# src" ) ) | 111 | if ( lineStr.startsWith( "src" ) || lineStr.startsWith( "#src" ) || lineStr.startsWith( "# src" ) ) |
109 | { | 112 | { |
110 | char alias[20]; | 113 | char alias[20]; |
111 | char url[100]; | 114 | char url[100]; |
112 | 115 | ||
113 | // Looks a little wierd but read up to the r of src (throwing it away), | 116 | // Looks a little wierd but read up to the r of src (throwing it away), |
114 | // then read up to the next space and throw that away, the alias | 117 | // then read up to the next space and throw that away, the alias |
115 | // is next. | 118 | // is next. |
116 | // Should Handle #src, # src, src, and combinations of | 119 | // Should Handle #src, # src, src, and combinations of |
117 | sscanf( lineStr, "%*[^r]%*[^ ] %s %s", alias, url ); | 120 | sscanf( lineStr, "%*[^r]%*[^ ] %s %s", alias, url ); |
118 | Server *s = new Server( alias, url ); | 121 | Server *s = new Server( alias, url ); |
119 | if ( lineStr.startsWith( "src" ) ) | 122 | if ( lineStr.startsWith( "src" ) ) |
120 | s->setActive( true ); | 123 | s->setActive( true ); |
121 | else | 124 | else |
122 | s->setActive( false ); | 125 | s->setActive( false ); |
123 | 126 | ||
124 | serverList.append( s ); | 127 | serverList.append( s ); |
125 | 128 | ||
126 | } | 129 | } |
127 | else if ( lineStr.startsWith( "dest" ) ) | 130 | else if ( lineStr.startsWith( "dest" ) ) |
128 | { | 131 | { |
129 | char alias[20]; | 132 | char alias[20]; |
130 | char path[50]; | 133 | char path[50]; |
131 | sscanf( lineStr, "%*[^ ] %s %s", alias, path ); | 134 | sscanf( lineStr, "%*[^ ] %s %s", alias, path ); |
132 | Destination *d = new Destination( alias, path ); | 135 | Destination *d = new Destination( alias, path ); |
133 | bool linkToRoot = true; | 136 | bool linkToRoot = true; |
134 | #ifdef QWS | 137 | #ifdef QWS |
135 | QString key = alias; | 138 | QString key = alias; |
136 | key += "_linkToRoot"; | 139 | key += "_linkToRoot"; |
137 | linkToRoot = cfg.readBoolEntry( key, true ); | 140 | linkToRoot = cfg.readBoolEntry( key, true ); |
138 | #endif | 141 | #endif |
139 | d->linkToRoot( linkToRoot ); | 142 | d->linkToRoot( linkToRoot ); |
140 | 143 | ||
141 | destList.append( d ); | 144 | destList.append( d ); |
142 | } | 145 | } |
143 | else if ( lineStr.startsWith( "option" ) || lineStr.startsWith( "#option" ) ) | 146 | else if ( lineStr.startsWith( "option" ) || lineStr.startsWith( "#option" ) ) |
144 | { | 147 | { |
145 | char type[20]; | 148 | char type[20]; |
146 | char val[100]; | 149 | char val[100]; |
147 | sscanf( lineStr, "%*[^ ] %s %s", type, val ); | 150 | sscanf( lineStr, "%*[^ ] %s %s", type, val ); |
148 | if ( stricmp( type, "http_proxy" ) == 0 ) | 151 | if ( stricmp( type, "http_proxy" ) == 0 ) |
149 | { | 152 | { |
150 | httpProxy = val; | 153 | httpProxy = val; |
151 | if ( lineStr.startsWith( "#" ) ) | 154 | if ( lineStr.startsWith( "#" ) ) |
152 | httpProxyEnabled = false; | 155 | httpProxyEnabled = false; |
153 | else | 156 | else |
154 | httpProxyEnabled = true; | 157 | httpProxyEnabled = true; |
155 | } | 158 | } |
156 | if ( stricmp( type, "ftp_proxy" ) == 0 ) | 159 | if ( stricmp( type, "ftp_proxy" ) == 0 ) |
157 | { | 160 | { |
158 | ftpProxy = val; | 161 | ftpProxy = val; |
159 | if ( lineStr.startsWith( "#" ) ) | 162 | if ( lineStr.startsWith( "#" ) ) |
160 | ftpProxyEnabled = false; | 163 | ftpProxyEnabled = false; |
161 | else | 164 | else |
162 | ftpProxyEnabled = true; | 165 | ftpProxyEnabled = true; |
163 | } | 166 | } |
164 | if ( stricmp( type, "proxy_username" ) == 0 ) | 167 | if ( stricmp( type, "proxy_username" ) == 0 ) |
165 | proxyUsername = val; | 168 | proxyUsername = val; |
166 | if ( stricmp( type, "proxy_password" ) == 0 ) | 169 | if ( stricmp( type, "proxy_password" ) == 0 ) |
167 | proxyPassword = val; | 170 | proxyPassword = val; |
168 | } | 171 | } |
169 | } | 172 | } |
170 | } | 173 | } |
171 | fclose( fp ); | 174 | fclose( fp ); |
172 | 175 | ||
173 | reloadServerData( ); | 176 | reloadServerData( ); |
174 | } | 177 | } |
175 | 178 | ||
176 | void DataManager :: reloadServerData( ) | 179 | void DataManager :: reloadServerData( ) |
177 | { | 180 | { |
178 | emit progressSetSteps( serverList.count() ); | 181 | emit progressSetSteps( serverList.count() ); |
179 | emit progressSetMessage( tr( "Reading configuration..." ) ); | 182 | emit progressSetMessage( tr( "Reading configuration..." ) ); |
180 | 183 | ||
181 | QString serverName; | 184 | QString serverName; |
182 | int i = 0; | 185 | int i = 0; |
183 | 186 | ||
184 | Server *server; | 187 | Server *server; |
185 | QListIterator<Server> it( serverList ); | 188 | QListIterator<Server> it( serverList ); |
186 | for ( ; it.current(); ++it ) | 189 | for ( ; it.current(); ++it ) |
187 | { | 190 | { |
188 | server = it.current(); | 191 | server = it.current(); |
189 | serverName = server->getServerName(); | 192 | serverName = server->getServerName(); |
190 | i++; | 193 | i++; |
191 | emit progressUpdate( i ); | 194 | emit progressUpdate( i ); |
192 | qApp->processEvents(); | 195 | qApp->processEvents(); |
193 | 196 | ||
194 | // Now we've read the config file in we need to read the servers | 197 | // Now we've read the config file in we need to read the servers |
195 | // The local server is a special case. This holds the contents of the | 198 | // The local server is a special case. This holds the contents of the |
196 | // status files the number of which depends on how many destinations | 199 | // status files the number of which depends on how many destinations |
197 | // we've set up | 200 | // we've set up |
198 | // The other servers files hold the contents of the server package list | 201 | // The other servers files hold the contents of the server package list |
199 | if ( serverName == LOCAL_SERVER ) | 202 | if ( serverName == LOCAL_SERVER ) |
200 | server->readStatusFile( destList ); | 203 | server->readStatusFile( destList ); |
201 | else if ( serverName == LOCAL_IPKGS ) | 204 | else if ( serverName == LOCAL_IPKGS ) |
202 | server->readLocalIpks( getServer( LOCAL_SERVER ) ); | 205 | server->readLocalIpks( getServer( LOCAL_SERVER ) ); |
203 | else | 206 | else |
204 | server->readPackageFile( getServer( LOCAL_SERVER ) ); | 207 | server->readPackageFile( getServer( LOCAL_SERVER ) ); |
205 | } | 208 | } |
206 | } | 209 | } |
207 | 210 | ||
208 | void DataManager :: writeOutIpkgConf() | 211 | void DataManager :: writeOutIpkgConf() |
209 | { | 212 | { |
210 | QFile f( IPKG_CONF ); | 213 | QFile f( IPKG_CONF ); |
211 | if ( !f.open( IO_WriteOnly ) ) | 214 | if ( !f.open( IO_WriteOnly ) ) |
212 | { | 215 | { |
213 | return; | 216 | return; |
214 | } | 217 | } |
215 | 218 | ||
216 | QTextStream t( &f ); | 219 | QTextStream t( &f ); |
217 | /* | 220 | /* |
218 | QString ipkg_conf = IPKG_CONF; | 221 | QString ipkg_conf = IPKG_CONF; |
219 | ofstream out( ipkg_conf ); | 222 | ofstream out( ipkg_conf ); |
220 | */ | 223 | */ |
221 | t << "# Written by AQPkg\n"; | 224 | t << "# Written by AQPkg\n"; |
222 | t << "# Must have one or more source entries of the form:\n"; | 225 | t << "# Must have one or more source entries of the form:\n"; |
223 | t << "#\n"; | 226 | t << "#\n"; |
224 | t << "# src <src-name> <source-url>\n"; | 227 | t << "# src <src-name> <source-url>\n"; |
225 | t << "#\n"; | 228 | t << "#\n"; |
226 | t << "# and one or more destination entries of the form:\n"; | 229 | t << "# and one or more destination entries of the form:\n"; |
227 | t << "#\n"; | 230 | t << "#\n"; |
228 | t << "# dest <dest-name> <target-path>\n"; | 231 | t << "# dest <dest-name> <target-path>\n"; |
229 | t << "#\n"; | 232 | t << "#\n"; |
230 | t << "# where <src-name> and <dest-names> are identifiers that\n"; | 233 | t << "# where <src-name> and <dest-names> are identifiers that\n"; |
231 | t << "# should match [a-zA-Z0-9._-]+, <source-url> should be a\n"; | 234 | t << "# should match [a-zA-Z0-9._-]+, <source-url> should be a\n"; |
232 | t << "# URL that points to a directory containing a Familiar\n"; | 235 | t << "# URL that points to a directory containing a Familiar\n"; |
233 | t << "# Packages file, and <target-path> should be a directory\n"; | 236 | t << "# Packages file, and <target-path> should be a directory\n"; |
234 | t << "# that exists on the target system.\n\n"; | 237 | t << "# that exists on the target system.\n\n"; |
235 | 238 | ||
236 | // Write out servers | 239 | // Write out servers |
237 | Server *server; | 240 | Server *server; |
238 | QListIterator<Server> it( serverList ); | 241 | QListIterator<Server> it( serverList ); |
239 | while ( it.current() ) | 242 | while ( it.current() ) |
240 | { | 243 | { |
241 | server = it.current(); | 244 | server = it.current(); |
242 | QString alias = server->getServerName(); | 245 | QString alias = server->getServerName(); |
243 | // Don't write out local as its a dummy | 246 | // Don't write out local as its a dummy |
244 | if ( alias != LOCAL_SERVER && alias != LOCAL_IPKGS ) | 247 | if ( alias != LOCAL_SERVER && alias != LOCAL_IPKGS ) |
245 | { | 248 | { |
246 | QString url = server->getServerUrl();; | 249 | QString url = server->getServerUrl();; |
247 | 250 | ||
248 | if ( !server->isServerActive() ) | 251 | if ( !server->isServerActive() ) |
249 | t << "#"; | 252 | t << "#"; |
250 | t << "src " << alias << " " << url << endl; | 253 | t << "src " << alias << " " << url << endl; |
251 | } | 254 | } |
252 | 255 | ||
253 | ++it; | 256 | ++it; |
254 | } | 257 | } |
255 | 258 | ||
256 | t << endl; | 259 | t << endl; |
257 | 260 | ||
258 | // Write out destinations | 261 | // Write out destinations |
259 | QListIterator<Destination> it2( destList ); | 262 | QListIterator<Destination> it2( destList ); |
260 | while ( it2.current() ) | 263 | while ( it2.current() ) |
261 | { | 264 | { |
262 | t << "dest " << it2.current()->getDestinationName() << " " << it2.current()->getDestinationPath() << endl; | 265 | t << "dest " << it2.current()->getDestinationName() << " " << it2.current()->getDestinationPath() << endl; |
263 | ++it2; | 266 | ++it2; |
264 | } | 267 | } |
265 | 268 | ||
266 | t << endl; | 269 | t << endl; |
267 | t << "# Proxy Support\n"; | 270 | t << "# Proxy Support\n"; |
268 | 271 | ||
269 | if ( !httpProxyEnabled && httpProxy == "" ) | 272 | if ( !httpProxyEnabled && httpProxy == "" ) |
270 | t << "#option http_proxy http://proxy.tld:3128\n"; | 273 | t << "#option http_proxy http://proxy.tld:3128\n"; |
271 | else | 274 | else |
272 | { | 275 | { |
273 | if ( !httpProxyEnabled ) | 276 | if ( !httpProxyEnabled ) |
274 | t << "#"; | 277 | t << "#"; |
275 | t << "option http_proxy " << httpProxy << endl; | 278 | t << "option http_proxy " << httpProxy << endl; |
276 | } | 279 | } |
277 | 280 | ||
278 | if ( !ftpProxyEnabled && ftpProxy == "" ) | 281 | if ( !ftpProxyEnabled && ftpProxy == "" ) |
279 | t << "#option ftp_proxy http://proxy.tld:3128\n"; | 282 | t << "#option ftp_proxy http://proxy.tld:3128\n"; |
280 | else | 283 | else |
281 | { | 284 | { |
282 | if ( !ftpProxyEnabled ) | 285 | if ( !ftpProxyEnabled ) |
283 | t << "#"; | 286 | t << "#"; |
284 | t << "option ftp_proxy " << ftpProxy << endl; | 287 | t << "option ftp_proxy " << ftpProxy << endl; |
285 | } | 288 | } |
286 | if ( proxyUsername == "" || (!httpProxyEnabled && !ftpProxyEnabled) ) | 289 | if ( proxyUsername == "" || (!httpProxyEnabled && !ftpProxyEnabled) ) |
287 | t << "#option proxy_username <username>\n"; | 290 | t << "#option proxy_username <username>\n"; |
288 | else | 291 | else |
289 | t << "option proxy_username " << proxyUsername << endl; | 292 | t << "option proxy_username " << proxyUsername << endl; |
290 | if ( proxyPassword == "" || (!httpProxyEnabled && !ftpProxyEnabled) ) | 293 | if ( proxyPassword == "" || (!httpProxyEnabled && !ftpProxyEnabled) ) |
291 | t << "#option proxy_password <password>\n\n"; | 294 | t << "#option proxy_password <password>\n\n"; |
292 | else | 295 | else |
293 | t << "option proxy_password " << proxyPassword << endl<< endl; | 296 | t << "option proxy_password " << proxyPassword << endl<< endl; |
294 | 297 | ||
295 | t << "# Offline mode (for use in constructing flash images offline)\n"; | 298 | t << "# Offline mode (for use in constructing flash images offline)\n"; |
296 | t << "#option offline_root target\n"; | 299 | t << "#option offline_root target\n"; |
297 | 300 | ||
298 | f.close(); | 301 | f.close(); |
299 | } | 302 | } |
300 | 303 | ||
301 | 304 | ||
302 | void DataManager :: setAvailableCategories( QString section ) | 305 | void DataManager :: setAvailableCategories( QString section ) |
303 | { | 306 | { |
304 | QString sectstr = "#"; | 307 | QString sectstr = "#"; |
305 | sectstr.append( section.lower() ); | 308 | sectstr.append( section.lower() ); |
306 | sectstr.append( "#" ); | 309 | sectstr.append( "#" ); |
307 | if ( availableCategories.find( sectstr ) == -1 ) | 310 | if ( availableCategories.find( sectstr ) == -1 ) |
308 | { | 311 | { |
309 | availableCategories.append( section ); | 312 | availableCategories.append( section ); |
310 | availableCategories.append( "#" ); | 313 | availableCategories.append( "#" ); |
311 | } | 314 | } |
312 | } | 315 | } |
diff --git a/noncore/settings/aqpkg/datamgr.h b/noncore/settings/aqpkg/datamgr.h index 32a1e57..9f8920d 100644 --- a/noncore/settings/aqpkg/datamgr.h +++ b/noncore/settings/aqpkg/datamgr.h | |||
@@ -1,111 +1,113 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | 3 | ||
4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> | 4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> |
5 | .=l. Dan Williams <drw@handhelds.org> | 5 | .=l. Dan Williams <drw@handhelds.org> |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This file is free software; you can | 7 | _;:, .> :=|. This file is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
19 | ..}^=.= = ; Public License for more details. | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | 20 | ++= -. .` .: |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | : = ...= . :.=- You should have received a copy of the GNU |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #ifndef DATAMGR_H | 30 | #ifndef DATAMGR_H |
31 | #define DATAMGR_H | 31 | #define DATAMGR_H |
32 | 32 | ||
33 | #include <map> | 33 | #include <map> |
34 | using namespace std; | 34 | using namespace std; |
35 | 35 | ||
36 | #include <qlist.h> | 36 | #include <qlist.h> |
37 | #include <qobject.h> | 37 | #include <qobject.h> |
38 | #include <qstring.h> | 38 | #include <qstring.h> |
39 | 39 | ||
40 | #include "server.h" | 40 | #include "server.h" |
41 | #include "destination.h" | 41 | #include "destination.h" |
42 | 42 | ||
43 | #define LOCAL_SERVER "Installed Pkgs" | 43 | //#define LOCAL_SERVER "Installed Pkgs" |
44 | #define LOCAL_IPKGS "local IPKG" | 44 | //#define LOCAL_IPKGS "local IPKG" |
45 | extern QString LOCAL_SERVER; | ||
46 | extern QString LOCAL_IPKGS; | ||
45 | 47 | ||
46 | /** | 48 | /** |
47 | *@author Andy Qua | 49 | *@author Andy Qua |
48 | */ | 50 | */ |
49 | 51 | ||
50 | 52 | ||
51 | class DataManager : public QObject | 53 | class DataManager : public QObject |
52 | { | 54 | { |
53 | Q_OBJECT | 55 | Q_OBJECT |
54 | public: | 56 | public: |
55 | DataManager(); | 57 | DataManager(); |
56 | ~DataManager(); | 58 | ~DataManager(); |
57 | 59 | ||
58 | void setActiveServer( const QString &act ) { activeServer = act; } | 60 | void setActiveServer( const QString &act ) { activeServer = act; } |
59 | QString &getActiveServer( ) { return activeServer; } | 61 | QString &getActiveServer( ) { return activeServer; } |
60 | 62 | ||
61 | Server *getLocalServer() { return ( getServer( LOCAL_SERVER ) ); } | 63 | Server *getLocalServer() { return ( getServer( LOCAL_SERVER ) ); } |
62 | QList<Server> &getServerList() { return serverList; } | 64 | QList<Server> &getServerList() { return serverList; } |
63 | Server *getServer( const char *name ); | 65 | Server *getServer( const char *name ); |
64 | 66 | ||
65 | QList<Destination> &getDestinationList() { return destList; } | 67 | QList<Destination> &getDestinationList() { return destList; } |
66 | Destination *getDestination( const char *name ); | 68 | Destination *getDestination( const char *name ); |
67 | 69 | ||
68 | void loadServers(); | 70 | void loadServers(); |
69 | void reloadServerData( ); | 71 | void reloadServerData( ); |
70 | 72 | ||
71 | void writeOutIpkgConf(); | 73 | void writeOutIpkgConf(); |
72 | 74 | ||
73 | static QString getAvailableCategories() { return availableCategories; } | 75 | static QString getAvailableCategories() { return availableCategories; } |
74 | static void setAvailableCategories( QString section ); | 76 | static void setAvailableCategories( QString section ); |
75 | 77 | ||
76 | QString getHttpProxy() { return httpProxy; } | 78 | QString getHttpProxy() { return httpProxy; } |
77 | QString getFtpProxy() { return ftpProxy; } | 79 | QString getFtpProxy() { return ftpProxy; } |
78 | QString getProxyUsername() { return proxyUsername; } | 80 | QString getProxyUsername() { return proxyUsername; } |
79 | QString getProxyPassword() { return proxyPassword; } | 81 | QString getProxyPassword() { return proxyPassword; } |
80 | 82 | ||
81 | bool getHttpProxyEnabled() { return httpProxyEnabled; } | 83 | bool getHttpProxyEnabled() { return httpProxyEnabled; } |
82 | bool getFtpProxyEnabled() { return ftpProxyEnabled; } | 84 | bool getFtpProxyEnabled() { return ftpProxyEnabled; } |
83 | 85 | ||
84 | void setHttpProxy( QString proxy ) { httpProxy = proxy; } | 86 | void setHttpProxy( QString proxy ) { httpProxy = proxy; } |
85 | void setFtpProxy( QString proxy ) { ftpProxy = proxy; } | 87 | void setFtpProxy( QString proxy ) { ftpProxy = proxy; } |
86 | void setProxyUsername( QString name ) { proxyUsername = name; } | 88 | void setProxyUsername( QString name ) { proxyUsername = name; } |
87 | void setProxyPassword( QString pword ) { proxyPassword = pword; } | 89 | void setProxyPassword( QString pword ) { proxyPassword = pword; } |
88 | 90 | ||
89 | void setHttpProxyEnabled( bool val ) { httpProxyEnabled = val; } | 91 | void setHttpProxyEnabled( bool val ) { httpProxyEnabled = val; } |
90 | void setFtpProxyEnabled( bool val ) { ftpProxyEnabled = val; } | 92 | void setFtpProxyEnabled( bool val ) { ftpProxyEnabled = val; } |
91 | private: | 93 | private: |
92 | static QString availableCategories; | 94 | static QString availableCategories; |
93 | QString activeServer; | 95 | QString activeServer; |
94 | QString httpProxy; | 96 | QString httpProxy; |
95 | QString ftpProxy; | 97 | QString ftpProxy; |
96 | QString proxyUsername; | 98 | QString proxyUsername; |
97 | QString proxyPassword; | 99 | QString proxyPassword; |
98 | 100 | ||
99 | bool httpProxyEnabled; | 101 | bool httpProxyEnabled; |
100 | bool ftpProxyEnabled; | 102 | bool ftpProxyEnabled; |
101 | 103 | ||
102 | QList<Server> serverList; | 104 | QList<Server> serverList; |
103 | QList<Destination> destList; | 105 | QList<Destination> destList; |
104 | 106 | ||
105 | signals: | 107 | signals: |
106 | void progressSetSteps( int ); | 108 | void progressSetSteps( int ); |
107 | void progressSetMessage( const QString & ); | 109 | void progressSetMessage( const QString & ); |
108 | void progressUpdate( int ); | 110 | void progressUpdate( int ); |
109 | }; | 111 | }; |
110 | 112 | ||
111 | #endif | 113 | #endif |
diff --git a/noncore/settings/aqpkg/global.h b/noncore/settings/aqpkg/global.h index 4fdd51d..0325a59 100644 --- a/noncore/settings/aqpkg/global.h +++ b/noncore/settings/aqpkg/global.h | |||
@@ -1,92 +1,92 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | 3 | ||
4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> | 4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> |
5 | .=l. Dan Williams <drw@handhelds.org> | 5 | .=l. Dan Williams <drw@handhelds.org> |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This file is free software; you can | 7 | _;:, .> :=|. This file is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
19 | ..}^=.= = ; Public License for more details. | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | 20 | ++= -. .` .: |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | : = ...= . :.=- You should have received a copy of the GNU |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #ifndef __GLOBAL_H | 30 | #ifndef __GLOBAL_H |
31 | #define __GLOBAL_H | 31 | #define __GLOBAL_H |
32 | 32 | ||
33 | #define VERSION_TEXT "AQPkg Version 1.11" | 33 | //extern QString VERSION_TEXT; |
34 | 34 | ||
35 | // Uncomment the below line to run on a Linux box rather than a Zaurus | 35 | // Uncomment the below line to run on a Linux box rather than a Zaurus |
36 | // box this allows you to change where root is, and where to load config files from | 36 | // box this allows you to change where root is, and where to load config files from |
37 | // #define X86 | 37 | // #define X86 |
38 | 38 | ||
39 | // Sets up location of ipkg.conf and root directory | 39 | // Sets up location of ipkg.conf and root directory |
40 | #ifdef QWS | 40 | #ifdef QWS |
41 | 41 | ||
42 | #ifndef X86 | 42 | #ifndef X86 |
43 | 43 | ||
44 | // Running QT/Embedded on an arm processor | 44 | // Running QT/Embedded on an arm processor |
45 | #define IPKG_CONF "/etc/ipkg.conf" | 45 | #define IPKG_CONF "/etc/ipkg.conf" |
46 | #define ROOT "/" | 46 | #define ROOT "/" |
47 | #define IPKG_DIR "/usr/lib/ipkg/" | 47 | #define IPKG_DIR "/usr/lib/ipkg/" |
48 | 48 | ||
49 | #else | 49 | #else |
50 | 50 | ||
51 | // Running QT/Embedded on a X86 linux box | 51 | // Running QT/Embedded on a X86 linux box |
52 | #define IPKG_CONF "/home/andy/projects/aqpkg/data/ipkg.conf" | 52 | #define IPKG_CONF "/home/andy/projects/aqpkg/data/ipkg.conf" |
53 | #define ROOT "/home/andy/projects/aqpkg/data/root" | 53 | #define ROOT "/home/andy/projects/aqpkg/data/root" |
54 | #define IPKG_DIR "/home/andy/projects/aqpkg/data/" | 54 | #define IPKG_DIR "/home/andy/projects/aqpkg/data/" |
55 | 55 | ||
56 | #endif | 56 | #endif |
57 | 57 | ||
58 | #else | 58 | #else |
59 | 59 | ||
60 | // Running QT on a X86 linux box | 60 | // Running QT on a X86 linux box |
61 | #define IPKG_CONF "/home/andy/projects/aqpkg/data/ipkg.conf" | 61 | #define IPKG_CONF "/home/andy/projects/aqpkg/data/ipkg.conf" |
62 | #define ROOT "/home/andy/projects/aqpkg/data/root" | 62 | #define ROOT "/home/andy/projects/aqpkg/data/root" |
63 | #define IPKG_DIR "/home/andy/projects/aqpkg/data/" | 63 | #define IPKG_DIR "/home/andy/projects/aqpkg/data/" |
64 | 64 | ||
65 | #endif | 65 | #endif |
66 | 66 | ||
67 | 67 | ||
68 | // Uncomment the below line to turn on memory checking | 68 | // Uncomment the below line to turn on memory checking |
69 | //#define _DEBUG 1 | 69 | //#define _DEBUG 1 |
70 | 70 | ||
71 | #ifndef __MEMFILE_C | 71 | #ifndef __MEMFILE_C |
72 | #ifdef _DEBUG | 72 | #ifdef _DEBUG |
73 | void * operator new(unsigned int size,const char *file, int line); | 73 | void * operator new(unsigned int size,const char *file, int line); |
74 | void operator delete(void *p); | 74 | void operator delete(void *p); |
75 | #endif | 75 | #endif |
76 | 76 | ||
77 | #ifdef _DEBUG | 77 | #ifdef _DEBUG |
78 | #define DEBUG_NEW new(__FILE__, __LINE__) | 78 | #define DEBUG_NEW new(__FILE__, __LINE__) |
79 | //#define DEBUG_NEW new | 79 | //#define DEBUG_NEW new |
80 | #else | 80 | #else |
81 | #define DEBUG_NEW new | 81 | #define DEBUG_NEW new |
82 | #endif | 82 | #endif |
83 | 83 | ||
84 | #define new DEBUG_NEW | 84 | #define new DEBUG_NEW |
85 | #endif | 85 | #endif |
86 | 86 | ||
87 | 87 | ||
88 | void AddTrack(long addr, long asize, const char *fname, long lnum); | 88 | void AddTrack(long addr, long asize, const char *fname, long lnum); |
89 | void RemoveTrack(long addr); | 89 | void RemoveTrack(long addr); |
90 | void DumpUnfreed(); | 90 | void DumpUnfreed(); |
91 | 91 | ||
92 | #endif | 92 | #endif |
diff --git a/noncore/settings/aqpkg/installdlgimpl.cpp b/noncore/settings/aqpkg/installdlgimpl.cpp index 17f7b08..ea2c47f 100644 --- a/noncore/settings/aqpkg/installdlgimpl.cpp +++ b/noncore/settings/aqpkg/installdlgimpl.cpp | |||
@@ -1,478 +1,476 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | 3 | ||
4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> | 4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> |
5 | .=l. Dan Williams <drw@handhelds.org> | 5 | .=l. Dan Williams <drw@handhelds.org> |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This file is free software; you can | 7 | _;:, .> :=|. This file is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
19 | ..}^=.= = ; Public License for more details. | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | 20 | ++= -. .` .: |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | : = ...= . :.=- You should have received a copy of the GNU |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include <stdio.h> | 30 | #include <stdio.h> |
31 | 31 | ||
32 | #include <opie/ofiledialog.h> | 32 | #include <opie/ofiledialog.h> |
33 | 33 | ||
34 | #ifdef QWS | 34 | #ifdef QWS |
35 | #include <qpe/config.h> | 35 | #include <qpe/config.h> |
36 | #include <qpe/fileselector.h> | 36 | #include <qpe/fileselector.h> |
37 | #include <qpe/qpeapplication.h> | 37 | #include <qpe/qpeapplication.h> |
38 | #include <qpe/resource.h> | 38 | #include <qpe/resource.h> |
39 | #include <qpe/storage.h> | 39 | #include <qpe/storage.h> |
40 | #endif | 40 | #endif |
41 | 41 | ||
42 | #include <qcheckbox.h> | 42 | #include <qcheckbox.h> |
43 | #include <qcombobox.h> | 43 | #include <qcombobox.h> |
44 | #include <qdialog.h> | 44 | #include <qdialog.h> |
45 | #include <qfileinfo.h> | 45 | #include <qfileinfo.h> |
46 | #include <qgroupbox.h> | 46 | #include <qgroupbox.h> |
47 | #include <qmultilineedit.h> | 47 | #include <qmultilineedit.h> |
48 | #include <qlabel.h> | 48 | #include <qlabel.h> |
49 | #include <qlayout.h> | 49 | #include <qlayout.h> |
50 | #include <qpushbutton.h> | 50 | #include <qpushbutton.h> |
51 | 51 | ||
52 | #include "datamgr.h" | 52 | #include "datamgr.h" |
53 | #include "destination.h" | 53 | #include "destination.h" |
54 | #include "instoptionsimpl.h" | 54 | #include "instoptionsimpl.h" |
55 | #include "installdlgimpl.h" | 55 | #include "installdlgimpl.h" |
56 | #include "ipkg.h" | 56 | #include "ipkg.h" |
57 | #include "utils.h" | 57 | #include "utils.h" |
58 | #include "global.h" | 58 | #include "global.h" |
59 | 59 | ||
60 | enum { | 60 | enum { |
61 | MAXLINES = 100, | 61 | MAXLINES = 100, |
62 | }; | 62 | }; |
63 | 63 | ||
64 | InstallDlgImpl::InstallDlgImpl( const QList<InstallData> &packageList, DataManager *dataManager, const char *title ) | 64 | InstallDlgImpl::InstallDlgImpl( const QList<InstallData> &packageList, DataManager *dataManager, const char *title ) |
65 | : QWidget( 0, 0, 0 ) | 65 | : QWidget( 0, 0, 0 ) |
66 | { | 66 | { |
67 | setCaption( title ); | 67 | setCaption( title ); |
68 | init( TRUE ); | 68 | init( TRUE ); |
69 | 69 | ||
70 | pIpkg = 0; | 70 | pIpkg = 0; |
71 | upgradePackages = false; | 71 | upgradePackages = false; |
72 | dataMgr = dataManager; | 72 | dataMgr = dataManager; |
73 | 73 | ||
74 | QString defaultDest = "root"; | 74 | QString defaultDest = "root"; |
75 | #ifdef QWS | 75 | #ifdef QWS |
76 | Config cfg( "aqpkg" ); | 76 | Config cfg( "aqpkg" ); |
77 | cfg.setGroup( "settings" ); | 77 | cfg.setGroup( "settings" ); |
78 | defaultDest = cfg.readEntry( "dest", "root" ); | 78 | defaultDest = cfg.readEntry( "dest", "root" ); |
79 | 79 | ||
80 | // Grab flags - Turn MAKE_LINKS on by default (if no flags found) | 80 | // Grab flags - Turn MAKE_LINKS on by default (if no flags found) |
81 | flags = cfg.readNumEntry( "installFlags", 0 ); | 81 | flags = cfg.readNumEntry( "installFlags", 0 ); |
82 | infoLevel = cfg.readNumEntry( "infoLevel", 1 ); | 82 | infoLevel = cfg.readNumEntry( "infoLevel", 1 ); |
83 | #else | 83 | #else |
84 | flags = 0; | 84 | flags = 0; |
85 | #endif | 85 | #endif |
86 | 86 | ||
87 | // Output text is read only | 87 | // Output text is read only |
88 | output->setReadOnly( true ); | 88 | output->setReadOnly( true ); |
89 | //QFont f( "helvetica" ); | 89 | //QFont f( "helvetica" ); |
90 | //f.setPointSize( 10 ); | 90 | //f.setPointSize( 10 ); |
91 | //output->setFont( f ); | 91 | //output->setFont( f ); |
92 | 92 | ||
93 | 93 | ||
94 | // setup destination data | 94 | // setup destination data |
95 | int defIndex = 0; | 95 | int defIndex = 0; |
96 | int i; | 96 | int i; |
97 | QListIterator<Destination> dit( dataMgr->getDestinationList() ); | 97 | QListIterator<Destination> dit( dataMgr->getDestinationList() ); |
98 | for ( i = 0; dit.current(); ++dit, ++i ) | 98 | for ( i = 0; dit.current(); ++dit, ++i ) |
99 | { | 99 | { |
100 | destination->insertItem( dit.current()->getDestinationName() ); | 100 | destination->insertItem( dit.current()->getDestinationName() ); |
101 | if ( dit.current()->getDestinationName() == defaultDest ) | 101 | if ( dit.current()->getDestinationName() == defaultDest ) |
102 | defIndex = i; | 102 | defIndex = i; |
103 | } | 103 | } |
104 | 104 | ||
105 | destination->setCurrentItem( defIndex ); | 105 | destination->setCurrentItem( defIndex ); |
106 | 106 | ||
107 | QListIterator<InstallData> it( packageList ); | 107 | QListIterator<InstallData> it( packageList ); |
108 | // setup package data | 108 | // setup package data |
109 | QString remove = tr( "Remove\n" ); | 109 | QString remove = tr( "Remove\n" ); |
110 | QString install = tr( "Install\n" ); | 110 | QString install = tr( "Install\n" ); |
111 | QString upgrade = tr( "Upgrade\n" ); | 111 | QString upgrade = tr( "Upgrade\n" ); |
112 | for ( ; it.current(); ++it ) | 112 | for ( ; it.current(); ++it ) |
113 | { | 113 | { |
114 | InstallData *item = it.current(); | 114 | InstallData *item = it.current(); |
115 | InstallData *newitem = new InstallData(); | 115 | InstallData *newitem = new InstallData(); |
116 | 116 | ||
117 | newitem->option = item->option; | 117 | newitem->option = item->option; |
118 | newitem->packageName = item->packageName; | 118 | newitem->packageName = item->packageName; |
119 | newitem->destination = item->destination; | 119 | newitem->destination = item->destination; |
120 | newitem->recreateLinks = item->recreateLinks; | 120 | newitem->recreateLinks = item->recreateLinks; |
121 | packages.append( newitem ); | 121 | packages.append( newitem ); |
122 | 122 | ||
123 | if ( item->option == "I" ) | 123 | if ( item->option == "I" ) |
124 | { | 124 | { |
125 | install.append( QString( " %1\n" ).arg( item->packageName ) ); | 125 | install.append( QString( " %1\n" ).arg( item->packageName ) ); |
126 | } | 126 | } |
127 | else if ( item->option == "D" ) | 127 | else if ( item->option == "D" ) |
128 | { | 128 | { |
129 | remove.append( QString( " %1\n" ).arg( item->packageName ) ); | 129 | remove.append( QString( " %1\n" ).arg( item->packageName ) ); |
130 | } | 130 | } |
131 | else if ( item->option == "U" || item->option == "R" ) | 131 | else if ( item->option == "U" || item->option == "R" ) |
132 | { | 132 | { |
133 | QString type; | 133 | QString type; |
134 | if ( item->option == "R" ) | 134 | if ( item->option == "R" ) |
135 | type = tr( "(ReInstall)" ); | 135 | type = tr( "(ReInstall)" ); |
136 | else | 136 | else |
137 | type = tr( "(Upgrade)" ); | 137 | type = tr( "(Upgrade)" ); |
138 | upgrade.append( QString( " %1 %2\n" ).arg( item->packageName ).arg( type ) ); | 138 | upgrade.append( QString( " %1 %2\n" ).arg( item->packageName ).arg( type ) ); |
139 | } | 139 | } |
140 | } | 140 | } |
141 | 141 | ||
142 | output->setText( QString( "%1\n%2\n%3\n" ).arg( remove ).arg( install ).arg( upgrade ) ); | 142 | output->setText( QString( "%1\n%2\n%3\n" ).arg( remove ).arg( install ).arg( upgrade ) ); |
143 | 143 | ||
144 | displayAvailableSpace( destination->currentText() ); | 144 | displayAvailableSpace( destination->currentText() ); |
145 | } | 145 | } |
146 | 146 | ||
147 | InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title ) | 147 | InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title ) |
148 | : QWidget( 0, 0, 0 ) | 148 | : QWidget( 0, 0, 0 ) |
149 | { | 149 | { |
150 | setCaption( title ); | 150 | setCaption( title ); |
151 | init( FALSE ); | 151 | init( FALSE ); |
152 | pIpkg = ipkg; | 152 | pIpkg = ipkg; |
153 | output->setText( initialText ); | 153 | output->setText( initialText ); |
154 | } | 154 | } |
155 | 155 | ||
156 | 156 | ||
157 | InstallDlgImpl::~InstallDlgImpl() | 157 | InstallDlgImpl::~InstallDlgImpl() |
158 | { | 158 | { |
159 | if ( pIpkg ) | 159 | if ( pIpkg ) |
160 | delete pIpkg; | 160 | delete pIpkg; |
161 | } | 161 | } |
162 | 162 | ||
163 | void InstallDlgImpl :: init( bool displayextrainfo ) | 163 | void InstallDlgImpl :: init( bool displayextrainfo ) |
164 | { | 164 | { |
165 | QGridLayout *layout = new QGridLayout( this ); | 165 | QGridLayout *layout = new QGridLayout( this ); |
166 | layout->setSpacing( 4 ); | 166 | layout->setSpacing( 4 ); |
167 | layout->setMargin( 4 ); | 167 | layout->setMargin( 4 ); |
168 | 168 | ||
169 | if ( displayextrainfo ) | 169 | if ( displayextrainfo ) |
170 | { | 170 | { |
171 | QLabel *label = new QLabel( tr( "Destination" ), this ); | 171 | QLabel *label = new QLabel( tr( "Destination" ), this ); |
172 | layout->addWidget( label, 0, 0 ); | 172 | layout->addWidget( label, 0, 0 ); |
173 | destination = new QComboBox( FALSE, this ); | 173 | destination = new QComboBox( FALSE, this ); |
174 | layout->addWidget( destination, 0, 1 ); | 174 | layout->addWidget( destination, 0, 1 ); |
175 | connect( destination, SIGNAL( highlighted( const QString & ) ), | 175 | connect( destination, SIGNAL( highlighted( const QString & ) ), |
176 | this, SLOT( displayAvailableSpace( const QString & ) ) ); | 176 | this, SLOT( displayAvailableSpace( const QString & ) ) ); |
177 | 177 | ||
178 | QLabel *label2 = new QLabel( tr( "Space Avail" ), this ); | 178 | QLabel *label2 = new QLabel( tr( "Space Avail" ), this ); |
179 | layout->addWidget( label2, 1, 0 ); | 179 | layout->addWidget( label2, 1, 0 ); |
180 | txtAvailableSpace = new QLabel( "", this ); | 180 | txtAvailableSpace = new QLabel( "", this ); |
181 | layout->addWidget( txtAvailableSpace, 1, 1 ); | 181 | layout->addWidget( txtAvailableSpace, 1, 1 ); |
182 | } | 182 | } |
183 | else | 183 | else |
184 | { | 184 | { |
185 | destination = 0x0; | 185 | destination = 0x0; |
186 | txtAvailableSpace = 0x0; | 186 | txtAvailableSpace = 0x0; |
187 | } | 187 | } |
188 | 188 | ||
189 | QGroupBox *GroupBox2 = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this ); | 189 | QGroupBox *GroupBox2 = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this ); |
190 | GroupBox2->layout()->setSpacing( 0 ); | 190 | GroupBox2->layout()->setSpacing( 0 ); |
191 | GroupBox2->layout()->setMargin( 4 ); | 191 | GroupBox2->layout()->setMargin( 4 ); |
192 | 192 | ||
193 | QVBoxLayout *GroupBox2Layout = new QVBoxLayout( GroupBox2->layout() ); | 193 | QVBoxLayout *GroupBox2Layout = new QVBoxLayout( GroupBox2->layout() ); |
194 | output = new QMultiLineEdit( GroupBox2 ); | 194 | output = new QMultiLineEdit( GroupBox2 ); |
195 | GroupBox2Layout->addWidget( output ); | 195 | GroupBox2Layout->addWidget( output ); |
196 | layout->addMultiCellWidget( GroupBox2, 2, 2, 0, 1 ); | 196 | layout->addMultiCellWidget( GroupBox2, 2, 2, 0, 1 ); |
197 | 197 | ||
198 | btnInstall = new QPushButton( Resource::loadPixmap( "aqpkg/apply" ), tr( "Start" ), this ); | 198 | btnInstall = new QPushButton( Resource::loadPixmap( "aqpkg/apply" ), tr( "Start" ), this ); |
199 | layout->addWidget( btnInstall, 3, 0 ); | 199 | layout->addWidget( btnInstall, 3, 0 ); |
200 | connect( btnInstall, SIGNAL( clicked() ), this, SLOT( installSelected() ) ); | 200 | connect( btnInstall, SIGNAL( clicked() ), this, SLOT( installSelected() ) ); |
201 | 201 | ||
202 | btnOptions = new QPushButton( Resource::loadPixmap( "SettingsIcon" ), tr( "Options" ), this ); | 202 | btnOptions = new QPushButton( Resource::loadPixmap( "SettingsIcon" ), tr( "Options" ), this ); |
203 | layout->addWidget( btnOptions, 3, 1 ); | 203 | layout->addWidget( btnOptions, 3, 1 ); |
204 | connect( btnOptions, SIGNAL( clicked() ), this, SLOT( optionsSelected() ) ); | 204 | connect( btnOptions, SIGNAL( clicked() ), this, SLOT( optionsSelected() ) ); |
205 | } | 205 | } |
206 | 206 | ||
207 | void InstallDlgImpl :: optionsSelected() | 207 | void InstallDlgImpl :: optionsSelected() |
208 | { | 208 | { |
209 | if ( btnOptions->text() == tr( "Options" ) ) | 209 | if ( btnOptions->text() == tr( "Options" ) ) |
210 | { | 210 | { |
211 | InstallOptionsDlgImpl opt( flags, infoLevel, this, "Option", true ); | 211 | InstallOptionsDlgImpl opt( flags, infoLevel, this, "Option", true ); |
212 | if ( opt.exec() == QDialog::Accepted ) | 212 | if ( opt.exec() == QDialog::Accepted ) |
213 | { | 213 | { |
214 | // set options selected from dialog | 214 | // set options selected from dialog |
215 | flags = opt.getFlags(); | 215 | flags = opt.getFlags(); |
216 | infoLevel = opt.getInfoLevel(); | 216 | infoLevel = opt.getInfoLevel(); |
217 | 217 | ||
218 | #ifdef QWS | 218 | #ifdef QWS |
219 | Config cfg( "aqpkg" ); | 219 | Config cfg( "aqpkg" ); |
220 | cfg.setGroup( "settings" ); | 220 | cfg.setGroup( "settings" ); |
221 | cfg.writeEntry( "installFlags", flags ); | 221 | cfg.writeEntry( "installFlags", flags ); |
222 | cfg.writeEntry( "infoLevel", infoLevel ); | 222 | cfg.writeEntry( "infoLevel", infoLevel ); |
223 | #endif | 223 | #endif |
224 | } | 224 | } |
225 | } | 225 | } |
226 | else // Save output | 226 | else // Save output |
227 | { | 227 | { |
228 | QMap<QString, QStringList> map; | 228 | QMap<QString, QStringList> map; |
229 | map.insert( tr( "All" ), QStringList() ); | 229 | map.insert( tr( "All" ), QStringList() ); |
230 | QStringList text; | 230 | QStringList text; |
231 | text << "text/*"; | 231 | text << "text/*"; |
232 | map.insert(tr( "Text" ), text ); | 232 | map.insert(tr( "Text" ), text ); |
233 | text << "*"; | 233 | text << "*"; |
234 | map.insert( tr( "All" ), text ); | 234 | map.insert( tr( "All" ), text ); |
235 | 235 | ||
236 | QString filename = OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map ); | 236 | QString filename = OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map ); |
237 | if( !filename.isEmpty() ) | 237 | if( !filename.isEmpty() ) |
238 | { | 238 | { |
239 | QString currentFileName = QFileInfo( filename ).fileName(); | 239 | QString currentFileName = QFileInfo( filename ).fileName(); |
240 | DocLnk doc; | 240 | DocLnk doc; |
241 | doc.setType( "text/plain" ); | 241 | doc.setType( "text/plain" ); |
242 | doc.setFile( filename ); | 242 | doc.setFile( filename ); |
243 | doc.setName( currentFileName ); | 243 | doc.setName( currentFileName ); |
244 | FileManager fm; | 244 | FileManager fm; |
245 | fm.saveFile( doc, output->text() ); | 245 | fm.saveFile( doc, output->text() ); |
246 | } | 246 | } |
247 | } | 247 | } |
248 | } | 248 | } |
249 | 249 | ||
250 | void InstallDlgImpl :: installSelected() | 250 | void InstallDlgImpl :: installSelected() |
251 | { | 251 | { |
252 | if ( btnInstall->text() == tr( "Abort" ) ) | 252 | if ( btnInstall->text() == tr( "Abort" ) ) |
253 | { | 253 | { |
254 | if ( pIpkg ) | 254 | if ( pIpkg ) |
255 | { | 255 | { |
256 | displayText( tr( "\n**** User Clicked ABORT ***" ) ); | 256 | displayText( tr( "\n**** User Clicked ABORT ***" ) ); |
257 | pIpkg->abort(); | 257 | pIpkg->abort(); |
258 | displayText( tr( "**** Process Aborted ****" ) ); | 258 | displayText( tr( "**** Process Aborted ****" ) ); |
259 | } | 259 | } |
260 | 260 | ||
261 | btnInstall->setText( tr( "Close" ) ); | 261 | btnInstall->setText( tr( "Close" ) ); |
262 | btnInstall->setIconSet( Resource::loadPixmap( "enter" ) ); | 262 | btnInstall->setIconSet( Resource::loadPixmap( "enter" ) ); |
263 | return; | 263 | return; |
264 | } | 264 | } |
265 | else if ( btnInstall->text() == tr( "Close" ) ) | 265 | else if ( btnInstall->text() == tr( "Close" ) ) |
266 | { | 266 | { |
267 | emit reloadData( this ); | 267 | emit reloadData( this ); |
268 | return; | 268 | return; |
269 | } | 269 | } |
270 | 270 | ||
271 | // Disable buttons | 271 | // Disable buttons |
272 | btnOptions->setEnabled( false ); | 272 | btnOptions->setEnabled( false ); |
273 | // btnInstall->setEnabled( false ); | 273 | // btnInstall->setEnabled( false ); |
274 | 274 | ||
275 | btnInstall->setText( tr( "Abort" ) ); | 275 | btnInstall->setText( tr( "Abort" ) ); |
276 | btnInstall->setIconSet( Resource::loadPixmap( "close" ) ); | 276 | btnInstall->setIconSet( Resource::loadPixmap( "close" ) ); |
277 | 277 | ||
278 | if ( pIpkg ) | 278 | if ( pIpkg ) |
279 | { | 279 | { |
280 | output->setText( "" ); | 280 | output->setText( "" ); |
281 | connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); | 281 | connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); |
282 | connect( pIpkg, SIGNAL(ipkgFinished()), this, SLOT(ipkgFinished())); | 282 | connect( pIpkg, SIGNAL(ipkgFinished()), this, SLOT(ipkgFinished())); |
283 | pIpkg->runIpkg(); | 283 | pIpkg->runIpkg(); |
284 | } | 284 | } |
285 | else | 285 | else |
286 | { | 286 | { |
287 | output->setText( "" ); | 287 | output->setText( "" ); |
288 | Destination *d = dataMgr->getDestination( destination->currentText() ); | 288 | Destination *d = dataMgr->getDestination( destination->currentText() ); |
289 | QString dest = d->getDestinationName(); | 289 | QString dest = d->getDestinationName(); |
290 | QString destDir = d->getDestinationPath(); | 290 | QString destDir = d->getDestinationPath(); |
291 | int instFlags = flags; | 291 | int instFlags = flags; |
292 | if ( d->linkToRoot() ) | 292 | if ( d->linkToRoot() ) |
293 | instFlags |= MAKE_LINKS; | 293 | instFlags |= MAKE_LINKS; |
294 | 294 | ||
295 | #ifdef QWS | 295 | #ifdef QWS |
296 | // Save settings | 296 | // Save settings |
297 | Config cfg( "aqpkg" ); | 297 | Config cfg( "aqpkg" ); |
298 | cfg.setGroup( "settings" ); | 298 | cfg.setGroup( "settings" ); |
299 | cfg.writeEntry( "dest", dest ); | 299 | cfg.writeEntry( "dest", dest ); |
300 | #endif | 300 | #endif |
301 | 301 | ||
302 | pIpkg = new Ipkg; | 302 | pIpkg = new Ipkg; |
303 | connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); | 303 | connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); |
304 | connect( pIpkg, SIGNAL(ipkgFinished()), this, SLOT(ipkgFinished())); | 304 | connect( pIpkg, SIGNAL(ipkgFinished()), this, SLOT(ipkgFinished())); |
305 | 305 | ||
306 | firstPackage = TRUE; | 306 | firstPackage = TRUE; |
307 | ipkgFinished(); | 307 | ipkgFinished(); |
308 | 308 | ||
309 | // First run through the remove list, then the install list then the upgrade list | 309 | // First run through the remove list, then the install list then the upgrade list |
310 | /* | 310 | /* |
311 | pIpkg->setOption( "remove" ); | 311 | pIpkg->setOption( "remove" ); |
312 | QListIterator<InstallData> it( removeList ); | 312 | QListIterator<InstallData> it( removeList ); |
313 | InstallData *idata; | 313 | InstallData *idata; |
314 | for ( ; it.current(); ++it ) | 314 | for ( ; it.current(); ++it ) |
315 | { | 315 | { |
316 | idata = it.current(); | 316 | idata = it.current(); |
317 | pIpkg->setDestination( idata->destination->getDestinationName() ); | 317 | pIpkg->setDestination( idata->destination->getDestinationName() ); |
318 | pIpkg->setDestinationDir( idata->destination->getDestinationPath() ); | 318 | pIpkg->setDestinationDir( idata->destination->getDestinationPath() ); |
319 | pIpkg->setPackage( idata->packageName ); | 319 | pIpkg->setPackage( idata->packageName ); |
320 | 320 | ||
321 | int tmpFlags = flags; | 321 | int tmpFlags = flags; |
322 | if ( idata->destination->linkToRoot() ) | 322 | if ( idata->destination->linkToRoot() ) |
323 | tmpFlags |= MAKE_LINKS; | 323 | tmpFlags |= MAKE_LINKS; |
324 | 324 | ||
325 | pIpkg->setFlags( tmpFlags, infoLevel ); | 325 | pIpkg->setFlags( tmpFlags, infoLevel ); |
326 | pIpkg->runIpkg(); | 326 | pIpkg->runIpkg(); |
327 | } | 327 | } |
328 | 328 | ||
329 | pIpkg->setOption( "install" ); | 329 | pIpkg->setOption( "install" ); |
330 | pIpkg->setDestination( dest ); | 330 | pIpkg->setDestination( dest ); |
331 | pIpkg->setDestinationDir( destDir ); | 331 | pIpkg->setDestinationDir( destDir ); |
332 | pIpkg->setFlags( instFlags, infoLevel ); | 332 | pIpkg->setFlags( instFlags, infoLevel ); |
333 | QListIterator<InstallData> it2( installList ); | 333 | QListIterator<InstallData> it2( installList ); |
334 | for ( ; it2.current(); ++it2 ) | 334 | for ( ; it2.current(); ++it2 ) |
335 | { | 335 | { |
336 | pIpkg->setPackage( it2.current()->packageName ); | 336 | pIpkg->setPackage( it2.current()->packageName ); |
337 | pIpkg->runIpkg(); | 337 | pIpkg->runIpkg(); |
338 | } | 338 | } |
339 | 339 | ||
340 | flags |= FORCE_REINSTALL; | 340 | flags |= FORCE_REINSTALL; |
341 | QListIterator<InstallData> it3( updateList ); | 341 | QListIterator<InstallData> it3( updateList ); |
342 | for ( ; it3.current() ; ++it3 ) | 342 | for ( ; it3.current() ; ++it3 ) |
343 | { | 343 | { |
344 | idata = it3.current(); | 344 | idata = it3.current(); |
345 | if ( idata->option == "R" ) | 345 | if ( idata->option == "R" ) |
346 | pIpkg->setOption( "reinstall" ); | 346 | pIpkg->setOption( "reinstall" ); |
347 | else | 347 | else |
348 | pIpkg->setOption( "upgrade" ); | 348 | pIpkg->setOption( "upgrade" ); |
349 | pIpkg->setDestination( idata->destination->getDestinationName() ); | 349 | pIpkg->setDestination( idata->destination->getDestinationName() ); |
350 | pIpkg->setDestinationDir( idata->destination->getDestinationPath() ); | 350 | pIpkg->setDestinationDir( idata->destination->getDestinationPath() ); |
351 | pIpkg->setPackage( idata->packageName ); | 351 | pIpkg->setPackage( idata->packageName ); |
352 | 352 | ||
353 | int tmpFlags = flags; | 353 | int tmpFlags = flags; |
354 | if ( idata->destination->linkToRoot() && idata->recreateLinks ) | 354 | if ( idata->destination->linkToRoot() && idata->recreateLinks ) |
355 | tmpFlags |= MAKE_LINKS; | 355 | tmpFlags |= MAKE_LINKS; |
356 | pIpkg->setFlags( tmpFlags, infoLevel ); | 356 | pIpkg->setFlags( tmpFlags, infoLevel ); |
357 | pIpkg->runIpkg(); | 357 | pIpkg->runIpkg(); |
358 | } | 358 | } |
359 | 359 | ||
360 | delete pIpkg; | 360 | delete pIpkg; |
361 | pIpkg = 0; | 361 | pIpkg = 0; |
362 | */ | 362 | */ |
363 | } | 363 | } |
364 | } | 364 | } |
365 | 365 | ||
366 | 366 | ||
367 | void InstallDlgImpl :: displayText(const QString &text ) | 367 | void InstallDlgImpl :: displayText(const QString &text ) |
368 | { | 368 | { |
369 | QString newtext = QString( "%1\n%2" ).arg( output->text() ).arg( text ); | 369 | QString newtext = QString( "%1\n%2" ).arg( output->text() ).arg( text ); |
370 | 370 | ||
371 | /* Set a max line count for the QMultiLineEdit, as users have reported | 371 | /* Set a max line count for the QMultiLineEdit, as users have reported |
372 | * performance issues when line count gets extreme. | 372 | * performance issues when line count gets extreme. |
373 | */ | 373 | */ |
374 | if(output->numLines() >= MAXLINES) | 374 | if(output->numLines() >= MAXLINES) |
375 | output->removeLine(0); | 375 | output->removeLine(0); |
376 | output->setText( newtext ); | 376 | output->setText( newtext ); |
377 | output->setCursorPosition( output->numLines(), 0 ); | 377 | output->setCursorPosition( output->numLines(), 0 ); |
378 | } | 378 | } |
379 | 379 | ||
380 | 380 | ||
381 | void InstallDlgImpl :: displayAvailableSpace( const QString &text ) | 381 | void InstallDlgImpl :: displayAvailableSpace( const QString &text ) |
382 | { | 382 | { |
383 | Destination *d = dataMgr->getDestination( text ); | 383 | Destination *d = dataMgr->getDestination( text ); |
384 | QString destDir = d->getDestinationPath(); | 384 | QString destDir = d->getDestinationPath(); |
385 | 385 | ||
386 | long blockSize = 0; | 386 | long blockSize = 0; |
387 | long totalBlocks = 0; | 387 | long totalBlocks = 0; |
388 | long availBlocks = 0; | 388 | long availBlocks = 0; |
389 | QString space; | 389 | QString space; |
390 | if ( Utils::getStorageSpace( (const char *)destDir, &blockSize, &totalBlocks, &availBlocks ) ) | 390 | if ( Utils::getStorageSpace( (const char *)destDir, &blockSize, &totalBlocks, &availBlocks ) ) |
391 | { | 391 | { |
392 | long mult = blockSize / 1024; | 392 | long mult = blockSize / 1024; |
393 | long div = 1024 / blockSize; | 393 | long div = 1024 / blockSize; |
394 | 394 | ||
395 | if ( !mult ) mult = 1; | 395 | if ( !mult ) mult = 1; |
396 | if ( !div ) div = 1; | 396 | if ( !div ) div = 1; |
397 | // long total = totalBlocks * mult / div; | ||
398 | long avail = availBlocks * mult / div; | 397 | long avail = availBlocks * mult / div; |
399 | // long used = total - avail; | ||
400 | 398 | ||
401 | space.sprintf( "%ld Kb", avail ); | 399 | space = tr( "%1 Kb" ).arg( avail ); |
402 | } | 400 | } |
403 | else | 401 | else |
404 | space = tr( "Unknown" ); | 402 | space = tr( "Unknown" ); |
405 | 403 | ||
406 | if ( txtAvailableSpace ) | 404 | if ( txtAvailableSpace ) |
407 | txtAvailableSpace->setText( space ); | 405 | txtAvailableSpace->setText( space ); |
408 | } | 406 | } |
409 | 407 | ||
410 | void InstallDlgImpl :: ipkgFinished() | 408 | void InstallDlgImpl :: ipkgFinished() |
411 | { | 409 | { |
412 | InstallData *item; | 410 | InstallData *item; |
413 | if ( firstPackage ) | 411 | if ( firstPackage ) |
414 | item = packages.first(); | 412 | item = packages.first(); |
415 | else | 413 | else |
416 | { | 414 | { |
417 | // Create symlinks if necessary before moving on to next package | 415 | // Create symlinks if necessary before moving on to next package |
418 | pIpkg->createSymLinks(); | 416 | pIpkg->createSymLinks(); |
419 | 417 | ||
420 | item = packages.next(); | 418 | item = packages.next(); |
421 | } | 419 | } |
422 | 420 | ||
423 | firstPackage = FALSE; | 421 | firstPackage = FALSE; |
424 | if ( item ) | 422 | if ( item ) |
425 | { | 423 | { |
426 | pIpkg->setPackage( item->packageName ); | 424 | pIpkg->setPackage( item->packageName ); |
427 | int tmpFlags = flags; | 425 | int tmpFlags = flags; |
428 | 426 | ||
429 | if ( item->option == "I" ) | 427 | if ( item->option == "I" ) |
430 | { | 428 | { |
431 | pIpkg->setOption( "install" ); | 429 | pIpkg->setOption( "install" ); |
432 | Destination *d = dataMgr->getDestination( destination->currentText() ); | 430 | Destination *d = dataMgr->getDestination( destination->currentText() ); |
433 | pIpkg->setDestination( d->getDestinationName() ); | 431 | pIpkg->setDestination( d->getDestinationName() ); |
434 | pIpkg->setDestinationDir( d->getDestinationPath() ); | 432 | pIpkg->setDestinationDir( d->getDestinationPath() ); |
435 | 433 | ||
436 | if ( d->linkToRoot() ) | 434 | if ( d->linkToRoot() ) |
437 | tmpFlags |= MAKE_LINKS; | 435 | tmpFlags |= MAKE_LINKS; |
438 | } | 436 | } |
439 | else if ( item->option == "D" ) | 437 | else if ( item->option == "D" ) |
440 | { | 438 | { |
441 | pIpkg->setOption( "remove" ); | 439 | pIpkg->setOption( "remove" ); |
442 | pIpkg->setDestination( item->destination->getDestinationName() ); | 440 | pIpkg->setDestination( item->destination->getDestinationName() ); |
443 | pIpkg->setDestinationDir( item->destination->getDestinationPath() ); | 441 | pIpkg->setDestinationDir( item->destination->getDestinationPath() ); |
444 | 442 | ||
445 | if ( item->destination->linkToRoot() ) | 443 | if ( item->destination->linkToRoot() ) |
446 | tmpFlags |= MAKE_LINKS; | 444 | tmpFlags |= MAKE_LINKS; |
447 | } | 445 | } |
448 | else | 446 | else |
449 | { | 447 | { |
450 | if ( item->option == "R" ) | 448 | if ( item->option == "R" ) |
451 | pIpkg->setOption( "reinstall" ); | 449 | pIpkg->setOption( "reinstall" ); |
452 | else | 450 | else |
453 | pIpkg->setOption( "upgrade" ); | 451 | pIpkg->setOption( "upgrade" ); |
454 | 452 | ||
455 | pIpkg->setDestination( item->destination->getDestinationName() ); | 453 | pIpkg->setDestination( item->destination->getDestinationName() ); |
456 | pIpkg->setDestinationDir( item->destination->getDestinationPath() ); | 454 | pIpkg->setDestinationDir( item->destination->getDestinationPath() ); |
457 | pIpkg->setPackage( item->packageName ); | 455 | pIpkg->setPackage( item->packageName ); |
458 | 456 | ||
459 | tmpFlags |= FORCE_REINSTALL; | 457 | tmpFlags |= FORCE_REINSTALL; |
460 | if ( item->destination->linkToRoot() && item->recreateLinks ) | 458 | if ( item->destination->linkToRoot() && item->recreateLinks ) |
461 | tmpFlags |= MAKE_LINKS; | 459 | tmpFlags |= MAKE_LINKS; |
462 | } | 460 | } |
463 | pIpkg->setFlags( tmpFlags, infoLevel ); | 461 | pIpkg->setFlags( tmpFlags, infoLevel ); |
464 | pIpkg->runIpkg(); | 462 | pIpkg->runIpkg(); |
465 | } | 463 | } |
466 | else | 464 | else |
467 | { | 465 | { |
468 | btnOptions->setEnabled( true ); | 466 | btnOptions->setEnabled( true ); |
469 | btnInstall->setText( tr( "Close" ) ); | 467 | btnInstall->setText( tr( "Close" ) ); |
470 | btnInstall->setIconSet( Resource::loadPixmap( "enter" ) ); | 468 | btnInstall->setIconSet( Resource::loadPixmap( "enter" ) ); |
471 | 469 | ||
472 | btnOptions->setText( tr( "Save output" ) ); | 470 | btnOptions->setText( tr( "Save output" ) ); |
473 | btnOptions->setIconSet( Resource::loadPixmap( "save" ) ); | 471 | btnOptions->setIconSet( Resource::loadPixmap( "save" ) ); |
474 | 472 | ||
475 | if ( destination && destination->currentText() != 0 && destination->currentText() != "" ) | 473 | if ( destination && destination->currentText() != 0 && destination->currentText() != "" ) |
476 | displayAvailableSpace( destination->currentText() ); | 474 | displayAvailableSpace( destination->currentText() ); |
477 | } | 475 | } |
478 | } | 476 | } |
diff --git a/noncore/settings/aqpkg/ipkg.cpp b/noncore/settings/aqpkg/ipkg.cpp index 3df569b..43eaaae 100644 --- a/noncore/settings/aqpkg/ipkg.cpp +++ b/noncore/settings/aqpkg/ipkg.cpp | |||
@@ -1,598 +1,529 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | 3 | ||
4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> | 4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> |
5 | .=l. Dan Williams <drw@handhelds.org> | 5 | .=l. Dan Williams <drw@handhelds.org> |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This file is free software; you can | 7 | _;:, .> :=|. This file is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
19 | ..}^=.= = ; Public License for more details. | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | 20 | ++= -. .` .: |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | : = ...= . :.=- You should have received a copy of the GNU |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include <fstream> | 30 | #include <fstream> |
31 | #include <iostream> | 31 | #include <iostream> |
32 | #include <vector> | 32 | #include <vector> |
33 | using namespace std; | 33 | using namespace std; |
34 | 34 | ||
35 | #include <stdio.h> | 35 | #include <stdio.h> |
36 | #include <unistd.h> | 36 | #include <unistd.h> |
37 | 37 | ||
38 | #ifdef QWS | 38 | #ifdef QWS |
39 | #include <qpe/qpeapplication.h> | 39 | #include <qpe/qpeapplication.h> |
40 | #else | 40 | #else |
41 | #include <qapplication.h> | 41 | #include <qapplication.h> |
42 | #endif | 42 | #endif |
43 | #include <qdir.h> | 43 | #include <qdir.h> |
44 | #include <qtextstream.h> | 44 | #include <qtextstream.h> |
45 | 45 | ||
46 | #include <opie/oprocess.h> | 46 | #include <opie/oprocess.h> |
47 | 47 | ||
48 | #include "utils.h" | 48 | #include "utils.h" |
49 | #include "ipkg.h" | 49 | #include "ipkg.h" |
50 | #include "global.h" | 50 | #include "global.h" |
51 | 51 | ||
52 | Ipkg :: Ipkg() | 52 | Ipkg :: Ipkg() |
53 | { | 53 | { |
54 | proc = 0; | 54 | proc = 0; |
55 | } | 55 | } |
56 | 56 | ||
57 | Ipkg :: ~Ipkg() | 57 | Ipkg :: ~Ipkg() |
58 | { | 58 | { |
59 | } | 59 | } |
60 | 60 | ||
61 | // Option is what we are going to do - install, upgrade, download, reinstall | 61 | // Option is what we are going to do - install, upgrade, download, reinstall |
62 | // package is the package name to install - either a fully qualified path and ipk | 62 | // package is the package name to install - either a fully qualified path and ipk |
63 | // file (if stored locally) or just the name of the package (for a network package) | 63 | // file (if stored locally) or just the name of the package (for a network package) |
64 | // packageName is the package name - (for a network package this will be the same as | 64 | // packageName is the package name - (for a network package this will be the same as |
65 | // package parameter) | 65 | // package parameter) |
66 | // dest is the destination alias (from ipk.conf) | 66 | // dest is the destination alias (from ipk.conf) |
67 | // destDir is the dir that the destination alias points to (used to link to root) | 67 | // destDir is the dir that the destination alias points to (used to link to root) |
68 | // flags is the ipkg options flags | 68 | // flags is the ipkg options flags |
69 | // dir is the directory to run ipkg in (defaults to "") | 69 | // dir is the directory to run ipkg in (defaults to "") |
70 | void Ipkg :: runIpkg() | 70 | void Ipkg :: runIpkg() |
71 | { | 71 | { |
72 | error = false; | 72 | error = false; |
73 | QStringList commands; | 73 | QStringList commands; |
74 | 74 | ||
75 | QDir::setCurrent( "/tmp" ); | 75 | QDir::setCurrent( "/tmp" ); |
76 | 76 | ||
77 | if ( runtimeDir != "" ) | 77 | if ( runtimeDir != "" ) |
78 | { | 78 | { |
79 | commands << "cd "; | 79 | commands << "cd "; |
80 | commands << runtimeDir; | 80 | commands << runtimeDir; |
81 | commands << ";"; | 81 | commands << ";"; |
82 | } | 82 | } |
83 | commands << "ipkg" << "-V" << QString::number( infoLevel ) << "-force-defaults"; | 83 | commands << "ipkg" << "-V" << QString::number( infoLevel ) << "-force-defaults"; |
84 | 84 | ||
85 | // only set the destination for an install operation | 85 | // only set the destination for an install operation |
86 | if ( option == "install" ) | 86 | if ( option == "install" ) |
87 | commands << "-dest" << destination; | 87 | commands << "-dest" << destination; |
88 | 88 | ||
89 | 89 | ||
90 | if ( option != "update" && option != "download" ) | 90 | if ( option != "update" && option != "download" ) |
91 | { | 91 | { |
92 | if ( flags & FORCE_DEPENDS ) | 92 | if ( flags & FORCE_DEPENDS ) |
93 | commands << "-force-depends"; | 93 | commands << "-force-depends"; |
94 | if ( flags & FORCE_REINSTALL ) | 94 | if ( flags & FORCE_REINSTALL ) |
95 | commands << "-force-reinstall"; | 95 | commands << "-force-reinstall"; |
96 | if ( flags & FORCE_REMOVE ) | 96 | if ( flags & FORCE_REMOVE ) |
97 | commands << "-force-removal-of-essential-packages"; | 97 | commands << "-force-removal-of-essential-packages"; |
98 | if ( flags & FORCE_OVERWRITE ) | 98 | if ( flags & FORCE_OVERWRITE ) |
99 | commands << "-force-overwrite"; | 99 | commands << "-force-overwrite"; |
100 | if ( infoLevel == 3 ) | 100 | if ( infoLevel == 3 ) |
101 | commands << "-verbose_wget"; | 101 | commands << "-verbose_wget"; |
102 | 102 | ||
103 | // Handle make links | 103 | // Handle make links |
104 | // Rules - If make links is switched on, create links to root | 104 | // Rules - If make links is switched on, create links to root |
105 | // if destDir is NOT / | 105 | // if destDir is NOT / |
106 | if ( flags & MAKE_LINKS ) | 106 | if ( flags & MAKE_LINKS ) |
107 | { | 107 | { |
108 | // If destDir == / turn off make links as package is being insalled | 108 | // If destDir == / turn off make links as package is being insalled |
109 | // to root already. | 109 | // to root already. |
110 | if ( destDir == "/" ) | 110 | if ( destDir == "/" ) |
111 | flags ^= MAKE_LINKS; | 111 | flags ^= MAKE_LINKS; |
112 | } | 112 | } |
113 | } | 113 | } |
114 | 114 | ||
115 | #ifdef X86 | 115 | #ifdef X86 |
116 | commands << "-f"; | 116 | commands << "-f"; |
117 | commands << IPKG_CONF; | 117 | commands << IPKG_CONF; |
118 | #endif | 118 | #endif |
119 | 119 | ||
120 | 120 | ||
121 | if ( option == "reinstall" ) | 121 | if ( option == "reinstall" ) |
122 | commands << "install"; | 122 | commands << "install"; |
123 | else | 123 | else |
124 | commands << option; | 124 | commands << option; |
125 | if ( package != "" ) | 125 | if ( package != "" ) |
126 | commands << package; | 126 | commands << package; |
127 | 127 | ||
128 | 128 | ||
129 | if ( package != "" ) | 129 | if ( package != "" ) |
130 | emit outputText( QString( "Dealing with package " ) + package ); | 130 | emit outputText( tr( "Dealing with package %1" ).arg( package) ); |
131 | 131 | ||
132 | qApp->processEvents(); | 132 | qApp->processEvents(); |
133 | 133 | ||
134 | // If we are removing, reinstalling or upgrading packages and make links option is selected | 134 | // If we are removing, reinstalling or upgrading packages and make links option is selected |
135 | // create the links | 135 | // create the links |
136 | if ( option == "remove" || option == "reinstall" || option == "upgrade" ) | 136 | if ( option == "remove" || option == "reinstall" || option == "upgrade" ) |
137 | { | 137 | { |
138 | createLinks = false; | 138 | createLinks = false; |
139 | if ( flags & MAKE_LINKS ) | 139 | if ( flags & MAKE_LINKS ) |
140 | { | 140 | { |
141 | emit outputText( QString( "Removing symbolic links...\n" ) ); | 141 | emit outputText( tr( "Removing symbolic links...\n" ) ); |
142 | linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir ); | 142 | linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir ); |
143 | emit outputText( QString( " " ) ); | 143 | emit outputText( QString( " " ) ); |
144 | } | 144 | } |
145 | } | 145 | } |
146 | 146 | ||
147 | // Execute command | 147 | // Execute command |
148 | dependantPackages = new QList<QString>; | 148 | dependantPackages = new QList<QString>; |
149 | dependantPackages->setAutoDelete( true ); | 149 | dependantPackages->setAutoDelete( true ); |
150 | 150 | ||
151 | executeIpkgCommand( commands, option ); | 151 | executeIpkgCommand( commands, option ); |
152 | 152 | ||
153 | } | 153 | } |
154 | 154 | ||
155 | void Ipkg :: createSymLinks() | 155 | void Ipkg :: createSymLinks() |
156 | { | 156 | { |
157 | if ( option == "install" || option == "reinstall" || option == "upgrade" ) | 157 | if ( option == "install" || option == "reinstall" || option == "upgrade" ) |
158 | { | 158 | { |
159 | // If we are not removing packages and make links option is selected | 159 | // If we are not removing packages and make links option is selected |
160 | // create the links | 160 | // create the links |
161 | createLinks = true; | 161 | createLinks = true; |
162 | if ( flags & MAKE_LINKS ) | 162 | if ( flags & MAKE_LINKS ) |
163 | { | 163 | { |
164 | emit outputText( " " ); | 164 | emit outputText( " " ); |
165 | emit outputText( QString( "Creating symbolic links for " )+ package ); | 165 | emit outputText( tr( "Creating symbolic links for %1." ).arg( package) ); |
166 | 166 | ||
167 | linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir ); | 167 | linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir ); |
168 | 168 | ||
169 | // link dependant packages that were installed with this release | 169 | // link dependant packages that were installed with this release |
170 | QString *pkg; | 170 | QString *pkg; |
171 | for ( pkg = dependantPackages->first(); pkg != 0; pkg = dependantPackages->next() ) | 171 | for ( pkg = dependantPackages->first(); pkg != 0; pkg = dependantPackages->next() ) |
172 | { | 172 | { |
173 | if ( *pkg == package ) | 173 | if ( *pkg == package ) |
174 | continue; | 174 | continue; |
175 | emit outputText( " " ); | 175 | emit outputText( " " ); |
176 | emit outputText( QString( "Creating symbolic links for " )+ (*pkg) ); | 176 | emit outputText( tr( "Creating symbolic links for %1" ).arg( *pkg ) ); |
177 | linkPackage( Utils::getPackageNameFromIpkFilename( *pkg ), destination, destDir ); | 177 | linkPackage( Utils::getPackageNameFromIpkFilename( *pkg ), destination, destDir ); |
178 | } | 178 | } |
179 | } | 179 | } |
180 | } | 180 | } |
181 | 181 | ||
182 | delete dependantPackages; | 182 | delete dependantPackages; |
183 | 183 | ||
184 | emit outputText( "Finished" ); | 184 | emit outputText( tr("Finished") ); |
185 | emit outputText( "" ); | 185 | emit outputText( "" ); |
186 | } | 186 | } |
187 | 187 | ||
188 | void Ipkg :: removeStatusEntry() | 188 | void Ipkg :: removeStatusEntry() |
189 | { | 189 | { |
190 | QString statusFile = destDir; | 190 | QString statusFile = destDir; |
191 | if ( statusFile.right( 1 ) != "/" ) | 191 | if ( statusFile.right( 1 ) != "/" ) |
192 | statusFile.append( "/" ); | 192 | statusFile.append( "/" ); |
193 | statusFile.append( "usr/lib/ipkg/status" ); | 193 | statusFile.append( "usr/lib/ipkg/status" ); |
194 | QString outStatusFile = statusFile; | 194 | QString outStatusFile = statusFile; |
195 | outStatusFile.append( ".tmp" ); | 195 | outStatusFile.append( ".tmp" ); |
196 | 196 | ||
197 | emit outputText( "" ); | 197 | emit outputText( "" ); |
198 | emit outputText( "Removing status entry..." ); | 198 | emit outputText( tr("Removing status entry...") ); |
199 | QString tempstr = "status file - "; | 199 | QString tempstr = tr("status file - "); |
200 | tempstr.append( statusFile ); | 200 | tempstr.append( statusFile ); |
201 | emit outputText( tempstr ); | 201 | emit outputText( tempstr ); |
202 | tempstr = "package - "; | 202 | tempstr = tr("package - "); |
203 | tempstr.append( package ); | 203 | tempstr.append( package ); |
204 | emit outputText( tempstr ); | 204 | emit outputText( tempstr ); |
205 | 205 | ||
206 | ifstream in( statusFile ); | 206 | ifstream in( statusFile ); |
207 | ofstream out( outStatusFile ); | 207 | ofstream out( outStatusFile ); |
208 | if ( !in.is_open() ) | 208 | if ( !in.is_open() ) |
209 | { | 209 | { |
210 | tempstr = "Couldn't open status file - "; | 210 | tempstr = tr("Couldn't open status file - "); |
211 | tempstr.append( statusFile ); | 211 | tempstr.append( statusFile ); |
212 | emit outputText( tempstr ); | 212 | emit outputText( tempstr ); |
213 | return; | 213 | return; |
214 | } | 214 | } |
215 | 215 | ||
216 | if ( !out.is_open() ) | 216 | if ( !out.is_open() ) |
217 | { | 217 | { |
218 | tempstr = "Couldn't create tempory status file - "; | 218 | tempstr = tr("Couldn't create tempory status file - "); |
219 | tempstr.append( outStatusFile ); | 219 | tempstr.append( outStatusFile ); |
220 | emit outputText( tempstr ); | 220 | emit outputText( tempstr ); |
221 | return; | 221 | return; |
222 | } | 222 | } |
223 | 223 | ||
224 | char line[1001]; | 224 | char line[1001]; |
225 | char k[21]; | 225 | char k[21]; |
226 | char v[1001]; | 226 | char v[1001]; |
227 | QString key; | 227 | QString key; |
228 | QString value; | 228 | QString value; |
229 | vector<QString> lines; | 229 | vector<QString> lines; |
230 | int i = 0; | 230 | int i = 0; |
231 | do | 231 | do |
232 | { | 232 | { |
233 | in.getline( line, 1000 ); | 233 | in.getline( line, 1000 ); |
234 | if ( in.eof() ) | 234 | if ( in.eof() ) |
235 | continue; | 235 | continue; |
236 | 236 | ||
237 | k[0] = '\0'; | 237 | k[0] = '\0'; |
238 | v[0] = '\0'; | 238 | v[0] = '\0'; |
239 | 239 | ||
240 | sscanf( line, "%[^:]: %[^\n]", k, v ); | 240 | sscanf( line, "%[^:]: %[^\n]", k, v ); |
241 | key = k; | 241 | key = k; |
242 | value = v; | 242 | value = v; |
243 | key = key.stripWhiteSpace(); | 243 | key = key.stripWhiteSpace(); |
244 | value = value.stripWhiteSpace(); | 244 | value = value.stripWhiteSpace(); |
245 | if ( key == "Package" && value == package ) | 245 | if ( key == "Package" && value == package ) |
246 | { | 246 | { |
247 | // Ignore all lines up to next empty | 247 | // Ignore all lines up to next empty |
248 | do | 248 | do |
249 | { | 249 | { |
250 | in.getline( line, 1000 ); | 250 | in.getline( line, 1000 ); |
251 | if ( in.eof() || QString( line ).stripWhiteSpace() == "" ) | 251 | if ( in.eof() || QString( line ).stripWhiteSpace() == "" ) |
252 | continue; | 252 | continue; |
253 | } while ( !in.eof() && QString( line ).stripWhiteSpace() != "" ); | 253 | } while ( !in.eof() && QString( line ).stripWhiteSpace() != "" ); |
254 | } | 254 | } |
255 | 255 | ||
256 | lines.push_back( QString( line ) ); | 256 | lines.push_back( QString( line ) ); |
257 | out << line << endl; | 257 | out << line << endl; |
258 | 258 | ||
259 | // Improve UI responsiveness | 259 | // Improve UI responsiveness |
260 | i++; | 260 | i++; |
261 | if ( ( i % 50 ) == 0 ) | 261 | if ( ( i % 50 ) == 0 ) |
262 | qApp->processEvents(); | 262 | qApp->processEvents(); |
263 | } while ( !in.eof() ); | 263 | } while ( !in.eof() ); |
264 | 264 | ||
265 | // Write lines out | 265 | // Write lines out |
266 | vector<QString>::iterator it; | 266 | vector<QString>::iterator it; |
267 | for ( it = lines.begin() ; it != lines.end() ; ++it ) | 267 | for ( it = lines.begin() ; it != lines.end() ; ++it ) |
268 | { | 268 | { |
269 | out << (const char *)(*it) << endl; | 269 | out << (const char *)(*it) << endl; |
270 | 270 | ||
271 | // Improve UI responsiveness | 271 | // Improve UI responsiveness |
272 | i++; | 272 | i++; |
273 | if ( ( i % 50 ) == 0 ) | 273 | if ( ( i % 50 ) == 0 ) |
274 | qApp->processEvents(); | 274 | qApp->processEvents(); |
275 | } | 275 | } |
276 | 276 | ||
277 | in.close(); | 277 | in.close(); |
278 | out.close(); | 278 | out.close(); |
279 | 279 | ||
280 | // Remove old status file and put tmp stats file in its place | 280 | // Remove old status file and put tmp stats file in its place |
281 | remove( statusFile ); | 281 | remove( statusFile ); |
282 | rename( outStatusFile, statusFile ); | 282 | rename( outStatusFile, statusFile ); |
283 | } | 283 | } |
284 | 284 | ||
285 | int Ipkg :: executeIpkgCommand( QStringList &cmd, const QString /*option*/ ) | 285 | int Ipkg :: executeIpkgCommand( QStringList &cmd, const QString /*option*/ ) |
286 | { | 286 | { |
287 | // If one is already running - should never be but just to be safe | 287 | // If one is already running - should never be but just to be safe |
288 | if ( proc ) | 288 | if ( proc ) |
289 | { | 289 | { |
290 | delete proc; | 290 | delete proc; |
291 | proc = 0; | 291 | proc = 0; |
292 | } | 292 | } |
293 | 293 | ||
294 | // OK we're gonna use OProcess to run this thing | 294 | // OK we're gonna use OProcess to run this thing |
295 | proc = new OProcess(); | 295 | proc = new OProcess(); |
296 | aborted = false; | 296 | aborted = false; |
297 | 297 | ||
298 | 298 | ||
299 | // Connect up our slots | 299 | // Connect up our slots |
300 | connect(proc, SIGNAL(processExited(OProcess *)), | 300 | connect(proc, SIGNAL(processExited(OProcess *)), |
301 | this, SLOT( processFinished())); | 301 | this, SLOT( processFinished())); |
302 | 302 | ||
303 | connect(proc, SIGNAL(receivedStdout(OProcess *, char *, int)), | 303 | connect(proc, SIGNAL(receivedStdout(OProcess *, char *, int)), |
304 | this, SLOT(commandStdout(OProcess *, char *, int))); | 304 | this, SLOT(commandStdout(OProcess *, char *, int))); |
305 | 305 | ||
306 | connect(proc, SIGNAL(receivedStderr(OProcess *, char *, int)), | 306 | connect(proc, SIGNAL(receivedStderr(OProcess *, char *, int)), |
307 | this, SLOT(commandStderr(OProcess *, char *, int))); | 307 | this, SLOT(commandStderr(OProcess *, char *, int))); |
308 | 308 | ||
309 | for ( QStringList::Iterator it = cmd.begin(); it != cmd.end(); ++it ) | 309 | for ( QStringList::Iterator it = cmd.begin(); it != cmd.end(); ++it ) |
310 | { | 310 | { |
311 | *proc << (*it).latin1(); | 311 | *proc << (*it).latin1(); |
312 | } | 312 | } |
313 | 313 | ||
314 | // Start the process going | 314 | // Start the process going |
315 | finished = false; | 315 | finished = false; |
316 | if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) | 316 | if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) |
317 | { | 317 | { |
318 | emit outputText( QString( "Couldn't start ipkg process" ) ); | 318 | emit outputText( tr("Couldn't start ipkg process" ) ); |
319 | } | 319 | } |
320 | } | 320 | } |
321 | 321 | ||
322 | void Ipkg::commandStdout(OProcess*, char *buffer, int buflen) | 322 | void Ipkg::commandStdout(OProcess*, char *buffer, int buflen) |
323 | { | 323 | { |
324 | QString lineStr = buffer; | 324 | QString lineStr = buffer; |
325 | if ( lineStr[buflen-1] == '\n' ) | 325 | if ( lineStr[buflen-1] == '\n' ) |
326 | buflen --; | 326 | buflen --; |
327 | lineStr = lineStr.left( buflen ); | 327 | lineStr = lineStr.left( buflen ); |
328 | emit outputText( lineStr ); | 328 | emit outputText( lineStr ); |
329 | 329 | ||
330 | // check if we are installing dependant packages | 330 | // check if we are installing dependant packages |
331 | if ( option == "install" || option == "reinstall" ) | 331 | if ( option == "install" || option == "reinstall" ) |
332 | { | 332 | { |
333 | // Need to keep track of any dependant packages that get installed | 333 | // Need to keep track of any dependant packages that get installed |
334 | // so that we can create links to them as necessary | 334 | // so that we can create links to them as necessary |
335 | if ( lineStr.startsWith( "Installing " ) ) | 335 | if ( lineStr.startsWith( "Installing " ) ) |
336 | { | 336 | { |
337 | int start = lineStr.find( " " ) + 1; | 337 | int start = lineStr.find( " " ) + 1; |
338 | int end = lineStr.find( " ", start ); | 338 | int end = lineStr.find( " ", start ); |
339 | QString *package = new QString( lineStr.mid( start, end-start ) ); | 339 | QString *package = new QString( lineStr.mid( start, end-start ) ); |
340 | dependantPackages->append( package ); | 340 | dependantPackages->append( package ); |
341 | } | 341 | } |
342 | } | 342 | } |
343 | else if ( option == "remove" && !( flags & FORCE_DEPENDS ) && | 343 | else if ( option == "remove" && !( flags & FORCE_DEPENDS ) && |
344 | lineStr.find( "is depended upon by packages:" ) != -1 ) | 344 | lineStr.find( "is depended upon by packages:" ) != -1 ) |
345 | { | 345 | { |
346 | // Ipkg should send this to STDERR, but doesn't - so trap here | 346 | // Ipkg should send this to STDERR, but doesn't - so trap here |
347 | error = true; | 347 | error = true; |
348 | } | 348 | } |
349 | 349 | ||
350 | buffer[0] = '\0'; | 350 | buffer[0] = '\0'; |
351 | } | 351 | } |
352 | 352 | ||
353 | void Ipkg::commandStderr(OProcess*, char *buffer, int buflen) | 353 | void Ipkg::commandStderr(OProcess*, char *buffer, int buflen) |
354 | { | 354 | { |
355 | QString lineStr = buffer; | 355 | QString lineStr = buffer; |
356 | if ( lineStr[buflen-1] == '\n' ) | 356 | if ( lineStr[buflen-1] == '\n' ) |
357 | buflen --; | 357 | buflen --; |
358 | lineStr=lineStr.left( buflen ); | 358 | lineStr=lineStr.left( buflen ); |
359 | emit outputText( lineStr ); | 359 | emit outputText( lineStr ); |
360 | buffer[0] = '\0'; | 360 | buffer[0] = '\0'; |
361 | error = true; | 361 | error = true; |
362 | } | 362 | } |
363 | 363 | ||
364 | void Ipkg::processFinished() | 364 | void Ipkg::processFinished() |
365 | { | 365 | { |
366 | // Finally, if we are removing a package, remove its entry from the <destdir>/usr/lib/ipkg/status file | 366 | // Finally, if we are removing a package, remove its entry from the <destdir>/usr/lib/ipkg/status file |
367 | // to workaround an ipkg bug which stops reinstall to a different location | 367 | // to workaround an ipkg bug which stops reinstall to a different location |
368 | 368 | ||
369 | if ( !error && option == "remove" ) | 369 | if ( !error && option == "remove" ) |
370 | removeStatusEntry(); | 370 | removeStatusEntry(); |
371 | 371 | ||
372 | delete proc; | 372 | delete proc; |
373 | proc = 0; | 373 | proc = 0; |
374 | finished = true; | 374 | finished = true; |
375 | 375 | ||
376 | emit ipkgFinished(); | 376 | emit ipkgFinished(); |
377 | } | 377 | } |
378 | 378 | ||
379 | 379 | ||
380 | void Ipkg :: abort() | 380 | void Ipkg :: abort() |
381 | { | 381 | { |
382 | if ( proc ) | 382 | if ( proc ) |
383 | { | 383 | { |
384 | proc->kill(); | 384 | proc->kill(); |
385 | aborted = true; | 385 | aborted = true; |
386 | } | 386 | } |
387 | } | 387 | } |
388 | 388 | ||
389 | /* | ||
390 | int Ipkg :: executeIpkgCommand( QString &cmd, const QString option ) | ||
391 | { | ||
392 | FILE *fp = NULL; | ||
393 | char line[130]; | ||
394 | QString lineStr, lineStrOld; | ||
395 | int ret = false; | ||
396 | |||
397 | fp = popen( (const char *) cmd, "r"); | ||
398 | if ( fp == NULL ) | ||
399 | { | ||
400 | QString text; | ||
401 | text.sprintf( "Couldn't execute %s! See stdout for error code", (const char *)cmd ); | ||
402 | emit outputText( text ); | ||
403 | } | ||
404 | else | ||
405 | { | ||
406 | while ( fgets( line, sizeof line, fp) != NULL ) | ||
407 | { | ||
408 | lineStr = line; | ||
409 | lineStr=lineStr.left( lineStr.length()-1 ); | ||
410 | |||
411 | if ( lineStr != lineStrOld ) | ||
412 | { | ||
413 | //See if we're finished | ||
414 | if ( option == "install" || option == "reinstall" ) | ||
415 | { | ||
416 | // Need to keep track of any dependant packages that get installed | ||
417 | // so that we can create links to them as necessary | ||
418 | if ( lineStr.startsWith( "Installing " ) ) | ||
419 | { | ||
420 | int start = lineStr.find( " " ) + 1; | ||
421 | int end = lineStr.find( " ", start ); | ||
422 | QString *package = new QString( lineStr.mid( start, end-start ) ); | ||
423 | dependantPackages->append( package ); | ||
424 | } | ||
425 | } | ||
426 | |||
427 | if ( option == "update" ) | ||
428 | { | ||
429 | if (lineStr.contains("Updated list")) | ||
430 | ret = true; | ||
431 | } | ||
432 | else if ( option == "download" ) | ||
433 | { | ||
434 | if (lineStr.contains("Downloaded")) | ||
435 | ret = true; | ||
436 | } | ||
437 | else | ||
438 | { | ||
439 | if (lineStr.contains("Done")) | ||
440 | ret = true; | ||
441 | } | ||
442 | |||
443 | emit outputText( lineStr ); | ||
444 | } | ||
445 | lineStrOld = lineStr; | ||
446 | qApp->processEvents(); | ||
447 | } | ||
448 | pclose(fp); | ||
449 | } | ||
450 | |||
451 | return ret; | ||
452 | } | ||
453 | */ | ||
454 | |||
455 | void Ipkg :: linkPackage( const QString &packFileName, const QString &dest, const QString &destDir ) | 389 | void Ipkg :: linkPackage( const QString &packFileName, const QString &dest, const QString &destDir ) |
456 | { | 390 | { |
457 | if ( dest == "root" || dest == "/" ) | 391 | if ( dest == "root" || dest == "/" ) |
458 | return; | 392 | return; |
459 | 393 | ||
460 | qApp->processEvents(); | 394 | qApp->processEvents(); |
461 | QStringList *fileList = getList( packFileName, destDir ); | 395 | QStringList *fileList = getList( packFileName, destDir ); |
462 | qApp->processEvents(); | 396 | qApp->processEvents(); |
463 | processFileList( fileList, destDir ); | 397 | processFileList( fileList, destDir ); |
464 | delete fileList; | 398 | delete fileList; |
465 | } | 399 | } |
466 | 400 | ||
467 | QStringList* Ipkg :: getList( const QString &packageFilename, const QString &destDir ) | 401 | QStringList* Ipkg :: getList( const QString &packageFilename, const QString &destDir ) |
468 | { | 402 | { |
469 | QString packageFileDir = destDir; | 403 | QString packageFileDir = destDir; |
470 | packageFileDir.append( "/usr/lib/ipkg/info/" ); | 404 | packageFileDir.append( "/usr/lib/ipkg/info/" ); |
471 | packageFileDir.append( packageFilename ); | 405 | packageFileDir.append( packageFilename ); |
472 | packageFileDir.append( ".list" ); | 406 | packageFileDir.append( ".list" ); |
473 | QFile f( packageFileDir ); | 407 | QFile f( packageFileDir ); |
474 | 408 | ||
475 | if ( !f.open(IO_ReadOnly) ) | 409 | if ( !f.open(IO_ReadOnly) ) |
476 | { | 410 | { |
477 | // Couldn't open from dest, try from / | 411 | // Couldn't open from dest, try from / |
478 | f.close(); | 412 | f.close(); |
479 | 413 | ||
480 | packageFileDir = "/usr/lib/ipkg/info/"; | 414 | packageFileDir = "/usr/lib/ipkg/info/"; |
481 | packageFileDir.append( packageFilename ); | 415 | packageFileDir.append( packageFilename ); |
482 | packageFileDir.append( ".list" ); | 416 | packageFileDir.append( ".list" ); |
483 | f.setName( packageFileDir ); | 417 | f.setName( packageFileDir ); |
484 | if ( ! f.open(IO_ReadOnly) ) | 418 | if ( ! f.open(IO_ReadOnly) ) |
485 | { | 419 | { |
486 | QString tempstr = "Could not open :"; | 420 | QString tempstr = tr("Could not open :"); |
487 | tempstr.append( packageFileDir ); | 421 | tempstr.append( packageFileDir ); |
488 | emit outputText( tempstr ); | 422 | emit outputText( tempstr ); |
489 | return (QStringList*)0; | 423 | return (QStringList*)0; |
490 | } | 424 | } |
491 | } | 425 | } |
492 | QStringList *fileList = new QStringList(); | 426 | QStringList *fileList = new QStringList(); |
493 | QTextStream t( &f ); | 427 | QTextStream t( &f ); |
494 | while ( !t.eof() ) | 428 | while ( !t.eof() ) |
495 | *fileList += t.readLine(); | 429 | *fileList += t.readLine(); |
496 | 430 | ||
497 | f.close(); | 431 | f.close(); |
498 | return fileList; | 432 | return fileList; |
499 | } | 433 | } |
500 | 434 | ||
501 | void Ipkg :: processFileList( const QStringList *fileList, const QString &destDir ) | 435 | void Ipkg :: processFileList( const QStringList *fileList, const QString &destDir ) |
502 | { | 436 | { |
503 | if ( !fileList || fileList->isEmpty() ) | 437 | if ( !fileList || fileList->isEmpty() ) |
504 | return; | 438 | return; |
505 | 439 | ||
506 | QString baseDir = ROOT; | 440 | QString baseDir = ROOT; |
507 | 441 | ||
508 | if ( createLinks == true ) | 442 | if ( createLinks == true ) |
509 | { | 443 | { |
510 | for ( uint i=0; i < fileList->count(); i++ ) | 444 | for ( uint i=0; i < fileList->count(); i++ ) |
511 | { | 445 | { |
512 | processLinkDir( (*fileList)[i], baseDir, destDir ); | 446 | processLinkDir( (*fileList)[i], baseDir, destDir ); |
513 | qApp->processEvents(); | 447 | qApp->processEvents(); |
514 | } | 448 | } |
515 | } | 449 | } |
516 | else | 450 | else |
517 | { | 451 | { |
518 | for ( int i = fileList->count()-1; i >= 0 ; i-- ) | 452 | for ( int i = fileList->count()-1; i >= 0 ; i-- ) |
519 | { | 453 | { |
520 | processLinkDir( (*fileList)[i], baseDir, destDir ); | 454 | processLinkDir( (*fileList)[i], baseDir, destDir ); |
521 | qApp->processEvents(); | 455 | qApp->processEvents(); |
522 | } | 456 | } |
523 | } | 457 | } |
524 | } | 458 | } |
525 | 459 | ||
526 | void Ipkg :: processLinkDir( const QString &file, const QString &destDir, const QString &baseDir ) | 460 | void Ipkg :: processLinkDir( const QString &file, const QString &destDir, const QString &baseDir ) |
527 | { | 461 | { |
528 | 462 | ||
529 | QString sourceFile = baseDir; | 463 | QString sourceFile = baseDir; |
530 | sourceFile.append( file ); | 464 | sourceFile.append( file ); |
531 | 465 | ||
532 | QString linkFile = destDir; | 466 | QString linkFile = destDir; |
533 | if ( file.startsWith( "/" ) && destDir.right( 1 ) == "/" ) | 467 | if ( file.startsWith( "/" ) && destDir.right( 1 ) == "/" ) |
534 | { | 468 | { |
535 | linkFile.append( file.mid( 1 ) ); | 469 | linkFile.append( file.mid( 1 ) ); |
536 | } | 470 | } |
537 | else | 471 | else |
538 | { | 472 | { |
539 | linkFile.append( file ); | 473 | linkFile.append( file ); |
540 | } | 474 | } |
541 | QString text; | 475 | QString text; |
542 | if ( createLinks ) | 476 | if ( createLinks ) |
543 | { | 477 | { |
544 | // If this file is a directory (ends with a /) and it doesn't exist, | 478 | // If this file is a directory (ends with a /) and it doesn't exist, |
545 | // we need to create it | 479 | // we need to create it |
546 | if ( file.right(1) == "/" ) | 480 | if ( file.right(1) == "/" ) |
547 | { | 481 | { |
548 | QFileInfo f( linkFile ); | 482 | QFileInfo f( linkFile ); |
549 | if ( !f.exists() ) | 483 | if ( !f.exists() ) |
550 | { | 484 | { |
551 | QString tempstr = "Creating directory "; | 485 | QString tempstr = tr("Creating directory "); |
552 | tempstr.append( linkFile ); | 486 | tempstr.append( linkFile ); |
553 | emit outputText( tempstr ); | 487 | emit outputText( tempstr ); |
554 | QDir d; | 488 | QDir d; |
555 | d.mkdir( linkFile, true ); | 489 | d.mkdir( linkFile, true ); |
556 | } | 490 | } |
557 | // else | 491 | // else |
558 | // emit outputText( QString( "Directory " ) + linkFile + " already exists" ); | 492 | // emit outputText( QString( "Directory " ) + linkFile + " already exists" ); |
559 | 493 | ||
560 | } | 494 | } |
561 | else | 495 | else |
562 | { | 496 | { |
563 | int rc = symlink( sourceFile, linkFile ); | 497 | int rc = symlink( sourceFile, linkFile ); |
564 | text = (rc == 0 ? "Linked " : "Failed to link "); | 498 | text = ( rc == 0 ? tr( "Linked %1 to %2" ) : tr( "Failed to link %1 to %2" ) ). |
565 | text.append( sourceFile ); | 499 | arg( sourceFile ). |
566 | text.append( " to " ); | 500 | arg( linkFile ); |
567 | text.append( linkFile ); | ||
568 | emit outputText( text ); | 501 | emit outputText( text ); |
569 | } | 502 | } |
570 | } | 503 | } |
571 | else | 504 | else |
572 | { | 505 | { |
573 | QFileInfo f( linkFile ); | 506 | QFileInfo f( linkFile ); |
574 | if ( f.exists() ) | 507 | if ( f.exists() ) |
575 | { | 508 | { |
576 | if ( f.isFile() ) | 509 | if ( f.isFile() ) |
577 | { | 510 | { |
578 | QFile f( linkFile ); | 511 | QFile f( linkFile ); |
579 | bool rc = f.remove(); | 512 | bool rc = f.remove(); |
580 | 513 | ||
581 | text = (rc ? "Removed " : "Failed to remove "); | 514 | text = ( rc ? tr( "Removed %1" ) : tr( "Failed to remove %1" ) ).arg( linkFile ); |
582 | text.append( linkFile ); | ||
583 | emit outputText( text ); | 515 | emit outputText( text ); |
584 | } | 516 | } |
585 | else if ( f.isDir() ) | 517 | else if ( f.isDir() ) |
586 | { | 518 | { |
587 | QDir d; | 519 | QDir d; |
588 | bool rc = d.rmdir( linkFile, true ); | 520 | bool rc = d.rmdir( linkFile, true ); |
589 | if ( rc ) | 521 | if ( rc ) |
590 | { | 522 | { |
591 | text = (rc ? "Removed " : "Failed to remove "); | 523 | text = ( rc ? tr( "Removed " ) : tr( "Failed to remove " ) ).arg( linkFile ); |
592 | text.append( linkFile ); | ||
593 | emit outputText( text ); | 524 | emit outputText( text ); |
594 | } | 525 | } |
595 | } | 526 | } |
596 | } | 527 | } |
597 | } | 528 | } |
598 | } | 529 | } |
diff --git a/noncore/settings/aqpkg/main.cpp b/noncore/settings/aqpkg/main.cpp index 066d79f..b7f8b7b 100644 --- a/noncore/settings/aqpkg/main.cpp +++ b/noncore/settings/aqpkg/main.cpp | |||
@@ -1,71 +1,78 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | 3 | ||
4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> | 4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> |
5 | .=l. Dan Williams <drw@handhelds.org> | 5 | .=l. Dan Williams <drw@handhelds.org> |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This file is free software; you can | 7 | _;:, .> :=|. This file is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
19 | ..}^=.= = ; Public License for more details. | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | 20 | ++= -. .` .: |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | : = ...= . :.=- You should have received a copy of the GNU |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #ifdef QWS | 30 | #ifdef QWS |
31 | #include <qpe/qpeapplication.h> | 31 | #include <qpe/qpeapplication.h> |
32 | #include <qpe/qcopenvelope_qws.h> | 32 | #include <qpe/qcopenvelope_qws.h> |
33 | #else | 33 | #else |
34 | #include <qapplication.h> | 34 | #include <qapplication.h> |
35 | #endif | 35 | #endif |
36 | 36 | ||
37 | #include <qobjectdefs.h> | 37 | #include <qobjectdefs.h> |
38 | 38 | ||
39 | #include "mainwin.h" | 39 | #include "mainwin.h" |
40 | #include "server.h" | 40 | #include "server.h" |
41 | 41 | ||
42 | #include "global.h" | 42 | #include "global.h" |
43 | 43 | ||
44 | 44 | ||
45 | /* be less intrusive for translation -zecke */ | ||
46 | extern QString LOCAL_SERVER; | ||
47 | extern QString LOCAL_IPKGS; | ||
48 | |||
45 | int main(int argc, char *argv[]) | 49 | int main(int argc, char *argv[]) |
46 | { | 50 | { |
47 | #ifdef QWS | 51 | #ifdef QWS |
48 | QPEApplication a( argc, argv ); | 52 | QPEApplication a( argc, argv ); |
49 | #else | 53 | #else |
50 | QApplication a( argc, argv ); | 54 | QApplication a( argc, argv ); |
51 | #endif | 55 | #endif |
52 | 56 | ||
53 | #ifdef QWS | 57 | #ifdef QWS |
54 | // Disable suspend mode | 58 | // Disable suspend mode |
55 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; | 59 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::DisableSuspend; |
56 | #endif | 60 | #endif |
57 | 61 | ||
62 | LOCAL_SERVER = QObject::tr( "Installed packages" ); | ||
63 | LOCAL_IPKGS = QObject::tr( "Local packages" ); | ||
64 | |||
58 | MainWindow *win = new MainWindow(); | 65 | MainWindow *win = new MainWindow(); |
59 | a.setMainWidget(win); | 66 | a.setMainWidget(win); |
60 | win->showMaximized(); | 67 | win->showMaximized(); |
61 | 68 | ||
62 | a.exec(); | 69 | a.exec(); |
63 | 70 | ||
64 | #ifdef QWS | 71 | #ifdef QWS |
65 | // Reenable suspend mode | 72 | // Reenable suspend mode |
66 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; | 73 | QCopEnvelope( "QPE/System", "setScreenSaverMode(int)" ) << QPEApplication::Enable; |
67 | #endif | 74 | #endif |
68 | #ifdef _DEBUG | 75 | #ifdef _DEBUG |
69 | DumpUnfreed(); | 76 | DumpUnfreed(); |
70 | #endif | 77 | #endif |
71 | } | 78 | } |
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp index 0efa1e0..45a6663 100644 --- a/noncore/settings/aqpkg/mainwin.cpp +++ b/noncore/settings/aqpkg/mainwin.cpp | |||
@@ -33,1191 +33,1189 @@ | |||
33 | #include <qpe/qcopenvelope_qws.h> | 33 | #include <qpe/qcopenvelope_qws.h> |
34 | #include <qmenubar.h> | 34 | #include <qmenubar.h> |
35 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
36 | #include <qtoolbar.h> | 36 | #include <qtoolbar.h> |
37 | #include <qpe/config.h> | 37 | #include <qpe/config.h> |
38 | #include <qpe/resource.h> | 38 | #include <qpe/resource.h> |
39 | 39 | ||
40 | #include <qaction.h> | 40 | #include <qaction.h> |
41 | #include <qcombobox.h> | 41 | #include <qcombobox.h> |
42 | #include <qfile.h> | 42 | #include <qfile.h> |
43 | #include <qlabel.h> | 43 | #include <qlabel.h> |
44 | #include <qlayout.h> | 44 | #include <qlayout.h> |
45 | #include <qlineedit.h> | 45 | #include <qlineedit.h> |
46 | #include <qlistview.h> | 46 | #include <qlistview.h> |
47 | #include <qmenubar.h> | 47 | #include <qmenubar.h> |
48 | #include <qmessagebox.h> | 48 | #include <qmessagebox.h> |
49 | #include <qpopupmenu.h> | 49 | #include <qpopupmenu.h> |
50 | #include <qprogressbar.h> | 50 | #include <qprogressbar.h> |
51 | #include <qtimer.h> | 51 | #include <qtimer.h> |
52 | #include <qwhatsthis.h> | 52 | #include <qwhatsthis.h> |
53 | #include <qwidgetstack.h> | 53 | #include <qwidgetstack.h> |
54 | 54 | ||
55 | #include "categoryfilterimpl.h" | 55 | #include "categoryfilterimpl.h" |
56 | #include "datamgr.h" | 56 | #include "datamgr.h" |
57 | #include "global.h" | 57 | #include "global.h" |
58 | #include "inputdlg.h" | 58 | #include "inputdlg.h" |
59 | #include "ipkg.h" | 59 | #include "ipkg.h" |
60 | #include "installdlgimpl.h" | 60 | #include "installdlgimpl.h" |
61 | #include "letterpushbutton.h" | 61 | #include "letterpushbutton.h" |
62 | #include "mainwin.h" | 62 | #include "mainwin.h" |
63 | #include "packagewin.h" | 63 | #include "packagewin.h" |
64 | #include "settingsimpl.h" | 64 | #include "settingsimpl.h" |
65 | #include "utils.h" | 65 | #include "utils.h" |
66 | 66 | ||
67 | extern int compareVersions( const char *v1, const char *v2 ); | 67 | extern int compareVersions( const char *v1, const char *v2 ); |
68 | 68 | ||
69 | MainWindow :: MainWindow() | 69 | MainWindow :: MainWindow() |
70 | :QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) | 70 | :QMainWindow( 0x0, 0x0, WStyle_ContextHelp ) |
71 | { | 71 | { |
72 | setCaption( tr( "AQPkg - Package Manager" ) ); | 72 | setCaption( tr( "AQPkg - Package Manager" ) ); |
73 | 73 | ||
74 | // Create UI widgets | 74 | // Create UI widgets |
75 | initMainWidget(); | 75 | initMainWidget(); |
76 | initProgressWidget(); | 76 | initProgressWidget(); |
77 | 77 | ||
78 | // Build menu and tool bars | 78 | // Build menu and tool bars |
79 | setToolBarsMovable( FALSE ); | 79 | setToolBarsMovable( FALSE ); |
80 | 80 | ||
81 | QToolBar *bar = new QToolBar( this ); | 81 | QToolBar *bar = new QToolBar( this ); |
82 | bar->setHorizontalStretchable( TRUE ); | 82 | bar->setHorizontalStretchable( TRUE ); |
83 | QMenuBar *mb = new QMenuBar( bar ); | 83 | QMenuBar *mb = new QMenuBar( bar ); |
84 | mb->setMargin( 0 ); | 84 | mb->setMargin( 0 ); |
85 | bar = new QToolBar( this ); | 85 | bar = new QToolBar( this ); |
86 | 86 | ||
87 | // Find toolbar | 87 | // Find toolbar |
88 | findBar = new QToolBar( this ); | 88 | findBar = new QToolBar( this ); |
89 | addToolBar( findBar, QMainWindow::Top, true ); | 89 | addToolBar( findBar, QMainWindow::Top, true ); |
90 | findBar->setHorizontalStretchable( true ); | 90 | findBar->setHorizontalStretchable( true ); |
91 | findEdit = new QLineEdit( findBar ); | 91 | findEdit = new QLineEdit( findBar ); |
92 | QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) ); | 92 | QWhatsThis::add( findEdit, tr( "Type the text to search for here." ) ); |
93 | findBar->setStretchableWidget( findEdit ); | 93 | findBar->setStretchableWidget( findEdit ); |
94 | connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( findPackage( const QString & ) ) ); | 94 | connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( findPackage( const QString & ) ) ); |
95 | 95 | ||
96 | // Quick jump toolbar | 96 | // Quick jump toolbar |
97 | jumpBar = new QToolBar( this ); | 97 | jumpBar = new QToolBar( this ); |
98 | addToolBar( jumpBar, QMainWindow::Top, true ); | 98 | addToolBar( jumpBar, QMainWindow::Top, true ); |
99 | jumpBar->setHorizontalStretchable( true ); | 99 | jumpBar->setHorizontalStretchable( true ); |
100 | QWidget *w = new QWidget( jumpBar ); | 100 | QWidget *w = new QWidget( jumpBar ); |
101 | jumpBar->setStretchableWidget( w ); | 101 | jumpBar->setStretchableWidget( w ); |
102 | 102 | ||
103 | QGridLayout *layout = new QGridLayout( w ); | 103 | QGridLayout *layout = new QGridLayout( w ); |
104 | 104 | ||
105 | char text[2]; | 105 | char text[2]; |
106 | text[1] = '\0'; | 106 | text[1] = '\0'; |
107 | for ( int i = 0 ; i < 26 ; ++i ) | 107 | for ( int i = 0 ; i < 26 ; ++i ) |
108 | { | 108 | { |
109 | text[0] = 'A' + i; | 109 | text[0] = 'A' + i; |
110 | LetterPushButton *b = new LetterPushButton( text, w ); | 110 | LetterPushButton *b = new LetterPushButton( text, w ); |
111 | connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); | 111 | connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); |
112 | layout->addWidget( b, i / 13, i % 13); | 112 | layout->addWidget( b, i / 13, i % 13); |
113 | } | 113 | } |
114 | 114 | ||
115 | QAction *a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, w, 0 ); | 115 | QAction *a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, w, 0 ); |
116 | a->setWhatsThis( tr( "Click here to hide the Quick Jump toolbar." ) ); | 116 | a->setWhatsThis( tr( "Click here to hide the Quick Jump toolbar." ) ); |
117 | connect( a, SIGNAL( activated() ), this, SLOT( hideJumpBar() ) ); | 117 | connect( a, SIGNAL( activated() ), this, SLOT( hideJumpBar() ) ); |
118 | a->addTo( jumpBar ); | 118 | a->addTo( jumpBar ); |
119 | jumpBar->hide(); | 119 | jumpBar->hide(); |
120 | 120 | ||
121 | // Packages menu | 121 | // Packages menu |
122 | QPopupMenu *popup = new QPopupMenu( this ); | 122 | QPopupMenu *popup = new QPopupMenu( this ); |
123 | 123 | ||
124 | a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 ); | 124 | a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "aqpkg/update" ), QString::null, 0, this, 0 ); |
125 | a->setWhatsThis( tr( "Click here to update package lists from servers." ) ); | 125 | a->setWhatsThis( tr( "Click here to update package lists from servers." ) ); |
126 | connect( a, SIGNAL( activated() ), this, SLOT( updateServer() ) ); | 126 | connect( a, SIGNAL( activated() ), this, SLOT( updateServer() ) ); |
127 | a->addTo( popup ); | 127 | a->addTo( popup ); |
128 | a->addTo( bar ); | 128 | a->addTo( bar ); |
129 | 129 | ||
130 | actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 ); | 130 | actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "aqpkg/upgrade" ), QString::null, 0, this, 0 ); |
131 | actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) ); | 131 | actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) ); |
132 | connect( actionUpgrade, SIGNAL( activated() ), this, SLOT( upgradePackages() ) ); | 132 | connect( actionUpgrade, SIGNAL( activated() ), this, SLOT( upgradePackages() ) ); |
133 | actionUpgrade->addTo( popup ); | 133 | actionUpgrade->addTo( popup ); |
134 | actionUpgrade->addTo( bar ); | 134 | actionUpgrade->addTo( bar ); |
135 | 135 | ||
136 | iconDownload = Resource::loadPixmap( "aqpkg/download" ); | 136 | iconDownload = Resource::loadPixmap( "aqpkg/download" ); |
137 | iconRemove = Resource::loadPixmap( "aqpkg/remove" ); | 137 | iconRemove = Resource::loadPixmap( "aqpkg/remove" ); |
138 | actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); | 138 | actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); |
139 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); | 139 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); |
140 | connect( actionDownload, SIGNAL( activated() ), this, SLOT( downloadPackage() ) ); | 140 | connect( actionDownload, SIGNAL( activated() ), this, SLOT( downloadPackage() ) ); |
141 | actionDownload->addTo( popup ); | 141 | actionDownload->addTo( popup ); |
142 | actionDownload->addTo( bar ); | 142 | actionDownload->addTo( bar ); |
143 | 143 | ||
144 | a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 ); | 144 | a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "aqpkg/apply" ), QString::null, 0, this, 0 ); |
145 | a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) ); | 145 | a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) ); |
146 | connect( a, SIGNAL( activated() ), this, SLOT( applyChanges() ) ); | 146 | connect( a, SIGNAL( activated() ), this, SLOT( applyChanges() ) ); |
147 | a->addTo( popup ); | 147 | a->addTo( popup ); |
148 | a->addTo( bar ); | 148 | a->addTo( bar ); |
149 | 149 | ||
150 | popup->insertSeparator(); | 150 | popup->insertSeparator(); |
151 | 151 | ||
152 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); | 152 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); |
153 | a->setWhatsThis( tr( "Click here to configure this application." ) ); | 153 | a->setWhatsThis( tr( "Click here to configure this application." ) ); |
154 | connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) ); | 154 | connect( a, SIGNAL( activated() ), this, SLOT( displaySettings() ) ); |
155 | a->addTo( popup ); | 155 | a->addTo( popup ); |
156 | mb->insertItem( tr( "Actions" ), popup ); | 156 | mb->insertItem( tr( "Actions" ), popup ); |
157 | 157 | ||
158 | // View menu | 158 | // View menu |
159 | popup = new QPopupMenu( this ); | 159 | popup = new QPopupMenu( this ); |
160 | 160 | ||
161 | actionUninstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); | 161 | actionUninstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); |
162 | actionUninstalled->setToggleAction( TRUE ); | 162 | actionUninstalled->setToggleAction( TRUE ); |
163 | actionUninstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) ); | 163 | actionUninstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) ); |
164 | connect( actionUninstalled, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) ); | 164 | connect( actionUninstalled, SIGNAL( activated() ), this, SLOT( filterUninstalledPackages() ) ); |
165 | actionUninstalled->addTo( popup ); | 165 | actionUninstalled->addTo( popup ); |
166 | 166 | ||
167 | actionInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); | 167 | actionInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); |
168 | actionInstalled->setToggleAction( TRUE ); | 168 | actionInstalled->setToggleAction( TRUE ); |
169 | actionInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) ); | 169 | actionInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) ); |
170 | connect( actionInstalled, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) ); | 170 | connect( actionInstalled, SIGNAL( activated() ), this, SLOT( filterInstalledPackages() ) ); |
171 | actionInstalled->addTo( popup ); | 171 | actionInstalled->addTo( popup ); |
172 | 172 | ||
173 | actionUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); | 173 | actionUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); |
174 | actionUpdated->setToggleAction( TRUE ); | 174 | actionUpdated->setToggleAction( TRUE ); |
175 | actionUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) ); | 175 | actionUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) ); |
176 | connect( actionUpdated, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) ); | 176 | connect( actionUpdated, SIGNAL( activated() ), this, SLOT( filterUpgradedPackages() ) ); |
177 | actionUpdated->addTo( popup ); | 177 | actionUpdated->addTo( popup ); |
178 | 178 | ||
179 | popup->insertSeparator(); | 179 | popup->insertSeparator(); |
180 | 180 | ||
181 | actionFilter = new QAction( tr( "Filter by category" ), Resource::loadPixmap( "aqpkg/filter" ), QString::null, 0, this, 0 ); | 181 | actionFilter = new QAction( tr( "Filter by category" ), Resource::loadPixmap( "aqpkg/filter" ), QString::null, 0, this, 0 ); |
182 | actionFilter->setToggleAction( TRUE ); | 182 | actionFilter->setToggleAction( TRUE ); |
183 | actionFilter->setWhatsThis( tr( "Click here to list packages belonging to one category." ) ); | 183 | actionFilter->setWhatsThis( tr( "Click here to list packages belonging to one category." ) ); |
184 | connect( actionFilter, SIGNAL( activated() ), this, SLOT( filterCategory() ) ); | 184 | connect( actionFilter, SIGNAL( activated() ), this, SLOT( filterCategory() ) ); |
185 | actionFilter->addTo( popup ); | 185 | actionFilter->addTo( popup ); |
186 | 186 | ||
187 | a = new QAction( tr( "Set filter category" ), QString::null, 0, this, 0 ); | 187 | a = new QAction( tr( "Set filter category" ), QString::null, 0, this, 0 ); |
188 | a->setWhatsThis( tr( "Click here to change package category to used filter." ) ); | 188 | a->setWhatsThis( tr( "Click here to change package category to used filter." ) ); |
189 | connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) ); | 189 | connect( a, SIGNAL( activated() ), this, SLOT( setFilterCategory() ) ); |
190 | a->addTo( popup ); | 190 | a->addTo( popup ); |
191 | 191 | ||
192 | popup->insertSeparator(); | 192 | popup->insertSeparator(); |
193 | 193 | ||
194 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); | 194 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); |
195 | a->setWhatsThis( tr( "Click here to search for text in package names." ) ); | 195 | a->setWhatsThis( tr( "Click here to search for text in package names." ) ); |
196 | connect( a, SIGNAL( activated() ), this, SLOT( displayFindBar() ) ); | 196 | connect( a, SIGNAL( activated() ), this, SLOT( displayFindBar() ) ); |
197 | a->addTo( popup ); | 197 | a->addTo( popup ); |
198 | 198 | ||
199 | actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); | 199 | actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); |
200 | actionFindNext->setEnabled( FALSE ); | 200 | actionFindNext->setEnabled( FALSE ); |
201 | actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) ); | 201 | actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) ); |
202 | connect( actionFindNext, SIGNAL( activated() ), this, SLOT( repeatFind() ) ); | 202 | connect( actionFindNext, SIGNAL( activated() ), this, SLOT( repeatFind() ) ); |
203 | actionFindNext->addTo( popup ); | 203 | actionFindNext->addTo( popup ); |
204 | actionFindNext->addTo( findBar ); | 204 | actionFindNext->addTo( findBar ); |
205 | 205 | ||
206 | 206 | ||
207 | popup->insertSeparator(); | 207 | popup->insertSeparator(); |
208 | 208 | ||
209 | a = new QAction( tr( "Quick Jump keypad" ), Resource::loadPixmap( "aqpkg/keyboard" ), QString::null, 0, this, 0 ); | 209 | a = new QAction( tr( "Quick Jump keypad" ), Resource::loadPixmap( "aqpkg/keyboard" ), QString::null, 0, this, 0 ); |
210 | a->setWhatsThis( tr( "Click here to display/hide keypad to allow quick movement through the package list." ) ); | 210 | a->setWhatsThis( tr( "Click here to display/hide keypad to allow quick movement through the package list." ) ); |
211 | connect( a, SIGNAL( activated() ), this, SLOT( displayJumpBar() ) ); | 211 | connect( a, SIGNAL( activated() ), this, SLOT( displayJumpBar() ) ); |
212 | a->addTo( popup ); | 212 | a->addTo( popup ); |
213 | 213 | ||
214 | mb->insertItem( tr( "View" ), popup ); | 214 | mb->insertItem( tr( "View" ), popup ); |
215 | 215 | ||
216 | // Finish find toolbar creation | 216 | // Finish find toolbar creation |
217 | a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 217 | a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
218 | a->setWhatsThis( tr( "Click here to hide the find toolbar." ) ); | 218 | a->setWhatsThis( tr( "Click here to hide the find toolbar." ) ); |
219 | connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) ); | 219 | connect( a, SIGNAL( activated() ), this, SLOT( hideFindBar() ) ); |
220 | a->addTo( findBar ); | 220 | a->addTo( findBar ); |
221 | findBar->hide(); | 221 | findBar->hide(); |
222 | 222 | ||
223 | // Create widget stack and add UI widgets | 223 | // Create widget stack and add UI widgets |
224 | stack = new QWidgetStack( this ); | 224 | stack = new QWidgetStack( this ); |
225 | stack->addWidget( progressWindow, 2 ); | 225 | stack->addWidget( progressWindow, 2 ); |
226 | stack->addWidget( networkPkgWindow, 1 ); | 226 | stack->addWidget( networkPkgWindow, 1 ); |
227 | setCentralWidget( stack ); | 227 | setCentralWidget( stack ); |
228 | stack->raiseWidget( progressWindow ); | 228 | stack->raiseWidget( progressWindow ); |
229 | 229 | ||
230 | // Delayed call to finish initialization | 230 | // Delayed call to finish initialization |
231 | QTimer::singleShot( 100, this, SLOT( init() ) ); | 231 | QTimer::singleShot( 100, this, SLOT( init() ) ); |
232 | } | 232 | } |
233 | 233 | ||
234 | MainWindow :: ~MainWindow() | 234 | MainWindow :: ~MainWindow() |
235 | { | 235 | { |
236 | delete mgr; | 236 | delete mgr; |
237 | } | 237 | } |
238 | 238 | ||
239 | void MainWindow :: initMainWidget() | 239 | void MainWindow :: initMainWidget() |
240 | { | 240 | { |
241 | networkPkgWindow = new QWidget( this ); | 241 | networkPkgWindow = new QWidget( this ); |
242 | 242 | ||
243 | QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow ); | 243 | QLabel *l = new QLabel( tr( "Servers:" ), networkPkgWindow ); |
244 | 244 | ||
245 | serversList = new QComboBox( networkPkgWindow ); | 245 | serversList = new QComboBox( networkPkgWindow ); |
246 | connect( serversList, SIGNAL(activated(int)), this, SLOT(serverSelected(int)) ); | 246 | connect( serversList, SIGNAL(activated(int)), this, SLOT(serverSelected(int)) ); |
247 | QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) ); | 247 | QWhatsThis::add( serversList, tr( "Click here to select a package feed." ) ); |
248 | 248 | ||
249 | installedIcon = Resource::loadPixmap( "installed" ); | 249 | installedIcon = Resource::loadPixmap( "installed" ); |
250 | updatedIcon = Resource::loadPixmap( "aqpkg/updated" ); | 250 | updatedIcon = Resource::loadPixmap( "aqpkg/updated" ); |
251 | 251 | ||
252 | packagesList = new QListView( networkPkgWindow ); | 252 | packagesList = new QListView( networkPkgWindow ); |
253 | packagesList->addColumn( tr( "Packages" ), 225 ); | 253 | packagesList->addColumn( tr( "Packages" ), 225 ); |
254 | QWhatsThis::add( packagesList, tr( "This is a listing of all packages for the server feed selected above.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nClick inside the box at the left to select a package." ) ); | 254 | QWhatsThis::add( packagesList, tr( "This is a listing of all packages for the server feed selected above.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nClick inside the box at the left to select a package." ) ); |
255 | QPEApplication::setStylusOperation( packagesList->viewport(), QPEApplication::RightOnHold ); | 255 | QPEApplication::setStylusOperation( packagesList->viewport(), QPEApplication::RightOnHold ); |
256 | connect( packagesList, SIGNAL(rightButtonPressed(QListViewItem *,const QPoint &,int)), | 256 | connect( packagesList, SIGNAL(rightButtonPressed(QListViewItem *,const QPoint &,int)), |
257 | this, SLOT(slotDisplayPackage(QListViewItem *)) ); | 257 | this, SLOT(slotDisplayPackage(QListViewItem *)) ); |
258 | 258 | ||
259 | QVBoxLayout *vbox = new QVBoxLayout( networkPkgWindow, 0, -1 ); | 259 | QVBoxLayout *vbox = new QVBoxLayout( networkPkgWindow, 0, -1 ); |
260 | QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 ); | 260 | QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1 ); |
261 | hbox1->addWidget( l ); | 261 | hbox1->addWidget( l ); |
262 | hbox1->addWidget( serversList ); | 262 | hbox1->addWidget( serversList ); |
263 | 263 | ||
264 | vbox->addWidget( packagesList ); | 264 | vbox->addWidget( packagesList ); |
265 | 265 | ||
266 | downloadEnabled = TRUE; | 266 | downloadEnabled = TRUE; |
267 | } | 267 | } |
268 | 268 | ||
269 | void MainWindow :: initProgressWidget() | 269 | void MainWindow :: initProgressWidget() |
270 | { | 270 | { |
271 | progressWindow = new QWidget( this ); | 271 | progressWindow = new QWidget( this ); |
272 | 272 | ||
273 | QVBoxLayout *layout = new QVBoxLayout( progressWindow, 4, 4 ); | 273 | QVBoxLayout *layout = new QVBoxLayout( progressWindow, 4, 4 ); |
274 | 274 | ||
275 | m_status = new QLabel( progressWindow ); | 275 | m_status = new QLabel( progressWindow ); |
276 | m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); | 276 | m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); |
277 | layout->addWidget( m_status ); | 277 | layout->addWidget( m_status ); |
278 | 278 | ||
279 | m_progress = new QProgressBar( progressWindow ); | 279 | m_progress = new QProgressBar( progressWindow ); |
280 | layout->addWidget( m_progress ); | 280 | layout->addWidget( m_progress ); |
281 | } | 281 | } |
282 | 282 | ||
283 | void MainWindow :: init() | 283 | void MainWindow :: init() |
284 | { | 284 | { |
285 | #ifdef QWS | 285 | #ifdef QWS |
286 | // read download directory from config file | 286 | // read download directory from config file |
287 | Config cfg( "aqpkg" ); | 287 | Config cfg( "aqpkg" ); |
288 | cfg.setGroup( "settings" ); | 288 | cfg.setGroup( "settings" ); |
289 | currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); | 289 | currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); |
290 | // showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); | 290 | // showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); |
291 | 291 | ||
292 | #endif | 292 | #endif |
293 | 293 | ||
294 | stack->raiseWidget( progressWindow ); | 294 | stack->raiseWidget( progressWindow ); |
295 | 295 | ||
296 | mgr = new DataManager(); | 296 | mgr = new DataManager(); |
297 | connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) ); | 297 | connect( mgr, SIGNAL( progressSetSteps( int ) ), this, SLOT( setProgressSteps( int ) ) ); |
298 | connect( mgr, SIGNAL( progressSetMessage( const QString & ) ), | 298 | connect( mgr, SIGNAL( progressSetMessage( const QString & ) ), |
299 | this, SLOT( setProgressMessage( const QString & ) ) ); | 299 | this, SLOT( setProgressMessage( const QString & ) ) ); |
300 | connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) ); | 300 | connect( mgr, SIGNAL( progressUpdate( int ) ), this, SLOT( updateProgress( int ) ) ); |
301 | mgr->loadServers(); | 301 | mgr->loadServers(); |
302 | 302 | ||
303 | showUninstalledPkgs = false; | 303 | showUninstalledPkgs = false; |
304 | showInstalledPkgs = false; | 304 | showInstalledPkgs = false; |
305 | showUpgradedPkgs = false; | 305 | showUpgradedPkgs = false; |
306 | categoryFilterEnabled = false; | 306 | categoryFilterEnabled = false; |
307 | 307 | ||
308 | updateData(); | 308 | updateData(); |
309 | 309 | ||
310 | stack->raiseWidget( networkPkgWindow ); | 310 | stack->raiseWidget( networkPkgWindow ); |
311 | } | 311 | } |
312 | 312 | ||
313 | void MainWindow :: setDocument( const QString &doc ) | 313 | void MainWindow :: setDocument( const QString &doc ) |
314 | { | 314 | { |
315 | // Remove path from package | 315 | // Remove path from package |
316 | QString package = Utils::getPackageNameFromIpkFilename( doc ); | 316 | QString package = Utils::getPackageNameFromIpkFilename( doc ); |
317 | 317 | ||
318 | // First select local server | 318 | // First select local server |
319 | for ( int i = 0 ; i < serversList->count() ; ++i ) | 319 | for ( int i = 0 ; i < serversList->count() ; ++i ) |
320 | { | 320 | { |
321 | if ( serversList->text( i ) == LOCAL_IPKGS ) | 321 | if ( serversList->text( i ) == LOCAL_IPKGS ) |
322 | { | 322 | { |
323 | serversList->setCurrentItem( i ); | 323 | serversList->setCurrentItem( i ); |
324 | break; | 324 | break; |
325 | } | 325 | } |
326 | } | 326 | } |
327 | serverSelected( 0 ); | 327 | serverSelected( 0 ); |
328 | 328 | ||
329 | // Now set the check box of the selected package | 329 | // Now set the check box of the selected package |
330 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 330 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
331 | item != 0 ; | 331 | item != 0 ; |
332 | item = (QCheckListItem *)item->nextSibling() ) | 332 | item = (QCheckListItem *)item->nextSibling() ) |
333 | { | 333 | { |
334 | if ( item->text().startsWith( package ) ) | 334 | if ( item->text().startsWith( package ) ) |
335 | { | 335 | { |
336 | item->setOn( true ); | 336 | item->setOn( true ); |
337 | break; | 337 | break; |
338 | } | 338 | } |
339 | } | 339 | } |
340 | } | 340 | } |
341 | 341 | ||
342 | void MainWindow :: displaySettings() | 342 | void MainWindow :: displaySettings() |
343 | { | 343 | { |
344 | SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); | 344 | SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); |
345 | if ( dlg->showDlg() ) | 345 | if ( dlg->showDlg() ) |
346 | { | 346 | { |
347 | stack->raiseWidget( progressWindow ); | 347 | stack->raiseWidget( progressWindow ); |
348 | updateData(); | 348 | updateData(); |
349 | stack->raiseWidget( networkPkgWindow ); | 349 | stack->raiseWidget( networkPkgWindow ); |
350 | } | 350 | } |
351 | delete dlg; | 351 | delete dlg; |
352 | } | 352 | } |
353 | 353 | ||
354 | void MainWindow :: closeEvent( QCloseEvent *e ) | 354 | void MainWindow :: closeEvent( QCloseEvent *e ) |
355 | { | 355 | { |
356 | // If install dialog is visible, return to main view, otherwise close app | 356 | // If install dialog is visible, return to main view, otherwise close app |
357 | QWidget *widget = stack->visibleWidget(); | 357 | QWidget *widget = stack->visibleWidget(); |
358 | 358 | ||
359 | if ( widget != networkPkgWindow && widget != progressWindow ) | 359 | if ( widget != networkPkgWindow && widget != progressWindow ) |
360 | { | 360 | { |
361 | if ( widget ) delete widget; | 361 | if ( widget ) delete widget; |
362 | stack->raiseWidget( networkPkgWindow ); | 362 | stack->raiseWidget( networkPkgWindow ); |
363 | e->ignore(); | 363 | e->ignore(); |
364 | } | 364 | } |
365 | else | 365 | else |
366 | { | 366 | { |
367 | e->accept(); | 367 | e->accept(); |
368 | } | 368 | } |
369 | } | 369 | } |
370 | 370 | ||
371 | void MainWindow :: displayFindBar() | 371 | void MainWindow :: displayFindBar() |
372 | { | 372 | { |
373 | findBar->show(); | 373 | findBar->show(); |
374 | findEdit->setFocus(); | 374 | findEdit->setFocus(); |
375 | } | 375 | } |
376 | 376 | ||
377 | void MainWindow :: displayJumpBar() | 377 | void MainWindow :: displayJumpBar() |
378 | { | 378 | { |
379 | jumpBar->show(); | 379 | jumpBar->show(); |
380 | } | 380 | } |
381 | 381 | ||
382 | void MainWindow :: repeatFind() | 382 | void MainWindow :: repeatFind() |
383 | { | 383 | { |
384 | searchForPackage( findEdit->text() ); | 384 | searchForPackage( findEdit->text() ); |
385 | } | 385 | } |
386 | 386 | ||
387 | void MainWindow :: findPackage( const QString &text ) | 387 | void MainWindow :: findPackage( const QString &text ) |
388 | { | 388 | { |
389 | actionFindNext->setEnabled( !text.isEmpty() ); | 389 | actionFindNext->setEnabled( !text.isEmpty() ); |
390 | searchForPackage( text ); | 390 | searchForPackage( text ); |
391 | } | 391 | } |
392 | 392 | ||
393 | void MainWindow :: hideFindBar() | 393 | void MainWindow :: hideFindBar() |
394 | { | 394 | { |
395 | findBar->hide(); | 395 | findBar->hide(); |
396 | } | 396 | } |
397 | 397 | ||
398 | void MainWindow :: hideJumpBar() | 398 | void MainWindow :: hideJumpBar() |
399 | { | 399 | { |
400 | jumpBar->hide(); | 400 | jumpBar->hide(); |
401 | } | 401 | } |
402 | 402 | ||
403 | void MainWindow :: filterUninstalledPackages() | 403 | void MainWindow :: filterUninstalledPackages() |
404 | { | 404 | { |
405 | showUninstalledPkgs = actionUninstalled->isOn(); | 405 | showUninstalledPkgs = actionUninstalled->isOn(); |
406 | if ( showUninstalledPkgs ) | 406 | if ( showUninstalledPkgs ) |
407 | { | 407 | { |
408 | showInstalledPkgs = FALSE; | 408 | showInstalledPkgs = FALSE; |
409 | showUpgradedPkgs = FALSE; | 409 | showUpgradedPkgs = FALSE; |
410 | } | 410 | } |
411 | serverSelected( -1 ); | 411 | serverSelected( -1 ); |
412 | 412 | ||
413 | actionInstalled->setOn( FALSE ); | 413 | actionInstalled->setOn( FALSE ); |
414 | actionUpdated->setOn( FALSE ); | 414 | actionUpdated->setOn( FALSE ); |
415 | } | 415 | } |
416 | 416 | ||
417 | void MainWindow :: filterInstalledPackages() | 417 | void MainWindow :: filterInstalledPackages() |
418 | { | 418 | { |
419 | showInstalledPkgs = actionInstalled->isOn(); | 419 | showInstalledPkgs = actionInstalled->isOn(); |
420 | if ( showInstalledPkgs ) | 420 | if ( showInstalledPkgs ) |
421 | { | 421 | { |
422 | showUninstalledPkgs = FALSE; | 422 | showUninstalledPkgs = FALSE; |
423 | showUpgradedPkgs = FALSE; | 423 | showUpgradedPkgs = FALSE; |
424 | } | 424 | } |
425 | serverSelected( -1 ); | 425 | serverSelected( -1 ); |
426 | 426 | ||
427 | actionUninstalled->setOn( FALSE ); | 427 | actionUninstalled->setOn( FALSE ); |
428 | actionUpdated->setOn( FALSE ); | 428 | actionUpdated->setOn( FALSE ); |
429 | } | 429 | } |
430 | 430 | ||
431 | void MainWindow :: filterUpgradedPackages() | 431 | void MainWindow :: filterUpgradedPackages() |
432 | { | 432 | { |
433 | showUpgradedPkgs = actionUpdated->isOn(); | 433 | showUpgradedPkgs = actionUpdated->isOn(); |
434 | if ( showUpgradedPkgs ) | 434 | if ( showUpgradedPkgs ) |
435 | { | 435 | { |
436 | showUninstalledPkgs = FALSE; | 436 | showUninstalledPkgs = FALSE; |
437 | showInstalledPkgs = FALSE; | 437 | showInstalledPkgs = FALSE; |
438 | } | 438 | } |
439 | serverSelected( -1 ); | 439 | serverSelected( -1 ); |
440 | 440 | ||
441 | actionUninstalled->setOn( FALSE ); | 441 | actionUninstalled->setOn( FALSE ); |
442 | actionInstalled->setOn( FALSE ); | 442 | actionInstalled->setOn( FALSE ); |
443 | } | 443 | } |
444 | 444 | ||
445 | bool MainWindow :: setFilterCategory() | 445 | bool MainWindow :: setFilterCategory() |
446 | { | 446 | { |
447 | // Get categories; | 447 | // Get categories; |
448 | CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this ); | 448 | CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this ); |
449 | if ( dlg.exec() == QDialog::Accepted ) | 449 | if ( dlg.exec() == QDialog::Accepted ) |
450 | { | 450 | { |
451 | categoryFilter = dlg.getSelectedFilter(); | 451 | categoryFilter = dlg.getSelectedFilter(); |
452 | 452 | ||
453 | if ( categoryFilter == "" ) | 453 | if ( categoryFilter == "" ) |
454 | return false; | 454 | return false; |
455 | 455 | ||
456 | categoryFilterEnabled = true; | 456 | categoryFilterEnabled = true; |
457 | serverSelected( -1 ); | 457 | serverSelected( -1 ); |
458 | actionFilter->setOn( TRUE ); | 458 | actionFilter->setOn( TRUE ); |
459 | return true; | 459 | return true; |
460 | } | 460 | } |
461 | 461 | ||
462 | return false; | 462 | return false; |
463 | } | 463 | } |
464 | 464 | ||
465 | void MainWindow :: filterCategory() | 465 | void MainWindow :: filterCategory() |
466 | { | 466 | { |
467 | if ( !actionFilter->isOn() ) | 467 | if ( !actionFilter->isOn() ) |
468 | { | 468 | { |
469 | filterByCategory( FALSE ); | 469 | filterByCategory( FALSE ); |
470 | } | 470 | } |
471 | else | 471 | else |
472 | { | 472 | { |
473 | actionFilter->setOn( filterByCategory( TRUE ) ); | 473 | actionFilter->setOn( filterByCategory( TRUE ) ); |
474 | } | 474 | } |
475 | } | 475 | } |
476 | 476 | ||
477 | bool MainWindow :: filterByCategory( bool val ) | 477 | bool MainWindow :: filterByCategory( bool val ) |
478 | { | 478 | { |
479 | if ( val ) | 479 | if ( val ) |
480 | { | 480 | { |
481 | if ( categoryFilter == "" ) | 481 | if ( categoryFilter == "" ) |
482 | { | 482 | { |
483 | if ( !setFilterCategory() ) | 483 | if ( !setFilterCategory() ) |
484 | return false; | 484 | return false; |
485 | } | 485 | } |
486 | 486 | ||
487 | categoryFilterEnabled = true; | 487 | categoryFilterEnabled = true; |
488 | serverSelected( -1 ); | 488 | serverSelected( -1 ); |
489 | return true; | 489 | return true; |
490 | } | 490 | } |
491 | else | 491 | else |
492 | { | 492 | { |
493 | // Turn off filter | 493 | // Turn off filter |
494 | categoryFilterEnabled = false; | 494 | categoryFilterEnabled = false; |
495 | serverSelected( -1 ); | 495 | serverSelected( -1 ); |
496 | return false; | 496 | return false; |
497 | } | 497 | } |
498 | } | 498 | } |
499 | 499 | ||
500 | void MainWindow :: raiseMainWidget() | 500 | void MainWindow :: raiseMainWidget() |
501 | { | 501 | { |
502 | stack->raiseWidget( networkPkgWindow ); | 502 | stack->raiseWidget( networkPkgWindow ); |
503 | } | 503 | } |
504 | 504 | ||
505 | void MainWindow :: raiseProgressWidget() | 505 | void MainWindow :: raiseProgressWidget() |
506 | { | 506 | { |
507 | stack->raiseWidget( progressWindow ); | 507 | stack->raiseWidget( progressWindow ); |
508 | } | 508 | } |
509 | 509 | ||
510 | void MainWindow :: enableUpgrade( bool enabled ) | 510 | void MainWindow :: enableUpgrade( bool enabled ) |
511 | { | 511 | { |
512 | actionUpgrade->setEnabled( enabled ); | 512 | actionUpgrade->setEnabled( enabled ); |
513 | } | 513 | } |
514 | 514 | ||
515 | void MainWindow :: enableDownload( bool enabled ) | 515 | void MainWindow :: enableDownload( bool enabled ) |
516 | { | 516 | { |
517 | if ( enabled ) | 517 | if ( enabled ) |
518 | { | 518 | { |
519 | actionDownload->setIconSet( iconDownload ); | 519 | actionDownload->setIconSet( iconDownload ); |
520 | actionDownload->setText( tr( "Download" ) ); | 520 | actionDownload->setText( tr( "Download" ) ); |
521 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); | 521 | actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); |
522 | } | 522 | } |
523 | else | 523 | else |
524 | { | 524 | { |
525 | actionDownload->setIconSet( iconRemove ); | 525 | actionDownload->setIconSet( iconRemove ); |
526 | actionDownload->setText( tr( "Remove" ) ); | 526 | actionDownload->setText( tr( "Remove" ) ); |
527 | actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) ); | 527 | actionDownload->setWhatsThis( tr( "Click here to uninstall the currently selected package(s)." ) ); |
528 | } | 528 | } |
529 | } | 529 | } |
530 | 530 | ||
531 | void MainWindow :: setProgressSteps( int numsteps ) | 531 | void MainWindow :: setProgressSteps( int numsteps ) |
532 | { | 532 | { |
533 | m_progress->setTotalSteps( numsteps ); | 533 | m_progress->setTotalSteps( numsteps ); |
534 | } | 534 | } |
535 | 535 | ||
536 | void MainWindow :: setProgressMessage( const QString &msg ) | 536 | void MainWindow :: setProgressMessage( const QString &msg ) |
537 | { | 537 | { |
538 | m_status->setText( msg ); | 538 | m_status->setText( msg ); |
539 | } | 539 | } |
540 | 540 | ||
541 | void MainWindow :: updateProgress( int progress ) | 541 | void MainWindow :: updateProgress( int progress ) |
542 | { | 542 | { |
543 | m_progress->setProgress( progress ); | 543 | m_progress->setProgress( progress ); |
544 | } | 544 | } |
545 | 545 | ||
546 | void MainWindow :: updateData() | 546 | void MainWindow :: updateData() |
547 | { | 547 | { |
548 | m_progress->setTotalSteps( mgr->getServerList().count() ); | 548 | m_progress->setTotalSteps( mgr->getServerList().count() ); |
549 | 549 | ||
550 | serversList->clear(); | 550 | serversList->clear(); |
551 | packagesList->clear(); | 551 | packagesList->clear(); |
552 | 552 | ||
553 | int activeItem = -1; | 553 | int activeItem = -1; |
554 | int i = 0; | 554 | int i = 0; |
555 | QString serverName; | 555 | QString serverName; |
556 | 556 | ||
557 | QListIterator<Server> it( mgr->getServerList() ); | 557 | QListIterator<Server> it( mgr->getServerList() ); |
558 | Server *server; | 558 | Server *server; |
559 | 559 | ||
560 | for ( ; it.current(); ++it, ++i ) | 560 | for ( ; it.current(); ++it, ++i ) |
561 | { | 561 | { |
562 | server = it.current(); | 562 | server = it.current(); |
563 | serverName = server->getServerName(); | 563 | serverName = server->getServerName(); |
564 | m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) ); | 564 | m_status->setText( tr( "Building server list:\n\t%1" ).arg( serverName ) ); |
565 | m_progress->setProgress( i ); | 565 | m_progress->setProgress( i ); |
566 | qApp->processEvents(); | 566 | qApp->processEvents(); |
567 | 567 | ||
568 | if ( !server->isServerActive() ) | 568 | if ( !server->isServerActive() ) |
569 | { | 569 | { |
570 | i--; | 570 | i--; |
571 | continue; | 571 | continue; |
572 | } | 572 | } |
573 | 573 | ||
574 | serversList->insertItem( serverName ); | 574 | serversList->insertItem( serverName ); |
575 | if ( serverName == currentlySelectedServer ) | 575 | if ( serverName == currentlySelectedServer ) |
576 | activeItem = i; | 576 | activeItem = i; |
577 | } | 577 | } |
578 | 578 | ||
579 | // set selected server to be active server | 579 | // set selected server to be active server |
580 | if ( activeItem != -1 ) | 580 | if ( activeItem != -1 ) |
581 | serversList->setCurrentItem( activeItem ); | 581 | serversList->setCurrentItem( activeItem ); |
582 | serverSelected( 0, FALSE ); | 582 | serverSelected( 0, FALSE ); |
583 | } | 583 | } |
584 | 584 | ||
585 | void MainWindow :: serverSelected( int index ) | 585 | void MainWindow :: serverSelected( int index ) |
586 | { | 586 | { |
587 | serverSelected( index, TRUE ); | 587 | serverSelected( index, TRUE ); |
588 | } | 588 | } |
589 | 589 | ||
590 | void MainWindow :: serverSelected( int, bool raiseProgress ) | 590 | void MainWindow :: serverSelected( int, bool raiseProgress ) |
591 | { | 591 | { |
592 | QPixmap nullIcon( installedIcon.size() ); | 592 | QPixmap nullIcon( installedIcon.size() ); |
593 | nullIcon.fill( colorGroup().base() ); | 593 | nullIcon.fill( colorGroup().base() ); |
594 | 594 | ||
595 | // display packages | 595 | // display packages |
596 | QString serverName = serversList->currentText(); | 596 | QString serverName = serversList->currentText(); |
597 | currentlySelectedServer = serverName; | 597 | currentlySelectedServer = serverName; |
598 | 598 | ||
599 | Server *s = mgr->getServer( serverName ); | 599 | Server *s = mgr->getServer( serverName ); |
600 | 600 | ||
601 | QList<Package> &list = s->getPackageList(); | 601 | QList<Package> &list = s->getPackageList(); |
602 | QListIterator<Package> it( list ); | 602 | QListIterator<Package> it( list ); |
603 | 603 | ||
604 | // Display progress widget while loading list | 604 | // Display progress widget while loading list |
605 | bool doProgress = ( list.count() > 200 ); | 605 | bool doProgress = ( list.count() > 200 ); |
606 | if ( doProgress ) | 606 | if ( doProgress ) |
607 | { | 607 | { |
608 | if ( raiseProgress ) | 608 | if ( raiseProgress ) |
609 | { | 609 | { |
610 | stack->raiseWidget( progressWindow ); | 610 | stack->raiseWidget( progressWindow ); |
611 | } | 611 | } |
612 | m_progress->setTotalSteps( list.count() ); | 612 | m_progress->setTotalSteps( list.count() ); |
613 | m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) ); | 613 | m_status->setText( tr( "Building package list for:\n\t%1" ).arg( serverName ) ); |
614 | } | 614 | } |
615 | 615 | ||
616 | packagesList->clear(); | 616 | packagesList->clear(); |
617 | 617 | ||
618 | #ifdef QWS | 618 | #ifdef QWS |
619 | // read download directory from config file | 619 | // read download directory from config file |
620 | Config cfg( "aqpkg" ); | 620 | Config cfg( "aqpkg" ); |
621 | cfg.setGroup( "settings" ); | 621 | cfg.setGroup( "settings" ); |
622 | cfg.writeEntry( "selectedServer", currentlySelectedServer ); | 622 | cfg.writeEntry( "selectedServer", currentlySelectedServer ); |
623 | #endif | 623 | #endif |
624 | 624 | ||
625 | int i = 0; | 625 | int i = 0; |
626 | Package *package; | 626 | Package *package; |
627 | for ( ; it.current(); ++it ) | 627 | for ( ; it.current(); ++it ) |
628 | { | 628 | { |
629 | // Update progress after every 100th package (arbitrary value, seems to give good balance) | 629 | // Update progress after every 100th package (arbitrary value, seems to give good balance) |
630 | i++; | 630 | i++; |
631 | if ( ( i % 100 ) == 0 ) | 631 | if ( ( i % 100 ) == 0 ) |
632 | { | 632 | { |
633 | if ( doProgress ) | 633 | if ( doProgress ) |
634 | { | 634 | { |
635 | m_progress->setProgress( i ); | 635 | m_progress->setProgress( i ); |
636 | } | 636 | } |
637 | qApp->processEvents(); | 637 | qApp->processEvents(); |
638 | } | 638 | } |
639 | 639 | ||
640 | QString text = ""; | 640 | QString text = ""; |
641 | 641 | ||
642 | package = it.current(); | 642 | package = it.current(); |
643 | 643 | ||
644 | // Apply show only uninstalled packages filter | 644 | // Apply show only uninstalled packages filter |
645 | if ( showUninstalledPkgs && package->isInstalled() ) | 645 | if ( showUninstalledPkgs && package->isInstalled() ) |
646 | continue; | 646 | continue; |
647 | 647 | ||
648 | // Apply show only installed packages filter | 648 | // Apply show only installed packages filter |
649 | if ( showInstalledPkgs && !package->isInstalled() ) | 649 | if ( showInstalledPkgs && !package->isInstalled() ) |
650 | continue; | 650 | continue; |
651 | 651 | ||
652 | // Apply show only new installed packages filter | 652 | // Apply show only new installed packages filter |
653 | if ( showUpgradedPkgs ) | 653 | if ( showUpgradedPkgs ) |
654 | { | 654 | { |
655 | if ( !package->isInstalled() || !package->getNewVersionAvailable() ) | 655 | if ( !package->isInstalled() || !package->getNewVersionAvailable() ) |
656 | continue; | 656 | continue; |
657 | } | 657 | } |
658 | 658 | ||
659 | // Apply the section filter | 659 | // Apply the section filter |
660 | if ( categoryFilterEnabled && categoryFilter != "" ) | 660 | if ( categoryFilterEnabled && categoryFilter != "" ) |
661 | { | 661 | { |
662 | if ( package->getSection() == "" || categoryFilter.find( package->getSection().lower() ) == -1 ) | 662 | if ( package->getSection() == "" || categoryFilter.find( package->getSection().lower() ) == -1 ) |
663 | continue; | 663 | continue; |
664 | } | 664 | } |
665 | 665 | ||
666 | // If the local server, only display installed packages | 666 | // If the local server, only display installed packages |
667 | if ( serverName == LOCAL_SERVER && !package->isInstalled() ) | 667 | if ( serverName == LOCAL_SERVER && !package->isInstalled() ) |
668 | continue; | 668 | continue; |
669 | 669 | ||
670 | 670 | ||
671 | QCheckListItem *item = new QCheckListItem( packagesList, package->getPackageName(), | 671 | QCheckListItem *item = new QCheckListItem( packagesList, package->getPackageName(), |
672 | QCheckListItem::CheckBox ); | 672 | QCheckListItem::CheckBox ); |
673 | 673 | ||
674 | if ( package->isInstalled() ) | 674 | if ( package->isInstalled() ) |
675 | { | 675 | { |
676 | // If a different version of package is available, show update available icon | 676 | // If a different version of package is available, show update available icon |
677 | // Otherwise, show installed icon | 677 | // Otherwise, show installed icon |
678 | if ( package->getNewVersionAvailable()) | 678 | if ( package->getNewVersionAvailable()) |
679 | { | 679 | { |
680 | 680 | ||
681 | item->setPixmap( 0, updatedIcon ); | 681 | item->setPixmap( 0, updatedIcon ); |
682 | } | 682 | } |
683 | else | 683 | else |
684 | { | 684 | { |
685 | item->setPixmap( 0, installedIcon ); | 685 | item->setPixmap( 0, installedIcon ); |
686 | } | 686 | } |
687 | } | 687 | } |
688 | else | 688 | else |
689 | { | 689 | { |
690 | item->setPixmap( 0, nullIcon ); | 690 | item->setPixmap( 0, nullIcon ); |
691 | } | 691 | } |
692 | 692 | ||
693 | packagesList->insertItem( item ); | 693 | packagesList->insertItem( item ); |
694 | } | 694 | } |
695 | 695 | ||
696 | // If the local server or the local ipkgs server disable the download button | 696 | // If the local server or the local ipkgs server disable the download button |
697 | if ( serverName == LOCAL_SERVER ) | 697 | if ( serverName == LOCAL_SERVER ) |
698 | { | 698 | { |
699 | downloadEnabled = TRUE; | 699 | downloadEnabled = TRUE; |
700 | actionUpgrade->setEnabled( FALSE ); | 700 | actionUpgrade->setEnabled( FALSE ); |
701 | } | 701 | } |
702 | else if ( serverName == LOCAL_IPKGS ) | 702 | else if ( serverName == LOCAL_IPKGS ) |
703 | { | 703 | { |
704 | downloadEnabled = FALSE; | 704 | downloadEnabled = FALSE; |
705 | actionUpgrade->setEnabled( FALSE ); | 705 | actionUpgrade->setEnabled( FALSE ); |
706 | } | 706 | } |
707 | else | 707 | else |
708 | { | 708 | { |
709 | downloadEnabled = TRUE; | 709 | downloadEnabled = TRUE; |
710 | actionUpgrade->setEnabled( TRUE ); | 710 | actionUpgrade->setEnabled( TRUE ); |
711 | } | 711 | } |
712 | enableDownload( downloadEnabled ); | 712 | enableDownload( downloadEnabled ); |
713 | 713 | ||
714 | // Display this widget once everything is done | 714 | // Display this widget once everything is done |
715 | if ( doProgress && raiseProgress ) | 715 | if ( doProgress && raiseProgress ) |
716 | { | 716 | { |
717 | stack->raiseWidget( networkPkgWindow ); | 717 | stack->raiseWidget( networkPkgWindow ); |
718 | } | 718 | } |
719 | } | 719 | } |
720 | 720 | ||
721 | void MainWindow :: searchForPackage( const QString &text ) | 721 | void MainWindow :: searchForPackage( const QString &text ) |
722 | { | 722 | { |
723 | if ( !text.isEmpty() ) | 723 | if ( !text.isEmpty() ) |
724 | { | 724 | { |
725 | // look through package list for text startng at current position | 725 | // look through package list for text startng at current position |
726 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); | 726 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); |
727 | 727 | ||
728 | if ( start == 0 ) | 728 | if ( start == 0 ) |
729 | start = (QCheckListItem *)packagesList->firstChild(); | 729 | start = (QCheckListItem *)packagesList->firstChild(); |
730 | 730 | ||
731 | for ( QCheckListItem *item = start; item != 0 ; | 731 | for ( QCheckListItem *item = start; item != 0 ; |
732 | item = (QCheckListItem *)item->nextSibling() ) | 732 | item = (QCheckListItem *)item->nextSibling() ) |
733 | { | 733 | { |
734 | if ( item->text().lower().find( text ) != -1 ) | 734 | if ( item->text().lower().find( text ) != -1 ) |
735 | { | 735 | { |
736 | packagesList->ensureItemVisible( item ); | 736 | packagesList->ensureItemVisible( item ); |
737 | packagesList->setCurrentItem( item ); | 737 | packagesList->setCurrentItem( item ); |
738 | break; | 738 | break; |
739 | } | 739 | } |
740 | } | 740 | } |
741 | } | 741 | } |
742 | } | 742 | } |
743 | 743 | ||
744 | void MainWindow :: updateServer() | 744 | void MainWindow :: updateServer() |
745 | { | 745 | { |
746 | QString serverName = serversList->currentText(); | 746 | QString serverName = serversList->currentText(); |
747 | 747 | ||
748 | // Update the current server | 748 | // Update the current server |
749 | // Display dialog | 749 | // Display dialog |
750 | 750 | ||
751 | // Disable buttons to stop silly people clicking lots on them :) | 751 | // Disable buttons to stop silly people clicking lots on them :) |
752 | 752 | ||
753 | // First, write out ipkg_conf file so that ipkg can use it | 753 | // First, write out ipkg_conf file so that ipkg can use it |
754 | mgr->writeOutIpkgConf(); | 754 | mgr->writeOutIpkgConf(); |
755 | 755 | ||
756 | Ipkg *ipkg = new Ipkg; | 756 | Ipkg *ipkg = new Ipkg; |
757 | ipkg->setOption( "update" ); | 757 | ipkg->setOption( "update" ); |
758 | 758 | ||
759 | InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Refreshing server package lists" ), | 759 | InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Refreshing server package lists" ), |
760 | tr( "Update lists" ) ); | 760 | tr( "Update lists" ) ); |
761 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); | 761 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); |
762 | reloadDocuments = FALSE; | 762 | reloadDocuments = FALSE; |
763 | stack->addWidget( dlg, 3 ); | 763 | stack->addWidget( dlg, 3 ); |
764 | stack->raiseWidget( dlg ); | 764 | stack->raiseWidget( dlg ); |
765 | 765 | ||
766 | // delete progDlg; | 766 | // delete progDlg; |
767 | } | 767 | } |
768 | 768 | ||
769 | void MainWindow :: upgradePackages() | 769 | void MainWindow :: upgradePackages() |
770 | { | 770 | { |
771 | // We're gonna do an upgrade of all packages | 771 | // We're gonna do an upgrade of all packages |
772 | // First warn user that this isn't recommended | 772 | // First warn user that this isn't recommended |
773 | // TODO - ODevice???? | 773 | // TODO - ODevice???? |
774 | QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" ); | 774 | QString text = tr( "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n" ); |
775 | QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning, | 775 | QMessageBox warn( tr( "Warning" ), text, QMessageBox::Warning, |
776 | QMessageBox::Yes, | 776 | QMessageBox::Yes, |
777 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , | 777 | QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , |
778 | 0, this ); | 778 | 0, this ); |
779 | warn.adjustSize(); | 779 | warn.adjustSize(); |
780 | 780 | ||
781 | if ( warn.exec() == QMessageBox::Yes ) | 781 | if ( warn.exec() == QMessageBox::Yes ) |
782 | { | 782 | { |
783 | // First, write out ipkg_conf file so that ipkg can use it | 783 | // First, write out ipkg_conf file so that ipkg can use it |
784 | mgr->writeOutIpkgConf(); | 784 | mgr->writeOutIpkgConf(); |
785 | 785 | ||
786 | // Now run upgrade | 786 | // Now run upgrade |
787 | Ipkg *ipkg = new Ipkg; | 787 | Ipkg *ipkg = new Ipkg; |
788 | ipkg->setOption( "upgrade" ); | 788 | ipkg->setOption( "upgrade" ); |
789 | 789 | ||
790 | InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Upgrading installed packages" ), | 790 | InstallDlgImpl *dlg = new InstallDlgImpl( ipkg, tr( "Upgrading installed packages" ), |
791 | tr ( "Upgrade" ) ); | 791 | tr ( "Upgrade" ) ); |
792 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); | 792 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); |
793 | reloadDocuments = TRUE; | 793 | reloadDocuments = TRUE; |
794 | stack->addWidget( dlg, 3 ); | 794 | stack->addWidget( dlg, 3 ); |
795 | stack->raiseWidget( dlg ); | 795 | stack->raiseWidget( dlg ); |
796 | } | 796 | } |
797 | } | 797 | } |
798 | 798 | ||
799 | void MainWindow :: downloadPackage() | 799 | void MainWindow :: downloadPackage() |
800 | { | 800 | { |
801 | bool doUpdate = true; | 801 | bool doUpdate = true; |
802 | if ( downloadEnabled ) | 802 | if ( downloadEnabled ) |
803 | { | 803 | { |
804 | // See if any packages are selected | 804 | // See if any packages are selected |
805 | bool found = false; | 805 | bool found = false; |
806 | if ( serversList->currentText() != LOCAL_SERVER ) | 806 | if ( serversList->currentText() != LOCAL_SERVER ) |
807 | { | 807 | { |
808 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 808 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
809 | item != 0 && !found; | 809 | item != 0 && !found; |
810 | item = (QCheckListItem *)item->nextSibling() ) | 810 | item = (QCheckListItem *)item->nextSibling() ) |
811 | { | 811 | { |
812 | if ( item->isOn() ) | 812 | if ( item->isOn() ) |
813 | found = true; | 813 | found = true; |
814 | } | 814 | } |
815 | } | 815 | } |
816 | 816 | ||
817 | // If user selected some packages then download the and store the locally | 817 | // If user selected some packages then download the and store the locally |
818 | // otherwise, display dialog asking user what package to download from an http server | 818 | // otherwise, display dialog asking user what package to download from an http server |
819 | // and whether to install it | 819 | // and whether to install it |
820 | if ( found ) | 820 | if ( found ) |
821 | downloadSelectedPackages(); | 821 | downloadSelectedPackages(); |
822 | else | 822 | else |
823 | downloadRemotePackage(); | 823 | downloadRemotePackage(); |
824 | 824 | ||
825 | } | 825 | } |
826 | else | 826 | else |
827 | { | 827 | { |
828 | doUpdate = false; | 828 | doUpdate = false; |
829 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 829 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
830 | item != 0 ; | 830 | item != 0 ; |
831 | item = (QCheckListItem *)item->nextSibling() ) | 831 | item = (QCheckListItem *)item->nextSibling() ) |
832 | { | 832 | { |
833 | if ( item->isOn() ) | 833 | if ( item->isOn() ) |
834 | { | 834 | { |
835 | QString name = item->text(); | 835 | QString name = item->text(); |
836 | int pos = name.find( "*" ); | 836 | int pos = name.find( "*" ); |
837 | name.truncate( pos ); | 837 | name.truncate( pos ); |
838 | 838 | ||
839 | // if (there is a (installed), remove it | 839 | // if (there is a (installed), remove it |
840 | pos = name.find( "(installed)" ); | 840 | pos = name.find( "(installed)" ); |
841 | if ( pos > 0 ) | 841 | if ( pos > 0 ) |
842 | name.truncate( pos - 1 ); | 842 | name.truncate( pos - 1 ); |
843 | 843 | ||
844 | Package *p = mgr->getServer( serversList->currentText() )->getPackage( name ); | 844 | Package *p = mgr->getServer( serversList->currentText() )->getPackage( name ); |
845 | 845 | ||
846 | QString msgtext; | 846 | QString msgtext; |
847 | msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() ); | 847 | msgtext = tr( "Are you sure you wish to delete\n%1?" ).arg( (const char *)p->getPackageName() ); |
848 | if ( QMessageBox::information( this, tr( "Are you sure?" ), | 848 | if ( QMessageBox::information( this, tr( "Are you sure?" ), |
849 | msgtext, tr( "No" ), tr( "Yes" ) ) == 1 ) | 849 | msgtext, tr( "No" ), tr( "Yes" ) ) == 1 ) |
850 | { | 850 | { |
851 | doUpdate = true; | 851 | doUpdate = true; |
852 | QFile f( p->getFilename() ); | 852 | QFile f( p->getFilename() ); |
853 | f.remove(); | 853 | f.remove(); |
854 | } | 854 | } |
855 | } | 855 | } |
856 | } | 856 | } |
857 | } | 857 | } |
858 | 858 | ||
859 | if ( doUpdate ) | 859 | if ( doUpdate ) |
860 | { | 860 | { |
861 | reloadData( 0x0 ); | 861 | reloadData( 0x0 ); |
862 | } | 862 | } |
863 | } | 863 | } |
864 | 864 | ||
865 | void MainWindow :: downloadSelectedPackages() | 865 | void MainWindow :: downloadSelectedPackages() |
866 | { | 866 | { |
867 | // First, write out ipkg_conf file so that ipkg can use it | 867 | // First, write out ipkg_conf file so that ipkg can use it |
868 | mgr->writeOutIpkgConf(); | 868 | mgr->writeOutIpkgConf(); |
869 | 869 | ||
870 | // Display dialog to user asking where to download the files to | 870 | // Display dialog to user asking where to download the files to |
871 | bool ok = FALSE; | 871 | bool ok = FALSE; |
872 | QString dir = ""; | 872 | QString dir = ""; |
873 | #ifdef QWS | 873 | #ifdef QWS |
874 | // read download directory from config file | 874 | // read download directory from config file |
875 | Config cfg( "aqpkg" ); | 875 | Config cfg( "aqpkg" ); |
876 | cfg.setGroup( "settings" ); | 876 | cfg.setGroup( "settings" ); |
877 | dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); | 877 | dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); |
878 | #endif | 878 | #endif |
879 | 879 | ||
880 | QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); | 880 | QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); |
881 | if ( ok && !text.isEmpty() ) | 881 | if ( ok && !text.isEmpty() ) |
882 | dir = text; // user entered something and pressed ok | 882 | dir = text; // user entered something and pressed ok |
883 | else | 883 | else |
884 | return; // user entered nothing or pressed cancel | 884 | return; // user entered nothing or pressed cancel |
885 | 885 | ||
886 | #ifdef QWS | 886 | #ifdef QWS |
887 | // Store download directory in config file | 887 | // Store download directory in config file |
888 | cfg.writeEntry( "downloadDir", dir ); | 888 | cfg.writeEntry( "downloadDir", dir ); |
889 | #endif | 889 | #endif |
890 | 890 | ||
891 | // Get starting directory | 891 | // Get starting directory |
892 | char initDir[PATH_MAX]; | 892 | char initDir[PATH_MAX]; |
893 | getcwd( initDir, PATH_MAX ); | 893 | getcwd( initDir, PATH_MAX ); |
894 | 894 | ||
895 | // Download each package | 895 | // Download each package |
896 | Ipkg ipkg; | 896 | Ipkg ipkg; |
897 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); | 897 | connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); |
898 | 898 | ||
899 | ipkg.setOption( "download" ); | 899 | ipkg.setOption( "download" ); |
900 | ipkg.setRuntimeDirectory( dir ); | 900 | ipkg.setRuntimeDirectory( dir ); |
901 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 901 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
902 | item != 0 ; | 902 | item != 0 ; |
903 | item = (QCheckListItem *)item->nextSibling() ) | 903 | item = (QCheckListItem *)item->nextSibling() ) |
904 | { | 904 | { |
905 | if ( item->isOn() ) | 905 | if ( item->isOn() ) |
906 | { | 906 | { |
907 | ipkg.setPackage( item->text() ); | 907 | ipkg.setPackage( item->text() ); |
908 | ipkg.runIpkg( ); | 908 | ipkg.runIpkg( ); |
909 | } | 909 | } |
910 | } | 910 | } |
911 | } | 911 | } |
912 | 912 | ||
913 | void MainWindow :: downloadRemotePackage() | 913 | void MainWindow :: downloadRemotePackage() |
914 | { | 914 | { |
915 | // Display dialog | 915 | // Display dialog |
916 | bool ok; | 916 | bool ok; |
917 | QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this ); | 917 | QString package = InputDialog::getText( tr( "Install Remote Package" ), tr( "Enter package location" ), "http://", &ok, this ); |
918 | if ( !ok || package.isEmpty() ) | 918 | if ( !ok || package.isEmpty() ) |
919 | return; | 919 | return; |
920 | // DownloadRemoteDlgImpl dlg( this, "Install", true ); | 920 | // DownloadRemoteDlgImpl dlg( this, "Install", true ); |
921 | // if ( dlg.exec() == QDialog::Rejected ) | 921 | // if ( dlg.exec() == QDialog::Rejected ) |
922 | // return; | 922 | // return; |
923 | 923 | ||
924 | // grab details from dialog | 924 | // grab details from dialog |
925 | // QString package = dlg.getPackageLocation(); | 925 | // QString package = dlg.getPackageLocation(); |
926 | 926 | ||
927 | InstallData *item = new InstallData(); | 927 | InstallData *item = new InstallData(); |
928 | item->option = "I"; | 928 | item->option = "I"; |
929 | item->packageName = package; | 929 | item->packageName = package; |
930 | QList<InstallData> workingPackages; | 930 | QList<InstallData> workingPackages; |
931 | workingPackages.setAutoDelete( TRUE ); | 931 | workingPackages.setAutoDelete( TRUE ); |
932 | workingPackages.append( item ); | 932 | workingPackages.append( item ); |
933 | 933 | ||
934 | InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) ); | 934 | InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Download" ) ); |
935 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); | 935 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); |
936 | reloadDocuments = TRUE; | 936 | reloadDocuments = TRUE; |
937 | stack->addWidget( dlg, 3 ); | 937 | stack->addWidget( dlg, 3 ); |
938 | stack->raiseWidget( dlg ); | 938 | stack->raiseWidget( dlg ); |
939 | } | 939 | } |
940 | 940 | ||
941 | 941 | ||
942 | void MainWindow :: applyChanges() | 942 | void MainWindow :: applyChanges() |
943 | { | 943 | { |
944 | stickyOption = ""; | 944 | stickyOption = ""; |
945 | 945 | ||
946 | // First, write out ipkg_conf file so that ipkg can use it | 946 | // First, write out ipkg_conf file so that ipkg can use it |
947 | mgr->writeOutIpkgConf(); | 947 | mgr->writeOutIpkgConf(); |
948 | 948 | ||
949 | // Now for each selected item | 949 | // Now for each selected item |
950 | // deal with it | 950 | // deal with it |
951 | 951 | ||
952 | QList<InstallData> workingPackages; | 952 | QList<InstallData> workingPackages; |
953 | workingPackages.setAutoDelete( TRUE ); | 953 | workingPackages.setAutoDelete( TRUE ); |
954 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); | 954 | for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); |
955 | item != 0 ; | 955 | item != 0 ; |
956 | item = (QCheckListItem *)item->nextSibling() ) | 956 | item = (QCheckListItem *)item->nextSibling() ) |
957 | { | 957 | { |
958 | if ( item->isOn() ) | 958 | if ( item->isOn() ) |
959 | { | 959 | { |
960 | InstallData *instdata = dealWithItem( item ); | 960 | InstallData *instdata = dealWithItem( item ); |
961 | if ( instdata ) | 961 | if ( instdata ) |
962 | workingPackages.append( instdata ); | 962 | workingPackages.append( instdata ); |
963 | else | 963 | else |
964 | return; | 964 | return; |
965 | } | 965 | } |
966 | } | 966 | } |
967 | 967 | ||
968 | if ( workingPackages.count() == 0 ) | 968 | if ( workingPackages.count() == 0 ) |
969 | { | 969 | { |
970 | // Nothing to do | 970 | // Nothing to do |
971 | QMessageBox::information( this, tr( "Nothing to do" ), | 971 | QMessageBox::information( this, tr( "Nothing to do" ), |
972 | tr( "No packages selected" ), tr( "OK" ) ); | 972 | tr( "No packages selected" ), tr( "OK" ) ); |
973 | 973 | ||
974 | return; | 974 | return; |
975 | } | 975 | } |
976 | 976 | ||
977 | // do the stuff | 977 | // do the stuff |
978 | InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) ); | 978 | InstallDlgImpl *dlg = new InstallDlgImpl( workingPackages, mgr, tr( "Apply changes" ) ); |
979 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); | 979 | connect( dlg, SIGNAL( reloadData( InstallDlgImpl * ) ), this, SLOT( reloadData( InstallDlgImpl * ) ) ); |
980 | reloadDocuments = TRUE; | 980 | reloadDocuments = TRUE; |
981 | stack->addWidget( dlg, 3 ); | 981 | stack->addWidget( dlg, 3 ); |
982 | stack->raiseWidget( dlg ); | 982 | stack->raiseWidget( dlg ); |
983 | } | 983 | } |
984 | 984 | ||
985 | // decide what to do - either remove, upgrade or install | 985 | // decide what to do - either remove, upgrade or install |
986 | // Current rules: | 986 | // Current rules: |
987 | // If not installed - install | 987 | // If not installed - install |
988 | // If installed and different version available - upgrade | 988 | // If installed and different version available - upgrade |
989 | // If installed and version up to date - remove | 989 | // If installed and version up to date - remove |
990 | InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) | 990 | InstallData *MainWindow :: dealWithItem( QCheckListItem *item ) |
991 | { | 991 | { |
992 | QString name = item->text(); | 992 | QString name = item->text(); |
993 | 993 | ||
994 | // Get package | 994 | // Get package |
995 | Server *s = mgr->getServer( serversList->currentText() ); | 995 | Server *s = mgr->getServer( serversList->currentText() ); |
996 | Package *p = s->getPackage( name ); | 996 | Package *p = s->getPackage( name ); |
997 | 997 | ||
998 | // If the package has a filename then it is a local file | 998 | // If the package has a filename then it is a local file |
999 | if ( p->isPackageStoredLocally() ) | 999 | if ( p->isPackageStoredLocally() ) |
1000 | name = p->getFilename(); | 1000 | name = p->getFilename(); |
1001 | 1001 | ||
1002 | QString option; | 1002 | QString option; |
1003 | QString dest = "root"; | 1003 | QString dest = "root"; |
1004 | if ( !p->isInstalled() ) | 1004 | if ( !p->isInstalled() ) |
1005 | { | 1005 | { |
1006 | InstallData *newitem = new InstallData(); | 1006 | InstallData *newitem = new InstallData(); |
1007 | newitem->option = "I"; | 1007 | newitem->option = "I"; |
1008 | newitem->packageName = name; | 1008 | newitem->packageName = name; |
1009 | return newitem; | 1009 | return newitem; |
1010 | } | 1010 | } |
1011 | else | 1011 | else |
1012 | { | 1012 | { |
1013 | InstallData *newitem = new InstallData(); | 1013 | InstallData *newitem = new InstallData(); |
1014 | newitem->option = "D"; | 1014 | newitem->option = "D"; |
1015 | if ( !p->isPackageStoredLocally() ) | 1015 | if ( !p->isPackageStoredLocally() ) |
1016 | newitem->packageName = p->getInstalledPackageName(); | 1016 | newitem->packageName = p->getInstalledPackageName(); |
1017 | else | 1017 | else |
1018 | newitem->packageName = name; | 1018 | newitem->packageName = name; |
1019 | 1019 | ||
1020 | if ( p->getInstalledTo() ) | 1020 | if ( p->getInstalledTo() ) |
1021 | { | 1021 | { |
1022 | newitem->destination = p->getInstalledTo(); | 1022 | newitem->destination = p->getInstalledTo(); |
1023 | } | 1023 | } |
1024 | else | 1024 | else |
1025 | { | 1025 | { |
1026 | newitem->destination = p->getLocalPackage()->getInstalledTo(); | 1026 | newitem->destination = p->getLocalPackage()->getInstalledTo(); |
1027 | } | 1027 | } |
1028 | 1028 | ||
1029 | // Now see if version is newer or not | 1029 | // Now see if version is newer or not |
1030 | int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); | 1030 | int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); |
1031 | 1031 | ||
1032 | // If the version requested is older and user selected a local ipk file, then reinstall the file | 1032 | // If the version requested is older and user selected a local ipk file, then reinstall the file |
1033 | if ( p->isPackageStoredLocally() && val == -1 ) | 1033 | if ( p->isPackageStoredLocally() && val == -1 ) |
1034 | val = 0; | 1034 | val = 0; |
1035 | 1035 | ||
1036 | if ( val == -2 ) | 1036 | if ( val == -2 ) |
1037 | { | 1037 | { |
1038 | // Error - should handle | 1038 | // Error - should handle |
1039 | } | 1039 | } |
1040 | else if ( val == -1 ) | 1040 | else if ( val == -1 ) |
1041 | { | 1041 | { |
1042 | // Version available is older - remove only | 1042 | // Version available is older - remove only |
1043 | newitem->option = "D"; | 1043 | newitem->option = "D"; |
1044 | } | 1044 | } |
1045 | else | 1045 | else |
1046 | { | 1046 | { |
1047 | QString caption; | 1047 | QString caption; |
1048 | QString text; | 1048 | QString text; |
1049 | QString secondButton; | 1049 | QString secondButton; |
1050 | QString secondOption; | 1050 | QString secondOption; |
1051 | if ( val == 0 ) | 1051 | if ( val == 0 ) |
1052 | { | 1052 | { |
1053 | // Version available is the same - option to remove or reinstall | 1053 | // Version available is the same - option to remove or reinstall |
1054 | caption = tr( "Do you wish to remove or reinstall\n%1?" ); | 1054 | caption = tr( "Do you wish to remove or reinstall\n%1?" ); |
1055 | text = tr( "Remove or ReInstall" ); | 1055 | text = tr( "Remove or ReInstall" ); |
1056 | secondButton = tr( "ReInstall" ); | 1056 | secondButton = tr( "ReInstall" ); |
1057 | secondOption = tr( "R" ); | 1057 | secondOption = "R"; // Internal action code, do not translate |
1058 | } | 1058 | } |
1059 | else if ( val == 1 ) | 1059 | else if ( val == 1 ) |
1060 | { | 1060 | { |
1061 | // Version available is newer - option to remove or upgrade | 1061 | // Version available is newer - option to remove or upgrade |
1062 | caption = tr( "Do you wish to remove or upgrade\n%1?" ); | 1062 | caption = tr( "Do you wish to remove or upgrade\n%1?" ); |
1063 | text = tr( "Remove or Upgrade" ); | 1063 | text = tr( "Remove or Upgrade" ); |
1064 | secondButton = tr( "Upgrade" ); | 1064 | secondButton = tr( "Upgrade" ); |
1065 | secondOption = tr( "U" ); | 1065 | secondOption = "U"; // Internal action code, do not translate |
1066 | } | 1066 | } |
1067 | 1067 | ||
1068 | // Sticky option not implemented yet, but will eventually allow | 1068 | // Sticky option not implemented yet, but will eventually allow |
1069 | // the user to say something like 'remove all' | 1069 | // the user to say something like 'remove all' |
1070 | if ( stickyOption == "" ) | 1070 | if ( stickyOption == "" ) |
1071 | { | 1071 | { |
1072 | QString msgtext; | 1072 | QString msgtext; |
1073 | msgtext = caption.arg( ( const char * )name ); | 1073 | msgtext = caption.arg( ( const char * )name ); |
1074 | // switch( QMessageBox::information( this, text, | ||
1075 | // msgtext, tr( "Remove" ), secondButton ) ) | ||
1076 | QuestionDlg dlg( text, msgtext, secondButton ); | 1074 | QuestionDlg dlg( text, msgtext, secondButton ); |
1077 | switch( dlg.exec() ) | 1075 | switch( dlg.exec() ) |
1078 | { | 1076 | { |
1079 | case 0: // Cancel | 1077 | case 0: // Cancel |
1080 | delete newitem; | 1078 | delete newitem; |
1081 | return 0x0; | 1079 | return 0x0; |
1082 | break; | 1080 | break; |
1083 | case 1: // Remove | 1081 | case 1: // Remove |
1084 | newitem->option = "D"; | 1082 | newitem->option = "D"; |
1085 | break; | 1083 | break; |
1086 | case 2: // Reinstall or Upgrade | 1084 | case 2: // Reinstall or Upgrade |
1087 | newitem->option = secondOption; | 1085 | newitem->option = secondOption; |
1088 | break; | 1086 | break; |
1089 | } | 1087 | } |
1090 | } | 1088 | } |
1091 | else | 1089 | else |
1092 | { | 1090 | { |
1093 | // newitem->option = stickyOption; | 1091 | // newitem->option = stickyOption; |
1094 | } | 1092 | } |
1095 | } | 1093 | } |
1096 | 1094 | ||
1097 | 1095 | ||
1098 | // Check if we are reinstalling the same version | 1096 | // Check if we are reinstalling the same version |
1099 | if ( newitem->option != "R" ) | 1097 | if ( newitem->option != "R" ) |
1100 | newitem->recreateLinks = true; | 1098 | newitem->recreateLinks = true; |
1101 | else | 1099 | else |
1102 | newitem->recreateLinks = false; | 1100 | newitem->recreateLinks = false; |
1103 | 1101 | ||
1104 | // User hit cancel (on dlg - assume remove) | 1102 | // User hit cancel (on dlg - assume remove) |
1105 | return newitem; | 1103 | return newitem; |
1106 | } | 1104 | } |
1107 | } | 1105 | } |
1108 | 1106 | ||
1109 | void MainWindow :: reloadData( InstallDlgImpl *dlg ) | 1107 | void MainWindow :: reloadData( InstallDlgImpl *dlg ) |
1110 | { | 1108 | { |
1111 | stack->raiseWidget( progressWindow ); | 1109 | stack->raiseWidget( progressWindow ); |
1112 | 1110 | ||
1113 | if ( dlg ) | 1111 | if ( dlg ) |
1114 | { | 1112 | { |
1115 | dlg->close(); | 1113 | dlg->close(); |
1116 | delete dlg; | 1114 | delete dlg; |
1117 | } | 1115 | } |
1118 | 1116 | ||
1119 | mgr->reloadServerData(); | 1117 | mgr->reloadServerData(); |
1120 | serverSelected( -1, FALSE ); | 1118 | serverSelected( -1, FALSE ); |
1121 | 1119 | ||
1122 | #ifdef QWS | 1120 | #ifdef QWS |
1123 | if ( reloadDocuments ) | 1121 | if ( reloadDocuments ) |
1124 | { | 1122 | { |
1125 | m_status->setText( tr( "Updating Launcher..." ) ); | 1123 | m_status->setText( tr( "Updating Launcher..." ) ); |
1126 | 1124 | ||
1127 | // Finally let the main system update itself | 1125 | // Finally let the main system update itself |
1128 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 1126 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
1129 | QString lf = QString::null; | 1127 | QString lf = QString::null; |
1130 | e << lf; | 1128 | e << lf; |
1131 | } | 1129 | } |
1132 | #endif | 1130 | #endif |
1133 | 1131 | ||
1134 | stack->raiseWidget( networkPkgWindow ); | 1132 | stack->raiseWidget( networkPkgWindow ); |
1135 | } | 1133 | } |
1136 | 1134 | ||
1137 | void MainWindow :: letterPushed( QString t ) | 1135 | void MainWindow :: letterPushed( QString t ) |
1138 | { | 1136 | { |
1139 | QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); | 1137 | QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); |
1140 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); | 1138 | QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); |
1141 | if ( packagesList->firstChild() == 0 ) | 1139 | if ( packagesList->firstChild() == 0 ) |
1142 | return; | 1140 | return; |
1143 | 1141 | ||
1144 | QCheckListItem *item; | 1142 | QCheckListItem *item; |
1145 | if ( start == 0 ) | 1143 | if ( start == 0 ) |
1146 | { | 1144 | { |
1147 | item = (QCheckListItem *)packagesList->firstChild(); | 1145 | item = (QCheckListItem *)packagesList->firstChild(); |
1148 | start = top; | 1146 | start = top; |
1149 | } | 1147 | } |
1150 | else | 1148 | else |
1151 | item = (QCheckListItem *)start->nextSibling(); | 1149 | item = (QCheckListItem *)start->nextSibling(); |
1152 | 1150 | ||
1153 | if ( item == 0 ) | 1151 | if ( item == 0 ) |
1154 | item = (QCheckListItem *)packagesList->firstChild(); | 1152 | item = (QCheckListItem *)packagesList->firstChild(); |
1155 | do | 1153 | do |
1156 | { | 1154 | { |
1157 | if ( item->text().lower().startsWith( t.lower() ) ) | 1155 | if ( item->text().lower().startsWith( t.lower() ) ) |
1158 | { | 1156 | { |
1159 | packagesList->setSelected( item, true ); | 1157 | packagesList->setSelected( item, true ); |
1160 | packagesList->ensureItemVisible( item ); | 1158 | packagesList->ensureItemVisible( item ); |
1161 | break; | 1159 | break; |
1162 | } | 1160 | } |
1163 | 1161 | ||
1164 | item = (QCheckListItem *)item->nextSibling(); | 1162 | item = (QCheckListItem *)item->nextSibling(); |
1165 | if ( !item ) | 1163 | if ( !item ) |
1166 | item = (QCheckListItem *)packagesList->firstChild(); | 1164 | item = (QCheckListItem *)packagesList->firstChild(); |
1167 | } while ( item != start); | 1165 | } while ( item != start); |
1168 | } | 1166 | } |
1169 | 1167 | ||
1170 | void MainWindow :: slotDisplayPackage( QListViewItem *item ) | 1168 | void MainWindow :: slotDisplayPackage( QListViewItem *item ) |
1171 | { | 1169 | { |
1172 | QString itemstr( ((QCheckListItem*)item)->text() ); | 1170 | QString itemstr( ((QCheckListItem*)item)->text() ); |
1173 | PackageWindow *p = new PackageWindow( mgr->getServer( serversList->currentText() )->getPackage( itemstr ) ); | 1171 | PackageWindow *p = new PackageWindow( mgr->getServer( serversList->currentText() )->getPackage( itemstr ) ); |
1174 | p->showMaximized(); | 1172 | p->showMaximized(); |
1175 | } | 1173 | } |
1176 | 1174 | ||
1177 | QuestionDlg::QuestionDlg( const QString &caption, const QString &text, const QString &secondbtn ) | 1175 | QuestionDlg::QuestionDlg( const QString &caption, const QString &text, const QString &secondbtn ) |
1178 | : QWidget( 0x0, 0x0, WType_Modal | WType_TopLevel | WStyle_Dialog ) | 1176 | : QWidget( 0x0, 0x0, WType_Modal | WType_TopLevel | WStyle_Dialog ) |
1179 | { | 1177 | { |
1180 | setCaption( caption ); | 1178 | setCaption( caption ); |
1181 | resize( 175, 100 ); | 1179 | resize( 175, 100 ); |
1182 | 1180 | ||
1183 | QGridLayout *layout = new QGridLayout( this ); | 1181 | QGridLayout *layout = new QGridLayout( this ); |
1184 | 1182 | ||
1185 | QLabel *l = new QLabel( text, this ); | 1183 | QLabel *l = new QLabel( text, this ); |
1186 | l->setAlignment( AlignCenter | WordBreak ); | 1184 | l->setAlignment( AlignCenter | WordBreak ); |
1187 | layout->addMultiCellWidget( l, 0, 0, 0, 1 ); | 1185 | layout->addMultiCellWidget( l, 0, 0, 0, 1 ); |
1188 | 1186 | ||
1189 | btn1 = new QPushButton( tr( "Remove" ), this ); | 1187 | btn1 = new QPushButton( tr( "Remove" ), this ); |
1190 | connect( btn1, SIGNAL(clicked()), this, SLOT(slotButtonPressed()) ); | 1188 | connect( btn1, SIGNAL(clicked()), this, SLOT(slotButtonPressed()) ); |
1191 | layout->addWidget( btn1, 1, 0 ); | 1189 | layout->addWidget( btn1, 1, 0 ); |
1192 | 1190 | ||
1193 | btn2 = new QPushButton( secondbtn, this ); | 1191 | btn2 = new QPushButton( secondbtn, this ); |
1194 | connect( btn2, SIGNAL(clicked()), this, SLOT(slotButtonPressed()) ); | 1192 | connect( btn2, SIGNAL(clicked()), this, SLOT(slotButtonPressed()) ); |
1195 | layout->addWidget( btn2, 1, 1 ); | 1193 | layout->addWidget( btn2, 1, 1 ); |
1196 | 1194 | ||
1197 | executing = FALSE; | 1195 | executing = FALSE; |
1198 | } | 1196 | } |
1199 | 1197 | ||
1200 | int QuestionDlg::exec() | 1198 | int QuestionDlg::exec() |
1201 | { | 1199 | { |
1202 | show(); | 1200 | show(); |
1203 | 1201 | ||
1204 | if ( !executing ) | 1202 | if ( !executing ) |
1205 | { | 1203 | { |
1206 | executing = TRUE; | 1204 | executing = TRUE; |
1207 | qApp->enter_loop(); | 1205 | qApp->enter_loop(); |
1208 | } | 1206 | } |
1209 | 1207 | ||
1210 | return buttonpressed; | 1208 | return buttonpressed; |
1211 | } | 1209 | } |
1212 | 1210 | ||
1213 | void QuestionDlg::slotButtonPressed() | 1211 | void QuestionDlg::slotButtonPressed() |
1214 | { | 1212 | { |
1215 | if ( sender() == btn1 ) | 1213 | if ( sender() == btn1 ) |
1216 | buttonpressed = 1; | 1214 | buttonpressed = 1; |
1217 | else if ( sender() == btn2 ) | 1215 | else if ( sender() == btn2 ) |
1218 | buttonpressed = 2; | 1216 | buttonpressed = 2; |
1219 | else | 1217 | else |
1220 | buttonpressed = 0; | 1218 | buttonpressed = 0; |
1221 | 1219 | ||
1222 | qApp->exit_loop(); | 1220 | qApp->exit_loop(); |
1223 | } | 1221 | } |
diff --git a/noncore/settings/aqpkg/mem.cpp b/noncore/settings/aqpkg/mem.cpp index 5f32a26..4c6117b 100644 --- a/noncore/settings/aqpkg/mem.cpp +++ b/noncore/settings/aqpkg/mem.cpp | |||
@@ -1,110 +1,110 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | 3 | ||
4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> | 4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> |
5 | .=l. Dan Williams <drw@handhelds.org> | 5 | .=l. Dan Williams <drw@handhelds.org> |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This file is free software; you can | 7 | _;:, .> :=|. This file is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
19 | ..}^=.= = ; Public License for more details. | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | 20 | ++= -. .` .: |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | : = ...= . :.=- You should have received a copy of the GNU |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include <stdio.h> | 30 | #include <stdio.h> |
31 | #include <list> | 31 | #include <list> |
32 | using namespace std; | 32 | using namespace std; |
33 | 33 | ||
34 | #define __MEMFILE_C | 34 | #define __MEMFILE_C |
35 | #include "global.h" | 35 | #include "global.h" |
36 | 36 | ||
37 | #ifdef _DEBUG | 37 | #ifdef _DEBUG |
38 | 38 | ||
39 | void __cdecl *operator new( unsigned int size, const char *file, int line ) | 39 | void __cdecl *operator new( unsigned int size, const char *file, int line ) |
40 | { | 40 | { |
41 | void *ptr = (void *)malloc(size); | 41 | void *ptr = (void *)malloc(size); |
42 | AddTrack((long)ptr, size, file, line); | 42 | AddTrack((long)ptr, size, file, line); |
43 | return(ptr); | 43 | return(ptr); |
44 | } | 44 | } |
45 | 45 | ||
46 | void operator delete(void *p) | 46 | void operator delete(void *p) |
47 | { | 47 | { |
48 | RemoveTrack((long)p); | 48 | RemoveTrack((long)p); |
49 | free(p); | 49 | free(p); |
50 | } | 50 | } |
51 | 51 | ||
52 | #endif | 52 | #endif |
53 | 53 | ||
54 | 54 | ||
55 | typedef struct { | 55 | typedef struct { |
56 | longaddress; | 56 | longaddress; |
57 | longsize; | 57 | longsize; |
58 | charfile[64]; | 58 | charfile[64]; |
59 | longline; | 59 | longline; |
60 | } ALLOC_INFO; | 60 | } ALLOC_INFO; |
61 | 61 | ||
62 | typedef list<ALLOC_INFO*> AllocList; | 62 | typedef list<ALLOC_INFO*> AllocList; |
63 | 63 | ||
64 | AllocList allocList; | 64 | AllocList allocList; |
65 | 65 | ||
66 | 66 | ||
67 | 67 | ||
68 | void AddTrack(long addr, long asize, const char *fname, long lnum) | 68 | void AddTrack(long addr, long asize, const char *fname, long lnum) |
69 | { | 69 | { |
70 | ALLOC_INFO *info; | 70 | ALLOC_INFO *info; |
71 | 71 | ||
72 | 72 | ||
73 | info = (ALLOC_INFO *)malloc(sizeof( ALLOC_INFO )); | 73 | info = (ALLOC_INFO *)malloc(sizeof( ALLOC_INFO )); |
74 | info->address = addr; | 74 | info->address = addr; |
75 | strncpy(info->file, fname, 63); | 75 | strncpy(info->file, fname, 63); |
76 | info->line = lnum; | 76 | info->line = lnum; |
77 | info->size = asize; | 77 | info->size = asize; |
78 | allocList.insert(allocList.begin(), info); | 78 | allocList.insert(allocList.begin(), info); |
79 | }; | 79 | }; |
80 | 80 | ||
81 | void RemoveTrack(long addr) | 81 | void RemoveTrack(long addr) |
82 | { | 82 | { |
83 | AllocList::iterator i; | 83 | AllocList::iterator i; |
84 | 84 | ||
85 | bool found = false; | 85 | bool found = false; |
86 | for(i = allocList.begin(); i != allocList.end(); i++) | 86 | for(i = allocList.begin(); i != allocList.end(); i++) |
87 | { | 87 | { |
88 | if((*i)->address == addr) | 88 | if((*i)->address == addr) |
89 | { | 89 | { |
90 | allocList.remove((*i)); | 90 | allocList.remove((*i)); |
91 | found = true; | 91 | found = true; |
92 | break; | 92 | break; |
93 | } | 93 | } |
94 | } | 94 | } |
95 | } | 95 | } |
96 | 96 | ||
97 | void DumpUnfreed() | 97 | void DumpUnfreed() |
98 | { | 98 | { |
99 | AllocList::iterator i; | 99 | AllocList::iterator i; |
100 | long totalSize = 0; | 100 | long totalSize = 0; |
101 | char buf[1024]; | 101 | char buf[1024]; |
102 | 102 | // Debug output, okay to leave untranslated | |
103 | for(i = allocList.begin(); i != allocList.end(); i++) { | 103 | for(i = allocList.begin(); i != allocList.end(); i++) { |
104 | sprintf(buf, "%-15s: LINE %ld, ADDRESS %ld %ld unfreed", | 104 | sprintf(buf, "%-15s: LINE %ld, ADDRESS %ld %ld unfreed", |
105 | (*i)->file, (*i)->line, (*i)->address, (*i)->size); | 105 | (*i)->file, (*i)->line, (*i)->address, (*i)->size); |
106 | totalSize += (*i)->size; | 106 | totalSize += (*i)->size; |
107 | } | 107 | } |
108 | sprintf(buf, "-----------------------------------------------------------\n"); | 108 | sprintf(buf, "-----------------------------------------------------------\n"); |
109 | sprintf(buf, "Total Unfreed: %ld bytes\n", totalSize); | 109 | sprintf(buf, "Total Unfreed: %ld bytes\n", totalSize); |
110 | }; | 110 | }; |
diff --git a/noncore/settings/aqpkg/package.cpp b/noncore/settings/aqpkg/package.cpp index 4c27c65..adda832 100644 --- a/noncore/settings/aqpkg/package.cpp +++ b/noncore/settings/aqpkg/package.cpp | |||
@@ -1,157 +1,162 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | 3 | ||
4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> | 4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> |
5 | .=l. Dan Williams <drw@handhelds.org> | 5 | .=l. Dan Williams <drw@handhelds.org> |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This file is free software; you can | 7 | _;:, .> :=|. This file is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
19 | ..}^=.= = ; Public License for more details. | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | 20 | ++= -. .` .: |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | : = ...= . :.=- You should have received a copy of the GNU |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "package.h" | 30 | #include "package.h" |
31 | #include "global.h" | 31 | #include "global.h" |
32 | 32 | ||
33 | #include <qobject.h> | ||
34 | |||
33 | Package::Package( QString &name ) | 35 | Package::Package( QString &name ) |
34 | { | 36 | { |
35 | packageName = name; | 37 | packageName = name; |
36 | 38 | ||
37 | version = "N/A"; | 39 | QString tempstr = QObject::tr( "N/A" ); |
38 | description = "N/A"; | 40 | version = tempstr; |
39 | packageSize = "N/A"; | 41 | description = tempstr; |
40 | section = "N/A"; | 42 | packageSize = tempstr; |
41 | 43 | section = tempstr; | |
44 | |||
42 | localPackage = 0; | 45 | localPackage = 0; |
43 | installed = false; | 46 | installed = false; |
44 | packageStoredLocally = false; | 47 | packageStoredLocally = false; |
45 | installedToRoot = false; | 48 | installedToRoot = false; |
46 | installed = false; | 49 | installed = false; |
47 | installedTo = 0; | 50 | installedTo = 0; |
48 | } | 51 | } |
49 | 52 | ||
50 | Package::Package( char *name ) | 53 | Package::Package( char *name ) |
51 | { | 54 | { |
52 | packageName = name; | 55 | packageName = name; |
53 | 56 | ||
54 | version = "N/A"; | 57 | QString tempstr = QObject::tr( "N/A" ); |
55 | description = "N/A"; | 58 | version = tempstr; |
56 | packageSize = "N/A"; | 59 | description = tempstr; |
57 | section = "N/A"; | 60 | packageSize = tempstr; |
58 | 61 | section = tempstr; | |
62 | |||
59 | localPackage = 0; | 63 | localPackage = 0; |
60 | installed = false; | 64 | installed = false; |
61 | packageStoredLocally = false; | 65 | packageStoredLocally = false; |
62 | installedToRoot = false; | 66 | installedToRoot = false; |
63 | installed = false; | 67 | installed = false; |
64 | installedTo = 0; | 68 | installedTo = 0; |
65 | differentVersionAvailable = false; | 69 | differentVersionAvailable = false; |
66 | } | 70 | } |
67 | 71 | ||
68 | Package::~Package() | 72 | Package::~Package() |
69 | { | 73 | { |
70 | } | 74 | } |
71 | 75 | ||
72 | QString Package :: toString() | 76 | QString Package :: toString() |
73 | { | 77 | { |
74 | QString ret = "Package - " + getPackageName() + | 78 | QString ret = QObject::tr( "Package - %1\n version - %2" ). |
75 | "\n version - " + getVersion(); | 79 | arg( getPackageName() ). |
80 | arg( getVersion() ); | ||
76 | 81 | ||
77 | if ( localPackage ) | 82 | if ( localPackage ) |
78 | ret += "\n inst version - " + localPackage->getVersion(); | 83 | ret.append( QObject::tr( "\n inst version - %1" ).arg( localPackage->getVersion() ) ); |
79 | 84 | ||
80 | 85 | ||
81 | return ret; | 86 | return ret; |
82 | } | 87 | } |
83 | 88 | ||
84 | void Package :: setStatus( const QString &s ) | 89 | void Package :: setStatus( const QString &s ) |
85 | { | 90 | { |
86 | QString state_status; | 91 | QString state_status; |
87 | int two, three; | 92 | int two, three; |
88 | 93 | ||
89 | status = s.simplifyWhiteSpace( ); | 94 | status = s.simplifyWhiteSpace( ); |
90 | 95 | ||
91 | two = status.find( " " ); // find second column | 96 | two = status.find( " " ); // find second column |
92 | three = status.find( " ", two + 1 ); // find third column | 97 | three = status.find( " ", two + 1 ); // find third column |
93 | 98 | ||
94 | state_status = status.mid( three ).stripWhiteSpace( ); | 99 | state_status = status.mid( three ).stripWhiteSpace( ); |
95 | 100 | ||
96 | if ( state_status == "installed" ) | 101 | if ( state_status == "installed" ) |
97 | installed = true; | 102 | installed = true; |
98 | } | 103 | } |
99 | 104 | ||
100 | void Package :: setLocalPackage( Package *p ) | 105 | void Package :: setLocalPackage( Package *p ) |
101 | { | 106 | { |
102 | localPackage = p; | 107 | localPackage = p; |
103 | 108 | ||
104 | if ( localPackage ) | 109 | if ( localPackage ) |
105 | if ( localPackage->getVersion() < getVersion() && !installed ) | 110 | if ( localPackage->getVersion() < getVersion() && !installed ) |
106 | differentVersionAvailable = true; | 111 | differentVersionAvailable = true; |
107 | else | 112 | else |
108 | differentVersionAvailable = false; | 113 | differentVersionAvailable = false; |
109 | } | 114 | } |
110 | 115 | ||
111 | void Package :: setVersion( const QString &v ) | 116 | void Package :: setVersion( const QString &v ) |
112 | { | 117 | { |
113 | version = v; | 118 | version = v; |
114 | 119 | ||
115 | if ( localPackage ) | 120 | if ( localPackage ) |
116 | if ( localPackage->getVersion() < getVersion() && !installed ) | 121 | if ( localPackage->getVersion() < getVersion() && !installed ) |
117 | differentVersionAvailable = true; | 122 | differentVersionAvailable = true; |
118 | else | 123 | else |
119 | differentVersionAvailable = false; | 124 | differentVersionAvailable = false; |
120 | } | 125 | } |
121 | 126 | ||
122 | void Package :: setPackageName( const QString &name ) | 127 | void Package :: setPackageName( const QString &name ) |
123 | { | 128 | { |
124 | packageName = name; | 129 | packageName = name; |
125 | } | 130 | } |
126 | 131 | ||
127 | void Package :: setDescription( const QString &d ) | 132 | void Package :: setDescription( const QString &d ) |
128 | { | 133 | { |
129 | description = d; | 134 | description = d; |
130 | } | 135 | } |
131 | 136 | ||
132 | void Package :: setFilename( const QString &f ) | 137 | void Package :: setFilename( const QString &f ) |
133 | { | 138 | { |
134 | filename = f; | 139 | filename = f; |
135 | } | 140 | } |
136 | 141 | ||
137 | 142 | ||
138 | QString Package :: getInstalledVersion() | 143 | QString Package :: getInstalledVersion() |
139 | { | 144 | { |
140 | if ( localPackage ) | 145 | if ( localPackage ) |
141 | return localPackage->getVersion(); | 146 | return localPackage->getVersion(); |
142 | else | 147 | else |
143 | return getVersion(); | 148 | return getVersion(); |
144 | } | 149 | } |
145 | 150 | ||
146 | QString Package :: getInstalledPackageName() | 151 | QString Package :: getInstalledPackageName() |
147 | { | 152 | { |
148 | if ( localPackage ) | 153 | if ( localPackage ) |
149 | return localPackage->getPackageName(); | 154 | return localPackage->getPackageName(); |
150 | else | 155 | else |
151 | return getPackageName(); | 156 | return getPackageName(); |
152 | } | 157 | } |
153 | 158 | ||
154 | bool Package :: isInstalled() | 159 | bool Package :: isInstalled() |
155 | { | 160 | { |
156 | return installed || ( localPackage && localPackage->isInstalled() ); | 161 | return installed || ( localPackage && localPackage->isInstalled() ); |
157 | } | 162 | } |
diff --git a/noncore/settings/aqpkg/version.cpp b/noncore/settings/aqpkg/version.cpp index e836da1..59e6f3f 100644 --- a/noncore/settings/aqpkg/version.cpp +++ b/noncore/settings/aqpkg/version.cpp | |||
@@ -1,214 +1,219 @@ | |||
1 | /* | 1 | /* |
2 | * libdpkg - Debian packaging suite library routines | 2 | * libdpkg - Debian packaging suite library routines |
3 | * vercmp.c - comparison of version numbers | 3 | * vercmp.c - comparison of version numbers |
4 | * | 4 | * |
5 | * Copyright (C) 1995 Ian Jackson <iwj10@cus.cam.ac.uk> | 5 | * Copyright (C) 1995 Ian Jackson <iwj10@cus.cam.ac.uk> |
6 | * | 6 | * |
7 | * This is free software; you can redistribute it and/or modify | 7 | * This is free software; you can redistribute it and/or modify |
8 | * it under the terms of the GNU General Public License as | 8 | * it under the terms of the GNU General Public License as |
9 | * published by the Free Software Foundation; either version 2, | 9 | * published by the Free Software Foundation; either version 2, |
10 | * or (at your option) any later version. | 10 | * or (at your option) any later version. |
11 | * | 11 | * |
12 | * This is distributed in the hope that it will be useful, but | 12 | * This is distributed in the hope that it will be useful, but |
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 13 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15 | * GNU General Public License for more details. | 15 | * GNU General Public License for more details. |
16 | * | 16 | * |
17 | * You should have received a copy of the GNU General Public | 17 | * You should have received a copy of the GNU General Public |
18 | * License along with dpkg; if not, write to the Free Software | 18 | * License along with dpkg; if not, write to the Free Software |
19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. | 19 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
20 | */ | 20 | */ |
21 | #include <stdio.h> | 21 | #include <stdio.h> |
22 | #include <stdlib.h> | 22 | #include <stdlib.h> |
23 | #include <ctype.h> | 23 | #include <ctype.h> |
24 | #include <string.h> | 24 | #include <string.h> |
25 | 25 | ||
26 | # define _(Text) Text | 26 | #include <qobject.h> |
27 | |||
28 | //# define _(Text) Text | ||
27 | 29 | ||
28 | class versionrevision | 30 | class versionrevision |
29 | { | 31 | { |
30 | public: | 32 | public: |
31 | versionrevision() | 33 | versionrevision() |
32 | { | 34 | { |
33 | version = 0; | 35 | version = 0; |
34 | } | 36 | } |
35 | 37 | ||
36 | ~versionrevision() | 38 | ~versionrevision() |
37 | { | 39 | { |
38 | if ( version ) | 40 | if ( version ) |
39 | delete version; | 41 | delete version; |
40 | } | 42 | } |
41 | 43 | ||
42 | void setVersion( const char *str ) | 44 | void setVersion( const char *str ) |
43 | { | 45 | { |
44 | version = new char[(strlen(str)+1)]; | 46 | version = new char[(strlen(str)+1)]; |
45 | strcpy( version, str ); | 47 | strcpy( version, str ); |
46 | } | 48 | } |
47 | 49 | ||
48 | unsigned long epoch; | 50 | unsigned long epoch; |
49 | char *version; | 51 | char *version; |
50 | const char *revision; | 52 | const char *revision; |
51 | const char *familiar_revision; | 53 | const char *familiar_revision; |
52 | }; | 54 | }; |
53 | 55 | ||
54 | static int verrevcmp(const char *val, const char *ref) | 56 | static int verrevcmp(const char *val, const char *ref) |
55 | { | 57 | { |
56 | int vc, rc; | 58 | int vc, rc; |
57 | long vl, rl; | 59 | long vl, rl; |
58 | const char *vp, *rp; | 60 | const char *vp, *rp; |
59 | 61 | ||
60 | if (!val) val= ""; | 62 | if (!val) val= ""; |
61 | if (!ref) ref= ""; | 63 | if (!ref) ref= ""; |
62 | for (;;) { | 64 | for (;;) { |
63 | vp= val; while (*vp && !isdigit(*vp)) vp++; | 65 | vp= val; while (*vp && !isdigit(*vp)) vp++; |
64 | rp= ref; while (*rp && !isdigit(*rp)) rp++; | 66 | rp= ref; while (*rp && !isdigit(*rp)) rp++; |
65 | for (;;) { | 67 | for (;;) { |
66 | vc= val == vp ? 0 : *val++; | 68 | vc= val == vp ? 0 : *val++; |
67 | rc= ref == rp ? 0 : *ref++; | 69 | rc= ref == rp ? 0 : *ref++; |
68 | if (!rc && !vc) break; | 70 | if (!rc && !vc) break; |
69 | if (vc && !isalpha(vc)) vc += 256; /* assumes ASCII character set */ | 71 | if (vc && !isalpha(vc)) vc += 256; /* assumes ASCII character set */ |
70 | if (rc && !isalpha(rc)) rc += 256; | 72 | if (rc && !isalpha(rc)) rc += 256; |
71 | if (vc != rc) return vc - rc; | 73 | if (vc != rc) return vc - rc; |
72 | } | 74 | } |
73 | val= vp; | 75 | val= vp; |
74 | ref= rp; | 76 | ref= rp; |
75 | vl=0; if (isdigit(*vp)) vl= strtol(val,(char**)&val,10); | 77 | vl=0; if (isdigit(*vp)) vl= strtol(val,(char**)&val,10); |
76 | rl=0; if (isdigit(*rp)) rl= strtol(ref,(char**)&ref,10); | 78 | rl=0; if (isdigit(*rp)) rl= strtol(ref,(char**)&ref,10); |
77 | if (vl != rl) return vl - rl; | 79 | if (vl != rl) return vl - rl; |
78 | if (!*val && !*ref) return 0; | 80 | if (!*val && !*ref) return 0; |
79 | if (!*val) return -1; | 81 | if (!*val) return -1; |
80 | if (!*ref) return +1; | 82 | if (!*ref) return +1; |
81 | } | 83 | } |
82 | } | 84 | } |
83 | 85 | ||
84 | int versioncompare(const struct versionrevision *version, | 86 | int versioncompare(const struct versionrevision *version, |
85 | const struct versionrevision *refversion) | 87 | const struct versionrevision *refversion) |
86 | { | 88 | { |
87 | int r; | 89 | int r; |
88 | 90 | ||
89 | if (version->epoch > refversion->epoch) return 1; | 91 | if (version->epoch > refversion->epoch) return 1; |
90 | if (version->epoch < refversion->epoch) return -1; | 92 | if (version->epoch < refversion->epoch) return -1; |
91 | r= verrevcmp(version->version,refversion->version); if (r) return r; | 93 | r= verrevcmp(version->version,refversion->version); if (r) return r; |
92 | r= verrevcmp(version->revision,refversion->revision); if (r) return r; | 94 | r= verrevcmp(version->revision,refversion->revision); if (r) return r; |
93 | return verrevcmp(version->familiar_revision,refversion->familiar_revision); | 95 | return verrevcmp(version->familiar_revision,refversion->familiar_revision); |
94 | } | 96 | } |
95 | 97 | ||
96 | int versionsatisfied3(const struct versionrevision *it, | 98 | int versionsatisfied3(const struct versionrevision *it, |
97 | const struct versionrevision *ref, | 99 | const struct versionrevision *ref, |
98 | const char *op) | 100 | const char *op) |
99 | { | 101 | { |
100 | int r; | 102 | int r; |
101 | r= versioncompare(it,ref); | 103 | r= versioncompare(it,ref); |
102 | if (strcmp(op, "<=") == 0 || strcmp(op, "<") == 0) | 104 | if (strcmp(op, "<=") == 0 || strcmp(op, "<") == 0) |
103 | return r <= 0; | 105 | return r <= 0; |
104 | if (strcmp(op, ">=") == 0 || strcmp(op, ">") == 0) | 106 | if (strcmp(op, ">=") == 0 || strcmp(op, ">") == 0) |
105 | return r >= 0; | 107 | return r >= 0; |
106 | if (strcmp(op, "<<") == 0) | 108 | if (strcmp(op, "<<") == 0) |
107 | return r < 0; | 109 | return r < 0; |
108 | if (strcmp(op, ">>") == 0) | 110 | if (strcmp(op, ">>") == 0) |
109 | return r > 0; | 111 | return r > 0; |
110 | if (strcmp(op, "=") == 0) | 112 | if (strcmp(op, "=") == 0) |
111 | return r == 0; | 113 | return r == 0; |
112 | fprintf(stderr, "unknown operator: %s", op); | 114 | // fprintf(stderr, "unknown operator: %s", op); |
113 | 115 | ||
114 | exit(1); | 116 | exit(1); |
115 | } | 117 | } |
116 | 118 | ||
117 | const char *parseversion(struct versionrevision *rversion, const char *string) | 119 | const char *parseversion(struct versionrevision *rversion, const char *string) |
118 | { | 120 | { |
119 | char *hyphen, *colon, *eepochcolon; | 121 | char *hyphen, *colon, *eepochcolon; |
120 | unsigned long epoch; | 122 | unsigned long epoch; |
121 | 123 | ||
122 | if (!*string) return _("version string is empty"); | 124 | if ( !*string ) |
123 | 125 | return QObject::tr( "Version string is empty." ); | |
126 | |||
124 | colon= strchr(string,':'); | 127 | colon= strchr(string,':'); |
125 | if (colon) { | 128 | if (colon) { |
126 | epoch= strtoul(string,&eepochcolon,10); | 129 | epoch= strtoul(string,&eepochcolon,10); |
127 | if (colon != eepochcolon) return _("epoch in version is not number"); | 130 | if ( colon != eepochcolon ) |
128 | if (!*++colon) return _("nothing after colon in version number"); | 131 | return QObject::tr( "Epoch in version is not number." ); |
132 | if ( !*++colon ) | ||
133 | return QObject::tr( "Nothing after colon in version number." ); | ||
129 | string= colon; | 134 | string= colon; |
130 | rversion->epoch= epoch; | 135 | rversion->epoch= epoch; |
131 | } else { | 136 | } else { |
132 | rversion->epoch= 0; | 137 | rversion->epoch= 0; |
133 | } | 138 | } |
134 | 139 | ||
135 | rversion->revision = ""; | 140 | rversion->revision = ""; |
136 | rversion->familiar_revision = ""; | 141 | rversion->familiar_revision = ""; |
137 | 142 | ||
138 | rversion->setVersion( string ); | 143 | rversion->setVersion( string ); |
139 | hyphen= strrchr(rversion->version,'-'); | 144 | hyphen= strrchr(rversion->version,'-'); |
140 | if (hyphen) { | 145 | if (hyphen) { |
141 | *hyphen++= 0; | 146 | *hyphen++= 0; |
142 | if (strncmp("fam", hyphen, 3) == 0) { | 147 | if (strncmp("fam", hyphen, 3) == 0) { |
143 | rversion->familiar_revision=hyphen+3; | 148 | rversion->familiar_revision=hyphen+3; |
144 | hyphen= strrchr(rversion->version,'-'); | 149 | hyphen= strrchr(rversion->version,'-'); |
145 | if (hyphen) { | 150 | if (hyphen) { |
146 | *hyphen++= 0; | 151 | *hyphen++= 0; |
147 | rversion->revision = hyphen; | 152 | rversion->revision = hyphen; |
148 | } | 153 | } |
149 | } else { | 154 | } else { |
150 | rversion->revision = hyphen; | 155 | rversion->revision = hyphen; |
151 | } | 156 | } |
152 | } | 157 | } |
153 | /* | 158 | /* |
154 | fprintf(stderr,"Parsed version: %lu, %s, %s, %s\n", | 159 | fprintf(stderr,"Parsed version: %lu, %s, %s, %s\n", |
155 | rversion->epoch, | 160 | rversion->epoch, |
156 | rversion->version, | 161 | rversion->version, |
157 | rversion->revision, | 162 | rversion->revision, |
158 | rversion->familiar_revision); | 163 | rversion->familiar_revision); |
159 | */ | 164 | */ |
160 | return 0; | 165 | return 0; |
161 | } | 166 | } |
162 | 167 | ||
163 | int compareVersions( const char *v1, const char *v2 ) | 168 | int compareVersions( const char *v1, const char *v2 ) |
164 | { | 169 | { |
165 | const char *err; | 170 | const char *err; |
166 | versionrevision ver, ref; | 171 | versionrevision ver, ref; |
167 | 172 | ||
168 | err = parseversion(&ref, v1); | 173 | err = parseversion(&ref, v1); |
169 | if (err) { | 174 | if (err) { |
170 | fprintf(stderr, "Invalid version `%s': %s\n", v2, err); | 175 | // fprintf(stderr, "Invalid version `%s': %s\n", v2, err); |
171 | return -2; | 176 | return -2; |
172 | } | 177 | } |
173 | 178 | ||
174 | err = parseversion(&ver, v2); | 179 | err = parseversion(&ver, v2); |
175 | if (err) { | 180 | if (err) { |
176 | fprintf(stderr, "Invalid version `%s': %s\n", v1, err); | 181 | // fprintf(stderr, "Invalid version `%s': %s\n", v1, err); |
177 | return -2; | 182 | return -2; |
178 | } | 183 | } |
179 | 184 | ||
180 | if ( versionsatisfied3( &ver, &ref, "=" ) ) | 185 | if ( versionsatisfied3( &ver, &ref, "=" ) ) |
181 | return 0; | 186 | return 0; |
182 | else if ( versionsatisfied3( &ver, &ref, "<" ) ) | 187 | else if ( versionsatisfied3( &ver, &ref, "<" ) ) |
183 | return -1; | 188 | return -1; |
184 | else | 189 | else |
185 | return 1; | 190 | return 1; |
186 | } | 191 | } |
187 | 192 | ||
188 | /* | 193 | /* |
189 | int main(int argc, char *argv[]) | 194 | int main(int argc, char *argv[]) |
190 | { | 195 | { |
191 | const char *err; | 196 | const char *err; |
192 | versionrevision ver, ref; | 197 | versionrevision ver, ref; |
193 | 198 | ||
194 | if (argc < 4) { | 199 | if (argc < 4) { |
195 | fprintf(stderr, "usage: %s: version op refversion\n", argv[0]); | 200 | fprintf(stderr, "usage: %s: version op refversion\n", argv[0]); |
196 | return 2; | 201 | return 2; |
197 | } | 202 | } |
198 | 203 | ||
199 | err = parseversion(&ver, argv[1]); | 204 | err = parseversion(&ver, argv[1]); |
200 | if (err) { | 205 | if (err) { |
201 | fprintf(stderr, "Invalid version `%s': %s\n", argv[1], err); | 206 | fprintf(stderr, "Invalid version `%s': %s\n", argv[1], err); |
202 | return 2; | 207 | return 2; |
203 | } | 208 | } |
204 | 209 | ||
205 | err = parseversion(&ref, argv[3]); | 210 | err = parseversion(&ref, argv[3]); |
206 | if (err) { | 211 | if (err) { |
207 | fprintf(stderr, "Invalid version `%s': %s\n", argv[3], err); | 212 | fprintf(stderr, "Invalid version `%s': %s\n", argv[3], err); |
208 | return 2; | 213 | return 2; |
209 | } | 214 | } |
210 | 215 | ||
211 | printf( "Result: %d\n", versionsatisfied3(&ver, &ref, argv[2]) ); | 216 | printf( "Result: %d\n", versionsatisfied3(&ver, &ref, argv[2]) ); |
212 | } | 217 | } |
213 | 218 | ||
214 | */ | 219 | */ |