Thu, 23 Mar 2017 19:19:01 +0300
Replace misused g_str_equal() with purple_strequal()
| 7014 | 1 | /** |
| 2 | * @file iq.h JabberID handlers | |
| 3 | * | |
| 15884 | 4 | * purple |
| 7014 | 5 | * |
|
28322
ac8fec1d2234
Remove specific copyright lines from the XMPP prpl.
Paul Aurich <darkrain42@pidgin.im>
parents:
27103
diff
changeset
|
6 | * 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:
27103
diff
changeset
|
7 | * 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:
27103
diff
changeset
|
8 | * source distribution. |
| 7014 | 9 | * |
| 10 | * This program is free software; you can redistribute it and/or modify | |
| 11 | * it under the terms of the GNU General Public License as published by | |
| 12 | * the Free Software Foundation; either version 2 of the License, or | |
| 13 | * (at your option) any later version. | |
| 14 | * | |
| 15 | * This program is distributed in the hope that it will be useful, | |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 18 | * GNU General Public License for more details. | |
| 19 | * | |
| 20 | * You should have received a copy of the GNU General Public License | |
| 21 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
15884
diff
changeset
|
22 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 7014 | 23 | */ |
|
26703
17f9a4bef2a3
Further standardize the sentinel style (did someone say leading _s are theoretically a reserved namespace?)
Paul Aurich <darkrain42@pidgin.im>
parents:
26700
diff
changeset
|
24 | #ifndef PURPLE_JABBER_IQ_H_ |
|
17f9a4bef2a3
Further standardize the sentinel style (did someone say leading _s are theoretically a reserved namespace?)
Paul Aurich <darkrain42@pidgin.im>
parents:
26700
diff
changeset
|
25 | #define PURPLE_JABBER_IQ_H_ |
| 7014 | 26 | |
| 27 | typedef enum { | |
| 28 | JABBER_IQ_SET, | |
| 29 | JABBER_IQ_GET, | |
| 30 | JABBER_IQ_RESULT, | |
| 31 | JABBER_IQ_ERROR, | |
| 32 | JABBER_IQ_NONE | |
| 33 | } JabberIqType; | |
| 34 | ||
|
25817
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
25815
diff
changeset
|
35 | #include "jabber.h" |
|
27103
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26703
diff
changeset
|
36 | #include "connection.h" |
|
25817
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
25815
diff
changeset
|
37 | |
|
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
25815
diff
changeset
|
38 | typedef struct _JabberIq JabberIq; |
|
35235
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
28322
diff
changeset
|
39 | typedef struct _JabberIqCallbackData JabberIqCallbackData; |
|
25817
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
25815
diff
changeset
|
40 | |
|
26700
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
41 | /** |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
42 | * A JabberIqHandler is called to process an incoming IQ stanza. |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
43 | * Handlers typically process unsolicited incoming GETs or SETs for their |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
44 | * registered namespace, but may be called to handle the results of a |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
45 | * GET or SET that we generated if no JabberIqCallback was generated |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
46 | * The handler may be called for the results of a GET or SET (RESULT or ERROR) |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
47 | * that we generated |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
48 | * if the generating function did not register a JabberIqCallback. |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
49 | * |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
50 | * @param js The JabberStream object. |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
51 | * @param from The remote entity (the from attribute on the <iq/> stanza) |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
52 | * @param type The IQ type. |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
53 | * @param id The IQ id (the id attribute on the <iq/> stanza) |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
54 | * @param child The child element of the <iq/> stanza that matches the name |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
55 | * and namespace registered with jabber_iq_register_handler. |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
56 | * |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
57 | * @see jabber_iq_register_handler() |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
58 | * @see JabberIqCallback |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
59 | */ |
|
25817
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
25815
diff
changeset
|
60 | typedef void (JabberIqHandler)(JabberStream *js, const char *from, |
|
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
25815
diff
changeset
|
61 | JabberIqType type, const char *id, |
|
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
25815
diff
changeset
|
62 | xmlnode *child); |
| 14356 | 63 | |
|
26700
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
64 | /** |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
65 | * A JabberIqCallback is called to process the results of a GET or SET that |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
66 | * we send to a remote entity. The callback is matched based on the id |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
67 | * of the incoming stanza (which matches the one on the initial stanza). |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
68 | * |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
69 | * @param js The JabberStream object. |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
70 | * @param from The remote entity (the from attribute on the <iq/> stanza) |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
71 | * @param type The IQ type. The only possible values are JABBER_IQ_RESULT |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
72 | * and JABBER_IQ_ERROR. |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
73 | * @param id The IQ id (the id attribute on the <iq/> stanza) |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
74 | * @param packet The <iq/> stanza |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
75 | * @param data The callback data passed to jabber_iq_set_callback() |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
76 | * |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
77 | * @see jabber_iq_set_callback() |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
78 | */ |
|
26687
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
25821
diff
changeset
|
79 | typedef void (JabberIqCallback)(JabberStream *js, const char *from, |
|
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
25821
diff
changeset
|
80 | JabberIqType type, const char *id, |
|
1e799151fabe
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
25821
diff
changeset
|
81 | xmlnode *packet, gpointer data); |
| 7395 | 82 | |
| 7014 | 83 | struct _JabberIq { |
| 84 | JabberIqType type; | |
| 85 | char *id; | |
| 86 | xmlnode *node; | |
| 87 | ||
| 7395 | 88 | JabberIqCallback *callback; |
| 89 | gpointer callback_data; | |
| 7014 | 90 | |
| 91 | JabberStream *js; | |
| 92 | }; | |
| 93 | ||
| 94 | JabberIq *jabber_iq_new(JabberStream *js, JabberIqType type); | |
| 95 | JabberIq *jabber_iq_new_query(JabberStream *js, JabberIqType type, | |
| 96 | const char *xmlns); | |
| 97 | ||
| 98 | void jabber_iq_parse(JabberStream *js, xmlnode *packet); | |
| 99 | ||
|
35235
93d4bff19574
Prevent spoofing of iq replies by verifying that the 'from' address
Mark Doliner <mark@kingant.net>
parents:
28322
diff
changeset
|
100 | void jabber_iq_callbackdata_free(JabberIqCallbackData *jcd); |
| 13794 | 101 | void jabber_iq_remove_callback_by_id(JabberStream *js, const char *id); |
| 7395 | 102 | void jabber_iq_set_callback(JabberIq *iq, JabberIqCallback *cb, gpointer data); |
| 7170 | 103 | void jabber_iq_set_id(JabberIq *iq, const char *id); |
| 7014 | 104 | |
| 105 | void jabber_iq_send(JabberIq *iq); | |
| 106 | void jabber_iq_free(JabberIq *iq); | |
| 107 | ||
| 14356 | 108 | void jabber_iq_init(void); |
| 109 | void jabber_iq_uninit(void); | |
| 110 | ||
|
25821
5107c4870027
merge of '4dbe0c6eaf6dc066dddfd3084db3140b730b47a6'
Paul Aurich <darkrain42@pidgin.im>
parents:
25819
diff
changeset
|
111 | void jabber_iq_register_handler(const char *node, const char *xmlns, |
|
5107c4870027
merge of '4dbe0c6eaf6dc066dddfd3084db3140b730b47a6'
Paul Aurich <darkrain42@pidgin.im>
parents:
25819
diff
changeset
|
112 | JabberIqHandler *func); |
| 14356 | 113 | |
|
27103
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26703
diff
changeset
|
114 | /* Connected to namespace-handler registration signals */ |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26703
diff
changeset
|
115 | void jabber_iq_signal_register(const gchar *node, const gchar *xmlns); |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26703
diff
changeset
|
116 | void jabber_iq_signal_unregister(const gchar *node, const gchar *xmlns); |
|
815af6acd59b
Add jabber signals for IQ, Message, and Presence stanzas. Lightly tested (it doesn't crash [Prove me wrong!]) and as you'll note, I refer to documentation that doesn't yet exist.
Paul Aurich <darkrain42@pidgin.im>
parents:
26703
diff
changeset
|
117 | |
|
26703
17f9a4bef2a3
Further standardize the sentinel style (did someone say leading _s are theoretically a reserved namespace?)
Paul Aurich <darkrain42@pidgin.im>
parents:
26700
diff
changeset
|
118 | #endif /* PURPLE_JABBER_IQ_H_ */ |