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
@@ -32,7 +32,7 @@
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;
@@ -46,7 +46,8 @@ InstallDlgImpl::InstallDlgImpl( vector<QString> &packageList, DataManager *dataM
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
@@ -70,28 +71,28 @@ InstallDlgImpl::InstallDlgImpl( vector<QString> &packageList, DataManager *dataM
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
@@ -136,8 +137,6 @@ void InstallDlgImpl :: optionsSelected()
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" );
@@ -171,6 +170,9 @@ void InstallDlgImpl :: installSelected()
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
@@ -180,29 +182,48 @@ void InstallDlgImpl :: installSelected()
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 }
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
@@ -25,10 +25,19 @@ using namespace std;
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
@@ -39,9 +48,9 @@ protected:
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;
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
@@ -41,7 +41,7 @@ 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
@@ -89,7 +89,6 @@ bool Ipkg :: runIpkg( )
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
@@ -97,16 +96,23 @@ bool Ipkg :: runIpkg( )
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 )
@@ -125,7 +131,7 @@ bool Ipkg :: runIpkg( )
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
@@ -153,6 +159,7 @@ bool Ipkg :: runIpkg( )
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
@@ -182,7 +189,7 @@ int Ipkg :: executeIpkgCommand( QString &cmd, const QString option )
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
@@ -242,11 +249,11 @@ QStringList* Ipkg :: getList( const QString &packageFilename, const QString &des
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";
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
@@ -204,6 +204,24 @@ void NetworkPackageManager :: serverSelected( int )
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
@@ -255,20 +273,13 @@ void NetworkPackageManager :: updateServer()
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() );
@@ -394,7 +405,7 @@ void NetworkPackageManager :: downloadPackage()
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();
@@ -402,15 +413,15 @@ void NetworkPackageManager :: applyChanges()
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
@@ -437,7 +448,7 @@ void NetworkPackageManager :: applyChanges()
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( "*" );
@@ -458,10 +469,25 @@ QString NetworkPackageManager :: dealWithItem( QCheckListItem *item )
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 );
@@ -469,18 +495,26 @@ QString NetworkPackageManager :: dealWithItem( QCheckListItem *item )
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
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
@@ -26,6 +26,7 @@
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
@@ -59,7 +60,8 @@ private:
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 );