From 9e52ea7effea4bc2dbada9165bc96987f8eec955 Mon Sep 17 00:00:00 2001 From: Tilka Date: Wed, 9 May 2012 23:33:03 +0200 Subject: [PATCH] add on_change_nick() to struct plugin_funcs It's not called anywhere yet. Also reorder some typedefs, rename the ip check functions and add struct {hub,plugin}_user parameter to on_check_ip_late(). Not sure where to insert a call to that... --- src/core/plugininvoke.c | 7 ++++--- src/core/plugininvoke.h | 2 +- src/plugin_api/handle.h | 25 ++++++++++++------------- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/core/plugininvoke.c b/src/core/plugininvoke.c index ed31ef7..d5645f5 100644 --- a/src/core/plugininvoke.c +++ b/src/core/plugininvoke.c @@ -82,12 +82,13 @@ static struct plugin_user* convert_user_type(struct hub_user* user) plugin_st plugin_check_ip_early(struct hub_info* hub, struct ip_addr_encap* addr) { - PLUGIN_INVOKE_STATUS_1(hub, login_check_ip_early, addr); + PLUGIN_INVOKE_STATUS_1(hub, on_check_ip_early, addr); } -plugin_st plugin_check_ip_late(struct hub_info* hub, struct ip_addr_encap* addr) +plugin_st plugin_check_ip_late(struct hub_info* hub, struct hub_user* who, struct ip_addr_encap* addr) { - PLUGIN_INVOKE_STATUS_1(hub, login_check_ip_late, addr); + struct plugin_user* user = convert_user_type(who); + PLUGIN_INVOKE_STATUS_2(hub, on_check_ip_late, user, addr); } void plugin_log_connection_accepted(struct hub_info* hub, struct ip_addr_encap* ipaddr) diff --git a/src/core/plugininvoke.h b/src/core/plugininvoke.h index c01e705..56c71a4 100644 --- a/src/core/plugininvoke.h +++ b/src/core/plugininvoke.h @@ -38,7 +38,7 @@ void plugin_log_chat_message(struct hub_info* hub, struct hub_user* from, const /* IP ban related */ plugin_st plugin_check_ip_early(struct hub_info* hub, struct ip_addr_encap* addr); -plugin_st plugin_check_ip_late(struct hub_info* hub, struct ip_addr_encap* addr); +plugin_st plugin_check_ip_late(struct hub_info* hub, struct hub_user* user, struct ip_addr_encap* addr); /* Nickname allow/deny handling */ plugin_st plugin_check_nickname_valid(struct hub_info* hub, const char* nick); diff --git a/src/plugin_api/handle.h b/src/plugin_api/handle.h index 5151d3a..fd9e3e0 100644 --- a/src/plugin_api/handle.h +++ b/src/plugin_api/handle.h @@ -29,13 +29,6 @@ #include "util/ipcalc.h" #include "plugin_api/types.h" -typedef plugin_st (*on_chat_msg_t)(struct plugin_handle*, struct plugin_user* from, const char* message); -typedef plugin_st (*on_private_msg_t)(struct plugin_handle*, struct plugin_user* from, struct plugin_user* to, const char* message); -typedef plugin_st (*on_search_t)(struct plugin_handle*, struct plugin_user* from, const char* data); -typedef plugin_st (*on_search_result_t)(struct plugin_handle*, struct plugin_user* from, struct plugin_user* to, const char* data); -typedef plugin_st (*on_p2p_connect_t)(struct plugin_handle*, struct plugin_user* from, struct plugin_user* to); -typedef plugin_st (*on_p2p_revconnect_t)(struct plugin_handle*, struct plugin_user* from, struct plugin_user* to); - typedef void (*on_connection_accepted_t)(struct plugin_handle*, struct ip_addr_encap*); typedef void (*on_connection_refused_t)(struct plugin_handle*, struct ip_addr_encap*); @@ -51,12 +44,18 @@ typedef void (*on_hub_reloaded_t)(struct plugin_handle*, struct plugin_hub_info* typedef void (*on_hub_shutdown_t)(struct plugin_handle*, struct plugin_hub_info*); typedef void (*on_hub_error_t)(struct plugin_handle*, struct plugin_hub_info*, const char* message); -typedef plugin_st (*on_change_nick_t)(struct plugin_handle*, struct plugin_user*, const char* new_nick); - typedef plugin_st (*on_check_ip_early_t)(struct plugin_handle*, struct ip_addr_encap*); -typedef plugin_st (*on_check_ip_late_t)(struct plugin_handle*, struct ip_addr_encap*); +typedef plugin_st (*on_check_ip_late_t)(struct plugin_handle*, struct plugin_user*, struct ip_addr_encap*); typedef plugin_st (*on_validate_nick_t)(struct plugin_handle*, const char* nick); typedef plugin_st (*on_validate_cid_t)(struct plugin_handle*, const char* cid); +typedef plugin_st (*on_change_nick_t)(struct plugin_handle*, struct plugin_user*, const char* new_nick); + +typedef plugin_st (*on_chat_msg_t)(struct plugin_handle*, struct plugin_user* from, const char* message); +typedef plugin_st (*on_private_msg_t)(struct plugin_handle*, struct plugin_user* from, struct plugin_user* to, const char* message); +typedef plugin_st (*on_search_t)(struct plugin_handle*, struct plugin_user* from, const char* data); +typedef plugin_st (*on_search_result_t)(struct plugin_handle*, struct plugin_user* from, struct plugin_user* to, const char* data); +typedef plugin_st (*on_p2p_connect_t)(struct plugin_handle*, struct plugin_user* from, struct plugin_user* to); +typedef plugin_st (*on_p2p_revconnect_t)(struct plugin_handle*, struct plugin_user* from, struct plugin_user* to); typedef plugin_st (*auth_get_user_t)(struct plugin_handle*, const char* nickname, struct auth_info* info); typedef plugin_st (*auth_register_user_t)(struct plugin_handle*, struct auth_info* user); @@ -87,6 +86,9 @@ struct plugin_funcs on_hub_error_t on_hub_error; /* Triggered for log-worthy error messages */ // Activity events (can be intercepted and refused/accepted by a plugin) + on_check_ip_early_t on_check_ip_early; /* A user has just connected (can be intercepted) */ + on_check_ip_late_t on_check_ip_late; /* A user has logged in (can be intercepted) */ + on_change_nick_t on_change_nick; /* A user wants to change his nick (can be intercepted) */ on_chat_msg_t on_chat_msg; /* A public chat message is about to be sent (can be intercepted) */ on_private_msg_t on_private_msg; /* A public chat message is about to be sent (can be intercepted) */ on_search_t on_search; /* A search is about to be sent (can be intercepted) */ @@ -100,9 +102,6 @@ struct plugin_funcs auth_update_user_t auth_update_user; /* Update a registered user */ auth_delete_user_t auth_delete_user; /* Delete a registered user */ - // Login check functions - on_check_ip_early_t login_check_ip_early; - on_check_ip_late_t login_check_ip_late; }; struct plugin_command_handle;