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