source: trunk/third/bonobo-activation/test/empty-server.c @ 18563

Revision 18563, 2.9 KB checked in by ghudson, 22 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r18562, which included commits to RCS files with non-trunk default branches.
Line 
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- */
2#include <stdio.h>
3#include <stdlib.h>
4#include <string.h>
5#include <signal.h>
6#include <orbit/orbit.h>
7#include <popt.h>
8
9#include <bonobo-activation/bonobo-activation.h>
10
11#include "empty.h"
12
13Empty empty_client = CORBA_OBJECT_NIL;
14
15static void do_Nothing (PortableServer_Servant servant,
16                        CORBA_Environment * ev);
17
18PortableServer_ServantBase__epv base_epv = {
19        NULL,
20        NULL,
21        NULL
22};
23POA_Empty__epv empty_epv = { NULL, do_Nothing };
24POA_Empty__vepv poa_empty_vepv = { &base_epv, &empty_epv };
25POA_Empty poa_empty_servant = { NULL, &poa_empty_vepv };
26
27static void
28do_exit (int arg)
29{
30        exit (2);
31}
32
33int
34main (int argc, char *argv[])
35{
36        PortableServer_ObjectId *objid;
37        PortableServer_POA poa;
38        poptContext ctx;
39
40        CORBA_Environment ev;
41        CORBA_ORB orb;
42        GSList *reg_env = NULL;
43
44        signal (SIGINT, do_exit);
45        signal (SIGTERM, do_exit);
46
47        CORBA_exception_init (&ev);
48        orb = bonobo_activation_init (argc, argv);
49
50        ctx = poptGetContext ("oaf-empty-server", argc, (const char **)argv,
51                              bonobo_activation_popt_options, 0);
52        while (poptGetNextOpt (ctx) >= 0);
53        poptFreeContext (ctx);
54
55        POA_Empty__init (&poa_empty_servant, &ev);
56
57        poa = (PortableServer_POA)
58                CORBA_ORB_resolve_initial_references (orb, "RootPOA", &ev);
59        objid = PortableServer_POA_activate_object (poa, &poa_empty_servant, &ev);
60
61        empty_client = PortableServer_POA_servant_to_reference (poa,
62                                                                &poa_empty_servant,
63                                                                &ev);
64        if (!empty_client) {
65                printf ("Cannot get objref\n");
66                return 1;
67        }
68
69        reg_env = bonobo_activation_registration_env_set (
70                        reg_env, "DISPLAY", getenv ("DISPLAY"));
71        reg_env = bonobo_activation_registration_env_set (
72                        reg_env, "SESSION_MANAGER", getenv ("SESSION_MANAGER"));
73        reg_env = bonobo_activation_registration_env_set (
74                        reg_env, "LANG", getenv ("LANG"));
75        reg_env = bonobo_activation_registration_env_set (
76                        reg_env, "AUDIODEV", getenv ("AUDIODEV"));
77
78        /*
79         * NB. It is imperative to register the server that is being
80         * requested last - or we can still race in the activation daemon.
81         */
82        bonobo_activation_register_active_server ("OAFIID:Empty2:19991025", empty_client, reg_env);
83        g_usleep (500000); /* 1/2 sec */
84        bonobo_activation_register_active_server ("OAFIID:Empty:19991025", empty_client, reg_env);
85
86        bonobo_activation_registration_env_free (reg_env);
87
88        PortableServer_POAManager_activate
89                (PortableServer_POA__get_the_POAManager (poa, &ev), &ev);
90        while (1)
91                g_main_context_iteration (NULL, TRUE);
92
93        bonobo_activation_active_server_unregister ("OAFIID:Empty:19991025", empty_client);
94        bonobo_activation_active_server_unregister ("OAFIID:Empty2:19991025", empty_client);
95
96        PortableServer_POA_deactivate_object (poa, objid, &ev);
97
98        return 0;
99}
100
101static void
102do_Nothing (PortableServer_Servant servant, CORBA_Environment *ev)
103{
104        g_print ("doNothing called!");
105}
Note: See TracBrowser for help on using the repository browser.