author | tille <tille> | 2002-06-28 17:01:13 (UTC) |
---|---|---|
committer | tille <tille> | 2002-06-28 17:01:13 (UTC) |
commit | 8176526fc61f4b4012021a4324aee592463dbb3a (patch) (unidiff) | |
tree | 928ffd2ce9c00df7d763e1e34b0f137192975c09 | |
parent | 986a23a683f53ab612be03b56dd9bc7c1aeb3651 (diff) | |
download | opie-8176526fc61f4b4012021a4324aee592463dbb3a.zip opie-8176526fc61f4b4012021a4324aee592463dbb3a.tar.gz opie-8176526fc61f4b4012021a4324aee592463dbb3a.tar.bz2 |
setpgid(0,0); thanks to sandman
-rw-r--r-- | noncore/unsupported/oipkg/main.cpp | 1 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/package.cpp | 2 |
2 files changed, 3 insertions, 0 deletions
diff --git a/noncore/unsupported/oipkg/main.cpp b/noncore/unsupported/oipkg/main.cpp index f72540c..c579df8 100644 --- a/noncore/unsupported/oipkg/main.cpp +++ b/noncore/unsupported/oipkg/main.cpp | |||
@@ -1,25 +1,26 @@ | |||
1 | 1 | ||
2 | #include "mainwindow.h" | 2 | #include "mainwindow.h" |
3 | 3 | ||
4 | #include <qpe/qpeapplication.h> | 4 | #include <qpe/qpeapplication.h> |
5 | #include <qstring.h> | 5 | #include <qstring.h> |
6 | //#include <qmessagebox.h> | 6 | //#include <qmessagebox.h> |
7 | int debugLevel; | 7 | int debugLevel; |
8 | 8 | ||
9 | int main( int argc, char ** argv ) | 9 | int main( int argc, char ** argv ) |
10 | { | 10 | { |
11 | setpgid(0,0); | ||
11 | printf("This is oipkg\n"); | 12 | printf("This is oipkg\n"); |
12 | printf("$Id$\n"); | 13 | printf("$Id$\n"); |
13 | debugLevel = 2; | 14 | debugLevel = 2; |
14 | if (argc > 1) | 15 | if (argc > 1) |
15 | { | 16 | { |
16 | debugLevel = QString ( argv[1] ).toInt(); | 17 | debugLevel = QString ( argv[1] ).toInt(); |
17 | qDebug("setting debug level to %i",debugLevel); | 18 | qDebug("setting debug level to %i",debugLevel); |
18 | } | 19 | } |
19 | QPEApplication a( argc, argv ); | 20 | QPEApplication a( argc, argv ); |
20 | MainWindow mw; | 21 | MainWindow mw; |
21 | // if (argc > 2) | 22 | // if (argc > 2) |
22 | // QMessageBox::information( &mw, "oipkg","While ipkg is working\noipkg is hanging.\nPlease be patient!"); | 23 | // QMessageBox::information( &mw, "oipkg","While ipkg is working\noipkg is hanging.\nPlease be patient!"); |
23 | a.showMainDocumentWidget( &mw ); | 24 | a.showMainDocumentWidget( &mw ); |
24 | return a.exec(); | 25 | return a.exec(); |
25 | } | 26 | } |
diff --git a/noncore/unsupported/oipkg/package.cpp b/noncore/unsupported/oipkg/package.cpp index 8bbdd77..0cd93bf 100644 --- a/noncore/unsupported/oipkg/package.cpp +++ b/noncore/unsupported/oipkg/package.cpp | |||
@@ -1,461 +1,463 @@ | |||
1 | #include "package.h" | 1 | #include "package.h" |
2 | 2 | ||
3 | #include <qpe/process.h> | 3 | #include <qpe/process.h> |
4 | #include <qpe/stringutil.h> | 4 | #include <qpe/stringutil.h> |
5 | #include <qfile.h> | 5 | #include <qfile.h> |
6 | #include <qtextstream.h> | 6 | #include <qtextstream.h> |
7 | #include <stdlib.h> | 7 | #include <stdlib.h> |
8 | #include <unistd.h> | 8 | #include <unistd.h> |
9 | 9 | ||
10 | #include "debug.h" | 10 | #include "debug.h" |
11 | 11 | ||
12 | Package::Package( QObject *parent, const char *name ) | 12 | Package::Package( QObject *parent, const char *name ) |
13 | : QObject(parent,name) | 13 | : QObject(parent,name) |
14 | { | 14 | { |
15 | 15 | ||
16 | } | 16 | } |
17 | 17 | ||
18 | Package::~Package() | 18 | Package::~Package() |
19 | { | 19 | { |
20 | } | 20 | } |
21 | 21 | ||
22 | Package::Package( PackageManagerSettings *s, QObject *parent, const char *name ) | 22 | Package::Package( PackageManagerSettings *s, QObject *parent, const char *name ) |
23 | : QObject(parent,name) | 23 | : QObject(parent,name) |
24 | { | 24 | { |
25 | Package(parent,name); | 25 | Package(parent,name); |
26 | init(s); | 26 | init(s); |
27 | } | 27 | } |
28 | 28 | ||
29 | void Package::init( PackageManagerSettings *s ) | 29 | void Package::init( PackageManagerSettings *s ) |
30 | { | 30 | { |
31 | settings = s; | 31 | settings = s; |
32 | _size = ""; | 32 | _size = ""; |
33 | _section = ""; | 33 | _section = ""; |
34 | _subsection = ""; | 34 | _subsection = ""; |
35 | _shortDesc = ""; | 35 | _shortDesc = ""; |
36 | _desc = ""; | 36 | _desc = ""; |
37 | _name = ""; | 37 | _name = ""; |
38 | _toProcess = false; | 38 | _toProcess = false; |
39 | _useFileName = false; | 39 | _useFileName = false; |
40 | _old = false; | 40 | _old = false; |
41 | _status = ""; | 41 | _status = ""; |
42 | _dest = settings->getDestinationName(); | 42 | _dest = settings->getDestinationName(); |
43 | _link = settings->createLinks(); | 43 | _link = settings->createLinks(); |
44 | _versions=0; | 44 | _versions=0; |
45 | _version=""; | 45 | _version=""; |
46 | } | 46 | } |
47 | 47 | ||
48 | Package::Package( QStringList pack, PackageManagerSettings *s , QObject *parent, const char *name ) | 48 | Package::Package( QStringList pack, PackageManagerSettings *s , QObject *parent, const char *name ) |
49 | : QObject(parent,name) | 49 | : QObject(parent,name) |
50 | { | 50 | { |
51 | init(s); | 51 | init(s); |
52 | parsePackage( pack ); | 52 | parsePackage( pack ); |
53 | } | 53 | } |
54 | 54 | ||
55 | Package::Package( QString n, PackageManagerSettings *s, QObject *parent, const char *name ) | 55 | Package::Package( QString n, PackageManagerSettings *s, QObject *parent, const char *name ) |
56 | : QObject(parent,name) | ||
56 | { | 57 | { |
57 | init(s); | 58 | init(s); |
58 | if ( !QFile::exists( n ) ) | 59 | if ( !QFile::exists( n ) ) |
59 | { | 60 | { |
60 | _name = QString( n ); | 61 | _name = QString( n ); |
61 | }else{ | 62 | }else{ |
62 | pvDebug(4,"remote file: "+n); | 63 | pvDebug(4,"remote file: "+n); |
63 | parseIpkgFile( n ); | 64 | parseIpkgFile( n ); |
64 | _useFileName = true; | 65 | _useFileName = true; |
65 | _fileName = QString( n ); | 66 | _fileName = QString( n ); |
66 | } | 67 | } |
67 | } | 68 | } |
68 | 69 | ||
69 | Package::Package( Package *pi, QObject *parent, const char *name ) | 70 | Package::Package( Package *pi, QObject *parent, const char *name ) |
71 | : QObject(parent,name) | ||
70 | { | 72 | { |
71 | init(pi->settings); | 73 | init(pi->settings); |
72 | copyValues( pi ); | 74 | copyValues( pi ); |
73 | } | 75 | } |
74 | 76 | ||
75 | 77 | ||
76 | void Package::setValue( QString n, QString t ) | 78 | void Package::setValue( QString n, QString t ) |
77 | { | 79 | { |
78 | if ( n == "Package" ) | 80 | if ( n == "Package" ) |
79 | { | 81 | { |
80 | _name = QString( t ); | 82 | _name = QString( t ); |
81 | }else if ( n == "Installed-Size" ) | 83 | }else if ( n == "Installed-Size" ) |
82 | { | 84 | { |
83 | _size = t; | 85 | _size = t; |
84 | // }else if ( n == "Priority") | 86 | // }else if ( n == "Priority") |
85 | // { | 87 | // { |
86 | 88 | ||
87 | }else if ( n == "Section") | 89 | }else if ( n == "Section") |
88 | { | 90 | { |
89 | setSection( t ); | 91 | setSection( t ); |
90 | // }else if ( n == "Maintainer") | 92 | // }else if ( n == "Maintainer") |
91 | // { | 93 | // { |
92 | // | 94 | // |
93 | // }else if ( n == "Architecture") | 95 | // }else if ( n == "Architecture") |
94 | // { | 96 | // { |
95 | 97 | ||
96 | }else if ( n == "Version") | 98 | }else if ( n == "Version") |
97 | { | 99 | { |
98 | _version = t; | 100 | _version = t; |
99 | // }else if ( n == "Pre-Depends") | 101 | // }else if ( n == "Pre-Depends") |
100 | // { | 102 | // { |
101 | // | 103 | // |
102 | // }else if ( n == "Depends") | 104 | // }else if ( n == "Depends") |
103 | // { | 105 | // { |
104 | 106 | ||
105 | }else if ( n == "Filename") | 107 | }else if ( n == "Filename") |
106 | { | 108 | { |
107 | _fileName = t; | 109 | _fileName = t; |
108 | // }else if ( n == "Size") | 110 | // }else if ( n == "Size") |
109 | // { | 111 | // { |
110 | // | 112 | // |
111 | //}else if ( n == "MD5Sum") | 113 | //}else if ( n == "MD5Sum") |
112 | //{ | 114 | //{ |
113 | 115 | ||
114 | }else if ( n == "Description") | 116 | }else if ( n == "Description") |
115 | { | 117 | { |
116 | setDesc( t ); | 118 | setDesc( t ); |
117 | }else if ( n == "Status") | 119 | }else if ( n == "Status") |
118 | { | 120 | { |
119 | if ( installed() ) return; | 121 | if ( installed() ) return; |
120 | _status = t; | 122 | _status = t; |
121 | // }else if ( n == "Essential") | 123 | // }else if ( n == "Essential") |
122 | // { | 124 | // { |
123 | 125 | ||
124 | }else{ | 126 | }else{ |
125 | _values.insert(n,new QString(t)); | 127 | _values.insert(n,new QString(t)); |
126 | } | 128 | } |
127 | } | 129 | } |
128 | 130 | ||
129 | QString Package::name() | 131 | QString Package::name() |
130 | { | 132 | { |
131 | if (_displayName.isEmpty() ) return _name; | 133 | if (_displayName.isEmpty() ) return _name; |
132 | else return _displayName; | 134 | else return _displayName; |
133 | } | 135 | } |
134 | 136 | ||
135 | 137 | ||
136 | QString Package::installName() | 138 | QString Package::installName() |
137 | { | 139 | { |
138 | if (_useFileName) return _fileName; | 140 | if (_useFileName) return _fileName; |
139 | else return _name; | 141 | else return _name; |
140 | } | 142 | } |
141 | 143 | ||
142 | QString Package::packageName() | 144 | QString Package::packageName() |
143 | { | 145 | { |
144 | QString pn = installName(); | 146 | QString pn = installName(); |
145 | pn = pn.right(pn.length()-pn.findRev("/")); | 147 | pn = pn.right(pn.length()-pn.findRev("/")); |
146 | pn = pn.left(pn.find("_")); | 148 | pn = pn.left(pn.find("_")); |
147 | return pn; | 149 | return pn; |
148 | } | 150 | } |
149 | 151 | ||
150 | bool Package::installed() | 152 | bool Package::installed() |
151 | { | 153 | { |
152 | if (_status.contains("installed")) | 154 | if (_status.contains("installed")) |
153 | { | 155 | { |
154 | if (_status.contains("not-installed")) | 156 | if (_status.contains("not-installed")) |
155 | { | 157 | { |
156 | _toProcess = true; | 158 | _toProcess = true; |
157 | return false; | 159 | return false; |
158 | } | 160 | } |
159 | else return true; | 161 | else return true; |
160 | } | 162 | } |
161 | else | 163 | else |
162 | if (_versions) | 164 | if (_versions) |
163 | { | 165 | { |
164 | QDictIterator<Package> other( *_versions ); | 166 | QDictIterator<Package> other( *_versions ); |
165 | while ( other.current() ) | 167 | while ( other.current() ) |
166 | { | 168 | { |
167 | if (other.current()->status().contains("installed") | 169 | if (other.current()->status().contains("installed") |
168 | && other.current()->version() == version()) | 170 | && other.current()->version() == version()) |
169 | return true; | 171 | return true; |
170 | ++other; | 172 | ++other; |
171 | } | 173 | } |
172 | } | 174 | } |
173 | return false; | 175 | return false; |
174 | } | 176 | } |
175 | 177 | ||
176 | bool Package::otherInstalled() | 178 | bool Package::otherInstalled() |
177 | { | 179 | { |
178 | if (_versions) | 180 | if (_versions) |
179 | { | 181 | { |
180 | QDictIterator<Package> other( *_versions ); | 182 | QDictIterator<Package> other( *_versions ); |
181 | while ( other.current() ) | 183 | while ( other.current() ) |
182 | { | 184 | { |
183 | if (other.current()->installed()) return true; | 185 | if (other.current()->installed()) return true; |
184 | ++other; | 186 | ++other; |
185 | } | 187 | } |
186 | } | 188 | } |
187 | return false; | 189 | return false; |
188 | } | 190 | } |
189 | 191 | ||
190 | void Package::setDesc( QString s ) | 192 | void Package::setDesc( QString s ) |
191 | { | 193 | { |
192 | _desc = s; | 194 | _desc = s; |
193 | _shortDesc = s.left( s.find("\n") ); | 195 | _shortDesc = s.left( s.find("\n") ); |
194 | } | 196 | } |
195 | 197 | ||
196 | QString Package::desc() | 198 | QString Package::desc() |
197 | { | 199 | { |
198 | return _desc; | 200 | return _desc; |
199 | } | 201 | } |
200 | 202 | ||
201 | QString Package::shortDesc() | 203 | QString Package::shortDesc() |
202 | { | 204 | { |
203 | return _shortDesc; | 205 | return _shortDesc; |
204 | } | 206 | } |
205 | 207 | ||
206 | QString Package::size() | 208 | QString Package::size() |
207 | { | 209 | { |
208 | return _size; | 210 | return _size; |
209 | } | 211 | } |
210 | 212 | ||
211 | 213 | ||
212 | QString Package::version() | 214 | QString Package::version() |
213 | { | 215 | { |
214 | return _version; | 216 | return _version; |
215 | } | 217 | } |
216 | 218 | ||
217 | QString Package::sizeUnits() | 219 | QString Package::sizeUnits() |
218 | { | 220 | { |
219 | int i = _size.toInt(); | 221 | int i = _size.toInt(); |
220 | int c = 0; | 222 | int c = 0; |
221 | QString ret; | 223 | QString ret; |
222 | QStringList unit; | 224 | QStringList unit; |
223 | unit << "B" << "KB" << "MB" << "GB" << "TB"; //prepair for the future ;) | 225 | unit << "B" << "KB" << "MB" << "GB" << "TB"; //prepair for the future ;) |
224 | while (i > 1) | 226 | while (i > 1) |
225 | { | 227 | { |
226 | ret=QString::number(i)+" "+unit[c]; | 228 | ret=QString::number(i)+" "+unit[c]; |
227 | c++; | 229 | c++; |
228 | i /= 1024; | 230 | i /= 1024; |
229 | } | 231 | } |
230 | return ret; | 232 | return ret; |
231 | } | 233 | } |
232 | 234 | ||
233 | bool Package::toProcess() | 235 | bool Package::toProcess() |
234 | { | 236 | { |
235 | return _toProcess; | 237 | return _toProcess; |
236 | } | 238 | } |
237 | 239 | ||
238 | bool Package::toRemove() | 240 | bool Package::toRemove() |
239 | { | 241 | { |
240 | if ( _toProcess && installed() ) return true; | 242 | if ( _toProcess && installed() ) return true; |
241 | else return false; | 243 | else return false; |
242 | } | 244 | } |
243 | 245 | ||
244 | bool Package::toInstall() | 246 | bool Package::toInstall() |
245 | { | 247 | { |
246 | if ( _toProcess && !installed() ) return true; | 248 | if ( _toProcess && !installed() ) return true; |
247 | else return false; | 249 | else return false; |
248 | } | 250 | } |
249 | 251 | ||
250 | void Package::toggleProcess() | 252 | void Package::toggleProcess() |
251 | { | 253 | { |
252 | _toProcess = ! _toProcess; | 254 | _toProcess = ! _toProcess; |
253 | } | 255 | } |
254 | 256 | ||
255 | 257 | ||
256 | 258 | ||
257 | void Package::copyValues( Package* pack ) | 259 | void Package::copyValues( Package* pack ) |
258 | { | 260 | { |
259 | if (_size.isEmpty() && !pack->_size.isEmpty()) _size = QString( pack->_size ); | 261 | if (_size.isEmpty() && !pack->_size.isEmpty()) _size = QString( pack->_size ); |
260 | if (_section.isEmpty() && !pack->_section.isEmpty()) _section = QString( pack->_section ); | 262 | if (_section.isEmpty() && !pack->_section.isEmpty()) _section = QString( pack->_section ); |
261 | if (_subsection.isEmpty()&& !pack->_subsection.isEmpty()) _subsection = QString( pack->_subsection ); | 263 | if (_subsection.isEmpty()&& !pack->_subsection.isEmpty()) _subsection = QString( pack->_subsection ); |
262 | if (_shortDesc.isEmpty() && !pack->_shortDesc.isEmpty()) _shortDesc = QString( pack->_shortDesc ); | 264 | if (_shortDesc.isEmpty() && !pack->_shortDesc.isEmpty()) _shortDesc = QString( pack->_shortDesc ); |
263 | if (_desc.isEmpty() && !pack->_desc.isEmpty()) _desc = QString( pack->_desc ); | 265 | if (_desc.isEmpty() && !pack->_desc.isEmpty()) _desc = QString( pack->_desc ); |
264 | if (_name.isEmpty() && !pack->_name.isEmpty()) _name = QString( pack->_name ); | 266 | if (_name.isEmpty() && !pack->_name.isEmpty()) _name = QString( pack->_name ); |
265 | if (_dest.isEmpty() && !pack->_dest.isEmpty()) _dest= QString( pack->_dest ); | 267 | if (_dest.isEmpty() && !pack->_dest.isEmpty()) _dest= QString( pack->_dest ); |
266 | if (_displayName.isEmpty()&& !pack->_displayName.isEmpty()) _displayName = QString( pack->_displayName ); | 268 | if (_displayName.isEmpty()&& !pack->_displayName.isEmpty()) _displayName = QString( pack->_displayName ); |
267 | if (_fileName.isEmpty() && !pack->_fileName.isEmpty()) _fileName = QString( pack->_fileName ); | 269 | if (_fileName.isEmpty() && !pack->_fileName.isEmpty()) _fileName = QString( pack->_fileName ); |
268 | if (_version.isEmpty() && !pack->_version.isEmpty()) _version = QString( pack->_version ); | 270 | if (_version.isEmpty() && !pack->_version.isEmpty()) _version = QString( pack->_version ); |
269 | if (_values.isEmpty() && !pack->_values.isEmpty())_values = QDict<QString>( pack->_values ); | 271 | if (_values.isEmpty() && !pack->_values.isEmpty())_values = QDict<QString>( pack->_values ); |
270 | if (!installed() && _status.isEmpty() && !pack->_status.isEmpty()) _status = QString( pack->_status ); | 272 | if (!installed() && _status.isEmpty() && !pack->_status.isEmpty()) _status = QString( pack->_status ); |
271 | } | 273 | } |
272 | 274 | ||
273 | QString Package::section() | 275 | QString Package::section() |
274 | { | 276 | { |
275 | return _section; | 277 | return _section; |
276 | } | 278 | } |
277 | 279 | ||
278 | void Package::setSection( QString s) | 280 | void Package::setSection( QString s) |
279 | { | 281 | { |
280 | int i = s.find("/"); | 282 | int i = s.find("/"); |
281 | if ( i > 0 ) | 283 | if ( i > 0 ) |
282 | { | 284 | { |
283 | _section = s.left(i); | 285 | _section = s.left(i); |
284 | _subsection = s.mid(i+1); | 286 | _subsection = s.mid(i+1); |
285 | }else{ | 287 | }else{ |
286 | _section = s; | 288 | _section = s; |
287 | _subsection = ""; | 289 | _subsection = ""; |
288 | } | 290 | } |
289 | } | 291 | } |
290 | 292 | ||
291 | QString Package::subSection() | 293 | QString Package::subSection() |
292 | { | 294 | { |
293 | return _subsection; | 295 | return _subsection; |
294 | } | 296 | } |
295 | 297 | ||
296 | void Package::parsePackage( QStringList pack ) | 298 | void Package::parsePackage( QStringList pack ) |
297 | { | 299 | { |
298 | if ( pack.isEmpty() ) return; | 300 | if ( pack.isEmpty() ) return; |
299 | int count = pack.count(); | 301 | int count = pack.count(); |
300 | for( int i = 0; i < count; i++ ) | 302 | for( int i = 0; i < count; i++ ) |
301 | { | 303 | { |
302 | QString line = pack[i]; | 304 | QString line = pack[i]; |
303 | int sep = line.find( QRegExp(":[\t ]+") ); | 305 | int sep = line.find( QRegExp(":[\t ]+") ); |
304 | if ( sep >= 0 ) | 306 | if ( sep >= 0 ) |
305 | { | 307 | { |
306 | QString tag = line.left(sep); | 308 | QString tag = line.left(sep); |
307 | QString value = line.mid(sep+2).simplifyWhiteSpace(); | 309 | QString value = line.mid(sep+2).simplifyWhiteSpace(); |
308 | setValue( tag, value ); | 310 | setValue( tag, value ); |
309 | }else{ | 311 | }else{ |
310 | } | 312 | } |
311 | } | 313 | } |
312 | return; | 314 | return; |
313 | } | 315 | } |
314 | 316 | ||
315 | QString Package::details() | 317 | QString Package::details() |
316 | { | 318 | { |
317 | QString status; | 319 | QString status; |
318 | Process ipkg_status(QStringList() << "ipkg" << "info" << name() ); | 320 | Process ipkg_status(QStringList() << "ipkg" << "info" << name() ); |
319 | QString description; | 321 | QString description; |
320 | if ( ipkg_status.exec("",status) ) | 322 | if ( ipkg_status.exec("",status) ) |
321 | { | 323 | { |
322 | QStringList lines = QStringList::split('\n',status,TRUE); | 324 | QStringList lines = QStringList::split('\n',status,TRUE); |
323 | for (QStringList::Iterator it = lines.begin(); it!=lines.end(); ++it) { | 325 | for (QStringList::Iterator it = lines.begin(); it!=lines.end(); ++it) { |
324 | QString line = *it; | 326 | QString line = *it; |
325 | if ( line == " ." ) | 327 | if ( line == " ." ) |
326 | { | 328 | { |
327 | description.append("<p>"); | 329 | description.append("<p>"); |
328 | } else | 330 | } else |
329 | if ( line[0] == ' ' || line[0] == '\t' ) | 331 | if ( line[0] == ' ' || line[0] == '\t' ) |
330 | { | 332 | { |
331 | // continuation | 333 | // continuation |
332 | description.append(" "); | 334 | description.append(" "); |
333 | description.append(Qtopia::escapeString(line)); | 335 | description.append(Qtopia::escapeString(line)); |
334 | } else { | 336 | } else { |
335 | int sep = line.find(QRegExp(":[\t ]+")); | 337 | int sep = line.find(QRegExp(":[\t ]+")); |
336 | if ( sep >= 0 ) | 338 | if ( sep >= 0 ) |
337 | { | 339 | { |
338 | QString tag = line.left(sep); | 340 | QString tag = line.left(sep); |
339 | description.append("<br>"); | 341 | description.append("<br>"); |
340 | description.append("<b>"); | 342 | description.append("<b>"); |
341 | description.append(Qtopia::escapeString(tag)); | 343 | description.append(Qtopia::escapeString(tag)); |
342 | description.append(":</b> "); | 344 | description.append(":</b> "); |
343 | description.append(Qtopia::escapeString(line.mid(sep+2))); | 345 | description.append(Qtopia::escapeString(line.mid(sep+2))); |
344 | } else { | 346 | } else { |
345 | description.append(" "); | 347 | description.append(" "); |
346 | description.append(Qtopia::escapeString(line)); | 348 | description.append(Qtopia::escapeString(line)); |
347 | } | 349 | } |
348 | } | 350 | } |
349 | } | 351 | } |
350 | } | 352 | } |
351 | return description; | 353 | return description; |
352 | } | 354 | } |
353 | 355 | ||
354 | void Package::processed() | 356 | void Package::processed() |
355 | { | 357 | { |
356 | _toProcess = false; | 358 | _toProcess = false; |
357 | //hack, but we're not writing status anyway... | 359 | //hack, but we're not writing status anyway... |
358 | if ( installed() ) _status = "install"; | 360 | if ( installed() ) _status = "install"; |
359 | else _status = "installed"; | 361 | else _status = "installed"; |
360 | } | 362 | } |
361 | 363 | ||
362 | QString Package::dest() | 364 | QString Package::dest() |
363 | { | 365 | { |
364 | if ( installed()||(!installed() && _toProcess) ) | 366 | if ( installed()||(!installed() && _toProcess) ) |
365 | return _dest!=""?_dest:settings->getDestinationName(); | 367 | return _dest!=""?_dest:settings->getDestinationName(); |
366 | else return ""; | 368 | else return ""; |
367 | } | 369 | } |
368 | 370 | ||
369 | void Package::setDest( QString d ) | 371 | void Package::setDest( QString d ) |
370 | { | 372 | { |
371 | if ( d == "remote") _useFileName = true; | 373 | if ( d == "remote") _useFileName = true; |
372 | else _dest = d; | 374 | else _dest = d; |
373 | } | 375 | } |
374 | 376 | ||
375 | void Package::setOn() | 377 | void Package::setOn() |
376 | { | 378 | { |
377 | _toProcess = true; | 379 | _toProcess = true; |
378 | } | 380 | } |
379 | 381 | ||
380 | bool Package::link() | 382 | bool Package::link() |
381 | { | 383 | { |
382 | if ( _dest == "root" || (!installed() && !_toProcess) ) return false; | 384 | if ( _dest == "root" || (!installed() && !_toProcess) ) return false; |
383 | return _link; | 385 | return _link; |
384 | } | 386 | } |
385 | 387 | ||
386 | void Package::setLink(bool b) | 388 | void Package::setLink(bool b) |
387 | { | 389 | { |
388 | _link = b; | 390 | _link = b; |
389 | } | 391 | } |
390 | 392 | ||
391 | void Package::parseIpkgFile( QString file) | 393 | void Package::parseIpkgFile( QString file) |
392 | { | 394 | { |
393 | system("tar xzf "+file+" -C /tmp"); | 395 | system("tar xzf "+file+" -C /tmp"); |
394 | system("tar xzf /tmp/control.tar.gz -C /tmp"); | 396 | system("tar xzf /tmp/control.tar.gz -C /tmp"); |
395 | QFile f("/tmp/control"); | 397 | QFile f("/tmp/control"); |
396 | if ( f.open(IO_ReadOnly) ) | 398 | if ( f.open(IO_ReadOnly) ) |
397 | { | 399 | { |
398 | QTextStream t( &f ); | 400 | QTextStream t( &f ); |
399 | QStringList pack; | 401 | QStringList pack; |
400 | while ( !t.eof() ) | 402 | while ( !t.eof() ) |
401 | { | 403 | { |
402 | pack << t.readLine(); | 404 | pack << t.readLine(); |
403 | } | 405 | } |
404 | f.close(); | 406 | f.close(); |
405 | parsePackage( pack ); | 407 | parsePackage( pack ); |
406 | } | 408 | } |
407 | 409 | ||
408 | } | 410 | } |
409 | 411 | ||
410 | //QString Package::getPackageName() | 412 | //QString Package::getPackageName() |
411 | //{ | 413 | //{ |
412 | //if ( _packageName.isEmpty() ) return _name; | 414 | //if ( _packageName.isEmpty() ) return _name; |
413 | //else return _packageName; | 415 | //else return _packageName; |
414 | //} | 416 | //} |
415 | 417 | ||
416 | void Package::instalFromFile(bool iff) | 418 | void Package::instalFromFile(bool iff) |
417 | { | 419 | { |
418 | _useFileName = iff; | 420 | _useFileName = iff; |
419 | } | 421 | } |
420 | 422 | ||
421 | void Package::setName(QString n) | 423 | void Package::setName(QString n) |
422 | { | 424 | { |
423 | _displayName = n; | 425 | _displayName = n; |
424 | } | 426 | } |
425 | 427 | ||
426 | QDict<QString>* Package::getFields() | 428 | QDict<QString>* Package::getFields() |
427 | { | 429 | { |
428 | return &_values; | 430 | return &_values; |
429 | } | 431 | } |
430 | 432 | ||
431 | QString Package::status() | 433 | QString Package::status() |
432 | { | 434 | { |
433 | return _status; | 435 | return _status; |
434 | } | 436 | } |
435 | 437 | ||
436 | bool Package::isOld() | 438 | bool Package::isOld() |
437 | { | 439 | { |
438 | if (!_versions) return false; | 440 | if (!_versions) return false; |
439 | QDictIterator<Package> other( *_versions ); | 441 | QDictIterator<Package> other( *_versions ); |
440 | while ( other.current() ) { | 442 | while ( other.current() ) { |
441 | if (other.current()->version() > version() ) return true; | 443 | if (other.current()->version() > version() ) return true; |
442 | ++other; | 444 | ++other; |
443 | } | 445 | } |
444 | return false; | 446 | return false; |
445 | } | 447 | } |
446 | 448 | ||
447 | bool Package::hasVersions() | 449 | bool Package::hasVersions() |
448 | { | 450 | { |
449 | if (!_versions) return false; | 451 | if (!_versions) return false; |
450 | else return true; | 452 | else return true; |
451 | } | 453 | } |
452 | 454 | ||
453 | QDict<Package>* Package::getOtherVersions() | 455 | QDict<Package>* Package::getOtherVersions() |
454 | { | 456 | { |
455 | return _versions; | 457 | return _versions; |
456 | } | 458 | } |
457 | 459 | ||
458 | void Package::setOtherVersions(QDict<Package> *v) | 460 | void Package::setOtherVersions(QDict<Package> *v) |
459 | { | 461 | { |
460 | _versions=v; | 462 | _versions=v; |
461 | } | 463 | } |