libpurple/dnssrv.h

changeset 37468
2a1934a1e457
parent 37436
1f30661ee575
parent 37467
37d053fc8907
child 37469
f238b0a5ee69
equal deleted inserted replaced
37436:1f30661ee575 37468:2a1934a1e457
1 /* purple
2 *
3 * Copyright (C) 2005, Thomas Butter <butter@uni-mannheim.de>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
18 */
19
20 #ifndef _PURPLE_DNSSRV_H
21 #define _PURPLE_DNSSRV_H
22 /**
23 * SECTION:dnssrv
24 * @section_id: libpurple-dnssrv
25 * @short_description: <filename>dnssrv.h</filename>
26 * @title: DNS SRV Utilities
27 */
28
29 #define PURPLE_TYPE_SRV_TXT_QUERY_UI_OPS (purple_srv_txt_query_ui_ops_get_type())
30
31 typedef struct _PurpleSrvTxtQueryData PurpleSrvTxtQueryData;
32 typedef struct _PurpleSrvResponse PurpleSrvResponse;
33 typedef struct _PurpleTxtResponse PurpleTxtResponse;
34 typedef struct _PurpleSrvTxtQueryUiOps PurpleSrvTxtQueryUiOps;
35
36 #include <glib.h>
37 #include <glib-object.h>
38
39 struct _PurpleSrvResponse {
40 char hostname[256];
41 int port;
42 int weight;
43 int pref;
44 };
45
46 struct _PurpleTxtResponse {
47 char *content;
48 };
49
50 typedef void (*PurpleSrvTxtQueryResolvedCallback) (PurpleSrvTxtQueryData *query_data, GList *records);
51 typedef void (*PurpleSrvTxtQueryFailedCallback) (PurpleSrvTxtQueryData *query_data, const gchar *error_message);
52
53 /**
54 * PurpleSrvTxtQueryUiOps:
55 * @resolve: implemented, return %TRUE if the UI takes responsibility for SRV
56 * queries. When returning %FALSE, the standard implementation is
57 * used. These callbacks <emphasis>MUST</emphasis> be called
58 * asynchronously.
59 * @destroy: Called just before @query_data is freed; this should cancel any
60 * further use of @query_data the UI would make. Unneeded if @resolve
61 * is not implemented.
62 *
63 * SRV Request UI operations; UIs should implement this if they want to do SRV
64 * lookups themselves, rather than relying on the core.
65 *
66 * See <link linkend="chapter-ui-ops">List of <literal>UiOps</literal> Structures</link>
67 */
68 struct _PurpleSrvTxtQueryUiOps
69 {
70 gboolean (*resolve)(PurpleSrvTxtQueryData *query_data,
71 PurpleSrvTxtQueryResolvedCallback resolved_cb,
72 PurpleSrvTxtQueryFailedCallback failed_cb);
73
74 void (*destroy)(PurpleSrvTxtQueryData *query_data);
75
76 /*< private >*/
77 void (*_purple_reserved1)(void);
78 void (*_purple_reserved2)(void);
79 void (*_purple_reserved3)(void);
80 void (*_purple_reserved4)(void);
81 };
82
83 /**
84 * PurpleSrvCallback:
85 * @resp: An array of PurpleSrvResponse of size results. The array
86 * is sorted based on the order described in the DNS SRV RFC.
87 * Users of this API should try each record in resp in order,
88 * starting at the beginning.
89 */
90 typedef void (*PurpleSrvCallback)(PurpleSrvResponse *resp, int results, gpointer data);
91
92 /**
93 * PurpleTxtCallback:
94 * @responses: A GList of PurpleTxtResponse objects.
95 * @data: The extra data passed to purple_txt_resolve.
96 *
97 * Callback that returns the data retrieved from a DNS TXT lookup.
98 */
99 typedef void (*PurpleTxtCallback)(GList *responses, gpointer data);
100
101 G_BEGIN_DECLS
102
103 /**
104 * purple_srv_txt_query_ui_ops_get_type:
105 *
106 * Returns: The #GType for the #PurpleSrvTxtQueryUiOps boxed structure.
107 */
108 GType purple_srv_txt_query_ui_ops_get_type(void);
109
110 /**
111 * purple_srv_resolve:
112 * @account: The account that the query is being done for (or %NULL)
113 * @protocol: Name of the protocol (e.g. "sip")
114 * @transport: Name of the transport ("tcp" or "udp")
115 * @domain: Domain name to query (e.g. "blubb.com")
116 * @cb: (scope call): A callback which will be called with the results
117 * @extradata: Extra data to be passed to the callback
118 *
119 * Queries an SRV record.
120 *
121 * Returns: %NULL if there was an error, otherwise return a reference to
122 * a data structure that can be used to cancel the pending
123 * DNS query, if needed.
124 */
125 PurpleSrvTxtQueryData *purple_srv_resolve(PurpleAccount *account, const char *protocol, const char *transport, const char *domain, PurpleSrvCallback cb, gpointer extradata);
126
127 /**
128 * purple_txt_resolve:
129 * @account: The account that the query is being done for (or %NULL)
130 * @owner: Name of the protocol (e.g. "_xmppconnect")
131 * @domain: Domain name to query (e.g. "blubb.com")
132 * @cb: (scope call): A callback which will be called with the results
133 * @extradata: Extra data to be passed to the callback
134 *
135 * Queries an TXT record.
136 *
137 * Returns: %NULL if there was an error, otherwise return a reference to
138 * a data structure that can be used to cancel the pending
139 * DNS query, if needed.
140 */
141 PurpleSrvTxtQueryData *purple_txt_resolve(PurpleAccount *account, const char *owner, const char *domain, PurpleTxtCallback cb, gpointer extradata);
142
143 /**
144 * purple_txt_response_get_content:
145 * @response: The TXT response record
146 *
147 * Get the value of the current TXT record.
148 *
149 * Returns: The value of the current TXT record.
150 */
151 const gchar *purple_txt_response_get_content(PurpleTxtResponse *response);
152
153 /**
154 * purple_txt_response_destroy:
155 * @response: The PurpleTxtResponse to destroy.
156 *
157 * Destroy a TXT DNS response object.
158 */
159 void purple_txt_response_destroy(PurpleTxtResponse *response);
160
161 /**
162 * purple_srv_txt_query_destroy:
163 * @query_data: The SRV/TXT query to cancel. This data structure
164 * is freed by this function.
165 *
166 * Cancel a SRV/TXT query and destroy the associated data structure.
167 */
168 void purple_srv_txt_query_destroy(PurpleSrvTxtQueryData *query_data);
169
170 /**
171 * purple_srv_txt_query_set_ui_ops:
172 * @ops: The UI operations structure.
173 *
174 * Sets the UI operations structure to be used when doing a SRV/TXT
175 * resolve. The UI operations need only be set if the UI wants to
176 * handle the resolve itself; otherwise, leave it as NULL.
177 */
178 void purple_srv_txt_query_set_ui_ops(PurpleSrvTxtQueryUiOps *ops);
179
180 /**
181 * purple_srv_txt_query_get_ui_ops:
182 *
183 * Returns the UI operations structure to be used when doing a SRV/TXT
184 * resolve.
185 *
186 * Returns: The UI operations structure.
187 */
188 PurpleSrvTxtQueryUiOps *purple_srv_txt_query_get_ui_ops(void);
189
190 /**
191 * purple_srv_txt_query_get_query:
192 * @query_data: The SRV/TXT query
193 *
194 * Get the query from a PurpleSrvTxtQueryData
195 *
196 * Returns: The query.
197 */
198 char *purple_srv_txt_query_get_query(PurpleSrvTxtQueryData *query_data);
199
200 /**
201 * purple_srv_txt_query_get_query_type:
202 * @query_data: The query
203 *
204 * Get the type from a PurpleSrvTxtQueryData (TXT or SRV)
205 *
206 * Returns: The query type.
207 */
208 int purple_srv_txt_query_get_query_type(PurpleSrvTxtQueryData *query_data);
209
210 G_END_DECLS
211
212 #endif /* _PURPLE_DNSSRV_H */
213

mercurial