summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/unsupported/oipkg/TODO5
-rw-r--r--noncore/unsupported/oipkg/mainwindow.cpp3
-rw-r--r--noncore/unsupported/oipkg/packagelist.cpp6
-rw-r--r--noncore/unsupported/oipkg/packagelistdoclnk.cpp1
-rw-r--r--noncore/unsupported/oipkg/packagelistremote.cpp1
-rw-r--r--noncore/unsupported/oipkg/pmipkg.cpp25
6 files changed, 24 insertions, 17 deletions
diff --git a/noncore/unsupported/oipkg/TODO b/noncore/unsupported/oipkg/TODO
index 6de54ec..b92cbb0 100644
--- a/noncore/unsupported/oipkg/TODO
+++ b/noncore/unsupported/oipkg/TODO
@@ -1,15 +1,12 @@
* Settings Class
-* tr() ;)
-* Dialog to display ipkg output live
* parse "to install" and "to remove" from status
* install local file dialog
* 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
-* mark packages from doclnk and ipkgfind installed if installed
-* show if different version is installed \ No newline at end of file
+* display new list after update \ No newline at end of file
diff --git a/noncore/unsupported/oipkg/mainwindow.cpp b/noncore/unsupported/oipkg/mainwindow.cpp
index 2fa91e3..19a1420 100644
--- a/noncore/unsupported/oipkg/mainwindow.cpp
+++ b/noncore/unsupported/oipkg/mainwindow.cpp
@@ -71,49 +71,50 @@ MainWindow::MainWindow( QWidget *parent, const char *name, WFlags f = 0 ) :
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 = new QLabel( "", toolBar );
+ 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;
diff --git a/noncore/unsupported/oipkg/packagelist.cpp b/noncore/unsupported/oipkg/packagelist.cpp
index 2fc4c41..fdd1163 100644
--- a/noncore/unsupported/oipkg/packagelist.cpp
+++ b/noncore/unsupported/oipkg/packagelist.cpp
@@ -1,78 +1,81 @@
#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 )
{
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 )
{
settings = s;
PackageList();
}
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 = 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();
@@ -161,48 +164,49 @@ 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, settings );
p->setDest( dest );
if ( p )
{
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();
diff --git a/noncore/unsupported/oipkg/packagelistdoclnk.cpp b/noncore/unsupported/oipkg/packagelistdoclnk.cpp
index 1d10adf..f31f742 100644
--- a/noncore/unsupported/oipkg/packagelistdoclnk.cpp
+++ b/noncore/unsupported/oipkg/packagelistdoclnk.cpp
@@ -8,37 +8,38 @@
#include "package.h"
#include "pksettings.h"
PackageListDocLnk::PackageListDocLnk(PackageManagerSettings* s)
: PackageList(s)
{
PackageListDocLnk();
}
PackageListDocLnk::PackageListDocLnk()
: PackageList()
{
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/packagelistremote.cpp b/noncore/unsupported/oipkg/packagelistremote.cpp
index ee54fca..e37f256 100644
--- a/noncore/unsupported/oipkg/packagelistremote.cpp
+++ b/noncore/unsupported/oipkg/packagelistremote.cpp
@@ -8,41 +8,42 @@
PackageListRemote::PackageListRemote(PackageManagerSettings* s)
: PackageList(s)
{
PackageListRemote();
}
PackageListRemote::PackageListRemote()
: PackageList()
{
}
PackageListRemote::~PackageListRemote()
{
}
void PackageListRemote::query(QString s)
{
pvDebug(4,"set query "+s);
searchString = s;
}
void PackageListRemote::update()
{
pvDebug(2,"PackageListRemote::update");
+ if (searchString.isEmpty()) return;
int r=0;
QString cmd = "wget";
QString redirect = "/tmp/oipkg.query";
// use file for output
cmd += " --output-document="+redirect;
//http://ipkgfind.handhelds.org/packages.phtml?format=pda&query=ipkg&searchtype=package&section=
QString server="http://ipkgfind.handhelds.org/";
cmd += " \""+server+"/packages.phtml";
cmd += "?format=pda&searchtype=package&section=";
cmd += "&query="+searchString;
cmd += "\"";
pvDebug(4,"search :"+cmd);
r = system(cmd.latin1());
readFileEntries( redirect );
}
diff --git a/noncore/unsupported/oipkg/pmipkg.cpp b/noncore/unsupported/oipkg/pmipkg.cpp
index f2852c3..6ef6d19 100644
--- a/noncore/unsupported/oipkg/pmipkg.cpp
+++ b/noncore/unsupported/oipkg/pmipkg.cpp
@@ -30,84 +30,85 @@
PmIpkg::PmIpkg( PackageManagerSettings* s, QWidget* p, const char * name, WFlags f )
: QObject ( p )
{
settings = s;
runwindow = new RunWindow( p, name, true, f );
}
PmIpkg::~PmIpkg()
{
}
bool PmIpkg::runIpkg(const QString& args, const QString& dest )
{
bool ret=false;
QDir::setCurrent("/tmp");
QString cmd = "/usr/bin/ipkg ";
pvDebug( 3,"PmIpkg::runIpkg got dest="+dest);
if ( dest == "" )
cmd += " -dest "+settings->getDestinationName();
else
cmd += " -dest "+ dest;
cmd += " -force-defaults ";
- if (installDialog->_force_depends)
+ 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);
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);
}
//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->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", "" );
}
@@ -135,48 +136,50 @@ void PmIpkg::linkPackage( QString packFileName, QString 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 )
{
@@ -244,87 +247,87 @@ void PmIpkg::commit()
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();
+ if ( to_remove.at(i)->link() )
+ processFileList( fileList, to_remove.at(i)->dest() );
to_remove.take( i );
- out("\n\n");
+ out("\n");
}else{
out(tr("Error while removing")+to_remove.at(i)->name()+"\n");
- }
if ( to_remove.at(i)->link() )
- {
- out( "\nremoving links\n" );
- out( "for package "+to_remove.at(i)->name()+" in "+to_remove.at(i)->dest()+"\n" );
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\n");
+ out("\n");
}else{
out(tr("Error while installing")+to_install.at(i)->name()+"\n");
- }
linkOpp = createLink;
if ( to_install.at(i)->link() )
- {
- out( "\ncreating links\n" );
- out( "for package "+to_install.at(i)->name()+" in "+to_install.at(i)->dest()+"\n" );
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 );