Commit f32bdde1 authored by Rafaël Carré's avatar Rafaël Carré

telepathy: shows an empty status when VLC has been stopped

parent 848c1c1f
...@@ -51,6 +51,8 @@ static void Close ( vlc_object_t * ); ...@@ -51,6 +51,8 @@ static void Close ( vlc_object_t * );
static int ItemChange( vlc_object_t *, const char *, static int ItemChange( vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void * ); vlc_value_t, vlc_value_t, void * );
static int StateChange( vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void * );
static int SendToTelepathy( intf_thread_t *, const char * ); static int SendToTelepathy( intf_thread_t *, const char * );
/***************************************************************************** /*****************************************************************************
...@@ -128,6 +130,7 @@ static int Open( vlc_object_t *p_this ) ...@@ -128,6 +130,7 @@ static int Open( vlc_object_t *p_this )
*****************************************************************************/ *****************************************************************************/
static void Close( vlc_object_t *p_this ) static void Close( vlc_object_t *p_this )
{ {
p_this->b_dead = VLC_TRUE;
intf_thread_t *p_intf = (intf_thread_t *)p_this; intf_thread_t *p_intf = (intf_thread_t *)p_this;
playlist_t *p_playlist = pl_Yield( p_this ); playlist_t *p_playlist = pl_Yield( p_this );
...@@ -137,8 +140,12 @@ static void Close( vlc_object_t *p_this ) ...@@ -137,8 +140,12 @@ static void Close( vlc_object_t *p_this )
/* Do not check for VLC_ENOMEM as we're closing */ /* Do not check for VLC_ENOMEM as we're closing */
SendToTelepathy( p_intf, "" ); SendToTelepathy( p_intf, "" );
PL_LOCK;
var_DelCallback( p_playlist, "item-change", ItemChange, p_intf ); var_DelCallback( p_playlist, "item-change", ItemChange, p_intf );
var_DelCallback( p_playlist, "playlist-current", ItemChange, p_intf ); var_DelCallback( p_playlist, "playlist-current", ItemChange, p_intf );
if( p_playlist->p_input )
var_DelCallback( p_playlist->p_input, "state", StateChange, p_intf );
PL_UNLOCK;
pl_Release( p_this ); pl_Release( p_this );
/* we won't use the DBus connection anymore */ /* we won't use the DBus connection anymore */
...@@ -159,6 +166,9 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var, ...@@ -159,6 +166,9 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var,
char *psz_buf = NULL; char *psz_buf = NULL;
input_thread_t *p_input; input_thread_t *p_input;
if( p_intf->b_dead )
return VLC_EGENERIC;
/* Don't update Telepathy presence each time an item has been preparsed */ /* Don't update Telepathy presence each time an item has been preparsed */
if( !strncmp( "playlist-current", psz_var, 16 ) ) if( !strncmp( "playlist-current", psz_var, 16 ) )
{ /* stores the current input item id */ { /* stores the current input item id */
...@@ -199,8 +209,12 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var, ...@@ -199,8 +209,12 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var,
} }
} }
if( !strncmp( "playlist-current", psz_var, 16 ) )
var_AddCallback( p_input, "state", StateChange, p_intf );
/* We format the string to be displayed */ /* We format the string to be displayed */
psz_buf = str_format_meta( p_this, p_intf->p_sys->psz_format ); psz_buf = str_format_meta( p_this, p_intf->p_sys->psz_format );
/* We don't need the input anymore */ /* We don't need the input anymore */
vlc_object_release( p_input ); vlc_object_release( p_input );
...@@ -213,6 +227,20 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var, ...@@ -213,6 +227,20 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var,
return VLC_SUCCESS; return VLC_SUCCESS;
} }
/*****************************************************************************
* StateChange: State change callback
*****************************************************************************/
static int StateChange( vlc_object_t *p_this, const char *psz_var,
vlc_value_t oldval, vlc_value_t newval, void *param )
{
intf_thread_t *p_intf = (intf_thread_t *)param;
if( p_intf->b_dead )
return VLC_EGENERIC;
if( newval.i_int >= END_S )
return SendToTelepathy( p_intf, "" );
return VLC_SUCCESS;
}
/***************************************************************************** /*****************************************************************************
* SendToTelepathy * SendToTelepathy
*****************************************************************************/ *****************************************************************************/
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment