cpw.gillux.detachablepurple: b056fb67: The object loading function now uses the...
gillux at soc.pidgin.im
gillux at soc.pidgin.im
Sun May 20 13:21:52 EDT 2012
----------------------------------------------------------------------
Revision: b056fb6709801b504b70976e5c476a56bdb13597
Parent: 612b79074de959b70a2e215ddc856dc10a79640f
Author: gillux at soc.pidgin.im
Date: 05/20/12 11:22:33
Branch: im.pidgin.cpw.gillux.detachablepurple
URL: http://d.pidgin.im/viewmtn/revision/info/b056fb6709801b504b70976e5c476a56bdb13597
Changelog:
The object loading function now uses the GType instead of the type name.
This way, we ensure the type initialization function has been called before
we try to instatiate a new object of this type. We can't get a GType from
a type name that havn't been registered.
Changes against parent 612b79074de959b70a2e215ddc856dc10a79640f
patched libpurple/dbus/constructor.c
-------------- next part --------------
============================================================
--- libpurple/dbus/constructor.c 683a2e01e722c9209f18b7cf136ebe17ea17a223
+++ libpurple/dbus/constructor.c 0c145ce9319a7ad9b79c6ff6ab6556cef4d630d9
@@ -136,13 +136,12 @@ purple_constructor_get_instance(void)
return klass->instance;
}
-/* Creates a new proxy gobject of type_name, initializing its properties with
- * what's in props.
+/* Creates a new proxy gobject of the given type, initializing its properties
+ * with what's in props.
*/
static gpointer
-purple_constructor_new_proxy_object(const gchar *type_name, GVariant *props)
+purple_constructor_new_proxy_object(GType type, GVariant *props)
{
- GType type;
GParameter *params;
guint n_params, i = 0;
GVariantIter iter;
@@ -153,9 +152,6 @@ purple_constructor_new_proxy_object(cons
GObjectClass *class;
GParamSpec *pspec;
- /* Retreive the type and its class. */
- type = g_type_from_name(type_name);
- g_return_val_if_fail(type != 0, NULL);
class = g_type_class_ref(type);
/* Parse the given properties and build the parmas array. */
@@ -170,7 +166,7 @@ purple_constructor_new_proxy_object(cons
purple_dbus_gvariant_to_gvalue(prop_value, ¶ms[i].value,
G_PARAM_SPEC_VALUE_TYPE(pspec));
else
- purple_debug_warning("dbus", "Ignored an unknown property named '%s' for object type '%s'.\n", prop_name, type_name);
+ purple_debug_warning("dbus", "Ignored an unknown property named '%s' for object type '%s'.\n", prop_name, g_type_name(type));
i++;
g_variant_unref(prop_value);
@@ -252,7 +248,7 @@ static gpointer
}
static gpointer
-load_pobject(GVariant *vpobject, const char *type_name)
+load_pobject(GVariant *vpobject, GType type)
{
PurpleObject *pobject;
gpointer *obj;
@@ -261,8 +257,7 @@ load_pobject(GVariant *vpobject, const c
g_variant_get(vpobject, "(o at a(sv))", &dbus_path, &props);
- obj = purple_constructor_new_proxy_object(type_name, props);
-
+ obj = purple_constructor_new_proxy_object(type, props);
pobject = PURPLE_OBJECT(obj);
purple_object_set_dbus_path(pobject, dbus_path);
/* Note: we are in remote mode so the 2nd parameter doesn't matter. */
@@ -275,7 +270,7 @@ static void
}
static void
-load_pobjects(GVariant *box, const char *type_name)
+load_pobjects(GVariant *box, GType type)
{
GVariantIter iter;
GVariant *array, *pobject;
@@ -285,7 +280,7 @@ load_pobjects(GVariant *box, const char
g_variant_iter_init(&iter, array);
while ((pobject = g_variant_iter_next_value(&iter)) != NULL) {
- obj = load_pobject(pobject, type_name);
+ obj = load_pobject(pobject, type);
purple_object_set_synchronized(PURPLE_OBJECT(obj), TRUE);
g_variant_unref(pobject);
}
@@ -315,7 +310,7 @@ static void
}
static void
-purple_constructor_load_all_pobj(const char *method, const char *type)
+purple_constructor_load_all_pobj(const char *method, GType type)
{
PurpleConstructor* con = purple_constructor_get_instance();
GVariant *ret;
@@ -332,7 +327,7 @@ purple_accounts_get_all_RPC(void)
void
purple_accounts_get_all_RPC(void)
{
- purple_constructor_load_all_pobj("GetAllAccounts", "PurpleAccount");
+ purple_constructor_load_all_pobj("GetAllAccounts", PURPLE_TYPE_ACCOUNT);
}
void
@@ -356,12 +351,15 @@ purple_constructor_pobj_created(PurpleCo
const gchar *type_name, const gchar *dbus_path,
GVariant *props)
{
+ GType type;
gpointer *obj;
/* If we are the one who created this object, we already have it. */
if (purple_dbus_get_gobject_by_path(dbus_path))
return;
+ type = g_type_from_name(type_name);
+ g_return_if_fail(type != 0);
obj = purple_constructor_new_proxy_object(type, props);
g_variant_unref(props);
More information about the Commits
mailing list