summaryrefslogtreecommitdiff
path: root/noncore/settings/packagemanager/oipkg.cpp
authoralwin <alwin>2004-03-02 12:21:11 (UTC)
committer alwin <alwin>2004-03-02 12:21:11 (UTC)
commitb6b1c97559c0ed9f2e33632272426bf98f289232 (patch) (unidiff)
treed3a9987704770cdf5eb14e1136f6e3ecb2f36a04 /noncore/settings/packagemanager/oipkg.cpp
parent0d59c780513da78033f4d9040475dee9db0256d4 (diff)
downloadopie-b6b1c97559c0ed9f2e33632272426bf98f289232.zip
opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.gz
opie-b6b1c97559c0ed9f2e33632272426bf98f289232.tar.bz2
applied the patch generated by the optimize_connect script from
TT.
Diffstat (limited to 'noncore/settings/packagemanager/oipkg.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/packagemanager/oipkg.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/noncore/settings/packagemanager/oipkg.cpp b/noncore/settings/packagemanager/oipkg.cpp
index 086e91b..1dc23a4 100644
--- a/noncore/settings/packagemanager/oipkg.cpp
+++ b/noncore/settings/packagemanager/oipkg.cpp
@@ -223,242 +223,242 @@ OPackageList *OIpkg::installedPackages( const QString &destName, const QString &
223 path.append( "/" ); 223 path.append( "/" );
224 path.append( IPKG_STATUS_PATH ); 224 path.append( IPKG_STATUS_PATH );
225 225
226 QFile f( path ); 226 QFile f( path );
227 if ( !f.open( IO_ReadOnly ) ) 227 if ( !f.open( IO_ReadOnly ) )
228 return NULL; 228 return NULL;
229 QTextStream t( &f ); 229 QTextStream t( &f );
230 230
231 // Process all information in status file 231 // Process all information in status file
232 bool newPackage = false; 232 bool newPackage = false;
233 QString line = t.readLine(); 233 QString line = t.readLine();
234 QString name; 234 QString name;
235 QString version; 235 QString version;
236 QString status; 236 QString status;
237 237
238 while ( !t.eof() ) 238 while ( !t.eof() )
239 { 239 {
240 // Determine key/value pair 240 // Determine key/value pair
241 int pos = line.find( ':', 0 ); 241 int pos = line.find( ':', 0 );
242 QString key; 242 QString key;
243 if ( pos > -1 ) 243 if ( pos > -1 )
244 key = line.mid( 0, pos ); 244 key = line.mid( 0, pos );
245 else 245 else
246 key = QString::null; 246 key = QString::null;
247 QString value = line.mid( pos+2, line.length()-pos ); 247 QString value = line.mid( pos+2, line.length()-pos );
248 248
249 // Allocate new package and insert into list 249 // Allocate new package and insert into list
250 if ( newPackage && !key.isEmpty() ) 250 if ( newPackage && !key.isEmpty() )
251 { 251 {
252 // Add to list only if it has a valid name and is installed 252 // Add to list only if it has a valid name and is installed
253 if ( !name.isNull() && status.contains( " installed" ) ) 253 if ( !name.isNull() && status.contains( " installed" ) )
254 { 254 {
255 pl->append( new OPackage( name, QString::null, version, QString::null, destName ) ); 255 pl->append( new OPackage( name, QString::null, version, QString::null, destName ) );
256 name = QString::null; 256 name = QString::null;
257 version = QString::null; 257 version = QString::null;
258 status = QString::null; 258 status = QString::null;
259 259
260 newPackage = false; 260 newPackage = false;
261 } 261 }
262 } 262 }
263 263
264 // Update package data 264 // Update package data
265 if ( key == "Package" ) 265 if ( key == "Package" )
266 name = value; 266 name = value;
267 else if ( key == "Version" ) 267 else if ( key == "Version" )
268 version = value; 268 version = value;
269 else if ( key == "Status" ) 269 else if ( key == "Status" )
270 status = value; 270 status = value;
271 else if ( key.isEmpty() && value.isEmpty() ) 271 else if ( key.isEmpty() && value.isEmpty() )
272 newPackage = true; 272 newPackage = true;
273 273
274 // Skip past all description lines 274 // Skip past all description lines
275 if ( key == "Description" ) 275 if ( key == "Description" )
276 { 276 {
277 line = t.readLine(); 277 line = t.readLine();
278 while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) 278 while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() )
279 line = t.readLine(); 279 line = t.readLine();
280 } 280 }
281 else 281 else
282 line = t.readLine(); 282 line = t.readLine();
283 } 283 }
284 284
285 f.close(); 285 f.close();
286 286
287 return pl; 287 return pl;
288} 288}
289 289
290bool OIpkg::executeCommand( OPackage::Command command, QStringList *parameters, const QString &destination, 290bool OIpkg::executeCommand( OPackage::Command command, QStringList *parameters, const QString &destination,
291 const QObject *receiver, const char *slotOutput, bool rawOutput ) 291 const QObject *receiver, const char *slotOutput, bool rawOutput )
292{ 292{
293 if ( command == OPackage::NotDefined ) 293 if ( command == OPackage::NotDefined )
294 return false; 294 return false;
295 295
296 // Set ipkg run-time options/arguments 296 // Set ipkg run-time options/arguments
297 m_ipkgArgs.force_depends = ( m_ipkgExecOptions & FORCE_DEPENDS ); 297 m_ipkgArgs.force_depends = ( m_ipkgExecOptions & FORCE_DEPENDS );
298 m_ipkgArgs.force_reinstall = ( m_ipkgExecOptions & FORCE_REINSTALL ); 298 m_ipkgArgs.force_reinstall = ( m_ipkgExecOptions & FORCE_REINSTALL );
299 // TODO m_ipkgArgs.force_remove = ( m_ipkgExecOptions & FORCE_REMOVE ); 299 // TODO m_ipkgArgs.force_remove = ( m_ipkgExecOptions & FORCE_REMOVE );
300 m_ipkgArgs.force_overwrite = ( m_ipkgExecOptions & FORCE_OVERWRITE ); 300 m_ipkgArgs.force_overwrite = ( m_ipkgExecOptions & FORCE_OVERWRITE );
301 m_ipkgArgs.verbosity = m_ipkgExecVerbosity; 301 m_ipkgArgs.verbosity = m_ipkgExecVerbosity;
302 if ( m_ipkgArgs.dest ) 302 if ( m_ipkgArgs.dest )
303 free( m_ipkgArgs.dest ); 303 free( m_ipkgArgs.dest );
304 if ( !destination.isNull() ) 304 if ( !destination.isNull() )
305 { 305 {
306 int len = destination.length() + 1; 306 int len = destination.length() + 1;
307 m_ipkgArgs.dest = (char *)malloc( len ); 307 m_ipkgArgs.dest = (char *)malloc( len );
308 strncpy( m_ipkgArgs.dest, destination, destination.length() ); 308 strncpy( m_ipkgArgs.dest, destination, destination.length() );
309 m_ipkgArgs.dest[ len - 1 ] = '\0'; 309 m_ipkgArgs.dest[ len - 1 ] = '\0';
310 } 310 }
311 else 311 else
312 m_ipkgArgs.dest = 0x0; 312 m_ipkgArgs.dest = 0x0;
313 313
314 // Connect output signal to widget 314 // Connect output signal to widget
315 315
316 if ( rawOutput ) 316 if ( rawOutput )
317 { 317 {
318// if ( slotOutput ) 318// if ( slotOutput )
319// connect( this, SIGNAL(signalIpkgMessage(char *)), receiver, slotOutput ); 319// connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput );
320 } 320 }
321 else 321 else
322 { 322 {
323 // TODO - connect to local slot and parse output before emitting signalIpkgMessage 323 // TODO - connect to local slot and parse output before emitting signalIpkgMessage
324 } 324 }
325 325
326 switch( command ) 326 switch( command )
327 { 327 {
328 case OPackage::Update : { 328 case OPackage::Update : {
329 connect( this, SIGNAL(signalIpkgMessage(char *)), receiver, slotOutput ); 329 connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput );
330 ipkg_lists_update( &m_ipkgArgs ); 330 ipkg_lists_update( &m_ipkgArgs );
331 }; 331 };
332 break; 332 break;
333 case OPackage::Upgrade : { 333 case OPackage::Upgrade : {
334 connect( this, SIGNAL(signalIpkgMessage(char *)), receiver, slotOutput ); 334 connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput );
335 ipkg_packages_upgrade( &m_ipkgArgs ); 335 ipkg_packages_upgrade( &m_ipkgArgs );
336 }; 336 };
337 break; 337 break;
338 case OPackage::Install : { 338 case OPackage::Install : {
339 connect( this, SIGNAL(signalIpkgMessage(char *)), receiver, slotOutput ); 339 connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput );
340 for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) 340 for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it )
341 { 341 {
342 ipkg_packages_install( &m_ipkgArgs, (*it) ); 342 ipkg_packages_install( &m_ipkgArgs, (*it) );
343 } 343 }
344 }; 344 };
345 break; 345 break;
346 case OPackage::Remove : { 346 case OPackage::Remove : {
347 connect( this, SIGNAL(signalIpkgMessage(char *)), receiver, slotOutput ); 347 connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput );
348 for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) 348 for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it )
349 { 349 {
350 ipkg_packages_remove( &m_ipkgArgs, (*it), true ); 350 ipkg_packages_remove( &m_ipkgArgs, (*it), true );
351 } 351 }
352 }; 352 };
353 break; 353 break;
354 case OPackage::Download : { 354 case OPackage::Download : {
355 connect( this, SIGNAL(signalIpkgMessage(char *)), receiver, slotOutput ); 355 connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput );
356 for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) 356 for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it )
357 { 357 {
358 ipkg_packages_download( &m_ipkgArgs, (*it) ); 358 ipkg_packages_download( &m_ipkgArgs, (*it) );
359 } 359 }
360 }; 360 };
361 break; 361 break;
362 case OPackage::Info : { 362 case OPackage::Info : {
363 connect( this, SIGNAL(signalIpkgStatus(char *)), receiver, slotOutput ); 363 connect( this, SIGNAL(signalIpkgStatus(char*)), receiver, slotOutput );
364 ipkg_packages_info( &m_ipkgArgs, (*parameters->begin()), &fIpkgStatus, 0x0 ); 364 ipkg_packages_info( &m_ipkgArgs, (*parameters->begin()), &fIpkgStatus, 0x0 );
365 }; 365 };
366 break; 366 break;
367 case OPackage::Files : { 367 case OPackage::Files : {
368 connect( this, SIGNAL(signalIpkgList(char *)), receiver, slotOutput ); 368 connect( this, SIGNAL(signalIpkgList(char*)), receiver, slotOutput );
369 ipkg_package_files( &m_ipkgArgs, (*parameters->begin()), &fIpkgFiles, 0x0 ); 369 ipkg_package_files( &m_ipkgArgs, (*parameters->begin()), &fIpkgFiles, 0x0 );
370 }; 370 };
371 break; 371 break;
372 default : break; 372 default : break;
373 }; 373 };
374 374
375 return true; 375 return true;
376} 376}
377 377
378void OIpkg::ipkgMessage( char *msg ) 378void OIpkg::ipkgMessage( char *msg )
379{ 379{
380 emit signalIpkgMessage( msg ); 380 emit signalIpkgMessage( msg );
381} 381}
382 382
383void OIpkg::ipkgStatus( char *status ) 383void OIpkg::ipkgStatus( char *status )
384{ 384{
385 emit signalIpkgStatus( status ); 385 emit signalIpkgStatus( status );
386} 386}
387 387
388void OIpkg::ipkgList( char *filelist ) 388void OIpkg::ipkgList( char *filelist )
389{ 389{
390 emit signalIpkgList( filelist ); 390 emit signalIpkgList( filelist );
391} 391}
392 392
393void OIpkg::loadConfiguration() 393void OIpkg::loadConfiguration()
394{ 394{
395 if ( m_confInfo ) 395 if ( m_confInfo )
396 delete m_confInfo; 396 delete m_confInfo;
397 397
398 // Load configuration item list 398 // Load configuration item list
399 m_confInfo = new OConfItemList(); 399 m_confInfo = new OConfItemList();
400 400
401 QStringList confFiles; 401 QStringList confFiles;
402 QDir confDir( IPKG_CONF_DIR ); 402 QDir confDir( IPKG_CONF_DIR );
403 if ( confDir.exists() ) 403 if ( confDir.exists() )
404 { 404 {
405 confDir.setNameFilter( "*.conf" ); 405 confDir.setNameFilter( "*.conf" );
406 confDir.setFilter( QDir::Files ); 406 confDir.setFilter( QDir::Files );
407 confFiles = confDir.entryList( "*.conf", QDir::Files ); 407 confFiles = confDir.entryList( "*.conf", QDir::Files );
408 confFiles << IPKG_CONF; 408 confFiles << IPKG_CONF;
409 409
410 for ( QStringList::Iterator it = confFiles.begin(); it != confFiles.end(); ++it ) 410 for ( QStringList::Iterator it = confFiles.begin(); it != confFiles.end(); ++it )
411 { 411 {
412 // Create absolute file path if necessary 412 // Create absolute file path if necessary
413 QString absFile = (*it); 413 QString absFile = (*it);
414 if ( !absFile.startsWith( "/" ) ) 414 if ( !absFile.startsWith( "/" ) )
415 absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); 415 absFile.prepend( QString( IPKG_CONF_DIR ) + "/" );
416 416
417 // Read in file 417 // Read in file
418 QFile f( absFile ); 418 QFile f( absFile );
419 if ( f.open( IO_ReadOnly ) ) 419 if ( f.open( IO_ReadOnly ) )
420 { 420 {
421 QTextStream s( &f ); 421 QTextStream s( &f );
422 while ( !s.eof() ) 422 while ( !s.eof() )
423 { 423 {
424 424
425 QString line = s.readLine().simplifyWhiteSpace(); 425 QString line = s.readLine().simplifyWhiteSpace();
426 426
427 // Parse line and save info to the conf options list 427 // Parse line and save info to the conf options list
428 if ( !line.isEmpty() ) 428 if ( !line.isEmpty() )
429 { 429 {
430 if ( !line.startsWith( "#" ) || 430 if ( !line.startsWith( "#" ) ||
431 line.startsWith( "#src" ) || 431 line.startsWith( "#src" ) ||
432 line.startsWith( "#dest" ) || 432 line.startsWith( "#dest" ) ||
433 line.startsWith( "#arch" ) || 433 line.startsWith( "#arch" ) ||
434 line.startsWith( "#option" ) ) 434 line.startsWith( "#option" ) )
435 { 435 {
436 int pos = line.find( ' ', 1 ); 436 int pos = line.find( ' ', 1 );
437 437
438 // Type 438 // Type
439 QString typeStr = line.left( pos ); 439 QString typeStr = line.left( pos );
440 OConfItem::Type type; 440 OConfItem::Type type;
441 if ( typeStr == "src" || typeStr == "#src" ) 441 if ( typeStr == "src" || typeStr == "#src" )
442 type = OConfItem::Source; 442 type = OConfItem::Source;
443 else if ( typeStr == "dest" || typeStr == "#dest" ) 443 else if ( typeStr == "dest" || typeStr == "#dest" )
444 type = OConfItem::Destination; 444 type = OConfItem::Destination;
445 else if ( typeStr == "option" || typeStr == "#option" ) 445 else if ( typeStr == "option" || typeStr == "#option" )
446 type = OConfItem::Option; 446 type = OConfItem::Option;
447 else if ( typeStr == "arch" || typeStr == "#arch" ) 447 else if ( typeStr == "arch" || typeStr == "#arch" )
448 type = OConfItem::Arch; 448 type = OConfItem::Arch;
449 else 449 else
450 type = OConfItem::NotDefined; 450 type = OConfItem::NotDefined;
451 ++pos; 451 ++pos;
452 int endpos = line.find( ' ', pos ); 452 int endpos = line.find( ' ', pos );
453 453
454 // Name 454 // Name
455 QString name = line.mid( pos, endpos - pos ); 455 QString name = line.mid( pos, endpos - pos );
456 456
457 // Value 457 // Value
458 QString value = ""; 458 QString value = "";
459 if ( endpos > -1 ) 459 if ( endpos > -1 )
460 value = line.right( line.length() - endpos - 1 ); 460 value = line.right( line.length() - endpos - 1 );
461 461
462 // Active 462 // Active
463 bool active = !line.startsWith( "#" ); 463 bool active = !line.startsWith( "#" );
464 464