[Telepathy-commits] [telepathy-gabble/master] add conn_olpc_msg_cb message handler
Guillaume Desmottes
guillaume.desmottes at collabora.co.uk
Fri Sep 26 10:01:56 PDT 2008
20071206153657-7fe3f-9afd3a78dfd71b5fc4c073134fab080902b0b965.gz
---
src/conn-olpc.c | 16 ++++++++++++++++
src/conn-olpc.h | 3 +++
src/connection.c | 15 +++++++++++++++
3 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/src/conn-olpc.c b/src/conn-olpc.c
index 6f1f6d8..c7c2a75 100644
--- a/src/conn-olpc.c
+++ b/src/conn-olpc.c
@@ -2585,6 +2585,22 @@ connection_presence_do_update (GabblePresenceCache *cache,
}
}
+LmHandlerResult
+conn_olpc_msg_cb (LmMessageHandler *handler,
+ LmConnection *connection,
+ LmMessage *message,
+ gpointer user_data)
+{
+ const gchar *from;
+
+ from = lm_message_node_get_attribute (message->node, "from");
+ /* FIXME: we shouldn't hardcode that */
+ if (tp_strdiff (from, "index.jabber.laptop.org"))
+ return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
+
+ return LM_HANDLER_RESULT_REMOVE_MESSAGE;
+}
+
static void
connection_presences_updated_cb (GabblePresenceCache *cache,
GArray *handles,
diff --git a/src/conn-olpc.h b/src/conn-olpc.h
index 081e9be..4b9e796 100644
--- a/src/conn-olpc.h
+++ b/src/conn-olpc.h
@@ -57,5 +57,8 @@ gboolean conn_olpc_process_activity_properties_message (GabbleConnection *conn,
gboolean conn_olpc_process_activity_uninvite_message (GabbleConnection *conn,
LmMessage *msg, const gchar *from);
+LmHandlerResult conn_olpc_msg_cb (LmMessageHandler *handler,
+ LmConnection *connection, LmMessage *message, gpointer user_data);
+
#endif /* __CONN_OLPC_H__ */
diff --git a/src/connection.c b/src/connection.c
index f9077a1..e451490 100644
--- a/src/connection.c
+++ b/src/connection.c
@@ -137,6 +137,7 @@ struct _GabbleConnectionPrivate
LmMessageHandler *iq_unknown_cb;
LmMessageHandler *stream_error_cb;
LmMessageHandler *pubsub_msg_cb;
+ LmMessageHandler *olpc_msg_cb;
/* connection properties */
gchar *connect_server;
@@ -761,6 +762,7 @@ gabble_connection_dispose (GObject *object)
g_assert (priv->iq_unknown_cb == NULL);
g_assert (priv->stream_error_cb == NULL);
g_assert (priv->pubsub_msg_cb == NULL);
+ g_assert (priv->olpc_msg_cb == NULL);
/*
* The Loudmouth connection can't be unref'd immediately because this
@@ -1073,6 +1075,7 @@ connect_callbacks (TpBaseConnection *base)
g_assert (priv->iq_unknown_cb == NULL);
g_assert (priv->stream_error_cb == NULL);
g_assert (priv->pubsub_msg_cb == NULL);
+ g_assert (priv->olpc_msg_cb == NULL);
priv->iq_disco_cb = lm_message_handler_new (connection_iq_disco_cb,
conn, NULL);
@@ -1097,6 +1100,12 @@ connect_callbacks (TpBaseConnection *base)
lm_connection_register_message_handler (conn->lmconn, priv->pubsub_msg_cb,
LM_MESSAGE_TYPE_MESSAGE,
LM_HANDLER_PRIORITY_FIRST);
+
+ priv->olpc_msg_cb = lm_message_handler_new (conn_olpc_msg_cb,
+ conn, NULL);
+ lm_connection_register_message_handler (conn->lmconn, priv->olpc_msg_cb,
+ LM_MESSAGE_TYPE_MESSAGE,
+ LM_HANDLER_PRIORITY_FIRST);
}
static void
@@ -1109,6 +1118,7 @@ disconnect_callbacks (TpBaseConnection *base)
g_assert (priv->iq_unknown_cb != NULL);
g_assert (priv->stream_error_cb != NULL);
g_assert (priv->pubsub_msg_cb != NULL);
+ g_assert (priv->olpc_msg_cb != NULL);
lm_connection_unregister_message_handler (conn->lmconn, priv->iq_disco_cb,
LM_MESSAGE_TYPE_IQ);
@@ -1129,6 +1139,11 @@ disconnect_callbacks (TpBaseConnection *base)
LM_MESSAGE_TYPE_MESSAGE);
lm_message_handler_unref (priv->pubsub_msg_cb);
priv->pubsub_msg_cb = NULL;
+
+ lm_connection_unregister_message_handler (conn->lmconn, priv->olpc_msg_cb,
+ LM_MESSAGE_TYPE_MESSAGE);
+ lm_message_handler_unref (priv->olpc_msg_cb);
+ priv->olpc_msg_cb = NULL;
}
/**
--
1.5.6.5
More information about the Telepathy-commits
mailing list