Changeset 093de8561e556dcc9c233fa4aef3046fb658721c

Show
Ignore:
Timestamp:
08/02/06 21:51:46 (2 years ago)
Author:
Clément Stenac <zorglub@videolan.org>
git-committer:
Clément Stenac <zorglub@videolan.org> 1154548306 +0000
git-parent:

[7eee710f7983a7f186fe5cacaaaca74614690a89]

git-author:
Clément Stenac <zorglub@videolan.org> 1154548306 +0000
Message:

Interaction cleanup, remove some unused functions, factorize some code, ...

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • include/vlc_common.h

    r89471fa r093de85  
    619619#define DECMALLOC_VOID( var, type ) type* var = (type*)malloc( sizeof(type) );\ 
    620620                                    if( !var ) return; 
     621#define DECMALLOC_ERR( var, type ) type* var = (type*)malloc( sizeof(type) );\ 
     622                                    if( !var ) return VLC_ENOMEM; 
    621623#define DECMALLOC_NULL( var, type ) type* var = (type*)malloc( sizeof(type) );\ 
    622624                                    if( !var ) return NULL; 
    623625 
    624626#define FREENULL(a) if( a ) { free( a ); a = NULL; } 
     627#define FREE(a) if( a ) { free( a ); } 
    625628 
    626629/* Dynamic array handling: realloc array, move data, increment position */ 
  • include/vlc_interaction.h

    r14e11ab r093de85  
    170170 ***************************************************************************/ 
    171171 
    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  
    175172#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*, ...) ); 
     173VLC_EXPORT( int, __intf_UserFatal,( vlc_object_t*, vlc_bool_t, const char*, const char*, ...) ); 
    177174#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*, ...) ); 
     175VLC_EXPORT( int, __intf_UserWarn,( vlc_object_t*, const char*, const char*, ...) ); 
    179176#define intf_UserLoginPassword( a, b, c, d, e... ) __intf_UserLoginPassword( VLC_OBJECT(a),b,c,d,e) 
    180177VLC_EXPORT( int, __intf_UserLoginPassword,( vlc_object_t*, const char*, const char*, char **, char **) ); 
    181178#define intf_UserYesNo( a, b, c, d, e, f ) __intf_UserYesNo( VLC_OBJECT(a),b,c, d, e, f ) 
    182179VLC_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  
    191180#define intf_UserStringInput( a, b, c, d ) __intf_UserStringInput( VLC_OBJECT(a),b,c,d ) 
    192181VLC_EXPORT( int, __intf_UserStringInput,(vlc_object_t*, const char*, const char*, char **) ); 
    193182 
    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 ) 
     185VLC_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 ) 
     187VLC_EXPORT( void, __intf_ProgressUpdate,( vlc_object_t*, int, const char*, float, int) ); 
     188#define intf_ProgressIsCancelled( a, b ) __intf_UserProgressIsCancelled( VLC_OBJECT(a),b ) 
     189VLC_EXPORT( vlc_bool_t, __intf_UserProgressIsCancelled,( vlc_object_t*, int ) ); 
    198190 
    199191#define intf_UserHide( a, b ) __intf_UserHide( VLC_OBJECT(a), b ) 
  • include/vlc_symbols.h

    r14e11ab r093de85  
    430430    int (*__input_Read_inner) (vlc_object_t *, input_item_t *, vlc_bool_t); 
    431431    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
    433433    void (*intf_InteractionManage_inner) (playlist_t *); 
    434434    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*, ...); 
    436436    int (*__intf_UserLoginPassword_inner) (vlc_object_t*, const char*, const char*, char **, char **); 
    437437    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
    440440    void (*__intf_UserHide_inner) (vlc_object_t *, int); 
    441441    void *__stats_Create_deprecated; 
     
    518518    void *stats_TimersClean_deprecated; 
    519519    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
    522522    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*, ...); 
    524524    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); 
    525527}; 
    526528# if defined (__PLUGIN__) 
     
    909911#  define __input_Read (p_symbols)->__input_Read_inner 
    910912#  define __net_ConnectUDP (p_symbols)->__net_ConnectUDP_inner 
    911 #  define __intf_Interact (p_symbols)->__intf_Interact_inner 
    912913#  define intf_InteractionManage (p_symbols)->intf_InteractionManage_inner 
    913914#  define intf_InteractionDestroy (p_symbols)->intf_InteractionDestroy_inner 
     
    915916#  define __intf_UserLoginPassword (p_symbols)->__intf_UserLoginPassword_inner 
    916917#  define __intf_UserYesNo (p_symbols)->__intf_UserYesNo_inner 
    917 #  define __intf_UserProgress (p_symbols)->__intf_UserProgress_inner 
    918 #  define __intf_UserProgressUpdate (p_symbols)->__intf_UserProgressUpdate_inner 
    919918#  define __intf_UserHide (p_symbols)->__intf_UserHide_inner 
    920919#  define __stats_Update (p_symbols)->__stats_Update_inner 
     
    989988#  define __stats_CounterCreate (p_symbols)->__stats_CounterCreate_inner 
    990989#  define __stats_TimersClean (p_symbols)->__stats_TimersClean_inner 
    991 #  define __intf_IntfProgressUpdate (p_symbols)->__intf_IntfProgressUpdate_inner 
    992 #  define __intf_IntfProgress (p_symbols)->__intf_IntfProgress_inner 
    993990#  define __intf_UserWarn (p_symbols)->__intf_UserWarn_inner 
    994991#  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 
    995994# elif defined (HAVE_DYNAMIC_PLUGINS) && !defined (__BUILTIN__) 
    996995/****************************************************************** 
     
    13821381    ((p_symbols)->__input_Read_inner) = __input_Read; \ 
    13831382    ((p_symbols)->__net_ConnectUDP_inner) = __net_ConnectUDP; \ 
    1384     ((p_symbols)->__intf_Interact_inner) = __intf_Interact; \ 
    13851383    ((p_symbols)->intf_InteractionManage_inner) = intf_InteractionManage; \ 
    13861384    ((p_symbols)->intf_InteractionDestroy_inner) = intf_InteractionDestroy; \ 
     
    13881386    ((p_symbols)->__intf_UserLoginPassword_inner) = __intf_UserLoginPassword; \ 
    13891387    ((p_symbols)->__intf_UserYesNo_inner) = __intf_UserYesNo; \ 
    1390     ((p_symbols)->__intf_UserProgress_inner) = __intf_UserProgress; \ 
    1391     ((p_symbols)->__intf_UserProgressUpdate_inner) = __intf_UserProgressUpdate; \ 
    13921388    ((p_symbols)->__intf_UserHide_inner) = __intf_UserHide; \ 
    13931389    ((p_symbols)->__stats_Update_inner) = __stats_Update; \ 
     
    14621458    ((p_symbols)->__stats_CounterCreate_inner) = __stats_CounterCreate; \ 
    14631459    ((p_symbols)->__stats_TimersClean_inner) = __stats_TimersClean; \ 
    1464     ((p_symbols)->__intf_IntfProgressUpdate_inner) = __intf_IntfProgressUpdate; \ 
    1465     ((p_symbols)->__intf_IntfProgress_inner) = __intf_IntfProgress; \ 
    14661460    ((p_symbols)->__intf_UserWarn_inner) = __intf_UserWarn; \ 
    14671461    ((p_symbols)->__intf_UserProgressIsCancelled_inner) = __intf_UserProgressIsCancelled; \ 
     1462    ((p_symbols)->__intf_Progress_inner) = __intf_Progress; \ 
     1463    ((p_symbols)->__intf_ProgressUpdate_inner) = __intf_ProgressUpdate; \ 
    14681464    (p_symbols)->net_ConvertIPv4_deprecated = NULL; \ 
    14691465    (p_symbols)->__playlist_ItemCopy_deprecated = NULL; \ 
     
    14921488    (p_symbols)->playlist_Move_deprecated = NULL; \ 
    14931489    (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; \ 
    14941493    (p_symbols)->__stats_Create_deprecated = NULL; \ 
    14951494    (p_symbols)->__stats_CounterGet_deprecated = NULL; \ 
     
    15001499    (p_symbols)->stats_TimerClean_deprecated = NULL; \ 
    15011500    (p_symbols)->stats_TimersClean_deprecated = NULL; \ 
     1501    (p_symbols)->__intf_IntfProgressUpdate_deprecated = NULL; \ 
     1502    (p_symbols)->__intf_IntfProgress_deprecated = NULL; \ 
    15021503    (p_symbols)->streaming_ChainToPsz_deprecated = NULL; \ 
    15031504 
  • modules/demux/avi/avi.c

    r6cb1101 r093de85  
    22992299            float f_pos = (float)i_pos; 
    23002300            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 ); 
    23032303        } 
    23042304 
  • modules/services_discovery/shout.c

    r6cb1101 r093de85  
    197197    int i_dialog_id; 
    198198 
    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 ); 
    200201 
    201202    p_sys->b_dialog = VLC_TRUE; 
     
    215216                float f_pos = (float)(p_sys->p_node_cat->i_children)* 2 *100.0 / 
    216217                              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 ); 
    219220            } 
    220221            vlc_object_release( p_input ); 
  • src/interface/interaction.c

    r384f1ef r093de85  
    3737#include <vlc/vlc.h> 
    3838#include <vlc/input.h> 
     39#include <assert.h> 
    3940 
    4041#include "vlc_interaction.h" 
     
    4546 * Local prototypes 
    4647 *****************************************************************************/ 
    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 * 
     48static void                  InteractionInit( playlist_t *p_playlist ); 
     49static interaction_t *       InteractionGet( vlc_object_t *p_this ); 
     50static void                  InteractionSearchInterface( interaction_t * 
    5051                                                          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 
     52static interaction_dialog_t *DialogGetById( interaction_t* , int ); 
     53static void                  DialogDestroy( interaction_dialog_t *p_dialog ); 
     54static int DialogSend( vlc_object_t *p_this, interaction_dialog_t *p_dialog ); 
    9855 
    9956/** 
     
    10562{ 
    10663    int i; 
    107  
    10864    // Remove all dialogs - Interfaces must be able to clean up their data 
    109  
    11065    for( i = p_interaction->i_dialogs -1 ; i >= 0; i-- ) 
    11166    { 
    11267        interaction_dialog_t * p_dialog = p_interaction->pp_dialogs[i]; 
    113         intf_InteractionDialogDestroy( p_dialog ); 
     68        DialogDestroy( p_dialog ); 
    11469        REMOVE_ELEM( p_interaction->pp_dialogs, p_interaction->i_dialogs, i ); 
    11570    } 
    116  
    11771    vlc_object_destroy( p_interaction ); 
    11872} 
     
    12983    vlc_value_t val; 
    13084    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; 
    13486 
    13587    // Nothing to do 
     
    13890    vlc_mutex_lock( &p_interaction->object_lock ); 
    13991 
    140     intf_InteractionSearchInterface( p_interaction ); 
    141  
     92    InteractionSearchInterface( p_interaction ); 
    14293    if( !p_interaction->p_intf ) 
    14394    { 
     
    14697        { 
    14798            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 
    151100 
    152101            // Pretend we have hidden and destroyed it 
     
    201150                         i_index); 
    202151            i_index--; 
    203             intf_InteractionDialogDestroy( p_dialog ); 
     152            DialogDestroy( p_dialog ); 
    204153            break; 
    205154        case NEW_DIALOG: 
     
    222171} 
    223172 
    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 
    245188 *  \param p_this     Parent vlc_object 
    246189 *  \param b_blocking Is this dialog blocking or not? 
     
    248191 *  \param psz_format The message to display 
    249192 *  */ 
    250 void __intf_UserFatal( vlc_object_t *p_this, 
    251                        vlc_bool_t b_blocking, 
     193int __intf_UserFatal( vlc_object_t *p_this, vlc_bool_t b_blocking, 
    252194                       const char *psz_title, 
    253195                       const char *psz_format, ... ) 
    254196{ 
    255197    va_list args; 
    256     interaction_dialog_t *p_new = NULL; 
    257      
    258     INTERACT_INIT( p_new ); 
     198    DIALOG_INIT( ONEWAY ); 
    259199     
    260200    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; 
    266202 
    267203    if( b_blocking ) 
     
    270206        p_new->i_flags = DIALOG_NONBLOCKING_ERROR; 
    271207 
    272     intf_Interact( p_this, p_new ); 
     208    return DialogSend( p_this, p_new ); 
    273209} 
    274210 
     
    278214 *  \param psz_format The message to display 
    279215 *  */ 
    280 void __intf_UserWarn( vlc_object_t *p_this, 
    281                        const char *psz_title, 
    282                        const char *psz_format, ... ) 
     216int __intf_UserWarn( vlc_object_t *p_this, 
     217                     const char *psz_title, 
     218                     const char *psz_format, ... ) 
    283219{ 
    284220    va_list args; 
    285     interaction_dialog_t *p_new = NULL; 
    286      
    287     INTERACT_INIT( p_new ); 
     221    DIALOG_INIT( ONEWAY ); 
    288222     
    289223    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 
    295225 
    296226    p_new->i_flags = DIALOG_WARNING; 
    297227 
    298     intf_Interact( p_this, p_new ); 
     228    return DialogSend( p_this, p_new ); 
    299229} 
    300230 
     
    315245                      const char *psz_other ) 
    316246{ 
    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 
    323249    p_new->psz_title = strdup( psz_title ); 
    324250    p_new->psz_description = strdup( psz_description ); 
     
    328254    if( psz_other ) 
    329255        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 ); 
    336258} 
    337259 
    338260/** Helper function to create a dialogue showing a progress-bar with some info 
    339261 *  \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 ) 
    341263 *  \param psz_status       Current status 
    342264 *  \param f_position       Current position (0.0->100.0) 
     
    344266 *  \return                 Dialog id, to give to UserProgressUpdate 
    345267 */ 
    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 ); 
     268int __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 ); 
    359272    p_new->psz_description = strdup( psz_status ); 
    360273    p_new->val.f_float = f_pos; 
    361274    p_new->i_timeToGo = i_time; 
    362275 
    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 ); 
    367285    return p_new->i_id; 
    368286} 
     
    376294 *  \return                 nothing 
    377295 */ 
    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 ); 
     296void __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 ); 
    383300    interaction_dialog_t *p_dialog; 
    384301 
     
    386303 
    387304    vlc_mutex_lock( &p_interaction->object_lock ); 
    388     p_dialog  =  intf_InteractionGetById( p_this, i_id ); 
     305    p_dialog  =  DialogGetById( p_interaction, i_id ); 
    389306 
    390307    if( !p_dialog ) 
     
    394311    } 
    395312 
    396     if( p_dialog->psz_description ) 
    397         free( p_dialog->psz_description ); 
     313    FREE( p_dialog->psz_description ); 
    398314    p_dialog->psz_description = strdup( psz_status ); 
    399315 
     
    405321} 
    406322 
    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 
    408325 *  \param p_this           Parent vlc_object 
    409326 *  \param i_id             Identifier of the dialogue 
     
    412329vlc_bool_t __intf_UserProgressIsCancelled( vlc_object_t *p_this, int i_id ) 
    413330{ 
    414     interaction_t *p_interaction = intf_InteractionGet( p_this ); 
     331    interaction_t *p_interaction = InteractionGet( p_this ); 
    415332    interaction_dialog_t *p_dialog; 
     333    vlc_bool_t b_cancel; 
    416334 
    417335    if( !p_interaction ) return VLC_TRUE; 
    418336 
    419337    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 ); 
    422339    if( !p_dialog ) 
    423340    { 
     
    426343    } 
    427344 
    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; 
    430348} 
    431349 
     
    444362                              char **ppsz_password ) 
    445363{ 
    446  
    447364    int i_ret; 
    448     interaction_dialog_t *p_new = NULL; 
    449  
    450     INTERACT_INIT( p_new ); 
    451  
     365    DIALOG_INIT( TWOWAY ); 
    452366    p_new->i_type = INTERACT_DIALOG_TWOWAY; 
    453367    p_new->psz_title = strdup( psz_title ); 
     
    456370    p_new->i_flags = DIALOG_LOGIN_PW_OK_CANCEL; 
    457371 
    458     i_ret = intf_Interact( p_this, p_new ); 
     372    i_ret = DialogSend( p_this, p_new ); 
    459373 
    460374    if( i_ret != DIALOG_CANCELLED ) 
    461375    { 
     376        assert( p_new->psz_returned[0] && p_new->psz_returned[1] ); 
    462377        *ppsz_login = strdup( p_new->psz_returned[0] ); 
    463378        *ppsz_password = strdup( p_new->psz_returned[1] ); 
     
    478393                              char **ppsz_usersString ) 
    479394{ 
    480  
    481395    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 ); 
    487397    p_new->psz_title = strdup( psz_title ); 
    488398    p_new->psz_description = strdup( psz_description ); 
     
    490400    p_new->i_flags = DIALOG_PSZ_INPUT_OK_CANCEL; 
    491401 
    492     i_ret = intf_Interact( p_this, p_new ); 
     402    i_ret = DialogSend( p_this, p_new ); 
    493403 
    494404    if( i_ret != DIALOG_CANCELLED ) 
    495405    { 
     406        assert( p_new->psz_returned[0] ); 
    496407        *ppsz_usersString = strdup( p_new->psz_returned[0] ); 
    497408    } 
    498409    return i_ret; 
    499 } 
    500  
    501 /** Helper function to create a progress-bar in the main interface with a 
    502  *  single-line description 
    503  *  \param p_this           Parent vlc_object 
    504  *  \param psz_status       Current status 
    505  *  \param f_position       Current position (0.0->100.0) 
    506  *  \return                 Dialog id, to give to IntfProgressUpdate 
    507  */ 
    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 interface 
    529  *  \param p_this           Parent vlc_object 
    530  *  \param i_id             Identifier of the dialog 
    531  *  \param psz_status       New status 
    532  *  \param f_position       New position (0.0->100.0) 
    533  *  \return                 nothing 
    534  */ 
    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) ; 
    560410} 
    561411 
     
    567417void __intf_UserHide( vlc_object_t *p_this, int i_id ) 
    568418{ 
    569     interaction_t *p_interaction = intf_InteractionGet( p_this ); 
     419    interaction_t *p_interaction = InteractionGet( p_this ); 
    570420    interaction_dialog_t *p_dialog; 
    571421 
     
    573423 
    574424    vlc_mutex_lock( &p_interaction->object_lock ); 
    575     p_dialog =  intf_InteractionGetById( p_this, i_id ); 
     425    p_dialog = DialogGetById( p_interaction, i_id ); 
    576426 
    577427    if( !p_dialog ) 
     
    584434    vlc_mutex_unlock( &p_interaction->object_lock ); 
    585435} 
    586  
    587  
    588436 
    589437/********************************************************************** 
     
    592440 
    593441/* Get the interaction object. Create it if needed */ 
    594 static interaction_t * intf_InteractionGet( vlc_object_t *p_this ) 
     442static interaction_t * InteractionGet( vlc_object_t *p_this ) 
    595443{ 
    596444    playlist_t *p_playlist; 
     
    599447    p_playlist = (playlist_t*) vlc_object_find( p_this, VLC_OBJECT_PLAYLIST, 
    600448                                                FIND_ANYWHERE ); 
    601  
    602449    if( !p_playlist ) 
    603     { 
    604450        return NULL; 
    605     } 
    606451 
    607452    if( p_playlist->p_interaction == NULL ) 
    608     { 
    609         intf_InteractionInit( p_playlist ); 
    610     } 
     453       InteractionInit( p_playlist ); 
    611454 
    612455    p_interaction = p_playlist->p_interaction; 
    613456 
    614457    vlc_object_release( p_playlist ); 
    615  
    616458    return p_interaction; 
    617459} 
    618460 
    619461/* 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 ) ); 
     462static void InteractionInit( playlist_t *p_playlist ) 
     463
     464    interaction_t *p_interaction = vlc_object_create( VLC_OBJECT( p_playlist ), 
     465                                                      sizeof( interaction_t ) ); 
    626466    if( !p_interaction ) 
    627467    { 
     
    641481 
    642482/* Look for an interface suitable for interaction */ 
    643 static void intf_InteractionSearchInterface( interaction_t *p_interaction ) 
     483static void InteractionSearchInterface( interaction_t *p_interaction ) 
    644484{ 
    645485    vlc_list_t  *p_list; 
     
    668508} 
    669509 
    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 */ 
     511static interaction_dialog_t *DialogGetById( interaction_t *p_interaction
     512                                            int i_id
    673513{ 
    674514    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 */ 
     524static 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 */ 
     536static 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++ ) 
    680558        { 
    681             b_found = VLC_TRUE; 
     559            if( p_interaction->pp_dialogs[i]->i_id == p_dialog->i_id ) 
     560                b_found = VLC_TRUE; 
    682561        } 
    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        } 
    690600    } 
    691601    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</