summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/unsupported/oipkg/TODO13
-rw-r--r--noncore/unsupported/oipkg/installdialog.cpp4
-rw-r--r--noncore/unsupported/oipkg/main.cpp2
-rw-r--r--noncore/unsupported/oipkg/mainwindow.cpp3
-rw-r--r--noncore/unsupported/oipkg/oipkg.pro3
-rw-r--r--noncore/unsupported/oipkg/package.cpp23
-rw-r--r--noncore/unsupported/oipkg/package.h15
-rw-r--r--noncore/unsupported/oipkg/packagelist.cpp10
-rw-r--r--noncore/unsupported/oipkg/packagelist.h8
-rw-r--r--noncore/unsupported/oipkg/packagelistdoclnk.cpp8
-rw-r--r--noncore/unsupported/oipkg/packagelistdoclnk.h4
-rw-r--r--noncore/unsupported/oipkg/packagelistitem.cpp2
-rw-r--r--noncore/unsupported/oipkg/packagelistview.cpp6
-rw-r--r--noncore/unsupported/oipkg/pksettings.cpp1
-rw-r--r--noncore/unsupported/oipkg/pksettings.h2
-rw-r--r--noncore/unsupported/oipkg/pmipkg.cpp72
-rw-r--r--noncore/unsupported/oipkg/pmipkg.h10
-rw-r--r--noncore/unsupported/oipkg/settings.h2
18 files changed, 139 insertions, 49 deletions
diff --git a/noncore/unsupported/oipkg/TODO b/noncore/unsupported/oipkg/TODO
index e7b017c..6e0e6ca 100644
--- a/noncore/unsupported/oipkg/TODO
+++ b/noncore/unsupported/oipkg/TODO
@@ -1,13 +1,20 @@
-* check for networt before installing from network
-* Settings Class
-* parse "to install" and "to remove" from status
+* check for network before installing from network
+* Settings Class / new setting dialog
+* parse "to install" and "to remove" from status, and change status
+ i.e. improve status handling / modify status file
+ dest keyword in status? -> cworth
* install local file dialog
+* parse lists files after opening feed / doclnk
* qcop
* error handling
* manage links
* dependency checking
* create dest if it does not exist
* allow reinstalling
* different types of filters and searches
i.e. name, desc, files etc
* display new list after update
+* make sure oipkg installs to the correct dest when getting packet to install from list
+ dest keyword?
+* cancel button while installing
+* duplicate button for settings-servers
diff --git a/noncore/unsupported/oipkg/installdialog.cpp b/noncore/unsupported/oipkg/installdialog.cpp
index a2c9702..bb50103 100644
--- a/noncore/unsupported/oipkg/installdialog.cpp
+++ b/noncore/unsupported/oipkg/installdialog.cpp
@@ -1,107 +1,107 @@
/****************************************************************************
** Form implementation generated from reading ui file 'installdialog.ui'
**
** Created: Thu May 2 22:19:02 2002
** by: The User Interface Compiler (uic)
**
** WARNING! All changes made in this file will be lost!
****************************************************************************/
#include "installdialog.h"
#include <qcheckbox.h>
#include <qgroupbox.h>
#include <qheader.h>
#include <qlistview.h>
#include <qpushbutton.h>
#include <qlayout.h>
#include <qvariant.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
InstallDialog::InstallDialog( PackageManagerSettings* s, QWidget* parent, const char* name, bool modal, WFlags fl )
: QDialog( parent, name, modal, fl )
{
settings = s;
if ( !name )
setName( "InstallDialog" );
resize( 223, 269 );
setCaption( tr( "Install" ) );
InstallDialogLayout = new QGridLayout( this );
InstallDialogLayout->setSpacing( 2 );
InstallDialogLayout->setMargin( 2 );
ListViewPackages = new PackageListView( this,"listViewPackages",settings );
InstallDialogLayout->addWidget( ListViewPackages, 0, 0 );
GroupBoxOptions = new QGroupBox( this, "GroupBoxOptions" );
GroupBoxOptions->setTitle( tr( "Ipkg options" ) );
GroupBoxOptions->setColumnLayout(0, Qt::Vertical );
GroupBoxOptions->layout()->setSpacing( 0 );
GroupBoxOptions->layout()->setMargin( 0 );
GroupBoxOptionsLayout = new QGridLayout( GroupBoxOptions->layout() );
GroupBoxOptionsLayout->setAlignment( Qt::AlignTop );
GroupBoxOptionsLayout->setSpacing( 2 );
GroupBoxOptionsLayout->setMargin( 2 );
_force_depends = new QCheckBox( GroupBoxOptions, "_force_depends" );
QFont _force_depends_font( _force_depends->font() );
_force_depends_font.setPointSize( 8 );
_force_depends->setFont( _force_depends_font );
_force_depends->setText( tr( "-force-depends" ) );
//_force_depends->setChecked( true );
GroupBoxOptionsLayout->addWidget( _force_depends, 0, 0 );
_force_reinstall = new QCheckBox( GroupBoxOptions, "_force_reinstall" );
QFont _force_reinstall_font( _force_reinstall->font() );
_force_reinstall_font.setPointSize( 8 );
_force_reinstall->setFont( _force_reinstall_font );
_force_reinstall->setText( tr( "-force-reinstall" ) );
GroupBoxOptionsLayout->addWidget( _force_reinstall, 1, 0 );
_force_remove = new QCheckBox( GroupBoxOptions, "_force_remove" );
QFont _force_remove_font( _force_remove->font() );
_force_remove_font.setPointSize( 8 );
_force_remove->setFont( _force_remove_font );
_force_remove->setText( tr( "-force-removal-of-essential-packages" ) );
GroupBoxOptionsLayout->addWidget( _force_remove, 2, 0 );
InstallDialogLayout->addWidget( GroupBoxOptions, 1, 0 );
- toRemoveItem = new QCheckListItem( ListViewPackages, QObject::tr("To remove") );
- toInstallItem = new QCheckListItem( ListViewPackages, QObject::tr("To install") );
+ toRemoveItem = new QCheckListItem( ListViewPackages, tr("To remove") );
+ toInstallItem = new QCheckListItem( ListViewPackages, tr("To install") );
}
/*
* Destroys the object and frees any allocated resources
*/
InstallDialog::~InstallDialog()
{
// no need to delete child widgets, Qt does it all for us
}
/*
* Main event handler. Reimplemented to handle application
* font changes
*/
bool InstallDialog::event( QEvent* ev )
{
bool ret = QDialog::event( ev );
if ( ev->type() == QEvent::ApplicationFontChange ) {
QFont _force_depends_font( _force_depends->font() );
_force_depends_font.setPointSize( 8 );
_force_depends->setFont( _force_depends_font );
QFont _force_reinstall_font( _force_reinstall->font() );
_force_reinstall_font.setPointSize( 8 );
_force_reinstall->setFont( _force_reinstall_font );
QFont _force_remove_font( _force_remove->font() );
_force_remove_font.setPointSize( 8 );
_force_remove->setFont( _force_remove_font );
}
return ret;
}
diff --git a/noncore/unsupported/oipkg/main.cpp b/noncore/unsupported/oipkg/main.cpp
index de25e27..f72540c 100644
--- a/noncore/unsupported/oipkg/main.cpp
+++ b/noncore/unsupported/oipkg/main.cpp
@@ -1,25 +1,25 @@
#include "mainwindow.h"
#include <qpe/qpeapplication.h>
#include <qstring.h>
//#include <qmessagebox.h>
int debugLevel;
int main( int argc, char ** argv )
{
printf("This is oipkg\n");
- printf("$ID$\n");
+ printf("$Id$\n");
debugLevel = 2;
if (argc > 1)
{
debugLevel = QString ( argv[1] ).toInt();
qDebug("setting debug level to %i",debugLevel);
}
QPEApplication a( argc, argv );
MainWindow mw;
// if (argc > 2)
// QMessageBox::information( &mw, "oipkg","While ipkg is working\noipkg is hanging.\nPlease be patient!");
a.showMainDocumentWidget( &mw );
return a.exec();
}
diff --git a/noncore/unsupported/oipkg/mainwindow.cpp b/noncore/unsupported/oipkg/mainwindow.cpp
index 27c9f4c..11ab406 100644
--- a/noncore/unsupported/oipkg/mainwindow.cpp
+++ b/noncore/unsupported/oipkg/mainwindow.cpp
@@ -1,456 +1,459 @@
// 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 )
+// packageListServers( QObject(parent), name ),
+// packageListSearch( parent, name ),
+// packageListDocLnk( parent, name )
{
setCaption( tr("Package Manager") );
settings = new PackageManagerSettings(this,0,TRUE);
listViewPackages = new PackageListView( this,"listViewPackages",settings );
setCentralWidget( listViewPackages );
listViewPackages->addList( tr("feeds"), &packageListServers );
listViewPackages->addList( tr("ipkgfind"), &packageListSearch );
listViewPackages->addList( tr("documents"), &packageListDocLnk );
ipkg = new PmIpkg( settings, this );
packageListServers.setSettings( settings );
packageListSearch.setSettings( settings );
packageListDocLnk.setSettings( settings );
pvDebug(9,"packageListServers.update");
packageListServers.update();
pvDebug(9,"packageListDocLnk.update");
packageListDocLnk.update();
pvDebug(9,"makeMenu");
makeMenu();
makeChannel();
//opie is hardcoded default ;)
// pvDebug(9,"section->setCurrentItem");
// for (int i=0;i<section->count();i++)
// if (section->text(i)=="opie")
// section->setCurrentItem(i);
// 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()) );
pvDebug(9,"displayList");
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;
// 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() );
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 );
sectionBar->setStretchableWidget( section );
//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()
{
packageListServers.allPackages();
ipkg->loadList( &packageListSearch );
ipkg->loadList( &packageListDocLnk );
ipkg->loadList( &packageListServers );
ipkg->commit();
ipkg->clearLists();
// ##### 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()
{
packageListServers.clear();
packageListSearch.clear();
packageListDocLnk.clear();
ipkg->update();
packageListServers.update();
packageListSearch.update();
packageListDocLnk.update();
}
void MainWindow::filterList()
{
QString f = "";
if ( findAction->isOn() ) f = findEdit->text();
packageListServers.filterPackages( f );
}
void MainWindow::displayList()
{
filterList();
listViewPackages->display();
}
void MainWindow::sectionChanged()
{
disconnect( section, SIGNAL( activated(int) ),
this, SLOT( sectionChanged() ) );
disconnect( subsection, SIGNAL(activated(int) ),
this, SLOT( subSectionChanged() ) );
subsection->clear();
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() ) );
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( packageListServers.getSections() );
}
void MainWindow::setSubSections()
{
subsection->clear();
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::setDocument(const QString &fileName)
{
if ( !QFile::exists( fileName ) ) return;
ipkg->installFile( fileName );
QCopEnvelope e("QPE/System", "linkChanged(QString)");
QString lf = QString::null;
e << lf;
exit;
}
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() );
packageListSearch.update();
displayList();
}
diff --git a/noncore/unsupported/oipkg/oipkg.pro b/noncore/unsupported/oipkg/oipkg.pro
index 9e2f5f8..7f60ed8 100644
--- a/noncore/unsupported/oipkg/oipkg.pro
+++ b/noncore/unsupported/oipkg/oipkg.pro
@@ -1,36 +1,37 @@
DESTDIR = $(OPIEDIR)/bin
TEMPLATE = app
#CONFIG = qt warn_on release
CONFIG = qt warn_on debug
HEADERS = mainwindow.h \
pksettings.h \
pmipkg.h \
packagelistdoclnk.h \
installdialog.h \
utils.h \
packagelistitem.h \
packagelistremote.h \
packagelist.h \
packagelistlocal.h \
packagelistview.h \
package.h
SOURCES = main.cpp \
mainwindow.cpp \
utils.cpp \
packagelistdoclnk.cpp \
packagelistview.cpp \
installdialog.cpp \
packagelistremote.cpp \
packagelistlocal.cpp \
pksettings.cpp \
pmipkg.cpp \
packagelistitem.cpp \
packagelist.cpp \
package.cpp
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/ioclude
-LIBS += -lqpe
+LIBS += -lqpe
+LIBS += -lopie
INTERFACES = runwindow.ui \
pksettingsbase.ui
TARGET = oipkg
diff --git a/noncore/unsupported/oipkg/package.cpp b/noncore/unsupported/oipkg/package.cpp
index 4a09b40..97f7813 100644
--- a/noncore/unsupported/oipkg/package.cpp
+++ b/noncore/unsupported/oipkg/package.cpp
@@ -1,444 +1,453 @@
#include "package.h"
#include <qpe/process.h>
#include <qpe/stringutil.h>
#include <qfile.h>
#include <qtextstream.h>
#include <stdlib.h>
#include <unistd.h>
#include "debug.h"
-//Package::~Package()
-//{
-//}
+Package::Package( QObject *parent=0, const char *name=0 )
+ : QObject(parent,name)
+{
+
+}
+
+Package::~Package()
+{
+}
-Package::Package( PackageManagerSettings *s )
+Package::Package( PackageManagerSettings *s, QObject *parent=0, const char *name=0 )
+ : QObject(parent,name)
{
+ Package(parent,name);
init(s);
}
void Package::init( PackageManagerSettings *s )
{
settings = s;
_size = "";
_section = "";
_subsection = "";
_shortDesc = "";
_desc = "";
_name = "";
_toProcess = false;
_useFileName = false;
_old = false;
_status = "";
_dest = settings->getDestinationName();
_link = settings->createLinks();
_versions=0;
_version="";
}
-Package::Package( QStringList pack, PackageManagerSettings *s )
+Package::Package( QStringList pack, PackageManagerSettings *s , QObject *parent=0, const char *name=0 )
+ : QObject(parent,name)
{
init(s);
parsePackage( pack );
}
-Package::Package( QString n, PackageManagerSettings *s )
+Package::Package( QString n, PackageManagerSettings *s, QObject *parent=0, const char *name=0 )
{
init(s);
if ( !QFile::exists( n ) )
{
_name = QString( n );
}else{
pvDebug(4,"remote file: "+n);
parseIpkgFile( n );
_useFileName = true;
_fileName = QString( n );
}
}
-Package::Package( Package *pi )
+Package::Package( Package *pi, QObject *parent=0, const char *name=0 )
{
init(pi->settings);
copyValues( pi );
}
void Package::setValue( QString n, QString t )
{
if ( n == "Package" )
{
_name = QString( t );
}else if ( n == "Installed-Size" )
{
_size = t;
// }else if ( n == "Priority")
// {
}else if ( n == "Section")
{
setSection( t );
// }else if ( n == "Maintainer")
// {
//
// }else if ( n == "Architecture")
// {
}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()
{
if (_status.contains("installed"))
{
if (_status.contains("not-installed"))
{
_toProcess = true;
return false;
}
else return true;
}
else
if (_versions)
{
QDictIterator<Package> other( *_versions );
while ( other.current() )
{
if (other.current()->status().contains("installed")
&& other.current()->version() == version())
return true;
++other;
}
}
return false;
}
bool Package::otherInstalled()
{
if (_versions)
{
QDictIterator<Package> other( *_versions );
while ( other.current() )
{
if (other.current()->installed()) return true;
++other;
}
}
return false;
}
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 (_dest.isEmpty() && !pack->_dest.isEmpty()) _dest= QString( pack->_dest );
if (_displayName.isEmpty()&& !pack->_displayName.isEmpty()) _displayName = QString( pack->_displayName );
if (_fileName.isEmpty() && !pack->_fileName.isEmpty()) _fileName = QString( pack->_fileName );
if (_version.isEmpty() && !pack->_version.isEmpty()) _version = QString( pack->_version );
if (_values.isEmpty() && !pack->_values.isEmpty())_values = QDict<QString>( pack->_values );
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 )
{
if ( d == "remote") _useFileName = true;
else _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;
}
bool Package::isOld()
{
if (!_versions) return false;
QDictIterator<Package> other( *_versions );
while ( other.current() ) {
if (other.current()->version() > version() ) return true;
++other;
}
return false;
}
bool Package::hasVersions()
{
if (!_versions) return false;
else return true;
}
QDict<Package>* Package::getOtherVersions()
{
return _versions;
}
void Package::setOtherVersions(QDict<Package> *v)
{
_versions=v;
}
diff --git a/noncore/unsupported/oipkg/package.h b/noncore/unsupported/oipkg/package.h
index 68090dc..f50b9b5 100644
--- a/noncore/unsupported/oipkg/package.h
+++ b/noncore/unsupported/oipkg/package.h
@@ -1,89 +1,90 @@
#ifndef PK_ITEM_H
#define PK_ITEM_H
#include <qstring.h>
#include <qlistview.h>
#include <qpainter.h>
#include <qpixmap.h>
#include <qdict.h>
#include <qobject.h>
#include "pksettings.h"
-class Package //: public QObject
+class Package : public QObject
{
-// Q_OBJECT
+ Q_OBJECT
public:
- Package(PackageManagerSettings *);
- // ~Package();
- Package( QStringList, PackageManagerSettings * );
- Package( QString, PackageManagerSettings * );
- Package( Package* );
+ Package(QObject *parent=0, const char *name=0);
+ Package(PackageManagerSettings *s, QObject *parent=0, const char *name=0);
+ ~Package();
+ Package( QStringList, PackageManagerSettings *s, QObject *parent=0, const char *name=0 );
+ Package( QString, PackageManagerSettings *s, QObject *parent=0, const char *name=0 );
+ Package( Package*s, QObject *parent=0, const char *name=0 );
void setValue( QString, QString );
void copyValues( Package* );
QString name();
QString installName();
bool installed();
bool otherInstalled();
void setDesc( QString );
QString shortDesc();
QString desc();
QString size();
QString sizeUnits();
QString version();
void setSection( QString );
QString section();
QString subSection();
QString details();
bool toProcess();
bool toInstall();
bool toRemove();
void processed();
QString dest();
void setDest( QString d );
void setOn();
bool link();
void setLink(bool);
bool isOld();
bool hasVersions();
void parseIpkgFile( QString );
void instalFromFile(bool iff=true);
void setName(QString);
QDict<QString>* getFields();
QString status();
QDict<Package>* getOtherVersions();
void setOtherVersions(QDict<Package>*);
public slots:
void toggleProcess();
private:
PackageManagerSettings *settings;
QString _displayName;
QString _name;
QString _fileName;
bool _old;
bool _hasVersions;
bool _toProcess;
bool _link;
QString _status;
QString _size;
QString _section;
QString _subsection;
QString _shortDesc;
QString _desc;
QString _version;
QString _dest;
QDict<QString> _values;
QDict<Package> *_versions;
bool _useFileName;
void parsePackage( QStringList );
void init(PackageManagerSettings *);
};
#endif
diff --git a/noncore/unsupported/oipkg/packagelist.cpp b/noncore/unsupported/oipkg/packagelist.cpp
index 1b572e0..3cc0443 100644
--- a/noncore/unsupported/oipkg/packagelist.cpp
+++ b/noncore/unsupported/oipkg/packagelist.cpp
@@ -1,221 +1,221 @@
#include "packagelist.h"
#include <assert.h>
#include <qfile.h>
#include <qfileinfo.h>
#include <qtextstream.h>
#include "debug.h"
static QDict<Package> *packageListAll;
static int packageListAllRefCount = 0;
-PackageList::PackageList()
- : packageIter( packageList )
+PackageList::PackageList(QObject *parent=0, const char *name=0)
+ : QObject(parent,name), packageIter( packageList )
{
empty=true;
if (!packageListAll) packageListAll = new QDict<Package>();
packageListAllRefCount++;
sections << "All";
subSections.insert("All", new QStringList() );
QStringList *ss = subSections["All"];
*ss << "All";
aktSection = "All";
aktSubSection = "All";
}
-PackageList::PackageList( PackageManagerSettings* s)
- : packageIter( packageList )
+PackageList::PackageList( PackageManagerSettings* s, QObject *parent, const char *name)
+ : QObject(parent,name), packageIter( packageList )
{
settings = s;
- PackageList();
+ PackageList(parent, name);
}
PackageList::~PackageList()
{
if (--packageListAllRefCount < 1 ) delete packageListAll;
}
/** Inserts a package into the list */
void PackageList::insertPackage( Package* pack )
{
if (!pack) return;
Package* p = packageListAll->find( pack->name() );
if ( p )
{
if ( (p->version() == pack->version())
// && (p->dest() == pack->dest())
)
{
p->copyValues( pack );
delete pack;
pack = p;
} else {
QDict<Package> *packver = p->getOtherVersions();
// p->setName( pack->name()+"["+p->version()+"]" );
if (!packver)
{
packver = new QDict<Package>();
packver->insert( pack->name(), p );
p->setOtherVersions( packver );
}
pack->setName( pack->name()+"["+pack->version()+"]" );
pack->setOtherVersions( packver );
packver->insert( pack->name(), pack );
packageListAll->insert( pack->name(), pack );
packageList.insert( pack->name(), pack );
origPackageList.insert( pack->name(), pack );
}
}else{
packageListAll->insert( pack->name(), pack );
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->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->section();
if ( s.isEmpty() || s == "") return;
if ( sections.contains(s) ) return;
sections += s;
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;
}
void PackageList::readFileEntries( QString filename, QString dest )
{
pvDebug(5,"PackageList::readFileEntries "+filename+" dest "+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, settings );
if ( p )
{
p->setDest( dest );
insertPackage( p );
packEntry.clear();
}
}
}else{
packEntry << line;
};
}
delete statusStream;
return;
}
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 d0f8897..78dcd92 100644
--- a/noncore/unsupported/oipkg/packagelist.h
+++ b/noncore/unsupported/oipkg/packagelist.h
@@ -1,60 +1,60 @@
#ifndef PACKAGELIST_H
#define PACKAGELIST_H
#include <qdict.h>
#include "package.h"
#include "pksettings.h"
#include "debug.h"
-class PackageList //:QObject
+class PackageList :QObject
{
-// Q_OBJECT
+ Q_OBJECT
public:
// static QString all = QObject::tr("All");
- PackageList();
- PackageList( PackageManagerSettings* );
+ PackageList (QObject *parent=0, const char *name=0);
+ PackageList( PackageManagerSettings *s, QObject *parent=0, const char *name=0);
virtual ~PackageList();
void insertPackage( Package* );
Package* find( QString );
Package* next();
Package* first();
QStringList getSections();
QStringList getSubSections();
void setSettings( PackageManagerSettings* );
void filterPackages( QString );
Package* getByName( QString );
void clear();
void allPackages();
QDict<Package> *versions;
public slots:
void setSection(QString);
void setSubSection(QString);
// virtual void update();
protected:
int currentPackage;
int packageCount;
PackageManagerSettings *settings;
QDict<Package> packageList;
QDict<Package> origPackageList;
QDictIterator<Package> packageIter;
bool empty;
QString aktSection;
QString aktSubSection;
QStringList sections;
QDict<QStringList> subSections;
QDict<bool> sectionsDict;
void updateSections( Package* );
void readFileEntries( QString file, QString dest="" );
};
#endif
diff --git a/noncore/unsupported/oipkg/packagelistdoclnk.cpp b/noncore/unsupported/oipkg/packagelistdoclnk.cpp
index f31f742..b42cfdd 100644
--- a/noncore/unsupported/oipkg/packagelistdoclnk.cpp
+++ b/noncore/unsupported/oipkg/packagelistdoclnk.cpp
@@ -1,45 +1,45 @@
#include "packagelistdoclnk.h"
#include <qpe/applnk.h>
#include <qpe/config.h>
#include <qlist.h>
#include "package.h"
#include "pksettings.h"
-PackageListDocLnk::PackageListDocLnk(PackageManagerSettings* s)
+PackageListDocLnk::PackageListDocLnk(PackageManagerSettings* s, QObject *parent=0, const char *name=0)
: PackageList(s)
{
- PackageListDocLnk();
+ PackageListDocLnk(parent, name);
}
-PackageListDocLnk::PackageListDocLnk()
- : PackageList()
+PackageListDocLnk::PackageListDocLnk(QObject *parent=0, const char *name=0)
+ : PackageList(parent, name)
{
Config cfg( "oipkg", Config::User );
cfg.setGroup( "Common" );
docLnkDir = cfg.readEntry( "docLnkDir", "/root/" );
pvDebug(2,"opening DocLnkSet "+docLnkDir);
doclnkset = new DocLnkSet(docLnkDir,"application/ipkg");
}
PackageListDocLnk::~PackageListDocLnk()
{
Config cfg( "oipkg", Config::User );
cfg.setGroup( "Common" );
cfg.writeEntry( "docLnkDir", docLnkDir );
delete doclnkset;
}
void PackageListDocLnk::update()
{
pvDebug(2,"PackageListDocLnk::update ");
QList<DocLnk> packlist = doclnkset->children();
for (DocLnk *pack =packlist.first(); pack != 0; pack=packlist.next() )
{
insertPackage( new Package(pack->file(), settings ) );
}
}
diff --git a/noncore/unsupported/oipkg/packagelistdoclnk.h b/noncore/unsupported/oipkg/packagelistdoclnk.h
index fe73658..a63fb59 100644
--- a/noncore/unsupported/oipkg/packagelistdoclnk.h
+++ b/noncore/unsupported/oipkg/packagelistdoclnk.h
@@ -1,23 +1,23 @@
#ifndef PACKAGELISTDOCLNK_H
#define PACKAGELISTDOCLNK_H
#include "packagelist.h"
#include "debug.h"
class DocLnkSet;
class PackageListDocLnk : public PackageList
{
public:
- PackageListDocLnk();
- PackageListDocLnk( PackageManagerSettings* s);
+ PackageListDocLnk(QObject *parent=0, const char *name=0);
+ PackageListDocLnk( PackageManagerSettings *s, QObject *parent=0, const char *name=0);
virtual ~PackageListDocLnk();
public slots:
void update();
private:
DocLnkSet *doclnkset;
QString docLnkDir;
};
#endif
diff --git a/noncore/unsupported/oipkg/packagelistitem.cpp b/noncore/unsupported/oipkg/packagelistitem.cpp
index 55047d5..0c9c676 100644
--- a/noncore/unsupported/oipkg/packagelistitem.cpp
+++ b/noncore/unsupported/oipkg/packagelistitem.cpp
@@ -1,166 +1,166 @@
#include "packagelistitem.h"
#include <qpe/resource.h>
#include <qobject.h>
#include "debug.h"
static QPixmap *pm_uninstalled=0;
static QPixmap *pm_uninstalled_old=0;
static QPixmap *pm_installed=0;
static QPixmap *pm_installed_old=0;
static QPixmap *pm_uninstall=0;
static QPixmap *pm_install=0;
static QPixmap *pm_uninstalled_old_installed_new=0;
static QPixmap *pm_uninstalled_installed_old=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("Description: ")+pi->desc() );
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("Install Name: ")+pi->installName() );
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_uninstalled_old = new QPixmap(Resource::loadPixmap("oipkg/uninstalledOld"));
pm_uninstalled_old_installed_new = new QPixmap(Resource::loadPixmap("oipkg/uninstalledOldinstalledNew"));
pm_uninstalled_installed_old = new QPixmap(Resource::loadPixmap("oipkg/uninstalledInstalledOld"));
pm_installed = new QPixmap(Resource::loadPixmap("oipkg/installed"));
pm_installed_old = new QPixmap(Resource::loadPixmap("oipkg/installedOld"));
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();
bool old = package->isOld();
bool versions = package->hasVersions();
bool verinstalled = package->otherInstalled();
if ( !package->toProcess() ) {
if ( !installed )
if (old)
{
if (verinstalled) return *pm_uninstalled_old_installed_new;
else return *pm_uninstalled_old;
}
else
{
if (verinstalled) return *pm_uninstalled_installed_old;
else return *pm_uninstalled;
}
else
if (old) return *pm_installed_old;
else return *pm_installed;
} else { //toProcess() == true
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;
sod += package->sizeUnits().isEmpty()?QString(""):QString(package->sizeUnits());
//sod += QString(package->dest().isEmpty()?"":QObject::tr(" on ")+package->dest());
sod += package->dest().isEmpty()?QString(""):QString(QObject::tr(" on ")+package->dest());
sod = sod.isEmpty()?QString(""):QString(" ("+sod+")");
setText(0, package->name()+sod );
nameItem->setText( 0, QObject::tr("Name: ")+package->name());
- linkItem->setText( 0, QObject::tr("Link: ")+QString(package->link()?QObject::tr("Yes"):QObject::tr("No")) );
+ linkItem->setText( 0, QObject::tr("Link: ")+package->link()?QObject::tr("Yes"):QObject::tr("No"));
destItem->setText( 0, QObject::tr("Destination: ")+package->dest() );
statusItem->setText( 0, QObject::tr("Status: ")+package->status() );
repaint();
}
diff --git a/noncore/unsupported/oipkg/packagelistview.cpp b/noncore/unsupported/oipkg/packagelistview.cpp
index 70aa48a..2bb74e9 100644
--- a/noncore/unsupported/oipkg/packagelistview.cpp
+++ b/noncore/unsupported/oipkg/packagelistview.cpp
@@ -1,144 +1,144 @@
#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)
{
// QDictIterator<QCheckListItem> it( rootItems );
// while ( it.current() )
// {
// if ( it.current()==p )
// pvDebug(2,"current item");
// ++it;
// }
return;
}
popupTimer->start( 750, true );
}
void PackageListView::showPopup()
{
popupMenu->clear();
destsMenu->clear();
QAction *popupAction;
if ( !activePackage->installed() )
{
- popupMenu->insertItem( QObject::tr("Install to"), destsMenu );
+ popupMenu->insertItem( tr("Install to"), destsMenu );
QStringList dests = settings->getDestinationNames();
QString ad = settings->getDestinationName();
for (uint i = 0; i < dests.count(); i++ )
{
popupAction = new QAction( dests[i], QString::null, 0, this, 0 );
popupAction->addTo( destsMenu );
if ( dests[i] == ad && activePackage->toInstall() )
{
popupAction->setToggleAction( true );
popupAction->setOn(true);
};
}
connect( destsMenu, SIGNAL( activated( int ) ),
this, SLOT( changePackageDest( int ) ) );
}else{
- popupAction = new QAction( QObject::tr("Remove"),QString::null, 0, this, 0 );
+ popupAction = new QAction( tr("Remove"),QString::null, 0, this, 0 );
popupAction->addTo( popupMenu );
connect( popupAction, SIGNAL( activated() ),
this , SLOT( toggleProcess() ) );
- popupAction = new QAction( QObject::tr("Reinstall"),QString::null, 0, this, 0 );
+ popupAction = new QAction( tr("Reinstall"),QString::null, 0, this, 0 );
popupAction->addTo( popupMenu );
popupAction->setEnabled( false );
}
popupMenu->popup( QCursor::pos() );
}
void PackageListView::stopTimer( QListViewItem* )
{
popupTimer->stop();
}
void PackageListView::changePackageDest( int i )
{
activePackage->setDest( destsMenu->text(i) );
activePackage->setOn();
activePackage->setLink( settings->createLinks() );
activePackageListItem->displayDetails();
}
void PackageListView::toggleProcess()
{
activePackage->toggleProcess() ;
activePackageListItem->displayDetails();
}
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);
QCheckListItem *item = new QCheckListItem(this,n);
rootItems.insert(n, item);
}
diff --git a/noncore/unsupported/oipkg/pksettings.cpp b/noncore/unsupported/oipkg/pksettings.cpp
index 09975b0..59d5a3e 100644
--- a/noncore/unsupported/oipkg/pksettings.cpp
+++ b/noncore/unsupported/oipkg/pksettings.cpp
@@ -1,569 +1,570 @@
#include "pksettings.h"
#include <qpe/process.h>
#include <qpe/resource.h>
#include <qpe/stringutil.h>
#include <qpe/qpeapplication.h>
#include <qpe/qcopenvelope_qws.h>
#include <qpe/applnk.h>
#include <qpe/config.h>
#include <qprogressbar.h>
#include <qcombobox.h>
#include <qdict.h>
#include <qfile.h>
#include <qlineedit.h>
#include <qpushbutton.h>
#include <qlistview.h>
#include <qlistbox.h>
#include <qcheckbox.h>
#include <qmessagebox.h>
#include <qpainter.h>
#include <qpixmap.h>
#include <qregexp.h>
#include <qstring.h>
#include <qobject.h>
#include <qtextstream.h>
#include <qtextview.h>
#include <qtoolbutton.h>
#include <qtabwidget.h>
#include <stdlib.h>
#include <unistd.h>
#include "debug.h"
//#include "utils.h"
PackageManagerSettings::PackageManagerSettings( QWidget* parent, const char* name, WFlags fl )
: PackageManagerSettingsBase( parent, name, fl )
{
connect( newserver, SIGNAL(clicked()), this, SLOT(newServer()) );
connect( removeserver, SIGNAL(clicked()), this, SLOT(removeServer()) );
connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) );
connect( newdestination, SIGNAL(clicked()), this, SLOT(newDestination()) );
connect( removedestination, SIGNAL(clicked()), this, SLOT(removeDestination()) );
connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) );
// connect( CheckBoxLink, SIGNAL(toggled(bool)),
// activeLinkDestination, SLOT(setEnabled(bool)) );
connect( settingName, SIGNAL(activated(int)), this, SLOT(installationSettingChange(int)) );
connect( settingName, SIGNAL(textChanged(const QString &)), this, SLOT(installationSettingSetName(const QString &)) );
connect( newsetting, SIGNAL(clicked()), this, SLOT(newInstallationSetting()) );
connect( renamesetting, SIGNAL(clicked()), this, SLOT(renameInstallationSetting()) );
connect( removesetting, SIGNAL(clicked()), this, SLOT(removeInstallationSetting()) );
servername->setEnabled(FALSE);
serverurl->setEnabled(FALSE);
serverurlDic.setAutoDelete(TRUE);
destinationname->setEnabled(FALSE);
destinationurl->setEnabled(FALSE);
destinationurlDic.setAutoDelete(TRUE);
readSettings();
activeLinkDestination->hide();
serverChanged = false;
}
PackageManagerSettings::~PackageManagerSettings()
{
}
void PackageManagerSettings::newServer()
{
int i = servers->count();
if ( servername->isEnabled() || serverurl->text().isEmpty() ) {
serverurlDic.insert(i,new QString("http://"));
servers->insertItem(tr("New"));
activeServers->insertItem(tr("New"));
} else {
// allows one-level undo
serverurlDic.insert(i,new QString(serverurl->text()));
servers->insertItem(servername->text());
activeServers->insertItem(servername->text());
}
changed = true;
servers->setSelected(i,TRUE);
editServer(i);
changed = true;
}
void PackageManagerSettings::newDestination()
{
int i = destinations->count();
if ( destinationname->isEnabled() || destinationurl->text().isEmpty() ) {
destinationurlDic.insert(i,new QString("/"));
destinations->insertItem(tr("New"));
activeDestination->insertItem(tr("New"));
activeLinkDestination->insertItem(tr("New"));
} else {
// allows one-level undo
destinationurlDic.insert(i,new QString(destinationurl->text()));
destinations->insertItem(destinationname->text());
activeDestination->insertItem(destinationname->text());
activeLinkDestination->insertItem(destinationname->text());
}
destinations->setSelected(i,TRUE);
editDestination(i);
changed = true;
}
void PackageManagerSettings::editServer(int i)
{
if ( servername->isEnabled() ) {
disconnect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) );
disconnect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) );
} else {
servername->setEnabled(TRUE);
serverurl->setEnabled(TRUE);
}
servername->setText( servers->text(i) );
serverurl->setText( *serverurlDic[i] );
editedserver = i;
serverChanged = true;
connect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) );
connect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) );
changed = true;
}
void PackageManagerSettings::editDestination(int i)
{
if ( destinationname->isEnabled() ) {
disconnect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) );
disconnect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) );
} else {
destinationname->setEnabled(TRUE);
destinationurl->setEnabled(TRUE);
//since it does not work anyway
// createLinksButton->setEnabled(TRUE);
// removeLinksButton->setEnabled(TRUE);
}
destinationname->setText( destinations->text(i) );
destinationurl->setText( *destinationurlDic[i] );
editeddestination = i;
connect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) );
connect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) );
changed = true;
}
void PackageManagerSettings::removeServer()
{
disconnect( servername, SIGNAL(textChanged(const QString&)), this, SLOT(serverNameChanged(const QString&)) );
disconnect( serverurl, SIGNAL(textChanged(const QString&)), this, SLOT(serverUrlChanged(const QString&)) );
servername->setText(servers->text(editedserver));
serverurl->setText(*serverurlDic[editedserver]);
disconnect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) );
servers->removeItem(editedserver);
activeServers->removeItem(editedserver);
connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) );
servername->setEnabled(FALSE);
serverurl->setEnabled(FALSE);
changed = true;
}
void PackageManagerSettings::removeDestination()
{
disconnect( destinationname, SIGNAL(textChanged(const QString&)), this, SLOT(destNameChanged(const QString&)) );
disconnect( destinationurl, SIGNAL(textChanged(const QString&)), this, SLOT(destUrlChanged(const QString&)) );
destinationname->setText("");
destinationurl->setText("");
disconnect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) );
destinations->removeItem(editeddestination);
activeDestination->removeItem(editeddestination);
activeLinkDestination->removeItem(editeddestination);
editeddestination=0;
connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) );
destinationname->setEnabled(FALSE);
destinationurl->setEnabled(FALSE);
changed = true;
}
void PackageManagerSettings::serverNameChanged(const QString& t)
{
disconnect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) );
servers->changeItem( t, editedserver );
activeServers->changeItem( t, editedserver );
connect( servers, SIGNAL(highlighted(int)), this, SLOT(editServer(int)) );
changed = true;
serverChanged = true;
}
void PackageManagerSettings::destNameChanged(const QString& t)
{
disconnect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) );
destinations->changeItem( t, editeddestination );
activeDestination->changeItem( t, editeddestination );
activeLinkDestination->changeItem( t, editeddestination );
connect( destinations, SIGNAL(highlighted(int)), this, SLOT(editDestination(int)) );
changed = true;
}
void PackageManagerSettings::serverUrlChanged(const QString& t)
{
serverurlDic.replace(editedserver, new QString(t));
changed = true;
serverChanged = true;
}
void PackageManagerSettings::destUrlChanged(const QString& t)
{
destinationurlDic.replace(editeddestination, new QString(t));
changed = true;
}
void PackageManagerSettings::writeIpkgConfig(const QString& conffile)
{
QFile conf(conffile);
if ( ! conf.open(IO_WriteOnly) ) return;
QTextStream s(&conf);
s << "# Written by qpie Package Manager\n";
for (int i=0; i<(int)activeServers->count(); i++)
{
QString url = serverurlDic[i] ? *serverurlDic[i] : QString("???");
if ( !activeServers->isSelected(i) )
s << "#";
s << "src " << activeServers->text(i) << " " << url << "\n";
}
for (int i=0; i<(int)destinations->count(); i++)
{
QString url = destinationurlDic[i] ? *destinationurlDic[i] : QString("???");
s << "dest " << destinations->text(i) << " " << url << "\n";
}
conf.close();
}
void PackageManagerSettings::readInstallationSettings()
{
Config cfg( "oipkg", Config::User );
cfg.setGroup( "Settings" );
+
installationSettingsCount = cfg.readNumEntry( "count", -1 );
currentSetting = cfg.readNumEntry( "current", 0 );// o should be -1
for (int i = 0; i < installationSettingsCount; i++)
{
cfg.setGroup( "Setting_" + QString::number(i) );
settingName->insertItem( cfg.readEntry( "name", "???" ), i );
};
readInstallationSetting( currentSetting );
}
/**
* remove from conf file
*/
void PackageManagerSettings::removeInstallationSetting()
{
settingName->removeItem( settingName->currentItem() );
Config cfg( "oipkg", Config::User );
cfg.setGroup( "Setting_" + QString::number( installationSettingsCount ) );
cfg.clearGroup();
installationSettingsCount--;
changed = true;
settingName->setEditable( false );
}
/**
* write to confgile
*/
void PackageManagerSettings::newInstallationSetting()
{
installationSettingsCount++;
settingName->insertItem( "New", installationSettingsCount );
settingName->setCurrentItem( installationSettingsCount );
settingName->setEditable( true );
changed = true;
}
void PackageManagerSettings::installationSettingChange(int cs)
{
writeCurrentInstallationSetting();
currentSetting = cs;
readInstallationSetting( cs );
changed = true;
}
void PackageManagerSettings::writeInstallationSettings()
{
{
Config cfg( "oipkg", Config::User );
cfg.setGroup( "Settings" );
cfg.writeEntry( "count", installationSettingsCount );
cfg.writeEntry( "current", currentSetting );
}
writeCurrentInstallationSetting();
}
void PackageManagerSettings::readInstallationSetting(int setting)
{
if ( setting < 0 ) return;
Config cfg( "oipkg", Config::User );
cfg.setGroup( "Setting_" + QString::number( setting ) );
CheckBoxLink->setChecked( cfg.readBoolEntry( "link", true ) );
QString dest = cfg.readEntry( "dest" );
QString linkdest = cfg.readEntry( "linkdest" );
pvDebug(3, "dest="+dest);
pvDebug(3, "linkdest="+linkdest);
for ( int i = 0; i < activeDestination->count(); i++)
{
if ( activeDestination->text( i ) == dest )
activeDestination->setCurrentItem( i );
if ( activeLinkDestination->text( i ) == linkdest )
activeLinkDestination->setCurrentItem( i );
}
}
void PackageManagerSettings::writeCurrentInstallationSetting()
{
Config cfg( "oipkg", Config::User );
cfg.setGroup( "Setting_" + QString::number(currentSetting) );
cfg.writeEntry( "link", CheckBoxLink->isChecked() );
cfg.writeEntry( "dest", getDestinationName() );
cfg.writeEntry( "linkdest" , getLinkDestinationName() );
QStringList sers = getActiveServers();
int srvc = 0;
for ( QStringList::Iterator it = sers.begin(); it != sers.end(); ++it ) {
cfg.writeEntry( "server_" + QString::number(srvc++), *it );
}
cfg.writeEntry( "server_count", srvc );
}
void PackageManagerSettings::renameInstallationSetting()
{
settingName->setEditable( true );
changed = true;
}
void PackageManagerSettings::installationSettingSetName(const QString &name)
{
settingName->changeItem( name, settingName->currentItem() );
changed = true;
}
bool PackageManagerSettings::readIpkgConfig(const QString& conffile)
{
QFile conf(conffile);
changed = false;
if ( conf.open(IO_ReadOnly) ) {
QTextStream s(&conf);
servers->clear();
activeServers->clear();
destinations->clear();
activeDestination->clear();
activeLinkDestination->clear();
serverurlDic.clear();
destinationurlDic.clear();
ipkg_old=0;
int currentserver=0;
while ( !s.atEnd() ) {
QString l = s.readLine();
QStringList token = QStringList::split(' ', l);
if ( token[0] == "src" || token[0] == "#src" ) {
currentserver=servers->count();
serverurlDic.insert(servers->count(),new QString(token[2]));
int a = token[0] == "src" ? 1 : 0;
int i = servers->count();
servers->insertItem(token[1]);
activeServers->insertItem( token[1] );
activeServers->setSelected(i,a);
} else if ( token[0] == "dest" ) {
currentserver=destinations->count();
destinationurlDic.insert(destinations->count(),new QString(token[2]));
destinations->insertItem(token[1]);
activeDestination->insertItem( token[1] );
activeLinkDestination->insertItem( token[1] );
} else if ( token[0] == "option" ) {
// ### somehow need to use the settings from netsetup
// if ( token[1] == "http_proxy" )
// http->setText(token[2]);
// else if ( token[1] == "ftp_proxy" )
// ftp->setText(token[2]);
// else if ( token[1] == "proxy_username" )
// username->setText(token[2]);
// else if ( token[1] == "proxy_password" )
// password->setText(token[2]);
} else {
// Old style?
int eq = l.find('=');
if ( eq >= 0 ) {
QString v = l.mid(eq+1).stripWhiteSpace();
if ( v[0] == '"' || v[0] == '\'' ) {
int cl=v.find(v[0],1);
if ( cl >= 0 )
v = v.mid(1,cl-1);
}
if ( l.left(12) == "IPKG_SOURCE=" ) {
ipkg_old=1;
currentserver=servers->count();
serverurlDic.insert(servers->count(),new QString(v));
servers->insertItem(v);
} else if ( l.left(13) == "#IPKG_SOURCE=" ) {
serverurlDic.insert(servers->count(),new QString(v));
servers->insertItem(v);
} else if ( l.left(10) == "IPKG_ROOT=" ) {
// ### no UI
// } else if ( l.left(20) == "IPKG_PROXY_USERNAME=" ) {
// username->setText(v);
// } else if ( l.left(20) == "IPKG_PROXY_PASSWORD=" ) {
// password->setText(v);
// } else if ( l.left(16) == "IPKG_PROXY_HTTP=" ) {
// http->setText(v);
// } else if ( l.left(16) == "IPKG_PROXY_FTP=" ) {
// ftp->setText(v);
}
}
}
}
if ( ipkg_old ) {
servers->setSelectionMode(QListBox::Single);
servers->setSelected(currentserver,TRUE);
}
return TRUE;
} else {
return FALSE;
}
}
/**
* read from config file(s)
*/
void PackageManagerSettings::readSettings()
{
readIpkgConfig("/etc/ipkg.conf");
readInstallationSettings();
}
void PackageManagerSettings::writeSettings()
{
if ( changed ) 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 (changed && 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;
}
QStringList PackageManagerSettings::getServers()
{
QStringList sl;
for (int i=0; i<(int)activeServers->count(); 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 )
{
pvDebug(2,"PackageManagerSettings::linkEnabled "+QString(b?"yes":"no"));
activeLinkDestination->setEnabled( b );
}
void PackageManagerSettings::activeServerChanged()
{
changed = true;
}
QComboBox* PackageManagerSettings::getDestCombo()
{
return new QComboBox(activeDestination);
}
void PackageManagerSettings::createLinksToDest()
{
pvDebug(2,"creating links...");
// emit doCreateLinks( destinationurl->text() );
// ipkg->createLinks( destinationurl );
}
void PackageManagerSettings::removeLinksToDest()
{
pvDebug(2,"removing links...");
// emit doRemoveLinks( destinationurl->text() );
// ipkg->removeLinks( destinationurl );
}
//void PackageManagerSettings::setIpkg( PmIpkg* i )
//{
// ipkg = i;
//}
diff --git a/noncore/unsupported/oipkg/pksettings.h b/noncore/unsupported/oipkg/pksettings.h
index dcc1e3a..8f9fe62 100644
--- a/noncore/unsupported/oipkg/pksettings.h
+++ b/noncore/unsupported/oipkg/pksettings.h
@@ -1,75 +1,75 @@
#ifndef PACKAGEMANAGERSETTINGS_H
#define PACKAGEMANAGERSETTINGS_H
#include "pksettingsbase.h"
//#include "pmipkg.h"
#include <qintdict.h>
#include <qobject.h>
class PackageManagerSettings : public PackageManagerSettingsBase
{
-// Q_OBJECT
+ Q_OBJECT
public:
PackageManagerSettings( QWidget* , const char* , WFlags );
~PackageManagerSettings();
bool showDialog( int ) ;
QString getDestinationUrl();
QString getDestinationName();
QString getLinkDestinationName();
bool createLinks();
QStringList getServers();
QStringList getActiveServers();
QStringList getDestinationUrls();
QStringList getDestinationNames();
QString getDestinationUrlByName(QString);
QComboBox* getDestCombo();
// void setIpkg( PmIpkg* );
public slots:
void writeInstallationSettings();
void readInstallationSettings();
void writeCurrentInstallationSetting();
void readInstallationSetting(int);
void installationSettingSetName(const QString &);
void removeLinksToDest();
void createLinksToDest();
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();
void activeServerChanged();
signals:
// void doCreateLinks( QString dest );
// void doRemoveLinks( QString dest );
private:
QIntDict<QString> serverurlDic;
QIntDict<QString> destinationurlDic;
int ipkg_old;
int editedserver;
int editeddestination;
int currentSetting;
int installationSettingsCount;
bool changed;
bool serverChanged;
bool readIpkgConfig(const QString&);
void writeIpkgConfig(const QString&);
void writeSettings();
void readSettings();
};
#endif
diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp
index 7b3fa1e..2a534d2 100644
--- a/noncore/unsupported/oipkg/pmipkg.cpp
+++ b/noncore/unsupported/oipkg/pmipkg.cpp
@@ -1,398 +1,466 @@
#include "pmipkg.h"
#include "pksettings.h"
#include "package.h"
#include "packagelistitem.h"
-#include <qpe/process.h>
+//#infdef OPROCESS
+#include <opie/oprocess.h>
+//#endif
#include <qpe/resource.h>
#include <qpe/config.h>
#include <qpe/stringutil.h>
#include <qpe/qpeapplication.h>
#include <qdir.h>
#include <qfile.h>
#include <qgroupbox.h>
#include <qmultilineedit.h>
#include <qstring.h>
#include <qcheckbox.h>
#include <qtextstream.h>
#include <qtextview.h>
#include <qprogressbar.h>
#include <qpushbutton.h>
#include <qlayout.h>
#include <stdlib.h>
#include <unistd.h>
#include "mainwindow.h"
PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlags f )
: QObject ( p )
{
settings = s;
runwindow = new RunWindow( p, name, true, f );
+#ifdef OPROCESS
+ ipkgProcess = new OProcess();
+ connect ( ipkgProcess, SIGNAL(receivedStdout(OProcess*,char*,int)),
+ this, SLOT(getIpkgOutput(OProcess*,char*,int)));
+
+ connect ( ipkgProcess, SIGNAL(receivedStderr(OProcess*,char*,int)),
+ this, SLOT(getIpkgOutput(OProcess*,char*,int)));
+ installDialog = 0;
+#endif
}
PmIpkg::~PmIpkg()
{
+#ifdef OPROCESS
+ delete ipkgProcess;
+#endif
}
bool PmIpkg::runIpkg(const QString& args, const QString& dest )
{
bool ret=false;
QDir::setCurrent("/tmp");
QString cmd = "/usr/bin/ipkg ";
+#ifdef OPROCESS
+ ipkgProcess->clearArguments();
+ *ipkgProcess << "/usr/bin/ipkg ";
+ QString cmd = "";
+#endif
pvDebug( 3,"PmIpkg::runIpkg got dest="+dest);
if ( dest == "" )
cmd += " -dest "+settings->getDestinationName();
else
cmd += " -dest "+ dest;
cmd += " -force-defaults ";
if (installDialog && installDialog->_force_depends)
{
if (installDialog->_force_depends->isChecked())
cmd += " -force-depends ";
if (installDialog->_force_reinstall->isChecked())
cmd += " -force-reinstall ";
if (installDialog->_force_remove->isChecked())
cmd += " -force-removal-of-essential-packages ";
}
out( "Starting to "+ args+"\n");
cmd += args;
out( "running:\n"+cmd+"\n" );
pvDebug(2,"running:"+cmd);
+#ifdef OPROCESS
+ *ipkgProcess << args;
+ out( "running:\n" + cmd);
+ *ipkgProcess << cmd;
+
+//debug
+ ipkgProcess->clearArguments();
+ *ipkgProcess << "/bin/ls ";
+//debug
+ QValueList<QCString> a = ipkgProcess->args();
+ QValueList<QCString>::Iterator it;
+ for( it = a.begin(); it != a.end(); ++it )
+ {
+ out( *it );
+ cmd += *it;
+ }
+
+ pvDebug(2,"running:"+cmd);
+ qApp->processEvents();
+// sleep(1);
+ ret = ipkgProcess->start(OProcess::NotifyOnExit,OProcess::AllOutput);
+ if ( !ret ) {
+ pvDebug(2,"Could not execute '" + cmd);
+ out("\nError while executing "+ cmd+"\n\n");
+ out("\nError while executing\n\n");
+ // return false;
+ }
+
+ while ( ipkgProcess->isRunning() )
+ {
+ out(".");
+ pvDebug(7,"wait for oprocess to terminate");
+ qApp->processEvents();
+ };
+#else
qApp->processEvents();
FILE *fp;
char line[130];
QString lineStr, lineStrOld;
sleep(1);
cmd +=" 2>&1";
fp = popen( (const char *) cmd, "r");
if ( !fp ) {
qDebug("Could not execute '" + cmd + "'! err=%d", fp);
pclose(fp);
out("\nError while executing "+ cmd+"\n\n");
return false;
} else {
while ( fgets( line, sizeof line, fp)) {
lineStr = line;
lineStr=lineStr.left(lineStr.length()-1);
//Configuring opie-oipkg...Done
if (lineStr.contains("Done"))
ret = true;
if (lineStr!=lineStrOld)
out(lineStr);
lineStrOld = lineStr;
qApp->processEvents();
}
pclose(fp);
}
+#endif
//out( "Finished!");
pvDebug(2,QString(ret?"success\n":"failure\n"));
return ret;
}
void PmIpkg::makeLinks(Package *pack)
{
pvDebug( 2, "PmIpkg::makeLinks "+ pack->name());
- linkPackage( pack->installName(), pack->dest() );
+ linkPackage( pack->name(), pack->dest() );
}
QStringList* PmIpkg::getList( QString packFileName, QString d )
{
QString dest = settings->getDestinationUrlByName( d );
dest = dest==""?d:dest;
if (dest == "/" ) return 0;
{
Config cfg( "oipkg", Config::User );
cfg.setGroup( "Common" );
QString statusDir = cfg.readEntry( "statusDir", "" );
}
packFileName = dest+"/"+statusDir+"/info/"+packFileName+".list";
QFile f( packFileName );
if ( ! f.open(IO_ReadOnly) )
{
pvDebug(1," Panik! Could not open");
out( "Panik!\n Could not open:\n"+packFileName );
return (QStringList*)0;
}
QStringList *fileList = new QStringList();
QTextStream t( &f );
while ( !t.eof() )
{
*fileList += t.readLine();
}
return fileList;
}
void PmIpkg::linkPackage( QString packFileName, QString dest )
{
QStringList *fileList = getList( packFileName, dest );
processFileList( fileList, dest );
delete fileList;
}
void PmIpkg::processFileList( QStringList *fileList, QString d )
{
if (!fileList) return;
for (uint i=0; i < fileList->count(); i++)
{
QString dest = settings->getDestinationUrlByName( d );
dest = dest==""?d:dest;
processLinkDir( (*fileList)[i], dest );
}
}
void PmIpkg::processLinkDir( QString file, QString dest )
{
pvDebug( 4,"PmIpkg::processLinkDir "+file+" to "+ dest);
if (linkOpp==createLink) pvDebug( 4,"opp: createLink");
if (linkOpp==removeLink) pvDebug( 4,"opp: removeLink");
if ( dest == "???" || dest == "" ) return;
QString destFile = file;
file = dest+"/"+file;
if (file == dest) return;
// if (linkOpp==createLink) out( "\ncreating links\n" );
// if (linkOpp==removeLink) out( "\nremoving links\n" );
QFileInfo fileInfo( file );
if ( fileInfo.isDir() )
{
pvDebug(4, "process dir "+file);
QDir destDir( destFile );
if (linkOpp==createLink) destDir.mkdir( destFile, true );
QDir d( file );
// d.setFilter( QDir::Files | QDir::Hidden | QDir::NoSymLinks );
const QFileInfoList *list = d.entryInfoList();
QFileInfoListIterator it( *list );
QFileInfo *fi;
while ( (fi=it.current()) )
{
pvDebug(4, "processLinkDir "+fi->absFilePath());
processLinkDir( fi->absFilePath(), dest );
++it;
}
} else
if ( fileInfo.isFile() )
{
const char *instFile = strdup( (file).ascii() );
const char *linkFile = strdup( (destFile).ascii());
if( linkOpp==createLink )
{
pvDebug(4, "linking: "+file+" -> "+destFile );
symlink( instFile, linkFile );
}
} else {
const char *linkFile = strdup( (destFile).ascii());
if( linkOpp==removeLink )
{
QFileInfo toRemoveLink( destFile );
if ( !QFile::exists( file ) && toRemoveLink.isSymLink() )
{
pvDebug(4,"removing "+destFile+" no "+file);
unlink( linkFile );
}
}
}
}
void PmIpkg::loadList( PackageList *pl )
{
for( Package *pack = pl->first();pack ; (pack = pl->next()) )
{
if ( pack && (pack->name() != "") && pack)
{
if ( pack->toInstall() )
to_install.append( pack );
if ( pack->toRemove() )
to_remove.append( pack );
}
}
}
void PmIpkg::commit()
{
int sizecount = 0;
installDialog = new InstallDialog(settings,0,0,true);
installDialog->toRemoveItem->setOpen( true );
installDialog->toInstallItem->setOpen( true );
for (uint i=0; i < to_remove.count(); i++)
{
sizecount += 1;
installDialog->toRemoveItem->insertItem( new PackageListItem(installDialog->ListViewPackages, to_remove.at(i),settings) );
}
for (uint i=0; i < to_install.count(); i++)
{
sizecount += to_install.at(i)->size().toInt();
installDialog->toInstallItem->insertItem( new PackageListItem(installDialog->ListViewPackages, to_install.at(i),settings) );
}
runwindow->progress->setTotalSteps(sizecount);
qDebug("Install size %i",sizecount);
installDialog->showMaximized();
installDialog->show();
if ( installDialog->exec() )
{
doIt();
runwindow->showMaximized();
runwindow->show();
}
installDialog->close();
delete installDialog;
+ installDialog = 0;
out(tr("\nAll done."));
}
void PmIpkg::doIt()
{
runwindow->progress->setProgress(0);
show();
remove();
install();
}
void PmIpkg::remove()
{
if ( to_remove.count() == 0 ) return;
out(tr("Removing")+"\n"+tr("please wait")+"\n\n");
QStringList *fileList;
for (uint i=0; i < to_remove.count(); i++)
{
if ( to_remove.at(i)->link() )fileList = getList( to_remove.at(i)->name(), to_remove.at(i)->dest() );
if ( runIpkg("remove " + to_remove.at(i)->installName(), to_remove.at(i)->dest() ))
{
runwindow->progress->setProgress( 1 );
linkOpp = removeLink;
to_remove.at(i)->processed();
pvDebug(3,"link "+QString::number(i));
if ( to_remove.at(i)->link() )
processFileList( fileList, to_remove.at(i)->dest() );
//pvDebug(3,"take "+QString::number(i)+" of "+QString::number(to_remove.count()));
//if ( to_remove.at(i) ) to_remove.take( i );
out("\n");
}else{
out(tr("Error while removing ")+to_remove.at(i)->name()+"\n");
if ( to_remove.at(i)->link() )
processFileList( fileList, to_remove.at(i)->dest() );
}
if ( to_remove.at(i)->link() )
processFileList( fileList, to_remove.at(i)->dest() );
if ( to_remove.at(i)->link() )delete fileList;
}
to_remove.clear();
out("\n");
}
void PmIpkg::install()
{
if ( to_install.count() == 0 ) return;
out(tr("Installing")+"\n"+tr("please wait")+"\n");
for (uint i=0; i < to_install.count(); i++)
{
qDebug("install loop %i of %i installing %s",i,to_install.count(),to_install.at(i)->installName().latin1()); //pvDebug
if ( runIpkg("install " + to_install.at(i)->installName(), to_install.at(i)->dest() ))
{
runwindow->progress->setProgress( to_install.at(i)->size().toInt() + runwindow->progress->progress());
to_install.at(i)->processed();
linkOpp = createLink;
if ( to_install.at(i)->link() )
makeLinks( to_install.at(i) );
// to_install.take( i );
out("\n");
}else{
out(tr("Error while installing")+to_install.at(i)->name()+"\n");
linkOpp = createLink;
if ( to_install.at(i)->link() )
makeLinks( to_install.at(i) );
}
}
out("\n");
to_install.clear();
}
void PmIpkg::createLinks( const QString &dest )
{
pvDebug(2,"PmIpkg::createLinks "+dest);
linkOpp=createLink;
QString url = settings->getDestinationUrlByName( dest );
url = url==""?dest:url;
processLinkDir( "/opt", url );
processLinkDir( "/usr", url );
}
void PmIpkg::removeLinks( const QString &dest )
{
pvDebug(2,"PmIpkg::removeLinks "+dest);
linkOpp=removeLink;
QString url = settings->getDestinationUrlByName( dest );
url = url==""?dest:url;
processLinkDir( "/opt", url );
processLinkDir( "/usr", url );
}
void PmIpkg::update()
{
show();
if ( runIpkg( "update" ) )
runwindow->close();
else out("An error occurred!\nPlease check the log.");
}
void PmIpkg::out( QString o )
{
runwindow->outPut->append(o);
runwindow->outPut->setCursorPosition(runwindow->outPut->numLines() + 1,0,FALSE);
}
void PmIpkg::show()
{
if (!runwindow->isVisible())
{
runwindow->showMaximized();
runwindow->show();
}
runwindow->outPut->setText("");
}
void PmIpkg::installFile(const QString &fileName, const QString &dest)
{
to_install.clear();
to_remove.clear();
pvDebug( 2,"PmIpkg::installFile "+ fileName);
Package *p = new Package(fileName,settings);
if ( dest!="") p->setDest( dest );
to_install.append( p );
commit();
delete p;
}
void PmIpkg::removeFile(const QString &fileName, const QString &dest)
{
to_install.clear();
to_remove.clear();
pvDebug( 2,"PmIpkg::removeFile "+ fileName);
Package *p = new Package(fileName,settings);
if ( dest!="") p->setDest( dest );
to_remove.append( p );
commit();
delete p;
}
void PmIpkg::clearLists()
{
to_remove.clear();
to_install.clear();
}
+
+
+void PmIpkg::getIpkgOutput(OProcess *proc, char *buffer, int buflen)
+{
+ QString lineStr, lineStrOld;
+ lineStr = buffer;
+ lineStr=lineStr.left(buflen);
+ //Configuring opie-oipkg...Done
+ if (lineStr!=lineStrOld)
+ out(lineStr);
+ lineStrOld = lineStr;
+} \ No newline at end of file
diff --git a/noncore/unsupported/oipkg/pmipkg.h b/noncore/unsupported/oipkg/pmipkg.h
index d53a74d..2c92348 100644
--- a/noncore/unsupported/oipkg/pmipkg.h
+++ b/noncore/unsupported/oipkg/pmipkg.h
@@ -1,65 +1,65 @@
#ifndef PMIPKG_H
#define PMIPKG_H
+#include <opie/oprocess.h>
#include <qobject.h>
#include <qlist.h>
#include <qstring.h>
#include <qwidget.h>
#include "pksettings.h"
#include "runwindow.h"
#include "packagelist.h"
#include "installdialog.h"
#include "debug.h"
#define createLink 0
#define removeLink 1
class Package;
class PmIpkg : public QObject
{
Q_OBJECT
public:
PmIpkg( PackageManagerSettings* , QWidget* p=0, const char * name=0, WFlags f=0 );
~PmIpkg();
int linkOpp;
void loadList( PackageList* );
void commit();
void update();
void show();
/** No descriptions */
void clearLists();
public slots:
void doIt();
void install();
void remove();
void installFile(const QString &fileName, const QString &dest="");
void removeFile(const QString &fileName, const QString &dest="");
void createLinks( const QString &dest );
void removeLinks( const QString &dest );
+//private slots:
+ void getIpkgOutput(OProcess *proc, char *buffer, int buflen);
+
private:
+ OProcess *ipkgProcess;
PackageManagerSettings* settings;
RunWindow *runwindow;
InstallDialog *installDialog;
QList<Package> to_remove;
QList<Package> to_install;
- QString fileNameToInstall;
- QCheckBox *_force_reinstall;
- QCheckBox *_force_remove;
- QCheckBox *_force_depends;
-// void startDialog();
void makeLinks(Package*);
void linkPackage( QString, QString );
void processLinkDir( QString , QString );
bool runIpkg(const QString& args, const QString& dest="" );
void out( QString );
QStringList* getList( QString, QString );
void processFileList( QStringList*, QString );
};
#endif
diff --git a/noncore/unsupported/oipkg/settings.h b/noncore/unsupported/oipkg/settings.h
index f01cb69..9cb7a9b 100644
--- a/noncore/unsupported/oipkg/settings.h
+++ b/noncore/unsupported/oipkg/settings.h
@@ -1,67 +1,67 @@
#ifndef PACKAGEMANAGERSETTINGS_H
#define PACKAGEMANAGERSETTINGS_H
#include "pksettingsbase.h"
#include <qintdict.h>
class PackageManagerSettings : public PackageManagerSettingsBase
//class PackageManagerSettings : private PackageManagerSettingsBase
{
- // Q_OBJECT
+ Q_OBJECT
public:
PackageManagerSettings( QWidget* , const char* , WFlags );
~PackageManagerSettings();
bool showDialog( int ) ;
QString getDestinationUrl();
QString getDestinationName();
QString getLinkDestinationName();
bool createLinks();
QStringList getActiveServers();
QStringList getDestinationUrls();
public slots: /** No descriptions */
void createLinks();
void removeLinks();
void writeInstallationSettings();
void readInstallationSettings();
void writeCurrentInstallationSetting();
void readInstallationSetting(int);
void installationSettingSetName(const QString &);
void activeDestinationChange(int)
void newServer();
void editServer(int);
void removeDestination();
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 serverChanged;
bool readIpkgConfig(const QString&);
void writeIpkgConfig(const QString&);
void writeSettings();
void readSettings();
};
#endif