summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xconfigure18
-rw-r--r--libvo/vo_quartz.c2
-rw-r--r--osdep/Makefile3
-rw-r--r--osdep/macosx_finder_args.c108
-rw-r--r--parser-mpcmd.c9
5 files changed, 140 insertions, 0 deletions
diff --git a/configure b/configure
index a6752a76de..bb507803c3 100755
--- a/configure
+++ b/configure
@@ -182,6 +182,7 @@ Optional features:
--enable-fribidi Enable using the FriBiDi libs [disabled]
--disable-enca Disable using ENCA charset oracle library [autodetect]
--disable-macosx Disable Mac OS X specific features [autodetect]
+ --enable-macosx-finder-support Enable Mac OS X Finder invocation parameter parsing [disabled]
--disable-inet6 Disable IPv6 support [autodetect]
--disable-gethostbyname2 gethostbyname() function is not provided by the C
library [autodetect]
@@ -1381,6 +1382,7 @@ _shared_pp=no
_menu=no
_qtx=auto
_macosx=auto
+_macosx_finder_support=no
_sortsub=yes
_freetypeconfig='freetype-config'
_fribidi=no
@@ -1648,6 +1650,8 @@ for ac_option do
--enable-macosx) _macosx=yes ;;
--disable-macosx) _macosx=no ;;
+ --enable-macosx-finder-support) _macosx_finder_support=yes ;;
+ --disable-macosx-finder-support) _macosx_finder_support=no ;;
--enable-sortsub) _sortsub=yes ;;
--disable-sortsub) _sortsub=no ;;
@@ -3140,6 +3144,18 @@ EOF
fi
echores "$_macosx"
+echocheck "Mac OS X Finder Support"
+if test "$_macosx_finder_support" = auto ; then
+ _macosx_finder_support=$_macosx
+fi
+if test "$_macosx_finder_support" = yes; then
+ _def_macosx_finder_support='#define MACOSX_FINDER_SUPPORT 1'
+ _macosx_finder_support=yes
+else
+ _def_macosx_finder_support='#undef MACOSX_FINDER_SUPPORT'
+ _macosx_finder_support=no
+fi
+echores "$_macosx_finder_support"
echocheck "Samba support (libsmbclient)"
if test "$_smbsupport" = yes; then
@@ -6571,6 +6587,7 @@ SMBSUPPORT_LIB = $_ld_smb
XMMS_PLUGINS = $_xmms
XMMS_LIB = $_xmms_lib
MACOSX = $_macosx
+MACOSX_FINDER_SUPPORT = $_macosx_finder_support
MACOSX_FRAMEWORKS = $_macosx_frameworks
TOOLAME=$_toolame
TOOLAME_EXTRAFLAGS=$_toolame_extraflags
@@ -6874,6 +6891,7 @@ $_def_dshow
/* Mac OS X specific features */
$_def_macosx
+$_def_macosx_finder_support
/* Build our Win32-loader */
$_def_win32_loader
diff --git a/libvo/vo_quartz.c b/libvo/vo_quartz.c
index 2c0522a6d1..63092dd16d 100644
--- a/libvo/vo_quartz.c
+++ b/libvo/vo_quartz.c
@@ -1011,6 +1011,7 @@ static uint32_t preinit(const char *arg)
}
}
+#ifndef MACOSX_FINDER_SUPPORT
//this chunk of code is heavily based off SDL_macosx.m from SDL
//it uses an Apple private function to request foreground operation
@@ -1029,6 +1030,7 @@ static uint32_t preinit(const char *arg)
SetFrontProcess(&myProc);
}
}
+#endif
return 0;
}
diff --git a/osdep/Makefile b/osdep/Makefile
index 58370bc628..5685f774dd 100644
--- a/osdep/Makefile
+++ b/osdep/Makefile
@@ -15,6 +15,9 @@ endif
getch = getch2.c
timer = timer-lx.c
+ifeq ($(MACOSX_FINDER_SUPPORT),yes)
+SRCS += macosx_finder_args.c
+endif
ifeq ($(TARGET_OS),Darwin)
timer = timer-darwin.c
endif
diff --git a/osdep/macosx_finder_args.c b/osdep/macosx_finder_args.c
new file mode 100644
index 0000000000..16d95303c0
--- /dev/null
+++ b/osdep/macosx_finder_args.c
@@ -0,0 +1,108 @@
+#include <Carbon/Carbon.h>
+#include <ApplicationServices/ApplicationServices.h>
+#include "libmpdemux/url.h"
+#include "mp_msg.h"
+#include "m_option.h"
+#include "m_config.h"
+#include "playtree.h"
+
+static play_tree_t *files=NULL;
+
+static inline void add_entry(play_tree_t **last_parentp, play_tree_t **last_entryp, play_tree_t *entry) {
+
+ if(*last_entryp==NULL)
+ play_tree_set_child(*last_parentp, entry);
+ else
+ play_tree_append_entry(*last_entryp, entry);
+
+ *last_entryp=entry;
+}
+
+static pascal OSErr AppleEventHandlerProc(const AppleEvent *theAppleEvent, AppleEvent* reply, SInt32 handlerRefcon) {
+OSErr err=errAEEventNotHandled, res=noErr;
+AEDescList docList;
+long itemsInList;
+
+ AERemoveEventHandler(kCoreEventClass, kAEOpenDocuments, NULL, FALSE);
+ if((res=AEGetParamDesc(theAppleEvent, keyDirectObject, typeAEList, &docList))==noErr) {
+ if((res=AECountItems(&docList, &itemsInList))==noErr) {
+ Size currentSize=0;
+ int valid=0,i;
+ char *parm=NULL;
+ play_tree_t *last_entry=NULL;
+
+ files=play_tree_new();
+ for(i=1;i<=itemsInList;++i) {
+
+ for(;;) {
+ OSErr e;
+ Size actualSize=0;
+ AEKeyword keywd;
+ DescType returnedType;
+
+ if((e=AEGetNthPtr(&docList, i, typeFileURL, &keywd, &returnedType, (Ptr)parm, currentSize, &actualSize))==noErr) {
+ if(actualSize>=currentSize) {
+ currentSize=actualSize+1;
+ parm=realloc(parm, currentSize);
+ }
+ else {
+ parm[actualSize]=0;
+ valid=1;
+ break;
+ }
+ }
+ else {
+ valid=0;
+ break;
+ }
+ }
+
+ if(valid) {
+ URL_t *url=url_new(parm);
+
+ if(url && !strcmp(url->protocol,"file") && !strcmp(url->hostname,"localhost")) {
+ play_tree_t *entry=play_tree_new();
+
+ url_unescape_string(url->file, url->file);
+ play_tree_add_file(entry, url->file);
+ add_entry(&files, &last_entry, entry);
+ }
+
+ url_free(url);
+ }
+ }
+
+ if(parm)
+ free(parm);
+
+ err=noErr;
+ }
+ else
+ mp_msg(MSGT_CFGPARSER, MSGL_ERR, "AECountItems() error %d\n", res);
+
+ AEDisposeDesc(&docList);
+ }
+ else
+ mp_msg(MSGT_CFGPARSER, MSGL_ERR, "AEGetParamDesc() error %d\n", res);
+
+ QuitApplicationEventLoop();
+ return err;
+}
+
+play_tree_t *macosx_finder_args(m_config_t *config, int argc, char **argv) {
+ProcessSerialNumber myPsn;
+char myPsnStr[5+10+1+10+1];
+
+ GetCurrentProcess(&myPsn);
+ snprintf(myPsnStr, 5+10+1+10+1, "-psn_%u_%u", myPsn.highLongOfPSN, myPsn.lowLongOfPSN);
+ myPsnStr[5+10+1+10]=0;
+
+ if((argc==2) && !strcmp(myPsnStr, argv[1])) {
+ m_config_set_option(config, "quiet", NULL);
+ InitCursor();
+ AEInstallEventHandler(kCoreEventClass, kAEOpenDocuments, NewAEEventHandlerUPP(AppleEventHandlerProc), 0, FALSE);
+ RunApplicationEventLoop();
+ }
+
+ return files;
+}
diff --git a/parser-mpcmd.c b/parser-mpcmd.c
index 1864ae7686..55697d901c 100644
--- a/parser-mpcmd.c
+++ b/parser-mpcmd.c
@@ -65,6 +65,9 @@ m_config_parse_mp_command_line(m_config_t *config, int argc, char **argv)
char entbuf[10];
int no_more_opts = 0;
play_tree_t *last_parent, *last_entry = NULL, *root;
+#ifdef MACOSX_FINDER_SUPPORT
+ extern play_tree_t *macosx_finder_args(m_config_t *, int , char **);
+#endif
#ifdef MP_DEBUG
assert(config != NULL);
@@ -74,6 +77,12 @@ m_config_parse_mp_command_line(m_config_t *config, int argc, char **argv)
config->mode = M_COMMAND_LINE;
mode = GLOBAL;
+#ifdef MACOSX_FINDER_SUPPORT
+ root=macosx_finder_args(config, argc, argv);
+ if(root)
+ return root;
+#endif
+
last_parent = root = play_tree_new();
/* in order to work recursion detection properly in parse_config_file */
++recursion_depth;