Diffstat (limited to 'noncore/settings/packagemanager/oipkg.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/packagemanager/oipkg.cpp | 69 |
1 files changed, 58 insertions, 11 deletions
diff --git a/noncore/settings/packagemanager/oipkg.cpp b/noncore/settings/packagemanager/oipkg.cpp index ed9ea10..eb07a61 100644 --- a/noncore/settings/packagemanager/oipkg.cpp +++ b/noncore/settings/packagemanager/oipkg.cpp | |||
@@ -26,53 +26,70 @@ | |||
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 <stdio.h> | ||
34 | #include <stdlib.h> | 35 | #include <stdlib.h> |
35 | #include <string.h> | 36 | #include <string.h> |
36 | 37 | ||
37 | #include <qdir.h> | 38 | #include <qdir.h> |
38 | #include <qfile.h> | 39 | #include <qfile.h> |
39 | #include <qmessagebox.h> | 40 | #include <qmessagebox.h> |
40 | #include <qtextstream.h> | 41 | #include <qtextstream.h> |
41 | 42 | ||
42 | const QString IPKG_CONF = "/etc/ipkg.conf"; // Fully-qualified name of Ipkg primary configuration file | 43 | const QString IPKG_CONF = "/etc/ipkg.conf"; // Fully-qualified name of Ipkg primary configuration file |
43 | const QString IPKG_CONF_DIR = "/etc/ipkg"; // Directory of secondary Ipkg configuration files | 44 | const QString IPKG_CONF_DIR = "/etc/ipkg"; // Directory of secondary Ipkg configuration files |
44 | const QString IPKG_PKG_PATH = "/usr/lib/ipkg/lists"; // Directory containing server package lists | 45 | const QString IPKG_PKG_PATH = "/usr/lib/ipkg/lists"; // Directory containing server package lists |
45 | const QString IPKG_STATUS_PATH = "usr/lib/ipkg/status"; // Destination status file location | 46 | const QString IPKG_STATUS_PATH = "usr/lib/ipkg/status"; // Destination status file location |
46 | 47 | ||
47 | OIpkg *oipkg; | 48 | OIpkg *oipkg; |
48 | 49 | ||
49 | int fIpkgMessage( ipkg_conf_t */*conf*/, message_level_t /*level*/, char *msg ) | 50 | // Ipkg callback functions |
51 | |||
52 | int fsignalIpkgMessage( ipkg_conf_t */*conf*/, message_level_t /*level*/, char *msg ) | ||
50 | { | 53 | { |
51 | oipkg->ipkgOutput( msg ); | 54 | oipkg->ipkgMessage( msg ); |
52 | return 0; | 55 | return 0; |
53 | } | 56 | } |
54 | 57 | ||
55 | char* fIpkgResponse( char */*question*/ ) | 58 | char *fIpkgResponse( char */*question*/ ) |
56 | { | 59 | { |
57 | return 0x0; | 60 | return 0x0; |
58 | } | 61 | } |
59 | 62 | ||
63 | int fIpkgStatus( char */*name*/, int /*status*/, char *desc, void */*userdata*/ ) | ||
64 | { | ||
65 | oipkg->ipkgStatus( desc ); | ||
66 | return 0; | ||
67 | } | ||
68 | |||
69 | int fIpkgFiles( char */*name*/, char *desc, char */*version*/, pkg_state_status_t /*status*/, | ||
70 | void */*userdata*/ ) | ||
71 | { | ||
72 | printf( "*****List*****\n%s\n", desc ); | ||
73 | oipkg->ipkgList( desc ); | ||
74 | return 0; | ||
75 | } | ||
76 | |||
60 | OIpkg::OIpkg( Config *config, QObject *parent, const char *name ) | 77 | OIpkg::OIpkg( Config *config, QObject *parent, const char *name ) |
61 | : QObject( parent, name ) | 78 | : QObject( parent, name ) |
62 | , m_config( config ) | 79 | , m_config( config ) |
63 | , m_confInfo( NULL ) | 80 | , m_confInfo( NULL ) |
64 | , m_ipkgExecOptions( 0 ) | 81 | , m_ipkgExecOptions( 0 ) |
65 | , m_ipkgExecVerbosity( 1 ) | 82 | , m_ipkgExecVerbosity( 1 ) |
66 | { | 83 | { |
67 | oipkg = this; | 84 | oipkg = this; |
68 | 85 | ||
69 | // Initialize libipkg | 86 | // Initialize libipkg |
70 | if ( ipkg_init( &fIpkgMessage, &fIpkgResponse, &m_ipkgArgs ) ) | 87 | if ( ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ) ) |
71 | QMessageBox::critical( 0, tr( "OIpkg" ), tr( "Error initialing libipkg" ) ); | 88 | QMessageBox::critical( 0, tr( "OIpkg" ), tr( "Error initialing libipkg" ) ); |
72 | 89 | ||
73 | // Default ipkg run-time arguments | 90 | // Default ipkg run-time arguments |
74 | m_ipkgArgs.noaction = false; | 91 | m_ipkgArgs.noaction = false; |
75 | m_ipkgArgs.force_defaults = true; | 92 | m_ipkgArgs.force_defaults = true; |
76 | } | 93 | } |
77 | 94 | ||
78 | OIpkg::~OIpkg() | 95 | OIpkg::~OIpkg() |
@@ -292,62 +309,92 @@ bool OIpkg::executeCommand( OPackage::Command command, QStringList *parameters, | |||
292 | m_ipkgArgs.dest = (char *)malloc( len ); | 309 | m_ipkgArgs.dest = (char *)malloc( len ); |
293 | strncpy( m_ipkgArgs.dest, destination, destination.length() ); | 310 | strncpy( m_ipkgArgs.dest, destination, destination.length() ); |
294 | m_ipkgArgs.dest[ len - 1 ] = '\0'; | 311 | m_ipkgArgs.dest[ len - 1 ] = '\0'; |
295 | } | 312 | } |
296 | else | 313 | else |
297 | m_ipkgArgs.dest = 0x0; | 314 | m_ipkgArgs.dest = 0x0; |
298 | 315 | ||
299 | // Connect output signal to widget | 316 | // Connect output signal to widget |
317 | |||
300 | if ( rawOutput ) | 318 | if ( rawOutput ) |
301 | { | 319 | { |
302 | if ( slotOutput ) | 320 | // if ( slotOutput ) |
303 | connect( this, SIGNAL(execOutput(char *)), receiver, slotOutput ); | 321 | // connect( this, SIGNAL(signalIpkgMessage(char *)), receiver, slotOutput ); |
304 | } | 322 | } |
305 | else | 323 | else |
306 | { | 324 | { |
307 | // TODO - connect to local slot and parse output before emitting execOutput | 325 | // TODO - connect to local slot and parse output before emitting signalIpkgMessage |
308 | } | 326 | } |
309 | 327 | ||
310 | switch( command ) | 328 | switch( command ) |
311 | { | 329 | { |
312 | case OPackage::Update : ipkg_lists_update( &m_ipkgArgs ); | 330 | case OPackage::Update : { |
331 | connect( this, SIGNAL(signalIpkgMessage(char *)), receiver, slotOutput ); | ||
332 | ipkg_lists_update( &m_ipkgArgs ); | ||
333 | }; | ||
313 | break; | 334 | break; |
314 | case OPackage::Upgrade : ipkg_packages_upgrade( &m_ipkgArgs ); | 335 | case OPackage::Upgrade : { |
336 | connect( this, SIGNAL(signalIpkgMessage(char *)), receiver, slotOutput ); | ||
337 | ipkg_packages_upgrade( &m_ipkgArgs ); | ||
338 | }; | ||
315 | break; | 339 | break; |
316 | case OPackage::Install : { | 340 | case OPackage::Install : { |
341 | connect( this, SIGNAL(signalIpkgMessage(char *)), receiver, slotOutput ); | ||
317 | for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) | 342 | for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) |
318 | { | 343 | { |
319 | ipkg_packages_install( &m_ipkgArgs, (*it) ); | 344 | ipkg_packages_install( &m_ipkgArgs, (*it) ); |
320 | } | 345 | } |
321 | }; | 346 | }; |
322 | break; | 347 | break; |
323 | case OPackage::Remove : { | 348 | case OPackage::Remove : { |
349 | connect( this, SIGNAL(signalIpkgMessage(char *)), receiver, slotOutput ); | ||
324 | for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) | 350 | for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) |
325 | { | 351 | { |
326 | ipkg_packages_remove( &m_ipkgArgs, (*it), true ); | 352 | ipkg_packages_remove( &m_ipkgArgs, (*it), true ); |
327 | } | 353 | } |
328 | }; | 354 | }; |
329 | break; | 355 | break; |
330 | case OPackage::Download : { | 356 | case OPackage::Download : { |
357 | connect( this, SIGNAL(signalIpkgMessage(char *)), receiver, slotOutput ); | ||
331 | for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) | 358 | for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) |
332 | { | 359 | { |
333 | ipkg_packages_download( &m_ipkgArgs, (*it) ); | 360 | ipkg_packages_download( &m_ipkgArgs, (*it) ); |
334 | } | 361 | } |
335 | }; | 362 | }; |
336 | break; | 363 | break; |
364 | case OPackage::Info : { | ||
365 | connect( this, SIGNAL(signalIpkgStatus(char *)), receiver, slotOutput ); | ||
366 | ipkg_packages_info( &m_ipkgArgs, (*parameters->begin()), &fIpkgStatus, 0x0 ); | ||
367 | }; | ||
368 | break; | ||
369 | case OPackage::Files : { | ||
370 | connect( this, SIGNAL(signalIpkgList(char *)), receiver, slotOutput ); | ||
371 | ipkg_package_files( &m_ipkgArgs, (*parameters->begin()), &fIpkgFiles, 0x0 ); | ||
372 | }; | ||
373 | break; | ||
337 | default : break; | 374 | default : break; |
338 | }; | 375 | }; |
339 | 376 | ||
340 | return true; | 377 | return true; |
341 | } | 378 | } |
342 | 379 | ||
343 | void OIpkg::ipkgOutput( char *msg ) | 380 | void OIpkg::ipkgMessage( char *msg ) |
381 | { | ||
382 | emit signalIpkgMessage( msg ); | ||
383 | } | ||
384 | |||
385 | void OIpkg::ipkgStatus( char *status ) | ||
386 | { | ||
387 | emit signalIpkgStatus( status ); | ||
388 | } | ||
389 | |||
390 | void OIpkg::ipkgList( char *filelist ) | ||
344 | { | 391 | { |
345 | emit execOutput( msg ); | 392 | emit signalIpkgList( filelist ); |
346 | } | 393 | } |
347 | 394 | ||
348 | void OIpkg::loadConfiguration() | 395 | void OIpkg::loadConfiguration() |
349 | { | 396 | { |
350 | if ( m_confInfo ) | 397 | if ( m_confInfo ) |
351 | delete m_confInfo; | 398 | delete m_confInfo; |
352 | 399 | ||
353 | // Load configuration item list | 400 | // Load configuration item list |