/src/pidgin/libpurple/protocols/jabber/jingle/transport.c
Line | Count | Source |
1 | | /** |
2 | | * @file transport.c |
3 | | * |
4 | | * purple |
5 | | * |
6 | | * Purple is the legal property of its developers, whose names are too numerous |
7 | | * to list here. Please refer to the COPYRIGHT file distributed with this |
8 | | * source distribution. |
9 | | * |
10 | | * This program is free software; you can redistribute it and/or modify |
11 | | * it under the terms of the GNU General Public License as published by |
12 | | * the Free Software Foundation; either version 2 of the License, or |
13 | | * (at your option) any later version. |
14 | | * |
15 | | * This program is distributed in the hope that it will be useful, |
16 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
17 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18 | | * GNU General Public License for more details. |
19 | | * |
20 | | * You should have received a copy of the GNU General Public License |
21 | | * along with this program; if not, write to the Free Software |
22 | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
23 | | */ |
24 | | |
25 | | #include "internal.h" |
26 | | |
27 | | #include "transport.h" |
28 | | #include "jingle.h" |
29 | | #include "debug.h" |
30 | | |
31 | | #include <string.h> |
32 | | |
33 | | struct _JingleTransportPrivate |
34 | | { |
35 | | void *dummy; |
36 | | }; |
37 | | |
38 | 0 | #define JINGLE_TRANSPORT_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), JINGLE_TYPE_TRANSPORT, JingleTransportPrivate)) |
39 | | |
40 | | static void jingle_transport_class_init (JingleTransportClass *klass); |
41 | | static void jingle_transport_init (JingleTransport *transport); |
42 | | static void jingle_transport_finalize (GObject *object); |
43 | | static void jingle_transport_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec); |
44 | | static void jingle_transport_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec); |
45 | | JingleTransport *jingle_transport_parse_internal(xmlnode *transport); |
46 | | xmlnode *jingle_transport_to_xml_internal(JingleTransport *transport, xmlnode *content, JingleActionType action); |
47 | | |
48 | | static GObjectClass *parent_class = NULL; |
49 | | |
50 | | enum { |
51 | | PROP_0, |
52 | | }; |
53 | | |
54 | | GType |
55 | | jingle_transport_get_type() |
56 | 0 | { |
57 | 0 | static GType type = 0; |
58 | |
|
59 | 0 | if (type == 0) { |
60 | 0 | static const GTypeInfo info = { |
61 | 0 | sizeof(JingleTransportClass), |
62 | 0 | NULL, |
63 | 0 | NULL, |
64 | 0 | (GClassInitFunc) jingle_transport_class_init, |
65 | 0 | NULL, |
66 | 0 | NULL, |
67 | 0 | sizeof(JingleTransport), |
68 | 0 | 0, |
69 | 0 | (GInstanceInitFunc) jingle_transport_init, |
70 | 0 | NULL |
71 | 0 | }; |
72 | 0 | type = g_type_register_static(G_TYPE_OBJECT, "JingleTransport", &info, 0); |
73 | 0 | } |
74 | 0 | return type; |
75 | 0 | } |
76 | | |
77 | | static void |
78 | | jingle_transport_class_init (JingleTransportClass *klass) |
79 | 0 | { |
80 | 0 | GObjectClass *gobject_class = (GObjectClass*)klass; |
81 | 0 | parent_class = g_type_class_peek_parent(klass); |
82 | |
|
83 | 0 | gobject_class->finalize = jingle_transport_finalize; |
84 | 0 | gobject_class->set_property = jingle_transport_set_property; |
85 | 0 | gobject_class->get_property = jingle_transport_get_property; |
86 | 0 | klass->to_xml = jingle_transport_to_xml_internal; |
87 | 0 | klass->parse = jingle_transport_parse_internal; |
88 | |
|
89 | 0 | g_type_class_add_private(klass, sizeof(JingleTransportPrivate)); |
90 | 0 | } |
91 | | |
92 | | static void |
93 | | jingle_transport_init (JingleTransport *transport) |
94 | 0 | { |
95 | 0 | transport->priv = JINGLE_TRANSPORT_GET_PRIVATE(transport); |
96 | 0 | transport->priv->dummy = NULL; |
97 | 0 | } |
98 | | |
99 | | static void |
100 | | jingle_transport_finalize (GObject *transport) |
101 | 0 | { |
102 | | /* JingleTransportPrivate *priv = JINGLE_TRANSPORT_GET_PRIVATE(transport); */ |
103 | 0 | purple_debug_info("jingle","jingle_transport_finalize\n"); |
104 | |
|
105 | 0 | parent_class->finalize(transport); |
106 | 0 | } |
107 | | |
108 | | static void |
109 | | jingle_transport_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) |
110 | 0 | { |
111 | 0 | g_return_if_fail(object != NULL); |
112 | 0 | g_return_if_fail(JINGLE_IS_TRANSPORT(object)); |
113 | | |
114 | 0 | switch (prop_id) { |
115 | 0 | default: |
116 | 0 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
117 | 0 | break; |
118 | 0 | } |
119 | 0 | } |
120 | | |
121 | | static void |
122 | | jingle_transport_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) |
123 | 0 | { |
124 | 0 | g_return_if_fail(object != NULL); |
125 | 0 | g_return_if_fail(JINGLE_IS_TRANSPORT(object)); |
126 | | |
127 | 0 | switch (prop_id) { |
128 | 0 | default: |
129 | 0 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); |
130 | 0 | break; |
131 | 0 | } |
132 | 0 | } |
133 | | |
134 | | JingleTransport * |
135 | | jingle_transport_create(const gchar *type) |
136 | 0 | { |
137 | 0 | return g_object_new(jingle_get_type(type), NULL); |
138 | 0 | } |
139 | | |
140 | | const gchar * |
141 | | jingle_transport_get_transport_type(JingleTransport *transport) |
142 | 0 | { |
143 | 0 | return JINGLE_TRANSPORT_GET_CLASS(transport)->transport_type; |
144 | 0 | } |
145 | | |
146 | | JingleTransport * |
147 | | jingle_transport_parse_internal(xmlnode *transport) |
148 | 0 | { |
149 | 0 | const gchar *type = xmlnode_get_namespace(transport); |
150 | 0 | return jingle_transport_create(type); |
151 | 0 | } |
152 | | |
153 | | xmlnode * |
154 | | jingle_transport_to_xml_internal(JingleTransport *transport, xmlnode *content, JingleActionType action) |
155 | 0 | { |
156 | 0 | xmlnode *node = xmlnode_new_child(content, "transport"); |
157 | 0 | xmlnode_set_namespace(node, jingle_transport_get_transport_type(transport)); |
158 | 0 | return node; |
159 | 0 | } |
160 | | |
161 | | JingleTransport * |
162 | | jingle_transport_parse(xmlnode *transport) |
163 | 0 | { |
164 | 0 | const gchar *type_name = xmlnode_get_namespace(transport); |
165 | 0 | GType type = jingle_get_type(type_name); |
166 | 0 | if (type == G_TYPE_NONE) |
167 | 0 | return NULL; |
168 | | |
169 | 0 | return JINGLE_TRANSPORT_CLASS(g_type_class_ref(type))->parse(transport); |
170 | 0 | } |
171 | | |
172 | | xmlnode * |
173 | | jingle_transport_to_xml(JingleTransport *transport, xmlnode *content, JingleActionType action) |
174 | 0 | { |
175 | 0 | g_return_val_if_fail(transport != NULL, NULL); |
176 | 0 | g_return_val_if_fail(JINGLE_IS_TRANSPORT(transport), NULL); |
177 | 0 | return JINGLE_TRANSPORT_GET_CLASS(transport)->to_xml(transport, content, action); |
178 | 0 | } |
179 | | |