summaryrefslogtreecommitdiff
authordrw <drw>2004-04-21 18:20:31 (UTC)
committer drw <drw>2004-04-21 18:20:31 (UTC)
commitac414fa3802b471857bc84ecdd0d37200541b0a7 (patch) (unidiff)
treeb3557b5f67444c891f98fd3153a30d2cbd765636
parenta3c0ad0bddfdfd2a2ed476229df1ef8032a93871 (diff)
downloadopie-ac414fa3802b471857bc84ecdd0d37200541b0a7.zip
opie-ac414fa3802b471857bc84ecdd0d37200541b0a7.tar.gz
opie-ac414fa3802b471857bc84ecdd0d37200541b0a7.tar.bz2
Added some missed QWhatsThis, removed OConfItem location as it is not used/needed, reordered includes to follow conventions, removed all using namespaces occurrances and updated documentation
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/packagemanager/ChangeLog9
-rw-r--r--noncore/settings/packagemanager/README2
-rw-r--r--noncore/settings/packagemanager/TODO9
-rw-r--r--noncore/settings/packagemanager/entrydlg.cpp4
-rw-r--r--noncore/settings/packagemanager/filterdlg.h4
-rw-r--r--noncore/settings/packagemanager/global.h37
-rw-r--r--noncore/settings/packagemanager/installdlg.cpp15
-rw-r--r--noncore/settings/packagemanager/main.cpp3
-rw-r--r--noncore/settings/packagemanager/mainwindow.cpp22
-rw-r--r--noncore/settings/packagemanager/mainwindow.h8
-rw-r--r--noncore/settings/packagemanager/oconfitem.cpp5
-rw-r--r--noncore/settings/packagemanager/oconfitem.h35
-rw-r--r--noncore/settings/packagemanager/oipkg.cpp7
-rw-r--r--noncore/settings/packagemanager/oipkg.h14
-rw-r--r--noncore/settings/packagemanager/oipkgconfigdlg.cpp17
-rw-r--r--noncore/settings/packagemanager/oipkgconfigdlg.h16
-rw-r--r--noncore/settings/packagemanager/opackagemanager.cpp6
-rw-r--r--noncore/settings/packagemanager/opackagemanager.h8
-rw-r--r--noncore/settings/packagemanager/opie-packagemanager.control2
-rw-r--r--noncore/settings/packagemanager/packageinfodlg.cpp13
-rw-r--r--noncore/settings/packagemanager/packageinfodlg.h4
-rw-r--r--noncore/settings/packagemanager/promptdlg.cpp4
22 files changed, 105 insertions, 139 deletions
diff --git a/noncore/settings/packagemanager/ChangeLog b/noncore/settings/packagemanager/ChangeLog
index d53a2b3..c9e33c4 100644
--- a/noncore/settings/packagemanager/ChangeLog
+++ b/noncore/settings/packagemanager/ChangeLog
@@ -1,28 +1,37 @@
12004-04-21 Dan Williams <drw@handhelds.org>
2
3 * Released version 0.4.0
4 * Added saving of ipkg configuration information
5 * Re-initialize ipkg when configuration information changes
6 * Added QWhatsThis for all UI controls
7 * Remove Location from OConfItem as it is not used/needed
8 * Re-ordered includes to follow Opie standards
9
12004-02-13 Dan Williams <drw@handhelds.org> 102004-02-13 Dan Williams <drw@handhelds.org>
2 11
3 * Released version 0.3.0 12 * Released version 0.3.0
4 * Fix handling of filtering options in View menu 13 * Fix handling of filtering options in View menu
5 * Do proper version string comparison 14 * Do proper version string comparison
6 * Fix string alignment code in PromptDlg to eliminate QT warning messages 15 * Fix string alignment code in PromptDlg to eliminate QT warning messages
7 16
82004-02-12 Dan Williams <drw@handhelds.org> 172004-02-12 Dan Williams <drw@handhelds.org>
9 18
10 * Package information dialog implemented 19 * Package information dialog implemented
11 * What's This app icon enabled 20 * What's This app icon enabled
12 * Changed all QDialog::exec() occurences to QPEApplication::execDialog() 21 * Changed all QDialog::exec() occurences to QPEApplication::execDialog()
13 22
142004-01-23 Dan Williams <drw@handhelds.org> 232004-01-23 Dan Williams <drw@handhelds.org>
15 24
16 * Added package download functionality 25 * Added package download functionality
17 * Have Opie update links after install/removal so that apps 26 * Have Opie update links after install/removal so that apps
18 will display properly in Launcher 27 will display properly in Launcher
19 28
202004-01-20 Dan Williams <drw@handhelds.org> 292004-01-20 Dan Williams <drw@handhelds.org>
21 30
22 * Released version 0.2.0 31 * Released version 0.2.0
23 * Converted to use libipkg in place of spawning ipkg process 32 * Converted to use libipkg in place of spawning ipkg process
24 33
252004-01-13 Dan Williams <drw@handhelds.org> 342004-01-13 Dan Williams <drw@handhelds.org>
26 35
27 * Released version 0.1.0 36 * Released version 0.1.0
28 * Initial check-in of new package management client to eventually replace AQPkg 37 * Initial check-in of new package management client to eventually replace AQPkg
diff --git a/noncore/settings/packagemanager/README b/noncore/settings/packagemanager/README
index 9324f9c..bf93c98 100644
--- a/noncore/settings/packagemanager/README
+++ b/noncore/settings/packagemanager/README
@@ -1,55 +1,55 @@
1/************************************************************************ 1/************************************************************************
2/* 2/*
3/* Opie - Package Manager 3/* Opie - Package Manager
4/* ======================== 4/* ========================
5/* Version 0.3.0 5/* Version 0.4.0
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 Release Notes for Opie-PackageManager - January, 2004 12 Release Notes for Opie-PackageManager - January, 2004
13------------------------------------------------------- 13-------------------------------------------------------
14 14
15====================== 15======================
16= To-do = 16= To-do =
17====================== 17======================
18 18
19- See $OPIEDIR/noncore/settings/packagemanager/TODO for more info. 19- See $OPIEDIR/noncore/settings/packagemanager/TODO for more info.
20 20
21====================== 21======================
22= Build = 22= Build =
23====================== 23======================
24 24
25In order to build opie-packagemanager, libipkg needs to be present on 25In order to build opie-packagemanager, libipkg needs to be present on
26the build system along with the appropriate headers. 26the build system along with the appropriate headers.
27 27
28- libipkg source (best to use version 109 or greater): 28- libipkg source (best to use version 109 or greater):
29 - Familiar CVS directory: familiar/dist/ipkg/C (e.g. 'cvs co familiar/dist/ipkg/C') 29 - Familiar CVS directory: familiar/dist/ipkg/C (e.g. 'cvs co familiar/dist/ipkg/C')
30 - FTP: ftp://handhelds.org/linux/packages/ipkg 30 - FTP: ftp://handhelds.org/linux/packages/ipkg
31 31
32- before building opie-packagemanager, define the environmental variable 32- before building opie-packagemanager, define the environmental variable
33 IPKGDIR to point to the directory containing the ipkg source code 33 IPKGDIR to point to the directory containing the ipkg source code
34 - e.g. 'export IPKGDIR=$HOME/familiar/dist/ipkg/C' 34 - e.g. 'export IPKGDIR=$HOME/familiar/dist/ipkg/C'
35 35
36====================== 36======================
37= Run = 37= Run =
38====================== 38======================
39 39
40- In order to use opie-packagemanager, libipkg must be installed 40- In order to use opie-packagemanager, libipkg must be installed
41 on the system. 41 on the system.
42 42
43====================== 43======================
44= Credits = 44= Credits =
45====================== 45======================
46 46
47- Opie-PackageManager is (C) 2003-2004 Dan Williams 47- Opie-PackageManager is (C) 2003-2004 Dan Williams
48 48
49====================== 49======================
50= Links = 50= Links =
51====================== 51======================
52 52
53- Opie Project: http://opie.handhelds.org 53- Opie Project: http://opie.handhelds.org
54- OpenZaurus Project: http://openzaurus.org 54- OpenZaurus Project: http://openzaurus.org
55- Familiar Project: http://familiar.handhelds.org 55- Familiar Project: http://familiar.handhelds.org
diff --git a/noncore/settings/packagemanager/TODO b/noncore/settings/packagemanager/TODO
index 448ade3..633c589 100644
--- a/noncore/settings/packagemanager/TODO
+++ b/noncore/settings/packagemanager/TODO
@@ -1,28 +1,27 @@
1/************************************************************************ 1/************************************************************************
2/* 2/*
3/* Opie - Package Manager 3/* Opie - Package Manager
4/* ======================== 4/* ========================
5/* Version 0.3.0 5/* Version 0.4.0
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 - April, 2004 12 To-do for Opie-PackageManager - April, 2004
13--------------------------------------------- 13---------------------------------------------
14 14
15====================== 15======================
16= Current release = 16= Current release =
17====================== 17======================
18 18
191. Save configuration information (i.e. /etc/ipkg.conf) 191. Link non-root destination apps
202. Link non-root destination apps 202. Implement QCOP interface for installing, removing, etc.
213. Implement QCOP interface for installing, removing, etc. 213. Redesign configuration dialog
224. Redesign configuration dialog
23 22
24====================== 23======================
25= Future releases = 24= Future releases =
26====================== 25======================
27 26
281. ??? \ No newline at end of file 271. ??? \ No newline at end of file
diff --git a/noncore/settings/packagemanager/entrydlg.cpp b/noncore/settings/packagemanager/entrydlg.cpp
index 663abd2..fd275e1 100644
--- a/noncore/settings/packagemanager/entrydlg.cpp
+++ b/noncore/settings/packagemanager/entrydlg.cpp
@@ -1,85 +1,85 @@
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) 2004 Dan Williams <drw@handhelds.org> 4 =. Copyright (c) 2004 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 "entrydlg.h" 30#include "entrydlg.h"
31 31
32#include <qpe/qpeapplication.h>
33
32#include <qlabel.h> 34#include <qlabel.h>
33#include <qlayout.h> 35#include <qlayout.h>
34#include <qlineedit.h> 36#include <qlineedit.h>
35#include <qpushbutton.h> 37#include <qpushbutton.h>
36 38
37#include <qpe/qpeapplication.h>
38
39EntryDlg::EntryDlg( const QString &label, QWidget* parent, const char* name, bool modal ) 39EntryDlg::EntryDlg( const QString &label, QWidget* parent, const char* name, bool modal )
40 : QDialog( parent, name, modal ) 40 : QDialog( parent, name, modal )
41{ 41{
42 QVBoxLayout *vbox = new QVBoxLayout( this, 6, 6 ); 42 QVBoxLayout *vbox = new QVBoxLayout( this, 6, 6 );
43 43
44 QLabel *l = new QLabel( label, this ); 44 QLabel *l = new QLabel( label, this );
45 l->setAlignment( AlignLeft | AlignTop | WordBreak ); 45 l->setAlignment( AlignLeft | AlignTop | WordBreak );
46 vbox->addWidget( l ); 46 vbox->addWidget( l );
47 47
48 m_entry = new QLineEdit( this ); 48 m_entry = new QLineEdit( this );
49 vbox->addWidget( m_entry ); 49 vbox->addWidget( m_entry );
50 50
51 connect( m_entry, SIGNAL(returnPressed()), this, SLOT(tryAccept()) ); 51 connect( m_entry, SIGNAL(returnPressed()), this, SLOT(tryAccept()) );
52} 52}
53 53
54void EntryDlg::setText( const QString &text ) 54void EntryDlg::setText( const QString &text )
55{ 55{
56 m_entry->setText( text ); 56 m_entry->setText( text );
57 m_entry->selectAll(); 57 m_entry->selectAll();
58} 58}
59 59
60QString EntryDlg::getText() 60QString EntryDlg::getText()
61{ 61{
62 return m_entry->text(); 62 return m_entry->text();
63} 63}
64 64
65QString EntryDlg::getText( const QString &caption, const QString &label, const QString &text, bool *ok, 65QString EntryDlg::getText( const QString &caption, const QString &label, const QString &text, bool *ok,
66 QWidget *parent, const char *name ) 66 QWidget *parent, const char *name )
67{ 67{
68 EntryDlg *dlg = new EntryDlg( label, parent, name, true ); 68 EntryDlg *dlg = new EntryDlg( label, parent, name, true );
69 dlg->setCaption( caption ); 69 dlg->setCaption( caption );
70 dlg->setText( text ); 70 dlg->setText( text );
71 71
72 QString result; 72 QString result;
73 73
74 *ok = ( QPEApplication::execDialog( dlg ) == QDialog::Accepted ); 74 *ok = ( QPEApplication::execDialog( dlg ) == QDialog::Accepted );
75 if ( *ok ) 75 if ( *ok )
76 result = dlg->getText(); 76 result = dlg->getText();
77 77
78 delete dlg; 78 delete dlg;
79 return result; 79 return result;
80} 80}
81void EntryDlg::tryAccept() 81void EntryDlg::tryAccept()
82{ 82{
83 if ( !m_entry->text().isEmpty() ) 83 if ( !m_entry->text().isEmpty() )
84 accept(); 84 accept();
85} 85}
diff --git a/noncore/settings/packagemanager/filterdlg.h b/noncore/settings/packagemanager/filterdlg.h
index de9ea80..bd89b42 100644
--- a/noncore/settings/packagemanager/filterdlg.h
+++ b/noncore/settings/packagemanager/filterdlg.h
@@ -1,101 +1,101 @@
1/* 1/*
2                This file is part of the OPIE Project 2                This file is part of the OPIE Project
3 3
4 =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> 4 =. Copyright (c) 2003 Dan Williams <drw@handhelds.org>
5             .=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 FILTERDLG_H 30#ifndef FILTERDLG_H
31#define FILTERDLG_H 31#define FILTERDLG_H
32 32
33#include "opackagemanager.h"
34
33#include <qcheckbox.h> 35#include <qcheckbox.h>
34#include <qdialog.h> 36#include <qdialog.h>
35#include <qcombobox.h> 37#include <qcombobox.h>
36#include <qlayout.h> 38#include <qlayout.h>
37#include <qlineedit.h> 39#include <qlineedit.h>
38#include <qscrollview.h> 40#include <qscrollview.h>
39 41
40#include "opackagemanager.h"
41
42class FilterDlg : public QDialog 42class FilterDlg : public QDialog
43{ 43{
44 Q_OBJECT 44 Q_OBJECT
45 45
46public: 46public:
47 FilterDlg( QWidget *parent = 0x0, OPackageManager *pm = 0x0, const QString &name = 0x0, 47 FilterDlg( QWidget *parent = 0x0, OPackageManager *pm = 0x0, const QString &name = 0x0,
48 const QString &server = 0x0, const QString &destination = 0x0, 48 const QString &server = 0x0, const QString &destination = 0x0,
49 OPackageManager::Status status = OPackageManager::All, 49 OPackageManager::Status status = OPackageManager::All,
50 const QString &category = 0x0 ); 50 const QString &category = 0x0 );
51 51
52 QString name() 52 QString name()
53 { return m_nameCB->isChecked() ? m_name->text() : QString::null; }; 53 { return m_nameCB->isChecked() ? m_name->text() : QString::null; };
54 QString server() 54 QString server()
55 { return m_serverCB->isChecked() ? m_server->currentText() : QString::null; }; 55 { return m_serverCB->isChecked() ? m_server->currentText() : QString::null; };
56 QString destination() 56 QString destination()
57 { return m_destCB->isChecked() ? m_destination->currentText() : QString::null; }; 57 { return m_destCB->isChecked() ? m_destination->currentText() : QString::null; };
58 OPackageManager::Status status() 58 OPackageManager::Status status()
59 { 59 {
60 if ( m_statusCB->isChecked() ) 60 if ( m_statusCB->isChecked() )
61 { 61 {
62 if ( m_status->currentText() == tr( "All" ) ) 62 if ( m_status->currentText() == tr( "All" ) )
63 return OPackageManager::All; 63 return OPackageManager::All;
64 else if ( m_status->currentText() == tr( "Installed" ) ) 64 else if ( m_status->currentText() == tr( "Installed" ) )
65 return OPackageManager::Installed; 65 return OPackageManager::Installed;
66 else if ( m_status->currentText() == tr( "Not installed" ) ) 66 else if ( m_status->currentText() == tr( "Not installed" ) )
67 return OPackageManager::NotInstalled; 67 return OPackageManager::NotInstalled;
68 else if ( m_status->currentText() == tr( "Updated" ) ) 68 else if ( m_status->currentText() == tr( "Updated" ) )
69 return OPackageManager::Updated; 69 return OPackageManager::Updated;
70 } 70 }
71 71
72 return OPackageManager::NotDefined; 72 return OPackageManager::NotDefined;
73 }; 73 };
74 QString category() 74 QString category()
75 { return m_categoryCB->isChecked() ? m_category->currentText() : QString::null; }; 75 { return m_categoryCB->isChecked() ? m_category->currentText() : QString::null; };
76 76
77private: 77private:
78 QCheckBox *m_nameCB; 78 QCheckBox *m_nameCB;
79 QCheckBox *m_serverCB; 79 QCheckBox *m_serverCB;
80 QCheckBox *m_destCB; 80 QCheckBox *m_destCB;
81 QCheckBox *m_statusCB; 81 QCheckBox *m_statusCB;
82 QCheckBox *m_categoryCB; 82 QCheckBox *m_categoryCB;
83 83
84 QLineEdit *m_name; 84 QLineEdit *m_name;
85 QComboBox *m_server; 85 QComboBox *m_server;
86 QComboBox *m_destination; 86 QComboBox *m_destination;
87 QComboBox *m_status; 87 QComboBox *m_status;
88 QComboBox *m_category; 88 QComboBox *m_category;
89 89
90 void initItem( QComboBox *comboBox, QCheckBox *checkBox, const QString &selection ); 90 void initItem( QComboBox *comboBox, QCheckBox *checkBox, const QString &selection );
91 91
92private slots: 92private slots:
93 void slotNameSelected( bool ); 93 void slotNameSelected( bool );
94 void slotServerSelected( bool ); 94 void slotServerSelected( bool );
95 void slotDestSelected( bool ); 95 void slotDestSelected( bool );
96 void slotStatusSelected( bool ); 96 void slotStatusSelected( bool );
97 void slotStatusChanged( const QString & ); 97 void slotStatusChanged( const QString & );
98 void slotCategorySelected( bool ); 98 void slotCategorySelected( bool );
99}; 99};
100 100
101#endif 101#endif
diff --git a/noncore/settings/packagemanager/global.h b/noncore/settings/packagemanager/global.h
deleted file mode 100644
index 0fe5b85..0000000
--- a/noncore/settings/packagemanager/global.h
+++ b/dev/null
@@ -1,37 +0,0 @@
1/*
2                This file is part of the Opie Project
3
4              Copyright (c) 2003 Dan Williams <drw@handhelds.org>
5 =.
6 .=l.
7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details.
22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA.
29
30*/
31
32#ifndef GLOBAL_H
33#define GLOBAL_H
34
35#define VERSION "0.0.0"
36
37#endif \ No newline at end of file
diff --git a/noncore/settings/packagemanager/installdlg.cpp b/noncore/settings/packagemanager/installdlg.cpp
index 4a55c10..0cb30e2 100644
--- a/noncore/settings/packagemanager/installdlg.cpp
+++ b/noncore/settings/packagemanager/installdlg.cpp
@@ -1,302 +1,301 @@
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 <sys/vfs.h> 32#include <opie2/ofiledialog.h>
33
34#include <qpe/fileselector.h>
35#include <qpe/resource.h>
36#include <qpe/storage.h>
33 37
34#include <qapplication.h> 38#include <qapplication.h>
35#include <qcombobox.h> 39#include <qcombobox.h>
36#include <qfileinfo.h> 40#include <qfileinfo.h>
37#include <qgroupbox.h> 41#include <qgroupbox.h>
38#include <qlabel.h> 42#include <qlabel.h>
39#include <qlayout.h> 43#include <qlayout.h>
40#include <qmap.h> 44#include <qmap.h>
41#include <qmultilineedit.h> 45#include <qmultilineedit.h>
42#include <qpushbutton.h> 46#include <qpushbutton.h>
43 47
44#include <qpe/fileselector.h> 48#include <sys/vfs.h>
45#include <qpe/resource.h>
46#include <qpe/storage.h>
47
48#include <opie2/ofiledialog.h>
49 49
50#include "opackagemanager.h" 50#include "opackagemanager.h"
51 51
52using namespace Opie::Ui;
53InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &caption, bool showDestInfo, 52InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &caption, bool showDestInfo,
54 OPackage::Command command1, QStringList *packages1, 53 OPackage::Command command1, QStringList *packages1,
55 OPackage::Command command2, QStringList *packages2, 54 OPackage::Command command2, QStringList *packages2,
56 OPackage::Command command3, QStringList *packages3 ) 55 OPackage::Command command3, QStringList *packages3 )
57 : QWidget( 0x0 ) 56 : QWidget( 0x0 )
58 , m_packman( pm ) 57 , m_packman( pm )
59 , m_numCommands( 0 ) 58 , m_numCommands( 0 )
60 , m_currCommand( 0 ) 59 , m_currCommand( 0 )
61{ 60{
62 // Save command/package list information 61 // Save command/package list information
63 if ( command1 != OPackage::NotDefined ) 62 if ( command1 != OPackage::NotDefined )
64 { 63 {
65 m_command[ m_numCommands ] = command1; 64 m_command[ m_numCommands ] = command1;
66 m_packages[ m_numCommands ] = packages1; 65 m_packages[ m_numCommands ] = packages1;
67 ++m_numCommands; 66 ++m_numCommands;
68 } 67 }
69 if ( command2 != OPackage::NotDefined ) 68 if ( command2 != OPackage::NotDefined )
70 { 69 {
71 m_command[ m_numCommands ] = command2; 70 m_command[ m_numCommands ] = command2;
72 m_packages[ m_numCommands ] = packages2; 71 m_packages[ m_numCommands ] = packages2;
73 ++m_numCommands; 72 ++m_numCommands;
74 } 73 }
75 if ( command3 != OPackage::NotDefined ) 74 if ( command3 != OPackage::NotDefined )
76 { 75 {
77 m_command[ m_numCommands ] = command3; 76 m_command[ m_numCommands ] = command3;
78 m_packages[ m_numCommands ] = packages3; 77 m_packages[ m_numCommands ] = packages3;
79 ++m_numCommands; 78 ++m_numCommands;
80 } 79 }
81 80
82 // Initialize UI 81 // Initialize UI
83 if ( parent ) 82 if ( parent )
84 parent->setCaption( caption ); 83 parent->setCaption( caption );
85 84
86 QGridLayout *layout = new QGridLayout( this, 4, 2, 2, 4 ); 85 QGridLayout *layout = new QGridLayout( this, 4, 2, 2, 4 );
87 86
88 if ( showDestInfo ) 87 if ( showDestInfo )
89 { 88 {
90 QLabel *label = new QLabel( tr( "Destination" ), this ); 89 QLabel *label = new QLabel( tr( "Destination" ), this );
91 layout->addWidget( label, 0, 0 ); 90 layout->addWidget( label, 0, 0 );
92 m_destination = new QComboBox( this ); 91 m_destination = new QComboBox( this );
93 m_destination->insertStringList( *(m_packman->destinations()) ); 92 m_destination->insertStringList( *(m_packman->destinations()) );
94 layout->addWidget( m_destination, 0, 1 ); 93 layout->addWidget( m_destination, 0, 1 );
95 connect( m_destination, SIGNAL(highlighted(const QString&)), 94 connect( m_destination, SIGNAL(highlighted(const QString&)),
96 this, SLOT(slotDisplayAvailSpace(const QString&)) ); 95 this, SLOT(slotDisplayAvailSpace(const QString&)) );
97 96
98 label = new QLabel( tr( "Space Avail" ), this ); 97 label = new QLabel( tr( "Space Avail" ), this );
99 layout->addWidget( label, 1, 0 ); 98 layout->addWidget( label, 1, 0 );
100 m_availSpace = new QLabel( this ); 99 m_availSpace = new QLabel( this );
101 layout->addWidget( m_availSpace, 1, 1 ); 100 layout->addWidget( m_availSpace, 1, 1 );
102 101
103 // TODO - select correct destination 102 // TODO - select correct destination
104 slotDisplayAvailSpace( m_destination->currentText() ); 103 slotDisplayAvailSpace( m_destination->currentText() );
105 } 104 }
106 else 105 else
107 { 106 {
108 m_destination = 0x0; 107 m_destination = 0x0;
109 m_availSpace = 0x0; 108 m_availSpace = 0x0;
110 } 109 }
111 110
112 QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this ); 111 QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this );
113 groupBox->layout()->setSpacing( 0 ); 112 groupBox->layout()->setSpacing( 0 );
114 groupBox->layout()->setMargin( 4 ); 113 groupBox->layout()->setMargin( 4 );
115 114
116 QVBoxLayout *groupBoxLayout = new QVBoxLayout( groupBox->layout() ); 115 QVBoxLayout *groupBoxLayout = new QVBoxLayout( groupBox->layout() );
117 m_output = new QMultiLineEdit( groupBox ); 116 m_output = new QMultiLineEdit( groupBox );
118 m_output->setReadOnly( true ); 117 m_output->setReadOnly( true );
119 groupBoxLayout->addWidget( m_output ); 118 groupBoxLayout->addWidget( m_output );
120 layout->addMultiCellWidget( groupBox, 2, 2, 0, 1 ); 119 layout->addMultiCellWidget( groupBox, 2, 2, 0, 1 );
121 120
122 m_btnStart = new QPushButton( Resource::loadPixmap( "packagemanager/apply" ), tr( "Start" ), this ); 121 m_btnStart = new QPushButton( Resource::loadPixmap( "packagemanager/apply" ), tr( "Start" ), this );
123 layout->addWidget( m_btnStart, 3, 0 ); 122 layout->addWidget( m_btnStart, 3, 0 );
124 connect( m_btnStart, SIGNAL(clicked()), this, SLOT(slotBtnStart()) ); 123 connect( m_btnStart, SIGNAL(clicked()), this, SLOT(slotBtnStart()) );
125 124
126 m_btnOptions = new QPushButton( Resource::loadPixmap( "SettingsIcon" ), tr( "Options" ), this ); 125 m_btnOptions = new QPushButton( Resource::loadPixmap( "SettingsIcon" ), tr( "Options" ), this );
127 layout->addWidget( m_btnOptions, 3, 1 ); 126 layout->addWidget( m_btnOptions, 3, 1 );
128 connect( m_btnOptions, SIGNAL( clicked() ), this, SLOT(slotBtnOptions()) ); 127 connect( m_btnOptions, SIGNAL( clicked() ), this, SLOT(slotBtnOptions()) );
129 128
130 // Display packages being acted upon in output widget 129 // Display packages being acted upon in output widget
131 for( int i = 0; i < m_numCommands; i++ ) 130 for( int i = 0; i < m_numCommands; i++ )
132 { 131 {
133 if ( m_packages[ i ] ) 132 if ( m_packages[ i ] )
134 { 133 {
135 QString lineStr = tr( "Packages to " ); 134 QString lineStr = tr( "Packages to " );
136 135
137 switch( m_command[ i ] ) 136 switch( m_command[ i ] )
138 { 137 {
139 case OPackage::Install : lineStr.append( tr( "install" ) ); 138 case OPackage::Install : lineStr.append( tr( "install" ) );
140 break; 139 break;
141 case OPackage::Remove : lineStr.append( tr( "remove" ) ); 140 case OPackage::Remove : lineStr.append( tr( "remove" ) );
142 break; 141 break;
143 case OPackage::Upgrade : lineStr.append( tr( "upgrade" ) ); 142 case OPackage::Upgrade : lineStr.append( tr( "upgrade" ) );
144 break; 143 break;
145 case OPackage::Download : lineStr.append( tr( "download" ) ); 144 case OPackage::Download : lineStr.append( tr( "download" ) );
146 break; 145 break;
147 default : 146 default :
148 break; 147 break;
149 }; 148 };
150 lineStr.append( ":\n" ); 149 lineStr.append( ":\n" );
151 150
152 for ( QStringList::Iterator it = m_packages[ i ]->begin(); it != m_packages[ i ]->end(); ++it ) 151 for ( QStringList::Iterator it = m_packages[ i ]->begin(); it != m_packages[ i ]->end(); ++it )
153 { 152 {
154 lineStr.append( QString( "\t%1\n" ).arg( ( *it ) ) ); 153 lineStr.append( QString( "\t%1\n" ).arg( ( *it ) ) );
155 } 154 }
156 155
157 m_output->append( lineStr ); 156 m_output->append( lineStr );
158 } 157 }
159 } 158 }
160 159
161 m_output->append( tr( "Press the start button to begin.\n" ) ); 160 m_output->append( tr( "Press the start button to begin.\n" ) );
162 m_output->setCursorPosition( m_output->numLines(), 0 ); 161 m_output->setCursorPosition( m_output->numLines(), 0 );
163 162
164} 163}
165 164
166InstallDlg::~InstallDlg() 165InstallDlg::~InstallDlg()
167{ 166{
168 for( int i = 0; i < m_numCommands; i++ ) 167 for( int i = 0; i < m_numCommands; i++ )
169 { 168 {
170 if ( m_packages[ i ] ) 169 if ( m_packages[ i ] )
171 delete m_packages[ i ]; 170 delete m_packages[ i ];
172 } 171 }
173} 172}
174 173
175void InstallDlg::slotDisplayAvailSpace( const QString &destination ) 174void InstallDlg::slotDisplayAvailSpace( const QString &destination )
176{ 175{
177 // If available space is not displayed, exit 176 // If available space is not displayed, exit
178 if ( !m_availSpace ) 177 if ( !m_availSpace )
179 return; 178 return;
180 179
181 QString space = tr( "Unknown" ); 180 QString space = tr( "Unknown" );
182 181
183 // Get destination 182 // Get destination
184 OConfItem *dest = m_packman->findConfItem( OConfItem::Destination, destination ); 183 OConfItem *dest = m_packman->findConfItem( OConfItem::Destination, destination );
185 184
186 if ( dest ) 185 if ( dest )
187 { 186 {
188 // Calculate available space 187 // Calculate available space
189 struct statfs fs; 188 struct statfs fs;
190 if ( !statfs( dest->value(), &fs ) ) 189 if ( !statfs( dest->value(), &fs ) )
191 { 190 {
192 long mult = fs.f_bsize / 1024; 191 long mult = fs.f_bsize / 1024;
193 long div = 1024 / fs.f_bsize; 192 long div = 1024 / fs.f_bsize;
194 193
195 if ( !mult ) mult = 1; 194 if ( !mult ) mult = 1;
196 if ( !div ) div = 1; 195 if ( !div ) div = 1;
197 long avail = fs.f_bavail * mult / div; 196 long avail = fs.f_bavail * mult / div;
198 197
199 space = tr( "%1 Kb" ).arg( avail ); 198 space = tr( "%1 Kb" ).arg( avail );
200 } 199 }
201 } 200 }
202 201
203 // Display available space 202 // Display available space
204 m_availSpace->setText( space ); 203 m_availSpace->setText( space );
205} 204}
206 205
207void InstallDlg::slotBtnStart() 206void InstallDlg::slotBtnStart()
208{ 207{
209 QString btnText = m_btnStart->text(); 208 QString btnText = m_btnStart->text();
210 if ( btnText == tr( "Abort" ) ) 209 if ( btnText == tr( "Abort" ) )
211 { 210 {
212 // Prevent unexecuted commands from executing 211 // Prevent unexecuted commands from executing
213 m_currCommand = 999; 212 m_currCommand = 999;
214 213
215 // Allow user to close dialog 214 // Allow user to close dialog
216 m_btnStart->setText( tr( "Close" ) ); 215 m_btnStart->setText( tr( "Close" ) );
217 m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) ); 216 m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) );
218 return; 217 return;
219 } 218 }
220 else if ( btnText == tr( "Close" ) ) 219 else if ( btnText == tr( "Close" ) )
221 { 220 {
222 // TODO - force reload of package data 221 // TODO - force reload of package data
223 emit closeInstallDlg(); 222 emit closeInstallDlg();
224 return; 223 return;
225 } 224 }
226 225
227 // Start was clicked, start executing 226 // Start was clicked, start executing
228 m_btnOptions->setEnabled( false ); 227 m_btnOptions->setEnabled( false );
229 if ( m_numCommands > 1 ) 228 if ( m_numCommands > 1 )
230 { 229 {
231 m_btnStart->setText( tr( "Abort" ) ); 230 m_btnStart->setText( tr( "Abort" ) );
232 m_btnStart->setIconSet( Resource::loadPixmap( "close" ) ); 231 m_btnStart->setIconSet( Resource::loadPixmap( "close" ) );
233 } 232 }
234 else 233 else
235 { 234 {
236 m_btnStart->setEnabled( false ); 235 m_btnStart->setEnabled( false );
237 } 236 }
238 237
239 QString dest; 238 QString dest;
240 if ( m_destination ) 239 if ( m_destination )
241 dest = m_destination->currentText(); 240 dest = m_destination->currentText();
242 241
243 for ( m_currCommand = 0; m_currCommand < m_numCommands; m_currCommand++ ) 242 for ( m_currCommand = 0; m_currCommand < m_numCommands; m_currCommand++ )
244 { 243 {
245 // Execute next command 244 // Execute next command
246 m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], dest, 245 m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], dest,
247 this, SLOT(slotOutput(char*)), true ); 246 this, SLOT(slotOutput(char*)), true );
248 } 247 }
249 248
250 // All commands executed, allow user to close dialog 249 // All commands executed, allow user to close dialog
251 m_btnStart->setEnabled( true ); 250 m_btnStart->setEnabled( true );
252 m_btnStart->setText( tr( "Close" ) ); 251 m_btnStart->setText( tr( "Close" ) );
253 m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) ); 252 m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) );
254 253
255 m_btnOptions->setEnabled( true ); 254 m_btnOptions->setEnabled( true );
256 m_btnOptions->setText( tr( "Save output" ) ); 255 m_btnOptions->setText( tr( "Save output" ) );
257 m_btnOptions->setIconSet( Resource::loadPixmap( "save" ) ); 256 m_btnOptions->setIconSet( Resource::loadPixmap( "save" ) );
258} 257}
259 258
260void InstallDlg::slotBtnOptions() 259void InstallDlg::slotBtnOptions()
261{ 260{
262 QString btnText = m_btnOptions->text(); 261 QString btnText = m_btnOptions->text();
263 if ( btnText == tr( "Options" ) ) 262 if ( btnText == tr( "Options" ) )
264 { 263 {
265 // Display configuration dialog (only options tab is enabled) 264 // Display configuration dialog (only options tab is enabled)
266 m_packman->configureDlg( true ); 265 m_packman->configureDlg( true );
267 return; 266 return;
268 } 267 }
269 268
270 // Save output was clicked 269 // Save output was clicked
271 QMap<QString, QStringList> map; 270 QMap<QString, QStringList> map;
272 map.insert( tr( "All" ), QStringList() ); 271 map.insert( tr( "All" ), QStringList() );
273 QStringList text; 272 QStringList text;
274 text << "text/*"; 273 text << "text/*";
275 map.insert(tr( "Text" ), text ); 274 map.insert(tr( "Text" ), text );
276 text << "*"; 275 text << "*";
277 map.insert( tr( "All" ), text ); 276 map.insert( tr( "All" ), text );
278 277
279 QString filename = OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map ); 278 QString filename = Opie::Ui::OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map );
280 if( !filename.isEmpty() ) 279 if( !filename.isEmpty() )
281 { 280 {
282 QString currentFileName = QFileInfo( filename ).fileName(); 281 QString currentFileName = QFileInfo( filename ).fileName();
283 DocLnk doc; 282 DocLnk doc;
284 doc.setType( "text/plain" ); 283 doc.setType( "text/plain" );
285 doc.setFile( filename ); 284 doc.setFile( filename );
286 doc.setName( currentFileName ); 285 doc.setName( currentFileName );
287 FileManager fm; 286 FileManager fm;
288 fm.saveFile( doc, m_output->text() ); 287 fm.saveFile( doc, m_output->text() );
289 } 288 }
290} 289}
291 290
292void InstallDlg::slotOutput( char *msg ) 291void InstallDlg::slotOutput( char *msg )
293{ 292{
294 // Allow processing of other events 293 // Allow processing of other events
295 qApp->processEvents(); 294 qApp->processEvents();
296 295
297 QString lineStr = msg; 296 QString lineStr = msg;
298 if ( lineStr[lineStr.length()-1] == '\n' ) 297 if ( lineStr[lineStr.length()-1] == '\n' )
299 lineStr.truncate( lineStr.length() - 1 ); 298 lineStr.truncate( lineStr.length() - 1 );
300 m_output->append( lineStr ); 299 m_output->append( lineStr );
301 m_output->setCursorPosition( m_output->numLines(), 0 ); 300 m_output->setCursorPosition( m_output->numLines(), 0 );
302} 301}
diff --git a/noncore/settings/packagemanager/main.cpp b/noncore/settings/packagemanager/main.cpp
index c050e1a..3792881 100644
--- a/noncore/settings/packagemanager/main.cpp
+++ b/noncore/settings/packagemanager/main.cpp
@@ -1,35 +1,34 @@
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 "mainwindow.h" 30#include "mainwindow.h"
31 31
32#include <opie2/oapplicationfactory.h> 32#include <opie2/oapplicationfactory.h>
33 33
34using namespace Opie::Core; 34OPIE_EXPORT_APP( Opie::Core::OApplicationFactory<MainWindow> )
35OPIE_EXPORT_APP( OApplicationFactory<MainWindow> )
diff --git a/noncore/settings/packagemanager/mainwindow.cpp b/noncore/settings/packagemanager/mainwindow.cpp
index 810046f..991cc81 100644
--- a/noncore/settings/packagemanager/mainwindow.cpp
+++ b/noncore/settings/packagemanager/mainwindow.cpp
@@ -1,719 +1,719 @@
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 "mainwindow.h"
31#include "installdlg.h"
32#include "filterdlg.h"
33#include "promptdlg.h"
34#include "entrydlg.h"
35#include "packageinfodlg.h"
36
37#include <qpe/qcopenvelope_qws.h>
38#include <qpe/qpeapplication.h>
39#include <qpe/resource.h>
40
30#include <qaction.h> 41#include <qaction.h>
31#include <qdir.h> 42#include <qdir.h>
32#include <qlayout.h> 43#include <qlayout.h>
33#include <qlineedit.h> 44#include <qlineedit.h>
34#include <qmenubar.h> 45#include <qmenubar.h>
35#include <qmessagebox.h> 46#include <qmessagebox.h>
36#include <qpopupmenu.h> 47#include <qpopupmenu.h>
37#include <qtimer.h> 48#include <qtimer.h>
38#include <qtoolbar.h> 49#include <qtoolbar.h>
39#include <qwhatsthis.h> 50#include <qwhatsthis.h>
40 51
41#include <qpe/qcopenvelope_qws.h>
42#include <qpe/qpeapplication.h>
43#include <qpe/resource.h>
44
45#include "mainwindow.h"
46#include "installdlg.h"
47#include "filterdlg.h"
48#include "promptdlg.h"
49#include "entrydlg.h"
50#include "packageinfodlg.h"
51
52MainWindow::MainWindow( QWidget *parent, const char *name, WFlags /*fl*/ ) 52MainWindow::MainWindow( QWidget *parent, const char *name, WFlags /*fl*/ )
53 : QMainWindow( parent, name, WStyle_ContextHelp ) 53 : QMainWindow( parent, name, WStyle_ContextHelp )
54 , m_config( "packman" ) 54 , m_config( "packman" )
55 , m_packman( &m_config, this ) 55 , m_packman( &m_config, this )
56 , m_menuBar( this ) 56 , m_menuBar( this )
57 , m_toolBar( this ) 57 , m_toolBar( this )
58 , m_findBar( this ) 58 , m_findBar( this )
59 , m_widgetStack( this ) 59 , m_widgetStack( this )
60 , m_packageList( this ) 60 , m_packageList( this )
61 , m_statusWidget( this ) 61 , m_statusWidget( this )
62 , m_statusText( &m_statusWidget ) 62 , m_statusText( &m_statusWidget )
63 , m_statusBar( &m_statusWidget ) 63 , m_statusBar( &m_statusWidget )
64 , m_iconUpdated( Resource::loadPixmap( "packagemanager/updated" ) ) 64 , m_iconUpdated( Resource::loadPixmap( "packagemanager/updated" ) )
65 , m_iconInstalled( Resource::loadPixmap( "installed" ) ) 65 , m_iconInstalled( Resource::loadPixmap( "installed" ) )
66 , m_iconNull( m_iconUpdated.size() ) 66 , m_iconNull( m_iconUpdated.size() )
67 , m_filterName( QString::null ) 67 , m_filterName( QString::null )
68 , m_filterServer( QString::null ) 68 , m_filterServer( QString::null )
69 , m_filterDest( QString::null ) 69 , m_filterDest( QString::null )
70 , m_filterStatus( OPackageManager::NotDefined ) 70 , m_filterStatus( OPackageManager::NotDefined )
71 , m_filterCategory( QString::null ) 71 , m_filterCategory( QString::null )
72 72
73{ 73{
74// setCaption( tr( "Package Manager" ) ); 74// setCaption( tr( "Package Manager" ) );
75 75
76 m_iconNull.fill( colorGroup().base() ); 76 m_iconNull.fill( colorGroup().base() );
77 77
78 connect( &m_widgetStack, SIGNAL(aboutToShow(QWidget*)), this, SLOT(slotWidgetStackShow(QWidget*)) ); 78 connect( &m_widgetStack, SIGNAL(aboutToShow(QWidget*)), this, SLOT(slotWidgetStackShow(QWidget*)) );
79 79
80 // Initialize widget stack, package list and status widget 80 // Initialize widget stack, package list and status widget
81 initStatusWidget(); 81 initStatusWidget();
82 initPackageList(); 82 initPackageList();
83 83
84 m_widgetStack.addWidget( &m_statusWidget, 2 ); 84 m_widgetStack.addWidget( &m_statusWidget, 2 );
85 m_widgetStack.addWidget( &m_packageList, 1 ); 85 m_widgetStack.addWidget( &m_packageList, 1 );
86 setCentralWidget( &m_widgetStack ); 86 setCentralWidget( &m_widgetStack );
87 87
88 // Initialize remaining user interface items 88 // Initialize remaining user interface items
89 initUI(); 89 initUI();
90 90
91 // Initialize package information 91 // Initialize package information
92 QTimer::singleShot( 100, this, SLOT( initPackageInfo() ) ); 92 QTimer::singleShot( 100, this, SLOT( initPackageInfo() ) );
93} 93}
94 94
95void MainWindow::closeEvent( QCloseEvent *event ) 95void MainWindow::closeEvent( QCloseEvent *event )
96{ 96{
97 // Close app only if either the package or status widgets are currently active 97 // Close app only if either the package or status widgets are currently active
98 bool close = m_widgetStack.visibleWidget() == &m_packageList || 98 bool close = m_widgetStack.visibleWidget() == &m_packageList ||
99 m_widgetStack.visibleWidget() == &m_statusWidget; 99 m_widgetStack.visibleWidget() == &m_statusWidget;
100 if ( close ) 100 if ( close )
101 { 101 {
102 // TODO - write out application configuration settings 102 // TODO - write out application configuration settings
103 103
104 // Write out package manager configuration settings 104 // Write out package manager configuration settings
105 m_packman.saveSettings(); 105 m_packman.saveSettings();
106 event->accept(); 106 event->accept();
107 } 107 }
108 else 108 else
109 { 109 {
110 delete m_widgetStack.visibleWidget(); 110 delete m_widgetStack.visibleWidget();
111 m_widgetStack.raiseWidget( &m_packageList ); 111 m_widgetStack.raiseWidget( &m_packageList );
112 event->ignore(); 112 event->ignore();
113 } 113 }
114} 114}
115 115
116void MainWindow::initPackageList() 116void MainWindow::initPackageList()
117{ 117{
118 m_packageList.addColumn( tr( "Packages" ) ); 118 m_packageList.addColumn( tr( "Packages" ) );
119 QWhatsThis::add( &m_packageList, tr( "This is a listing of all packages.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nTap inside the box at the left to select a package. Tap and hold to view package details." ) ); 119 QWhatsThis::add( &m_packageList, tr( "This is a listing of all packages.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nTap inside the box at the left to select a package. Tap and hold to view package details." ) );
120 QPEApplication::setStylusOperation( m_packageList.viewport(), QPEApplication::RightOnHold ); 120 QPEApplication::setStylusOperation( m_packageList.viewport(), QPEApplication::RightOnHold );
121 connect( &m_packageList, SIGNAL(rightButtonPressed(QListViewItem*,const QPoint&,int)), 121 connect( &m_packageList, SIGNAL(rightButtonPressed(QListViewItem*,const QPoint&,int)),
122 this, SLOT(slotDisplayPackageInfo(QListViewItem*)) ); 122 this, SLOT(slotDisplayPackageInfo(QListViewItem*)) );
123} 123}
124 124
125void MainWindow::initStatusWidget() 125void MainWindow::initStatusWidget()
126{ 126{
127 QVBoxLayout *layout = new QVBoxLayout( &m_statusWidget, 4, 4 ); 127 QVBoxLayout *layout = new QVBoxLayout( &m_statusWidget, 4, 4 );
128 128
129 m_statusText.setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); 129 m_statusText.setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
130 layout->addWidget( &m_statusText ); 130 layout->addWidget( &m_statusText );
131 131
132 connect( &m_packman, SIGNAL(initStatus(int)), this, SLOT(slotInitStatusBar(int)) ); 132 connect( &m_packman, SIGNAL(initStatus(int)), this, SLOT(slotInitStatusBar(int)) );
133 connect( &m_packman, SIGNAL(statusText(const QString&)), this, SLOT(slotStatusText(const QString&)) ); 133 connect( &m_packman, SIGNAL(statusText(const QString&)), this, SLOT(slotStatusText(const QString&)) );
134 connect( &m_packman, SIGNAL(statusBar(int)), this, SLOT(slotStatusBar(int)) ); 134 connect( &m_packman, SIGNAL(statusBar(int)), this, SLOT(slotStatusBar(int)) );
135 135
136 layout->addWidget( &m_statusBar ); 136 layout->addWidget( &m_statusBar );
137} 137}
138 138
139void MainWindow::initUI() 139void MainWindow::initUI()
140{ 140{
141 // Build menu and tool bars 141 // Build menu and tool bars
142 setToolBarsMovable( false ); 142 setToolBarsMovable( false );
143 143
144 m_menuBar.setHorizontalStretchable( true ); 144 m_menuBar.setHorizontalStretchable( true );
145 QMenuBar *mb = new QMenuBar( &m_menuBar ); 145 QMenuBar *mb = new QMenuBar( &m_menuBar );
146 mb->setMargin( 0 ); 146 mb->setMargin( 0 );
147 147
148 // Find toolbar 148 // Find toolbar
149 addToolBar( &m_findBar, QMainWindow::Top, true ); 149 addToolBar( &m_findBar, QMainWindow::Top, true );
150 m_findBar.setHorizontalStretchable( true ); 150 m_findBar.setHorizontalStretchable( true );
151 m_findEdit = new QLineEdit( &m_findBar ); 151 m_findEdit = new QLineEdit( &m_findBar );
152 QWhatsThis::add( m_findEdit, tr( "Type the text to search for here." ) ); 152 QWhatsThis::add( m_findEdit, tr( "Type the text to search for here." ) );
153 m_findBar.setStretchableWidget( m_findEdit ); 153 m_findBar.setStretchableWidget( m_findEdit );
154 connect( m_findEdit, SIGNAL(textChanged(const QString&)), this, SLOT(slotFindChanged(const QString&)) ); 154 connect( m_findEdit, SIGNAL(textChanged(const QString&)), this, SLOT(slotFindChanged(const QString&)) );
155 155
156 // Packages menu 156 // Packages menu
157 QPopupMenu *popup = new QPopupMenu( this ); 157 QPopupMenu *popup = new QPopupMenu( this );
158 158
159 QAction *a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "packagemanager/update" ), QString::null, 0, this, 0 ); 159 QAction *a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "packagemanager/update" ), QString::null, 0, this, 0 );
160 a->setWhatsThis( tr( "Tap here to update package lists from servers." ) ); 160 a->setWhatsThis( tr( "Tap here to update package lists from servers." ) );
161 connect( a, SIGNAL(activated()), this, SLOT(slotUpdate()) ); 161 connect( a, SIGNAL(activated()), this, SLOT(slotUpdate()) );
162 a->addTo( popup ); 162 a->addTo( popup );
163 a->addTo( &m_toolBar ); 163 a->addTo( &m_toolBar );
164 164
165 QAction *actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "packagemanager/upgrade" ), QString::null, 0, this, 0 ); 165 QAction *actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "packagemanager/upgrade" ), QString::null, 0, this, 0 );
166 actionUpgrade->setWhatsThis( tr( "Tap here to upgrade all installed packages if a newer version is available." ) ); 166 actionUpgrade->setWhatsThis( tr( "Tap here to upgrade all installed packages if a newer version is available." ) );
167 connect( actionUpgrade, SIGNAL(activated()), this, SLOT(slotUpgrade()) ); 167 connect( actionUpgrade, SIGNAL(activated()), this, SLOT(slotUpgrade()) );
168 actionUpgrade->addTo( popup ); 168 actionUpgrade->addTo( popup );
169 actionUpgrade->addTo( &m_toolBar ); 169 actionUpgrade->addTo( &m_toolBar );
170 170
171 QPixmap iconDownload = Resource::loadPixmap( "packagemanager/download" ); 171 QPixmap iconDownload = Resource::loadPixmap( "packagemanager/download" );
172 QPixmap iconRemove = Resource::loadPixmap( "packagemanager/remove" ); 172 QPixmap iconRemove = Resource::loadPixmap( "packagemanager/remove" );
173 QAction *actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); 173 QAction *actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 );
174 actionDownload->setWhatsThis( tr( "Tap here to download the currently selected package(s)." ) ); 174 actionDownload->setWhatsThis( tr( "Tap here to download the currently selected package(s)." ) );
175 connect( actionDownload, SIGNAL(activated()), this, SLOT(slotDownload()) ); 175 connect( actionDownload, SIGNAL(activated()), this, SLOT(slotDownload()) );
176 actionDownload->addTo( popup ); 176 actionDownload->addTo( popup );
177 actionDownload->addTo( &m_toolBar ); 177 actionDownload->addTo( &m_toolBar );
178 178
179 a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "packagemanager/apply" ), QString::null, 0, this, 0 ); 179 a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "packagemanager/apply" ), QString::null, 0, this, 0 );
180 a->setWhatsThis( tr( "Tap here to install, remove or upgrade currently selected package(s)." ) ); 180 a->setWhatsThis( tr( "Tap here to install, remove or upgrade currently selected package(s)." ) );
181 connect( a, SIGNAL(activated()), this, SLOT(slotApply()) ); 181 connect( a, SIGNAL(activated()), this, SLOT(slotApply()) );
182 a->addTo( popup ); 182 a->addTo( popup );
183 a->addTo( &m_toolBar ); 183 a->addTo( &m_toolBar );
184 184
185 popup->insertSeparator(); 185 popup->insertSeparator();
186 186
187 a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); 187 a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 );
188 a->setWhatsThis( tr( "Tap here to configure this application." ) ); 188 a->setWhatsThis( tr( "Tap here to configure this application." ) );
189 connect( a, SIGNAL(activated()), this, SLOT(slotConfigure()) ); 189 connect( a, SIGNAL(activated()), this, SLOT(slotConfigure()) );
190 a->addTo( popup ); 190 a->addTo( popup );
191 mb->insertItem( tr( "Actions" ), popup ); 191 mb->insertItem( tr( "Actions" ), popup );
192 192
193 // View menu 193 // View menu
194 popup = new QPopupMenu( this ); 194 popup = new QPopupMenu( this );
195 195
196 m_actionShowNotInstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); 196 m_actionShowNotInstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 );
197 m_actionShowNotInstalled->setToggleAction( true ); 197 m_actionShowNotInstalled->setToggleAction( true );
198 m_actionShowNotInstalled->setWhatsThis( tr( "Tap here to show packages available which have not been installed." ) ); 198 m_actionShowNotInstalled->setWhatsThis( tr( "Tap here to show packages available which have not been installed." ) );
199 connect( m_actionShowNotInstalled, SIGNAL(activated()), this, SLOT(slotShowNotInstalled()) ); 199 connect( m_actionShowNotInstalled, SIGNAL(activated()), this, SLOT(slotShowNotInstalled()) );
200 m_actionShowNotInstalled->addTo( popup ); 200 m_actionShowNotInstalled->addTo( popup );
201 201
202 m_actionShowInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); 202 m_actionShowInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 );
203 m_actionShowInstalled->setToggleAction( true ); 203 m_actionShowInstalled->setToggleAction( true );
204 m_actionShowInstalled->setWhatsThis( tr( "Tap here to show packages currently installed on this device." ) ); 204 m_actionShowInstalled->setWhatsThis( tr( "Tap here to show packages currently installed on this device." ) );
205 connect( m_actionShowInstalled, SIGNAL(activated()), this, SLOT(slotShowInstalled()) ); 205 connect( m_actionShowInstalled, SIGNAL(activated()), this, SLOT(slotShowInstalled()) );
206 m_actionShowInstalled->addTo( popup ); 206 m_actionShowInstalled->addTo( popup );
207 207
208 m_actionShowUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); 208 m_actionShowUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 );
209 m_actionShowUpdated->setToggleAction( true ); 209 m_actionShowUpdated->setToggleAction( true );
210 m_actionShowUpdated->setWhatsThis( tr( "Tap here to show packages currently installed on this device which have a newer version available." ) ); 210 m_actionShowUpdated->setWhatsThis( tr( "Tap here to show packages currently installed on this device which have a newer version available." ) );
211 connect( m_actionShowUpdated, SIGNAL(activated()), this, SLOT(slotShowUpdated()) ); 211 connect( m_actionShowUpdated, SIGNAL(activated()), this, SLOT(slotShowUpdated()) );
212 m_actionShowUpdated->addTo( popup ); 212 m_actionShowUpdated->addTo( popup );
213 213
214 popup->insertSeparator(); 214 popup->insertSeparator();
215 215
216 m_actionFilter = new QAction( tr( "Filter" ), Resource::loadPixmap( "packagemanager/filter" ), 216 m_actionFilter = new QAction( tr( "Filter" ), Resource::loadPixmap( "packagemanager/filter" ),
217 QString::null, 0, this, 0 ); 217 QString::null, 0, this, 0 );
218 m_actionFilter->setToggleAction( true ); 218 m_actionFilter->setToggleAction( true );
219 m_actionFilter->setWhatsThis( tr( "Tap here to apply current filter." ) ); 219 m_actionFilter->setWhatsThis( tr( "Tap here to apply current filter." ) );
220 connect( m_actionFilter, SIGNAL(toggled(bool)), this, SLOT(slotFilter(bool)) ); 220 connect( m_actionFilter, SIGNAL(toggled(bool)), this, SLOT(slotFilter(bool)) );
221 m_actionFilter->addTo( popup ); 221 m_actionFilter->addTo( popup );
222 222
223 a = new QAction( tr( "Filter settings" ), QString::null, 0, this, 0 ); 223 a = new QAction( tr( "Filter settings" ), QString::null, 0, this, 0 );
224 a->setWhatsThis( tr( "Tap here to change the package filter criteria." ) ); 224 a->setWhatsThis( tr( "Tap here to change the package filter criteria." ) );
225 connect( a, SIGNAL(activated()), this, SLOT(slotFilterChange()) ); 225 connect( a, SIGNAL(activated()), this, SLOT(slotFilterChange()) );
226 a->addTo( popup ); 226 a->addTo( popup );
227 227
228 popup->insertSeparator(); 228 popup->insertSeparator();
229 229
230 a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); 230 a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 );
231 a->setWhatsThis( tr( "Tap here to search for text in package names." ) ); 231 a->setWhatsThis( tr( "Tap here to search for text in package names." ) );
232 connect( a, SIGNAL(activated()), this, SLOT(slotFindShowToolbar()) ); 232 connect( a, SIGNAL(activated()), this, SLOT(slotFindShowToolbar()) );
233 a->addTo( popup ); 233 a->addTo( popup );
234 234
235 m_actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); 235 m_actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 );
236 m_actionFindNext->setEnabled( false ); 236 m_actionFindNext->setEnabled( false );
237 m_actionFindNext->setWhatsThis( tr( "Tap here to find the next package name containing the text you are searching for." ) ); 237 m_actionFindNext->setWhatsThis( tr( "Tap here to find the next package name containing the text you are searching for." ) );
238 connect( m_actionFindNext, SIGNAL(activated()), this, SLOT(slotFindNext()) ); 238 connect( m_actionFindNext, SIGNAL(activated()), this, SLOT(slotFindNext()) );
239 m_actionFindNext->addTo( popup ); 239 m_actionFindNext->addTo( popup );
240 m_actionFindNext->addTo( &m_findBar ); 240 m_actionFindNext->addTo( &m_findBar );
241 241
242 mb->insertItem( tr( "View" ), popup ); 242 mb->insertItem( tr( "View" ), popup );
243 243
244 // Finish find toolbar creation 244 // Finish find toolbar creation
245 a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); 245 a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
246 a->setWhatsThis( tr( "Tap here to hide the find toolbar." ) ); 246 a->setWhatsThis( tr( "Tap here to hide the find toolbar." ) );
247 connect( a, SIGNAL(activated()), this, SLOT(slotFindHideToolbar()) ); 247 connect( a, SIGNAL(activated()), this, SLOT(slotFindHideToolbar()) );
248 a->addTo( &m_findBar ); 248 a->addTo( &m_findBar );
249 m_findBar.hide(); 249 m_findBar.hide();
250} 250}
251 251
252void MainWindow::loadPackageList( OPackageList *packages, bool clearList ) 252void MainWindow::loadPackageList( OPackageList *packages, bool clearList )
253{ 253{
254 if ( clearList ) 254 if ( clearList )
255 m_packageList.clear(); 255 m_packageList.clear();
256 256
257 if ( packages ) 257 if ( packages )
258 { 258 {
259 for ( OPackageListIterator packageIt( *packages ); packageIt.current(); ++packageIt ) 259 for ( OPackageListIterator packageIt( *packages ); packageIt.current(); ++packageIt )
260 { 260 {
261 OPackage *package = packageIt.current(); 261 OPackage *package = packageIt.current();
262 QCheckListItem *item = new QCheckListItem( &m_packageList, package->name(), 262 QCheckListItem *item = new QCheckListItem( &m_packageList, package->name(),
263 QCheckListItem::CheckBox ); 263 QCheckListItem::CheckBox );
264 m_packageList.insertItem( item ); 264 m_packageList.insertItem( item );
265 265
266 // If a different version of package is available, show update available icon 266 // If a different version of package is available, show update available icon
267 // Otherwise, show installed icon 267 // Otherwise, show installed icon
268 if ( !package->versionInstalled().isNull() ) 268 if ( !package->versionInstalled().isNull() )
269 { 269 {
270 if ( m_packman.compareVersions( package->version(), package->versionInstalled() ) == 1 ) 270 if ( m_packman.compareVersions( package->version(), package->versionInstalled() ) == 1 )
271 item->setPixmap( 0, m_iconUpdated ); 271 item->setPixmap( 0, m_iconUpdated );
272 else 272 else
273 item->setPixmap( 0, m_iconInstalled ); 273 item->setPixmap( 0, m_iconInstalled );
274 } 274 }
275 else 275 else
276 item->setPixmap( 0, m_iconNull ); 276 item->setPixmap( 0, m_iconNull );
277 } 277 }
278 } 278 }
279} 279}
280 280
281void MainWindow::searchForPackage( const QString &text ) 281void MainWindow::searchForPackage( const QString &text )
282{ 282{
283 if ( !text.isEmpty() ) 283 if ( !text.isEmpty() )
284 { 284 {
285 // look through package list for text startng at current position 285 // look through package list for text startng at current position
286 QCheckListItem *start = static_cast<QCheckListItem *>(m_packageList.currentItem()); 286 QCheckListItem *start = static_cast<QCheckListItem *>(m_packageList.currentItem());
287 if ( start == 0 ) 287 if ( start == 0 )
288 start = static_cast<QCheckListItem *>(m_packageList.firstChild()); 288 start = static_cast<QCheckListItem *>(m_packageList.firstChild());
289 289
290// for ( QCheckListItem *item = static_cast<QCheckListItem *>(start->nextSibling()); item != 0 ; 290// for ( QCheckListItem *item = static_cast<QCheckListItem *>(start->nextSibling()); item != 0 ;
291 for ( QCheckListItem *item = static_cast<QCheckListItem *>(start); item != 0 ; 291 for ( QCheckListItem *item = static_cast<QCheckListItem *>(start); item != 0 ;
292 item = static_cast<QCheckListItem *>(item->nextSibling()) ) 292 item = static_cast<QCheckListItem *>(item->nextSibling()) )
293 { 293 {
294 if ( item->text().lower().find( text ) != -1 ) 294 if ( item->text().lower().find( text ) != -1 )
295 { 295 {
296 m_packageList.ensureItemVisible( item ); 296 m_packageList.ensureItemVisible( item );
297 m_packageList.setCurrentItem( item ); 297 m_packageList.setCurrentItem( item );
298 break; 298 break;
299 } 299 }
300 } 300 }
301 } 301 }
302} 302}
303 303
304void MainWindow::initPackageInfo() 304void MainWindow::initPackageInfo()
305{ 305{
306 m_widgetStack.raiseWidget( &m_statusWidget ); 306 m_widgetStack.raiseWidget( &m_statusWidget );
307 307
308 // Load package list 308 // Load package list
309 m_packman.loadAvailablePackages(); 309 m_packman.loadAvailablePackages();
310 m_packman.loadInstalledPackages(); 310 m_packman.loadInstalledPackages();
311 311
312 OPackageList *packageList = m_packman.packages(); 312 OPackageList *packageList = m_packman.packages();
313 if ( packageList ) 313 if ( packageList )
314 { 314 {
315 loadPackageList( packageList, true ); 315 loadPackageList( packageList, true );
316 delete packageList; 316 delete packageList;
317 } 317 }
318 318
319 m_widgetStack.raiseWidget( &m_packageList ); 319 m_widgetStack.raiseWidget( &m_packageList );
320} 320}
321 321
322void MainWindow::slotWidgetStackShow( QWidget *widget ) 322void MainWindow::slotWidgetStackShow( QWidget *widget )
323{ 323{
324 if ( widget == &m_packageList ) 324 if ( widget == &m_packageList )
325 { 325 {
326 setCaption( tr( "Package Manager" ) ); 326 setCaption( tr( "Package Manager" ) );
327 327
328 m_menuBar.show(); 328 m_menuBar.show();
329 m_toolBar.show(); 329 m_toolBar.show();
330 } 330 }
331 else 331 else
332 { 332 {
333 m_menuBar.hide(); 333 m_menuBar.hide();
334 m_toolBar.hide(); 334 m_toolBar.hide();
335 } 335 }
336} 336}
337 337
338void MainWindow::slotInitStatusBar( int numSteps ) 338void MainWindow::slotInitStatusBar( int numSteps )
339{ 339{
340 m_statusBar.setTotalSteps( numSteps ); 340 m_statusBar.setTotalSteps( numSteps );
341} 341}
342 342
343void MainWindow::slotStatusText( const QString &status ) 343void MainWindow::slotStatusText( const QString &status )
344{ 344{
345 m_statusText.setText( status ); 345 m_statusText.setText( status );
346} 346}
347 347
348void MainWindow::slotStatusBar( int currStep ) 348void MainWindow::slotStatusBar( int currStep )
349{ 349{
350 m_statusBar.setProgress( currStep ); 350 m_statusBar.setProgress( currStep );
351} 351}
352 352
353void MainWindow::slotUpdate() 353void MainWindow::slotUpdate()
354{ 354{
355 // Create package manager output widget 355 // Create package manager output widget
356 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Update package information" ), false, 356 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Update package information" ), false,
357 OPackage::Update ); 357 OPackage::Update );
358 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); 358 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) );
359 359
360 // Display widget 360 // Display widget
361 m_widgetStack.addWidget( dlg, 3 ); 361 m_widgetStack.addWidget( dlg, 3 );
362 m_widgetStack.raiseWidget( dlg ); 362 m_widgetStack.raiseWidget( dlg );
363} 363}
364 364
365void MainWindow::slotUpgrade() 365void MainWindow::slotUpgrade()
366{ 366{
367 // Create package manager output widget 367 // Create package manager output widget
368 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Upgrade installed packages" ), false, 368 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Upgrade installed packages" ), false,
369 OPackage::Upgrade ); 369 OPackage::Upgrade );
370 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); 370 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) );
371 371
372 // Display widget 372 // Display widget
373 m_widgetStack.addWidget( dlg, 3 ); 373 m_widgetStack.addWidget( dlg, 3 );
374 m_widgetStack.raiseWidget( dlg ); 374 m_widgetStack.raiseWidget( dlg );
375} 375}
376 376
377void MainWindow::slotDownload() 377void MainWindow::slotDownload()
378{ 378{
379 // Retrieve list of packages selected for download (if any) 379 // Retrieve list of packages selected for download (if any)
380 QStringList *workingPackages = new QStringList(); 380 QStringList *workingPackages = new QStringList();
381 381
382 for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild()); 382 for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild());
383 item != 0 ; 383 item != 0 ;
384 item = static_cast<QCheckListItem *>(item->nextSibling()) ) 384 item = static_cast<QCheckListItem *>(item->nextSibling()) )
385 { 385 {
386 if ( item->isOn() ) 386 if ( item->isOn() )
387 workingPackages->append( item->text() ); 387 workingPackages->append( item->text() );
388 } 388 }
389 389
390 if ( workingPackages->isEmpty() ) 390 if ( workingPackages->isEmpty() )
391 { 391 {
392 QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) ); 392 QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) );
393 return; 393 return;
394 } 394 }
395 else 395 else
396 { 396 {
397 // Download selected packages 397 // Download selected packages
398 m_config.setGroup( "settings" ); 398 m_config.setGroup( "settings" );
399 QString workingDir = m_config.readEntry( "DownloadDir", "/tmp" ); 399 QString workingDir = m_config.readEntry( "DownloadDir", "/tmp" );
400 400
401 bool ok = false; 401 bool ok = false;
402 QString text = EntryDlg::getText( tr( "Download" ), tr( "Enter path to download package to:" ), workingDir, &ok, this ); 402 QString text = EntryDlg::getText( tr( "Download" ), tr( "Enter path to download package to:" ), workingDir, &ok, this );
403 if ( ok && !text.isEmpty() ) 403 if ( ok && !text.isEmpty() )
404 workingDir = text; // user entered something and pressed ok 404 workingDir = text; // user entered something and pressed ok
405 else 405 else
406 return; // user entered nothing or pressed cancel 406 return; // user entered nothing or pressed cancel
407 407
408 // Store download directory in config file 408 // Store download directory in config file
409 m_config.writeEntry( "DownloadDir", workingDir ); 409 m_config.writeEntry( "DownloadDir", workingDir );
410 410
411 // Get starting directory 411 // Get starting directory
412 QDir::setCurrent( workingDir ); 412 QDir::setCurrent( workingDir );
413 413
414 // Create package manager output widget 414 // Create package manager output widget
415 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Download packages" ), false, 415 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Download packages" ), false,
416 OPackage::Download, workingPackages ); 416 OPackage::Download, workingPackages );
417 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); 417 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) );
418 418
419 // Display widget 419 // Display widget
420 m_widgetStack.addWidget( dlg, 3 ); 420 m_widgetStack.addWidget( dlg, 3 );
421 m_widgetStack.raiseWidget( dlg ); 421 m_widgetStack.raiseWidget( dlg );
422 } 422 }
423} 423}
424 424
425void MainWindow::slotApply() 425void MainWindow::slotApply()
426{ 426{
427 QStringList *removeList = 0x0; 427 QStringList *removeList = 0x0;
428 QStringList *installList = 0x0; 428 QStringList *installList = 0x0;
429 QStringList *upgradeList = 0x0; 429 QStringList *upgradeList = 0x0;
430 430
431 for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild()); 431 for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild());
432 item != 0 ; 432 item != 0 ;
433 item = static_cast<QCheckListItem *>(item->nextSibling()) ) 433 item = static_cast<QCheckListItem *>(item->nextSibling()) )
434 { 434 {
435 if ( item->isOn() ) 435 if ( item->isOn() )
436 { 436 {
437 OPackage *package = m_packman.findPackage( item->text() ); 437 OPackage *package = m_packman.findPackage( item->text() );
438 if ( package ) 438 if ( package )
439 { 439 {
440 if ( !package->versionInstalled().isNull() ) 440 if ( !package->versionInstalled().isNull() )
441 { 441 {
442 if ( m_packman.compareVersions( package->version(), package->versionInstalled() ) == 1 ) 442 if ( m_packman.compareVersions( package->version(), package->versionInstalled() ) == 1 )
443 { 443 {
444 // Remove/upgrade package 444 // Remove/upgrade package
445 int answer = PromptDlg::ask( tr( "Remove or upgrade" ), 445 int answer = PromptDlg::ask( tr( "Remove or upgrade" ),
446 tr( QString( "Do you wish to remove or upgrade\n%1?" ).arg( item->text() ) ), 446 tr( QString( "Do you wish to remove or upgrade\n%1?" ).arg( item->text() ) ),
447 tr( "Remove" ), tr( "Upgrade" ), this ); 447 tr( "Remove" ), tr( "Upgrade" ), this );
448 if ( answer == 1 ) // Remove 448 if ( answer == 1 ) // Remove
449 { 449 {
450 if ( !removeList ) 450 if ( !removeList )
451 removeList = new QStringList(); 451 removeList = new QStringList();
452 removeList->append( item->text() ); 452 removeList->append( item->text() );
453 } 453 }
454 else if ( answer == 2 ) // Upgrade 454 else if ( answer == 2 ) // Upgrade
455 { 455 {
456 if ( !upgradeList ) 456 if ( !upgradeList )
457 upgradeList = new QStringList(); 457 upgradeList = new QStringList();
458 upgradeList->append( item->text() ); 458 upgradeList->append( item->text() );
459 } 459 }
460 } 460 }
461 else 461 else
462 { 462 {
463 // Remove/reinstall package 463 // Remove/reinstall package
464 int answer = PromptDlg::ask( tr( "Remove or reinstall" ), 464 int answer = PromptDlg::ask( tr( "Remove or reinstall" ),
465 tr( QString( "Do you wish to remove or reinstall\n%1?" ).arg( item->text() ) ), 465 tr( QString( "Do you wish to remove or reinstall\n%1?" ).arg( item->text() ) ),
466 tr( "Remove" ), tr( "Reinstall" ), this ); 466 tr( "Remove" ), tr( "Reinstall" ), this );
467 if ( answer == 1 ) // Remove 467 if ( answer == 1 ) // Remove
468 { 468 {
469 if ( !removeList ) 469 if ( !removeList )
470 removeList = new QStringList(); 470 removeList = new QStringList();
471 removeList->append( item->text() ); 471 removeList->append( item->text() );
472 } 472 }
473 else if ( answer == 2 ) // Reinstall 473 else if ( answer == 2 ) // Reinstall
474 { 474 {
475 if ( !installList ) 475 if ( !installList )
476 installList = new QStringList(); 476 installList = new QStringList();
477 installList->append( item->text() ); 477 installList->append( item->text() );
478 } 478 }
479 } 479 }
480 } 480 }
481 else 481 else
482 { 482 {
483 // Install package 483 // Install package
484 if ( !installList ) 484 if ( !installList )
485 installList = new QStringList(); 485 installList = new QStringList();
486 installList->append( item->text() ); 486 installList->append( item->text() );
487 } 487 }
488 } 488 }
489 } 489 }
490 } 490 }
491 491
492 // If nothing is selected, display message and exit 492 // If nothing is selected, display message and exit
493 if ( !removeList && !installList && !upgradeList ) 493 if ( !removeList && !installList && !upgradeList )
494 { 494 {
495 QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) ); 495 QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) );
496 return; 496 return;
497 } 497 }
498 498
499 // Send command only if there are packages to process 499 // Send command only if there are packages to process
500 OPackage::Command removeCmd = OPackage::NotDefined; 500 OPackage::Command removeCmd = OPackage::NotDefined;
501 if ( removeList && !removeList->isEmpty() ) 501 if ( removeList && !removeList->isEmpty() )
502 removeCmd = OPackage::Remove; 502 removeCmd = OPackage::Remove;
503 OPackage::Command installCmd = OPackage::NotDefined; 503 OPackage::Command installCmd = OPackage::NotDefined;
504 if ( installList && !installList->isEmpty() ) 504 if ( installList && !installList->isEmpty() )
505 installCmd = OPackage::Install; 505 installCmd = OPackage::Install;
506 OPackage::Command upgradeCmd = OPackage::NotDefined; 506 OPackage::Command upgradeCmd = OPackage::NotDefined;
507 if ( upgradeList && !upgradeList->isEmpty() ) 507 if ( upgradeList && !upgradeList->isEmpty() )
508 upgradeCmd = OPackage::Upgrade; 508 upgradeCmd = OPackage::Upgrade;
509 509
510 // Create package manager output widget 510 // Create package manager output widget
511 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Apply changes" ), true, 511 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Apply changes" ), true,
512 removeCmd, removeList, 512 removeCmd, removeList,
513 installCmd, installList, 513 installCmd, installList,
514 upgradeCmd, upgradeList ); 514 upgradeCmd, upgradeList );
515 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); 515 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) );
516 516
517 // Display widget 517 // Display widget
518 m_widgetStack.addWidget( dlg, 3 ); 518 m_widgetStack.addWidget( dlg, 3 );
519 m_widgetStack.raiseWidget( dlg ); 519 m_widgetStack.raiseWidget( dlg );
520} 520}
521 521
522void MainWindow::slotCloseDlg() 522void MainWindow::slotCloseDlg()
523{ 523{
524 // Close install dialog 524 // Close install dialog
525 delete m_widgetStack.visibleWidget(); 525 delete m_widgetStack.visibleWidget();
526 526
527 // Reload package list 527 // Reload package list
528 initPackageInfo(); 528 initPackageInfo();
529 529
530 // Update Opie launcher links 530 // Update Opie launcher links
531 QCopEnvelope e("QPE/System", "linkChanged(QString)"); 531 QCopEnvelope e("QPE/System", "linkChanged(QString)");
532 QString lf = QString::null; 532 QString lf = QString::null;
533 e << lf; 533 e << lf;
534} 534}
535 535
536void MainWindow::slotConfigure() 536void MainWindow::slotConfigure()
537{ 537{
538 if ( m_packman.configureDlg( false ) ) 538 if ( m_packman.configureDlg( false ) )
539 { 539 {
540 if ( PromptDlg::ask( tr( "Config updated" ), 540 if ( PromptDlg::ask( tr( "Config updated" ),
541 tr( "The configuration has been updated. Do you want to update server and package information now?" ), 541 tr( "The configuration has been updated. Do you want to update server and package information now?" ),
542 tr( "Yes" ), tr( "No" ), this ) == 1 ) 542 tr( "Yes" ), tr( "No" ), this ) == 1 )
543 { 543 {
544 // Update package list and reload package info 544 // Update package list and reload package info
545 slotUpdate(); 545 slotUpdate();
546 } 546 }
547 } 547 }
548} 548}
549 549
550void MainWindow::slotShowNotInstalled() 550void MainWindow::slotShowNotInstalled()
551{ 551{
552 OPackageList *packageList; 552 OPackageList *packageList;
553 if ( m_actionShowNotInstalled->isOn() ) 553 if ( m_actionShowNotInstalled->isOn() )
554 { 554 {
555 m_actionShowInstalled->setOn( false ); 555 m_actionShowInstalled->setOn( false );
556 m_actionShowUpdated->setOn( false ); 556 m_actionShowUpdated->setOn( false );
557 m_actionFilter->setOn( false ); 557 m_actionFilter->setOn( false );
558 packageList = m_packman.filterPackages( QString::null, QString::null, QString::null, 558 packageList = m_packman.filterPackages( QString::null, QString::null, QString::null,
559 OPackageManager::NotInstalled, QString::null ); 559 OPackageManager::NotInstalled, QString::null );
560 } 560 }
561 else 561 else
562 packageList = m_packman.packages(); 562 packageList = m_packman.packages();
563 563
564 if ( packageList ) 564 if ( packageList )
565 { 565 {
566 loadPackageList( packageList, true ); 566 loadPackageList( packageList, true );
567 delete packageList; 567 delete packageList;
568 } 568 }
569} 569}
570 570
571void MainWindow::slotShowInstalled() 571void MainWindow::slotShowInstalled()
572{ 572{
573 OPackageList *packageList; 573 OPackageList *packageList;
574 if ( m_actionShowInstalled->isOn() ) 574 if ( m_actionShowInstalled->isOn() )
575 { 575 {
576 m_actionShowNotInstalled->setOn( false ); 576 m_actionShowNotInstalled->setOn( false );
577 m_actionShowUpdated->setOn( false ); 577 m_actionShowUpdated->setOn( false );
578 m_actionFilter->setOn( false ); 578 m_actionFilter->setOn( false );
579 packageList = m_packman.filterPackages( QString::null, QString::null, QString::null, 579 packageList = m_packman.filterPackages( QString::null, QString::null, QString::null,
580 OPackageManager::Installed, QString::null ); 580 OPackageManager::Installed, QString::null );
581 } 581 }
582 else 582 else
583 packageList = m_packman.packages(); 583 packageList = m_packman.packages();
584 584
585 if ( packageList ) 585 if ( packageList )
586 { 586 {
587 loadPackageList( packageList, true ); 587 loadPackageList( packageList, true );
588 delete packageList; 588 delete packageList;
589 } 589 }
590} 590}
591 591
592void MainWindow::slotShowUpdated() 592void MainWindow::slotShowUpdated()
593{ 593{
594 OPackageList *packageList; 594 OPackageList *packageList;
595 if ( m_actionShowUpdated->isOn() ) 595 if ( m_actionShowUpdated->isOn() )
596 { 596 {
597 m_actionShowInstalled->setOn( false ); 597 m_actionShowInstalled->setOn( false );
598 m_actionShowNotInstalled->setOn( false ); 598 m_actionShowNotInstalled->setOn( false );
599 m_actionFilter->setOn( false ); 599 m_actionFilter->setOn( false );
600 packageList = m_packman.filterPackages( QString::null, QString::null, QString::null, 600 packageList = m_packman.filterPackages( QString::null, QString::null, QString::null,
601 OPackageManager::Updated, QString::null ); 601 OPackageManager::Updated, QString::null );
602 } 602 }
603 else 603 else
604 packageList = m_packman.packages(); 604 packageList = m_packman.packages();
605 605
606 if ( packageList ) 606 if ( packageList )
607 { 607 {
608 loadPackageList( packageList, true ); 608 loadPackageList( packageList, true );
609 delete packageList; 609 delete packageList;
610 } 610 }
611} 611}
612 612
613void MainWindow::slotFilterChange() 613void MainWindow::slotFilterChange()
614{ 614{
615 FilterDlg dlg( this, &m_packman, m_filterName, m_filterServer, m_filterDest, m_filterStatus, 615 FilterDlg dlg( this, &m_packman, m_filterName, m_filterServer, m_filterDest, m_filterStatus,
616 m_filterCategory ); 616 m_filterCategory );
617 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) 617 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted )
618 { 618 {
619 m_filterName = dlg.name(); 619 m_filterName = dlg.name();
620 m_filterServer = dlg.server(); 620 m_filterServer = dlg.server();
621 m_filterDest = dlg.destination(); 621 m_filterDest = dlg.destination();
622 m_filterStatus = dlg.status(); 622 m_filterStatus = dlg.status();
623 m_filterCategory = dlg.category(); 623 m_filterCategory = dlg.category();
624 m_actionFilter->setOn( true ); 624 m_actionFilter->setOn( true );
625 slotFilter( true ); 625 slotFilter( true );
626 } 626 }
627 else 627 else
628 { 628 {
629 m_actionFilter->setOn( false ); 629 m_actionFilter->setOn( false );
630 slotFilter( false ); 630 slotFilter( false );
631 } 631 }
632} 632}
633 633
634void MainWindow::slotFilter( bool isOn ) 634void MainWindow::slotFilter( bool isOn )
635{ 635{
636 OPackageList *packageList; 636 OPackageList *packageList;
637 if ( isOn ) 637 if ( isOn )
638 { 638 {
639 // Turn off other filtering options 639 // Turn off other filtering options
640 m_actionShowNotInstalled->setOn( false ); 640 m_actionShowNotInstalled->setOn( false );
641 m_actionShowInstalled->setOn( false ); 641 m_actionShowInstalled->setOn( false );
642 m_actionShowUpdated->setOn( false ); 642 m_actionShowUpdated->setOn( false );
643 643
644 // If the filter settings have not been set yet, display filter dialog 644 // If the filter settings have not been set yet, display filter dialog
645 if ( m_filterName.isNull() && m_filterServer.isNull() && m_filterDest.isNull() && 645 if ( m_filterName.isNull() && m_filterServer.isNull() && m_filterDest.isNull() &&
646 m_filterStatus == OPackageManager::NotDefined && m_filterCategory.isNull() ) 646 m_filterStatus == OPackageManager::NotDefined && m_filterCategory.isNull() )
647 { 647 {
648 FilterDlg dlg( this, &m_packman, m_filterName, m_filterServer, m_filterDest, m_filterStatus, 648 FilterDlg dlg( this, &m_packman, m_filterName, m_filterServer, m_filterDest, m_filterStatus,
649 m_filterCategory ); 649 m_filterCategory );
650 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) 650 if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted )
651 { 651 {
652 m_filterName = dlg.name(); 652 m_filterName = dlg.name();
653 m_filterServer = dlg.server(); 653 m_filterServer = dlg.server();
654 m_filterDest = dlg.destination(); 654 m_filterDest = dlg.destination();
655 m_filterStatus = dlg.status(); 655 m_filterStatus = dlg.status();
656 m_filterCategory = dlg.category(); 656 m_filterCategory = dlg.category();
657 m_actionFilter->setOn( true ); 657 m_actionFilter->setOn( true );
658 packageList = m_packman.filterPackages( m_filterName, m_filterServer, m_filterDest, 658 packageList = m_packman.filterPackages( m_filterName, m_filterServer, m_filterDest,
659 m_filterStatus, m_filterCategory ); 659 m_filterStatus, m_filterCategory );
660 } 660 }
661 else 661 else
662 { 662 {
663 m_actionFilter->setOn( false ); 663 m_actionFilter->setOn( false );
664 packageList = m_packman.packages(); 664 packageList = m_packman.packages();
665 } 665 }
666 } 666 }
667 else 667 else
668 { 668 {
669 m_actionFilter->setOn( true ); 669 m_actionFilter->setOn( true );
670 packageList = m_packman.filterPackages( m_filterName, m_filterServer, m_filterDest, 670 packageList = m_packman.filterPackages( m_filterName, m_filterServer, m_filterDest,
671 m_filterStatus, m_filterCategory ); 671 m_filterStatus, m_filterCategory );
672 } 672 }
673 673
674 674
675 } 675 }
676 else 676 else
677 packageList = m_packman.packages(); 677 packageList = m_packman.packages();
678 678
679 if ( packageList ) 679 if ( packageList )
680 { 680 {
681 loadPackageList( packageList, true ); 681 loadPackageList( packageList, true );
682 delete packageList; 682 delete packageList;
683 } 683 }
684} 684}
685 685
686void MainWindow::slotFindShowToolbar() 686void MainWindow::slotFindShowToolbar()
687{ 687{
688 m_findBar.show(); 688 m_findBar.show();
689 m_findEdit->setFocus(); 689 m_findEdit->setFocus();
690} 690}
691 691
692void MainWindow::slotFindHideToolbar() 692void MainWindow::slotFindHideToolbar()
693{ 693{
694 m_findBar.hide(); 694 m_findBar.hide();
695} 695}
696 696
697void MainWindow::slotFindChanged( const QString &findText ) 697void MainWindow::slotFindChanged( const QString &findText )
698{ 698{
699 699
700 m_actionFindNext->setEnabled( !findText.isEmpty() ); 700 m_actionFindNext->setEnabled( !findText.isEmpty() );
701 searchForPackage( findText ); 701 searchForPackage( findText );
702} 702}
703 703
704void MainWindow::slotFindNext() 704void MainWindow::slotFindNext()
705{ 705{
706 searchForPackage( m_findEdit->text() ); 706 searchForPackage( m_findEdit->text() );
707} 707}
708 708
709void MainWindow::slotDisplayPackageInfo( QListViewItem *packageItem ) 709void MainWindow::slotDisplayPackageInfo( QListViewItem *packageItem )
710{ 710{
711 QString packageName( ( static_cast<QCheckListItem*>( packageItem ) )->text() ); 711 QString packageName( ( static_cast<QCheckListItem*>( packageItem ) )->text() );
712 712
713 // Create package manager output widget 713 // Create package manager output widget
714 PackageInfoDlg *dlg = new PackageInfoDlg( this, &m_packman, packageName ); 714 PackageInfoDlg *dlg = new PackageInfoDlg( this, &m_packman, packageName );
715 715
716 // Display widget 716 // Display widget
717 m_widgetStack.addWidget( dlg, 3 ); 717 m_widgetStack.addWidget( dlg, 3 );
718 m_widgetStack.raiseWidget( dlg ); 718 m_widgetStack.raiseWidget( dlg );
719} 719}
diff --git a/noncore/settings/packagemanager/mainwindow.h b/noncore/settings/packagemanager/mainwindow.h
index fb555c5..632effb 100644
--- a/noncore/settings/packagemanager/mainwindow.h
+++ b/noncore/settings/packagemanager/mainwindow.h
@@ -1,139 +1,139 @@
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 MAINWINDOW_H 30#ifndef MAINWINDOW_H
31#define MAINWINDOW_H 31#define MAINWINDOW_H
32 32
33#include "opackagemanager.h"
34
35#include <qpe/config.h>
36
33#include <qlabel.h> 37#include <qlabel.h>
34#include <qlistview.h> 38#include <qlistview.h>
35#include <qmainwindow.h> 39#include <qmainwindow.h>
36#include <qpixmap.h> 40#include <qpixmap.h>
37#include <qprogressbar.h> 41#include <qprogressbar.h>
38#include <qtoolbar.h> 42#include <qtoolbar.h>
39#include <qwidgetstack.h> 43#include <qwidgetstack.h>
40 44
41#include <qpe/config.h>
42
43#include "opackagemanager.h"
44
45class QAction; 45class QAction;
46class QLineEdit; 46class QLineEdit;
47 47
48class MainWindow :public QMainWindow 48class MainWindow :public QMainWindow
49{ 49{
50 Q_OBJECT 50 Q_OBJECT
51 51
52public: 52public:
53 MainWindow( QWidget *parent = 0x0, const char *name = 0x0, WFlags fl = 0 ); 53 MainWindow( QWidget *parent = 0x0, const char *name = 0x0, WFlags fl = 0 );
54 static QString appName() { return QString::fromLatin1( "packagemanager" ); }; 54 static QString appName() { return QString::fromLatin1( "packagemanager" ); };
55 55
56protected: 56protected:
57 void closeEvent( QCloseEvent *event ); 57 void closeEvent( QCloseEvent *event );
58 58
59private: 59private:
60 Config m_config; // Configuration file 60 Config m_config; // Configuration file
61 61
62 OPackageManager m_packman; // Package manager 62 OPackageManager m_packman; // Package manager
63 63
64 // Toolbars 64 // Toolbars
65 QToolBar m_menuBar; // Main toolbar containing menu 65 QToolBar m_menuBar; // Main toolbar containing menu
66 QToolBar m_toolBar; // Main toolbar 66 QToolBar m_toolBar; // Main toolbar
67 QToolBar m_findBar; // Find toolbar 67 QToolBar m_findBar; // Find toolbar
68 68
69 QWidgetStack m_widgetStack; // Main widget stack which contains m_packageList & m_statusWidget 69 QWidgetStack m_widgetStack; // Main widget stack which contains m_packageList & m_statusWidget
70 QListView m_packageList; // Main list view of all packages 70 QListView m_packageList; // Main list view of all packages
71 71
72 QLineEdit *m_findEdit; // Line edit box used for find toolbar 72 QLineEdit *m_findEdit; // Line edit box used for find toolbar
73 73
74 // Status widget controls 74 // Status widget controls
75 QWidget m_statusWidget; // Widget to display status during long operations 75 QWidget m_statusWidget; // Widget to display status during long operations
76 QLabel m_statusText; // Text status message 76 QLabel m_statusText; // Text status message
77 QProgressBar m_statusBar; // Progress bar showing % completed 77 QProgressBar m_statusBar; // Progress bar showing % completed
78 78
79 // Icon pixmaps 79 // Icon pixmaps
80 QPixmap m_iconUpdated; // Cached icon which shows when package can be updated 80 QPixmap m_iconUpdated; // Cached icon which shows when package can be updated
81 QPixmap m_iconInstalled; // Cached icon which shows when package is installed 81 QPixmap m_iconInstalled; // Cached icon which shows when package is installed
82 QPixmap m_iconNull; // Cached icon which shows when package is not installed 82 QPixmap m_iconNull; // Cached icon which shows when package is not installed
83 83
84 // Menu/tool bar actions 84 // Menu/tool bar actions
85 QAction *m_actionShowNotInstalled; // Action to show pakages not currently installed 85 QAction *m_actionShowNotInstalled; // Action to show pakages not currently installed
86 QAction *m_actionShowInstalled; // Action to show pakages currently installed 86 QAction *m_actionShowInstalled; // Action to show pakages currently installed
87 QAction *m_actionShowUpdated; // Action to show pakages currently installed with update available 87 QAction *m_actionShowUpdated; // Action to show pakages currently installed with update available
88 QAction *m_actionFilter; // Action to filter packages 88 QAction *m_actionFilter; // Action to filter packages
89 QAction *m_actionFindNext; // Action to find next match 89 QAction *m_actionFindNext; // Action to find next match
90 90
91 // Cached filter settings 91 // Cached filter settings
92 QString m_filterName; // Cached name filter value 92 QString m_filterName; // Cached name filter value
93 QString m_filterServer; // Cached server name filter value 93 QString m_filterServer; // Cached server name filter value
94 QString m_filterDest; // Cached destination name filter value 94 QString m_filterDest; // Cached destination name filter value
95 OPackageManager::Status m_filterStatus; // Cached status filter value 95 OPackageManager::Status m_filterStatus; // Cached status filter value
96 QString m_filterCategory; // Cached category filter value 96 QString m_filterCategory; // Cached category filter value
97 97
98 void initPackageList(); 98 void initPackageList();
99 void initStatusWidget(); 99 void initStatusWidget();
100 void initUI(); 100 void initUI();
101 101
102 void loadPackageList( OPackageList *packages = 0x0, bool clearList = true ); 102 void loadPackageList( OPackageList *packages = 0x0, bool clearList = true );
103 void searchForPackage( const QString &text ); 103 void searchForPackage( const QString &text );
104 104
105private slots: 105private slots:
106 void initPackageInfo(); 106 void initPackageInfo();
107 void slotWidgetStackShow( QWidget *widget ); 107 void slotWidgetStackShow( QWidget *widget );
108 108
109 // Status widget slots 109 // Status widget slots
110 void slotInitStatusBar( int numSteps ); 110 void slotInitStatusBar( int numSteps );
111 void slotStatusText( const QString &status ); 111 void slotStatusText( const QString &status );
112 void slotStatusBar( int currStep ); 112 void slotStatusBar( int currStep );
113 113
114 // Actions menu action slots 114 // Actions menu action slots
115 void slotUpdate(); 115 void slotUpdate();
116 void slotUpgrade(); 116 void slotUpgrade();
117 void slotDownload(); 117 void slotDownload();
118 void slotApply(); 118 void slotApply();
119 void slotCloseDlg(); 119 void slotCloseDlg();
120 void slotConfigure(); 120 void slotConfigure();
121 121
122 // View menu action slots 122 // View menu action slots
123 void slotShowNotInstalled(); 123 void slotShowNotInstalled();
124 void slotShowInstalled(); 124 void slotShowInstalled();
125 void slotShowUpdated(); 125 void slotShowUpdated();
126 void slotFilterChange(); 126 void slotFilterChange();
127 void slotFilter( bool isOn ); 127 void slotFilter( bool isOn );
128 128
129 // Find action slots 129 // Find action slots
130 void slotFindShowToolbar(); 130 void slotFindShowToolbar();
131 void slotFindHideToolbar(); 131 void slotFindHideToolbar();
132 void slotFindChanged( const QString &findText ); 132 void slotFindChanged( const QString &findText );
133 void slotFindNext(); 133 void slotFindNext();
134 134
135 // Other slots 135 // Other slots
136 void slotDisplayPackageInfo( QListViewItem * ); 136 void slotDisplayPackageInfo( QListViewItem * );
137}; 137};
138 138
139#endif 139#endif
diff --git a/noncore/settings/packagemanager/oconfitem.cpp b/noncore/settings/packagemanager/oconfitem.cpp
index 940a6de..a90730c 100644
--- a/noncore/settings/packagemanager/oconfitem.cpp
+++ b/noncore/settings/packagemanager/oconfitem.cpp
@@ -1,42 +1,41 @@
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 "oconfitem.h" 32#include "oconfitem.h"
33 33
34OConfItem::OConfItem( const QString &location, Type type, const QString &name, 34OConfItem::OConfItem( Type type, const QString &name,
35 const QString &value, bool active ) 35 const QString &value, bool active )
36 : m_location( location ) 36 : m_type( type )
37 , m_type( type )
38 , m_name( name ) 37 , m_name( name )
39 , m_value( value ) 38 , m_value( value )
40 , m_active( active ) 39 , m_active( active )
41{ 40{
42} 41}
diff --git a/noncore/settings/packagemanager/oconfitem.h b/noncore/settings/packagemanager/oconfitem.h
index aeee511..db77980 100644
--- a/noncore/settings/packagemanager/oconfitem.h
+++ b/noncore/settings/packagemanager/oconfitem.h
@@ -1,95 +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 =. 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 OCONFITEM_H 32#ifndef OCONFITEM_H
33#define OCONFITEM_H 33#define OCONFITEM_H
34 34
35#include <qlist.h> 35#include <qlist.h>
36#include <qstring.h> 36#include <qstring.h>
37 37
38class OConfItem 38class OConfItem
39{ 39{
40public: 40public:
41 enum Type { Source, Destination, Option, Arch, NotDefined }; 41 enum Type { Source, Destination, Option, Arch, NotDefined };
42 42
43 OConfItem( const QString &location = 0x0, Type type = NotDefined, const QString &name = 0x0, 43 OConfItem( Type type = NotDefined, const QString &name = 0x0, const QString &value = 0x0,
44 const QString &value = 0x0, bool active = true ); 44 bool active = true );
45 45
46 const QString &location() { return m_location; }
47 Type type() { return m_type; } 46 Type type() { return m_type; }
48 const QString &name() { return m_name; } 47 const QString &name() { return m_name; }
49 const QString &value() { return m_value; } 48 const QString &value() { return m_value; }
50 bool active() { return m_active; } 49 bool active() { return m_active; }
51 50
52 void setLocation( const QString &location ) { m_location = location; } 51 void setType( Type type ) { m_type = type; }
53 void setType( Type type ) { m_type = type; } 52 void setName( const QString &name ) { m_name = name; }
54 void setName( const QString &name ) { m_name = name; } 53 void setValue( const QString &value ) { m_value = value; }
55 void setValue( const QString &value ) { m_value = value; } 54 void setActive( bool active ) { m_active = active; }
56 void setActive( bool active ) { m_active = active; }
57 55
58private: 56private:
59 QString m_location; // Configuration file where item is located
60 Type m_type; // Type of configuration item 57 Type m_type; // Type of configuration item
61 QString m_name; // Name of item 58 QString m_name; // Name of item
62 QString m_value; // Value of item 59 QString m_value; // Value of item
63 bool m_active; // Indicates whether item is currently active 60 bool m_active; // Indicates whether item is currently active
64}; 61};
65 62
66class OConfItemList : public QList<OConfItem> 63class OConfItemList : public QList<OConfItem>
67{ 64{
68private: 65private:
69 66
70 int compareItems( QCollection::Item item1, QCollection::Item item2 ) 67 int compareItems( QCollection::Item item1, QCollection::Item item2 )
71 { 68 {
72 // Sort by OConfItem location then by type 69 // Sort by OConfItem location then by type
73 QString loc1 = reinterpret_cast<OConfItem*>(item1)->location(); 70 OConfItem::Type type1 = reinterpret_cast<OConfItem*>(item1)->type();
74 QString loc2 = reinterpret_cast<OConfItem*>(item2)->location(); 71 OConfItem::Type type2 = reinterpret_cast<OConfItem*>(item2)->type();
75 if ( loc1 < loc2 ) 72 if ( type1 < type2 )
76 return -1; 73 return -1;
77 else if ( loc1 == loc2 ) 74 else if ( type1 == type2 )
78 { 75 {
79 OConfItem::Type type1 = reinterpret_cast<OConfItem*>(item1)->type(); 76 QString name1 = reinterpret_cast<OConfItem*>(item1)->name();
80 OConfItem::Type type2 = reinterpret_cast<OConfItem*>(item2)->type(); 77 QString name2 = reinterpret_cast<OConfItem*>(item2)->name();
81 if ( type1 < type2 ) 78 if ( name1 < name2 )
82 return -1; 79 return -1;
83 else if ( type1 == type2 ) 80 else if ( name1 == name2 )
84 return 0; 81 return 0;
85 else /*if ( type1 > type2 )*/ 82 else /*if ( name1 > name2 )*/
86 return 1; 83 return 1;
87 } 84 }
88 else /*if ( loc1 > loc2 )*/ 85 else /*if ( type1 > type2 )*/
89 return 1; 86 return 1;
90 } 87 }
91}; 88};
92 89
93typedef QListIterator<OConfItem> OConfItemListIterator; 90typedef QListIterator<OConfItem> OConfItemListIterator;
94 91
95#endif 92#endif
diff --git a/noncore/settings/packagemanager/oipkg.cpp b/noncore/settings/packagemanager/oipkg.cpp
index 696a64a..87a30bb 100644
--- a/noncore/settings/packagemanager/oipkg.cpp
+++ b/noncore/settings/packagemanager/oipkg.cpp
@@ -1,575 +1,574 @@
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 <stdlib.h>
35#include <string.h>
36
37#include <qdir.h> 34#include <qdir.h>
38#include <qfile.h> 35#include <qfile.h>
39#include <qtextstream.h> 36#include <qtextstream.h>
40 37
38#include <stdlib.h>
39
41const QString IPKG_CONF = "/etc/ipkg.conf"; // Fully-qualified name of Ipkg primary configuration file 40const QString IPKG_CONF = "/etc/ipkg.conf"; // Fully-qualified name of Ipkg primary configuration file
42const QString IPKG_CONF_DIR = "/etc/ipkg"; // Directory of secondary Ipkg configuration files 41const QString IPKG_CONF_DIR = "/etc/ipkg"; // Directory of secondary Ipkg configuration files
43const QString IPKG_PKG_PATH = "/usr/lib/ipkg/lists"; // Directory containing server package lists 42const QString IPKG_PKG_PATH = "/usr/lib/ipkg/lists"; // Directory containing server package lists
44const QString IPKG_STATUS_PATH = "usr/lib/ipkg/status"; // Destination status file location 43const QString IPKG_STATUS_PATH = "usr/lib/ipkg/status"; // Destination status file location
45 44
46OIpkg *oipkg; 45OIpkg *oipkg;
47 46
48// Ipkg callback functions 47// Ipkg callback functions
49 48
50int fsignalIpkgMessage( ipkg_conf_t */*conf*/, message_level_t /*level*/, char *msg ) 49int fsignalIpkgMessage( ipkg_conf_t */*conf*/, message_level_t /*level*/, char *msg )
51{ 50{
52 oipkg->ipkgMessage( msg ); 51 oipkg->ipkgMessage( msg );
53 return 0; 52 return 0;
54} 53}
55 54
56char *fIpkgResponse( char */*question*/ ) 55char *fIpkgResponse( char */*question*/ )
57{ 56{
58 return 0x0; 57 return 0x0;
59} 58}
60 59
61int fIpkgStatus( char */*name*/, int /*status*/, char *desc, void */*userdata*/ ) 60int fIpkgStatus( char */*name*/, int /*status*/, char *desc, void */*userdata*/ )
62{ 61{
63 oipkg->ipkgStatus( desc ); 62 oipkg->ipkgStatus( desc );
64 return 0; 63 return 0;
65} 64}
66 65
67int fIpkgFiles( char */*name*/, char *desc, char */*version*/, pkg_state_status_t /*status*/, 66int fIpkgFiles( char */*name*/, char *desc, char */*version*/, pkg_state_status_t /*status*/,
68 void */*userdata*/ ) 67 void */*userdata*/ )
69{ 68{
70 oipkg->ipkgList( desc ); 69 oipkg->ipkgList( desc );
71 return 0; 70 return 0;
72} 71}
73 72
74OIpkg::OIpkg( Config *config, QObject *parent, const char *name ) 73OIpkg::OIpkg( Config *config, QObject *parent, const char *name )
75 : QObject( parent, name ) 74 : QObject( parent, name )
76 , m_config( config ) 75 , m_config( config )
77 , m_confInfo( NULL ) 76 , m_confInfo( NULL )
78 , m_ipkgExecOptions( 0 ) 77 , m_ipkgExecOptions( 0 )
79 , m_ipkgExecVerbosity( 1 ) 78 , m_ipkgExecVerbosity( 1 )
80{ 79{
81 oipkg = this; 80 oipkg = this;
82 81
83 // Initialize libipkg 82 // Initialize libipkg
84 ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ); 83 ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs );
85 84
86 // Default ipkg run-time arguments 85 // Default ipkg run-time arguments
87 m_ipkgArgs.noaction = false; 86 m_ipkgArgs.noaction = false;
88 m_ipkgArgs.force_defaults = true; 87 m_ipkgArgs.force_defaults = true;
89} 88}
90 89
91OIpkg::~OIpkg() 90OIpkg::~OIpkg()
92{ 91{
93 // Upon destruction, ensure that items in config list are deleted with list 92 // Upon destruction, ensure that items in config list are deleted with list
94 if ( m_confInfo ) 93 if ( m_confInfo )
95 m_confInfo->setAutoDelete( true ); 94 m_confInfo->setAutoDelete( true );
96 95
97 // Free up libipkg resources 96 // Free up libipkg resources
98 ipkg_deinit( &m_ipkgArgs ); 97 ipkg_deinit( &m_ipkgArgs );
99} 98}
100 99
101OConfItemList *OIpkg::configItems() 100OConfItemList *OIpkg::configItems()
102{ 101{
103 // Retrieve all configuration items 102 // Retrieve all configuration items
104 return filterConfItems(); 103 return filterConfItems();
105} 104}
106 105
107OConfItemList *OIpkg::servers() 106OConfItemList *OIpkg::servers()
108{ 107{
109 // Retrieve only servers 108 // Retrieve only servers
110 return filterConfItems( OConfItem::Source ); 109 return filterConfItems( OConfItem::Source );
111} 110}
112 111
113OConfItemList *OIpkg::destinations() 112OConfItemList *OIpkg::destinations()
114{ 113{
115 // Retrieve only destinations 114 // Retrieve only destinations
116 return filterConfItems( OConfItem::Destination ); 115 return filterConfItems( OConfItem::Destination );
117} 116}
118 117
119OConfItemList *OIpkg::options() 118OConfItemList *OIpkg::options()
120{ 119{
121 // Retrieve only destinations 120 // Retrieve only destinations
122 return filterConfItems( OConfItem::Option ); 121 return filterConfItems( OConfItem::Option );
123} 122}
124 123
125void OIpkg::setConfigItems( OConfItemList *configList ) 124void OIpkg::setConfigItems( OConfItemList *configList )
126{ 125{
127 if ( m_confInfo ) 126 if ( m_confInfo )
128 delete m_confInfo; 127 delete m_confInfo;
129 128
130 m_confInfo = configList; 129 m_confInfo = configList;
131 130
132 // Write out new /etc/ipkg.conf 131 // Write out new /etc/ipkg.conf
133 QFile confFile( IPKG_CONF ); 132 QFile confFile( IPKG_CONF );
134 if ( confFile.open( IO_WriteOnly ) ) 133 if ( confFile.open( IO_WriteOnly ) )
135 { 134 {
136 QTextStream confStream( &confFile ); 135 QTextStream confStream( &confFile );
137 confStream << "# Generated by Opie Package Manager\n\n"; 136 confStream << "# Generated by Opie Package Manager\n\n";
138 137
139 OConfItemListIterator it( *m_confInfo ); 138 OConfItemListIterator it( *m_confInfo );
140 for ( ; it.current(); ++it ) 139 for ( ; it.current(); ++it )
141 { 140 {
142 OConfItem *item = it.current(); 141 OConfItem *item = it.current();
143 142
144 // Only write out valid conf items 143 // Only write out valid conf items
145 if ( item->type() != OConfItem::NotDefined ) 144 if ( item->type() != OConfItem::NotDefined )
146 { 145 {
147 QString confLine; 146 QString confLine;
148 if ( !item->active() ) 147 if ( !item->active() )
149 confLine = "#"; 148 confLine = "#";
150 149
151 switch ( item->type() ) 150 switch ( item->type() )
152 { 151 {
153 case OConfItem::Source : confLine.append( "src " ); break; 152 case OConfItem::Source : confLine.append( "src " ); break;
154 case OConfItem::Destination : confLine.append( "dest " ); break; 153 case OConfItem::Destination : confLine.append( "dest " ); break;
155 case OConfItem::Option : confLine.append( "option " ); break; 154 case OConfItem::Option : confLine.append( "option " ); break;
156 case OConfItem::Arch : confLine.append( "arch " ); break; 155 case OConfItem::Arch : confLine.append( "arch " ); break;
157 default : break; 156 default : break;
158 }; 157 };
159 158
160 confStream << confLine << " " << item->name() << " " << item->value() << "\n"; 159 confStream << confLine << " " << item->name() << " " << item->value() << "\n";
161 } 160 }
162 } 161 }
163 162
164 confFile.close(); 163 confFile.close();
165 } 164 }
166 else 165 else
167 { 166 {
168 // Problem writing to /etc/ipkg.conf, exit before removing other conf files 167 // Problem writing to /etc/ipkg.conf, exit before removing other conf files
169 return; 168 return;
170 } 169 }
171 170
172 // Delete /etc/ipkg/*.conf files (/etc/ipkg.conf should now have all settings 171 // Delete /etc/ipkg/*.conf files (/etc/ipkg.conf should now have all settings
173 QStringList confFiles; 172 QStringList confFiles;
174 QDir confDir( IPKG_CONF_DIR ); 173 QDir confDir( IPKG_CONF_DIR );
175 if ( confDir.exists() ) 174 if ( confDir.exists() )
176 { 175 {
177 confDir.setNameFilter( "*.conf" ); 176 confDir.setNameFilter( "*.conf" );
178 confDir.setFilter( QDir::Files ); 177 confDir.setFilter( QDir::Files );
179 confFiles = confDir.entryList( "*.conf", QDir::Files ); 178 confFiles = confDir.entryList( "*.conf", QDir::Files );
180 179
181 QStringList::Iterator lastFile = confFiles.end(); 180 QStringList::Iterator lastFile = confFiles.end();
182 for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it ) 181 for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it )
183 { 182 {
184 // Create absolute file path if necessary 183 // Create absolute file path if necessary
185 QString absFile = (*it); 184 QString absFile = (*it);
186 if ( !absFile.startsWith( "/" ) ) 185 if ( !absFile.startsWith( "/" ) )
187 absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); 186 absFile.prepend( QString( IPKG_CONF_DIR ) + "/" );
188 187
189 // Delete file 188 // Delete file
190 QFile::remove( absFile ); 189 QFile::remove( absFile );
191 } 190 }
192 } 191 }
193 192
194 // Reinitialize libipkg to pick up new configuration 193 // Reinitialize libipkg to pick up new configuration
195 ipkg_deinit( &m_ipkgArgs ); 194 ipkg_deinit( &m_ipkgArgs );
196 ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ); 195 ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs );
197 m_ipkgArgs.noaction = false; 196 m_ipkgArgs.noaction = false;
198 m_ipkgArgs.force_defaults = true; 197 m_ipkgArgs.force_defaults = true;
199} 198}
200 199
201void OIpkg::saveSettings() 200void OIpkg::saveSettings()
202{ 201{
203 // Save Ipkg execution options to application configuration file 202 // Save Ipkg execution options to application configuration file
204 if ( m_config ) 203 if ( m_config )
205 { 204 {
206 m_config->setGroup( "Ipkg" ); 205 m_config->setGroup( "Ipkg" );
207 m_config->writeEntry( "ExecOptions", m_ipkgExecOptions ); 206 m_config->writeEntry( "ExecOptions", m_ipkgExecOptions );
208 m_config->writeEntry( "Verbosity", m_ipkgExecVerbosity ); 207 m_config->writeEntry( "Verbosity", m_ipkgExecVerbosity );
209 } 208 }
210} 209}
211 210
212OPackageList *OIpkg::availablePackages( const QString &server ) 211OPackageList *OIpkg::availablePackages( const QString &server )
213{ 212{
214 // Load Ipkg configuration info if not already cached 213 // Load Ipkg configuration info if not already cached
215 if ( !m_confInfo ) 214 if ( !m_confInfo )
216 loadConfiguration(); 215 loadConfiguration();
217 216
218 // Build new server list (caller is responsible for deleting) 217 // Build new server list (caller is responsible for deleting)
219 OPackageList *pl = new OPackageList; 218 OPackageList *pl = new OPackageList;
220 219
221 // Open package list file 220 // Open package list file
222 QFile f( IPKG_PKG_PATH + "/" + server ); 221 QFile f( IPKG_PKG_PATH + "/" + server );
223 if ( !f.open( IO_ReadOnly ) ) 222 if ( !f.open( IO_ReadOnly ) )
224 return NULL; 223 return NULL;
225 QTextStream t( &f ); 224 QTextStream t( &f );
226 225
227 // Process all information in package list file 226 // Process all information in package list file
228 OPackage *package = NULL; 227 OPackage *package = NULL;
229 QString line = t.readLine(); 228 QString line = t.readLine();
230 while ( !t.eof() ) 229 while ( !t.eof() )
231 { 230 {
232 // Determine key/value pair 231 // Determine key/value pair
233 int pos = line.find( ':', 0 ); 232 int pos = line.find( ':', 0 );
234 QString key; 233 QString key;
235 if ( pos > -1 ) 234 if ( pos > -1 )
236 key = line.mid( 0, pos ); 235 key = line.mid( 0, pos );
237 else 236 else
238 key = QString::null; 237 key = QString::null;
239 QString value = line.mid( pos+2, line.length()-pos ); 238 QString value = line.mid( pos+2, line.length()-pos );
240 239
241 // Allocate new package and insert into list 240 // Allocate new package and insert into list
242 if ( package == NULL && !key.isEmpty() ) 241 if ( package == NULL && !key.isEmpty() )
243 { 242 {
244 package = new OPackage( value ); 243 package = new OPackage( value );
245 package->setSource( server ); 244 package->setSource( server );
246 pl->append( package ); 245 pl->append( package );
247 } 246 }
248 247
249 // Update package data 248 // Update package data
250 if ( key == "Package" ) 249 if ( key == "Package" )
251 package->setName( value ); 250 package->setName( value );
252 else if ( key == "Version" ) 251 else if ( key == "Version" )
253 package->setVersion( value ); 252 package->setVersion( value );
254 else if ( key == "Section" ) 253 else if ( key == "Section" )
255 package->setCategory( value ); 254 package->setCategory( value );
256 //DataManager::setAvailableCategories( value ); 255 //DataManager::setAvailableCategories( value );
257 else if ( key.isEmpty() && value.isEmpty() ) 256 else if ( key.isEmpty() && value.isEmpty() )
258 package = NULL; 257 package = NULL;
259 258
260 // Skip past all description lines 259 // Skip past all description lines
261 if ( key == "Description" ) 260 if ( key == "Description" )
262 { 261 {
263 line = t.readLine(); 262 line = t.readLine();
264 while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) 263 while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() )
265 line = t.readLine(); 264 line = t.readLine();
266 } 265 }
267 else 266 else
268 line = t.readLine(); 267 line = t.readLine();
269 } 268 }
270 269
271 f.close(); 270 f.close();
272 271
273 return pl; 272 return pl;
274} 273}
275 274
276OPackageList *OIpkg::installedPackages( const QString &destName, const QString &destPath ) 275OPackageList *OIpkg::installedPackages( const QString &destName, const QString &destPath )
277{ 276{
278 // Load Ipkg configuration info if not already cached 277 // Load Ipkg configuration info if not already cached
279 if ( !m_confInfo ) 278 if ( !m_confInfo )
280 loadConfiguration(); 279 loadConfiguration();
281 280
282 // Build new server list (caller is responsible for deleting) 281 // Build new server list (caller is responsible for deleting)
283 OPackageList *pl = new OPackageList; 282 OPackageList *pl = new OPackageList;
284 283
285 // Open status file 284 // Open status file
286 QString path = destPath; 285 QString path = destPath;
287 if ( path.right( 1 ) != "/" ) 286 if ( path.right( 1 ) != "/" )
288 path.append( "/" ); 287 path.append( "/" );
289 path.append( IPKG_STATUS_PATH ); 288 path.append( IPKG_STATUS_PATH );
290 289
291 QFile f( path ); 290 QFile f( path );
292 if ( !f.open( IO_ReadOnly ) ) 291 if ( !f.open( IO_ReadOnly ) )
293 return NULL; 292 return NULL;
294 QTextStream t( &f ); 293 QTextStream t( &f );
295 294
296 // Process all information in status file 295 // Process all information in status file
297 bool newPackage = false; 296 bool newPackage = false;
298 QString line = t.readLine(); 297 QString line = t.readLine();
299 QString name; 298 QString name;
300 QString version; 299 QString version;
301 QString status; 300 QString status;
302 301
303 while ( !t.eof() ) 302 while ( !t.eof() )
304 { 303 {
305 // Determine key/value pair 304 // Determine key/value pair
306 int pos = line.find( ':', 0 ); 305 int pos = line.find( ':', 0 );
307 QString key; 306 QString key;
308 if ( pos > -1 ) 307 if ( pos > -1 )
309 key = line.mid( 0, pos ); 308 key = line.mid( 0, pos );
310 else 309 else
311 key = QString::null; 310 key = QString::null;
312 QString value = line.mid( pos+2, line.length()-pos ); 311 QString value = line.mid( pos+2, line.length()-pos );
313 312
314 // Allocate new package and insert into list 313 // Allocate new package and insert into list
315 if ( newPackage && !key.isEmpty() ) 314 if ( newPackage && !key.isEmpty() )
316 { 315 {
317 // Add to list only if it has a valid name and is installed 316 // Add to list only if it has a valid name and is installed
318 if ( !name.isNull() && status.contains( " installed" ) ) 317 if ( !name.isNull() && status.contains( " installed" ) )
319 { 318 {
320 pl->append( new OPackage( name, QString::null, version, QString::null, destName ) ); 319 pl->append( new OPackage( name, QString::null, version, QString::null, destName ) );
321 name = QString::null; 320 name = QString::null;
322 version = QString::null; 321 version = QString::null;
323 status = QString::null; 322 status = QString::null;
324 323
325 newPackage = false; 324 newPackage = false;
326 } 325 }
327 } 326 }
328 327
329 // Update package data 328 // Update package data
330 if ( key == "Package" ) 329 if ( key == "Package" )
331 name = value; 330 name = value;
332 else if ( key == "Version" ) 331 else if ( key == "Version" )
333 version = value; 332 version = value;
334 else if ( key == "Status" ) 333 else if ( key == "Status" )
335 status = value; 334 status = value;
336 else if ( key.isEmpty() && value.isEmpty() ) 335 else if ( key.isEmpty() && value.isEmpty() )
337 newPackage = true; 336 newPackage = true;
338 337
339 // Skip past all description lines 338 // Skip past all description lines
340 if ( key == "Description" ) 339 if ( key == "Description" )
341 { 340 {
342 line = t.readLine(); 341 line = t.readLine();
343 while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) 342 while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() )
344 line = t.readLine(); 343 line = t.readLine();
345 } 344 }
346 else 345 else
347 line = t.readLine(); 346 line = t.readLine();
348 } 347 }
349 348
350 f.close(); 349 f.close();
351 350
352 return pl; 351 return pl;
353} 352}
354 353
355bool OIpkg::executeCommand( OPackage::Command command, QStringList *parameters, const QString &destination, 354bool OIpkg::executeCommand( OPackage::Command command, QStringList *parameters, const QString &destination,
356 const QObject *receiver, const char *slotOutput, bool rawOutput ) 355 const QObject *receiver, const char *slotOutput, bool rawOutput )
357{ 356{
358 if ( command == OPackage::NotDefined ) 357 if ( command == OPackage::NotDefined )
359 return false; 358 return false;
360 359
361 // Set ipkg run-time options/arguments 360 // Set ipkg run-time options/arguments
362 m_ipkgArgs.force_depends = ( m_ipkgExecOptions & FORCE_DEPENDS ); 361 m_ipkgArgs.force_depends = ( m_ipkgExecOptions & FORCE_DEPENDS );
363 m_ipkgArgs.force_reinstall = ( m_ipkgExecOptions & FORCE_REINSTALL ); 362 m_ipkgArgs.force_reinstall = ( m_ipkgExecOptions & FORCE_REINSTALL );
364 // TODO m_ipkgArgs.force_remove = ( m_ipkgExecOptions & FORCE_REMOVE ); 363 // TODO m_ipkgArgs.force_remove = ( m_ipkgExecOptions & FORCE_REMOVE );
365 m_ipkgArgs.force_overwrite = ( m_ipkgExecOptions & FORCE_OVERWRITE ); 364 m_ipkgArgs.force_overwrite = ( m_ipkgExecOptions & FORCE_OVERWRITE );
366 m_ipkgArgs.verbosity = m_ipkgExecVerbosity; 365 m_ipkgArgs.verbosity = m_ipkgExecVerbosity;
367 if ( m_ipkgArgs.dest ) 366 if ( m_ipkgArgs.dest )
368 free( m_ipkgArgs.dest ); 367 free( m_ipkgArgs.dest );
369 if ( !destination.isNull() ) 368 if ( !destination.isNull() )
370 { 369 {
371 int len = destination.length() + 1; 370 int len = destination.length() + 1;
372 m_ipkgArgs.dest = (char *)malloc( len ); 371 m_ipkgArgs.dest = (char *)malloc( len );
373 strncpy( m_ipkgArgs.dest, destination, destination.length() ); 372 strncpy( m_ipkgArgs.dest, destination, destination.length() );
374 m_ipkgArgs.dest[ len - 1 ] = '\0'; 373 m_ipkgArgs.dest[ len - 1 ] = '\0';
375 } 374 }
376 else 375 else
377 m_ipkgArgs.dest = 0x0; 376 m_ipkgArgs.dest = 0x0;
378 377
379 // Connect output signal to widget 378 // Connect output signal to widget
380 379
381 if ( rawOutput ) 380 if ( rawOutput )
382 { 381 {
383// if ( slotOutput ) 382// if ( slotOutput )
384// connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); 383// connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput );
385 } 384 }
386 else 385 else
387 { 386 {
388 // TODO - connect to local slot and parse output before emitting signalIpkgMessage 387 // TODO - connect to local slot and parse output before emitting signalIpkgMessage
389 } 388 }
390 389
391 switch( command ) 390 switch( command )
392 { 391 {
393 case OPackage::Update : { 392 case OPackage::Update : {
394 connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); 393 connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput );
395 ipkg_lists_update( &m_ipkgArgs ); 394 ipkg_lists_update( &m_ipkgArgs );
396 }; 395 };
397 break; 396 break;
398 case OPackage::Upgrade : { 397 case OPackage::Upgrade : {
399 connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); 398 connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput );
400 ipkg_packages_upgrade( &m_ipkgArgs ); 399 ipkg_packages_upgrade( &m_ipkgArgs );
401 }; 400 };
402 break; 401 break;
403 case OPackage::Install : { 402 case OPackage::Install : {
404 connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); 403 connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput );
405 for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) 404 for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it )
406 { 405 {
407 ipkg_packages_install( &m_ipkgArgs, (*it) ); 406 ipkg_packages_install( &m_ipkgArgs, (*it) );
408 } 407 }
409 }; 408 };
410 break; 409 break;
411 case OPackage::Remove : { 410 case OPackage::Remove : {
412 connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); 411 connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput );
413 for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) 412 for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it )
414 { 413 {
415 ipkg_packages_remove( &m_ipkgArgs, (*it), true ); 414 ipkg_packages_remove( &m_ipkgArgs, (*it), true );
416 } 415 }
417 }; 416 };
418 break; 417 break;
419 case OPackage::Download : { 418 case OPackage::Download : {
420 connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); 419 connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput );
421 for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) 420 for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it )
422 { 421 {
423 ipkg_packages_download( &m_ipkgArgs, (*it) ); 422 ipkg_packages_download( &m_ipkgArgs, (*it) );
424 } 423 }
425 }; 424 };
426 break; 425 break;
427 case OPackage::Info : { 426 case OPackage::Info : {
428 connect( this, SIGNAL(signalIpkgStatus(char*)), receiver, slotOutput ); 427 connect( this, SIGNAL(signalIpkgStatus(char*)), receiver, slotOutput );
429 ipkg_packages_info( &m_ipkgArgs, (*parameters->begin()), &fIpkgStatus, 0x0 ); 428 ipkg_packages_info( &m_ipkgArgs, (*parameters->begin()), &fIpkgStatus, 0x0 );
430 }; 429 };
431 break; 430 break;
432 case OPackage::Files : { 431 case OPackage::Files : {
433 connect( this, SIGNAL(signalIpkgList(char*)), receiver, slotOutput ); 432 connect( this, SIGNAL(signalIpkgList(char*)), receiver, slotOutput );
434 ipkg_package_files( &m_ipkgArgs, (*parameters->begin()), &fIpkgFiles, 0x0 ); 433 ipkg_package_files( &m_ipkgArgs, (*parameters->begin()), &fIpkgFiles, 0x0 );
435 }; 434 };
436 break; 435 break;
437 default : break; 436 default : break;
438 }; 437 };
439 438
440 return true; 439 return true;
441} 440}
442 441
443void OIpkg::ipkgMessage( char *msg ) 442void OIpkg::ipkgMessage( char *msg )
444{ 443{
445 emit signalIpkgMessage( msg ); 444 emit signalIpkgMessage( msg );
446} 445}
447 446
448void OIpkg::ipkgStatus( char *status ) 447void OIpkg::ipkgStatus( char *status )
449{ 448{
450 emit signalIpkgStatus( status ); 449 emit signalIpkgStatus( status );
451} 450}
452 451
453void OIpkg::ipkgList( char *filelist ) 452void OIpkg::ipkgList( char *filelist )
454{ 453{
455 emit signalIpkgList( filelist ); 454 emit signalIpkgList( filelist );
456} 455}
457 456
458void OIpkg::loadConfiguration() 457void OIpkg::loadConfiguration()
459{ 458{
460 if ( m_confInfo ) 459 if ( m_confInfo )
461 delete m_confInfo; 460 delete m_confInfo;
462 461
463 // Load configuration item list 462 // Load configuration item list
464 m_confInfo = new OConfItemList(); 463 m_confInfo = new OConfItemList();
465 464
466 QStringList confFiles; 465 QStringList confFiles;
467 QDir confDir( IPKG_CONF_DIR ); 466 QDir confDir( IPKG_CONF_DIR );
468 if ( confDir.exists() ) 467 if ( confDir.exists() )
469 { 468 {
470 confDir.setNameFilter( "*.conf" ); 469 confDir.setNameFilter( "*.conf" );
471 confDir.setFilter( QDir::Files ); 470 confDir.setFilter( QDir::Files );
472 confFiles = confDir.entryList( "*.conf", QDir::Files ); 471 confFiles = confDir.entryList( "*.conf", QDir::Files );
473 confFiles << IPKG_CONF; 472 confFiles << IPKG_CONF;
474 473
475 QStringList::Iterator lastFile = confFiles.end(); 474 QStringList::Iterator lastFile = confFiles.end();
476 for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it ) 475 for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it )
477 { 476 {
478 // Create absolute file path if necessary 477 // Create absolute file path if necessary
479 QString absFile = (*it); 478 QString absFile = (*it);
480 if ( !absFile.startsWith( "/" ) ) 479 if ( !absFile.startsWith( "/" ) )
481 absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); 480 absFile.prepend( QString( IPKG_CONF_DIR ) + "/" );
482 481
483 // Read in file 482 // Read in file
484 QFile f( absFile ); 483 QFile f( absFile );
485 if ( f.open( IO_ReadOnly ) ) 484 if ( f.open( IO_ReadOnly ) )
486 { 485 {
487 QTextStream s( &f ); 486 QTextStream s( &f );
488 while ( !s.eof() ) 487 while ( !s.eof() )
489 { 488 {
490 489
491 QString line = s.readLine().simplifyWhiteSpace(); 490 QString line = s.readLine().simplifyWhiteSpace();
492 491
493 // Parse line and save info to the conf options list 492 // Parse line and save info to the conf options list
494 if ( !line.isEmpty() ) 493 if ( !line.isEmpty() )
495 { 494 {
496 if ( !line.startsWith( "#" ) || 495 if ( !line.startsWith( "#" ) ||
497 line.startsWith( "#src" ) || 496 line.startsWith( "#src" ) ||
498 line.startsWith( "#dest" ) || 497 line.startsWith( "#dest" ) ||
499 line.startsWith( "#arch" ) || 498 line.startsWith( "#arch" ) ||
500 line.startsWith( "#option" ) ) 499 line.startsWith( "#option" ) )
501 { 500 {
502 int pos = line.find( ' ', 1 ); 501 int pos = line.find( ' ', 1 );
503 502
504 // Type 503 // Type
505 QString typeStr = line.left( pos ); 504 QString typeStr = line.left( pos );
506 OConfItem::Type type; 505 OConfItem::Type type;
507 if ( typeStr == "src" || typeStr == "#src" ) 506 if ( typeStr == "src" || typeStr == "#src" )
508 type = OConfItem::Source; 507 type = OConfItem::Source;
509 else if ( typeStr == "dest" || typeStr == "#dest" ) 508 else if ( typeStr == "dest" || typeStr == "#dest" )
510 type = OConfItem::Destination; 509 type = OConfItem::Destination;
511 else if ( typeStr == "option" || typeStr == "#option" ) 510 else if ( typeStr == "option" || typeStr == "#option" )
512 type = OConfItem::Option; 511 type = OConfItem::Option;
513 else if ( typeStr == "arch" || typeStr == "#arch" ) 512 else if ( typeStr == "arch" || typeStr == "#arch" )
514 type = OConfItem::Arch; 513 type = OConfItem::Arch;
515 else 514 else
516 type = OConfItem::NotDefined; 515 type = OConfItem::NotDefined;
517 ++pos; 516 ++pos;
518 int endpos = line.find( ' ', pos ); 517 int endpos = line.find( ' ', pos );
519 518
520 // Name 519 // Name
521 QString name = line.mid( pos, endpos - pos ); 520 QString name = line.mid( pos, endpos - pos );
522 521
523 // Value 522 // Value
524 QString value = ""; 523 QString value = "";
525 if ( endpos > -1 ) 524 if ( endpos > -1 )
526 value = line.right( line.length() - endpos - 1 ); 525 value = line.right( line.length() - endpos - 1 );
527 526
528 // Active 527 // Active
529 bool active = !line.startsWith( "#" ); 528 bool active = !line.startsWith( "#" );
530 529
531 // Add to list 530 // Add to list
532 m_confInfo->append( new OConfItem( absFile, type, name, value, active ) ); 531 m_confInfo->append( new OConfItem( type, name, value, active ) );
533 } 532 }
534 } 533 }
535 } 534 }
536 535
537 f.close(); 536 f.close();
538 } 537 }
539 } 538 }
540 } 539 }
541 540
542 // Load Ipkg execution options from application configuration file 541 // Load Ipkg execution options from application configuration file
543 if ( m_config ) 542 if ( m_config )
544 { 543 {
545 m_config->setGroup( "Ipkg" ); 544 m_config->setGroup( "Ipkg" );
546 m_ipkgExecOptions = m_config->readNumEntry( "ExecOptions", m_ipkgExecOptions ); 545 m_ipkgExecOptions = m_config->readNumEntry( "ExecOptions", m_ipkgExecOptions );
547 m_ipkgExecVerbosity = m_config->readNumEntry( "Verbosity", m_ipkgExecVerbosity ); 546 m_ipkgExecVerbosity = m_config->readNumEntry( "Verbosity", m_ipkgExecVerbosity );
548 } 547 }
549} 548}
550 549
551OConfItemList *OIpkg::filterConfItems( OConfItem::Type typefilter ) 550OConfItemList *OIpkg::filterConfItems( OConfItem::Type typefilter )
552{ 551{
553 // Load Ipkg configuration info if not already cached 552 // Load Ipkg configuration info if not already cached
554 if ( !m_confInfo ) 553 if ( !m_confInfo )
555 loadConfiguration(); 554 loadConfiguration();
556 555
557 // Build new server list (caller is responsible for deleting) 556 // Build new server list (caller is responsible for deleting)
558 OConfItemList *sl = new OConfItemList; 557 OConfItemList *sl = new OConfItemList;
559 558
560 // If typefilter is empty, retrieve all items 559 // If typefilter is empty, retrieve all items
561 bool retrieveAll = ( typefilter == OConfItem::NotDefined ); 560 bool retrieveAll = ( typefilter == OConfItem::NotDefined );
562 561
563 // Parse configuration info for servers 562 // Parse configuration info for servers
564 OConfItemListIterator it( *m_confInfo ); 563 OConfItemListIterator it( *m_confInfo );
565 for ( ; it.current(); ++it ) 564 for ( ; it.current(); ++it )
566 { 565 {
567 OConfItem *item = it.current(); 566 OConfItem *item = it.current();
568 if ( retrieveAll || item->type() == typefilter ) 567 if ( retrieveAll || item->type() == typefilter )
569 { 568 {
570 sl->append( item ); 569 sl->append( item );
571 } 570 }
572 } 571 }
573 572
574 return sl; 573 return sl;
575} 574}
diff --git a/noncore/settings/packagemanager/oipkg.h b/noncore/settings/packagemanager/oipkg.h
index ea126cf..b8a859a 100644
--- a/noncore/settings/packagemanager/oipkg.h
+++ b/noncore/settings/packagemanager/oipkg.h
@@ -1,105 +1,105 @@
1/* 1/*
2                This file is part of the Opie Project 2                This file is part of the Opie Project
3 3
4              Copyright (c) 2003 Dan Williams <drw@handhelds.org> 4              Copyright (c) 2003 Dan Williams <drw@handhelds.org>
5 =. 5 =.
6 .=l. 6 .=l.
7           .>+-= 7           .>+-=
8 _;:,     .>    :=|. This program is free software; you can 8 _;:,     .>    :=|. This program is free software; you can
9.> <`_,   >  .   <= redistribute it and/or modify it under 9.> <`_,   >  .   <= redistribute it and/or modify it under
10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 10:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
11.="- .-=="i,     .._ License as published by the Free Software 11.="- .-=="i,     .._ License as published by the Free Software
12 - .   .-<_>     .<> Foundation; either version 2 of the License, 12 - .   .-<_>     .<> Foundation; either version 2 of the License,
13     ._= =}       : or (at your option) any later version. 13     ._= =}       : or (at your option) any later version.
14    .%`+i>       _;_. 14    .%`+i>       _;_.
15    .i_,=:_.      -<s. This program is distributed in the hope that 15    .i_,=:_.      -<s. This program is distributed in the hope that
16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 16     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
17    : ..    .:,     . . . without even the implied warranty of 17    : ..    .:,     . . . without even the implied warranty of
18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 18    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 19  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
20..}^=.=       =       ; Library General Public License for more 20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 21++=   -.     .`     .: details.
22 :     =  ...= . :.=- 22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32#ifndef OIPKG_H 32#ifndef OIPKG_H
33#define OIPKG_H 33#define OIPKG_H
34 34
35extern "C" { 35#include "oconfitem.h"
36#include <libipkg.h> 36#include "opackage.h"
37};
38
39#include <qobject.h>
40 37
41#include <qpe/config.h> 38#include <qpe/config.h>
42 39
43#include "oconfitem.h" 40#include <qobject.h>
44#include "opackage.h" 41
42extern "C" {
43#include <libipkg.h>
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 = 0x0, QObject *parent = 0x0, const char *name = 0x0 );
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 bool executeCommand( OPackage::Command command = OPackage::NotDefined, QStringList *parameters = 0x0, 80 bool executeCommand( OPackage::Command command = OPackage::NotDefined, QStringList *parameters = 0x0,
81 const QString &destination = QString::null, const QObject *receiver = 0x0, 81 const QString &destination = QString::null, const QObject *receiver = 0x0,
82 const char *slotOutput = 0x0, bool rawOutput = true ); 82 const char *slotOutput = 0x0, bool rawOutput = true );
83 void abortCommand(); 83 void abortCommand();
84 84
85 void ipkgMessage( char *msg ); 85 void ipkgMessage( char *msg );
86 void ipkgStatus( char *status ); 86 void ipkgStatus( char *status );
87 void ipkgList( char *filelist ); 87 void ipkgList( char *filelist );
88 88
89private: 89private:
90 Config *m_config; // Pointer to application configuration file 90 Config *m_config; // Pointer to application configuration file
91 args_t m_ipkgArgs; // libipkg configuration arguments 91 args_t m_ipkgArgs; // libipkg configuration arguments
92 OConfItemList *m_confInfo; // Contains info from all Ipkg configuration files 92 OConfItemList *m_confInfo; // Contains info from all Ipkg configuration files
93 int m_ipkgExecOptions; // Bit-mapped flags for Ipkg execution options 93 int m_ipkgExecOptions; // Bit-mapped flags for Ipkg execution options
94 int m_ipkgExecVerbosity; // Ipkg execution verbosity level 94 int m_ipkgExecVerbosity; // Ipkg execution verbosity level
95 95
96 void loadConfiguration(); 96 void loadConfiguration();
97 OConfItemList *filterConfItems( OConfItem::Type typefilter = OConfItem::NotDefined ); 97 OConfItemList *filterConfItems( OConfItem::Type typefilter = OConfItem::NotDefined );
98 98
99signals: 99signals:
100 void signalIpkgMessage( char *msg ); 100 void signalIpkgMessage( char *msg );
101 void signalIpkgStatus( char *status ); 101 void signalIpkgStatus( char *status );
102 void signalIpkgList( char *filelist ); 102 void signalIpkgList( char *filelist );
103}; 103};
104 104
105#endif 105#endif
diff --git a/noncore/settings/packagemanager/oipkgconfigdlg.cpp b/noncore/settings/packagemanager/oipkgconfigdlg.cpp
index d134651..7941ab8 100644
--- a/noncore/settings/packagemanager/oipkgconfigdlg.cpp
+++ b/noncore/settings/packagemanager/oipkgconfigdlg.cpp
@@ -1,629 +1,628 @@
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 <qpe/resource.h>
35
34#include <qcheckbox.h> 36#include <qcheckbox.h>
35#include <qcombobox.h> 37#include <qcombobox.h>
36#include <qgroupbox.h> 38#include <qgroupbox.h>
37#include <qlabel.h> 39#include <qlabel.h>
38#include <qlineedit.h> 40#include <qlineedit.h>
39#include <qlistbox.h> 41#include <qlistbox.h>
40#include <qpushbutton.h> 42#include <qpushbutton.h>
41#include <qscrollview.h> 43#include <qscrollview.h>
42#include <qwhatsthis.h> 44#include <qwhatsthis.h>
43 45
44#include <qpe/resource.h>
45
46using namespace Opie::Ui;
47OIpkgConfigDlg::OIpkgConfigDlg( OIpkg *ipkg, bool installOptions, QWidget *parent ) 46OIpkgConfigDlg::OIpkgConfigDlg( OIpkg *ipkg, bool installOptions, QWidget *parent )
48 : QDialog( parent, QString::null, true, WStyle_ContextHelp ) 47 : QDialog( parent, QString::null, true, WStyle_ContextHelp )
49 , m_ipkg( ipkg ) 48 , m_ipkg( ipkg )
50 , m_configs( 0x0 ) 49 , m_configs( 0x0 )
51 , m_installOptions( installOptions ) 50 , m_installOptions( installOptions )
52 , m_serverNew( false ) 51 , m_serverNew( false )
53 , m_serverCurrent( -1 ) 52 , m_serverCurrent( -1 )
54 , m_destNew( false ) 53 , m_destNew( false )
55 , m_destCurrent( -1 ) 54 , m_destCurrent( -1 )
56 , m_layout( this, 2, 4 ) 55 , m_layout( this, 2, 4 )
57 , m_tabWidget( this ) 56 , m_tabWidget( this )
58{ 57{
59 setCaption( tr( "Configuration" ) ); 58 setCaption( tr( "Configuration" ) );
60 59
61 // Initialize configuration widgets 60 // Initialize configuration widgets
62 if ( !installOptions ) 61 if ( !installOptions )
63 { 62 {
64 initServerWidget(); 63 initServerWidget();
65 initDestinationWidget(); 64 initDestinationWidget();
66 initProxyWidget(); 65 initProxyWidget();
67 } 66 }
68 initOptionsWidget(); 67 initOptionsWidget();
69 68
70 // Load configuration information 69 // Load configuration information
71 initData(); 70 initData();
72 71
73 // Setup tabs for all info 72 // Setup tabs for all info
74 m_layout.addWidget( &m_tabWidget ); 73 m_layout.addWidget( &m_tabWidget );
75 if ( !m_installOptions ) 74 if ( !m_installOptions )
76 { 75 {
77 m_tabWidget.addTab( m_serverWidget, "packagemanager/servertab", tr( "Servers" ) ); 76 m_tabWidget.addTab( m_serverWidget, "packagemanager/servertab", tr( "Servers" ) );
78 m_tabWidget.addTab( m_destWidget, "packagemanager/desttab", tr( "Destinations" ) ); 77 m_tabWidget.addTab( m_destWidget, "packagemanager/desttab", tr( "Destinations" ) );
79 m_tabWidget.addTab( m_proxyWidget, "packagemanager/proxytab", tr( "Proxies" ) ); 78 m_tabWidget.addTab( m_proxyWidget, "packagemanager/proxytab", tr( "Proxies" ) );
80 m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) ); 79 m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) );
81 m_tabWidget.setCurrentTab( tr( "Servers" ) ); 80 m_tabWidget.setCurrentTab( tr( "Servers" ) );
82 } 81 }
83 else 82 else
84 { 83 {
85 m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) ); 84 m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) );
86 } 85 }
87 86
88 //showMaximized(); 87 //showMaximized();
89} 88}
90 89
91void OIpkgConfigDlg::accept() 90void OIpkgConfigDlg::accept()
92{ 91{
93 // Save server, destination and proxy configuration 92 // Save server, destination and proxy configuration
94 if ( !m_installOptions ) 93 if ( !m_installOptions )
95 { 94 {
96 // Update proxy information before saving settings 95 // Update proxy information before saving settings
97 OConfItem *confItem = findConfItem( OConfItem::Option, "http_proxy" ); 96 OConfItem *confItem = findConfItem( OConfItem::Option, "http_proxy" );
98 if ( confItem ) 97 if ( confItem )
99 { 98 {
100 confItem->setValue( m_proxyHttpServer->text() ); 99 confItem->setValue( m_proxyHttpServer->text() );
101 confItem->setActive( m_proxyHttpActive->isChecked() ); 100 confItem->setActive( m_proxyHttpActive->isChecked() );
102 } 101 }
103 else 102 else
104 m_configs->append( new OConfItem( QString::null, OConfItem::Option, "http_proxy", 103 m_configs->append( new OConfItem( OConfItem::Option, "http_proxy",
105 m_proxyHttpServer->text(), m_proxyHttpActive->isChecked() ) ); 104 m_proxyHttpServer->text(), m_proxyHttpActive->isChecked() ) );
106 105
107 confItem = findConfItem( OConfItem::Option, "ftp_proxy" ); 106 confItem = findConfItem( OConfItem::Option, "ftp_proxy" );
108 if ( confItem ) 107 if ( confItem )
109 { 108 {
110 confItem->setValue( m_proxyFtpServer->text() ); 109 confItem->setValue( m_proxyFtpServer->text() );
111 confItem->setActive( m_proxyFtpActive->isChecked() ); 110 confItem->setActive( m_proxyFtpActive->isChecked() );
112 } 111 }
113 else 112 else
114 m_configs->append( new OConfItem( QString::null, OConfItem::Option, "ftp_proxy", 113 m_configs->append( new OConfItem( OConfItem::Option, "ftp_proxy",
115 m_proxyFtpServer->text(), m_proxyFtpActive->isChecked() ) ); 114 m_proxyFtpServer->text(), m_proxyFtpActive->isChecked() ) );
116 115
117 confItem = findConfItem( OConfItem::Option, "proxy_username" ); 116 confItem = findConfItem( OConfItem::Option, "proxy_username" );
118 if ( confItem ) 117 if ( confItem )
119 confItem->setValue( m_proxyUsername->text() ); 118 confItem->setValue( m_proxyUsername->text() );
120 else 119 else
121 m_configs->append( new OConfItem( QString::null, OConfItem::Option, "proxy_username", 120 m_configs->append( new OConfItem( OConfItem::Option, "proxy_username",
122 m_proxyUsername->text() ) ); 121 m_proxyUsername->text() ) );
123 122
124 confItem = findConfItem( OConfItem::Option, "proxy_password" ); 123 confItem = findConfItem( OConfItem::Option, "proxy_password" );
125 if ( confItem ) 124 if ( confItem )
126 confItem->setValue( m_proxyPassword->text() ); 125 confItem->setValue( m_proxyPassword->text() );
127 else 126 else
128 m_configs->append( new OConfItem( QString::null, OConfItem::Option, "proxy_password", 127 m_configs->append( new OConfItem( OConfItem::Option, "proxy_password",
129 m_proxyPassword->text() ) ); 128 m_proxyPassword->text() ) );
130 129
131 m_ipkg->setConfigItems( m_configs ); 130 m_ipkg->setConfigItems( m_configs );
132 } 131 }
133 132
134 // Save options configuration 133 // Save options configuration
135 int options = 0; 134 int options = 0;
136 if ( m_optForceDepends->isChecked() ) 135 if ( m_optForceDepends->isChecked() )
137 options |= FORCE_DEPENDS; 136 options |= FORCE_DEPENDS;
138 if ( m_optForceReinstall->isChecked() ) 137 if ( m_optForceReinstall->isChecked() )
139 options |= FORCE_REINSTALL; 138 options |= FORCE_REINSTALL;
140 if ( m_optForceRemove->isChecked() ) 139 if ( m_optForceRemove->isChecked() )
141 options |= FORCE_REMOVE; 140 options |= FORCE_REMOVE;
142 if ( m_optForceOverwrite->isChecked() ) 141 if ( m_optForceOverwrite->isChecked() )
143 options |= FORCE_OVERWRITE; 142 options |= FORCE_OVERWRITE;
144 m_ipkg->setIpkgExecOptions( options ); 143 m_ipkg->setIpkgExecOptions( options );
145 m_ipkg->setIpkgExecVerbosity( m_optVerboseIpkg->currentItem() ); 144 m_ipkg->setIpkgExecVerbosity( m_optVerboseIpkg->currentItem() );
146 145
147 QDialog::accept(); 146 QDialog::accept();
148} 147}
149 148
150void OIpkgConfigDlg::reject() 149void OIpkgConfigDlg::reject()
151{ 150{
152 if ( m_configs ) 151 if ( m_configs )
153 delete m_configs; 152 delete m_configs;
154} 153}
155 154
156void OIpkgConfigDlg::initServerWidget() 155void OIpkgConfigDlg::initServerWidget()
157{ 156{
158 m_serverWidget = new QWidget( this ); 157 m_serverWidget = new QWidget( this );
159 158
160 // Initialize UI 159 // Initialize UI
161 QVBoxLayout *vb = new QVBoxLayout( m_serverWidget ); 160 QVBoxLayout *vb = new QVBoxLayout( m_serverWidget );
162 QScrollView *sv = new QScrollView( m_serverWidget ); 161 QScrollView *sv = new QScrollView( m_serverWidget );
163 vb->addWidget( sv, 0, 0 ); 162 vb->addWidget( sv, 0, 0 );
164 sv->setResizePolicy( QScrollView::AutoOneFit ); 163 sv->setResizePolicy( QScrollView::AutoOneFit );
165 sv->setFrameStyle( QFrame::NoFrame ); 164 sv->setFrameStyle( QFrame::NoFrame );
166 QWidget *container = new QWidget( sv->viewport() ); 165 QWidget *container = new QWidget( sv->viewport() );
167 sv->addChild( container ); 166 sv->addChild( container );
168 QGridLayout *layout = new QGridLayout( container, 3, 2, 2, 4 ); 167 QGridLayout *layout = new QGridLayout( container, 3, 2, 2, 4 );
169 168
170 m_serverList = new QListBox( container ); 169 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." ) ); 170 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 ) ); 171 m_serverList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
173 connect( m_serverList, SIGNAL(highlighted(int)), this, SLOT(slotServerEdit(int)) ); 172 connect( m_serverList, SIGNAL(highlighted(int)), this, SLOT(slotServerEdit(int)) );
174 layout->addMultiCellWidget( m_serverList, 0, 0, 0, 1 ); 173 layout->addMultiCellWidget( m_serverList, 0, 0, 0, 1 );
175 174
176 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); 175 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." ) ); 176 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()) ); 177 connect( btn, SIGNAL(clicked()), this, SLOT(slotServerNew()) );
179 layout->addWidget( btn, 1, 0 ); 178 layout->addWidget( btn, 1, 0 );
180 179
181 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); 180 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container );
182 QWhatsThis::add( btn, tr( "Tap here to delete the entry selected above." ) ); 181 QWhatsThis::add( btn, tr( "Tap here to delete the entry selected above." ) );
183 connect( btn, SIGNAL(clicked()), this, SLOT(slotServerDelete()) ); 182 connect( btn, SIGNAL(clicked()), this, SLOT(slotServerDelete()) );
184 layout->addWidget( btn, 1, 1 ); 183 layout->addWidget( btn, 1, 1 );
185 184
186 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container ); 185 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container );
187 grpbox->layout()->setSpacing( 2 ); 186 grpbox->layout()->setSpacing( 2 );
188 grpbox->layout()->setMargin( 4 ); 187 grpbox->layout()->setMargin( 4 );
189 layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); 188 layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 );
190 189
191 QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); 190 QGridLayout *grplayout = new QGridLayout( grpbox->layout() );
192 191
193 QLabel *label = new QLabel( tr( "Name:" ), grpbox ); 192 QLabel *label = new QLabel( tr( "Name:" ), grpbox );
194 QWhatsThis::add( label, tr( "Enter the name of this entry here." ) ); 193 QWhatsThis::add( label, tr( "Enter the name of this entry here." ) );
195 grplayout->addWidget( label, 0, 0 ); 194 grplayout->addWidget( label, 0, 0 );
196 m_serverName = new QLineEdit( grpbox ); 195 m_serverName = new QLineEdit( grpbox );
197 QWhatsThis::add( m_serverName, tr( "Enter the name of this entry here." ) ); 196 QWhatsThis::add( m_serverName, tr( "Enter the name of this entry here." ) );
198 grplayout->addWidget( m_serverName, 0, 1 ); 197 grplayout->addWidget( m_serverName, 0, 1 );
199 198
200 label = new QLabel( tr( "Address:" ), grpbox ); 199 label = new QLabel( tr( "Address:" ), grpbox );
201 QWhatsThis::add( label, tr( "Enter the URL address of this entry here." ) ); 200 QWhatsThis::add( label, tr( "Enter the URL address of this entry here." ) );
202 grplayout->addWidget( label, 1, 0 ); 201 grplayout->addWidget( label, 1, 0 );
203 m_serverLocation = new QLineEdit( grpbox ); 202 m_serverLocation = new QLineEdit( grpbox );
204 QWhatsThis::add( m_serverLocation, tr( "Enter the URL address of this entry here." ) ); 203 QWhatsThis::add( m_serverLocation, tr( "Enter the URL address of this entry here." ) );
205 grplayout->addWidget( m_serverLocation, 1, 1 ); 204 grplayout->addWidget( m_serverLocation, 1, 1 );
206 205
207 m_serverActive = new QCheckBox( tr( "Active" ), grpbox ); 206 m_serverActive = new QCheckBox( tr( "Active" ), grpbox );
208 QWhatsThis::add( m_serverActive, tr( "Tap here to indicate whether this entry is active or not." ) ); 207 QWhatsThis::add( m_serverActive, tr( "Tap here to indicate whether this entry is active or not." ) );
209 grplayout->addMultiCellWidget( m_serverActive, 2, 2, 0, 1 ); 208 grplayout->addMultiCellWidget( m_serverActive, 2, 2, 0, 1 );
210 209
211 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); 210 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox );
212 QWhatsThis::add( btn, tr( "Tap here to update the entry's information." ) ); 211 QWhatsThis::add( btn, tr( "Tap here to update the entry's information." ) );
213 connect( btn, SIGNAL(clicked()), this, SLOT(slotServerUpdate()) ); 212 connect( btn, SIGNAL(clicked()), this, SLOT(slotServerUpdate()) );
214 grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); 213 grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 );
215} 214}
216 215
217void OIpkgConfigDlg::initDestinationWidget() 216void OIpkgConfigDlg::initDestinationWidget()
218{ 217{
219 m_destWidget = new QWidget( this ); 218 m_destWidget = new QWidget( this );
220 219
221 // Initialize UI 220 // Initialize UI
222 QVBoxLayout *vb = new QVBoxLayout( m_destWidget ); 221 QVBoxLayout *vb = new QVBoxLayout( m_destWidget );
223 QScrollView *sv = new QScrollView( m_destWidget ); 222 QScrollView *sv = new QScrollView( m_destWidget );
224 vb->addWidget( sv, 0, 0 ); 223 vb->addWidget( sv, 0, 0 );
225 sv->setResizePolicy( QScrollView::AutoOneFit ); 224 sv->setResizePolicy( QScrollView::AutoOneFit );
226 sv->setFrameStyle( QFrame::NoFrame ); 225 sv->setFrameStyle( QFrame::NoFrame );
227 QWidget *container = new QWidget( sv->viewport() ); 226 QWidget *container = new QWidget( sv->viewport() );
228 sv->addChild( container ); 227 sv->addChild( container );
229 QGridLayout *layout = new QGridLayout( container, 3, 2, 2, 4 ); 228 QGridLayout *layout = new QGridLayout( container, 3, 2, 2, 4 );
230 229
231 m_destList = new QListBox( container ); 230 m_destList = new QListBox( container );
232 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." ) ); 231 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." ) );
233 m_destList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) ); 232 m_destList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
234 connect( m_destList, SIGNAL(highlighted(int)), this, SLOT(slotDestEdit(int)) ); 233 connect( m_destList, SIGNAL(highlighted(int)), this, SLOT(slotDestEdit(int)) );
235 layout->addMultiCellWidget( m_destList, 0, 0, 0, 1 ); 234 layout->addMultiCellWidget( m_destList, 0, 0, 0, 1 );
236 235
237 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container ); 236 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container );
238 QWhatsThis::add( btn, tr( "Tap here to create a new entry. Fill in the fields below and then tap on Update." ) ); 237 QWhatsThis::add( btn, tr( "Tap here to create a new entry. Fill in the fields below and then tap on Update." ) );
239 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestNew()) ); 238 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestNew()) );
240 layout->addWidget( btn, 1, 0 ); 239 layout->addWidget( btn, 1, 0 );
241 240
242 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container ); 241 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container );
243 QWhatsThis::add( btn, tr( "Tap here to delete the entry selected above." ) ); 242 QWhatsThis::add( btn, tr( "Tap here to delete the entry selected above." ) );
244 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestDelete()) ); 243 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestDelete()) );
245 layout->addWidget( btn, 1, 1 ); 244 layout->addWidget( btn, 1, 1 );
246 245
247 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container ); 246 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container );
248 grpbox->layout()->setSpacing( 2 ); 247 grpbox->layout()->setSpacing( 2 );
249 grpbox->layout()->setMargin( 4 ); 248 grpbox->layout()->setMargin( 4 );
250 layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 ); 249 layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 );
251 250
252 QGridLayout *grplayout = new QGridLayout( grpbox->layout() ); 251 QGridLayout *grplayout = new QGridLayout( grpbox->layout() );
253 252
254 QLabel *label = new QLabel( tr( "Name:" ), grpbox ); 253 QLabel *label = new QLabel( tr( "Name:" ), grpbox );
255 QWhatsThis::add( label, tr( "Enter the name of this entry here." ) ); 254 QWhatsThis::add( label, tr( "Enter the name of this entry here." ) );
256 grplayout->addWidget( label, 0, 0 ); 255 grplayout->addWidget( label, 0, 0 );
257 m_destName = new QLineEdit( grpbox ); 256 m_destName = new QLineEdit( grpbox );
258 QWhatsThis::add( m_destName, tr( "Enter the name of this entry here." ) ); 257 QWhatsThis::add( m_destName, tr( "Enter the name of this entry here." ) );
259 grplayout->addWidget( m_destName, 0, 1 ); 258 grplayout->addWidget( m_destName, 0, 1 );
260 259
261 label = new QLabel( tr( "Location:" ), grpbox ); 260 label = new QLabel( tr( "Location:" ), grpbox );
262 QWhatsThis::add( label, tr( "Enter the absolute directory path of this entry here." ) ); 261 QWhatsThis::add( label, tr( "Enter the absolute directory path of this entry here." ) );
263 grplayout->addWidget( label, 1, 0 ); 262 grplayout->addWidget( label, 1, 0 );
264 m_destLocation = new QLineEdit( grpbox ); 263 m_destLocation = new QLineEdit( grpbox );
265 QWhatsThis::add( m_destLocation, tr( "Enter the absolute directory path of this entry here." ) ); 264 QWhatsThis::add( m_destLocation, tr( "Enter the absolute directory path of this entry here." ) );
266 grplayout->addWidget( m_destLocation, 1, 1 ); 265 grplayout->addWidget( m_destLocation, 1, 1 );
267 266
268 m_destActive = new QCheckBox( tr( "Active" ), grpbox ); 267 m_destActive = new QCheckBox( tr( "Active" ), grpbox );
269 QWhatsThis::add( m_destActive, tr( "Tap here to indicate whether this entry is active or not." ) ); 268 QWhatsThis::add( m_destActive, tr( "Tap here to indicate whether this entry is active or not." ) );
270 grplayout->addMultiCellWidget( m_destActive, 2, 2, 0, 1 ); 269 grplayout->addMultiCellWidget( m_destActive, 2, 2, 0, 1 );
271 270
272 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox ); 271 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox );
273 QWhatsThis::add( btn, tr( "Tap here to update the entry's information." ) ); 272 QWhatsThis::add( btn, tr( "Tap here to update the entry's information." ) );
274 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestUpdate()) ); 273 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestUpdate()) );
275 grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 ); 274 grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 );
276} 275}
277 276
278void OIpkgConfigDlg::initProxyWidget() 277void OIpkgConfigDlg::initProxyWidget()
279{ 278{
280 m_proxyWidget = new QWidget( this ); 279 m_proxyWidget = new QWidget( this );
281 280
282 // Initialize UI 281 // Initialize UI
283 QVBoxLayout *vb = new QVBoxLayout( m_proxyWidget ); 282 QVBoxLayout *vb = new QVBoxLayout( m_proxyWidget );
284 QScrollView *sv = new QScrollView( m_proxyWidget ); 283 QScrollView *sv = new QScrollView( m_proxyWidget );
285 vb->addWidget( sv, 0, 0 ); 284 vb->addWidget( sv, 0, 0 );
286 sv->setResizePolicy( QScrollView::AutoOneFit ); 285 sv->setResizePolicy( QScrollView::AutoOneFit );
287 sv->setFrameStyle( QFrame::NoFrame ); 286 sv->setFrameStyle( QFrame::NoFrame );
288 QWidget *container = new QWidget( sv->viewport() ); 287 QWidget *container = new QWidget( sv->viewport() );
289 sv->addChild( container ); 288 sv->addChild( container );
290 QGridLayout *layout = new QGridLayout( container, 4, 2, 2, 4 ); 289 QGridLayout *layout = new QGridLayout( container, 4, 2, 2, 4 );
291 290
292 // HTTP proxy server configuration 291 // HTTP proxy server configuration
293 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "HTTP Proxy" ), container ); 292 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "HTTP Proxy" ), container );
294 grpbox->layout()->setSpacing( 2 ); 293 grpbox->layout()->setSpacing( 2 );
295 grpbox->layout()->setMargin( 4 ); 294 grpbox->layout()->setMargin( 4 );
296 layout->addMultiCellWidget( grpbox, 0, 0, 0, 1 ); 295 layout->addMultiCellWidget( grpbox, 0, 0, 0, 1 );
297 QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); 296 QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() );
298 m_proxyHttpServer = new QLineEdit( grpbox ); 297 m_proxyHttpServer = new QLineEdit( grpbox );
299 QWhatsThis::add( m_proxyHttpServer, tr( "Enter the URL address of the HTTP proxy server here." ) ); 298 QWhatsThis::add( m_proxyHttpServer, tr( "Enter the URL address of the HTTP proxy server here." ) );
300 grplayout->addWidget( m_proxyHttpServer ); 299 grplayout->addWidget( m_proxyHttpServer );
301 m_proxyHttpActive = new QCheckBox( tr( "Enabled" ), grpbox ); 300 m_proxyHttpActive = new QCheckBox( tr( "Enabled" ), grpbox );
302 QWhatsThis::add( m_proxyHttpActive, tr( "Tap here to enable or disable the HTTP proxy server." ) ); 301 QWhatsThis::add( m_proxyHttpActive, tr( "Tap here to enable or disable the HTTP proxy server." ) );
303 grplayout->addWidget( m_proxyHttpActive ); 302 grplayout->addWidget( m_proxyHttpActive );
304 303
305 // FTP proxy server configuration 304 // FTP proxy server configuration
306 grpbox = new QGroupBox( 0, Qt::Vertical, tr( "FTP Proxy" ), container ); 305 grpbox = new QGroupBox( 0, Qt::Vertical, tr( "FTP Proxy" ), container );
307 grpbox->layout()->setSpacing( 2 ); 306 grpbox->layout()->setSpacing( 2 );
308 grpbox->layout()->setMargin( 4 ); 307 grpbox->layout()->setMargin( 4 );
309 layout->addMultiCellWidget( grpbox, 1, 1, 0, 1 ); 308 layout->addMultiCellWidget( grpbox, 1, 1, 0, 1 );
310 grplayout = new QVBoxLayout( grpbox->layout() ); 309 grplayout = new QVBoxLayout( grpbox->layout() );
311 m_proxyFtpServer = new QLineEdit( grpbox ); 310 m_proxyFtpServer = new QLineEdit( grpbox );
312 QWhatsThis::add( m_proxyFtpServer, tr( "Enter the URL address of the FTP proxy server here." ) ); 311 QWhatsThis::add( m_proxyFtpServer, tr( "Enter the URL address of the FTP proxy server here." ) );
313 grplayout->addWidget( m_proxyFtpServer ); 312 grplayout->addWidget( m_proxyFtpServer );
314 m_proxyFtpActive = new QCheckBox( tr( "Enabled" ), grpbox ); 313 m_proxyFtpActive = new QCheckBox( tr( "Enabled" ), grpbox );
315 QWhatsThis::add( m_proxyFtpActive, tr( "Tap here to enable or disable the FTP proxy server." ) ); 314 QWhatsThis::add( m_proxyFtpActive, tr( "Tap here to enable or disable the FTP proxy server." ) );
316 grplayout->addWidget( m_proxyFtpActive ); 315 grplayout->addWidget( m_proxyFtpActive );
317 316
318 // Proxy server username and password configuration 317 // Proxy server username and password configuration
319 QLabel *label = new QLabel( tr( "Username:" ), container ); 318 QLabel *label = new QLabel( tr( "Username:" ), container );
320 QWhatsThis::add( label, tr( "Enter the username for the proxy servers here." ) ); 319 QWhatsThis::add( label, tr( "Enter the username for the proxy servers here." ) );
321 layout->addWidget( label, 2, 0 ); 320 layout->addWidget( label, 2, 0 );
322 m_proxyUsername = new QLineEdit( container ); 321 m_proxyUsername = new QLineEdit( container );
323 QWhatsThis::add( m_proxyUsername, tr( "Enter the username for the proxy servers here." ) ); 322 QWhatsThis::add( m_proxyUsername, tr( "Enter the username for the proxy servers here." ) );
324 layout->addWidget( m_proxyUsername, 2, 1 ); 323 layout->addWidget( m_proxyUsername, 2, 1 );
325 324
326 label = new QLabel( tr( "Password:" ), container ); 325 label = new QLabel( tr( "Password:" ), container );
327 QWhatsThis::add( label, tr( "Enter the password for the proxy servers here." ) ); 326 QWhatsThis::add( label, tr( "Enter the password for the proxy servers here." ) );
328 layout->addWidget( label, 3, 0 ); 327 layout->addWidget( label, 3, 0 );
329 m_proxyPassword = new QLineEdit( container ); 328 m_proxyPassword = new QLineEdit( container );
330 QWhatsThis::add( m_proxyPassword, tr( "Enter the password for the proxy servers here." ) ); 329 QWhatsThis::add( m_proxyPassword, tr( "Enter the password for the proxy servers here." ) );
331 layout->addWidget( m_proxyPassword, 3, 1 ); 330 layout->addWidget( m_proxyPassword, 3, 1 );
332} 331}
333 332
334void OIpkgConfigDlg::initOptionsWidget() 333void OIpkgConfigDlg::initOptionsWidget()
335{ 334{
336 m_optionsWidget = new QWidget( this ); 335 m_optionsWidget = new QWidget( this );
337 336
338 // Initialize UI 337 // Initialize UI
339 QVBoxLayout *vb = new QVBoxLayout( m_optionsWidget ); 338 QVBoxLayout *vb = new QVBoxLayout( m_optionsWidget );
340 QScrollView *sv = new QScrollView( m_optionsWidget ); 339 QScrollView *sv = new QScrollView( m_optionsWidget );
341 vb->addWidget( sv, 0, 0 ); 340 vb->addWidget( sv, 0, 0 );
342 sv->setResizePolicy( QScrollView::AutoOneFit ); 341 sv->setResizePolicy( QScrollView::AutoOneFit );
343 sv->setFrameStyle( QFrame::NoFrame ); 342 sv->setFrameStyle( QFrame::NoFrame );
344 QWidget *container = new QWidget( sv->viewport() ); 343 QWidget *container = new QWidget( sv->viewport() );
345 sv->addChild( container ); 344 sv->addChild( container );
346 QVBoxLayout *layout = new QVBoxLayout( container, 2, 4 ); 345 QVBoxLayout *layout = new QVBoxLayout( container, 2, 4 );
347 346
348 m_optForceDepends = new QCheckBox( tr( "Force Depends" ), container ); 347 m_optForceDepends = new QCheckBox( tr( "Force Depends" ), container );
349 QWhatsThis::add( m_optForceDepends, tr( "Tap here to enable or disable the '-force-depends' option for Ipkg." ) ); 348 QWhatsThis::add( m_optForceDepends, tr( "Tap here to enable or disable the '-force-depends' option for Ipkg." ) );
350 layout->addWidget( m_optForceDepends ); 349 layout->addWidget( m_optForceDepends );
351 350
352 m_optForceReinstall = new QCheckBox( tr( "Force Reinstall" ), container ); 351 m_optForceReinstall = new QCheckBox( tr( "Force Reinstall" ), container );
353 QWhatsThis::add( m_optForceReinstall, tr( "Tap here to enable or disable the '-force-reinstall' option for Ipkg." ) ); 352 QWhatsThis::add( m_optForceReinstall, tr( "Tap here to enable or disable the '-force-reinstall' option for Ipkg." ) );
354 layout->addWidget( m_optForceReinstall ); 353 layout->addWidget( m_optForceReinstall );
355 354
356 m_optForceRemove = new QCheckBox( tr( "Force Remove" ), container ); 355 m_optForceRemove = new QCheckBox( tr( "Force Remove" ), container );
357 QWhatsThis::add( m_optForceRemove, tr( "Tap here to enable or disable the '-force-removal-of-dependent-packages' option for Ipkg." ) ); 356 QWhatsThis::add( m_optForceRemove, tr( "Tap here to enable or disable the '-force-removal-of-dependent-packages' option for Ipkg." ) );
358 layout->addWidget( m_optForceRemove ); 357 layout->addWidget( m_optForceRemove );
359 358
360 m_optForceOverwrite = new QCheckBox( tr( "Force Overwrite" ), container ); 359 m_optForceOverwrite = new QCheckBox( tr( "Force Overwrite" ), container );
361 QWhatsThis::add( m_optForceOverwrite, tr( "Tap here to enable or disable the '-force-overwrite' option for Ipkg." ) ); 360 QWhatsThis::add( m_optForceOverwrite, tr( "Tap here to enable or disable the '-force-overwrite' option for Ipkg." ) );
362 layout->addWidget( m_optForceOverwrite ); 361 layout->addWidget( m_optForceOverwrite );
363 362
364 QLabel *l = new QLabel( tr( "Information Level" ), container ); 363 QLabel *l = new QLabel( tr( "Information Level" ), container );
365 QWhatsThis::add( l, tr( "Select information level for Ipkg." ) ); 364 QWhatsThis::add( l, tr( "Select information level for Ipkg." ) );
366 layout->addWidget( l ); 365 layout->addWidget( l );
367 366
368 m_optVerboseIpkg = new QComboBox( container ); 367 m_optVerboseIpkg = new QComboBox( container );
369 QWhatsThis::add( m_optVerboseIpkg, tr( "Select information level for Ipkg." ) ); 368 QWhatsThis::add( m_optVerboseIpkg, tr( "Select information level for Ipkg." ) );
370 m_optVerboseIpkg->insertItem( tr( "Errors only" ) ); 369 m_optVerboseIpkg->insertItem( tr( "Errors only" ) );
371 m_optVerboseIpkg->insertItem( tr( "Normal messages" ) ); 370 m_optVerboseIpkg->insertItem( tr( "Normal messages" ) );
372 m_optVerboseIpkg->insertItem( tr( "Informative messages" ) ); 371 m_optVerboseIpkg->insertItem( tr( "Informative messages" ) );
373 m_optVerboseIpkg->insertItem( tr( "Troubleshooting output" ) ); 372 m_optVerboseIpkg->insertItem( tr( "Troubleshooting output" ) );
374 layout->addWidget( m_optVerboseIpkg ); 373 layout->addWidget( m_optVerboseIpkg );
375 374
376 layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); 375 layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ) );
377} 376}
378 377
379void OIpkgConfigDlg::initData() 378void OIpkgConfigDlg::initData()
380{ 379{
381 // Read ipkg configuration (server/destination/proxy) information 380 // Read ipkg configuration (server/destination/proxy) information
382 if ( m_ipkg && !m_installOptions ) 381 if ( m_ipkg && !m_installOptions )
383 { 382 {
384 m_configs = m_ipkg->configItems(); 383 m_configs = m_ipkg->configItems();
385 if ( m_configs ) 384 if ( m_configs )
386 { 385 {
387 for ( OConfItemListIterator configIt( *m_configs ); configIt.current(); ++configIt ) 386 for ( OConfItemListIterator configIt( *m_configs ); configIt.current(); ++configIt )
388 { 387 {
389 OConfItem *config = configIt.current(); 388 OConfItem *config = configIt.current();
390 389
391 // Add configuration item to the appropriate dialog controls 390 // Add configuration item to the appropriate dialog controls
392 if ( config ) 391 if ( config )
393 { 392 {
394 if ( config->type() == OConfItem::Source ) 393 if ( config->type() == OConfItem::Source )
395 { 394 {
396 m_serverList->insertItem( config->name() ); 395 m_serverList->insertItem( config->name() );
397 } 396 }
398 else if ( config->type() == OConfItem::Destination ) 397 else if ( config->type() == OConfItem::Destination )
399 { 398 {
400 m_destList->insertItem( config->name() ); 399 m_destList->insertItem( config->name() );
401 } 400 }
402 else if ( config->type() == OConfItem::Option ) 401 else if ( config->type() == OConfItem::Option )
403 { 402 {
404 if ( config->name() == "http_proxy" ) 403 if ( config->name() == "http_proxy" )
405 { 404 {
406 m_proxyHttpServer->setText( config->value() ); 405 m_proxyHttpServer->setText( config->value() );
407 m_proxyHttpActive->setChecked( config->active() ); 406 m_proxyHttpActive->setChecked( config->active() );
408 } 407 }
409 else if ( config->name() == "ftp_proxy" ) 408 else if ( config->name() == "ftp_proxy" )
410 { 409 {
411 m_proxyFtpServer->setText( config->value() ); 410 m_proxyFtpServer->setText( config->value() );
412 m_proxyFtpActive->setChecked( config->active() ); 411 m_proxyFtpActive->setChecked( config->active() );
413 } 412 }
414 else if ( config->name() == "proxy_username" ) 413 else if ( config->name() == "proxy_username" )
415 { 414 {
416 m_proxyUsername->setText( config->value() ); 415 m_proxyUsername->setText( config->value() );
417 } 416 }
418 else if ( config->name() == "proxy_password" ) 417 else if ( config->name() == "proxy_password" )
419 { 418 {
420 m_proxyPassword->setText( config->value() ); 419 m_proxyPassword->setText( config->value() );
421 } 420 }
422 } 421 }
423 } 422 }
424 } 423 }
425 } 424 }
426 } 425 }
427 426
428 // Get Ipkg execution options 427 // Get Ipkg execution options
429 int options = m_ipkg->ipkgExecOptions(); 428 int options = m_ipkg->ipkgExecOptions();
430 if ( options & FORCE_DEPENDS ) 429 if ( options & FORCE_DEPENDS )
431 m_optForceDepends->setChecked( true ); 430 m_optForceDepends->setChecked( true );
432 if ( options & FORCE_REINSTALL ) 431 if ( options & FORCE_REINSTALL )
433 m_optForceReinstall->setChecked( true ); 432 m_optForceReinstall->setChecked( true );
434 if ( options & FORCE_REMOVE ) 433 if ( options & FORCE_REMOVE )
435 m_optForceRemove->setChecked( true ); 434 m_optForceRemove->setChecked( true );
436 if ( options & FORCE_OVERWRITE ) 435 if ( options & FORCE_OVERWRITE )
437 m_optForceOverwrite->setChecked( true ); 436 m_optForceOverwrite->setChecked( true );
438 437
439 m_optVerboseIpkg->setCurrentItem( m_ipkg->ipkgExecVerbosity() ); 438 m_optVerboseIpkg->setCurrentItem( m_ipkg->ipkgExecVerbosity() );
440} 439}
441 440
442OConfItem *OIpkgConfigDlg::findConfItem( OConfItem::Type type, const QString &name ) 441OConfItem *OIpkgConfigDlg::findConfItem( OConfItem::Type type, const QString &name )
443{ 442{
444 // Find selected server in list 443 // Find selected server in list
445 OConfItemListIterator configIt( *m_configs ); 444 OConfItemListIterator configIt( *m_configs );
446 OConfItem *config = 0x0; 445 OConfItem *config = 0x0;
447 for ( ; configIt.current(); ++configIt ) 446 for ( ; configIt.current(); ++configIt )
448 { 447 {
449 config = configIt.current(); 448 config = configIt.current();
450 if ( config->type() == type && config->name() == name ) 449 if ( config->type() == type && config->name() == name )
451 break; 450 break;
452 } 451 }
453 452
454 if ( config && config->type() == type && config->name() == name ) 453 if ( config && config->type() == type && config->name() == name )
455 return config; 454 return config;
456 455
457 return 0x0; 456 return 0x0;
458} 457}
459 458
460void OIpkgConfigDlg::slotServerEdit( int index ) 459void OIpkgConfigDlg::slotServerEdit( int index )
461{ 460{
462 m_serverNew = false; 461 m_serverNew = false;
463 m_serverCurrent = index; 462 m_serverCurrent = index;
464 463
465 // Find selected server in list 464 // Find selected server in list
466 OConfItem *server = findConfItem( OConfItem::Source, m_serverList->currentText() ); 465 OConfItem *server = findConfItem( OConfItem::Source, m_serverList->currentText() );
467 466
468 // Display server details 467 // Display server details
469 if ( server ) 468 if ( server )
470 { 469 {
471 m_serverCurrName = server->name(); 470 m_serverCurrName = server->name();
472 m_serverName->setText( server->name() ); 471 m_serverName->setText( server->name() );
473 m_serverLocation->setText( server->value() ); 472 m_serverLocation->setText( server->value() );
474 m_serverActive->setChecked( server->active() ); 473 m_serverActive->setChecked( server->active() );
475 m_serverName->setFocus(); 474 m_serverName->setFocus();
476 } 475 }
477} 476}
478 477
479void OIpkgConfigDlg::slotServerNew() 478void OIpkgConfigDlg::slotServerNew()
480{ 479{
481 m_serverNew = true; 480 m_serverNew = true;
482 481
483 m_serverName->setText( QString::null ); 482 m_serverName->setText( QString::null );
484 m_serverLocation->setText( QString::null ); 483 m_serverLocation->setText( QString::null );
485 m_serverActive->setChecked( true ); 484 m_serverActive->setChecked( true );
486 m_serverName->setFocus(); 485 m_serverName->setFocus();
487} 486}
488 487
489void OIpkgConfigDlg::slotServerDelete() 488void OIpkgConfigDlg::slotServerDelete()
490{ 489{
491 // Find selected server in list 490 // Find selected server in list
492 OConfItem *server = findConfItem( OConfItem::Source, m_serverList->currentText() ); 491 OConfItem *server = findConfItem( OConfItem::Source, m_serverList->currentText() );
493 492
494 // Delete server 493 // Delete server
495 if ( server ) 494 if ( server )
496 { 495 {
497 m_configs->removeRef( server ); 496 m_configs->removeRef( server );
498 m_serverList->removeItem( m_serverCurrent ); 497 m_serverList->removeItem( m_serverCurrent );
499 } 498 }
500} 499}
501 500
502void OIpkgConfigDlg::slotServerUpdate() 501void OIpkgConfigDlg::slotServerUpdate()
503{ 502{
504 QString newName = m_serverName->text(); 503 QString newName = m_serverName->text();
505 504
506 // Convert any spaces to underscores 505 // Convert any spaces to underscores
507 newName.replace( QRegExp( " " ), "_" ); 506 newName.replace( QRegExp( " " ), "_" );
508 507
509 if ( !m_serverNew ) 508 if ( !m_serverNew )
510 { 509 {
511 // Find selected server in list 510 // Find selected server in list
512 OConfItem *server = findConfItem( OConfItem::Source, m_serverCurrName ); 511 OConfItem *server = findConfItem( OConfItem::Source, m_serverCurrName );
513 512
514 // Delete server 513 // Delete server
515 if ( server ) 514 if ( server )
516 { 515 {
517 // Update url 516 // Update url
518 server->setValue( m_serverLocation->text() ); 517 server->setValue( m_serverLocation->text() );
519 server->setActive( m_serverActive->isChecked() ); 518 server->setActive( m_serverActive->isChecked() );
520 519
521 // Check if server name has changed, if it has then we need to replace the key in the map 520 // Check if server name has changed, if it has then we need to replace the key in the map
522 if ( m_serverCurrName != newName ) 521 if ( m_serverCurrName != newName )
523 { 522 {
524 // Update server name 523 // Update server name
525 server->setName( newName ); 524 server->setName( newName );
526 525
527 // Update list box 526 // Update list box
528 m_serverList->changeItem( newName, m_serverCurrent ); 527 m_serverList->changeItem( newName, m_serverCurrent );
529 } 528 }
530 } 529 }
531 } 530 }
532 else 531 else
533 { 532 {
534 // Add new destination to configuration list 533 // Add new destination to configuration list
535 m_configs->append( new OConfItem( QString::null, OConfItem::Source, newName, 534 m_configs->append( new OConfItem( OConfItem::Source, newName,
536 m_serverLocation->text(), m_serverActive->isChecked() ) ); 535 m_serverLocation->text(), m_serverActive->isChecked() ) );
537 m_configs->sort(); 536 m_configs->sort();
538 537
539 m_serverList->insertItem( newName ); 538 m_serverList->insertItem( newName );
540 m_serverList->setCurrentItem( m_serverList->count() ); 539 m_serverList->setCurrentItem( m_serverList->count() );
541 m_serverNew = false; 540 m_serverNew = false;
542 m_serverList->insertItem( newName ); 541 m_serverList->insertItem( newName );
543 } 542 }
544} 543}
545 544
546void OIpkgConfigDlg::slotDestEdit( int index ) 545void OIpkgConfigDlg::slotDestEdit( int index )
547{ 546{
548 m_destNew = false; 547 m_destNew = false;
549 m_destCurrent = index; 548 m_destCurrent = index;
550 549
551 // Find selected destination in list 550 // Find selected destination in list
552 OConfItem *destination = findConfItem( OConfItem::Destination, m_destList->currentText() ); 551 OConfItem *destination = findConfItem( OConfItem::Destination, m_destList->currentText() );
553 552
554 // Display destination details 553 // Display destination details
555 if ( destination ) 554 if ( destination )
556 { 555 {
557 m_destCurrName = destination->name(); 556 m_destCurrName = destination->name();
558 m_destName->setText( destination->name() ); 557 m_destName->setText( destination->name() );
559 m_destLocation->setText( destination->value() ); 558 m_destLocation->setText( destination->value() );
560 m_destActive->setChecked( destination->active() ); 559 m_destActive->setChecked( destination->active() );
561 m_destName->setFocus(); 560 m_destName->setFocus();
562 } 561 }
563} 562}
564 563
565void OIpkgConfigDlg::slotDestNew() 564void OIpkgConfigDlg::slotDestNew()
566{ 565{
567 m_destNew = true; 566 m_destNew = true;
568 567
569 m_destName->setText( QString::null ); 568 m_destName->setText( QString::null );
570 m_destLocation->setText( QString::null ); 569 m_destLocation->setText( QString::null );
571 m_destActive->setChecked( true ); 570 m_destActive->setChecked( true );
572 m_destName->setFocus(); 571 m_destName->setFocus();
573} 572}
574 573
575void OIpkgConfigDlg::slotDestDelete() 574void OIpkgConfigDlg::slotDestDelete()
576{ 575{
577 // Find selected destination in list 576 // Find selected destination in list
578 OConfItem *destination = findConfItem( OConfItem::Destination, m_destList->currentText() ); 577 OConfItem *destination = findConfItem( OConfItem::Destination, m_destList->currentText() );
579 578
580 // Delete destination 579 // Delete destination
581 if ( destination ) 580 if ( destination )
582 { 581 {
583 m_configs->removeRef( destination ); 582 m_configs->removeRef( destination );
584 m_destList->removeItem( m_destCurrent ); 583 m_destList->removeItem( m_destCurrent );
585 } 584 }
586} 585}
587 586
588void OIpkgConfigDlg::slotDestUpdate() 587void OIpkgConfigDlg::slotDestUpdate()
589{ 588{
590 QString newName = m_destName->text(); 589 QString newName = m_destName->text();
591 590
592 // Convert any spaces to underscores 591 // Convert any spaces to underscores
593 newName.replace( QRegExp( " " ), "_" ); 592 newName.replace( QRegExp( " " ), "_" );
594 593
595 if ( !m_destNew ) 594 if ( !m_destNew )
596 { 595 {
597 // Find selected destination in list 596 // Find selected destination in list
598 OConfItem *destination = findConfItem( OConfItem::Destination, m_destCurrName ); 597 OConfItem *destination = findConfItem( OConfItem::Destination, m_destCurrName );
599 598
600 // Display destination details 599 // Display destination details
601 if ( destination ) 600 if ( destination )
602 { 601 {
603 // Update url 602 // Update url
604 destination->setValue( m_destLocation->text() ); 603 destination->setValue( m_destLocation->text() );
605 destination->setActive( m_destActive->isChecked() ); 604 destination->setActive( m_destActive->isChecked() );
606 605
607 // Check if destination name has changed, if it has then we need to replace the key in the map 606 // Check if destination name has changed, if it has then we need to replace the key in the map
608 if ( m_destCurrName != newName ) 607 if ( m_destCurrName != newName )
609 { 608 {
610 // Update destination name 609 // Update destination name
611 destination->setName( newName ); 610 destination->setName( newName );
612 611
613 // Update list box 612 // Update list box
614 m_destList->changeItem( newName, m_destCurrent ); 613 m_destList->changeItem( newName, m_destCurrent );
615 } 614 }
616 } 615 }
617 } 616 }
618 else 617 else
619 { 618 {
620 // Add new destination to configuration list 619 // Add new destination to configuration list
621 m_configs->append( new OConfItem( QString::null, OConfItem::Destination, newName, 620 m_configs->append( new OConfItem( OConfItem::Destination, newName,
622 m_destLocation->text(), m_destActive->isChecked() ) ); 621 m_destLocation->text(), m_destActive->isChecked() ) );
623 m_configs->sort(); 622 m_configs->sort();
624 623
625 m_destList->insertItem( newName ); 624 m_destList->insertItem( newName );
626 m_destList->setCurrentItem( m_destList->count() ); 625 m_destList->setCurrentItem( m_destList->count() );
627 m_destNew = false; 626 m_destNew = false;
628 } 627 }
629} 628}
diff --git a/noncore/settings/packagemanager/oipkgconfigdlg.h b/noncore/settings/packagemanager/oipkgconfigdlg.h
index 0aba898..800d94a 100644
--- a/noncore/settings/packagemanager/oipkgconfigdlg.h
+++ b/noncore/settings/packagemanager/oipkgconfigdlg.h
@@ -1,131 +1,131 @@
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>
37
36#include <qdialog.h> 38#include <qdialog.h>
37#include <qlayout.h> 39#include <qlayout.h>
38 40
39#include <opie2/otabwidget.h>
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;
47 47
48class OIpkgConfigDlg : public QDialog 48class OIpkgConfigDlg : public QDialog
49{ 49{
50 Q_OBJECT 50 Q_OBJECT
51 51
52public: 52public:
53 OIpkgConfigDlg( OIpkg *ipkg = 0x0, bool installOptions = false, QWidget *parent = 0x0 ); 53 OIpkgConfigDlg( OIpkg *ipkg = 0x0, bool installOptions = false, QWidget *parent = 0x0 );
54 54
55protected slots: 55protected slots:
56 void accept(); 56 void accept();
57 void reject(); 57 void reject();
58 58
59private: 59private:
60 OIpkg *m_ipkg; // Pointer to Ipkg class for retrieving/saving configuration options 60 OIpkg *m_ipkg; // Pointer to Ipkg class for retrieving/saving configuration options
61 OConfItemList *m_configs; // Local list of configuration items 61 OConfItemList *m_configs; // Local list of configuration items
62 62
63 bool m_installOptions; // If true, will only display the Options tab 63 bool m_installOptions; // If true, will only display the Options tab
64 64
65 // Server cached information 65 // Server cached information
66 bool m_serverNew; // Indicates if server information is for a new server 66 bool m_serverNew; // Indicates if server information is for a new server
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 QString m_serverCurrName; // Name of currently selected server in m_serverList 68 QString m_serverCurrName; // Name of currently selected server in m_serverList
69 69
70 // Destination cached information 70 // Destination cached information
71 bool m_destNew; // Indicates if destination information is for a new destination 71 bool m_destNew; // Indicates if destination information is for a new destination
72 int m_destCurrent; // Index of currently selected destination in m_destList 72 int m_destCurrent; // Index of currently selected destination in m_destList
73 QString m_destCurrName; // Name of currently selected destination in m_destList 73 QString m_destCurrName; // Name of currently selected destination in m_destList
74 74
75 // UI controls 75 // UI controls
76 QVBoxLayout m_layout; // Main dialog layout control 76 QVBoxLayout m_layout; // Main dialog layout control
77 Opie::Ui::OTabWidget m_tabWidget; // Main tab widget control 77 Opie::Ui::OTabWidget m_tabWidget; // Main tab widget control
78 QWidget *m_serverWidget; // Widget containing server configuration controls 78 QWidget *m_serverWidget; // Widget containing server configuration controls
79 QWidget *m_destWidget; // Widget containing destination configuration controls 79 QWidget *m_destWidget; // Widget containing destination configuration controls
80 QWidget *m_proxyWidget; // Widget containing proxy configuration controls 80 QWidget *m_proxyWidget; // Widget containing proxy configuration controls
81 QWidget *m_optionsWidget; // Widget containing ipkg execution configuration controls 81 QWidget *m_optionsWidget; // Widget containing ipkg execution configuration controls
82 82
83 // Server configuration UI controls 83 // Server configuration UI controls
84 QListBox *m_serverList; // Server list selection 84 QListBox *m_serverList; // Server list selection
85 QLineEdit *m_serverName; // Server name edit box 85 QLineEdit *m_serverName; // Server name edit box
86 QLineEdit *m_serverLocation; // Server location URL edit box 86 QLineEdit *m_serverLocation; // Server location URL edit box
87 QCheckBox *m_serverActive; // Activate server check box 87 QCheckBox *m_serverActive; // Activate server check box
88 88
89 // Destination configuration UI controls 89 // Destination configuration UI controls
90 QListBox *m_destList; // Destination list selection 90 QListBox *m_destList; // Destination list selection
91 QLineEdit *m_destName; // Destination name edit box 91 QLineEdit *m_destName; // Destination name edit box
92 QLineEdit *m_destLocation; // Destination location URL edit box 92 QLineEdit *m_destLocation; // Destination location URL edit box
93 QCheckBox *m_destActive; // Activate destination check box 93 QCheckBox *m_destActive; // Activate destination check box
94 94
95 // Proxy server configuration UI controls 95 // Proxy server configuration UI controls
96 QLineEdit *m_proxyHttpServer; // HTTP proxy server URL edit box 96 QLineEdit *m_proxyHttpServer; // HTTP proxy server URL edit box
97 QCheckBox *m_proxyHttpActive; // Activate HTTP proxy check box 97 QCheckBox *m_proxyHttpActive; // Activate HTTP proxy check box
98 QLineEdit *m_proxyFtpServer; // FTP proxy server edit box 98 QLineEdit *m_proxyFtpServer; // FTP proxy server edit box
99 QCheckBox *m_proxyFtpActive; // Activate FTP proxy check box 99 QCheckBox *m_proxyFtpActive; // Activate FTP proxy check box
100 QLineEdit *m_proxyUsername; // Proxy server username edit box 100 QLineEdit *m_proxyUsername; // Proxy server username edit box
101 QLineEdit *m_proxyPassword; // Proxy server password edit box 101 QLineEdit *m_proxyPassword; // Proxy server password edit box
102 102
103 // Options configuration UI controls 103 // Options configuration UI controls
104 QCheckBox *m_optForceDepends; // Force depends ipkg option checkbox 104 QCheckBox *m_optForceDepends; // Force depends ipkg option checkbox
105 QCheckBox *m_optForceReinstall; // Force reinstall ipkg option checkbox 105 QCheckBox *m_optForceReinstall; // Force reinstall ipkg option checkbox
106 QCheckBox *m_optForceRemove; // Force remove ipkg option checkbox 106 QCheckBox *m_optForceRemove; // Force remove ipkg option checkbox
107 QCheckBox *m_optForceOverwrite; // Force overwrite ipkg option checkbox 107 QCheckBox *m_optForceOverwrite; // Force overwrite ipkg option checkbox
108 QComboBox *m_optVerboseIpkg; // Ipkg verbosity option selection 108 QComboBox *m_optVerboseIpkg; // Ipkg verbosity option selection
109 109
110 void initServerWidget(); 110 void initServerWidget();
111 void initDestinationWidget(); 111 void initDestinationWidget();
112 void initProxyWidget(); 112 void initProxyWidget();
113 void initOptionsWidget(); 113 void initOptionsWidget();
114 114
115 void initData(); 115 void initData();
116 116
117 OConfItem *findConfItem( OConfItem::Type type = OConfItem::NotDefined, const QString &name = 0x0 ); 117 OConfItem *findConfItem( OConfItem::Type type = OConfItem::NotDefined, const QString &name = 0x0 );
118 118
119private slots: 119private slots:
120 void slotServerEdit( int index ); 120 void slotServerEdit( int index );
121 void slotServerNew(); 121 void slotServerNew();
122 void slotServerDelete(); 122 void slotServerDelete();
123 void slotServerUpdate(); 123 void slotServerUpdate();
124 124
125 void slotDestEdit( int index ); 125 void slotDestEdit( int index );
126 void slotDestNew(); 126 void slotDestNew();
127 void slotDestDelete(); 127 void slotDestDelete();
128 void slotDestUpdate(); 128 void slotDestUpdate();
129}; 129};
130 130
131#endif 131#endif
diff --git a/noncore/settings/packagemanager/opackagemanager.cpp b/noncore/settings/packagemanager/opackagemanager.cpp
index 3633e05..f75d3b3 100644
--- a/noncore/settings/packagemanager/opackagemanager.cpp
+++ b/noncore/settings/packagemanager/opackagemanager.cpp
@@ -1,412 +1,412 @@
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 <ctype.h> 32#include "opackagemanager.h"
33#include "oipkgconfigdlg.h"
33 34
34#include <qpe/qpeapplication.h> 35#include <qpe/qpeapplication.h>
35 36
36#include "opackagemanager.h" 37#include <ctype.h>
37#include "oipkgconfigdlg.h"
38 38
39OPackageManager::OPackageManager( Config *config, QObject *parent, const char *name ) 39OPackageManager::OPackageManager( Config *config, QObject *parent, const char *name )
40 : QObject( parent, name ) 40 : QObject( parent, name )
41 , m_config( config ) 41 , m_config( config )
42 , m_ipkg( m_config, this ) 42 , m_ipkg( m_config, this )
43 , m_packages( 9973 ) 43 , m_packages( 9973 )
44 , m_categories() 44 , m_categories()
45{ 45{
46 m_packages.setAutoDelete( true ); 46 m_packages.setAutoDelete( true );
47} 47}
48 48
49void OPackageManager::loadAvailablePackages() 49void OPackageManager::loadAvailablePackages()
50{ 50{
51 m_packages.clear(); 51 m_packages.clear();
52 52
53 OConfItemList *serverList = m_ipkg.servers(); 53 OConfItemList *serverList = m_ipkg.servers();
54 54
55 if ( serverList ) 55 if ( serverList )
56 { 56 {
57 // Initialize status messaging 57 // Initialize status messaging
58 emit initStatus( serverList->count() ); 58 emit initStatus( serverList->count() );
59 int serverCount = 0; 59 int serverCount = 0;
60 60
61 bool categoryAdded = false; 61 bool categoryAdded = false;
62 62
63 for ( OConfItemListIterator serverIt( *serverList ); serverIt.current(); ++serverIt ) 63 for ( OConfItemListIterator serverIt( *serverList ); serverIt.current(); ++serverIt )
64 { 64 {
65 OConfItem *server = serverIt.current(); 65 OConfItem *server = serverIt.current();
66 66
67 // Process server only if it is active 67 // Process server only if it is active
68 if ( server->active() ) 68 if ( server->active() )
69 { 69 {
70 // Update status 70 // Update status
71 QString status = tr( "Reading available packages:\n\t" ); 71 QString status = tr( "Reading available packages:\n\t" );
72 status.append( server->name() ); 72 status.append( server->name() );
73 emit statusText( status ); 73 emit statusText( status );
74 ++serverCount; 74 ++serverCount;
75 emit statusBar( serverCount ); 75 emit statusBar( serverCount );
76 qApp->processEvents(); 76 qApp->processEvents();
77 77
78 OPackageList *packageList = m_ipkg.availablePackages( server->name() ); 78 OPackageList *packageList = m_ipkg.availablePackages( server->name() );
79 if ( packageList ) 79 if ( packageList )
80 { 80 {
81 for ( OPackageListIterator packageIt( *packageList ); packageIt.current(); ++packageIt ) 81 for ( OPackageListIterator packageIt( *packageList ); packageIt.current(); ++packageIt )
82 { 82 {
83 OPackage *package = packageIt.current(); 83 OPackage *package = packageIt.current();
84 84
85 // Load package info 85 // Load package info
86 if ( !m_packages.find( package->name() ) ) 86 if ( !m_packages.find( package->name() ) )
87 m_packages.insert( package->name(), package ); 87 m_packages.insert( package->name(), package );
88 else 88 else
89 { 89 {
90 // If new package is newer version, replace existing package 90 // If new package is newer version, replace existing package
91 OPackage *currPackage = m_packages[package->name()]; 91 OPackage *currPackage = m_packages[package->name()];
92 if ( compareVersions( package->version(), currPackage->version() ) == 1 ) 92 if ( compareVersions( package->version(), currPackage->version() ) == 1 )
93 m_packages.replace( package->name(), package ); 93 m_packages.replace( package->name(), package );
94 } 94 }
95 95
96 // Add category to list if it doesn't already exist 96 // Add category to list if it doesn't already exist
97 if ( m_categories.grep( package->category() ).isEmpty() ) 97 if ( m_categories.grep( package->category() ).isEmpty() )
98 { 98 {
99 m_categories << package->category(); 99 m_categories << package->category();
100 categoryAdded = true; 100 categoryAdded = true;
101 } 101 }
102 } 102 }
103 } 103 }
104 } 104 }
105 } 105 }
106 delete serverList; 106 delete serverList;
107 107
108 // Sort category list if categories were added 108 // Sort category list if categories were added
109 if ( categoryAdded ) 109 if ( categoryAdded )
110 m_categories.sort(); 110 m_categories.sort();
111 } 111 }
112} 112}
113 113
114void OPackageManager::loadInstalledPackages() 114void OPackageManager::loadInstalledPackages()
115{ 115{
116 OConfItemList *destList = m_ipkg.destinations(); 116 OConfItemList *destList = m_ipkg.destinations();
117 117
118 if ( destList ) 118 if ( destList )
119 { 119 {
120 // Initialize status messaging 120 // Initialize status messaging
121 emit initStatus( destList->count() ); 121 emit initStatus( destList->count() );
122 int destCount = 0; 122 int destCount = 0;
123 123
124 bool categoryAdded = false; 124 bool categoryAdded = false;
125 125
126 for ( OConfItemListIterator destIt( *destList ); destIt.current(); ++destIt ) 126 for ( OConfItemListIterator destIt( *destList ); destIt.current(); ++destIt )
127 { 127 {
128 OConfItem *destination = destIt.current(); 128 OConfItem *destination = destIt.current();
129 129
130 // Process destination only if it is active 130 // Process destination only if it is active
131 if ( destination->active() ) 131 if ( destination->active() )
132 { 132 {
133 // Update status 133 // Update status
134 QString status = tr( "Reading installed packages:\n\t" ); 134 QString status = tr( "Reading installed packages:\n\t" );
135 status.append( destination->name() ); 135 status.append( destination->name() );
136 emit statusText( status ); 136 emit statusText( status );
137 ++destCount; 137 ++destCount;
138 emit statusBar( destCount ); 138 emit statusBar( destCount );
139 qApp->processEvents(); 139 qApp->processEvents();
140 140
141 OPackageList *packageList = m_ipkg.installedPackages( destination->name(), 141 OPackageList *packageList = m_ipkg.installedPackages( destination->name(),
142 destination->value() ); 142 destination->value() );
143 if ( packageList ) 143 if ( packageList )
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 = new QStringList(); 232 QStringList *sl = new QStringList();
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 = new QStringList(); 252 QStringList *dl = new QStringList();
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 OConfItem *confItem = 0x0;
273 OConfItemList *confList = m_ipkg.configItems(); 273 OConfItemList *confList = m_ipkg.configItems();
274 if ( confList ) 274 if ( confList )
275 { 275 {
276 for ( OConfItemListIterator confIt( *confList ); confIt.current(); ++confIt ) 276 for ( OConfItemListIterator confIt( *confList ); confIt.current(); ++confIt )
277 { 277 {
278 OConfItem *conf = confIt.current(); 278 OConfItem *conf = confIt.current();
279 279
280 // Add only active confinations 280 // Add only active confinations
281 if ( conf->type() == type && conf->name() == name ) 281 if ( conf->type() == type && conf->name() == name )
282 { 282 {
283 confItem = conf; 283 confItem = conf;
284 break; 284 break;
285 } 285 }
286 } 286 }
287 } 287 }
288 288
289 return confItem; 289 return confItem;
290 290
291} 291}
292 292
293OPackage *OPackageManager::findPackage( const QString &name ) 293OPackage *OPackageManager::findPackage( const QString &name )
294{ 294{
295 return m_packages[ name ]; 295 return m_packages[ name ];
296} 296}
297 297
298int OPackageManager::compareVersions( const QString &ver1, const QString &ver2 ) 298int OPackageManager::compareVersions( const QString &ver1, const QString &ver2 )
299{ 299{
300 // TODO - should this be in OIpkg??? 300 // TODO - should this be in OIpkg???
301 301
302 int epoch1, epoch2; 302 int epoch1, epoch2;
303 QString version1, revision1; 303 QString version1, revision1;
304 QString version2, revision2; 304 QString version2, revision2;
305 305
306 parseVersion( ver1, &epoch1, &version1, &revision1 ); 306 parseVersion( ver1, &epoch1, &version1, &revision1 );
307 parseVersion( ver2, &epoch2, &version2, &revision2 ); 307 parseVersion( ver2, &epoch2, &version2, &revision2 );
308 308
309 if ( epoch1 > epoch2 ) 309 if ( epoch1 > epoch2 )
310 return 1; 310 return 1;
311 else if ( epoch1 < epoch2 ) 311 else if ( epoch1 < epoch2 )
312 return -1; 312 return -1;
313 313
314 int r = verrevcmp( version1.latin1(), version2.latin1() ); 314 int r = verrevcmp( version1.latin1(), version2.latin1() );
315 if (r) 315 if (r)
316 return r; 316 return r;
317 317
318 r = verrevcmp( revision1.latin1(), revision2.latin1() ); 318 r = verrevcmp( revision1.latin1(), revision2.latin1() );
319 return r; 319 return r;
320} 320}
321 321
322bool OPackageManager::configureDlg( bool installOptions ) 322bool OPackageManager::configureDlg( bool installOptions )
323{ 323{
324 OIpkgConfigDlg dlg( &m_ipkg, installOptions, static_cast<QWidget *>(parent()) ); 324 OIpkgConfigDlg dlg( &m_ipkg, installOptions, static_cast<QWidget *>(parent()) );
325 return ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ); 325 return ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted );
326} 326}
327 327
328void OPackageManager::saveSettings() 328void OPackageManager::saveSettings()
329{ 329{
330 m_ipkg.saveSettings(); 330 m_ipkg.saveSettings();
331} 331}
332 332
333bool OPackageManager::executeCommand( OPackage::Command command, QStringList *packages, 333bool OPackageManager::executeCommand( OPackage::Command command, QStringList *packages,
334 const QString &destination, const QObject *receiver, 334 const QString &destination, const QObject *receiver,
335 const char *slotOutput, bool rawOutput ) 335 const char *slotOutput, bool rawOutput )
336{ 336{
337 return m_ipkg.executeCommand( command, packages, destination, receiver, slotOutput, rawOutput ); 337 return m_ipkg.executeCommand( command, packages, destination, receiver, slotOutput, rawOutput );
338} 338}
339 339
340void OPackageManager::parseVersion( const QString &verstr, int *epoch, QString *version, 340void OPackageManager::parseVersion( const QString &verstr, int *epoch, QString *version,
341 QString *revision ) 341 QString *revision )
342{ 342{
343 *epoch = 0; 343 *epoch = 0;
344 *revision = QString::null; 344 *revision = QString::null;
345 345
346 // Version string is in the format "ee:vv-rv", where ee=epoch, vv=version, rv=revision 346 // Version string is in the format "ee:vv-rv", where ee=epoch, vv=version, rv=revision
347 347
348 // Get epoch 348 // Get epoch
349 int colonpos = verstr.find( ':' ); 349 int colonpos = verstr.find( ':' );
350 if ( colonpos > -1 ) 350 if ( colonpos > -1 )
351 { 351 {
352 *epoch = verstr.left( colonpos ).toInt(); 352 *epoch = verstr.left( colonpos ).toInt();
353 } 353 }
354 354
355 // Get version and revision 355 // Get version and revision
356 int hyphenpos = verstr.find( '-', colonpos + 1 ); 356 int hyphenpos = verstr.find( '-', colonpos + 1 );
357 int verlen = verstr.length(); 357 int verlen = verstr.length();
358 if ( hyphenpos > -1 ) 358 if ( hyphenpos > -1 )
359 { 359 {
360 *version = verstr.mid( colonpos + 1, hyphenpos - colonpos - 1 ); 360 *version = verstr.mid( colonpos + 1, hyphenpos - colonpos - 1 );
361 *revision = verstr.right( verlen - hyphenpos - 1 ); 361 *revision = verstr.right( verlen - hyphenpos - 1 );
362 } 362 }
363 else 363 else
364 { 364 {
365 *version = verstr.right( verlen - colonpos ); 365 *version = verstr.right( verlen - colonpos );
366 } 366 }
367} 367}
368 368
369/* 369/*
370 * libdpkg - Debian packaging suite library routines 370 * libdpkg - Debian packaging suite library routines
371 * vercmp.c - comparison of version numbers 371 * vercmp.c - comparison of version numbers
372 * 372 *
373 * Copyright (C) 1995 Ian Jackson <iwj10@cus.cam.ac.uk> 373 * Copyright (C) 1995 Ian Jackson <iwj10@cus.cam.ac.uk>
374 */ 374 */
375int OPackageManager::verrevcmp( const char *val, const char *ref ) 375int OPackageManager::verrevcmp( const char *val, const char *ref )
376{ 376{
377 int vc, rc; 377 int vc, rc;
378 long vl, rl; 378 long vl, rl;
379 const char *vp, *rp; 379 const char *vp, *rp;
380 const char *vsep, *rsep; 380 const char *vsep, *rsep;
381 381
382 if (!val) val= ""; 382 if (!val) val= "";
383 if (!ref) ref= ""; 383 if (!ref) ref= "";
384 for (;;) { 384 for (;;) {
385 vp= val; while (*vp && !isdigit(*vp)) vp++; 385 vp= val; while (*vp && !isdigit(*vp)) vp++;
386 rp= ref; while (*rp && !isdigit(*rp)) rp++; 386 rp= ref; while (*rp && !isdigit(*rp)) rp++;
387 for (;;) { 387 for (;;) {
388 vc= (val == vp) ? 0 : *val++; 388 vc= (val == vp) ? 0 : *val++;
389 rc= (ref == rp) ? 0 : *ref++; 389 rc= (ref == rp) ? 0 : *ref++;
390 if (!rc && !vc) break; 390 if (!rc && !vc) break;
391 if (vc && !isalpha(vc)) vc += 256; /* assumes ASCII character set */ 391 if (vc && !isalpha(vc)) vc += 256; /* assumes ASCII character set */
392 if (rc && !isalpha(rc)) rc += 256; 392 if (rc && !isalpha(rc)) rc += 256;
393 if (vc != rc) return vc - rc; 393 if (vc != rc) return vc - rc;
394 } 394 }
395 val= vp; 395 val= vp;
396 ref= rp; 396 ref= rp;
397 vl=0; if (isdigit(*vp)) vl= strtol(val,(char**)&val,10); 397 vl=0; if (isdigit(*vp)) vl= strtol(val,(char**)&val,10);
398 rl=0; if (isdigit(*rp)) rl= strtol(ref,(char**)&ref,10); 398 rl=0; if (isdigit(*rp)) rl= strtol(ref,(char**)&ref,10);
399 if (vl != rl) return vl - rl; 399 if (vl != rl) return vl - rl;
400 400
401 vc = *val; 401 vc = *val;
402 rc = *ref; 402 rc = *ref;
403 vsep = strchr(".-", vc); 403 vsep = strchr(".-", vc);
404 rsep = strchr(".-", rc); 404 rsep = strchr(".-", rc);
405 if (vsep && !rsep) return -1; 405 if (vsep && !rsep) return -1;
406 if (!vsep && rsep) return +1; 406 if (!vsep && rsep) return +1;
407 407
408 if (!*val && !*ref) return 0; 408 if (!*val && !*ref) return 0;
409 if (!*val) return -1; 409 if (!*val) return -1;
410 if (!*ref) return +1; 410 if (!*ref) return +1;
411 } 411 }
412} 412}
diff --git a/noncore/settings/packagemanager/opackagemanager.h b/noncore/settings/packagemanager/opackagemanager.h
index b710a51..58e597b 100644
--- a/noncore/settings/packagemanager/opackagemanager.h
+++ b/noncore/settings/packagemanager/opackagemanager.h
@@ -1,92 +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 =. 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 OPACKAGEMANAGER_H 32#ifndef OPACKAGEMANAGER_H
33#define OPACKAGEMANAGER_H 33#define OPACKAGEMANAGER_H
34 34
35#include <qdict.h> 35#include "oipkg.h"
36#include <qobject.h>
37#include <qstringlist.h>
38 36
39#include <qpe/config.h> 37#include <qpe/config.h>
40 38
41#include "oipkg.h" 39#include <qdict.h>
40#include <qobject.h>
41#include <qstringlist.h>
42 42
43class OPackageManager : public QObject 43class OPackageManager : public QObject
44{ 44{
45 Q_OBJECT 45 Q_OBJECT
46 46
47public: 47public:
48 OPackageManager( Config *config = 0x0, QObject *parent = 0x0, const char *name = 0x0 ); 48 OPackageManager( Config *config = 0x0, QObject *parent = 0x0, const char *name = 0x0 );
49 49
50 void loadAvailablePackages(); 50 void loadAvailablePackages();
51 void loadInstalledPackages(); 51 void loadInstalledPackages();
52 52
53 enum Status { All, NotInstalled, Installed, Updated, NotDefined }; 53 enum Status { All, NotInstalled, Installed, Updated, NotDefined };
54 54
55 OPackageList *packages(); 55 OPackageList *packages();
56 OPackageList *filterPackages( const QString &name = 0x0,const QString &server = 0x0, 56 OPackageList *filterPackages( const QString &name = 0x0,const QString &server = 0x0,
57 const QString &destination = 0x0, Status status = NotDefined, 57 const QString &destination = 0x0, Status status = NotDefined,
58 const QString &category = 0x0 ); 58 const QString &category = 0x0 );
59 59
60 const QStringList &categories() { return m_categories; } 60 const QStringList &categories() { return m_categories; }
61 QStringList *servers(); 61 QStringList *servers();
62 QStringList *destinations(); 62 QStringList *destinations();
63 63
64 int compareVersions( const QString &version1, const QString &version2 ); 64 int compareVersions( const QString &version1, const QString &version2 );
65 65
66 OConfItem *findConfItem( OConfItem::Type type = OConfItem::NotDefined, 66 OConfItem *findConfItem( OConfItem::Type type = OConfItem::NotDefined,
67 const QString &name = QString::null ); 67 const QString &name = QString::null );
68 OPackage *findPackage( const QString &name = QString::null ); 68 OPackage *findPackage( const QString &name = QString::null );
69 69
70 bool configureDlg( bool installOptions = false ); 70 bool configureDlg( bool installOptions = false );
71 void saveSettings(); 71 void saveSettings();
72 72
73 bool executeCommand( OPackage::Command command = OPackage::NotDefined, QStringList *parameters = 0x0, 73 bool executeCommand( OPackage::Command command = OPackage::NotDefined, QStringList *parameters = 0x0,
74 const QString &destination = QString::null, const QObject *receiver = 0x0, 74 const QString &destination = QString::null, const QObject *receiver = 0x0,
75 const char *slotOutput = 0x0, bool rawOutput = true ); 75 const char *slotOutput = 0x0, bool rawOutput = true );
76 76
77private: 77private:
78 Config *m_config; // Pointer to application configuration file 78 Config *m_config; // Pointer to application configuration file
79 OIpkg m_ipkg; // OIpkg object to retrieve package/configuration information 79 OIpkg m_ipkg; // OIpkg object to retrieve package/configuration information
80 QDict<OPackage> m_packages; // Global list of available packages 80 QDict<OPackage> m_packages; // Global list of available packages
81 QStringList m_categories; // List of all categories 81 QStringList m_categories; // List of all categories
82 82
83 void parseVersion( const QString &verstr, int *epoch, QString *version, QString *revision ); 83 void parseVersion( const QString &verstr, int *epoch, QString *version, QString *revision );
84 int verrevcmp( const char *val, const char *ref ); 84 int verrevcmp( const char *val, const char *ref );
85 85
86signals: 86signals:
87 void initStatus( int numSteps ); 87 void initStatus( int numSteps );
88 void statusText( const QString &status ); 88 void statusText( const QString &status );
89 void statusBar( int currStep ); 89 void statusBar( int currStep );
90}; 90};
91 91
92#endif 92#endif
diff --git a/noncore/settings/packagemanager/opie-packagemanager.control b/noncore/settings/packagemanager/opie-packagemanager.control
index aff8866..09bb18b 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 5Depends: task-opie-minimal, libopiecore2, libopieui2, libipkg
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.3.0$EXTRAVERSION 10Version: 0.4.0$EXTRAVERSION
diff --git a/noncore/settings/packagemanager/packageinfodlg.cpp b/noncore/settings/packagemanager/packageinfodlg.cpp
index 73d3de7..d27eacb 100644
--- a/noncore/settings/packagemanager/packageinfodlg.cpp
+++ b/noncore/settings/packagemanager/packageinfodlg.cpp
@@ -1,141 +1,144 @@
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 <qlayout.h> 34#include <opie2/otabwidget.h>
35#include <qpushbutton.h>
36 35
37#include <qpe/resource.h> 36#include <qpe/resource.h>
38 37
39#include <opie2/otabwidget.h> 38#include <qlayout.h>
39#include <qpushbutton.h>
40#include <qwhatsthis.h>
40 41
41using namespace Opie::Ui;
42PackageInfoDlg::PackageInfoDlg( QWidget *parent, OPackageManager *pm, const QString &package ) 42PackageInfoDlg::PackageInfoDlg( QWidget *parent, OPackageManager *pm, const QString &package )
43 : QWidget( 0x0 ) 43 : QWidget( 0x0 )
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{ 47{
48 // Initialize UI 48 // Initialize UI
49 if ( parent ) 49 if ( parent )
50 parent->setCaption( package ); 50 parent->setCaption( package );
51 51
52 QVBoxLayout *layout = new QVBoxLayout( this, 4, 2 ); 52 QVBoxLayout *layout = new QVBoxLayout( this, 4, 2 );
53 53
54 OTabWidget *tabWidget = new OTabWidget( this ); 54 Opie::Ui::OTabWidget *tabWidget = new Opie::Ui::OTabWidget( this );
55 layout->addWidget( tabWidget ); 55 layout->addWidget( tabWidget );
56 56
57 // Information tab 57 // Information tab
58 QWhatsThis::add( &m_information, tr( "This area contains information about the package." ) );
58 m_information.reparent( tabWidget, QPoint( 0, 0 ) ); 59 m_information.reparent( tabWidget, QPoint( 0, 0 ) );
59 m_information.setReadOnly( true ); 60 m_information.setReadOnly( true );
60 tabWidget->addTab( &m_information, "UtilsIcon", tr( "Information" ) ); 61 tabWidget->addTab( &m_information, "UtilsIcon", tr( "Information" ) );
61 62
62 // Retrive package information 63 // Retrive package information
63 m_package = m_packman->findPackage( package ); 64 m_package = m_packman->findPackage( package );
64 if ( !m_package ) 65 if ( !m_package )
65 { 66 {
66 m_information.setText( tr( "Unable to retrieve package information." ) ); 67 m_information.setText( tr( "Unable to retrieve package information." ) );
67 return; 68 return;
68 } 69 }
69 70
70 // Display package information 71 // Display package information
71 if ( !m_package->information().isNull() ) 72 if ( !m_package->information().isNull() )
72 m_information.setText( m_package->information() ); 73 m_information.setText( m_package->information() );
73 else 74 else
74 { 75 {
75 // Package information is not cached, retrieve it 76 // Package information is not cached, retrieve it
76 QStringList list( package ); 77 QStringList list( package );
77 m_packman->executeCommand( OPackage::Info, &list, QString::null, this, SLOT(slotInfo(char*)), true ); 78 m_packman->executeCommand( OPackage::Info, &list, QString::null, this, SLOT(slotInfo(char*)), true );
78 } 79 }
79 80
80 // Files tab (display only if package is installed) 81 // Files tab (display only if package is installed)
81 if ( !m_package->versionInstalled().isNull() ) 82 if ( !m_package->versionInstalled().isNull() )
82 { 83 {
83 QWidget *filesWidget = new QWidget( tabWidget ); 84 QWidget *filesWidget = new QWidget( tabWidget );
84 QVBoxLayout *filesLayout = new QVBoxLayout( filesWidget, 2, 2 ); 85 QVBoxLayout *filesLayout = new QVBoxLayout( filesWidget, 2, 2 );
86 QWhatsThis::add( &m_files, tr( "This area contains a list of files contained in this package." ) );
85 m_files.reparent( filesWidget, QPoint( 0, 0 ) ); 87 m_files.reparent( filesWidget, QPoint( 0, 0 ) );
86 m_files.setReadOnly( true ); 88 m_files.setReadOnly( true );
87 filesLayout->addWidget( &m_files ); 89 filesLayout->addWidget( &m_files );
88 90
89 QPushButton *btn = new QPushButton( Resource::loadPixmap( "packagemanager/apply" ), 91 QPushButton *btn = new QPushButton( Resource::loadPixmap( "packagemanager/apply" ),
90 tr( "Retrieve file list" ), filesWidget ); 92 tr( "Retrieve file list" ), filesWidget );
93 QWhatsThis::add( btn, tr( "Tap here to retrieve list of files contained in this package." ) );
91 filesLayout->addWidget( btn ); 94 filesLayout->addWidget( btn );
92 connect( btn, SIGNAL(clicked()), this, SLOT(slotBtnFileScan()) ); 95 connect( btn, SIGNAL(clicked()), this, SLOT(slotBtnFileScan()) );
93 tabWidget->addTab( filesWidget, "binary", tr( "File list" ) ); 96 tabWidget->addTab( filesWidget, "binary", tr( "File list" ) );
94 97
95 tabWidget->setCurrentTab( tr( "Information" ) ); 98 tabWidget->setCurrentTab( tr( "Information" ) );
96 99
97 // If file list is already cached, display 100 // If file list is already cached, display
98 if ( !m_package->files().isNull() ) 101 if ( !m_package->files().isNull() )
99 m_files.setText( m_package->files() ); 102 m_files.setText( m_package->files() );
100 } 103 }
101 else 104 else
102 m_files.hide(); 105 m_files.hide();
103} 106}
104 107
105PackageInfoDlg::~PackageInfoDlg() 108PackageInfoDlg::~PackageInfoDlg()
106{ 109{
107 if ( !m_package ) 110 if ( !m_package )
108 return; 111 return;
109 112
110 // Cache package information 113 // Cache package information
111 if ( !m_information.text().isNull() ) 114 if ( !m_information.text().isNull() )
112 m_package->setInformation( m_information.text() ); 115 m_package->setInformation( m_information.text() );
113 116
114 // Cache package file list 117 // Cache package file list
115 if ( !m_files.text().isNull() ) 118 if ( !m_files.text().isNull() )
116 m_package->setFiles( m_files.text() ); 119 m_package->setFiles( m_files.text() );
117} 120}
118 121
119void PackageInfoDlg::slotBtnFileScan() 122void PackageInfoDlg::slotBtnFileScan()
120{ 123{
121 m_files.clear(); 124 m_files.clear();
122 125
123 QStringList list( m_package->name() ); 126 QStringList list( m_package->name() );
124 m_packman->executeCommand( OPackage::Files, &list, QString::null, this, SLOT(slotFiles(char*)), true ); 127 m_packman->executeCommand( OPackage::Files, &list, QString::null, this, SLOT(slotFiles(char*)), true );
125} 128}
126 129
127void PackageInfoDlg::slotInfo( char *info ) 130void PackageInfoDlg::slotInfo( char *info )
128{ 131{
129 m_information.append( info ); 132 m_information.append( info );
130} 133}
131 134
132void PackageInfoDlg::slotFiles( char *filelist ) 135void PackageInfoDlg::slotFiles( char *filelist )
133{ 136{
134 QString str = filelist; 137 QString str = filelist;
135 138
136 // Skip first line of output ("Package xxx is installed...") 139 // Skip first line of output ("Package xxx is installed...")
137 if ( str.startsWith( "Package " ) ) 140 if ( str.startsWith( "Package " ) )
138 str = str.right( str.length() - str.find( '\n' ) - 1 ); 141 str = str.right( str.length() - str.find( '\n' ) - 1 );
139 142
140 m_files.append( str ); 143 m_files.append( str );
141} 144}
diff --git a/noncore/settings/packagemanager/packageinfodlg.h b/noncore/settings/packagemanager/packageinfodlg.h
index 7ed9f0a..ec031e1 100644
--- a/noncore/settings/packagemanager/packageinfodlg.h
+++ b/noncore/settings/packagemanager/packageinfodlg.h
@@ -1,65 +1,65 @@
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"
34
33#include <qmultilineedit.h> 35#include <qmultilineedit.h>
34#include <qwidget.h> 36#include <qwidget.h>
35 37
36#include "opackage.h"
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 = 0x0, OPackageManager *pm = 0x0, const QString &package = QString::null ); 48 PackageInfoDlg( QWidget *parent = 0x0, OPackageManager *pm = 0x0, 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 58
59private slots: 59private slots:
60 void slotBtnFileScan(); 60 void slotBtnFileScan();
61 void slotInfo( char *info ); 61 void slotInfo( char *info );
62 void slotFiles( char *filelist ); 62 void slotFiles( char *filelist );
63}; 63};
64 64
65#endif 65#endif
diff --git a/noncore/settings/packagemanager/promptdlg.cpp b/noncore/settings/packagemanager/promptdlg.cpp
index 4e82ba9..841b98e 100644
--- a/noncore/settings/packagemanager/promptdlg.cpp
+++ b/noncore/settings/packagemanager/promptdlg.cpp
@@ -1,140 +1,140 @@
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 "promptdlg.h" 30#include "promptdlg.h"
31 31
32#include <qpe/qpeapplication.h>
33
32#include <qlabel.h> 34#include <qlabel.h>
33#include <qlayout.h> 35#include <qlayout.h>
34#include <qpushbutton.h> 36#include <qpushbutton.h>
35#include <qwidgetlist.h> 37#include <qwidgetlist.h>
36 38
37#include <qpe/qpeapplication.h>
38
39PromptDlg::PromptDlg( const QString &caption, const QString &text, const QString &btn1, const QString &btn2, 39PromptDlg::PromptDlg( const QString &caption, const QString &text, const QString &btn1, const QString &btn2,
40 QWidget *parent ) 40 QWidget *parent )
41 : QWidget( parent, QString::null, WType_Modal | WType_TopLevel | WStyle_Dialog ) 41 : QWidget( parent, QString::null, WType_Modal | WType_TopLevel | WStyle_Dialog )
42 , m_btnClicked( -1 ) 42 , m_btnClicked( -1 )
43{ 43{
44 setCaption( caption ); 44 setCaption( caption );
45 45
46 QGridLayout *layout = new QGridLayout( this, 2, 2, 4, 2 ); 46 QGridLayout *layout = new QGridLayout( this, 2, 2, 4, 2 );
47 QLabel *label = new QLabel( text, this ); 47 QLabel *label = new QLabel( text, this );
48 label->setAlignment( AlignCenter | WordBreak ); 48 label->setAlignment( AlignCenter | WordBreak );
49 layout->addMultiCellWidget( label, 0, 0, 0, 1 ); 49 layout->addMultiCellWidget( label, 0, 0, 0, 1 );
50 50
51 QPushButton *btn = new QPushButton( btn1, this ); 51 QPushButton *btn = new QPushButton( btn1, this );
52 layout->addWidget( btn, 1, 0 ); 52 layout->addWidget( btn, 1, 0 );
53 connect( btn, SIGNAL(clicked()), this, SLOT(slotBtn1Clicked()) ); 53 connect( btn, SIGNAL(clicked()), this, SLOT(slotBtn1Clicked()) );
54 54
55 btn = new QPushButton( btn2, this ); 55 btn = new QPushButton( btn2, this );
56 layout->addWidget( btn, 1, 1 ); 56 layout->addWidget( btn, 1, 1 );
57 connect( btn, SIGNAL(clicked()), this, SLOT(slotBtn2Clicked()) ); 57 connect( btn, SIGNAL(clicked()), this, SLOT(slotBtn2Clicked()) );
58} 58}
59 59
60int PromptDlg::display() 60int PromptDlg::display()
61{ 61{
62 // Determine position of dialog. Derived from QT's QDialog::show() method. 62 // Determine position of dialog. Derived from QT's QDialog::show() method.
63 QWidget *w = parentWidget(); 63 QWidget *w = parentWidget();
64 QPoint p( 0, 0 ); 64 QPoint p( 0, 0 );
65 int extraw = 0, extrah = 0; 65 int extraw = 0, extrah = 0;
66 QWidget * desk = QApplication::desktop(); 66 QWidget * desk = QApplication::desktop();
67 if ( w ) 67 if ( w )
68 w = w->topLevelWidget(); 68 w = w->topLevelWidget();
69 69
70 QWidgetList *list = QApplication::topLevelWidgets(); 70 QWidgetList *list = QApplication::topLevelWidgets();
71 QWidgetListIt it( *list ); 71 QWidgetListIt it( *list );
72 while ( (extraw == 0 || extrah == 0) && it.current() != 0 ) 72 while ( (extraw == 0 || extrah == 0) && it.current() != 0 )
73 { 73 {
74 int w, h; 74 int w, h;
75 QWidget * current = it.current(); 75 QWidget * current = it.current();
76 ++it; 76 ++it;
77 w = current->geometry().x() - current->x(); 77 w = current->geometry().x() - current->x();
78 h = current->geometry().y() - current->y(); 78 h = current->geometry().y() - current->y();
79 79
80 extraw = QMAX( extraw, w ); 80 extraw = QMAX( extraw, w );
81 extrah = QMAX( extrah, h ); 81 extrah = QMAX( extrah, h );
82 } 82 }
83 delete list; 83 delete list;
84 84
85 // sanity check for decoration frames. With embedding, we 85 // sanity check for decoration frames. With embedding, we
86 // might get extraordinary values 86 // might get extraordinary values
87 if ( extraw >= 10 || extrah >= 40 ) 87 if ( extraw >= 10 || extrah >= 40 )
88 extraw = extrah = 0; 88 extraw = extrah = 0;
89 89
90 if ( w ) 90 if ( w )
91 { 91 {
92 // Use mapToGlobal rather than geometry() in case w might 92 // Use mapToGlobal rather than geometry() in case w might
93 // be embedded in another application 93 // be embedded in another application
94 QPoint pp = w->mapToGlobal( QPoint(0,0) ); 94 QPoint pp = w->mapToGlobal( QPoint(0,0) );
95 p = QPoint( pp.x() + w->width()/2, pp.y() + w->height()/ 2 ); 95 p = QPoint( pp.x() + w->width()/2, pp.y() + w->height()/ 2 );
96 } 96 }
97 else 97 else
98 p = QPoint( desk->width()/2, desk->height()/2 ); 98 p = QPoint( desk->width()/2, desk->height()/2 );
99 99
100 p = QPoint( p.x()-width()/2 - extraw, p.y()-height()/2 - extrah ); 100 p = QPoint( p.x()-width()/2 - extraw, p.y()-height()/2 - extrah );
101 101
102 if ( p.x() + extraw + width() > desk->width() ) 102 if ( p.x() + extraw + width() > desk->width() )
103 p.setX( desk->width() - width() - extraw ); 103 p.setX( desk->width() - width() - extraw );
104 if ( p.x() < 0 ) 104 if ( p.x() < 0 )
105 p.setX( 0 ); 105 p.setX( 0 );
106 106
107 if ( p.y() + extrah + height() > desk->height() ) 107 if ( p.y() + extrah + height() > desk->height() )
108 p.setY( desk->height() - height() - extrah ); 108 p.setY( desk->height() - height() - extrah );
109 if ( p.y() < 0 ) 109 if ( p.y() < 0 )
110 p.setY( 0 ); 110 p.setY( 0 );
111 111
112 move( p ); 112 move( p );
113 show(); 113 show();
114 114
115 // Enter event loop for modality 115 // Enter event loop for modality
116 qApp->enter_loop(); 116 qApp->enter_loop();
117 117
118 return m_btnClicked; 118 return m_btnClicked;
119} 119}
120 120
121int PromptDlg::ask( const QString &caption, const QString &text, const QString &btn1, const QString &btn2, 121int PromptDlg::ask( const QString &caption, const QString &text, const QString &btn1, const QString &btn2,
122 QWidget *parent ) 122 QWidget *parent )
123{ 123{
124 PromptDlg *dlg = new PromptDlg( caption, text, btn1, btn2, parent ); 124 PromptDlg *dlg = new PromptDlg( caption, text, btn1, btn2, parent );
125 int rc = dlg->display(); 125 int rc = dlg->display();
126 delete dlg; 126 delete dlg;
127 return rc; 127 return rc;
128} 128}
129 129
130void PromptDlg::slotBtn1Clicked() 130void PromptDlg::slotBtn1Clicked()
131{ 131{
132 m_btnClicked = 1; 132 m_btnClicked = 1;
133 qApp->exit_loop(); 133 qApp->exit_loop();
134} 134}
135 135
136void PromptDlg::slotBtn2Clicked() 136void PromptDlg::slotBtn2Clicked()
137{ 137{
138 m_btnClicked = 2; 138 m_btnClicked = 2;
139 qApp->exit_loop(); 139 qApp->exit_loop();
140} 140}