summaryrefslogtreecommitdiff
authordrw <drw>2005-01-02 20:26:01 (UTC)
committer drw <drw>2005-01-02 20:26:01 (UTC)
commite763e0cea060ae3a2dfb1c411f56354e27ac12a9 (patch) (unidiff)
tree37896734be7d2679c3f19635fe9fe3b52a549332
parent020ea2d54bcd0fc4420cb433b3e657cd13ae07e2 (diff)
downloadopie-e763e0cea060ae3a2dfb1c411f56354e27ac12a9.zip
opie-e763e0cea060ae3a2dfb1c411f56354e27ac12a9.tar.gz
opie-e763e0cea060ae3a2dfb1c411f56354e27ac12a9.tar.bz2
Implement native package linking code (removing need for ipkg-link and its shortcomings), move package linking code to OIpkg (proper place for ipkg specific code), many small code tweaks and bump version up to 0.6.1
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/packagemanager/ChangeLog7
-rw-r--r--noncore/settings/packagemanager/TODO8
-rw-r--r--noncore/settings/packagemanager/installdlg.cpp81
-rw-r--r--noncore/settings/packagemanager/installdlg.h11
-rw-r--r--noncore/settings/packagemanager/oipkg.cpp208
-rw-r--r--noncore/settings/packagemanager/oipkg.h20
-rw-r--r--noncore/settings/packagemanager/oipkgconfigdlg.cpp34
-rw-r--r--noncore/settings/packagemanager/oipkgconfigdlg.h3
-rw-r--r--noncore/settings/packagemanager/opackagemanager.cpp20
-rw-r--r--noncore/settings/packagemanager/opie-packagemanager.control4
-rw-r--r--noncore/settings/packagemanager/packageinfodlg.cpp10
-rw-r--r--noncore/settings/packagemanager/packageinfodlg.h4
12 files changed, 237 insertions, 173 deletions
diff --git a/noncore/settings/packagemanager/ChangeLog b/noncore/settings/packagemanager/ChangeLog
index c776ce5..608cd98 100644
--- a/noncore/settings/packagemanager/ChangeLog
+++ b/noncore/settings/packagemanager/ChangeLog
@@ -1,53 +1,60 @@
12005-01-02 Dan Williams <drw@handhelds.org>
2
3 * Released version 0.6.1
4 * Implemented native package linking code to remove need for ipkg-link
5 * Implement package in OIpkg (removed from InstallDlg) as this is ipkg specific
6 * Many small code tweaks
7
12004-12-21 Dan Williams <drw@handhelds.org> 82004-12-21 Dan Williams <drw@handhelds.org>
2 9
3 * Released version 0.6.0 10 * Released version 0.6.0
4 * Added support for Ipkg 'src/gz' feeds 11 * Added support for Ipkg 'src/gz' feeds
5 * Improve server and destination tabs UI's in configuration dialog 12 * Improve server and destination tabs UI's in configuration dialog
6 * Fix app linking to link all dependent packages as well as selected packages 13 * Fix app linking to link all dependent packages as well as selected packages
7 * Hide 'Retrive File List' button once list is retrieved in Package Info dialog 14 * Hide 'Retrive File List' button once list is retrieved in Package Info dialog
8 15
92004-11-18 Dan Williams <drw@handhelds.org> 162004-11-18 Dan Williams <drw@handhelds.org>
10 17
11 * Released version 0.5.0 18 * Released version 0.5.0
12 * All v1.0 functionality implemented 19 * All v1.0 functionality implemented
13 * Implemented installation of local packages 20 * Implemented installation of local packages
14 * Implemented linking of non-root apps (using ipkg-link) 21 * Implemented linking of non-root apps (using ipkg-link)
15 * Many UI tweaks for installation and filter dialogs 22 * Many UI tweaks for installation and filter dialogs
16 23
172004-04-21 Dan Williams <drw@handhelds.org> 242004-04-21 Dan Williams <drw@handhelds.org>
18 25
19 * Released version 0.4.0 26 * Released version 0.4.0
20 * Added saving of ipkg configuration information 27 * Added saving of ipkg configuration information
21 * Re-initialize ipkg when configuration information changes 28 * Re-initialize ipkg when configuration information changes
22 * Added QWhatsThis for all UI controls 29 * Added QWhatsThis for all UI controls
23 * Remove Location from OConfItem as it is not used/needed 30 * Remove Location from OConfItem as it is not used/needed
24 * Re-ordered includes to follow Opie standards 31 * Re-ordered includes to follow Opie standards
25 32
262004-02-13 Dan Williams <drw@handhelds.org> 332004-02-13 Dan Williams <drw@handhelds.org>
27 34
28 * Released version 0.3.0 35 * Released version 0.3.0
29 * Fix handling of filtering options in View menu 36 * Fix handling of filtering options in View menu
30 * Do proper version string comparison 37 * Do proper version string comparison
31 * Fix string alignment code in PromptDlg to eliminate QT warning messages 38 * Fix string alignment code in PromptDlg to eliminate QT warning messages
32 39
332004-02-12 Dan Williams <drw@handhelds.org> 402004-02-12 Dan Williams <drw@handhelds.org>
34 41
35 * Package information dialog implemented 42 * Package information dialog implemented
36 * What's This app icon enabled 43 * What's This app icon enabled
37 * Changed all QDialog::exec() occurences to QPEApplication::execDialog() 44 * Changed all QDialog::exec() occurences to QPEApplication::execDialog()
38 45
392004-01-23 Dan Williams <drw@handhelds.org> 462004-01-23 Dan Williams <drw@handhelds.org>
40 47
41 * Added package download functionality 48 * Added package download functionality
42 * Have Opie update links after install/removal so that apps 49 * Have Opie update links after install/removal so that apps
43 will display properly in Launcher 50 will display properly in Launcher
44 51
452004-01-20 Dan Williams <drw@handhelds.org> 522004-01-20 Dan Williams <drw@handhelds.org>
46 53
47 * Released version 0.2.0 54 * Released version 0.2.0
48 * Converted to use libipkg in place of spawning ipkg process 55 * Converted to use libipkg in place of spawning ipkg process
49 56
502004-01-13 Dan Williams <drw@handhelds.org> 572004-01-13 Dan Williams <drw@handhelds.org>
51 58
52 * Released version 0.1.0 59 * Released version 0.1.0
53 * Initial check-in of new package management client to eventually replace AQPkg 60 * Initial check-in of new package management client to eventually replace AQPkg
diff --git a/noncore/settings/packagemanager/TODO b/noncore/settings/packagemanager/TODO
index 744ad95..2512624 100644
--- a/noncore/settings/packagemanager/TODO
+++ b/noncore/settings/packagemanager/TODO
@@ -1,17 +1,15 @@
1/************************************************************************ 1/************************************************************************
2/* 2/*
3/* Opie - Package Manager 3/* Opie - Package Manager
4/* ======================== 4/* ========================
5/* Version 0.6.0 5/* Version 0.6.1
6/* 6/*
7/* A package management client for Opie 7/* A package management client for Opie
8/* 8/*
9/************************************************************************ 9/************************************************************************
10 10
11----------------------------------------------- 11-----------------------------------------------
12 To-do for Opie-PackageManager - December, 2004 12 To-do for Opie-PackageManager - January, 2005
13----------------------------------------------- 13-----------------------------------------------
14 14
151. Move ipkg-link code from InstallDlg to OIpkg 151. Re-work package download dialog
162. Code ipkg-link logic directly in OIpkg
173. Re-work package download dialog
diff --git a/noncore/settings/packagemanager/installdlg.cpp b/noncore/settings/packagemanager/installdlg.cpp
index 985e2bd..7dea591 100644
--- a/noncore/settings/packagemanager/installdlg.cpp
+++ b/noncore/settings/packagemanager/installdlg.cpp
@@ -1,388 +1,311 @@
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 "installdlg.h" 30#include "installdlg.h"
31 31
32#include <opie2/ofiledialog.h> 32#include <opie2/ofiledialog.h>
33#include <opie2/oprocess.h>
34 33
35#include <qpe/fileselector.h> 34#include <qpe/fileselector.h>
36#include <qpe/resource.h> 35#include <qpe/resource.h>
37#include <qpe/storage.h> 36#include <qpe/storage.h>
38 37
39#include <qapplication.h> 38#include <qapplication.h>
40#include <qcombobox.h> 39#include <qcombobox.h>
41#include <qfileinfo.h> 40#include <qfileinfo.h>
42#include <qgroupbox.h> 41#include <qgroupbox.h>
43#include <qlabel.h> 42#include <qlabel.h>
44#include <qlayout.h> 43#include <qlayout.h>
45#include <qmap.h> 44#include <qmap.h>
46#include <qmultilineedit.h> 45#include <qmultilineedit.h>
47#include <qpushbutton.h> 46#include <qpushbutton.h>
48 47
49#include <sys/vfs.h> 48#include <sys/vfs.h>
50 49
51#include "opackagemanager.h" 50#include "opackagemanager.h"
52 51
53InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &caption, 52InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &caption,
54 OPackage::Command command1, const QStringList &packages1, 53 OPackage::Command command1, const QStringList &packages1,
55 OPackage::Command command2, const QStringList &packages2, 54 OPackage::Command command2, const QStringList &packages2,
56 OPackage::Command command3, const QStringList &packages3 ) 55 OPackage::Command command3, const QStringList &packages3 )
57 : QWidget( 0l ) 56 : QWidget( 0l )
58 , m_packman( pm ) 57 , m_packman( pm )
59 , m_installFound( false ) 58 , m_installFound( false )
60 , m_numCommands( 0 ) 59 , m_numCommands( 0 )
61 , m_currCommand( 0 ) 60 , m_currCommand( 0 )
62 , m_destItem( 0l ) 61 , m_destItem( 0l )
63{ 62{
64 // Save command/package list information 63 // Save command/package list information
65 if ( command1 != OPackage::NotDefined ) 64 if ( command1 != OPackage::NotDefined )
66 { 65 {
67 m_command[ m_numCommands ] = command1; 66 m_command[ m_numCommands ] = command1;
68 m_packages[ m_numCommands ] = packages1; 67 m_packages[ m_numCommands ] = packages1;
69 ++m_numCommands; 68 ++m_numCommands;
70 69
71 if ( command1 == OPackage::Install ) 70 if ( command1 == OPackage::Install )
72 m_installFound = true; 71 m_installFound = true;
73 } 72 }
74 if ( command2 != OPackage::NotDefined ) 73 if ( command2 != OPackage::NotDefined )
75 { 74 {
76 m_command[ m_numCommands ] = command2; 75 m_command[ m_numCommands ] = command2;
77 m_packages[ m_numCommands ] = packages2; 76 m_packages[ m_numCommands ] = packages2;
78 ++m_numCommands; 77 ++m_numCommands;
79 78
80 if ( command2 == OPackage::Install ) 79 if ( command2 == OPackage::Install )
81 m_installFound = true; 80 m_installFound = true;
82 } 81 }
83 if ( command3 != OPackage::NotDefined ) 82 if ( command3 != OPackage::NotDefined )
84 { 83 {
85 m_command[ m_numCommands ] = command3; 84 m_command[ m_numCommands ] = command3;
86 m_packages[ m_numCommands ] = packages3; 85 m_packages[ m_numCommands ] = packages3;
87 ++m_numCommands; 86 ++m_numCommands;
88 87
89 if ( command3 == OPackage::Install ) 88 if ( command3 == OPackage::Install )
90 m_installFound = true; 89 m_installFound = true;
91 } 90 }
92 91
93 // Initialize UI 92 // Initialize UI
94 if ( parent ) 93 if ( parent )
95 parent->setCaption( caption ); 94 parent->setCaption( caption );
96 95
97 QGridLayout *layout = new QGridLayout( this, 4, 2, 2, 4 ); 96 QGridLayout *layout = new QGridLayout( this, 4, 2, 2, 4 );
98 97
99 if ( m_installFound ) 98 if ( m_installFound )
100 { 99 {
101 QLabel *label = new QLabel( tr( "Destination" ), this ); 100 QLabel *label = new QLabel( tr( "Destination" ), this );
102 layout->addWidget( label, 0, 0 ); 101 layout->addWidget( label, 0, 0 );
103 m_destination = new QComboBox( this ); 102 m_destination = new QComboBox( this );
104 m_destination->insertStringList( m_packman->destinations() ); 103 m_destination->insertStringList( m_packman->destinations() );
105 layout->addWidget( m_destination, 0, 1 ); 104 layout->addWidget( m_destination, 0, 1 );
106 connect( m_destination, SIGNAL(highlighted(const QString&)), 105 connect( m_destination, SIGNAL(highlighted(const QString&)),
107 this, SLOT(slotDisplayAvailSpace(const QString&)) ); 106 this, SLOT(slotDisplayAvailSpace(const QString&)) );
108 107
109 label = new QLabel( tr( "Space Avail" ), this ); 108 label = new QLabel( tr( "Space Avail" ), this );
110 layout->addWidget( label, 1, 0 ); 109 layout->addWidget( label, 1, 0 );
111 m_availSpace = new QLabel( this ); 110 m_availSpace = new QLabel( this );
112 layout->addWidget( m_availSpace, 1, 1 ); 111 layout->addWidget( m_availSpace, 1, 1 );
113 112
114 // TODO - select correct destination 113 // TODO - select correct destination
115 slotDisplayAvailSpace( m_destination->currentText() ); 114 slotDisplayAvailSpace( m_destination->currentText() );
116 } 115 }
117 else 116 else
118 { 117 {
119 m_destination = 0l; 118 m_destination = 0l;
120 m_availSpace = 0l; 119 m_availSpace = 0l;
121 } 120 }
122 121
123 QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this ); 122 QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this );
124 groupBox->layout()->setSpacing( 0 ); 123 groupBox->layout()->setSpacing( 0 );
125 groupBox->layout()->setMargin( 4 ); 124 groupBox->layout()->setMargin( 4 );
126 125
127 QVBoxLayout *groupBoxLayout = new QVBoxLayout( groupBox->layout() ); 126 QVBoxLayout *groupBoxLayout = new QVBoxLayout( groupBox->layout() );
128 m_output = new QMultiLineEdit( groupBox ); 127 m_output = new QMultiLineEdit( groupBox );
129 m_output->setReadOnly( true ); 128 m_output->setReadOnly( true );
130 groupBoxLayout->addWidget( m_output ); 129 groupBoxLayout->addWidget( m_output );
131 layout->addMultiCellWidget( groupBox, 2, 2, 0, 1 ); 130 layout->addMultiCellWidget( groupBox, 2, 2, 0, 1 );
132 131
133 m_btnStart = new QPushButton( Resource::loadPixmap( "packagemanager/apply" ), tr( "Start" ), this ); 132 m_btnStart = new QPushButton( Resource::loadPixmap( "packagemanager/apply" ), tr( "Start" ), this );
134 layout->addWidget( m_btnStart, 3, 0 ); 133 layout->addWidget( m_btnStart, 3, 0 );
135 connect( m_btnStart, SIGNAL(clicked()), this, SLOT(slotBtnStart()) ); 134 connect( m_btnStart, SIGNAL(clicked()), this, SLOT(slotBtnStart()) );
136 135
137 m_btnOptions = new QPushButton( Resource::loadPixmap( "SettingsIcon" ), tr( "Options" ), this ); 136 m_btnOptions = new QPushButton( Resource::loadPixmap( "SettingsIcon" ), tr( "Options" ), this );
138 layout->addWidget( m_btnOptions, 3, 1 ); 137 layout->addWidget( m_btnOptions, 3, 1 );
139 connect( m_btnOptions, SIGNAL( clicked() ), this, SLOT(slotBtnOptions()) ); 138 connect( m_btnOptions, SIGNAL( clicked() ), this, SLOT(slotBtnOptions()) );
140 139
141 // Display packages being acted upon in output widget 140 // Display packages being acted upon in output widget
142 for( int i = 0; i < m_numCommands; i++ ) 141 for( int i = 0; i < m_numCommands; i++ )
143 { 142 {
144 if ( !m_packages[ i ].isEmpty() ) 143 if ( !m_packages[ i ].isEmpty() )
145 { 144 {
146 QString lineStr = tr( "Packages to " ); 145 QString lineStr = tr( "Packages to " );
147 146
148 switch( m_command[ i ] ) 147 switch( m_command[ i ] )
149 { 148 {
150 case OPackage::Install : lineStr.append( tr( "install" ) ); 149 case OPackage::Install : lineStr.append( tr( "install" ) );
151 break; 150 break;
152 case OPackage::Remove : lineStr.append( tr( "remove" ) ); 151 case OPackage::Remove : lineStr.append( tr( "remove" ) );
153 break; 152 break;
154 case OPackage::Upgrade : lineStr.append( tr( "upgrade" ) ); 153 case OPackage::Upgrade : lineStr.append( tr( "upgrade" ) );
155 break; 154 break;
156 case OPackage::Download : lineStr.append( tr( "download" ) ); 155 case OPackage::Download : lineStr.append( tr( "download" ) );
157 break; 156 break;
158 default : 157 default :
159 break; 158 break;
160 }; 159 };
161 lineStr.append( ":\n" ); 160 lineStr.append( ":\n" );
162 161
163 QStringList tmpPackage = m_packages[ i ]; 162 QStringList tmpPackage = m_packages[ i ];
164 for ( QStringList::Iterator it = tmpPackage.begin(); it != tmpPackage.end(); ++it ) 163 for ( QStringList::Iterator it = tmpPackage.begin(); it != tmpPackage.end(); ++it )
165 { 164 {
166 lineStr.append( QString( "\t%1\n" ).arg( ( *it ) ) ); 165 lineStr.append( QString( "\t%1\n" ).arg( ( *it ) ) );
167 } 166 }
168 167
169 m_output->append( lineStr ); 168 m_output->append( lineStr );
170 } 169 }
171 } 170 }
172 171
173 m_output->append( tr( "Press the start button to begin.\n" ) ); 172 m_output->append( tr( "Press the start button to begin.\n" ) );
174 m_output->setCursorPosition( m_output->numLines(), 0 ); 173 m_output->setCursorPosition( m_output->numLines(), 0 );
175 174
176} 175}
177 176
178void InstallDlg::slotDisplayAvailSpace( const QString &destination ) 177void InstallDlg::slotDisplayAvailSpace( const QString &destination )
179{ 178{
180 // If available space is not displayed, exit 179 // If available space is not displayed, exit
181 if ( !m_availSpace ) 180 if ( !m_availSpace )
182 return; 181 return;
183 182
184 QString space = tr( "Unknown" ); 183 QString space = tr( "Unknown" );
185 184
186 // Get destination 185 // Get destination
187 if ( !destination.isNull() ) 186 if ( !destination.isNull() )
188 m_destItem = m_packman->findConfItem( OConfItem::Destination, destination ); 187 m_destItem = m_packman->findConfItem( OConfItem::Destination, destination );
189 188
190 if ( m_destItem ) 189 if ( m_destItem )
191 { 190 {
192 // Calculate available space 191 // Calculate available space
193 struct statfs fs; 192 struct statfs fs;
194 if ( !statfs( m_destItem->value(), &fs ) ) 193 if ( !statfs( m_destItem->value(), &fs ) )
195 { 194 {
196 long mult = fs.f_bsize / 1024; 195 long mult = fs.f_bsize / 1024;
197 long div = 1024 / fs.f_bsize; 196 long div = 1024 / fs.f_bsize;
198 197
199 if ( !mult ) mult = 1; 198 if ( !mult ) mult = 1;
200 if ( !div ) div = 1; 199 if ( !div ) div = 1;
201 long avail = fs.f_bavail * mult / div; 200 long avail = fs.f_bavail * mult / div;
202 201
203 space = tr( "%1 Kb" ).arg( avail ); 202 space = tr( "%1 Kb" ).arg( avail );
204 } 203 }
205 } 204 }
206 205
207 // Display available space 206 // Display available space
208 m_availSpace->setText( space ); 207 m_availSpace->setText( space );
209} 208}
210 209
211void InstallDlg::slotBtnStart() 210void InstallDlg::slotBtnStart()
212{ 211{
213 QString btnText = m_btnStart->text(); 212 QString btnText = m_btnStart->text();
214 if ( btnText == tr( "Abort" ) ) 213 if ( btnText == tr( "Abort" ) )
215 { 214 {
216 // Prevent unexecuted commands from executing 215 // Prevent unexecuted commands from executing
217 m_currCommand = 999; 216 m_currCommand = 999;
218 217
219 // Allow user to close dialog 218 // Allow user to close dialog
220 m_btnStart->setText( tr( "Close" ) ); 219 m_btnStart->setText( tr( "Close" ) );
221 m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) ); 220 m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) );
222 return; 221 return;
223 } 222 }
224 else if ( btnText == tr( "Close" ) ) 223 else if ( btnText == tr( "Close" ) )
225 { 224 {
226 // TODO - force reload of package data 225 // TODO - force reload of package data
227 emit closeInstallDlg(); 226 emit closeInstallDlg();
228 return; 227 return;
229 } 228 }
230 229
231 // Start was clicked, start executing 230 // Start was clicked, start executing
232 QString dest; 231 QString dest;
233 if ( m_installFound ) 232 if ( m_installFound )
234 { 233 {
235 dest = m_destination->currentText(); 234 dest = m_destination->currentText();
236 m_destination->setEnabled( false ); 235 m_destination->setEnabled( false );
237 } 236 }
238 237
239 m_btnOptions->setEnabled( false ); 238 m_btnOptions->setEnabled( false );
240 if ( m_numCommands > 1 ) 239 if ( m_numCommands > 1 )
241 { 240 {
242 m_btnStart->setText( tr( "Abort" ) ); 241 m_btnStart->setText( tr( "Abort" ) );
243 m_btnStart->setIconSet( Resource::loadPixmap( "close" ) ); 242 m_btnStart->setIconSet( Resource::loadPixmap( "close" ) );
244 } 243 }
245 else 244 else
246 { 245 {
247 m_btnStart->setEnabled( false ); 246 m_btnStart->setEnabled( false );
248 } 247 }
249 248
250 Opie::Core::OProcess process( this );
251 for ( m_currCommand = 0; m_currCommand < m_numCommands; m_currCommand++ ) 249 for ( m_currCommand = 0; m_currCommand < m_numCommands; m_currCommand++ )
252 { 250 {
253 // Execute next command 251 // Execute next command
254 m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], dest, 252 m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], dest,
255 this, SLOT(slotOutput(char*)), true ); 253 this, SLOT(slotOutput(const QString &)), true );
256
257 if ( m_command[ m_currCommand ] == OPackage::Remove )
258 {
259 // Unlink application if the package was removed
260
261 // Loop through all package names in the command group
262 for ( QStringList::Iterator it = m_packages[ m_currCommand ].begin();
263 it != m_packages[ m_currCommand ].end();
264 ++it )
265 {
266 OPackage *currPackage = m_packman->findPackage( (*it) );
267
268 // Skip package if it is not found or being removed from 'root'
269 if ( !currPackage || ( m_command[ m_currCommand ] == OPackage::Remove &&
270 currPackage->destination() == "root" ) )
271 continue;
272
273 // Display feedback to user
274 m_output->append( tr( QString( "Running ipkg-link to remove links for package '%1'." )
275 .arg( currPackage->name() ) ) );
276 m_output->setCursorPosition( m_output->numLines(), 0 );
277
278 // Execute ipkg-link
279 process.clearArguments();
280 process << "ipkg-link"
281 << ( ( m_command[ m_currCommand ] == OPackage::Install ) ? "add" : "remove" )
282 << currPackage->name();
283 if ( !process.start( Opie::Core::OProcess::Block,
284 Opie::Core::OProcess::NoCommunication ) )
285 {
286 slotProcessDone( 0l );
287 m_output->append( tr( "Unable to run ipkg-link." ) );
288 m_output->setCursorPosition( m_output->numLines(), 0 );
289 return;
290 }
291 }
292 }
293 else if ( m_command[ m_currCommand ] == OPackage::Install && dest != "root" )
294 {
295 // Link applications in the destination directory
296
297 m_output->append( tr( "Running ipkg-link to link packages in '%1'." ).arg( dest ) );
298 m_output->setCursorPosition( m_output->numLines(), 0 );
299
300 QString destPath;
301 OConfItem *destItem = m_packman->findConfItem( OConfItem::Destination, dest );
302
303 // Execute ipkg-link
304 process.clearArguments();
305 process << "ipkg-link"
306 << "mount"
307 << destItem->value();
308 if ( !process.start( Opie::Core::OProcess::Block,
309 Opie::Core::OProcess::NoCommunication ) )
310 {
311 slotProcessDone( 0l );
312 m_output->append( tr( "Unable to run ipkg-link." ) );
313 m_output->setCursorPosition( m_output->numLines(), 0 );
314 return;
315 }
316 }
317 }
318
319 slotProcessDone( 0l );
320}
321
322void InstallDlg::slotProcessDone( Opie::Core::OProcess *proc )
323{
324 if ( proc )
325 {
326 // Display message pnly if linking was done
327 m_output->append( tr( "The package linking is done." ) );
328 m_output->setCursorPosition( m_output->numLines(), 0 );
329
330 delete proc;
331 } 254 }
332 255
333 // All commands executed, allow user to close dialog 256 // All commands executed, allow user to close dialog
334 m_btnStart->setEnabled( true ); 257 m_btnStart->setEnabled( true );
335 m_btnStart->setText( tr( "Close" ) ); 258 m_btnStart->setText( tr( "Close" ) );
336 m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) ); 259 m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) );
337 260
338 m_btnOptions->setEnabled( true ); 261 m_btnOptions->setEnabled( true );
339 m_btnOptions->setText( tr( "Save output" ) ); 262 m_btnOptions->setText( tr( "Save output" ) );
340 m_btnOptions->setIconSet( Resource::loadPixmap( "save" ) ); 263 m_btnOptions->setIconSet( Resource::loadPixmap( "save" ) );
341} 264}
342 265
343void InstallDlg::slotBtnOptions() 266void InstallDlg::slotBtnOptions()
344{ 267{
345 QString btnText = m_btnOptions->text(); 268 QString btnText = m_btnOptions->text();
346 if ( btnText == tr( "Options" ) ) 269 if ( btnText == tr( "Options" ) )
347 { 270 {
348 // Display configuration dialog (only options tab is enabled) 271 // Display configuration dialog (only options tab is enabled)
349 m_packman->configureDlg( true ); 272 m_packman->configureDlg( true );
350 return; 273 return;
351 } 274 }
352 275
353 // Save output was clicked 276 // Save output was clicked
354 QMap<QString, QStringList> map; 277 QMap<QString, QStringList> map;
355 map.insert( tr( "All" ), QStringList() ); 278 map.insert( tr( "All" ), QStringList() );
356 QStringList text; 279 QStringList text;
357 text << "text/*"; 280 text << "text/*";
358 map.insert(tr( "Text" ), text ); 281 map.insert(tr( "Text" ), text );
359 text << "*"; 282 text << "*";
360 map.insert( tr( "All" ), text ); 283 map.insert( tr( "All" ), text );
361 284
362 QString filename = Opie::Ui::OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map ); 285 QString filename = Opie::Ui::OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map );
363 if( !filename.isEmpty() ) 286 if( !filename.isEmpty() )
364 { 287 {
365 QString currentFileName = QFileInfo( filename ).fileName(); 288 QString currentFileName = QFileInfo( filename ).fileName();
366 DocLnk doc; 289 DocLnk doc;
367 doc.setType( "text/plain" ); 290 doc.setType( "text/plain" );
368 doc.setFile( filename ); 291 doc.setFile( filename );
369 doc.setName( currentFileName ); 292 doc.setName( currentFileName );
370 FileManager fm; 293 FileManager fm;
371 fm.saveFile( doc, m_output->text() ); 294 fm.saveFile( doc, m_output->text() );
372 } 295 }
373} 296}
374 297
375void InstallDlg::slotOutput( char *msg ) 298void InstallDlg::slotOutput( const QString &msg )
376{ 299{
377 // Allow processing of other events 300 // Allow processing of other events
378 qApp->processEvents(); 301 qApp->processEvents();
379 302
380 QString lineStr = msg; 303 QString lineStr = msg;
381 if ( lineStr[lineStr.length()-1] == '\n' ) 304 if ( lineStr[lineStr.length()-1] == '\n' )
382 lineStr.truncate( lineStr.length() - 1 ); 305 lineStr.truncate( lineStr.length() - 1 );
383 m_output->append( lineStr ); 306 m_output->append( lineStr );
384 m_output->setCursorPosition( m_output->numLines(), 0 ); 307 m_output->setCursorPosition( m_output->numLines(), 0 );
385 308
386 // Update available space 309 // Update available space
387 slotDisplayAvailSpace( QString::null ); 310 slotDisplayAvailSpace( QString::null );
388} 311}
diff --git a/noncore/settings/packagemanager/installdlg.h b/noncore/settings/packagemanager/installdlg.h
index 7a64fe0..e633809 100644
--- a/noncore/settings/packagemanager/installdlg.h
+++ b/noncore/settings/packagemanager/installdlg.h
@@ -1,101 +1,92 @@
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 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 "opackage.h" 35#include "opackage.h"
36 36
37class QComboBox; 37class QComboBox;
38class QLabel; 38class QLabel;
39class QMultiLineEdit; 39class QMultiLineEdit;
40class QPushButton; 40class QPushButton;
41 41
42class OConfItem; 42class OConfItem;
43class OPackageManager; 43class OPackageManager;
44 44
45namespace Opie
46{
47 namespace Core
48 {
49 class OProcess;
50 }
51}
52
53class InstallDlg : public QWidget 45class InstallDlg : public QWidget
54{ 46{
55 Q_OBJECT 47 Q_OBJECT
56 48
57public: 49public:
58 InstallDlg( QWidget *parent = 0l, OPackageManager *pm = 0l, 50 InstallDlg( QWidget *parent = 0l, OPackageManager *pm = 0l,
59 const QString &caption = QString::null, 51 const QString &caption = QString::null,
60 OPackage::Command command1 = OPackage::NotDefined, 52 OPackage::Command command1 = OPackage::NotDefined,
61 const QStringList &packages1 = QStringList(), 53 const QStringList &packages1 = QStringList(),
62 OPackage::Command command2 = OPackage::NotDefined, 54 OPackage::Command command2 = OPackage::NotDefined,
63 const QStringList &packages2 = QStringList(), 55 const QStringList &packages2 = QStringList(),
64 OPackage::Command command3 = OPackage::NotDefined, 56 OPackage::Command command3 = OPackage::NotDefined,
65 const QStringList &packages3 = QStringList() ); 57 const QStringList &packages3 = QStringList() );
66 58
67private: 59private:
68 OPackageManager *m_packman; // Pointer to application instance of package manager 60 OPackageManager *m_packman; // Pointer to application instance of package manager
69 61
70 bool m_installFound; // Indicates if an install is being done, controls display of 62 bool m_installFound; // Indicates if an install is being done, controls display of
71 // destination selection, available space 63 // destination selection, available space
72 64
73 // UI controls 65 // UI controls
74 QComboBox *m_destination; // Destination selection list 66 QComboBox *m_destination; // Destination selection list
75 QLabel *m_availSpace; // Text label to display available space on selected destination 67 QLabel *m_availSpace; // Text label to display available space on selected destination
76 QMultiLineEdit *m_output; // Multi-line edit to display status 68 QMultiLineEdit *m_output; // Multi-line edit to display status
77 QPushButton *m_btnStart; // Start/abort/close button 69 QPushButton *m_btnStart; // Start/abort/close button
78 QPushButton *m_btnOptions; // Installation options button 70 QPushButton *m_btnOptions; // Installation options button
79 71
80 // Commands and packages to execute 72 // Commands and packages to execute
81 int m_numCommands; // Number of commands to be executed 73 int m_numCommands; // Number of commands to be executed
82 int m_currCommand; // Number of currently executing command 74 int m_currCommand; // Number of currently executing command
83 OPackage::Command m_command[3]; // List of commands to be executed 75 OPackage::Command m_command[3]; // List of commands to be executed
84 QStringList m_packages[3]; // Lists of package names associated to commands (m_command[]) 76 QStringList m_packages[3]; // Lists of package names associated to commands (m_command[])
85 OConfItem *m_destItem; // Pointer to destination for package installation 77 OConfItem *m_destItem; // Pointer to destination for package installation
86 78
87private slots: 79private slots:
88 // UI control slots 80 // UI control slots
89 void slotDisplayAvailSpace( const QString &destination ); 81 void slotDisplayAvailSpace( const QString &destination );
90 void slotBtnStart(); 82 void slotBtnStart();
91 void slotBtnOptions(); 83 void slotBtnOptions();
92 void slotProcessDone( Opie::Core::OProcess *proc );
93 84
94 // Execution slots 85 // Execution slots
95 void slotOutput( char *msg ); 86 void slotOutput( const QString &msg );
96 87
97signals: 88signals:
98 void closeInstallDlg(); 89 void closeInstallDlg();
99}; 90};
100 91
101#endif 92#endif
diff --git a/noncore/settings/packagemanager/oipkg.cpp b/noncore/settings/packagemanager/oipkg.cpp
index a66bd51..f2d7e39 100644
--- a/noncore/settings/packagemanager/oipkg.cpp
+++ b/noncore/settings/packagemanager/oipkg.cpp
@@ -1,211 +1,215 @@
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 <qdir.h> 34#include <qdir.h>
35#include <qfile.h> 35#include <qfile.h>
36#include <qtextstream.h> 36#include <qtextstream.h>
37 37
38#include <stdlib.h> 38#include <stdlib.h>
39#include <unistd.h>
39 40
40const QString IPKG_CONF = "/etc/ipkg.conf"; // Fully-qualified name of Ipkg primary configuration file 41const QString IPKG_CONF = "/etc/ipkg.conf"; // Fully-qualified name of Ipkg primary configuration file
41const QString IPKG_CONF_DIR = "/etc/ipkg"; // Directory of secondary Ipkg configuration files 42const QString IPKG_CONF_DIR = "/etc/ipkg"; // Directory of secondary Ipkg configuration files
42const QString IPKG_PKG_PATH = "/usr/lib/ipkg/lists"; // Directory containing server package lists 43const QString IPKG_PKG_PATH = "/usr/lib/ipkg/lists"; // Directory containing server package lists
43const QString IPKG_STATUS_PATH = "usr/lib/ipkg/status"; // Destination status file location 44const QString IPKG_STATUS_PATH = "usr/lib/ipkg/status"; // Destination status file location
45const QString IPKG_INFO_PATH = "usr/lib/ipkg/info"; // Package file lists location
44 46
45OIpkg *oipkg; 47OIpkg *oipkg;
46 48
47// Ipkg callback functions 49// Ipkg callback functions
48 50
49int fsignalIpkgMessage( ipkg_conf_t *conf, message_level_t level, char *msg ) 51int fsignalIpkgMessage( ipkg_conf_t *conf, message_level_t level, char *msg )
50{ 52{
53 // Display message only if it is below the message level threshold
51 if ( conf && ( conf->verbosity < level ) ) 54 if ( conf && ( conf->verbosity < level ) )
52 return 0; 55 return 0;
53 else 56 else
54 oipkg->ipkgMessage( msg ); 57 oipkg->ipkgMessage( msg );
55 58
56 return 0; 59 return 0;
57} 60}
58 61
59char *fIpkgResponse( char */*question*/ ) 62char *fIpkgResponse( char */*question*/ )
60{ 63{
61 return 0x0; 64 return 0l;
62} 65}
63 66
64int fIpkgStatus( char */*name*/, int /*status*/, char *desc, void */*userdata*/ ) 67int fIpkgStatus( char */*name*/, int /*status*/, char *desc, void */*userdata*/ )
65{ 68{
66 oipkg->ipkgStatus( desc ); 69 oipkg->ipkgStatus( desc );
67 return 0; 70 return 0;
68} 71}
69 72
70int fIpkgFiles( char */*name*/, char *desc, char */*version*/, pkg_state_status_t /*status*/, 73int fIpkgFiles( char */*name*/, char *desc, char */*version*/, pkg_state_status_t /*status*/,
71 void */*userdata*/ ) 74 void */*userdata*/ )
72{ 75{
73 oipkg->ipkgList( desc ); 76 oipkg->ipkgList( desc );
74 return 0; 77 return 0;
75} 78}
76 79
77OIpkg::OIpkg( Config *config, QObject *parent, const char *name ) 80OIpkg::OIpkg( Config *config, QObject *parent, const char *name )
78 : QObject( parent, name ) 81 : QObject( parent, name )
79 , m_config( config ) 82 , m_config( config )
80 , m_confInfo( NULL ) 83 , m_confInfo( NULL )
81 , m_ipkgExecOptions( 0 ) 84 , m_ipkgExecOptions( 0 )
82 , m_ipkgExecVerbosity( 1 ) 85 , m_ipkgExecVerbosity( 1 )
83{ 86{
87 // Keep pointer to self for the Ipkg callback functions
84 oipkg = this; 88 oipkg = this;
85 89
86 // Initialize libipkg 90 // Initialize libipkg
87 ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ); 91 ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs );
88 92
89 // Default ipkg run-time arguments 93 // Default ipkg run-time arguments
90 m_ipkgArgs.noaction = false; 94 m_ipkgArgs.noaction = false;
91 m_ipkgArgs.force_defaults = true; 95 m_ipkgArgs.force_defaults = true;
92} 96}
93 97
94OIpkg::~OIpkg() 98OIpkg::~OIpkg()
95{ 99{
96 // Upon destruction, ensure that items in config list are deleted with list 100 // Upon destruction, ensure that items in config list are deleted with list
97 if ( m_confInfo ) 101 if ( m_confInfo )
98 m_confInfo->setAutoDelete( true ); 102 m_confInfo->setAutoDelete( true );
99 103
100 // Free up libipkg resources 104 // Free up libipkg resources
101 ipkg_deinit( &m_ipkgArgs ); 105 ipkg_deinit( &m_ipkgArgs );
102} 106}
103 107
104OConfItemList *OIpkg::configItems() 108OConfItemList *OIpkg::configItems()
105{ 109{
106 // Retrieve all configuration items 110 // Retrieve all configuration items
107 return filterConfItems(); 111 return filterConfItems();
108} 112}
109 113
110OConfItemList *OIpkg::servers() 114OConfItemList *OIpkg::servers()
111{ 115{
112 // Retrieve only servers 116 // Retrieve only servers
113 return filterConfItems( OConfItem::Source ); 117 return filterConfItems( OConfItem::Source );
114} 118}
115 119
116OConfItemList *OIpkg::destinations() 120OConfItemList *OIpkg::destinations()
117{ 121{
118 // Retrieve only destinations 122 // Retrieve only destinations
119 return filterConfItems( OConfItem::Destination ); 123 return filterConfItems( OConfItem::Destination );
120} 124}
121 125
122OConfItemList *OIpkg::options() 126OConfItemList *OIpkg::options()
123{ 127{
124 // Retrieve only destinations 128 // Retrieve only destinations
125 return filterConfItems( OConfItem::Option ); 129 return filterConfItems( OConfItem::Option );
126} 130}
127 131
128void OIpkg::setConfigItems( OConfItemList *configList ) 132void OIpkg::setConfigItems( OConfItemList *configList )
129{ 133{
130 if ( m_confInfo ) 134 if ( m_confInfo )
131 delete m_confInfo; 135 delete m_confInfo;
132 136
133 m_confInfo = configList; 137 m_confInfo = configList;
134 138
135 // Write out new /etc/ipkg.conf 139 // Write out new /etc/ipkg.conf
136 QFile confFile( IPKG_CONF ); 140 QFile confFile( IPKG_CONF );
137 if ( confFile.open( IO_WriteOnly ) ) 141 if ( confFile.open( IO_WriteOnly ) )
138 { 142 {
139 QTextStream confStream( &confFile ); 143 QTextStream confStream( &confFile );
140 confStream << "# Generated by Opie Package Manager\n\n"; 144 confStream << "# Generated by Opie Package Manager\n\n";
141 145
142 OConfItemListIterator it( *m_confInfo ); 146 OConfItemListIterator it( *m_confInfo );
143 for ( ; it.current(); ++it ) 147 for ( ; it.current(); ++it )
144 { 148 {
145 OConfItem *item = it.current(); 149 OConfItem *item = it.current();
146 150
147 // Only write out valid conf items 151 // Only write out valid conf items
148 if ( item->type() != OConfItem::NotDefined ) 152 if ( item->type() != OConfItem::NotDefined )
149 { 153 {
150 QString confLine; 154 QString confLine;
151 if ( !item->active() ) 155 if ( !item->active() )
152 confLine = "#"; 156 confLine = "#";
153 157
154 switch ( item->type() ) 158 switch ( item->type() )
155 { 159 {
156 case OConfItem::Source : 160 case OConfItem::Source :
157 { 161 {
158 if ( item->features().contains( "Compressed" ) ) 162 if ( item->features().contains( "Compressed" ) )
159 confLine.append( "src/gz " ); 163 confLine.append( "src/gz " );
160 else 164 else
161 confLine.append( "src " ); 165 confLine.append( "src " );
162 } 166 }
163 break; 167 break;
164 case OConfItem::Destination : confLine.append( "dest " ); break; 168 case OConfItem::Destination : confLine.append( "dest " ); break;
165 case OConfItem::Option : confLine.append( "option " ); break; 169 case OConfItem::Option : confLine.append( "option " ); break;
166 case OConfItem::Arch : confLine.append( "arch " ); break; 170 case OConfItem::Arch : confLine.append( "arch " ); break;
167 default : break; 171 default : break;
168 }; 172 };
169 173
170 confStream << confLine << " " << item->name() << " " << item->value() << "\n"; 174 confStream << confLine << " " << item->name() << " " << item->value() << "\n";
171 } 175 }
172 } 176 }
173 177
174 confFile.close(); 178 confFile.close();
175 } 179 }
176 else 180 else
177 { 181 {
178 // Problem writing to /etc/ipkg.conf, exit before removing other conf files 182 // Problem writing to /etc/ipkg.conf, exit before removing other conf files
179 return; 183 return;
180 } 184 }
181 185
182 // Delete /etc/ipkg/*.conf files (/etc/ipkg.conf should now have all settings 186 // Delete /etc/ipkg/*.conf files (/etc/ipkg.conf should now have all settings
183 QStringList confFiles; 187 QStringList confFiles;
184 QDir confDir( IPKG_CONF_DIR ); 188 QDir confDir( IPKG_CONF_DIR );
185 if ( confDir.exists() ) 189 if ( confDir.exists() )
186 { 190 {
187 confDir.setNameFilter( "*.conf" ); 191 confDir.setNameFilter( "*.conf" );
188 confDir.setFilter( QDir::Files ); 192 confDir.setFilter( QDir::Files );
189 confFiles = confDir.entryList( "*.conf", QDir::Files ); 193 confFiles = confDir.entryList( "*.conf", QDir::Files );
190 194
191 QStringList::Iterator lastFile = confFiles.end(); 195 QStringList::Iterator lastFile = confFiles.end();
192 for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it ) 196 for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it )
193 { 197 {
194 // Create absolute file path if necessary 198 // Create absolute file path if necessary
195 QString absFile = (*it); 199 QString absFile = (*it);
196 if ( !absFile.startsWith( "/" ) ) 200 if ( !absFile.startsWith( "/" ) )
197 absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); 201 absFile.prepend( QString( IPKG_CONF_DIR ) + "/" );
198 202
199 // Delete file 203 // Delete file
200 QFile::remove( absFile ); 204 QFile::remove( absFile );
201 } 205 }
202 } 206 }
203 207
204 // Reinitialize libipkg to pick up new configuration 208 // Reinitialize libipkg to pick up new configuration
205 ipkg_deinit( &m_ipkgArgs ); 209 ipkg_deinit( &m_ipkgArgs );
206 ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ); 210 ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs );
207 m_ipkgArgs.noaction = false; 211 m_ipkgArgs.noaction = false;
208 m_ipkgArgs.force_defaults = true; 212 m_ipkgArgs.force_defaults = true;
209} 213}
210 214
211void OIpkg::saveSettings() 215void OIpkg::saveSettings()
@@ -237,355 +241,525 @@ OPackageList *OIpkg::availablePackages( const QString &server )
237 // Process all information in package list file 241 // Process all information in package list file
238 OPackage *package = NULL; 242 OPackage *package = NULL;
239 QString line = t.readLine(); 243 QString line = t.readLine();
240 while ( !t.eof() ) 244 while ( !t.eof() )
241 { 245 {
242 // Determine key/value pair 246 // Determine key/value pair
243 int pos = line.find( ':', 0 ); 247 int pos = line.find( ':', 0 );
244 QString key; 248 QString key;
245 if ( pos > -1 ) 249 if ( pos > -1 )
246 key = line.mid( 0, pos ); 250 key = line.mid( 0, pos );
247 else 251 else
248 key = QString::null; 252 key = QString::null;
249 QString value = line.mid( pos+2, line.length()-pos ); 253 QString value = line.mid( pos+2, line.length()-pos );
250 254
251 // Allocate new package and insert into list 255 // Allocate new package and insert into list
252 if ( package == NULL && !key.isEmpty() ) 256 if ( package == NULL && !key.isEmpty() )
253 { 257 {
254 package = new OPackage( value ); 258 package = new OPackage( value );
255 package->setSource( server ); 259 package->setSource( server );
256 pl->append( package ); 260 pl->append( package );
257 } 261 }
258 262
259 // Update package data 263 // Update package data
260 if ( key == "Package" ) 264 if ( key == "Package" )
261 package->setName( value ); 265 package->setName( value );
262 else if ( key == "Version" ) 266 else if ( key == "Version" )
263 package->setVersion( value ); 267 package->setVersion( value );
264 else if ( key == "Section" ) 268 else if ( key == "Section" )
265 package->setCategory( value ); 269 package->setCategory( value );
266 //DataManager::setAvailableCategories( value ); 270 //DataManager::setAvailableCategories( value );
267 else if ( key.isEmpty() && value.isEmpty() ) 271 else if ( key.isEmpty() && value.isEmpty() )
268 package = NULL; 272 package = NULL;
269 273
270 // Skip past all description lines 274 // Skip past all description lines
271 if ( key == "Description" ) 275 if ( key == "Description" )
272 { 276 {
273 line = t.readLine(); 277 line = t.readLine();
274 while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) 278 while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() )
275 line = t.readLine(); 279 line = t.readLine();
276 } 280 }
277 else 281 else
278 line = t.readLine(); 282 line = t.readLine();
279 } 283 }
280 284
281 f.close(); 285 f.close();
282 286
283 return pl; 287 return pl;
284} 288}
285 289
286OPackageList *OIpkg::installedPackages( const QString &destName, const QString &destPath ) 290OPackageList *OIpkg::installedPackages( const QString &destName, const QString &destPath )
287{ 291{
288 // Load Ipkg configuration info if not already cached 292 // Load Ipkg configuration info if not already cached
289 if ( !m_confInfo ) 293 if ( !m_confInfo )
290 loadConfiguration(); 294 loadConfiguration();
291 295
292 // Build new server list (caller is responsible for deleting) 296 // Build new server list (caller is responsible for deleting)
293 OPackageList *pl = new OPackageList; 297 OPackageList *pl = new OPackageList;
294 298
295 // Open status file 299 // Open status file
296 QString path = destPath; 300 QString path = destPath;
297 if ( path.right( 1 ) != "/" ) 301 if ( path.right( 1 ) != "/" )
298 path.append( "/" ); 302 path.append( "/" );
299 path.append( IPKG_STATUS_PATH ); 303 path.append( IPKG_STATUS_PATH );
300 304
301 QFile f( path ); 305 QFile f( path );
302 if ( !f.open( IO_ReadOnly ) ) 306 if ( !f.open( IO_ReadOnly ) )
303 return NULL; 307 return NULL;
304 QTextStream t( &f ); 308 QTextStream t( &f );
305 309
306 // Process all information in status file 310 // Process all information in status file
307 bool newPackage = false; 311 bool newPackage = false;
308 QString line = t.readLine(); 312 QString line = t.readLine();
309 QString name; 313 QString name;
310 QString version; 314 QString version;
311 QString status; 315 QString status;
312 316
313 while ( !t.eof() ) 317 while ( !t.eof() )
314 { 318 {
315 // Determine key/value pair 319 // Determine key/value pair
316 int pos = line.find( ':', 0 ); 320 int pos = line.find( ':', 0 );
317 QString key; 321 QString key;
318 if ( pos > -1 ) 322 if ( pos > -1 )
319 key = line.mid( 0, pos ); 323 key = line.mid( 0, pos );
320 else 324 else
321 key = QString::null; 325 key = QString::null;
322 QString value = line.mid( pos+2, line.length()-pos ); 326 QString value = line.mid( pos+2, line.length()-pos );
323 327
324 // Allocate new package and insert into list 328 // Allocate new package and insert into list
325 if ( newPackage && !key.isEmpty() ) 329 if ( newPackage && !key.isEmpty() )
326 { 330 {
327 // Add to list only if it has a valid name and is installed 331 // Add to list only if it has a valid name and is installed
328 if ( !name.isNull() && status.contains( " installed" ) ) 332 if ( !name.isNull() && status.contains( " installed" ) )
329 { 333 {
330 pl->append( new OPackage( name, QString::null, version, QString::null, destName ) ); 334 pl->append( new OPackage( name, QString::null, version, QString::null, destName ) );
331 name = QString::null; 335 name = QString::null;
332 version = QString::null; 336 version = QString::null;
333 status = QString::null; 337 status = QString::null;
334 338
335 newPackage = false; 339 newPackage = false;
336 } 340 }
337 } 341 }
338 342
339 // Update package data 343 // Update package data
340 if ( key == "Package" ) 344 if ( key == "Package" )
341 name = value; 345 name = value;
342 else if ( key == "Version" ) 346 else if ( key == "Version" )
343 version = value; 347 version = value;
344 else if ( key == "Status" ) 348 else if ( key == "Status" )
345 status = value; 349 status = value;
346 else if ( key.isEmpty() && value.isEmpty() ) 350 else if ( key.isEmpty() && value.isEmpty() )
347 newPackage = true; 351 newPackage = true;
348 352
349 // Skip past all description lines 353 // Skip past all description lines
350 if ( key == "Description" ) 354 if ( key == "Description" )
351 { 355 {
352 line = t.readLine(); 356 line = t.readLine();
353 while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) 357 while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() )
354 line = t.readLine(); 358 line = t.readLine();
355 } 359 }
356 else 360 else
357 line = t.readLine(); 361 line = t.readLine();
358 } 362 }
359 363
360 f.close(); 364 f.close();
361 365
362 return pl; 366 return pl;
363} 367}
364 368
369OConfItem *OIpkg::findConfItem( OConfItem::Type type, const QString &name )
370{
371 // Find configuration item in list
372 OConfItemListIterator configIt( *m_confInfo );
373 OConfItem *config = 0l;
374 for ( ; configIt.current(); ++configIt )
375 {
376 config = configIt.current();
377 if ( config->type() == type && config->name() == name )
378 break;
379 }
380
381 if ( config && config->type() == type && config->name() == name )
382 return config;
383
384 return 0l;
385}
386
365bool OIpkg::executeCommand( OPackage::Command command, const QStringList &parameters, const QString &destination, 387bool OIpkg::executeCommand( OPackage::Command command, const QStringList &parameters, const QString &destination,
366 const QObject *receiver, const char *slotOutput, bool rawOutput ) 388 const QObject *receiver, const char *slotOutput, bool rawOutput )
367{ 389{
368 if ( command == OPackage::NotDefined ) 390 if ( command == OPackage::NotDefined )
369 return false; 391 return false;
370 392
371 // Set ipkg run-time options/arguments 393 // Set ipkg run-time options/arguments
372 m_ipkgArgs.force_depends = ( m_ipkgExecOptions & FORCE_DEPENDS ); 394 m_ipkgArgs.force_depends = ( m_ipkgExecOptions & FORCE_DEPENDS );
373 m_ipkgArgs.force_reinstall = ( m_ipkgExecOptions & FORCE_REINSTALL ); 395 m_ipkgArgs.force_reinstall = ( m_ipkgExecOptions & FORCE_REINSTALL );
374 // TODO m_ipkgArgs.force_remove = ( m_ipkgExecOptions & FORCE_REMOVE ); 396 // TODO m_ipkgArgs.force_remove = ( m_ipkgExecOptions & FORCE_REMOVE );
375 m_ipkgArgs.force_overwrite = ( m_ipkgExecOptions & FORCE_OVERWRITE ); 397 m_ipkgArgs.force_overwrite = ( m_ipkgExecOptions & FORCE_OVERWRITE );
376 m_ipkgArgs.verbosity = m_ipkgExecVerbosity; 398 m_ipkgArgs.verbosity = m_ipkgExecVerbosity;
377 if ( m_ipkgArgs.dest ) 399 if ( m_ipkgArgs.dest )
378 free( m_ipkgArgs.dest ); 400 free( m_ipkgArgs.dest );
379 if ( !destination.isNull() ) 401 if ( !destination.isNull() )
380 { 402 {
381 int len = destination.length() + 1; 403 int len = destination.length() + 1;
382 m_ipkgArgs.dest = (char *)malloc( len ); 404 m_ipkgArgs.dest = (char *)malloc( len );
383 strncpy( m_ipkgArgs.dest, destination, destination.length() ); 405 strncpy( m_ipkgArgs.dest, destination, destination.length() );
384 m_ipkgArgs.dest[ len - 1 ] = '\0'; 406 m_ipkgArgs.dest[ len - 1 ] = '\0';
385 } 407 }
386 else 408 else
387 m_ipkgArgs.dest = 0x0; 409 m_ipkgArgs.dest = 0l;
388 410
389 // Connect output signal to widget 411 // Connect output signal to widget
390 412
391 if ( rawOutput ) 413 if ( !rawOutput )
392 {
393// if ( slotOutput )
394// connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput );
395 }
396 else
397 { 414 {
398 // TODO - connect to local slot and parse output before emitting signalIpkgMessage 415 // TODO - connect to local slot and parse output before emitting signalIpkgMessage
399 } 416 }
400 417
401 switch( command ) 418 switch( command )
402 { 419 {
403 case OPackage::Update : { 420 case OPackage::Update : {
404 connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); 421 connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput );
405 ipkg_lists_update( &m_ipkgArgs ); 422 ipkg_lists_update( &m_ipkgArgs );
406 }; 423 };
407 break; 424 break;
408 case OPackage::Upgrade : { 425 case OPackage::Upgrade : {
409 connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); 426 connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput );
410 ipkg_packages_upgrade( &m_ipkgArgs ); 427 ipkg_packages_upgrade( &m_ipkgArgs );
428
429 // Re-link non-root destinations to make sure everything is in sync
430 OConfItemList *destList = destinations();
431 OConfItemListIterator it( *destList );
432 for ( ; it.current(); ++it )
433 {
434 OConfItem *dest = it.current();
435 if ( dest->name() != "root" )
436 linkPackageDir( dest->name() );
437 }
438 delete destList;
411 }; 439 };
412 break; 440 break;
413 case OPackage::Install : { 441 case OPackage::Install : {
414 connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); 442 connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput );
415 for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) 443 for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it )
416 { 444 {
417 ipkg_packages_install( &m_ipkgArgs, (*it) ); 445 ipkg_packages_install( &m_ipkgArgs, (*it) );
418 } 446 }
447 if ( destination != "root" )
448 linkPackageDir( destination );
419 }; 449 };
420 break; 450 break;
421 case OPackage::Remove : { 451 case OPackage::Remove : {
422 connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); 452 connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput );
453
454 // Get list of destinations for unlinking of packages not installed to root
455 OConfItemList *destList = destinations();
456
423 for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) 457 for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it )
424 { 458 {
459 unlinkPackage( (*it), destList );
425 ipkg_packages_remove( &m_ipkgArgs, (*it), true ); 460 ipkg_packages_remove( &m_ipkgArgs, (*it), true );
426 } 461 }
462
463 delete destList;
427 }; 464 };
428 break; 465 break;
429 case OPackage::Download : { 466 case OPackage::Download : {
430 connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); 467 connect( this, SIGNAL(signalIpkgMessage(const QString &)), receiver, slotOutput );
431 for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) 468 for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it )
432 { 469 {
433 ipkg_packages_download( &m_ipkgArgs, (*it) ); 470 ipkg_packages_download( &m_ipkgArgs, (*it) );
434 } 471 }
435 }; 472 };
436 break; 473 break;
437 case OPackage::Info : { 474 case OPackage::Info : {
438 connect( this, SIGNAL(signalIpkgStatus(char*)), receiver, slotOutput ); 475 connect( this, SIGNAL(signalIpkgStatus(const QString &)), receiver, slotOutput );
439 ipkg_packages_info( &m_ipkgArgs, (*parameters.begin()), &fIpkgStatus, 0x0 ); 476 ipkg_packages_info( &m_ipkgArgs, (*parameters.begin()), &fIpkgStatus, 0l );
440 }; 477 };
441 break; 478 break;
442 case OPackage::Files : { 479 case OPackage::Files : {
443 connect( this, SIGNAL(signalIpkgList(char*)), receiver, slotOutput ); 480 connect( this, SIGNAL(signalIpkgList(const QString &)), receiver, slotOutput );
444 ipkg_package_files( &m_ipkgArgs, (*parameters.begin()), &fIpkgFiles, 0x0 ); 481 ipkg_package_files( &m_ipkgArgs, (*parameters.begin()), &fIpkgFiles, 0l );
445 }; 482 };
446 break; 483 break;
447 default : break; 484 default : break;
448 }; 485 };
449 486
450 return true; 487 return true;
451} 488}
452 489
453void OIpkg::ipkgMessage( char *msg ) 490void OIpkg::ipkgMessage( char *msg )
454{ 491{
455 emit signalIpkgMessage( msg ); 492 emit signalIpkgMessage( msg );
456} 493}
457 494
458void OIpkg::ipkgStatus( char *status ) 495void OIpkg::ipkgStatus( char *status )
459{ 496{
460 emit signalIpkgStatus( status ); 497 emit signalIpkgStatus( status );
461} 498}
462 499
463void OIpkg::ipkgList( char *filelist ) 500void OIpkg::ipkgList( char *filelist )
464{ 501{
465 emit signalIpkgList( filelist ); 502 emit signalIpkgList( filelist );
466} 503}
467 504
468void OIpkg::loadConfiguration() 505void OIpkg::loadConfiguration()
469{ 506{
470 if ( m_confInfo ) 507 if ( m_confInfo )
471 delete m_confInfo; 508 delete m_confInfo;
472 509
473 // Load configuration item list 510 // Load configuration item list
474 m_confInfo = new OConfItemList(); 511 m_confInfo = new OConfItemList();
475 512
476 QStringList confFiles; 513 QStringList confFiles;
477 QDir confDir( IPKG_CONF_DIR ); 514 QDir confDir( IPKG_CONF_DIR );
478 if ( confDir.exists() ) 515 if ( confDir.exists() )
479 { 516 {
480 confDir.setNameFilter( "*.conf" ); 517 confDir.setNameFilter( "*.conf" );
481 confDir.setFilter( QDir::Files ); 518 confDir.setFilter( QDir::Files );
482 confFiles = confDir.entryList( "*.conf", QDir::Files ); 519 confFiles = confDir.entryList( "*.conf", QDir::Files );
483 } 520 }
484 confFiles << IPKG_CONF; 521 confFiles << IPKG_CONF;
485 522
486 QStringList::Iterator lastFile = confFiles.end(); 523 QStringList::Iterator lastFile = confFiles.end();
487 for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it ) 524 for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it )
488 { 525 {
489 // Create absolute file path if necessary 526 // Create absolute file path if necessary
490 QString absFile = (*it); 527 QString absFile = (*it);
491 if ( !absFile.startsWith( "/" ) ) 528 if ( !absFile.startsWith( "/" ) )
492 absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); 529 absFile.prepend( QString( IPKG_CONF_DIR ) + "/" );
493 530
494 // Read in file 531 // Read in file
495 QFile f( absFile ); 532 QFile f( absFile );
496 if ( f.open( IO_ReadOnly ) ) 533 if ( f.open( IO_ReadOnly ) )
497 { 534 {
498 QTextStream s( &f ); 535 QTextStream s( &f );
499 while ( !s.eof() ) 536 while ( !s.eof() )
500 { 537 {
501 538
502 QString line = s.readLine().simplifyWhiteSpace(); 539 QString line = s.readLine().simplifyWhiteSpace();
503 540
504 // Parse line and save info to the conf options list 541 // Parse line and save info to the conf options list
505 if ( !line.isEmpty() ) 542 if ( !line.isEmpty() )
506 { 543 {
507 if ( !line.startsWith( "#" ) || 544 if ( !line.startsWith( "#" ) ||
508 line.startsWith( "#src" ) || 545 line.startsWith( "#src" ) ||
509 line.startsWith( "#dest" ) || 546 line.startsWith( "#dest" ) ||
510 line.startsWith( "#arch" ) || 547 line.startsWith( "#arch" ) ||
511 line.startsWith( "#option" ) ) 548 line.startsWith( "#option" ) )
512 { 549 {
513 int pos = line.find( ' ', 1 ); 550 int pos = line.find( ' ', 1 );
514 551
515 // Type 552 // Type
516 QString typeStr = line.left( pos ); 553 QString typeStr = line.left( pos );
517 OConfItem::Type type; 554 OConfItem::Type type;
518 QString features; 555 QString features;
519 if ( typeStr == "src" || typeStr == "#src" ) 556 if ( typeStr == "src" || typeStr == "#src" )
520 type = OConfItem::Source; 557 type = OConfItem::Source;
521 else if ( typeStr == "src/gz" || typeStr == "#src/gz" ) 558 else if ( typeStr == "src/gz" || typeStr == "#src/gz" )
522 { 559 {
523 type = OConfItem::Source; 560 type = OConfItem::Source;
524 features = "Compressed"; 561 features = "Compressed";
525 } 562 }
526 else if ( typeStr == "dest" || typeStr == "#dest" ) 563 else if ( typeStr == "dest" || typeStr == "#dest" )
527 type = OConfItem::Destination; 564 type = OConfItem::Destination;
528 else if ( typeStr == "option" || typeStr == "#option" ) 565 else if ( typeStr == "option" || typeStr == "#option" )
529 type = OConfItem::Option; 566 type = OConfItem::Option;
530 else if ( typeStr == "arch" || typeStr == "#arch" ) 567 else if ( typeStr == "arch" || typeStr == "#arch" )
531 type = OConfItem::Arch; 568 type = OConfItem::Arch;
532 else 569 else
533 type = OConfItem::NotDefined; 570 type = OConfItem::NotDefined;
534 ++pos; 571 ++pos;
535 int endpos = line.find( ' ', pos ); 572 int endpos = line.find( ' ', pos );
536 573
537 // Name 574 // Name
538 QString name = line.mid( pos, endpos - pos ); 575 QString name = line.mid( pos, endpos - pos );
539 576
540 // Value 577 // Value
541 QString value = ""; 578 QString value = "";
542 if ( endpos > -1 ) 579 if ( endpos > -1 )
543 value = line.right( line.length() - endpos - 1 ); 580 value = line.right( line.length() - endpos - 1 );
544 581
545 // Active 582 // Active
546 bool active = !line.startsWith( "#" ); 583 bool active = !line.startsWith( "#" );
547 584
548 // Add to list 585 // Add to list
549 m_confInfo->append( new OConfItem( type, name, value, features, active ) ); 586 m_confInfo->append( new OConfItem( type, name, value, features, active ) );
550 } 587 }
551 } 588 }
552 } 589 }
553 590
554 f.close(); 591 f.close();
555 } 592 }
556 } 593 }
557 594
558 // Load Ipkg execution options from application configuration file 595 // Load Ipkg execution options from application configuration file
559 if ( m_config ) 596 if ( m_config )
560 { 597 {
561 m_config->setGroup( "Ipkg" ); 598 m_config->setGroup( "Ipkg" );
562 m_ipkgExecOptions = m_config->readNumEntry( "ExecOptions", m_ipkgExecOptions ); 599 m_ipkgExecOptions = m_config->readNumEntry( "ExecOptions", m_ipkgExecOptions );
563 m_ipkgExecVerbosity = m_config->readNumEntry( "Verbosity", m_ipkgExecVerbosity ); 600 m_ipkgExecVerbosity = m_config->readNumEntry( "Verbosity", m_ipkgExecVerbosity );
564 } 601 }
565} 602}
566 603
567OConfItemList *OIpkg::filterConfItems( OConfItem::Type typefilter ) 604OConfItemList *OIpkg::filterConfItems( OConfItem::Type typefilter )
568{ 605{
569 // Load Ipkg configuration info if not already cached 606 // Load Ipkg configuration info if not already cached
570 if ( !m_confInfo ) 607 if ( !m_confInfo )
571 loadConfiguration(); 608 loadConfiguration();
572 609
573 // Build new server list (caller is responsible for deleting) 610 // Build new server list (caller is responsible for deleting)
574 OConfItemList *sl = new OConfItemList; 611 OConfItemList *sl = new OConfItemList;
575 612
576 // If typefilter is empty, retrieve all items 613 // If typefilter is empty, retrieve all items
577 bool retrieveAll = ( typefilter == OConfItem::NotDefined ); 614 bool retrieveAll = ( typefilter == OConfItem::NotDefined );
578 615
579 // Parse configuration info for servers 616 // Parse configuration info for servers
580 OConfItemListIterator it( *m_confInfo ); 617 OConfItemListIterator it( *m_confInfo );
581 for ( ; it.current(); ++it ) 618 for ( ; it.current(); ++it )
582 { 619 {
583 OConfItem *item = it.current(); 620 OConfItem *item = it.current();
584 if ( retrieveAll || item->type() == typefilter ) 621 if ( retrieveAll || item->type() == typefilter )
585 { 622 {
586 sl->append( item ); 623 sl->append( item );
587 } 624 }
588 } 625 }
589 626
590 return sl; 627 return sl;
591} 628}
629
630const QString &OIpkg::rootPath()
631{
632 if ( m_rootPath.isEmpty() )
633 {
634 OConfItem *rootDest = findConfItem( OConfItem::Destination, "root" );
635 rootDest ? m_rootPath = rootDest->value()
636 : m_rootPath = '/';
637 if ( m_rootPath.right( 1 ) == '/' )
638 m_rootPath.truncate( m_rootPath.length() - 1 );
639 }
640 return m_rootPath;
641}
642
643void OIpkg::linkPackageDir( const QString &dest )
644{
645 if ( !dest.isNull() )
646 {
647 OConfItem *destConfItem = findConfItem( OConfItem::Destination, dest );
648
649 emit signalIpkgMessage( tr( "Linking packages installed in: %1" ).arg( dest ) );
650
651 // Set package destination directory
652 QString destDir = destConfItem->value();
653 QString destInfoDir = destDir;
654 if ( destInfoDir.right( 1 ) != '/' )
655 destInfoDir.append( '/' );
656 destInfoDir.append( IPKG_INFO_PATH );
657
658 // Get list of installed packages in destination
659 QDir packageDir( destInfoDir );
660 QStringList packageFiles;
661 if ( packageDir.exists() )
662 {
663 packageDir.setNameFilter( "*.list" );
664 packageDir.setFilter( QDir::Files );
665 packageFiles = packageDir.entryList( "*.list", QDir::Files );
666 }
667
668 // Link all files for every package installed in desination
669 QStringList::Iterator lastFile = packageFiles.end();
670 for ( QStringList::Iterator it = packageFiles.begin(); it != lastFile; ++it )
671 {
672 //emit signalIpkgMessage( QString( "Processing: %1/%2" ).arg( destInfoDir ).arg (*it) );
673 QString packageFileName = destInfoDir;
674 packageFileName.append( '/' );
675 packageFileName.append( (*it) );
676 QFile packageFile( packageFileName );
677 if ( packageFile.open( IO_ReadOnly ) )
678 {
679 QTextStream t( &packageFile );
680 QString linkFile;
681 while ( !t.eof() )
682 {
683 // Get the name of the file to link and build the sym link filename
684 linkFile = t.readLine();
685 QString linkDest( linkFile.right( linkFile.length() - destDir.length() ) );
686 linkDest.prepend( rootPath() );
687
688 // If file installed file is actually symbolic link, use actual file for linking
689 QFileInfo fileInfo( linkFile );
690 if ( fileInfo.isSymLink() && !fileInfo.readLink().isEmpty() )
691 linkFile = fileInfo.readLink();
692
693 // See if directory exists in 'root', if not, create
694 fileInfo.setFile( linkDest );
695 QString linkDestDirName = fileInfo.dirPath( true );
696 QDir linkDestDir( linkDestDirName );
697 if ( !linkDestDir.exists() )
698 {
699 linkDestDir.mkdir( linkDestDirName );
700 }
701 else
702 {
703 // Remove any previous link to make sure we will be pointing to the current version
704 if ( QFile::exists( linkDest ) )
705 QFile::remove( linkDest );
706 }
707
708 // Link the file
709 //emit signalIpkgMessage( QString( "Linking '%1' to '%2'" ).arg( linkFile ).arg( linkDest ) );
710 if ( symlink( linkFile, linkDest ) == -1 )
711 emit signalIpkgMessage( tr( "Error linkling '%1' to '%2'" )
712 .arg( linkFile )
713 .arg( linkDest ) );
714 }
715 packageFile.close();
716 }
717 }
718 }
719}
720
721void OIpkg::unlinkPackage( const QString &package, OConfItemList *destList )
722{
723 if ( !package.isNull() )
724 {
725 // Find destination package is installed in
726 if ( destList )
727 {
728 OConfItemListIterator it( *destList );
729 for ( ; it.current(); ++it )
730 {
731 OConfItem *dest = it.current();
732 QString destInfoFileName = QString( "%1/%2/%3.list" ).arg( dest->value() )
733 .arg( IPKG_INFO_PATH )
734 .arg( package );
735 //emit signalIpkgMessage( QString( "Looking for '%1'" ).arg ( destInfoFileName ) );
736
737 // If found and destination is not 'root', remove symbolic links
738 if ( QFile::exists( destInfoFileName ) && dest->name() != "root" )
739 {
740 QFile destInfoFile( destInfoFileName );
741 if ( destInfoFile.open( IO_ReadOnly ) )
742 {
743 QTextStream t( &destInfoFile );
744 QString linkFile;
745 while ( !t.eof() )
746 {
747 // Get the name of the file to link and build the sym link filename
748 linkFile = t.readLine();
749 QString linkDest( linkFile.right( linkFile.length() -
750 dest->value().length() ) );
751 linkDest.prepend( rootPath() );
752
753 //emit signalIpkgMessage( QString( "Deleting: '%1'" ).arg( linkDest ) );
754 QFile::remove( linkDest );
755 }
756 destInfoFile.close();
757 }
758
759 emit signalIpkgMessage( tr( "Links removed for: %1" ).arg( package ) );
760 return;
761 }
762 }
763 }
764 }
765}
diff --git a/noncore/settings/packagemanager/oipkg.h b/noncore/settings/packagemanager/oipkg.h
index 3c96200..0263f50 100644
--- a/noncore/settings/packagemanager/oipkg.h
+++ b/noncore/settings/packagemanager/oipkg.h
@@ -1,108 +1,116 @@
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
35#include "oconfitem.h" 35#include "oconfitem.h"
36#include "opackage.h" 36#include "opackage.h"
37 37
38#include <qpe/config.h> 38#include <qpe/config.h>
39 39
40#include <qobject.h> 40#include <qobject.h>
41 41
42extern "C" { 42extern "C" {
43#include <libipkg.h> 43#include <libipkg.h>
44}; 44};
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 = 0l, QObject *parent = 0l, const char *name = 0l );
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 OConfItem *findConfItem( OConfItem::Type type = OConfItem::NotDefined,
81 const QString &name = QString::null );
82
80 bool executeCommand( OPackage::Command command = OPackage::NotDefined, 83 bool executeCommand( OPackage::Command command = OPackage::NotDefined,
81 const QStringList &parameters = QStringList(), 84 const QStringList &parameters = QStringList(),
82 const QString &destination = QString::null, 85 const QString &destination = QString::null,
83 const QObject *receiver = 0x0, 86 const QObject *receiver = 0l,
84 const char *slotOutput = 0x0, 87 const char *slotOutput = 0l,
85 bool rawOutput = true ); 88 bool rawOutput = true );
86 void abortCommand(); 89 void abortCommand();
87 90
88 void ipkgMessage( char *msg ); 91 void ipkgMessage( char *msg );
89 void ipkgStatus( char *status ); 92 void ipkgStatus( char *status );
90 void ipkgList( char *filelist ); 93 void ipkgList( char *filelist );
91 94
92private: 95private:
93 Config *m_config; // Pointer to application configuration file 96 Config *m_config; // Pointer to application configuration file
94 args_t m_ipkgArgs; // libipkg configuration arguments 97 args_t m_ipkgArgs; // libipkg configuration arguments
95 OConfItemList *m_confInfo; // Contains info from all Ipkg configuration files 98 OConfItemList *m_confInfo; // Contains info from all Ipkg configuration files
96 int m_ipkgExecOptions; // Bit-mapped flags for Ipkg execution options 99 int m_ipkgExecOptions; // Bit-mapped flags for Ipkg execution options
97 int m_ipkgExecVerbosity; // Ipkg execution verbosity level 100 int m_ipkgExecVerbosity; // Ipkg execution verbosity level
101 QString m_rootPath; // Directory path where the 'root' destination is located
98 102
99 void loadConfiguration(); 103 void loadConfiguration();
100 OConfItemList *filterConfItems( OConfItem::Type typefilter = OConfItem::NotDefined ); 104 OConfItemList *filterConfItems( OConfItem::Type typefilter = OConfItem::NotDefined );
105 const QString &rootPath();
106 void linkPackageDir( const QString &dest = QString::null );
107 void unlinkPackage( const QString &package = QString::null,
108 OConfItemList *destList = 0l );
101 109
102signals: 110signals:
103 void signalIpkgMessage( char *msg ); 111 void signalIpkgMessage( const QString &msg );
104 void signalIpkgStatus( char *status ); 112 void signalIpkgStatus( const QString &status );
105 void signalIpkgList( char *filelist ); 113 void signalIpkgList( const QString &filelist );
106}; 114};
107 115
108#endif 116#endif
diff --git a/noncore/settings/packagemanager/oipkgconfigdlg.cpp b/noncore/settings/packagemanager/oipkgconfigdlg.cpp
index 77ad220..e6d6a81 100644
--- a/noncore/settings/packagemanager/oipkgconfigdlg.cpp
+++ b/noncore/settings/packagemanager/oipkgconfigdlg.cpp
@@ -1,252 +1,252 @@
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 "oipkgconfigdlg.h" 32#include "oipkgconfigdlg.h"
33 33
34#include <opie2/ofiledialog.h> 34#include <opie2/ofiledialog.h>
35 35
36#include <qpe/qpeapplication.h> 36#include <qpe/qpeapplication.h>
37#include <qpe/resource.h> 37#include <qpe/resource.h>
38 38
39#include <qcheckbox.h> 39#include <qcheckbox.h>
40#include <qcombobox.h> 40#include <qcombobox.h>
41#include <qgroupbox.h> 41#include <qgroupbox.h>
42#include <qlabel.h> 42#include <qlabel.h>
43#include <qlineedit.h> 43#include <qlineedit.h>
44#include <qlistbox.h> 44#include <qlistbox.h>
45#include <qpushbutton.h> 45#include <qpushbutton.h>
46#include <qscrollview.h> 46#include <qscrollview.h>
47#include <qwhatsthis.h> 47#include <qwhatsthis.h>
48 48
49OIpkgConfigDlg::OIpkgConfigDlg( OIpkg *ipkg, bool installOptions, QWidget *parent ) 49OIpkgConfigDlg::OIpkgConfigDlg( OIpkg *ipkg, bool installOptions, QWidget *parent )
50 : QDialog( parent, QString::null, true, WStyle_ContextHelp ) 50 : QDialog( parent, QString::null, true, WStyle_ContextHelp )
51 , m_ipkg( ipkg ) 51 , m_ipkg( ipkg )
52 , m_configs( 0l ) 52 , m_configs( 0l )
53 , m_installOptions( installOptions ) 53 , m_installOptions( installOptions )
54 , m_serverCurrent( -1 ) 54 , m_serverCurrent( -1 )
55 , m_destCurrent( -1 ) 55 , m_destCurrent( -1 )
56 , m_layout( this, 2, 4 ) 56 , m_layout( this, 2, 4 )
57 , m_tabWidget( this ) 57 , m_tabWidget( this )
58{ 58{
59 setCaption( tr( "Configuration" ) ); 59 setCaption( tr( "Configuration" ) );
60 60
61 // Initialize configuration widgets 61 // Initialize configuration widgets
62 if ( !installOptions ) 62 if ( !installOptions )
63 { 63 {
64 initServerWidget(); 64 initServerWidget();
65 initDestinationWidget(); 65 initDestinationWidget();
66 initProxyWidget(); 66 initProxyWidget();
67 } 67 }
68 initOptionsWidget(); 68 initOptionsWidget();
69 69
70 // Load configuration information 70 // Load configuration information
71 initData(); 71 initData();
72 72
73 // Setup tabs for all info 73 // Setup tabs for all info
74 m_layout.addWidget( &m_tabWidget ); 74 m_layout.addWidget( &m_tabWidget );
75 if ( !m_installOptions ) 75 if ( !m_installOptions )
76 { 76 {
77 m_tabWidget.addTab( m_serverWidget, "packagemanager/servertab", tr( "Servers" ) ); 77 m_tabWidget.addTab( m_serverWidget, "packagemanager/servertab", tr( "Servers" ) );
78 m_tabWidget.addTab( m_destWidget, "packagemanager/desttab", tr( "Destinations" ) ); 78 m_tabWidget.addTab( m_destWidget, "packagemanager/desttab", tr( "Destinations" ) );
79 m_tabWidget.addTab( m_proxyWidget, "packagemanager/proxytab", tr( "Proxies" ) ); 79 m_tabWidget.addTab( m_proxyWidget, "packagemanager/proxytab", tr( "Proxies" ) );
80 m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) ); 80 m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) );
81 m_tabWidget.setCurrentTab( tr( "Servers" ) ); 81 m_tabWidget.setCurrentTab( tr( "Servers" ) );
82 } 82 }
83 else 83 else
84 { 84 {
85 m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) ); 85 m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) );
86 } 86 }
87} 87}
88 88
89void OIpkgConfigDlg::accept() 89void OIpkgConfigDlg::accept()
90{ 90{
91 // Save server, destination and proxy configuration 91 // Save server, destination and proxy configuration
92 if ( !m_installOptions ) 92 if ( !m_installOptions )
93 { 93 {
94 // Update proxy information before saving settings 94 // Update proxy information before saving settings
95 OConfItem *confItem = findConfItem( OConfItem::Option, "http_proxy" ); 95 OConfItem *confItem = m_ipkg->findConfItem( OConfItem::Option, "http_proxy" );
96 if ( confItem ) 96 if ( confItem )
97 { 97 {
98 confItem->setValue( m_proxyHttpServer->text() ); 98 confItem->setValue( m_proxyHttpServer->text() );
99 confItem->setActive( m_proxyHttpActive->isChecked() ); 99 confItem->setActive( m_proxyHttpActive->isChecked() );
100 } 100 }
101 else 101 else
102 m_configs->append( new OConfItem( OConfItem::Option, "http_proxy", 102 m_configs->append( new OConfItem( OConfItem::Option, "http_proxy",
103 m_proxyHttpServer->text(), QString::null, 103 m_proxyHttpServer->text(), QString::null,
104 m_proxyHttpActive->isChecked() ) ); 104 m_proxyHttpActive->isChecked() ) );
105 105
106 confItem = findConfItem( OConfItem::Option, "ftp_proxy" ); 106 confItem = m_ipkg->findConfItem( OConfItem::Option, "ftp_proxy" );
107 if ( confItem ) 107 if ( confItem )
108 { 108 {
109 confItem->setValue( m_proxyFtpServer->text() ); 109 confItem->setValue( m_proxyFtpServer->text() );
110 confItem->setActive( m_proxyFtpActive->isChecked() ); 110 confItem->setActive( m_proxyFtpActive->isChecked() );
111 } 111 }
112 else 112 else
113 m_configs->append( new OConfItem( OConfItem::Option, "ftp_proxy", 113 m_configs->append( new OConfItem( OConfItem::Option, "ftp_proxy",
114 m_proxyFtpServer->text(), QString::null, 114 m_proxyFtpServer->text(), QString::null,
115 m_proxyFtpActive->isChecked() ) ); 115 m_proxyFtpActive->isChecked() ) );
116 116
117 confItem = findConfItem( OConfItem::Option, "proxy_username" ); 117 confItem = m_ipkg->findConfItem( OConfItem::Option, "proxy_username" );
118 if ( confItem ) 118 if ( confItem )
119 confItem->setValue( m_proxyUsername->text() ); 119 confItem->setValue( m_proxyUsername->text() );
120 else 120 else
121 m_configs->append( new OConfItem( OConfItem::Option, "proxy_username", 121 m_configs->append( new OConfItem( OConfItem::Option, "proxy_username",
122 m_proxyUsername->text() ) ); 122 m_proxyUsername->text() ) );
123 123
124 confItem = findConfItem( OConfItem::Option, "proxy_password" ); 124 confItem = m_ipkg->findConfItem( OConfItem::Option, "proxy_password" );
125 if ( confItem ) 125 if ( confItem )
126 confItem->setValue( m_proxyPassword->text() ); 126 confItem->setValue( m_proxyPassword->text() );
127 else 127 else
128 m_configs->append( new OConfItem( OConfItem::Option, "proxy_password", 128 m_configs->append( new OConfItem( OConfItem::Option, "proxy_password",
129 m_proxyPassword->text() ) ); 129 m_proxyPassword->text() ) );
130 130
131 m_ipkg->setConfigItems( m_configs ); 131 m_ipkg->setConfigItems( m_configs );
132 } 132 }
133 133
134 // Save options configuration 134 // Save options configuration
135 int options = 0; 135 int options = 0;
136 if ( m_optForceDepends->isChecked() ) 136 if ( m_optForceDepends->isChecked() )
137 options |= FORCE_DEPENDS; 137 options |= FORCE_DEPENDS;
138 if ( m_optForceReinstall->isChecked() ) 138 if ( m_optForceReinstall->isChecked() )
139 options |= FORCE_REINSTALL; 139 options |= FORCE_REINSTALL;
140 if ( m_optForceRemove->isChecked() ) 140 if ( m_optForceRemove->isChecked() )
141 options |= FORCE_REMOVE; 141 options |= FORCE_REMOVE;
142 if ( m_optForceOverwrite->isChecked() ) 142 if ( m_optForceOverwrite->isChecked() )
143 options |= FORCE_OVERWRITE; 143 options |= FORCE_OVERWRITE;
144 m_ipkg->setIpkgExecOptions( options ); 144 m_ipkg->setIpkgExecOptions( options );
145 m_ipkg->setIpkgExecVerbosity( m_optVerboseIpkg->currentItem() ); 145 m_ipkg->setIpkgExecVerbosity( m_optVerboseIpkg->currentItem() );
146 146
147 QDialog::accept(); 147 QDialog::accept();
148} 148}
149 149
150void OIpkgConfigDlg::reject() 150void OIpkgConfigDlg::reject()
151{ 151{
152 if ( m_configs ) 152 if ( m_configs )
153 delete m_configs; 153 delete m_configs;
154} 154}
155 155
156void OIpkgConfigDlg::initServerWidget() 156void OIpkgConfigDlg::initServerWidget()
157{ 157{
158 m_serverWidget = new QWidget( this ); 158 m_serverWidget = new QWidget( this );
159 159
160 // Initialize UI 160 // Initialize UI
161 QVBoxLayout *vb = new QVBoxLayout( m_serverWidget ); 161 QVBoxLayout *vb = new QVBoxLayout( m_serverWidget );
162 QScrollView *sv = new QScrollView( m_serverWidget ); 162 QScrollView *sv = new QScrollView( m_serverWidget );
163 vb->addWidget( sv, 0, 0 ); 163 vb->addWidget( sv, 0, 0 );
164 sv->setResizePolicy( QScrollView::AutoOneFit ); 164 sv->setResizePolicy( QScrollView::AutoOneFit );
165 sv->setFrameStyle( QFrame::NoFrame ); 165 sv->setFrameStyle( QFrame::NoFrame );
166 QWidget *container = new QWidget( sv->viewport() ); 166 QWidget *container = new QWidget( sv->viewport() );
167 sv->addChild( container ); 167 sv->addChild( container );
168 QGridLayout *layout = new QGridLayout( container, 2, 3, 2, 4 ); 168 QGridLayout *layout = new QGridLayout( container, 2, 3, 2, 4 );
169 169
170 m_serverList = new QListBox( container ); 170 m_serverList = new QListBox( container );
171 QWhatsThis::add( m_serverList, tr( "This is a list of all servers configured. Select one here to edit or delete, or add a new one below." ) ); 171 QWhatsThis::add( m_serverList, tr( "This is a list of all servers configured. Select one here to edit or delete, or add a new one below." ) );
172 m_serverList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); 172 m_serverList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
173 connect( m_serverList, SIGNAL(highlighted(int)), this, SLOT(slotServerSelected(int)) ); 173 connect( m_serverList, SIGNAL(highlighted(int)), this, SLOT(slotServerSelected(int)) );
174 layout->addMultiCellWidget( m_serverList, 0, 0, 0, 2 ); 174 layout->addMultiCellWidget( m_serverList, 0, 0, 0, 2 );
175 175
176 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); 176 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container );
177 QWhatsThis::add( btn, tr( "Tap here to create a new entry. Fill in the fields below and then tap on Update." ) ); 177 QWhatsThis::add( btn, tr( "Tap here to create a new entry. Fill in the fields below and then tap on Update." ) );
178 connect( btn, SIGNAL(clicked()), this, SLOT(slotServerNew()) ); 178 connect( btn, SIGNAL(clicked()), this, SLOT(slotServerNew()) );
179 layout->addWidget( btn, 1, 0 ); 179 layout->addWidget( btn, 1, 0 );
180 180
181 m_serverEditBtn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), container ); 181 m_serverEditBtn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), container );
182 m_serverEditBtn->setEnabled( false ); 182 m_serverEditBtn->setEnabled( false );
183 QWhatsThis::add( m_serverEditBtn, tr( "Tap here to edit the entry selected above." ) ); 183 QWhatsThis::add( m_serverEditBtn, tr( "Tap here to edit the entry selected above." ) );
184 connect( m_serverEditBtn, SIGNAL(clicked()), this, SLOT(slotServerEdit()) ); 184 connect( m_serverEditBtn, SIGNAL(clicked()), this, SLOT(slotServerEdit()) );
185 layout->addWidget( m_serverEditBtn, 1, 1 ); 185 layout->addWidget( m_serverEditBtn, 1, 1 );
186 186
187 m_serverDeleteBtn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); 187 m_serverDeleteBtn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container );
188 m_serverDeleteBtn->setEnabled( false ); 188 m_serverDeleteBtn->setEnabled( false );
189 QWhatsThis::add( m_serverDeleteBtn, tr( "Tap here to delete the entry selected above." ) ); 189 QWhatsThis::add( m_serverDeleteBtn, tr( "Tap here to delete the entry selected above." ) );
190 connect( m_serverDeleteBtn, SIGNAL(clicked()), this, SLOT(slotServerDelete()) ); 190 connect( m_serverDeleteBtn, SIGNAL(clicked()), this, SLOT(slotServerDelete()) );
191 layout->addWidget( m_serverDeleteBtn, 1, 2 ); 191 layout->addWidget( m_serverDeleteBtn, 1, 2 );
192} 192}
193 193
194void OIpkgConfigDlg::initDestinationWidget() 194void OIpkgConfigDlg::initDestinationWidget()
195{ 195{
196 m_destWidget = new QWidget( this ); 196 m_destWidget = new QWidget( this );
197 197
198 // Initialize UI 198 // Initialize UI
199 QVBoxLayout *vb = new QVBoxLayout( m_destWidget ); 199 QVBoxLayout *vb = new QVBoxLayout( m_destWidget );
200 QScrollView *sv = new QScrollView( m_destWidget ); 200 QScrollView *sv = new QScrollView( m_destWidget );
201 vb->addWidget( sv, 0, 0 ); 201 vb->addWidget( sv, 0, 0 );
202 sv->setResizePolicy( QScrollView::AutoOneFit ); 202 sv->setResizePolicy( QScrollView::AutoOneFit );
203 sv->setFrameStyle( QFrame::NoFrame ); 203 sv->setFrameStyle( QFrame::NoFrame );
204 QWidget *container = new QWidget( sv->viewport() ); 204 QWidget *container = new QWidget( sv->viewport() );
205 sv->addChild( container ); 205 sv->addChild( container );
206 QGridLayout *layout = new QGridLayout( container, 2, 3, 2, 4 ); 206 QGridLayout *layout = new QGridLayout( container, 2, 3, 2, 4 );
207 207
208 m_destList = new QListBox( container ); 208 m_destList = new QListBox( container );
209 QWhatsThis::add( m_destList, tr( "This is a list of all destinations configured for this device. Select one here to edit or delete, or add a new one below." ) ); 209 QWhatsThis::add( m_destList, tr( "This is a list of all destinations configured for this device. Select one here to edit or delete, or add a new one below." ) );
210 m_destList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); 210 m_destList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
211 connect( m_destList, SIGNAL(highlighted(int)), this, SLOT(slotDestSelected(int)) ); 211 connect( m_destList, SIGNAL(highlighted(int)), this, SLOT(slotDestSelected(int)) );
212 layout->addMultiCellWidget( m_destList, 0, 0, 0, 2 ); 212 layout->addMultiCellWidget( m_destList, 0, 0, 0, 2 );
213 213
214 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); 214 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container );
215 QWhatsThis::add( btn, tr( "Tap here to create a new entry. Fill in the fields below and then tap on Update." ) ); 215 QWhatsThis::add( btn, tr( "Tap here to create a new entry. Fill in the fields below and then tap on Update." ) );
216 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestNew()) ); 216 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestNew()) );
217 layout->addWidget( btn, 1, 0 ); 217 layout->addWidget( btn, 1, 0 );
218 218
219 m_destEditBtn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), container ); 219 m_destEditBtn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Edit" ), container );
220 m_destEditBtn->setEnabled( false ); 220 m_destEditBtn->setEnabled( false );
221 QWhatsThis::add( m_destEditBtn, tr( "Tap here to edit the entry selected above." ) ); 221 QWhatsThis::add( m_destEditBtn, tr( "Tap here to edit the entry selected above." ) );
222 connect( m_destEditBtn, SIGNAL(clicked()), this, SLOT(slotDestEdit()) ); 222 connect( m_destEditBtn, SIGNAL(clicked()), this, SLOT(slotDestEdit()) );
223 layout->addWidget( m_destEditBtn, 1, 1 ); 223 layout->addWidget( m_destEditBtn, 1, 1 );
224 224
225 m_destDeleteBtn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); 225 m_destDeleteBtn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container );
226 m_destDeleteBtn->setEnabled( false ); 226 m_destDeleteBtn->setEnabled( false );
227 QWhatsThis::add( m_destDeleteBtn, tr( "Tap here to delete the entry selected above." ) ); 227 QWhatsThis::add( m_destDeleteBtn, tr( "Tap here to delete the entry selected above." ) );
228 connect( m_destDeleteBtn, SIGNAL(clicked()), this, SLOT(slotDestDelete()) ); 228 connect( m_destDeleteBtn, SIGNAL(clicked()), this, SLOT(slotDestDelete()) );
229 layout->addWidget( m_destDeleteBtn, 1, 2 ); 229 layout->addWidget( m_destDeleteBtn, 1, 2 );
230} 230}
231 231
232void OIpkgConfigDlg::initProxyWidget() 232void OIpkgConfigDlg::initProxyWidget()
233{ 233{
234 m_proxyWidget = new QWidget( this ); 234 m_proxyWidget = new QWidget( this );
235 235
236 // Initialize UI 236 // Initialize UI
237 QVBoxLayout *vb = new QVBoxLayout( m_proxyWidget ); 237 QVBoxLayout *vb = new QVBoxLayout( m_proxyWidget );
238 QScrollView *sv = new QScrollView( m_proxyWidget ); 238 QScrollView *sv = new QScrollView( m_proxyWidget );
239 vb->addWidget( sv, 0, 0 ); 239 vb->addWidget( sv, 0, 0 );
240 sv->setResizePolicy( QScrollView::AutoOneFit ); 240 sv->setResizePolicy( QScrollView::AutoOneFit );
241 sv->setFrameStyle( QFrame::NoFrame ); 241 sv->setFrameStyle( QFrame::NoFrame );
242 QWidget *container = new QWidget( sv->viewport() ); 242 QWidget *container = new QWidget( sv->viewport() );
243 sv->addChild( container ); 243 sv->addChild( container );
244 QGridLayout *layout = new QGridLayout( container, 4, 2, 2, 4 ); 244 QGridLayout *layout = new QGridLayout( container, 4, 2, 2, 4 );
245 245
246 // HTTP proxy server configuration 246 // HTTP proxy server configuration
247 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "HTTP Proxy" ), container ); 247 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "HTTP Proxy" ), container );
248 grpbox->layout()->setSpacing( 2 ); 248 grpbox->layout()->setSpacing( 2 );
249 grpbox->layout()->setMargin( 4 ); 249 grpbox->layout()->setMargin( 4 );
250 layout->addMultiCellWidget( grpbox, 0, 0, 0, 1 ); 250 layout->addMultiCellWidget( grpbox, 0, 0, 0, 1 );
251 QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); 251 QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() );
252 m_proxyHttpServer = new QLineEdit( grpbox ); 252 m_proxyHttpServer = new QLineEdit( grpbox );
@@ -268,385 +268,367 @@ void OIpkgConfigDlg::initProxyWidget()
268 m_proxyFtpActive = new QCheckBox( tr( "Enabled" ), grpbox ); 268 m_proxyFtpActive = new QCheckBox( tr( "Enabled" ), grpbox );
269 QWhatsThis::add( m_proxyFtpActive, tr( "Tap here to enable or disable the FTP proxy server." ) ); 269 QWhatsThis::add( m_proxyFtpActive, tr( "Tap here to enable or disable the FTP proxy server." ) );
270 grplayout->addWidget( m_proxyFtpActive ); 270 grplayout->addWidget( m_proxyFtpActive );
271 271
272 // Proxy server username and password configuration 272 // Proxy server username and password configuration
273 QLabel *label = new QLabel( tr( "Username:" ), container ); 273 QLabel *label = new QLabel( tr( "Username:" ), container );
274 QWhatsThis::add( label, tr( "Enter the username for the proxy servers here." ) ); 274 QWhatsThis::add( label, tr( "Enter the username for the proxy servers here." ) );
275 layout->addWidget( label, 2, 0 ); 275 layout->addWidget( label, 2, 0 );
276 m_proxyUsername = new QLineEdit( container ); 276 m_proxyUsername = new QLineEdit( container );
277 QWhatsThis::add( m_proxyUsername, tr( "Enter the username for the proxy servers here." ) ); 277 QWhatsThis::add( m_proxyUsername, tr( "Enter the username for the proxy servers here." ) );
278 layout->addWidget( m_proxyUsername, 2, 1 ); 278 layout->addWidget( m_proxyUsername, 2, 1 );
279 279
280 label = new QLabel( tr( "Password:" ), container ); 280 label = new QLabel( tr( "Password:" ), container );
281 QWhatsThis::add( label, tr( "Enter the password for the proxy servers here." ) ); 281 QWhatsThis::add( label, tr( "Enter the password for the proxy servers here." ) );
282 layout->addWidget( label, 3, 0 ); 282 layout->addWidget( label, 3, 0 );
283 m_proxyPassword = new QLineEdit( container ); 283 m_proxyPassword = new QLineEdit( container );
284 QWhatsThis::add( m_proxyPassword, tr( "Enter the password for the proxy servers here." ) ); 284 QWhatsThis::add( m_proxyPassword, tr( "Enter the password for the proxy servers here." ) );
285 layout->addWidget( m_proxyPassword, 3, 1 ); 285 layout->addWidget( m_proxyPassword, 3, 1 );
286} 286}
287 287
288void OIpkgConfigDlg::initOptionsWidget() 288void OIpkgConfigDlg::initOptionsWidget()
289{ 289{
290 m_optionsWidget = new QWidget( this ); 290 m_optionsWidget = new QWidget( this );
291 291
292 // Initialize UI 292 // Initialize UI
293 QVBoxLayout *vb = new QVBoxLayout( m_optionsWidget ); 293 QVBoxLayout *vb = new QVBoxLayout( m_optionsWidget );
294 QScrollView *sv = new QScrollView( m_optionsWidget ); 294 QScrollView *sv = new QScrollView( m_optionsWidget );
295 vb->addWidget( sv, 0, 0 ); 295 vb->addWidget( sv, 0, 0 );
296 sv->setResizePolicy( QScrollView::AutoOneFit ); 296 sv->setResizePolicy( QScrollView::AutoOneFit );
297 sv->setFrameStyle( QFrame::NoFrame ); 297 sv->setFrameStyle( QFrame::NoFrame );
298 QWidget *container = new QWidget( sv->viewport() ); 298 QWidget *container = new QWidget( sv->viewport() );
299 sv->addChild( container ); 299 sv->addChild( container );
300 QVBoxLayout *layout = new QVBoxLayout( container, 2, 4 ); 300 QVBoxLayout *layout = new QVBoxLayout( container, 2, 4 );
301 301
302 m_optForceDepends = new QCheckBox( tr( "Force Depends" ), container ); 302 m_optForceDepends = new QCheckBox( tr( "Force Depends" ), container );
303 QWhatsThis::add( m_optForceDepends, tr( "Tap here to enable or disable the '-force-depends' option for Ipkg." ) ); 303 QWhatsThis::add( m_optForceDepends, tr( "Tap here to enable or disable the '-force-depends' option for Ipkg." ) );
304 layout->addWidget( m_optForceDepends ); 304 layout->addWidget( m_optForceDepends );
305 305
306 m_optForceReinstall = new QCheckBox( tr( "Force Reinstall" ), container ); 306 m_optForceReinstall = new QCheckBox( tr( "Force Reinstall" ), container );
307 QWhatsThis::add( m_optForceReinstall, tr( "Tap here to enable or disable the '-force-reinstall' option for Ipkg." ) ); 307 QWhatsThis::add( m_optForceReinstall, tr( "Tap here to enable or disable the '-force-reinstall' option for Ipkg." ) );
308 layout->addWidget( m_optForceReinstall ); 308 layout->addWidget( m_optForceReinstall );
309 309
310 m_optForceRemove = new QCheckBox( tr( "Force Remove" ), container ); 310 m_optForceRemove = new QCheckBox( tr( "Force Remove" ), container );
311 QWhatsThis::add( m_optForceRemove, tr( "Tap here to enable or disable the '-force-removal-of-dependent-packages' option for Ipkg." ) ); 311 QWhatsThis::add( m_optForceRemove, tr( "Tap here to enable or disable the '-force-removal-of-dependent-packages' option for Ipkg." ) );
312 layout->addWidget( m_optForceRemove ); 312 layout->addWidget( m_optForceRemove );
313 313
314 m_optForceOverwrite = new QCheckBox( tr( "Force Overwrite" ), container ); 314 m_optForceOverwrite = new QCheckBox( tr( "Force Overwrite" ), container );
315 QWhatsThis::add( m_optForceOverwrite, tr( "Tap here to enable or disable the '-force-overwrite' option for Ipkg." ) ); 315 QWhatsThis::add( m_optForceOverwrite, tr( "Tap here to enable or disable the '-force-overwrite' option for Ipkg." ) );
316 layout->addWidget( m_optForceOverwrite ); 316 layout->addWidget( m_optForceOverwrite );
317 317
318 QLabel *l = new QLabel( tr( "Information Level" ), container ); 318 QLabel *l = new QLabel( tr( "Information Level" ), container );
319 QWhatsThis::add( l, tr( "Select information level for Ipkg." ) ); 319 QWhatsThis::add( l, tr( "Select information level for Ipkg." ) );
320 layout->addWidget( l ); 320 layout->addWidget( l );
321 321
322 m_optVerboseIpkg = new QComboBox( container ); 322 m_optVerboseIpkg = new QComboBox( container );
323 QWhatsThis::add( m_optVerboseIpkg, tr( "Select information level for Ipkg." ) ); 323 QWhatsThis::add( m_optVerboseIpkg, tr( "Select information level for Ipkg." ) );
324 m_optVerboseIpkg->insertItem( tr( "Errors only" ) ); 324 m_optVerboseIpkg->insertItem( tr( "Errors only" ) );
325 m_optVerboseIpkg->insertItem( tr( "Normal messages" ) ); 325 m_optVerboseIpkg->insertItem( tr( "Normal messages" ) );
326 m_optVerboseIpkg->insertItem( tr( "Informative messages" ) ); 326 m_optVerboseIpkg->insertItem( tr( "Informative messages" ) );
327 m_optVerboseIpkg->insertItem( tr( "Troubleshooting output" ) ); 327 m_optVerboseIpkg->insertItem( tr( "Troubleshooting output" ) );
328 layout->addWidget( m_optVerboseIpkg ); 328 layout->addWidget( m_optVerboseIpkg );
329 329
330 layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); 330 layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ) );
331} 331}
332 332
333void OIpkgConfigDlg::initData() 333void OIpkgConfigDlg::initData()
334{ 334{
335 // Read ipkg configuration (server/destination/proxy) information 335 // Read ipkg configuration (server/destination/proxy) information
336 if ( m_ipkg && !m_installOptions ) 336 if ( m_ipkg && !m_installOptions )
337 { 337 {
338 m_configs = m_ipkg->configItems(); 338 m_configs = m_ipkg->configItems();
339 if ( m_configs ) 339 if ( m_configs )
340 { 340 {
341 for ( OConfItemListIterator configIt( *m_configs ); configIt.current(); ++configIt ) 341 for ( OConfItemListIterator configIt( *m_configs ); configIt.current(); ++configIt )
342 { 342 {
343 OConfItem *config = configIt.current(); 343 OConfItem *config = configIt.current();
344 344
345 // Add configuration item to the appropriate dialog controls 345 // Add configuration item to the appropriate dialog controls
346 if ( config ) 346 if ( config )
347 { 347 {
348 if ( config->type() == OConfItem::Source ) 348 if ( config->type() == OConfItem::Source )
349 { 349 {
350 m_serverList->insertItem( config->name() ); 350 m_serverList->insertItem( config->name() );
351 } 351 }
352 else if ( config->type() == OConfItem::Destination ) 352 else if ( config->type() == OConfItem::Destination )
353 { 353 {
354 m_destList->insertItem( config->name() ); 354 m_destList->insertItem( config->name() );
355 } 355 }
356 else if ( config->type() == OConfItem::Option ) 356 else if ( config->type() == OConfItem::Option )
357 { 357 {
358 if ( config->name() == "http_proxy" ) 358 if ( config->name() == "http_proxy" )
359 { 359 {
360 m_proxyHttpServer->setText( config->value() ); 360 m_proxyHttpServer->setText( config->value() );
361 m_proxyHttpActive->setChecked( config->active() ); 361 m_proxyHttpActive->setChecked( config->active() );
362 } 362 }
363 else if ( config->name() == "ftp_proxy" ) 363 else if ( config->name() == "ftp_proxy" )
364 { 364 {
365 m_proxyFtpServer->setText( config->value() ); 365 m_proxyFtpServer->setText( config->value() );
366 m_proxyFtpActive->setChecked( config->active() ); 366 m_proxyFtpActive->setChecked( config->active() );
367 } 367 }
368 else if ( config->name() == "proxy_username" ) 368 else if ( config->name() == "proxy_username" )
369 { 369 {
370 m_proxyUsername->setText( config->value() ); 370 m_proxyUsername->setText( config->value() );
371 } 371 }
372 else if ( config->name() == "proxy_password" ) 372 else if ( config->name() == "proxy_password" )
373 { 373 {
374 m_proxyPassword->setText( config->value() ); 374 m_proxyPassword->setText( config->value() );
375 } 375 }
376 } 376 }
377 } 377 }
378 } 378 }
379 } 379 }
380 } 380 }
381 381
382 // Get Ipkg execution options 382 // Get Ipkg execution options
383 int options = m_ipkg->ipkgExecOptions(); 383 int options = m_ipkg->ipkgExecOptions();
384 if ( options & FORCE_DEPENDS ) 384 if ( options & FORCE_DEPENDS )
385 m_optForceDepends->setChecked( true ); 385 m_optForceDepends->setChecked( true );
386 if ( options & FORCE_REINSTALL ) 386 if ( options & FORCE_REINSTALL )
387 m_optForceReinstall->setChecked( true ); 387 m_optForceReinstall->setChecked( true );
388 if ( options & FORCE_REMOVE ) 388 if ( options & FORCE_REMOVE )
389 m_optForceRemove->setChecked( true ); 389 m_optForceRemove->setChecked( true );
390 if ( options & FORCE_OVERWRITE ) 390 if ( options & FORCE_OVERWRITE )
391 m_optForceOverwrite->setChecked( true ); 391 m_optForceOverwrite->setChecked( true );
392 392
393 m_optVerboseIpkg->setCurrentItem( m_ipkg->ipkgExecVerbosity() ); 393 m_optVerboseIpkg->setCurrentItem( m_ipkg->ipkgExecVerbosity() );
394} 394}
395 395
396OConfItem *OIpkgConfigDlg::findConfItem( OConfItem::Type type, const QString &name )
397{
398 // Find selected server in list
399 OConfItemListIterator configIt( *m_configs );
400 OConfItem *config = 0l;
401 for ( ; configIt.current(); ++configIt )
402 {
403 config = configIt.current();
404 if ( config->type() == type && config->name() == name )
405 break;
406 }
407
408 if ( config && config->type() == type && config->name() == name )
409 return config;
410
411 return 0l;
412}
413
414void OIpkgConfigDlg::slotServerSelected( int index ) 396void OIpkgConfigDlg::slotServerSelected( int index )
415{ 397{
416 m_serverCurrent = index; 398 m_serverCurrent = index;
417 399
418 // Enable Edit and Delete buttons 400 // Enable Edit and Delete buttons
419 m_serverEditBtn->setEnabled( true ); 401 m_serverEditBtn->setEnabled( true );
420 m_serverDeleteBtn->setEnabled( true ); 402 m_serverDeleteBtn->setEnabled( true );
421} 403}
422 404
423void OIpkgConfigDlg::slotServerNew() 405void OIpkgConfigDlg::slotServerNew()
424{ 406{
425 OConfItem *server = new OConfItem( OConfItem::Source ); 407 OConfItem *server = new OConfItem( OConfItem::Source );
426 408
427 OIpkgServerDlg dlg( server, this ); 409 OIpkgServerDlg dlg( server, this );
428 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) 410 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted )
429 { 411 {
430 // Add to configuration option list 412 // Add to configuration option list
431 m_configs->append( server ); 413 m_configs->append( server );
432 m_configs->sort(); 414 m_configs->sort();
433 415
434 // Add to server list 416 // Add to server list
435 m_serverList->insertItem( server->name() ); 417 m_serverList->insertItem( server->name() );
436 m_serverList->setCurrentItem( m_serverList->count() ); 418 m_serverList->setCurrentItem( m_serverList->count() );
437 } 419 }
438 else 420 else
439 delete server; 421 delete server;
440} 422}
441 423
442void OIpkgConfigDlg::slotServerEdit() 424void OIpkgConfigDlg::slotServerEdit()
443{ 425{
444 // Find selected server in list 426 // Find selected server in list
445 OConfItem *server = findConfItem( OConfItem::Source, m_serverList->currentText() ); 427 OConfItem *server = m_ipkg->findConfItem( OConfItem::Source, m_serverList->currentText() );
446 428
447 // Edit server 429 // Edit server
448 if ( server ) 430 if ( server )
449 { 431 {
450 QString origName = server->name(); 432 QString origName = server->name();
451 OIpkgServerDlg dlg( server, this ); 433 OIpkgServerDlg dlg( server, this );
452 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) 434 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted )
453 { 435 {
454 // Check to see if name has changed, if so update the server list 436 // Check to see if name has changed, if so update the server list
455 if ( server->name() != origName ) 437 if ( server->name() != origName )
456 m_serverList->changeItem( server->name(), m_serverCurrent ); 438 m_serverList->changeItem( server->name(), m_serverCurrent );
457 } 439 }
458 } 440 }
459} 441}
460 442
461void OIpkgConfigDlg::slotServerDelete() 443void OIpkgConfigDlg::slotServerDelete()
462{ 444{
463 // Find selected server in list 445 // Find selected server in list
464 OConfItem *server = findConfItem( OConfItem::Source, m_serverList->currentText() ); 446 OConfItem *server = m_ipkg->findConfItem( OConfItem::Source, m_serverList->currentText() );
465 447
466 // Delete server 448 // Delete server
467 if ( server ) 449 if ( server )
468 { 450 {
469 m_configs->removeRef( server ); 451 m_configs->removeRef( server );
470 m_serverList->removeItem( m_serverCurrent ); 452 m_serverList->removeItem( m_serverCurrent );
471 } 453 }
472} 454}
473 455
474void OIpkgConfigDlg::slotDestSelected( int index ) 456void OIpkgConfigDlg::slotDestSelected( int index )
475{ 457{
476 m_destCurrent = index; 458 m_destCurrent = index;
477 459
478 // Enable Edit and Delete buttons 460 // Enable Edit and Delete buttons
479 m_destEditBtn->setEnabled( true ); 461 m_destEditBtn->setEnabled( true );
480 m_destDeleteBtn->setEnabled( true ); 462 m_destDeleteBtn->setEnabled( true );
481} 463}
482 464
483void OIpkgConfigDlg::slotDestNew() 465void OIpkgConfigDlg::slotDestNew()
484{ 466{
485 OConfItem *dest = new OConfItem( OConfItem::Destination ); 467 OConfItem *dest = new OConfItem( OConfItem::Destination );
486 468
487 OIpkgDestDlg dlg( dest, this ); 469 OIpkgDestDlg dlg( dest, this );
488 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) 470 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted )
489 { 471 {
490 // Add to configuration option list 472 // Add to configuration option list
491 m_configs->append( dest ); 473 m_configs->append( dest );
492 m_configs->sort(); 474 m_configs->sort();
493 475
494 // Add to destination list 476 // Add to destination list
495 m_destList->insertItem( dest->name() ); 477 m_destList->insertItem( dest->name() );
496 m_destList->setCurrentItem( m_destList->count() ); 478 m_destList->setCurrentItem( m_destList->count() );
497 } 479 }
498 else 480 else
499 delete dest; 481 delete dest;
500} 482}
501 483
502void OIpkgConfigDlg::slotDestEdit() 484void OIpkgConfigDlg::slotDestEdit()
503{ 485{
504 // Find selected destination in list 486 // Find selected destination in list
505 OConfItem *dest = findConfItem( OConfItem::Destination, m_destList->currentText() ); 487 OConfItem *dest = m_ipkg->findConfItem( OConfItem::Destination, m_destList->currentText() );
506 488
507 // Edit destination 489 // Edit destination
508 if ( dest ) 490 if ( dest )
509 { 491 {
510 QString origName = dest->name(); 492 QString origName = dest->name();
511 OIpkgDestDlg dlg( dest, this ); 493 OIpkgDestDlg dlg( dest, this );
512 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) 494 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted )
513 { 495 {
514 // Check to see if name has changed, if so update the dest list 496 // Check to see if name has changed, if so update the dest list
515 if ( dest->name() != origName ) 497 if ( dest->name() != origName )
516 m_destList->changeItem( dest->name(), m_destCurrent ); 498 m_destList->changeItem( dest->name(), m_destCurrent );
517 } 499 }
518 } 500 }
519} 501}
520 502
521void OIpkgConfigDlg::slotDestDelete() 503void OIpkgConfigDlg::slotDestDelete()
522{ 504{
523 // Find selected destination in list 505 // Find selected destination in list
524 OConfItem *destination = findConfItem( OConfItem::Destination, m_destList->currentText() ); 506 OConfItem *destination = m_ipkg->findConfItem( OConfItem::Destination, m_destList->currentText() );
525 507
526 // Delete destination 508 // Delete destination
527 if ( destination ) 509 if ( destination )
528 { 510 {
529 m_configs->removeRef( destination ); 511 m_configs->removeRef( destination );
530 m_destList->removeItem( m_destCurrent ); 512 m_destList->removeItem( m_destCurrent );
531 } 513 }
532} 514}
533 515
534OIpkgServerDlg::OIpkgServerDlg( OConfItem *server, QWidget *parent ) 516OIpkgServerDlg::OIpkgServerDlg( OConfItem *server, QWidget *parent )
535 : QDialog( parent, QString::null, true, WStyle_ContextHelp ) 517 : QDialog( parent, QString::null, true, WStyle_ContextHelp )
536 , m_server( server ) 518 , m_server( server )
537{ 519{
538 setCaption( tr( "Edit Server" ) ); 520 setCaption( tr( "Edit Server" ) );
539 521
540 // Initialize UI 522 // Initialize UI
541 QVBoxLayout *layout = new QVBoxLayout( this, 2, 4 ); 523 QVBoxLayout *layout = new QVBoxLayout( this, 2, 4 );
542 524
543 m_active = new QCheckBox( tr( "Active" ), this ); 525 m_active = new QCheckBox( tr( "Active" ), this );
544 QWhatsThis::add( m_active, tr( "Tap here to indicate whether this entry is active or not." ) ); 526 QWhatsThis::add( m_active, tr( "Tap here to indicate whether this entry is active or not." ) );
545 layout->addWidget( m_active ); 527 layout->addWidget( m_active );
546 528
547 layout->addStretch(); 529 layout->addStretch();
548 530
549 QLabel *label = new QLabel( tr( "Name:" ), this ); 531 QLabel *label = new QLabel( tr( "Name:" ), this );
550 QWhatsThis::add( label, tr( "Enter the name of this entry here." ) ); 532 QWhatsThis::add( label, tr( "Enter the name of this entry here." ) );
551 layout->addWidget( label ); 533 layout->addWidget( label );
552 m_name = new QLineEdit( this ); 534 m_name = new QLineEdit( this );
553 QWhatsThis::add( m_name, tr( "Enter the name of this entry here." ) ); 535 QWhatsThis::add( m_name, tr( "Enter the name of this entry here." ) );
554 layout->addWidget( m_name ); 536 layout->addWidget( m_name );
555 537
556 layout->addStretch(); 538 layout->addStretch();
557 539
558 label = new QLabel( tr( "Address:" ), this ); 540 label = new QLabel( tr( "Address:" ), this );
559 QWhatsThis::add( label, tr( "Enter the URL address of this entry here." ) ); 541 QWhatsThis::add( label, tr( "Enter the URL address of this entry here." ) );
560 layout->addWidget( label ); 542 layout->addWidget( label );
561 m_location = new QLineEdit( this ); 543 m_location = new QLineEdit( this );
562 QWhatsThis::add( m_location, tr( "Enter the URL address of this entry here." ) ); 544 QWhatsThis::add( m_location, tr( "Enter the URL address of this entry here." ) );
563 layout->addWidget( m_location ); 545 layout->addWidget( m_location );
564 546
565 layout->addStretch(); 547 layout->addStretch();
566 548
567 m_compressed = new QCheckBox( tr( "Compressed server feed" ), this ); 549 m_compressed = new QCheckBox( tr( "Compressed server feed" ), this );
568 QWhatsThis::add( m_compressed, tr( "Tap here to indicate whether the server support compressed archives or not." ) ); 550 QWhatsThis::add( m_compressed, tr( "Tap here to indicate whether the server support compressed archives or not." ) );
569 layout->addWidget( m_compressed ); 551 layout->addWidget( m_compressed );
570 552
571 // Populate initial information 553 // Populate initial information
572 if ( m_server ) 554 if ( m_server )
573 { 555 {
574 m_name->setText( m_server->name() ); 556 m_name->setText( m_server->name() );
575 m_location->setText( m_server->value() ); 557 m_location->setText( m_server->value() );
576 m_compressed->setChecked( m_server->features().contains( "Compressed" ) ); 558 m_compressed->setChecked( m_server->features().contains( "Compressed" ) );
577 m_active->setChecked( m_server->active() ); 559 m_active->setChecked( m_server->active() );
578 } 560 }
579} 561}
580 562
581void OIpkgServerDlg::accept() 563void OIpkgServerDlg::accept()
582{ 564{
583 // Save information entered 565 // Save information entered
584 QString name = m_name->text(); 566 QString name = m_name->text();
585 name.replace( QRegExp( " " ), "_" ); 567 name.replace( QRegExp( " " ), "_" );
586 m_server->setName( name ); 568 m_server->setName( name );
587 m_server->setValue( m_location->text() ); 569 m_server->setValue( m_location->text() );
588 m_compressed->isChecked() ? m_server->setFeatures( "Compressed" ) 570 m_compressed->isChecked() ? m_server->setFeatures( "Compressed" )
589 : m_server->setFeatures( QString::null ); 571 : m_server->setFeatures( QString::null );
590 m_server->setActive( m_active->isChecked() ); 572 m_server->setActive( m_active->isChecked() );
591 573
592 QDialog::accept(); 574 QDialog::accept();
593} 575}
594 576
595OIpkgDestDlg::OIpkgDestDlg( OConfItem *dest, QWidget *parent ) 577OIpkgDestDlg::OIpkgDestDlg( OConfItem *dest, QWidget *parent )
596 : QDialog( parent, QString::null, true, WStyle_ContextHelp ) 578 : QDialog( parent, QString::null, true, WStyle_ContextHelp )
597 , m_dest( dest ) 579 , m_dest( dest )
598{ 580{
599 setCaption( tr( "Edit Destination" ) ); 581 setCaption( tr( "Edit Destination" ) );
600 582
601 // Initialize UI 583 // Initialize UI
602 QVBoxLayout *layout = new QVBoxLayout( this, 2, 4 ); 584 QVBoxLayout *layout = new QVBoxLayout( this, 2, 4 );
603 585
604 m_active = new QCheckBox( tr( "Active" ), this ); 586 m_active = new QCheckBox( tr( "Active" ), this );
605 QWhatsThis::add( m_active, tr( "Tap here to indicate whether this entry is active or not." ) ); 587 QWhatsThis::add( m_active, tr( "Tap here to indicate whether this entry is active or not." ) );
606 layout->addWidget( m_active ); 588 layout->addWidget( m_active );
607 589
608 layout->addStretch(); 590 layout->addStretch();
609 591
610 QLabel *label = new QLabel( tr( "Name:" ), this ); 592 QLabel *label = new QLabel( tr( "Name:" ), this );
611 QWhatsThis::add( label, tr( "Enter the name of this entry here." ) ); 593 QWhatsThis::add( label, tr( "Enter the name of this entry here." ) );
612 layout->addWidget( label ); 594 layout->addWidget( label );
613 m_name = new QLineEdit( this ); 595 m_name = new QLineEdit( this );
614 QWhatsThis::add( m_name, tr( "Enter the name of this entry here." ) ); 596 QWhatsThis::add( m_name, tr( "Enter the name of this entry here." ) );
615 layout->addWidget( m_name ); 597 layout->addWidget( m_name );
616 598
617 layout->addStretch(); 599 layout->addStretch();
618 600
619 label = new QLabel( tr( "Location:" ), this ); 601 label = new QLabel( tr( "Location:" ), this );
620 QWhatsThis::add( label, tr( "Enter the absolute directory path of this entry here." ) ); 602 QWhatsThis::add( label, tr( "Enter the absolute directory path of this entry here." ) );
621 layout->addWidget( label ); 603 layout->addWidget( label );
622 604
623 QHBoxLayout *layout2 = new QHBoxLayout( this, 2, 4 ); 605 QHBoxLayout *layout2 = new QHBoxLayout( this, 2, 4 );
624 layout->addLayout( layout2 ); 606 layout->addLayout( layout2 );
625 607
626 m_location = new QLineEdit( this ); 608 m_location = new QLineEdit( this );
627 QWhatsThis::add( m_location, tr( "Enter the absolute directory path of this entry here." ) ); 609 QWhatsThis::add( m_location, tr( "Enter the absolute directory path of this entry here." ) );
628 layout2->addWidget( m_location ); 610 layout2->addWidget( m_location );
629 QPushButton *btn = new QPushButton( Resource::loadPixmap( "folder" ), QString::null, this ); 611 QPushButton *btn = new QPushButton( Resource::loadPixmap( "folder" ), QString::null, this );
630 btn->setMaximumWidth( btn->height() ); 612 btn->setMaximumWidth( btn->height() );
631 QWhatsThis::add( btn, tr( "Tap here to select the desired location." ) ); 613 QWhatsThis::add( btn, tr( "Tap here to select the desired location." ) );
632 connect( btn, SIGNAL(clicked()), this, SLOT(slotSelectPath()) ); 614 connect( btn, SIGNAL(clicked()), this, SLOT(slotSelectPath()) );
633 layout2->addWidget( btn ); 615 layout2->addWidget( btn );
634 616
635 // Populate initial information 617 // Populate initial information
636 if ( m_dest ) 618 if ( m_dest )
637 { 619 {
638 m_name->setText( m_dest->name() ); 620 m_name->setText( m_dest->name() );
639 m_location->setText( m_dest->value() ); 621 m_location->setText( m_dest->value() );
640 m_active->setChecked( m_dest->active() ); 622 m_active->setChecked( m_dest->active() );
641 } 623 }
642} 624}
643 625
644void OIpkgDestDlg::accept() 626void OIpkgDestDlg::accept()
645{ 627{
646 // Save information entered 628 // Save information entered
647 QString name = m_name->text(); 629 QString name = m_name->text();
648 name.replace( QRegExp( " " ), "_" ); 630 name.replace( QRegExp( " " ), "_" );
649 m_dest->setName( name ); 631 m_dest->setName( name );
650 m_dest->setValue( m_location->text() ); 632 m_dest->setValue( m_location->text() );
651 m_dest->setActive( m_active->isChecked() ); 633 m_dest->setActive( m_active->isChecked() );
652 634
diff --git a/noncore/settings/packagemanager/oipkgconfigdlg.h b/noncore/settings/packagemanager/oipkgconfigdlg.h
index 5b7e91d..0fb2e16 100644
--- a/noncore/settings/packagemanager/oipkgconfigdlg.h
+++ b/noncore/settings/packagemanager/oipkgconfigdlg.h
@@ -1,167 +1,164 @@
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 32
33#ifndef OIPKGCONFIGDLG_H 33#ifndef OIPKGCONFIGDLG_H
34#define OIPKGCONFIGDLG_H 34#define OIPKGCONFIGDLG_H
35 35
36#include <opie2/otabwidget.h> 36#include <opie2/otabwidget.h>
37 37
38#include <qdialog.h> 38#include <qdialog.h>
39#include <qlayout.h> 39#include <qlayout.h>
40 40
41#include "oipkg.h" 41#include "oipkg.h"
42 42
43class QCheckBox; 43class QCheckBox;
44class QComboBox; 44class QComboBox;
45class QLineEdit; 45class QLineEdit;
46class QListBox; 46class QListBox;
47class QPushButton; 47class QPushButton;
48 48
49class OIpkgConfigDlg : public QDialog 49class OIpkgConfigDlg : public QDialog
50{ 50{
51 Q_OBJECT 51 Q_OBJECT
52 52
53public: 53public:
54 OIpkgConfigDlg( OIpkg *ipkg = 0l, bool installOptions = false, QWidget *parent = 0l ); 54 OIpkgConfigDlg( OIpkg *ipkg = 0l, bool installOptions = false, QWidget *parent = 0l );
55 55
56protected slots: 56protected slots:
57 void accept(); 57 void accept();
58 void reject(); 58 void reject();
59 59
60private: 60private:
61 OIpkg *m_ipkg; // Pointer to Ipkg class for retrieving/saving configuration options 61 OIpkg *m_ipkg; // Pointer to Ipkg class for retrieving/saving configuration options
62 OConfItemList *m_configs; // Local list of configuration items 62 OConfItemList *m_configs; // Local list of configuration items
63 63
64 bool m_installOptions; // If true, will only display the Options tab 64 bool m_installOptions; // If true, will only display the Options tab
65 65
66 // Server/Destination cached information 66 // Server/Destination cached information
67 int m_serverCurrent; // Index of currently selected server in m_serverList 67 int m_serverCurrent; // Index of currently selected server in m_serverList
68 int m_destCurrent; // Index of currently selected destination in m_destList 68 int m_destCurrent; // Index of currently selected destination in m_destList
69 69
70 // UI controls 70 // UI controls
71 QVBoxLayout m_layout; // Main dialog layout control 71 QVBoxLayout m_layout; // Main dialog layout control
72 Opie::Ui::OTabWidget m_tabWidget; // Main tab widget control 72 Opie::Ui::OTabWidget m_tabWidget; // Main tab widget control
73 QWidget *m_serverWidget; // Widget containing server configuration controls 73 QWidget *m_serverWidget; // Widget containing server configuration controls
74 QWidget *m_destWidget; // Widget containing destination configuration controls 74 QWidget *m_destWidget; // Widget containing destination configuration controls
75 QWidget *m_proxyWidget; // Widget containing proxy configuration controls 75 QWidget *m_proxyWidget; // Widget containing proxy configuration controls
76 QWidget *m_optionsWidget; // Widget containing ipkg execution configuration controls 76 QWidget *m_optionsWidget; // Widget containing ipkg execution configuration controls
77 77
78 // Server configuration UI controls 78 // Server configuration UI controls
79 QListBox *m_serverList; // Server list selection 79 QListBox *m_serverList; // Server list selection
80 QPushButton *m_serverEditBtn; // Server edit button 80 QPushButton *m_serverEditBtn; // Server edit button
81 QPushButton *m_serverDeleteBtn; // Server edit button 81 QPushButton *m_serverDeleteBtn; // Server edit button
82 82
83 // Destination configuration UI controls 83 // Destination configuration UI controls
84 QListBox *m_destList; // Destination list selection 84 QListBox *m_destList; // Destination list selection
85 QPushButton *m_destEditBtn; // Destination edit button 85 QPushButton *m_destEditBtn; // Destination edit button
86 QPushButton *m_destDeleteBtn; // Destination edit button 86 QPushButton *m_destDeleteBtn; // Destination edit button
87 87
88 // Proxy server configuration UI controls 88 // Proxy server configuration UI controls
89 QLineEdit *m_proxyHttpServer; // HTTP proxy server URL edit box 89 QLineEdit *m_proxyHttpServer; // HTTP proxy server URL edit box
90 QCheckBox *m_proxyHttpActive; // Activate HTTP proxy check box 90 QCheckBox *m_proxyHttpActive; // Activate HTTP proxy check box
91 QLineEdit *m_proxyFtpServer; // FTP proxy server edit box 91 QLineEdit *m_proxyFtpServer; // FTP proxy server edit box
92 QCheckBox *m_proxyFtpActive; // Activate FTP proxy check box 92 QCheckBox *m_proxyFtpActive; // Activate FTP proxy check box
93 QLineEdit *m_proxyUsername; // Proxy server username edit box 93 QLineEdit *m_proxyUsername; // Proxy server username edit box
94 QLineEdit *m_proxyPassword; // Proxy server password edit box 94 QLineEdit *m_proxyPassword; // Proxy server password edit box
95 95
96 // Options configuration UI controls 96 // Options configuration UI controls
97 QCheckBox *m_optForceDepends; // Force depends ipkg option checkbox 97 QCheckBox *m_optForceDepends; // Force depends ipkg option checkbox
98 QCheckBox *m_optForceReinstall; // Force reinstall ipkg option checkbox 98 QCheckBox *m_optForceReinstall; // Force reinstall ipkg option checkbox
99 QCheckBox *m_optForceRemove; // Force remove ipkg option checkbox 99 QCheckBox *m_optForceRemove; // Force remove ipkg option checkbox
100 QCheckBox *m_optForceOverwrite; // Force overwrite ipkg option checkbox 100 QCheckBox *m_optForceOverwrite; // Force overwrite ipkg option checkbox
101 QComboBox *m_optVerboseIpkg; // Ipkg verbosity option selection 101 QComboBox *m_optVerboseIpkg; // Ipkg verbosity option selection
102 102
103 void initServerWidget(); 103 void initServerWidget();
104 void initDestinationWidget(); 104 void initDestinationWidget();
105 void initProxyWidget(); 105 void initProxyWidget();
106 void initOptionsWidget(); 106 void initOptionsWidget();
107 107
108 void initData(); 108 void initData();
109 109
110 OConfItem *findConfItem( OConfItem::Type type = OConfItem::NotDefined,
111 const QString &name = QString::null );
112
113private slots: 110private slots:
114 void slotServerSelected( int index ); 111 void slotServerSelected( int index );
115 void slotServerNew(); 112 void slotServerNew();
116 void slotServerEdit(); 113 void slotServerEdit();
117 void slotServerDelete(); 114 void slotServerDelete();
118 115
119 void slotDestSelected( int index ); 116 void slotDestSelected( int index );
120 void slotDestNew(); 117 void slotDestNew();
121 void slotDestEdit(); 118 void slotDestEdit();
122 void slotDestDelete(); 119 void slotDestDelete();
123}; 120};
124 121
125class OIpkgServerDlg : public QDialog 122class OIpkgServerDlg : public QDialog
126{ 123{
127 Q_OBJECT 124 Q_OBJECT
128 125
129public: 126public:
130 OIpkgServerDlg( OConfItem *server = 0l, QWidget *parent = 0l ); 127 OIpkgServerDlg( OConfItem *server = 0l, QWidget *parent = 0l );
131 128
132protected slots: 129protected slots:
133 void accept(); 130 void accept();
134 131
135private: 132private:
136 OConfItem *m_server; 133 OConfItem *m_server;
137 134
138 // UI controls 135 // UI controls
139 QLineEdit *m_name; // Server name edit box 136 QLineEdit *m_name; // Server name edit box
140 QLineEdit *m_location; // Server location URL edit box 137 QLineEdit *m_location; // Server location URL edit box
141 QCheckBox *m_compressed; // Indicates whether the server is a 'src/gz' feed 138 QCheckBox *m_compressed; // Indicates whether the server is a 'src/gz' feed
142 QCheckBox *m_active; // Indicates whether the server is activated 139 QCheckBox *m_active; // Indicates whether the server is activated
143}; 140};
144 141
145class OIpkgDestDlg : public QDialog 142class OIpkgDestDlg : public QDialog
146{ 143{
147 Q_OBJECT 144 Q_OBJECT
148 145
149public: 146public:
150 OIpkgDestDlg( OConfItem *dest = 0l, QWidget *parent = 0l ); 147 OIpkgDestDlg( OConfItem *dest = 0l, QWidget *parent = 0l );
151 148
152protected slots: 149protected slots:
153 void accept(); 150 void accept();
154 151
155private: 152private:
156 OConfItem *m_dest; 153 OConfItem *m_dest;
157 154
158 // UI controls 155 // UI controls
159 QLineEdit *m_name; // Destination name edit box 156 QLineEdit *m_name; // Destination name edit box
160 QLineEdit *m_location; // Destination location URL edit box 157 QLineEdit *m_location; // Destination location URL edit box
161 QCheckBox *m_active; // Indicates whether the destination is activated 158 QCheckBox *m_active; // Indicates whether the destination is activated
162 159
163private slots: 160private slots:
164 void slotSelectPath(); 161 void slotSelectPath();
165}; 162};
166 163
167#endif 164#endif
diff --git a/noncore/settings/packagemanager/opackagemanager.cpp b/noncore/settings/packagemanager/opackagemanager.cpp
index cbddfe7..c9fdec1 100644
--- a/noncore/settings/packagemanager/opackagemanager.cpp
+++ b/noncore/settings/packagemanager/opackagemanager.cpp
@@ -144,269 +144,251 @@ void OPackageManager::loadInstalledPackages()
144 { 144 {
145 for ( OPackageListIterator packageIt( *packageList ); packageIt.current(); ++packageIt ) 145 for ( OPackageListIterator packageIt( *packageList ); packageIt.current(); ++packageIt )
146 { 146 {
147 OPackage *package = packageIt.current(); 147 OPackage *package = packageIt.current();
148 OPackage *currPackage = m_packages[package->name()]; 148 OPackage *currPackage = m_packages[package->name()];
149 if ( currPackage ) 149 if ( currPackage )
150 { 150 {
151 // Package is in a current feed, update installed version, destination 151 // Package is in a current feed, update installed version, destination
152 currPackage->setVersionInstalled( package->versionInstalled() ); 152 currPackage->setVersionInstalled( package->versionInstalled() );
153 currPackage->setDestination( package->destination() ); 153 currPackage->setDestination( package->destination() );
154 154
155 delete package; 155 delete package;
156 } 156 }
157 else 157 else
158 { 158 {
159 // Package isn't in a current feed, add to list 159 // Package isn't in a current feed, add to list
160 m_packages.insert( package->name(), package ); 160 m_packages.insert( package->name(), package );
161 161
162 // Add category to list if it doesn't already exist 162 // Add category to list if it doesn't already exist
163 if ( m_categories.grep( package->category() ).isEmpty() ) 163 if ( m_categories.grep( package->category() ).isEmpty() )
164 { 164 {
165 m_categories << package->category(); 165 m_categories << package->category();
166 categoryAdded = true; 166 categoryAdded = true;
167 } 167 }
168 } 168 }
169 } 169 }
170 } 170 }
171 } 171 }
172 } 172 }
173 delete destList; 173 delete destList;
174 174
175 // Sort category list if categories were added 175 // Sort category list if categories were added
176 if ( categoryAdded ) 176 if ( categoryAdded )
177 m_categories.sort(); 177 m_categories.sort();
178 } 178 }
179} 179}
180 180
181OPackageList *OPackageManager::packages() 181OPackageList *OPackageManager::packages()
182{ 182{
183 // TODO - look to see if list is loaded, if not, load available & installed 183 // TODO - look to see if list is loaded, if not, load available & installed
184 184
185 OPackageList *pl = new OPackageList; 185 OPackageList *pl = new OPackageList;
186 186
187 for ( QDictIterator<OPackage> packageIt( m_packages ); packageIt.current(); ++packageIt ) 187 for ( QDictIterator<OPackage> packageIt( m_packages ); packageIt.current(); ++packageIt )
188 pl->append( packageIt.current() ); 188 pl->append( packageIt.current() );
189 189
190 return pl; 190 return pl;
191} 191}
192 192
193OPackageList *OPackageManager::filterPackages( const QString &name,const QString &server, 193OPackageList *OPackageManager::filterPackages( const QString &name,const QString &server,
194 const QString &destination, Status status, const QString &category ) 194 const QString &destination, Status status, const QString &category )
195{ 195{
196 // TODO - look to see if list is loaded, if not, load available & installed 196 // TODO - look to see if list is loaded, if not, load available & installed
197 197
198 OPackageList *pl = new OPackageList; 198 OPackageList *pl = new OPackageList;
199 for ( QDictIterator<OPackage> packageIt( m_packages ); packageIt.current(); ++packageIt ) 199 for ( QDictIterator<OPackage> packageIt( m_packages ); packageIt.current(); ++packageIt )
200 { 200 {
201 OPackage *package = packageIt.current(); 201 OPackage *package = packageIt.current();
202 202
203 bool nameMatch = ( name.isNull() || package->name().contains( name ) ); 203 bool nameMatch = ( name.isNull() || package->name().contains( name ) );
204 bool serverMatch = ( server.isNull() || package->source() == server ); 204 bool serverMatch = ( server.isNull() || package->source() == server );
205 bool destinationMatch = ( destination.isNull() || package->destination() == destination ); 205 bool destinationMatch = ( destination.isNull() || package->destination() == destination );
206 bool statusMatch; 206 bool statusMatch;
207 switch ( status ) 207 switch ( status )
208 { 208 {
209 case All : statusMatch = true; 209 case All : statusMatch = true;
210 break; 210 break;
211 case NotInstalled : statusMatch = package->versionInstalled().isNull(); 211 case NotInstalled : statusMatch = package->versionInstalled().isNull();
212 break; 212 break;
213 case Installed : statusMatch = !package->versionInstalled().isNull(); 213 case Installed : statusMatch = !package->versionInstalled().isNull();
214 break; 214 break;
215 case Updated : statusMatch = ( !package->versionInstalled().isNull() && 215 case Updated : statusMatch = ( !package->versionInstalled().isNull() &&
216 compareVersions( package->version(), package->versionInstalled() ) == 1 ); 216 compareVersions( package->version(), package->versionInstalled() ) == 1 );
217 break; 217 break;
218 default : statusMatch = true; 218 default : statusMatch = true;
219 break; 219 break;
220 }; 220 };
221 bool categoryMatch = ( category.isNull() || package->category() == category ); 221 bool categoryMatch = ( category.isNull() || package->category() == category );
222 222
223 if ( nameMatch && serverMatch && destinationMatch && statusMatch && categoryMatch ) 223 if ( nameMatch && serverMatch && destinationMatch && statusMatch && categoryMatch )
224 pl->append( packageIt.current() ); 224 pl->append( packageIt.current() );
225 } 225 }
226 226
227 return pl; 227 return pl;
228} 228}
229 229
230QStringList OPackageManager::servers() 230QStringList OPackageManager::servers()
231{ 231{
232 QStringList sl; 232 QStringList sl;
233 233
234 OConfItemList *serverList = m_ipkg.servers(); 234 OConfItemList *serverList = m_ipkg.servers();
235 if ( serverList ) 235 if ( serverList )
236 { 236 {
237 for ( OConfItemListIterator serverIt( *serverList ); serverIt.current(); ++serverIt ) 237 for ( OConfItemListIterator serverIt( *serverList ); serverIt.current(); ++serverIt )
238 { 238 {
239 OConfItem *server = serverIt.current(); 239 OConfItem *server = serverIt.current();
240 240
241 // Add only active servers 241 // Add only active servers
242 if ( server->active() ) 242 if ( server->active() )
243 sl << server->name(); 243 sl << server->name();
244 } 244 }
245 } 245 }
246 246
247 return sl; 247 return sl;
248} 248}
249 249
250QStringList OPackageManager::destinations() 250QStringList OPackageManager::destinations()
251{ 251{
252 QStringList dl; 252 QStringList dl;
253 253
254 OConfItemList *destList = m_ipkg.destinations(); 254 OConfItemList *destList = m_ipkg.destinations();
255 if ( destList ) 255 if ( destList )
256 { 256 {
257 for ( OConfItemListIterator destIt( *destList ); destIt.current(); ++destIt ) 257 for ( OConfItemListIterator destIt( *destList ); destIt.current(); ++destIt )
258 { 258 {
259 OConfItem *destination = destIt.current(); 259 OConfItem *destination = destIt.current();
260 260
261 // Add only active destinations 261 // Add only active destinations
262 if ( destination->active() ) 262 if ( destination->active() )
263 dl << destination->name(); 263 dl << destination->name();
264 } 264 }
265 } 265 }
266 266
267 return dl; 267 return dl;
268} 268}
269 269
270OConfItem *OPackageManager::findConfItem( OConfItem::Type type, const QString &name ) 270OConfItem *OPackageManager::findConfItem( OConfItem::Type type, const QString &name )
271{ 271{
272 OConfItem *confItem = 0x0; 272 return m_ipkg.findConfItem( type, name );
273 OConfItemList *confList = m_ipkg.configItems();
274 if ( confList )
275 {
276 for ( OConfItemListIterator confIt( *confList ); confIt.current(); ++confIt )
277 {
278 OConfItem *conf = confIt.current();
279
280 // Add only active confinations
281 if ( conf->type() == type && conf->name() == name )
282 {
283 confItem = conf;
284 break;
285 }
286 }
287 }
288
289 return confItem;
290
291} 273}
292 274
293OPackage *OPackageManager::findPackage( const QString &name ) 275OPackage *OPackageManager::findPackage( const QString &name )
294{ 276{
295 return m_packages[ name ]; 277 return m_packages[ name ];
296} 278}
297 279
298int OPackageManager::compareVersions( const QString &ver1, const QString &ver2 ) 280int OPackageManager::compareVersions( const QString &ver1, const QString &ver2 )
299{ 281{
300 // TODO - should this be in OIpkg??? 282 // TODO - should this be in OIpkg???
301 283
302 int epoch1, epoch2; 284 int epoch1, epoch2;
303 QString version1, revision1; 285 QString version1, revision1;
304 QString version2, revision2; 286 QString version2, revision2;
305 287
306 parseVersion( ver1, &epoch1, &version1, &revision1 ); 288 parseVersion( ver1, &epoch1, &version1, &revision1 );
307 parseVersion( ver2, &epoch2, &version2, &revision2 ); 289 parseVersion( ver2, &epoch2, &version2, &revision2 );
308 290
309 if ( epoch1 > epoch2 ) 291 if ( epoch1 > epoch2 )
310 return 1; 292 return 1;
311 else if ( epoch1 < epoch2 ) 293 else if ( epoch1 < epoch2 )
312 return -1; 294 return -1;
313 295
314 int r = verrevcmp( version1.latin1(), version2.latin1() ); 296 int r = verrevcmp( version1.latin1(), version2.latin1() );
315 if (r) 297 if (r)
316 return r; 298 return r;
317 299
318 r = verrevcmp( revision1.latin1(), revision2.latin1() ); 300 r = verrevcmp( revision1.latin1(), revision2.latin1() );
319 return r; 301 return r;
320} 302}
321 303
322bool OPackageManager::configureDlg( bool installOptions ) 304bool OPackageManager::configureDlg( bool installOptions )
323{ 305{
324 OIpkgConfigDlg dlg( &m_ipkg, installOptions, static_cast<QWidget *>(parent()) ); 306 OIpkgConfigDlg dlg( &m_ipkg, installOptions, static_cast<QWidget *>(parent()) );
325 return ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ); 307 return ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted );
326} 308}
327 309
328void OPackageManager::saveSettings() 310void OPackageManager::saveSettings()
329{ 311{
330 m_ipkg.saveSettings(); 312 m_ipkg.saveSettings();
331} 313}
332 314
333bool OPackageManager::executeCommand( OPackage::Command command, const QStringList &packages, 315bool OPackageManager::executeCommand( OPackage::Command command, const QStringList &packages,
334 const QString &destination, const QObject *receiver, 316 const QString &destination, const QObject *receiver,
335 const char *slotOutput, bool rawOutput ) 317 const char *slotOutput, bool rawOutput )
336{ 318{
337 return m_ipkg.executeCommand( command, packages, destination, receiver, slotOutput, rawOutput ); 319 return m_ipkg.executeCommand( command, packages, destination, receiver, slotOutput, rawOutput );
338} 320}
339 321
340void OPackageManager::parseVersion( const QString &verstr, int *epoch, QString *version, 322void OPackageManager::parseVersion( const QString &verstr, int *epoch, QString *version,
341 QString *revision ) 323 QString *revision )
342{ 324{
343 *epoch = 0; 325 *epoch = 0;
344 *revision = QString::null; 326 *revision = QString::null;
345 327
346 // Version string is in the format "ee:vv-rv", where ee=epoch, vv=version, rv=revision 328 // Version string is in the format "ee:vv-rv", where ee=epoch, vv=version, rv=revision
347 329
348 // Get epoch 330 // Get epoch
349 int colonpos = verstr.find( ':' ); 331 int colonpos = verstr.find( ':' );
350 if ( colonpos > -1 ) 332 if ( colonpos > -1 )
351 { 333 {
352 *epoch = verstr.left( colonpos ).toInt(); 334 *epoch = verstr.left( colonpos ).toInt();
353 } 335 }
354 336
355 // Get version and revision 337 // Get version and revision
356 int hyphenpos = verstr.find( '-', colonpos + 1 ); 338 int hyphenpos = verstr.find( '-', colonpos + 1 );
357 int verlen = verstr.length(); 339 int verlen = verstr.length();
358 if ( hyphenpos > -1 ) 340 if ( hyphenpos > -1 )
359 { 341 {
360 *version = verstr.mid( colonpos + 1, hyphenpos - colonpos - 1 ); 342 *version = verstr.mid( colonpos + 1, hyphenpos - colonpos - 1 );
361 *revision = verstr.right( verlen - hyphenpos - 1 ); 343 *revision = verstr.right( verlen - hyphenpos - 1 );
362 } 344 }
363 else 345 else
364 { 346 {
365 *version = verstr.right( verlen - colonpos ); 347 *version = verstr.right( verlen - colonpos );
366 } 348 }
367} 349}
368 350
369/* 351/*
370 * libdpkg - Debian packaging suite library routines 352 * libdpkg - Debian packaging suite library routines
371 * vercmp.c - comparison of version numbers 353 * vercmp.c - comparison of version numbers
372 * 354 *
373 * Copyright (C) 1995 Ian Jackson <iwj10@cus.cam.ac.uk> 355 * Copyright (C) 1995 Ian Jackson <iwj10@cus.cam.ac.uk>
374 */ 356 */
375int OPackageManager::verrevcmp( const char *val, const char *ref ) 357int OPackageManager::verrevcmp( const char *val, const char *ref )
376{ 358{
377 int vc, rc; 359 int vc, rc;
378 long vl, rl; 360 long vl, rl;
379 const char *vp, *rp; 361 const char *vp, *rp;
380 const char *vsep, *rsep; 362 const char *vsep, *rsep;
381 363
382 if (!val) val= ""; 364 if (!val) val= "";
383 if (!ref) ref= ""; 365 if (!ref) ref= "";
384 for (;;) { 366 for (;;) {
385 vp= val; while (*vp && !isdigit(*vp)) vp++; 367 vp= val; while (*vp && !isdigit(*vp)) vp++;
386 rp= ref; while (*rp && !isdigit(*rp)) rp++; 368 rp= ref; while (*rp && !isdigit(*rp)) rp++;
387 for (;;) { 369 for (;;) {
388 vc= (val == vp) ? 0 : *val++; 370 vc= (val == vp) ? 0 : *val++;
389 rc= (ref == rp) ? 0 : *ref++; 371 rc= (ref == rp) ? 0 : *ref++;
390 if (!rc && !vc) break; 372 if (!rc && !vc) break;
391 if (vc && !isalpha(vc)) vc += 256; /* assumes ASCII character set */ 373 if (vc && !isalpha(vc)) vc += 256; /* assumes ASCII character set */
392 if (rc && !isalpha(rc)) rc += 256; 374 if (rc && !isalpha(rc)) rc += 256;
393 if (vc != rc) return vc - rc; 375 if (vc != rc) return vc - rc;
394 } 376 }
395 val= vp; 377 val= vp;
396 ref= rp; 378 ref= rp;
397 vl=0; if (isdigit(*vp)) vl= strtol(val,(char**)&val,10); 379 vl=0; if (isdigit(*vp)) vl= strtol(val,(char**)&val,10);
398 rl=0; if (isdigit(*rp)) rl= strtol(ref,(char**)&ref,10); 380 rl=0; if (isdigit(*rp)) rl= strtol(ref,(char**)&ref,10);
399 if (vl != rl) return vl - rl; 381 if (vl != rl) return vl - rl;
400 382
401 vc = *val; 383 vc = *val;
402 rc = *ref; 384 rc = *ref;
403 vsep = strchr(".-", vc); 385 vsep = strchr(".-", vc);
404 rsep = strchr(".-", rc); 386 rsep = strchr(".-", rc);
405 if (vsep && !rsep) return -1; 387 if (vsep && !rsep) return -1;
406 if (!vsep && rsep) return +1; 388 if (!vsep && rsep) return +1;
407 389
408 if (!*val && !*ref) return 0; 390 if (!*val && !*ref) return 0;
409 if (!*val) return -1; 391 if (!*val) return -1;
410 if (!*ref) return +1; 392 if (!*ref) return +1;
411 } 393 }
412} 394}
diff --git a/noncore/settings/packagemanager/opie-packagemanager.control b/noncore/settings/packagemanager/opie-packagemanager.control
index cdf419c..da3ddfe 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: opie/settings 4Section: opie/settings
5Depends: task-opie-minimal, libopiecore2, libopieui2, libipkg (>=0.99.120), ipkg-link 5Depends: task-opie-minimal, libopiecore2, libopieui2, libipkg (>=0.99.120)
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.6.0$EXTRAVERSION 10Version: 0.6.1$EXTRAVERSION
diff --git a/noncore/settings/packagemanager/packageinfodlg.cpp b/noncore/settings/packagemanager/packageinfodlg.cpp
index 5f72a67..3eef939 100644
--- a/noncore/settings/packagemanager/packageinfodlg.cpp
+++ b/noncore/settings/packagemanager/packageinfodlg.cpp
@@ -1,151 +1,153 @@
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" 31#include "opackage.h"
32#include "opackagemanager.h" 32#include "opackagemanager.h"
33 33
34#include <opie2/otabwidget.h> 34#include <opie2/otabwidget.h>
35 35
36#include <qpe/resource.h> 36#include <qpe/resource.h>
37 37
38#include <qlayout.h> 38#include <qlayout.h>
39#include <qpushbutton.h> 39#include <qpushbutton.h>
40#include <qwhatsthis.h> 40#include <qwhatsthis.h>
41 41
42PackageInfoDlg::PackageInfoDlg( QWidget *parent, OPackageManager *pm, const QString &package ) 42PackageInfoDlg::PackageInfoDlg( QWidget *parent, OPackageManager *pm, const QString &package )
43 : QWidget( 0l ) 43 : QWidget( 0l )
44 , m_packman( pm ) 44 , m_packman( pm )
45 , m_information( this ) 45 , m_information( this )
46 , m_files( this ) 46 , m_files( this )
47 , m_retrieveFiles( 0l ) 47 , m_retrieveFiles( 0l )
48{ 48{
49 // Initialize UI 49 // Initialize UI
50 if ( parent ) 50 if ( parent )
51 parent->setCaption( package ); 51 parent->setCaption( package );
52 52
53 QVBoxLayout *layout = new QVBoxLayout( this, 4, 2 ); 53 QVBoxLayout *layout = new QVBoxLayout( this, 4, 2 );
54 54
55 Opie::Ui::OTabWidget *tabWidget = new Opie::Ui::OTabWidget( this ); 55 Opie::Ui::OTabWidget *tabWidget = new Opie::Ui::OTabWidget( this );
56 layout->addWidget( tabWidget ); 56 layout->addWidget( tabWidget );
57 57
58 // Information tab 58 // Information tab
59 QWhatsThis::add( &m_information, tr( "This area contains information about the package." ) ); 59 QWhatsThis::add( &m_information, tr( "This area contains information about the package." ) );
60 m_information.reparent( tabWidget, QPoint( 0, 0 ) ); 60 m_information.reparent( tabWidget, QPoint( 0, 0 ) );
61 m_information.setReadOnly( true ); 61 m_information.setReadOnly( true );
62 tabWidget->addTab( &m_information, "UtilsIcon", tr( "Information" ) ); 62 tabWidget->addTab( &m_information, "UtilsIcon", tr( "Information" ) );
63 63
64 // Retrive package information 64 // Retrive package information
65 m_package = m_packman->findPackage( package ); 65 m_package = m_packman->findPackage( package );
66 if ( !m_package ) 66 if ( !m_package )
67 { 67 {
68 m_information.setText( tr( "Unable to retrieve package information." ) ); 68 m_information.setText( tr( "Unable to retrieve package information." ) );
69 return; 69 return;
70 } 70 }
71 71
72 // Display package information 72 // Display package information
73 if ( !m_package->information().isNull() ) 73 if ( !m_package->information().isNull() )
74 m_information.setText( m_package->information() ); 74 m_information.setText( m_package->information() );
75 else 75 else
76 { 76 {
77 // Package information is not cached, retrieve it 77 // Package information is not cached, retrieve it
78 QStringList list( package ); 78 QStringList list( package );
79 m_packman->executeCommand( OPackage::Info, list, QString::null, this, SLOT(slotInfo(char*)), true ); 79 m_packman->executeCommand( OPackage::Info, list, QString::null,
80 this, SLOT(slotInfo(const QString &)), true );
80 } 81 }
81 82
82 // Files tab (display only if package is installed) 83 // Files tab (display only if package is installed)
83 if ( !m_package->versionInstalled().isNull() ) 84 if ( !m_package->versionInstalled().isNull() )
84 { 85 {
85 QWidget *filesWidget = new QWidget( tabWidget ); 86 QWidget *filesWidget = new QWidget( tabWidget );
86 QVBoxLayout *filesLayout = new QVBoxLayout( filesWidget, 2, 2 ); 87 QVBoxLayout *filesLayout = new QVBoxLayout( filesWidget, 2, 2 );
87 QWhatsThis::add( &m_files, tr( "This area contains a list of files contained in this package." ) ); 88 QWhatsThis::add( &m_files, tr( "This area contains a list of files contained in this package." ) );
88 m_files.reparent( filesWidget, QPoint( 0, 0 ) ); 89 m_files.reparent( filesWidget, QPoint( 0, 0 ) );
89 m_files.setReadOnly( true ); 90 m_files.setReadOnly( true );
90 filesLayout->addWidget( &m_files ); 91 filesLayout->addWidget( &m_files );
91 92
92 // If file list is already cached, display 93 // If file list is already cached, display
93 if ( !m_package->files().isNull() ) 94 if ( !m_package->files().isNull() )
94 m_files.setText( m_package->files() ); 95 m_files.setText( m_package->files() );
95 else 96 else
96 { 97 {
97 m_retrieveFiles = new QPushButton( Resource::loadPixmap( "packagemanager/apply" ), 98 m_retrieveFiles = new QPushButton( Resource::loadPixmap( "packagemanager/apply" ),
98 tr( "Retrieve file list" ), filesWidget ); 99 tr( "Retrieve file list" ), filesWidget );
99 QWhatsThis::add( m_retrieveFiles, tr( "Tap here to retrieve list of files contained in this package." ) ); 100 QWhatsThis::add( m_retrieveFiles, tr( "Tap here to retrieve list of files contained in this package." ) );
100 filesLayout->addWidget( m_retrieveFiles ); 101 filesLayout->addWidget( m_retrieveFiles );
101 connect( m_retrieveFiles, SIGNAL(clicked()), this, SLOT(slotBtnFileScan()) ); 102 connect( m_retrieveFiles, SIGNAL(clicked()), this, SLOT(slotBtnFileScan()) );
102 } 103 }
103 104
104 tabWidget->addTab( filesWidget, "binary", tr( "File list" ) ); 105 tabWidget->addTab( filesWidget, "binary", tr( "File list" ) );
105 tabWidget->setCurrentTab( tr( "Information" ) ); 106 tabWidget->setCurrentTab( tr( "Information" ) );
106 107
107 } 108 }
108 else 109 else
109 m_files.hide(); 110 m_files.hide();
110} 111}
111 112
112PackageInfoDlg::~PackageInfoDlg() 113PackageInfoDlg::~PackageInfoDlg()
113{ 114{
114 if ( !m_package ) 115 if ( !m_package )
115 return; 116 return;
116 117
117 // Cache package information 118 // Cache package information
118 if ( !m_information.text().isNull() ) 119 if ( !m_information.text().isNull() )
119 m_package->setInformation( m_information.text() ); 120 m_package->setInformation( m_information.text() );
120 121
121 // Cache package file list 122 // Cache package file list
122 if ( !m_files.text().isEmpty() ) 123 if ( !m_files.text().isEmpty() )
123 m_package->setFiles( m_files.text() ); 124 m_package->setFiles( m_files.text() );
124} 125}
125 126
126void PackageInfoDlg::slotBtnFileScan() 127void PackageInfoDlg::slotBtnFileScan()
127{ 128{
128 m_files.clear(); 129 m_files.clear();
129 130
130 QStringList list( m_package->name() ); 131 QStringList list( m_package->name() );
131 m_packman->executeCommand( OPackage::Files, list, QString::null, this, SLOT(slotFiles(char*)), true ); 132 m_packman->executeCommand( OPackage::Files, list, QString::null,
133 this, SLOT(slotFiles(const QString &)), true );
132 134
133 if ( m_retrieveFiles ) 135 if ( m_retrieveFiles )
134 m_retrieveFiles->hide(); 136 m_retrieveFiles->hide();
135} 137}
136 138
137void PackageInfoDlg::slotInfo( char *info ) 139void PackageInfoDlg::slotInfo( const QString &info )
138{ 140{
139 m_information.append( info ); 141 m_information.append( info );
140} 142}
141 143
142void PackageInfoDlg::slotFiles( char *filelist ) 144void PackageInfoDlg::slotFiles( const QString &filelist )
143{ 145{
144 QString str = filelist; 146 QString str = filelist;
145 147
146 // Skip first line of output ("Package xxx is installed...") 148 // Skip first line of output ("Package xxx is installed...")
147 if ( str.startsWith( "Package " ) ) 149 if ( str.startsWith( "Package " ) )
148 str = str.right( str.length() - str.find( '\n' ) - 1 ); 150 str = str.right( str.length() - str.find( '\n' ) - 1 );
149 151
150 m_files.append( str ); 152 m_files.append( str );
151} 153}
diff --git a/noncore/settings/packagemanager/packageinfodlg.h b/noncore/settings/packagemanager/packageinfodlg.h
index d1830de..2962f9a 100644
--- a/noncore/settings/packagemanager/packageinfodlg.h
+++ b/noncore/settings/packagemanager/packageinfodlg.h
@@ -1,66 +1,66 @@
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 "opackage.h" 33#include "opackage.h"
34 34
35#include <qmultilineedit.h> 35#include <qmultilineedit.h>
36#include <qwidget.h> 36#include <qwidget.h>
37 37
38class QPushButton; 38class QPushButton;
39 39
40class OPackage; 40class OPackage;
41class OPackageManager; 41class OPackageManager;
42 42
43class PackageInfoDlg : public QWidget 43class PackageInfoDlg : public QWidget
44{ 44{
45 Q_OBJECT 45 Q_OBJECT
46 46
47public: 47public:
48 PackageInfoDlg( QWidget *parent = 0l, OPackageManager *pm = 0l, const QString &package = QString::null ); 48 PackageInfoDlg( QWidget *parent = 0l, OPackageManager *pm = 0l, const QString &package = QString::null );
49 ~PackageInfoDlg(); 49 ~PackageInfoDlg();
50 50
51private: 51private:
52 OPackageManager *m_packman; // Pointer to application instance of package manager 52 OPackageManager *m_packman; // Pointer to application instance of package manager
53 OPackage *m_package; // Pointer to package to display information for 53 OPackage *m_package; // Pointer to package to display information for
54 54
55 // UI controls 55 // UI controls
56 QMultiLineEdit m_information; // Multi-line edit to display package information 56 QMultiLineEdit m_information; // Multi-line edit to display package information
57 QMultiLineEdit m_files; // Multi-line edit to display package file list 57 QMultiLineEdit m_files; // Multi-line edit to display package file list
58 QPushButton *m_retrieveFiles; // Push button to retrieve file list 58 QPushButton *m_retrieveFiles; // Push button to retrieve file list
59 59
60private slots: 60private slots:
61 void slotBtnFileScan(); 61 void slotBtnFileScan();
62 void slotInfo( char *info ); 62 void slotInfo( const QString &info );
63 void slotFiles( char *filelist ); 63 void slotFiles( const QString &filelist );
64}; 64};
65 65
66#endif 66#endif