Commit 1fa9ce8d authored by Clément Stenac's avatar Clément Stenac

* Move all notifications plugins to misc/notify

* Don't find playlist
* Fix a few bugs in notification plugins

Todo: find a way to get rid of this mostly redundant code and rewrite the XOSD plugin
parent 415749bf
......@@ -5637,6 +5637,7 @@ AC_CONFIG_FILES([
modules/misc/dummy/Makefile
modules/misc/memcpy/Makefile
modules/misc/network/Makefile
modules/misc/notify/Makefile
modules/misc/testsuite/Makefile
modules/misc/playlist/Makefile
modules/misc/xml/Makefile
......
......@@ -10,7 +10,4 @@ SOURCES_logger = logger.c
SOURCES_vod_rtsp = rtsp.c
SOURCES_gnutls = gnutls.c
SOURCES_svg = svg.c
SOURCES_msn = msn.c
SOURCES_growl = growl.c
SOURCES_notify = notify.c
SOURCES_profile_parser = profile_parser.c
SOURCES_msn = msn.c
SOURCES_growl = growl.c
SOURCES_notify = notify.c
SOURCES_xosd = xosd.c
......@@ -126,18 +126,15 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var,
vlc_value_t oldval, vlc_value_t newval, void *param )
{
char psz_tmp[GROWL_MAX_LENGTH];
playlist_t *p_playlist;
char *psz_title = NULL;
char *psz_artist = NULL;
char *psz_album = NULL;
input_thread_t *p_input;
p_playlist = (playlist_t *)vlc_object_find( p_this, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( !p_playlist ) return VLC_EGENERIC;
playlist_t *p_playlist = pl_Yield( p_this );
p_input = p_playlist->p_input;
vlc_object_release( p_playlist );
if( !p_input ) return VLC_SUCCESS;
vlc_object_yield( p_input );
......
......@@ -86,13 +86,7 @@ static int Open( vlc_object_t *p_this )
intf_thread_t *p_intf = (intf_thread_t *)p_this;
playlist_t *p_playlist;
/* Allocate instance and initialize some members */
p_intf->p_sys = (intf_sys_t *)malloc( sizeof( intf_sys_t ) );
if( p_intf->p_sys == NULL )
{
msg_Err( p_intf, "out of memory" );
return -1;
}
MALLOC_ERR( p_intf->p_sys, intf_sys_t );
p_intf->p_sys->psz_format = config_GetPsz( p_intf, "msn-format" );
if( !p_intf->p_sys->psz_format )
......@@ -102,22 +96,10 @@ static int Open( vlc_object_t *p_this )
}
msg_Dbg( p_intf, "using format: %s", p_intf->p_sys->psz_format );
p_playlist = (playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( !p_playlist )
{
msg_Err( p_intf, "could not find playlist object" );
free( p_intf->p_sys->psz_format );
free( p_intf->p_sys );
return VLC_ENOOBJ;
}
/* Item's info changes */
p_playlist = pl_Yield( p_intf );
var_AddCallback( p_playlist, "item-change", ItemChange, p_intf );
/* We're playing a new item */
var_AddCallback( p_playlist, "playlist-current", ItemChange, p_intf );
vlc_object_release( p_playlist );
pl_Release( p_intf );
p_intf->pf_run = Run;
......@@ -130,19 +112,15 @@ static int Open( vlc_object_t *p_this )
static void Close( vlc_object_t *p_this )
{
intf_thread_t *p_intf = (intf_thread_t *)p_this;
playlist_t *p_playlist = (playlist_t *)vlc_object_find(
p_this, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
playlist_t *p_playlist = pl_Yield( p_this );
/* clear the MSN stuff ... else it looks like we're still playing
* something although VLC (or the MSN plugin) is closed */
SendToMSN( "\\0Music\\01\\0\\0\\0\\0\\0\\0\\0" );
if( p_playlist )
{
var_DelCallback( p_playlist, "item-change", ItemChange, p_intf );
var_DelCallback( p_playlist, "playlist-current", ItemChange, p_intf );
}
pl_Release( p_this );
/* Destroy structure */
free( p_intf->p_sys->psz_format );
......@@ -164,22 +142,16 @@ static int ItemChange( 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;
playlist_t *p_playlist;
char psz_tmp[MSN_MAX_LENGTH];
char *psz_title = NULL;
char *psz_artist = NULL;
char *psz_album = NULL;
input_thread_t *p_input;
if( !p_intf->p_sys ) return VLC_SUCCESS;
p_playlist = (playlist_t *)vlc_object_find( p_this, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( !p_playlist ) return VLC_EGENERIC;
playlist_t *p_playlist = pl_Yield( p_this );
p_input = p_playlist->p_input;
vlc_object_release( p_playlist );
pl_Release( p_this );
if( !p_input ) return VLC_SUCCESS;
vlc_object_yield( p_input );
......
......@@ -74,28 +74,19 @@ vlc_module_end();
static int Open( vlc_object_t *p_this )
{
intf_thread_t *p_intf = (intf_thread_t *)p_this;
playlist_t *p_playlist = (playlist_t *)vlc_object_find(
p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
if( !p_playlist )
{
msg_Err( p_intf, "could not find playlist object" );
return VLC_ENOOBJ;
}
var_AddCallback( p_playlist, "playlist-current", ItemChange, p_intf );
/* var_AddCallback( p_playlist, "item-change", ItemChange, p_intf );*/
vlc_object_release( p_playlist );
playlist_t *p_playlist;
if( !notify_init( APPLICATION_NAME ) )
{
msg_Err( p_intf, "can't find notification daemon" );
return VLC_EGENERIC;
}
p_playlist = pl_Yield( p_intf );
var_AddCallback( p_playlist, "playlist-current", ItemChange, p_intf );
pl_Release( p_intf );
p_intf->pf_run = Run;
msg_Dbg( p_intf,"notify plugin started");
return VLC_SUCCESS;
}
......@@ -104,14 +95,9 @@ static int Open( vlc_object_t *p_this )
*****************************************************************************/
static void Close( vlc_object_t *p_this )
{
playlist_t *p_playlist = (playlist_t *)vlc_object_find(
p_this, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
if( p_playlist )
{
playlist_t *p_playlist = pl_Yield( p_intf );
var_DelCallback( p_playlist, "playlist-current", ItemChange, p_this );
vlc_object_release( p_playlist );
}
pl_Release( p_intf );
notify_uninit();
}
......@@ -121,7 +107,7 @@ static void Close( vlc_object_t *p_this )
*****************************************************************************/
static void Run( intf_thread_t *p_this )
{
msleep( 100*INTF_IDLE_SLEEP );
msleep( 10*INTF_IDLE_SLEEP );
}
/*****************************************************************************
......@@ -136,12 +122,11 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var,
char *psz_artist = NULL;
char *psz_album = NULL;
input_thread_t *p_input=NULL;
p_playlist = (playlist_t *)vlc_object_find( p_this, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( !p_playlist ) return VLC_EGENERIC;
playlist_t * p_playlist = pl_Yield( p_this );
p_input = p_playlist->p_input;
vlc_object_release( p_playlist );
if( !p_input ) return VLC_SUCCESS;
vlc_object_yield( p_input );
......
......@@ -141,18 +141,10 @@ static int Open( vlc_object_t *p_this )
#endif
playlist_t *p_playlist =
(playlist_t *)vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist == NULL )
{
return VLC_EGENERIC;
}
playlist_t *p_playlist = pl_Yield( p_intf );
var_AddCallback( p_playlist, "playlist-current", PlaylistNext, p_this );
var_AddCallback( p_playlist, "item-change", PlaylistNext, p_this );
vlc_object_release( p_playlist );
pl_Release( p_intf );
/* Set user preferences */
xosd_set_font( p_intf->p_sys->p_osd,
......@@ -189,6 +181,10 @@ static int Open( vlc_object_t *p_this )
static void Close( vlc_object_t *p_this )
{
intf_thread_t *p_intf = (intf_thread_t *)p_this;
playlist_t *p_playlist = pl_Yield( p_intf );
var_DelCallback( p_playlist, "playlist-current", PlaylistNext, p_this );
var_DelCallback( p_playlist, "item-change", PlaylistNext, p_this );
pl_Release( p_intf );
/* Uninitialize library */
xosd_destroy( p_intf->p_sys->p_osd );
......@@ -215,12 +211,7 @@ static void Run( intf_thread_t *p_intf )
if( p_intf->p_sys->b_need_update == VLC_TRUE )
{
p_intf->p_sys->b_need_update = VLC_FALSE;
p_playlist = (playlist_t *)vlc_object_find( p_intf,
VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
if( !p_playlist )
{
continue;
}
p_playlist = pl_Yield( p_intf );
if( p_playlist->i_size < 0 )
{
......
SOURCES_goom = goom.c
SOURCES_xosd = xosd.c
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