diff options
author | Will Thompson <will.thompson@collabora.co.uk> | 2012-09-25 18:57:01 -0400 |
---|---|---|
committer | Will Thompson <will.thompson@collabora.co.uk> | 2012-09-25 18:57:01 -0400 |
commit | 02378b69d4057001f873875ea9c03bda516fc08d (patch) | |
tree | f0d0edbcf7a8c3c6f1572a25986921b6d58e89ea | |
parent | e897c6f8284dc4ce6f5329fbfc6b24ba643d3ecd (diff) |
Make TplLogStore:name immutable.
For all log stores except the Xml one, this is always set to the same
thing. For the Xml one, the name of the store depends entirely on the
value of empathy-legacy.
-rw-r--r-- | telepathy-logger/log-manager.c | 4 | ||||
-rw-r--r-- | telepathy-logger/log-store-pidgin.c | 26 | ||||
-rw-r--r-- | telepathy-logger/log-store-xml.c | 29 | ||||
-rw-r--r-- | telepathy-logger/log-store.c | 2 | ||||
-rw-r--r-- | tests/dbus/test-tpl-log-iter-pidgin.c | 1 | ||||
-rw-r--r-- | tests/dbus/test-tpl-log-iter-xml.c | 1 | ||||
-rw-r--r-- | tests/dbus/test-tpl-log-store-pidgin.c | 9 | ||||
-rw-r--r-- | tests/dbus/test-tpl-log-store-xml.c | 1 |
8 files changed, 14 insertions, 59 deletions
diff --git a/telepathy-logger/log-manager.c b/telepathy-logger/log-manager.c index f9cd608f2..f3f179569 100644 --- a/telepathy-logger/log-manager.c +++ b/telepathy-logger/log-manager.c @@ -276,25 +276,21 @@ tpl_log_manager_init (TplLogManager *self) /* The TPL's default read-write logstore */ add_log_store (self, g_object_new (TPL_TYPE_LOG_STORE_XML, - "name", "TpLogger", NULL)); /* Load by default the Empathy's legacy 'past coversations' LogStore */ add_log_store (self, g_object_new (TPL_TYPE_LOG_STORE_XML, - "name", "Empathy", "empathy-legacy", TRUE, NULL)); add_log_store (self, g_object_new (TPL_TYPE_LOG_STORE_PIDGIN, - "name", "Pidgin", NULL)); /* Load the event counting cache */ add_log_store (self, g_object_new (TPL_TYPE_LOG_STORE_SQLITE, - "name", "Sqlite", NULL)); DEBUG ("Log Manager initialised"); diff --git a/telepathy-logger/log-store-pidgin.c b/telepathy-logger/log-store-pidgin.c index fe289e9b7..40a58cf35 100644 --- a/telepathy-logger/log-store-pidgin.c +++ b/telepathy-logger/log-store-pidgin.c @@ -39,6 +39,8 @@ #define DEBUG_FLAG TPL_DEBUG_LOG_STORE #include "debug-internal.h" +#define TPL_LOG_STORE_PIDGIN_NAME "Pidgin" + #define TXT_LOG_FILENAME_SUFFIX ".txt" #define HTML_LOG_FILENAME_SUFFIX ".html" @@ -47,7 +49,6 @@ struct _TplLogStorePidginPriv gboolean test_mode; gchar *basedir; - gchar *name; }; enum { @@ -66,7 +67,6 @@ static void tpl_log_store_pidgin_get_property (GObject *object, guint param_id, static void tpl_log_store_pidgin_set_property (GObject *object, guint param_id, const GValue *value, GParamSpec *pspec); static const gchar *log_store_pidgin_get_name (TplLogStore *store); -static void log_store_pidgin_set_name (TplLogStorePidgin *self, const gchar *data); static const gchar *log_store_pidgin_get_basedir (TplLogStorePidgin *self); static void log_store_pidgin_set_basedir (TplLogStorePidgin *self, const gchar *data); @@ -87,7 +87,7 @@ tpl_log_store_pidgin_get_property (GObject *object, switch (param_id) { case PROP_NAME: - g_value_set_string (value, priv->name); + g_value_set_string (value, TPL_LOG_STORE_PIDGIN_NAME); break; case PROP_READABLE: g_value_set_boolean (value, TRUE); @@ -115,9 +115,6 @@ tpl_log_store_pidgin_set_property (GObject *object, switch (param_id) { - case PROP_NAME: - log_store_pidgin_set_name (self, g_value_get_string (value)); - break; case PROP_BASEDIR: log_store_pidgin_set_basedir (self, g_value_get_string (value)); break; @@ -139,9 +136,6 @@ tpl_log_store_pidgin_dispose (GObject *self) g_free (priv->basedir); priv->basedir = NULL; - g_free (priv->name); - priv->name = NULL; - G_OBJECT_CLASS (tpl_log_store_pidgin_parent_class)->dispose (self); } @@ -198,7 +192,7 @@ log_store_pidgin_get_name (TplLogStore *store) g_return_val_if_fail (TPL_IS_LOG_STORE_PIDGIN (self), NULL); - return self->priv->name; + return TPL_LOG_STORE_PIDGIN_NAME; } @@ -230,18 +224,6 @@ log_store_pidgin_get_basedir (TplLogStorePidgin *self) static void -log_store_pidgin_set_name (TplLogStorePidgin *self, - const gchar *data) -{ - g_return_if_fail (TPL_IS_LOG_STORE_PIDGIN (self)); - g_return_if_fail (!TPL_STR_EMPTY (data)); - g_return_if_fail (self->priv->name == NULL); - - self->priv->name = g_strdup (data); -} - - -static void log_store_pidgin_set_basedir (TplLogStorePidgin *self, const gchar *data) { diff --git a/telepathy-logger/log-store-xml.c b/telepathy-logger/log-store-xml.c index 17753ed79..6b3582227 100644 --- a/telepathy-logger/log-store-xml.c +++ b/telepathy-logger/log-store-xml.c @@ -79,7 +79,6 @@ struct _TplLogStoreXmlPriv { gchar *basedir; - gchar *name; gboolean empathy_legacy; gboolean test_mode; TpAccountManager *account_manager; @@ -100,7 +99,6 @@ static void tpl_log_store_xml_get_property (GObject *object, guint param_id, GVa static void tpl_log_store_xml_set_property (GObject *object, guint param_id, const GValue *value, GParamSpec *pspec); static const gchar *log_store_xml_get_name (TplLogStore *store); -static void log_store_xml_set_name (TplLogStoreXml *self, const gchar *data); static const gchar *log_store_xml_get_basedir (TplLogStoreXml *self); static void log_store_xml_set_basedir (TplLogStoreXml *self, const gchar *data); @@ -144,11 +142,6 @@ log_store_xml_finalize (GObject *object) g_free (priv->basedir); priv->basedir = NULL; } - if (priv->name != NULL) - { - g_free (priv->name); - priv->name = NULL; - } } @@ -163,7 +156,8 @@ tpl_log_store_xml_get_property (GObject *object, switch (param_id) { case PROP_NAME: - g_value_set_string (value, priv->name); + g_value_set_string (value, + log_store_xml_get_name ((TplLogStore *) object)); break; case PROP_READABLE: g_value_set_boolean (value, TRUE); @@ -194,9 +188,6 @@ tpl_log_store_xml_set_property (GObject *object, switch (param_id) { - case PROP_NAME: - log_store_xml_set_name (self, g_value_get_string (value)); - break; case PROP_EMPATHY_LEGACY: self->priv->empathy_legacy = g_value_get_boolean (value); break; @@ -1761,7 +1752,10 @@ log_store_xml_get_name (TplLogStore *store) g_return_val_if_fail (TPL_IS_LOG_STORE_XML (self), NULL); - return self->priv->name; + if (self->priv->empathy_legacy) + return "Empathy"; + else + return "TpLogger"; } @@ -1801,17 +1795,6 @@ log_store_xml_get_basedir (TplLogStoreXml *self) static void -log_store_xml_set_name (TplLogStoreXml *self, - const gchar *data) -{ - g_return_if_fail (TPL_IS_LOG_STORE_XML (self)); - g_return_if_fail (!TPL_STR_EMPTY (data)); - g_return_if_fail (self->priv->name == NULL); - - self->priv->name = g_strdup (data); -} - -static void log_store_xml_set_basedir (TplLogStoreXml *self, const gchar *data) { diff --git a/telepathy-logger/log-store.c b/telepathy-logger/log-store.c index 5ad1536a5..401744731 100644 --- a/telepathy-logger/log-store.c +++ b/telepathy-logger/log-store.c @@ -71,7 +71,7 @@ _tpl_log_store_init (gpointer g_iface) "Name", "The TplLogStore implementation's name", NULL, - G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); + G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); /** * TplLogStore:readable: diff --git a/tests/dbus/test-tpl-log-iter-pidgin.c b/tests/dbus/test-tpl-log-iter-pidgin.c index c18a34b63..e1a96dc55 100644 --- a/tests/dbus/test-tpl-log-iter-pidgin.c +++ b/tests/dbus/test-tpl-log-iter-pidgin.c @@ -52,7 +52,6 @@ setup (PidginTestCaseFixture* fixture, g_assert (fixture->main_loop != NULL); fixture->store = g_object_new (TPL_TYPE_LOG_STORE_PIDGIN, - "name", "testcase", "testmode", TRUE, NULL); diff --git a/tests/dbus/test-tpl-log-iter-xml.c b/tests/dbus/test-tpl-log-iter-xml.c index 1d64c15a8..7b966f654 100644 --- a/tests/dbus/test-tpl-log-iter-xml.c +++ b/tests/dbus/test-tpl-log-iter-xml.c @@ -28,7 +28,6 @@ setup (XmlTestCaseFixture* fixture, GError *error = NULL; fixture->store = g_object_new (TPL_TYPE_LOG_STORE_XML, - "name", "testcase", "testmode", TRUE, NULL); diff --git a/tests/dbus/test-tpl-log-store-pidgin.c b/tests/dbus/test-tpl-log-store-pidgin.c index 3ef0a2393..fea3daff7 100644 --- a/tests/dbus/test-tpl-log-store-pidgin.c +++ b/tests/dbus/test-tpl-log-store-pidgin.c @@ -171,7 +171,6 @@ setup (PidginTestCaseFixture* fixture, DEBUG ("basedir is %s", fixture->basedir); fixture->store = g_object_new (TPL_TYPE_LOG_STORE_PIDGIN, - "name", "testcase", "testmode", TRUE, NULL); @@ -251,9 +250,7 @@ test_basedir (PidginTestCaseFixture *fixture, /* try to instantiate the default store, without passing basedir, it has to * match the real libpurple basedir */ - store = g_object_new (TPL_TYPE_LOG_STORE_PIDGIN, - "name", "testcase", - NULL); + store = g_object_new (TPL_TYPE_LOG_STORE_PIDGIN, NULL); dir = g_build_path (G_DIR_SEPARATOR_S, g_get_home_dir (), ".purple", "logs", NULL); g_assert_cmpstr (log_store_pidgin_get_basedir (store), ==, dir); @@ -345,9 +342,9 @@ test_get_name (PidginTestCaseFixture *fixture, { const gchar *name; - name = log_store_pidgin_get_name (TPL_LOG_STORE (fixture->store)); + name = _tpl_log_store_get_name (TPL_LOG_STORE (fixture->store)); - g_assert_cmpstr (name, ==, "testcase"); + g_assert_cmpstr (name, ==, "Pidgin"); } static void diff --git a/tests/dbus/test-tpl-log-store-xml.c b/tests/dbus/test-tpl-log-store-xml.c index f35b4a7da..6deceb9ab 100644 --- a/tests/dbus/test-tpl-log-store-xml.c +++ b/tests/dbus/test-tpl-log-store-xml.c @@ -48,7 +48,6 @@ setup (XmlTestCaseFixture* fixture, gconstpointer user_data) { fixture->store = g_object_new (TPL_TYPE_LOG_STORE_XML, - "name", "testcase", "testmode", TRUE, NULL); |