#include <vlc_gcrypt.h>
#include "update.h"
+#include "../libvlc.h"
/*****************************************************************************
* Misc defines
return false;
}
-static void update_CheckReal( update_check_thread_t *p_uct );
+static void* update_CheckReal( vlc_object_t *p_this );
/**
* Check for updates
{
assert( p_update );
- update_check_thread_t *p_uct = vlc_object_create( p_update->p_libvlc,
- sizeof( update_check_thread_t ) );
+ update_check_thread_t *p_uct =
+ vlc_custom_create( p_update->p_libvlc, sizeof( *p_uct ),
+ VLC_OBJECT_GENERIC, "update check" );
if( !p_uct ) return;
p_uct->p_update = p_update;
VLC_THREAD_PRIORITY_LOW, false );
}
-void update_CheckReal( update_check_thread_t *p_uct )
+void* update_CheckReal( vlc_object_t* p_this )
{
+ update_check_thread_t *p_uct = (update_check_thread_t *)p_this;
bool b_ret;
vlc_mutex_lock( &p_uct->p_update->lock );
p_uct->p_update->p_check = NULL;
vlc_object_release( p_uct );
+ return NULL;
}
/**
* \param p_update structure
* \return true if we have to upgrade to the given version to be up to date
*/
+static bool is_strictly_greater( int * a, int * b, int n)
+{
+ if( n <= 0 ) return false;
+ if(a[0] > b[0] ) return true;
+ if(a[0] == b[0] ) return is_strictly_greater( a+1, b+1, n-1 );
+ /* a[0] < b[0] */ return false;
+}
+
bool update_NeedUpgrade( update_t *p_update )
{
assert( p_update );
- 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 - '0' ||
- p_update->release.extra < *PACKAGE_VERSION_EXTRA;
+ int current_version[] = {
+ *PACKAGE_VERSION_MAJOR - '0',
+ *PACKAGE_VERSION_MINOR - '0',
+ *PACKAGE_VERSION_REVISION - '0',
+ *PACKAGE_VERSION_EXTRA
+ };
+ int latest_version[] = {
+ p_update->release.i_major,
+ p_update->release.i_minor,
+ p_update->release.i_revision,
+ p_update->release.extra
+ };
+
+ return is_strictly_greater( latest_version, current_version, 4 );
}
/**
return i_retval == -1 ? NULL : psz_tmp;
}
-static void update_DownloadReal( update_download_thread_t *p_udt );
+static void* update_DownloadReal( vlc_object_t *p_this );
/**
* Download the file given in the update_t
{
assert( p_update );
- update_download_thread_t *p_udt = vlc_object_create( p_update->p_libvlc,
- sizeof( update_download_thread_t ) );
+ update_download_thread_t *p_udt =
+ vlc_custom_create( p_update->p_libvlc, sizeof( *p_udt ),
+ VLC_OBJECT_GENERIC, "update download" );
if( !p_udt )
return;
VLC_THREAD_PRIORITY_LOW, false );
}
-static void update_DownloadReal( update_download_thread_t *p_udt )
+static void* update_DownloadReal( vlc_object_t *p_this )
{
+ update_download_thread_t *p_udt = (update_download_thread_t *)p_this;
int i_progress = 0;
long int l_size;
long int l_downloaded = 0;
{
utf8_unlink( psz_destfile );
- intf_UserFatal( p_udt, true, _("File can not be verified"),
+ intf_UserFatal( p_udt, true, _("File could not be verified"),
_("It was not possible to download a cryptographic signature for "
- "downloaded file \"%s\", and so VLC deleted it."),
+ "the downloaded file \"%s\". Thus, it was deleted."),
psz_destfile );
msg_Err( p_udt, "Couldn't download signature of downloaded file" );
goto end;
utf8_unlink( psz_destfile );
msg_Err( p_udt, "Invalid signature issuer" );
intf_UserFatal( p_udt, true, _("Invalid signature"),
- _("The cryptographic signature for downloaded file \"%s\" was "
- "invalid and couldn't be used to securely verify it, and so "
- "VLC deleted it."),
+ _("The cryptographic signature for the downloaded file \"%s\" was "
+ "invalid and could not be used to securely verify it. Thus, the "
+ "file was deleted."),
psz_destfile );
goto end;
}
utf8_unlink( psz_destfile );
msg_Err( p_udt, "Invalid signature type" );
intf_UserFatal( p_udt, true, _("Invalid signature"),
- _("The cryptographic signature for downloaded file \"%s\" was "
- "invalid and couldn't be used to securely verify it, and so "
- "VLC deleted it."),
+ _("The cryptographic signature for the downloaded file \"%s\" was "
+ "invalid and could not be used to securely verify it. Thus, the "
+ "file was deleted."),
psz_destfile );
goto end;
}
msg_Err( p_udt, "Unable to hash %s", psz_destfile );
utf8_unlink( psz_destfile );
intf_UserFatal( p_udt, true, _("File not verifiable"),
- _("It was not possible to securely verify downloaded file \"%s\", "
- "and so VLC deleted it."),
+ _("It was not possible to securely verify the downloaded file"
+ " \"%s\". Thus, it was VLC deleted."),
psz_destfile );
goto end;
{
utf8_unlink( psz_destfile );
intf_UserFatal( p_udt, true, _("File corrupted"),
- _("Downloaded file \"%s\" was corrupted, and so VLC deleted it."),
+ _("Downloaded file \"%s\" was corrupted. Thus, it was deleted."),
psz_destfile );
msg_Err( p_udt, "Bad SHA1 hash for %s", psz_destfile );
free( p_hash );
{
utf8_unlink( psz_destfile );
intf_UserFatal( p_udt, true, _("File corrupted"),
- _("Downloaded file \"%s\" was corrupted, and so VLC deleted it."),
+ _("Downloaded file \"%s\" was corrupted. Thus, it was deleted."),
psz_destfile );
msg_Err( p_udt, "BAD SIGNATURE for %s", psz_destfile );
free( p_hash );
p_udt->p_update->p_download = NULL;
vlc_object_release( p_udt );
+ return NULL;
}
update_release_t *update_GetRelease( update_t *p_update )