diff -rN -u old-telepathy-gabble/src/capabilities.c new-telepathy-gabble/src/capabilities.c --- old-telepathy-gabble/src/capabilities.c 2008-01-31 19:10:34.000000000 +0100 +++ new-telepathy-gabble/src/capabilities.c 2008-01-31 19:10:35.000000000 +0100 @@ -37,6 +37,7 @@ { VERSION, NS_SI, PRESENCE_CAP_SI}, { VERSION, NS_IBB, PRESENCE_CAP_IBB}, { VERSION, NS_TUBES, PRESENCE_CAP_SI_TUBES}, + { VERSION, NS_VERSION, 0}, { BUNDLE_VOICE_V1, NS_GOOGLE_FEAT_VOICE, PRESENCE_CAP_GOOGLE_VOICE}, { BUNDLE_JINGLE_AUDIO, NS_JINGLE_DESCRIPTION_AUDIO, diff -rN -u old-telepathy-gabble/src/gabble-connection.c new-telepathy-gabble/src/gabble-connection.c --- old-telepathy-gabble/src/gabble-connection.c 2008-01-31 19:10:34.000000000 +0100 +++ new-telepathy-gabble/src/gabble-connection.c 2008-01-31 19:10:35.000000000 +0100 @@ -130,6 +130,7 @@ struct _GabbleConnectionPrivate { LmMessageHandler *iq_disco_cb; + LmMessageHandler *iq_version_cb; LmMessageHandler *iq_unknown_cb; LmMessageHandler *stream_error_cb; LmMessageHandler *msg_cb; @@ -734,6 +735,7 @@ g_assert (!lm_connection_is_open (self->lmconn)); g_assert (priv->iq_disco_cb == NULL); + g_assert (priv->iq_version_cb == NULL); g_assert (priv->iq_unknown_cb == NULL); g_assert (priv->stream_error_cb == NULL); g_assert (priv->msg_cb == NULL); @@ -999,6 +1001,8 @@ static LmHandlerResult connection_iq_disco_cb (LmMessageHandler *, LmConnection *, LmMessage *, gpointer); +static LmHandlerResult connection_iq_version_cb (LmMessageHandler *, + LmConnection *, LmMessage *, gpointer); static LmHandlerResult connection_iq_unknown_cb (LmMessageHandler *, LmConnection *, LmMessage *, gpointer); static LmHandlerResult connection_stream_error_cb (LmMessageHandler *, @@ -1042,6 +1046,7 @@ GabbleConnectionPrivate *priv = GABBLE_CONNECTION_GET_PRIVATE (conn); g_assert (priv->iq_disco_cb == NULL); + g_assert (priv->iq_version_cb == NULL); g_assert (priv->iq_unknown_cb == NULL); g_assert (priv->stream_error_cb == NULL); g_assert (priv->msg_cb == NULL); @@ -1052,6 +1057,12 @@ LM_MESSAGE_TYPE_IQ, LM_HANDLER_PRIORITY_NORMAL); + priv->iq_version_cb = lm_message_handler_new (connection_iq_version_cb, + conn, NULL); + lm_connection_register_message_handler (conn->lmconn, priv->iq_version_cb, + LM_MESSAGE_TYPE_IQ, + LM_HANDLER_PRIORITY_FIRST); + priv->iq_unknown_cb = lm_message_handler_new (connection_iq_unknown_cb, conn, NULL); lm_connection_register_message_handler (conn->lmconn, priv->iq_unknown_cb, @@ -1069,6 +1080,7 @@ lm_connection_register_message_handler (conn->lmconn, priv->msg_cb, LM_MESSAGE_TYPE_MESSAGE, LM_HANDLER_PRIORITY_FIRST); + } static void @@ -1078,6 +1090,7 @@ GabbleConnectionPrivate *priv = GABBLE_CONNECTION_GET_PRIVATE (conn); g_assert (priv->iq_disco_cb != NULL); + g_assert (priv->iq_version_cb != NULL); g_assert (priv->iq_unknown_cb != NULL); g_assert (priv->stream_error_cb != NULL); g_assert (priv->msg_cb != NULL); @@ -1087,6 +1100,11 @@ lm_message_handler_unref (priv->iq_disco_cb); priv->iq_disco_cb = NULL; + lm_connection_unregister_message_handler (conn->lmconn, priv->iq_version_cb, + LM_MESSAGE_TYPE_IQ); + lm_message_handler_unref (priv->iq_version_cb); + priv->iq_version_cb = NULL; + lm_connection_unregister_message_handler (conn->lmconn, priv->iq_unknown_cb, LM_MESSAGE_TYPE_IQ); lm_message_handler_unref (priv->iq_unknown_cb); @@ -1534,6 +1552,64 @@ return LM_HANDLER_RESULT_REMOVE_MESSAGE; } + +/** + * connection_iq_version_cb + * + * Called by loudmouth when we get an incoming . This handler handles + * jabber:iq:version-related IQs (XEP 0092). + */ +static LmHandlerResult +connection_iq_version_cb (LmMessageHandler *handler, + LmConnection *connection, + LmMessage *message, + gpointer user_data) +{ + GabbleConnection *self = GABBLE_CONNECTION (user_data); + const gchar *id; + LmMessage *result; + LmMessageNode *iq; + + if (lm_message_get_sub_type (message) != LM_MESSAGE_SUB_TYPE_GET) + return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS; + + if (lm_message_node_get_attribute (iq, "from") != NULL) + return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS; + + iq = lm_message_get_node (message); + + if (! lm_message_node_get_child_with_namespace (iq, "query", NS_VERSION)) + return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS; + + id = lm_message_node_get_attribute (iq, "id"); + if (id == NULL) + { + NODE_DEBUG (iq, "can't acknowledge IQ with no id"); + return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS; + } + + result = lm_message_build (lm_message_node_get_attribute (iq, "from"), + LM_MESSAGE_TYPE_IQ, + '@', "type", "result", + '@', "id", id, + '(', "query", "", + '@', "xmlns", NS_VERSION, + '(', "version", VERSION, ')', + '(', "name", "Telepathy-gabble", ')', + ')', NULL); + + + if (!lm_connection_send (self->lmconn, result, NULL)) + { + DEBUG ("sending disco response failed"); + } + + lm_message_unref (result); + + return LM_HANDLER_RESULT_REMOVE_MESSAGE; +} + + /** * connection_iq_unknown_cb * diff -rN -u old-telepathy-gabble/src/namespaces.h new-telepathy-gabble/src/namespaces.h --- old-telepathy-gabble/src/namespaces.h 2008-01-31 19:10:34.000000000 +0100 +++ new-telepathy-gabble/src/namespaces.h 2008-01-31 19:10:35.000000000 +0100 @@ -67,6 +67,7 @@ #define NS_TUBES "http://telepathy.freedesktop.org/xmpp/tubes" #define NS_VCARD_TEMP "vcard-temp" #define NS_VCARD_TEMP_UPDATE "vcard-temp:x:update" +#define NS_VERSION "jabber:iq:version" #define NS_X_DATA "jabber:x:data" #define NS_X_DELAY "jabber:x:delay" #define NS_X_CONFERENCE "jabber:x:conference"