summaryrefslogtreecommitdiff
path: root/noncore/settings/packagemanager/oipkgconfigdlg.cpp
blob: 78a18f7c4d6db5da63c19243c6e641ea21a9d5e4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
/*
                             This file is part of the Opie Project

                             Copyright (C)2004, 2005 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 <opie2/ofiledialog.h>
#include <opie2/oresource.h>

#include <qpe/qpeapplication.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 <qwhatsthis.h>

OIpkgConfigDlg::OIpkgConfigDlg( OIpkg *ipkg, bool installOptions, QWidget *parent )
    : QDialog( parent, QString::null, true, WStyle_ContextHelp )
    , m_ipkg( ipkg )
    , m_configs( 0l )
    , m_installOptions( installOptions )
    , m_serverCurrent( -1 )
    , 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" ) );
    }
}

void OIpkgConfigDlg::accept()
{
    // Save server, destination and proxy configuration
    if ( !m_installOptions )
    {
        // Update proxy information before saving settings
        OConfItem *confItem = m_ipkg->findConfItem( OConfItem::Option, "http_proxy" );
        if ( confItem )
        {
            confItem->setValue( m_proxyHttpServer->text() );
            confItem->setActive( m_proxyHttpActive->isChecked() );
        }
        else
            m_configs->append( new OConfItem( OConfItem::Option, "http_proxy",
                               m_proxyHttpServer->text(), QString::null,
                               m_proxyHttpActive->isChecked() ) );

        confItem = m_ipkg->findConfItem( OConfItem::Option, "ftp_proxy" );
        if ( confItem )
        {
            confItem->setValue( m_proxyFtpServer->text() );
            confItem->setActive( m_proxyFtpActive->isChecked() );
        }
        else
            m_configs->append( new OConfItem( OConfItem::Option, "ftp_proxy",
                               m_proxyFtpServer->text(), QString::null,
                               m_proxyFtpActive->isChecked() ) );

        confItem = m_ipkg->findConfItem( OConfItem::Option, "proxy_username" );
        if ( confItem )
            confItem->setValue( m_proxyUsername->text() );
        else
            m_configs->append( new OConfItem( OConfItem::Option, "proxy_username",
                               m_proxyUsername->text() ) );

        confItem = m_ipkg->findConfItem( OConfItem::Option, "proxy_password" );
        if ( confItem )
            confItem->setValue( m_proxyPassword->text() );
        else
            m_configs->append( new OConfItem( OConfItem::Option, "proxy_password",
                               m_proxyPassword->text() ) );

        QString listsDir = m_optSourceLists->text();
        if ( listsDir == QString::null || listsDir == "" )
            listsDir = "/usr/lib/ipkg/lists"; // TODO - use proper libipkg define
        confItem = m_ipkg->findConfItem( OConfItem::Other, "lists_dir" );
        if ( confItem )
            confItem->setValue( listsDir );
        else
            m_configs->append( new OConfItem( OConfItem::Other, "lists_dir",
                               listsDir, "name" ) );

        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;
    if ( m_optForceRecursive->isChecked() )
        options |= FORCE_RECURSIVE;
    if ( m_optVerboseWget->isChecked() )
        options |= FORCE_VERBOSE_WGET;
    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, 2, 3, 2, 4 );

    m_serverList = new QListBox( container );
    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." ) );
    m_serverList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
    connect( m_serverList, SIGNAL(highlighted(int)), this, SLOT(slotServerSelected(int)) );
    layout->addMultiCellWidget( m_serverList, 0, 0, 0, 2 );

    QPushButton *btn = new QPushButton( Opie::Core::OResource::loadPixmap( "new", Opie::Core::OResource::SmallIcon ),
                                        tr( "New" ), container );
    btn->setMinimumHeight( AppLnk::smallIconSize()+4 );
    QWhatsThis::add( btn, tr( "Tap here to create a new entry.  Fill in the fields below and then tap on Update." ) );
    connect( btn, SIGNAL(clicked()), this, SLOT(slotServerNew()) );
    layout->addWidget( btn, 1, 0 );

    m_serverEditBtn = new QPushButton( Opie::Core::OResource::loadPixmap( "edit", Opie::Core::OResource::SmallIcon ),
                                       tr( "Edit" ), container );
    m_serverEditBtn->setMinimumHeight( AppLnk::smallIconSize()+4 );
    m_serverEditBtn->setEnabled( false );
    QWhatsThis::add( m_serverEditBtn, tr( "Tap here to edit the entry selected above." ) );
    connect( m_serverEditBtn, SIGNAL(clicked()), this, SLOT(slotServerEdit()) );
    layout->addWidget( m_serverEditBtn, 1, 1 );

    m_serverDeleteBtn = new QPushButton( Opie::Core::OResource::loadPixmap( "trash", Opie::Core::OResource::SmallIcon ),
                                         tr( "Delete" ), container );
    m_serverDeleteBtn->setMinimumHeight( AppLnk::smallIconSize()+4 );
    m_serverDeleteBtn->setEnabled( false );
    QWhatsThis::add( m_serverDeleteBtn, tr( "Tap here to delete the entry selected above." ) );
    connect( m_serverDeleteBtn, SIGNAL(clicked()), this, SLOT(slotServerDelete()) );
    layout->addWidget( m_serverDeleteBtn, 1, 2 );
}

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, 2, 3, 2, 4 );

    m_destList = new QListBox( container );
    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." ) );
    m_destList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
    connect( m_destList, SIGNAL(highlighted(int)), this, SLOT(slotDestSelected(int)) );
    layout->addMultiCellWidget( m_destList, 0, 0, 0, 2 );

    QPushButton *btn = new QPushButton( Opie::Core::OResource::loadPixmap( "new", Opie::Core::OResource::SmallIcon ),
                                        tr( "New" ), container );
    btn->setMinimumHeight( AppLnk::smallIconSize()+4 );
    QWhatsThis::add( btn, tr( "Tap here to create a new entry.  Fill in the fields below and then tap on Update." ) );
    connect( btn, SIGNAL(clicked()), this, SLOT(slotDestNew()) );
    layout->addWidget( btn, 1, 0 );

    m_destEditBtn = new QPushButton( Opie::Core::OResource::loadPixmap( "edit", Opie::Core::OResource::SmallIcon ),
                                     tr( "Edit" ), container );
    m_destEditBtn->setMinimumHeight( AppLnk::smallIconSize()+4 );
    m_destEditBtn->setEnabled( false );
    QWhatsThis::add( m_destEditBtn, tr( "Tap here to edit the entry selected above." ) );
    connect( m_destEditBtn, SIGNAL(clicked()), this, SLOT(slotDestEdit()) );
    layout->addWidget( m_destEditBtn, 1, 1 );

    m_destDeleteBtn = new QPushButton( Opie::Core::OResource::loadPixmap( "trash", Opie::Core::OResource::SmallIcon ),
                                       tr( "Delete" ), container );
    m_destDeleteBtn->setMinimumHeight( AppLnk::smallIconSize()+4 );
    m_destDeleteBtn->setEnabled( false );
    QWhatsThis::add( m_destDeleteBtn, tr( "Tap here to delete the entry selected above." ) );
    connect( m_destDeleteBtn, SIGNAL(clicked()), this, SLOT(slotDestDelete()) );
    layout->addWidget( m_destDeleteBtn, 1, 2 );
}

void OIpkgConfigDlg::initProxyWidget()
{
    m_proxyWidget = new QWidget( this );

    // Initialize UI
    QVBoxLayout *vb = new QVBoxLayout( m_proxyWidget );
    QScrollView *sv = new QScrollView( m_proxyWidget );
    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, 4, 2, 2, 4 );

    // HTTP proxy server configuration
    QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "HTTP Proxy" ), container );
    grpbox->layout()->setSpacing( 2 );
    grpbox->layout()->setMargin( 4 );
    layout->addMultiCellWidget( grpbox, 0, 0, 0, 1 );
    QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() );
    m_proxyHttpServer = new QLineEdit( grpbox );
    QWhatsThis::add( m_proxyHttpServer, tr( "Enter the URL address of the HTTP proxy server here." ) );
    grplayout->addWidget( m_proxyHttpServer );
    m_proxyHttpActive = new QCheckBox( tr( "Enabled" ), grpbox );
    QWhatsThis::add( m_proxyHttpActive, tr( "Tap here to enable or disable the HTTP proxy server." ) );
    grplayout->addWidget( m_proxyHttpActive );

    // FTP proxy server configuration
    grpbox = new QGroupBox( 0, Qt::Vertical, tr( "FTP Proxy" ), container );
    grpbox->layout()->setSpacing( 2 );
    grpbox->layout()->setMargin( 4 );
    layout->addMultiCellWidget( grpbox, 1, 1, 0, 1 );
    grplayout = new QVBoxLayout( grpbox->layout() );
    m_proxyFtpServer = new QLineEdit( grpbox );
    QWhatsThis::add( m_proxyFtpServer, tr( "Enter the URL address of the FTP proxy server here." ) );
    grplayout->addWidget( m_proxyFtpServer );
    m_proxyFtpActive = new QCheckBox( tr( "Enabled" ), grpbox );
    QWhatsThis::add( m_proxyFtpActive, tr( "Tap here to enable or disable the FTP proxy server." ) );
    grplayout->addWidget( m_proxyFtpActive );

    // Proxy server username and password configuration
    QLabel *label = new QLabel( tr( "Username:" ), container );
    QWhatsThis::add( label, tr( "Enter the username for the proxy servers here." ) );
    layout->addWidget( label, 2, 0 );
    m_proxyUsername = new QLineEdit( container );
    QWhatsThis::add( m_proxyUsername, tr( "Enter the username for the proxy servers here." ) );
    layout->addWidget( m_proxyUsername, 2, 1 );

    label = new QLabel( tr( "Password:" ), container );
    QWhatsThis::add( label, tr( "Enter the password for the proxy servers here." ) );
    layout->addWidget( label, 3, 0 );
    m_proxyPassword = new QLineEdit( container );
    QWhatsThis::add( m_proxyPassword, tr( "Enter the password for the proxy servers here." ) );
    layout->addWidget( m_proxyPassword, 3, 1 );
}

void OIpkgConfigDlg::initOptionsWidget()
{
    m_optionsWidget = new QWidget( this );

    // Initialize UI
    QVBoxLayout *vb = new QVBoxLayout( m_optionsWidget );
    QScrollView *sv = new QScrollView( m_optionsWidget );
    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, 8, 2, 2, 4 );

    m_optForceDepends = new QCheckBox( tr( "Force Depends" ), container );
    QWhatsThis::add( m_optForceDepends, tr( "Tap here to enable or disable the '-force-depends' option for Ipkg." ) );
    layout->addMultiCellWidget( m_optForceDepends, 0, 0, 0, 1 );

    m_optForceReinstall = new QCheckBox( tr( "Force Reinstall" ), container );
    QWhatsThis::add( m_optForceReinstall, tr( "Tap here to enable or disable the '-force-reinstall' option for Ipkg." ) );
    layout->addMultiCellWidget( m_optForceReinstall, 1, 1, 0, 1 );

    m_optForceRemove = new QCheckBox( tr( "Force Remove" ), container );
    QWhatsThis::add( m_optForceRemove, tr( "Tap here to enable or disable the '-force-removal-of-dependent-packages' option for Ipkg." ) );
    layout->addMultiCellWidget( m_optForceRemove, 2, 2, 0, 1 );

    m_optForceOverwrite = new QCheckBox( tr( "Force Overwrite" ), container );
    QWhatsThis::add( m_optForceOverwrite, tr( "Tap here to enable or disable the '-force-overwrite' option for Ipkg." ) );
    layout->addMultiCellWidget( m_optForceOverwrite, 3, 3, 0, 1 );

    m_optForceRecursive = new QCheckBox( tr( "Force Recursive" ), container );
    QWhatsThis::add( m_optForceRecursive, tr( "Tap here to enable or disable the '-recursive' option for Ipkg." ) );
    layout->addMultiCellWidget( m_optForceRecursive, 4, 4, 0, 1 );

    m_optVerboseWget = new QCheckBox( tr( "Verbose fetch" ), container );
    QWhatsThis::add( m_optVerboseWget, tr( "Tap here to enable or disable the '-verbose_wget' option for Ipkg." ) );
    layout->addMultiCellWidget( m_optVerboseWget, 5, 5, 0, 1 );

    QLabel *l = new QLabel( tr( "Information level:" ), container );
    QWhatsThis::add( l, tr( "Select information level for Ipkg." ) );
    layout->addMultiCellWidget( l, 6, 6, 0, 1 );

    m_optVerboseIpkg = new QComboBox( container );
    QWhatsThis::add( m_optVerboseIpkg, tr( "Select information level for Ipkg." ) );
    m_optVerboseIpkg->insertItem( tr( "Errors only" ) );
    m_optVerboseIpkg->insertItem( tr( "Normal messages" ) );
    m_optVerboseIpkg->insertItem( tr( "Informative messages" ) );
    m_optVerboseIpkg->insertItem( tr( "Troubleshooting output" ) );
    layout->addMultiCellWidget( m_optVerboseIpkg, 7, 7, 0, 1 );

    l = new QLabel( tr( "Package source lists directory:" ), container );
    QWhatsThis::add( l, tr( "Enter the directory where package source feed information is stored." ) );
    layout->addMultiCellWidget( l, 8, 8, 0, 1 );

    m_optSourceLists = new QLineEdit( container );
    QWhatsThis::add( m_optSourceLists, tr( "Enter the directory where package source feed information is stored." ) );
    layout->addWidget( m_optSourceLists, 9, 0 );

    QPushButton *btn = new QPushButton( Opie::Core::OResource::loadPixmap( "folder", Opie::Core::OResource::SmallIcon ),
                                        QString::null, container );
    btn->setMinimumHeight( AppLnk::smallIconSize()+4 );
    btn->setMaximumWidth( btn->height() );
    QWhatsThis::add( btn, tr( "Tap here to select the directory where package source feed information is stored." ) );
    connect( btn, SIGNAL(clicked()), this, SLOT(slotOptSelectSourceListsPath()) );
    layout->addWidget( btn, 9, 1 );

    layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ) );
}

void OIpkgConfigDlg::initData()
{
    // Read ipkg configuration (server/destination/proxy) information
    if ( m_ipkg && !m_installOptions )
    {
        m_configs = m_ipkg->configItems();
        if ( m_configs )
        {
            for ( OConfItemListIterator configIt( *m_configs ); configIt.current(); ++configIt )
            {
                OConfItem *config = configIt.current();

                // Add configuration item to the appropriate dialog controls
                if ( config )
                {
                    switch ( config->type() )
                    {
                        case OConfItem::Source :  m_serverList->insertItem( config->name() ); break;
                        case OConfItem::Destination : m_destList->insertItem( config->name() ); break;
                        case OConfItem::Option :
                            {
                                if ( config->name() == "http_proxy" )
                                {
                                    m_proxyHttpServer->setText( config->value() );
                                    m_proxyHttpActive->setChecked( config->active() );
                                }
                                else if ( config->name() == "ftp_proxy" )
                                {
                                    m_proxyFtpServer->setText( config->value() );
                                    m_proxyFtpActive->setChecked( config->active() );
                                }
                                else if ( config->name() == "proxy_username" )
                                {
                                    m_proxyUsername->setText( config->value() );
                                }
                                else if ( config->name() == "proxy_password" )
                                {
                                    m_proxyPassword->setText( config->value() );
                                }
                            }
                            break;
                        case OConfItem::Other :
                            {
                                if ( config->name() == "lists_dir" )
                                    m_optSourceLists->setText( config->value() );
                                else // TODO - use proper libipkg define
                                    m_optSourceLists->setText( "/usr/lib/ipkg/lists" );
                            }
                            break;
                        default : break;
                    };
                }
            }
        }
    }

    // Get Ipkg execution options
    int options = 0;
    if ( m_ipkg )
        options = m_ipkg->ipkgExecOptions();
    if ( options & FORCE_DEPENDS )
        m_optForceDepends->setChecked( true );
    if ( options & FORCE_REINSTALL )
        m_optForceReinstall->setChecked( true );
    if ( options & FORCE_REMOVE )
        m_optForceRemove->setChecked( true );
    if ( options & FORCE_OVERWRITE )
        m_optForceOverwrite->setChecked( true );
    if ( options & FORCE_RECURSIVE )
        m_optForceRecursive->setChecked( true );
    if ( options & FORCE_VERBOSE_WGET )
        m_optVerboseWget->setChecked( true );

    m_optVerboseIpkg->setCurrentItem( ( m_ipkg ? m_ipkg->ipkgExecVerbosity() : 0 ) );
}

void OIpkgConfigDlg::slotServerSelected( int index )
{
    m_serverCurrent = index;

    // Enable Edit and Delete buttons
    m_serverEditBtn->setEnabled( true );
    m_serverDeleteBtn->setEnabled( true );
}

void OIpkgConfigDlg::slotServerNew()
{
    OConfItem *server = new OConfItem( OConfItem::Source );

    OIpkgServerDlg dlg( server, this );
    if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted )
    {
        // Add to configuration option list
        m_configs->append( server );
        m_configs->sort();

        // Add to server list
        m_serverList->insertItem( server->name() );
        m_serverList->setCurrentItem( m_serverList->count() );
    }
    else
        delete server;
}

void OIpkgConfigDlg::slotServerEdit()
{
    // Find selected server in list
    OConfItem *server = m_ipkg->findConfItem( OConfItem::Source, m_serverList->currentText() );

    // Edit server
    if ( server )
    {
        QString origName = server->name();
        OIpkgServerDlg dlg( server, this );
        if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted )
        {
            // Check to see if name has changed, if so update the server list
            if ( server->name() != origName )
                m_serverList->changeItem( server->name(), m_serverCurrent );
        }
    }
}

void OIpkgConfigDlg::slotServerDelete()
{
    // Find selected server in list
    OConfItem *server = m_ipkg->findConfItem( OConfItem::Source, m_serverList->currentText() );

    // Delete server
    if ( server )
    {
        m_configs->removeRef( server );
        m_serverList->removeItem( m_serverCurrent );
    }
}

void OIpkgConfigDlg::slotDestSelected( int index )
{
    m_destCurrent = index;

    // Enable Edit and Delete buttons
    m_destEditBtn->setEnabled( true );
    m_destDeleteBtn->setEnabled( true );
}

void OIpkgConfigDlg::slotDestNew()
{
    OConfItem *dest = new OConfItem( OConfItem::Destination );

    OIpkgDestDlg dlg( dest, this );
    if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted )
    {
        // Add to configuration option list
        m_configs->append( dest );
        m_configs->sort();

        // Add to destination list
        m_destList->insertItem( dest->name() );
        m_destList->setCurrentItem( m_destList->count() );
    }
    else
        delete dest;
}

void OIpkgConfigDlg::slotDestEdit()
{
    // Find selected destination in list
    OConfItem *dest = m_ipkg->findConfItem( OConfItem::Destination, m_destList->currentText() );

    // Edit destination
    if ( dest )
    {
        QString origName = dest->name();
        OIpkgDestDlg dlg( dest, this );
        if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted )
        {
            // Check to see if name has changed, if so update the dest list
            if ( dest->name() != origName )
                m_destList->changeItem( dest->name(), m_destCurrent );
        }
    }
}

void OIpkgConfigDlg::slotDestDelete()
{
    // Find selected destination in list
    OConfItem *destination = m_ipkg->findConfItem( OConfItem::Destination, m_destList->currentText() );

    // Delete destination
    if ( destination )
    {
        m_configs->removeRef( destination );
        m_destList->removeItem( m_destCurrent );
    }
}

void OIpkgConfigDlg::slotOptSelectSourceListsPath()
{
    QString path = Opie::Ui::OFileDialog::getDirectory( 0, m_optSourceLists->text() );
    if ( path.at( path.length() - 1 ) == '/' )
        path.truncate( path.length() - 1 );
    if ( !path.isNull() )
        m_optSourceLists->setText( path );
}

OIpkgServerDlg::OIpkgServerDlg( OConfItem *server, QWidget *parent )
    : QDialog( parent, QString::null, true, WStyle_ContextHelp )
    , m_server( server )
{
    setCaption( tr( "Edit Server" ) );

    // Initialize UI
    QVBoxLayout *layout = new QVBoxLayout( this, 2, 4 );

    m_active = new QCheckBox( tr( "Active" ), this );
    QWhatsThis::add( m_active, tr( "Tap here to indicate whether this entry is active or not." ) );
    layout->addWidget( m_active );

    layout->addStretch();

    QLabel *label = new QLabel( tr( "Name:" ), this );
    QWhatsThis::add( label, tr( "Enter the name of this entry here." ) );
    layout->addWidget( label );
    m_name = new QLineEdit( this );
    QWhatsThis::add( m_name, tr( "Enter the name of this entry here." ) );
    layout->addWidget( m_name );

    layout->addStretch();

    label = new QLabel( tr( "Address:" ), this );
    QWhatsThis::add( label, tr( "Enter the URL address of this entry here." ) );
    layout->addWidget( label );
    m_location = new QLineEdit( this );
    QWhatsThis::add( m_location, tr( "Enter the URL address of this entry here." ) );
    layout->addWidget( m_location );

    layout->addStretch();

    m_compressed = new QCheckBox( tr( "Compressed server feed" ), this );
    QWhatsThis::add( m_compressed, tr( "Tap here to indicate whether the server support compressed archives or not." ) );
    layout->addWidget( m_compressed );

    // Populate initial information
    if ( m_server )
    {
        m_name->setText( m_server->name() );
        m_location->setText( m_server->value() );
        m_compressed->setChecked( m_server->features().contains( "Compressed" ) );
        m_active->setChecked( m_server->active() );
    }
}

void OIpkgServerDlg::accept()
{
    // Save information entered
    QString name = m_name->text();
    name.replace( QRegExp( " " ), "_" );
    m_server->setName( name );
    m_server->setValue( m_location->text() );
    m_compressed->isChecked() ? m_server->setFeatures( "Compressed" )
                              : m_server->setFeatures( QString::null );
    m_server->setActive( m_active->isChecked() );

    QDialog::accept();
}

OIpkgDestDlg::OIpkgDestDlg( OConfItem *dest, QWidget *parent )
    : QDialog( parent, QString::null, true, WStyle_ContextHelp )
    , m_dest( dest )
{
    setCaption( tr( "Edit Destination" ) );

    // Initialize UI
    QVBoxLayout *layout = new QVBoxLayout( this, 2, 4 );

    m_active = new QCheckBox( tr( "Active" ), this );
    QWhatsThis::add( m_active, tr( "Tap here to indicate whether this entry is active or not." ) );
    layout->addWidget( m_active );

    layout->addStretch();

    QLabel *label = new QLabel( tr( "Name:" ), this );
    QWhatsThis::add( label, tr( "Enter the name of this entry here." ) );
    layout->addWidget( label );
    m_name = new QLineEdit( this );
    QWhatsThis::add( m_name, tr( "Enter the name of this entry here." ) );
    layout->addWidget( m_name );

    layout->addStretch();

    label = new QLabel( tr( "Location:" ), this );
    QWhatsThis::add( label, tr( "Enter the absolute directory path of this entry here." ) );
    layout->addWidget( label );

    QHBoxLayout *layout2 = new QHBoxLayout( this, 2, 4 );
    layout->addLayout( layout2 );

    m_location = new QLineEdit( this );
    QWhatsThis::add( m_location, tr( "Enter the absolute directory path of this entry here." ) );
    layout2->addWidget( m_location );
    QPushButton *btn = new QPushButton( Opie::Core::OResource::loadPixmap( "folder", Opie::Core::OResource::SmallIcon ),
                                        QString::null, this );
    btn->setMaximumWidth( btn->height() );
    QWhatsThis::add( btn, tr( "Tap here to select the desired location." ) );
    connect( btn, SIGNAL(clicked()), this, SLOT(slotSelectPath()) );
    layout2->addWidget( btn );

    // Populate initial information
    if ( m_dest )
    {
        m_name->setText( m_dest->name() );
        m_location->setText( m_dest->value() );
        m_active->setChecked( m_dest->active() );
    }
}

void OIpkgDestDlg::accept()
{
    // Save information entered
    QString name = m_name->text();
    name.replace( QRegExp( " " ), "_" );
    m_dest->setName( name );
    m_dest->setValue( m_location->text() );
    m_dest->setActive( m_active->isChecked() );

    QDialog::accept();
}

void OIpkgDestDlg::slotSelectPath()
{
    QString path = Opie::Ui::OFileDialog::getDirectory( 0, m_location->text() );
    if ( path.at( path.length() - 1 ) == '/' )
        path.truncate( path.length() - 1 );
    if ( !path.isNull() )
        m_location->setText( path );
}