pidgin: 5ef0b1be: Fixes to the PurpleSrvTxtQueryUiOps code...
darkrain42 at pidgin.im
darkrain42 at pidgin.im
Sun Jul 17 13:26:07 EDT 2011
----------------------------------------------------------------------
Revision: 5ef0b1be0093e35cabb262017f3ee49c7b308c82
Parent: ae8a393feae88af209e008a7d205d28f92c5c4e4
Author: thijsalkemade at gmail.com
Date: 07/17/11 13:14:21
Branch: im.pidgin.pidgin
URL: http://d.pidgin.im/viewmtn/revision/info/5ef0b1be0093e35cabb262017f3ee49c7b308c82
Changelog:
Fixes to the PurpleSrvTxtQueryUiOps code. Refs #12647
Changes against parent ae8a393feae88af209e008a7d205d28f92c5c4e4
patched ChangeLog.API
patched libpurple/dnssrv.c
patched libpurple/dnssrv.h
-------------- next part --------------
============================================================
--- ChangeLog.API 983c801f9823e2ea868c94e9f8f8200701331b08
+++ ChangeLog.API a6af0e10c6c7040694ccc146a633c59d1aee327c
@@ -1,6 +1,10 @@ version 2.10.0:
Pidgin and Finch: The Pimpin' Penguin IM Clients That're Good for the Soul
version 2.10.0:
+ libpurple:
+ Added:
+ * purple_srv_txt_query_destroy (accidentally left out of 2.8.0)
+
Pidgin:
Added:
* pidgin_dialogs_plugins_info (should not be used by anything but Pidgin)
============================================================
--- libpurple/dnssrv.c f0f0b672d16c88368ff684b3127ca914f5a1136c
+++ libpurple/dnssrv.c 3c322cf1d666750eda746b6cd1a95033e2fd32d2
@@ -523,7 +523,7 @@ resolved(gpointer data, gint source, Pur
}
waitpid(query_data->pid, &status, 0);
- purple_srv_cancel(query_data);
+ purple_srv_txt_query_destroy(query_data);
}
#else /* _WIN32 */
@@ -583,7 +583,7 @@ res_main_thread_cb(gpointer data)
query_data->resolver = NULL;
query_data->handle = 0;
- purple_srv_cancel(query_data);
+ purple_srv_txt_query_destroy(query_data);
return FALSE;
}
@@ -736,6 +736,8 @@ purple_srv_resolve_account(PurpleAccount
query_data->cb.srv = cb;
query_data->extradata = extradata;
query_data->query = query;
+ query_data->fd_in = -1;
+ query_data->fd_out = -1;
if (purple_srv_txt_query_ui_resolve(query_data))
{
@@ -868,6 +870,8 @@ PurpleSrvTxtQueryData *purple_txt_resolv
query_data->cb.txt = cb;
query_data->extradata = extradata;
query_data->query = query;
+ query_data->fd_in = -1;
+ query_data->fd_out = -1;
if (purple_srv_txt_query_ui_resolve(query_data)) {
/* query intentionally not freed
@@ -949,7 +953,7 @@ void
}
void
-purple_srv_cancel(PurpleSrvTxtQueryData *query_data)
+purple_srv_txt_query_destroy(PurpleSrvTxtQueryData *query_data)
{
PurpleSrvTxtQueryUiOps *ops = purple_srv_txt_query_get_ui_ops();
@@ -969,21 +973,29 @@ purple_srv_cancel(PurpleSrvTxtQueryData
query_data->cb.srv = NULL;
return;
}
- g_free(query_data->query);
g_free(query_data->error_message);
#else
- close(query_data->fd_out);
- close(query_data->fd_in);
+ if (query_data->fd_out != -1)
+ close(query_data->fd_out);
+ if (query_data->fd_in != -1)
+ close(query_data->fd_in);
#endif
+ g_free(query_data->query);
g_free(query_data);
}
void
purple_txt_cancel(PurpleSrvTxtQueryData *query_data)
{
- purple_srv_cancel(query_data);
+ purple_srv_txt_query_destroy(query_data);
}
+void
+purple_srv_cancel(PurpleSrvTxtQueryData *query_data)
+{
+ purple_srv_txt_query_destroy(query_data);
+}
+
const gchar *
purple_txt_response_get_content(PurpleTxtResponse *resp)
{
@@ -1006,12 +1018,38 @@ purple_srv_query_resolved(PurpleSrvTxtQu
static void
purple_srv_query_resolved(PurpleSrvTxtQueryData *query_data, GList *records)
{
+ GList *sorted_records, *l;
+ PurpleSrvResponse *records_array;
+ int i;
+
g_return_if_fail(records != NULL);
+
+ if (query_data->cb.srv == NULL) {
+ purple_srv_txt_query_destroy(query_data);
+
+ g_list_foreach(records, (GFunc)g_free, NULL);
+ g_list_free(records);
+ return;
+ }
+
+ sorted_records = purple_srv_sort(records);
+
+ purple_debug_info("dnssrv", "SRV records resolved for %s, count: %d\n", query_data->query, g_list_length(sorted_records));
+
+ records_array = g_new(PurpleSrvResponse, g_list_length(sorted_records));
+
+ i = 0;
+
+ for (l = sorted_records; l; l = l->next, i++) {
+ records_array[i] = *(PurpleSrvResponse *)l->data;
+ }
+
+ query_data->cb.srv(records_array, i, query_data->extradata);
- purple_debug_info("dnssrv", "SRV records resolved for %s, count: %d\n", query_data->query, g_list_length(records));
+ purple_srv_txt_query_destroy(query_data);
- if (query_data->cb.srv != NULL)
- query_data->cb.srv(purple_srv_sort(records)->data, g_list_length(records), query_data->extradata);
+ g_list_foreach(sorted_records, (GFunc)g_free, NULL);
+ g_list_free(sorted_records);
}
/*
@@ -1024,8 +1062,16 @@ purple_txt_query_resolved(PurpleSrvTxtQu
purple_debug_info("dnssrv", "TXT entries resolved for %s, count: %d\n", query_data->query, g_list_length(entries));
+ /* the callback should g_free the entries.
+ */
if (query_data->cb.txt != NULL)
query_data->cb.txt(entries, query_data->extradata);
+ else {
+ g_list_foreach(entries, (GFunc)g_free, NULL);
+ g_list_free(entries);
+ }
+
+ purple_srv_txt_query_destroy(query_data);
}
static void
@@ -1036,7 +1082,7 @@ purple_srv_query_failed(PurpleSrvTxtQuer
if (query_data->cb.srv != NULL)
query_data->cb.srv(NULL, 0, query_data->extradata);
- purple_srv_cancel(query_data);
+ purple_srv_txt_query_destroy(query_data);
}
static gboolean
============================================================
--- libpurple/dnssrv.h fb5a5c37acfea95ea78541872185ea5ae1e87991
+++ libpurple/dnssrv.h 5dc4a90b9bc983c7be1b0d022bcb6a277aac7e5a
@@ -133,6 +133,8 @@ PurpleSrvTxtQueryData *purple_srv_resolv
* Cancel an SRV or DNS query.
*
* @param query_data The request to cancel.
+ *
+ * @deprecated Use purple_srv_txt_query_destroy instead
*/
void purple_srv_cancel(PurpleSrvTxtQueryData *query_data);
@@ -170,6 +172,8 @@ PurpleSrvTxtQueryData *purple_txt_resolv
*
* @param query_data The request to cancel.
* @since 2.6.0
+ *
+ * @deprecated Use purple_srv_txt_query_destroy instead
*/
void purple_txt_cancel(PurpleSrvTxtQueryData *query_data);
More information about the Commits
mailing list