]> git.sesse.net Git - vlc/blobdiff - modules/codec/cmml/intf.c
Remove E_()
[vlc] / modules / codec / cmml / intf.c
index 346c69020ef0edd8c45d6f0ace8b6ba300a27a16..6ca85e01941d040f002b7f89ded6979e0bdc6c04 100644 (file)
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
 #include <vlc/vlc.h>
 
 #include <stdio.h>
-#include <stdlib.h>                                      /* malloc(), free() */
-#include <string.h>
 
 #ifdef HAVE_UNISTD_H
 #    include <unistd.h>
 #endif
 
-#include <vlc/decoder.h>
-#include <vlc/input.h>
-#include <vlc/intf.h>
-#include <vlc/vout.h>
-
+#include <vlc_codec.h>
+#include <vlc_input.h>
+#include <vlc_interface.h>
+#include <vlc_vout.h>
+#include <vlc_playlist.h>
 #include <vlc_osd.h>
 
 #include "vlc_keys.h"
@@ -64,7 +66,7 @@ struct intf_sys_t
     decoder_t *         p_cmml_decoder;
     input_thread_t *    p_input;
 
-    vlc_bool_t          b_key_pressed;
+    int                 i_key_action;
 };
 
 struct navigation_history_t
@@ -76,6 +78,10 @@ struct navigation_history_t
 /*****************************************************************************
  * Local prototypes.
  *****************************************************************************/
+
+int          OpenIntf               ( vlc_object_t * );
+void         CloseIntf              ( vlc_object_t * );
+
 static int   InitThread                 ( intf_thread_t * );
 static int   MouseEvent                 ( vlc_object_t *, char const *,
                                           vlc_value_t, vlc_value_t, void * );
@@ -108,7 +114,7 @@ static void RunIntf        ( intf_thread_t *p_intf );
 /*****************************************************************************
  * OpenIntf: initialize CMML interface
  *****************************************************************************/
-int E_(OpenIntf) ( vlc_object_t *p_this )
+int OpenIntf ( vlc_object_t *p_this )
 {
     intf_thread_t *p_intf = (intf_thread_t *)p_this;
 
@@ -120,7 +126,7 @@ int E_(OpenIntf) ( vlc_object_t *p_this )
 
     p_intf->pf_run = RunIntf;
 
-    var_AddCallback( p_intf->p_libvlc, "key-pressed", KeyEvent, p_intf );
+    var_AddCallback( p_intf->p_libvlc, "key-action", KeyEvent, p_intf );
     /* we also need to add the callback for "mouse-clicked", but do that later
      * when we've found a p_vout */
 
@@ -140,7 +146,7 @@ int E_(OpenIntf) ( vlc_object_t *p_this )
 /*****************************************************************************
  * CloseIntf: destroy dummy interface
  *****************************************************************************/
-void E_(CloseIntf) ( vlc_object_t *p_this )
+void CloseIntf ( vlc_object_t *p_this )
 {
     intf_thread_t * p_intf = (intf_thread_t *)p_this;
     vout_thread_t * p_vout;
@@ -158,7 +164,7 @@ void E_(CloseIntf) ( vlc_object_t *p_this )
         vlc_object_release( p_vout );
     }
 
-    var_DelCallback( p_intf->p_libvlc, "key-pressed", KeyEvent, p_intf );
+    var_DelCallback( p_intf->p_libvlc, "key-action", KeyEvent, p_intf );
 
     vlc_object_release( p_intf->p_sys->p_cmml_decoder );
 
@@ -213,48 +219,21 @@ static void RunIntf( intf_thread_t *p_intf )
         /*
          * keyboard event
          */
-        if( p_intf->p_sys->b_key_pressed )
+        switch( p_intf->p_sys->i_key_action )
         {
-            vlc_value_t val;
-            int i, i_action = -1;
-            struct hotkey *p_hotkeys = p_intf->p_libvlc->p_hotkeys;
-
-            /* Find action triggered by hotkey (if any) */
-            var_Get( p_intf->p_libvlc, "key-pressed", &val );
-
-            /* Acknowledge that we've handled the b_key_pressed event */
-            p_intf->p_sys->b_key_pressed = VLC_FALSE;
-
-#ifdef CMML_INTF_DEBUG
-            msg_Dbg( p_intf, "Got a keypress: %d", val.i_int );
-#endif
-
-            for( i = 0; p_hotkeys[i].psz_action != NULL; i++ )
-            {
-                if( p_hotkeys[i].i_key == val.i_int )
-                    i_action = p_hotkeys[i].i_action;
-            }
-
-            /* What did the user do? */
-            if( i_action != -1 )
-            {
-                switch( i_action )
-                {
-                    case ACTIONID_NAV_ACTIVATE:
-                        FollowAnchor( p_intf );
-                        break;
-                    case ACTIONID_HISTORY_BACK:
-                        GoBack( p_intf );
-                        break;
-                    case ACTIONID_HISTORY_FORWARD:
-                        GoForward( p_intf );
-                        break;
-                    default:
-                        break;
-                }
-            }
+            case ACTIONID_NAV_ACTIVATE:
+                FollowAnchor( p_intf );
+                break;
+            case ACTIONID_HISTORY_BACK:
+                GoBack( p_intf );
+                break;
+            case ACTIONID_HISTORY_FORWARD:
+                GoForward( p_intf );
+                break;
+            default:
+                break;
         }
-
+        p_intf->p_sys->i_key_action = 0;
         vlc_mutex_unlock( &p_intf->change_lock );
 
         (void) DisplayPendingAnchor( p_intf, p_vout );
@@ -291,11 +270,11 @@ static int DisplayPendingAnchor( intf_thread_t *p_intf, vout_thread_t *p_vout )
     if( var_Get( p_cmml_decoder, "psz-current-anchor-description", &val )
             != VLC_SUCCESS )
     {
-        return VLC_TRUE;
+        return true;
     }
 
     if( !val.p_address )
-        return VLC_TRUE;
+        return true;
 
     psz_description = val.p_address;
 
@@ -316,10 +295,10 @@ static int DisplayPendingAnchor( intf_thread_t *p_intf, vout_thread_t *p_vout )
             if( var_Get( p_primary_intf, "intf-displays-cmml-description", &val )
                     == VLC_SUCCESS )
             {
-                if( val.b_bool == VLC_TRUE )
+                if( val.b_bool == true )
                 {
                     vlc_object_release( p_primary_intf );
-                    return VLC_TRUE;
+                    return true;
                 }
             }
 
@@ -331,7 +310,7 @@ static int DisplayPendingAnchor( intf_thread_t *p_intf, vout_thread_t *p_vout )
                 != VLC_SUCCESS )
         {
             /* text render unsuccessful: do nothing */
-            return VLC_FALSE;
+            return false;
         }
 
         /* text render successful: clear description */
