OJI Pluginの必要条件

著者: Ed Burns

注釈: これはこのドキュメントの最初のドラフトです。

このドキュメントは次のトピックをカバーします:

ドキュメントの目的
実装に必要な条件

共有ライブラリ関数
OJI と Plugin Interfaces

Sample Implementation Framework

ドキュメントの目的

このドキュメントは、Mozilla OJI pluginのための必要条件を指定します。 このように仮定しましょう (1)あなたは OJIがいかなるものか知っている; (2)あなたは OJI Pluginを書き始めたい。

実装に必要な条件

OJI pluginを書くためにはあなたは以下のことをしなければなりません:

共有ライブラリ関数

OJI pluginは必要な OJIインターフェースをさらに実装する Mozilla pluginです。すべての Mozilla plugins のように、Mozillaからあなたの pluginまでのエントリー・ポイントは npoji.dll のように np で始まるファイル名をが付けられた共有ライブラリでなくてはなりません。 この共有ライブラリは、現在 mozilla/dist/[WIN32*/]bin/plugins という pluginsディレクトリの中になくてはなりません。 あなたの OJI 共有ライブラリは下記機能(それらは実際にmozillaのコンポーネントの auto registration functionsである)を実装し export するべきです:

 

extern "C" nsresult NSGetFactory(nsISupports *pProvider, 
                                 const nsCID &clsid, 
                                 const char *aClassName, 
                                 const char *aProgID, 
                                 nsIFactory **ppFactory);
 

nsISupports *pProvider

これは現在の nsIServiceManagerを指します。
(This points to the current nsIServiceManager.)

  const nsCID %clsid

これは static NS_DEFINE_CID(kPluginCID, NS_PLUGIN_CID); からの kPluginCIDです。(This is kPluginCID from static NS_DEFINE_CID(kPluginCID, NS_PLUGIN_CID); )

  const char *aClass

mozillaがあなたの OJI pluginのための NSGetFactoryを呼ぶ場合、この値は null です。
(This value ends up being null when Mozilla calls NSGetFactory for your OJI plugin.)

  const char *progID

mozillaがあなたの OJI pluginのための NSGetFactoryを呼ぶ場合、この値は null です。
(This value ends up being null when Mozilla calls NSGetFactory for your OJI plugin.)

  nsIFactory **ppFactory

あなたが返り値(nsIPluginのインスタンス)を格納するところです。
(This is where you store the return value, which must be an instance of nsIPlugin.)

注釈: この関数は LiveConnect が始められる時、呼び出されます。 それはあなたが nsIPluginのインスタンスを返す時です。あなたはこの nsIJVMPlugin の実装のインスタンスを持つことを便利に感じるかもしれません。
(The above function gets called when LiveConnect is started. It is your opportunity to return an instance of nsIPlugin. You may find it convenient to have this instance also implement nsIJVMPlugin.)

extern "C" nsresult NSRegisterSelf(nsISupports* serviceMgr, 
                                   const char *path);
  nsISupports *serviceMgr

これは現在の nsIServiceManager を示します。
(This points to the current nsIServiceManager.)

  const char *path

ロードされている dll への絶対パス
(This is the absolute qualified path to the dll being loaded)

注釈:この関数は mozilla plugin システムによって呼び出されません。
(The above function is not called by the Mozilla plugin system.)

extern "C" NS_EXPORT nsresult NSUnregisterSelf(nsISupports* serviceMgr, 
                                               const char *path);
  nsISupports *serviceMgr

これは現在の nsIServiceManager を示します。
(This points to the current nsIServiceManager.)

  const char *path

ロードされている dll への絶対パス
(This is the absolute qualified path to the dll being loaded.)

