author | drw <drw> | 2004-12-21 19:58:58 (UTC) |
---|---|---|
committer | drw <drw> | 2004-12-21 19:58:58 (UTC) |
commit | 2e21be2e93866511f55e2a200514b3ce15b14791 (patch) (unidiff) | |
tree | 0aa6ca907bfbcfc5b8abbc5a83f0a2cae70730fe | |
parent | 570c8709d1d7622e2a57432f40a67213216d2606 (diff) | |
download | opie-2e21be2e93866511f55e2a200514b3ce15b14791.zip opie-2e21be2e93866511f55e2a200514b3ce15b14791.tar.gz opie-2e21be2e93866511f55e2a200514b3ce15b14791.tar.bz2 |
Fix app linking to link all dependent packages as well as selected packages.
-rw-r--r-- | noncore/settings/packagemanager/installdlg.cpp | 52 | ||||
-rw-r--r-- | noncore/settings/packagemanager/installdlg.h | 2 |
2 files changed, 35 insertions, 19 deletions
diff --git a/noncore/settings/packagemanager/installdlg.cpp b/noncore/settings/packagemanager/installdlg.cpp index 494603b..985e2bd 100644 --- a/noncore/settings/packagemanager/installdlg.cpp +++ b/noncore/settings/packagemanager/installdlg.cpp | |||
@@ -1,372 +1,388 @@ | |||
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 | #include <opie2/oprocess.h> | 33 | #include <opie2/oprocess.h> |
34 | 34 | ||
35 | #include <qpe/fileselector.h> | 35 | #include <qpe/fileselector.h> |
36 | #include <qpe/resource.h> | 36 | #include <qpe/resource.h> |
37 | #include <qpe/storage.h> | 37 | #include <qpe/storage.h> |
38 | 38 | ||
39 | #include <qapplication.h> | 39 | #include <qapplication.h> |
40 | #include <qcombobox.h> | 40 | #include <qcombobox.h> |
41 | #include <qfileinfo.h> | 41 | #include <qfileinfo.h> |
42 | #include <qgroupbox.h> | 42 | #include <qgroupbox.h> |
43 | #include <qlabel.h> | 43 | #include <qlabel.h> |
44 | #include <qlayout.h> | 44 | #include <qlayout.h> |
45 | #include <qmap.h> | 45 | #include <qmap.h> |
46 | #include <qmultilineedit.h> | 46 | #include <qmultilineedit.h> |
47 | #include <qpushbutton.h> | 47 | #include <qpushbutton.h> |
48 | 48 | ||
49 | #include <sys/vfs.h> | 49 | #include <sys/vfs.h> |
50 | 50 | ||
51 | #include "opackagemanager.h" | 51 | #include "opackagemanager.h" |
52 | 52 | ||
53 | InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &caption, | 53 | InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &caption, |
54 | OPackage::Command command1, const QStringList &packages1, | 54 | OPackage::Command command1, const QStringList &packages1, |
55 | OPackage::Command command2, const QStringList &packages2, | 55 | OPackage::Command command2, const QStringList &packages2, |
56 | OPackage::Command command3, const QStringList &packages3 ) | 56 | OPackage::Command command3, const QStringList &packages3 ) |
57 | : QWidget( 0x0 ) | 57 | : QWidget( 0l ) |
58 | , m_packman( pm ) | 58 | , m_packman( pm ) |
59 | , m_installFound( false ) | 59 | , m_installFound( false ) |
60 | , m_numCommands( 0 ) | 60 | , m_numCommands( 0 ) |
61 | , m_currCommand( 0 ) | 61 | , m_currCommand( 0 ) |
62 | , m_destItem( 0x0 ) | 62 | , m_destItem( 0l ) |
63 | { | 63 | { |
64 | // Save command/package list information | 64 | // Save command/package list information |
65 | if ( command1 != OPackage::NotDefined ) | 65 | if ( command1 != OPackage::NotDefined ) |
66 | { | 66 | { |
67 | m_command[ m_numCommands ] = command1; | 67 | m_command[ m_numCommands ] = command1; |
68 | m_packages[ m_numCommands ] = packages1; | 68 | m_packages[ m_numCommands ] = packages1; |
69 | ++m_numCommands; | 69 | ++m_numCommands; |
70 | 70 | ||
71 | if ( command1 == OPackage::Install ) | 71 | if ( command1 == OPackage::Install ) |
72 | m_installFound = true; | 72 | m_installFound = true; |
73 | } | 73 | } |
74 | if ( command2 != OPackage::NotDefined ) | 74 | if ( command2 != OPackage::NotDefined ) |
75 | { | 75 | { |
76 | m_command[ m_numCommands ] = command2; | 76 | m_command[ m_numCommands ] = command2; |
77 | m_packages[ m_numCommands ] = packages2; | 77 | m_packages[ m_numCommands ] = packages2; |
78 | ++m_numCommands; | 78 | ++m_numCommands; |
79 | 79 | ||
80 | if ( command2 == OPackage::Install ) | 80 | if ( command2 == OPackage::Install ) |
81 | m_installFound = true; | 81 | m_installFound = true; |
82 | } | 82 | } |
83 | if ( command3 != OPackage::NotDefined ) | 83 | if ( command3 != OPackage::NotDefined ) |
84 | { | 84 | { |
85 | m_command[ m_numCommands ] = command3; | 85 | m_command[ m_numCommands ] = command3; |
86 | m_packages[ m_numCommands ] = packages3; | 86 | m_packages[ m_numCommands ] = packages3; |
87 | ++m_numCommands; | 87 | ++m_numCommands; |
88 | 88 | ||
89 | if ( command3 == OPackage::Install ) | 89 | if ( command3 == OPackage::Install ) |
90 | m_installFound = true; | 90 | m_installFound = true; |
91 | } | 91 | } |
92 | 92 | ||
93 | // Initialize UI | 93 | // Initialize UI |
94 | if ( parent ) | 94 | if ( parent ) |
95 | parent->setCaption( caption ); | 95 | parent->setCaption( caption ); |
96 | 96 | ||
97 | QGridLayout *layout = new QGridLayout( this, 4, 2, 2, 4 ); | 97 | QGridLayout *layout = new QGridLayout( this, 4, 2, 2, 4 ); |
98 | 98 | ||
99 | if ( m_installFound ) | 99 | if ( m_installFound ) |
100 | { | 100 | { |
101 | QLabel *label = new QLabel( tr( "Destination" ), this ); | 101 | QLabel *label = new QLabel( tr( "Destination" ), this ); |
102 | layout->addWidget( label, 0, 0 ); | 102 | layout->addWidget( label, 0, 0 ); |
103 | m_destination = new QComboBox( this ); | 103 | m_destination = new QComboBox( this ); |
104 | m_destination->insertStringList( m_packman->destinations() ); | 104 | m_destination->insertStringList( m_packman->destinations() ); |
105 | layout->addWidget( m_destination, 0, 1 ); | 105 | layout->addWidget( m_destination, 0, 1 ); |
106 | connect( m_destination, SIGNAL(highlighted(const QString&)), | 106 | connect( m_destination, SIGNAL(highlighted(const QString&)), |
107 | this, SLOT(slotDisplayAvailSpace(const QString&)) ); | 107 | this, SLOT(slotDisplayAvailSpace(const QString&)) ); |
108 | 108 | ||
109 | label = new QLabel( tr( "Space Avail" ), this ); | 109 | label = new QLabel( tr( "Space Avail" ), this ); |
110 | layout->addWidget( label, 1, 0 ); | 110 | layout->addWidget( label, 1, 0 ); |
111 | m_availSpace = new QLabel( this ); | 111 | m_availSpace = new QLabel( this ); |
112 | layout->addWidget( m_availSpace, 1, 1 ); | 112 | layout->addWidget( m_availSpace, 1, 1 ); |
113 | 113 | ||
114 | // TODO - select correct destination | 114 | // TODO - select correct destination |
115 | slotDisplayAvailSpace( m_destination->currentText() ); | 115 | slotDisplayAvailSpace( m_destination->currentText() ); |
116 | } | 116 | } |
117 | else | 117 | else |
118 | { | 118 | { |
119 | m_destination = 0x0; | 119 | m_destination = 0l; |
120 | m_availSpace = 0x0; | 120 | m_availSpace = 0l; |
121 | } | 121 | } |
122 | 122 | ||
123 | QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this ); | 123 | QGroupBox *groupBox = new QGroupBox( 0, Qt::Vertical, tr( "Output" ), this ); |
124 | groupBox->layout()->setSpacing( 0 ); | 124 | groupBox->layout()->setSpacing( 0 ); |
125 | groupBox->layout()->setMargin( 4 ); | 125 | groupBox->layout()->setMargin( 4 ); |
126 | 126 | ||
127 | QVBoxLayout *groupBoxLayout = new QVBoxLayout( groupBox->layout() ); | 127 | QVBoxLayout *groupBoxLayout = new QVBoxLayout( groupBox->layout() ); |
128 | m_output = new QMultiLineEdit( groupBox ); | 128 | m_output = new QMultiLineEdit( groupBox ); |
129 | m_output->setReadOnly( true ); | 129 | m_output->setReadOnly( true ); |
130 | groupBoxLayout->addWidget( m_output ); | 130 | groupBoxLayout->addWidget( m_output ); |
131 | layout->addMultiCellWidget( groupBox, 2, 2, 0, 1 ); | 131 | layout->addMultiCellWidget( groupBox, 2, 2, 0, 1 ); |
132 | 132 | ||
133 | m_btnStart = new QPushButton( Resource::loadPixmap( "packagemanager/apply" ), tr( "Start" ), this ); | 133 | m_btnStart = new QPushButton( Resource::loadPixmap( "packagemanager/apply" ), tr( "Start" ), this ); |
134 | layout->addWidget( m_btnStart, 3, 0 ); | 134 | layout->addWidget( m_btnStart, 3, 0 ); |
135 | connect( m_btnStart, SIGNAL(clicked()), this, SLOT(slotBtnStart()) ); | 135 | connect( m_btnStart, SIGNAL(clicked()), this, SLOT(slotBtnStart()) ); |
136 | 136 | ||
137 | m_btnOptions = new QPushButton( Resource::loadPixmap( "SettingsIcon" ), tr( "Options" ), this ); | 137 | m_btnOptions = new QPushButton( Resource::loadPixmap( "SettingsIcon" ), tr( "Options" ), this ); |
138 | layout->addWidget( m_btnOptions, 3, 1 ); | 138 | layout->addWidget( m_btnOptions, 3, 1 ); |
139 | connect( m_btnOptions, SIGNAL( clicked() ), this, SLOT(slotBtnOptions()) ); | 139 | connect( m_btnOptions, SIGNAL( clicked() ), this, SLOT(slotBtnOptions()) ); |
140 | 140 | ||
141 | // Display packages being acted upon in output widget | 141 | // Display packages being acted upon in output widget |
142 | for( int i = 0; i < m_numCommands; i++ ) | 142 | for( int i = 0; i < m_numCommands; i++ ) |
143 | { | 143 | { |
144 | if ( !m_packages[ i ].isEmpty() ) | 144 | if ( !m_packages[ i ].isEmpty() ) |
145 | { | 145 | { |
146 | QString lineStr = tr( "Packages to " ); | 146 | QString lineStr = tr( "Packages to " ); |
147 | 147 | ||
148 | switch( m_command[ i ] ) | 148 | switch( m_command[ i ] ) |
149 | { | 149 | { |
150 | case OPackage::Install : lineStr.append( tr( "install" ) ); | 150 | case OPackage::Install : lineStr.append( tr( "install" ) ); |
151 | break; | 151 | break; |
152 | case OPackage::Remove : lineStr.append( tr( "remove" ) ); | 152 | case OPackage::Remove : lineStr.append( tr( "remove" ) ); |
153 | break; | 153 | break; |
154 | case OPackage::Upgrade : lineStr.append( tr( "upgrade" ) ); | 154 | case OPackage::Upgrade : lineStr.append( tr( "upgrade" ) ); |
155 | break; | 155 | break; |
156 | case OPackage::Download : lineStr.append( tr( "download" ) ); | 156 | case OPackage::Download : lineStr.append( tr( "download" ) ); |
157 | break; | 157 | break; |
158 | default : | 158 | default : |
159 | break; | 159 | break; |
160 | }; | 160 | }; |
161 | lineStr.append( ":\n" ); | 161 | lineStr.append( ":\n" ); |
162 | 162 | ||
163 | QStringList tmpPackage = m_packages[ i ]; | 163 | QStringList tmpPackage = m_packages[ i ]; |
164 | for ( QStringList::Iterator it = tmpPackage.begin(); it != tmpPackage.end(); ++it ) | 164 | for ( QStringList::Iterator it = tmpPackage.begin(); it != tmpPackage.end(); ++it ) |
165 | { | 165 | { |
166 | lineStr.append( QString( "\t%1\n" ).arg( ( *it ) ) ); | 166 | lineStr.append( QString( "\t%1\n" ).arg( ( *it ) ) ); |
167 | } | 167 | } |
168 | 168 | ||
169 | m_output->append( lineStr ); | 169 | m_output->append( lineStr ); |
170 | } | 170 | } |
171 | } | 171 | } |
172 | 172 | ||
173 | m_output->append( tr( "Press the start button to begin.\n" ) ); | 173 | m_output->append( tr( "Press the start button to begin.\n" ) ); |
174 | m_output->setCursorPosition( m_output->numLines(), 0 ); | 174 | m_output->setCursorPosition( m_output->numLines(), 0 ); |
175 | 175 | ||
176 | } | 176 | } |
177 | 177 | ||
178 | void InstallDlg::slotDisplayAvailSpace( const QString &destination ) | 178 | void InstallDlg::slotDisplayAvailSpace( const QString &destination ) |
179 | { | 179 | { |
180 | // If available space is not displayed, exit | 180 | // If available space is not displayed, exit |
181 | if ( !m_availSpace ) | 181 | if ( !m_availSpace ) |
182 | return; | 182 | return; |
183 | 183 | ||
184 | QString space = tr( "Unknown" ); | 184 | QString space = tr( "Unknown" ); |
185 | 185 | ||
186 | // Get destination | 186 | // Get destination |
187 | if ( !destination.isNull() ) | 187 | if ( !destination.isNull() ) |
188 | m_destItem = m_packman->findConfItem( OConfItem::Destination, destination ); | 188 | m_destItem = m_packman->findConfItem( OConfItem::Destination, destination ); |
189 | 189 | ||
190 | if ( m_destItem ) | 190 | if ( m_destItem ) |
191 | { | 191 | { |
192 | // Calculate available space | 192 | // Calculate available space |
193 | struct statfs fs; | 193 | struct statfs fs; |
194 | if ( !statfs( m_destItem->value(), &fs ) ) | 194 | if ( !statfs( m_destItem->value(), &fs ) ) |
195 | { | 195 | { |
196 | long mult = fs.f_bsize / 1024; | 196 | long mult = fs.f_bsize / 1024; |
197 | long div = 1024 / fs.f_bsize; | 197 | long div = 1024 / fs.f_bsize; |
198 | 198 | ||
199 | if ( !mult ) mult = 1; | 199 | if ( !mult ) mult = 1; |
200 | if ( !div ) div = 1; | 200 | if ( !div ) div = 1; |
201 | long avail = fs.f_bavail * mult / div; | 201 | long avail = fs.f_bavail * mult / div; |
202 | 202 | ||
203 | space = tr( "%1 Kb" ).arg( avail ); | 203 | space = tr( "%1 Kb" ).arg( avail ); |
204 | } | 204 | } |
205 | } | 205 | } |
206 | 206 | ||
207 | // Display available space | 207 | // Display available space |
208 | m_availSpace->setText( space ); | 208 | m_availSpace->setText( space ); |
209 | } | 209 | } |
210 | 210 | ||
211 | void InstallDlg::slotBtnStart() | 211 | void InstallDlg::slotBtnStart() |
212 | { | 212 | { |
213 | QString btnText = m_btnStart->text(); | 213 | QString btnText = m_btnStart->text(); |
214 | if ( btnText == tr( "Abort" ) ) | 214 | if ( btnText == tr( "Abort" ) ) |
215 | { | 215 | { |
216 | // Prevent unexecuted commands from executing | 216 | // Prevent unexecuted commands from executing |
217 | m_currCommand = 999; | 217 | m_currCommand = 999; |
218 | 218 | ||
219 | // Allow user to close dialog | 219 | // Allow user to close dialog |
220 | m_btnStart->setText( tr( "Close" ) ); | 220 | m_btnStart->setText( tr( "Close" ) ); |
221 | m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) ); | 221 | m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) ); |
222 | return; | 222 | return; |
223 | } | 223 | } |
224 | else if ( btnText == tr( "Close" ) ) | 224 | else if ( btnText == tr( "Close" ) ) |
225 | { | 225 | { |
226 | // TODO - force reload of package data | 226 | // TODO - force reload of package data |
227 | emit closeInstallDlg(); | 227 | emit closeInstallDlg(); |
228 | return; | 228 | return; |
229 | } | 229 | } |
230 | 230 | ||
231 | // Start was clicked, start executing | 231 | // Start was clicked, start executing |
232 | QString dest; | 232 | QString dest; |
233 | if ( m_installFound ) | 233 | if ( m_installFound ) |
234 | { | 234 | { |
235 | dest = m_destination->currentText(); | 235 | dest = m_destination->currentText(); |
236 | m_destination->setEnabled( false ); | 236 | m_destination->setEnabled( false ); |
237 | } | 237 | } |
238 | 238 | ||
239 | m_btnOptions->setEnabled( false ); | 239 | m_btnOptions->setEnabled( false ); |
240 | if ( m_numCommands > 1 ) | 240 | if ( m_numCommands > 1 ) |
241 | { | 241 | { |
242 | m_btnStart->setText( tr( "Abort" ) ); | 242 | m_btnStart->setText( tr( "Abort" ) ); |
243 | m_btnStart->setIconSet( Resource::loadPixmap( "close" ) ); | 243 | m_btnStart->setIconSet( Resource::loadPixmap( "close" ) ); |
244 | } | 244 | } |
245 | else | 245 | else |
246 | { | 246 | { |
247 | m_btnStart->setEnabled( false ); | 247 | m_btnStart->setEnabled( false ); |
248 | } | 248 | } |
249 | 249 | ||
250 | Opie::Core::OProcess process( this ); | 250 | Opie::Core::OProcess process( this ); |
251 | for ( m_currCommand = 0; m_currCommand < m_numCommands; m_currCommand++ ) | 251 | for ( m_currCommand = 0; m_currCommand < m_numCommands; m_currCommand++ ) |
252 | { | 252 | { |
253 | // Execute next command | 253 | // Execute next command |
254 | m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], dest, | 254 | m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], dest, |
255 | this, SLOT(slotOutput(char*)), true ); | 255 | this, SLOT(slotOutput(char*)), true ); |
256 | 256 | ||
257 | // Link/Unlink application if the package was removed from or installed to a destination | 257 | if ( m_command[ m_currCommand ] == OPackage::Remove ) |
258 | // other than root | ||
259 | if ( ( m_command[ m_currCommand ] == OPackage::Install && dest != "root" ) || | ||
260 | ( m_command[ m_currCommand ] == OPackage::Remove ) ) | ||
261 | { | 258 | { |
262 | //m_packman->findPackage( m_packages[ m_currCommand ]->destination() != "root"*/ ) | 259 | // Unlink application if the package was removed |
263 | 260 | ||
264 | // Loop through all package names in the command group | 261 | // Loop through all package names in the command group |
265 | for ( QStringList::Iterator it = m_packages[ m_currCommand ].begin(); | 262 | for ( QStringList::Iterator it = m_packages[ m_currCommand ].begin(); |
266 | it != m_packages[ m_currCommand ].end(); | 263 | it != m_packages[ m_currCommand ].end(); |
267 | ++it ) | 264 | ++it ) |
268 | { | 265 | { |
269 | OPackage *currPackage = m_packman->findPackage( (*it) ); | 266 | OPackage *currPackage = m_packman->findPackage( (*it) ); |
270 | 267 | ||
271 | // Skip package if it is not found or being removed from 'root' | 268 | // Skip package if it is not found or being removed from 'root' |
272 | if ( !currPackage || ( m_command[ m_currCommand ] == OPackage::Remove && | 269 | if ( !currPackage || ( m_command[ m_currCommand ] == OPackage::Remove && |
273 | currPackage->destination() == "root" ) ) | 270 | currPackage->destination() == "root" ) ) |
274 | continue; | 271 | continue; |
275 | 272 | ||
276 | // Display feedback to user | 273 | // Display feedback to user |
277 | if ( m_command[ m_currCommand ] == OPackage::Install ) | 274 | m_output->append( tr( QString( "Running ipkg-link to remove links for package '%1'." ) |
278 | m_output->append( tr( QString( "Running ipkg-link to link package '%1'." ) | 275 | .arg( currPackage->name() ) ) ); |
279 | .arg( currPackage->name() ) ) ); | ||
280 | else | ||
281 | m_output->append( tr( QString( "Running ipkg-link to remove links for package '%1'." ) | ||
282 | .arg( currPackage->name() ) ) ); | ||
283 | m_output->setCursorPosition( m_output->numLines(), 0 ); | 276 | m_output->setCursorPosition( m_output->numLines(), 0 ); |
284 | 277 | ||
285 | // Execute ipkg-link | 278 | // Execute ipkg-link |
286 | process.clearArguments(); | 279 | process.clearArguments(); |
287 | process << "ipkg-link" | 280 | process << "ipkg-link" |
288 | << ( ( m_command[ m_currCommand ] == OPackage::Install ) ? "add" : "remove" ) | 281 | << ( ( m_command[ m_currCommand ] == OPackage::Install ) ? "add" : "remove" ) |
289 | << currPackage->name(); | 282 | << currPackage->name(); |
290 | if ( !process.start( Opie::Core::OProcess::Block, | 283 | if ( !process.start( Opie::Core::OProcess::Block, |
291 | Opie::Core::OProcess::NoCommunication ) ) | 284 | Opie::Core::OProcess::NoCommunication ) ) |
292 | { | 285 | { |
293 | slotProcessDone( 0x0 ); | 286 | slotProcessDone( 0l ); |
294 | m_output->append( tr( "Unable to run ipkg-link." ) ); | 287 | m_output->append( tr( "Unable to run ipkg-link." ) ); |
295 | m_output->setCursorPosition( m_output->numLines(), 0 ); | 288 | m_output->setCursorPosition( m_output->numLines(), 0 ); |
296 | return; | 289 | return; |
297 | } | 290 | } |
298 | } | 291 | } |
299 | 292 | } | |
293 | else if ( m_command[ m_currCommand ] == OPackage::Install && dest != "root" ) | ||
294 | { | ||
295 | // Link applications in the destination directory | ||
296 | |||
297 | m_output->append( tr( "Running ipkg-link to link packages in '%1'." ).arg( dest ) ); | ||
298 | m_output->setCursorPosition( m_output->numLines(), 0 ); | ||
299 | |||
300 | QString destPath; | ||
301 | OConfItem *destItem = m_packman->findConfItem( OConfItem::Destination, dest ); | ||
302 | |||
303 | // Execute ipkg-link | ||
304 | process.clearArguments(); | ||
305 | process << "ipkg-link" | ||
306 | << "mount" | ||
307 | << destItem->value(); | ||
308 | if ( !process.start( Opie::Core::OProcess::Block, | ||
309 | Opie::Core::OProcess::NoCommunication ) ) | ||
310 | { | ||
311 | slotProcessDone( 0l ); | ||
312 | m_output->append( tr( "Unable to run ipkg-link." ) ); | ||
313 | m_output->setCursorPosition( m_output->numLines(), 0 ); | ||
314 | return; | ||
315 | } | ||
300 | } | 316 | } |
301 | } | 317 | } |
302 | 318 | ||
303 | slotProcessDone( 0x0 ); | 319 | slotProcessDone( 0l ); |
304 | } | 320 | } |
305 | 321 | ||
306 | void InstallDlg::slotProcessDone( Opie::Core::OProcess *proc ) | 322 | void InstallDlg::slotProcessDone( Opie::Core::OProcess *proc ) |
307 | { | 323 | { |
308 | if ( proc ) | 324 | if ( proc ) |
309 | { | 325 | { |
310 | // Display message pnly if linking was done | 326 | // Display message pnly if linking was done |
311 | m_output->append( tr( "The package linking is done." ) ); | 327 | m_output->append( tr( "The package linking is done." ) ); |
312 | m_output->setCursorPosition( m_output->numLines(), 0 ); | 328 | m_output->setCursorPosition( m_output->numLines(), 0 ); |
313 | 329 | ||
314 | delete proc; | 330 | delete proc; |
315 | } | 331 | } |
316 | 332 | ||
317 | // All commands executed, allow user to close dialog | 333 | // All commands executed, allow user to close dialog |
318 | m_btnStart->setEnabled( true ); | 334 | m_btnStart->setEnabled( true ); |
319 | m_btnStart->setText( tr( "Close" ) ); | 335 | m_btnStart->setText( tr( "Close" ) ); |
320 | m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) ); | 336 | m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) ); |
321 | 337 | ||
322 | m_btnOptions->setEnabled( true ); | 338 | m_btnOptions->setEnabled( true ); |
323 | m_btnOptions->setText( tr( "Save output" ) ); | 339 | m_btnOptions->setText( tr( "Save output" ) ); |
324 | m_btnOptions->setIconSet( Resource::loadPixmap( "save" ) ); | 340 | m_btnOptions->setIconSet( Resource::loadPixmap( "save" ) ); |
325 | } | 341 | } |
326 | 342 | ||
327 | void InstallDlg::slotBtnOptions() | 343 | void InstallDlg::slotBtnOptions() |
328 | { | 344 | { |
329 | QString btnText = m_btnOptions->text(); | 345 | QString btnText = m_btnOptions->text(); |
330 | if ( btnText == tr( "Options" ) ) | 346 | if ( btnText == tr( "Options" ) ) |
331 | { | 347 | { |
332 | // Display configuration dialog (only options tab is enabled) | 348 | // Display configuration dialog (only options tab is enabled) |
333 | m_packman->configureDlg( true ); | 349 | m_packman->configureDlg( true ); |
334 | return; | 350 | return; |
335 | } | 351 | } |
336 | 352 | ||
337 | // Save output was clicked | 353 | // Save output was clicked |
338 | QMap<QString, QStringList> map; | 354 | QMap<QString, QStringList> map; |
339 | map.insert( tr( "All" ), QStringList() ); | 355 | map.insert( tr( "All" ), QStringList() ); |
340 | QStringList text; | 356 | QStringList text; |
341 | text << "text/*"; | 357 | text << "text/*"; |
342 | map.insert(tr( "Text" ), text ); | 358 | map.insert(tr( "Text" ), text ); |
343 | text << "*"; | 359 | text << "*"; |
344 | map.insert( tr( "All" ), text ); | 360 | map.insert( tr( "All" ), text ); |
345 | 361 | ||
346 | QString filename = Opie::Ui::OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map ); | 362 | QString filename = Opie::Ui::OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map ); |
347 | if( !filename.isEmpty() ) | 363 | if( !filename.isEmpty() ) |
348 | { | 364 | { |
349 | QString currentFileName = QFileInfo( filename ).fileName(); | 365 | QString currentFileName = QFileInfo( filename ).fileName(); |
350 | DocLnk doc; | 366 | DocLnk doc; |
351 | doc.setType( "text/plain" ); | 367 | doc.setType( "text/plain" ); |
352 | doc.setFile( filename ); | 368 | doc.setFile( filename ); |
353 | doc.setName( currentFileName ); | 369 | doc.setName( currentFileName ); |
354 | FileManager fm; | 370 | FileManager fm; |
355 | fm.saveFile( doc, m_output->text() ); | 371 | fm.saveFile( doc, m_output->text() ); |
356 | } | 372 | } |
357 | } | 373 | } |
358 | 374 | ||
359 | void InstallDlg::slotOutput( char *msg ) | 375 | void InstallDlg::slotOutput( char *msg ) |
360 | { | 376 | { |
361 | // Allow processing of other events | 377 | // Allow processing of other events |
362 | qApp->processEvents(); | 378 | qApp->processEvents(); |
363 | 379 | ||
364 | QString lineStr = msg; | 380 | QString lineStr = msg; |
365 | if ( lineStr[lineStr.length()-1] == '\n' ) | 381 | if ( lineStr[lineStr.length()-1] == '\n' ) |
366 | lineStr.truncate( lineStr.length() - 1 ); | 382 | lineStr.truncate( lineStr.length() - 1 ); |
367 | m_output->append( lineStr ); | 383 | m_output->append( lineStr ); |
368 | m_output->setCursorPosition( m_output->numLines(), 0 ); | 384 | m_output->setCursorPosition( m_output->numLines(), 0 ); |
369 | 385 | ||
370 | // Update available space | 386 | // Update available space |
371 | slotDisplayAvailSpace( QString::null ); | 387 | slotDisplayAvailSpace( QString::null ); |
372 | } | 388 | } |
diff --git a/noncore/settings/packagemanager/installdlg.h b/noncore/settings/packagemanager/installdlg.h index eabb717..7a64fe0 100644 --- a/noncore/settings/packagemanager/installdlg.h +++ b/noncore/settings/packagemanager/installdlg.h | |||
@@ -1,101 +1,101 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the OPIE Project | 2 | This file is part of the OPIE Project |
3 | 3 | ||
4 | =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> | 4 | =. Copyright (c) 2003 Dan Williams <drw@handhelds.org> |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This file is free software; you can | 7 | _;:, .> :=|. This file is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This file is distributed in the hope that | 14 | .i_,=:_. -<s. This file is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU General |
19 | ..}^=.= = ; Public License for more details. | 19 | ..}^=.= = ; Public License for more details. |
20 | ++= -. .` .: | 20 | ++= -. .` .: |
21 | : = ...= . :.=- You should have received a copy of the GNU | 21 | : = ...= . :.=- You should have received a copy of the GNU |
22 | -. .:....=;==+<; General Public License along with this file; | 22 | -. .:....=;==+<; General Public License along with this file; |
23 | -_. . . )=. = see the file COPYING. If not, write to the | 23 | -_. . . )=. = see the file COPYING. If not, write to the |
24 | -- :-=` Free Software Foundation, Inc., | 24 | -- :-=` Free Software Foundation, Inc., |
25 | 59 Temple Place - Suite 330, | 25 | 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | #ifndef 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 OConfItem; | 42 | class OConfItem; |
43 | class OPackageManager; | 43 | class OPackageManager; |
44 | 44 | ||
45 | namespace Opie | 45 | namespace Opie |
46 | { | 46 | { |
47 | namespace Core | 47 | namespace Core |
48 | { | 48 | { |
49 | class OProcess; | 49 | class OProcess; |
50 | } | 50 | } |
51 | } | 51 | } |
52 | 52 | ||
53 | class InstallDlg : public QWidget | 53 | class InstallDlg : public QWidget |
54 | { | 54 | { |
55 | Q_OBJECT | 55 | Q_OBJECT |
56 | 56 | ||
57 | public: | 57 | public: |
58 | InstallDlg( QWidget *parent = 0x0, OPackageManager *pm = 0x0, | 58 | InstallDlg( QWidget *parent = 0l, OPackageManager *pm = 0l, |
59 | const QString &caption = QString::null, | 59 | const QString &caption = QString::null, |
60 | OPackage::Command command1 = OPackage::NotDefined, | 60 | OPackage::Command command1 = OPackage::NotDefined, |
61 | const QStringList &packages1 = QStringList(), | 61 | const QStringList &packages1 = QStringList(), |
62 | OPackage::Command command2 = OPackage::NotDefined, | 62 | OPackage::Command command2 = OPackage::NotDefined, |
63 | const QStringList &packages2 = QStringList(), | 63 | const QStringList &packages2 = QStringList(), |
64 | OPackage::Command command3 = OPackage::NotDefined, | 64 | OPackage::Command command3 = OPackage::NotDefined, |
65 | const QStringList &packages3 = QStringList() ); | 65 | const QStringList &packages3 = QStringList() ); |
66 | 66 | ||
67 | private: | 67 | private: |
68 | OPackageManager *m_packman; // Pointer to application instance of package manager | 68 | OPackageManager *m_packman; // Pointer to application instance of package manager |
69 | 69 | ||
70 | bool m_installFound; // Indicates if an install is being done, controls display of | 70 | bool m_installFound; // Indicates if an install is being done, controls display of |
71 | // destination selection, available space | 71 | // destination selection, available space |
72 | 72 | ||
73 | // UI controls | 73 | // UI controls |
74 | QComboBox *m_destination; // Destination selection list | 74 | QComboBox *m_destination; // Destination selection list |
75 | QLabel *m_availSpace; // Text label to display available space on selected destination | 75 | QLabel *m_availSpace; // Text label to display available space on selected destination |
76 | QMultiLineEdit *m_output; // Multi-line edit to display status | 76 | QMultiLineEdit *m_output; // Multi-line edit to display status |
77 | QPushButton *m_btnStart; // Start/abort/close button | 77 | QPushButton *m_btnStart; // Start/abort/close button |
78 | QPushButton *m_btnOptions; // Installation options button | 78 | QPushButton *m_btnOptions; // Installation options button |
79 | 79 | ||
80 | // Commands and packages to execute | 80 | // Commands and packages to execute |
81 | int m_numCommands; // Number of commands to be executed | 81 | int m_numCommands; // Number of commands to be executed |
82 | int m_currCommand; // Number of currently executing command | 82 | int m_currCommand; // Number of currently executing command |
83 | OPackage::Command m_command[3]; // List of commands to be executed | 83 | OPackage::Command m_command[3]; // List of commands to be executed |
84 | QStringList m_packages[3]; // Lists of package names associated to commands (m_command[]) | 84 | QStringList m_packages[3]; // Lists of package names associated to commands (m_command[]) |
85 | OConfItem *m_destItem; // Pointer to destination for package installation | 85 | OConfItem *m_destItem; // Pointer to destination for package installation |
86 | 86 | ||
87 | private slots: | 87 | private slots: |
88 | // UI control slots | 88 | // UI control slots |
89 | void slotDisplayAvailSpace( const QString &destination ); | 89 | void slotDisplayAvailSpace( const QString &destination ); |
90 | void slotBtnStart(); | 90 | void slotBtnStart(); |
91 | void slotBtnOptions(); | 91 | void slotBtnOptions(); |
92 | void slotProcessDone( Opie::Core::OProcess *proc ); | 92 | void slotProcessDone( Opie::Core::OProcess *proc ); |
93 | 93 | ||
94 | // Execution slots | 94 | // Execution slots |
95 | void slotOutput( char *msg ); | 95 | void slotOutput( char *msg ); |
96 | 96 | ||
97 | signals: | 97 | signals: |
98 | void closeInstallDlg(); | 98 | void closeInstallDlg(); |
99 | }; | 99 | }; |
100 | 100 | ||
101 | #endif | 101 | #endif |