-rw-r--r-- | noncore/settings/packagemanager/filterdlg.cpp | 4 | ||||
-rw-r--r-- | noncore/settings/packagemanager/installdlg.cpp | 60 | ||||
-rw-r--r-- | noncore/settings/packagemanager/installdlg.h | 59 | ||||
-rw-r--r-- | noncore/settings/packagemanager/mainwindow.cpp | 42 | ||||
-rw-r--r-- | noncore/settings/packagemanager/mainwindow.h | 2 | ||||
-rw-r--r-- | noncore/settings/packagemanager/oconfitem.h | 46 | ||||
-rw-r--r-- | noncore/settings/packagemanager/oipkg.cpp | 56 | ||||
-rw-r--r-- | noncore/settings/packagemanager/oipkg.h | 51 | ||||
-rw-r--r-- | noncore/settings/packagemanager/opackagemanager.cpp | 56 | ||||
-rw-r--r-- | noncore/settings/packagemanager/opackagemanager.h | 57 | ||||
-rw-r--r-- | noncore/settings/packagemanager/packageinfodlg.cpp | 46 | ||||
-rw-r--r-- | noncore/settings/packagemanager/promptdlg.h | 52 |
12 files changed, 265 insertions, 266 deletions
diff --git a/noncore/settings/packagemanager/filterdlg.cpp b/noncore/settings/packagemanager/filterdlg.cpp index 0e1ea52..e69b6eb 100644 --- a/noncore/settings/packagemanager/filterdlg.cpp +++ b/noncore/settings/packagemanager/filterdlg.cpp | |||
@@ -1,194 +1,194 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | 3 | ||
4 | =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> | 4 | =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This file is free software; you can | 7 | _;:, .> :=|. This file is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
19 | ..}^=.= = ; Public License for more details. | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | 20 | ++= -. .` .: |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | : = ...= . :.=- You should have received a copy of the GNU |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "filterdlg.h" | 30 | #include "filterdlg.h" |
31 | 31 | ||
32 | #include <qwhatsthis.h> | 32 | #include <qwhatsthis.h> |
33 | 33 | ||
34 | FilterDlg::FilterDlg( QWidget *parent, OPackageManager *pm, const QString &name, | 34 | FilterDlg::FilterDlg( QWidget *parent, OPackageManager *pm, const QString &name, |
35 | const QString &server, const QString &destination, | 35 | const QString &server, const QString &destination, |
36 | OPackageManager::Status status, const QString &category ) | 36 | OPackageManager::Status status, const QString &category ) |
37 | : QDialog( parent, QString::null, true, WStyle_ContextHelp ) | 37 | : QDialog( parent, QString::null, true, WStyle_ContextHelp ) |
38 | { | 38 | { |
39 | setCaption( tr( "Filter packages" ) ); | 39 | setCaption( tr( "Filter packages" ) ); |
40 | 40 | ||
41 | QVBoxLayout *layout = new QVBoxLayout( this ); | 41 | QVBoxLayout *layout = new QVBoxLayout( this ); |
42 | QScrollView *sv = new QScrollView( this ); | 42 | QScrollView *sv = new QScrollView( this ); |
43 | layout->addWidget( sv, 0, 0 ); | 43 | layout->addWidget( sv, 0, 0 ); |
44 | sv->setResizePolicy( QScrollView::AutoOneFit ); | 44 | sv->setResizePolicy( QScrollView::AutoOneFit ); |
45 | sv->setFrameStyle( QFrame::NoFrame ); | 45 | sv->setFrameStyle( QFrame::NoFrame ); |
46 | QWidget *container = new QWidget( sv->viewport() ); | 46 | QWidget *container = new QWidget( sv->viewport() ); |
47 | sv->addChild( container ); | 47 | sv->addChild( container ); |
48 | layout = new QVBoxLayout( container, 4, 4 ); | 48 | layout = new QVBoxLayout( container, 4, 4 ); |
49 | 49 | ||
50 | // Category | 50 | // Category |
51 | m_categoryCB = new QCheckBox( tr( "Category:" ), container ); | 51 | m_categoryCB = new QCheckBox( tr( "Category:" ), container ); |
52 | QWhatsThis::add( m_categoryCB, tr( "Tap here to filter package list by application category." ) ); | 52 | QWhatsThis::add( m_categoryCB, tr( "Tap here to filter package list by application category." ) ); |
53 | connect( m_categoryCB, SIGNAL(toggled(bool)), this, SLOT(slotCategorySelected(bool)) ); | 53 | connect( m_categoryCB, SIGNAL(toggled(bool)), this, SLOT(slotCategorySelected(bool)) ); |
54 | m_category = new QComboBox( container ); | 54 | m_category = new QComboBox( container ); |
55 | QWhatsThis::add( m_category, tr( "Select the application category to filter by here." ) ); | 55 | QWhatsThis::add( m_category, tr( "Select the application category to filter by here." ) ); |
56 | m_category->insertStringList( pm->categories() ); | 56 | m_category->insertStringList( pm->categories() ); |
57 | initItem( m_category, m_categoryCB, category ); | 57 | initItem( m_category, m_categoryCB, category ); |
58 | layout->addWidget( m_categoryCB ); | 58 | layout->addWidget( m_categoryCB ); |
59 | layout->addWidget( m_category ); | 59 | layout->addWidget( m_category ); |
60 | 60 | ||
61 | // Package name | 61 | // Package name |
62 | m_nameCB = new QCheckBox( tr( "Names containing:" ), container ); | 62 | m_nameCB = new QCheckBox( tr( "Names containing:" ), container ); |
63 | QWhatsThis::add( m_nameCB, tr( "Tap here to filter package list by package name." ) ); | 63 | QWhatsThis::add( m_nameCB, tr( "Tap here to filter package list by package name." ) ); |
64 | connect( m_nameCB, SIGNAL(toggled(bool)), this, SLOT(slotNameSelected(bool)) ); | 64 | connect( m_nameCB, SIGNAL(toggled(bool)), this, SLOT(slotNameSelected(bool)) ); |
65 | m_name = new QLineEdit( name, container ); | 65 | m_name = new QLineEdit( name, container ); |
66 | QWhatsThis::add( m_name, tr( "Enter the package name to filter by here." ) ); | 66 | QWhatsThis::add( m_name, tr( "Enter the package name to filter by here." ) ); |
67 | if ( !name.isNull() ) | 67 | if ( !name.isNull() ) |
68 | m_nameCB->setChecked( true ); | 68 | m_nameCB->setChecked( true ); |
69 | m_name->setEnabled( !name.isNull() ); | 69 | m_name->setEnabled( !name.isNull() ); |
70 | layout->addWidget( m_nameCB ); | 70 | layout->addWidget( m_nameCB ); |
71 | layout->addWidget( m_name ); | 71 | layout->addWidget( m_name ); |
72 | 72 | ||
73 | // Status | 73 | // Status |
74 | m_statusCB = new QCheckBox( tr( "With the status:" ), container ); | 74 | m_statusCB = new QCheckBox( tr( "With the status:" ), container ); |
75 | QWhatsThis::add( m_statusCB, tr( "Tap here to filter package list by the package status." ) ); | 75 | QWhatsThis::add( m_statusCB, tr( "Tap here to filter package list by the package status." ) ); |
76 | connect( m_statusCB, SIGNAL(toggled(bool)), this, SLOT(slotStatusSelected(bool)) ); | 76 | connect( m_statusCB, SIGNAL(toggled(bool)), this, SLOT(slotStatusSelected(bool)) ); |
77 | m_status = new QComboBox( container ); | 77 | m_status = new QComboBox( container ); |
78 | QWhatsThis::add( m_status, tr( "Select the package status to filter by here." ) ); | 78 | QWhatsThis::add( m_status, tr( "Select the package status to filter by here." ) ); |
79 | connect( m_status, SIGNAL(activated(const QString&)), this, SLOT(slotStatusChanged(const QString&)) ); | 79 | connect( m_status, SIGNAL(activated(const QString&)), this, SLOT(slotStatusChanged(const QString&)) ); |
80 | QString currStatus; | 80 | QString currStatus; |
81 | switch ( status ) | 81 | switch ( status ) |
82 | { | 82 | { |
83 | case OPackageManager::All : currStatus = tr( "All" ); | 83 | case OPackageManager::All : currStatus = tr( "All" ); |
84 | break; | 84 | break; |
85 | case OPackageManager::Installed : currStatus = tr( "Installed" ); | 85 | case OPackageManager::Installed : currStatus = tr( "Installed" ); |
86 | break; | 86 | break; |
87 | case OPackageManager::NotInstalled : currStatus = tr( "Not installed" ); | 87 | case OPackageManager::NotInstalled : currStatus = tr( "Not installed" ); |
88 | break; | 88 | break; |
89 | case OPackageManager::Updated : currStatus = tr( "Updated" ); | 89 | case OPackageManager::Updated : currStatus = tr( "Updated" ); |
90 | break; | 90 | break; |
91 | default : currStatus = QString::null; | 91 | default : currStatus = QString::null; |
92 | }; | 92 | }; |
93 | m_status->insertItem( tr( "All" ) ); | 93 | m_status->insertItem( tr( "All" ) ); |
94 | m_status->insertItem( tr( "Installed" ) ); | 94 | m_status->insertItem( tr( "Installed" ) ); |
95 | m_status->insertItem( tr( "Not installed" ) ); | 95 | m_status->insertItem( tr( "Not installed" ) ); |
96 | m_status->insertItem( tr( "Updated" ) ); | 96 | m_status->insertItem( tr( "Updated" ) ); |
97 | initItem( m_status, m_statusCB, currStatus ); | 97 | initItem( m_status, m_statusCB, currStatus ); |
98 | layout->addWidget( m_statusCB ); | 98 | layout->addWidget( m_statusCB ); |
99 | layout->addWidget( m_status ); | 99 | layout->addWidget( m_status ); |
100 | 100 | ||
101 | // Server | 101 | // Server |
102 | m_serverCB = new QCheckBox( tr( "Available from the following server:" ), container ); | 102 | m_serverCB = new QCheckBox( tr( "Available from the following server:" ), container ); |
103 | QWhatsThis::add( m_serverCB, tr( "Tap here to filter package list by source server." ) ); | 103 | QWhatsThis::add( m_serverCB, tr( "Tap here to filter package list by source server." ) ); |
104 | connect( m_serverCB, SIGNAL(toggled(bool)), this, SLOT(slotServerSelected(bool)) ); | 104 | connect( m_serverCB, SIGNAL(toggled(bool)), this, SLOT(slotServerSelected(bool)) ); |
105 | m_server = new QComboBox( container ); | 105 | m_server = new QComboBox( container ); |
106 | QWhatsThis::add( m_server, tr( "Select the source server to filter by here." ) ); | 106 | QWhatsThis::add( m_server, tr( "Select the source server to filter by here." ) ); |
107 | m_server->insertStringList( *(pm->servers()) ); | 107 | m_server->insertStringList( pm->servers() ); |
108 | initItem( m_server, m_serverCB, server ); | 108 | initItem( m_server, m_serverCB, server ); |
109 | layout->addWidget( m_serverCB ); | 109 | layout->addWidget( m_serverCB ); |
110 | layout->addWidget( m_server ); | 110 | layout->addWidget( m_server ); |
111 | 111 | ||
112 | // Destination | 112 | // Destination |
113 | m_destCB = new QCheckBox( tr( "Installed on device at:" ), container ); | 113 | m_destCB = new QCheckBox( tr( "Installed on device at:" ), container ); |
114 | QWhatsThis::add( m_destCB, tr( "Tap here to filter package list by destination where the package is installed to on this device." ) ); | 114 | QWhatsThis::add( m_destCB, tr( "Tap here to filter package list by destination where the package is installed to on this device." ) ); |
115 | connect( m_destCB, SIGNAL(toggled(bool)), this, SLOT(slotDestSelected(bool)) ); | 115 | connect( m_destCB, SIGNAL(toggled(bool)), this, SLOT(slotDestSelected(bool)) ); |
116 | m_destination = new QComboBox( container ); | 116 | m_destination = new QComboBox( container ); |
117 | QWhatsThis::add( m_destination, tr( "Select the destination location to filter by here." ) ); | 117 | QWhatsThis::add( m_destination, tr( "Select the destination location to filter by here." ) ); |
118 | m_destination->insertStringList( *(pm->destinations()) ); | 118 | m_destination->insertStringList( pm->destinations() ); |
119 | initItem( m_destination, m_destCB, destination ); | 119 | initItem( m_destination, m_destCB, destination ); |
120 | layout->addWidget( m_destCB ); | 120 | layout->addWidget( m_destCB ); |
121 | layout->addWidget( m_destination ); | 121 | layout->addWidget( m_destination ); |
122 | } | 122 | } |
123 | 123 | ||
124 | void FilterDlg::initItem( QComboBox *comboBox, QCheckBox *checkBox, const QString &selection ) | 124 | void FilterDlg::initItem( QComboBox *comboBox, QCheckBox *checkBox, const QString &selection ) |
125 | { | 125 | { |
126 | if ( !selection.isNull() ) | 126 | if ( !selection.isNull() ) |
127 | { | 127 | { |
128 | checkBox->setChecked( true ); | 128 | checkBox->setChecked( true ); |
129 | 129 | ||
130 | for ( int i = 0; i < comboBox->count(); i++ ) | 130 | for ( int i = 0; i < comboBox->count(); i++ ) |
131 | { | 131 | { |
132 | if ( comboBox->text( i ) == selection ) | 132 | if ( comboBox->text( i ) == selection ) |
133 | { | 133 | { |
134 | comboBox->setCurrentItem( i ); | 134 | comboBox->setCurrentItem( i ); |
135 | return; | 135 | return; |
136 | } | 136 | } |
137 | } | 137 | } |
138 | } | 138 | } |
139 | comboBox->setEnabled( !selection.isNull() ); | 139 | comboBox->setEnabled( !selection.isNull() ); |
140 | } | 140 | } |
141 | 141 | ||
142 | void FilterDlg::slotNameSelected( bool selected ) | 142 | void FilterDlg::slotNameSelected( bool selected ) |
143 | { | 143 | { |
144 | m_name->setEnabled( selected ); | 144 | m_name->setEnabled( selected ); |
145 | m_name->setFocus(); | 145 | m_name->setFocus(); |
146 | } | 146 | } |
147 | 147 | ||
148 | void FilterDlg::slotServerSelected( bool selected ) | 148 | void FilterDlg::slotServerSelected( bool selected ) |
149 | { | 149 | { |
150 | m_server->setEnabled( selected ); | 150 | m_server->setEnabled( selected ); |
151 | m_server->setFocus(); | 151 | m_server->setFocus(); |
152 | } | 152 | } |
153 | 153 | ||
154 | void FilterDlg::slotDestSelected( bool selected ) | 154 | void FilterDlg::slotDestSelected( bool selected ) |
155 | { | 155 | { |
156 | m_destination->setEnabled( selected ); | 156 | m_destination->setEnabled( selected ); |
157 | m_destination->setFocus(); | 157 | m_destination->setFocus(); |
158 | } | 158 | } |
159 | 159 | ||
160 | void FilterDlg::slotStatusSelected( bool selected ) | 160 | void FilterDlg::slotStatusSelected( bool selected ) |
161 | { | 161 | { |
162 | m_status->setEnabled( selected ); | 162 | m_status->setEnabled( selected ); |
163 | m_status->setFocus(); | 163 | m_status->setFocus(); |
164 | 164 | ||
165 | if ( !selected && !m_destCB->isEnabled() ) | 165 | if ( !selected && !m_destCB->isEnabled() ) |
166 | { | 166 | { |
167 | // If status check box has been deselected and destination option was previously deselected | 167 | // If status check box has been deselected and destination option was previously deselected |
168 | // (because status == "Not installed"), re-enable destination option | 168 | // (because status == "Not installed"), re-enable destination option |
169 | m_destCB->setEnabled( true ); | 169 | m_destCB->setEnabled( true ); |
170 | m_destination->setEnabled( true ); | 170 | m_destination->setEnabled( true ); |
171 | } | 171 | } |
172 | else if ( selected && m_destCB->isEnabled() && m_status->currentText() == tr( "Not installed" ) ) | 172 | else if ( selected && m_destCB->isEnabled() && m_status->currentText() == tr( "Not installed" ) ) |
173 | { | 173 | { |
174 | // If status check box has been selected and status == "Not installed", disable destination option | 174 | // If status check box has been selected and status == "Not installed", disable destination option |
175 | m_destCB->setEnabled( false ); | 175 | m_destCB->setEnabled( false ); |
176 | m_destCB->setChecked( false ); | 176 | m_destCB->setChecked( false ); |
177 | m_destination->setEnabled( false ); | 177 | m_destination->setEnabled( false ); |
178 | } | 178 | } |
179 | } | 179 | } |
180 | 180 | ||
181 | void FilterDlg::slotStatusChanged( const QString &category ) | 181 | void FilterDlg::slotStatusChanged( const QString &category ) |
182 | { | 182 | { |
183 | bool notInstalled = ( category == tr( "Not installed" ) ); | 183 | bool notInstalled = ( category == tr( "Not installed" ) ); |
184 | m_destCB->setEnabled( !notInstalled ); | 184 | m_destCB->setEnabled( !notInstalled ); |
185 | m_destination->setEnabled( !notInstalled ); | 185 | m_destination->setEnabled( !notInstalled ); |
186 | if ( notInstalled ) | 186 | if ( notInstalled ) |
187 | m_destCB->setChecked( false ); | 187 | m_destCB->setChecked( false ); |
188 | } | 188 | } |
189 | 189 | ||
190 | void FilterDlg::slotCategorySelected( bool selected ) | 190 | void FilterDlg::slotCategorySelected( bool selected ) |
191 | { | 191 | { |
192 | m_category->setEnabled( selected ); | 192 | m_category->setEnabled( selected ); |
193 | m_category->setFocus(); | 193 | m_category->setFocus(); |
194 | } | 194 | } |
diff --git a/noncore/settings/packagemanager/installdlg.cpp b/noncore/settings/packagemanager/installdlg.cpp index 0cb30e2..945dfed 100644 --- a/noncore/settings/packagemanager/installdlg.cpp +++ b/noncore/settings/packagemanager/installdlg.cpp | |||
@@ -1,301 +1,297 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | 3 | ||
4 | =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> | 4 | =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This file is free software; you can | 7 | _;:, .> :=|. This file is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
19 | ..}^=.= = ; Public License for more details. | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | 20 | ++= -. .` .: |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | : = ...= . :.=- You should have received a copy of the GNU |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "installdlg.h" | 30 | #include "installdlg.h" |
31 | 31 | ||
32 | #include <opie2/ofiledialog.h> | 32 | #include <opie2/ofiledialog.h> |
33 | 33 | ||
34 | #include <qpe/fileselector.h> | 34 | #include <qpe/fileselector.h> |
35 | #include <qpe/resource.h> | 35 | #include <qpe/resource.h> |
36 | #include <qpe/storage.h> | 36 | #include <qpe/storage.h> |
37 | 37 | ||
38 | #include <qapplication.h> | 38 | #include <qapplication.h> |
39 | #include <qcombobox.h> | 39 | #include <qcombobox.h> |
40 | #include <qfileinfo.h> | 40 | #include <qfileinfo.h> |
41 | #include <qgroupbox.h> | 41 | #include <qgroupbox.h> |
42 | #include <qlabel.h> | 42 | #include <qlabel.h> |
43 | #include <qlayout.h> | 43 | #include <qlayout.h> |
44 | #include <qmap.h> | 44 | #include <qmap.h> |
45 | #include <qmultilineedit.h> | 45 | #include <qmultilineedit.h> |
46 | #include <qpushbutton.h> | 46 | #include <qpushbutton.h> |
47 | 47 | ||
48 | #include <sys/vfs.h> | 48 | #include <sys/vfs.h> |
49 | 49 | ||
50 | #include "opackagemanager.h" | 50 | #include "opackagemanager.h" |
51 | 51 | ||
52 | InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &caption, bool showDestInfo, | 52 | InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &caption, bool showDestInfo, |
53 | OPackage::Command command1, QStringList *packages1, | 53 | OPackage::Command command1, const QStringList &packages1, |
54 | OPackage::Command command2, QStringList *packages2, | 54 | OPackage::Command command2, const QStringList &packages2, |
55 | OPackage::Command command3, QStringList *packages3 ) | 55 | OPackage::Command command3, const QStringList &packages3 ) |
56 | : QWidget( 0x0 ) | 56 | : QWidget( 0x0 ) |
57 | , m_packman( pm ) | 57 | , m_packman( pm ) |
58 | , m_numCommands( 0 ) | 58 | , m_numCommands( 0 ) |
59 | , m_currCommand( 0 ) | 59 | , m_currCommand( 0 ) |
60 | { | 60 | { |
61 | // Save command/package list information | 61 | // Save command/package list information |
62 | if ( command1 != OPackage::NotDefined ) | 62 | if ( command1 != OPackage::NotDefined ) |
63 | { | 63 | { |
64 | m_command[ m_numCommands ] = command1; | 64 | m_command[ m_numCommands ] = command1; |
65 | m_packages[ m_numCommands ] = packages1; | 65 | m_packages[ m_numCommands ] = packages1; |
66 | ++m_numCommands; | 66 | ++m_numCommands; |
67 | } | 67 | } |
68 | if ( command2 != OPackage::NotDefined ) | 68 | if ( command2 != OPackage::NotDefined ) |
69 | { | 69 | { |
70 | m_command[ m_numCommands ] = command2; | 70 | m_command[ m_numCommands ] = command2; |
71 | m_packages[ m_numCommands ] = packages2; | 71 | m_packages[ m_numCommands ] = packages2; |
72 | ++m_numCommands; | 72 | ++m_numCommands; |
73 | } | 73 | } |
74 | if ( command3 != OPackage::NotDefined ) | 74 | if ( command3 != OPackage::NotDefined ) |
75 | { | 75 | { |
76 | m_command[ m_numCommands ] = command3; | 76 | m_command[ m_numCommands ] = command3; |
77 | m_packages[ m_numCommands ] = packages3; | 77 | m_packages[ m_numCommands ] = packages3; |
78 | ++m_numCommands; | 78 | ++m_numCommands; |
79 | } | 79 | } |
80 | 80 | ||
81 | // Initialize UI | 81 | // Initialize UI |
82 | if ( parent ) | 82 | if ( parent ) |
83 | parent->setCaption( caption ); | 83 | parent->setCaption( caption ); |
84 | 84 | ||
85 | QGridLayout *layout = new QGridLayout( this, 4, 2, 2, 4 ); | 85 | QGridLayout *layout = new QGridLayout( this, 4, 2, 2, 4 ); |
86 | 86 | ||
87 | if ( showDestInfo ) | 87 | if ( showDestInfo ) |
88 | { | 88 | { |
89 | QLabel *label = new QLabel( tr( "Destination" ), this ); | 89 | QLabel *label = new QLabel( tr( "Destination" ), this ); |
90 | layout->addWidget( label, 0, 0 ); | 90 | layout->addWidget( label, 0, 0 ); |
91 | m_destination = new QComboBox( this ); | 91 | m_destination = new QComboBox( this ); |
92 | m_destination->insertStringList( *(m_packman->destinations()) ); | 92 | m_destination->insertStringList( m_packman->destinations() ); |
93 | layout->addWidget( m_destination, 0, 1 ); | 93 | layout->addWidget( m_destination, 0, 1 ); |
94 | connect( m_destination, SIGNAL(highlighted(const QString&)), | 94 | connect( m_destination, SIGNAL(highlighted(const QString&)), |
95 | this, SLOT(slotDisplayAvailSpace(const QString&)) ); | 95 | this, SLOT(slotDisplayAvailSpace(const QString&)) ); |
96 | 96 | ||
97 | label = new QLabel( tr( "Space Avail" ), this ); | 97 | label = new QLabel( tr( "Space Avail" ), this ); |
98 | layout->addWidget( label, 1, 0 ); | 98 | layout->addWidget( label, 1, 0 ); |
99 | m_availSpace = new QLabel( this ); | 99 | m_availSpace = new QLabel( this ); |
100 | layout->addWidget( m_availSpace, 1, 1 ); | 100 | layout->addWidget( m_availSpace, 1, 1 ); |
101 | 101 | ||
102 | // TODO - select correct destination | 102 | // TODO - select correct destination |
103 | slotDisplayAvailSpace( m_destination->currentText() ); | 103 | slotDisplayAvailSpace( m_destination->currentText() ); |
104 | } | 104 | } |
105 | else | 105 | else |
106 | { | 106 | { |
107 | m_destination = 0x0; | 107 | m_destination = 0x0; |
108 | m_availSpace = 0x0; | 108 | m_availSpace = 0x0; |
109 | } | 109 | } |
110 | 110 | ||
111 | QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this ); | 111 | QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this ); |
112 | groupBox->layout()->setSpacing( 0 ); | 112 | groupBox->layout()->setSpacing( 0 ); |
113 | groupBox->layout()->setMargin( 4 ); | 113 | groupBox->layout()->setMargin( 4 ); |
114 | 114 | ||
115 | QVBoxLayout *groupBoxLayout = new QVBoxLayout( groupBox->layout() ); | 115 | QVBoxLayout *groupBoxLayout = new QVBoxLayout( groupBox->layout() ); |
116 | m_output = new QMultiLineEdit( groupBox ); | 116 | m_output = new QMultiLineEdit( groupBox ); |
117 | m_output->setReadOnly( true ); | 117 | m_output->setReadOnly( true ); |
118 | groupBoxLayout->addWidget( m_output ); | 118 | groupBoxLayout->addWidget( m_output ); |
119 | layout->addMultiCellWidget( groupBox, 2, 2, 0, 1 ); | 119 | layout->addMultiCellWidget( groupBox, 2, 2, 0, 1 ); |
120 | 120 | ||
121 | m_btnStart = new QPushButton( Resource::loadPixmap( "packagemanager/apply" ), tr( "Start" ), this ); | 121 | m_btnStart = new QPushButton( Resource::loadPixmap( "packagemanager/apply" ), tr( "Start" ), this ); |
122 | layout->addWidget( m_btnStart, 3, 0 ); | 122 | layout->addWidget( m_btnStart, 3, 0 ); |
123 | connect( m_btnStart, SIGNAL(clicked()), this, SLOT(slotBtnStart()) ); | 123 | connect( m_btnStart, SIGNAL(clicked()), this, SLOT(slotBtnStart()) ); |
124 | 124 | ||
125 | m_btnOptions = new QPushButton( Resource::loadPixmap( "SettingsIcon" ), tr( "Options" ), this ); | 125 | m_btnOptions = new QPushButton( Resource::loadPixmap( "SettingsIcon" ), tr( "Options" ), this ); |
126 | layout->addWidget( m_btnOptions, 3, 1 ); | 126 | layout->addWidget( m_btnOptions, 3, 1 ); |
127 | connect( m_btnOptions, SIGNAL( clicked() ), this, SLOT(slotBtnOptions()) ); | 127 | connect( m_btnOptions, SIGNAL( clicked() ), this, SLOT(slotBtnOptions()) ); |
128 | 128 | ||
129 | // Display packages being acted upon in output widget | 129 | // Display packages being acted upon in output widget |
130 | for( int i = 0; i < m_numCommands; i++ ) | 130 | for( int i = 0; i < m_numCommands; i++ ) |
131 | { | 131 | { |
132 | if ( m_packages[ i ] ) | 132 | if ( !m_packages[ i ].isEmpty() ) |
133 | { | 133 | { |
134 | QString lineStr = tr( "Packages to " ); | 134 | QString lineStr = tr( "Packages to " ); |
135 | 135 | ||
136 | switch( m_command[ i ] ) | 136 | switch( m_command[ i ] ) |
137 | { | 137 | { |
138 | case OPackage::Install : lineStr.append( tr( "install" ) ); | 138 | case OPackage::Install : lineStr.append( tr( "install" ) ); |
139 | break; | 139 | break; |
140 | case OPackage::Remove : lineStr.append( tr( "remove" ) ); | 140 | case OPackage::Remove : lineStr.append( tr( "remove" ) ); |
141 | break; | 141 | break; |
142 | case OPackage::Upgrade : lineStr.append( tr( "upgrade" ) ); | 142 | case OPackage::Upgrade : lineStr.append( tr( "upgrade" ) ); |
143 | break; | 143 | break; |
144 | case OPackage::Download : lineStr.append( tr( "download" ) ); | 144 | case OPackage::Download : lineStr.append( tr( "download" ) ); |
145 | break; | 145 | break; |
146 | default : | 146 | default : |
147 | break; | 147 | break; |
148 | }; | 148 | }; |
149 | lineStr.append( ":\n" ); | 149 | lineStr.append( ":\n" ); |
150 | 150 | ||
151 | for ( QStringList::Iterator it = m_packages[ i ]->begin(); it != m_packages[ i ]->end(); ++it ) | 151 | QStringList tmpPackage = m_packages[ i ]; |
152 | for ( QStringList::Iterator it = tmpPackage.begin(); it != tmpPackage.end(); ++it ) | ||
152 | { | 153 | { |
153 | lineStr.append( QString( "\t%1\n" ).arg( ( *it ) ) ); | 154 | lineStr.append( QString( "\t%1\n" ).arg( ( *it ) ) ); |
154 | } | 155 | } |
155 | 156 | ||
156 | m_output->append( lineStr ); | 157 | m_output->append( lineStr ); |
157 | } | 158 | } |
158 | } | 159 | } |
159 | 160 | ||
160 | m_output->append( tr( "Press the start button to begin.\n" ) ); | 161 | m_output->append( tr( "Press the start button to begin.\n" ) ); |
161 | m_output->setCursorPosition( m_output->numLines(), 0 ); | 162 | m_output->setCursorPosition( m_output->numLines(), 0 ); |
162 | 163 | ||
163 | } | 164 | } |
164 | 165 | ||
165 | InstallDlg::~InstallDlg() | 166 | InstallDlg::~InstallDlg() |
166 | { | 167 | { |
167 | for( int i = 0; i < m_numCommands; i++ ) | ||
168 | { | ||
169 | if ( m_packages[ i ] ) | ||
170 | delete m_packages[ i ]; | ||
171 | } | ||
172 | } | 168 | } |
173 | 169 | ||
174 | void InstallDlg::slotDisplayAvailSpace( const QString &destination ) | 170 | void InstallDlg::slotDisplayAvailSpace( const QString &destination ) |
175 | { | 171 | { |
176 | // If available space is not displayed, exit | 172 | // If available space is not displayed, exit |
177 | if ( !m_availSpace ) | 173 | if ( !m_availSpace ) |
178 | return; | 174 | return; |
179 | 175 | ||
180 | QString space = tr( "Unknown" ); | 176 | QString space = tr( "Unknown" ); |
181 | 177 | ||
182 | // Get destination | 178 | // Get destination |
183 | OConfItem *dest = m_packman->findConfItem( OConfItem::Destination, destination ); | 179 | OConfItem *dest = m_packman->findConfItem( OConfItem::Destination, destination ); |
184 | 180 | ||
185 | if ( dest ) | 181 | if ( dest ) |
186 | { | 182 | { |
187 | // Calculate available space | 183 | // Calculate available space |
188 | struct statfs fs; | 184 | struct statfs fs; |
189 | if ( !statfs( dest->value(), &fs ) ) | 185 | if ( !statfs( dest->value(), &fs ) ) |
190 | { | 186 | { |
191 | long mult = fs.f_bsize / 1024; | 187 | long mult = fs.f_bsize / 1024; |
192 | long div = 1024 / fs.f_bsize; | 188 | long div = 1024 / fs.f_bsize; |
193 | 189 | ||
194 | if ( !mult ) mult = 1; | 190 | if ( !mult ) mult = 1; |
195 | if ( !div ) div = 1; | 191 | if ( !div ) div = 1; |
196 | long avail = fs.f_bavail * mult / div; | 192 | long avail = fs.f_bavail * mult / div; |
197 | 193 | ||
198 | space = tr( "%1 Kb" ).arg( avail ); | 194 | space = tr( "%1 Kb" ).arg( avail ); |
199 | } | 195 | } |
200 | } | 196 | } |
201 | 197 | ||
202 | // Display available space | 198 | // Display available space |
203 | m_availSpace->setText( space ); | 199 | m_availSpace->setText( space ); |
204 | } | 200 | } |
205 | 201 | ||
206 | void InstallDlg::slotBtnStart() | 202 | void InstallDlg::slotBtnStart() |
207 | { | 203 | { |
208 | QString btnText = m_btnStart->text(); | 204 | QString btnText = m_btnStart->text(); |
209 | if ( btnText == tr( "Abort" ) ) | 205 | if ( btnText == tr( "Abort" ) ) |
210 | { | 206 | { |
211 | // Prevent unexecuted commands from executing | 207 | // Prevent unexecuted commands from executing |
212 | m_currCommand = 999; | 208 | m_currCommand = 999; |
213 | 209 | ||
214 | // Allow user to close dialog | 210 | // Allow user to close dialog |
215 | m_btnStart->setText( tr( "Close" ) ); | 211 | m_btnStart->setText( tr( "Close" ) ); |
216 | m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) ); | 212 | m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) ); |
217 | return; | 213 | return; |
218 | } | 214 | } |
219 | else if ( btnText == tr( "Close" ) ) | 215 | else if ( btnText == tr( "Close" ) ) |
220 | { | 216 | { |
221 | // TODO - force reload of package data | 217 | // TODO - force reload of package data |
222 | emit closeInstallDlg(); | 218 | emit closeInstallDlg(); |
223 | return; | 219 | return; |
224 | } | 220 | } |
225 | 221 | ||
226 | // Start was clicked, start executing | 222 | // Start was clicked, start executing |
227 | m_btnOptions->setEnabled( false ); | 223 | m_btnOptions->setEnabled( false ); |
228 | if ( m_numCommands > 1 ) | 224 | if ( m_numCommands > 1 ) |
229 | { | 225 | { |
230 | m_btnStart->setText( tr( "Abort" ) ); | 226 | m_btnStart->setText( tr( "Abort" ) ); |
231 | m_btnStart->setIconSet( Resource::loadPixmap( "close" ) ); | 227 | m_btnStart->setIconSet( Resource::loadPixmap( "close" ) ); |
232 | } | 228 | } |
233 | else | 229 | else |
234 | { | 230 | { |
235 | m_btnStart->setEnabled( false ); | 231 | m_btnStart->setEnabled( false ); |
236 | } | 232 | } |
237 | 233 | ||
238 | QString dest; | 234 | QString dest; |
239 | if ( m_destination ) | 235 | if ( m_destination ) |
240 | dest = m_destination->currentText(); | 236 | dest = m_destination->currentText(); |
241 | 237 | ||
242 | for ( m_currCommand = 0; m_currCommand < m_numCommands; m_currCommand++ ) | 238 | for ( m_currCommand = 0; m_currCommand < m_numCommands; m_currCommand++ ) |
243 | { | 239 | { |
244 | // Execute next command | 240 | // Execute next command |
245 | m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], dest, | 241 | m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], dest, |
246 | this, SLOT(slotOutput(char*)), true ); | 242 | this, SLOT(slotOutput(char*)), true ); |
247 | } | 243 | } |
248 | 244 | ||
249 | // All commands executed, allow user to close dialog | 245 | // All commands executed, allow user to close dialog |
250 | m_btnStart->setEnabled( true ); | 246 | m_btnStart->setEnabled( true ); |
251 | m_btnStart->setText( tr( "Close" ) ); | 247 | m_btnStart->setText( tr( "Close" ) ); |
252 | m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) ); | 248 | m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) ); |
253 | 249 | ||
254 | m_btnOptions->setEnabled( true ); | 250 | m_btnOptions->setEnabled( true ); |
255 | m_btnOptions->setText( tr( "Save output" ) ); | 251 | m_btnOptions->setText( tr( "Save output" ) ); |
256 | m_btnOptions->setIconSet( Resource::loadPixmap( "save" ) ); | 252 | m_btnOptions->setIconSet( Resource::loadPixmap( "save" ) ); |
257 | } | 253 | } |
258 | 254 | ||
259 | void InstallDlg::slotBtnOptions() | 255 | void InstallDlg::slotBtnOptions() |
260 | { | 256 | { |
261 | QString btnText = m_btnOptions->text(); | 257 | QString btnText = m_btnOptions->text(); |
262 | if ( btnText == tr( "Options" ) ) | 258 | if ( btnText == tr( "Options" ) ) |
263 | { | 259 | { |
264 | // Display configuration dialog (only options tab is enabled) | 260 | // Display configuration dialog (only options tab is enabled) |
265 | m_packman->configureDlg( true ); | 261 | m_packman->configureDlg( true ); |
266 | return; | 262 | return; |
267 | } | 263 | } |
268 | 264 | ||
269 | // Save output was clicked | 265 | // Save output was clicked |
270 | QMap<QString, QStringList> map; | 266 | QMap<QString, QStringList> map; |
271 | map.insert( tr( "All" ), QStringList() ); | 267 | map.insert( tr( "All" ), QStringList() ); |
272 | QStringList text; | 268 | QStringList text; |
273 | text << "text/*"; | 269 | text << "text/*"; |
274 | map.insert(tr( "Text" ), text ); | 270 | map.insert(tr( "Text" ), text ); |
275 | text << "*"; | 271 | text << "*"; |
276 | map.insert( tr( "All" ), text ); | 272 | map.insert( tr( "All" ), text ); |
277 | 273 | ||
278 | QString filename = Opie::Ui::OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map ); | 274 | QString filename = Opie::Ui::OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map ); |
279 | if( !filename.isEmpty() ) | 275 | if( !filename.isEmpty() ) |
280 | { | 276 | { |
281 | QString currentFileName = QFileInfo( filename ).fileName(); | 277 | QString currentFileName = QFileInfo( filename ).fileName(); |
282 | DocLnk doc; | 278 | DocLnk doc; |
283 | doc.setType( "text/plain" ); | 279 | doc.setType( "text/plain" ); |
284 | doc.setFile( filename ); | 280 | doc.setFile( filename ); |
285 | doc.setName( currentFileName ); | 281 | doc.setName( currentFileName ); |
286 | FileManager fm; | 282 | FileManager fm; |
287 | fm.saveFile( doc, m_output->text() ); | 283 | fm.saveFile( doc, m_output->text() ); |
288 | } | 284 | } |
289 | } | 285 | } |
290 | 286 | ||
291 | void InstallDlg::slotOutput( char *msg ) | 287 | void InstallDlg::slotOutput( char *msg ) |
292 | { | 288 | { |
293 | // Allow processing of other events | 289 | // Allow processing of other events |
294 | qApp->processEvents(); | 290 | qApp->processEvents(); |
295 | 291 | ||
296 | QString lineStr = msg; | 292 | QString lineStr = msg; |
297 | if ( lineStr[lineStr.length()-1] == '\n' ) | 293 | if ( lineStr[lineStr.length()-1] == '\n' ) |
298 | lineStr.truncate( lineStr.length() - 1 ); | 294 | lineStr.truncate( lineStr.length() - 1 ); |
299 | m_output->append( lineStr ); | 295 | m_output->append( lineStr ); |
300 | m_output->setCursorPosition( m_output->numLines(), 0 ); | 296 | m_output->setCursorPosition( m_output->numLines(), 0 ); |
301 | } | 297 | } |
diff --git a/noncore/settings/packagemanager/installdlg.h b/noncore/settings/packagemanager/installdlg.h index 4da9cf6..cddc911 100644 --- a/noncore/settings/packagemanager/installdlg.h +++ b/noncore/settings/packagemanager/installdlg.h | |||
@@ -1,85 +1,88 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | 3 | ||
4 | =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> | 4 | =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This file is free software; you can | 7 | _;:, .> :=|. This file is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
19 | ..}^=.= = ; Public License for more details. | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | 20 | ++= -. .` .: |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | : = ...= . :.=- You should have received a copy of the GNU |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #ifndef INSTALLDLG_H | 30 | #ifndef INSTALLDLG_H |
31 | #define INSTALLDLG_H | 31 | #define INSTALLDLG_H |
32 | 32 | ||
33 | #include <qwidget.h> | 33 | #include <qwidget.h> |
34 | 34 | ||
35 | #include "opackage.h" | 35 | #include "opackage.h" |
36 | 36 | ||
37 | class QComboBox; | 37 | class QComboBox; |
38 | class QLabel; | 38 | class QLabel; |
39 | class QMultiLineEdit; | 39 | class QMultiLineEdit; |
40 | class QPushButton; | 40 | class QPushButton; |
41 | 41 | ||
42 | class OPackageManager; | 42 | class OPackageManager; |
43 | 43 | ||
44 | class InstallDlg : public QWidget | 44 | class InstallDlg : public QWidget |
45 | { | 45 | { |
46 | Q_OBJECT | 46 | Q_OBJECT |
47 | 47 | ||
48 | public: | 48 | public: |
49 | InstallDlg( QWidget *parent = 0x0, OPackageManager *pm = 0x0, const QString &caption = QString::null, | 49 | InstallDlg( QWidget *parent = 0x0, OPackageManager *pm = 0x0, const QString &caption = QString::null, |
50 | bool showDestInfo = true, | 50 | bool showDestInfo = true, |
51 | OPackage::Command command1 = OPackage::NotDefined, QStringList *packages1 = 0x0, | 51 | OPackage::Command command1 = OPackage::NotDefined, |
52 | OPackage::Command command2 = OPackage::NotDefined, QStringList *packages2 = 0x0, | 52 | const QStringList &packages1 = QStringList(), |
53 | OPackage::Command command3 = OPackage::NotDefined, QStringList *packages3 = 0x0 ); | 53 | OPackage::Command command2 = OPackage::NotDefined, |
54 | const QStringList &packages2 = QStringList(), | ||
55 | OPackage::Command command3 = OPackage::NotDefined, | ||
56 | const QStringList &packages3 = QStringList() ); | ||
54 | ~InstallDlg(); | 57 | ~InstallDlg(); |
55 | 58 | ||
56 | private: | 59 | private: |
57 | OPackageManager *m_packman; // Pointer to application instance of package manager | 60 | OPackageManager *m_packman; // Pointer to application instance of package manager |
58 | 61 | ||
59 | // UI controls | 62 | // UI controls |
60 | QComboBox *m_destination; // Destination selection list | 63 | QComboBox *m_destination; // Destination selection list |
61 | QLabel *m_availSpace; // Text label to display available space on selected destination | 64 | QLabel *m_availSpace; // Text label to display available space on selected destination |
62 | QMultiLineEdit *m_output; // Multi-line edit to display status | 65 | QMultiLineEdit *m_output; // Multi-line edit to display status |
63 | QPushButton *m_btnStart; // Start/abort/close button | 66 | QPushButton *m_btnStart; // Start/abort/close button |
64 | QPushButton *m_btnOptions; // Installation options button | 67 | QPushButton *m_btnOptions; // Installation options button |
65 | 68 | ||
66 | // Commands and packages to execute | 69 | // Commands and packages to execute |
67 | int m_numCommands; // Number of commands to be executed | 70 | int m_numCommands; // Number of commands to be executed |
68 | int m_currCommand; // Number of currently executing command | 71 | int m_currCommand; // Number of currently executing command |
69 | OPackage::Command m_command[3]; // List of commands to be executed | 72 | OPackage::Command m_command[3]; // List of commands to be executed |
70 | QStringList *m_packages[3]; // Lists of package names associated to commands (m_command[]) | 73 | QStringList m_packages[3]; // Lists of package names associated to commands (m_command[]) |
71 | 74 | ||
72 | private slots: | 75 | private slots: |
73 | // UI control slots | 76 | // UI control slots |
74 | void slotDisplayAvailSpace( const QString &destination ); | 77 | void slotDisplayAvailSpace( const QString &destination ); |
75 | void slotBtnStart(); | 78 | void slotBtnStart(); |
76 | void slotBtnOptions(); | 79 | void slotBtnOptions(); |
77 | 80 | ||
78 | // Execution slots | 81 | // Execution slots |
79 | void slotOutput( char *msg ); | 82 | void slotOutput( char *msg ); |
80 | 83 | ||
81 | signals: | 84 | signals: |
82 | void closeInstallDlg(); | 85 | void closeInstallDlg(); |
83 | }; | 86 | }; |
84 | 87 | ||
85 | #endif | 88 | #endif |
diff --git a/noncore/settings/packagemanager/mainwindow.cpp b/noncore/settings/packagemanager/mainwindow.cpp index 349094d..5e15874 100644 --- a/noncore/settings/packagemanager/mainwindow.cpp +++ b/noncore/settings/packagemanager/mainwindow.cpp | |||
@@ -1,775 +1,765 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | 3 | ||
4 | =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> | 4 | =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This file is free software; you can | 7 | _;:, .> :=|. This file is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
19 | ..}^=.= = ; Public License for more details. | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | 20 | ++= -. .` .: |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | : = ...= . :.=- You should have received a copy of the GNU |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "mainwindow.h" | 30 | #include "mainwindow.h" |
31 | #include "installdlg.h" | 31 | #include "installdlg.h" |
32 | #include "filterdlg.h" | 32 | #include "filterdlg.h" |
33 | #include "promptdlg.h" | 33 | #include "promptdlg.h" |
34 | #include "entrydlg.h" | 34 | #include "entrydlg.h" |
35 | #include "packageinfodlg.h" | 35 | #include "packageinfodlg.h" |
36 | 36 | ||
37 | #include <opie2/ofiledialog.h> | 37 | #include <opie2/ofiledialog.h> |
38 | 38 | ||
39 | #include <qpe/qcopenvelope_qws.h> | 39 | #include <qpe/qcopenvelope_qws.h> |
40 | #include <qpe/qpeapplication.h> | 40 | #include <qpe/qpeapplication.h> |
41 | #include <qpe/resource.h> | 41 | #include <qpe/resource.h> |
42 | 42 | ||
43 | #include <qaction.h> | 43 | #include <qaction.h> |
44 | #include <qdir.h> | 44 | #include <qdir.h> |
45 | #include <qlayout.h> | 45 | #include <qlayout.h> |
46 | #include <qlineedit.h> | 46 | #include <qlineedit.h> |
47 | #include <qmenubar.h> | 47 | #include <qmenubar.h> |
48 | #include <qmessagebox.h> | 48 | #include <qmessagebox.h> |
49 | #include <qpopupmenu.h> | 49 | #include <qpopupmenu.h> |
50 | #include <qtimer.h> | 50 | #include <qtimer.h> |
51 | #include <qtoolbar.h> | 51 | #include <qtoolbar.h> |
52 | #include <qwhatsthis.h> | 52 | #include <qwhatsthis.h> |
53 | 53 | ||
54 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags /*fl*/ ) | 54 | MainWindow::MainWindow( QWidget *parent, const char *name, WFlags /*fl*/ ) |
55 | : QMainWindow( parent, name, WStyle_ContextHelp ) | 55 | : QMainWindow( parent, name, WStyle_ContextHelp ) |
56 | , m_config( "packman" ) | 56 | , m_config( "packman" ) |
57 | , m_packman( &m_config, this ) | 57 | , m_packman( &m_config, this ) |
58 | , m_menuBar( this ) | 58 | , m_menuBar( this ) |
59 | , m_toolBar( this ) | 59 | , m_toolBar( this ) |
60 | , m_findBar( this ) | 60 | , m_findBar( this ) |
61 | , m_widgetStack( this ) | 61 | , m_widgetStack( this ) |
62 | , m_packageList( this ) | 62 | , m_packageList( this ) |
63 | , m_statusWidget( this ) | 63 | , m_statusWidget( this ) |
64 | , m_statusText( &m_statusWidget ) | 64 | , m_statusText( &m_statusWidget ) |
65 | , m_statusBar( &m_statusWidget ) | 65 | , m_statusBar( &m_statusWidget ) |
66 | , m_iconUpdated( Resource::loadPixmap( "packagemanager/updated" ) ) | 66 | , m_iconUpdated( Resource::loadPixmap( "packagemanager/updated" ) ) |
67 | , m_iconInstalled( Resource::loadPixmap( "installed" ) ) | 67 | , m_iconInstalled( Resource::loadPixmap( "installed" ) ) |
68 | , m_iconNull( m_iconUpdated.size() ) | 68 | , m_iconNull( m_iconUpdated.size() ) |
69 | , m_filterName( QString::null ) | 69 | , m_filterName( QString::null ) |
70 | , m_filterServer( QString::null ) | 70 | , m_filterServer( QString::null ) |
71 | , m_filterDest( QString::null ) | 71 | , m_filterDest( QString::null ) |
72 | , m_filterStatus( OPackageManager::NotDefined ) | 72 | , m_filterStatus( OPackageManager::NotDefined ) |
73 | , m_filterCategory( QString::null ) | 73 | , m_filterCategory( QString::null ) |
74 | 74 | ||
75 | { | 75 | { |
76 | // setCaption( tr( "Package Manager" ) ); | 76 | // setCaption( tr( "Package Manager" ) ); |
77 | 77 | ||
78 | m_iconNull.fill( colorGroup().base() ); | 78 | m_iconNull.fill( colorGroup().base() ); |
79 | 79 | ||
80 | connect( &m_widgetStack, SIGNAL(aboutToShow(QWidget*)), this, SLOT(slotWidgetStackShow(QWidget*)) ); | 80 | connect( &m_widgetStack, SIGNAL(aboutToShow(QWidget*)), this, SLOT(slotWidgetStackShow(QWidget*)) ); |
81 | 81 | ||
82 | // Initialize widget stack, package list and status widget | 82 | // Initialize widget stack, package list and status widget |
83 | initStatusWidget(); | 83 | initStatusWidget(); |
84 | initPackageList(); | 84 | initPackageList(); |
85 | 85 | ||
86 | m_widgetStack.addWidget( &m_statusWidget, 2 ); | 86 | m_widgetStack.addWidget( &m_statusWidget, 2 ); |
87 | m_widgetStack.addWidget( &m_packageList, 1 ); | 87 | m_widgetStack.addWidget( &m_packageList, 1 ); |
88 | setCentralWidget( &m_widgetStack ); | 88 | setCentralWidget( &m_widgetStack ); |
89 | 89 | ||
90 | // Initialize remaining user interface items | 90 | // Initialize remaining user interface items |
91 | initUI(); | 91 | initUI(); |
92 | 92 | ||
93 | // Initialize package information | 93 | // Initialize package information |
94 | QTimer::singleShot( -1, this, SLOT( initPackageInfo() ) ); | 94 | QTimer::singleShot( -1, this, SLOT( initPackageInfo() ) ); |
95 | } | 95 | } |
96 | 96 | ||
97 | void MainWindow::closeEvent( QCloseEvent *event ) | 97 | void MainWindow::closeEvent( QCloseEvent *event ) |
98 | { | 98 | { |
99 | // Close app only if either the package or status widgets are currently active | 99 | // Close app only if either the package or status widgets are currently active |
100 | bool close = m_widgetStack.visibleWidget() == &m_packageList || | 100 | bool close = m_widgetStack.visibleWidget() == &m_packageList || |
101 | m_widgetStack.visibleWidget() == &m_statusWidget; | 101 | m_widgetStack.visibleWidget() == &m_statusWidget; |
102 | if ( close ) | 102 | if ( close ) |
103 | { | 103 | { |
104 | // TODO - write out application configuration settings | 104 | // TODO - write out application configuration settings |
105 | 105 | ||
106 | // Write out package manager configuration settings | 106 | // Write out package manager configuration settings |
107 | m_packman.saveSettings(); | 107 | m_packman.saveSettings(); |
108 | event->accept(); | 108 | event->accept(); |
109 | } | 109 | } |
110 | else | 110 | else |
111 | { | 111 | { |
112 | delete m_widgetStack.visibleWidget(); | 112 | delete m_widgetStack.visibleWidget(); |
113 | m_widgetStack.raiseWidget( &m_packageList ); | 113 | m_widgetStack.raiseWidget( &m_packageList ); |
114 | event->ignore(); | 114 | event->ignore(); |
115 | } | 115 | } |
116 | } | 116 | } |
117 | 117 | ||
118 | void MainWindow::initPackageList() | 118 | void MainWindow::initPackageList() |
119 | { | 119 | { |
120 | m_packageList.addColumn( tr( "Packages" ) ); | 120 | m_packageList.addColumn( tr( "Packages" ) ); |
121 | QWhatsThis::add( &m_packageList, tr( "This is a listing of all packages.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nTap inside the box at the left to select a package. Tap and hold to view package details." ) ); | 121 | QWhatsThis::add( &m_packageList, tr( "This is a listing of all packages.\n\nA blue dot next to the package name indicates that the package is currently installed.\n\nA blue dot with a star indicates that a newer version of the package is available from the server feed.\n\nTap inside the box at the left to select a package. Tap and hold to view package details." ) ); |
122 | QPEApplication::setStylusOperation( m_packageList.viewport(), QPEApplication::RightOnHold ); | 122 | QPEApplication::setStylusOperation( m_packageList.viewport(), QPEApplication::RightOnHold ); |
123 | connect( &m_packageList, SIGNAL(rightButtonPressed(QListViewItem*,const QPoint&,int)), | 123 | connect( &m_packageList, SIGNAL(rightButtonPressed(QListViewItem*,const QPoint&,int)), |
124 | this, SLOT(slotDisplayPackageInfo(QListViewItem*)) ); | 124 | this, SLOT(slotDisplayPackageInfo(QListViewItem*)) ); |
125 | } | 125 | } |
126 | 126 | ||
127 | void MainWindow::initStatusWidget() | 127 | void MainWindow::initStatusWidget() |
128 | { | 128 | { |
129 | QVBoxLayout *layout = new QVBoxLayout( &m_statusWidget, 4, 4 ); | 129 | QVBoxLayout *layout = new QVBoxLayout( &m_statusWidget, 4, 4 ); |
130 | 130 | ||
131 | m_statusText.setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); | 131 | m_statusText.setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) ); |
132 | layout->addWidget( &m_statusText ); | 132 | layout->addWidget( &m_statusText ); |
133 | 133 | ||
134 | connect( &m_packman, SIGNAL(initStatus(int)), this, SLOT(slotInitStatusBar(int)) ); | 134 | connect( &m_packman, SIGNAL(initStatus(int)), this, SLOT(slotInitStatusBar(int)) ); |
135 | connect( &m_packman, SIGNAL(statusText(const QString&)), this, SLOT(slotStatusText(const QString&)) ); | 135 | connect( &m_packman, SIGNAL(statusText(const QString&)), this, SLOT(slotStatusText(const QString&)) ); |
136 | connect( &m_packman, SIGNAL(statusBar(int)), this, SLOT(slotStatusBar(int)) ); | 136 | connect( &m_packman, SIGNAL(statusBar(int)), this, SLOT(slotStatusBar(int)) ); |
137 | 137 | ||
138 | layout->addWidget( &m_statusBar ); | 138 | layout->addWidget( &m_statusBar ); |
139 | } | 139 | } |
140 | 140 | ||
141 | void MainWindow::initUI() | 141 | void MainWindow::initUI() |
142 | { | 142 | { |
143 | // Build menu and tool bars | 143 | // Build menu and tool bars |
144 | setToolBarsMovable( false ); | 144 | setToolBarsMovable( false ); |
145 | 145 | ||
146 | m_menuBar.setHorizontalStretchable( true ); | 146 | m_menuBar.setHorizontalStretchable( true ); |
147 | QMenuBar *mb = new QMenuBar( &m_menuBar ); | 147 | QMenuBar *mb = new QMenuBar( &m_menuBar ); |
148 | mb->setMargin( 0 ); | 148 | mb->setMargin( 0 ); |
149 | 149 | ||
150 | // Find toolbar | 150 | // Find toolbar |
151 | addToolBar( &m_findBar, QMainWindow::Top, true ); | 151 | addToolBar( &m_findBar, QMainWindow::Top, true ); |
152 | m_findBar.setHorizontalStretchable( true ); | 152 | m_findBar.setHorizontalStretchable( true ); |
153 | m_findEdit = new QLineEdit( &m_findBar ); | 153 | m_findEdit = new QLineEdit( &m_findBar ); |
154 | QWhatsThis::add( m_findEdit, tr( "Type the text to search for here." ) ); | 154 | QWhatsThis::add( m_findEdit, tr( "Type the text to search for here." ) ); |
155 | m_findBar.setStretchableWidget( m_findEdit ); | 155 | m_findBar.setStretchableWidget( m_findEdit ); |
156 | connect( m_findEdit, SIGNAL(textChanged(const QString&)), this, SLOT(slotFindChanged(const QString&)) ); | 156 | connect( m_findEdit, SIGNAL(textChanged(const QString&)), this, SLOT(slotFindChanged(const QString&)) ); |
157 | 157 | ||
158 | // Packages menu | 158 | // Packages menu |
159 | QPopupMenu *popup = new QPopupMenu( this ); | 159 | QPopupMenu *popup = new QPopupMenu( this ); |
160 | 160 | ||
161 | QAction *a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "packagemanager/update" ), QString::null, 0, this, 0 ); | 161 | QAction *a = new QAction( tr( "Update lists" ), Resource::loadPixmap( "packagemanager/update" ), QString::null, 0, this, 0 ); |
162 | a->setWhatsThis( tr( "Tap here to update package lists from servers." ) ); | 162 | a->setWhatsThis( tr( "Tap here to update package lists from servers." ) ); |
163 | connect( a, SIGNAL(activated()), this, SLOT(slotUpdate()) ); | 163 | connect( a, SIGNAL(activated()), this, SLOT(slotUpdate()) ); |
164 | a->addTo( popup ); | 164 | a->addTo( popup ); |
165 | a->addTo( &m_toolBar ); | 165 | a->addTo( &m_toolBar ); |
166 | 166 | ||
167 | QAction *actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "packagemanager/upgrade" ), QString::null, 0, this, 0 ); | 167 | QAction *actionUpgrade = new QAction( tr( "Upgrade" ), Resource::loadPixmap( "packagemanager/upgrade" ), QString::null, 0, this, 0 ); |
168 | actionUpgrade->setWhatsThis( tr( "Tap here to upgrade all installed packages if a newer version is available." ) ); | 168 | actionUpgrade->setWhatsThis( tr( "Tap here to upgrade all installed packages if a newer version is available." ) ); |
169 | connect( actionUpgrade, SIGNAL(activated()), this, SLOT(slotUpgrade()) ); | 169 | connect( actionUpgrade, SIGNAL(activated()), this, SLOT(slotUpgrade()) ); |
170 | actionUpgrade->addTo( popup ); | 170 | actionUpgrade->addTo( popup ); |
171 | actionUpgrade->addTo( &m_toolBar ); | 171 | actionUpgrade->addTo( &m_toolBar ); |
172 | 172 | ||
173 | QPixmap iconDownload = Resource::loadPixmap( "packagemanager/download" ); | 173 | QPixmap iconDownload = Resource::loadPixmap( "packagemanager/download" ); |
174 | QPixmap iconRemove = Resource::loadPixmap( "packagemanager/remove" ); | 174 | QPixmap iconRemove = Resource::loadPixmap( "packagemanager/remove" ); |
175 | QAction *actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); | 175 | QAction *actionDownload = new QAction( tr( "Download" ), iconDownload, QString::null, 0, this, 0 ); |
176 | actionDownload->setWhatsThis( tr( "Tap here to download the currently selected package(s)." ) ); | 176 | actionDownload->setWhatsThis( tr( "Tap here to download the currently selected package(s)." ) ); |
177 | connect( actionDownload, SIGNAL(activated()), this, SLOT(slotDownload()) ); | 177 | connect( actionDownload, SIGNAL(activated()), this, SLOT(slotDownload()) ); |
178 | actionDownload->addTo( popup ); | 178 | actionDownload->addTo( popup ); |
179 | actionDownload->addTo( &m_toolBar ); | 179 | actionDownload->addTo( &m_toolBar ); |
180 | 180 | ||
181 | a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "packagemanager/apply" ), QString::null, 0, this, 0 ); | 181 | a = new QAction( tr( "Apply changes" ), Resource::loadPixmap( "packagemanager/apply" ), QString::null, 0, this, 0 ); |
182 | a->setWhatsThis( tr( "Tap here to install, remove or upgrade currently selected package(s)." ) ); | 182 | a->setWhatsThis( tr( "Tap here to install, remove or upgrade currently selected package(s)." ) ); |
183 | connect( a, SIGNAL(activated()), this, SLOT(slotApply()) ); | 183 | connect( a, SIGNAL(activated()), this, SLOT(slotApply()) ); |
184 | a->addTo( popup ); | 184 | a->addTo( popup ); |
185 | a->addTo( &m_toolBar ); | 185 | a->addTo( &m_toolBar ); |
186 | 186 | ||
187 | a = new QAction( tr( "Install local package" ), Resource::loadPixmap( "folder" ), QString::null, 0, this, 0 ); | 187 | a = new QAction( tr( "Install local package" ), Resource::loadPixmap( "folder" ), QString::null, 0, this, 0 ); |
188 | a->setWhatsThis( tr( "Tap here to install a package file located on device." ) ); | 188 | a->setWhatsThis( tr( "Tap here to install a package file located on device." ) ); |
189 | connect( a, SIGNAL(activated()), this, SLOT(slotInstallLocal()) ); | 189 | connect( a, SIGNAL(activated()), this, SLOT(slotInstallLocal()) ); |
190 | a->addTo( popup ); | 190 | a->addTo( popup ); |
191 | //a->addTo( &m_toolBar ); | 191 | //a->addTo( &m_toolBar ); |
192 | 192 | ||
193 | popup->insertSeparator(); | 193 | popup->insertSeparator(); |
194 | 194 | ||
195 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); | 195 | a = new QAction( tr( "Configure" ), Resource::loadPixmap( "SettingsIcon" ), QString::null, 0, this, 0 ); |
196 | a->setWhatsThis( tr( "Tap here to configure this application." ) ); | 196 | a->setWhatsThis( tr( "Tap here to configure this application." ) ); |
197 | connect( a, SIGNAL(activated()), this, SLOT(slotConfigure()) ); | 197 | connect( a, SIGNAL(activated()), this, SLOT(slotConfigure()) ); |
198 | a->addTo( popup ); | 198 | a->addTo( popup ); |
199 | mb->insertItem( tr( "Actions" ), popup ); | 199 | mb->insertItem( tr( "Actions" ), popup ); |
200 | 200 | ||
201 | // View menu | 201 | // View menu |
202 | popup = new QPopupMenu( this ); | 202 | popup = new QPopupMenu( this ); |
203 | 203 | ||
204 | m_actionShowNotInstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); | 204 | m_actionShowNotInstalled = new QAction( tr( "Show packages not installed" ), QString::null, 0, this, 0 ); |
205 | m_actionShowNotInstalled->setToggleAction( true ); | 205 | m_actionShowNotInstalled->setToggleAction( true ); |
206 | m_actionShowNotInstalled->setWhatsThis( tr( "Tap here to show packages available which have not been installed." ) ); | 206 | m_actionShowNotInstalled->setWhatsThis( tr( "Tap here to show packages available which have not been installed." ) ); |
207 | connect( m_actionShowNotInstalled, SIGNAL(activated()), this, SLOT(slotShowNotInstalled()) ); | 207 | connect( m_actionShowNotInstalled, SIGNAL(activated()), this, SLOT(slotShowNotInstalled()) ); |
208 | m_actionShowNotInstalled->addTo( popup ); | 208 | m_actionShowNotInstalled->addTo( popup ); |
209 | 209 | ||
210 | m_actionShowInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); | 210 | m_actionShowInstalled = new QAction( tr( "Show installed packages" ), QString::null, 0, this, 0 ); |
211 | m_actionShowInstalled->setToggleAction( true ); | 211 | m_actionShowInstalled->setToggleAction( true ); |
212 | m_actionShowInstalled->setWhatsThis( tr( "Tap here to show packages currently installed on this device." ) ); | 212 | m_actionShowInstalled->setWhatsThis( tr( "Tap here to show packages currently installed on this device." ) ); |
213 | connect( m_actionShowInstalled, SIGNAL(activated()), this, SLOT(slotShowInstalled()) ); | 213 | connect( m_actionShowInstalled, SIGNAL(activated()), this, SLOT(slotShowInstalled()) ); |
214 | m_actionShowInstalled->addTo( popup ); | 214 | m_actionShowInstalled->addTo( popup ); |
215 | 215 | ||
216 | m_actionShowUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); | 216 | m_actionShowUpdated = new QAction( tr( "Show updated packages" ), QString::null, 0, this, 0 ); |
217 | m_actionShowUpdated->setToggleAction( true ); | 217 | m_actionShowUpdated->setToggleAction( true ); |
218 | m_actionShowUpdated->setWhatsThis( tr( "Tap here to show packages currently installed on this device which have a newer version available." ) ); | 218 | m_actionShowUpdated->setWhatsThis( tr( "Tap here to show packages currently installed on this device which have a newer version available." ) ); |
219 | connect( m_actionShowUpdated, SIGNAL(activated()), this, SLOT(slotShowUpdated()) ); | 219 | connect( m_actionShowUpdated, SIGNAL(activated()), this, SLOT(slotShowUpdated()) ); |
220 | m_actionShowUpdated->addTo( popup ); | 220 | m_actionShowUpdated->addTo( popup ); |
221 | 221 | ||
222 | popup->insertSeparator(); | 222 | popup->insertSeparator(); |
223 | 223 | ||
224 | m_actionFilter = new QAction( tr( "Filter" ), Resource::loadPixmap( "packagemanager/filter" ), | 224 | m_actionFilter = new QAction( tr( "Filter" ), Resource::loadPixmap( "packagemanager/filter" ), |
225 | QString::null, 0, this, 0 ); | 225 | QString::null, 0, this, 0 ); |
226 | m_actionFilter->setToggleAction( true ); | 226 | m_actionFilter->setToggleAction( true ); |
227 | m_actionFilter->setWhatsThis( tr( "Tap here to apply current filter." ) ); | 227 | m_actionFilter->setWhatsThis( tr( "Tap here to apply current filter." ) ); |
228 | connect( m_actionFilter, SIGNAL(toggled(bool)), this, SLOT(slotFilter(bool)) ); | 228 | connect( m_actionFilter, SIGNAL(toggled(bool)), this, SLOT(slotFilter(bool)) ); |
229 | m_actionFilter->addTo( popup ); | 229 | m_actionFilter->addTo( popup ); |
230 | 230 | ||
231 | a = new QAction( tr( "Filter settings" ), QString::null, 0, this, 0 ); | 231 | a = new QAction( tr( "Filter settings" ), QString::null, 0, this, 0 ); |
232 | a->setWhatsThis( tr( "Tap here to change the package filter criteria." ) ); | 232 | a->setWhatsThis( tr( "Tap here to change the package filter criteria." ) ); |
233 | connect( a, SIGNAL(activated()), this, SLOT(slotFilterChange()) ); | 233 | connect( a, SIGNAL(activated()), this, SLOT(slotFilterChange()) ); |
234 | a->addTo( popup ); | 234 | a->addTo( popup ); |
235 | 235 | ||
236 | popup->insertSeparator(); | 236 | popup->insertSeparator(); |
237 | 237 | ||
238 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); | 238 | a = new QAction( tr( "Find" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); |
239 | a->setWhatsThis( tr( "Tap here to search for text in package names." ) ); | 239 | a->setWhatsThis( tr( "Tap here to search for text in package names." ) ); |
240 | connect( a, SIGNAL(activated()), this, SLOT(slotFindShowToolbar()) ); | 240 | connect( a, SIGNAL(activated()), this, SLOT(slotFindShowToolbar()) ); |
241 | a->addTo( popup ); | 241 | a->addTo( popup ); |
242 | 242 | ||
243 | m_actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); | 243 | m_actionFindNext = new QAction( tr( "Find next" ), Resource::loadIconSet( "next" ), QString::null, 0, this, 0 ); |
244 | m_actionFindNext->setEnabled( false ); | 244 | m_actionFindNext->setEnabled( false ); |
245 | m_actionFindNext->setWhatsThis( tr( "Tap here to find the next package name containing the text you are searching for." ) ); | 245 | m_actionFindNext->setWhatsThis( tr( "Tap here to find the next package name containing the text you are searching for." ) ); |
246 | connect( m_actionFindNext, SIGNAL(activated()), this, SLOT(slotFindNext()) ); | 246 | connect( m_actionFindNext, SIGNAL(activated()), this, SLOT(slotFindNext()) ); |
247 | m_actionFindNext->addTo( popup ); | 247 | m_actionFindNext->addTo( popup ); |
248 | m_actionFindNext->addTo( &m_findBar ); | 248 | m_actionFindNext->addTo( &m_findBar ); |
249 | 249 | ||
250 | mb->insertItem( tr( "View" ), popup ); | 250 | mb->insertItem( tr( "View" ), popup ); |
251 | 251 | ||
252 | // Finish find toolbar creation | 252 | // Finish find toolbar creation |
253 | a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); | 253 | a = new QAction( QString::null, Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); |
254 | a->setWhatsThis( tr( "Tap here to hide the find toolbar." ) ); | 254 | a->setWhatsThis( tr( "Tap here to hide the find toolbar." ) ); |
255 | connect( a, SIGNAL(activated()), this, SLOT(slotFindHideToolbar()) ); | 255 | connect( a, SIGNAL(activated()), this, SLOT(slotFindHideToolbar()) ); |
256 | a->addTo( &m_findBar ); | 256 | a->addTo( &m_findBar ); |
257 | m_findBar.hide(); | 257 | m_findBar.hide(); |
258 | } | 258 | } |
259 | 259 | ||
260 | void MainWindow::loadPackageList( OPackageList *packages, bool clearList ) | 260 | void MainWindow::loadPackageList( OPackageList *packages, bool clearList ) |
261 | { | 261 | { |
262 | if ( clearList ) | 262 | if ( clearList ) |
263 | m_packageList.clear(); | 263 | m_packageList.clear(); |
264 | 264 | ||
265 | if ( packages ) | 265 | if ( packages ) |
266 | { | 266 | { |
267 | for ( OPackageListIterator packageIt( *packages ); packageIt.current(); ++packageIt ) | 267 | for ( OPackageListIterator packageIt( *packages ); packageIt.current(); ++packageIt ) |
268 | { | 268 | { |
269 | OPackage *package = packageIt.current(); | 269 | OPackage *package = packageIt.current(); |
270 | QCheckListItem *item = new QCheckListItem( &m_packageList, package->name(), | 270 | QCheckListItem *item = new QCheckListItem( &m_packageList, package->name(), |
271 | QCheckListItem::CheckBox ); | 271 | QCheckListItem::CheckBox ); |
272 | m_packageList.insertItem( item ); | 272 | m_packageList.insertItem( item ); |
273 | 273 | ||
274 | // If a different version of package is available, show update available icon | 274 | // If a different version of package is available, show update available icon |
275 | // Otherwise, show installed icon | 275 | // Otherwise, show installed icon |
276 | if ( !package->versionInstalled().isNull() ) | 276 | if ( !package->versionInstalled().isNull() ) |
277 | { | 277 | { |
278 | if ( m_packman.compareVersions( package->version(), package->versionInstalled() ) == 1 ) | 278 | if ( m_packman.compareVersions( package->version(), package->versionInstalled() ) == 1 ) |
279 | item->setPixmap( 0, m_iconUpdated ); | 279 | item->setPixmap( 0, m_iconUpdated ); |
280 | else | 280 | else |
281 | item->setPixmap( 0, m_iconInstalled ); | 281 | item->setPixmap( 0, m_iconInstalled ); |
282 | } | 282 | } |
283 | else | 283 | else |
284 | item->setPixmap( 0, m_iconNull ); | 284 | item->setPixmap( 0, m_iconNull ); |
285 | } | 285 | } |
286 | } | 286 | } |
287 | } | 287 | } |
288 | 288 | ||
289 | void MainWindow::searchForPackage( const QString &text ) | 289 | void MainWindow::searchForPackage( const QString &text ) |
290 | { | 290 | { |
291 | if ( !text.isEmpty() ) | 291 | if ( !text.isEmpty() ) |
292 | { | 292 | { |
293 | // look through package list for text startng at current position | 293 | // look through package list for text startng at current position |
294 | QCheckListItem *start = static_cast<QCheckListItem *>(m_packageList.currentItem()); | 294 | QCheckListItem *start = static_cast<QCheckListItem *>(m_packageList.currentItem()); |
295 | if ( start == 0 ) | 295 | if ( start == 0 ) |
296 | start = static_cast<QCheckListItem *>(m_packageList.firstChild()); | 296 | start = static_cast<QCheckListItem *>(m_packageList.firstChild()); |
297 | 297 | ||
298 | // for ( QCheckListItem *item = static_cast<QCheckListItem *>(start->nextSibling()); item != 0 ; | 298 | // for ( QCheckListItem *item = static_cast<QCheckListItem *>(start->nextSibling()); item != 0 ; |
299 | for ( QCheckListItem *item = static_cast<QCheckListItem *>(start); item != 0 ; | 299 | for ( QCheckListItem *item = static_cast<QCheckListItem *>(start); item != 0 ; |
300 | item = static_cast<QCheckListItem *>(item->nextSibling()) ) | 300 | item = static_cast<QCheckListItem *>(item->nextSibling()) ) |
301 | { | 301 | { |
302 | if ( item->text().lower().find( text ) != -1 ) | 302 | if ( item->text().lower().find( text ) != -1 ) |
303 | { | 303 | { |
304 | m_packageList.ensureItemVisible( item ); | 304 | m_packageList.ensureItemVisible( item ); |
305 | m_packageList.setCurrentItem( item ); | 305 | m_packageList.setCurrentItem( item ); |
306 | break; | 306 | break; |
307 | } | 307 | } |
308 | } | 308 | } |
309 | } | 309 | } |
310 | } | 310 | } |
311 | 311 | ||
312 | void MainWindow::installLocalPackage( const QString &ipkFile ) | 312 | void MainWindow::installLocalPackage( const QString &ipkFile ) |
313 | { | 313 | { |
314 | // Install selected file | 314 | // Install selected file |
315 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Install local package" ), true, | 315 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Install local package" ), true, |
316 | OPackage::Install, new QStringList( ipkFile ) ); | 316 | OPackage::Install, ipkFile ); |
317 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); | 317 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); |
318 | 318 | ||
319 | // Display widget | 319 | // Display widget |
320 | m_widgetStack.addWidget( dlg, 3 ); | 320 | m_widgetStack.addWidget( dlg, 3 ); |
321 | m_widgetStack.raiseWidget( dlg ); | 321 | m_widgetStack.raiseWidget( dlg ); |
322 | } | 322 | } |
323 | 323 | ||
324 | void MainWindow::setDocument( const QString &ipkFile ) | 324 | void MainWindow::setDocument( const QString &ipkFile ) |
325 | { | 325 | { |
326 | QString file = ipkFile; | 326 | QString file = ipkFile; |
327 | DocLnk lnk( ipkFile ); | 327 | DocLnk lnk( ipkFile ); |
328 | if ( lnk.isValid() ) | 328 | if ( lnk.isValid() ) |
329 | file = lnk.file(); | 329 | file = lnk.file(); |
330 | 330 | ||
331 | installLocalPackage( file ); | 331 | installLocalPackage( file ); |
332 | } | 332 | } |
333 | 333 | ||
334 | void MainWindow::initPackageInfo() | 334 | void MainWindow::initPackageInfo() |
335 | { | 335 | { |
336 | m_widgetStack.raiseWidget( &m_statusWidget ); | 336 | m_widgetStack.raiseWidget( &m_statusWidget ); |
337 | 337 | ||
338 | // Load package list | 338 | // Load package list |
339 | m_packman.loadAvailablePackages(); | 339 | m_packman.loadAvailablePackages(); |
340 | m_packman.loadInstalledPackages(); | 340 | m_packman.loadInstalledPackages(); |
341 | 341 | ||
342 | OPackageList *packageList = m_packman.packages(); | 342 | OPackageList *packageList = m_packman.packages(); |
343 | if ( packageList ) | 343 | if ( packageList ) |
344 | { | 344 | { |
345 | loadPackageList( packageList, true ); | 345 | loadPackageList( packageList, true ); |
346 | delete packageList; | 346 | delete packageList; |
347 | } | 347 | } |
348 | 348 | ||
349 | QWidget *widget = m_widgetStack.widget( 3 ); | 349 | QWidget *widget = m_widgetStack.widget( 3 ); |
350 | if ( !widget ) | 350 | if ( !widget ) |
351 | widget = &m_packageList; | 351 | widget = &m_packageList; |
352 | m_widgetStack.raiseWidget( widget ); | 352 | m_widgetStack.raiseWidget( widget ); |
353 | } | 353 | } |
354 | 354 | ||
355 | void MainWindow::slotWidgetStackShow( QWidget *widget ) | 355 | void MainWindow::slotWidgetStackShow( QWidget *widget ) |
356 | { | 356 | { |
357 | if ( widget == &m_packageList ) | 357 | if ( widget == &m_packageList ) |
358 | { | 358 | { |
359 | setCaption( tr( "Package Manager" ) ); | 359 | setCaption( tr( "Package Manager" ) ); |
360 | 360 | ||
361 | m_menuBar.show(); | 361 | m_menuBar.show(); |
362 | m_toolBar.show(); | 362 | m_toolBar.show(); |
363 | } | 363 | } |
364 | else | 364 | else |
365 | { | 365 | { |
366 | m_menuBar.hide(); | 366 | m_menuBar.hide(); |
367 | m_toolBar.hide(); | 367 | m_toolBar.hide(); |
368 | } | 368 | } |
369 | } | 369 | } |
370 | 370 | ||
371 | void MainWindow::slotInitStatusBar( int numSteps ) | 371 | void MainWindow::slotInitStatusBar( int numSteps ) |
372 | { | 372 | { |
373 | m_statusBar.setTotalSteps( numSteps ); | 373 | m_statusBar.setTotalSteps( numSteps ); |
374 | } | 374 | } |
375 | 375 | ||
376 | void MainWindow::slotStatusText( const QString &status ) | 376 | void MainWindow::slotStatusText( const QString &status ) |
377 | { | 377 | { |
378 | m_statusText.setText( status ); | 378 | m_statusText.setText( status ); |
379 | } | 379 | } |
380 | 380 | ||
381 | void MainWindow::slotStatusBar( int currStep ) | 381 | void MainWindow::slotStatusBar( int currStep ) |
382 | { | 382 | { |
383 | m_statusBar.setProgress( currStep ); | 383 | m_statusBar.setProgress( currStep ); |
384 | } | 384 | } |
385 | 385 | ||
386 | void MainWindow::slotUpdate() | 386 | void MainWindow::slotUpdate() |
387 | { | 387 | { |
388 | // Create package manager output widget | 388 | // Create package manager output widget |
389 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Update package information" ), false, | 389 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Update package information" ), false, |
390 | OPackage::Update ); | 390 | OPackage::Update ); |
391 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); | 391 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); |
392 | 392 | ||
393 | // Display widget | 393 | // Display widget |
394 | m_widgetStack.addWidget( dlg, 3 ); | 394 | m_widgetStack.addWidget( dlg, 3 ); |
395 | m_widgetStack.raiseWidget( dlg ); | 395 | m_widgetStack.raiseWidget( dlg ); |
396 | } | 396 | } |
397 | 397 | ||
398 | void MainWindow::slotUpgrade() | 398 | void MainWindow::slotUpgrade() |
399 | { | 399 | { |
400 | // Create package manager output widget | 400 | // Create package manager output widget |
401 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Upgrade installed packages" ), false, | 401 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Upgrade installed packages" ), false, |
402 | OPackage::Upgrade ); | 402 | OPackage::Upgrade ); |
403 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); | 403 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); |
404 | 404 | ||
405 | // Display widget | 405 | // Display widget |
406 | m_widgetStack.addWidget( dlg, 3 ); | 406 | m_widgetStack.addWidget( dlg, 3 ); |
407 | m_widgetStack.raiseWidget( dlg ); | 407 | m_widgetStack.raiseWidget( dlg ); |
408 | } | 408 | } |
409 | 409 | ||
410 | void MainWindow::slotDownload() | 410 | void MainWindow::slotDownload() |
411 | { | 411 | { |
412 | // Retrieve list of packages selected for download (if any) | 412 | // Retrieve list of packages selected for download (if any) |
413 | QStringList *workingPackages = new QStringList(); | 413 | QStringList workingPackages; |
414 | 414 | ||
415 | for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild()); | 415 | for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild()); |
416 | item != 0 ; | 416 | item != 0 ; |
417 | item = static_cast<QCheckListItem *>(item->nextSibling()) ) | 417 | item = static_cast<QCheckListItem *>(item->nextSibling()) ) |
418 | { | 418 | { |
419 | if ( item->isOn() ) | 419 | if ( item->isOn() ) |
420 | workingPackages->append( item->text() ); | 420 | workingPackages.append( item->text() ); |
421 | } | 421 | } |
422 | 422 | ||
423 | if ( workingPackages->isEmpty() ) | 423 | if ( workingPackages.isEmpty() ) |
424 | { | 424 | { |
425 | QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) ); | 425 | QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) ); |
426 | return; | 426 | return; |
427 | } | 427 | } |
428 | else | 428 | else |
429 | { | 429 | { |
430 | // Download selected packages | 430 | // Download selected packages |
431 | m_config.setGroup( "settings" ); | 431 | m_config.setGroup( "settings" ); |
432 | QString workingDir = m_config.readEntry( "DownloadDir", "/tmp" ); | 432 | QString workingDir = m_config.readEntry( "DownloadDir", "/tmp" ); |
433 | 433 | ||
434 | bool ok = false; | 434 | bool ok = false; |
435 | QString text = EntryDlg::getText( tr( "Download" ), tr( "Enter path to download package to:" ), workingDir, &ok, this ); | 435 | QString text = EntryDlg::getText( tr( "Download" ), tr( "Enter path to download package to:" ), workingDir, &ok, this ); |
436 | if ( ok && !text.isEmpty() ) | 436 | if ( ok && !text.isEmpty() ) |
437 | workingDir = text; // user entered something and pressed ok | 437 | workingDir = text; // user entered something and pressed ok |
438 | else | 438 | else |
439 | return; // user entered nothing or pressed cancel | 439 | return; // user entered nothing or pressed cancel |
440 | 440 | ||
441 | // Store download directory in config file | 441 | // Store download directory in config file |
442 | m_config.writeEntry( "DownloadDir", workingDir ); | 442 | m_config.writeEntry( "DownloadDir", workingDir ); |
443 | 443 | ||
444 | // Get starting directory | 444 | // Get starting directory |
445 | QDir::setCurrent( workingDir ); | 445 | QDir::setCurrent( workingDir ); |
446 | 446 | ||
447 | // Create package manager output widget | 447 | // Create package manager output widget |
448 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Download packages" ), false, | 448 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Download packages" ), false, |
449 | OPackage::Download, workingPackages ); | 449 | OPackage::Download, workingPackages ); |
450 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); | 450 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); |
451 | 451 | ||
452 | // Display widget | 452 | // Display widget |
453 | m_widgetStack.addWidget( dlg, 3 ); | 453 | m_widgetStack.addWidget( dlg, 3 ); |
454 | m_widgetStack.raiseWidget( dlg ); | 454 | m_widgetStack.raiseWidget( dlg ); |
455 | } | 455 | } |
456 | } | 456 | } |
457 | 457 | ||
458 | void MainWindow::slotApply() | 458 | void MainWindow::slotApply() |
459 | { | 459 | { |
460 | QStringList *removeList = 0x0; | 460 | QStringList removeList; |
461 | QStringList *installList = 0x0; | 461 | QStringList installList; |
462 | QStringList *upgradeList = 0x0; | 462 | QStringList upgradeList; |
463 | 463 | ||
464 | for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild()); | 464 | for ( QCheckListItem *item = static_cast<QCheckListItem *>(m_packageList.firstChild()); |
465 | item != 0 ; | 465 | item != 0 ; |
466 | item = static_cast<QCheckListItem *>(item->nextSibling()) ) | 466 | item = static_cast<QCheckListItem *>(item->nextSibling()) ) |
467 | { | 467 | { |
468 | if ( item->isOn() ) | 468 | if ( item->isOn() ) |
469 | { | 469 | { |
470 | OPackage *package = m_packman.findPackage( item->text() ); | 470 | OPackage *package = m_packman.findPackage( item->text() ); |
471 | if ( package ) | 471 | if ( package ) |
472 | { | 472 | { |
473 | if ( !package->versionInstalled().isNull() ) | 473 | if ( !package->versionInstalled().isNull() ) |
474 | { | 474 | { |
475 | if ( m_packman.compareVersions( package->version(), package->versionInstalled() ) == 1 ) | 475 | if ( m_packman.compareVersions( package->version(), package->versionInstalled() ) == 1 ) |
476 | { | 476 | { |
477 | // Remove/upgrade package | 477 | // Remove/upgrade package |
478 | int answer = PromptDlg::ask( tr( "Remove or upgrade" ), | 478 | int answer = PromptDlg::ask( tr( "Remove or upgrade" ), |
479 | tr( QString( "Do you wish to remove or upgrade\n%1?" ).arg( item->text() ) ), | 479 | tr( QString( "Do you wish to remove or upgrade\n%1?" ).arg( item->text() ) ), |
480 | tr( "Remove" ), tr( "Upgrade" ), this ); | 480 | tr( "Remove" ), tr( "Upgrade" ), this ); |
481 | if ( answer == 1 ) // Remove | 481 | if ( answer == 1 ) // Remove |
482 | { | 482 | { |
483 | if ( !removeList ) | 483 | removeList.append( item->text() ); |
484 | removeList = new QStringList(); | ||
485 | removeList->append( item->text() ); | ||
486 | } | 484 | } |
487 | else if ( answer == 2 ) // Upgrade | 485 | else if ( answer == 2 ) // Upgrade |
488 | { | 486 | { |
489 | if ( !upgradeList ) | 487 | upgradeList.append( item->text() ); |
490 | upgradeList = new QStringList(); | ||
491 | upgradeList->append( item->text() ); | ||
492 | } | 488 | } |
493 | } | 489 | } |
494 | else | 490 | else |
495 | { | 491 | { |
496 | // Remove/reinstall package | 492 | // Remove/reinstall package |
497 | int answer = PromptDlg::ask( tr( "Remove or reinstall" ), | 493 | int answer = PromptDlg::ask( tr( "Remove or reinstall" ), |
498 | tr( QString( "Do you wish to remove or reinstall\n%1?" ).arg( item->text() ) ), | 494 | tr( QString( "Do you wish to remove or reinstall\n%1?" ).arg( item->text() ) ), |
499 | tr( "Remove" ), tr( "Reinstall" ), this ); | 495 | tr( "Remove" ), tr( "Reinstall" ), this ); |
500 | if ( answer == 1 ) // Remove | 496 | if ( answer == 1 ) // Remove |
501 | { | 497 | { |
502 | if ( !removeList ) | 498 | removeList.append( item->text() ); |
503 | removeList = new QStringList(); | ||
504 | removeList->append( item->text() ); | ||
505 | } | 499 | } |
506 | else if ( answer == 2 ) // Reinstall | 500 | else if ( answer == 2 ) // Reinstall |
507 | { | 501 | { |
508 | if ( !installList ) | 502 | installList.append( item->text() ); |
509 | installList = new QStringList(); | ||
510 | installList->append( item->text() ); | ||
511 | } | 503 | } |
512 | } | 504 | } |
513 | } | 505 | } |
514 | else | 506 | else |
515 | { | 507 | { |
516 | // Install package | 508 | // Install package |
517 | if ( !installList ) | 509 | installList.append( item->text() ); |
518 | installList = new QStringList(); | ||
519 | installList->append( item->text() ); | ||
520 | } | 510 | } |
521 | } | 511 | } |
522 | } | 512 | } |
523 | } | 513 | } |
524 | 514 | ||
525 | // If nothing is selected, display message and exit | 515 | // If nothing is selected, display message and exit |
526 | if ( !removeList && !installList && !upgradeList ) | 516 | if ( removeList.isEmpty() && installList.isEmpty() && upgradeList.isEmpty() ) |
527 | { | 517 | { |
528 | QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) ); | 518 | QMessageBox::information( this, tr( "Nothing to do" ), tr( "No packages selected" ), tr( "OK" ) ); |
529 | return; | 519 | return; |
530 | } | 520 | } |
531 | 521 | ||
532 | // Send command only if there are packages to process | 522 | // Send command only if there are packages to process |
533 | OPackage::Command removeCmd = OPackage::NotDefined; | 523 | OPackage::Command removeCmd = OPackage::NotDefined; |
534 | if ( removeList && !removeList->isEmpty() ) | 524 | if ( !removeList.isEmpty() ) |
535 | removeCmd = OPackage::Remove; | 525 | removeCmd = OPackage::Remove; |
536 | OPackage::Command installCmd = OPackage::NotDefined; | 526 | OPackage::Command installCmd = OPackage::NotDefined; |
537 | if ( installList && !installList->isEmpty() ) | 527 | if ( !installList.isEmpty() ) |
538 | installCmd = OPackage::Install; | 528 | installCmd = OPackage::Install; |
539 | OPackage::Command upgradeCmd = OPackage::NotDefined; | 529 | OPackage::Command upgradeCmd = OPackage::NotDefined; |
540 | if ( upgradeList && !upgradeList->isEmpty() ) | 530 | if ( !upgradeList.isEmpty() ) |
541 | upgradeCmd = OPackage::Upgrade; | 531 | upgradeCmd = OPackage::Upgrade; |
542 | 532 | ||
543 | // Create package manager output widget | 533 | // Create package manager output widget |
544 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Apply changes" ), true, | 534 | InstallDlg *dlg = new InstallDlg( this, &m_packman, tr( "Apply changes" ), true, |
545 | removeCmd, removeList, | 535 | removeCmd, removeList, |
546 | installCmd, installList, | 536 | installCmd, installList, |
547 | upgradeCmd, upgradeList ); | 537 | upgradeCmd, upgradeList ); |
548 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); | 538 | connect( dlg, SIGNAL(closeInstallDlg()), this, SLOT(slotCloseDlg()) ); |
549 | 539 | ||
550 | // Display widget | 540 | // Display widget |
551 | m_widgetStack.addWidget( dlg, 3 ); | 541 | m_widgetStack.addWidget( dlg, 3 ); |
552 | m_widgetStack.raiseWidget( dlg ); | 542 | m_widgetStack.raiseWidget( dlg ); |
553 | } | 543 | } |
554 | 544 | ||
555 | void MainWindow::slotInstallLocal() | 545 | void MainWindow::slotInstallLocal() |
556 | { | 546 | { |
557 | // Display file open dialog with only package files | 547 | // Display file open dialog with only package files |
558 | MimeTypes type; | 548 | MimeTypes type; |
559 | QStringList packages; | 549 | QStringList packages; |
560 | packages << "application/ipkg"; | 550 | packages << "application/ipkg"; |
561 | type.insert( tr( "Application Packages" ), packages ); | 551 | type.insert( tr( "Application Packages" ), packages ); |
562 | QString package = Opie::Ui::OFileDialog::getOpenFileName( Opie::Ui::OFileSelector::NORMAL, | 552 | QString package = Opie::Ui::OFileDialog::getOpenFileName( Opie::Ui::OFileSelector::NORMAL, |
563 | "/", QString::null, type ); | 553 | "/", QString::null, type ); |
564 | if ( !package.isNull() ) | 554 | if ( !package.isNull() ) |
565 | installLocalPackage( package ); | 555 | installLocalPackage( package ); |
566 | } | 556 | } |
567 | 557 | ||
568 | void MainWindow::slotCloseDlg() | 558 | void MainWindow::slotCloseDlg() |
569 | { | 559 | { |
570 | // Close install dialog | 560 | // Close install dialog |
571 | delete m_widgetStack.visibleWidget(); | 561 | delete m_widgetStack.visibleWidget(); |
572 | 562 | ||
573 | // Reload package list | 563 | // Reload package list |
574 | initPackageInfo(); | 564 | initPackageInfo(); |
575 | 565 | ||
576 | // Update Opie launcher links | 566 | // Update Opie launcher links |
577 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); | 567 | QCopEnvelope e("QPE/System", "linkChanged(QString)"); |
578 | QString lf = QString::null; | 568 | QString lf = QString::null; |
579 | e << lf; | 569 | e << lf; |
580 | 570 | ||
581 | // Reapply any filters previously set | 571 | // Reapply any filters previously set |
582 | if ( m_actionShowNotInstalled->isOn() ) | 572 | if ( m_actionShowNotInstalled->isOn() ) |
583 | slotShowNotInstalled(); | 573 | slotShowNotInstalled(); |
584 | else if ( m_actionShowInstalled->isOn() ) | 574 | else if ( m_actionShowInstalled->isOn() ) |
585 | slotShowInstalled(); | 575 | slotShowInstalled(); |
586 | else if ( m_actionShowUpdated->isOn() ) | 576 | else if ( m_actionShowUpdated->isOn() ) |
587 | slotShowUpdated(); | 577 | slotShowUpdated(); |
588 | else if ( m_actionFilter->isOn() ) | 578 | else if ( m_actionFilter->isOn() ) |
589 | slotFilter( true ); | 579 | slotFilter( true ); |
590 | } | 580 | } |
591 | 581 | ||
592 | void MainWindow::slotConfigure() | 582 | void MainWindow::slotConfigure() |
593 | { | 583 | { |
594 | if ( m_packman.configureDlg( false ) ) | 584 | if ( m_packman.configureDlg( false ) ) |
595 | { | 585 | { |
596 | if ( PromptDlg::ask( tr( "Config updated" ), | 586 | if ( PromptDlg::ask( tr( "Config updated" ), |
597 | tr( "The configuration has been updated. Do you want to update server and package information now?" ), | 587 | tr( "The configuration has been updated. Do you want to update server and package information now?" ), |
598 | tr( "Yes" ), tr( "No" ), this ) == 1 ) | 588 | tr( "Yes" ), tr( "No" ), this ) == 1 ) |
599 | { | 589 | { |
600 | // Update package list and reload package info | 590 | // Update package list and reload package info |
601 | slotUpdate(); | 591 | slotUpdate(); |
602 | } | 592 | } |
603 | } | 593 | } |
604 | } | 594 | } |
605 | 595 | ||
606 | void MainWindow::slotShowNotInstalled() | 596 | void MainWindow::slotShowNotInstalled() |
607 | { | 597 | { |
608 | OPackageList *packageList; | 598 | OPackageList *packageList; |
609 | if ( m_actionShowNotInstalled->isOn() ) | 599 | if ( m_actionShowNotInstalled->isOn() ) |
610 | { | 600 | { |
611 | m_actionShowInstalled->setOn( false ); | 601 | m_actionShowInstalled->setOn( false ); |
612 | m_actionShowUpdated->setOn( false ); | 602 | m_actionShowUpdated->setOn( false ); |
613 | m_actionFilter->setOn( false ); | 603 | m_actionFilter->setOn( false ); |
614 | packageList = m_packman.filterPackages( QString::null, QString::null, QString::null, | 604 | packageList = m_packman.filterPackages( QString::null, QString::null, QString::null, |
615 | OPackageManager::NotInstalled, QString::null ); | 605 | OPackageManager::NotInstalled, QString::null ); |
616 | } | 606 | } |
617 | else | 607 | else |
618 | packageList = m_packman.packages(); | 608 | packageList = m_packman.packages(); |
619 | 609 | ||
620 | if ( packageList ) | 610 | if ( packageList ) |
621 | { | 611 | { |
622 | loadPackageList( packageList, true ); | 612 | loadPackageList( packageList, true ); |
623 | delete packageList; | 613 | delete packageList; |
624 | } | 614 | } |
625 | } | 615 | } |
626 | 616 | ||
627 | void MainWindow::slotShowInstalled() | 617 | void MainWindow::slotShowInstalled() |
628 | { | 618 | { |
629 | OPackageList *packageList; | 619 | OPackageList *packageList; |
630 | if ( m_actionShowInstalled->isOn() ) | 620 | if ( m_actionShowInstalled->isOn() ) |
631 | { | 621 | { |
632 | m_actionShowNotInstalled->setOn( false ); | 622 | m_actionShowNotInstalled->setOn( false ); |
633 | m_actionShowUpdated->setOn( false ); | 623 | m_actionShowUpdated->setOn( false ); |
634 | m_actionFilter->setOn( false ); | 624 | m_actionFilter->setOn( false ); |
635 | packageList = m_packman.filterPackages( QString::null, QString::null, QString::null, | 625 | packageList = m_packman.filterPackages( QString::null, QString::null, QString::null, |
636 | OPackageManager::Installed, QString::null ); | 626 | OPackageManager::Installed, QString::null ); |
637 | } | 627 | } |
638 | else | 628 | else |
639 | packageList = m_packman.packages(); | 629 | packageList = m_packman.packages(); |
640 | 630 | ||
641 | if ( packageList ) | 631 | if ( packageList ) |
642 | { | 632 | { |
643 | loadPackageList( packageList, true ); | 633 | loadPackageList( packageList, true ); |
644 | delete packageList; | 634 | delete packageList; |
645 | } | 635 | } |
646 | } | 636 | } |
647 | 637 | ||
648 | void MainWindow::slotShowUpdated() | 638 | void MainWindow::slotShowUpdated() |
649 | { | 639 | { |
650 | OPackageList *packageList; | 640 | OPackageList *packageList; |
651 | if ( m_actionShowUpdated->isOn() ) | 641 | if ( m_actionShowUpdated->isOn() ) |
652 | { | 642 | { |
653 | m_actionShowInstalled->setOn( false ); | 643 | m_actionShowInstalled->setOn( false ); |
654 | m_actionShowNotInstalled->setOn( false ); | 644 | m_actionShowNotInstalled->setOn( false ); |
655 | m_actionFilter->setOn( false ); | 645 | m_actionFilter->setOn( false ); |
656 | packageList = m_packman.filterPackages( QString::null, QString::null, QString::null, | 646 | packageList = m_packman.filterPackages( QString::null, QString::null, QString::null, |
657 | OPackageManager::Updated, QString::null ); | 647 | OPackageManager::Updated, QString::null ); |
658 | } | 648 | } |
659 | else | 649 | else |
660 | packageList = m_packman.packages(); | 650 | packageList = m_packman.packages(); |
661 | 651 | ||
662 | if ( packageList ) | 652 | if ( packageList ) |
663 | { | 653 | { |
664 | loadPackageList( packageList, true ); | 654 | loadPackageList( packageList, true ); |
665 | delete packageList; | 655 | delete packageList; |
666 | } | 656 | } |
667 | } | 657 | } |
668 | 658 | ||
669 | void MainWindow::slotFilterChange() | 659 | void MainWindow::slotFilterChange() |
670 | { | 660 | { |
671 | FilterDlg dlg( this, &m_packman, m_filterName, m_filterServer, m_filterDest, m_filterStatus, | 661 | FilterDlg dlg( this, &m_packman, m_filterName, m_filterServer, m_filterDest, m_filterStatus, |
672 | m_filterCategory ); | 662 | m_filterCategory ); |
673 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) | 663 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) |
674 | { | 664 | { |
675 | m_filterName = dlg.name(); | 665 | m_filterName = dlg.name(); |
676 | m_filterServer = dlg.server(); | 666 | m_filterServer = dlg.server(); |
677 | m_filterDest = dlg.destination(); | 667 | m_filterDest = dlg.destination(); |
678 | m_filterStatus = dlg.status(); | 668 | m_filterStatus = dlg.status(); |
679 | m_filterCategory = dlg.category(); | 669 | m_filterCategory = dlg.category(); |
680 | m_actionFilter->setOn( true ); | 670 | m_actionFilter->setOn( true ); |
681 | slotFilter( true ); | 671 | slotFilter( true ); |
682 | } | 672 | } |
683 | else | 673 | else |
684 | { | 674 | { |
685 | m_actionFilter->setOn( false ); | 675 | m_actionFilter->setOn( false ); |
686 | slotFilter( false ); | 676 | slotFilter( false ); |
687 | } | 677 | } |
688 | } | 678 | } |
689 | 679 | ||
690 | void MainWindow::slotFilter( bool isOn ) | 680 | void MainWindow::slotFilter( bool isOn ) |
691 | { | 681 | { |
692 | OPackageList *packageList; | 682 | OPackageList *packageList; |
693 | if ( isOn ) | 683 | if ( isOn ) |
694 | { | 684 | { |
695 | // Turn off other filtering options | 685 | // Turn off other filtering options |
696 | m_actionShowNotInstalled->setOn( false ); | 686 | m_actionShowNotInstalled->setOn( false ); |
697 | m_actionShowInstalled->setOn( false ); | 687 | m_actionShowInstalled->setOn( false ); |
698 | m_actionShowUpdated->setOn( false ); | 688 | m_actionShowUpdated->setOn( false ); |
699 | 689 | ||
700 | // If the filter settings have not been set yet, display filter dialog | 690 | // If the filter settings have not been set yet, display filter dialog |
701 | if ( m_filterName.isNull() && m_filterServer.isNull() && m_filterDest.isNull() && | 691 | if ( m_filterName.isNull() && m_filterServer.isNull() && m_filterDest.isNull() && |
702 | m_filterStatus == OPackageManager::NotDefined && m_filterCategory.isNull() ) | 692 | m_filterStatus == OPackageManager::NotDefined && m_filterCategory.isNull() ) |
703 | { | 693 | { |
704 | FilterDlg dlg( this, &m_packman, m_filterName, m_filterServer, m_filterDest, m_filterStatus, | 694 | FilterDlg dlg( this, &m_packman, m_filterName, m_filterServer, m_filterDest, m_filterStatus, |
705 | m_filterCategory ); | 695 | m_filterCategory ); |
706 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) | 696 | if ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ) |
707 | { | 697 | { |
708 | m_filterName = dlg.name(); | 698 | m_filterName = dlg.name(); |
709 | m_filterServer = dlg.server(); | 699 | m_filterServer = dlg.server(); |
710 | m_filterDest = dlg.destination(); | 700 | m_filterDest = dlg.destination(); |
711 | m_filterStatus = dlg.status(); | 701 | m_filterStatus = dlg.status(); |
712 | m_filterCategory = dlg.category(); | 702 | m_filterCategory = dlg.category(); |
713 | m_actionFilter->setOn( true ); | 703 | m_actionFilter->setOn( true ); |
714 | packageList = m_packman.filterPackages( m_filterName, m_filterServer, m_filterDest, | 704 | packageList = m_packman.filterPackages( m_filterName, m_filterServer, m_filterDest, |
715 | m_filterStatus, m_filterCategory ); | 705 | m_filterStatus, m_filterCategory ); |
716 | } | 706 | } |
717 | else | 707 | else |
718 | { | 708 | { |
719 | m_actionFilter->setOn( false ); | 709 | m_actionFilter->setOn( false ); |
720 | packageList = m_packman.packages(); | 710 | packageList = m_packman.packages(); |
721 | } | 711 | } |
722 | } | 712 | } |
723 | else | 713 | else |
724 | { | 714 | { |
725 | m_actionFilter->setOn( true ); | 715 | m_actionFilter->setOn( true ); |
726 | packageList = m_packman.filterPackages( m_filterName, m_filterServer, m_filterDest, | 716 | packageList = m_packman.filterPackages( m_filterName, m_filterServer, m_filterDest, |
727 | m_filterStatus, m_filterCategory ); | 717 | m_filterStatus, m_filterCategory ); |
728 | } | 718 | } |
729 | 719 | ||
730 | 720 | ||
731 | } | 721 | } |
732 | else | 722 | else |
733 | packageList = m_packman.packages(); | 723 | packageList = m_packman.packages(); |
734 | 724 | ||
735 | if ( packageList ) | 725 | if ( packageList ) |
736 | { | 726 | { |
737 | loadPackageList( packageList, true ); | 727 | loadPackageList( packageList, true ); |
738 | delete packageList; | 728 | delete packageList; |
739 | } | 729 | } |
740 | } | 730 | } |
741 | 731 | ||
742 | void MainWindow::slotFindShowToolbar() | 732 | void MainWindow::slotFindShowToolbar() |
743 | { | 733 | { |
744 | m_findBar.show(); | 734 | m_findBar.show(); |
745 | m_findEdit->setFocus(); | 735 | m_findEdit->setFocus(); |
746 | } | 736 | } |
747 | 737 | ||
748 | void MainWindow::slotFindHideToolbar() | 738 | void MainWindow::slotFindHideToolbar() |
749 | { | 739 | { |
750 | m_findBar.hide(); | 740 | m_findBar.hide(); |
751 | } | 741 | } |
752 | 742 | ||
753 | void MainWindow::slotFindChanged( const QString &findText ) | 743 | void MainWindow::slotFindChanged( const QString &findText ) |
754 | { | 744 | { |
755 | 745 | ||
756 | m_actionFindNext->setEnabled( !findText.isEmpty() ); | 746 | m_actionFindNext->setEnabled( !findText.isEmpty() ); |
757 | searchForPackage( findText ); | 747 | searchForPackage( findText ); |
758 | } | 748 | } |
759 | 749 | ||
760 | void MainWindow::slotFindNext() | 750 | void MainWindow::slotFindNext() |
761 | { | 751 | { |
762 | searchForPackage( m_findEdit->text() ); | 752 | searchForPackage( m_findEdit->text() ); |
763 | } | 753 | } |
764 | 754 | ||
765 | void MainWindow::slotDisplayPackageInfo( QListViewItem *packageItem ) | 755 | void MainWindow::slotDisplayPackageInfo( QListViewItem *packageItem ) |
766 | { | 756 | { |
767 | QString packageName( ( static_cast<QCheckListItem*>( packageItem ) )->text() ); | 757 | QString packageName( ( static_cast<QCheckListItem*>( packageItem ) )->text() ); |
768 | 758 | ||
769 | // Create package manager output widget | 759 | // Create package manager output widget |
770 | PackageInfoDlg *dlg = new PackageInfoDlg( this, &m_packman, packageName ); | 760 | PackageInfoDlg *dlg = new PackageInfoDlg( this, &m_packman, packageName ); |
771 | 761 | ||
772 | // Display widget | 762 | // Display widget |
773 | m_widgetStack.addWidget( dlg, 3 ); | 763 | m_widgetStack.addWidget( dlg, 3 ); |
774 | m_widgetStack.raiseWidget( dlg ); | 764 | m_widgetStack.raiseWidget( dlg ); |
775 | } | 765 | } |
diff --git a/noncore/settings/packagemanager/mainwindow.h b/noncore/settings/packagemanager/mainwindow.h index 103c664..f00e344 100644 --- a/noncore/settings/packagemanager/mainwindow.h +++ b/noncore/settings/packagemanager/mainwindow.h | |||
@@ -1,143 +1,143 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | 3 | ||
4 | =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> | 4 | =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This file is free software; you can | 7 | _;:, .> :=|. This file is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
19 | ..}^=.= = ; Public License for more details. | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | 20 | ++= -. .` .: |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | : = ...= . :.=- You should have received a copy of the GNU |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #ifndef MAINWINDOW_H | 30 | #ifndef MAINWINDOW_H |
31 | #define MAINWINDOW_H | 31 | #define MAINWINDOW_H |
32 | 32 | ||
33 | #include "opackagemanager.h" | 33 | #include "opackagemanager.h" |
34 | 34 | ||
35 | #include <qpe/config.h> | 35 | #include <qpe/config.h> |
36 | 36 | ||
37 | #include <qlabel.h> | 37 | #include <qlabel.h> |
38 | #include <qlistview.h> | 38 | #include <qlistview.h> |
39 | #include <qmainwindow.h> | 39 | #include <qmainwindow.h> |
40 | #include <qpixmap.h> | 40 | #include <qpixmap.h> |
41 | #include <qprogressbar.h> | 41 | #include <qprogressbar.h> |
42 | #include <qtoolbar.h> | 42 | #include <qtoolbar.h> |
43 | #include <qwidgetstack.h> | 43 | #include <qwidgetstack.h> |
44 | 44 | ||
45 | class QAction; | 45 | class QAction; |
46 | class QLineEdit; | 46 | class QLineEdit; |
47 | 47 | ||
48 | class MainWindow :public QMainWindow | 48 | class MainWindow :public QMainWindow |
49 | { | 49 | { |
50 | Q_OBJECT | 50 | Q_OBJECT |
51 | 51 | ||
52 | public: | 52 | public: |
53 | MainWindow( QWidget *parent = 0x0, const char *name = 0x0, WFlags fl = 0 ); | 53 | MainWindow( QWidget *parent = 0x0, const char *name = 0x0, WFlags fl = 0 ); |
54 | static QString appName() { return QString::fromLatin1( "packagemanager" ); }; | 54 | static QString appName() { return QString::fromLatin1( QUICKAPP_NAME ); }; |
55 | 55 | ||
56 | protected: | 56 | protected: |
57 | void closeEvent( QCloseEvent *event ); | 57 | void closeEvent( QCloseEvent *event ); |
58 | 58 | ||
59 | private: | 59 | private: |
60 | Config m_config; // Configuration file | 60 | Config m_config; // Configuration file |
61 | 61 | ||
62 | OPackageManager m_packman; // Package manager | 62 | OPackageManager m_packman; // Package manager |
63 | 63 | ||
64 | // Toolbars | 64 | // Toolbars |
65 | QToolBar m_menuBar; // Main toolbar containing menu | 65 | QToolBar m_menuBar; // Main toolbar containing menu |
66 | QToolBar m_toolBar; // Main toolbar | 66 | QToolBar m_toolBar; // Main toolbar |
67 | QToolBar m_findBar; // Find toolbar | 67 | QToolBar m_findBar; // Find toolbar |
68 | 68 | ||
69 | QWidgetStack m_widgetStack; // Main widget stack which contains m_packageList & m_statusWidget | 69 | QWidgetStack m_widgetStack; // Main widget stack which contains m_packageList & m_statusWidget |
70 | QListView m_packageList; // Main list view of all packages | 70 | QListView m_packageList; // Main list view of all packages |
71 | 71 | ||
72 | QLineEdit *m_findEdit; // Line edit box used for find toolbar | 72 | QLineEdit *m_findEdit; // Line edit box used for find toolbar |
73 | 73 | ||
74 | // Status widget controls | 74 | // Status widget controls |
75 | QWidget m_statusWidget; // Widget to display status during long operations | 75 | QWidget m_statusWidget; // Widget to display status during long operations |
76 | QLabel m_statusText; // Text status message | 76 | QLabel m_statusText; // Text status message |
77 | QProgressBar m_statusBar; // Progress bar showing % completed | 77 | QProgressBar m_statusBar; // Progress bar showing % completed |
78 | 78 | ||
79 | // Icon pixmaps | 79 | // Icon pixmaps |
80 | QPixmap m_iconUpdated; // Cached icon which shows when package can be updated | 80 | QPixmap m_iconUpdated; // Cached icon which shows when package can be updated |
81 | QPixmap m_iconInstalled; // Cached icon which shows when package is installed | 81 | QPixmap m_iconInstalled; // Cached icon which shows when package is installed |
82 | QPixmap m_iconNull; // Cached icon which shows when package is not installed | 82 | QPixmap m_iconNull; // Cached icon which shows when package is not installed |
83 | 83 | ||
84 | // Menu/tool bar actions | 84 | // Menu/tool bar actions |
85 | QAction *m_actionShowNotInstalled; // Action to show pakages not currently installed | 85 | QAction *m_actionShowNotInstalled; // Action to show pakages not currently installed |
86 | QAction *m_actionShowInstalled; // Action to show pakages currently installed | 86 | QAction *m_actionShowInstalled; // Action to show pakages currently installed |
87 | QAction *m_actionShowUpdated; // Action to show pakages currently installed with update available | 87 | QAction *m_actionShowUpdated; // Action to show pakages currently installed with update available |
88 | QAction *m_actionFilter; // Action to filter packages | 88 | QAction *m_actionFilter; // Action to filter packages |
89 | QAction *m_actionFindNext; // Action to find next match | 89 | QAction *m_actionFindNext; // Action to find next match |
90 | 90 | ||
91 | // Cached filter settings | 91 | // Cached filter settings |
92 | QString m_filterName; // Cached name filter value | 92 | QString m_filterName; // Cached name filter value |
93 | QString m_filterServer; // Cached server name filter value | 93 | QString m_filterServer; // Cached server name filter value |
94 | QString m_filterDest; // Cached destination name filter value | 94 | QString m_filterDest; // Cached destination name filter value |
95 | OPackageManager::Status m_filterStatus; // Cached status filter value | 95 | OPackageManager::Status m_filterStatus; // Cached status filter value |
96 | QString m_filterCategory; // Cached category filter value | 96 | QString m_filterCategory; // Cached category filter value |
97 | 97 | ||
98 | void initPackageList(); | 98 | void initPackageList(); |
99 | void initStatusWidget(); | 99 | void initStatusWidget(); |
100 | void initUI(); | 100 | void initUI(); |
101 | 101 | ||
102 | void loadPackageList( OPackageList *packages = 0x0, bool clearList = true ); | 102 | void loadPackageList( OPackageList *packages = 0x0, bool clearList = true ); |
103 | void searchForPackage( const QString &text ); | 103 | void searchForPackage( const QString &text ); |
104 | void installLocalPackage( const QString &ipkFile ); | 104 | void installLocalPackage( const QString &ipkFile ); |
105 | 105 | ||
106 | private slots: | 106 | private slots: |
107 | void setDocument( const QString &ipkFile ); | 107 | void setDocument( const QString &ipkFile ); |
108 | 108 | ||
109 | void initPackageInfo(); | 109 | void initPackageInfo(); |
110 | void slotWidgetStackShow( QWidget *widget ); | 110 | void slotWidgetStackShow( QWidget *widget ); |
111 | 111 | ||
112 | // Status widget slots | 112 | // Status widget slots |
113 | void slotInitStatusBar( int numSteps ); | 113 | void slotInitStatusBar( int numSteps ); |
114 | void slotStatusText( const QString &status ); | 114 | void slotStatusText( const QString &status ); |
115 | void slotStatusBar( int currStep ); | 115 | void slotStatusBar( int currStep ); |
116 | 116 | ||
117 | // Actions menu action slots | 117 | // Actions menu action slots |
118 | void slotUpdate(); | 118 | void slotUpdate(); |
119 | void slotUpgrade(); | 119 | void slotUpgrade(); |
120 | void slotDownload(); | 120 | void slotDownload(); |
121 | void slotApply(); | 121 | void slotApply(); |
122 | void slotInstallLocal(); | 122 | void slotInstallLocal(); |
123 | void slotCloseDlg(); | 123 | void slotCloseDlg(); |
124 | void slotConfigure(); | 124 | void slotConfigure(); |
125 | 125 | ||
126 | // View menu action slots | 126 | // View menu action slots |
127 | void slotShowNotInstalled(); | 127 | void slotShowNotInstalled(); |
128 | void slotShowInstalled(); | 128 | void slotShowInstalled(); |
129 | void slotShowUpdated(); | 129 | void slotShowUpdated(); |
130 | void slotFilterChange(); | 130 | void slotFilterChange(); |
131 | void slotFilter( bool isOn ); | 131 | void slotFilter( bool isOn ); |
132 | 132 | ||
133 | // Find action slots | 133 | // Find action slots |
134 | void slotFindShowToolbar(); | 134 | void slotFindShowToolbar(); |
135 | void slotFindHideToolbar(); | 135 | void slotFindHideToolbar(); |
136 | void slotFindChanged( const QString &findText ); | 136 | void slotFindChanged( const QString &findText ); |
137 | void slotFindNext(); | 137 | void slotFindNext(); |
138 | 138 | ||
139 | // Other slots | 139 | // Other slots |
140 | void slotDisplayPackageInfo( QListViewItem * ); | 140 | void slotDisplayPackageInfo( QListViewItem * ); |
141 | }; | 141 | }; |
142 | 142 | ||
143 | #endif | 143 | #endif |
diff --git a/noncore/settings/packagemanager/oconfitem.h b/noncore/settings/packagemanager/oconfitem.h index db77980..7c158c9 100644 --- a/noncore/settings/packagemanager/oconfitem.h +++ b/noncore/settings/packagemanager/oconfitem.h | |||
@@ -1,92 +1,92 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2003 Dan Williams <drw@handhelds.org> | 4 | Copyright (c) 2003 Dan Williams <drw@handhelds.org> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | 29 | ||
30 | */ | 30 | */ |
31 | 31 | ||
32 | #ifndef OCONFITEM_H | 32 | #ifndef OCONFITEM_H |
33 | #define OCONFITEM_H | 33 | #define OCONFITEM_H |
34 | 34 | ||
35 | #include <qlist.h> | 35 | #include <qlist.h> |
36 | #include <qstring.h> | 36 | #include <qstring.h> |
37 | 37 | ||
38 | class OConfItem | 38 | class OConfItem |
39 | { | 39 | { |
40 | public: | 40 | public: |
41 | enum Type { Source, Destination, Option, Arch, NotDefined }; | 41 | enum Type { Source, Destination, Option, Arch, NotDefined }; |
42 | 42 | ||
43 | OConfItem( Type type = NotDefined, const QString &name = 0x0, const QString &value = 0x0, | 43 | OConfItem( Type type = NotDefined, const QString &name = QString::null, |
44 | bool active = true ); | 44 | const QString &value = QString::null, bool active = true ); |
45 | 45 | ||
46 | Type type() { return m_type; } | 46 | Type type() { return m_type; } |
47 | const QString &name() { return m_name; } | 47 | const QString &name() { return m_name; } |
48 | const QString &value() { return m_value; } | 48 | const QString &value() { return m_value; } |
49 | bool active() { return m_active; } | 49 | bool active() { return m_active; } |
50 | 50 | ||
51 | void setType( Type type ) { m_type = type; } | 51 | void setType( Type type ) { m_type = type; } |
52 | void setName( const QString &name ) { m_name = name; } | 52 | void setName( const QString &name ) { m_name = name; } |
53 | void setValue( const QString &value ) { m_value = value; } | 53 | void setValue( const QString &value ) { m_value = value; } |
54 | void setActive( bool active ) { m_active = active; } | 54 | void setActive( bool active ) { m_active = active; } |
55 | 55 | ||
56 | private: | 56 | private: |
57 | Type m_type; // Type of configuration item | 57 | Type m_type; // Type of configuration item |
58 | QString m_name; // Name of item | 58 | QString m_name; // Name of item |
59 | QString m_value; // Value of item | 59 | QString m_value; // Value of item |
60 | bool m_active; // Indicates whether item is currently active | 60 | bool m_active; // Indicates whether item is currently active |
61 | }; | 61 | }; |
62 | 62 | ||
63 | class OConfItemList : public QList<OConfItem> | 63 | class OConfItemList : public QList<OConfItem> |
64 | { | 64 | { |
65 | private: | 65 | private: |
66 | 66 | ||
67 | int compareItems( QCollection::Item item1, QCollection::Item item2 ) | 67 | int compareItems( QCollection::Item item1, QCollection::Item item2 ) |
68 | { | 68 | { |
69 | // Sort by OConfItem location then by type | 69 | // Sort by OConfItem location then by type |
70 | OConfItem::Type type1 = reinterpret_cast<OConfItem*>(item1)->type(); | 70 | OConfItem::Type type1 = reinterpret_cast<OConfItem*>(item1)->type(); |
71 | OConfItem::Type type2 = reinterpret_cast<OConfItem*>(item2)->type(); | 71 | OConfItem::Type type2 = reinterpret_cast<OConfItem*>(item2)->type(); |
72 | if ( type1 < type2 ) | 72 | if ( type1 < type2 ) |
73 | return -1; | 73 | return -1; |
74 | else if ( type1 == type2 ) | 74 | else if ( type1 == type2 ) |
75 | { | 75 | { |
76 | QString name1 = reinterpret_cast<OConfItem*>(item1)->name(); | 76 | QString name1 = reinterpret_cast<OConfItem*>(item1)->name(); |
77 | QString name2 = reinterpret_cast<OConfItem*>(item2)->name(); | 77 | QString name2 = reinterpret_cast<OConfItem*>(item2)->name(); |
78 | if ( name1 < name2 ) | 78 | if ( name1 < name2 ) |
79 | return -1; | 79 | return -1; |
80 | else if ( name1 == name2 ) | 80 | else if ( name1 == name2 ) |
81 | return 0; | 81 | return 0; |
82 | else /*if ( name1 > name2 )*/ | 82 | else /*if ( name1 > name2 )*/ |
83 | return 1; | 83 | return 1; |
84 | } | 84 | } |
85 | else /*if ( type1 > type2 )*/ | 85 | else /*if ( type1 > type2 )*/ |
86 | return 1; | 86 | return 1; |
87 | } | 87 | } |
88 | }; | 88 | }; |
89 | 89 | ||
90 | typedef QListIterator<OConfItem> OConfItemListIterator; | 90 | typedef QListIterator<OConfItem> OConfItemListIterator; |
91 | 91 | ||
92 | #endif | 92 | #endif |
diff --git a/noncore/settings/packagemanager/oipkg.cpp b/noncore/settings/packagemanager/oipkg.cpp index 1978ad5..b0cc94d 100644 --- a/noncore/settings/packagemanager/oipkg.cpp +++ b/noncore/settings/packagemanager/oipkg.cpp | |||
@@ -1,576 +1,578 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2003 Dan Williams <drw@handhelds.org> | 4 | Copyright (c) 2003 Dan Williams <drw@handhelds.org> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | 29 | ||
30 | */ | 30 | */ |
31 | 31 | ||
32 | #include "oipkg.h" | 32 | #include "oipkg.h" |
33 | 33 | ||
34 | #include <qdir.h> | 34 | #include <qdir.h> |
35 | #include <qfile.h> | 35 | #include <qfile.h> |
36 | #include <qtextstream.h> | 36 | #include <qtextstream.h> |
37 | 37 | ||
38 | #include <stdlib.h> | 38 | #include <stdlib.h> |
39 | 39 | ||
40 | const QString IPKG_CONF = "/etc/ipkg.conf"; // Fully-qualified name of Ipkg primary configuration file | 40 | const QString IPKG_CONF = "/etc/ipkg.conf"; // Fully-qualified name of Ipkg primary configuration file |
41 | const QString IPKG_CONF_DIR = "/etc/ipkg"; // Directory of secondary Ipkg configuration files | 41 | const QString IPKG_CONF_DIR = "/etc/ipkg"; // Directory of secondary Ipkg configuration files |
42 | const QString IPKG_PKG_PATH = "/usr/lib/ipkg/lists"; // Directory containing server package lists | 42 | const QString IPKG_PKG_PATH = "/usr/lib/ipkg/lists"; // Directory containing server package lists |
43 | const QString IPKG_STATUS_PATH = "usr/lib/ipkg/status"; // Destination status file location | 43 | const QString IPKG_STATUS_PATH = "usr/lib/ipkg/status"; // Destination status file location |
44 | 44 | ||
45 | OIpkg *oipkg; | 45 | OIpkg *oipkg; |
46 | 46 | ||
47 | // Ipkg callback functions | 47 | // Ipkg callback functions |
48 | 48 | ||
49 | int fsignalIpkgMessage( ipkg_conf_t *conf, message_level_t level, char *msg ) | 49 | int fsignalIpkgMessage( ipkg_conf_t *conf, message_level_t level, char *msg ) |
50 | { | 50 | { |
51 | if ( conf && ( conf->verbosity < level ) ) | 51 | if ( conf && ( conf->verbosity < level ) ) |
52 | return 0; | 52 | return 0; |
53 | else | 53 | else |
54 | oipkg->ipkgMessage( msg ); | 54 | oipkg->ipkgMessage( msg ); |
55 | |||
56 | return 0; | ||
55 | } | 57 | } |
56 | 58 | ||
57 | char *fIpkgResponse( char */*question*/ ) | 59 | char *fIpkgResponse( char */*question*/ ) |
58 | { | 60 | { |
59 | return 0x0; | 61 | return 0x0; |
60 | } | 62 | } |
61 | 63 | ||
62 | int fIpkgStatus( char */*name*/, int /*status*/, char *desc, void */*userdata*/ ) | 64 | int fIpkgStatus( char */*name*/, int /*status*/, char *desc, void */*userdata*/ ) |
63 | { | 65 | { |
64 | oipkg->ipkgStatus( desc ); | 66 | oipkg->ipkgStatus( desc ); |
65 | return 0; | 67 | return 0; |
66 | } | 68 | } |
67 | 69 | ||
68 | int fIpkgFiles( char */*name*/, char *desc, char */*version*/, pkg_state_status_t /*status*/, | 70 | int fIpkgFiles( char */*name*/, char *desc, char */*version*/, pkg_state_status_t /*status*/, |
69 | void */*userdata*/ ) | 71 | void */*userdata*/ ) |
70 | { | 72 | { |
71 | oipkg->ipkgList( desc ); | 73 | oipkg->ipkgList( desc ); |
72 | return 0; | 74 | return 0; |
73 | } | 75 | } |
74 | 76 | ||
75 | OIpkg::OIpkg( Config *config, QObject *parent, const char *name ) | 77 | OIpkg::OIpkg( Config *config, QObject *parent, const char *name ) |
76 | : QObject( parent, name ) | 78 | : QObject( parent, name ) |
77 | , m_config( config ) | 79 | , m_config( config ) |
78 | , m_confInfo( NULL ) | 80 | , m_confInfo( NULL ) |
79 | , m_ipkgExecOptions( 0 ) | 81 | , m_ipkgExecOptions( 0 ) |
80 | , m_ipkgExecVerbosity( 1 ) | 82 | , m_ipkgExecVerbosity( 1 ) |
81 | { | 83 | { |
82 | oipkg = this; | 84 | oipkg = this; |
83 | 85 | ||
84 | // Initialize libipkg | 86 | // Initialize libipkg |
85 | ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ); | 87 | ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ); |
86 | 88 | ||
87 | // Default ipkg run-time arguments | 89 | // Default ipkg run-time arguments |
88 | m_ipkgArgs.noaction = false; | 90 | m_ipkgArgs.noaction = false; |
89 | m_ipkgArgs.force_defaults = true; | 91 | m_ipkgArgs.force_defaults = true; |
90 | } | 92 | } |
91 | 93 | ||
92 | OIpkg::~OIpkg() | 94 | OIpkg::~OIpkg() |
93 | { | 95 | { |
94 | // Upon destruction, ensure that items in config list are deleted with list | 96 | // Upon destruction, ensure that items in config list are deleted with list |
95 | if ( m_confInfo ) | 97 | if ( m_confInfo ) |
96 | m_confInfo->setAutoDelete( true ); | 98 | m_confInfo->setAutoDelete( true ); |
97 | 99 | ||
98 | // Free up libipkg resources | 100 | // Free up libipkg resources |
99 | ipkg_deinit( &m_ipkgArgs ); | 101 | ipkg_deinit( &m_ipkgArgs ); |
100 | } | 102 | } |
101 | 103 | ||
102 | OConfItemList *OIpkg::configItems() | 104 | OConfItemList *OIpkg::configItems() |
103 | { | 105 | { |
104 | // Retrieve all configuration items | 106 | // Retrieve all configuration items |
105 | return filterConfItems(); | 107 | return filterConfItems(); |
106 | } | 108 | } |
107 | 109 | ||
108 | OConfItemList *OIpkg::servers() | 110 | OConfItemList *OIpkg::servers() |
109 | { | 111 | { |
110 | // Retrieve only servers | 112 | // Retrieve only servers |
111 | return filterConfItems( OConfItem::Source ); | 113 | return filterConfItems( OConfItem::Source ); |
112 | } | 114 | } |
113 | 115 | ||
114 | OConfItemList *OIpkg::destinations() | 116 | OConfItemList *OIpkg::destinations() |
115 | { | 117 | { |
116 | // Retrieve only destinations | 118 | // Retrieve only destinations |
117 | return filterConfItems( OConfItem::Destination ); | 119 | return filterConfItems( OConfItem::Destination ); |
118 | } | 120 | } |
119 | 121 | ||
120 | OConfItemList *OIpkg::options() | 122 | OConfItemList *OIpkg::options() |
121 | { | 123 | { |
122 | // Retrieve only destinations | 124 | // Retrieve only destinations |
123 | return filterConfItems( OConfItem::Option ); | 125 | return filterConfItems( OConfItem::Option ); |
124 | } | 126 | } |
125 | 127 | ||
126 | void OIpkg::setConfigItems( OConfItemList *configList ) | 128 | void OIpkg::setConfigItems( OConfItemList *configList ) |
127 | { | 129 | { |
128 | if ( m_confInfo ) | 130 | if ( m_confInfo ) |
129 | delete m_confInfo; | 131 | delete m_confInfo; |
130 | 132 | ||
131 | m_confInfo = configList; | 133 | m_confInfo = configList; |
132 | 134 | ||
133 | // Write out new /etc/ipkg.conf | 135 | // Write out new /etc/ipkg.conf |
134 | QFile confFile( IPKG_CONF ); | 136 | QFile confFile( IPKG_CONF ); |
135 | if ( confFile.open( IO_WriteOnly ) ) | 137 | if ( confFile.open( IO_WriteOnly ) ) |
136 | { | 138 | { |
137 | QTextStream confStream( &confFile ); | 139 | QTextStream confStream( &confFile ); |
138 | confStream << "# Generated by Opie Package Manager\n\n"; | 140 | confStream << "# Generated by Opie Package Manager\n\n"; |
139 | 141 | ||
140 | OConfItemListIterator it( *m_confInfo ); | 142 | OConfItemListIterator it( *m_confInfo ); |
141 | for ( ; it.current(); ++it ) | 143 | for ( ; it.current(); ++it ) |
142 | { | 144 | { |
143 | OConfItem *item = it.current(); | 145 | OConfItem *item = it.current(); |
144 | 146 | ||
145 | // Only write out valid conf items | 147 | // Only write out valid conf items |
146 | if ( item->type() != OConfItem::NotDefined ) | 148 | if ( item->type() != OConfItem::NotDefined ) |
147 | { | 149 | { |
148 | QString confLine; | 150 | QString confLine; |
149 | if ( !item->active() ) | 151 | if ( !item->active() ) |
150 | confLine = "#"; | 152 | confLine = "#"; |
151 | 153 | ||
152 | switch ( item->type() ) | 154 | switch ( item->type() ) |
153 | { | 155 | { |
154 | case OConfItem::Source : confLine.append( "src " ); break; | 156 | case OConfItem::Source : confLine.append( "src " ); break; |
155 | case OConfItem::Destination : confLine.append( "dest " ); break; | 157 | case OConfItem::Destination : confLine.append( "dest " ); break; |
156 | case OConfItem::Option : confLine.append( "option " ); break; | 158 | case OConfItem::Option : confLine.append( "option " ); break; |
157 | case OConfItem::Arch : confLine.append( "arch " ); break; | 159 | case OConfItem::Arch : confLine.append( "arch " ); break; |
158 | default : break; | 160 | default : break; |
159 | }; | 161 | }; |
160 | 162 | ||
161 | confStream << confLine << " " << item->name() << " " << item->value() << "\n"; | 163 | confStream << confLine << " " << item->name() << " " << item->value() << "\n"; |
162 | } | 164 | } |
163 | } | 165 | } |
164 | 166 | ||
165 | confFile.close(); | 167 | confFile.close(); |
166 | } | 168 | } |
167 | else | 169 | else |
168 | { | 170 | { |
169 | // Problem writing to /etc/ipkg.conf, exit before removing other conf files | 171 | // Problem writing to /etc/ipkg.conf, exit before removing other conf files |
170 | return; | 172 | return; |
171 | } | 173 | } |
172 | 174 | ||
173 | // Delete /etc/ipkg/*.conf files (/etc/ipkg.conf should now have all settings | 175 | // Delete /etc/ipkg/*.conf files (/etc/ipkg.conf should now have all settings |
174 | QStringList confFiles; | 176 | QStringList confFiles; |
175 | QDir confDir( IPKG_CONF_DIR ); | 177 | QDir confDir( IPKG_CONF_DIR ); |
176 | if ( confDir.exists() ) | 178 | if ( confDir.exists() ) |
177 | { | 179 | { |
178 | confDir.setNameFilter( "*.conf" ); | 180 | confDir.setNameFilter( "*.conf" ); |
179 | confDir.setFilter( QDir::Files ); | 181 | confDir.setFilter( QDir::Files ); |
180 | confFiles = confDir.entryList( "*.conf", QDir::Files ); | 182 | confFiles = confDir.entryList( "*.conf", QDir::Files ); |
181 | 183 | ||
182 | QStringList::Iterator lastFile = confFiles.end(); | 184 | QStringList::Iterator lastFile = confFiles.end(); |
183 | for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it ) | 185 | for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it ) |
184 | { | 186 | { |
185 | // Create absolute file path if necessary | 187 | // Create absolute file path if necessary |
186 | QString absFile = (*it); | 188 | QString absFile = (*it); |
187 | if ( !absFile.startsWith( "/" ) ) | 189 | if ( !absFile.startsWith( "/" ) ) |
188 | absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); | 190 | absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); |
189 | 191 | ||
190 | // Delete file | 192 | // Delete file |
191 | QFile::remove( absFile ); | 193 | QFile::remove( absFile ); |
192 | } | 194 | } |
193 | } | 195 | } |
194 | 196 | ||
195 | // Reinitialize libipkg to pick up new configuration | 197 | // Reinitialize libipkg to pick up new configuration |
196 | ipkg_deinit( &m_ipkgArgs ); | 198 | ipkg_deinit( &m_ipkgArgs ); |
197 | ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ); | 199 | ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ); |
198 | m_ipkgArgs.noaction = false; | 200 | m_ipkgArgs.noaction = false; |
199 | m_ipkgArgs.force_defaults = true; | 201 | m_ipkgArgs.force_defaults = true; |
200 | } | 202 | } |
201 | 203 | ||
202 | void OIpkg::saveSettings() | 204 | void OIpkg::saveSettings() |
203 | { | 205 | { |
204 | // Save Ipkg execution options to application configuration file | 206 | // Save Ipkg execution options to application configuration file |
205 | if ( m_config ) | 207 | if ( m_config ) |
206 | { | 208 | { |
207 | m_config->setGroup( "Ipkg" ); | 209 | m_config->setGroup( "Ipkg" ); |
208 | m_config->writeEntry( "ExecOptions", m_ipkgExecOptions ); | 210 | m_config->writeEntry( "ExecOptions", m_ipkgExecOptions ); |
209 | m_config->writeEntry( "Verbosity", m_ipkgExecVerbosity ); | 211 | m_config->writeEntry( "Verbosity", m_ipkgExecVerbosity ); |
210 | } | 212 | } |
211 | } | 213 | } |
212 | 214 | ||
213 | OPackageList *OIpkg::availablePackages( const QString &server ) | 215 | OPackageList *OIpkg::availablePackages( const QString &server ) |
214 | { | 216 | { |
215 | // Load Ipkg configuration info if not already cached | 217 | // Load Ipkg configuration info if not already cached |
216 | if ( !m_confInfo ) | 218 | if ( !m_confInfo ) |
217 | loadConfiguration(); | 219 | loadConfiguration(); |
218 | 220 | ||
219 | // Build new server list (caller is responsible for deleting) | 221 | // Build new server list (caller is responsible for deleting) |
220 | OPackageList *pl = new OPackageList; | 222 | OPackageList *pl = new OPackageList; |
221 | 223 | ||
222 | // Open package list file | 224 | // Open package list file |
223 | QFile f( IPKG_PKG_PATH + "/" + server ); | 225 | QFile f( IPKG_PKG_PATH + "/" + server ); |
224 | if ( !f.open( IO_ReadOnly ) ) | 226 | if ( !f.open( IO_ReadOnly ) ) |
225 | return NULL; | 227 | return NULL; |
226 | QTextStream t( &f ); | 228 | QTextStream t( &f ); |
227 | 229 | ||
228 | // Process all information in package list file | 230 | // Process all information in package list file |
229 | OPackage *package = NULL; | 231 | OPackage *package = NULL; |
230 | QString line = t.readLine(); | 232 | QString line = t.readLine(); |
231 | while ( !t.eof() ) | 233 | while ( !t.eof() ) |
232 | { | 234 | { |
233 | // Determine key/value pair | 235 | // Determine key/value pair |
234 | int pos = line.find( ':', 0 ); | 236 | int pos = line.find( ':', 0 ); |
235 | QString key; | 237 | QString key; |
236 | if ( pos > -1 ) | 238 | if ( pos > -1 ) |
237 | key = line.mid( 0, pos ); | 239 | key = line.mid( 0, pos ); |
238 | else | 240 | else |
239 | key = QString::null; | 241 | key = QString::null; |
240 | QString value = line.mid( pos+2, line.length()-pos ); | 242 | QString value = line.mid( pos+2, line.length()-pos ); |
241 | 243 | ||
242 | // Allocate new package and insert into list | 244 | // Allocate new package and insert into list |
243 | if ( package == NULL && !key.isEmpty() ) | 245 | if ( package == NULL && !key.isEmpty() ) |
244 | { | 246 | { |
245 | package = new OPackage( value ); | 247 | package = new OPackage( value ); |
246 | package->setSource( server ); | 248 | package->setSource( server ); |
247 | pl->append( package ); | 249 | pl->append( package ); |
248 | } | 250 | } |
249 | 251 | ||
250 | // Update package data | 252 | // Update package data |
251 | if ( key == "Package" ) | 253 | if ( key == "Package" ) |
252 | package->setName( value ); | 254 | package->setName( value ); |
253 | else if ( key == "Version" ) | 255 | else if ( key == "Version" ) |
254 | package->setVersion( value ); | 256 | package->setVersion( value ); |
255 | else if ( key == "Section" ) | 257 | else if ( key == "Section" ) |
256 | package->setCategory( value ); | 258 | package->setCategory( value ); |
257 | //DataManager::setAvailableCategories( value ); | 259 | //DataManager::setAvailableCategories( value ); |
258 | else if ( key.isEmpty() && value.isEmpty() ) | 260 | else if ( key.isEmpty() && value.isEmpty() ) |
259 | package = NULL; | 261 | package = NULL; |
260 | 262 | ||
261 | // Skip past all description lines | 263 | // Skip past all description lines |
262 | if ( key == "Description" ) | 264 | if ( key == "Description" ) |
263 | { | 265 | { |
264 | line = t.readLine(); | 266 | line = t.readLine(); |
265 | while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) | 267 | while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) |
266 | line = t.readLine(); | 268 | line = t.readLine(); |
267 | } | 269 | } |
268 | else | 270 | else |
269 | line = t.readLine(); | 271 | line = t.readLine(); |
270 | } | 272 | } |
271 | 273 | ||
272 | f.close(); | 274 | f.close(); |
273 | 275 | ||
274 | return pl; | 276 | return pl; |
275 | } | 277 | } |
276 | 278 | ||
277 | OPackageList *OIpkg::installedPackages( const QString &destName, const QString &destPath ) | 279 | OPackageList *OIpkg::installedPackages( const QString &destName, const QString &destPath ) |
278 | { | 280 | { |
279 | // Load Ipkg configuration info if not already cached | 281 | // Load Ipkg configuration info if not already cached |
280 | if ( !m_confInfo ) | 282 | if ( !m_confInfo ) |
281 | loadConfiguration(); | 283 | loadConfiguration(); |
282 | 284 | ||
283 | // Build new server list (caller is responsible for deleting) | 285 | // Build new server list (caller is responsible for deleting) |
284 | OPackageList *pl = new OPackageList; | 286 | OPackageList *pl = new OPackageList; |
285 | 287 | ||
286 | // Open status file | 288 | // Open status file |
287 | QString path = destPath; | 289 | QString path = destPath; |
288 | if ( path.right( 1 ) != "/" ) | 290 | if ( path.right( 1 ) != "/" ) |
289 | path.append( "/" ); | 291 | path.append( "/" ); |
290 | path.append( IPKG_STATUS_PATH ); | 292 | path.append( IPKG_STATUS_PATH ); |
291 | 293 | ||
292 | QFile f( path ); | 294 | QFile f( path ); |
293 | if ( !f.open( IO_ReadOnly ) ) | 295 | if ( !f.open( IO_ReadOnly ) ) |
294 | return NULL; | 296 | return NULL; |
295 | QTextStream t( &f ); | 297 | QTextStream t( &f ); |
296 | 298 | ||
297 | // Process all information in status file | 299 | // Process all information in status file |
298 | bool newPackage = false; | 300 | bool newPackage = false; |
299 | QString line = t.readLine(); | 301 | QString line = t.readLine(); |
300 | QString name; | 302 | QString name; |
301 | QString version; | 303 | QString version; |
302 | QString status; | 304 | QString status; |
303 | 305 | ||
304 | while ( !t.eof() ) | 306 | while ( !t.eof() ) |
305 | { | 307 | { |
306 | // Determine key/value pair | 308 | // Determine key/value pair |
307 | int pos = line.find( ':', 0 ); | 309 | int pos = line.find( ':', 0 ); |
308 | QString key; | 310 | QString key; |
309 | if ( pos > -1 ) | 311 | if ( pos > -1 ) |
310 | key = line.mid( 0, pos ); | 312 | key = line.mid( 0, pos ); |
311 | else | 313 | else |
312 | key = QString::null; | 314 | key = QString::null; |
313 | QString value = line.mid( pos+2, line.length()-pos ); | 315 | QString value = line.mid( pos+2, line.length()-pos ); |
314 | 316 | ||
315 | // Allocate new package and insert into list | 317 | // Allocate new package and insert into list |
316 | if ( newPackage && !key.isEmpty() ) | 318 | if ( newPackage && !key.isEmpty() ) |
317 | { | 319 | { |
318 | // Add to list only if it has a valid name and is installed | 320 | // Add to list only if it has a valid name and is installed |
319 | if ( !name.isNull() && status.contains( " installed" ) ) | 321 | if ( !name.isNull() && status.contains( " installed" ) ) |
320 | { | 322 | { |
321 | pl->append( new OPackage( name, QString::null, version, QString::null, destName ) ); | 323 | pl->append( new OPackage( name, QString::null, version, QString::null, destName ) ); |
322 | name = QString::null; | 324 | name = QString::null; |
323 | version = QString::null; | 325 | version = QString::null; |
324 | status = QString::null; | 326 | status = QString::null; |
325 | 327 | ||
326 | newPackage = false; | 328 | newPackage = false; |
327 | } | 329 | } |
328 | } | 330 | } |
329 | 331 | ||
330 | // Update package data | 332 | // Update package data |
331 | if ( key == "Package" ) | 333 | if ( key == "Package" ) |
332 | name = value; | 334 | name = value; |
333 | else if ( key == "Version" ) | 335 | else if ( key == "Version" ) |
334 | version = value; | 336 | version = value; |
335 | else if ( key == "Status" ) | 337 | else if ( key == "Status" ) |
336 | status = value; | 338 | status = value; |
337 | else if ( key.isEmpty() && value.isEmpty() ) | 339 | else if ( key.isEmpty() && value.isEmpty() ) |
338 | newPackage = true; | 340 | newPackage = true; |
339 | 341 | ||
340 | // Skip past all description lines | 342 | // Skip past all description lines |
341 | if ( key == "Description" ) | 343 | if ( key == "Description" ) |
342 | { | 344 | { |
343 | line = t.readLine(); | 345 | line = t.readLine(); |
344 | while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) | 346 | while ( !line.isEmpty() && line.find( ':', 0 ) == -1 && !t.eof() ) |
345 | line = t.readLine(); | 347 | line = t.readLine(); |
346 | } | 348 | } |
347 | else | 349 | else |
348 | line = t.readLine(); | 350 | line = t.readLine(); |
349 | } | 351 | } |
350 | 352 | ||
351 | f.close(); | 353 | f.close(); |
352 | 354 | ||
353 | return pl; | 355 | return pl; |
354 | } | 356 | } |
355 | 357 | ||
356 | bool OIpkg::executeCommand( OPackage::Command command, QStringList *parameters, const QString &destination, | 358 | bool OIpkg::executeCommand( OPackage::Command command, const QStringList ¶meters, const QString &destination, |
357 | const QObject *receiver, const char *slotOutput, bool rawOutput ) | 359 | const QObject *receiver, const char *slotOutput, bool rawOutput ) |
358 | { | 360 | { |
359 | if ( command == OPackage::NotDefined ) | 361 | if ( command == OPackage::NotDefined ) |
360 | return false; | 362 | return false; |
361 | 363 | ||
362 | // Set ipkg run-time options/arguments | 364 | // Set ipkg run-time options/arguments |
363 | m_ipkgArgs.force_depends = ( m_ipkgExecOptions & FORCE_DEPENDS ); | 365 | m_ipkgArgs.force_depends = ( m_ipkgExecOptions & FORCE_DEPENDS ); |
364 | m_ipkgArgs.force_reinstall = ( m_ipkgExecOptions & FORCE_REINSTALL ); | 366 | m_ipkgArgs.force_reinstall = ( m_ipkgExecOptions & FORCE_REINSTALL ); |
365 | // TODO m_ipkgArgs.force_remove = ( m_ipkgExecOptions & FORCE_REMOVE ); | 367 | // TODO m_ipkgArgs.force_remove = ( m_ipkgExecOptions & FORCE_REMOVE ); |
366 | m_ipkgArgs.force_overwrite = ( m_ipkgExecOptions & FORCE_OVERWRITE ); | 368 | m_ipkgArgs.force_overwrite = ( m_ipkgExecOptions & FORCE_OVERWRITE ); |
367 | m_ipkgArgs.verbosity = m_ipkgExecVerbosity; | 369 | m_ipkgArgs.verbosity = m_ipkgExecVerbosity; |
368 | if ( m_ipkgArgs.dest ) | 370 | if ( m_ipkgArgs.dest ) |
369 | free( m_ipkgArgs.dest ); | 371 | free( m_ipkgArgs.dest ); |
370 | if ( !destination.isNull() ) | 372 | if ( !destination.isNull() ) |
371 | { | 373 | { |
372 | int len = destination.length() + 1; | 374 | int len = destination.length() + 1; |
373 | m_ipkgArgs.dest = (char *)malloc( len ); | 375 | m_ipkgArgs.dest = (char *)malloc( len ); |
374 | strncpy( m_ipkgArgs.dest, destination, destination.length() ); | 376 | strncpy( m_ipkgArgs.dest, destination, destination.length() ); |
375 | m_ipkgArgs.dest[ len - 1 ] = '\0'; | 377 | m_ipkgArgs.dest[ len - 1 ] = '\0'; |
376 | } | 378 | } |
377 | else | 379 | else |
378 | m_ipkgArgs.dest = 0x0; | 380 | m_ipkgArgs.dest = 0x0; |
379 | 381 | ||
380 | // Connect output signal to widget | 382 | // Connect output signal to widget |
381 | 383 | ||
382 | if ( rawOutput ) | 384 | if ( rawOutput ) |
383 | { | 385 | { |
384 | // if ( slotOutput ) | 386 | // if ( slotOutput ) |
385 | // connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); | 387 | // connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); |
386 | } | 388 | } |
387 | else | 389 | else |
388 | { | 390 | { |
389 | // TODO - connect to local slot and parse output before emitting signalIpkgMessage | 391 | // TODO - connect to local slot and parse output before emitting signalIpkgMessage |
390 | } | 392 | } |
391 | 393 | ||
392 | switch( command ) | 394 | switch( command ) |
393 | { | 395 | { |
394 | case OPackage::Update : { | 396 | case OPackage::Update : { |
395 | connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); | 397 | connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); |
396 | ipkg_lists_update( &m_ipkgArgs ); | 398 | ipkg_lists_update( &m_ipkgArgs ); |
397 | }; | 399 | }; |
398 | break; | 400 | break; |
399 | case OPackage::Upgrade : { | 401 | case OPackage::Upgrade : { |
400 | connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); | 402 | connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); |
401 | ipkg_packages_upgrade( &m_ipkgArgs ); | 403 | ipkg_packages_upgrade( &m_ipkgArgs ); |
402 | }; | 404 | }; |
403 | break; | 405 | break; |
404 | case OPackage::Install : { | 406 | case OPackage::Install : { |
405 | connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); | 407 | connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); |
406 | for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) | 408 | for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) |
407 | { | 409 | { |
408 | ipkg_packages_install( &m_ipkgArgs, (*it) ); | 410 | ipkg_packages_install( &m_ipkgArgs, (*it) ); |
409 | } | 411 | } |
410 | }; | 412 | }; |
411 | break; | 413 | break; |
412 | case OPackage::Remove : { | 414 | case OPackage::Remove : { |
413 | connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); | 415 | connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); |
414 | for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) | 416 | for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) |
415 | { | 417 | { |
416 | ipkg_packages_remove( &m_ipkgArgs, (*it), true ); | 418 | ipkg_packages_remove( &m_ipkgArgs, (*it), true ); |
417 | } | 419 | } |
418 | }; | 420 | }; |
419 | break; | 421 | break; |
420 | case OPackage::Download : { | 422 | case OPackage::Download : { |
421 | connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); | 423 | connect( this, SIGNAL(signalIpkgMessage(char*)), receiver, slotOutput ); |
422 | for ( QStringList::Iterator it = parameters->begin(); it != parameters->end(); ++it ) | 424 | for ( QStringList::ConstIterator it = parameters.begin(); it != parameters.end(); ++it ) |
423 | { | 425 | { |
424 | ipkg_packages_download( &m_ipkgArgs, (*it) ); | 426 | ipkg_packages_download( &m_ipkgArgs, (*it) ); |
425 | } | 427 | } |
426 | }; | 428 | }; |
427 | break; | 429 | break; |
428 | case OPackage::Info : { | 430 | case OPackage::Info : { |
429 | connect( this, SIGNAL(signalIpkgStatus(char*)), receiver, slotOutput ); | 431 | connect( this, SIGNAL(signalIpkgStatus(char*)), receiver, slotOutput ); |
430 | ipkg_packages_info( &m_ipkgArgs, (*parameters->begin()), &fIpkgStatus, 0x0 ); | 432 | ipkg_packages_info( &m_ipkgArgs, (*parameters.begin()), &fIpkgStatus, 0x0 ); |
431 | }; | 433 | }; |
432 | break; | 434 | break; |
433 | case OPackage::Files : { | 435 | case OPackage::Files : { |
434 | connect( this, SIGNAL(signalIpkgList(char*)), receiver, slotOutput ); | 436 | connect( this, SIGNAL(signalIpkgList(char*)), receiver, slotOutput ); |
435 | ipkg_package_files( &m_ipkgArgs, (*parameters->begin()), &fIpkgFiles, 0x0 ); | 437 | ipkg_package_files( &m_ipkgArgs, (*parameters.begin()), &fIpkgFiles, 0x0 ); |
436 | }; | 438 | }; |
437 | break; | 439 | break; |
438 | default : break; | 440 | default : break; |
439 | }; | 441 | }; |
440 | 442 | ||
441 | return true; | 443 | return true; |
442 | } | 444 | } |
443 | 445 | ||
444 | void OIpkg::ipkgMessage( char *msg ) | 446 | void OIpkg::ipkgMessage( char *msg ) |
445 | { | 447 | { |
446 | emit signalIpkgMessage( msg ); | 448 | emit signalIpkgMessage( msg ); |
447 | } | 449 | } |
448 | 450 | ||
449 | void OIpkg::ipkgStatus( char *status ) | 451 | void OIpkg::ipkgStatus( char *status ) |
450 | { | 452 | { |
451 | emit signalIpkgStatus( status ); | 453 | emit signalIpkgStatus( status ); |
452 | } | 454 | } |
453 | 455 | ||
454 | void OIpkg::ipkgList( char *filelist ) | 456 | void OIpkg::ipkgList( char *filelist ) |
455 | { | 457 | { |
456 | emit signalIpkgList( filelist ); | 458 | emit signalIpkgList( filelist ); |
457 | } | 459 | } |
458 | 460 | ||
459 | void OIpkg::loadConfiguration() | 461 | void OIpkg::loadConfiguration() |
460 | { | 462 | { |
461 | if ( m_confInfo ) | 463 | if ( m_confInfo ) |
462 | delete m_confInfo; | 464 | delete m_confInfo; |
463 | 465 | ||
464 | // Load configuration item list | 466 | // Load configuration item list |
465 | m_confInfo = new OConfItemList(); | 467 | m_confInfo = new OConfItemList(); |
466 | 468 | ||
467 | QStringList confFiles; | 469 | QStringList confFiles; |
468 | QDir confDir( IPKG_CONF_DIR ); | 470 | QDir confDir( IPKG_CONF_DIR ); |
469 | if ( confDir.exists() ) | 471 | if ( confDir.exists() ) |
470 | { | 472 | { |
471 | confDir.setNameFilter( "*.conf" ); | 473 | confDir.setNameFilter( "*.conf" ); |
472 | confDir.setFilter( QDir::Files ); | 474 | confDir.setFilter( QDir::Files ); |
473 | confFiles = confDir.entryList( "*.conf", QDir::Files ); | 475 | confFiles = confDir.entryList( "*.conf", QDir::Files ); |
474 | } | 476 | } |
475 | confFiles << IPKG_CONF; | 477 | confFiles << IPKG_CONF; |
476 | 478 | ||
477 | QStringList::Iterator lastFile = confFiles.end(); | 479 | QStringList::Iterator lastFile = confFiles.end(); |
478 | for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it ) | 480 | for ( QStringList::Iterator it = confFiles.begin(); it != lastFile; ++it ) |
479 | { | 481 | { |
480 | // Create absolute file path if necessary | 482 | // Create absolute file path if necessary |
481 | QString absFile = (*it); | 483 | QString absFile = (*it); |
482 | if ( !absFile.startsWith( "/" ) ) | 484 | if ( !absFile.startsWith( "/" ) ) |
483 | absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); | 485 | absFile.prepend( QString( IPKG_CONF_DIR ) + "/" ); |
484 | 486 | ||
485 | // Read in file | 487 | // Read in file |
486 | QFile f( absFile ); | 488 | QFile f( absFile ); |
487 | if ( f.open( IO_ReadOnly ) ) | 489 | if ( f.open( IO_ReadOnly ) ) |
488 | { | 490 | { |
489 | QTextStream s( &f ); | 491 | QTextStream s( &f ); |
490 | while ( !s.eof() ) | 492 | while ( !s.eof() ) |
491 | { | 493 | { |
492 | 494 | ||
493 | QString line = s.readLine().simplifyWhiteSpace(); | 495 | QString line = s.readLine().simplifyWhiteSpace(); |
494 | 496 | ||
495 | // Parse line and save info to the conf options list | 497 | // Parse line and save info to the conf options list |
496 | if ( !line.isEmpty() ) | 498 | if ( !line.isEmpty() ) |
497 | { | 499 | { |
498 | if ( !line.startsWith( "#" ) || | 500 | if ( !line.startsWith( "#" ) || |
499 | line.startsWith( "#src" ) || | 501 | line.startsWith( "#src" ) || |
500 | line.startsWith( "#dest" ) || | 502 | line.startsWith( "#dest" ) || |
501 | line.startsWith( "#arch" ) || | 503 | line.startsWith( "#arch" ) || |
502 | line.startsWith( "#option" ) ) | 504 | line.startsWith( "#option" ) ) |
503 | { | 505 | { |
504 | int pos = line.find( ' ', 1 ); | 506 | int pos = line.find( ' ', 1 ); |
505 | 507 | ||
506 | // Type | 508 | // Type |
507 | QString typeStr = line.left( pos ); | 509 | QString typeStr = line.left( pos ); |
508 | OConfItem::Type type; | 510 | OConfItem::Type type; |
509 | if ( typeStr == "src" || typeStr == "#src" ) | 511 | if ( typeStr == "src" || typeStr == "#src" ) |
510 | type = OConfItem::Source; | 512 | type = OConfItem::Source; |
511 | else if ( typeStr == "dest" || typeStr == "#dest" ) | 513 | else if ( typeStr == "dest" || typeStr == "#dest" ) |
512 | type = OConfItem::Destination; | 514 | type = OConfItem::Destination; |
513 | else if ( typeStr == "option" || typeStr == "#option" ) | 515 | else if ( typeStr == "option" || typeStr == "#option" ) |
514 | type = OConfItem::Option; | 516 | type = OConfItem::Option; |
515 | else if ( typeStr == "arch" || typeStr == "#arch" ) | 517 | else if ( typeStr == "arch" || typeStr == "#arch" ) |
516 | type = OConfItem::Arch; | 518 | type = OConfItem::Arch; |
517 | else | 519 | else |
518 | type = OConfItem::NotDefined; | 520 | type = OConfItem::NotDefined; |
519 | ++pos; | 521 | ++pos; |
520 | int endpos = line.find( ' ', pos ); | 522 | int endpos = line.find( ' ', pos ); |
521 | 523 | ||
522 | // Name | 524 | // Name |
523 | QString name = line.mid( pos, endpos - pos ); | 525 | QString name = line.mid( pos, endpos - pos ); |
524 | 526 | ||
525 | // Value | 527 | // Value |
526 | QString value = ""; | 528 | QString value = ""; |
527 | if ( endpos > -1 ) | 529 | if ( endpos > -1 ) |
528 | value = line.right( line.length() - endpos - 1 ); | 530 | value = line.right( line.length() - endpos - 1 ); |
529 | 531 | ||
530 | // Active | 532 | // Active |
531 | bool active = !line.startsWith( "#" ); | 533 | bool active = !line.startsWith( "#" ); |
532 | 534 | ||
533 | // Add to list | 535 | // Add to list |
534 | m_confInfo->append( new OConfItem( type, name, value, active ) ); | 536 | m_confInfo->append( new OConfItem( type, name, value, active ) ); |
535 | } | 537 | } |
536 | } | 538 | } |
537 | } | 539 | } |
538 | 540 | ||
539 | f.close(); | 541 | f.close(); |
540 | } | 542 | } |
541 | } | 543 | } |
542 | 544 | ||
543 | // Load Ipkg execution options from application configuration file | 545 | // Load Ipkg execution options from application configuration file |
544 | if ( m_config ) | 546 | if ( m_config ) |
545 | { | 547 | { |
546 | m_config->setGroup( "Ipkg" ); | 548 | m_config->setGroup( "Ipkg" ); |
547 | m_ipkgExecOptions = m_config->readNumEntry( "ExecOptions", m_ipkgExecOptions ); | 549 | m_ipkgExecOptions = m_config->readNumEntry( "ExecOptions", m_ipkgExecOptions ); |
548 | m_ipkgExecVerbosity = m_config->readNumEntry( "Verbosity", m_ipkgExecVerbosity ); | 550 | m_ipkgExecVerbosity = m_config->readNumEntry( "Verbosity", m_ipkgExecVerbosity ); |
549 | } | 551 | } |
550 | } | 552 | } |
551 | 553 | ||
552 | OConfItemList *OIpkg::filterConfItems( OConfItem::Type typefilter ) | 554 | OConfItemList *OIpkg::filterConfItems( OConfItem::Type typefilter ) |
553 | { | 555 | { |
554 | // Load Ipkg configuration info if not already cached | 556 | // Load Ipkg configuration info if not already cached |
555 | if ( !m_confInfo ) | 557 | if ( !m_confInfo ) |
556 | loadConfiguration(); | 558 | loadConfiguration(); |
557 | 559 | ||
558 | // Build new server list (caller is responsible for deleting) | 560 | // Build new server list (caller is responsible for deleting) |
559 | OConfItemList *sl = new OConfItemList; | 561 | OConfItemList *sl = new OConfItemList; |
560 | 562 | ||
561 | // If typefilter is empty, retrieve all items | 563 | // If typefilter is empty, retrieve all items |
562 | bool retrieveAll = ( typefilter == OConfItem::NotDefined ); | 564 | bool retrieveAll = ( typefilter == OConfItem::NotDefined ); |
563 | 565 | ||
564 | // Parse configuration info for servers | 566 | // Parse configuration info for servers |
565 | OConfItemListIterator it( *m_confInfo ); | 567 | OConfItemListIterator it( *m_confInfo ); |
566 | for ( ; it.current(); ++it ) | 568 | for ( ; it.current(); ++it ) |
567 | { | 569 | { |
568 | OConfItem *item = it.current(); | 570 | OConfItem *item = it.current(); |
569 | if ( retrieveAll || item->type() == typefilter ) | 571 | if ( retrieveAll || item->type() == typefilter ) |
570 | { | 572 | { |
571 | sl->append( item ); | 573 | sl->append( item ); |
572 | } | 574 | } |
573 | } | 575 | } |
574 | 576 | ||
575 | return sl; | 577 | return sl; |
576 | } | 578 | } |
diff --git a/noncore/settings/packagemanager/oipkg.h b/noncore/settings/packagemanager/oipkg.h index b8a859a..3c96200 100644 --- a/noncore/settings/packagemanager/oipkg.h +++ b/noncore/settings/packagemanager/oipkg.h | |||
@@ -1,105 +1,108 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2003 Dan Williams <drw@handhelds.org> | 4 | Copyright (c) 2003 Dan Williams <drw@handhelds.org> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | 29 | ||
30 | */ | 30 | */ |
31 | 31 | ||
32 | #ifndef OIPKG_H | 32 | #ifndef OIPKG_H |
33 | #define OIPKG_H | 33 | #define OIPKG_H |
34 | 34 | ||
35 | #include "oconfitem.h" | 35 | #include "oconfitem.h" |
36 | #include "opackage.h" | 36 | #include "opackage.h" |
37 | 37 | ||
38 | #include <qpe/config.h> | 38 | #include <qpe/config.h> |
39 | 39 | ||
40 | #include <qobject.h> | 40 | #include <qobject.h> |
41 | 41 | ||
42 | extern "C" { | 42 | extern "C" { |
43 | #include <libipkg.h> | 43 | #include <libipkg.h> |
44 | }; | 44 | }; |
45 | 45 | ||
46 | // Ipkg execution options (m_ipkgExecOptions) | 46 | // Ipkg execution options (m_ipkgExecOptions) |
47 | #define FORCE_DEPENDS 0x0001 | 47 | #define FORCE_DEPENDS 0x0001 |
48 | #define FORCE_REMOVE 0x0002 | 48 | #define FORCE_REMOVE 0x0002 |
49 | #define FORCE_REINSTALL 0x0004 | 49 | #define FORCE_REINSTALL 0x0004 |
50 | #define FORCE_OVERWRITE 0x0008 | 50 | #define FORCE_OVERWRITE 0x0008 |
51 | 51 | ||
52 | class OConfItemList; | 52 | class OConfItemList; |
53 | 53 | ||
54 | class OIpkg : public QObject | 54 | class OIpkg : public QObject |
55 | { | 55 | { |
56 | Q_OBJECT | 56 | Q_OBJECT |
57 | 57 | ||
58 | public: | 58 | public: |
59 | OIpkg( Config *config = 0x0, QObject *parent = 0x0, const char *name = 0x0 ); | 59 | OIpkg( Config *config = 0x0, QObject *parent = 0x0, const char *name = 0x0 ); |
60 | ~OIpkg(); | 60 | ~OIpkg(); |
61 | 61 | ||
62 | OConfItemList *configItems(); | 62 | OConfItemList *configItems(); |
63 | OConfItemList *servers(); | 63 | OConfItemList *servers(); |
64 | OConfItemList *destinations(); | 64 | OConfItemList *destinations(); |
65 | OConfItemList *options(); | 65 | OConfItemList *options(); |
66 | 66 | ||
67 | int ipkgExecOptions() { return m_ipkgExecOptions; } | 67 | int ipkgExecOptions() { return m_ipkgExecOptions; } |
68 | int ipkgExecVerbosity() { return m_ipkgExecVerbosity; } | 68 | int ipkgExecVerbosity() { return m_ipkgExecVerbosity; } |
69 | 69 | ||
70 | void setConfigItems( OConfItemList *configList ); | 70 | void setConfigItems( OConfItemList *configList ); |
71 | void setIpkgExecOptions( int options ) { m_ipkgExecOptions = options; } | 71 | void setIpkgExecOptions( int options ) { m_ipkgExecOptions = options; } |
72 | void setIpkgExecVerbosity( int verbosity ) { m_ipkgExecVerbosity = verbosity; } | 72 | void setIpkgExecVerbosity( int verbosity ) { m_ipkgExecVerbosity = verbosity; } |
73 | 73 | ||
74 | void saveSettings(); | 74 | void saveSettings(); |
75 | 75 | ||
76 | OPackageList *availablePackages( const QString &server = QString::null ); | 76 | OPackageList *availablePackages( const QString &server = QString::null ); |
77 | OPackageList *installedPackages( const QString &destName = QString::null, | 77 | OPackageList *installedPackages( const QString &destName = QString::null, |
78 | const QString &destPath = QString::null ); | 78 | const QString &destPath = QString::null ); |
79 | 79 | ||
80 | bool executeCommand( OPackage::Command command = OPackage::NotDefined, QStringList *parameters = 0x0, | 80 | bool executeCommand( OPackage::Command command = OPackage::NotDefined, |
81 | const QString &destination = QString::null, const QObject *receiver = 0x0, | 81 | const QStringList ¶meters = QStringList(), |
82 | const char *slotOutput = 0x0, bool rawOutput = true ); | 82 | const QString &destination = QString::null, |
83 | const QObject *receiver = 0x0, | ||
84 | const char *slotOutput = 0x0, | ||
85 | bool rawOutput = true ); | ||
83 | void abortCommand(); | 86 | void abortCommand(); |
84 | 87 | ||
85 | void ipkgMessage( char *msg ); | 88 | void ipkgMessage( char *msg ); |
86 | void ipkgStatus( char *status ); | 89 | void ipkgStatus( char *status ); |
87 | void ipkgList( char *filelist ); | 90 | void ipkgList( char *filelist ); |
88 | 91 | ||
89 | private: | 92 | private: |
90 | Config *m_config; // Pointer to application configuration file | 93 | Config *m_config; // Pointer to application configuration file |
91 | args_t m_ipkgArgs; // libipkg configuration arguments | 94 | args_t m_ipkgArgs; // libipkg configuration arguments |
92 | OConfItemList *m_confInfo; // Contains info from all Ipkg configuration files | 95 | OConfItemList *m_confInfo; // Contains info from all Ipkg configuration files |
93 | int m_ipkgExecOptions; // Bit-mapped flags for Ipkg execution options | 96 | int m_ipkgExecOptions; // Bit-mapped flags for Ipkg execution options |
94 | int m_ipkgExecVerbosity; // Ipkg execution verbosity level | 97 | int m_ipkgExecVerbosity; // Ipkg execution verbosity level |
95 | 98 | ||
96 | void loadConfiguration(); | 99 | void loadConfiguration(); |
97 | OConfItemList *filterConfItems( OConfItem::Type typefilter = OConfItem::NotDefined ); | 100 | OConfItemList *filterConfItems( OConfItem::Type typefilter = OConfItem::NotDefined ); |
98 | 101 | ||
99 | signals: | 102 | signals: |
100 | void signalIpkgMessage( char *msg ); | 103 | void signalIpkgMessage( char *msg ); |
101 | void signalIpkgStatus( char *status ); | 104 | void signalIpkgStatus( char *status ); |
102 | void signalIpkgList( char *filelist ); | 105 | void signalIpkgList( char *filelist ); |
103 | }; | 106 | }; |
104 | 107 | ||
105 | #endif | 108 | #endif |
diff --git a/noncore/settings/packagemanager/opackagemanager.cpp b/noncore/settings/packagemanager/opackagemanager.cpp index f75d3b3..cbddfe7 100644 --- a/noncore/settings/packagemanager/opackagemanager.cpp +++ b/noncore/settings/packagemanager/opackagemanager.cpp | |||
@@ -1,412 +1,412 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2003 Dan Williams <drw@handhelds.org> | 4 | Copyright (c) 2003 Dan Williams <drw@handhelds.org> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | 29 | ||
30 | */ | 30 | */ |
31 | 31 | ||
32 | #include "opackagemanager.h" | 32 | #include "opackagemanager.h" |
33 | #include "oipkgconfigdlg.h" | 33 | #include "oipkgconfigdlg.h" |
34 | 34 | ||
35 | #include <qpe/qpeapplication.h> | 35 | #include <qpe/qpeapplication.h> |
36 | 36 | ||
37 | #include <ctype.h> | 37 | #include <ctype.h> |
38 | 38 | ||
39 | OPackageManager::OPackageManager( Config *config, QObject *parent, const char *name ) | 39 | OPackageManager::OPackageManager( Config *config, QObject *parent, const char *name ) |
40 | : QObject( parent, name ) | 40 | : QObject( parent, name ) |
41 | , m_config( config ) | 41 | , m_config( config ) |
42 | , m_ipkg( m_config, this ) | 42 | , m_ipkg( m_config, this ) |
43 | , m_packages( 9973 ) | 43 | , m_packages( 9973 ) |
44 | , m_categories() | 44 | , m_categories() |
45 | { | 45 | { |
46 | m_packages.setAutoDelete( true ); | 46 | m_packages.setAutoDelete( true ); |
47 | } | 47 | } |
48 | 48 | ||
49 | void OPackageManager::loadAvailablePackages() | 49 | void OPackageManager::loadAvailablePackages() |
50 | { | 50 | { |
51 | m_packages.clear(); | 51 | m_packages.clear(); |
52 | 52 | ||
53 | OConfItemList *serverList = m_ipkg.servers(); | 53 | OConfItemList *serverList = m_ipkg.servers(); |
54 | 54 | ||
55 | if ( serverList ) | 55 | if ( serverList ) |
56 | { | 56 | { |
57 | // Initialize status messaging | 57 | // Initialize status messaging |
58 | emit initStatus( serverList->count() ); | 58 | emit initStatus( serverList->count() ); |
59 | int serverCount = 0; | 59 | int serverCount = 0; |
60 | 60 | ||
61 | bool categoryAdded = false; | 61 | bool categoryAdded = false; |
62 | 62 | ||
63 | for ( OConfItemListIterator serverIt( *serverList ); serverIt.current(); ++serverIt ) | 63 | for ( OConfItemListIterator serverIt( *serverList ); serverIt.current(); ++serverIt ) |
64 | { | 64 | { |
65 | OConfItem *server = serverIt.current(); | 65 | OConfItem *server = serverIt.current(); |
66 | 66 | ||
67 | // Process server only if it is active | 67 | // Process server only if it is active |
68 | if ( server->active() ) | 68 | if ( server->active() ) |
69 | { | 69 | { |
70 | // Update status | 70 | // Update status |
71 | QString status = tr( "Reading available packages:\n\t" ); | 71 | QString status = tr( "Reading available packages:\n\t" ); |
72 | status.append( server->name() ); | 72 | status.append( server->name() ); |
73 | emit statusText( status ); | 73 | emit statusText( status ); |
74 | ++serverCount; | 74 | ++serverCount; |
75 | emit statusBar( serverCount ); | 75 | emit statusBar( serverCount ); |
76 | qApp->processEvents(); | 76 | qApp->processEvents(); |
77 | 77 | ||
78 | OPackageList *packageList = m_ipkg.availablePackages( server->name() ); | 78 | OPackageList *packageList = m_ipkg.availablePackages( server->name() ); |
79 | if ( packageList ) | 79 | if ( packageList ) |
80 | { | 80 | { |
81 | for ( OPackageListIterator packageIt( *packageList ); packageIt.current(); ++packageIt ) | 81 | for ( OPackageListIterator packageIt( *packageList ); packageIt.current(); ++packageIt ) |
82 | { | 82 | { |
83 | OPackage *package = packageIt.current(); | 83 | OPackage *package = packageIt.current(); |
84 | 84 | ||
85 | // Load package info | 85 | // Load package info |
86 | if ( !m_packages.find( package->name() ) ) | 86 | if ( !m_packages.find( package->name() ) ) |
87 | m_packages.insert( package->name(), package ); | 87 | m_packages.insert( package->name(), package ); |
88 | else | 88 | else |
89 | { | 89 | { |
90 | // If new package is newer version, replace existing package | 90 | // If new package is newer version, replace existing package |
91 | OPackage *currPackage = m_packages[package->name()]; | 91 | OPackage *currPackage = m_packages[package->name()]; |
92 | if ( compareVersions( package->version(), currPackage->version() ) == 1 ) | 92 | if ( compareVersions( package->version(), currPackage->version() ) == 1 ) |
93 | m_packages.replace( package->name(), package ); | 93 | m_packages.replace( package->name(), package ); |
94 | } | 94 | } |
95 | 95 | ||
96 | // Add category to list if it doesn't already exist | 96 | // Add category to list if it doesn't already exist |
97 | if ( m_categories.grep( package->category() ).isEmpty() ) | 97 | if ( m_categories.grep( package->category() ).isEmpty() ) |
98 | { | 98 | { |
99 | m_categories << package->category(); | 99 | m_categories << package->category(); |
100 | categoryAdded = true; | 100 | categoryAdded = true; |
101 | } | 101 | } |
102 | } | 102 | } |
103 | } | 103 | } |
104 | } | 104 | } |
105 | } | 105 | } |
106 | delete serverList; | 106 | delete serverList; |
107 | 107 | ||
108 | // Sort category list if categories were added | 108 | // Sort category list if categories were added |
109 | if ( categoryAdded ) | 109 | if ( categoryAdded ) |
110 | m_categories.sort(); | 110 | m_categories.sort(); |
111 | } | 111 | } |
112 | } | 112 | } |
113 | 113 | ||
114 | void OPackageManager::loadInstalledPackages() | 114 | void OPackageManager::loadInstalledPackages() |
115 | { | 115 | { |
116 | OConfItemList *destList = m_ipkg.destinations(); | 116 | OConfItemList *destList = m_ipkg.destinations(); |
117 | 117 | ||
118 | if ( destList ) | 118 | if ( destList ) |
119 | { | 119 | { |
120 | // Initialize status messaging | 120 | // Initialize status messaging |
121 | emit initStatus( destList->count() ); | 121 | emit initStatus( destList->count() ); |
122 | int destCount = 0; | 122 | int destCount = 0; |
123 | 123 | ||
124 | bool categoryAdded = false; | 124 | bool categoryAdded = false; |
125 | 125 | ||
126 | for ( OConfItemListIterator destIt( *destList ); destIt.current(); ++destIt ) | 126 | for ( OConfItemListIterator destIt( *destList ); destIt.current(); ++destIt ) |
127 | { | 127 | { |
128 | OConfItem *destination = destIt.current(); | 128 | OConfItem *destination = destIt.current(); |
129 | 129 | ||
130 | // Process destination only if it is active | 130 | // Process destination only if it is active |
131 | if ( destination->active() ) | 131 | if ( destination->active() ) |
132 | { | 132 | { |
133 | // Update status | 133 | // Update status |
134 | QString status = tr( "Reading installed packages:\n\t" ); | 134 | QString status = tr( "Reading installed packages:\n\t" ); |
135 | status.append( destination->name() ); | 135 | status.append( destination->name() ); |
136 | emit statusText( status ); | 136 | emit statusText( status ); |
137 | ++destCount; | 137 | ++destCount; |
138 | emit statusBar( destCount ); | 138 | emit statusBar( destCount ); |
139 | qApp->processEvents(); | 139 | qApp->processEvents(); |
140 | 140 | ||
141 | OPackageList *packageList = m_ipkg.installedPackages( destination->name(), | 141 | OPackageList *packageList = m_ipkg.installedPackages( destination->name(), |
142 | destination->value() ); | 142 | destination->value() ); |
143 | if ( packageList ) | 143 | if ( packageList ) |
144 | { | 144 | { |
145 | for ( OPackageListIterator packageIt( *packageList ); packageIt.current(); ++packageIt ) | 145 | for ( OPackageListIterator packageIt( *packageList ); packageIt.current(); ++packageIt ) |
146 | { | 146 | { |
147 | OPackage *package = packageIt.current(); | 147 | OPackage *package = packageIt.current(); |
148 | OPackage *currPackage = m_packages[package->name()]; | 148 | OPackage *currPackage = m_packages[package->name()]; |
149 | if ( currPackage ) | 149 | if ( currPackage ) |
150 | { | 150 | { |
151 | // Package is in a current feed, update installed version, destination | 151 | // Package is in a current feed, update installed version, destination |
152 | currPackage->setVersionInstalled( package->versionInstalled() ); | 152 | currPackage->setVersionInstalled( package->versionInstalled() ); |
153 | currPackage->setDestination( package->destination() ); | 153 | currPackage->setDestination( package->destination() ); |
154 | 154 | ||
155 | delete package; | 155 | delete package; |
156 | } | 156 | } |
157 | else | 157 | else |
158 | { | 158 | { |
159 | // Package isn't in a current feed, add to list | 159 | // Package isn't in a current feed, add to list |
160 | m_packages.insert( package->name(), package ); | 160 | m_packages.insert( package->name(), package ); |
161 | 161 | ||
162 | // Add category to list if it doesn't already exist | 162 | // Add category to list if it doesn't already exist |
163 | if ( m_categories.grep( package->category() ).isEmpty() ) | 163 | if ( m_categories.grep( package->category() ).isEmpty() ) |
164 | { | 164 | { |
165 | m_categories << package->category(); | 165 | m_categories << package->category(); |
166 | categoryAdded = true; | 166 | categoryAdded = true; |
167 | } | 167 | } |
168 | } | 168 | } |
169 | } | 169 | } |
170 | } | 170 | } |
171 | } | 171 | } |
172 | } | 172 | } |
173 | delete destList; | 173 | delete destList; |
174 | 174 | ||
175 | // Sort category list if categories were added | 175 | // Sort category list if categories were added |
176 | if ( categoryAdded ) | 176 | if ( categoryAdded ) |
177 | m_categories.sort(); | 177 | m_categories.sort(); |
178 | } | 178 | } |
179 | } | 179 | } |
180 | 180 | ||
181 | OPackageList *OPackageManager::packages() | 181 | OPackageList *OPackageManager::packages() |
182 | { | 182 | { |
183 | // TODO - look to see if list is loaded, if not, load available & installed | 183 | // TODO - look to see if list is loaded, if not, load available & installed |
184 | 184 | ||
185 | OPackageList *pl = new OPackageList; | 185 | OPackageList *pl = new OPackageList; |
186 | 186 | ||
187 | for ( QDictIterator<OPackage> packageIt( m_packages ); packageIt.current(); ++packageIt ) | 187 | for ( QDictIterator<OPackage> packageIt( m_packages ); packageIt.current(); ++packageIt ) |
188 | pl->append( packageIt.current() ); | 188 | pl->append( packageIt.current() ); |
189 | 189 | ||
190 | return pl; | 190 | return pl; |
191 | } | 191 | } |
192 | 192 | ||
193 | OPackageList *OPackageManager::filterPackages( const QString &name,const QString &server, | 193 | OPackageList *OPackageManager::filterPackages( const QString &name,const QString &server, |
194 | const QString &destination, Status status, const QString &category ) | 194 | const QString &destination, Status status, const QString &category ) |
195 | { | 195 | { |
196 | // TODO - look to see if list is loaded, if not, load available & installed | 196 | // TODO - look to see if list is loaded, if not, load available & installed |
197 | 197 | ||
198 | OPackageList *pl = new OPackageList; | 198 | OPackageList *pl = new OPackageList; |
199 | for ( QDictIterator<OPackage> packageIt( m_packages ); packageIt.current(); ++packageIt ) | 199 | for ( QDictIterator<OPackage> packageIt( m_packages ); packageIt.current(); ++packageIt ) |
200 | { | 200 | { |
201 | OPackage *package = packageIt.current(); | 201 | OPackage *package = packageIt.current(); |
202 | 202 | ||
203 | bool nameMatch = ( name.isNull() || package->name().contains( name ) ); | 203 | bool nameMatch = ( name.isNull() || package->name().contains( name ) ); |
204 | bool serverMatch = ( server.isNull() || package->source() == server ); | 204 | bool serverMatch = ( server.isNull() || package->source() == server ); |
205 | bool destinationMatch = ( destination.isNull() || package->destination() == destination ); | 205 | bool destinationMatch = ( destination.isNull() || package->destination() == destination ); |
206 | bool statusMatch; | 206 | bool statusMatch; |
207 | switch ( status ) | 207 | switch ( status ) |
208 | { | 208 | { |
209 | case All : statusMatch = true; | 209 | case All : statusMatch = true; |
210 | break; | 210 | break; |
211 | case NotInstalled : statusMatch = package->versionInstalled().isNull(); | 211 | case NotInstalled : statusMatch = package->versionInstalled().isNull(); |
212 | break; | 212 | break; |
213 | case Installed : statusMatch = !package->versionInstalled().isNull(); | 213 | case Installed : statusMatch = !package->versionInstalled().isNull(); |
214 | break; | 214 | break; |
215 | case Updated : statusMatch = ( !package->versionInstalled().isNull() && | 215 | case Updated : statusMatch = ( !package->versionInstalled().isNull() && |
216 | compareVersions( package->version(), package->versionInstalled() ) == 1 ); | 216 | compareVersions( package->version(), package->versionInstalled() ) == 1 ); |
217 | break; | 217 | break; |
218 | default : statusMatch = true; | 218 | default : statusMatch = true; |
219 | break; | 219 | break; |
220 | }; | 220 | }; |
221 | bool categoryMatch = ( category.isNull() || package->category() == category ); | 221 | bool categoryMatch = ( category.isNull() || package->category() == category ); |
222 | 222 | ||
223 | if ( nameMatch && serverMatch && destinationMatch && statusMatch && categoryMatch ) | 223 | if ( nameMatch && serverMatch && destinationMatch && statusMatch && categoryMatch ) |
224 | pl->append( packageIt.current() ); | 224 | pl->append( packageIt.current() ); |
225 | } | 225 | } |
226 | 226 | ||
227 | return pl; | 227 | return pl; |
228 | } | 228 | } |
229 | 229 | ||
230 | QStringList *OPackageManager::servers() | 230 | QStringList OPackageManager::servers() |
231 | { | 231 | { |
232 | QStringList *sl = new QStringList(); | 232 | QStringList sl; |
233 | 233 | ||
234 | OConfItemList *serverList = m_ipkg.servers(); | 234 | OConfItemList *serverList = m_ipkg.servers(); |
235 | if ( serverList ) | 235 | if ( serverList ) |
236 | { | 236 | { |
237 | for ( OConfItemListIterator serverIt( *serverList ); serverIt.current(); ++serverIt ) | 237 | for ( OConfItemListIterator serverIt( *serverList ); serverIt.current(); ++serverIt ) |
238 | { | 238 | { |
239 | OConfItem *server = serverIt.current(); | 239 | OConfItem *server = serverIt.current(); |
240 | 240 | ||
241 | // Add only active servers | 241 | // Add only active servers |
242 | if ( server->active() ) | 242 | if ( server->active() ) |
243 | *sl << server->name(); | 243 | sl << server->name(); |
244 | } | 244 | } |
245 | } | 245 | } |
246 | 246 | ||
247 | return sl; | 247 | return sl; |
248 | } | 248 | } |
249 | 249 | ||
250 | QStringList *OPackageManager::destinations() | 250 | QStringList OPackageManager::destinations() |
251 | { | 251 | { |
252 | QStringList *dl = new QStringList(); | 252 | QStringList dl; |
253 | 253 | ||
254 | OConfItemList *destList = m_ipkg.destinations(); | 254 | OConfItemList *destList = m_ipkg.destinations(); |
255 | if ( destList ) | 255 | if ( destList ) |
256 | { | 256 | { |
257 | for ( OConfItemListIterator destIt( *destList ); destIt.current(); ++destIt ) | 257 | for ( OConfItemListIterator destIt( *destList ); destIt.current(); ++destIt ) |
258 | { | 258 | { |
259 | OConfItem *destination = destIt.current(); | 259 | OConfItem *destination = destIt.current(); |
260 | 260 | ||
261 | // Add only active destinations | 261 | // Add only active destinations |
262 | if ( destination->active() ) | 262 | if ( destination->active() ) |
263 | *dl << destination->name(); | 263 | dl << destination->name(); |
264 | } | 264 | } |
265 | } | 265 | } |
266 | 266 | ||
267 | return dl; | 267 | return dl; |
268 | } | 268 | } |
269 | 269 | ||
270 | OConfItem *OPackageManager::findConfItem( OConfItem::Type type, const QString &name ) | 270 | OConfItem *OPackageManager::findConfItem( OConfItem::Type type, const QString &name ) |
271 | { | 271 | { |
272 | OConfItem *confItem = 0x0; | 272 | OConfItem *confItem = 0x0; |
273 | OConfItemList *confList = m_ipkg.configItems(); | 273 | OConfItemList *confList = m_ipkg.configItems(); |
274 | if ( confList ) | 274 | if ( confList ) |
275 | { | 275 | { |
276 | for ( OConfItemListIterator confIt( *confList ); confIt.current(); ++confIt ) | 276 | for ( OConfItemListIterator confIt( *confList ); confIt.current(); ++confIt ) |
277 | { | 277 | { |
278 | OConfItem *conf = confIt.current(); | 278 | OConfItem *conf = confIt.current(); |
279 | 279 | ||
280 | // Add only active confinations | 280 | // Add only active confinations |
281 | if ( conf->type() == type && conf->name() == name ) | 281 | if ( conf->type() == type && conf->name() == name ) |
282 | { | 282 | { |
283 | confItem = conf; | 283 | confItem = conf; |
284 | break; | 284 | break; |
285 | } | 285 | } |
286 | } | 286 | } |
287 | } | 287 | } |
288 | 288 | ||
289 | return confItem; | 289 | return confItem; |
290 | 290 | ||
291 | } | 291 | } |
292 | 292 | ||
293 | OPackage *OPackageManager::findPackage( const QString &name ) | 293 | OPackage *OPackageManager::findPackage( const QString &name ) |
294 | { | 294 | { |
295 | return m_packages[ name ]; | 295 | return m_packages[ name ]; |
296 | } | 296 | } |
297 | 297 | ||
298 | int OPackageManager::compareVersions( const QString &ver1, const QString &ver2 ) | 298 | int OPackageManager::compareVersions( const QString &ver1, const QString &ver2 ) |
299 | { | 299 | { |
300 | // TODO - should this be in OIpkg??? | 300 | // TODO - should this be in OIpkg??? |
301 | 301 | ||
302 | int epoch1, epoch2; | 302 | int epoch1, epoch2; |
303 | QString version1, revision1; | 303 | QString version1, revision1; |
304 | QString version2, revision2; | 304 | QString version2, revision2; |
305 | 305 | ||
306 | parseVersion( ver1, &epoch1, &version1, &revision1 ); | 306 | parseVersion( ver1, &epoch1, &version1, &revision1 ); |
307 | parseVersion( ver2, &epoch2, &version2, &revision2 ); | 307 | parseVersion( ver2, &epoch2, &version2, &revision2 ); |
308 | 308 | ||
309 | if ( epoch1 > epoch2 ) | 309 | if ( epoch1 > epoch2 ) |
310 | return 1; | 310 | return 1; |
311 | else if ( epoch1 < epoch2 ) | 311 | else if ( epoch1 < epoch2 ) |
312 | return -1; | 312 | return -1; |
313 | 313 | ||
314 | int r = verrevcmp( version1.latin1(), version2.latin1() ); | 314 | int r = verrevcmp( version1.latin1(), version2.latin1() ); |
315 | if (r) | 315 | if (r) |
316 | return r; | 316 | return r; |
317 | 317 | ||
318 | r = verrevcmp( revision1.latin1(), revision2.latin1() ); | 318 | r = verrevcmp( revision1.latin1(), revision2.latin1() ); |
319 | return r; | 319 | return r; |
320 | } | 320 | } |
321 | 321 | ||
322 | bool OPackageManager::configureDlg( bool installOptions ) | 322 | bool OPackageManager::configureDlg( bool installOptions ) |
323 | { | 323 | { |
324 | OIpkgConfigDlg dlg( &m_ipkg, installOptions, static_cast<QWidget *>(parent()) ); | 324 | OIpkgConfigDlg dlg( &m_ipkg, installOptions, static_cast<QWidget *>(parent()) ); |
325 | return ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ); | 325 | return ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ); |
326 | } | 326 | } |
327 | 327 | ||
328 | void OPackageManager::saveSettings() | 328 | void OPackageManager::saveSettings() |
329 | { | 329 | { |
330 | m_ipkg.saveSettings(); | 330 | m_ipkg.saveSettings(); |
331 | } | 331 | } |
332 | 332 | ||
333 | bool OPackageManager::executeCommand( OPackage::Command command, QStringList *packages, | 333 | bool OPackageManager::executeCommand( OPackage::Command command, const QStringList &packages, |
334 | const QString &destination, const QObject *receiver, | 334 | const QString &destination, const QObject *receiver, |
335 | const char *slotOutput, bool rawOutput ) | 335 | const char *slotOutput, bool rawOutput ) |
336 | { | 336 | { |
337 | return m_ipkg.executeCommand( command, packages, destination, receiver, slotOutput, rawOutput ); | 337 | return m_ipkg.executeCommand( command, packages, destination, receiver, slotOutput, rawOutput ); |
338 | } | 338 | } |
339 | 339 | ||
340 | void OPackageManager::parseVersion( const QString &verstr, int *epoch, QString *version, | 340 | void OPackageManager::parseVersion( const QString &verstr, int *epoch, QString *version, |
341 | QString *revision ) | 341 | QString *revision ) |
342 | { | 342 | { |
343 | *epoch = 0; | 343 | *epoch = 0; |
344 | *revision = QString::null; | 344 | *revision = QString::null; |
345 | 345 | ||
346 | // Version string is in the format "ee:vv-rv", where ee=epoch, vv=version, rv=revision | 346 | // Version string is in the format "ee:vv-rv", where ee=epoch, vv=version, rv=revision |
347 | 347 | ||
348 | // Get epoch | 348 | // Get epoch |
349 | int colonpos = verstr.find( ':' ); | 349 | int colonpos = verstr.find( ':' ); |
350 | if ( colonpos > -1 ) | 350 | if ( colonpos > -1 ) |
351 | { | 351 | { |
352 | *epoch = verstr.left( colonpos ).toInt(); | 352 | *epoch = verstr.left( colonpos ).toInt(); |
353 | } | 353 | } |
354 | 354 | ||
355 | // Get version and revision | 355 | // Get version and revision |
356 | int hyphenpos = verstr.find( '-', colonpos + 1 ); | 356 | int hyphenpos = verstr.find( '-', colonpos + 1 ); |
357 | int verlen = verstr.length(); | 357 | int verlen = verstr.length(); |
358 | if ( hyphenpos > -1 ) | 358 | if ( hyphenpos > -1 ) |
359 | { | 359 | { |
360 | *version = verstr.mid( colonpos + 1, hyphenpos - colonpos - 1 ); | 360 | *version = verstr.mid( colonpos + 1, hyphenpos - colonpos - 1 ); |
361 | *revision = verstr.right( verlen - hyphenpos - 1 ); | 361 | *revision = verstr.right( verlen - hyphenpos - 1 ); |
362 | } | 362 | } |
363 | else | 363 | else |
364 | { | 364 | { |
365 | *version = verstr.right( verlen - colonpos ); | 365 | *version = verstr.right( verlen - colonpos ); |
366 | } | 366 | } |
367 | } | 367 | } |
368 | 368 | ||
369 | /* | 369 | /* |
370 | * libdpkg - Debian packaging suite library routines | 370 | * libdpkg - Debian packaging suite library routines |
371 | * vercmp.c - comparison of version numbers | 371 | * vercmp.c - comparison of version numbers |
372 | * | 372 | * |
373 | * Copyright (C) 1995 Ian Jackson <iwj10@cus.cam.ac.uk> | 373 | * Copyright (C) 1995 Ian Jackson <iwj10@cus.cam.ac.uk> |
374 | */ | 374 | */ |
375 | int OPackageManager::verrevcmp( const char *val, const char *ref ) | 375 | int OPackageManager::verrevcmp( const char *val, const char *ref ) |
376 | { | 376 | { |
377 | int vc, rc; | 377 | int vc, rc; |
378 | long vl, rl; | 378 | long vl, rl; |
379 | const char *vp, *rp; | 379 | const char *vp, *rp; |
380 | const char *vsep, *rsep; | 380 | const char *vsep, *rsep; |
381 | 381 | ||
382 | if (!val) val= ""; | 382 | if (!val) val= ""; |
383 | if (!ref) ref= ""; | 383 | if (!ref) ref= ""; |
384 | for (;;) { | 384 | for (;;) { |
385 | vp= val; while (*vp && !isdigit(*vp)) vp++; | 385 | vp= val; while (*vp && !isdigit(*vp)) vp++; |
386 | rp= ref; while (*rp && !isdigit(*rp)) rp++; | 386 | rp= ref; while (*rp && !isdigit(*rp)) rp++; |
387 | for (;;) { | 387 | for (;;) { |
388 | vc= (val == vp) ? 0 : *val++; | 388 | vc= (val == vp) ? 0 : *val++; |
389 | rc= (ref == rp) ? 0 : *ref++; | 389 | rc= (ref == rp) ? 0 : *ref++; |
390 | if (!rc && !vc) break; | 390 | if (!rc && !vc) break; |
391 | if (vc && !isalpha(vc)) vc += 256; /* assumes ASCII character set */ | 391 | if (vc && !isalpha(vc)) vc += 256; /* assumes ASCII character set */ |
392 | if (rc && !isalpha(rc)) rc += 256; | 392 | if (rc && !isalpha(rc)) rc += 256; |
393 | if (vc != rc) return vc - rc; | 393 | if (vc != rc) return vc - rc; |
394 | } | 394 | } |
395 | val= vp; | 395 | val= vp; |
396 | ref= rp; | 396 | ref= rp; |
397 | vl=0; if (isdigit(*vp)) vl= strtol(val,(char**)&val,10); | 397 | vl=0; if (isdigit(*vp)) vl= strtol(val,(char**)&val,10); |
398 | rl=0; if (isdigit(*rp)) rl= strtol(ref,(char**)&ref,10); | 398 | rl=0; if (isdigit(*rp)) rl= strtol(ref,(char**)&ref,10); |
399 | if (vl != rl) return vl - rl; | 399 | if (vl != rl) return vl - rl; |
400 | 400 | ||
401 | vc = *val; | 401 | vc = *val; |
402 | rc = *ref; | 402 | rc = *ref; |
403 | vsep = strchr(".-", vc); | 403 | vsep = strchr(".-", vc); |
404 | rsep = strchr(".-", rc); | 404 | rsep = strchr(".-", rc); |
405 | if (vsep && !rsep) return -1; | 405 | if (vsep && !rsep) return -1; |
406 | if (!vsep && rsep) return +1; | 406 | if (!vsep && rsep) return +1; |
407 | 407 | ||
408 | if (!*val && !*ref) return 0; | 408 | if (!*val && !*ref) return 0; |
409 | if (!*val) return -1; | 409 | if (!*val) return -1; |
410 | if (!*ref) return +1; | 410 | if (!*ref) return +1; |
411 | } | 411 | } |
412 | } | 412 | } |
diff --git a/noncore/settings/packagemanager/opackagemanager.h b/noncore/settings/packagemanager/opackagemanager.h index 58e597b..bc394e8 100644 --- a/noncore/settings/packagemanager/opackagemanager.h +++ b/noncore/settings/packagemanager/opackagemanager.h | |||
@@ -1,92 +1,95 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | 3 | ||
4 | Copyright (c) 2003 Dan Williams <drw@handhelds.org> | 4 | Copyright (c) 2003 Dan Williams <drw@handhelds.org> |
5 | =. | 5 | =. |
6 | .=l. | 6 | .=l. |
7 | .>+-= | 7 | .>+-= |
8 | _;:, .> :=|. This program is free software; you can | 8 | _;:, .> :=|. This program is free software; you can |
9 | .> <`_, > . <= redistribute it and/or modify it under | 9 | .> <`_, > . <= redistribute it and/or modify it under |
10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 10 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
11 | .="- .-=="i, .._ License as published by the Free Software | 11 | .="- .-=="i, .._ License as published by the Free Software |
12 | - . .-<_> .<> Foundation; either version 2 of the License, | 12 | - . .-<_> .<> Foundation; either version 2 of the License, |
13 | ._= =} : or (at your option) any later version. | 13 | ._= =} : or (at your option) any later version. |
14 | .%`+i> _;_. | 14 | .%`+i> _;_. |
15 | .i_,=:_. -<s. This program is distributed in the hope that | 15 | .i_,=:_. -<s. This program is distributed in the hope that |
16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 16 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
17 | : .. .:, . . . without even the implied warranty of | 17 | : .. .:, . . . without even the implied warranty of |
18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 18 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 19 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
20 | ..}^=.= = ; Library General Public License for more | 20 | ..}^=.= = ; Library General Public License for more |
21 | ++= -. .` .: details. | 21 | ++= -. .` .: details. |
22 | : = ...= . :.=- | 22 | : = ...= . :.=- |
23 | -. .:....=;==+<; You should have received a copy of the GNU | 23 | -. .:....=;==+<; You should have received a copy of the GNU |
24 | -_. . . )=. = Library General Public License along with | 24 | -_. . . )=. = Library General Public License along with |
25 | -- :-=` this library; see the file COPYING.LIB. | 25 | -- :-=` this library; see the file COPYING.LIB. |
26 | If not, write to the Free Software Foundation, | 26 | If not, write to the Free Software Foundation, |
27 | Inc., 59 Temple Place - Suite 330, | 27 | Inc., 59 Temple Place - Suite 330, |
28 | Boston, MA 02111-1307, USA. | 28 | Boston, MA 02111-1307, USA. |
29 | 29 | ||
30 | */ | 30 | */ |
31 | 31 | ||
32 | #ifndef OPACKAGEMANAGER_H | 32 | #ifndef OPACKAGEMANAGER_H |
33 | #define OPACKAGEMANAGER_H | 33 | #define OPACKAGEMANAGER_H |
34 | 34 | ||
35 | #include "oipkg.h" | 35 | #include "oipkg.h" |
36 | 36 | ||
37 | #include <qpe/config.h> | 37 | #include <qpe/config.h> |
38 | 38 | ||
39 | #include <qdict.h> | 39 | #include <qdict.h> |
40 | #include <qobject.h> | 40 | #include <qobject.h> |
41 | #include <qstringlist.h> | 41 | #include <qstringlist.h> |
42 | 42 | ||
43 | class OPackageManager : public QObject | 43 | class OPackageManager : public QObject |
44 | { | 44 | { |
45 | Q_OBJECT | 45 | Q_OBJECT |
46 | 46 | ||
47 | public: | 47 | public: |
48 | OPackageManager( Config *config = 0x0, QObject *parent = 0x0, const char *name = 0x0 ); | 48 | OPackageManager( Config *config = 0x0, QObject *parent = 0x0, const char *name = 0x0 ); |
49 | 49 | ||
50 | void loadAvailablePackages(); | 50 | void loadAvailablePackages(); |
51 | void loadInstalledPackages(); | 51 | void loadInstalledPackages(); |
52 | 52 | ||
53 | enum Status { All, NotInstalled, Installed, Updated, NotDefined }; | 53 | enum Status { All, NotInstalled, Installed, Updated, NotDefined }; |
54 | 54 | ||
55 | OPackageList *packages(); | 55 | OPackageList *packages(); |
56 | OPackageList *filterPackages( const QString &name = 0x0,const QString &server = 0x0, | 56 | OPackageList *filterPackages( const QString &name = QString::null, |
57 | const QString &destination = 0x0, Status status = NotDefined, | 57 | const QString &server = QString::null, |
58 | const QString &category = 0x0 ); | 58 | const QString &destination = QString::null, |
59 | Status status = NotDefined, | ||
60 | const QString &category = QString::null ); | ||
59 | 61 | ||
60 | const QStringList &categories() { return m_categories; } | 62 | const QStringList &categories() { return m_categories; } |
61 | QStringList *servers(); | 63 | QStringList servers(); |
62 | QStringList *destinations(); | 64 | QStringList destinations(); |
63 | 65 | ||
64 | int compareVersions( const QString &version1, const QString &version2 ); | 66 | int compareVersions( const QString &version1, const QString &version2 ); |
65 | 67 | ||
66 | OConfItem *findConfItem( OConfItem::Type type = OConfItem::NotDefined, | 68 | OConfItem *findConfItem( OConfItem::Type type = OConfItem::NotDefined, |
67 | const QString &name = QString::null ); | 69 | const QString &name = QString::null ); |
68 | OPackage *findPackage( const QString &name = QString::null ); | 70 | OPackage *findPackage( const QString &name = QString::null ); |
69 | 71 | ||
70 | bool configureDlg( bool installOptions = false ); | 72 | bool configureDlg( bool installOptions = false ); |
71 | void saveSettings(); | 73 | void saveSettings(); |
72 | 74 | ||
73 | bool executeCommand( OPackage::Command command = OPackage::NotDefined, QStringList *parameters = 0x0, | 75 | bool executeCommand( OPackage::Command command = OPackage::NotDefined, |
76 | const QStringList ¶meters = QStringList(), | ||
74 | const QString &destination = QString::null, const QObject *receiver = 0x0, | 77 | const QString &destination = QString::null, const QObject *receiver = 0x0, |
75 | const char *slotOutput = 0x0, bool rawOutput = true ); | 78 | const char *slotOutput = 0x0, bool rawOutput = true ); |
76 | 79 | ||
77 | private: | 80 | private: |
78 | Config *m_config; // Pointer to application configuration file | 81 | Config *m_config; // Pointer to application configuration file |
79 | OIpkg m_ipkg; // OIpkg object to retrieve package/configuration information | 82 | OIpkg m_ipkg; // OIpkg object to retrieve package/configuration information |
80 | QDict<OPackage> m_packages; // Global list of available packages | 83 | QDict<OPackage> m_packages; // Global list of available packages |
81 | QStringList m_categories; // List of all categories | 84 | QStringList m_categories; // List of all categories |
82 | 85 | ||
83 | void parseVersion( const QString &verstr, int *epoch, QString *version, QString *revision ); | 86 | void parseVersion( const QString &verstr, int *epoch, QString *version, QString *revision ); |
84 | int verrevcmp( const char *val, const char *ref ); | 87 | int verrevcmp( const char *val, const char *ref ); |
85 | 88 | ||
86 | signals: | 89 | signals: |
87 | void initStatus( int numSteps ); | 90 | void initStatus( int numSteps ); |
88 | void statusText( const QString &status ); | 91 | void statusText( const QString &status ); |
89 | void statusBar( int currStep ); | 92 | void statusBar( int currStep ); |
90 | }; | 93 | }; |
91 | 94 | ||
92 | #endif | 95 | #endif |
diff --git a/noncore/settings/packagemanager/packageinfodlg.cpp b/noncore/settings/packagemanager/packageinfodlg.cpp index d27eacb..c5924fd 100644 --- a/noncore/settings/packagemanager/packageinfodlg.cpp +++ b/noncore/settings/packagemanager/packageinfodlg.cpp | |||
@@ -1,144 +1,144 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | 3 | ||
4 | =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> | 4 | =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This file is free software; you can | 7 | _;:, .> :=|. This file is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
19 | ..}^=.= = ; Public License for more details. | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | 20 | ++= -. .` .: |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | : = ...= . :.=- You should have received a copy of the GNU |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #include "packageinfodlg.h" | 30 | #include "packageinfodlg.h" |
31 | #include "opackage.h" | 31 | #include "opackage.h" |
32 | #include "opackagemanager.h" | 32 | #include "opackagemanager.h" |
33 | 33 | ||
34 | #include <opie2/otabwidget.h> | 34 | #include <opie2/otabwidget.h> |
35 | 35 | ||
36 | #include <qpe/resource.h> | 36 | #include <qpe/resource.h> |
37 | 37 | ||
38 | #include <qlayout.h> | 38 | #include <qlayout.h> |
39 | #include <qpushbutton.h> | 39 | #include <qpushbutton.h> |
40 | #include <qwhatsthis.h> | 40 | #include <qwhatsthis.h> |
41 | 41 | ||
42 | PackageInfoDlg::PackageInfoDlg( QWidget *parent, OPackageManager *pm, const QString &package ) | 42 | PackageInfoDlg::PackageInfoDlg( QWidget *parent, OPackageManager *pm, const QString &package ) |
43 | : QWidget( 0x0 ) | 43 | : QWidget( 0x0 ) |
44 | , m_packman( pm ) | 44 | , m_packman( pm ) |
45 | , m_information( this ) | 45 | , m_information( this ) |
46 | , m_files( this ) | 46 | , m_files( this ) |
47 | { | 47 | { |
48 | // Initialize UI | 48 | // Initialize UI |
49 | if ( parent ) | 49 | if ( parent ) |
50 | parent->setCaption( package ); | 50 | parent->setCaption( package ); |
51 | 51 | ||
52 | QVBoxLayout *layout = new QVBoxLayout( this, 4, 2 ); | 52 | QVBoxLayout *layout = new QVBoxLayout( this, 4, 2 ); |
53 | 53 | ||
54 | Opie::Ui::OTabWidget *tabWidget = new Opie::Ui::OTabWidget( this ); | 54 | Opie::Ui::OTabWidget *tabWidget = new Opie::Ui::OTabWidget( this ); |
55 | layout->addWidget( tabWidget ); | 55 | layout->addWidget( tabWidget ); |
56 | 56 | ||
57 | // Information tab | 57 | // Information tab |
58 | QWhatsThis::add( &m_information, tr( "This area contains information about the package." ) ); | 58 | QWhatsThis::add( &m_information, tr( "This area contains information about the package." ) ); |
59 | m_information.reparent( tabWidget, QPoint( 0, 0 ) ); | 59 | m_information.reparent( tabWidget, QPoint( 0, 0 ) ); |
60 | m_information.setReadOnly( true ); | 60 | m_information.setReadOnly( true ); |
61 | tabWidget->addTab( &m_information, "UtilsIcon", tr( "Information" ) ); | 61 | tabWidget->addTab( &m_information, "UtilsIcon", tr( "Information" ) ); |
62 | 62 | ||
63 | // Retrive package information | 63 | // Retrive package information |
64 | m_package = m_packman->findPackage( package ); | 64 | m_package = m_packman->findPackage( package ); |
65 | if ( !m_package ) | 65 | if ( !m_package ) |
66 | { | 66 | { |
67 | m_information.setText( tr( "Unable to retrieve package information." ) ); | 67 | m_information.setText( tr( "Unable to retrieve package information." ) ); |
68 | return; | 68 | return; |
69 | } | 69 | } |
70 | 70 | ||
71 | // Display package information | 71 | // Display package information |
72 | if ( !m_package->information().isNull() ) | 72 | if ( !m_package->information().isNull() ) |
73 | m_information.setText( m_package->information() ); | 73 | m_information.setText( m_package->information() ); |
74 | else | 74 | else |
75 | { | 75 | { |
76 | // Package information is not cached, retrieve it | 76 | // Package information is not cached, retrieve it |
77 | QStringList list( package ); | 77 | QStringList list( package ); |
78 | m_packman->executeCommand( OPackage::Info, &list, QString::null, this, SLOT(slotInfo(char*)), true ); | 78 | m_packman->executeCommand( OPackage::Info, list, QString::null, this, SLOT(slotInfo(char*)), true ); |
79 | } | 79 | } |
80 | 80 | ||
81 | // Files tab (display only if package is installed) | 81 | // Files tab (display only if package is installed) |
82 | if ( !m_package->versionInstalled().isNull() ) | 82 | if ( !m_package->versionInstalled().isNull() ) |
83 | { | 83 | { |
84 | QWidget *filesWidget = new QWidget( tabWidget ); | 84 | QWidget *filesWidget = new QWidget( tabWidget ); |
85 | QVBoxLayout *filesLayout = new QVBoxLayout( filesWidget, 2, 2 ); | 85 | QVBoxLayout *filesLayout = new QVBoxLayout( filesWidget, 2, 2 ); |
86 | QWhatsThis::add( &m_files, tr( "This area contains a list of files contained in this package." ) ); | 86 | QWhatsThis::add( &m_files, tr( "This area contains a list of files contained in this package." ) ); |
87 | m_files.reparent( filesWidget, QPoint( 0, 0 ) ); | 87 | m_files.reparent( filesWidget, QPoint( 0, 0 ) ); |
88 | m_files.setReadOnly( true ); | 88 | m_files.setReadOnly( true ); |
89 | filesLayout->addWidget( &m_files ); | 89 | filesLayout->addWidget( &m_files ); |
90 | 90 | ||
91 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "packagemanager/apply" ), | 91 | QPushButton *btn = new QPushButton( Resource::loadPixmap( "packagemanager/apply" ), |
92 | tr( "Retrieve file list" ), filesWidget ); | 92 | tr( "Retrieve file list" ), filesWidget ); |
93 | QWhatsThis::add( btn, tr( "Tap here to retrieve list of files contained in this package." ) ); | 93 | QWhatsThis::add( btn, tr( "Tap here to retrieve list of files contained in this package." ) ); |
94 | filesLayout->addWidget( btn ); | 94 | filesLayout->addWidget( btn ); |
95 | connect( btn, SIGNAL(clicked()), this, SLOT(slotBtnFileScan()) ); | 95 | connect( btn, SIGNAL(clicked()), this, SLOT(slotBtnFileScan()) ); |
96 | tabWidget->addTab( filesWidget, "binary", tr( "File list" ) ); | 96 | tabWidget->addTab( filesWidget, "binary", tr( "File list" ) ); |
97 | 97 | ||
98 | tabWidget->setCurrentTab( tr( "Information" ) ); | 98 | tabWidget->setCurrentTab( tr( "Information" ) ); |
99 | 99 | ||
100 | // If file list is already cached, display | 100 | // If file list is already cached, display |
101 | if ( !m_package->files().isNull() ) | 101 | if ( !m_package->files().isNull() ) |
102 | m_files.setText( m_package->files() ); | 102 | m_files.setText( m_package->files() ); |
103 | } | 103 | } |
104 | else | 104 | else |
105 | m_files.hide(); | 105 | m_files.hide(); |
106 | } | 106 | } |
107 | 107 | ||
108 | PackageInfoDlg::~PackageInfoDlg() | 108 | PackageInfoDlg::~PackageInfoDlg() |
109 | { | 109 | { |
110 | if ( !m_package ) | 110 | if ( !m_package ) |
111 | return; | 111 | return; |
112 | 112 | ||
113 | // Cache package information | 113 | // Cache package information |
114 | if ( !m_information.text().isNull() ) | 114 | if ( !m_information.text().isNull() ) |
115 | m_package->setInformation( m_information.text() ); | 115 | m_package->setInformation( m_information.text() ); |
116 | 116 | ||
117 | // Cache package file list | 117 | // Cache package file list |
118 | if ( !m_files.text().isNull() ) | 118 | if ( !m_files.text().isNull() ) |
119 | m_package->setFiles( m_files.text() ); | 119 | m_package->setFiles( m_files.text() ); |
120 | } | 120 | } |
121 | 121 | ||
122 | void PackageInfoDlg::slotBtnFileScan() | 122 | void PackageInfoDlg::slotBtnFileScan() |
123 | { | 123 | { |
124 | m_files.clear(); | 124 | m_files.clear(); |
125 | 125 | ||
126 | QStringList list( m_package->name() ); | 126 | QStringList list( m_package->name() ); |
127 | m_packman->executeCommand( OPackage::Files, &list, QString::null, this, SLOT(slotFiles(char*)), true ); | 127 | m_packman->executeCommand( OPackage::Files, list, QString::null, this, SLOT(slotFiles(char*)), true ); |
128 | } | 128 | } |
129 | 129 | ||
130 | void PackageInfoDlg::slotInfo( char *info ) | 130 | void PackageInfoDlg::slotInfo( char *info ) |
131 | { | 131 | { |
132 | m_information.append( info ); | 132 | m_information.append( info ); |
133 | } | 133 | } |
134 | 134 | ||
135 | void PackageInfoDlg::slotFiles( char *filelist ) | 135 | void PackageInfoDlg::slotFiles( char *filelist ) |
136 | { | 136 | { |
137 | QString str = filelist; | 137 | QString str = filelist; |
138 | 138 | ||
139 | // Skip first line of output ("Package xxx is installed...") | 139 | // Skip first line of output ("Package xxx is installed...") |
140 | if ( str.startsWith( "Package " ) ) | 140 | if ( str.startsWith( "Package " ) ) |
141 | str = str.right( str.length() - str.find( '\n' ) - 1 ); | 141 | str = str.right( str.length() - str.find( '\n' ) - 1 ); |
142 | 142 | ||
143 | m_files.append( str ); | 143 | m_files.append( str ); |
144 | } | 144 | } |
diff --git a/noncore/settings/packagemanager/promptdlg.h b/noncore/settings/packagemanager/promptdlg.h index 790ff4d..f7bc0c0 100644 --- a/noncore/settings/packagemanager/promptdlg.h +++ b/noncore/settings/packagemanager/promptdlg.h | |||
@@ -1,57 +1,59 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | 3 | ||
4 | =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> | 4 | =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This file is free software; you can | 7 | _;:, .> :=|. This file is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
19 | ..}^=.= = ; Public License for more details. | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | 20 | ++= -. .` .: |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | : = ...= . :.=- You should have received a copy of the GNU |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #ifndef PROMPTDLG_H | 30 | #ifndef PROMPTDLG_H |
31 | #define PROMPTDLG_H | 31 | #define PROMPTDLG_H |
32 | 32 | ||
33 | #include <qwidget.h> | 33 | #include <qwidget.h> |
34 | 34 | ||
35 | class PromptDlg : public QWidget | 35 | class PromptDlg : public QWidget |
36 | { | 36 | { |
37 | Q_OBJECT | 37 | Q_OBJECT |
38 | 38 | ||
39 | public: | 39 | public: |
40 | PromptDlg( const QString &caption = 0x0, const QString &text = 0x0, const QString &btn1 = 0x0, | 40 | PromptDlg( const QString &caption = QString::null, const QString &text = QString::null, |
41 | const QString &btn2 = 0x0, QWidget *parent = 0x0 ); | 41 | const QString &btn1 = QString::null, const QString &btn2 = QString::null, |
42 | QWidget *parent = 0x0 ); | ||
42 | 43 | ||
43 | int display(); | 44 | int display(); |
44 | int btnPressed() { return m_btnClicked; } | 45 | int btnPressed() { return m_btnClicked; } |
45 | 46 | ||
46 | static int ask( const QString &caption = 0x0, const QString &text = 0x0, const QString &btn1 = 0x0, | 47 | static int ask( const QString &caption = QString::null, const QString &text = QString::null, |
47 | const QString &btn2 = 0x0, QWidget *parent = 0x0 ); | 48 | const QString &btn1 = QString::null, const QString &btn2 = QString::null, |
49 | QWidget *parent = 0x0 ); | ||
48 | 50 | ||
49 | private: | 51 | private: |
50 | int m_btnClicked; // Indicator for which button was pressed | 52 | int m_btnClicked; // Indicator for which button was pressed |
51 | 53 | ||
52 | private slots: | 54 | private slots: |
53 | void slotBtn1Clicked(); | 55 | void slotBtn1Clicked(); |
54 | void slotBtn2Clicked(); | 56 | void slotBtn2Clicked(); |
55 | }; | 57 | }; |
56 | 58 | ||
57 | #endif | 59 | #endif |