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