[Galago-commits] r2323 - in trunk/libgalago: . libgalago
galago-commits at freedesktop.org
galago-commits at freedesktop.org
Sat Nov 19 15:42:33 PST 2005
Author: chipx86
Date: 2005-11-19 15:42:30 -0800 (Sat, 19 Nov 2005)
New Revision: 2323
Modified:
trunk/libgalago/ChangeLog
trunk/libgalago/libgalago/galago-account.c
trunk/libgalago/libgalago/galago-image.c
trunk/libgalago/libgalago/galago-object.c
trunk/libgalago/libgalago/galago-object.h
trunk/libgalago/libgalago/galago-person.c
trunk/libgalago/libgalago/galago-service.c
Log:
Redo object signature retrieval. We don't really want to operate on a per-object basis, so now we're per-type basis. galago_object_get_dbus_signature() has been renamed to galago_object_type_get_dbus_signature(). It no longer requires the returned string to be freed, as it caches it.
Modified: trunk/libgalago/ChangeLog
===================================================================
--- trunk/libgalago/ChangeLog 2005-11-19 23:13:34 UTC (rev 2322)
+++ trunk/libgalago/ChangeLog 2005-11-19 23:42:30 UTC (rev 2323)
@@ -1,3 +1,17 @@
+Sat Nov 19 15:41:18 PST 2005 Christian Hammond <chipx86 at chipx86.com>
+
+ * libgalago/galago-account.c:
+ * libgalago/galago-image.c:
+ * libgalago/galago-object.c:
+ * libgalago/galago-object.h:
+ * libgalago/galago-person.c:
+ * libgalago/galago-service.c:
+ - Redo object signature retrieval. We don't really want to operate on a
+ per-object basis, so now we're per-type basis.
+ galago_object_get_dbus_signature() has been renamed to
+ galago_object_type_get_dbus_signature(). It no longer requires the
+ returned string to be freed, as it caches it.
+
Sat Nov 19 15:13:16 PST 2005 Christian Hammond <chipx86 at chipx86.com>
* libgalago/galago-person.c:
Modified: trunk/libgalago/libgalago/galago-account.c
===================================================================
--- trunk/libgalago/libgalago/galago-account.c 2005-11-19 23:13:34 UTC (rev 2322)
+++ trunk/libgalago/libgalago/galago-account.c 2005-11-19 23:42:30 UTC (rev 2323)
@@ -79,7 +79,7 @@
const GalagoObject *object);
static void *galago_account_dbus_message_get(DBusMessageIter *iter);
static void galago_account_dbus_push_full(GalagoObject *object);
-static gchar *galago_account_dbus_get_signature(const GalagoObject *object);
+static gchar *galago_account_dbus_get_signature(void);
static void galago_account_set_property(GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec);
static void galago_account_get_property(GObject *object, guint prop_id,
@@ -353,17 +353,14 @@
}
static gchar *
-galago_account_dbus_get_signature(const GalagoObject *object)
+galago_account_dbus_get_signature(void)
{
- GalagoAccount *account = GALAGO_ACCOUNT(object);
- GalagoService *service = galago_account_get_service(account);
- GalagoPerson *person = galago_account_get_person(account);
- gchar *service_sig;
- gchar *person_sig;
+ const gchar *service_sig;
+ const gchar *person_sig;
gchar *sig;
- service_sig = galago_object_get_dbus_signature(GALAGO_OBJECT(service));
- person_sig = galago_object_get_dbus_signature(GALAGO_OBJECT(person));
+ service_sig = galago_object_type_get_dbus_signature(GALAGO_TYPE_SERVICE);
+ person_sig = galago_object_type_get_dbus_signature(GALAGO_TYPE_PERSON);
sig = g_strconcat(service_sig, // service,
person_sig, // person,
@@ -372,9 +369,6 @@
DBUS_TYPE_BOOLEAN_AS_STRING, // connected
NULL);
- g_free(service_sig);
- g_free(person_sig);
-
return sig;
}
Modified: trunk/libgalago/libgalago/galago-image.c
===================================================================
--- trunk/libgalago/libgalago/galago-image.c 2005-11-19 23:13:34 UTC (rev 2322)
+++ trunk/libgalago/libgalago/galago-image.c 2005-11-19 23:42:30 UTC (rev 2323)
@@ -39,7 +39,7 @@
static void galago_image_dbus_message_append(DBusMessageIter *iter,
const GalagoObject *object);
static void *galago_image_dbus_message_get(DBusMessageIter *iter);
-static gchar *galago_image_dbus_get_signature(const GalagoObject *object);
+static gchar *galago_image_dbus_get_signature(void);
static GalagoObjectClass *parent_class = NULL;
@@ -128,7 +128,7 @@
}
gchar *
-galago_image_dbus_get_signature(const GalagoObject *object)
+galago_image_dbus_get_signature(void)
{
return g_strdup(DBUS_TYPE_ARRAY_AS_STRING
DBUS_TYPE_BYTE_AS_STRING);
Modified: trunk/libgalago/libgalago/galago-object.c
===================================================================
--- trunk/libgalago/libgalago/galago-object.c 2005-11-19 23:13:34 UTC (rev 2322)
+++ trunk/libgalago/libgalago/galago-object.c 2005-11-19 23:42:30 UTC (rev 2323)
@@ -30,14 +30,14 @@
struct _GalagoObjectPrivate
{
GalagoContext *context;
- char *dbus_path;
+ gchar *dbus_path;
GalagoOrigin origin;
gboolean watched : 1;
};
struct _GalagoObjectClassPrivate
{
- char *dbus_iface;
+ gchar *dbus_signature;
};
enum
@@ -73,6 +73,8 @@
parent_class = g_type_class_peek_parent(klass);
+ klass->priv = g_new0(GalagoObjectClassPrivate, 1);
+
klass->dbus_message_append = NULL;
klass->dbus_message_get = NULL;
klass->dbus_push_full = NULL;
@@ -190,6 +192,37 @@
}
}
+const gchar *
+galago_object_type_get_dbus_signature(GType type)
+{
+ GalagoObjectClass *klass;
+
+ g_return_val_if_fail(g_type_is_a(type, GALAGO_TYPE_OBJECT), NULL);
+
+ klass = g_type_class_ref(type);
+
+ if (klass->dbus_get_signature != NULL)
+ {
+ g_type_class_unref(klass);
+ return NULL;
+ }
+
+ if (klass->priv->dbus_signature == NULL)
+ {
+ char *sig = klass->dbus_get_signature();
+ klass->priv->dbus_signature =
+ g_strconcat(DBUS_STRUCT_BEGIN_CHAR_AS_STRING,
+ sig,
+ DBUS_STRUCT_END_CHAR_AS_STRING,
+ NULL);
+ g_free(sig);
+ }
+
+ g_type_class_unref(klass);
+
+ return klass->priv->dbus_signature;
+}
+
void
galago_object_set_dbus_path(GalagoObject *object, const gchar *obj_path)
{
@@ -220,30 +253,6 @@
return object->priv->dbus_path;
}
-gchar *
-galago_object_get_dbus_signature(const GalagoObject *object)
-{
- GalagoObjectClass *klass;
- gchar *obj_sig;
- gchar *sig;
-
- g_return_val_if_fail(object != NULL && GALAGO_IS_OBJECT(object), NULL);
-
- klass = GALAGO_OBJECT_GET_CLASS(object);
-
- if (klass->dbus_get_signature == NULL)
- return NULL;
-
- obj_sig = klass->dbus_get_signature(object);
- sig = g_strconcat(DBUS_STRUCT_BEGIN_CHAR_AS_STRING,
- obj_sig,
- DBUS_STRUCT_END_CHAR_AS_STRING,
- NULL);
- g_free(obj_sig);
-
- return sig;
-}
-
void
galago_object_set_watch(GalagoObject *object, gboolean watch)
{
Modified: trunk/libgalago/libgalago/galago-object.h
===================================================================
--- trunk/libgalago/libgalago/galago-object.h 2005-11-19 23:13:34 UTC (rev 2322)
+++ trunk/libgalago/libgalago/galago-object.h 2005-11-19 23:42:30 UTC (rev 2323)
@@ -64,7 +64,7 @@
const GalagoObject *object);
void *(*dbus_message_get)(DBusMessageIter *iter);
void (*dbus_push_full)(GalagoObject *object);
- gchar *(*dbus_get_signature)(const GalagoObject *object);
+ gchar *(*dbus_get_signature)(void);
/* Signals */
void (*destroy)(GalagoObject *object);
@@ -145,6 +145,15 @@
GType galago_object_get_type(void);
/**
+ * Returns the D-BUS signature of the object type.
+ *
+ * @param class The object type.
+ *
+ * @return The signature string, or NULL.
+ */
+const gchar *galago_object_type_get_dbus_signature(GType type);
+
+/**
* Sets the D-BUS object path of an object.
*
* @param object The object.
@@ -162,17 +171,6 @@
const gchar *galago_object_get_dbus_path(const GalagoObject *object);
/**
- * Returns the D-BUS signature of the object.
- *
- * The returned string must be freed.
- *
- * @param object The object.
- *
- * @return The signature string, or NULL. This must be freed.
- */
-gchar *galago_object_get_dbus_signature(const GalagoObject *object);
-
-/**
* Sets whether or not this object is watched for events.
*
* @param object The object.
Modified: trunk/libgalago/libgalago/galago-person.c
===================================================================
--- trunk/libgalago/libgalago/galago-person.c 2005-11-19 23:13:34 UTC (rev 2322)
+++ trunk/libgalago/libgalago/galago-person.c 2005-11-19 23:42:30 UTC (rev 2323)
@@ -82,7 +82,7 @@
const GalagoObject *object);
static void *galago_person_dbus_message_get(DBusMessageIter *iter);
static void galago_person_dbus_push_full(GalagoObject *object);
-static gchar *galago_person_dbus_get_signature(const GalagoObject *object);
+static gchar *galago_person_dbus_get_signature(void);
static void galago_person_set_gproperty(GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec);
static void galago_person_get_gproperty(GObject *object, guint prop_id,
@@ -289,7 +289,7 @@
}
static gchar *
-galago_person_dbus_get_signature(const GalagoObject *object)
+galago_person_dbus_get_signature(void)
{
return g_strdup(DBUS_TYPE_STRING_AS_STRING // obj path
DBUS_TYPE_STRING_AS_STRING // id
Modified: trunk/libgalago/libgalago/galago-service.c
===================================================================
--- trunk/libgalago/libgalago/galago-service.c 2005-11-19 23:13:34 UTC (rev 2322)
+++ trunk/libgalago/libgalago/galago-service.c 2005-11-19 23:42:30 UTC (rev 2323)
@@ -71,7 +71,7 @@
const GalagoObject *object);
static void *galago_service_dbus_message_get(DBusMessageIter *iter);
static void galago_service_dbus_push_full(GalagoObject *object);
-static gchar *galago_service_dbus_get_signature(const GalagoObject *object);
+static gchar *galago_service_dbus_get_signature(void);
static void galago_service_set_property(GObject *object, guint prop_id,
const GValue *value, GParamSpec *pspec);
static void galago_service_get_property(GObject *object, guint prop_id,
@@ -252,7 +252,7 @@
}
static gchar *
-galago_service_dbus_get_signature(const GalagoObject *object)
+galago_service_dbus_get_signature(void)
{
return g_strdup(DBUS_TYPE_STRING_AS_STRING // object path
DBUS_TYPE_STRING_AS_STRING // id
More information about the galago-commits
mailing list