summaryrefslogtreecommitdiff
authorandyq <andyq>2002-11-01 12:41:03 (UTC)
committer andyq <andyq>2002-11-01 12:41:03 (UTC)
commit0e34499726f7fa275363988ea466d13aab09f544 (patch) (unidiff)
tree20403963ae3c1b315c2d1fd4b23a33754289287c
parent4c5a56dbaddb3ac6b587c61a8ba6841987cf60fa (diff)
downloadopie-0e34499726f7fa275363988ea466d13aab09f544.zip
opie-0e34499726f7fa275363988ea466d13aab09f544.tar.gz
opie-0e34499726f7fa275363988ea466d13aab09f544.tar.bz2
Fixed a bug where if a package was removed from the local view the packages didn't get relinked properly
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/datamgr.cpp34
-rw-r--r--noncore/settings/aqpkg/datamgr.h2
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.cpp32
3 files changed, 36 insertions, 32 deletions
diff --git a/noncore/settings/aqpkg/datamgr.cpp b/noncore/settings/aqpkg/datamgr.cpp
index 089c3e3..f342aff 100644
--- a/noncore/settings/aqpkg/datamgr.cpp
+++ b/noncore/settings/aqpkg/datamgr.cpp
@@ -1,209 +1,209 @@
1/*************************************************************************** 1/***************************************************************************
2 datamgr.cpp - description 2 datamgr.cpp - description
3 ------------------- 3 -------------------
4 begin : Thu Aug 29 2002 4 begin : Thu Aug 29 2002
5 copyright : (C) 2002 by Andy Qua 5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk 6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17#include <fstream> 17#include <fstream>
18#include <iostream> 18#include <iostream>
19using namespace std; 19using namespace std;
20 20
21#ifdef QWS 21#ifdef QWS
22#include <qpe/config.h> 22#include <qpe/config.h>
23#endif 23#endif
24 24
25#include <stdio.h> 25#include <stdio.h>
26 26
27#include "datamgr.h" 27#include "datamgr.h"
28#include "global.h" 28#include "global.h"
29 29
30 30
31DataManager::DataManager() 31DataManager::DataManager()
32{ 32{
33 activeServer = ""; 33 activeServer = "";
34} 34}
35 35
36DataManager::~DataManager() 36DataManager::~DataManager()
37{ 37{
38} 38}
39 39
40Server *DataManager :: getServer( const char *name ) 40Server *DataManager :: getServer( const char *name )
41{ 41{
42 Server *s = 0; 42 Server *s = 0;
43 vector<Server>::iterator it = serverList.begin(); 43 vector<Server>::iterator it = serverList.begin();
44 while ( it != serverList.end() && s == 0 ) 44 while ( it != serverList.end() && s == 0 )
45 { 45 {
46 if ( it->getServerName() == name ) 46 if ( it->getServerName() == name )
47 s = &(*it); 47 s = &(*it);
48 48
49 ++it; 49 ++it;
50 } 50 }
51 51
52 return s; 52 return s;
53} 53}
54 54
55Destination *DataManager :: getDestination( const char *name ) 55Destination *DataManager :: getDestination( const char *name )
56{ 56{
57 Destination *d = 0; 57 Destination *d = 0;
58 vector<Destination>::iterator it = destList.begin(); 58 vector<Destination>::iterator it = destList.begin();
59 while ( it != destList.end() && d == 0 ) 59 while ( it != destList.end() && d == 0 )
60 { 60 {
61 if ( it->getDestinationName() == name ) 61 if ( it->getDestinationName() == name )
62 d = &(*it); 62 d = &(*it);
63 63
64 ++it; 64 ++it;
65 } 65 }
66 66
67 return d; 67 return d;
68} 68}
69 69
70void DataManager :: loadServers() 70void DataManager :: loadServers()
71{ 71{
72 // First add our local server - not really a server but 72 // First add our local server - not really a server but
73 // the local config (which packages are installed) 73 // the local config (which packages are installed)
74 serverList.push_back( Server( LOCAL_SERVER, "" ) ); 74 serverList.push_back( Server( LOCAL_SERVER, "" ) );
75 serverList.push_back( Server( LOCAL_IPKGS, "" ) ); 75 serverList.push_back( Server( LOCAL_IPKGS, "" ) );
76 76
77#ifdef QWS 77#ifdef QWS
78 Config cfg( "aqpkg" ); 78 Config cfg( "aqpkg" );
79 cfg.setGroup( "destinations" ); 79 cfg.setGroup( "destinations" );
80#endif 80#endif
81 81
82 // Read file from /etc/ipkg.conf 82 // Read file from /etc/ipkg.conf
83 QString ipkg_conf = IPKG_CONF; 83 QString ipkg_conf = IPKG_CONF;
84 FILE *fp; 84 FILE *fp;
85 fp = fopen( ipkg_conf, "r" ); 85 fp = fopen( ipkg_conf, "r" );
86 char line[130]; 86 char line[130];
87 QString lineStr; 87 QString lineStr;
88 if ( fp == NULL ) 88 if ( fp == NULL )
89 { 89 {
90 cout << "Couldn't open " << ipkg_conf << "! err = " << fp << endl; 90 cout << "Couldn't open " << ipkg_conf << "! err = " << fp << endl;
91 return; 91 return;
92 } 92 }
93 else 93 else
94 { 94 {
95 while ( fgets( line, sizeof line, fp) != NULL ) 95 while ( fgets( line, sizeof line, fp) != NULL )
96 { 96 {
97 lineStr = line; 97 lineStr = line;
98 if ( lineStr.startsWith( "src" ) || lineStr.startsWith( "#src" ) || lineStr.startsWith( "# src" ) ) 98 if ( lineStr.startsWith( "src" ) || lineStr.startsWith( "#src" ) || lineStr.startsWith( "# src" ) )
99 { 99 {
100 char alias[20]; 100 char alias[20];
101 char url[100]; 101 char url[100];
102 102
103 103
104 // Looks a little wierd but read up to the r of src (throwing it away), 104 // Looks a little wierd but read up to the r of src (throwing it away),
105 // then read up to the next space and throw that away, the alias 105 // then read up to the next space and throw that away, the alias
106 // is next. 106 // is next.
107 // Should Handle #src, # src, src, and combinations of 107 // Should Handle #src, # src, src, and combinations of
108 sscanf( lineStr, "%*[^r]%*[^ ] %s %s", alias, url ); 108 sscanf( lineStr, "%*[^r]%*[^ ] %s %s", alias, url );
109 Server s( alias, url ); 109 Server s( alias, url );
110 if ( lineStr.startsWith( "src" ) ) 110 if ( lineStr.startsWith( "src" ) )
111 s.setActive( true ); 111 s.setActive( true );
112 else 112 else
113 s.setActive( false ); 113 s.setActive( false );
114 114
115 serverList.push_back( s ); 115 serverList.push_back( s );
116 116
117 } 117 }
118 else if ( lineStr.startsWith( "dest" ) ) 118 else if ( lineStr.startsWith( "dest" ) )
119 { 119 {
120 char alias[20]; 120 char alias[20];
121 char path[50]; 121 char path[50];
122 sscanf( lineStr, "%*[^ ] %s %s", alias, path ); 122 sscanf( lineStr, "%*[^ ] %s %s", alias, path );
123 Destination d( alias, path ); 123 Destination d( alias, path );
124 bool linkToRoot = true; 124 bool linkToRoot = true;
125#ifdef QWS 125#ifdef QWS
126 QString key = alias; 126 QString key = alias;
127 key += "_linkToRoot"; 127 key += "_linkToRoot";
128 linkToRoot = cfg.readBoolEntry( key, true ); 128 linkToRoot = cfg.readBoolEntry( key, true );
129#endif 129#endif
130 d.linkToRoot( linkToRoot ); 130 d.linkToRoot( linkToRoot );
131 131
132 destList.push_back( d ); 132 destList.push_back( d );
133 } 133 }
134 } 134 }
135 } 135 }
136 fclose( fp ); 136 fclose( fp );
137 137
138 vector<Server>::iterator it; 138 reloadServerData( );
139 for ( it = serverList.begin() ; it != serverList.end() ; ++it )
140 reloadServerData( it->getServerName() );
141} 139}
142 140
143void DataManager :: reloadServerData( const char *serverName ) 141void DataManager :: reloadServerData( )
144{ 142{
145 Server *s = getServer( serverName ); 143 vector<Server>::iterator it = serverList.begin();
146 // Now we've read the config file in we need to read the servers 144 for ( it = serverList.begin() ; it != serverList.end() ; ++it )
147 // The local server is a special case. This holds the contents of the 145 {
148 // status files the number of which depends on how many destinations 146 // Now we've read the config file in we need to read the servers
149 // we've set up 147 // The local server is a special case. This holds the contents of the
150 // The other servers files hold the contents of the server package list 148 // status files the number of which depends on how many destinations
151 if ( s->getServerName() == LOCAL_SERVER ) 149 // we've set up
152 s->readStatusFile( destList ); 150 // The other servers files hold the contents of the server package list
153 else if ( s->getServerName() == LOCAL_IPKGS ) 151 if ( it->getServerName() == LOCAL_SERVER )
154 s->readLocalIpks( getServer( LOCAL_SERVER ) ); 152 it->readStatusFile( destList );
155 else 153 else if ( it->getServerName() == LOCAL_IPKGS )
156 s->readPackageFile( getServer( LOCAL_SERVER ) ); 154 it->readLocalIpks( getServer( LOCAL_SERVER ) );
157 155 else
156 it->readPackageFile( getServer( LOCAL_SERVER ) );
157 }
158} 158}
159 159
160void DataManager :: writeOutIpkgConf() 160void DataManager :: writeOutIpkgConf()
161{ 161{
162 QString ipkg_conf = IPKG_CONF; 162 QString ipkg_conf = IPKG_CONF;
163 ofstream out( ipkg_conf ); 163 ofstream out( ipkg_conf );
164 164
165 out << "# Written by AQPkg" << endl; 165 out << "# Written by AQPkg" << endl;
166 out << "# Must have one or more source entries of the form:" << endl; 166 out << "# Must have one or more source entries of the form:" << endl;
167 out << "#" << endl; 167 out << "#" << endl;
168 out << "# src <src-name> <source-url>" << endl; 168 out << "# src <src-name> <source-url>" << endl;
169 out << "#" << endl; 169 out << "#" << endl;
170 out << "# and one or more destination entries of the form:" << endl; 170 out << "# and one or more destination entries of the form:" << endl;
171 out << "#" << endl; 171 out << "#" << endl;
172 out << "# dest <dest-name> <target-path>" << endl; 172 out << "# dest <dest-name> <target-path>" << endl;
173 out << "#" << endl; 173 out << "#" << endl;
174 out << "# where <src-name> and <dest-names> are identifiers that" << endl; 174 out << "# where <src-name> and <dest-names> are identifiers that" << endl;
175 out << "# should match [a-zA-Z0-9._-]+, <source-url> should be a" << endl; 175 out << "# should match [a-zA-Z0-9._-]+, <source-url> should be a" << endl;
176 out << "# URL that points to a directory containing a Familiar" << endl; 176 out << "# URL that points to a directory containing a Familiar" << endl;
177 out << "# Packages file, and <target-path> should be a directory" << endl; 177 out << "# Packages file, and <target-path> should be a directory" << endl;
178 out << "# that exists on the target system." << endl << endl; 178 out << "# that exists on the target system." << endl << endl;
179 179
180 // Write out servers 180 // Write out servers
181 vector<Server>::iterator it = serverList.begin(); 181 vector<Server>::iterator it = serverList.begin();
182 while ( it != serverList.end() ) 182 while ( it != serverList.end() )
183 { 183 {
184 QString alias = it->getServerName(); 184 QString alias = it->getServerName();
185 // Don't write out local as its a dummy 185 // Don't write out local as its a dummy
186 if ( alias != LOCAL_SERVER && alias != LOCAL_IPKGS ) 186 if ( alias != LOCAL_SERVER && alias != LOCAL_IPKGS )
187 { 187 {
188 QString url = it->getServerUrl();; 188 QString url = it->getServerUrl();;
189 189
190 if ( !it->isServerActive() ) 190 if ( !it->isServerActive() )
191 out << "#"; 191 out << "#";
192 out << "src " << alias << " " << url << endl; 192 out << "src " << alias << " " << url << endl;
193 } 193 }
194 194
195 it++; 195 it++;
196 } 196 }
197 197
198 out << endl; 198 out << endl;
199 199
200 // Write out destinations 200 // Write out destinations
201 vector<Destination>::iterator it2 = destList.begin(); 201 vector<Destination>::iterator it2 = destList.begin();
202 while ( it2 != destList.end() ) 202 while ( it2 != destList.end() )
203 { 203 {
204 out << "dest " << it2->getDestinationName() << " " << it2->getDestinationPath() << endl; 204 out << "dest " << it2->getDestinationName() << " " << it2->getDestinationPath() << endl;
205 it2++; 205 it2++;
206 } 206 }
207 207
208 out.close(); 208 out.close();
209} 209}
diff --git a/noncore/settings/aqpkg/datamgr.h b/noncore/settings/aqpkg/datamgr.h
index eb802b5..8c6fb0d 100644
--- a/noncore/settings/aqpkg/datamgr.h
+++ b/noncore/settings/aqpkg/datamgr.h
@@ -1,64 +1,64 @@
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 "server.h" 24#include "server.h"
25#include "destination.h" 25#include "destination.h"
26 26
27 #define LOCAL_SERVER "Installed Pkgs" 27 #define LOCAL_SERVER "Installed Pkgs"
28 #define LOCAL_IPKGS "local IPKG" 28 #define LOCAL_IPKGS "local IPKG"
29 29
30/** 30/**
31 *@author Andy Qua 31 *@author Andy Qua
32 */ 32 */
33 33
34 34
35class DataManager 35class DataManager
36{ 36{
37public: 37public:
38 DataManager(); 38 DataManager();
39 ~DataManager(); 39 ~DataManager();
40 40
41 void setActiveServer( const QString &act ) { activeServer = act; } 41 void setActiveServer( const QString &act ) { activeServer = act; }
42 QString &getActiveServer( ) { return activeServer; } 42 QString &getActiveServer( ) { return activeServer; }
43 43
44 Server *getLocalServer() { return getServer( LOCAL_SERVER ); } 44 Server *getLocalServer() { return getServer( LOCAL_SERVER ); }
45 vector<Server> &getServerList() { return serverList; } 45 vector<Server> &getServerList() { return serverList; }
46 Server *getServer( const char *name ); 46 Server *getServer( const char *name );
47 47
48 vector<Destination> &getDestinationList() { return destList; } 48 vector<Destination> &getDestinationList() { return destList; }
49 Destination *getDestination( const char *name ); 49 Destination *getDestination( const char *name );
50 50
51 void loadServers(); 51 void loadServers();
52 void reloadServerData( const char *sn ); 52 void reloadServerData( );
53 53
54 void writeOutIpkgConf(); 54 void writeOutIpkgConf();
55 55
56 56
57private: 57private:
58 QString activeServer; 58 QString activeServer;
59 59
60 vector<Server> serverList; 60 vector<Server> serverList;
61 vector<Destination> destList; 61 vector<Destination> destList;
62}; 62};
63 63
64#endif 64#endif
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp
index 02e4e73..b5d7352 100644
--- a/noncore/settings/aqpkg/networkpkgmgr.cpp
+++ b/noncore/settings/aqpkg/networkpkgmgr.cpp
@@ -1,647 +1,651 @@
1/*************************************************************************** 1/***************************************************************************
2 networkpkgmgr.cpp - description 2 networkpkgmgr.cpp - description
3 ------------------- 3 -------------------
4 begin : Mon Aug 26 13:32:30 BST 2002 4 begin : Mon Aug 26 13:32:30 BST 2002
5 copyright : (C) 2002 by Andy Qua 5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk 6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#include <fstream> 18#include <fstream>
19#include <iostream> 19#include <iostream>
20using namespace std; 20using namespace std;
21 21
22#include <unistd.h> 22#include <unistd.h>
23#include <stdlib.h> 23#include <stdlib.h>
24#include <linux/limits.h> 24#include <linux/limits.h>
25 25
26#ifdef QWS 26#ifdef QWS
27#include <qpe/qpeapplication.h> 27#include <qpe/qpeapplication.h>
28#include <qpe/qcopenvelope_qws.h> 28#include <qpe/qcopenvelope_qws.h>
29#include <qpe/config.h> 29#include <qpe/config.h>
30#else 30#else
31#include <qapplication.h> 31#include <qapplication.h>
32#endif 32#endif
33#include <qlabel.h> 33#include <qlabel.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qmessagebox.h> 35#include <qmessagebox.h>
36 36
37#include "datamgr.h" 37#include "datamgr.h"
38#include "networkpkgmgr.h" 38#include "networkpkgmgr.h"
39#include "installdlgimpl.h" 39#include "installdlgimpl.h"
40#include "ipkg.h" 40#include "ipkg.h"
41#include "inputdlg.h" 41#include "inputdlg.h"
42#include "letterpushbutton.h" 42#include "letterpushbutton.h"
43 43
44#include "global.h" 44#include "global.h"
45 45
46extern int compareVersions( const char *v1, const char *v2 ); 46extern int compareVersions( const char *v1, const char *v2 );
47 47
48NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name) 48NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name)
49 : QWidget(parent, name) 49 : QWidget(parent, name)
50{ 50{
51 dataMgr = dataManager; 51 dataMgr = dataManager;
52 52
53#ifdef QWS 53#ifdef QWS
54 // read download directory from config file 54 // read download directory from config file
55 Config cfg( "aqpkg" ); 55 Config cfg( "aqpkg" );
56 cfg.setGroup( "settings" ); 56 cfg.setGroup( "settings" );
57 currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); 57 currentlySelectedServer = cfg.readEntry( "selectedServer", "local" );
58 showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); 58 showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" );
59#endif 59#endif
60 60
61 61
62 initGui(); 62 initGui();
63 setupConnections(); 63 setupConnections();
64 64
65 updateData(); 65 updateData();
66// progressDlg = 0; 66// progressDlg = 0;
67// timerId = startTimer( 100 ); 67// timerId = startTimer( 100 );
68} 68}
69 69
70NetworkPackageManager::~NetworkPackageManager() 70NetworkPackageManager::~NetworkPackageManager()
71{ 71{
72} 72}
73 73
74void NetworkPackageManager :: timerEvent ( QTimerEvent * ) 74void NetworkPackageManager :: timerEvent ( QTimerEvent * )
75{ 75{
76 killTimer( timerId ); 76 killTimer( timerId );
77 77
78// showProgressDialog(); 78// showProgressDialog();
79 // Add server names to listbox 79 // Add server names to listbox
80 updateData(); 80 updateData();
81 81
82// progressDlg->hide(); 82// progressDlg->hide();
83} 83}
84 84
85void NetworkPackageManager :: updateData() 85void NetworkPackageManager :: updateData()
86{ 86{
87 serversList->clear(); 87 serversList->clear();
88 packagesList->clear(); 88 packagesList->clear();
89 89
90 90
91 vector<Server>::iterator it; 91 vector<Server>::iterator it;
92 int activeItem = -1; 92 int activeItem = -1;
93 int i; 93 int i;
94 for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i ) 94 for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i )
95 { 95 {
96 if ( !it->isServerActive() ) 96 if ( !it->isServerActive() )
97 { 97 {
98 i--; 98 i--;
99 continue; 99 continue;
100 } 100 }
101 serversList->insertItem( it->getServerName() ); 101 serversList->insertItem( it->getServerName() );
102 if ( it->getServerName() == currentlySelectedServer ) 102 if ( it->getServerName() == currentlySelectedServer )
103 activeItem = i; 103 activeItem = i;
104 } 104 }
105 105
106 // set selected server to be active server 106 // set selected server to be active server
107 if ( activeItem != -1 ) 107 if ( activeItem != -1 )
108 serversList->setCurrentItem( activeItem ); 108 serversList->setCurrentItem( activeItem );
109 serverSelected( 0 ); 109 serverSelected( 0 );
110} 110}
111 111
112void NetworkPackageManager :: selectLocalPackage( const QString &pkg ) 112void NetworkPackageManager :: selectLocalPackage( const QString &pkg )
113{ 113{
114 // First select local server 114 // First select local server
115 for ( int i = 0 ; i < serversList->count() ; ++i ) 115 for ( int i = 0 ; i < serversList->count() ; ++i )
116 { 116 {
117 if ( serversList->text( i ) == LOCAL_IPKGS ) 117 if ( serversList->text( i ) == LOCAL_IPKGS )
118 { 118 {
119 serversList->setCurrentItem( i ); 119 serversList->setCurrentItem( i );
120 break; 120 break;
121 } 121 }
122 } 122 }
123 serverSelected( 0 ); 123 serverSelected( 0 );
124 124
125 // Now set the check box of the selected package 125 // Now set the check box of the selected package
126 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 126 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
127 item != 0 ; 127 item != 0 ;
128 item = (QCheckListItem *)item->nextSibling() ) 128 item = (QCheckListItem *)item->nextSibling() )
129 { 129 {
130 if ( item->text().startsWith( pkg ) ) 130 if ( item->text().startsWith( pkg ) )
131 { 131 {
132 item->setOn( true ); 132 item->setOn( true );
133 break; 133 break;
134 } 134 }
135 } 135 }
136} 136}
137 137
138 138
139void NetworkPackageManager :: initGui() 139void NetworkPackageManager :: initGui()
140{ 140{
141 QLabel *l = new QLabel( "Servers", this ); 141 QLabel *l = new QLabel( "Servers", this );
142 serversList = new QComboBox( this ); 142 serversList = new QComboBox( this );
143 packagesList = new QListView( this ); 143 packagesList = new QListView( this );
144 update = new QPushButton( "Refresh List", this ); 144 update = new QPushButton( "Refresh List", this );
145 download = new QPushButton( "Download", this ); 145 download = new QPushButton( "Download", this );
146 upgrade = new QPushButton( "Upgrade", this ); 146 upgrade = new QPushButton( "Upgrade", this );
147 apply = new QPushButton( "Apply", this ); 147 apply = new QPushButton( "Apply", this );
148 148
149 QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1, "VBox" ); 149 QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1, "VBox" );
150 QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1, "HBox1" ); 150 QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1, "HBox1" );
151 hbox1->addWidget( l ); 151 hbox1->addWidget( l );
152 hbox1->addWidget( serversList ); 152 hbox1->addWidget( serversList );
153 153
154 QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1, "HBox1" ); 154 QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1, "HBox1" );
155 QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1, "HBox1" ); 155 QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1, "HBox1" );
156 156
157 157
158 if ( showJumpTo ) 158 if ( showJumpTo )
159 { 159 {
160 char text[2]; 160 char text[2];
161 text[1] = '\0'; 161 text[1] = '\0';
162 for ( int i = 0 ; i < 26 ; ++i ) 162 for ( int i = 0 ; i < 26 ; ++i )
163 { 163 {
164 text[0] = 'A' + i; 164 text[0] = 'A' + i;
165 LetterPushButton *b = new LetterPushButton( text, this ); 165 LetterPushButton *b = new LetterPushButton( text, this );
166 connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); 166 connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) );
167 if ( i < 13 ) 167 if ( i < 13 )
168 hbox3->addWidget( b ); 168 hbox3->addWidget( b );
169 else 169 else
170 hbox4->addWidget( b ); 170 hbox4->addWidget( b );
171 } 171 }
172 } 172 }
173 173
174 vbox->addWidget( packagesList ); 174 vbox->addWidget( packagesList );
175 packagesList->addColumn( "Packages" ); 175 packagesList->addColumn( "Packages" );
176 176
177 QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1, "HBox2" ); 177 QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1, "HBox2" );
178 hbox2->addWidget( update ); 178 hbox2->addWidget( update );
179 hbox2->addWidget( download ); 179 hbox2->addWidget( download );
180 hbox2->addWidget( upgrade ); 180 hbox2->addWidget( upgrade );
181 hbox2->addWidget( apply ); 181 hbox2->addWidget( apply );
182} 182}
183 183
184void NetworkPackageManager :: setupConnections() 184void NetworkPackageManager :: setupConnections()
185{ 185{
186 connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int ))); 186 connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int )));
187 connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) ); 187 connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) );
188 connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) ); 188 connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) );
189 connect( upgrade, SIGNAL( released()), this, SLOT(upgradePackages()) ); 189 connect( upgrade, SIGNAL( released()), this, SLOT(upgradePackages()) );
190 connect( update, SIGNAL(released()), this, SLOT(updateServer()) ); 190 connect( update, SIGNAL(released()), this, SLOT(updateServer()) );
191} 191}
192 192
193void NetworkPackageManager :: showProgressDialog( char *initialText ) 193void NetworkPackageManager :: showProgressDialog( char *initialText )
194{ 194{
195 if ( !progressDlg ) 195 if ( !progressDlg )
196 progressDlg = new ProgressDlg( this, "Progress", false ); 196 progressDlg = new ProgressDlg( this, "Progress", false );
197 progressDlg->setText( initialText ); 197 progressDlg->setText( initialText );
198 progressDlg->show(); 198 progressDlg->show();
199} 199}
200 200
201 201
202void NetworkPackageManager :: serverSelected( int ) 202void NetworkPackageManager :: serverSelected( int )
203{ 203{
204 packagesList->clear(); 204 packagesList->clear();
205 205
206 // display packages 206 // display packages
207 QString serverName = serversList->currentText(); 207 QString serverName = serversList->currentText();
208 currentlySelectedServer = serverName; 208 currentlySelectedServer = serverName;
209 209
210#ifdef QWS 210#ifdef QWS
211 // read download directory from config file 211 // read download directory from config file
212 Config cfg( "aqpkg" ); 212 Config cfg( "aqpkg" );
213 cfg.setGroup( "settings" ); 213 cfg.setGroup( "settings" );
214 cfg.writeEntry( "selectedServer", currentlySelectedServer ); 214 cfg.writeEntry( "selectedServer", currentlySelectedServer );
215#endif 215#endif
216 216
217 Server *s = dataMgr->getServer( serverName ); 217 Server *s = dataMgr->getServer( serverName );
218// dataMgr->setActiveServer( serverName );
219 218
220 vector<Package> &list = s->getPackageList(); 219 vector<Package> &list = s->getPackageList();
221 vector<Package>::iterator it; 220 vector<Package>::iterator it;
222 for ( it = list.begin() ; it != list.end() ; ++it ) 221 for ( it = list.begin() ; it != list.end() ; ++it )
223 { 222 {
223
224 QString text = ""; 224 QString text = "";
225 225
226 // If the local server, only display installed packages 226 // If the local server, only display installed packages
227 if ( serverName == LOCAL_SERVER && !it->isInstalled() ) 227 if ( serverName == LOCAL_SERVER && !it->isInstalled() )
228 continue; 228 continue;
229 229
230 text += it->getPackageName(); 230 text += it->getPackageName();
231 if ( it->isInstalled() ) 231 if ( it->isInstalled() )
232 { 232 {
233 text += " (installed)"; 233 text += " (installed)";
234 234
235 // If a different version of package is available, postfix it with an * 235 // If a different version of package is available, postfix it with an *
236 if ( it->getVersion() != it->getInstalledVersion() ) 236 if ( it->getVersion() != it->getInstalledVersion() )
237 { 237 {
238
238 if ( compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1 ) 239 if ( compareVersions( it->getInstalledVersion(), it->getVersion() ) == 1 )
239 text += "*"; 240 text += "*";
240 } 241 }
241 } 242 }
242 243
243 QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox ); 244 QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox );
244 245
245 if ( it->isInstalled() ) 246 if ( it->isInstalled() )
246 { 247 {
247 QString destName = ""; 248 QString destName = "";
248 if ( it->getLocalPackage() ) 249 if ( it->getLocalPackage() )
249 { 250 {
250 if ( it->getLocalPackage()->getInstalledTo() ) 251 if ( it->getLocalPackage()->getInstalledTo() )
251 destName = it->getLocalPackage()->getInstalledTo()->getDestinationName(); 252 destName = it->getLocalPackage()->getInstalledTo()->getDestinationName();
252 } 253 }
253 else 254 else
254 { 255 {
255 if ( it->getInstalledTo() ) 256 if ( it->getInstalledTo() )
256 destName = it->getInstalledTo()->getDestinationName(); 257 destName = it->getInstalledTo()->getDestinationName();
257 } 258 }
258 if ( destName != "" ) 259 if ( destName != "" )
259 new QCheckListItem( item, QString( "Installed To - " ) + destName ); 260 new QCheckListItem( item, QString( "Installed To - " ) + destName );
260 } 261 }
261 262
262 if ( !it->isPackageStoredLocally() ) 263 if ( !it->isPackageStoredLocally() )
263 new QCheckListItem( item, QString( "Description - " ) + it->getDescription() ); 264 new QCheckListItem( item, QString( "Description - " ) + it->getDescription() );
264 else 265 else
265 new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() ); 266 new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() );
266 267
267 new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() ); 268 if ( serverName == LOCAL_SERVER )
268 if ( it->getLocalPackage() ) 269 {
269 { 270 new QCheckListItem( item, QString( "V. Installed - " ) + it->getVersion() );
270 if ( it->isInstalled() ) 271 }
271 new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() ); 272 else
273 {
274 new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() );
275 if ( it->getLocalPackage() )
276 {
277 if ( it->isInstalled() )
278 new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() );
279 }
272 } 280 }
273 packagesList->insertItem( item ); 281 packagesList->insertItem( item );
274 } 282 }
275 283
276 // If the local server or the local ipkgs server disable the download button 284 // If the local server or the local ipkgs server disable the download button
277 if ( serverName == LOCAL_SERVER ) 285 if ( serverName == LOCAL_SERVER )
278 { 286 {
279 upgrade->setEnabled( false ); 287 upgrade->setEnabled( false );
280 download->setText( "Download" ); 288 download->setText( "Download" );
281 download->setEnabled( false ); 289 download->setEnabled( false );
282 } 290 }
283 else if ( serverName == LOCAL_IPKGS ) 291 else if ( serverName == LOCAL_IPKGS )
284 { 292 {
285 upgrade->setEnabled( false ); 293 upgrade->setEnabled( false );
286 download->setEnabled( true ); 294 download->setEnabled( true );
287 download->setText( "Remove" ); 295 download->setText( "Remove" );
288 } 296 }
289 else 297 else
290 { 298 {
291 upgrade->setEnabled( true ); 299 upgrade->setEnabled( true );
292 download->setEnabled( true ); 300 download->setEnabled( true );
293 download->setText( "Download" ); 301 download->setText( "Download" );
294 } 302 }
295} 303}
296 304
297void NetworkPackageManager :: updateServer() 305void NetworkPackageManager :: updateServer()
298{ 306{
299 QString serverName = serversList->currentText(); 307 QString serverName = serversList->currentText();
300 308
301 // Update the current server 309 // Update the current server
302 // Display dialog 310 // Display dialog
303// ProgressDlg *progDlg = new ProgressDlg( this ); 311// ProgressDlg *progDlg = new ProgressDlg( this );
304// QString status = "Updating package lists..."; 312// QString status = "Updating package lists...";
305// progDlg->show(); 313// progDlg->show();
306// progDlg->setText( status ); 314// progDlg->setText( status );
307 315
308 // Disable buttons to stop silly people clicking lots on them :) 316 // Disable buttons to stop silly people clicking lots on them :)
309 317
310 // First, write out ipkg_conf file so that ipkg can use it 318 // First, write out ipkg_conf file so that ipkg can use it
311 dataMgr->writeOutIpkgConf(); 319 dataMgr->writeOutIpkgConf();
312 320
313 Ipkg ipkg; 321 Ipkg ipkg;
314 ipkg.setOption( "update" ); 322 ipkg.setOption( "update" );
315 323
316 InstallDlgImpl dlg( &ipkg, "Refreshing server package lists", this, "Upgrade", true ); 324 InstallDlgImpl dlg( &ipkg, "Refreshing server package lists", this, "Upgrade", true );
317 dlg.showDlg(); 325 dlg.showDlg();
318 326
319 // Reload data 327 // Reload data
320 dataMgr->reloadServerData( serversList->currentText() ); 328 dataMgr->reloadServerData();
321 serverSelected(-1); 329 serverSelected(-1);
322// delete progDlg; 330// delete progDlg;
323} 331}
324 332
325void NetworkPackageManager :: upgradePackages() 333void NetworkPackageManager :: upgradePackages()
326{ 334{
327 // We're gonna do an upgrade of all packages 335 // We're gonna do an upgrade of all packages
328 // First warn user that this isn't recommended 336 // First warn user that this isn't recommended
329 QString text = "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n"; 337 QString text = "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n";
330 QMessageBox warn("Warning", text, QMessageBox::Warning, 338 QMessageBox warn("Warning", text, QMessageBox::Warning,
331 QMessageBox::Yes, 339 QMessageBox::Yes,
332 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , 340 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default ,
333 0, this ); 341 0, this );
334 warn.adjustSize(); 342 warn.adjustSize();
335 343
336 if ( warn.exec() == QMessageBox::Yes ) 344 if ( warn.exec() == QMessageBox::Yes )
337 { 345 {
338 // First, write out ipkg_conf file so that ipkg can use it 346 // First, write out ipkg_conf file so that ipkg can use it
339 dataMgr->writeOutIpkgConf(); 347 dataMgr->writeOutIpkgConf();
340 348
341 // Now run upgrade 349 // Now run upgrade
342 Ipkg ipkg; 350 Ipkg ipkg;
343 ipkg.setOption( "upgrade" ); 351 ipkg.setOption( "upgrade" );
344 352
345 InstallDlgImpl dlg( &ipkg, "Upgrading installed packages", this, "Upgrade", true ); 353 InstallDlgImpl dlg( &ipkg, "Upgrading installed packages", this, "Upgrade", true );
346 dlg.showDlg(); 354 dlg.showDlg();
347 355
348 // Reload data 356 // Reload data
349 dataMgr->reloadServerData( LOCAL_SERVER ); 357 dataMgr->reloadServerData();
350
351 dataMgr->reloadServerData( serversList->currentText() );
352 serverSelected(-1); 358 serverSelected(-1);
353 } 359 }
354} 360}
355 361
356 362
357void NetworkPackageManager :: downloadPackage() 363void NetworkPackageManager :: downloadPackage()
358{ 364{
359 if ( download->text() == "Download" ) 365 if ( download->text() == "Download" )
360 { 366 {
361 // First, write out ipkg_conf file so that ipkg can use it 367 // First, write out ipkg_conf file so that ipkg can use it
362 dataMgr->writeOutIpkgConf(); 368 dataMgr->writeOutIpkgConf();
363 369
364 // Display dialog to user asking where to download the files to 370 // Display dialog to user asking where to download the files to
365 bool ok = FALSE; 371 bool ok = FALSE;
366 QString dir = ""; 372 QString dir = "";
367#ifdef QWS 373#ifdef QWS
368 // read download directory from config file 374 // read download directory from config file
369 Config cfg( "aqpkg" ); 375 Config cfg( "aqpkg" );
370 cfg.setGroup( "settings" ); 376 cfg.setGroup( "settings" );
371 dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); 377 dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" );
372#endif 378#endif
373 379
374 QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); 380 QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this );
375 if ( ok && !text.isEmpty() ) 381 if ( ok && !text.isEmpty() )
376 dir = text; // user entered something and pressed ok 382 dir = text; // user entered something and pressed ok
377 else 383 else
378 return; // user entered nothing or pressed cancel 384 return; // user entered nothing or pressed cancel
379 385
380#ifdef QWS 386#ifdef QWS
381 // Store download directory in config file 387 // Store download directory in config file
382 cfg.writeEntry( "downloadDir", dir ); 388 cfg.writeEntry( "downloadDir", dir );
383#endif 389#endif
384 390
385 // Get starting directory 391 // Get starting directory
386 char initDir[PATH_MAX]; 392 char initDir[PATH_MAX];
387 getcwd( initDir, PATH_MAX ); 393 getcwd( initDir, PATH_MAX );
388 394
389 // Download each package 395 // Download each package
390 Ipkg ipkg; 396 Ipkg ipkg;
391 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 397 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
392 398
393 ipkg.setOption( "download" ); 399 ipkg.setOption( "download" );
394 ipkg.setRuntimeDirectory( dir ); 400 ipkg.setRuntimeDirectory( dir );
395 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 401 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
396 item != 0 ; 402 item != 0 ;
397 item = (QCheckListItem *)item->nextSibling() ) 403 item = (QCheckListItem *)item->nextSibling() )
398 { 404 {
399 if ( item->isOn() ) 405 if ( item->isOn() )
400 { 406 {
401 QString name = item->text(); 407 QString name = item->text();
402 int pos = name.find( "*" ); 408 int pos = name.find( "*" );
403 name.truncate( pos ); 409 name.truncate( pos );
404 410
405 // if (there is a (installed), remove it 411 // if (there is a (installed), remove it
406 pos = name.find( "(installed)" ); 412 pos = name.find( "(installed)" );
407 if ( pos > 0 ) 413 if ( pos > 0 )
408 name.truncate( pos - 1 ); 414 name.truncate( pos - 1 );
409 415
410 ipkg.setPackage( name ); 416 ipkg.setPackage( name );
411 ipkg.runIpkg( ); 417 ipkg.runIpkg( );
412 } 418 }
413 } 419 }
414 } 420 }
415 else if ( download->text() == "Remove" ) 421 else if ( download->text() == "Remove" )
416 { 422 {
417 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 423 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
418 item != 0 ; 424 item != 0 ;
419 item = (QCheckListItem *)item->nextSibling() ) 425 item = (QCheckListItem *)item->nextSibling() )
420 { 426 {
421 if ( item->isOn() ) 427 if ( item->isOn() )
422 { 428 {
423 QString name = item->text(); 429 QString name = item->text();
424 int pos = name.find( "*" ); 430 int pos = name.find( "*" );
425 name.truncate( pos ); 431 name.truncate( pos );
426 432
427 // if (there is a (installed), remove it 433 // if (there is a (installed), remove it
428 pos = name.find( "(installed)" ); 434 pos = name.find( "(installed)" );
429 if ( pos > 0 ) 435 if ( pos > 0 )
430 name.truncate( pos - 1 ); 436 name.truncate( pos - 1 );
431 437
432 Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name ); 438 Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name );
433 QFile f( p->getFilename() ); 439 QFile f( p->getFilename() );
434 f.remove(); 440 f.remove();
435 } 441 }
436 } 442 }
437 } 443 }
438 444
439 dataMgr->reloadServerData( LOCAL_IPKGS ); 445 dataMgr->reloadServerData();
440 serverSelected( -1 ); 446 serverSelected( -1 );
441} 447}
442 448
443 449
444void NetworkPackageManager :: applyChanges() 450void NetworkPackageManager :: applyChanges()
445{ 451{
446 stickyOption = ""; 452 stickyOption = "";
447 453
448 // First, write out ipkg_conf file so that ipkg can use it 454 // First, write out ipkg_conf file so that ipkg can use it
449 dataMgr->writeOutIpkgConf(); 455 dataMgr->writeOutIpkgConf();
450 456
451 // Now for each selected item 457 // Now for each selected item
452 // deal with it 458 // deal with it
453 459
454 vector<InstallData> workingPackages; 460 vector<InstallData> workingPackages;
455 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 461 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
456 item != 0 ; 462 item != 0 ;
457 item = (QCheckListItem *)item->nextSibling() ) 463 item = (QCheckListItem *)item->nextSibling() )
458 { 464 {
459 if ( item->isOn() ) 465 if ( item->isOn() )
460 { 466 {
461 InstallData data = dealWithItem( item ); 467 InstallData data = dealWithItem( item );
462 workingPackages.push_back( data ); 468 workingPackages.push_back( data );
463 } 469 }
464 } 470 }
465 471
466 if ( workingPackages.size() == 0 ) 472 if ( workingPackages.size() == 0 )
467 { 473 {
468 // Nothing to do 474 // Nothing to do
469 QMessageBox::information( this, "Nothing to do", 475 QMessageBox::information( this, "Nothing to do",
470 "No packages selected", "OK" ); 476 "No packages selected", "OK" );
471 477
472 return; 478 return;
473 } 479 }
474 480
475 // do the stuff 481 // do the stuff
476 InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true ); 482 InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true );
477 dlg.showDlg(); 483 dlg.showDlg();
478 484
479 // Reload data 485 // Reload data
480 dataMgr->reloadServerData( LOCAL_SERVER ); 486 dataMgr->reloadServerData();
481
482 dataMgr->reloadServerData( serversList->currentText() );
483 serverSelected(-1); 487 serverSelected(-1);
484 488
485#ifdef QWS 489#ifdef QWS
486 // Finally let the main system update itself 490 // Finally let the main system update itself
487 QCopEnvelope e("QPE/System", "linkChanged(QString)"); 491 QCopEnvelope e("QPE/System", "linkChanged(QString)");
488 QString lf = QString::null; 492 QString lf = QString::null;
489 e << lf; 493 e << lf;
490#endif 494#endif
491} 495}
492 496
493// decide what to do - either remove, upgrade or install 497// decide what to do - either remove, upgrade or install
494// Current rules: 498// Current rules:
495// If not installed - install 499// If not installed - install
496// If installed and different version available - upgrade 500// If installed and different version available - upgrade
497// If installed and version up to date - remove 501// If installed and version up to date - remove
498InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item ) 502InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item )
499{ 503{
500 QString name = item->text(); 504 QString name = item->text();
501 int pos = name.find( "*" ); 505 int pos = name.find( "*" );
502 name.truncate( pos ); 506 name.truncate( pos );
503 507
504 // if (there is a (installed), remove it 508 // if (there is a (installed), remove it
505 pos = name.find( "(installed)" ); 509 pos = name.find( "(installed)" );
506 if ( pos > 0 ) 510 if ( pos > 0 )
507 name.truncate( pos - 1 ); 511 name.truncate( pos - 1 );
508 512
509 // Get package 513 // Get package
510 Server *s = dataMgr->getServer( serversList->currentText() ); 514 Server *s = dataMgr->getServer( serversList->currentText() );
511 Package *p = s->getPackage( name ); 515 Package *p = s->getPackage( name );
512 516
513 // If the package has a filename then it is a local file 517 // If the package has a filename then it is a local file
514 if ( p->isPackageStoredLocally() ) 518 if ( p->isPackageStoredLocally() )
515 name = p->getFilename(); 519 name = p->getFilename();
516 QString option; 520 QString option;
517 QString dest = "root"; 521 QString dest = "root";
518 if ( !p->isInstalled() ) 522 if ( !p->isInstalled() )
519 { 523 {
520 InstallData item; 524 InstallData item;
521 item.option = "I"; 525 item.option = "I";
522 item.packageName = name; 526 item.packageName = name;
523 return item; 527 return item;
524 } 528 }
525 else 529 else
526 { 530 {
527 InstallData item; 531 InstallData item;
528 item.option = "D"; 532 item.option = "D";
529 item.packageName = p->getInstalledPackageName(); 533 item.packageName = p->getInstalledPackageName();
530 if ( p->getInstalledTo() ) 534 if ( p->getInstalledTo() )
531 { 535 {
532 item.destination = p->getInstalledTo(); 536 item.destination = p->getInstalledTo();
533 cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl; 537 cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl;
534 cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl; 538 cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl;
535 } 539 }
536 else 540 else
537 { 541 {
538 item.destination = p->getLocalPackage()->getInstalledTo(); 542 item.destination = p->getLocalPackage()->getInstalledTo();
539 } 543 }
540 544
541 // Now see if version is newer or not 545 // Now see if version is newer or not
542 int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); 546 int val = compareVersions( p->getInstalledVersion(), p->getVersion() );
543 if ( val == -2 ) 547 if ( val == -2 )
544 { 548 {
545 // Error - should handle 549 // Error - should handle
546 } 550 }
547 else if ( val == -1 ) 551 else if ( val == -1 )
548 { 552 {
549 // Version available is older - remove only 553 // Version available is older - remove only
550 item.option = "R"; 554 item.option = "R";
551 } 555 }
552 else 556 else
553 { 557 {
554 QString caption; 558 QString caption;
555 QString text; 559 QString text;
556 QString secondButton; 560 QString secondButton;
557 QString secondOption; 561 QString secondOption;
558 if ( val == 0 ) 562 if ( val == 0 )
559 { 563 {
560 // Version available is the same - option to remove or reinstall 564 // Version available is the same - option to remove or reinstall
561 caption = "Do you wish to remove or reinstall\n%s?"; 565 caption = "Do you wish to remove or reinstall\n%s?";
562 text = "Remove or ReInstall"; 566 text = "Remove or ReInstall";
563 secondButton = "ReInstall"; 567 secondButton = "ReInstall";
564 secondOption = "R"; 568 secondOption = "R";
565 } 569 }
566 else if ( val == 1 ) 570 else if ( val == 1 )
567 { 571 {
568 // Version available is newer - option to remove or upgrade 572 // Version available is newer - option to remove or upgrade
569 caption = "Do you wish to remove or upgrade\n%s?"; 573 caption = "Do you wish to remove or upgrade\n%s?";
570 text = "Remove or Upgrade"; 574 text = "Remove or Upgrade";
571 secondButton = "Upgrade"; 575 secondButton = "Upgrade";
572 secondOption = "U"; 576 secondOption = "U";
573 } 577 }
574 578
575 // Sticky option not implemented yet, but will eventually allow 579 // Sticky option not implemented yet, but will eventually allow
576 // the user to say something like 'remove all' 580 // the user to say something like 'remove all'
577 if ( stickyOption == "" ) 581 if ( stickyOption == "" )
578 { 582 {
579 QString msgtext; 583 QString msgtext;
580 msgtext.sprintf( caption, (const char *)name ); 584 msgtext.sprintf( caption, (const char *)name );
581 switch( QMessageBox::information( this, text, 585 switch( QMessageBox::information( this, text,
582 msgtext, "Remove", secondButton ) ) 586 msgtext, "Remove", secondButton ) )
583 { 587 {
584 case 0: // Try again or Enter 588 case 0: // Try again or Enter
585 item.option = "D"; 589 item.option = "D";
586 break; 590 break;
587 case 1: // Quit or Escape 591 case 1: // Quit or Escape
588 item.option = secondOption; 592 item.option = secondOption;
589 break; 593 break;
590 } 594 }
591 } 595 }
592 else 596 else
593 { 597 {
594// item.option = stickyOption; 598// item.option = stickyOption;
595 } 599 }
596 } 600 }
597 601
598 602
599 // Check if we are reinstalling the same version 603 // Check if we are reinstalling the same version
600 if ( item.option != "R" ) 604 if ( item.option != "R" )
601 item.recreateLinks = true; 605 item.recreateLinks = true;
602 else 606 else
603 item.recreateLinks = false; 607 item.recreateLinks = false;
604 608
605 // User hit cancel (on dlg - assume remove) 609 // User hit cancel (on dlg - assume remove)
606 return item; 610 return item;
607 } 611 }
608} 612}
609 613
610void NetworkPackageManager :: displayText( const QString &t ) 614void NetworkPackageManager :: displayText( const QString &t )
611{ 615{
612 cout << t << endl; 616 cout << t << endl;
613} 617}
614 618
615 619
616void NetworkPackageManager :: letterPushed( QString t ) 620void NetworkPackageManager :: letterPushed( QString t )
617{ 621{
618 QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); 622 QCheckListItem *top = (QCheckListItem *)packagesList->firstChild();
619 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); 623 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem();
620 if ( packagesList->firstChild() == 0 ) 624 if ( packagesList->firstChild() == 0 )
621 return; 625 return;
622 626
623 QCheckListItem *item; 627 QCheckListItem *item;
624 if ( start == 0 ) 628 if ( start == 0 )
625 { 629 {
626 item = (QCheckListItem *)packagesList->firstChild(); 630 item = (QCheckListItem *)packagesList->firstChild();
627 start = top; 631 start = top;
628 } 632 }
629 else 633 else
630 item = (QCheckListItem *)start->nextSibling(); 634 item = (QCheckListItem *)start->nextSibling();
631 635
632 if ( item == 0 ) 636 if ( item == 0 )
633 item = (QCheckListItem *)packagesList->firstChild(); 637 item = (QCheckListItem *)packagesList->firstChild();
634 do 638 do
635 { 639 {
636 if ( item->text().lower().startsWith( t.lower() ) ) 640 if ( item->text().lower().startsWith( t.lower() ) )
637 { 641 {
638 packagesList->setSelected( item, true ); 642 packagesList->setSelected( item, true );
639 packagesList->ensureItemVisible( item ); 643 packagesList->ensureItemVisible( item );
640 break; 644 break;
641 } 645 }
642 646
643 item = (QCheckListItem *)item->nextSibling(); 647 item = (QCheckListItem *)item->nextSibling();
644 if ( !item ) 648 if ( !item )
645 item = (QCheckListItem *)packagesList->firstChild(); 649 item = (QCheckListItem *)packagesList->firstChild();
646 } while ( item != start); 650 } while ( item != start);
647} 651}