Mercurial > pidgin
comparison libpurple/protocols/jabber/ping.c @ 17835: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 | |
children | 413103ddeaac |
comparison
equal
deleted
inserted
replaced
17834:a75079eae085 | 17835:6ab1089e2101 |
---|---|
1 /* | |
2 * purple - Jabber Protocol Plugin | |
3 * | |
4 * Copyright (C) 2003, Nathan Walp <faceprint@faceprint.com> | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * | |
15 * GNU General Public License for more details. | |
16 * | |
17 * You should have received a copy of the GNU General Public License | |
18 * along with this program; if not, write to the Free Software | |
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
20 * | |
21 */ | |
22 | |
23 #include "internal.h" | |
24 | |
25 #include "debug.h" | |
26 #include "xmlnode.h" | |
27 | |
28 #include "jabber.h" | |
29 #include "ping.h" | |
30 #include "iq.h" | |
31 | |
32 void | |
33 jabber_ping_parse(JabberStream *js, xmlnode *packet) | |
34 { | |
35 JabberIq *iq; | |
36 | |
37 purple_debug_info("jabber", "jabber_ping_parse\n"); | |
38 | |
39 iq = jabber_iq_new(js, JABBER_IQ_RESULT); | |
40 | |
41 xmlnode_set_attrib(iq->node, "to", xmlnode_get_attrib(packet, "from") ); | |
42 | |
43 jabber_iq_set_id(iq, xmlnode_get_attrib(packet, "id")); | |
44 | |
45 jabber_iq_send(iq); | |
46 } | |
47 | |
48 static void jabber_ping_result_cb(JabberStream *js, xmlnode *packet, | |
49 gpointer data) | |
50 { | |
51 const char *type = xmlnode_get_attrib(packet, "type"); | |
52 | |
53 purple_debug_info("jabber", "jabber_ping_result_cb\n"); | |
54 if(type && !strcmp(type, "result")) { | |
55 purple_debug_info("jabber", "PONG!\n"); | |
56 } else { | |
57 purple_debug_info("jabber", "(not supported)\n"); | |
58 } | |
59 } | |
60 | |
61 gboolean jabber_ping_jid(PurpleConversation *conv, const char *jid) | |
62 { | |
63 JabberIq *iq; | |
64 xmlnode *ping; | |
65 | |
66 purple_debug_info("jabber", "jabber_ping_jid\n"); | |
67 | |
68 iq = jabber_iq_new(conv->account->gc->proto_data, JABBER_IQ_GET); | |
69 xmlnode_set_attrib(iq->node, "to", jid); | |
70 | |
71 ping = xmlnode_new_child(iq->node, "ping"); | |
72 xmlnode_set_namespace(ping, "http://www.xmpp.org/extensions/xep-0199.html#ns"); | |
73 | |
74 jabber_iq_set_callback(iq, jabber_ping_result_cb, NULL); | |
75 jabber_iq_send(iq); | |
76 | |
77 | |
78 | |
79 return TRUE; | |
80 } |