~ubuntu-branches/ubuntu/quantal/libbonobo/quantal-201207170711

« back to all changes in this revision

Viewing changes to bonobo/bonobo-foreign-object.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2005-02-18 14:40:51 UTC
  • mto: (3.1.1 etch) (1.1.25 upstream)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20050218144051-fo4h9qh2gim8x3wt
Tags: upstream-2.8.1
ImportĀ upstreamĀ versionĀ 2.8.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
 
2
#include <bonobo/bonobo-foreign-object.h>
 
3
#include <bonobo/bonobo-exception.h>
 
4
#include <bonobo/bonobo-running-context.h>
 
5
 
 
6
static void
 
7
bonobo_foreign_object_class_init (BonoboForeignObjectClass *klass)
 
8
{
 
9
}
 
10
 
 
11
static void
 
12
bonobo_foreign_object_instance_init (GObject    *g_object,
 
13
                                     GTypeClass *klass)
 
14
{
 
15
}
 
16
 
 
17
GType
 
18
bonobo_foreign_object_get_type (void)
 
19
{
 
20
        static GType type = 0;
 
21
 
 
22
        if (!type) {
 
23
                GTypeInfo info = {
 
24
                        sizeof (BonoboForeignObjectClass),
 
25
                        (GBaseInitFunc) NULL,
 
26
                        (GBaseFinalizeFunc) NULL,
 
27
                        (GClassInitFunc) bonobo_foreign_object_class_init,
 
28
                        NULL, /* class_finalize */
 
29
                        NULL, /* class_data */
 
30
                        sizeof (BonoboForeignObject),
 
31
                        0, /* n_preallocs */
 
32
                        (GInstanceInitFunc) bonobo_foreign_object_instance_init
 
33
                };
 
34
                
 
35
                type = g_type_register_static (BONOBO_TYPE_OBJECT, "BonoboForeignObject",
 
36
                                               &info, 0);
 
37
        }
 
38
 
 
39
        return type;
 
40
}
 
41
 
 
42
 
 
43
BonoboObject *
 
44
bonobo_foreign_object_new (CORBA_Object corba_objref)
 
45
{
 
46
        BonoboObject *object;
 
47
        CORBA_Environment ev[1];
 
48
 
 
49
        g_return_val_if_fail (corba_objref != CORBA_OBJECT_NIL, NULL);
 
50
 
 
51
        CORBA_exception_init (ev);
 
52
        if (!CORBA_Object_is_a (corba_objref, "IDL:Bonobo/Unknown:1.0", ev)) {
 
53
                if (ev->_major != CORBA_NO_EXCEPTION)
 
54
                        g_warning ("CORBA_Object_is_a: %s",
 
55
                                   bonobo_exception_get_text (ev));
 
56
                else
 
57
                        g_warning ("bonobo_foreign_object_new: corba_objref"
 
58
                                   " doesn't have interface Bonobo::Unknown");
 
59
                object = NULL;
 
60
 
 
61
        } else {
 
62
                object = BONOBO_OBJECT (g_object_new (BONOBO_TYPE_FOREIGN_OBJECT, NULL));
 
63
                object->corba_objref = CORBA_Object_duplicate (corba_objref, NULL);
 
64
                bonobo_running_context_add_object_T (object->corba_objref);
 
65
        }
 
66
        CORBA_exception_free (ev);
 
67
 
 
68
        return object;
 
69
}
 
70