Diffstat (limited to 'noncore/settings/packagemanager/oipkg.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/packagemanager/oipkg.cpp | 56 |
1 files changed, 29 insertions, 27 deletions
diff --git a/noncore/settings/packagemanager/oipkg.cpp b/noncore/settings/packagemanager/oipkg.cpp index 1978ad5..b0cc94d 100644 --- a/noncore/settings/packagemanager/oipkg.cpp +++ b/noncore/settings/packagemanager/oipkg.cpp | |||
@@ -1,78 +1,80 @@ | |||
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 | if ( conf && ( conf->verbosity < level ) ) | 51 | if ( conf && ( conf->verbosity < level ) ) |
52 | return 0; | 52 | return 0; |
53 | else | 53 | else |
54 | oipkg->ipkgMessage( msg ); | 54 | oipkg->ipkgMessage( msg ); |
55 | |||
56 | return 0; | ||
55 | } | 57 | } |
56 | 58 | ||
57 | char *fIpkgResponse( char */*question*/ ) | 59 | char *fIpkgResponse( char */*question*/ ) |
58 | { | 60 | { |
59 | return 0x0; | 61 | return 0x0; |
60 | } | 62 | } |
61 | 63 | ||
62 | int fIpkgStatus( char */*name*/, int /*status*/, char *desc, void */*userdata*/ ) | 64 | int fIpkgStatus( char */*name*/, int /*status*/, char *desc, void */*userdata*/ ) |
63 | { | 65 | { |
64 | oipkg->ipkgStatus( desc ); | 66 | oipkg->ipkgStatus( desc ); |
65 | return 0; | 67 | return 0; |
66 | } | 68 | } |
67 | 69 | ||
68 | int fIpkgFiles( char */*name*/, char *desc, char */*version*/, pkg_state_status_t /*status*/, | 70 | int fIpkgFiles( char */*name*/, char *desc, char */*version*/, pkg_state_status_t /*status*/, |
69 | void */*userdata*/ ) | 71 | void */*userdata*/ ) |
70 | { | 72 | { |
71 | oipkg->ipkgList( desc ); | 73 | oipkg->ipkgList( desc ); |
72 | return 0; | 74 | return 0; |
73 | } | 75 | } |
74 | 76 | ||
75 | OIpkg::OIpkg( Config *config, QObject *parent, const char *name ) | 77 | OIpkg::OIpkg( Config *config, QObject *parent, const char *name ) |
76 | : QObject( parent, name ) | 78 | : QObject( parent, name ) |
77 | , m_config( config ) | 79 | , m_config( config ) |
78 | , m_confInfo( NULL ) | 80 | , m_confInfo( NULL ) |
@@ -332,49 +334,49 @@ OPackageList *OIpkg::installedPackages( const QString &destName, const QString & | |||
332 | name = value; | 334 | name = value; |
333 | else if ( key == "Version" ) | 335 | else if ( key == "Version" ) |
334 | version = value; | 336 | version = value; |
335 | else if ( key == "Status" ) | 337 | else if ( key == "Status" ) |
336 | status = value; | 338 | status = value; |
337 | else if ( key.isEmpty() && value.isEmpty() ) | 339 | else if ( key.isEmpty() && value.isEmpty() ) |
338 | newPackage = true; | 340 | newPackage = true; |
339 | 341 | ||
340 | // Skip past all description lines | 342 | // Skip past all description lines |
341 | if ( key == "Description" ) | 343 | if ( key == "Description" ) |
342 | { | 344 | { |
343 | line = t.readLine(); | 345 | line = t.readLine(); |
344 | while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) | 346 | while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) |
345 | line = t.readLine(); | 347 | line = t.readLine(); |
346 | } | 348 | } |
347 | else | 349 | else |
348 | line = t.readLine(); | 350 | line = t.readLine(); |
349 | } | 351 | } |
350 | 352 | ||
351 | f.close(); | 353 | f.close(); |
352 | 354 | ||
353 | return pl; | 355 | return pl; |
354 | } | 356 | } |
355 | 357 | ||
356 | bool OIpkg::executeCommand( OPackage::Command command, QStringList *parameters, const QString &destination, | 358 | bool OIpkg::executeCommand( OPackage::Command command, const QStringList ¶meters, const QString &destination, |
357 | const QObject *receiver, const char *slotOutput, bool rawOutput ) | 359 | const QObject *receiver, const char *slotOutput, bool rawOutput ) |
358 | { | 360 | { |
359 | if ( command == OPackage::NotDefined ) | 361 | if ( command == OPackage::NotDefined ) |
360 | return false; | 362 | return false; |
361 | 363 | ||
362 | // Set ipkg run-time options/arguments | 364 | // Set ipkg run-time options/arguments |
363 | m_ipkgArgs.force_depends = ( m_ipkgExecOptions & FORCE_DEPENDS ); | 365 | m_ipkgArgs.force_depends = ( m_ipkgExecOptions & FORCE_DEPENDS ); |
364 | m_ipkgArgs.force_reinstall = ( m_ipkgExecOptions & FORCE_REINSTALL ); | 366 | m_ipkgArgs.force_reinstall = ( m_ipkgExecOptions & FORCE_REINSTALL ); |
365 | // TODO m_ipkgArgs.force_remove = ( m_ipkgExecOptions & FORCE_REMOVE ); | 367 | // TODO m_ipkgArgs.force_remove = ( m_ipkgExecOptions & FORCE_REMOVE ); |
366 | m_ipkgArgs.force_overwrite = ( m_ipkgExecOptions & FORCE_OVERWRITE ); | 368 | m_ipkgArgs.force_overwrite = ( m_ipkgExecOptions & FORCE_OVERWRITE ); |
367 | m_ipkgArgs.verbosity = m_ipkgExecVerbosity; | 369 | m_ipkgArgs.verbosity = m_ipkgExecVerbosity; |
368 | if ( m_ipkgArgs.dest ) | 370 | if ( m_ipkgArgs.dest ) |
369 | free( m_ipkgArgs.dest ); | 371 | free( m_ipkgArgs.dest ); |
370 | if ( !destination.isNull() ) | 372 | if ( !destination.isNull() ) |
371 | { | 373 | { |
372 | int len = destination.length() + 1; | 374 | int len = destination.length() + 1; |
373 | m_ipkgArgs.dest = (char *)malloc( len ); | 375 | m_ipkgArgs.dest = (char *)malloc( len ); |
374 | strncpy( m_ipkgArgs.dest, destination, destination.length() ); | 376 | strncpy( m_ipkgArgs.dest, destination, destination.length() ); |
375 | m_ipkgArgs.dest[ len - 1 ] = '\0'; | 377 | m_ipkgArgs.dest[ len - 1 ] = '\0'; |
376 | } | 378 | } |
377 | else | 379 | else |
378 | m_ipkgArgs.dest = 0x0; | 380 | m_ipkgArgs.dest = 0x0; |
379 | 381 | ||
380 | // Connect output signal to widget | 382 | // Connect output signal to widget |
@@ -382,78 +384,78 @@ bool OIpkg::executeCommand( OPackage::Command command, QStringList *parameters, | |||
382 | if ( rawOutput ) | 384 | if ( rawOutput ) |
383 | { | 385 | { |
384 | // if ( slotOutput ) | 386 | // if ( slotOutput ) |
385 | // connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); | 387 | // connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); |
386 | } | 388 | } |
387 | else | 389 | else |
388 | { | 390 | { |
389 | // TODO - connect to local slot and parse output before emitting signalIpkgMessage | 391 | // TODO - connect to local slot and parse output before emitting signalIpkgMessage |
390 | } | 392 | } |
391 | 393 | ||
392 | switch( command ) | 394 | switch( command ) |
393 | { | 395 | { |
394 | case OPackage::Update : { | 396 | case OPackage::Update : { |
395 | connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); | 397 | connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); |
396 | ipkg_lists_update( &m_ipkgArgs ); | 398 | ipkg_lists_update( &m_ipkgArgs ); |
397 | }; | 399 | }; |
398 | break; | 400 | break; |
399 | case OPackage::Upgrade : { | 401 | case OPackage::Upgrade : { |
400 | connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); | 402 | connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); |
401 | ipkg_packages_upgrade( &m_ipkgArgs ); | 403 | ipkg_packages_upgrade( &m_ipkgArgs ); |
402 | }; | 404 | }; |
403 | break; | 405 | break; |
404 | case OPackage::Install : { | 406 | case OPackage::Install : { |
405 | connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); | 407 | connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); |
406 | for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) | 408 | for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) |
407 | { | 409 | { |
408 | ipkg_packages_install( &m_ipkgArgs, (*it) ); | 410 | ipkg_packages_install( &m_ipkgArgs, (*it) ); |
409 | } | 411 | } |
410 | }; | 412 | }; |
411 | break; | 413 | break; |
412 | case OPackage::Remove : { | 414 | case OPackage::Remove : { |
413 | connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); | 415 | connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); |
414 | for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) | 416 | for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) |
415 | { | 417 | { |
416 | ipkg_packages_remove( &m_ipkgArgs, (*it), true ); | 418 | ipkg_packages_remove( &m_ipkgArgs, (*it), true ); |
417 | } | 419 | } |
418 | }; | 420 | }; |
419 | break; | 421 | break; |
420 | case OPackage::Download : { | 422 | case OPackage::Download : { |
421 | connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); | 423 | connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); |
422 | for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) | 424 | for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) |
423 | { | 425 | { |
424 | ipkg_packages_download( &m_ipkgArgs, (*it) ); | 426 | ipkg_packages_download( &m_ipkgArgs, (*it) ); |
425 | } | 427 | } |
426 | }; | 428 | }; |
427 | break; | 429 | break; |
428 | case OPackage::Info : { | 430 | case OPackage::Info : { |
429 | connect( this, SIGNAL(signalIpkgStatus(char*)), receiver, slotOutput ); | 431 | connect( this, SIGNAL(signalIpkgStatus(char*)), receiver, slotOutput ); |
430 | ipkg_packages_info( &m_ipkgArgs, (*parameters->begin()), &fIpkgStatus, 0x0 ); | 432 | ipkg_packages_info( &m_ipkgArgs, (*parameters.begin()), &fIpkgStatus, 0x0 ); |
431 | }; | 433 | }; |
432 | break; | 434 | break; |
433 | case OPackage::Files : { | 435 | case OPackage::Files : { |
434 | connect( this, SIGNAL(signalIpkgList(char*)), receiver, slotOutput ); | 436 | connect( this, SIGNAL(signalIpkgList(char*)), receiver, slotOutput ); |
435 | ipkg_package_files( &m_ipkgArgs, (*parameters->begin()), &fIpkgFiles, 0x0 ); | 437 | ipkg_package_files( &m_ipkgArgs, (*parameters.begin()), &fIpkgFiles, 0x0 ); |
436 | }; | 438 | }; |
437 | break; | 439 | break; |
438 | default : break; | 440 | default : break; |
439 | }; | 441 | }; |
440 | 442 | ||
441 | return true; | 443 | return true; |
442 | } | 444 | } |
443 | 445 | ||
444 | void OIpkg::ipkgMessage( char *msg ) | 446 | void OIpkg::ipkgMessage( char *msg ) |
445 | { | 447 | { |
446 | emit signalIpkgMessage( msg ); | 448 | emit signalIpkgMessage( msg ); |
447 | } | 449 | } |
448 | 450 | ||
449 | void OIpkg::ipkgStatus( char *status ) | 451 | void OIpkg::ipkgStatus( char *status ) |
450 | { | 452 | { |
451 | emit signalIpkgStatus( status ); | 453 | emit signalIpkgStatus( status ); |
452 | } | 454 | } |
453 | 455 | ||
454 | void OIpkg::ipkgList( char *filelist ) | 456 | void OIpkg::ipkgList( char *filelist ) |
455 | { | 457 | { |
456 | emit signalIpkgList( filelist ); | 458 | emit signalIpkgList( filelist ); |
457 | } | 459 | } |
458 | 460 | ||
459 | void OIpkg::loadConfiguration() | 461 | void OIpkg::loadConfiguration() |