Changes

Jump to: navigation, search

D-Bus and other Linux desktop integration improvements

76 bytes removed, 14:48, 15 December 2006
Create the Component
====Create the Component====
1. Download the Gecko SDK.
  a. * You can find it at ftp://ftp.mozilla.org/pub/mozilla.org/mozilla/releases/mozilla1.7.13  b. * You can choose a different Mozilla release if you like.  c. * Extract the SDK to a local directory.
2. Create a GUID for the main interface.
  a. * You can use the uuidgen utility to generate the unique 128 bit number. Or  b. * You can use one of the special “bots” on IRC at the irc.mozilla.org server (irc://irc.mozilla.org/#mozilla).
3. Create the interface definition file – ImyComponent.idl
  a. * Use the following template add methods and attributes to the interface.  b. * Fill in the GUID you have generated.
#include “nsISupports.idl”
};
4. Generate the interface header and typelib files out of the interface definition file.
  a. * Use the xpidl utility that comes with Gecko SDK. b. * Substitute the “_DIR_” in the following commands with the full path to the xpcom/idl directory found under the Gecko SDK main directory.  c. * xpidl -m hearer -I_DIR_ IMyComponent.idl will created the IMyComponent.h hearder file.  d. * xpidl -m typelib -I_DIR_ IMyComponent.idl will create the IMyComponent.xpt typelib file.
5. The interface header file IMyComponent.h contains templates for building the component header and implementation files. You can copy and paste the templates to create these files, changing only the component name.
6. Create the component header file “MyComponent.h”.
  a. * Start by inserting double includsion protection code (#ifndef _My_COMPONENT_H_ ….).  b. * Add #include “IMyComponent.h” to include the interface definition.  c. * Create a GUID for the component.  d. * Add the following lines, which define the component name, contract ID, and GUID:
#define MY_COMPONENT_CONTRACTID “@mydomain.com/XPCOMSample/MyComponent;1”
#define MY_COMPONENT_CID _YOU_COMPONENT_GUID_
e. * Copy the header template from IMyComponent.h (starting with /*Header file */) into the MyComponent.h file.  f. * Replace all the instances of _MYCLASS_ with the name of the component.
7. Create the component implementation file “MyComponent.cpp”.
  a. * Add #include “MyComponent.h” to include the component definitions.  b. * Copy the implementation template from IMyComponent.h (starting with /*Implementation file */) into the MyComponent.cpp file.  c. * Replace all the instances of _MYCLASS_ with the name of the component.  d. * Add method implementation code.
8. Create the module definitions file “MyComponentModule.cpp”
a. * Add #include “nsIGenericFactory.h” to include Mozilla GenericFactory definitions.  b. * Add #include “MyComponent.h” to include the component definitions.  c. * Add NS_GENERIC_FACTORY_CONSTRUCTIOR(MyComponent) to define the constructor for the component.  d. * Add
static nsModuleComponentInfo components[] =
{
to define the class name, contract ID and GUID of the component.
e. * Add NS_IMPL_NSGETMODULE(“MyComponentsMoudle”, components) to export the above information to Mozilla.
9. Create a custom makefiles.
1
edit

Navigation menu