[next] telepathy-glib: log-store: add 'writable' property
Simon McVittie
smcv at kemper.freedesktop.org
Thu Mar 20 10:25:43 PDT 2014
Module: telepathy-glib
Branch: next
Commit: ad9df58583955455aa4457966f4bff2c16017585
URL: http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=ad9df58583955455aa4457966f4bff2c16017585
Author: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
Date: Mon Jan 13 18:35:16 2014 +0100
log-store: add 'writable' property
This makes the API more symetric as we already had a 'readable' property and
will allow us to easily instantiate read-only stores.
---
telepathy-logger/log-store-pidgin.c | 9 +++++++++
telepathy-logger/log-store-sqlite.c | 6 ++++++
telepathy-logger/log-store-xml.c | 5 +++++
telepathy-logger/log-store.c | 32 ++++++++++++++++++++++++++++++--
4 files changed, 50 insertions(+), 2 deletions(-)
diff --git a/telepathy-logger/log-store-pidgin.c b/telepathy-logger/log-store-pidgin.c
index 5a37fa9..f6fabe0 100644
--- a/telepathy-logger/log-store-pidgin.c
+++ b/telepathy-logger/log-store-pidgin.c
@@ -56,6 +56,7 @@ enum {
PROP_0,
PROP_NAME,
PROP_READABLE,
+ PROP_WRITABLE,
};
@@ -90,6 +91,9 @@ tpl_log_store_pidgin_get_property (GObject *object,
case PROP_READABLE:
g_value_set_boolean (value, TRUE);
break;
+ case PROP_WRITABLE:
+ g_value_set_boolean (value, FALSE);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@@ -110,6 +114,10 @@ tpl_log_store_pidgin_set_property (GObject *object,
case PROP_NAME:
self->priv->name = g_value_dup_string (value);
break;
+ case PROP_WRITABLE:
+ /* we don't support writing to Pidgin logs atm */
+ g_return_if_fail (!g_value_get_boolean (value));
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@@ -150,6 +158,7 @@ tpl_log_store_pidgin_class_init (TplLogStorePidginClass *klass)
g_object_class_override_property (object_class, PROP_NAME, "name");
g_object_class_override_property (object_class, PROP_READABLE, "readable");
+ g_object_class_override_property (object_class, PROP_WRITABLE, "writable");
g_type_class_add_private (object_class, sizeof (TplLogStorePidginPriv));
}
diff --git a/telepathy-logger/log-store-sqlite.c b/telepathy-logger/log-store-sqlite.c
index ace554f..26d1ac2 100644
--- a/telepathy-logger/log-store-sqlite.c
+++ b/telepathy-logger/log-store-sqlite.c
@@ -52,6 +52,7 @@ enum /* properties */
PROP_0,
PROP_NAME,
PROP_READABLE,
+ PROP_WRITABLE,
};
struct _TplLogStoreSqlitePrivate
@@ -116,6 +117,10 @@ tpl_log_store_sqlite_get_property (GObject *self,
g_value_set_boolean (value, FALSE);
break;
+ case PROP_WRITABLE:
+ g_value_set_boolean (value, TRUE);
+ break;
+
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (self, id, pspec);
break;
@@ -324,6 +329,7 @@ _tpl_log_store_sqlite_class_init (TplLogStoreSqliteClass *klass)
g_object_class_override_property (gobject_class, PROP_NAME, "name");
g_object_class_override_property (gobject_class, PROP_READABLE, "readable");
+ g_object_class_override_property (gobject_class, PROP_WRITABLE, "writable");
g_type_class_add_private (gobject_class, sizeof (TplLogStoreSqlitePrivate));
}
diff --git a/telepathy-logger/log-store-xml.c b/telepathy-logger/log-store-xml.c
index 3a05dad..11edc03 100644
--- a/telepathy-logger/log-store-xml.c
+++ b/telepathy-logger/log-store-xml.c
@@ -88,6 +88,7 @@ enum {
PROP_0,
PROP_NAME,
PROP_READABLE,
+ PROP_WRITABLE,
};
static void log_store_iface_init (gpointer g_iface, gpointer iface_data);
@@ -159,6 +160,9 @@ tpl_log_store_xml_get_property (GObject *object,
case PROP_READABLE:
g_value_set_boolean (value, TRUE);
break;
+ case PROP_WRITABLE:
+ g_value_set_boolean (value, TRUE);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@@ -198,6 +202,7 @@ _tpl_log_store_xml_class_init (TplLogStoreXmlClass *klass)
g_object_class_override_property (object_class, PROP_NAME, "name");
g_object_class_override_property (object_class, PROP_READABLE, "readable");
+ g_object_class_override_property (object_class, PROP_WRITABLE, "writable");
g_type_class_add_private (object_class, sizeof (TplLogStoreXmlPriv));
}
diff --git a/telepathy-logger/log-store.c b/telepathy-logger/log-store.c
index 48952ec..fbf0255 100644
--- a/telepathy-logger/log-store.c
+++ b/telepathy-logger/log-store.c
@@ -95,6 +95,22 @@ _tpl_log_store_init (gpointer g_iface)
"Whether this log store is readable",
TRUE,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+
+ /**
+ * TplLogStore:writable:
+ *
+ * Defines whether the object is writable for a #TplLogManager.
+ *
+ * If an TplLogStore implementation is writable, the #TplLogManager will
+ * use the _tpl_log_store_add_event method against the instance
+ * every time a event needs to be logged.
+ */
+ g_object_interface_install_property (g_iface,
+ g_param_spec_boolean ("writable",
+ "Writable",
+ "Whether this log store is writable",
+ FALSE,
+ G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
}
gchar *
@@ -371,11 +387,23 @@ _tpl_log_store_create_iter (TplLogStore *self,
gboolean
_tpl_log_store_is_writable (TplLogStore *self)
{
+ gboolean writable;
+
g_return_val_if_fail (TPL_IS_LOG_STORE (self), FALSE);
- return (TPL_LOG_STORE_GET_INTERFACE (self)->add_event != NULL);
-}
+ g_object_get (self,
+ "writable", &writable,
+ NULL);
+ if (!writable)
+ return FALSE;
+
+ /* If the store claims to be writable it MUST implement add_event */
+ g_return_val_if_fail (TPL_LOG_STORE_GET_INTERFACE (self)->add_event != NULL,
+ FALSE);
+
+ return TRUE;
+}
gboolean
_tpl_log_store_is_readable (TplLogStore *self)
More information about the telepathy-commits
mailing list