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
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
27 #include "transport.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
);
46 jingle_transport_add_local_candidate_internal(JingleTransport
*transport
, const gchar
*id
, guint generation
, PurpleMediaCandidate
*candidate
)
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
));
60 jingle_transport_get_remote_candidates_internal(JingleTransport
*transport
)
65 /******************************************************************************
67 *****************************************************************************/
69 jingle_transport_init (JingleTransport
*transport
)
74 jingle_transport_class_finalize (JingleTransportClass
*klass
)
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 /******************************************************************************
89 *****************************************************************************/
91 jingle_transport_register(PurplePlugin
*plugin
) {
92 jingle_transport_register_type(G_TYPE_MODULE(plugin
));
96 jingle_transport_create(const gchar
*type
)
98 return g_object_new(jingle_get_type(type
), NULL
);
102 jingle_transport_get_transport_type(JingleTransport
*transport
)
104 return JINGLE_TRANSPORT_GET_CLASS(transport
)->transport_type
;
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
);
116 jingle_transport_get_remote_candidates(JingleTransport
*transport
)
118 return JINGLE_TRANSPORT_GET_CLASS(transport
)->get_remote_candidates(transport
);
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
)
129 return JINGLE_TRANSPORT_CLASS(g_type_class_ref(type
))->parse(transport
);
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
);