summaryrefslogtreecommitdiff
authordrw <drw>2005-04-01 20:32:01 (UTC)
committer drw <drw>2005-04-01 20:32:01 (UTC)
commitcc4594a5c8d45d2f8d14c6ac1723a8ed39577f8f (patch) (unidiff)
tree3500347a14f4106be68712c4d4af49e3c69f7248
parent629c1c9a366f56e9d98940f8dcd0778d039f1421 (diff)
downloadopie-cc4594a5c8d45d2f8d14c6ac1723a8ed39577f8f.zip
opie-cc4594a5c8d45d2f8d14c6ac1723a8ed39577f8f.tar.gz
opie-cc4594a5c8d45d2f8d14c6ac1723a8ed39577f8f.tar.bz2
Fix linking issue with libipkg >= 0.99.146, at least until I can come up with a better way to do it...
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/packagemanager/oipkg.cpp5
-rw-r--r--noncore/settings/packagemanager/oipkg.h7
2 files changed, 6 insertions, 6 deletions
diff --git a/noncore/settings/packagemanager/oipkg.cpp b/noncore/settings/packagemanager/oipkg.cpp
index 127204d..7bc2040 100644
--- a/noncore/settings/packagemanager/oipkg.cpp
+++ b/noncore/settings/packagemanager/oipkg.cpp
@@ -1,813 +1,818 @@
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#include <unistd.h> 39#include <unistd.h>
40 40
41extern "C" {
42#include <libipkg.h>
43};
44args_t m_ipkgArgs; // libipkg configuration arguments
45
41const QString IPKG_CONF = "/etc/ipkg.conf"; // Fully-qualified name of Ipkg primary configuration file 46const QString IPKG_CONF = "/etc/ipkg.conf"; // Fully-qualified name of Ipkg primary configuration file
42const QString IPKG_CONF_DIR = "/etc/ipkg"; // Directory of secondary Ipkg configuration files 47const QString IPKG_CONF_DIR = "/etc/ipkg"; // Directory of secondary Ipkg configuration files
43const QString IPKG_PKG_PATH = "/usr/lib/ipkg/lists"; // Directory containing server package lists 48const QString IPKG_PKG_PATH = "/usr/lib/ipkg/lists"; // Directory containing server package lists
44const QString IPKG_STATUS_PATH = "usr/lib/ipkg/status"; // Destination status file location 49const QString IPKG_STATUS_PATH = "usr/lib/ipkg/status"; // Destination status file location
45const QString IPKG_INFO_PATH = "usr/lib/ipkg/info"; // Package file lists location 50const QString IPKG_INFO_PATH = "usr/lib/ipkg/info"; // Package file lists location
46 51
47OIpkg *oipkg; 52OIpkg *oipkg;
48 53
49// Ipkg callback functions 54// Ipkg callback functions
50 55
51int fsignalIpkgMessage( ipkg_conf_t *conf, message_level_t level, char *msg ) 56int fsignalIpkgMessage( ipkg_conf_t *conf, message_level_t level, char *msg )
52{ 57{
53 // Display message only if it is below the message level threshold 58 // Display message only if it is below the message level threshold
54 if ( conf && ( conf->verbosity < level ) ) 59 if ( conf && ( conf->verbosity < level ) )
55 return 0; 60 return 0;
56 else 61 else
57 oipkg->ipkgMessage( msg ); 62 oipkg->ipkgMessage( msg );
58 63
59 return 0; 64 return 0;
60} 65}
61 66
62char *fIpkgResponse( char */*question*/ ) 67char *fIpkgResponse( char */*question*/ )
63{ 68{
64 return 0l; 69 return 0l;
65} 70}
66 71
67int fIpkgStatus( char */*name*/, int /*status*/, char *desc, void */*userdata*/ ) 72int fIpkgStatus( char */*name*/, int /*status*/, char *desc, void */*userdata*/ )
68{ 73{
69 oipkg->ipkgStatus( desc ); 74 oipkg->ipkgStatus( desc );
70 return 0; 75 return 0;
71} 76}
72 77
73int fIpkgFiles( char */*name*/, char *desc, char */*version*/, pkg_state_status_t /*status*/, 78int fIpkgFiles( char */*name*/, char *desc, char */*version*/, pkg_state_status_t /*status*/,
74 void */*userdata*/ ) 79 void */*userdata*/ )
75{ 80{
76 oipkg->ipkgList( desc ); 81 oipkg->ipkgList( desc );
77 return 0; 82 return 0;
78} 83}
79 84
80OIpkg::OIpkg( Config *config, QObject *parent, const char *name ) 85OIpkg::OIpkg( Config *config, QObject *parent, const char *name )
81 : QObject( parent, name ) 86 : QObject( parent, name )
82 , m_config( config ) 87 , m_config( config )
83 , m_confInfo( NULL ) 88 , m_confInfo( NULL )
84 , m_ipkgExecOptions( 0 ) 89 , m_ipkgExecOptions( 0 )
85 , m_ipkgExecVerbosity( 1 ) 90 , m_ipkgExecVerbosity( 1 )
86{ 91{
87 // Keep pointer to self for the Ipkg callback functions 92 // Keep pointer to self for the Ipkg callback functions
88 oipkg = this; 93 oipkg = this;
89 94
90 // Initialize libipkg 95 // Initialize libipkg
91 ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ); 96 ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs );
92 97
93 // Default ipkg run-time arguments 98 // Default ipkg run-time arguments
94 m_ipkgArgs.noaction = false; 99 m_ipkgArgs.noaction = false;
95 m_ipkgArgs.force_defaults = true; 100 m_ipkgArgs.force_defaults = true;
96} 101}
97 102
98OIpkg::~OIpkg() 103OIpkg::~OIpkg()
99{ 104{
100 // Upon destruction, ensure that items in config list are deleted with list 105 // Upon destruction, ensure that items in config list are deleted with list
101 if ( m_confInfo ) 106 if ( m_confInfo )
102 m_confInfo->setAutoDelete( true ); 107 m_confInfo->setAutoDelete( true );
103 108
104 // Free up libipkg resources 109 // Free up libipkg resources
105 ipkg_deinit( &m_ipkgArgs ); 110 ipkg_deinit( &m_ipkgArgs );
106} 111}
107 112
108OConfItemList *OIpkg::configItems() 113OConfItemList *OIpkg::configItems()
109{ 114{
110 // Retrieve all configuration items 115 // Retrieve all configuration items
111 return filterConfItems(); 116 return filterConfItems();
112} 117}
113 118
114OConfItemList *OIpkg::servers() 119OConfItemList *OIpkg::servers()
115{ 120{
116 // Retrieve only servers 121 // Retrieve only servers
117 return filterConfItems( OConfItem::Source ); 122 return filterConfItems( OConfItem::Source );
118} 123}
119 124
120OConfItemList *OIpkg::destinations() 125OConfItemList *OIpkg::destinations()
121{ 126{
122 // Retrieve only destinations 127 // Retrieve only destinations
123 return filterConfItems( OConfItem::Destination ); 128 return filterConfItems( OConfItem::Destination );
124} 129}
125 130
126OConfItemList *OIpkg::options() 131OConfItemList *OIpkg::options()
127{ 132{
128 // Retrieve only destinations 133 // Retrieve only destinations
129 return filterConfItems( OConfItem::Option ); 134 return filterConfItems( OConfItem::Option );
130} 135}
131 136
132void OIpkg::setConfigItems( OConfItemList *configList ) 137void OIpkg::setConfigItems( OConfItemList *configList )
133{ 138{
134 if ( m_confInfo ) 139 if ( m_confInfo )
135 delete m_confInfo; 140 delete m_confInfo;
136 141
137 m_confInfo = configList; 142 m_confInfo = configList;
138 143
139 // Write out new /etc/ipkg.conf 144 // Write out new /etc/ipkg.conf
140 QFile confFile( IPKG_CONF ); 145 QFile confFile( IPKG_CONF );
141 if ( confFile.open( IO_WriteOnly ) ) 146 if ( confFile.open( IO_WriteOnly ) )
142 { 147 {
143 QTextStream confStream( &confFile ); 148 QTextStream confStream( &confFile );
144 confStream << "# Generated by Opie Package Manager\n\n"; 149 confStream << "# Generated by Opie Package Manager\n\n";
145 150
146 OConfItemListIterator it( *m_confInfo ); 151 OConfItemListIterator it( *m_confInfo );
147 for ( ; it.current(); ++it ) 152 for ( ; it.current(); ++it )
148 { 153 {
149 OConfItem *item = it.current(); 154 OConfItem *item = it.current();
150 155
151 // Only write out valid conf items 156 // Only write out valid conf items
152 if ( item->type() != OConfItem::NotDefined ) 157 if ( item->type() != OConfItem::NotDefined )
153 { 158 {
154 QString confLine; 159 QString confLine;
155 QString name = item->name(); 160 QString name = item->name();
156 if ( !item->active() ) 161 if ( !item->active() )
157 confLine = "#"; 162 confLine = "#";
158 163
159 switch ( item->type() ) 164 switch ( item->type() )
160 { 165 {
161 case OConfItem::Source : 166 case OConfItem::Source :
162 { 167 {
163 if ( item->features().contains( "Compressed" ) ) 168 if ( item->features().contains( "Compressed" ) )
164 confLine.append( "src/gz" ); 169 confLine.append( "src/gz" );
165 else 170 else
166 confLine.append( "src" ); 171 confLine.append( "src" );
167 } 172 }
168 break; 173 break;
169 case OConfItem::Destination : confLine.append( "dest" ); break; 174 case OConfItem::Destination : confLine.append( "dest" ); break;
170 case OConfItem::Option : confLine.append( "option" ); break; 175 case OConfItem::Option : confLine.append( "option" ); break;
171 case OConfItem::Arch : confLine.append( "arch" ); break; 176 case OConfItem::Arch : confLine.append( "arch" ); break;
172 case OConfItem::Other : 177 case OConfItem::Other :
173 { 178 {
174 // For options w/type = Other, the mapping is as follows: 179 // For options w/type = Other, the mapping is as follows:
175 // name = typeStr (e.g. "lists_dir") 180 // name = typeStr (e.g. "lists_dir")
176 // value = value 181 // value = value
177 // features = name (from configuration file) 182 // features = name (from configuration file)
178 confLine.append( item->name() ); 183 confLine.append( item->name() );
179 name = item->features(); 184 name = item->features();
180 } 185 }
181 break; 186 break;
182 default : break; 187 default : break;
183 }; 188 };
184 189
185 confStream << confLine << " " << name << " " << item->value() << "\n"; 190 confStream << confLine << " " << name << " " << item->value() << "\n";
186 } 191 }
187 } 192 }
188 193
189 confFile.close(); 194 confFile.close();
190 } 195 }
191 else 196 else
192 { 197 {
193 // Problem writing to /etc/ipkg.conf, exit before removing other conf files 198 // Problem writing to /etc/ipkg.conf, exit before removing other conf files
194 return; 199 return;
195 } 200 }
196 201
197 // Delete /etc/ipkg/*.conf files (/etc/ipkg.conf should now have all settings 202 // Delete /etc/ipkg/*.conf files (/etc/ipkg.conf should now have all settings
198 QStringList confFiles; 203 QStringList confFiles;
199 QDir confDir( IPKG_CONF_DIR ); 204 QDir confDir( IPKG_CONF_DIR );
200 if ( confDir.exists() ) 205 if ( confDir.exists() )
201 { 206 {
202 confDir.setNameFilter( "*.conf" ); 207 confDir.setNameFilter( "*.conf" );
203 confDir.setFilter( QDir::Files ); 208 confDir.setFilter( QDir::Files );
204 confFiles = confDir.entryList( "*.conf", QDir::Files ); 209 confFiles = confDir.entryList( "*.conf", QDir::Files );
205 210
206 QStringList::Iterator lastFile = confFiles.end(); 211 QStringList::Iterator lastFile = confFiles.end();
207 for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it ) 212 for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it )
208 { 213 {
209 // Create absolute file path if necessary 214 // Create absolute file path if necessary
210 QString absFile = (*it); 215 QString absFile = (*it);
211 if ( !absFile.startsWith( "/" ) ) 216 if ( !absFile.startsWith( "/" ) )
212 absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); 217 absFile.prepend( QString( IPKG_CONF_DIR ) + "/" );
213 218
214 // Delete file 219 // Delete file
215 QFile::remove( absFile ); 220 QFile::remove( absFile );
216 } 221 }
217 } 222 }
218 223
219 // Reinitialize libipkg to pick up new configuration 224 // Reinitialize libipkg to pick up new configuration
220 ipkg_deinit( &m_ipkgArgs ); 225 ipkg_deinit( &m_ipkgArgs );
221 ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ); 226 ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs );
222 m_ipkgArgs.noaction = false; 227 m_ipkgArgs.noaction = false;
223 m_ipkgArgs.force_defaults = true; 228 m_ipkgArgs.force_defaults = true;
224} 229}
225 230
226void OIpkg::saveSettings() 231void OIpkg::saveSettings()
227{ 232{
228 // Save Ipkg execution options to application configuration file 233 // Save Ipkg execution options to application configuration file
229 if ( m_config ) 234 if ( m_config )
230 { 235 {
231 m_config->setGroup( "Ipkg" ); 236 m_config->setGroup( "Ipkg" );
232 m_config->writeEntry( "ExecOptions", m_ipkgExecOptions ); 237 m_config->writeEntry( "ExecOptions", m_ipkgExecOptions );
233 m_config->writeEntry( "Verbosity", m_ipkgExecVerbosity ); 238 m_config->writeEntry( "Verbosity", m_ipkgExecVerbosity );
234 } 239 }
235} 240}
236 241
237OPackageList *OIpkg::availablePackages( const QString &server ) 242OPackageList *OIpkg::availablePackages( const QString &server )
238{ 243{
239 // Load Ipkg configuration info if not already cached 244 // Load Ipkg configuration info if not already cached
240 if ( !m_confInfo ) 245 if ( !m_confInfo )
241 loadConfiguration(); 246 loadConfiguration();
242 247
243 // Build new server list (caller is responsible for deleting) 248 // Build new server list (caller is responsible for deleting)
244 OPackageList *pl = new OPackageList; 249 OPackageList *pl = new OPackageList;
245 250
246 // Get directory where server lists are located 251 // Get directory where server lists are located
247 QString listsDir; 252 QString listsDir;
248 OConfItem *confItem = findConfItem( OConfItem::Other, "lists_dir" ); 253 OConfItem *confItem = findConfItem( OConfItem::Other, "lists_dir" );
249 if ( confItem ) 254 if ( confItem )
250 listsDir = confItem->value(); 255 listsDir = confItem->value();
251 else 256 else
252 listsDir = IPKG_PKG_PATH; 257 listsDir = IPKG_PKG_PATH;
253 258
254 // Open package list file 259 // Open package list file
255 QFile f( listsDir + "/" + server ); 260 QFile f( listsDir + "/" + server );
256 if ( !f.open( IO_ReadOnly ) ) 261 if ( !f.open( IO_ReadOnly ) )
257 return NULL; 262 return NULL;
258 QTextStream t( &f ); 263 QTextStream t( &f );
259 264
260 // Process all information in package list file 265 // Process all information in package list file
261 OPackage *package = NULL; 266 OPackage *package = NULL;
262 QString line = t.readLine(); 267 QString line = t.readLine();
263 while ( !t.eof() ) 268 while ( !t.eof() )
264 { 269 {
265 // Determine key/value pair 270 // Determine key/value pair
266 int pos = line.find( ':', 0 ); 271 int pos = line.find( ':', 0 );
267 QString key; 272 QString key;
268 if ( pos > -1 ) 273 if ( pos > -1 )
269 key = line.mid( 0, pos ); 274 key = line.mid( 0, pos );
270 else 275 else
271 key = QString::null; 276 key = QString::null;
272 QString value = line.mid( pos+2, line.length()-pos ); 277 QString value = line.mid( pos+2, line.length()-pos );
273 278
274 // Allocate new package and insert into list 279 // Allocate new package and insert into list
275 if ( package == NULL && !key.isEmpty() ) 280 if ( package == NULL && !key.isEmpty() )
276 { 281 {
277 package = new OPackage( value ); 282 package = new OPackage( value );
278 package->setSource( server ); 283 package->setSource( server );
279 pl->append( package ); 284 pl->append( package );
280 } 285 }
281 286
282 // Update package data 287 // Update package data
283 if ( key == "Package" ) 288 if ( key == "Package" )
284 package->setName( value ); 289 package->setName( value );
285 else if ( key == "Version" ) 290 else if ( key == "Version" )
286 package->setVersion( value ); 291 package->setVersion( value );
287 else if ( key == "Section" ) 292 else if ( key == "Section" )
288 package->setCategory( value ); 293 package->setCategory( value );
289 //DataManager::setAvailableCategories( value ); 294 //DataManager::setAvailableCategories( value );
290 else if ( key.isEmpty() && value.isEmpty() ) 295 else if ( key.isEmpty() && value.isEmpty() )
291 package = NULL; 296 package = NULL;
292 297
293 // Skip past all description lines 298 // Skip past all description lines
294 if ( key == "Description" ) 299 if ( key == "Description" )
295 { 300 {
296 line = t.readLine(); 301 line = t.readLine();
297 while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) 302 while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() )
298 line = t.readLine(); 303 line = t.readLine();
299 } 304 }
300 else 305 else
301 line = t.readLine(); 306 line = t.readLine();
302 } 307 }
303 308
304 f.close(); 309 f.close();
305 310
306 return pl; 311 return pl;
307} 312}
308 313
309OPackageList *OIpkg::installedPackages( const QString &destName, const QString &destPath ) 314OPackageList *OIpkg::installedPackages( const QString &destName, const QString &destPath )
310{ 315{
311 // Load Ipkg configuration info if not already cached 316 // Load Ipkg configuration info if not already cached
312 if ( !m_confInfo ) 317 if ( !m_confInfo )
313 loadConfiguration(); 318 loadConfiguration();
314 319
315 // Build new server list (caller is responsible for deleting) 320 // Build new server list (caller is responsible for deleting)
316 OPackageList *pl = new OPackageList; 321 OPackageList *pl = new OPackageList;
317 322
318 // Open status file 323 // Open status file
319 QString path = destPath; 324 QString path = destPath;
320 if ( path.right( 1 ) != "/" ) 325 if ( path.right( 1 ) != "/" )
321 path.append( "/" ); 326 path.append( "/" );
322 path.append( IPKG_STATUS_PATH ); 327 path.append( IPKG_STATUS_PATH );
323 328
324 QFile f( path ); 329 QFile f( path );
325 if ( !f.open( IO_ReadOnly ) ) 330 if ( !f.open( IO_ReadOnly ) )
326 return NULL; 331 return NULL;
327 QTextStream t( &f ); 332 QTextStream t( &f );
328 333
329 // Process all information in status file 334 // Process all information in status file
330 bool newPackage = false; 335 bool newPackage = false;
331 QString line = t.readLine(); 336 QString line = t.readLine();
332 QString name; 337 QString name;
333 QString version; 338 QString version;
334 QString status; 339 QString status;
335 340
336 while ( !t.eof() ) 341 while ( !t.eof() )
337 { 342 {
338 // Determine key/value pair 343 // Determine key/value pair
339 int pos = line.find( ':', 0 ); 344 int pos = line.find( ':', 0 );
340 QString key; 345 QString key;
341 if ( pos > -1 ) 346 if ( pos > -1 )
342 key = line.mid( 0, pos ); 347 key = line.mid( 0, pos );
343 else 348 else
344 key = QString::null; 349 key = QString::null;
345 QString value = line.mid( pos+2, line.length()-pos ); 350 QString value = line.mid( pos+2, line.length()-pos );
346 351
347 // Allocate new package and insert into list 352 // Allocate new package and insert into list
348 if ( newPackage && !key.isEmpty() ) 353 if ( newPackage && !key.isEmpty() )
349 { 354 {
350 // Add to list only if it has a valid name and is installed 355 // Add to list only if it has a valid name and is installed
351 if ( !name.isNull() && status.contains( " installed" ) ) 356 if ( !name.isNull() && status.contains( " installed" ) )
352 { 357 {
353 pl->append( new OPackage( name, QString::null, version, QString::null, destName ) ); 358 pl->append( new OPackage( name, QString::null, version, QString::null, destName ) );
354 name = QString::null; 359 name = QString::null;
355 version = QString::null; 360 version = QString::null;
356 status = QString::null; 361 status = QString::null;
357 362
358 newPackage = false; 363 newPackage = false;
359 } 364 }
360 } 365 }
361 366
362 // Update package data 367 // Update package data
363 if ( key == "Package" ) 368 if ( key == "Package" )
364 name = value; 369 name = value;
365 else if ( key == "Version" ) 370 else if ( key == "Version" )
366 version = value; 371 version = value;
367 else if ( key == "Status" ) 372 else if ( key == "Status" )
368 status = value; 373 status = value;
369 else if ( key.isEmpty() && value.isEmpty() ) 374 else if ( key.isEmpty() && value.isEmpty() )
370 newPackage = true; 375 newPackage = true;
371 376
372 // Skip past all description lines 377 // Skip past all description lines
373 if ( key == "Description" ) 378 if ( key == "Description" )
374 { 379 {
375 line = t.readLine(); 380 line = t.readLine();
376 while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) 381 while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() )
377 line = t.readLine(); 382 line = t.readLine();
378 } 383 }
379 else 384 else
380 line = t.readLine(); 385 line = t.readLine();
381 } 386 }
382 387
383 f.close(); 388 f.close();
384 389
385 // Make sure to add to list last entry 390 // Make sure to add to list last entry
386 if ( !name.isNull() && status.contains( " installed" ) ) 391 if ( !name.isNull() && status.contains( " installed" ) )
387 pl->append( new OPackage( name, QString::null, version, QString::null, destName ) ); 392 pl->append( new OPackage( name, QString::null, version, QString::null, destName ) );
388 393
389 return pl; 394 return pl;
390} 395}
391 396
392OConfItem *OIpkg::findConfItem( OConfItem::Type type, const QString &name ) 397OConfItem *OIpkg::findConfItem( OConfItem::Type type, const QString &name )
393{ 398{
394 // Find configuration item in list 399 // Find configuration item in list
395 OConfItemListIterator configIt( *m_confInfo ); 400 OConfItemListIterator configIt( *m_confInfo );
396 OConfItem *config = 0l; 401 OConfItem *config = 0l;
397 for ( ; configIt.current(); ++configIt ) 402 for ( ; configIt.current(); ++configIt )
398 { 403 {
399 config = configIt.current(); 404 config = configIt.current();
400 if ( config->type() == type && config->name() == name ) 405 if ( config->type() == type && config->name() == name )
401 break; 406 break;
402 } 407 }
403 408
404 if ( config && config->type() == type && config->name() == name ) 409 if ( config && config->type() == type && config->name() == name )
405 return config; 410 return config;
406 411
407 return 0l; 412 return 0l;
408} 413}
409 414
410bool OIpkg::executeCommand( OPackage::Command command, const QStringList &parameters, const QString &destination, 415bool OIpkg::executeCommand( OPackage::Command command, const QStringList &parameters, const QString &destination,
411 const QObject *receiver, const char *slotOutput, bool rawOutput ) 416 const QObject *receiver, const char *slotOutput, bool rawOutput )
412{ 417{
413 if ( command == OPackage::NotDefined ) 418 if ( command == OPackage::NotDefined )
414 return false; 419 return false;
415 420
416 // Set ipkg run-time options/arguments 421 // Set ipkg run-time options/arguments
417 m_ipkgArgs.force_depends = ( m_ipkgExecOptions & FORCE_DEPENDS ); 422 m_ipkgArgs.force_depends = ( m_ipkgExecOptions & FORCE_DEPENDS );
418 m_ipkgArgs.force_reinstall = ( m_ipkgExecOptions & FORCE_REINSTALL ); 423 m_ipkgArgs.force_reinstall = ( m_ipkgExecOptions & FORCE_REINSTALL );
419 // TODO m_ipkgArgs.force_remove = ( m_ipkgExecOptions & FORCE_REMOVE ); 424 // TODO m_ipkgArgs.force_remove = ( m_ipkgExecOptions & FORCE_REMOVE );
420 m_ipkgArgs.force_overwrite = ( m_ipkgExecOptions & FORCE_OVERWRITE ); 425 m_ipkgArgs.force_overwrite = ( m_ipkgExecOptions & FORCE_OVERWRITE );
421 m_ipkgArgs.verbosity = m_ipkgExecVerbosity; 426 m_ipkgArgs.verbosity = m_ipkgExecVerbosity;
422 if ( m_ipkgArgs.dest ) 427 if ( m_ipkgArgs.dest )
423 free( m_ipkgArgs.dest ); 428 free( m_ipkgArgs.dest );
424 if ( !destination.isNull() ) 429 if ( !destination.isNull() )
425 { 430 {
426 int len = destination.length() + 1; 431 int len = destination.length() + 1;
427 m_ipkgArgs.dest = (char *)malloc( len ); 432 m_ipkgArgs.dest = (char *)malloc( len );
428 strncpy( m_ipkgArgs.dest, destination, destination.length() ); 433 strncpy( m_ipkgArgs.dest, destination, destination.length() );
429 m_ipkgArgs.dest[ len - 1 ] = '\0'; 434 m_ipkgArgs.dest[ len - 1 ] = '\0';
430 } 435 }
431 else 436 else
432 m_ipkgArgs.dest = 0l; 437 m_ipkgArgs.dest = 0l;
433 438
434 // Connect output signal to widget 439 // Connect output signal to widget
435 440
436 if ( !rawOutput ) 441 if ( !rawOutput )
437 { 442 {
438 // TODO - connect to local slot and parse output before emitting signalIpkgMessage 443 // TODO - connect to local slot and parse output before emitting signalIpkgMessage
439 } 444 }
440 445
441 switch( command ) 446 switch( command )
442 { 447 {
443 case OPackage::Update : { 448 case OPackage::Update : {
444 connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); 449 connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput );
445 ipkg_lists_update( &m_ipkgArgs ); 450 ipkg_lists_update( &m_ipkgArgs );
446 disconnect( this, SIGNAL(signalIpkgMessage(const QString &)), 0, 0 ); 451 disconnect( this, SIGNAL(signalIpkgMessage(const QString &)), 0, 0 );
447 }; 452 };
448 break; 453 break;
449 case OPackage::Upgrade : { 454 case OPackage::Upgrade : {
450 connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); 455 connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput );
451 ipkg_packages_upgrade( &m_ipkgArgs ); 456 ipkg_packages_upgrade( &m_ipkgArgs );
452 457
453 // Re-link non-root destinations to make sure everything is in sync 458 // Re-link non-root destinations to make sure everything is in sync
454 OConfItemList *destList = destinations(); 459 OConfItemList *destList = destinations();
455 OConfItemListIterator it( *destList ); 460 OConfItemListIterator it( *destList );
456 for ( ; it.current(); ++it ) 461 for ( ; it.current(); ++it )
457 { 462 {
458 OConfItem *dest = it.current(); 463 OConfItem *dest = it.current();
459 if ( dest->name() != "root" ) 464 if ( dest->name() != "root" )
460 linkPackageDir( dest->name() ); 465 linkPackageDir( dest->name() );
461 } 466 }
462 delete destList; 467 delete destList;
463 disconnect( this, SIGNAL(signalIpkgMessage(const QString &)), 0, 0 ); 468 disconnect( this, SIGNAL(signalIpkgMessage(const QString &)), 0, 0 );
464 }; 469 };
465 break; 470 break;
466 case OPackage::Install : { 471 case OPackage::Install : {
467 connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); 472 connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput );
468 for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) 473 for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it )
469 { 474 {
470 ipkg_packages_install( &m_ipkgArgs, (*it) ); 475 ipkg_packages_install( &m_ipkgArgs, (*it) );
471 } 476 }
472 if ( destination != "root" ) 477 if ( destination != "root" )
473 linkPackageDir( destination ); 478 linkPackageDir( destination );
474 disconnect( this, SIGNAL(signalIpkgMessage(const QString &)), 0, 0 ); 479 disconnect( this, SIGNAL(signalIpkgMessage(const QString &)), 0, 0 );
475 }; 480 };
476 break; 481 break;
477 case OPackage::Remove : { 482 case OPackage::Remove : {
478 connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); 483 connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput );
479 484
480 // Get list of destinations for unlinking of packages not installed to root 485 // Get list of destinations for unlinking of packages not installed to root
481 OConfItemList *destList = destinations(); 486 OConfItemList *destList = destinations();
482 487
483 for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) 488 for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it )
484 { 489 {
485 unlinkPackage( (*it), destList ); 490 unlinkPackage( (*it), destList );
486 ipkg_packages_remove( &m_ipkgArgs, (*it), true ); 491 ipkg_packages_remove( &m_ipkgArgs, (*it), true );
487 } 492 }
488 493
489 delete destList; 494 delete destList;
490 disconnect( this, SIGNAL(signalIpkgMessage(const QString &)), 0, 0 ); 495 disconnect( this, SIGNAL(signalIpkgMessage(const QString &)), 0, 0 );
491 }; 496 };
492 break; 497 break;
493 case OPackage::Download : { 498 case OPackage::Download : {
494 connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput ); 499 connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput );
495 for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) 500 for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it )
496 { 501 {
497 ipkg_packages_download( &m_ipkgArgs, (*it) ); 502 ipkg_packages_download( &m_ipkgArgs, (*it) );
498 } 503 }
499 disconnect( this, SIGNAL(signalIpkgMessage(const QString &)), 0, 0 ); 504 disconnect( this, SIGNAL(signalIpkgMessage(const QString &)), 0, 0 );
500 }; 505 };
501 break; 506 break;
502 case OPackage::Info : { 507 case OPackage::Info : {
503 connect( this, SIGNAL(signalIpkgStatus(const QString &)), receiver, slotOutput ); 508 connect( this, SIGNAL(signalIpkgStatus(const QString &)), receiver, slotOutput );
504 ipkg_packages_info( &m_ipkgArgs, (*parameters.begin()), &fIpkgStatus, 0l ); 509 ipkg_packages_info( &m_ipkgArgs, (*parameters.begin()), &fIpkgStatus, 0l );
505 disconnect( this, SIGNAL(signalIpkgStatus(const QString &)), 0, 0 ); 510 disconnect( this, SIGNAL(signalIpkgStatus(const QString &)), 0, 0 );
506 }; 511 };
507 break; 512 break;
508 case OPackage::Files : { 513 case OPackage::Files : {
509 connect( this, SIGNAL(signalIpkgList(const QString &)), receiver, slotOutput ); 514 connect( this, SIGNAL(signalIpkgList(const QString &)), receiver, slotOutput );
510 ipkg_package_files( &m_ipkgArgs, (*parameters.begin()), &fIpkgFiles, 0l ); 515 ipkg_package_files( &m_ipkgArgs, (*parameters.begin()), &fIpkgFiles, 0l );
511 disconnect( this, SIGNAL(signalIpkgList(const QString &)), 0, 0 ); 516 disconnect( this, SIGNAL(signalIpkgList(const QString &)), 0, 0 );
512 }; 517 };
513 break; 518 break;
514 default : break; 519 default : break;
515 }; 520 };
516 521
517 return true; 522 return true;
518} 523}
519 524
520void OIpkg::ipkgMessage( char *msg ) 525void OIpkg::ipkgMessage( char *msg )
521{ 526{
522 emit signalIpkgMessage( msg ); 527 emit signalIpkgMessage( msg );
523} 528}
524 529
525void OIpkg::ipkgStatus( char *status ) 530void OIpkg::ipkgStatus( char *status )
526{ 531{
527 emit signalIpkgStatus( status ); 532 emit signalIpkgStatus( status );
528} 533}
529 534
530void OIpkg::ipkgList( char *filelist ) 535void OIpkg::ipkgList( char *filelist )
531{ 536{
532 emit signalIpkgList( filelist ); 537 emit signalIpkgList( filelist );
533} 538}
534 539
535void OIpkg::loadConfiguration() 540void OIpkg::loadConfiguration()
536{ 541{
537 if ( m_confInfo ) 542 if ( m_confInfo )
538 delete m_confInfo; 543 delete m_confInfo;
539 544
540 // Load configuration item list 545 // Load configuration item list
541 m_confInfo = new OConfItemList(); 546 m_confInfo = new OConfItemList();
542 547
543 QStringList confFiles; 548 QStringList confFiles;
544 QDir confDir( IPKG_CONF_DIR ); 549 QDir confDir( IPKG_CONF_DIR );
545 if ( confDir.exists() ) 550 if ( confDir.exists() )
546 { 551 {
547 confDir.setNameFilter( "*.conf" ); 552 confDir.setNameFilter( "*.conf" );
548 confDir.setFilter( QDir::Files ); 553 confDir.setFilter( QDir::Files );
549 confFiles = confDir.entryList( "*.conf", QDir::Files ); 554 confFiles = confDir.entryList( "*.conf", QDir::Files );
550 } 555 }
551 confFiles << IPKG_CONF; 556 confFiles << IPKG_CONF;
552 557
553 QStringList::Iterator lastFile = confFiles.end(); 558 QStringList::Iterator lastFile = confFiles.end();
554 for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it ) 559 for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it )
555 { 560 {
556 // Create absolute file path if necessary 561 // Create absolute file path if necessary
557 QString absFile = (*it); 562 QString absFile = (*it);
558 if ( !absFile.startsWith( "/" ) ) 563 if ( !absFile.startsWith( "/" ) )
559 absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); 564 absFile.prepend( QString( IPKG_CONF_DIR ) + "/" );
560 565
561 // Read in file 566 // Read in file
562 QFile f( absFile ); 567 QFile f( absFile );
563 if ( f.open( IO_ReadOnly ) ) 568 if ( f.open( IO_ReadOnly ) )
564 { 569 {
565 QTextStream s( &f ); 570 QTextStream s( &f );
566 while ( !s.eof() ) 571 while ( !s.eof() )
567 { 572 {
568 573
569 QString line = s.readLine().simplifyWhiteSpace(); 574 QString line = s.readLine().simplifyWhiteSpace();
570 575
571 // Parse line and save info to the conf options list 576 // Parse line and save info to the conf options list
572 if ( !line.isEmpty() ) 577 if ( !line.isEmpty() )
573 { 578 {
574 // Strip leading comment marker if exists 579 // Strip leading comment marker if exists
575 bool comment = false; 580 bool comment = false;
576 if ( line.startsWith( "#" ) ) 581 if ( line.startsWith( "#" ) )
577 { 582 {
578 line.remove( 0, 1 ); 583 line.remove( 0, 1 );
579 line = line.simplifyWhiteSpace(); 584 line = line.simplifyWhiteSpace();
580 comment = true; 585 comment = true;
581 } 586 }
582 587
583 bool recognizedOption = true; 588 bool recognizedOption = true;
584 int pos = line.find( ' ', 1 ) + 1; 589 int pos = line.find( ' ', 1 ) + 1;
585 int endpos = line.find( ' ', pos ); 590 int endpos = line.find( ' ', pos );
586 591
587 // Name 592 // Name
588 QString name = line.mid( pos, endpos - pos ); 593 QString name = line.mid( pos, endpos - pos );
589 594
590 // Value 595 // Value
591 QString value = ""; 596 QString value = "";
592 if ( endpos > -1 ) 597 if ( endpos > -1 )
593 value = line.right( line.length() - endpos - 1 ); 598 value = line.right( line.length() - endpos - 1 );
594 599
595 // Active 600 // Active
596 bool active = !comment; 601 bool active = !comment;
597 602
598 // Type 603 // Type
599 // For options w/type = Other, the mapping is as follows: 604 // For options w/type = Other, the mapping is as follows:
600 // name = typeStr (e.g. "lists_dir") 605 // name = typeStr (e.g. "lists_dir")
601 // value = value 606 // value = value
602 // features = name (from configuration file) 607 // features = name (from configuration file)
603 608
604 QString typeStr = line.left( pos - 1 ); 609 QString typeStr = line.left( pos - 1 );
605 OConfItem::Type type; 610 OConfItem::Type type;
606 QString features; 611 QString features;
607 if ( typeStr == "src" ) 612 if ( typeStr == "src" )
608 type = OConfItem::Source; 613 type = OConfItem::Source;
609 else if ( typeStr == "src/gz" ) 614 else if ( typeStr == "src/gz" )
610 { 615 {
611 type = OConfItem::Source; 616 type = OConfItem::Source;
612 features = "Compressed"; 617 features = "Compressed";
613 } 618 }
614 else if ( typeStr == "dest" ) 619 else if ( typeStr == "dest" )
615 type = OConfItem::Destination; 620 type = OConfItem::Destination;
616 else if ( typeStr == "option" ) 621 else if ( typeStr == "option" )
617 type = OConfItem::Option; 622 type = OConfItem::Option;
618 else if ( typeStr == "arch" ) 623 else if ( typeStr == "arch" )
619 type = OConfItem::Arch; 624 type = OConfItem::Arch;
620 else if ( typeStr == "lists_dir" ) 625 else if ( typeStr == "lists_dir" )
621 { 626 {
622 type = OConfItem::Other; 627 type = OConfItem::Other;
623 features = name; 628 features = name;
624 name = typeStr; 629 name = typeStr;
625 630
626 // Default value when not defined 631 // Default value when not defined
627 if ( value == QString::null || value == "" ) 632 if ( value == QString::null || value == "" )
628 value = IPKG_PKG_PATH; 633 value = IPKG_PKG_PATH;
629 } 634 }
630 else 635 else
631 recognizedOption = false; 636 recognizedOption = false;
632 637
633 // Add to list 638 // Add to list
634 if ( recognizedOption ) 639 if ( recognizedOption )
635 m_confInfo->append( new OConfItem( type, name, value, features, active ) ); 640 m_confInfo->append( new OConfItem( type, name, value, features, active ) );
636 } 641 }
637 } 642 }
638 643
639 f.close(); 644 f.close();
640 } 645 }
641 } 646 }
642 647
643 // Load Ipkg execution options from application configuration file 648 // Load Ipkg execution options from application configuration file
644 if ( m_config ) 649 if ( m_config )
645 { 650 {
646 m_config->setGroup( "Ipkg" ); 651 m_config->setGroup( "Ipkg" );
647 m_ipkgExecOptions = m_config->readNumEntry( "ExecOptions", m_ipkgExecOptions ); 652 m_ipkgExecOptions = m_config->readNumEntry( "ExecOptions", m_ipkgExecOptions );
648 m_ipkgExecVerbosity = m_config->readNumEntry( "Verbosity", m_ipkgExecVerbosity ); 653 m_ipkgExecVerbosity = m_config->readNumEntry( "Verbosity", m_ipkgExecVerbosity );
649 } 654 }
650} 655}
651 656
652OConfItemList *OIpkg::filterConfItems( OConfItem::Type typefilter ) 657OConfItemList *OIpkg::filterConfItems( OConfItem::Type typefilter )
653{ 658{
654 // Load Ipkg configuration info if not already cached 659 // Load Ipkg configuration info if not already cached
655 if ( !m_confInfo ) 660 if ( !m_confInfo )
656 loadConfiguration(); 661 loadConfiguration();
657 662
658 // Build new server list (caller is responsible for deleting) 663 // Build new server list (caller is responsible for deleting)
659 OConfItemList *sl = new OConfItemList; 664 OConfItemList *sl = new OConfItemList;
660 665
661 // If typefilter is empty, retrieve all items 666 // If typefilter is empty, retrieve all items
662 bool retrieveAll = ( typefilter == OConfItem::NotDefined ); 667 bool retrieveAll = ( typefilter == OConfItem::NotDefined );
663 668
664 // Parse configuration info for servers 669 // Parse configuration info for servers
665 OConfItemListIterator it( *m_confInfo ); 670 OConfItemListIterator it( *m_confInfo );
666 for ( ; it.current(); ++it ) 671 for ( ; it.current(); ++it )
667 { 672 {
668 OConfItem *item = it.current(); 673 OConfItem *item = it.current();
669 if ( retrieveAll || item->type() == typefilter ) 674 if ( retrieveAll || item->type() == typefilter )
670 { 675 {
671 sl->append( item ); 676 sl->append( item );
672 } 677 }
673 } 678 }
674 679
675 return sl; 680 return sl;
676} 681}
677 682
678const QString &OIpkg::rootPath() 683const QString &OIpkg::rootPath()
679{ 684{
680 if ( m_rootPath.isEmpty() ) 685 if ( m_rootPath.isEmpty() )
681 { 686 {
682 OConfItem *rootDest = findConfItem( OConfItem::Destination, "root" ); 687 OConfItem *rootDest = findConfItem( OConfItem::Destination, "root" );
683 rootDest ? m_rootPath = rootDest->value() 688 rootDest ? m_rootPath = rootDest->value()
684 : m_rootPath = '/'; 689 : m_rootPath = '/';
685 if ( m_rootPath.right( 1 ) == '/' ) 690 if ( m_rootPath.right( 1 ) == '/' )
686 m_rootPath.truncate( m_rootPath.length() - 1 ); 691 m_rootPath.truncate( m_rootPath.length() - 1 );
687 } 692 }
688 return m_rootPath; 693 return m_rootPath;
689} 694}
690 695
691void OIpkg::linkPackageDir( const QString &dest ) 696void OIpkg::linkPackageDir( const QString &dest )
692{ 697{
693 if ( !dest.isNull() ) 698 if ( !dest.isNull() )
694 { 699 {
695 OConfItem *destConfItem = findConfItem( OConfItem::Destination, dest ); 700 OConfItem *destConfItem = findConfItem( OConfItem::Destination, dest );
696 701
697 emit signalIpkgMessage( tr( "Linking packages installed in: %1" ).arg( dest ) ); 702 emit signalIpkgMessage( tr( "Linking packages installed in: %1" ).arg( dest ) );
698 703
699 // Set package destination directory 704 // Set package destination directory
700 QString destDir = destConfItem->value(); 705 QString destDir = destConfItem->value();
701 QString destInfoDir = destDir; 706 QString destInfoDir = destDir;
702 if ( destInfoDir.right( 1 ) != '/' ) 707 if ( destInfoDir.right( 1 ) != '/' )
703 destInfoDir.append( '/' ); 708 destInfoDir.append( '/' );
704 destInfoDir.append( IPKG_INFO_PATH ); 709 destInfoDir.append( IPKG_INFO_PATH );
705 710
706 // Get list of installed packages in destination 711 // Get list of installed packages in destination
707 QDir packageDir( destInfoDir ); 712 QDir packageDir( destInfoDir );
708 QStringList packageFiles; 713 QStringList packageFiles;
709 if ( packageDir.exists() ) 714 if ( packageDir.exists() )
710 { 715 {
711 packageDir.setNameFilter( "*.list" ); 716 packageDir.setNameFilter( "*.list" );
712 packageDir.setFilter( QDir::Files ); 717 packageDir.setFilter( QDir::Files );
713 packageFiles = packageDir.entryList( "*.list", QDir::Files ); 718 packageFiles = packageDir.entryList( "*.list", QDir::Files );
714 } 719 }
715 720
716 // Link all files for every package installed in desination 721 // Link all files for every package installed in desination
717 QStringList::Iterator lastFile = packageFiles.end(); 722 QStringList::Iterator lastFile = packageFiles.end();
718 for ( QStringList::Iterator it = packageFiles.begin(); it != lastFile; ++it ) 723 for ( QStringList::Iterator it = packageFiles.begin(); it != lastFile; ++it )
719 { 724 {
720 //emit signalIpkgMessage( QString( "Processing: %1/%2" ).arg( destInfoDir ).arg (*it) ); 725 //emit signalIpkgMessage( QString( "Processing: %1/%2" ).arg( destInfoDir ).arg (*it) );
721 QString packageFileName = destInfoDir; 726 QString packageFileName = destInfoDir;
722 packageFileName.append( '/' ); 727 packageFileName.append( '/' );
723 packageFileName.append( (*it) ); 728 packageFileName.append( (*it) );
724 QFile packageFile( packageFileName ); 729 QFile packageFile( packageFileName );
725 if ( packageFile.open( IO_ReadOnly ) ) 730 if ( packageFile.open( IO_ReadOnly ) )
726 { 731 {
727 QTextStream t( &packageFile ); 732 QTextStream t( &packageFile );
728 QString linkFile; 733 QString linkFile;
729 while ( !t.eof() ) 734 while ( !t.eof() )
730 { 735 {
731 // Get the name of the file to link and build the sym link filename 736 // Get the name of the file to link and build the sym link filename
732 linkFile = t.readLine(); 737 linkFile = t.readLine();
733 QString linkDest( linkFile.right( linkFile.length() - destDir.length() ) ); 738 QString linkDest( linkFile.right( linkFile.length() - destDir.length() ) );
734 linkDest.prepend( rootPath() ); 739 linkDest.prepend( rootPath() );
735 740
736 // If file installed file is actually symbolic link, use actual file for linking 741 // If file installed file is actually symbolic link, use actual file for linking
737 QFileInfo fileInfo( linkFile ); 742 QFileInfo fileInfo( linkFile );
738 if ( fileInfo.isSymLink() && !fileInfo.readLink().isEmpty() ) 743 if ( fileInfo.isSymLink() && !fileInfo.readLink().isEmpty() )
739 linkFile = fileInfo.readLink(); 744 linkFile = fileInfo.readLink();
740 745
741 // See if directory exists in 'root', if not, create 746 // See if directory exists in 'root', if not, create
742 fileInfo.setFile( linkDest ); 747 fileInfo.setFile( linkDest );
743 QString linkDestDirName = fileInfo.dirPath( true ); 748 QString linkDestDirName = fileInfo.dirPath( true );
744 QDir linkDestDir( linkDestDirName ); 749 QDir linkDestDir( linkDestDirName );
745 if ( !linkDestDir.exists() ) 750 if ( !linkDestDir.exists() )
746 { 751 {
747 linkDestDir.mkdir( linkDestDirName ); 752 linkDestDir.mkdir( linkDestDirName );
748 } 753 }
749 else 754 else
750 { 755 {
751 // Remove any previous link to make sure we will be pointing to the current version 756 // Remove any previous link to make sure we will be pointing to the current version
752 if ( QFile::exists( linkDest ) ) 757 if ( QFile::exists( linkDest ) )
753 QFile::remove( linkDest ); 758 QFile::remove( linkDest );
754 } 759 }
755 760
756 // Link the file 761 // Link the file
757 //emit signalIpkgMessage( QString( "Linking '%1' to '%2'" ).arg( linkFile ).arg( linkDest ) ); 762 //emit signalIpkgMessage( QString( "Linking '%1' to '%2'" ).arg( linkFile ).arg( linkDest ) );
758 if ( symlink( linkFile, linkDest ) == -1 ) 763 if ( symlink( linkFile, linkDest ) == -1 )
759 emit signalIpkgMessage( tr( "Error linkling '%1' to '%2'" ) 764 emit signalIpkgMessage( tr( "Error linkling '%1' to '%2'" )
760 .arg( linkFile ) 765 .arg( linkFile )
761 .arg( linkDest ) ); 766 .arg( linkDest ) );
762 } 767 }
763 packageFile.close(); 768 packageFile.close();
764 } 769 }
765 } 770 }
766 } 771 }
767} 772}
768 773
769void OIpkg::unlinkPackage( const QString &package, OConfItemList *destList ) 774void OIpkg::unlinkPackage( const QString &package, OConfItemList *destList )
770{ 775{
771 if ( !package.isNull() ) 776 if ( !package.isNull() )
772 { 777 {
773 // Find destination package is installed in 778 // Find destination package is installed in
774 if ( destList ) 779 if ( destList )
775 { 780 {
776 OConfItemListIterator it( *destList ); 781 OConfItemListIterator it( *destList );
777 for ( ; it.current(); ++it ) 782 for ( ; it.current(); ++it )
778 { 783 {
779 OConfItem *dest = it.current(); 784 OConfItem *dest = it.current();
780 QString destInfoFileName = QString( "%1/%2/%3.list" ).arg( dest->value() ) 785 QString destInfoFileName = QString( "%1/%2/%3.list" ).arg( dest->value() )
781 .arg( IPKG_INFO_PATH ) 786 .arg( IPKG_INFO_PATH )
782 .arg( package ); 787 .arg( package );
783 //emit signalIpkgMessage( QString( "Looking for '%1'" ).arg ( destInfoFileName ) ); 788 //emit signalIpkgMessage( QString( "Looking for '%1'" ).arg ( destInfoFileName ) );
784 789
785 // If found and destination is not 'root', remove symbolic links 790 // If found and destination is not 'root', remove symbolic links
786 if ( QFile::exists( destInfoFileName ) && dest->name() != "root" ) 791 if ( QFile::exists( destInfoFileName ) && dest->name() != "root" )
787 { 792 {
788 QFile destInfoFile( destInfoFileName ); 793 QFile destInfoFile( destInfoFileName );
789 if ( destInfoFile.open( IO_ReadOnly ) ) 794 if ( destInfoFile.open( IO_ReadOnly ) )
790 { 795 {
791 QTextStream t( &destInfoFile ); 796 QTextStream t( &destInfoFile );
792 QString linkFile; 797 QString linkFile;
793 while ( !t.eof() ) 798 while ( !t.eof() )
794 { 799 {
795 // Get the name of the file to link and build the sym link filename 800 // Get the name of the file to link and build the sym link filename
796 linkFile = t.readLine(); 801 linkFile = t.readLine();
797 QString linkDest( linkFile.right( linkFile.length() - 802 QString linkDest( linkFile.right( linkFile.length() -
798 dest->value().length() ) ); 803 dest->value().length() ) );
799 linkDest.prepend( rootPath() ); 804 linkDest.prepend( rootPath() );
800 805
801 //emit signalIpkgMessage( QString( "Deleting: '%1'" ).arg( linkDest ) ); 806 //emit signalIpkgMessage( QString( "Deleting: '%1'" ).arg( linkDest ) );
802 QFile::remove( linkDest ); 807 QFile::remove( linkDest );
803 } 808 }
804 destInfoFile.close(); 809 destInfoFile.close();
805 } 810 }
806 811
807 emit signalIpkgMessage( tr( "Links removed for: %1" ).arg( package ) ); 812 emit signalIpkgMessage( tr( "Links removed for: %1" ).arg( package ) );
808 return; 813 return;
809 } 814 }
810 } 815 }
811 } 816 }
812 } 817 }
813} 818}
diff --git a/noncore/settings/packagemanager/oipkg.h b/noncore/settings/packagemanager/oipkg.h
index 0263f50..4e390fa 100644
--- a/noncore/settings/packagemanager/oipkg.h
+++ b/noncore/settings/packagemanager/oipkg.h
@@ -1,116 +1,111 @@
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#ifndef OIPKG_H 32#ifndef OIPKG_H
33#define OIPKG_H 33#define OIPKG_H
34 34
35#include "oconfitem.h" 35#include "oconfitem.h"
36#include "opackage.h" 36#include "opackage.h"
37 37
38#include <qpe/config.h> 38#include <qpe/config.h>
39 39
40#include <qobject.h> 40#include <qobject.h>
41 41
42extern "C" {
43#include <libipkg.h>
44};
45
46// Ipkg execution options (m_ipkgExecOptions) 42// Ipkg execution options (m_ipkgExecOptions)
47#define FORCE_DEPENDS 0x0001 43#define FORCE_DEPENDS 0x0001
48#define FORCE_REMOVE 0x0002 44#define FORCE_REMOVE 0x0002
49#define FORCE_REINSTALL 0x0004 45#define FORCE_REINSTALL 0x0004
50#define FORCE_OVERWRITE 0x0008 46#define FORCE_OVERWRITE 0x0008
51 47
52class OConfItemList; 48class OConfItemList;
53 49
54class OIpkg : public QObject 50class OIpkg : public QObject
55{ 51{
56 Q_OBJECT 52 Q_OBJECT
57 53
58public: 54public:
59 OIpkg( Config *config = 0l, QObject *parent = 0l, const char *name = 0l ); 55 OIpkg( Config *config = 0l, QObject *parent = 0l, const char *name = 0l );
60 ~OIpkg(); 56 ~OIpkg();
61 57
62 OConfItemList *configItems(); 58 OConfItemList *configItems();
63 OConfItemList *servers(); 59 OConfItemList *servers();
64 OConfItemList *destinations(); 60 OConfItemList *destinations();
65 OConfItemList *options(); 61 OConfItemList *options();
66 62
67 int ipkgExecOptions() { return m_ipkgExecOptions; } 63 int ipkgExecOptions() { return m_ipkgExecOptions; }
68 int ipkgExecVerbosity() { return m_ipkgExecVerbosity; } 64 int ipkgExecVerbosity() { return m_ipkgExecVerbosity; }
69 65
70 void setConfigItems( OConfItemList *configList ); 66 void setConfigItems( OConfItemList *configList );
71 void setIpkgExecOptions( int options ) { m_ipkgExecOptions = options; } 67 void setIpkgExecOptions( int options ) { m_ipkgExecOptions = options; }
72 void setIpkgExecVerbosity( int verbosity ) { m_ipkgExecVerbosity = verbosity; } 68 void setIpkgExecVerbosity( int verbosity ) { m_ipkgExecVerbosity = verbosity; }
73 69
74 void saveSettings(); 70 void saveSettings();
75 71
76 OPackageList *availablePackages( const QString &server = QString::null ); 72 OPackageList *availablePackages( const QString &server = QString::null );
77 OPackageList *installedPackages( const QString &destName = QString::null, 73 OPackageList *installedPackages( const QString &destName = QString::null,
78 const QString &destPath = QString::null ); 74 const QString &destPath = QString::null );
79 75
80 OConfItem *findConfItem( OConfItem::Type type = OConfItem::NotDefined, 76 OConfItem *findConfItem( OConfItem::Type type = OConfItem::NotDefined,
81 const QString &name = QString::null ); 77 const QString &name = QString::null );
82 78
83 bool executeCommand( OPackage::Command command = OPackage::NotDefined, 79 bool executeCommand( OPackage::Command command = OPackage::NotDefined,
84 const QStringList &parameters = QStringList(), 80 const QStringList &parameters = QStringList(),
85 const QString &destination = QString::null, 81 const QString &destination = QString::null,
86 const QObject *receiver = 0l, 82 const QObject *receiver = 0l,
87 const char *slotOutput = 0l, 83 const char *slotOutput = 0l,
88 bool rawOutput = true ); 84 bool rawOutput = true );
89 void abortCommand(); 85 void abortCommand();
90 86
91 void ipkgMessage( char *msg ); 87 void ipkgMessage( char *msg );
92 void ipkgStatus( char *status ); 88 void ipkgStatus( char *status );
93 void ipkgList( char *filelist ); 89 void ipkgList( char *filelist );
94 90
95private: 91private:
96 Config *m_config; // Pointer to application configuration file 92 Config *m_config; // Pointer to application configuration file
97 args_t m_ipkgArgs; // libipkg configuration arguments
98 OConfItemList *m_confInfo; // Contains info from all Ipkg configuration files 93 OConfItemList *m_confInfo; // Contains info from all Ipkg configuration files
99 int m_ipkgExecOptions; // Bit-mapped flags for Ipkg execution options 94 int m_ipkgExecOptions; // Bit-mapped flags for Ipkg execution options
100 int m_ipkgExecVerbosity; // Ipkg execution verbosity level 95 int m_ipkgExecVerbosity; // Ipkg execution verbosity level
101 QString m_rootPath; // Directory path where the 'root' destination is located 96 QString m_rootPath; // Directory path where the 'root' destination is located
102 97
103 void loadConfiguration(); 98 void loadConfiguration();
104 OConfItemList *filterConfItems( OConfItem::Type typefilter = OConfItem::NotDefined ); 99 OConfItemList *filterConfItems( OConfItem::Type typefilter = OConfItem::NotDefined );
105 const QString &rootPath(); 100 const QString &rootPath();
106 void linkPackageDir( const QString &dest = QString::null ); 101 void linkPackageDir( const QString &dest = QString::null );
107 void unlinkPackage( const QString &package = QString::null, 102 void unlinkPackage( const QString &package = QString::null,
108 OConfItemList *destList = 0l ); 103 OConfItemList *destList = 0l );
109 104
110signals: 105signals:
111 void signalIpkgMessage( const QString &msg ); 106 void signalIpkgMessage( const QString &msg );
112 void signalIpkgStatus( const QString &status ); 107 void signalIpkgStatus( const QString &status );
113 void signalIpkgList( const QString &filelist ); 108 void signalIpkgList( const QString &filelist );
114}; 109};
115 110
116#endif 111#endif