summaryrefslogtreecommitdiff
authorandyq <andyq>2002-11-19 17:31:00 (UTC)
committer andyq <andyq>2002-11-19 17:31:00 (UTC)
commitabeb38c25d2cfe90d1a17912a63c9518e602766c (patch) (unidiff)
tree79df89e95a7dafc4a3bf9a7e377b41467396f20d
parent638b671dce5eff05a2ec666492c060fa2fd021a2 (diff)
downloadopie-abeb38c25d2cfe90d1a17912a63c9518e602766c.zip
opie-abeb38c25d2cfe90d1a17912a63c9518e602766c.tar.gz
opie-abeb38c25d2cfe90d1a17912a63c9518e602766c.tar.bz2
Changed so that the size of a package is passed down into the local package
(as long as the package installed is the same version as the package available in the feed)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/package.cpp10
-rw-r--r--noncore/settings/aqpkg/package.h14
-rw-r--r--noncore/settings/aqpkg/server.cpp22
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
@@ -1,124 +1,124 @@
1/*************************************************************************** 1/***************************************************************************
2 package.cpp - description 2 package.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#include "package.h" 18#include "package.h"
19#include "global.h" 19#include "global.h"
20 20
21Package::Package( QString &name ) 21Package::Package( QString &name )
22{ 22{
23 packageName = name; 23 packageName = name;
24 localPackage = 0; 24 localPackage = 0;
25 installed = false; 25 installed = false;
26 packageStoredLocally = false; 26 packageStoredLocally = false;
27 installedToRoot = false; 27 installedToRoot = false;
28 installed = false; 28 installed = false;
29 installedTo = 0; 29 installedTo = 0;
30} 30}
31 31
32Package::Package( char *name ) 32Package::Package( char *name )
33{ 33{
34 packageName = name; 34 packageName = 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
43Package::~Package() 43Package::~Package()
44{ 44{
45} 45}
46 46
47QString Package :: toString() 47QString 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
59void Package :: setStatus( QString &s ) 59void 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
67void Package :: setLocalPackage( Package *p ) 67void 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
78void Package :: setVersion( QString &v ) 78void 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
89void Package :: setPackageName( QString &name ) 89void Package :: setPackageName( const QString &name )
90{ 90{
91 packageName = name; 91 packageName = name;
92} 92}
93 93
94void Package :: setDescription( QString &d ) 94void Package :: setDescription( const QString &d )
95{ 95{
96 description = d; 96 description = d;
97} 97}
98 98
99void Package :: setFilename( QString &f ) 99void Package :: setFilename( const QString &f )
100{ 100{
101 filename = f; 101 filename = f;
102} 102}
103 103
104 104
105QString Package :: getInstalledVersion() 105QString 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
113QString Package :: getInstalledPackageName() 113QString 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
121bool Package :: isInstalled() 121bool Package :: isInstalled()
122{ 122{
123 return installed || ( localPackage && localPackage->isInstalled() ); 123 return installed || ( localPackage && localPackage->isInstalled() );
124} 124}
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
@@ -1,89 +1,89 @@
1/*************************************************************************** 1/***************************************************************************
2 package.h - description 2 package.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 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
30class Package 30class Package
31{ 31{
32public: 32public:
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 &sect) { 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
70private: 70private:
71 Package *localPackage; 71 Package *localPackage;
72 72
73 QString packageName; 73 QString packageName;
74 QString version; 74 QString version;
75 QString status; 75 QString status;
76 QString description; 76 QString description;
77 QString filename; 77 QString filename;
78 bool packageStoredLocally; 78 bool packageStoredLocally;
79 bool installedToRoot; 79 bool installedToRoot;
80 bool installed; 80 bool installed;
81 bool differentVersionAvailable; 81 bool differentVersionAvailable;
82 QString dependancies; 82 QString dependancies;
83 QString packageSize; 83 QString packageSize;
84 QString section; 84 QString section;
85 85
86 Destination *installedTo; 86 Destination *installedTo;
87}; 87};
88 88
89#endif 89#endif
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
@@ -1,298 +1,306 @@
1/*************************************************************************** 1/***************************************************************************
2 server.cpp - description 2 server.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 description : This class holds details about a server 7 description : This class holds details about a server
8 : e.g. all the packages that contained on the server 8 : e.g. all the packages that contained on the server
9 : the installation status 9 : the installation status
10 ***************************************************************************/ 10 ***************************************************************************/
11 11
12/*************************************************************************** 12/***************************************************************************
13 * * 13 * *
14 * This program is free software; you can redistribute it and/or modify * 14 * This program is free software; you can redistribute it and/or modify *
15 * it under the terms of the GNU General Public License as published by * 15 * it under the terms of the GNU General Public License as published by *
16 * the Free Software Foundation; either version 2 of the License, or * 16 * the Free Software Foundation; either version 2 of the License, or *
17 * (at your option) any later version. * 17 * (at your option) any later version. *
18 * * 18 * *
19 ***************************************************************************/ 19 ***************************************************************************/
20 20
21 21
22#include <stdio.h> 22#include <stdio.h>
23#include <string.h> 23#include <string.h>
24#include <stdlib.h> 24#include <stdlib.h>
25 25
26#include <iostream> 26#include <iostream>
27#include <fstream> 27#include <fstream>
28using namespace std; 28using namespace std;
29 29
30#include "server.h" 30#include "server.h"
31#include "datamgr.h" 31#include "datamgr.h"
32 32
33#ifdef QWS 33#ifdef QWS
34#include <qpe/global.h> 34#include <qpe/global.h>
35#include <qpe/applnk.h> 35#include <qpe/applnk.h>
36#include <qlist.h> 36#include <qlist.h>
37#endif 37#endif
38 38
39#include "utils.h" 39#include "utils.h"
40 40
41#include "global.h" 41#include "global.h"
42 42
43Server :: Server( const char *name, const char *url ) 43Server :: Server( const char *name, const char *url )
44{ 44{
45 serverName = name; 45 serverName = name;
46 serverUrl = url; 46 serverUrl = url;
47 packageFile = IPKG_DIR; 47 packageFile = IPKG_DIR;
48 packageFile += "lists/" + serverName; 48 packageFile += "lists/" + serverName;
49} 49}
50 50
51Server :: ~Server() 51Server :: ~Server()
52{ 52{
53 cleanUp(); 53 cleanUp();
54} 54}
55 55
56void Server :: cleanUp() 56void Server :: cleanUp()
57{ 57{
58 packageList.clear(); 58 packageList.clear();
59} 59}
60 60
61void Server :: readStatusFile( vector<Destination> &destList ) 61void Server :: readStatusFile( vector<Destination> &destList )
62{ 62{
63 cleanUp(); 63 cleanUp();
64 64
65 vector<Destination>::iterator dit; 65 vector<Destination>::iterator dit;
66 bool rootRead = false; 66 bool rootRead = false;
67 for ( dit = destList.begin() ; dit != destList.end() ; ++dit ) 67 for ( dit = destList.begin() ; dit != destList.end() ; ++dit )
68 { 68 {
69 bool installingToRoot = false; 69 bool installingToRoot = false;
70 70
71 QString path = dit->getDestinationPath(); 71 QString path = dit->getDestinationPath();
72 if ( path.right( 1 ) != "/" ) 72 if ( path.right( 1 ) != "/" )
73 path += "/"; 73 path += "/";
74 74
75 if ( path == "/" ) 75 if ( path == "/" )
76 { 76 {
77 rootRead = true; 77 rootRead = true;
78 installingToRoot = true; 78 installingToRoot = true;
79 } 79 }
80 80
81 packageFile = path + "usr/lib/ipkg/status"; 81 packageFile = path + "usr/lib/ipkg/status";
82 readPackageFile( 0, false, installingToRoot, dit ); 82 readPackageFile( 0, false, installingToRoot, dit );
83 } 83 }
84 84
85 // Ensure that the root status file is read 85 // Ensure that the root status file is read
86 if ( !rootRead ) 86 if ( !rootRead )
87 { 87 {
88 cout << "Reading status file " << "/usr/lib/ipkg/status" << endl; 88 cout << "Reading status file " << "/usr/lib/ipkg/status" << endl;
89 packageFile = "/usr/lib/ipkg/status"; 89 packageFile = "/usr/lib/ipkg/status";
90 readPackageFile( 0, false, true ); 90 readPackageFile( 0, false, true );
91 } 91 }
92} 92}
93 93
94void Server :: readLocalIpks( Server *local ) 94void Server :: readLocalIpks( Server *local )
95{ 95{
96 cleanUp(); 96 cleanUp();
97 97
98#ifdef QWS 98#ifdef QWS
99 // First, get any local IPKGs in the documents area 99 // First, get any local IPKGs in the documents area
100 // Only applicable to Qtopie/Opie 100 // Only applicable to Qtopie/Opie
101 101
102 DocLnkSet files; 102 DocLnkSet files;
103 Global::findDocuments( &files, "application/ipkg" ); 103 Global::findDocuments( &files, "application/ipkg" );
104 104
105 // Now add the items to the list 105 // Now add the items to the list
106 QListIterator<DocLnk> it( files.children() ); 106 QListIterator<DocLnk> it( files.children() );
107 107
108 for ( ; it.current() ; ++it ) 108 for ( ; it.current() ; ++it )
109 { 109 {
110 // OK, we have a local IPK file, I think the standard naming conventions 110 // OK, we have a local IPK file, I think the standard naming conventions
111 // for these are packagename_version_arm.ipk 111 // for these are packagename_version_arm.ipk
112 QString file = (*it)->file(); 112 QString file = (*it)->file();
113 113
114 // Changed to display the filename (excluding the path) 114 // Changed to display the filename (excluding the path)
115 QString packageName = Utils::getFilenameFromIpkFilename( file ); 115 QString packageName = Utils::getFilenameFromIpkFilename( file );
116 QString ver = Utils::getPackageVersionFromIpkFilename( file ); 116 QString ver = Utils::getPackageVersionFromIpkFilename( file );
117 packageList.push_back( Package( packageName ) ); 117 packageList.push_back( Package( packageName ) );
118 packageList.back().setVersion( ver ); 118 packageList.back().setVersion( ver );
119 packageList.back().setFilename( file ); 119 packageList.back().setFilename( file );
120 packageList.back().setPackageStoredLocally( true ); 120 packageList.back().setPackageStoredLocally( true );
121 121
122 } 122 }
123#else 123#else
124 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" }; 124 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" };
125 for ( int i = 0 ; i < 4 ; ++i ) 125 for ( int i = 0 ; i < 4 ; ++i )
126 { 126 {
127 // OK, we have a local IPK file, I think the standard naming conventions 127 // OK, we have a local IPK file, I think the standard naming conventions
128 // for these are packagename_version_arm.ipk 128 // for these are packagename_version_arm.ipk
129 QString file = names[i]; 129 QString file = names[i];
130 int p = file.find( "_" ); 130 int p = file.find( "_" );
131 QString tmp = file.mid( 0, p ); 131 QString tmp = file.mid( 0, p );
132 packageList.push_back( Package( tmp ) ); 132 packageList.push_back( Package( tmp ) );
133 int p2 = file.find( "_", p+1 ); 133 int p2 = file.find( "_", p+1 );
134 tmp = file.mid( p+1, p2-(p+1) ); 134 tmp = file.mid( p+1, p2-(p+1) );
135 packageList.back().setVersion( tmp ); 135 packageList.back().setVersion( tmp );
136 packageList.back().setPackageStoredLocally( true ); 136 packageList.back().setPackageStoredLocally( true );
137 } 137 }
138#endif 138#endif
139 139
140 // build local packages 140 // build local packages
141 buildLocalPackages( local ); 141 buildLocalPackages( local );
142} 142}
143 143
144void Server :: readPackageFile( Server *local, bool clearAll, bool installingToRoot, Destination *dest ) 144void Server :: readPackageFile( Server *local, bool clearAll, bool installingToRoot, Destination *dest )
145{ 145{
146 ifstream in( packageFile ); 146 ifstream in( packageFile );
147 if ( !in.is_open() ) 147 if ( !in.is_open() )
148 return; 148 return;
149 149
150 char line[1001]; 150 char line[1001];
151 char k[21]; 151 char k[21];
152 char v[1001]; 152 char v[1001];
153 QString key; 153 QString key;
154 QString value; 154 QString value;
155 155
156 if ( clearAll ) 156 if ( clearAll )
157 cleanUp(); 157 cleanUp();
158 Package *currPackage = 0; 158 Package *currPackage = 0;
159 159
160 bool newPackage = true; 160 bool newPackage = true;
161 do 161 do
162 { 162 {
163 in.getline( line, 1000 ); 163 in.getline( line, 1000 );
164 if ( in.eof() ) 164 if ( in.eof() )
165 continue; 165 continue;
166 166
167 k[0] = '\0'; 167 k[0] = '\0';
168 v[0] = '\0'; 168 v[0] = '\0';
169 169
170 sscanf( line, "%[^:]: %[^\n]", k, v ); 170 sscanf( line, "%[^:]: %[^\n]", k, v );
171 key = k; 171 key = k;
172 value = v; 172 value = v;
173 key = key.stripWhiteSpace(); 173 key = key.stripWhiteSpace();
174 value = value.stripWhiteSpace(); 174 value = value.stripWhiteSpace();
175 if ( key == "Package" && newPackage ) 175 if ( key == "Package" && newPackage )
176 { 176 {
177 newPackage = false; 177 newPackage = false;
178 178
179 currPackage = getPackage( value ); 179 currPackage = getPackage( value );
180 if ( !currPackage ) 180 if ( !currPackage )
181 { 181 {
182 packageList.push_back( Package( value ) ); 182 packageList.push_back( Package( value ) );
183 currPackage = &(packageList.back()); 183 currPackage = &(packageList.back());
184 currPackage->setInstalledTo( dest ); 184 currPackage->setInstalledTo( dest );
185 185
186 if ( installingToRoot ) 186 if ( installingToRoot )
187 currPackage->setInstalledToRoot( true ); 187 currPackage->setInstalledToRoot( true );
188 } 188 }
189 else 189 else
190 { 190 {
191 if (currPackage->getStatus().find( "deinstall" ) != -1 ) 191 if (currPackage->getStatus().find( "deinstall" ) != -1 )
192 currPackage->setInstalledTo( dest ); 192 currPackage->setInstalledTo( dest );
193 } 193 }
194 } 194 }
195 else if ( key == "Version" ) 195 else if ( key == "Version" )
196 { 196 {
197 if ( currPackage ) 197 if ( currPackage )
198 currPackage->setVersion( value ); 198 currPackage->setVersion( value );
199 } 199 }
200 else if ( key == "Status" ) 200 else if ( key == "Status" )
201 { 201 {
202 if ( currPackage ) 202 if ( currPackage )
203 currPackage->setStatus( value ); 203 currPackage->setStatus( value );
204 } 204 }
205 else if ( key == "Description" ) 205 else if ( key == "Description" )
206 { 206 {
207 if ( currPackage ) 207 if ( currPackage )
208 currPackage->setDescription( value ); 208 currPackage->setDescription( value );
209 } 209 }
210 else if ( key == "Filename" ) 210 else if ( key == "Filename" )
211 { 211 {
212 if ( currPackage ) 212 if ( currPackage )
213 currPackage->setFilename( value ); 213 currPackage->setFilename( value );
214 } 214 }
215 else if ( key == "Size" ) 215 else if ( key == "Size" )
216 { 216 {
217 if ( currPackage ) 217 if ( currPackage )
218 currPackage->setPackageSize( value ); 218 currPackage->setPackageSize( value );
219 } 219 }
220 else if ( key == "Section" ) 220 else if ( key == "Section" )
221 { 221 {
222 if ( currPackage ) 222 if ( currPackage )
223 currPackage->setSection( value ); 223 currPackage->setSection( value );
224 224
225 DataManager::setAvailableCategories( value ); 225 DataManager::setAvailableCategories( value );
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
239void Server :: buildLocalPackages( Server *local ) 239void 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
257Package *Server :: getPackage( QString &name ) 271Package *Server :: getPackage( QString &name )
258{ 272{
259 return getPackage( (const char *)name ); 273 return getPackage( (const char *)name );
260} 274}
261 275
262Package *Server :: getPackage( const char *name ) 276Package *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
275QString Server :: toString() 289QString 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} /*
287void addAvailableSection( QString section )
288{
289 if ( DataManager::availableCategories.find( value ) == -1 )
290// DataManager::availableCategories += "#" + value;
291} 300}
292*/
293 301
294vector<Package> &Server::getPackageList() 302vector<Package> &Server::getPackageList()
295{ 303{
296 return packageList; 304 return packageList;
297} 305}
298 306