#include <assert.h>
-
#include <vlc_update.h>
-
#include <vlc_stream.h>
#include <vlc_interface.h>
# define UPDATE_VLC_STATUS_URL "http://update.videolan.org/vlc/status"
#endif
-#define STRDUP( a ) ( a ? strdup( a ) : NULL )
-
/*****************************************************************************
* Local Prototypes
update_t *__update_New( vlc_object_t *p_this )
{
update_t *p_update;
-
- if( p_this == NULL ) return NULL;
+ assert( p_this );
p_update = (update_t *)malloc( sizeof( update_t ) );
if( !p_update ) return NULL;
p_update->release.psz_url = NULL;
p_update->release.psz_desc = NULL;
- var_Create( p_this->p_libvlc, "update-notify", VLC_VAR_INTEGER |
- VLC_VAR_ISCOMMAND );
-
return p_update;
}
vlc_mutex_destroy( &p_update->lock );
- var_Destroy( p_update->p_libvlc, "update-notify" );
-
FREENULL( p_update->release.psz_url );
FREENULL( p_update->release.psz_desc );
}
p_update->release.psz_desc = psz_line;
- error:
- if( p_stream )
- stream_Delete( p_stream );
+error:
+ if( p_stream )
+ stream_Delete( p_stream );
}
vlc_mutex_unlock( &p_uct->p_update->lock );
- var_TriggerCallback( p_uct->p_update->p_libvlc, "update-notify" );
+ var_TriggerCallback( p_uct->p_libvlc, "update-notify" );
}
/**
sizeof( update_download_thread_t ) );
p_udt->p_update = p_update;
- p_udt->psz_destdir = STRDUP( psz_destdir );
+ p_udt->psz_destdir = psz_destdir ? strdup( psz_destdir ) : NULL;
vlc_thread_create( p_udt, "download update", update_DownloadReal,
VLC_THREAD_PRIORITY_LOW, VLC_FALSE );
p_stream = stream_UrlNew( p_update->p_libvlc, p_update->release.psz_url );
if( !p_stream )
{
- msg_Err( p_update->p_libvlc, "Failed to open %s for reading", p_update->release.psz_url );
+ msg_Err( p_udt, "Failed to open %s for reading", p_update->release.psz_url );
goto error;
}
psz_tmpdestfile = strrchr( p_update->release.psz_url, '/' );
if( !psz_tmpdestfile )
{
- msg_Err( p_update->p_libvlc, "The URL %s is false formated", p_update->release.psz_url );
+ msg_Err( p_udt, "The URL %s is false formated", p_update->release.psz_url );
goto error;
}
psz_tmpdestfile++;
p_file = utf8_fopen( psz_destfile, "w" );
if( !p_file )
{
- msg_Err( p_update->p_libvlc, "Failed to open %s for writing", psz_destfile );
+ msg_Err( p_udt, "Failed to open %s for writing", psz_destfile );
goto error;
}
psz_size = size_str( l_size );
if( asprintf( &psz_status, "%s\nDownloading... O.O/%s %.1f%% done", p_update->release.psz_url, psz_size, 0.0 ) != -1 )
{
- i_progress = intf_UserProgress( p_update->p_libvlc, "Downloading ...", psz_status, 0.0, 0 );
+ i_progress = intf_UserProgress( p_udt, "Downloading ...", psz_status, 0.0, 0 );
free( psz_status );
}
while( ( i_read = stream_Read( p_stream, p_buffer, 1 << 10 ) ) &&
- !intf_ProgressIsCancelled( p_update->p_libvlc, i_progress ) )
+ !intf_ProgressIsCancelled( p_udt, i_progress ) )
{
fwrite( p_buffer, i_read, 1, p_file );
if( asprintf( &psz_status, "%s\nDonwloading... %s/%s %.1f%% done", p_update->release.psz_url,
psz_size, psz_downloaded, f_progress ) != -1 )
{
- intf_ProgressUpdate( p_update->p_libvlc, i_progress, psz_status, f_progress, 0 );
+ intf_ProgressUpdate( p_udt, i_progress, psz_status, f_progress, 0 );
free( psz_status );
}
free( psz_downloaded );
/* Finish the progress bar or delete the file if the user had canceled */
fclose( p_file );
p_file = NULL;
- if( !intf_ProgressIsCancelled( p_update->p_libvlc, i_progress ) )
+ if( !intf_ProgressIsCancelled( p_udt, i_progress ) )
{
if( asprintf( &psz_status, "%s\nDone %s (100.0%%)", p_update->release.psz_url, psz_size ) != -1 )
{
- intf_ProgressUpdate( p_update->p_libvlc, i_progress, psz_status, 100.0, 0 );
+ intf_ProgressUpdate( p_udt, i_progress, psz_status, 100.0, 0 );
free( psz_status );
}
}