author | drw <drw> | 2004-09-09 14:15:52 (UTC) |
---|---|---|
committer | drw <drw> | 2004-09-09 14:15:52 (UTC) |
commit | 317734f41201bf25fa3a1b38c2867bb9557053b9 (patch) (unidiff) | |
tree | 7ce5e9d735483415f42b15ae6939e37e8fc35a0c | |
parent | 4e798036b423bcb8800f125357591e48b84594c8 (diff) | |
download | opie-317734f41201bf25fa3a1b38c2867bb9557053b9.zip opie-317734f41201bf25fa3a1b38c2867bb9557053b9.tar.gz opie-317734f41201bf25fa3a1b38c2867bb9557053b9.tar.bz2 |
Fix for too much verbosity while performing ipkg functions. Thanks to Seb for fix
-rw-r--r-- | noncore/settings/packagemanager/oipkg.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/noncore/settings/packagemanager/oipkg.cpp b/noncore/settings/packagemanager/oipkg.cpp index eca5861..1978ad5 100644 --- a/noncore/settings/packagemanager/oipkg.cpp +++ b/noncore/settings/packagemanager/oipkg.cpp | |||
@@ -1,436 +1,438 @@ | |||
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) 2003 Dan Williams <drw@handhelds.org> | 4 | Copyright (c) 2003 Dan Williams <drw@handhelds.org> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | 29 | ||
30 | */ | 30 | */ |
31 | 31 | ||
32 | #include "oipkg.h" | 32 | #include "oipkg.h" |
33 | 33 | ||
34 | #include <qdir.h> | 34 | #include <qdir.h> |
35 | #include <qfile.h> | 35 | #include <qfile.h> |
36 | #include <qtextstream.h> | 36 | #include <qtextstream.h> |
37 | 37 | ||
38 | #include <stdlib.h> | 38 | #include <stdlib.h> |
39 | 39 | ||
40 | const QString IPKG_CONF = "/etc/ipkg.conf"; // Fully-qualified name of Ipkg primary configuration file | 40 | const QString IPKG_CONF = "/etc/ipkg.conf"; // Fully-qualified name of Ipkg primary configuration file |
41 | const QString IPKG_CONF_DIR = "/etc/ipkg"; // Directory of secondary Ipkg configuration files | 41 | const QString IPKG_CONF_DIR = "/etc/ipkg"; // Directory of secondary Ipkg configuration files |
42 | const QString IPKG_PKG_PATH = "/usr/lib/ipkg/lists"; // Directory containing server package lists | 42 | const QString IPKG_PKG_PATH = "/usr/lib/ipkg/lists"; // Directory containing server package lists |
43 | const QString IPKG_STATUS_PATH = "usr/lib/ipkg/status"; // Destination status file location | 43 | const QString IPKG_STATUS_PATH = "usr/lib/ipkg/status"; // Destination status file location |
44 | 44 | ||
45 | OIpkg *oipkg; | 45 | OIpkg *oipkg; |
46 | 46 | ||
47 | // Ipkg callback functions | 47 | // Ipkg callback functions |
48 | 48 | ||
49 | int fsignalIpkgMessage( ipkg_conf_t */*conf*/, message_level_t /*level*/, char *msg ) | 49 | int fsignalIpkgMessage( ipkg_conf_t *conf, message_level_t level, char *msg ) |
50 | { | 50 | { |
51 | oipkg->ipkgMessage( msg ); | 51 | if ( conf && ( conf->verbosity < level ) ) |
52 | return 0; | 52 | return 0; |
53 | else | ||
54 | oipkg->ipkgMessage( msg ); | ||
53 | } | 55 | } |
54 | 56 | ||
55 | char *fIpkgResponse( char */*question*/ ) | 57 | char *fIpkgResponse( char */*question*/ ) |
56 | { | 58 | { |
57 | return 0x0; | 59 | return 0x0; |
58 | } | 60 | } |
59 | 61 | ||
60 | int fIpkgStatus( char */*name*/, int /*status*/, char *desc, void */*userdata*/ ) | 62 | int fIpkgStatus( char */*name*/, int /*status*/, char *desc, void */*userdata*/ ) |
61 | { | 63 | { |
62 | oipkg->ipkgStatus( desc ); | 64 | oipkg->ipkgStatus( desc ); |
63 | return 0; | 65 | return 0; |
64 | } | 66 | } |
65 | 67 | ||
66 | int fIpkgFiles( char */*name*/, char *desc, char */*version*/, pkg_state_status_t /*status*/, | 68 | int fIpkgFiles( char */*name*/, char *desc, char */*version*/, pkg_state_status_t /*status*/, |
67 | void */*userdata*/ ) | 69 | void */*userdata*/ ) |
68 | { | 70 | { |
69 | oipkg->ipkgList( desc ); | 71 | oipkg->ipkgList( desc ); |
70 | return 0; | 72 | return 0; |
71 | } | 73 | } |
72 | 74 | ||
73 | OIpkg::OIpkg( Config *config, QObject *parent, const char *name ) | 75 | OIpkg::OIpkg( Config *config, QObject *parent, const char *name ) |
74 | : QObject( parent, name ) | 76 | : QObject( parent, name ) |
75 | , m_config( config ) | 77 | , m_config( config ) |
76 | , m_confInfo( NULL ) | 78 | , m_confInfo( NULL ) |
77 | , m_ipkgExecOptions( 0 ) | 79 | , m_ipkgExecOptions( 0 ) |
78 | , m_ipkgExecVerbosity( 1 ) | 80 | , m_ipkgExecVerbosity( 1 ) |
79 | { | 81 | { |
80 | oipkg = this; | 82 | oipkg = this; |
81 | 83 | ||
82 | // Initialize libipkg | 84 | // Initialize libipkg |
83 | ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ); | 85 | ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ); |
84 | 86 | ||
85 | // Default ipkg run-time arguments | 87 | // Default ipkg run-time arguments |
86 | m_ipkgArgs.noaction = false; | 88 | m_ipkgArgs.noaction = false; |
87 | m_ipkgArgs.force_defaults = true; | 89 | m_ipkgArgs.force_defaults = true; |
88 | } | 90 | } |
89 | 91 | ||
90 | OIpkg::~OIpkg() | 92 | OIpkg::~OIpkg() |
91 | { | 93 | { |
92 | // Upon destruction, ensure that items in config list are deleted with list | 94 | // Upon destruction, ensure that items in config list are deleted with list |
93 | if ( m_confInfo ) | 95 | if ( m_confInfo ) |
94 | m_confInfo->setAutoDelete( true ); | 96 | m_confInfo->setAutoDelete( true ); |
95 | 97 | ||
96 | // Free up libipkg resources | 98 | // Free up libipkg resources |
97 | ipkg_deinit( &m_ipkgArgs ); | 99 | ipkg_deinit( &m_ipkgArgs ); |
98 | } | 100 | } |
99 | 101 | ||
100 | OConfItemList *OIpkg::configItems() | 102 | OConfItemList *OIpkg::configItems() |
101 | { | 103 | { |
102 | // Retrieve all configuration items | 104 | // Retrieve all configuration items |
103 | return filterConfItems(); | 105 | return filterConfItems(); |
104 | } | 106 | } |
105 | 107 | ||
106 | OConfItemList *OIpkg::servers() | 108 | OConfItemList *OIpkg::servers() |
107 | { | 109 | { |
108 | // Retrieve only servers | 110 | // Retrieve only servers |
109 | return filterConfItems( OConfItem::Source ); | 111 | return filterConfItems( OConfItem::Source ); |
110 | } | 112 | } |
111 | 113 | ||
112 | OConfItemList *OIpkg::destinations() | 114 | OConfItemList *OIpkg::destinations() |
113 | { | 115 | { |
114 | // Retrieve only destinations | 116 | // Retrieve only destinations |
115 | return filterConfItems( OConfItem::Destination ); | 117 | return filterConfItems( OConfItem::Destination ); |
116 | } | 118 | } |
117 | 119 | ||
118 | OConfItemList *OIpkg::options() | 120 | OConfItemList *OIpkg::options() |
119 | { | 121 | { |
120 | // Retrieve only destinations | 122 | // Retrieve only destinations |
121 | return filterConfItems( OConfItem::Option ); | 123 | return filterConfItems( OConfItem::Option ); |
122 | } | 124 | } |
123 | 125 | ||
124 | void OIpkg::setConfigItems( OConfItemList *configList ) | 126 | void OIpkg::setConfigItems( OConfItemList *configList ) |
125 | { | 127 | { |
126 | if ( m_confInfo ) | 128 | if ( m_confInfo ) |
127 | delete m_confInfo; | 129 | delete m_confInfo; |
128 | 130 | ||
129 | m_confInfo = configList; | 131 | m_confInfo = configList; |
130 | 132 | ||
131 | // Write out new /etc/ipkg.conf | 133 | // Write out new /etc/ipkg.conf |
132 | QFile confFile( IPKG_CONF ); | 134 | QFile confFile( IPKG_CONF ); |
133 | if ( confFile.open( IO_WriteOnly ) ) | 135 | if ( confFile.open( IO_WriteOnly ) ) |
134 | { | 136 | { |
135 | QTextStream confStream( &confFile ); | 137 | QTextStream confStream( &confFile ); |
136 | confStream << "# Generated by Opie Package Manager\n\n"; | 138 | confStream << "# Generated by Opie Package Manager\n\n"; |
137 | 139 | ||
138 | OConfItemListIterator it( *m_confInfo ); | 140 | OConfItemListIterator it( *m_confInfo ); |
139 | for ( ; it.current(); ++it ) | 141 | for ( ; it.current(); ++it ) |
140 | { | 142 | { |
141 | OConfItem *item = it.current(); | 143 | OConfItem *item = it.current(); |
142 | 144 | ||
143 | // Only write out valid conf items | 145 | // Only write out valid conf items |
144 | if ( item->type() != OConfItem::NotDefined ) | 146 | if ( item->type() != OConfItem::NotDefined ) |
145 | { | 147 | { |
146 | QString confLine; | 148 | QString confLine; |
147 | if ( !item->active() ) | 149 | if ( !item->active() ) |
148 | confLine = "#"; | 150 | confLine = "#"; |
149 | 151 | ||
150 | switch ( item->type() ) | 152 | switch ( item->type() ) |
151 | { | 153 | { |
152 | case OConfItem::Source : confLine.append( "src " ); break; | 154 | case OConfItem::Source : confLine.append( "src " ); break; |
153 | case OConfItem::Destination : confLine.append( "dest " ); break; | 155 | case OConfItem::Destination : confLine.append( "dest " ); break; |
154 | case OConfItem::Option : confLine.append( "option " ); break; | 156 | case OConfItem::Option : confLine.append( "option " ); break; |
155 | case OConfItem::Arch : confLine.append( "arch " ); break; | 157 | case OConfItem::Arch : confLine.append( "arch " ); break; |
156 | default : break; | 158 | default : break; |
157 | }; | 159 | }; |
158 | 160 | ||
159 | confStream << confLine << " " << item->name() << " " << item->value() << "\n"; | 161 | confStream << confLine << " " << item->name() << " " << item->value() << "\n"; |
160 | } | 162 | } |
161 | } | 163 | } |
162 | 164 | ||
163 | confFile.close(); | 165 | confFile.close(); |
164 | } | 166 | } |
165 | else | 167 | else |
166 | { | 168 | { |
167 | // Problem writing to /etc/ipkg.conf, exit before removing other conf files | 169 | // Problem writing to /etc/ipkg.conf, exit before removing other conf files |
168 | return; | 170 | return; |
169 | } | 171 | } |
170 | 172 | ||
171 | // Delete /etc/ipkg/*.conf files (/etc/ipkg.conf should now have all settings | 173 | // Delete /etc/ipkg/*.conf files (/etc/ipkg.conf should now have all settings |
172 | QStringList confFiles; | 174 | QStringList confFiles; |
173 | QDir confDir( IPKG_CONF_DIR ); | 175 | QDir confDir( IPKG_CONF_DIR ); |
174 | if ( confDir.exists() ) | 176 | if ( confDir.exists() ) |
175 | { | 177 | { |
176 | confDir.setNameFilter( "*.conf" ); | 178 | confDir.setNameFilter( "*.conf" ); |
177 | confDir.setFilter( QDir::Files ); | 179 | confDir.setFilter( QDir::Files ); |
178 | confFiles = confDir.entryList( "*.conf", QDir::Files ); | 180 | confFiles = confDir.entryList( "*.conf", QDir::Files ); |
179 | 181 | ||
180 | QStringList::Iterator lastFile = confFiles.end(); | 182 | QStringList::Iterator lastFile = confFiles.end(); |
181 | for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it ) | 183 | for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it ) |
182 | { | 184 | { |
183 | // Create absolute file path if necessary | 185 | // Create absolute file path if necessary |
184 | QString absFile = (*it); | 186 | QString absFile = (*it); |
185 | if ( !absFile.startsWith( "/" ) ) | 187 | if ( !absFile.startsWith( "/" ) ) |
186 | absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); | 188 | absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); |
187 | 189 | ||
188 | // Delete file | 190 | // Delete file |
189 | QFile::remove( absFile ); | 191 | QFile::remove( absFile ); |
190 | } | 192 | } |
191 | } | 193 | } |
192 | 194 | ||
193 | // Reinitialize libipkg to pick up new configuration | 195 | // Reinitialize libipkg to pick up new configuration |
194 | ipkg_deinit( &m_ipkgArgs ); | 196 | ipkg_deinit( &m_ipkgArgs ); |
195 | ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ); | 197 | ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ); |
196 | m_ipkgArgs.noaction = false; | 198 | m_ipkgArgs.noaction = false; |
197 | m_ipkgArgs.force_defaults = true; | 199 | m_ipkgArgs.force_defaults = true; |
198 | } | 200 | } |
199 | 201 | ||
200 | void OIpkg::saveSettings() | 202 | void OIpkg::saveSettings() |
201 | { | 203 | { |
202 | // Save Ipkg execution options to application configuration file | 204 | // Save Ipkg execution options to application configuration file |
203 | if ( m_config ) | 205 | if ( m_config ) |
204 | { | 206 | { |
205 | m_config->setGroup( "Ipkg" ); | 207 | m_config->setGroup( "Ipkg" ); |
206 | m_config->writeEntry( "ExecOptions", m_ipkgExecOptions ); | 208 | m_config->writeEntry( "ExecOptions", m_ipkgExecOptions ); |
207 | m_config->writeEntry( "Verbosity", m_ipkgExecVerbosity ); | 209 | m_config->writeEntry( "Verbosity", m_ipkgExecVerbosity ); |
208 | } | 210 | } |
209 | } | 211 | } |
210 | 212 | ||
211 | OPackageList *OIpkg::availablePackages( const QString &server ) | 213 | OPackageList *OIpkg::availablePackages( const QString &server ) |
212 | { | 214 | { |
213 | // Load Ipkg configuration info if not already cached | 215 | // Load Ipkg configuration info if not already cached |
214 | if ( !m_confInfo ) | 216 | if ( !m_confInfo ) |
215 | loadConfiguration(); | 217 | loadConfiguration(); |
216 | 218 | ||
217 | // Build new server list (caller is responsible for deleting) | 219 | // Build new server list (caller is responsible for deleting) |
218 | OPackageList *pl = new OPackageList; | 220 | OPackageList *pl = new OPackageList; |
219 | 221 | ||
220 | // Open package list file | 222 | // Open package list file |
221 | QFile f( IPKG_PKG_PATH + "/" + server ); | 223 | QFile f( IPKG_PKG_PATH + "/" + server ); |
222 | if ( !f.open( IO_ReadOnly ) ) | 224 | if ( !f.open( IO_ReadOnly ) ) |
223 | return NULL; | 225 | return NULL; |
224 | QTextStream t( &f ); | 226 | QTextStream t( &f ); |
225 | 227 | ||
226 | // Process all information in package list file | 228 | // Process all information in package list file |
227 | OPackage *package = NULL; | 229 | OPackage *package = NULL; |
228 | QString line = t.readLine(); | 230 | QString line = t.readLine(); |
229 | while ( !t.eof() ) | 231 | while ( !t.eof() ) |
230 | { | 232 | { |
231 | // Determine key/value pair | 233 | // Determine key/value pair |
232 | int pos = line.find( ':', 0 ); | 234 | int pos = line.find( ':', 0 ); |
233 | QString key; | 235 | QString key; |
234 | if ( pos > -1 ) | 236 | if ( pos > -1 ) |
235 | key = line.mid( 0, pos ); | 237 | key = line.mid( 0, pos ); |
236 | else | 238 | else |
237 | key = QString::null; | 239 | key = QString::null; |
238 | QString value = line.mid( pos+2, line.length()-pos ); | 240 | QString value = line.mid( pos+2, line.length()-pos ); |
239 | 241 | ||
240 | // Allocate new package and insert into list | 242 | // Allocate new package and insert into list |
241 | if ( package == NULL && !key.isEmpty() ) | 243 | if ( package == NULL && !key.isEmpty() ) |
242 | { | 244 | { |
243 | package = new OPackage( value ); | 245 | package = new OPackage( value ); |
244 | package->setSource( server ); | 246 | package->setSource( server ); |
245 | pl->append( package ); | 247 | pl->append( package ); |
246 | } | 248 | } |
247 | 249 | ||
248 | // Update package data | 250 | // Update package data |
249 | if ( key == "Package" ) | 251 | if ( key == "Package" ) |
250 | package->setName( value ); | 252 | package->setName( value ); |
251 | else if ( key == "Version" ) | 253 | else if ( key == "Version" ) |
252 | package->setVersion( value ); | 254 | package->setVersion( value ); |
253 | else if ( key == "Section" ) | 255 | else if ( key == "Section" ) |
254 | package->setCategory( value ); | 256 | package->setCategory( value ); |
255 | //DataManager::setAvailableCategories( value ); | 257 | //DataManager::setAvailableCategories( value ); |
256 | else if ( key.isEmpty() && value.isEmpty() ) | 258 | else if ( key.isEmpty() && value.isEmpty() ) |
257 | package = NULL; | 259 | package = NULL; |
258 | 260 | ||
259 | // Skip past all description lines | 261 | // Skip past all description lines |
260 | if ( key == "Description" ) | 262 | if ( key == "Description" ) |
261 | { | 263 | { |
262 | line = t.readLine(); | 264 | line = t.readLine(); |
263 | while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) | 265 | while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) |
264 | line = t.readLine(); | 266 | line = t.readLine(); |
265 | } | 267 | } |
266 | else | 268 | else |
267 | line = t.readLine(); | 269 | line = t.readLine(); |
268 | } | 270 | } |
269 | 271 | ||
270 | f.close(); | 272 | f.close(); |
271 | 273 | ||
272 | return pl; | 274 | return pl; |
273 | } | 275 | } |
274 | 276 | ||
275 | OPackageList *OIpkg::installedPackages( const QString &destName, const QString &destPath ) | 277 | OPackageList *OIpkg::installedPackages( const QString &destName, const QString &destPath ) |
276 | { | 278 | { |
277 | // Load Ipkg configuration info if not already cached | 279 | // Load Ipkg configuration info if not already cached |
278 | if ( !m_confInfo ) | 280 | if ( !m_confInfo ) |
279 | loadConfiguration(); | 281 | loadConfiguration(); |
280 | 282 | ||
281 | // Build new server list (caller is responsible for deleting) | 283 | // Build new server list (caller is responsible for deleting) |
282 | OPackageList *pl = new OPackageList; | 284 | OPackageList *pl = new OPackageList; |
283 | 285 | ||
284 | // Open status file | 286 | // Open status file |
285 | QString path = destPath; | 287 | QString path = destPath; |
286 | if ( path.right( 1 ) != "/" ) | 288 | if ( path.right( 1 ) != "/" ) |
287 | path.append( "/" ); | 289 | path.append( "/" ); |
288 | path.append( IPKG_STATUS_PATH ); | 290 | path.append( IPKG_STATUS_PATH ); |
289 | 291 | ||
290 | QFile f( path ); | 292 | QFile f( path ); |
291 | if ( !f.open( IO_ReadOnly ) ) | 293 | if ( !f.open( IO_ReadOnly ) ) |
292 | return NULL; | 294 | return NULL; |
293 | QTextStream t( &f ); | 295 | QTextStream t( &f ); |
294 | 296 | ||
295 | // Process all information in status file | 297 | // Process all information in status file |
296 | bool newPackage = false; | 298 | bool newPackage = false; |
297 | QString line = t.readLine(); | 299 | QString line = t.readLine(); |
298 | QString name; | 300 | QString name; |
299 | QString version; | 301 | QString version; |
300 | QString status; | 302 | QString status; |
301 | 303 | ||
302 | while ( !t.eof() ) | 304 | while ( !t.eof() ) |
303 | { | 305 | { |
304 | // Determine key/value pair | 306 | // Determine key/value pair |
305 | int pos = line.find( ':', 0 ); | 307 | int pos = line.find( ':', 0 ); |
306 | QString key; | 308 | QString key; |
307 | if ( pos > -1 ) | 309 | if ( pos > -1 ) |
308 | key = line.mid( 0, pos ); | 310 | key = line.mid( 0, pos ); |
309 | else | 311 | else |
310 | key = QString::null; | 312 | key = QString::null; |
311 | QString value = line.mid( pos+2, line.length()-pos ); | 313 | QString value = line.mid( pos+2, line.length()-pos ); |
312 | 314 | ||
313 | // Allocate new package and insert into list | 315 | // Allocate new package and insert into list |
314 | if ( newPackage && !key.isEmpty() ) | 316 | if ( newPackage && !key.isEmpty() ) |
315 | { | 317 | { |
316 | // Add to list only if it has a valid name and is installed | 318 | // Add to list only if it has a valid name and is installed |
317 | if ( !name.isNull() && status.contains( " installed" ) ) | 319 | if ( !name.isNull() && status.contains( " installed" ) ) |
318 | { | 320 | { |
319 | pl->append( new OPackage( name, QString::null, version, QString::null, destName ) ); | 321 | pl->append( new OPackage( name, QString::null, version, QString::null, destName ) ); |
320 | name = QString::null; | 322 | name = QString::null; |
321 | version = QString::null; | 323 | version = QString::null; |
322 | status = QString::null; | 324 | status = QString::null; |
323 | 325 | ||
324 | newPackage = false; | 326 | newPackage = false; |
325 | } | 327 | } |
326 | } | 328 | } |
327 | 329 | ||
328 | // Update package data | 330 | // Update package data |
329 | if ( key == "Package" ) | 331 | if ( key == "Package" ) |
330 | name = value; | 332 | name = value; |
331 | else if ( key == "Version" ) | 333 | else if ( key == "Version" ) |
332 | version = value; | 334 | version = value; |
333 | else if ( key == "Status" ) | 335 | else if ( key == "Status" ) |
334 | status = value; | 336 | status = value; |
335 | else if ( key.isEmpty() && value.isEmpty() ) | 337 | else if ( key.isEmpty() && value.isEmpty() ) |
336 | newPackage = true; | 338 | newPackage = true; |
337 | 339 | ||
338 | // Skip past all description lines | 340 | // Skip past all description lines |
339 | if ( key == "Description" ) | 341 | if ( key == "Description" ) |
340 | { | 342 | { |
341 | line = t.readLine(); | 343 | line = t.readLine(); |
342 | while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) | 344 | while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) |
343 | line = t.readLine(); | 345 | line = t.readLine(); |
344 | } | 346 | } |
345 | else | 347 | else |
346 | line = t.readLine(); | 348 | line = t.readLine(); |
347 | } | 349 | } |
348 | 350 | ||
349 | f.close(); | 351 | f.close(); |
350 | 352 | ||
351 | return pl; | 353 | return pl; |
352 | } | 354 | } |
353 | 355 | ||
354 | bool OIpkg::executeCommand( OPackage::Command command, QStringList *parameters, const QString &destination, | 356 | bool OIpkg::executeCommand( OPackage::Command command, QStringList *parameters, const QString &destination, |
355 | const QObject *receiver, const char *slotOutput, bool rawOutput ) | 357 | const QObject *receiver, const char *slotOutput, bool rawOutput ) |
356 | { | 358 | { |
357 | if ( command == OPackage::NotDefined ) | 359 | if ( command == OPackage::NotDefined ) |
358 | return false; | 360 | return false; |
359 | 361 | ||
360 | // Set ipkg run-time options/arguments | 362 | // Set ipkg run-time options/arguments |
361 | m_ipkgArgs.force_depends = ( m_ipkgExecOptions & FORCE_DEPENDS ); | 363 | m_ipkgArgs.force_depends = ( m_ipkgExecOptions & FORCE_DEPENDS ); |
362 | m_ipkgArgs.force_reinstall = ( m_ipkgExecOptions & FORCE_REINSTALL ); | 364 | m_ipkgArgs.force_reinstall = ( m_ipkgExecOptions & FORCE_REINSTALL ); |
363 | // TODO m_ipkgArgs.force_remove = ( m_ipkgExecOptions & FORCE_REMOVE ); | 365 | // TODO m_ipkgArgs.force_remove = ( m_ipkgExecOptions & FORCE_REMOVE ); |
364 | m_ipkgArgs.force_overwrite = ( m_ipkgExecOptions & FORCE_OVERWRITE ); | 366 | m_ipkgArgs.force_overwrite = ( m_ipkgExecOptions & FORCE_OVERWRITE ); |
365 | m_ipkgArgs.verbosity = m_ipkgExecVerbosity; | 367 | m_ipkgArgs.verbosity = m_ipkgExecVerbosity; |
366 | if ( m_ipkgArgs.dest ) | 368 | if ( m_ipkgArgs.dest ) |
367 | free( m_ipkgArgs.dest ); | 369 | free( m_ipkgArgs.dest ); |
368 | if ( !destination.isNull() ) | 370 | if ( !destination.isNull() ) |
369 | { | 371 | { |
370 | int len = destination.length() + 1; | 372 | int len = destination.length() + 1; |
371 | m_ipkgArgs.dest = (char *)malloc( len ); | 373 | m_ipkgArgs.dest = (char *)malloc( len ); |
372 | strncpy( m_ipkgArgs.dest, destination, destination.length() ); | 374 | strncpy( m_ipkgArgs.dest, destination, destination.length() ); |
373 | m_ipkgArgs.dest[ len - 1 ] = '\0'; | 375 | m_ipkgArgs.dest[ len - 1 ] = '\0'; |
374 | } | 376 | } |
375 | else | 377 | else |
376 | m_ipkgArgs.dest = 0x0; | 378 | m_ipkgArgs.dest = 0x0; |
377 | 379 | ||
378 | // Connect output signal to widget | 380 | // Connect output signal to widget |
379 | 381 | ||
380 | if ( rawOutput ) | 382 | if ( rawOutput ) |
381 | { | 383 | { |
382 | // if ( slotOutput ) | 384 | // if ( slotOutput ) |
383 | // connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); | 385 | // connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); |
384 | } | 386 | } |
385 | else | 387 | else |
386 | { | 388 | { |
387 | // TODO - connect to local slot and parse output before emitting signalIpkgMessage | 389 | // TODO - connect to local slot and parse output before emitting signalIpkgMessage |
388 | } | 390 | } |
389 | 391 | ||
390 | switch( command ) | 392 | switch( command ) |
391 | { | 393 | { |
392 | case OPackage::Update : { | 394 | case OPackage::Update : { |
393 | connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); | 395 | connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); |
394 | ipkg_lists_update( &m_ipkgArgs ); | 396 | ipkg_lists_update( &m_ipkgArgs ); |
395 | }; | 397 | }; |
396 | break; | 398 | break; |
397 | case OPackage::Upgrade : { | 399 | case OPackage::Upgrade : { |
398 | connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); | 400 | connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); |
399 | ipkg_packages_upgrade( &m_ipkgArgs ); | 401 | ipkg_packages_upgrade( &m_ipkgArgs ); |
400 | }; | 402 | }; |
401 | break; | 403 | break; |
402 | case OPackage::Install : { | 404 | case OPackage::Install : { |
403 | connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); | 405 | connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); |
404 | for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) | 406 | for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) |
405 | { | 407 | { |
406 | ipkg_packages_install( &m_ipkgArgs, (*it) ); | 408 | ipkg_packages_install( &m_ipkgArgs, (*it) ); |
407 | } | 409 | } |
408 | }; | 410 | }; |
409 | break; | 411 | break; |
410 | case OPackage::Remove : { | 412 | case OPackage::Remove : { |
411 | connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); | 413 | connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); |
412 | for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) | 414 | for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) |
413 | { | 415 | { |
414 | ipkg_packages_remove( &m_ipkgArgs, (*it), true ); | 416 | ipkg_packages_remove( &m_ipkgArgs, (*it), true ); |
415 | } | 417 | } |
416 | }; | 418 | }; |
417 | break; | 419 | break; |
418 | case OPackage::Download : { | 420 | case OPackage::Download : { |
419 | connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); | 421 | connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); |
420 | for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) | 422 | for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) |
421 | { | 423 | { |
422 | ipkg_packages_download( &m_ipkgArgs, (*it) ); | 424 | ipkg_packages_download( &m_ipkgArgs, (*it) ); |
423 | } | 425 | } |
424 | }; | 426 | }; |
425 | break; | 427 | break; |
426 | case OPackage::Info : { | 428 | case OPackage::Info : { |
427 | connect( this, SIGNAL(signalIpkgStatus(char*)), receiver, slotOutput ); | 429 | connect( this, SIGNAL(signalIpkgStatus(char*)), receiver, slotOutput ); |
428 | ipkg_packages_info( &m_ipkgArgs, (*parameters->begin()), &fIpkgStatus, 0x0 ); | 430 | ipkg_packages_info( &m_ipkgArgs, (*parameters->begin()), &fIpkgStatus, 0x0 ); |
429 | }; | 431 | }; |
430 | break; | 432 | break; |
431 | case OPackage::Files : { | 433 | case OPackage::Files : { |
432 | connect( this, SIGNAL(signalIpkgList(char*)), receiver, slotOutput ); | 434 | connect( this, SIGNAL(signalIpkgList(char*)), receiver, slotOutput ); |
433 | ipkg_package_files( &m_ipkgArgs, (*parameters->begin()), &fIpkgFiles, 0x0 ); | 435 | ipkg_package_files( &m_ipkgArgs, (*parameters->begin()), &fIpkgFiles, 0x0 ); |
434 | }; | 436 | }; |
435 | break; | 437 | break; |
436 | default : break; | 438 | default : break; |