Added stanza send hooks for plugins

This commit is contained in:
James Booth
2016-03-26 15:50:16 +00:00
parent ce9b0836a0
commit d0397f3da5
11 changed files with 396 additions and 58 deletions

View File

@@ -97,6 +97,9 @@ c_plugin_create(const char * const filename)
plugin->post_priv_message_display = c_post_priv_message_display_hook;
plugin->pre_priv_message_send = c_pre_priv_message_send_hook;
plugin->post_priv_message_send = c_post_priv_message_send_hook;
plugin->on_message_stanza_send = c_on_message_stanza_send_hook;
plugin->on_presence_stanza_send = c_on_presence_stanza_send_hook;
plugin->on_iq_stanza_send = c_on_iq_stanza_send_hook;
g_string_free(path, TRUE);
g_free(module_name);
@@ -347,6 +350,48 @@ c_post_priv_message_send_hook(ProfPlugin *plugin, const char * const room, const
func (room, nick, message);
}
char *
c_on_message_stanza_send_hook(ProfPlugin *plugin, const char * const text)
{
void * f = NULL;
char* (*func)(const char * const __text);
assert (plugin && plugin->module);
if (NULL == (f = dlsym (plugin->module, "prof_on_message_stanza_send")))
return NULL;
func = (char* (*)(const char * const)) f;
return func (text);
}
char *
c_on_presence_stanza_send_hook(ProfPlugin *plugin, const char * const text)
{
void * f = NULL;
char* (*func)(const char * const __text);
assert (plugin && plugin->module);
if (NULL == (f = dlsym (plugin->module, "prof_on_presence_stanza_send")))
return NULL;
func = (char* (*)(const char * const)) f;
return func (text);
}
char *
c_on_iq_stanza_send_hook(ProfPlugin *plugin, const char * const text)
{
void * f = NULL;
char* (*func)(const char * const __text);
assert (plugin && plugin->module);
if (NULL == (f = dlsym (plugin->module, "prof_on_iq_stanza_send")))
return NULL;
func = (char* (*)(const char * const)) f;
return func (text);
}
void
c_plugin_destroy(ProfPlugin *plugin)
{