summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-10-29 16:37:07 +0200
committerGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>2010-12-09 13:56:28 +0100
commit8ea29ea69403753ab46dcd0e3a974ab45b4209c9 (patch)
tree14d1af32ead10324c8c7133311d83ecf1cff45a9
parentc832e8ed9a988e2b2dec5852824764e85559bb40 (diff)
TpSignalledMessage: add API to get/set the sender
-rw-r--r--docs/reference/telepathy-glib-sections.txt1
-rw-r--r--telepathy-glib/signalled-message-internal.h5
-rw-r--r--telepathy-glib/signalled-message.c41
-rw-r--r--telepathy-glib/signalled-message.h3
4 files changed, 48 insertions, 2 deletions
diff --git a/docs/reference/telepathy-glib-sections.txt b/docs/reference/telepathy-glib-sections.txt
index 81a359f26..551fbda06 100644
--- a/docs/reference/telepathy-glib-sections.txt
+++ b/docs/reference/telepathy-glib-sections.txt
@@ -5346,6 +5346,7 @@ tp_client_message_get_type
<INCLUDE>telepathy-glib/signalled-message.h</INCLUDE>
<TITLE>TpSignalledMessage</TITLE>
TpSignalledMessage
+tp_signalled_message_get_sender
<SUBSECTION Standard>
TP_IS_SIGNALLED_MESSAGE
TP_IS_SIGNALLED_MESSAGE_CLASS
diff --git a/telepathy-glib/signalled-message-internal.h b/telepathy-glib/signalled-message-internal.h
index 80b451e55..661a49f2c 100644
--- a/telepathy-glib/signalled-message-internal.h
+++ b/telepathy-glib/signalled-message-internal.h
@@ -23,6 +23,8 @@
#include <glib.h>
+#include "signalled-message.h"
+
#include "message.h"
#include "message-internal.h"
@@ -44,6 +46,9 @@ struct _TpSignalledMessage {
TpMessage * _tp_signalled_message_new (const GPtrArray *parts);
+void _tp_signalled_message_set_sender (TpMessage *message,
+ TpContact *contact);
+
G_END_DECLS
#endif /* __TP_Signalled_MESSAGE_INTERNAL_H__ */
diff --git a/telepathy-glib/signalled-message.c b/telepathy-glib/signalled-message.c
index 2a9811580..f16105006 100644
--- a/telepathy-glib/signalled-message.c
+++ b/telepathy-glib/signalled-message.c
@@ -47,16 +47,18 @@ G_DEFINE_TYPE (TpSignalledMessage, tp_signalled_message, TP_TYPE_MESSAGE)
struct _TpSignalledMessagePrivate
{
- gpointer unused;
+ TpContact *sender;
};
static void
tp_signalled_message_dispose (GObject *object)
{
- //TpSignalledMessage *self = TP_SIGNALLED_MESSAGE (object);
+ TpSignalledMessage *self = TP_SIGNALLED_MESSAGE (object);
void (*dispose) (GObject *) =
G_OBJECT_CLASS (tp_signalled_message_parent_class)->dispose;
+ tp_clear_object (&self->priv->sender);
+
if (dispose != NULL)
dispose (object);
}
@@ -76,6 +78,8 @@ tp_signalled_message_init (TpSignalledMessage *self)
{
self->priv = G_TYPE_INSTANCE_GET_PRIVATE ((self), TP_TYPE_SIGNALLED_MESSAGE,
TpSignalledMessagePrivate);
+
+ self->priv->sender = NULL;
}
TpMessage *
@@ -103,3 +107,36 @@ _tp_signalled_message_new (const GPtrArray *parts)
return self;
}
+
+void
+_tp_signalled_message_set_sender (TpMessage *message,
+ TpContact *contact)
+{
+ TpSignalledMessage *self = TP_SIGNALLED_MESSAGE (message);
+
+ g_assert (self->priv->sender == NULL);
+ self->priv->sender = g_object_ref (contact);
+}
+
+/**
+ * tp_signalled_message_get_sender:
+ * @message: a #TpSignalledMessage
+ *
+ * Returns a #TpContact representing the sender of @message if known, %NULL
+ * otherwise.
+ *
+ * Returns: (transfer none): the sender of the message
+ *
+ * @since 0.13.UNRELEASED
+ */
+TpContact *
+tp_signalled_message_get_sender (TpMessage *message)
+{
+ TpSignalledMessage *self;
+
+ g_return_val_if_fail (TP_IS_SIGNALLED_MESSAGE (message), NULL);
+
+ self = (TpSignalledMessage *) message;
+
+ return self->priv->sender;
+}
diff --git a/telepathy-glib/signalled-message.h b/telepathy-glib/signalled-message.h
index e9c0618c0..ae7f9bd4f 100644
--- a/telepathy-glib/signalled-message.h
+++ b/telepathy-glib/signalled-message.h
@@ -25,6 +25,7 @@
G_BEGIN_DECLS
+#include <telepathy-glib/contact.h>
#include <telepathy-glib/message.h>
#define TP_TYPE_SIGNALLED_MESSAGE (tp_signalled_message_get_type ())
@@ -39,6 +40,8 @@ typedef struct _TpSignalledMessageClass TpSignalledMessageClass;
GType tp_signalled_message_get_type (void);
+TpContact * tp_signalled_message_get_sender (TpMessage *message);
+
G_END_DECLS
#endif /* __TP_SIGNALLED_MESSAGE_H__ */