summaryrefslogtreecommitdiff
path: root/noncore/unsupported/oipkg/package.cpp
Unidiff
Diffstat (limited to 'noncore/unsupported/oipkg/package.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/oipkg/package.cpp54
1 files changed, 44 insertions, 10 deletions
diff --git a/noncore/unsupported/oipkg/package.cpp b/noncore/unsupported/oipkg/package.cpp
index 1705f78..9f602b5 100644
--- a/noncore/unsupported/oipkg/package.cpp
+++ b/noncore/unsupported/oipkg/package.cpp
@@ -1,52 +1,59 @@
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 5
6#include "debug.h" 6#include "debug.h"
7 7
8Package::~Package() 8Package::~Package()
9{ 9{
10} 10}
11 11
12Package::Package() 12Package::Package( PackageManagerSettings *s )
13{ 13{
14 init(s);
15}
16
17void Package::init( PackageManagerSettings *s )
18{
19 settings = s;
14 _size = ""; 20 _size = "";
15 _section = ""; 21 _section = "";
16 _subsection = ""; 22 _subsection = "";
17 _shortDesc = ""; 23 _shortDesc = "";
18 _desc = ""; 24 _desc = "";
19 _name = ""; 25 _name = "";
20 _toProcess = false; 26 _toProcess = false;
21 _status = ""; 27 _status = "";
28 _dest = "";
22} 29}
23 30
24Package::Package( QStringList pack ) 31Package::Package( QStringList pack, PackageManagerSettings *s )
25 { 32 {
26 Package(); 33 init(s);
27 parsePackage( pack ); 34 parsePackage( pack );
28 _toProcess = false; 35 _toProcess = false;
29} 36}
30 37
31Package::Package( QString n ) 38Package::Package( QString n, PackageManagerSettings *s )
32 { 39 {
33 Package(); 40 init(s);
34 _name = QString( n ); 41 _name = QString( n );
35 _toProcess = false; 42 _toProcess = false;
36} 43}
37 44
38Package::Package( Package *pi ) 45Package::Package( Package *pi )
39{ 46{
40 Package(); 47 init(pi->settings);
41 copyValues( pi ); 48 copyValues( pi );
42 _toProcess = false; 49 _toProcess = false;
43} 50}
44 51
45 52
46void Package::setValue( QString n, QString t ) 53void Package::setValue( QString n, QString t )
47{ 54{
48 if ( n == "Status" && installed() ) return; 55 if ( n == "Status" && installed() ) return;
49 if ( n == "Package" ) 56 if ( n == "Package" )
50 { 57 {
51 _name = QString( t ); 58 _name = QString( t );
52 } 59 }
@@ -163,43 +170,43 @@ void Package::toggleProcess()
163 170
164void Package::copyValues( Package* pack ) 171void Package::copyValues( Package* pack )
165{ 172{
166 if (_size.isEmpty() && !pack->_size.isEmpty()) _size = QString( pack->_size ); 173 if (_size.isEmpty() && !pack->_size.isEmpty()) _size = QString( pack->_size );
167 if (_section.isEmpty() && !pack->_section.isEmpty()) _section = QString( pack->_section ); 174 if (_section.isEmpty() && !pack->_section.isEmpty()) _section = QString( pack->_section );
168 if (_subsection.isEmpty()&& !pack->_subsection.isEmpty()) _subsection = QString( pack->_subsection ); 175 if (_subsection.isEmpty()&& !pack->_subsection.isEmpty()) _subsection = QString( pack->_subsection );
169 if (_shortDesc.isEmpty() && !pack->_shortDesc.isEmpty()) _shortDesc = QString( pack->_shortDesc ); 176 if (_shortDesc.isEmpty() && !pack->_shortDesc.isEmpty()) _shortDesc = QString( pack->_shortDesc );
170 if (_desc.isEmpty() && !pack->_desc.isEmpty()) _desc = QString( pack->_desc ); 177 if (_desc.isEmpty() && !pack->_desc.isEmpty()) _desc = QString( pack->_desc );
171 if (_name.isEmpty() && !pack->_name.isEmpty()) _name = QString( pack->_name ); 178 if (_name.isEmpty() && !pack->_name.isEmpty()) _name = QString( pack->_name );
172 if (!installed() && _status.isEmpty() && !pack->_status.isEmpty()) _status = QString( pack->_status ); 179 if (!installed() && _status.isEmpty() && !pack->_status.isEmpty()) _status = QString( pack->_status );
173} 180}
174 181
175QString Package::getSection() 182QString Package::section()
176{ 183{
177 return _section; 184 return _section;
178} 185}
179 186
180void Package::setSection( QString s) 187void Package::setSection( QString s)
181{ 188{
182 int i = s.find("/"); 189 int i = s.find("/");
183 if ( i > 0 ) 190 if ( i > 0 )
184 { 191 {
185 _section = s.left(i); 192 _section = s.left(i);
186 _subsection = s.mid(i+1); 193 _subsection = s.mid(i+1);
187 }else{ 194 }else{
188 _section = s; 195 _section = s;
189 _subsection = ""; 196 _subsection = "";
190 } 197 }
191} 198}
192 199
193QString Package::getSubSection() 200QString Package::subSection()
194{ 201{
195 return _subsection; 202 return _subsection;
196} 203}
197 204
198void Package::parsePackage( QStringList pack ) 205void Package::parsePackage( QStringList pack )
199{ 206{
200 if ( pack.isEmpty() ) return; 207 if ( pack.isEmpty() ) return;
201 int count = pack.count(); 208 int count = pack.count();
202 for( int i = 0; i < count; i++ ) 209 for( int i = 0; i < count; i++ )
203 { 210 {
204 QString line = pack[i]; 211 QString line = pack[i];
205 int sep = line.find( QRegExp(":[\t ]+") ); 212 int sep = line.find( QRegExp(":[\t ]+") );
@@ -244,20 +251,47 @@ QString Package::details()
244 description.append(":</b> "); 251 description.append(":</b> ");
245 description.append(Qtopia::escapeString(line.mid(sep+2))); 252 description.append(Qtopia::escapeString(line.mid(sep+2)));
246 } else { 253 } else {
247 description.append(" "); 254 description.append(" ");
248 description.append(Qtopia::escapeString(line)); 255 description.append(Qtopia::escapeString(line));
249 } 256 }
250 } 257 }
251 } 258 }
252 } 259 }
253 return description; 260 return description;
254} 261}
255 262
256/** No descriptions */
257void Package::processed() 263void Package::processed()
258{ 264{
259 _toProcess = false; 265 _toProcess = false;
260 //hack, but we're mot writing status anyway... 266 //hack, but we're not writing status anyway...
261 if ( installed() ) _status = "install"; 267 if ( installed() ) _status = "install";
262 else _status = "installed"; 268 else _status = "installed";
263} 269}
270
271QString Package::dest()
272{
273 if ( installed()||(!installed() && _toProcess) )
274 return _dest!=""?_dest:settings->getDestinationName();
275 else return "";
276}
277
278void Package::setDest( QString d )
279{
280 _dest = d;
281}
282
283void Package::setOn()
284{
285 _toProcess = true;
286}
287
288bool Package::link()
289{
290 if ( _dest == "root" || (!installed() && !_toProcess) ) return false;
291 return _link;
292}
293
294void Package::setLink(bool b)
295{
296 _link = b;
297}