2 * @file iq.h JabberID handlers
6 * Copyright (C) 2003 Nathan Walp <faceprint@faceprint.com>
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.
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.
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
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
22 #ifndef PURPLE_JABBER_IQ_H_
23 #define PURPLE_JABBER_IQ_H_
34 #include "connection.h"
36 typedef struct _JabberIq JabberIq;
39 * A JabberIqHandler is called to process an incoming IQ stanza.
40 * Handlers typically process unsolicited incoming GETs or SETs for their
41 * registered namespace, but may be called to handle the results of a
42 * GET or SET that we generated if no JabberIqCallback was generated
43 * The handler may be called for the results of a GET or SET (RESULT or ERROR)
45 * if the generating function did not register a JabberIqCallback.
47 * @param js The JabberStream object.
48 * @param from The remote entity (the from attribute on the <iq/> stanza)
49 * @param type The IQ type.
50 * @param id The IQ id (the id attribute on the <iq/> stanza)
51 * @param child The child element of the <iq/> stanza that matches the name
52 * and namespace registered with jabber_iq_register_handler.
54 * @see jabber_iq_register_handler()
55 * @see JabberIqCallback
57 typedef void (JabberIqHandler)(JabberStream *js, const char *from,
58 JabberIqType type, const char *id,
62 * A JabberIqCallback is called to process the results of a GET or SET that
63 * we send to a remote entity. The callback is matched based on the id
64 * of the incoming stanza (which matches the one on the initial stanza).
66 * @param js The JabberStream object.
67 * @param from The remote entity (the from attribute on the <iq/> stanza)
68 * @param type The IQ type. The only possible values are JABBER_IQ_RESULT
69 * and JABBER_IQ_ERROR.
70 * @param id The IQ id (the id attribute on the <iq/> stanza)
71 * @param packet The <iq/> stanza
72 * @param data The callback data passed to jabber_iq_set_callback()
74 * @see jabber_iq_set_callback()
76 typedef void (JabberIqCallback)(JabberStream *js, const char *from,
77 JabberIqType type, const char *id,
78 xmlnode *packet, gpointer data);
85 JabberIqCallback *callback;
86 gpointer callback_data;
91 JabberIq *jabber_iq_new(JabberStream *js, JabberIqType type);
92 JabberIq *jabber_iq_new_query(JabberStream *js, JabberIqType type,
95 void jabber_iq_parse(JabberStream *js, xmlnode *packet);
97 void jabber_iq_remove_callback_by_id(JabberStream *js, const char *id);
98 void jabber_iq_set_callback(JabberIq *iq, JabberIqCallback *cb, gpointer data);
99 void jabber_iq_set_id(JabberIq *iq, const char *id);
101 void jabber_iq_send(JabberIq *iq);
102 void jabber_iq_free(JabberIq *iq);
104 void jabber_iq_init(void);
105 void jabber_iq_uninit(void);
107 void jabber_iq_register_handler(const char *node, const char *xmlns,
108 JabberIqHandler *func);
110 /* Connected to namespace-handler registration signals */
111 void jabber_iq_signal_register(const gchar *node, const gchar *xmlns);
112 void jabber_iq_signal_unregister(const gchar *node, const gchar *xmlns);
114 #endif /* PURPLE_JABBER_IQ_H_ */