]> git.sesse.net Git - vlc/blobdiff - src/misc/update.c
Protect XInitThreads() with a global lock
[vlc] / src / misc / update.c
index eea3663101e888b112cf478f30c4df78818006db..4660b0b5b0a979ec1b6f823095a18dd7a0d54261 100644 (file)
 #include <vlc_strings.h>
 #include <vlc_fs.h>
 #include <vlc_dialog.h>
+#include <vlc_interface.h>
 
 #include <gcrypt.h>
 #include <vlc_gcrypt.h>
-
+#ifdef WIN32
+#include <shellapi.h>
+#endif
 #include "update.h"
 #include "../libvlc.h"
 
@@ -275,8 +278,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;
@@ -483,11 +484,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 );
 
@@ -729,6 +730,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 );