summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/packagemanager/ChangeLog5
-rw-r--r--noncore/settings/packagemanager/mainwindow.cpp5
-rw-r--r--noncore/settings/packagemanager/oipkg.cpp69
-rw-r--r--noncore/settings/packagemanager/oipkg.h8
-rw-r--r--noncore/settings/packagemanager/opackage.cpp5
-rw-r--r--noncore/settings/packagemanager/opackage.h15
-rw-r--r--noncore/settings/packagemanager/packageinfodlg.cpp96
-rw-r--r--noncore/settings/packagemanager/packageinfodlg.h10
8 files changed, 169 insertions, 44 deletions
diff --git a/noncore/settings/packagemanager/ChangeLog b/noncore/settings/packagemanager/ChangeLog
index efa75b1..72e6169 100644
--- a/noncore/settings/packagemanager/ChangeLog
+++ b/noncore/settings/packagemanager/ChangeLog
@@ -1,15 +1,20 @@
12004-mm-dd Dan Williams <drw@handhelds.org>
2
3 * Package information dialog implemented
4 * What's This app icon enabled
5
12004-01-23 Dan Williams <drw@handhelds.org> 62004-01-23 Dan Williams <drw@handhelds.org>
2 7
3 * Added package download functionality 8 * Added package download functionality
4 * Have Opie update links after install/removal so that apps 9 * Have Opie update links after install/removal so that apps
5 will display properly in Launcher 10 will display properly in Launcher
6 11
72004-01-20 Dan Williams <drw@handhelds.org> 122004-01-20 Dan Williams <drw@handhelds.org>
8 13
9 * Released version 0.2.0 14 * Released version 0.2.0
10 * Converted to use libipkg in place of spawning ipkg process 15 * Converted to use libipkg in place of spawning ipkg process
11 16
122004-01-13 Dan Williams <drw@handhelds.org> 172004-01-13 Dan Williams <drw@handhelds.org>
13 18
14 * Released version 0.1.0 19 * Released version 0.1.0
15 * Initial check-in of new package management client to eventually replace AQPkg 20 * Initial check-in of new package management client to eventually replace AQPkg
diff --git a/noncore/settings/packagemanager/mainwindow.cpp b/noncore/settings/packagemanager/mainwindow.cpp
index 05f21bc..8b374ab 100644
--- a/noncore/settings/packagemanager/mainwindow.cpp
+++ b/noncore/settings/packagemanager/mainwindow.cpp
@@ -1,683 +1,682 @@
1/* 1/*
2                This file is part of the OPIE Project 2                This file is part of the OPIE Project
3 3
4 =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> 4 =. Copyright (c) 2003 Dan Williams <drw@handhelds.org>
5             .=l. 5             .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This file is free software; you can 7 _;:,     .>    :=|. This file is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU General Public 9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This file is distributed in the hope that 14    .i_,=:_.      -<s. This file is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details. 19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .: 20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU 21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file; 22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the 23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc., 24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330, 25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
27 27
28*/ 28*/
29 29
30#include <qaction.h> 30#include <qaction.h>
31#include <qdir.h> 31#include <qdir.h>
32#include <qlayout.h> 32#include <qlayout.h>
33#include <qlineedit.h> 33#include <qlineedit.h>
34#include <qmenubar.h> 34#include <qmenubar.h>
35#include <qmessagebox.h> 35#include <qmessagebox.h>
36#include <qpopupmenu.h> 36#include <qpopupmenu.h>
37#include <qtimer.h> 37#include <qtimer.h>
38#include <qtoolbar.h> 38#include <qtoolbar.h>
39#include <qwhatsthis.h> 39#include <qwhatsthis.h>
40 40
41#include <qpe/qcopenvelope_qws.h> 41#include <qpe/qcopenvelope_qws.h>
42#include <qpe/qpeapplication.h> 42#include <qpe/qpeapplication.h>
43#include <qpe/resource.h> 43#include <qpe/resource.h>
44 44
45#include "mainwindow.h" 45#include "mainwindow.h"
46#include "installdlg.h" 46#include "installdlg.h"
47#include "filterdlg.h" 47#include "filterdlg.h"
48#include "promptdlg.h" 48#include "promptdlg.h"
49#include "entrydlg.h" 49#include "entrydlg.h"
50#include "packageinfodlg.h" 50#include "packageinfodlg.h"
51 51
52MainWindow::MainWindow( QWidget *parent, const char *name, WFlags fl ) 52MainWindow::MainWindow( QWidget *parent, const char *name, WFlags /*fl*/ )
53 : QMainWindow( parent, name, fl || WStyle_ContextHelp ) 53 : QMainWindow( parent, name, WStyle_ContextHelp )
54 , m_config( "packman" ) 54 , m_config( "packman" )
55 , m_packman( &m_config, this ) 55 , m_packman( &m_config, this )
56 , m_menuBar( this ) 56 , m_menuBar( this )
57 , m_toolBar( this ) 57 , m_toolBar( this )
58 , m_findBar( this ) 58 , m_findBar( this )
59 , m_widgetStack( this ) 59 , m_widgetStack( this )
60 , m_packageList( this ) 60 , m_packageList( this )
61 , m_statusWidget( this ) 61 , m_statusWidget( this )
62 , m_statusText( &m_statusWidget ) 62 , m_statusText( &m_statusWidget )
63 , m_statusBar( &m_statusWidget ) 63 , m_statusBar( &m_statusWidget )
64 , m_iconUpdated( Resource::loadPixmap( "packagemanager/updated" ) ) 64 , m_iconUpdated( Resource::loadPixmap( "packagemanager/updated" ) )
65 , m_iconInstalled( Resource::loadPixmap( "installed" ) ) 65 , m_iconInstalled( Resource::loadPixmap( "installed" ) )
66 , m_iconNull( m_iconUpdated.size() ) 66 , m_iconNull( m_iconUpdated.size() )
67 , m_filterName( QString::null ) 67 , m_filterName( QString::null )
68 , m_filterServer( QString::null ) 68 , m_filterServer( QString::null )
69 , m_filterDest( QString::null ) 69 , m_filterDest( QString::null )
70 , m_filterStatus( OPackageManager::NotDefined ) 70 , m_filterStatus( OPackageManager::NotDefined )
71 , m_filterCategory( QString::null ) 71 , m_filterCategory( QString::null )
72 72
73{ 73{
74// setCaption( tr( "Package Manager" ) ); 74// setCaption( tr( "Package Manager" ) );
75 75
76 m_iconNull.fill( colorGroup().base() ); 76 m_iconNull.fill( colorGroup().base() );
77 77
78 connect( &m_widgetStack, SIGNAL(aboutToShow(QWidget*)), this, SLOT(slotWidgetStackShow(QWidget*)) ); 78 connect( &m_widgetStack, SIGNAL(aboutToShow(QWidget*)), this, SLOT(slotWidgetStackShow(QWidget*)) );
79 79
80 // Initialize widget stack, package list and status widget 80 // Initialize widget stack, package list and status widget
81 initStatusWidget(); 81 initStatusWidget();
82 initPackageList(); 82 initPackageList();
83 83
84 m_widgetStack.addWidget( &m_statusWidget, 2 ); 84 m_widgetStack.addWidget( &m_statusWidget, 2 );
85 m_widgetStack.addWidget( &m_packageList, 1 ); 85 m_widgetStack.addWidget( &m_packageList, 1 );
86 setCentralWidget( &m_widgetStack ); 86 setCentralWidget( &m_widgetStack );
87 87
88 // Initialize remaining user interface items 88 // Initialize remaining user interface items
89 initUI(); 89 initUI();
90 90
91 // Initialize package information 91 // Initialize package information
92 QTimer::singleShot( 100, this, SLOT( initPackageInfo() ) ); 92 QTimer::singleShot( 100, this, SLOT( initPackageInfo() ) );
93} 93}
94 94
95void MainWindow::closeEvent( QCloseEvent *event ) 95void MainWindow::closeEvent( QCloseEvent *event )
96{ 96{
97 // Close app only if either the package or status widgets are currently active 97 // Close app only if either the package or status widgets are currently active
98 bool close = m_widgetStack.visibleWidget() == &m_packageList || 98 bool close = m_widgetStack.visibleWidget() == &m_packageList ||
99 m_widgetStack.visibleWidget() == &m_statusWidget; 99 m_widgetStack.visibleWidget() == &m_statusWidget;
100 if ( close ) 100 if ( close )
101 { 101 {
102 // TODO - write out application configuration settings 102 // TODO - write out application configuration settings
103 103
104 // Write out package manager configuration settings 104 // Write out package manager configuration settings
105 m_packman.saveSettings(); 105 m_packman.saveSettings();
106 event->accept(); 106 event->accept();
107 } 107 }
108 else 108 else
109 { 109 {
110 delete m_widgetStack.visibleWidget(); 110 delete m_widgetStack.visibleWidget();
111 m_widgetStack.raiseWidget( &m_packageList ); 111 m_widgetStack.raiseWidget( &m_packageList );
112 event->ignore(); 112 event->ignore();
113 } 113 }
114} 114}
115 115
116void MainWindow::initPackageList() 116void MainWindow::initPackageList()
117{ 117{
118 m_packageList.addColumn( tr( "Packages" ) ); 118 m_packageList.addColumn( tr( "Packages" ) );
119 QWhatsThis::add( &m_packageList, tr( "This is a listing of all packages.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nClick inside the box at the left to select a package." ) ); 119 QWhatsThis::add( &m_packageList, tr( "This is a listing of all packages.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nClick inside the box at the left to select a package." ) );
120 QPEApplication::setStylusOperation( m_packageList.viewport(), QPEApplication::RightOnHold ); 120 QPEApplication::setStylusOperation( m_packageList.viewport(), QPEApplication::RightOnHold );
121 connect( &m_packageList, SIGNAL(rightButtonPressed(QListViewItem *,const QPoint &,int)), 121 connect( &m_packageList, SIGNAL(rightButtonPressed(QListViewItem *,const QPoint &,int)),
122 this, SLOT(slotDisplayPackageInfo(QListViewItem *)) ); 122 this, SLOT(slotDisplayPackageInfo(QListViewItem *)) );
123} 123}
124 124
125void MainWindow::initStatusWidget() 125void MainWindow::initStatusWidget()
126{ 126{
127 QVBoxLayout *layout = new QVBoxLayout( &m_statusWidget, 4, 4 ); 127 QVBoxLayout *layout = new QVBoxLayout( &m_statusWidget, 4, 4 );
128 128
129 m_statusText.setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); 129 m_statusText.setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
130 layout->addWidget( &m_statusText ); 130 layout->addWidget( &m_statusText );
131 131
132 connect( &m_packman, SIGNAL(initStatus(int)), this, SLOT(slotInitStatusBar(int)) ); 132 connect( &m_packman, SIGNAL(initStatus(int)), this, SLOT(slotInitStatusBar(int)) );
133 connect( &m_packman, SIGNAL(statusText(const QString &)), this, SLOT(slotStatusText(const QString &)) ); 133 connect( &m_packman, SIGNAL(statusText(const QString &)), this, SLOT(slotStatusText(const QString &)) );
134 connect( &m_packman, SIGNAL(statusBar(int)), this, SLOT(slotStatusBar(int)) ); 134 connect( &m_packman, SIGNAL(statusBar(int)), this, SLOT(slotStatusBar(int)) );
135 135
136 layout->addWidget( &m_statusBar ); 136 layout->addWidget( &m_statusBar );
137} 137}
138 138
139void MainWindow::initUI() 139void MainWindow::initUI()
140{ 140{
141 // Build menu and tool bars 141 // Build menu and tool bars
142 setToolBarsMovable( false ); 142 setToolBarsMovable( false );
143 143
144 m_menuBar.setHorizontalStretchable( true ); 144 m_menuBar.setHorizontalStretchable( true );
145 QMenuBar *mb = new QMenuBar( &m_menuBar ); 145 QMenuBar *mb = new QMenuBar( &m_menuBar );
146 mb->setMargin( 0 ); 146 mb->setMargin( 0 );
147 147
148 // Find toolbar 148 // Find toolbar
149 addToolBar( &m_findBar, QMainWindow::Top, true ); 149 addToolBar( &m_findBar, QMainWindow::Top, true );
150 m_findBar.setHorizontalStretchable( true ); 150 m_findBar.setHorizontalStretchable( true );
151 m_findEdit = new QLineEdit( &m_findBar ); 151 m_findEdit = new QLineEdit( &m_findBar );
152 QWhatsThis::add( m_findEdit, tr( "Type the text to search for here." ) ); 152 QWhatsThis::add( m_findEdit, tr( "Type the text to search for here." ) );
153 m_findBar.setStretchableWidget( m_findEdit ); 153 m_findBar.setStretchableWidget( m_findEdit );
154 connect( m_findEdit, SIGNAL(textChanged(const QString &)), this, SLOT(slotFindChanged(const QString &)) ); 154 connect( m_findEdit, SIGNAL(textChanged(const QString &)), this, SLOT(slotFindChanged(const QString &)) );
155 155
156 // Packages menu 156 // Packages menu
157 QPopupMenu *popup = new QPopupMenu( this ); 157 QPopupMenu *popup = new QPopupMenu( this );
158 158
159 QAction *a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "packagemanager/update" ), QString::null, 0, this, 0 ); 159 QAction *a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "packagemanager/update" ), QString::null, 0, this, 0 );
160 a->setWhatsThis( tr( "Click here to update package lists from servers." ) ); 160 a->setWhatsThis( tr( "Click here to update package lists from servers." ) );
161 connect( a, SIGNAL(activated()), this, SLOT(slotUpdate()) ); 161 connect( a, SIGNAL(activated()), this, SLOT(slotUpdate()) );
162 a->addTo( popup ); 162 a->addTo( popup );
163 a->addTo( &m_toolBar ); 163 a->addTo( &m_toolBar );
164 164
165 QAction *actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "packagemanager/upgrade" ), QString::null, 0, this, 0 ); 165 QAction *actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "packagemanager/upgrade" ), QString::null, 0, this, 0 );
166 actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) ); 166 actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) );
167 connect( actionUpgrade, SIGNAL(activated()), this, SLOT(slotUpgrade()) ); 167 connect( actionUpgrade, SIGNAL(activated()), this, SLOT(slotUpgrade()) );
168 actionUpgrade->addTo( popup ); 168 actionUpgrade->addTo( popup );
169 actionUpgrade->addTo( &m_toolBar ); 169 actionUpgrade->addTo( &m_toolBar );
170 170
171 QPixmap iconDownload = Resource::loadPixmap( "packagemanager/download" ); 171 QPixmap iconDownload = Resource::loadPixmap( "packagemanager/download" );
172 QPixmap iconRemove = Resource::loadPixmap( "packagemanager/remove" ); 172 QPixmap iconRemove = Resource::loadPixmap( "packagemanager/remove" );
173 QAction *actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); 173 QAction *actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 );
174 actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); 174 actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) );
175 connect( actionDownload, SIGNAL(activated()), this, SLOT(slotDownload()) ); 175 connect( actionDownload, SIGNAL(activated()), this, SLOT(slotDownload()) );
176 actionDownload->addTo( popup ); 176 actionDownload->addTo( popup );
177 actionDownload->addTo( &m_toolBar ); 177 actionDownload->addTo( &m_toolBar );
178 178
179 a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "packagemanager/apply" ), QString::null, 0, this, 0 ); 179 a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "packagemanager/apply" ), QString::null, 0, this, 0 );
180 a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) ); 180 a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) );
181 connect( a, SIGNAL(activated()), this, SLOT(slotApply()) ); 181 connect( a, SIGNAL(activated()), this, SLOT(slotApply()) );
182 a->addTo( popup ); 182 a->addTo( popup );
183 a->addTo( &m_toolBar ); 183 a->addTo( &m_toolBar );
184 184
185 popup->insertSeparator(); 185 popup->insertSeparator();
186 186
187 a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); 187 a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 );
188 a->setWhatsThis( tr( "Click here to configure this application." ) ); 188 a->setWhatsThis( tr( "Click here to configure this application." ) );
189 connect( a, SIGNAL(activated()), this, SLOT(slotConfigure()) ); 189 connect( a, SIGNAL(activated()), this, SLOT(slotConfigure()) );
190 a->addTo( popup ); 190 a->addTo( popup );
191 mb->insertItem( tr( "Actions" ), popup ); 191 mb->insertItem( tr( "Actions" ), popup );
192 192
193 // View menu 193 // View menu
194 popup = new QPopupMenu( this ); 194 popup = new QPopupMenu( this );
195 195
196 m_actionShowNotInstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); 196 m_actionShowNotInstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 );
197 m_actionShowNotInstalled->setToggleAction( true ); 197 m_actionShowNotInstalled->setToggleAction( true );
198 m_actionShowNotInstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) ); 198 m_actionShowNotInstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) );
199 connect( m_actionShowNotInstalled, SIGNAL(activated()), this, SLOT(slotShowNotInstalled()) ); 199 connect( m_actionShowNotInstalled, SIGNAL(activated()), this, SLOT(slotShowNotInstalled()) );
200 m_actionShowNotInstalled->addTo( popup ); 200 m_actionShowNotInstalled->addTo( popup );
201 201
202 m_actionShowInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); 202 m_actionShowInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 );
203 m_actionShowInstalled->setToggleAction( true ); 203 m_actionShowInstalled->setToggleAction( true );
204 m_actionShowInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) ); 204 m_actionShowInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) );
205 connect( m_actionShowInstalled, SIGNAL(activated()), this, SLOT(slotShowInstalled()) ); 205 connect( m_actionShowInstalled, SIGNAL(activated()), this, SLOT(slotShowInstalled()) );
206 m_actionShowInstalled->addTo( popup ); 206 m_actionShowInstalled->addTo( popup );
207 207
208 m_actionShowUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); 208 m_actionShowUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 );
209 m_actionShowUpdated->setToggleAction( true ); 209 m_actionShowUpdated->setToggleAction( true );
210 m_actionShowUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) ); 210 m_actionShowUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) );
211 connect( m_actionShowUpdated, SIGNAL(activated()), this, SLOT(slotShowUpdated()) ); 211 connect( m_actionShowUpdated, SIGNAL(activated()), this, SLOT(slotShowUpdated()) );
212 m_actionShowUpdated->addTo( popup ); 212 m_actionShowUpdated->addTo( popup );
213 213
214 popup->insertSeparator(); 214 popup->insertSeparator();
215 215
216 a = new QAction( tr( "Configure filter" ), QString::null, 0, this, 0 ); 216 a = new QAction( tr( "Configure filter" ), QString::null, 0, this, 0 );
217 a->setWhatsThis( tr( "Click here to change package filter criteria." ) ); 217 a->setWhatsThis( tr( "Click here to change package filter criteria." ) );
218 connect( a, SIGNAL(activated()), this, SLOT(slotFilterChange()) ); 218 connect( a, SIGNAL(activated()), this, SLOT(slotFilterChange()) );
219 a->addTo( popup ); 219 a->addTo( popup );
220 220
221 m_actionFilter = new QAction( tr( "Filter" ), Resource::loadPixmap( "packagemanager/filter" ), 221 m_actionFilter = new QAction( tr( "Filter" ), Resource::loadPixmap( "packagemanager/filter" ),
222 QString::null, 0, this, 0 ); 222 QString::null, 0, this, 0 );
223 m_actionFilter->setToggleAction( true ); 223 m_actionFilter->setToggleAction( true );
224 m_actionFilter->setWhatsThis( tr( "Click here to apply current filter." ) ); 224 m_actionFilter->setWhatsThis( tr( "Click here to apply current filter." ) );
225 connect( m_actionFilter, SIGNAL(toggled(bool)), this, SLOT(slotFilter(bool)) ); 225 connect( m_actionFilter, SIGNAL(toggled(bool)), this, SLOT(slotFilter(bool)) );
226 m_actionFilter->addTo( popup ); 226 m_actionFilter->addTo( popup );
227 227
228 popup->insertSeparator(); 228 popup->insertSeparator();
229 229
230 a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); 230 a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 );
231 a->setWhatsThis( tr( "Click here to search for text in package names." ) ); 231 a->setWhatsThis( tr( "Click here to search for text in package names." ) );
232 connect( a, SIGNAL(activated()), this, SLOT(slotFindShowToolbar()) ); 232 connect( a, SIGNAL(activated()), this, SLOT(slotFindShowToolbar()) );
233 a->addTo( popup ); 233 a->addTo( popup );
234 234
235 m_actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); 235 m_actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 );
236 m_actionFindNext->setEnabled( false ); 236 m_actionFindNext->setEnabled( false );
237 m_actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) ); 237 m_actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) );
238 connect( m_actionFindNext, SIGNAL(activated()), this, SLOT(slotFindNext()) ); 238 connect( m_actionFindNext, SIGNAL(activated()), this, SLOT(slotFindNext()) );
239 m_actionFindNext->addTo( popup ); 239 m_actionFindNext->addTo( popup );
240 m_actionFindNext->addTo( &m_findBar ); 240 m_actionFindNext->addTo( &m_findBar );
241 241
242 mb->insertItem( tr( "View" ), popup ); 242 mb->insertItem( tr( "View" ), popup );
243 243
244 // Finish find toolbar creation 244 // Finish find toolbar creation
245 a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 245 a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
246 a->setWhatsThis( tr( "Click here to hide the find toolbar." ) ); 246 a->setWhatsThis( tr( "Click here to hide the find toolbar." ) );
247 connect( a, SIGNAL(activated()), this, SLOT(slotFindHideToolbar()) ); 247 connect( a, SIGNAL(activated()), this, SLOT(slotFindHideToolbar()) );
248 a->addTo( &m_findBar ); 248 a->addTo( &m_findBar );
249 m_findBar.hide(); 249 m_findBar.hide();
250} 250}
251 251
252void MainWindow::loadPackageList( OPackageList *packages, bool clearList ) 252void MainWindow::loadPackageList( OPackageList *packages, bool clearList )
253{ 253{
254 if ( clearList ) 254 if ( clearList )
255 m_packageList.clear(); 255 m_packageList.clear();
256 256
257 if ( packages ) 257 if ( packages )
258 { 258 {
259 for ( OPackageListIterator packageIt( *packages ); packageIt.current(); ++packageIt ) 259 for ( OPackageListIterator packageIt( *packages ); packageIt.current(); ++packageIt )
260 { 260 {
261 OPackage *package = packageIt.current(); 261 OPackage *package = packageIt.current();
262 QCheckListItem *item = new QCheckListItem( &m_packageList, package->name(), 262 QCheckListItem *item = new QCheckListItem( &m_packageList, package->name(),
263 QCheckListItem::CheckBox ); 263 QCheckListItem::CheckBox );
264 m_packageList.insertItem( item ); 264 m_packageList.insertItem( item );
265 265
266 // If a different version of package is available, show update available icon 266 // If a different version of package is available, show update available icon
267 // Otherwise, show installed icon 267 // Otherwise, show installed icon
268 if ( !package->versionInstalled().isNull() ) 268 if ( !package->versionInstalled().isNull() )
269 { 269 {
270 if ( m_packman.compareVersions( package->version(), package->versionInstalled() ) == 1 ) 270 if ( m_packman.compareVersions( package->version(), package->versionInstalled() ) == 1 )
271 item->setPixmap( 0, m_iconUpdated ); 271 item->setPixmap( 0, m_iconUpdated );
272 else 272 else
273 item->setPixmap( 0, m_iconInstalled ); 273 item->setPixmap( 0, m_iconInstalled );
274 } 274 }
275 else 275 else
276 item->setPixmap( 0, m_iconNull ); 276 item->setPixmap( 0, m_iconNull );
277 } 277 }
278 } 278 }
279} 279}
280 280
281void MainWindow::searchForPackage( const QString &text ) 281void MainWindow::searchForPackage( const QString &text )
282{ 282{
283 if ( !text.isEmpty() ) 283 if ( !text.isEmpty() )
284 { 284 {
285 // look through package list for text startng at current position 285 // look through package list for text startng at current position
286 QCheckListItem *start = static_cast<QCheckListItem *>(m_packageList.currentItem()); 286 QCheckListItem *start = static_cast<QCheckListItem *>(m_packageList.currentItem());
287 if ( start == 0 ) 287 if ( start == 0 )
288 start = static_cast<QCheckListItem *>(m_packageList.firstChild()); 288 start = static_cast<QCheckListItem *>(m_packageList.firstChild());
289 289
290// for ( QCheckListItem *item = static_cast<QCheckListItem *>(start->nextSibling()); item != 0 ; 290// for ( QCheckListItem *item = static_cast<QCheckListItem *>(start->nextSibling()); item != 0 ;
291 for ( QCheckListItem *item = static_cast<QCheckListItem *>(start); item != 0 ; 291 for ( QCheckListItem *item = static_cast<QCheckListItem *>(start); item != 0 ;
292 item = static_cast<QCheckListItem *>(item->nextSibling()) ) 292 item = static_cast<QCheckListItem *>(item->nextSibling()) )
293 { 293 {
294 if ( item->text().lower().find( text ) != -1 ) 294 if ( item->text().lower().find( text ) != -1 )
295 { 295 {
296 m_packageList.ensureItemVisible( item ); 296 m_packageList.ensureItemVisible( item );
297 m_packageList.setCurrentItem( item ); 297 m_packageList.setCurrentItem( item );
298 break; 298 break;
299 } 299 }
300 } 300 }
301 } 301 }
302} 302}
303 303
304void MainWindow::initPackageInfo() 304void MainWindow::initPackageInfo()
305{ 305{
306 m_widgetStack.raiseWidget( &m_statusWidget ); 306 m_widgetStack.raiseWidget( &m_statusWidget );
307 307
308 // Load package list 308 // Load package list
309 m_packman.loadAvailablePackages(); 309 m_packman.loadAvailablePackages();
310 m_packman.loadInstalledPackages(); 310 m_packman.loadInstalledPackages();
311 311
312 OPackageList *packageList = m_packman.packages(); 312 OPackageList *packageList = m_packman.packages();
313 if ( packageList ) 313 if ( packageList )
314 { 314 {
315 loadPackageList( packageList, true ); 315 loadPackageList( packageList, true );
316 delete packageList; 316 delete packageList;
317 } 317 }
318 318
319 m_widgetStack.raiseWidget( &m_packageList ); 319 m_widgetStack.raiseWidget( &m_packageList );
320} 320}
321 321
322void MainWindow::slotWidgetStackShow( QWidget *widget ) 322void MainWindow::slotWidgetStackShow( QWidget *widget )
323{ 323{
324 if ( widget == &m_packageList ) 324 if ( widget == &m_packageList )
325 { 325 {
326 setCaption( tr( "Package Manager" ) ); 326 setCaption( tr( "Package Manager" ) );
327 327
328 m_menuBar.show(); 328 m_menuBar.show();
329 m_toolBar.show(); 329 m_toolBar.show();
330 } 330 }
331 else 331 else
332 { 332 {
333 m_menuBar.hide(); 333 m_menuBar.hide();
334 m_toolBar.hide(); 334 m_toolBar.hide();
335 } 335 }
336} 336}
337 337
338void MainWindow::slotInitStatusBar( int numSteps ) 338void MainWindow::slotInitStatusBar( int numSteps )
339{ 339{
340 m_statusBar.setTotalSteps( numSteps ); 340 m_statusBar.setTotalSteps( numSteps );
341} 341}
342 342
343void MainWindow::slotStatusText( const QString &status ) 343void MainWindow::slotStatusText( const QString &status )
344{ 344{
345 m_statusText.setText( status ); 345 m_statusText.setText( status );
346} 346}
347 347
348void MainWindow::slotStatusBar( int currStep ) 348void MainWindow::slotStatusBar( int currStep )
349{ 349{
350 m_statusBar.setProgress( currStep ); 350 m_statusBar.setProgress( currStep );
351} 351}
352 352
353void MainWindow::slotUpdate() 353void MainWindow::slotUpdate()
354{ 354{
355 // Create package manager output widget 355 // Create package manager output widget
356 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Update package information" ), false, 356 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Update package information" ), false,
357 OPackage::Update ); 357 OPackage::Update );
358 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); 358 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) );
359 359
360 // Display widget 360 // Display widget
361 m_widgetStack.addWidget( dlg, 3 ); 361 m_widgetStack.addWidget( dlg, 3 );
362 m_widgetStack.raiseWidget( dlg ); 362 m_widgetStack.raiseWidget( dlg );
363} 363}
364 364
365void MainWindow::slotUpgrade() 365void MainWindow::slotUpgrade()
366{ 366{
367 // Create package manager output widget 367 // Create package manager output widget
368 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Upgrade installed packages" ), false, 368 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Upgrade installed packages" ), false,
369 OPackage::Upgrade ); 369 OPackage::Upgrade );
370 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); 370 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) );
371 371
372 // Display widget 372 // Display widget
373 m_widgetStack.addWidget( dlg, 3 ); 373 m_widgetStack.addWidget( dlg, 3 );
374 m_widgetStack.raiseWidget( dlg ); 374 m_widgetStack.raiseWidget( dlg );
375} 375}
376 376
377void MainWindow::slotDownload() 377void MainWindow::slotDownload()
378{ 378{
379 // Retrieve list of packages selected for download (if any) 379 // Retrieve list of packages selected for download (if any)
380 QStringList *workingPackages = new QStringList(); 380 QStringList *workingPackages = new QStringList();
381 381
382 for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild()); 382 for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild());
383 item != 0 ; 383 item != 0 ;
384 item = static_cast<QCheckListItem *>(item->nextSibling()) ) 384 item = static_cast<QCheckListItem *>(item->nextSibling()) )
385 { 385 {
386 if ( item->isOn() ) 386 if ( item->isOn() )
387 workingPackages->append( item->text() ); 387 workingPackages->append( item->text() );
388 } 388 }
389 389
390 if ( workingPackages->isEmpty() ) 390 if ( workingPackages->isEmpty() )
391 { 391 {
392 QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) ); 392 QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) );
393 return; 393 return;
394 } 394 }
395 else 395 else
396 { 396 {
397 // Download selected packages 397 // Download selected packages
398 m_config.setGroup( "settings" ); 398 m_config.setGroup( "settings" );
399 QString workingDir = m_config.readEntry( "DownloadDir", "/tmp" ); 399 QString workingDir = m_config.readEntry( "DownloadDir", "/tmp" );
400 400
401 bool ok = false; 401 bool ok = false;
402 QString text = EntryDlg::getText( tr( "Download" ), tr( "Enter path to download package to:" ), workingDir, &ok, this ); 402 QString text = EntryDlg::getText( tr( "Download" ), tr( "Enter path to download package to:" ), workingDir, &ok, this );
403 if ( ok && !text.isEmpty() ) 403 if ( ok && !text.isEmpty() )
404 workingDir = text; // user entered something and pressed ok 404 workingDir = text; // user entered something and pressed ok
405 else 405 else
406 return; // user entered nothing or pressed cancel 406 return; // user entered nothing or pressed cancel
407 407
408 // Store download directory in config file 408 // Store download directory in config file
409 m_config.writeEntry( "DownloadDir", workingDir ); 409 m_config.writeEntry( "DownloadDir", workingDir );
410 410
411 // Get starting directory 411 // Get starting directory
412 QDir::setCurrent( workingDir ); 412 QDir::setCurrent( workingDir );
413 413
414 // Create package manager output widget 414 // Create package manager output widget
415 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Download packages" ), false, 415 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Download packages" ), false,
416 OPackage::Download, workingPackages ); 416 OPackage::Download, workingPackages );
417 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); 417 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) );
418 418
419 // Display widget 419 // Display widget
420 m_widgetStack.addWidget( dlg, 3 ); 420 m_widgetStack.addWidget( dlg, 3 );
421 m_widgetStack.raiseWidget( dlg ); 421 m_widgetStack.raiseWidget( dlg );
422 } 422 }
423} 423}
424 424
425void MainWindow::slotApply() 425void MainWindow::slotApply()
426{ 426{
427 QStringList *removeList = 0x0; 427 QStringList *removeList = 0x0;
428 QStringList *installList = 0x0; 428 QStringList *installList = 0x0;
429 QStringList *upgradeList = 0x0; 429 QStringList *upgradeList = 0x0;
430 430
431 for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild()); 431 for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild());
432 item != 0 ; 432 item != 0 ;
433 item = static_cast<QCheckListItem *>(item->nextSibling()) ) 433 item = static_cast<QCheckListItem *>(item->nextSibling()) )
434 { 434 {
435 if ( item->isOn() ) 435 if ( item->isOn() )
436 { 436 {
437 OPackage *package = m_packman.findPackage( item->text() ); 437 OPackage *package = m_packman.findPackage( item->text() );
438 if ( package ) 438 if ( package )
439 { 439 {
440 if ( !package->versionInstalled().isNull() ) 440 if ( !package->versionInstalled().isNull() )
441 { 441 {
442 if ( m_packman.compareVersions( package->version(), package->versionInstalled() ) == 1 ) 442 if ( m_packman.compareVersions( package->version(), package->versionInstalled() ) == 1 )
443 { 443 {
444 // Remove/upgrade package 444 // Remove/upgrade package
445 int answer = PromptDlg::ask( tr( "Remove or upgrade" ), 445 int answer = PromptDlg::ask( tr( "Remove or upgrade" ),
446 tr( QString( "Do you wish to remove or upgrade\n%1?" ).arg( item->text() ) ), 446 tr( QString( "Do you wish to remove or upgrade\n%1?" ).arg( item->text() ) ),
447 tr( "Remove" ), tr( "Upgrade" ), this ); 447 tr( "Remove" ), tr( "Upgrade" ), this );
448 if ( answer == 1 ) // Remove 448 if ( answer == 1 ) // Remove
449 { 449 {
450 if ( !removeList ) 450 if ( !removeList )
451 removeList = new QStringList(); 451 removeList = new QStringList();
452 removeList->append( item->text() ); 452 removeList->append( item->text() );
453 } 453 }
454 else if ( answer == 2 ) // Upgrade 454 else if ( answer == 2 ) // Upgrade
455 { 455 {
456 if ( !upgradeList ) 456 if ( !upgradeList )
457 upgradeList = new QStringList(); 457 upgradeList = new QStringList();
458 upgradeList->append( item->text() ); 458 upgradeList->append( item->text() );
459 } 459 }
460 } 460 }
461 else 461 else
462 { 462 {
463 // Remove/reinstall package 463 // Remove/reinstall package
464 int answer = PromptDlg::ask( tr( "Remove or reinstall" ), 464 int answer = PromptDlg::ask( tr( "Remove or reinstall" ),
465 tr( QString( "Do you wish to remove or reinstall\n%1?" ).arg( item->text() ) ), 465 tr( QString( "Do you wish to remove or reinstall\n%1?" ).arg( item->text() ) ),
466 tr( "Remove" ), tr( "Reinstall" ), this ); 466 tr( "Remove" ), tr( "Reinstall" ), this );
467 if ( answer == 1 ) // Remove 467 if ( answer == 1 ) // Remove
468 { 468 {
469 if ( !removeList ) 469 if ( !removeList )
470 removeList = new QStringList(); 470 removeList = new QStringList();
471 removeList->append( item->text() ); 471 removeList->append( item->text() );
472 } 472 }
473 else if ( answer == 2 ) // Reinstall 473 else if ( answer == 2 ) // Reinstall
474 { 474 {
475 if ( !installList ) 475 if ( !installList )
476 installList = new QStringList(); 476 installList = new QStringList();
477 installList->append( item->text() ); 477 installList->append( item->text() );
478 } 478 }
479 } 479 }
480 } 480 }
481 else 481 else
482 { 482 {
483 // Install package 483 // Install package
484 if ( !installList ) 484 if ( !installList )
485 installList = new QStringList(); 485 installList = new QStringList();
486 installList->append( item->text() ); 486 installList->append( item->text() );
487 } 487 }
488 } 488 }
489 } 489 }
490 } 490 }
491 491
492 // If nothing is selected, display message and exit 492 // If nothing is selected, display message and exit
493 if ( !removeList && !installList && !upgradeList ) 493 if ( !removeList && !installList && !upgradeList )
494 { 494 {
495 QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) ); 495 QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) );
496 return; 496 return;
497 } 497 }
498 498
499 // Send command only if there are packages to process 499 // Send command only if there are packages to process
500 OPackage::Command removeCmd = OPackage::NotDefined; 500 OPackage::Command removeCmd = OPackage::NotDefined;
501 if ( removeList && !removeList->isEmpty() ) 501 if ( removeList && !removeList->isEmpty() )
502 removeCmd = OPackage::Remove; 502 removeCmd = OPackage::Remove;
503 OPackage::Command installCmd = OPackage::NotDefined; 503 OPackage::Command installCmd = OPackage::NotDefined;
504 if ( installList && !installList->isEmpty() ) 504 if ( installList && !installList->isEmpty() )
505 installCmd = OPackage::Install; 505 installCmd = OPackage::Install;
506 OPackage::Command upgradeCmd = OPackage::NotDefined; 506 OPackage::Command upgradeCmd = OPackage::NotDefined;
507 if ( upgradeList && !upgradeList->isEmpty() ) 507 if ( upgradeList && !upgradeList->isEmpty() )
508 upgradeCmd = OPackage::Upgrade; 508 upgradeCmd = OPackage::Upgrade;
509 509
510 // Create package manager output widget 510 // Create package manager output widget
511 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Apply changes" ), true, 511 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Apply changes" ), true,
512 removeCmd, removeList, 512 removeCmd, removeList,
513 installCmd, installList, 513 installCmd, installList,
514 upgradeCmd, upgradeList ); 514 upgradeCmd, upgradeList );
515 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); 515 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) );
516 516
517 // Display widget 517 // Display widget
518 m_widgetStack.addWidget( dlg, 3 ); 518 m_widgetStack.addWidget( dlg, 3 );
519 m_widgetStack.raiseWidget( dlg ); 519 m_widgetStack.raiseWidget( dlg );
520} 520}
521 521
522void MainWindow::slotCloseDlg() 522void MainWindow::slotCloseDlg()
523{ 523{
524 // Close install dialog 524 // Close install dialog
525 delete m_widgetStack.visibleWidget(); 525 delete m_widgetStack.visibleWidget();
526 526
527 // Reload package list 527 // Reload package list
528 initPackageInfo(); 528 initPackageInfo();
529 529
530 // Update Opie launcher links 530 // Update Opie launcher links
531 QCopEnvelope e("QPE/System", "linkChanged(QString)"); 531 QCopEnvelope e("QPE/System", "linkChanged(QString)");
532 QString lf = QString::null; 532 QString lf = QString::null;
533 e << lf; 533 e << lf;
534} 534}
535 535
536void MainWindow::slotConfigure() 536void MainWindow::slotConfigure()
537{ 537{
538 if ( m_packman.configureDlg( false ) ) 538 if ( m_packman.configureDlg( false ) )
539 { 539 {
540 if ( PromptDlg::ask( tr( "Config updated" ), 540 if ( PromptDlg::ask( tr( "Config updated" ),
541 tr( "The configuration has been updated. Do you want to update server and package information now?" ), 541 tr( "The configuration has been updated. Do you want to update server and package information now?" ),
542 tr( "Yes" ), tr( "No" ), this ) == 1 ) 542 tr( "Yes" ), tr( "No" ), this ) == 1 )
543 { 543 {
544 // Update package list and reload package info 544 // Update package list and reload package info
545 slotUpdate(); 545 slotUpdate();
546 } 546 }
547 } 547 }
548} 548}
549 549
550void MainWindow::slotShowNotInstalled() 550void MainWindow::slotShowNotInstalled()
551{ 551{
552 OPackageList *packageList; 552 OPackageList *packageList;
553 if ( m_actionShowNotInstalled->isOn() ) 553 if ( m_actionShowNotInstalled->isOn() )
554 { 554 {
555 m_actionShowInstalled->setOn( false ); 555 m_actionShowInstalled->setOn( false );
556 m_actionShowUpdated->setOn( false ); 556 m_actionShowUpdated->setOn( false );
557 packageList = m_packman.filterPackages( QString::null, QString::null, QString::null, 557 packageList = m_packman.filterPackages( QString::null, QString::null, QString::null,
558 OPackageManager::NotInstalled, QString::null ); 558 OPackageManager::NotInstalled, QString::null );
559 } 559 }
560 else 560 else
561 packageList = m_packman.packages(); 561 packageList = m_packman.packages();
562 562
563 if ( packageList ) 563 if ( packageList )
564 { 564 {
565 loadPackageList( packageList, true ); 565 loadPackageList( packageList, true );
566 delete packageList; 566 delete packageList;
567 } 567 }
568} 568}
569 569
570void MainWindow::slotShowInstalled() 570void MainWindow::slotShowInstalled()
571{ 571{
572 OPackageList *packageList; 572 OPackageList *packageList;
573 if ( m_actionShowInstalled->isOn() ) 573 if ( m_actionShowInstalled->isOn() )
574 { 574 {
575 m_actionShowNotInstalled->setOn( false ); 575 m_actionShowNotInstalled->setOn( false );
576 m_actionShowUpdated->setOn( false ); 576 m_actionShowUpdated->setOn( false );
577 packageList = m_packman.filterPackages( QString::null, QString::null, QString::null, 577 packageList = m_packman.filterPackages( QString::null, QString::null, QString::null,
578 OPackageManager::Installed, QString::null ); 578 OPackageManager::Installed, QString::null );
579 } 579 }
580 else 580 else
581 packageList = m_packman.packages(); 581 packageList = m_packman.packages();
582 582
583 if ( packageList ) 583 if ( packageList )
584 { 584 {
585 loadPackageList( packageList, true ); 585 loadPackageList( packageList, true );
586 delete packageList; 586 delete packageList;
587 } 587 }
588} 588}
589 589
590void MainWindow::slotShowUpdated() 590void MainWindow::slotShowUpdated()
591{ 591{
592 OPackageList *packageList; 592 OPackageList *packageList;
593 if ( m_actionShowUpdated->isOn() ) 593 if ( m_actionShowUpdated->isOn() )
594 { 594 {
595 m_actionShowInstalled->setOn( false ); 595 m_actionShowInstalled->setOn( false );
596 m_actionShowNotInstalled->setOn( false ); 596 m_actionShowNotInstalled->setOn( false );
597 packageList = m_packman.filterPackages( QString::null, QString::null, QString::null, 597 packageList = m_packman.filterPackages( QString::null, QString::null, QString::null,
598 OPackageManager::Updated, QString::null ); 598 OPackageManager::Updated, QString::null );
599 } 599 }
600 else 600 else
601 packageList = m_packman.packages(); 601 packageList = m_packman.packages();
602 602
603 if ( packageList ) 603 if ( packageList )
604 { 604 {
605 loadPackageList( packageList, true ); 605 loadPackageList( packageList, true );
606 delete packageList; 606 delete packageList;
607 } 607 }
608} 608}
609 609
610void MainWindow::slotFilterChange() 610void MainWindow::slotFilterChange()
611{ 611{
612 FilterDlg dlg( this, &m_packman, m_filterName, m_filterServer, m_filterDest, m_filterStatus, 612 FilterDlg dlg( this, &m_packman, m_filterName, m_filterServer, m_filterDest, m_filterStatus,
613 m_filterCategory ); 613 m_filterCategory );
614 if ( dlg.exec() == QDialog::Accepted ) 614 if ( dlg.exec() == QDialog::Accepted )
615 { 615 {
616 m_filterName = dlg.name(); 616 m_filterName = dlg.name();
617 m_filterServer = dlg.server(); 617 m_filterServer = dlg.server();
618 m_filterDest = dlg.destination(); 618 m_filterDest = dlg.destination();
619 m_filterStatus = dlg.status(); 619 m_filterStatus = dlg.status();
620 m_filterCategory = dlg.category(); 620 m_filterCategory = dlg.category();
621 m_actionFilter->setOn( true ); 621 m_actionFilter->setOn( true );
622 slotFilter( true ); 622 slotFilter( true );
623 } 623 }
624 else 624 else
625 { 625 {
626 m_actionFilter->setOn( false ); 626 m_actionFilter->setOn( false );
627 slotFilter( false ); 627 slotFilter( false );
628 } 628 }
629} 629}
630 630
631void MainWindow::slotFilter( bool isOn ) 631void MainWindow::slotFilter( bool isOn )
632{ 632{
633 OPackageList *packageList; 633 OPackageList *packageList;
634 if ( isOn ) 634 if ( isOn )
635 { 635 {
636 packageList = m_packman.filterPackages( m_filterName, m_filterServer, m_filterDest, 636 packageList = m_packman.filterPackages( m_filterName, m_filterServer, m_filterDest,
637 m_filterStatus, m_filterCategory ); 637 m_filterStatus, m_filterCategory );
638 } 638 }
639 else 639 else
640 packageList = m_packman.packages(); 640 packageList = m_packman.packages();
641 641
642 if ( packageList ) 642 if ( packageList )
643 { 643 {
644 loadPackageList( packageList, true ); 644 loadPackageList( packageList, true );
645 delete packageList; 645 delete packageList;
646 } 646 }
647} 647}
648 648
649void MainWindow::slotFindShowToolbar() 649void MainWindow::slotFindShowToolbar()
650{ 650{
651 m_findBar.show(); 651 m_findBar.show();
652 m_findEdit->setFocus(); 652 m_findEdit->setFocus();
653} 653}
654 654
655void MainWindow::slotFindHideToolbar() 655void MainWindow::slotFindHideToolbar()
656{ 656{
657 m_findBar.hide(); 657 m_findBar.hide();
658} 658}
659 659
660void MainWindow::slotFindChanged( const QString &findText ) 660void MainWindow::slotFindChanged( const QString &findText )
661{ 661{
662 662
663 m_actionFindNext->setEnabled( !findText.isEmpty() ); 663 m_actionFindNext->setEnabled( !findText.isEmpty() );
664 searchForPackage( findText ); 664 searchForPackage( findText );
665} 665}
666 666
667void MainWindow::slotFindNext() 667void MainWindow::slotFindNext()
668{ 668{
669 searchForPackage( m_findEdit->text() ); 669 searchForPackage( m_findEdit->text() );
670} 670}
671 671
672void MainWindow::slotDisplayPackageInfo( QListViewItem *packageItem ) 672void MainWindow::slotDisplayPackageInfo( QListViewItem *packageItem )
673{ 673{
674 QString packageName( ( static_cast<QCheckListItem*>( packageItem ) )->text() ); 674 QString packageName( ( static_cast<QCheckListItem*>( packageItem ) )->text() );
675 675
676 // Create package manager output widget 676 // Create package manager output widget
677 PackageInfoDlg *dlg = new PackageInfoDlg( this, &m_packman, packageName ); 677 PackageInfoDlg *dlg = new PackageInfoDlg( this, &m_packman, packageName );
678 connect( dlg, SIGNAL(closeInfoDlg()), this, SLOT(slotCloseDlg()) );
679 678
680 // Display widget 679 // Display widget
681 m_widgetStack.addWidget( dlg, 3 ); 680 m_widgetStack.addWidget( dlg, 3 );
682 m_widgetStack.raiseWidget( dlg ); 681 m_widgetStack.raiseWidget( dlg );
683} 682}
diff --git a/noncore/settings/packagemanager/oipkg.cpp b/noncore/settings/packagemanager/oipkg.cpp
index ed9ea10..eb07a61 100644
--- a/noncore/settings/packagemanager/oipkg.cpp
+++ b/noncore/settings/packagemanager/oipkg.cpp
@@ -1,464 +1,511 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2003 Dan Williams <drw@handhelds.org> 4              Copyright (c) 2003 Dan Williams <drw@handhelds.org>
5 =. 5 =.
6 .=l. 6 .=l.
7           .>+-= 7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 17    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 21++=   -.     .`     .: details.
22 :     =  ...= . :.=- 22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32#include "oipkg.h" 32#include "oipkg.h"
33 33
34#include <stdio.h>
34#include <stdlib.h> 35#include <stdlib.h>
35#include <string.h> 36#include <string.h>
36 37
37#include <qdir.h> 38#include <qdir.h>
38#include <qfile.h> 39#include <qfile.h>
39#include <qmessagebox.h> 40#include <qmessagebox.h>
40#include <qtextstream.h> 41#include <qtextstream.h>
41 42
42const QString IPKG_CONF = "/etc/ipkg.conf"; // Fully-qualified name of Ipkg primary configuration file 43const QString IPKG_CONF = "/etc/ipkg.conf"; // Fully-qualified name of Ipkg primary configuration file
43const QString IPKG_CONF_DIR = "/etc/ipkg"; // Directory of secondary Ipkg configuration files 44const QString IPKG_CONF_DIR = "/etc/ipkg"; // Directory of secondary Ipkg configuration files
44const QString IPKG_PKG_PATH = "/usr/lib/ipkg/lists"; // Directory containing server package lists 45const QString IPKG_PKG_PATH = "/usr/lib/ipkg/lists"; // Directory containing server package lists
45const QString IPKG_STATUS_PATH = "usr/lib/ipkg/status"; // Destination status file location 46const QString IPKG_STATUS_PATH = "usr/lib/ipkg/status"; // Destination status file location
46 47
47OIpkg *oipkg; 48OIpkg *oipkg;
48 49
49int fIpkgMessage( ipkg_conf_t */*conf*/, message_level_t /*level*/, char *msg ) 50// Ipkg callback functions
51
52int fsignalIpkgMessage( ipkg_conf_t */*conf*/, message_level_t /*level*/, char *msg )
50{ 53{
51 oipkg->ipkgOutput( msg ); 54 oipkg->ipkgMessage( msg );
52 return 0; 55 return 0;
53} 56}
54 57
55char* fIpkgResponse( char */*question*/ ) 58char *fIpkgResponse( char */*question*/ )
56{ 59{
57 return 0x0; 60 return 0x0;
58} 61}
59 62
63int fIpkgStatus( char */*name*/, int /*status*/, char *desc, void */*userdata*/ )
64{
65 oipkg->ipkgStatus( desc );
66 return 0;
67}
68
69int fIpkgFiles( char */*name*/, char *desc, char */*version*/, pkg_state_status_t /*status*/,
70 void */*userdata*/ )
71{
72printf( "*****List*****\n%s\n", desc );
73 oipkg->ipkgList( desc );
74 return 0;
75}
76
60OIpkg::OIpkg( Config *config, QObject *parent, const char *name ) 77OIpkg::OIpkg( Config *config, QObject *parent, const char *name )
61 : QObject( parent, name ) 78 : QObject( parent, name )
62 , m_config( config ) 79 , m_config( config )
63 , m_confInfo( NULL ) 80 , m_confInfo( NULL )
64 , m_ipkgExecOptions( 0 ) 81 , m_ipkgExecOptions( 0 )
65 , m_ipkgExecVerbosity( 1 ) 82 , m_ipkgExecVerbosity( 1 )
66{ 83{
67 oipkg = this; 84 oipkg = this;
68 85
69 // Initialize libipkg 86 // Initialize libipkg
70 if ( ipkg_init( &fIpkgMessage, &fIpkgResponse, &m_ipkgArgs ) ) 87 if ( ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ) )
71 QMessageBox::critical( 0, tr( "OIpkg" ), tr( "Error initialing libipkg" ) ); 88 QMessageBox::critical( 0, tr( "OIpkg" ), tr( "Error initialing libipkg" ) );
72 89
73 // Default ipkg run-time arguments 90 // Default ipkg run-time arguments
74 m_ipkgArgs.noaction = false; 91 m_ipkgArgs.noaction = false;
75 m_ipkgArgs.force_defaults = true; 92 m_ipkgArgs.force_defaults = true;
76} 93}
77 94
78OIpkg::~OIpkg() 95OIpkg::~OIpkg()
79{ 96{
80 // Upon destruction, ensure that items in config list are deleted with list 97 // Upon destruction, ensure that items in config list are deleted with list
81 if ( m_confInfo ) 98 if ( m_confInfo )
82 m_confInfo->setAutoDelete( true ); 99 m_confInfo->setAutoDelete( true );
83 100
84 // Free up libipkg resources 101 // Free up libipkg resources
85 if ( ipkg_deinit( &m_ipkgArgs ) ) 102 if ( ipkg_deinit( &m_ipkgArgs ) )
86 QMessageBox::critical( 0, tr( "OIpkg" ), tr( "Error freeing libipkg" ) ); 103 QMessageBox::critical( 0, tr( "OIpkg" ), tr( "Error freeing libipkg" ) );
87} 104}
88 105
89OConfItemList *OIpkg::configItems() 106OConfItemList *OIpkg::configItems()
90{ 107{
91 // Retrieve all configuration items 108 // Retrieve all configuration items
92 return filterConfItems(); 109 return filterConfItems();
93} 110}
94 111
95OConfItemList *OIpkg::servers() 112OConfItemList *OIpkg::servers()
96{ 113{
97 // Retrieve only servers 114 // Retrieve only servers
98 return filterConfItems( OConfItem::Source ); 115 return filterConfItems( OConfItem::Source );
99} 116}
100 117
101OConfItemList *OIpkg::destinations() 118OConfItemList *OIpkg::destinations()
102{ 119{
103 // Retrieve only destinations 120 // Retrieve only destinations
104 return filterConfItems( OConfItem::Destination ); 121 return filterConfItems( OConfItem::Destination );
105} 122}
106 123
107OConfItemList *OIpkg::options() 124OConfItemList *OIpkg::options()
108{ 125{
109 // Retrieve only destinations 126 // Retrieve only destinations
110 return filterConfItems( OConfItem::Option ); 127 return filterConfItems( OConfItem::Option );
111} 128}
112 129
113void OIpkg::setConfigItems( OConfItemList *configList ) 130void OIpkg::setConfigItems( OConfItemList *configList )
114{ 131{
115 if ( m_confInfo ) 132 if ( m_confInfo )
116 delete m_confInfo; 133 delete m_confInfo;
117 134
118 m_confInfo = configList; 135 m_confInfo = configList;
119} 136}
120 137
121void OIpkg::saveSettings() 138void OIpkg::saveSettings()
122{ 139{
123 // Save Ipkg execution options to application configuration file 140 // Save Ipkg execution options to application configuration file
124 if ( m_config ) 141 if ( m_config )
125 { 142 {
126 m_config->setGroup( "Ipkg" ); 143 m_config->setGroup( "Ipkg" );
127 m_config->writeEntry( "ExecOptions", m_ipkgExecOptions ); 144 m_config->writeEntry( "ExecOptions", m_ipkgExecOptions );
128 m_config->writeEntry( "Verbosity", m_ipkgExecVerbosity ); 145 m_config->writeEntry( "Verbosity", m_ipkgExecVerbosity );
129 } 146 }
130} 147}
131 148
132OPackageList *OIpkg::availablePackages( const QString &server ) 149OPackageList *OIpkg::availablePackages( const QString &server )
133{ 150{
134 // Load Ipkg configuration info if not already cached 151 // Load Ipkg configuration info if not already cached
135 if ( !m_confInfo ) 152 if ( !m_confInfo )
136 loadConfiguration(); 153 loadConfiguration();
137 154
138 // Build new server list (caller is responsible for deleting) 155 // Build new server list (caller is responsible for deleting)
139 OPackageList *pl = new OPackageList; 156 OPackageList *pl = new OPackageList;
140 157
141 // Open package list file 158 // Open package list file
142 QFile f( IPKG_PKG_PATH + "/" + server ); 159 QFile f( IPKG_PKG_PATH + "/" + server );
143 if ( !f.open( IO_ReadOnly ) ) 160 if ( !f.open( IO_ReadOnly ) )
144 return NULL; 161 return NULL;
145 QTextStream t( &f ); 162 QTextStream t( &f );
146 163
147 // Process all information in package list file 164 // Process all information in package list file
148 OPackage *package = NULL; 165 OPackage *package = NULL;
149 QString line = t.readLine(); 166 QString line = t.readLine();
150 while ( !t.eof() ) 167 while ( !t.eof() )
151 { 168 {
152 // Determine key/value pair 169 // Determine key/value pair
153 int pos = line.find( ':', 0 ); 170 int pos = line.find( ':', 0 );
154 QString key; 171 QString key;
155 if ( pos > -1 ) 172 if ( pos > -1 )
156 key = line.mid( 0, pos ); 173 key = line.mid( 0, pos );
157 else 174 else
158 key = QString::null; 175 key = QString::null;
159 QString value = line.mid( pos+2, line.length()-pos ); 176 QString value = line.mid( pos+2, line.length()-pos );
160 177
161 // Allocate new package and insert into list 178 // Allocate new package and insert into list
162 if ( package == NULL && !key.isEmpty() ) 179 if ( package == NULL && !key.isEmpty() )
163 { 180 {
164 package = new OPackage( value ); 181 package = new OPackage( value );
165 package->setSource( server ); 182 package->setSource( server );
166 pl->append( package ); 183 pl->append( package );
167 } 184 }
168 185
169 // Update package data 186 // Update package data
170 if ( key == "Package" ) 187 if ( key == "Package" )
171 package->setName( value ); 188 package->setName( value );
172 else if ( key == "Version" ) 189 else if ( key == "Version" )
173 package->setVersion( value ); 190 package->setVersion( value );
174 else if ( key == "Section" ) 191 else if ( key == "Section" )
175 package->setCategory( value ); 192 package->setCategory( value );
176 //DataManager::setAvailableCategories( value ); 193 //DataManager::setAvailableCategories( value );
177 else if ( key.isEmpty() && value.isEmpty() ) 194 else if ( key.isEmpty() && value.isEmpty() )
178 package = NULL; 195 package = NULL;
179 196
180 // Skip past all description lines 197 // Skip past all description lines
181 if ( key == "Description" ) 198 if ( key == "Description" )
182 { 199 {
183 line = t.readLine(); 200 line = t.readLine();
184 while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) 201 while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() )
185 line = t.readLine(); 202 line = t.readLine();
186 } 203 }
187 else 204 else
188 line = t.readLine(); 205 line = t.readLine();
189 } 206 }
190 207
191 f.close(); 208 f.close();
192 209
193 return pl; 210 return pl;
194} 211}
195 212
196OPackageList *OIpkg::installedPackages( const QString &destName, const QString &destPath ) 213OPackageList *OIpkg::installedPackages( const QString &destName, const QString &destPath )
197{ 214{
198 // Load Ipkg configuration info if not already cached 215 // Load Ipkg configuration info if not already cached
199 if ( !m_confInfo ) 216 if ( !m_confInfo )
200 loadConfiguration(); 217 loadConfiguration();
201 218
202 // Build new server list (caller is responsible for deleting) 219 // Build new server list (caller is responsible for deleting)
203 OPackageList *pl = new OPackageList; 220 OPackageList *pl = new OPackageList;
204 221
205 // Open status file 222 // Open status file
206 QString path = destPath; 223 QString path = destPath;
207 if ( path.right( 1 ) != "/" ) 224 if ( path.right( 1 ) != "/" )
208 path.append( "/" ); 225 path.append( "/" );
209 path.append( IPKG_STATUS_PATH ); 226 path.append( IPKG_STATUS_PATH );
210 227
211 QFile f( path ); 228 QFile f( path );
212 if ( !f.open( IO_ReadOnly ) ) 229 if ( !f.open( IO_ReadOnly ) )
213 return NULL; 230 return NULL;
214 QTextStream t( &f ); 231 QTextStream t( &f );
215 232
216 // Process all information in status file 233 // Process all information in status file
217 bool newPackage = false; 234 bool newPackage = false;
218 QString line = t.readLine(); 235 QString line = t.readLine();
219 QString name; 236 QString name;
220 QString version; 237 QString version;
221 QString status; 238 QString status;
222 239
223 while ( !t.eof() ) 240 while ( !t.eof() )
224 { 241 {
225 // Determine key/value pair 242 // Determine key/value pair
226 int pos = line.find( ':', 0 ); 243 int pos = line.find( ':', 0 );
227 QString key; 244 QString key;
228 if ( pos > -1 ) 245 if ( pos > -1 )
229 key = line.mid( 0, pos ); 246 key = line.mid( 0, pos );
230 else 247 else
231 key = QString::null; 248 key = QString::null;
232 QString value = line.mid( pos+2, line.length()-pos ); 249 QString value = line.mid( pos+2, line.length()-pos );
233 250
234 // Allocate new package and insert into list 251 // Allocate new package and insert into list
235 if ( newPackage && !key.isEmpty() ) 252 if ( newPackage && !key.isEmpty() )
236 { 253 {
237 // Add to list only if it has a valid name and is installed 254 // Add to list only if it has a valid name and is installed
238 if ( !name.isNull() && status.contains( " installed" ) ) 255 if ( !name.isNull() && status.contains( " installed" ) )
239 { 256 {
240 pl->append( new OPackage( name, QString::null, version, QString::null, destName ) ); 257 pl->append( new OPackage( name, QString::null, version, QString::null, destName ) );
241 name = QString::null; 258 name = QString::null;
242 version = QString::null; 259 version = QString::null;
243 status = QString::null; 260 status = QString::null;
244 261
245 newPackage = false; 262 newPackage = false;
246 } 263 }
247 } 264 }
248 265
249 // Update package data 266 // Update package data
250 if ( key == "Package" ) 267 if ( key == "Package" )
251 name = value; 268 name = value;
252 else if ( key == "Version" ) 269 else if ( key == "Version" )
253 version = value; 270 version = value;
254 else if ( key == "Status" ) 271 else if ( key == "Status" )
255 status = value; 272 status = value;
256 else if ( key.isEmpty() && value.isEmpty() ) 273 else if ( key.isEmpty() && value.isEmpty() )
257 newPackage = true; 274 newPackage = true;
258 275
259 // Skip past all description lines 276 // Skip past all description lines
260 if ( key == "Description" ) 277 if ( key == "Description" )
261 { 278 {
262 line = t.readLine(); 279 line = t.readLine();
263 while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) 280 while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() )
264 line = t.readLine(); 281 line = t.readLine();
265 } 282 }
266 else 283 else
267 line = t.readLine(); 284 line = t.readLine();
268 } 285 }
269 286
270 f.close(); 287 f.close();
271 288
272 return pl; 289 return pl;
273} 290}
274 291
275bool OIpkg::executeCommand( OPackage::Command command, QStringList *parameters, const QString &destination, 292bool OIpkg::executeCommand( OPackage::Command command, QStringList *parameters, const QString &destination,
276 const QObject *receiver, const char *slotOutput, bool rawOutput ) 293 const QObject *receiver, const char *slotOutput, bool rawOutput )
277{ 294{
278 if ( command == OPackage::NotDefined ) 295 if ( command == OPackage::NotDefined )
279 return false; 296 return false;
280 297
281 // Set ipkg run-time options/arguments 298 // Set ipkg run-time options/arguments
282 m_ipkgArgs.force_depends = ( m_ipkgExecOptions & FORCE_DEPENDS ); 299 m_ipkgArgs.force_depends = ( m_ipkgExecOptions & FORCE_DEPENDS );
283 m_ipkgArgs.force_reinstall = ( m_ipkgExecOptions & FORCE_REINSTALL ); 300 m_ipkgArgs.force_reinstall = ( m_ipkgExecOptions & FORCE_REINSTALL );
284 // TODO m_ipkgArgs.force_remove = ( m_ipkgExecOptions & FORCE_REMOVE ); 301 // TODO m_ipkgArgs.force_remove = ( m_ipkgExecOptions & FORCE_REMOVE );
285 m_ipkgArgs.force_overwrite = ( m_ipkgExecOptions & FORCE_OVERWRITE ); 302 m_ipkgArgs.force_overwrite = ( m_ipkgExecOptions & FORCE_OVERWRITE );
286 m_ipkgArgs.verbosity = m_ipkgExecVerbosity; 303 m_ipkgArgs.verbosity = m_ipkgExecVerbosity;
287 if ( m_ipkgArgs.dest ) 304 if ( m_ipkgArgs.dest )
288 free( m_ipkgArgs.dest ); 305 free( m_ipkgArgs.dest );
289 if ( !destination.isNull() ) 306 if ( !destination.isNull() )
290 { 307 {
291 int len = destination.length() + 1; 308 int len = destination.length() + 1;
292 m_ipkgArgs.dest = (char *)malloc( len ); 309 m_ipkgArgs.dest = (char *)malloc( len );
293 strncpy( m_ipkgArgs.dest, destination, destination.length() ); 310 strncpy( m_ipkgArgs.dest, destination, destination.length() );
294 m_ipkgArgs.dest[ len - 1 ] = '\0'; 311 m_ipkgArgs.dest[ len - 1 ] = '\0';
295 } 312 }
296 else 313 else
297 m_ipkgArgs.dest = 0x0; 314 m_ipkgArgs.dest = 0x0;
298 315
299 // Connect output signal to widget 316 // Connect output signal to widget
317
300 if ( rawOutput ) 318 if ( rawOutput )
301 { 319 {
302 if ( slotOutput ) 320// if ( slotOutput )
303 connect( this, SIGNAL(execOutput(char *)), receiver, slotOutput ); 321// connect( this, SIGNAL(signalIpkgMessage(char *)), receiver, slotOutput );
304 } 322 }
305 else 323 else
306 { 324 {
307 // TODO - connect to local slot and parse output before emitting execOutput 325 // TODO - connect to local slot and parse output before emitting signalIpkgMessage
308 } 326 }
309 327
310 switch( command ) 328 switch( command )
311 { 329 {
312 case OPackage::Update : ipkg_lists_update( &m_ipkgArgs ); 330 case OPackage::Update : {
331 connect( this, SIGNAL(signalIpkgMessage(char *)), receiver, slotOutput );
332 ipkg_lists_update( &m_ipkgArgs );
333 };
313 break; 334 break;
314 case OPackage::Upgrade : ipkg_packages_upgrade( &m_ipkgArgs ); 335 case OPackage::Upgrade : {
336 connect( this, SIGNAL(signalIpkgMessage(char *)), receiver, slotOutput );
337 ipkg_packages_upgrade( &m_ipkgArgs );
338 };
315 break; 339 break;
316 case OPackage::Install : { 340 case OPackage::Install : {
341 connect( this, SIGNAL(signalIpkgMessage(char *)), receiver, slotOutput );
317 for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) 342 for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it )
318 { 343 {
319 ipkg_packages_install( &m_ipkgArgs, (*it) ); 344 ipkg_packages_install( &m_ipkgArgs, (*it) );
320 } 345 }
321 }; 346 };
322 break; 347 break;
323 case OPackage::Remove : { 348 case OPackage::Remove : {
349 connect( this, SIGNAL(signalIpkgMessage(char *)), receiver, slotOutput );
324 for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) 350 for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it )
325 { 351 {
326 ipkg_packages_remove( &m_ipkgArgs, (*it), true ); 352 ipkg_packages_remove( &m_ipkgArgs, (*it), true );
327 } 353 }
328 }; 354 };
329 break; 355 break;
330 case OPackage::Download : { 356 case OPackage::Download : {
357 connect( this, SIGNAL(signalIpkgMessage(char *)), receiver, slotOutput );
331 for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) 358 for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it )
332 { 359 {
333 ipkg_packages_download( &m_ipkgArgs, (*it) ); 360 ipkg_packages_download( &m_ipkgArgs, (*it) );
334 } 361 }
335 }; 362 };
336 break; 363 break;
364 case OPackage::Info : {
365 connect( this, SIGNAL(signalIpkgStatus(char *)), receiver, slotOutput );
366 ipkg_packages_info( &m_ipkgArgs, (*parameters->begin()), &fIpkgStatus, 0x0 );
367 };
368 break;
369 case OPackage::Files : {
370 connect( this, SIGNAL(signalIpkgList(char *)), receiver, slotOutput );
371 ipkg_package_files( &m_ipkgArgs, (*parameters->begin()), &fIpkgFiles, 0x0 );
372 };
373 break;
337 default : break; 374 default : break;
338 }; 375 };
339 376
340 return true; 377 return true;
341} 378}
342 379
343void OIpkg::ipkgOutput( char *msg ) 380void OIpkg::ipkgMessage( char *msg )
381{
382 emit signalIpkgMessage( msg );
383}
384
385void OIpkg::ipkgStatus( char *status )
386{
387 emit signalIpkgStatus( status );
388}
389
390void OIpkg::ipkgList( char *filelist )
344{ 391{
345 emit execOutput( msg ); 392 emit signalIpkgList( filelist );
346} 393}
347 394
348void OIpkg::loadConfiguration() 395void OIpkg::loadConfiguration()
349{ 396{
350 if ( m_confInfo ) 397 if ( m_confInfo )
351 delete m_confInfo; 398 delete m_confInfo;
352 399
353 // Load configuration item list 400 // Load configuration item list
354 m_confInfo = new OConfItemList(); 401 m_confInfo = new OConfItemList();
355 402
356 QStringList confFiles; 403 QStringList confFiles;
357 QDir confDir( IPKG_CONF_DIR ); 404 QDir confDir( IPKG_CONF_DIR );
358 if ( confDir.exists() ) 405 if ( confDir.exists() )
359 { 406 {
360 confDir.setNameFilter( "*.conf" ); 407 confDir.setNameFilter( "*.conf" );
361 confDir.setFilter( QDir::Files ); 408 confDir.setFilter( QDir::Files );
362 confFiles = confDir.entryList( "*.conf", QDir::Files ); 409 confFiles = confDir.entryList( "*.conf", QDir::Files );
363 confFiles << IPKG_CONF; 410 confFiles << IPKG_CONF;
364 411
365 for ( QStringList::Iterator it = confFiles.begin(); it != confFiles.end(); ++it ) 412 for ( QStringList::Iterator it = confFiles.begin(); it != confFiles.end(); ++it )
366 { 413 {
367 // Create absolute file path if necessary 414 // Create absolute file path if necessary
368 QString absFile = (*it); 415 QString absFile = (*it);
369 if ( !absFile.startsWith( "/" ) ) 416 if ( !absFile.startsWith( "/" ) )
370 absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); 417 absFile.prepend( QString( IPKG_CONF_DIR ) + "/" );
371 418
372 // Read in file 419 // Read in file
373 QFile f( absFile ); 420 QFile f( absFile );
374 if ( f.open( IO_ReadOnly ) ) 421 if ( f.open( IO_ReadOnly ) )
375 { 422 {
376 QTextStream s( &f ); 423 QTextStream s( &f );
377 while ( !s.eof() ) 424 while ( !s.eof() )
378 { 425 {
379 426
380 QString line = s.readLine().simplifyWhiteSpace(); 427 QString line = s.readLine().simplifyWhiteSpace();
381 428
382 // Parse line and save info to the conf options list 429 // Parse line and save info to the conf options list
383 if ( !line.isEmpty() ) 430 if ( !line.isEmpty() )
384 { 431 {
385 if ( !line.startsWith( "#" ) || 432 if ( !line.startsWith( "#" ) ||
386 line.startsWith( "#src" ) || 433 line.startsWith( "#src" ) ||
387 line.startsWith( "#dest" ) || 434 line.startsWith( "#dest" ) ||
388 line.startsWith( "#arch" ) || 435 line.startsWith( "#arch" ) ||
389 line.startsWith( "#option" ) ) 436 line.startsWith( "#option" ) )
390 { 437 {
391 int pos = line.find( ' ', 1 ); 438 int pos = line.find( ' ', 1 );
392 439
393 // Type 440 // Type
394 QString typeStr = line.left( pos ); 441 QString typeStr = line.left( pos );
395 OConfItem::Type type; 442 OConfItem::Type type;
396 if ( typeStr == "src" || typeStr == "#src" ) 443 if ( typeStr == "src" || typeStr == "#src" )
397 type = OConfItem::Source; 444 type = OConfItem::Source;
398 else if ( typeStr == "dest" || typeStr == "#dest" ) 445 else if ( typeStr == "dest" || typeStr == "#dest" )
399 type = OConfItem::Destination; 446 type = OConfItem::Destination;
400 else if ( typeStr == "option" || typeStr == "#option" ) 447 else if ( typeStr == "option" || typeStr == "#option" )
401 type = OConfItem::Option; 448 type = OConfItem::Option;
402 else if ( typeStr == "arch" || typeStr == "#arch" ) 449 else if ( typeStr == "arch" || typeStr == "#arch" )
403 type = OConfItem::Arch; 450 type = OConfItem::Arch;
404 else 451 else
405 type = OConfItem::NotDefined; 452 type = OConfItem::NotDefined;
406 ++pos; 453 ++pos;
407 int endpos = line.find( ' ', pos ); 454 int endpos = line.find( ' ', pos );
408 455
409 // Name 456 // Name
410 QString name = line.mid( pos, endpos - pos ); 457 QString name = line.mid( pos, endpos - pos );
411 458
412 // Value 459 // Value
413 QString value = ""; 460 QString value = "";
414 if ( endpos > -1 ) 461 if ( endpos > -1 )
415 value = line.right( line.length() - endpos - 1 ); 462 value = line.right( line.length() - endpos - 1 );
416 463
417 // Active 464 // Active
418 bool active = !line.startsWith( "#" ); 465 bool active = !line.startsWith( "#" );
419 466
420 // Add to list 467 // Add to list
421 m_confInfo->append( new OConfItem( absFile, type, name, value, active ) ); 468 m_confInfo->append( new OConfItem( absFile, type, name, value, active ) );
422 } 469 }
423 } 470 }
424 } 471 }
425 472
426 f.close(); 473 f.close();
427 } 474 }
428 } 475 }
429 } 476 }
430 477
431 // Load Ipkg execution options from application configuration file 478 // Load Ipkg execution options from application configuration file
432 if ( m_config ) 479 if ( m_config )
433 { 480 {
434 m_config->setGroup( "Ipkg" ); 481 m_config->setGroup( "Ipkg" );
435 m_ipkgExecOptions = m_config->readNumEntry( "ExecOptions", m_ipkgExecOptions ); 482 m_ipkgExecOptions = m_config->readNumEntry( "ExecOptions", m_ipkgExecOptions );
436 m_ipkgExecVerbosity = m_config->readNumEntry( "Verbosity", m_ipkgExecVerbosity ); 483 m_ipkgExecVerbosity = m_config->readNumEntry( "Verbosity", m_ipkgExecVerbosity );
437 } 484 }
438} 485}
439 486
440OConfItemList *OIpkg::filterConfItems( OConfItem::Type typefilter ) 487OConfItemList *OIpkg::filterConfItems( OConfItem::Type typefilter )
441{ 488{
442 // Load Ipkg configuration info if not already cached 489 // Load Ipkg configuration info if not already cached
443 if ( !m_confInfo ) 490 if ( !m_confInfo )
444 loadConfiguration(); 491 loadConfiguration();
445 492
446 // Build new server list (caller is responsible for deleting) 493 // Build new server list (caller is responsible for deleting)
447 OConfItemList *sl = new OConfItemList; 494 OConfItemList *sl = new OConfItemList;
448 495
449 // If typefilter is empty, retrieve all items 496 // If typefilter is empty, retrieve all items
450 bool retrieveAll = ( typefilter == OConfItem::NotDefined ); 497 bool retrieveAll = ( typefilter == OConfItem::NotDefined );
451 498
452 // Parse configuration info for servers 499 // Parse configuration info for servers
453 OConfItemListIterator it( *m_confInfo ); 500 OConfItemListIterator it( *m_confInfo );
454 for ( ; it.current(); ++it ) 501 for ( ; it.current(); ++it )
455 { 502 {
456 OConfItem *item = it.current(); 503 OConfItem *item = it.current();
457 if ( retrieveAll || item->type() == typefilter ) 504 if ( retrieveAll || item->type() == typefilter )
458 { 505 {
459 sl->append( item ); 506 sl->append( item );
460 } 507 }
461 } 508 }
462 509
463 return sl; 510 return sl;
464} 511}
diff --git a/noncore/settings/packagemanager/oipkg.h b/noncore/settings/packagemanager/oipkg.h
index 824fa17..ea126cf 100644
--- a/noncore/settings/packagemanager/oipkg.h
+++ b/noncore/settings/packagemanager/oipkg.h
@@ -1,101 +1,105 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2003 Dan Williams <drw@handhelds.org> 4              Copyright (c) 2003 Dan Williams <drw@handhelds.org>
5 =. 5 =.
6 .=l. 6 .=l.
7           .>+-= 7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 17    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 21++=   -.     .`     .: details.
22 :     =  ...= . :.=- 22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32#ifndef OIPKG_H 32#ifndef OIPKG_H
33#define OIPKG_H 33#define OIPKG_H
34 34
35extern "C" { 35extern "C" {
36#include <libipkg.h> 36#include <libipkg.h>
37}; 37};
38 38
39#include <qobject.h> 39#include <qobject.h>
40 40
41#include <qpe/config.h> 41#include <qpe/config.h>
42 42
43#include "oconfitem.h" 43#include "oconfitem.h"
44#include "opackage.h" 44#include "opackage.h"
45 45
46// Ipkg execution options (m_ipkgExecOptions) 46// Ipkg execution options (m_ipkgExecOptions)
47#define FORCE_DEPENDS 0x0001 47#define FORCE_DEPENDS 0x0001
48#define FORCE_REMOVE 0x0002 48#define FORCE_REMOVE 0x0002
49#define FORCE_REINSTALL 0x0004 49#define FORCE_REINSTALL 0x0004
50#define FORCE_OVERWRITE 0x0008 50#define FORCE_OVERWRITE 0x0008
51 51
52class OConfItemList; 52class OConfItemList;
53 53
54class OIpkg : public QObject 54class OIpkg : public QObject
55{ 55{
56 Q_OBJECT 56 Q_OBJECT
57 57
58public: 58public:
59 OIpkg( Config *config = 0x0, QObject *parent = 0x0, const char *name = 0x0 ); 59 OIpkg( Config *config = 0x0, QObject *parent = 0x0, const char *name = 0x0 );
60 ~OIpkg(); 60 ~OIpkg();
61 61
62 OConfItemList *configItems(); 62 OConfItemList *configItems();
63 OConfItemList *servers(); 63 OConfItemList *servers();
64 OConfItemList *destinations(); 64 OConfItemList *destinations();
65 OConfItemList *options(); 65 OConfItemList *options();
66 66
67 int ipkgExecOptions() { return m_ipkgExecOptions; } 67 int ipkgExecOptions() { return m_ipkgExecOptions; }
68 int ipkgExecVerbosity() { return m_ipkgExecVerbosity; } 68 int ipkgExecVerbosity() { return m_ipkgExecVerbosity; }
69 69
70 void setConfigItems( OConfItemList *configList ); 70 void setConfigItems( OConfItemList *configList );
71 void setIpkgExecOptions( int options ) { m_ipkgExecOptions = options; } 71 void setIpkgExecOptions( int options ) { m_ipkgExecOptions = options; }
72 void setIpkgExecVerbosity( int verbosity ) { m_ipkgExecVerbosity = verbosity; } 72 void setIpkgExecVerbosity( int verbosity ) { m_ipkgExecVerbosity = verbosity; }
73 73
74 void saveSettings(); 74 void saveSettings();
75 75
76 OPackageList *availablePackages( const QString &server = QString::null ); 76 OPackageList *availablePackages( const QString &server = QString::null );
77 OPackageList *installedPackages( const QString &destName = QString::null, 77 OPackageList *installedPackages( const QString &destName = QString::null,
78 const QString &destPath = QString::null ); 78 const QString &destPath = QString::null );
79 79
80 bool executeCommand( OPackage::Command command = OPackage::NotDefined, QStringList *parameters = 0x0, 80 bool executeCommand( OPackage::Command command = OPackage::NotDefined, QStringList *parameters = 0x0,
81 const QString &destination = QString::null, const QObject *receiver = 0x0, 81 const QString &destination = QString::null, const QObject *receiver = 0x0,
82 const char *slotOutput = 0x0, bool rawOutput = true ); 82 const char *slotOutput = 0x0, bool rawOutput = true );
83 void abortCommand(); 83 void abortCommand();
84 84
85 void ipkgOutput( char *msg ); 85 void ipkgMessage( char *msg );
86 void ipkgStatus( char *status );
87 void ipkgList( char *filelist );
86 88
87private: 89private:
88 Config *m_config; // Pointer to application configuration file 90 Config *m_config; // Pointer to application configuration file
89 args_t m_ipkgArgs; // libipkg configuration arguments 91 args_t m_ipkgArgs; // libipkg configuration arguments
90 OConfItemList *m_confInfo; // Contains info from all Ipkg configuration files 92 OConfItemList *m_confInfo; // Contains info from all Ipkg configuration files
91 int m_ipkgExecOptions; // Bit-mapped flags for Ipkg execution options 93 int m_ipkgExecOptions; // Bit-mapped flags for Ipkg execution options
92 int m_ipkgExecVerbosity; // Ipkg execution verbosity level 94 int m_ipkgExecVerbosity; // Ipkg execution verbosity level
93 95
94 void loadConfiguration(); 96 void loadConfiguration();
95 OConfItemList *filterConfItems( OConfItem::Type typefilter = OConfItem::NotDefined ); 97 OConfItemList *filterConfItems( OConfItem::Type typefilter = OConfItem::NotDefined );
96 98
97signals: 99signals:
98 void execOutput( char *msg ); 100 void signalIpkgMessage( char *msg );
101 void signalIpkgStatus( char *status );
102 void signalIpkgList( char *filelist );
99}; 103};
100 104
101#endif 105#endif
diff --git a/noncore/settings/packagemanager/opackage.cpp b/noncore/settings/packagemanager/opackage.cpp
index 34717e3..37963fa 100644
--- a/noncore/settings/packagemanager/opackage.cpp
+++ b/noncore/settings/packagemanager/opackage.cpp
@@ -1,43 +1,46 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2003 Dan Williams <drw@handhelds.org> 4              Copyright (c) 2003 Dan Williams <drw@handhelds.org>
5 =. 5 =.
6 .=l. 6 .=l.
7           .>+-= 7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 17    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 21++=   -.     .`     .: details.
22 :     =  ...= . :.=- 22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32#include "opackage.h" 32#include "opackage.h"
33 33
34OPackage::OPackage( const QString &name, const QString &version, const QString &versionInstalled, 34OPackage::OPackage( const QString &name, const QString &version, const QString &versionInstalled,
35 const QString &source, const QString &destination, const QString &category ) 35 const QString &source, const QString &destination, const QString &category,
36 const QString &information, const QString &files )
36 : m_name( name ) 37 : m_name( name )
37 , m_version( version ) 38 , m_version( version )
38 , m_versionInstalled( versionInstalled ) 39 , m_versionInstalled( versionInstalled )
39 , m_source( source ) 40 , m_source( source )
40 , m_destination( destination ) 41 , m_destination( destination )
41 , m_category( category ) 42 , m_category( category )
43 , m_information( information )
44 , m_files( files )
42{ 45{
43} 46}
diff --git a/noncore/settings/packagemanager/opackage.h b/noncore/settings/packagemanager/opackage.h
index 1e2e49f..fbd9ec0 100644
--- a/noncore/settings/packagemanager/opackage.h
+++ b/noncore/settings/packagemanager/opackage.h
@@ -1,74 +1,81 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2003 Dan Williams <drw@handhelds.org> 4              Copyright (c) 2003 Dan Williams <drw@handhelds.org>
5 =. 5 =.
6 .=l. 6 .=l.
7           .>+-= 7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 17    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 21++=   -.     .`     .: details.
22 :     =  ...= . :.=- 22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32#ifndef OPACKAGE_H 32#ifndef OPACKAGE_H
33#define OPACKAGE_H 33#define OPACKAGE_H
34 34
35#include <qlist.h> 35#include <qlist.h>
36#include <qstring.h> 36#include <qstring.h>
37 37
38class OPackage 38class OPackage
39{ 39{
40public: 40public:
41 enum Command { Install, Remove, Update, Upgrade, Download, Info, Files, Version, NotDefined }; 41 enum Command { Install, Remove, Update, Upgrade, Download, Info, Files, Version, NotDefined };
42 42
43 OPackage( const QString &name = 0x0, 43 OPackage( const QString &name= QString::null,
44 const QString &version = 0x0, const QString &versionInstalled = 0x0, 44 const QString &version= QString::null, const QString &versionInstalled= QString::null,
45 const QString &source = 0x0, const QString &destination = 0x0, 45 const QString &source= QString::null, const QString &destination= QString::null,
46 const QString &category = "misc" ); 46 const QString &category = "misc", const QString &information = QString::null,
47 const QString &files = QString::null );
47 48
48 const QString &name() { return m_name; } 49 const QString &name() { return m_name; }
49 const QString &version() { return m_version; } 50 const QString &version() { return m_version; }
50 const QString &versionInstalled() { return m_versionInstalled; } 51 const QString &versionInstalled() { return m_versionInstalled; }
51 const QString &source() { return m_source; } 52 const QString &source() { return m_source; }
52 const QString &destination() { return m_destination; } 53 const QString &destination() { return m_destination; }
53 const QString &category() { return m_category; } 54 const QString &category() { return m_category; }
55 const QString &information() { return m_information; }
56 const QString &files() { return m_files; }
54 57
55 void setName( const QString &name ) { m_name = name; } 58 void setName( const QString &name ) { m_name = name; }
56 void setVersion( const QString &version ) { m_version = version; } 59 void setVersion( const QString &version ) { m_version = version; }
57 void setVersionInstalled( const QString &version ) { m_versionInstalled = version; } 60 void setVersionInstalled( const QString &version ) { m_versionInstalled = version; }
58 void setSource( const QString &source ) { m_source = source; } 61 void setSource( const QString &source ) { m_source = source; }
59 void setDestination( const QString &destination ) { m_destination = destination; } 62 void setDestination( const QString &destination ) { m_destination = destination; }
60 void setCategory( const QString &category ) { m_category = category; } 63 void setCategory( const QString &category ) { m_category = category; }
64 void setInformation( const QString &information ) { m_information = information; }
65 void setFiles( const QString &files ) { m_files = files; }
61 66
62private: 67private:
63 QString m_name; // Name of item 68 QString m_name; // Name of item
64 QString m_version; // Available version number of item 69 QString m_version; // Available version number of item
65 QString m_versionInstalled; // Installed version number of item, null if not installed 70 QString m_versionInstalled; // Installed version number of item, null if not installed
66 QString m_source; // Source feed of available version 71 QString m_source; // Source feed of available version
67 QString m_destination; // Location item is installed to, null if not installed 72 QString m_destination; // Location item is installed to, null if not installed
68 QString m_category; // Item category 73 QString m_category; // Item category
74 QString m_information; // Package information
75 QString m_files; // File list information
69}; 76};
70 77
71typedef QList<OPackage> OPackageList; 78typedef QList<OPackage> OPackageList;
72typedef QListIterator<OPackage> OPackageListIterator; 79typedef QListIterator<OPackage> OPackageListIterator;
73 80
74#endif 81#endif
diff --git a/noncore/settings/packagemanager/packageinfodlg.cpp b/noncore/settings/packagemanager/packageinfodlg.cpp
index 26356b9..7daf336 100644
--- a/noncore/settings/packagemanager/packageinfodlg.cpp
+++ b/noncore/settings/packagemanager/packageinfodlg.cpp
@@ -1,82 +1,140 @@
1/* 1/*
2                This file is part of the OPIE Project 2                This file is part of the OPIE Project
3 3
4 =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> 4 =. Copyright (c) 2003 Dan Williams <drw@handhelds.org>
5             .=l. 5             .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This file is free software; you can 7 _;:,     .>    :=|. This file is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU General Public 9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This file is distributed in the hope that 14    .i_,=:_.      -<s. This file is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details. 19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .: 20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU 21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file; 22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the 23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc., 24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330, 25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
27 27
28*/ 28*/
29 29
30#include "packageinfodlg.h" 30#include "packageinfodlg.h"
31#include "opackage.h"
32#include "opackagemanager.h"
31 33
32#include <qlayout.h> 34#include <qlayout.h>
33#include <qpushbutton.h> 35#include <qpushbutton.h>
34 36
35#include <qpe/resource.h> 37#include <qpe/resource.h>
36 38
37#include <opie/otabwidget.h> 39#include <opie/otabwidget.h>
38 40
39PackageInfoDlg::PackageInfoDlg( QWidget *parent, OPackageManager *pm, const QString &package ) 41PackageInfoDlg::PackageInfoDlg( QWidget *parent, OPackageManager *pm, const QString &package )
40 : QWidget( 0x0 ) 42 : QWidget( 0x0 )
41 , m_packman( pm ) 43 , m_packman( pm )
42 , m_information( this ) 44 , m_information( this )
43 , m_files( this ) 45 , m_files( this )
44{ 46{
45 // Initialize UI 47 // Initialize UI
46 if ( parent ) 48 if ( parent )
47 parent->setCaption( package ); 49 parent->setCaption( package );
48 50
49 QVBoxLayout *layout = new QVBoxLayout( this, 4, 0 ); 51 QVBoxLayout *layout = new QVBoxLayout( this, 4, 2 );
50 52
51 OTabWidget *tabWidget = new OTabWidget( this ); 53 OTabWidget *tabWidget = new OTabWidget( this );
52 layout->addWidget( tabWidget ); 54 layout->addWidget( tabWidget );
53 55
54 QPushButton *btn = new QPushButton( Resource::loadPixmap( "enter" ), tr( "Close" ), this );
55 layout->addWidget( btn );
56 connect( btn, SIGNAL(clicked()), this, SLOT(slotBtnClose()) );
57
58 // Information tab 56 // Information tab
59 m_information.reparent( tabWidget, QPoint( 0, 0 ) ); 57 m_information.reparent( tabWidget, QPoint( 0, 0 ) );
60 m_information.setReadOnly( true ); 58 m_information.setReadOnly( true );
61 tabWidget->addTab( &m_information, "UtilsIcon", tr( "Information" ) ); 59 tabWidget->addTab( &m_information, "UtilsIcon", tr( "Information" ) );
62 60
63 // Files tab 61 // Retrive package information
64 QWidget *filesWidget = new QWidget( tabWidget ); 62 m_package = m_packman->findPackage( package );
65 QVBoxLayout *filesLayout = new QVBoxLayout( filesWidget, 4, 0 ); 63 if ( !m_package )
66 m_files.reparent( filesWidget, QPoint( 0, 0 ) ); 64 {
67 m_files.setReadOnly( true ); 65 m_information.setText( tr( "Unable to retrieve package information." ) );
68 filesLayout->addWidget( &m_files ); 66 return;
67 }
68
69 // Display package information
70 if ( !m_package->information().isNull() )
71 m_information.setText( m_package->information() );
72 else
73 {
74 // Package information is not cached, retrieve it
75 QStringList list( package );
76 m_packman->executeCommand( OPackage::Info, &list, QString::null, this, SLOT(slotInfo(char*)), true );
77 }
78
79 // Files tab (display only if package is installed)
80 if ( !m_package->versionInstalled().isNull() )
81 {
82 QWidget *filesWidget = new QWidget( tabWidget );
83 QVBoxLayout *filesLayout = new QVBoxLayout( filesWidget, 2, 2 );
84 m_files.reparent( filesWidget, QPoint( 0, 0 ) );
85 m_files.setReadOnly( true );
86 filesLayout->addWidget( &m_files );
87
88 QPushButton *btn = new QPushButton( Resource::loadPixmap( "packagemanager/apply" ),
89 tr( "Retrieve file list" ), filesWidget );
90 filesLayout->addWidget( btn );
91 connect( btn, SIGNAL(clicked()), this, SLOT(slotBtnFileScan()) );
92 tabWidget->addTab( filesWidget, "binary", tr( "File list" ) );
93
94 tabWidget->setCurrentTab( tr( "Information" ) );
95
96 // If file list is already cached, display
97 if ( !m_package->files().isNull() )
98 m_files.setText( m_package->files() );
99 }
100 else
101 m_files.hide();
102}
103
104PackageInfoDlg::~PackageInfoDlg()
105{
106 if ( !m_package )
107 return;
108
109 // Cache package information
110 if ( !m_information.text().isNull() )
111 m_package->setInformation( m_information.text() );
69 112
70 btn = new QPushButton( Resource::loadPixmap( "packagemanager/apply" ), tr( "Retrieve file list" ), 113 // Cache package file list
71 filesWidget ); 114 if ( !m_files.text().isNull() )
72 filesLayout->addWidget( btn ); 115 m_package->setFiles( m_files.text() );
73// TODO connect( btn, SIGNAL(clicked()), this, SLOT(slotFileScan()) ); 116}
74 tabWidget->addTab( filesWidget, "binary", tr( "Files" ) );
75 117
76 tabWidget->setCurrentTab( tr( "Information" ) ); 118void PackageInfoDlg::slotBtnFileScan()
119{
120 m_files.clear();
121
122 QStringList list( m_package->name() );
123 m_packman->executeCommand( OPackage::Files, &list, QString::null, this, SLOT(slotFiles(char*)), true );
77} 124}
78 125
79void PackageInfoDlg::slotBtnClose() 126void PackageInfoDlg::slotInfo( char *info )
80{ 127{
81 emit closeInfoDlg(); 128 m_information.append( info );
129}
130
131void PackageInfoDlg::slotFiles( char *filelist )
132{
133 QString str = filelist;
134
135 // Skip first line of output ("Package xxx is installed...")
136 if ( str.startsWith( "Package " ) )
137 str = str.right( str.length() - str.find( '\n' ) - 1 );
138
139 m_files.append( str );
82} 140}
diff --git a/noncore/settings/packagemanager/packageinfodlg.h b/noncore/settings/packagemanager/packageinfodlg.h
index 09af6f4..13a15e2 100644
--- a/noncore/settings/packagemanager/packageinfodlg.h
+++ b/noncore/settings/packagemanager/packageinfodlg.h
@@ -1,65 +1,67 @@
1/* 1/*
2                This file is part of the OPIE Project 2                This file is part of the OPIE Project
3 3
4 =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> 4 =. Copyright (c) 2003 Dan Williams <drw@handhelds.org>
5             .=l. 5             .=l.
6           .>+-= 6           .>+-=
7 _;:,     .>    :=|. This file is free software; you can 7 _;:,     .>    :=|. This file is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU General Public 9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_. 13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This file is distributed in the hope that 14    .i_,=:_.      -<s. This file is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General 18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details. 19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .: 20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU 21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file; 22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the 23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc., 24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330, 25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA. 26 Boston, MA 02111-1307, USA.
27 27
28*/ 28*/
29 29
30#ifndef PACKAGEINFODLG_H 30#ifndef PACKAGEINFODLG_H
31#define PACKAGEINFODLG_H 31#define PACKAGEINFODLG_H
32 32
33#include <qmultilineedit.h> 33#include <qmultilineedit.h>
34#include <qwidget.h> 34#include <qwidget.h>
35 35
36#include <opie/oprocess.h> 36#include <opie/oprocess.h>
37 37
38#include "opackage.h" 38#include "opackage.h"
39 39
40class QPushButton; 40class QPushButton;
41 41
42class OPackage;
42class OPackageManager; 43class OPackageManager;
43 44
44class PackageInfoDlg : public QWidget 45class PackageInfoDlg : public QWidget
45{ 46{
46 Q_OBJECT 47 Q_OBJECT
47 48
48public: 49public:
49 PackageInfoDlg( QWidget *parent = 0x0, OPackageManager *pm = 0x0, const QString &package = QString::null ); 50 PackageInfoDlg( QWidget *parent = 0x0, OPackageManager *pm = 0x0, const QString &package = QString::null );
51 ~PackageInfoDlg();
50 52
51private: 53private:
52 OPackageManager *m_packman; // Pointer to application instance of package manager 54 OPackageManager *m_packman; // Pointer to application instance of package manager
55 OPackage *m_package; // Pointer to package to display information for
53 56
54 // UI controls 57 // UI controls
55 QMultiLineEdit m_information; // Multi-line edit to display package information 58 QMultiLineEdit m_information; // Multi-line edit to display package information
56 QMultiLineEdit m_files; // Multi-line edit to display package file list 59 QMultiLineEdit m_files; // Multi-line edit to display package file list
57 60
58private slots: 61private slots:
59 void slotBtnClose(); 62 void slotBtnFileScan();
60 63 void slotInfo( char *info );
61signals: 64 void slotFiles( char *filelist );
62 void closeInfoDlg();
63}; 65};
64 66
65#endif 67#endif