Commit 22f5492b authored by Felix Paul Kühne's avatar Felix Paul Kühne

growl: fixed runtime behavior and compilation

parent 234d6579
......@@ -1717,9 +1717,10 @@ AC_ARG_ENABLE(growl,
[enable_growl=no])
AS_IF([test "${enable_growl}" != "no"], [
VLC_ADD_PLUGIN([growl_udp])
AC_CHECK_HEADERS(Growl/GrowlDefines.h, [
AC_CHECK_HEADERS(${CONTRIB_DIR}/Growl/Growl.framework/Versions/A/Headers/GrowlDefines.h, [
VLC_ADD_PLUGIN([growl])
VLC_ADD_LDFLAGS([growl], [-Wl,-framework,Growl,-framework,AppKit])
VLC_ADD_LDFLAGS([growl], [-F${CONTRIB_DIR}/Growl -Wl,-framework,Growl,-framework,CoreFoundation])
VLC_ADD_OBJCFLAGS([growl], [-F${CONTRIB_DIR}/Growl])
VLC_ADD_OBJCFLAGS([growl], [-fobjc-exceptions] )
])
]
......
......@@ -8,6 +8,7 @@
/* Begin PBXBuildFile section */
CC0FB34C0F8BED1100F057F7 /* CoreDialogs.nib in Resources */ = {isa = PBXBuildFile; fileRef = CC0FB34A0F8BED1100F057F7 /* CoreDialogs.nib */; };
CC3F9F7C1350AAE000B0E885 /* Growl.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CC3F9F7B1350AAE000B0E885 /* Growl.framework */; };
CC402EB00E00ABBB006A4BA4 /* vlc.icns in Resources */ = {isa = PBXBuildFile; fileRef = F74F13DF02C2A53401EE194C /* vlc.icns */; };
CC402EB10E00ABBB006A4BA4 /* MainMenu.nib in Resources */ = {isa = PBXBuildFile; fileRef = F74F13EA02C2A79C01EE194C /* MainMenu.nib */; };
CC402EB30E00ABBB006A4BA4 /* generic.icns in Resources */ = {isa = PBXBuildFile; fileRef = F6E4F90B02D2648B01A80112 /* generic.icns */; };
......@@ -295,6 +296,7 @@
CC33C24F0D2578F5008C4683 /* volumeslider_graphite.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = volumeslider_graphite.png; path = Resources/volumeslider_graphite.png; sourceTree = "<group>"; };
CC33C2500D2578F5008C4683 /* fullscreen_graphite.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = fullscreen_graphite.png; path = Resources/fullscreen_graphite.png; sourceTree = "<group>"; };
CC3DC89B0A7CDB9600B53F32 /* ApplicationServices.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = ApplicationServices.framework; path = /System/Library/Frameworks/ApplicationServices.framework; sourceTree = "<absolute>"; };
CC3F9F7B1350AAE000B0E885 /* Growl.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Growl.framework; path = "../../contrib/Growl/Growl.framework"; sourceTree = "<group>"; };
CC402F4B0E00ABBB006A4BA4 /* VLC.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = VLC.bundle; sourceTree = BUILT_PRODUCTS_DIR; };
CC426FD01020D44F00A32659 /* Sparkle.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Sparkle.framework; path = ../../contrib/Sparkle/Sparkle.framework; sourceTree = SOURCE_ROOT; };
CC4A33210F8CB017000FC4A7 /* coredialogs.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = coredialogs.m; path = ../../../modules/gui/macosx/coredialogs.m; sourceTree = SOURCE_ROOT; };
......@@ -439,6 +441,7 @@
CC402F440E00ABBB006A4BA4 /* WebKit.framework in Frameworks */,
CCBE999F0F922C51000705F8 /* CoreServices.framework in Frameworks */,
CC426FD11020D44F00A32659 /* Sparkle.framework in Frameworks */,
CC3F9F7C1350AAE000B0E885 /* Growl.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
......@@ -547,6 +550,7 @@
1058C7ACFEA557BF11CA2CBB /* Linked Frameworks */ = {
isa = PBXGroup;
children = (
CC3F9F7B1350AAE000B0E885 /* Growl.framework */,
CC426FD01020D44F00A32659 /* Sparkle.framework */,
CCBE999E0F922C51000705F8 /* CoreServices.framework */,
CC962E2C0CC7992800A56695 /* WebKit.framework */,
......@@ -1185,6 +1189,7 @@
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1)",
"\"$(SRCROOT)/../../contrib/Growl\"",
);
FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SRCROOT)/../../contrib/Sparkle\"";
GCC_DYNAMIC_NO_PIC = NO;
......@@ -1219,6 +1224,7 @@
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1)",
"\"$(SRCROOT)/../../contrib/Growl\"",
);
FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SRCROOT)/../../contrib/Sparkle\"";
GCC_ENABLE_FIX_AND_CONTINUE = NO;
......@@ -1249,6 +1255,7 @@
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
"$(FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1)",
"\"$(SRCROOT)/../../contrib/Growl\"",
);
FRAMEWORK_SEARCH_PATHS_QUOTED_FOR_TARGET_1 = "\"$(SRCROOT)/../../contrib/Sparkle\"";
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
......
......@@ -50,7 +50,7 @@
# include "config.h"
#endif
#import <Foundation/Foundation.h>
#import <CoreFoundation/CoreFoundation.h>
#import <Growl/GrowlDefines.h>
#include <vlc_common.h>
......@@ -67,9 +67,10 @@
struct intf_sys_t
{
CFDataRef default_icon;
NSAutoreleasePool *p_pool;
CFStringRef app_name;
CFStringRef notification_type;
int i_id;
int i_item_changes;
};
/*****************************************************************************
......@@ -105,23 +106,26 @@ 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;
intf_sys_t *p_sys;
p_sys = p_intf->p_sys = calloc( 1, sizeof(intf_sys_t) );
if( !p_sys )
return VLC_ENOMEM;
p_sys->p_pool = [[NSAutoreleasePool alloc] init];
p_sys->app_name = CFSTR( "VLC media player" );
p_sys->notification_type = CFSTR( "New input playing" );
char *data_path = config_GetDataDir ( p_this );
char buf[strlen (data_path) + sizeof ("/vlc48x48.png")];
snprintf (buf, sizeof (buf), "%s/vlc48x48.png", data_path);
char buf[strlen (data_path) + sizeof ("/vlc512x512.png")];
snprintf (buf, sizeof (buf), "%s/vlc512x512.png", data_path);
msg_Dbg( p_this, "looking for icon at %s", buf );
free( data_path );
p_sys->default_icon = (CFDataRef) readFile( buf );
var_AddCallback( pl_Get( p_intf ), "item-current", ItemChange, p_intf );
p_playlist = pl_Get( p_intf );
var_AddCallback( p_playlist, "item-change", ItemChange, p_intf );
var_AddCallback( p_playlist, "item-current", ItemChange, p_intf );
RegisterToGrowl( p_this );
return VLC_SUCCESS;
......@@ -132,14 +136,16 @@ static int Open( vlc_object_t *p_this )
*****************************************************************************/
static void Close( vlc_object_t *p_this )
{
intf_sys_t *p_sys = ((intf_thread_t*)p_this)->p_sys;
intf_thread_t *p_intf = (intf_thread_t *)p_this;
playlist_t *p_playlist = pl_Get( p_this );
intf_sys_t *p_sys = p_intf->p_sys;
var_DelCallback( pl_Get( p_this ), "item-current", ItemChange, p_this );
var_DelCallback( p_playlist, "item-change", ItemChange, p_intf );
var_DelCallback( p_playlist, "item-current", ItemChange, p_intf );
CFRelease( p_sys->default_icon );
CFRelease( p_sys->app_name );
CFRelease( p_sys->notification_type );
[p_sys->p_pool release];
free( p_sys );
}
......@@ -149,32 +155,56 @@ static void Close( vlc_object_t *p_this )
static int ItemChange( vlc_object_t *p_this, const char *psz_var,
vlc_value_t oldval, vlc_value_t newval, void *param )
{
VLC_UNUSED(psz_var); VLC_UNUSED(oldval); VLC_UNUSED(newval);
VLC_UNUSED(oldval);
intf_thread_t *p_intf = (intf_thread_t*)param;
intf_thread_t *p_intf = (intf_thread_t *)param;
char *psz_tmp = NULL;
char *psz_title = NULL;
char *psz_artist = NULL;
char *psz_album = NULL;
input_thread_t *p_input;
p_input = playlist_CurrentInput( (playlist_t*)p_this );
input_item_t *p_item = newval.p_address;
bool b_is_item_current = !strcmp( "item-current", psz_var );
/* Don't update each time an item has been preparsed */
if( b_is_item_current )
{ /* stores the current input item id */
p_intf->p_sys->i_id = p_item->i_id;
p_intf->p_sys->i_item_changes = 0;
return VLC_SUCCESS;
}
else
{
if( p_item->i_id != p_intf->p_sys->i_id ) { /* "item-change" */
p_intf->p_sys->i_item_changes = 0;
return VLC_SUCCESS;
}
/* Some variable bitrate inputs call "item-change" callbacks each time
* their length is updated, that is several times per second.
* We'll limit the number of changes to 1 per input. */
if( p_intf->p_sys->i_item_changes > 0 )
return VLC_SUCCESS;
p_intf->p_sys->i_item_changes++;
}
input_thread_t *p_input = playlist_CurrentInput( (playlist_t*)p_this );
if( !p_input ) return VLC_SUCCESS;
char *psz_name = input_item_GetName( input_GetItem( p_input ) );
if( p_input->b_dead || !psz_name )
if( p_input->b_dead || !input_GetItem(p_input)->psz_name )
{
/* Not playing anything ... */
free( psz_name );
vlc_object_release( p_input );
return VLC_SUCCESS;
}
free( psz_name );
/* Playing something ... */
input_item_t *p_item = input_GetItem( p_input );
psz_title = input_item_GetTitleFbName( p_item );
if( input_item_GetNowPlaying( p_item ) )
psz_title = input_item_GetNowPlaying( p_item );
else
psz_title = input_item_GetTitleFbName( p_item );
if( EMPTY_STR( psz_title ) )
{
free( psz_title );
......@@ -194,11 +224,7 @@ static int ItemChange( vlc_object_t *p_this, const char *psz_var,
else if( psz_artist )
i_ret = asprintf( &psz_tmp, "%s\n%s", psz_title, psz_artist );
else
{
psz_tmp = strdup( psz_title );
if( psz_tmp == NULL )
i_ret = -1;
}
i_ret = asprintf(&psz_tmp, "%s", psz_title );
if( i_ret == -1 )
{
......
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