Пример #1
0
ASErr Plugin::Message(char *caller, char *selector, void *message)
{
	ASErr error = kUnhandledMsgErr;

	//sAIUser->MessageAlert(ai::UnicodeString(caller));
	
	// Acquire any missing optional suites.
	AcquireOptionalSuites();

	/* Sweet Pea messages */

	

	if (strcmp(caller, kSPAccessCaller ) == 0)
	{
		if (strcmp( selector, kSPAccessUnloadSelector) == 0)
			error = UnloadPlugin((SPInterfaceMessage *)message);

		else if (strcmp( selector, kSPAccessReloadSelector) == 0)
			error = ReloadPlugin((SPInterfaceMessage *)message);
	}
	else if (strcmp(caller, kSPInterfaceCaller) == 0)
	{
		if (strcmp(selector, kSPInterfaceAboutSelector) == 0)
			error = kNoErr;

		else if (strcmp(selector, kSPInterfaceStartupSelector) == 0)
			error = kNoErr;
	}
	else if (strcmp(caller, kSPCacheCaller) == 0)
	{
		if (strcmp(selector, kSPPluginPurgeCachesSelector) == 0)
		{
			if (Purge())
				error = kSPPluginCachesFlushResponse;
			else
				error = kSPPluginCouldntFlushResponse;
		}
	}
	else if (strcmp( caller, kSPPropertiesCaller ) == 0)
	{
		if (strcmp( selector, kSPPropertiesAcquireSelector ) == 0)
		{
			error = AcquireProperty((SPPropertiesMessage *) message);
		}
		else if (strcmp( selector, kSPPropertiesReleaseSelector ) == 0)
		{
			error = ReleaseProperty((SPPropertiesMessage *) message);
		}
	}

	/* Some common AI messages */

	else if (strcmp(caller, kCallerAINotify) == 0)
	{
		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 (strcmp(msg->type, kAIApplicationStartedNotifier) == 0)
			error = PostStartupPlugin();

		if (!error || error == kUnhandledMsgErr)
		{
			if (strcmp( selector, kSelectorAINotify ) == 0)
				error = Notify(msg);
		}
	}
	else if (strcmp(caller, kActionCaller) == 0)
	{
		if (strcmp( selector, kDoActionSelector ) == 0)
		{
			/*
			char *my_argv[] = { "program name", "arg1", "arg2", NULL };
			int my_argc = sizeof(my_argv) / sizeof(char*) - 1;

			QApplication a(my_argc, my_argv);
			MyQTUI w;
			w.show();
			a.exec();*/
			error = GoAction((DoActionMessage *)message);
		}
	}
	else if (strcmp(caller, kCallerAIMenu) == 0)
	{
		if (strcmp( selector, kSelectorAIGoMenuItem ) == 0)
		{
			//sAIUser->MessageAlert(ai::UnicodeString("GoMenuItem"));
			error = GoMenuItem((AIMenuMessage *)message);
		}
		else if (strcmp( selector, kSelectorAIUpdateMenuItem ) == 0)
		{
			//sAIUser->MessageAlert(ai::UnicodeString("UpdateMenuItem"));
			error = UpdateMenuItem((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, kCallerAIPluginGroup) == 0)
	{
		if (strcmp( selector, kSelectorAINotifyEdits ) == 0)
		{
			error = PluginGroupNotify((AIPluginGroupMessage *)message);
		}
		else if (strcmp( selector, kSelectorAIUpdateArt ) == 0)
		{
			error = PluginGroupUpdate((AIPluginGroupMessage *)message);
		}
	}
	else if (strcmp(caller, kCallerAIFileFormat) == 0)
	{
		if (strcmp( selector, kSelectorAIGetFileFormatParameters ) == 0)
		{
			error = GetFileFormatParameters((AIFileFormatMessage *)message);
		}
		else if (strcmp( selector, kSelectorAIGoFileFormat ) == 0)
		{
			error = GoFileFormat((AIFileFormatMessage *)message);
		}
		else if (strcmp( selector, kSelectorAICheckFileFormat ) == 0)
		{
			error = CheckFileFormat((AIFileFormatMessage *)message);
		}
		else if ( strcmp( selector, kSelectorAIUpdateFileFormat ) == 0 )
		{
			error = FileFormatUpdate( (AIUpdateFileFormatMessage *)message );
		}
		else if (!strcmp( selector, kDoActionSelector))
		{
			error = SetFileFormatParameters( (DoActionMessage *) message );
		}
	}
	else if (strcmp(caller, kCallerAITool) == 0)
	{
		if (strcmp( selector, kSelectorAIEditToolOptions ) == 0)
		{
			error = EditTool((AIToolMessage *)message);
		}
		else if (strcmp( selector, kSelectorAITrackToolCursor ) == 0)
		{
			error = TrackToolCursor((AIToolMessage *)message);
		}
		else if (strcmp( selector, kSelectorAIToolMouseDown ) == 0)
		{
			error = ToolMouseDown((AIToolMessage *)message);
			sAIUser->MessageAlert(ai::UnicodeString("Mouse down"));
		}
		else if (strcmp( selector, kSelectorAIToolMouseDrag ) == 0)
		{
			error = ToolMouseDrag((AIToolMessage *)message);
		}
		else if (strcmp( selector, kSelectorAIToolMouseUp ) == 0)
		{
			sAIUser->MessageAlert(ai::UnicodeString("Mouse up"));
			//error = ToolMouseUp((AIToolMessage *)message);
		}
		else if (strcmp( selector, kSelectorAISelectTool ) == 0)
		{
			error = SelectTool((AIToolMessage *)message);
		}
		else if (strcmp( selector, kSelectorAIDeselectTool ) == 0)
		{
			error = DeselectTool((AIToolMessage *)message);
		}
		else if (strcmp( selector, kSelectorAIReselectTool ) == 0)
		{
			error = ReselectTool((AIToolMessage *)message);
		}
		else if (strcmp( selector, kSelectorAIToolDecreaseDiameter ) == 0)
		{
			error = DecreaseDiameter((AIToolMessage *)message);
		}
		else if (strcmp( selector, kSelectorAIToolIncreaseDiameter ) == 0)
		{
			error = IncreaseDiameter((AIToolMessage *)message);
		}
		

	} else if (strcmp(caller, kCallerAILiveEffect ) == 0)
	{
		if (strcmp( selector, kSelectorAIEditLiveEffectParameters ) == 0)
		{
			error = EditLiveEffectParameters((AILiveEffectEditParamMessage *)message);
		}
		else if (strcmp( selector, kSelectorAIGoLiveEffect ) == 0)
		{
			error = GoLiveEffect((AILiveEffectGoMessage *)message);
		}
		else if (strcmp( selector, kSelectorAILiveEffectInterpolate ) == 0)
		{
			error = LiveEffectInterpolate((AILiveEffectInterpParamMessage *)message);
		}
		else if (strcmp( selector, kSelectorAILiveEffectInputType ) == 0)
		{
			error = LiveEffectGetInputType((AILiveEffectInputTypeMessage *)message);
		}
		else if (strcmp( selector, kSelectorAILiveEffectScaleParameters ) == 0)
		{
			error = LiveEffectScaleParameters((AILiveEffectScaleParamMessage *)message);
		}
		else if (strcmp( selector, kSelectorAILiveEffectConverColorSpace ) == 0)
		{
			error = LiveEffectConvertColorSpace((AILiveEffectConvertColorMessage *)message);
		}
		else if (strcmp( selector, kSelectorAILiveEffectAdjustColors ) == 0)
		{
			error = LiveEffectAdjustColors((AILiveEffectAdjustColorsMessage *)message);
		}
		else if (strcmp( selector, kSelectorAILiveEffectHandleMerge ) == 0)
		{
			error = LiveEffectHandleMerge((AILiveEffectHandleMergeMessage *)message);
		}
	} else if (strcmp(caller, kCallerAITimer ) == 0)
	{
		if (strcmp( selector, kSelectorAIGoTimer ) == 0)
		{
			error = GoTimer((AITimerMessage *)message);
		}
	}
	else if (strcmp(caller, kCallerAIClipboard ) == 0)
	{
		if ( strcmp( selector, kSelectorAIGoClipboard ) == 0 )
			error = GoClipboard( (AIClipboardMessage *) message );

		else if ( strcmp( selector, kSelectorAICanCopyClipboard ) == 0 )
			error = CanCopyClipboard( (AIClipboardMessage *) message );

		else if ( strcmp( selector, kSelectorAICloneClipboard ) == 0 )
			error = CloneClipboard( (AIClipboardMessage *) message );

		else if ( strcmp( selector, kSelectorAIDisposeClipboard ) == 0 )
			error = DisposeClipboard( (AIClipboardMessage *) message );
	}
	else if (strcmp(caller, kAIWorkspaceCaller ) == 0)
	{
		if ( strcmp( selector, kAIWSWriteSelector ) == 0 )
			error = WorkspaceWrite( (AIWorkspaceMessage *) message );

		else if ( strcmp( selector, kAIWSRestoreSelector ) == 0 )
			error = WorkspaceRestore( (AIWorkspaceMessage *) message );

		else if ( strcmp( selector, kAIWSDefaultSelector ) == 0 )
			error = WorkspaceDefault( (AIWorkspaceMessage *) message );
	}
	return error;
}
Пример #2
0
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;
}