X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fmisc%2Fnotify%2Fgrowl.m;h=575739f24881571e7148919a9af525f523c64d6b;hb=28e52ddb9b8a1ae76eba086114ecf0bca90383ee;hp=53c6a4e82534735e04be399c4f780ad7e5f8f3d1;hpb=ba6501f3084682844e7ee87bad3986bced5f3652;p=vlc diff --git a/modules/misc/notify/growl.m b/modules/misc/notify/growl.m index 53c6a4e825..575739f248 100644 --- a/modules/misc/notify/growl.m +++ b/modules/misc/notify/growl.m @@ -58,6 +58,7 @@ #include #include #include +#include /***************************************************************************** @@ -89,14 +90,14 @@ static CFDataRef readFile(const char *); * Module descriptor ****************************************************************************/ -vlc_module_begin(); - set_category( CAT_INTERFACE ); - set_subcategory( SUBCAT_INTERFACE_CONTROL ); - set_shortname( "Growl" ); - set_description( N_("Growl Notification Plugin") ); - set_capability( "interface", 0 ); - set_callbacks( Open, Close ); -vlc_module_end(); +vlc_module_begin () + set_category( CAT_INTERFACE ) + set_subcategory( SUBCAT_INTERFACE_CONTROL ) + set_shortname( "Growl" ) + set_description( N_("Growl Notification Plugin") ) + set_capability( "interface", 0 ) + set_callbacks( Open, Close ) +vlc_module_end () /***************************************************************************** * Open: initialize and create stuff @@ -106,7 +107,7 @@ static int Open( vlc_object_t *p_this ) intf_thread_t *p_intf = (intf_thread_t *)p_this; intf_sys_t *p_sys; - p_sys = p_intf->p_sys = calloc( sizeof(intf_sys_t), 1); + p_sys = p_intf->p_sys = calloc( 1, sizeof(intf_sys_t) ); if( !p_sys ) return VLC_ENOMEM; @@ -114,13 +115,14 @@ static int Open( vlc_object_t *p_this ) p_sys->app_name = CFSTR( "VLC media player" ); p_sys->notification_type = CFSTR( "New input playing" ); - const char *data_path = config_GetDataDir (); + char *data_path = config_GetDataDir ( p_this ); char buf[strlen (data_path) + sizeof ("/vlc48x48.png")]; snprintf (buf, sizeof (buf), "%s/vlc48x48.png", data_path); + free( data_path ); p_sys->default_icon = (CFDataRef) readFile( buf ); playlist_t *p_playlist = pl_Hold( p_intf ); - var_AddCallback( p_playlist, "playlist-current", ItemChange, p_intf ); + var_AddCallback( p_playlist, "item-current", ItemChange, p_intf ); pl_Release( p_intf ); RegisterToGrowl( p_this ); @@ -141,7 +143,7 @@ static void Close( vlc_object_t *p_this ) free( p_sys ); playlist_t *p_playlist = pl_Hold( p_this ); - var_DelCallback( p_playlist, "playlist-current", ItemChange, p_this ); + var_DelCallback( p_playlist, "item-current", ItemChange, p_this ); pl_Release( p_this ); } @@ -159,13 +161,9 @@ 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; - playlist_t *p_playlist = pl_Hold( p_this ); - - p_input = p_playlist->p_input; - pl_Release( p_this ); + p_input = playlist_CurrentInput( (playlist_t*)p_this ); if( !p_input ) return VLC_SUCCESS; - vlc_object_hold( p_input ); char *psz_name = input_item_GetName( input_GetItem( p_input ) ); if( p_input->b_dead || !psz_name ) @@ -180,17 +178,12 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var, /* Playing something ... */ input_item_t *p_item = input_GetItem( p_input ); - psz_title = input_item_GetTitle( p_item ); - if( psz_title == NULL || EMPTY_STR( psz_title ) ) + psz_title = input_item_GetTitleFbName( p_item ); + if( EMPTY_STR( psz_title ) ) { free( psz_title ); - psz_title = input_item_GetName( input_GetItem( p_input ) ); - if( psz_title == NULL || EMPTY_STR( psz_title ) ) - { - free( psz_title ); - vlc_object_release( p_input ); - return VLC_SUCCESS; - } + vlc_object_release( p_input ); + return VLC_SUCCESS; } psz_artist = input_item_GetArtist( p_item ); @@ -219,7 +212,7 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var, char *psz_arturl = input_item_GetArtURL( p_item ); CFDataRef art = NULL; if( psz_arturl && !strncmp( psz_arturl, "file://", 7 ) && - strlen( psz_arturl ) > 7 ) + decode_URI( psz_arturl + 7 ) ) art = (CFDataRef) readFile( psz_arturl + 7 ); free( psz_title ); @@ -230,6 +223,7 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var, NotifyToGrowl( p_intf, psz_tmp, art ); if( art ) CFRelease( art ); + free( psz_tmp ); vlc_object_release( p_input ); return VLC_SUCCESS;