summaryrefslogtreecommitdiff
authordrw <drw>2004-02-13 18:56:44 (UTC)
committer drw <drw>2004-02-13 18:56:44 (UTC)
commited80e76bb5fd0cc8c346e3a27e4be858d5cf5c98 (patch) (side-by-side diff)
tree446720b4302433a7ef6df33336605c03dc79de8d
parentf3cf623e76060c8f4ee7c2eef241de02d63a2614 (diff)
downloadopie-ed80e76bb5fd0cc8c346e3a27e4be858d5cf5c98.zip
opie-ed80e76bb5fd0cc8c346e3a27e4be858d5cf5c98.tar.gz
opie-ed80e76bb5fd0cc8c346e3a27e4be858d5cf5c98.tar.bz2
Do proper version string comparison and fix string alignment code in PromptDlg to eliminate QT warning messages
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/settings/packagemanager/ChangeLog3
-rw-r--r--noncore/settings/packagemanager/oipkg.cpp2
-rw-r--r--noncore/settings/packagemanager/opackagemanager.cpp101
-rw-r--r--noncore/settings/packagemanager/opackagemanager.h3
-rw-r--r--noncore/settings/packagemanager/opie-packagemanager.control2
-rw-r--r--noncore/settings/packagemanager/promptdlg.cpp2
6 files changed, 103 insertions, 10 deletions
diff --git a/noncore/settings/packagemanager/ChangeLog b/noncore/settings/packagemanager/ChangeLog
index 6ad724f..d53a2b3 100644
--- a/noncore/settings/packagemanager/ChangeLog
+++ b/noncore/settings/packagemanager/ChangeLog
@@ -1,19 +1,22 @@
2004-02-13 Dan Williams <drw@handhelds.org>
+ * Released version 0.3.0
* Fix handling of filtering options in View menu
+ * Do proper version string comparison
+ * Fix string alignment code in PromptDlg to eliminate QT warning messages
2004-02-12 Dan Williams <drw@handhelds.org>
* Package information dialog implemented
* What's This app icon enabled
* Changed all QDialog::exec() occurences to QPEApplication::execDialog()
2004-01-23 Dan Williams <drw@handhelds.org>
* Added package download functionality
* Have Opie update links after install/removal so that apps
will display properly in Launcher
2004-01-20 Dan Williams <drw@handhelds.org>
* Released version 0.2.0
diff --git a/noncore/settings/packagemanager/oipkg.cpp b/noncore/settings/packagemanager/oipkg.cpp
index eb07a61..086e91b 100644
--- a/noncore/settings/packagemanager/oipkg.cpp
+++ b/noncore/settings/packagemanager/oipkg.cpp
@@ -18,33 +18,32 @@
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "oipkg.h"
-#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <qdir.h>
#include <qfile.h>
#include <qmessagebox.h>
#include <qtextstream.h>
const QString IPKG_CONF = "/etc/ipkg.conf"; // Fully-qualified name of Ipkg primary configuration file
const QString IPKG_CONF_DIR = "/etc/ipkg"; // Directory of secondary Ipkg configuration files
const QString IPKG_PKG_PATH = "/usr/lib/ipkg/lists"; // Directory containing server package lists
const QString IPKG_STATUS_PATH = "usr/lib/ipkg/status"; // Destination status file location
OIpkg *oipkg;
// Ipkg callback functions
@@ -56,33 +55,32 @@ int fsignalIpkgMessage( ipkg_conf_t */*conf*/, message_level_t /*level*/, char *
}
char *fIpkgResponse( char */*question*/ )
{
return 0x0;
}
int fIpkgStatus( char */*name*/, int /*status*/, char *desc, void */*userdata*/ )
{
oipkg->ipkgStatus( desc );
return 0;
}
int fIpkgFiles( char */*name*/, char *desc, char */*version*/, pkg_state_status_t /*status*/,
void */*userdata*/ )
{
-printf( "*****List*****\n%s\n", desc );
oipkg->ipkgList( desc );
return 0;
}
OIpkg::OIpkg( Config *config, QObject *parent, const char *name )
: QObject( parent, name )
, m_config( config )
, m_confInfo( NULL )
, m_ipkgExecOptions( 0 )
, m_ipkgExecVerbosity( 1 )
{
oipkg = this;
// Initialize libipkg
if ( ipkg_init( &fsignalIpkgMessage, &fIpkgResponse, &m_ipkgArgs ) )
QMessageBox::critical( 0, tr( "OIpkg" ), tr( "Error initialing libipkg" ) );
diff --git a/noncore/settings/packagemanager/opackagemanager.cpp b/noncore/settings/packagemanager/opackagemanager.cpp
index ad2fe02..3633e05 100644
--- a/noncore/settings/packagemanager/opackagemanager.cpp
+++ b/noncore/settings/packagemanager/opackagemanager.cpp
@@ -16,32 +16,34 @@
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
+#include <ctype.h>
+
#include <qpe/qpeapplication.h>
#include "opackagemanager.h"
#include "oipkgconfigdlg.h"
OPackageManager::OPackageManager( Config *config, QObject *parent, const char *name )
: QObject( parent, name )
, m_config( config )
, m_ipkg( m_config, this )
, m_packages( 9973 )
, m_categories()
{
m_packages.setAutoDelete( true );
}
void OPackageManager::loadAvailablePackages()
@@ -280,44 +282,131 @@ OConfItem *OPackageManager::findConfItem( OConfItem::Type type, const QString &n
{
confItem = conf;
break;
}
}
}
return confItem;
}
OPackage *OPackageManager::findPackage( const QString &name )
{
return m_packages[ name ];
}
-int OPackageManager::compareVersions( const QString &version1, const QString &version2 )
+int OPackageManager::compareVersions( const QString &ver1, const QString &ver2 )
{
- // TODO - do proper compare!
- if ( version1 < version2 )
- return -1;
- else if ( version1 > version2 )
+ // TODO - should this be in OIpkg???
+
+ int epoch1, epoch2;
+ QString version1, revision1;
+ QString version2, revision2;
+
+ parseVersion( ver1, &epoch1, &version1, &revision1 );
+ parseVersion( ver2, &epoch2, &version2, &revision2 );
+
+ if ( epoch1 > epoch2 )
return 1;
+ else if ( epoch1 < epoch2 )
+ return -1;
+
+ int r = verrevcmp( version1.latin1(), version2.latin1() );
+ if (r)
+ return r;
- return 0;
+ r = verrevcmp( revision1.latin1(), revision2.latin1() );
+ return r;
}
bool OPackageManager::configureDlg( bool installOptions )
{
OIpkgConfigDlg dlg( &m_ipkg, installOptions, static_cast<QWidget *>(parent()) );
return ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted );
}
void OPackageManager::saveSettings()
{
m_ipkg.saveSettings();
}
bool OPackageManager::executeCommand( OPackage::Command command, QStringList *packages,
const QString &destination, const QObject *receiver,
const char *slotOutput, bool rawOutput )
{
return m_ipkg.executeCommand( command, packages, destination, receiver, slotOutput, rawOutput );
}
+
+void OPackageManager::parseVersion( const QString &verstr, int *epoch, QString *version,
+ QString *revision )
+{
+ *epoch = 0;
+ *revision = QString::null;
+
+ // Version string is in the format "ee:vv-rv", where ee=epoch, vv=version, rv=revision
+
+ // Get epoch
+ int colonpos = verstr.find( ':' );
+ if ( colonpos > -1 )
+ {
+ *epoch = verstr.left( colonpos ).toInt();
+ }
+
+ // Get version and revision
+ int hyphenpos = verstr.find( '-', colonpos + 1 );
+ int verlen = verstr.length();
+ if ( hyphenpos > -1 )
+ {
+ *version = verstr.mid( colonpos + 1, hyphenpos - colonpos - 1 );
+ *revision = verstr.right( verlen - hyphenpos - 1 );
+ }
+ else
+ {
+ *version = verstr.right( verlen - colonpos );
+ }
+}
+
+/*
+ * libdpkg - Debian packaging suite library routines
+ * vercmp.c - comparison of version numbers
+ *
+ * Copyright (C) 1995 Ian Jackson <iwj10@cus.cam.ac.uk>
+ */
+int OPackageManager::verrevcmp( const char *val, const char *ref )
+{
+ int vc, rc;
+ long vl, rl;
+ const char *vp, *rp;
+ const char *vsep, *rsep;
+
+ if (!val) val= "";
+ if (!ref) ref= "";
+ for (;;) {
+ vp= val; while (*vp && !isdigit(*vp)) vp++;
+ rp= ref; while (*rp && !isdigit(*rp)) rp++;
+ for (;;) {
+ vc= (val == vp) ? 0 : *val++;
+ rc= (ref == rp) ? 0 : *ref++;
+ if (!rc && !vc) break;
+ if (vc && !isalpha(vc)) vc += 256; /* assumes ASCII character set */
+ if (rc && !isalpha(rc)) rc += 256;
+ if (vc != rc) return vc - rc;
+ }
+ val= vp;
+ ref= rp;
+ vl=0; if (isdigit(*vp)) vl= strtol(val,(char**)&val,10);
+ rl=0; if (isdigit(*rp)) rl= strtol(ref,(char**)&ref,10);
+ if (vl != rl) return vl - rl;
+
+ vc = *val;
+ rc = *ref;
+ vsep = strchr(".-", vc);
+ rsep = strchr(".-", rc);
+ if (vsep && !rsep) return -1;
+ if (!vsep && rsep) return +1;
+
+ if (!*val && !*ref) return 0;
+ if (!*val) return -1;
+ if (!*ref) return +1;
+ }
+}
diff --git a/noncore/settings/packagemanager/opackagemanager.h b/noncore/settings/packagemanager/opackagemanager.h
index 871af0c..b710a51 100644
--- a/noncore/settings/packagemanager/opackagemanager.h
+++ b/noncore/settings/packagemanager/opackagemanager.h
@@ -67,23 +67,26 @@ public:
const QString &name = QString::null );
OPackage *findPackage( const QString &name = QString::null );
bool configureDlg( bool installOptions = false );
void saveSettings();
bool executeCommand( OPackage::Command command = OPackage::NotDefined, QStringList *parameters = 0x0,
const QString &destination = QString::null, const QObject *receiver = 0x0,
const char *slotOutput = 0x0, bool rawOutput = true );
private:
Config *m_config; // Pointer to application configuration file
OIpkg m_ipkg; // OIpkg object to retrieve package/configuration information
QDict<OPackage> m_packages; // Global list of available packages
QStringList m_categories; // List of all categories
+ void parseVersion( const QString &verstr, int *epoch, QString *version, QString *revision );
+ int verrevcmp( const char *val, const char *ref );
+
signals:
void initStatus( int numSteps );
void statusText( const QString &status );
void statusBar( int currStep );
};
#endif
diff --git a/noncore/settings/packagemanager/opie-packagemanager.control b/noncore/settings/packagemanager/opie-packagemanager.control
index 095e3be..5a3908e 100644
--- a/noncore/settings/packagemanager/opie-packagemanager.control
+++ b/noncore/settings/packagemanager/opie-packagemanager.control
@@ -1,10 +1,10 @@
Package: opie-packagemanager
Files: plugins/application/libpackagemanager.so* bin/packagemanager pics/packagemanager apps/Settings/packagemanager.desktop
Priority: optional
Section: Settings
Depends: task-opie-minimal
Replaces: packagemanager
Architecture: arm
Maintainer: Dan Williams (drw@handhelds.org)
Description: Opie package management client
-Version: 0.2.0
+Version: 0.3.0
diff --git a/noncore/settings/packagemanager/promptdlg.cpp b/noncore/settings/packagemanager/promptdlg.cpp
index 128e88e..4e82ba9 100644
--- a/noncore/settings/packagemanager/promptdlg.cpp
+++ b/noncore/settings/packagemanager/promptdlg.cpp
@@ -32,33 +32,33 @@
#include <qlabel.h>
#include <qlayout.h>
#include <qpushbutton.h>
#include <qwidgetlist.h>
#include <qpe/qpeapplication.h>
PromptDlg::PromptDlg( const QString &caption, const QString &text, const QString &btn1, const QString &btn2,
QWidget *parent )
: QWidget( parent, QString::null, WType_Modal | WType_TopLevel | WStyle_Dialog )
, m_btnClicked( -1 )
{
setCaption( caption );
QGridLayout *layout = new QGridLayout( this, 2, 2, 4, 2 );
QLabel *label = new QLabel( text, this );
- label->setAlignment( AlignCenter | AlignTop | WordBreak );
+ label->setAlignment( AlignCenter | WordBreak );
layout->addMultiCellWidget( label, 0, 0, 0, 1 );
QPushButton *btn = new QPushButton( btn1, this );
layout->addWidget( btn, 1, 0 );
connect( btn, SIGNAL(clicked()), this, SLOT(slotBtn1Clicked()) );
btn = new QPushButton( btn2, this );
layout->addWidget( btn, 1, 1 );
connect( btn, SIGNAL(clicked()), this, SLOT(slotBtn2Clicked()) );
}
int PromptDlg::display()
{
// Determine position of dialog. Derived from QT's QDialog::show() method.
QWidget *w = parentWidget();
QPoint p( 0, 0 );