extern "C" ASAPI ASErr PluginMain(char* caller, char* selector, void* message) { AIErr error = kNoErr; // This is just an easy way of not having to cast message to ( SPMessageData* ) // everytime we use IsEqual() sSPBasic = ( ( SPMessageData* )message)->basic; // standard caller/selectors // if these do anything other than restore globals, you may need to move them // into the aquire/releaseSuites block if ( sSPBasic->IsEqual( caller, kSPAccessCaller ) ) { if ( sSPBasic->IsEqual( selector, kSPAccessUnloadSelector ) ) error = UnloadPlugin( (SPAccessMessage*) message ); else if ( sSPBasic->IsEqual( selector, kSPAccessReloadSelector ) ) error = ReloadPlugin( (SPAccessMessage*) message ); } else { // we need suites for the following routines, so acquire all of them now error = acquireSuites( ((SPInterfaceMessage*)message)->d.basic ); if ( error ) goto error; if ( sSPBasic->IsEqual( caller, kSPInterfaceCaller ) ) { if ( sSPBasic->IsEqual( selector, kSPInterfaceStartupSelector ) ) error = StartupPlugin( (SPInterfaceMessage*) message ); // else if ( sSPBasic->IsEqual( selector, kSPInterfaceAboutSelector ) ) // error = AboutPlugin( (SPInterfaceMessage*) message ); else if ( sSPBasic->IsEqual( selector, kSPInterfaceShutdownSelector ) ) error = ShutdownPlugin( (SPInterfaceMessage*) message ); } else error = handlePluginCaller( caller, selector, message ); error: if ( (error) && (error != kSPSuiteNotFoundError) && (error != 1)) report_error( (SPInterfaceMessage*) message, error ); releaseSuites( ((SPInterfaceMessage*)message)->d.basic ); } return error; }
/* Handles message actions for this plug-in. */ extern "C" ASAPI ASErr PluginMain(char* caller, char* selector, void* message) { ASErr error = kASNoError; if ( strcmp( caller, kSPAccessCaller ) == 0 ) { if ( strcmp( selector, kSPAccessUnloadSelector ) == 0 ) error = UnloadPlugin( ( SPAccessMessage* )message ); else if ( strcmp( selector, kSPAccessReloadSelector ) == 0 ) error = ReloadPlugin( ( SPAccessMessage* )message ); } else if ( strcmp( caller, kSPInterfaceCaller ) == 0 ) { if ( strcmp( selector, kSPInterfaceStartupSelector ) == 0 ) error = StartupPlugin( ( SPInterfaceMessage* )message ); else if ( strcmp( selector, kSPInterfaceShutdownSelector ) == 0 ) error = ShutdownPlugin( ( SPInterfaceMessage* )message ); } else if ( strcmp( caller, kCallerAIMenu ) == 0 ) { if ( strcmp( selector, kSelectorAIGoMenuItem ) == 0 ) error = GoMenu( ( AIMenuMessage* )message ); } else if ( strcmp( caller, kCallerAIFilter ) == 0 ) { if ( strcmp( selector, kSelectorAIGetFilterParameters ) == 0 ) error = GetFilterParameters( ( AIFilterMessage* )message ); else if ( strcmp( selector, kSelectorAIGoFilter ) == 0 ) error = GoFilter( ( AIFilterMessage* )message ); } else if ( strcmp( caller, kCallerAITool ) == 0 ) { if ( strcmp( selector, kSelectorAIToolMouseDown ) == 0 ) error = ToolMouseDown( ( AIToolMessage* )message ); } else if ( strcmp( caller, kActionCaller ) == 0 ) { if ( strcmp( selector, kDoActionSelector ) == 0 ) error = DoAction( ( DoActionMessage* )message ); } return error; }
ASErr Plugin::Message(char *caller, char *selector, void *message) { ASErr error = kUnhandledMsgErr; /* Sweet Pea messages */ if (sSPBasic->IsEqual(caller, kSPAccessCaller )) { if (sSPBasic->IsEqual( selector, kSPAccessUnloadSelector)) error = UnloadPlugin(static_cast<SPInterfaceMessage *>(message)); else if (sSPBasic->IsEqual( selector, kSPAccessReloadSelector)) error = ReloadPlugin(static_cast<SPInterfaceMessage *>(message)); } else if (sSPBasic->IsEqual(caller, kSPInterfaceCaller)) { if (sSPBasic->IsEqual(selector, kSPInterfaceAboutSelector)) error = About(static_cast<SPInterfaceMessage *>(message)); else if (sSPBasic->IsEqual(selector, kSPInterfaceStartupSelector)) error = StartupPlugin(static_cast<SPInterfaceMessage *>(message)); else if (sSPBasic->IsEqual(selector, kSPInterfaceShutdownSelector)) error = ShutdownPlugin(static_cast<SPInterfaceMessage *>(message)); } else if (sSPBasic->IsEqual(caller, kSPCacheCaller)) { if (sSPBasic->IsEqual(selector, kSPPluginPurgeCachesSelector)) { if (Purge()) error = kSPPluginCachesFlushResponse; else error = kSPPluginCouldntFlushResponse; } } else if (sSPBasic->IsEqual( caller, kSPPropertiesCaller )) { if (sSPBasic->IsEqual( selector, kSPPropertiesAcquireSelector )) { error = AcquireProperty((SPPropertiesMessage *) message); } else if (sSPBasic->IsEqual( selector, kSPPropertiesReleaseSelector )) { error = ReleaseProperty((SPPropertiesMessage *) message); } } /* Some common AI messages */ else if (sSPBasic->IsEqual(caller, kCallerAINotify)) { AppContext appContext(((SPInterfaceMessage *)message)->d.self); // Ideally we would rely upon the caller to envelop our Notify method. // But since we won't work right if he doesn't, do this ourselves AINotifierMessage *msg = (AINotifierMessage *)message; if (sSPBasic->IsEqual(msg->type, kAIApplicationStartedNotifier)) error = PostStartupPlugin(); if (!error || error == kUnhandledMsgErr) { if (sSPBasic->IsEqual( selector, kSelectorAINotify )) error = Notify(msg); } } else if (sSPBasic->IsEqual(caller, kCallerAIMenu)) { if (sSPBasic->IsEqual( selector, kSelectorAIGoMenuItem )) { error = GoMenuItem((AIMenuMessage *)message); } else if (sSPBasic->IsEqual( selector, kSelectorAIUpdateMenuItem )) { error = UpdateMenuItem((AIMenuMessage *)message); } } else if (sSPBasic->IsEqual(caller, kCallerAIFilter)) { if (sSPBasic->IsEqual( selector, kSelectorAIGetFilterParameters )) { error = GetFilterParameters((AIFilterMessage *)message); } else if (sSPBasic->IsEqual( selector, kSelectorAIGoFilter )) { error = GoFilter((AIFilterMessage *)message); } } else if (sSPBasic->IsEqual(caller, kCallerAIPluginGroup)) { if (sSPBasic->IsEqual( selector, kSelectorAINotifyEdits )) { error = PluginGroupNotify((AIPluginGroupMessage *)message); } else if (sSPBasic->IsEqual( selector, kSelectorAIUpdateArt )) { error = PluginGroupUpdate((AIPluginGroupMessage *)message); } } else if (sSPBasic->IsEqual(caller, kCallerAIFileFormat)) { if (sSPBasic->IsEqual( selector, kSelectorAIGetFileFormatParameters )) { error = GetFileFormatParameters((AIFileFormatMessage *)message); } else if (sSPBasic->IsEqual( selector, kSelectorAIGoFileFormat )) { error = GoFileFormat((AIFileFormatMessage *)message); } else if (sSPBasic->IsEqual( selector, kSelectorAICheckFileFormat )) { error = CheckFileFormat((AIFileFormatMessage *)message); } } else if (sSPBasic->IsEqual(caller, kCallerAITool)) { if (sSPBasic->IsEqual( selector, kSelectorAIEditToolOptions )) { error = EditTool((AIToolMessage *)message); } else if (sSPBasic->IsEqual( selector, kSelectorAITrackToolCursor )) { error = TrackToolCursor((AIToolMessage *)message); } else if (sSPBasic->IsEqual( selector, kSelectorAIToolMouseDown )) { error = ToolMouseDown((AIToolMessage *)message); } else if (sSPBasic->IsEqual( selector, kSelectorAIToolMouseDrag )) { error = ToolMouseDrag((AIToolMessage *)message); } else if (sSPBasic->IsEqual( selector, kSelectorAIToolMouseUp )) { error = ToolMouseUp((AIToolMessage *)message); } else if (sSPBasic->IsEqual( selector, kSelectorAISelectTool )) { error = SelectTool((AIToolMessage *)message); } else if (sSPBasic->IsEqual( selector, kSelectorAIDeselectTool )) { error = DeselectTool((AIToolMessage *)message); } else if (sSPBasic->IsEqual( selector, kSelectorAIReselectTool )) { error = ReselectTool((AIToolMessage *)message); } } else if (sSPBasic->IsEqual(caller, kCallerAILiveEffect )) { if (sSPBasic->IsEqual( selector, kSelectorAIEditLiveEffectParameters )) { error = EditLiveEffectParameters((AILiveEffectEditParamMessage *)message); } else if (sSPBasic->IsEqual( selector, kSelectorAIGoLiveEffect )) { error = GoLiveEffect((AILiveEffectGoMessage *)message); } else if (sSPBasic->IsEqual( selector, kSelectorAILiveEffectInterpolate )) { error = LiveEffectInterpolate((AILiveEffectInterpParamMessage *)message); } else if (sSPBasic->IsEqual( selector, kSelectorAILiveEffectInputType )) { error = LiveEffectGetInputType((AILiveEffectInputTypeMessage *)message); } } else if (sSPBasic->IsEqual(caller, kCallerAITimer )) { if (sSPBasic->IsEqual( selector, kSelectorAIGoTimer )) { error = Timer((AITimerMessage *)message); } } // We should probably handle some ADM messages too, but I don't know // which ones right now... return error; }