Hi

There is maybe a better a way to do what I understand of your request 
but I only found this one which is elegant because component oriented.

You may find some clue in the Downloader that refresh a progress bar as 
downloading.

Some keywords : Listener, nsIRunnable, Thread, nsIProxy ...


1. You need to define two interfaces :

- one for your XPCOM object : nsIRTcom
- second a listener to allow callback
   to JS/HTML context : nsIRTcomListener


2. Define methods :

/**
  * Set the javascript listener
  */
nsIRTcom::SetListener( nsIRTcomListener )

/**
  * Start a new thread that handle realtime event from your system
  * the new thread call nsIRTcomListener methods through a nsIProxyObject
  */
nsIRTcom::StartEventFiring()


3. Define a new JS Object :

var listener = {
     callMe:function(){
       document.getElementById("any").setAttribute("attname","value");
       }
     }

4. In the onload JS function :

netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");

aIRT = Components.classes["@mozilla.org/nsRTCom;1"].
          createInstance(Components.interfaces.nsIRTCom);

aIRT.setListener(listener);
aIRT.StartEventFiring();


Note : You won't be in RealTime because there is a unique thread for UI 
so event fired are put in a queue by the ProxyObjectManager.

David Olivari
eProcess


Riga Vit wrote:
> Hi,

> 
> I'm a developer working on a mozilla embedded project. My groups want the
> HTML document on the browser to interact with the events raising from the
> realtime applications.
> I need some information about the possibility to create new type of event
> and
> fire it from an XPCOM object (C++) to the HTML document on the browser.
> 
> Following you can find pieces of code that I want to write:
> 
> //XPCOM object C++
> 
> ... myMethod(...)
> {
> ....
> 
>   fireToHtml(myEvent);
> ....
> }
> 
> //XPCOM object end
> 
> 
> <!-- HTML page>
> ....
> <HTMLTAG onMyEvent="handleMyEvent();">
> .....
> 
> I hope that my question is clear and that it possible to do what I want.
> 
> All comments, references to docs, CODE SAMPLES, general ideas are welcome.
> 
> Thanks,
> Vitt
> 
> 
> 
> 



Reply via email to