author | drw <drw> | 2004-02-05 16:34:04 (UTC) |
---|---|---|
committer | drw <drw> | 2004-02-05 16:34:04 (UTC) |
commit | ef8ece225a663f0ff1262989085fc214500beebe (patch) (side-by-side diff) | |
tree | 2d6902575eb29de18a0ed7f3a33acadabd37021b | |
parent | 823399a552c04821fb0b49d816d733fa21a12a21 (diff) | |
download | opie-ef8ece225a663f0ff1262989085fc214500beebe.zip opie-ef8ece225a663f0ff1262989085fc214500beebe.tar.gz opie-ef8ece225a663f0ff1262989085fc214500beebe.tar.bz2 |
Completed package information dialog and a couple of other minor tweaks
-rw-r--r-- | noncore/settings/packagemanager/ChangeLog | 5 | ||||
-rw-r--r-- | noncore/settings/packagemanager/mainwindow.cpp | 5 | ||||
-rw-r--r-- | noncore/settings/packagemanager/oipkg.cpp | 69 | ||||
-rw-r--r-- | noncore/settings/packagemanager/oipkg.h | 8 | ||||
-rw-r--r-- | noncore/settings/packagemanager/opackage.cpp | 5 | ||||
-rw-r--r-- | noncore/settings/packagemanager/opackage.h | 15 | ||||
-rw-r--r-- | noncore/settings/packagemanager/packageinfodlg.cpp | 96 | ||||
-rw-r--r-- | noncore/settings/packagemanager/packageinfodlg.h | 10 |
8 files changed, 169 insertions, 44 deletions
diff --git a/noncore/settings/packagemanager/ChangeLog b/noncore/settings/packagemanager/ChangeLog index efa75b1..72e6169 100644 --- a/noncore/settings/packagemanager/ChangeLog +++ b/noncore/settings/packagemanager/ChangeLog @@ -1,8 +1,13 @@ +2004-mm-dd Dan Williams <drw@handhelds.org> + + * Package information dialog implemented + * What's This app icon enabled + 2004-01-23 Dan Williams <drw@handhelds.org> * Added package download functionality * Have Opie update links after install/removal so that apps will display properly in Launcher 2004-01-20 Dan Williams <drw@handhelds.org> diff --git a/noncore/settings/packagemanager/mainwindow.cpp b/noncore/settings/packagemanager/mainwindow.cpp index 05f21bc..8b374ab 100644 --- a/noncore/settings/packagemanager/mainwindow.cpp +++ b/noncore/settings/packagemanager/mainwindow.cpp @@ -44,18 +44,18 @@ #include "mainwindow.h" #include "installdlg.h" #include "filterdlg.h" #include "promptdlg.h" #include "entrydlg.h" #include "packageinfodlg.h" -MainWindow::MainWindow( QWidget *parent, const char *name, WFlags fl ) - : QMainWindow( parent, name, fl || WStyle_ContextHelp ) +MainWindow::MainWindow( QWidget *parent, const char *name, WFlags /*fl*/ ) + : QMainWindow( parent, name, WStyle_ContextHelp ) , m_config( "packman" ) , m_packman( &m_config, this ) , m_menuBar( this ) , m_toolBar( this ) , m_findBar( this ) , m_widgetStack( this ) , m_packageList( this ) , m_statusWidget( this ) @@ -670,14 +670,13 @@ void MainWindow::slotFindNext() } void MainWindow::slotDisplayPackageInfo( QListViewItem *packageItem ) { QString packageName( ( static_cast<QCheckListItem*>( packageItem ) )->text() ); // Create package manager output widget PackageInfoDlg *dlg = new PackageInfoDlg( this, &m_packman, packageName ); - connect( dlg, SIGNAL(closeInfoDlg()), this, SLOT(slotCloseDlg()) ); // Display widget m_widgetStack.addWidget( dlg, 3 ); m_widgetStack.raiseWidget( dlg ); } 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 @@ If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "oipkg.h" +#include <stdio.h> #include <stdlib.h> #include <string.h> #include <qdir.h> #include <qfile.h> #include <qmessagebox.h> #include <qtextstream.h> const QString IPKG_CONF = "/etc/ipkg.conf"; // Fully-qualified name of Ipkg primary configuration file const QString IPKG_CONF_DIR = "/etc/ipkg"; // Directory of secondary Ipkg configuration files const QString IPKG_PKG_PATH = "/usr/lib/ipkg/lists"; // Directory containing server package lists const QString IPKG_STATUS_PATH = "usr/lib/ipkg/status"; // Destination status file location OIpkg *oipkg; -int fIpkgMessage( ipkg_conf_t */*conf*/, message_level_t /*level*/, char *msg ) +// Ipkg callback functions + +int fsignalIpkgMessage( ipkg_conf_t */*conf*/, message_level_t /*level*/, char *msg ) { - oipkg->ipkgOutput( msg ); + oipkg->ipkgMessage( msg ); return 0; } -char* fIpkgResponse( char */*question*/ ) +char *fIpkgResponse( char */*question*/ ) { return 0x0; } +int fIpkgStatus( char */*name*/, int /*status*/, char *desc, void */*userdata*/ ) +{ + oipkg->ipkgStatus( desc ); + return 0; +} + +int fIpkgFiles( char */*name*/, char *desc, char */*version*/, pkg_state_status_t /*status*/, + void */*userdata*/ ) +{ +printf( "*****List*****\n%s\n", desc ); + oipkg->ipkgList( desc ); + return 0; +} + OIpkg::OIpkg( Config *config, QObject *parent, const char *name ) : QObject( parent, name ) , m_config( config ) , m_confInfo( NULL ) , m_ipkgExecOptions( 0 ) , m_ipkgExecVerbosity( 1 ) { oipkg = this; // Initialize libipkg - if ( ipkg_init( &fIpkgMessage, &fIpkgResponse, &m_ipkgArgs ) ) + if ( ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ) ) QMessageBox::critical( 0, tr( "OIpkg" ), tr( "Error initialing libipkg" ) ); // Default ipkg run-time arguments m_ipkgArgs.noaction = false; m_ipkgArgs.force_defaults = true; } OIpkg::~OIpkg() @@ -292,62 +309,92 @@ bool OIpkg::executeCommand( OPackage::Command command, QStringList *parameters, m_ipkgArgs.dest = (char *)malloc( len ); strncpy( m_ipkgArgs.dest, destination, destination.length() ); m_ipkgArgs.dest[ len - 1 ] = '\0'; } else m_ipkgArgs.dest = 0x0; // Connect output signal to widget + if ( rawOutput ) { - if ( slotOutput ) - connect( this, SIGNAL(execOutput(char *)), receiver, slotOutput ); +// if ( slotOutput ) +// connect( this, SIGNAL(signalIpkgMessage(char *)), receiver, slotOutput ); } else { - // TODO - connect to local slot and parse output before emitting execOutput + // TODO - connect to local slot and parse output before emitting signalIpkgMessage } switch( command ) { - case OPackage::Update : ipkg_lists_update( &m_ipkgArgs ); + case OPackage::Update : { + connect( this, SIGNAL(signalIpkgMessage(char *)), receiver, slotOutput ); + ipkg_lists_update( &m_ipkgArgs ); + }; break; - case OPackage::Upgrade : ipkg_packages_upgrade( &m_ipkgArgs ); + case OPackage::Upgrade : { + connect( this, SIGNAL(signalIpkgMessage(char *)), receiver, slotOutput ); + ipkg_packages_upgrade( &m_ipkgArgs ); + }; break; case OPackage::Install : { + connect( this, SIGNAL(signalIpkgMessage(char *)), receiver, slotOutput ); for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) { ipkg_packages_install( &m_ipkgArgs, (*it) ); } }; break; case OPackage::Remove : { + connect( this, SIGNAL(signalIpkgMessage(char *)), receiver, slotOutput ); for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) { ipkg_packages_remove( &m_ipkgArgs, (*it), true ); } }; break; case OPackage::Download : { + connect( this, SIGNAL(signalIpkgMessage(char *)), receiver, slotOutput ); for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) { ipkg_packages_download( &m_ipkgArgs, (*it) ); } }; break; + case OPackage::Info : { + connect( this, SIGNAL(signalIpkgStatus(char *)), receiver, slotOutput ); + ipkg_packages_info( &m_ipkgArgs, (*parameters->begin()), &fIpkgStatus, 0x0 ); + }; + break; + case OPackage::Files : { + connect( this, SIGNAL(signalIpkgList(char *)), receiver, slotOutput ); + ipkg_package_files( &m_ipkgArgs, (*parameters->begin()), &fIpkgFiles, 0x0 ); + }; + break; default : break; }; return true; } -void OIpkg::ipkgOutput( char *msg ) +void OIpkg::ipkgMessage( char *msg ) +{ + emit signalIpkgMessage( msg ); +} + +void OIpkg::ipkgStatus( char *status ) +{ + emit signalIpkgStatus( status ); +} + +void OIpkg::ipkgList( char *filelist ) { - emit execOutput( msg ); + emit signalIpkgList( filelist ); } void OIpkg::loadConfiguration() { if ( m_confInfo ) delete m_confInfo; // Load configuration item list diff --git a/noncore/settings/packagemanager/oipkg.h b/noncore/settings/packagemanager/oipkg.h index 824fa17..ea126cf 100644 --- a/noncore/settings/packagemanager/oipkg.h +++ b/noncore/settings/packagemanager/oipkg.h @@ -77,25 +77,29 @@ public: OPackageList *installedPackages( const QString &destName = QString::null, const QString &destPath = QString::null ); bool executeCommand( OPackage::Command command = OPackage::NotDefined, QStringList *parameters = 0x0, const QString &destination = QString::null, const QObject *receiver = 0x0, const char *slotOutput = 0x0, bool rawOutput = true ); void abortCommand(); - void ipkgOutput( char *msg ); + void ipkgMessage( char *msg ); + void ipkgStatus( char *status ); + void ipkgList( char *filelist ); private: Config *m_config; // Pointer to application configuration file args_t m_ipkgArgs; // libipkg configuration arguments OConfItemList *m_confInfo; // Contains info from all Ipkg configuration files int m_ipkgExecOptions; // Bit-mapped flags for Ipkg execution options int m_ipkgExecVerbosity; // Ipkg execution verbosity level void loadConfiguration(); OConfItemList *filterConfItems( OConfItem::Type typefilter = OConfItem::NotDefined ); signals: - void execOutput( char *msg ); + void signalIpkgMessage( char *msg ); + void signalIpkgStatus( char *status ); + void signalIpkgList( char *filelist ); }; #endif diff --git a/noncore/settings/packagemanager/opackage.cpp b/noncore/settings/packagemanager/opackage.cpp index 34717e3..37963fa 100644 --- a/noncore/settings/packagemanager/opackage.cpp +++ b/noncore/settings/packagemanager/opackage.cpp @@ -27,17 +27,20 @@ Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "opackage.h" OPackage::OPackage( const QString &name, const QString &version, const QString &versionInstalled, - const QString &source, const QString &destination, const QString &category ) + const QString &source, const QString &destination, const QString &category, + const QString &information, const QString &files ) : m_name( name ) , m_version( version ) , m_versionInstalled( versionInstalled ) , m_source( source ) , m_destination( destination ) , m_category( category ) + , m_information( information ) + , m_files( files ) { } diff --git a/noncore/settings/packagemanager/opackage.h b/noncore/settings/packagemanager/opackage.h index 1e2e49f..fbd9ec0 100644 --- a/noncore/settings/packagemanager/opackage.h +++ b/noncore/settings/packagemanager/opackage.h @@ -35,40 +35,47 @@ #include <qlist.h> #include <qstring.h> class OPackage { public: enum Command { Install, Remove, Update, Upgrade, Download, Info, Files, Version, NotDefined }; - OPackage( const QString &name = 0x0, - const QString &version = 0x0, const QString &versionInstalled = 0x0, - const QString &source = 0x0, const QString &destination = 0x0, - const QString &category = "misc" ); + OPackage( const QString &name= QString::null, + const QString &version= QString::null, const QString &versionInstalled= QString::null, + const QString &source= QString::null, const QString &destination= QString::null, + const QString &category = "misc", const QString &information = QString::null, + const QString &files = QString::null ); const QString &name() { return m_name; } const QString &version() { return m_version; } const QString &versionInstalled() { return m_versionInstalled; } const QString &source() { return m_source; } const QString &destination() { return m_destination; } const QString &category() { return m_category; } + const QString &information() { return m_information; } + const QString &files() { return m_files; } void setName( const QString &name ) { m_name = name; } void setVersion( const QString &version ) { m_version = version; } void setVersionInstalled( const QString &version ) { m_versionInstalled = version; } void setSource( const QString &source ) { m_source = source; } void setDestination( const QString &destination ) { m_destination = destination; } void setCategory( const QString &category ) { m_category = category; } + void setInformation( const QString &information ) { m_information = information; } + void setFiles( const QString &files ) { m_files = files; } private: QString m_name; // Name of item QString m_version; // Available version number of item QString m_versionInstalled; // Installed version number of item, null if not installed QString m_source; // Source feed of available version QString m_destination; // Location item is installed to, null if not installed QString m_category; // Item category + QString m_information; // Package information + QString m_files; // File list information }; typedef QList<OPackage> OPackageList; typedef QListIterator<OPackage> OPackageListIterator; #endif diff --git a/noncore/settings/packagemanager/packageinfodlg.cpp b/noncore/settings/packagemanager/packageinfodlg.cpp index 26356b9..7daf336 100644 --- a/noncore/settings/packagemanager/packageinfodlg.cpp +++ b/noncore/settings/packagemanager/packageinfodlg.cpp @@ -23,16 +23,18 @@ -_. . . )=. = see the file COPYING. If not, write to the -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "packageinfodlg.h" +#include "opackage.h" +#include "opackagemanager.h" #include <qlayout.h> #include <qpushbutton.h> #include <qpe/resource.h> #include <opie/otabwidget.h> @@ -41,42 +43,98 @@ PackageInfoDlg::PackageInfoDlg( QWidget *parent, OPackageManager *pm, const QStr , m_packman( pm ) , m_information( this ) , m_files( this ) { // Initialize UI if ( parent ) parent->setCaption( package ); - QVBoxLayout *layout = new QVBoxLayout( this, 4, 0 ); + QVBoxLayout *layout = new QVBoxLayout( this, 4, 2 ); OTabWidget *tabWidget = new OTabWidget( this ); layout->addWidget( tabWidget ); - QPushButton *btn = new QPushButton( Resource::loadPixmap( "enter" ), tr( "Close" ), this ); - layout->addWidget( btn ); - connect( btn, SIGNAL(clicked()), this, SLOT(slotBtnClose()) ); - // Information tab m_information.reparent( tabWidget, QPoint( 0, 0 ) ); m_information.setReadOnly( true ); tabWidget->addTab( &m_information, "UtilsIcon", tr( "Information" ) ); - // Files tab - QWidget *filesWidget = new QWidget( tabWidget ); - QVBoxLayout *filesLayout = new QVBoxLayout( filesWidget, 4, 0 ); - m_files.reparent( filesWidget, QPoint( 0, 0 ) ); - m_files.setReadOnly( true ); - filesLayout->addWidget( &m_files ); + // Retrive package information + m_package = m_packman->findPackage( package ); + if ( !m_package ) + { + m_information.setText( tr( "Unable to retrieve package information." ) ); + return; + } + + // Display package information + if ( !m_package->information().isNull() ) + m_information.setText( m_package->information() ); + else + { + // Package information is not cached, retrieve it + QStringList list( package ); + m_packman->executeCommand( OPackage::Info, &list, QString::null, this, SLOT(slotInfo(char*)), true ); + } + + // Files tab (display only if package is installed) + if ( !m_package->versionInstalled().isNull() ) + { + QWidget *filesWidget = new QWidget( tabWidget ); + QVBoxLayout *filesLayout = new QVBoxLayout( filesWidget, 2, 2 ); + m_files.reparent( filesWidget, QPoint( 0, 0 ) ); + m_files.setReadOnly( true ); + filesLayout->addWidget( &m_files ); + + QPushButton *btn = new QPushButton( Resource::loadPixmap( "packagemanager/apply" ), + tr( "Retrieve file list" ), filesWidget ); + filesLayout->addWidget( btn ); + connect( btn, SIGNAL(clicked()), this, SLOT(slotBtnFileScan()) ); + tabWidget->addTab( filesWidget, "binary", tr( "File list" ) ); + + tabWidget->setCurrentTab( tr( "Information" ) ); + + // If file list is already cached, display + if ( !m_package->files().isNull() ) + m_files.setText( m_package->files() ); + } + else + m_files.hide(); +} + +PackageInfoDlg::~PackageInfoDlg() +{ + if ( !m_package ) + return; + + // Cache package information + if ( !m_information.text().isNull() ) + m_package->setInformation( m_information.text() ); - btn = new QPushButton( Resource::loadPixmap( "packagemanager/apply" ), tr( "Retrieve file list" ), - filesWidget ); - filesLayout->addWidget( btn ); -// TODO connect( btn, SIGNAL(clicked()), this, SLOT(slotFileScan()) ); - tabWidget->addTab( filesWidget, "binary", tr( "Files" ) ); + // Cache package file list + if ( !m_files.text().isNull() ) + m_package->setFiles( m_files.text() ); +} - tabWidget->setCurrentTab( tr( "Information" ) ); +void PackageInfoDlg::slotBtnFileScan() +{ + m_files.clear(); + + QStringList list( m_package->name() ); + m_packman->executeCommand( OPackage::Files, &list, QString::null, this, SLOT(slotFiles(char*)), true ); } -void PackageInfoDlg::slotBtnClose() +void PackageInfoDlg::slotInfo( char *info ) { - emit closeInfoDlg(); + m_information.append( info ); +} + +void PackageInfoDlg::slotFiles( char *filelist ) +{ + QString str = filelist; + + // Skip first line of output ("Package xxx is installed...") + if ( str.startsWith( "Package " ) ) + str = str.right( str.length() - str.find( '\n' ) - 1 ); + + m_files.append( str ); } diff --git a/noncore/settings/packagemanager/packageinfodlg.h b/noncore/settings/packagemanager/packageinfodlg.h index 09af6f4..13a15e2 100644 --- a/noncore/settings/packagemanager/packageinfodlg.h +++ b/noncore/settings/packagemanager/packageinfodlg.h @@ -34,32 +34,34 @@ #include <qwidget.h> #include <opie/oprocess.h> #include "opackage.h" class QPushButton; +class OPackage; class OPackageManager; class PackageInfoDlg : public QWidget { Q_OBJECT public: PackageInfoDlg( QWidget *parent = 0x0, OPackageManager *pm = 0x0, const QString &package = QString::null ); + ~PackageInfoDlg(); private: OPackageManager *m_packman; // Pointer to application instance of package manager + OPackage *m_package; // Pointer to package to display information for // UI controls QMultiLineEdit m_information; // Multi-line edit to display package information QMultiLineEdit m_files; // Multi-line edit to display package file list private slots: - void slotBtnClose(); - -signals: - void closeInfoDlg(); + void slotBtnFileScan(); + void slotInfo( char *info ); + void slotFiles( char *filelist ); }; #endif |