]> git.sesse.net Git - vlc/blobdiff - src/interface/interaction.c
* modules/gui/wxwidgets: small code cleanup.
[vlc] / src / interface / interaction.c
index c110a087a77d410fa82364c33fa18ba5f68de50c..8d3232795127ba8701345d2fef390cf93c088287 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>
 
@@ -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;
 }
@@ -392,6 +398,7 @@ int __intf_UserStringInput( vlc_object_t *p_this,
 {
     int i_ret;
     DIALOG_INIT( TWOWAY );
+    p_new->i_type = INTERACT_DIALOG_TWOWAY;
     p_new->psz_title = strdup( psz_title );
     p_new->psz_description = strdup( psz_description );
 
@@ -401,8 +408,8 @@ int __intf_UserStringInput( vlc_object_t *p_this,
 
     if( i_ret != DIALOG_CANCELLED )
     {
-        assert( p_new->psz_returned[0] );
-        *ppsz_usersString = strdup( p_new->psz_returned[0] );
+        *ppsz_usersString = p_new->psz_returned[0]?
+                                    strdup( p_new->psz_returned[0] ) : NULL;
     }
     return i_ret;
 }
@@ -439,20 +446,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;
 }