Changeset 15354b0406c9222fd39dcee94f9d7239d65d5f39
- Timestamp:
- 11/12/05 17:06:19 (3 years ago)
- git-parent:
- Files:
-
- include/vlc_interaction.h (modified) (7 diffs)
- include/vlc_interface.h (modified) (3 diffs)
- include/vlc_symbols.h (modified) (5 diffs)
- src/input/input.c (modified) (2 diffs)
- src/interface/interaction.c (modified) (15 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
include/vlc_interaction.h
r29c81fb r15354b0 40 40 WIDGET_TEXT, //< Text display 41 41 WIDGET_PROGRESS, //< A progress bar 42 WIDGET_INPUT //< Input (backed up by a variable)42 WIDGET_INPUT_TEXT //< Input (backed up by a variable) 43 43 }; 44 44 … … 53 53 char *psz_description; //< Descriptor string 54 54 55 /* For dialogs */56 55 int i_widgets; //< Nu,ber of dialog widgets 57 56 user_widget_t **pp_widgets; //< Dialog widgets 58 57 59 v lc_bool_t b_reusable; //< Do we have to reuse this ?58 void * p_private; //< Private interface data 60 59 61 void * p_private; //< Private interface data62 60 int i_status; //< Dialog status; 61 int i_action; //< Action to perform; 62 int i_flags; //< Misc flags 63 int i_return; //< Return status 63 64 64 int i_action; //< Action to perform; 65 interaction_t *p_interaction; //< Parent interaction object 66 vlc_object_t *p_parent; //< The vlc object that asked 67 //for interaction 68 }; 69 70 /** 71 * Possible flags . Reusable and button types 72 */ 73 #define DIALOG_REUSABLE 0x01 74 #define DIALOG_OK_CANCEL 0x02 75 #define DIALOG_YES_NO 0x04 76 #define DIALOG_YES_NO_CANCEL 0x04 77 #define DIALOG_GOT_ANSWER 0x08 78 79 /** 80 * Possible return codes 81 */ 82 enum 83 { 84 DIALOG_DEFAULT, 85 DIALOG_OK_YES, 86 DIALOG_NO, 87 DIALOG_CANCELLED 65 88 }; 66 89 … … 70 93 enum 71 94 { 72 NEW_DIALOG, 73 SENT_DIALOG, 74 UPDATED_DIALOG, 75 ANSWERED_DIALOG, 76 HIDING_DIALOG, 77 HIDDEN_DIALOG, 95 NEW_DIALOG, //< Just created 96 SENT_DIALOG, //< Sent to interface 97 UPDATED_DIALOG, //< Update to send 98 ANSWERED_DIALOG, //< Got "answer" 99 HIDING_DIALOG, //< Hiding requested 100 HIDDEN_DIALOG, //< Now hidden. Requesting destruction 101 DESTROYED_DIALOG, //< Interface has destroyed it 78 102 }; 79 103 … … 83 107 enum 84 108 { 85 INTERACT_PROGRESS, //< Progress bar 86 INTERACT_WARNING, //< Warning message ("codec not supported") 87 INTERACT_FATAL, //< Fatal message ("File not found") 88 INTERACT_FATAL_LIST, //< List of fatal messages ("File not found") 89 INTERACT_ASK, //< Full-featured dialog box (password) 109 INTERACT_PROGRESS, //< Progress bar (in the main interface ?) 110 INTERACT_DIALOG_ONEWAY, //< Dialog box without feedback 111 INTERACT_DIALOG_TWOWAY, //< Dialog box with feedback 90 112 }; 91 113 … … 96 118 { 97 119 DIALOG_FIRST, 98 DIALOG_NOACCESS, 99 DIALOG_NOCODEC, 100 DIALOG_NOAUDIO, 120 DIALOG_ERRORS, 101 121 102 122 DIALOG_LAST_PREDEFINED, … … 125 145 INTERACT_NEW, 126 146 INTERACT_UPDATE, 127 INTERACT_HIDE 147 INTERACT_HIDE, 148 INTERACT_DESTROY 128 149 }; 129 150 … … 135 156 VLC_EXPORT( int,__intf_Interact,( vlc_object_t *,interaction_dialog_t * ) ); 136 157 137 #define intf_UserFatal( a,b, c, d, e... ) __intf_UserFatal( a,b,c,d, ## e ) 138 VLC_EXPORT( void, __intf_UserFatal,( vlc_object_t*, int, const char*, const char*, ...) ); 158 #define intf_UserFatal( a, c, d, e... ) __intf_UserFatal( a,c,d, ## e ) 159 VLC_EXPORT( void, __intf_UserFatal,( vlc_object_t*, const char*, const char*, ...) ); 160 #define intf_UserLoginPassword( a, b, c, d, e... ) __intf_UserLoginPassword( a,b,c,d,e) 161 VLC_EXPORT( int, __intf_UserLoginPassword,( vlc_object_t*, const char*, const char*, char **, char **) ); 139 162 140 163 VLC_EXPORT( void, intf_InteractionManage,( playlist_t *) ); include/vlc_interface.h
r29c81fb r15354b0 93 93 struct intf_dialog_args_t 94 94 { 95 intf_thread_t *p_intf; 95 96 char *psz_title; 96 97 … … 105 106 vlc_bool_t b_save; 106 107 vlc_bool_t b_multiple; 108 109 /* Specific to INTF_DIALOG_INTERACTION */ 110 interaction_dialog_t *p_dialog; 107 111 }; 108 112 … … 161 165 162 166 #define INTF_DIALOG_FILE_GENERIC 30 167 #define INTF_DIALOG_INTERACTION 50 163 168 164 169 #define INTF_DIALOG_UPDATEVLC 90 include/vlc_symbols.h
rbe2365a r15354b0 146 146 int __vlc_threads_end (vlc_object_t *); 147 147 int sout_AccessOutRead (sout_access_out_t *, block_t *); 148 int __intf_UserLoginPassword (vlc_object_t*, const char*, const char*, char **, char **); 148 149 int demux2_vaControlHelper (stream_t *, int64_t i_start, int64_t i_end, int i_bitrate, int i_align, int i_query, va_list args); 149 150 int httpd_UrlCatch (httpd_url_t *, int i_msg, httpd_callback_t, httpd_callback_sys_t *); … … 298 299 int vout_vaControlDefault (vout_thread_t *, int, va_list); 299 300 int playlist_NodeEmpty (playlist_t *, playlist_item_t *, vlc_bool_t); 300 void __intf_UserFatal (vlc_object_t*, int,const char*, const char*, ...);301 void __intf_UserFatal (vlc_object_t*, const char*, const char*, ...); 301 302 spu_t * __spu_Create (vlc_object_t *); 302 303 int playlist_NodeRemoveItem (playlist_t *,playlist_item_t*,playlist_item_t *); … … 859 860 void (*intf_InteractionManage_inner) (playlist_t *); 860 861 void (*intf_InteractionDestroy_inner) (interaction_t *); 861 void (*__intf_UserFatal_inner) (vlc_object_t*, int, const char*, const char*, ...); 862 void (*__intf_UserFatal_inner) (vlc_object_t*, const char*, const char*, ...); 863 int (*__intf_UserLoginPassword_inner) (vlc_object_t*, const char*, const char*, char **, char **); 862 864 }; 863 865 # if defined (__PLUGIN__) … … 1275 1277 # define intf_InteractionDestroy (p_symbols)->intf_InteractionDestroy_inner 1276 1278 # define __intf_UserFatal (p_symbols)->__intf_UserFatal_inner 1279 # define __intf_UserLoginPassword (p_symbols)->__intf_UserLoginPassword_inner 1277 1280 # elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__) 1278 1281 /****************************************************************** … … 1693 1696 ((p_symbols)->intf_InteractionDestroy_inner) = intf_InteractionDestroy; \ 1694 1697 ((p_symbols)->__intf_UserFatal_inner) = __intf_UserFatal; \ 1698 ((p_symbols)->__intf_UserLoginPassword_inner) = __intf_UserLoginPassword; \ 1695 1699 (p_symbols)->net_ConvertIPv4_deprecated = NULL; \ 1696 1700 src/input/input.c
r29c81fb r15354b0 2096 2096 { 2097 2097 msg_Err( p_input, "no suitable access module for `%s'", psz_mrl ); 2098 intf_UserFatal( VLC_OBJECT( p_input), DIALOG_NOACCESS, 2099 "Error opening stream", 2100 "Unable to open '%s'", psz_mrl ); 2098 intf_UserFatal( VLC_OBJECT( p_input), 2099 _("Errors"),"Unable to open '%s'", psz_mrl ); 2101 2100 goto error; 2102 2101 } … … 2168 2167 msg_Err( p_input, "no suitable demux module for `%s/%s://%s'", 2169 2168 psz_access, psz_demux, psz_path ); 2169 intf_UserFatal( VLC_OBJECT( p_input), _("Errors"), 2170 "Unrecognized format for '%s'", psz_mrl ); 2170 2171 goto error; 2171 2172 } src/interface/interaction.c
r29c81fb r15354b0 64 64 p_dialog ) 65 65 { 66 67 66 interaction_t *p_interaction = intf_InteractionGet( p_this ); 68 67 … … 73 72 } 74 73 75 if( p_dialog->i_type == INTERACT_ASK ) 74 p_dialog->p_interaction = p_interaction; 75 p_dialog->p_parent = p_this; 76 77 if( p_dialog->i_type == INTERACT_DIALOG_TWOWAY ) 76 78 { 77 79 return intf_WaitAnswer( p_interaction, p_dialog ); … … 79 81 else 80 82 { 83 p_dialog->i_flags |= DIALOG_GOT_ANSWER; 81 84 return intf_Send( p_interaction, p_dialog ); 82 85 } … … 115 118 if( !p_interaction->p_intf ) 116 119 { 117 vlc_mutex_unlock( &p_interaction->object_lock ); 118 119 /// \todo Remove all dialogs as we can't display them 120 return; 121 } 122 123 vlc_object_yield( p_interaction->p_intf ); 120 // We mark all dialogs as answered with their "default" answer 121 for( i_index = 0 ; i_index < p_interaction->i_dialogs; i_index ++ ) 122 { 123 interaction_dialog_t *p_dialog = p_interaction->pp_dialogs[i_index]; 124 p_dialog->i_return = DIALOG_DEFAULT; 125 if( p_dialog->i_flags & DIALOG_OK_CANCEL ) 126 p_dialog->i_return = DIALOG_CANCELLED; 127 if( p_dialog->i_flags & DIALOG_YES_NO_CANCEL ) 128 p_dialog->i_return = DIALOG_CANCELLED; 129 p_dialog->i_status = ANSWERED_DIALOG; 130 } 131 } 132 else 133 { 134 vlc_object_yield( p_interaction->p_intf ); 135 } 124 136 125 137 for( i_index = 0 ; i_index < p_interaction->i_dialogs; i_index ++ ) 126 138 { 127 139 interaction_dialog_t *p_dialog = p_interaction->pp_dialogs[i_index]; 128 129 140 switch( p_dialog->i_status ) 130 141 { 131 142 case ANSWERED_DIALOG: 132 /// \todo Signal we have an answer133 // - If have answer, signal what is waiting134 // (vlc_cond ? dangerous in case of pb ?)135 136 143 // Ask interface to hide it 137 144 msg_Dbg( p_interaction, "Hiding dialog %i", p_dialog->i_id ); 138 145 p_dialog->i_action = INTERACT_HIDE; 139 146 val.p_address = p_dialog; 140 var_Set( p_interaction->p_intf, "interaction", val ); 147 if( p_interaction->p_intf ) 148 var_Set( p_interaction->p_intf, "interaction", val ); 141 149 p_dialog->i_status = HIDING_DIALOG; 142 150 break; … … 144 152 p_dialog->i_action = INTERACT_UPDATE; 145 153 val.p_address = p_dialog; 146 var_Set( p_interaction->p_intf, "interaction", val ); 154 if( p_interaction->p_intf ) 155 var_Set( p_interaction->p_intf, "interaction", val ); 147 156 p_dialog->i_status = SENT_DIALOG; 148 157 msg_Dbg( p_interaction, "Updating dialog %i, %i widgets", … … 150 159 break; 151 160 case HIDDEN_DIALOG: 152 if( !p_dialog->b_reusable ) 161 if( !(p_dialog->i_flags & DIALOG_GOT_ANSWER) ) break; 162 if( !(p_dialog->i_flags & DIALOG_REUSABLE) ) 153 163 { 154 /// \todo Destroy the dialog 164 msg_Dbg( p_interaction, "Destroying dialog %i", 165 p_dialog->i_id ); 166 p_dialog->i_action = INTERACT_DESTROY; 167 val.p_address = p_dialog; 168 if( p_interaction->p_intf ) 169 var_Set( p_interaction->p_intf, "interaction", val ); 155 170 } 156 171 break; 172 case DESTROYED_DIALOG: 173 // Interface has now destroyed it, remove it 174 /// \todo Remove it from the list 175 /// \todo Free data fields 176 free( p_dialog ); 157 177 case NEW_DIALOG: 158 178 // This is truly a new dialog, send it. 159 179 p_dialog->i_action = INTERACT_NEW; 160 180 val.p_address = p_dialog; 161 var_Set( p_interaction->p_intf, "interaction", val ); 162 msg_Dbg( p_interaction, "Creating dialog %i to interface %i, %i widgets", 163 p_dialog->i_id, p_interaction->p_intf->i_object_id, p_dialog->i_widgets ); 181 if( p_interaction->p_intf ) 182 var_Set( p_interaction->p_intf, "interaction", val ); 164 183 p_dialog->i_status = SENT_DIALOG; 165 184 break; … … 167 186 } 168 187 169 vlc_object_release( p_interaction->p_intf ); 188 if( p_interaction->p_intf ) 189 { 190 vlc_object_release( p_interaction->p_intf ); 191 } 170 192 171 193 vlc_mutex_unlock( &p_playlist->p_interaction->object_lock ); … … 188 210 if( new->psz_description ) free( new->psz_description ); 189 211 190 /** Helper function to send a fatalmessage212 /** Helper function to send an error message 191 213 * \param p_this Parent vlc_object 192 214 * \param i_id A predefined ID, 0 if not applicable … … 194 216 * \param psz_format The message to display 195 217 * */ 196 void __intf_UserFatal( vlc_object_t *p_this, int i_id,218 void __intf_UserFatal( vlc_object_t *p_this, 197 219 const char *psz_title, 198 220 const char *psz_format, ... ) … … 201 223 interaction_dialog_t *p_new = NULL; 202 224 user_widget_t *p_widget = NULL; 225 int i_id = DIALOG_ERRORS; 203 226 204 227 if( i_id > 0 ) … … 216 239 } 217 240 218 p_new->i_type = INTERACT_FATAL; 241 p_new->i_flags |= DIALOG_REUSABLE; 242 243 p_new->i_type = INTERACT_DIALOG_ONEWAY; 219 244 p_new->psz_title = strdup( psz_title ); 220 245 … … 235 260 } 236 261 237 #if 0 238 /** Helper function to build a progress bar 239 * \param p_this Parent vlc object 262 /** Helper function to make a login/password box 263 * \param p_this Parent vlc_object 264 * \param psz_title Title for the dialog 265 * \param psz_description A description 266 * \param ppsz_login Returned login 267 * \param ppsz_password Returned password 268 * \return 1 if user clicked Cancel, 0 if OK 240 269 */ 241 interaction_dialog_t *__intf_ProgressBuild( vlc_object_t *p_this, 242 const char *psz_text ) 243 { 244 interaction_dialog_t *p_new = (interaction_dialog_t *)malloc( 245 sizeof( interaction_dialog_t ) ); 246 247 248 return p_new; 249 } 250 #endif 251 252 270 int __intf_UserLoginPassword( vlc_object_t *p_this, 271 const char *psz_title, 272 const char *psz_description, 273 char **ppsz_login, 274 char **ppsz_password ) 275 { 276 int i_ret; 277 interaction_dialog_t *p_new = NULL; 278 user_widget_t *p_widget = NULL; 279 280 INTERACT_INIT( p_new ); 281 282 p_new->i_type = INTERACT_DIALOG_TWOWAY; 283 p_new->psz_title = strdup( psz_title ); 284 285 /* Text */ 286 p_widget = (user_widget_t* )malloc( sizeof( user_widget_t ) ); 287 p_widget->i_type = WIDGET_TEXT; 288 p_widget->psz_text = strdup( psz_description ); 289 INSERT_ELEM ( p_new->pp_widgets, p_new->i_widgets, 290 p_new->i_widgets, p_widget ); 291 292 /* Login */ 293 p_widget = (user_widget_t* )malloc( sizeof( user_widget_t ) ); 294 p_widget->i_type = WIDGET_INPUT_TEXT; 295 p_widget->psz_text = strdup( _("Login") ); 296 p_widget->val.psz_string = NULL; 297 INSERT_ELEM ( p_new->pp_widgets, p_new->i_widgets, 298 p_new->i_widgets, p_widget ); 299 300 /* Password */ 301 p_widget = (user_widget_t* )malloc( sizeof( user_widget_t ) ); 302 p_widget->i_type = WIDGET_INPUT_TEXT; 303 p_widget->psz_text = strdup( _("Password") ); 304 p_widget->val.psz_string = NULL; 305 INSERT_ELEM ( p_new->pp_widgets, p_new->i_widgets, 306 p_new->i_widgets, p_widget ); 307 308 p_new->i_flags = DIALOG_OK_CANCEL; 309 310 i_ret = intf_Interact( p_this, p_new ); 311 312 if( i_ret == DIALOG_OK_YES ) 313 { 314 *ppsz_login = strdup( p_new->pp_widgets[1]->val.psz_string ); 315 *ppsz_password = strdup( p_new->pp_widgets[2]->val.psz_string ); 316 } 317 return i_ret; 318 } 253 319 254 320 /********************************************************************** … … 338 404 static int intf_WaitAnswer( interaction_t *p_interact, interaction_dialog_t *p_dialog ) 339 405 { 340 // TODO: Add to queue, wait for answer 341 return VLC_SUCCESS; 406 int i; 407 vlc_bool_t b_found = VLC_FALSE; 408 vlc_mutex_lock( &p_interact->object_lock ); 409 for( i = 0 ; i< p_interact->i_dialogs; i++ ) 410 { 411 if( p_interact->pp_dialogs[i]->i_id == p_dialog->i_id ) 412 { 413 b_found = VLC_TRUE; 414 } 415 } 416 if( ! b_found ) 417 { 418 INSERT_ELEM( p_interact->pp_dialogs, 419 p_interact->i_dialogs, 420 p_interact->i_dialogs, 421 p_dialog ); 422 } 423 else 424 p_dialog->i_status = UPDATED_DIALOG; 425 vlc_mutex_unlock( &p_interact->object_lock ); 426 427 /// \todo Check that the initiating object is not dying 428 while( p_dialog->i_status != ANSWERED_DIALOG && 429 p_dialog->i_status != HIDING_DIALOG && 430 !p_dialog->p_parent->b_die ) 431 { 432 msleep( 100000 ); 433 } 434 /// \todo locking 435 if( p_dialog->p_parent->b_die ) 436 { 437 p_dialog->i_return = DIALOG_CANCELLED; 438 p_dialog->i_status = ANSWERED_DIALOG; 439 } 440 p_dialog->i_flags |= DIALOG_GOT_ANSWER; 441 return p_dialog->i_return; 342 442 } 343 443 … … 345 445 static int intf_Send( interaction_t *p_interact, interaction_dialog_t *p_dialog ) 346 446 { 447 int i; 448 vlc_bool_t b_found = VLC_FALSE; 347 449 vlc_mutex_lock( &p_interact->object_lock ); 348 450 349 /// \todo Check first it does not exist !!! 350 INSERT_ELEM( p_interact->pp_dialogs, 351 p_interact->i_dialogs, 352 p_interact->i_dialogs, 353 p_dialog ); 451 for( i = 0 ; i< p_interact->i_dialogs; i++ ) 452 { 453 if( p_interact->pp_dialogs[i]->i_id == p_dialog->i_id ) 454 { 455 b_found = VLC_TRUE; 456 } 457 } 458 if( !b_found ) 459 { 460 INSERT_ELEM( p_interact->pp_dialogs, 461 p_interact->i_dialogs, 462 p_interact->i_dialogs, 463 p_dialog ); 464 } 465 else 466 p_dialog->i_status = UPDATED_DIALOG; 354 467 vlc_mutex_unlock( &p_interact->object_lock ); 355 468 return VLC_SUCCESS; … … 363 476 int i; 364 477 478 if( !p_interaction ) return NULL; 479 365 480 for( i = 0 ; i< p_interaction->i_dialogs; i++ ) 366 481 {
