summaryrefslogtreecommitdiff
authordrw <drw>2004-01-13 17:29:39 (UTC)
committer drw <drw>2004-01-13 17:29:39 (UTC)
commit4617ef389426b5b6d37a5fd878147abb916367fe (patch) (unidiff)
tree41417a10d99b7292ffc0ea63b5e1699b58e578de
parentaf79bda4c7e51f46abe67124f9c06126eaebb59d (diff)
downloadopie-4617ef389426b5b6d37a5fd878147abb916367fe.zip
opie-4617ef389426b5b6d37a5fd878147abb916367fe.tar.gz
opie-4617ef389426b5b6d37a5fd878147abb916367fe.tar.bz2
Initial upload of new package manager
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--apps/Settings/packagemanager.desktop8
-rw-r--r--noncore/settings/packagemanager/ChangeLog4
-rw-r--r--noncore/settings/packagemanager/README40
-rw-r--r--noncore/settings/packagemanager/config.in4
-rw-r--r--noncore/settings/packagemanager/filterdlg.cpp179
-rw-r--r--noncore/settings/packagemanager/filterdlg.h101
-rw-r--r--noncore/settings/packagemanager/global.h37
-rw-r--r--noncore/settings/packagemanager/installdlg.cpp306
-rw-r--r--noncore/settings/packagemanager/installdlg.h89
-rw-r--r--noncore/settings/packagemanager/main.cpp34
-rw-r--r--noncore/settings/packagemanager/mainwindow.cpp667
-rw-r--r--noncore/settings/packagemanager/mainwindow.h136
-rw-r--r--noncore/settings/packagemanager/oconfitem.cpp42
-rw-r--r--noncore/settings/packagemanager/oconfitem.h95
-rw-r--r--noncore/settings/packagemanager/oipkg.cpp505
-rw-r--r--noncore/settings/packagemanager/oipkg.h100
-rw-r--r--noncore/settings/packagemanager/oipkgconfigdlg.cpp558
-rw-r--r--noncore/settings/packagemanager/oipkgconfigdlg.h131
-rw-r--r--noncore/settings/packagemanager/opackage.cpp43
-rw-r--r--noncore/settings/packagemanager/opackage.h74
-rw-r--r--noncore/settings/packagemanager/opackagemanager.cpp330
-rw-r--r--noncore/settings/packagemanager/opackagemanager.h91
-rw-r--r--noncore/settings/packagemanager/opie-packagemanager.control10
-rw-r--r--noncore/settings/packagemanager/packageinfodlg.cpp56
-rw-r--r--noncore/settings/packagemanager/packageinfodlg.h58
-rw-r--r--noncore/settings/packagemanager/packagemanager.pro31
-rw-r--r--noncore/settings/packagemanager/promptdlg.cpp140
-rw-r--r--noncore/settings/packagemanager/promptdlg.h57
-rw-r--r--packages1
-rw-r--r--pics/packagemanager/apply.pngbin0 -> 816 bytes
-rw-r--r--pics/packagemanager/desttab.pngbin0 -> 740 bytes
-rw-r--r--pics/packagemanager/download.pngbin0 -> 842 bytes
-rw-r--r--pics/packagemanager/filter.pngbin0 -> 651 bytes
-rw-r--r--pics/packagemanager/ipkg.pngbin0 -> 2089 bytes
-rw-r--r--pics/packagemanager/keyboard.pngbin0 -> 394 bytes
-rw-r--r--pics/packagemanager/packagemanager.pngbin0 -> 2547 bytes
-rw-r--r--pics/packagemanager/proxytab.pngbin0 -> 623 bytes
-rw-r--r--pics/packagemanager/remove.pngbin0 -> 839 bytes
-rw-r--r--pics/packagemanager/servertab.pngbin0 -> 657 bytes
-rw-r--r--pics/packagemanager/update.pngbin0 -> 659 bytes
-rw-r--r--pics/packagemanager/updated.pngbin0 -> 736 bytes
-rw-r--r--pics/packagemanager/upgrade.pngbin0 -> 785 bytes
42 files changed, 3927 insertions, 0 deletions
diff --git a/apps/Settings/packagemanager.desktop b/apps/Settings/packagemanager.desktop
new file mode 100644
index 0000000..c631ff8
--- a/dev/null
+++ b/apps/Settings/packagemanager.desktop
@@ -0,0 +1,8 @@
1[Desktop Entry]
2Exec=packagemanager
3Icon=packagemanager/packagemanager
4MimeType=application/ipkg
5MimeTypeIcons=packagemanager/ipkg
6Type=Application
7Name=Package Manager
8Comment=Opie package management client
diff --git a/noncore/settings/packagemanager/ChangeLog b/noncore/settings/packagemanager/ChangeLog
new file mode 100644
index 0000000..a01c8b3
--- a/dev/null
+++ b/noncore/settings/packagemanager/ChangeLog
@@ -0,0 +1,4 @@
12004-01-nn Dan Williams <drw@handhelds.org>
2
3 * Released version 0.1.0
4 * Initial check-in of new package management client to eventually replace AQPkg
diff --git a/noncore/settings/packagemanager/README b/noncore/settings/packagemanager/README
new file mode 100644
index 0000000..3e3f409
--- a/dev/null
+++ b/noncore/settings/packagemanager/README
@@ -0,0 +1,40 @@
1/************************************************************************
2/*
3/* Opie - Package Manager
4/* ========================
5/* Version 0.1.0
6/*
7/* A package management client for Opie
8/*
9/************************************************************************
10
11-------------------------------------------------------
12 Release Notes for Opie-PackageManager - January, 2004
13-------------------------------------------------------
14
15======================
16= To-do =
17======================
18
19- See $OPIEDIR/noncore/settings/packagemanager/TODO for more info.
20
21======================
22= Run =
23======================
24
25- In order to use opie-packagemanager, ipkg must be installed and
26 configured on the system.
27
28======================
29= Credits =
30======================
31
32- Opie-PackageManager is (C) 2003-2004 Dan Williams
33
34======================
35= Links =
36======================
37
38- Opie Project: http://opie.handhelds.org
39- OpenZaurus Project: http://openzaurus.org
40- Familiar Project: http://familiar.handhelds.org
diff --git a/noncore/settings/packagemanager/config.in b/noncore/settings/packagemanager/config.in
new file mode 100644
index 0000000..4b47e65
--- a/dev/null
+++ b/noncore/settings/packagemanager/config.in
@@ -0,0 +1,4 @@
1 config PACKAGEMANAGER
2 boolean "opie-packagemanager (package management client)"
3 default "y"
4 depends ( LIBQPE || LIBQPE-X11 ) && LIBOPIE
diff --git a/noncore/settings/packagemanager/filterdlg.cpp b/noncore/settings/packagemanager/filterdlg.cpp
new file mode 100644
index 0000000..2e48d5b
--- a/dev/null
+++ b/noncore/settings/packagemanager/filterdlg.cpp
@@ -0,0 +1,179 @@
1/*
2                This file is part of the OPIE Project
3
4 =. Copyright (c) 2003 Dan Williams <drw@handhelds.org>
5             .=l.
6           .>+-=
7 _;:,     .>    :=|. This file is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This file is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
29
30#include "filterdlg.h"
31
32FilterDlg::FilterDlg( QWidget *parent, OPackageManager *pm, const QString &name,
33 const QString &server, const QString &destination,
34 OPackageManager::Status status, const QString &category )
35 : QDialog( parent, QString::null, true )
36{
37 setCaption( tr( "Filter packages" ) );
38
39 QVBoxLayout *layout = new QVBoxLayout( this );
40 QScrollView *sv = new QScrollView( this );
41 layout->addWidget( sv, 0, 0 );
42 sv->setResizePolicy( QScrollView::AutoOneFit );
43 sv->setFrameStyle( QFrame::NoFrame );
44 QWidget *container = new QWidget( sv->viewport() );
45 sv->addChild( container );
46 layout = new QVBoxLayout( container, 4, 4 );
47
48 // Category
49 m_categoryCB = new QCheckBox( tr( "Category:" ), container );
50 connect( m_categoryCB, SIGNAL(toggled(bool)), this, SLOT(slotCategorySelected(bool)) );
51 m_category = new QComboBox( container );
52 m_category->insertStringList( pm->categories() );
53 initItem( m_category, m_categoryCB, category );
54 layout->addWidget( m_categoryCB );
55 layout->addWidget( m_category );
56
57 // Package name
58 m_nameCB = new QCheckBox( tr( "Names containing:" ), container );
59 connect( m_nameCB, SIGNAL(toggled(bool)), this, SLOT(slotNameSelected(bool)) );
60 m_name = new QLineEdit( name, container );
61 if ( !name.isNull() )
62 m_nameCB->setChecked( true );
63 m_name->setEnabled( !name.isNull() );
64 layout->addWidget( m_nameCB );
65 layout->addWidget( m_name );
66
67 // Status
68 m_statusCB = new QCheckBox( tr( "With the status:" ), container );
69 connect( m_statusCB, SIGNAL(toggled(bool)), this, SLOT(slotStatusSelected(bool)) );
70 m_status = new QComboBox( container );
71 connect( m_status, SIGNAL(activated(const QString &)), this, SLOT(slotStatusChanged(const QString &)) );
72 QString currStatus;
73 switch ( status )
74 {
75 case OPackageManager::All : currStatus = tr( "All" );
76 break;
77 case OPackageManager::Installed : currStatus = tr( "Installed" );
78 break;
79 case OPackageManager::NotInstalled : currStatus = tr( "Not installed" );
80 break;
81 case OPackageManager::Updated : currStatus = tr( "Updated" );
82 break;
83 default : currStatus = QString::null;
84 };
85 m_status->insertItem( tr( "All" ) );
86 m_status->insertItem( tr( "Installed" ) );
87 m_status->insertItem( tr( "Not installed" ) );
88 m_status->insertItem( tr( "Updated" ) );
89 initItem( m_status, m_statusCB, currStatus );
90 layout->addWidget( m_statusCB );
91 layout->addWidget( m_status );
92
93 // Server
94 m_serverCB = new QCheckBox( tr( "Available from the following server:" ), container );
95 connect( m_serverCB, SIGNAL(toggled(bool)), this, SLOT(slotServerSelected(bool)) );
96 m_server = new QComboBox( container );
97 m_server->insertStringList( *(pm->servers()) );
98 initItem( m_server, m_serverCB, server );
99 layout->addWidget( m_serverCB );
100 layout->addWidget( m_server );
101
102 // Destination
103 m_destCB = new QCheckBox( tr( "Installed on device at:" ), container );
104 connect( m_destCB, SIGNAL(toggled(bool)), this, SLOT(slotDestSelected(bool)) );
105 m_destination = new QComboBox( container );
106 m_destination->insertStringList( *(pm->destinations()) );
107 initItem( m_destination, m_destCB, destination );
108 layout->addWidget( m_destCB );
109 layout->addWidget( m_destination );
110
111 showMaximized();
112}
113
114void FilterDlg::initItem( QComboBox *comboBox, QCheckBox *checkBox, const QString &selection )
115{
116 if ( !selection.isNull() )
117 {
118 checkBox->setChecked( true );
119
120 for ( int i = 0; i < comboBox->count(); i++ )
121 {
122 if ( comboBox->text( i ) == selection )
123 {
124 comboBox->setCurrentItem( i );
125 return;
126 }
127 }
128 }
129 comboBox->setEnabled( !selection.isNull() );
130}
131
132void FilterDlg::slotNameSelected( bool selected )
133{
134 m_name->setEnabled( selected );
135}
136
137void FilterDlg::slotServerSelected( bool selected )
138{
139 m_server->setEnabled( selected );
140}
141
142void FilterDlg::slotDestSelected( bool selected )
143{
144 m_destination->setEnabled( selected );
145}
146
147void FilterDlg::slotStatusSelected( bool selected )
148{
149 m_status->setEnabled( selected );
150
151 if ( !selected && !m_destCB->isEnabled() )
152 {
153 // If status check box has been deselected and destination option was previously deselected
154 // (because status == "Not installed"), re-enable destination option
155 m_destCB->setEnabled( true );
156 m_destination->setEnabled( true );
157 }
158 else if ( selected && m_destCB->isEnabled() && m_status->currentText() == tr( "Not installed" ) )
159 {
160 // If status check box has been selected and status == "Not installed", disable destination option
161 m_destCB->setEnabled( false );
162 m_destCB->setChecked( false );
163 m_destination->setEnabled( false );
164 }
165}
166
167void FilterDlg::slotStatusChanged( const QString &category )
168{
169 bool notInstalled = ( category == tr( "Not installed" ) );
170 m_destCB->setEnabled( !notInstalled );
171 m_destination->setEnabled( !notInstalled );
172 if ( notInstalled )
173 m_destCB->setChecked( false );
174}
175
176void FilterDlg::slotCategorySelected( bool selected )
177{
178 m_category->setEnabled( selected );
179}
diff --git a/noncore/settings/packagemanager/filterdlg.h b/noncore/settings/packagemanager/filterdlg.h
new file mode 100644
index 0000000..42bae8b
--- a/dev/null
+++ b/noncore/settings/packagemanager/filterdlg.h
@@ -0,0 +1,101 @@
1/*
2                This file is part of the OPIE Project
3
4 =. Copyright (c) 2003 Dan Williams <drw@handhelds.org>
5             .=l.
6           .>+-=
7 _;:,     .>    :=|. This file is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This file is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
29
30#ifndef FILTERDLG_H
31#define FILTERDLG_H
32
33#include <qcheckbox.h>
34#include <qdialog.h>
35#include <qcombobox.h>
36#include <qlayout.h>
37#include <qlineedit.h>
38#include <qscrollview.h>
39
40#include "opackagemanager.h"
41
42class FilterDlg : public QDialog
43{
44 Q_OBJECT
45
46public:
47 FilterDlg( QWidget *parent = 0x0, OPackageManager *pm = 0x0, const QString &name = 0x0,
48 const QString &server = 0x0, const QString &destination = 0x0,
49 OPackageManager::Status status = OPackageManager::All,
50 const QString &category = 0x0 );
51
52 const QString &name()
53 { return m_nameCB->isChecked() ? m_name->text() : QString::null; };
54 const QString &server()
55 { return m_serverCB->isChecked() ? m_server->currentText() : QString::null; };
56 const QString &destination()
57 { return m_destCB->isChecked() ? m_destination->currentText() : QString::null; };
58 OPackageManager::Status status()
59 {
60 if ( m_statusCB->isChecked() )
61 {
62 if ( m_status->currentText() == tr( "All" ) )
63 return OPackageManager::All;
64 else if ( m_status->currentText() == tr( "Installed" ) )
65 return OPackageManager::Installed;
66 else if ( m_status->currentText() == tr( "Not installed" ) )
67 return OPackageManager::NotInstalled;
68 else if ( m_status->currentText() == tr( "Updated" ) )
69 return OPackageManager::Updated;
70 }
71 else
72 return OPackageManager::NotDefined;
73 };
74 const QString &category()
75 { return m_categoryCB->isChecked() ? m_category->currentText() : QString::null; };
76
77private:
78 QCheckBox *m_nameCB;
79 QCheckBox *m_serverCB;
80 QCheckBox *m_destCB;
81 QCheckBox *m_statusCB;
82 QCheckBox *m_categoryCB;
83
84 QLineEdit *m_name;
85 QComboBox *m_server;
86 QComboBox *m_destination;
87 QComboBox *m_status;
88 QComboBox *m_category;
89
90 void initItem( QComboBox *comboBox, QCheckBox *checkBox, const QString &selection );
91
92private slots:
93 void slotNameSelected( bool );
94 void slotServerSelected( bool );
95 void slotDestSelected( bool );
96 void slotStatusSelected( bool );
97 void slotStatusChanged( const QString & );
98 void slotCategorySelected( bool );
99};
100
101#endif
diff --git a/noncore/settings/packagemanager/global.h b/noncore/settings/packagemanager/global.h
new file mode 100644
index 0000000..0fe5b85
--- a/dev/null
+++ b/noncore/settings/packagemanager/global.h
@@ -0,0 +1,37 @@
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
new file mode 100644
index 0000000..c0c03fc
--- a/dev/null
+++ b/noncore/settings/packagemanager/installdlg.cpp
@@ -0,0 +1,306 @@
1/*
2                This file is part of the OPIE Project
3
4 =. Copyright (c) 2003 Dan Williams <drw@handhelds.org>
5             .=l.
6           .>+-=
7 _;:,     .>    :=|. This file is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This file is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
29
30#include "installdlg.h"
31
32#include <sys/vfs.h>
33
34#include <qapplication.h>
35#include <qcombobox.h>
36#include <qfileinfo.h>
37#include <qgroupbox.h>
38#include <qlabel.h>
39#include <qlayout.h>
40#include <qmap.h>
41#include <qmultilineedit.h>
42#include <qpushbutton.h>
43
44#include <qpe/fileselector.h>
45#include <qpe/resource.h>
46#include <qpe/storage.h>
47
48#include <opie/ofiledialog.h>
49
50#include "opackagemanager.h"
51
52InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &caption, bool showDestInfo,
53 OPackage::Command command1, QStringList *packages1,
54 OPackage::Command command2, QStringList *packages2,
55 OPackage::Command command3, QStringList *packages3 )
56 : QWidget( 0x0 )
57 , m_packman( pm )
58 , m_numCommands( 0 )
59 , m_currCommand( 0 )
60{
61 // Save command/package list information
62 if ( command1 != OPackage::NotDefined )
63 {
64 m_command[ m_numCommands ] = command1;
65 m_packages[ m_numCommands ] = packages1;
66 ++m_numCommands;
67 }
68 if ( command2 != OPackage::NotDefined )
69 {
70 m_command[ m_numCommands ] = command2;
71 m_packages[ m_numCommands ] = packages2;
72 ++m_numCommands;
73 }
74 if ( command3 != OPackage::NotDefined )
75 {
76 m_command[ m_numCommands ] = command3;
77 m_packages[ m_numCommands ] = packages3;
78 ++m_numCommands;
79 }
80
81 // Initialize UI
82 if ( parent )
83 parent->setCaption( caption );
84
85 QGridLayout *layout = new QGridLayout( this, 4, 2, 2, 4 );
86
87 if ( showDestInfo )
88 {
89 QLabel *label = new QLabel( tr( "Destination" ), this );
90 layout->addWidget( label, 0, 0 );
91 m_destination = new QComboBox( this );
92 m_destination->insertStringList( *(m_packman->destinations()) );
93 layout->addWidget( m_destination, 0, 1 );
94 connect( m_destination, SIGNAL(highlighted(const QString&)),
95 this, SLOT(slotDisplayAvailSpace(const QString&)) );
96
97 label = new QLabel( tr( "Space Avail" ), this );
98 layout->addWidget( label, 1, 0 );
99 m_availSpace = new QLabel( this );
100 layout->addWidget( m_availSpace, 1, 1 );
101
102 // TODO - select correct destination
103 slotDisplayAvailSpace( m_destination->currentText() );
104 }
105 else
106 {
107 m_destination = 0x0;
108 m_availSpace = 0x0;
109 }
110
111 QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this );
112 groupBox->layout()->setSpacing( 0 );
113 groupBox->layout()->setMargin( 4 );
114
115 QVBoxLayout *groupBoxLayout = new QVBoxLayout( groupBox->layout() );
116 m_output = new QMultiLineEdit( groupBox );
117 m_output->setReadOnly( true );
118 groupBoxLayout->addWidget( m_output );
119 layout->addMultiCellWidget( groupBox, 2, 2, 0, 1 );
120
121 m_btnStart = new QPushButton( Resource::loadPixmap( "packagemanager/apply" ), tr( "Start" ), this );
122 layout->addWidget( m_btnStart, 3, 0 );
123 connect( m_btnStart, SIGNAL(clicked()), this, SLOT(slotBtnStart()) );
124
125 m_btnOptions = new QPushButton( Resource::loadPixmap( "SettingsIcon" ), tr( "Options" ), this );
126 layout->addWidget( m_btnOptions, 3, 1 );
127 connect( m_btnOptions, SIGNAL( clicked() ), this, SLOT(slotBtnOptions()) );
128
129 // Display packages being acted upon in output widget
130 for( int i = 0; i < m_numCommands; i++ )
131 {
132 if ( m_packages[ i ] )
133 {
134 QString lineStr = tr( "Packages to " );
135
136 switch( m_command[ i ] )
137 {
138 case OPackage::Install : lineStr.append( tr( "install" ) );
139 break;
140 case OPackage::Remove : lineStr.append( tr( "remove" ) );
141 break;
142 case OPackage::Upgrade : lineStr.append( tr( "upgrade" ) );
143 break;
144 default :
145 break;
146 };
147 lineStr.append( ":\n" );
148
149 for ( QStringList::Iterator it = m_packages[ i ]->begin(); it != m_packages[ i ]->end(); ++it )
150 {
151 lineStr.append( QString( "\t%1\n" ).arg( ( *it ) ) );
152 }
153
154 m_output->append( lineStr );
155 }
156 }
157
158 m_output->append( tr( "Press the start button to begin.\n" ) );
159 m_output->setCursorPosition( m_output->numLines(), 0 );
160
161}
162
163InstallDlg::~InstallDlg()
164{
165 for( int i = 0; i < m_numCommands; i++ )
166 {
167 if ( m_packages[ i ] )
168 delete m_packages[ i ];
169 }
170}
171
172void InstallDlg::slotDisplayAvailSpace( const QString &destination )
173{
174 // If available space is not displayed, exit
175 if ( !m_availSpace )
176 return;
177
178 QString space = tr( "Unknown" );
179
180 // Get destination
181 OConfItem *dest = m_packman->findConfItem( OConfItem::Destination, destination );
182
183 if ( dest )
184 {
185 // Calculate available space
186 struct statfs fs;
187 if ( !statfs( dest->value(), &fs ) )
188 {
189 long mult = fs.f_bsize / 1024;
190 long div = 1024 / fs.f_bsize;
191
192 if ( !mult ) mult = 1;
193 if ( !div ) div = 1;
194 long avail = fs.f_bavail * mult / div;
195
196 space = tr( "%1 Kb" ).arg( avail );
197 }
198 }
199
200 // Display available space (if known)
201 m_availSpace->setText( space );
202}
203
204void InstallDlg::slotBtnStart()
205{
206 QString btnText = m_btnStart->text();
207 if ( btnText == tr( "Abort" ) )
208 {
209 // Stop execution of current command and prevent any others from executing
210 m_packman->abortCommand();
211 m_currCommand = 999;
212
213 // Allow user to close dialog
214 m_btnStart->setText( tr( "Close" ) );
215 m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) );
216 return;
217 }
218 else if ( btnText == tr( "Close" ) )
219 {
220 // TODO - force reload of package data
221 emit closeInstallDlg();
222 return;
223 }
224
225 // Start was clicked, execute first command
226 m_btnOptions->setEnabled( false );
227 m_btnStart->setText( tr( "Abort" ) );
228 m_btnStart->setIconSet( Resource::loadPixmap( "close" ) );
229
230 m_packman->executeCommand( m_command[ 0 ], m_packages[ 0 ], m_destination->currentText(), this,
231 SLOT(slotOutput(OProcess*,char*,int)), SLOT(slotErrors(OProcess*,char*,int)),
232 SLOT(slotFinished(OProcess*)), true );
233}
234
235void InstallDlg::slotBtnOptions()
236{
237 QString btnText = m_btnOptions->text();
238 if ( btnText == tr( "Options" ) )
239 {
240 // Display configuration dialog (only options tab is enabled)
241 m_packman->configureDlg( true );
242 return;
243 }
244
245 // Save output was clicked
246 QMap<QString, QStringList> map;
247 map.insert( tr( "All" ), QStringList() );
248 QStringList text;
249 text << "text/*";
250 map.insert(tr( "Text" ), text );
251 text << "*";
252 map.insert( tr( "All" ), text );
253
254 QString filename = OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map );
255 if( !filename.isEmpty() )
256 {
257 QString currentFileName = QFileInfo( filename ).fileName();
258 DocLnk doc;
259 doc.setType( "text/plain" );
260 doc.setFile( filename );
261 doc.setName( currentFileName );
262 FileManager fm;
263 fm.saveFile( doc, m_output->text() );
264 }
265}
266
267void InstallDlg::slotOutput( OProcess */*process*/, char *buffer, int buffLen )
268{
269 QString lineStr = buffer;
270 if ( lineStr[buffLen-1] == '\n' )
271 lineStr.truncate( buffLen - 1 );
272 m_output->append( lineStr );
273 m_output->setCursorPosition( m_output->numLines(), 0 );
274}
275
276void InstallDlg::slotErrors( OProcess */*process*/, char *buffer, int buffLen )
277{
278 QString lineStr = buffer;
279 if ( lineStr[buffLen-1] == '\n' )
280 lineStr.truncate( buffLen - 1 );
281 m_output->append( lineStr );
282 m_output->setCursorPosition( m_output->numLines(), 0 );
283}
284
285void InstallDlg::slotFinished( OProcess */*process*/ )
286{
287 ++m_currCommand;
288 if ( m_currCommand < m_numCommands )
289 {
290 // More commands left, execute next one
291 m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], m_destination->currentText(),
292 this, SLOT(slotOutput(OProcess*,char*,int)),
293 SLOT(slotErrors(OProcess*,char*,int)),
294 SLOT(slotFinished(OProcess*)), true );
295 }
296 else
297 {
298 // All commands executed, allow user to close dialog
299 m_btnStart->setText( tr( "Close" ) );
300 m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) );
301
302 m_btnOptions->setEnabled( true );
303 m_btnOptions->setText( tr( "Save output" ) );
304 m_btnOptions->setIconSet( Resource::loadPixmap( "save" ) );
305 }
306}
diff --git a/noncore/settings/packagemanager/installdlg.h b/noncore/settings/packagemanager/installdlg.h
new file mode 100644
index 0000000..8075f1d
--- a/dev/null
+++ b/noncore/settings/packagemanager/installdlg.h
@@ -0,0 +1,89 @@
1/*
2                This file is part of the OPIE Project
3
4 =. Copyright (c) 2003 Dan Williams <drw@handhelds.org>
5             .=l.
6           .>+-=
7 _;:,     .>    :=|. This file is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This file is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
29
30#ifndef INSTALLDLG_H
31#define INSTALLDLG_H
32
33#include <qwidget.h>
34
35#include <opie/oprocess.h>
36
37#include "opackage.h"
38
39class QComboBox;
40class QLabel;
41class QMultiLineEdit;
42class QPushButton;
43
44class OPackageManager;
45
46class InstallDlg : public QWidget
47{
48 Q_OBJECT
49
50public:
51 InstallDlg( QWidget *parent = 0x0, OPackageManager *pm = 0x0, const QString &caption = QString::null,
52 bool showDestInfo = true,
53 OPackage::Command command1 = OPackage::NotDefined, QStringList *packages1 = 0x0,
54 OPackage::Command command2 = OPackage::NotDefined, QStringList *packages2 = 0x0,
55 OPackage::Command command3 = OPackage::NotDefined, QStringList *packages3 = 0x0 );
56 ~InstallDlg();
57
58private:
59 OPackageManager *m_packman; // Pointer to application instance of package manager
60
61 // UI controls
62 QComboBox *m_destination; // Destination selection list
63 QLabel *m_availSpace; // Text label to display available space on selected destination
64 QMultiLineEdit *m_output; // Multi-line edit to display status
65 QPushButton *m_btnStart; // Start/abort/close button
66 QPushButton *m_btnOptions; // Installation options button
67
68 // Commands and packages to execute
69 int m_numCommands; // Number of commands to be executed
70 int m_currCommand; // Number of currently executing command
71 OPackage::Command m_command[3]; // List of commands to be executed
72 QStringList *m_packages[3]; // Lists of package names associated to commands (m_command[])
73
74private slots:
75 // UI control slots
76 void slotDisplayAvailSpace( const QString &destination );
77 void slotBtnStart();
78 void slotBtnOptions();
79
80 // Execution slots
81 void slotOutput( OProcess *process, char *buffer, int buffLen );
82 void slotErrors( OProcess *process, char *buffer, int buffLen );
83 void slotFinished( OProcess *process );
84
85signals:
86 void closeInstallDlg();
87};
88
89#endif
diff --git a/noncore/settings/packagemanager/main.cpp b/noncore/settings/packagemanager/main.cpp
new file mode 100644
index 0000000..b731695
--- a/dev/null
+++ b/noncore/settings/packagemanager/main.cpp
@@ -0,0 +1,34 @@
1/*
2                This file is part of the OPIE Project
3
4 =. Copyright (c) 2003 Dan Williams <drw@handhelds.org>
5             .=l.
6           .>+-=
7 _;:,     .>    :=|. This file is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This file is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
29
30#include "mainwindow.h"
31
32#include <opie/oapplicationfactory.h>
33
34OPIE_EXPORT_APP( OApplicationFactory<MainWindow> )
diff --git a/noncore/settings/packagemanager/mainwindow.cpp b/noncore/settings/packagemanager/mainwindow.cpp
new file mode 100644
index 0000000..311b5fc
--- a/dev/null
+++ b/noncore/settings/packagemanager/mainwindow.cpp
@@ -0,0 +1,667 @@
1/*
2                This file is part of the OPIE Project
3
4 =. Copyright (c) 2003 Dan Williams <drw@handhelds.org>
5             .=l.
6           .>+-=
7 _;:,     .>    :=|. This file is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This file is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
29
30#include <qaction.h>
31#include <qlayout.h>
32#include <qlineedit.h>
33#include <qmenubar.h>
34#include <qmessagebox.h>
35#include <qpopupmenu.h>
36#include <qtimer.h>
37#include <qtoolbar.h>
38#include <qwhatsthis.h>
39
40#include <qpe/qpeapplication.h>
41#include <qpe/resource.h>
42
43#include "mainwindow.h"
44#include "installdlg.h"
45#include "filterdlg.h"
46#include "promptdlg.h"
47
48MainWindow::MainWindow( QWidget *parent, const char *name, WFlags fl )
49 : QMainWindow( parent, name, fl || WStyle_ContextHelp )
50 , m_config( "packman" )
51 , m_packman( &m_config, this )
52 , m_menuBar( this )
53 , m_toolBar( this )
54 , m_findBar( this )
55 , m_widgetStack( this )
56 , m_packageList( this )
57 , m_statusWidget( this )
58 , m_statusText( &m_statusWidget )
59 , m_statusBar( &m_statusWidget )
60 , m_iconUpdated( Resource::loadPixmap( "packagemanager/updated" ) )
61 , m_iconInstalled( Resource::loadPixmap( "installed" ) )
62 , m_iconNull( m_iconUpdated.size() )
63 , m_filterName( QString::null )
64 , m_filterServer( QString::null )
65 , m_filterDest( QString::null )
66 , m_filterStatus( OPackageManager::NotDefined )
67 , m_filterCategory( QString::null )
68
69{
70// setCaption( tr( "Package Manager" ) );
71
72 m_iconNull.fill( colorGroup().base() );
73
74 connect( &m_widgetStack, SIGNAL(aboutToShow(QWidget*)), this, SLOT(slotWidgetStackShow(QWidget*)) );
75
76 // Initialize widget stack, package list and status widget
77 initStatusWidget();
78 initPackageList();
79
80 m_widgetStack.addWidget( &m_statusWidget, 2 );
81 m_widgetStack.addWidget( &m_packageList, 1 );
82 setCentralWidget( &m_widgetStack );
83
84 // Initialize remaining user interface items
85 initUI();
86
87 // Initialize package information
88 QTimer::singleShot( 100, this, SLOT( initPackageInfo() ) );
89}
90
91void MainWindow::closeEvent( QCloseEvent *event )
92{
93 // Close app only if either the package or status widgets are currently active
94 bool close = m_widgetStack.visibleWidget() == &m_packageList ||
95 m_widgetStack.visibleWidget() == &m_statusWidget;
96 if ( close )
97 {
98 // TODO - write out application configuration settings
99
100 // Write out package manager configuration settings
101 m_packman.saveSettings();
102 event->accept();
103 }
104 else
105 {
106 delete m_widgetStack.visibleWidget();
107 m_widgetStack.raiseWidget( &m_packageList );
108 event->ignore();
109 }
110}
111
112void MainWindow::initPackageList()
113{
114 m_packageList.addColumn( tr( "Packages" ) );
115 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\nClick inside the box at the left to select a package." ) );
116 QPEApplication::setStylusOperation( m_packageList.viewport(), QPEApplication::RightOnHold );
117}
118
119void MainWindow::initStatusWidget()
120{
121 QVBoxLayout *layout = new QVBoxLayout( &m_statusWidget, 4, 4 );
122
123 m_statusText.setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
124 layout->addWidget( &m_statusText );
125
126 connect( &m_packman, SIGNAL(initStatus(int)), this, SLOT(slotInitStatusBar(int)) );
127 connect( &m_packman, SIGNAL(statusText(const QString &)), this, SLOT(slotStatusText(const QString &)) );
128 connect( &m_packman, SIGNAL(statusBar(int)), this, SLOT(slotStatusBar(int)) );
129
130 layout->addWidget( &m_statusBar );
131}
132
133void MainWindow::initUI()
134{
135 // Build menu and tool bars
136 setToolBarsMovable( false );
137
138 m_menuBar.setHorizontalStretchable( true );
139 QMenuBar *mb = new QMenuBar( &m_menuBar );
140 mb->setMargin( 0 );
141
142 // Find toolbar
143 addToolBar( &m_findBar, QMainWindow::Top, true );
144 m_findBar.setHorizontalStretchable( true );
145 m_findEdit = new QLineEdit( &m_findBar );
146 QWhatsThis::add( m_findEdit, tr( "Type the text to search for here." ) );
147 m_findBar.setStretchableWidget( m_findEdit );
148 connect( m_findEdit, SIGNAL(textChanged(const QString &)), this, SLOT(slotFindChanged(const QString &)) );
149
150 // Packages menu
151 QPopupMenu *popup = new QPopupMenu( this );
152
153 QAction *a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "packagemanager/update" ), QString::null, 0, this, 0 );
154 a->setWhatsThis( tr( "Click here to update package lists from servers." ) );
155 connect( a, SIGNAL(activated()), this, SLOT(slotUpdate()) );
156 a->addTo( popup );
157 a->addTo( &m_toolBar );
158
159 QAction *actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "packagemanager/upgrade" ), QString::null, 0, this, 0 );
160 actionUpgrade->setWhatsThis( tr( "Click here to upgrade all installed packages if a newer version is available." ) );
161 connect( actionUpgrade, SIGNAL(activated()), this, SLOT(slotUpgrade()) );
162 actionUpgrade->addTo( popup );
163 actionUpgrade->addTo( &m_toolBar );
164
165 // Ipkg implementation does not seem to work currently? (not working in aqpkg either)
166 /*
167 QPixmap iconDownload = Resource::loadPixmap( "packagemanager/download" );
168 QPixmap iconRemove = Resource::loadPixmap( "packagemanager/remove" );
169 QAction *actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 );
170 actionDownload->setWhatsThis( tr( "Click here to download the currently selected package(s)." ) );
171 connect( actionDownload, SIGNAL(activated()), this, SLOT(slotDownload()) );
172 actionDownload->addTo( popup );
173 actionDownload->addTo( &m_toolBar );
174 */
175
176 a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "packagemanager/apply" ), QString::null, 0, this, 0 );
177 a->setWhatsThis( tr( "Click here to install, remove or upgrade currently selected package(s)." ) );
178 connect( a, SIGNAL(activated()), this, SLOT(slotApply()) );
179 a->addTo( popup );
180 a->addTo( &m_toolBar );
181
182 popup->insertSeparator();
183
184 a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 );
185 a->setWhatsThis( tr( "Click here to configure this application." ) );
186 connect( a, SIGNAL(activated()), this, SLOT(slotConfigure()) );
187 a->addTo( popup );
188 mb->insertItem( tr( "Actions" ), popup );
189
190 // View menu
191 popup = new QPopupMenu( this );
192
193 m_actionShowNotInstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 );
194 m_actionShowNotInstalled->setToggleAction( true );
195 m_actionShowNotInstalled->setWhatsThis( tr( "Click here to show packages available which have not been installed." ) );
196 connect( m_actionShowNotInstalled, SIGNAL(activated()), this, SLOT(slotShowNotInstalled()) );
197 m_actionShowNotInstalled->addTo( popup );
198
199 m_actionShowInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 );
200 m_actionShowInstalled->setToggleAction( true );
201 m_actionShowInstalled->setWhatsThis( tr( "Click here to show packages currently installed on this device." ) );
202 connect( m_actionShowInstalled, SIGNAL(activated()), this, SLOT(slotShowInstalled()) );
203 m_actionShowInstalled->addTo( popup );
204
205 m_actionShowUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 );
206 m_actionShowUpdated->setToggleAction( true );
207 m_actionShowUpdated->setWhatsThis( tr( "Click here to show packages currently installed on this device which have a newer version available." ) );
208 connect( m_actionShowUpdated, SIGNAL(activated()), this, SLOT(slotShowUpdated()) );
209 m_actionShowUpdated->addTo( popup );
210
211 popup->insertSeparator();
212
213 a = new QAction( tr( "Configure filter" ), QString::null, 0, this, 0 );
214 a->setWhatsThis( tr( "Click here to change package filter criteria." ) );
215 connect( a, SIGNAL(activated()), this, SLOT(slotFilterChange()) );
216 a->addTo( popup );
217
218 m_actionFilter = new QAction( tr( "Filter" ), Resource::loadPixmap( "packagemanager/filter" ),
219 QString::null, 0, this, 0 );
220 m_actionFilter->setToggleAction( true );
221 m_actionFilter->setWhatsThis( tr( "Click here to apply current filter." ) );
222 connect( m_actionFilter, SIGNAL(toggled(bool)), this, SLOT(slotFilter(bool)) );
223 m_actionFilter->addTo( popup );
224
225 popup->insertSeparator();
226
227 a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 );
228 a->setWhatsThis( tr( "Click here to search for text in package names." ) );
229 connect( a, SIGNAL(activated()), this, SLOT(slotFindShowToolbar()) );
230 a->addTo( popup );
231
232 m_actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 );
233 m_actionFindNext->setEnabled( false );
234 m_actionFindNext->setWhatsThis( tr( "Click here to find the next package name containing the text you are searching for." ) );
235 connect( m_actionFindNext, SIGNAL(activated()), this, SLOT(slotFindNext()) );
236 m_actionFindNext->addTo( popup );
237 m_actionFindNext->addTo( &m_findBar );
238
239 mb->insertItem( tr( "View" ), popup );
240
241 // Finish find toolbar creation
242 a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
243 a->setWhatsThis( tr( "Click here to hide the find toolbar." ) );
244 connect( a, SIGNAL(activated()), this, SLOT(slotFindHideToolbar()) );
245 a->addTo( &m_findBar );
246 m_findBar.hide();
247}
248
249void MainWindow::loadPackageList( OPackageList *packages, bool clearList )
250{
251 if ( clearList )
252 m_packageList.clear();
253
254 if ( packages )
255 {
256 for ( OPackageListIterator packageIt( *packages ); packageIt.current(); ++packageIt )
257 {
258 OPackage *package = packageIt.current();
259 QCheckListItem *item = new QCheckListItem( &m_packageList, package->name(),
260 QCheckListItem::CheckBox );
261 m_packageList.insertItem( item );
262
263 // If a different version of package is available, show update available icon
264 // Otherwise, show installed icon
265 if ( !package->versionInstalled().isNull() )
266 {
267 if ( m_packman.compareVersions( package->version(), package->versionInstalled() ) == 1 )
268 item->setPixmap( 0, m_iconUpdated );
269 else
270 item->setPixmap( 0, m_iconInstalled );
271 }
272 else
273 item->setPixmap( 0, m_iconNull );
274 }
275 }
276}
277
278void MainWindow::searchForPackage( const QString &text )
279{
280 if ( !text.isEmpty() )
281 {
282 // look through package list for text startng at current position
283 QCheckListItem *start = static_cast<QCheckListItem *>(m_packageList.currentItem());
284 if ( start == 0 )
285 start = static_cast<QCheckListItem *>(m_packageList.firstChild());
286
287// for ( QCheckListItem *item = static_cast<QCheckListItem *>(start->nextSibling()); item != 0 ;
288 for ( QCheckListItem *item = static_cast<QCheckListItem *>(start); item != 0 ;
289 item = static_cast<QCheckListItem *>(item->nextSibling()) )
290 {
291 if ( item->text().lower().find( text ) != -1 )
292 {
293 m_packageList.ensureItemVisible( item );
294 m_packageList.setCurrentItem( item );
295 break;
296 }
297 }
298 }
299}
300
301void MainWindow::initPackageInfo()
302{
303 m_widgetStack.raiseWidget( &m_statusWidget );
304
305 // Load package list
306 m_packman.loadAvailablePackages();
307 m_packman.loadInstalledPackages();
308
309 OPackageList *packageList = m_packman.packages();
310 if ( packageList )
311 {
312 loadPackageList( packageList, true );
313 delete packageList;
314 }
315
316 m_widgetStack.raiseWidget( &m_packageList );
317}
318
319void MainWindow::slotWidgetStackShow( QWidget *widget )
320{
321 if ( widget == &m_packageList )
322 {
323 setCaption( tr( "Package Manager" ) );
324
325 m_menuBar.show();
326 m_toolBar.show();
327 }
328 else
329 {
330 m_menuBar.hide();
331 m_toolBar.hide();
332 }
333}
334
335void MainWindow::slotInitStatusBar( int numSteps )
336{
337 m_statusBar.setTotalSteps( numSteps );
338}
339
340void MainWindow::slotStatusText( const QString &status )
341{
342 m_statusText.setText( status );
343}
344
345void MainWindow::slotStatusBar( int currStep )
346{
347 m_statusBar.setProgress( currStep );
348}
349
350void MainWindow::slotUpdate()
351{
352 // Create package manager output widget
353 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Update package information" ), false,
354 OPackage::Update );
355 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseInstallDlg()) );
356
357 // Display widget
358 m_widgetStack.addWidget( dlg, 3 );
359 m_widgetStack.raiseWidget( dlg );
360}
361
362void MainWindow::slotUpgrade()
363{
364 // Create package manager output widget
365 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Upgrade installed packages" ), false,
366 OPackage::Upgrade );
367 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseInstallDlg()) );
368
369 // Display widget
370 m_widgetStack.addWidget( dlg, 3 );
371 m_widgetStack.raiseWidget( dlg );
372}
373
374 // Ipkg implementation does not seem to work currently? (not working in aqpkg either)
375/*
376void MainWindow::slotDownload()
377{
378 // Retrieve list of packages selected for download (if any)
379 QStringList *workingPackages = new QStringList();
380
381 for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild());
382 item != 0 ;
383 item = static_cast<QCheckListItem *>(item->nextSibling()) )
384 {
385 if ( item->isOn() )
386 workingPackages->append( item->text() );
387 }
388
389 if ( workingPackages->isEmpty() )
390 {
391 // No packages were selected, prompt for URL of package to download
392 }
393 else
394 {
395 // Download selected packages
396 m_config.setGroup( "settings" );
397 QString workingDir = m_config.readEntry( "DownloadDir", "/tmp" );
398
399// QString text = InputDialog::getText( tr( "Download to where" ), tr( "Enter path to download to" ), workingDir, &ok, this );
400// if ( ok && !text.isEmpty() )
401// workingDir = text; // user entered something and pressed ok
402// else
403// return; // user entered nothing or pressed cancel
404
405// // Store download directory in config file
406// m_config.writeEntry( "DownloadDir", workingDir );
407
408 // Get starting directory
409// char initDir[PATH_MAX];
410// getcwd( initDir, PATH_MAX );
411
412 // Download packages
413
414 }
415
416 // Create package manager output widget
417 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Download packages" ), false,
418 OPackage::Download, workingPackages );
419 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseInstallDlg()) );
420
421 // Display widget
422 m_widgetStack.addWidget( dlg, 3 );
423 m_widgetStack.raiseWidget( dlg );
424}
425*/
426
427void MainWindow::slotApply()
428{
429 QStringList *removeList = 0x0;
430 QStringList *installList = 0x0;
431 QStringList *upgradeList = 0x0;
432
433 for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild());
434 item != 0 ;
435 item = static_cast<QCheckListItem *>(item->nextSibling()) )
436 {
437 if ( item->isOn() )
438 {
439 OPackage *package = m_packman.findPackage( item->text() );
440 if ( package )
441 {
442 if ( !package->versionInstalled().isNull() )
443 {
444 if ( m_packman.compareVersions( package->version(), package->versionInstalled() ) == 1 )
445 {
446 // Remove/upgrade package
447 int answer = PromptDlg::ask( tr( "Remove or upgrade" ),
448 tr( QString( "Do you wish to remove or upgrade\n%1?" ).arg( item->text() ) ),
449 tr( "Remove" ), tr( "Upgrade" ), this );
450 if ( answer == 1 ) // Remove
451 {
452 if ( !removeList )
453 removeList = new QStringList();
454 removeList->append( item->text() );
455 }
456 else if ( answer == 2 ) // Upgrade
457 {
458 if ( !upgradeList )
459 upgradeList = new QStringList();
460 upgradeList->append( item->text() );
461 }
462 }
463 else
464 {
465 // Remove/reinstall package
466 int answer = PromptDlg::ask( tr( "Remove or reinstall" ),
467 tr( QString( "Do you wish to remove or reinstall\n%1?" ).arg( item->text() ) ),
468 tr( "Remove" ), tr( "Reinstall" ), this );
469 if ( answer == 1 ) // Remove
470 {
471 if ( !removeList )
472 removeList = new QStringList();
473 removeList->append( item->text() );
474 }
475 else if ( answer == 2 ) // Reinstall
476 {
477 if ( !installList )
478 installList = new QStringList();
479 installList->append( item->text() );
480 }
481 }
482 }
483 else
484 {
485 // Install package
486 if ( !installList )
487 installList = new QStringList();
488 installList->append( item->text() );
489 }
490 }
491 }
492 }
493
494 // If nothing is selected, display message and exit
495 if ( !removeList && !installList && !upgradeList )
496 {
497 QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) );
498 return;
499 }
500
501 // Send command only if there are packages to process
502 OPackage::Command removeCmd = OPackage::NotDefined;
503 if ( removeList && !removeList->isEmpty() )
504 removeCmd = OPackage::Remove;
505 OPackage::Command installCmd = OPackage::NotDefined;
506 if ( installList && !installList->isEmpty() )
507 installCmd = OPackage::Install;
508 OPackage::Command upgradeCmd = OPackage::NotDefined;
509 if ( upgradeList && !upgradeList->isEmpty() )
510 upgradeCmd = OPackage::Upgrade;
511
512 // Create package manager output widget
513 InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Apply changes" ), true,
514 removeCmd, removeList,
515 installCmd, installList,
516 upgradeCmd, upgradeList );
517 connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseInstallDlg()) );
518
519 // Display widget
520 m_widgetStack.addWidget( dlg, 3 );
521 m_widgetStack.raiseWidget( dlg );
522}
523
524void MainWindow::slotCloseInstallDlg()
525{
526 // Close install dialog
527 delete m_widgetStack.visibleWidget();
528
529 // Reload package list
530 initPackageInfo();
531}
532
533void MainWindow::slotConfigure()
534{
535 if ( m_packman.configureDlg( false ) )
536 {
537 if ( PromptDlg::ask( tr( "Config updated" ),
538 tr( "The configuration has been updated. Do you want to update server and package information now?" ),
539 tr( "Yes" ), tr( "No" ), this ) == 1 )
540 {
541 // Update package list and reload package info
542 slotUpdate();
543 }
544 }
545}
546
547void MainWindow::slotShowNotInstalled()
548{
549 OPackageList *packageList;
550 if ( m_actionShowNotInstalled->isOn() )
551 {
552 m_actionShowInstalled->setOn( false );
553 m_actionShowUpdated->setOn( false );
554 packageList = m_packman.filterPackages( QString::null, QString::null, QString::null,
555 OPackageManager::NotInstalled, QString::null );
556 }
557 else
558 packageList = m_packman.packages();
559
560 if ( packageList )
561 {
562 loadPackageList( packageList, true );
563 delete packageList;
564 }
565}
566
567void MainWindow::slotShowInstalled()
568{
569 OPackageList *packageList;
570 if ( m_actionShowInstalled->isOn() )
571 {
572 m_actionShowNotInstalled->setOn( false );
573 m_actionShowUpdated->setOn( false );
574 packageList = m_packman.filterPackages( QString::null, QString::null, QString::null,
575 OPackageManager::Installed, QString::null );
576 }
577 else
578 packageList = m_packman.packages();
579
580 if ( packageList )
581 {
582 loadPackageList( packageList, true );
583 delete packageList;
584 }
585}
586
587void MainWindow::slotShowUpdated()
588{
589 OPackageList *packageList;
590 if ( m_actionShowUpdated->isOn() )
591 {
592 m_actionShowInstalled->setOn( false );
593 m_actionShowNotInstalled->setOn( false );
594 packageList = m_packman.filterPackages( QString::null, QString::null, QString::null,
595 OPackageManager::Updated, QString::null );
596 }
597 else
598 packageList = m_packman.packages();
599
600 if ( packageList )
601 {
602 loadPackageList( packageList, true );
603 delete packageList;
604 }
605}
606
607void MainWindow::slotFilterChange()
608{
609 FilterDlg dlg( this, &m_packman, m_filterName, m_filterServer, m_filterDest, m_filterStatus,
610 m_filterCategory );
611 if ( dlg.exec() == QDialog::Accepted )
612 {
613 m_filterName = dlg.name();
614 m_filterServer = dlg.server();
615 m_filterDest = dlg.destination();
616 m_filterStatus = dlg.status();
617 m_filterCategory = dlg.category();
618 m_actionFilter->setOn( true );
619 slotFilter( true );
620 }
621 else
622 {
623 m_actionFilter->setOn( false );
624 slotFilter( false );
625 }
626}
627
628void MainWindow::slotFilter( bool isOn )
629{
630 OPackageList *packageList;
631 if ( isOn )
632 {
633 packageList = m_packman.filterPackages( m_filterName, m_filterServer, m_filterDest,
634 m_filterStatus, m_filterCategory );
635 }
636 else
637 packageList = m_packman.packages();
638
639 if ( packageList )
640 {
641 loadPackageList( packageList, true );
642 delete packageList;
643 }
644}
645
646void MainWindow::slotFindShowToolbar()
647{
648 m_findBar.show();
649 m_findEdit->setFocus();
650}
651
652void MainWindow::slotFindHideToolbar()
653{
654 m_findBar.hide();
655}
656
657void MainWindow::slotFindChanged( const QString &findText )
658{
659
660 m_actionFindNext->setEnabled( !findText.isEmpty() );
661 searchForPackage( findText );
662}
663
664void MainWindow::slotFindNext()
665{
666 searchForPackage( m_findEdit->text() );
667}
diff --git a/noncore/settings/packagemanager/mainwindow.h b/noncore/settings/packagemanager/mainwindow.h
new file mode 100644
index 0000000..49bb66c
--- a/dev/null
+++ b/noncore/settings/packagemanager/mainwindow.h
@@ -0,0 +1,136 @@
1/*
2                This file is part of the OPIE Project
3
4 =. Copyright (c) 2003 Dan Williams <drw@handhelds.org>
5             .=l.
6           .>+-=
7 _;:,     .>    :=|. This file is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This file is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
29
30#ifndef MAINWINDOW_H
31#define MAINWINDOW_H
32
33#include <qlabel.h>
34#include <qlistview.h>
35#include <qmainwindow.h>
36#include <qpixmap.h>
37#include <qprogressbar.h>
38#include <qtoolbar.h>
39#include <qwidgetstack.h>
40
41#include <qpe/config.h>
42
43#include "opackagemanager.h"
44
45class QAction;
46class QLineEdit;
47
48class MainWindow :public QMainWindow
49{
50 Q_OBJECT
51
52public:
53 MainWindow( QWidget *parent = 0x0, const char *name = 0x0, WFlags fl = 0 );
54 static QString appName() { return QString::fromLatin1( "packagemanager" ); };
55
56protected:
57 void closeEvent( QCloseEvent *event );
58
59private:
60 Config m_config; // Configuration file
61
62 OPackageManager m_packman; // Package manager
63
64 // Toolbars
65 QToolBar m_menuBar; // Main toolbar containing menu
66 QToolBar m_toolBar; // Main toolbar
67 QToolBar m_findBar; // Find toolbar
68
69 QWidgetStack m_widgetStack; // Main widget stack which contains m_packageList & m_statusWidget
70 QListView m_packageList; // Main list view of all packages
71
72 QLineEdit *m_findEdit; // Line edit box used for find toolbar
73
74 // Status widget controls
75 QWidget m_statusWidget; // Widget to display status during long operations
76 QLabel m_statusText; // Text status message
77 QProgressBar m_statusBar; // Progress bar showing % completed
78
79 // Icon pixmaps
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
82 QPixmap m_iconNull; // Cached icon which shows when package is not installed
83
84 // Menu/tool bar actions
85 QAction *m_actionShowNotInstalled; // Action to show pakages not 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
88 QAction *m_actionFilter; // Action to filter packages
89 QAction *m_actionFindNext; // Action to find next match
90
91 // Cached filter settings
92 QString m_filterName; // Cached name filter value
93 QString m_filterServer; // Cached server name filter value
94 QString m_filterDest; // Cached destination name filter value
95 OPackageManager::Status m_filterStatus; // Cached status filter value
96 QString m_filterCategory; // Cached category filter value
97
98 void initPackageList();
99 void initStatusWidget();
100 void initUI();
101
102 void loadPackageList( OPackageList *packages = 0x0, bool clearList = true );
103 void searchForPackage( const QString &text );
104
105private slots:
106 void initPackageInfo();
107 void slotWidgetStackShow( QWidget *widget );
108
109 // Status widget slots
110 void slotInitStatusBar( int numSteps );
111 void slotStatusText( const QString &status );
112 void slotStatusBar( int currStep );
113
114 // Actions menu action slots
115 void slotUpdate();
116 void slotUpgrade();
117// void slotDownload();
118 void slotApply();
119 void slotCloseInstallDlg();
120 void slotConfigure();
121
122 // View menu action slots
123 void slotShowNotInstalled();
124 void slotShowInstalled();
125 void slotShowUpdated();
126 void slotFilterChange();
127 void slotFilter( bool isOn );
128
129 // Find action slots
130 void slotFindShowToolbar();
131 void slotFindHideToolbar();
132 void slotFindChanged( const QString &findText );
133 void slotFindNext();
134};
135
136#endif
diff --git a/noncore/settings/packagemanager/oconfitem.cpp b/noncore/settings/packagemanager/oconfitem.cpp
new file mode 100644
index 0000000..940a6de
--- a/dev/null
+++ b/noncore/settings/packagemanager/oconfitem.cpp
@@ -0,0 +1,42 @@
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#include "oconfitem.h"
33
34OConfItem::OConfItem( const QString &location, Type type, const QString &name,
35 const QString &value, bool active )
36 : m_location( location )
37 , m_type( type )
38 , m_name( name )
39 , m_value( value )
40 , m_active( active )
41{
42}
diff --git a/noncore/settings/packagemanager/oconfitem.h b/noncore/settings/packagemanager/oconfitem.h
new file mode 100644
index 0000000..aeee511
--- a/dev/null
+++ b/noncore/settings/packagemanager/oconfitem.h
@@ -0,0 +1,95 @@
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 OCONFITEM_H
33#define OCONFITEM_H
34
35#include <qlist.h>
36#include <qstring.h>
37
38class OConfItem
39{
40public:
41 enum Type { Source, Destination, Option, Arch, NotDefined };
42
43 OConfItem( const QString &location = 0x0, Type type = NotDefined, const QString &name = 0x0,
44 const QString &value = 0x0, bool active = true );
45
46 const QString &location() { return m_location; }
47 Type type() { return m_type; }
48 const QString &name() { return m_name; }
49 const QString &value() { return m_value; }
50 bool active() { return m_active; }
51
52 void setLocation( const QString &location ) { m_location = location; }
53 void setType( Type type ) { m_type = type; }
54 void setName( const QString &name ) { m_name = name; }
55 void setValue( const QString &value ) { m_value = value; }
56 void setActive( bool active ) { m_active = active; }
57
58private:
59 QString m_location; // Configuration file where item is located
60 Type m_type; // Type of configuration item
61 QString m_name; // Name of item
62 QString m_value; // Value of item
63 bool m_active; // Indicates whether item is currently active
64};
65
66class OConfItemList : public QList<OConfItem>
67{
68private:
69
70 int compareItems( QCollection::Item item1, QCollection::Item item2 )
71 {
72 // Sort by OConfItem location then by type
73 QString loc1 = reinterpret_cast<OConfItem*>(item1)->location();
74 QString loc2 = reinterpret_cast<OConfItem*>(item2)->location();
75 if ( loc1 < loc2 )
76 return -1;
77 else if ( loc1 == loc2 )
78 {
79 OConfItem::Type type1 = reinterpret_cast<OConfItem*>(item1)->type();
80 OConfItem::Type type2 = reinterpret_cast<OConfItem*>(item2)->type();
81 if ( type1 < type2 )
82 return -1;
83 else if ( type1 == type2 )
84 return 0;
85 else /*if ( type1 > type2 )*/
86 return 1;
87 }
88 else /*if ( loc1 > loc2 )*/
89 return 1;
90 }
91};
92
93typedef QListIterator<OConfItem> OConfItemListIterator;
94
95#endif
diff --git a/noncore/settings/packagemanager/oipkg.cpp b/noncore/settings/packagemanager/oipkg.cpp
new file mode 100644
index 0000000..13f3d7d
--- a/dev/null
+++ b/noncore/settings/packagemanager/oipkg.cpp
@@ -0,0 +1,505 @@
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#include "oipkg.h"
33
34#include <stdio.h>
35
36#include <qdir.h>
37#include <qfile.h>
38#include <qtextstream.h>
39
40#include <opie/oprocess.h>
41
42const QString IPKG_EXEC = "ipkg"; // Fully-qualified name of Ipkg executable
43const QString IPKG_CONF = "/etc/ipkg.conf"; // Fully-qualified name of Ipkg primary configuration file
44const QString IPKG_CONF_DIR = "/etc/ipkg"; // Directory of secondary Ipkg configuration files
45const QString IPKG_PKG_PATH = "/usr/lib/ipkg/lists"; // Directory containing server package lists
46const QString IPKG_STATUS_PATH = "usr/lib/ipkg/status"; // Destination status file location
47
48OIpkg::OIpkg( Config *config, QObject *parent, const char *name )
49 : QObject( parent, name )
50 , m_config( config )
51 , m_ipkgExec( IPKG_EXEC ) // TODO - find executable?
52 , m_confInfo( NULL )
53 , m_ipkgExecOptions( 0 )
54 , m_ipkgExecVerbosity( 1 )
55 , m_ipkgProcess( NULL )
56{
57}
58
59OIpkg::~OIpkg()
60{
61 // Upon destruction, ensure that items in config list are deleted with list
62 if ( m_confInfo )
63 m_confInfo->setAutoDelete( true );
64
65 // Terminate any running ipkg processes
66 if ( m_ipkgProcess )
67 delete m_ipkgProcess;
68}
69
70OConfItemList *OIpkg::configItems()
71{
72 // Retrieve all configuration items
73 return filterConfItems();
74}
75
76OConfItemList *OIpkg::servers()
77{
78 // Retrieve only servers
79 return filterConfItems( OConfItem::Source );
80}
81
82OConfItemList *OIpkg::destinations()
83{
84 // Retrieve only destinations
85 return filterConfItems( OConfItem::Destination );
86}
87
88OConfItemList *OIpkg::options()
89{
90 // Retrieve only destinations
91 return filterConfItems( OConfItem::Option );
92}
93
94void OIpkg::setConfigItems( OConfItemList *configList )
95{
96 if ( m_confInfo )
97 delete m_confInfo;
98
99 m_confInfo = configList;
100}
101
102void OIpkg::saveSettings()
103{
104 // Save Ipkg execution options to application configuration file
105 if ( m_config )
106 {
107 m_config->setGroup( "Ipkg" );
108 m_config->writeEntry( "ExecOptions", m_ipkgExecOptions );
109 m_config->writeEntry( "Verbosity", m_ipkgExecVerbosity );
110 }
111}
112
113OPackageList *OIpkg::availablePackages( const QString &server )
114{
115 // Load Ipkg configuration info if not already cached
116 if ( !m_confInfo )
117 loadConfiguration();
118
119 // Build new server list (caller is responsible for deleting)
120 OPackageList *pl = new OPackageList;
121
122 // Open package list file
123 QFile f( IPKG_PKG_PATH + "/" + server );
124 if ( !f.open( IO_ReadOnly ) )
125 return NULL;
126 QTextStream t( &f );
127
128 // Process all information in package list file
129 OPackage *package = NULL;
130 QString line = t.readLine();
131 while ( !t.eof() )
132 {
133 // Determine key/value pair
134 int pos = line.find( ':', 0 );
135 QString key;
136 if ( pos > -1 )
137 key = line.mid( 0, pos );
138 else
139 key = QString::null;
140 QString value = line.mid( pos+2, line.length()-pos );
141
142 // Allocate new package and insert into list
143 if ( package == NULL && !key.isEmpty() )
144 {
145 package = new OPackage( value );
146 package->setSource( server );
147 pl->append( package );
148 }
149
150 // Update package data
151 if ( key == "Package" )
152 package->setName( value );
153 else if ( key == "Version" )
154 package->setVersion( value );
155 else if ( key == "Section" )
156 package->setCategory( value );
157 //DataManager::setAvailableCategories( value );
158 else if ( key.isEmpty() && value.isEmpty() )
159 package = NULL;
160
161 // Skip past all description lines
162 if ( key == "Description" )
163 {
164 line = t.readLine();
165 while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() )
166 line = t.readLine();
167 }
168 else
169 line = t.readLine();
170 }
171
172 f.close();
173
174 return pl;
175}
176
177OPackageList *OIpkg::installedPackages( const QString &destName, const QString &destPath )
178{
179 // Load Ipkg configuration info if not already cached
180 if ( !m_confInfo )
181 loadConfiguration();
182
183 // Build new server list (caller is responsible for deleting)
184 OPackageList *pl = new OPackageList;
185
186 // Open status file
187 QString path = destPath;
188 if ( path.right( 1 ) != "/" )
189 path.append( "/" );
190 path.append( IPKG_STATUS_PATH );
191
192 QFile f( path );
193 if ( !f.open( IO_ReadOnly ) )
194 return NULL;
195 QTextStream t( &f );
196
197 // Process all information in status file
198 bool newPackage = false;
199 QString line = t.readLine();
200 QString name;
201 QString version;
202 QString status;
203
204 while ( !t.eof() )
205 {
206 // Determine key/value pair
207 int pos = line.find( ':', 0 );
208 QString key;
209 if ( pos > -1 )
210 key = line.mid( 0, pos );
211 else
212 key = QString::null;
213 QString value = line.mid( pos+2, line.length()-pos );
214
215 // Allocate new package and insert into list
216 if ( newPackage && !key.isEmpty() )
217 {
218 // Add to list only if it has a valid name and is installed
219 if ( !name.isNull() && status.contains( " installed" ) )
220 {
221 pl->append( new OPackage( name, QString::null, version, QString::null, destName ) );
222 name = QString::null;
223 version = QString::null;
224 status = QString::null;
225
226 newPackage = false;
227 }
228 }
229
230 // Update package data
231 if ( key == "Package" )
232 name = value;
233 else if ( key == "Version" )
234 version = value;
235 else if ( key == "Status" )
236 status = value;
237 else if ( key.isEmpty() && value.isEmpty() )
238 newPackage = true;
239
240 // Skip past all description lines
241 if ( key == "Description" )
242 {
243 line = t.readLine();
244 while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() )
245 line = t.readLine();
246 }
247 else
248 line = t.readLine();
249 }
250
251 f.close();
252
253 return pl;
254}
255
256bool OIpkg::executeCommand( OPackage::Command command, QStringList *parameters, const QString &destination,
257 const QObject *receiver, const char *slotOutput, const char *slotErrors,
258 const char *slotFinished, bool rawOutput )
259{
260 if ( command == OPackage::NotDefined )
261 return false;
262
263 // Set up command line for execution
264 QStringList cmdLine;
265 cmdLine.append( IPKG_EXEC );
266
267 QString verbosity( "-V" );
268 verbosity.append( QString::number( m_ipkgExecVerbosity ) );
269 cmdLine.append( verbosity );
270
271 // Determine Ipkg execution options
272 if ( command == OPackage::Install && destination != QString::null )
273 {
274 // TODO - Set destination for installs
275 cmdLine.append( "-dest" );
276 cmdLine.append( destination );
277 }
278
279 if ( command != OPackage::Update && command != OPackage::Download )
280 {
281 if ( m_ipkgExecOptions & FORCE_DEPENDS )
282 cmdLine.append( "-force-depends" );
283 if ( m_ipkgExecOptions & FORCE_REINSTALL )
284 cmdLine.append( "-force-reinstall" );
285 if ( m_ipkgExecOptions & FORCE_REMOVE )
286 cmdLine.append( "-force-removal-of-essential-packages" );
287 if ( m_ipkgExecOptions & FORCE_OVERWRITE )
288 cmdLine.append( "-force-overwrite" );
289 if ( m_ipkgExecVerbosity == 3 )
290 cmdLine.append( "-verbose_wget" );
291
292 // TODO
293 // Handle make links
294 // Rules - If make links is switched on, create links to root
295 // if destDir is NOT /
296 /*
297 if ( m_ipkgExecOptions & MAKE_LINKS )
298 {
299 // If destDir == / turn off make links as package is being insalled
300 // to root already.
301 if ( destDir == "/" )
302 m_ipkgExecOptions ^= MAKE_LINKS;
303 }
304 */
305 }
306
307 QString cmd;
308 switch( command )
309 {
310 case OPackage::Install: cmd = "install";
311 break;
312 case OPackage::Remove: cmd = "remove";
313 break;
314 case OPackage::Update: cmd = "update";
315 break;
316 case OPackage::Upgrade: cmd = "upgrade";
317 break;
318 case OPackage::Download: cmd = "download";
319 break;
320 case OPackage::Info: cmd = "info";
321 break;
322 case OPackage::Files: cmd = "files";
323 break;
324 //case OPackage::Version: cmd = "" );
325 // break;
326 default:
327 break;
328 };
329 cmdLine.append( cmd );
330
331 // TODO
332 // If we are removing, reinstalling or upgrading packages and make links option is selected
333 // create the links
334/*
335 if ( command == Remove || command == Upgrade )
336 {
337 createLinks = false;
338 if ( flags & MAKE_LINKS )
339 {
340 emit outputText( tr( "Removing symbolic links...\n" ) );
341 linkPackage( Utils::getPackageNameFromIpkFilename( package ), destination, destDir );
342 emit outputText( QString( " " ) );
343 }
344 }
345*/
346 // Append package list (if any) to end of command line
347 if ( parameters && !parameters->isEmpty() )
348 {
349 for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it )
350 {
351 cmdLine.append( *it );
352 }
353 }
354
355 // Create OProcess
356 if ( m_ipkgProcess )
357 delete m_ipkgProcess;
358 m_ipkgProcess = new OProcess( cmdLine, this );
359
360 // Connect signals (if any)
361 if ( receiver )
362 {
363 if ( rawOutput )
364 {
365 if ( slotOutput )
366 connect( m_ipkgProcess, SIGNAL(receivedStdout(OProcess*,char*,int)), receiver, slotOutput );
367 if ( slotErrors )
368 connect( m_ipkgProcess, SIGNAL(receivedStderr(OProcess*,char*,int)), receiver, slotErrors );
369 if ( slotFinished )
370 connect( m_ipkgProcess, SIGNAL(processExited(OProcess*)), receiver, slotFinished );
371 }
372 else // !rawOutput
373 {
374 // TODO - how should it handle partial lines? (i.e. "Installing opi", "e-aqpkg...")
375 }
376 }
377
378 // Run process
379printf( "Running: \'%s\'\n", cmdLine.join( " " ).latin1() );
380 return m_ipkgProcess->start( OProcess::NotifyOnExit, OProcess::All );
381}
382
383void OIpkg::abortCommand()
384{
385 if ( m_ipkgProcess )
386 delete m_ipkgProcess;
387}
388
389void OIpkg::loadConfiguration()
390{
391 if ( m_confInfo )
392 delete m_confInfo;
393
394 // Load configuration item list
395 m_confInfo = new OConfItemList();
396
397 QStringList confFiles;
398 QDir confDir( IPKG_CONF_DIR );
399 if ( confDir.exists() )
400 {
401 confDir.setNameFilter( "*.conf" );
402 confDir.setFilter( QDir::Files );
403 confFiles = confDir.entryList( "*.conf", QDir::Files );
404 confFiles << IPKG_CONF;
405
406 for ( QStringList::Iterator it = confFiles.begin(); it != confFiles.end(); ++it )
407 {
408 // Create absolute file path if necessary
409 QString absFile = (*it);
410 if ( !absFile.startsWith( "/" ) )
411 absFile.prepend( QString( IPKG_CONF_DIR ) + "/" );
412
413 // Read in file
414 QFile f( absFile );
415 if ( f.open( IO_ReadOnly ) )
416 {
417 QTextStream s( &f );
418 while ( !s.eof() )
419 {
420
421 QString line = s.readLine().simplifyWhiteSpace();
422
423 // Parse line and save info to the conf options list
424 if ( !line.isEmpty() )
425 {
426 if ( !line.startsWith( "#" ) ||
427 line.startsWith( "#src" ) ||
428 line.startsWith( "#dest" ) ||
429 line.startsWith( "#arch" ) ||
430 line.startsWith( "#option" ) )
431 {
432 int pos = line.find( ' ', 1 );
433
434 // Type
435 QString typeStr = line.left( pos );
436 OConfItem::Type type;
437 if ( typeStr == "src" || typeStr == "#src" )
438 type = OConfItem::Source;
439 else if ( typeStr == "dest" || typeStr == "#dest" )
440 type = OConfItem::Destination;
441 else if ( typeStr == "option" || typeStr == "#option" )
442 type = OConfItem::Option;
443 else if ( typeStr == "arch" || typeStr == "#arch" )
444 type = OConfItem::Arch;
445 else
446 type = OConfItem::NotDefined;
447 ++pos;
448 int endpos = line.find( ' ', pos );
449
450 // Name
451 QString name = line.mid( pos, endpos - pos );
452
453 // Value
454 QString value = "";
455 if ( endpos > -1 )
456 value = line.right( line.length() - endpos - 1 );
457
458 // Active
459 bool active = !line.startsWith( "#" );
460
461 // Add to list
462 m_confInfo->append( new OConfItem( absFile, type, name, value, active ) );
463 }
464 }
465 }
466
467 f.close();
468 }
469 }
470 }
471
472 // Load Ipkg execution options from application configuration file
473 if ( m_config )
474 {
475 m_config->setGroup( "Ipkg" );
476 m_ipkgExecOptions = m_config->readNumEntry( "ExecOptions", m_ipkgExecOptions );
477 m_ipkgExecVerbosity = m_config->readNumEntry( "Verbosity", m_ipkgExecVerbosity );
478 }
479}
480
481OConfItemList *OIpkg::filterConfItems( OConfItem::Type typefilter )
482{
483 // Load Ipkg configuration info if not already cached
484 if ( !m_confInfo )
485 loadConfiguration();
486
487 // Build new server list (caller is responsible for deleting)
488 OConfItemList *sl = new OConfItemList;
489
490 // If typefilter is empty, retrieve all items
491 bool retrieveAll = ( typefilter == OConfItem::NotDefined );
492
493 // Parse configuration info for servers
494 OConfItemListIterator it( *m_confInfo );
495 for ( ; it.current(); ++it )
496 {
497 OConfItem *item = it.current();
498 if ( retrieveAll || item->type() == typefilter )
499 {
500 sl->append( item );
501 }
502 }
503
504 return sl;
505}
diff --git a/noncore/settings/packagemanager/oipkg.h b/noncore/settings/packagemanager/oipkg.h
new file mode 100644
index 0000000..4065f48
--- a/dev/null
+++ b/noncore/settings/packagemanager/oipkg.h
@@ -0,0 +1,100 @@
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 OIPKG_H
33#define OIPKG_H
34
35#include <qobject.h>
36
37#include <qpe/config.h>
38
39#include "oconfitem.h"
40#include "opackage.h"
41
42// Ipkg execution options (m_ipkgExecOptions)
43#define FORCE_DEPENDS 0x0001
44#define FORCE_REMOVE 0x0002
45#define FORCE_REINSTALL 0x0004
46#define FORCE_OVERWRITE 0x0008
47
48class OConfItemList;
49class OProcess;
50
51class OIpkg : public QObject
52{
53 Q_OBJECT
54
55public:
56 OIpkg( Config *config = 0x0, QObject *parent = 0x0, const char *name = 0x0 );
57 ~OIpkg();
58
59 OConfItemList *configItems();
60 OConfItemList *servers();
61 OConfItemList *destinations();
62 OConfItemList *options();
63
64 int ipkgExecOptions() { return m_ipkgExecOptions; }
65 int ipkgExecVerbosity() { return m_ipkgExecVerbosity; }
66
67 void setConfigItems( OConfItemList *configList );
68 void setIpkgExecOptions( int options ) { m_ipkgExecOptions = options; }
69 void setIpkgExecVerbosity( int verbosity ) { m_ipkgExecVerbosity = verbosity; }
70
71 void saveSettings();
72
73 OPackageList *availablePackages( const QString &server = QString::null );
74 OPackageList *installedPackages( const QString &destName = QString::null,
75 const QString &destPath = QString::null );
76
77 bool executeCommand( OPackage::Command command = OPackage::NotDefined, QStringList *parameters = 0x0,
78 const QString &destination = QString::null, const QObject *receiver = 0x0,
79 const char *slotOutput = 0x0, const char *slotErrors = 0x0,
80 const char *slotFinished = 0x0, bool rawOutput = true );
81 void abortCommand();
82
83private:
84 Config *m_config; // Pointer to application configuration file
85 QString m_ipkgExec; // Fully qualified path/filename of ipkg binary
86 OConfItemList *m_confInfo; // Contains info from all Ipkg configuration files
87 int m_ipkgExecOptions; // Bit-mapped flags for Ipkg execution options
88 int m_ipkgExecVerbosity; // Ipkg execution verbosity level
89 OProcess *m_ipkgProcess; // Pointer to process which Ipkg will run in
90
91 void loadConfiguration();
92 OConfItemList *filterConfItems( OConfItem::Type typefilter = OConfItem::NotDefined );
93
94signals:
95 void execOutput( OProcess *process, char *buffer, int length );
96 void execErrors( OProcess *process, char *buffer, int length );
97 void execFinished( OProcess *process, char *buffer, int length );
98};
99
100#endif
diff --git a/noncore/settings/packagemanager/oipkgconfigdlg.cpp b/noncore/settings/packagemanager/oipkgconfigdlg.cpp
new file mode 100644
index 0000000..e335f8f
--- a/dev/null
+++ b/noncore/settings/packagemanager/oipkgconfigdlg.cpp
@@ -0,0 +1,558 @@
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#include "oipkgconfigdlg.h"
33
34#include <qcheckbox.h>
35#include <qcombobox.h>
36#include <qgroupbox.h>
37#include <qlabel.h>
38#include <qlineedit.h>
39#include <qlistbox.h>
40#include <qpushbutton.h>
41#include <qscrollview.h>
42
43#include <qpe/resource.h>
44
45OIpkgConfigDlg::OIpkgConfigDlg( OIpkg *ipkg, bool installOptions, QWidget *parent )
46 : QDialog( parent, QString::null, true )
47 , m_ipkg( ipkg )
48 , m_configs( 0x0 )
49 , m_installOptions( installOptions )
50 , m_serverNew( false )
51 , m_serverCurrent( -1 )
52 , m_destNew( false )
53 , m_destCurrent( -1 )
54 , m_layout( this, 2, 4 )
55 , m_tabWidget( this )
56{
57 setCaption( tr( "Configuration" ) );
58
59 // Initialize configuration widgets
60 if ( !installOptions )
61 {
62 initServerWidget();
63 initDestinationWidget();
64 initProxyWidget();
65 }
66 initOptionsWidget();
67
68 // Load configuration information
69 initData();
70
71 // Setup tabs for all info
72 m_layout.addWidget( &m_tabWidget );
73 if ( !m_installOptions )
74 {
75 m_tabWidget.addTab( m_serverWidget, "packagemanager/servertab", tr( "Servers" ) );
76 m_tabWidget.addTab( m_destWidget, "packagemanager/desttab", tr( "Destinations" ) );
77 m_tabWidget.addTab( m_proxyWidget, "packagemanager/proxytab", tr( "Proxies" ) );
78 m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) );
79 m_tabWidget.setCurrentTab( tr( "Servers" ) );
80 }
81 else
82 {
83 m_tabWidget.addTab( m_optionsWidget, "exec", tr( "Options" ) );
84 }
85
86 showMaximized();
87}
88
89void OIpkgConfigDlg::accept()
90{
91 // Save server, destination and proxy configuration
92 if ( !m_installOptions )
93 m_ipkg->setConfigItems( m_configs );
94
95 // Save options configuration
96 int options = 0;
97 if ( m_optForceDepends->isChecked() )
98 options |= FORCE_DEPENDS;
99 if ( m_optForceReinstall->isChecked() )
100 options |= FORCE_REINSTALL;
101 if ( m_optForceRemove->isChecked() )
102 options |= FORCE_REMOVE;
103 if ( m_optForceOverwrite->isChecked() )
104 options |= FORCE_OVERWRITE;
105 m_ipkg->setIpkgExecOptions( options );
106 m_ipkg->setIpkgExecVerbosity( m_optVerboseIpkg->currentItem() );
107
108 QDialog::accept();
109}
110
111void OIpkgConfigDlg::reject()
112{
113 if ( m_configs )
114 delete m_configs;
115}
116
117void OIpkgConfigDlg::initServerWidget()
118{
119 m_serverWidget = new QWidget( this );
120
121 // Initialize UI
122 QVBoxLayout *vb = new QVBoxLayout( m_serverWidget );
123 QScrollView *sv = new QScrollView( m_serverWidget );
124 vb->addWidget( sv, 0, 0 );
125 sv->setResizePolicy( QScrollView::AutoOneFit );
126 sv->setFrameStyle( QFrame::NoFrame );
127 QWidget *container = new QWidget( sv->viewport() );
128 sv->addChild( container );
129 QGridLayout *layout = new QGridLayout( container, 3, 2, 2, 4 );
130
131 m_serverList = new QListBox( container );
132 m_serverList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
133 connect( m_serverList, SIGNAL(highlighted(int)), this, SLOT(slotServerEdit(int)) );
134 layout->addMultiCellWidget( m_serverList, 0, 0, 0, 1 );
135
136 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container );
137 connect( btn, SIGNAL(clicked()), this, SLOT(slotServerNew()) );
138 layout->addWidget( btn, 1, 0 );
139
140 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container );
141 connect( btn, SIGNAL(clicked()), this, SLOT(slotServerDelete()) );
142 layout->addWidget( btn, 1, 1 );
143
144 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container );
145 grpbox->layout()->setSpacing( 2 );
146 grpbox->layout()->setMargin( 4 );
147 layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 );
148
149 QGridLayout *grplayout = new QGridLayout( grpbox->layout() );
150
151 QLabel *label = new QLabel( tr( "Name:" ), grpbox );
152 grplayout->addWidget( label, 0, 0 );
153 m_serverName = new QLineEdit( grpbox );
154 grplayout->addWidget( m_serverName, 0, 1 );
155
156 label = new QLabel( tr( "Address:" ), grpbox );
157 grplayout->addWidget( label, 1, 0 );
158 m_serverLocation = new QLineEdit( grpbox );
159 grplayout->addWidget( m_serverLocation, 1, 1 );
160
161 m_serverActive = new QCheckBox( tr( "Active Server" ), grpbox );
162 grplayout->addMultiCellWidget( m_serverActive, 2, 2, 0, 1 );
163
164 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox );
165 connect( btn, SIGNAL(clicked()), this, SLOT(slotServerUpdate()) );
166 grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 );
167}
168
169void OIpkgConfigDlg::initDestinationWidget()
170{
171 m_destWidget = new QWidget( this );
172
173 // Initialize UI
174 QVBoxLayout *vb = new QVBoxLayout( m_destWidget );
175 QScrollView *sv = new QScrollView( m_destWidget );
176 vb->addWidget( sv, 0, 0 );
177 sv->setResizePolicy( QScrollView::AutoOneFit );
178 sv->setFrameStyle( QFrame::NoFrame );
179 QWidget *container = new QWidget( sv->viewport() );
180 sv->addChild( container );
181 QGridLayout *layout = new QGridLayout( container, 3, 2, 2, 4 );
182
183 m_destList = new QListBox( container );
184 m_destList->setSizePolicy( QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Preferred ) );
185 connect( m_destList, SIGNAL(highlighted(int)), this, SLOT(slotDestEdit(int)) );
186 layout->addMultiCellWidget( m_destList, 0, 0, 0, 1 );
187
188 QPushButton *btn = new QPushButton( Resource::loadPixmap( "new" ), tr( "New" ), container );
189 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestNew()) );
190 layout->addWidget( btn, 1, 0 );
191
192 btn = new QPushButton( Resource::loadPixmap( "trash" ), tr( "Delete" ), container );
193 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestDelete()) );
194 layout->addWidget( btn, 1, 1 );
195
196 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Server" ), container );
197 grpbox->layout()->setSpacing( 2 );
198 grpbox->layout()->setMargin( 4 );
199 layout->addMultiCellWidget( grpbox, 2, 2, 0, 1 );
200
201 QGridLayout *grplayout = new QGridLayout( grpbox->layout() );
202
203 QLabel *label = new QLabel( tr( "Name:" ), grpbox );
204 grplayout->addWidget( label, 0, 0 );
205 m_destName = new QLineEdit( grpbox );
206 grplayout->addWidget( m_destName, 0, 1 );
207
208 label = new QLabel( tr( "Address:" ), grpbox );
209 grplayout->addWidget( label, 1, 0 );
210 m_destLocation = new QLineEdit( grpbox );
211 grplayout->addWidget( m_destLocation, 1, 1 );
212
213 m_destActive = new QCheckBox( tr( "Active Server" ), grpbox );
214 grplayout->addMultiCellWidget( m_destActive, 2, 2, 0, 1 );
215
216 btn = new QPushButton( Resource::loadPixmap( "edit" ), tr( "Update" ), grpbox );
217 connect( btn, SIGNAL(clicked()), this, SLOT(slotDestUpdate()) );
218 grplayout->addMultiCellWidget( btn, 3, 3, 0, 1 );
219}
220
221void OIpkgConfigDlg::initProxyWidget()
222{
223 m_proxyWidget = new QWidget( this );
224
225 // Initialize UI
226 QVBoxLayout *vb = new QVBoxLayout( m_proxyWidget );
227 QScrollView *sv = new QScrollView( m_proxyWidget );
228 vb->addWidget( sv, 0, 0 );
229 sv->setResizePolicy( QScrollView::AutoOneFit );
230 sv->setFrameStyle( QFrame::NoFrame );
231 QWidget *container = new QWidget( sv->viewport() );
232 sv->addChild( container );
233 QGridLayout *layout = new QGridLayout( container, 4, 2, 2, 4 );
234
235 // HTTP proxy server configuration
236 QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "HTTP Proxy" ), container );
237 grpbox->layout()->setSpacing( 2 );
238 grpbox->layout()->setMargin( 4 );
239 layout->addMultiCellWidget( grpbox, 0, 0, 0, 1 );
240 QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() );
241 m_proxyHttpServer = new QLineEdit( grpbox );
242 grplayout->addWidget( m_proxyHttpServer );
243 m_proxyHttpActive = new QCheckBox( tr( "Enabled" ), grpbox );
244 grplayout->addWidget( m_proxyHttpActive );
245
246 // FTP proxy server configuration
247 grpbox = new QGroupBox( 0, Qt::Vertical, tr( "FTP Proxy" ), container );
248 grpbox->layout()->setSpacing( 2 );
249 grpbox->layout()->setMargin( 4 );
250 layout->addMultiCellWidget( grpbox, 1, 1, 0, 1 );
251 grplayout = new QVBoxLayout( grpbox->layout() );
252 m_proxyFtpServer = new QLineEdit( grpbox );
253 grplayout->addWidget( m_proxyFtpServer );
254 m_proxyFtpActive = new QCheckBox( tr( "Enabled" ), grpbox );
255 grplayout->addWidget( m_proxyFtpActive );
256
257 // Proxy server username and password configuration
258 QLabel *label = new QLabel( tr( "Username:" ), container );
259 layout->addWidget( label, 2, 0 );
260 m_proxyUsername = new QLineEdit( container );
261 layout->addWidget( m_proxyUsername, 2, 1 );
262
263 label = new QLabel( tr( "Password:" ), container );
264 layout->addWidget( label, 3, 0 );
265 m_proxyPassword = new QLineEdit( container );
266 layout->addWidget( m_proxyPassword, 3, 1 );
267}
268
269void OIpkgConfigDlg::initOptionsWidget()
270{
271 m_optionsWidget = new QWidget( this );
272
273 // Initialize UI
274 QVBoxLayout *vb = new QVBoxLayout( m_optionsWidget );
275 QScrollView *sv = new QScrollView( m_optionsWidget );
276 vb->addWidget( sv, 0, 0 );
277 sv->setResizePolicy( QScrollView::AutoOneFit );
278 sv->setFrameStyle( QFrame::NoFrame );
279 QWidget *container = new QWidget( sv->viewport() );
280 sv->addChild( container );
281 QVBoxLayout *layout = new QVBoxLayout( container, 2, 4 );
282
283 m_optForceDepends = new QCheckBox( tr( "Force Depends" ), container );
284 layout->addWidget( m_optForceDepends );
285
286 m_optForceReinstall = new QCheckBox( tr( "Force Reinstall" ), container );
287 layout->addWidget( m_optForceReinstall );
288
289 m_optForceRemove = new QCheckBox( tr( "Force Remove" ), container );
290 layout->addWidget( m_optForceRemove );
291
292 m_optForceOverwrite = new QCheckBox( tr( "Force Overwrite" ), container );
293 layout->addWidget( m_optForceOverwrite );
294
295 QLabel *l = new QLabel( tr( "Information Level" ), container );
296 layout->addWidget( l );
297
298 m_optVerboseIpkg = new QComboBox( container );
299 m_optVerboseIpkg->insertItem( tr( "Errors only" ) );
300 m_optVerboseIpkg->insertItem( tr( "Normal messages" ) );
301 m_optVerboseIpkg->insertItem( tr( "Informative messages" ) );
302 m_optVerboseIpkg->insertItem( tr( "Troubleshooting output" ) );
303 layout->addWidget( m_optVerboseIpkg );
304
305 layout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ) );
306}
307
308void OIpkgConfigDlg::initData()
309{
310 // Read ipkg configuration (server/destination/proxy) information
311 if ( m_ipkg && !m_installOptions )
312 {
313 m_configs = m_ipkg->configItems();
314 if ( m_configs )
315 {
316 for ( OConfItemListIterator configIt( *m_configs ); configIt.current(); ++configIt )
317 {
318 OConfItem *config = configIt.current();
319
320 // Add configuration item to the appropriate dialog controls
321 if ( config )
322 {
323 if ( config->type() == OConfItem::Source )
324 {
325 m_serverList->insertItem( config->name() );
326 }
327 else if ( config->type() == OConfItem::Destination )
328 {
329 m_destList->insertItem( config->name() );
330 }
331 else if ( config->type() == OConfItem::Option )
332 {
333 if ( config->name() == "http_proxy" )
334 {
335 m_proxyHttpServer->setText( config->value() );
336 m_proxyHttpActive->setChecked( config->active() );
337 }
338 else if ( config->name() == "ftp_proxy" )
339 {
340 m_proxyFtpServer->setText( config->value() );
341 m_proxyFtpActive->setChecked( config->active() );
342 }
343 else if ( config->name() == "proxy_username" )
344 {
345 m_proxyUsername->setText( config->value() );
346 }
347 else if ( config->name() == "proxy_password" )
348 {
349 m_proxyPassword->setText( config->value() );
350 }
351 }
352 }
353 }
354 }
355 }
356
357 // Get Ipkg execution options
358 int options = m_ipkg->ipkgExecOptions();
359 if ( options & FORCE_DEPENDS )
360 m_optForceDepends->setChecked( true );
361 if ( options & FORCE_REINSTALL )
362 m_optForceReinstall->setChecked( true );
363 if ( options & FORCE_REMOVE )
364 m_optForceRemove->setChecked( true );
365 if ( options & FORCE_OVERWRITE )
366 m_optForceOverwrite->setChecked( true );
367
368 m_optVerboseIpkg->setCurrentItem( m_ipkg->ipkgExecVerbosity() );
369}
370
371OConfItem *OIpkgConfigDlg::findConfItem( OConfItem::Type type, const QString &name )
372{
373 // Find selected server in list
374 OConfItemListIterator configIt( *m_configs );
375 OConfItem *config = 0x0;
376 for ( ; configIt.current(); ++configIt )
377 {
378 config = configIt.current();
379 if ( config->type() == type && config->name() == name )
380 break;
381 }
382
383 if ( config && config->type() == type && config->name() == name )
384 return config;
385
386 return 0x0;
387}
388
389void OIpkgConfigDlg::slotServerEdit( int index )
390{
391 m_serverNew = false;
392 m_serverCurrent = index;
393
394 // Find selected server in list
395 OConfItem *server = findConfItem( OConfItem::Source, m_serverList->currentText() );
396
397 // Display server details
398 if ( server )
399 {
400 m_serverCurrName = server->name();
401 m_serverName->setText( server->name() );
402 m_serverLocation->setText( server->value() );
403 m_serverActive->setChecked( server->active() );
404 m_serverName->setFocus();
405 }
406}
407
408void OIpkgConfigDlg::slotServerNew()
409{
410 m_serverNew = true;
411
412 m_serverName->setText( QString::null );
413 m_serverLocation->setText( QString::null );
414 m_serverActive->setChecked( true );
415 m_serverName->setFocus();
416}
417
418void OIpkgConfigDlg::slotServerDelete()
419{
420 // Find selected server in list
421 OConfItem *server = findConfItem( OConfItem::Source, m_serverList->currentText() );
422
423 // Delete server
424 if ( server )
425 {
426 m_configs->removeRef( server );
427 m_serverList->removeItem( m_serverCurrent );
428 }
429}
430
431void OIpkgConfigDlg::slotServerUpdate()
432{
433 QString newName = m_serverName->text();
434
435 // Convert any spaces to underscores
436 newName.replace( QRegExp( " " ), "_" );
437
438 if ( !m_serverNew )
439 {
440 // Find selected server in list
441 OConfItem *server = findConfItem( OConfItem::Source, m_serverCurrName );
442
443 // Delete server
444 if ( server )
445 {
446 // Update url
447 server->setValue( m_serverLocation->text() );
448 server->setActive( m_serverActive->isChecked() );
449
450 // Check if server name has changed, if it has then we need to replace the key in the map
451 if ( m_serverCurrName != newName )
452 {
453 // Update server name
454 server->setName( newName );
455
456 // Update list box
457 m_serverList->changeItem( newName, m_serverCurrent );
458 }
459 }
460 }
461 else
462 {
463 // Add new destination to configuration list
464 m_configs->append( new OConfItem( QString::null, OConfItem::Source, newName,
465 m_serverLocation->text(), m_serverActive->isChecked() ) );
466 m_configs->sort();
467
468 m_serverList->insertItem( newName );
469 m_serverList->setCurrentItem( m_serverList->count() );
470 m_serverNew = false;
471 m_serverList->insertItem( newName );
472 }
473}
474
475void OIpkgConfigDlg::slotDestEdit( int index )
476{
477 m_destNew = false;
478 m_destCurrent = index;
479
480 // Find selected destination in list
481 OConfItem *destination = findConfItem( OConfItem::Destination, m_destList->currentText() );
482
483 // Display destination details
484 if ( destination )
485 {
486 m_destCurrName = destination->name();
487 m_destName->setText( destination->name() );
488 m_destLocation->setText( destination->value() );
489 m_destActive->setChecked( destination->active() );
490 m_destName->setFocus();
491 }
492}
493
494void OIpkgConfigDlg::slotDestNew()
495{
496 m_destNew = true;
497
498 m_destName->setText( QString::null );
499 m_destLocation->setText( QString::null );
500 m_destActive->setChecked( true );
501 m_destName->setFocus();
502}
503
504void OIpkgConfigDlg::slotDestDelete()
505{
506 // Find selected destination in list
507 OConfItem *destination = findConfItem( OConfItem::Destination, m_destList->currentText() );
508
509 // Delete destination
510 if ( destination )
511 {
512 m_configs->removeRef( destination );
513 m_destList->removeItem( m_destCurrent );
514 }
515}
516
517void OIpkgConfigDlg::slotDestUpdate()
518{
519 QString newName = m_destName->text();
520
521 // Convert any spaces to underscores
522 newName.replace( QRegExp( " " ), "_" );
523
524 if ( !m_destNew )
525 {
526 // Find selected destination in list
527 OConfItem *destination = findConfItem( OConfItem::Destination, m_destCurrName );
528
529 // Display destination details
530 if ( destination )
531 {
532 // Update url
533 destination->setValue( m_destLocation->text() );
534 destination->setActive( m_destActive->isChecked() );
535
536 // Check if destination name has changed, if it has then we need to replace the key in the map
537 if ( m_destCurrName != newName )
538 {
539 // Update destination name
540 destination->setName( newName );
541
542 // Update list box
543 m_destList->changeItem( newName, m_destCurrent );
544 }
545 }
546 }
547 else
548 {
549 // Add new destination to configuration list
550 m_configs->append( new OConfItem( QString::null, OConfItem::Destination, newName,
551 m_destLocation->text(), m_destActive->isChecked() ) );
552 m_configs->sort();
553
554 m_destList->insertItem( newName );
555 m_destList->setCurrentItem( m_destList->count() );
556 m_destNew = false;
557 }
558}
diff --git a/noncore/settings/packagemanager/oipkgconfigdlg.h b/noncore/settings/packagemanager/oipkgconfigdlg.h
new file mode 100644
index 0000000..ef8c596
--- a/dev/null
+++ b/noncore/settings/packagemanager/oipkgconfigdlg.h
@@ -0,0 +1,131 @@
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
33#ifndef OIPKGCONFIGDLG_H
34#define OIPKGCONFIGDLG_H
35
36#include <qdialog.h>
37#include <qlayout.h>
38
39#include <opie/otabwidget.h>
40
41#include "oipkg.h"
42
43class QCheckBox;
44class QComboBox;
45class QLineEdit;
46class QListBox;
47
48class OIpkgConfigDlg : public QDialog
49{
50 Q_OBJECT
51
52public:
53 OIpkgConfigDlg( OIpkg *ipkg = 0x0, bool installOptions = false, QWidget *parent = 0x0 );
54
55protected slots:
56 void accept();
57 void reject();
58
59private:
60 OIpkg *m_ipkg; // Pointer to Ipkg class for retrieving/saving configuration options
61 OConfItemList *m_configs; // Local list of configuration items
62
63 bool m_installOptions; // If true, will only display the Options tab
64
65 // Server cached information
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
68 QString m_serverCurrName; // Name of currently selected server in m_serverList
69
70 // Destination cached information
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
73 QString m_destCurrName; // Name of currently selected destination in m_destList
74
75 // UI controls
76 QVBoxLayout m_layout; // Main dialog layout control
77 OTabWidget m_tabWidget; // Main tab widget control
78 QWidget *m_serverWidget; // Widget containing server configuration controls
79 QWidget *m_destWidget; // Widget containing destination configuration controls
80 QWidget *m_proxyWidget; // Widget containing proxy configuration controls
81 QWidget *m_optionsWidget; // Widget containing ipkg execution configuration controls
82
83 // Server configuration UI controls
84 QListBox *m_serverList; // Server list selection
85 QLineEdit *m_serverName; // Server name edit box
86 QLineEdit *m_serverLocation; // Server location URL edit box
87 QCheckBox *m_serverActive; // Activate server check box
88
89 // Destination configuration UI controls
90 QListBox *m_destList; // Destination list selection
91 QLineEdit *m_destName; // Destination name edit box
92 QLineEdit *m_destLocation; // Destination location URL edit box
93 QCheckBox *m_destActive; // Activate destination check box
94
95 // Proxy server configuration UI controls
96 QLineEdit *m_proxyHttpServer; // HTTP proxy server URL edit box
97 QCheckBox *m_proxyHttpActive; // Activate HTTP proxy check box
98 QLineEdit *m_proxyFtpServer; // FTP proxy server edit box
99 QCheckBox *m_proxyFtpActive; // Activate FTP proxy check box
100 QLineEdit *m_proxyUsername; // Proxy server username edit box
101 QLineEdit *m_proxyPassword; // Proxy server password edit box
102
103 // Options configuration UI controls
104 QCheckBox *m_optForceDepends; // Force depends ipkg option checkbox
105 QCheckBox *m_optForceReinstall; // Force reinstall ipkg option checkbox
106 QCheckBox *m_optForceRemove; // Force remove ipkg option checkbox
107 QCheckBox *m_optForceOverwrite; // Force overwrite ipkg option checkbox
108 QComboBox *m_optVerboseIpkg; // Ipkg verbosity option selection
109
110 void initServerWidget();
111 void initDestinationWidget();
112 void initProxyWidget();
113 void initOptionsWidget();
114
115 void initData();
116
117 OConfItem *findConfItem( OConfItem::Type type = OConfItem::NotDefined, const QString &name = 0x0 );
118
119private slots:
120 void slotServerEdit( int index );
121 void slotServerNew();
122 void slotServerDelete();
123 void slotServerUpdate();
124
125 void slotDestEdit( int index );
126 void slotDestNew();
127 void slotDestDelete();
128 void slotDestUpdate();
129};
130
131#endif
diff --git a/noncore/settings/packagemanager/opackage.cpp b/noncore/settings/packagemanager/opackage.cpp
new file mode 100644
index 0000000..34717e3
--- a/dev/null
+++ b/noncore/settings/packagemanager/opackage.cpp
@@ -0,0 +1,43 @@
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#include "opackage.h"
33
34OPackage::OPackage( const QString &name, const QString &version, const QString &versionInstalled,
35 const QString &source, const QString &destination, const QString &category )
36 : m_name( name )
37 , m_version( version )
38 , m_versionInstalled( versionInstalled )
39 , m_source( source )
40 , m_destination( destination )
41 , m_category( category )
42{
43}
diff --git a/noncore/settings/packagemanager/opackage.h b/noncore/settings/packagemanager/opackage.h
new file mode 100644
index 0000000..1e2e49f
--- a/dev/null
+++ b/noncore/settings/packagemanager/opackage.h
@@ -0,0 +1,74 @@
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 OPACKAGE_H
33#define OPACKAGE_H
34
35#include <qlist.h>
36#include <qstring.h>
37
38class OPackage
39{
40public:
41 enum Command { Install, Remove, Update, Upgrade, Download, Info, Files, Version, NotDefined };
42
43 OPackage( const QString &name = 0x0,
44 const QString &version = 0x0, const QString &versionInstalled = 0x0,
45 const QString &source = 0x0, const QString &destination = 0x0,
46 const QString &category = "misc" );
47
48 const QString &name() { return m_name; }
49 const QString &version() { return m_version; }
50 const QString &versionInstalled() { return m_versionInstalled; }
51 const QString &source() { return m_source; }
52 const QString &destination() { return m_destination; }
53 const QString &category() { return m_category; }
54
55 void setName( const QString &name ) { m_name = name; }
56 void setVersion( const QString &version ) { m_version = version; }
57 void setVersionInstalled( const QString &version ) { m_versionInstalled = version; }
58 void setSource( const QString &source ) { m_source = source; }
59 void setDestination( const QString &destination ) { m_destination = destination; }
60 void setCategory( const QString &category ) { m_category = category; }
61
62private:
63 QString m_name; // Name of item
64 QString m_version; // Available version number of item
65 QString m_versionInstalled; // Installed version number of item, null if not installed
66 QString m_source; // Source feed of available version
67 QString m_destination; // Location item is installed to, null if not installed
68 QString m_category; // Item category
69};
70
71typedef QList<OPackage> OPackageList;
72typedef QListIterator<OPackage> OPackageListIterator;
73
74#endif
diff --git a/noncore/settings/packagemanager/opackagemanager.cpp b/noncore/settings/packagemanager/opackagemanager.cpp
new file mode 100644
index 0000000..6bef918
--- a/dev/null
+++ b/noncore/settings/packagemanager/opackagemanager.cpp
@@ -0,0 +1,330 @@
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#include <qpe/qpeapplication.h>
33
34#include "opackagemanager.h"
35#include "oipkgconfigdlg.h"
36
37OPackageManager::OPackageManager( Config *config, QObject *parent, const char *name )
38 : QObject( parent, name )
39 , m_config( config )
40 , m_ipkg( m_config, this )
41 , m_packages( 9973 )
42 , m_categories()
43{
44 m_packages.setAutoDelete( true );
45}
46
47void OPackageManager::loadAvailablePackages()
48{
49 m_packages.clear();
50
51 OConfItemList *serverList = m_ipkg.servers();
52
53 if ( serverList )
54 {
55 // Initialize status messaging
56 emit initStatus( serverList->count() );
57 int serverCount = 0;
58
59 bool categoryAdded = false;
60
61 for ( OConfItemListIterator serverIt( *serverList ); serverIt.current(); ++serverIt )
62 {
63 OConfItem *server = serverIt.current();
64
65 // Process server only if it is active
66 if ( server->active() )
67 {
68 // Update status
69 QString status = tr( "Reading available packages:\n\t" );
70 status.append( server->name() );
71 emit statusText( status );
72 ++serverCount;
73 emit statusBar( serverCount );
74 qApp->processEvents();
75
76 OPackageList *packageList = m_ipkg.availablePackages( server->name() );
77 if ( packageList )
78 {
79 for ( OPackageListIterator packageIt( *packageList ); packageIt.current(); ++packageIt )
80 {
81 OPackage *package = packageIt.current();
82
83 // Load package info
84 if ( !m_packages.find( package->name() ) )
85 m_packages.insert( package->name(), package );
86 else
87 {
88 // If new package is newer version, replace existing package
89 OPackage *currPackage = m_packages[package->name()];
90 if ( compareVersions( package->version(), currPackage->version() ) == 1 )
91 m_packages.replace( package->name(), package );
92 }
93
94 // Add category to list if it doesn't already exist
95 if ( m_categories.grep( package->category() ).isEmpty() )
96 {
97 m_categories << package->category();
98 categoryAdded = true;
99 }
100 }
101 }
102 }
103 }
104 delete serverList;
105
106 // Sort category list if categories were added
107 if ( categoryAdded )
108 m_categories.sort();
109 }
110}
111
112void OPackageManager::loadInstalledPackages()
113{
114 OConfItemList *destList = m_ipkg.destinations();
115
116 if ( destList )
117 {
118 // Initialize status messaging
119 emit initStatus( destList->count() );
120 int destCount = 0;
121
122 bool categoryAdded = false;
123
124 for ( OConfItemListIterator destIt( *destList ); destIt.current(); ++destIt )
125 {
126 OConfItem *destination = destIt.current();
127
128 // Process destination only if it is active
129 if ( destination->active() )
130 {
131 // Update status
132 QString status = tr( "Reading installed packages:\n\t" );
133 status.append( destination->name() );
134 emit statusText( status );
135 ++destCount;
136 emit statusBar( destCount );
137 qApp->processEvents();
138
139 OPackageList *packageList = m_ipkg.installedPackages( destination->name(),
140 destination->value() );
141 if ( packageList )
142 {
143 for ( OPackageListIterator packageIt( *packageList ); packageIt.current(); ++packageIt )
144 {
145 OPackage *package = packageIt.current();
146 OPackage *currPackage = m_packages[package->name()];
147 if ( currPackage )
148 {
149 // Package is in a current feed, update installed version, destination
150 currPackage->setVersionInstalled( package->versionInstalled() );
151 currPackage->setDestination( package->destination() );
152
153 delete package;
154 }
155 else
156 {
157 // Package isn't in a current feed, add to list
158 m_packages.insert( package->name(), package );
159
160 // Add category to list if it doesn't already exist
161 if ( m_categories.grep( package->category() ).isEmpty() )
162 {
163 m_categories << package->category();
164 categoryAdded = true;
165 }
166 }
167 }
168 }
169 }
170 }
171 delete destList;
172
173 // Sort category list if categories were added
174 if ( categoryAdded )
175 m_categories.sort();
176 }
177}
178
179OPackageList *OPackageManager::packages()
180{
181 // TODO - look to see if list is loaded, if not, load available & installed
182
183 OPackageList *pl = new OPackageList;
184
185 for ( QDictIterator<OPackage> packageIt( m_packages ); packageIt.current(); ++packageIt )
186 pl->append( packageIt.current() );
187
188 return pl;
189}
190
191OPackageList *OPackageManager::filterPackages( const QString &name,const QString &server,
192 const QString &destination, Status status, const QString &category )
193{
194 // TODO - look to see if list is loaded, if not, load available & installed
195
196 OPackageList *pl = new OPackageList;
197 for ( QDictIterator<OPackage> packageIt( m_packages ); packageIt.current(); ++packageIt )
198 {
199 OPackage *package = packageIt.current();
200
201 bool nameMatch = ( name.isNull() || package->name().contains( name ) );
202 bool serverMatch = ( server.isNull() || package->source() == server );
203 bool destinationMatch = ( destination.isNull() || package->destination() == destination );
204 bool statusMatch;
205 switch ( status )
206 {
207 case All : statusMatch = true;
208 break;
209 case NotInstalled : statusMatch = package->versionInstalled().isNull();
210 break;
211 case Installed : statusMatch = !package->versionInstalled().isNull();
212 break;
213 case Updated : statusMatch = ( !package->versionInstalled().isNull() &&
214 compareVersions( package->version(), package->versionInstalled() ) == 1 );
215 break;
216 default : statusMatch = true;
217 break;
218 };
219 bool categoryMatch = ( category.isNull() || package->category() == category );
220
221 if ( nameMatch && serverMatch && destinationMatch && statusMatch && categoryMatch )
222 pl->append( packageIt.current() );
223 }
224
225 return pl;
226}
227
228QStringList *OPackageManager::servers()
229{
230 QStringList *sl = new QStringList();
231
232 OConfItemList *serverList = m_ipkg.servers();
233 if ( serverList )
234 {
235 for ( OConfItemListIterator serverIt( *serverList ); serverIt.current(); ++serverIt )
236 {
237 OConfItem *server = serverIt.current();
238
239 // Add only active servers
240 if ( server->active() )
241 *sl << server->name();
242 }
243 }
244
245 return sl;
246}
247
248QStringList *OPackageManager::destinations()
249{
250 QStringList *dl = new QStringList();
251
252 OConfItemList *destList = m_ipkg.destinations();
253 if ( destList )
254 {
255 for ( OConfItemListIterator destIt( *destList ); destIt.current(); ++destIt )
256 {
257 OConfItem *destination = destIt.current();
258
259 // Add only active destinations
260 if ( destination->active() )
261 *dl << destination->name();
262 }
263 }
264
265 return dl;
266}
267
268OConfItem *OPackageManager::findConfItem( OConfItem::Type type, const QString &name )
269{
270 OConfItem *confItem = 0x0;
271 OConfItemList *confList = m_ipkg.configItems();
272 if ( confList )
273 {
274 for ( OConfItemListIterator confIt( *confList ); confIt.current(); ++confIt )
275 {
276 OConfItem *conf = confIt.current();
277
278 // Add only active confinations
279 if ( conf->type() == type && conf->name() == name )
280 {
281 confItem = conf;
282 break;
283 }
284 }
285 }
286
287 return confItem;
288
289}
290
291OPackage *OPackageManager::findPackage( const QString &name )
292{
293 return m_packages[ name ];
294}
295
296int OPackageManager::compareVersions( const QString &version1, const QString &version2 )
297{
298 // TODO - do proper compare!
299 if ( version1 < version2 )
300 return -1;
301 else if ( version1 > version2 )
302 return 1;
303
304 return 0;
305}
306
307bool OPackageManager::configureDlg( bool installOptions )
308{
309 OIpkgConfigDlg dlg( &m_ipkg, installOptions, static_cast<QWidget *>(parent()) );
310 return ( dlg.exec() == QDialog::Accepted );
311}
312
313void OPackageManager::saveSettings()
314{
315 m_ipkg.saveSettings();
316}
317
318bool OPackageManager::executeCommand( OPackage::Command command, QStringList *packages,
319 const QString &destination, const QObject *receiver,
320 const char *slotOutput, const char *slotErrors,
321 const char *slotFinished, bool rawOutput )
322{
323 return m_ipkg.executeCommand( command, packages, destination, receiver, slotOutput, slotErrors,
324 slotFinished, rawOutput );
325}
326
327void OPackageManager::abortCommand()
328{
329 m_ipkg.abortCommand();
330}
diff --git a/noncore/settings/packagemanager/opackagemanager.h b/noncore/settings/packagemanager/opackagemanager.h
new file mode 100644
index 0000000..5e1a30a
--- a/dev/null
+++ b/noncore/settings/packagemanager/opackagemanager.h
@@ -0,0 +1,91 @@
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 OPACKAGEMANAGER_H
33#define OPACKAGEMANAGER_H
34
35#include <qdict.h>
36#include <qobject.h>
37#include <qstringlist.h>
38
39#include <qpe/config.h>
40
41#include "oipkg.h"
42
43class OPackageManager : public QObject
44{
45 Q_OBJECT
46
47public:
48 OPackageManager( Config *config = 0x0, QObject *parent = 0x0, const char *name = 0x0 );
49
50 void loadAvailablePackages();
51 void loadInstalledPackages();
52
53 enum Status { All, NotInstalled, Installed, Updated, NotDefined };
54
55 OPackageList *packages();
56 OPackageList *filterPackages( const QString &name = 0x0,const QString &server = 0x0,
57 const QString &destination = 0x0, Status status = NotDefined,
58 const QString &category = 0x0 );
59
60 const QStringList &categories() { return m_categories; }
61 QStringList *servers();
62 QStringList *destinations();
63
64 int compareVersions( const QString &version1, const QString &version2 );
65
66 OConfItem *findConfItem( OConfItem::Type type = OConfItem::NotDefined,
67 const QString &name = QString::null );
68 OPackage *findPackage( const QString &name = QString::null );
69
70 bool configureDlg( bool installOptions = false );
71 void saveSettings();
72
73 bool executeCommand( OPackage::Command command = OPackage::NotDefined, QStringList *parameters = 0x0,
74 const QString &destination = QString::null, const QObject *receiver = 0x0,
75 const char *slotOutput = 0x0, const char *slotErrors = 0x0,
76 const char *slotFinished = 0x0, bool rawOutput = true );
77 void abortCommand();
78
79private:
80 Config *m_config; // Pointer to application configuration file
81 OIpkg m_ipkg; // OIpkg object to retrieve package/configuration information
82 QDict<OPackage> m_packages; // Global list of available packages
83 QStringList m_categories; // List of all categories
84
85signals:
86 void initStatus( int numSteps );
87 void statusText( const QString &status );
88 void statusBar( int currStep );
89};
90
91#endif
diff --git a/noncore/settings/packagemanager/opie-packagemanager.control b/noncore/settings/packagemanager/opie-packagemanager.control
new file mode 100644
index 0000000..db06761
--- a/dev/null
+++ b/noncore/settings/packagemanager/opie-packagemanager.control
@@ -0,0 +1,10 @@
1Package: opie-packagemanager
2Files: plugins/application/libpackagemanager.so* bin/packagemanager pics/packagemanager apps/Settings/packagemanager.desktop
3Priority: optional
4Section: Settings
5Depends: task-opie-minimal
6Replaces: packagemanager
7Architecture: arm
8Maintainer: Dan Williams (drw@handhelds.org)
9Description: Opie package management client
10Version: 0.1.0
diff --git a/noncore/settings/packagemanager/packageinfodlg.cpp b/noncore/settings/packagemanager/packageinfodlg.cpp
new file mode 100644
index 0000000..71f17eb
--- a/dev/null
+++ b/noncore/settings/packagemanager/packageinfodlg.cpp
@@ -0,0 +1,56 @@
1/*
2                This file is part of the OPIE Project
3
4 =. Copyright (c) 2003 Dan Williams <drw@handhelds.org>
5             .=l.
6           .>+-=
7 _;:,     .>    :=|. This file is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This file is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
29
30#include "packageinfodlg.h"
31
32#include <qlayout.h>
33#include <qpushbutton.h>
34
35#include <qpe/resource.h>
36
37PackageInfoDlg::PackageInfoDlg( QWidget *parent, OPackageManager *pm, const QString &package )
38 : QWidget( 0x0 )
39 , m_packman( pm )
40 , m_output( this )
41{
42 // Initialize UI
43 if ( parent )
44 parent->setCaption( package );
45
46 QVBoxLayout *layout = new QVBoxLayout( this, 4, 0 );
47
48 m_output.setReadOnly( true );
49 layout->addWidget( &m_output );
50
51 QPushButton *btn = new QPushButton( Resource::loadPixmap( "enter" ), tr( "Close" ), this );
52 layout->addWidget( btn );
53// TODO connect( btn, SIGNAL(clicked()), this, SLOT(slotBtnClose()) );
54
55
56}
diff --git a/noncore/settings/packagemanager/packageinfodlg.h b/noncore/settings/packagemanager/packageinfodlg.h
new file mode 100644
index 0000000..3bb9a7a
--- a/dev/null
+++ b/noncore/settings/packagemanager/packageinfodlg.h
@@ -0,0 +1,58 @@
1/*
2                This file is part of the OPIE Project
3
4 =. Copyright (c) 2003 Dan Williams <drw@handhelds.org>
5             .=l.
6           .>+-=
7 _;:,     .>    :=|. This file is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This file is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
29
30#ifndef PACKAGEINFODLG_H
31#define PACKAGEINFODLG_H
32
33#include <qmultilineedit.h>
34#include <qwidget.h>
35
36#include <opie/oprocess.h>
37
38#include "opackage.h"
39
40class QPushButton;
41
42class OPackageManager;
43
44class PackageInfoDlg : public QWidget
45{
46 Q_OBJECT
47
48public:
49 PackageInfoDlg( QWidget *parent = 0x0, OPackageManager *pm = 0x0, const QString &package = QString::null );
50
51private:
52 OPackageManager *m_packman; // Pointer to application instance of package manager
53
54 // UI controls
55 QMultiLineEdit m_output; // Multi-line edit to display package information
56};
57
58#endif
diff --git a/noncore/settings/packagemanager/packagemanager.pro b/noncore/settings/packagemanager/packagemanager.pro
new file mode 100644
index 0000000..9aa3dc6
--- a/dev/null
+++ b/noncore/settings/packagemanager/packagemanager.pro
@@ -0,0 +1,31 @@
1CONFIG = qt warn_on release quick-app
2
3SOURCES = opackage.cpp \
4 oconfitem.cpp \
5 oipkg.cpp \
6 oipkgconfigdlg.cpp \
7 opackagemanager.cpp \
8 mainwindow.cpp \
9 installdlg.cpp \
10 packageinfodlg.cpp \
11 filterdlg.cpp \
12 promptdlg.cpp \
13 main.cpp
14HEADERS = opackage.h \
15 oconfitem.h \
16 oipkg.h \
17 oipkgconfigdlg.h \
18 opackagemanager.h \
19 mainwindow.h \
20 installdlg.h \
21 packageinfodlg.h \
22 filterdlg.h \
23 promptdlg.h
24
25TARGET = packagemanager
26INCLUDEPATH += $(OPIEDIR)/include
27DEPENDPATH += $(OPIEDIR)/include
28LIBS += -lqpe -lopie
29
30include ( $(OPIEDIR)/include.pro )
31
diff --git a/noncore/settings/packagemanager/promptdlg.cpp b/noncore/settings/packagemanager/promptdlg.cpp
new file mode 100644
index 0000000..3122699
--- a/dev/null
+++ b/noncore/settings/packagemanager/promptdlg.cpp
@@ -0,0 +1,140 @@
1/*
2                This file is part of the OPIE Project
3
4 =. Copyright (c) 2003 Dan Williams <drw@handhelds.org>
5             .=l.
6           .>+-=
7 _;:,     .>    :=|. This file is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This file is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
29
30#include "promptdlg.h"
31
32#include <qlabel.h>
33#include <qlayout.h>
34#include <qpushbutton.h>
35#include <qwidgetlist.h>
36
37#include <qpe/qpeapplication.h>
38
39PromptDlg::PromptDlg( const QString &caption, const QString &text, const QString &btn1, const QString &btn2,
40 QWidget *parent )
41 : QWidget( parent, QString::null, WType_Modal | WType_TopLevel | WStyle_Dialog )
42 , m_btnClicked( -1 )
43{
44 setCaption( caption );
45
46 QGridLayout *layout = new QGridLayout( this, 2, 2, 4, 2 );
47 QLabel *label = new QLabel( text, this );
48 label->setAlignment( AlignCenter | WordBreak );
49 layout->addMultiCellWidget( label, 0, 0, 0, 1 );
50
51 QPushButton *btn = new QPushButton( btn1, this );
52 layout->addWidget( btn, 1, 0 );
53 connect( btn, SIGNAL(clicked()), this, SLOT(slotBtn1Clicked()) );
54
55 btn = new QPushButton( btn2, this );
56 layout->addWidget( btn, 1, 1 );
57 connect( btn, SIGNAL(clicked()), this, SLOT(slotBtn2Clicked()) );
58}
59
60int PromptDlg::exec()
61{
62 // Determine position of dialog. Derived from QT's QDialog::show() method.
63 QWidget *w = parentWidget();
64 QPoint p( 0, 0 );
65 int extraw = 0, extrah = 0;
66 QWidget * desk = QApplication::desktop();
67 if ( w )
68 w = w->topLevelWidget();
69
70 QWidgetList *list = QApplication::topLevelWidgets();
71 QWidgetListIt it( *list );
72 while ( (extraw == 0 || extrah == 0) && it.current() != 0 )
73 {
74 int w, h;
75 QWidget * current = it.current();
76 ++it;
77 w = current->geometry().x() - current->x();
78 h = current->geometry().y() - current->y();
79
80 extraw = QMAX( extraw, w );
81 extrah = QMAX( extrah, h );
82 }
83 delete list;
84
85 // sanity check for decoration frames. With embedding, we
86 // might get extraordinary values
87 if ( extraw >= 10 || extrah >= 40 )
88 extraw = extrah = 0;
89
90 if ( w )
91 {
92 // Use mapToGlobal rather than geometry() in case w might
93 // be embedded in another application
94 QPoint pp = w->mapToGlobal( QPoint(0,0) );
95 p = QPoint( pp.x() + w->width()/2, pp.y() + w->height()/ 2 );
96 }
97 else
98 p = QPoint( desk->width()/2, desk->height()/2 );
99
100 p = QPoint( p.x()-width()/2 - extraw, p.y()-height()/2 - extrah );
101
102 if ( p.x() + extraw + width() > desk->width() )
103 p.setX( desk->width() - width() - extraw );
104 if ( p.x() < 0 )
105 p.setX( 0 );
106
107 if ( p.y() + extrah + height() > desk->height() )
108 p.setY( desk->height() - height() - extrah );
109 if ( p.y() < 0 )
110 p.setY( 0 );
111
112 move( p );
113 show();
114
115 // Enter event loop for modality
116 qApp->enter_loop();
117
118 return m_btnClicked;
119}
120
121int PromptDlg::ask( const QString &caption, const QString &text, const QString &btn1, const QString &btn2,
122 QWidget *parent )
123{
124 PromptDlg *dlg = new PromptDlg( caption, text, btn1, btn2, parent );
125 int rc = dlg->exec();
126 delete dlg;
127 return rc;
128}
129
130void PromptDlg::slotBtn1Clicked()
131{
132 m_btnClicked = 1;
133 qApp->exit_loop();
134}
135
136void PromptDlg::slotBtn2Clicked()
137{
138 m_btnClicked = 2;
139 qApp->exit_loop();
140}
diff --git a/noncore/settings/packagemanager/promptdlg.h b/noncore/settings/packagemanager/promptdlg.h
new file mode 100644
index 0000000..e0e9f41
--- a/dev/null
+++ b/noncore/settings/packagemanager/promptdlg.h
@@ -0,0 +1,57 @@
1/*
2                This file is part of the OPIE Project
3
4 =. Copyright (c) 2003 Dan Williams <drw@handhelds.org>
5             .=l.
6           .>+-=
7 _;:,     .>    :=|. This file is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU General Public
10.="- .-=="i,     .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version.
13    .%`+i>       _;_.
14    .i_,=:_.      -<s. This file is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU General
19..}^=.=       =       ; Public License for more details.
20++=   -.     .`     .:
21 :     =  ...= . :.=- You should have received a copy of the GNU
22 -.   .:....=;==+<; General Public License along with this file;
23  -_. . .   )=.  = see the file COPYING. If not, write to the
24    --        :-=` Free Software Foundation, Inc.,
25 59 Temple Place - Suite 330,
26 Boston, MA 02111-1307, USA.
27
28*/
29
30#ifndef PROMPTDLG_H
31#define PROMPTDLG_H
32
33#include <qwidget.h>
34
35class PromptDlg : public QWidget
36{
37 Q_OBJECT
38
39public:
40 PromptDlg( const QString &caption = 0x0, const QString &text = 0x0, const QString &btn1 = 0x0,
41 const QString &btn2 = 0x0, QWidget *parent = 0x0 );
42
43 int exec();
44 int btnPressed() { return m_btnClicked; }
45
46 static int ask( const QString &caption = 0x0, const QString &text = 0x0, const QString &btn1 = 0x0,
47 const QString &btn2 = 0x0, QWidget *parent = 0x0 );
48
49private:
50 int m_btnClicked; // Indicator for which button was pressed
51
52private slots:
53 void slotBtn1Clicked();
54 void slotBtn2Clicked();
55};
56
57#endif
diff --git a/packages b/packages
index c33a6ad..d68f8cf 100644
--- a/packages
+++ b/packages
@@ -115,24 +115,25 @@ CONFIG_OPIEALARM core/opiealarm
115 CONFIG_OPIEFTP noncore/net/opieftpopieftp.pro 115 CONFIG_OPIEFTP noncore/net/opieftpopieftp.pro
116 CONFIG_OPIEIRC noncore/net/opieircopieirc.pro 116 CONFIG_OPIEIRC noncore/net/opieircopieirc.pro
117 CONFIG_OPIEMAIL2noncore/unsupported/mail2 mail.pro 117 CONFIG_OPIEMAIL2noncore/unsupported/mail2 mail.pro
118 CONFIG_OPIEPLAYER core/multimedia/opieplayeropieplayer.pro 118 CONFIG_OPIEPLAYER core/multimedia/opieplayeropieplayer.pro
119 CONFIG_OPIEPLAYER2 noncore/multimedia/opieplayer2opieplayer2.pro 119 CONFIG_OPIEPLAYER2 noncore/multimedia/opieplayer2opieplayer2.pro
120 CONFIG_OPIE-RDESKTOP noncore/net/opierdesktopopierdesktop.pro 120 CONFIG_OPIE-RDESKTOP noncore/net/opierdesktopopierdesktop.pro
121 CONFIG_OPIEREC noncore/multimedia/opierecopierec.pro 121 CONFIG_OPIEREC noncore/multimedia/opierecopierec.pro
122 CONFIG_TONLEITER noncore/multimedia/tonleitertonleiter.pro 122 CONFIG_TONLEITER noncore/multimedia/tonleitertonleiter.pro
123 CONFIG_OPIETOOTH-APPLET noncore/net/opietooth/appletapplet.pro 123 CONFIG_OPIETOOTH-APPLET noncore/net/opietooth/appletapplet.pro
124 CONFIG_OPIETOOTH-MANAGER noncore/net/opietooth/managermanager.pro 124 CONFIG_OPIETOOTH-MANAGER noncore/net/opietooth/managermanager.pro
125 CONFIG_OSEARCH core/pim/osearchosearch.pro 125 CONFIG_OSEARCH core/pim/osearchosearch.pro
126 CONFIG_OXYGEN noncore/apps/oxygenoxygen.pro 126 CONFIG_OXYGEN noncore/apps/oxygenoxygen.pro
127 CONFIG_PACKAGEMANAGER noncore/settings/packagemanagerpackagemanager.pro
127 CONFIG_PARASHOOT noncore/games/parashootparashoot.pro 128 CONFIG_PARASHOOT noncore/games/parashootparashoot.pro
128 CONFIG_PICKBOARD inputmethods/pickboardpickboard.pro 129 CONFIG_PICKBOARD inputmethods/pickboardpickboard.pro
129 CONFIG_QASTEROIDS noncore/games/qasteroidsqasteroids.pro 130 CONFIG_QASTEROIDS noncore/games/qasteroidsqasteroids.pro
130 CONFIG_QASHMONEY noncore/apps/qashmoneyqashmoney.pro 131 CONFIG_QASHMONEY noncore/apps/qashmoneyqashmoney.pro
131 CONFIG_QCOP core/apps/qcopqcop.pro 132 CONFIG_QCOP core/apps/qcopqcop.pro
132 CONFIG_QPDF noncore/unsupported/qpdfqpdf.pro 133 CONFIG_QPDF noncore/unsupported/qpdfqpdf.pro
133CONFIG_QUICKLAUNCHER core/tools/quicklauncher quicklauncher.pro 134CONFIG_QUICKLAUNCHER core/tools/quicklauncher quicklauncher.pro
134 CONFIG_QWS core/qwsqws.pro 135 CONFIG_QWS core/qwsqws.pro
135 CONFIG_REMOTE noncore/tools/remoteremote.pro 136 CONFIG_REMOTE noncore/tools/remoteremote.pro
136 CONFIG_RESTARTAPPLET core/applets/restartappletrestartapplet.pro 137 CONFIG_RESTARTAPPLET core/applets/restartappletrestartapplet.pro
137 CONFIG_RESTARTAPPLET2 core/applets/restartapplet2restartapplet2.pro 138 CONFIG_RESTARTAPPLET2 core/applets/restartapplet2restartapplet2.pro
138 CONFIG_ROTATEAPPLET core/applets/rotateappletrotateapplet.pro 139 CONFIG_ROTATEAPPLET core/applets/rotateappletrotateapplet.pro
diff --git a/pics/packagemanager/apply.png b/pics/packagemanager/apply.png
new file mode 100644
index 0000000..80ceb68
--- a/dev/null
+++ b/pics/packagemanager/apply.png
Binary files differ
diff --git a/pics/packagemanager/desttab.png b/pics/packagemanager/desttab.png
new file mode 100644
index 0000000..d0b9b86
--- a/dev/null
+++ b/pics/packagemanager/desttab.png
Binary files differ
diff --git a/pics/packagemanager/download.png b/pics/packagemanager/download.png
new file mode 100644
index 0000000..727ec60
--- a/dev/null
+++ b/pics/packagemanager/download.png
Binary files differ
diff --git a/pics/packagemanager/filter.png b/pics/packagemanager/filter.png
new file mode 100644
index 0000000..4518e72
--- a/dev/null
+++ b/pics/packagemanager/filter.png
Binary files differ
diff --git a/pics/packagemanager/ipkg.png b/pics/packagemanager/ipkg.png
new file mode 100644
index 0000000..da8ffe6
--- a/dev/null
+++ b/pics/packagemanager/ipkg.png
Binary files differ
diff --git a/pics/packagemanager/keyboard.png b/pics/packagemanager/keyboard.png
new file mode 100644
index 0000000..5827b6c
--- a/dev/null
+++ b/pics/packagemanager/keyboard.png
Binary files differ
diff --git a/pics/packagemanager/packagemanager.png b/pics/packagemanager/packagemanager.png
new file mode 100644
index 0000000..b938d97
--- a/dev/null
+++ b/pics/packagemanager/packagemanager.png
Binary files differ
diff --git a/pics/packagemanager/proxytab.png b/pics/packagemanager/proxytab.png
new file mode 100644
index 0000000..ab630ed
--- a/dev/null
+++ b/pics/packagemanager/proxytab.png
Binary files differ
diff --git a/pics/packagemanager/remove.png b/pics/packagemanager/remove.png
new file mode 100644
index 0000000..abb70aa
--- a/dev/null
+++ b/pics/packagemanager/remove.png
Binary files differ
diff --git a/pics/packagemanager/servertab.png b/pics/packagemanager/servertab.png
new file mode 100644
index 0000000..e3b77ce
--- a/dev/null
+++ b/pics/packagemanager/servertab.png
Binary files differ
diff --git a/pics/packagemanager/update.png b/pics/packagemanager/update.png
new file mode 100644
index 0000000..20e1192
--- a/dev/null
+++ b/pics/packagemanager/update.png
Binary files differ
diff --git a/pics/packagemanager/updated.png b/pics/packagemanager/updated.png
new file mode 100644
index 0000000..eaabbf1
--- a/dev/null
+++ b/pics/packagemanager/updated.png
Binary files differ
diff --git a/pics/packagemanager/upgrade.png b/pics/packagemanager/upgrade.png
new file mode 100644
index 0000000..7afbd44
--- a/dev/null
+++ b/pics/packagemanager/upgrade.png
Binary files differ