summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/packagemanager/.cvsignore2
-rw-r--r--noncore/settings/packagemanager/ChangeLog7
-rw-r--r--noncore/settings/packagemanager/installdlg.cpp76
-rw-r--r--noncore/settings/packagemanager/installdlg.h4
-rw-r--r--noncore/settings/packagemanager/mainwindow.cpp6
-rw-r--r--noncore/settings/packagemanager/oipkg.cpp188
-rw-r--r--noncore/settings/packagemanager/oipkg.h17
-rw-r--r--noncore/settings/packagemanager/opackagemanager.cpp11
-rw-r--r--noncore/settings/packagemanager/opackagemanager.h4
-rw-r--r--noncore/settings/packagemanager/opie-packagemanager.control2
-rw-r--r--noncore/settings/packagemanager/packagemanager.pro9
11 files changed, 135 insertions, 191 deletions
diff --git a/noncore/settings/packagemanager/.cvsignore b/noncore/settings/packagemanager/.cvsignore
index 4183697..9f2b524 100644
--- a/noncore/settings/packagemanager/.cvsignore
+++ b/noncore/settings/packagemanager/.cvsignore
@@ -1,3 +1,5 @@
1Makefile* 1Makefile*
2moc* 2moc*
3.moc* 3.moc*
4.obj
5.moc
diff --git a/noncore/settings/packagemanager/ChangeLog b/noncore/settings/packagemanager/ChangeLog
index a01c8b3..1ba12af 100644
--- a/noncore/settings/packagemanager/ChangeLog
+++ b/noncore/settings/packagemanager/ChangeLog
@@ -1,4 +1,9 @@
12004-01-nn Dan Williams <drw@handhelds.org> 12004-01-20 Dan Williams <drw@handhelds.org>
2
3 * Released version 0.2.0
4 * Converted to use libipkg in place of spawning ipkg process
5
62004-01-13 Dan Williams <drw@handhelds.org>
2 7
3 * Released version 0.1.0 8 * Released version 0.1.0
4 * Initial check-in of new package management client to eventually replace AQPkg 9 * Initial check-in of new package management client to eventually replace AQPkg
diff --git a/noncore/settings/packagemanager/installdlg.cpp b/noncore/settings/packagemanager/installdlg.cpp
index 980d5eb..6a9ccbd 100644
--- a/noncore/settings/packagemanager/installdlg.cpp
+++ b/noncore/settings/packagemanager/installdlg.cpp
@@ -145,165 +145,155 @@ InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &cap
145 break; 145 break;
146 }; 146 };
147 lineStr.append( ":\n" ); 147 lineStr.append( ":\n" );
148 148
149 for ( QStringList::Iterator it = m_packages[ i ]->begin(); it != m_packages[ i ]->end(); ++it ) 149 for ( QStringList::Iterator it = m_packages[ i ]->begin(); it != m_packages[ i ]->end(); ++it )
150 { 150 {
151 lineStr.append( QString( "\t%1\n" ).arg( ( *it ) ) ); 151 lineStr.append( QString( "\t%1\n" ).arg( ( *it ) ) );
152 } 152 }
153 153
154 m_output->append( lineStr ); 154 m_output->append( lineStr );
155 } 155 }
156 } 156 }
157 157
158 m_output->append( tr( "Press the start button to begin.\n" ) ); 158 m_output->append( tr( "Press the start button to begin.\n" ) );
159 m_output->setCursorPosition( m_output->numLines(), 0 ); 159 m_output->setCursorPosition( m_output->numLines(), 0 );
160 160
161} 161}
162 162
163InstallDlg::~InstallDlg() 163InstallDlg::~InstallDlg()
164{ 164{
165 for( int i = 0; i < m_numCommands; i++ ) 165 for( int i = 0; i < m_numCommands; i++ )
166 { 166 {
167 if ( m_packages[ i ] ) 167 if ( m_packages[ i ] )
168 delete m_packages[ i ]; 168 delete m_packages[ i ];
169 } 169 }
170} 170}
171 171
172void InstallDlg::slotDisplayAvailSpace( const QString &destination ) 172void InstallDlg::slotDisplayAvailSpace( const QString &destination )
173{ 173{
174 // If available space is not displayed, exit 174 // If available space is not displayed, exit
175 if ( !m_availSpace ) 175 if ( !m_availSpace )
176 return; 176 return;
177 177
178 QString space = tr( "Unknown" ); 178 QString space = tr( "Unknown" );
179 179
180 // Get destination 180 // Get destination
181 OConfItem *dest = m_packman->findConfItem( OConfItem::Destination, destination ); 181 OConfItem *dest = m_packman->findConfItem( OConfItem::Destination, destination );
182 182
183 if ( dest ) 183 if ( dest )
184 { 184 {
185 // Calculate available space 185 // Calculate available space
186 struct statfs fs; 186 struct statfs fs;
187 if ( !statfs( dest->value(), &fs ) ) 187 if ( !statfs( dest->value(), &fs ) )
188 { 188 {
189 long mult = fs.f_bsize / 1024; 189 long mult = fs.f_bsize / 1024;
190 long div = 1024 / fs.f_bsize; 190 long div = 1024 / fs.f_bsize;
191 191
192 if ( !mult ) mult = 1; 192 if ( !mult ) mult = 1;
193 if ( !div ) div = 1; 193 if ( !div ) div = 1;
194 long avail = fs.f_bavail * mult / div; 194 long avail = fs.f_bavail * mult / div;
195 195
196 space = tr( "%1 Kb" ).arg( avail ); 196 space = tr( "%1 Kb" ).arg( avail );
197 } 197 }
198 } 198 }
199 199
200 // Display available space 200 // Display available space
201 m_availSpace->setText( space ); 201 m_availSpace->setText( space );
202} 202}
203 203
204void InstallDlg::slotBtnStart() 204void InstallDlg::slotBtnStart()
205{ 205{
206 QString btnText = m_btnStart->text(); 206 QString btnText = m_btnStart->text();
207 if ( btnText == tr( "Abort" ) ) 207 if ( btnText == tr( "Abort" ) )
208 { 208 {
209 // Stop execution of current command and prevent any others from executing 209 // Prevent unexecuted commands from executing
210 m_packman->abortCommand();
211 m_currCommand = 999; 210 m_currCommand = 999;
212 211
213 // Allow user to close dialog 212 // Allow user to close dialog
214 m_btnStart->setText( tr( "Close" ) ); 213 m_btnStart->setText( tr( "Close" ) );
215 m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) ); 214 m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) );
216 return; 215 return;
217 } 216 }
218 else if ( btnText == tr( "Close" ) ) 217 else if ( btnText == tr( "Close" ) )
219 { 218 {
220 // TODO - force reload of package data 219 // TODO - force reload of package data
221 emit closeInstallDlg(); 220 emit closeInstallDlg();
222 return; 221 return;
223 } 222 }
224 223
225 // Start was clicked, execute first command 224 // Start was clicked, start executing
226 m_btnOptions->setEnabled( false ); 225 m_btnOptions->setEnabled( false );
227 m_btnStart->setText( tr( "Abort" ) ); 226 if ( m_numCommands > 1 )
228 m_btnStart->setIconSet( Resource::loadPixmap( "close" ) ); 227 {
228 m_btnStart->setText( tr( "Abort" ) );
229 m_btnStart->setIconSet( Resource::loadPixmap( "close" ) );
230 }
231 else
232 {
233 m_btnStart->setEnabled( false );
234 }
229 235
230 QString dest; 236 QString dest;
231 if ( m_destination ) 237 if ( m_destination )
232 dest = m_destination->currentText(); 238 dest = m_destination->currentText();
233 m_packman->executeCommand( m_command[ 0 ], m_packages[ 0 ], dest, this, 239
234 SLOT(slotOutput(OProcess*,char*,int)), SLOT(slotErrors(OProcess*,char*,int)), 240 for ( m_currCommand = 0; m_currCommand < m_numCommands; m_currCommand++ )
235 SLOT(slotFinished(OProcess*)), true ); 241 {
242 // Execute next command
243 m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], dest,
244 this, SLOT(slotOutput(char*)), true );
245 }
246
247 // All commands executed, allow user to close dialog
248 m_btnStart->setEnabled( true );
249 m_btnStart->setText( tr( "Close" ) );
250 m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) );
251
252 m_btnOptions->setEnabled( true );
253 m_btnOptions->setText( tr( "Save output" ) );
254 m_btnOptions->setIconSet( Resource::loadPixmap( "save" ) );
236} 255}
237 256
238void InstallDlg::slotBtnOptions() 257void InstallDlg::slotBtnOptions()
239{ 258{
240 QString btnText = m_btnOptions->text(); 259 QString btnText = m_btnOptions->text();
241 if ( btnText == tr( "Options" ) ) 260 if ( btnText == tr( "Options" ) )
242 { 261 {
243 // Display configuration dialog (only options tab is enabled) 262 // Display configuration dialog (only options tab is enabled)
244 m_packman->configureDlg( true ); 263 m_packman->configureDlg( true );
245 return; 264 return;
246 } 265 }
247 266
248 // Save output was clicked 267 // Save output was clicked
249 QMap<QString, QStringList> map; 268 QMap<QString, QStringList> map;
250 map.insert( tr( "All" ), QStringList() ); 269 map.insert( tr( "All" ), QStringList() );
251 QStringList text; 270 QStringList text;
252 text << "text/*"; 271 text << "text/*";
253 map.insert(tr( "Text" ), text ); 272 map.insert(tr( "Text" ), text );
254 text << "*"; 273 text << "*";
255 map.insert( tr( "All" ), text ); 274 map.insert( tr( "All" ), text );
256 275
257 QString filename = OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map ); 276 QString filename = OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map );
258 if( !filename.isEmpty() ) 277 if( !filename.isEmpty() )
259 { 278 {
260 QString currentFileName = QFileInfo( filename ).fileName(); 279 QString currentFileName = QFileInfo( filename ).fileName();
261 DocLnk doc; 280 DocLnk doc;
262 doc.setType( "text/plain" ); 281 doc.setType( "text/plain" );
263 doc.setFile( filename ); 282 doc.setFile( filename );
264 doc.setName( currentFileName ); 283 doc.setName( currentFileName );
265 FileManager fm; 284 FileManager fm;
266 fm.saveFile( doc, m_output->text() ); 285 fm.saveFile( doc, m_output->text() );
267 } 286 }
268} 287}
269 288
270void InstallDlg::slotOutput( OProcess */*process*/, char *buffer, int buffLen ) 289void InstallDlg::slotOutput( char *msg )
271{ 290{
272 QString lineStr = buffer; 291 // Allow processing of other events
273 if ( lineStr[buffLen-1] == '\n' ) 292 qApp->processEvents();
274 lineStr.truncate( buffLen - 1 );
275 m_output->append( lineStr );
276 m_output->setCursorPosition( m_output->numLines(), 0 );
277}
278 293
279void InstallDlg::slotErrors( OProcess */*process*/, char *buffer, int buffLen ) 294 QString lineStr = msg;
280{ 295 if ( lineStr[lineStr.length()-1] == '\n' )
281 QString lineStr = buffer; 296 lineStr.truncate( lineStr.length() - 1 );
282 if ( lineStr[buffLen-1] == '\n' )
283 lineStr.truncate( buffLen - 1 );
284 m_output->append( lineStr ); 297 m_output->append( lineStr );
285 m_output->setCursorPosition( m_output->numLines(), 0 ); 298 m_output->setCursorPosition( m_output->numLines(), 0 );
286} 299}
287
288void InstallDlg::slotFinished( OProcess */*process*/ )
289{
290 ++m_currCommand;
291 if ( m_currCommand < m_numCommands )
292 {
293 // More commands left, execute next one
294 m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], m_destination->currentText(),
295 this, SLOT(slotOutput(OProcess*,char*,int)),
296 SLOT(slotErrors(OProcess*,char*,int)),
297 SLOT(slotFinished(OProcess*)), true );
298 }
299 else
300 {
301 // All commands executed, allow user to close dialog
302 m_btnStart->setText( tr( "Close" ) );
303 m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) );
304
305 m_btnOptions->setEnabled( true );
306 m_btnOptions->setText( tr( "Save output" ) );
307 m_btnOptions->setIconSet( Resource::loadPixmap( "save" ) );
308 }
309}
diff --git a/noncore/settings/packagemanager/installdlg.h b/noncore/settings/packagemanager/installdlg.h
index 8075f1d..7efe721 100644
--- a/noncore/settings/packagemanager/installdlg.h
+++ b/noncore/settings/packagemanager/installdlg.h
@@ -17,73 +17,71 @@
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 INSTALLDLG_H 30#ifndef INSTALLDLG_H
31#define INSTALLDLG_H 31#define INSTALLDLG_H
32 32
33#include <qwidget.h> 33#include <qwidget.h>
34 34
35#include <opie/oprocess.h> 35#include <opie/oprocess.h>
36 36
37#include "opackage.h" 37#include "opackage.h"
38 38
39class QComboBox; 39class QComboBox;
40class QLabel; 40class QLabel;
41class QMultiLineEdit; 41class QMultiLineEdit;
42class QPushButton; 42class QPushButton;
43 43
44class OPackageManager; 44class OPackageManager;
45 45
46class InstallDlg : public QWidget 46class InstallDlg : public QWidget
47{ 47{
48 Q_OBJECT 48 Q_OBJECT
49 49
50public: 50public:
51 InstallDlg( QWidget *parent = 0x0, OPackageManager *pm = 0x0, const QString &caption = QString::null, 51 InstallDlg( QWidget *parent = 0x0, OPackageManager *pm = 0x0, const QString &caption = QString::null,
52 bool showDestInfo = true, 52 bool showDestInfo = true,
53 OPackage::Command command1 = OPackage::NotDefined, QStringList *packages1 = 0x0, 53 OPackage::Command command1 = OPackage::NotDefined, QStringList *packages1 = 0x0,
54 OPackage::Command command2 = OPackage::NotDefined, QStringList *packages2 = 0x0, 54 OPackage::Command command2 = OPackage::NotDefined, QStringList *packages2 = 0x0,
55 OPackage::Command command3 = OPackage::NotDefined, QStringList *packages3 = 0x0 ); 55 OPackage::Command command3 = OPackage::NotDefined, QStringList *packages3 = 0x0 );
56 ~InstallDlg(); 56 ~InstallDlg();
57 57
58private: 58private:
59 OPackageManager *m_packman; // Pointer to application instance of package manager 59 OPackageManager *m_packman; // Pointer to application instance of package manager
60 60
61 // UI controls 61 // UI controls
62 QComboBox *m_destination; // Destination selection list 62 QComboBox *m_destination; // Destination selection list
63 QLabel *m_availSpace; // Text label to display available space on selected destination 63 QLabel *m_availSpace; // Text label to display available space on selected destination
64 QMultiLineEdit *m_output; // Multi-line edit to display status 64 QMultiLineEdit *m_output; // Multi-line edit to display status
65 QPushButton *m_btnStart; // Start/abort/close button 65 QPushButton *m_btnStart; // Start/abort/close button
66 QPushButton *m_btnOptions; // Installation options button 66 QPushButton *m_btnOptions; // Installation options button
67 67
68 // Commands and packages to execute 68 // Commands and packages to execute
69 int m_numCommands; // Number of commands to be executed 69 int m_numCommands; // Number of commands to be executed
70 int m_currCommand; // Number of currently executing command 70 int m_currCommand; // Number of currently executing command
71 OPackage::Command m_command[3]; // List of commands to be executed 71 OPackage::Command m_command[3]; // List of commands to be executed
72 QStringList *m_packages[3]; // Lists of package names associated to commands (m_command[]) 72 QStringList *m_packages[3]; // Lists of package names associated to commands (m_command[])
73 73
74private slots: 74private slots:
75 // UI control slots 75 // UI control slots
76 void slotDisplayAvailSpace( const QString &destination ); 76 void slotDisplayAvailSpace( const QString &destination );
77 void slotBtnStart(); 77 void slotBtnStart();
78 void slotBtnOptions(); 78 void slotBtnOptions();
79 79
80 // Execution slots 80 // Execution slots
81 void slotOutput( OProcess *process, char *buffer, int buffLen ); 81 void slotOutput( char *msg );
82 void slotErrors( OProcess *process, char *buffer, int buffLen );
83 void slotFinished( OProcess *process );
84 82
85signals: 83signals:
86 void closeInstallDlg(); 84 void closeInstallDlg();
87}; 85};
88 86
89#endif 87#endif
diff --git a/noncore/settings/packagemanager/mainwindow.cpp b/noncore/settings/packagemanager/mainwindow.cpp
index 311b5fc..4611404 100644
--- a/noncore/settings/packagemanager/mainwindow.cpp
+++ b/noncore/settings/packagemanager/mainwindow.cpp
@@ -101,138 +101,137 @@ void MainWindow::closeEvent( QCloseEvent *event )
101 m_packman.saveSettings(); 101 m_packman.saveSettings();
102 event->accept(); 102 event->accept();
103 } 103 }
104 else 104 else
105 { 105 {
106 delete m_widgetStack.visibleWidget(); 106 delete m_widgetStack.visibleWidget();
107 m_widgetStack.raiseWidget( &m_packageList ); 107 m_widgetStack.raiseWidget( &m_packageList );
108 event->ignore(); 108 event->ignore();
109 } 109 }
110} 110}
111 111
112void MainWindow::initPackageList() 112void MainWindow::initPackageList()
113{ 113{
114 m_packageList.addColumn( tr( "Packages" ) ); 114 m_packageList.addColumn( tr( "Packages" ) );
115 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." ) ); 115 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." ) );
116 QPEApplication::setStylusOperation( m_packageList.viewport(), QPEApplication::RightOnHold ); 116 QPEApplication::setStylusOperation( m_packageList.viewport(), QPEApplication::RightOnHold );
117} 117}
118 118
119void MainWindow::initStatusWidget() 119void MainWindow::initStatusWidget()
120{ 120{
121 QVBoxLayout *layout = new QVBoxLayout( &m_statusWidget, 4, 4 ); 121 QVBoxLayout *layout = new QVBoxLayout( &m_statusWidget, 4, 4 );
122 122
123 m_statusText.setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); 123 m_statusText.setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
124 layout->addWidget( &m_statusText ); 124 layout->addWidget( &m_statusText );
125 125
126 connect( &m_packman, SIGNAL(initStatus(int)), this, SLOT(slotInitStatusBar(int)) ); 126 connect( &m_packman, SIGNAL(initStatus(int)), this, SLOT(slotInitStatusBar(int)) );
127 connect( &m_packman, SIGNAL(statusText(const QString &)), this, SLOT(slotStatusText(const QString &)) ); 127 connect( &m_packman, SIGNAL(statusText(const QString &)), this, SLOT(slotStatusText(const QString &)) );
128 connect( &m_packman, SIGNAL(statusBar(int)), this, SLOT(slotStatusBar(int)) ); 128 connect( &m_packman, SIGNAL(statusBar(int)), this, SLOT(slotStatusBar(int)) );
129 129
130 layout->addWidget( &m_statusBar ); 130 layout->addWidget( &m_statusBar );
131} 131}
132 132
133void MainWindow::initUI() 133void MainWindow::initUI()
134{ 134{
135 // Build menu and tool bars 135 // Build menu and tool bars
136 setToolBarsMovable( false ); 136 setToolBarsMovable( false );
137 137
138 m_menuBar.setHorizontalStretchable( true ); 138 m_menuBar.setHorizontalStretchable( true );
139 QMenuBar *mb = new QMenuBar( &m_menuBar ); 139 QMenuBar *mb = new QMenuBar( &m_menuBar );
140 mb->setMargin( 0 ); 140 mb->setMargin( 0 );
141 141
142 // Find toolbar 142 // Find toolbar
143 addToolBar( &m_findBar, QMainWindow::Top, true ); 143 addToolBar( &m_findBar, QMainWindow::Top, true );
144 m_findBar.setHorizontalStretchable( true ); 144 m_findBar.setHorizontalStretchable( true );
145 m_findEdit = new QLineEdit( &m_findBar ); 145 m_findEdit = new QLineEdit( &m_findBar );
146 QWhatsThis::add( m_findEdit, tr( "Type the text to search for here." ) ); 146 QWhatsThis::add( m_findEdit, tr( "Type the text to search for here." ) );
147 m_findBar.setStretchableWidget( m_findEdit ); 147 m_findBar.setStretchableWidget( m_findEdit );
148 connect( m_findEdit, SIGNAL(textChanged(const QString &)), this, SLOT(slotFindChanged(const QString &)) ); 148 connect( m_findEdit, SIGNAL(textChanged(const QString &)), this, SLOT(slotFindChanged(const QString &)) );
149 149
150 // Packages menu 150 // Packages menu
151 QPopupMenu *popup = new QPopupMenu( this ); 151 QPopupMenu *popup = new QPopupMenu( this );
152 152
153 QAction *a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "packagemanager/update" ), QString::null, 0, this, 0 ); 153 QAction *a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "packagemanager/update" ), QString::null, 0, this, 0 );
154 a->setWhatsThis( tr( "Click here to update package lists from servers." ) ); 154 a->setWhatsThis( tr( "Click here to update package lists from servers." ) );
155 connect( a, SIGNAL(activated()), this, SLOT(slotUpdate()) ); 155 connect( a, SIGNAL(activated()), this, SLOT(slotUpdate()) );
156 a->addTo( popup ); 156 a->addTo( popup );
157 a->addTo( &m_toolBar ); 157 a->addTo( &m_toolBar );
158 158
159 QAction *actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "packagemanager/upgrade" ), QString::null, 0, this, 0 ); 159 QAction *actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "packagemanager/upgrade" ), QString::null, 0, this, 0 );
160 actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) ); 160 actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) );
161 connect( actionUpgrade, SIGNAL(activated()), this, SLOT(slotUpgrade()) ); 161 connect( actionUpgrade, SIGNAL(activated()), this, SLOT(slotUpgrade()) );
162 actionUpgrade->addTo( popup ); 162 actionUpgrade->addTo( popup );
163 actionUpgrade->addTo( &m_toolBar ); 163 actionUpgrade->addTo( &m_toolBar );
164 164
165 // Ipkg implementation does not seem to work currently? (not working in aqpkg either) 165/*
166 /*
167 QPixmap iconDownload = Resource::loadPixmap( "packagemanager/download" ); 166 QPixmap iconDownload = Resource::loadPixmap( "packagemanager/download" );
168 QPixmap iconRemove = Resource::loadPixmap( "packagemanager/remove" ); 167 QPixmap iconRemove = Resource::loadPixmap( "packagemanager/remove" );
169 QAction *actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); 168 QAction *actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 );
170 actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) ); 169 actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) );
171 connect( actionDownload, SIGNAL(activated()), this, SLOT(slotDownload()) ); 170 connect( actionDownload, SIGNAL(activated()), this, SLOT(slotDownload()) );
172 actionDownload->addTo( popup ); 171 actionDownload->addTo( popup );
173 actionDownload->addTo( &m_toolBar ); 172 actionDownload->addTo( &m_toolBar );
174 */ 173*/
175 174
176 a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "packagemanager/apply" ), QString::null, 0, this, 0 ); 175 a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "packagemanager/apply" ), QString::null, 0, this, 0 );
177 a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) ); 176 a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) );
178 connect( a, SIGNAL(activated()), this, SLOT(slotApply()) ); 177 connect( a, SIGNAL(activated()), this, SLOT(slotApply()) );
179 a->addTo( popup ); 178 a->addTo( popup );
180 a->addTo( &m_toolBar ); 179 a->addTo( &m_toolBar );
181 180
182 popup->insertSeparator(); 181 popup->insertSeparator();
183 182
184 a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); 183 a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 );
185 a->setWhatsThis( tr( "Click here to configure this application." ) ); 184 a->setWhatsThis( tr( "Click here to configure this application." ) );
186 connect( a, SIGNAL(activated()), this, SLOT(slotConfigure()) ); 185 connect( a, SIGNAL(activated()), this, SLOT(slotConfigure()) );
187 a->addTo( popup ); 186 a->addTo( popup );
188 mb->insertItem( tr( "Actions" ), popup ); 187 mb->insertItem( tr( "Actions" ), popup );
189 188
190 // View menu 189 // View menu
191 popup = new QPopupMenu( this ); 190 popup = new QPopupMenu( this );
192 191
193 m_actionShowNotInstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); 192 m_actionShowNotInstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 );
194 m_actionShowNotInstalled->setToggleAction( true ); 193 m_actionShowNotInstalled->setToggleAction( true );
195 m_actionShowNotInstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) ); 194 m_actionShowNotInstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) );
196 connect( m_actionShowNotInstalled, SIGNAL(activated()), this, SLOT(slotShowNotInstalled()) ); 195 connect( m_actionShowNotInstalled, SIGNAL(activated()), this, SLOT(slotShowNotInstalled()) );
197 m_actionShowNotInstalled->addTo( popup ); 196 m_actionShowNotInstalled->addTo( popup );
198 197
199 m_actionShowInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); 198 m_actionShowInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 );
200 m_actionShowInstalled->setToggleAction( true ); 199 m_actionShowInstalled->setToggleAction( true );
201 m_actionShowInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) ); 200 m_actionShowInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) );
202 connect( m_actionShowInstalled, SIGNAL(activated()), this, SLOT(slotShowInstalled()) ); 201 connect( m_actionShowInstalled, SIGNAL(activated()), this, SLOT(slotShowInstalled()) );
203 m_actionShowInstalled->addTo( popup ); 202 m_actionShowInstalled->addTo( popup );
204 203
205 m_actionShowUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); 204 m_actionShowUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 );
206 m_actionShowUpdated->setToggleAction( true ); 205 m_actionShowUpdated->setToggleAction( true );
207 m_actionShowUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) ); 206 m_actionShowUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) );
208 connect( m_actionShowUpdated, SIGNAL(activated()), this, SLOT(slotShowUpdated()) ); 207 connect( m_actionShowUpdated, SIGNAL(activated()), this, SLOT(slotShowUpdated()) );
209 m_actionShowUpdated->addTo( popup ); 208 m_actionShowUpdated->addTo( popup );
210 209
211 popup->insertSeparator(); 210 popup->insertSeparator();
212 211
213 a = new QAction( tr( "Configure filter" ), QString::null, 0, this, 0 ); 212 a = new QAction( tr( "Configure filter" ), QString::null, 0, this, 0 );
214 a->setWhatsThis( tr( "Click here to change package filter criteria." ) ); 213 a->setWhatsThis( tr( "Click here to change package filter criteria." ) );
215 connect( a, SIGNAL(activated()), this, SLOT(slotFilterChange()) ); 214 connect( a, SIGNAL(activated()), this, SLOT(slotFilterChange()) );
216 a->addTo( popup ); 215 a->addTo( popup );
217 216
218 m_actionFilter = new QAction( tr( "Filter" ), Resource::loadPixmap( "packagemanager/filter" ), 217 m_actionFilter = new QAction( tr( "Filter" ), Resource::loadPixmap( "packagemanager/filter" ),
219 QString::null, 0, this, 0 ); 218 QString::null, 0, this, 0 );
220 m_actionFilter->setToggleAction( true ); 219 m_actionFilter->setToggleAction( true );
221 m_actionFilter->setWhatsThis( tr( "Click here to apply current filter." ) ); 220 m_actionFilter->setWhatsThis( tr( "Click here to apply current filter." ) );
222 connect( m_actionFilter, SIGNAL(toggled(bool)), this, SLOT(slotFilter(bool)) ); 221 connect( m_actionFilter, SIGNAL(toggled(bool)), this, SLOT(slotFilter(bool)) );
223 m_actionFilter->addTo( popup ); 222 m_actionFilter->addTo( popup );
224 223
225 popup->insertSeparator(); 224 popup->insertSeparator();
226 225
227 a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); 226 a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 );
228 a->setWhatsThis( tr( "Click here to search for text in package names." ) ); 227 a->setWhatsThis( tr( "Click here to search for text in package names." ) );
229 connect( a, SIGNAL(activated()), this, SLOT(slotFindShowToolbar()) ); 228 connect( a, SIGNAL(activated()), this, SLOT(slotFindShowToolbar()) );
230 a->addTo( popup ); 229 a->addTo( popup );
231 230
232 m_actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); 231 m_actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 );
233 m_actionFindNext->setEnabled( false ); 232 m_actionFindNext->setEnabled( false );
234 m_actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) ); 233 m_actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) );
235 connect( m_actionFindNext, SIGNAL(activated()), this, SLOT(slotFindNext()) ); 234 connect( m_actionFindNext, SIGNAL(activated()), this, SLOT(slotFindNext()) );
236 m_actionFindNext->addTo( popup ); 235 m_actionFindNext->addTo( popup );
237 m_actionFindNext->addTo( &m_findBar ); 236 m_actionFindNext->addTo( &m_findBar );
238 237
@@ -310,129 +309,128 @@ void MainWindow::initPackageInfo()
310 if ( packageList ) 309 if ( packageList )
311 { 310 {
312 loadPackageList( packageList, true ); 311 loadPackageList( packageList, true );
313 delete packageList; 312 delete packageList;
314 } 313 }
315 314
316 m_widgetStack.raiseWidget( &m_packageList ); 315 m_widgetStack.raiseWidget( &m_packageList );
317} 316}
318 317
319void MainWindow::slotWidgetStackShow( QWidget *widget ) 318void MainWindow::slotWidgetStackShow( QWidget *widget )
320{ 319{
321 if ( widget == &m_packageList ) 320 if ( widget == &m_packageList )
322 { 321 {
323 setCaption( tr( "Package Manager" ) ); 322 setCaption( tr( "Package Manager" ) );
324 323
325 m_menuBar.show(); 324 m_menuBar.show();
326 m_toolBar.show(); 325 m_toolBar.show();
327 } 326 }
328 else 327 else
329 { 328 {
330 m_menuBar.hide(); 329 m_menuBar.hide();
331 m_toolBar.hide(); 330 m_toolBar.hide();
332 } 331 }
333} 332}
334 333
335void MainWindow::slotInitStatusBar( int numSteps ) 334void MainWindow::slotInitStatusBar( int numSteps )
336{ 335{
337 m_statusBar.setTotalSteps( numSteps ); 336 m_statusBar.setTotalSteps( numSteps );
338} 337}
339 338
340void MainWindow::slotStatusText( const QString &status ) 339void MainWindow::slotStatusText( const QString &status )
341{ 340{
342 m_statusText.setText( status ); 341 m_statusText.setText( status );
343} 342}
344 343
345void MainWindow::slotStatusBar( int currStep ) 344void MainWindow::slotStatusBar( int currStep )
346{ 345{
347 m_statusBar.setProgress( currStep ); 346 m_statusBar.setProgress( currStep );
348} 347}
349 348
350void MainWindow::slotUpdate() 349void MainWindow::slotUpdate()
351{ 350{
352 // Create package manager output widget 351 // Create package manager output widget
353 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Update package information" ), false, 352 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Update package information" ), false,
354 OPackage::Update ); 353 OPackage::Update );
355 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseInstallDlg()) ); 354 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseInstallDlg()) );
356 355
357 // Display widget 356 // Display widget
358 m_widgetStack.addWidget( dlg, 3 ); 357 m_widgetStack.addWidget( dlg, 3 );
359 m_widgetStack.raiseWidget( dlg ); 358 m_widgetStack.raiseWidget( dlg );
360} 359}
361 360
362void MainWindow::slotUpgrade() 361void MainWindow::slotUpgrade()
363{ 362{
364 // Create package manager output widget 363 // Create package manager output widget
365 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Upgrade installed packages" ), false, 364 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Upgrade installed packages" ), false,
366 OPackage::Upgrade ); 365 OPackage::Upgrade );
367 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseInstallDlg()) ); 366 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseInstallDlg()) );
368 367
369 // Display widget 368 // Display widget
370 m_widgetStack.addWidget( dlg, 3 ); 369 m_widgetStack.addWidget( dlg, 3 );
371 m_widgetStack.raiseWidget( dlg ); 370 m_widgetStack.raiseWidget( dlg );
372} 371}
373 372
374 // Ipkg implementation does not seem to work currently? (not working in aqpkg either)
375/* 373/*
376void MainWindow::slotDownload() 374void MainWindow::slotDownload()
377{ 375{
378 // Retrieve list of packages selected for download (if any) 376 // Retrieve list of packages selected for download (if any)
379 QStringList *workingPackages = new QStringList(); 377 QStringList *workingPackages = new QStringList();
380 378
381 for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild()); 379 for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild());
382 item != 0 ; 380 item != 0 ;
383 item = static_cast<QCheckListItem *>(item->nextSibling()) ) 381 item = static_cast<QCheckListItem *>(item->nextSibling()) )
384 { 382 {
385 if ( item->isOn() ) 383 if ( item->isOn() )
386 workingPackages->append( item->text() ); 384 workingPackages->append( item->text() );
387 } 385 }
388 386
389 if ( workingPackages->isEmpty() ) 387 if ( workingPackages->isEmpty() )
390 { 388 {
391 // No packages were selected, prompt for URL of package to download 389 // No packages were selected, prompt for URL of package to download
392 } 390 }
393 else 391 else
394 { 392 {
395 // Download selected packages 393 // Download selected packages
396 m_config.setGroup( "settings" ); 394 m_config.setGroup( "settings" );
397 QString workingDir = m_config.readEntry( "DownloadDir", "/tmp" ); 395 QString workingDir = m_config.readEntry( "DownloadDir", "/tmp" );
398 396
399// QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), workingDir, &ok, this ); 397// QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), workingDir, &ok, this );
400// if ( ok && !text.isEmpty() ) 398// if ( ok && !text.isEmpty() )
401// workingDir = text; // user entered something and pressed ok 399// workingDir = text; // user entered something and pressed ok
402// else 400// else
403// return; // user entered nothing or pressed cancel 401// return; // user entered nothing or pressed cancel
404 402
405// // Store download directory in config file 403// // Store download directory in config file
406// m_config.writeEntry( "DownloadDir", workingDir ); 404// m_config.writeEntry( "DownloadDir", workingDir );
407 405
408 // Get starting directory 406 // Get starting directory
409// char initDir[PATH_MAX]; 407// char initDir[PATH_MAX];
410// getcwd( initDir, PATH_MAX ); 408// getcwd( initDir, PATH_MAX );
411 409
412 // Download packages 410 // Download packages
413 411
414 } 412 }
415 413
416 // Create package manager output widget 414 // Create package manager output widget
417 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Download packages" ), false, 415 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Download packages" ), false,
418 OPackage::Download, workingPackages ); 416 OPackage::Download, workingPackages );
419 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseInstallDlg()) ); 417 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseInstallDlg()) );
420 418
421 // Display widget 419 // Display widget
422 m_widgetStack.addWidget( dlg, 3 ); 420 m_widgetStack.addWidget( dlg, 3 );
423 m_widgetStack.raiseWidget( dlg ); 421 m_widgetStack.raiseWidget( dlg );
424} 422}
425*/ 423*/
426 424
427void MainWindow::slotApply() 425void MainWindow::slotApply()
428{ 426{
429 QStringList *removeList = 0x0; 427 QStringList *removeList = 0x0;
430 QStringList *installList = 0x0; 428 QStringList *installList = 0x0;
431 QStringList *upgradeList = 0x0; 429 QStringList *upgradeList = 0x0;
432 430
433 for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild()); 431 for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild());
434 item != 0 ; 432 item != 0 ;
435 item = static_cast<QCheckListItem *>(item->nextSibling()) ) 433 item = static_cast<QCheckListItem *>(item->nextSibling()) )
436 { 434 {
437 if ( item->isOn() ) 435 if ( item->isOn() )
438 { 436 {
diff --git a/noncore/settings/packagemanager/oipkg.cpp b/noncore/settings/packagemanager/oipkg.cpp
index 13f3d7d..eeb0131 100644
--- a/noncore/settings/packagemanager/oipkg.cpp
+++ b/noncore/settings/packagemanager/oipkg.cpp
@@ -1,131 +1,150 @@
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 <string.h>
35 36
36#include <qdir.h> 37#include <qdir.h>
37#include <qfile.h> 38#include <qfile.h>
39#include <qmessagebox.h>
38#include <qtextstream.h> 40#include <qtextstream.h>
39 41
40#include <opie/oprocess.h>
41
42const QString IPKG_EXEC = "ipkg"; // Fully-qualified name of Ipkg executable
43const QString IPKG_CONF = "/etc/ipkg.conf"; // Fully-qualified name of Ipkg primary configuration file 42const QString IPKG_CONF = "/etc/ipkg.conf"; // Fully-qualified name of Ipkg primary configuration file
44const QString IPKG_CONF_DIR = "/etc/ipkg"; // Directory of secondary Ipkg configuration files 43const QString IPKG_CONF_DIR = "/etc/ipkg"; // Directory of secondary Ipkg configuration files
45const QString IPKG_PKG_PATH = "/usr/lib/ipkg/lists"; // Directory containing server package lists 44const QString IPKG_PKG_PATH = "/usr/lib/ipkg/lists"; // Directory containing server package lists
46const QString IPKG_STATUS_PATH = "usr/lib/ipkg/status"; // Destination status file location 45const QString IPKG_STATUS_PATH = "usr/lib/ipkg/status"; // Destination status file location
47 46
47OIpkg *oipkg;
48
49int fIpkgMessage( ipkg_conf_t */*conf*/, message_level_t /*level*/, char *msg )
50{
51 oipkg->ipkgOutput( msg );
52 return 0;
53}
54
55char* fIpkgResponse( char */*question*/ )
56{
57 return 0x0;
58}
59
48OIpkg::OIpkg( Config *config, QObject *parent, const char *name ) 60OIpkg::OIpkg( Config *config, QObject *parent, const char *name )
49 : QObject( parent, name ) 61 : QObject( parent, name )
50 , m_config( config ) 62 , m_config( config )
51 , m_ipkgExec( IPKG_EXEC ) // TODO - find executable?
52 , m_confInfo( NULL ) 63 , m_confInfo( NULL )
53 , m_ipkgExecOptions( 0 ) 64 , m_ipkgExecOptions( 0 )
54 , m_ipkgExecVerbosity( 1 ) 65 , m_ipkgExecVerbosity( 1 )
55 , m_ipkgProcess( NULL )
56{ 66{
67 oipkg = this;
68
69 // Initialize libipkg
70 if ( ipkg_init( &fIpkgMessage, &fIpkgResponse, &m_ipkgArgs ) )
71 QMessageBox::critical( 0, tr( "OIpkg" ), tr( "Error initialing libipkg" ) );
72
73 // Default ipkg run-time arguments
74 m_ipkgArgs.noaction = false;
75 m_ipkgArgs.force_defaults = true;
57} 76}
58 77
59OIpkg::~OIpkg() 78OIpkg::~OIpkg()
60{ 79{
61 // Upon destruction, ensure that items in config list are deleted with list 80 // Upon destruction, ensure that items in config list are deleted with list
62 if ( m_confInfo ) 81 if ( m_confInfo )
63 m_confInfo->setAutoDelete( true ); 82 m_confInfo->setAutoDelete( true );
64 83
65 // Terminate any running ipkg processes 84 // Free up libipkg resources
66 if ( m_ipkgProcess ) 85 if ( ipkg_deinit( &m_ipkgArgs ) )
67 delete m_ipkgProcess; 86 QMessageBox::critical( 0, tr( "OIpkg" ), tr( "Error freeing libipkg" ) );
68} 87}
69 88
70OConfItemList *OIpkg::configItems() 89OConfItemList *OIpkg::configItems()
71{ 90{
72 // Retrieve all configuration items 91 // Retrieve all configuration items
73 return filterConfItems(); 92 return filterConfItems();
74} 93}
75 94
76OConfItemList *OIpkg::servers() 95OConfItemList *OIpkg::servers()
77{ 96{
78 // Retrieve only servers 97 // Retrieve only servers
79 return filterConfItems( OConfItem::Source ); 98 return filterConfItems( OConfItem::Source );
80} 99}
81 100
82OConfItemList *OIpkg::destinations() 101OConfItemList *OIpkg::destinations()
83{ 102{
84 // Retrieve only destinations 103 // Retrieve only destinations
85 return filterConfItems( OConfItem::Destination ); 104 return filterConfItems( OConfItem::Destination );
86} 105}
87 106
88OConfItemList *OIpkg::options() 107OConfItemList *OIpkg::options()
89{ 108{
90 // Retrieve only destinations 109 // Retrieve only destinations
91 return filterConfItems( OConfItem::Option ); 110 return filterConfItems( OConfItem::Option );
92} 111}
93 112
94void OIpkg::setConfigItems( OConfItemList *configList ) 113void OIpkg::setConfigItems( OConfItemList *configList )
95{ 114{
96 if ( m_confInfo ) 115 if ( m_confInfo )
97 delete m_confInfo; 116 delete m_confInfo;
98 117
99 m_confInfo = configList; 118 m_confInfo = configList;
100} 119}
101 120
102void OIpkg::saveSettings() 121void OIpkg::saveSettings()
103{ 122{
104 // Save Ipkg execution options to application configuration file 123 // Save Ipkg execution options to application configuration file
105 if ( m_config ) 124 if ( m_config )
106 { 125 {
107 m_config->setGroup( "Ipkg" ); 126 m_config->setGroup( "Ipkg" );
108 m_config->writeEntry( "ExecOptions", m_ipkgExecOptions ); 127 m_config->writeEntry( "ExecOptions", m_ipkgExecOptions );
109 m_config->writeEntry( "Verbosity", m_ipkgExecVerbosity ); 128 m_config->writeEntry( "Verbosity", m_ipkgExecVerbosity );
110 } 129 }
111} 130}
112 131
113OPackageList *OIpkg::availablePackages( const QString &server ) 132OPackageList *OIpkg::availablePackages( const QString &server )
114{ 133{
115 // Load Ipkg configuration info if not already cached 134 // Load Ipkg configuration info if not already cached
116 if ( !m_confInfo ) 135 if ( !m_confInfo )
117 loadConfiguration(); 136 loadConfiguration();
118 137
119 // Build new server list (caller is responsible for deleting) 138 // Build new server list (caller is responsible for deleting)
120 OPackageList *pl = new OPackageList; 139 OPackageList *pl = new OPackageList;
121 140
122 // Open package list file 141 // Open package list file
123 QFile f( IPKG_PKG_PATH + "/" + server ); 142 QFile f( IPKG_PKG_PATH + "/" + server );
124 if ( !f.open( IO_ReadOnly ) ) 143 if ( !f.open( IO_ReadOnly ) )
125 return NULL; 144 return NULL;
126 QTextStream t( &f ); 145 QTextStream t( &f );
127 146
128 // Process all information in package list file 147 // Process all information in package list file
129 OPackage *package = NULL; 148 OPackage *package = NULL;
130 QString line = t.readLine(); 149 QString line = t.readLine();
131 while ( !t.eof() ) 150 while ( !t.eof() )
@@ -193,258 +212,193 @@ OPackageList *OIpkg::installedPackages( const QString &destName, const QString &
193 if ( !f.open( IO_ReadOnly ) ) 212 if ( !f.open( IO_ReadOnly ) )
194 return NULL; 213 return NULL;
195 QTextStream t( &f ); 214 QTextStream t( &f );
196 215
197 // Process all information in status file 216 // Process all information in status file
198 bool newPackage = false; 217 bool newPackage = false;
199 QString line = t.readLine(); 218 QString line = t.readLine();
200 QString name; 219 QString name;
201 QString version; 220 QString version;
202 QString status; 221 QString status;
203 222
204 while ( !t.eof() ) 223 while ( !t.eof() )
205 { 224 {
206 // Determine key/value pair 225 // Determine key/value pair
207 int pos = line.find( ':', 0 ); 226 int pos = line.find( ':', 0 );
208 QString key; 227 QString key;
209 if ( pos > -1 ) 228 if ( pos > -1 )
210 key = line.mid( 0, pos ); 229 key = line.mid( 0, pos );
211 else 230 else
212 key = QString::null; 231 key = QString::null;
213 QString value = line.mid( pos+2, line.length()-pos ); 232 QString value = line.mid( pos+2, line.length()-pos );
214 233
215 // Allocate new package and insert into list 234 // Allocate new package and insert into list
216 if ( newPackage && !key.isEmpty() ) 235 if ( newPackage && !key.isEmpty() )
217 { 236 {
218 // Add to list only if it has a valid name and is installed 237 // Add to list only if it has a valid name and is installed
219 if ( !name.isNull() && status.contains( " installed" ) ) 238 if ( !name.isNull() && status.contains( " installed" ) )
220 { 239 {
221 pl->append( new OPackage( name, QString::null, version, QString::null, destName ) ); 240 pl->append( new OPackage( name, QString::null, version, QString::null, destName ) );
222 name = QString::null; 241 name = QString::null;
223 version = QString::null; 242 version = QString::null;
224 status = QString::null; 243 status = QString::null;
225 244
226 newPackage = false; 245 newPackage = false;
227 } 246 }
228 } 247 }
229 248
230 // Update package data 249 // Update package data
231 if ( key == "Package" ) 250 if ( key == "Package" )
232 name = value; 251 name = value;
233 else if ( key == "Version" ) 252 else if ( key == "Version" )
234 version = value; 253 version = value;
235 else if ( key == "Status" ) 254 else if ( key == "Status" )
236 status = value; 255 status = value;
237 else if ( key.isEmpty() && value.isEmpty() ) 256 else if ( key.isEmpty() && value.isEmpty() )
238 newPackage = true; 257 newPackage = true;
239 258
240 // Skip past all description lines 259 // Skip past all description lines
241 if ( key == "Description" ) 260 if ( key == "Description" )
242 { 261 {
243 line = t.readLine(); 262 line = t.readLine();
244 while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) 263 while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() )
245 line = t.readLine(); 264 line = t.readLine();
246 } 265 }
247 else 266 else
248 line = t.readLine(); 267 line = t.readLine();
249 } 268 }
250 269
251 f.close(); 270 f.close();
252 271
253 return pl; 272 return pl;
254} 273}
255 274
256bool OIpkg::executeCommand( OPackage::Command command, QStringList *parameters, const QString &destination, 275bool OIpkg::executeCommand( OPackage::Command command, QStringList *parameters, const QString &destination,
257 const QObject *receiver, const char *slotOutput, const char *slotErrors, 276 const QObject *receiver, const char *slotOutput, bool rawOutput )
258 const char *slotFinished, bool rawOutput )
259{ 277{
260 if ( command == OPackage::NotDefined ) 278 if ( command == OPackage::NotDefined )
261 return false; 279 return false;
262 280
263 // Set up command line for execution 281 // Set ipkg run-time options/arguments
264 QStringList cmdLine; 282 m_ipkgArgs.force_depends = ( m_ipkgExecOptions & FORCE_DEPENDS );
265 cmdLine.append( IPKG_EXEC ); 283 m_ipkgArgs.force_reinstall = ( m_ipkgExecOptions & FORCE_REINSTALL );
266 284 // TODO m_ipkgArgs.force_remove = ( m_ipkgExecOptions & FORCE_REMOVE );
267 QString verbosity( "-V" ); 285 m_ipkgArgs.force_overwrite = ( m_ipkgExecOptions & FORCE_OVERWRITE );
268 verbosity.append( QString::number( m_ipkgExecVerbosity ) ); 286 m_ipkgArgs.verbosity = m_ipkgExecVerbosity;
269 cmdLine.append( verbosity ); 287 if ( m_ipkgArgs.dest )
270 288 free( m_ipkgArgs.dest );
271 // Determine Ipkg execution options 289 if ( !destination.isNull() )
272 if ( command == OPackage::Install && destination != QString::null )
273 { 290 {
274 // TODO - Set destination for installs 291 int len = destination.length() + 1;
275 cmdLine.append( "-dest" ); 292 m_ipkgArgs.dest = (char *)malloc( len );
276 cmdLine.append( destination ); 293 strncpy( m_ipkgArgs.dest, destination, destination.length() );
294 m_ipkgArgs.dest[ len - 1 ] = '\0';
277 } 295 }
296 else
297 m_ipkgArgs.dest = 0x0;
278 298
279 if ( command != OPackage::Update && command != OPackage::Download ) 299 // Connect output signal to widget
300 if ( rawOutput )
280 { 301 {
281 if ( m_ipkgExecOptions & FORCE_DEPENDS ) 302 if ( slotOutput )
282 cmdLine.append( "-force-depends" ); 303 connect( this, SIGNAL(execOutput(char *)), receiver, slotOutput );
283 if ( m_ipkgExecOptions & FORCE_REINSTALL ) 304 }
284 cmdLine.append( "-force-reinstall" ); 305 else
285 if ( m_ipkgExecOptions & FORCE_REMOVE ) 306 {
286 cmdLine.append( "-force-removal-of-essential-packages" ); 307 // TODO - connect to local slot and parse output before emitting execOutput
287 if ( m_ipkgExecOptions & FORCE_OVERWRITE )
288 cmdLine.append( "-force-overwrite" );
289 if ( m_ipkgExecVerbosity == 3 )
290 cmdLine.append( "-verbose_wget" );
291
292 // TODO
293 // Handle make links
294 // Rules - If make links is switched on, create links to root
295 // if destDir is NOT /
296 /*
297 if ( m_ipkgExecOptions & MAKE_LINKS )
298 {
299 // If destDir == / turn off make links as package is being insalled
300 // to root already.
301 if ( destDir == "/" )
302 m_ipkgExecOptions ^= MAKE_LINKS;
303 }
304 */
305 } 308 }
306 309
307 QString cmd;
308 switch( command ) 310 switch( command )
309 { 311 {
310 case OPackage::Install: cmd = "install"; 312 case OPackage::Update : ipkg_lists_update( &m_ipkgArgs );
311 break;
312 case OPackage::Remove: cmd = "remove";
313 break; 313 break;
314 case OPackage::Update: cmd = "update"; 314 case OPackage::Upgrade : ipkg_packages_upgrade( &m_ipkgArgs );
315 break; 315 break;
316 case OPackage::Upgrade: cmd = "upgrade"; 316 case OPackage::Install : {
317 break; 317 for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it )
318 case OPackage::Download: cmd = "download"; 318 {
319 break; 319 ipkg_packages_install( &m_ipkgArgs, (*it) );
320 case OPackage::Info: cmd = "info"; 320 }
321 };
321 break; 322 break;
322 case OPackage::Files: cmd = "files"; 323 case OPackage::Remove : {
324 for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it )
325 {
326 ipkg_packages_remove( &m_ipkgArgs, (*it), true );
327 }
328 };
323 break; 329 break;
324 //case OPackage::Version: cmd = "" ); 330 //case OPackage::Download : ;
325 // break; 331 // break;
326 default: 332 default : break;
327 break;
328 }; 333 };
329 cmdLine.append( cmd );
330
331 // TODO
332 // If we are removing, reinstalling or upgrading packages and make links option is selected
333 // create the links
334/*
335 if ( command == Remove || command == Upgrade )
336 {
337 createLinks = false;
338 if ( flags & MAKE_LINKS )
339 {
340 emit outputText( tr( "Removing symbolic links...\n" ) );
341 linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir );
342 emit outputText( QString( " " ) );
343 }
344 }
345*/
346 // Append package list (if any) to end of command line
347 if ( parameters && !parameters->isEmpty() )
348 {
349 for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it )
350 {
351 cmdLine.append( *it );
352 }
353 }
354
355 // Create OProcess
356 if ( m_ipkgProcess )
357 delete m_ipkgProcess;
358 m_ipkgProcess = new OProcess( cmdLine, this );
359
360 // Connect signals (if any)
361 if ( receiver )
362 {
363 if ( rawOutput )
364 {
365 if ( slotOutput )
366 connect( m_ipkgProcess, SIGNAL(receivedStdout(OProcess*,char*,int)), receiver, slotOutput );
367 if ( slotErrors )
368 connect( m_ipkgProcess, SIGNAL(receivedStderr(OProcess*,char*,int)), receiver, slotErrors );
369 if ( slotFinished )
370 connect( m_ipkgProcess, SIGNAL(processExited(OProcess*)), receiver, slotFinished );
371 }
372 else // !rawOutput
373 {
374 // TODO - how should it handle partial lines? (i.e. "Installing opi", "e-aqpkg...")
375 }
376 }
377 334
378 // Run process 335 return true;
379printf( "Running: \'%s\'\n", cmdLine.join( " " ).latin1() );
380 return m_ipkgProcess->start( OProcess::NotifyOnExit, OProcess::All );
381} 336}
382 337
383void OIpkg::abortCommand() 338void OIpkg::ipkgOutput( char *msg )
384{ 339{
385 if ( m_ipkgProcess ) 340 emit execOutput( msg );
386 delete m_ipkgProcess;
387} 341}
388 342
389void OIpkg::loadConfiguration() 343void OIpkg::loadConfiguration()
390{ 344{
391 if ( m_confInfo ) 345 if ( m_confInfo )
392 delete m_confInfo; 346 delete m_confInfo;
393 347
394 // Load configuration item list 348 // Load configuration item list
395 m_confInfo = new OConfItemList(); 349 m_confInfo = new OConfItemList();
396 350
397 QStringList confFiles; 351 QStringList confFiles;
398 QDir confDir( IPKG_CONF_DIR ); 352 QDir confDir( IPKG_CONF_DIR );
399 if ( confDir.exists() ) 353 if ( confDir.exists() )
400 { 354 {
401 confDir.setNameFilter( "*.conf" ); 355 confDir.setNameFilter( "*.conf" );
402 confDir.setFilter( QDir::Files ); 356 confDir.setFilter( QDir::Files );
403 confFiles = confDir.entryList( "*.conf", QDir::Files ); 357 confFiles = confDir.entryList( "*.conf", QDir::Files );
404 confFiles << IPKG_CONF; 358 confFiles << IPKG_CONF;
405 359
406 for ( QStringList::Iterator it = confFiles.begin(); it != confFiles.end(); ++it ) 360 for ( QStringList::Iterator it = confFiles.begin(); it != confFiles.end(); ++it )
407 { 361 {
408 // Create absolute file path if necessary 362 // Create absolute file path if necessary
409 QString absFile = (*it); 363 QString absFile = (*it);
410 if ( !absFile.startsWith( "/" ) ) 364 if ( !absFile.startsWith( "/" ) )
411 absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); 365 absFile.prepend( QString( IPKG_CONF_DIR ) + "/" );
412 366
413 // Read in file 367 // Read in file
414 QFile f( absFile ); 368 QFile f( absFile );
415 if ( f.open( IO_ReadOnly ) ) 369 if ( f.open( IO_ReadOnly ) )
416 { 370 {
417 QTextStream s( &f ); 371 QTextStream s( &f );
418 while ( !s.eof() ) 372 while ( !s.eof() )
419 { 373 {
420 374
421 QString line = s.readLine().simplifyWhiteSpace(); 375 QString line = s.readLine().simplifyWhiteSpace();
422 376
423 // Parse line and save info to the conf options list 377 // Parse line and save info to the conf options list
424 if ( !line.isEmpty() ) 378 if ( !line.isEmpty() )
425 { 379 {
426 if ( !line.startsWith( "#" ) || 380 if ( !line.startsWith( "#" ) ||
427 line.startsWith( "#src" ) || 381 line.startsWith( "#src" ) ||
428 line.startsWith( "#dest" ) || 382 line.startsWith( "#dest" ) ||
429 line.startsWith( "#arch" ) || 383 line.startsWith( "#arch" ) ||
430 line.startsWith( "#option" ) ) 384 line.startsWith( "#option" ) )
431 { 385 {
432 int pos = line.find( ' ', 1 ); 386 int pos = line.find( ' ', 1 );
433 387
434 // Type 388 // Type
435 QString typeStr = line.left( pos ); 389 QString typeStr = line.left( pos );
436 OConfItem::Type type; 390 OConfItem::Type type;
437 if ( typeStr == "src" || typeStr == "#src" ) 391 if ( typeStr == "src" || typeStr == "#src" )
438 type = OConfItem::Source; 392 type = OConfItem::Source;
439 else if ( typeStr == "dest" || typeStr == "#dest" ) 393 else if ( typeStr == "dest" || typeStr == "#dest" )
440 type = OConfItem::Destination; 394 type = OConfItem::Destination;
441 else if ( typeStr == "option" || typeStr == "#option" ) 395 else if ( typeStr == "option" || typeStr == "#option" )
442 type = OConfItem::Option; 396 type = OConfItem::Option;
443 else if ( typeStr == "arch" || typeStr == "#arch" ) 397 else if ( typeStr == "arch" || typeStr == "#arch" )
444 type = OConfItem::Arch; 398 type = OConfItem::Arch;
445 else 399 else
446 type = OConfItem::NotDefined; 400 type = OConfItem::NotDefined;
447 ++pos; 401 ++pos;
448 int endpos = line.find( ' ', pos ); 402 int endpos = line.find( ' ', pos );
449 403
450 // Name 404 // Name
diff --git a/noncore/settings/packagemanager/oipkg.h b/noncore/settings/packagemanager/oipkg.h
index 4065f48..824fa17 100644
--- a/noncore/settings/packagemanager/oipkg.h
+++ b/noncore/settings/packagemanager/oipkg.h
@@ -1,100 +1,101 @@
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" {
36#include <libipkg.h>
37};
38
35#include <qobject.h> 39#include <qobject.h>
36 40
37#include <qpe/config.h> 41#include <qpe/config.h>
38 42
39#include "oconfitem.h" 43#include "oconfitem.h"
40#include "opackage.h" 44#include "opackage.h"
41 45
42// Ipkg execution options (m_ipkgExecOptions) 46// Ipkg execution options (m_ipkgExecOptions)
43#define FORCE_DEPENDS 0x0001 47#define FORCE_DEPENDS 0x0001
44#define FORCE_REMOVE 0x0002 48#define FORCE_REMOVE 0x0002
45#define FORCE_REINSTALL 0x0004 49#define FORCE_REINSTALL 0x0004
46#define FORCE_OVERWRITE 0x0008 50#define FORCE_OVERWRITE 0x0008
47 51
48class OConfItemList; 52class OConfItemList;
49class OProcess;
50 53
51class OIpkg : public QObject 54class OIpkg : public QObject
52{ 55{
53 Q_OBJECT 56 Q_OBJECT
54 57
55public: 58public:
56 OIpkg( Config *config = 0x0, QObject *parent = 0x0, const char *name = 0x0 ); 59 OIpkg( Config *config = 0x0, QObject *parent = 0x0, const char *name = 0x0 );
57 ~OIpkg(); 60 ~OIpkg();
58 61
59 OConfItemList *configItems(); 62 OConfItemList *configItems();
60 OConfItemList *servers(); 63 OConfItemList *servers();
61 OConfItemList *destinations(); 64 OConfItemList *destinations();
62 OConfItemList *options(); 65 OConfItemList *options();
63 66
64 int ipkgExecOptions() { return m_ipkgExecOptions; } 67 int ipkgExecOptions() { return m_ipkgExecOptions; }
65 int ipkgExecVerbosity() { return m_ipkgExecVerbosity; } 68 int ipkgExecVerbosity() { return m_ipkgExecVerbosity; }
66 69
67 void setConfigItems( OConfItemList *configList ); 70 void setConfigItems( OConfItemList *configList );
68 void setIpkgExecOptions( int options ) { m_ipkgExecOptions = options; } 71 void setIpkgExecOptions( int options ) { m_ipkgExecOptions = options; }
69 void setIpkgExecVerbosity( int verbosity ) { m_ipkgExecVerbosity = verbosity; } 72 void setIpkgExecVerbosity( int verbosity ) { m_ipkgExecVerbosity = verbosity; }
70 73
71 void saveSettings(); 74 void saveSettings();
72 75
73 OPackageList *availablePackages( const QString &server = QString::null ); 76 OPackageList *availablePackages( const QString &server = QString::null );
74 OPackageList *installedPackages( const QString &destName = QString::null, 77 OPackageList *installedPackages( const QString &destName = QString::null,
75 const QString &destPath = QString::null ); 78 const QString &destPath = QString::null );
76 79
77 bool executeCommand( OPackage::Command command = OPackage::NotDefined, QStringList *parameters = 0x0, 80 bool executeCommand( OPackage::Command command = OPackage::NotDefined, QStringList *parameters = 0x0,
78 const QString &destination = QString::null, const QObject *receiver = 0x0, 81 const QString &destination = QString::null, const QObject *receiver = 0x0,
79 const char *slotOutput = 0x0, const char *slotErrors = 0x0, 82 const char *slotOutput = 0x0, bool rawOutput = true );
80 const char *slotFinished = 0x0, bool rawOutput = true );
81 void abortCommand(); 83 void abortCommand();
82 84
85 void ipkgOutput( char *msg );
86
83private: 87private:
84 Config *m_config; // Pointer to application configuration file 88 Config *m_config; // Pointer to application configuration file
85 QString m_ipkgExec; // Fully qualified path/filename of ipkg binary 89 args_t m_ipkgArgs; // libipkg configuration arguments
86 OConfItemList *m_confInfo; // Contains info from all Ipkg configuration files 90 OConfItemList *m_confInfo; // Contains info from all Ipkg configuration files
87 int m_ipkgExecOptions; // Bit-mapped flags for Ipkg execution options 91 int m_ipkgExecOptions; // Bit-mapped flags for Ipkg execution options
88 int m_ipkgExecVerbosity; // Ipkg execution verbosity level 92 int m_ipkgExecVerbosity; // Ipkg execution verbosity level
89 OProcess *m_ipkgProcess; // Pointer to process which Ipkg will run in
90 93
91 void loadConfiguration(); 94 void loadConfiguration();
92 OConfItemList *filterConfItems( OConfItem::Type typefilter = OConfItem::NotDefined ); 95 OConfItemList *filterConfItems( OConfItem::Type typefilter = OConfItem::NotDefined );
93 96
94signals: 97signals:
95 void execOutput( OProcess *process, char *buffer, int length ); 98 void execOutput( char *msg );
96 void execErrors( OProcess *process, char *buffer, int length );
97 void execFinished( OProcess *process, char *buffer, int length );
98}; 99};
99 100
100#endif 101#endif
diff --git a/noncore/settings/packagemanager/opackagemanager.cpp b/noncore/settings/packagemanager/opackagemanager.cpp
index 6bef918..e1c8a21 100644
--- a/noncore/settings/packagemanager/opackagemanager.cpp
+++ b/noncore/settings/packagemanager/opackagemanager.cpp
@@ -256,75 +256,68 @@ QStringList *OPackageManager::destinations()
256 { 256 {
257 OConfItem *destination = destIt.current(); 257 OConfItem *destination = destIt.current();
258 258
259 // Add only active destinations 259 // Add only active destinations
260 if ( destination->active() ) 260 if ( destination->active() )
261 *dl << destination->name(); 261 *dl << destination->name();
262 } 262 }
263 } 263 }
264 264
265 return dl; 265 return dl;
266} 266}
267 267
268OConfItem *OPackageManager::findConfItem( OConfItem::Type type, const QString &name ) 268OConfItem *OPackageManager::findConfItem( OConfItem::Type type, const QString &name )
269{ 269{
270 OConfItem *confItem = 0x0; 270 OConfItem *confItem = 0x0;
271 OConfItemList *confList = m_ipkg.configItems(); 271 OConfItemList *confList = m_ipkg.configItems();
272 if ( confList ) 272 if ( confList )
273 { 273 {
274 for ( OConfItemListIterator confIt( *confList ); confIt.current(); ++confIt ) 274 for ( OConfItemListIterator confIt( *confList ); confIt.current(); ++confIt )
275 { 275 {
276 OConfItem *conf = confIt.current(); 276 OConfItem *conf = confIt.current();
277 277
278 // Add only active confinations 278 // Add only active confinations
279 if ( conf->type() == type && conf->name() == name ) 279 if ( conf->type() == type && conf->name() == name )
280 { 280 {
281 confItem = conf; 281 confItem = conf;
282 break; 282 break;
283 } 283 }
284 } 284 }
285 } 285 }
286 286
287 return confItem; 287 return confItem;
288 288
289} 289}
290 290
291OPackage *OPackageManager::findPackage( const QString &name ) 291OPackage *OPackageManager::findPackage( const QString &name )
292{ 292{
293 return m_packages[ name ]; 293 return m_packages[ name ];
294} 294}
295 295
296int OPackageManager::compareVersions( const QString &version1, const QString &version2 ) 296int OPackageManager::compareVersions( const QString &version1, const QString &version2 )
297{ 297{
298 // TODO - do proper compare! 298 // TODO - do proper compare!
299 if ( version1 < version2 ) 299 if ( version1 < version2 )
300 return -1; 300 return -1;
301 else if ( version1 > version2 ) 301 else if ( version1 > version2 )
302 return 1; 302 return 1;
303 303
304 return 0; 304 return 0;
305} 305}
306 306
307bool OPackageManager::configureDlg( bool installOptions ) 307bool OPackageManager::configureDlg( bool installOptions )
308{ 308{
309 OIpkgConfigDlg dlg( &m_ipkg, installOptions, static_cast<QWidget *>(parent()) ); 309 OIpkgConfigDlg dlg( &m_ipkg, installOptions, static_cast<QWidget *>(parent()) );
310 return ( dlg.exec() == QDialog::Accepted ); 310 return ( dlg.exec() == QDialog::Accepted );
311} 311}
312 312
313void OPackageManager::saveSettings() 313void OPackageManager::saveSettings()
314{ 314{
315 m_ipkg.saveSettings(); 315 m_ipkg.saveSettings();
316} 316}
317 317
318bool OPackageManager::executeCommand( OPackage::Command command, QStringList *packages, 318bool OPackageManager::executeCommand( OPackage::Command command, QStringList *packages,
319 const QString &destination, const QObject *receiver, 319 const QString &destination, const QObject *receiver,
320 const char *slotOutput, const char *slotErrors, 320 const char *slotOutput, bool rawOutput )
321 const char *slotFinished, bool rawOutput )
322{ 321{
323 return m_ipkg.executeCommand( command, packages, destination, receiver, slotOutput, slotErrors, 322 return m_ipkg.executeCommand( command, packages, destination, receiver, slotOutput, rawOutput );
324 slotFinished, rawOutput );
325}
326
327void OPackageManager::abortCommand()
328{
329 m_ipkg.abortCommand();
330} 323}
diff --git a/noncore/settings/packagemanager/opackagemanager.h b/noncore/settings/packagemanager/opackagemanager.h
index 5e1a30a..871af0c 100644
--- a/noncore/settings/packagemanager/opackagemanager.h
+++ b/noncore/settings/packagemanager/opackagemanager.h
@@ -11,81 +11,79 @@
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 OPACKAGEMANAGER_H 32#ifndef OPACKAGEMANAGER_H
33#define OPACKAGEMANAGER_H 33#define OPACKAGEMANAGER_H
34 34
35#include <qdict.h> 35#include <qdict.h>
36#include <qobject.h> 36#include <qobject.h>
37#include <qstringlist.h> 37#include <qstringlist.h>
38 38
39#include <qpe/config.h> 39#include <qpe/config.h>
40 40
41#include "oipkg.h" 41#include "oipkg.h"
42 42
43class OPackageManager : public QObject 43class OPackageManager : public QObject
44{ 44{
45 Q_OBJECT 45 Q_OBJECT
46 46
47public: 47public:
48 OPackageManager( Config *config = 0x0, QObject *parent = 0x0, const char *name = 0x0 ); 48 OPackageManager( Config *config = 0x0, QObject *parent = 0x0, const char *name = 0x0 );
49 49
50 void loadAvailablePackages(); 50 void loadAvailablePackages();
51 void loadInstalledPackages(); 51 void loadInstalledPackages();
52 52
53 enum Status { All, NotInstalled, Installed, Updated, NotDefined }; 53 enum Status { All, NotInstalled, Installed, Updated, NotDefined };
54 54
55 OPackageList *packages(); 55 OPackageList *packages();
56 OPackageList *filterPackages( const QString &name = 0x0,const QString &server = 0x0, 56 OPackageList *filterPackages( const QString &name = 0x0,const QString &server = 0x0,
57 const QString &destination = 0x0, Status status = NotDefined, 57 const QString &destination = 0x0, Status status = NotDefined,
58 const QString &category = 0x0 ); 58 const QString &category = 0x0 );
59 59
60 const QStringList &categories() { return m_categories; } 60 const QStringList &categories() { return m_categories; }
61 QStringList *servers(); 61 QStringList *servers();
62 QStringList *destinations(); 62 QStringList *destinations();
63 63
64 int compareVersions( const QString &version1, const QString &version2 ); 64 int compareVersions( const QString &version1, const QString &version2 );
65 65
66 OConfItem *findConfItem( OConfItem::Type type = OConfItem::NotDefined, 66 OConfItem *findConfItem( OConfItem::Type type = OConfItem::NotDefined,
67 const QString &name = QString::null ); 67 const QString &name = QString::null );
68 OPackage *findPackage( const QString &name = QString::null ); 68 OPackage *findPackage( const QString &name = QString::null );
69 69
70 bool configureDlg( bool installOptions = false ); 70 bool configureDlg( bool installOptions = false );
71 void saveSettings(); 71 void saveSettings();
72 72
73 bool executeCommand( OPackage::Command command = OPackage::NotDefined, QStringList *parameters = 0x0, 73 bool executeCommand( OPackage::Command command = OPackage::NotDefined, QStringList *parameters = 0x0,
74 const QString &destination = QString::null, const QObject *receiver = 0x0, 74 const QString &destination = QString::null, const QObject *receiver = 0x0,
75 const char *slotOutput = 0x0, const char *slotErrors = 0x0, 75 const char *slotOutput = 0x0, bool rawOutput = true );
76 const char *slotFinished = 0x0, bool rawOutput = true );
77 void abortCommand();
78 76
79private: 77private:
80 Config *m_config; // Pointer to application configuration file 78 Config *m_config; // Pointer to application configuration file
81 OIpkg m_ipkg; // OIpkg object to retrieve package/configuration information 79 OIpkg m_ipkg; // OIpkg object to retrieve package/configuration information
82 QDict<OPackage> m_packages; // Global list of available packages 80 QDict<OPackage> m_packages; // Global list of available packages
83 QStringList m_categories; // List of all categories 81 QStringList m_categories; // List of all categories
84 82
85signals: 83signals:
86 void initStatus( int numSteps ); 84 void initStatus( int numSteps );
87 void statusText( const QString &status ); 85 void statusText( const QString &status );
88 void statusBar( int currStep ); 86 void statusBar( int currStep );
89}; 87};
90 88
91#endif 89#endif
diff --git a/noncore/settings/packagemanager/opie-packagemanager.control b/noncore/settings/packagemanager/opie-packagemanager.control
index db06761..095e3be 100644
--- a/noncore/settings/packagemanager/opie-packagemanager.control
+++ b/noncore/settings/packagemanager/opie-packagemanager.control
@@ -1,10 +1,10 @@
1Package: opie-packagemanager 1Package: opie-packagemanager
2Files: plugins/application/libpackagemanager.so* bin/packagemanager pics/packagemanager apps/Settings/packagemanager.desktop 2Files: plugins/application/libpackagemanager.so* bin/packagemanager pics/packagemanager apps/Settings/packagemanager.desktop
3Priority: optional 3Priority: optional
4Section: Settings 4Section: Settings
5Depends: task-opie-minimal 5Depends: task-opie-minimal
6Replaces: packagemanager 6Replaces: packagemanager
7Architecture: arm 7Architecture: arm
8Maintainer: Dan Williams (drw@handhelds.org) 8Maintainer: Dan Williams (drw@handhelds.org)
9Description: Opie package management client 9Description: Opie package management client
10Version: 0.1.0 10Version: 0.2.0
diff --git a/noncore/settings/packagemanager/packagemanager.pro b/noncore/settings/packagemanager/packagemanager.pro
index 9aa3dc6..55af13e 100644
--- a/noncore/settings/packagemanager/packagemanager.pro
+++ b/noncore/settings/packagemanager/packagemanager.pro
@@ -1,31 +1,36 @@
1CONFIG = qt warn_on release quick-app 1CONFIG = qt warn_on release quick-app
2//TEMPLATE = app
3//CONFIG += qte warn_on debug
4//DESTDIR = $(OPIEDIR)/bin
2 5
3SOURCES = opackage.cpp \ 6SOURCES = opackage.cpp \
4 oconfitem.cpp \ 7 oconfitem.cpp \
5 oipkg.cpp \ 8 oipkg.cpp \
6 oipkgconfigdlg.cpp \ 9 oipkgconfigdlg.cpp \
7 opackagemanager.cpp \ 10 opackagemanager.cpp \
8 mainwindow.cpp \ 11 mainwindow.cpp \
9 installdlg.cpp \ 12 installdlg.cpp \
10 packageinfodlg.cpp \ 13 packageinfodlg.cpp \
11 filterdlg.cpp \ 14 filterdlg.cpp \
12 promptdlg.cpp \ 15 promptdlg.cpp \
13 main.cpp 16 main.cpp
14HEADERS = opackage.h \ 17HEADERS = opackage.h \
15 oconfitem.h \ 18 oconfitem.h \
16 oipkg.h \ 19 oipkg.h \
17 oipkgconfigdlg.h \ 20 oipkgconfigdlg.h \
18 opackagemanager.h \ 21 opackagemanager.h \
19 mainwindow.h \ 22 mainwindow.h \
20 installdlg.h \ 23 installdlg.h \
21 packageinfodlg.h \ 24 packageinfodlg.h \
22 filterdlg.h \ 25 filterdlg.h \
23 promptdlg.h 26 promptdlg.h
24 27
28DEFINES += IPKG_LIB
29DEFINES += HAVE_MKDTEMP
25TARGET = packagemanager 30TARGET = packagemanager
26INCLUDEPATH += $(OPIEDIR)/include 31INCLUDEPATH += $(OPIEDIR)/include $(IPKGDIR)
27DEPENDPATH += $(OPIEDIR)/include 32DEPENDPATH += $(OPIEDIR)/include
28LIBS += -lqpe -lopie 33LIBS += -lqpe -lopie -lipkg
29 34
30include ( $(OPIEDIR)/include.pro ) 35include ( $(OPIEDIR)/include.pro )
31 36