/pidgin/main: 9454bda83147: Add response message to authorizatio...
Elliott Sales de Andrade
qulogic at pidgin.im
Sun Jan 27 05:57:49 EST 2013
Changeset: 9454bda8314762d8c9eff0e69c72bceb7e288b8f
Author: Elliott Sales de Andrade <qulogic at pidgin.im>
Date: 2013-01-26 03:20 -0500
Branch: default
URL: http://hg.pidgin.im/pidgin/main/rev/9454bda83147
Description:
Add response message to authorization signals.
Fixes #8049.
diffstat:
doc/account-signals.dox | 15 +++++++++------
libpurple/account.c | 37 +++++++++++++++++++++++--------------
libpurple/plugins/signals-test.c | 14 +++++++-------
3 files changed, 39 insertions(+), 27 deletions(-)
diffs (181 lines):
diff --git a/doc/account-signals.dox b/doc/account-signals.dox
--- a/doc/account-signals.dox
+++ b/doc/account-signals.dox
@@ -144,13 +144,14 @@ void (*account_alias_changed)(PurpleAcco
@signaldef account-authorization-requested
@signalproto
-int (*account_authorization_requested)(PurpleAccount *account, const char *user, const char *message);
+int (*account_authorization_requested)(PurpleAccount *account, const char *user, const char *message, char **response);
@endsignalproto
@signaldesc
Emitted when a user requests authorization.
- @param account The account.
- @param user The name of the user requesting authorization.
- @param message The authorization request message
+ @param account The account.
+ @param user The name of the user requesting authorization.
+ @param message The authorization request message.
+ @param response The message to send in the response.
@return PURPLE_ACCOUNT_RESPONSE_IGNORE to silently ignore the request,
PURPLE_ACCOUNT_RESPONSE_DENY to block the request (the sender might
get informed), PURPLE_ACCOUNT_RESPONSE_ACCEPT if the request should be
@@ -160,22 +161,24 @@ int (*account_authorization_requested)(P
@signaldef account-authorization-denied
@signalproto
-void (*account_authorization_denied)(PurpleAccount *account, const char *user);
+void (*account_authorization_denied)(PurpleAccount *account, const char *user, const char *message);
@endsignalproto
@signaldesc
Emitted when the authorization request for a buddy is denied.
@param account The account.
@param user The name of the user requesting authorization.
+ @param message The message to tell the buddy who was denied.
@endsignaldef
@signaldef account-authorization-granted
@signalproto
-void (*account_authorization_granted)(PurpleAccount *account, const char *user);
+void (*account_authorization_granted)(PurpleAccount *account, const char *user, const char *message);
@endsignalproto
@signaldesc
Emitted when the authorization request for a buddy is granted.
@param account The account.
@param user The name of the user requesting authorization.
+ @param message The message to tell the buddy who was granted authorization.
@endsignaldef
@signaldef account-error-changed
diff --git a/libpurple/account.c b/libpurple/account.c
--- a/libpurple/account.c
+++ b/libpurple/account.c
@@ -1388,7 +1388,7 @@ request_auth_cb(const char *message, voi
info->auth_cb(message, info->userdata);
purple_signal_emit(purple_accounts_get_handle(),
- "account-authorization-granted", info->account, info->user);
+ "account-authorization-granted", info->account, info->user, message);
purple_account_request_info_unref(info);
}
@@ -1404,7 +1404,7 @@ request_deny_cb(const char *message, voi
info->deny_cb(message, info->userdata);
purple_signal_emit(purple_accounts_get_handle(),
- "account-authorization-denied", info->account, info->user);
+ "account-authorization-denied", info->account, info->user, message);
purple_account_request_info_unref(info);
}
@@ -1417,6 +1417,7 @@ purple_account_request_authorization(Pur
PurpleAccountUiOps *ui_ops;
PurpleAccountRequestInfo *info;
int plugin_return;
+ char *response = NULL;
g_return_val_if_fail(account != NULL, NULL);
g_return_val_if_fail(remote_user != NULL, NULL);
@@ -1427,23 +1428,28 @@ purple_account_request_authorization(Pur
purple_signal_emit_return_1(
purple_accounts_get_handle(),
"account-authorization-requested",
- account, remote_user, message
+ account, remote_user, message, &response
));
switch (plugin_return)
{
case PURPLE_ACCOUNT_RESPONSE_IGNORE:
+ g_free(response);
return NULL;
case PURPLE_ACCOUNT_RESPONSE_ACCEPT:
if (auth_cb != NULL)
- auth_cb(NULL, user_data);
+ auth_cb(response, user_data);
+ g_free(response);
return NULL;
case PURPLE_ACCOUNT_RESPONSE_DENY:
if (deny_cb != NULL)
- deny_cb(NULL, user_data);
+ deny_cb(response, user_data);
+ g_free(response);
return NULL;
}
+ g_free(response);
+
if (ui_ops != NULL && ui_ops->request_authorize != NULL) {
info = g_new0(PurpleAccountRequestInfo, 1);
info->type = PURPLE_ACCOUNT_REQUEST_AUTHORIZATION;
@@ -3075,22 +3081,25 @@ purple_accounts_init(void)
purple_signal_register(handle, "account-authorization-requested",
purple_marshal_INT__POINTER_POINTER_POINTER,
- purple_value_new(PURPLE_TYPE_INT), 3,
+ purple_value_new(PURPLE_TYPE_INT), 4,
+ purple_value_new(PURPLE_TYPE_SUBTYPE,
+ PURPLE_SUBTYPE_ACCOUNT),
+ purple_value_new(PURPLE_TYPE_STRING),
+ purple_value_new(PURPLE_TYPE_STRING),
+ purple_value_new(PURPLE_TYPE_STRING));
+
+ purple_signal_register(handle, "account-authorization-denied",
+ purple_marshal_VOID__POINTER_POINTER, NULL, 3,
purple_value_new(PURPLE_TYPE_SUBTYPE,
PURPLE_SUBTYPE_ACCOUNT),
purple_value_new(PURPLE_TYPE_STRING),
purple_value_new(PURPLE_TYPE_STRING));
- purple_signal_register(handle, "account-authorization-denied",
- purple_marshal_VOID__POINTER_POINTER, NULL, 2,
+ purple_signal_register(handle, "account-authorization-granted",
+ purple_marshal_VOID__POINTER_POINTER, NULL, 3,
purple_value_new(PURPLE_TYPE_SUBTYPE,
PURPLE_SUBTYPE_ACCOUNT),
- purple_value_new(PURPLE_TYPE_STRING));
-
- purple_signal_register(handle, "account-authorization-granted",
- purple_marshal_VOID__POINTER_POINTER, NULL, 2,
- purple_value_new(PURPLE_TYPE_SUBTYPE,
- PURPLE_SUBTYPE_ACCOUNT),
+ purple_value_new(PURPLE_TYPE_STRING),
purple_value_new(PURPLE_TYPE_STRING));
purple_signal_register(handle, "account-error-changed",
diff --git a/libpurple/plugins/signals-test.c b/libpurple/plugins/signals-test.c
--- a/libpurple/plugins/signals-test.c
+++ b/libpurple/plugins/signals-test.c
@@ -78,7 +78,7 @@ account_alias_changed(PurpleAccount *acc
}
static int
-account_authorization_requested_cb(PurpleAccount *account, const char *user, const char *message, gpointer data)
+account_authorization_requested_cb(PurpleAccount *account, const char *user, const char *message, char *response, gpointer data)
{
purple_debug_misc("signals test", "account-authorization-requested (%s, %s, %s)\n",
purple_account_get_username(account), user, message);
@@ -86,17 +86,17 @@ account_authorization_requested_cb(Purpl
}
static void
-account_authorization_granted_cb(PurpleAccount *account, const char *user, gpointer data)
+account_authorization_granted_cb(PurpleAccount *account, const char *user, const char *message, gpointer data)
{
- purple_debug_misc("signals test", "account-authorization-granted (%s, %s)\n",
- purple_account_get_username(account), user);
+ purple_debug_misc("signals test", "account-authorization-granted (%s, %s, %s)\n",
+ purple_account_get_username(account), user, message);
}
static void
-account_authorization_denied_cb(PurpleAccount *account, const char *user, gpointer data)
+account_authorization_denied_cb(PurpleAccount *account, const char *user, const char *message, gpointer data)
{
- purple_debug_misc("signals test", "account-authorization-denied (%s, %s)\n",
- purple_account_get_username(account), user);
+ purple_debug_misc("signals test", "account-authorization-denied (%s, %s, %s)\n",
+ purple_account_get_username(account), user, message);
}
/**************************************************************************
More information about the Commits
mailing list