Frameworks/libpurple.framework/Versions/0.6.2/Headers/iq.h
author Zachary West <zacw@adium.im>
Fri Aug 21 13:25:11 2009 -0700 (2009-08-21)
changeset 2592 e8d15275025e
parent 2250 Frameworks/libpurple.framework/Versions/0.6.0/Headers/iq.h@9da0b118ce57
permissions -rw-r--r--
im.pidgin.adium.1-4 at 267c6165e02e34318a1823960bd04c0639952f73
zacw@1759
     1
/**
zacw@1759
     2
 * @file iq.h JabberID handlers
zacw@1759
     3
 *
zacw@1759
     4
 * purple
zacw@1759
     5
 *
zacw@1759
     6
 * Copyright (C) 2003 Nathan Walp <faceprint@faceprint.com>
zacw@1759
     7
 *
zacw@1759
     8
 * This program is free software; you can redistribute it and/or modify
zacw@1759
     9
 * it under the terms of the GNU General Public License as published by
zacw@1759
    10
 * the Free Software Foundation; either version 2 of the License, or
zacw@1759
    11
 * (at your option) any later version.
zacw@1759
    12
 *
zacw@1759
    13
 * This program is distributed in the hope that it will be useful,
zacw@1759
    14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
zacw@1759
    15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
zacw@1759
    16
 * GNU General Public License for more details.
zacw@1759
    17
 *
zacw@1759
    18
 * You should have received a copy of the GNU General Public License
zacw@1759
    19
 * along with this program; if not, write to the Free Software
zacw@1759
    20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
zacw@1759
    21
 */
zacw@1759
    22
#ifndef PURPLE_JABBER_IQ_H_
zacw@1759
    23
#define PURPLE_JABBER_IQ_H_
zacw@1759
    24
zacw@1759
    25
typedef enum {
zacw@1759
    26
	JABBER_IQ_SET,
zacw@1759
    27
	JABBER_IQ_GET,
zacw@1759
    28
	JABBER_IQ_RESULT,
zacw@1759
    29
	JABBER_IQ_ERROR,
zacw@1759
    30
	JABBER_IQ_NONE
zacw@1759
    31
} JabberIqType;
zacw@1759
    32
zacw@1759
    33
#include "jabber.h"
zacw@2250
    34
#include "connection.h"
zacw@1759
    35
zacw@1759
    36
typedef struct _JabberIq JabberIq;
zacw@1759
    37
zacw@1759
    38
/**
zacw@1759
    39
 * A JabberIqHandler is called to process an incoming IQ stanza.
zacw@1759
    40
 * Handlers typically process unsolicited incoming GETs or SETs for their
zacw@1759
    41
 * registered namespace, but may be called to handle the results of a
zacw@1759
    42
 * GET or SET that we generated if no JabberIqCallback was generated
zacw@1759
    43
 * The handler may be called for the results of a GET or SET (RESULT or ERROR)
zacw@1759
    44
 * that we generated
zacw@1759
    45
 * if the generating function did not register a JabberIqCallback.
zacw@1759
    46
 *
zacw@1759
    47
 * @param js    The JabberStream object.
zacw@1759
    48
 * @param from  The remote entity (the from attribute on the <iq/> stanza)
zacw@1759
    49
 * @param type  The IQ type.
zacw@1759
    50
 * @param id    The IQ id (the id attribute on the <iq/> stanza)
zacw@1759
    51
 * @param child The child element of the <iq/> stanza that matches the name
zacw@1759
    52
 *              and namespace registered with jabber_iq_register_handler.
zacw@1759
    53
 *
zacw@1759
    54
 * @see jabber_iq_register_handler()
zacw@1759
    55
 * @see JabberIqCallback
zacw@1759
    56
 */
zacw@1759
    57
typedef void (JabberIqHandler)(JabberStream *js, const char *from,
zacw@1759
    58
                               JabberIqType type, const char *id,
zacw@1759
    59
                               xmlnode *child);
zacw@1759
    60
zacw@1759
    61
/**
zacw@1759
    62
 * A JabberIqCallback is called to process the results of a GET or SET that
zacw@1759
    63
 * we send to a remote entity. The callback is matched based on the id
zacw@1759
    64
 * of the incoming stanza (which matches the one on the initial stanza).
zacw@1759
    65
 *
zacw@1759
    66
 * @param js     The JabberStream object.
zacw@1759
    67
 * @param from   The remote entity (the from attribute on the <iq/> stanza)
zacw@1759
    68
 * @param type   The IQ type. The only possible values are JABBER_IQ_RESULT
zacw@1759
    69
 *               and JABBER_IQ_ERROR.
zacw@1759
    70
 * @param id     The IQ id (the id attribute on the <iq/> stanza)
zacw@1759
    71
 * @param packet The <iq/> stanza
zacw@1759
    72
 * @param data   The callback data passed to jabber_iq_set_callback()
zacw@1759
    73
 *
zacw@1759
    74
 * @see jabber_iq_set_callback()
zacw@1759
    75
 */
zacw@1759
    76
typedef void (JabberIqCallback)(JabberStream *js, const char *from,
zacw@1759
    77
                                JabberIqType type, const char *id,
zacw@1759
    78
                                xmlnode *packet, gpointer data);
zacw@1759
    79
zacw@1759
    80
struct _JabberIq {
zacw@1759
    81
	JabberIqType type;
zacw@1759
    82
	char *id;
zacw@1759
    83
	xmlnode *node;
zacw@1759
    84
zacw@1759
    85
	JabberIqCallback *callback;
zacw@1759
    86
	gpointer callback_data;
zacw@1759
    87
zacw@1759
    88
	JabberStream *js;
zacw@1759
    89
};
zacw@1759
    90
zacw@1759
    91
JabberIq *jabber_iq_new(JabberStream *js, JabberIqType type);
zacw@1759
    92
JabberIq *jabber_iq_new_query(JabberStream *js, JabberIqType type,
zacw@1759
    93
		const char *xmlns);
zacw@1759
    94
zacw@1759
    95
void jabber_iq_parse(JabberStream *js, xmlnode *packet);
zacw@1759
    96
zacw@1759
    97
void jabber_iq_remove_callback_by_id(JabberStream *js, const char *id);
zacw@1759
    98
void jabber_iq_set_callback(JabberIq *iq, JabberIqCallback *cb, gpointer data);
zacw@1759
    99
void jabber_iq_set_id(JabberIq *iq, const char *id);
zacw@1759
   100
zacw@1759
   101
void jabber_iq_send(JabberIq *iq);
zacw@1759
   102
void jabber_iq_free(JabberIq *iq);
zacw@1759
   103
zacw@1759
   104
void jabber_iq_init(void);
zacw@1759
   105
void jabber_iq_uninit(void);
zacw@1759
   106
zacw@1759
   107
void jabber_iq_register_handler(const char *node, const char *xmlns,
zacw@1759
   108
                                JabberIqHandler *func);
zacw@1759
   109
zacw@2250
   110
/* Connected to namespace-handler registration signals */
zacw@2250
   111
void jabber_iq_signal_register(const gchar *node, const gchar *xmlns);
zacw@2250
   112
void jabber_iq_signal_unregister(const gchar *node, const gchar *xmlns);
zacw@2250
   113
zacw@1759
   114
#endif /* PURPLE_JABBER_IQ_H_ */