Changeset 107b78a957c386f36923338a7273ea4fd82f631a
- Timestamp:
- 12/22/07 13:41:56
(9 months ago)
- Author:
- Rémi Duraffort <ivoire@videolan.org>
- git-committer:
- Rémi Duraffort <ivoire@videolan.org> 1198327316 +0000
- git-parent:
[8442f8adddbb55bd66a9155512fef5c0ab70ad4c]
- git-author:
- Rémi Duraffort <ivoire@videolan.org> 1198327316 +0000
- Message:
use a pointer to a function instead of a callback
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| rc2598291 |
r107b78a |
|
| 281 | 281 | VLC_EXPORT( update_t *, __update_New, ( vlc_object_t * ) ); |
|---|
| 282 | 282 | VLC_EXPORT( void, update_Delete, ( update_t * ) ); |
|---|
| 283 | | VLC_EXPORT( void, update_Check, ( update_t * ) ); |
|---|
| | 283 | VLC_EXPORT( void, update_Check, ( update_t *, void (*callback)( void* ), void * ) ); |
|---|
| 284 | 284 | VLC_EXPORT( int, update_CompareReleaseToCurrent, ( update_t * ) ); |
|---|
| 285 | 285 | VLC_EXPORT( void, update_Download, ( update_t *, char* ) ); |
|---|
| rf5a08fa |
r107b78a |
|
| 180 | 180 | *****************************************************************************/ |
|---|
| 181 | 181 | /* callback to get information from the core */ |
|---|
| 182 | | static int updateCallback( vlc_object_t *p_this, char const *psz_cmd, |
|---|
| 183 | | vlc_value_t oldval, vlc_value_t newval, void *data ) |
|---|
| | 182 | static void UpdateCallback( void *data ) |
|---|
| 184 | 183 | { |
|---|
| 185 | 184 | UpdateDialog* UDialog = (UpdateDialog *)data; |
|---|
| 186 | 185 | QEvent *event = new QEvent( QEvent::User ); |
|---|
| 187 | 186 | QApplication::postEvent( UDialog, event ); |
|---|
| 188 | | return VLC_SUCCESS; |
|---|
| 189 | 187 | } |
|---|
| 190 | 188 | |
|---|
| … | … | |
| 216 | 214 | /* create the update structure and the callback */ |
|---|
| 217 | 215 | p_update = update_New( _p_intf ); |
|---|
| 218 | | var_AddCallback( _p_intf->p_libvlc, "update-notify", updateCallback, this ); |
|---|
| 219 | 216 | b_checked = false; |
|---|
| 220 | 217 | } |
|---|
| … | … | |
| 222 | 219 | UpdateDialog::~UpdateDialog() |
|---|
| 223 | 220 | { |
|---|
| 224 | | var_DelCallback( p_update->p_libvlc, "update-notify", updateCallback, this ); |
|---|
| 225 | 221 | update_Delete( p_update ); |
|---|
| 226 | 222 | } |
|---|
| … | … | |
| 237 | 233 | { |
|---|
| 238 | 234 | updateButton->setEnabled( false ); |
|---|
| 239 | | update_Check( p_update ); |
|---|
| | 235 | update_Check( p_update, UpdateCallback, this ); |
|---|
| 240 | 236 | } |
|---|
| 241 | 237 | else |
|---|
| r48c2ac8 |
r107b78a |
|
| 101 | 101 | void UpdateVLC::OnCheckForUpdate( wxCommandEvent& event ) |
|---|
| 102 | 102 | { |
|---|
| 103 | | update_Check( p_update ); |
|---|
| | 103 | update_Check( p_update, NULL, this ); |
|---|
| 104 | 104 | wxBoxSizer *main_sizer = new wxBoxSizer( wxVERTICAL ); |
|---|
| 105 | 105 | |
|---|
| r12c3968 |
r107b78a |
|
| 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 |
|---|
| 891 | 886 | |
|---|
| 892 | 887 | /* |
|---|
| r12c3968 |
r107b78a |
|
| 884 | 884 | VLC_COMMON_MEMBERS |
|---|
| 885 | 885 | update_t *p_update; |
|---|
| | 886 | void (*pf_callback)( void * ); |
|---|
| | 887 | void *p_data; |
|---|
| 886 | 888 | } update_check_thread_t; |
|---|
| 887 | 889 | |
|---|
| … | … | |
| 892 | 894 | * |
|---|
| 893 | 895 | * \param p_update pointer to update struct |
|---|
| | 896 | * \param pf_callback pointer to a function to call when the update_check is finished |
|---|
| | 897 | * \param p_data pointer to some datas to give to the callback |
|---|
| 894 | 898 | * \returns nothing |
|---|
| 895 | 899 | */ |
|---|
| 896 | | void update_Check( update_t *p_update ) |
|---|
| | 900 | void update_Check( update_t *p_update, void (*pf_callback)( void* ), void *p_data ) |
|---|
| 897 | 901 | { |
|---|
| 898 | 902 | assert( p_update ); |
|---|
| … | … | |
| 901 | 905 | sizeof( update_check_thread_t ) ); |
|---|
| 902 | 906 | p_uct->p_update = p_update; |
|---|
| | 907 | p_uct->pf_callback = pf_callback; |
|---|
| | 908 | p_uct->p_data = p_data; |
|---|
| 903 | 909 | |
|---|
| 904 | 910 | vlc_thread_create( p_uct, "check for update", update_CheckReal, |
|---|
| … | … | |
| 915 | 921 | vlc_mutex_unlock( &p_uct->p_update->lock ); |
|---|
| 916 | 922 | |
|---|
| 917 | | var_TriggerCallback( p_uct->p_libvlc, "update-notify" ); |
|---|
| | 923 | if( p_uct->pf_callback ) |
|---|
| | 924 | (p_uct->pf_callback)( p_uct->p_data ); |
|---|
| 918 | 925 | } |
|---|
| 919 | 926 | |
|---|
| … | … | |
| 1036 | 1043 | |
|---|
| 1037 | 1044 | /* Open the stream */ |
|---|
| 1038 | | p_stream = stream_UrlNew( p_update->p_libvlc, p_update->release.psz_url ); |
|---|
| | 1045 | p_stream = stream_UrlNew( p_udt, p_update->release.psz_url ); |
|---|
| 1039 | 1046 | if( !p_stream ) |
|---|
| 1040 | 1047 | { |
|---|
| … | … | |
| 1108 | 1115 | remove( psz_destfile ); |
|---|
| 1109 | 1116 | |
|---|
| 1110 | | error: |
|---|
| 1111 | | if( p_stream ) |
|---|
| 1112 | | stream_Delete( p_stream ); |
|---|
| 1113 | | if( p_file ) |
|---|
| 1114 | | fclose( p_file ); |
|---|
| 1115 | | free( psz_destdir ); |
|---|
| 1116 | | free( psz_destfile ); |
|---|
| 1117 | | free( p_buffer ); |
|---|
| 1118 | | free( psz_size ); |
|---|
| | 1117 | error: |
|---|
| | 1118 | if( p_stream ) |
|---|
| | 1119 | stream_Delete( p_stream ); |
|---|
| | 1120 | if( p_file ) |
|---|
| | 1121 | fclose( p_file ); |
|---|
| | 1122 | free( psz_destdir ); |
|---|
| | 1123 | free( psz_destfile ); |
|---|
| | 1124 | free( p_buffer ); |
|---|
| | 1125 | free( psz_size ); |
|---|
| 1119 | 1126 | } |
|---|
| 1120 | 1127 | |
|---|