MozNET:  
MozNET R19.4 has just been turned loose! This is the first release to target .NET framework 3.5.

MozNET:  
The first, official, MozNET addon has been released! Be on the lookout for H/F Bridge!
MozNET:  
The MozNET AIO Builder has been updated. Login in and check out the 'My Account' to pick up the new bits!
MozNET:  
MozNET Source+ is now available!
New Software:  
JackHammer, the newest member of the Se7en Soft software lineup, is available! Details here.
MozNET:  
New MozNET tutorial posted!
Use MosStringBundleService to localize your applications.
 
Follow Se7en Soft On Twitter:
     Twitter.com/Se7enSoft

Did You Know...
... an egg contains every vitamin except vitamin C?
MozNet Tutorial - Javascript XPCOM Component

Now we're just a few steps away from having a working XPCOM component. So far we've taken the skeleton and filled it in with some code that will do something more than say 'Hello World!'. I'd say we're doing pretty good so far but, we can't count our chickens before they hatch. We've got more work ahead of us so don't say 'Look what I can do!' just yet.

IDL File Definition

Since we've got our javascript file taken care of we need a way to tell XPCom that we've got a component that we want to call methods on. This is done by creating a XPT file. But, before we can create that we need to make an IDL. IDL stands for Interface Definition Language and is the basic way of defining interfaces in XulRunner. To write your own components, like extending MozNet, you'll want to have the SDK version of XulRunner. Since the current version of MozNet is targeting XulRunner 1.9.2.17 you'll need the SDK for that build. You can download it here.

Let's define our IDL file. We'll use this file in the next step, creating the XPT file. In your text editor open a new, blank, document and paste or type the code below. Save the document next to the 'ExampleComponent.js' file we created earlier and name it 'nsIExampleComponent.idl'.

#include "nsISupports.idl"
#include "nsIDOMHTMLCanvasElement.idl"

/* Note that the uuid (Guid in c#) is the same as we defined in ExampleComponent.js  */
[scriptable, uuid(12345678-9012-3456-7890-ABCDEF123456)]
interface nsIExampleComponent : nsISupports
{
  /* This is the method that we defined in ExampleComponent.js  
   * Also, note the use of the 'in' keyword. All params must be marked as 'in' or 'out' or '[in,out]' as needed.*/
  string getPageImage(in nsIDOMWindow wnd);
};
    


Our IDL file must retain the same structure and syntax as other XulRunner IDL files that you'll find in the SDK. The tool that will create the XPT from your IDL file expects a proper input file and is not forgiving of any mistakes.




SSL Logo
open drive
ASPCA.org
Visitor IP: 38.107.179.211
Copyright (c) 2009 - 2011 Se7en Soft   :  All Rights Reserved  |  Privacy Statement