summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikhail Zabaluev <mikhail.zabaluev@nokia.com>2010-11-03 16:47:58 +0200
committerMikhail Zabaluev <mikhail.zabaluev@nokia.com>2010-11-03 16:47:58 +0200
commit6b3085a3e3f0a310dc0625d8fd0e5b62241efd10 (patch)
tree882d502c11524714104ea46d81174e8f08dbe1a7
parent1c9931a882038ac20ab45fe6de015cb8b76a841b (diff)
Offer the header "message-token" on received messages in chan.I.Messages
-rw-r--r--src/sip-text-channel.c16
-rw-r--r--src/sip-text-channel.h2
-rw-r--r--src/text-factory.c2
3 files changed, 17 insertions, 3 deletions
diff --git a/src/sip-text-channel.c b/src/sip-text-channel.c
index 23159fd..211f796 100644
--- a/src/sip-text-channel.c
+++ b/src/sip-text-channel.c
@@ -43,6 +43,7 @@
#include "sip-connection.h"
#include "sip-connection-helpers.h"
+#include <sofia-sip/sip_protos.h>
#include <sofia-sip/sip_status.h>
#define DEBUG_FLAG TPSIP_DEBUG_IM
@@ -880,7 +881,7 @@ tpsip_text_channel_nua_r_message_cb (TpsipTextChannel *self,
}
void tpsip_text_channel_receive(TpsipTextChannel *chan,
- nua_t *nua,
+ const sip_t *sip,
TpHandle sender,
const char *text,
gsize len)
@@ -888,6 +889,8 @@ void tpsip_text_channel_receive(TpsipTextChannel *chan,
TpsipTextChannelPrivate *priv = TPSIP_TEXT_CHANNEL_GET_PRIVATE (chan);
TpMessage *msg;
TpBaseConnection *base_conn;
+ sip_call_id_t *hdr_call_id;
+ sip_cseq_t *hdr_cseq;
base_conn = (TpBaseConnection *) priv->conn;
msg = tp_message_new (base_conn, 2, 2);
@@ -899,6 +902,17 @@ void tpsip_text_channel_receive(TpsipTextChannel *chan,
sender);
tp_message_set_uint64 (msg, 0, "message-received", time (NULL));
+ /* Create a message token out of globally unique SIP header values.
+ * As MESSAGE requests can be sent within a dialog, we have to append
+ * the Call-ID value with the sequence number in CSeq. */
+ hdr_call_id = sip_call_id (sip);
+ hdr_cseq = sip_cseq (sip);
+ if (hdr_call_id != NULL && hdr_cseq != NULL)
+ {
+ tp_message_set_string_printf(msg, 0, "message-token", "%s;cseq=%u",
+ hdr_call_id->i_id, (guint) hdr_cseq->cs_seq);
+ }
+
/* Body */
tp_message_set_string (msg, 1, "content-type", "text/plain");
tp_message_set_string (msg, 1, "content", text);
diff --git a/src/sip-text-channel.h b/src/sip-text-channel.h
index 98db60d..4be5d51 100644
--- a/src/sip-text-channel.h
+++ b/src/sip-text-channel.h
@@ -62,7 +62,7 @@ GType tpsip_text_channel_get_type(void);
(G_TYPE_INSTANCE_GET_CLASS ((obj), TPSIP_TYPE_TEXT_CHANNEL, TpsipTextChannelClass))
void tpsip_text_channel_receive (TpsipTextChannel *obj,
- nua_t *nua,
+ const sip_t *sip,
TpHandle sender,
const char *text,
gsize len);
diff --git a/src/text-factory.c b/src/text-factory.c
index 881891e..36730de 100644
--- a/src/text-factory.c
+++ b/src/text-factory.c
@@ -586,7 +586,7 @@ tpsip_nua_i_message_cb (TpBaseConnection *conn,
handle, handle, NULL);
tpsip_text_channel_receive (channel,
- ev->nua, handle, text, len);
+ sip, handle, text, len);
tp_handle_unref (contact_repo, handle);