Wed, 29 Apr 2009 23:20:51 +0000
propagate from branch 'im.pidgin.pidgin' (head feb6f844abcd8e7add3c986f3010f642838533e8)
to branch 'im.pidgin.cpw.darkrain42.xmpp.disco' (head 89d794256bfae4cd7b60b635b786baf37e472a6a)
| 7014 | 1 | /** |
| 2 | * @file iq.h JabberID handlers | |
| 3 | * | |
| 15884 | 4 | * purple |
| 7014 | 5 | * |
| 6 | * Copyright (C) 2003 Nathan Walp <faceprint@faceprint.com> | |
| 7 | * | |
| 8 | * This program is free software; you can redistribute it and/or modify | |
| 9 | * it under the terms of the GNU General Public License as published by | |
| 10 | * the Free Software Foundation; either version 2 of the License, or | |
| 11 | * (at your option) any later version. | |
| 12 | * | |
| 13 | * This program is distributed in the hope that it will be useful, | |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 16 | * GNU General Public License for more details. | |
| 17 | * | |
| 18 | * You should have received a copy of the GNU General Public License | |
| 19 | * 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
|
20 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 7014 | 21 | */ |
|
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
|
22 | #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
|
23 | #define PURPLE_JABBER_IQ_H_ |
| 7014 | 24 | |
| 25 | typedef enum { | |
| 26 | JABBER_IQ_SET, | |
| 27 | JABBER_IQ_GET, | |
| 28 | JABBER_IQ_RESULT, | |
| 29 | JABBER_IQ_ERROR, | |
| 30 | JABBER_IQ_NONE | |
| 31 | } JabberIqType; | |
| 32 | ||
|
25817
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
25815
diff
changeset
|
33 | #include "jabber.h" |
|
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
25815
diff
changeset
|
34 | |
|
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
25815
diff
changeset
|
35 | typedef struct _JabberIq JabberIq; |
|
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
25815
diff
changeset
|
36 | |
|
26700
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
37 | /** |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
38 | * 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
|
39 | * 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
|
40 | * 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
|
41 | * 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
|
42 | * 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
|
43 | * that we generated |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
44 | * 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
|
45 | * |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
46 | * @param js The JabberStream object. |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
47 | * @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
|
48 | * @param type The IQ type. |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
49 | * @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
|
50 | * @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
|
51 | * and namespace registered with jabber_iq_register_handler. |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
52 | * |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
53 | * @see jabber_iq_register_handler() |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
54 | * @see JabberIqCallback |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
55 | */ |
|
25817
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
25815
diff
changeset
|
56 | 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
|
57 | 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
|
58 | xmlnode *child); |
| 14356 | 59 | |
|
26700
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
60 | /** |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
61 | * 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
|
62 | * 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
|
63 | * 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
|
64 | * |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
65 | * @param js The JabberStream object. |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
66 | * @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
|
67 | * @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
|
68 | * and JABBER_IQ_ERROR. |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
69 | * @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
|
70 | * @param packet The <iq/> stanza |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
71 | * @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
|
72 | * |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
73 | * @see jabber_iq_set_callback() |
|
8bdeed3f9115
Large documentation blocks never hurt anyone.
Paul Aurich <darkrain42@pidgin.im>
parents:
26687
diff
changeset
|
74 | */ |
|
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
|
75 | 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
|
76 | 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
|
77 | xmlnode *packet, gpointer data); |
| 7395 | 78 | |
| 7014 | 79 | struct _JabberIq { |
| 80 | JabberIqType type; | |
| 81 | char *id; | |
| 82 | xmlnode *node; | |
| 83 | ||
| 7395 | 84 | JabberIqCallback *callback; |
| 85 | gpointer callback_data; | |
| 7014 | 86 | |
| 87 | JabberStream *js; | |
| 88 | }; | |
| 89 | ||
| 90 | JabberIq *jabber_iq_new(JabberStream *js, JabberIqType type); | |
| 91 | JabberIq *jabber_iq_new_query(JabberStream *js, JabberIqType type, | |
| 92 | const char *xmlns); | |
| 93 | ||
| 94 | void jabber_iq_parse(JabberStream *js, xmlnode *packet); | |
| 95 | ||
| 13794 | 96 | void jabber_iq_remove_callback_by_id(JabberStream *js, const char *id); |
| 7395 | 97 | void jabber_iq_set_callback(JabberIq *iq, JabberIqCallback *cb, gpointer data); |
| 7170 | 98 | void jabber_iq_set_id(JabberIq *iq, const char *id); |
| 7014 | 99 | |
| 100 | void jabber_iq_send(JabberIq *iq); | |
| 101 | void jabber_iq_free(JabberIq *iq); | |
| 102 | ||
| 14356 | 103 | void jabber_iq_init(void); |
| 104 | void jabber_iq_uninit(void); | |
| 105 | ||
|
25821
5107c4870027
merge of '4dbe0c6eaf6dc066dddfd3084db3140b730b47a6'
Paul Aurich <darkrain42@pidgin.im>
parents:
25819
diff
changeset
|
106 | void jabber_iq_register_handler(const char *node, const char *xmlns, |
|
5107c4870027
merge of '4dbe0c6eaf6dc066dddfd3084db3140b730b47a6'
Paul Aurich <darkrain42@pidgin.im>
parents:
25819
diff
changeset
|
107 | JabberIqHandler *func); |
| 14356 | 108 | |
|
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
|
109 | #endif /* PURPLE_JABBER_IQ_H_ */ |