Mercurial > pidgin.yaz
diff libpurple/dnssrv.h @ 31876:08dcd2d4f0b7
Added PurpleSrvTxtQueryUiOps which allow UIs to specify their own mechanisms
to resolve SRV and/or TXT queries.
Additionally, some functions and datatypes have been renamed to show which
are SRV only, which TXT only, and which are used by both.
author | thijsalkemade@gmail.com |
---|---|
date | Thu, 24 Mar 2011 23:22:29 +0000 |
parents | 63cb8c4f3c66 |
children | 0eceb1304f53 3448f64d197c |
line wrap: on
line diff
--- a/libpurple/dnssrv.h Thu Mar 24 15:18:14 2011 +0000 +++ b/libpurple/dnssrv.h Thu Mar 24 23:22:29 2011 +0000 @@ -28,12 +28,21 @@ extern "C" { #endif -typedef struct _PurpleSrvQueryData PurpleSrvQueryData; +typedef struct _PurpleSrvTxtQueryData PurpleSrvTxtQueryData; typedef struct _PurpleSrvResponse PurpleSrvResponse; typedef struct _PurpleTxtResponse PurpleTxtResponse; +/* For compatibility, should be removed for 3.0.0 + */ +typedef struct _PurpleSrvTxtQueryData PurpleSrvQueryData; + #include <glib.h> +enum PurpleDnsType { + PurpleDnsTypeTxt = 16, + PurpleDnsTypeSrv = 33 +}; + struct _PurpleSrvResponse { char hostname[256]; int port; @@ -41,6 +50,40 @@ int pref; }; +struct _PurpleTxtResponse { + char *content; +}; + +typedef void (*PurpleSrvTxtQueryResolvedCallback) (PurpleSrvTxtQueryData *query_data, GList *records); +typedef void (*PurpleSrvTxtQueryFailedCallback) (PurpleSrvTxtQueryData *query_data, const gchar *error_message); + +/** + * SRV Request UI operations; UIs should implement this if they want to do SRV + * lookups themselves, rather than relying on the core. + * + * @see @ref ui-ops + */ +typedef struct +{ + /** If implemented, return TRUE if the UI takes responsibility for SRV + * queries. When returning FALSE, the standard implementation is used. + * These callbacks MUST be called asynchronously. */ + gboolean (*resolve)(PurpleSrvTxtQueryData *query_data, + PurpleSrvTxtQueryResolvedCallback resolved_cb, + PurpleSrvTxtQueryFailedCallback failed_cb); + + /** Called just before @a query_data is freed; this should cancel any + * further use of @a query_data the UI would make. Unneeded if + * #resolve_host is not implemented. + */ + void (*destroy)(PurpleSrvTxtQueryData *query_data); + + void (*_purple_reserved1)(void); + void (*_purple_reserved2)(void); + void (*_purple_reserved3)(void); + void (*_purple_reserved4)(void); +} PurpleSrvTxtQueryUiOps; + /** * @param resp An array of PurpleSrvResponse of size results. The array * is sorted based on the order described in the DNS SRV RFC. @@ -66,14 +109,14 @@ * @param cb A callback which will be called with the results * @param extradata Extra data to be passed to the callback */ -PurpleSrvQueryData *purple_srv_resolve(const char *protocol, const char *transport, const char *domain, PurpleSrvCallback cb, gpointer extradata); +PurpleSrvTxtQueryData *purple_srv_resolve(const char *protocol, const char *transport, const char *domain, PurpleSrvCallback cb, gpointer extradata); /** - * Cancel an SRV DNS query. + * Cancel an SRV or DNS query. * * @param query_data The request to cancel. */ -void purple_srv_cancel(PurpleSrvQueryData *query_data); +void purple_srv_cancel(PurpleSrvTxtQueryData *query_data); /** * Queries an TXT record. @@ -85,7 +128,7 @@ * * @since 2.6.0 */ -PurpleSrvQueryData *purple_txt_resolve(const char *owner, const char *domain, PurpleTxtCallback cb, gpointer extradata); +PurpleSrvTxtQueryData *purple_txt_resolve(const char *owner, const char *domain, PurpleTxtCallback cb, gpointer extradata); /** * Cancel an TXT DNS query. @@ -93,7 +136,7 @@ * @param query_data The request to cancel. * @since 2.6.0 */ -void purple_txt_cancel(PurpleSrvQueryData *query_data); +void purple_txt_cancel(PurpleSrvTxtQueryData *query_data); /** * Get the value of the current TXT record. @@ -112,6 +155,47 @@ */ void purple_txt_response_destroy(PurpleTxtResponse *response); +/** + * Cancel a SRV/TXT query and destroy the associated data structure. + * + * @param query_data The SRV/TXT query to cancel. This data structure + * is freed by this function. + */ +void purple_srv_txt_query_destroy(PurpleSrvTxtQueryData *query_data); + +/** + * Sets the UI operations structure to be used when doing a SRV/TXT + * resolve. The UI operations need only be set if the UI wants to + * handle the resolve itself; otherwise, leave it as NULL. + * + * @param ops The UI operations structure. + */ +void purple_srv_txt_query_set_ui_ops(PurpleSrvTxtQueryUiOps *ops); + +/** + * Returns the UI operations structure to be used when doing a SRV/TXT + * resolve. + * + * @return The UI operations structure. + */ +PurpleSrvTxtQueryUiOps *purple_srv_txt_query_get_ui_ops(void); + +/** + * Get the query from a PurpleDnsQueryData + * + * @param query_data The SRV/TXT query + * @return The query. + */ +char *purple_srv_txt_query_get_query(PurpleSrvTxtQueryData *query_data); + +/** + * Get the type from a PurpleDnsQueryData (TXT or SRV) + * + * @param query_data The query + * @return The query. + */ +int purple_srv_txt_query_get_type(PurpleSrvTxtQueryData *query_data); + #ifdef __cplusplus } #endif