diff options
author | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2010-10-08 13:42:34 +0100 |
---|---|---|
committer | Simon McVittie <simon.mcvittie@collabora.co.uk> | 2010-10-08 13:42:34 +0100 |
commit | 8418b6f5cde587b444c45a308e8a8698e39b383f (patch) | |
tree | 41621ce0fd32a5110148148c8d9a908f4b7848a1 /src/text-helper.c | |
parent | e6efc9a197db675f84df2e84ebb38e283f90ed22 (diff) | |
download | telepathy-salut-8418b6f5cde587b444c45a308e8a8698e39b383f.tar.gz |
Replace GibberXmppNode and GibberXmppStanza with WockyNode and WockyStanza
Most of the API is similar enough to add a pile of #defines and not touch
application code. Exceptions:
- wocky_node_each_attribute passes an extra argument to the callback,
so adjust GibberXmppWriter and test-xmpp-connection to cope
- WockyStanza->node doesn't exist, so use wocky_xmpp_stanza_get_top_node
a lot
Diffstat (limited to 'src/text-helper.c')
-rw-r--r-- | src/text-helper.c | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/src/text-helper.c b/src/text-helper.c index 3f86fc88..5155d514 100644 --- a/src/text-helper.c +++ b/src/text-helper.c @@ -47,12 +47,13 @@ static void add_text (GibberXmppStanza *stanza, const gchar *text) { + WockyNode *node = wocky_stanza_get_top_node (stanza); GibberXmppNode *htmlnode; - gibber_xmpp_node_add_child_with_content (stanza->node, "body", text); + gibber_xmpp_node_add_child_with_content (node, "body", text); /* Add plain xhtml-im node */ - htmlnode = gibber_xmpp_node_add_child_ns (stanza->node, "html", + htmlnode = gibber_xmpp_node_add_child_ns (node, "html", GIBBER_XMPP_NS_XHTML_IM); gibber_xmpp_node_add_child_with_content_ns (htmlnode, "body", text, GIBBER_W3C_NS_XHTML); @@ -64,6 +65,7 @@ create_message_stanza (const gchar *from, GError **error) { GibberXmppStanza *stanza; + WockyNode *node; if (type > TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE) { @@ -75,9 +77,10 @@ create_message_stanza (const gchar *from, return NULL; } stanza = gibber_xmpp_stanza_new_ns ("message", WOCKY_XMPP_NS_JABBER_CLIENT); + node = wocky_stanza_get_top_node (stanza); - gibber_xmpp_node_set_attribute (stanza->node, "from", from); - gibber_xmpp_node_set_attribute (stanza->node, "to", to); + gibber_xmpp_node_set_attribute (node, "from", from); + gibber_xmpp_node_set_attribute (node, "to", to); if (type == TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION) { @@ -102,8 +105,11 @@ text_helper_create_message (const gchar *from, GError **error) { GibberXmppStanza *stanza; + WockyNode *node; stanza = create_message_stanza (from, to, type, text, error); + node = wocky_stanza_get_top_node (stanza); + if (stanza == NULL) return NULL; @@ -111,10 +117,10 @@ text_helper_create_message (const gchar *from, { case TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL: case TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION: - gibber_xmpp_node_set_attribute (stanza->node, "type", "chat"); + gibber_xmpp_node_set_attribute (node, "type", "chat"); break; case TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE: - gibber_xmpp_node_set_attribute (stanza->node, "type", "normal"); + gibber_xmpp_node_set_attribute (node, "type", "normal"); break; default: g_assert_not_reached (); @@ -132,19 +138,22 @@ text_helper_create_message_groupchat (const gchar *from, GError **error) { GibberXmppStanza *stanza; + WockyNode *node; stanza = create_message_stanza (from, to, type, text, error); if (stanza == NULL) return NULL; + node = wocky_stanza_get_top_node (stanza); + switch (type) { case TP_CHANNEL_TEXT_MESSAGE_TYPE_NORMAL: case TP_CHANNEL_TEXT_MESSAGE_TYPE_ACTION: - gibber_xmpp_node_set_attribute (stanza->node, "type", "groupchat"); + gibber_xmpp_node_set_attribute (node, "type", "groupchat"); break; case TP_CHANNEL_TEXT_MESSAGE_TYPE_NOTICE: - gibber_xmpp_node_set_attribute (stanza->node, "type", "normal"); + gibber_xmpp_node_set_attribute (node, "type", "normal"); break; default: g_assert_not_reached (); @@ -164,11 +173,12 @@ text_helper_parse_incoming_message (GibberXmppStanza *stanza, const gchar *type; GibberXmppNode *node; GibberXmppNode *event; + WockyNode *top_node = wocky_stanza_get_top_node (stanza); - *from = gibber_xmpp_node_get_attribute (stanza->node, "from"); - type = gibber_xmpp_node_get_attribute (stanza->node, "type"); + *from = gibber_xmpp_node_get_attribute (top_node, "from"); + type = gibber_xmpp_node_get_attribute (top_node, "type"); /* Work around iChats strange way of doing typing notification */ - event = gibber_xmpp_node_get_child_ns (stanza->node, "x", + event = gibber_xmpp_node_get_child_ns (top_node, "x", GIBBER_XMPP_NS_EVENT); if (event != NULL) @@ -184,7 +194,7 @@ text_helper_parse_incoming_message (GibberXmppStanza *stanza, /* * Parse body if it exists. */ - node = gibber_xmpp_node_get_child (stanza->node, "body"); + node = gibber_xmpp_node_get_child (top_node, "body"); if (node) { |