summaryrefslogtreecommitdiff
authortille <tille>2002-04-27 13:06:45 (UTC)
committer tille <tille>2002-04-27 13:06:45 (UTC)
commitdb90999f6298c1107888f062f2c25cb8817b528a (patch) (side-by-side diff)
tree020ebe65beb9286f3c63e4329fc3a0f298d34460
parente2f3288d468508f2cf7c0a327044963ca4b1b54a (diff)
downloadopie-db90999f6298c1107888f062f2c25cb8817b528a.zip
opie-db90999f6298c1107888f062f2c25cb8817b528a.tar.gz
opie-db90999f6298c1107888f062f2c25cb8817b528a.tar.bz2
added popup menu to choose inst dest (and more...)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/oipkg/TODO3
-rw-r--r--noncore/unsupported/oipkg/debug.h1
-rw-r--r--noncore/unsupported/oipkg/mainwindow.cpp115
-rw-r--r--noncore/unsupported/oipkg/mainwindow.h9
-rw-r--r--noncore/unsupported/oipkg/opie-oipkg.control2
-rw-r--r--noncore/unsupported/oipkg/package.cpp54
-rw-r--r--noncore/unsupported/oipkg/package.h22
-rw-r--r--noncore/unsupported/oipkg/packagelist.cpp46
-rw-r--r--noncore/unsupported/oipkg/packagelist.h8
-rw-r--r--noncore/unsupported/oipkg/packagelistitem.cpp44
-rw-r--r--noncore/unsupported/oipkg/packagelistitem.h8
-rw-r--r--noncore/unsupported/oipkg/pksettings.cpp24
-rw-r--r--noncore/unsupported/oipkg/pksettings.h3
-rw-r--r--noncore/unsupported/oipkg/pmipkg.cpp112
-rw-r--r--noncore/unsupported/oipkg/pmipkg.h12
-rw-r--r--noncore/unsupported/oipkg/runwindow.ui2
-rw-r--r--noncore/unsupported/oipkg/settings.h2
17 files changed, 312 insertions, 155 deletions
diff --git a/noncore/unsupported/oipkg/TODO b/noncore/unsupported/oipkg/TODO
index c53ca93..744cba4 100644
--- a/noncore/unsupported/oipkg/TODO
+++ b/noncore/unsupported/oipkg/TODO
@@ -1,11 +1,8 @@
-* search
* Settings Class
-* make oipkg determine dest of "to remove" apps
* tr() ;)
* Dialog to display ipkg output live
* parse "to install" and "to remove" from status
* install local file
-* install to dest with click on packet
* qcop
* error handling
* manage links
diff --git a/noncore/unsupported/oipkg/debug.h b/noncore/unsupported/oipkg/debug.h
index c53e36c..e73b9b2 100644
--- a/noncore/unsupported/oipkg/debug.h
+++ b/noncore/unsupported/oipkg/debug.h
@@ -1,20 +1,21 @@
#ifndef _DEBUG_H_
#define _DEBUG_H_
#include <stdio.h>
extern int debugLevel;
#define HACK
+#define NEWLAYOUT
#define pvDebug(I, S) \
if ( debugLevel < 3 ) \
{ \
if ( I <= debugLevel ) qDebug(S);\
}else{\
if ( I <= debugLevel ) \
printf("# %s \t\t(Level: %i)\n",QString(S).latin1(),I);\
}
#endif \ No newline at end of file
diff --git a/noncore/unsupported/oipkg/mainwindow.cpp b/noncore/unsupported/oipkg/mainwindow.cpp
index c803ca0..25ca889 100644
--- a/noncore/unsupported/oipkg/mainwindow.cpp
+++ b/noncore/unsupported/oipkg/mainwindow.cpp
@@ -1,127 +1,138 @@
// 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 );
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-20;
+ 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 );
-
- contextMenu = new QPopupMenu( this );
+ 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;
cfgact = new QAction( tr( "Setups" ),
// Resource::loadIconSet( "" ),
QString::null, 0, this, 0 );
connect( cfgact, SIGNAL( activated() ),
SLOT( showSettings() ) );
cfgact->addTo( cfgMenu );
@@ -135,223 +146,273 @@ void MainWindow::makeMenu()
// Resource::loadIconSet( "" ),
QString::null, 0, this, 0 );
connect( cfgact, SIGNAL( activated() ),
SLOT( showSettingsDst() ) );
cfgact->addTo( cfgMenu );
QAction *a;
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 );
// section->setBackgroundMode( PaletteBackground );
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 );
sectionAction = new QAction( tr( "Sections" ), QString::null, 0, this, 0 );
connect( sectionAction, SIGNAL( toggled(bool) ), this, SLOT( sectionShow(bool) ) );
sectionAction->setToggleAction( true );
sectionAction->setOn( true );
sectionAction->addTo( viewMenu );
findBar = new QPEToolBar(this);
addToolBar( findBar, "Search", 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( "Close Find" ), Resource::loadPixmap( "close" ), QString::null, 0, this, 0 );
connect( a, SIGNAL( activated() ), this, SLOT( findClose() ) );
a->addTo( findBar );
findAction = new QAction( tr( "Find" ), QString::null, 0, this, 0 );
connect( findAction, SIGNAL( toggled(bool) ), this, SLOT( findShow(bool) ) );
findAction->setToggleAction( true );
findAction->setOn( true );
findAction->addTo( viewMenu );
+
+ #ifdef NEW
+ Config cfg( "oipkg", Config::User );
+ cfg.setGroup( "Setting_" + QString::number( setting ) );
+ CheckBoxLink->setChecked( cfg.readBoolEntry( "link", false ) );
+ findShow(bool b)
+ sectionShow(bool b)
+ #endif
}
MainWindow::~MainWindow()
{
}
void MainWindow::runIpkg()
{
ipkg->commit( packageList );
-// updateList(); //to remove
+ // ##### 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()
{
QTimer *t = new QTimer( this );
connect( t, SIGNAL(timeout()), SLOT( rotateUpdateIcon() ) );
t->start( 0, false );
packageList.clear();
ipkg->update();
getList();
- t->stop();
+ t->stop();
}
void MainWindow::getList()
{
packageList.update();
displayList();
}
void MainWindow::filterList()
{
QString f = "";
if ( findAction->isOn() ) f = findEdit->text();
packageList.filterPackages( f );
}
void MainWindow::displayList()
{
filterList();
listViewPackages->clear();
Package *pack = packageList.first();
while( pack )
{
if ( pack && (pack->name() != "") )
- listViewPackages->insertItem( new PackageListItem( listViewPackages, pack ) );
+ listViewPackages->insertItem( new PackageListItem( listViewPackages, pack, settings ) );
pack = packageList.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() );
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() );
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() );
}
void MainWindow::setSubSections()
{
subsection->clear();
subsection->insertStringList( packageList.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::showDetails()
{
- if ( activePackage ) return;
if ( details )
- {
- details = new PackageDetails( this );
- connect( details->install, SIGNAL(clicked()), SLOT( toggleActivePackage() ) );
- connect( details->remove, SIGNAL(clicked()), SLOT( toggleActivePackage() ) );
- connect( details->ignore, SIGNAL(clicked()), details, SLOT(close()));
- details->description->setTextFormat(RichText);
- }
-
- details->setCaption("Package: " + activePackage->name());
- details->description->setText(activePackage->details() );
- details->install->setEnabled(!activePackage->installed());
- details->remove->setEnabled(activePackage->installed());
+ {
+ details = new PackageDetails( this );
+ connect( details->install, SIGNAL(clicked()), SLOT( toggleActivePackage() ) );
+ connect( details->remove, SIGNAL(clicked()), SLOT( toggleActivePackage() ) );
+ 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 )
{
- pvDebug(2, "MainWindow::setCurrent ");
- return;
- pvDebug(2, "name "+((Package*)p)->name());
- activePackage = (Package*)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();
+}
diff --git a/noncore/unsupported/oipkg/mainwindow.h b/noncore/unsupported/oipkg/mainwindow.h
index 892d5e8..adc5e78 100644
--- a/noncore/unsupported/oipkg/mainwindow.h
+++ b/noncore/unsupported/oipkg/mainwindow.h
@@ -1,78 +1,83 @@
#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 MainWindow : public QMainWindow
{
Q_OBJECT
public:
MainWindow( QWidget *parent = 0, const char *name = 0, WFlags f = 0 );
~MainWindow();
protected slots:
void runIpkg();
void getList();
void updateList();
void displayList();
void subSectionChanged();
void sectionChanged();
void showSettings();
void showSettingsSrv();
void showSettingsDst();
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* );
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;
- QPopupMenu *contextMenu;
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/opie-oipkg.control b/noncore/unsupported/oipkg/opie-oipkg.control
index 89cc0b4..2ffec71 100644
--- a/noncore/unsupported/oipkg/opie-oipkg.control
+++ b/noncore/unsupported/oipkg/opie-oipkg.control
@@ -1,9 +1,9 @@
Files: bin/oipkg apps/Settings/oipkg.desktop pics/oipkg/
Priority: optional
Section: opie/settings
Maintainer: Patrick S. Vogt <tille@almana.ch>
Architecture: arm
Version: $QPE_VERSION-$SUB_VERSION
-Depends: opie-base ($QPE_VERSION)
+Depends: opie-base ($QPE_VERSION), ipkg (>0.9)
Description: Package Manager
A GUI front-end to ipkg for the Opie environment.
diff --git a/noncore/unsupported/oipkg/package.cpp b/noncore/unsupported/oipkg/package.cpp
index 1705f78..9f602b5 100644
--- a/noncore/unsupported/oipkg/package.cpp
+++ b/noncore/unsupported/oipkg/package.cpp
@@ -1,88 +1,95 @@
#include "package.h"
#include <qpe/process.h>
#include <qpe/stringutil.h>
#include "debug.h"
Package::~Package()
{
}
-Package::Package()
+Package::Package( PackageManagerSettings *s )
{
+ init(s);
+}
+
+void Package::init( PackageManagerSettings *s )
+{
+ settings = s;
_size = "";
_section = "";
_subsection = "";
_shortDesc = "";
_desc = "";
_name = "";
_toProcess = false;
_status = "";
+ _dest = "";
}
-Package::Package( QStringList pack )
+Package::Package( QStringList pack, PackageManagerSettings *s )
{
- Package();
+ init(s);
parsePackage( pack );
_toProcess = false;
}
-Package::Package( QString n )
+Package::Package( QString n, PackageManagerSettings *s )
{
- Package();
+ init(s);
_name = QString( n );
_toProcess = false;
}
Package::Package( Package *pi )
{
- Package();
+ init(pi->settings);
copyValues( pi );
_toProcess = false;
}
void Package::setValue( QString n, QString t )
{
if ( n == "Status" && installed() ) return;
if ( n == "Package" )
{
_name = QString( t );
}
if ( n == "Installed-Size" )
{
_size = t;
}
if ( n == "Priority")
{
}
if ( n == "Section")
{
setSection( t );
}
if ( n == "Maintainer")
{
}
if ( n == "Architecture")
{
}
if ( n == "Version")
{
}
if ( n == "Pre-Depends")
{
}
if ( n == "Depends")
{
}else if ( n == "Filename")
{
}else if ( n == "Size")
{
@@ -127,137 +134,164 @@ QString Package::desc()
return _desc;
}
QString Package::shortDesc()
{
return _shortDesc;
}
QString Package::size()
{
return _size;
}
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::getSection()
+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::getSubSection()
+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;
}
-/** No descriptions */
void Package::processed()
{
_toProcess = false;
- //hack, but we're mot writing status anyway...
+ //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;
+}
diff --git a/noncore/unsupported/oipkg/package.h b/noncore/unsupported/oipkg/package.h
index cf2af75..6c292ed 100644
--- a/noncore/unsupported/oipkg/package.h
+++ b/noncore/unsupported/oipkg/package.h
@@ -1,56 +1,66 @@
#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();
+ Package(PackageManagerSettings *);
~Package();
- Package( QStringList );
- Package( QString );
+ Package( QStringList, PackageManagerSettings * );
+ Package( QString, PackageManagerSettings * );
Package( Package* );
void setValue( QString, QString );
void copyValues( Package* );
QString name() ;
bool installed();
void setDesc( QString );
QString shortDesc();
QString desc();
QString size();
void setSection( QString );
- QString getSection();
- QString getSubSection();
+ QString section();
+ QString subSection();
QString details();
bool toProcess();
bool toInstall();
bool toRemove();
- /** No descriptions */
void processed();
+ QString dest();
+ void setDest( QString d );
+ void setOn();
+ bool link();
+ void setLink(bool);
public slots:
void toggleProcess();
private:
+ PackageManagerSettings *settings;
QString _name;
bool _toProcess;
+ bool _link;
QString _status;
QString _size;
QString _section;
QString _subsection;
QString _shortDesc;
QString _desc;
+ QString _dest;
void parsePackage( QStringList );
+ void init(PackageManagerSettings *);
};
#endif
diff --git a/noncore/unsupported/oipkg/packagelist.cpp b/noncore/unsupported/oipkg/packagelist.cpp
index 944bb83..035ec81 100644
--- a/noncore/unsupported/oipkg/packagelist.cpp
+++ b/noncore/unsupported/oipkg/packagelist.cpp
@@ -25,199 +25,217 @@ PackageList::PackageList()
cfg.writeEntry( "listsDir", listsDir );
}
}
sections << "All";
subSections.insert("All", new QStringList() );
QStringList *ss = subSections["All"];
*ss << "All";
aktSection = "All";
aktSubSection = "All";
}
PackageList::PackageList( PackageManagerSettings* s)
: packageIter( packageList )
{
settings = s;
PackageList();
}
PackageList::~PackageList()
{
}
/** Inserts a package into the list */
void PackageList::insertPackage( Package* pack )
{
Package* p = packageList.find( pack->name() );
if ( p )
{
p->copyValues( pack );
delete pack;
pack = p;
}else{
packageList.insert( pack->name(), pack );
origPackageList.insert( pack->name(), pack );
empty=false;
};
updateSections( pack );
}
void PackageList::filterPackages( QString f )
{
packageList.clear();
QDictIterator<Package> filterIter( origPackageList );
filterIter.toFirst();
Package *pack= filterIter.current() ;
while ( pack )
{
if (
- ((aktSection=="All")||(pack->getSection()==aktSection)) &&
- ((aktSubSection=="All")||(pack->getSubSection()==aktSubSection)) &&
+ ((aktSection=="All")||(pack->section()==aktSection)) &&
+ ((aktSubSection=="All")||(pack->subSection()==aktSubSection)) &&
pack->name().contains( f )
)
{
packageList.insert( pack->name(), pack );
}
++filterIter;
pack = filterIter.current();
}
}
Package* PackageList::find( QString n )
{
return packageList.find( n );
}
Package* PackageList::first()
{
packageIter.toFirst();
return packageIter.current();
}
Package* PackageList::next()
{
++packageIter;
return packageIter.current();
}
QStringList PackageList::getSections()
{
sections.sort();
return sections;
}
QStringList PackageList::getSubSections()
{
QStringList ss;
if ( !subSections[aktSection] ) return ss;
ss = *subSections[aktSection];
ss.sort();
return ss;
}
void PackageList::setSection( QString sec )
{
aktSection = sec;
}
void PackageList::setSubSection( QString ssec )
{
aktSubSection = ssec;
}
void PackageList::updateSections( Package* pack )
{
- QString s = pack->getSection();
+ QString s = pack->section();
if ( s.isEmpty() || s == "") return;
if ( sections.contains(s) ) return;
sections += s;
- QString ss = pack->getSubSection();
+ QString ss = pack->subSection();
if ( ss.isEmpty() || ss == "" ) return;
if ( !subSections[s] ) {
subSections.insert( s, new QStringList() );
QStringList *subsecs = subSections[s];
*subsecs += "All";
}
QStringList *subsecs = subSections[s];
*subsecs += ss;
if ( !subSections["All"] ) subSections.insert( "All", new QStringList() );
subsecs = subSections["All"];
*subsecs += ss;
}
/** No descriptions */
void PackageList::parseStatus()
{
QStringList dests = settings->getDestinationUrls();
- for ( QStringList::Iterator it = dests.begin(); it != dests.end(); ++it )
+ QStringList destnames = settings->getDestinationNames();
+ QStringList::Iterator name = destnames.begin();
+ for ( QStringList::Iterator dir = dests.begin(); dir != dests.end(); ++dir )
{
- pvDebug( 2,"Status Dir: "+*it+statusDir+"/status");
- readFileEntries( *it+statusDir+"/status" );
+ pvDebug( 2,"Status: "+*dir+statusDir+"/status");
+ readFileEntries( *dir+statusDir+"/status", *name );
+ ++name;
};
}
void PackageList::parseList()
{
QStringList srvs = settings->getActiveServers();
for ( QStringList::Iterator it = srvs.begin(); it != srvs.end(); ++it )
{
- pvDebug( 2, "List Dir: "+listsDir+"/"+*it);
- readFileEntries( listsDir+"/"+*it );
+ pvDebug( 2, "List: "+listsDir+"/"+*it);
+ readFileEntries( listsDir+"/"+*it, "" );
}
}
-void PackageList::readFileEntries( QString filename )
+void PackageList::readFileEntries( QString filename, QString dest )
{
QStringList packEntry;
QFile f( filename );
if ( !f.open(IO_ReadOnly) ) return;
QTextStream *statusStream = new QTextStream( &f );
while ( !statusStream ->eof() )
{
QString line = statusStream->readLine();
if ( line.find(QRegExp("[\n\t ]*")) || line == "" )
{
//end of package
if ( ! packEntry.isEmpty() )
{
- Package *p = new Package( packEntry );
+ Package *p = new Package( packEntry, settings );
+ p->setDest( dest );
if ( p )
{
insertPackage( p );
packEntry.clear();
}
}
}else{
packEntry << line;
};
}
return;
}
void PackageList::update()
{
- pvDebug( 3, "parseStatus");
+ pvDebug( 2, "parseStatus");
parseStatus();
- pvDebug( 3, "parseList");
+ pvDebug( 2, "parseList");
parseList();
- pvDebug( 3, "finished parsing");
+ pvDebug( 2, "finished parsing");
}
void PackageList::setSettings( PackageManagerSettings *s )
{
settings = s;
}
Package* PackageList::getByName( QString n )
{
origPackageList[n];
}
void PackageList::clear()
{
origPackageList.clear();
packageList.clear();
}
+
+void PackageList::allPackages()
+{
+ packageList.clear();
+ QDictIterator<Package> filterIter( origPackageList );
+ filterIter.toFirst();
+ Package *pack= filterIter.current() ;
+ while ( pack )
+ {
+ packageList.insert( pack->name(), pack );
+ ++filterIter;
+ pack = filterIter.current();
+ }
+}
diff --git a/noncore/unsupported/oipkg/packagelist.h b/noncore/unsupported/oipkg/packagelist.h
index 4ce97af..7c326ca 100644
--- a/noncore/unsupported/oipkg/packagelist.h
+++ b/noncore/unsupported/oipkg/packagelist.h
@@ -1,68 +1,70 @@
#ifndef PACKAGELIST_H
#define PACKAGELIST_H
#include <qdict.h>
#include "package.h"
#include "pksettings.h"
#include "debug.h"
#define HACK
#ifdef HACK
static QString listsDir="/usr/lib/ipkg/";
static QString statusDir="/usr/lib/ipkg/";
#endif
-class PackageList {
+class PackageList //:QObject
+{
+// Q_OBJECT
public:
// static QString all = QObject::tr("All");
PackageList();
PackageList( PackageManagerSettings* );
~PackageList();
void insertPackage( Package* );
Package* find( QString );
Package* next();
Package* first();
QStringList getSections();
QStringList getSubSections();
void setSettings( PackageManagerSettings* );
void filterPackages( QString );
Package* getByName( QString );
- /** No descriptions */
void clear();
+ void allPackages();
public slots:
void setSection(QString);
void setSubSection(QString);
void update();
private:
int currentPackage;
int packageCount;
PackageManagerSettings *settings;
QDict<Package> packageList;
QDict<Package> origPackageList;
QDictIterator<Package> packageIter;
bool empty;
#ifndef HACK
QString listsDir;
QString statusDir;
#endif
QString aktSection;
QString aktSubSection;
QStringList sections;
QDict<QStringList> subSections;
QDict<bool> sectionsDict;
void updateSections( Package* );
void parseStatus();
void parseList();
- void readFileEntries( QString );
+ void readFileEntries( QString file, QString dest );
};
#endif
diff --git a/noncore/unsupported/oipkg/packagelistitem.cpp b/noncore/unsupported/oipkg/packagelistitem.cpp
index 5d08bb1..149ba35 100644
--- a/noncore/unsupported/oipkg/packagelistitem.cpp
+++ b/noncore/unsupported/oipkg/packagelistitem.cpp
@@ -1,97 +1,139 @@
#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)
+PackageListItem::PackageListItem(QListView* lv, Package *pi, PackageManagerSettings *s)
: QCheckListItem(lv,pi->name(),CheckBox)
{
package = pi;
+ settings = s;
+ setExpandable( true );
+ QCheckListItem *item;
+#ifndef NEWLAYOUT
+ item = new QCheckListItem( this, QObject::tr("Name") );
+ item->setText(1,pi->name());
+ item = new QCheckListItem( this, QObject::tr("Description") );
+ item->setText(1,pi->desc()+"\ntest multi\nline");
+ item = new QCheckListItem( this, QObject::tr("Size") );
+ item->setText(1,pi->size());
+ item = new QCheckListItem( this, QObject::tr("Destination") );
+ item->setText(1,pi->getDest());
+#endif
+#ifdef NEWLAYOUT
+ item = new QCheckListItem( this, QObject::tr("Name: ")+pi->name() );
+ item = new QCheckListItem( this, QObject::tr("Description: ")+pi->desc() );
+ item = new QCheckListItem( this, QObject::tr("Size: ")+pi->size() );
+ destItem = new QCheckListItem( this, "" );
+ linkItem = new QCheckListItem( this, "" );
+ displayDetails();
+#endif
+
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"));
}
+#ifndef NEWLAYOUT
setText(1, package->shortDesc() );
setText(2, package->size() );
+#endif
}
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();
+// if ( b )
+// {
+// if ((package->dest()).isEmpty)
+// package->setDest( settings->getDestinationName() );
+// }else{
+// package->setDest( QObject::tr("not installed"));
+// }
+ package->setLink( settings->createLinks() );
+ displayDetails();
+}
+
+void PackageListItem::displayDetails()
+{
+ linkItem->setText( 0, QObject::tr("Link: ")+QString(package->link()?QObject::tr("Yes"):QObject::tr("No")) );
+ destItem->setText( 0, QObject::tr("Destination: ")+package->dest() );
repaint();
}
diff --git a/noncore/unsupported/oipkg/packagelistitem.h b/noncore/unsupported/oipkg/packagelistitem.h
index 6983e58..f695432 100644
--- a/noncore/unsupported/oipkg/packagelistitem.h
+++ b/noncore/unsupported/oipkg/packagelistitem.h
@@ -1,31 +1,37 @@
#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(QListView*, Package* );
+ 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:
+ QCheckListItem *destItem;
+ QCheckListItem *linkItem;
+ PackageManagerSettings *settings;
Package *package;
};
#endif
diff --git a/noncore/unsupported/oipkg/pksettings.cpp b/noncore/unsupported/oipkg/pksettings.cpp
index 32224b5..f84a9c4 100644
--- a/noncore/unsupported/oipkg/pksettings.cpp
+++ b/noncore/unsupported/oipkg/pksettings.cpp
@@ -424,64 +424,88 @@ void PackageManagerSettings::readSettings()
void PackageManagerSettings::writeSettings()
{
writeIpkgConfig("/etc/ipkg.conf");
writeInstallationSettings();
}
/** shows the setting dialog */
bool PackageManagerSettings::showDialog( int i )
{
TabWidget->setCurrentPage( i );
showMaximized();
bool ret = exec();
if ( ret ) writeSettings();
else readSettings();
return ret;
}
/** Returns the installation destination */
QString PackageManagerSettings::getDestinationName()
{
return activeDestination->currentText();
}
/** Returns the link destination */
QString PackageManagerSettings::getLinkDestinationName()
{
return activeLinkDestination->currentText();
}
/** Returns the URL of the active destination */
QString PackageManagerSettings::getDestinationUrl()
{
int dnr = activeDestination->currentItem();
return *destinationurlDic.find(dnr);
}
/** Should oipkg create links form install destination to link destination */
bool PackageManagerSettings::createLinks()
{
return CheckBoxLink->isChecked();
}
/** get the servers that are active */
QStringList PackageManagerSettings::getActiveServers()
{
QStringList sl;
for (int i=0; i<(int)activeServers->count(); i++)
{
if ( activeServers->isSelected(i) )
sl += activeServers->text(i);
}
return sl;
}
+
/** returns the destination listed in ipkg.conf */
QStringList PackageManagerSettings::getDestinationUrls()
{
QStringList sl;
for (int i=0; i<(int)destinations->count(); i++)
{
sl += *destinationurlDic[i];
}
return sl;
}
+/** returns the destination listed in ipkg.conf */
+QString PackageManagerSettings::getDestinationUrlByName(QString n)
+{
+ QStringList sl;
+ for (int i=0; i<(int)destinations->count(); i++)
+ {
+ if ( n == destinations->text(i)) return*destinationurlDic[i];
+ }
+ return "";
+}
+
+/** returns the destination listed in ipkg.conf */
+QStringList PackageManagerSettings::getDestinationNames()
+{
+ QStringList sl;
+ for (int i=0; i<(int)destinations->count(); i++)
+ {
+ sl += destinations->text(i);
+ }
+ return sl;
+}
+
+
void PackageManagerSettings::linkEnabled( bool b )
{
changed = true;
activeLinkDestination->setEnabled( b );
}
diff --git a/noncore/unsupported/oipkg/pksettings.h b/noncore/unsupported/oipkg/pksettings.h
index 2982f1c..11ba55c 100644
--- a/noncore/unsupported/oipkg/pksettings.h
+++ b/noncore/unsupported/oipkg/pksettings.h
@@ -1,61 +1,64 @@
#ifndef PACKAGEMANAGERSETTINGS_H
#define PACKAGEMANAGERSETTINGS_H
#include "pksettingsbase.h"
#include <qintdict.h>
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();
+ QStringList getDestinationNames();
+ QString getDestinationUrlByName(QString);
+
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();
public slots:
void writeInstallationSettings();
void readInstallationSettings();
void writeCurrentInstallationSetting();
void readInstallationSetting(int);
void installationSettingSetName(const QString &);
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();
};
#endif
diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp
index eae73ad..3b31b4d 100644
--- a/noncore/unsupported/oipkg/pmipkg.cpp
+++ b/noncore/unsupported/oipkg/pmipkg.cpp
@@ -1,352 +1,316 @@
#include "pmipkg.h"
#include "pkdesc.h"
#include "pksettings.h"
#include "package.h"
#include "packagelistitem.h"
#include <qpe/process.h>
#include <qpe/resource.h>
#include <qpe/config.h>
#include <qpe/stringutil.h>
-#include <qpe/qcopenvelope_qws.h>
#include <qdir.h>
#include <qfile.h>
#include <qmultilineedit.h>
#include <qstring.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)
+int PmIpkg::runIpkg(const QString& args, const QString& dest )
{
pvDebug(2,"PmIpkg::runIpkg "+args);
- //to make script ipkg happy
- pvDebug(2, "cd "+settings->getDestinationUrl()+"/tmp/ipkg");
- if (!QDir::setCurrent(settings->getDestinationUrl()+"/tmp/ipkg"))
- {
- QDir instDir = QDir(settings->getDestinationUrl()+"/tmp/ipkg");
- instDir.mkdir(settings->getDestinationUrl()+"/tmp/ipkg");
- }
#ifdef PROC
QStringList cmd = "/usr/bin/ipkg ";
#endif
#ifdef SYSTEM
QString cmd = "/usr/bin/ipkg ";
#endif
- cmd += " -dest "+settings->getDestinationName();
+ 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;
- out( "running:<br>\n"+cmd+"<br>\n" );
int r = 0;
#ifdef PROC
QString o = "start";
- Process ipkg( cmd );
+ Process *ipkg = new Process( "ls");//cmd );
+ out( "running:<br>\n"+ipkg->arguments().join(" ")+"<br>\n" );
QString description;
- ipkg.exec("",o);
- out( o );
+ 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;
+ if ( line != oldLine )
+ {
+ out( line +"<br>" );
+ oldLine = line;
+ }
}
- }
+// }
f.close();
out( "Finished!<br>");
#endif
return r;
}
-void PmIpkg::makeLinks(QString pack)
+void PmIpkg::makeLinks(Package *pack)
{
- pvDebug( 2, "PmIpkg::makeLinks "+ pack);
+ pvDebug( 2, "PmIpkg::makeLinks "+ pack->name());
+ QString dest = settings->getDestinationUrlByName( pack->dest() );
+ if (dest == "/" ) return;
out( "<br>creating links<br>" );
- QString dest = settings->getDestinationUrl();
- out("for package "+pack+" in "+dest+"<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+".list";
+ QString fn = dest+"/"+statusDir+"/info/"+pack->name()+".list";
QFile f( fn );
if ( ! f.open(IO_ReadOnly) )
{
out( "<b>Panik!</b> Could not open:<br>"+fn );
+ 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() )
{
- #ifndef NEWLIST
- to_install.append( pack->name() );
- #endif
- #ifdef NEWLIST
to_install.append( pack );
sizecount += pack->size().toInt();
- #endif
- inst += pack->name()+"<br>";
+ inst += pack->name()+"\t(on "+pack->dest()+")<br>";
}
if ( pack->toRemove() )
{
- #ifndef NEWLIST
- to_remove.append( pack->name() );
- #endif
- #ifdef NEWLIST
to_remove.append( pack );
sizecount += 1;
- #endif
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();
- // ##### 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;
return;
}
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>");
- #ifndef NEWLIST
- for (QStringList::ConstIterator it=to_remove.begin(); it!=to_remove.end(); ++it)
- {
- if ( runIpkg("remove " + *it) == 0)
- {
-
- }else{
- out("<b>"+tr("Error while removing")+"</b>"+*it);
- }
- }
-#endif
- #ifdef NEWLIST
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());
}
}
-#endif
}
void PmIpkg::install()
{
if ( to_install.count() == 0 ) return;
show( true );
out("<hr><hr><b>"+tr("Installing")+"<br>"+tr("please wait")+"</b><br>");
- #ifndef NEWLIST
- for (QStringList::ConstIterator it=to_install.begin(); it!=to_install.end(); ++it)
- {
- if ( runIpkg("install " + *it) == 0 )
- {
- if ( settings->createLinks() )
- makeLinks( *it );
- }else{
- out("<b>"+tr("Error while installing")+"</b>"+*it);
- }
- }
-#endif
- #ifdef NEWLIST
- for (Package *it=to_install.first(); it != 0; it=to_install.next() )
+ for (Package *it=to_install.first(); it != 0; it=to_install.next() )
{
- if ( runIpkg("install " + it->name()) == 0 )
+
+ if ( runIpkg("install " + it->name(), it->dest() ) == 0 )
{
runwindow->progress->setProgress( it->size().toInt() + runwindow->progress->progress());
- if ( settings->createLinks() )
- makeLinks( it->name() );
+ if ( it->link() )
+ makeLinks( it );
it->processed();
}else{
out("<b>"+tr("Error while installing")+"</b>"+it->name());
}
}
-#endif
}
void PmIpkg::linkDestination( const QString msg, const QByteArray dest )
-// add 3rd package parameter
{
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 )
+ if ( b )
runwindow->progress->hide();
-// else
-// runwindow->progress->show();
+ else
+ runwindow->progress->show();
}
diff --git a/noncore/unsupported/oipkg/pmipkg.h b/noncore/unsupported/oipkg/pmipkg.h
index 2692017..c57adb7 100644
--- a/noncore/unsupported/oipkg/pmipkg.h
+++ b/noncore/unsupported/oipkg/pmipkg.h
@@ -1,55 +1,47 @@
#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 NEWLIST
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;
-#ifndef NEWLIST
- QStringList to_remove;
- QStringList to_install;
-#endif
-#ifdef NEWLIST
QList<Package> to_remove;
QList<Package> to_install;
-#endif
bool runwindowopen;
- void makeLinks(QString);
+ void makeLinks(Package*);
void processLinkDir( QString, QString );
-
- int runIpkg(const QString& args);
+ int runIpkg(const QString& args, const QString& dest="" );
void out( QString );
public slots:
void doIt();
void install();
void remove();
void linkDestination( const QString, const QByteArray );
};
#endif
diff --git a/noncore/unsupported/oipkg/runwindow.ui b/noncore/unsupported/oipkg/runwindow.ui
index 5359fe2..52da408 100644
--- a/noncore/unsupported/oipkg/runwindow.ui
+++ b/noncore/unsupported/oipkg/runwindow.ui
@@ -1,93 +1,93 @@
<!DOCTYPE UI><UI>
<class>RunWindow</class>
<widget>
<class>QDialog</class>
<property stdset="1">
<name>name</name>
<cstring>RunWindow</cstring>
</property>
<property stdset="1">
<name>geometry</name>
<rect>
<x>0</x>
<y>0</y>
<width>344</width>
<height>291</height>
</rect>
</property>
<property stdset="1">
<name>caption</name>
<string>running...</string>
</property>
<property>
<name>layoutMargin</name>
</property>
<property>
<name>layoutSpacing</name>
</property>
<grid>
<property stdset="1">
<name>margin</name>
<number>2</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>2</number>
</property>
<widget row="0" column="0" >
<class>QProgressBar</class>
<property stdset="1">
<name>name</name>
<cstring>progress</cstring>
</property>
<property stdset="1">
<name>progress</name>
- <number>42</number>
+ <number>0</number>
</property>
</widget>
<widget row="1" column="0" >
<class>QTextView</class>
<property stdset="1">
<name>name</name>
<cstring>outPut</cstring>
</property>
<property stdset="1">
<name>font</name>
<font>
<pointsize>6</pointsize>
</font>
</property>
</widget>
<widget row="2" column="0" >
<class>QLayoutWidget</class>
<property stdset="1">
<name>name</name>
<cstring>buttons</cstring>
</property>
<hbox>
<property stdset="1">
<name>margin</name>
<number>0</number>
</property>
<property stdset="1">
<name>spacing</name>
<number>6</number>
</property>
<widget>
<class>QPushButton</class>
<property stdset="1">
<name>name</name>
<cstring>doItButton</cstring>
</property>
<property stdset="1">
<name>sizePolicy</name>
<sizepolicy>
<hsizetype>0</hsizetype>
<vsizetype>0</vsizetype>
</sizepolicy>
</property>
<property stdset="1">
<name>font</name>
<font>
<pointsize>8</pointsize>
</font>
diff --git a/noncore/unsupported/oipkg/settings.h b/noncore/unsupported/oipkg/settings.h
index 5df522b..cf6e614 100644
--- a/noncore/unsupported/oipkg/settings.h
+++ b/noncore/unsupported/oipkg/settings.h
@@ -1,65 +1,63 @@
#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();
- /** No descriptions */
- QComboBox getActiveDestinationCombo();
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();
public slots:
void writeInstallationSettings();
void readInstallationSettings();
void writeCurrentInstallationSetting();
void readInstallationSetting(int);
void installationSettingSetName(const QString &);
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();
};
#endif