@@ -346,7 +325,7 @@ static int DisplayPendingAnchor( intf_thread_t *p_intf, vout_thread_t *p_vout )
         psz_url = NULL;
     }
 
-    return VLC_TRUE;
+    return true;
 }
 
 
@@ -380,7 +359,7 @@ static int InitThread( intf_thread_t * p_intf )
         p_intf->p_sys->p_input = p_input;
         p_intf->p_sys->p_cmml_decoder = p_cmml_decoder;
 
-        p_intf->p_sys->b_key_pressed = VLC_FALSE;
+        p_intf->p_sys->i_key_action = 0;
 
         vlc_mutex_unlock( &p_intf->change_lock );
 
@@ -398,6 +377,9 @@ static int InitThread( intf_thread_t * p_intf )
 static int MouseEvent( vlc_object_t *p_this, char const *psz_var,
                        vlc_value_t oldval, vlc_value_t newval, void *p_data )
 {
+    VLC_UNUSED(p_this); VLC_UNUSED(psz_var);
+    VLC_UNUSED(oldval); VLC_UNUSED(newval);
+    VLC_UNUSED(p_data);
     /* TODO: handle mouse clicks on the anchor text */
 
     return VLC_SUCCESS;
@@ -409,10 +391,12 @@ static int MouseEvent( vlc_object_t *p_this, char const *psz_var,
 static int KeyEvent( vlc_object_t *p_this, char const *psz_var,
                        vlc_value_t oldval, vlc_value_t newval, void *p_data )
 {
+    VLC_UNUSED(p_this); VLC_UNUSED(psz_var);
+    VLC_UNUSED(oldval); VLC_UNUSED(newval);
     intf_thread_t *p_intf = (intf_thread_t *)p_data;
     vlc_mutex_lock( &p_intf->change_lock );
 
-    p_intf->p_sys->b_key_pressed = VLC_TRUE;
+    p_intf->p_sys->i_key_action = newval.i_int;
 
     vlc_mutex_unlock( &p_intf->change_lock );
 
@@ -462,13 +446,13 @@ static void FollowAnchor ( intf_thread_t *p_intf )
 
         /* Get new URL */
         p_current_item = p_playlist->status.p_item;
+        char *psz_uri = input_item_GetURI( p_current_item->p_input );
 #ifdef CMML_INTF_DEBUG
-        msg_Dbg( p_intf, "Current playlist item URL is \"%s\"",
-                p_current_item->input.psz_uri );
+        msg_Dbg( p_intf, "Current playlist item URL is \"%s\"", psz_uri );
 #endif
 
-        psz_uri_to_load = XURL_Concat( p_current_item->p_input->psz_uri,
-                                       psz_url );
+        psz_uri_to_load = XURL_Concat( psz_uri, psz_url );
+        free( psz_uri );
 
 #ifdef CMML_INTF_DEBUG
         msg_Dbg( p_intf, "URL to load is \"%s\"", psz_uri_to_load );
@@ -533,7 +517,7 @@ static void FollowAnchor ( intf_thread_t *p_intf )
             msg_Dbg( p_intf, "calling browser_Open with \"%s\"", psz_url );
 #endif
             (void) browser_Open( psz_url );
-            playlist_Control( p_playlist, PLAYLIST_PAUSE, 0 );
+            playlist_Control( p_playlist, PLAYLIST_PAUSE, true, 0 );
         }
 
         free( psz_uri_to_load );
@@ -552,10 +536,12 @@ char *GetTimedURLFromPlaylistItem( intf_thread_t *p_intf,
     char *psz_seconds = NULL;
     int i_seconds;
 
-    psz_url = XURL_GetWithoutFragment( p_current_item->input->psz_uri );
+    char *psz_uri = input_item_GetURI( p_current_item->p_input );
+    psz_url = XURL_GetWithoutFragment( psz_uri );
+    free( psz_uri );
 
     /* Get current time as a string */
-    if( XURL_IsFileURL( psz_url ) == VLC_TRUE )
+    if( XURL_IsFileURL( psz_url ) == true )
         psz_url = xstrcat( psz_url, "#" );
     else
         psz_url = xstrcat( psz_url, "?" );
@@ -572,13 +558,14 @@ char *GetTimedURLFromPlaylistItem( intf_thread_t *p_intf,
 
     return psz_return_value;
 #else
+    VLC_UNUSED(p_intf);
     void *p;
 
     /* Suppress warning messages about unused functions */
     p = GetTimedURIFragmentForTime; /* unused */
     p = GetCurrentTimeInSeconds;    /* unused */
 
-    return strdup( p_current_item->p_input->psz_uri );
+    return input_item_GetURI( p_current_item->p_input );
 #endif
 }
 
@@ -612,6 +599,8 @@ static
 int GoBackCallback( vlc_object_t *p_this, char const *psz_var,
                     vlc_value_t oldval, vlc_value_t newval, void *p_data )
 {
+    VLC_UNUSED(p_this); VLC_UNUSED(psz_var);
+    VLC_UNUSED(oldval); VLC_UNUSED(newval);
     intf_thread_t *p_intf = (intf_thread_t *) p_data;
     GoBack( p_intf );
     return VLC_SUCCESS;
@@ -621,6 +610,8 @@ static
 int GoForwardCallback( vlc_object_t *p_this, char const *psz_var,
                        vlc_value_t oldval, vlc_value_t newval, void *p_data )
 {
+    VLC_UNUSED(p_this); VLC_UNUSED(psz_var);
+    VLC_UNUSED(oldval); VLC_UNUSED(newval);
     intf_thread_t *p_intf = (intf_thread_t *) p_data;
     GoForward( p_intf );
     return VLC_SUCCESS;
@@ -631,6 +622,8 @@ int FollowAnchorCallback( vlc_object_t *p_this, char const *psz_var,
                           vlc_value_t oldval, vlc_value_t newval,
                           void *p_data )
 {
+    VLC_UNUSED(p_this); VLC_UNUSED(psz_var);
+    VLC_UNUSED(oldval); VLC_UNUSED(newval);
     intf_thread_t *p_intf = (intf_thread_t *) p_data;
     FollowAnchor( p_intf );
     return VLC_SUCCESS;
@@ -678,7 +671,7 @@ void GoBack( intf_thread_t *p_intf )
 #endif
 
     /* Check whether we can go back in the history */
-    if( history_CanGoBack( p_history ) == VLC_FALSE )
+    if( history_CanGoBack( p_history ) == false )
     {
         msg_Warn( p_intf, "can't go back: already at beginning of history" );
         vlc_object_release( p_playlist );
@@ -756,7 +749,7 @@ void GoForward( intf_thread_t *p_intf )
 #endif
 
     /* Check whether we can go forward in the history */
-    if( history_CanGoForward( p_history ) == VLC_FALSE )
+    if( history_CanGoForward( p_history ) == false )
     {
         msg_Warn( p_intf, "can't go forward: already at end of history" );
         vlc_object_release( p_playlist );
@@ -796,7 +789,8 @@ static void ReplacePlaylistItem( playlist_t *p_playlist, char *psz_uri )
 {
     playlist_Stop( p_playlist );
     (void) playlist_Add( p_playlist, psz_uri, psz_uri,
-                         PLAYLIST_INSERT /* FIXME: used to be PLAYLIST_REPLACE */, PLAYLIST_END|PLAYLIST_GO, VLC_TRUE /* FIXME: p_playlist->status.i_index */ );
+                         PLAYLIST_INSERT /* FIXME: used to be PLAYLIST_REPLACE */, PLAYLIST_END|PLAYLIST_GO, true /* FIXME: p_playlist->status.i_index */,
+                         false);
 }
 
 /****************************************************************************