Sun, 08 Feb 2009 06:31:18 +0000
Pass IQ handlers type, from, id, and the child node
As QuLogic pointed out in 8a80f271, it's pointless for the handlers to re-get
the information from the IQ stanza. Additionally, instead of string-matching
the type everywhere, pass around a JabberIqType.
Last, 'child' cannot be NULL, but 'from' may be.
| 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 | */ |
| 15884 | 22 | #ifndef _PURPLE_JABBER_IQ_H_ |
| 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 | |
|
09d6a40a341d
Pass IQ handlers type, from, id, and the child node
Paul Aurich <darkrain42@pidgin.im>
parents:
25815
diff
changeset
|
37 | 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
|
38 | 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
|
39 | xmlnode *child); |
| 14356 | 40 | |
| 7395 | 41 | typedef void (JabberIqCallback)(JabberStream *js, xmlnode *packet, gpointer data); |
| 42 | ||
| 7014 | 43 | struct _JabberIq { |
| 44 | JabberIqType type; | |
| 45 | char *id; | |
| 46 | xmlnode *node; | |
| 47 | ||
| 7395 | 48 | JabberIqCallback *callback; |
| 49 | gpointer callback_data; | |
| 7014 | 50 | |
| 51 | JabberStream *js; | |
| 52 | }; | |
| 53 | ||
| 54 | JabberIq *jabber_iq_new(JabberStream *js, JabberIqType type); | |
| 55 | JabberIq *jabber_iq_new_query(JabberStream *js, JabberIqType type, | |
| 56 | const char *xmlns); | |
| 57 | ||
| 58 | void jabber_iq_parse(JabberStream *js, xmlnode *packet); | |
| 59 | ||
| 13794 | 60 | void jabber_iq_remove_callback_by_id(JabberStream *js, const char *id); |
| 7395 | 61 | void jabber_iq_set_callback(JabberIq *iq, JabberIqCallback *cb, gpointer data); |
| 7170 | 62 | void jabber_iq_set_id(JabberIq *iq, const char *id); |
| 7014 | 63 | |
| 64 | void jabber_iq_send(JabberIq *iq); | |
| 65 | void jabber_iq_free(JabberIq *iq); | |
| 66 | ||
| 14356 | 67 | void jabber_iq_init(void); |
| 68 | void jabber_iq_uninit(void); | |
| 69 | ||
|
25815
a25fc3804b22
Track the sub-node name in addition to the namespace for handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
19859
diff
changeset
|
70 | void jabber_iq_register_handler(const char *node, const char *xmlns, |
|
a25fc3804b22
Track the sub-node name in addition to the namespace for handlers.
Paul Aurich <darkrain42@pidgin.im>
parents:
19859
diff
changeset
|
71 | JabberIqHandler *func); |
| 14356 | 72 | |
| 15884 | 73 | #endif /* _PURPLE_JABBER_IQ_H_ */ |