Mercurial > mplayer.hg
changeset 13909:07dadc3066f3
add support for macosx finder argument support (let you bundle mplayer to be a finder compliant .app) patch by Chris Roccati <roccati@pobox.com>
author | nplourde |
---|---|
date | Wed, 10 Nov 2004 16:43:40 +0000 |
parents | befd295c58d3 |
children | 0bfa2dc3231b |
files | configure libvo/vo_quartz.c osdep/Makefile osdep/macosx_finder_args.c parser-mpcmd.c |
diffstat | 5 files changed, 140 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/configure Wed Nov 10 01:45:52 2004 +0000 +++ b/configure Wed Nov 10 16:43:40 2004 +0000 @@ -182,6 +182,7 @@ --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 @@ _menu=no _qtx=auto _macosx=auto +_macosx_finder_support=no _sortsub=yes _freetypeconfig='freetype-config' _fribidi=no @@ -1648,6 +1650,8 @@ --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 @@ 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 @@ 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 @@ /* Mac OS X specific features */ $_def_macosx +$_def_macosx_finder_support /* Build our Win32-loader */ $_def_win32_loader
--- a/libvo/vo_quartz.c Wed Nov 10 01:45:52 2004 +0000 +++ b/libvo/vo_quartz.c Wed Nov 10 16:43:40 2004 +0000 @@ -1011,6 +1011,7 @@ } } +#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 @@ SetFrontProcess(&myProc); } } +#endif return 0; }
--- a/osdep/Makefile Wed Nov 10 01:45:52 2004 +0000 +++ b/osdep/Makefile Wed Nov 10 16:43:40 2004 +0000 @@ -15,6 +15,9 @@ 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/osdep/macosx_finder_args.c Wed Nov 10 16:43:40 2004 +0000 @@ -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; +}
--- a/parser-mpcmd.c Wed Nov 10 01:45:52 2004 +0000 +++ b/parser-mpcmd.c Wed Nov 10 16:43:40 2004 +0000 @@ -65,6 +65,9 @@ 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 @@ 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;