-rw-r--r-- | noncore/settings/aqpkg/package.cpp | 10 | ||||
-rw-r--r-- | noncore/settings/aqpkg/package.h | 14 | ||||
-rw-r--r-- | noncore/settings/aqpkg/server.cpp | 22 |
3 files changed, 27 insertions, 19 deletions
diff --git a/noncore/settings/aqpkg/package.cpp b/noncore/settings/aqpkg/package.cpp index fd75450..526de5e 100644 --- a/noncore/settings/aqpkg/package.cpp +++ b/noncore/settings/aqpkg/package.cpp | |||
@@ -35,89 +35,89 @@ Package::Package( char *name ) | |||
35 | localPackage = 0; | 35 | localPackage = 0; |
36 | installed = false; | 36 | installed = false; |
37 | packageStoredLocally = false; | 37 | packageStoredLocally = false; |
38 | installedToRoot = false; | 38 | installedToRoot = false; |
39 | installed = false; | 39 | installed = false; |
40 | installedTo = 0; | 40 | installedTo = 0; |
41 | } | 41 | } |
42 | 42 | ||
43 | Package::~Package() | 43 | Package::~Package() |
44 | { | 44 | { |
45 | } | 45 | } |
46 | 46 | ||
47 | QString Package :: toString() | 47 | QString Package :: toString() |
48 | { | 48 | { |
49 | QString ret = "Package - " + getPackageName() + | 49 | QString ret = "Package - " + getPackageName() + |
50 | "\n version - " + getVersion(); | 50 | "\n version - " + getVersion(); |
51 | 51 | ||
52 | if ( localPackage ) | 52 | if ( localPackage ) |
53 | ret += "\n inst version - " + localPackage->getVersion(); | 53 | ret += "\n inst version - " + localPackage->getVersion(); |
54 | 54 | ||
55 | 55 | ||
56 | return ret; | 56 | return ret; |
57 | } | 57 | } |
58 | 58 | ||
59 | void Package :: setStatus( QString &s ) | 59 | void Package :: setStatus( const QString &s ) |
60 | { | 60 | { |
61 | status = s; | 61 | status = s; |
62 | 62 | ||
63 | if ( status.find( "installed" ) != -1 ) | 63 | if ( status.find( "installed" ) != -1 ) |
64 | installed = true; | 64 | installed = true; |
65 | } | 65 | } |
66 | 66 | ||
67 | void Package :: setLocalPackage( Package *p ) | 67 | void Package :: setLocalPackage( Package *p ) |
68 | { | 68 | { |
69 | localPackage = p; | 69 | localPackage = p; |
70 | 70 | ||
71 | if ( localPackage ) | 71 | if ( localPackage ) |
72 | if ( localPackage->getVersion() != getVersion() ) | 72 | if ( localPackage->getVersion() != getVersion() ) |
73 | differentVersionAvailable = true; | 73 | differentVersionAvailable = true; |
74 | else | 74 | else |
75 | differentVersionAvailable = false; | 75 | differentVersionAvailable = false; |
76 | } | 76 | } |
77 | 77 | ||
78 | void Package :: setVersion( QString &v ) | 78 | void Package :: setVersion( const QString &v ) |
79 | { | 79 | { |
80 | version = v; | 80 | version = v; |
81 | 81 | ||
82 | if ( localPackage ) | 82 | if ( localPackage ) |
83 | if ( localPackage->getVersion() != getVersion() ) | 83 | if ( localPackage->getVersion() != getVersion() ) |
84 | differentVersionAvailable = true; | 84 | differentVersionAvailable = true; |
85 | else | 85 | else |
86 | differentVersionAvailable = false; | 86 | differentVersionAvailable = false; |
87 | } | 87 | } |
88 | 88 | ||
89 | void Package :: setPackageName( QString &name ) | 89 | void Package :: setPackageName( const QString &name ) |
90 | { | 90 | { |
91 | packageName = name; | 91 | packageName = name; |
92 | } | 92 | } |
93 | 93 | ||
94 | void Package :: setDescription( QString &d ) | 94 | void Package :: setDescription( const QString &d ) |
95 | { | 95 | { |
96 | description = d; | 96 | description = d; |
97 | } | 97 | } |
98 | 98 | ||
99 | void Package :: setFilename( QString &f ) | 99 | void Package :: setFilename( const QString &f ) |
100 | { | 100 | { |
101 | filename = f; | 101 | filename = f; |
102 | } | 102 | } |
103 | 103 | ||
104 | 104 | ||
105 | QString Package :: getInstalledVersion() | 105 | QString Package :: getInstalledVersion() |
106 | { | 106 | { |
107 | if ( localPackage ) | 107 | if ( localPackage ) |
108 | return localPackage->getVersion(); | 108 | return localPackage->getVersion(); |
109 | else | 109 | else |
110 | return getVersion(); | 110 | return getVersion(); |
111 | } | 111 | } |
112 | 112 | ||
113 | QString Package :: getInstalledPackageName() | 113 | QString Package :: getInstalledPackageName() |
114 | { | 114 | { |
115 | if ( localPackage ) | 115 | if ( localPackage ) |
116 | return localPackage->getPackageName(); | 116 | return localPackage->getPackageName(); |
117 | else | 117 | else |
118 | return getPackageName(); | 118 | return getPackageName(); |
119 | } | 119 | } |
120 | 120 | ||
121 | bool Package :: isInstalled() | 121 | bool Package :: isInstalled() |
122 | { | 122 | { |
123 | return installed || ( localPackage && localPackage->isInstalled() ); | 123 | return installed || ( localPackage && localPackage->isInstalled() ); |
diff --git a/noncore/settings/aqpkg/package.h b/noncore/settings/aqpkg/package.h index 7545818..f5a132f 100644 --- a/noncore/settings/aqpkg/package.h +++ b/noncore/settings/aqpkg/package.h | |||
@@ -14,59 +14,59 @@ | |||
14 | * (at your option) any later version. * | 14 | * (at your option) any later version. * |
15 | * * | 15 | * * |
16 | ***************************************************************************/ | 16 | ***************************************************************************/ |
17 | 17 | ||
18 | #ifndef PACKAGE_H | 18 | #ifndef PACKAGE_H |
19 | #define PACKAGE_H | 19 | #define PACKAGE_H |
20 | 20 | ||
21 | #include <stdlib.h> | 21 | #include <stdlib.h> |
22 | 22 | ||
23 | /** | 23 | /** |
24 | *@author Andy Qua | 24 | *@author Andy Qua |
25 | */ | 25 | */ |
26 | 26 | ||
27 | #include <qstring.h> | 27 | #include <qstring.h> |
28 | #include "destination.h" | 28 | #include "destination.h" |
29 | 29 | ||
30 | class Package | 30 | class Package |
31 | { | 31 | { |
32 | public: | 32 | public: |
33 | Package( QString &name ); | 33 | Package( QString &name ); |
34 | Package( char *name ); | 34 | Package( char *name ); |
35 | ~Package(); | 35 | ~Package(); |
36 | 36 | ||
37 | void setLocalPackage( Package *p ); | 37 | void setLocalPackage( Package *p ); |
38 | void setPackageName( QString &name ); | 38 | void setPackageName( const QString &name ); |
39 | void setVersion( QString &v ); | 39 | void setVersion( const QString &v ); |
40 | void setStatus( QString &s ); | 40 | void setStatus( const QString &s ); |
41 | void setDescription( QString &d ); | 41 | void setDescription( const QString &d ); |
42 | void setFilename( QString &f ); | 42 | void setFilename( const QString &f ); |
43 | void setPackageStoredLocally( bool local ){ packageStoredLocally = local; } | 43 | void setPackageStoredLocally( bool local ){ packageStoredLocally = local; } |
44 | void setInstalledToRoot( bool root ) { installedToRoot = root; } | 44 | void setInstalledToRoot( bool root ) { installedToRoot = root; } |
45 | void setInstalledTo( Destination *d ) { installedTo = d; } | 45 | void setInstalledTo( Destination *d ) { installedTo = d; } |
46 | void setDependancies( QString &deps ) { dependancies = deps; } | 46 | void setDependancies( QString &deps ) { dependancies = deps; } |
47 | void setPackageSize( QString size ) { packageSize = size; } | 47 | void setPackageSize( const QString &size ) { packageSize = size; } |
48 | void setSection( QString sect) { section = sect; } | 48 | void setSection( const QString §) { section = sect; } |
49 | 49 | ||
50 | Package *getLocalPackage() { return localPackage; } | 50 | Package *getLocalPackage() { return localPackage; } |
51 | QString getPackageName() { return packageName; } | 51 | QString getPackageName() { return packageName; } |
52 | QString getVersion() { return version; } | 52 | QString getVersion() { return version; } |
53 | QString getStatus() { return status; } | 53 | QString getStatus() { return status; } |
54 | QString getDescription() { return description; } | 54 | QString getDescription() { return description; } |
55 | QString getFilename() { return filename; } | 55 | QString getFilename() { return filename; } |
56 | QString getDependancies() { return dependancies; } | 56 | QString getDependancies() { return dependancies; } |
57 | QString getPackageSize() { return packageSize; } | 57 | QString getPackageSize() { return packageSize; } |
58 | QString getSection() { return section; } | 58 | QString getSection() { return section; } |
59 | 59 | ||
60 | bool isInstalled(); | 60 | bool isInstalled(); |
61 | bool isPackageStoredLocally(){ return packageStoredLocally; } | 61 | bool isPackageStoredLocally(){ return packageStoredLocally; } |
62 | bool isInstalledToRoot() { return installedToRoot; } | 62 | bool isInstalledToRoot() { return installedToRoot; } |
63 | QString getInstalledVersion(); | 63 | QString getInstalledVersion(); |
64 | QString getInstalledPackageName(); | 64 | QString getInstalledPackageName(); |
65 | Destination *getInstalledTo() { return installedTo; } | 65 | Destination *getInstalledTo() { return installedTo; } |
66 | 66 | ||
67 | QString toString(); | 67 | QString toString(); |
68 | 68 | ||
69 | 69 | ||
70 | private: | 70 | private: |
71 | Package *localPackage; | 71 | Package *localPackage; |
72 | 72 | ||
diff --git a/noncore/settings/aqpkg/server.cpp b/noncore/settings/aqpkg/server.cpp index 7c3257b..726cf00 100644 --- a/noncore/settings/aqpkg/server.cpp +++ b/noncore/settings/aqpkg/server.cpp | |||
@@ -226,73 +226,81 @@ void Server :: readPackageFile( Server *local, bool clearAll, bool installingToR | |||
226 | } | 226 | } |
227 | else if ( key == "" ) | 227 | else if ( key == "" ) |
228 | { | 228 | { |
229 | newPackage = true; | 229 | newPackage = true; |
230 | } | 230 | } |
231 | } while ( !in.eof() ); | 231 | } while ( !in.eof() ); |
232 | 232 | ||
233 | in.close(); | 233 | in.close(); |
234 | 234 | ||
235 | // build local packages | 235 | // build local packages |
236 | buildLocalPackages( local ); | 236 | buildLocalPackages( local ); |
237 | } | 237 | } |
238 | 238 | ||
239 | void Server :: buildLocalPackages( Server *local ) | 239 | void Server :: buildLocalPackages( Server *local ) |
240 | { | 240 | { |
241 | for ( unsigned int i = 0 ; i < packageList.size() ; ++i ) | 241 | for ( unsigned int i = 0 ; i < packageList.size() ; ++i ) |
242 | { | 242 | { |
243 | QString name = packageList[i].getPackageName(); | 243 | QString name = packageList[i].getPackageName(); |
244 | 244 | ||
245 | // If the package name is an ipk name, then convert the filename to a package name | 245 | // If the package name is an ipk name, then convert the filename to a package name |
246 | if ( name.find( ".ipk" ) != -1 ) | 246 | if ( name.find( ".ipk" ) != -1 ) |
247 | name = Utils::getPackageNameFromIpkFilename( packageList[i].getFilename() ); | 247 | name = Utils::getPackageNameFromIpkFilename( packageList[i].getFilename() ); |
248 | 248 | ||
249 | if ( local ) | 249 | if ( local ) |
250 | packageList[i].setLocalPackage( local->getPackage( name ) ); | 250 | { |
251 | Package *p = local->getPackage( name ); | ||
252 | packageList[i].setLocalPackage( p ); | ||
253 | if ( p ) | ||
254 | { | ||
255 | // Set some default stuff like size and things | ||
256 | if ( p->getInstalledVersion() == packageList[i].getVersion() ) | ||
257 | { | ||
258 | p->setPackageSize( packageList[i].getPackageSize() ); | ||
259 | p->setSection( packageList[i].getSection() ); | ||
260 | p->setDescription( packageList[i].getDescription() ); | ||
261 | } | ||
262 | } | ||
263 | |||
264 | } | ||
251 | else | 265 | else |
252 | packageList[i].setLocalPackage( 0 ); | 266 | packageList[i].setLocalPackage( 0 ); |
253 | } | 267 | } |
254 | 268 | ||
255 | } | 269 | } |
256 | 270 | ||
257 | Package *Server :: getPackage( QString &name ) | 271 | Package *Server :: getPackage( QString &name ) |
258 | { | 272 | { |
259 | return getPackage( (const char *)name ); | 273 | return getPackage( (const char *)name ); |
260 | } | 274 | } |
261 | 275 | ||
262 | Package *Server :: getPackage( const char *name ) | 276 | Package *Server :: getPackage( const char *name ) |
263 | { | 277 | { |
264 | Package *ret = 0; | 278 | Package *ret = 0; |
265 | 279 | ||
266 | for ( unsigned int i = 0 ; i < packageList.size() && ret == 0; ++i ) | 280 | for ( unsigned int i = 0 ; i < packageList.size() && ret == 0; ++i ) |
267 | { | 281 | { |
268 | if ( packageList[i].getPackageName() == name ) | 282 | if ( packageList[i].getPackageName() == name ) |
269 | ret = &packageList[i]; | 283 | ret = &packageList[i]; |
270 | } | 284 | } |
271 | 285 | ||
272 | return ret; | 286 | return ret; |
273 | } | 287 | } |
274 | 288 | ||
275 | QString Server :: toString() | 289 | QString Server :: toString() |
276 | { | 290 | { |
277 | QString ret = "Server\n name - " + serverName + | 291 | QString ret = "Server\n name - " + serverName + |
278 | "\n url - " + serverUrl + | 292 | "\n url - " + serverUrl + |
279 | "\n"; | 293 | "\n"; |
280 | 294 | ||
281 | for ( unsigned int i = 0 ; i < packageList.size() ; ++i ) | 295 | for ( unsigned int i = 0 ; i < packageList.size() ; ++i ) |
282 | ret += "\n " + packageList[i].toString(); | 296 | ret += "\n " + packageList[i].toString(); |
283 | 297 | ||
284 | 298 | ||
285 | return ret; | 299 | return ret; |
286 | } /* | ||
287 | void addAvailableSection( QString section ) | ||
288 | { | ||
289 | if ( DataManager::availableCategories.find( value ) == -1 ) | ||
290 | // DataManager::availableCategories += "#" + value; | ||
291 | } | 300 | } |
292 | */ | ||
293 | 301 | ||
294 | vector<Package> &Server::getPackageList() | 302 | vector<Package> &Server::getPackageList() |
295 | { | 303 | { |
296 | return packageList; | 304 | return packageList; |
297 | } | 305 | } |
298 | 306 | ||