summaryrefslogtreecommitdiff
authorandyq <andyq>2002-10-25 14:37:28 (UTC)
committer andyq <andyq>2002-10-25 14:37:28 (UTC)
commitf4007b261a7a4dc9672a1806be50ea16ccfc84f1 (patch) (unidiff)
tree5a2469d149be879bd221a1d1f07d9cab7cab5a49
parent3421736c248c6ca7171bafdf3af9e2edf94eb593 (diff)
downloadopie-f4007b261a7a4dc9672a1806be50ea16ccfc84f1.zip
opie-f4007b261a7a4dc9672a1806be50ea16ccfc84f1.tar.gz
opie-f4007b261a7a4dc9672a1806be50ea16ccfc84f1.tar.bz2
Hopefully handles upgrading to newer packages correctly
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/installdlgimpl.cpp7
-rw-r--r--noncore/settings/aqpkg/installdlgimpl.h2
-rw-r--r--noncore/settings/aqpkg/ipkg.cpp8
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.cpp4
4 files changed, 13 insertions, 8 deletions
diff --git a/noncore/settings/aqpkg/installdlgimpl.cpp b/noncore/settings/aqpkg/installdlgimpl.cpp
index f5aef94..83f983a 100644
--- a/noncore/settings/aqpkg/installdlgimpl.cpp
+++ b/noncore/settings/aqpkg/installdlgimpl.cpp
@@ -1,237 +1,240 @@
1/*************************************************************************** 1/***************************************************************************
2 installdlgimpl.cpp - description 2 installdlgimpl.cpp - description
3 ------------------- 3 -------------------
4 begin : Mon Aug 26 2002 4 begin : Mon Aug 26 2002
5 copyright : (C) 2002 by Andy Qua 5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk 6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#ifdef QWS 18#ifdef QWS
19#include <qpe/config.h> 19#include <qpe/config.h>
20#endif 20#endif
21 21
22#include <qmultilineedit.h> 22#include <qmultilineedit.h>
23#include <qdialog.h> 23#include <qdialog.h>
24#include <qcombobox.h> 24#include <qcombobox.h>
25#include <qcheckbox.h> 25#include <qcheckbox.h>
26#include <qpushbutton.h> 26#include <qpushbutton.h>
27 27
28 28
29#include "datamgr.h" 29#include "datamgr.h"
30#include "instoptionsimpl.h" 30#include "instoptionsimpl.h"
31#include "destination.h" 31#include "destination.h"
32#include "installdlgimpl.h" 32#include "installdlgimpl.h"
33#include "global.h" 33#include "global.h"
34 34
35InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl ) 35InstallDlgImpl::InstallDlgImpl( vector<InstallData> &packageList, DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl )
36 : InstallDlg( parent, name, modal, fl ) 36 : InstallDlg( parent, name, modal, fl )
37{ 37{
38 pIpkg = 0; 38 pIpkg = 0;
39 upgradePackages = false; 39 upgradePackages = false;
40 dataMgr = dataManager; 40 dataMgr = dataManager;
41 vector<Destination>::iterator dit; 41 vector<Destination>::iterator dit;
42 42
43 QString defaultDest = "root"; 43 QString defaultDest = "root";
44#ifdef QWS 44#ifdef QWS
45 Config cfg( "aqpkg" ); 45 Config cfg( "aqpkg" );
46 cfg.setGroup( "settings" ); 46 cfg.setGroup( "settings" );
47 defaultDest = cfg.readEntry( "dest", "root" ); 47 defaultDest = cfg.readEntry( "dest", "root" );
48 48
49 // Grab flags - Turn MAKE_LINKS on by default (if no flags found) 49 // Grab flags - Turn MAKE_LINKS on by default (if no flags found)
50// flags = cfg.readNumEntry( "installFlags", MAKE_LINKS ); 50// flags = cfg.readNumEntry( "installFlags", MAKE_LINKS );
51 flags = 0; 51 flags = 0;
52#else 52#else
53 flags = 0; 53 flags = 0;
54#endif 54#endif
55 55
56 // Output text is read only 56 // Output text is read only
57 output->setReadOnly( true ); 57 output->setReadOnly( true );
58 QFont f( "helvetica" ); 58 QFont f( "helvetica" );
59 f.setPointSize( 10 ); 59 f.setPointSize( 10 );
60 output->setFont( f ); 60 output->setFont( f );
61 61
62 62
63 // setup destination data 63 // setup destination data
64 int defIndex = 0; 64 int defIndex = 0;
65 int i; 65 int i;
66 for ( i = 0 , dit = dataMgr->getDestinationList().begin() ; dit != dataMgr->getDestinationList().end() ; ++dit, ++i ) 66 for ( i = 0 , dit = dataMgr->getDestinationList().begin() ; dit != dataMgr->getDestinationList().end() ; ++dit, ++i )
67 { 67 {
68 destination->insertItem( dit->getDestinationName() ); 68 destination->insertItem( dit->getDestinationName() );
69 if ( dit->getDestinationName() == defaultDest ) 69 if ( dit->getDestinationName() == defaultDest )
70 defIndex = i; 70 defIndex = i;
71 } 71 }
72 72
73 destination->setCurrentItem( defIndex ); 73 destination->setCurrentItem( defIndex );
74 74
75 vector<InstallData>::iterator it; 75 vector<InstallData>::iterator it;
76 // setup package data 76 // setup package data
77 QString remove = "Remove\n"; 77 QString remove = "Remove\n";
78 QString install = "\nInstall\n"; 78 QString install = "\nInstall\n";
79 QString upgrade = "\nUpgrade\n"; 79 QString upgrade = "\nUpgrade\n";
80 for ( it = packageList.begin() ; it != packageList.end() ; ++it ) 80 for ( it = packageList.begin() ; it != packageList.end() ; ++it )
81 { 81 {
82 InstallData item = *it; 82 InstallData item = *it;
83 if ( item.option == "I" ) 83 if ( item.option == "I" )
84 { 84 {
85 installList.push_back( item ); 85 installList.push_back( item );
86 install += " " + item.packageName + "\n"; 86 install += " " + item.packageName + "\n";
87 } 87 }
88 else if ( item.option == "D" ) 88 else if ( item.option == "D" )
89 { 89 {
90 removeList.push_back( item ); 90 removeList.push_back( item );
91 remove += " " + item.packageName + "\n"; 91 remove += " " + item.packageName + "\n";
92 } 92 }
93 else if ( item.option == "U" ) 93 else if ( item.option == "U" || item.option == "R" )
94 { 94 {
95 updateList.push_back( item ); 95 updateList.push_back( item );
96 upgrade += " " + item.packageName + "\n"; 96 upgrade += " " + item.packageName + "\n";
97 } 97 }
98 } 98 }
99 99
100 output->setText( remove + install + upgrade ); 100 output->setText( remove + install + upgrade );
101} 101}
102 102
103InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, QWidget *parent, const char *name, bool modal, WFlags fl ) 103InstallDlgImpl::InstallDlgImpl( Ipkg *ipkg, QString initialText, QWidget *parent, const char *name, bool modal, WFlags fl )
104 : InstallDlg( parent, name, modal, fl ) 104 : InstallDlg( parent, name, modal, fl )
105{ 105{
106 pIpkg = ipkg; 106 pIpkg = ipkg;
107 output->setText( initialText ); 107 output->setText( initialText );
108} 108}
109 109
110 110
111InstallDlgImpl::~InstallDlgImpl() 111InstallDlgImpl::~InstallDlgImpl()
112{ 112{
113} 113}
114 114
115bool InstallDlgImpl :: showDlg() 115bool InstallDlgImpl :: showDlg()
116{ 116{
117 showMaximized(); 117 showMaximized();
118 bool ret = exec(); 118 bool ret = exec();
119 119
120 return ret; 120 return ret;
121} 121}
122 122
123void InstallDlgImpl :: optionsSelected() 123void InstallDlgImpl :: optionsSelected()
124{ 124{
125 InstallOptionsDlgImpl opt( flags, this, "Option", true ); 125 InstallOptionsDlgImpl opt( flags, this, "Option", true );
126 opt.exec(); 126 opt.exec();
127 127
128 // set options selected from dialog 128 // set options selected from dialog
129 flags = 0; 129 flags = 0;
130 if ( opt.forceDepends->isChecked() ) 130 if ( opt.forceDepends->isChecked() )
131 flags |= FORCE_DEPENDS; 131 flags |= FORCE_DEPENDS;
132 if ( opt.forceReinstall->isChecked() ) 132 if ( opt.forceReinstall->isChecked() )
133 flags |= FORCE_REINSTALL; 133 flags |= FORCE_REINSTALL;
134 if ( opt.forceRemove->isChecked() ) 134 if ( opt.forceRemove->isChecked() )
135 flags |= FORCE_REMOVE; 135 flags |= FORCE_REMOVE;
136 if ( opt.forceOverwrite->isChecked() ) 136 if ( opt.forceOverwrite->isChecked() )
137 flags |= FORCE_OVERWRITE; 137 flags |= FORCE_OVERWRITE;
138 138
139#ifdef QWS 139#ifdef QWS
140 Config cfg( "aqpkg" ); 140 Config cfg( "aqpkg" );
141 cfg.setGroup( "settings" ); 141 cfg.setGroup( "settings" );
142 cfg.writeEntry( "installFlags", flags ); 142 cfg.writeEntry( "installFlags", flags );
143#endif 143#endif
144} 144}
145 145
146void InstallDlgImpl :: installSelected() 146void InstallDlgImpl :: installSelected()
147{ 147{
148 if ( btnInstall->text() == "Close" ) 148 if ( btnInstall->text() == "Close" )
149 { 149 {
150 done( 1 ); 150 done( 1 );
151 return; 151 return;
152 } 152 }
153 153
154 btnInstall->setEnabled( false ); 154 btnInstall->setEnabled( false );
155 155
156 if ( pIpkg ) 156 if ( pIpkg )
157 { 157 {
158 output->setText( "" ); 158 output->setText( "" );
159 159
160 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 160 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
161 pIpkg->runIpkg(); 161 pIpkg->runIpkg();
162 } 162 }
163 else 163 else
164 { 164 {
165 output->setText( "" ); 165 output->setText( "" );
166 Destination *d = dataMgr->getDestination( destination->currentText() ); 166 Destination *d = dataMgr->getDestination( destination->currentText() );
167 QString dest = d->getDestinationName(); 167 QString dest = d->getDestinationName();
168 QString destDir = d->getDestinationPath(); 168 QString destDir = d->getDestinationPath();
169 int instFlags = flags; 169 int instFlags = flags;
170 if ( d->linkToRoot() ) 170 if ( d->linkToRoot() )
171 instFlags |= MAKE_LINKS; 171 instFlags |= MAKE_LINKS;
172 172
173#ifdef QWS 173#ifdef QWS
174 // Save settings 174 // Save settings
175 Config cfg( "aqpkg" ); 175 Config cfg( "aqpkg" );
176 cfg.setGroup( "settings" ); 176 cfg.setGroup( "settings" );
177 cfg.writeEntry( "dest", dest ); 177 cfg.writeEntry( "dest", dest );
178#endif 178#endif
179 179
180 pIpkg = new Ipkg; 180 pIpkg = new Ipkg;
181 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 181 connect( pIpkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
182 182
183 // First run through the remove list, then the install list then the upgrade list 183 // First run through the remove list, then the install list then the upgrade list
184 vector<InstallData>::iterator it; 184 vector<InstallData>::iterator it;
185 pIpkg->setOption( "remove" ); 185 pIpkg->setOption( "remove" );
186 for ( it = removeList.begin() ; it != removeList.end() ; ++it ) 186 for ( it = removeList.begin() ; it != removeList.end() ; ++it )
187 { 187 {
188 pIpkg->setDestination( it->destination->getDestinationName() ); 188 pIpkg->setDestination( it->destination->getDestinationName() );
189 pIpkg->setDestinationDir( it->destination->getDestinationPath() ); 189 pIpkg->setDestinationDir( it->destination->getDestinationPath() );
190 pIpkg->setPackage( it->packageName ); 190 pIpkg->setPackage( it->packageName );
191 191
192 int tmpFlags = flags; 192 int tmpFlags = flags;
193 if ( it->destination->linkToRoot() ) 193 if ( it->destination->linkToRoot() )
194 tmpFlags |= MAKE_LINKS; 194 tmpFlags |= MAKE_LINKS;
195 195
196 pIpkg->setFlags( tmpFlags ); 196 pIpkg->setFlags( tmpFlags );
197 pIpkg->runIpkg(); 197 pIpkg->runIpkg();
198 } 198 }
199 199
200 pIpkg->setOption( "install" ); 200 pIpkg->setOption( "install" );
201 pIpkg->setDestination( dest ); 201 pIpkg->setDestination( dest );
202 pIpkg->setDestinationDir( destDir ); 202 pIpkg->setDestinationDir( destDir );
203 pIpkg->setFlags( instFlags ); 203 pIpkg->setFlags( instFlags );
204 for ( it = installList.begin() ; it != installList.end() ; ++it ) 204 for ( it = installList.begin() ; it != installList.end() ; ++it )
205 { 205 {
206 pIpkg->setPackage( it->packageName ); 206 pIpkg->setPackage( it->packageName );
207 pIpkg->runIpkg(); 207 pIpkg->runIpkg();
208 } 208 }
209 209
210 flags |= FORCE_REINSTALL; 210 flags |= FORCE_REINSTALL;
211 pIpkg->setOption( "reinstall" );
212 for ( it = updateList.begin() ; it != updateList.end() ; ++it ) 211 for ( it = updateList.begin() ; it != updateList.end() ; ++it )
213 { 212 {
213 if ( it->option == "R" )
214 pIpkg->setOption( "reinstall" );
215 else
216 pIpkg->setOption( "upgrade" );
214 pIpkg->setDestination( it->destination->getDestinationName() ); 217 pIpkg->setDestination( it->destination->getDestinationName() );
215 pIpkg->setDestinationDir( it->destination->getDestinationPath() ); 218 pIpkg->setDestinationDir( it->destination->getDestinationPath() );
216 pIpkg->setPackage( it->packageName ); 219 pIpkg->setPackage( it->packageName );
217 220
218 int tmpFlags = flags; 221 int tmpFlags = flags;
219 if ( it->destination->linkToRoot() && it->recreateLinks ) 222 if ( it->destination->linkToRoot() && it->recreateLinks )
220 tmpFlags |= MAKE_LINKS; 223 tmpFlags |= MAKE_LINKS;
221 pIpkg->setFlags( tmpFlags ); 224 pIpkg->setFlags( tmpFlags );
222 pIpkg->runIpkg(); 225 pIpkg->runIpkg();
223 } 226 }
224 227
225 delete pIpkg; 228 delete pIpkg;
226 } 229 }
227 230
228 btnInstall->setEnabled( true ); 231 btnInstall->setEnabled( true );
229 btnInstall->setText( tr( "Close" ) ); 232 btnInstall->setText( tr( "Close" ) );
230} 233}
231 234
232void InstallDlgImpl :: displayText(const QString &text ) 235void InstallDlgImpl :: displayText(const QString &text )
233{ 236{
234 QString t = output->text() + "\n" + text; 237 QString t = output->text() + "\n" + text;
235 output->setText( t ); 238 output->setText( t );
236 output->setCursorPosition( output->numLines(), 0 ); 239 output->setCursorPosition( output->numLines(), 0 );
237} 240}
diff --git a/noncore/settings/aqpkg/installdlgimpl.h b/noncore/settings/aqpkg/installdlgimpl.h
index 6716ced..9819b2e 100644
--- a/noncore/settings/aqpkg/installdlgimpl.h
+++ b/noncore/settings/aqpkg/installdlgimpl.h
@@ -1,65 +1,65 @@
1/*************************************************************************** 1/***************************************************************************
2 installdlgimpl.h - description 2 installdlgimpl.h - description
3 ------------------- 3 -------------------
4 begin : Mon Aug 26 2002 4 begin : Mon Aug 26 2002
5 copyright : (C) 2002 by Andy Qua 5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk 6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17#ifndef INSTALLDLGIMPL_H 17#ifndef INSTALLDLGIMPL_H
18#define INSTALLDLGIMPL_H 18#define INSTALLDLGIMPL_H
19 19
20#include <vector> 20#include <vector>
21using namespace std; 21using namespace std;
22 22
23#include <qstring.h> 23#include <qstring.h>
24 24
25#include "ipkg.h" 25#include "ipkg.h"
26#include "install.h" 26#include "install.h"
27 27
28class InstallData 28class InstallData
29{ 29{
30public: 30public:
31 QString option; // I - install, D - delete, U - upgrade 31 QString option; // I - install, D - delete, R- reinstall U - upgrade
32 QString packageName; 32 QString packageName;
33 Destination *destination; 33 Destination *destination;
34 bool recreateLinks; 34 bool recreateLinks;
35}; 35};
36 36
37class InstallDlgImpl : public InstallDlg 37class InstallDlgImpl : public InstallDlg
38{ 38{
39public: 39public:
40 InstallDlgImpl( vector<InstallData> &packageList, DataManager *dataManager, QWidget * parent = 0, const char* name = 0, bool modal = false, WFlags fl = 0 ); 40 InstallDlgImpl( vector<InstallData> &packageList, DataManager *dataManager, QWidget * parent = 0, const char* name = 0, bool modal = false, WFlags fl = 0 );
41 InstallDlgImpl( Ipkg *ipkg, QString initialText, QWidget * parent = 0, const char* name = 0, bool modal = false, WFlags fl = 0 ); 41 InstallDlgImpl( Ipkg *ipkg, QString initialText, QWidget * parent = 0, const char* name = 0, bool modal = false, WFlags fl = 0 );
42 ~InstallDlgImpl(); 42 ~InstallDlgImpl();
43 43
44 bool showDlg(); 44 bool showDlg();
45 bool upgradeServer( QString &server ); 45 bool upgradeServer( QString &server );
46 46
47protected: 47protected:
48 48
49private: 49private:
50 DataManager *dataMgr; 50 DataManager *dataMgr;
51 vector<InstallData> installList; 51 vector<InstallData> installList;
52 vector<InstallData> removeList; 52 vector<InstallData> removeList;
53 vector<InstallData> updateList; 53 vector<InstallData> updateList;
54 int flags; 54 int flags;
55 Ipkg *pIpkg; 55 Ipkg *pIpkg;
56 bool upgradePackages; 56 bool upgradePackages;
57 57
58 bool runIpkg( QString &option, const QString& package, const QString& dest, int flags ); 58 bool runIpkg( QString &option, const QString& package, const QString& dest, int flags );
59 59
60 void optionsSelected(); 60 void optionsSelected();
61 void installSelected(); 61 void installSelected();
62 void displayText(const QString &text ); 62 void displayText(const QString &text );
63}; 63};
64 64
65#endif 65#endif
diff --git a/noncore/settings/aqpkg/ipkg.cpp b/noncore/settings/aqpkg/ipkg.cpp
index 368548b..731a336 100644
--- a/noncore/settings/aqpkg/ipkg.cpp
+++ b/noncore/settings/aqpkg/ipkg.cpp
@@ -1,367 +1,365 @@
1/*************************************************************************** 1/***************************************************************************
2 ipkg.cpp - description 2 ipkg.cpp - description
3 ------------------- 3 -------------------
4 begin : Sat Aug 31 2002 4 begin : Sat Aug 31 2002
5 copyright : (C) 2002 by Andy Qua 5 copyright : (C) 2002 by Andy Qua
6 email : andy.qua@blueyonder.co.uk 6 email : andy.qua@blueyonder.co.uk
7 ***************************************************************************/ 7 ***************************************************************************/
8 8
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#include <fstream> 18#include <fstream>
19using namespace std; 19using namespace std;
20 20
21#include <stdio.h> 21#include <stdio.h>
22#include <unistd.h> 22#include <unistd.h>
23 23
24#ifdef QWS 24#ifdef QWS
25#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
26#else 26#else
27#include <qapplication.h> 27#include <qapplication.h>
28#endif 28#endif
29#include <qdir.h> 29#include <qdir.h>
30#include <qtextstream.h> 30#include <qtextstream.h>
31 31
32#include "utils.h" 32#include "utils.h"
33#include "ipkg.h" 33#include "ipkg.h"
34#include "global.h" 34#include "global.h"
35 35
36Ipkg :: Ipkg() 36Ipkg :: Ipkg()
37{ 37{
38} 38}
39 39
40Ipkg :: ~Ipkg() 40Ipkg :: ~Ipkg()
41{ 41{
42} 42}
43 43
44// Option is what we are going to do - install, upgrade, download, reinstall 44// Option is what we are going to do - install, upgrade, download, reinstall
45// package is the package name to install - either a fully qualified path and ipk 45// package is the package name to install - either a fully qualified path and ipk
46// file (if stored locally) or just the name of the package (for a network package) 46// file (if stored locally) or just the name of the package (for a network package)
47// packageName is the package name - (for a network package this will be the same as 47// packageName is the package name - (for a network package this will be the same as
48// package parameter) 48// package parameter)
49// dest is the destination alias (from ipk.conf) 49// dest is the destination alias (from ipk.conf)
50// destDir is the dir that the destination alias points to (used to link to root) 50// destDir is the dir that the destination alias points to (used to link to root)
51// flags is the ipkg options flags 51// flags is the ipkg options flags
52// dir is the directory to run ipkg in (defaults to "") 52// dir is the directory to run ipkg in (defaults to "")
53bool Ipkg :: runIpkg( ) 53bool Ipkg :: runIpkg( )
54{ 54{
55 bool ret = false; 55 bool ret = false;
56 56
57 QDir::setCurrent( "/tmp" ); 57 QDir::setCurrent( "/tmp" );
58 QString cmd = ""; 58 QString cmd = "";
59 59
60 if ( runtimeDir != "" ) 60 if ( runtimeDir != "" )
61 { 61 {
62 cmd += "cd "; 62 cmd += "cd ";
63 cmd += runtimeDir; 63 cmd += runtimeDir;
64 cmd += " ; "; 64 cmd += " ; ";
65 } 65 }
66 cmd += "ipkg"; 66 cmd += "ipkg -force-defaults";
67 67 if ( option != "update" && option != "download" )
68 if ( option != "update" && option != "download" && option != "upgrade" )
69 { 68 {
70 cmd += " -dest "+ destination; 69 cmd += " -dest "+ destination;
71 cmd += " -force-defaults";
72 70
73 if ( flags & FORCE_DEPENDS ) 71 if ( flags & FORCE_DEPENDS )
74 cmd += " -force-depends"; 72 cmd += " -force-depends";
75 if ( flags & FORCE_REINSTALL ) 73 if ( flags & FORCE_REINSTALL )
76 cmd += " -force-reinstall"; 74 cmd += " -force-reinstall";
77 if ( flags & FORCE_REMOVE ) 75 if ( flags & FORCE_REMOVE )
78 cmd += " -force-removal-of-essential-packages"; 76 cmd += " -force-removal-of-essential-packages";
79 if ( flags & FORCE_OVERWRITE ) 77 if ( flags & FORCE_OVERWRITE )
80 cmd += " -force-overwrite"; 78 cmd += " -force-overwrite";
81 79
82 // Handle make links 80 // Handle make links
83 // Rules - If make links is switched on, create links to root 81 // Rules - If make links is switched on, create links to root
84 // if destDir is NOT / 82 // if destDir is NOT /
85 if ( flags & MAKE_LINKS ) 83 if ( flags & MAKE_LINKS )
86 { 84 {
87 // If destDir == / turn off make links as package is being insalled 85 // If destDir == / turn off make links as package is being insalled
88 // to root already. 86 // to root already.
89 if ( destDir == "/" ) 87 if ( destDir == "/" )
90 flags ^= MAKE_LINKS; 88 flags ^= MAKE_LINKS;
91 } 89 }
92 } 90 }
93 91
94#ifdef X86 92#ifdef X86
95 cmd += " -f "; 93 cmd += " -f ";
96 cmd += IPKG_CONF; 94 cmd += IPKG_CONF;
97#endif 95#endif
98 96
99 97
100 if ( option == "reinstall" ) 98 if ( option == "reinstall" )
101 cmd += " install"; 99 cmd += " install";
102 else 100 else
103 cmd += " " + option; 101 cmd += " " + option;
104 if ( option != "upgrade" ) 102 if ( package != "" )
105 cmd += " " + package; 103 cmd += " " + package;
106 cmd += " 2>&1"; 104 cmd += " 2>&1";
107 105
108 106
109 if ( package != "" ) 107 if ( package != "" )
110 emit outputText( QString( "Dealing with package " ) + package ); 108 emit outputText( QString( "Dealing with package " ) + package );
111 109
112 qApp->processEvents(); 110 qApp->processEvents();
113 111
114 // If we are removing packages and make links option is selected 112 // If we are removing packages and make links option is selected
115 // create the links 113 // create the links
116 if ( option == "remove" || option == "reinstall" ) 114 if ( option == "remove" || option == "reinstall" )
117 { 115 {
118 createLinks = false; 116 createLinks = false;
119 if ( flags & MAKE_LINKS ) 117 if ( flags & MAKE_LINKS )
120 { 118 {
121 emit outputText( QString( "Removing symbolic links...\n" ) ); 119 emit outputText( QString( "Removing symbolic links...\n" ) );
122 linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir ); 120 linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir );
123 emit outputText( QString( " " ) ); 121 emit outputText( QString( " " ) );
124 } 122 }
125 } 123 }
126 124
127 emit outputText( cmd ); 125 emit outputText( cmd );
128 126
129 // Execute command 127 // Execute command
130 dependantPackages = new QList<QString>; 128 dependantPackages = new QList<QString>;
131 dependantPackages->setAutoDelete( true ); 129 dependantPackages->setAutoDelete( true );
132 130
133 ret = executeIpkgCommand( cmd, option ); 131 ret = executeIpkgCommand( cmd, option );
134 132
135 if ( option == "install" || option == "reinstall" ) 133 if ( option == "install" || option == "reinstall" )
136 { 134 {
137 // If we are not removing packages and make links option is selected 135 // If we are not removing packages and make links option is selected
138 // create the links 136 // create the links
139 createLinks = true; 137 createLinks = true;
140 if ( flags & MAKE_LINKS ) 138 if ( flags & MAKE_LINKS )
141 { 139 {
142 emit outputText( " " ); 140 emit outputText( " " );
143 emit outputText( QString( "Creating symbolic links for " )+ package ); 141 emit outputText( QString( "Creating symbolic links for " )+ package );
144 142
145 linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir ); 143 linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir );
146 144
147 // link dependant packages that were installed with this release 145 // link dependant packages that were installed with this release
148 QString *pkg; 146 QString *pkg;
149 for ( pkg = dependantPackages->first(); pkg != 0; pkg = dependantPackages->next() ) 147 for ( pkg = dependantPackages->first(); pkg != 0; pkg = dependantPackages->next() )
150 { 148 {
151 if ( *pkg == package ) 149 if ( *pkg == package )
152 continue; 150 continue;
153 emit outputText( " " ); 151 emit outputText( " " );
154 emit outputText( QString( "Creating symbolic links for " )+ (*pkg) ); 152 emit outputText( QString( "Creating symbolic links for " )+ (*pkg) );
155 linkPackage( Utils::getPackageNameFromIpkFilename( *pkg ), destination, destDir ); 153 linkPackage( Utils::getPackageNameFromIpkFilename( *pkg ), destination, destDir );
156 } 154 }
157 } 155 }
158 } 156 }
159 157
160 delete dependantPackages; 158 delete dependantPackages;
161 159
162 emit outputText( QString( "Finished - status=" ) + (ret ? "success" : "failure") ); 160 emit outputText( QString( "Finished - status=" ) + (ret ? "success" : "failure") );
163 emit outputText( "" ); 161 emit outputText( "" );
164 return ret; 162 return ret;
165} 163}
166 164
167 165
168int Ipkg :: executeIpkgCommand( QString &cmd, const QString option ) 166int Ipkg :: executeIpkgCommand( QString &cmd, const QString option )
169{ 167{
170 FILE *fp = NULL; 168 FILE *fp = NULL;
171 char line[130]; 169 char line[130];
172 QString lineStr, lineStrOld; 170 QString lineStr, lineStrOld;
173 int ret = false; 171 int ret = false;
174 172
175 fp = popen( (const char *) cmd, "r"); 173 fp = popen( (const char *) cmd, "r");
176 if ( fp == NULL ) 174 if ( fp == NULL )
177 { 175 {
178 cout << "Couldn't execute " << cmd << "! err = " << fp << endl; 176 cout << "Couldn't execute " << cmd << "! err = " << fp << endl;
179 QString text; 177 QString text;
180 text.sprintf( "Couldn't execute %s! See stdout for error code", (const char *)cmd ); 178 text.sprintf( "Couldn't execute %s! See stdout for error code", (const char *)cmd );
181 emit outputText( text ); 179 emit outputText( text );
182 } 180 }
183 else 181 else
184 { 182 {
185 while ( fgets( line, sizeof line, fp) != NULL ) 183 while ( fgets( line, sizeof line, fp) != NULL )
186 { 184 {
187 lineStr = line; 185 lineStr = line;
188 lineStr=lineStr.left( lineStr.length()-1 ); 186 lineStr=lineStr.left( lineStr.length()-1 );
189 187
190 if ( lineStr != lineStrOld ) 188 if ( lineStr != lineStrOld )
191 { 189 {
192 //See if we're finished 190 //See if we're finished
193 if ( option == "install" || option == "reinstall" ) 191 if ( option == "install" || option == "reinstall" )
194 { 192 {
195 // Need to keep track of any dependant packages that get installed 193 // Need to keep track of any dependant packages that get installed
196 // so that we can create links to them as necessary 194 // so that we can create links to them as necessary
197 if ( lineStr.startsWith( "Installing " ) ) 195 if ( lineStr.startsWith( "Installing " ) )
198 { 196 {
199 int start = lineStr.find( " " ) + 1; 197 int start = lineStr.find( " " ) + 1;
200 int end = lineStr.find( " ", start ); 198 int end = lineStr.find( " ", start );
201 QString *package = new QString( lineStr.mid( start, end-start ) ); 199 QString *package = new QString( lineStr.mid( start, end-start ) );
202 dependantPackages->append( package ); 200 dependantPackages->append( package );
203 } 201 }
204 } 202 }
205 203
206 if ( option == "update" ) 204 if ( option == "update" )
207 { 205 {
208 if (lineStr.contains("Updated list")) 206 if (lineStr.contains("Updated list"))
209 ret = true; 207 ret = true;
210 } 208 }
211 else if ( option == "download" ) 209 else if ( option == "download" )
212 { 210 {
213 if (lineStr.contains("Downloaded")) 211 if (lineStr.contains("Downloaded"))
214 ret = true; 212 ret = true;
215 } 213 }
216 else 214 else
217 { 215 {
218 if (lineStr.contains("Done")) 216 if (lineStr.contains("Done"))
219 ret = true; 217 ret = true;
220 } 218 }
221 219
222 emit outputText( lineStr ); 220 emit outputText( lineStr );
223 } 221 }
224 lineStrOld = lineStr; 222 lineStrOld = lineStr;
225 qApp->processEvents(); 223 qApp->processEvents();
226 } 224 }
227 pclose(fp); 225 pclose(fp);
228 } 226 }
229 227
230 return ret; 228 return ret;
231} 229}
232 230
233 231
234void Ipkg :: linkPackage( const QString &packFileName, const QString &dest, const QString &destDir ) 232void Ipkg :: linkPackage( const QString &packFileName, const QString &dest, const QString &destDir )
235{ 233{
236 if ( dest == "root" || dest == "/" ) 234 if ( dest == "root" || dest == "/" )
237 return; 235 return;
238 236
239 qApp->processEvents(); 237 qApp->processEvents();
240 QStringList *fileList = getList( packFileName, destDir ); 238 QStringList *fileList = getList( packFileName, destDir );
241 qApp->processEvents(); 239 qApp->processEvents();
242 processFileList( fileList, destDir ); 240 processFileList( fileList, destDir );
243 delete fileList; 241 delete fileList;
244} 242}
245 243
246QStringList* Ipkg :: getList( const QString &packageFilename, const QString &destDir ) 244QStringList* Ipkg :: getList( const QString &packageFilename, const QString &destDir )
247{ 245{
248 QString packageFileDir = destDir+"/usr/lib/ipkg/info/"+packageFilename+".list"; 246 QString packageFileDir = destDir+"/usr/lib/ipkg/info/"+packageFilename+".list";
249 QFile f( packageFileDir ); 247 QFile f( packageFileDir );
250 248
251 cout << "Try to open " << packageFileDir << endl; 249 cout << "Try to open " << packageFileDir << endl;
252 if ( !f.open(IO_ReadOnly) ) 250 if ( !f.open(IO_ReadOnly) )
253 { 251 {
254 // Couldn't open from dest, try from / 252 // Couldn't open from dest, try from /
255 cout << "Could not open:" << packageFileDir << endl; 253 cout << "Could not open:" << packageFileDir << endl;
256 f.close(); 254 f.close();
257 255
258 packageFileDir = "/usr/lib/ipkg/info/"+packageFilename+".list"; 256 packageFileDir = "/usr/lib/ipkg/info/"+packageFilename+".list";
259 f.setName( packageFileDir ); 257 f.setName( packageFileDir );
260// cout << "Try to open " << packageFileDir.latin1() << endl; 258// cout << "Try to open " << packageFileDir.latin1() << endl;
261 if ( ! f.open(IO_ReadOnly) ) 259 if ( ! f.open(IO_ReadOnly) )
262 { 260 {
263 cout << "Could not open:" << packageFileDir << endl; 261 cout << "Could not open:" << packageFileDir << endl;
264 emit outputText( QString( "Could not open :" ) + packageFileDir ); 262 emit outputText( QString( "Could not open :" ) + packageFileDir );
265 return (QStringList*)0; 263 return (QStringList*)0;
266 } 264 }
267 } 265 }
268 QStringList *fileList = new QStringList(); 266 QStringList *fileList = new QStringList();
269 QTextStream t( &f ); 267 QTextStream t( &f );
270 while ( !t.eof() ) 268 while ( !t.eof() )
271 *fileList += t.readLine(); 269 *fileList += t.readLine();
272 270
273 f.close(); 271 f.close();
274 return fileList; 272 return fileList;
275} 273}
276 274
277void Ipkg :: processFileList( const QStringList *fileList, const QString &destDir ) 275void Ipkg :: processFileList( const QStringList *fileList, const QString &destDir )
278{ 276{
279 if ( !fileList || fileList->isEmpty() ) 277 if ( !fileList || fileList->isEmpty() )
280 return; 278 return;
281 279
282 QString baseDir = ROOT; 280 QString baseDir = ROOT;
283 281
284 if ( createLinks == true ) 282 if ( createLinks == true )
285 { 283 {
286 for ( uint i=0; i < fileList->count(); i++ ) 284 for ( uint i=0; i < fileList->count(); i++ )
287 { 285 {
288 processLinkDir( (*fileList)[i], baseDir, destDir ); 286 processLinkDir( (*fileList)[i], baseDir, destDir );
289 qApp->processEvents(); 287 qApp->processEvents();
290 } 288 }
291 } 289 }
292 else 290 else
293 { 291 {
294 for ( int i = fileList->count()-1; i >= 0 ; i-- ) 292 for ( int i = fileList->count()-1; i >= 0 ; i-- )
295 { 293 {
296 processLinkDir( (*fileList)[i], baseDir, destDir ); 294 processLinkDir( (*fileList)[i], baseDir, destDir );
297 qApp->processEvents(); 295 qApp->processEvents();
298 } 296 }
299 } 297 }
300} 298}
301 299
302void Ipkg :: processLinkDir( const QString &file, const QString &destDir, const QString &baseDir ) 300void Ipkg :: processLinkDir( const QString &file, const QString &destDir, const QString &baseDir )
303{ 301{
304 302
305 QString sourceFile = baseDir + file; 303 QString sourceFile = baseDir + file;
306 304
307 QString linkFile = destDir; 305 QString linkFile = destDir;
308 if ( file.startsWith( "/" ) && destDir.right( 1 ) == "/" ) 306 if ( file.startsWith( "/" ) && destDir.right( 1 ) == "/" )
309 { 307 {
310 linkFile += file.mid( 1 ); 308 linkFile += file.mid( 1 );
311 } 309 }
312 else 310 else
313 { 311 {
314 linkFile += file; 312 linkFile += file;
315 } 313 }
316 QString text; 314 QString text;
317 if ( createLinks ) 315 if ( createLinks )
318 { 316 {
319 // If this file is a directory (ends with a /) and it doesn't exist, 317 // If this file is a directory (ends with a /) and it doesn't exist,
320 // we need to create it 318 // we need to create it
321 if ( file.right(1) == "/" ) 319 if ( file.right(1) == "/" )
322 { 320 {
323 QFileInfo f( linkFile ); 321 QFileInfo f( linkFile );
324 if ( !f.exists() ) 322 if ( !f.exists() )
325 { 323 {
326 emit outputText( QString( "Creating directory " ) + linkFile ); 324 emit outputText( QString( "Creating directory " ) + linkFile );
327 QDir d; 325 QDir d;
328 d.mkdir( linkFile, true ); 326 d.mkdir( linkFile, true );
329 } 327 }
330 else 328 else
331 emit outputText( QString( "Directory " ) + linkFile + " exists" ); 329 emit outputText( QString( "Directory " ) + linkFile + " exists" );
332 330
333 } 331 }
334 else 332 else
335 { 333 {
336 int rc = symlink( sourceFile, linkFile ); 334 int rc = symlink( sourceFile, linkFile );
337 text = (rc == 0 ? "Linked " : "Failed to link "); 335 text = (rc == 0 ? "Linked " : "Failed to link ");
338 text += sourceFile + " to " + linkFile; 336 text += sourceFile + " to " + linkFile;
339 emit outputText( text ); 337 emit outputText( text );
340 } 338 }
341 } 339 }
342 else 340 else
343 { 341 {
344 QFileInfo f( linkFile ); 342 QFileInfo f( linkFile );
345 if ( f.exists() ) 343 if ( f.exists() )
346 { 344 {
347 if ( f.isFile() ) 345 if ( f.isFile() )
348 { 346 {
349 QFile f( linkFile ); 347 QFile f( linkFile );
350 bool rc = f.remove(); 348 bool rc = f.remove();
351 349
352 text = (rc ? "Removed " : "Failed to remove "); 350 text = (rc ? "Removed " : "Failed to remove ");
353 text += linkFile; 351 text += linkFile;
354 emit outputText( text ); 352 emit outputText( text );
355 } 353 }
356 else if ( f.isDir() ) 354 else if ( f.isDir() )
357 { 355 {
358 QDir d; 356 QDir d;
359 bool rc = d.rmdir( linkFile, true ); 357 bool rc = d.rmdir( linkFile, true );
360 text = (rc ? "Removed " : "Failed to remove "); 358 text = (rc ? "Removed " : "Failed to remove ");
361 text += linkFile; 359 text += linkFile;
362 emit outputText( text ); 360 emit outputText( text );
363 } 361 }
364 } 362 }
365 } 363 }
366 364
367} 365}
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp
index a374266..3971aea 100644
--- a/noncore/settings/aqpkg/networkpkgmgr.cpp
+++ b/noncore/settings/aqpkg/networkpkgmgr.cpp
@@ -1,606 +1,610 @@
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
46NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name) 46NetworkPackageManager::NetworkPackageManager( DataManager *dataManager, QWidget *parent, const char *name)
47 : QWidget(parent, name) 47 : QWidget(parent, name)
48{ 48{
49 dataMgr = dataManager; 49 dataMgr = dataManager;
50 50
51#ifdef QWS 51#ifdef QWS
52 // read download directory from config file 52 // read download directory from config file
53 Config cfg( "aqpkg" ); 53 Config cfg( "aqpkg" );
54 cfg.setGroup( "settings" ); 54 cfg.setGroup( "settings" );
55 currentlySelectedServer = cfg.readEntry( "selectedServer", "local" ); 55 currentlySelectedServer = cfg.readEntry( "selectedServer", "local" );
56 showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" ); 56 showJumpTo = cfg.readBoolEntry( "showJumpTo", "true" );
57#endif 57#endif
58 58
59 59
60 initGui(); 60 initGui();
61 setupConnections(); 61 setupConnections();
62 62
63 updateData(); 63 updateData();
64// progressDlg = 0; 64// progressDlg = 0;
65// timerId = startTimer( 100 ); 65// timerId = startTimer( 100 );
66} 66}
67 67
68NetworkPackageManager::~NetworkPackageManager() 68NetworkPackageManager::~NetworkPackageManager()
69{ 69{
70} 70}
71 71
72void NetworkPackageManager :: timerEvent ( QTimerEvent * ) 72void NetworkPackageManager :: timerEvent ( QTimerEvent * )
73{ 73{
74 killTimer( timerId ); 74 killTimer( timerId );
75 75
76// showProgressDialog(); 76// showProgressDialog();
77 // Add server names to listbox 77 // Add server names to listbox
78 updateData(); 78 updateData();
79 79
80// progressDlg->hide(); 80// progressDlg->hide();
81} 81}
82 82
83void NetworkPackageManager :: updateData() 83void NetworkPackageManager :: updateData()
84{ 84{
85 serversList->clear(); 85 serversList->clear();
86 packagesList->clear(); 86 packagesList->clear();
87 87
88 88
89 vector<Server>::iterator it; 89 vector<Server>::iterator it;
90 int activeItem = -1; 90 int activeItem = -1;
91 int i; 91 int i;
92 for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i ) 92 for ( i = 0, it = dataMgr->getServerList().begin() ; it != dataMgr->getServerList().end() ; ++it, ++i )
93 { 93 {
94 if ( !it->isServerActive() ) 94 if ( !it->isServerActive() )
95 { 95 {
96 i--; 96 i--;
97 continue; 97 continue;
98 } 98 }
99 serversList->insertItem( it->getServerName() ); 99 serversList->insertItem( it->getServerName() );
100 if ( it->getServerName() == currentlySelectedServer ) 100 if ( it->getServerName() == currentlySelectedServer )
101 activeItem = i; 101 activeItem = i;
102 } 102 }
103 103
104 // set selected server to be active server 104 // set selected server to be active server
105 if ( activeItem != -1 ) 105 if ( activeItem != -1 )
106 serversList->setCurrentItem( activeItem ); 106 serversList->setCurrentItem( activeItem );
107 serverSelected( 0 ); 107 serverSelected( 0 );
108} 108}
109 109
110void NetworkPackageManager :: selectLocalPackage( const QString &pkg ) 110void NetworkPackageManager :: selectLocalPackage( const QString &pkg )
111{ 111{
112 // First select local server 112 // First select local server
113 for ( int i = 0 ; i < serversList->count() ; ++i ) 113 for ( int i = 0 ; i < serversList->count() ; ++i )
114 { 114 {
115 if ( serversList->text( i ) == LOCAL_IPKGS ) 115 if ( serversList->text( i ) == LOCAL_IPKGS )
116 { 116 {
117 serversList->setCurrentItem( i ); 117 serversList->setCurrentItem( i );
118 break; 118 break;
119 } 119 }
120 } 120 }
121 serverSelected( 0 ); 121 serverSelected( 0 );
122 122
123 // Now set the check box of the selected package 123 // Now set the check box of the selected package
124 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 124 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
125 item != 0 ; 125 item != 0 ;
126 item = (QCheckListItem *)item->nextSibling() ) 126 item = (QCheckListItem *)item->nextSibling() )
127 { 127 {
128 if ( item->text().startsWith( pkg ) ) 128 if ( item->text().startsWith( pkg ) )
129 { 129 {
130 item->setOn( true ); 130 item->setOn( true );
131 break; 131 break;
132 } 132 }
133 } 133 }
134} 134}
135 135
136 136
137void NetworkPackageManager :: initGui() 137void NetworkPackageManager :: initGui()
138{ 138{
139 QLabel *l = new QLabel( "Servers", this ); 139 QLabel *l = new QLabel( "Servers", this );
140 serversList = new QComboBox( this ); 140 serversList = new QComboBox( this );
141 packagesList = new QListView( this ); 141 packagesList = new QListView( this );
142 update = new QPushButton( "Refresh List", this ); 142 update = new QPushButton( "Refresh List", this );
143 download = new QPushButton( "Download", this ); 143 download = new QPushButton( "Download", this );
144 upgrade = new QPushButton( "Upgrade", this ); 144 upgrade = new QPushButton( "Upgrade", this );
145 apply = new QPushButton( "Apply", this ); 145 apply = new QPushButton( "Apply", this );
146 146
147 QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1, "VBox" ); 147 QVBoxLayout *vbox = new QVBoxLayout( this, 0, -1, "VBox" );
148 QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1, "HBox1" ); 148 QHBoxLayout *hbox1 = new QHBoxLayout( vbox, -1, "HBox1" );
149 hbox1->addWidget( l ); 149 hbox1->addWidget( l );
150 hbox1->addWidget( serversList ); 150 hbox1->addWidget( serversList );
151 151
152 QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1, "HBox1" ); 152 QHBoxLayout *hbox3 = new QHBoxLayout( vbox, -1, "HBox1" );
153 QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1, "HBox1" ); 153 QHBoxLayout *hbox4 = new QHBoxLayout( vbox, -1, "HBox1" );
154 154
155 155
156 if ( showJumpTo ) 156 if ( showJumpTo )
157 { 157 {
158 char text[2]; 158 char text[2];
159 text[1] = '\0'; 159 text[1] = '\0';
160 for ( int i = 0 ; i < 26 ; ++i ) 160 for ( int i = 0 ; i < 26 ; ++i )
161 { 161 {
162 text[0] = 'A' + i; 162 text[0] = 'A' + i;
163 LetterPushButton *b = new LetterPushButton( text, this ); 163 LetterPushButton *b = new LetterPushButton( text, this );
164 connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) ); 164 connect( b, SIGNAL( released( QString ) ), this, SLOT( letterPushed( QString ) ) );
165 if ( i < 13 ) 165 if ( i < 13 )
166 hbox3->addWidget( b ); 166 hbox3->addWidget( b );
167 else 167 else
168 hbox4->addWidget( b ); 168 hbox4->addWidget( b );
169 } 169 }
170 } 170 }
171 171
172 vbox->addWidget( packagesList ); 172 vbox->addWidget( packagesList );
173 packagesList->addColumn( "Packages" ); 173 packagesList->addColumn( "Packages" );
174 174
175 QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1, "HBox2" ); 175 QHBoxLayout *hbox2 = new QHBoxLayout( vbox, -1, "HBox2" );
176 hbox2->addWidget( update ); 176 hbox2->addWidget( update );
177 hbox2->addWidget( download ); 177 hbox2->addWidget( download );
178 hbox2->addWidget( upgrade ); 178 hbox2->addWidget( upgrade );
179 hbox2->addWidget( apply ); 179 hbox2->addWidget( apply );
180} 180}
181 181
182void NetworkPackageManager :: setupConnections() 182void NetworkPackageManager :: setupConnections()
183{ 183{
184 connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int ))); 184 connect( serversList, SIGNAL(activated( int )), this, SLOT(serverSelected( int )));
185 connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) ); 185 connect( apply, SIGNAL(released()), this, SLOT(applyChanges()) );
186 connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) ); 186 connect( download, SIGNAL(released()), this, SLOT(downloadPackage()) );
187 connect( upgrade, SIGNAL( released()), this, SLOT(upgradePackages()) ); 187 connect( upgrade, SIGNAL( released()), this, SLOT(upgradePackages()) );
188 connect( update, SIGNAL(released()), this, SLOT(updateServer()) ); 188 connect( update, SIGNAL(released()), this, SLOT(updateServer()) );
189} 189}
190 190
191void NetworkPackageManager :: showProgressDialog( char *initialText ) 191void NetworkPackageManager :: showProgressDialog( char *initialText )
192{ 192{
193 if ( !progressDlg ) 193 if ( !progressDlg )
194 progressDlg = new ProgressDlg( this, "Progress", false ); 194 progressDlg = new ProgressDlg( this, "Progress", false );
195 progressDlg->setText( initialText ); 195 progressDlg->setText( initialText );
196 progressDlg->show(); 196 progressDlg->show();
197} 197}
198 198
199 199
200void NetworkPackageManager :: serverSelected( int ) 200void NetworkPackageManager :: serverSelected( int )
201{ 201{
202 packagesList->clear(); 202 packagesList->clear();
203 203
204 // display packages 204 // display packages
205 QString serverName = serversList->currentText(); 205 QString serverName = serversList->currentText();
206 currentlySelectedServer = serverName; 206 currentlySelectedServer = serverName;
207 207
208#ifdef QWS 208#ifdef QWS
209 // read download directory from config file 209 // read download directory from config file
210 Config cfg( "aqpkg" ); 210 Config cfg( "aqpkg" );
211 cfg.setGroup( "settings" ); 211 cfg.setGroup( "settings" );
212 cfg.writeEntry( "selectedServer", currentlySelectedServer ); 212 cfg.writeEntry( "selectedServer", currentlySelectedServer );
213#endif 213#endif
214 214
215 Server *s = dataMgr->getServer( serverName ); 215 Server *s = dataMgr->getServer( serverName );
216// dataMgr->setActiveServer( serverName ); 216// dataMgr->setActiveServer( serverName );
217 217
218 vector<Package> &list = s->getPackageList(); 218 vector<Package> &list = s->getPackageList();
219 vector<Package>::iterator it; 219 vector<Package>::iterator it;
220 for ( it = list.begin() ; it != list.end() ; ++it ) 220 for ( it = list.begin() ; it != list.end() ; ++it )
221 { 221 {
222 QString text = ""; 222 QString text = "";
223 223
224 // If the local server, only display installed packages 224 // If the local server, only display installed packages
225 if ( serverName == LOCAL_SERVER && !it->isInstalled() ) 225 if ( serverName == LOCAL_SERVER && !it->isInstalled() )
226 continue; 226 continue;
227 227
228 text += it->getPackageName(); 228 text += it->getPackageName();
229 if ( it->isInstalled() ) 229 if ( it->isInstalled() )
230 { 230 {
231 text += " (installed)"; 231 text += " (installed)";
232 232
233 // If a different version of package is available, postfix it with an * 233 // If a different version of package is available, postfix it with an *
234 if ( it->getVersion() != it->getInstalledVersion() ) 234 if ( it->getVersion() != it->getInstalledVersion() )
235 text += "*"; 235 text += "*";
236 } 236 }
237 237
238 QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox ); 238 QCheckListItem *item = new QCheckListItem( packagesList, text, QCheckListItem::CheckBox );
239 239
240 if ( it->isInstalled() ) 240 if ( it->isInstalled() )
241 { 241 {
242 QString destName = ""; 242 QString destName = "";
243 if ( it->getLocalPackage() ) 243 if ( it->getLocalPackage() )
244 { 244 {
245 if ( it->getLocalPackage()->getInstalledTo() ) 245 if ( it->getLocalPackage()->getInstalledTo() )
246 destName = it->getLocalPackage()->getInstalledTo()->getDestinationName(); 246 destName = it->getLocalPackage()->getInstalledTo()->getDestinationName();
247 } 247 }
248 else 248 else
249 { 249 {
250 if ( it->getInstalledTo() ) 250 if ( it->getInstalledTo() )
251 destName = it->getInstalledTo()->getDestinationName(); 251 destName = it->getInstalledTo()->getDestinationName();
252 } 252 }
253 if ( destName != "" ) 253 if ( destName != "" )
254 new QCheckListItem( item, QString( "Installed To - " ) + destName ); 254 new QCheckListItem( item, QString( "Installed To - " ) + destName );
255 } 255 }
256 256
257 if ( !it->isPackageStoredLocally() ) 257 if ( !it->isPackageStoredLocally() )
258 new QCheckListItem( item, QString( "Description - " ) + it->getDescription() ); 258 new QCheckListItem( item, QString( "Description - " ) + it->getDescription() );
259 else 259 else
260 new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() ); 260 new QCheckListItem( item, QString( "Filename - " ) + it->getFilename() );
261 261
262 new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() ); 262 new QCheckListItem( item, QString( "V. Available - " ) + it->getVersion() );
263 if ( it->getLocalPackage() ) 263 if ( it->getLocalPackage() )
264 { 264 {
265 if ( it->isInstalled() ) 265 if ( it->isInstalled() )
266 new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() ); 266 new QCheckListItem( item, QString( "V. Installed - " ) + it->getInstalledVersion() );
267 } 267 }
268 packagesList->insertItem( item ); 268 packagesList->insertItem( item );
269 } 269 }
270 270
271 // If the local server or the local ipkgs server disable the download button 271 // If the local server or the local ipkgs server disable the download button
272 if ( serverName == LOCAL_SERVER ) 272 if ( serverName == LOCAL_SERVER )
273 { 273 {
274 upgrade->setEnabled( false ); 274 upgrade->setEnabled( false );
275 download->setText( "Download" ); 275 download->setText( "Download" );
276 download->setEnabled( false ); 276 download->setEnabled( false );
277 } 277 }
278 else if ( serverName == LOCAL_IPKGS ) 278 else if ( serverName == LOCAL_IPKGS )
279 { 279 {
280 upgrade->setEnabled( false ); 280 upgrade->setEnabled( false );
281 download->setEnabled( true ); 281 download->setEnabled( true );
282 download->setText( "Remove" ); 282 download->setText( "Remove" );
283 } 283 }
284 else 284 else
285 { 285 {
286 upgrade->setEnabled( true ); 286 upgrade->setEnabled( true );
287 download->setEnabled( true ); 287 download->setEnabled( true );
288 download->setText( "Download" ); 288 download->setText( "Download" );
289 } 289 }
290} 290}
291 291
292void NetworkPackageManager :: updateServer() 292void NetworkPackageManager :: updateServer()
293{ 293{
294 QString serverName = serversList->currentText(); 294 QString serverName = serversList->currentText();
295 295
296 // Update the current server 296 // Update the current server
297 // Display dialog 297 // Display dialog
298// ProgressDlg *progDlg = new ProgressDlg( this ); 298// ProgressDlg *progDlg = new ProgressDlg( this );
299// QString status = "Updating package lists..."; 299// QString status = "Updating package lists...";
300// progDlg->show(); 300// progDlg->show();
301// progDlg->setText( status ); 301// progDlg->setText( status );
302 302
303 // Disable buttons to stop silly people clicking lots on them :) 303 // Disable buttons to stop silly people clicking lots on them :)
304 304
305 // First, write out ipkg_conf file so that ipkg can use it 305 // First, write out ipkg_conf file so that ipkg can use it
306 dataMgr->writeOutIpkgConf(); 306 dataMgr->writeOutIpkgConf();
307 307
308 Ipkg ipkg; 308 Ipkg ipkg;
309 ipkg.setOption( "update" ); 309 ipkg.setOption( "update" );
310 310
311 InstallDlgImpl dlg( &ipkg, "Refreshing server package lists", this, "Upgrade", true ); 311 InstallDlgImpl dlg( &ipkg, "Refreshing server package lists", this, "Upgrade", true );
312 dlg.showDlg(); 312 dlg.showDlg();
313 313
314 // Reload data 314 // Reload data
315 dataMgr->reloadServerData( serversList->currentText() ); 315 dataMgr->reloadServerData( serversList->currentText() );
316 serverSelected(-1); 316 serverSelected(-1);
317// delete progDlg; 317// delete progDlg;
318} 318}
319 319
320void NetworkPackageManager :: upgradePackages() 320void NetworkPackageManager :: upgradePackages()
321{ 321{
322 // We're gonna do an upgrade of all packages 322 // We're gonna do an upgrade of all packages
323 // First warn user that this isn't recommended 323 // First warn user that this isn't recommended
324 QString text = "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n"; 324 QString text = "WARNING: Upgrading while\nOpie/Qtopia is running\nis NOT recommended!\n\nAre you sure?\n";
325 QMessageBox warn("Warning", text, QMessageBox::Warning, 325 QMessageBox warn("Warning", text, QMessageBox::Warning,
326 QMessageBox::Yes, 326 QMessageBox::Yes,
327 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default , 327 QMessageBox::No | QMessageBox::Escape | QMessageBox::Default ,
328 0, this ); 328 0, this );
329 warn.adjustSize(); 329 warn.adjustSize();
330 330
331 if ( warn.exec() == QMessageBox::Yes ) 331 if ( warn.exec() == QMessageBox::Yes )
332 { 332 {
333 // First, write out ipkg_conf file so that ipkg can use it 333 // First, write out ipkg_conf file so that ipkg can use it
334 dataMgr->writeOutIpkgConf(); 334 dataMgr->writeOutIpkgConf();
335 335
336 // Now run upgrade 336 // Now run upgrade
337 Ipkg ipkg; 337 Ipkg ipkg;
338 ipkg.setOption( "upgrade" ); 338 ipkg.setOption( "upgrade" );
339 339
340 InstallDlgImpl dlg( &ipkg, "Upgrading installed packages", this, "Upgrade", true ); 340 InstallDlgImpl dlg( &ipkg, "Upgrading installed packages", this, "Upgrade", true );
341 dlg.showDlg(); 341 dlg.showDlg();
342 342
343 // Reload data 343 // Reload data
344 dataMgr->reloadServerData( LOCAL_SERVER ); 344 dataMgr->reloadServerData( LOCAL_SERVER );
345 345
346 dataMgr->reloadServerData( serversList->currentText() ); 346 dataMgr->reloadServerData( serversList->currentText() );
347 serverSelected(-1); 347 serverSelected(-1);
348 } 348 }
349} 349}
350 350
351 351
352void NetworkPackageManager :: downloadPackage() 352void NetworkPackageManager :: downloadPackage()
353{ 353{
354 if ( download->text() == "Download" ) 354 if ( download->text() == "Download" )
355 { 355 {
356 // First, write out ipkg_conf file so that ipkg can use it 356 // First, write out ipkg_conf file so that ipkg can use it
357 dataMgr->writeOutIpkgConf(); 357 dataMgr->writeOutIpkgConf();
358 358
359 // Display dialog to user asking where to download the files to 359 // Display dialog to user asking where to download the files to
360 bool ok = FALSE; 360 bool ok = FALSE;
361 QString dir = ""; 361 QString dir = "";
362#ifdef QWS 362#ifdef QWS
363 // read download directory from config file 363 // read download directory from config file
364 Config cfg( "aqpkg" ); 364 Config cfg( "aqpkg" );
365 cfg.setGroup( "settings" ); 365 cfg.setGroup( "settings" );
366 dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" ); 366 dir = cfg.readEntry( "downloadDir", "/home/root/Documents/application/ipkg" );
367#endif 367#endif
368 368
369 QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this ); 369 QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), dir, &ok, this );
370 if ( ok && !text.isEmpty() ) 370 if ( ok && !text.isEmpty() )
371 dir = text; // user entered something and pressed ok 371 dir = text; // user entered something and pressed ok
372 else 372 else
373 return; // user entered nothing or pressed cancel 373 return; // user entered nothing or pressed cancel
374 374
375#ifdef QWS 375#ifdef QWS
376 // Store download directory in config file 376 // Store download directory in config file
377 cfg.writeEntry( "downloadDir", dir ); 377 cfg.writeEntry( "downloadDir", dir );
378#endif 378#endif
379 379
380 // Get starting directory 380 // Get starting directory
381 char initDir[PATH_MAX]; 381 char initDir[PATH_MAX];
382 getcwd( initDir, PATH_MAX ); 382 getcwd( initDir, PATH_MAX );
383 383
384 // Download each package 384 // Download each package
385 Ipkg ipkg; 385 Ipkg ipkg;
386 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &))); 386 connect( &ipkg, SIGNAL(outputText(const QString &)), this, SLOT(displayText(const QString &)));
387 387
388 ipkg.setOption( "download" ); 388 ipkg.setOption( "download" );
389 ipkg.setRuntimeDirectory( dir ); 389 ipkg.setRuntimeDirectory( dir );
390 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 390 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
391 item != 0 ; 391 item != 0 ;
392 item = (QCheckListItem *)item->nextSibling() ) 392 item = (QCheckListItem *)item->nextSibling() )
393 { 393 {
394 if ( item->isOn() ) 394 if ( item->isOn() )
395 { 395 {
396 QString name = item->text(); 396 QString name = item->text();
397 int pos = name.find( "*" ); 397 int pos = name.find( "*" );
398 name.truncate( pos ); 398 name.truncate( pos );
399 399
400 // if (there is a (installed), remove it 400 // if (there is a (installed), remove it
401 pos = name.find( "(installed)" ); 401 pos = name.find( "(installed)" );
402 if ( pos > 0 ) 402 if ( pos > 0 )
403 name.truncate( pos - 1 ); 403 name.truncate( pos - 1 );
404 404
405 ipkg.setPackage( name ); 405 ipkg.setPackage( name );
406 ipkg.runIpkg( ); 406 ipkg.runIpkg( );
407 } 407 }
408 } 408 }
409 } 409 }
410 else if ( download->text() == "Remove" ) 410 else if ( download->text() == "Remove" )
411 { 411 {
412 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 412 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
413 item != 0 ; 413 item != 0 ;
414 item = (QCheckListItem *)item->nextSibling() ) 414 item = (QCheckListItem *)item->nextSibling() )
415 { 415 {
416 if ( item->isOn() ) 416 if ( item->isOn() )
417 { 417 {
418 QString name = item->text(); 418 QString name = item->text();
419 int pos = name.find( "*" ); 419 int pos = name.find( "*" );
420 name.truncate( pos ); 420 name.truncate( pos );
421 421
422 // if (there is a (installed), remove it 422 // if (there is a (installed), remove it
423 pos = name.find( "(installed)" ); 423 pos = name.find( "(installed)" );
424 if ( pos > 0 ) 424 if ( pos > 0 )
425 name.truncate( pos - 1 ); 425 name.truncate( pos - 1 );
426 426
427 Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name ); 427 Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name );
428 QFile f( p->getFilename() ); 428 QFile f( p->getFilename() );
429 f.remove(); 429 f.remove();
430 } 430 }
431 } 431 }
432 } 432 }
433 433
434 dataMgr->reloadServerData( LOCAL_IPKGS ); 434 dataMgr->reloadServerData( LOCAL_IPKGS );
435 serverSelected( -1 ); 435 serverSelected( -1 );
436} 436}
437 437
438 438
439void NetworkPackageManager :: applyChanges() 439void NetworkPackageManager :: applyChanges()
440{ 440{
441 stickyOption = ""; 441 stickyOption = "";
442 442
443 // First, write out ipkg_conf file so that ipkg can use it 443 // First, write out ipkg_conf file so that ipkg can use it
444 dataMgr->writeOutIpkgConf(); 444 dataMgr->writeOutIpkgConf();
445 445
446 // Now for each selected item 446 // Now for each selected item
447 // deal with it 447 // deal with it
448 448
449 vector<InstallData> workingPackages; 449 vector<InstallData> workingPackages;
450 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild(); 450 for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
451 item != 0 ; 451 item != 0 ;
452 item = (QCheckListItem *)item->nextSibling() ) 452 item = (QCheckListItem *)item->nextSibling() )
453 { 453 {
454 if ( item->isOn() ) 454 if ( item->isOn() )
455 { 455 {
456 InstallData data = dealWithItem( item ); 456 InstallData data = dealWithItem( item );
457 workingPackages.push_back( data ); 457 workingPackages.push_back( data );
458 } 458 }
459 } 459 }
460 460
461 if ( workingPackages.size() == 0 ) 461 if ( workingPackages.size() == 0 )
462 { 462 {
463 // Nothing to do 463 // Nothing to do
464 QMessageBox::information( this, "Nothing to do", 464 QMessageBox::information( this, "Nothing to do",
465 "No packages selected", "OK" ); 465 "No packages selected", "OK" );
466 466
467 return; 467 return;
468 } 468 }
469 469
470 // do the stuff 470 // do the stuff
471 InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true ); 471 InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true );
472 dlg.showDlg(); 472 dlg.showDlg();
473 473
474 // Reload data 474 // Reload data
475 dataMgr->reloadServerData( LOCAL_SERVER ); 475 dataMgr->reloadServerData( LOCAL_SERVER );
476 476
477 dataMgr->reloadServerData( serversList->currentText() ); 477 dataMgr->reloadServerData( serversList->currentText() );
478 serverSelected(-1); 478 serverSelected(-1);
479 479
480#ifdef QWS 480#ifdef QWS
481 // Finally let the main system update itself 481 // Finally let the main system update itself
482 QCopEnvelope e("QPE/System", "linkChanged(QString)"); 482 QCopEnvelope e("QPE/System", "linkChanged(QString)");
483 QString lf = QString::null; 483 QString lf = QString::null;
484 e << lf; 484 e << lf;
485#endif 485#endif
486} 486}
487 487
488// decide what to do - either remove, upgrade or install 488// decide what to do - either remove, upgrade or install
489// Current rules: 489// Current rules:
490// If not installed - install 490// If not installed - install
491// If installed and different version available - upgrade 491// If installed and different version available - upgrade
492// If installed and version up to date - remove 492// If installed and version up to date - remove
493InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item ) 493InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item )
494{ 494{
495 QString name = item->text(); 495 QString name = item->text();
496 int pos = name.find( "*" ); 496 int pos = name.find( "*" );
497 name.truncate( pos ); 497 name.truncate( pos );
498 498
499 // if (there is a (installed), remove it 499 // if (there is a (installed), remove it
500 pos = name.find( "(installed)" ); 500 pos = name.find( "(installed)" );
501 if ( pos > 0 ) 501 if ( pos > 0 )
502 name.truncate( pos - 1 ); 502 name.truncate( pos - 1 );
503 503
504 // Get package 504 // Get package
505 Server *s = dataMgr->getServer( serversList->currentText() ); 505 Server *s = dataMgr->getServer( serversList->currentText() );
506 Package *p = s->getPackage( name ); 506 Package *p = s->getPackage( name );
507 507
508 // If the package has a filename then it is a local file 508 // If the package has a filename then it is a local file
509 if ( p->isPackageStoredLocally() ) 509 if ( p->isPackageStoredLocally() )
510 name = p->getFilename(); 510 name = p->getFilename();
511 QString option; 511 QString option;
512 QString dest = "root"; 512 QString dest = "root";
513 if ( !p->isInstalled() ) 513 if ( !p->isInstalled() )
514 { 514 {
515 InstallData item; 515 InstallData item;
516 item.option = "I"; 516 item.option = "I";
517 item.packageName = name; 517 item.packageName = name;
518 return item; 518 return item;
519 } 519 }
520 else 520 else
521 { 521 {
522 InstallData item; 522 InstallData item;
523 item.option = "D"; 523 item.option = "D";
524 item.packageName = p->getInstalledPackageName(); 524 item.packageName = p->getInstalledPackageName();
525 if ( p->getInstalledTo() ) 525 if ( p->getInstalledTo() )
526 { 526 {
527 item.destination = p->getInstalledTo(); 527 item.destination = p->getInstalledTo();
528 cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl; 528 cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl;
529 cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl; 529 cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl;
530 } 530 }
531 else 531 else
532 { 532 {
533 item.destination = p->getLocalPackage()->getInstalledTo(); 533 item.destination = p->getLocalPackage()->getInstalledTo();
534 } 534 }
535 535
536 // Sticky option not implemented yet, but will eventually allow 536 // Sticky option not implemented yet, but will eventually allow
537 // the user to say something like 'remove all' 537 // the user to say something like 'remove all'
538 if ( stickyOption == "" ) 538 if ( stickyOption == "" )
539 { 539 {
540 QString msgtext; 540 QString msgtext;
541 msgtext.sprintf( "Do you wish to remove or reinstall\n%s?", (const char *)name ); 541 msgtext.sprintf( "Do you wish to remove or reinstall\n%s?", (const char *)name );
542 switch( QMessageBox::information( this, "Remove or ReInstall", 542 switch( QMessageBox::information( this, "Remove or ReInstall",
543 msgtext, "Remove", "ReInstall" ) ) 543 msgtext, "Remove", "ReInstall" ) )
544 { 544 {
545 case 0: // Try again or Enter 545 case 0: // Try again or Enter
546 item.option = "D"; 546 item.option = "D";
547 break; 547 break;
548 case 1: // Quit or Escape 548 case 1: // Quit or Escape
549 item.option = "U"; 549 item.option = "U";
550 break; 550 break;
551 } 551 }
552 } 552 }
553 else 553 else
554 { 554 {
555// item.option = stickyOption; 555// item.option = stickyOption;
556 } 556 }
557 557
558 // Check if we are reinstalling the same version 558 // Check if we are reinstalling the same version
559 if ( p->getVersion() != p->getInstalledVersion() ) 559 if ( p->getVersion() != p->getInstalledVersion() )
560 item.recreateLinks = true; 560 item.recreateLinks = true;
561 else 561 else
562 {
563 if ( item.option == "U" )
564 item.option = "R";
562 item.recreateLinks = false; 565 item.recreateLinks = false;
566 }
563 567
564 // User hit cancel (on dlg - assume remove) 568 // User hit cancel (on dlg - assume remove)
565 return item; 569 return item;
566 } 570 }
567} 571}
568 572
569void NetworkPackageManager :: displayText( const QString &t ) 573void NetworkPackageManager :: displayText( const QString &t )
570{ 574{
571 cout << t << endl; 575 cout << t << endl;
572} 576}
573 577
574 578
575void NetworkPackageManager :: letterPushed( QString t ) 579void NetworkPackageManager :: letterPushed( QString t )
576{ 580{
577 QCheckListItem *top = (QCheckListItem *)packagesList->firstChild(); 581 QCheckListItem *top = (QCheckListItem *)packagesList->firstChild();
578 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem(); 582 QCheckListItem *start = (QCheckListItem *)packagesList->currentItem();
579 if ( packagesList->firstChild() == 0 ) 583 if ( packagesList->firstChild() == 0 )
580 return; 584 return;
581 585
582 QCheckListItem *item; 586 QCheckListItem *item;
583 if ( start == 0 ) 587 if ( start == 0 )
584 { 588 {
585 item = (QCheckListItem *)packagesList->firstChild(); 589 item = (QCheckListItem *)packagesList->firstChild();
586 start = top; 590 start = top;
587 } 591 }
588 else 592 else
589 item = (QCheckListItem *)start->nextSibling(); 593 item = (QCheckListItem *)start->nextSibling();
590 594
591 if ( item == 0 ) 595 if ( item == 0 )
592 item = (QCheckListItem *)packagesList->firstChild(); 596 item = (QCheckListItem *)packagesList->firstChild();
593 do 597 do
594 { 598 {
595 if ( item->text().lower().startsWith( t.lower() ) ) 599 if ( item->text().lower().startsWith( t.lower() ) )
596 { 600 {
597 packagesList->setSelected( item, true ); 601 packagesList->setSelected( item, true );
598 packagesList->ensureItemVisible( item ); 602 packagesList->ensureItemVisible( item );
599 break; 603 break;
600 } 604 }
601 605
602 item = (QCheckListItem *)item->nextSibling(); 606 item = (QCheckListItem *)item->nextSibling();
603 if ( !item ) 607 if ( !item )
604 item = (QCheckListItem *)packagesList->firstChild(); 608 item = (QCheckListItem *)packagesList->firstChild();
605 } while ( item != start); 609 } while ( item != start);
606} 610}