author | andyq <andyq> | 2002-10-17 22:58:36 (UTC) |
---|---|---|
committer | andyq <andyq> | 2002-10-17 22:58:36 (UTC) |
commit | cd48ed3935f1baa6392afee5764d0927abcf62cc (patch) (unidiff) | |
tree | 54423b7242c59457ded23ce0dd1e89ce05b630b1 | |
parent | 4ce3fb5c10a50aece4ef8a78d07ed116ad754c27 (diff) | |
download | opie-cd48ed3935f1baa6392afee5764d0927abcf62cc.zip opie-cd48ed3935f1baa6392afee5764d0927abcf62cc.tar.gz opie-cd48ed3935f1baa6392afee5764d0927abcf62cc.tar.bz2 |
Changed so that installings/removing and upgrading from/to multiple destinations
works better
-rw-r--r-- | noncore/settings/aqpkg/installdlgimpl.cpp | 67 | ||||
-rw-r--r-- | noncore/settings/aqpkg/installdlgimpl.h | 17 | ||||
-rw-r--r-- | noncore/settings/aqpkg/ipkg.cpp | 23 | ||||
-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.cpp | 88 | ||||
-rw-r--r-- | noncore/settings/aqpkg/networkpkgmgr.h | 4 |
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 | |||
@@ -29,13 +29,13 @@ | |||
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 | ||
35 | InstallDlgImpl::InstallDlgImpl( vector<QString> &packageList, DataManager *dataManager, QWidget * parent, const char* name, bool modal, WFlags fl ) | 35 | InstallDlgImpl::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 | ||
@@ -43,13 +43,14 @@ InstallDlgImpl::InstallDlgImpl( vector<QString> &packageList, DataManager *dataM | |||
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 ); |
@@ -67,34 +68,34 @@ InstallDlgImpl::InstallDlgImpl( vector<QString> &packageList, DataManager *dataM | |||
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 &))); |
@@ -133,14 +134,12 @@ void InstallDlgImpl :: optionsSelected() | |||
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 |
@@ -168,44 +167,66 @@ void InstallDlgImpl :: installSelected() | |||
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" ) ); |
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 | |||
@@ -22,29 +22,38 @@ using 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 | ||
28 | class InstallData | ||
29 | { | ||
30 | public: | ||
31 | QString option; // I - install, D - delete, U - upgrade | ||
32 | QString packageName; | ||
33 | Destination *destination; | ||
34 | bool recreateLinks; | ||
35 | }; | ||
36 | |||
28 | class InstallDlgImpl : public InstallDlg | 37 | class InstallDlgImpl : public InstallDlg |
29 | { | 38 | { |
30 | public: | 39 | public: |
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 | ||
38 | protected: | 47 | protected: |
39 | 48 | ||
40 | private: | 49 | private: |
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 | ||
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 | |||
@@ -38,13 +38,13 @@ Ipkg :: Ipkg() | |||
38 | } | 38 | } |
39 | 39 | ||
40 | Ipkg :: ~Ipkg() | 40 | Ipkg :: ~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) |
@@ -86,30 +86,36 @@ bool Ipkg :: runIpkg( ) | |||
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 ); |
@@ -122,13 +128,13 @@ bool Ipkg :: runIpkg( ) | |||
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 | { |
@@ -150,12 +156,13 @@ bool Ipkg :: runIpkg( ) | |||
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 | ||
160 | int Ipkg :: executeIpkgCommand( QString &cmd, const QString option ) | 167 | int Ipkg :: executeIpkgCommand( QString &cmd, const QString option ) |
161 | { | 168 | { |
@@ -179,13 +186,13 @@ int Ipkg :: executeIpkgCommand( QString &cmd, const QString option ) | |||
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; |
@@ -239,17 +246,17 @@ void Ipkg :: linkPackage( const QString &packFileName, const QString &dest, cons | |||
239 | 246 | ||
240 | QStringList* Ipkg :: getList( const QString &packageFilename, const QString &destDir ) | 247 | QStringList* 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) ) |
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 | |||
@@ -201,12 +201,30 @@ void NetworkPackageManager :: serverSelected( int ) | |||
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() ); |
@@ -252,26 +270,19 @@ void NetworkPackageManager :: updateServer() | |||
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 | } |
@@ -391,29 +402,29 @@ void NetworkPackageManager :: downloadPackage() | |||
391 | serverSelected( -1 ); | 402 | serverSelected( -1 ); |
392 | } | 403 | } |
393 | 404 | ||
394 | 405 | ||
395 | void NetworkPackageManager :: applyChanges() | 406 | void 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(); |
@@ -434,13 +445,13 @@ void NetworkPackageManager :: applyChanges() | |||
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 |
440 | QString NetworkPackageManager :: dealWithItem( QCheckListItem *item ) | 451 | InstallData 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 |
@@ -455,35 +466,58 @@ QString NetworkPackageManager :: dealWithItem( QCheckListItem *item ) | |||
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 | ||
487 | void NetworkPackageManager :: displayText( const QString &t ) | 521 | void NetworkPackageManager :: displayText( const QString &t ) |
488 | { | 522 | { |
489 | cout << t << endl; | 523 | cout << t << endl; |
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 | |||
@@ -23,12 +23,13 @@ | |||
23 | #include <qwidget.h> | 23 | #include <qwidget.h> |
24 | #include <qcombobox.h> | 24 | #include <qcombobox.h> |
25 | #include <qlistview.h> | 25 | #include <qlistview.h> |
26 | 26 | ||
27 | #include "datamgr.h" | 27 | #include "datamgr.h" |
28 | #include "progressdlg.h" | 28 | #include "progressdlg.h" |
29 | class InstallData; | ||
29 | 30 | ||
30 | /** NetworkPackageManager is the base class of the project */ | 31 | /** NetworkPackageManager is the base class of the project */ |
31 | class NetworkPackageManager : public QWidget | 32 | class NetworkPackageManager : public QWidget |
32 | { | 33 | { |
33 | Q_OBJECT | 34 | Q_OBJECT |
34 | public: | 35 | public: |
@@ -56,13 +57,14 @@ private: | |||
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 | ||
64 | public slots: | 66 | public 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(); |