summaryrefslogtreecommitdiff
authordrw <drw>2003-03-28 01:27:02 (UTC)
committer drw <drw>2003-03-28 01:27:02 (UTC)
commit9e561f9fdd2bef09d21904aba0a74faa39165c04 (patch) (unidiff)
treee183734520a857a424d7e07c4bf0f0e7a35c90f8
parent79907dc7b9d89717b0d02f51a4094449e28eca6c (diff)
downloadopie-9e561f9fdd2bef09d21904aba0a74faa39165c04.zip
opie-9e561f9fdd2bef09d21904aba0a74faa39165c04.tar.gz
opie-9e561f9fdd2bef09d21904aba0a74faa39165c04.tar.bz2
Fix bug in reading feed's Package file
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/server.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/noncore/settings/aqpkg/server.cpp b/noncore/settings/aqpkg/server.cpp
index 04f5ab7..06b0863 100644
--- a/noncore/settings/aqpkg/server.cpp
+++ b/noncore/settings/aqpkg/server.cpp
@@ -72,198 +72,200 @@ void Server :: readStatusFile( QList<Destination> &destList )
72 bool installingToRoot = false; 72 bool installingToRoot = false;
73 73
74 QString path = dest->getDestinationPath(); 74 QString path = dest->getDestinationPath();
75 if ( path.right( 1 ) != "/" ) 75 if ( path.right( 1 ) != "/" )
76 path += "/"; 76 path += "/";
77 77
78 if ( path == "/" ) 78 if ( path == "/" )
79 { 79 {
80 rootRead = true; 80 rootRead = true;
81 installingToRoot = true; 81 installingToRoot = true;
82 } 82 }
83 83
84 packageFile = path + "usr/lib/ipkg/status"; 84 packageFile = path + "usr/lib/ipkg/status";
85 readPackageFile( 0, false, installingToRoot, &( *dest ) ); 85 readPackageFile( 0, false, installingToRoot, &( *dest ) );
86 } 86 }
87 87
88 // Ensure that the root status file is read 88 // Ensure that the root status file is read
89 if ( !rootRead ) 89 if ( !rootRead )
90 { 90 {
91 cout << "Reading status file " << "/usr/lib/ipkg/status" << endl; 91 cout << "Reading status file " << "/usr/lib/ipkg/status" << endl;
92 packageFile = "/usr/lib/ipkg/status"; 92 packageFile = "/usr/lib/ipkg/status";
93 readPackageFile( 0, false, true ); 93 readPackageFile( 0, false, true );
94 } 94 }
95} 95}
96 96
97void Server :: readLocalIpks( Server *local ) 97void Server :: readLocalIpks( Server *local )
98{ 98{
99 cleanUp(); 99 cleanUp();
100 100
101#ifdef QWS 101#ifdef QWS
102 // First, get any local IPKGs in the documents area 102 // First, get any local IPKGs in the documents area
103 // Only applicable to Qtopie/Opie 103 // Only applicable to Qtopie/Opie
104 104
105 DocLnkSet files; 105 DocLnkSet files;
106 Global::findDocuments( &files, "application/ipkg" ); 106 Global::findDocuments( &files, "application/ipkg" );
107 107
108 // Now add the items to the list 108 // Now add the items to the list
109 QListIterator<DocLnk> it( files.children() ); 109 QListIterator<DocLnk> it( files.children() );
110 110
111 for ( ; it.current() ; ++it ) 111 for ( ; it.current() ; ++it )
112 { 112 {
113 // OK, we have a local IPK file, I think the standard naming conventions 113 // OK, we have a local IPK file, I think the standard naming conventions
114 // for these are packagename_version_arm.ipk 114 // for these are packagename_version_arm.ipk
115 QString file = (*it)->file(); 115 QString file = (*it)->file();
116 116
117 // Changed to display the filename (excluding the path) 117 // Changed to display the filename (excluding the path)
118 QString packageName = Utils::getFilenameFromIpkFilename( file ); 118 QString packageName = Utils::getFilenameFromIpkFilename( file );
119 QString ver = Utils::getPackageVersionFromIpkFilename( file ); 119 QString ver = Utils::getPackageVersionFromIpkFilename( file );
120 Package *package = new Package( packageName ); 120 Package *package = new Package( packageName );
121 package->setVersion( ver ); 121 package->setVersion( ver );
122 package->setFilename( file ); 122 package->setFilename( file );
123 package->setPackageStoredLocally( true ); 123 package->setPackageStoredLocally( true );
124 packageList.append( package ); 124 packageList.append( package );
125 } 125 }
126#else 126#else
127 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" }; 127 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" };
128 for ( int i = 0 ; i < 4 ; ++i ) 128 for ( int i = 0 ; i < 4 ; ++i )
129 { 129 {
130 // OK, we have a local IPK file, I think the standard naming conventions 130 // OK, we have a local IPK file, I think the standard naming conventions
131 // for these are packagename_version_arm.ipk 131 // for these are packagename_version_arm.ipk
132 QString file = names[i]; 132 QString file = names[i];
133 int p = file.find( "_" ); 133 int p = file.find( "_" );
134 QString tmp = file.mid( 0, p ); 134 QString tmp = file.mid( 0, p );
135 packageList.push_back( Package( tmp ) ); 135 packageList.push_back( Package( tmp ) );
136 int p2 = file.find( "_", p+1 ); 136 int p2 = file.find( "_", p+1 );
137 tmp = file.mid( p+1, p2-(p+1) ); 137 tmp = file.mid( p+1, p2-(p+1) );
138 packageList.back().setVersion( tmp ); 138 packageList.back().setVersion( tmp );
139 packageList.back().setPackageStoredLocally( true ); 139 packageList.back().setPackageStoredLocally( true );
140 } 140 }
141#endif 141#endif
142 142
143 // build local packages 143 // build local packages
144 buildLocalPackages( local ); 144 buildLocalPackages( local );
145} 145}
146 146
147void Server :: readPackageFile( Server *local, bool clearAll, bool installingToRoot, Destination *dest ) 147void Server :: readPackageFile( Server *local, bool clearAll, bool installingToRoot, Destination *dest )
148{ 148{
149 ifstream in( packageFile ); 149 ifstream in( packageFile );
150 if ( !in.is_open() ) 150 if ( !in.is_open() )
151 return; 151 return;
152 152
153 char line[1001]; 153 char line[1001];
154 char k[21]; 154 char k[21];
155 char v[1001]; 155 char v[1001];
156 QString key; 156 QString key;
157 QString value; 157 QString value;
158 158
159 if ( clearAll ) 159 if ( clearAll )
160 cleanUp(); 160 cleanUp();
161 Package *currPackage = 0; 161 Package *currPackage = 0;
162 162
163 bool newPackage = true; 163 bool newPackage = true;
164 do 164 do
165 { 165 {
166 in.getline( line, 1000 ); 166 in.getline( line, 1000 );
167 if ( in.eof() ) 167 if ( in.eof() )
168 continue; 168 break;
169 169
170 k[0] = '\0'; 170 k[0] = '\0';
171 v[0] = '\0'; 171 v[0] = '\0';
172 172
173 sscanf( line, "%[^:]: %[^\n]", k, v ); 173 if ( sscanf( line, "%[^:]: %[^\n]", k, v ) < 2 )
174 break;
175
174 key = k; 176 key = k;
175 value = v; 177 value = v;
176 key = key.stripWhiteSpace(); 178 key = key.stripWhiteSpace();
177 value = value.stripWhiteSpace(); 179 value = value.stripWhiteSpace();
178 if ( key == "Package" && newPackage ) 180 if ( key == "Package" && newPackage )
179 { 181 {
180 newPackage = false; 182 newPackage = false;
181 183
182 currPackage = getPackage( value ); 184 currPackage = getPackage( value );
183 if ( !currPackage ) 185 if ( !currPackage )
184 { 186 {
185 Package *package = new Package( value ); 187 Package *package = new Package( value );
186 packageList.append( package ); 188 packageList.append( package );
187 currPackage = package; 189 currPackage = package;
188 currPackage->setInstalledTo( dest ); 190 currPackage->setInstalledTo( dest );
189 if ( installingToRoot ) 191 if ( installingToRoot )
190 currPackage->setInstalledToRoot( true ); 192 currPackage->setInstalledToRoot( true );
191 } 193 }
192 else 194 else
193 { 195 {
194 if (currPackage->getStatus().find( "deinstall" ) != -1 ) 196 if (currPackage->getStatus().find( "deinstall" ) != -1 )
195 currPackage->setInstalledTo( dest ); 197 currPackage->setInstalledTo( dest );
196 } 198 }
197 } 199 }
198 else if ( key == "Version" ) 200 else if ( key == "Version" )
199 { 201 {
200 if ( currPackage ) 202 if ( currPackage )
201 currPackage->setVersion( value ); 203 currPackage->setVersion( value );
202 } 204 }
203 else if ( key == "Status" ) 205 else if ( key == "Status" )
204 { 206 {
205 if ( currPackage ) 207 if ( currPackage )
206 currPackage->setStatus( value ); 208 currPackage->setStatus( value );
207 } 209 }
208 else if ( key == "Description" ) 210 else if ( key == "Description" )
209 { 211 {
210 if ( currPackage ) 212 if ( currPackage )
211 currPackage->setDescription( value ); 213 currPackage->setDescription( value );
212 } 214 }
213 else if ( key == "Filename" ) 215 else if ( key == "Filename" )
214 { 216 {
215 if ( currPackage ) 217 if ( currPackage )
216 currPackage->setFilename( value ); 218 currPackage->setFilename( value );
217 } 219 }
218 else if ( key == "Size" ) 220 else if ( key == "Size" )
219 { 221 {
220 if ( currPackage ) 222 if ( currPackage )
221 currPackage->setPackageSize( value ); 223 currPackage->setPackageSize( value );
222 } 224 }
223 else if ( key == "Section" ) 225 else if ( key == "Section" )
224 { 226 {
225 if ( currPackage ) 227 if ( currPackage )
226 currPackage->setSection( value ); 228 currPackage->setSection( value );
227 229
228 DataManager::setAvailableCategories( value ); 230 DataManager::setAvailableCategories( value );
229 } 231 }
230 else if ( key == "" ) 232 else if ( key == "" )
231 { 233 {
232 newPackage = true; 234 newPackage = true;
233 } 235 }
234 } while ( !in.eof() ); 236 } while ( !in.eof() );
235 237
236 in.close(); 238 in.close();
237 239
238 // build local packages 240 // build local packages
239 buildLocalPackages( local ); 241 buildLocalPackages( local );
240} 242}
241 243
242void Server :: buildLocalPackages( Server *local ) 244void Server :: buildLocalPackages( Server *local )
243{ 245{
244 Package *curr; 246 Package *curr;
245 QListIterator<Package> it( packageList ); 247 QListIterator<Package> it( packageList );
246 for ( ; it.current(); ++it ) 248 for ( ; it.current(); ++it )
247 { 249 {
248 curr = it.current(); 250 curr = it.current();
249 QString name = curr->getPackageName(); 251 QString name = curr->getPackageName();
250 252
251 // If the package name is an ipk name, then convert the filename to a package name 253 // If the package name is an ipk name, then convert the filename to a package name
252 if ( name.find( ".ipk" ) != -1 ) 254 if ( name.find( ".ipk" ) != -1 )
253 name = Utils::getPackageNameFromIpkFilename( curr->getFilename() ); 255 name = Utils::getPackageNameFromIpkFilename( curr->getFilename() );
254 256
255 if ( local ) 257 if ( local )
256 { 258 {
257 Package *p = local->getPackage( name ); 259 Package *p = local->getPackage( name );
258 curr->setLocalPackage( p ); 260 curr->setLocalPackage( p );
259 if ( p ) 261 if ( p )
260 { 262 {
261 // Set some default stuff like size and things 263 // Set some default stuff like size and things
262 if ( p->getInstalledVersion() == curr->getVersion() ) 264 if ( p->getInstalledVersion() == curr->getVersion() )
263 { 265 {
264 p->setPackageSize( curr->getPackageSize() ); 266 p->setPackageSize( curr->getPackageSize() );
265 p->setSection( curr->getSection() ); 267 p->setSection( curr->getSection() );
266 p->setDescription( curr->getDescription() ); 268 p->setDescription( curr->getDescription() );
267 } 269 }
268 } 270 }
269 271