These changes are reuired to make the Windows installer build.
[pidgin-git.git] / libpurple / dnsquery.h
blobd68286414c6411db8026b4d534f302dbe1c7e515
1 /**
2 * @file dnsquery.h DNS query API
3 * @ingroup core
4 */
6 /* purple
8 * Purple is the legal property of its developers, whose names are too numerous
9 * to list here. Please refer to the COPYRIGHT file distributed with this
10 * source distribution.
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or
15 * (at your option) any later version.
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
26 #ifndef _PURPLE_DNSQUERY_H_
27 #define _PURPLE_DNSQUERY_H_
29 #include <glib.h>
30 #include "eventloop.h"
31 #include "account.h"
33 /**
34 * An opaque structure representing a DNS query. The hostname and port
35 * associated with the query can be retrieved using
36 * purple_dnsquery_get_host() and purple_dnsquery_get_port().
38 typedef struct _PurpleDnsQueryData PurpleDnsQueryData;
40 /**
41 * The "hosts" parameter is a linked list containing pairs of
42 * one size_t addrlen and one struct sockaddr *addr. It should
43 * be free'd by the callback function.
45 typedef void (*PurpleDnsQueryConnectFunction)(GSList *hosts, gpointer data, const char *error_message);
47 /**
48 * Callbacks used by the UI if it handles resolving DNS
50 typedef void (*PurpleDnsQueryResolvedCallback) (PurpleDnsQueryData *query_data, GSList *hosts);
51 typedef void (*PurpleDnsQueryFailedCallback) (PurpleDnsQueryData *query_data, const gchar *error_message);
53 /**
54 * DNS Request UI operations; UIs should implement this if they want to do DNS
55 * lookups themselves, rather than relying on the core.
57 * @see @ref ui-ops
59 typedef struct
61 /** If implemented, the UI is responsible for DNS queries */
62 gboolean (*resolve_host)(PurpleDnsQueryData *query_data,
63 PurpleDnsQueryResolvedCallback resolved_cb,
64 PurpleDnsQueryFailedCallback failed_cb);
66 /** Called just before @a query_data is freed; this should cancel any
67 * further use of @a query_data the UI would make. Unneeded if
68 * #resolve_host is not implemented.
70 void (*destroy)(PurpleDnsQueryData *query_data);
72 void (*_purple_reserved1)(void);
73 void (*_purple_reserved2)(void);
74 void (*_purple_reserved3)(void);
75 void (*_purple_reserved4)(void);
76 } PurpleDnsQueryUiOps;
78 #ifdef __cplusplus
79 extern "C" {
80 #endif
82 /**************************************************************************/
83 /** @name DNS query API */
84 /**************************************************************************/
85 /*@{*/
87 /**
88 * Perform an asynchronous DNS query.
90 * @param hostname The hostname to resolve.
91 * @param port A port number which is stored in the struct sockaddr.
92 * @param callback The callback function to call after resolving.
93 * @param data Extra data to pass to the callback function.
95 * @return NULL if there was an error, otherwise return a reference to
96 * a data structure that can be used to cancel the pending
97 * DNS query, if needed.
99 PurpleDnsQueryData *purple_dnsquery_a(const char *hostname, int port, PurpleDnsQueryConnectFunction callback, gpointer data);
102 * Cancel a DNS query and destroy the associated data structure.
104 * @param query_data The DNS query to cancel. This data structure
105 * is freed by this function.
107 void purple_dnsquery_destroy(PurpleDnsQueryData *query_data);
110 * Sets the UI operations structure to be used when doing a DNS
111 * resolve. The UI operations need only be set if the UI wants to
112 * handle the resolve itself; otherwise, leave it as NULL.
114 * @param ops The UI operations structure.
116 void purple_dnsquery_set_ui_ops(PurpleDnsQueryUiOps *ops);
119 * Returns the UI operations structure to be used when doing a DNS
120 * resolve.
122 * @return The UI operations structure.
124 PurpleDnsQueryUiOps *purple_dnsquery_get_ui_ops(void);
127 * Get the host associated with a PurpleDnsQueryData
129 * @param query_data The DNS query
130 * @return The host.
132 char *purple_dnsquery_get_host(PurpleDnsQueryData *query_data);
135 * Get the port associated with a PurpleDnsQueryData
137 * @param query_data The DNS query
138 * @return The port.
140 unsigned short purple_dnsquery_get_port(PurpleDnsQueryData *query_data);
143 * Initializes the DNS query subsystem.
145 void purple_dnsquery_init(void);
148 * Uninitializes the DNS query subsystem.
150 void purple_dnsquery_uninit(void);
152 /*@}*/
154 #ifdef __cplusplus
156 #endif
158 #endif /* _PURPLE_DNSQUERY_H_ */