summaryrefslogtreecommitdiff
authordrw <drw>2004-02-13 18:56:44 (UTC)
committer drw <drw>2004-02-13 18:56:44 (UTC)
commited80e76bb5fd0cc8c346e3a27e4be858d5cf5c98 (patch) (unidiff)
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) (ignore 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,15 +1,18 @@
12004-02-13 Dan Williams <drw@handhelds.org> 12004-02-13 Dan Williams <drw@handhelds.org>
2 2
3 * Released version 0.3.0
3 * Fix handling of filtering options in View menu 4 * Fix handling of filtering options in View menu
5 * Do proper version string comparison
6 * Fix string alignment code in PromptDlg to eliminate QT warning messages
4 7
52004-02-12 Dan Williams <drw@handhelds.org> 82004-02-12 Dan Williams <drw@handhelds.org>
6 9
7 * Package information dialog implemented 10 * Package information dialog implemented
8 * What's This app icon enabled 11 * What's This app icon enabled
9 * Changed all QDialog::exec() occurences to QPEApplication::execDialog() 12 * Changed all QDialog::exec() occurences to QPEApplication::execDialog()
10 13
112004-01-23 Dan Williams <drw@handhelds.org> 142004-01-23 Dan Williams <drw@handhelds.org>
12 15
13 * Added package download functionality 16 * Added package download functionality
14 * Have Opie update links after install/removal so that apps 17 * Have Opie update links after install/removal so that apps
15 will display properly in Launcher 18 will display properly in Launcher
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
@@ -22,25 +22,24 @@
22 :     =  ...= . :.=- 22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32#include "oipkg.h" 32#include "oipkg.h"
33 33
34#include <stdio.h>
35#include <stdlib.h> 34#include <stdlib.h>
36#include <string.h> 35#include <string.h>
37 36
38#include <qdir.h> 37#include <qdir.h>
39#include <qfile.h> 38#include <qfile.h>
40#include <qmessagebox.h> 39#include <qmessagebox.h>
41#include <qtextstream.h> 40#include <qtextstream.h>
42 41
43const QString IPKG_CONF = "/etc/ipkg.conf"; // Fully-qualified name of Ipkg primary configuration file 42const QString IPKG_CONF = "/etc/ipkg.conf"; // Fully-qualified name of Ipkg primary configuration file
44const QString IPKG_CONF_DIR = "/etc/ipkg"; // Directory of secondary Ipkg configuration files 43const QString IPKG_CONF_DIR = "/etc/ipkg"; // Directory of secondary Ipkg configuration files
45const QString IPKG_PKG_PATH = "/usr/lib/ipkg/lists"; // Directory containing server package lists 44const QString IPKG_PKG_PATH = "/usr/lib/ipkg/lists"; // Directory containing server package lists
46const QString IPKG_STATUS_PATH = "usr/lib/ipkg/status"; // Destination status file location 45const QString IPKG_STATUS_PATH = "usr/lib/ipkg/status"; // Destination status file location
@@ -60,25 +59,24 @@ char *fIpkgResponse( char */*question*/ )
60 return 0x0; 59 return 0x0;
61} 60}
62 61
63int fIpkgStatus( char */*name*/, int /*status*/, char *desc, void */*userdata*/ ) 62int fIpkgStatus( char */*name*/, int /*status*/, char *desc, void */*userdata*/ )
64{ 63{
65 oipkg->ipkgStatus( desc ); 64 oipkg->ipkgStatus( desc );
66 return 0; 65 return 0;
67} 66}
68 67
69int fIpkgFiles( char */*name*/, char *desc, char */*version*/, pkg_state_status_t /*status*/, 68int fIpkgFiles( char */*name*/, char *desc, char */*version*/, pkg_state_status_t /*status*/,
70 void */*userdata*/ ) 69 void */*userdata*/ )
71{ 70{
72printf( "*****List*****\n%s\n", desc );
73 oipkg->ipkgList( desc ); 71 oipkg->ipkgList( desc );
74 return 0; 72 return 0;
75} 73}
76 74
77OIpkg::OIpkg( Config *config, QObject *parent, const char *name ) 75OIpkg::OIpkg( Config *config, QObject *parent, const char *name )
78 : QObject( parent, name ) 76 : QObject( parent, name )
79 , m_config( config ) 77 , m_config( config )
80 , m_confInfo( NULL ) 78 , m_confInfo( NULL )
81 , m_ipkgExecOptions( 0 ) 79 , m_ipkgExecOptions( 0 )
82 , m_ipkgExecVerbosity( 1 ) 80 , m_ipkgExecVerbosity( 1 )
83{ 81{
84 oipkg = this; 82 oipkg = this;
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
@@ -20,24 +20,26 @@
20..}^=.=       =       ; Library General Public License for more 20..}^=.=       =       ; Library General Public License for more
21++=   -.     .`     .: details. 21++=   -.     .`     .: details.
22 :     =  ...= . :.=- 22 :     =  ...= . :.=-
23 -.   .:....=;==+<; You should have received a copy of the GNU 23 -.   .:....=;==+<; You should have received a copy of the GNU
24  -_. . .   )=.  = Library General Public License along with 24  -_. . .   )=.  = Library General Public License along with
25    --        :-=` this library; see the file COPYING.LIB. 25    --        :-=` this library; see the file COPYING.LIB.
26 If not, write to the Free Software Foundation, 26 If not, write to the Free Software Foundation,
27 Inc., 59 Temple Place - Suite 330, 27 Inc., 59 Temple Place - Suite 330,
28 Boston, MA 02111-1307, USA. 28 Boston, MA 02111-1307, USA.
29 29
30*/ 30*/
31 31
32#include <ctype.h>
33
32#include <qpe/qpeapplication.h> 34#include <qpe/qpeapplication.h>
33 35
34#include "opackagemanager.h" 36#include "opackagemanager.h"
35#include "oipkgconfigdlg.h" 37#include "oipkgconfigdlg.h"
36 38
37OPackageManager::OPackageManager( Config *config, QObject *parent, const char *name ) 39OPackageManager::OPackageManager( Config *config, QObject *parent, const char *name )
38 : QObject( parent, name ) 40 : QObject( parent, name )
39 , m_config( config ) 41 , m_config( config )
40 , m_ipkg( m_config, this ) 42 , m_ipkg( m_config, this )
41 , m_packages( 9973 ) 43 , m_packages( 9973 )
42 , m_categories() 44 , m_categories()
43{ 45{
@@ -284,40 +286,127 @@ OConfItem *OPackageManager::findConfItem( OConfItem::Type type, const QString &n
284 } 286 }
285 } 287 }
286 288
287 return confItem; 289 return confItem;
288 290
289} 291}
290 292
291OPackage *OPackageManager::findPackage( const QString &name ) 293OPackage *OPackageManager::findPackage( const QString &name )
292{ 294{
293 return m_packages[ name ]; 295 return m_packages[ name ];
294} 296}
295 297
296int OPackageManager::compareVersions( const QString &version1, const QString &version2 ) 298int OPackageManager::compareVersions( const QString &ver1, const QString &ver2 )
297{ 299{
298 // TODO - do proper compare! 300 // TODO - should this be in OIpkg???
299 if ( version1 < version2 ) 301
300 return -1; 302 int epoch1, epoch2;
301 else if ( version1 > version2 ) 303 QString version1, revision1;
304 QString version2, revision2;
305
306 parseVersion( ver1, &epoch1, &version1, &revision1 );
307 parseVersion( ver2, &epoch2, &version2, &revision2 );
308
309 if ( epoch1 > epoch2 )
302 return 1; 310 return 1;
311 else if ( epoch1 < epoch2 )
312 return -1;
303 313
304 return 0; 314 int r = verrevcmp( version1.latin1(), version2.latin1() );
315 if (r)
316 return r;
317
318 r = verrevcmp( revision1.latin1(), revision2.latin1() );
319 return r;
305} 320}
306 321
307bool OPackageManager::configureDlg( bool installOptions ) 322bool OPackageManager::configureDlg( bool installOptions )
308{ 323{
309 OIpkgConfigDlg dlg( &m_ipkg, installOptions, static_cast<QWidget *>(parent()) ); 324 OIpkgConfigDlg dlg( &m_ipkg, installOptions, static_cast<QWidget *>(parent()) );
310 return ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted ); 325 return ( QPEApplication::execDialog( &dlg ) == QDialog::Accepted );
311} 326}
312 327
313void OPackageManager::saveSettings() 328void OPackageManager::saveSettings()
314{ 329{
315 m_ipkg.saveSettings(); 330 m_ipkg.saveSettings();
316} 331}
317 332
318bool OPackageManager::executeCommand( OPackage::Command command, QStringList *packages, 333bool OPackageManager::executeCommand( OPackage::Command command, QStringList *packages,
319 const QString &destination, const QObject *receiver, 334 const QString &destination, const QObject *receiver,
320 const char *slotOutput, bool rawOutput ) 335 const char *slotOutput, bool rawOutput )
321{ 336{
322 return m_ipkg.executeCommand( command, packages, destination, receiver, slotOutput, rawOutput ); 337 return m_ipkg.executeCommand( command, packages, destination, receiver, slotOutput, rawOutput );
323} 338}
339
340void OPackageManager::parseVersion( const QString &verstr, int *epoch, QString *version,
341 QString *revision )
342{
343 *epoch = 0;
344 *revision = QString::null;
345
346 // Version string is in the format "ee:vv-rv", where ee=epoch, vv=version, rv=revision
347
348 // Get epoch
349 int colonpos = verstr.find( ':' );
350 if ( colonpos > -1 )
351 {
352 *epoch = verstr.left( colonpos ).toInt();
353 }
354
355 // Get version and revision
356 int hyphenpos = verstr.find( '-', colonpos + 1 );
357 int verlen = verstr.length();
358 if ( hyphenpos > -1 )
359 {
360 *version = verstr.mid( colonpos + 1, hyphenpos - colonpos - 1 );
361 *revision = verstr.right( verlen - hyphenpos - 1 );
362 }
363 else
364 {
365 *version = verstr.right( verlen - colonpos );
366 }
367}
368
369/*
370 * libdpkg - Debian packaging suite library routines
371 * vercmp.c - comparison of version numbers
372 *
373 * Copyright (C) 1995 Ian Jackson <iwj10@cus.cam.ac.uk>
374 */
375int OPackageManager::verrevcmp( const char *val, const char *ref )
376{
377 int vc, rc;
378 long vl, rl;
379 const char *vp, *rp;
380 const char *vsep, *rsep;
381
382 if (!val) val= "";
383 if (!ref) ref= "";
384 for (;;) {
385 vp= val; while (*vp && !isdigit(*vp)) vp++;
386 rp= ref; while (*rp && !isdigit(*rp)) rp++;
387 for (;;) {
388 vc= (val == vp) ? 0 : *val++;
389 rc= (ref == rp) ? 0 : *ref++;
390 if (!rc && !vc) break;
391 if (vc && !isalpha(vc)) vc += 256; /* assumes ASCII character set */
392 if (rc && !isalpha(rc)) rc += 256;
393 if (vc != rc) return vc - rc;
394 }
395 val= vp;
396 ref= rp;
397 vl=0; if (isdigit(*vp)) vl= strtol(val,(char**)&val,10);
398 rl=0; if (isdigit(*rp)) rl= strtol(ref,(char**)&ref,10);
399 if (vl != rl) return vl - rl;
400
401 vc = *val;
402 rc = *ref;
403 vsep = strchr(".-", vc);
404 rsep = strchr(".-", rc);
405 if (vsep && !rsep) return -1;
406 if (!vsep && rsep) return +1;
407
408 if (!*val && !*ref) return 0;
409 if (!*val) return -1;
410 if (!*ref) return +1;
411 }
412}
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
@@ -71,19 +71,22 @@ public:
71 void saveSettings(); 71 void saveSettings();
72 72
73 bool executeCommand( OPackage::Command command = OPackage::NotDefined, QStringList *parameters = 0x0, 73 bool executeCommand( OPackage::Command command = OPackage::NotDefined, QStringList *parameters = 0x0,
74 const QString &destination = QString::null, const QObject *receiver = 0x0, 74 const QString &destination = QString::null, const QObject *receiver = 0x0,
75 const char *slotOutput = 0x0, bool rawOutput = true ); 75 const char *slotOutput = 0x0, bool rawOutput = true );
76 76
77private: 77private:
78 Config *m_config; // Pointer to application configuration file 78 Config *m_config; // Pointer to application configuration file
79 OIpkg m_ipkg; // OIpkg object to retrieve package/configuration information 79 OIpkg m_ipkg; // OIpkg object to retrieve package/configuration information
80 QDict<OPackage> m_packages; // Global list of available packages 80 QDict<OPackage> m_packages; // Global list of available packages
81 QStringList m_categories; // List of all categories 81 QStringList m_categories; // List of all categories
82 82
83 void parseVersion( const QString &verstr, int *epoch, QString *version, QString *revision );
84 int verrevcmp( const char *val, const char *ref );
85
83signals: 86signals:
84 void initStatus( int numSteps ); 87 void initStatus( int numSteps );
85 void statusText( const QString &status ); 88 void statusText( const QString &status );
86 void statusBar( int currStep ); 89 void statusBar( int currStep );
87}; 90};
88 91
89#endif 92#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 @@
1Package: opie-packagemanager 1Package: opie-packagemanager
2Files: plugins/application/libpackagemanager.so* bin/packagemanager pics/packagemanager apps/Settings/packagemanager.desktop 2Files: plugins/application/libpackagemanager.so* bin/packagemanager pics/packagemanager apps/Settings/packagemanager.desktop
3Priority: optional 3Priority: optional
4Section: Settings 4Section: Settings
5Depends: task-opie-minimal 5Depends: task-opie-minimal
6Replaces: packagemanager 6Replaces: packagemanager
7Architecture: arm 7Architecture: arm
8Maintainer: Dan Williams (drw@handhelds.org) 8Maintainer: Dan Williams (drw@handhelds.org)
9Description: Opie package management client 9Description: Opie package management client
10Version: 0.2.0 10Version: 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
@@ -36,25 +36,25 @@
36 36
37#include <qpe/qpeapplication.h> 37#include <qpe/qpeapplication.h>
38 38
39PromptDlg::PromptDlg( const QString &caption, const QString &text, const QString &btn1, const QString &btn2, 39PromptDlg::PromptDlg( const QString &caption, const QString &text, const QString &btn1, const QString &btn2,
40 QWidget *parent ) 40 QWidget *parent )
41 : QWidget( parent, QString::null, WType_Modal | WType_TopLevel | WStyle_Dialog ) 41 : QWidget( parent, QString::null, WType_Modal | WType_TopLevel | WStyle_Dialog )
42 , m_btnClicked( -1 ) 42 , m_btnClicked( -1 )
43{ 43{
44 setCaption( caption ); 44 setCaption( caption );
45 45
46 QGridLayout *layout = new QGridLayout( this, 2, 2, 4, 2 ); 46 QGridLayout *layout = new QGridLayout( this, 2, 2, 4, 2 );
47 QLabel *label = new QLabel( text, this ); 47 QLabel *label = new QLabel( text, this );
48 label->setAlignment( AlignCenter | AlignTop | WordBreak ); 48 label->setAlignment( AlignCenter | WordBreak );
49 layout->addMultiCellWidget( label, 0, 0, 0, 1 ); 49 layout->addMultiCellWidget( label, 0, 0, 0, 1 );
50 50
51 QPushButton *btn = new QPushButton( btn1, this ); 51 QPushButton *btn = new QPushButton( btn1, this );
52 layout->addWidget( btn, 1, 0 ); 52 layout->addWidget( btn, 1, 0 );
53 connect( btn, SIGNAL(clicked()), this, SLOT(slotBtn1Clicked()) ); 53 connect( btn, SIGNAL(clicked()), this, SLOT(slotBtn1Clicked()) );
54 54
55 btn = new QPushButton( btn2, this ); 55 btn = new QPushButton( btn2, this );
56 layout->addWidget( btn, 1, 1 ); 56 layout->addWidget( btn, 1, 1 );
57 connect( btn, SIGNAL(clicked()), this, SLOT(slotBtn2Clicked()) ); 57 connect( btn, SIGNAL(clicked()), this, SLOT(slotBtn2Clicked()) );
58} 58}
59 59
60int PromptDlg::display() 60int PromptDlg::display()