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