summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <simon.mcvittie@collabora.co.uk>2013-10-28 12:53:10 +0000
committerSimon McVittie <simon.mcvittie@collabora.co.uk>2013-11-11 16:48:57 +0000
commit5db97e2ccc40795502202f404fc5a0c4cab0cb5f (patch)
tree9c64ea9fc49448723bf654d7a0b3ef52071bd2fc
parent45d958eeff097e1df862cbbbb760bf5831201642 (diff)
downloadtelepathy-glib-5db97e2ccc40795502202f404fc5a0c4cab0cb5f.tar.gz
TpProtocol: parse_default_value: take raw value as a parameter
We previously passed the value when parsed as a string, but that makes very little sense. The raw value is at least used for something by the function itself, and it's better for debug messages too. Bug: https://bugs.freedesktop.org/show_bug.cgi?id=71048 Reviewed-by: Guillaume Desmottes <guillaume.desmottes@collabora.co.uk>
-rw-r--r--telepathy-glib/protocol.c19
1 files changed, 8 insertions, 11 deletions
diff --git a/telepathy-glib/protocol.c b/telepathy-glib/protocol.c
index b2935c042..caf78ceb8 100644
--- a/telepathy-glib/protocol.c
+++ b/telepathy-glib/protocol.c
@@ -1221,7 +1221,7 @@ init_gvalue_from_dbus_sig (const gchar *sig,
static gboolean
parse_default_value (GValue *value,
const gchar *sig,
- gchar *string,
+ gchar *raw_value,
GKeyFile *file,
const gchar *group,
const gchar *key)
@@ -1244,31 +1244,28 @@ parse_default_value (GValue *value,
* So, on error, let's fall back to more lenient parsing that explicitly
* allows everything we historically allowed. */
g_error_free (error);
- s = g_key_file_get_value (file, group, key, NULL);
- if (s == NULL)
+ if (raw_value == NULL)
return FALSE;
- for (p = s; *p != '\0'; p++)
+ for (p = raw_value; *p != '\0'; p++)
{
*p = g_ascii_tolower (*p);
}
- if (!tp_strdiff (s, "1") || !tp_strdiff (s, "true"))
+ if (!tp_strdiff (raw_value, "1") || !tp_strdiff (raw_value, "true"))
{
g_value_set_boolean (value, TRUE);
}
- else if (!tp_strdiff (s, "0") || !tp_strdiff (s, "false"))
+ else if (!tp_strdiff (raw_value, "0") || !tp_strdiff (raw_value, "false"))
{
g_value_set_boolean (value, TRUE);
}
else
{
- g_free (s);
return FALSE;
}
- g_free (s);
return TRUE;
case 's':
@@ -1317,7 +1314,7 @@ parse_default_value (GValue *value,
case 'n':
case 'i':
case 'x':
- if (string[0] == '\0')
+ if (raw_value[0] == '\0')
{
return FALSE;
}
@@ -1464,7 +1461,7 @@ _tp_protocol_parse_channel_class (GKeyFile *file,
const gchar *dbus_type;
GValue *v = g_slice_new0 (GValue);
- value = g_key_file_get_string (file, group, *key, NULL);
+ value = g_key_file_get_value (file, group, *key, NULL);
/* keys without a space are reserved */
if (space == NULL)
@@ -1607,7 +1604,7 @@ _tp_protocol_parse_manager_file (GKeyFile *file,
}
def = g_strdup_printf ("default-%s", param.name);
- value = g_key_file_get_string (file, group, def, NULL);
+ value = g_key_file_get_value (file, group, def, NULL);
init_gvalue_from_dbus_sig (param.dbus_signature,
&param.default_value);