Da Sample CORBA Bonobo Code --------------------------- This directory contains simple sample code showing how to write a basic client and server using Bonobo, oaf and gnome. It is a pirated and slightly modified version of the standard gnome Bonobo "echo" example. The original "echo" example can be found at the following URL: http://cvs.gnome.org/lxr/source/bonobo/samples/bonobo-class/ This code here has been modified in the following ways: -- print statements go to a file, so you can see what's going on. -- additional comments have been added to the code. -- The Makefile.am infrastructure has been neutered (although automake is strongly recommended for 'real projects' it can be a hindrance to playing with toys.) -- The names of classes and objects have been made whimsical, hopefully in order to highlight what parts of the naming convention are required, and which are up to you. To play with this demo: -- untar the code -- install recent versions of bonobo, oaf and ORBit. -- type make. -- read the source code. The following are of note: iface.idl: The CORBA IDL file define the API. myserver.h: code that defines the actual 'implementation' of 'my server'. Most of this file is 'fixed' and must be the way it is, in order to work. But the part you can modify is highlighted. myserver.c: code that implements the specifics of the server. This is where you will want to plug in your server code. main.c: initialization code for the server. Mostly boring code that you'll need to cut-n-paste into your app. myclient.c: The example client code. It sends a secret message to the server. iface.oaf: The OAF definition file. This helps your client find your server 'by name', rather than by having to exchange IOR's by hand (yuck!) myquery.c: Code that is handy for seeing what's going on with oaf. -- install the code. As root, type 'make install'. This copies the server to /usr/bin (the location is probably not important, as long as oaf can find it.) More importantly, it copies the oaf-info file to /usr/share/oaf. This is critical. -- As an ordinary login user, type in "oaf-slay". This will stop and restart the oaf server, forcing it to re-read the contents of the /usr/share/oaf directory. It will also kill some programs that use oaf (e.g. nautilus, galeon). Sorry about that. -- Check to see if OAF has found you config files. Run the following command: oaf-run-query "repo_ids.has('IDL:Dohh/Echo:1.0')" You should see the following output: number of results: 1 OAFIID:Bonobo_Dasample_MyServer If you don't get this, go back to step 1, and try again. You might also want to look at what happens when you try the following: oaf-run-query "repo_ids.has('IDL:Bonobo/Unknown:1.0')" oaf-run-query "repo_ids.has('IDL:GNOME/ObjectFactory:1.0')" oaf-run-query "iid.defined()" If you are really unlucky, try setting the OAF_DEBUG_OUTPUT environment variable. -- run the client 'myclient'. Then 'cat /tmp/xxx'. The server will have written various debugging messages into this file. You might want to 'tail -f /tmp/xxx' and run myclient a few more times. Change the message in myclient.c, recompile, and run it again! -- Bonus/Extra Credit: play with myquery.c to see what it does. ============================================================== See Also: Tutorial: -------- http://www-106.ibm.com/developerworks/components/library/co-bnbo2.html Other ORBS: ----------- http://www.linas.org/linux/corba.html That's all folks! Linas Vepstas 2 October 2001