Add hub function for plugins to get list of currently connected users.
Can be filtered to include only users of a certain credential level, or users of a certain credential level or greater. Results are returned as a linked list of plugin_user objects. Hub function to free the memory used by the list also added. As plugins may store the list, users may disconnect before the list is used. Hence a copy of each user is made for the list, so that if a plugin tries to send a message to a user who has left the hub it will be ignored, rather than the hub trying to access memory that was free()d when the user disconnected. The lookup function to turn a plugin_user into a hub_user for some of the other hub functions is changed accordingly. (I think this description is possibly more confusing than just looking at the code, but oh well...)
This commit is contained in:
@@ -129,6 +129,9 @@ typedef int (*hfunc_ucmd_add_pm)(struct plugin_handle*, struct p
|
||||
typedef int (*hfunc_ucmd_send)(struct plugin_handle*, struct plugin_user*, struct plugin_ucmd*);
|
||||
typedef void (*hfunc_ucmd_free)(struct plugin_handle*, struct plugin_ucmd*);
|
||||
|
||||
typedef struct linked_list* (*hfunc_get_user_list)(struct plugin_handle*, enum auth_credentials);
|
||||
typedef void (*hfunc_free_user_list)(struct plugin_handle*, struct linked_list*);
|
||||
|
||||
/**
|
||||
* These are functions created and initialized by the hub and which can be used
|
||||
* by plugins to access functionality internal to the hub.
|
||||
@@ -151,6 +154,8 @@ struct plugin_hub_funcs
|
||||
hfunc_ucmd_add_pm ucmd_add_pm;
|
||||
hfunc_ucmd_send ucmd_send;
|
||||
hfunc_ucmd_free ucmd_free;
|
||||
hfunc_get_user_list get_user_list;
|
||||
hfunc_free_user_list free_user_list;
|
||||
};
|
||||
|
||||
struct plugin_handle
|
||||
|
||||
Reference in New Issue
Block a user