~ubuntu-branches/ubuntu/breezy/orbit2/breezy

« back to all changes in this revision

Viewing changes to src/orb/orb-core/orbit-policy.c

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2005-09-06 16:37:02 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 sarge)
  • Revision ID: james.westby@ubuntu.com-20050906163702-hrqi0ctymth53bnn
Tags: 1:2.12.4-0ubuntu1
* New upstream version.
* debian/patches/100-compile-name-server.patch:
  - updated.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include <stdarg.h>
 
2
#include <string.h>
 
3
#include "../util/orbit-purify.h"
 
4
#include "orbit-policy.h"
 
5
#include "orbit-debug.h"
 
6
#include "orbit-object.h"
 
7
#include "orbit/GIOP/giop.h"
 
8
 
 
9
GType
 
10
ORBit_policy_ex_get_type (void)
 
11
{
 
12
        return 0; /* FIXME: maybe use GObject some day ? */
 
13
}
 
14
 
 
15
static void
 
16
ORBit_policy_free_fn (ORBit_RootObject obj)
 
17
{
 
18
        ORBitPolicy *p = (ORBitPolicy *) obj;
 
19
        g_ptr_array_free (p->allowed_poas, TRUE);
 
20
        p_free (p, ORBitPolicy);
 
21
}
 
22
 
 
23
static const ORBit_RootObject_Interface ORBit_Policy_epv = {
 
24
        ORBIT_ROT_CLIENT_POLICY,
 
25
        ORBit_policy_free_fn
 
26
};
 
27
 
 
28
ORBitPolicy *
 
29
ORBit_policy_new (GType        type,
 
30
                  const char  *first_prop,
 
31
                  ...)
 
32
{
 
33
        va_list      args;
 
34
        const char  *name;
 
35
        ORBitPolicy *policy = g_new0 (ORBitPolicy, 1);
 
36
        ORBit_RootObject_init (&policy->parent, &ORBit_Policy_epv);
 
37
 
 
38
        policy->allowed_poas = g_ptr_array_sized_new (1);
 
39
 
 
40
        va_start (args, first_prop);
 
41
        for (name = first_prop; name; name = va_arg (args, char *)) {
 
42
                if (!strcmp (name, "allow")) {
 
43
                        gpointer poa = va_arg (args, void *);
 
44
                        g_ptr_array_add (policy->allowed_poas, poa);
 
45
                }
 
46
        }
 
47
 
 
48
        va_end (args);
 
49
 
 
50
        return ORBit_RootObject_duplicate_T (policy);
 
51
}
 
52
 
 
53
ORBitPolicy *
 
54
ORBit_policy_ref (ORBitPolicy *p)
 
55
{
 
56
        return ORBit_RootObject_duplicate (p);
 
57
}
 
58
 
 
59
void
 
60
ORBit_policy_unref (ORBitPolicy *p)
 
61
{
 
62
        ORBit_RootObject_release (p);
 
63
}
 
64
 
 
65
void
 
66
ORBit_object_set_policy (CORBA_Object obj,
 
67
                         ORBitPolicy *p)
 
68
{
 
69
        if (obj == CORBA_OBJECT_NIL)
 
70
                return;
 
71
        ORBit_policy_unref (obj->invoke_policy);
 
72
        obj->invoke_policy = ORBit_policy_ref (p);
 
73
}
 
74
 
 
75
ORBitPolicy *
 
76
ORBit_object_get_policy (CORBA_Object obj)
 
77
{
 
78
        if (obj == CORBA_OBJECT_NIL)
 
79
                return CORBA_OBJECT_NIL;
 
80
        else
 
81
                return ORBit_policy_ref (obj->invoke_policy);
 
82
}
 
83
 
 
84
void
 
85
ORBit_policy_push (ORBitPolicy *p)
 
86
{
 
87
        GIOPThread *tdata = giop_thread_self ();
 
88
 
 
89
        if (!tdata->invoke_policies)
 
90
                tdata->invoke_policies = g_queue_new ();
 
91
        
 
92
        g_queue_push_head (tdata->invoke_policies, ORBit_policy_ref (p));
 
93
}
 
94
 
 
95
void
 
96
ORBit_policy_pop (void)
 
97
{
 
98
        GIOPThread *tdata = giop_thread_self ();
 
99
 
 
100
        if (!tdata->invoke_policies)
 
101
                g_warning ("No policy queue to pop from");
 
102
        else {
 
103
                ORBitPolicy *p;
 
104
                p = g_queue_pop_head (tdata->invoke_policies);
 
105
                ORBit_policy_unref (p);
 
106
        }
 
107
}
 
108
 
 
109
gboolean
 
110
ORBit_policy_validate (ORBitPolicy *policy)
 
111
{
 
112
        return TRUE;
 
113
}