summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonny Lamb <jonny.lamb@collabora.co.uk>2011-03-31 09:32:42 +0100
committerJonny Lamb <jonny.lamb@collabora.co.uk>2011-03-31 11:08:33 +0100
commit3db9f852cb1cef9fea984cc52bbe8b24a9903237 (patch)
treecb1dd726594abb278a3268c2d49ae3f5fae69617
parentafcf1727d6fe7a5a0123c47034165bd87e7679ca (diff)
meta-porter: store the contact JID on the actual C2S porter object
Signed-off-by: Jonny Lamb <jonny.lamb@collabora.co.uk>
-rw-r--r--wocky/wocky-meta-porter.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/wocky/wocky-meta-porter.c b/wocky/wocky-meta-porter.c
index 75362de..cd68354 100644
--- a/wocky/wocky-meta-porter.c
+++ b/wocky/wocky-meta-porter.c
@@ -50,6 +50,9 @@ enum
PROP_RESOURCE,
};
+#define PORTER_JID_QUARK \
+ (g_quark_from_static_string ("wocky-meta-porter-c2s-jid"))
+
/* private structure */
struct _WockyMetaPorterPrivate
{
@@ -260,6 +263,13 @@ create_porter (WockyMetaPorter *self,
g_hash_table_insert (priv->porters, g_object_ref (contact), data);
}
+ /* we need to set this so when we get a stanza in from a porter with
+ * no from attribute we can find the real originating contact. The
+ * StanzaHandler struct doesn't reference the PorterData struct, so
+ * we simply store its jid here now. */
+ g_object_set_qdata_full (G_OBJECT (data->porter), PORTER_JID_QUARK,
+ g_strdup (data->jid), g_free);
+
g_signal_connect (data->porter, "closing", G_CALLBACK (porter_closing_cb),
data);
g_signal_connect (data->porter, "remote-closed",
@@ -1043,8 +1053,13 @@ porter_handler_cb (WockyPorter *porter,
WockyLLContact *contact;
const gchar *from;
+ /* prefer the from attribute over ignoring it and using the porter
+ * JID */
from = wocky_stanza_get_from (stanza);
+ if (from == NULL)
+ from = g_object_get_qdata (G_OBJECT (porter), PORTER_JID_QUARK);
+
contact = wocky_contact_factory_ensure_ll_contact (
priv->contact_factory, from);