summaryrefslogtreecommitdiff
path: root/noncore/settings/packagemanager/installdlg.cpp
Unidiff
Diffstat (limited to 'noncore/settings/packagemanager/installdlg.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/packagemanager/installdlg.cpp81
1 files changed, 2 insertions, 79 deletions
diff --git a/noncore/settings/packagemanager/installdlg.cpp b/noncore/settings/packagemanager/installdlg.cpp
index 985e2bd..7dea591 100644
--- a/noncore/settings/packagemanager/installdlg.cpp
+++ b/noncore/settings/packagemanager/installdlg.cpp
@@ -9,49 +9,48 @@ _;:, .> :=|. This file is free software; you can
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>
34 33
35#include <qpe/fileselector.h> 34#include <qpe/fileselector.h>
36#include <qpe/resource.h> 35#include <qpe/resource.h>
37#include <qpe/storage.h> 36#include <qpe/storage.h>
38 37
39#include <qapplication.h> 38#include <qapplication.h>
40#include <qcombobox.h> 39#include <qcombobox.h>
41#include <qfileinfo.h> 40#include <qfileinfo.h>
42#include <qgroupbox.h> 41#include <qgroupbox.h>
43#include <qlabel.h> 42#include <qlabel.h>
44#include <qlayout.h> 43#include <qlayout.h>
45#include <qmap.h> 44#include <qmap.h>
46#include <qmultilineedit.h> 45#include <qmultilineedit.h>
47#include <qpushbutton.h> 46#include <qpushbutton.h>
48 47
49#include <sys/vfs.h> 48#include <sys/vfs.h>
50 49
51#include "opackagemanager.h" 50#include "opackagemanager.h"
52 51
53InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &caption, 52InstallDlg::InstallDlg( QWidget *parent, OPackageManager *pm, const QString &caption,
54 OPackage::Command command1, const QStringList &packages1, 53 OPackage::Command command1, const QStringList &packages1,
55 OPackage::Command command2, const QStringList &packages2, 54 OPackage::Command command2, const QStringList &packages2,
56 OPackage::Command command3, const QStringList &packages3 ) 55 OPackage::Command command3, const QStringList &packages3 )
57 : QWidget( 0l ) 56 : QWidget( 0l )
@@ -226,163 +225,87 @@ void InstallDlg::slotBtnStart()
226 // TODO - force reload of package data 225 // TODO - force reload of package data
227 emit closeInstallDlg(); 226 emit closeInstallDlg();
228 return; 227 return;
229 } 228 }
230 229
231 // Start was clicked, start executing 230 // Start was clicked, start executing
232 QString dest; 231 QString dest;
233 if ( m_installFound ) 232 if ( m_installFound )
234 { 233 {
235 dest = m_destination->currentText(); 234 dest = m_destination->currentText();
236 m_destination->setEnabled( false ); 235 m_destination->setEnabled( false );
237 } 236 }
238 237
239 m_btnOptions->setEnabled( false ); 238 m_btnOptions->setEnabled( false );
240 if ( m_numCommands > 1 ) 239 if ( m_numCommands > 1 )
241 { 240 {
242 m_btnStart->setText( tr( "Abort" ) ); 241 m_btnStart->setText( tr( "Abort" ) );
243 m_btnStart->setIconSet( Resource::loadPixmap( "close" ) ); 242 m_btnStart->setIconSet( Resource::loadPixmap( "close" ) );
244 } 243 }
245 else 244 else
246 { 245 {
247 m_btnStart->setEnabled( false ); 246 m_btnStart->setEnabled( false );
248 } 247 }
249 248
250 Opie::Core::OProcess process( this );
251 for ( m_currCommand = 0; m_currCommand < m_numCommands; m_currCommand++ ) 249 for ( m_currCommand = 0; m_currCommand < m_numCommands; m_currCommand++ )
252 { 250 {
253 // Execute next command 251 // Execute next command
254 m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], dest, 252 m_packman->executeCommand( m_command[ m_currCommand ], m_packages[ m_currCommand ], dest,
255 this, SLOT(slotOutput(char*)), true ); 253 this, SLOT(slotOutput(const QString &)), true );
256
257 if ( m_command[ m_currCommand ] == OPackage::Remove )
258 {
259 // Unlink application if the package was removed
260
261 // Loop through all package names in the command group
262 for ( QStringList::Iterator it = m_packages[ m_currCommand ].begin();
263 it != m_packages[ m_currCommand ].end();
264 ++it )
265 {
266 OPackage *currPackage = m_packman->findPackage( (*it) );
267
268 // Skip package if it is not found or being removed from 'root'
269 if ( !currPackage || ( m_command[ m_currCommand ] == OPackage::Remove &&
270 currPackage->destination() == "root" ) )
271 continue;
272
273 // Display feedback to user
274 m_output->append( tr( QString( "Running ipkg-link to remove links for package '%1'." )
275 .arg( currPackage->name() ) ) );
276 m_output->setCursorPosition( m_output->numLines(), 0 );
277
278 // Execute ipkg-link
279 process.clearArguments();
280 process << "ipkg-link"
281 << ( ( m_command[ m_currCommand ] == OPackage::Install ) ? "add" : "remove" )
282 << currPackage->name();
283 if ( !process.start( Opie::Core::OProcess::Block,
284 Opie::Core::OProcess::NoCommunication ) )
285 {
286 slotProcessDone( 0l );
287 m_output->append( tr( "Unable to run ipkg-link." ) );
288 m_output->setCursorPosition( m_output->numLines(), 0 );
289 return;
290 }
291 }
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 }
316 }
317 }
318
319 slotProcessDone( 0l );
320}
321
322void InstallDlg::slotProcessDone( Opie::Core::OProcess *proc )
323{
324 if ( proc )
325 {
326 // Display message pnly if linking was done
327 m_output->append( tr( "The package linking is done." ) );
328 m_output->setCursorPosition( m_output->numLines(), 0 );
329
330 delete proc;
331 } 254 }
332 255
333 // All commands executed, allow user to close dialog 256 // All commands executed, allow user to close dialog
334 m_btnStart->setEnabled( true ); 257 m_btnStart->setEnabled( true );
335 m_btnStart->setText( tr( "Close" ) ); 258 m_btnStart->setText( tr( "Close" ) );
336 m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) ); 259 m_btnStart->setIconSet( Resource::loadPixmap( "enter" ) );
337 260
338 m_btnOptions->setEnabled( true ); 261 m_btnOptions->setEnabled( true );
339 m_btnOptions->setText( tr( "Save output" ) ); 262 m_btnOptions->setText( tr( "Save output" ) );
340 m_btnOptions->setIconSet( Resource::loadPixmap( "save" ) ); 263 m_btnOptions->setIconSet( Resource::loadPixmap( "save" ) );
341} 264}
342 265
343void InstallDlg::slotBtnOptions() 266void InstallDlg::slotBtnOptions()
344{ 267{
345 QString btnText = m_btnOptions->text(); 268 QString btnText = m_btnOptions->text();
346 if ( btnText == tr( "Options" ) ) 269 if ( btnText == tr( "Options" ) )
347 { 270 {
348 // Display configuration dialog (only options tab is enabled) 271 // Display configuration dialog (only options tab is enabled)
349 m_packman->configureDlg( true ); 272 m_packman->configureDlg( true );
350 return; 273 return;
351 } 274 }
352 275
353 // Save output was clicked 276 // Save output was clicked
354 QMap<QString, QStringList> map; 277 QMap<QString, QStringList> map;
355 map.insert( tr( "All" ), QStringList() ); 278 map.insert( tr( "All" ), QStringList() );
356 QStringList text; 279 QStringList text;
357 text << "text/*"; 280 text << "text/*";
358 map.insert(tr( "Text" ), text ); 281 map.insert(tr( "Text" ), text );
359 text << "*"; 282 text << "*";
360 map.insert( tr( "All" ), text ); 283 map.insert( tr( "All" ), text );
361 284
362 QString filename = Opie::Ui::OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map ); 285 QString filename = Opie::Ui::OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map );
363 if( !filename.isEmpty() ) 286 if( !filename.isEmpty() )
364 { 287 {
365 QString currentFileName = QFileInfo( filename ).fileName(); 288 QString currentFileName = QFileInfo( filename ).fileName();
366 DocLnk doc; 289 DocLnk doc;
367 doc.setType( "text/plain" ); 290 doc.setType( "text/plain" );
368 doc.setFile( filename ); 291 doc.setFile( filename );
369 doc.setName( currentFileName ); 292 doc.setName( currentFileName );
370 FileManager fm; 293 FileManager fm;
371 fm.saveFile( doc, m_output->text() ); 294 fm.saveFile( doc, m_output->text() );
372 } 295 }
373} 296}
374 297
375void InstallDlg::slotOutput( char *msg ) 298void InstallDlg::slotOutput( const QString &msg )
376{ 299{
377 // Allow processing of other events 300 // Allow processing of other events
378 qApp->processEvents(); 301 qApp->processEvents();
379 302
380 QString lineStr = msg; 303 QString lineStr = msg;
381 if ( lineStr[lineStr.length()-1] == '\n' ) 304 if ( lineStr[lineStr.length()-1] == '\n' )
382 lineStr.truncate( lineStr.length() - 1 ); 305 lineStr.truncate( lineStr.length() - 1 );
383 m_output->append( lineStr ); 306 m_output->append( lineStr );
384 m_output->setCursorPosition( m_output->numLines(), 0 ); 307 m_output->setCursorPosition( m_output->numLines(), 0 );
385 308
386 // Update available space 309 // Update available space
387 slotDisplayAvailSpace( QString::null ); 310 slotDisplayAvailSpace( QString::null );
388} 311}