# HG changeset patch
# Node ID 8caf7ad87a31d62d5bca354bec3f7396168dc5b5
# Parent  58687db710b539ed03c068461bbc27b443f2d205
diff --git a/libpurple/purplenotificationauthorizationrequest.c b/libpurple/purplenotificationauthorizationrequest.c
--- a/libpurple/purplenotificationauthorizationrequest.c
+++ b/libpurple/purplenotificationauthorizationrequest.c
@@ -97,6 +97,10 @@
 			g_signal_connect_object(contact, "notify::name-for-display",
 			                        G_CALLBACK(purple_notification_authorization_request_notify_cb),
 			                        notification, G_CONNECT_DEFAULT);
+
+			g_object_bind_property(request, "message",
+			                       notification, "subtitle",
+			                       G_BINDING_BIDIRECTIONAL | G_BINDING_SYNC_CREATE);
 		}
 
 		purple_notification_set_account(PURPLE_NOTIFICATION(notification),
diff --git a/protocols/demo/purpledemoprotocolactions.c b/protocols/demo/purpledemoprotocolactions.c
--- a/protocols/demo/purpledemoprotocolactions.c
+++ b/protocols/demo/purpledemoprotocolactions.c
@@ -508,6 +508,55 @@
 	g_clear_object(&account);
 }
 
+static const char *auth_request_ids[] = {"chuck", "eve", "mallory", "michael"};
+
+static void
+purple_demo_protocol_authorization_request(G_GNUC_UNUSED GSimpleAction *action,
+                                           GVariant *parameter,
+                                           G_GNUC_UNUSED gpointer data)
+{
+	PurpleAccount *account = NULL;
+	PurpleAccountManager *account_manager = NULL;
+	PurpleAuthorizationRequest *request = NULL;
+	PurpleContact *contact = NULL;
+	PurpleContactManager *contact_manager = NULL;
+	PurpleNotification *notification = NULL;
+	PurpleNotificationManager *notification_manager = NULL;
+	PurpleTags *tags = NULL;
+	const char *account_id = NULL;
+	const char *message = NULL;
+	static guint counter = 0;
+
+	account_id = g_variant_get_string(parameter, NULL);
+	account_manager = purple_account_manager_get_default();
+	account = purple_account_manager_find_by_id(account_manager, account_id);
+
+	contact_manager = purple_contact_manager_get_default();
+	contact = purple_contact_manager_find_with_id(contact_manager, account,
+	                                              auth_request_ids[counter]);
+
+	tags = purple_contact_info_get_tags(PURPLE_CONTACT_INFO(contact));
+	message = purple_tags_get(tags, "auth-request-msg");
+
+	request = purple_authorization_request_new(contact);
+	if(!purple_strempty(message)) {
+		purple_authorization_request_set_message(request, message);
+	}
+
+	notification = purple_notification_authorization_request_new(NULL,
+	                                                             request);
+	notification_manager = purple_notification_manager_get_default();
+	purple_notification_manager_add(notification_manager, notification);
+
+	counter++;
+	if(counter >= G_N_ELEMENTS(auth_request_ids)) {
+		counter = 0;
+	}
+
+	g_clear_object(&notification);
+	g_clear_object(&account);
+}
+
 /******************************************************************************
  * Helpers
  *****************************************************************************/
@@ -532,6 +581,10 @@
 			.activate = purple_demo_protocol_remote_add,
 			.parameter_type = "s",
 		}, {
+			.name = "authorization-request",
+			.activate = purple_demo_protocol_authorization_request,
+			.parameter_type = "s",
+		}, {
 			.name = "request-fields",
 			.activate = purple_demo_protocol_request_fields_activate,
 			.parameter_type = "s",
@@ -581,6 +634,13 @@
 	g_menu_append_item(menu, item);
 	g_object_unref(item);
 
+	item = g_menu_item_new(_("Trigger a contact authorization request"),
+	                       "prpl-demo.authorization-request");
+	g_menu_item_set_attribute(item, PURPLE_MENU_ATTRIBUTE_DYNAMIC_TARGET, "s",
+	                          "account");
+	g_menu_append_item(menu, item);
+	g_object_unref(item);
+
 	item = g_menu_item_new(_("Request Fields"), "prpl-demo.request-fields");
 	g_menu_item_set_attribute(item, PURPLE_MENU_ATTRIBUTE_DYNAMIC_TARGET, "s",
 	                          "account");
diff --git a/protocols/demo/resources/buddy_icons/Chuck.png b/protocols/demo/resources/buddy_icons/Chuck.png
new file mode 100644
index 0000000000000000000000000000000000000000..dd06ac166d5714ec36532b7c23f0b2df407155dd
GIT binary patch
diff --git a/protocols/demo/resources/buddy_icons/Eve.png b/protocols/demo/resources/buddy_icons/Eve.png
new file mode 100644
index 0000000000000000000000000000000000000000..3c0c41b6b06ac9f2bfa794a9e4995417e48a1e11
GIT binary patch
diff --git a/protocols/demo/resources/buddy_icons/Mallory.png b/protocols/demo/resources/buddy_icons/Mallory.png
new file mode 100644
index 0000000000000000000000000000000000000000..a9a17461bc9d96982e51b899182bd12377afbe37
GIT binary patch
diff --git a/protocols/demo/resources/buddy_icons/Michael.png b/protocols/demo/resources/buddy_icons/Michael.png
new file mode 100644
index 0000000000000000000000000000000000000000..b2967a68039b4ff005f05b99e77b980d22844932
GIT binary patch
diff --git a/protocols/demo/resources/contacts.json b/protocols/demo/resources/contacts.json
--- a/protocols/demo/resources/contacts.json
+++ b/protocols/demo/resources/contacts.json
@@ -130,4 +130,34 @@
 		"primitive": "do-not-disturb"
 	},
 	"username": "Erin"
+}, {
+	"id": "chuck",
+	"presence": {
+		"primitive": "available"
+	},
+	"username": "Chuck"
+}, {
+	"id": "eve",
+	"presence": {
+		"primitive": "invisible"
+	},
+	"tags": [
+		"auth-request-msg:Nice avatar!"
+	],
+	"username": "Eve"
+}, {
+	"id": "mallory",
+	"presence": {
+		"primitive": "offline"
+	},
+	"username": "Mallory"
+}, {
+	"id": "michael",
+	"presence": {
+		"primitive": "streaming"
+	},
+	"tags": [
+		"auth-request-msg:Hey come check out my stream!"
+	],
+	"username": "Michael"
 }]
diff --git a/protocols/demo/resources/purpledemo.gresource.xml b/protocols/demo/resources/purpledemo.gresource.xml
--- a/protocols/demo/resources/purpledemo.gresource.xml
+++ b/protocols/demo/resources/purpledemo.gresource.xml
@@ -10,13 +10,17 @@
     <file>buddy_icons/Alice.png</file>
     <file>buddy_icons/Bob.png</file>
     <file>buddy_icons/Carlos.png</file>
+    <file>buddy_icons/Chuck.png</file>
     <file>buddy_icons/Echo.png</file>
     <file>buddy_icons/Eion.png</file>
     <file>buddy_icons/Elliott.png</file>
     <file>buddy_icons/Erin.png</file>
+    <file>buddy_icons/Eve.png</file>
     <file>buddy_icons/Gary.png</file>
     <file>buddy_icons/John.png</file>
+    <file>buddy_icons/Mallory.png</file>
     <file>buddy_icons/Markus.png</file>
+    <file>buddy_icons/Michael.png</file>
     <file>buddy_icons/Richard.png</file>
   </gresource>
 </gresources>
