diff options
author | Jonny Lamb <jonny.lamb@collabora.co.uk> | 2011-02-04 17:06:54 +0000 |
---|---|---|
committer | Will Thompson <will.thompson@collabora.co.uk> | 2011-05-02 15:11:32 +0100 |
commit | 3cd3ffc609f92a534317f006eb4401f39bc4b279 (patch) | |
tree | cfad467e4798bf5cacd09f8953fcd48a61c10f26 /src/search-channel.c | |
parent | 0de3d249d69bb99fddbcf72e4dafe36660245eb7 (diff) | |
download | telepathy-gabble-3cd3ffc609f92a534317f006eb4401f39bc4b279.tar.gz |
stop using LmMessageNode wrapper
WockyNode is the future.
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
Diffstat (limited to 'src/search-channel.c')
-rw-r--r-- | src/search-channel.c | 109 |
1 files changed, 53 insertions, 56 deletions
diff --git a/src/search-channel.c b/src/search-channel.c index 4fc6a29c1..bd0ffb2b4 100644 --- a/src/search-channel.c +++ b/src/search-channel.c @@ -206,7 +206,7 @@ supported_field_discovery_failed (GabbleSearchChannel *chan, static GPtrArray * parse_unextended_field_response ( GabbleSearchChannel *self, - LmMessageNode *query_node, + WockyNode *query_node, GError **error) { GPtrArray *search_keys = g_ptr_array_new (); @@ -214,13 +214,13 @@ parse_unextended_field_response ( for (i = node_iter (query_node); i; i = node_iter_next (i)) { - LmMessageNode *field = node_iter_data (i); + WockyNode *field = node_iter_data (i); gchar *tp_name; if (!strcmp (field->name, "instructions")) { DEBUG ("server gave us some instructions: %s", - lm_message_node_get_value (field)); + field->content); continue; } @@ -263,13 +263,13 @@ name_in_array (GPtrArray *array, static GPtrArray * parse_data_form ( GabbleSearchChannel *self, - LmMessageNode *x_node, + WockyNode *x_node, GError **error) { GPtrArray *search_keys = g_ptr_array_new (); NodeIter i; - if (tp_strdiff (lm_message_node_get_attribute (x_node, "type"), "form")) + if (tp_strdiff (wocky_node_get_attribute (x_node, "type"), "form")) { g_set_error (error, TP_ERRORS, TP_ERROR_NOT_AVAILABLE, "server is broken: <x> not type='form'"); @@ -278,15 +278,15 @@ parse_data_form ( for (i = node_iter (x_node); i; i = node_iter_next (i)) { - LmMessageNode *n = node_iter_data (i); - const gchar *type = lm_message_node_get_attribute (n, "type"); - const gchar *var = lm_message_node_get_attribute (n, "var"); + WockyNode *n = node_iter_data (i); + const gchar *type = wocky_node_get_attribute (n, "type"); + const gchar *var = wocky_node_get_attribute (n, "var"); gchar *tp_name; if (!strcmp (n->name, "title") || !strcmp (n->name, "instructions")) { - DEBUG ("ignoring <%s>: %s", n->name, lm_message_node_get_value (n)); + DEBUG ("ignoring <%s>: %s", n->name, n->content); continue; } @@ -302,8 +302,7 @@ parse_data_form ( if (!strcmp (var, "FORM_TYPE")) { if (node_iter (n) == NULL || - strcmp (lm_message_node_get_value (node_iter_data ( - node_iter (n))), NS_SEARCH)) + strcmp (node_iter_data (node_iter (n))->content, NS_SEARCH)) { DEBUG ("<x> form does not have FORM_TYPE %s", NS_SEARCH); g_set_error (error, TP_ERRORS, TP_ERROR_NOT_AVAILABLE, @@ -357,9 +356,9 @@ fail: static void parse_search_field_response (GabbleSearchChannel *chan, - LmMessageNode *query_node) + WockyNode *query_node) { - LmMessageNode *x_node; + WockyNode *x_node; GPtrArray *search_keys = NULL; GError *e = NULL; @@ -402,7 +401,7 @@ query_reply_cb (GabbleConnection *conn, gpointer user_data) { GabbleSearchChannel *chan = GABBLE_SEARCH_CHANNEL (object); - LmMessageNode *query_node; + WockyNode *query_node; GError *err = NULL; query_node = lm_message_node_get_child_with_namespace ( @@ -442,14 +441,14 @@ request_search_fields (GabbleSearchChannel *chan) TpBaseChannel *base = TP_BASE_CHANNEL (chan); TpBaseConnection *base_conn = tp_base_channel_get_connection (base); LmMessage *msg; - LmMessageNode *lm_node; + WockyNode *lm_node; GError *error = NULL; msg = lm_message_new_with_sub_type (chan->priv->server, LM_MESSAGE_TYPE_IQ, LM_MESSAGE_SUB_TYPE_GET); - lm_node = lm_message_node_add_child ( + lm_node = wocky_node_add_child_with_content ( wocky_stanza_get_top_node (msg), "query", NULL); - lm_message_node_set_attribute (lm_node, "xmlns", NS_SEARCH); + lm_node->ns = g_quark_from_string (NS_SEARCH); if (! _gabble_connection_send_with_reply (GABBLE_CONNECTION (base_conn), msg, query_reply_cb, (GObject *) chan, NULL, &error)) @@ -642,9 +641,9 @@ add_search_result (GabbleSearchChannel *chan, static void parse_result_item (GabbleSearchChannel *chan, - LmMessageNode *item) + WockyNode *item) { - const gchar *jid = lm_message_node_get_attribute (item, "jid"); + const gchar *jid = wocky_node_get_attribute (item, "jid"); GHashTable *info; NodeIter i; @@ -659,8 +658,8 @@ parse_result_item (GabbleSearchChannel *chan, for (i = node_iter (item); i; i = node_iter_next (i)) { - LmMessageNode *n = node_iter_data (i); - gchar *value = (gchar *) lm_message_node_get_value (n); + WockyNode *n = node_iter_data (i); + gchar *value = (gchar *) n->content; g_hash_table_insert (info, n->name, value); } @@ -671,7 +670,7 @@ parse_result_item (GabbleSearchChannel *chan, static void parse_extended_result_item (GabbleSearchChannel *chan, - LmMessageNode *item) + WockyNode *item) { GHashTable *info; NodeIter i; @@ -680,8 +679,8 @@ parse_extended_result_item (GabbleSearchChannel *chan, for (i = node_iter (item); i; i = node_iter_next (i)) { - LmMessageNode *field = node_iter_data (i); - LmMessageNode *value_node; + WockyNode *field = node_iter_data (i); + WockyNode *value_node; const gchar *var, *value; if (tp_strdiff (field->name, "field")) @@ -691,21 +690,21 @@ parse_extended_result_item (GabbleSearchChannel *chan, continue; } - var = lm_message_node_get_attribute (field, "var"); + var = wocky_node_get_attribute (field, "var"); if (var == NULL) { DEBUG ("Ignore <field/> without 'var' attribut"); continue; } - value_node = lm_message_node_get_child (field, "value"); + value_node = wocky_node_get_child (field, "value"); if (value_node == NULL) { DEBUG ("Ignore <field/> without <value/> child"); continue; } - value = lm_message_node_get_value (value_node); + value = value_node->content; g_hash_table_insert (info, (gchar *) var, (gchar *) value); } @@ -724,14 +723,14 @@ parse_extended_result_item (GabbleSearchChannel *chan, static gboolean parse_unextended_search_results (GabbleSearchChannel *chan, - LmMessageNode *query_node, + WockyNode *query_node, GError **error) { NodeIter i; for (i = node_iter (query_node); i; i = node_iter_next (i)) { - LmMessageNode *item = node_iter_data (i); + WockyNode *item = node_iter_data (i); if (!strcmp (item->name, "item")) parse_result_item (chan, item); @@ -745,10 +744,10 @@ parse_unextended_search_results (GabbleSearchChannel *chan, static gboolean parse_extended_search_results (GabbleSearchChannel *chan, - LmMessageNode *query_node, + WockyNode *query_node, GError **error) { - LmMessageNode *x; + WockyNode *x; NodeIter i; x = lm_message_node_get_child_with_namespace (query_node, "x", NS_X_DATA); @@ -761,7 +760,7 @@ parse_extended_search_results (GabbleSearchChannel *chan, for (i = node_iter (x); i; i = node_iter_next (i)) { - LmMessageNode *item = node_iter_data (i); + WockyNode *item = node_iter_data (i); if (!tp_strdiff (item->name, "item")) parse_extended_result_item (chan, item); @@ -769,7 +768,7 @@ parse_extended_search_results (GabbleSearchChannel *chan, /* Ignore <reported> node */ continue; else if (!tp_strdiff (item->name, "title")) - DEBUG ("title: %s", lm_message_node_get_value (item)); + DEBUG ("title: %s", item->content); else DEBUG ("found <%s/> in <x/> rather than <item/>, <title/> and " "<reported/>, skipping", item->name); @@ -780,7 +779,7 @@ parse_extended_search_results (GabbleSearchChannel *chan, static gboolean parse_search_results (GabbleSearchChannel *chan, - LmMessageNode *query_node, + WockyNode *query_node, GError **error) { if (chan->priv->xforms) @@ -797,7 +796,7 @@ search_reply_cb (GabbleConnection *conn, gpointer user_data) { GabbleSearchChannel *chan = GABBLE_SEARCH_CHANNEL (object); - LmMessageNode *query_node; + WockyNode *query_node; GError *err = NULL; DEBUG ("called"); @@ -906,7 +905,7 @@ validate_terms (GabbleSearchChannel *chan, static void build_unextended_query ( GabbleSearchChannel *self, - LmMessageNode *query, + WockyNode *query, GHashTable *terms) { GHashTableIter iter; @@ -920,32 +919,30 @@ build_unextended_query ( g_assert (xmpp_field != NULL); - lm_message_node_add_child (query, xmpp_field, value); + wocky_node_add_child_with_content (query, xmpp_field, value); } } static void build_extended_query (GabbleSearchChannel *self, - LmMessageNode *query, + WockyNode *query, GHashTable *terms) { - LmMessageNode *x, *field; + WockyNode *x, *field; GHashTableIter iter; gpointer key, value; - x = lm_message_node_add_child (query, "x", ""); - lm_message_node_set_attributes (x, - "type", "submit", - "xmlns", NS_X_DATA, - NULL); + x = wocky_node_add_child_with_content (query, "x", ""); + x->ns = g_quark_from_static_string (NS_X_DATA); + wocky_node_set_attribute (x, "type", "submit"); /* add FORM_TYPE */ - field = lm_message_node_add_child (x, "field", ""); - lm_message_node_set_attributes (field, + field = wocky_node_add_child_with_content (x, "field", ""); + wocky_node_set_attributes (field, "type", "hidden", "var", "FORM_TYPE", NULL); - lm_message_node_add_child (field, "value", NS_SEARCH); + wocky_node_add_child_with_content (field, "value", NS_SEARCH); /* Add search terms */ g_hash_table_iter_init (&iter, terms); @@ -957,9 +954,9 @@ build_extended_query (GabbleSearchChannel *self, g_assert (xmpp_field != NULL); - field = lm_message_node_add_child (x, "field", ""); - lm_message_node_set_attribute (field, "var", xmpp_field); - lm_message_node_add_child (field, "value", value); + field = wocky_node_add_child_with_content (x, "field", ""); + wocky_node_set_attribute (field, "var", xmpp_field); + wocky_node_add_child_with_content (field, "value", value); if (!tp_strdiff (tp_name, "")) { @@ -970,12 +967,12 @@ build_extended_query (GabbleSearchChannel *self, { xmpp_field = g_ptr_array_index (self->priv->boolean_keys, i); - field = lm_message_node_add_child (x, "field", ""); - lm_message_node_set_attributes (field, + field = wocky_node_add_child_with_content (x, "field", ""); + wocky_node_set_attributes (field, "var", xmpp_field, "type", "boolean", NULL); - lm_message_node_add_child (field, "value", "1"); + wocky_node_add_child_with_content (field, "value", "1"); } } } @@ -989,7 +986,7 @@ do_search (GabbleSearchChannel *chan, TpBaseChannel *base = TP_BASE_CHANNEL (chan); TpBaseConnection *base_conn = tp_base_channel_get_connection (base); LmMessage *msg; - LmMessageNode *query; + WockyNode *query; gboolean ret; DEBUG ("called"); @@ -999,9 +996,9 @@ do_search (GabbleSearchChannel *chan, msg = lm_message_new_with_sub_type (chan->priv->server, LM_MESSAGE_TYPE_IQ, LM_MESSAGE_SUB_TYPE_SET); - query = lm_message_node_add_child ( + query = wocky_node_add_child_with_content ( wocky_stanza_get_top_node (msg), "query", NULL); - lm_message_node_set_attribute (query, "xmlns", NS_SEARCH); + query->ns = g_quark_from_string (NS_SEARCH); if (chan->priv->xforms) { |