summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCosimo Alfarano <cosimo.alfarano@collabora.co.uk>2010-01-19 11:57:19 +0000
committerCosimo Alfarano <cosimo.alfarano@collabora.co.uk>2010-01-19 11:57:19 +0000
commit0fa5a714f0ae01f4307a325a0d67ed2c294c8600 (patch)
tree196301117e4b21d763fc333bac2779486a975a89
parent5853f0728abf10827245b5bdb496f2c960a4ef36 (diff)
downloadtelepathy-logger-0fa5a714f0ae01f4307a325a0d67ed2c294c8600.tar.gz
TplConf bug fixed
-rw-r--r--.gitignore5
-rw-r--r--TODO5
-rw-r--r--src/dbus-service.c2
-rw-r--r--src/test_api.c2
-rw-r--r--telepathy-logger/Makefile.am7
-rw-r--r--telepathy-logger/channel-text.c24
-rw-r--r--telepathy-logger/channel.c32
-rw-r--r--telepathy-logger/channel.h9
-rw-r--r--telepathy-logger/conf.c8
-rw-r--r--telepathy-logger/conf.h10
-rw-r--r--telepathy-logger/contact.c60
-rw-r--r--telepathy-logger/contact.h16
-rw-r--r--telepathy-logger/log-entry.c24
-rw-r--r--telepathy-logger/log-entry.h3
-rw-r--r--telepathy-logger/log-manager.c2
-rw-r--r--telepathy-logger/observer.c43
16 files changed, 153 insertions, 99 deletions
diff --git a/.gitignore b/.gitignore
index 65172d8..9f12e48 100644
--- a/.gitignore
+++ b/.gitignore
@@ -37,8 +37,9 @@ src/test-api
src/telepathy-logger-dbus
src/dbus-service-client.h
src/dbus-service-server.h
-src/*.service
-src/*.client
+
+data/*.service
+data/*.client
telepathy-logger/*.o
telepathy-logger/*.lo
diff --git a/TODO b/TODO
index 018026b..6bf28f9 100644
--- a/TODO
+++ b/TODO
@@ -1,7 +1,12 @@
Those are mini tasks still to do. They should be filed against a bug
trucker as soon as TPL will have one:
+- TplChannel TplChannelText refactoring
+- TplLogEntry refactoring
+- use Private struct
- fix dbus_g_method_return_error
+- fix race condition with connecting signals in observer
+
- global configuration object (ie disable logging partially or totally,
choose the logstore, etc)
- understand if direction from tpl_log_entry_text is to be removed
diff --git a/src/dbus-service.c b/src/dbus-service.c
index 3f53f60..339c376 100644
--- a/src/dbus-service.c
+++ b/src/dbus-service.c
@@ -168,7 +168,7 @@ tpl_dbus_service_last_chats (TplDBusService *self,
account = tp_account_new(tp_dbus, account_path, &error);
if (error!=NULL) {
- g_error("TpAccount creation: %s\n",
+ g_error("TpAccount creation: %s",
error->message);
dbus_g_method_return_error(context, error);
g_error_free(error);
diff --git a/src/test_api.c b/src/test_api.c
index 5ca6a4a..d9e4945 100644
--- a/src/test_api.c
+++ b/src/test_api.c
@@ -53,7 +53,7 @@ main (int argc, char *argv[])
g_message("FINISH\n");
/* set */
- tpl_conf_togle_globally_enable(conf, FALSE, NULL);
+ tpl_conf_togle_globally_enable(conf, TRUE, NULL);
newlist = g_slist_append(newlist, "foo");
newlist = g_slist_append(newlist, "bar");
tpl_conf_set_accounts_ignorelist(conf, newlist, NULL);
diff --git a/telepathy-logger/Makefile.am b/telepathy-logger/Makefile.am
index 28c43e9..1fdd313 100644
--- a/telepathy-logger/Makefile.am
+++ b/telepathy-logger/Makefile.am
@@ -16,17 +16,10 @@ lib_LTLIBRARIES = libtelepathy-logger.la
LIBTPLdir = $(includedir)/telepathy-logger
LIBTPL_HEADERS = \
utils.h \
- channel.h \
- channel-text.h \
- conf.h \
contact.h \
log-entry.h \
log-entry-text.h \
log-manager.h \
- log-manager-priv.h \
- log-store-empathy.h \
- log-store.h \
- observer.h \
datetime.h
diff --git a/telepathy-logger/channel-text.c b/telepathy-logger/channel-text.c
index cedf19b..66b4e8c 100644
--- a/telepathy-logger/channel-text.c
+++ b/telepathy-logger/channel-text.c
@@ -115,7 +115,7 @@ _channel_on_sent_signal_cb (TpChannel * proxy,
if (!tpl_text_channel_is_chatroom (tpl_text) && remote == NULL)
{
- g_error ("Sending message: Remote TplContact NULL on 1-1 Chat\n");
+ g_error ("Sending message: Remote TplContact NULL on 1-1 Chat");
}
tpl_contact_sender = tpl_contact_from_tp_contact (me);
@@ -197,7 +197,7 @@ _channel_on_received_signal_with_contact_cb (TpConnection * connection,
{
g_error ("Unrecoverable error retrieving remote contact "
"information: %s\n", error->message);
- g_error ("Not able to log the received message: %s\n",
+ g_error ("Not able to log the received message: %s",
tpl_log_entry_text_get_message (tlog));
return;
}
@@ -206,7 +206,7 @@ _channel_on_received_signal_with_contact_cb (TpConnection * connection,
{
g_error ("%d invalid handle(s) passed to "
"tp_connection_get_contacts_by_handle()\n", n_failed);
- g_error ("Not able to log the received message: %s\n",
+ g_error ("Not able to log the received message: %s",
tpl_log_entry_text_get_message (tlog));
return;
}
@@ -340,7 +340,7 @@ _tpl_text_channel_pendingproc_connect_signals (TplTextChannel * self)
self, NULL, NULL, &error);
if (error != NULL)
{
- g_error ("received signal connect: %s\n", error->message);
+ g_error ("received signal connect: %s", error->message);
g_clear_error (&error);
g_error_free (error);
error = NULL;
@@ -351,7 +351,7 @@ _tpl_text_channel_pendingproc_connect_signals (TplTextChannel * self)
NULL, NULL, &error);
if (error != NULL)
{
- g_error ("sent signal connect: %s\n", error->message);
+ g_error ("sent signal connect: %s", error->message);
g_clear_error (&error);
g_error_free (error);
error = NULL;
@@ -362,7 +362,7 @@ _tpl_text_channel_pendingproc_connect_signals (TplTextChannel * self)
self, NULL, NULL, &error);
if (error != NULL)
{
- g_error ("send error signal connect: %s\n", error->message);
+ g_error ("send error signal connect: %s", error->message);
g_clear_error (&error);
g_error_free (error);
error = NULL;
@@ -373,7 +373,7 @@ _tpl_text_channel_pendingproc_connect_signals (TplTextChannel * self)
self, NULL, NULL, &error);
if (error != NULL)
{
- g_error ("lost message signal connect: %s\n", error->message);
+ g_error ("lost message signal connect: %s", error->message);
g_clear_error (&error);
g_error_free (error);
error = NULL;
@@ -383,7 +383,7 @@ _tpl_text_channel_pendingproc_connect_signals (TplTextChannel * self)
self, NULL, NULL, &error);
if (error != NULL)
{
- g_error ("channel closed signal connect: %s\n", error->message);
+ g_error ("channel closed signal connect: %s", error->message);
g_clear_error (&error);
g_error_free (error);
error = NULL;
@@ -403,7 +403,7 @@ _tpl_text_channel_get_chatroom_cb (TpConnection * proxy,
if (error != NULL)
{
- g_error ("retrieving chatroom identifier: %s\n", error->message);
+ g_error ("retrieving chatroom identifier: %s", error->message);
}
tpl_text_channel_set_chatroom_id (tpl_text, *out_Identifiers);
@@ -456,8 +456,8 @@ _tpl_text_channel_get_contact_cb (TpConnection * connection,
if (n_failed > 0)
{
- g_error ("error resolving self handle for connection %s.\n"
- "Aborting channel %s observation\n",
+ g_error ("Error resolving self handle for connection %s."
+ " Aborting channel %s observation",
tpl_channel_get_connection_path
(tpl_text_channel_get_tpl_channel (tpl_text)),
tpl_channel_get_channel_path (tpl_text_channel_get_tpl_channel
@@ -623,7 +623,7 @@ tpl_text_channel_new (TplChannel * tpl_channel)
"un-handled. It's probably OK.\n");
break;
default:
- g_error ("remote handle type unknown %d.\n", remote_handle_type);
+ g_error ("remote handle type unknown %d.", remote_handle_type);
break;
}
diff --git a/telepathy-logger/channel.c b/telepathy-logger/channel.c
index b83c2fc..24d5f9a 100644
--- a/telepathy-logger/channel.c
+++ b/telepathy-logger/channel.c
@@ -28,6 +28,22 @@
G_DEFINE_TYPE (TplChannel, tpl_channel, G_TYPE_OBJECT)
+struct
+{
+ TpChannel *channel;
+ gchar *channel_path;
+ gchar *channel_type;
+ GHashTable *channel_properties;
+
+ TpAccount *account;
+ gchar *account_path;
+ TpConnection *connection;
+ gchar *connection_path;
+
+ TpSvcClientObserver *observer;
+
+} _TplChannelPriv;
+
static void tpl_channel_dispose (GObject * obj)
{
TplChannel *self = TPL_CHANNEL (obj);
@@ -76,20 +92,6 @@ tpl_channel_class_init (TplChannelClass * klass)
static void
tpl_channel_init (TplChannel * self)
{
- /* Init TplChannel's members to zero/NULL */
-/* TODO remove the comment
-#define TPL_SET_NULL(x) tpl_channel_set_##x(self, NULL)
- TPL_SET_NULL(channel);
- TPL_SET_NULL(channel_path);
- TPL_SET_NULL(channel_type);
- TPL_SET_NULL(channel_properties);
- TPL_SET_NULL(account);
- TPL_SET_NULL(account_path);
- TPL_SET_NULL(connection);
- TPL_SET_NULL(connection_path);
- TPL_SET_NULL(observer);
-#undef TPL_SET_NULL
-*/
}
@@ -280,7 +282,7 @@ tpl_channel_register_to_observer (TplChannel * self)
if (g_hash_table_lookup (glob_map, key) != NULL)
{
- g_error ("Channel path found, replacing %s\n", key);
+ g_error ("Channel path found, replacing %s", key);
g_hash_table_remove (glob_map, key);
}
else
diff --git a/telepathy-logger/channel.h b/telepathy-logger/channel.h
index fc93916..7d0071d 100644
--- a/telepathy-logger/channel.h
+++ b/telepathy-logger/channel.h
@@ -39,13 +39,16 @@ G_BEGIN_DECLS
#define TPL_IS_CHANNEL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TPL_TYPE_CHANNEL))
#define TPL_IS_CHANNEL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TPL_TYPE_CHANNEL))
#define TPL_CHANNEL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TPL_TYPE_CHANNEL, TplChannelClass))
-// TODO test the following macros
-//#define TPL_CHANNEL_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE((obj), TPL_TYPE_CHANNEL, TplChannelClass))
- typedef struct
+
+typedef struct _TplChannelPriv TplChannelPriv;
+
+typedef struct
{
GObject parent;
/* private */
+ TplChannelPriv *priv;
+
TpChannel *channel;
gchar *channel_path;
gchar *channel_type;
diff --git a/telepathy-logger/conf.c b/telepathy-logger/conf.c
index ed2b350..79caca4 100644
--- a/telepathy-logger/conf.c
+++ b/telepathy-logger/conf.c
@@ -27,7 +27,6 @@
//#define DEBUG(...)
#define GET_PRIV(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TPL_TYPE_CONF, TplConfPriv))
-//#define GET_PRIV(obj) TPL_GET_PRIV (obj, TplConf)
#define GCONF_KEY_LOGGING_TURNED_ON "/apps/telepathy-logger/logging/turned_on"
#define GCONF_KEY_LOGGING_ACCOUNTS_IGNORELIST "/apps/telepathy-logger/logging/accounts/ignorelist"
@@ -132,7 +131,12 @@ tpl_conf_is_globally_enabled (TplConf * self, GError **error)
gboolean ret;
GError *loc_error = NULL;
- g_return_val_if_fail (TPL_IS_CONF (self), FALSE);
+ if (!TPL_IS_CONF (self))
+ {
+ g_set_error (error, TPL_CONF_ERROR, TPL_CONF_ERROR_GCONF_KEY,
+ "NOT A OBJ, %d", 1);
+ return FALSE;
+ }
ret = gconf_client_get_bool (GET_PRIV(self)->client, GCONF_KEY_LOGGING_TURNED_ON,
&loc_error);
diff --git a/telepathy-logger/conf.h b/telepathy-logger/conf.h
index a707605..11086d2 100644
--- a/telepathy-logger/conf.h
+++ b/telepathy-logger/conf.h
@@ -34,6 +34,16 @@ G_BEGIN_DECLS
#define TPL_IS_CONF_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TPL_TYPE_CONF))
#define TPL_CONF_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TPL_TYPE_CONF, TplConfClass))
+#define TPL_CONF_ERROR g_quark_from_static_string ("tpl-conf-error-quark")
+
+typedef enum
+{
+ /* generic error */
+ TPL_CONF_ERROR_FAILED,
+ /* GCONF KEY ERROR */
+ TPL_CONF_ERROR_GCONF_KEY
+} TplConfError;
+
typedef struct
{
GObject parent;
diff --git a/telepathy-logger/contact.c b/telepathy-logger/contact.c
index e79e34d..3f8aa49 100644
--- a/telepathy-logger/contact.c
+++ b/telepathy-logger/contact.c
@@ -26,20 +26,6 @@
#include <telepathy-logger/utils.h>
G_DEFINE_TYPE (TplContact, tpl_contact, G_TYPE_OBJECT)
- static void tpl_contact_finalize (GObject * obj);
- static void tpl_contact_dispose (GObject * obj);
-
- static void tpl_contact_class_init (TplContactClass * klass)
-{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
- object_class->finalize = tpl_contact_finalize;
- object_class->dispose = tpl_contact_dispose;
-}
-
-static void
-tpl_contact_init (TplContact * self)
-{
-}
static void
tpl_contact_finalize (GObject * obj)
@@ -71,6 +57,19 @@ tpl_contact_dispose (GObject * obj)
+static void tpl_contact_class_init (TplContactClass * klass)
+{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
+ object_class->finalize = tpl_contact_finalize;
+ object_class->dispose = tpl_contact_dispose;
+}
+
+static void
+tpl_contact_init (TplContact * self)
+{
+}
+
+
TplContact *
tpl_contact_from_tp_contact (TpContact * contact)
{
@@ -79,15 +78,12 @@ tpl_contact_from_tp_contact (TpContact * contact)
ret = tpl_contact_new ();
tpl_contact_set_contact (ret, contact);
tpl_contact_set_identifier (ret,
- (gchar *) tp_contact_get_identifier (contact));
+ tp_contact_get_identifier (contact));
tpl_contact_set_alias (ret, (gchar *) tp_contact_get_alias (contact));
tpl_contact_set_presence_status (ret,
- (gchar *)
- tp_contact_get_presence_status (contact));
+ tp_contact_get_presence_status (contact));
tpl_contact_set_presence_message (ret,
- (gchar *)
- tp_contact_get_presence_message
- (contact));
+ tp_contact_get_presence_message (contact));
return ret;
}
@@ -102,34 +98,39 @@ TpContact *
tpl_contact_get_contact (TplContact * self)
{
g_return_val_if_fail (TPL_IS_CONTACT (self), NULL);
+
return self->contact;
}
-gchar *
+const gchar *
tpl_contact_get_alias (TplContact * self)
{
g_return_val_if_fail (TPL_IS_CONTACT (self), NULL);
+
return self->alias;
}
-gchar *
+const gchar *
tpl_contact_get_identifier (TplContact * self)
{
g_return_val_if_fail (TPL_IS_CONTACT (self), NULL);
+
return self->identifier;
}
-gchar *
+const gchar *
tpl_contact_get_presence_status (TplContact * self)
{
g_return_val_if_fail (TPL_IS_CONTACT (self), NULL);
+
return self->presence_status;
}
-gchar *
+const gchar *
tpl_contact_get_presence_message (TplContact * self)
{
g_return_val_if_fail (TPL_IS_CONTACT (self), NULL);
+
return self->presence_message;
}
@@ -137,6 +138,7 @@ TplContactType
tpl_contact_get_contact_type (TplContact * self)
{
g_return_val_if_fail (TPL_IS_CONTACT (self), TPL_CONTACT_UNKNOWN);
+
return self->contact_type;
}
@@ -144,6 +146,7 @@ TpAccount *
tpl_contact_get_account (TplContact * self)
{
g_return_val_if_fail (TPL_IS_CONTACT (self), NULL);
+
return self->account;
}
@@ -171,16 +174,17 @@ tpl_contact_set_account (TplContact * self, TpAccount * data)
}
void
-tpl_contact_set_alias (TplContact * self, gchar * data)
+tpl_contact_set_alias (TplContact * self, const gchar * data)
{
g_return_if_fail (TPL_IS_CONTACT (self));
+ g_return_if_fail (!TPL_STR_EMPTY (data));
g_free (self->alias);
self->alias = g_strdup (data);
}
void
-tpl_contact_set_identifier (TplContact * self, gchar * data)
+tpl_contact_set_identifier (TplContact * self, const gchar * data)
{
g_return_if_fail (TPL_IS_CONTACT (self));
@@ -189,7 +193,7 @@ tpl_contact_set_identifier (TplContact * self, gchar * data)
}
void
-tpl_contact_set_presence_status (TplContact * self, gchar * data)
+tpl_contact_set_presence_status (TplContact * self, const gchar * data)
{
g_return_if_fail (TPL_IS_CONTACT (self));
@@ -198,7 +202,7 @@ tpl_contact_set_presence_status (TplContact * self, gchar * data)
}
void
-tpl_contact_set_presence_message (TplContact * self, gchar * data)
+tpl_contact_set_presence_message (TplContact * self, const gchar * data)
{
g_return_if_fail (TPL_IS_CONTACT (self));
diff --git a/telepathy-logger/contact.h b/telepathy-logger/contact.h
index 6fca0ae..1f709c8 100644
--- a/telepathy-logger/contact.h
+++ b/telepathy-logger/contact.h
@@ -70,13 +70,13 @@ TplContact *tpl_contact_new (void);
TpContact *tpl_contact_get_contact (TplContact * self);
-gchar *tpl_contact_get_alias (TplContact * self);
+const gchar *tpl_contact_get_alias (TplContact * self);
-gchar *tpl_contact_get_identifier (TplContact * self);
+const gchar *tpl_contact_get_identifier (TplContact * self);
-gchar *tpl_contact_get_presence_status (TplContact * self);
+const gchar *tpl_contact_get_presence_status (TplContact * self);
-gchar *tpl_contact_get_presence_message (TplContact * self);
+const gchar *tpl_contact_get_presence_message (TplContact * self);
TplContactType tpl_contact_get_contact_type (TplContact * self);
@@ -86,13 +86,13 @@ void tpl_contact_set_contact (TplContact * self, TpContact * data);
void tpl_contact_set_account (TplContact * self, TpAccount * data);
-void tpl_contact_set_alias (TplContact * self, gchar * data);
+void tpl_contact_set_alias (TplContact * self, const gchar * data);
-void tpl_contact_set_identifier (TplContact * self, gchar * data);
+void tpl_contact_set_identifier (TplContact * self, const gchar * data);
-void tpl_contact_set_presence_status (TplContact * self, gchar * data);
+void tpl_contact_set_presence_status (TplContact * self, const gchar * data);
-void tpl_contact_set_presence_message (TplContact * self, gchar * data);
+void tpl_contact_set_presence_message (TplContact * self, const gchar * data);
void tpl_contact_set_contact_type (TplContact * self, TplContactType data);
diff --git a/telepathy-logger/log-entry.c b/telepathy-logger/log-entry.c
index 99d0316..b5b9f48 100644
--- a/telepathy-logger/log-entry.c
+++ b/telepathy-logger/log-entry.c
@@ -22,6 +22,7 @@
#include "log-entry.h"
#include <glib.h>
+#include <telepathy-glib/util.h>
#include <telepathy-logger/debug.h>
@@ -70,7 +71,7 @@ tpl_log_entry_set_entry (TplLogEntry * self, void *entry)
}
else
{
- g_error ("TplLogEntry does handle only Text channels\n");
+ g_error ("TplLogEntry does handle only Text channels");
}
}
@@ -125,3 +126,24 @@ tpl_log_entry_set_timestamp (TplLogEntry * self, time_t data)
self->timestamp = data;
}
+
+gboolean
+tpl_log_entry_equal (TplLogEntry *message1, TplLogEntry *message2)
+{
+ //TplLogEntryPriv *priv1;
+ //TplLogEntryPriv *priv2;
+
+ g_return_val_if_fail (TPL_IS_LOG_ENTRY (message1), FALSE);
+ g_return_val_if_fail (TPL_IS_LOG_ENTRY (message2), FALSE);
+
+ //priv1 = GET_PRIV (message1);
+ //priv2 = GET_PRIV (message2);
+
+ //if (priv1->id == priv2->id && !tp_strdiff (priv1->body, priv2->body)) {
+ if (message1->type == message2->type)
+ if (!tp_strdiff (message1->entry.text->message, message2->entry.text->message)) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
diff --git a/telepathy-logger/log-entry.h b/telepathy-logger/log-entry.h
index dbb073e..8f9f5f3 100644
--- a/telepathy-logger/log-entry.h
+++ b/telepathy-logger/log-entry.h
@@ -70,5 +70,8 @@ time_t tpl_log_entry_get_timestamp (TplLogEntry * self);
void tpl_log_entry_set_entry (TplLogEntry * self, void *entry);
void tpl_log_entry_set_timestamp (TplLogEntry * self, time_t data);
+gboolean tpl_log_entry_equal (TplLogEntry *message1, TplLogEntry *message2);
+
+
G_END_DECLS
#endif // __TPL_LOG_ENTRY_H__
diff --git a/telepathy-logger/log-manager.c b/telepathy-logger/log-manager.c
index 97ef591..e66f1b0 100644
--- a/telepathy-logger/log-manager.c
+++ b/telepathy-logger/log-manager.c
@@ -320,7 +320,7 @@ tpl_log_manager_get_filtered_messages (TplLogManager * manager,
guint i = 0;
g_return_val_if_fail (TPL_IS_LOG_MANAGER (manager), NULL);
- g_return_val_if_fail (chat_id != NULL, NULL);
+ g_return_val_if_fail (!TPL_STR_EMPTY (chat_id), NULL);
priv = GET_PRIV (manager);
diff --git a/telepathy-logger/observer.c b/telepathy-logger/observer.c
index 5685f11..73df43e 100644
--- a/telepathy-logger/observer.c
+++ b/telepathy-logger/observer.c
@@ -28,6 +28,7 @@
#include <telepathy-glib/dbus.h>
#include <telepathy-glib/svc-generic.h>
#include <telepathy-glib/svc-client.h>
+#include <telepathy-glib/util.h>
#include <telepathy-logger/conf.h>
#include <telepathy-logger/channel.h>
@@ -73,7 +74,7 @@ _observe_channel_when_ready_cb (TpChannel * channel,
if (error != NULL)
{
- g_error ("%s\n", error->message);
+ g_error ("%s", error->message);
g_error ("giving up observing channel '%s'", tpl_chan->channel_path);
g_object_unref (tpl_chan);
return;
@@ -112,23 +113,37 @@ tpl_observer_observe_channels (TpSvcClientObserver * self,
TplConf *conf;
GError *error = NULL;
- g_return_if_fail (TP_IS_ACCOUNT (account) );
- g_return_if_fail (TP_IS_CONNECTION (connection) );
+ g_return_if_fail (!TPL_STR_EMPTY (account) );
+ g_return_if_fail (!TPL_STR_EMPTY (connection) );
/* Check if logging if enabled globally and for the given account_path,
* return imemdiatly if it's not
*/
conf = tpl_conf_dup();
- if (!tpl_conf_is_globally_enabled(conf, NULL))
+ if (!tpl_conf_is_globally_enabled(conf, &error))
+ {
+ if (error)
+ {
+ g_debug ("%s", error->message);
+ }
+ else
+ {
+ g_debug ("Logging is globally disabled. Skipping channel logging.");
+ }
return;
- if (tpl_conf_is_account_ignored(conf, account, NULL))
+ }
+ if (tpl_conf_is_account_ignored(conf, account, &error))
+ {
+ g_debug("Logging is disabled for account %s. "
+ "Skipping channel logging.", account);
return;
+ }
tp_bus_daemon = tp_dbus_daemon_dup (&error);
if (tp_bus_daemon == NULL)
{
- g_error ("%s\n", error->message);
+ g_error ("%s", error->message);
g_clear_error (&error);
g_error_free (error);
return;
@@ -137,7 +152,7 @@ tpl_observer_observe_channels (TpSvcClientObserver * self,
tp_acc = tp_account_new (tp_bus_daemon, account, &error);
if (tp_acc == NULL)
{
- g_error ("%s\n", error->message);
+ g_error ("%s", error->message);
g_clear_error (&error);
g_error_free (error);
g_object_unref (tp_bus_daemon);
@@ -148,7 +163,7 @@ tpl_observer_observe_channels (TpSvcClientObserver * self,
tp_conn = tp_connection_new (tp_bus_daemon, NULL, connection, &error);
if (tp_conn == NULL)
{
- g_error ("%s\n", error->message);
+ g_error ("%s", error->message);
g_clear_error (&error);
g_error_free (error);
g_object_unref (tp_bus_daemon);
@@ -314,14 +329,6 @@ tpl_observer_class_init (TplObserverClass * klass)
dbus_props_class));
}
-
-static gboolean
-tpl_str_are_eq (gconstpointer data, gconstpointer data2)
-{
- return g_strcmp0 (data, data2) ? FALSE : TRUE;
-}
-
-
static void
tpl_observer_init (TplObserver * self)
{
@@ -329,7 +336,7 @@ tpl_observer_init (TplObserver * self)
TpDBusDaemon *tp_bus;
GError *error = NULL;
- self->channel_map = g_hash_table_new_full (g_str_hash, tpl_str_are_eq,
+ self->channel_map = g_hash_table_new_full (g_str_hash, (GEqualFunc) tp_strdiff,
g_free, g_object_unref);
logmanager = tpl_log_manager_dup_singleton ();
@@ -344,7 +351,7 @@ tpl_observer_init (TplObserver * self)
}
else
{
- g_error ("Well Known name request error: %s\n", error->message);
+ g_error ("Well Known name request error: %s", error->message);
g_clear_error (&error);
g_error_free (error);
}