summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/aqpkg.pro2
-rw-r--r--noncore/settings/aqpkg/datamgr.cpp20
-rw-r--r--noncore/settings/aqpkg/datamgr.h9
-rw-r--r--noncore/settings/aqpkg/mainwin.cpp51
-rw-r--r--noncore/settings/aqpkg/mainwin.h7
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.cpp84
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.h18
-rw-r--r--noncore/settings/aqpkg/progresswidget.cpp66
-rw-r--r--noncore/settings/aqpkg/progresswidget.h54
9 files changed, 267 insertions, 44 deletions
diff --git a/noncore/settings/aqpkg/aqpkg.pro b/noncore/settings/aqpkg/aqpkg.pro
index 3b27ac3..ad0dfc5 100644
--- a/noncore/settings/aqpkg/aqpkg.pro
+++ b/noncore/settings/aqpkg/aqpkg.pro
@@ -1,47 +1,49 @@
1 TEMPLATE= app 1 TEMPLATE= app
2 CONFIG = qt warn_on debug 2 CONFIG = qt warn_on debug
3 HEADERS = global.h \ 3 HEADERS = global.h \
4 mainwin.h \ 4 mainwin.h \
5 datamgr.h \ 5 datamgr.h \
6 settingsimpl.h \ 6 settingsimpl.h \
7 ipkg.h \ 7 ipkg.h \
8 networkpkgmgr.h \ 8 networkpkgmgr.h \
9 package.h \ 9 package.h \
10 progressdlg.h \ 10 progressdlg.h \
11 progresswidget.h \
11 installdlgimpl.h \ 12 installdlgimpl.h \
12 instoptionsimpl.h \ 13 instoptionsimpl.h \
13 destination.h \ 14 destination.h \
14 utils.h \ 15 utils.h \
15 server.h \ 16 server.h \
16 helpwindow.h \ 17 helpwindow.h \
17 letterpushbutton.h \ 18 letterpushbutton.h \
18 inputdlg.h \ 19 inputdlg.h \
19 categoryfilterimpl.h 20 categoryfilterimpl.h
20 SOURCES = mainwin.cpp \ 21 SOURCES = mainwin.cpp \
21 datamgr.cpp \ 22 datamgr.cpp \
22 mem.cpp \ 23 mem.cpp \
23 settingsimpl.cpp \ 24 settingsimpl.cpp \
24 ipkg.cpp \ 25 ipkg.cpp \
25 networkpkgmgr.cpp \ 26 networkpkgmgr.cpp \
26 main.cpp \ 27 main.cpp \
27 package.cpp \ 28 package.cpp \
28 progressdlg.cpp \ 29 progressdlg.cpp \
30 progresswidget.cpp \
29 installdlgimpl.cpp \ 31 installdlgimpl.cpp \
30 instoptionsimpl.cpp \ 32 instoptionsimpl.cpp \
31 destination.cpp \ 33 destination.cpp \
32 utils.cpp \ 34 utils.cpp \
33 server.cpp \ 35 server.cpp \
34 helpwindow.cpp \ 36 helpwindow.cpp \
35 letterpushbutton.cpp \ 37 letterpushbutton.cpp \
36 inputdlg.cpp \ 38 inputdlg.cpp \
37 version.cpp \ 39 version.cpp \
38 categoryfilterimpl.cpp 40 categoryfilterimpl.cpp
39 INTERFACES= settings.ui \ 41 INTERFACES= settings.ui \
40 install.ui \ 42 install.ui \
41 instoptions.ui \ 43 instoptions.ui \
42 categoryfilter.ui 44 categoryfilter.ui
43 TARGET = aqpkg 45 TARGET = aqpkg
44INCLUDEPATH += $(OPIEDIR)/include 46INCLUDEPATH += $(OPIEDIR)/include
45DEPENDPATH += $(OPIEDIR)/include 47DEPENDPATH += $(OPIEDIR)/include
46LIBS += -lqpe -lopie -lstdc++ 48LIBS += -lqpe -lopie -lstdc++
47DESTDIR = $(OPIEDIR)/bin 49DESTDIR = $(OPIEDIR)/bin
diff --git a/noncore/settings/aqpkg/datamgr.cpp b/noncore/settings/aqpkg/datamgr.cpp
index 0159a79..2c83e28 100644
--- a/noncore/settings/aqpkg/datamgr.cpp
+++ b/noncore/settings/aqpkg/datamgr.cpp
@@ -1,275 +1,289 @@
1/*************************************************************************** 1/***************************************************************************
2 datamgr.cpp - description 2 datamgr.cpp - description
3 ------------------- 3 -------------------
4 begin : Thu Aug 29 2002 4 begin : Thu Aug 29 2002
5 copyright : (C) 2002 by Andy Qua 5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk 6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17#include <fstream> 17#include <fstream>
18#include <iostream> 18#include <iostream>
19using namespace std; 19using namespace std;
20 20
21#ifdef QWS 21#ifdef QWS
22#include <qpe/config.h> 22#include <qpe/config.h>
23#include <qpe/qpeapplication.h>
24#else
25#include <qapplication.h>
23#endif 26#endif
24 27
25#include <stdio.h> 28#include <stdio.h>
26 29
27#include "datamgr.h" 30#include "datamgr.h"
28#include "global.h" 31#include "global.h"
29 32
30 33
31QString DataManager::availableCategories = ""; 34QString DataManager::availableCategories = "";
32DataManager::DataManager() 35DataManager::DataManager()
36 : QObject( 0x0, 0x0 )
33{ 37{
34 activeServer = ""; 38 activeServer = "";
35 availableCategories = "#"; 39 availableCategories = "#";
36} 40}
37 41
38DataManager::~DataManager() 42DataManager::~DataManager()
39{ 43{
40} 44}
41 45
42vector<Server>::iterator DataManager :: getServer( const char *name ) 46vector<Server>::iterator DataManager :: getServer( const char *name )
43{ 47{
44 vector<Server>::iterator it = serverList.begin(); 48 vector<Server>::iterator it = serverList.begin();
45 while ( it != serverList.end() ) 49 while ( it != serverList.end() )
46 { 50 {
47 if ( it->getServerName() == name ) 51 if ( it->getServerName() == name )
48 return it; 52 return it;
49 53
50 ++it; 54 ++it;
51 } 55 }
52 56
53 return serverList.end(); 57 return serverList.end();
54} 58}
55 59
56vector<Destination>::iterator DataManager :: getDestination( const char *name ) 60vector<Destination>::iterator DataManager :: getDestination( const char *name )
57{ 61{
58 vector<Destination>::iterator it = destList.begin(); 62 vector<Destination>::iterator it = destList.begin();
59 while ( it != destList.end() ) 63 while ( it != destList.end() )
60 { 64 {
61 if ( it->getDestinationName() == name ) 65 if ( it->getDestinationName() == name )
62 return it; 66 return it;
63 67
64 ++it; 68 ++it;
65 } 69 }
66 70
67 return destList.end(); 71 return destList.end();
68} 72}
69 73
70void DataManager :: loadServers() 74void DataManager :: loadServers()
71{ 75{
72 // First add our local server - not really a server but 76 // First add our local server - not really a server but
73 // the local config (which packages are installed) 77 // the local config (which packages are installed)
74 serverList.push_back( Server( LOCAL_SERVER, "" ) ); 78 serverList.push_back( Server( LOCAL_SERVER, "" ) );
75 serverList.push_back( Server( LOCAL_IPKGS, "" ) ); 79 serverList.push_back( Server( LOCAL_IPKGS, "" ) );
76 80
77#ifdef QWS 81#ifdef QWS
78 Config cfg( "aqpkg" ); 82 Config cfg( "aqpkg" );
79 cfg.setGroup( "destinations" ); 83 cfg.setGroup( "destinations" );
80#endif 84#endif
81 85
82 // Read file from /etc/ipkg.conf 86 // Read file from /etc/ipkg.conf
83 QString ipkg_conf = IPKG_CONF; 87 QString ipkg_conf = IPKG_CONF;
84 FILE *fp; 88 FILE *fp;
85 fp = fopen( ipkg_conf, "r" ); 89 fp = fopen( ipkg_conf, "r" );
86 char line[130]; 90 char line[130];
87 QString lineStr; 91 QString lineStr;
88 if ( fp == NULL ) 92 if ( fp == NULL )
89 { 93 {
90 cout << "Couldn't open " << ipkg_conf << "! err = " << fp << endl; 94 cout << "Couldn't open " << ipkg_conf << "! err = " << fp << endl;
91 return; 95 return;
92 } 96 }
93 else 97 else
94 { 98 {
95 while ( fgets( line, sizeof line, fp) != NULL ) 99 while ( fgets( line, sizeof line, fp) != NULL )
96 { 100 {
97 lineStr = line; 101 lineStr = line;
98 if ( lineStr.startsWith( "src" ) || lineStr.startsWith( "#src" ) || lineStr.startsWith( "# src" ) ) 102 if ( lineStr.startsWith( "src" ) || lineStr.startsWith( "#src" ) || lineStr.startsWith( "# src" ) )
99 { 103 {
100 char alias[20]; 104 char alias[20];
101 char url[100]; 105 char url[100];
102 106
103 // Looks a little wierd but read up to the r of src (throwing it away), 107 // Looks a little wierd but read up to the r of src (throwing it away),
104 // then read up to the next space and throw that away, the alias 108 // then read up to the next space and throw that away, the alias
105 // is next. 109 // is next.
106 // Should Handle #src, # src, src, and combinations of 110 // Should Handle #src, # src, src, and combinations of
107 sscanf( lineStr, "%*[^r]%*[^ ] %s %s", alias, url ); 111 sscanf( lineStr, "%*[^r]%*[^ ] %s %s", alias, url );
108 Server s( alias, url ); 112 Server s( alias, url );
109 if ( lineStr.startsWith( "src" ) ) 113 if ( lineStr.startsWith( "src" ) )
110 s.setActive( true ); 114 s.setActive( true );
111 else 115 else
112 s.setActive( false ); 116 s.setActive( false );
113 117
114 serverList.push_back( s ); 118 serverList.push_back( s );
115 119
116 } 120 }
117 else if ( lineStr.startsWith( "dest" ) ) 121 else if ( lineStr.startsWith( "dest" ) )
118 { 122 {
119 char alias[20]; 123 char alias[20];
120 char path[50]; 124 char path[50];
121 sscanf( lineStr, "%*[^ ] %s %s", alias, path ); 125 sscanf( lineStr, "%*[^ ] %s %s", alias, path );
122 Destination d( alias, path ); 126 Destination d( alias, path );
123 bool linkToRoot = true; 127 bool linkToRoot = true;
124#ifdef QWS 128#ifdef QWS
125 QString key = alias; 129 QString key = alias;
126 key += "_linkToRoot"; 130 key += "_linkToRoot";
127 linkToRoot = cfg.readBoolEntry( key, true ); 131 linkToRoot = cfg.readBoolEntry( key, true );
128#endif 132#endif
129 d.linkToRoot( linkToRoot ); 133 d.linkToRoot( linkToRoot );
130 134
131 destList.push_back( d ); 135 destList.push_back( d );
132 } 136 }
133 else if ( lineStr.startsWith( "option" ) || lineStr.startsWith( "#option" ) ) 137 else if ( lineStr.startsWith( "option" ) || lineStr.startsWith( "#option" ) )
134 { 138 {
135 char type[20]; 139 char type[20];
136 char val[100]; 140 char val[100];
137 sscanf( lineStr, "%*[^ ] %s %s", type, val ); 141 sscanf( lineStr, "%*[^ ] %s %s", type, val );
138 if ( stricmp( type, "http_proxy" ) == 0 ) 142 if ( stricmp( type, "http_proxy" ) == 0 )
139 { 143 {
140 httpProxy = val; 144 httpProxy = val;
141 if ( lineStr.startsWith( "#" ) ) 145 if ( lineStr.startsWith( "#" ) )
142 httpProxyEnabled = false; 146 httpProxyEnabled = false;
143 else 147 else
144 httpProxyEnabled = true; 148 httpProxyEnabled = true;
145 } 149 }
146 if ( stricmp( type, "ftp_proxy" ) == 0 ) 150 if ( stricmp( type, "ftp_proxy" ) == 0 )
147 { 151 {
148 ftpProxy = val; 152 ftpProxy = val;
149 if ( lineStr.startsWith( "#" ) ) 153 if ( lineStr.startsWith( "#" ) )
150 ftpProxyEnabled = false; 154 ftpProxyEnabled = false;
151 else 155 else
152 ftpProxyEnabled = true; 156 ftpProxyEnabled = true;
153 } 157 }
154 if ( stricmp( type, "proxy_username" ) == 0 ) 158 if ( stricmp( type, "proxy_username" ) == 0 )
155 proxyUsername = val; 159 proxyUsername = val;
156 if ( stricmp( type, "proxy_password" ) == 0 ) 160 if ( stricmp( type, "proxy_password" ) == 0 )
157 proxyPassword = val; 161 proxyPassword = val;
158 } 162 }
159 } 163 }
160 } 164 }
161 fclose( fp ); 165 fclose( fp );
162 166
163 reloadServerData( ); 167 reloadServerData( );
164} 168}
165 169
166void DataManager :: reloadServerData( ) 170void DataManager :: reloadServerData( )
167{ 171{
168 vector<Server>::iterator it = serverList.begin(); 172 emit progressSetSteps( serverList.size() );
173 emit progressSetMessage( tr( "Reading configuration..." ) );
174
175 vector<Server>::iterator it = serverList.begin();
176 QString serverName;
177 int i = 0;
169 for ( it = serverList.begin() ; it != serverList.end() ; ++it ) 178 for ( it = serverList.begin() ; it != serverList.end() ; ++it )
170 { 179 {
180 serverName = it->getServerName();
181 i++;
182 emit progressUpdate( i );
183 qApp->processEvents();
184
171 // Now we've read the config file in we need to read the servers 185 // Now we've read the config file in we need to read the servers
172 // The local server is a special case. This holds the contents of the 186 // The local server is a special case. This holds the contents of the
173 // status files the number of which depends on how many destinations 187 // status files the number of which depends on how many destinations
174 // we've set up 188 // we've set up
175 // The other servers files hold the contents of the server package list 189 // The other servers files hold the contents of the server package list
176 if ( it->getServerName() == LOCAL_SERVER ) 190 if ( serverName == LOCAL_SERVER )
177 it->readStatusFile( destList ); 191 it->readStatusFile( destList );
178 else if ( it->getServerName() == LOCAL_IPKGS ) 192 else if ( serverName == LOCAL_IPKGS )
179 it->readLocalIpks( &( *getServer( LOCAL_SERVER ) ) ); 193 it->readLocalIpks( &( *getServer( LOCAL_SERVER ) ) );
180 else 194 else
181 it->readPackageFile( &( *getServer( LOCAL_SERVER ) ) ); 195 it->readPackageFile( &( *getServer( LOCAL_SERVER ) ) );
182 } 196 }
183} 197}
184 198
185void DataManager :: writeOutIpkgConf() 199void DataManager :: writeOutIpkgConf()
186{ 200{
187 QString ipkg_conf = IPKG_CONF; 201 QString ipkg_conf = IPKG_CONF;
188 ofstream out( ipkg_conf ); 202 ofstream out( ipkg_conf );
189 203
190 out << "# Written by AQPkg" << endl; 204 out << "# Written by AQPkg" << endl;
191 out << "# Must have one or more source entries of the form:" << endl; 205 out << "# Must have one or more source entries of the form:" << endl;
192 out << "#" << endl; 206 out << "#" << endl;
193 out << "# src <src-name> <source-url>" << endl; 207 out << "# src <src-name> <source-url>" << endl;
194 out << "#" << endl; 208 out << "#" << endl;
195 out << "# and one or more destination entries of the form:" << endl; 209 out << "# and one or more destination entries of the form:" << endl;
196 out << "#" << endl; 210 out << "#" << endl;
197 out << "# dest <dest-name> <target-path>" << endl; 211 out << "# dest <dest-name> <target-path>" << endl;
198 out << "#" << endl; 212 out << "#" << endl;
199 out << "# where <src-name> and <dest-names> are identifiers that" << endl; 213 out << "# where <src-name> and <dest-names> are identifiers that" << endl;
200 out << "# should match [a-zA-Z0-9._-]+, <source-url> should be a" << endl; 214 out << "# should match [a-zA-Z0-9._-]+, <source-url> should be a" << endl;
201 out << "# URL that points to a directory containing a Familiar" << endl; 215 out << "# URL that points to a directory containing a Familiar" << endl;
202 out << "# Packages file, and <target-path> should be a directory" << endl; 216 out << "# Packages file, and <target-path> should be a directory" << endl;
203 out << "# that exists on the target system." << endl << endl; 217 out << "# that exists on the target system." << endl << endl;
204 218
205 // Write out servers 219 // Write out servers
206 vector<Server>::iterator it = serverList.begin(); 220 vector<Server>::iterator it = serverList.begin();
207 while ( it != serverList.end() ) 221 while ( it != serverList.end() )
208 { 222 {
209 QString alias = it->getServerName(); 223 QString alias = it->getServerName();
210 // Don't write out local as its a dummy 224 // Don't write out local as its a dummy
211 if ( alias != LOCAL_SERVER && alias != LOCAL_IPKGS ) 225 if ( alias != LOCAL_SERVER && alias != LOCAL_IPKGS )
212 { 226 {
213 QString url = it->getServerUrl();; 227 QString url = it->getServerUrl();;
214 228
215 if ( !it->isServerActive() ) 229 if ( !it->isServerActive() )
216 out << "#"; 230 out << "#";
217 out << "src " << alias << " " << url << endl; 231 out << "src " << alias << " " << url << endl;
218 } 232 }
219 233
220 it++; 234 it++;
221 } 235 }
222 236
223 out << endl; 237 out << endl;
224 238
225 // Write out destinations 239 // Write out destinations
226 vector<Destination>::iterator it2 = destList.begin(); 240 vector<Destination>::iterator it2 = destList.begin();
227 while ( it2 != destList.end() ) 241 while ( it2 != destList.end() )
228 { 242 {
229 out << "dest " << it2->getDestinationName() << " " << it2->getDestinationPath() << endl; 243 out << "dest " << it2->getDestinationName() << " " << it2->getDestinationPath() << endl;
230 it2++; 244 it2++;
231 } 245 }
232 246
233 out << endl; 247 out << endl;
234 out << "# Proxy Support" << endl; 248 out << "# Proxy Support" << endl;
235 249
236 if ( !httpProxyEnabled && httpProxy == "" ) 250 if ( !httpProxyEnabled && httpProxy == "" )
237 out << "#option http_proxy http://proxy.tld:3128" << endl; 251 out << "#option http_proxy http://proxy.tld:3128" << endl;
238 else 252 else
239 { 253 {
240 if ( !httpProxyEnabled ) 254 if ( !httpProxyEnabled )
241 out << "#"; 255 out << "#";
242 out << "option http_proxy " << httpProxy << endl; 256 out << "option http_proxy " << httpProxy << endl;
243 } 257 }
244 258
245 if ( !ftpProxyEnabled && ftpProxy == "" ) 259 if ( !ftpProxyEnabled && ftpProxy == "" )
246 out << "#option ftp_proxy http://proxy.tld:3128" << endl; 260 out << "#option ftp_proxy http://proxy.tld:3128" << endl;
247 else 261 else
248 { 262 {
249 if ( !ftpProxyEnabled ) 263 if ( !ftpProxyEnabled )
250 out << "#"; 264 out << "#";
251 out << "option ftp_proxy " << ftpProxy << endl; 265 out << "option ftp_proxy " << ftpProxy << endl;
252 } 266 }
253 if ( proxyUsername == "" || (!httpProxyEnabled && !ftpProxyEnabled) ) 267 if ( proxyUsername == "" || (!httpProxyEnabled && !ftpProxyEnabled) )
254 out << "#option proxy_username <username>" << endl; 268 out << "#option proxy_username <username>" << endl;
255 else 269 else
256 out << "option proxy_username " << proxyUsername << endl; 270 out << "option proxy_username " << proxyUsername << endl;
257 if ( proxyPassword == "" || (!httpProxyEnabled && !ftpProxyEnabled) ) 271 if ( proxyPassword == "" || (!httpProxyEnabled && !ftpProxyEnabled) )
258 out << "#option proxy_password <password>" << endl << endl; 272 out << "#option proxy_password <password>" << endl << endl;
259 else 273 else
260 out << "option proxy_password " << proxyPassword << endl<< endl; 274 out << "option proxy_password " << proxyPassword << endl<< endl;
261 275
262 out << "# Offline mode (for use in constructing flash images offline)" << endl; 276 out << "# Offline mode (for use in constructing flash images offline)" << endl;
263 out << "#option offline_root target" << endl; 277 out << "#option offline_root target" << endl;
264 278
265 279
266 out.close(); 280 out.close();
267} 281}
268 282
269 283
270void DataManager :: setAvailableCategories( QString section ) 284void DataManager :: setAvailableCategories( QString section )
271{ 285{
272 section = section.lower(); 286 section = section.lower();
273 if ( availableCategories.find( "#" + section + "#" ) == -1 ) 287 if ( availableCategories.find( "#" + section + "#" ) == -1 )
274 availableCategories += section + "#"; 288 availableCategories += section + "#";
275} 289}
diff --git a/noncore/settings/aqpkg/datamgr.h b/noncore/settings/aqpkg/datamgr.h
index 0a7467f..90328ab 100644
--- a/noncore/settings/aqpkg/datamgr.h
+++ b/noncore/settings/aqpkg/datamgr.h
@@ -1,91 +1,98 @@
1/*************************************************************************** 1/***************************************************************************
2 datamgr.h - description 2 datamgr.h - description
3 ------------------- 3 -------------------
4 begin : Thu Aug 29 2002 4 begin : Thu Aug 29 2002
5 copyright : (C) 2002 by Andy Qua 5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk 6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#ifndef DATAMGR_H 18#ifndef DATAMGR_H
19#define DATAMGR_H 19#define DATAMGR_H
20 20
21#include <map> 21#include <map>
22using namespace std; 22using namespace std;
23 23
24#include <qobject.h>
24#include <qstring.h> 25#include <qstring.h>
25 26
26#include "server.h" 27#include "server.h"
27#include "destination.h" 28#include "destination.h"
28 29
29 #define LOCAL_SERVER "Installed Pkgs" 30 #define LOCAL_SERVER "Installed Pkgs"
30 #define LOCAL_IPKGS "local IPKG" 31 #define LOCAL_IPKGS "local IPKG"
31 32
32/** 33/**
33 *@author Andy Qua 34 *@author Andy Qua
34 */ 35 */
35 36
36 37
37class DataManager 38class DataManager : public QObject
38{ 39{
40 Q_OBJECT
39public: 41public:
40 DataManager(); 42 DataManager();
41 ~DataManager(); 43 ~DataManager();
42 44
43 void setActiveServer( const QString &act ) { activeServer = act; } 45 void setActiveServer( const QString &act ) { activeServer = act; }
44 QString &getActiveServer( ) { return activeServer; } 46 QString &getActiveServer( ) { return activeServer; }
45 47
46 Server *getLocalServer() { return &( *getServer( LOCAL_SERVER ) ); } 48 Server *getLocalServer() { return &( *getServer( LOCAL_SERVER ) ); }
47 vector<Server> &getServerList() { return serverList; } 49 vector<Server> &getServerList() { return serverList; }
48 vector<Server>::iterator getServer( const char *name ); 50 vector<Server>::iterator getServer( const char *name );
49 51
50 vector<Destination> &getDestinationList() { return destList; } 52 vector<Destination> &getDestinationList() { return destList; }
51 vector<Destination>::iterator getDestination( const char *name ); 53 vector<Destination>::iterator getDestination( const char *name );
52 54
53 void loadServers(); 55 void loadServers();
54 void reloadServerData( ); 56 void reloadServerData( );
55 57
56 void writeOutIpkgConf(); 58 void writeOutIpkgConf();
57 59
58 static QString getAvailableCategories() { return availableCategories; } 60 static QString getAvailableCategories() { return availableCategories; }
59 static void setAvailableCategories( QString section ); 61 static void setAvailableCategories( QString section );
60 62
61 QString getHttpProxy() { return httpProxy; } 63 QString getHttpProxy() { return httpProxy; }
62 QString getFtpProxy() { return ftpProxy; } 64 QString getFtpProxy() { return ftpProxy; }
63 QString getProxyUsername() { return proxyUsername; } 65 QString getProxyUsername() { return proxyUsername; }
64 QString getProxyPassword() { return proxyPassword; } 66 QString getProxyPassword() { return proxyPassword; }
65 67
66 bool getHttpProxyEnabled() { return httpProxyEnabled; } 68 bool getHttpProxyEnabled() { return httpProxyEnabled; }
67 bool getFtpProxyEnabled() { return ftpProxyEnabled; } 69 bool getFtpProxyEnabled() { return ftpProxyEnabled; }
68 70
69 void setHttpProxy( QString proxy ) { httpProxy = proxy; } 71 void setHttpProxy( QString proxy ) { httpProxy = proxy; }
70 void setFtpProxy( QString proxy ) { ftpProxy = proxy; } 72 void setFtpProxy( QString proxy ) { ftpProxy = proxy; }
71 void setProxyUsername( QString name ) { proxyUsername = name; } 73 void setProxyUsername( QString name ) { proxyUsername = name; }
72 void setProxyPassword( QString pword ) { proxyPassword = pword; } 74 void setProxyPassword( QString pword ) { proxyPassword = pword; }
73 75
74 void setHttpProxyEnabled( bool val ) { httpProxyEnabled = val; } 76 void setHttpProxyEnabled( bool val ) { httpProxyEnabled = val; }
75 void setFtpProxyEnabled( bool val ) { ftpProxyEnabled = val; } 77 void setFtpProxyEnabled( bool val ) { ftpProxyEnabled = val; }
76private: 78private:
77 static QString availableCategories; 79 static QString availableCategories;
78 QString activeServer; 80 QString activeServer;
79 QString httpProxy; 81 QString httpProxy;
80 QString ftpProxy; 82 QString ftpProxy;
81 QString proxyUsername; 83 QString proxyUsername;
82 QString proxyPassword; 84 QString proxyPassword;
83 85
84 bool httpProxyEnabled; 86 bool httpProxyEnabled;
85 bool ftpProxyEnabled; 87 bool ftpProxyEnabled;
86 88
87 vector<Server> serverList; 89 vector<Server> serverList;
88 vector<Destination> destList; 90 vector<Destination> destList;
91
92signals:
93 void progressSetSteps( int );
94 void progressSetMessage( const QString & );
95 void progressUpdate( int );
89}; 96};
90 97
91#endif 98#endif
diff --git a/noncore/settings/aqpkg/mainwin.cpp b/noncore/settings/aqpkg/mainwin.cpp
index b00931e..5e03f11 100644
--- a/noncore/settings/aqpkg/mainwin.cpp
+++ b/noncore/settings/aqpkg/mainwin.cpp
@@ -1,210 +1,247 @@
1/*************************************************************************** 1/***************************************************************************
2 mainwin.cpp - description 2 mainwin.cpp - description
3 ------------------- 3 -------------------
4 begin : Mon Aug 26 13:32:30 BST 2002 4 begin : Mon Aug 26 13:32:30 BST 2002
5 copyright : (C) 2002 by Andy Qua 5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk 6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#include <iostream> 18#include <iostream>
19using namespace std; 19using namespace std;
20 20
21#include <qmenubar.h> 21#include <qmenubar.h>
22#include <qpopupmenu.h>
23#include <qmessagebox.h> 22#include <qmessagebox.h>
23#include <qpopupmenu.h>
24#include <qtimer.h>
24 25
25#include "mainwin.h" 26#include "mainwin.h"
27#include "progresswidget.h"
26#include "datamgr.h" 28#include "datamgr.h"
27#include "networkpkgmgr.h" 29#include "networkpkgmgr.h"
28#include "settingsimpl.h" 30#include "settingsimpl.h"
29#include "helpwindow.h" 31#include "helpwindow.h"
30#include "utils.h" 32#include "utils.h"
31#include "global.h" 33#include "global.h"
32 34
33MainWindow :: MainWindow( QWidget *p, char *name ) 35MainWindow :: MainWindow( QWidget *p, char *name )
34 :QMainWindow( p, name ) 36 :QMainWindow( p, name )
35{ 37{
36#ifdef QWS 38#ifdef QWS
37 showMaximized(); 39 showMaximized();
38#endif 40#endif
39 41
40 setCaption( tr( "AQPkg - Package Manager" ) ); 42 setCaption( tr( "AQPkg - Package Manager" ) );
41 43
42 // Create our menu 44 // Create our menu
43 help = new QPopupMenu( this ); 45 help = new QPopupMenu( this );
44 help->insertItem( "&General", this, SLOT(displayHelp()), Qt::CTRL+Qt::Key_G ); 46 help->insertItem( "&General", this, SLOT(displayHelp()), Qt::CTRL+Qt::Key_G );
45 help->insertItem( "&About", this, SLOT(displayAbout()), Qt::CTRL+Qt::Key_A ); 47 help->insertItem( "&About", this, SLOT(displayAbout()), Qt::CTRL+Qt::Key_A );
46 48
47 settings = new QPopupMenu( this ); 49 settings = new QPopupMenu( this );
48 settings->insertItem( "&Settings", this, SLOT(displaySettings()), Qt::CTRL+Qt::Key_S ); 50 settings->insertItem( "&Settings", this, SLOT(displaySettings()), Qt::CTRL+Qt::Key_S );
49 51
50 edit = new QPopupMenu( this ); 52 edit = new QPopupMenu( this );
51 edit->insertItem( "&Find", this, SLOT(searchForPackage()), Qt::CTRL+Qt::Key_I ); 53 edit->insertItem( "&Find", this, SLOT(searchForPackage()), Qt::CTRL+Qt::Key_I );
52 edit->insertItem( "Find &Next", this, SLOT(repeatSearchForPackage()), Qt::CTRL+Qt::Key_N ); 54 edit->insertItem( "Find &Next", this, SLOT(repeatSearchForPackage()), Qt::CTRL+Qt::Key_N );
53 55
54 filter = new QPopupMenu( this ); 56 filter = new QPopupMenu( this );
55 mnuShowUninstalledPkgsId = filter->insertItem( "Show &Non-Installed Packages", this, SLOT(filterUninstalledPackages()), Qt::CTRL+Qt::Key_U ); 57 mnuShowUninstalledPkgsId = filter->insertItem( "Show &Non-Installed Packages", this, SLOT(filterUninstalledPackages()), Qt::CTRL+Qt::Key_U );
56 mnuShowInstalledPkgsId = filter->insertItem( "Show In&stalled Packages", this, SLOT(filterInstalledPackages()), Qt::CTRL+Qt::Key_S ); 58 mnuShowInstalledPkgsId = filter->insertItem( "Show In&stalled Packages", this, SLOT(filterInstalledPackages()), Qt::CTRL+Qt::Key_S );
57 mnuShowUpgradedPkgsId = filter->insertItem( "Show U&pdated Packages", this, SLOT(filterUpgradedPackages()), Qt::CTRL+Qt::Key_P ); 59 mnuShowUpgradedPkgsId = filter->insertItem( "Show U&pdated Packages", this, SLOT(filterUpgradedPackages()), Qt::CTRL+Qt::Key_P );
58 filter->insertSeparator(); 60 filter->insertSeparator();
59 mnuFilterByCategory = filter->insertItem( "Filter By &Category", this, SLOT(filterCategory()), Qt::CTRL+Qt::Key_C ); 61 mnuFilterByCategory = filter->insertItem( "Filter By &Category", this, SLOT(filterCategory()), Qt::CTRL+Qt::Key_C );
60 mnuSetFilterCategory = filter->insertItem( "Set Filter C&ategory", this, SLOT(setFilterCategory()), Qt::CTRL+Qt::Key_A ); 62 mnuSetFilterCategory = filter->insertItem( "Set Filter C&ategory", this, SLOT(setFilterCategory()), Qt::CTRL+Qt::Key_A );
61 63
62 // Create the main menu 64 // Create the main menu
63 menu = menuBar(); //new QMenuBar( this ); 65 menu = menuBar(); //new QMenuBar( this );
64 menu->insertItem( tr( "&Settings" ), settings ); 66 menu->insertItem( tr( "&Settings" ), settings );
65 menu->insertItem( tr( "&Edit" ), edit ); 67 menu->insertItem( tr( "&Edit" ), edit );
66 menu->insertItem( tr( "&Filter" ), filter ); 68 menu->insertItem( tr( "&Filter" ), filter );
67 menu->insertItem( tr( "&Help" ), help ); 69 menu->insertItem( tr( "&Help" ), help );
68 70
69 mgr = new DataManager(); 71 // Create UI widgets
70 mgr->loadServers();
71
72 stack = new QWidgetStack( this ); 72 stack = new QWidgetStack( this );
73 73
74 networkPkgWindow = new NetworkPackageManager( mgr, stack ); 74 progressWindow = new ProgressWidget( stack );
75 stack->addWidget( progressWindow, 2 );
76
77 networkPkgWindow = new NetworkPackageManager( stack );
78 connect( networkPkgWindow, SIGNAL( appRaiseMainWidget() ), this, SLOT( raiseMainWidget() ) );
79 connect( networkPkgWindow, SIGNAL( appRaiseProgressWidget() ), this, SLOT( raiseProgressWidget() ) );
80 connect( networkPkgWindow, SIGNAL( progressSetSteps( int ) ), progressWindow, SLOT( setSteps( int ) ) );
81 connect( networkPkgWindow, SIGNAL( progressSetMessage( const QString & ) ),
82 progressWindow, SLOT( setMessage( const QString & ) ) );
83 connect( networkPkgWindow, SIGNAL( progressUpdate( int ) ), progressWindow, SLOT( update( int ) ) );
75 stack->addWidget( networkPkgWindow, 1 ); 84 stack->addWidget( networkPkgWindow, 1 );
76 85
77 setCentralWidget( stack ); 86 setCentralWidget( stack );
78 stack->raiseWidget( networkPkgWindow ); 87 stack->raiseWidget( progressWindow );
88
89 // Delayed call to finish initialization
90 QTimer::singleShot( 100, this, SLOT( init() ) );
91
79} 92}
80 93
81MainWindow :: ~MainWindow() 94MainWindow :: ~MainWindow()
82{ 95{
83 delete networkPkgWindow; 96 delete mgr;
97}
98
99void MainWindow :: init()
100{
101 stack->raiseWidget( progressWindow );
102 mgr = new DataManager();
103 connect( mgr, SIGNAL( progressSetSteps( int ) ), progressWindow, SLOT( setSteps( int ) ) );
104 connect( mgr, SIGNAL( progressSetMessage( const QString & ) ),
105 progressWindow, SLOT( setMessage( const QString & ) ) );
106 connect( mgr, SIGNAL( progressUpdate( int ) ), progressWindow, SLOT( update( int ) ) );
107 mgr->loadServers();
108 networkPkgWindow->setDataManager( mgr );
109 networkPkgWindow->updateData();
110 stack->raiseWidget( networkPkgWindow );
84} 111}
85 112
86void MainWindow :: setDocument( const QString &doc ) 113void MainWindow :: setDocument( const QString &doc )
87{ 114{
88 // Remove path from package 115 // Remove path from package
89 QString package = Utils::getPackageNameFromIpkFilename( doc ); 116 QString package = Utils::getPackageNameFromIpkFilename( doc );
90 std::cout << "Selecting package " << package << std::endl; 117 std::cout << "Selecting package " << package << std::endl;
91 networkPkgWindow->selectLocalPackage( package ); 118 networkPkgWindow->selectLocalPackage( package );
92} 119}
93 120
94void MainWindow :: displaySettings() 121void MainWindow :: displaySettings()
95{ 122{
96 SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true ); 123 SettingsImpl *dlg = new SettingsImpl( mgr, this, "Settings", true );
97 if ( dlg->showDlg( 0 ) ) 124 if ( dlg->showDlg( 0 ) )
98 networkPkgWindow->updateData(); 125 networkPkgWindow->updateData();
99 delete dlg; 126 delete dlg;
100} 127}
101 128
102void MainWindow :: displayHelp() 129void MainWindow :: displayHelp()
103{ 130{
104 HelpWindow *dlg = new HelpWindow( this ); 131 HelpWindow *dlg = new HelpWindow( this );
105 dlg->exec(); 132 dlg->exec();
106 delete dlg; 133 delete dlg;
107} 134}
108 135
109void MainWindow :: searchForPackage() 136void MainWindow :: searchForPackage()
110{ 137{
111 networkPkgWindow->searchForPackage( false ); 138 networkPkgWindow->searchForPackage( false );
112} 139}
113 140
114void MainWindow :: repeatSearchForPackage() 141void MainWindow :: repeatSearchForPackage()
115{ 142{
116 networkPkgWindow->searchForPackage( true ); 143 networkPkgWindow->searchForPackage( true );
117} 144}
118 145
119void MainWindow :: displayAbout() 146void MainWindow :: displayAbout()
120{ 147{
121 QMessageBox::about( this, "About AQPkg", VERSION_TEXT ); 148 QMessageBox::about( this, "About AQPkg", VERSION_TEXT );
122} 149}
123 150
124 151
125void MainWindow :: filterUninstalledPackages() 152void MainWindow :: filterUninstalledPackages()
126{ 153{
127 bool val; 154 bool val;
128 if ( filter->isItemChecked( mnuShowUninstalledPkgsId ) ) 155 if ( filter->isItemChecked( mnuShowUninstalledPkgsId ) )
129 { 156 {
130 val = false; 157 val = false;
131 filter->setItemChecked( mnuShowUninstalledPkgsId, false ); 158 filter->setItemChecked( mnuShowUninstalledPkgsId, false );
132 } 159 }
133 else 160 else
134 { 161 {
135 val = true; 162 val = true;
136 filter->setItemChecked( mnuShowUninstalledPkgsId, true ); 163 filter->setItemChecked( mnuShowUninstalledPkgsId, true );
137 } 164 }
138 165
139 filter->setItemChecked( mnuShowInstalledPkgsId, false ); 166 filter->setItemChecked( mnuShowInstalledPkgsId, false );
140 networkPkgWindow->showOnlyInstalledPackages( false ); 167 networkPkgWindow->showOnlyInstalledPackages( false );
141 filter->setItemChecked( mnuShowUpgradedPkgsId, false ); 168 filter->setItemChecked( mnuShowUpgradedPkgsId, false );
142 networkPkgWindow->showUpgradedPackages( false ); 169 networkPkgWindow->showUpgradedPackages( false );
143 170
144 networkPkgWindow->showOnlyUninstalledPackages( val ); 171 networkPkgWindow->showOnlyUninstalledPackages( val );
145 172
146} 173}
147 174
148void MainWindow :: filterInstalledPackages() 175void MainWindow :: filterInstalledPackages()
149{ 176{
150 bool val; 177 bool val;
151 if ( filter->isItemChecked( mnuShowInstalledPkgsId ) ) 178 if ( filter->isItemChecked( mnuShowInstalledPkgsId ) )
152 { 179 {
153 val = false; 180 val = false;
154 filter->setItemChecked( mnuShowInstalledPkgsId, false ); 181 filter->setItemChecked( mnuShowInstalledPkgsId, false );
155 } 182 }
156 else 183 else
157 { 184 {
158 val = true; 185 val = true;
159 filter->setItemChecked( mnuShowInstalledPkgsId, true ); 186 filter->setItemChecked( mnuShowInstalledPkgsId, true );
160 } 187 }
161 188
162 filter->setItemChecked( mnuShowUninstalledPkgsId, false ); 189 filter->setItemChecked( mnuShowUninstalledPkgsId, false );
163 networkPkgWindow->showOnlyUninstalledPackages( false ); 190 networkPkgWindow->showOnlyUninstalledPackages( false );
164 filter->setItemChecked( mnuShowUpgradedPkgsId, false ); 191 filter->setItemChecked( mnuShowUpgradedPkgsId, false );
165 networkPkgWindow->showUpgradedPackages( false ); 192 networkPkgWindow->showUpgradedPackages( false );
166 193
167 networkPkgWindow->showOnlyInstalledPackages( val ); 194 networkPkgWindow->showOnlyInstalledPackages( val );
168} 195}
169 196
170void MainWindow :: filterUpgradedPackages() 197void MainWindow :: filterUpgradedPackages()
171{ 198{
172 bool val; 199 bool val;
173 if ( filter->isItemChecked( mnuShowUpgradedPkgsId ) ) 200 if ( filter->isItemChecked( mnuShowUpgradedPkgsId ) )
174 { 201 {
175 val = false; 202 val = false;
176 filter->setItemChecked( mnuShowUpgradedPkgsId, false ); 203 filter->setItemChecked( mnuShowUpgradedPkgsId, false );
177 } 204 }
178 else 205 else
179 { 206 {
180 val = true; 207 val = true;
181 filter->setItemChecked( mnuShowUpgradedPkgsId, true ); 208 filter->setItemChecked( mnuShowUpgradedPkgsId, true );
182 } 209 }
183 210
184 filter->setItemChecked( mnuShowUninstalledPkgsId, false ); 211 filter->setItemChecked( mnuShowUninstalledPkgsId, false );
185 networkPkgWindow->showOnlyUninstalledPackages( false ); 212 networkPkgWindow->showOnlyUninstalledPackages( false );
186 filter->setItemChecked( mnuShowInstalledPkgsId, false ); 213 filter->setItemChecked( mnuShowInstalledPkgsId, false );
187 networkPkgWindow->showOnlyInstalledPackages( false ); 214 networkPkgWindow->showOnlyInstalledPackages( false );
188 215
189 networkPkgWindow->showUpgradedPackages( val ); 216 networkPkgWindow->showUpgradedPackages( val );
190} 217}
191 218
192void MainWindow :: setFilterCategory() 219void MainWindow :: setFilterCategory()
193{ 220{
194 if ( networkPkgWindow->setFilterCategory( ) ) 221 if ( networkPkgWindow->setFilterCategory( ) )
195 filter->setItemChecked( mnuFilterByCategory, true ); 222 filter->setItemChecked( mnuFilterByCategory, true );
196} 223}
197 224
198void MainWindow :: filterCategory() 225void MainWindow :: filterCategory()
199{ 226{
200 if ( filter->isItemChecked( mnuFilterByCategory ) ) 227 if ( filter->isItemChecked( mnuFilterByCategory ) )
201 { 228 {
202 networkPkgWindow->filterByCategory( false ); 229 networkPkgWindow->filterByCategory( false );
203 filter->setItemChecked( mnuFilterByCategory, false ); 230 filter->setItemChecked( mnuFilterByCategory, false );
204 } 231 }
205 else 232 else
206 { 233 {
207 if ( networkPkgWindow->filterByCategory( true ) ) 234 if ( networkPkgWindow->filterByCategory( true ) )
208 filter->setItemChecked( mnuFilterByCategory, true ); 235 filter->setItemChecked( mnuFilterByCategory, true );
209 } 236 }
210} 237}
238
239void MainWindow :: raiseMainWidget()
240{
241 stack->raiseWidget( networkPkgWindow );
242}
243
244void MainWindow :: raiseProgressWidget()
245{
246 stack->raiseWidget( progressWindow );
247}
diff --git a/noncore/settings/aqpkg/mainwin.h b/noncore/settings/aqpkg/mainwin.h
index 92aba4d..39799f9 100644
--- a/noncore/settings/aqpkg/mainwin.h
+++ b/noncore/settings/aqpkg/mainwin.h
@@ -1,68 +1,73 @@
1/*************************************************************************** 1/***************************************************************************
2 mainwin.h - description 2 mainwin.h - description
3 ------------------- 3 -------------------
4 begin : Mon Aug 26 13:32:30 BST 2002 4 begin : Mon Aug 26 13:32:30 BST 2002
5 copyright : (C) 2002 by Andy Qua 5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk 6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#ifndef MAINWIN_H 18#ifndef MAINWIN_H
19#define MAINWIN_H 19#define MAINWIN_H
20 20
21#include <qmainwindow.h> 21#include <qmainwindow.h>
22#include <qwidgetstack.h> 22#include <qwidgetstack.h>
23 23
24 24class ProgressWidget;
25class NetworkPackageManager; 25class NetworkPackageManager;
26class DataManager; 26class DataManager;
27 27
28class MainWindow :public QMainWindow 28class MainWindow :public QMainWindow
29{ 29{
30 Q_OBJECT 30 Q_OBJECT
31public: 31public:
32 32
33 MainWindow( QWidget *p = 0, char *name = 0 ); 33 MainWindow( QWidget *p = 0, char *name = 0 );
34 ~MainWindow(); 34 ~MainWindow();
35 35
36private: 36private:
37 DataManager *mgr; 37 DataManager *mgr;
38 38
39 QMenuBar *menu; 39 QMenuBar *menu;
40 QPopupMenu *help; 40 QPopupMenu *help;
41 QPopupMenu *settings; 41 QPopupMenu *settings;
42 QPopupMenu *edit; 42 QPopupMenu *edit;
43 QPopupMenu *filter; 43 QPopupMenu *filter;
44 QWidgetStack *stack; 44 QWidgetStack *stack;
45 45
46 NetworkPackageManager *networkPkgWindow; 46 NetworkPackageManager *networkPkgWindow;
47 ProgressWidget *progressWindow;
47 48
48 int mnuShowUninstalledPkgsId; 49 int mnuShowUninstalledPkgsId;
49 int mnuShowInstalledPkgsId; 50 int mnuShowInstalledPkgsId;
50 int mnuShowUpgradedPkgsId; 51 int mnuShowUpgradedPkgsId;
51 int mnuFilterByCategory; 52 int mnuFilterByCategory;
52 int mnuSetFilterCategory; 53 int mnuSetFilterCategory;
53 54
54public slots: 55public slots:
55 void setDocument( const QString &doc ); 56 void setDocument( const QString &doc );
56 void displayHelp(); 57 void displayHelp();
57 void searchForPackage(); 58 void searchForPackage();
58 void repeatSearchForPackage(); 59 void repeatSearchForPackage();
59 void displayAbout(); 60 void displayAbout();
60 void displaySettings(); 61 void displaySettings();
61 void filterUninstalledPackages(); 62 void filterUninstalledPackages();
62 void filterInstalledPackages(); 63 void filterInstalledPackages();
63 void filterUpgradedPackages(); 64 void filterUpgradedPackages();
64 void filterCategory(); 65 void filterCategory();
65 void setFilterCategory(); 66 void setFilterCategory();
67 void raiseMainWidget();
68 void raiseProgressWidget();
66 69
70private slots:
71 void init();
67}; 72};
68#endif 73#endif
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp
index 79a380e..cae0d8f 100644
--- a/noncore/settings/aqpkg/networkpkgmgr.cpp
+++ b/noncore/settings/aqpkg/networkpkgmgr.cpp
@@ -1,859 +1,889 @@
1/*************************************************************************** 1/***************************************************************************
2 networkpkgmgr.cpp - description 2 networkpkgmgr.cpp - description
3 ------------------- 3 -------------------
4 begin : Mon Aug 26 13:32:30 BST 2002 4 begin : Mon Aug 26 13:32:30 BST 2002
5 copyright : (C) 2002 by Andy Qua 5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk 6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#include <fstream> 18#include <fstream>
19#include <iostream> 19#include <iostream>
20using namespace std; 20using namespace std;
21 21
22#include <unistd.h> 22#include <unistd.h>
23#include <stdlib.h> 23#include <stdlib.h>
24#include <linux/limits.h> 24#include <linux/limits.h>
25 25
26#ifdef QWS 26#ifdef QWS
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28#include <qpe/qcopenvelope_qws.h> 28#include <qpe/qcopenvelope_qws.h>
29#include <qpe/config.h> 29#include <qpe/config.h>
30#else 30#else
31#include <qapplication.h> 31#include <qapplication.h>
32#endif 32#endif
33#include <qlabel.h> 33#include <qlabel.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qmessagebox.h> 35#include <qmessagebox.h>
36 36
37#include "datamgr.h" 37#include "datamgr.h"
38#include "networkpkgmgr.h" 38#include "networkpkgmgr.h"
39#include "installdlgimpl.h" 39#include "installdlgimpl.h"
40#include "ipkg.h" 40#include "ipkg.h"
41#include "inputdlg.h" 41#include "inputdlg.h"
42#include "letterpushbutton.h" 42#include "letterpushbutton.h"
43#include "categoryfilterimpl.h" 43#include "categoryfilterimpl.h"
44 44
45#include "global.h" 45#include "global.h"
46 46
47extern int compareVersions( const char *v1, const char *v2 ); 47extern int compareVersions( const char *v1, const char *v2 );
48 48
49NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name) 49NetworkPackageManager::NetworkPackageManager( QWidget *parent, const char *name )
50 : QWidget(parent, name) 50 : QWidget(parent, name)
51{ 51{
52 dataMgr = dataManager;
53 52
54#ifdef QWS 53#ifdef QWS
55 // read download directory from config file 54 // read download directory from config file
56 Config cfg( "aqpkg" ); 55 Config cfg( "aqpkg" );
57 cfg.setGroup( "settings" ); 56 cfg.setGroup( "settings" );
58 currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); 57 currentlySelectedServer = cfg.readEntry( "selectedServer", "local" );
59 showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); 58 showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" );
60 59
61#endif 60#endif
62 61
63 showUninstalledPkgs = false; 62 showUninstalledPkgs = false;
64 showInstalledPkgs = false; 63 showInstalledPkgs = false;
65 showUpgradedPkgs = false; 64 showUpgradedPkgs = false;
66 categoryFilterEnabled = false; 65 categoryFilterEnabled = false;
67 66
68 initGui(); 67 initGui();
69 setupConnections(); 68 setupConnections();
70 69
71 updateData(); 70 //updateData();
72} 71}
73 72
74NetworkPackageManager::~NetworkPackageManager() 73NetworkPackageManager::~NetworkPackageManager()
75{ 74{
76} 75}
77 76
78void NetworkPackageManager :: timerEvent ( QTimerEvent * ) 77void NetworkPackageManager :: setDataManager( DataManager *dm )
79{ 78{
80 killTimer( timerId ); 79 dataMgr = dm;
81
82 // Add server names to listbox
83 updateData();
84} 80}
85 81
86void NetworkPackageManager :: updateData() 82void NetworkPackageManager :: updateData()
87{ 83{
84 emit progressSetSteps( dataMgr->getServerList().size() );
85
88 serversList->clear(); 86 serversList->clear();
89 packagesList->clear(); 87 packagesList->clear();
90 88
91
92 vector<Server>::iterator it; 89 vector<Server>::iterator it;
93 int activeItem = -1; 90 int activeItem = -1;
94 int i; 91 int i;
92 QString serverName;
95 for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i ) 93 for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i )
96 { 94 {
95 serverName = it->getServerName();
96 emit progressSetMessage( tr( "Building server list:\n\t%1" ).arg( serverName ) );
97 emit progressUpdate( i );
98 qApp->processEvents();
99
97// cout << "Adding " << it->getServerName() << " to combobox" << endl; 100// cout << "Adding " << it->getServerName() << " to combobox" << endl;
98 if ( !it->isServerActive() ) 101 if ( !it->isServerActive() )
99 { 102 {
100 cout << it->getServerName() << " is not active" << endl; 103 cout << serverName << " is not active" << endl;
101 i--; 104 i--;
102 continue; 105 continue;
103 } 106 }
104 serversList->insertItem( it->getServerName() ); 107
105 if ( it->getServerName() == currentlySelectedServer ) 108 serversList->insertItem( serverName );
109 if ( serverName == currentlySelectedServer )
106 activeItem = i; 110 activeItem = i;
107 } 111 }
108 112
109 // set selected server to be active server 113 // set selected server to be active server
110 if ( activeItem != -1 ) 114 if ( activeItem != -1 )
111 serversList->setCurrentItem( activeItem ); 115 serversList->setCurrentItem( activeItem );
112 serverSelected( 0 ); 116 serverSelected( 0, FALSE );
113} 117}
114 118
115void NetworkPackageManager :: selectLocalPackage( const QString &pkg ) 119void NetworkPackageManager :: selectLocalPackage( const QString &pkg )
116{ 120{
117 // First select local server 121 // First select local server
118 for ( int i = 0 ; i < serversList->count() ; ++i ) 122 for ( int i = 0 ; i < serversList->count() ; ++i )
119 { 123 {
120 if ( serversList->text( i ) == LOCAL_IPKGS ) 124 if ( serversList->text( i ) == LOCAL_IPKGS )
121 { 125 {
122 serversList->setCurrentItem( i ); 126 serversList->setCurrentItem( i );
123 break; 127 break;
124 } 128 }
125 } 129 }
126 serverSelected( 0 ); 130 serverSelected( 0 );
127 131
128 // Now set the check box of the selected package 132 // Now set the check box of the selected package
129 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 133 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
130 item != 0 ; 134 item != 0 ;
131 item = (QCheckListItem *)item->nextSibling() ) 135 item = (QCheckListItem *)item->nextSibling() )
132 { 136 {
133 if ( item->text().startsWith( pkg ) ) 137 if ( item->text().startsWith( pkg ) )
134 { 138 {
135 item->setOn( true ); 139 item->setOn( true );
136 break; 140 break;
137 } 141 }
138 } 142 }
139} 143}
140 144
141 145
142void NetworkPackageManager :: initGui() 146void NetworkPackageManager :: initGui()
143{ 147{
144 QLabel *l = new QLabel( "Servers", this ); 148 QLabel *l = new QLabel( "Servers", this );
145 serversList = new QComboBox( this ); 149 serversList = new QComboBox( this );
146 packagesList = new QListView( this ); 150 packagesList = new QListView( this );
147 update = new QPushButton( "Refresh Lists", this ); 151 update = new QPushButton( "Refresh Lists", this );
148 download = new QPushButton( "Download", this ); 152 download = new QPushButton( "Download", this );
149 upgrade = new QPushButton( "Upgrade", this ); 153 upgrade = new QPushButton( "Upgrade", this );
150 apply = new QPushButton( "Apply", this ); 154 apply = new QPushButton( "Apply", this );
151 155
152 QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1, "VBox" ); 156 QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1, "VBox" );
153 QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1, "HBox1" ); 157 QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1, "HBox1" );
154 hbox1->addWidget( l ); 158 hbox1->addWidget( l );
155 hbox1->addWidget( serversList ); 159 hbox1->addWidget( serversList );
156 160
157 QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1, "HBox1" ); 161 QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1, "HBox1" );
158 QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1, "HBox1" ); 162 QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1, "HBox1" );
159 163
160 164
161 if ( showJumpTo ) 165 if ( showJumpTo )
162 { 166 {
163 char text[2]; 167 char text[2];
164 text[1] = '\0'; 168 text[1] = '\0';
165 for ( int i = 0 ; i < 26 ; ++i ) 169 for ( int i = 0 ; i < 26 ; ++i )
166 { 170 {
167 text[0] = 'A' + i; 171 text[0] = 'A' + i;
168 LetterPushButton *b = new LetterPushButton( text, this ); 172 LetterPushButton *b = new LetterPushButton( text, this );
169 connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); 173 connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) );
170 if ( i < 13 ) 174 if ( i < 13 )
171 hbox3->addWidget( b ); 175 hbox3->addWidget( b );
172 else 176 else
173 hbox4->addWidget( b ); 177 hbox4->addWidget( b );
174 } 178 }
175 } 179 }
176 180
177 vbox->addWidget( packagesList ); 181 vbox->addWidget( packagesList );
178 packagesList->addColumn( "Packages" ); 182 packagesList->addColumn( "Packages" );
179 183
180 QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1, "HBox2" ); 184 QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1, "HBox2" );
181 hbox2->addWidget( update ); 185 hbox2->addWidget( update );
182 hbox2->addWidget( download ); 186 hbox2->addWidget( download );
183 hbox2->addWidget( upgrade ); 187 hbox2->addWidget( upgrade );
184 hbox2->addWidget( apply ); 188 hbox2->addWidget( apply );
185} 189}
186 190
187void NetworkPackageManager :: setupConnections() 191void NetworkPackageManager :: setupConnections()
188{ 192{
189 connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int ))); 193 connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int )));
190 connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) ); 194 connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) );
191 connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) ); 195 connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) );
192 connect( upgrade, SIGNAL( released()), this, SLOT(upgradePackages()) ); 196 connect( upgrade, SIGNAL( released()), this, SLOT(upgradePackages()) );
193 connect( update, SIGNAL(released()), this, SLOT(updateServer()) ); 197 connect( update, SIGNAL(released()), this, SLOT(updateServer()) );
194} 198}
195 199
196void NetworkPackageManager :: showProgressDialog( char *initialText ) 200void NetworkPackageManager :: serverSelected( int index )
197{ 201{
198 if ( !progressDlg ) 202 serverSelected( index, TRUE );
199 progressDlg = new ProgressDlg( this, "Progress", false );
200 progressDlg->setText( initialText );
201 progressDlg->show();
202} 203}
203 204
204 205void NetworkPackageManager :: serverSelected( int, bool raiseProgress )
205void NetworkPackageManager :: serverSelected( int )
206{ 206{
207 packagesList->clear();
208
209 // display packages 207 // display packages
210 QString serverName = serversList->currentText(); 208 QString serverName = serversList->currentText();
211 currentlySelectedServer = serverName; 209 currentlySelectedServer = serverName;
212 210
211 vector<Server>::iterator s = dataMgr->getServer( serverName );
212
213 vector<Package> &list = s->getPackageList();
214 vector<Package>::iterator it;
215
216 // Display progress widget while loading list
217 bool doProgress = ( list.size() > 200 );
218 if ( doProgress )
219 {
220 if ( raiseProgress )
221 {
222 emit appRaiseProgressWidget();
223 }
224 emit progressSetSteps( list.size() );
225 emit progressSetMessage( tr( "Building package list for:\n\t%1" ).arg( serverName ) );
226 }
227
228 packagesList->clear();
229
213#ifdef QWS 230#ifdef QWS
214 // read download directory from config file 231 // read download directory from config file
215 Config cfg( "aqpkg" ); 232 Config cfg( "aqpkg" );
216 cfg.setGroup( "settings" ); 233 cfg.setGroup( "settings" );
217 cfg.writeEntry( "selectedServer", currentlySelectedServer ); 234 cfg.writeEntry( "selectedServer", currentlySelectedServer );
218#endif 235#endif
219 236
220 vector<Server>::iterator s = dataMgr->getServer( serverName ); 237 int i = 0;
221
222 vector<Package> &list = s->getPackageList();
223 vector<Package>::iterator it;
224 for ( it = list.begin() ; it != list.end() ; ++it ) 238 for ( it = list.begin() ; it != list.end() ; ++it )
225 { 239 {
226 240 // Update progress after every 100th package (arbitrary value, seems to give good balance)
241 i++;
242 if ( ( i % 100 ) == 0 )
243 {
244 if ( doProgress )
245 {
246 emit progressUpdate( i );
247 }
248 qApp->processEvents();
249 }
250
227 QString text = ""; 251 QString text = "";
228 252
229 // Apply show only uninstalled packages filter 253 // Apply show only uninstalled packages filter
230 if ( showUninstalledPkgs && it->isInstalled() ) 254 if ( showUninstalledPkgs && it->isInstalled() )
231 continue; 255 continue;
232 256
233 // Apply show only installed packages filter 257 // Apply show only installed packages filter
234 if ( showInstalledPkgs && !it->isInstalled() ) 258 if ( showInstalledPkgs && !it->isInstalled() )
235 continue; 259 continue;
236 260
237 // Apply show only new installed packages filter 261 // Apply show only new installed packages filter
238 if ( showUpgradedPkgs ) 262 if ( showUpgradedPkgs )
239 { 263 {
240 if ( !it->isInstalled() || 264 if ( !it->isInstalled() ||
241 compareVersions( it->getInstalledVersion(), it->getVersion() ) != 1 ) 265 compareVersions( it->getInstalledVersion(), it->getVersion() ) != 1 )
242 continue; 266 continue;
243 } 267 }
244 268
245 // Apply the section filter 269 // Apply the section filter
246 if ( categoryFilterEnabled && categoryFilter != "" ) 270 if ( categoryFilterEnabled && categoryFilter != "" )
247 { 271 {
248 if ( it->getSection() == "" || categoryFilter.find( it->getSection().lower() ) == -1 ) 272 if ( it->getSection() == "" || categoryFilter.find( it->getSection().lower() ) == -1 )
249 continue; 273 continue;
250 } 274 }
251 275
252 // If the local server, only display installed packages 276 // If the local server, only display installed packages
253 if ( serverName == LOCAL_SERVER && !it->isInstalled() ) 277 if ( serverName == LOCAL_SERVER && !it->isInstalled() )
254 continue; 278 continue;
255 279
256 280
257 text += it->getPackageName(); 281 text += it->getPackageName();
258 if ( it->isInstalled() ) 282 if ( it->isInstalled() )
259 { 283 {
260 text += " (installed)"; 284 text += " (installed)";
261 285
262 // If a different version of package is available, postfix it with an * 286 // If a different version of package is available, postfix it with an *
263 if ( it->getVersion() != it->getInstalledVersion() ) 287 if ( it->getVersion() != it->getInstalledVersion() )
264 { 288 {
265 289
266 if ( compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1 ) 290 if ( compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1 )
267 text += "*"; 291 text += "*";
268 } 292 }
269 } 293 }
270 294
271 QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox ); 295 QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox );
272 296
273 if ( it->isInstalled() ) 297 if ( it->isInstalled() )
274 { 298 {
275 QString destName = ""; 299 QString destName = "";
276 if ( it->getLocalPackage() ) 300 if ( it->getLocalPackage() )
277 { 301 {
278 if ( it->getLocalPackage()->getInstalledTo() ) 302 if ( it->getLocalPackage()->getInstalledTo() )
279 destName = it->getLocalPackage()->getInstalledTo()->getDestinationName(); 303 destName = it->getLocalPackage()->getInstalledTo()->getDestinationName();
280 } 304 }
281 else 305 else
282 { 306 {
283 if ( it->getInstalledTo() ) 307 if ( it->getInstalledTo() )
284 destName = it->getInstalledTo()->getDestinationName(); 308 destName = it->getInstalledTo()->getDestinationName();
285 } 309 }
286 if ( destName != "" ) 310 if ( destName != "" )
287 new QCheckListItem( item, QString( "Installed To - " ) + destName ); 311 new QCheckListItem( item, QString( "Installed To - " ) + destName );
288 } 312 }
289 313
290 if ( !it->isPackageStoredLocally() ) 314 if ( !it->isPackageStoredLocally() )
291 { 315 {
292 new QCheckListItem( item, QString( "Description - " ) + it->getDescription() ); 316 new QCheckListItem( item, QString( "Description - " ) + it->getDescription() );
293 new QCheckListItem( item, QString( "Size - " ) + it->getPackageSize() ); 317 new QCheckListItem( item, QString( "Size - " ) + it->getPackageSize() );
294 new QCheckListItem( item, QString( "Section - " ) + it->getSection() ); 318 new QCheckListItem( item, QString( "Section - " ) + it->getSection() );
295 } 319 }
296 else 320 else
297 new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() ); 321 new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() );
298 322
299 if ( serverName == LOCAL_SERVER ) 323 if ( serverName == LOCAL_SERVER )
300 { 324 {
301 new QCheckListItem( item, QString( "V. Installed - " ) + it->getVersion() ); 325 new QCheckListItem( item, QString( "V. Installed - " ) + it->getVersion() );
302 } 326 }
303 else 327 else
304 { 328 {
305 new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() ); 329 new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() );
306 if ( it->getLocalPackage() ) 330 if ( it->getLocalPackage() )
307 { 331 {
308 if ( it->isInstalled() ) 332 if ( it->isInstalled() )
309 new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() ); 333 new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() );
310 } 334 }
311 } 335 }
312 336
313 packagesList->insertItem( item ); 337 packagesList->insertItem( item );
314 } 338 }
315 339
316 // If the local server or the local ipkgs server disable the download button 340 // If the local server or the local ipkgs server disable the download button
317 if ( serverName == LOCAL_SERVER ) 341 if ( serverName == LOCAL_SERVER )
318 { 342 {
319 upgrade->setEnabled( false ); 343 upgrade->setEnabled( false );
320 download->setText( "Download" ); 344 download->setText( "Download" );
321 download->setEnabled( true ); 345 download->setEnabled( true );
322 } 346 }
323 else if ( serverName == LOCAL_IPKGS ) 347 else if ( serverName == LOCAL_IPKGS )
324 { 348 {
325 upgrade->setEnabled( false ); 349 upgrade->setEnabled( false );
326 download->setEnabled( true ); 350 download->setEnabled( true );
327 download->setText( "Remove" ); 351 download->setText( "Remove" );
328 } 352 }
329 else 353 else
330 { 354 {
331 upgrade->setEnabled( true ); 355 upgrade->setEnabled( true );
332 download->setEnabled( true ); 356 download->setEnabled( true );
333 download->setText( "Download" ); 357 download->setText( "Download" );
334 } 358 }
359
360 // Display this widget once everything is done
361 if ( doProgress && raiseProgress )
362 {
363 emit appRaiseMainWidget();
364 }
335} 365}
336 366
337void NetworkPackageManager :: updateServer() 367void NetworkPackageManager :: updateServer()
338{ 368{
339 QString serverName = serversList->currentText(); 369 QString serverName = serversList->currentText();
340 370
341 // Update the current server 371 // Update the current server
342 // Display dialog 372 // Display dialog
343 373
344 // Disable buttons to stop silly people clicking lots on them :) 374 // Disable buttons to stop silly people clicking lots on them :)
345 375
346 // First, write out ipkg_conf file so that ipkg can use it 376 // First, write out ipkg_conf file so that ipkg can use it
347 dataMgr->writeOutIpkgConf(); 377 dataMgr->writeOutIpkgConf();
348 378
349 Ipkg ipkg; 379 Ipkg ipkg;
350 ipkg.setOption( "update" ); 380 ipkg.setOption( "update" );
351 381
352 InstallDlgImpl dlg( &ipkg, "Refreshing server package lists", this, "Upgrade", true ); 382 InstallDlgImpl dlg( &ipkg, "Refreshing server package lists", this, "Upgrade", true );
353 dlg.showDlg(); 383 dlg.showDlg();
354 384
355 // Reload data 385 // Reload data
356 dataMgr->reloadServerData(); 386 dataMgr->reloadServerData();
357 serverSelected(-1); 387 serverSelected(-1);
358// delete progDlg; 388// delete progDlg;
359} 389}
360 390
361void NetworkPackageManager :: upgradePackages() 391void NetworkPackageManager :: upgradePackages()
362{ 392{
363 // We're gonna do an upgrade of all packages 393 // We're gonna do an upgrade of all packages
364 // First warn user that this isn't recommended 394 // First warn user that this isn't recommended
365 QString text = "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n"; 395 QString text = "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n";
366 QMessageBox warn("Warning", text, QMessageBox::Warning, 396 QMessageBox warn("Warning", text, QMessageBox::Warning,
367 QMessageBox::Yes, 397 QMessageBox::Yes,
368 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , 398 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default ,
369 0, this ); 399 0, this );
370 warn.adjustSize(); 400 warn.adjustSize();
371 401
372 if ( warn.exec() == QMessageBox::Yes ) 402 if ( warn.exec() == QMessageBox::Yes )
373 { 403 {
374 // First, write out ipkg_conf file so that ipkg can use it 404 // First, write out ipkg_conf file so that ipkg can use it
375 dataMgr->writeOutIpkgConf(); 405 dataMgr->writeOutIpkgConf();
376 406
377 // Now run upgrade 407 // Now run upgrade
378 Ipkg ipkg; 408 Ipkg ipkg;
379 ipkg.setOption( "upgrade" ); 409 ipkg.setOption( "upgrade" );
380 410
381 InstallDlgImpl dlg( &ipkg, "Upgrading installed packages", this, "Upgrade", true ); 411 InstallDlgImpl dlg( &ipkg, "Upgrading installed packages", this, "Upgrade", true );
382 dlg.showDlg(); 412 dlg.showDlg();
383 413
384 // Reload data 414 // Reload data
385 dataMgr->reloadServerData(); 415 dataMgr->reloadServerData();
386 serverSelected(-1); 416 serverSelected(-1);
387 } 417 }
388} 418}
389 419
390 420
391void NetworkPackageManager :: downloadPackage() 421void NetworkPackageManager :: downloadPackage()
392{ 422{
393 bool doUpdate = true; 423 bool doUpdate = true;
394 if ( download->text() == "Download" ) 424 if ( download->text() == "Download" )
395 { 425 {
396 // See if any packages are selected 426 // See if any packages are selected
397 bool found = false; 427 bool found = false;
398 if ( serversList->currentText() != LOCAL_SERVER ) 428 if ( serversList->currentText() != LOCAL_SERVER )
399 { 429 {
400 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 430 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
401 item != 0 && !found; 431 item != 0 && !found;
402 item = (QCheckListItem *)item->nextSibling() ) 432 item = (QCheckListItem *)item->nextSibling() )
403 { 433 {
404 if ( item->isOn() ) 434 if ( item->isOn() )
405 found = true; 435 found = true;
406 } 436 }
407 } 437 }
408 438
409 // If user selected some packages then download the and store the locally 439 // If user selected some packages then download the and store the locally
410 // otherwise, display dialog asking user what package to download from an http server 440 // otherwise, display dialog asking user what package to download from an http server
411 // and whether to install it 441 // and whether to install it
412 if ( found ) 442 if ( found )
413 downloadSelectedPackages(); 443 downloadSelectedPackages();
414 else 444 else
415 downloadRemotePackage(); 445 downloadRemotePackage();
416 446
417 } 447 }
418 else if ( download->text() == "Remove" ) 448 else if ( download->text() == "Remove" )
419 { 449 {
420 doUpdate = false; 450 doUpdate = false;
421 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 451 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
422 item != 0 ; 452 item != 0 ;
423 item = (QCheckListItem *)item->nextSibling() ) 453 item = (QCheckListItem *)item->nextSibling() )
424 { 454 {
425 if ( item->isOn() ) 455 if ( item->isOn() )
426 { 456 {
427 QString name = item->text(); 457 QString name = item->text();
428 int pos = name.find( "*" ); 458 int pos = name.find( "*" );
429 name.truncate( pos ); 459 name.truncate( pos );
430 460
431 // if (there is a (installed), remove it 461 // if (there is a (installed), remove it
432 pos = name.find( "(installed)" ); 462 pos = name.find( "(installed)" );
433 if ( pos > 0 ) 463 if ( pos > 0 )
434 name.truncate( pos - 1 ); 464 name.truncate( pos - 1 );
435 465
436 Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name ); 466 Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name );
437 467
438 QString msgtext; 468 QString msgtext;
439 msgtext.sprintf( "Are you sure you wish to delete\n%s?", (const char *)p->getPackageName() ); 469 msgtext.sprintf( "Are you sure you wish to delete\n%s?", (const char *)p->getPackageName() );
440 if ( QMessageBox::information( this, "Are you sure?", 470 if ( QMessageBox::information( this, "Are you sure?",
441 msgtext, "No", "Yes" ) == 1 ) 471 msgtext, "No", "Yes" ) == 1 )
442 { 472 {
443 doUpdate = true; 473 doUpdate = true;
444 QFile f( p->getFilename() ); 474 QFile f( p->getFilename() );
445 f.remove(); 475 f.remove();
446 } 476 }
447 } 477 }
448 } 478 }
449 } 479 }
450 480
451 if ( doUpdate ) 481 if ( doUpdate )
452 { 482 {
453 dataMgr->reloadServerData(); 483 dataMgr->reloadServerData();
454 serverSelected( -1 ); 484 serverSelected( -1 );
455 } 485 }
456} 486}
457 487
458void NetworkPackageManager :: downloadSelectedPackages() 488void NetworkPackageManager :: downloadSelectedPackages()
459{ 489{
460 // First, write out ipkg_conf file so that ipkg can use it 490 // First, write out ipkg_conf file so that ipkg can use it
461 dataMgr->writeOutIpkgConf(); 491 dataMgr->writeOutIpkgConf();
462 492
463 // Display dialog to user asking where to download the files to 493 // Display dialog to user asking where to download the files to
464 bool ok = FALSE; 494 bool ok = FALSE;
465 QString dir = ""; 495 QString dir = "";
466#ifdef QWS 496#ifdef QWS
467 // read download directory from config file 497 // read download directory from config file
468 Config cfg( "aqpkg" ); 498 Config cfg( "aqpkg" );
469 cfg.setGroup( "settings" ); 499 cfg.setGroup( "settings" );
470 dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); 500 dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" );
471#endif 501#endif
472 502
473 QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); 503 QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this );
474 if ( ok && !text.isEmpty() ) 504 if ( ok && !text.isEmpty() )
475 dir = text; // user entered something and pressed ok 505 dir = text; // user entered something and pressed ok
476 else 506 else
477 return; // user entered nothing or pressed cancel 507 return; // user entered nothing or pressed cancel
478 508
479#ifdef QWS 509#ifdef QWS
480 // Store download directory in config file 510 // Store download directory in config file
481 cfg.writeEntry( "downloadDir", dir ); 511 cfg.writeEntry( "downloadDir", dir );
482#endif 512#endif
483 513
484 // Get starting directory 514 // Get starting directory
485 char initDir[PATH_MAX]; 515 char initDir[PATH_MAX];
486 getcwd( initDir, PATH_MAX ); 516 getcwd( initDir, PATH_MAX );
487 517
488 // Download each package 518 // Download each package
489 Ipkg ipkg; 519 Ipkg ipkg;
490 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 520 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
491 521
492 ipkg.setOption( "download" ); 522 ipkg.setOption( "download" );
493 ipkg.setRuntimeDirectory( dir ); 523 ipkg.setRuntimeDirectory( dir );
494 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 524 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
495 item != 0 ; 525 item != 0 ;
496 item = (QCheckListItem *)item->nextSibling() ) 526 item = (QCheckListItem *)item->nextSibling() )
497 { 527 {
498 if ( item->isOn() ) 528 if ( item->isOn() )
499 { 529 {
500 QString name = item->text(); 530 QString name = item->text();
501 int pos = name.find( "*" ); 531 int pos = name.find( "*" );
502 name.truncate( pos ); 532 name.truncate( pos );
503 533
504 // if (there is a (installed), remove it 534 // if (there is a (installed), remove it
505 pos = name.find( "(installed)" ); 535 pos = name.find( "(installed)" );
506 if ( pos > 0 ) 536 if ( pos > 0 )
507 name.truncate( pos - 1 ); 537 name.truncate( pos - 1 );
508 538
509 ipkg.setPackage( name ); 539 ipkg.setPackage( name );
510 ipkg.runIpkg( ); 540 ipkg.runIpkg( );
511 } 541 }
512 } 542 }
513} 543}
514 544
515void NetworkPackageManager :: downloadRemotePackage() 545void NetworkPackageManager :: downloadRemotePackage()
516{ 546{
517 // Display dialog 547 // Display dialog
518 bool ok; 548 bool ok;
519 QString package = InputDialog::getText( "Install Remote Package", tr( "Enter package location" ), "http://", &ok, this ); 549 QString package = InputDialog::getText( "Install Remote Package", tr( "Enter package location" ), "http://", &ok, this );
520 if ( !ok || package.isEmpty() ) 550 if ( !ok || package.isEmpty() )
521 return; 551 return;
522// DownloadRemoteDlgImpl dlg( this, "Install", true ); 552// DownloadRemoteDlgImpl dlg( this, "Install", true );
523// if ( dlg.exec() == QDialog::Rejected ) 553// if ( dlg.exec() == QDialog::Rejected )
524// return; 554// return;
525 555
526 // grab details from dialog 556 // grab details from dialog
527// QString package = dlg.getPackageLocation(); 557// QString package = dlg.getPackageLocation();
528 558
529 InstallData item; 559 InstallData item;
530 item.option = "I"; 560 item.option = "I";
531 item.packageName = package; 561 item.packageName = package;
532 vector<InstallData> workingPackages; 562 vector<InstallData> workingPackages;
533 workingPackages.push_back( item ); 563 workingPackages.push_back( item );
534 564
535 InstallDlgImpl dlg2( workingPackages, dataMgr, this, "Install", true ); 565 InstallDlgImpl dlg2( workingPackages, dataMgr, this, "Install", true );
536 dlg2.showDlg(); 566 dlg2.showDlg();
537 567
538 // Reload data 568 // Reload data
539 dataMgr->reloadServerData(); 569 dataMgr->reloadServerData();
540 serverSelected(-1); 570 serverSelected(-1);
541 571
542#ifdef QWS 572#ifdef QWS
543 // Finally let the main system update itself 573 // Finally let the main system update itself
544 QCopEnvelope e("QPE/System", "linkChanged(QString)"); 574 QCopEnvelope e("QPE/System", "linkChanged(QString)");
545 QString lf = QString::null; 575 QString lf = QString::null;
546 e << lf; 576 e << lf;
547#endif 577#endif
548} 578}
549 579
550 580
551void NetworkPackageManager :: applyChanges() 581void NetworkPackageManager :: applyChanges()
552{ 582{
553 stickyOption = ""; 583 stickyOption = "";
554 584
555 // First, write out ipkg_conf file so that ipkg can use it 585 // First, write out ipkg_conf file so that ipkg can use it
556 dataMgr->writeOutIpkgConf(); 586 dataMgr->writeOutIpkgConf();
557 587
558 // Now for each selected item 588 // Now for each selected item
559 // deal with it 589 // deal with it
560 590
561 vector<InstallData> workingPackages; 591 vector<InstallData> workingPackages;
562 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 592 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
563 item != 0 ; 593 item != 0 ;
564 item = (QCheckListItem *)item->nextSibling() ) 594 item = (QCheckListItem *)item->nextSibling() )
565 { 595 {
566 if ( item->isOn() ) 596 if ( item->isOn() )
567 { 597 {
568 InstallData data = dealWithItem( item ); 598 InstallData data = dealWithItem( item );
569 workingPackages.push_back( data ); 599 workingPackages.push_back( data );
570 } 600 }
571 } 601 }
572 602
573 if ( workingPackages.size() == 0 ) 603 if ( workingPackages.size() == 0 )
574 { 604 {
575 // Nothing to do 605 // Nothing to do
576 QMessageBox::information( this, "Nothing to do", 606 QMessageBox::information( this, "Nothing to do",
577 "No packages selected", "OK" ); 607 "No packages selected", "OK" );
578 608
579 return; 609 return;
580 } 610 }
581 611
582 // do the stuff 612 // do the stuff
583 InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true ); 613 InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true );
584 dlg.showDlg(); 614 dlg.showDlg();
585 615
586 // Reload data 616 // Reload data
587 dataMgr->reloadServerData(); 617 dataMgr->reloadServerData();
588 serverSelected(-1); 618 serverSelected(-1);
589 619
590#ifdef QWS 620#ifdef QWS
591 // Finally let the main system update itself 621 // Finally let the main system update itself
592 QCopEnvelope e("QPE/System", "linkChanged(QString)"); 622 QCopEnvelope e("QPE/System", "linkChanged(QString)");
593 QString lf = QString::null; 623 QString lf = QString::null;
594 e << lf; 624 e << lf;
595#endif 625#endif
596} 626}
597 627
598// decide what to do - either remove, upgrade or install 628// decide what to do - either remove, upgrade or install
599// Current rules: 629// Current rules:
600// If not installed - install 630// If not installed - install
601// If installed and different version available - upgrade 631// If installed and different version available - upgrade
602// If installed and version up to date - remove 632// If installed and version up to date - remove
603InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item ) 633InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item )
604{ 634{
605 QString name = item->text(); 635 QString name = item->text();
606 int pos = name.find( "*" ); 636 int pos = name.find( "*" );
607 name.truncate( pos ); 637 name.truncate( pos );
608 638
609 // if (there is a (installed), remove it 639 // if (there is a (installed), remove it
610 pos = name.find( "(installed)" ); 640 pos = name.find( "(installed)" );
611 if ( pos > 0 ) 641 if ( pos > 0 )
612 name.truncate( pos - 1 ); 642 name.truncate( pos - 1 );
613 643
614 // Get package 644 // Get package
615 vector<Server>::iterator s = dataMgr->getServer( serversList->currentText() ); 645 vector<Server>::iterator s = dataMgr->getServer( serversList->currentText() );
616 Package *p = s->getPackage( name ); 646 Package *p = s->getPackage( name );
617 647
618 // If the package has a filename then it is a local file 648 // If the package has a filename then it is a local file
619 if ( p->isPackageStoredLocally() ) 649 if ( p->isPackageStoredLocally() )
620 name = p->getFilename(); 650 name = p->getFilename();
621 651
622 QString option; 652 QString option;
623 QString dest = "root"; 653 QString dest = "root";
624 if ( !p->isInstalled() ) 654 if ( !p->isInstalled() )
625 { 655 {
626 InstallData item; 656 InstallData item;
627 item.option = "I"; 657 item.option = "I";
628 item.packageName = name; 658 item.packageName = name;
629 return item; 659 return item;
630 } 660 }
631 else 661 else
632 { 662 {
633 InstallData item; 663 InstallData item;
634 item.option = "D"; 664 item.option = "D";
635 if ( !p->isPackageStoredLocally() ) 665 if ( !p->isPackageStoredLocally() )
636 item.packageName = p->getInstalledPackageName(); 666 item.packageName = p->getInstalledPackageName();
637 else 667 else
638 item.packageName = name; 668 item.packageName = name;
639 669
640 if ( p->getInstalledTo() ) 670 if ( p->getInstalledTo() )
641 { 671 {
642 item.destination = p->getInstalledTo(); 672 item.destination = p->getInstalledTo();
643 cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl; 673 cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl;
644 cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl; 674 cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl;
645 } 675 }
646 else 676 else
647 { 677 {
648 item.destination = p->getLocalPackage()->getInstalledTo(); 678 item.destination = p->getLocalPackage()->getInstalledTo();
649 } 679 }
650 680
651 // Now see if version is newer or not 681 // Now see if version is newer or not
652 int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); 682 int val = compareVersions( p->getInstalledVersion(), p->getVersion() );
653 683
654 // If the version requested is older and user selected a local ipk file, then reinstall the file 684 // If the version requested is older and user selected a local ipk file, then reinstall the file
655 if ( p->isPackageStoredLocally() && val == -1 ) 685 if ( p->isPackageStoredLocally() && val == -1 )
656 val = 0; 686 val = 0;
657 687
658 if ( val == -2 ) 688 if ( val == -2 )
659 { 689 {
660 // Error - should handle 690 // Error - should handle
661 } 691 }
662 else if ( val == -1 ) 692 else if ( val == -1 )
663 { 693 {
664 // Version available is older - remove only 694 // Version available is older - remove only
665 item.option = "D"; 695 item.option = "D";
666 } 696 }
667 else 697 else
668 { 698 {
669 QString caption; 699 QString caption;
670 QString text; 700 QString text;
671 QString secondButton; 701 QString secondButton;
672 QString secondOption; 702 QString secondOption;
673 if ( val == 0 ) 703 if ( val == 0 )
674 { 704 {
675 // Version available is the same - option to remove or reinstall 705 // Version available is the same - option to remove or reinstall
676 caption = "Do you wish to remove or reinstall\n%s?"; 706 caption = "Do you wish to remove or reinstall\n%s?";
677 text = "Remove or ReInstall"; 707 text = "Remove or ReInstall";
678 secondButton = "ReInstall"; 708 secondButton = "ReInstall";
679 secondOption = "R"; 709 secondOption = "R";
680 } 710 }
681 else if ( val == 1 ) 711 else if ( val == 1 )
682 { 712 {
683 // Version available is newer - option to remove or upgrade 713 // Version available is newer - option to remove or upgrade
684 caption = "Do you wish to remove or upgrade\n%s?"; 714 caption = "Do you wish to remove or upgrade\n%s?";
685 text = "Remove or Upgrade"; 715 text = "Remove or Upgrade";
686 secondButton = "Upgrade"; 716 secondButton = "Upgrade";
687 secondOption = "U"; 717 secondOption = "U";
688 } 718 }
689 719
690 // Sticky option not implemented yet, but will eventually allow 720 // Sticky option not implemented yet, but will eventually allow
691 // the user to say something like 'remove all' 721 // the user to say something like 'remove all'
692 if ( stickyOption == "" ) 722 if ( stickyOption == "" )
693 { 723 {
694 QString msgtext; 724 QString msgtext;
695 msgtext.sprintf( caption, (const char *)name ); 725 msgtext.sprintf( caption, (const char *)name );
696 switch( QMessageBox::information( this, text, 726 switch( QMessageBox::information( this, text,
697 msgtext, "Remove", secondButton ) ) 727 msgtext, "Remove", secondButton ) )
698 { 728 {
699 case 0: // Try again or Enter 729 case 0: // Try again or Enter
700 // option 0 = Remove 730 // option 0 = Remove
701 item.option = "D"; 731 item.option = "D";
702 break; 732 break;
703 case 1: // Quit or Escape 733 case 1: // Quit or Escape
704 item.option = secondOption; 734 item.option = secondOption;
705 break; 735 break;
706 } 736 }
707 } 737 }
708 else 738 else
709 { 739 {
710// item.option = stickyOption; 740// item.option = stickyOption;
711 } 741 }
712 } 742 }
713 743
714 744
715 // Check if we are reinstalling the same version 745 // Check if we are reinstalling the same version
716 if ( item.option != "R" ) 746 if ( item.option != "R" )
717 item.recreateLinks = true; 747 item.recreateLinks = true;
718 else 748 else
719 item.recreateLinks = false; 749 item.recreateLinks = false;
720 750
721 // User hit cancel (on dlg - assume remove) 751 // User hit cancel (on dlg - assume remove)
722 return item; 752 return item;
723 } 753 }
724} 754}
725 755
726void NetworkPackageManager :: displayText( const QString &t ) 756void NetworkPackageManager :: displayText( const QString &t )
727{ 757{
728 cout << t << endl; 758 cout << t << endl;
729} 759}
730 760
731 761
732void NetworkPackageManager :: letterPushed( QString t ) 762void NetworkPackageManager :: letterPushed( QString t )
733{ 763{
734 QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); 764 QCheckListItem *top = (QCheckListItem *)packagesList->firstChild();
735 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); 765 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem();
736 if ( packagesList->firstChild() == 0 ) 766 if ( packagesList->firstChild() == 0 )
737 return; 767 return;
738 768
739 QCheckListItem *item; 769 QCheckListItem *item;
740 if ( start == 0 ) 770 if ( start == 0 )
741 { 771 {
742 item = (QCheckListItem *)packagesList->firstChild(); 772 item = (QCheckListItem *)packagesList->firstChild();
743 start = top; 773 start = top;
744 } 774 }
745 else 775 else
746 item = (QCheckListItem *)start->nextSibling(); 776 item = (QCheckListItem *)start->nextSibling();
747 777
748 if ( item == 0 ) 778 if ( item == 0 )
749 item = (QCheckListItem *)packagesList->firstChild(); 779 item = (QCheckListItem *)packagesList->firstChild();
750 do 780 do
751 { 781 {
752 if ( item->text().lower().startsWith( t.lower() ) ) 782 if ( item->text().lower().startsWith( t.lower() ) )
753 { 783 {
754 packagesList->setSelected( item, true ); 784 packagesList->setSelected( item, true );
755 packagesList->ensureItemVisible( item ); 785 packagesList->ensureItemVisible( item );
756 break; 786 break;
757 } 787 }
758 788
759 item = (QCheckListItem *)item->nextSibling(); 789 item = (QCheckListItem *)item->nextSibling();
760 if ( !item ) 790 if ( !item )
761 item = (QCheckListItem *)packagesList->firstChild(); 791 item = (QCheckListItem *)packagesList->firstChild();
762 } while ( item != start); 792 } while ( item != start);
763} 793}
764 794
765 795
766void NetworkPackageManager :: searchForPackage( bool findNext ) 796void NetworkPackageManager :: searchForPackage( bool findNext )
767{ 797{
768 bool ok = false; 798 bool ok = false;
769 if ( !findNext || lastSearchText.isEmpty() ) 799 if ( !findNext || lastSearchText.isEmpty() )
770 lastSearchText = InputDialog::getText( "Search for package", "Enter package to search for", lastSearchText, &ok, this ).lower(); 800 lastSearchText = InputDialog::getText( "Search for package", "Enter package to search for", lastSearchText, &ok, this ).lower();
771 else 801 else
772 ok = true; 802 ok = true;
773 803
774 if ( ok && !lastSearchText.isEmpty() ) 804 if ( ok && !lastSearchText.isEmpty() )
775 { 805 {
776 cout << "searching for " << lastSearchText << endl; 806 cout << "searching for " << lastSearchText << endl;
777 // look through package list for text startng at current position 807 // look through package list for text startng at current position
778 vector<InstallData> workingPackages; 808 vector<InstallData> workingPackages;
779 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); 809 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem();
780 if ( start != 0 ) 810 if ( start != 0 )
781 start = (QCheckListItem *)start->nextSibling(); 811 start = (QCheckListItem *)start->nextSibling();
782 812
783 if ( start == 0 ) 813 if ( start == 0 )
784 start = (QCheckListItem *)packagesList->firstChild(); 814 start = (QCheckListItem *)packagesList->firstChild();
785 815
786 for ( QCheckListItem *item = start; item != 0 ; 816 for ( QCheckListItem *item = start; item != 0 ;
787 item = (QCheckListItem *)item->nextSibling() ) 817 item = (QCheckListItem *)item->nextSibling() )
788 { 818 {
789 cout << "checking " << item->text().lower() << endl; 819 cout << "checking " << item->text().lower() << endl;
790 if ( item->text().lower().find( lastSearchText ) != -1 ) 820 if ( item->text().lower().find( lastSearchText ) != -1 )
791 { 821 {
792 cout << "matched " << item->text() << endl; 822 cout << "matched " << item->text() << endl;
793 packagesList->ensureItemVisible( item ); 823 packagesList->ensureItemVisible( item );
794 packagesList->setCurrentItem( item ); 824 packagesList->setCurrentItem( item );
795 break; 825 break;
796 } 826 }
797 } 827 }
798 } 828 }
799} 829}
800 830
801void NetworkPackageManager :: showOnlyUninstalledPackages( bool val ) 831void NetworkPackageManager :: showOnlyUninstalledPackages( bool val )
802{ 832{
803 showUninstalledPkgs = val; 833 showUninstalledPkgs = val;
804 serverSelected( -1 ); 834 serverSelected( -1 );
805} 835}
806 836
807void NetworkPackageManager :: showOnlyInstalledPackages( bool val ) 837void NetworkPackageManager :: showOnlyInstalledPackages( bool val )
808{ 838{
809 showInstalledPkgs = val; 839 showInstalledPkgs = val;
810 serverSelected( -1 ); 840 serverSelected( -1 );
811} 841}
812 842
813void NetworkPackageManager :: showUpgradedPackages( bool val ) 843void NetworkPackageManager :: showUpgradedPackages( bool val )
814{ 844{
815 showUpgradedPkgs = val; 845 showUpgradedPkgs = val;
816 serverSelected( -1 ); 846 serverSelected( -1 );
817} 847}
818 848
819bool NetworkPackageManager :: filterByCategory( bool val ) 849bool NetworkPackageManager :: filterByCategory( bool val )
820{ 850{
821 if ( val ) 851 if ( val )
822 { 852 {
823 if ( categoryFilter == "" ) 853 if ( categoryFilter == "" )
824 { 854 {
825 if ( !setFilterCategory() ) 855 if ( !setFilterCategory() )
826 return false; 856 return false;
827 } 857 }
828 858
829 categoryFilterEnabled = true; 859 categoryFilterEnabled = true;
830 serverSelected( -1 ); 860 serverSelected( -1 );
831 return true; 861 return true;
832 } 862 }
833 else 863 else
834 { 864 {
835 // Turn off filter 865 // Turn off filter
836 categoryFilterEnabled = false; 866 categoryFilterEnabled = false;
837 serverSelected( -1 ); 867 serverSelected( -1 );
838 return false; 868 return false;
839 } 869 }
840} 870}
841 871
842bool NetworkPackageManager :: setFilterCategory( ) 872bool NetworkPackageManager :: setFilterCategory( )
843{ 873{
844 // Get categories; 874 // Get categories;
845 CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this ); 875 CategoryFilterImpl dlg( DataManager::getAvailableCategories(), categoryFilter, this );
846 if ( dlg.exec() == QDialog::Accepted ) 876 if ( dlg.exec() == QDialog::Accepted )
847 { 877 {
848 categoryFilter = dlg.getSelectedFilter(); 878 categoryFilter = dlg.getSelectedFilter();
849 879
850 if ( categoryFilter == "" ) 880 if ( categoryFilter == "" )
851 return false; 881 return false;
852 882
853 categoryFilterEnabled = true; 883 categoryFilterEnabled = true;
854 serverSelected( -1 ); 884 serverSelected( -1 );
855 return true; 885 return true;
856 } 886 }
857 887
858 return false; 888 return false;
859} 889}
diff --git a/noncore/settings/aqpkg/networkpkgmgr.h b/noncore/settings/aqpkg/networkpkgmgr.h
index 46919d7..2206c81 100644
--- a/noncore/settings/aqpkg/networkpkgmgr.h
+++ b/noncore/settings/aqpkg/networkpkgmgr.h
@@ -1,92 +1,100 @@
1/*************************************************************************** 1/***************************************************************************
2 networkpkgmgr.h - description 2 networkpkgmgr.h - description
3 ------------------- 3 -------------------
4 begin : Mon Aug 26 13:32:30 BST 2002 4 begin : Mon Aug 26 13:32:30 BST 2002
5 copyright : (C) 2002 by Andy Qua 5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk 6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#ifndef NETWORKPKGMGR_H 18#ifndef NETWORKPKGMGR_H
19#define NETWORKPKGMGR_H 19#define NETWORKPKGMGR_H
20 20
21#include <qlayout.h> 21#include <qlayout.h>
22#include <qpushbutton.h> 22#include <qpushbutton.h>
23#include <qwidget.h> 23#include <qwidget.h>
24#include <qcombobox.h> 24#include <qcombobox.h>
25#include <qlistview.h> 25#include <qlistview.h>
26 26
27#include "datamgr.h" 27#include "datamgr.h"
28#include "progressdlg.h" 28#include "progressdlg.h"
29
29class InstallData; 30class InstallData;
30 31
31/** NetworkPackageManager is the base class of the project */ 32/** NetworkPackageManager is the base class of the project */
32class NetworkPackageManager : public QWidget 33class NetworkPackageManager : public QWidget
33{ 34{
34 Q_OBJECT 35 Q_OBJECT
35public: 36public:
36 /** construtor */ 37 /** construtor */
37 NetworkPackageManager( DataManager *dataManager, QWidget* parent=0, const char *name=0); 38 NetworkPackageManager( QWidget* parent=0, const char *name=0 );
38 /** destructor */ 39 /** destructor */
39 ~NetworkPackageManager(); 40 ~NetworkPackageManager();
40 41
42 void setDataManager( DataManager *dm );
41 void selectLocalPackage( const QString &pkg ); 43 void selectLocalPackage( const QString &pkg );
42 void updateData(); 44 void updateData();
43 void searchForPackage( bool findNext ); 45 void searchForPackage( bool findNext );
44 void showOnlyUninstalledPackages( bool val ); 46 void showOnlyUninstalledPackages( bool val );
45 void showOnlyInstalledPackages( bool val ); 47 void showOnlyInstalledPackages( bool val );
46 void showUpgradedPackages( bool val ); 48 void showUpgradedPackages( bool val );
47 bool filterByCategory( bool val ); 49 bool filterByCategory( bool val );
48 bool setFilterCategory(); 50 bool setFilterCategory();
49 51
50private: 52private:
51 DataManager *dataMgr; 53 DataManager *dataMgr;
52 54
53 QComboBox *serversList; 55 QComboBox *serversList;
54 QListView *packagesList; 56 QListView *packagesList;
55 QPushButton *update; 57 QPushButton *update;
56 QPushButton *upgrade; 58 QPushButton *upgrade;
57 QPushButton *download; 59 QPushButton *download;
58 QPushButton *apply; 60 QPushButton *apply;
59 61
60 ProgressDlg *progressDlg; 62 ProgressDlg *progressDlg;
61 QString currentlySelectedServer; 63 QString currentlySelectedServer;
62 QString lastSearchText; 64 QString lastSearchText;
63 QString categoryFilter; 65 QString categoryFilter;
64 66
65 bool categoryFilterEnabled; 67 bool categoryFilterEnabled;
66 bool showJumpTo; 68 bool showJumpTo;
67 bool showUninstalledPkgs; 69 bool showUninstalledPkgs;
68 bool showInstalledPkgs; 70 bool showInstalledPkgs;
69 bool showUpgradedPkgs; 71 bool showUpgradedPkgs;
70 int timerId;
71
72 void timerEvent ( QTimerEvent * );
73 72
74 void initGui(); 73 void initGui();
75 void setupConnections(); 74 void setupConnections();
76 void showProgressDialog( char *initialText ); 75 void showProgressDialog( char *initialText );
77 void downloadSelectedPackages(); 76 void downloadSelectedPackages();
78 void downloadRemotePackage(); 77 void downloadRemotePackage();
78 void serverSelected( int index, bool showProgress );
79
79 InstallData dealWithItem( QCheckListItem *item ); 80 InstallData dealWithItem( QCheckListItem *item );
80 QString stickyOption; 81 QString stickyOption;
81 82
83signals:
84 void appRaiseMainWidget();
85 void appRaiseProgressWidget();
86 void progressSetSteps( int );
87 void progressSetMessage( const QString & );
88 void progressUpdate( int );
89
82public slots: 90public slots:
83 void serverSelected( int index );
84 void applyChanges(); 91 void applyChanges();
85 void upgradePackages(); 92 void upgradePackages();
86 void downloadPackage(); 93 void downloadPackage();
87 void updateServer(); 94 void updateServer();
88 void displayText( const QString &t ); 95 void displayText( const QString &t );
89 void letterPushed( QString t ); 96 void letterPushed( QString t );
97 void serverSelected( int index );
90}; 98};
91 99
92#endif 100#endif
diff --git a/noncore/settings/aqpkg/progresswidget.cpp b/noncore/settings/aqpkg/progresswidget.cpp
new file mode 100644
index 0000000..bbafcac
--- a/dev/null
+++ b/noncore/settings/aqpkg/progresswidget.cpp
@@ -0,0 +1,66 @@
1/*
2                This file is part of the OPIE Project
3 =.
4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org>
5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29#include "progresswidget.h"
30
31#include <qlabel.h>
32#include <qlayout.h>
33#include <qprogressbar.h>
34
35ProgressWidget::ProgressWidget( QWidget *parent, const char *name, WFlags f )
36 : QWidget( parent, name, f )
37{
38 QVBoxLayout *layout = new QVBoxLayout( this, 4, 4 );
39
40 m_status = new QLabel( this );
41 m_status->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
42 layout->addWidget( m_status );
43
44 m_progress = new QProgressBar( this );
45 layout->addWidget( m_progress );
46}
47
48ProgressWidget::~ProgressWidget()
49{
50}
51
52void ProgressWidget::setSteps( int numsteps )
53{
54 m_progress->setTotalSteps( numsteps );
55}
56
57void ProgressWidget::setMessage( const QString &msg )
58{
59 m_status->setText( msg );
60}
61
62void ProgressWidget::update( int progress )
63{
64 m_progress->setProgress( progress );
65}
66
diff --git a/noncore/settings/aqpkg/progresswidget.h b/noncore/settings/aqpkg/progresswidget.h
new file mode 100644
index 0000000..7d99978
--- a/dev/null
+++ b/noncore/settings/aqpkg/progresswidget.h
@@ -0,0 +1,54 @@
1/*
2                This file is part of the OPIE Project
3 =.
4             .=l. Copyright (c) 2002 Dan Williams <drw@handhelds.org>
5           .>+-=
6 _;:,     .>    :=|. This file is free software; you can
7.> <`_,   >  .   <= redistribute it and/or modify it under
8:`=1 )Y*s>-.--   : the terms of the GNU General Public
9.="- .-=="i,     .._ License as published by the Free Software
10 - .   .-<_>     .<> Foundation; either version 2 of the License,
11     ._= =}       : or (at your option) any later version.
12    .%`+i>       _;_.
13    .i_,=:_.      -<s. This file is distributed in the hope that
14     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
15    : ..    .:,     . . . without even the implied warranty of
16    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
17  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
18..}^=.=       =       ; Public License for more details.
19++=   -.     .`     .:
20 :     =  ...= . :.=- You should have received a copy of the GNU
21 -.   .:....=;==+<; General Public License along with this file;
22  -_. . .   )=.  = see the file COPYING. If not, write to the
23    --        :-=` Free Software Foundation, Inc.,
24 59 Temple Place - Suite 330,
25 Boston, MA 02111-1307, USA.
26
27*/
28
29#ifndef PROGRESSWIDGET_H
30#define PROGRESSWIDGET_H
31
32#include <qwidget.h>
33
34class QLabel;
35class QProgressBar;
36
37class ProgressWidget : public QWidget
38{
39 Q_OBJECT
40public:
41 ProgressWidget( QWidget * = 0, const char * = 0, WFlags = 0 );
42 ~ProgressWidget();
43
44private:
45 QLabel *m_status;
46 QProgressBar *m_progress;
47
48public slots:
49 void setSteps( int );
50 void setMessage( const QString & );
51 void update( int );
52};
53
54#endif