changeset 31371:28e27a37e4b4

Patch from Stefan Ott to add the account-authorization-requested-with-message signal, which can be useful to plugins. Fixes #8690. I also slipped in some ChangeLog.API tweaks.
author John Bailey <rekkanoryo@rekkanoryo.org>
date Sun, 09 Jan 2011 04:40:07 +0000
parents 5767e981508a
children 17a4b32f4d46
files ChangeLog.API doc/account-signals.dox libpurple/account.c libpurple/account.h libpurple/signals.c libpurple/signals.h
diffstat 6 files changed, 77 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog.API	Sat Jan 08 04:01:05 2011 +0000
+++ b/ChangeLog.API	Sun Jan 09 04:40:07 2011 +0000
@@ -3,11 +3,13 @@
 version 2.8.0 (??/??/????):
 	libpurple:
 		Added:
+		* account-authorization-requested-with-message signal (Stefan Ott)
+		  (#8690)
 		* purple_notify_user_info_add_pair_plaintext
 		* purple_media_get_active_local_candidates
 		* purple_media_get_active_remote_candidates
-		* purple_media_manager_get_video_caps (Jakub Adam)
-		* purple_media_manager_set_video_caps (Jakub Adam)
+		* purple_media_manager_get_video_caps (Jakub Adam) (#13095)
+		* purple_media_manager_set_video_caps (Jakub Adam) (#13095)
 
 	Pidgin:
 		Added:
--- a/doc/account-signals.dox	Sat Jan 08 04:01:05 2011 +0000
+++ b/doc/account-signals.dox	Sun Jan 09 04:40:07 2011 +0000
@@ -14,6 +14,7 @@
   @signal account-actions-changed
   @signal account-alias-changed
   @signal account-authorization-requested
+  @signal account-authorization-requested-with-message
   @signal account-authorization-denied
   @signal account-authorization-granted
   @signal account-error-changed
@@ -158,6 +159,23 @@
   @since 2.3.0
  @endsignaldef
 
+ @signaldef account-authorization-requested-with-message
+  @signalproto
+int (*account_authorization_requested)(PurpleAccount *account, const char *user, const char *message);
+  @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
+  @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
+          granted. If PURPLE_ACCOUNT_RESPONSE_PASS is returned, then the user
+          will be prompted with the request.
+  @since 2.8.0
+ @endsignaldef
+
  @signaldef account-authorization-denied
   @signalproto
 void (*account_authorization_denied)(PurpleAccount *account, const char *user);
--- a/libpurple/account.c	Sat Jan 08 04:01:05 2011 +0000
+++ b/libpurple/account.c	Sun Jan 09 04:40:07 2011 +0000
@@ -1441,6 +1441,27 @@
 		return NULL;
 	}
 
+	plugin_return = GPOINTER_TO_INT(
+			purple_signal_emit_return_1(
+				purple_accounts_get_handle(),
+				"account-authorization-requested-with-message",
+				account, remote_user, message
+			));
+
+	switch (plugin_return)
+	{
+		case PURPLE_ACCOUNT_RESPONSE_IGNORE:
+			return NULL;
+		case PURPLE_ACCOUNT_RESPONSE_ACCEPT:
+			if (auth_cb != NULL)
+				auth_cb(user_data);
+			return NULL;
+		case PURPLE_ACCOUNT_RESPONSE_DENY:
+			if (deny_cb != NULL)
+				deny_cb(user_data);
+			return NULL;
+	}
+
 	if (ui_ops != NULL && ui_ops->request_authorize != NULL) {
 		info            = g_new0(PurpleAccountRequestInfo, 1);
 		info->type      = PURPLE_ACCOUNT_REQUEST_AUTHORIZATION;
@@ -3046,6 +3067,13 @@
 										PURPLE_SUBTYPE_ACCOUNT),
 						purple_value_new(PURPLE_TYPE_STRING));
 
+	purple_signal_register(handle, "account-authorization-requested-with-message",
+						purple_marshal_INT__POINTER_POINTER_POINTER,
+						purple_value_new(PURPLE_TYPE_INT), 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_value_new(PURPLE_TYPE_SUBTYPE,
--- a/libpurple/account.h	Sat Jan 08 04:01:05 2011 +0000
+++ b/libpurple/account.h	Sun Jan 09 04:40:07 2011 +0000
@@ -59,6 +59,16 @@
 	PURPLE_ACCOUNT_REQUEST_AUTHORIZATION = 0 /* Account authorization request */
 } PurpleAccountRequestType;
 
+/**
+ * Account request response types
+ */
+typedef enum
+{
+	PURPLE_ACCOUNT_RESPONSE_IGNORE = -2,
+	PURPLE_ACCOUNT_RESPONSE_DENY = -1,
+	PURPLE_ACCOUNT_RESPONSE_PASS = 0,
+	PURPLE_ACCOUNT_RESPONSE_ACCEPT = 1
+} PurpleAccountRequestResponse;
 
 /**  Account UI operations, used to notify the user of status changes and when
  *   buddies add this account to their buddy lists.
--- a/libpurple/signals.c	Sat Jan 08 04:01:05 2011 +0000
+++ b/libpurple/signals.c	Sun Jan 09 04:40:07 2011 +0000
@@ -818,6 +818,21 @@
 		*return_val = GINT_TO_POINTER(ret_val);
 }
 
+	void
+purple_marshal_INT__POINTER_POINTER_POINTER(
+		PurpleCallback cb, va_list args, void *data, void **return_val)
+{
+	gint ret_val;
+	void *arg1 = va_arg(args, void *);
+	void *arg2 = va_arg(args, void *);
+	void *arg3 = va_arg(args, void *);
+
+	ret_val = ((gint (*)(void *, void *, void *, void *))cb)(arg1, arg2, arg3, data);
+
+	if (return_val != NULL)
+		*return_val = GINT_TO_POINTER(ret_val);
+}
+
 void
 purple_marshal_INT__POINTER_POINTER_POINTER_POINTER_POINTER(
 		PurpleCallback cb, va_list args, void *data, void **return_val)
--- a/libpurple/signals.h	Sat Jan 08 04:01:05 2011 +0000
+++ b/libpurple/signals.h	Sun Jan 09 04:40:07 2011 +0000
@@ -330,6 +330,8 @@
 		PurpleCallback cb, va_list args, void *data, void **return_val);
 void purple_marshal_INT__POINTER_POINTER(
 		PurpleCallback cb, va_list args, void *data, void **return_val);
+void purple_marshal_INT__POINTER_POINTER_POINTER(
+		PurpleCallback cb, va_list args, void *data, void **return_val);
 void purple_marshal_INT__POINTER_POINTER_POINTER_POINTER_POINTER(
 		PurpleCallback cb, va_list args, void *data, void **return_val);