Skip to main content
Participating Frequently
January 17, 2007
Question

HowTo: PlugIns Communication

  • January 17, 2007
  • 9 replies
  • 639 views
How to use a PlugIn1 funtion from PlugIn2?

let us suppose that we have got a PlugIn1, it have got a function CreateFrame.
And we want to use this function from other PlugIn (PlugIn2).

Is it possible??
Can Anybody give me an example?

Thanks

Leonardo
This topic has been closed for replies.

9 replies

Participating Frequently
January 19, 2007
Thanks you very match Patrick!
Known Participant
January 19, 2007
PluginDependency - it's a resource statement where you'll declare the *parent* plugin's ID/name.

It was defined like this in objectmodeltypes.fh:

type PluginDependency(kPlugInDependents)
{
integer; // Feature Set Id
longint = $$CountOf(Dependents);
array Dependents {
longint; // Plug-in ID of plug-in this one is dependent on
PlatformPMString; // Name of plug-in this one is depedent on
longint; longint; // Major & minor version number of plug-in this one is dependent on
}
};

Therefore I would do it that way I'll guess:

resource PluginDependency(1)
{
kWildFS
{
kMyPluginID,
kMyPluginName,
kSDKDefPlugInMajorVersionNumber,
kSDKDefPlugInMinorVersionNumber,
}
}

HTH

Best regards

Patrick Perroud
Participating Frequently
January 19, 2007
Thank you.

Patrick:
How to declare their actual dependencies?
How to add a PluginDependency resource to the client's .fr file?

Best regards,
Leonardo
Known Participant
January 19, 2007
Something else - the plugin that provides the interface implementation (the provider) should be required to launch the plugin that uses the interface (the client): this is done by adding a PluginDependency resource to the client's .fr file.

The reason this is required is quite obvious I'll guess: if the provider was missing for any cause then the client would crash InDesign trying to reach the missing provider's implementation . . .

Therefore - a good practice is to require the provider plugin in order to load the client plugin by *declaring* their actual dependencies.

HTH

Best regards

Patrick Perroud
Participating Frequently
January 19, 2007
Yes, that's correct. You can use interfaces implemented by other plugins provided you have the header files. Note that there are different ways of doing this.<br /><br />Another example:<br />Suppose Plugin1 has kMyBoss with an implementation of IMyInterface. You can use this interface in Plugin2 as given below,<br /><br />InterfacePtr<IMyInterface> myInterface((IMyInterface*)::CreateObject(kMyBoss, IID_IMYINTERFACE));<br />if(myInterface)<br /> myInterface->CreateFrame(...);<br /><br />Regards,<br />Narayan
Participating Frequently
January 18, 2007
Thank you Hans-Juergen, Patrick and especially Narayan.

Narayan:
When InDesign Load a PlugIn, the interfaces that it contains can be used directly from other PlugIn. ( sharing related Interface header file ).
Is this correct?

Thanks again

Regards,
Leonardo
Participating Frequently
January 18, 2007
Another example: Suppose you have a utility interface in Plugin1 that has function CreateFrame, you can use this function in Plugin2 as given below,<br /><br />if( Utils<IMyUtils>().Exists() )<br /> Utils<IMyUtils>()->CreateFrame(...);<br /><br />Regards,<br />Narayan
Known Participant
January 17, 2007
I just don't know what you are exactly meaning by *function* here . . .

Assuming that plugin 1 is implementing a new command - then plugin 2 would be able to call plugin 1 command as long as this command interface is known to plugin 2 at building time.

Which is quite simple to achieve sharing related header file - assuming you are implementing both plugins indeed . . .

This is how things are working with InDesign SDK - and using a proper terminology is already a first step to a solution I'll guess . . .

HTH

Best regards

Patrick Perroud
Participating Frequently
January 17, 2007
Hello Leonardo. Please take a look at the transparencyeffect and transparencyeffectui sample of the CS2 SDK to see how to access the interfaces from a different Plug-In.

Hans-Juergen