summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Thompson <will.thompson@collabora.co.uk>2013-03-01 15:04:11 +0000
committerWill Thompson <will.thompson@collabora.co.uk>2013-03-01 15:04:11 +0000
commitd822581db0752351850b7e7ddfe3e70008897a5b (patch)
treecc7fc0e8fd0109fac5d9238d8dce5905c93806db
parente77ed03f870529c027b5abe98cd7f4620a063995 (diff)
parent565f2ed54f53adc7bd6793a0e746ceb349843408 (diff)
Merge branch 'gabble-0.16'
-rw-r--r--wocky/wocky-caps-hash.c37
-rw-r--r--wocky/wocky-data-form.c2
2 files changed, 31 insertions, 8 deletions
diff --git a/wocky/wocky-caps-hash.c b/wocky/wocky-caps-hash.c
index 1c18293..01006a7 100644
--- a/wocky/wocky-caps-hash.c
+++ b/wocky/wocky-caps-hash.c
@@ -80,8 +80,17 @@ dataforms_cmp (gconstpointer a,
else if (left_type != NULL && right_type == NULL)
return 1;
else /* left_type != NULL && right_type != NULL */
- return strcmp (g_value_get_string (left_type->default_value),
- g_value_get_string (right_type->default_value));
+ {
+ const gchar *left_value = NULL, *right_value = NULL;
+
+ if (left_type->raw_value_contents != NULL)
+ left_value = left_type->raw_value_contents[0];
+
+ if (right_type->raw_value_contents != NULL)
+ right_value = right_type->raw_value_contents[0];
+
+ return g_strcmp0 (left_value, right_value);
+ }
}
static GPtrArray *
@@ -190,16 +199,22 @@ wocky_caps_hash_compute_from_lists (
continue;
}
- form_name = g_value_get_string (field->default_value);
-
if (field->type != WOCKY_DATA_FORM_FIELD_TYPE_HIDDEN)
{
- DEBUG ("FORM_TYPE field of form '%s' is not hidden; "
- "ignoring form and moving onto next one",
- form_name);
+ DEBUG ("FORM_TYPE field is not hidden; "
+ "ignoring form and moving onto next one");
continue;
}
+ if (field->raw_value_contents == NULL ||
+ g_strv_length (field->raw_value_contents) != 1)
+ {
+ DEBUG ("FORM_TYPE field does not have exactly one value; failing");
+ goto cleanup;
+ }
+
+ form_name = field->raw_value_contents[0];
+
if (g_hash_table_lookup (form_names, form_name) != NULL)
{
DEBUG ("error: there are multiple data forms with the "
@@ -224,6 +239,14 @@ wocky_caps_hash_compute_from_lists (
field = l->data;
+ if (field->var == NULL)
+ {
+ DEBUG ("can't hash form '%s': it has an anonymous field",
+ form_name);
+ g_slist_free (fields);
+ goto cleanup;
+ }
+
if (!wocky_strdiff (field->var, "FORM_TYPE"))
continue;
diff --git a/wocky/wocky-data-form.c b/wocky/wocky-data-form.c
index 8428016..c74c1ae 100644
--- a/wocky/wocky-data-form.c
+++ b/wocky/wocky-data-form.c
@@ -1050,7 +1050,7 @@ gint
wocky_data_form_field_cmp (const WockyDataFormField *left,
const WockyDataFormField *right)
{
- return strcmp (left->var, right->var);
+ return g_strcmp0 (left->var, right->var);
}
static void