]> git.sesse.net Git - vlc/blob - src/misc/update.c
update: remove spurious asprintf (the string is not used).
[vlc] / src / misc / update.c
1 /*****************************************************************************
2  * update.c: VLC update checking and downloading
3  *****************************************************************************
4  * Copyright © 2005-2008 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Antoine Cellerier <dionoea -at- videolan -dot- org>
8  *          Rémi Duraffort <ivoire at via.ecp.fr>
9             Rafaël Carré <funman@videolanorg>
10  *
11  * This program is free software; you can redistribute it and/or modify
12  * it under the terms of the GNU General Public License as published by
13  * the Free Software Foundation; either release 2 of the License, or
14  * (at your option) any later release.
15  *
16  * This program is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
19  * GNU General Public License for more details.
20  *
21  * You should have received a copy of the GNU General Public License
22  * along with this program; if not, write to the Free Software
23  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
24  *****************************************************************************/
25
26 /**
27  *   \file
28  *   This file contains functions related to VLC update management
29  */
30
31 /*****************************************************************************
32  * Preamble
33  *****************************************************************************/
34
35 #ifdef HAVE_CONFIG_H
36 # include "config.h"
37 #endif
38
39 #include <vlc_common.h>
40 #include <vlc_update.h>
41
42 #ifdef UPDATE_CHECK
43
44 #include <assert.h>
45
46 #include <vlc_pgpkey.h>
47 #include <vlc_stream.h>
48 #include <vlc_strings.h>
49 #include <vlc_fs.h>
50 #include <vlc_dialog.h>
51 #include <vlc_interface.h>
52
53 #include <gcrypt.h>
54 #include <vlc_gcrypt.h>
55 #ifdef WIN32
56 #include <shellapi.h>
57 #endif
58 #include "update.h"
59 #include "../libvlc.h"
60
61 /*****************************************************************************
62  * Misc defines
63  *****************************************************************************/
64
65 /*
66  * Here is the format of these "status files" :
67  * First line is the last version: "X.Y.Ze" where:
68  *      * X is the major number
69  *      * Y is the minor number
70  *      * Z is the revision number
71  *      * e is an OPTIONAL extra letter
72  *      * AKA "0.8.6d" or "0.9.0"
73  * Second line is an url of the binary for this last version
74  * Remaining text is a required description of the update
75  */
76
77 #if defined( UNDER_CE )
78 #   define UPDATE_VLC_STATUS_URL "http://update.videolan.org/vlc/status-ce"
79 #elif defined( WIN32 )
80 #   define UPDATE_VLC_STATUS_URL "http://update.videolan.org/vlc/status-win-x86"
81 #elif defined( SYS_BEOS )
82 #       define UPDATE_VLC_STATUS_URL "http://update.videolan.org/vlc/status-beos-x86"
83 #else
84 #   define UPDATE_VLC_STATUS_URL "http://update.videolan.org/vlc/status"
85 #endif
86
87
88 /*****************************************************************************
89  * Update_t functions
90  *****************************************************************************/
91
92 #undef update_New
93 /**
94  * Create a new update VLC struct
95  *
96  * \param p_this the calling vlc_object
97  * \return pointer to new update_t or NULL
98  */
99 update_t *update_New( vlc_object_t *p_this )
100 {
101     update_t *p_update;
102     assert( p_this );
103
104     p_update = (update_t *)malloc( sizeof( update_t ) );
105     if( !p_update ) return NULL;
106
107     vlc_mutex_init( &p_update->lock );
108
109     p_update->p_libvlc = p_this->p_libvlc;
110
111     p_update->release.psz_url = NULL;
112     p_update->release.psz_desc = NULL;
113
114     p_update->p_download = NULL;
115     p_update->p_check = NULL;
116
117     p_update->p_pkey = NULL;
118     vlc_gcrypt_init();
119
120     return p_update;
121 }
122
123 /**
124  * Delete an update_t struct
125  *
126  * \param p_update update_t* pointer
127  * \return nothing
128  */
129 void update_Delete( update_t *p_update )
130 {
131     assert( p_update );
132
133     if( p_update->p_check )
134     {
135         vlc_object_kill( p_update->p_check );
136         vlc_thread_join( p_update->p_check );
137         vlc_object_release( p_update->p_check );
138     }
139
140     if( p_update->p_download )
141     {
142         vlc_object_kill( p_update->p_download );
143         vlc_thread_join( p_update->p_download );
144         vlc_object_release( p_update->p_download );
145     }
146
147     vlc_mutex_destroy( &p_update->lock );
148
149     free( p_update->release.psz_url );
150     free( p_update->release.psz_desc );
151     free( p_update->p_pkey );
152
153     free( p_update );
154 }
155
156 /**
157  * Empty the release struct
158  *
159  * \param p_update update_t* pointer
160  * \return nothing
161  */
162 static void EmptyRelease( update_t *p_update )
163 {
164     p_update->release.i_major = 0;
165     p_update->release.i_minor = 0;
166     p_update->release.i_revision = 0;
167
168     FREENULL( p_update->release.psz_url );
169     FREENULL( p_update->release.psz_desc );
170 }
171
172 /**
173  * Get the update file and parse it
174  * p_update has to be locked when calling this function
175  *
176  * \param p_update pointer to update struct
177  * \return true if the update is valid and authenticated
178  */
179 static bool GetUpdateFile( update_t *p_update )
180 {
181     stream_t *p_stream = NULL;
182     int i_major = 0;
183     int i_minor = 0;
184     int i_revision = 0;
185     unsigned char extra;
186     char *psz_version_line = NULL;
187     char *psz_update_data = NULL;
188
189     p_stream = stream_UrlNew( p_update->p_libvlc, UPDATE_VLC_STATUS_URL );
190     if( !p_stream )
191     {
192         msg_Err( p_update->p_libvlc, "Failed to open %s for reading",
193                  UPDATE_VLC_STATUS_URL );
194         goto error;
195     }
196
197     const int64_t i_read = stream_Size( p_stream );
198     psz_update_data = malloc( i_read + 1 ); /* terminating '\0' */
199     if( !psz_update_data )
200         goto error;
201
202     if( stream_Read( p_stream, psz_update_data, i_read ) != i_read )
203     {
204         msg_Err( p_update->p_libvlc, "Couldn't download update file %s",
205                 UPDATE_VLC_STATUS_URL );
206         goto error;
207     }
208     psz_update_data[i_read] = '\0';
209
210     stream_Delete( p_stream );
211     p_stream = NULL;
212
213     /* first line : version number */
214     char *psz_update_data_parser = psz_update_data;
215     size_t i_len = strcspn( psz_update_data, "\r\n" );
216     psz_update_data_parser += i_len;
217     while( *psz_update_data_parser == '\r' || *psz_update_data_parser == '\n' )
218         psz_update_data_parser++;
219
220     if( !(psz_version_line = malloc( i_len + 1)) )
221         goto error;
222     strncpy( psz_version_line, psz_update_data, i_len );
223     psz_version_line[i_len] = '\0';
224
225     p_update->release.extra = 0;
226     switch( sscanf( psz_version_line, "%i.%i.%i%c",
227                     &i_major, &i_minor, &i_revision, &extra ) )
228     {
229         case 4:
230             p_update->release.extra = extra;
231         case 3:
232             p_update->release.i_major = i_major;
233             p_update->release.i_minor = i_minor;
234             p_update->release.i_revision = i_revision;
235             break;
236         default:
237             msg_Err( p_update->p_libvlc, "Update version false formated" );
238             goto error;
239     }
240
241     /* second line : URL */
242     i_len = strcspn( psz_update_data_parser, "\r\n" );
243     if( i_len == 0 )
244     {
245         msg_Err( p_update->p_libvlc, "Update file %s is corrupted: URL missing",
246                  UPDATE_VLC_STATUS_URL );
247
248         goto error;
249     }
250
251     if( !(p_update->release.psz_url = malloc( i_len + 1)) )
252         goto error;
253     strncpy( p_update->release.psz_url, psz_update_data_parser, i_len );
254     p_update->release.psz_url[i_len] = '\0';
255
256     psz_update_data_parser += i_len;
257     while( *psz_update_data_parser == '\r' || *psz_update_data_parser == '\n' )
258         psz_update_data_parser++;
259
260     /* Remaining data : description */
261     i_len = strlen( psz_update_data_parser );
262     if( i_len == 0 )
263     {
264         msg_Err( p_update->p_libvlc,
265                 "Update file %s is corrupted: description missing",
266                 UPDATE_VLC_STATUS_URL );
267         goto error;
268     }
269
270     if( !(p_update->release.psz_desc = malloc( i_len + 1)) )
271         goto error;
272     strncpy( p_update->release.psz_desc, psz_update_data_parser, i_len );
273     p_update->release.psz_desc[i_len] = '\0';
274
275     /* Now that we know the status is valid, we must download its signature
276      * to authenticate it */
277     signature_packet_t sign;
278     if( download_signature( VLC_OBJECT( p_update->p_libvlc ), &sign,
279             UPDATE_VLC_STATUS_URL ) != VLC_SUCCESS )
280     {
281         msg_Err( p_update->p_libvlc, "Couldn't download signature of status file" );
282         goto error;
283     }
284
285     if( sign.type != BINARY_SIGNATURE && sign.type != TEXT_SIGNATURE )
286     {
287         msg_Err( p_update->p_libvlc, "Invalid signature type" );
288         goto error;
289     }
290
291     p_update->p_pkey = (public_key_t*)malloc( sizeof( public_key_t ) );
292     if( !p_update->p_pkey )
293         goto error;
294
295     if( parse_public_key( videolan_public_key, sizeof( videolan_public_key ),
296                         p_update->p_pkey, NULL ) != VLC_SUCCESS )
297     {
298         msg_Err( p_update->p_libvlc, "Couldn't parse embedded public key, something went really wrong..." );
299         FREENULL( p_update->p_pkey );
300         goto error;
301     }
302
303     memcpy( p_update->p_pkey->longid, videolan_public_key_longid, 8 );
304
305     if( memcmp( sign.issuer_longid, p_update->p_pkey->longid , 8 ) != 0 )
306     {
307         msg_Dbg( p_update->p_libvlc, "Need to download the GPG key" );
308         public_key_t *p_new_pkey = download_key(
309                 VLC_OBJECT(p_update->p_libvlc),
310                 sign.issuer_longid, videolan_public_key_longid );
311         if( !p_new_pkey )
312         {
313             msg_Err( p_update->p_libvlc, "Couldn't download GPG key" );
314             FREENULL( p_update->p_pkey );
315             goto error;
316         }
317
318         uint8_t *p_hash = hash_sha1_from_public_key( p_new_pkey );
319         if( !p_hash )
320         {
321             msg_Err( p_update->p_libvlc, "Failed to hash signature" );
322             free( p_new_pkey );
323             FREENULL( p_update->p_pkey );
324             goto error;
325         }
326
327         if( verify_signature( p_new_pkey->sig.r, p_new_pkey->sig.s,
328                     &p_update->p_pkey->key, p_hash ) == VLC_SUCCESS )
329         {
330             free( p_hash );
331             msg_Info( p_update->p_libvlc, "Key authenticated" );
332             free( p_update->p_pkey );
333             p_update->p_pkey = p_new_pkey;
334         }
335         else
336         {
337             free( p_hash );
338             msg_Err( p_update->p_libvlc, "Key signature invalid !\n" );
339             goto error;
340         }
341     }
342
343     uint8_t *p_hash = hash_sha1_from_text( psz_update_data, &sign );
344     if( !p_hash )
345     {
346         msg_Warn( p_update->p_libvlc, "Can't compute SHA1 hash for status file" );
347         goto error;
348     }
349
350     else if( p_hash[0] != sign.hash_verification[0] ||
351         p_hash[1] != sign.hash_verification[1] )
352     {
353         msg_Warn( p_update->p_libvlc, "Bad SHA1 hash for status file" );
354         goto error;
355     }
356
357     else if( verify_signature( sign.r, sign.s, &p_update->p_pkey->key, p_hash )
358             != VLC_SUCCESS )
359     {
360         msg_Err( p_update->p_libvlc, "BAD SIGNATURE for status file" );
361         goto error;
362     }
363
364     else
365     {
366         msg_Info( p_update->p_libvlc, "Status file authenticated" );
367         return true;
368     }
369
370 error:
371     if( p_stream )
372         stream_Delete( p_stream );
373     free( psz_version_line );
374     free( psz_update_data );
375     return false;
376 }
377
378 static void* update_CheckReal( vlc_object_t *p_this );
379
380 /**
381  * Check for updates
382  *
383  * \param p_update pointer to update struct
384  * \param pf_callback pointer to a function to call when the update_check is finished
385  * \param p_data pointer to some datas to give to the callback
386  * \returns nothing
387  */
388 void update_Check( update_t *p_update, void (*pf_callback)( void*, bool ), void *p_data )
389 {
390     assert( p_update );
391
392     // If the object already exist, destroy it
393     if( p_update->p_check )
394     {
395         vlc_object_kill( p_update->p_check );
396         vlc_thread_join( p_update->p_check );
397         vlc_object_release( p_update->p_check );
398     }
399
400     update_check_thread_t *p_uct =
401         vlc_custom_create( p_update->p_libvlc, sizeof( *p_uct ),
402                            VLC_OBJECT_GENERIC, "update check" );
403     if( !p_uct ) return;
404
405     p_uct->p_update = p_update;
406     p_update->p_check = p_uct;
407     p_uct->pf_callback = pf_callback;
408     p_uct->p_data = p_data;
409
410     vlc_thread_create( p_uct, "check for update", update_CheckReal,
411                        VLC_THREAD_PRIORITY_LOW );
412 }
413
414 void* update_CheckReal( vlc_object_t* p_this )
415 {
416     update_check_thread_t *p_uct = (update_check_thread_t *)p_this;
417     bool b_ret;
418     int canc;
419
420     canc = vlc_savecancel ();
421     vlc_mutex_lock( &p_uct->p_update->lock );
422
423     EmptyRelease( p_uct->p_update );
424     b_ret = GetUpdateFile( p_uct->p_update );
425     vlc_mutex_unlock( &p_uct->p_update->lock );
426
427     if( p_uct->pf_callback )
428         (p_uct->pf_callback)( p_uct->p_data, b_ret );
429
430     vlc_restorecancel (canc);
431     return NULL;
432 }
433
434 /**
435  * Compare a given release's version number to the current VLC's one
436  *
437  * \param p_update structure
438  * \return true if we have to upgrade to the given version to be up to date
439  */
440 static bool is_strictly_greater( int * a, int * b, int n)
441 {
442     if( n <= 0 ) return false;
443     if(a[0] > b[0] ) return true;
444     if(a[0] == b[0] ) return is_strictly_greater( a+1, b+1, n-1 );
445     /* a[0] < b[0] */ return false;
446 }
447
448 bool update_NeedUpgrade( update_t *p_update )
449 {
450     assert( p_update );
451
452     int current_version[] = {
453         *PACKAGE_VERSION_MAJOR - '0',
454         *PACKAGE_VERSION_MINOR - '0',
455         *PACKAGE_VERSION_REVISION - '0',
456         /* extra string of development versions is "-git", "-rc" ..
457          * so make sure version a.b.c is newer than a.b.c-XXX */
458         (*PACKAGE_VERSION_EXTRA == '-') ? -1 : *PACKAGE_VERSION_EXTRA
459     };
460     int latest_version[] = {
461         p_update->release.i_major,
462         p_update->release.i_minor,
463         p_update->release.i_revision,
464         p_update->release.extra
465     };
466
467     return is_strictly_greater( latest_version, current_version, 4 );
468 }
469
470 /**
471  * Convert a long int size in bytes to a string
472  *
473  * \param l_size the size in bytes
474  * \return the size as a string
475  */
476 static char *size_str( long int l_size )
477 {
478     char *psz_tmp = NULL;
479     int i_retval = 0;
480     if( l_size >> 30 )
481         i_retval = asprintf( &psz_tmp, _("%.1f GiB"), (float)l_size/(1<<30) );
482     else if( l_size >> 20 )
483         i_retval = asprintf( &psz_tmp, _("%.1f MiB"), (float)l_size/(1<<20) );
484     else if( l_size >> 10 )
485         i_retval = asprintf( &psz_tmp, _("%.1f KiB"), (float)l_size/(1<<10) );
486     else
487         i_retval = asprintf( &psz_tmp, _("%ld B"), l_size );
488
489     return i_retval == -1 ? NULL : psz_tmp;
490 }
491
492 static void* update_DownloadReal( vlc_object_t *p_this );
493
494 /**
495  * Download the file given in the update_t
496  *
497  * \param p_update structure
498  * \param dir to store the download file
499  * \return nothing
500  */
501 void update_Download( update_t *p_update, const char *psz_destdir )
502 {
503     assert( p_update );
504
505     // If the object already exist, destroy it
506     if( p_update->p_download )
507     {
508         vlc_object_kill( p_update->p_download );
509         vlc_thread_join( p_update->p_download );
510         vlc_object_release( p_update->p_download );
511     }
512
513     update_download_thread_t *p_udt =
514         vlc_custom_create( p_update->p_libvlc, sizeof( *p_udt ),
515                            VLC_OBJECT_GENERIC, "update download" );
516     if( !p_udt )
517         return;
518
519     p_udt->p_update = p_update;
520     p_update->p_download = p_udt;
521     p_udt->psz_destdir = psz_destdir ? strdup( psz_destdir ) : NULL;
522
523     vlc_thread_create( p_udt, "download update", update_DownloadReal,
524                        VLC_THREAD_PRIORITY_LOW );
525 }
526
527 static void* update_DownloadReal( vlc_object_t *p_this )
528 {
529     update_download_thread_t *p_udt = (update_download_thread_t *)p_this;
530     dialog_progress_bar_t *p_progress = NULL;
531     long int l_size;
532     long int l_downloaded = 0;
533     float f_progress;
534     char *psz_status;
535     char *psz_downloaded = NULL;
536     char *psz_size = NULL;
537     char *psz_destfile = NULL;
538     char *psz_tmpdestfile = NULL;
539
540     FILE *p_file = NULL;
541     stream_t *p_stream = NULL;
542     void* p_buffer = NULL;
543     int i_read;
544     int canc;
545
546     update_t *p_update = p_udt->p_update;
547     char *psz_destdir = p_udt->psz_destdir;
548
549     msg_Dbg( p_udt, "Opening Stream '%s'", p_update->release.psz_url );
550     canc = vlc_savecancel ();
551
552     /* Open the stream */
553     p_stream = stream_UrlNew( p_udt, p_update->release.psz_url );
554     if( !p_stream )
555     {
556         msg_Err( p_udt, "Failed to open %s for reading", p_update->release.psz_url );
557         goto end;
558     }
559
560     /* Get the stream size */
561     l_size = stream_Size( p_stream );
562
563     /* Get the file name and open it*/
564     psz_tmpdestfile = strrchr( p_update->release.psz_url, '/' );
565     if( !psz_tmpdestfile )
566     {
567         msg_Err( p_udt, "The URL %s is badly formated",
568                  p_update->release.psz_url );
569         goto end;
570     }
571     psz_tmpdestfile++;
572     if( asprintf( &psz_destfile, "%s%s", psz_destdir, psz_tmpdestfile ) == -1 )
573         goto end;
574
575     p_file = vlc_fopen( psz_destfile, "w" );
576     if( !p_file )
577     {
578         msg_Err( p_udt, "Failed to open %s for writing", psz_destfile );
579         dialog_FatalWait( p_udt, _("Saving file failed"),
580             _("Failed to open \"%s\" for writing"),
581              psz_destfile );
582         goto end;
583     }
584
585     /* Create a buffer and fill it with the downloaded file */
586     p_buffer = (void *)malloc( 1 << 10 );
587     if( !p_buffer )
588     {
589         msg_Err( p_udt, "Can't malloc (1 << 10) bytes! download cancelled." );
590         goto end;
591     }
592
593     msg_Dbg( p_udt, "Downloading Stream '%s'", p_update->release.psz_url );
594
595     psz_size = size_str( l_size );
596     if( asprintf( &psz_status, _("%s\nDownloading... %s/%s %.1f%% done"),
597         p_update->release.psz_url, "0.0", psz_size, 0.0 ) != -1 )
598     {
599         p_progress = dialog_ProgressCreate( p_udt, _( "Downloading ..."),
600                                             psz_status, _("Cancel") );
601         free( psz_status );
602     }
603
604     while( vlc_object_alive( p_udt ) &&
605            ( i_read = stream_Read( p_stream, p_buffer, 1 << 10 ) ) &&
606            !dialog_ProgressCancelled( p_progress ) )
607     {
608         if( fwrite( p_buffer, i_read, 1, p_file ) < 1 )
609         {
610             msg_Err( p_udt, "Failed to write into %s", psz_destfile );
611             break;
612         }
613
614         l_downloaded += i_read;
615         psz_downloaded = size_str( l_downloaded );
616         f_progress = (float)l_downloaded/(float)l_size;
617
618         if( asprintf( &psz_status, _( "%s\nDownloading... %s/%s - %.1f%% done" ),
619                       p_update->release.psz_url, psz_downloaded, psz_size,
620                       f_progress*100 ) != -1 )
621         {
622             dialog_ProgressSet( p_progress, psz_status, f_progress );
623             free( psz_status );
624         }
625         free( psz_downloaded );
626     }
627
628     /* Finish the progress bar or delete the file if the user had canceled */
629     fclose( p_file );
630     p_file = NULL;
631
632     if( vlc_object_alive( p_udt ) &&
633         !dialog_ProgressCancelled( p_progress ) )
634     {
635         dialog_ProgressDestroy( p_progress );
636         p_progress = NULL;
637     }
638     else
639     {
640         vlc_unlink( psz_destfile );
641         goto end;
642     }
643
644     signature_packet_t sign;
645     if( download_signature( VLC_OBJECT( p_udt ), &sign,
646             p_update->release.psz_url ) != VLC_SUCCESS )
647     {
648         vlc_unlink( psz_destfile );
649
650         dialog_FatalWait( p_udt, _("File could not be verified"),
651             _("It was not possible to download a cryptographic signature for "
652               "the downloaded file \"%s\". Thus, it was deleted."),
653             psz_destfile );
654         msg_Err( p_udt, "Couldn't download signature of downloaded file" );
655         goto end;
656     }
657
658     if( memcmp( sign.issuer_longid, p_update->p_pkey->longid, 8 ) )
659     {
660         vlc_unlink( psz_destfile );
661         msg_Err( p_udt, "Invalid signature issuer" );
662         dialog_FatalWait( p_udt, _("Invalid signature"),
663             _("The cryptographic signature for the downloaded file \"%s\" was "
664               "invalid and could not be used to securely verify it. Thus, the "
665               "file was deleted."),
666             psz_destfile );
667         goto end;
668     }
669
670     if( sign.type != BINARY_SIGNATURE )
671     {
672         vlc_unlink( psz_destfile );
673         msg_Err( p_udt, "Invalid signature type" );
674         dialog_FatalWait( p_udt, _("Invalid signature"),
675             _("The cryptographic signature for the downloaded file \"%s\" was "
676               "invalid and could not be used to securely verify it. Thus, the "
677               "file was deleted."),
678             psz_destfile );
679         goto end;
680     }
681
682     uint8_t *p_hash = hash_sha1_from_file( psz_destfile, &sign );
683     if( !p_hash )
684     {
685         msg_Err( p_udt, "Unable to hash %s", psz_destfile );
686         vlc_unlink( psz_destfile );
687         dialog_FatalWait( p_udt, _("File not verifiable"),
688             _("It was not possible to securely verify the downloaded file"
689               " \"%s\". Thus, it was deleted."),
690             psz_destfile );
691
692         goto end;
693     }
694
695     if( p_hash[0] != sign.hash_verification[0] ||
696         p_hash[1] != sign.hash_verification[1] )
697     {
698         vlc_unlink( psz_destfile );
699         dialog_FatalWait( p_udt, _("File corrupted"),
700             _("Downloaded file \"%s\" was corrupted. Thus, it was deleted."),
701              psz_destfile );
702         msg_Err( p_udt, "Bad SHA1 hash for %s", psz_destfile );
703         free( p_hash );
704         goto end;
705     }
706
707     if( verify_signature( sign.r, sign.s, &p_update->p_pkey->key, p_hash )
708             != VLC_SUCCESS )
709     {
710         vlc_unlink( psz_destfile );
711         dialog_FatalWait( p_udt, _("File corrupted"),
712             _("Downloaded file \"%s\" was corrupted. Thus, it was deleted."),
713              psz_destfile );
714         msg_Err( p_udt, "BAD SIGNATURE for %s", psz_destfile );
715         free( p_hash );
716         goto end;
717     }
718
719     msg_Info( p_udt, "%s authenticated", psz_destfile );
720     free( p_hash );
721
722 #ifdef WIN32
723     int answer = dialog_Question( p_udt, _("Update VLC media player"),
724     _("The new version was successfully downloaded. Do you want to close VLC and install it now?"),
725     _("Install"), _("Cancel"), NULL);
726
727     if(answer == 1)
728     {
729         wchar_t psz_wdestfile[MAX_PATH];
730         MultiByteToWideChar( CP_UTF8, 0, psz_destfile, -1, psz_wdestfile, MAX_PATH );
731         answer = ShellExecuteW( NULL, L"open", psz_wdestfile, NULL, NULL, SW_SHOW);
732         if(answer > 32)
733             libvlc_Quit(p_this->p_libvlc);
734     }
735 #endif
736 end:
737     if( p_progress )
738         dialog_ProgressDestroy( p_progress );
739     if( p_stream )
740         stream_Delete( p_stream );
741     if( p_file )
742         fclose( p_file );
743     free( psz_destdir );
744     free( psz_destfile );
745     free( p_buffer );
746     free( psz_size );
747
748     vlc_restorecancel( canc );
749     return NULL;
750 }
751
752 update_release_t *update_GetRelease( update_t *p_update )
753 {
754     return &p_update->release;
755 }
756
757 #else
758 #undef update_New
759 update_t *update_New( vlc_object_t *p_this )
760 {
761     (void)p_this;
762     return NULL;
763 }
764
765 void update_Delete( update_t *p_update )
766 {
767     (void)p_update;
768 }
769
770 void update_Check( update_t *p_update, void (*pf_callback)( void*, bool ),
771                    void *p_data )
772 {
773     (void)p_update; (void)pf_callback; (void)p_data;
774 }
775
776 bool update_NeedUpgrade( update_t *p_update )
777 {
778     (void)p_update;
779     return false;
780 }
781
782 void update_Download( update_t *p_update, const char *psz_destdir )
783 {
784     (void)p_update; (void)psz_destdir;
785 }
786
787 update_release_t *update_GetRelease( update_t *p_update )
788 {
789     (void)p_update;
790     return NULL;
791 }
792 #endif