Tue, 21 Mar 2023 02:07:16 -0500
Remove libsoup2 code
Soup 3 has been required since /r/2068.
Testing Done:
Compiled only.
Reviewed at https://reviews.imfreedom.org/r/2375/
|
17769
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
1 | /* |
|
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
2 | * purple - Jabber Protocol Plugin |
|
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
3 | * |
|
28322
ac8fec1d2234
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents:
28321
diff
changeset
|
4 | * Purple is the legal property of its developers, whose names are too numerous |
|
ac8fec1d2234
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents:
28321
diff
changeset
|
5 | * to list here. Please refer to the COPYRIGHT file distributed with this |
|
ac8fec1d2234
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents:
28321
diff
changeset
|
6 | * source distribution. |
|
17769
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
7 | * |
|
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
8 | * This program is free software; you can redistribute it and/or modify |
|
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
9 | * it under the terms of the GNU General Public License as published by |
|
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
10 | * the Free Software Foundation; either version 2 of the License, or |
|
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
11 | * (at your option) any later version. |
|
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
12 | * |
|
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
13 | * This program is distributed in the hope that it will be useful, |
|
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
16 | * |
|
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
17 | * GNU General Public License for more details. |
|
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
18 | * |
|
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
19 | * You should have received a copy of the GNU General Public License |
|
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
20 | * along with this program; if not, write to the Free Software |
|
28321
c8d617c408ab
Update various header copyrights thanks to licensecheck.
Paul Aurich <darkrain42@pidgin.im>
parents:
27435
diff
changeset
|
21 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
|
17769
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
22 | * |
|
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
23 | */ |
|
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
24 | |
|
40358
e6fe6fc1f516
move all protocols, purple plugins, and purple tests to use purple.h instead of including files individually
Gary Kramlich <grim@reaperworld.com>
parents:
38433
diff
changeset
|
25 | #include <purple.h> |
|
17769
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
26 | |
|
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
27 | #include "jabber.h" |
|
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
28 | #include "ping.h" |
|
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
29 | #include "iq.h" |
|
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
30 | |
|
41967
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40439
diff
changeset
|
31 | static void |
|
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40439
diff
changeset
|
32 | jabber_keepalive_pong_cb(JabberStream *js, G_GNUC_UNUSED const char *from, |
|
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40439
diff
changeset
|
33 | G_GNUC_UNUSED JabberIqType type, |
|
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40439
diff
changeset
|
34 | G_GNUC_UNUSED const char *id, |
|
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40439
diff
changeset
|
35 | G_GNUC_UNUSED PurpleXmlNode *packet, |
|
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40439
diff
changeset
|
36 | G_GNUC_UNUSED gpointer data) |
|
25555
dd0cb987435f
Make the XMPP keepalive use jabber_ping_jid instead of building it itself.
Paul Aurich <darkrain42@pidgin.im>
parents:
25554
diff
changeset
|
37 | { |
|
42175
4185b4043214
Use g_clear_handle_id everywhere
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
41967
diff
changeset
|
38 | g_clear_handle_id(&js->keepalive_timeout, g_source_remove); |
|
25555
dd0cb987435f
Make the XMPP keepalive use jabber_ping_jid instead of building it itself.
Paul Aurich <darkrain42@pidgin.im>
parents:
25554
diff
changeset
|
39 | } |
|
dd0cb987435f
Make the XMPP keepalive use jabber_ping_jid instead of building it itself.
Paul Aurich <darkrain42@pidgin.im>
parents:
25554
diff
changeset
|
40 | |
|
17769
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
41 | void |
|
41967
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40439
diff
changeset
|
42 | jabber_ping_parse(JabberStream *js, const char *from, JabberIqType type, |
|
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40439
diff
changeset
|
43 | const char *id, G_GNUC_UNUSED PurpleXmlNode *ping) |
|
17769
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
44 | { |
|
25817
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
25814
diff
changeset
|
45 | if (type == JABBER_IQ_GET) { |
|
25554
53e161fc0658
Jabber IQ handlers should handle non-query child nodes
Paul Aurich <darkrain42@pidgin.im>
parents:
18911
diff
changeset
|
46 | JabberIq *iq = jabber_iq_new(js, JABBER_IQ_RESULT); |
|
17769
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
47 | |
|
25818
d087a2754595
Avoid assertion failures on NULL 'from' attributes
Paul Aurich <darkrain42@pidgin.im>
parents:
25817
diff
changeset
|
48 | if (from) |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
28979
diff
changeset
|
49 | purple_xmlnode_set_attrib(iq->node, "to", from); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
28979
diff
changeset
|
50 | purple_xmlnode_set_attrib(iq->node, "id", id); |
|
17769
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
51 | |
|
25554
53e161fc0658
Jabber IQ handlers should handle non-query child nodes
Paul Aurich <darkrain42@pidgin.im>
parents:
18911
diff
changeset
|
52 | jabber_iq_send(iq); |
|
25817
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
25814
diff
changeset
|
53 | } else if (type == JABBER_IQ_SET) { |
|
25554
53e161fc0658
Jabber IQ handlers should handle non-query child nodes
Paul Aurich <darkrain42@pidgin.im>
parents:
18911
diff
changeset
|
54 | /* XXX: error */ |
|
53e161fc0658
Jabber IQ handlers should handle non-query child nodes
Paul Aurich <darkrain42@pidgin.im>
parents:
18911
diff
changeset
|
55 | } |
|
17769
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
56 | } |
|
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
57 | |
|
41967
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40439
diff
changeset
|
58 | static void |
|
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40439
diff
changeset
|
59 | jabber_ping_result_cb(G_GNUC_UNUSED JabberStream *js, |
|
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40439
diff
changeset
|
60 | G_GNUC_UNUSED const char *from, JabberIqType type, |
|
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40439
diff
changeset
|
61 | G_GNUC_UNUSED const char *id, |
|
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40439
diff
changeset
|
62 | G_GNUC_UNUSED PurpleXmlNode *packet, |
|
025eee9e6f1d
Bump C standard to C99 for XMPP and fix warnings
Elliott Sales de Andrade <quantum.analyst@gmail.com>
parents:
40439
diff
changeset
|
63 | G_GNUC_UNUSED gpointer data) |
|
17769
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
64 | { |
|
27143
977add4a215e
Stop trying to be clever with XMPP keepalive pings.
Paul Aurich <darkrain42@pidgin.im>
parents:
26983
diff
changeset
|
65 | if (type == JABBER_IQ_RESULT) |
|
977add4a215e
Stop trying to be clever with XMPP keepalive pings.
Paul Aurich <darkrain42@pidgin.im>
parents:
26983
diff
changeset
|
66 | purple_debug_info("jabber", "PONG!\n"); |
|
977add4a215e
Stop trying to be clever with XMPP keepalive pings.
Paul Aurich <darkrain42@pidgin.im>
parents:
26983
diff
changeset
|
67 | else |
|
977add4a215e
Stop trying to be clever with XMPP keepalive pings.
Paul Aurich <darkrain42@pidgin.im>
parents:
26983
diff
changeset
|
68 | purple_debug_info("jabber", "ping not supported\n"); |
|
977add4a215e
Stop trying to be clever with XMPP keepalive pings.
Paul Aurich <darkrain42@pidgin.im>
parents:
26983
diff
changeset
|
69 | } |
|
977add4a215e
Stop trying to be clever with XMPP keepalive pings.
Paul Aurich <darkrain42@pidgin.im>
parents:
26983
diff
changeset
|
70 | |
|
977add4a215e
Stop trying to be clever with XMPP keepalive pings.
Paul Aurich <darkrain42@pidgin.im>
parents:
26983
diff
changeset
|
71 | void jabber_keepalive_ping(JabberStream *js) |
|
977add4a215e
Stop trying to be clever with XMPP keepalive pings.
Paul Aurich <darkrain42@pidgin.im>
parents:
26983
diff
changeset
|
72 | { |
|
977add4a215e
Stop trying to be clever with XMPP keepalive pings.
Paul Aurich <darkrain42@pidgin.im>
parents:
26983
diff
changeset
|
73 | JabberIq *iq; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
28979
diff
changeset
|
74 | PurpleXmlNode *ping; |
|
27143
977add4a215e
Stop trying to be clever with XMPP keepalive pings.
Paul Aurich <darkrain42@pidgin.im>
parents:
26983
diff
changeset
|
75 | |
|
977add4a215e
Stop trying to be clever with XMPP keepalive pings.
Paul Aurich <darkrain42@pidgin.im>
parents:
26983
diff
changeset
|
76 | iq = jabber_iq_new(js, JABBER_IQ_GET); |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
28979
diff
changeset
|
77 | ping = purple_xmlnode_new_child(iq->node, "ping"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
28979
diff
changeset
|
78 | purple_xmlnode_set_namespace(ping, NS_PING); |
|
27143
977add4a215e
Stop trying to be clever with XMPP keepalive pings.
Paul Aurich <darkrain42@pidgin.im>
parents:
26983
diff
changeset
|
79 | |
|
977add4a215e
Stop trying to be clever with XMPP keepalive pings.
Paul Aurich <darkrain42@pidgin.im>
parents:
26983
diff
changeset
|
80 | jabber_iq_set_callback(iq, jabber_keepalive_pong_cb, NULL); |
|
977add4a215e
Stop trying to be clever with XMPP keepalive pings.
Paul Aurich <darkrain42@pidgin.im>
parents:
26983
diff
changeset
|
81 | jabber_iq_send(iq); |
|
17769
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
82 | } |
|
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
83 | |
|
25555
dd0cb987435f
Make the XMPP keepalive use jabber_ping_jid instead of building it itself.
Paul Aurich <darkrain42@pidgin.im>
parents:
25554
diff
changeset
|
84 | gboolean jabber_ping_jid(JabberStream *js, const char *jid) |
|
17769
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
85 | { |
|
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
86 | JabberIq *iq; |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
28979
diff
changeset
|
87 | PurpleXmlNode *ping; |
|
17769
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
88 | |
|
25555
dd0cb987435f
Make the XMPP keepalive use jabber_ping_jid instead of building it itself.
Paul Aurich <darkrain42@pidgin.im>
parents:
25554
diff
changeset
|
89 | iq = jabber_iq_new(js, JABBER_IQ_GET); |
|
dd0cb987435f
Make the XMPP keepalive use jabber_ping_jid instead of building it itself.
Paul Aurich <darkrain42@pidgin.im>
parents:
25554
diff
changeset
|
90 | if (jid) |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
28979
diff
changeset
|
91 | purple_xmlnode_set_attrib(iq->node, "to", jid); |
|
17769
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
92 | |
|
34935
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
28979
diff
changeset
|
93 | ping = purple_xmlnode_new_child(iq->node, "ping"); |
|
686fa55b0deb
Replaced xmlnode with PurpleXmlNode, and xmlnode_* API with purple_xmlnode_* API
Ankit Vani <a@nevitus.org>
parents:
28979
diff
changeset
|
94 | purple_xmlnode_set_namespace(ping, NS_PING); |
|
17769
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
95 | |
|
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
96 | jabber_iq_set_callback(iq, jabber_ping_result_cb, NULL); |
|
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
97 | jabber_iq_send(iq); |
|
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
98 | |
|
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
99 | return TRUE; |
|
69d98a4da006
applied patch for supporting XEP-0199: XMPP Ping
Andreas Monitzer <am@adiumx.com>
parents:
diff
changeset
|
100 | } |