summaryrefslogtreecommitdiff
path: root/telepathy-logger/log-entry.c
diff options
context:
space:
mode:
authorCosimo Alfarano <cosimo.alfarano@collabora.co.uk>2010-02-17 14:59:42 +0000
committerCosimo Alfarano <cosimo.alfarano@collabora.co.uk>2010-02-22 12:34:29 +0000
commit993b4f4b9a14749dd7c36b0e605a3ef4aa04f76e (patch)
tree90156ef1b73c5e7600d5d071bdc1dd5b5f676948 /telepathy-logger/log-entry.c
parentcab4c064c3bbe0a30f83d0f935f9c549682a99ba (diff)
downloadtelepathy-logger-993b4f4b9a14749dd7c36b0e605a3ef4aa04f76e.tar.gz
added account-path property/member to TplLogStore
That way a client needing to obtain a TpAccount, can acquire it from its object-path. account-path is a PROP_CONSTRUCT_ONLY property, thus the _new method has been updated as well. Setting the avatar_token for queried log entries. Also, cleaned up some code and TP style fixes.
Diffstat (limited to 'telepathy-logger/log-entry.c')
-rw-r--r--telepathy-logger/log-entry.c63
1 files changed, 59 insertions, 4 deletions
diff --git a/telepathy-logger/log-entry.c b/telepathy-logger/log-entry.c
index c3647f9..43adb22 100644
--- a/telepathy-logger/log-entry.c
+++ b/telepathy-logger/log-entry.c
@@ -44,6 +44,9 @@
G_DEFINE_ABSTRACT_TYPE (TplLogEntry, tpl_log_entry, G_TYPE_OBJECT)
static void tpl_log_entry_set_log_id (TplLogEntry *self, guint data);
+static void tpl_log_entry_set_account_path (TplLogEntry *self,
+ const gchar *data);
+
#define GET_PRIV(obj) TPL_GET_PRIV (obj, TplLogEntry)
struct _TplLogEntryPriv
@@ -52,6 +55,7 @@ struct _TplLogEntryPriv
gint64 timestamp;
TplLogEntrySignalType signal_type;
gchar *chat_id;
+ gchar *account_path;
/* incoming/outgoing */
TplLogEntryDirection direction;
@@ -68,6 +72,7 @@ enum {
PROP_LOG_ID,
PROP_DIRECTION,
PROP_CHAT_ID,
+ PROP_ACCOUNT_PATH,
PROP_SENDER,
PROP_RECEIVER
};
@@ -80,6 +85,8 @@ tpl_log_entry_finalize (GObject *obj)
g_free (priv->chat_id);
priv->chat_id = NULL;
+ g_free (priv->account_path);
+ priv->account_path = NULL;
G_OBJECT_CLASS (tpl_log_entry_parent_class)->finalize (obj);
}
@@ -96,7 +103,7 @@ tpl_log_entry_dispose (GObject *obj)
g_object_unref (priv->sender);
priv->sender = NULL;
}
- if (priv->receiver)
+ if (priv->receiver != NULL)
{
g_object_unref (priv->receiver);
priv->receiver = NULL;
@@ -131,6 +138,9 @@ tpl_log_entry_get_property (GObject *object,
case PROP_CHAT_ID:
g_value_set_string (value, priv->chat_id);
break;
+ case PROP_ACCOUNT_PATH:
+ g_value_set_string (value, priv->account_path);
+ break;
case PROP_SENDER:
g_value_set_object (value, priv->sender);
break;
@@ -168,6 +178,9 @@ tpl_log_entry_set_property (GObject *object,
case PROP_CHAT_ID:
tpl_log_entry_set_chat_id (self, g_value_get_string (value));
break;
+ case PROP_ACCOUNT_PATH:
+ tpl_log_entry_set_account_path (self, g_value_get_string (value));
+ break;
case PROP_SENDER:
tpl_log_entry_set_sender (self, g_value_get_object (value));
break;
@@ -236,13 +249,23 @@ tpl_log_entry_class_init (TplLogEntryClass *klass)
G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_DIRECTION, param_spec);
+ /* FIXME: G_PARAM_CONSTRUCT and not G_PARAM_CONSTRUCT_ONLY because it needs to be
+ * set not at instance time in channel_text.c on_received_signal.
+ * It would be much better using G_PARAM_CONSTRUCT_ONLY */
param_spec = g_param_spec_string ("chat-id",
"ChatId",
- "The chat id relative to the log entry's account name",
+ "The chat identifier to which the log entry is related.",
NULL,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT | G_PARAM_STATIC_STRINGS);
g_object_class_install_property (object_class, PROP_CHAT_ID, param_spec);
+ param_spec = g_param_spec_string ("account-path",
+ "AccountPath",
+ "The account path of the TpAccount to which the log entry is related",
+ NULL,
+ G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS);
+ g_object_class_install_property (object_class, PROP_ACCOUNT_PATH, param_spec);
+
param_spec = g_param_spec_object ("sender",
"Sender",
"TplContact instance who originated the log entry",
@@ -366,6 +389,18 @@ tpl_log_entry_get_chat_id (TplLogEntry *self)
}
+const gchar *
+tpl_log_entry_get_account_path (TplLogEntry *self)
+{
+ TplLogEntryPriv *priv;
+
+ g_return_val_if_fail (TPL_IS_LOG_ENTRY (self), NULL);
+
+ priv = GET_PRIV (self);
+ return priv->account_path;
+}
+
+
void
tpl_log_entry_set_timestamp (TplLogEntry *self,
gint64 data)
@@ -463,14 +498,34 @@ tpl_log_entry_set_chat_id (TplLogEntry *self,
{
TplLogEntryPriv *priv;
+ priv = GET_PRIV (self);
+
g_return_if_fail (TPL_IS_LOG_ENTRY (self));
+ g_return_if_fail (!TPL_STR_EMPTY (data));
+ g_return_if_fail (priv->chat_id == NULL);
- priv = GET_PRIV (self);
- g_free (priv->chat_id);
priv->chat_id = g_strdup (data);
g_object_notify (G_OBJECT(self), "chat-id");
}
+
+static void
+tpl_log_entry_set_account_path (TplLogEntry *self,
+ const gchar *data)
+{
+ TplLogEntryPriv *priv;
+
+ priv = GET_PRIV (self);
+
+ g_return_if_fail (TPL_IS_LOG_ENTRY (self));
+ g_return_if_fail (!TPL_STR_EMPTY (data));
+ g_return_if_fail (priv->account_path == NULL);
+
+ priv->account_path = g_strdup (data);
+ g_object_notify (G_OBJECT(self), "account-path");
+}
+
+
/**
* log_entry:
* @self: TplLogEntry subclass instance