Mercurial > pidgin.yaz
annotate libpurple/protocols/jabber/iq.h @ 28137:da33da2e1a1e
Fix a bunch of memory leaks reported by Josh Mueller. Refs #9822.
author | Paul Aurich <paul@darkrain42.org> |
---|---|
date | Sun, 02 Aug 2009 05:04:41 +0000 |
parents | 92565c8e1e3a |
children | c585572e80dd |
rev | line source |
---|---|
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1 /** |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2 * @file iq.h JabberID handlers |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3 * |
15823 | 4 * purple |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
6 * Copyright (C) 2003 Nathan Walp <faceprint@faceprint.com> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
7 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
8 * This program is free software; you can redistribute it and/or modify |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
9 * it under the terms of the GNU General Public License as published by |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
10 * the Free Software Foundation; either version 2 of the License, or |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
11 * (at your option) any later version. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
12 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
13 * This program is distributed in the hope that it will be useful, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
16 * GNU General Public License for more details. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
17 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
18 * You should have received a copy of the GNU General Public License |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
19 * along with this program; if not, write to the Free Software |
19680
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
15823
diff
changeset
|
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
21 */ |
26563
5767b7698c73
Further standardize the sentinel style (did someone say leading _s are theoretically a reserved namespace?)
Paul Aurich <paul@darkrain42.org>
parents:
26560
diff
changeset
|
22 #ifndef PURPLE_JABBER_IQ_H_ |
5767b7698c73
Further standardize the sentinel style (did someone say leading _s are theoretically a reserved namespace?)
Paul Aurich <paul@darkrain42.org>
parents:
26560
diff
changeset
|
23 #define PURPLE_JABBER_IQ_H_ |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
24 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
25 typedef enum { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
26 JABBER_IQ_SET, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
27 JABBER_IQ_GET, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
28 JABBER_IQ_RESULT, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
29 JABBER_IQ_ERROR, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
30 JABBER_IQ_NONE |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
31 } JabberIqType; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
32 |
25933
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25931
diff
changeset
|
33 #include "jabber.h" |
26952
92565c8e1e3a
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 <paul@darkrain42.org>
parents:
26563
diff
changeset
|
34 #include "connection.h" |
25933
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25931
diff
changeset
|
35 |
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25931
diff
changeset
|
36 typedef struct _JabberIq JabberIq; |
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25931
diff
changeset
|
37 |
26560
36c435f55252
Large documentation blocks never hurt anyone.
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
38 /** |
36c435f55252
Large documentation blocks never hurt anyone.
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
39 * A JabberIqHandler is called to process an incoming IQ stanza. |
36c435f55252
Large documentation blocks never hurt anyone.
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
40 * Handlers typically process unsolicited incoming GETs or SETs for their |
36c435f55252
Large documentation blocks never hurt anyone.
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
41 * registered namespace, but may be called to handle the results of a |
36c435f55252
Large documentation blocks never hurt anyone.
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
42 * GET or SET that we generated if no JabberIqCallback was generated |
36c435f55252
Large documentation blocks never hurt anyone.
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
43 * The handler may be called for the results of a GET or SET (RESULT or ERROR) |
36c435f55252
Large documentation blocks never hurt anyone.
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
44 * that we generated |
36c435f55252
Large documentation blocks never hurt anyone.
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
45 * if the generating function did not register a JabberIqCallback. |
36c435f55252
Large documentation blocks never hurt anyone.
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
46 * |
36c435f55252
Large documentation blocks never hurt anyone.
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
47 * @param js The JabberStream object. |
36c435f55252
Large documentation blocks never hurt anyone.
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
48 * @param from The remote entity (the from attribute on the <iq/> stanza) |
36c435f55252
Large documentation blocks never hurt anyone.
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
49 * @param type The IQ type. |
36c435f55252
Large documentation blocks never hurt anyone.
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
50 * @param id The IQ id (the id attribute on the <iq/> stanza) |
36c435f55252
Large documentation blocks never hurt anyone.
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
51 * @param child The child element of the <iq/> stanza that matches the name |
36c435f55252
Large documentation blocks never hurt anyone.
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
52 * and namespace registered with jabber_iq_register_handler. |
36c435f55252
Large documentation blocks never hurt anyone.
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
53 * |
36c435f55252
Large documentation blocks never hurt anyone.
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
54 * @see jabber_iq_register_handler() |
36c435f55252
Large documentation blocks never hurt anyone.
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
55 * @see JabberIqCallback |
36c435f55252
Large documentation blocks never hurt anyone.
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
56 */ |
25933
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25931
diff
changeset
|
57 typedef void (JabberIqHandler)(JabberStream *js, const char *from, |
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25931
diff
changeset
|
58 JabberIqType type, const char *id, |
050052891c55
Pass IQ handlers type, from, id, and the child node
Paul Aurich <paul@darkrain42.org>
parents:
25931
diff
changeset
|
59 xmlnode *child); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
60 |
26560
36c435f55252
Large documentation blocks never hurt anyone.
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
61 /** |
36c435f55252
Large documentation blocks never hurt anyone.
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
62 * A JabberIqCallback is called to process the results of a GET or SET that |
36c435f55252
Large documentation blocks never hurt anyone.
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
63 * we send to a remote entity. The callback is matched based on the id |
36c435f55252
Large documentation blocks never hurt anyone.
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
64 * of the incoming stanza (which matches the one on the initial stanza). |
36c435f55252
Large documentation blocks never hurt anyone.
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
65 * |
36c435f55252
Large documentation blocks never hurt anyone.
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
66 * @param js The JabberStream object. |
36c435f55252
Large documentation blocks never hurt anyone.
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
67 * @param from The remote entity (the from attribute on the <iq/> stanza) |
36c435f55252
Large documentation blocks never hurt anyone.
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
68 * @param type The IQ type. The only possible values are JABBER_IQ_RESULT |
36c435f55252
Large documentation blocks never hurt anyone.
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
69 * and JABBER_IQ_ERROR. |
36c435f55252
Large documentation blocks never hurt anyone.
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
70 * @param id The IQ id (the id attribute on the <iq/> stanza) |
36c435f55252
Large documentation blocks never hurt anyone.
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
71 * @param packet The <iq/> stanza |
36c435f55252
Large documentation blocks never hurt anyone.
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
72 * @param data The callback data passed to jabber_iq_set_callback() |
36c435f55252
Large documentation blocks never hurt anyone.
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
73 * |
36c435f55252
Large documentation blocks never hurt anyone.
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
74 * @see jabber_iq_set_callback() |
36c435f55252
Large documentation blocks never hurt anyone.
Paul Aurich <paul@darkrain42.org>
parents:
26547
diff
changeset
|
75 */ |
26547
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25937
diff
changeset
|
76 typedef void (JabberIqCallback)(JabberStream *js, const char *from, |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25937
diff
changeset
|
77 JabberIqType type, const char *id, |
ae41d8e827e3
Convert all the XMPP IQ callbacks to a typedef similar to the IQ Handlers.
Paul Aurich <paul@darkrain42.org>
parents:
25937
diff
changeset
|
78 xmlnode *packet, gpointer data); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
79 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
80 struct _JabberIq { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
81 JabberIqType type; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
82 char *id; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
83 xmlnode *node; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
84 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
85 JabberIqCallback *callback; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
86 gpointer callback_data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
87 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
88 JabberStream *js; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
89 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
90 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
91 JabberIq *jabber_iq_new(JabberStream *js, JabberIqType type); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
92 JabberIq *jabber_iq_new_query(JabberStream *js, JabberIqType type, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
93 const char *xmlns); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
94 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
95 void jabber_iq_parse(JabberStream *js, xmlnode *packet); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
96 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
97 void jabber_iq_remove_callback_by_id(JabberStream *js, const char *id); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
98 void jabber_iq_set_callback(JabberIq *iq, JabberIqCallback *cb, gpointer data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
99 void jabber_iq_set_id(JabberIq *iq, const char *id); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
100 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
101 void jabber_iq_send(JabberIq *iq); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
102 void jabber_iq_free(JabberIq *iq); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
103 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
104 void jabber_iq_init(void); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
105 void jabber_iq_uninit(void); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
106 |
25937
a4cba207068f
merge of '1f6758f8bdba42d2eeca66535d11e7de12d9e715'
Paul Aurich <paul@darkrain42.org>
parents:
25936
diff
changeset
|
107 void jabber_iq_register_handler(const char *node, const char *xmlns, |
a4cba207068f
merge of '1f6758f8bdba42d2eeca66535d11e7de12d9e715'
Paul Aurich <paul@darkrain42.org>
parents:
25936
diff
changeset
|
108 JabberIqHandler *func); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
109 |
26952
92565c8e1e3a
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 <paul@darkrain42.org>
parents:
26563
diff
changeset
|
110 /* Connected to namespace-handler registration signals */ |
92565c8e1e3a
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 <paul@darkrain42.org>
parents:
26563
diff
changeset
|
111 void jabber_iq_signal_register(const gchar *node, const gchar *xmlns); |
92565c8e1e3a
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 <paul@darkrain42.org>
parents:
26563
diff
changeset
|
112 void jabber_iq_signal_unregister(const gchar *node, const gchar *xmlns); |
92565c8e1e3a
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 <paul@darkrain42.org>
parents:
26563
diff
changeset
|
113 |
26563
5767b7698c73
Further standardize the sentinel style (did someone say leading _s are theoretically a reserved namespace?)
Paul Aurich <paul@darkrain42.org>
parents:
26560
diff
changeset
|
114 #endif /* PURPLE_JABBER_IQ_H_ */ |