author | kergoth <kergoth> | 2003-03-27 18:41:00 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2003-03-27 18:41:00 (UTC) |
commit | bff145f5cced95c742deefcd607932a9f3728dd3 (patch) (unidiff) | |
tree | c1d533d21e78fb0d45e94490f055651c9e5e3156 | |
parent | 390a5a0c332c8c6fb380c1ed4cd6adae3e544a08 (diff) | |
download | opie-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.
-rw-r--r-- | noncore/settings/aqpkg/package.cpp | 12 |
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 | ||
21 | Package::Package( QString &name ) | 21 | Package::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 | ||
38 | Package::Package( char *name ) | 38 | Package::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 | ||
55 | Package::~Package() | 55 | Package::~Package() |
56 | { | 56 | { |
57 | } | 57 | } |
58 | 58 | ||
59 | QString Package :: toString() | 59 | QString 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 | ||
71 | void Package :: setStatus( const QString &s ) | 71 | void 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 | ||
79 | void Package :: setLocalPackage( Package *p ) | 87 | void 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 | ||
90 | void Package :: setVersion( const QString &v ) | 98 | void 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 | ||
101 | void Package :: setPackageName( const QString &name ) | 109 | void Package :: setPackageName( const QString &name ) |
102 | { | 110 | { |
103 | packageName = name; | 111 | packageName = name; |
104 | } | 112 | } |
105 | 113 | ||
106 | void Package :: setDescription( const QString &d ) | 114 | void Package :: setDescription( const QString &d ) |
107 | { | 115 | { |
108 | description = d; | 116 | description = d; |
109 | } | 117 | } |
110 | 118 | ||
111 | void Package :: setFilename( const QString &f ) | 119 | void Package :: setFilename( const QString &f ) |
112 | { | 120 | { |
113 | filename = f; | 121 | filename = f; |
114 | } | 122 | } |
115 | 123 | ||
116 | 124 | ||
117 | QString Package :: getInstalledVersion() | 125 | QString 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 | ||
125 | QString Package :: getInstalledPackageName() | 133 | QString 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 | ||
133 | bool Package :: isInstalled() | 141 | bool Package :: isInstalled() |
134 | { | 142 | { |
135 | return installed || ( localPackage && localPackage->isInstalled() ); | 143 | return installed || ( localPackage && localPackage->isInstalled() ); |
136 | } | 144 | } |