22 files changed, 105 insertions, 139 deletions
diff --git a/noncore/settings/packagemanager/ChangeLog b/noncore/settings/packagemanager/ChangeLog index d53a2b3..c9e33c4 100644 --- a/noncore/settings/packagemanager/ChangeLog +++ b/noncore/settings/packagemanager/ChangeLog @@ -1,28 +1,37 @@ +2004-04-21 Dan Williams <drw@handhelds.org> + + * Released version 0.4.0 + * Added saving of ipkg configuration information + * Re-initialize ipkg when configuration information changes + * Added QWhatsThis for all UI controls + * Remove Location from OConfItem as it is not used/needed + * Re-ordered includes to follow Opie standards + 2004-02-13 Dan Williams <drw@handhelds.org> * Released version 0.3.0 * Fix handling of filtering options in View menu * Do proper version string comparison * Fix string alignment code in PromptDlg to eliminate QT warning messages 2004-02-12 Dan Williams <drw@handhelds.org> * Package information dialog implemented * What's This app icon enabled * Changed all QDialog::exec() occurences to QPEApplication::execDialog() 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> * Released version 0.2.0 * Converted to use libipkg in place of spawning ipkg process 2004-01-13 Dan Williams <drw@handhelds.org> * Released version 0.1.0 * Initial check-in of new package management client to eventually replace AQPkg diff --git a/noncore/settings/packagemanager/README b/noncore/settings/packagemanager/README index 9324f9c..bf93c98 100644 --- a/noncore/settings/packagemanager/README +++ b/noncore/settings/packagemanager/README @@ -1,55 +1,55 @@ /************************************************************************ /* /* Opie - Package Manager /* ======================== -/* Version 0.3.0 +/* Version 0.4.0 /* /* A package management client for Opie /* /************************************************************************ ------------------------------------------------------- Release Notes for Opie-PackageManager - January, 2004 ------------------------------------------------------- ====================== = To-do = ====================== - See $OPIEDIR/noncore/settings/packagemanager/TODO for more info. ====================== = Build = ====================== In order to build opie-packagemanager, libipkg needs to be present on the build system along with the appropriate headers. - libipkg source (best to use version 109 or greater): - Familiar CVS directory: familiar/dist/ipkg/C (e.g. 'cvs co familiar/dist/ipkg/C') - FTP: ftp://handhelds.org/linux/packages/ipkg - before building opie-packagemanager, define the environmental variable IPKGDIR to point to the directory containing the ipkg source code - e.g. 'export IPKGDIR=$HOME/familiar/dist/ipkg/C' ====================== = Run = ====================== - In order to use opie-packagemanager, libipkg must be installed on the system. ====================== = Credits = ====================== - Opie-PackageManager is (C) 2003-2004 Dan Williams ====================== = Links = ====================== - Opie Project: http://opie.handhelds.org - OpenZaurus Project: http://openzaurus.org - Familiar Project: http://familiar.handhelds.org diff --git a/noncore/settings/packagemanager/TODO b/noncore/settings/packagemanager/TODO index 448ade3..633c589 100644 --- a/noncore/settings/packagemanager/TODO +++ b/noncore/settings/packagemanager/TODO @@ -1,28 +1,27 @@ /************************************************************************ /* /* Opie - Package Manager /* ======================== -/* Version 0.3.0 +/* Version 0.4.0 /* /* A package management client for Opie /* /************************************************************************ --------------------------------------------- To-do for Opie-PackageManager - April, 2004 --------------------------------------------- ====================== = Current release = ====================== -1. Save configuration information (i.e. /etc/ipkg.conf) -2. Link non-root destination apps -3. Implement QCOP interface for installing, removing, etc. -4. Redesign configuration dialog +1. Link non-root destination apps +2. Implement QCOP interface for installing, removing, etc. +3. Redesign configuration dialog ====================== = Future releases = ====================== 1. ???
\ No newline at end of file diff --git a/noncore/settings/packagemanager/entrydlg.cpp b/noncore/settings/packagemanager/entrydlg.cpp index 663abd2..fd275e1 100644 --- a/noncore/settings/packagemanager/entrydlg.cpp +++ b/noncore/settings/packagemanager/entrydlg.cpp @@ -1,85 +1,85 @@ /* This file is part of the OPIE Project =. Copyright (c) 2004 Dan Williams <drw@handhelds.org> .=l. .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This file is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General ..}^=.= = ; Public License for more details. ++= -. .` .: : = ...= . :.=- You should have received a copy of the GNU -. .:....=;==+<; General Public License along with this file; -_. . . )=. = see the file COPYING. If not, write to the -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "entrydlg.h" +#include <qpe/qpeapplication.h> + #include <qlabel.h> #include <qlayout.h> #include <qlineedit.h> #include <qpushbutton.h> -#include <qpe/qpeapplication.h> - EntryDlg::EntryDlg( const QString &label, QWidget* parent, const char* name, bool modal ) : QDialog( parent, name, modal ) { QVBoxLayout *vbox = new QVBoxLayout( this, 6, 6 ); QLabel *l = new QLabel( label, this ); l->setAlignment( AlignLeft | AlignTop | WordBreak ); vbox->addWidget( l ); m_entry = new QLineEdit( this ); vbox->addWidget( m_entry ); connect( m_entry, SIGNAL(returnPressed()), this, SLOT(tryAccept()) ); } void EntryDlg::setText( const QString &text ) { m_entry->setText( text ); m_entry->selectAll(); } QString EntryDlg::getText() { return m_entry->text(); } QString EntryDlg::getText( const QString &caption, const QString &label, const QString &text, bool *ok, QWidget *parent, const char *name ) { EntryDlg *dlg = new EntryDlg( label, parent, name, true ); dlg->setCaption( caption ); dlg->setText( text ); QString result; *ok = ( QPEApplication::execDialog( dlg ) == QDialog::Accepted ); if ( *ok ) result = dlg->getText(); delete dlg; return result; } void EntryDlg::tryAccept() { if ( !m_entry->text().isEmpty() ) accept(); } diff --git a/noncore/settings/packagemanager/filterdlg.h b/noncore/settings/packagemanager/filterdlg.h index de9ea80..bd89b42 100644 --- a/noncore/settings/packagemanager/filterdlg.h +++ b/noncore/settings/packagemanager/filterdlg.h @@ -1,101 +1,101 @@ /* This file is part of the OPIE Project =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> .=l. .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This file is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General ..}^=.= = ; Public License for more details. ++= -. .` .: : = ...= . :.=- You should have received a copy of the GNU -. .:....=;==+<; General Public License along with this file; -_. . . )=. = see the file COPYING. If not, write to the -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef FILTERDLG_H #define FILTERDLG_H +#include "opackagemanager.h" + #include <qcheckbox.h> #include <qdialog.h> #include <qcombobox.h> #include <qlayout.h> #include <qlineedit.h> #include <qscrollview.h> -#include "opackagemanager.h" - class FilterDlg : public QDialog { Q_OBJECT public: FilterDlg( QWidget *parent = 0x0, OPackageManager *pm = 0x0, const QString &name = 0x0, const QString &server = 0x0, const QString &destination = 0x0, OPackageManager::Status status = OPackageManager::All, const QString &category = 0x0 ); QString name() { return m_nameCB->isChecked() ? m_name->text() : QString::null; }; QString server() { return m_serverCB->isChecked() ? m_server->currentText() : QString::null; }; QString destination() { return m_destCB->isChecked() ? m_destination->currentText() : QString::null; }; OPackageManager::Status status() { if ( m_statusCB->isChecked() ) { if ( m_status->currentText() == tr( "All" ) ) return OPackageManager::All; else if ( m_status->currentText() == tr( "Installed" ) ) return OPackageManager::Installed; else if ( m_status->currentText() == tr( "Not installed" ) ) return OPackageManager::NotInstalled; else if ( m_status->currentText() == tr( "Updated" ) ) return OPackageManager::Updated; } return OPackageManager::NotDefined; }; QString category() { return m_categoryCB->isChecked() ? m_category->currentText() : QString::null; }; private: QCheckBox *m_nameCB; QCheckBox *m_serverCB; QCheckBox *m_destCB; QCheckBox *m_statusCB; QCheckBox *m_categoryCB; QLineEdit *m_name; QComboBox *m_server; QComboBox *m_destination; QComboBox *m_status; QComboBox *m_category; void initItem( QComboBox *comboBox, QCheckBox *checkBox, const QString &selection ); private slots: void slotNameSelected( bool ); void slotServerSelected( bool ); void slotDestSelected( bool ); void slotStatusSelected( bool ); void slotStatusChanged( const QString & ); void slotCategorySelected( bool ); }; #endif diff --git a/noncore/settings/packagemanager/global.h b/noncore/settings/packagemanager/global.h deleted file mode 100644 index 0fe5b85..0000000 --- a/noncore/settings/packagemanager/global.h +++ b/dev/null @@ -1,37 +0,0 @@ -/* - This file is part of the Opie Project - - Copyright (c) 2003 Dan Williams <drw@handhelds.org> - =. - .=l. - .>+-= - _;:, .> :=|. This program is free software; you can -.> <`_, > . <= redistribute it and/or modify it under -:`=1 )Y*s>-.-- : the terms of the GNU Library General Public -.="- .-=="i, .._ License as published by the Free Software - - . .-<_> .<> Foundation; either version 2 of the License, - ._= =} : or (at your option) any later version. - .%`+i> _;_. - .i_,=:_. -<s. This program is distributed in the hope that - + . -:. = it will be useful, but WITHOUT ANY WARRANTY; - : .. .:, . . . without even the implied warranty of - =_ + =;=|` MERCHANTABILITY or FITNESS FOR A - _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU -..}^=.= = ; Library General Public License for more -++= -. .` .: details. - : = ...= . :.=- - -. .:....=;==+<; You should have received a copy of the GNU - -_. . . )=. = Library General Public License along with - -- :-=` this library; see the file COPYING.LIB. - If not, write to the Free Software Foundation, - Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. - -*/ - -#ifndef GLOBAL_H -#define GLOBAL_H - -#define VERSION "0.0.0" - -#endif
\ No newline at end of file diff --git a/noncore/settings/packagemanager/installdlg.cpp b/noncore/settings/packagemanager/installdlg.cpp index 4a55c10..0cb30e2 100644 --- a/noncore/settings/packagemanager/installdlg.cpp +++ b/noncore/settings/packagemanager/installdlg.cpp @@ -1,148 +1,147 @@ /* This file is part of the OPIE Project =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> .=l. .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This file is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General ..}^=.= = ; Public License for more details. ++= -. .` .: : = ...= . :.=- You should have received a copy of the GNU -. .:....=;==+<; General Public License along with this file; -_. . . )=. = see the file COPYING. If not, write to the -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "installdlg.h" -#include <sys/vfs.h> +#include <opie2/ofiledialog.h> + +#include <qpe/fileselector.h> +#include <qpe/resource.h> +#include <qpe/storage.h> #include <qapplication.h> #include <qcombobox.h> #include <qfileinfo.h> #include <qgroupbox.h> #include <qlabel.h> #include <qlayout.h> #include <qmap.h> #include <qmultilineedit.h> #include <qpushbutton.h> -#include <qpe/fileselector.h> -#include <qpe/resource.h> -#include <qpe/storage.h> - -#include <opie2/ofiledialog.h> +#include <sys/vfs.h> #include "opackagemanager.h" -using namespace Opie::Ui; InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &caption, bool showDestInfo, OPackage::Command command1, QStringList *packages1, OPackage::Command command2, QStringList *packages2, OPackage::Command command3, QStringList *packages3 ) : QWidget( 0x0 ) , m_packman( pm ) , m_numCommands( 0 ) , m_currCommand( 0 ) { // Save command/package list information if ( command1 != OPackage::NotDefined ) { m_command[ m_numCommands ] = command1; m_packages[ m_numCommands ] = packages1; ++m_numCommands; } if ( command2 != OPackage::NotDefined ) { m_command[ m_numCommands ] = command2; m_packages[ m_numCommands ] = packages2; ++m_numCommands; } if ( command3 != OPackage::NotDefined ) { m_command[ m_numCommands ] = command3; m_packages[ m_numCommands ] = packages3; ++m_numCommands; } // Initialize UI if ( parent ) parent->setCaption( caption ); QGridLayout *layout = new QGridLayout( this, 4, 2, 2, 4 ); if ( showDestInfo ) { QLabel *label = new QLabel( tr( "Destination" ), this ); layout->addWidget( label, 0, 0 ); m_destination = new QComboBox( this ); m_destination->insertStringList( *(m_packman->destinations()) ); layout->addWidget( m_destination, 0, 1 ); connect( m_destination, SIGNAL(highlighted(const QString&)), this, SLOT(slotDisplayAvailSpace(const QString&)) ); label = new QLabel( tr( "Space Avail" ), this ); layout->addWidget( label, 1, 0 ); m_availSpace = new QLabel( this ); layout->addWidget( m_availSpace, 1, 1 ); // TODO - select correct destination slotDisplayAvailSpace( m_destination->currentText() ); } else { m_destination = 0x0; m_availSpace = 0x0; } QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this ); groupBox->layout()->setSpacing( 0 ); groupBox->layout()->setMargin( 4 ); QVBoxLayout *groupBoxLayout = new QVBoxLayout( groupBox->layout() ); m_output = new QMultiLineEdit( groupBox ); m_output->setReadOnly( true ); groupBoxLayout->addWidget( m_output ); layout->addMultiCellWidget( groupBox, 2, 2, 0, 1 ); m_btnStart = new QPushButton( Resource::loadPixmap( "packagemanager/apply" ), tr( "Start" ), this ); layout->addWidget( m_btnStart, 3, 0 ); connect( m_btnStart, SIGNAL(clicked()), this, SLOT(slotBtnStart()) ); m_btnOptions = new QPushButton( Resource::loadPixmap( "SettingsIcon" ), tr( "Options" ), this ); layout->addWidget( m_btnOptions, 3, 1 ); connect( m_btnOptions, SIGNAL( clicked() ), this, SLOT(slotBtnOptions()) ); // Display packages being acted upon in output widget for( int i = 0; i < m_numCommands; i++ ) { if ( m_packages[ i ] ) { QString lineStr = tr( "Packages to " ); switch( m_command[ i ] ) { case OPackage::Install : lineStr.append( tr( "install" ) ); break; case OPackage::Remove : lineStr.append( tr( "remove" ) ); break; case OPackage::Upgrade : lineStr.append( tr( "upgrade" ) ); break; case OPackage::Download : lineStr.append( tr( "download" ) ); break; default : break; @@ -183,120 +182,120 @@ void InstallDlg::slotDisplayAvailSpace( const QString &destination ) // Get destination OConfItem *dest = m_packman->findConfItem( OConfItem::Destination, destination ); if ( dest ) { // Calculate available space struct statfs fs; if ( !statfs( dest->value(), &fs ) ) { long mult = fs.f_bsize / 1024; long div = 1024 / fs.f_bsize; if ( !mult ) mult = 1; if ( !div ) div = 1; long avail = fs.f_bavail * mult / div; space = tr( "%1 Kb" ).arg( avail ); } } // Display available space m_availSpace->setText( space ); } void InstallDlg::slotBtnStart() { QString btnText = m_btnStart->text(); if ( btnText == tr( "Abort" ) ) { // Prevent unexecuted commands from executing m_currCommand = 999; // Allow user to close dialog m_btnStart->setText( tr( "Close" ) ); m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) ); return; } else if ( btnText == tr( "Close" ) ) { // TODO - force reload of package data emit closeInstallDlg(); return; } // Start was clicked, start executing m_btnOptions->setEnabled( false ); if ( m_numCommands > 1 ) { m_btnStart->setText( tr( "Abort" ) ); m_btnStart->setIconSet( Resource::loadPixmap( "close" ) ); } else { m_btnStart->setEnabled( false ); } QString dest; if ( m_destination ) dest = m_destination->currentText(); for ( m_currCommand = 0; m_currCommand < m_numCommands; m_currCommand++ ) { // Execute next command m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], dest, this, SLOT(slotOutput(char*)), true ); } // All commands executed, allow user to close dialog m_btnStart->setEnabled( true ); m_btnStart->setText( tr( "Close" ) ); m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) ); m_btnOptions->setEnabled( true ); m_btnOptions->setText( tr( "Save output" ) ); m_btnOptions->setIconSet( Resource::loadPixmap( "save" ) ); } void InstallDlg::slotBtnOptions() { QString btnText = m_btnOptions->text(); if ( btnText == tr( "Options" ) ) { // Display configuration dialog (only options tab is enabled) m_packman->configureDlg( true ); return; } // Save output was clicked QMap<QString, QStringList> map; map.insert( tr( "All" ), QStringList() ); QStringList text; text << "text/*"; map.insert(tr( "Text" ), text ); text << "*"; map.insert( tr( "All" ), text ); - QString filename = OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map ); + QString filename = Opie::Ui::OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map ); if( !filename.isEmpty() ) { QString currentFileName = QFileInfo( filename ).fileName(); DocLnk doc; doc.setType( "text/plain" ); doc.setFile( filename ); doc.setName( currentFileName ); FileManager fm; fm.saveFile( doc, m_output->text() ); } } void InstallDlg::slotOutput( char *msg ) { // Allow processing of other events qApp->processEvents(); QString lineStr = msg; if ( lineStr[lineStr.length()-1] == '\n' ) lineStr.truncate( lineStr.length() - 1 ); m_output->append( lineStr ); m_output->setCursorPosition( m_output->numLines(), 0 ); } diff --git a/noncore/settings/packagemanager/main.cpp b/noncore/settings/packagemanager/main.cpp index c050e1a..3792881 100644 --- a/noncore/settings/packagemanager/main.cpp +++ b/noncore/settings/packagemanager/main.cpp @@ -1,35 +1,34 @@ /* This file is part of the OPIE Project =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> .=l. .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This file is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General ..}^=.= = ; Public License for more details. ++= -. .` .: : = ...= . :.=- You should have received a copy of the GNU -. .:....=;==+<; General Public License along with this file; -_. . . )=. = see the file COPYING. If not, write to the -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "mainwindow.h" #include <opie2/oapplicationfactory.h> -using namespace Opie::Core; -OPIE_EXPORT_APP( OApplicationFactory<MainWindow> ) +OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<MainWindow> ) diff --git a/noncore/settings/packagemanager/mainwindow.cpp b/noncore/settings/packagemanager/mainwindow.cpp index 810046f..991cc81 100644 --- a/noncore/settings/packagemanager/mainwindow.cpp +++ b/noncore/settings/packagemanager/mainwindow.cpp @@ -1,147 +1,147 @@ /* This file is part of the OPIE Project =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> .=l. .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This file is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General ..}^=.= = ; Public License for more details. ++= -. .` .: : = ...= . :.=- You should have received a copy of the GNU -. .:....=;==+<; General Public License along with this file; -_. . . )=. = see the file COPYING. If not, write to the -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ +#include "mainwindow.h" +#include "installdlg.h" +#include "filterdlg.h" +#include "promptdlg.h" +#include "entrydlg.h" +#include "packageinfodlg.h" + +#include <qpe/qcopenvelope_qws.h> +#include <qpe/qpeapplication.h> +#include <qpe/resource.h> + #include <qaction.h> #include <qdir.h> #include <qlayout.h> #include <qlineedit.h> #include <qmenubar.h> #include <qmessagebox.h> #include <qpopupmenu.h> #include <qtimer.h> #include <qtoolbar.h> #include <qwhatsthis.h> -#include <qpe/qcopenvelope_qws.h> -#include <qpe/qpeapplication.h> -#include <qpe/resource.h> - -#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, 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 ) , m_statusText( &m_statusWidget ) , m_statusBar( &m_statusWidget ) , m_iconUpdated( Resource::loadPixmap( "packagemanager/updated" ) ) , m_iconInstalled( Resource::loadPixmap( "installed" ) ) , m_iconNull( m_iconUpdated.size() ) , m_filterName( QString::null ) , m_filterServer( QString::null ) , m_filterDest( QString::null ) , m_filterStatus( OPackageManager::NotDefined ) , m_filterCategory( QString::null ) { // setCaption( tr( "Package Manager" ) ); m_iconNull.fill( colorGroup().base() ); connect( &m_widgetStack, SIGNAL(aboutToShow(QWidget*)), this, SLOT(slotWidgetStackShow(QWidget*)) ); // Initialize widget stack, package list and status widget initStatusWidget(); initPackageList(); m_widgetStack.addWidget( &m_statusWidget, 2 ); m_widgetStack.addWidget( &m_packageList, 1 ); setCentralWidget( &m_widgetStack ); // Initialize remaining user interface items initUI(); // Initialize package information QTimer::singleShot( 100, this, SLOT( initPackageInfo() ) ); } void MainWindow::closeEvent( QCloseEvent *event ) { // Close app only if either the package or status widgets are currently active bool close = m_widgetStack.visibleWidget() == &m_packageList || m_widgetStack.visibleWidget() == &m_statusWidget; if ( close ) { // TODO - write out application configuration settings // Write out package manager configuration settings m_packman.saveSettings(); event->accept(); } else { delete m_widgetStack.visibleWidget(); m_widgetStack.raiseWidget( &m_packageList ); event->ignore(); } } void MainWindow::initPackageList() { m_packageList.addColumn( tr( "Packages" ) ); QWhatsThis::add( &m_packageList, tr( "This is a listing of all packages.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nTap inside the box at the left to select a package. Tap and hold to view package details." ) ); QPEApplication::setStylusOperation( m_packageList.viewport(), QPEApplication::RightOnHold ); connect( &m_packageList, SIGNAL(rightButtonPressed(QListViewItem*,const QPoint&,int)), this, SLOT(slotDisplayPackageInfo(QListViewItem*)) ); } void MainWindow::initStatusWidget() { QVBoxLayout *layout = new QVBoxLayout( &m_statusWidget, 4, 4 ); m_statusText.setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); layout->addWidget( &m_statusText ); connect( &m_packman, SIGNAL(initStatus(int)), this, SLOT(slotInitStatusBar(int)) ); connect( &m_packman, SIGNAL(statusText(const QString&)), this, SLOT(slotStatusText(const QString&)) ); connect( &m_packman, SIGNAL(statusBar(int)), this, SLOT(slotStatusBar(int)) ); layout->addWidget( &m_statusBar ); } void MainWindow::initUI() { // Build menu and tool bars setToolBarsMovable( false ); m_menuBar.setHorizontalStretchable( true ); QMenuBar *mb = new QMenuBar( &m_menuBar ); mb->setMargin( 0 ); diff --git a/noncore/settings/packagemanager/mainwindow.h b/noncore/settings/packagemanager/mainwindow.h index fb555c5..632effb 100644 --- a/noncore/settings/packagemanager/mainwindow.h +++ b/noncore/settings/packagemanager/mainwindow.h @@ -1,139 +1,139 @@ /* This file is part of the OPIE Project =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> .=l. .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This file is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General ..}^=.= = ; Public License for more details. ++= -. .` .: : = ...= . :.=- You should have received a copy of the GNU -. .:....=;==+<; General Public License along with this file; -_. . . )=. = see the file COPYING. If not, write to the -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef MAINWINDOW_H #define MAINWINDOW_H +#include "opackagemanager.h" + +#include <qpe/config.h> + #include <qlabel.h> #include <qlistview.h> #include <qmainwindow.h> #include <qpixmap.h> #include <qprogressbar.h> #include <qtoolbar.h> #include <qwidgetstack.h> -#include <qpe/config.h> - -#include "opackagemanager.h" - class QAction; class QLineEdit; class MainWindow :public QMainWindow { Q_OBJECT public: MainWindow( QWidget *parent = 0x0, const char *name = 0x0, WFlags fl = 0 ); static QString appName() { return QString::fromLatin1( "packagemanager" ); }; protected: void closeEvent( QCloseEvent *event ); private: Config m_config; // Configuration file OPackageManager m_packman; // Package manager // Toolbars QToolBar m_menuBar; // Main toolbar containing menu QToolBar m_toolBar; // Main toolbar QToolBar m_findBar; // Find toolbar QWidgetStack m_widgetStack; // Main widget stack which contains m_packageList & m_statusWidget QListView m_packageList; // Main list view of all packages QLineEdit *m_findEdit; // Line edit box used for find toolbar // Status widget controls QWidget m_statusWidget; // Widget to display status during long operations QLabel m_statusText; // Text status message QProgressBar m_statusBar; // Progress bar showing % completed // Icon pixmaps QPixmap m_iconUpdated; // Cached icon which shows when package can be updated QPixmap m_iconInstalled; // Cached icon which shows when package is installed QPixmap m_iconNull; // Cached icon which shows when package is not installed // Menu/tool bar actions QAction *m_actionShowNotInstalled; // Action to show pakages not currently installed QAction *m_actionShowInstalled; // Action to show pakages currently installed QAction *m_actionShowUpdated; // Action to show pakages currently installed with update available QAction *m_actionFilter; // Action to filter packages QAction *m_actionFindNext; // Action to find next match // Cached filter settings QString m_filterName; // Cached name filter value QString m_filterServer; // Cached server name filter value QString m_filterDest; // Cached destination name filter value OPackageManager::Status m_filterStatus; // Cached status filter value QString m_filterCategory; // Cached category filter value void initPackageList(); void initStatusWidget(); void initUI(); void loadPackageList( OPackageList *packages = 0x0, bool clearList = true ); void searchForPackage( const QString &text ); private slots: void initPackageInfo(); void slotWidgetStackShow( QWidget *widget ); // Status widget slots void slotInitStatusBar( int numSteps ); void slotStatusText( const QString &status ); void slotStatusBar( int currStep ); // Actions menu action slots void slotUpdate(); void slotUpgrade(); void slotDownload(); void slotApply(); void slotCloseDlg(); void slotConfigure(); // View menu action slots void slotShowNotInstalled(); void slotShowInstalled(); void slotShowUpdated(); void slotFilterChange(); void slotFilter( bool isOn ); // Find action slots void slotFindShowToolbar(); void slotFindHideToolbar(); void slotFindChanged( const QString &findText ); void slotFindNext(); // Other slots void slotDisplayPackageInfo( QListViewItem * ); }; #endif diff --git a/noncore/settings/packagemanager/oconfitem.cpp b/noncore/settings/packagemanager/oconfitem.cpp index 940a6de..a90730c 100644 --- a/noncore/settings/packagemanager/oconfitem.cpp +++ b/noncore/settings/packagemanager/oconfitem.cpp @@ -1,42 +1,41 @@ /* This file is part of the Opie Project Copyright (c) 2003 Dan Williams <drw@handhelds.org> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "oconfitem.h" -OConfItem::OConfItem( const QString &location, Type type, const QString &name, +OConfItem::OConfItem( Type type, const QString &name, const QString &value, bool active ) - : m_location( location ) - , m_type( type ) + : m_type( type ) , m_name( name ) , m_value( value ) , m_active( active ) { } diff --git a/noncore/settings/packagemanager/oconfitem.h b/noncore/settings/packagemanager/oconfitem.h index aeee511..db77980 100644 --- a/noncore/settings/packagemanager/oconfitem.h +++ b/noncore/settings/packagemanager/oconfitem.h @@ -1,95 +1,92 @@ /* This file is part of the Opie Project Copyright (c) 2003 Dan Williams <drw@handhelds.org> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef OCONFITEM_H #define OCONFITEM_H #include <qlist.h> #include <qstring.h> class OConfItem { public: enum Type { Source, Destination, Option, Arch, NotDefined }; - OConfItem( const QString &location = 0x0, Type type = NotDefined, const QString &name = 0x0, - const QString &value = 0x0, bool active = true ); + OConfItem( Type type = NotDefined, const QString &name = 0x0, const QString &value = 0x0, + bool active = true ); - const QString &location() { return m_location; } Type type() { return m_type; } const QString &name() { return m_name; } const QString &value() { return m_value; } bool active() { return m_active; } - void setLocation( const QString &location ) { m_location = location; } - void setType( Type type ) { m_type = type; } - void setName( const QString &name ) { m_name = name; } - void setValue( const QString &value ) { m_value = value; } - void setActive( bool active ) { m_active = active; } + void setType( Type type ) { m_type = type; } + void setName( const QString &name ) { m_name = name; } + void setValue( const QString &value ) { m_value = value; } + void setActive( bool active ) { m_active = active; } private: - QString m_location; // Configuration file where item is located Type m_type; // Type of configuration item QString m_name; // Name of item QString m_value; // Value of item bool m_active; // Indicates whether item is currently active }; class OConfItemList : public QList<OConfItem> { private: int compareItems( QCollection::Item item1, QCollection::Item item2 ) { // Sort by OConfItem location then by type - QString loc1 = reinterpret_cast<OConfItem*>(item1)->location(); - QString loc2 = reinterpret_cast<OConfItem*>(item2)->location(); - if ( loc1 < loc2 ) + OConfItem::Type type1 = reinterpret_cast<OConfItem*>(item1)->type(); + OConfItem::Type type2 = reinterpret_cast<OConfItem*>(item2)->type(); + if ( type1 < type2 ) return -1; - else if ( loc1 == loc2 ) + else if ( type1 == type2 ) { - OConfItem::Type type1 = reinterpret_cast<OConfItem*>(item1)->type(); - OConfItem::Type type2 = reinterpret_cast<OConfItem*>(item2)->type(); - if ( type1 < type2 ) + QString name1 = reinterpret_cast<OConfItem*>(item1)->name(); + QString name2 = reinterpret_cast<OConfItem*>(item2)->name(); + if ( name1 < name2 ) return -1; - else if ( type1 == type2 ) + else if ( name1 == name2 ) return 0; - else /*if ( type1 > type2 )*/ + else /*if ( name1 > name2 )*/ return 1; } - else /*if ( loc1 > loc2 )*/ + else /*if ( type1 > type2 )*/ return 1; } }; typedef QListIterator<OConfItem> OConfItemListIterator; #endif diff --git a/noncore/settings/packagemanager/oipkg.cpp b/noncore/settings/packagemanager/oipkg.cpp index 696a64a..87a30bb 100644 --- a/noncore/settings/packagemanager/oipkg.cpp +++ b/noncore/settings/packagemanager/oipkg.cpp @@ -1,136 +1,135 @@ /* This file is part of the Opie Project Copyright (c) 2003 Dan Williams <drw@handhelds.org> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "oipkg.h" -#include <stdlib.h> -#include <string.h> - #include <qdir.h> #include <qfile.h> #include <qtextstream.h> +#include <stdlib.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; // Ipkg callback functions int fsignalIpkgMessage( ipkg_conf_t */*conf*/, message_level_t /*level*/, char *msg ) { oipkg->ipkgMessage( msg ); return 0; } 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*/ ) { 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 ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ); // Default ipkg run-time arguments m_ipkgArgs.noaction = false; m_ipkgArgs.force_defaults = true; } OIpkg::~OIpkg() { // Upon destruction, ensure that items in config list are deleted with list if ( m_confInfo ) m_confInfo->setAutoDelete( true ); // Free up libipkg resources ipkg_deinit( &m_ipkgArgs ); } OConfItemList *OIpkg::configItems() { // Retrieve all configuration items return filterConfItems(); } OConfItemList *OIpkg::servers() { // Retrieve only servers return filterConfItems( OConfItem::Source ); } OConfItemList *OIpkg::destinations() { // Retrieve only destinations return filterConfItems( OConfItem::Destination ); } OConfItemList *OIpkg::options() { // Retrieve only destinations return filterConfItems( OConfItem::Option ); } void OIpkg::setConfigItems( OConfItemList *configList ) { if ( m_confInfo ) delete m_confInfo; m_confInfo = configList; // Write out new /etc/ipkg.conf QFile confFile( IPKG_CONF ); if ( confFile.open( IO_WriteOnly ) ) { QTextStream confStream( &confFile ); @@ -436,140 +435,140 @@ bool OIpkg::executeCommand( OPackage::Command command, QStringList *parameters, break; default : break; }; return true; } void OIpkg::ipkgMessage( char *msg ) { emit signalIpkgMessage( msg ); } void OIpkg::ipkgStatus( char *status ) { emit signalIpkgStatus( status ); } void OIpkg::ipkgList( char *filelist ) { emit signalIpkgList( filelist ); } void OIpkg::loadConfiguration() { if ( m_confInfo ) delete m_confInfo; // Load configuration item list m_confInfo = new OConfItemList(); QStringList confFiles; QDir confDir( IPKG_CONF_DIR ); if ( confDir.exists() ) { confDir.setNameFilter( "*.conf" ); confDir.setFilter( QDir::Files ); confFiles = confDir.entryList( "*.conf", QDir::Files ); confFiles << IPKG_CONF; QStringList::Iterator lastFile = confFiles.end(); for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it ) { // Create absolute file path if necessary QString absFile = (*it); if ( !absFile.startsWith( "/" ) ) absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); // Read in file QFile f( absFile ); if ( f.open( IO_ReadOnly ) ) { QTextStream s( &f ); while ( !s.eof() ) { QString line = s.readLine().simplifyWhiteSpace(); // Parse line and save info to the conf options list if ( !line.isEmpty() ) { if ( !line.startsWith( "#" ) || line.startsWith( "#src" ) || line.startsWith( "#dest" ) || line.startsWith( "#arch" ) || line.startsWith( "#option" ) ) { int pos = line.find( ' ', 1 ); // Type QString typeStr = line.left( pos ); OConfItem::Type type; if ( typeStr == "src" || typeStr == "#src" ) type = OConfItem::Source; else if ( typeStr == "dest" || typeStr == "#dest" ) type = OConfItem::Destination; else if ( typeStr == "option" || typeStr == "#option" ) type = OConfItem::Option; else if ( typeStr == "arch" || typeStr == "#arch" ) type = OConfItem::Arch; else type = OConfItem::NotDefined; ++pos; int endpos = line.find( ' ', pos ); // Name QString name = line.mid( pos, endpos - pos ); // Value QString value = ""; if ( endpos > -1 ) value = line.right( line.length() - endpos - 1 ); // Active bool active = !line.startsWith( "#" ); // Add to list - m_confInfo->append( new OConfItem( absFile, type, name, value, active ) ); + m_confInfo->append( new OConfItem( type, name, value, active ) ); } } } f.close(); } } } // Load Ipkg execution options from application configuration file if ( m_config ) { m_config->setGroup( "Ipkg" ); m_ipkgExecOptions = m_config->readNumEntry( "ExecOptions", m_ipkgExecOptions ); m_ipkgExecVerbosity = m_config->readNumEntry( "Verbosity", m_ipkgExecVerbosity ); } } OConfItemList *OIpkg::filterConfItems( OConfItem::Type typefilter ) { // Load Ipkg configuration info if not already cached if ( !m_confInfo ) loadConfiguration(); // Build new server list (caller is responsible for deleting) OConfItemList *sl = new OConfItemList; // If typefilter is empty, retrieve all items bool retrieveAll = ( typefilter == OConfItem::NotDefined ); // Parse configuration info for servers OConfItemListIterator it( *m_confInfo ); for ( ; it.current(); ++it ) { OConfItem *item = it.current(); if ( retrieveAll || item->type() == typefilter ) { sl->append( item ); } } return sl; } diff --git a/noncore/settings/packagemanager/oipkg.h b/noncore/settings/packagemanager/oipkg.h index ea126cf..b8a859a 100644 --- a/noncore/settings/packagemanager/oipkg.h +++ b/noncore/settings/packagemanager/oipkg.h @@ -1,105 +1,105 @@ /* This file is part of the Opie Project Copyright (c) 2003 Dan Williams <drw@handhelds.org> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef OIPKG_H #define OIPKG_H -extern "C" { -#include <libipkg.h> -}; - -#include <qobject.h> +#include "oconfitem.h" +#include "opackage.h" #include <qpe/config.h> -#include "oconfitem.h" -#include "opackage.h" +#include <qobject.h> + +extern "C" { +#include <libipkg.h> +}; // Ipkg execution options (m_ipkgExecOptions) #define FORCE_DEPENDS 0x0001 #define FORCE_REMOVE 0x0002 #define FORCE_REINSTALL 0x0004 #define FORCE_OVERWRITE 0x0008 class OConfItemList; class OIpkg : public QObject { Q_OBJECT public: OIpkg( Config *config = 0x0, QObject *parent = 0x0, const char *name = 0x0 ); ~OIpkg(); OConfItemList *configItems(); OConfItemList *servers(); OConfItemList *destinations(); OConfItemList *options(); int ipkgExecOptions() { return m_ipkgExecOptions; } int ipkgExecVerbosity() { return m_ipkgExecVerbosity; } void setConfigItems( OConfItemList *configList ); void setIpkgExecOptions( int options ) { m_ipkgExecOptions = options; } void setIpkgExecVerbosity( int verbosity ) { m_ipkgExecVerbosity = verbosity; } void saveSettings(); OPackageList *availablePackages( const QString &server = QString::null ); 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 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 signalIpkgMessage( char *msg ); void signalIpkgStatus( char *status ); void signalIpkgList( char *filelist ); }; #endif diff --git a/noncore/settings/packagemanager/oipkgconfigdlg.cpp b/noncore/settings/packagemanager/oipkgconfigdlg.cpp index d134651..7941ab8 100644 --- a/noncore/settings/packagemanager/oipkgconfigdlg.cpp +++ b/noncore/settings/packagemanager/oipkgconfigdlg.cpp @@ -1,224 +1,223 @@ /* This file is part of the Opie Project Copyright (c) 2003 Dan Williams <drw@handhelds.org> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "oipkgconfigdlg.h" +#include <qpe/resource.h> + #include <qcheckbox.h> #include <qcombobox.h> #include <qgroupbox.h> #include <qlabel.h> #include <qlineedit.h> #include <qlistbox.h> #include <qpushbutton.h> #include <qscrollview.h> #include <qwhatsthis.h> -#include <qpe/resource.h> - -using namespace Opie::Ui; OIpkgConfigDlg::OIpkgConfigDlg( OIpkg *ipkg, bool installOptions, QWidget *parent ) : QDialog( parent, QString::null, true, WStyle_ContextHelp ) , m_ipkg( ipkg ) , m_configs( 0x0 ) , m_installOptions( installOptions ) , m_serverNew( false ) , m_serverCurrent( -1 ) , m_destNew( false ) , m_destCurrent( -1 ) , m_layout( this, 2, 4 ) , m_tabWidget( this ) { setCaption( tr( "Configuration" ) ); // Initialize configuration widgets if ( !installOptions ) { initServerWidget(); initDestinationWidget(); initProxyWidget(); } initOptionsWidget(); // Load configuration information initData(); // Setup tabs for all info m_layout.addWidget( &m_tabWidget ); if ( !m_installOptions ) { m_tabWidget.addTab( m_serverWidget, "packagemanager/servertab", tr( "Servers" ) ); m_tabWidget.addTab( m_destWidget, "packagemanager/desttab", tr( "Destinations" ) ); m_tabWidget.addTab( m_proxyWidget, "packagemanager/proxytab", tr( "Proxies" ) ); m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) ); m_tabWidget.setCurrentTab( tr( "Servers" ) ); } else { m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) ); } //showMaximized(); } void OIpkgConfigDlg::accept() { // Save server, destination and proxy configuration if ( !m_installOptions ) { // Update proxy information before saving settings OConfItem *confItem = findConfItem( OConfItem::Option, "http_proxy" ); if ( confItem ) { confItem->setValue( m_proxyHttpServer->text() ); confItem->setActive( m_proxyHttpActive->isChecked() ); } else - m_configs->append( new OConfItem( QString::null, OConfItem::Option, "http_proxy", + m_configs->append( new OConfItem( OConfItem::Option, "http_proxy", m_proxyHttpServer->text(), m_proxyHttpActive->isChecked() ) ); confItem = findConfItem( OConfItem::Option, "ftp_proxy" ); if ( confItem ) { confItem->setValue( m_proxyFtpServer->text() ); confItem->setActive( m_proxyFtpActive->isChecked() ); } else - m_configs->append( new OConfItem( QString::null, OConfItem::Option, "ftp_proxy", + m_configs->append( new OConfItem( OConfItem::Option, "ftp_proxy", m_proxyFtpServer->text(), m_proxyFtpActive->isChecked() ) ); confItem = findConfItem( OConfItem::Option, "proxy_username" ); if ( confItem ) confItem->setValue( m_proxyUsername->text() ); else - m_configs->append( new OConfItem( QString::null, OConfItem::Option, "proxy_username", + m_configs->append( new OConfItem( OConfItem::Option, "proxy_username", m_proxyUsername->text() ) ); confItem = findConfItem( OConfItem::Option, "proxy_password" ); if ( confItem ) confItem->setValue( m_proxyPassword->text() ); else - m_configs->append( new OConfItem( QString::null, OConfItem::Option, "proxy_password", + m_configs->append( new OConfItem( OConfItem::Option, "proxy_password", m_proxyPassword->text() ) ); m_ipkg->setConfigItems( m_configs ); } // Save options configuration int options = 0; if ( m_optForceDepends->isChecked() ) options |= FORCE_DEPENDS; if ( m_optForceReinstall->isChecked() ) options |= FORCE_REINSTALL; if ( m_optForceRemove->isChecked() ) options |= FORCE_REMOVE; if ( m_optForceOverwrite->isChecked() ) options |= FORCE_OVERWRITE; m_ipkg->setIpkgExecOptions( options ); m_ipkg->setIpkgExecVerbosity( m_optVerboseIpkg->currentItem() ); QDialog::accept(); } void OIpkgConfigDlg::reject() { if ( m_configs ) delete m_configs; } void OIpkgConfigDlg::initServerWidget() { m_serverWidget = new QWidget( this ); // Initialize UI QVBoxLayout *vb = new QVBoxLayout( m_serverWidget ); QScrollView *sv = new QScrollView( m_serverWidget ); vb->addWidget( sv, 0, 0 ); sv->setResizePolicy( QScrollView::AutoOneFit ); sv->setFrameStyle( QFrame::NoFrame ); QWidget *container = new QWidget( sv->viewport() ); sv->addChild( container ); QGridLayout *layout = new QGridLayout( container, 3, 2, 2, 4 ); m_serverList = new QListBox( container ); QWhatsThis::add( m_serverList, tr( "This is a list of all servers configured. Select one here to edit or delete, or add a new one below." ) ); m_serverList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); connect( m_serverList, SIGNAL(highlighted(int)), this, SLOT(slotServerEdit(int)) ); layout->addMultiCellWidget( m_serverList, 0, 0, 0, 1 ); QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); QWhatsThis::add( btn, tr( "Tap here to create a new entry. Fill in the fields below and then tap on Update." ) ); connect( btn, SIGNAL(clicked()), this, SLOT(slotServerNew()) ); layout->addWidget( btn, 1, 0 ); btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); QWhatsThis::add( btn, tr( "Tap here to delete the entry selected above." ) ); connect( btn, SIGNAL(clicked()), this, SLOT(slotServerDelete()) ); layout->addWidget( btn, 1, 1 ); QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container ); grpbox->layout()->setSpacing( 2 ); grpbox->layout()->setMargin( 4 ); layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); QLabel *label = new QLabel( tr( "Name:" ), grpbox ); QWhatsThis::add( label, tr( "Enter the name of this entry here." ) ); grplayout->addWidget( label, 0, 0 ); m_serverName = new QLineEdit( grpbox ); QWhatsThis::add( m_serverName, tr( "Enter the name of this entry here." ) ); grplayout->addWidget( m_serverName, 0, 1 ); label = new QLabel( tr( "Address:" ), grpbox ); QWhatsThis::add( label, tr( "Enter the URL address of this entry here." ) ); grplayout->addWidget( label, 1, 0 ); m_serverLocation = new QLineEdit( grpbox ); QWhatsThis::add( m_serverLocation, tr( "Enter the URL address of this entry here." ) ); grplayout->addWidget( m_serverLocation, 1, 1 ); m_serverActive = new QCheckBox( tr( "Active" ), grpbox ); QWhatsThis::add( m_serverActive, tr( "Tap here to indicate whether this entry is active or not." ) ); grplayout->addMultiCellWidget( m_serverActive, 2, 2, 0, 1 ); btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); QWhatsThis::add( btn, tr( "Tap here to update the entry's information." ) ); connect( btn, SIGNAL(clicked()), this, SLOT(slotServerUpdate()) ); grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); } void OIpkgConfigDlg::initDestinationWidget() { m_destWidget = new QWidget( this ); // Initialize UI QVBoxLayout *vb = new QVBoxLayout( m_destWidget ); QScrollView *sv = new QScrollView( m_destWidget ); vb->addWidget( sv, 0, 0 ); @@ -439,191 +438,191 @@ void OIpkgConfigDlg::initData() m_optVerboseIpkg->setCurrentItem( m_ipkg->ipkgExecVerbosity() ); } OConfItem *OIpkgConfigDlg::findConfItem( OConfItem::Type type, const QString &name ) { // Find selected server in list OConfItemListIterator configIt( *m_configs ); OConfItem *config = 0x0; for ( ; configIt.current(); ++configIt ) { config = configIt.current(); if ( config->type() == type && config->name() == name ) break; } if ( config && config->type() == type && config->name() == name ) return config; return 0x0; } void OIpkgConfigDlg::slotServerEdit( int index ) { m_serverNew = false; m_serverCurrent = index; // Find selected server in list OConfItem *server = findConfItem( OConfItem::Source, m_serverList->currentText() ); // Display server details if ( server ) { m_serverCurrName = server->name(); m_serverName->setText( server->name() ); m_serverLocation->setText( server->value() ); m_serverActive->setChecked( server->active() ); m_serverName->setFocus(); } } void OIpkgConfigDlg::slotServerNew() { m_serverNew = true; m_serverName->setText( QString::null ); m_serverLocation->setText( QString::null ); m_serverActive->setChecked( true ); m_serverName->setFocus(); } void OIpkgConfigDlg::slotServerDelete() { // Find selected server in list OConfItem *server = findConfItem( OConfItem::Source, m_serverList->currentText() ); // Delete server if ( server ) { m_configs->removeRef( server ); m_serverList->removeItem( m_serverCurrent ); } } void OIpkgConfigDlg::slotServerUpdate() { QString newName = m_serverName->text(); // Convert any spaces to underscores newName.replace( QRegExp( " " ), "_" ); if ( !m_serverNew ) { // Find selected server in list OConfItem *server = findConfItem( OConfItem::Source, m_serverCurrName ); // Delete server if ( server ) { // Update url server->setValue( m_serverLocation->text() ); server->setActive( m_serverActive->isChecked() ); // Check if server name has changed, if it has then we need to replace the key in the map if ( m_serverCurrName != newName ) { // Update server name server->setName( newName ); // Update list box m_serverList->changeItem( newName, m_serverCurrent ); } } } else { // Add new destination to configuration list - m_configs->append( new OConfItem( QString::null, OConfItem::Source, newName, + m_configs->append( new OConfItem( OConfItem::Source, newName, m_serverLocation->text(), m_serverActive->isChecked() ) ); m_configs->sort(); m_serverList->insertItem( newName ); m_serverList->setCurrentItem( m_serverList->count() ); m_serverNew = false; m_serverList->insertItem( newName ); } } void OIpkgConfigDlg::slotDestEdit( int index ) { m_destNew = false; m_destCurrent = index; // Find selected destination in list OConfItem *destination = findConfItem( OConfItem::Destination, m_destList->currentText() ); // Display destination details if ( destination ) { m_destCurrName = destination->name(); m_destName->setText( destination->name() ); m_destLocation->setText( destination->value() ); m_destActive->setChecked( destination->active() ); m_destName->setFocus(); } } void OIpkgConfigDlg::slotDestNew() { m_destNew = true; m_destName->setText( QString::null ); m_destLocation->setText( QString::null ); m_destActive->setChecked( true ); m_destName->setFocus(); } void OIpkgConfigDlg::slotDestDelete() { // Find selected destination in list OConfItem *destination = findConfItem( OConfItem::Destination, m_destList->currentText() ); // Delete destination if ( destination ) { m_configs->removeRef( destination ); m_destList->removeItem( m_destCurrent ); } } void OIpkgConfigDlg::slotDestUpdate() { QString newName = m_destName->text(); // Convert any spaces to underscores newName.replace( QRegExp( " " ), "_" ); if ( !m_destNew ) { // Find selected destination in list OConfItem *destination = findConfItem( OConfItem::Destination, m_destCurrName ); // Display destination details if ( destination ) { // Update url destination->setValue( m_destLocation->text() ); destination->setActive( m_destActive->isChecked() ); // Check if destination name has changed, if it has then we need to replace the key in the map if ( m_destCurrName != newName ) { // Update destination name destination->setName( newName ); // Update list box m_destList->changeItem( newName, m_destCurrent ); } } } else { // Add new destination to configuration list - m_configs->append( new OConfItem( QString::null, OConfItem::Destination, newName, + m_configs->append( new OConfItem( OConfItem::Destination, newName, m_destLocation->text(), m_destActive->isChecked() ) ); m_configs->sort(); m_destList->insertItem( newName ); m_destList->setCurrentItem( m_destList->count() ); m_destNew = false; } } diff --git a/noncore/settings/packagemanager/oipkgconfigdlg.h b/noncore/settings/packagemanager/oipkgconfigdlg.h index 0aba898..800d94a 100644 --- a/noncore/settings/packagemanager/oipkgconfigdlg.h +++ b/noncore/settings/packagemanager/oipkgconfigdlg.h @@ -1,131 +1,131 @@ /* This file is part of the Opie Project Copyright (c) 2003 Dan Williams <drw@handhelds.org> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef OIPKGCONFIGDLG_H #define OIPKGCONFIGDLG_H +#include <opie2/otabwidget.h> + #include <qdialog.h> #include <qlayout.h> -#include <opie2/otabwidget.h> - #include "oipkg.h" class QCheckBox; class QComboBox; class QLineEdit; class QListBox; class OIpkgConfigDlg : public QDialog { Q_OBJECT public: OIpkgConfigDlg( OIpkg *ipkg = 0x0, bool installOptions = false, QWidget *parent = 0x0 ); protected slots: void accept(); void reject(); private: OIpkg *m_ipkg; // Pointer to Ipkg class for retrieving/saving configuration options OConfItemList *m_configs; // Local list of configuration items bool m_installOptions; // If true, will only display the Options tab // Server cached information bool m_serverNew; // Indicates if server information is for a new server int m_serverCurrent; // Index of currently selected server in m_serverList QString m_serverCurrName; // Name of currently selected server in m_serverList // Destination cached information bool m_destNew; // Indicates if destination information is for a new destination int m_destCurrent; // Index of currently selected destination in m_destList QString m_destCurrName; // Name of currently selected destination in m_destList // UI controls - QVBoxLayout m_layout; // Main dialog layout control - Opie::Ui::OTabWidget m_tabWidget; // Main tab widget control - QWidget *m_serverWidget; // Widget containing server configuration controls - QWidget *m_destWidget; // Widget containing destination configuration controls - QWidget *m_proxyWidget; // Widget containing proxy configuration controls - QWidget *m_optionsWidget; // Widget containing ipkg execution configuration controls + QVBoxLayout m_layout; // Main dialog layout control + Opie::Ui::OTabWidget m_tabWidget; // Main tab widget control + QWidget *m_serverWidget; // Widget containing server configuration controls + QWidget *m_destWidget; // Widget containing destination configuration controls + QWidget *m_proxyWidget; // Widget containing proxy configuration controls + QWidget *m_optionsWidget; // Widget containing ipkg execution configuration controls // Server configuration UI controls QListBox *m_serverList; // Server list selection QLineEdit *m_serverName; // Server name edit box QLineEdit *m_serverLocation; // Server location URL edit box QCheckBox *m_serverActive; // Activate server check box // Destination configuration UI controls QListBox *m_destList; // Destination list selection QLineEdit *m_destName; // Destination name edit box QLineEdit *m_destLocation; // Destination location URL edit box QCheckBox *m_destActive; // Activate destination check box // Proxy server configuration UI controls QLineEdit *m_proxyHttpServer; // HTTP proxy server URL edit box QCheckBox *m_proxyHttpActive; // Activate HTTP proxy check box QLineEdit *m_proxyFtpServer; // FTP proxy server edit box QCheckBox *m_proxyFtpActive; // Activate FTP proxy check box QLineEdit *m_proxyUsername; // Proxy server username edit box QLineEdit *m_proxyPassword; // Proxy server password edit box // Options configuration UI controls QCheckBox *m_optForceDepends; // Force depends ipkg option checkbox QCheckBox *m_optForceReinstall; // Force reinstall ipkg option checkbox QCheckBox *m_optForceRemove; // Force remove ipkg option checkbox QCheckBox *m_optForceOverwrite; // Force overwrite ipkg option checkbox QComboBox *m_optVerboseIpkg; // Ipkg verbosity option selection void initServerWidget(); void initDestinationWidget(); void initProxyWidget(); void initOptionsWidget(); void initData(); OConfItem *findConfItem( OConfItem::Type type = OConfItem::NotDefined, const QString &name = 0x0 ); private slots: void slotServerEdit( int index ); void slotServerNew(); void slotServerDelete(); void slotServerUpdate(); void slotDestEdit( int index ); void slotDestNew(); void slotDestDelete(); void slotDestUpdate(); }; #endif diff --git a/noncore/settings/packagemanager/opackagemanager.cpp b/noncore/settings/packagemanager/opackagemanager.cpp index 3633e05..f75d3b3 100644 --- a/noncore/settings/packagemanager/opackagemanager.cpp +++ b/noncore/settings/packagemanager/opackagemanager.cpp @@ -1,133 +1,133 @@ /* This file is part of the Opie Project Copyright (c) 2003 Dan Williams <drw@handhelds.org> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include <ctype.h> +#include "opackagemanager.h" +#include "oipkgconfigdlg.h" #include <qpe/qpeapplication.h> -#include "opackagemanager.h" -#include "oipkgconfigdlg.h" +#include <ctype.h> OPackageManager::OPackageManager( Config *config, QObject *parent, const char *name ) : QObject( parent, name ) , m_config( config ) , m_ipkg( m_config, this ) , m_packages( 9973 ) , m_categories() { m_packages.setAutoDelete( true ); } void OPackageManager::loadAvailablePackages() { m_packages.clear(); OConfItemList *serverList = m_ipkg.servers(); if ( serverList ) { // Initialize status messaging emit initStatus( serverList->count() ); int serverCount = 0; bool categoryAdded = false; for ( OConfItemListIterator serverIt( *serverList ); serverIt.current(); ++serverIt ) { OConfItem *server = serverIt.current(); // Process server only if it is active if ( server->active() ) { // Update status QString status = tr( "Reading available packages:\n\t" ); status.append( server->name() ); emit statusText( status ); ++serverCount; emit statusBar( serverCount ); qApp->processEvents(); OPackageList *packageList = m_ipkg.availablePackages( server->name() ); if ( packageList ) { for ( OPackageListIterator packageIt( *packageList ); packageIt.current(); ++packageIt ) { OPackage *package = packageIt.current(); // Load package info if ( !m_packages.find( package->name() ) ) m_packages.insert( package->name(), package ); else { // If new package is newer version, replace existing package OPackage *currPackage = m_packages[package->name()]; if ( compareVersions( package->version(), currPackage->version() ) == 1 ) m_packages.replace( package->name(), package ); } // Add category to list if it doesn't already exist if ( m_categories.grep( package->category() ).isEmpty() ) { m_categories << package->category(); categoryAdded = true; } } } } } delete serverList; // Sort category list if categories were added if ( categoryAdded ) m_categories.sort(); } } void OPackageManager::loadInstalledPackages() { OConfItemList *destList = m_ipkg.destinations(); if ( destList ) { // Initialize status messaging emit initStatus( destList->count() ); int destCount = 0; bool categoryAdded = false; for ( OConfItemListIterator destIt( *destList ); destIt.current(); ++destIt ) { OConfItem *destination = destIt.current(); // Process destination only if it is active if ( destination->active() ) { // Update status diff --git a/noncore/settings/packagemanager/opackagemanager.h b/noncore/settings/packagemanager/opackagemanager.h index b710a51..58e597b 100644 --- a/noncore/settings/packagemanager/opackagemanager.h +++ b/noncore/settings/packagemanager/opackagemanager.h @@ -1,92 +1,92 @@ /* This file is part of the Opie Project Copyright (c) 2003 Dan Williams <drw@handhelds.org> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU ..}^=.= = ; Library General Public License for more ++= -. .` .: details. : = ...= . :.=- -. .:....=;==+<; You should have received a copy of the GNU -_. . . )=. = Library General Public License along with -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef OPACKAGEMANAGER_H #define OPACKAGEMANAGER_H -#include <qdict.h> -#include <qobject.h> -#include <qstringlist.h> +#include "oipkg.h" #include <qpe/config.h> -#include "oipkg.h" +#include <qdict.h> +#include <qobject.h> +#include <qstringlist.h> class OPackageManager : public QObject { Q_OBJECT public: OPackageManager( Config *config = 0x0, QObject *parent = 0x0, const char *name = 0x0 ); void loadAvailablePackages(); void loadInstalledPackages(); enum Status { All, NotInstalled, Installed, Updated, NotDefined }; OPackageList *packages(); OPackageList *filterPackages( const QString &name = 0x0,const QString &server = 0x0, const QString &destination = 0x0, Status status = NotDefined, const QString &category = 0x0 ); const QStringList &categories() { return m_categories; } QStringList *servers(); QStringList *destinations(); int compareVersions( const QString &version1, const QString &version2 ); OConfItem *findConfItem( OConfItem::Type type = OConfItem::NotDefined, const QString &name = QString::null ); OPackage *findPackage( const QString &name = QString::null ); bool configureDlg( bool installOptions = false ); void saveSettings(); 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 ); private: Config *m_config; // Pointer to application configuration file OIpkg m_ipkg; // OIpkg object to retrieve package/configuration information QDict<OPackage> m_packages; // Global list of available packages QStringList m_categories; // List of all categories void parseVersion( const QString &verstr, int *epoch, QString *version, QString *revision ); int verrevcmp( const char *val, const char *ref ); signals: void initStatus( int numSteps ); void statusText( const QString &status ); void statusBar( int currStep ); }; #endif diff --git a/noncore/settings/packagemanager/opie-packagemanager.control b/noncore/settings/packagemanager/opie-packagemanager.control index aff8866..09bb18b 100644 --- a/noncore/settings/packagemanager/opie-packagemanager.control +++ b/noncore/settings/packagemanager/opie-packagemanager.control @@ -1,10 +1,10 @@ Package: opie-packagemanager Files: plugins/application/libpackagemanager.so* bin/packagemanager pics/packagemanager apps/Settings/packagemanager.desktop Priority: optional Section: opie/settings Depends: task-opie-minimal, libopiecore2, libopieui2, libipkg Replaces: packagemanager Architecture: arm Maintainer: Dan Williams (drw@handhelds.org) Description: Opie package management client -Version: 0.3.0$EXTRAVERSION +Version: 0.4.0$EXTRAVERSION diff --git a/noncore/settings/packagemanager/packageinfodlg.cpp b/noncore/settings/packagemanager/packageinfodlg.cpp index 73d3de7..d27eacb 100644 --- a/noncore/settings/packagemanager/packageinfodlg.cpp +++ b/noncore/settings/packagemanager/packageinfodlg.cpp @@ -1,141 +1,144 @@ /* This file is part of the OPIE Project =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> .=l. .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This file is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General ..}^=.= = ; Public License for more details. ++= -. .` .: : = ...= . :.=- You should have received a copy of the GNU -. .:....=;==+<; General Public License along with this file; -_. . . )=. = 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 <opie2/otabwidget.h> #include <qpe/resource.h> -#include <opie2/otabwidget.h> +#include <qlayout.h> +#include <qpushbutton.h> +#include <qwhatsthis.h> -using namespace Opie::Ui; PackageInfoDlg::PackageInfoDlg( QWidget *parent, OPackageManager *pm, const QString &package ) : QWidget( 0x0 ) , m_packman( pm ) , m_information( this ) , m_files( this ) { // Initialize UI if ( parent ) parent->setCaption( package ); QVBoxLayout *layout = new QVBoxLayout( this, 4, 2 ); - OTabWidget *tabWidget = new OTabWidget( this ); + Opie::Ui::OTabWidget *tabWidget = new Opie::Ui::OTabWidget( this ); layout->addWidget( tabWidget ); // Information tab + QWhatsThis::add( &m_information, tr( "This area contains information about the package." ) ); m_information.reparent( tabWidget, QPoint( 0, 0 ) ); m_information.setReadOnly( true ); tabWidget->addTab( &m_information, "UtilsIcon", tr( "Information" ) ); // 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 ); + QWhatsThis::add( &m_files, tr( "This area contains a list of files contained in this package." ) ); 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 ); + QWhatsThis::add( btn, tr( "Tap here to retrieve list of files contained in this package." ) ); 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() ); // Cache package file list if ( !m_files.text().isNull() ) m_package->setFiles( m_files.text() ); } 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::slotInfo( char *info ) { 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 7ed9f0a..ec031e1 100644 --- a/noncore/settings/packagemanager/packageinfodlg.h +++ b/noncore/settings/packagemanager/packageinfodlg.h @@ -1,65 +1,65 @@ /* This file is part of the OPIE Project =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> .=l. .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This file is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General ..}^=.= = ; Public License for more details. ++= -. .` .: : = ...= . :.=- You should have received a copy of the GNU -. .:....=;==+<; General Public License along with this file; -_. . . )=. = see the file COPYING. If not, write to the -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef PACKAGEINFODLG_H #define PACKAGEINFODLG_H +#include "opackage.h" + #include <qmultilineedit.h> #include <qwidget.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 slotBtnFileScan(); void slotInfo( char *info ); void slotFiles( char *filelist ); }; #endif diff --git a/noncore/settings/packagemanager/promptdlg.cpp b/noncore/settings/packagemanager/promptdlg.cpp index 4e82ba9..841b98e 100644 --- a/noncore/settings/packagemanager/promptdlg.cpp +++ b/noncore/settings/packagemanager/promptdlg.cpp @@ -1,134 +1,134 @@ /* This file is part of the OPIE Project =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> .=l. .>+-= _;:, .> :=|. This file is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This file is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; : .. .:, . . . without even the implied warranty of =_ + =;=|` MERCHANTABILITY or FITNESS FOR A _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General ..}^=.= = ; Public License for more details. ++= -. .` .: : = ...= . :.=- You should have received a copy of the GNU -. .:....=;==+<; General Public License along with this file; -_. . . )=. = see the file COPYING. If not, write to the -- :-=` Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "promptdlg.h" +#include <qpe/qpeapplication.h> + #include <qlabel.h> #include <qlayout.h> #include <qpushbutton.h> #include <qwidgetlist.h> -#include <qpe/qpeapplication.h> - PromptDlg::PromptDlg( const QString &caption, const QString &text, const QString &btn1, const QString &btn2, QWidget *parent ) : QWidget( parent, QString::null, WType_Modal | WType_TopLevel | WStyle_Dialog ) , m_btnClicked( -1 ) { setCaption( caption ); QGridLayout *layout = new QGridLayout( this, 2, 2, 4, 2 ); QLabel *label = new QLabel( text, this ); label->setAlignment( AlignCenter | WordBreak ); layout->addMultiCellWidget( label, 0, 0, 0, 1 ); QPushButton *btn = new QPushButton( btn1, this ); layout->addWidget( btn, 1, 0 ); connect( btn, SIGNAL(clicked()), this, SLOT(slotBtn1Clicked()) ); btn = new QPushButton( btn2, this ); layout->addWidget( btn, 1, 1 ); connect( btn, SIGNAL(clicked()), this, SLOT(slotBtn2Clicked()) ); } int PromptDlg::display() { // Determine position of dialog. Derived from QT's QDialog::show() method. QWidget *w = parentWidget(); QPoint p( 0, 0 ); int extraw = 0, extrah = 0; QWidget * desk = QApplication::desktop(); if ( w ) w = w->topLevelWidget(); QWidgetList *list = QApplication::topLevelWidgets(); QWidgetListIt it( *list ); while ( (extraw == 0 || extrah == 0) && it.current() != 0 ) { int w, h; QWidget * current = it.current(); ++it; w = current->geometry().x() - current->x(); h = current->geometry().y() - current->y(); extraw = QMAX( extraw, w ); extrah = QMAX( extrah, h ); } delete list; // sanity check for decoration frames. With embedding, we // might get extraordinary values if ( extraw >= 10 || extrah >= 40 ) extraw = extrah = 0; if ( w ) { // Use mapToGlobal rather than geometry() in case w might // be embedded in another application QPoint pp = w->mapToGlobal( QPoint(0,0) ); p = QPoint( pp.x() + w->width()/2, pp.y() + w->height()/ 2 ); } else p = QPoint( desk->width()/2, desk->height()/2 ); p = QPoint( p.x()-width()/2 - extraw, p.y()-height()/2 - extrah ); if ( p.x() + extraw + width() > desk->width() ) p.setX( desk->width() - width() - extraw ); if ( p.x() < 0 ) p.setX( 0 ); if ( p.y() + extrah + height() > desk->height() ) p.setY( desk->height() - height() - extrah ); if ( p.y() < 0 ) p.setY( 0 ); move( p ); show(); // Enter event loop for modality qApp->enter_loop(); return m_btnClicked; } int PromptDlg::ask( const QString &caption, const QString &text, const QString &btn1, const QString &btn2, QWidget *parent ) { PromptDlg *dlg = new PromptDlg( caption, text, btn1, btn2, parent ); int rc = dlg->display(); delete dlg; return rc; } void PromptDlg::slotBtn1Clicked() { m_btnClicked = 1; qApp->exit_loop(); } |