-rw-r--r-- | noncore/settings/packagemanager/ChangeLog | 8 | ||||
-rw-r--r-- | noncore/settings/packagemanager/README | 2 | ||||
-rw-r--r-- | noncore/settings/packagemanager/TODO | 14 | ||||
-rw-r--r-- | noncore/settings/packagemanager/installdlg.cpp | 104 | ||||
-rw-r--r-- | noncore/settings/packagemanager/installdlg.h | 7 | ||||
-rw-r--r-- | noncore/settings/packagemanager/mainwindow.cpp | 29 | ||||
-rw-r--r-- | noncore/settings/packagemanager/opie-packagemanager.control | 4 |
7 files changed, 105 insertions, 63 deletions
diff --git a/noncore/settings/packagemanager/ChangeLog b/noncore/settings/packagemanager/ChangeLog index c9e33c4..7799136 100644 --- a/noncore/settings/packagemanager/ChangeLog +++ b/noncore/settings/packagemanager/ChangeLog @@ -1,37 +1,45 @@ +2004-11-18 Dan Williams <drw@handhelds.org> + + * Released version 0.5.0 + * All v1.0 functionality implemented + * Implemented installation of local packages + * Implemented linking of non-root apps (using ipkg-link) + * Many UI tweaks for installation and filter dialogs + 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 bf93c98..c34a6af 100644 --- a/noncore/settings/packagemanager/README +++ b/noncore/settings/packagemanager/README @@ -1,55 +1,55 @@ /************************************************************************ /* /* Opie - Package Manager /* ======================== -/* Version 0.4.0 +/* Version 0.5.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 633c589..265beda 100644 --- a/noncore/settings/packagemanager/TODO +++ b/noncore/settings/packagemanager/TODO @@ -1,27 +1,25 @@ /************************************************************************ /* /* Opie - Package Manager /* ======================== -/* Version 0.4.0 +/* Version 0.5.0 /* /* A package management client for Opie /* /************************************************************************ ---------------------------------------------- - To-do for Opie-PackageManager - April, 2004 ---------------------------------------------- +----------------------------------------------- + To-do for Opie-PackageManager - November, 2004 +----------------------------------------------- ====================== = Current release = ====================== -1. Link non-root destination apps -2. Implement QCOP interface for installing, removing, etc. -3. Redesign configuration dialog +1. Re-work package download dialog ====================== = Future releases = ====================== -1. ???
\ No newline at end of file +1. Re-work server and destination tabs in configuration dialog
\ No newline at end of file diff --git a/noncore/settings/packagemanager/installdlg.cpp b/noncore/settings/packagemanager/installdlg.cpp index 781f8f5..494603b 100644 --- a/noncore/settings/packagemanager/installdlg.cpp +++ b/noncore/settings/packagemanager/installdlg.cpp @@ -1,336 +1,372 @@ /* 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 <opie2/ofiledialog.h> #include <opie2/oprocess.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 <sys/vfs.h> #include "opackagemanager.h" -InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &caption, bool showDestInfo, +InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &caption, OPackage::Command command1, const QStringList &packages1, OPackage::Command command2, const QStringList &packages2, OPackage::Command command3, const QStringList &packages3 ) : QWidget( 0x0 ) , m_packman( pm ) + , m_installFound( false ) , m_numCommands( 0 ) , m_currCommand( 0 ) , m_destItem( 0x0 ) { // Save command/package list information if ( command1 != OPackage::NotDefined ) { m_command[ m_numCommands ] = command1; m_packages[ m_numCommands ] = packages1; ++m_numCommands; + + if ( command1 == OPackage::Install ) + m_installFound = true; } if ( command2 != OPackage::NotDefined ) { m_command[ m_numCommands ] = command2; m_packages[ m_numCommands ] = packages2; ++m_numCommands; + + if ( command2 == OPackage::Install ) + m_installFound = true; } if ( command3 != OPackage::NotDefined ) { m_command[ m_numCommands ] = command3; m_packages[ m_numCommands ] = packages3; ++m_numCommands; + + if ( command3 == OPackage::Install ) + m_installFound = true; } // Initialize UI if ( parent ) parent->setCaption( caption ); QGridLayout *layout = new QGridLayout( this, 4, 2, 2, 4 ); - if ( showDestInfo ) + if ( m_installFound ) { 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 ].isEmpty() ) { 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; }; lineStr.append( ":\n" ); QStringList tmpPackage = m_packages[ i ]; for ( QStringList::Iterator it = tmpPackage.begin(); it != tmpPackage.end(); ++it ) { lineStr.append( QString( "\t%1\n" ).arg( ( *it ) ) ); } m_output->append( lineStr ); } } m_output->append( tr( "Press the start button to begin.\n" ) ); m_output->setCursorPosition( m_output->numLines(), 0 ); } void InstallDlg::slotDisplayAvailSpace( const QString &destination ) { // If available space is not displayed, exit if ( !m_availSpace ) return; QString space = tr( "Unknown" ); // Get destination if ( !destination.isNull() ) m_destItem = m_packman->findConfItem( OConfItem::Destination, destination ); if ( m_destItem ) { // Calculate available space struct statfs fs; if ( !statfs( m_destItem->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 QString dest; - if ( m_destination ) + if ( m_installFound ) { dest = m_destination->currentText(); m_destination->setEnabled( false ); } m_btnOptions->setEnabled( false ); if ( m_numCommands > 1 ) { m_btnStart->setText( tr( "Abort" ) ); m_btnStart->setIconSet( Resource::loadPixmap( "close" ) ); } else { m_btnStart->setEnabled( false ); } + Opie::Core::OProcess process( this ); 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 ); + + // Link/Unlink application if the package was removed from or installed to a destination + // other than root + if ( ( m_command[ m_currCommand ] == OPackage::Install && dest != "root" ) || + ( m_command[ m_currCommand ] == OPackage::Remove ) ) + { + //m_packman->findPackage( m_packages[ m_currCommand ]->destination() != "root"*/ ) + + // Loop through all package names in the command group + for ( QStringList::Iterator it = m_packages[ m_currCommand ].begin(); + it != m_packages[ m_currCommand ].end(); + ++it ) + { + OPackage *currPackage = m_packman->findPackage( (*it) ); + + // Skip package if it is not found or being removed from 'root' + if ( !currPackage || ( m_command[ m_currCommand ] == OPackage::Remove && + currPackage->destination() == "root" ) ) + continue; + + // Display feedback to user + if ( m_command[ m_currCommand ] == OPackage::Install ) + m_output->append( tr( QString( "Running ipkg-link to link package '%1'." ) + .arg( currPackage->name() ) ) ); + else + m_output->append( tr( QString( "Running ipkg-link to remove links for package '%1'." ) + .arg( currPackage->name() ) ) ); + m_output->setCursorPosition( m_output->numLines(), 0 ); + + // Execute ipkg-link + process.clearArguments(); + process << "ipkg-link" + << ( ( m_command[ m_currCommand ] == OPackage::Install ) ? "add" : "remove" ) + << currPackage->name(); + if ( !process.start( Opie::Core::OProcess::Block, + Opie::Core::OProcess::NoCommunication ) ) + { + slotProcessDone( 0x0 ); + m_output->append( tr( "Unable to run ipkg-link." ) ); + m_output->setCursorPosition( m_output->numLines(), 0 ); + return; + } + } + + } } - slotProcessDone(0l); - - // Get destination -/* - if ( dest == "root" ) - { - slotProcessDone(0l); - return; - } - - m_destItem = m_packman->findConfItem( OConfItem::Destination, dest ); - if ( m_destItem ) - { - QString path = m_destItem->value(); - Opie::Core::OProcess *process = new Opie::Core::OProcess( this, "ipkg-link process" ); - connect( process, SIGNAL(processExited(Opie::Core::OProcess*)), - this, SLOT(slotProcessDone(Opie::Core::OProcess*)) ); - - *process << "ipkg-link" << "mount" << path; - if ( !process->start( Opie::Core::OProcess::NotifyOnExit, - Opie::Core::OProcess::NoCommunication ) ) - slotProcessDone( 0l ); - m_output->append( tr( "Starting ipkg-link to link installed applications." ) ); - m_output->setCursorPosition( m_output->numLines(), 0 ); - } -*/ + + slotProcessDone( 0x0 ); } void InstallDlg::slotProcessDone( Opie::Core::OProcess *proc ) { - delete proc; - - m_output->append( tr( "The package linking is done." ) ); - m_output->setCursorPosition( m_output->numLines(), 0 ); - + if ( proc ) + { + // Display message pnly if linking was done + m_output->append( tr( "The package linking is done." ) ); + m_output->setCursorPosition( m_output->numLines(), 0 ); + + delete proc; + } + // 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 = 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 ); // Update available space slotDisplayAvailSpace( QString::null ); } diff --git a/noncore/settings/packagemanager/installdlg.h b/noncore/settings/packagemanager/installdlg.h index f45c17c..eabb717 100644 --- a/noncore/settings/packagemanager/installdlg.h +++ b/noncore/settings/packagemanager/installdlg.h @@ -1,98 +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 INSTALLDLG_H #define INSTALLDLG_H #include <qwidget.h> #include "opackage.h" class QComboBox; class QLabel; class QMultiLineEdit; class QPushButton; class OConfItem; class OPackageManager; namespace Opie { namespace Core { class OProcess; } } class InstallDlg : public QWidget { Q_OBJECT public: - InstallDlg( QWidget *parent = 0x0, OPackageManager *pm = 0x0, const QString &caption = QString::null, - bool showDestInfo = true, + InstallDlg( QWidget *parent = 0x0, OPackageManager *pm = 0x0, + const QString &caption = QString::null, OPackage::Command command1 = OPackage::NotDefined, const QStringList &packages1 = QStringList(), OPackage::Command command2 = OPackage::NotDefined, const QStringList &packages2 = QStringList(), OPackage::Command command3 = OPackage::NotDefined, const QStringList &packages3 = QStringList() ); private: OPackageManager *m_packman; // Pointer to application instance of package manager + + bool m_installFound; // Indicates if an install is being done, controls display of + // destination selection, available space // UI controls QComboBox *m_destination; // Destination selection list QLabel *m_availSpace; // Text label to display available space on selected destination QMultiLineEdit *m_output; // Multi-line edit to display status QPushButton *m_btnStart; // Start/abort/close button QPushButton *m_btnOptions; // Installation options button // Commands and packages to execute int m_numCommands; // Number of commands to be executed int m_currCommand; // Number of currently executing command OPackage::Command m_command[3]; // List of commands to be executed QStringList m_packages[3]; // Lists of package names associated to commands (m_command[]) OConfItem *m_destItem; // Pointer to destination for package installation private slots: // UI control slots void slotDisplayAvailSpace( const QString &destination ); void slotBtnStart(); void slotBtnOptions(); void slotProcessDone( Opie::Core::OProcess *proc ); // Execution slots void slotOutput( char *msg ); signals: void closeInstallDlg(); }; #endif diff --git a/noncore/settings/packagemanager/mainwindow.cpp b/noncore/settings/packagemanager/mainwindow.cpp index 459a75b..8a5b90c 100644 --- a/noncore/settings/packagemanager/mainwindow.cpp +++ b/noncore/settings/packagemanager/mainwindow.cpp @@ -123,604 +123,601 @@ void MainWindow::initPackageList() 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 ); // Find toolbar addToolBar( &m_findBar, QMainWindow::Top, true ); m_findBar.setHorizontalStretchable( true ); m_findEdit = new QLineEdit( &m_findBar ); QWhatsThis::add( m_findEdit, tr( "Type the text to search for here." ) ); m_findBar.setStretchableWidget( m_findEdit ); connect( m_findEdit, SIGNAL(textChanged(const QString&)), this, SLOT(slotFindChanged(const QString&)) ); // Packages menu QPopupMenu *popup = new QPopupMenu( this ); QAction *a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "packagemanager/update" ), QString::null, 0, this, 0 ); a->setWhatsThis( tr( "Tap here to update package lists from servers." ) ); connect( a, SIGNAL(activated()), this, SLOT(slotUpdate()) ); a->addTo( popup ); a->addTo( &m_toolBar ); QAction *actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "packagemanager/upgrade" ), QString::null, 0, this, 0 ); actionUpgrade->setWhatsThis( tr( "Tap here to upgrade all installed packages if a newer version is available." ) ); connect( actionUpgrade, SIGNAL(activated()), this, SLOT(slotUpgrade()) ); actionUpgrade->addTo( popup ); actionUpgrade->addTo( &m_toolBar ); QPixmap iconDownload = Resource::loadPixmap( "packagemanager/download" ); QPixmap iconRemove = Resource::loadPixmap( "packagemanager/remove" ); QAction *actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); actionDownload->setWhatsThis( tr( "Tap here to download the currently selected package(s)." ) ); connect( actionDownload, SIGNAL(activated()), this, SLOT(slotDownload()) ); actionDownload->addTo( popup ); actionDownload->addTo( &m_toolBar ); a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "packagemanager/apply" ), QString::null, 0, this, 0 ); a->setWhatsThis( tr( "Tap here to install, remove or upgrade currently selected package(s)." ) ); connect( a, SIGNAL(activated()), this, SLOT(slotApply()) ); a->addTo( popup ); a->addTo( &m_toolBar ); a = new QAction( tr( "Install local package" ), Resource::loadPixmap( "folder" ), QString::null, 0, this, 0 ); a->setWhatsThis( tr( "Tap here to install a package file located on device." ) ); connect( a, SIGNAL(activated()), this, SLOT(slotInstallLocal()) ); a->addTo( popup ); //a->addTo( &m_toolBar ); popup->insertSeparator(); a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); a->setWhatsThis( tr( "Tap here to configure this application." ) ); connect( a, SIGNAL(activated()), this, SLOT(slotConfigure()) ); a->addTo( popup ); mb->insertItem( tr( "Actions" ), popup ); // View menu popup = new QPopupMenu( this ); m_actionShowNotInstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); m_actionShowNotInstalled->setToggleAction( true ); m_actionShowNotInstalled->setWhatsThis( tr( "Tap here to show packages available which have not been installed." ) ); connect( m_actionShowNotInstalled, SIGNAL(activated()), this, SLOT(slotShowNotInstalled()) ); m_actionShowNotInstalled->addTo( popup ); m_actionShowInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); m_actionShowInstalled->setToggleAction( true ); m_actionShowInstalled->setWhatsThis( tr( "Tap here to show packages currently installed on this device." ) ); connect( m_actionShowInstalled, SIGNAL(activated()), this, SLOT(slotShowInstalled()) ); m_actionShowInstalled->addTo( popup ); m_actionShowUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); m_actionShowUpdated->setToggleAction( true ); m_actionShowUpdated->setWhatsThis( tr( "Tap here to show packages currently installed on this device which have a newer version available." ) ); connect( m_actionShowUpdated, SIGNAL(activated()), this, SLOT(slotShowUpdated()) ); m_actionShowUpdated->addTo( popup ); popup->insertSeparator(); m_actionFilter = new QAction( tr( "Filter" ), Resource::loadPixmap( "packagemanager/filter" ), QString::null, 0, this, 0 ); m_actionFilter->setToggleAction( true ); m_actionFilter->setWhatsThis( tr( "Tap here to apply current filter." ) ); connect( m_actionFilter, SIGNAL(toggled(bool)), this, SLOT(slotFilter(bool)) ); m_actionFilter->addTo( popup ); a = new QAction( tr( "Filter settings" ), QString::null, 0, this, 0 ); a->setWhatsThis( tr( "Tap here to change the package filter criteria." ) ); connect( a, SIGNAL(activated()), this, SLOT(slotFilterChange()) ); a->addTo( popup ); popup->insertSeparator(); a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); a->setWhatsThis( tr( "Tap here to search for text in package names." ) ); connect( a, SIGNAL(activated()), this, SLOT(slotFindShowToolbar()) ); a->addTo( popup ); m_actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); m_actionFindNext->setEnabled( false ); m_actionFindNext->setWhatsThis( tr( "Tap here to find the next package name containing the text you are searching for." ) ); connect( m_actionFindNext, SIGNAL(activated()), this, SLOT(slotFindNext()) ); m_actionFindNext->addTo( popup ); m_actionFindNext->addTo( &m_findBar ); mb->insertItem( tr( "View" ), popup ); // Finish find toolbar creation a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); a->setWhatsThis( tr( "Tap here to hide the find toolbar." ) ); connect( a, SIGNAL(activated()), this, SLOT(slotFindHideToolbar()) ); a->addTo( &m_findBar ); m_findBar.hide(); } void MainWindow::loadPackageList( OPackageList *packages, bool clearList ) { if ( clearList ) m_packageList.clear(); if ( packages ) { for ( OPackageListIterator packageIt( *packages ); packageIt.current(); ++packageIt ) { OPackage *package = packageIt.current(); QCheckListItem *item = new QCheckListItem( &m_packageList, package->name(), QCheckListItem::CheckBox ); m_packageList.insertItem( item ); // If a different version of package is available, show update available icon // Otherwise, show installed icon if ( !package->versionInstalled().isNull() ) { if ( m_packman.compareVersions( package->version(), package->versionInstalled() ) == 1 ) item->setPixmap( 0, m_iconUpdated ); else item->setPixmap( 0, m_iconInstalled ); } else item->setPixmap( 0, m_iconNull ); } } } void MainWindow::searchForPackage( const QString &text ) { if ( !text.isEmpty() ) { // look through package list for text startng at current position QCheckListItem *start = static_cast<QCheckListItem *>(m_packageList.currentItem()); if ( start == 0 ) start = static_cast<QCheckListItem *>(m_packageList.firstChild()); // for ( QCheckListItem *item = static_cast<QCheckListItem *>(start->nextSibling()); item != 0 ; for ( QCheckListItem *item = static_cast<QCheckListItem *>(start); item != 0 ; item = static_cast<QCheckListItem *>(item->nextSibling()) ) { if ( item->text().lower().find( text ) != -1 ) { m_packageList.ensureItemVisible( item ); m_packageList.setCurrentItem( item ); break; } } } } void MainWindow::installLocalPackage( const QString &ipkFile ) { // Install selected file - InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Install local package" ), true, - OPackage::Install, ipkFile ); + InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Install local package" ), + OPackage::Install, ipkFile ); connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); // Display widget m_widgetStack.addWidget( dlg, 3 ); m_widgetStack.raiseWidget( dlg ); } void MainWindow::setDocument( const QString &ipkFile ) { QString file = ipkFile; DocLnk lnk( ipkFile ); if ( lnk.isValid() ) file = lnk.file(); installLocalPackage( file ); } void MainWindow::initPackageInfo() { m_widgetStack.raiseWidget( &m_statusWidget ); // Load package list m_packman.loadAvailablePackages(); m_packman.loadInstalledPackages(); OPackageList *packageList = m_packman.packages(); if ( packageList ) { loadPackageList( packageList, true ); delete packageList; } QWidget *widget = m_widgetStack.widget( 3 ); if ( !widget ) widget = &m_packageList; m_widgetStack.raiseWidget( widget ); } void MainWindow::slotWidgetStackShow( QWidget *widget ) { if ( widget == &m_packageList ) { setCaption( tr( "Package Manager" ) ); m_menuBar.show(); m_toolBar.show(); } else { m_menuBar.hide(); m_toolBar.hide(); } } void MainWindow::slotInitStatusBar( int numSteps ) { m_statusBar.setTotalSteps( numSteps ); } void MainWindow::slotStatusText( const QString &status ) { m_statusText.setText( status ); } void MainWindow::slotStatusBar( int currStep ) { m_statusBar.setProgress( currStep ); } void MainWindow::slotUpdate() { // Create package manager output widget - InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Update package information" ), false, + InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Update package information" ), OPackage::Update ); connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); // Display widget m_widgetStack.addWidget( dlg, 3 ); m_widgetStack.raiseWidget( dlg ); } void MainWindow::slotUpgrade() { // Create package manager output widget - InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Upgrade installed packages" ), false, + InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Upgrade installed packages" ), OPackage::Upgrade ); connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); // Display widget m_widgetStack.addWidget( dlg, 3 ); m_widgetStack.raiseWidget( dlg ); } void MainWindow::slotDownload() { // Retrieve list of packages selected for download (if any) QStringList workingPackages; for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild()); item != 0 ; item = static_cast<QCheckListItem *>(item->nextSibling()) ) { if ( item->isOn() ) workingPackages.append( item->text() ); } if ( workingPackages.isEmpty() ) { QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) ); return; } else { // Download selected packages m_config.setGroup( "settings" ); QString workingDir = m_config.readEntry( "DownloadDir", "/tmp" ); bool ok = false; QString text = EntryDlg::getText( tr( "Download" ), tr( "Enter path to download package to:" ), workingDir, &ok, this ); if ( ok && !text.isEmpty() ) workingDir = text; // user entered something and pressed ok else return; // user entered nothing or pressed cancel // Store download directory in config file m_config.writeEntry( "DownloadDir", workingDir ); // Get starting directory QDir::setCurrent( workingDir ); // Create package manager output widget - InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Download packages" ), false, - OPackage::Download, workingPackages ); + InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Download packages" ), + OPackage::Download, workingPackages ); connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); // Display widget m_widgetStack.addWidget( dlg, 3 ); m_widgetStack.raiseWidget( dlg ); } } void MainWindow::slotApply() { QStringList removeList; QStringList installList; QStringList upgradeList; for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild()); item != 0 ; item = static_cast<QCheckListItem *>(item->nextSibling()) ) { if ( item->isOn() ) { OPackage *package = m_packman.findPackage( item->text() ); if ( package ) { if ( !package->versionInstalled().isNull() ) { if ( m_packman.compareVersions( package->version(), package->versionInstalled() ) == 1 ) { // Remove/upgrade package int answer = PromptDlg::ask( tr( "Remove or upgrade" ), tr( QString( "Do you wish to remove or upgrade\n%1?" ).arg( item->text() ) ), tr( "Remove" ), tr( "Upgrade" ), this ); if ( answer == 1 ) // Remove { removeList.append( item->text() ); } else if ( answer == 2 ) // Upgrade { upgradeList.append( item->text() ); } } else { // Remove/reinstall package int answer = PromptDlg::ask( tr( "Remove or reinstall" ), tr( QString( "Do you wish to remove or reinstall\n%1?" ).arg( item->text() ) ), tr( "Remove" ), tr( "Reinstall" ), this ); if ( answer == 1 ) // Remove { removeList.append( item->text() ); } else if ( answer == 2 ) // Reinstall { installList.append( item->text() ); } } } else { // Install package installList.append( item->text() ); } } } } // If nothing is selected, display message and exit if ( removeList.isEmpty() && installList.isEmpty() && upgradeList.isEmpty() ) { QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) ); return; } // Send command only if there are packages to process - OPackage::Command removeCmd = OPackage::NotDefined; - if ( !removeList.isEmpty() ) - removeCmd = OPackage::Remove; - OPackage::Command installCmd = OPackage::NotDefined; - if ( !installList.isEmpty() ) - installCmd = OPackage::Install; - OPackage::Command upgradeCmd = OPackage::NotDefined; - if ( !upgradeList.isEmpty() ) - upgradeCmd = OPackage::Upgrade; + OPackage::Command removeCmd = !removeList.isEmpty() ? OPackage::Remove + : OPackage::NotDefined; + OPackage::Command installCmd = !installList.isEmpty() ? OPackage::Install + : OPackage::NotDefined; + OPackage::Command upgradeCmd = !upgradeList.isEmpty() ? OPackage::Upgrade + : OPackage::NotDefined; // Create package manager output widget - InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Apply changes" ), !installList.isEmpty(), + InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Apply changes" ), removeCmd, removeList, installCmd, installList, upgradeCmd, upgradeList ); connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); // Display widget m_widgetStack.addWidget( dlg, 3 ); m_widgetStack.raiseWidget( dlg ); } void MainWindow::slotInstallLocal() { // Display file open dialog with only package files MimeTypes type; QStringList packages; packages << "application/ipkg"; type.insert( tr( "Application Packages" ), packages ); QString package = Opie::Ui::OFileDialog::getOpenFileName( Opie::Ui::OFileSelector::NORMAL, "/", QString::null, type ); if ( !package.isNull() ) installLocalPackage( package ); } void MainWindow::slotCloseDlg() { // Close install dialog delete m_widgetStack.visibleWidget(); // Reload package list initPackageInfo(); // Update Opie launcher links QCopEnvelope e("QPE/System", "linkChanged(QString)"); QString lf = QString::null; e << lf; // Reapply any filters previously set if ( m_actionShowNotInstalled->isOn() ) slotShowNotInstalled(); else if ( m_actionShowInstalled->isOn() ) slotShowInstalled(); else if ( m_actionShowUpdated->isOn() ) slotShowUpdated(); else if ( m_actionFilter->isOn() ) slotFilter( true ); } void MainWindow::slotConfigure() { if ( m_packman.configureDlg( false ) ) { if ( PromptDlg::ask( tr( "Config updated" ), tr( "The configuration has been updated. Do you want to update server and package information now?" ), tr( "Yes" ), tr( "No" ), this ) == 1 ) { // Update package list and reload package info slotUpdate(); } } } void MainWindow::slotShowNotInstalled() { OPackageList *packageList; if ( m_actionShowNotInstalled->isOn() ) { m_actionShowInstalled->setOn( false ); m_actionShowUpdated->setOn( false ); m_actionFilter->setOn( false ); packageList = m_packman.filterPackages( QString::null, QString::null, QString::null, OPackageManager::NotInstalled, QString::null ); } else packageList = m_packman.packages(); if ( packageList ) { loadPackageList( packageList, true ); delete packageList; } } void MainWindow::slotShowInstalled() { OPackageList *packageList; if ( m_actionShowInstalled->isOn() ) { m_actionShowNotInstalled->setOn( false ); m_actionShowUpdated->setOn( false ); m_actionFilter->setOn( false ); packageList = m_packman.filterPackages( QString::null, QString::null, QString::null, OPackageManager::Installed, QString::null ); } else packageList = m_packman.packages(); if ( packageList ) { loadPackageList( packageList, true ); delete packageList; } } void MainWindow::slotShowUpdated() { OPackageList *packageList; if ( m_actionShowUpdated->isOn() ) { m_actionShowInstalled->setOn( false ); m_actionShowNotInstalled->setOn( false ); m_actionFilter->setOn( false ); packageList = m_packman.filterPackages( QString::null, QString::null, QString::null, OPackageManager::Updated, QString::null ); } else packageList = m_packman.packages(); if ( packageList ) { loadPackageList( packageList, true ); delete packageList; } } void MainWindow::slotFilterChange() { FilterDlg dlg( this, &m_packman, m_filterName, m_filterServer, m_filterDest, m_filterStatus, m_filterCategory ); if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) { m_filterName = dlg.name(); m_filterServer = dlg.server(); m_filterDest = dlg.destination(); m_filterStatus = dlg.status(); m_filterCategory = dlg.category(); m_actionFilter->setOn( true ); slotFilter( true ); } else { m_actionFilter->setOn( false ); slotFilter( false ); } } void MainWindow::slotFilter( bool isOn ) { OPackageList *packageList; if ( isOn ) { // Turn off other filtering options m_actionShowNotInstalled->setOn( false ); m_actionShowInstalled->setOn( false ); m_actionShowUpdated->setOn( false ); // If the filter settings have not been set yet, display filter dialog if ( m_filterName.isNull() && m_filterServer.isNull() && m_filterDest.isNull() && m_filterStatus == OPackageManager::NotDefined && m_filterCategory.isNull() ) { FilterDlg dlg( this, &m_packman, m_filterName, m_filterServer, m_filterDest, m_filterStatus, m_filterCategory ); if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) { m_filterName = dlg.name(); m_filterServer = dlg.server(); m_filterDest = dlg.destination(); m_filterStatus = dlg.status(); m_filterCategory = dlg.category(); m_actionFilter->setOn( true ); packageList = m_packman.filterPackages( m_filterName, m_filterServer, m_filterDest, m_filterStatus, m_filterCategory ); } else { m_actionFilter->setOn( false ); packageList = m_packman.packages(); } } else { m_actionFilter->setOn( true ); packageList = m_packman.filterPackages( m_filterName, m_filterServer, m_filterDest, m_filterStatus, m_filterCategory ); } } else packageList = m_packman.packages(); if ( packageList ) { diff --git a/noncore/settings/packagemanager/opie-packagemanager.control b/noncore/settings/packagemanager/opie-packagemanager.control index 5385ea5..aacd0ca 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 (>=0.99.120) +Depends: task-opie-minimal, libopiecore2, libopieui2, libipkg (>=0.99.120), ipkg-link Replaces: packagemanager Architecture: arm Maintainer: Dan Williams (drw@handhelds.org) Description: Opie package management client -Version: 0.4.0$EXTRAVERSION +Version: 0.5.0$EXTRAVERSION |