1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
#include "pn_ns.h"
#include "pn_cmd_node.h"
#include "pn_session.h"
static void *parent_class;
struct pn_ns_priv {
struct pn_session *session;
gulong open_sig_handler;
};
enum {
PROP_SESSION = 1,
};
struct pn_ns *
pn_ns_new(struct pn_session *session)
{
return g_object_new(PN_NS_TYPE,
"session", session,
NULL);
}
void
pn_ns_free(struct pn_ns *ns)
{
if (!ns)
return;
g_object_unref(ns);
}
static void
open_cb(struct pn_ns *self)
{
/* stub */
}
/* GObject stuff */
static void
instance_init(GTypeInstance *instance,
void *g_class)
{
struct pn_ns *self = PN_NS(instance);
struct pn_ns_priv *priv = self->priv;
self->priv = priv = G_TYPE_INSTANCE_GET_PRIVATE(instance, PN_NS_TYPE, struct pn_ns_priv);
priv->open_sig_handler = g_signal_connect(self, "open", G_CALLBACK(open_cb), NULL);
}
static void
get_property(GObject *object,
unsigned property_id,
GValue *value,
GParamSpec *spec)
{
struct pn_ns *self = PN_NS(object);
struct pn_ns_priv *priv = self->priv;
switch (property_id) {
case PROP_SESSION:
g_value_set_object(value, priv->session);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, spec);
}
}
static void
set_property(GObject *object,
unsigned property_id,
const GValue *value,
GParamSpec *spec)
{
struct pn_ns *self = PN_NS(object);
struct pn_ns_priv *priv = self->priv;
switch (property_id) {
case PROP_SESSION:
priv->session = g_value_get_object(value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, spec);
}
}
static void
dispose(GObject *obj)
{
struct pn_ns *self = PN_NS(obj);
struct pn_ns_priv *priv = self->priv;
if (priv->open_sig_handler) {
g_signal_handler_disconnect(self, priv->open_sig_handler);
priv->open_sig_handler = 0;
}
G_OBJECT_CLASS(parent_class)->dispose(obj);
}
static void
class_init(void *g_class,
void *class_data)
{
GObjectClass *gobject_class = G_OBJECT_CLASS(g_class);
gobject_class->dispose = dispose;
gobject_class->get_property = get_property;
gobject_class->set_property = set_property;
{
GParamSpec *param_spec;
param_spec = g_param_spec_object("session", "Session", "The Session",
PN_SESSION_TYPE,
G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE);
g_object_class_install_property(gobject_class, PROP_SESSION, param_spec);
}
parent_class = g_type_class_peek_parent(g_class);
g_type_class_add_private(g_class, sizeof(struct pn_ns_priv));
}
GType
pn_ns_get_type(void)
{
static gsize init_type;
if (g_once_init_enter(&init_type)) {
GType type;
GTypeInfo type_info = {
.class_size = sizeof(struct pn_ns_class),
.class_init = class_init,
.instance_size = sizeof(struct pn_ns),
.instance_init = instance_init,
};
type = g_type_register_static(PN_CMD_NODE_TYPE, "PnNs", &type_info, 0);
g_once_init_leave(&init_type, type);
}
return init_type;
}
|