Changeset 12c39680e3b87acf1e9c7f5019598e16b8f9d669
- Timestamp:
- 22/12/07 12:29:57
(1 year ago)
- Author:
- Rafaël Carré <funman@videolan.org>
- git-committer:
- Rafaël Carré <funman@videolan.org> 1198322997 +0000
- git-parent:
[9548b1290c630d2e60409f4a678377a07505ffe8]
- git-author:
- Rafaël Carré <funman@videolan.org> 1198322997 +0000
- Message:
update: cosmetics, put the variable creation in libvlc
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r3d0196c |
r12c3968 |
|
| 884 | 884 | /* Create volume callback system. */ |
|---|
| 885 | 885 | var_Create( p_libvlc, "volume-change", VLC_VAR_BOOL ); |
|---|
| | 886 | |
|---|
| | 887 | /* Notify interfaces that a new VLC version is available */ |
|---|
| | 888 | #ifdef UPDATE_CHECK |
|---|
| | 889 | var_Create( p_libvlc, "update-notify", VLC_VAR_INTEGER | VLC_VAR_ISCOMMAND ); |
|---|
| | 890 | #endif |
|---|
| 886 | 891 | |
|---|
| 887 | 892 | /* |
|---|
| r9548b12 |
r12c3968 |
|
| 41 | 41 | #include <assert.h> |
|---|
| 42 | 42 | |
|---|
| 43 | | |
|---|
| 44 | 43 | #include <vlc_update.h> |
|---|
| 45 | | |
|---|
| 46 | 44 | #include <vlc_stream.h> |
|---|
| 47 | 45 | #include <vlc_interface.h> |
|---|
| … | … | |
| 78 | 76 | # define UPDATE_VLC_STATUS_URL "http://update.videolan.org/vlc/status" |
|---|
| 79 | 77 | #endif |
|---|
| 80 | | |
|---|
| 81 | | #define STRDUP( a ) ( a ? strdup( a ) : NULL ) |
|---|
| 82 | 78 | |
|---|
| 83 | 79 | |
|---|
| … | … | |
| 758 | 754 | { |
|---|
| 759 | 755 | update_t *p_update; |
|---|
| 760 | | |
|---|
| 761 | | if( p_this == NULL ) return NULL; |
|---|
| | 756 | assert( p_this ); |
|---|
| 762 | 757 | |
|---|
| 763 | 758 | p_update = (update_t *)malloc( sizeof( update_t ) ); |
|---|
| … | … | |
| 771 | 766 | p_update->release.psz_desc = NULL; |
|---|
| 772 | 767 | |
|---|
| 773 | | var_Create( p_this->p_libvlc, "update-notify", VLC_VAR_INTEGER | |
|---|
| 774 | | VLC_VAR_ISCOMMAND ); |
|---|
| 775 | | |
|---|
| 776 | 768 | return p_update; |
|---|
| 777 | 769 | } |
|---|
| … | … | |
| 788 | 780 | |
|---|
| 789 | 781 | vlc_mutex_destroy( &p_update->lock ); |
|---|
| 790 | | |
|---|
| 791 | | var_Destroy( p_update->p_libvlc, "update-notify" ); |
|---|
| 792 | 782 | |
|---|
| 793 | 783 | FREENULL( p_update->release.psz_url ); |
|---|
| … | … | |
| 881 | 871 | p_update->release.psz_desc = psz_line; |
|---|
| 882 | 872 | |
|---|
| 883 | | error: |
|---|
| 884 | | if( p_stream ) |
|---|
| 885 | | stream_Delete( p_stream ); |
|---|
| | 873 | error: |
|---|
| | 874 | if( p_stream ) |
|---|
| | 875 | stream_Delete( p_stream ); |
|---|
| 886 | 876 | } |
|---|
| 887 | 877 | |
|---|
| … | … | |
| 925 | 915 | vlc_mutex_unlock( &p_uct->p_update->lock ); |
|---|
| 926 | 916 | |
|---|
| 927 | | var_TriggerCallback( p_uct->p_update->p_libvlc, "update-notify" ); |
|---|
| | 917 | var_TriggerCallback( p_uct->p_libvlc, "update-notify" ); |
|---|
| 928 | 918 | } |
|---|
| 929 | 919 | |
|---|
| … | … | |
| 1020 | 1010 | |
|---|
| 1021 | 1011 | p_udt->p_update = p_update; |
|---|
| 1022 | | p_udt->psz_destdir = STRDUP( psz_destdir ); |
|---|
| | 1012 | p_udt->psz_destdir = psz_destdir ? strdup( psz_destdir ) : NULL; |
|---|
| 1023 | 1013 | |
|---|
| 1024 | 1014 | vlc_thread_create( p_udt, "download update", update_DownloadReal, |
|---|
| … | … | |
| 1049 | 1039 | if( !p_stream ) |
|---|
| 1050 | 1040 | { |
|---|
| 1051 | | msg_Err( p_update->p_libvlc, "Failed to open %s for reading", p_update->release.psz_url ); |
|---|
| | 1041 | msg_Err( p_udt, "Failed to open %s for reading", p_update->release.psz_url ); |
|---|
| 1052 | 1042 | goto error; |
|---|
| 1053 | 1043 | } |
|---|
| … | … | |
| 1060 | 1050 | if( !psz_tmpdestfile ) |
|---|
| 1061 | 1051 | { |
|---|
| 1062 | | msg_Err( p_update->p_libvlc, "The URL %s is false formated", p_update->release.psz_url ); |
|---|
| | 1052 | msg_Err( p_udt, "The URL %s is false formated", p_update->release.psz_url ); |
|---|
| 1063 | 1053 | goto error; |
|---|
| 1064 | 1054 | } |
|---|
| … | … | |
| 1070 | 1060 | if( !p_file ) |
|---|
| 1071 | 1061 | { |
|---|
| 1072 | | msg_Err( p_update->p_libvlc, "Failed to open %s for writing", psz_destfile ); |
|---|
| | 1062 | msg_Err( p_udt, "Failed to open %s for writing", psz_destfile ); |
|---|
| 1073 | 1063 | goto error; |
|---|
| 1074 | 1064 | } |
|---|
| … | … | |
| 1082 | 1072 | if( asprintf( &psz_status, "%s\nDownloading... O.O/%s %.1f%% done", p_update->release.psz_url, psz_size, 0.0 ) != -1 ) |
|---|
| 1083 | 1073 | { |
|---|
| 1084 | | i_progress = intf_UserProgress( p_update->p_libvlc, "Downloading ...", psz_status, 0.0, 0 ); |
|---|
| | 1074 | i_progress = intf_UserProgress( p_udt, "Downloading ...", psz_status, 0.0, 0 ); |
|---|
| 1085 | 1075 | free( psz_status ); |
|---|
| 1086 | 1076 | } |
|---|
| 1087 | 1077 | |
|---|
| 1088 | 1078 | while( ( i_read = stream_Read( p_stream, p_buffer, 1 << 10 ) ) && |
|---|
| 1089 | | !intf_ProgressIsCancelled( p_update->p_libvlc, i_progress ) ) |
|---|
| | 1079 | !intf_ProgressIsCancelled( p_udt, i_progress ) ) |
|---|
| 1090 | 1080 | { |
|---|
| 1091 | 1081 | fwrite( p_buffer, i_read, 1, p_file ); |
|---|
| … | … | |
| 1098 | 1088 | psz_size, psz_downloaded, f_progress ) != -1 ) |
|---|
| 1099 | 1089 | { |
|---|
| 1100 | | intf_ProgressUpdate( p_update->p_libvlc, i_progress, psz_status, f_progress, 0 ); |
|---|
| | 1090 | intf_ProgressUpdate( p_udt, i_progress, psz_status, f_progress, 0 ); |
|---|
| 1101 | 1091 | free( psz_status ); |
|---|
| 1102 | 1092 | } |
|---|
| … | … | |
| 1107 | 1097 | fclose( p_file ); |
|---|
| 1108 | 1098 | p_file = NULL; |
|---|
| 1109 | | if( !intf_ProgressIsCancelled( p_update->p_libvlc, i_progress ) ) |
|---|
| | 1099 | if( !intf_ProgressIsCancelled( p_udt, i_progress ) ) |
|---|
| 1110 | 1100 | { |
|---|
| 1111 | 1101 | if( asprintf( &psz_status, "%s\nDone %s (100.0%%)", p_update->release.psz_url, psz_size ) != -1 ) |
|---|
| 1112 | 1102 | { |
|---|
| 1113 | | intf_ProgressUpdate( p_update->p_libvlc, i_progress, psz_status, 100.0, 0 ); |
|---|
| | 1103 | intf_ProgressUpdate( p_udt, i_progress, psz_status, 100.0, 0 ); |
|---|
| 1114 | 1104 | free( psz_status ); |
|---|
| 1115 | 1105 | } |
|---|