summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/server.cpp56
1 files changed, 24 insertions, 32 deletions
diff --git a/noncore/settings/aqpkg/server.cpp b/noncore/settings/aqpkg/server.cpp
index 64a9c26..9a239a5 100644
--- a/noncore/settings/aqpkg/server.cpp
+++ b/noncore/settings/aqpkg/server.cpp
@@ -16,23 +16,18 @@
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>
23#include <string.h>
24#include <stdlib.h>
25
26#include <iostream>
27#include <fstream>
28using namespace std;
29
30#include "server.h" 22#include "server.h"
31#include "datamgr.h" 23#include "datamgr.h"
32 24
25#include <qfile.h>
26#include <qtextstream.h>
27
33#ifdef QWS 28#ifdef QWS
34#include <qpe/global.h> 29#include <qpe/global.h>
35#include <qpe/applnk.h> 30#include <qpe/applnk.h>
36#include <qlist.h> 31#include <qlist.h>
37#endif 32#endif
38 33
@@ -70,28 +65,29 @@ void Server :: readStatusFile( QList<Destination> &destList )
70 { 65 {
71 dest = dit.current(); 66 dest = dit.current();
72 bool installingToRoot = false; 67 bool installingToRoot = false;
73 68
74 QString path = dest->getDestinationPath(); 69 QString path = dest->getDestinationPath();
75 if ( path.right( 1 ) != "/" ) 70 if ( path.right( 1 ) != "/" )
76 path += "/"; 71 path.append( "/" );
77 72
78 if ( path == "/" ) 73 if ( path == "/" )
79 { 74 {
80 rootRead = true; 75 rootRead = true;
81 installingToRoot = true; 76 installingToRoot = true;
82 } 77 }
83 78
84 packageFile = path + "usr/lib/ipkg/status"; 79 packageFile = path;
80 packageFile.append( "usr/lib/ipkg/status" );
85 readPackageFile( 0, false, installingToRoot, &( *dest ) ); 81 readPackageFile( 0, false, installingToRoot, &( *dest ) );
86 } 82 }
87 83
88 // Ensure that the root status file is read 84 // Ensure that the root status file is read
89 if ( !rootRead ) 85 if ( !rootRead )
90 { 86 {
91 cout << "Reading status file " << "/usr/lib/ipkg/status" << endl; 87 //cout << "Reading status file " << "/usr/lib/ipkg/status" << endl;
92 packageFile = "/usr/lib/ipkg/status"; 88 packageFile = "/usr/lib/ipkg/status";
93 readPackageFile( 0, false, true ); 89 readPackageFile( 0, false, true );
94 } 90 }
95} 91}
96 92
97void Server :: readLocalIpks( Server *local ) 93void Server :: readLocalIpks( Server *local )
@@ -143,42 +139,38 @@ void Server :: readLocalIpks( Server *local )
143 // build local packages 139 // build local packages
144 buildLocalPackages( local ); 140 buildLocalPackages( local );
145} 141}
146 142
147void Server :: readPackageFile( Server *local, bool clearAll, bool installingToRoot, Destination *dest ) 143void Server :: readPackageFile( Server *local, bool clearAll, bool installingToRoot, Destination *dest )
148{ 144{
149 ifstream in( packageFile ); 145 QFile f( packageFile );
150 if ( !in.is_open() ) 146 if ( !f.open( IO_ReadOnly ) )
151 return; 147 return;
148 QTextStream t( &f );
152 149
153 char line[5001]; 150 QString line;
154 char k[21];
155 char v[5001];
156 QString key; 151 QString key;
157 QString value; 152 QString value;
153 int pos;
158 154
159 if ( clearAll ) 155 if ( clearAll )
160 cleanUp(); 156 cleanUp();
161 Package *currPackage = 0; 157 Package *currPackage = 0;
162 158
163 bool newPackage = true; 159 bool newPackage = true;
164 do 160 while ( !t.eof() )
165 { 161 {
166 in.getline( line, 5000 ); 162 line = t.readLine();
167 if ( in.eof() )
168 continue;
169
170 k[0] = '\0';
171 v[0] = '\0';
172
173 sscanf( line, "%[^:]: %[^\n]", k, v );
174 163
175 key = k; 164 pos = line.find( ':', 0 );
176 value = v; 165 if ( pos > -1 )
177 key = key.stripWhiteSpace(); 166 key = line.mid( 0, pos ).stripWhiteSpace();
178 value = value.stripWhiteSpace(); 167 else
168 key = QString::null;
169 value = line.mid( pos+1, line.length()-pos ).stripWhiteSpace();
170
179 if ( key == "Package" && newPackage ) 171 if ( key == "Package" && newPackage )
180 { 172 {
181 newPackage = false; 173 newPackage = false;
182 174
183 currPackage = getPackage( value ); 175 currPackage = getPackage( value );
184 if ( !currPackage ) 176 if ( !currPackage )
@@ -225,19 +217,19 @@ void Server :: readPackageFile( Server *local, bool clearAll, bool installingToR
225 { 217 {
226 if ( currPackage ) 218 if ( currPackage )
227 currPackage->setSection( value ); 219 currPackage->setSection( value );
228 220
229 DataManager::setAvailableCategories( value ); 221 DataManager::setAvailableCategories( value );
230 } 222 }
231 else if ( key == "" ) 223 else if ( key == QString::null )
232 { 224 {
233 newPackage = true; 225 newPackage = true;
234 } 226 }
235 } while ( !in.eof() ); 227 }
236 228
237 in.close(); 229 f.close();
238 230
239 // build local packages 231 // build local packages
240 buildLocalPackages( local ); 232 buildLocalPackages( local );
241} 233}
242 234
243void Server :: buildLocalPackages( Server *local ) 235void Server :: buildLocalPackages( Server *local )