]> git.sesse.net Git - vlc/commitdiff
Fix MacOSX update checking - inverted behavior
authorRafaël Carré <funman@videolan.org>
Tue, 15 Apr 2008 19:41:37 +0000 (21:41 +0200)
committerRafaël Carré <funman@videolan.org>
Tue, 15 Apr 2008 19:43:25 +0000 (21:43 +0200)
The problem came from my misreading of the API
This commit also fix potential misunderstanding by simplifying it further

include/vlc_update.h
modules/gui/macosx/update.m
modules/gui/qt4/dialogs/help.cpp
src/misc/update.c

index d80c6740d451ea08ee9b7492702b0bb9816a4048..46add4c528853a5f576ef01ff834fe06a1fbe7b1 100644 (file)
@@ -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* ) );
 
 /**
index 134b36789780357add76734b6b4c099aad5ce079..e201cb26fce40a539d911571b98a106a480677d0 100644 (file)
@@ -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
index 4f337214bae6d6d07f77751e9f6a9f9e64973bf8..c6ced9b08dc723933f377e319b4c706728e699be 100644 (file)
@@ -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" );
index 03119387e3e9ca58e3f40004f6c3c4e209ed3f56..b84de8368cc3c5d9cca54f7be0abc2b4cb00a361 100644 (file)
@@ -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;
 }
 
 /**