Changeset 093de8561e556dcc9c233fa4aef3046fb658721c
- Timestamp:
- 08/02/06 21:51:46 (2 years ago)
- git-parent:
- Files:
-
- include/vlc_common.h (modified) (1 diff)
- include/vlc_interaction.h (modified) (1 diff)
- include/vlc_symbols.h (modified) (10 diffs)
- modules/demux/avi/avi.c (modified) (1 diff)
- modules/services_discovery/shout.c (modified) (2 diffs)
- src/interface/interaction.c (modified) (31 diffs)
- src/misc/update.c (modified) (14 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
include/vlc_common.h
r89471fa r093de85 619 619 #define DECMALLOC_VOID( var, type ) type* var = (type*)malloc( sizeof(type) );\ 620 620 if( !var ) return; 621 #define DECMALLOC_ERR( var, type ) type* var = (type*)malloc( sizeof(type) );\ 622 if( !var ) return VLC_ENOMEM; 621 623 #define DECMALLOC_NULL( var, type ) type* var = (type*)malloc( sizeof(type) );\ 622 624 if( !var ) return NULL; 623 625 624 626 #define FREENULL(a) if( a ) { free( a ); a = NULL; } 627 #define FREE(a) if( a ) { free( a ); } 625 628 626 629 /* Dynamic array handling: realloc array, move data, increment position */ include/vlc_interaction.h
r14e11ab r093de85 170 170 ***************************************************************************/ 171 171 172 #define intf_Interact( a,b ) __intf_Interact( VLC_OBJECT(a), b )173 VLC_EXPORT( int,__intf_Interact,( vlc_object_t *,interaction_dialog_t * ) );174 175 172 #define intf_UserFatal( a, b, c, d, e... ) __intf_UserFatal( VLC_OBJECT(a),b,c,d, ## e ) 176 VLC_EXPORT( void, __intf_UserFatal,( vlc_object_t*, vlc_bool_t, const char*, const char*, ...) );173 VLC_EXPORT( int, __intf_UserFatal,( vlc_object_t*, vlc_bool_t, const char*, const char*, ...) ); 177 174 #define intf_UserWarn( a, c, d, e... ) __intf_UserWarn( VLC_OBJECT(a),c,d, ## e ) 178 VLC_EXPORT( void, __intf_UserWarn,( vlc_object_t*, const char*, const char*, ...) );175 VLC_EXPORT( int, __intf_UserWarn,( vlc_object_t*, const char*, const char*, ...) ); 179 176 #define intf_UserLoginPassword( a, b, c, d, e... ) __intf_UserLoginPassword( VLC_OBJECT(a),b,c,d,e) 180 177 VLC_EXPORT( int, __intf_UserLoginPassword,( vlc_object_t*, const char*, const char*, char **, char **) ); 181 178 #define intf_UserYesNo( a, b, c, d, e, f ) __intf_UserYesNo( VLC_OBJECT(a),b,c, d, e, f ) 182 179 VLC_EXPORT( int, __intf_UserYesNo,( vlc_object_t*, const char*, const char*, const char*, const char*, const char*) ); 183 184 #define intf_UserProgress( a, b, c, d, e ) __intf_UserProgress( VLC_OBJECT(a),b,c,d,e )185 VLC_EXPORT( int, __intf_UserProgress,( vlc_object_t*, const char*, const char*, float, int) );186 #define intf_UserProgressUpdate( a, b, c, d, e ) __intf_UserProgressUpdate( VLC_OBJECT(a),b,c,d,e )187 VLC_EXPORT( void, __intf_UserProgressUpdate,( vlc_object_t*, int, const char*, float, int) );188 #define intf_UserProgressIsCancelled( a, b ) __intf_UserProgressIsCancelled( VLC_OBJECT(a),b )189 VLC_EXPORT( vlc_bool_t, __intf_UserProgressIsCancelled,( vlc_object_t*, int ) );190 191 180 #define intf_UserStringInput( a, b, c, d ) __intf_UserStringInput( VLC_OBJECT(a),b,c,d ) 192 181 VLC_EXPORT( int, __intf_UserStringInput,(vlc_object_t*, const char*, const char*, char **) ); 193 182 194 #define intf_IntfProgress( a, b, c ) __intf_IntfProgress( VLC_OBJECT(a),b,c ) 195 VLC_EXPORT( int, __intf_IntfProgress,( vlc_object_t*, const char*, float) ); 196 #define intf_IntfProgressUpdate( a, b, c, d ) __intf_IntfProgressUpdate( VLC_OBJECT(a),b,c,d ) 197 VLC_EXPORT( void, __intf_IntfProgressUpdate,( vlc_object_t*, int, const char*, float) ); 183 #define intf_IntfProgress( a, b, c ) __intf_Progress( VLC_OBJECT(a), NULL, b,c, -1 ) 184 #define intf_UserProgress( a, b, c, d, e ) __intf_Progress( VLC_OBJECT(a),b,c,d,e ) 185 VLC_EXPORT( int, __intf_Progress,( vlc_object_t*, const char*, const char*, float, int) ); 186 #define intf_ProgressUpdate( a, b, c, d, e ) __intf_ProgressUpdate( VLC_OBJECT(a),b,c,d,e ) 187 VLC_EXPORT( void, __intf_ProgressUpdate,( vlc_object_t*, int, const char*, float, int) ); 188 #define intf_ProgressIsCancelled( a, b ) __intf_UserProgressIsCancelled( VLC_OBJECT(a),b ) 189 VLC_EXPORT( vlc_bool_t, __intf_UserProgressIsCancelled,( vlc_object_t*, int ) ); 198 190 199 191 #define intf_UserHide( a, b ) __intf_UserHide( VLC_OBJECT(a), b ) include/vlc_symbols.h
r14e11ab r093de85 430 430 int (*__input_Read_inner) (vlc_object_t *, input_item_t *, vlc_bool_t); 431 431 int (*__net_ConnectUDP_inner) (vlc_object_t *p_this, const char *psz_host, int i_port, int hlim); 432 int (*__intf_Interact_inner) (vlc_object_t *,interaction_dialog_t *);432 void *__intf_Interact_deprecated; 433 433 void (*intf_InteractionManage_inner) (playlist_t *); 434 434 void (*intf_InteractionDestroy_inner) (interaction_t *); 435 void(*__intf_UserFatal_inner) (vlc_object_t*, vlc_bool_t, const char*, const char*, ...);435 int (*__intf_UserFatal_inner) (vlc_object_t*, vlc_bool_t, const char*, const char*, ...); 436 436 int (*__intf_UserLoginPassword_inner) (vlc_object_t*, const char*, const char*, char **, char **); 437 437 int (*__intf_UserYesNo_inner) (vlc_object_t*, const char*, const char*, const char*, const char*, const char*); 438 int (*__intf_UserProgress_inner) (vlc_object_t*, const char*, const char*, float, int);439 void (*__intf_UserProgressUpdate_inner) (vlc_object_t*, int, const char*, float, int);438 void *__intf_UserProgress_deprecated; 439 void *__intf_UserProgressUpdate_deprecated; 440 440 void (*__intf_UserHide_inner) (vlc_object_t *, int); 441 441 void *__stats_Create_deprecated; … … 518 518 void *stats_TimersClean_deprecated; 519 519 void (*__stats_TimersClean_inner) (vlc_object_t *); 520 void (*__intf_IntfProgressUpdate_inner) (vlc_object_t*, int, const char*, float);521 int (*__intf_IntfProgress_inner) (vlc_object_t*, const char*, float);520 void *__intf_IntfProgressUpdate_deprecated; 521 void *__intf_IntfProgress_deprecated; 522 522 void *streaming_ChainToPsz_deprecated; 523 void(*__intf_UserWarn_inner) (vlc_object_t*, const char*, const char*, ...);523 int (*__intf_UserWarn_inner) (vlc_object_t*, const char*, const char*, ...); 524 524 vlc_bool_t (*__intf_UserProgressIsCancelled_inner) (vlc_object_t*, int); 525 int (*__intf_Progress_inner) (vlc_object_t*, const char*, const char*, float, int); 526 void (*__intf_ProgressUpdate_inner) (vlc_object_t*, int, const char*, float, int); 525 527 }; 526 528 # if defined (__PLUGIN__) … … 909 911 # define __input_Read (p_symbols)->__input_Read_inner 910 912 # define __net_ConnectUDP (p_symbols)->__net_ConnectUDP_inner 911 # define __intf_Interact (p_symbols)->__intf_Interact_inner912 913 # define intf_InteractionManage (p_symbols)->intf_InteractionManage_inner 913 914 # define intf_InteractionDestroy (p_symbols)->intf_InteractionDestroy_inner … … 915 916 # define __intf_UserLoginPassword (p_symbols)->__intf_UserLoginPassword_inner 916 917 # define __intf_UserYesNo (p_symbols)->__intf_UserYesNo_inner 917 # define __intf_UserProgress (p_symbols)->__intf_UserProgress_inner918 # define __intf_UserProgressUpdate (p_symbols)->__intf_UserProgressUpdate_inner919 918 # define __intf_UserHide (p_symbols)->__intf_UserHide_inner 920 919 # define __stats_Update (p_symbols)->__stats_Update_inner … … 989 988 # define __stats_CounterCreate (p_symbols)->__stats_CounterCreate_inner 990 989 # define __stats_TimersClean (p_symbols)->__stats_TimersClean_inner 991 # define __intf_IntfProgressUpdate (p_symbols)->__intf_IntfProgressUpdate_inner992 # define __intf_IntfProgress (p_symbols)->__intf_IntfProgress_inner993 990 # define __intf_UserWarn (p_symbols)->__intf_UserWarn_inner 994 991 # define __intf_UserProgressIsCancelled (p_symbols)->__intf_UserProgressIsCancelled_inner 992 # define __intf_Progress (p_symbols)->__intf_Progress_inner 993 # define __intf_ProgressUpdate (p_symbols)->__intf_ProgressUpdate_inner 995 994 # elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__) 996 995 /****************************************************************** … … 1382 1381 ((p_symbols)->__input_Read_inner) = __input_Read; \ 1383 1382 ((p_symbols)->__net_ConnectUDP_inner) = __net_ConnectUDP; \ 1384 ((p_symbols)->__intf_Interact_inner) = __intf_Interact; \1385 1383 ((p_symbols)->intf_InteractionManage_inner) = intf_InteractionManage; \ 1386 1384 ((p_symbols)->intf_InteractionDestroy_inner) = intf_InteractionDestroy; \ … … 1388 1386 ((p_symbols)->__intf_UserLoginPassword_inner) = __intf_UserLoginPassword; \ 1389 1387 ((p_symbols)->__intf_UserYesNo_inner) = __intf_UserYesNo; \ 1390 ((p_symbols)->__intf_UserProgress_inner) = __intf_UserProgress; \1391 ((p_symbols)->__intf_UserProgressUpdate_inner) = __intf_UserProgressUpdate; \1392 1388 ((p_symbols)->__intf_UserHide_inner) = __intf_UserHide; \ 1393 1389 ((p_symbols)->__stats_Update_inner) = __stats_Update; \ … … 1462 1458 ((p_symbols)->__stats_CounterCreate_inner) = __stats_CounterCreate; \ 1463 1459 ((p_symbols)->__stats_TimersClean_inner) = __stats_TimersClean; \ 1464 ((p_symbols)->__intf_IntfProgressUpdate_inner) = __intf_IntfProgressUpdate; \1465 ((p_symbols)->__intf_IntfProgress_inner) = __intf_IntfProgress; \1466 1460 ((p_symbols)->__intf_UserWarn_inner) = __intf_UserWarn; \ 1467 1461 ((p_symbols)->__intf_UserProgressIsCancelled_inner) = __intf_UserProgressIsCancelled; \ 1462 ((p_symbols)->__intf_Progress_inner) = __intf_Progress; \ 1463 ((p_symbols)->__intf_ProgressUpdate_inner) = __intf_ProgressUpdate; \ 1468 1464 (p_symbols)->net_ConvertIPv4_deprecated = NULL; \ 1469 1465 (p_symbols)->__playlist_ItemCopy_deprecated = NULL; \ … … 1492 1488 (p_symbols)->playlist_Move_deprecated = NULL; \ 1493 1489 (p_symbols)->playlist_NodeRemoveParent_deprecated = NULL; \ 1490 (p_symbols)->__intf_Interact_deprecated = NULL; \ 1491 (p_symbols)->__intf_UserProgress_deprecated = NULL; \ 1492 (p_symbols)->__intf_UserProgressUpdate_deprecated = NULL; \ 1494 1493 (p_symbols)->__stats_Create_deprecated = NULL; \ 1495 1494 (p_symbols)->__stats_CounterGet_deprecated = NULL; \ … … 1500 1499 (p_symbols)->stats_TimerClean_deprecated = NULL; \ 1501 1500 (p_symbols)->stats_TimersClean_deprecated = NULL; \ 1501 (p_symbols)->__intf_IntfProgressUpdate_deprecated = NULL; \ 1502 (p_symbols)->__intf_IntfProgress_deprecated = NULL; \ 1502 1503 (p_symbols)->streaming_ChainToPsz_deprecated = NULL; \ 1503 1504 modules/demux/avi/avi.c
r6cb1101 r093de85 2299 2299 float f_pos = (float)i_pos; 2300 2300 p_demux->p_sys->last_update = mdate(); 2301 intf_ IntfProgressUpdate( p_demux, p_demux->p_sys->i_dialog_id,2302 _( "Fixing AVI Index..." ), f_pos);2301 intf_ProgressUpdate( p_demux, p_demux->p_sys->i_dialog_id, 2302 _( "Fixing AVI Index..." ), f_pos, -1 ); 2303 2303 } 2304 2304 modules/services_discovery/shout.c
r6cb1101 r093de85 197 197 int i_dialog_id; 198 198 199 i_dialog_id = intf_UserProgress( p_sd, "Shoutcast" , "Connecting...", 0.0, 0 ); 199 i_dialog_id = intf_UserProgress( p_sd, "Shoutcast" , 200 _("Connecting...") , 0.0, 0 ); 200 201 201 202 p_sys->b_dialog = VLC_TRUE; … … 215 216 float f_pos = (float)(p_sys->p_node_cat->i_children)* 2 *100.0 / 216 217 260 /* gruiiik FIXME */; 217 intf_ UserProgressUpdate( p_sd, i_dialog_id, "Downloading",218 f_pos, 0 );218 intf_ProgressUpdate( p_sd, i_dialog_id, "Downloading", 219 f_pos, 0 ); 219 220 } 220 221 vlc_object_release( p_input ); src/interface/interaction.c
r384f1ef r093de85 37 37 #include <vlc/vlc.h> 38 38 #include <vlc/input.h> 39 #include <assert.h> 39 40 40 41 #include "vlc_interaction.h" … … 45 46 * Local prototypes 46 47 *****************************************************************************/ 47 static void intf_InteractionInit( playlist_t *p_playlist );48 static interaction_t * intf_InteractionGet( vlc_object_t *p_this );49 static void intf_InteractionSearchInterface( interaction_t *48 static void InteractionInit( playlist_t *p_playlist ); 49 static interaction_t * InteractionGet( vlc_object_t *p_this ); 50 static void InteractionSearchInterface( interaction_t * 50 51 p_interaction ); 51 static int intf_WaitAnswer( interaction_t *p_interact, 52 interaction_dialog_t *p_dialog ); 53 static int intf_Send( interaction_t *p_interact, 54 interaction_dialog_t *p_dialog ); 55 static interaction_dialog_t *intf_InteractionGetById( vlc_object_t* , int ); 56 static void intf_InteractionDialogDestroy( 57 interaction_dialog_t *p_dialog ); 58 59 /** 60 * Send an interaction element to the user 61 * 62 * \param p_this the calling vlc_object_t 63 * \param p_interact the interaction element 64 * \return VLC_SUCCESS or an error code 65 */ 66 int __intf_Interact( vlc_object_t *p_this, interaction_dialog_t *p_dialog ) 67 { 68 interaction_t *p_interaction = intf_InteractionGet( p_this ); 69 70 /* Get an id, if we don't already have one */ 71 if( p_dialog->i_id == 0 ) 72 { 73 p_dialog->i_id = ++p_interaction->i_last_id; 74 } 75 76 if( p_this->i_flags & OBJECT_FLAGS_NOINTERACT ) return VLC_EGENERIC; 77 78 if( config_GetInt(p_this, "interact") || 79 p_dialog->i_flags & DIALOG_BLOCKING_ERROR || 80 p_dialog->i_flags & DIALOG_NONBLOCKING_ERROR ) 81 { 82 p_dialog->p_interaction = p_interaction; 83 p_dialog->p_parent = p_this; 84 85 if( p_dialog->i_type == INTERACT_DIALOG_TWOWAY ) 86 { 87 return intf_WaitAnswer( p_interaction, p_dialog ); 88 } 89 else 90 { 91 p_dialog->i_flags |= DIALOG_GOT_ANSWER; 92 return intf_Send( p_interaction, p_dialog ); 93 } 94 } 95 else 96 return VLC_EGENERIC; 97 } 52 static interaction_dialog_t *DialogGetById( interaction_t* , int ); 53 static void DialogDestroy( interaction_dialog_t *p_dialog ); 54 static int DialogSend( vlc_object_t *p_this, interaction_dialog_t *p_dialog ); 98 55 99 56 /** … … 105 62 { 106 63 int i; 107 108 64 // Remove all dialogs - Interfaces must be able to clean up their data 109 110 65 for( i = p_interaction->i_dialogs -1 ; i >= 0; i-- ) 111 66 { 112 67 interaction_dialog_t * p_dialog = p_interaction->pp_dialogs[i]; 113 intf_InteractionDialogDestroy( p_dialog );68 DialogDestroy( p_dialog ); 114 69 REMOVE_ELEM( p_interaction->pp_dialogs, p_interaction->i_dialogs, i ); 115 70 } 116 117 71 vlc_object_destroy( p_interaction ); 118 72 } … … 129 83 vlc_value_t val; 130 84 int i_index; 131 interaction_t *p_interaction; 132 133 p_interaction = p_playlist->p_interaction; 85 interaction_t *p_interaction = p_playlist->p_interaction; 134 86 135 87 // Nothing to do … … 138 90 vlc_mutex_lock( &p_interaction->object_lock ); 139 91 140 intf_InteractionSearchInterface( p_interaction ); 141 92 InteractionSearchInterface( p_interaction ); 142 93 if( !p_interaction->p_intf ) 143 94 { … … 146 97 { 147 98 interaction_dialog_t *p_dialog = p_interaction->pp_dialogs[i_index]; 148 149 // Give default answer 150 p_dialog->i_return = DIALOG_DEFAULT; 99 p_dialog->i_return = DIALOG_DEFAULT; // Give default answer 151 100 152 101 // Pretend we have hidden and destroyed it … … 201 150 i_index); 202 151 i_index--; 203 intf_InteractionDialogDestroy( p_dialog );152 DialogDestroy( p_dialog ); 204 153 break; 205 154 case NEW_DIALOG: … … 222 171 } 223 172 224 225 #define INTERACT_INIT( new ) \ 226 new = (interaction_dialog_t*)malloc( \ 227 sizeof( interaction_dialog_t ) ); \ 228 new->psz_title = NULL; \ 229 new->psz_description = NULL; \ 230 new->psz_default_button = NULL; \ 231 new->psz_alternate_button = NULL; \ 232 new->psz_other_button = NULL; \ 233 new->i_timeToGo = 0; \ 234 new->b_cancelled = VLC_FALSE; \ 235 new->p_private = NULL; \ 236 new->i_id = 0; \ 237 new->i_flags = 0; \ 238 new->i_status = NEW_DIALOG; 239 240 #define INTERACT_FREE( new ) \ 241 if( new->psz_title ) free( new->psz_title ); \ 242 if( new->psz_description ) free( new->psz_description ); 243 244 /** Helper function to send an error message, both in a blocking and non-blocking way 173 #define DIALOG_INIT( type ) \ 174 DECMALLOC_ERR( p_new, interaction_dialog_t ); \ 175 memset( p_new, 0, sizeof( interaction_dialog_t ) ); \ 176 p_new->b_cancelled = VLC_FALSE; \ 177 p_new->i_status = NEW_DIALOG; \ 178 p_new->i_type = INTERACT_DIALOG_##type; \ 179 p_new->psz_returned[0] = NULL; \ 180 p_new->psz_returned[1] = NULL; 181 182 #define FORMAT_DESC \ 183 va_start( args, psz_format ); \ 184 vasprintf( &p_new->psz_description, psz_format, args ); \ 185 va_end( args ); 186 187 /** Send an error message, both in a blocking and non-blocking way 245 188 * \param p_this Parent vlc_object 246 189 * \param b_blocking Is this dialog blocking or not? … … 248 191 * \param psz_format The message to display 249 192 * */ 250 void __intf_UserFatal( vlc_object_t *p_this, 251 vlc_bool_t b_blocking, 193 int __intf_UserFatal( vlc_object_t *p_this, vlc_bool_t b_blocking, 252 194 const char *psz_title, 253 195 const char *psz_format, ... ) 254 196 { 255 197 va_list args; 256 interaction_dialog_t *p_new = NULL; 257 258 INTERACT_INIT( p_new ); 198 DIALOG_INIT( ONEWAY ); 259 199 260 200 p_new->psz_title = strdup( psz_title ); 261 p_new->i_type = INTERACT_DIALOG_ONEWAY; 262 263 va_start( args, psz_format ); 264 vasprintf( &p_new->psz_description, psz_format, args ); 265 va_end( args ); 201 FORMAT_DESC; 266 202 267 203 if( b_blocking ) … … 270 206 p_new->i_flags = DIALOG_NONBLOCKING_ERROR; 271 207 272 intf_Interact( p_this, p_new );208 return DialogSend( p_this, p_new ); 273 209 } 274 210 … … 278 214 * \param psz_format The message to display 279 215 * */ 280 void__intf_UserWarn( vlc_object_t *p_this,281 const char *psz_title,282 const char *psz_format, ... )216 int __intf_UserWarn( vlc_object_t *p_this, 217 const char *psz_title, 218 const char *psz_format, ... ) 283 219 { 284 220 va_list args; 285 interaction_dialog_t *p_new = NULL; 286 287 INTERACT_INIT( p_new ); 221 DIALOG_INIT( ONEWAY ); 288 222 289 223 p_new->psz_title = strdup( psz_title ); 290 p_new->i_type = INTERACT_DIALOG_ONEWAY; 291 292 va_start( args, psz_format ); 293 vasprintf( &p_new->psz_description, psz_format, args ); 294 va_end( args ); 224 FORMAT_DESC 295 225 296 226 p_new->i_flags = DIALOG_WARNING; 297 227 298 intf_Interact( p_this, p_new );228 return DialogSend( p_this, p_new ); 299 229 } 300 230 … … 315 245 const char *psz_other ) 316 246 { 317 int i_ret; 318 interaction_dialog_t *p_new = NULL; 319 320 INTERACT_INIT( p_new ); 321 322 p_new->i_type = INTERACT_DIALOG_TWOWAY; 247 DIALOG_INIT( TWOWAY ); 248 323 249 p_new->psz_title = strdup( psz_title ); 324 250 p_new->psz_description = strdup( psz_description ); … … 328 254 if( psz_other ) 329 255 p_new->psz_other_button = strdup( psz_other ); 330 else 331 p_new->psz_other_button = NULL; 332 333 i_ret = intf_Interact( p_this, p_new ); 334 335 return i_ret; 256 257 return DialogSend( p_this, p_new ); 336 258 } 337 259 338 260 /** Helper function to create a dialogue showing a progress-bar with some info 339 261 * \param p_this Parent vlc_object 340 * \param psz_title Title for the dialog 262 * \param psz_title Title for the dialog (NULL implies main intf ) 341 263 * \param psz_status Current status 342 264 * \param f_position Current position (0.0->100.0) … … 344 266 * \return Dialog id, to give to UserProgressUpdate 345 267 */ 346 int __intf_UserProgress( vlc_object_t *p_this, 347 const char *psz_title, 348 const char *psz_status, 349 float f_pos, 350 int i_time ) 351 { 352 int i_ret; 353 interaction_dialog_t *p_new = NULL; 354 355 INTERACT_INIT( p_new ); 356 357 p_new->i_type = INTERACT_DIALOG_ONEWAY; 358 p_new->psz_title = strdup( psz_title ); 268 int __intf_Progress( vlc_object_t *p_this, const char *psz_title, 269 const char *psz_status, float f_pos, int i_time ) 270 { 271 DIALOG_INIT( ONEWAY ); 359 272 p_new->psz_description = strdup( psz_status ); 360 273 p_new->val.f_float = f_pos; 361 274 p_new->i_timeToGo = i_time; 362 275 363 p_new->i_flags = DIALOG_USER_PROGRESS; 364 365 i_ret = intf_Interact( p_this, p_new ); 366 276 if( psz_title ) 277 { 278 p_new->psz_title = strdup( psz_title ); 279 p_new->i_flags = DIALOG_USER_PROGRESS; 280 } 281 else 282 p_new->i_flags = DIALOG_INTF_PROGRESS; 283 284 DialogSend( p_this, p_new ); 367 285 return p_new->i_id; 368 286 } … … 376 294 * \return nothing 377 295 */ 378 void __intf_UserProgressUpdate( vlc_object_t *p_this, int i_id, 379 const char *psz_status, float f_pos, 380 int i_time ) 381 { 382 interaction_t *p_interaction = intf_InteractionGet( p_this ); 296 void __intf_ProgressUpdate( vlc_object_t *p_this, int i_id, 297 const char *psz_status, float f_pos, int i_time ) 298 { 299 interaction_t *p_interaction = InteractionGet( p_this ); 383 300 interaction_dialog_t *p_dialog; 384 301 … … 386 303 387 304 vlc_mutex_lock( &p_interaction->object_lock ); 388 p_dialog = intf_InteractionGetById( p_this, i_id );305 p_dialog = DialogGetById( p_interaction, i_id ); 389 306 390 307 if( !p_dialog ) … … 394 311 } 395 312 396 if( p_dialog->psz_description ) 397 free( p_dialog->psz_description ); 313 FREE( p_dialog->psz_description ); 398 314 p_dialog->psz_description = strdup( psz_status ); 399 315 … … 405 321 } 406 322 407 /** Helper function to communicate dialogue cancellations between the intf-module and caller 323 /** Helper function to communicate dialogue cancellations between the 324 * interface module and the caller 408 325 * \param p_this Parent vlc_object 409 326 * \param i_id Identifier of the dialogue … … 412 329 vlc_bool_t __intf_UserProgressIsCancelled( vlc_object_t *p_this, int i_id ) 413 330 { 414 interaction_t *p_interaction = intf_InteractionGet( p_this );331 interaction_t *p_interaction = InteractionGet( p_this ); 415 332 interaction_dialog_t *p_dialog; 333 vlc_bool_t b_cancel; 416 334 417 335 if( !p_interaction ) return VLC_TRUE; 418 336 419 337 vlc_mutex_lock( &p_interaction->object_lock ); 420 p_dialog = intf_InteractionGetById( p_this, i_id ); 421 338 p_dialog = DialogGetById( p_interaction, i_id ); 422 339 if( !p_dialog ) 423 340 { … … 426 343 } 427 344 428 vlc_mutex_unlock( &p_interaction->object_lock) ; 429 return p_dialog->b_cancelled; 345 b_cancel = p_dialog->b_cancelled; 346 vlc_mutex_unlock( &p_interaction->object_lock ); 347 return b_cancel; 430 348 } 431 349 … … 444 362 char **ppsz_password ) 445 363 { 446 447 364 int i_ret; 448 interaction_dialog_t *p_new = NULL; 449 450 INTERACT_INIT( p_new ); 451 365 DIALOG_INIT( TWOWAY ); 452 366 p_new->i_type = INTERACT_DIALOG_TWOWAY; 453 367 p_new->psz_title = strdup( psz_title ); … … 456 370 p_new->i_flags = DIALOG_LOGIN_PW_OK_CANCEL; 457 371 458 i_ret = intf_Interact( p_this, p_new );372 i_ret = DialogSend( p_this, p_new ); 459 373 460 374 if( i_ret != DIALOG_CANCELLED ) 461 375 { 376 assert( p_new->psz_returned[0] && p_new->psz_returned[1] ); 462 377 *ppsz_login = strdup( p_new->psz_returned[0] ); 463 378 *ppsz_password = strdup( p_new->psz_returned[1] ); … … 478 393 char **ppsz_usersString ) 479 394 { 480 481 395 int i_ret; 482 interaction_dialog_t *p_new = NULL; 483 484 INTERACT_INIT( p_new ); 485 486 p_new->i_type = INTERACT_DIALOG_TWOWAY; 396 DIALOG_INIT( TWOWAY ); 487 397 p_new->psz_title = strdup( psz_title ); 488 398 p_new->psz_description = strdup( psz_description ); … … 490 400 p_new->i_flags = DIALOG_PSZ_INPUT_OK_CANCEL; 491 401 492 i_ret = intf_Interact( p_this, p_new );402 i_ret = DialogSend( p_this, p_new ); 493 403 494 404 if( i_ret != DIALOG_CANCELLED ) 495 405 { 406 assert( p_new->psz_returned[0] ); 496 407 *ppsz_usersString = strdup( p_new->psz_returned[0] ); 497 408 } 498 409 return i_ret; 499 }500 501 /** Helper function to create a progress-bar in the main interface with a502 * single-line description503 * \param p_this Parent vlc_object504 * \param psz_status Current status505 * \param f_position Current position (0.0->100.0)506 * \return Dialog id, to give to IntfProgressUpdate507 */508 int __intf_IntfProgress( vlc_object_t *p_this,509 const char *psz_status,510 float f_pos )511 {512 int i_ret;513 interaction_dialog_t *p_new = NULL;514 515 INTERACT_INIT( p_new );516 517 p_new->i_type = INTERACT_DIALOG_ONEWAY;518 p_new->psz_description = strdup( psz_status );519 p_new->val.f_float = f_pos;520 521 p_new->i_flags = DIALOG_INTF_PROGRESS;522 523 i_ret = intf_Interact( p_this, p_new );524 525 return p_new->i_id;526 }527 528 /** Update the progress bar in the main interface529 * \param p_this Parent vlc_object530 * \param i_id Identifier of the dialog531 * \param psz_status New status532 * \param f_position New position (0.0->100.0)533 * \return nothing534 */535 void __intf_IntfProgressUpdate( vlc_object_t *p_this, int i_id,536 const char *psz_status, float f_pos )537 {538 interaction_t *p_interaction = intf_InteractionGet( p_this );539 interaction_dialog_t *p_dialog;540 541 if( !p_interaction ) return;542 543 vlc_mutex_lock( &p_interaction->object_lock );544 p_dialog = intf_InteractionGetById( p_this, i_id );545 546 if( !p_dialog )547 {548 vlc_mutex_unlock( &p_interaction->object_lock ) ;549 return;550 }551 552 if( p_dialog->psz_description )553 free( p_dialog->psz_description );554 p_dialog->psz_description = strdup( psz_status );555 556 p_dialog->val.f_float = f_pos;557 558 p_dialog->i_status = UPDATED_DIALOG;559 vlc_mutex_unlock( &p_interaction->object_lock) ;560 410 } 561 411 … … 567 417 void __intf_UserHide( vlc_object_t *p_this, int i_id ) 568 418 { 569 interaction_t *p_interaction = intf_InteractionGet( p_this );419 interaction_t *p_interaction = InteractionGet( p_this ); 570 420 interaction_dialog_t *p_dialog; 571 421 … … 573 423 574 424 vlc_mutex_lock( &p_interaction->object_lock ); 575 p_dialog = intf_InteractionGetById( p_this, i_id );425 p_dialog = DialogGetById( p_interaction, i_id ); 576 426 577 427 if( !p_dialog ) … … 584 434 vlc_mutex_unlock( &p_interaction->object_lock ); 585 435 } 586 587 588 436 589 437 /********************************************************************** … … 592 440 593 441 /* Get the interaction object. Create it if needed */ 594 static interaction_t * intf_InteractionGet( vlc_object_t *p_this )442 static interaction_t * InteractionGet( vlc_object_t *p_this ) 595 443 { 596 444 playlist_t *p_playlist; … … 599 447 p_playlist = (playlist_t*) vlc_object_find( p_this, VLC_OBJECT_PLAYLIST, 600 448 FIND_ANYWHERE ); 601 602 449 if( !p_playlist ) 603 {604 450 return NULL; 605 }606 451 607 452 if( p_playlist->p_interaction == NULL ) 608 { 609 intf_InteractionInit( p_playlist ); 610 } 453 InteractionInit( p_playlist ); 611 454 612 455 p_interaction = p_playlist->p_interaction; 613 456 614 457 vlc_object_release( p_playlist ); 615 616 458 return p_interaction; 617 459 } 618 460 619 461 /* Create the interaction object in the given playlist object */ 620 static void intf_InteractionInit( playlist_t *p_playlist ) 621 { 622 interaction_t *p_interaction; 623 624 p_interaction = vlc_object_create( VLC_OBJECT( p_playlist ), 625 sizeof( interaction_t ) ); 462 static void InteractionInit( playlist_t *p_playlist ) 463 { 464 interaction_t *p_interaction = vlc_object_create( VLC_OBJECT( p_playlist ), 465 sizeof( interaction_t ) ); 626 466 if( !p_interaction ) 627 467 { … … 641 481 642 482 /* Look for an interface suitable for interaction */ 643 static void intf_InteractionSearchInterface( interaction_t *p_interaction )483 static void InteractionSearchInterface( interaction_t *p_interaction ) 644 484 { 645 485 vlc_list_t *p_list; … … 668 508 } 669 509 670 /* Add a dialog to the queue and wait for answer*/671 static int intf_WaitAnswer( interaction_t *p_interact,672 interaction_dialog_t *p_dialog)510 /* Find an interaction dialog by its id */ 511 static interaction_dialog_t *DialogGetById( interaction_t *p_interaction, 512 int i_id ) 673 513 { 674 514 int i; 675 vlc_bool_t b_found = VLC_FALSE; 676 vlc_mutex_lock( &p_interact->object_lock ); 677 for( i = 0 ; i< p_interact->i_dialogs; i++ ) 678 { 679 if( p_interact->pp_dialogs[i]->i_id == p_dialog->i_id ) 515 for( i = 0 ; i< p_interaction->i_dialogs; i++ ) 516 { 517 if( p_interaction->pp_dialogs[i]->i_id == i_id ) 518 return p_interaction->pp_dialogs[i]; 519 } 520 return NULL; 521 } 522 523 /* Destroy a dialog */ 524 static void DialogDestroy( interaction_dialog_t *p_dialog ) 525 { 526 FREENULL( p_dialog->psz_title ); 527 FREENULL( p_dialog->psz_description ); 528 FREENULL( p_dialog->psz_default_button ); 529 FREENULL( p_dialog->psz_alternate_button ); 530 FREENULL( p_dialog->psz_other_button ); 531 free( p_dialog ); 532 } 533 534 /* Ask for the dialog to be sent to the user. Wait for answer 535 * if required */ 536 static int DialogSend( vlc_object_t *p_this, interaction_dialog_t *p_dialog ) 537 { 538 interaction_t *p_interaction = InteractionGet( p_this ); 539 540 /* Get an id, if we don't already have one */ 541 if( p_dialog->i_id == 0 ) 542 p_dialog->i_id = ++p_interaction->i_last_id; 543 544 if( p_this->i_flags & OBJECT_FLAGS_NOINTERACT ) return VLC_EGENERIC; 545 546 if( config_GetInt(p_this, "interact") || 547 p_dialog->i_flags & DIALOG_BLOCKING_ERROR || 548 p_dialog->i_flags & DIALOG_NONBLOCKING_ERROR ) 549 { 550 vlc_bool_t b_found = VLC_FALSE; 551 int i; 552 p_dialog->p_interaction = p_interaction; 553 p_dialog->p_parent = p_this; 554 555 /* Check if we have already added this dialog */ 556 vlc_mutex_lock( &p_interaction->object_lock ); 557 for( i = 0 ; i< p_interaction->i_dialogs; i++ ) 680 558 { 681 b_found = VLC_TRUE; 559 if( p_interaction->pp_dialogs[i]->i_id == p_dialog->i_id ) 560 b_found = VLC_TRUE; 682 561 } 683 } 684 if( ! b_found ) 685 { 686 INSERT_ELEM( p_interact->pp_dialogs, 687 p_interact->i_dialogs, 688 p_interact->i_dialogs, 689 p_dialog ); 562 /* Add it to the queue, the main loop will send the orders to the 563 * interface */ 564 if( ! b_found ) 565 { 566 INSERT_ELEM( p_interaction->pp_dialogs, 567 p_interaction->i_dialogs, 568 p_interaction->i_dialogs, 569 p_dialog ); 570 } 571 else 572 p_dialog->i_status = UPDATED_DIALOG; 573 vlc_mutex_unlock( &p_interaction->object_lock ); 574 575 if( p_dialog->i_type == INTERACT_DIALOG_TWOWAY ) // Wait for answer 576 { 577 while( p_dialog->i_status != ANSWERED_DIALOG && 578 p_dialog->i_status != HIDING_DIALOG && 579 p_dialog->i_status != HIDDEN_DIALOG && 580 !p_dialog->p_parent->b_die ) 581 { 582 msleep( 100000 ); 583 } 584 /// \todo locking ? 585 if( p_dialog->p_parent->b_die ) 586 { 587 p_dialog->i_return = DIALOG_CANCELLED; 588 p_dialog->i_status = ANSWERED_DIALOG; 589 } 590 p_dialog->i_flags |= DIALOG_GOT_ANSWER; 591 return p_dialog->i_return; 592 } 593 else 594 { 595 // Pretend we already retrieved the "answer" 596 p_dialog->i_flags |= DIALOG_GOT_ANSWER; 597 vlc_mutex_unlock( &p_interaction->object_lock ); 598 return VLC_SUCCESS; 599 } 690 600 } 691 601 else 692 p_dialog->i_status = UPDATED_DIALOG; 693 vlc_mutex_unlock( &p_interact->object_lock ); 694 695 /// \todo Check that the initiating object is not dying 696 while( p_dialog->i_status != ANSWERED_DIALOG && 697 p_dialog->i_status != HIDING_DIALOG && 698 p_dialog->i_status != HIDDEN_DIALOG && 699 !p_dialog->p_parent->b_die ) 700 { 701 msleep( 100000 ); 702 } 703 /// \todo locking 704 if( p_dialog->p_parent->b_die ) 705 { 706 p_dialog->i_return = DIALOG_CANCELLED; 707 p_dialog->i_status = ANSWERED_DIALOG; 708 } 709 p_dialog->i_flags |= DIALOG_GOT_ANSWER; 710 return p_dialog->i_return; 711 } 712 713 /* Add a dialog to the queue and return */ 714 static int intf_Send( interaction_t *p_interact, 715 interaction_dialog_t *p_dialog ) 716 { 717 int i; 718 vlc_bool_t b_found = VLC_FALSE; 719 if( p_interact == NULL ) return VLC_ENOOBJ; 720 vlc_mutex_lock( &p_interact->object_lock ); 721 722 for( i = 0 ; i< p_interact->i_dialogs; i++ ) 723 { 724 if( p_interact->pp_dialogs[i]->i_id == p_dialog->i_id ) 725 { 726 b_found = VLC_TRUE; 727 } 728 } 729 if( !b_found ) 730 { 731 INSERT_ELEM( p_interact->pp_dialogs, 732 p_interact->i_dialogs, 733 p_interact->i_dialogs, 734 p_dialog ); 735 } 736 else 737 p_dialog->i_status = UPDATED_DIALOG; 738 // Pretend we already retrieved the "answer" 739 p_dialog->i_flags |= DIALOG_GOT_ANSWER; 740 vlc_mutex_unlock( &p_interact->object_lock ); 741 return VLC_SUCCESS; 742 } 743 744 /* Find an interaction dialog by its id */ 745 static interaction_dialog_t *intf_InteractionGetById( vlc_object_t* p_this, 746 int i_id ) 747 { 748 interaction_t *p_interaction = intf_InteractionGet( p_this ); 749 int i; 750 751 if( !p_interaction ) return NULL; 752 753 for( i = 0 ; i< p_interaction->i_dialogs; i++ ) 754 { 755 if( p_interaction->pp_dialogs[i]->i_id == i_id ) 756 { 757 return p_interaction->pp_dialogs[i]; 758 } 759 } 760 return NULL; 761 } 762 763 #define FREE( i ) { if( i ) free( i ); i = NULL; } 764 765 static void intf_InteractionDialogDestroy( interaction_dialog_t *p_dialog ) 766 { 767 FREE( p_dialog->psz_title ); 768 FREE( p_dialog->psz_description ); 769 FREE( p_dialog->psz_default_button ); 770 FREE( p_dialog->psz_alternate_button ); 771 FREE( p_dialog->psz_other_button ); 772 773 free( p_dialog ); 774