注釈: 上記の関数は mozilla pluginシステムによって呼ばれません。 もしこれが autoregisteringしていた XPCOMコンポーネントならば、この関数はコンポーネントが serviceManagerでそれ自体を登録することを可能にするために呼ばれるでしょう。
(The above function is not called by the Mozilla plugin system. If this were an XPCOM component that was auto-registering, this function would be called to allow the component to register itself with the serviceManager.

 

extern "C" PRBool NSCanUnload(nsISupports* serviceMgr);
  nsISupports *serviceMgr

これは現在の nsIServiceManager を示します。
(This points to the current nsIServiceManager.)

注釈:この関数は mozilla pluginシステムによって呼ばれません。しかし、そうだった場合、pluginを unloadすることが安全かどうか決めることが目的です。
(The above function is not called by the Mozilla plugin system, but if it were, its purpose would be to determine if it were safe to unload the plugin.

 

OJI and Plugin Interfaces

This section lists all interfaces that an OJI plugin must implement, and it provides links to the header files via LXR. Listed for each interface are the interfaces to which it must respond when called by QueryInterface or AggregatedQueryInterface (this is in addition to the mandatory nsISupports).

 

OJI Interfaces
mozilla\modules\oji\public\nsIJVMConsole.h: nsIJVMConsole
AggregatedQueryInterface: NS_IJVMCONSOLE_IID
mozilla\modules\oji\public\nsIJVMPlugin.h: nsIJVMPlugin
QueryInterface: NS_IJVMPLUGIN_IID, NS_IJVMCONSOLE_IID
mozilla\modules\oji\public\nsIJVMPluginInstance.h: nsIJVMPluginInstance
QueryInterface: NS_IPLUGININSTANCE_IID, NS_IJVMPLUGININSTANCE_IID
mozilla\modules\oji\public\nsIJVMPrefsWindow.h: nsIJVMPrefsWindow
AggregatedQueryInterface: NS_IJVMPREFSWINDOW_IID
mozilla\modules\oji\public\nsISecureEnv.h: nsISecureEnv
AggregatedQueryInterface: NS_ISECUREENV_IID
Plugin Interfaces
mozilla\modules\plugin\public\nsIPlugin.h: nsIPlugin
AggregatedQueryInterface: NS_IPLUGIN_IID
mozilla\modules\plugin\public\nsIPluginInstance.h: nsIPluginInstance
QueryInterface: NS_IPLUGININSTANCE_IID
mozilla\modules\plugin\public\nsIPluginInstancePeer.h: nsIPluginInstancePeer
QueryInterface: NS_IPLUGININSTANCEPEER_IID

PENDING (Ed Burns): Unsure why the plugin needs to implement this.
mozilla\modules\plugin\public\nsIPluginManager.h: nsIPluginManager
QueryInterface: NS_IPLUGINMANAGER_IID

PENDING (Ed Burns): Unsure why the plugin needs to implement this.
mozilla\modules\plugin\public\nsIPluginStreamInfo.h: nsIPluginStreamInfo
QueryInterface: NS_IPLUGINSTREAMINFO_IID
mozilla\modules\plugin\public\nsIPluginStreamListener.h: nsIPluginStreamListener
QueryInterface: NS_IPLUGINSTREAMLISTENER_IID

mozilla\modules\plugin\public\nsIPluginTagInfo.h: nsIPluginTagInfo
QueryInterface: NS_IPLUGINTAGINFO_IID
PENDING (Ed Burns): Unsure why the plugin needs to implement this.

 

Sample Implementation Framework

This section lists sample class definitions and the appropriate Mozilla inheritences for each class. You must implement these interfaces, in addition to the above-mentioned NS* functions, in order to implement a Java Plugin.

 

/**

 * Responsible for creating an instance of the Java Plugin.

 */

class JavaPluginFactory : public nsIJVMPlugin, public nsIPlugin
{
};
	

/**

 * The actual java plugin instance.  

 */

class JavaPlugin : public nsIJVMPluginInstance, public nsIPluginInstance 
{
};
	

/**

 * Instances of this class come from the nsIJVMPlugin instance.  
 * This class provides a secure version of the JNIEnv class from 
 * Sun's JNI.  There is a 1:1 mapping of methods in this class to
 * methods in JNI.

 */

class SecureJNIEnv : public nsISecureEnv
{
};
	

/**

 * Allows Mozilla to pop up or hide a console that displays the console
 * output from the java plugin.

 */

class JavaConsole : public nsIJVMConsole
{
};
	

/**

 * Allows Mozilla to pop up or hide a window that allows the user to
 * control settings of the Java plugin.

 */

class JavaPrefsWindow : public nsIJVMPrefsWindow
{
};
	

/**

 * 
PENDING (Ed Burns): Unsure why the plugin needs to implement this. */ class PluginInstancePeer : public nsIPluginInstancePeer, public nsIPluginTagInfo { };

/**

 * 
PENDING (Ed Burns): Unsure why the plugin needs to implement this. */ class PluginManager : public nsIPluginManager { };

/**

 * Allows Mozilla to gain information about streams for this plugin.
 * 
PENDING (Ed Burns): Unsure why the plugin needs to implement this. */ class PluginStreamInfo : public nsIPluginStreamInfo { };

/**

 * Methods that get called by Mozilla for various stream events.

 */
class PluginStreamListener : public nsIPluginStreamListener 
{
};