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