summaryrefslogtreecommitdiff
authordrw <drw>2004-04-08 00:22:39 (UTC)
committer drw <drw>2004-04-08 00:22:39 (UTC)
commit8c54ad421c7bee65b2a1442ce85c09f2eff3efc6 (patch) (unidiff)
tree9ed0d01e5afc0ac7ec418b2cf3115d783cc0f186
parentc968f44205a5da7dc37029e701f527450692e39a (diff)
downloadopie-8c54ad421c7bee65b2a1442ce85c09f2eff3efc6.zip
opie-8c54ad421c7bee65b2a1442ce85c09f2eff3efc6.tar.gz
opie-8c54ad421c7bee65b2a1442ce85c09f2eff3efc6.tar.bz2
Save proxy information
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/packagemanager/oipkgconfigdlg.cpp37
1 files changed, 37 insertions, 0 deletions
diff --git a/noncore/settings/packagemanager/oipkgconfigdlg.cpp b/noncore/settings/packagemanager/oipkgconfigdlg.cpp
index 592de3e..74e7137 100644
--- a/noncore/settings/packagemanager/oipkgconfigdlg.cpp
+++ b/noncore/settings/packagemanager/oipkgconfigdlg.cpp
@@ -1,559 +1,596 @@
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 <qcheckbox.h> 34#include <qcheckbox.h>
35#include <qcombobox.h> 35#include <qcombobox.h>
36#include <qgroupbox.h> 36#include <qgroupbox.h>
37#include <qlabel.h> 37#include <qlabel.h>
38#include <qlineedit.h> 38#include <qlineedit.h>
39#include <qlistbox.h> 39#include <qlistbox.h>
40#include <qpushbutton.h> 40#include <qpushbutton.h>
41#include <qscrollview.h> 41#include <qscrollview.h>
42 42
43#include <qpe/resource.h> 43#include <qpe/resource.h>
44 44
45using namespace Opie::Ui; 45using namespace Opie::Ui;
46OIpkgConfigDlg::OIpkgConfigDlg( OIpkg *ipkg, bool installOptions, QWidget *parent ) 46OIpkgConfigDlg::OIpkgConfigDlg( OIpkg *ipkg, bool installOptions, QWidget *parent )
47 : QDialog( parent, QString::null, true ) 47 : QDialog( parent, QString::null, true )
48 , m_ipkg( ipkg ) 48 , m_ipkg( ipkg )
49 , m_configs( 0x0 ) 49 , m_configs( 0x0 )
50 , m_installOptions( installOptions ) 50 , m_installOptions( installOptions )
51 , m_serverNew( false ) 51 , m_serverNew( false )
52 , m_serverCurrent( -1 ) 52 , m_serverCurrent( -1 )
53 , m_destNew( false ) 53 , m_destNew( false )
54 , m_destCurrent( -1 ) 54 , m_destCurrent( -1 )
55 , m_layout( this, 2, 4 ) 55 , m_layout( this, 2, 4 )
56 , m_tabWidget( this ) 56 , m_tabWidget( this )
57{ 57{
58 setCaption( tr( "Configuration" ) ); 58 setCaption( tr( "Configuration" ) );
59 59
60 // Initialize configuration widgets 60 // Initialize configuration widgets
61 if ( !installOptions ) 61 if ( !installOptions )
62 { 62 {
63 initServerWidget(); 63 initServerWidget();
64 initDestinationWidget(); 64 initDestinationWidget();
65 initProxyWidget(); 65 initProxyWidget();
66 } 66 }
67 initOptionsWidget(); 67 initOptionsWidget();
68 68
69 // Load configuration information 69 // Load configuration information
70 initData(); 70 initData();
71 71
72 // Setup tabs for all info 72 // Setup tabs for all info
73 m_layout.addWidget( &m_tabWidget ); 73 m_layout.addWidget( &m_tabWidget );
74 if ( !m_installOptions ) 74 if ( !m_installOptions )
75 { 75 {
76 m_tabWidget.addTab( m_serverWidget, "packagemanager/servertab", tr( "Servers" ) ); 76 m_tabWidget.addTab( m_serverWidget, "packagemanager/servertab", tr( "Servers" ) );
77 m_tabWidget.addTab( m_destWidget, "packagemanager/desttab", tr( "Destinations" ) ); 77 m_tabWidget.addTab( m_destWidget, "packagemanager/desttab", tr( "Destinations" ) );
78 m_tabWidget.addTab( m_proxyWidget, "packagemanager/proxytab", tr( "Proxies" ) ); 78 m_tabWidget.addTab( m_proxyWidget, "packagemanager/proxytab", tr( "Proxies" ) );
79 m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) ); 79 m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) );
80 m_tabWidget.setCurrentTab( tr( "Servers" ) ); 80 m_tabWidget.setCurrentTab( tr( "Servers" ) );
81 } 81 }
82 else 82 else
83 { 83 {
84 m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) ); 84 m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) );
85 } 85 }
86 86
87 //showMaximized(); 87 //showMaximized();
88} 88}
89 89
90void OIpkgConfigDlg::accept() 90void OIpkgConfigDlg::accept()
91{ 91{
92 // Save server, destination and proxy configuration 92 // Save server, destination and proxy configuration
93 if ( !m_installOptions ) 93 if ( !m_installOptions )
94 {
95 // Update proxy information before saving settings
96 OConfItem *confItem = findConfItem( OConfItem::Option, "http_proxy" );
97 if ( confItem )
98 {
99 confItem->setValue( m_proxyHttpServer->text() );
100 confItem->setActive( m_proxyHttpActive->isChecked() );
101 }
102 else
103 m_configs->append( new OConfItem( QString::null, OConfItem::Option, "http_proxy",
104 m_proxyHttpServer->text(), m_proxyHttpActive->isChecked() ) );
105
106 confItem = findConfItem( OConfItem::Option, "ftp_proxy" );
107 if ( confItem )
108 {
109 confItem->setValue( m_proxyFtpServer->text() );
110 confItem->setActive( m_proxyFtpActive->isChecked() );
111 }
112 else
113 m_configs->append( new OConfItem( QString::null, OConfItem::Option, "ftp_proxy",
114 m_proxyFtpServer->text(), m_proxyFtpActive->isChecked() ) );
115
116 confItem = findConfItem( OConfItem::Option, "proxy_username" );
117 if ( confItem )
118 confItem->setValue( m_proxyUsername->text() );
119 else
120 m_configs->append( new OConfItem( QString::null, OConfItem::Option, "proxy_username",
121 m_proxyUsername->text() ) );
122
123 confItem = findConfItem( OConfItem::Option, "proxy_password" );
124 if ( confItem )
125 confItem->setValue( m_proxyPassword->text() );
126 else
127 m_configs->append( new OConfItem( QString::null, OConfItem::Option, "proxy_password",
128 m_proxyPassword->text() ) );
129
94 m_ipkg->setConfigItems( m_configs ); 130 m_ipkg->setConfigItems( m_configs );
131 }
95 132
96 // Save options configuration 133 // Save options configuration
97 int options = 0; 134 int options = 0;
98 if ( m_optForceDepends->isChecked() ) 135 if ( m_optForceDepends->isChecked() )
99 options |= FORCE_DEPENDS; 136 options |= FORCE_DEPENDS;
100 if ( m_optForceReinstall->isChecked() ) 137 if ( m_optForceReinstall->isChecked() )
101 options |= FORCE_REINSTALL; 138 options |= FORCE_REINSTALL;
102 if ( m_optForceRemove->isChecked() ) 139 if ( m_optForceRemove->isChecked() )
103 options |= FORCE_REMOVE; 140 options |= FORCE_REMOVE;
104 if ( m_optForceOverwrite->isChecked() ) 141 if ( m_optForceOverwrite->isChecked() )
105 options |= FORCE_OVERWRITE; 142 options |= FORCE_OVERWRITE;
106 m_ipkg->setIpkgExecOptions( options ); 143 m_ipkg->setIpkgExecOptions( options );
107 m_ipkg->setIpkgExecVerbosity( m_optVerboseIpkg->currentItem() ); 144 m_ipkg->setIpkgExecVerbosity( m_optVerboseIpkg->currentItem() );
108 145
109 QDialog::accept(); 146 QDialog::accept();
110} 147}
111 148
112void OIpkgConfigDlg::reject() 149void OIpkgConfigDlg::reject()
113{ 150{
114 if ( m_configs ) 151 if ( m_configs )
115 delete m_configs; 152 delete m_configs;
116} 153}
117 154
118void OIpkgConfigDlg::initServerWidget() 155void OIpkgConfigDlg::initServerWidget()
119{ 156{
120 m_serverWidget = new QWidget( this ); 157 m_serverWidget = new QWidget( this );
121 158
122 // Initialize UI 159 // Initialize UI
123 QVBoxLayout *vb = new QVBoxLayout( m_serverWidget ); 160 QVBoxLayout *vb = new QVBoxLayout( m_serverWidget );
124 QScrollView *sv = new QScrollView( m_serverWidget ); 161 QScrollView *sv = new QScrollView( m_serverWidget );
125 vb->addWidget( sv, 0, 0 ); 162 vb->addWidget( sv, 0, 0 );
126 sv->setResizePolicy( QScrollView::AutoOneFit ); 163 sv->setResizePolicy( QScrollView::AutoOneFit );
127 sv->setFrameStyle( QFrame::NoFrame ); 164 sv->setFrameStyle( QFrame::NoFrame );
128 QWidget *container = new QWidget( sv->viewport() ); 165 QWidget *container = new QWidget( sv->viewport() );
129 sv->addChild( container ); 166 sv->addChild( container );
130 QGridLayout *layout = new QGridLayout( container, 3, 2, 2, 4 ); 167 QGridLayout *layout = new QGridLayout( container, 3, 2, 2, 4 );
131 168
132 m_serverList = new QListBox( container ); 169 m_serverList = new QListBox( container );
133 m_serverList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); 170 m_serverList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
134 connect( m_serverList, SIGNAL(highlighted(int)), this, SLOT(slotServerEdit(int)) ); 171 connect( m_serverList, SIGNAL(highlighted(int)), this, SLOT(slotServerEdit(int)) );
135 layout->addMultiCellWidget( m_serverList, 0, 0, 0, 1 ); 172 layout->addMultiCellWidget( m_serverList, 0, 0, 0, 1 );
136 173
137 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); 174 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container );
138 connect( btn, SIGNAL(clicked()), this, SLOT(slotServerNew()) ); 175 connect( btn, SIGNAL(clicked()), this, SLOT(slotServerNew()) );
139 layout->addWidget( btn, 1, 0 ); 176 layout->addWidget( btn, 1, 0 );
140 177
141 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); 178 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container );
142 connect( btn, SIGNAL(clicked()), this, SLOT(slotServerDelete()) ); 179 connect( btn, SIGNAL(clicked()), this, SLOT(slotServerDelete()) );
143 layout->addWidget( btn, 1, 1 ); 180 layout->addWidget( btn, 1, 1 );
144 181
145 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container ); 182 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container );
146 grpbox->layout()->setSpacing( 2 ); 183 grpbox->layout()->setSpacing( 2 );
147 grpbox->layout()->setMargin( 4 ); 184 grpbox->layout()->setMargin( 4 );
148 layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); 185 layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 );
149 186
150 QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); 187 QGridLayout *grplayout = new QGridLayout( grpbox->layout() );
151 188
152 QLabel *label = new QLabel( tr( "Name:" ), grpbox ); 189 QLabel *label = new QLabel( tr( "Name:" ), grpbox );
153 grplayout->addWidget( label, 0, 0 ); 190 grplayout->addWidget( label, 0, 0 );
154 m_serverName = new QLineEdit( grpbox ); 191 m_serverName = new QLineEdit( grpbox );
155 grplayout->addWidget( m_serverName, 0, 1 ); 192 grplayout->addWidget( m_serverName, 0, 1 );
156 193
157 label = new QLabel( tr( "Address:" ), grpbox ); 194 label = new QLabel( tr( "Address:" ), grpbox );
158 grplayout->addWidget( label, 1, 0 ); 195 grplayout->addWidget( label, 1, 0 );
159 m_serverLocation = new QLineEdit( grpbox ); 196 m_serverLocation = new QLineEdit( grpbox );
160 grplayout->addWidget( m_serverLocation, 1, 1 ); 197 grplayout->addWidget( m_serverLocation, 1, 1 );
161 198
162 m_serverActive = new QCheckBox( tr( "Active Server" ), grpbox ); 199 m_serverActive = new QCheckBox( tr( "Active Server" ), grpbox );
163 grplayout->addMultiCellWidget( m_serverActive, 2, 2, 0, 1 ); 200 grplayout->addMultiCellWidget( m_serverActive, 2, 2, 0, 1 );
164 201
165 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); 202 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox );
166 connect( btn, SIGNAL(clicked()), this, SLOT(slotServerUpdate()) ); 203 connect( btn, SIGNAL(clicked()), this, SLOT(slotServerUpdate()) );
167 grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); 204 grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 );
168} 205}
169 206
170void OIpkgConfigDlg::initDestinationWidget() 207void OIpkgConfigDlg::initDestinationWidget()
171{ 208{
172 m_destWidget = new QWidget( this ); 209 m_destWidget = new QWidget( this );
173 210
174 // Initialize UI 211 // Initialize UI
175 QVBoxLayout *vb = new QVBoxLayout( m_destWidget ); 212 QVBoxLayout *vb = new QVBoxLayout( m_destWidget );
176 QScrollView *sv = new QScrollView( m_destWidget ); 213 QScrollView *sv = new QScrollView( m_destWidget );
177 vb->addWidget( sv, 0, 0 ); 214 vb->addWidget( sv, 0, 0 );
178 sv->setResizePolicy( QScrollView::AutoOneFit ); 215 sv->setResizePolicy( QScrollView::AutoOneFit );
179 sv->setFrameStyle( QFrame::NoFrame ); 216 sv->setFrameStyle( QFrame::NoFrame );
180 QWidget *container = new QWidget( sv->viewport() ); 217 QWidget *container = new QWidget( sv->viewport() );
181 sv->addChild( container ); 218 sv->addChild( container );
182 QGridLayout *layout = new QGridLayout( container, 3, 2, 2, 4 ); 219 QGridLayout *layout = new QGridLayout( container, 3, 2, 2, 4 );
183 220
184 m_destList = new QListBox( container ); 221 m_destList = new QListBox( container );
185 m_destList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); 222 m_destList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
186 connect( m_destList, SIGNAL(highlighted(int)), this, SLOT(slotDestEdit(int)) ); 223 connect( m_destList, SIGNAL(highlighted(int)), this, SLOT(slotDestEdit(int)) );
187 layout->addMultiCellWidget( m_destList, 0, 0, 0, 1 ); 224 layout->addMultiCellWidget( m_destList, 0, 0, 0, 1 );
188 225
189 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); 226 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container );
190 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestNew()) ); 227 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestNew()) );
191 layout->addWidget( btn, 1, 0 ); 228 layout->addWidget( btn, 1, 0 );
192 229
193 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); 230 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container );
194 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestDelete()) ); 231 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestDelete()) );
195 layout->addWidget( btn, 1, 1 ); 232 layout->addWidget( btn, 1, 1 );
196 233
197 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container ); 234 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container );
198 grpbox->layout()->setSpacing( 2 ); 235 grpbox->layout()->setSpacing( 2 );
199 grpbox->layout()->setMargin( 4 ); 236 grpbox->layout()->setMargin( 4 );
200 layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); 237 layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 );
201 238
202 QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); 239 QGridLayout *grplayout = new QGridLayout( grpbox->layout() );
203 240
204 QLabel *label = new QLabel( tr( "Name:" ), grpbox ); 241 QLabel *label = new QLabel( tr( "Name:" ), grpbox );
205 grplayout->addWidget( label, 0, 0 ); 242 grplayout->addWidget( label, 0, 0 );
206 m_destName = new QLineEdit( grpbox ); 243 m_destName = new QLineEdit( grpbox );
207 grplayout->addWidget( m_destName, 0, 1 ); 244 grplayout->addWidget( m_destName, 0, 1 );
208 245
209 label = new QLabel( tr( "Address:" ), grpbox ); 246 label = new QLabel( tr( "Address:" ), grpbox );
210 grplayout->addWidget( label, 1, 0 ); 247 grplayout->addWidget( label, 1, 0 );
211 m_destLocation = new QLineEdit( grpbox ); 248 m_destLocation = new QLineEdit( grpbox );
212 grplayout->addWidget( m_destLocation, 1, 1 ); 249 grplayout->addWidget( m_destLocation, 1, 1 );
213 250
214 m_destActive = new QCheckBox( tr( "Active Server" ), grpbox ); 251 m_destActive = new QCheckBox( tr( "Active Server" ), grpbox );
215 grplayout->addMultiCellWidget( m_destActive, 2, 2, 0, 1 ); 252 grplayout->addMultiCellWidget( m_destActive, 2, 2, 0, 1 );
216 253
217 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); 254 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox );
218 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestUpdate()) ); 255 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestUpdate()) );
219 grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); 256 grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 );
220} 257}
221 258
222void OIpkgConfigDlg::initProxyWidget() 259void OIpkgConfigDlg::initProxyWidget()
223{ 260{
224 m_proxyWidget = new QWidget( this ); 261 m_proxyWidget = new QWidget( this );
225 262
226 // Initialize UI 263 // Initialize UI
227 QVBoxLayout *vb = new QVBoxLayout( m_proxyWidget ); 264 QVBoxLayout *vb = new QVBoxLayout( m_proxyWidget );
228 QScrollView *sv = new QScrollView( m_proxyWidget ); 265 QScrollView *sv = new QScrollView( m_proxyWidget );
229 vb->addWidget( sv, 0, 0 ); 266 vb->addWidget( sv, 0, 0 );
230 sv->setResizePolicy( QScrollView::AutoOneFit ); 267 sv->setResizePolicy( QScrollView::AutoOneFit );
231 sv->setFrameStyle( QFrame::NoFrame ); 268 sv->setFrameStyle( QFrame::NoFrame );
232 QWidget *container = new QWidget( sv->viewport() ); 269 QWidget *container = new QWidget( sv->viewport() );
233 sv->addChild( container ); 270 sv->addChild( container );
234 QGridLayout *layout = new QGridLayout( container, 4, 2, 2, 4 ); 271 QGridLayout *layout = new QGridLayout( container, 4, 2, 2, 4 );
235 272
236 // HTTP proxy server configuration 273 // HTTP proxy server configuration
237 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "HTTP Proxy" ), container ); 274 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "HTTP Proxy" ), container );
238 grpbox->layout()->setSpacing( 2 ); 275 grpbox->layout()->setSpacing( 2 );
239 grpbox->layout()->setMargin( 4 ); 276 grpbox->layout()->setMargin( 4 );
240 layout->addMultiCellWidget( grpbox, 0, 0, 0, 1 ); 277 layout->addMultiCellWidget( grpbox, 0, 0, 0, 1 );
241 QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); 278 QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() );
242 m_proxyHttpServer = new QLineEdit( grpbox ); 279 m_proxyHttpServer = new QLineEdit( grpbox );
243 grplayout->addWidget( m_proxyHttpServer ); 280 grplayout->addWidget( m_proxyHttpServer );
244 m_proxyHttpActive = new QCheckBox( tr( "Enabled" ), grpbox ); 281 m_proxyHttpActive = new QCheckBox( tr( "Enabled" ), grpbox );
245 grplayout->addWidget( m_proxyHttpActive ); 282 grplayout->addWidget( m_proxyHttpActive );
246 283
247 // FTP proxy server configuration 284 // FTP proxy server configuration
248 grpbox = new QGroupBox( 0, Qt::Vertical, tr( "FTP Proxy" ), container ); 285 grpbox = new QGroupBox( 0, Qt::Vertical, tr( "FTP Proxy" ), container );
249 grpbox->layout()->setSpacing( 2 ); 286 grpbox->layout()->setSpacing( 2 );
250 grpbox->layout()->setMargin( 4 ); 287 grpbox->layout()->setMargin( 4 );
251 layout->addMultiCellWidget( grpbox, 1, 1, 0, 1 ); 288 layout->addMultiCellWidget( grpbox, 1, 1, 0, 1 );
252 grplayout = new QVBoxLayout( grpbox->layout() ); 289 grplayout = new QVBoxLayout( grpbox->layout() );
253 m_proxyFtpServer = new QLineEdit( grpbox ); 290 m_proxyFtpServer = new QLineEdit( grpbox );
254 grplayout->addWidget( m_proxyFtpServer ); 291 grplayout->addWidget( m_proxyFtpServer );
255 m_proxyFtpActive = new QCheckBox( tr( "Enabled" ), grpbox ); 292 m_proxyFtpActive = new QCheckBox( tr( "Enabled" ), grpbox );
256 grplayout->addWidget( m_proxyFtpActive ); 293 grplayout->addWidget( m_proxyFtpActive );
257 294
258 // Proxy server username and password configuration 295 // Proxy server username and password configuration
259 QLabel *label = new QLabel( tr( "Username:" ), container ); 296 QLabel *label = new QLabel( tr( "Username:" ), container );
260 layout->addWidget( label, 2, 0 ); 297 layout->addWidget( label, 2, 0 );
261 m_proxyUsername = new QLineEdit( container ); 298 m_proxyUsername = new QLineEdit( container );
262 layout->addWidget( m_proxyUsername, 2, 1 ); 299 layout->addWidget( m_proxyUsername, 2, 1 );
263 300
264 label = new QLabel( tr( "Password:" ), container ); 301 label = new QLabel( tr( "Password:" ), container );
265 layout->addWidget( label, 3, 0 ); 302 layout->addWidget( label, 3, 0 );
266 m_proxyPassword = new QLineEdit( container ); 303 m_proxyPassword = new QLineEdit( container );
267 layout->addWidget( m_proxyPassword, 3, 1 ); 304 layout->addWidget( m_proxyPassword, 3, 1 );
268} 305}
269 306
270void OIpkgConfigDlg::initOptionsWidget() 307void OIpkgConfigDlg::initOptionsWidget()
271{ 308{
272 m_optionsWidget = new QWidget( this ); 309 m_optionsWidget = new QWidget( this );
273 310
274 // Initialize UI 311 // Initialize UI
275 QVBoxLayout *vb = new QVBoxLayout( m_optionsWidget ); 312 QVBoxLayout *vb = new QVBoxLayout( m_optionsWidget );
276 QScrollView *sv = new QScrollView( m_optionsWidget ); 313 QScrollView *sv = new QScrollView( m_optionsWidget );
277 vb->addWidget( sv, 0, 0 ); 314 vb->addWidget( sv, 0, 0 );
278 sv->setResizePolicy( QScrollView::AutoOneFit ); 315 sv->setResizePolicy( QScrollView::AutoOneFit );
279 sv->setFrameStyle( QFrame::NoFrame ); 316 sv->setFrameStyle( QFrame::NoFrame );
280 QWidget *container = new QWidget( sv->viewport() ); 317 QWidget *container = new QWidget( sv->viewport() );
281 sv->addChild( container ); 318 sv->addChild( container );
282 QVBoxLayout *layout = new QVBoxLayout( container, 2, 4 ); 319 QVBoxLayout *layout = new QVBoxLayout( container, 2, 4 );
283 320
284 m_optForceDepends = new QCheckBox( tr( "Force Depends" ), container ); 321 m_optForceDepends = new QCheckBox( tr( "Force Depends" ), container );
285 layout->addWidget( m_optForceDepends ); 322 layout->addWidget( m_optForceDepends );
286 323
287 m_optForceReinstall = new QCheckBox( tr( "Force Reinstall" ), container ); 324 m_optForceReinstall = new QCheckBox( tr( "Force Reinstall" ), container );
288 layout->addWidget( m_optForceReinstall ); 325 layout->addWidget( m_optForceReinstall );
289 326
290 m_optForceRemove = new QCheckBox( tr( "Force Remove" ), container ); 327 m_optForceRemove = new QCheckBox( tr( "Force Remove" ), container );
291 layout->addWidget( m_optForceRemove ); 328 layout->addWidget( m_optForceRemove );
292 329
293 m_optForceOverwrite = new QCheckBox( tr( "Force Overwrite" ), container ); 330 m_optForceOverwrite = new QCheckBox( tr( "Force Overwrite" ), container );
294 layout->addWidget( m_optForceOverwrite ); 331 layout->addWidget( m_optForceOverwrite );
295 332
296 QLabel *l = new QLabel( tr( "Information Level" ), container ); 333 QLabel *l = new QLabel( tr( "Information Level" ), container );
297 layout->addWidget( l ); 334 layout->addWidget( l );
298 335
299 m_optVerboseIpkg = new QComboBox( container ); 336 m_optVerboseIpkg = new QComboBox( container );
300 m_optVerboseIpkg->insertItem( tr( "Errors only" ) ); 337 m_optVerboseIpkg->insertItem( tr( "Errors only" ) );
301 m_optVerboseIpkg->insertItem( tr( "Normal messages" ) ); 338 m_optVerboseIpkg->insertItem( tr( "Normal messages" ) );
302 m_optVerboseIpkg->insertItem( tr( "Informative messages" ) ); 339 m_optVerboseIpkg->insertItem( tr( "Informative messages" ) );
303 m_optVerboseIpkg->insertItem( tr( "Troubleshooting output" ) ); 340 m_optVerboseIpkg->insertItem( tr( "Troubleshooting output" ) );
304 layout->addWidget( m_optVerboseIpkg ); 341 layout->addWidget( m_optVerboseIpkg );
305 342
306 layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); 343 layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ) );
307} 344}
308 345
309void OIpkgConfigDlg::initData() 346void OIpkgConfigDlg::initData()
310{ 347{
311 // Read ipkg configuration (server/destination/proxy) information 348 // Read ipkg configuration (server/destination/proxy) information
312 if ( m_ipkg && !m_installOptions ) 349 if ( m_ipkg && !m_installOptions )
313 { 350 {
314 m_configs = m_ipkg->configItems(); 351 m_configs = m_ipkg->configItems();
315 if ( m_configs ) 352 if ( m_configs )
316 { 353 {
317 for ( OConfItemListIterator configIt( *m_configs ); configIt.current(); ++configIt ) 354 for ( OConfItemListIterator configIt( *m_configs ); configIt.current(); ++configIt )
318 { 355 {
319 OConfItem *config = configIt.current(); 356 OConfItem *config = configIt.current();
320 357
321 // Add configuration item to the appropriate dialog controls 358 // Add configuration item to the appropriate dialog controls
322 if ( config ) 359 if ( config )
323 { 360 {
324 if ( config->type() == OConfItem::Source ) 361 if ( config->type() == OConfItem::Source )
325 { 362 {
326 m_serverList->insertItem( config->name() ); 363 m_serverList->insertItem( config->name() );
327 } 364 }
328 else if ( config->type() == OConfItem::Destination ) 365 else if ( config->type() == OConfItem::Destination )
329 { 366 {
330 m_destList->insertItem( config->name() ); 367 m_destList->insertItem( config->name() );
331 } 368 }
332 else if ( config->type() == OConfItem::Option ) 369 else if ( config->type() == OConfItem::Option )
333 { 370 {
334 if ( config->name() == "http_proxy" ) 371 if ( config->name() == "http_proxy" )
335 { 372 {
336 m_proxyHttpServer->setText( config->value() ); 373 m_proxyHttpServer->setText( config->value() );
337 m_proxyHttpActive->setChecked( config->active() ); 374 m_proxyHttpActive->setChecked( config->active() );
338 } 375 }
339 else if ( config->name() == "ftp_proxy" ) 376 else if ( config->name() == "ftp_proxy" )
340 { 377 {
341 m_proxyFtpServer->setText( config->value() ); 378 m_proxyFtpServer->setText( config->value() );
342 m_proxyFtpActive->setChecked( config->active() ); 379 m_proxyFtpActive->setChecked( config->active() );
343 } 380 }
344 else if ( config->name() == "proxy_username" ) 381 else if ( config->name() == "proxy_username" )
345 { 382 {
346 m_proxyUsername->setText( config->value() ); 383 m_proxyUsername->setText( config->value() );
347 } 384 }
348 else if ( config->name() == "proxy_password" ) 385 else if ( config->name() == "proxy_password" )
349 { 386 {
350 m_proxyPassword->setText( config->value() ); 387 m_proxyPassword->setText( config->value() );
351 } 388 }
352 } 389 }
353 } 390 }
354 } 391 }
355 } 392 }
356 } 393 }
357 394
358 // Get Ipkg execution options 395 // Get Ipkg execution options
359 int options = m_ipkg->ipkgExecOptions(); 396 int options = m_ipkg->ipkgExecOptions();
360 if ( options & FORCE_DEPENDS ) 397 if ( options & FORCE_DEPENDS )
361 m_optForceDepends->setChecked( true ); 398 m_optForceDepends->setChecked( true );
362 if ( options & FORCE_REINSTALL ) 399 if ( options & FORCE_REINSTALL )
363 m_optForceReinstall->setChecked( true ); 400 m_optForceReinstall->setChecked( true );
364 if ( options & FORCE_REMOVE ) 401 if ( options & FORCE_REMOVE )
365 m_optForceRemove->setChecked( true ); 402 m_optForceRemove->setChecked( true );
366 if ( options & FORCE_OVERWRITE ) 403 if ( options & FORCE_OVERWRITE )
367 m_optForceOverwrite->setChecked( true ); 404 m_optForceOverwrite->setChecked( true );
368 405
369 m_optVerboseIpkg->setCurrentItem( m_ipkg->ipkgExecVerbosity() ); 406 m_optVerboseIpkg->setCurrentItem( m_ipkg->ipkgExecVerbosity() );
370} 407}
371 408
372OConfItem *OIpkgConfigDlg::findConfItem( OConfItem::Type type, const QString &name ) 409OConfItem *OIpkgConfigDlg::findConfItem( OConfItem::Type type, const QString &name )
373{ 410{
374 // Find selected server in list 411 // Find selected server in list
375 OConfItemListIterator configIt( *m_configs ); 412 OConfItemListIterator configIt( *m_configs );
376 OConfItem *config = 0x0; 413 OConfItem *config = 0x0;
377 for ( ; configIt.current(); ++configIt ) 414 for ( ; configIt.current(); ++configIt )
378 { 415 {
379 config = configIt.current(); 416 config = configIt.current();
380 if ( config->type() == type && config->name() == name ) 417 if ( config->type() == type && config->name() == name )
381 break; 418 break;
382 } 419 }
383 420
384 if ( config && config->type() == type && config->name() == name ) 421 if ( config && config->type() == type && config->name() == name )
385 return config; 422 return config;
386 423
387 return 0x0; 424 return 0x0;
388} 425}
389 426
390void OIpkgConfigDlg::slotServerEdit( int index ) 427void OIpkgConfigDlg::slotServerEdit( int index )
391{ 428{
392 m_serverNew = false; 429 m_serverNew = false;
393 m_serverCurrent = index; 430 m_serverCurrent = index;
394 431
395 // Find selected server in list 432 // Find selected server in list
396 OConfItem *server = findConfItem( OConfItem::Source, m_serverList->currentText() ); 433 OConfItem *server = findConfItem( OConfItem::Source, m_serverList->currentText() );
397 434
398 // Display server details 435 // Display server details
399 if ( server ) 436 if ( server )
400 { 437 {
401 m_serverCurrName = server->name(); 438 m_serverCurrName = server->name();
402 m_serverName->setText( server->name() ); 439 m_serverName->setText( server->name() );
403 m_serverLocation->setText( server->value() ); 440 m_serverLocation->setText( server->value() );
404 m_serverActive->setChecked( server->active() ); 441 m_serverActive->setChecked( server->active() );
405 m_serverName->setFocus(); 442 m_serverName->setFocus();
406 } 443 }
407} 444}
408 445
409void OIpkgConfigDlg::slotServerNew() 446void OIpkgConfigDlg::slotServerNew()
410{ 447{
411 m_serverNew = true; 448 m_serverNew = true;
412 449
413 m_serverName->setText( QString::null ); 450 m_serverName->setText( QString::null );
414 m_serverLocation->setText( QString::null ); 451 m_serverLocation->setText( QString::null );
415 m_serverActive->setChecked( true ); 452 m_serverActive->setChecked( true );
416 m_serverName->setFocus(); 453 m_serverName->setFocus();
417} 454}
418 455
419void OIpkgConfigDlg::slotServerDelete() 456void OIpkgConfigDlg::slotServerDelete()
420{ 457{
421 // Find selected server in list 458 // Find selected server in list
422 OConfItem *server = findConfItem( OConfItem::Source, m_serverList->currentText() ); 459 OConfItem *server = findConfItem( OConfItem::Source, m_serverList->currentText() );
423 460
424 // Delete server 461 // Delete server
425 if ( server ) 462 if ( server )
426 { 463 {
427 m_configs->removeRef( server ); 464 m_configs->removeRef( server );
428 m_serverList->removeItem( m_serverCurrent ); 465 m_serverList->removeItem( m_serverCurrent );
429 } 466 }
430} 467}
431 468
432void OIpkgConfigDlg::slotServerUpdate() 469void OIpkgConfigDlg::slotServerUpdate()
433{ 470{
434 QString newName = m_serverName->text(); 471 QString newName = m_serverName->text();
435 472
436 // Convert any spaces to underscores 473 // Convert any spaces to underscores
437 newName.replace( QRegExp( " " ), "_" ); 474 newName.replace( QRegExp( " " ), "_" );
438 475
439 if ( !m_serverNew ) 476 if ( !m_serverNew )
440 { 477 {
441 // Find selected server in list 478 // Find selected server in list
442 OConfItem *server = findConfItem( OConfItem::Source, m_serverCurrName ); 479 OConfItem *server = findConfItem( OConfItem::Source, m_serverCurrName );
443 480
444 // Delete server 481 // Delete server
445 if ( server ) 482 if ( server )
446 { 483 {
447 // Update url 484 // Update url
448 server->setValue( m_serverLocation->text() ); 485 server->setValue( m_serverLocation->text() );
449 server->setActive( m_serverActive->isChecked() ); 486 server->setActive( m_serverActive->isChecked() );
450 487
451 // Check if server name has changed, if it has then we need to replace the key in the map 488 // Check if server name has changed, if it has then we need to replace the key in the map
452 if ( m_serverCurrName != newName ) 489 if ( m_serverCurrName != newName )
453 { 490 {
454 // Update server name 491 // Update server name
455 server->setName( newName ); 492 server->setName( newName );
456 493
457 // Update list box 494 // Update list box
458 m_serverList->changeItem( newName, m_serverCurrent ); 495 m_serverList->changeItem( newName, m_serverCurrent );
459 } 496 }
460 } 497 }
461 } 498 }
462 else 499 else
463 { 500 {
464 // Add new destination to configuration list 501 // Add new destination to configuration list
465 m_configs->append( new OConfItem( QString::null, OConfItem::Source, newName, 502 m_configs->append( new OConfItem( QString::null, OConfItem::Source, newName,
466 m_serverLocation->text(), m_serverActive->isChecked() ) ); 503 m_serverLocation->text(), m_serverActive->isChecked() ) );
467 m_configs->sort(); 504 m_configs->sort();
468 505
469 m_serverList->insertItem( newName ); 506 m_serverList->insertItem( newName );
470 m_serverList->setCurrentItem( m_serverList->count() ); 507 m_serverList->setCurrentItem( m_serverList->count() );
471 m_serverNew = false; 508 m_serverNew = false;
472 m_serverList->insertItem( newName ); 509 m_serverList->insertItem( newName );
473 } 510 }
474} 511}
475 512
476void OIpkgConfigDlg::slotDestEdit( int index ) 513void OIpkgConfigDlg::slotDestEdit( int index )
477{ 514{
478 m_destNew = false; 515 m_destNew = false;
479 m_destCurrent = index; 516 m_destCurrent = index;
480 517
481 // Find selected destination in list 518 // Find selected destination in list
482 OConfItem *destination = findConfItem( OConfItem::Destination, m_destList->currentText() ); 519 OConfItem *destination = findConfItem( OConfItem::Destination, m_destList->currentText() );
483 520
484 // Display destination details 521 // Display destination details
485 if ( destination ) 522 if ( destination )
486 { 523 {
487 m_destCurrName = destination->name(); 524 m_destCurrName = destination->name();
488 m_destName->setText( destination->name() ); 525 m_destName->setText( destination->name() );
489 m_destLocation->setText( destination->value() ); 526 m_destLocation->setText( destination->value() );
490 m_destActive->setChecked( destination->active() ); 527 m_destActive->setChecked( destination->active() );
491 m_destName->setFocus(); 528 m_destName->setFocus();
492 } 529 }
493} 530}
494 531
495void OIpkgConfigDlg::slotDestNew() 532void OIpkgConfigDlg::slotDestNew()
496{ 533{
497 m_destNew = true; 534 m_destNew = true;
498 535
499 m_destName->setText( QString::null ); 536 m_destName->setText( QString::null );
500 m_destLocation->setText( QString::null ); 537 m_destLocation->setText( QString::null );
501 m_destActive->setChecked( true ); 538 m_destActive->setChecked( true );
502 m_destName->setFocus(); 539 m_destName->setFocus();
503} 540}
504 541
505void OIpkgConfigDlg::slotDestDelete() 542void OIpkgConfigDlg::slotDestDelete()
506{ 543{
507 // Find selected destination in list 544 // Find selected destination in list
508 OConfItem *destination = findConfItem( OConfItem::Destination, m_destList->currentText() ); 545 OConfItem *destination = findConfItem( OConfItem::Destination, m_destList->currentText() );
509 546
510 // Delete destination 547 // Delete destination
511 if ( destination ) 548 if ( destination )
512 { 549 {
513 m_configs->removeRef( destination ); 550 m_configs->removeRef( destination );
514 m_destList->removeItem( m_destCurrent ); 551 m_destList->removeItem( m_destCurrent );
515 } 552 }
516} 553}
517 554
518void OIpkgConfigDlg::slotDestUpdate() 555void OIpkgConfigDlg::slotDestUpdate()
519{ 556{
520 QString newName = m_destName->text(); 557 QString newName = m_destName->text();
521 558
522 // Convert any spaces to underscores 559 // Convert any spaces to underscores
523 newName.replace( QRegExp( " " ), "_" ); 560 newName.replace( QRegExp( " " ), "_" );
524 561
525 if ( !m_destNew ) 562 if ( !m_destNew )
526 { 563 {
527 // Find selected destination in list 564 // Find selected destination in list
528 OConfItem *destination = findConfItem( OConfItem::Destination, m_destCurrName ); 565 OConfItem *destination = findConfItem( OConfItem::Destination, m_destCurrName );
529 566
530 // Display destination details 567 // Display destination details
531 if ( destination ) 568 if ( destination )
532 { 569 {
533 // Update url 570 // Update url
534 destination->setValue( m_destLocation->text() ); 571 destination->setValue( m_destLocation->text() );
535 destination->setActive( m_destActive->isChecked() ); 572 destination->setActive( m_destActive->isChecked() );
536 573
537 // Check if destination name has changed, if it has then we need to replace the key in the map 574 // Check if destination name has changed, if it has then we need to replace the key in the map
538 if ( m_destCurrName != newName ) 575 if ( m_destCurrName != newName )
539 { 576 {
540 // Update destination name 577 // Update destination name
541 destination->setName( newName ); 578 destination->setName( newName );
542 579
543 // Update list box 580 // Update list box
544 m_destList->changeItem( newName, m_destCurrent ); 581 m_destList->changeItem( newName, m_destCurrent );
545 } 582 }
546 } 583 }
547 } 584 }
548 else 585 else
549 { 586 {
550 // Add new destination to configuration list 587 // Add new destination to configuration list
551 m_configs->append( new OConfItem( QString::null, OConfItem::Destination, newName, 588 m_configs->append( new OConfItem( QString::null, OConfItem::Destination, newName,
552 m_destLocation->text(), m_destActive->isChecked() ) ); 589 m_destLocation->text(), m_destActive->isChecked() ) );
553 m_configs->sort(); 590 m_configs->sort();
554 591
555 m_destList->insertItem( newName ); 592 m_destList->insertItem( newName );
556 m_destList->setCurrentItem( m_destList->count() ); 593 m_destList->setCurrentItem( m_destList->count() );
557 m_destNew = false; 594 m_destNew = false;
558 } 595 }
559} 596}