]> git.sesse.net Git - vlc/blobdiff - src/interface/interaction.c
Should fix OS X build
[vlc] / src / interface / interaction.c
index 1c5565acfcedd884c93ab1541b9d6d962e6abe7f..6b884b1fff2994b40581c06b45e884c954b386d0 100644 (file)
@@ -1,7 +1,7 @@
 /*****************************************************************************
  * interaction.c: User interaction functions
  *****************************************************************************
- * Copyright (C) 2005-2006 VideoLAN
+ * Copyright (C) 2005-2006 the VideoLAN team
  * $Id$
  *
  * Authors: ClĂ©ment Stenac <zorglub@videolan.org>
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
+
+#include <vlc/vlc.h>
+
 #include <stdlib.h>                                      /* free(), strtol() */
 #include <stdio.h>                                                   /* FILE */
 #include <string.h>                                            /* strerror() */
 
-#include <vlc/vlc.h>
 #include <vlc/input.h>
 #include <assert.h>
 
@@ -217,7 +219,7 @@ int __intf_UserWarn( vlc_object_t *p_this,
 {
     va_list args;
     DIALOG_INIT( ONEWAY );
-    
+
     p_new->psz_title = strdup( psz_title );
     FORMAT_DESC
 
@@ -270,6 +272,7 @@ int __intf_Progress( vlc_object_t *p_this, const char *psz_title,
     p_new->psz_description = strdup( psz_status );
     p_new->val.f_float = f_pos;
     p_new->i_timeToGo = i_time;
+    p_new->psz_alternate_button = strdup( _("Cancel" ) );
 
     if( psz_title )
     {
@@ -364,16 +367,19 @@ int __intf_UserLoginPassword( vlc_object_t *p_this,
     p_new->i_type = INTERACT_DIALOG_TWOWAY;
     p_new->psz_title = strdup( psz_title );
     p_new->psz_description = strdup( psz_description );
+    p_new->psz_default_button = strdup( _("Ok" ) );
+    p_new->psz_alternate_button = strdup( _("Cancel" ) );
 
     p_new->i_flags = DIALOG_LOGIN_PW_OK_CANCEL;
 
     i_ret = DialogSend( p_this, p_new );
 
-    if( i_ret != DIALOG_CANCELLED )
+    if( i_ret != DIALOG_CANCELLED && i_ret != VLC_EGENERIC )
     {
-        assert( p_new->psz_returned[0] && p_new->psz_returned[1] );
-        *ppsz_login = strdup( p_new->psz_returned[0] );
-        *ppsz_password = strdup( p_new->psz_returned[1] );
+        *ppsz_login = p_new->psz_returned[0]?
+                                strdup( p_new->psz_returned[0] ) : NULL;
+        *ppsz_password = p_new->psz_returned[1]?
+                                strdup( p_new->psz_returned[1] ) : NULL;
     }
     return i_ret;
 }
@@ -439,20 +445,17 @@ void __intf_UserHide( vlc_object_t *p_this, int i_id )
 /* Get the interaction object. Create it if needed */
 static interaction_t * InteractionGet( vlc_object_t *p_this )
 {
-    playlist_t *p_playlist;
     interaction_t *p_interaction;
+    playlist_t *p_playlist = pl_Yield( p_this );
 
-    p_playlist = (playlist_t*) vlc_object_find( p_this, VLC_OBJECT_PLAYLIST,
-                                                FIND_ANYWHERE );
-    if( !p_playlist )
-        return NULL;
-
+    PL_LOCK;
     if( p_playlist->p_interaction == NULL )
        InteractionInit( p_playlist );
 
     p_interaction = p_playlist->p_interaction;
+    PL_UNLOCK;
 
-    vlc_object_release( p_playlist );
+    pl_Release( p_this );
     return p_interaction;
 }
 
@@ -541,7 +544,7 @@ static int DialogSend( vlc_object_t *p_this, interaction_dialog_t *p_dialog )
 
     if( p_this->i_flags & OBJECT_FLAGS_NOINTERACT ) return VLC_EGENERIC;
 
-    if( config_GetInt(p_this, "interact") || 
+    if( config_GetInt(p_this, "interact") ||
         p_dialog->i_flags & DIALOG_BLOCKING_ERROR ||
         p_dialog->i_flags & DIALOG_NONBLOCKING_ERROR )
     {
@@ -568,7 +571,6 @@ static int DialogSend( vlc_object_t *p_this, interaction_dialog_t *p_dialog )
         }
         else
             p_dialog->i_status = UPDATED_DIALOG;
-        vlc_mutex_unlock( &p_interaction->object_lock );
 
         if( p_dialog->i_type == INTERACT_DIALOG_TWOWAY ) // Wait for answer
         {
@@ -577,15 +579,17 @@ static int DialogSend( vlc_object_t *p_this, interaction_dialog_t *p_dialog )
                    p_dialog->i_status != HIDDEN_DIALOG &&
                    !p_dialog->p_parent->b_die )
             {
+                vlc_mutex_unlock( &p_interaction->object_lock );
                 msleep( 100000 );
+                vlc_mutex_lock( &p_interaction->object_lock );
             }
-            /// \todo locking ?
             if( p_dialog->p_parent->b_die )
             {
                 p_dialog->i_return = DIALOG_CANCELLED;
                 p_dialog->i_status = ANSWERED_DIALOG;
             }
             p_dialog->i_flags |= DIALOG_GOT_ANSWER;
+            vlc_mutex_unlock( &p_interaction->object_lock );
             return p_dialog->i_return;
         }
         else
@@ -598,4 +602,4 @@ static int DialogSend( vlc_object_t *p_this, interaction_dialog_t *p_dialog )
     }
     else
         return VLC_EGENERIC;
-} 
+}