summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDanielle Madeley <danielle.madeley@collabora.co.uk>2010-02-18 15:38:07 +1100
committerDanielle Madeley <danielle.madeley@collabora.co.uk>2010-03-05 17:44:46 +1100
commita76bec681af40f1bb88073bd0aa8e2a7c1e0042c (patch)
treee9831f89ff89cef00d3625a5f89e174d9357d1d0
parent5d1ed6a2da3dd1dd7d0cc47dbe454e4dbbd285c2 (diff)
downloadtelepathy-logger-a76bec681af40f1bb88073bd0aa8e2a7c1e0042c.tar.gz
log-store: add common properties to the LogStore GInterface
Remove is_{readable,writable} from iface use properties instead
-rw-r--r--telepathy-logger/log-store-empathy.c94
-rw-r--r--telepathy-logger/log-store.c89
-rw-r--r--telepathy-logger/log-store.h3
3 files changed, 72 insertions, 114 deletions
diff --git a/telepathy-logger/log-store-empathy.c b/telepathy-logger/log-store-empathy.c
index e3893b3..0c0b89e 100644
--- a/telepathy-logger/log-store-empathy.c
+++ b/telepathy-logger/log-store-empathy.c
@@ -84,17 +84,11 @@ enum {
};
static void log_store_iface_init (gpointer g_iface, gpointer iface_data);
-static void tpl_log_store_get_property (GObject *object, guint param_id, GValue *value,
- GParamSpec *pspec);
-static void tpl_log_store_set_property (GObject *object, guint param_id, const GValue *value,
- GParamSpec *pspec);
static const gchar *log_store_empathy_get_name (TplLogStore *self);
static void log_store_empathy_set_name (TplLogStore *self, const gchar *data);
static const gchar *log_store_empathy_get_basedir (TplLogStore *self);
static void log_store_empathy_set_basedir (TplLogStore *self,
const gchar *data);
-static gboolean log_store_empathy_is_writable (TplLogStore *self);
-static gboolean log_store_empathy_is_readable (TplLogStore *self);
static void log_store_empathy_set_writable (TplLogStore *self, gboolean data);
static void log_store_empathy_set_readable (TplLogStore *self, gboolean data);
@@ -104,7 +98,7 @@ G_DEFINE_TYPE_WITH_CODE (TplLogStoreEmpathy, tpl_log_store_empathy,
G_IMPLEMENT_INTERFACE (TPL_TYPE_LOG_STORE, log_store_iface_init))
static void
-log_store_empathy_dispose (GObject *object)
+tpl_log_store_empathy_dispose (GObject *object)
{
TplLogStoreEmpathy *self = TPL_LOG_STORE_EMPATHY (object);
TplLogStoreEmpathyPriv *priv = GET_PRIV (self);
@@ -124,7 +118,7 @@ log_store_empathy_dispose (GObject *object)
static void
-log_store_empathy_finalize (GObject *object)
+tpl_log_store_empathy_finalize (GObject *object)
{
TplLogStoreEmpathy *self = TPL_LOG_STORE_EMPATHY (object);
TplLogStoreEmpathyPriv *priv = GET_PRIV (self);
@@ -143,7 +137,7 @@ log_store_empathy_finalize (GObject *object)
static void
-tpl_log_store_get_property (GObject *object,
+tpl_log_store_empathy_get_property (GObject *object,
guint param_id,
GValue *value,
GParamSpec *pspec)
@@ -172,7 +166,7 @@ tpl_log_store_get_property (GObject *object,
static void
-tpl_log_store_set_property (GObject *object,
+tpl_log_store_empathy_set_property (GObject *object,
guint param_id,
const GValue *value,
GParamSpec *pspec)
@@ -206,24 +200,14 @@ tpl_log_store_empathy_class_init (TplLogStoreEmpathyClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GParamSpec *param_spec;
- object_class->finalize = log_store_empathy_finalize;
- object_class->dispose = log_store_empathy_dispose;
- object_class->get_property = tpl_log_store_get_property;
- object_class->set_property = tpl_log_store_set_property;
+ object_class->finalize = tpl_log_store_empathy_finalize;
+ object_class->dispose = tpl_log_store_empathy_dispose;
+ object_class->get_property = tpl_log_store_empathy_get_property;
+ object_class->set_property = tpl_log_store_empathy_set_property;
- /**
- * TplLogStoreEmpathy:name:
- *
- * The log store's name. No default available, it has to be passed at object
- * creation.
- * As defined in #TplLogStore.
- */
- param_spec = g_param_spec_string ("name",
- "Name",
- "The TplLogStore implementation's name",
- NULL, G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS);
- g_object_class_install_property (object_class, PROP_NAME, param_spec);
+ 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");
/* the default value for the basedir prop is composed by user_data_dir () +
* prop "name" value, it's not possible to know it at param_spec time, so
@@ -243,39 +227,6 @@ tpl_log_store_empathy_class_init (TplLogStoreEmpathyClass *klass)
G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_BASEDIR, param_spec);
- /**
- * TplLogStoreEmpathy:readable:
- *
- * Wether the log store is readable.
- * Default: %TRUE
- *
- * As defined in #TplLogStore.
- */
- param_spec = g_param_spec_boolean ("readable",
- "Readable",
- "Defines wether the LogStore is readable or not, allowing searching "
- "into this instance",
- TRUE, G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS);
- g_object_class_install_property (object_class, PROP_READABLE, param_spec);
-
- /**
- * TplLogStoreEmpathy:writable:
- *
- * Wether the log store is writable.
- * Default: %FALSE.
- * Setting a LogStore to %TRUE might result in duplicate entries among logs.
- *
- * As defined in #TplLogStore.
- */
- param_spec = g_param_spec_boolean ("writable",
- "Writable",
- "Defines wether the LogStore is writable or not, allowing message "
- "to be stored into this instance",
- FALSE, G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
- G_PARAM_STATIC_STRINGS);
- g_object_class_install_property (object_class, PROP_WRITABLE, param_spec);
-
g_type_class_add_private (object_class, sizeof (TplLogStoreEmpathyPriv));
}
@@ -1152,27 +1103,6 @@ log_store_empathy_get_basedir (TplLogStore *self)
}
-static gboolean
-log_store_empathy_is_readable (TplLogStore *self)
-{
- TplLogStoreEmpathyPriv *priv = GET_PRIV (self);
-
- g_return_val_if_fail (TPL_IS_LOG_STORE_EMPATHY (self), FALSE);
-
- return priv->readable;
-}
-
-
-static gboolean
-log_store_empathy_is_writable (TplLogStore *self)
-{
- TplLogStoreEmpathyPriv *priv = GET_PRIV (self);
-
- g_return_val_if_fail (TPL_IS_LOG_STORE_EMPATHY (self), FALSE);
-
- return priv->writable;
-}
-
static void
log_store_empathy_set_name (TplLogStore *self,
const gchar *data)
@@ -1291,6 +1221,4 @@ log_store_iface_init (gpointer g_iface,
log_store_empathy_search_in_identifier_chats_new;
iface->search_new = log_store_empathy_search_new;
iface->get_filtered_messages = log_store_empathy_get_filtered_messages;
- iface->is_writable = log_store_empathy_is_writable;
- iface->is_readable = log_store_empathy_is_readable;
}
diff --git a/telepathy-logger/log-store.c b/telepathy-logger/log-store.c
index 31e1aec..7e2f3c0 100644
--- a/telepathy-logger/log-store.c
+++ b/telepathy-logger/log-store.c
@@ -38,27 +38,7 @@
* implement in order to be used into a #TplLogManager.
*/
-/**
- * TplLogStore:writable:
- *
- * Defines wether the object is writable for a #TplLogManager.
- *
- * If an TplLogStore implementation is writable, the #TplLogManager will call
- * it's tpl_log_store_add_message() method every time a loggable even occurs,
- * i.e., everytime tpl_log_manager_add_message() is called.
- */
-
-/**
- * TplLogStore:readable:
- *
- * Defines wether the object is readable for a #TplLogManager.
- *
- * If an TplLogStore implementation is readable, the #TplLogManager will
- * use the query methods against the instance (i.e., tpl_log_store_get_dates())
- * every time a #TplLogManager instance is queried (i.e.,
- * tpl_log_manager_get_date()).
- */
-
+static void tpl_log_store_init (gpointer g_iface);
GType
tpl_log_store_get_type (void)
@@ -70,7 +50,7 @@ tpl_log_store_get_type (void)
sizeof (TplLogStoreInterface),
NULL, /* base_init */
NULL, /* base_finalize */
- NULL, /* class_init */
+ (GClassInitFunc) tpl_log_store_init, /* class_init */
NULL, /* class_finalize */
NULL, /* class_data */
0,
@@ -83,6 +63,49 @@ tpl_log_store_get_type (void)
return type;
}
+static void
+tpl_log_store_init (gpointer g_iface)
+{
+ g_object_interface_install_property (g_iface,
+ g_param_spec_string ("name",
+ "Name",
+ "The TplLogStore implementation's name",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
+
+ /**
+ * TplLogStore:writable:
+ *
+ * Defines wether the object is writable for a #TplLogManager.
+ *
+ * If an TplLogStore implementation is writable, the #TplLogManager will call
+ * it's tpl_log_store_add_message() method every time a loggable even occurs,
+ * i.e., everytime tpl_log_manager_add_message() is called.
+ */
+ g_object_interface_install_property (g_iface,
+ g_param_spec_boolean ("readable",
+ "Readable",
+ "Whether this log store is readable",
+ TRUE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
+
+ /**
+ * TplLogStore:readable:
+ *
+ * Defines wether the object is readable for a #TplLogManager.
+ *
+ * If an TplLogStore implementation is readable, the #TplLogManager will
+ * use the query methods against the instance (i.e. tpl_log_store_get_dates())
+ * every time a #TplLogManager instance is queried (i.e.,
+ * tpl_log_manager_get_date()).
+ */
+ g_object_interface_install_property (g_iface,
+ g_param_spec_boolean ("writable",
+ "Writable",
+ "Whether this log store is writable",
+ TRUE,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
+}
const gchar *
tpl_log_store_get_name (TplLogStore *self)
@@ -319,18 +342,28 @@ tpl_log_store_get_filtered_messages (TplLogStore *self,
gboolean
tpl_log_store_is_writable (TplLogStore *self)
{
- if (!TPL_LOG_STORE_GET_INTERFACE (self)->is_writable)
- return FALSE;
+ gboolean writable;
+
+ g_return_val_if_fail (TPL_IS_LOG_STORE (self), FALSE);
- return TPL_LOG_STORE_GET_INTERFACE (self)->is_writable (self);
+ g_object_get (self,
+ "writable", &writable,
+ NULL);
+
+ return writable;
}
gboolean
tpl_log_store_is_readable (TplLogStore *self)
{
- if (!TPL_LOG_STORE_GET_INTERFACE (self)->is_readable)
- return FALSE;
+ gboolean readable;
+
+ g_return_val_if_fail (TPL_IS_LOG_STORE (self), FALSE);
+
+ g_object_get (self,
+ "writable", &readable,
+ NULL);
- return TPL_LOG_STORE_GET_INTERFACE (self)->is_readable (self);
+ return readable;
}
diff --git a/telepathy-logger/log-store.h b/telepathy-logger/log-store.h
index 971f7cb..f52e775 100644
--- a/telepathy-logger/log-store.h
+++ b/telepathy-logger/log-store.h
@@ -57,9 +57,6 @@ typedef struct
{
GTypeInterface parent;
- gboolean (*is_writable) (TplLogStore *self);
- gboolean (*is_readable) (TplLogStore *self);
-
const gchar * (*get_name) (TplLogStore *self);
gboolean (*exists) (TplLogStore *self, TpAccount *account,
const gchar *chat_id, gboolean chatroom);