summaryrefslogtreecommitdiff
Side-by-side diff
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,190 +1,227 @@
/*
                This file is part of the Opie Project
              Copyright (c) 2003 Dan Williams <drw@handhelds.org>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "oipkgconfigdlg.h"
#include <qcheckbox.h>
#include <qcombobox.h>
#include <qgroupbox.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qlistbox.h>
#include <qpushbutton.h>
#include <qscrollview.h>
#include <qpe/resource.h>
using namespace Opie::Ui;
OIpkgConfigDlg::OIpkgConfigDlg( OIpkg *ipkg, bool installOptions, QWidget *parent )
: QDialog( parent, QString::null, true )
, m_ipkg( ipkg )
, m_configs( 0x0 )
, m_installOptions( installOptions )
, m_serverNew( false )
, m_serverCurrent( -1 )
, m_destNew( false )
, m_destCurrent( -1 )
, m_layout( this, 2, 4 )
, m_tabWidget( this )
{
setCaption( tr( "Configuration" ) );
// Initialize configuration widgets
if ( !installOptions )
{
initServerWidget();
initDestinationWidget();
initProxyWidget();
}
initOptionsWidget();
// Load configuration information
initData();
// Setup tabs for all info
m_layout.addWidget( &m_tabWidget );
if ( !m_installOptions )
{
m_tabWidget.addTab( m_serverWidget, "packagemanager/servertab", tr( "Servers" ) );
m_tabWidget.addTab( m_destWidget, "packagemanager/desttab", tr( "Destinations" ) );
m_tabWidget.addTab( m_proxyWidget, "packagemanager/proxytab", tr( "Proxies" ) );
m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) );
m_tabWidget.setCurrentTab( tr( "Servers" ) );
}
else
{
m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) );
}
//showMaximized();
}
void OIpkgConfigDlg::accept()
{
// Save server, destination and proxy configuration
if ( !m_installOptions )
+ {
+ // Update proxy information before saving settings
+ OConfItem *confItem = findConfItem( OConfItem::Option, "http_proxy" );
+ if ( confItem )
+ {
+ confItem->setValue( m_proxyHttpServer->text() );
+ confItem->setActive( m_proxyHttpActive->isChecked() );
+ }
+ else
+ m_configs->append( new OConfItem( QString::null, OConfItem::Option, "http_proxy",
+ m_proxyHttpServer->text(), m_proxyHttpActive->isChecked() ) );
+
+ confItem = findConfItem( OConfItem::Option, "ftp_proxy" );
+ if ( confItem )
+ {
+ confItem->setValue( m_proxyFtpServer->text() );
+ confItem->setActive( m_proxyFtpActive->isChecked() );
+ }
+ else
+ m_configs->append( new OConfItem( QString::null, OConfItem::Option, "ftp_proxy",
+ m_proxyFtpServer->text(), m_proxyFtpActive->isChecked() ) );
+
+ confItem = findConfItem( OConfItem::Option, "proxy_username" );
+ if ( confItem )
+ confItem->setValue( m_proxyUsername->text() );
+ else
+ m_configs->append( new OConfItem( QString::null, OConfItem::Option, "proxy_username",
+ m_proxyUsername->text() ) );
+
+ confItem = findConfItem( OConfItem::Option, "proxy_password" );
+ if ( confItem )
+ confItem->setValue( m_proxyPassword->text() );
+ else
+ m_configs->append( new OConfItem( QString::null, OConfItem::Option, "proxy_password",
+ m_proxyPassword->text() ) );
+
m_ipkg->setConfigItems( m_configs );
+ }
// Save options configuration
int options = 0;
if ( m_optForceDepends->isChecked() )
options |= FORCE_DEPENDS;
if ( m_optForceReinstall->isChecked() )
options |= FORCE_REINSTALL;
if ( m_optForceRemove->isChecked() )
options |= FORCE_REMOVE;
if ( m_optForceOverwrite->isChecked() )
options |= FORCE_OVERWRITE;
m_ipkg->setIpkgExecOptions( options );
m_ipkg->setIpkgExecVerbosity( m_optVerboseIpkg->currentItem() );
QDialog::accept();
}
void OIpkgConfigDlg::reject()
{
if ( m_configs )
delete m_configs;
}
void OIpkgConfigDlg::initServerWidget()
{
m_serverWidget = new QWidget( this );
// Initialize UI
QVBoxLayout *vb = new QVBoxLayout( m_serverWidget );
QScrollView *sv = new QScrollView( m_serverWidget );
vb->addWidget( sv, 0, 0 );
sv->setResizePolicy( QScrollView::AutoOneFit );
sv->setFrameStyle( QFrame::NoFrame );
QWidget *container = new QWidget( sv->viewport() );
sv->addChild( container );
QGridLayout *layout = new QGridLayout( container, 3, 2, 2, 4 );
m_serverList = new QListBox( container );
m_serverList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
connect( m_serverList, SIGNAL(highlighted(int)), this, SLOT(slotServerEdit(int)) );
layout->addMultiCellWidget( m_serverList, 0, 0, 0, 1 );
QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container );
connect( btn, SIGNAL(clicked()), this, SLOT(slotServerNew()) );
layout->addWidget( btn, 1, 0 );
btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container );
connect( btn, SIGNAL(clicked()), this, SLOT(slotServerDelete()) );
layout->addWidget( btn, 1, 1 );
QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container );
grpbox->layout()->setSpacing( 2 );
grpbox->layout()->setMargin( 4 );
layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 );
QGridLayout *grplayout = new QGridLayout( grpbox->layout() );
QLabel *label = new QLabel( tr( "Name:" ), grpbox );
grplayout->addWidget( label, 0, 0 );
m_serverName = new QLineEdit( grpbox );
grplayout->addWidget( m_serverName, 0, 1 );
label = new QLabel( tr( "Address:" ), grpbox );
grplayout->addWidget( label, 1, 0 );
m_serverLocation = new QLineEdit( grpbox );
grplayout->addWidget( m_serverLocation, 1, 1 );
m_serverActive = new QCheckBox( tr( "Active Server" ), grpbox );
grplayout->addMultiCellWidget( m_serverActive, 2, 2, 0, 1 );
btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox );
connect( btn, SIGNAL(clicked()), this, SLOT(slotServerUpdate()) );
grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 );
}
void OIpkgConfigDlg::initDestinationWidget()
{
m_destWidget = new QWidget( this );
// Initialize UI
QVBoxLayout *vb = new QVBoxLayout( m_destWidget );
QScrollView *sv = new QScrollView( m_destWidget );
vb->addWidget( sv, 0, 0 );
sv->setResizePolicy( QScrollView::AutoOneFit );
sv->setFrameStyle( QFrame::NoFrame );
QWidget *container = new QWidget( sv->viewport() );
sv->addChild( container );
QGridLayout *layout = new QGridLayout( container, 3, 2, 2, 4 );
m_destList = new QListBox( container );
m_destList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
connect( m_destList, SIGNAL(highlighted(int)), this, SLOT(slotDestEdit(int)) );
layout->addMultiCellWidget( m_destList, 0, 0, 0, 1 );
QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container );
connect( btn, SIGNAL(clicked()), this, SLOT(slotDestNew()) );