-rw-r--r-- | noncore/unsupported/oipkg/main.cpp | 7 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/mainwindow.cpp | 51 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/mainwindow.h | 6 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/oipkg.pro | 2 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/package.cpp | 6 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/package.h | 1 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/packagelistdoclnk.cpp | 36 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/packagelistdoclnk.h | 22 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/packagelistitem.cpp | 8 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/packagelistitem.h | 1 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/packagelistremote.cpp | 14 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/packagelistremote.h | 2 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/packagelistview.cpp | 3 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/pmipkg.cpp | 21 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/pmipkg.h | 4 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/settings.h | 9 |
16 files changed, 128 insertions, 65 deletions
diff --git a/noncore/unsupported/oipkg/main.cpp b/noncore/unsupported/oipkg/main.cpp index 5cef2dc..bacc973 100644 --- a/noncore/unsupported/oipkg/main.cpp +++ b/noncore/unsupported/oipkg/main.cpp @@ -1,22 +1,23 @@ #include "mainwindow.h" #include <qpe/qpeapplication.h> #include <qstring.h> #include <qmessagebox.h> int debugLevel; int main( int argc, char ** argv ) { debugLevel = 2; if (argc > 0) - { + { debugLevel = QString ( argv[1] ).toInt(); - } + } QPEApplication a( argc, argv ); MainWindow mw; - QMessageBox::information( &mw, "oipkg","While ipkg is working\noipkg is hanging.\nPlease be patient!"); + if (debugLevel < 4) + 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 0422d65..b668660 100644 --- a/noncore/unsupported/oipkg/mainwindow.cpp +++ b/noncore/unsupported/oipkg/mainwindow.cpp @@ -1,495 +1,484 @@ // adadpted form qpe/qipkg #include "mainwindow.h" #include <qpe/qpemenubar.h> #include <qpe/qpemessagebox.h> #include <qpe/resource.h> #include <qpe/config.h> #include <qpe/qpetoolbar.h> #include <qpe/qcopenvelope_qws.h> #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 ) { setCaption( tr("Package Manager") ); settings = new PackageManagerSettings(this,0,TRUE); listViewPackages = new PackageListView( this,"listViewPackages",settings ); setCentralWidget( listViewPackages ); - listViewPackages->addList( tr("local"), &packageList ); + listViewPackages->addList( tr("feeds"), &packageListServers ); listViewPackages->addList( tr("ipkgfind"), &packageListSearch ); + listViewPackages->addList( tr("documents"), &packageListDocLnk ); // wait = new QMessageBox(tr("oipkg"),tr("Please wait")//,QMessageBox::Information,QMessageBox::NoButton,QMessageBox::NoButton,QMessageBox::NoButton); // wait = new QMessageBox(this); // wait->setText(tr("Please wait")); ipkg = new PmIpkg( settings, this ); // settings->setIpkg( ipkg ); - packageList.setSettings( settings ); + packageListServers.setSettings( settings ); packageListSearch.setSettings( settings ); - packageList.update(); + packageListDocLnk.setSettings( settings ); + packageListServers.update(); + packageListDocLnk.update(); makeMenu(); makeChannel(); //opie is hardcoded default ;) for (int i=0;i<section->count();i++) if (section->text(i)=="opie") section->setCurrentItem(i); sectionChanged(); connect( section, SIGNAL(activated(int)), SLOT(sectionChanged()) ); connect( subsection, SIGNAL(activated(int)), SLOT(subSectionChanged()) ); connect( settings->removeLinksButton, SIGNAL( clicked()), SLOT(removeLinks()) ); connect( settings->createLinksButton, SIGNAL( clicked()), SLOT(createLinks()) ); displayList(); } void MainWindow::makeMenu() { QPEToolBar *toolBar = new QPEToolBar( this ); QPEMenuBar *menuBar = new QPEMenuBar( toolBar ); QPopupMenu *srvMenu = new QPopupMenu( menuBar ); QPopupMenu *viewMenu = new QPopupMenu( menuBar ); QPopupMenu *cfgMenu = new QPopupMenu( menuBar ); // QPopupMenu *sectMenu = new QPopupMenu( menuBar ); setToolBarsMovable( false ); toolBar->setHorizontalStretchable( true ); menuBar->insertItem( tr( "Package" ), srvMenu ); menuBar->insertItem( tr( "View" ), viewMenu ); menuBar->insertItem( tr( "Settings" ), cfgMenu ); // menuBar->insertItem( tr( "Sections" ), sectMenu ); QLabel *spacer = new QLabel( "", toolBar ); spacer->setBackgroundColor( toolBar->backgroundColor() ); toolBar->setStretchableWidget( spacer ); runAction = new QAction( tr( "Apply" ), Resource::loadPixmap( "oipkg/install" ), QString::null, 0, this, 0 ); connect( runAction, SIGNAL( activated() ), this, SLOT( runIpkg() ) ); runAction->addTo( toolBar ); runAction->addTo( srvMenu ); srvMenu->insertSeparator (); updateAction = new QAction( tr( "Update" ), Resource::loadIconSet( "oipkg/update" ), QString::null, 0, this, 0 ); connect( updateAction, SIGNAL( activated() ), this , SLOT( updateList() ) ); updateAction->addTo( toolBar ); updateAction->addTo( srvMenu ); QAction *cfgact; cfgact = new QAction( tr( "Setups" ), QString::null, 0, this, 0 ); connect( cfgact, SIGNAL( activated() ), SLOT( showSettings() ) ); cfgact->addTo( cfgMenu ); cfgact = new QAction( tr( "Servers" ), QString::null, 0, this, 0 ); connect( cfgact, SIGNAL( activated() ), SLOT( showSettingsSrv() ) ); cfgact->addTo( cfgMenu ); cfgact = new QAction( tr( "Destinations" ), QString::null, 0, this, 0 ); connect( cfgact, SIGNAL( activated() ), SLOT( showSettingsDst() ) ); cfgact->addTo( cfgMenu ); QAction *a; // SECTIONS sectionBar = new QPEToolBar( this ); addToolBar( sectionBar, "Section", QMainWindow::Top, TRUE ); sectionBar->setHorizontalStretchable( true ); QLabel *label = new QLabel( tr("Section: "), sectionBar ); label->setBackgroundColor( sectionBar->backgroundColor() ); sectionBar->setStretchableWidget( label ); section = new QComboBox( false, sectionBar ); label = new QLabel( " / ", sectionBar ); label->setBackgroundColor( sectionBar->backgroundColor() ); subsection = new QComboBox( false, sectionBar ); a = new QAction( tr( "Close Section" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( sectionClose() ) ); a->addTo( sectionBar ); setSections(); setSubSections(); sectionAction = new QAction( tr( "Sections" ), QString::null, 0, this, 0 ); connect( sectionAction, SIGNAL( toggled(bool) ), this, SLOT( sectionShow(bool) ) ); sectionAction->setToggleAction( true ); sectionAction->addTo( viewMenu ); //FIND findBar = new QPEToolBar(this); addToolBar( findBar, "Filter", QMainWindow::Top, TRUE ); label = new QLabel( tr("Filter: "), findBar ); label->setBackgroundColor( findBar->backgroundColor() ); findBar->setHorizontalStretchable( TRUE ); findEdit = new QLineEdit( findBar, "findEdit" ); findBar->setStretchableWidget( findEdit ); connect( findEdit, SIGNAL( textChanged( const QString & ) ), this, SLOT( displayList() ) ); a = new QAction( tr( "Clear Find" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), findEdit, SLOT( clear() ) ); a->addTo( findBar ); a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) ); a->addTo( findBar ); findAction = new QAction( tr( "Filter" ), QString::null, 0, this, 0 ); connect( findAction, SIGNAL( toggled(bool) ), this, SLOT( findShow(bool) ) ); findAction->setToggleAction( true ); findAction->addTo( viewMenu ); //SEARCH searchBar = new QPEToolBar(this); addToolBar( searchBar, "Search", QMainWindow::Top, TRUE ); label = new QLabel( tr("ipkgfind: "), searchBar ); label->setBackgroundColor( searchBar->backgroundColor() ); searchBar->setHorizontalStretchable( TRUE ); searchEdit = new QLineEdit( searchBar, "seachEdit" ); searchBar->setStretchableWidget( searchEdit ); // connect( searchEdit, SIGNAL( textChanged( const QString & ) ), // this, SLOT( displayList() ) ); a = new QAction( tr( "Clear Search" ), Resource::loadPixmap( "back" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), searchEdit, SLOT( clear() ) ); a->addTo( searchBar ); searchCommit = new QAction( tr( "Do Search" ), Resource::loadPixmap( "find" ), QString::null, 0, this, 0 ); connect( searchCommit, SIGNAL( activated() ), SLOT( remotePackageQuery() ) ); searchCommit->addTo( searchBar ); a = new QAction( tr( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), this, SLOT( searchClose() ) ); a->addTo( searchBar ); searchAction = new QAction( tr( "Search" ), QString::null, 0, this, 0 ); connect( searchAction, SIGNAL( toggled(bool) ), this, SLOT( searchShow(bool) ) ); searchAction->setToggleAction( true ); searchAction->addTo( viewMenu ); //DEST destBar = new QPEToolBar(this); addToolBar( destBar, "Destination", QMainWindow::Top, TRUE ); label = new QLabel( tr("Destination: "), destBar ); label->setBackgroundColor( destBar->backgroundColor() ); destBar->setHorizontalStretchable( TRUE ); destination = new QComboBox( false, destBar ); destination->insertStringList( settings->getDestinationNames() ); setComboName(destination,settings->getDestinationName()); connect( destination, SIGNAL(activated(int)), settings, SLOT(activeDestinationChange(int)) ); spacer = new QLabel( " ", destBar ); spacer->setBackgroundColor( destBar->backgroundColor() ); CheckBoxLink = new QCheckBox( tr("Link"), destBar); CheckBoxLink->setBackgroundColor( destBar->backgroundColor() ); CheckBoxLink->setChecked( settings->createLinks() ); connect( CheckBoxLink, SIGNAL(toggled(bool)), settings, SLOT(linkEnabled(bool)) ); destAction = new QAction( tr( "Destinations" ), QString::null, 0, this, 0 ); connect( destAction, SIGNAL( toggled(bool) ), SLOT( destShow(bool) ) ); a = new QAction( tr( "Close Destinations" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 ); connect( a, SIGNAL( activated() ), SLOT( destClose() ) ); a->addTo( destBar ); destBar->setStretchableWidget( CheckBoxLink ); destAction->setToggleAction( true ); // destAction->addTo( viewMenu ); // configure the menus Config cfg( "oipkg", Config::User ); cfg.setGroup( "gui" ); findShow( cfg.readBoolEntry( "findBar", true ) ); searchShow( cfg.readBoolEntry( "searchBar", true ) ); sectionShow( cfg.readBoolEntry( "sectionBar", true ) ); destShow( cfg.readBoolEntry( "destBar", false ) ); } MainWindow::~MainWindow() { Config cfg( "oipkg", Config::User ); cfg.setGroup( "gui" ); cfg.writeEntry( "findBar", !findBar->isHidden() ); cfg.writeEntry( "searchBar", !searchBar->isHidden() ); cfg.writeEntry( "sectionBar", !sectionBar->isHidden() ); cfg.writeEntry( "destBar", !destBar->isHidden() ); } void MainWindow::runIpkg() { - packageList.allPackages(); + packageListServers.allPackages(); ipkg->loadList( packageListSearch ); - ipkg->commit( packageList ); + ipkg->loadList( packageListDocLnk ); + ipkg->commit( packageListServers ); // ##### If we looked in the list of files, we could send out accurate // ##### messages. But we don't bother yet, and just do an "all". QCopEnvelope e("QPE/System", "linkChanged(QString)"); QString lf = QString::null; e << lf; displayList(); } void MainWindow::updateList() { // wait->show(); QTimer *t = new QTimer( this ); connect( t, SIGNAL(timeout()), SLOT( rotateUpdateIcon() ) ); t->start( 0, false ); - packageList.clear(); + packageListServers.clear(); + packageListSearch.clear(); + packageListDocLnk.clear(); ipkg->update(); - packageList.update(); + packageListServers.update(); + packageListSearch.update(); + packageListDocLnk.update(); t->stop(); // wait->hide(); } void MainWindow::filterList() { // wait->show(); QString f = ""; if ( findAction->isOn() ) f = findEdit->text(); - packageList.filterPackages( f ); + packageListServers.filterPackages( f ); // wait->hide(); } void MainWindow::displayList() { // wait->hide(); filterList(); listViewPackages->display(); -//// if (!rootLocal) -//// { -// QCheckListItem *rootLocal = new QCheckListItem(listViewPackages,tr("local")); -// QCheckListItem *rootSearch = new QCheckListItem(listViewPackages,tr("ipkgfind")); -//// } -// listViewPackages->clear(); -// Package *pack = packageList.first(); -// PackageListItem *item; -// while( pack ) -// { -// item = new PackageListItem( rootLocal, pack, settings ); -// pack = packageList.next(); -// } -// pack = packageListSearch.first(); -// while( pack ) -// { -// item = new PackageListItem( rootSearch, pack, settings ); -// pack = packageListSearch.next(); -// } } void MainWindow::sectionChanged() { disconnect( section, SIGNAL( activated(int) ), this, SLOT( sectionChanged() ) ); disconnect( subsection, SIGNAL(activated(int) ), this, SLOT( subSectionChanged() ) ); subsection->clear(); - packageList.setSection( section->currentText() ); + packageListServers.setSection( section->currentText() ); setSubSections(); connect( section, SIGNAL( activated(int) ), this, SLOT( sectionChanged() ) ); connect( subsection, SIGNAL(activated(int) ), this, SLOT( subSectionChanged() ) ); displayList(); } void MainWindow::subSectionChanged() { disconnect( section, SIGNAL( activated(int) ), this, SLOT( sectionChanged() ) ); disconnect( subsection, SIGNAL(activated(int) ), this, SLOT( subSectionChanged() ) ); - packageList.setSubSection( subsection->currentText() ); + packageListServers.setSubSection( subsection->currentText() ); connect( section, SIGNAL( activated(int) ), this, SLOT( sectionChanged() ) ); connect( subsection, SIGNAL(activated(int) ), this, SLOT( subSectionChanged() ) ); displayList(); } void MainWindow::setSections() { section->clear(); - section->insertStringList( packageList.getSections() ); + section->insertStringList( packageListServers.getSections() ); } void MainWindow::setSubSections() { subsection->clear(); - subsection->insertStringList( packageList.getSubSections() ); + subsection->insertStringList( packageListServers.getSubSections() ); } void MainWindow::showSettings() { if ( settings->showDialog( 0 ) ) updateList(); } void MainWindow::showSettingsSrv() { if ( settings->showDialog( 1 ) ) updateList(); } void MainWindow::showSettingsDst() { if ( settings->showDialog( 2 ) ) updateList(); } void MainWindow::sectionShow(bool b) { if (b) sectionBar->show(); else sectionBar->hide(); sectionAction->setOn( b ); } void MainWindow::sectionClose() { sectionAction->setOn( false ); } void MainWindow::findShow(bool b) { if (b) findBar->show(); else findBar->hide(); findAction->setOn( b ); } void MainWindow::findClose() { findAction->setOn( false ); } void MainWindow::searchShow(bool b) { if (b) searchBar->show(); else searchBar->hide(); searchAction->setOn( b ); } void MainWindow::searchClose() { searchAction->setOn( false ); } void MainWindow::destShow(bool b) { if (b) destBar->show(); else destBar->hide(); destAction->setOn( b ); } void MainWindow::destClose() { destAction->setOn( false ); } void MainWindow::rotateUpdateIcon() { pvDebug(2, "MainWindow::rotateUpdateIcon"); if ( updateIcon ) updateAction->setIconSet( Resource::loadIconSet( "oipkg/update" ) ); else updateAction->setIconSet( Resource::loadIconSet( "oipkg/update2" ) ); updateIcon = !updateIcon; } void MainWindow::setDocument(const QString &fileName) { installFile(fileName); // ##### If we looked in the list of files, we could send out accurate // ##### messages. But we don't bother yet, and just do an "all". QCopEnvelope e("QPE/System", "linkChanged(QString)"); QString lf = QString::null; e << lf; displayList(); } void MainWindow::installFile(const QString &fileName) { pvDebug(3, "MainWindow::installFile "+fileName); if ( !QFile::exists( fileName ) ) return; ipkg->installFile( fileName ); // ##### If we looked in the list of files, we could send out accurate // ##### messages. But we don't bother yet, and just do an "all". QCopEnvelope e("QPE/System", "linkChanged(QString)"); QString lf = QString::null; e << lf; displayList(); } void MainWindow::makeChannel() { channel = new QCopChannel( "QPE/Application/oipkg", this ); connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), this, SLOT(receive(const QCString&, const QByteArray&)) ); } void MainWindow::receive(const QCString &msg, const QByteArray &arg) { pvDebug(3, "QCop "+msg+" "+QCString(arg)); if ( msg == "installFile(QString)" ) { ipkg->installFile( QString(arg) ); }else if( msg == "removeFile(QString)" ) { ipkg->removeFile( QString(arg) ); }else if( msg == "createLinks(QString)" ) { ipkg->createLinks( QString(arg) ); }else if( msg == "removeLinks(QString)" ) { ipkg->removeLinks( QString(arg) ); }else{ pvDebug(2,"Huh what do ya want") } } void MainWindow::createLinks() { pvDebug(2,"creating links..."); ipkg->createLinks( settings->destinationurl->text() ); } void MainWindow::removeLinks() { pvDebug(2,"removing links..."); ipkg->removeLinks( settings->destinationurl->text() ); } void MainWindow::remotePackageQuery() { packageListSearch.query( searchEdit->text() ); displayList(); } diff --git a/noncore/unsupported/oipkg/mainwindow.h b/noncore/unsupported/oipkg/mainwindow.h index 4a73b78..f6023b0 100644 --- a/noncore/unsupported/oipkg/mainwindow.h +++ b/noncore/unsupported/oipkg/mainwindow.h @@ -1,98 +1,98 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <qmainwindow.h> #include <qaction.h> #include <qtimer.h> #include <qpopupmenu.h> #include "packagelist.h" #include "packagelistremote.h" #include "packagelistlocal.h" +#include "packagelistdoclnk.h" #include "pmipkg.h" #include "pksettings.h" #include "packagelistview.h" class QComboBox; class QPEToolBar; class QLineEdit; class PackageListItem; class QCopChannel; class QMessageBox; class QCheckBox; class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); ~MainWindow(); void makeChannel(); QCopChannel *channel; protected slots: void runIpkg(); void updateList(); void displayList(); void subSectionChanged(); void sectionChanged(); void showSettings(); void showSettingsSrv(); void showSettingsDst(); public slots: void sectionClose(); void sectionShow(bool); void findClose(); void findShow(bool); void searchClose(); void searchShow(bool); void destClose(); void destShow(bool); void filterList(); void createLinks(); void removeLinks(); void receive (const QCString &, const QByteArray &); void setDocument (const QString &); void remotePackageQuery(); private: void makeMenu(); void setSections(); void setSubSections(); void installFile(const QString &); bool updateIcon; PmIpkg* ipkg; PackageManagerSettings *settings; - PackageListLocal packageList; + PackageListLocal packageListServers; PackageListRemote packageListSearch; + PackageListDocLnk packageListDocLnk; PackageListView *listViewPackages; -// QCheckListItem* rootSearch; -// QCheckListItem* rootLocal; QAction *runAction; QAction *updateAction; QAction *findAction; QPEToolBar *findBar; QLineEdit *findEdit; QAction *searchAction; QAction *searchCommit; QPEToolBar *searchBar; QLineEdit *searchEdit; QAction *sectionAction; QPEToolBar *sectionBar; QComboBox *section; QComboBox *subsection; QAction *destAction; QPEToolBar *destBar; QComboBox *destination; QCheckBox* CheckBoxLink; // QMessageBox *wait; private slots: void rotateUpdateIcon(); }; #endif diff --git a/noncore/unsupported/oipkg/oipkg.pro b/noncore/unsupported/oipkg/oipkg.pro index 98f92c8..6ee1963 100644 --- a/noncore/unsupported/oipkg/oipkg.pro +++ b/noncore/unsupported/oipkg/oipkg.pro @@ -1,32 +1,34 @@ DESTDIR = $(OPIEDIR)/bin TEMPLATE = app #CONFIG = qt warn_on release CONFIG = qt warn_on debug HEADERS = mainwindow.h \ pksettings.h \ pmipkg.h \ + packagelistdoclnk.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 \ packagelistremote.cpp \ packagelistlocal.cpp \ pksettings.cpp \ pmipkg.cpp \ packagelistitem.cpp \ packagelist.cpp \ package.cpp INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/ioclude LIBS += -lqpe INTERFACES = runwindow.ui \ pksettingsbase.ui TARGET = oipkg diff --git a/noncore/unsupported/oipkg/package.cpp b/noncore/unsupported/oipkg/package.cpp index f992641..9280d89 100644 --- a/noncore/unsupported/oipkg/package.cpp +++ b/noncore/unsupported/oipkg/package.cpp @@ -1,368 +1,372 @@ #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( PackageManagerSettings *s ) { init(s); } void Package::init( PackageManagerSettings *s ) { settings = s; _size = ""; _section = ""; _subsection = ""; _shortDesc = ""; _desc = ""; _name = ""; _toProcess = false; _useFileName = false; _status = ""; _dest = settings->getDestinationName(); _link = settings->createLinks(); } Package::Package( QStringList pack, PackageManagerSettings *s ) { init(s); parsePackage( pack ); } Package::Package( QString n, PackageManagerSettings *s ) { init(s); if ( !QFile::exists( n ) ) { _name = QString( n ); }else{ parseIpkgFile( n ); - _toProcess = true; _useFileName = true; _fileName = QString( n ); } } Package::Package( Package *pi ) { 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") // { }else if ( n == "Version") { _version = t; // }else if ( n == "Pre-Depends") // { // // }else if ( n == "Depends") // { }else if ( n == "Filename") { _fileName = t; // }else if ( n == "Size") // { // // }else if ( n == "MD5Sum") // { }else if ( n == "Description") { setDesc( t ); }else if ( n == "Status") { if ( installed() ) return; _status = t; // }else if ( n == "Essential") // { }else{ _values.insert(n,new QString(t)); } } QString Package::name() { if (_displayName.isEmpty() ) return _name; else return _displayName; } QString Package::installName() { if (_useFileName) return _fileName; else return _name; } bool Package::installed() { return _status.contains("installed"); } void Package::setDesc( QString s ) { _desc = s; _shortDesc = s.left( s.find("\n") ); } QString Package::desc() { return _desc; } QString Package::shortDesc() { return _shortDesc; } QString Package::size() { return _size; } QString Package::version() { return _version; } QString Package::sizeUnits() { int i = _size.toInt(); int c = 0; QString ret; QStringList unit; unit << "B" << "KB" << "MB" << "GB" << "TB"; //prepair for the future ;) while (i > 1) { ret=QString::number(i)+" "+unit[c]; c++; i /= 1024; } return ret; } bool Package::toProcess() { return _toProcess; } bool Package::toRemove() { if ( _toProcess && installed() ) return true; else return false; } bool Package::toInstall() { if ( _toProcess && !installed() ) return true; else return false; } void Package::toggleProcess() { _toProcess = ! _toProcess; } void Package::copyValues( Package* pack ) { if (_size.isEmpty() && !pack->_size.isEmpty()) _size = QString( pack->_size ); if (_section.isEmpty() && !pack->_section.isEmpty()) _section = QString( pack->_section ); if (_subsection.isEmpty()&& !pack->_subsection.isEmpty()) _subsection = QString( pack->_subsection ); if (_shortDesc.isEmpty() && !pack->_shortDesc.isEmpty()) _shortDesc = QString( pack->_shortDesc ); if (_desc.isEmpty() && !pack->_desc.isEmpty()) _desc = QString( pack->_desc ); if (_name.isEmpty() && !pack->_name.isEmpty()) _name = QString( pack->_name ); if (!installed() && _status.isEmpty() && !pack->_status.isEmpty()) _status = QString( pack->_status ); } QString Package::section() { return _section; } void Package::setSection( QString s) { int i = s.find("/"); if ( i > 0 ) { _section = s.left(i); _subsection = s.mid(i+1); }else{ _section = s; _subsection = ""; } } QString Package::subSection() { return _subsection; } void Package::parsePackage( QStringList pack ) { if ( pack.isEmpty() ) return; int count = pack.count(); for( int i = 0; i < count; i++ ) { QString line = pack[i]; int sep = line.find( QRegExp(":[\t ]+") ); if ( sep >= 0 ) { QString tag = line.left(sep); QString value = line.mid(sep+2).simplifyWhiteSpace(); setValue( tag, value ); }else{ } } return; } QString Package::details() { QString status; Process ipkg_status(QStringList() << "ipkg" << "info" << name() ); QString description; if ( ipkg_status.exec("",status) ) { QStringList lines = QStringList::split('\n',status,TRUE); for (QStringList::Iterator it = lines.begin(); it!=lines.end(); ++it) { QString line = *it; if ( line == " ." ) { description.append("<p>"); } else if ( line[0] == ' ' || line[0] == '\t' ) { // continuation description.append(" "); description.append(Qtopia::escapeString(line)); } else { int sep = line.find(QRegExp(":[\t ]+")); if ( sep >= 0 ) { QString tag = line.left(sep); description.append("<br>"); description.append("<b>"); description.append(Qtopia::escapeString(tag)); description.append(":</b> "); description.append(Qtopia::escapeString(line.mid(sep+2))); } else { description.append(" "); description.append(Qtopia::escapeString(line)); } } } } return description; } void Package::processed() { _toProcess = false; //hack, but we're not writing status anyway... if ( installed() ) _status = "install"; else _status = "installed"; } QString Package::dest() { if ( installed()||(!installed() && _toProcess) ) return _dest!=""?_dest:settings->getDestinationName(); else return ""; } void Package::setDest( QString d ) { _dest = d; } void Package::setOn() { _toProcess = true; } bool Package::link() { if ( _dest == "root" || (!installed() && !_toProcess) ) return false; return _link; } void Package::setLink(bool b) { _link = b; } void Package::parseIpkgFile( QString file) { system("tar xzf "+file+" -C /tmp"); system("tar xzf /tmp/control.tar.gz -C /tmp"); QFile f("/tmp/control"); if ( f.open(IO_ReadOnly) ) { QTextStream t( &f ); QStringList pack; while ( !t.eof() ) { pack << t.readLine(); } f.close(); parsePackage( pack ); } } //QString Package::getPackageName() //{ // if ( _packageName.isEmpty() ) return _name; // else return _packageName; //} void Package::instalFromFile(bool iff) { _useFileName = iff; } void Package::setName(QString n) { _displayName = n; } QDict<QString>* Package::getFields() { return &_values; } + +QString Package::status() +{ + return _status; +} diff --git a/noncore/unsupported/oipkg/package.h b/noncore/unsupported/oipkg/package.h index fc725bc..257d9c7 100644 --- a/noncore/unsupported/oipkg/package.h +++ b/noncore/unsupported/oipkg/package.h @@ -1,78 +1,79 @@ #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 { // Q_OBJECT public: Package(PackageManagerSettings *); // ~Package(); Package( QStringList, PackageManagerSettings * ); Package( QString, PackageManagerSettings * ); Package( Package* ); void setValue( QString, QString ); void copyValues( Package* ); QString name() ; QString installName() ; bool installed(); 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(); void setDest( QString d ); void setOn(); bool link(); void setLink(bool); void parseIpkgFile( QString ); void instalFromFile(bool iff=true); void setName(QString); QDict<QString>* getFields(); + QString status(); public slots: void toggleProcess(); private: PackageManagerSettings *settings; QString _displayName; QString _name; QString _fileName; bool _toProcess; bool _link; QString _status; QString _size; QString _section; QString _subsection; QString _shortDesc; QString _desc; QString _version; QString _dest; QDict<QString> _values; bool _useFileName; void parsePackage( QStringList ); void init(PackageManagerSettings *); }; #endif diff --git a/noncore/unsupported/oipkg/packagelistdoclnk.cpp b/noncore/unsupported/oipkg/packagelistdoclnk.cpp new file mode 100644 index 0000000..575ac62 --- a/dev/null +++ b/noncore/unsupported/oipkg/packagelistdoclnk.cpp @@ -0,0 +1,36 @@ + +#include "packagelistdoclnk.h" + +#include <qpe/applnk.h> +#include <qlist.h> + +#include "package.h" +#include "pksettings.h" + +PackageListDocLnk::PackageListDocLnk(PackageManagerSettings* s) + : PackageList(s) +{ + PackageListDocLnk(); +} + +PackageListDocLnk::PackageListDocLnk() + : PackageList() +{ + doclnkset = new DocLnkSet("/mnt/nfs/ipk","application/ipkg"); +} + +PackageListDocLnk::~PackageListDocLnk() +{ +} + + + +void PackageListDocLnk::update() +{ + pvDebug(2,"PackageListDocLnk::update "); + QList<DocLnk> packlist = doclnkset->children(); + for (DocLnk *pack =packlist.first(); pack != 0; pack=packlist.next() ) + { + insertPackage( new Package(pack->file(), settings) ); + } +} diff --git a/noncore/unsupported/oipkg/packagelistdoclnk.h b/noncore/unsupported/oipkg/packagelistdoclnk.h new file mode 100644 index 0000000..3864ace --- a/dev/null +++ b/noncore/unsupported/oipkg/packagelistdoclnk.h @@ -0,0 +1,22 @@ +#ifndef PACKAGELISTDOCLNK_H +#define PACKAGELISTDOCLNK_H + +#include "packagelist.h" +#include "debug.h" + +class DocLnkSet; + +class PackageListDocLnk : public PackageList +{ +public: + PackageListDocLnk(); + PackageListDocLnk( PackageManagerSettings* s); + virtual ~PackageListDocLnk(); +public slots: + void update(); +private: + DocLnkSet *doclnkset; +}; + + +#endif diff --git a/noncore/unsupported/oipkg/packagelistitem.cpp b/noncore/unsupported/oipkg/packagelistitem.cpp index 2f81714..45aaf1d 100644 --- a/noncore/unsupported/oipkg/packagelistitem.cpp +++ b/noncore/unsupported/oipkg/packagelistitem.cpp @@ -1,140 +1,144 @@ #include "packagelistitem.h" #include <qpe/resource.h> #include <qobject.h> #include "debug.h" static QPixmap *pm_uninstalled=0; static QPixmap *pm_installed=0; static QPixmap *pm_uninstall=0; static QPixmap *pm_install=0; PackageListItem::PackageListItem(QListView* lv, Package *pi, PackageManagerSettings *s) : QCheckListItem(lv,pi->name(),CheckBox) { init(pi,s); } PackageListItem::PackageListItem(QListViewItem *lvi, Package *pi, PackageManagerSettings *s) : QCheckListItem(lvi,pi->name(),CheckBox) { init(pi,s); } void PackageListItem::init( Package *pi, PackageManagerSettings *s) { package = pi; settings = s; setExpandable( true ); QCheckListItem *item; nameItem = new QCheckListItem( this, "" ); item = new QCheckListItem( this, QObject::tr("Size: ")+pi->size() ); destItem = new QCheckListItem( this, "" ); linkItem = new QCheckListItem( this, "" ); + statusItem = new QCheckListItem( this, "" ); QCheckListItem *otherItem = new QCheckListItem( this, QObject::tr("other") ); item = new QCheckListItem( otherItem, QObject::tr("Description: ")+pi->desc() ); QDict<QString> *fields = pi->getFields(); QDictIterator<QString> it( *fields ); while ( it.current() ) { item = new QCheckListItem( otherItem, QString(it.currentKey()+": "+*it.current()) ); ++it; } displayDetails(); if (!pm_uninstalled) { pm_uninstalled = new QPixmap(Resource::loadPixmap("oipkg/uninstalled")); pm_installed = new QPixmap(Resource::loadPixmap("oipkg/installed")); pm_install = new QPixmap(Resource::loadPixmap("oipkg/install")); pm_uninstall = new QPixmap(Resource::loadPixmap("oipkg/uninstall")); } } void PackageListItem::paintCell( QPainter *p, const QColorGroup & cg, int column, int width, int alignment ) { if ( !p ) return; p->fillRect( 0, 0, width, height(), isSelected()? cg.highlight() : cg.base() ); if ( column != 0 ) { // The rest is text QListViewItem::paintCell( p, cg, column, width, alignment ); return; } QListView *lv = listView(); if ( !lv ) return; int marg = lv->itemMargin(); int r = marg; QPixmap pm = statePixmap(); p->drawPixmap(marg,(height()-pm.height())/2,pm); r += pm.width()+1; p->translate( r, 0 ); QListViewItem::paintCell( p, cg, column, width - r, alignment ); } void PackageListItem::paintFocus( QPainter *p, const QColorGroup & cg, const QRect & r ) { // Skip QCheckListItem // (makes you wonder what we're getting from QCheckListItem) QListViewItem::paintFocus(p,cg,r); } QPixmap PackageListItem::statePixmap() const { bool installed = package->installed(); if ( !package->toProcess() ) { if ( !installed ) return *pm_uninstalled; else return *pm_installed; } else { if ( !installed ) return *pm_install; else return *pm_uninstall; } } QString PackageListItem::key( int column, bool ascending ) const { if ( column == 2 ) { QString t = text(2); double bytes=t.toDouble(); if ( t.contains('M') ) bytes*=1024*1024; else if ( t.contains('K') || t.contains('k') ) bytes*=1024; 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 = " ("+package->sizeUnits(); + 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 = 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")) ); destItem->setText( 0, QObject::tr("Destination: ")+package->dest() ); + statusItem->setText( 0, QObject::tr("Status: ")+package->status() ); repaint(); } diff --git a/noncore/unsupported/oipkg/packagelistitem.h b/noncore/unsupported/oipkg/packagelistitem.h index b128f0d..65e9711 100644 --- a/noncore/unsupported/oipkg/packagelistitem.h +++ b/noncore/unsupported/oipkg/packagelistitem.h @@ -1,40 +1,41 @@ #ifndef PK_LISTITEM_H #define PK_LISTITEM_H #include "package.h" #include <qstring.h> #include <qlistview.h> #include <qpainter.h> #include <qpixmap.h> #include <qdict.h> #include "pksettings.h" class PackageListItem : public QCheckListItem { public: PackageListItem(QListViewItem*, Package*, PackageManagerSettings*); PackageListItem(QListView*, Package*, PackageManagerSettings*); void paintCell( QPainter*, const QColorGroup&, int, int, int ); void paintFocus( QPainter*, const QColorGroup&, const QRect& ); QPixmap statePixmap() const; QString key( int, bool ) const; Package* getPackage() { return package; } ; QString getName() { return package->name(); } ; bool isInstalled(){ return package->installed(); }; virtual void setOn ( bool ); void displayDetails(); private: void init(Package*, PackageManagerSettings*); QCheckListItem *nameItem; QCheckListItem *destItem; QCheckListItem *linkItem; + QCheckListItem *statusItem; PackageManagerSettings *settings; Package *package; }; #endif diff --git a/noncore/unsupported/oipkg/packagelistremote.cpp b/noncore/unsupported/oipkg/packagelistremote.cpp index 721d4a6..1ec7292 100644 --- a/noncore/unsupported/oipkg/packagelistremote.cpp +++ b/noncore/unsupported/oipkg/packagelistremote.cpp @@ -1,47 +1,47 @@ #include "packagelistremote.h" #include <qstring.h> #include <stdlib.h> #include <unistd.h> PackageListRemote::PackageListRemote(PackageManagerSettings* s) : PackageList(s) { PackageListRemote(); } PackageListRemote::PackageListRemote() : PackageList() { } PackageListRemote::~PackageListRemote() { } void PackageListRemote::query(QString s) { + searchString = s; +} + +void PackageListRemote::update() +{ + pvDebug(2,"PackageListRemote::update"); int r=0; QString cmd = "wget"; QString redirect = "/tmp/oipkg.query"; // use file for output cmd += " --output-document="+redirect; //http://ipkgfind.handhelds.org/packages.phtml?format=pda&query=ipkg&searchtype=package§ion= QString server="http://ipkgfind.handhelds.org/"; cmd += " \""+server+"/packages.phtml"; cmd += "?format=pda&searchtype=package§ion="; - cmd += "&query="+s; + cmd += "&query="+searchString; cmd += "\""; pvDebug(2,"search :"+cmd); r = system(cmd.latin1()); readFileEntries( redirect ); - -} - -void PackageListRemote::update() -{ - pvDebug(2,"PackageListRemote::update\ndoing nothing "); } diff --git a/noncore/unsupported/oipkg/packagelistremote.h b/noncore/unsupported/oipkg/packagelistremote.h index 147da1e..87bf10d 100644 --- a/noncore/unsupported/oipkg/packagelistremote.h +++ b/noncore/unsupported/oipkg/packagelistremote.h @@ -1,19 +1,21 @@ #ifndef PACKAGELISTREMOTE_H #define PACKAGELISTREMOTE_H #include "packagelist.h" #include "package.h" #include "pksettings.h" #include "debug.h" class PackageListRemote : public PackageList { public: PackageListRemote(); PackageListRemote( PackageManagerSettings* s); virtual ~PackageListRemote(); void query(QString); public slots: void update(); +private: + QString searchString; }; #endif diff --git a/noncore/unsupported/oipkg/packagelistview.cpp b/noncore/unsupported/oipkg/packagelistview.cpp index 5137c64..b6b520b 100644 --- a/noncore/unsupported/oipkg/packagelistview.cpp +++ b/noncore/unsupported/oipkg/packagelistview.cpp @@ -1,132 +1,133 @@ #include "packagelistview.h" #include <qpopupmenu.h> #include <qaction.h> #include "packagelistitem.h" #include "pksettings.h" PackageListView::PackageListView(QWidget *p, const char* n, PackageManagerSettings *s) : QListView(p,n) { settings = s; popupMenu = new QPopupMenu( this ); destsMenu = new QPopupMenu( popupMenu ); popupTimer = new QTimer( this ); setSelectionMode(QListView::NoSelection); addColumn( tr("Package") ); setRootIsDecorated( true ); connect( popupTimer, SIGNAL(timeout()), this, SLOT(showPopup()) ); connect( this, SIGNAL( pressed( QListViewItem* ) ), this, SLOT( setCurrent( QListViewItem* ) ) ); connect( this, SIGNAL( clicked( QListViewItem* ) ), this, SLOT( stopTimer( QListViewItem* ) ) ); } //PackageListView::~PackageListView() //{ //} void PackageListView::setCurrent( QListViewItem* p ) { if ( !p ) return; activePackageListItem = (PackageListItem*)p; activePackage = activePackageListItem->getPackage(); if (!activePackage) return; popupTimer->start( 750, true ); } void PackageListView::showPopup() { popupMenu->clear(); destsMenu->clear(); QAction *popupAction; if ( !activePackage->installed() ) { popupMenu->insertItem( QObject::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->addTo( popupMenu ); connect( popupAction, SIGNAL( activated() ), this , SLOT( toggleProcess() ) ); popupAction = new QAction( QObject::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(); } void PackageListView::display() { QDictIterator<PackageList> list( PackageLists ); PackageList *packlist; Package *pack; PackageListItem *item; QCheckListItem *rootItem; QListViewItem* it; QListViewItem* itdel; while ( list.current() ) { packlist = list.current(); rootItem = rootItems.find( list.currentKey() ); //rootItem->clear(); it=rootItem->firstChild(); while ( it ) { itdel = it; it = it->nextSibling(); delete itdel; } pack = packlist->first(); while( pack ) { item = new PackageListItem( rootItem, pack, settings ); pack = packlist->next(); } ++list; } } void PackageListView::addList( QString n, PackageList* pl) { PackageLists.insert(n, pl); - rootItems.insert(n, new QCheckListItem(this,n)); + QCheckListItem *item = new QCheckListItem(this,n); + rootItems.insert(n, item); } diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp index 2559a51..be9d6da 100644 --- a/noncore/unsupported/oipkg/pmipkg.cpp +++ b/noncore/unsupported/oipkg/pmipkg.cpp @@ -1,448 +1,449 @@ #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 <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; - runwindowopen = false; runwindow = new RunWindow( p, name, true, f ); } PmIpkg::~PmIpkg() { } //#define PROC #define SYSTEM int PmIpkg::runIpkg(const QString& args, const QString& dest ) { pvDebug(2,"PmIpkg::runIpkg "+args); #ifdef PROC QStringList cmd = "/usr/bin/ipkg "; #endif #ifdef SYSTEM QString cmd = "/usr/bin/ipkg "; #endif pvDebug( 3,"PmIpkg::runIpkg got dest="+dest); if ( dest == "" ) cmd += " -dest "+settings->getDestinationName(); else cmd += " -dest "+ dest; cmd += " -force-defaults "; if (_force_depends) { if (_force_depends->isChecked()) cmd += " -force-depends "; if (_force_reinstall->isChecked()) cmd += " -force-reinstall "; if (_force_remove->isChecked()) cmd += " -force-removal-of-essential-packages "; } out( "<hr><br>Starting to "+ args+"<br>\n"); cmd += args; int r = 0; #ifdef PROC QString o = "start"; - Process *ipkg = new Process( "ls");//cmd ); + Process *ipkg = new Process( cmd ); out( "running:<br>\n"+ipkg->arguments().join(" ")+"<br>\n" ); QString description; ipkg->exec("",o); // out( o ); #endif #ifdef SYSTEM out( "running:<br>\n"+cmd+"<br>\n" ); QString redirect = "/tmp/oipkg.pipe"; cmd += " 2>&1 | tee "+redirect+" 2>&1"; pvDebug(2, "running >"+cmd+"<"); r = system(cmd.latin1()); QFile f( redirect ); QString line; QString oldLine; while ( ! f.open(IO_ReadOnly) ) {}; QTextStream t( &f ); while ( !t.eof() ) { line = t.readLine(); if ( line != oldLine ) { out( line +"<br>" ); oldLine = line; } } f.close(); out( "Finished!<br>"); #endif return r; } 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( "<b>Panik!</b> Could not open:<br>"+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( 7,"PmIpkg::processLinkDir "+file+" to "+ dest); - if (linkOpp==createLink) pvDebug( 2,"opp: createLink"); - if (linkOpp==removeLink) pvDebug( 2,"opp:removeLink"); + 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, "process dir "+fi->absFilePath()); processLinkDir( fi->absFilePath(), dest ); ++it; } // if (linkOpp==removeLink) // { // pvDebug(2,"remove destDir "+ destFile ); // destDir.remove( destFile, true ); // } } 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 ) { pvDebug(4,"removing "+destFile+" no "+file); QFileInfo toRemoveLink( destFile ); if ( !QFile::exists( file ) && toRemoveLink.isSymLink() ) 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( PackageList pl ) { - sizecount = 0; - QString rem="<b>"+tr("To remove:")+"</b><br>\n"; - QString inst="<b>"+tr("To install:")+"</b><br>\n"; + int sizecount = 0; +// QString rem="<b>"+tr("To remove:")+"</b><br>\n"; +// QString inst="<b>"+tr("To install:")+"</b><br>\n"; loadList(pl); for (uint i=0; i < to_remove.count(); i++) sizecount += 1; for (uint i=0; i < to_install.count(); i++) sizecount += to_install.at(i)->size().toInt(); + runwindow->progress->setTotalSteps(sizecount); startDialog(); } void PmIpkg::startDialog() { installDialog = new QDialog(0,0,true); QGridLayout *RunWindowLayout = new QGridLayout( installDialog ); RunWindowLayout->setSpacing( 2 ); RunWindowLayout->setMargin( 2 ); PackageListView *plv = new PackageListView(installDialog, "install",settings); plv->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding, plv->sizePolicy().mayShrinkVertically()) ); RunWindowLayout->addWidget( plv, 1, 0 ); QCheckListItem *toRemoveItem; toRemoveItem= new QCheckListItem( plv, QObject::tr("To remove") ); toRemoveItem->setOpen( true ); for (Package *it=to_remove.first(); it != 0; it=to_remove.next() ) { toRemoveItem->insertItem( new PackageListItem(plv, it,settings) ); } QCheckListItem *toInstallItem; toInstallItem = new QCheckListItem( plv, QObject::tr("To install") ); toInstallItem->setOpen( true ); for (Package *it=to_install.first(); it != 0; it=to_install.next() ) { toInstallItem->insertItem( new PackageListItem(plv, it,settings) ); } QGroupBox *GroupBox1 = new QGroupBox( installDialog, "Ipkg" ); GroupBox1->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)3, (QSizePolicy::SizeType)3, GroupBox1->sizePolicy().mayShrinkVertically() ) ); GroupBox1->setTitle( tr( "Ipkg options" ) ); GroupBox1->setColumnLayout(0, Qt::Vertical ); GroupBox1->layout()->setSpacing( 0 ); GroupBox1->layout()->setMargin( 0 ); QGridLayout *GroupBox1Layout = new QGridLayout( GroupBox1->layout() ); GroupBox1Layout->setAlignment( Qt::AlignTop ); GroupBox1Layout->setSpacing( 3 ); GroupBox1Layout->setMargin( 3 ); _force_depends = new QCheckBox( GroupBox1, "_force_depends" ); _force_depends->setText( tr( "-force-depends" ) ); _force_depends->setAutoResize( TRUE ); _force_depends->setChecked(true); GroupBox1Layout->addWidget( _force_depends, 0, 0 ); _force_reinstall = new QCheckBox( GroupBox1, "_force_reinstall" ); _force_reinstall->setText( tr( "-force-reinstall" ) ); _force_reinstall->setAutoResize( TRUE ); GroupBox1Layout->addWidget( _force_reinstall, 1, 0 ); _force_remove = new QCheckBox( GroupBox1, "_force_remove" ); _force_remove->setText( tr( "-force-removal-of-essential-packages" ) ); _force_remove->setAutoResize( TRUE ); GroupBox1Layout->addWidget( _force_remove, 1, 0 ); RunWindowLayout->addWidget( GroupBox1 , 3, 0 ); installDialog->showMaximized(); if ( installDialog->exec() ) doIt(); installDialog->close(); out(tr("<b>All done.</b>")); } void PmIpkg::doIt() { show( true ); remove(); install(); } void PmIpkg::remove() { if ( to_remove.count() == 0 ) return; out("<b>"+tr("Removing")+"<br>"+tr("please wait")+"</b><br><hr>"); QStringList *fileList; for (Package *it=to_remove.first(); it != 0; it=to_remove.next() ) { if ( it->link() )fileList = getList( it->name(), it->dest() ); if ( runIpkg("remove " + it->name(), it->dest() ) == 0) { runwindow->progress->setProgress( 1 + runwindow->progress->progress() ); linkOpp = removeLink; if ( it->link() ) { out( "<br>removing links<br>" ); out( "for package "+it->name()+" in "+it->dest()+"<br>" ); processFileList( fileList, it->dest() ); } it->processed(); - +// to_install.take( it ); out("<br><hr>"); }else{ out("<b>"+tr("Error while removing")+"</b><hr>"+it->name()); } if ( it->link() )delete fileList; } out("<br>"); } void PmIpkg::install() { if ( to_install.count() == 0 ) return; out("<b>"+tr("Installing")+"<br>"+tr("please wait")+"</b><br>"); for (Package *it=to_install.first(); it != 0; it=to_install.next() ) { if ( runIpkg("install " + it->installName(), it->dest() ) == 0 ) { runwindow->progress->setProgress( it->size().toInt() + runwindow->progress->progress()); linkOpp = createLink; if ( it->link() ) { out( "<br>creating links<br>" ); out( "for package "+it->name()+" in "+it->dest()+"<br>" ); makeLinks( it ); } it->processed(); +// to_install.take( it->name() ); out("<br><hr>"); }else{ out("<b>"+tr("Error while installing")+"</b><hr>"+it->name()); } } out("<br>"); } void PmIpkg::createLinks( const QString &dest ) { pvDebug(2,"PmIpkg::createLinks "+dest); linkOpp=createLink; QString url = settings->getDestinationUrlByName( dest ); url = url==""?dest:url; processLinkDir( "/", url ); } void PmIpkg::removeLinks( const QString &dest ) { pvDebug(2,"PmIpkg::removeLinks "+dest); linkOpp=removeLink; QString url = settings->getDestinationUrlByName( dest ); url = url==""?dest:url; processLinkDir( "/", url ); } void PmIpkg::update() { show( false ); runIpkg( "update" ); runwindow->close(); } void PmIpkg::out( QString o ) { runwindow->outPut->append(o); //runwindow->outPut->setCursorPosition(0, runwindow->outPut->contentsHeight()); // runwindow->outPut->setText( runwindow->outPut->text()+o ); runwindow->outPut->setContentsPos(0, runwindow->outPut->contentsHeight()); } void PmIpkg::showButtons(bool b) { if ( b ) { runwindow->cancelButton->hide(); runwindow->doItButton->hide(); runwindow->removeButton->hide(); runwindow->installButton->hide(); }else{ runwindow->cancelButton->show(); runwindow->doItButton->show(); runwindow->removeButton->show(); runwindow->installButton->show(); } } void PmIpkg::show(bool b) { if (!runwindow->isVisible()) runwindow->showMaximized(); 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 ); startDialog(); 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 ); startDialog(); delete p; } diff --git a/noncore/unsupported/oipkg/pmipkg.h b/noncore/unsupported/oipkg/pmipkg.h index fa00048..3799969 100644 --- a/noncore/unsupported/oipkg/pmipkg.h +++ b/noncore/unsupported/oipkg/pmipkg.h @@ -1,65 +1,65 @@ #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 "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( PackageList ); void update(); void showButtons(bool b=true); void show( bool buttons=true ); 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: - int sizecount; +// int sizecount; PackageManagerSettings* settings; RunWindow *runwindow; QDialog *installDialog; QList<Package> to_remove; QList<Package> to_install; - bool runwindowopen; +// bool runwindowopen; QString fileNameToInstall; QCheckBox *_force_reinstall; QCheckBox *_force_remove; QCheckBox *_force_depends; void startDialog(); void makeLinks(Package*); void linkPackage( QString, QString ); void processLinkDir( QString , QString ); int 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 3be4334..bab7a4f 100644 --- a/noncore/unsupported/oipkg/settings.h +++ b/noncore/unsupported/oipkg/settings.h @@ -1,67 +1,66 @@ #ifndef PACKAGEMANAGERSETTINGS_H #define PACKAGEMANAGERSETTINGS_H #include "pksettingsbase.h" #include <qintdict.h> class PackageManagerSettings : public PackageManagerSettingsBase //class PackageManagerSettings : private PackageManagerSettingsBase { // 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: +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(); void newDestination(); void editDestination(int); void linkEnabled(bool); void removeServer(); void serverNameChanged(const QString&); void serverUrlChanged(const QString&); void destNameChanged(const QString&); void destUrlChanged(const QString&); void installationSettingChange(int); void newInstallationSetting(); void removeInstallationSetting(); void renameInstallationSetting(); private: QIntDict<QString> serverurlDic; QIntDict<QString> destinationurlDic; int ipkg_old; int editedserver; int editeddestination; int currentSetting; int installationSettingsCount; bool changed; bool readIpkgConfig(const QString&); void writeIpkgConfig(const QString&); void writeSettings(); void readSettings(); }; #endif - /** No descriptions */ - void createLinks(); - /** No descriptions */ - void removeLinks(); + |