author | ar <ar> | 2003-12-10 21:29:36 (UTC) |
---|---|---|
committer | ar <ar> | 2003-12-10 21:29:36 (UTC) |
commit | 6dffa571b5bfdd3e353fdabb555a805c2999ef0f (patch) (unidiff) | |
tree | b57902c4087e3a0035d07f8aa75c9d541b51307b | |
parent | f8254fecc4f76de574ebca05d4a6c91e543ff58c (diff) | |
download | opie-6dffa571b5bfdd3e353fdabb555a805c2999ef0f.zip opie-6dffa571b5bfdd3e353fdabb555a805c2999ef0f.tar.gz opie-6dffa571b5bfdd3e353fdabb555a805c2999ef0f.tar.bz2 |
remove STL dependencies
-rw-r--r-- | noncore/settings/aqpkg/aqpkg.pro | 2 | ||||
-rw-r--r-- | noncore/settings/aqpkg/ipkg.cpp | 103 | ||||
-rw-r--r-- | noncore/settings/aqpkg/utils.cpp | 9 |
3 files changed, 52 insertions, 62 deletions
diff --git a/noncore/settings/aqpkg/aqpkg.pro b/noncore/settings/aqpkg/aqpkg.pro index 882cfd4..a24f036 100644 --- a/noncore/settings/aqpkg/aqpkg.pro +++ b/noncore/settings/aqpkg/aqpkg.pro | |||
@@ -34,7 +34,7 @@ SOURCES = mainwin.cpp \ | |||
34 | TARGET = aqpkg | 34 | TARGET = aqpkg |
35 | INCLUDEPATH += $(OPIEDIR)/include | 35 | INCLUDEPATH += $(OPIEDIR)/include |
36 | DEPENDPATH += $(OPIEDIR)/include | 36 | DEPENDPATH += $(OPIEDIR)/include |
37 | LIBS += -lqpe -lopie -lstdc++ | 37 | LIBS += -lqpe -lopie |
38 | 38 | ||
39 | include ( $(OPIEDIR)/include.pro ) | 39 | include ( $(OPIEDIR)/include.pro ) |
40 | 40 | ||
diff --git a/noncore/settings/aqpkg/ipkg.cpp b/noncore/settings/aqpkg/ipkg.cpp index 43eaaae..2a9c576 100644 --- a/noncore/settings/aqpkg/ipkg.cpp +++ b/noncore/settings/aqpkg/ipkg.cpp | |||
@@ -27,20 +27,13 @@ | |||
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include <fstream> | ||
31 | #include <iostream> | ||
32 | #include <vector> | ||
33 | using namespace std; | ||
34 | |||
35 | #include <stdio.h> | ||
36 | #include <unistd.h> | ||
37 | |||
38 | #ifdef QWS | 30 | #ifdef QWS |
39 | #include <qpe/qpeapplication.h> | 31 | #include <qpe/qpeapplication.h> |
40 | #else | 32 | #else |
41 | #include <qapplication.h> | 33 | #include <qapplication.h> |
42 | #endif | 34 | #endif |
43 | #include <qdir.h> | 35 | #include <qdir.h> |
36 | #include <qfile.h> | ||
44 | #include <qtextstream.h> | 37 | #include <qtextstream.h> |
45 | 38 | ||
46 | #include <opie/oprocess.h> | 39 | #include <opie/oprocess.h> |
@@ -203,9 +196,10 @@ void Ipkg :: removeStatusEntry() | |||
203 | tempstr.append( package ); | 196 | tempstr.append( package ); |
204 | emit outputText( tempstr ); | 197 | emit outputText( tempstr ); |
205 | 198 | ||
206 | ifstream in( statusFile ); | 199 | QFile readFile( statusFile ); |
207 | ofstream out( outStatusFile ); | 200 | QFile writeFile( outStatusFile ); |
208 | if ( !in.is_open() ) | 201 | |
202 | if ( !readFile.open( IO_ReadOnly ) ) | ||
209 | { | 203 | { |
210 | tempstr = tr("Couldn't open status file - "); | 204 | tempstr = tr("Couldn't open status file - "); |
211 | tempstr.append( statusFile ); | 205 | tempstr.append( statusFile ); |
@@ -213,7 +207,7 @@ void Ipkg :: removeStatusEntry() | |||
213 | return; | 207 | return; |
214 | } | 208 | } |
215 | 209 | ||
216 | if ( !out.is_open() ) | 210 | if ( !writeFile.open( IO_WriteOnly ) ) |
217 | { | 211 | { |
218 | tempstr = tr("Couldn't create tempory status file - "); | 212 | tempstr = tr("Couldn't create tempory status file - "); |
219 | tempstr.append( outStatusFile ); | 213 | tempstr.append( outStatusFile ); |
@@ -221,66 +215,63 @@ void Ipkg :: removeStatusEntry() | |||
221 | return; | 215 | return; |
222 | } | 216 | } |
223 | 217 | ||
224 | char line[1001]; | 218 | int i = 0; |
219 | |||
220 | QTextStream readStream( &readFile ); | ||
221 | QTextStream writeStream( &writeFile ); | ||
222 | QString line; | ||
223 | |||
225 | char k[21]; | 224 | char k[21]; |
226 | char v[1001]; | 225 | char v[1001]; |
227 | QString key; | 226 | QString key; |
228 | QString value; | 227 | QString value; |
229 | vector<QString> lines; | 228 | |
230 | int i = 0; | 229 | while ( !readStream.atEnd() ) |
231 | do | ||
232 | { | 230 | { |
233 | in.getline( line, 1000 ); | 231 | //read new line |
234 | if ( in.eof() ) | 232 | line = readStream.readLine(); |
235 | continue; | 233 | |
236 | 234 | if ( line.contains( ":", TRUE ) ) | |
237 | k[0] = '\0'; | ||
238 | v[0] = '\0'; | ||
239 | |||
240 | sscanf( line, "%[^:]: %[^\n]", k, v ); | ||
241 | key = k; | ||
242 | value = v; | ||
243 | key = key.stripWhiteSpace(); | ||
244 | value = value.stripWhiteSpace(); | ||
245 | if ( key == "Package" && value == package ) | ||
246 | { | 235 | { |
247 | // Ignore all lines up to next empty | 236 | //grep key and value from line |
248 | do | 237 | k[0] = '\0'; |
249 | { | 238 | v[0] = '\0'; |
250 | in.getline( line, 1000 ); | 239 | sscanf( line, "%[^:]: %[^\n]", k, v ); |
251 | if ( in.eof() || QString( line ).stripWhiteSpace() == "" ) | 240 | key = k; |
252 | continue; | 241 | value = v; |
253 | } while ( !in.eof() && QString( line ).stripWhiteSpace() != "" ); | 242 | key = key.stripWhiteSpace(); |
243 | value = value.stripWhiteSpace(); | ||
244 | } else { | ||
245 | key = ""; | ||
246 | value = ""; | ||
254 | } | 247 | } |
255 | 248 | ||
256 | lines.push_back( QString( line ) ); | 249 | if ( key == "Package" && value == package ) |
257 | out << line << endl; | 250 | { |
258 | 251 | //skip lines from the deleted package | |
259 | // Improve UI responsiveness | 252 | while ( ( !readStream.atEnd() ) && ( line.stripWhiteSpace() != "" ) ) |
260 | i++; | 253 | { |
261 | if ( ( i % 50 ) == 0 ) | 254 | line = readStream.readLine(); |
262 | qApp->processEvents(); | 255 | } |
263 | } while ( !in.eof() ); | 256 | } else { |
264 | 257 | ||
265 | // Write lines out | 258 | //write other lines into the tempfile |
266 | vector<QString>::iterator it; | 259 | writeStream << line << "\n"; |
267 | for ( it = lines.begin() ; it != lines.end() ; ++it ) | ||
268 | { | ||
269 | out << (const char *)(*it) << endl; | ||
270 | 260 | ||
271 | // Improve UI responsiveness | 261 | // Improve UI responsiveness |
272 | i++; | 262 | i++; |
273 | if ( ( i % 50 ) == 0 ) | 263 | if ( ( i % 50 ) == 0 ) |
274 | qApp->processEvents(); | 264 | qApp->processEvents(); |
265 | } | ||
275 | } | 266 | } |
276 | 267 | ||
277 | in.close(); | 268 | readFile.close(); |
278 | out.close(); | 269 | writeFile.close(); |
279 | 270 | ||
280 | // Remove old status file and put tmp stats file in its place | 271 | // Remove old status file and put tmp stats file in its place |
281 | remove( statusFile ); | 272 | remove( statusFile ); |
282 | rename( outStatusFile, statusFile ); | 273 | rename( outStatusFile, statusFile ); |
283 | } | 274 | } |
284 | 275 | ||
285 | int Ipkg :: executeIpkgCommand( QStringList &cmd, const QString /*option*/ ) | 276 | int Ipkg :: executeIpkgCommand( QStringList &cmd, const QString /*option*/ ) |
286 | { | 277 | { |
diff --git a/noncore/settings/aqpkg/utils.cpp b/noncore/settings/aqpkg/utils.cpp index 00607dd..be02b3a 100644 --- a/noncore/settings/aqpkg/utils.cpp +++ b/noncore/settings/aqpkg/utils.cpp | |||
@@ -1,6 +1,6 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | 3 | ||
4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> | 4 | =. Copyright (c) 2002 Andy Qua <andy.qua@blueyonder.co.uk> |
5 | .=l. Dan Williams <drw@handhelds.org> | 5 | .=l. Dan Williams <drw@handhelds.org> |
6 | .>+-= | 6 | .>+-= |
@@ -27,9 +27,8 @@ | |||
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include <stdio.h> | ||
31 | #include <sys/vfs.h> | 30 | #include <sys/vfs.h> |
32 | 31 | ||
33 | #include "utils.h" | 32 | #include "utils.h" |
34 | #include "global.h" | 33 | #include "global.h" |
35 | 34 | ||
@@ -49,7 +48,7 @@ QString Utils :: getPathfromIpkFilename( const QString &file ) | |||
49 | path = file.left( p ); | 48 | path = file.left( p ); |
50 | 49 | ||
51 | return path; | 50 | return path; |
52 | 51 | ||
53 | } | 52 | } |
54 | 53 | ||
55 | QString Utils :: getFilenameFromIpkFilename( const QString &file ) | 54 | QString Utils :: getFilenameFromIpkFilename( const QString &file ) |
@@ -58,7 +57,7 @@ QString Utils :: getFilenameFromIpkFilename( const QString &file ) | |||
58 | QString name = file; | 57 | QString name = file; |
59 | if ( p != -1 ) | 58 | if ( p != -1 ) |
60 | name = name.mid( p + 1 ); | 59 | name = name.mid( p + 1 ); |
61 | 60 | ||
62 | 61 | ||
63 | return name; | 62 | return name; |
64 | } | 63 | } |