rename accountopt.[ch] to purpleaccountoption.[ch]
[pidgin-git.git] / libpurple / protocols / jabber / jingle / transport.c
blob7287229d74378bea173e7f62805def5e2f0d99c5
1 /**
2 * @file transport.c
4 * purple
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.
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.
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.
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
25 #include "internal.h"
27 #include "transport.h"
28 #include "jingle.h"
29 #include "debug.h"
31 #include <string.h>
33 G_DEFINE_DYNAMIC_TYPE(JingleTransport, jingle_transport, G_TYPE_OBJECT);
35 /******************************************************************************
36 * Transport Implementation
37 *****************************************************************************/
38 static JingleTransport *
39 jingle_transport_parse_internal(PurpleXmlNode *transport)
41 const gchar *type = purple_xmlnode_get_namespace(transport);
42 return jingle_transport_create(type);
45 static void
46 jingle_transport_add_local_candidate_internal(JingleTransport *transport, const gchar *id, guint generation, PurpleMediaCandidate *candidate)
48 /* Nothing to do */
51 static PurpleXmlNode *
52 jingle_transport_to_xml_internal(JingleTransport *transport, PurpleXmlNode *content, JingleActionType action)
54 PurpleXmlNode *node = purple_xmlnode_new_child(content, "transport");
55 purple_xmlnode_set_namespace(node, jingle_transport_get_transport_type(transport));
56 return node;
59 static GList *
60 jingle_transport_get_remote_candidates_internal(JingleTransport *transport)
62 return NULL;
65 /******************************************************************************
66 * GObject Stuff
67 *****************************************************************************/
68 static void
69 jingle_transport_init (JingleTransport *transport)
73 static void
74 jingle_transport_class_finalize (JingleTransportClass *klass)
78 static void
79 jingle_transport_class_init (JingleTransportClass *klass)
81 klass->to_xml = jingle_transport_to_xml_internal;
82 klass->parse = jingle_transport_parse_internal;
83 klass->add_local_candidate = jingle_transport_add_local_candidate_internal;
84 klass->get_remote_candidates = jingle_transport_get_remote_candidates_internal;
87 /******************************************************************************
88 * Public API
89 *****************************************************************************/
90 void
91 jingle_transport_register(PurplePlugin *plugin) {
92 jingle_transport_register_type(G_TYPE_MODULE(plugin));
95 JingleTransport *
96 jingle_transport_create(const gchar *type)
98 return g_object_new(jingle_get_type(type), NULL);
101 const gchar *
102 jingle_transport_get_transport_type(JingleTransport *transport)
104 return JINGLE_TRANSPORT_GET_CLASS(transport)->transport_type;
107 void
108 jingle_transport_add_local_candidate(JingleTransport *transport, const gchar *id,
109 guint generation, PurpleMediaCandidate *candidate)
111 JINGLE_TRANSPORT_GET_CLASS(transport)->add_local_candidate(transport, id,
112 generation, candidate);
115 GList *
116 jingle_transport_get_remote_candidates(JingleTransport *transport)
118 return JINGLE_TRANSPORT_GET_CLASS(transport)->get_remote_candidates(transport);
121 JingleTransport *
122 jingle_transport_parse(PurpleXmlNode *transport)
124 const gchar *type_name = purple_xmlnode_get_namespace(transport);
125 GType type = jingle_get_type(type_name);
126 if (type == G_TYPE_NONE)
127 return NULL;
129 return JINGLE_TRANSPORT_CLASS(g_type_class_ref(type))->parse(transport);
132 PurpleXmlNode *
133 jingle_transport_to_xml(JingleTransport *transport, PurpleXmlNode *content, JingleActionType action)
135 g_return_val_if_fail(transport != NULL, NULL);
136 g_return_val_if_fail(JINGLE_IS_TRANSPORT(transport), NULL);
137 return JINGLE_TRANSPORT_GET_CLASS(transport)->to_xml(transport, content, action);