Mercurial > pidgin.yaz
diff libpurple/account.c @ 24838:0d7c21b5f1d7
propagate from branch 'im.pidgin.pidgin' (head c06356e8e8d2c586f0192a5564053c2584020da8)
to branch 'im.pidgin.pidgin.openq' (head a7077bc12b850d60ea7d768f4b9d4ee6ae6ad2c1)
author | SHiNE CsyFeK <csyfek@gmail.com> |
---|---|
date | Thu, 25 Dec 2008 14:06:10 +0000 |
parents | 98ec72f8f3cc |
children | ff883620d9d4 65cfc59858cf 1260a3fb60f4 |
line wrap: on
line diff
--- a/libpurple/account.c Wed Dec 17 13:52:00 2008 +0000 +++ b/libpurple/account.c Thu Dec 25 14:06:10 2008 +0000 @@ -75,6 +75,7 @@ gpointer userdata; PurpleAccountRequestAuthorizationCb auth_cb; PurpleAccountRequestAuthorizationCb deny_cb; + guint ref; } PurpleAccountRequestInfo; static PurpleAccountUiOps *account_ui_ops = NULL; @@ -1211,6 +1212,18 @@ ui_ops->request_add(account, remote_user, id, alias, message); } +static PurpleAccountRequestInfo * +purple_account_request_info_unref(PurpleAccountRequestInfo *info) +{ + if (--info->ref) + return info; + + /* TODO: This will leak info->user_data, but there is no callback to just clean that up */ + g_free(info->user); + g_free(info); + return NULL; +} + static void purple_account_request_close_info(PurpleAccountRequestInfo *info) { @@ -1221,11 +1234,7 @@ if (ops != NULL && ops->close_account_request != NULL) ops->close_account_request(info->ui_handle); - /* TODO: This will leak info->user_data, but there is no callback to just clean that up */ - - g_free(info->user); - g_free(info); - + purple_account_request_info_unref(info); } void @@ -1278,8 +1287,7 @@ purple_signal_emit(purple_accounts_get_handle(), "account-authorization-granted", info->account, info->user); - g_free(info->user); - g_free(info); + purple_account_request_info_unref(info); } static void @@ -1294,8 +1302,7 @@ purple_signal_emit(purple_accounts_get_handle(), "account-authorization-denied", info->account, info->user); - g_free(info->user); - g_free(info); + purple_account_request_info_unref(info); } void * @@ -1332,11 +1339,18 @@ info->deny_cb = deny_cb; info->userdata = user_data; info->user = g_strdup(remote_user); + info->ref = 2; /* We hold an extra ref to make sure info remains valid + if any of the callbacks are called synchronously. We + unref it after the function call */ + info->ui_handle = ui_ops->request_authorize(account, remote_user, id, alias, message, on_list, request_auth_cb, request_deny_cb, info); - handles = g_list_append(handles, info); - return info->ui_handle; + info = purple_account_request_info_unref(info); + if (info) { + handles = g_list_append(handles, info); + return info->ui_handle; + } } return NULL; @@ -2499,7 +2513,7 @@ purple_accounts_remove(account); /* Remove this account's buddies */ - for (gnode = purple_get_blist()->root; gnode != NULL; gnode = gnode->next) { + for (gnode = purple_blist_get_root(); gnode != NULL; gnode = gnode->next) { if (!PURPLE_BLIST_NODE_IS_GROUP(gnode)) continue;