summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWill Thompson <will.thompson@collabora.co.uk>2010-03-25 12:46:22 (GMT)
committerWill Thompson <will.thompson@collabora.co.uk>2010-03-25 15:20:06 (GMT)
commit74072d08ab03f6f70513542728d5b0fdbfe33229 (patch)
tree5f15a6d07e10a68dfa02cbe09431b007865a8b51
parente3b19005cc7512ae8bb37a6c949c08ce343b01ae (diff)
downloadwocky-74072d08ab03f6f70513542728d5b0fdbfe33229.tar.gz
wocky-74072d08ab03f6f70513542728d5b0fdbfe33229.tar.xz
Use get_content_from_child a bunch.
I actually thought it would be useful in more places than this. Oh well.
-rw-r--r--wocky/wocky-data-form.c36
-rw-r--r--wocky/wocky-muc.c18
-rw-r--r--wocky/wocky-xmpp-error.c7
3 files changed, 16 insertions, 45 deletions
diff --git a/wocky/wocky-data-form.c b/wocky/wocky-data-form.c
index f3285e8..f8d5dee 100644
--- a/wocky/wocky-data-form.c
+++ b/wocky/wocky-data-form.c
@@ -289,22 +289,19 @@ extract_options_list (WockyXmppNode *node)
while (wocky_xmpp_node_iter_next (&iter, &option_node))
{
- WockyXmppNode *value;
WockyDataFormFieldOption *option;
- const gchar *label;
+ const gchar *value, *label;
+ value = wocky_xmpp_node_get_content_from_child (option_node, "value");
label = wocky_xmpp_node_get_attribute (option_node, "label");
- /* the label is optional */
- value = wocky_xmpp_node_get_child (option_node, "value");
if (value == NULL)
continue;
- if (value->content == NULL)
- continue;
+ /* the label is optional */
- DEBUG ("Add option: %s", value->content);
- option = wocky_data_form_field_option_new (label, value->content);
+ DEBUG ("Add option: %s", value);
+ option = wocky_data_form_field_option_new (label, value);
result = g_slist_append (result, option);
}
@@ -479,20 +476,14 @@ static WockyDataFormField *
data_form_parse_form_field (WockyXmppNode *field_node)
{
WockyDataFormField *field;
- const gchar *var, *label;
+ const gchar *var, *label, *desc;
WockyDataFormFieldType type;
- WockyXmppNode *desc_node;
- const gchar *desc = NULL;
gboolean required;
if (!extract_var_type_label (field_node, &var, &type, &label))
return NULL;
- desc_node = wocky_xmpp_node_get_child (field_node, "desc");
-
- if (desc_node != NULL)
- desc = desc_node->content;
-
+ desc = wocky_xmpp_node_get_content_from_child (field_node, "desc");
required = (wocky_xmpp_node_get_child (field_node, "required") != NULL);
field = create_field (field_node, var, type, label, desc, required);
@@ -529,7 +520,7 @@ wocky_data_form_new_from_form (WockyXmppNode *root,
{
WockyXmppNode *x, *node;
WockyXmppNodeIter iter;
- const gchar *type, *title = NULL, *instructions = NULL;
+ const gchar *type, *title, *instructions;
WockyDataForm *form;
x = wocky_xmpp_node_get_child_ns (root, "x", WOCKY_XMPP_NS_DATA);
@@ -551,15 +542,8 @@ wocky_data_form_new_from_form (WockyXmppNode *root,
return NULL;
}
- /* get title */
- node = wocky_xmpp_node_get_child (x, "title");
- if (node != NULL)
- title = node->content;
-
- /* get instructions */
- node = wocky_xmpp_node_get_child (x, "instructions");
- if (node != NULL)
- instructions = node->content;
+ title = wocky_xmpp_node_get_content_from_child (x, "title");
+ instructions = wocky_xmpp_node_get_content_from_child (x, "instructions");
form = g_object_new (WOCKY_TYPE_DATA_FORM,
"title", title,
diff --git a/wocky/wocky-muc.c b/wocky/wocky-muc.c
index 6368bcb..adc2954 100644
--- a/wocky/wocky-muc.c
+++ b/wocky/wocky-muc.c
@@ -609,7 +609,6 @@ static gboolean
store_muc_disco_info_x (WockyXmppNode *field, gpointer data)
{
WockyMucPrivate *priv = data;
- WockyXmppNode *val = NULL;
const gchar *var = NULL;
if (wocky_strdiff (field->name, "field"))
@@ -620,12 +619,8 @@ store_muc_disco_info_x (WockyXmppNode *field, gpointer data)
if (wocky_strdiff (var, "muc#roominfo_description"))
return TRUE;
- val = wocky_xmpp_node_get_child (field, "value");
-
- if (val == NULL)
- return TRUE;
-
- priv->desc = g_strdup (val->content);
+ priv->desc = g_strdup (
+ wocky_xmpp_node_get_content_from_child (field, "value"));
return TRUE;
}
@@ -1454,13 +1449,8 @@ handle_message (WockyPorter *porter,
}
}
- child = wocky_xmpp_node_get_child (msg, "body");
- if (child != NULL)
- body = child->content;
-
- child = wocky_xmpp_node_get_child (msg, "subject");
- if (child != NULL)
- subj = child->content;
+ body = wocky_xmpp_node_get_content_from_child (msg, "body");
+ subj = wocky_xmpp_node_get_content_from_child (msg, "subject");
/* ********************************************************************** */
/* parse timestap, if any */
diff --git a/wocky/wocky-xmpp-error.c b/wocky/wocky-xmpp-error.c
index ed968be..719d8f1 100644
--- a/wocky/wocky-xmpp-error.c
+++ b/wocky/wocky-xmpp-error.c
@@ -592,7 +592,6 @@ wocky_xmpp_stream_error_quark (void)
GError *
wocky_xmpp_stream_error_from_node (WockyXmppNode *error)
{
- WockyXmppNode *text;
gint code = WOCKY_XMPP_STREAM_ERROR_UNKNOWN;
const gchar *message = NULL;
@@ -600,10 +599,8 @@ wocky_xmpp_stream_error_from_node (WockyXmppNode *error)
xmpp_error_from_node_for_ns (error, WOCKY_XMPP_STREAM_ERROR,
WOCKY_TYPE_XMPP_STREAM_ERROR, &code);
- text = wocky_xmpp_node_get_child_ns (error, "text", WOCKY_XMPP_NS_STREAMS);
-
- if (text != NULL)
- message = text->content;
+ message = wocky_xmpp_node_get_content_from_child_ns (error, "text",
+ WOCKY_XMPP_NS_STREAMS);
if (message == NULL)
message = "";