Frameworks/libpurple.framework/Versions/0.6.2/Headers/dnsquery.h
changeset 2592 e8d15275025e
parent 1739 8b0daad9656c
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/Frameworks/libpurple.framework/Versions/0.6.2/Headers/dnsquery.h	Fri Aug 21 13:25:11 2009 -0700
     1.3 @@ -0,0 +1,153 @@
     1.4 +/**
     1.5 + * @file dnsquery.h DNS query API
     1.6 + * @ingroup core
     1.7 + */
     1.8 +
     1.9 +/* purple
    1.10 + *
    1.11 + * Purple is the legal property of its developers, whose names are too numerous
    1.12 + * to list here.  Please refer to the COPYRIGHT file distributed with this
    1.13 + * source distribution.
    1.14 + *
    1.15 + * This program is free software; you can redistribute it and/or modify
    1.16 + * it under the terms of the GNU General Public License as published by
    1.17 + * the Free Software Foundation; either version 2 of the License, or
    1.18 + * (at your option) any later version.
    1.19 + *
    1.20 + * This program is distributed in the hope that it will be useful,
    1.21 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
    1.22 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    1.23 + * GNU General Public License for more details.
    1.24 + *
    1.25 + * You should have received a copy of the GNU General Public License
    1.26 + * along with this program; if not, write to the Free Software
    1.27 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02111-1301  USA
    1.28 + */
    1.29 +#ifndef _PURPLE_DNSQUERY_H_
    1.30 +#define _PURPLE_DNSQUERY_H_
    1.31 +
    1.32 +#include <glib.h>
    1.33 +#include "eventloop.h"
    1.34 +#include "account.h"
    1.35 +
    1.36 +typedef struct _PurpleDnsQueryData PurpleDnsQueryData;
    1.37 +
    1.38 +/**
    1.39 + * The "hosts" parameter is a linked list containing pairs of
    1.40 + * one size_t addrlen and one struct sockaddr *addr.  It should
    1.41 + * be free'd by the callback function.
    1.42 + */
    1.43 +typedef void (*PurpleDnsQueryConnectFunction)(GSList *hosts, gpointer data, const char *error_message);
    1.44 +
    1.45 +/**
    1.46 + * Callbacks used by the UI if it handles resolving DNS
    1.47 + */
    1.48 +typedef void  (*PurpleDnsQueryResolvedCallback) (PurpleDnsQueryData *query_data, GSList *hosts);
    1.49 +typedef void  (*PurpleDnsQueryFailedCallback) (PurpleDnsQueryData *query_data, const gchar *error_message);
    1.50 +
    1.51 +/**
    1.52 + * DNS Request UI operations;  UIs should implement this if they want to do DNS
    1.53 + * lookups themselves, rather than relying on the core.
    1.54 + *
    1.55 + * @see @ref ui-ops
    1.56 + */
    1.57 +typedef struct
    1.58 +{
    1.59 +	/** If implemented, the UI is responsible for DNS queries */
    1.60 +	gboolean (*resolve_host)(PurpleDnsQueryData *query_data,
    1.61 +	                         PurpleDnsQueryResolvedCallback resolved_cb,
    1.62 +	                         PurpleDnsQueryFailedCallback failed_cb);
    1.63 +
    1.64 +	/** Called just before @a query_data is freed; this should cancel any
    1.65 +	 *  further use of @a query_data the UI would make. Unneeded if
    1.66 +	 *  #resolve_host is not implemented.
    1.67 +	 */
    1.68 +	void (*destroy)(PurpleDnsQueryData *query_data);
    1.69 +
    1.70 +	void (*_purple_reserved1)(void);
    1.71 +	void (*_purple_reserved2)(void);
    1.72 +	void (*_purple_reserved3)(void);
    1.73 +	void (*_purple_reserved4)(void);
    1.74 +} PurpleDnsQueryUiOps;
    1.75 +
    1.76 +#ifdef __cplusplus
    1.77 +extern "C" {
    1.78 +#endif
    1.79 +
    1.80 +/**************************************************************************/
    1.81 +/** @name DNS query API                                                   */
    1.82 +/**************************************************************************/
    1.83 +/*@{*/
    1.84 +
    1.85 +/**
    1.86 + * Perform an asynchronous DNS query.
    1.87 + *
    1.88 + * @param hostname The hostname to resolve.
    1.89 + * @param port     A port number which is stored in the struct sockaddr.
    1.90 + * @param callback The callback function to call after resolving.
    1.91 + * @param data     Extra data to pass to the callback function.
    1.92 + *
    1.93 + * @return NULL if there was an error, otherwise return a reference to
    1.94 + *         a data structure that can be used to cancel the pending
    1.95 + *         DNS query, if needed.
    1.96 + */
    1.97 +PurpleDnsQueryData *purple_dnsquery_a(const char *hostname, int port, PurpleDnsQueryConnectFunction callback, gpointer data);
    1.98 +
    1.99 +/**
   1.100 + * Cancel a DNS query and destroy the associated data structure.
   1.101 + *
   1.102 + * @param query_data The DNS query to cancel.  This data structure
   1.103 + *        is freed by this function.
   1.104 + */
   1.105 +void purple_dnsquery_destroy(PurpleDnsQueryData *query_data);
   1.106 +
   1.107 +/**
   1.108 + * Sets the UI operations structure to be used when doing a DNS
   1.109 + * resolve.  The UI operations need only be set if the UI wants to
   1.110 + * handle the resolve itself; otherwise, leave it as NULL.
   1.111 + *
   1.112 + * @param ops The UI operations structure.
   1.113 + */
   1.114 +void purple_dnsquery_set_ui_ops(PurpleDnsQueryUiOps *ops);
   1.115 +
   1.116 +/**
   1.117 + * Returns the UI operations structure to be used when doing a DNS
   1.118 + * resolve.
   1.119 + *
   1.120 + * @return The UI operations structure.
   1.121 + */
   1.122 +PurpleDnsQueryUiOps *purple_dnsquery_get_ui_ops(void);
   1.123 +
   1.124 +/**
   1.125 + * Get the host associated with a PurpleDnsQueryData
   1.126 + *
   1.127 + * @param query_data The DNS query
   1.128 + * @return The host.
   1.129 + */
   1.130 +char *purple_dnsquery_get_host(PurpleDnsQueryData *query_data);
   1.131 +
   1.132 +/**
   1.133 + * Get the port associated with a PurpleDnsQueryData
   1.134 + *
   1.135 + * @param query_data The DNS query
   1.136 + * @return The port.
   1.137 + */
   1.138 +unsigned short purple_dnsquery_get_port(PurpleDnsQueryData *query_data);
   1.139 +
   1.140 +/**
   1.141 + * Initializes the DNS query subsystem.
   1.142 + */
   1.143 +void purple_dnsquery_init(void);
   1.144 +
   1.145 +/**
   1.146 + * Uninitializes the DNS query subsystem.
   1.147 + */
   1.148 +void purple_dnsquery_uninit(void);
   1.149 +
   1.150 +/*@}*/
   1.151 +
   1.152 +#ifdef __cplusplus
   1.153 +}
   1.154 +#endif
   1.155 +
   1.156 +#endif /* _PURPLE_DNSQUERY_H_ */