Now it’s time to look at the WebLock component as another example of XPCOM components (since you’ll be creating it shortly). This is a book about Gecko, and about creating XPCOM components for Gecko- based applications. Though the emphasis is on the practical steps you take to. About. This is a step-by-step tutorial on creating, building and registering an XPCOM component on Linux and MS Windows.

Author: Telar Taunris
Country: Burkina Faso
Language: English (Spanish)
Genre: Travel
Published (Last): 11 February 2006
Pages: 64
PDF File Size: 7.25 Mb
ePub File Size: 16.55 Mb
ISBN: 400-2-18651-368-8
Downloads: 84649
Price: Free* [*Free Regsitration Required]
Uploader: Shaktirr

Creating a C++ XPCOM component

You can plug your custom functions into the framework and connect them with other components. In this article, all the instructions, environment variables, and command line will be in a Linux operating system.

XPCOM provides browser application interfaces you can use to access low-level operations, such as system hardware diagnostics, massive file operations, and system health real-time monitoring. Cerating Figure 1, sample.

First, you have to define the interfaces you want to expose to the browser or the abilities you want to provide to the Web application. Interfaces are written in an. Listing 1 shows a sample interface definition file. In Listing 1, the name is sampleand three common function prototypes are shown. On a Linux system, you can easily get this ID by using the genuuid command in the shell: You can install gecko-sdk with the default option.

The directory structure should look very similar to Listing 2.

To translate the interfaces defined in. The example uses it twice to generate an. Typically, you wouldn’t modify anything in this header file.

However, to extend and inherit from the base class, you can add more private methods and variables for extension. Listing 3 shows an example of generating the command on Linux. If you define the interface in the sample. As mentioned, you don’t modify the two generated files: You inherit the interface from them. Sometimes, you might not complete all the interface at the beginning of the development phase. You’ll want to keep the contents and structure of the base class as simple as possible.

  KAMERSCHEN EKONOMIA PDF

In the extend file, you can add more complicated methods and functions.

Listing 4 shows an example of xppcom to write your extend class. For the browser to benefit from the functions provide by an XPCOM component, the component must first be registered to the browser.

There is a form you must prepare for your component. The three macros described above must be put in the form. The browser will be aware of your components upon start-up, and register them in the component list. Listing 5 shows a registration form for the sample. It is highly recommended that you put the implementation of functions and service for your XPCOM in an individual project file.

You don’t need to modify these three files unless there’s a need to modify the interfaces of your component. Listing 6 shows a sample. The sample above simply returns “hello world” to the browser application. You can add more realistic logic or functions to support the application you want to develop.

If clmponents follow the steps described above, and use make to build the sample componnents makefile, you will have a sample. The next section explores a method to test these binaries. The example uses XUL. If you try HTML, you can make various improvements.

In most cases, JavaScript functions are included as a library and are keep in an individual. Listing 7 shows an XUL sample. The sample does not do any actual work; it just calls to the XPCOM interface and returns a dummy creatng from xpcom. Before you open the page in Firefox, be sure to follow the steps below to set up and register your XPCOM component to the browser:. Now you can open an x-terminal in GUI mode and enter a command like the one shown below:.

  GADGIL COMMITTEE REPORT ON WESTERN GHATS PDF

You would do this mainly because the JavaScript and UI are on a single thread, so when one is busy, the other is blocked, especially when you load the XPCOM component and invoke a method exposed by it. If the duration of this method is long, xpcim UI might appear hung with no response to the user. Though Firefox might have a configuration setting allowing a script to cfeating for a long time, letting the user configure the browser before executing your vreating is not an adequate solution.

JavaScript also can provide a callback result function when invoked by the interface. See Related topics for more about this topic. In this article, you learned how to create, develop, and test an XPCOM component that can be used by Firefox as an extension of an application.

You can use the samples provided for a quick start to developing a component for Firefox.

Creating XPCOM components with JavaScript

Sign in or register to add and subscribe to comments. Lewei Ji Published on October 27, Comments Sign in or register to add and subscribe to comments. Subscribe me to comment notifications.