summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/packagemanager/filterdlg.cpp4
-rw-r--r--noncore/settings/packagemanager/installdlg.cpp60
-rw-r--r--noncore/settings/packagemanager/installdlg.h59
-rw-r--r--noncore/settings/packagemanager/mainwindow.cpp42
-rw-r--r--noncore/settings/packagemanager/mainwindow.h2
-rw-r--r--noncore/settings/packagemanager/oconfitem.h46
-rw-r--r--noncore/settings/packagemanager/oipkg.cpp56
-rw-r--r--noncore/settings/packagemanager/oipkg.h51
-rw-r--r--noncore/settings/packagemanager/opackagemanager.cpp56
-rw-r--r--noncore/settings/packagemanager/opackagemanager.h57
-rw-r--r--noncore/settings/packagemanager/packageinfodlg.cpp46
-rw-r--r--noncore/settings/packagemanager/promptdlg.h52
12 files changed, 265 insertions, 266 deletions
diff --git a/noncore/settings/packagemanager/filterdlg.cpp b/noncore/settings/packagemanager/filterdlg.cpp
index 0e1ea52..e69b6eb 100644
--- a/noncore/settings/packagemanager/filterdlg.cpp
+++ b/noncore/settings/packagemanager/filterdlg.cpp
@@ -11,184 +11,184 @@ _;:, .> :=|. This file is free software; you can
- . .-<_> .<> 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 "filterdlg.h"
#include <qwhatsthis.h>
FilterDlg::FilterDlg( QWidget *parent, OPackageManager *pm, const QString &name,
const QString &server, const QString &destination,
OPackageManager::Status status, const QString &category )
: QDialog( parent, QString::null, true, WStyle_ContextHelp )
{
setCaption( tr( "Filter packages" ) );
QVBoxLayout *layout = new QVBoxLayout( this );
QScrollView *sv = new QScrollView( this );
layout->addWidget( sv, 0, 0 );
sv->setResizePolicy( QScrollView::AutoOneFit );
sv->setFrameStyle( QFrame::NoFrame );
QWidget *container = new QWidget( sv->viewport() );
sv->addChild( container );
layout = new QVBoxLayout( container, 4, 4 );
// Category
m_categoryCB = new QCheckBox( tr( "Category:" ), container );
QWhatsThis::add( m_categoryCB, tr( "Tap here to filter package list by application category." ) );
connect( m_categoryCB, SIGNAL(toggled(bool)), this, SLOT(slotCategorySelected(bool)) );
m_category = new QComboBox( container );
QWhatsThis::add( m_category, tr( "Select the application category to filter by here." ) );
m_category->insertStringList( pm->categories() );
initItem( m_category, m_categoryCB, category );
layout->addWidget( m_categoryCB );
layout->addWidget( m_category );
// Package name
m_nameCB = new QCheckBox( tr( "Names containing:" ), container );
QWhatsThis::add( m_nameCB, tr( "Tap here to filter package list by package name." ) );
connect( m_nameCB, SIGNAL(toggled(bool)), this, SLOT(slotNameSelected(bool)) );
m_name = new QLineEdit( name, container );
QWhatsThis::add( m_name, tr( "Enter the package name to filter by here." ) );
if ( !name.isNull() )
m_nameCB->setChecked( true );
m_name->setEnabled( !name.isNull() );
layout->addWidget( m_nameCB );
layout->addWidget( m_name );
// Status
m_statusCB = new QCheckBox( tr( "With the status:" ), container );
QWhatsThis::add( m_statusCB, tr( "Tap here to filter package list by the package status." ) );
connect( m_statusCB, SIGNAL(toggled(bool)), this, SLOT(slotStatusSelected(bool)) );
m_status = new QComboBox( container );
QWhatsThis::add( m_status, tr( "Select the package status to filter by here." ) );
connect( m_status, SIGNAL(activated(const QString&)), this, SLOT(slotStatusChanged(const QString&)) );
QString currStatus;
switch ( status )
{
case OPackageManager::All : currStatus = tr( "All" );
break;
case OPackageManager::Installed : currStatus = tr( "Installed" );
break;
case OPackageManager::NotInstalled : currStatus = tr( "Not installed" );
break;
case OPackageManager::Updated : currStatus = tr( "Updated" );
break;
default : currStatus = QString::null;
};
m_status->insertItem( tr( "All" ) );
m_status->insertItem( tr( "Installed" ) );
m_status->insertItem( tr( "Not installed" ) );
m_status->insertItem( tr( "Updated" ) );
initItem( m_status, m_statusCB, currStatus );
layout->addWidget( m_statusCB );
layout->addWidget( m_status );
// Server
m_serverCB = new QCheckBox( tr( "Available from the following server:" ), container );
QWhatsThis::add( m_serverCB, tr( "Tap here to filter package list by source server." ) );
connect( m_serverCB, SIGNAL(toggled(bool)), this, SLOT(slotServerSelected(bool)) );
m_server = new QComboBox( container );
QWhatsThis::add( m_server, tr( "Select the source server to filter by here." ) );
- m_server->insertStringList( *(pm->servers()) );
+ m_server->insertStringList( pm->servers() );
initItem( m_server, m_serverCB, server );
layout->addWidget( m_serverCB );
layout->addWidget( m_server );
// Destination
m_destCB = new QCheckBox( tr( "Installed on device at:" ), container );
QWhatsThis::add( m_destCB, tr( "Tap here to filter package list by destination where the package is installed to on this device." ) );
connect( m_destCB, SIGNAL(toggled(bool)), this, SLOT(slotDestSelected(bool)) );
m_destination = new QComboBox( container );
QWhatsThis::add( m_destination, tr( "Select the destination location to filter by here." ) );
- m_destination->insertStringList( *(pm->destinations()) );
+ m_destination->insertStringList( pm->destinations() );
initItem( m_destination, m_destCB, destination );
layout->addWidget( m_destCB );
layout->addWidget( m_destination );
}
void FilterDlg::initItem( QComboBox *comboBox, QCheckBox *checkBox, const QString &selection )
{
if ( !selection.isNull() )
{
checkBox->setChecked( true );
for ( int i = 0; i < comboBox->count(); i++ )
{
if ( comboBox->text( i ) == selection )
{
comboBox->setCurrentItem( i );
return;
}
}
}
comboBox->setEnabled( !selection.isNull() );
}
void FilterDlg::slotNameSelected( bool selected )
{
m_name->setEnabled( selected );
m_name->setFocus();
}
void FilterDlg::slotServerSelected( bool selected )
{
m_server->setEnabled( selected );
m_server->setFocus();
}
void FilterDlg::slotDestSelected( bool selected )
{
m_destination->setEnabled( selected );
m_destination->setFocus();
}
void FilterDlg::slotStatusSelected( bool selected )
{
m_status->setEnabled( selected );
m_status->setFocus();
if ( !selected && !m_destCB->isEnabled() )
{
// If status check box has been deselected and destination option was previously deselected
// (because status == "Not installed"), re-enable destination option
m_destCB->setEnabled( true );
m_destination->setEnabled( true );
}
else if ( selected && m_destCB->isEnabled() && m_status->currentText() == tr( "Not installed" ) )
{
// If status check box has been selected and status == "Not installed", disable destination option
m_destCB->setEnabled( false );
m_destCB->setChecked( false );
m_destination->setEnabled( false );
}
}
void FilterDlg::slotStatusChanged( const QString &category )
{
bool notInstalled = ( category == tr( "Not installed" ) );
m_destCB->setEnabled( !notInstalled );
m_destination->setEnabled( !notInstalled );
if ( notInstalled )
m_destCB->setChecked( false );
}
void FilterDlg::slotCategorySelected( bool selected )
{
m_category->setEnabled( selected );
m_category->setFocus();
}
diff --git a/noncore/settings/packagemanager/installdlg.cpp b/noncore/settings/packagemanager/installdlg.cpp
index 0cb30e2..945dfed 100644
--- a/noncore/settings/packagemanager/installdlg.cpp
+++ b/noncore/settings/packagemanager/installdlg.cpp
@@ -1,267 +1,263 @@
/*
-                This file is part of the OPIE Project
+ 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.,
+ .=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 <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,
- OPackage::Command command1, QStringList *packages1,
- OPackage::Command command2, QStringList *packages2,
- OPackage::Command command3, QStringList *packages3 )
+ OPackage::Command command1, const QStringList &packages1,
+ OPackage::Command command2, const QStringList &packages2,
+ OPackage::Command command3, const 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()) );
+ 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 ] )
+ 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" );
- for ( QStringList::Iterator it = m_packages[ i ]->begin(); it != m_packages[ i ]->end(); ++it )
+ 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 );
}
InstallDlg::~InstallDlg()
{
- for( int i = 0; i < m_numCommands; i++ )
- {
- if ( m_packages[ i ] )
- delete m_packages[ i ];
- }
}
void InstallDlg::slotDisplayAvailSpace( const QString &destination )
{
// If available space is not displayed, exit
if ( !m_availSpace )
return;
QString space = tr( "Unknown" );
// 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;
}
diff --git a/noncore/settings/packagemanager/installdlg.h b/noncore/settings/packagemanager/installdlg.h
index 4da9cf6..cddc911 100644
--- a/noncore/settings/packagemanager/installdlg.h
+++ b/noncore/settings/packagemanager/installdlg.h
@@ -1,85 +1,88 @@
/*
-                This file is part of the OPIE Project
+ 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.,
+ .=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 OPackageManager;
class InstallDlg : public QWidget
{
Q_OBJECT
public:
InstallDlg( QWidget *parent = 0x0, OPackageManager *pm = 0x0, const QString &caption = QString::null,
bool showDestInfo = true,
- OPackage::Command command1 = OPackage::NotDefined, QStringList *packages1 = 0x0,
- OPackage::Command command2 = OPackage::NotDefined, QStringList *packages2 = 0x0,
- OPackage::Command command3 = OPackage::NotDefined, QStringList *packages3 = 0x0 );
+ 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() );
~InstallDlg();
private:
OPackageManager *m_packman; // Pointer to application instance of package manager
// 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[])
+ 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[])
private slots:
// UI control slots
void slotDisplayAvailSpace( const QString &destination );
void slotBtnStart();
void slotBtnOptions();
// 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 349094d..5e15874 100644
--- a/noncore/settings/packagemanager/mainwindow.cpp
+++ b/noncore/settings/packagemanager/mainwindow.cpp
@@ -220,417 +220,407 @@ void MainWindow::initUI()
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, new QStringList( ipkFile ) );
+ 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,
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,
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 = new QStringList();
+ 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() );
+ workingPackages.append( item->text() );
}
- if ( workingPackages->isEmpty() )
+ 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 );
connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) );
// Display widget
m_widgetStack.addWidget( dlg, 3 );
m_widgetStack.raiseWidget( dlg );
}
}
void MainWindow::slotApply()
{
- QStringList *removeList = 0x0;
- QStringList *installList = 0x0;
- QStringList *upgradeList = 0x0;
+ 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
{
- if ( !removeList )
- removeList = new QStringList();
- removeList->append( item->text() );
+ removeList.append( item->text() );
}
else if ( answer == 2 ) // Upgrade
{
- if ( !upgradeList )
- upgradeList = new QStringList();
- upgradeList->append( item->text() );
+ 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
{
- if ( !removeList )
- removeList = new QStringList();
- removeList->append( item->text() );
+ removeList.append( item->text() );
}
else if ( answer == 2 ) // Reinstall
{
- if ( !installList )
- installList = new QStringList();
- installList->append( item->text() );
+ installList.append( item->text() );
}
}
}
else
{
// Install package
- if ( !installList )
- installList = new QStringList();
- installList->append( item->text() );
+ installList.append( item->text() );
}
}
}
}
// If nothing is selected, display message and exit
- if ( !removeList && !installList && !upgradeList )
+ 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 && !removeList->isEmpty() )
+ if ( !removeList.isEmpty() )
removeCmd = OPackage::Remove;
OPackage::Command installCmd = OPackage::NotDefined;
- if ( installList && !installList->isEmpty() )
+ if ( !installList.isEmpty() )
installCmd = OPackage::Install;
OPackage::Command upgradeCmd = OPackage::NotDefined;
- if ( upgradeList && !upgradeList->isEmpty() )
+ if ( !upgradeList.isEmpty() )
upgradeCmd = OPackage::Upgrade;
// Create package manager output widget
InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Apply changes" ), true,
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 );
diff --git a/noncore/settings/packagemanager/mainwindow.h b/noncore/settings/packagemanager/mainwindow.h
index 103c664..f00e344 100644
--- a/noncore/settings/packagemanager/mainwindow.h
+++ b/noncore/settings/packagemanager/mainwindow.h
@@ -1,143 +1,143 @@
/*
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>
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" ); };
+ static QString appName() { return QString::fromLatin1( QUICKAPP_NAME ); };
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 );
void installLocalPackage( const QString &ipkFile );
private slots:
void setDocument( const QString &ipkFile );
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 slotInstallLocal();
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.h b/noncore/settings/packagemanager/oconfitem.h
index db77980..7c158c9 100644
--- a/noncore/settings/packagemanager/oconfitem.h
+++ b/noncore/settings/packagemanager/oconfitem.h
@@ -1,92 +1,92 @@
/*
-                This file is part of the Opie Project
+ This file is part of the Opie Project
-              Copyright (c) 2003 Dan Williams <drw@handhelds.org>
+ 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.
+ .>+-=
+_;:, .> :=|. 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( Type type = NotDefined, const QString &name = 0x0, const QString &value = 0x0,
- bool active = true );
+ OConfItem( Type type = NotDefined, const QString &name = QString::null,
+ const QString &value = QString::null, bool active = true );
Type type() { return m_type; }
const QString &name() { return m_name; }
const QString &value() { return m_value; }
bool active() { return m_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:
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
OConfItem::Type type1 = reinterpret_cast<OConfItem*>(item1)->type();
OConfItem::Type type2 = reinterpret_cast<OConfItem*>(item2)->type();
if ( type1 < type2 )
return -1;
else if ( type1 == type2 )
{
QString name1 = reinterpret_cast<OConfItem*>(item1)->name();
QString name2 = reinterpret_cast<OConfItem*>(item2)->name();
if ( name1 < name2 )
return -1;
else if ( name1 == name2 )
return 0;
else /*if ( name1 > name2 )*/
return 1;
}
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 1978ad5..b0cc94d 100644
--- a/noncore/settings/packagemanager/oipkg.cpp
+++ b/noncore/settings/packagemanager/oipkg.cpp
@@ -1,150 +1,152 @@
/*
-                This file is part of the Opie Project
+ This file is part of the Opie Project
-              Copyright (c) 2003 Dan Williams <drw@handhelds.org>
+ 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.
+ .>+-=
+_;:, .> :=|. 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 <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 )
{
if ( conf && ( conf->verbosity < level ) )
return 0;
else
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 );
confStream << "# Generated by Opie Package Manager\n\n";
OConfItemListIterator it( *m_confInfo );
for ( ; it.current(); ++it )
{
OConfItem *item = it.current();
// Only write out valid conf items
if ( item->type() != OConfItem::NotDefined )
{
QString confLine;
if ( !item->active() )
confLine = "#";
@@ -260,272 +262,272 @@ OPackageList *OIpkg::availablePackages( const QString &server )
// Skip past all description lines
if ( key == "Description" )
{
line = t.readLine();
while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() )
line = t.readLine();
}
else
line = t.readLine();
}
f.close();
return pl;
}
OPackageList *OIpkg::installedPackages( const QString &destName, const QString &destPath )
{
// Load Ipkg configuration info if not already cached
if ( !m_confInfo )
loadConfiguration();
// Build new server list (caller is responsible for deleting)
OPackageList *pl = new OPackageList;
// Open status file
QString path = destPath;
if ( path.right( 1 ) != "/" )
path.append( "/" );
path.append( IPKG_STATUS_PATH );
QFile f( path );
if ( !f.open( IO_ReadOnly ) )
return NULL;
QTextStream t( &f );
// Process all information in status file
bool newPackage = false;
QString line = t.readLine();
QString name;
QString version;
QString status;
while ( !t.eof() )
{
// Determine key/value pair
int pos = line.find( ':', 0 );
QString key;
if ( pos > -1 )
key = line.mid( 0, pos );
else
key = QString::null;
QString value = line.mid( pos+2, line.length()-pos );
// Allocate new package and insert into list
if ( newPackage && !key.isEmpty() )
{
// Add to list only if it has a valid name and is installed
if ( !name.isNull() && status.contains( " installed" ) )
{
pl->append( new OPackage( name, QString::null, version, QString::null, destName ) );
name = QString::null;
version = QString::null;
status = QString::null;
newPackage = false;
}
}
// Update package data
if ( key == "Package" )
name = value;
else if ( key == "Version" )
version = value;
else if ( key == "Status" )
status = value;
else if ( key.isEmpty() && value.isEmpty() )
newPackage = true;
// Skip past all description lines
if ( key == "Description" )
{
line = t.readLine();
while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() )
line = t.readLine();
}
else
line = t.readLine();
}
f.close();
return pl;
}
-bool OIpkg::executeCommand( OPackage::Command command, QStringList *parameters, const QString &destination,
+bool OIpkg::executeCommand( OPackage::Command command, const QStringList &parameters, const QString &destination,
const QObject *receiver, const char *slotOutput, bool rawOutput )
{
if ( command == OPackage::NotDefined )
return false;
// Set ipkg run-time options/arguments
m_ipkgArgs.force_depends = ( m_ipkgExecOptions & FORCE_DEPENDS );
m_ipkgArgs.force_reinstall = ( m_ipkgExecOptions & FORCE_REINSTALL );
// TODO m_ipkgArgs.force_remove = ( m_ipkgExecOptions & FORCE_REMOVE );
m_ipkgArgs.force_overwrite = ( m_ipkgExecOptions & FORCE_OVERWRITE );
m_ipkgArgs.verbosity = m_ipkgExecVerbosity;
if ( m_ipkgArgs.dest )
free( m_ipkgArgs.dest );
if ( !destination.isNull() )
{
int len = destination.length() + 1;
m_ipkgArgs.dest = (char *)malloc( len );
strncpy( m_ipkgArgs.dest, destination, destination.length() );
m_ipkgArgs.dest[ len - 1 ] = '\0';
}
else
m_ipkgArgs.dest = 0x0;
// Connect output signal to widget
if ( rawOutput )
{
// if ( slotOutput )
// connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput );
}
else
{
// TODO - connect to local slot and parse output before emitting signalIpkgMessage
}
switch( command )
{
case OPackage::Update : {
connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput );
ipkg_lists_update( &m_ipkgArgs );
};
break;
case OPackage::Upgrade : {
connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput );
ipkg_packages_upgrade( &m_ipkgArgs );
};
break;
case OPackage::Install : {
connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput );
- for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it )
+ for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it )
{
ipkg_packages_install( &m_ipkgArgs, (*it) );
}
};
break;
case OPackage::Remove : {
connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput );
- for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it )
+ for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it )
{
ipkg_packages_remove( &m_ipkgArgs, (*it), true );
}
};
break;
case OPackage::Download : {
connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput );
- for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it )
+ for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it )
{
ipkg_packages_download( &m_ipkgArgs, (*it) );
}
};
break;
case OPackage::Info : {
connect( this, SIGNAL(signalIpkgStatus(char*)), receiver, slotOutput );
- ipkg_packages_info( &m_ipkgArgs, (*parameters->begin()), &fIpkgStatus, 0x0 );
+ ipkg_packages_info( &m_ipkgArgs, (*parameters.begin()), &fIpkgStatus, 0x0 );
};
break;
case OPackage::Files : {
connect( this, SIGNAL(signalIpkgList(char*)), receiver, slotOutput );
- ipkg_package_files( &m_ipkgArgs, (*parameters->begin()), &fIpkgFiles, 0x0 );
+ ipkg_package_files( &m_ipkgArgs, (*parameters.begin()), &fIpkgFiles, 0x0 );
};
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( "#" );
diff --git a/noncore/settings/packagemanager/oipkg.h b/noncore/settings/packagemanager/oipkg.h
index b8a859a..3c96200 100644
--- a/noncore/settings/packagemanager/oipkg.h
+++ b/noncore/settings/packagemanager/oipkg.h
@@ -1,105 +1,108 @@
/*
-                This file is part of the Opie Project
+ This file is part of the Opie Project
-              Copyright (c) 2003 Dan Williams <drw@handhelds.org>
+ 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.
+ .>+-=
+_;:, .> :=|. 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
#include "oconfitem.h"
#include "opackage.h"
#include <qpe/config.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 );
+ bool executeCommand( OPackage::Command command = OPackage::NotDefined,
+ const QStringList &parameters = QStringList(),
+ 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/opackagemanager.cpp b/noncore/settings/packagemanager/opackagemanager.cpp
index f75d3b3..cbddfe7 100644
--- a/noncore/settings/packagemanager/opackagemanager.cpp
+++ b/noncore/settings/packagemanager/opackagemanager.cpp
@@ -1,121 +1,121 @@
/*
-                This file is part of the Opie Project
+ This file is part of the Opie Project
-              Copyright (c) 2003 Dan Williams <drw@handhelds.org>
+ 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.
+ .>+-=
+_;:, .> :=|. 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 "opackagemanager.h"
#include "oipkgconfigdlg.h"
#include <qpe/qpeapplication.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() );
@@ -134,279 +134,279 @@ void OPackageManager::loadInstalledPackages()
QString status = tr( "Reading installed packages:\n\t" );
status.append( destination->name() );
emit statusText( status );
++destCount;
emit statusBar( destCount );
qApp->processEvents();
OPackageList *packageList = m_ipkg.installedPackages( destination->name(),
destination->value() );
if ( packageList )
{
for ( OPackageListIterator packageIt( *packageList ); packageIt.current(); ++packageIt )
{
OPackage *package = packageIt.current();
OPackage *currPackage = m_packages[package->name()];
if ( currPackage )
{
// Package is in a current feed, update installed version, destination
currPackage->setVersionInstalled( package->versionInstalled() );
currPackage->setDestination( package->destination() );
delete package;
}
else
{
// Package isn't in a current feed, add to list
m_packages.insert( 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 destList;
// Sort category list if categories were added
if ( categoryAdded )
m_categories.sort();
}
}
OPackageList *OPackageManager::packages()
{
// TODO - look to see if list is loaded, if not, load available & installed
OPackageList *pl = new OPackageList;
for ( QDictIterator<OPackage> packageIt( m_packages ); packageIt.current(); ++packageIt )
pl->append( packageIt.current() );
return pl;
}
OPackageList *OPackageManager::filterPackages( const QString &name,const QString &server,
const QString &destination, Status status, const QString &category )
{
// TODO - look to see if list is loaded, if not, load available & installed
OPackageList *pl = new OPackageList;
for ( QDictIterator<OPackage> packageIt( m_packages ); packageIt.current(); ++packageIt )
{
OPackage *package = packageIt.current();
bool nameMatch = ( name.isNull() || package->name().contains( name ) );
bool serverMatch = ( server.isNull() || package->source() == server );
bool destinationMatch = ( destination.isNull() || package->destination() == destination );
bool statusMatch;
switch ( status )
{
case All : statusMatch = true;
break;
case NotInstalled : statusMatch = package->versionInstalled().isNull();
break;
case Installed : statusMatch = !package->versionInstalled().isNull();
break;
case Updated : statusMatch = ( !package->versionInstalled().isNull() &&
compareVersions( package->version(), package->versionInstalled() ) == 1 );
break;
default : statusMatch = true;
break;
};
bool categoryMatch = ( category.isNull() || package->category() == category );
if ( nameMatch && serverMatch && destinationMatch && statusMatch && categoryMatch )
pl->append( packageIt.current() );
}
return pl;
}
-QStringList *OPackageManager::servers()
+QStringList OPackageManager::servers()
{
- QStringList *sl = new QStringList();
+ QStringList sl;
OConfItemList *serverList = m_ipkg.servers();
if ( serverList )
{
for ( OConfItemListIterator serverIt( *serverList ); serverIt.current(); ++serverIt )
{
OConfItem *server = serverIt.current();
// Add only active servers
if ( server->active() )
- *sl << server->name();
+ sl << server->name();
}
}
return sl;
}
-QStringList *OPackageManager::destinations()
+QStringList OPackageManager::destinations()
{
- QStringList *dl = new QStringList();
+ QStringList dl;
OConfItemList *destList = m_ipkg.destinations();
if ( destList )
{
for ( OConfItemListIterator destIt( *destList ); destIt.current(); ++destIt )
{
OConfItem *destination = destIt.current();
// Add only active destinations
if ( destination->active() )
- *dl << destination->name();
+ dl << destination->name();
}
}
return dl;
}
OConfItem *OPackageManager::findConfItem( OConfItem::Type type, const QString &name )
{
OConfItem *confItem = 0x0;
OConfItemList *confList = m_ipkg.configItems();
if ( confList )
{
for ( OConfItemListIterator confIt( *confList ); confIt.current(); ++confIt )
{
OConfItem *conf = confIt.current();
// Add only active confinations
if ( conf->type() == type && conf->name() == name )
{
confItem = conf;
break;
}
}
}
return confItem;
}
OPackage *OPackageManager::findPackage( const QString &name )
{
return m_packages[ name ];
}
int OPackageManager::compareVersions( const QString &ver1, const QString &ver2 )
{
// TODO - should this be in OIpkg???
int epoch1, epoch2;
QString version1, revision1;
QString version2, revision2;
parseVersion( ver1, &epoch1, &version1, &revision1 );
parseVersion( ver2, &epoch2, &version2, &revision2 );
if ( epoch1 > epoch2 )
return 1;
else if ( epoch1 < epoch2 )
return -1;
int r = verrevcmp( version1.latin1(), version2.latin1() );
if (r)
return r;
r = verrevcmp( revision1.latin1(), revision2.latin1() );
return r;
}
bool OPackageManager::configureDlg( bool installOptions )
{
OIpkgConfigDlg dlg( &m_ipkg, installOptions, static_cast<QWidget *>(parent()) );
return ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted );
}
void OPackageManager::saveSettings()
{
m_ipkg.saveSettings();
}
-bool OPackageManager::executeCommand( OPackage::Command command, QStringList *packages,
+bool OPackageManager::executeCommand( OPackage::Command command, const QStringList &packages,
const QString &destination, const QObject *receiver,
const char *slotOutput, bool rawOutput )
{
return m_ipkg.executeCommand( command, packages, destination, receiver, slotOutput, rawOutput );
}
void OPackageManager::parseVersion( const QString &verstr, int *epoch, QString *version,
QString *revision )
{
*epoch = 0;
*revision = QString::null;
// Version string is in the format "ee:vv-rv", where ee=epoch, vv=version, rv=revision
// Get epoch
int colonpos = verstr.find( ':' );
if ( colonpos > -1 )
{
*epoch = verstr.left( colonpos ).toInt();
}
// Get version and revision
int hyphenpos = verstr.find( '-', colonpos + 1 );
int verlen = verstr.length();
if ( hyphenpos > -1 )
{
*version = verstr.mid( colonpos + 1, hyphenpos - colonpos - 1 );
*revision = verstr.right( verlen - hyphenpos - 1 );
}
else
{
*version = verstr.right( verlen - colonpos );
}
}
/*
* libdpkg - Debian packaging suite library routines
* vercmp.c - comparison of version numbers
*
* Copyright (C) 1995 Ian Jackson <iwj10@cus.cam.ac.uk>
*/
int OPackageManager::verrevcmp( const char *val, const char *ref )
{
int vc, rc;
long vl, rl;
const char *vp, *rp;
const char *vsep, *rsep;
if (!val) val= "";
if (!ref) ref= "";
for (;;) {
vp= val; while (*vp && !isdigit(*vp)) vp++;
rp= ref; while (*rp && !isdigit(*rp)) rp++;
for (;;) {
vc= (val == vp) ? 0 : *val++;
rc= (ref == rp) ? 0 : *ref++;
if (!rc && !vc) break;
if (vc && !isalpha(vc)) vc += 256; /* assumes ASCII character set */
if (rc && !isalpha(rc)) rc += 256;
if (vc != rc) return vc - rc;
}
val= vp;
ref= rp;
vl=0; if (isdigit(*vp)) vl= strtol(val,(char**)&val,10);
rl=0; if (isdigit(*rp)) rl= strtol(ref,(char**)&ref,10);
if (vl != rl) return vl - rl;
vc = *val;
rc = *ref;
vsep = strchr(".-", vc);
rsep = strchr(".-", rc);
if (vsep && !rsep) return -1;
if (!vsep && rsep) return +1;
if (!*val && !*ref) return 0;
if (!*val) return -1;
if (!*ref) return +1;
}
}
diff --git a/noncore/settings/packagemanager/opackagemanager.h b/noncore/settings/packagemanager/opackagemanager.h
index 58e597b..bc394e8 100644
--- a/noncore/settings/packagemanager/opackagemanager.h
+++ b/noncore/settings/packagemanager/opackagemanager.h
@@ -1,92 +1,95 @@
/*
-                This file is part of the Opie Project
+ This file is part of the Opie Project
-              Copyright (c) 2003 Dan Williams <drw@handhelds.org>
+ 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.
+ .>+-=
+_;:, .> :=|. 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 "oipkg.h"
#include <qpe/config.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 );
+ OPackageList *filterPackages( const QString &name = QString::null,
+ const QString &server = QString::null,
+ const QString &destination = QString::null,
+ Status status = NotDefined,
+ const QString &category = QString::null );
const QStringList &categories() { return m_categories; }
- QStringList *servers();
- QStringList *destinations();
+ 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,
+ bool executeCommand( OPackage::Command command = OPackage::NotDefined,
+ const QStringList &parameters = QStringList(),
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/packageinfodlg.cpp b/noncore/settings/packagemanager/packageinfodlg.cpp
index d27eacb..c5924fd 100644
--- a/noncore/settings/packagemanager/packageinfodlg.cpp
+++ b/noncore/settings/packagemanager/packageinfodlg.cpp
@@ -1,144 +1,144 @@
/*
-                This file is part of the OPIE Project
+ 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.,
+ .=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 <opie2/otabwidget.h>
#include <qpe/resource.h>
#include <qlayout.h>
#include <qpushbutton.h>
#include <qwhatsthis.h>
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 );
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 );
+ 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 );
+ 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/promptdlg.h b/noncore/settings/packagemanager/promptdlg.h
index 790ff4d..f7bc0c0 100644
--- a/noncore/settings/packagemanager/promptdlg.h
+++ b/noncore/settings/packagemanager/promptdlg.h
@@ -1,57 +1,59 @@
/*
-                This file is part of the OPIE Project
+ 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.,
+ .=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 PROMPTDLG_H
#define PROMPTDLG_H
#include <qwidget.h>
class PromptDlg : public QWidget
{
Q_OBJECT
public:
- PromptDlg( const QString &caption = 0x0, const QString &text = 0x0, const QString &btn1 = 0x0,
- const QString &btn2 = 0x0, QWidget *parent = 0x0 );
+ PromptDlg( const QString &caption = QString::null, const QString &text = QString::null,
+ const QString &btn1 = QString::null, const QString &btn2 = QString::null,
+ QWidget *parent = 0x0 );
int display();
int btnPressed() { return m_btnClicked; }
- static int ask( const QString &caption = 0x0, const QString &text = 0x0, const QString &btn1 = 0x0,
- const QString &btn2 = 0x0, QWidget *parent = 0x0 );
+ static int ask( const QString &caption = QString::null, const QString &text = QString::null,
+ const QString &btn1 = QString::null, const QString &btn2 = QString::null,
+ QWidget *parent = 0x0 );
private:
int m_btnClicked; // Indicator for which button was pressed
private slots:
void slotBtn1Clicked();
void slotBtn2Clicked();
};
#endif