-rw-r--r-- | noncore/unsupported/oipkg/installdialog.cpp | 3 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/installdialog.h | 5 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/pmipkg.cpp | 44 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/pmipkg.h | 2 |
4 files changed, 30 insertions, 24 deletions
diff --git a/noncore/unsupported/oipkg/installdialog.cpp b/noncore/unsupported/oipkg/installdialog.cpp index 72f436a..a2c9702 100644 --- a/noncore/unsupported/oipkg/installdialog.cpp +++ b/noncore/unsupported/oipkg/installdialog.cpp @@ -1,104 +1,107 @@ /**************************************************************************** ** Form implementation generated from reading ui file 'installdialog.ui' ** ** Created: Thu May 2 22:19:02 2002 ** by: The User Interface Compiler (uic) ** ** WARNING! All changes made in this file will be lost! ****************************************************************************/ #include "installdialog.h" #include <qcheckbox.h> #include <qgroupbox.h> #include <qheader.h> #include <qlistview.h> #include <qpushbutton.h> #include <qlayout.h> #include <qvariant.h> #include <qtooltip.h> #include <qwhatsthis.h> InstallDialog::InstallDialog( PackageManagerSettings* s, QWidget* parent, const char* name, bool modal, WFlags fl ) : QDialog( parent, name, modal, fl ) { settings = s; if ( !name ) setName( "InstallDialog" ); resize( 223, 269 ); setCaption( tr( "Install" ) ); InstallDialogLayout = new QGridLayout( this ); InstallDialogLayout->setSpacing( 2 ); InstallDialogLayout->setMargin( 2 ); ListViewPackages = new PackageListView( this,"listViewPackages",settings ); InstallDialogLayout->addWidget( ListViewPackages, 0, 0 ); GroupBoxOptions = new QGroupBox( this, "GroupBoxOptions" ); GroupBoxOptions->setTitle( tr( "Ipkg options" ) ); GroupBoxOptions->setColumnLayout(0, Qt::Vertical ); GroupBoxOptions->layout()->setSpacing( 0 ); GroupBoxOptions->layout()->setMargin( 0 ); GroupBoxOptionsLayout = new QGridLayout( GroupBoxOptions->layout() ); GroupBoxOptionsLayout->setAlignment( Qt::AlignTop ); GroupBoxOptionsLayout->setSpacing( 2 ); GroupBoxOptionsLayout->setMargin( 2 ); _force_depends = new QCheckBox( GroupBoxOptions, "_force_depends" ); QFont _force_depends_font( _force_depends->font() ); _force_depends_font.setPointSize( 8 ); _force_depends->setFont( _force_depends_font ); _force_depends->setText( tr( "-force-depends" ) ); //_force_depends->setChecked( true ); GroupBoxOptionsLayout->addWidget( _force_depends, 0, 0 ); _force_reinstall = new QCheckBox( GroupBoxOptions, "_force_reinstall" ); QFont _force_reinstall_font( _force_reinstall->font() ); _force_reinstall_font.setPointSize( 8 ); _force_reinstall->setFont( _force_reinstall_font ); _force_reinstall->setText( tr( "-force-reinstall" ) ); GroupBoxOptionsLayout->addWidget( _force_reinstall, 1, 0 ); _force_remove = new QCheckBox( GroupBoxOptions, "_force_remove" ); QFont _force_remove_font( _force_remove->font() ); _force_remove_font.setPointSize( 8 ); _force_remove->setFont( _force_remove_font ); _force_remove->setText( tr( "-force-removal-of-essential-packages" ) ); GroupBoxOptionsLayout->addWidget( _force_remove, 2, 0 ); InstallDialogLayout->addWidget( GroupBoxOptions, 1, 0 ); + toRemoveItem = new QCheckListItem( ListViewPackages, QObject::tr("To remove") ); + toInstallItem = new QCheckListItem( ListViewPackages, QObject::tr("To install") ); + } /* * Destroys the object and frees any allocated resources */ InstallDialog::~InstallDialog() { // no need to delete child widgets, Qt does it all for us } /* * Main event handler. Reimplemented to handle application * font changes */ bool InstallDialog::event( QEvent* ev ) { bool ret = QDialog::event( ev ); if ( ev->type() == QEvent::ApplicationFontChange ) { QFont _force_depends_font( _force_depends->font() ); _force_depends_font.setPointSize( 8 ); _force_depends->setFont( _force_depends_font ); QFont _force_reinstall_font( _force_reinstall->font() ); _force_reinstall_font.setPointSize( 8 ); _force_reinstall->setFont( _force_reinstall_font ); QFont _force_remove_font( _force_remove->font() ); _force_remove_font.setPointSize( 8 ); _force_remove->setFont( _force_remove_font ); } return ret; } diff --git a/noncore/unsupported/oipkg/installdialog.h b/noncore/unsupported/oipkg/installdialog.h index f2164ac..5af2c35 100644 --- a/noncore/unsupported/oipkg/installdialog.h +++ b/noncore/unsupported/oipkg/installdialog.h @@ -1,46 +1,47 @@ /**************************************************************************** ** Form interface generated from reading ui file 'installdialog.ui' ** ** Created: Thu May 2 22:19:01 2002 ** by: The User Interface Compiler (uic) ** ** WARNING! All changes made in this file will be lost! ****************************************************************************/ #ifndef INSTALLDIALOG_H #define INSTALLDIALOG_H #include "pksettings.h" #include "packagelistview.h" #include <qvariant.h> #include <qdialog.h> class QVBoxLayout; class QHBoxLayout; class QGridLayout; class QCheckBox; class QGroupBox; class QListView; class QListViewItem; class InstallDialog : public QDialog { Q_OBJECT -public: - InstallDialog( PackageManagerSettings* s, QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); +public: InstallDialog( PackageManagerSettings* s, QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 ); ~InstallDialog(); PackageListView* ListViewPackages; QGroupBox* GroupBoxOptions; QCheckBox* _force_depends; QCheckBox* _force_reinstall; QCheckBox* _force_remove; + QCheckListItem *toRemoveItem; + QCheckListItem *toInstallItem; protected: QGridLayout* InstallDialogLayout; QGridLayout* GroupBoxOptionsLayout; bool event( QEvent* ); private: PackageManagerSettings* settings; }; #endif // INSTALLDIALOG_H diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp index 75f93cf..f2852c3 100644 --- a/noncore/unsupported/oipkg/pmipkg.cpp +++ b/noncore/unsupported/oipkg/pmipkg.cpp @@ -1,388 +1,390 @@ #include "pmipkg.h" #include "pksettings.h" #include "package.h" #include "packagelistitem.h" #include <qpe/process.h> #include <qpe/resource.h> #include <qpe/config.h> #include <qpe/stringutil.h> #include <qpe/qpeapplication.h> #include <qdir.h> #include <qfile.h> #include <qgroupbox.h> #include <qmultilineedit.h> #include <qstring.h> #include <qcheckbox.h> #include <qtextstream.h> #include <qtextview.h> #include <qprogressbar.h> #include <qpushbutton.h> #include <qlayout.h> #include <stdlib.h> #include <unistd.h> #include "mainwindow.h" PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlags f ) : QObject ( p ) { settings = s; runwindow = new RunWindow( p, name, true, f ); } PmIpkg::~PmIpkg() { } bool PmIpkg::runIpkg(const QString& args, const QString& dest ) { bool ret=false; QDir::setCurrent("/tmp"); QString cmd = "/usr/bin/ipkg "; pvDebug( 3,"PmIpkg::runIpkg got dest="+dest); if ( dest == "" ) cmd += " -dest "+settings->getDestinationName(); else cmd += " -dest "+ dest; cmd += " -force-defaults "; if (installDialog->_force_depends) { if (installDialog->_force_depends->isChecked()) cmd += " -force-depends "; if (installDialog->_force_reinstall->isChecked()) cmd += " -force-reinstall "; if (installDialog->_force_remove->isChecked()) cmd += " -force-removal-of-essential-packages "; } out( "Starting to "+ args+"\n"); cmd += args; out( "running:\n"+cmd+"\n" ); pvDebug(2,"running:"+cmd); qApp->processEvents(); FILE *fp; char line[130]; QString lineStr, lineStrOld; sleep(1); cmd +=" 2>&1"; fp = popen( (const char *) cmd, "r"); if ( !fp ) { qDebug("Could not execute '" + cmd + "'! err=%d", fp); pclose(fp); out("\nError while executing "+ cmd+"\n\n"); return false; } else { while ( fgets( line, sizeof line, fp)) { lineStr = line; lineStr=lineStr.left(lineStr.length()-1); //Configuring opie-oipkg...Done if (lineStr.contains("Done")) ret = true; if (lineStr!=lineStrOld) out(lineStr); lineStrOld = lineStr; } pclose(fp); } //out( "Finished!"); pvDebug(2,QString(ret?"success\n":"failure\n")); return ret; } void PmIpkg::makeLinks(Package *pack) { pvDebug( 2, "PmIpkg::makeLinks "+ pack->name()); linkPackage( pack->name(), pack->dest() ); } QStringList* PmIpkg::getList( QString packFileName, QString d ) { QString dest = settings->getDestinationUrlByName( d ); dest = dest==""?d:dest; if (dest == "/" ) return 0; { Config cfg( "oipkg", Config::User ); cfg.setGroup( "Common" ); QString statusDir = cfg.readEntry( "statusDir", "" ); } packFileName = dest+"/"+statusDir+"/info/"+packFileName+".list"; QFile f( packFileName ); if ( ! f.open(IO_ReadOnly) ) { pvDebug(1," Panik! Could not open"); out( "Panik!\n Could not open:\n"+packFileName ); return (QStringList*)0; } QStringList *fileList = new QStringList(); QTextStream t( &f ); while ( !t.eof() ) { *fileList += t.readLine(); } return fileList; } void PmIpkg::linkPackage( QString packFileName, QString dest ) { QStringList *fileList = getList( packFileName, dest ); processFileList( fileList, dest ); delete fileList; } void PmIpkg::processFileList( QStringList *fileList, QString d ) { if (!fileList) return; for (uint i=0; i < fileList->count(); i++) { QString dest = settings->getDestinationUrlByName( d ); dest = dest==""?d:dest; processLinkDir( (*fileList)[i], dest ); } } void PmIpkg::processLinkDir( QString file, QString dest ) { pvDebug( 4,"PmIpkg::processLinkDir "+file+" to "+ dest); if (linkOpp==createLink) pvDebug( 4,"opp: createLink"); if (linkOpp==removeLink) pvDebug( 4,"opp: removeLink"); if ( dest == "???" || dest == "" ) return; QString destFile = file; file = dest+"/"+file; if (file == dest) return; QFileInfo fileInfo( file ); if ( fileInfo.isDir() ) { pvDebug(4, "process dir "+file); QDir destDir( destFile ); if (linkOpp==createLink) destDir.mkdir( destFile, true ); QDir d( file ); // d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks ); const QFileInfoList *list = d.entryInfoList(); QFileInfoListIterator it( *list ); QFileInfo *fi; while ( (fi=it.current()) ) { pvDebug(4, "processLinkDir "+fi->absFilePath()); processLinkDir( fi->absFilePath(), dest ); ++it; } } else if ( fileInfo.isFile() ) { const char *instFile = strdup( (file).ascii() ); const char *linkFile = strdup( (destFile).ascii()); if( linkOpp==createLink ) { pvDebug(4, "linking: "+file+" -> "+destFile ); symlink( instFile, linkFile ); } } else { const char *linkFile = strdup( (destFile).ascii()); if( linkOpp==removeLink ) { QFileInfo toRemoveLink( destFile ); if ( !QFile::exists( file ) && toRemoveLink.isSymLink() ) { pvDebug(4,"removing "+destFile+" no "+file); unlink( linkFile ); } } } } void PmIpkg::loadList( PackageList *pl ) { for( Package *pack = pl->first();pack ; (pack = pl->next()) ) { if ( pack && (pack->name() != "") && pack) { if ( pack->toInstall() ) to_install.append( pack ); if ( pack->toRemove() ) to_remove.append( pack ); } } } void PmIpkg::commit() { int sizecount = 0; installDialog = new InstallDialog(settings,0,0,true); - QCheckListItem *toRemoveItem = new QCheckListItem( installDialog->ListViewPackages, QObject::tr("To remove") ); - QCheckListItem *toInstallItem = new QCheckListItem( installDialog->ListViewPackages, QObject::tr("To install") ); - toRemoveItem->setOpen( true ); - toInstallItem->setOpen( true ); + installDialog->toRemoveItem->setOpen( true ); + installDialog->toInstallItem->setOpen( true ); for (uint i=0; i < to_remove.count(); i++) { sizecount += 1; - toRemoveItem->insertItem( new PackageListItem(installDialog->ListViewPackages, to_remove.at(i),settings) ); + installDialog->toRemoveItem->insertItem( new PackageListItem(installDialog->ListViewPackages, to_remove.at(i),settings) ); } for (uint i=0; i < to_install.count(); i++) { sizecount += to_install.at(i)->size().toInt(); - toInstallItem->insertItem( new PackageListItem(installDialog->ListViewPackages, to_install.at(i),settings) ); + installDialog->toInstallItem->insertItem( new PackageListItem(installDialog->ListViewPackages, to_install.at(i),settings) ); } runwindow->progress->setTotalSteps(sizecount); qDebug("Install size %i",sizecount); installDialog->showMaximized(); installDialog->show(); - if ( installDialog->exec() ) doIt(); - installDialog->close(); + if ( installDialog->exec() ) + { + doIt(); runwindow->showMaximized(); runwindow->show(); + } + installDialog->close(); out(tr("\nAll done.")); } void PmIpkg::doIt() { runwindow->progress->setProgress(0); show(); remove(); install(); } void PmIpkg::remove() { if ( to_remove.count() == 0 ) return; out(tr("Removing")+"\n"+tr("please wait")+"\n\n"); QStringList *fileList; for (uint i=0; i < to_remove.count(); i++) { if ( to_remove.at(i)->link() )fileList = getList( to_remove.at(i)->name(), to_remove.at(i)->dest() ); - if ( runIpkg("remove " + to_remove.at(i)->name(), to_remove.at(i)->dest() )) + if ( runIpkg("remove " + to_remove.at(i)->installName(), to_remove.at(i)->dest() )) { runwindow->progress->setProgress( 1 ); linkOpp = removeLink; - if ( to_remove.at(i)->link() ) - { - out( "\nremoving links\n" ); - out( "for package "+to_remove.at(i)->name()+" in "+to_remove.at(i)->dest()+"\n" ); - processFileList( fileList, to_remove.at(i)->dest() ); - } to_remove.at(i)->processed(); to_remove.take( i ); + out("\n\n"); }else{ out(tr("Error while removing")+to_remove.at(i)->name()+"\n"); } + if ( to_remove.at(i)->link() ) + { + out( "\nremoving links\n" ); + out( "for package "+to_remove.at(i)->name()+" in "+to_remove.at(i)->dest()+"\n" ); + processFileList( fileList, to_remove.at(i)->dest() ); + } if ( to_remove.at(i)->link() )delete fileList; } to_remove.clear(); out("\n"); } void PmIpkg::install() { if ( to_install.count() == 0 ) return; out(tr("Installing")+"\n"+tr("please wait")+"\n"); for (uint i=0; i < to_install.count(); i++) { if ( runIpkg("install " + to_install.at(i)->installName(), to_install.at(i)->dest() )) { runwindow->progress->setProgress( to_install.at(i)->size().toInt() + runwindow->progress->progress()); + to_install.at(i)->processed(); + to_install.take( i ); + out("\n\n"); + }else{ + out(tr("Error while installing")+to_install.at(i)->name()+"\n"); + } linkOpp = createLink; if ( to_install.at(i)->link() ) { out( "\ncreating links\n" ); out( "for package "+to_install.at(i)->name()+" in "+to_install.at(i)->dest()+"\n" ); makeLinks( to_install.at(i) ); } - to_install.at(i)->processed(); - to_install.take( i ); - out("\n\n"); - }else{ - out(tr("Error while installing")+to_install.at(i)->name()+"\n"); - } } out("\n"); to_install.clear(); } void PmIpkg::createLinks( const QString &dest ) { pvDebug(2,"PmIpkg::createLinks "+dest); linkOpp=createLink; QString url = settings->getDestinationUrlByName( dest ); url = url==""?dest:url; processLinkDir( "/opt", url ); processLinkDir( "/usr", url ); } void PmIpkg::removeLinks( const QString &dest ) { pvDebug(2,"PmIpkg::removeLinks "+dest); linkOpp=removeLink; QString url = settings->getDestinationUrlByName( dest ); url = url==""?dest:url; processLinkDir( "/opt", url ); processLinkDir( "/usr", url ); } void PmIpkg::update() { show(); runIpkg( "update" ); runwindow->close(); } void PmIpkg::out( QString o ) { runwindow->outPut->append(o); runwindow->outPut->setCursorPosition(runwindow->outPut->numLines() + 1,0,FALSE); } void PmIpkg::show() { if (!runwindow->isVisible()) { runwindow->showMaximized(); runwindow->show(); } runwindow->outPut->setText(""); // showButtons(b); // if ( !b ) // runwindow->progress->hide(); // else // runwindow->progress->show(); } void PmIpkg::installFile(const QString &fileName, const QString &dest) { to_install.clear(); to_remove.clear(); pvDebug( 2,"PmIpkg::installFile "+ fileName); Package *p = new Package(fileName,settings); if ( dest!="") p->setDest( dest ); to_install.append( p ); commit(); delete p; } void PmIpkg::removeFile(const QString &fileName, const QString &dest) { to_install.clear(); to_remove.clear(); pvDebug( 2,"PmIpkg::removeFile "+ fileName); Package *p = new Package(fileName,settings); if ( dest!="") p->setDest( dest ); to_remove.append( p ); commit(); delete p; } diff --git a/noncore/unsupported/oipkg/pmipkg.h b/noncore/unsupported/oipkg/pmipkg.h index f8ac39a..c543304 100644 --- a/noncore/unsupported/oipkg/pmipkg.h +++ b/noncore/unsupported/oipkg/pmipkg.h @@ -1,63 +1,63 @@ #ifndef PMIPKG_H #define PMIPKG_H #include <qobject.h> #include <qlist.h> #include <qstring.h> #include <qwidget.h> #include "pksettings.h" #include "runwindow.h" #include "packagelist.h" #include "installdialog.h" #include "debug.h" #define createLink 0 #define removeLink 1 class Package; class PmIpkg : public QObject { Q_OBJECT public: PmIpkg( PackageManagerSettings* , QWidget* p=0, const char * name=0, WFlags f=0 ); ~PmIpkg(); int linkOpp; void loadList( PackageList* ); void commit(); void update(); void show(); public slots: void doIt(); void install(); void remove(); void installFile(const QString &fileName, const QString &dest=""); void removeFile(const QString &fileName, const QString &dest=""); void createLinks( const QString &dest ); void removeLinks( const QString &dest ); private: PackageManagerSettings* settings; RunWindow *runwindow; InstallDialog *installDialog; QList<Package> to_remove; QList<Package> to_install; QString fileNameToInstall; QCheckBox *_force_reinstall; QCheckBox *_force_remove; QCheckBox *_force_depends; - void startDialog(); +// void startDialog(); void makeLinks(Package*); void linkPackage( QString, QString ); void processLinkDir( QString , QString ); bool runIpkg(const QString& args, const QString& dest="" ); void out( QString ); QStringList* getList( QString, QString ); void processFileList( QStringList*, QString ); }; #endif |