Commit c64426b9 authored by Rafaël Carré's avatar Rafaël Carré

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
parent 788a66f8
......@@ -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* ) );
/**
......
......@@ -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
......
......@@ -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" );
......
......@@ -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;
}
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment