Re: [OBORONA-SPAM] how can I use bonobo in xpcom?

"Nickolay V. Shmyrev" <[email protected]> Tue, 08 Jun 2004 15:10:30 +0400
Newsgroups gmane.comp.gnome.components
Message-ID <[email protected]>
On Wed, 2004-06-09 at 13:33 +0000, Tong wrote:
> how can I use bonobo in xpcom?
> I want to use bonobo in xpcom.
> I have write a bonobo service, and want to create bonobo-object in
> xpcom.
> This is my code in xpcom(nsService.cpp):
> 
>     if (!bonobo_init (NULL, NULL))
>         g_error (_("I could not initialize Bonobo"));
>     else
>         printf("Initialize Bonobo!\n");
> 
>     bonobo_activate ();
>     printf("bonobo_activate\n"); 
> 
>     service_server = bonobo_get_object
> ("OAFIID:Bonobo_Pterogaim_Service",
>                      "Bonobo/Pterogaim/Service", NULL);
> 
>     
>     if (service_server == CORBA_OBJECT_NIL) {
>         g_warning (_("Could not create an instance of the gaim service
> component"));
>         bonobo_debug_shutdown ();
>     }
>     else {
>         printf("Bonobo_Pterogaim_Service is available!\n");
>     }
>     
>     CORBA_exception_init (&ev);
> 
> And this is part of my XUL file:
> 
> <script>
> function addButton() 
> {
>   var aBox = document.getElementById("aBox");
> 
>   var button = document.createElement("button");
>   button.setAttribute("label","A Button");
>   aBox.appendChild(button);
>  
> 
>     var myservice =
> Components.classes["@mozilla.org/cpp_service;1"].createInstance();
>     if (myservice)
>         myservice.QueryInterface(Components.interfaces.nsIService);
>     var buddyaccount = myservice.getForwardingBuddyCount();
>     var buddyaccount = "a";
> 
>     var mylabel = document.createElement("label");
>     mylabel.setAttribute("value", buddyaccount);
>     aBox.appendChild(mylabel);
> 
> }
> </script>
> 

So I cant understand your problems. Both two parts of code seems to be
correct and should work. On addButton, the method
getForwardingBuddyCount should be executed. 
In your cpp code, all seems to work too, you should get a reference on
corba object. And what is the problem in using such object. You should
then simply call
result = Bonobo_PterogamService_someMethod (service_server, arg, &ev);
and use result.

What goes wrong?