[next] telepathy-glib: implement the empathy store using the XML store directly
Simon McVittie
smcv at kemper.freedesktop.org
Thu Mar 20 10:25:43 PDT 2014
Module: telepathy-glib
Branch: next
Commit: e4e3555e97927655544880978bcb3dbacc735cf9
URL: http://cgit.freedesktop.org/telepathy/telepathy-glib/commit/?id=e4e3555e97927655544880978bcb3dbacc735cf9
Author: Guillaume Desmottes <guillaume.desmottes at collabora.co.uk>
Date: Mon Jan 13 18:54:23 2014 +0100
implement the empathy store using the XML store directly
The XML and Empathy stores were exactly the same but their name and the
Empathy one being read-only. It's much cleaner to have one store class per
storage format and tweak its settings using properties.
---
telepathy-logger/Makefile.am | 2 -
telepathy-logger/log-manager.c | 1 -
telepathy-logger/log-store-empathy-internal.h | 56 ----------------------
telepathy-logger/log-store-empathy.c | 62 -------------------------
telepathy-logger/log-store-pidgin.c | 3 +-
telepathy-logger/log-store-sqlite.c | 7 ++-
telepathy-logger/log-store-xml-internal.h | 1 +
telepathy-logger/log-store-xml.c | 15 +++++-
telepathy-logger/log-store.c | 3 +-
9 files changed, 25 insertions(+), 125 deletions(-)
diff --git a/telepathy-logger/Makefile.am b/telepathy-logger/Makefile.am
index 774bd21..def42ac 100644
--- a/telepathy-logger/Makefile.am
+++ b/telepathy-logger/Makefile.am
@@ -100,8 +100,6 @@ libtelepathy_logger_1_la_SOURCES = \
log-store-internal.h \
log-store-xml.c \
log-store-xml-internal.h \
- log-store-empathy.c \
- log-store-empathy-internal.h \
log-store-sqlite.c \
log-store-sqlite-internal.h \
log-store-pidgin.c \
diff --git a/telepathy-logger/log-manager.c b/telepathy-logger/log-manager.c
index d032d87..41cea08 100644
--- a/telepathy-logger/log-manager.c
+++ b/telepathy-logger/log-manager.c
@@ -39,7 +39,6 @@
#include <telepathy-logger/event.h>
#include <telepathy-logger/event-internal.h>
#include <telepathy-logger/log-store-internal.h>
-#include <telepathy-logger/log-store-empathy-internal.h>
#include <telepathy-logger/log-store-xml-internal.h>
#include <telepathy-logger/log-store-pidgin-internal.h>
#include <telepathy-logger/log-store-sqlite-internal.h>
diff --git a/telepathy-logger/log-store-empathy-internal.h b/telepathy-logger/log-store-empathy-internal.h
deleted file mode 100644
index c27788f..0000000
--- a/telepathy-logger/log-store-empathy-internal.h
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright © 2013 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-#ifndef TPL_LOG_STORE_EMPATHY_H
-#define TPL_LOG_STORE_EMPATHY_H
-
-#include "log-store-xml-internal.h"
-
-typedef struct _TplLogStoreEmpathy TplLogStoreEmpathy;
-typedef struct _TplLogStoreEmpathyClass TplLogStoreEmpathyClass;
-
-struct _TplLogStoreEmpathyClass {
- /*< private >*/
- TplLogStoreXmlClass parent_class;
-};
-
-struct _TplLogStoreEmpathy {
- TplLogStoreXml parent;
-};
-
-GType _tpl_log_store_empathy_get_type (void);
-
-TplLogStore * _tpl_log_store_empathy_new (void);
-
-/* TYPE MACROS */
-#define TPL_TYPE_LOG_STORE_EMPATHY \
- (_tpl_log_store_empathy_get_type ())
-#define TPL_LOG_STORE_EMPATHY(obj) \
- (G_TYPE_CHECK_INSTANCE_CAST((obj), TPL_TYPE_LOG_STORE_EMPATHY, TplLogStoreEmpathy))
-#define TPL_LOG_STORE_EMPATHY_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_CAST((klass), TPL_TYPE_LOG_STORE_EMPATHY,\
- TplLogStoreEmpathyClass))
-#define TPL_IS_LOG_STORE_EMPATHY(obj) \
- (G_TYPE_CHECK_INSTANCE_TYPE((obj), TPL_TYPE_LOG_STORE_EMPATHY))
-#define TPL_IS_LOG_STORE_EMPATHY_CLASS(klass) \
- (G_TYPE_CHECK_CLASS_TYPE((klass), TPL_TYPE_LOG_STORE_EMPATHY))
-#define TPL_LOG_STORE_EMPATHY_GET_CLASS(obj) \
- (G_TYPE_INSTANCE_GET_CLASS ((obj), TPL_TYPE_LOG_STORE_EMPATHY, \
- TplLogStoreEmpathyClass))
-
-#endif /* TPL_LOG_STORE_EMPATHY_H */
diff --git a/telepathy-logger/log-store-empathy.c b/telepathy-logger/log-store-empathy.c
deleted file mode 100644
index 7b6d646..0000000
--- a/telepathy-logger/log-store-empathy.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * Copyright ©2013 Collabora Ltd.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-/*
- * This is a subclass of TplLogStoreXml to read logs from the directory Empathy
- * used to store them it. It disables writing to that legacy location.
- */
-
-#include "config.h"
-#include "log-store-empathy-internal.h"
-
-#include "telepathy-logger/log-store-internal.h"
-
-static void log_store_iface_init (gpointer g_iface, gpointer iface_data);
-
-G_DEFINE_TYPE_WITH_CODE (TplLogStoreEmpathy, _tpl_log_store_empathy,
- TPL_TYPE_LOG_STORE_XML,
- G_IMPLEMENT_INTERFACE (TPL_TYPE_LOG_STORE, log_store_iface_init))
-
-static void
-_tpl_log_store_empathy_init (TplLogStoreEmpathy *self)
-{
-}
-
-static void
-_tpl_log_store_empathy_class_init (TplLogStoreEmpathyClass *klass)
-{
-}
-
-static void
-log_store_iface_init (gpointer g_iface,
- gpointer iface_data)
-{
- TplLogStoreInterface *iface = (TplLogStoreInterface *) g_iface;
-
- /* We don't want to store new logs in Empathy's directory, just read the old
- * ones. */
- iface->add_event = NULL;
-}
-
-TplLogStore *
-_tpl_log_store_empathy_new (void)
-{
- return g_object_new (TPL_TYPE_LOG_STORE_EMPATHY,
- "name", "Empathy",
- NULL);
-}
diff --git a/telepathy-logger/log-store-pidgin.c b/telepathy-logger/log-store-pidgin.c
index f6fabe0..c6189d3 100644
--- a/telepathy-logger/log-store-pidgin.c
+++ b/telepathy-logger/log-store-pidgin.c
@@ -47,6 +47,7 @@
struct _TplLogStorePidginPriv
{
gchar *name;
+ gboolean writable;
TpAccountManager *account_manager;
gchar *basedir;
@@ -92,7 +93,7 @@ tpl_log_store_pidgin_get_property (GObject *object,
g_value_set_boolean (value, TRUE);
break;
case PROP_WRITABLE:
- g_value_set_boolean (value, FALSE);
+ g_value_set_boolean (value, self->priv->writable);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
diff --git a/telepathy-logger/log-store-sqlite.c b/telepathy-logger/log-store-sqlite.c
index 26d1ac2..4a8afa8 100644
--- a/telepathy-logger/log-store-sqlite.c
+++ b/telepathy-logger/log-store-sqlite.c
@@ -58,6 +58,7 @@ enum /* properties */
struct _TplLogStoreSqlitePrivate
{
gchar *name;
+ gchar writable;
sqlite3 *db;
};
@@ -118,7 +119,7 @@ tpl_log_store_sqlite_get_property (GObject *self,
break;
case PROP_WRITABLE:
- g_value_set_boolean (value, TRUE);
+ g_value_set_boolean (value, priv->writable);
break;
default:
@@ -140,6 +141,9 @@ tpl_log_store_sqlite_set_property (GObject *self,
case PROP_NAME:
priv->name = g_value_dup_string (value);
break;
+ case PROP_WRITABLE:
+ priv->writable = g_value_get_boolean (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (self, id, pspec);
break;
@@ -654,6 +658,7 @@ _tpl_log_store_sqlite_dup (void)
{
return g_object_new (TPL_TYPE_LOG_STORE_SQLITE,
"name", TPL_LOG_STORE_SQLITE_NAME,
+ "writable", TRUE,
NULL);
}
diff --git a/telepathy-logger/log-store-xml-internal.h b/telepathy-logger/log-store-xml-internal.h
index 4e8748a..8bddd3b 100644
--- a/telepathy-logger/log-store-xml-internal.h
+++ b/telepathy-logger/log-store-xml-internal.h
@@ -61,6 +61,7 @@ typedef struct
GType _tpl_log_store_xml_get_type (void);
TplLogStore * _tpl_log_store_xml_new (void);
+TplLogStore * _tpl_log_store_empathy_new (void);
G_END_DECLS
#endif /* __TPL_LOG_STORE_XML_H__ */
diff --git a/telepathy-logger/log-store-xml.c b/telepathy-logger/log-store-xml.c
index 11edc03..490314d 100644
--- a/telepathy-logger/log-store-xml.c
+++ b/telepathy-logger/log-store-xml.c
@@ -80,6 +80,7 @@
struct _TplLogStoreXmlPriv
{
gchar *name;
+ gboolean writable;
gchar *basedir;
TpAccountManager *account_manager;
};
@@ -161,7 +162,7 @@ tpl_log_store_xml_get_property (GObject *object,
g_value_set_boolean (value, TRUE);
break;
case PROP_WRITABLE:
- g_value_set_boolean (value, TRUE);
+ g_value_set_boolean (value, self->priv->writable);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
@@ -183,6 +184,9 @@ tpl_log_store_xml_set_property (GObject *object,
case PROP_NAME:
self->priv->name = g_value_dup_string (value);
break;
+ case PROP_WRITABLE:
+ self->priv->writable = g_value_get_boolean (value);
+ break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, param_id, pspec);
break;
@@ -1909,3 +1913,12 @@ _tpl_log_store_xml_new (void)
"name", "TpLogger",
NULL);
}
+
+TplLogStore *
+_tpl_log_store_empathy_new (void)
+{
+ return g_object_new (TPL_TYPE_LOG_STORE_XML,
+ "name", "Empathy",
+ "writable", FALSE,
+ NULL);
+}
diff --git a/telepathy-logger/log-store.c b/telepathy-logger/log-store.c
index fbf0255..9239bc4 100644
--- a/telepathy-logger/log-store.c
+++ b/telepathy-logger/log-store.c
@@ -110,7 +110,8 @@ _tpl_log_store_init (gpointer g_iface)
"Writable",
"Whether this log store is writable",
FALSE,
- G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
+ G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY |
+ G_PARAM_STATIC_STRINGS));
}
gchar *
More information about the telepathy-commits
mailing list