summaryrefslogtreecommitdiff
path: root/noncore/settings
Unidiff
Diffstat (limited to 'noncore/settings') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/global.h2
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.cpp20
-rw-r--r--noncore/settings/aqpkg/server.cpp8
3 files changed, 23 insertions, 7 deletions
diff --git a/noncore/settings/aqpkg/global.h b/noncore/settings/aqpkg/global.h
index 96ab46c..a4363b4 100644
--- a/noncore/settings/aqpkg/global.h
+++ b/noncore/settings/aqpkg/global.h
@@ -1,69 +1,69 @@
1/*************************************************************************** 1/***************************************************************************
2 global.h - description 2 global.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 17
18#ifndef __GLOBAL_H 18#ifndef __GLOBAL_H
19#define __GLOBAL_H 19#define __GLOBAL_H
20 20
21#define VERSION_TEXT "AQPkg Version 0.7" 21#define VERSION_TEXT "AQPkg Version 0.8"
22 22
23// Uncomment the below line to run on a Linux box rather than a Zaurus 23// Uncomment the below line to run on a Linux box rather than a Zaurus
24// box this allows you to change where root is, and where to load config files from 24// box this allows you to change where root is, and where to load config files from
25// #define X86 25// #define X86
26 26
27// Sets up location of ipkg.conf and root directory 27// Sets up location of ipkg.conf and root directory
28#ifdef QWS 28#ifdef QWS
29 29
30#ifndef X86 30#ifndef X86
31 31
32// Running QT/Embedded on an arm processor 32// Running QT/Embedded on an arm processor
33#define IPKG_CONF "/etc/ipkg.conf" 33#define IPKG_CONF "/etc/ipkg.conf"
34#define ROOT "/" 34#define ROOT "/"
35#define IPKG_DIR "/usr/lib/ipkg/" 35#define IPKG_DIR "/usr/lib/ipkg/"
36 36
37#else 37#else
38 38
39// Running QT/Embedded on a X86 linux box 39// Running QT/Embedded on a X86 linux box
40#define IPKG_CONF "/home/andy/projects/aqpkg/aqpkg/data/ipkg.conf" 40#define IPKG_CONF "/home/andy/projects/aqpkg/aqpkg/data/ipkg.conf"
41#define ROOT "/home/andy/projects/aqpkg/aqpkg/data/root" 41#define ROOT "/home/andy/projects/aqpkg/aqpkg/data/root"
42#define IPKG_DIR "/home/andy/projects/aqpkg/aqpkg/data/" 42#define IPKG_DIR "/home/andy/projects/aqpkg/aqpkg/data/"
43 43
44#endif 44#endif
45 45
46#else 46#else
47 47
48// Running QT on a X86 linux box 48// Running QT on a X86 linux box
49#define IPKG_CONF "/home/andy/projects/aqpkg/aqpkg/data/ipkg.conf" 49#define IPKG_CONF "/home/andy/projects/aqpkg/aqpkg/data/ipkg.conf"
50#define ROOT "/home/andy/projects/aqpkg/aqpkg/data/root" 50#define ROOT "/home/andy/projects/aqpkg/aqpkg/data/root"
51#define IPKG_DIR "/home/andy/projects/aqpkg/aqpkg/data/" 51#define IPKG_DIR "/home/andy/projects/aqpkg/aqpkg/data/"
52 52
53#endif 53#endif
54 54
55 55
56// Uncomment the below line to turn on memory checking 56// Uncomment the below line to turn on memory checking
57//#define _DEBUG 1 57//#define _DEBUG 1
58 58
59#ifndef __MEMFILE_C 59#ifndef __MEMFILE_C
60#ifdef _DEBUG 60#ifdef _DEBUG
61void * operator new(unsigned int size,const char *file, int line); 61void * operator new(unsigned int size,const char *file, int line);
62void operator delete(void *p); 62void operator delete(void *p);
63#endif 63#endif
64 64
65#ifdef _DEBUG 65#ifdef _DEBUG
66#define DEBUG_NEW new(__FILE__, __LINE__) 66#define DEBUG_NEW new(__FILE__, __LINE__)
67//#define DEBUG_NEW new 67//#define DEBUG_NEW new
68#else 68#else
69#define DEBUG_NEW new 69#define DEBUG_NEW new
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp
index 3d06aef..dee834e 100644
--- a/noncore/settings/aqpkg/networkpkgmgr.cpp
+++ b/noncore/settings/aqpkg/networkpkgmgr.cpp
@@ -469,126 +469,136 @@ void NetworkPackageManager :: applyChanges()
469 } 469 }
470 } 470 }
471 471
472 if ( workingPackages.size() == 0 ) 472 if ( workingPackages.size() == 0 )
473 { 473 {
474 // Nothing to do 474 // Nothing to do
475 QMessageBox::information( this, "Nothing to do", 475 QMessageBox::information( this, "Nothing to do",
476 "No packages selected", "OK" ); 476 "No packages selected", "OK" );
477 477
478 return; 478 return;
479 } 479 }
480 480
481 // do the stuff 481 // do the stuff
482 InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true ); 482 InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true );
483 dlg.showDlg(); 483 dlg.showDlg();
484 484
485 // Reload data 485 // Reload data
486 dataMgr->reloadServerData(); 486 dataMgr->reloadServerData();
487 serverSelected(-1); 487 serverSelected(-1);
488 488
489#ifdef QWS 489#ifdef QWS
490 // Finally let the main system update itself 490 // Finally let the main system update itself
491 QCopEnvelope e("QPE/System", "linkChanged(QString)"); 491 QCopEnvelope e("QPE/System", "linkChanged(QString)");
492 QString lf = QString::null; 492 QString lf = QString::null;
493 e << lf; 493 e << lf;
494#endif 494#endif
495} 495}
496 496
497// decide what to do - either remove, upgrade or install 497// decide what to do - either remove, upgrade or install
498// Current rules: 498// Current rules:
499// If not installed - install 499// If not installed - install
500// If installed and different version available - upgrade 500// If installed and different version available - upgrade
501// If installed and version up to date - remove 501// If installed and version up to date - remove
502InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item ) 502InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item )
503{ 503{
504 QString name = item->text(); 504 QString name = item->text();
505 int pos = name.find( "*" ); 505 int pos = name.find( "*" );
506 name.truncate( pos ); 506 name.truncate( pos );
507 507
508 // if (there is a (installed), remove it 508 // if (there is a (installed), remove it
509 pos = name.find( "(installed)" ); 509 pos = name.find( "(installed)" );
510 if ( pos > 0 ) 510 if ( pos > 0 )
511 name.truncate( pos - 1 ); 511 name.truncate( pos - 1 );
512 512
513 // Get package 513 // Get package
514 Server *s = dataMgr->getServer( serversList->currentText() ); 514 Server *s = dataMgr->getServer( serversList->currentText() );
515 Package *p = s->getPackage( name ); 515 Package *p = s->getPackage( name );
516 516
517 // If the package has a filename then it is a local file 517 // If the package has a filename then it is a local file
518 if ( p->isPackageStoredLocally() ) 518 if ( p->isPackageStoredLocally() )
519 name = p->getFilename(); 519 name = p->getFilename();
520
520 QString option; 521 QString option;
521 QString dest = "root"; 522 QString dest = "root";
522 if ( !p->isInstalled() ) 523 if ( !p->isInstalled() )
523 { 524 {
524 InstallData item; 525 InstallData item;
525 item.option = "I"; 526 item.option = "I";
526 item.packageName = name; 527 item.packageName = name;
527 return item; 528 return item;
528 } 529 }
529 else 530 else
530 { 531 {
531 InstallData item; 532 InstallData item;
532 item.option = "D"; 533 item.option = "D";
533 item.packageName = p->getInstalledPackageName(); 534 if ( !p->isPackageStoredLocally() )
535 item.packageName = p->getInstalledPackageName();
536 else
537 item.packageName = name;
538
534 if ( p->getInstalledTo() ) 539 if ( p->getInstalledTo() )
535 { 540 {
536 item.destination = p->getInstalledTo(); 541 item.destination = p->getInstalledTo();
537 cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl; 542 cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl;
538 cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl; 543 cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl;
539 } 544 }
540 else 545 else
541 { 546 {
542 item.destination = p->getLocalPackage()->getInstalledTo(); 547 item.destination = p->getLocalPackage()->getInstalledTo();
543 } 548 }
544 549
545 // Now see if version is newer or not 550 // Now see if version is newer or not
546 int val = compareVersions( p->getInstalledVersion(), p->getVersion() ); 551 int val = compareVersions( p->getInstalledVersion(), p->getVersion() );
552
553 // If the version requested is older and user selected a local ipk file, then reinstall the file
554 if ( p->isPackageStoredLocally() && val == -1 )
555 val = 0;
556
547 if ( val == -2 ) 557 if ( val == -2 )
548 { 558 {
549 // Error - should handle 559 // Error - should handle
550 } 560 }
551 else if ( val == -1 ) 561 else if ( val == -1 )
552 { 562 {
553 // Version available is older - remove only 563 // Version available is older - remove only
554 item.option = "D"; 564 item.option = "D";
555 } 565 }
556 else 566 else
557 { 567 {
558 QString caption; 568 QString caption;
559 QString text; 569 QString text;
560 QString secondButton; 570 QString secondButton;
561 QString secondOption; 571 QString secondOption;
562 if ( val == 0 ) 572 if ( val == 0 )
563 { 573 {
564 // Version available is the same - option to remove or reinstall 574 // Version available is the same - option to remove or reinstall
565 caption = "Do you wish to remove or reinstall\n%s?"; 575 caption = "Do you wish to remove or reinstall\n%s?";
566 text = "Remove or ReInstall"; 576 text = "Remove or ReInstall";
567 secondButton = "ReInstall"; 577 secondButton = "ReInstall";
568 secondOption = "R"; 578 secondOption = "R";
569 } 579 }
570 else if ( val == 1 ) 580 else if ( val == 1 )
571 { 581 {
572 // Version available is newer - option to remove or upgrade 582 // Version available is newer - option to remove or upgrade
573 caption = "Do you wish to remove or upgrade\n%s?"; 583 caption = "Do you wish to remove or upgrade\n%s?";
574 text = "Remove or Upgrade"; 584 text = "Remove or Upgrade";
575 secondButton = "Upgrade"; 585 secondButton = "Upgrade";
576 secondOption = "U"; 586 secondOption = "U";
577 } 587 }
578 588
579 // Sticky option not implemented yet, but will eventually allow 589 // Sticky option not implemented yet, but will eventually allow
580 // the user to say something like 'remove all' 590 // the user to say something like 'remove all'
581 if ( stickyOption == "" ) 591 if ( stickyOption == "" )
582 { 592 {
583 QString msgtext; 593 QString msgtext;
584 msgtext.sprintf( caption, (const char *)name ); 594 msgtext.sprintf( caption, (const char *)name );
585 switch( QMessageBox::information( this, text, 595 switch( QMessageBox::information( this, text,
586 msgtext, "Remove", secondButton ) ) 596 msgtext, "Remove", secondButton ) )
587 { 597 {
588 case 0: // Try again or Enter 598 case 0: // Try again or Enter
589 // option 0 = Remove 599 // option 0 = Remove
590 item.option = "D"; 600 item.option = "D";
591 break; 601 break;
592 case 1: // Quit or Escape 602 case 1: // Quit or Escape
593 item.option = secondOption; 603 item.option = secondOption;
594 break; 604 break;
diff --git a/noncore/settings/aqpkg/server.cpp b/noncore/settings/aqpkg/server.cpp
index 8bca892..539ebf0 100644
--- a/noncore/settings/aqpkg/server.cpp
+++ b/noncore/settings/aqpkg/server.cpp
@@ -65,97 +65,98 @@ void Server :: readStatusFile( vector<Destination> &destList )
65 bool rootRead = false; 65 bool rootRead = false;
66 for ( dit = destList.begin() ; dit != destList.end() ; ++dit ) 66 for ( dit = destList.begin() ; dit != destList.end() ; ++dit )
67 { 67 {
68 bool installingToRoot = false; 68 bool installingToRoot = false;
69 69
70 QString path = dit->getDestinationPath(); 70 QString path = dit->getDestinationPath();
71 if ( path.right( 1 ) != "/" ) 71 if ( path.right( 1 ) != "/" )
72 path += "/"; 72 path += "/";
73 73
74 if ( path == "/" ) 74 if ( path == "/" )
75 { 75 {
76 rootRead = true; 76 rootRead = true;
77 installingToRoot = true; 77 installingToRoot = true;
78 } 78 }
79 79
80 packageFile = path + "usr/lib/ipkg/status"; 80 packageFile = path + "usr/lib/ipkg/status";
81 readPackageFile( 0, false, installingToRoot, dit ); 81 readPackageFile( 0, false, installingToRoot, dit );
82 } 82 }
83 83
84 // Ensure that the root status file is read 84 // Ensure that the root status file is read
85 if ( !rootRead ) 85 if ( !rootRead )
86 { 86 {
87 cout << "Reading status file " << "/usr/lib/ipkg/status" << endl; 87 cout << "Reading status file " << "/usr/lib/ipkg/status" << endl;
88 packageFile = "/usr/lib/ipkg/status"; 88 packageFile = "/usr/lib/ipkg/status";
89 readPackageFile( 0, false, true ); 89 readPackageFile( 0, false, true );
90 } 90 }
91} 91}
92 92
93void Server :: readLocalIpks( Server *local ) 93void Server :: readLocalIpks( Server *local )
94{ 94{
95 cleanUp(); 95 cleanUp();
96 96
97#ifdef QWS 97#ifdef QWS
98 // First, get any local IPKGs in the documents area 98 // First, get any local IPKGs in the documents area
99 // Only applicable to Qtopie/Opie 99 // Only applicable to Qtopie/Opie
100 100
101 DocLnkSet files; 101 DocLnkSet files;
102 Global::findDocuments( &files, "application/ipkg" ); 102 Global::findDocuments( &files, "application/ipkg" );
103 103
104 // Now add the items to the list 104 // Now add the items to the list
105 QListIterator<DocLnk> it( files.children() ); 105 QListIterator<DocLnk> it( files.children() );
106 106
107 for ( ; it.current() ; ++it ) 107 for ( ; it.current() ; ++it )
108 { 108 {
109 // OK, we have a local IPK file, I think the standard naming conventions 109 // OK, we have a local IPK file, I think the standard naming conventions
110 // for these are packagename_version_arm.ipk 110 // for these are packagename_version_arm.ipk
111 QString file = (*it)->file(); 111 QString file = (*it)->file();
112 112
113 QString packageName = Utils::getPackageNameFromIpkFilename( file ); 113 // Changed to display the filename (excluding the path)
114 QString packageName = Utils::getFilenameFromIpkFilename( file );
114 QString ver = Utils::getPackageVersionFromIpkFilename( file ); 115 QString ver = Utils::getPackageVersionFromIpkFilename( file );
115 packageList.push_back( Package( packageName ) ); 116 packageList.push_back( Package( packageName ) );
116 packageList.back().setVersion( ver ); 117 packageList.back().setVersion( ver );
117 packageList.back().setFilename( file ); 118 packageList.back().setFilename( file );
118 packageList.back().setPackageStoredLocally( true ); 119 packageList.back().setPackageStoredLocally( true );
119 120
120 } 121 }
121#else 122#else
122 QString names[] = { "advancedfm_0.9.1-20020811_arm.ipk", "libopie_0.9.1-20020811_arm.ipk", "libopieobex_0.9.1-20020811.1_arm.ipk", "opie-addressbook_0.9.1-20020811_arm.ipk" }; 123 QString names[] = { "advancedfm_0.9.1-20020811_arm.ipk", "libopie_0.9.1-20020811_arm.ipk", "libopieobex_0.9.1-20020811.1_arm.ipk", "opie-addressbook_0.9.1-20020811_arm.ipk" };
123 for ( int i = 0 ; i < 4 ; ++i ) 124 for ( int i = 0 ; i < 4 ; ++i )
124 { 125 {
125 // OK, we have a local IPK file, I think the standard naming conventions 126 // OK, we have a local IPK file, I think the standard naming conventions
126 // for these are packagename_version_arm.ipk 127 // for these are packagename_version_arm.ipk
127 QString file = names[i]; 128 QString file = names[i];
128 int p = file.find( "_" ); 129 int p = file.find( "_" );
129 QString tmp = file.mid( 0, p ); 130 QString tmp = file.mid( 0, p );
130 packageList.push_back( Package( tmp ) ); 131 packageList.push_back( Package( tmp ) );
131 int p2 = file.find( "_", p+1 ); 132 int p2 = file.find( "_", p+1 );
132 tmp = file.mid( p+1, p2-(p+1) ); 133 tmp = file.mid( p+1, p2-(p+1) );
133 packageList.back().setVersion( tmp ); 134 packageList.back().setVersion( tmp );
134 packageList.back().setPackageStoredLocally( true ); 135 packageList.back().setPackageStoredLocally( true );
135 } 136 }
136#endif 137#endif
137 138
138 // build local packages 139 // build local packages
139 buildLocalPackages( local ); 140 buildLocalPackages( local );
140} 141}
141 142
142void Server :: readPackageFile( Server *local, bool clearAll, bool installingToRoot, Destination *dest ) 143void Server :: readPackageFile( Server *local, bool clearAll, bool installingToRoot, Destination *dest )
143{ 144{
144 ifstream in( packageFile ); 145 ifstream in( packageFile );
145 if ( !in.is_open() ) 146 if ( !in.is_open() )
146 return; 147 return;
147 148
148 char line[1001]; 149 char line[1001];
149 char k[21]; 150 char k[21];
150 char v[1001]; 151 char v[1001];
151 QString key; 152 QString key;
152 QString value; 153 QString value;
153 154
154 if ( clearAll ) 155 if ( clearAll )
155 cleanUp(); 156 cleanUp();
156 Package *currPackage = 0; 157 Package *currPackage = 0;
157 158
158 bool newPackage = true; 159 bool newPackage = true;
159 do 160 do
160 { 161 {
161 in.getline( line, 1000 ); 162 in.getline( line, 1000 );
@@ -182,92 +183,97 @@ void Server :: readPackageFile( Server *local, bool clearAll, bool installingToR
182 currPackage->setInstalledTo( dest ); 183 currPackage->setInstalledTo( dest );
183 184
184 if ( installingToRoot ) 185 if ( installingToRoot )
185 currPackage->setInstalledToRoot( true ); 186 currPackage->setInstalledToRoot( true );
186 } 187 }
187 else 188 else
188 { 189 {
189 if (currPackage->getStatus().find( "deinstall" ) != -1 ) 190 if (currPackage->getStatus().find( "deinstall" ) != -1 )
190 currPackage->setInstalledTo( dest ); 191 currPackage->setInstalledTo( dest );
191 } 192 }
192 } 193 }
193 else if ( key == "Version" ) 194 else if ( key == "Version" )
194 { 195 {
195 if ( currPackage ) 196 if ( currPackage )
196 currPackage->setVersion( value ); 197 currPackage->setVersion( value );
197 } 198 }
198 else if ( key == "Status" ) 199 else if ( key == "Status" )
199 { 200 {
200 if ( currPackage ) 201 if ( currPackage )
201 currPackage->setStatus( value ); 202 currPackage->setStatus( value );
202 } 203 }
203 else if ( key == "Description" ) 204 else if ( key == "Description" )
204 { 205 {
205 if ( currPackage ) 206 if ( currPackage )
206 currPackage->setDescription( value ); 207 currPackage->setDescription( value );
207 } 208 }
208 else if ( key == "Filename" ) 209 else if ( key == "Filename" )
209 { 210 {
210 if ( currPackage ) 211 if ( currPackage )
211 currPackage->setFilename( value ); 212 currPackage->setFilename( value );
212 } 213 }
213 else if ( key == "" ) 214 else if ( key == "" )
214 { 215 {
215 newPackage = true; 216 newPackage = true;
216 } 217 }
217 } while ( !in.eof() ); 218 } while ( !in.eof() );
218 219
219 in.close(); 220 in.close();
220 221
221 // build local packages 222 // build local packages
222 buildLocalPackages( local ); 223 buildLocalPackages( local );
223} 224}
224 225
225void Server :: buildLocalPackages( Server *local ) 226void Server :: buildLocalPackages( Server *local )
226{ 227{
227 for ( unsigned int i = 0 ; i < packageList.size() ; ++i ) 228 for ( unsigned int i = 0 ; i < packageList.size() ; ++i )
228 { 229 {
229 QString name = packageList[i].getPackageName(); 230 QString name = packageList[i].getPackageName();
231
232 // If the package name is an ipk name, then convert the filename to a package name
233 if ( name.find( ".ipk" ) != -1 )
234 name = Utils::getPackageNameFromIpkFilename( packageList[i].getFilename() );
235
230 if ( local ) 236 if ( local )
231 packageList[i].setLocalPackage( local->getPackage( name ) ); 237 packageList[i].setLocalPackage( local->getPackage( name ) );
232 else 238 else
233 packageList[i].setLocalPackage( 0 ); 239 packageList[i].setLocalPackage( 0 );
234 } 240 }
235 241
236} 242}
237 243
238Package *Server :: getPackage( QString &name ) 244Package *Server :: getPackage( QString &name )
239{ 245{
240 return getPackage( (const char *)name ); 246 return getPackage( (const char *)name );
241} 247}
242 248
243Package *Server :: getPackage( const char *name ) 249Package *Server :: getPackage( const char *name )
244{ 250{
245 Package *ret = 0; 251 Package *ret = 0;
246 252
247 for ( unsigned int i = 0 ; i < packageList.size() && ret == 0; ++i ) 253 for ( unsigned int i = 0 ; i < packageList.size() && ret == 0; ++i )
248 { 254 {
249 if ( packageList[i].getPackageName() == name ) 255 if ( packageList[i].getPackageName() == name )
250 ret = &packageList[i]; 256 ret = &packageList[i];
251 } 257 }
252 258
253 return ret; 259 return ret;
254} 260}
255 261
256QString Server :: toString() 262QString Server :: toString()
257{ 263{
258 QString ret = "Server\n name - " + serverName + 264 QString ret = "Server\n name - " + serverName +
259 "\n url - " + serverUrl + 265 "\n url - " + serverUrl +
260 "\n"; 266 "\n";
261 267
262 for ( unsigned int i = 0 ; i < packageList.size() ; ++i ) 268 for ( unsigned int i = 0 ; i < packageList.size() ; ++i )
263 ret += "\n " + packageList[i].toString(); 269 ret += "\n " + packageList[i].toString();
264 270
265 271
266 return ret; 272 return ret;
267} 273}
268 274
269vector<Package> &Server::getPackageList() 275vector<Package> &Server::getPackageList()
270{ 276{
271 return packageList; 277 return packageList;
272} 278}
273 279