summaryrefslogtreecommitdiff
authorkergoth <kergoth>2003-03-27 18:41:00 (UTC)
committer kergoth <kergoth>2003-03-27 18:41:00 (UTC)
commitbff145f5cced95c742deefcd607932a9f3728dd3 (patch) (unidiff)
treec1d533d21e78fb0d45e94490f055651c9e5e3156
parent390a5a0c332c8c6fb380c1ed4cd6adae3e544a08 (diff)
downloadopie-bff145f5cced95c742deefcd607932a9f3728dd3.zip
opie-bff145f5cced95c742deefcd607932a9f3728dd3.tar.gz
opie-bff145f5cced95c742deefcd607932a9f3728dd3.tar.bz2
Slower, but more appropriate status parser. Now identifies the state_status column and compares against installed.. This fixes the bug introduced where it hit 'ok installed' but not 'prefer installed', both of which are valid entries.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/package.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/noncore/settings/aqpkg/package.cpp b/noncore/settings/aqpkg/package.cpp
index 99187ac..83e0706 100644
--- a/noncore/settings/aqpkg/package.cpp
+++ b/noncore/settings/aqpkg/package.cpp
@@ -9,128 +9,136 @@
9/*************************************************************************** 9/***************************************************************************
10 * * 10 * *
11 * This program is free software; you can redistribute it and/or modify * 11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by * 12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or * 13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. * 14 * (at your option) any later version. *
15 * * 15 * *
16 ***************************************************************************/ 16 ***************************************************************************/
17 17
18#include "package.h" 18#include "package.h"
19#include "global.h" 19#include "global.h"
20 20
21Package::Package( QString &name ) 21Package::Package( QString &name )
22{ 22{
23 packageName = name; 23 packageName = name;
24 24
25 version = "N/A"; 25 version = "N/A";
26 description = "N/A"; 26 description = "N/A";
27 packageSize = "N/A"; 27 packageSize = "N/A";
28 section = "N/A"; 28 section = "N/A";
29 29
30 localPackage = 0; 30 localPackage = 0;
31 installed = false; 31 installed = false;
32 packageStoredLocally = false; 32 packageStoredLocally = false;
33 installedToRoot = false; 33 installedToRoot = false;
34 installed = false; 34 installed = false;
35 installedTo = 0; 35 installedTo = 0;
36} 36}
37 37
38Package::Package( char *name ) 38Package::Package( char *name )
39{ 39{
40 packageName = name; 40 packageName = name;
41 41
42 version = "N/A"; 42 version = "N/A";
43 description = "N/A"; 43 description = "N/A";
44 packageSize = "N/A"; 44 packageSize = "N/A";
45 section = "N/A"; 45 section = "N/A";
46 46
47 localPackage = 0; 47 localPackage = 0;
48 installed = false; 48 installed = false;
49 packageStoredLocally = false; 49 packageStoredLocally = false;
50 installedToRoot = false; 50 installedToRoot = false;
51 installed = false; 51 installed = false;
52 installedTo = 0; 52 installedTo = 0;
53} 53}
54 54
55Package::~Package() 55Package::~Package()
56{ 56{
57} 57}
58 58
59QString Package :: toString() 59QString Package :: toString()
60{ 60{
61 QString ret = "Package - " + getPackageName() + 61 QString ret = "Package - " + getPackageName() +
62 "\n version - " + getVersion(); 62 "\n version - " + getVersion();
63 63
64 if ( localPackage ) 64 if ( localPackage )
65 ret += "\n inst version - " + localPackage->getVersion(); 65 ret += "\n inst version - " + localPackage->getVersion();
66 66
67 67
68 return ret; 68 return ret;
69} 69}
70 70
71void Package :: setStatus( const QString &s ) 71void Package :: setStatus( const QString &s )
72{ 72{
73 status = s; 73 QString state_status;
74 int two, three;
74 75
75 if ( status.find( "ok installed" ) != -1 ) 76 status = s.simplifyWhiteSpace( );
77
78 two = status.find( " " ); // find second column
79 three = status.find( " ", two + 1 ); // find third column
80
81 state_status = status.mid( three ).stripWhiteSpace( );
82
83 if ( state_status == "installed" )
76 installed = true; 84 installed = true;
77} 85}
78 86
79void Package :: setLocalPackage( Package *p ) 87void Package :: setLocalPackage( Package *p )
80{ 88{
81 localPackage = p; 89 localPackage = p;
82 90
83 if ( localPackage ) 91 if ( localPackage )
84 if ( localPackage->getVersion() != getVersion() ) 92 if ( localPackage->getVersion() != getVersion() )
85 differentVersionAvailable = true; 93 differentVersionAvailable = true;
86 else 94 else
87 differentVersionAvailable = false; 95 differentVersionAvailable = false;
88} 96}
89 97
90void Package :: setVersion( const QString &v ) 98void Package :: setVersion( const QString &v )
91{ 99{
92 version = v; 100 version = v;
93 101
94 if ( localPackage ) 102 if ( localPackage )
95 if ( localPackage->getVersion() != getVersion() ) 103 if ( localPackage->getVersion() != getVersion() )
96 differentVersionAvailable = true; 104 differentVersionAvailable = true;
97 else 105 else
98 differentVersionAvailable = false; 106 differentVersionAvailable = false;
99} 107}
100 108
101void Package :: setPackageName( const QString &name ) 109void Package :: setPackageName( const QString &name )
102{ 110{
103 packageName = name; 111 packageName = name;
104} 112}
105 113
106void Package :: setDescription( const QString &d ) 114void Package :: setDescription( const QString &d )
107{ 115{
108 description = d; 116 description = d;
109} 117}
110 118
111void Package :: setFilename( const QString &f ) 119void Package :: setFilename( const QString &f )
112{ 120{
113 filename = f; 121 filename = f;
114} 122}
115 123
116 124
117QString Package :: getInstalledVersion() 125QString Package :: getInstalledVersion()
118{ 126{
119 if ( localPackage ) 127 if ( localPackage )
120 return localPackage->getVersion(); 128 return localPackage->getVersion();
121 else 129 else
122 return getVersion(); 130 return getVersion();
123} 131}
124 132
125QString Package :: getInstalledPackageName() 133QString Package :: getInstalledPackageName()
126{ 134{
127 if ( localPackage ) 135 if ( localPackage )
128 return localPackage->getPackageName(); 136 return localPackage->getPackageName();
129 else 137 else
130 return getPackageName(); 138 return getPackageName();
131} 139}
132 140
133bool Package :: isInstalled() 141bool Package :: isInstalled()
134{ 142{
135 return installed || ( localPackage && localPackage->isInstalled() ); 143 return installed || ( localPackage && localPackage->isInstalled() );
136} 144}