Home | Download | Getting Started | Contact | White Paper | Examples | Documentation | Troubleshooting | Newsgroup | Mailing List | Source Code | Bugs | Screenshots

Using IPC services through XPConnect

(for Mozilla/XUL developers)

Protozilla extends the capabilities of Mozilla by allowing you to execute an arbitrary program on the system, write to its standard input and read from its standard output. These capabilities may be accessed through XPCOM or XPConnect, i.e., through privileged Javascript calls or raw C++ code.

The Protozilla source code sits in the root directory named pipella. The C++ portion of the code is in the directory ipc. The *.idl files in this directory implement the following XPConnect interfaces:

Example: The nsIIPCService interface provides the following methods:

    string execSh(in string command);
    string getEnv(in string name);

To create and use an nsIIPCService object, you need the following Javascript code:

var ipcService, curDate, curPath;
ipcService = Components.classes[NS_IPCSERVICE_CONTRACTID].createInstance();
ipcService = ipcService.QueryInterface(Components.interfaces.nsIIPCService);
curDate = ipcService.execSh("date");
curPath = ipcService.getEnv("PATH");
To try out the above Javascript code, go to the directory where the mozilla binary resides. Run the xpcshell command found there, and cut-and-paste the above commands (after installing Protozilla, of course).

The function call ipcService.execSh("date") will execute the system command date and return its output as a string (rather like the backtick operator `date` in Perl or in Unix shells). The function call ipcService.getEnv("PATH") returns the value of the system PATH environment variable as a string.

The protozilla project can be contacted through the mailing list or the member list.
Copyright © 2000-2020. All rights reserved. Terms of Use & Privacy Policy.