X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fmisc%2Fupdate.c;h=70df3ac1fd6a073f0b8d421f8f43fc219da95f17;hb=f7345bf58ea06d0f5e8a0c7d42c1728eff334c0c;hp=16c5ec660f32ee953e5abe04b1a68c4d83231b1a;hpb=b3b41c2c3b67c7e3aed5ccaba5eeb725e6123821;p=vlc diff --git a/src/misc/update.c b/src/misc/update.c index 16c5ec660f..70df3ac1fd 100644 --- a/src/misc/update.c +++ b/src/misc/update.c @@ -46,12 +46,15 @@ #include #include #include -#include +#include #include +#include #include #include - +#ifdef WIN32 +#include +#endif #include "update.h" #include "../libvlc.h" @@ -75,12 +78,6 @@ # define UPDATE_VLC_STATUS_URL "http://update.videolan.org/vlc/status-ce" #elif defined( WIN32 ) # define UPDATE_VLC_STATUS_URL "http://update.videolan.org/vlc/status-win-x86" -#elif defined( __APPLE__ ) -# if defined( __powerpc__ ) || defined( __ppc__ ) || defined( __ppc64__ ) -# define UPDATE_VLC_STATUS_URL "http://update.videolan.org/vlc/status-mac-ppc" -# else -# define UPDATE_VLC_STATUS_URL "http://update.videolan.org/vlc/status-mac-x86" -# endif #elif defined( SYS_BEOS ) # define UPDATE_VLC_STATUS_URL "http://update.videolan.org/vlc/status-beos-x86" #else @@ -92,13 +89,14 @@ * Update_t functions *****************************************************************************/ +#undef update_New /** * Create a new update VLC struct * * \param p_this the calling vlc_object * \return pointer to new update_t or NULL */ -update_t *__update_New( vlc_object_t *p_this ) +update_t *update_New( vlc_object_t *p_this ) { update_t *p_update; assert( p_this ); @@ -274,8 +272,6 @@ static bool GetUpdateFile( update_t *p_update ) strncpy( p_update->release.psz_desc, psz_update_data_parser, i_len ); p_update->release.psz_desc[i_len] = '\0'; - printf("desc %s\n", p_update->release.psz_desc); - /* Now that we know the status is valid, we must download its signature * to authenticate it */ signature_packet_t sign; @@ -482,11 +478,11 @@ static char *size_str( long int l_size ) char *psz_tmp = NULL; int i_retval = 0; if( l_size >> 30 ) - i_retval = asprintf( &psz_tmp, _("%.1f GB"), (float)l_size/(1<<30) ); + i_retval = asprintf( &psz_tmp, _("%.1f GiB"), (float)l_size/(1<<30) ); else if( l_size >> 20 ) - i_retval = asprintf( &psz_tmp, _("%.1f MB"), (float)l_size/(1<<20) ); + i_retval = asprintf( &psz_tmp, _("%.1f MiB"), (float)l_size/(1<<20) ); else if( l_size >> 10 ) - i_retval = asprintf( &psz_tmp, _("%.1f kB"), (float)l_size/(1<<10) ); + i_retval = asprintf( &psz_tmp, _("%.1f KiB"), (float)l_size/(1<<10) ); else i_retval = asprintf( &psz_tmp, _("%ld B"), l_size ); @@ -576,7 +572,7 @@ static void* update_DownloadReal( vlc_object_t *p_this ) if( asprintf( &psz_destfile, "%s%s", psz_destdir, psz_tmpdestfile ) == -1 ) goto end; - p_file = utf8_fopen( psz_destfile, "w" ); + p_file = vlc_fopen( psz_destfile, "w" ); if( !p_file ) { msg_Err( p_udt, "Failed to open %s for writing", psz_destfile ); @@ -646,7 +642,7 @@ static void* update_DownloadReal( vlc_object_t *p_this ) } else { - utf8_unlink( psz_destfile ); + vlc_unlink( psz_destfile ); goto end; } @@ -654,7 +650,7 @@ static void* update_DownloadReal( vlc_object_t *p_this ) if( download_signature( VLC_OBJECT( p_udt ), &sign, p_update->release.psz_url ) != VLC_SUCCESS ) { - utf8_unlink( psz_destfile ); + vlc_unlink( psz_destfile ); dialog_FatalWait( p_udt, _("File could not be verified"), _("It was not possible to download a cryptographic signature for " @@ -666,7 +662,7 @@ static void* update_DownloadReal( vlc_object_t *p_this ) if( memcmp( sign.issuer_longid, p_update->p_pkey->longid, 8 ) ) { - utf8_unlink( psz_destfile ); + vlc_unlink( psz_destfile ); msg_Err( p_udt, "Invalid signature issuer" ); dialog_FatalWait( p_udt, _("Invalid signature"), _("The cryptographic signature for the downloaded file \"%s\" was " @@ -678,7 +674,7 @@ static void* update_DownloadReal( vlc_object_t *p_this ) if( sign.type != BINARY_SIGNATURE ) { - utf8_unlink( psz_destfile ); + vlc_unlink( psz_destfile ); msg_Err( p_udt, "Invalid signature type" ); dialog_FatalWait( p_udt, _("Invalid signature"), _("The cryptographic signature for the downloaded file \"%s\" was " @@ -692,7 +688,7 @@ static void* update_DownloadReal( vlc_object_t *p_this ) if( !p_hash ) { msg_Err( p_udt, "Unable to hash %s", psz_destfile ); - utf8_unlink( psz_destfile ); + vlc_unlink( psz_destfile ); dialog_FatalWait( p_udt, _("File not verifiable"), _("It was not possible to securely verify the downloaded file" " \"%s\". Thus, it was deleted."), @@ -704,7 +700,7 @@ static void* update_DownloadReal( vlc_object_t *p_this ) if( p_hash[0] != sign.hash_verification[0] || p_hash[1] != sign.hash_verification[1] ) { - utf8_unlink( psz_destfile ); + vlc_unlink( psz_destfile ); dialog_FatalWait( p_udt, _("File corrupted"), _("Downloaded file \"%s\" was corrupted. Thus, it was deleted."), psz_destfile ); @@ -716,7 +712,7 @@ static void* update_DownloadReal( vlc_object_t *p_this ) if( verify_signature( sign.r, sign.s, &p_update->p_pkey->key, p_hash ) != VLC_SUCCESS ) { - utf8_unlink( psz_destfile ); + vlc_unlink( psz_destfile ); dialog_FatalWait( p_udt, _("File corrupted"), _("Downloaded file \"%s\" was corrupted. Thus, it was deleted."), psz_destfile ); @@ -728,6 +724,20 @@ static void* update_DownloadReal( vlc_object_t *p_this ) msg_Info( p_udt, "%s authenticated", psz_destfile ); free( p_hash ); +#ifdef WIN32 + int answer = dialog_Question( p_udt, _("Update VLC media player"), + _("The new version was successfully downloaded. Do you want to close VLC and install it now?"), + _("Install"), _("Cancel"), NULL); + + if(answer == 1) + { + wchar_t psz_wdestfile[MAX_PATH]; + MultiByteToWideChar( CP_UTF8, 0, psz_destfile, -1, psz_wdestfile, MAX_PATH ); + answer = ShellExecuteW( NULL, L"open", psz_wdestfile, NULL, NULL, SW_SHOW); + if(answer > 32) + libvlc_Quit(p_this->p_libvlc); + } +#endif end: if( p_progress ) dialog_ProgressDestroy( p_progress ); @@ -750,7 +760,8 @@ update_release_t *update_GetRelease( update_t *p_update ) } #else -update_t *__update_New( vlc_object_t *p_this ) +#undef update_New +update_t *update_New( vlc_object_t *p_this ) { (void)p_this; return NULL;