diff -rN -u old-telepathy-gabble/src/capabilities.c new-telepathy-gabble/src/capabilities.c --- old-telepathy-gabble/src/capabilities.c 2007-06-17 12:01:39.000000000 +0200 +++ new-telepathy-gabble/src/capabilities.c 2007-06-17 12:01:39.000000000 +0200 @@ -34,6 +34,7 @@ { VERSION, NS_CHAT_STATES, PRESENCE_CAP_CHAT_STATES}, { VERSION, NS_NICK, 0}, { VERSION, NS_NICK "+notify", 0}, + { VERSION, NS_VERSION, 0}, { VERSION, NS_OLPC_BUDDY_PROPS, 0}, { VERSION, NS_OLPC_BUDDY_PROPS "+notify", 0}, { VERSION, NS_OLPC_ACTIVITIES, 0}, diff -rN -u old-telepathy-gabble/src/gabble-connection.c new-telepathy-gabble/src/gabble-connection.c --- old-telepathy-gabble/src/gabble-connection.c 2007-06-17 12:01:39.000000000 +0200 +++ new-telepathy-gabble/src/gabble-connection.c 2007-06-17 12:01:39.000000000 +0200 @@ -134,6 +134,7 @@ struct _GabbleConnectionPrivate { LmMessageHandler *iq_disco_cb; + LmMessageHandler *iq_version_cb; LmMessageHandler *iq_unknown_cb; LmMessageHandler *stream_error_cb; LmMessageHandler *msg_cb; @@ -729,6 +730,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); @@ -994,6 +996,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 *, @@ -1037,6 +1041,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); @@ -1047,6 +1052,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, @@ -1064,6 +1075,7 @@ lm_connection_register_message_handler (conn->lmconn, priv->msg_cb, LM_MESSAGE_TYPE_MESSAGE, LM_HANDLER_PRIORITY_FIRST); + } static void @@ -1073,6 +1085,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); @@ -1082,6 +1095,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); @@ -1657,6 +1675,48 @@ 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); + LmMessage *result; + LmMessageNode *iq, *result_iq, *query, *result_query, *name, *version; + if (lm_message_get_sub_type (message) != LM_MESSAGE_SUB_TYPE_GET) + return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS; + + iq = lm_message_get_node (message); + query = lm_message_node_get_child_with_namespace (iq, "query", + NS_VERSION); + + if (!query) + return LM_HANDLER_RESULT_ALLOW_MORE_HANDLERS; + result = _lm_iq_message_make_result (message); + result_iq = lm_message_get_node (result); + result_query = lm_message_node_add_child (result_iq, "query", NULL); + lm_message_node_set_attribute (result_query, "xmlns", NS_VERSION); + + version = lm_message_node_add_child (result_query, "version", VERSION); + name = lm_message_node_add_child (result_query, "name", "Telepathy-gabble"); + 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 2007-06-17 12:01:39.000000000 +0200 +++ new-telepathy-gabble/src/namespaces.h 2007-06-17 12:01:39.000000000 +0200 @@ -60,6 +60,7 @@ #define NS_ROSTER "jabber:iq:roster" #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"