From: Rafaël Carré Date: Tue, 15 Apr 2008 19:41:37 +0000 (+0200) Subject: Fix MacOSX update checking - inverted behavior X-Git-Tag: 0.9.0-test0~1474 X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;h=c64426b9ddac138ccad991fdf0c0f1f1f0a38333;p=vlc Fix MacOSX update checking - inverted behavior The problem came from my misreading of the API This commit also fix potential misunderstanding by simplifying it further --- diff --git a/include/vlc_update.h b/include/vlc_update.h index d80c6740d4..46add4c528 100644 --- a/include/vlc_update.h +++ b/include/vlc_update.h @@ -155,13 +155,6 @@ struct public_key_t typedef struct public_key_t public_key_t; -enum -{ - UpdateReleaseStatusOlder, - UpdateReleaseStatusEqual, - UpdateReleaseStatusNewer -}; - /** * Describes an update VLC release number */ @@ -191,7 +184,7 @@ struct update_t VLC_EXPORT( update_t *, __update_New, ( vlc_object_t * ) ); VLC_EXPORT( void, update_Delete, ( update_t * ) ); VLC_EXPORT( void, update_Check, ( update_t *, void (*callback)( void*, bool ), void * ) ); -VLC_EXPORT( int, update_CompareReleaseToCurrent, ( update_t * ) ); +VLC_EXPORT( bool, update_NeedUpgrade, ( update_t * ) ); VLC_EXPORT( void, update_Download, ( update_t *, char* ) ); /** diff --git a/modules/gui/macosx/update.m b/modules/gui/macosx/update.m index 134b367897..e201cb26fc 100644 --- a/modules/gui/macosx/update.m +++ b/modules/gui/macosx/update.m @@ -193,7 +193,7 @@ static VLCUpdate *_o_sharedInstance = nil; static void updateCallback( void * p_data, bool b_success ) { - [(id)p_data setUpToDate: !b_success || update_CompareReleaseToCurrent( ((VLCUpdate*)p_data)->p_u ) == UpdateReleaseStatusNewer ]; + [(id)p_data setUpToDate: !b_success || !update_NeedUpgrade( ((VLCUpdate*)p_data)->p_u )]; } - (void)checkForUpdate diff --git a/modules/gui/qt4/dialogs/help.cpp b/modules/gui/qt4/dialogs/help.cpp index 4f337214ba..c6ced9b08d 100644 --- a/modules/gui/qt4/dialogs/help.cpp +++ b/modules/gui/qt4/dialogs/help.cpp @@ -284,7 +284,7 @@ void UpdateDialog::updateNotify( bool b_result ) /* The update finish without errors */ if( b_result ) { - if( update_CompareReleaseToCurrent( p_update ) == UpdateReleaseStatusNewer ) + if( update_NeedUpgrade( p_update ) ) { b_checked = true; updateButton->setText( "Download" ); diff --git a/src/misc/update.c b/src/misc/update.c index 03119387e3..b84de8368c 100644 --- a/src/misc/update.c +++ b/src/misc/update.c @@ -88,8 +88,6 @@ *****************************************************************************/ static void EmptyRelease( update_t *p_update ); static bool GetUpdateFile( update_t *p_update ); -static int CompareReleases( const struct update_release_t *p1, - const struct update_release_t *p2 ); static char * size_str( long int l_size ); @@ -1145,48 +1143,20 @@ void update_CheckReal( update_check_thread_t *p_uct ) vlc_object_release( p_uct ); } -/** - * Compare two release numbers - * - * \param p1 first release - * \param p2 second release - * \return UpdateReleaseStatus(Older|Equal|Newer) - */ -static int CompareReleases( const struct update_release_t *p1, - const struct update_release_t *p2 ) -{ - int32_t d; - d = ( p1->i_major << 24 ) + ( p1->i_minor << 16 ) + ( p1->i_revision << 8 ) - - ( p2->i_major << 24 ) - ( p2->i_minor << 16 ) - ( p2->i_revision << 8 ) - + ( p1->extra ) - ( p2->extra ); - - if( d < 0 ) - return UpdateReleaseStatusOlder; - else if( d == 0 ) - return UpdateReleaseStatusEqual; - else - return UpdateReleaseStatusNewer; -} - /** * Compare a given release's version number to the current VLC's one * * \param p_update structure - * \return UpdateReleaseStatus(Older|Equal|Newer) + * \return true if we have to upgrade to the given version to be up to date */ -int update_CompareReleaseToCurrent( update_t *p_update ) +bool update_NeedUpgrade( update_t *p_update ) { assert( p_update ); - struct update_release_t c; - - /* get the current version number */ - c.i_major = *PACKAGE_VERSION_MAJOR - '0'; - c.i_minor = *PACKAGE_VERSION_MINOR - '0'; - c.i_revision = *PACKAGE_VERSION_REVISION - '0'; - c.extra = *PACKAGE_VERSION_EXTRA; - - return CompareReleases( &p_update->release, &c ); + return p_update->release.i_major < *PACKAGE_VERSION_MAJOR - '0' || + p_update->release.i_minor < *PACKAGE_VERSION_MINOR - '0' || + p_update->release.i_revision < *PACKAGE_VERSION_REVISION || + p_update->release.extra < *PACKAGE_VERSION_EXTRA; } /**