[Telepathy-commits] [telepathy-glib/master] base-connection-manager: add support for more CM parameter types
Simon McVittie
simon.mcvittie at collabora.co.uk
Wed Mar 25 08:48:19 PDT 2009
---
telepathy-glib/base-connection-manager.c | 66 ++++++++++++++++++++++++++++++
1 files changed, 66 insertions(+), 0 deletions(-)
diff --git a/telepathy-glib/base-connection-manager.c b/telepathy-glib/base-connection-manager.c
index eac29ab..b2b798e 100644
--- a/telepathy-glib/base-connection-manager.c
+++ b/telepathy-glib/base-connection-manager.c
@@ -368,20 +368,62 @@ param_default_value (const TpCMParamSpec *param)
else
g_value_set_static_string (value, param->def);
break;
+
case DBUS_TYPE_INT16:
case DBUS_TYPE_INT32:
g_assert (param->gtype == G_TYPE_INT);
g_value_set_int (value, GPOINTER_TO_INT (param->def));
break;
+
case DBUS_TYPE_UINT16:
case DBUS_TYPE_UINT32:
g_assert (param->gtype == G_TYPE_UINT);
g_value_set_uint (value, GPOINTER_TO_UINT (param->def));
break;
+
+ case DBUS_TYPE_UINT64:
+ g_assert (param->gtype == G_TYPE_UINT64);
+ g_value_set_uint64 (value, param->def == NULL ? 0
+ : *(const guint64 *) param->def);
+ break;
+
+ case DBUS_TYPE_INT64:
+ g_assert (param->gtype == G_TYPE_INT64);
+ g_value_set_int64 (value, param->def == NULL ? 0
+ : *(const gint64 *) param->def);
+ break;
+
+ case DBUS_TYPE_DOUBLE:
+ g_assert (param->gtype == G_TYPE_DOUBLE);
+ g_value_set_double (value, param->def == NULL ? 0.0
+ : *(const double *) param->def);
+ break;
+
+ case DBUS_TYPE_OBJECT_PATH:
+ g_assert (param->gtype == DBUS_TYPE_G_OBJECT_PATH);
+ g_value_set_static_boxed (value, param->def == NULL ? "/"
+ : param->def);
+ break;
+
+ case DBUS_TYPE_ARRAY:
+ switch (param->dtype[1])
+ {
+ case DBUS_TYPE_STRING:
+ g_assert (param->gtype == G_TYPE_STRV);
+ g_value_set_static_boxed (value, param->def);
+ break;
+
+ default:
+ g_error ("parameter_defaults: encountered unknown type %s on "
+ "argument %s", param->dtype, param->name);
+ }
+ break;
+
case DBUS_TYPE_BOOLEAN:
g_assert (param->gtype == G_TYPE_BOOLEAN);
g_value_set_boolean (value, GPOINTER_TO_INT (param->def));
break;
+
default:
g_error ("parameter_defaults: encountered unknown type %s on "
"argument %s", param->dtype, param->name);
@@ -446,6 +488,7 @@ tp_cm_param_setter_offset (const TpCMParamSpec *paramspec,
}
}
break;
+
case DBUS_TYPE_INT16:
case DBUS_TYPE_INT32:
{
@@ -457,6 +500,7 @@ tp_cm_param_setter_offset (const TpCMParamSpec *paramspec,
DEBUG ("%s = %d = 0x%x", paramspec->name, i, i);
}
break;
+
case DBUS_TYPE_UINT16:
case DBUS_TYPE_UINT32:
{
@@ -468,6 +512,7 @@ tp_cm_param_setter_offset (const TpCMParamSpec *paramspec,
DEBUG ("%s = %u = 0x%x", paramspec->name, i, i);
}
break;
+
case DBUS_TYPE_BOOLEAN:
{
gboolean *save_to = (gboolean *) (params_mem + paramspec->offset);
@@ -479,9 +524,28 @@ tp_cm_param_setter_offset (const TpCMParamSpec *paramspec,
DEBUG ("%s = %s", paramspec->name, b ? "TRUE" : "FALSE");
}
break;
+
case DBUS_TYPE_ARRAY:
switch (paramspec->dtype[1])
{
+ case DBUS_TYPE_STRING:
+ {
+ GStrv *save_to = (GStrv *) (params_mem + paramspec->offset);
+ GStrv strv = g_value_get_boxed (value);
+
+ g_strfreev (*save_to);
+ *save_to = g_strdupv (strv);
+
+ if (DEBUGGING)
+ {
+ gchar *joined = g_strjoinv (", ", strv);
+
+ DEBUG ("%s = [%s]", paramspec->name, joined);
+ g_free (joined);
+ }
+ }
+ break;
+
case DBUS_TYPE_BYTE:
{
GArray **save_to = (GArray **) (params_mem + paramspec->offset);
@@ -496,6 +560,7 @@ tp_cm_param_setter_offset (const TpCMParamSpec *paramspec,
DEBUG ("%s = ...[%u]", paramspec->name, a->len);
}
break;
+
default:
g_error ("%s: encountered unhandled D-Bus array type %s on "
"argument %s", G_STRFUNC, paramspec->dtype,
@@ -503,6 +568,7 @@ tp_cm_param_setter_offset (const TpCMParamSpec *paramspec,
g_assert_not_reached ();
}
break;
+
default:
g_error ("%s: encountered unhandled D-Bus type %s on argument %s",
G_STRFUNC, paramspec->dtype, paramspec->name);
--
1.5.6.5
More information about the telepathy-commits
mailing list