Mercurial > pidgin.yaz
changeset 17562:6ab1089e2101
applied patch for supporting XEP-0199: XMPP Ping
author | Andreas Monitzer <pidgin@monitzer.com> |
---|---|
date | Wed, 06 Jun 2007 00:04:29 +0000 |
parents | a75079eae085 |
children | 95affacf6f82 |
files | libpurple/protocols/jabber/Makefile.am libpurple/protocols/jabber/Makefile.mingw libpurple/protocols/jabber/disco.c libpurple/protocols/jabber/iq.c libpurple/protocols/jabber/jabber.c libpurple/protocols/jabber/jabber.h libpurple/protocols/jabber/jutil.h libpurple/protocols/jabber/ping.c libpurple/protocols/jabber/ping.h |
diffstat | 9 files changed, 155 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/protocols/jabber/Makefile.am Wed Jun 06 00:01:15 2007 +0000 +++ b/libpurple/protocols/jabber/Makefile.am Wed Jun 06 00:04:29 2007 +0000 @@ -27,6 +27,8 @@ oob.h \ parser.c \ parser.h \ + ping.c \ + ping.h \ presence.c \ presence.h \ roster.c \
--- a/libpurple/protocols/jabber/Makefile.mingw Wed Jun 06 00:01:15 2007 +0000 +++ b/libpurple/protocols/jabber/Makefile.mingw Wed Jun 06 00:04:29 2007 +0000 @@ -53,6 +53,7 @@ message.c \ oob.c \ parser.c \ + ping.c \ presence.c \ roster.c \ si.c \
--- a/libpurple/protocols/jabber/disco.c Wed Jun 06 00:01:15 2007 +0000 +++ b/libpurple/protocols/jabber/disco.c Wed Jun 06 00:04:29 2007 +0000 @@ -97,6 +97,7 @@ SUPPORT_FEATURE("http://jabber.org/protocol/si") SUPPORT_FEATURE("http://jabber.org/protocol/si/profile/file-transfer") SUPPORT_FEATURE("http://jabber.org/protocol/xhtml-im") + SUPPORT_FEATURE("http://www.xmpp.org/extensions/xep-0199.html#ns") } else { xmlnode *error, *inf; @@ -164,6 +165,8 @@ capabilities |= JABBER_CAP_IQ_SEARCH; else if(!strcmp(var, "jabber:iq:register")) capabilities |= JABBER_CAP_IQ_REGISTER; + else if(!strcmp(var, "http://www.xmpp.org/extensions/xep-0199.html#ns")) + capabilities |= JABBER_CAP_PING; } }
--- a/libpurple/protocols/jabber/iq.c Wed Jun 06 00:01:15 2007 +0000 +++ b/libpurple/protocols/jabber/iq.c Wed Jun 06 00:04:29 2007 +0000 @@ -30,6 +30,7 @@ #include "oob.h" #include "roster.h" #include "si.h" +#include "ping.h" #ifdef _WIN32 #include "utsname.h" @@ -290,6 +291,13 @@ return; } + purple_debug_info("jabber", "jabber_iq_parse\n"); + + if(xmlnode_get_child_with_namespace(packet, "ping", "http://www.xmpp.org/extensions/xep-0199.html#ns")) { + jabber_ping_parse(js, packet); + return; + } + /* If we get here, send the default error reply mandated by XMPP-CORE */ if(type && (!strcmp(type, "set") || !strcmp(type, "get"))) { JabberIq *iq = jabber_iq_new(js, JABBER_IQ_ERROR);
--- a/libpurple/protocols/jabber/jabber.c Wed Jun 06 00:01:15 2007 +0000 +++ b/libpurple/protocols/jabber/jabber.c Wed Jun 06 00:04:29 2007 +0000 @@ -51,6 +51,7 @@ #include "presence.h" #include "jabber.h" #include "roster.h" +#include "ping.h" #include "si.h" #include "xdata.h" #include "pep.h" @@ -1791,6 +1792,20 @@ return PURPLE_CMD_RET_OK; } +static PurpleCmdRet jabber_cmd_ping(PurpleConversation *conv, + const char *cmd, char **args, char **error, void *data) +{ + if(!args || !args[0]) + return PURPLE_CMD_RET_FAILED; + + if(!jabber_ping_jid(conv, args[0])) { + *error = g_strdup_printf(_("Unable to ping user %s"), args[0]); + return PURPLE_CMD_RET_FAILED; + } + + return PURPLE_CMD_RET_OK; +} + gboolean jabber_offline_message(const PurpleBuddy *buddy) { return TRUE; @@ -1868,6 +1883,13 @@ "prpl-jabber", jabber_cmd_chat_msg, _("msg <user> <message>: Send a private message to another user."), NULL); + purple_cmd_register("ping", "w", PURPLE_CMD_P_PRPL, + PURPLE_CMD_FLAG_CHAT | PURPLE_CMD_FLAG_IM | + PURPLE_CMD_FLAG_PRPL_ONLY, + "prpl-jabber", jabber_cmd_ping, + _("ping <jid>: Ping a user/component/server."), + NULL); + } void
--- a/libpurple/protocols/jabber/jabber.h Wed Jun 06 00:01:15 2007 +0000 +++ b/libpurple/protocols/jabber/jabber.h Wed Jun 06 00:04:29 2007 +0000 @@ -57,6 +57,8 @@ JABBER_CAP_GMAIL_NOTIFY = 1 << 9, JABBER_CAP_GOOGLE_ROSTER = 1 << 10, + JABBER_CAP_PING = 1 << 11, + JABBER_CAP_RETRIEVED = 1 << 31 } JabberCapabilities;
--- a/libpurple/protocols/jabber/jutil.h Wed Jun 06 00:01:15 2007 +0000 +++ b/libpurple/protocols/jabber/jutil.h Wed Jun 06 00:04:29 2007 +0000 @@ -22,6 +22,8 @@ #ifndef _PURPLE_JABBER_JUTIL_H_ #define _PURPLE_JABBER_JUTIL_H_ +#include "account.h" + typedef struct _JabberID { char *node; char *domain;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libpurple/protocols/jabber/ping.c Wed Jun 06 00:04:29 2007 +0000 @@ -0,0 +1,80 @@ +/* + * purple - Jabber Protocol Plugin + * + * Copyright (C) 2003, Nathan Walp <faceprint@faceprint.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + +#include "internal.h" + +#include "debug.h" +#include "xmlnode.h" + +#include "jabber.h" +#include "ping.h" +#include "iq.h" + +void +jabber_ping_parse(JabberStream *js, xmlnode *packet) +{ + JabberIq *iq; + + purple_debug_info("jabber", "jabber_ping_parse\n"); + + iq = jabber_iq_new(js, JABBER_IQ_RESULT); + + xmlnode_set_attrib(iq->node, "to", xmlnode_get_attrib(packet, "from") ); + + jabber_iq_set_id(iq, xmlnode_get_attrib(packet, "id")); + + jabber_iq_send(iq); +} + +static void jabber_ping_result_cb(JabberStream *js, xmlnode *packet, + gpointer data) +{ + const char *type = xmlnode_get_attrib(packet, "type"); + + purple_debug_info("jabber", "jabber_ping_result_cb\n"); + if(type && !strcmp(type, "result")) { + purple_debug_info("jabber", "PONG!\n"); + } else { + purple_debug_info("jabber", "(not supported)\n"); + } +} + +gboolean jabber_ping_jid(PurpleConversation *conv, const char *jid) +{ + JabberIq *iq; + xmlnode *ping; + + purple_debug_info("jabber", "jabber_ping_jid\n"); + + iq = jabber_iq_new(conv->account->gc->proto_data, JABBER_IQ_GET); + xmlnode_set_attrib(iq->node, "to", jid); + + ping = xmlnode_new_child(iq->node, "ping"); + xmlnode_set_namespace(ping, "http://www.xmpp.org/extensions/xep-0199.html#ns"); + + jabber_iq_set_callback(iq, jabber_ping_result_cb, NULL); + jabber_iq_send(iq); + + + + return TRUE; +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/libpurple/protocols/jabber/ping.h Wed Jun 06 00:04:29 2007 +0000 @@ -0,0 +1,35 @@ +/** + * @file ping.h utility functions + * + * purple + * + * Copyright (C) 2003, Nathan Walp <faceprint@faceprint.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef _PURPLE_JABBER_PING_H_ +#define _PURPLE_JABBER_PING_H_ + +#include "jabber.h" +#include "conversation.h" + +void jabber_ping_parse(JabberStream *js, + xmlnode *packet); + + +gboolean jabber_ping_jid(PurpleConversation *conv, const char *jid); + + +#endif /* _PURPLE_JABBER_PING_H_ */