Mercurial > pidgin.yaz
changeset 19931:cd067497cbe0
Fix the bug reported to the devel mailing list by Georgi Kirilov.
The bug is that, when displaying the results of a form-based
user search in XMPP, the server had to sent down the contents of
each item in the same order as the columns.
We now no longer make that assumption and instead make sure that
the value we add to each row is in the correct spot in the column.
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Wed, 12 Sep 2007 07:13:57 +0000 |
parents | ab87820e95b6 |
children | 8f8421bda08d |
files | libpurple/protocols/jabber/buddy.c |
diffstat | 1 files changed, 31 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/jabber/buddy.c Wed Sep 12 01:43:10 2007 +0000 +++ b/libpurple/protocols/jabber/buddy.c Wed Sep 12 07:13:57 2007 +0000 @@ -2147,36 +2147,58 @@ results = purple_notify_searchresults_new(); if((x = xmlnode_get_child_with_namespace(query, "x", "jabber:x:data"))) { xmlnode *reported; + GSList *column_vars = NULL; + purple_debug_info("jabber", "new-skool\n"); + if((reported = xmlnode_get_child(x, "reported"))) { xmlnode *field = xmlnode_get_child(reported, "field"); while(field) { - /* XXX keep track of this order, use it below */ const char *var = xmlnode_get_attrib(field, "var"); const char *label = xmlnode_get_attrib(field, "label"); if(var) { column = purple_notify_searchresults_column_new(label ? label : var); purple_notify_searchresults_column_add(results, column); + column_vars = g_slist_append(column_vars, (char *)var); } field = xmlnode_get_next_twin(field); } } + item = xmlnode_get_child(x, "item"); while(item) { GList *row = NULL; - field = xmlnode_get_child(item, "field"); - while(field) { - xmlnode *valuenode = xmlnode_get_child(field, "value"); - if(valuenode) { - char *value = xmlnode_get_data(valuenode); - row = g_list_append(row, value); + GSList *l; + xmlnode *valuenode; + const char *var; + + for (l = column_vars; l != NULL; l = l->next) { + /* + * Build a row containing the strings that correspond + * to each column of the search results. + */ + for (field = xmlnode_get_child(item, "field"); + field != NULL; + field = xmlnode_get_next_twin(field)) + { + if ((var = xmlnode_get_attrib(field, "var")) && + !strcmp(var, l->data) && + (valuenode = xmlnode_get_child(field, "value"))) + { + char *value = xmlnode_get_data(valuenode); + row = g_list_append(row, value); + break; + } } - field = xmlnode_get_next_twin(field); + if (field == NULL) + /* No data for this column */ + row = g_list_append(row, NULL); } purple_notify_searchresults_row_add(results, row); - item = xmlnode_get_next_twin(item); } + + g_slist_free(column_vars); } else { /* old skool */ purple_debug_info("jabber", "old-skool\n");