author | tille <tille> | 2002-06-21 09:01:39 (UTC) |
---|---|---|
committer | tille <tille> | 2002-06-21 09:01:39 (UTC) |
commit | 0d5a0129ee055e0f077505b05caa942bf6ef6165 (patch) (side-by-side diff) | |
tree | c718cc805ae49c922a126192c7e98747c025b103 | |
parent | 48847f165b3ee8d096871c1bde8748d18cfb0f43 (diff) | |
download | opie-0d5a0129ee055e0f077505b05caa942bf6ef6165.zip opie-0d5a0129ee055e0f077505b05caa942bf6ef6165.tar.gz opie-0d5a0129ee055e0f077505b05caa942bf6ef6165.tar.bz2 |
some fixes and first version with oprocess (out-ifdefed)
-rw-r--r-- | noncore/unsupported/oipkg/TODO | 13 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/installdialog.cpp | 4 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/main.cpp | 2 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/mainwindow.cpp | 3 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/oipkg.pro | 1 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/package.cpp | 23 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/package.h | 15 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/packagelist.cpp | 10 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/packagelist.h | 8 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/packagelistdoclnk.cpp | 8 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/packagelistdoclnk.h | 4 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/packagelistitem.cpp | 2 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/packagelistview.cpp | 6 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/pksettings.cpp | 1 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/pksettings.h | 2 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/pmipkg.cpp | 72 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/pmipkg.h | 10 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/settings.h | 2 |
18 files changed, 138 insertions, 48 deletions
diff --git a/noncore/unsupported/oipkg/TODO b/noncore/unsupported/oipkg/TODO index e7b017c..6e0e6ca 100644 --- a/noncore/unsupported/oipkg/TODO +++ b/noncore/unsupported/oipkg/TODO @@ -1,13 +1,20 @@ -* check for networt before installing from network -* Settings Class -* parse "to install" and "to remove" from status +* check for network before installing from network +* Settings Class / new setting dialog +* parse "to install" and "to remove" from status, and change status + i.e. improve status handling / modify status file + dest keyword in status? -> cworth * install local file dialog +* parse lists files after opening feed / doclnk * qcop * error handling * manage links * dependency checking * create dest if it does not exist * allow reinstalling * different types of filters and searches i.e. name, desc, files etc * display new list after update +* make sure oipkg installs to the correct dest when getting packet to install from list + dest keyword? +* cancel button while installing +* duplicate button for settings-servers diff --git a/noncore/unsupported/oipkg/installdialog.cpp b/noncore/unsupported/oipkg/installdialog.cpp index a2c9702..bb50103 100644 --- a/noncore/unsupported/oipkg/installdialog.cpp +++ b/noncore/unsupported/oipkg/installdialog.cpp @@ -50,50 +50,50 @@ InstallDialog::InstallDialog( PackageManagerSettings* s, QWidget* parent, const _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") ); + toRemoveItem = new QCheckListItem( ListViewPackages, tr("To remove") ); + toInstallItem = new QCheckListItem( ListViewPackages, 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 ); diff --git a/noncore/unsupported/oipkg/main.cpp b/noncore/unsupported/oipkg/main.cpp index de25e27..f72540c 100644 --- a/noncore/unsupported/oipkg/main.cpp +++ b/noncore/unsupported/oipkg/main.cpp @@ -1,25 +1,25 @@ #include "mainwindow.h" #include <qpe/qpeapplication.h> #include <qstring.h> //#include <qmessagebox.h> int debugLevel; int main( int argc, char ** argv ) { printf("This is oipkg\n"); - printf("$ID$\n"); + printf("$Id$\n"); debugLevel = 2; if (argc > 1) { debugLevel = QString ( argv[1] ).toInt(); qDebug("setting debug level to %i",debugLevel); } QPEApplication a( argc, argv ); MainWindow mw; // if (argc > 2) // QMessageBox::information( &mw, "oipkg","While ipkg is working\noipkg is hanging.\nPlease be patient!"); a.showMainDocumentWidget( &mw ); return a.exec(); } diff --git a/noncore/unsupported/oipkg/mainwindow.cpp b/noncore/unsupported/oipkg/mainwindow.cpp index 27c9f4c..11ab406 100644 --- a/noncore/unsupported/oipkg/mainwindow.cpp +++ b/noncore/unsupported/oipkg/mainwindow.cpp @@ -12,48 +12,51 @@ #include <qaction.h> #include <qmessagebox.h> #include <qpopupmenu.h> #include <qtoolbutton.h> #include <qstring.h> #include <qlabel.h> #include <qfile.h> #include <qlistview.h> #include <qtextview.h> #include <qcheckbox.h> #include <qlineedit.h> #include <qtabwidget.h> #include <qcombobox.h> #include <qmessagebox.h> #include <qpushbutton.h> #include <qlayout.h> #include "pksettingsbase.h" #include "utils.h" #include "packagelistitem.h" MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f = 0 ) : QMainWindow( parent, name, f ) +// packageListServers( QObject(parent), name ), +// packageListSearch( parent, name ), +// packageListDocLnk( parent, name ) { setCaption( tr("Package Manager") ); settings = new PackageManagerSettings(this,0,TRUE); listViewPackages = new PackageListView( this,"listViewPackages",settings ); setCentralWidget( listViewPackages ); listViewPackages->addList( tr("feeds"), &packageListServers ); listViewPackages->addList( tr("ipkgfind"), &packageListSearch ); listViewPackages->addList( tr("documents"), &packageListDocLnk ); ipkg = new PmIpkg( settings, this ); packageListServers.setSettings( settings ); packageListSearch.setSettings( settings ); packageListDocLnk.setSettings( settings ); pvDebug(9,"packageListServers.update"); packageListServers.update(); pvDebug(9,"packageListDocLnk.update"); packageListDocLnk.update(); pvDebug(9,"makeMenu"); makeMenu(); makeChannel(); //opie is hardcoded default ;) // pvDebug(9,"section->setCurrentItem"); // for (int i=0;i<section->count();i++) // if (section->text(i)=="opie") // section->setCurrentItem(i); diff --git a/noncore/unsupported/oipkg/oipkg.pro b/noncore/unsupported/oipkg/oipkg.pro index 9e2f5f8..7f60ed8 100644 --- a/noncore/unsupported/oipkg/oipkg.pro +++ b/noncore/unsupported/oipkg/oipkg.pro @@ -9,28 +9,29 @@ HEADERS = mainwindow.h \ installdialog.h \ utils.h \ packagelistitem.h \ packagelistremote.h \ packagelist.h \ packagelistlocal.h \ packagelistview.h \ package.h SOURCES = main.cpp \ mainwindow.cpp \ utils.cpp \ packagelistdoclnk.cpp \ packagelistview.cpp \ installdialog.cpp \ packagelistremote.cpp \ packagelistlocal.cpp \ pksettings.cpp \ pmipkg.cpp \ packagelistitem.cpp \ packagelist.cpp \ package.cpp INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/ioclude LIBS += -lqpe +LIBS += -lopie INTERFACES = runwindow.ui \ pksettingsbase.ui TARGET = oipkg diff --git a/noncore/unsupported/oipkg/package.cpp b/noncore/unsupported/oipkg/package.cpp index 4a09b40..97f7813 100644 --- a/noncore/unsupported/oipkg/package.cpp +++ b/noncore/unsupported/oipkg/package.cpp @@ -1,84 +1,93 @@ #include "package.h" #include <qpe/process.h> #include <qpe/stringutil.h> #include <qfile.h> #include <qtextstream.h> #include <stdlib.h> #include <unistd.h> #include "debug.h" -//Package::~Package() -//{ -//} +Package::Package( QObject *parent=0, const char *name=0 ) + : QObject(parent,name) +{ + +} + +Package::~Package() +{ +} -Package::Package( PackageManagerSettings *s ) +Package::Package( PackageManagerSettings *s, QObject *parent=0, const char *name=0 ) + : QObject(parent,name) { + Package(parent,name); init(s); } void Package::init( PackageManagerSettings *s ) { settings = s; _size = ""; _section = ""; _subsection = ""; _shortDesc = ""; _desc = ""; _name = ""; _toProcess = false; _useFileName = false; _old = false; _status = ""; _dest = settings->getDestinationName(); _link = settings->createLinks(); _versions=0; _version=""; } -Package::Package( QStringList pack, PackageManagerSettings *s ) +Package::Package( QStringList pack, PackageManagerSettings *s , QObject *parent=0, const char *name=0 ) + : QObject(parent,name) { init(s); parsePackage( pack ); } -Package::Package( QString n, PackageManagerSettings *s ) +Package::Package( QString n, PackageManagerSettings *s, QObject *parent=0, const char *name=0 ) { init(s); if ( !QFile::exists( n ) ) { _name = QString( n ); }else{ pvDebug(4,"remote file: "+n); parseIpkgFile( n ); _useFileName = true; _fileName = QString( n ); } } -Package::Package( Package *pi ) +Package::Package( Package *pi, QObject *parent=0, const char *name=0 ) { init(pi->settings); copyValues( pi ); } void Package::setValue( QString n, QString t ) { if ( n == "Package" ) { _name = QString( t ); }else if ( n == "Installed-Size" ) { _size = t; // }else if ( n == "Priority") // { }else if ( n == "Section") { setSection( t ); // }else if ( n == "Maintainer") // { // // }else if ( n == "Architecture") diff --git a/noncore/unsupported/oipkg/package.h b/noncore/unsupported/oipkg/package.h index 68090dc..f50b9b5 100644 --- a/noncore/unsupported/oipkg/package.h +++ b/noncore/unsupported/oipkg/package.h @@ -1,45 +1,46 @@ #ifndef PK_ITEM_H #define PK_ITEM_H #include <qstring.h> #include <qlistview.h> #include <qpainter.h> #include <qpixmap.h> #include <qdict.h> #include <qobject.h> #include "pksettings.h" -class Package //: public QObject +class Package : public QObject { -// Q_OBJECT + Q_OBJECT public: - Package(PackageManagerSettings *); - // ~Package(); - Package( QStringList, PackageManagerSettings * ); - Package( QString, PackageManagerSettings * ); - Package( Package* ); + Package(QObject *parent=0, const char *name=0); + Package(PackageManagerSettings *s, QObject *parent=0, const char *name=0); + ~Package(); + Package( QStringList, PackageManagerSettings *s, QObject *parent=0, const char *name=0 ); + Package( QString, PackageManagerSettings *s, QObject *parent=0, const char *name=0 ); + Package( Package*s, QObject *parent=0, const char *name=0 ); void setValue( QString, QString ); void copyValues( Package* ); QString name(); QString installName(); bool installed(); bool otherInstalled(); void setDesc( QString ); QString shortDesc(); QString desc(); QString size(); QString sizeUnits(); QString version(); void setSection( QString ); QString section(); QString subSection(); QString details(); bool toProcess(); bool toInstall(); bool toRemove(); void processed(); QString dest(); diff --git a/noncore/unsupported/oipkg/packagelist.cpp b/noncore/unsupported/oipkg/packagelist.cpp index 1b572e0..3cc0443 100644 --- a/noncore/unsupported/oipkg/packagelist.cpp +++ b/noncore/unsupported/oipkg/packagelist.cpp @@ -1,55 +1,55 @@ #include "packagelist.h" #include <assert.h> #include <qfile.h> #include <qfileinfo.h> #include <qtextstream.h> #include "debug.h" static QDict<Package> *packageListAll; static int packageListAllRefCount = 0; -PackageList::PackageList() - : packageIter( packageList ) +PackageList::PackageList(QObject *parent=0, const char *name=0) + : QObject(parent,name), packageIter( packageList ) { empty=true; if (!packageListAll) packageListAll = new QDict<Package>(); packageListAllRefCount++; sections << "All"; subSections.insert("All", new QStringList() ); QStringList *ss = subSections["All"]; *ss << "All"; aktSection = "All"; aktSubSection = "All"; } -PackageList::PackageList( PackageManagerSettings* s) - : packageIter( packageList ) +PackageList::PackageList( PackageManagerSettings* s, QObject *parent, const char *name) + : QObject(parent,name), packageIter( packageList ) { settings = s; - PackageList(); + PackageList(parent, name); } PackageList::~PackageList() { if (--packageListAllRefCount < 1 ) delete packageListAll; } /** Inserts a package into the list */ void PackageList::insertPackage( Package* pack ) { if (!pack) return; Package* p = packageListAll->find( pack->name() ); if ( p ) { if ( (p->version() == pack->version()) // && (p->dest() == pack->dest()) ) { p->copyValues( pack ); delete pack; pack = p; } else { QDict<Package> *packver = p->getOtherVersions(); // p->setName( pack->name()+"["+p->version()+"]" ); diff --git a/noncore/unsupported/oipkg/packagelist.h b/noncore/unsupported/oipkg/packagelist.h index d0f8897..78dcd92 100644 --- a/noncore/unsupported/oipkg/packagelist.h +++ b/noncore/unsupported/oipkg/packagelist.h @@ -1,40 +1,40 @@ #ifndef PACKAGELIST_H #define PACKAGELIST_H #include <qdict.h> #include "package.h" #include "pksettings.h" #include "debug.h" -class PackageList //:QObject +class PackageList :QObject { -// Q_OBJECT + Q_OBJECT public: // static QString all = QObject::tr("All"); - PackageList(); - PackageList( PackageManagerSettings* ); + PackageList (QObject *parent=0, const char *name=0); + PackageList( PackageManagerSettings *s, QObject *parent=0, const char *name=0); virtual ~PackageList(); void insertPackage( Package* ); Package* find( QString ); Package* next(); Package* first(); QStringList getSections(); QStringList getSubSections(); void setSettings( PackageManagerSettings* ); void filterPackages( QString ); Package* getByName( QString ); void clear(); void allPackages(); QDict<Package> *versions; public slots: void setSection(QString); void setSubSection(QString); // virtual void update(); protected: int currentPackage; int packageCount; diff --git a/noncore/unsupported/oipkg/packagelistdoclnk.cpp b/noncore/unsupported/oipkg/packagelistdoclnk.cpp index f31f742..b42cfdd 100644 --- a/noncore/unsupported/oipkg/packagelistdoclnk.cpp +++ b/noncore/unsupported/oipkg/packagelistdoclnk.cpp @@ -1,42 +1,42 @@ #include "packagelistdoclnk.h" #include <qpe/applnk.h> #include <qpe/config.h> #include <qlist.h> #include "package.h" #include "pksettings.h" -PackageListDocLnk::PackageListDocLnk(PackageManagerSettings* s) +PackageListDocLnk::PackageListDocLnk(PackageManagerSettings* s, QObject *parent=0, const char *name=0) : PackageList(s) { - PackageListDocLnk(); + PackageListDocLnk(parent, name); } -PackageListDocLnk::PackageListDocLnk() - : PackageList() +PackageListDocLnk::PackageListDocLnk(QObject *parent=0, const char *name=0) + : PackageList(parent, name) { Config cfg( "oipkg", Config::User ); cfg.setGroup( "Common" ); docLnkDir = cfg.readEntry( "docLnkDir", "/root/" ); pvDebug(2,"opening DocLnkSet "+docLnkDir); doclnkset = new DocLnkSet(docLnkDir,"application/ipkg"); } PackageListDocLnk::~PackageListDocLnk() { Config cfg( "oipkg", Config::User ); cfg.setGroup( "Common" ); cfg.writeEntry( "docLnkDir", docLnkDir ); delete doclnkset; } void PackageListDocLnk::update() { pvDebug(2,"PackageListDocLnk::update "); QList<DocLnk> packlist = doclnkset->children(); for (DocLnk *pack =packlist.first(); pack != 0; pack=packlist.next() ) { diff --git a/noncore/unsupported/oipkg/packagelistdoclnk.h b/noncore/unsupported/oipkg/packagelistdoclnk.h index fe73658..a63fb59 100644 --- a/noncore/unsupported/oipkg/packagelistdoclnk.h +++ b/noncore/unsupported/oipkg/packagelistdoclnk.h @@ -1,23 +1,23 @@ #ifndef PACKAGELISTDOCLNK_H #define PACKAGELISTDOCLNK_H #include "packagelist.h" #include "debug.h" class DocLnkSet; class PackageListDocLnk : public PackageList { public: - PackageListDocLnk(); - PackageListDocLnk( PackageManagerSettings* s); + PackageListDocLnk(QObject *parent=0, const char *name=0); + PackageListDocLnk( PackageManagerSettings *s, QObject *parent=0, const char *name=0); virtual ~PackageListDocLnk(); public slots: void update(); private: DocLnkSet *doclnkset; QString docLnkDir; }; #endif diff --git a/noncore/unsupported/oipkg/packagelistitem.cpp b/noncore/unsupported/oipkg/packagelistitem.cpp index 55047d5..0c9c676 100644 --- a/noncore/unsupported/oipkg/packagelistitem.cpp +++ b/noncore/unsupported/oipkg/packagelistitem.cpp @@ -138,29 +138,29 @@ QString PackageListItem::key( int column, bool ascending ) const if ( !ascending ) bytes=999999999-bytes; return QString().sprintf("%09d",(int)bytes); } else { return QListViewItem::key(column,ascending); } } void PackageListItem::setOn( bool b ) { QCheckListItem::setOn( b ); package->toggleProcess(); package->setLink( settings->createLinks() ); displayDetails(); } void PackageListItem::displayDetails() { QString sod; sod += package->sizeUnits().isEmpty()?QString(""):QString(package->sizeUnits()); //sod += QString(package->dest().isEmpty()?"":QObject::tr(" on ")+package->dest()); sod += package->dest().isEmpty()?QString(""):QString(QObject::tr(" on ")+package->dest()); sod = sod.isEmpty()?QString(""):QString(" ("+sod+")"); setText(0, package->name()+sod ); nameItem->setText( 0, QObject::tr("Name: ")+package->name()); - linkItem->setText( 0, QObject::tr("Link: ")+QString(package->link()?QObject::tr("Yes"):QObject::tr("No")) ); + linkItem->setText( 0, QObject::tr("Link: ")+package->link()?QObject::tr("Yes"):QObject::tr("No")); destItem->setText( 0, QObject::tr("Destination: ")+package->dest() ); statusItem->setText( 0, QObject::tr("Status: ")+package->status() ); repaint(); } diff --git a/noncore/unsupported/oipkg/packagelistview.cpp b/noncore/unsupported/oipkg/packagelistview.cpp index 70aa48a..2bb74e9 100644 --- a/noncore/unsupported/oipkg/packagelistview.cpp +++ b/noncore/unsupported/oipkg/packagelistview.cpp @@ -38,69 +38,69 @@ void PackageListView::setCurrent( QListViewItem* p ) if (!activePackage) { // QDictIterator<QCheckListItem> it( rootItems ); // while ( it.current() ) // { // if ( it.current()==p ) // pvDebug(2,"current item"); // ++it; // } return; } popupTimer->start( 750, true ); } void PackageListView::showPopup() { popupMenu->clear(); destsMenu->clear(); QAction *popupAction; if ( !activePackage->installed() ) { - popupMenu->insertItem( QObject::tr("Install to"), destsMenu ); + popupMenu->insertItem( tr("Install to"), destsMenu ); QStringList dests = settings->getDestinationNames(); QString ad = settings->getDestinationName(); for (uint i = 0; i < dests.count(); i++ ) { popupAction = new QAction( dests[i], QString::null, 0, this, 0 ); popupAction->addTo( destsMenu ); if ( dests[i] == ad && activePackage->toInstall() ) { popupAction->setToggleAction( true ); popupAction->setOn(true); }; } connect( destsMenu, SIGNAL( activated( int ) ), this, SLOT( changePackageDest( int ) ) ); }else{ - popupAction = new QAction( QObject::tr("Remove"),QString::null, 0, this, 0 ); + popupAction = new QAction( tr("Remove"),QString::null, 0, this, 0 ); popupAction->addTo( popupMenu ); connect( popupAction, SIGNAL( activated() ), this , SLOT( toggleProcess() ) ); - popupAction = new QAction( QObject::tr("Reinstall"),QString::null, 0, this, 0 ); + popupAction = new QAction( tr("Reinstall"),QString::null, 0, this, 0 ); popupAction->addTo( popupMenu ); popupAction->setEnabled( false ); } popupMenu->popup( QCursor::pos() ); } void PackageListView::stopTimer( QListViewItem* ) { popupTimer->stop(); } void PackageListView::changePackageDest( int i ) { activePackage->setDest( destsMenu->text(i) ); activePackage->setOn(); activePackage->setLink( settings->createLinks() ); activePackageListItem->displayDetails(); } void PackageListView::toggleProcess() { activePackage->toggleProcess() ; activePackageListItem->displayDetails(); diff --git a/noncore/unsupported/oipkg/pksettings.cpp b/noncore/unsupported/oipkg/pksettings.cpp index 09975b0..59d5a3e 100644 --- a/noncore/unsupported/oipkg/pksettings.cpp +++ b/noncore/unsupported/oipkg/pksettings.cpp @@ -220,48 +220,49 @@ void PackageManagerSettings::writeIpkgConfig(const QString& conffile) QFile conf(conffile); if ( ! conf.open(IO_WriteOnly) ) return; QTextStream s(&conf); s << "# Written by qpie Package Manager\n"; for (int i=0; i<(int)activeServers->count(); i++) { QString url = serverurlDic[i] ? *serverurlDic[i] : QString("???"); if ( !activeServers->isSelected(i) ) s << "#"; s << "src " << activeServers->text(i) << " " << url << "\n"; } for (int i=0; i<(int)destinations->count(); i++) { QString url = destinationurlDic[i] ? *destinationurlDic[i] : QString("???"); s << "dest " << destinations->text(i) << " " << url << "\n"; } conf.close(); } void PackageManagerSettings::readInstallationSettings() { Config cfg( "oipkg", Config::User ); cfg.setGroup( "Settings" ); + installationSettingsCount = cfg.readNumEntry( "count", -1 ); currentSetting = cfg.readNumEntry( "current", 0 );// o should be -1 for (int i = 0; i < installationSettingsCount; i++) { cfg.setGroup( "Setting_" + QString::number(i) ); settingName->insertItem( cfg.readEntry( "name", "???" ), i ); }; readInstallationSetting( currentSetting ); } /** * remove from conf file */ void PackageManagerSettings::removeInstallationSetting() { settingName->removeItem( settingName->currentItem() ); Config cfg( "oipkg", Config::User ); cfg.setGroup( "Setting_" + QString::number( installationSettingsCount ) ); cfg.clearGroup(); installationSettingsCount--; changed = true; diff --git a/noncore/unsupported/oipkg/pksettings.h b/noncore/unsupported/oipkg/pksettings.h index dcc1e3a..8f9fe62 100644 --- a/noncore/unsupported/oipkg/pksettings.h +++ b/noncore/unsupported/oipkg/pksettings.h @@ -1,36 +1,36 @@ #ifndef PACKAGEMANAGERSETTINGS_H #define PACKAGEMANAGERSETTINGS_H #include "pksettingsbase.h" //#include "pmipkg.h" #include <qintdict.h> #include <qobject.h> class PackageManagerSettings : public PackageManagerSettingsBase { -// Q_OBJECT + Q_OBJECT public: PackageManagerSettings( QWidget* , const char* , WFlags ); ~PackageManagerSettings(); bool showDialog( int ) ; QString getDestinationUrl(); QString getDestinationName(); QString getLinkDestinationName(); bool createLinks(); QStringList getServers(); QStringList getActiveServers(); QStringList getDestinationUrls(); QStringList getDestinationNames(); QString getDestinationUrlByName(QString); QComboBox* getDestCombo(); // void setIpkg( PmIpkg* ); public slots: void writeInstallationSettings(); void readInstallationSettings(); void writeCurrentInstallationSetting(); void readInstallationSetting(int); void installationSettingSetName(const QString &); void removeLinksToDest(); diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp index 7b3fa1e..2a534d2 100644 --- a/noncore/unsupported/oipkg/pmipkg.cpp +++ b/noncore/unsupported/oipkg/pmipkg.cpp @@ -1,126 +1,181 @@ #include "pmipkg.h" #include "pksettings.h" #include "package.h" #include "packagelistitem.h" -#include <qpe/process.h> +//#infdef OPROCESS +#include <opie/oprocess.h> +//#endif #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 ); +#ifdef OPROCESS + ipkgProcess = new OProcess(); + connect ( ipkgProcess, SIGNAL(receivedStdout(OProcess*,char*,int)), + this, SLOT(getIpkgOutput(OProcess*,char*,int))); + + connect ( ipkgProcess, SIGNAL(receivedStderr(OProcess*,char*,int)), + this, SLOT(getIpkgOutput(OProcess*,char*,int))); + installDialog = 0; +#endif } PmIpkg::~PmIpkg() { +#ifdef OPROCESS + delete ipkgProcess; +#endif } bool PmIpkg::runIpkg(const QString& args, const QString& dest ) { bool ret=false; QDir::setCurrent("/tmp"); QString cmd = "/usr/bin/ipkg "; +#ifdef OPROCESS + ipkgProcess->clearArguments(); + *ipkgProcess << "/usr/bin/ipkg "; + QString cmd = ""; +#endif pvDebug( 3,"PmIpkg::runIpkg got dest="+dest); if ( dest == "" ) cmd += " -dest "+settings->getDestinationName(); else cmd += " -dest "+ dest; cmd += " -force-defaults "; if (installDialog && 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); +#ifdef OPROCESS + *ipkgProcess << args; + out( "running:\n" + cmd); + *ipkgProcess << cmd; + +//debug + ipkgProcess->clearArguments(); + *ipkgProcess << "/bin/ls "; +//debug + QValueList<QCString> a = ipkgProcess->args(); + QValueList<QCString>::Iterator it; + for( it = a.begin(); it != a.end(); ++it ) + { + out( *it ); + cmd += *it; + } + + pvDebug(2,"running:"+cmd); + qApp->processEvents(); +// sleep(1); + ret = ipkgProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput); + if ( !ret ) { + pvDebug(2,"Could not execute '" + cmd); + out("\nError while executing "+ cmd+"\n\n"); + out("\nError while executing\n\n"); + // return false; + } + + while ( ipkgProcess->isRunning() ) + { + out("."); + pvDebug(7,"wait for oprocess to terminate"); + qApp->processEvents(); + }; +#else 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; qApp->processEvents(); } pclose(fp); } +#endif //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->installName(), pack->dest() ); + 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() ) { @@ -221,48 +276,49 @@ void PmIpkg::commit() installDialog->toRemoveItem->setOpen( true ); installDialog->toInstallItem->setOpen( true ); for (uint i=0; i < to_remove.count(); i++) { sizecount += 1; 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(); 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(); runwindow->showMaximized(); runwindow->show(); } installDialog->close(); delete installDialog; + installDialog = 0; 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)->installName(), to_remove.at(i)->dest() )) { @@ -375,24 +431,36 @@ void PmIpkg::installFile(const QString &fileName, const QString &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; } void PmIpkg::clearLists() { to_remove.clear(); to_install.clear(); } + + +void PmIpkg::getIpkgOutput(OProcess *proc, char *buffer, int buflen) +{ + QString lineStr, lineStrOld; + lineStr = buffer; + lineStr=lineStr.left(buflen); + //Configuring opie-oipkg...Done + if (lineStr!=lineStrOld) + out(lineStr); + lineStrOld = lineStr; +}
\ No newline at end of file diff --git a/noncore/unsupported/oipkg/pmipkg.h b/noncore/unsupported/oipkg/pmipkg.h index d53a74d..2c92348 100644 --- a/noncore/unsupported/oipkg/pmipkg.h +++ b/noncore/unsupported/oipkg/pmipkg.h @@ -1,65 +1,65 @@ #ifndef PMIPKG_H #define PMIPKG_H +#include <opie/oprocess.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(); /** No descriptions */ void clearLists(); 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 slots: + void getIpkgOutput(OProcess *proc, char *buffer, int buflen); + private: + OProcess *ipkgProcess; 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 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 diff --git a/noncore/unsupported/oipkg/settings.h b/noncore/unsupported/oipkg/settings.h index f01cb69..9cb7a9b 100644 --- a/noncore/unsupported/oipkg/settings.h +++ b/noncore/unsupported/oipkg/settings.h @@ -1,35 +1,35 @@ #ifndef PACKAGEMANAGERSETTINGS_H #define PACKAGEMANAGERSETTINGS_H #include "pksettingsbase.h" #include <qintdict.h> class PackageManagerSettings : public PackageManagerSettingsBase //class PackageManagerSettings : private PackageManagerSettingsBase { - // Q_OBJECT + Q_OBJECT public: PackageManagerSettings( QWidget* , const char* , WFlags ); ~PackageManagerSettings(); bool showDialog( int ) ; QString getDestinationUrl(); QString getDestinationName(); QString getLinkDestinationName(); bool createLinks(); QStringList getActiveServers(); QStringList getDestinationUrls(); public slots: /** No descriptions */ void createLinks(); void removeLinks(); void writeInstallationSettings(); void readInstallationSettings(); void writeCurrentInstallationSetting(); void readInstallationSetting(int); void installationSettingSetName(const QString &); void activeDestinationChange(int) void newServer(); void editServer(int); void removeDestination(); |