-rw-r--r-- | noncore/settings/aqpkg/installdlgimpl.cpp | 58 | ||||
-rw-r--r-- | noncore/settings/aqpkg/installdlgimpl.h | 1 | ||||
-rw-r--r-- | noncore/settings/aqpkg/instoptionsimpl.cpp | 27 | ||||
-rw-r--r-- | noncore/settings/aqpkg/instoptionsimpl.h | 5 | ||||
-rw-r--r-- | noncore/settings/aqpkg/ipkg.cpp | 6 | ||||
-rw-r--r-- | noncore/settings/aqpkg/ipkg.h | 3 |
6 files changed, 79 insertions, 21 deletions
diff --git a/noncore/settings/aqpkg/installdlgimpl.cpp b/noncore/settings/aqpkg/installdlgimpl.cpp index 2bb8b4d..76d0a80 100644 --- a/noncore/settings/aqpkg/installdlgimpl.cpp +++ b/noncore/settings/aqpkg/installdlgimpl.cpp @@ -3,43 +3,47 @@ ------------------- begin : Mon Aug 26 2002 copyright : (C) 2002 by Andy Qua email : andy.qua@blueyonder.co.uk ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #include <stdio.h> + +#include <opie/ofiledialog.h> #ifdef QWS #include <qpe/config.h> +#include <qpe/fileselector.h> #include <qpe/qpeapplication.h> #include <qpe/resource.h> #include <qpe/storage.h> #endif #include <qcheckbox.h> #include <qcombobox.h> #include <qdialog.h> +#include <qfileinfo.h> #include <qgroupbox.h> #include <qmultilineedit.h> #include <qlabel.h> #include <qlayout.h> #include <qpushbutton.h> #include "datamgr.h" #include "destination.h" #include "instoptionsimpl.h" #include "installdlgimpl.h" #include "ipkg.h" #include "utils.h" #include "global.h" enum { MAXLINES = 100, @@ -50,32 +54,33 @@ InstallDlgImpl::InstallDlgImpl( QList<InstallData> &packageList, DataManager *da { setCaption( title ); init( TRUE ); pIpkg = 0; upgradePackages = false; dataMgr = dataManager; QString defaultDest = "root"; #ifdef QWS Config cfg( "aqpkg" ); cfg.setGroup( "settings" ); defaultDest = cfg.readEntry( "dest", "root" ); // Grab flags - Turn MAKE_LINKS on by default (if no flags found) flags = cfg.readNumEntry( "installFlags", 0 ); + infoLevel = cfg.readNumEntry( "infoLevel", 1 ); #else flags = 0; #endif // Output text is read only output->setReadOnly( true ); // QFont f( "helvetica" ); // f.setPointSize( 10 ); // output->setFont( f ); // setup destination data int defIndex = 0; int i; QListIterator<Destination> dit( dataMgr->getDestinationList() ); for ( i = 0; dit.current(); ++dit, ++i ) @@ -177,43 +182,71 @@ void InstallDlgImpl :: init( bool displayextrainfo ) QVBoxLayout *GroupBox2Layout = new QVBoxLayout( GroupBox2->layout() ); output = new QMultiLineEdit( GroupBox2 ); GroupBox2Layout->addWidget( output ); layout->addMultiCellWidget( GroupBox2, 2, 2, 0, 1 ); btnInstall = new QPushButton( Resource::loadPixmap( "aqpkg/apply" ), tr( "Start" ), this ); layout->addWidget( btnInstall, 3, 0 ); connect( btnInstall, SIGNAL( clicked() ), this, SLOT( installSelected() ) ); btnOptions = new QPushButton( Resource::loadPixmap( "SettingsIcon" ), tr( "Options" ), this ); layout->addWidget( btnOptions, 3, 1 ); connect( btnOptions, SIGNAL( clicked() ), this, SLOT( optionsSelected() ) ); } void InstallDlgImpl :: optionsSelected() { - InstallOptionsDlgImpl opt( flags, this, "Option", true ); - opt.exec(); - - // set options selected from dialog - flags = opt.getFlags(); + if ( btnOptions->text() == tr( "Options" ) ) + { + InstallOptionsDlgImpl opt( flags, infoLevel, this, "Option", true ); + if ( opt.exec() == QDialog::Accepted ) + { + // set options selected from dialog + flags = opt.getFlags(); + infoLevel = opt.getInfoLevel(); #ifdef QWS - Config cfg( "aqpkg" ); - cfg.setGroup( "settings" ); - cfg.writeEntry( "installFlags", flags ); + Config cfg( "aqpkg" ); + cfg.setGroup( "settings" ); + cfg.writeEntry( "installFlags", flags ); + cfg.writeEntry( "infoLevel", infoLevel ); #endif + } + } + else // Save output + { + QMap<QString, QStringList> map; + map.insert( tr( "All" ), QStringList() ); + QStringList text; + text << "text/*"; + map.insert(tr( "Text" ), text ); + text << "*"; + map.insert( tr( "All" ), text ); + + QString filename = OFileDialog::getSaveFileName( 2, "/", "ipkg-output", map ); + if( !filename.isEmpty() ) + { + QString currentFileName = QFileInfo( filename ).fileName(); + DocLnk doc; + doc.setType( "text/plain" ); + doc.setFile( filename ); + doc.setName( currentFileName ); + FileManager fm; + fm.saveFile( doc, output->text() ); + } + } } void InstallDlgImpl :: installSelected() { if ( btnInstall->text() == tr( "Abort" ) ) { if ( pIpkg ) { displayText( tr( "\n**** User Clicked ABORT ***" ) ); pIpkg->abort(); displayText( tr( "**** Process Aborted ****" ) ); } btnInstall->setText( tr( "Close" ) ); btnInstall->setIconSet( Resource::loadPixmap( "enter" ) ); return; @@ -259,75 +292,78 @@ void InstallDlgImpl :: installSelected() // First run through the remove list, then the install list then the upgrade list pIpkg->setOption( "remove" ); QListIterator<InstallData> it( removeList ); InstallData *idata; for ( ; it.current(); ++it ) { idata = it.current(); pIpkg->setDestination( idata->destination->getDestinationName() ); pIpkg->setDestinationDir( idata->destination->getDestinationPath() ); pIpkg->setPackage( idata->packageName ); int tmpFlags = flags; if ( idata->destination->linkToRoot() ) tmpFlags |= MAKE_LINKS; - pIpkg->setFlags( tmpFlags ); + pIpkg->setFlags( tmpFlags, infoLevel ); pIpkg->runIpkg(); } pIpkg->setOption( "install" ); pIpkg->setDestination( dest ); pIpkg->setDestinationDir( destDir ); - pIpkg->setFlags( instFlags ); + pIpkg->setFlags( instFlags, infoLevel ); QListIterator<InstallData> it2( installList ); for ( ; it2.current(); ++it2 ) { pIpkg->setPackage( it2.current()->packageName ); pIpkg->runIpkg(); } flags |= FORCE_REINSTALL; QListIterator<InstallData> it3( updateList ); for ( ; it3.current() ; ++it3 ) { idata = it3.current(); if ( idata->option == "R" ) pIpkg->setOption( "reinstall" ); else pIpkg->setOption( "upgrade" ); pIpkg->setDestination( idata->destination->getDestinationName() ); pIpkg->setDestinationDir( idata->destination->getDestinationPath() ); pIpkg->setPackage( idata->packageName ); int tmpFlags = flags; if ( idata->destination->linkToRoot() && idata->recreateLinks ) tmpFlags |= MAKE_LINKS; - pIpkg->setFlags( tmpFlags ); + pIpkg->setFlags( tmpFlags, infoLevel ); pIpkg->runIpkg(); } delete pIpkg; pIpkg = 0; } btnOptions->setEnabled( true ); // btnInstall->setEnabled( true ); btnInstall->setText( tr( "Close" ) ); btnInstall->setIconSet( Resource::loadPixmap( "enter" ) ); + + btnOptions->setText( tr( "Save output" ) ); + btnOptions->setIconSet( Resource::loadPixmap( "save" ) ); if ( destination && destination->currentText() != 0 && destination->currentText() != "" ) displayAvailableSpace( destination->currentText() ); } void InstallDlgImpl :: displayText(const QString &text ) { QString newtext = QString( "%1\n%2" ).arg( output->text() ).arg( text ); /* Set a max line count for the QMultiLineEdit, as users have reported * performance issues when line count gets extreme. */ if(output->numLines() >= MAXLINES) output->removeLine(0); output->setText( newtext ); diff --git a/noncore/settings/aqpkg/installdlgimpl.h b/noncore/settings/aqpkg/installdlgimpl.h index c30963e..15cf427 100644 --- a/noncore/settings/aqpkg/installdlgimpl.h +++ b/noncore/settings/aqpkg/installdlgimpl.h @@ -46,32 +46,33 @@ class InstallDlgImpl : public QWidget Q_OBJECT public: InstallDlgImpl( QList<InstallData> &packageList, DataManager *dataManager, const char *title = 0 ); InstallDlgImpl( Ipkg *ipkg, QString initialText, const char *title = 0 ); ~InstallDlgImpl(); bool upgradeServer( QString &server ); protected: private: DataManager *dataMgr; QList<InstallData> installList; QList<InstallData> removeList; QList<InstallData> updateList; int flags; + int infoLevel; Ipkg *pIpkg; bool upgradePackages; QComboBox *destination; QPushButton *btnInstall; QPushButton *btnOptions; QMultiLineEdit *output; QLabel *txtAvailableSpace; void init( bool ); bool runIpkg( QString &option, const QString& package, const QString& dest, int flags ); signals: void reloadData( InstallDlgImpl * ); diff --git a/noncore/settings/aqpkg/instoptionsimpl.cpp b/noncore/settings/aqpkg/instoptionsimpl.cpp index 47b250d..72d794f 100644 --- a/noncore/settings/aqpkg/instoptionsimpl.cpp +++ b/noncore/settings/aqpkg/instoptionsimpl.cpp @@ -7,93 +7,110 @@ ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifdef QWS #include <qpe/config.h> #endif #include <qcheckbox.h> +#include <qcombobox.h> #include <qgroupbox.h> +#include <qlabel.h> #include <qlayout.h> #include "global.h" #include "instoptionsimpl.h" #include "ipkg.h" -InstallOptionsDlgImpl::InstallOptionsDlgImpl( int flags, QWidget * parent, const char* name, bool modal, WFlags fl ) +InstallOptionsDlgImpl::InstallOptionsDlgImpl( int flags, int verb, QWidget * parent, const char* name, bool modal, WFlags fl ) : QDialog( parent, name, modal, fl ) { setCaption( tr( "Options" ) ); QVBoxLayout *layout = new QVBoxLayout( this ); layout->setMargin( 2 ); layout->setSpacing( 4 ); QGroupBox *grpbox = new QGroupBox( 0, Qt::Vertical, tr( "Options" ), this ); grpbox->layout()->setSpacing( 2 ); grpbox->layout()->setMargin( 4 ); layout->addWidget( grpbox ); QVBoxLayout *grplayout = new QVBoxLayout( grpbox->layout() ); forceDepends = new QCheckBox( tr( "Force Depends" ), grpbox ); grplayout->addWidget( forceDepends ); forceReinstall = new QCheckBox( tr( "Force Reinstall" ), grpbox ); grplayout->addWidget( forceReinstall ); forceRemove = new QCheckBox( tr( "Force Remove" ), grpbox ); grplayout->addWidget( forceRemove ); forceOverwrite = new QCheckBox( tr( "Force Overwrite" ), grpbox ); grplayout->addWidget( forceOverwrite ); - verboseWget = new QCheckBox( tr( "Verbose WGet" ), grpbox ); - grplayout->addWidget( verboseWget ); + QLabel *l = new QLabel( tr( "Information Level" ), grpbox ); + grplayout->addWidget( l ); + + verboseIpkg = new QComboBox( grpbox ); + verboseIpkg->insertItem( tr( "Errors only" ) ); + verboseIpkg->insertItem( tr( "Normal messages" ) ); + verboseIpkg->insertItem( tr( "Informative messages" ) ); + verboseIpkg->insertItem( tr( "Troubleshooting output" ) ); + verboseIpkg->setCurrentItem( verb ); + grplayout->addWidget( verboseIpkg ); + + grplayout->addItem( new QSpacerItem( 1, 1, QSizePolicy::Minimum, QSizePolicy::Expanding ) ); if ( flags & FORCE_DEPENDS ) forceDepends->setChecked( true ); if ( flags & FORCE_REINSTALL ) forceReinstall->setChecked( true ); if ( flags & FORCE_REMOVE ) forceRemove->setChecked( true ); if ( flags & FORCE_OVERWRITE ) forceOverwrite->setChecked( true ); - if ( flags & VERBOSE_WGET ) - verboseWget->setChecked( true ); +// if ( flags & VERBOSE_WGET ) +// verboseWget->setChecked( true ); // if ( flags & MAKE_LINKS ) // makeLinks->setChecked( true ); showMaximized(); } InstallOptionsDlgImpl::~InstallOptionsDlgImpl() { } int InstallOptionsDlgImpl :: getFlags() { int flags = 0; if ( forceDepends->isChecked() ) flags |= FORCE_DEPENDS; if ( forceReinstall->isChecked() ) flags |= FORCE_REINSTALL; if ( forceRemove->isChecked() ) flags |= FORCE_REMOVE; if ( forceOverwrite->isChecked() ) flags |= FORCE_OVERWRITE; if ( verboseWget->isChecked() ) flags |= VERBOSE_WGET; return flags; } + +int InstallOptionsDlgImpl :: getInfoLevel() +{ + return verboseIpkg->currentItem(); +} diff --git a/noncore/settings/aqpkg/instoptionsimpl.h b/noncore/settings/aqpkg/instoptionsimpl.h index f4724a0..1312afd 100644 --- a/noncore/settings/aqpkg/instoptionsimpl.h +++ b/noncore/settings/aqpkg/instoptionsimpl.h @@ -7,34 +7,37 @@ ***************************************************************************/ /*************************************************************************** * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * ***************************************************************************/ #ifndef INSTALLOPTIONSIMPL_H #define INSTALLOPTIONSIMPL_H #include <qdialog.h> class QCheckBox; +class QComboBox; class InstallOptionsDlgImpl : public QDialog { Q_OBJECT public: - InstallOptionsDlgImpl( int flags, QWidget * parent = 0, const char* name = 0, bool modal = false, WFlags fl = 0 ); + InstallOptionsDlgImpl( int, int, QWidget * = 0, const char * = 0, bool = false, WFlags = 0 ); ~InstallOptionsDlgImpl(); int getFlags(); + int getInfoLevel(); private: QCheckBox* forceDepends; QCheckBox* forceReinstall; QCheckBox* forceRemove; QCheckBox* forceOverwrite; QCheckBox* verboseWget; + QComboBox* verboseIpkg; }; #endif diff --git a/noncore/settings/aqpkg/ipkg.cpp b/noncore/settings/aqpkg/ipkg.cpp index e66c02d..7df643e 100644 --- a/noncore/settings/aqpkg/ipkg.cpp +++ b/noncore/settings/aqpkg/ipkg.cpp @@ -56,50 +56,50 @@ Ipkg :: ~Ipkg() // flags is the ipkg options flags // dir is the directory to run ipkg in (defaults to "") bool Ipkg :: runIpkg( ) { error = false; bool ret = false; QStringList commands; QDir::setCurrent( "/tmp" ); if ( runtimeDir != "" ) { commands << "cd "; commands << runtimeDir; commands << ";"; } - commands << "ipkg" << "-force-defaults"; + commands << "ipkg" << "-V" << QString::number( infoLevel ) << "-force-defaults"; // only set the destination for an install operation if ( option == "install" ) commands << "-dest" << destination; if ( option != "update" && option != "download" ) { if ( flags & FORCE_DEPENDS ) commands << "-force-depends"; if ( flags & FORCE_REINSTALL ) commands << "-force-reinstall"; if ( flags & FORCE_REMOVE ) commands << "-force-removal-of-essential-packages"; if ( flags & FORCE_OVERWRITE ) commands << "-force-overwrite"; - if ( flags & VERBOSE_WGET ) + if ( infoLevel == 3 ) commands << "-verbose_wget"; // Handle make links // Rules - If make links is switched on, create links to root // if destDir is NOT / if ( flags & MAKE_LINKS ) { // If destDir == / turn off make links as package is being insalled // to root already. if ( destDir == "/" ) flags ^= MAKE_LINKS; } } #ifdef X86 commands << "-f"; @@ -240,33 +240,33 @@ void Ipkg :: removeStatusEntry() // Write lines out vector<QString>::iterator it; for ( it = lines.begin() ; it != lines.end() ; ++it ) { cout << "Writing " << (const char *)(*it) << endl; out << (const char *)(*it) << endl; } in.close(); out.close(); // Remove old status file and put tmp stats file in its place remove( statusFile ); rename( outStatusFile, statusFile ); } -int Ipkg :: executeIpkgCommand( QStringList &cmd, const QString option ) +int Ipkg :: executeIpkgCommand( QStringList &cmd, const QString /*option*/ ) { // If one is already running - should never be but just to be safe if ( proc ) { delete proc; proc = 0; } // OK we're gonna use OProcess to run this thing proc = new OProcess(); aborted = false; // Connect up our slots connect(proc, SIGNAL(processExited(OProcess *)), this, SLOT( processFinished())); diff --git a/noncore/settings/aqpkg/ipkg.h b/noncore/settings/aqpkg/ipkg.h index d49bb04..531bfc0 100644 --- a/noncore/settings/aqpkg/ipkg.h +++ b/noncore/settings/aqpkg/ipkg.h @@ -36,54 +36,55 @@ #define VERBOSE_WGET 0x0020 class OProcess; class Ipkg : public QObject { Q_OBJECT public: Ipkg(); ~Ipkg(); bool runIpkg( ); void setOption( const char *opt ) { option = opt; } void setPackage( const char *pkg ) { package = pkg; } void setDestination( const char *dest ) { destination = dest; } void setDestinationDir( const char *dir ) { destDir = dir; } - void setFlags( int fl ) { flags = fl; } + void setFlags( int fl, int il ) { flags = fl; infoLevel = il; } void setRuntimeDirectory( const char *dir ) { runtimeDir = dir; } signals: void outputText( const QString &text ); public slots: void commandStdout(OProcess*, char *buffer, int buflen); void commandStderr(OProcess*, char *buffer, int buflen); void processFinished(); void abort(); private: bool createLinks; bool aborted; bool error; QString option; QString package; QString destination; QString destDir; QString runtimeDir; OProcess *proc; int flags; + int infoLevel; bool finished; QList<QString> *dependantPackages; int executeIpkgCommand( QStringList &cmd, const QString option ); void removeStatusEntry(); void linkPackage( const QString &packFileName, const QString &dest, const QString &destDir ); QStringList* getList( const QString &packageFilename, const QString &destDir ); void processFileList( const QStringList *fileList, const QString &destDir ); void processLinkDir( const QString &file, const QString &baseDir, const QString &destDir ); }; #endif |