Permalink
Browse files

Add the option to emit events when an authorization request is sent

  • Loading branch information...
xavery authored and sardemff7 committed Aug 25, 2017
1 parent 74adbf9 commit 7b01b0a2724f675dadf41a8d8e9bee203ef1ccc2
Showing with 36 additions and 1 deletion.
  1. +9 −0 src/plugin/callbacks.c
  2. +1 −1 src/plugin/callbacks.h
  3. +18 −0 src/plugin/events.c
  4. +8 −0 src/plugin/ui.c
View
@@ -226,3 +226,12 @@ purple_events_callback_account_signed_on(PurpleConnection *conn, PurpleEventsCon
data->handle = purple_timeout_add_seconds(5, _purple_events_callback_account_signed_on_timeout, data);
}
void
purple_events_callback_auth_requested(PurpleAccount *account, const char *sender, const char *message, PurpleEventsContext *context)
{
if ( ! purple_events_utils_check_event_dispatch(context, account, NULL, "authorization-requested") )
return;
purple_signal_emit(context->plugin, "user_authorization-requested", account, sender, message);
}
View
@@ -38,7 +38,7 @@ void purple_events_callback_email_notification(const gchar *subject, const gchar
void purple_events_callback_emails_notification(const gchar **subject, const gchar **from, const gchar **to, const gchar **url, guint count, PurpleEventsContext *context);
void purple_events_callback_conversation_updated(PurpleConversation *conv, PurpleConvUpdateType type, PurpleEventsContext *context);
void purple_events_callback_account_signed_on(PurpleConnection *conn, PurpleEventsContext *context);
void purple_events_callback_auth_requested(PurpleAccount *account, const char *remote_user, const char *message, PurpleEventsContext *context);
G_END_DECLS
View
@@ -99,6 +99,7 @@ _purple_events_init(PurplePlugin *plugin)
purple_prefs_add_bool("/plugins/core/events/events/anonymous-highlight", FALSE);
purple_prefs_add_bool("/plugins/core/events/events/signed-on", TRUE);
purple_prefs_add_bool("/plugins/core/events/events/signed-off", FALSE);
purple_prefs_add_bool("/plugins/core/events/events/authorization-requested", TRUE);
purple_prefs_add_bool("/plugins/core/events/events/away", TRUE);
purple_prefs_add_bool("/plugins/core/events/events/idle", TRUE);
purple_prefs_add_bool("/plugins/core/events/events/back", TRUE);
@@ -136,6 +137,8 @@ _purple_events_init(PurplePlugin *plugin)
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_SUBTYPE, PURPLE_SUBTYPE_CONVERSATION), purple_value_new(PURPLE_TYPE_UINT));
purple_signal_register(plugin, "user_email-arrived", purple_marshal_VOID__POINTER_POINTER_POINTER_POINTER, NULL, 4,
purple_value_new(PURPLE_TYPE_STRING), purple_value_new(PURPLE_TYPE_STRING), purple_value_new(PURPLE_TYPE_STRING), purple_value_new(PURPLE_TYPE_STRING));
purple_signal_register(plugin, "user_authorization-requested", purple_marshal_VOID__POINTER_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(plugin, "conversation-got-focus", purple_marshal_VOID__POINTER_POINTER_POINTER_POINTER, NULL, 1,
purple_value_new(PURPLE_TYPE_SUBTYPE, PURPLE_SUBTYPE_CONVERSATION));
}
@@ -157,6 +160,7 @@ _purple_events_destroy(PurplePlugin *plugin)
purple_signal_unregister(plugin, "user_chat-received");
purple_signal_unregister(plugin, "user_chat-highlight");
purple_signal_unregister(plugin, "user_email-arrived");
purple_signal_unregister(plugin, "user_authorization-requested");
purple_signal_unregister(plugin, "conversation-got-focus");
g_list_free(context->handlers);
@@ -172,6 +176,7 @@ _purple_events_load(PurplePlugin *plugin)
void *blist_handle = purple_blist_get_handle();
void *conn_handle = purple_connections_get_handle();
void *notify_handle = purple_notify_get_handle();
void *acct_handle = purple_accounts_get_handle();
purple_signal_connect(
blist_handle, "buddy-signed-on", plugin,
@@ -231,6 +236,12 @@ _purple_events_load(PurplePlugin *plugin)
blist_handle, "blist-node-extended-menu", plugin,
(PurpleCallback)purple_events_ui_menu_add, plugin->extra
);
purple_signal_connect(
acct_handle, "account-authorization-requested-with-message", plugin,
(PurpleCallback)purple_events_callback_auth_requested, plugin->extra
);
return TRUE;
}
@@ -251,6 +262,7 @@ _purple_events_unload(PurplePlugin *plugin)
void *conv_handle = purple_conversations_get_handle();
void *blist_handle = purple_blist_get_handle();
void *conn_handle = purple_connections_get_handle();
void *acct_handle = purple_accounts_get_handle();
g_list_free_full(context->just_signed_on_accounts, _purple_events_just_signed_on_account_free);
@@ -295,6 +307,12 @@ _purple_events_unload(PurplePlugin *plugin)
blist_handle, "blist-node-extended-menu", plugin,
(PurpleCallback)purple_events_ui_menu_add
);
purple_signal_disconnect(
acct_handle, "account-authorization-requested-with-message", plugin,
(PurpleCallback)purple_events_callback_auth_requested
);
return TRUE;
}
View
@@ -101,6 +101,12 @@ purple_events_ui_get_pref_frame(PurplePlugin *plugin)
);
purple_plugin_pref_frame_add(frame, pref);
pref = purple_plugin_pref_new_with_name_and_label(
"/plugins/core/events/events/authorization-requested",
_("Buddy requesting authorization")
);
purple_plugin_pref_frame_add(frame, pref);
pref = purple_plugin_pref_new_with_name_and_label(
"/plugins/core/events/events/emails",
_("E-mails")
@@ -190,6 +196,7 @@ static const gchar *_purple_events_ui_events[] =
"events/idle",
"events/back",
"events/status-message",
"events/authorization-requested",
NULL
};
@@ -203,6 +210,7 @@ static const gchar *_purple_events_ui_events_labels[] =
N_("Buddy going idle"),
N_("Buddy coming back"),
N_("Status message change (or removal)"),
N_("Buddy requesting authorization"),
NULL
};

0 comments on commit 7b01b0a

Please sign in to comment.