summaryrefslogtreecommitdiff
authorandyq <andyq>2002-11-02 13:52:55 (UTC)
committer andyq <andyq>2002-11-02 13:52:55 (UTC)
commitcf34849ac5c3eb9d16929cc88834973910209f74 (patch) (side-by-side diff)
tree06e189f927f88baeb16c927317153e1805a5f614
parentd21d693d91af8ee8fb54478a6db67f5a0590a767 (diff)
downloadopie-cf34849ac5c3eb9d16929cc88834973910209f74.zip
opie-cf34849ac5c3eb9d16929cc88834973910209f74.tar.gz
opie-cf34849ac5c3eb9d16929cc88834973910209f74.tar.bz2
Handles upgrading of local ipk files better and the Local-IPKG view displays
the name of the file rather thanthe package name (so version can easily be seen)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/aqpkg/global.h2
-rw-r--r--noncore/settings/aqpkg/networkpkgmgr.cpp20
-rw-r--r--noncore/settings/aqpkg/server.cpp8
3 files changed, 23 insertions, 7 deletions
diff --git a/noncore/settings/aqpkg/global.h b/noncore/settings/aqpkg/global.h
index 96ab46c..a4363b4 100644
--- a/noncore/settings/aqpkg/global.h
+++ b/noncore/settings/aqpkg/global.h
@@ -1,80 +1,80 @@
/***************************************************************************
global.h - description
-------------------
begin : Mon Aug 26 2002
copyright : (C) 2002 by Andy Qua
email : andy.qua@blueyonder.co.uk
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef __GLOBAL_H
#define __GLOBAL_H
-#define VERSION_TEXT "AQPkg Version 0.7"
+#define VERSION_TEXT "AQPkg Version 0.8"
// Uncomment the below line to run on a Linux box rather than a Zaurus
// box this allows you to change where root is, and where to load config files from
// #define X86
// Sets up location of ipkg.conf and root directory
#ifdef QWS
#ifndef X86
// Running QT/Embedded on an arm processor
#define IPKG_CONF "/etc/ipkg.conf"
#define ROOT "/"
#define IPKG_DIR "/usr/lib/ipkg/"
#else
// Running QT/Embedded on a X86 linux box
#define IPKG_CONF "/home/andy/projects/aqpkg/aqpkg/data/ipkg.conf"
#define ROOT "/home/andy/projects/aqpkg/aqpkg/data/root"
#define IPKG_DIR "/home/andy/projects/aqpkg/aqpkg/data/"
#endif
#else
// Running QT on a X86 linux box
#define IPKG_CONF "/home/andy/projects/aqpkg/aqpkg/data/ipkg.conf"
#define ROOT "/home/andy/projects/aqpkg/aqpkg/data/root"
#define IPKG_DIR "/home/andy/projects/aqpkg/aqpkg/data/"
#endif
// Uncomment the below line to turn on memory checking
//#define _DEBUG 1
#ifndef __MEMFILE_C
#ifdef _DEBUG
void * operator new(unsigned int size,const char *file, int line);
void operator delete(void *p);
#endif
#ifdef _DEBUG
#define DEBUG_NEW new(__FILE__, __LINE__)
//#define DEBUG_NEW new
#else
#define DEBUG_NEW new
#endif
#define new DEBUG_NEW
#endif
void AddTrack(long addr, long asize, const char *fname, long lnum);
void RemoveTrack(long addr);
void DumpUnfreed();
#endif
diff --git a/noncore/settings/aqpkg/networkpkgmgr.cpp b/noncore/settings/aqpkg/networkpkgmgr.cpp
index 3d06aef..dee834e 100644
--- a/noncore/settings/aqpkg/networkpkgmgr.cpp
+++ b/noncore/settings/aqpkg/networkpkgmgr.cpp
@@ -421,222 +421,232 @@ void NetworkPackageManager :: downloadPackage()
else if ( download->text() == "Remove" )
{
for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
item != 0 ;
item = (QCheckListItem *)item->nextSibling() )
{
if ( item->isOn() )
{
QString name = item->text();
int pos = name.find( "*" );
name.truncate( pos );
// if (there is a (installed), remove it
pos = name.find( "(installed)" );
if ( pos > 0 )
name.truncate( pos - 1 );
Package *p = dataMgr->getServer( serversList->currentText() )->getPackage( name );
QFile f( p->getFilename() );
f.remove();
}
}
}
dataMgr->reloadServerData();
serverSelected( -1 );
}
void NetworkPackageManager :: applyChanges()
{
stickyOption = "";
// First, write out ipkg_conf file so that ipkg can use it
dataMgr->writeOutIpkgConf();
// Now for each selected item
// deal with it
vector<InstallData> workingPackages;
for ( QCheckListItem *item = (QCheckListItem *)packagesList->firstChild();
item != 0 ;
item = (QCheckListItem *)item->nextSibling() )
{
if ( item->isOn() )
{
InstallData data = dealWithItem( item );
workingPackages.push_back( data );
}
}
if ( workingPackages.size() == 0 )
{
// Nothing to do
QMessageBox::information( this, "Nothing to do",
"No packages selected", "OK" );
return;
}
// do the stuff
InstallDlgImpl dlg( workingPackages, dataMgr, this, "Install", true );
dlg.showDlg();
// Reload data
dataMgr->reloadServerData();
serverSelected(-1);
#ifdef QWS
// Finally let the main system update itself
QCopEnvelope e("QPE/System", "linkChanged(QString)");
QString lf = QString::null;
e << lf;
#endif
}
// decide what to do - either remove, upgrade or install
// Current rules:
// If not installed - install
// If installed and different version available - upgrade
// If installed and version up to date - remove
InstallData NetworkPackageManager :: dealWithItem( QCheckListItem *item )
{
QString name = item->text();
int pos = name.find( "*" );
name.truncate( pos );
// if (there is a (installed), remove it
pos = name.find( "(installed)" );
if ( pos > 0 )
name.truncate( pos - 1 );
// Get package
Server *s = dataMgr->getServer( serversList->currentText() );
Package *p = s->getPackage( name );
- // If the package has a filename then it is a local file
- if ( p->isPackageStoredLocally() )
- name = p->getFilename();
+ // If the package has a filename then it is a local file
+ if ( p->isPackageStoredLocally() )
+ name = p->getFilename();
+
QString option;
QString dest = "root";
if ( !p->isInstalled() )
{
InstallData item;
item.option = "I";
item.packageName = name;
- return item;
+ return item;
}
else
{
InstallData item;
item.option = "D";
- item.packageName = p->getInstalledPackageName();
+ if ( !p->isPackageStoredLocally() )
+ item.packageName = p->getInstalledPackageName();
+ else
+ item.packageName = name;
+
if ( p->getInstalledTo() )
{
item.destination = p->getInstalledTo();
cout << "dest - " << p->getInstalledTo()->getDestinationName() << endl;
cout << "dest - " << p->getInstalledTo()->getDestinationPath() << endl;
}
else
{
item.destination = p->getLocalPackage()->getInstalledTo();
}
// Now see if version is newer or not
int val = compareVersions( p->getInstalledVersion(), p->getVersion() );
+
+ // If the version requested is older and user selected a local ipk file, then reinstall the file
+ if ( p->isPackageStoredLocally() && val == -1 )
+ val = 0;
+
if ( val == -2 )
{
// Error - should handle
}
else if ( val == -1 )
{
// Version available is older - remove only
item.option = "D";
}
else
{
QString caption;
QString text;
QString secondButton;
QString secondOption;
if ( val == 0 )
{
// Version available is the same - option to remove or reinstall
caption = "Do you wish to remove or reinstall\n%s?";
text = "Remove or ReInstall";
secondButton = "ReInstall";
secondOption = "R";
}
else if ( val == 1 )
{
// Version available is newer - option to remove or upgrade
caption = "Do you wish to remove or upgrade\n%s?";
text = "Remove or Upgrade";
secondButton = "Upgrade";
secondOption = "U";
}
// Sticky option not implemented yet, but will eventually allow
// the user to say something like 'remove all'
if ( stickyOption == "" )
{
QString msgtext;
msgtext.sprintf( caption, (const char *)name );
switch( QMessageBox::information( this, text,
msgtext, "Remove", secondButton ) )
{
case 0: // Try again or Enter
// option 0 = Remove
item.option = "D";
break;
case 1: // Quit or Escape
item.option = secondOption;
break;
}
}
else
{
// item.option = stickyOption;
}
}
// Check if we are reinstalling the same version
if ( item.option != "R" )
item.recreateLinks = true;
else
item.recreateLinks = false;
// User hit cancel (on dlg - assume remove)
return item;
}
}
void NetworkPackageManager :: displayText( const QString &t )
{
cout << t << endl;
}
void NetworkPackageManager :: letterPushed( QString t )
{
QCheckListItem *top = (QCheckListItem *)packagesList->firstChild();
QCheckListItem *start = (QCheckListItem *)packagesList->currentItem();
if ( packagesList->firstChild() == 0 )
return;
QCheckListItem *item;
if ( start == 0 )
{
item = (QCheckListItem *)packagesList->firstChild();
start = top;
}
else
item = (QCheckListItem *)start->nextSibling();
if ( item == 0 )
item = (QCheckListItem *)packagesList->firstChild();
do
{
if ( item->text().lower().startsWith( t.lower() ) )
{
diff --git a/noncore/settings/aqpkg/server.cpp b/noncore/settings/aqpkg/server.cpp
index 8bca892..539ebf0 100644
--- a/noncore/settings/aqpkg/server.cpp
+++ b/noncore/settings/aqpkg/server.cpp
@@ -17,257 +17,263 @@
* (at your option) any later version. *
* *
***************************************************************************/
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <iostream>
#include <fstream>
using namespace std;
#include "server.h"
#ifdef QWS
#include <qpe/global.h>
#include <qpe/applnk.h>
#include <qlist.h>
#endif
#include "utils.h"
#include "global.h"
Server :: Server( const char *name, const char *url )
{
serverName = name;
serverUrl = url;
packageFile = IPKG_DIR;
packageFile += "lists/" + serverName;
}
Server :: ~Server()
{
cleanUp();
}
void Server :: cleanUp()
{
packageList.clear();
}
void Server :: readStatusFile( vector<Destination> &destList )
{
cleanUp();
vector<Destination>::iterator dit;
bool rootRead = false;
for ( dit = destList.begin() ; dit != destList.end() ; ++dit )
{
bool installingToRoot = false;
QString path = dit->getDestinationPath();
if ( path.right( 1 ) != "/" )
path += "/";
if ( path == "/" )
{
rootRead = true;
installingToRoot = true;
}
packageFile = path + "usr/lib/ipkg/status";
readPackageFile( 0, false, installingToRoot, dit );
}
// Ensure that the root status file is read
if ( !rootRead )
{
cout << "Reading status file " << "/usr/lib/ipkg/status" << endl;
packageFile = "/usr/lib/ipkg/status";
readPackageFile( 0, false, true );
}
}
void Server :: readLocalIpks( Server *local )
{
cleanUp();
#ifdef QWS
// First, get any local IPKGs in the documents area
// Only applicable to Qtopie/Opie
DocLnkSet files;
Global::findDocuments( &files, "application/ipkg" );
// Now add the items to the list
QListIterator<DocLnk> it( files.children() );
for ( ; it.current() ; ++it )
{
// OK, we have a local IPK file, I think the standard naming conventions
// for these are packagename_version_arm.ipk
QString file = (*it)->file();
- QString packageName = Utils::getPackageNameFromIpkFilename( file );
+ // Changed to display the filename (excluding the path)
+ QString packageName = Utils::getFilenameFromIpkFilename( file );
QString ver = Utils::getPackageVersionFromIpkFilename( file );
packageList.push_back( Package( packageName ) );
packageList.back().setVersion( ver );
packageList.back().setFilename( file );
packageList.back().setPackageStoredLocally( true );
}
#else
QString names[] = { "advancedfm_0.9.1-20020811_arm.ipk", "libopie_0.9.1-20020811_arm.ipk", "libopieobex_0.9.1-20020811.1_arm.ipk", "opie-addressbook_0.9.1-20020811_arm.ipk" };
for ( int i = 0 ; i < 4 ; ++i )
{
// OK, we have a local IPK file, I think the standard naming conventions
// for these are packagename_version_arm.ipk
QString file = names[i];
int p = file.find( "_" );
QString tmp = file.mid( 0, p );
packageList.push_back( Package( tmp ) );
int p2 = file.find( "_", p+1 );
tmp = file.mid( p+1, p2-(p+1) );
packageList.back().setVersion( tmp );
packageList.back().setPackageStoredLocally( true );
}
#endif
// build local packages
buildLocalPackages( local );
}
void Server :: readPackageFile( Server *local, bool clearAll, bool installingToRoot, Destination *dest )
{
ifstream in( packageFile );
if ( !in.is_open() )
return;
char line[1001];
char k[21];
char v[1001];
QString key;
QString value;
if ( clearAll )
cleanUp();
Package *currPackage = 0;
bool newPackage = true;
do
{
in.getline( line, 1000 );
if ( in.eof() )
continue;
k[0] = '\0';
v[0] = '\0';
sscanf( line, "%[^:]: %[^\n]", k, v );
key = k;
value = v;
key = key.stripWhiteSpace();
value = value.stripWhiteSpace();
if ( key == "Package" && newPackage )
{
newPackage = false;
currPackage = getPackage( value );
if ( !currPackage )
{
packageList.push_back( Package( value ) );
currPackage = &(packageList.back());
currPackage->setInstalledTo( dest );
if ( installingToRoot )
currPackage->setInstalledToRoot( true );
}
else
{
if (currPackage->getStatus().find( "deinstall" ) != -1 )
currPackage->setInstalledTo( dest );
}
}
else if ( key == "Version" )
{
if ( currPackage )
currPackage->setVersion( value );
}
else if ( key == "Status" )
{
if ( currPackage )
currPackage->setStatus( value );
}
else if ( key == "Description" )
{
if ( currPackage )
currPackage->setDescription( value );
}
else if ( key == "Filename" )
{
if ( currPackage )
currPackage->setFilename( value );
}
else if ( key == "" )
{
newPackage = true;
}
} while ( !in.eof() );
in.close();
// build local packages
buildLocalPackages( local );
}
void Server :: buildLocalPackages( Server *local )
{
for ( unsigned int i = 0 ; i < packageList.size() ; ++i )
{
QString name = packageList[i].getPackageName();
+
+ // If the package name is an ipk name, then convert the filename to a package name
+ if ( name.find( ".ipk" ) != -1 )
+ name = Utils::getPackageNameFromIpkFilename( packageList[i].getFilename() );
+
if ( local )
packageList[i].setLocalPackage( local->getPackage( name ) );
else
packageList[i].setLocalPackage( 0 );
}
}
Package *Server :: getPackage( QString &name )
{
return getPackage( (const char *)name );
}
Package *Server :: getPackage( const char *name )
{
Package *ret = 0;
for ( unsigned int i = 0 ; i < packageList.size() && ret == 0; ++i )
{
if ( packageList[i].getPackageName() == name )
ret = &packageList[i];
}
return ret;
}
QString Server :: toString()
{
QString ret = "Server\n name - " + serverName +
"\n url - " + serverUrl +
"\n";
for ( unsigned int i = 0 ; i < packageList.size() ; ++i )
ret += "\n " + packageList[i].toString();
return ret;
}
vector<Package> &Server::getPackageList()
{
return packageList;
}