--- a/libpurple/protocols/demo/purpledemoprotocolactions.c Mon Mar 11 21:25:28 2024 -0500 +++ b/libpurple/protocols/demo/purpledemoprotocolactions.c Mon Mar 11 21:27:23 2024 -0500 @@ -744,6 +744,45 @@ g_clear_object(&account); } +static const char *puns[] = { + "Toucan play at that game!", + "As long as it's not too much of a birden...", + "Sounds like a bit of ostrich...", + "People can't stop raven!", + "Have you heard about the bird?", +}; + +static void +purple_demo_protocol_generic_notification(G_GNUC_UNUSED GSimpleAction *action, + GVariant *parameter, + G_GNUC_UNUSED gpointer data) +{ + PurpleAccount *account = NULL; + PurpleAccountManager *account_manager = NULL; + PurpleNotification *notification = NULL; + PurpleNotificationManager *notification_manager = NULL; + const char *account_id = 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); + + notification = purple_notification_new(PURPLE_NOTIFICATION_TYPE_GENERIC, + account, g_strdup(puns[counter]), + g_free); + + notification_manager = purple_notification_manager_get_default(); + purple_notification_manager_add(notification_manager, notification); + + counter++; + if(counter >= G_N_ELEMENTS(puns)) { + counter = 0; + } + + g_clear_object(&account); +} + /****************************************************************************** * PurpleProtocolActions Implementation *****************************************************************************/ @@ -767,6 +806,10 @@ .activate = purple_demo_protocol_fatal_failure_action_activate, .parameter_type = "s", }, { + .name = "generic-notification", + .activate = purple_demo_protocol_generic_notification, + .parameter_type = "s", + }, { .name = "remote-add", .activate = purple_demo_protocol_remote_add, .parameter_type = "s", @@ -833,6 +876,13 @@ g_menu_append_item(menu, item); g_object_unref(item); + item = g_menu_item_new(_("Trigger a generic notification"), + "prpl-demo.generic-notification"); + 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(_("Trigger a contact adding you"), "prpl-demo.remote-add"); g_menu_item_set_attribute(item, PURPLE_MENU_ATTRIBUTE_DYNAMIC_TARGET, "s",