-rw-r--r-- | noncore/unsupported/oipkg/TODO | 2 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/mainwindow.cpp | 18 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/mainwindow.h | 5 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/pmipkg.cpp | 40 | ||||
-rw-r--r-- | noncore/unsupported/oipkg/pmipkg.h | 4 |
5 files changed, 65 insertions, 4 deletions
diff --git a/noncore/unsupported/oipkg/TODO b/noncore/unsupported/oipkg/TODO index 744cba4..b07542a 100644 --- a/noncore/unsupported/oipkg/TODO +++ b/noncore/unsupported/oipkg/TODO @@ -1,8 +1,10 @@ +* setDocument function * Settings Class * tr() ;) * Dialog to display ipkg output live * parse "to install" and "to remove" from status * install local file * qcop * error handling * manage links +* dependency checking
\ No newline at end of file diff --git a/noncore/unsupported/oipkg/mainwindow.cpp b/noncore/unsupported/oipkg/mainwindow.cpp index 25ca889..e3abf36 100644 --- a/noncore/unsupported/oipkg/mainwindow.cpp +++ b/noncore/unsupported/oipkg/mainwindow.cpp @@ -1,131 +1,135 @@ // adadpted form qpe/qipkg #include "mainwindow.h" #include <qpe/qpemenubar.h> #include <qpe/qpemessagebox.h> #include <qpe/resource.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 <qlistview.h> #include <qtextview.h> #include <qlineedit.h> #include <qtabwidget.h> #include <qcombobox.h> #include <qlayout.h> #include "pksettingsbase.h" #include "packagelistitem.h" MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f = 0 ) : QMainWindow( parent, name, f ) { setCaption( tr("Package Manager") ); listViewPackages = new QListView( this,0,0 ); listViewPackages->setSelectionMode(QListView::NoSelection); setCentralWidget( listViewPackages ); + channel = new QCopChannel( "QPE/Application/oipkg", this ); + connect( channel, SIGNAL(received(const QCString&, const QByteArray&)), + this, SLOT(receive(const QCString&, const QByteArray&)) ); + makeMenu(); #ifdef NEWLAYOUT listViewPackages->addColumn( tr("Package") ); listViewPackages->setRootIsDecorated( true ); #endif #ifndef NEWLAYOUT QFontMetrics fm = fontMetrics(); int wlw = width()*2; int w0 = fm.width(tr("Package"))+30; // int w0 = fm.width(tr("Package"))+30; int w2 = fm.width("00000")+4; int w1 = wlw-w2-w0-24; listViewPackages->addColumn( tr("Package"), w0 ); listViewPackages->addColumn( tr("Description"), w1 ); listViewPackages->addColumn( tr("Size"), w2 ); listViewPackages->setColumnWidthMode(0,QListView::Manual); listViewPackages->setColumnWidthMode(1,QListView::Manual); listViewPackages->setColumnWidthMode(2,QListView::Manual); listViewPackages->setSelectionMode( QListView::Multi ); #endif connect( section, SIGNAL( activated(int) ), this, SLOT( sectionChanged() ) ); connect( subsection, SIGNAL(activated(int) ), this, SLOT( subSectionChanged() ) ); connect( listViewPackages, SIGNAL( pressed( QListViewItem* ) ), this, SLOT( setCurrent( QListViewItem* ) ) ); connect( listViewPackages, SIGNAL( clicked( QListViewItem* ) ), this, SLOT( stopTimer( QListViewItem* ) ) ); popupMenu = new QPopupMenu( this ); settings = new PackageManagerSettings(this,0,TRUE); ipkg = new PmIpkg( settings, this ); packageList.setSettings( settings ); getList(); setSections(); setSubSections(); 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 ); popupMenu = new QPopupMenu( this ); destsMenu = new QPopupMenu( popupMenu ); popupTimer = new QTimer( this ); connect( popupTimer, SIGNAL(timeout()), this, SLOT(showPopup()) ); 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 ); detailsAction = new QAction( tr( "Details" ), Resource::loadIconSet( "find" ), QString::null, 0, this, 0 ); connect( detailsAction, SIGNAL( activated() ), this , SLOT( showDetails() ) ); detailsAction->addTo( toolBar ); detailsAction->addTo( srvMenu ); QAction *cfgact; @@ -323,96 +327,110 @@ void MainWindow::showDetails() connect( details->ignore, SIGNAL(clicked()), details, SLOT(close())); details->description->setTextFormat(RichText); } if ( !activePackage ) { details->description->setText(tr("no package selected")); details->description->setText(tr("errmm...<br>...not working?")); }else{ details->setCaption("Package: " + activePackage->name()); details->description->setText(activePackage->details() ); details->install->setEnabled(!activePackage->installed()); details->remove->setEnabled(activePackage->installed()); } details->showMaximized(); } void MainWindow::toggleActivePackage() { activePackage->toggleProcess(); if ( details ) details->close(); } void MainWindow::setCurrent( QListViewItem* p ) { if ( !p ) return; activePackageListItem = (PackageListItem*)p; activePackage = activePackageListItem->getPackage(); pvDebug(5, "start timer"); popupTimer->start( 750, true ); } 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::rotateUpdateIcon() { pvDebug(2, "MainWindow::rotateUpdateIcon"); if ( updateIcon ) updateAction->setIconSet( Resource::loadIconSet( "oipkg/update" ) ); else updateAction->setIconSet( Resource::loadIconSet( "oipkg/update2" ) ); updateIcon = !updateIcon; } void MainWindow::showPopup() { popupMenu->clear(); destsMenu->clear(); QAction *popupAction; popupMenu->insertItem( tr("Install to"), destsMenu ); QStringList dests = settings->getDestinationNames(); for (uint i = 0; i < dests.count(); i++ ) { popupAction = new QAction( dests[i], QString::null, 0, this, 0 ); popupAction->addTo( destsMenu ); } connect( destsMenu, SIGNAL( activated( int ) ), this, SLOT( changePackageDest( int ) ) ); popupMenu->popup( QCursor::pos() ); } void MainWindow::changePackageDest( int i ) { activePackage->setDest( destsMenu->text(i) ); activePackage->setOn(); activePackage->setLink( settings->createLinks() ); activePackageListItem->displayDetails(); } void MainWindow::stopTimer( QListViewItem* ) { pvDebug( 5, "stop timer" ); popupTimer->stop(); } + +void MainWindow::setDocument(const QString &fileName) +{ + ipkg->installFile( fileName ); +} + +void MainWindow::receive(const QCString &msg, const QByteArray &arg) +{ + pvDebug(3, "QCop "+msg); + if ( msg == "setDocument(QString)" ) + { + setDocument( QString(arg) ); + } +}
\ No newline at end of file diff --git a/noncore/unsupported/oipkg/mainwindow.h b/noncore/unsupported/oipkg/mainwindow.h index adc5e78..34943f2 100644 --- a/noncore/unsupported/oipkg/mainwindow.h +++ b/noncore/unsupported/oipkg/mainwindow.h @@ -1,83 +1,88 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H #include <qmainwindow.h> #include <qaction.h> #include <qtimer.h> #include <qpopupmenu.h> #include "packagelist.h" #include "pmipkg.h" #include "pksettings.h" #include "pkdesc.h" class QComboBox; class QPEToolBar; class QLineEdit; class QListView; class PackageListItem; +class QCopChannel; class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 ); ~MainWindow(); + QCopChannel *channel; + protected slots: void runIpkg(); void getList(); void updateList(); void displayList(); void subSectionChanged(); void sectionChanged(); void showSettings(); void showSettingsSrv(); void showSettingsDst(); + void setDocument (const QString &); public slots: void showDetails(); void toggleActivePackage(); void setCurrent( QListViewItem* ); void sectionClose(); void sectionShow(bool); void findClose(); void findShow(bool); void filterList(); void showPopup(); void changePackageDest( int ); void stopTimer( QListViewItem* ); + void receive (const QCString &, const QByteArray &); private: void makeMenu(); void setSections(); void setSubSections(); PmIpkg* ipkg; PackageManagerSettings *settings; PackageDetails* details; PackageList packageList; Package *activePackage; PackageListItem *activePackageListItem; QAction *runAction; QAction *detailsAction; QAction *updateAction; QAction *findAction; QAction *sectionAction; QListView *listViewPackages; QPEToolBar *findBar; QLineEdit *findEdit; QPEToolBar *sectionBar; QComboBox *section; QComboBox *subsection; QTimer *popupTimer; QPopupMenu *popupMenu; QPopupMenu *destsMenu; bool updateIcon; private slots: void rotateUpdateIcon(); }; #endif diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp index 3b31b4d..45c89c5 100644 --- a/noncore/unsupported/oipkg/pmipkg.cpp +++ b/noncore/unsupported/oipkg/pmipkg.cpp @@ -18,299 +18,331 @@ #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 "; out( "<hr><br>Starting to "+ args+"<br>\n"); cmd += args; int r = 0; #ifdef PROC QString o = "start"; Process *ipkg = new Process( "ls");//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 += " | 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 ); // QString fp; 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()); QString dest = settings->getDestinationUrlByName( pack->dest() ); if (dest == "/" ) return; out( "<br>creating links<br>" ); out("for package "+pack->name()+" in "+dest+"<br>"); { Config cfg( "oipkg", Config::User ); cfg.setGroup( "Common" ); QString statusDir = cfg.readEntry( "statusDir", "" ); } QString fn = dest+"/"+statusDir+"/info/"+pack->name()+".list"; - QFile f( fn ); - if ( ! f.open(IO_ReadOnly) ) + linkPackage( fn, dest ); +} + +void PmIpkg::linkPackage( QString packFileName, QString dest ) +{ + QFile f( packFileName ); + if ( ! f.open(IO_ReadOnly) ) { - out( "<b>Panik!</b> Could not open:<br>"+fn ); + out( "<b>Panik!</b> Could not open:<br>"+packFileName ); return; }; QTextStream t( &f ); QString fp; while ( !t.eof() ) { fp = t.readLine(); processLinkDir( fp, dest ); } f.close(); } void PmIpkg::processLinkDir( QString file, QString dest ) { if ( dest == "???" ) return; QString destFile = file; file = dest+"/"+file; if (file == dest) return; QFileInfo fileInfo( file ); if ( fileInfo.isDir() ) { QDir destDir( destFile ); 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()) ) { // out( "<b>"+fi->absFilePath()+"</b>" ); processLinkDir( fi->absFilePath(), dest ); ++it; } } else if ( fileInfo.isFile() ) { const char *instFile = strdup( (file).ascii() ); const char *linkFile = strdup( (destFile).ascii()); // out( "linking: "+file+" -> "+destFile ); qDebug( "linking: %s -> %s", instFile, linkFile ); symlink( instFile, linkFile ); } } void PmIpkg::commit( PackageList pl ) { show( false ); runwindow->outPut->setText(""); out( "<h1>"+tr("Todo")+"</h1>\n"); to_install.clear(); to_remove.clear(); int sizecount = 0; QString rem="<b>To remove:</b><br>\n"; QString inst="<b>To install:</b><br>\n";; pl.allPackages(); for( Package *pack = pl.first();pack ; (pack = pl.next()) ) { if ( pack && (pack->name() != "") && pack) { if ( pack->toInstall() ) { to_install.append( pack ); sizecount += pack->size().toInt(); inst += pack->name()+"\t(on "+pack->dest()+")<br>"; } if ( pack->toRemove() ) { to_remove.append( pack ); sizecount += 1; rem += pack->name()+"<br>"; } } } out("<p>"+inst+"</p>"+"<p>"+rem+"</p><hl>"); qDebug("to remove=%i; to install=%i",to_remove.count(),to_install.count()); runwindow->progress->setTotalSteps( sizecount ); connect( runwindow->doItButton, SIGNAL( clicked() ), SLOT( doIt() ) ); connect( runwindow->installButton, SIGNAL( clicked() ), this, SLOT( install() ) ); connect( runwindow->removeButton, SIGNAL( clicked() ), this, SLOT( remove() ) ); connect( runwindow->cancelButton, SIGNAL( clicked() ), runwindow, SLOT( close() ) ); runwindow->exec(); - return; + out("<h1>"+tr("Its now save to close this window")+"<h1>"); } void PmIpkg::doIt() { remove(); install(); } void PmIpkg::remove() { if ( to_remove.count() == 0 ) return; show( true ); out("<hr><hr><b>"+tr("Removing")+"<br>"+tr("please wait")+"</b><br>"); for (Package *it=to_remove.first(); it != 0; it=to_remove.next() ) { if ( runIpkg("remove " + it->name()) == 0) { runwindow->progress->setProgress( it->size().toInt() + runwindow->progress->progress()); it->processed(); runwindow->progress->setProgress( 1 ); }else{ out("<b>"+tr("Error while removing")+"</b>"+it->name()); } } } void PmIpkg::install() { if ( to_install.count() == 0 ) return; show( true ); out("<hr><hr><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->name(), it->dest() ) == 0 ) { runwindow->progress->setProgress( it->size().toInt() + runwindow->progress->progress()); if ( it->link() ) makeLinks( it ); it->processed(); }else{ out("<b>"+tr("Error while installing")+"</b>"+it->name()); } } } void PmIpkg::linkDestination( const QString msg, const QByteArray dest ) { qDebug("msg="+msg+" -- "+QString(dest) ); // QDir d( src ); // d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks ); //// if (! d.exists() ) return; // const QFileInfoList *list = d.entryInfoList(); // QFileInfoListIterator it( *list ); // QFileInfo *fi; // while ( (fi=it.current()) ) { // processLinkDir( fi->absFilePath(), dest ); // ++it; // } } void PmIpkg::update() { show( false ); runIpkg( "update" ); runwindow->close(); } void PmIpkg::out( QString o ) { 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) +{ + pvDebug( 2,"PmIpkg::installFile "+ fileName); + show( false ); + runwindow->outPut->setText(""); + fileNameToInstall = fileName; + runwindow->doItButton->hide(); + runwindow->removeButton->hide(); + out("<b>"+tr("Install: ")+fileName); + connect( runwindow->installButton, SIGNAL( clicked() ), + this, SLOT( installFileName() ) ); + connect( runwindow->cancelButton, SIGNAL( clicked() ), + runwindow, SLOT( close() ) ); + + runwindow->exec(); +} + +void PmIpkg::installFileName() +{ + if ( !QFile::exists( fileNameToInstall ) ) return; + out(tr("Installing pacakge ")+fileNameToInstall+"<br>"+tr("please wait")+"</b><br>"); + runIpkg("install " + fileNameToInstall ); + if ( settings->createLinks() ) + linkPackage( fileNameToInstall, settings->getDestinationUrl() ); + out("<h1>"+tr("Its now save to close this window")+"<h1>"); +}
\ No newline at end of file diff --git a/noncore/unsupported/oipkg/pmipkg.h b/noncore/unsupported/oipkg/pmipkg.h index c57adb7..8e06f4c 100644 --- a/noncore/unsupported/oipkg/pmipkg.h +++ b/noncore/unsupported/oipkg/pmipkg.h @@ -1,47 +1,51 @@ #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" class Package; class PmIpkg : public QObject { Q_OBJECT public: PmIpkg( PackageManagerSettings* , QWidget* p=0, const char * name=0, WFlags f=0 ); ~PmIpkg(); void commit( PackageList ); void update(); PackageList* getPackageList(); void showButtons(bool b=true); void show( bool buttons=true ); private: PackageManagerSettings* settings; RunWindow *runwindow; QList<Package> to_remove; QList<Package> to_install; bool runwindowopen; + QString fileNameToInstall; void makeLinks(Package*); + void linkPackage( QString, QString ); void processLinkDir( QString, QString ); int runIpkg(const QString& args, const QString& dest="" ); void out( QString ); public slots: void doIt(); void install(); + void installFileName(); void remove(); + void installFile(const QString &fileName); void linkDestination( const QString, const QByteArray ); }; #endif |