]> git.sesse.net Git - vlc/blob - src/misc/update.c
Win32: use Win32DebugOutputMsgW instead of ANSI version
[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         vlc_atomic_set( &p_update->p_download->aborted, 1 );
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     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.i_extra = 0;
224     int ret = sscanf( psz_version_line, "%i.%i.%i.%i",
225                     &p_update->release.i_major, &p_update->release.i_minor,
226                     &p_update->release.i_revision, &p_update->release.i_extra);
227     if( ret != 3 && ret != 4 )
228     {
229             msg_Err( p_update->p_libvlc, "Update version false formated" );
230             goto error;
231     }
232
233     /* second line : URL */
234     i_len = strcspn( psz_update_data_parser, "\r\n" );
235     if( i_len == 0 )
236     {
237         msg_Err( p_update->p_libvlc, "Update file %s is corrupted: URL missing",
238                  UPDATE_VLC_STATUS_URL );
239
240         goto error;
241     }
242
243     if( !(p_update->release.psz_url = malloc( i_len + 1)) )
244         goto error;
245     strncpy( p_update->release.psz_url, psz_update_data_parser, i_len );
246     p_update->release.psz_url[i_len] = '\0';
247
248     psz_update_data_parser += i_len;
249     while( *psz_update_data_parser == '\r' || *psz_update_data_parser == '\n' )
250         psz_update_data_parser++;
251
252     /* Remaining data : description */
253     i_len = strlen( psz_update_data_parser );
254     if( i_len == 0 )
255     {
256         msg_Err( p_update->p_libvlc,
257                 "Update file %s is corrupted: description missing",
258                 UPDATE_VLC_STATUS_URL );
259         goto error;
260     }
261
262     if( !(p_update->release.psz_desc = malloc( i_len + 1)) )
263         goto error;
264     strncpy( p_update->release.psz_desc, psz_update_data_parser, i_len );
265     p_update->release.psz_desc[i_len] = '\0';
266
267     /* Now that we know the status is valid, we must download its signature
268      * to authenticate it */
269     signature_packet_t sign;
270     if( download_signature( VLC_OBJECT( p_update->p_libvlc ), &sign,
271             UPDATE_VLC_STATUS_URL ) != VLC_SUCCESS )
272     {
273         msg_Err( p_update->p_libvlc, "Couldn't download signature of status file" );
274         goto error;
275     }
276
277     if( sign.type != BINARY_SIGNATURE && sign.type != TEXT_SIGNATURE )
278     {
279         msg_Err( p_update->p_libvlc, "Invalid signature type" );
280         goto error;
281     }
282
283     p_update->p_pkey = (public_key_t*)malloc( sizeof( public_key_t ) );
284     if( !p_update->p_pkey )
285         goto error;
286
287     if( parse_public_key( videolan_public_key, sizeof( videolan_public_key ),
288                         p_update->p_pkey, NULL ) != VLC_SUCCESS )
289     {
290         msg_Err( p_update->p_libvlc, "Couldn't parse embedded public key, something went really wrong..." );
291         FREENULL( p_update->p_pkey );
292         goto error;
293     }
294
295     memcpy( p_update->p_pkey->longid, videolan_public_key_longid, 8 );
296
297     if( memcmp( sign.issuer_longid, p_update->p_pkey->longid , 8 ) != 0 )
298     {
299         msg_Dbg( p_update->p_libvlc, "Need to download the GPG key" );
300         public_key_t *p_new_pkey = download_key(
301                 VLC_OBJECT(p_update->p_libvlc),
302                 sign.issuer_longid, videolan_public_key_longid );
303         if( !p_new_pkey )
304         {
305             msg_Err( p_update->p_libvlc, "Couldn't download GPG key" );
306             FREENULL( p_update->p_pkey );
307             goto error;
308         }
309
310         uint8_t *p_hash = hash_sha1_from_public_key( p_new_pkey );
311         if( !p_hash )
312         {
313             msg_Err( p_update->p_libvlc, "Failed to hash signature" );
314             free( p_new_pkey );
315             FREENULL( p_update->p_pkey );
316             goto error;
317         }
318
319         if( verify_signature( p_new_pkey->sig.r, p_new_pkey->sig.s,
320                     &p_update->p_pkey->key, p_hash ) == VLC_SUCCESS )
321         {
322             free( p_hash );
323             msg_Info( p_update->p_libvlc, "Key authenticated" );
324             free( p_update->p_pkey );
325             p_update->p_pkey = p_new_pkey;
326         }
327         else
328         {
329             free( p_hash );
330             msg_Err( p_update->p_libvlc, "Key signature invalid !" );
331             goto error;
332         }
333     }
334
335     uint8_t *p_hash = hash_sha1_from_text( psz_update_data, &sign );
336     if( !p_hash )
337     {
338         msg_Warn( p_update->p_libvlc, "Can't compute SHA1 hash for status file" );
339         goto error;
340     }
341
342     else if( p_hash[0] != sign.hash_verification[0] ||
343         p_hash[1] != sign.hash_verification[1] )
344     {
345         msg_Warn( p_update->p_libvlc, "Bad SHA1 hash for status file" );
346         goto error;
347     }
348
349     else if( verify_signature( sign.r, sign.s, &p_update->p_pkey->key, p_hash )
350             != VLC_SUCCESS )
351     {
352         msg_Err( p_update->p_libvlc, "BAD SIGNATURE for status file" );
353         goto error;
354     }
355
356     else
357     {
358         msg_Info( p_update->p_libvlc, "Status file authenticated" );
359         return true;
360     }
361
362 error:
363     if( p_stream )
364         stream_Delete( p_stream );
365     free( psz_version_line );
366     free( psz_update_data );
367     return false;
368 }
369
370 static void* update_CheckReal( void * );
371
372 /**
373  * Check for updates
374  *
375  * \param p_update pointer to update struct
376  * \param pf_callback pointer to a function to call when the update_check is finished
377  * \param p_data pointer to some datas to give to the callback
378  * \returns nothing
379  */
380 void update_Check( update_t *p_update, void (*pf_callback)( void*, bool ), void *p_data )
381 {
382     assert( p_update );
383
384     // If the object already exist, destroy it
385     if( p_update->p_check )
386     {
387         vlc_join( p_update->p_check->thread, NULL );
388         free( p_update->p_check );
389     }
390
391     update_check_thread_t *p_uct = calloc( 1, sizeof( *p_uct ) );
392     if( !p_uct ) return;
393
394     p_uct->p_update = p_update;
395     p_update->p_check = p_uct;
396     p_uct->pf_callback = pf_callback;
397     p_uct->p_data = p_data;
398
399     vlc_clone( &p_uct->thread, update_CheckReal, p_uct, VLC_THREAD_PRIORITY_LOW );
400 }
401
402 void* update_CheckReal( void *obj )
403 {
404     update_check_thread_t *p_uct = (update_check_thread_t *)obj;
405     bool b_ret;
406     int canc;
407
408     canc = vlc_savecancel ();
409     vlc_mutex_lock( &p_uct->p_update->lock );
410
411     EmptyRelease( p_uct->p_update );
412     b_ret = GetUpdateFile( p_uct->p_update );
413     vlc_mutex_unlock( &p_uct->p_update->lock );
414
415     if( p_uct->pf_callback )
416         (p_uct->pf_callback)( p_uct->p_data, b_ret );
417
418     vlc_restorecancel (canc);
419     return NULL;
420 }
421
422 bool update_NeedUpgrade( update_t *p_update )
423 {
424     assert( p_update );
425
426     static const int current[4] = {
427         PACKAGE_VERSION_MAJOR,
428         PACKAGE_VERSION_MINOR,
429         PACKAGE_VERSION_REVISION,
430         PACKAGE_VERSION_EXTRA
431     };
432     const int latest[4] = {
433         p_update->release.i_major,
434         p_update->release.i_minor,
435         p_update->release.i_revision,
436         p_update->release.i_extra
437     };
438
439     for (unsigned i = 0; i < sizeof latest / sizeof *latest; i++) {
440         /* there is a new version available */
441         if (latest[i] > current[i])
442             return true;
443
444         /* current version is more recent than the latest version ?! */
445         if (latest[i] < current[i])
446             return false;
447     }
448
449     /* current version is not a release, it's a -git or -rc version */
450     if (*PACKAGE_VERSION_DEV)
451         return true;
452
453     /* current version is latest version */
454     return false;
455 }
456
457 /**
458  * Convert a long int size in bytes to a string
459  *
460  * \param l_size the size in bytes
461  * \return the size as a string
462  */
463 static char *size_str( long int l_size )
464 {
465     char *psz_tmp = NULL;
466     int i_retval = 0;
467     if( l_size >> 30 )
468         i_retval = asprintf( &psz_tmp, _("%.1f GiB"), (float)l_size/(1<<30) );
469     else if( l_size >> 20 )
470         i_retval = asprintf( &psz_tmp, _("%.1f MiB"), (float)l_size/(1<<20) );
471     else if( l_size >> 10 )
472         i_retval = asprintf( &psz_tmp, _("%.1f KiB"), (float)l_size/(1<<10) );
473     else
474         i_retval = asprintf( &psz_tmp, _("%ld B"), l_size );
475
476     return i_retval == -1 ? NULL : psz_tmp;
477 }
478
479 static void* update_DownloadReal( void * );
480
481 /**
482  * Download the file given in the update_t
483  *
484  * \param p_update structure
485  * \param dir to store the download file
486  * \return nothing
487  */
488 void update_Download( update_t *p_update, const char *psz_destdir )
489 {
490     assert( p_update );
491
492     // If the object already exist, destroy it
493     if( p_update->p_download )
494     {
495         vlc_atomic_set( &p_update->p_download->aborted, 1 );
496         vlc_join( p_update->p_download->thread, NULL );
497         vlc_object_release( p_update->p_download );
498     }
499
500     update_download_thread_t *p_udt =
501         vlc_custom_create( p_update->p_libvlc, sizeof( *p_udt ),
502                            "update download" );
503     if( !p_udt )
504         return;
505
506     p_udt->p_update = p_update;
507     p_update->p_download = p_udt;
508     p_udt->psz_destdir = psz_destdir ? strdup( psz_destdir ) : NULL;
509
510     vlc_atomic_set(&p_udt->aborted, 0);
511     vlc_clone( &p_udt->thread, update_DownloadReal, p_udt, VLC_THREAD_PRIORITY_LOW );
512 }
513
514 static void* update_DownloadReal( void *obj )
515 {
516     update_download_thread_t *p_udt = (update_download_thread_t *)obj;
517     dialog_progress_bar_t *p_progress = NULL;
518     long int l_size;
519     long int l_downloaded = 0;
520     float f_progress;
521     char *psz_status;
522     char *psz_downloaded = NULL;
523     char *psz_size = NULL;
524     char *psz_destfile = NULL;
525     char *psz_tmpdestfile = NULL;
526
527     FILE *p_file = NULL;
528     stream_t *p_stream = NULL;
529     void* p_buffer = NULL;
530     int i_read;
531     int canc;
532
533     update_t *p_update = p_udt->p_update;
534     char *psz_destdir = p_udt->psz_destdir;
535
536     msg_Dbg( p_udt, "Opening Stream '%s'", p_update->release.psz_url );
537     canc = vlc_savecancel ();
538
539     /* Open the stream */
540     p_stream = stream_UrlNew( p_udt, p_update->release.psz_url );
541     if( !p_stream )
542     {
543         msg_Err( p_udt, "Failed to open %s for reading", p_update->release.psz_url );
544         goto end;
545     }
546
547     /* Get the stream size */
548     l_size = stream_Size( p_stream );
549
550     /* Get the file name and open it*/
551     psz_tmpdestfile = strrchr( p_update->release.psz_url, '/' );
552     if( !psz_tmpdestfile )
553     {
554         msg_Err( p_udt, "The URL %s is badly formated",
555                  p_update->release.psz_url );
556         goto end;
557     }
558     psz_tmpdestfile++;
559     if( asprintf( &psz_destfile, "%s%s", psz_destdir, psz_tmpdestfile ) == -1 )
560         goto end;
561
562     p_file = vlc_fopen( psz_destfile, "w" );
563     if( !p_file )
564     {
565         msg_Err( p_udt, "Failed to open %s for writing", psz_destfile );
566         dialog_FatalWait( p_udt, _("Saving file failed"),
567             _("Failed to open \"%s\" for writing"),
568              psz_destfile );
569         goto end;
570     }
571
572     /* Create a buffer and fill it with the downloaded file */
573     p_buffer = (void *)malloc( 1 << 10 );
574     if( unlikely(p_buffer == NULL) )
575         goto end;
576
577     msg_Dbg( p_udt, "Downloading Stream '%s'", p_update->release.psz_url );
578
579     psz_size = size_str( l_size );
580     if( asprintf( &psz_status, _("%s\nDownloading... %s/%s %.1f%% done"),
581         p_update->release.psz_url, "0.0", psz_size, 0.0 ) == -1 )
582         goto end;
583
584     p_progress = dialog_ProgressCreate( p_udt, _( "Downloading ..."),
585                                         psz_status, _("Cancel") );
586
587     free( psz_status );
588     if( p_progress == NULL )
589         goto end;
590
591     while( !vlc_atomic_get( &p_udt->aborted ) &&
592            ( i_read = stream_Read( p_stream, p_buffer, 1 << 10 ) ) &&
593            !dialog_ProgressCancelled( p_progress ) )
594     {
595         if( fwrite( p_buffer, i_read, 1, p_file ) < 1 )
596         {
597             msg_Err( p_udt, "Failed to write into %s", psz_destfile );
598             break;
599         }
600
601         l_downloaded += i_read;
602         psz_downloaded = size_str( l_downloaded );
603         f_progress = (float)l_downloaded/(float)l_size;
604
605         if( asprintf( &psz_status, _( "%s\nDownloading... %s/%s - %.1f%% done" ),
606                       p_update->release.psz_url, psz_downloaded, psz_size,
607                       f_progress*100 ) != -1 )
608         {
609             dialog_ProgressSet( p_progress, psz_status, f_progress );
610             free( psz_status );
611         }
612         free( psz_downloaded );
613     }
614
615     /* Finish the progress bar or delete the file if the user had canceled */
616     fclose( p_file );
617     p_file = NULL;
618
619     if( !vlc_atomic_get( &p_udt->aborted ) &&
620         !dialog_ProgressCancelled( p_progress ) )
621     {
622         dialog_ProgressDestroy( p_progress );
623         p_progress = NULL;
624     }
625     else
626     {
627         vlc_unlink( psz_destfile );
628         goto end;
629     }
630
631     signature_packet_t sign;
632     if( download_signature( VLC_OBJECT( p_udt ), &sign,
633             p_update->release.psz_url ) != VLC_SUCCESS )
634     {
635         vlc_unlink( psz_destfile );
636
637         dialog_FatalWait( p_udt, _("File could not be verified"),
638             _("It was not possible to download a cryptographic signature for "
639               "the downloaded file \"%s\". Thus, it was deleted."),
640             psz_destfile );
641         msg_Err( p_udt, "Couldn't download signature of downloaded file" );
642         goto end;
643     }
644
645     if( memcmp( sign.issuer_longid, p_update->p_pkey->longid, 8 ) )
646     {
647         vlc_unlink( psz_destfile );
648         msg_Err( p_udt, "Invalid signature issuer" );
649         dialog_FatalWait( p_udt, _("Invalid signature"),
650             _("The cryptographic signature for the downloaded file \"%s\" was "
651               "invalid and could not be used to securely verify it. Thus, the "
652               "file was deleted."),
653             psz_destfile );
654         goto end;
655     }
656
657     if( sign.type != BINARY_SIGNATURE )
658     {
659         vlc_unlink( psz_destfile );
660         msg_Err( p_udt, "Invalid signature type" );
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     uint8_t *p_hash = hash_sha1_from_file( psz_destfile, &sign );
670     if( !p_hash )
671     {
672         msg_Err( p_udt, "Unable to hash %s", psz_destfile );
673         vlc_unlink( psz_destfile );
674         dialog_FatalWait( p_udt, _("File not verifiable"),
675             _("It was not possible to securely verify the downloaded file"
676               " \"%s\". Thus, it was deleted."),
677             psz_destfile );
678
679         goto end;
680     }
681
682     if( p_hash[0] != sign.hash_verification[0] ||
683         p_hash[1] != sign.hash_verification[1] )
684     {
685         vlc_unlink( psz_destfile );
686         dialog_FatalWait( p_udt, _("File corrupted"),
687             _("Downloaded file \"%s\" was corrupted. Thus, it was deleted."),
688              psz_destfile );
689         msg_Err( p_udt, "Bad SHA1 hash for %s", psz_destfile );
690         free( p_hash );
691         goto end;
692     }
693
694     if( verify_signature( sign.r, sign.s, &p_update->p_pkey->key, p_hash )
695             != VLC_SUCCESS )
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 SIGNATURE for %s", psz_destfile );
702         free( p_hash );
703         goto end;
704     }
705
706     msg_Info( p_udt, "%s authenticated", psz_destfile );
707     free( p_hash );
708
709 #ifdef WIN32
710     int answer = dialog_Question( p_udt, _("Update VLC media player"),
711     _("The new version was successfully downloaded. Do you want to close VLC and install it now?"),
712     _("Install"), _("Cancel"), NULL);
713
714     if(answer == 1)
715     {
716         wchar_t psz_wdestfile[MAX_PATH];
717         MultiByteToWideChar( CP_UTF8, 0, psz_destfile, -1, psz_wdestfile, MAX_PATH );
718         answer = (int)ShellExecuteW( NULL, L"open", psz_wdestfile, NULL, NULL, SW_SHOW);
719         if(answer > 32)
720             libvlc_Quit(p_udt->p_libvlc);
721     }
722 #endif
723 end:
724     if( p_progress )
725         dialog_ProgressDestroy( p_progress );
726     if( p_stream )
727         stream_Delete( p_stream );
728     if( p_file )
729         fclose( p_file );
730     free( psz_destdir );
731     free( psz_destfile );
732     free( p_buffer );
733     free( psz_size );
734
735     vlc_restorecancel( canc );
736     return NULL;
737 }
738
739 update_release_t *update_GetRelease( update_t *p_update )
740 {
741     return &p_update->release;
742 }
743
744 #else
745 #undef update_New
746 update_t *update_New( vlc_object_t *p_this )
747 {
748     (void)p_this;
749     return NULL;
750 }
751
752 void update_Delete( update_t *p_update )
753 {
754     (void)p_update;
755 }
756
757 void update_Check( update_t *p_update, void (*pf_callback)( void*, bool ),
758                    void *p_data )
759 {
760     (void)p_update; (void)pf_callback; (void)p_data;
761 }
762
763 bool update_NeedUpgrade( update_t *p_update )
764 {
765     (void)p_update;
766     return false;
767 }
768
769 void update_Download( update_t *p_update, const char *psz_destdir )
770 {
771     (void)p_update; (void)psz_destdir;
772 }
773
774 update_release_t *update_GetRelease( update_t *p_update )
775 {
776     (void)p_update;
777     return NULL;
778 }
779 #endif