1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/Frameworks/libpurple.framework/Versions/0.6.2/Headers/iq.h Fri Aug 21 13:25:11 2009 -0700
1.3 @@ -0,0 +1,114 @@
1.4 +/**
1.5 + * @file iq.h JabberID handlers
1.6 + *
1.7 + * purple
1.8 + *
1.9 + * Copyright (C) 2003 Nathan Walp <faceprint@faceprint.com>
1.10 + *
1.11 + * This program is free software; you can redistribute it and/or modify
1.12 + * it under the terms of the GNU General Public License as published by
1.13 + * the Free Software Foundation; either version 2 of the License, or
1.14 + * (at your option) any later version.
1.15 + *
1.16 + * This program is distributed in the hope that it will be useful,
1.17 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.18 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1.19 + * GNU General Public License for more details.
1.20 + *
1.21 + * You should have received a copy of the GNU General Public License
1.22 + * along with this program; if not, write to the Free Software
1.23 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
1.24 + */
1.25 +#ifndef PURPLE_JABBER_IQ_H_
1.26 +#define PURPLE_JABBER_IQ_H_
1.27 +
1.28 +typedef enum {
1.29 + JABBER_IQ_SET,
1.30 + JABBER_IQ_GET,
1.31 + JABBER_IQ_RESULT,
1.32 + JABBER_IQ_ERROR,
1.33 + JABBER_IQ_NONE
1.34 +} JabberIqType;
1.35 +
1.36 +#include "jabber.h"
1.37 +#include "connection.h"
1.38 +
1.39 +typedef struct _JabberIq JabberIq;
1.40 +
1.41 +/**
1.42 + * A JabberIqHandler is called to process an incoming IQ stanza.
1.43 + * Handlers typically process unsolicited incoming GETs or SETs for their
1.44 + * registered namespace, but may be called to handle the results of a
1.45 + * GET or SET that we generated if no JabberIqCallback was generated
1.46 + * The handler may be called for the results of a GET or SET (RESULT or ERROR)
1.47 + * that we generated
1.48 + * if the generating function did not register a JabberIqCallback.
1.49 + *
1.50 + * @param js The JabberStream object.
1.51 + * @param from The remote entity (the from attribute on the <iq/> stanza)
1.52 + * @param type The IQ type.
1.53 + * @param id The IQ id (the id attribute on the <iq/> stanza)
1.54 + * @param child The child element of the <iq/> stanza that matches the name
1.55 + * and namespace registered with jabber_iq_register_handler.
1.56 + *
1.57 + * @see jabber_iq_register_handler()
1.58 + * @see JabberIqCallback
1.59 + */
1.60 +typedef void (JabberIqHandler)(JabberStream *js, const char *from,
1.61 + JabberIqType type, const char *id,
1.62 + xmlnode *child);
1.63 +
1.64 +/**
1.65 + * A JabberIqCallback is called to process the results of a GET or SET that
1.66 + * we send to a remote entity. The callback is matched based on the id
1.67 + * of the incoming stanza (which matches the one on the initial stanza).
1.68 + *
1.69 + * @param js The JabberStream object.
1.70 + * @param from The remote entity (the from attribute on the <iq/> stanza)
1.71 + * @param type The IQ type. The only possible values are JABBER_IQ_RESULT
1.72 + * and JABBER_IQ_ERROR.
1.73 + * @param id The IQ id (the id attribute on the <iq/> stanza)
1.74 + * @param packet The <iq/> stanza
1.75 + * @param data The callback data passed to jabber_iq_set_callback()
1.76 + *
1.77 + * @see jabber_iq_set_callback()
1.78 + */
1.79 +typedef void (JabberIqCallback)(JabberStream *js, const char *from,
1.80 + JabberIqType type, const char *id,
1.81 + xmlnode *packet, gpointer data);
1.82 +
1.83 +struct _JabberIq {
1.84 + JabberIqType type;
1.85 + char *id;
1.86 + xmlnode *node;
1.87 +
1.88 + JabberIqCallback *callback;
1.89 + gpointer callback_data;
1.90 +
1.91 + JabberStream *js;
1.92 +};
1.93 +
1.94 +JabberIq *jabber_iq_new(JabberStream *js, JabberIqType type);
1.95 +JabberIq *jabber_iq_new_query(JabberStream *js, JabberIqType type,
1.96 + const char *xmlns);
1.97 +
1.98 +void jabber_iq_parse(JabberStream *js, xmlnode *packet);
1.99 +
1.100 +void jabber_iq_remove_callback_by_id(JabberStream *js, const char *id);
1.101 +void jabber_iq_set_callback(JabberIq *iq, JabberIqCallback *cb, gpointer data);
1.102 +void jabber_iq_set_id(JabberIq *iq, const char *id);
1.103 +
1.104 +void jabber_iq_send(JabberIq *iq);
1.105 +void jabber_iq_free(JabberIq *iq);
1.106 +
1.107 +void jabber_iq_init(void);
1.108 +void jabber_iq_uninit(void);
1.109 +
1.110 +void jabber_iq_register_handler(const char *node, const char *xmlns,
1.111 + JabberIqHandler *func);
1.112 +
1.113 +/* Connected to namespace-handler registration signals */
1.114 +void jabber_iq_signal_register(const gchar *node, const gchar *xmlns);
1.115 +void jabber_iq_signal_unregister(const gchar *node, const gchar *xmlns);
1.116 +
1.117 +#endif /* PURPLE_JABBER_IQ_H_ */