1
0
mirror of https://github.com/profanity-im/profanity.git synced 2024-12-04 14:46:46 -05:00

Merge branch 'master' into osx-functional

This commit is contained in:
James Booth 2016-03-30 23:18:34 +01:00
commit f4f5b36814
7 changed files with 433 additions and 286 deletions

View File

@ -604,6 +604,7 @@ sv_ev_contact_offline(char *barejid, char *resource, char *status)
gboolean updated = roster_contact_offline(barejid, resource, status);
if (resource && updated) {
plugins_on_contact_offline(barejid, resource, status);
ui_contact_offline(barejid, resource, status);
}
@ -625,6 +626,8 @@ sv_ev_contact_online(char *barejid, Resource *resource, GDateTime *last_activity
gboolean updated = roster_update_presence(barejid, resource, last_activity);
if (updated) {
plugins_on_contact_presence(barejid, resource->name, string_from_resource_presence(resource->presence),
resource->status, resource->priority);
ui_contact_online(barejid, resource, last_activity);
}

View File

@ -54,8 +54,8 @@ c_env_init(void)
c_api_init();
}
ProfPlugin *
c_plugin_create(const char * const filename)
ProfPlugin*
c_plugin_create(const char *const filename)
{
ProfPlugin *plugin;
void *handle = NULL;
@ -103,6 +103,8 @@ c_plugin_create(const char * const filename)
plugin->on_presence_stanza_receive = c_on_presence_stanza_receive_hook;
plugin->on_iq_stanza_send = c_on_iq_stanza_send_hook;
plugin->on_iq_stanza_receive = c_on_iq_stanza_receive_hook;
plugin->on_contact_offline = c_on_contact_offline_hook;
plugin->on_contact_presence = c_on_contact_presence_hook;
g_string_free(path, TRUE);
g_free(module_name);
@ -111,330 +113,363 @@ c_plugin_create(const char * const filename)
}
void
c_init_hook(ProfPlugin *plugin, const char * const version, const char * const status)
c_init_hook(ProfPlugin *plugin, const char *const version, const char *const status)
{
void * f = NULL;
void (*func)(const char * const __version, const char * const __status);
void *f = NULL;
void (*func)(const char *const __version, const char *const __status);
assert (plugin && plugin->module);
assert(plugin && plugin->module);
if (NULL == (f = dlsym (plugin->module, "prof_init"))) {
if (NULL == (f = dlsym(plugin->module, "prof_init"))) {
log_warning ("warning: %s does not have init function", plugin->name);
return ;
return;
}
func = (void (*)(const char * const, const char * const))f;
func = (void (*)(const char *const, const char *const))f;
// FIXME maybe we want to make it boolean to see if it succeeded or not?
func (version, status);
func(version, status);
}
void
c_on_start_hook(ProfPlugin *plugin)
{
void * f = NULL;
void *f = NULL;
void (*func)(void);
assert (plugin && plugin->module);
assert(plugin && plugin->module);
if (NULL == (f = dlsym (plugin->module, "prof_on_start")))
return ;
if (NULL == (f = dlsym(plugin->module, "prof_on_start")))
return;
func = (void (*)(void)) f;
func ();
func = (void (*)(void))f;
func();
}
void
c_on_shutdown_hook(ProfPlugin *plugin)
{
void * f = NULL;
void *f = NULL;
void (*func)(void);
assert (plugin && plugin->module);
assert(plugin && plugin->module);
if (NULL == (f = dlsym (plugin->module, "prof_on_shutdown")))
return ;
func = (void (*)(void)) f;
func ();
}
void
c_on_connect_hook(ProfPlugin *plugin, const char * const account_name, const char * const fulljid)
{
void * f = NULL;
void (*func)(const char * const __account_name, const char * const __fulljid);
assert (plugin && plugin->module);
if (NULL == (f = dlsym (plugin->module, "prof_on_connect")))
return ;
func = (void (*)(const char * const, const char * const)) f;
func (account_name, fulljid);
}
void
c_on_disconnect_hook(ProfPlugin *plugin, const char * const account_name, const char * const fulljid)
{
void * f = NULL;
void (*func)(const char * const __account_name, const char * const __fulljid);
assert (plugin && plugin->module);
if (NULL == (f = dlsym (plugin->module, "prof_on_disconnect")))
return ;
func = (void (*)(const char * const, const char * const)) f;
func (account_name, fulljid);
}
char *
c_pre_chat_message_display_hook(ProfPlugin *plugin, const char * const jid, const char *message)
{
void * f = NULL;
char* (*func)(const char * const __jid, const char * __message);
assert (plugin && plugin->module);
if (NULL == (f = dlsym (plugin->module, "prof_pre_chat_message_display")))
return NULL;
func = (char* (*)(const char * const, const char *)) f;
return func (jid, message);
}
void
c_post_chat_message_display_hook(ProfPlugin *plugin, const char * const jid, const char *message)
{
void * f = NULL;
void (*func)(const char * const __jid, const char * __message);
assert (plugin && plugin->module);
if (NULL == (f = dlsym (plugin->module, "prof_post_chat_message_display")))
if (NULL == (f = dlsym(plugin->module, "prof_on_shutdown")))
return;
func = (void (*)(const char * const, const char *)) f;
func (jid, message);
}
char *
c_pre_chat_message_send_hook(ProfPlugin *plugin, const char * const jid, const char *message)
{
void * f = NULL;
char* (*func)(const char * const __jid, const char * __message);
assert (plugin && plugin->module);
if (NULL == (f = dlsym (plugin->module, "prof_pre_chat_message_send")))
return NULL;
func = (char* (*)(const char * const, const char *)) f;
return func (jid, message);
func = (void (*)(void))f;
func();
}
void
c_post_chat_message_send_hook(ProfPlugin *plugin, const char * const jid, const char *message)
c_on_connect_hook(ProfPlugin *plugin, const char *const account_name, const char *const fulljid)
{
void * f = NULL;
void (*func)(const char * const __jid, const char * __message);
assert (plugin && plugin->module);
void *f = NULL;
void (*func)(const char *const __account_name, const char *const __fulljid);
assert(plugin && plugin->module);
if (NULL == (f = dlsym (plugin->module, "prof_post_chat_message_send")))
if (NULL == (f = dlsym(plugin->module, "prof_on_connect")))
return;
func = (void (*)(const char * const, const char *)) f;
func (jid, message);
}
char *
c_pre_room_message_display_hook(ProfPlugin *plugin, const char * const room, const char * const nick, const char *message)
{
void * f = NULL;
char* (*func)(const char * const __room, const char * const __nick, const char * __message);
assert (plugin && plugin->module);
if (NULL == (f = dlsym (plugin->module, "prof_pre_room_message_display")))
return NULL;
func = (char* (*)(const char * const, const char * const, const char *)) f;
return func (room, nick, message);
func = (void (*)(const char *const, const char *const))f;
func(account_name, fulljid);
}
void
c_post_room_message_display_hook(ProfPlugin *plugin, const char * const room, const char * const nick, const char *message)
c_on_disconnect_hook(ProfPlugin *plugin, const char *const account_name, const char *const fulljid)
{
void * f = NULL;
void (*func)(const char * const __room, const char * const __nick, const char * __message);
assert (plugin && plugin->module);
void *f = NULL;
void (*func)(const char *const __account_name, const char *const __fulljid);
assert(plugin && plugin->module);
if (NULL == (f = dlsym (plugin->module, "prof_post_room_message_display")))
if (NULL == (f = dlsym(plugin->module, "prof_on_disconnect")))
return;
func = (void (*)(const char * const, const char * const, const char *)) f;
func (room, nick, message);
func = (void (*)(const char *const, const char *const))f;
func(account_name, fulljid);
}
char *
c_pre_room_message_send_hook(ProfPlugin *plugin, const char * const room, const char *message)
char*
c_pre_chat_message_display_hook(ProfPlugin *plugin, const char *const jid, const char *message)
{
void * f = NULL;
char* (*func)(const char * const __room, const char * __message);
assert (plugin && plugin->module);
void *f = NULL;
char* (*func)(const char *const __jid, const char *__message);
assert(plugin && plugin->module);
if (NULL == (f = dlsym (plugin->module, "prof_pre_room_message_send")))
if (NULL == (f = dlsym(plugin->module, "prof_pre_chat_message_display")))
return NULL;
func = (char* (*)(const char * const, const char *)) f;
return func (room, message);
func = (char* (*)(const char *const, const char *))f;
return func(jid, message);
}
void
c_post_room_message_send_hook(ProfPlugin *plugin, const char * const room, const char *message)
c_post_chat_message_display_hook(ProfPlugin *plugin, const char *const jid, const char *message)
{
void * f = NULL;
void (*func)(const char * const __room, const char * __message);
assert (plugin && plugin->module);
void *f = NULL;
void (*func)(const char *const __jid, const char *__message);
assert(plugin && plugin->module);
if (NULL == (f = dlsym (plugin->module, "prof_post_room_message_send")))
if (NULL == (f = dlsym(plugin->module, "prof_post_chat_message_display")))
return;
func = (void (*)(const char * const, const char *)) f;
func (room, message);
func = (void (*)(const char *const, const char *))f;
func(jid, message);
}
char *
c_pre_priv_message_display_hook(ProfPlugin *plugin, const char * const room, const char * const nick, const char *message)
char*
c_pre_chat_message_send_hook(ProfPlugin *plugin, const char *const jid, const char *message)
{
void * f = NULL;
char* (*func)(const char * const __room, const char * const __nick, const char * __message);
assert (plugin && plugin->module);
void *f = NULL;
char* (*func)(const char *const __jid, const char *__message);
assert(plugin && plugin->module);
if (NULL == (f = dlsym (plugin->module, "prof_pre_priv_message_display")))
if (NULL == (f = dlsym(plugin->module, "prof_pre_chat_message_send")))
return NULL;
func = (char* (*)(const char * const, const char * const, const char *)) f;
return func (room, nick, message);
func = (char* (*)(const char *const, const char *))f;
return func(jid, message);
}
void
c_post_priv_message_display_hook(ProfPlugin *plugin, const char * const room, const char * const nick, const char *message)
c_post_chat_message_send_hook(ProfPlugin *plugin, const char *const jid, const char *message)
{
void * f = NULL;
void (*func)(const char * const __room, const char * const __nick, const char * __message);
assert (plugin && plugin->module);
void *f = NULL;
void (*func)(const char *const __jid, const char *__message);
assert(plugin && plugin->module);
if (NULL == (f = dlsym (plugin->module, "prof_post_priv_message_display")))
if (NULL == (f = dlsym(plugin->module, "prof_post_chat_message_send")))
return;
func = (void (*)(const char * const, const char * const, const char *)) f;
func (room, nick, message);
func = (void (*)(const char *const, const char *))f;
func(jid, message);
}
char *
c_pre_priv_message_send_hook(ProfPlugin *plugin, const char * const room, const char * const nick, const char *message)
char*
c_pre_room_message_display_hook(ProfPlugin *plugin, const char *const room, const char *const nick, const char *message)
{
void * f = NULL;
char* (*func)(const char * const __room, const char * const __nick, const char * __message);
assert (plugin && plugin->module);
void *f = NULL;
char* (*func)(const char *const __room, const char *const __nick, const char *__message);
assert(plugin && plugin->module);
if (NULL == (f = dlsym (plugin->module, "prof_pre_priv_message_send")))
if (NULL == (f = dlsym(plugin->module, "prof_pre_room_message_display")))
return NULL;
func = (char* (*)(const char * const, const char * const, const char *)) f;
return func (room, nick, message);
func = (char* (*)(const char *const, const char *const, const char *))f;
return func(room, nick, message);
}
void
c_post_priv_message_send_hook(ProfPlugin *plugin, const char * const room, const char * const nick, const char *message)
c_post_room_message_display_hook(ProfPlugin *plugin, const char *const room, const char *const nick,
const char *message)
{
void * f = NULL;
void (*func)(const char * const __room, const char * const __nick, const char * __message);
assert (plugin && plugin->module);
void *f = NULL;
void (*func)(const char *const __room, const char *const __nick, const char *__message);
assert(plugin && plugin->module);
if (NULL == (f = dlsym (plugin->module, "prof_post_priv_message_send")))
if (NULL == (f = dlsym(plugin->module, "prof_post_room_message_display")))
return;
func = (void (*)(const char * const, const char * const, const char *)) f;
func (room, nick, message);
func = (void (*)(const char *const, const char *const, const char *))f;
func(room, nick, message);
}
char *
c_on_message_stanza_send_hook(ProfPlugin *plugin, const char * const text)
char*
c_pre_room_message_send_hook(ProfPlugin *plugin, const char *const room, const char *message)
{
void * f = NULL;
char* (*func)(const char * const __text);
assert (plugin && plugin->module);
void *f = NULL;
char* (*func)(const char *const __room, const char *__message);
assert(plugin && plugin->module);
if (NULL == (f = dlsym (plugin->module, "prof_on_message_stanza_send")))
if (NULL == (f = dlsym(plugin->module, "prof_pre_room_message_send")))
return NULL;
func = (char* (*)(const char * const)) f;
return func (text);
func = (char* (*)(const char *const, const char *))f;
return func(room, message);
}
void
c_post_room_message_send_hook(ProfPlugin *plugin, const char *const room, const char *message)
{
void *f = NULL;
void (*func)(const char *const __room, const char *__message);
assert(plugin && plugin->module);
if (NULL == (f = dlsym(plugin->module, "prof_post_room_message_send")))
return;
func = (void (*)(const char *const, const char *))f;
func(room, message);
}
char*
c_pre_priv_message_display_hook(ProfPlugin *plugin, const char *const room, const char *const nick, const char *message)
{
void *f = NULL;
char* (*func)(const char *const __room, const char *const __nick, const char *__message);
assert(plugin && plugin->module);
if (NULL == (f = dlsym(plugin->module, "prof_pre_priv_message_display")))
return NULL;
func = (char* (*)(const char *const, const char *const, const char *))f;
return func(room, nick, message);
}
void
c_post_priv_message_display_hook(ProfPlugin *plugin, const char *const room, const char *const nick,
const char *message)
{
void *f = NULL;
void (*func)(const char *const __room, const char *const __nick, const char *__message);
assert(plugin && plugin->module);
if (NULL == (f = dlsym(plugin->module, "prof_post_priv_message_display")))
return;
func = (void (*)(const char *const, const char *const, const char *))f;
func(room, nick, message);
}
char*
c_pre_priv_message_send_hook(ProfPlugin *plugin, const char *const room, const char *const nick, const char *message)
{
void *f = NULL;
char* (*func)(const char *const __room, const char *const __nick, const char *__message);
assert(plugin && plugin->module);
if (NULL == (f = dlsym(plugin->module, "prof_pre_priv_message_send")))
return NULL;
func = (char* (*)(const char *const, const char *const, const char *))f;
return func(room, nick, message);
}
void
c_post_priv_message_send_hook(ProfPlugin *plugin, const char *const room, const char *const nick, const char *message)
{
void *f = NULL;
void (*func)(const char *const __room, const char *const __nick, const char *__message);
assert(plugin && plugin->module);
if (NULL == (f = dlsym(plugin->module, "prof_post_priv_message_send")))
return;
func = (void (*)(const char *const, const char *const, const char *))f;
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);
}
gboolean
c_on_message_stanza_receive_hook(ProfPlugin *plugin, const char *const text)
{
void * f = NULL;
int (*func)(const char * const __text);
assert (plugin && plugin->module);
void *f = NULL;
int (*func)(const char *const __text);
assert(plugin && plugin->module);
if (NULL == (f = dlsym (plugin->module, "prof_on_message_stanza_receive")))
if (NULL == (f = dlsym(plugin->module, "prof_on_message_stanza_receive")))
return TRUE;
func = (int (*)(const char * const)) f;
return func (text);
func = (int (*)(const char *const))f;
return func(text);
}
char *
c_on_presence_stanza_send_hook(ProfPlugin *plugin, const char * const 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);
void *f = NULL;
char* (*func)(const char *const __text);
assert(plugin && plugin->module);
if (NULL == (f = dlsym (plugin->module, "prof_on_presence_stanza_send")))
if (NULL == (f = dlsym(plugin->module, "prof_on_presence_stanza_send")))
return NULL;
func = (char* (*)(const char * const)) f;
return func (text);
func = (char* (*)(const char *const))f;
return func(text);
}
gboolean
c_on_presence_stanza_receive_hook(ProfPlugin *plugin, const char *const text)
{
void * f = NULL;
int (*func)(const char * const __text);
assert (plugin && plugin->module);
void *f = NULL;
int (*func)(const char *const __text);
assert(plugin && plugin->module);
if (NULL == (f = dlsym (plugin->module, "prof_on_presence_stanza_receive")))
if (NULL == (f = dlsym(plugin->module, "prof_on_presence_stanza_receive")))
return TRUE;
func = (int (*)(const char * const)) f;
return func (text);
func = (int (*)(const char *const))f;
return func(text);
}
char *
c_on_iq_stanza_send_hook(ProfPlugin *plugin, const char * const 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);
void *f = NULL;
char* (*func)(const char *const __text);
assert(plugin && plugin->module);
if (NULL == (f = dlsym (plugin->module, "prof_on_iq_stanza_send")))
if (NULL == (f = dlsym(plugin->module, "prof_on_iq_stanza_send")))
return NULL;
func = (char* (*)(const char * const)) f;
return func (text);
func = (char* (*)(const char *const))f;
return func(text);
}
gboolean
c_on_iq_stanza_receive_hook(ProfPlugin *plugin, const char *const text)
{
void * f = NULL;
int (*func)(const char * const __text);
assert (plugin && plugin->module);
void *f = NULL;
int (*func)(const char *const __text);
assert(plugin && plugin->module);
if (NULL == (f = dlsym (plugin->module, "prof_on_iq_stanza_receive")))
if (NULL == (f = dlsym(plugin->module, "prof_on_iq_stanza_receive")))
return TRUE;
func = (int (*)(const char * const)) f;
return func (text);
func = (int (*)(const char *const))f;
return func(text);
}
void
c_on_contact_offline_hook(ProfPlugin *plugin, const char *const barejid, const char *const resource,
const char *const status)
{
void *f = NULL;
void (*func)(const char *const __barejid, const char *const __resource, const char *const __status);
assert(plugin && plugin->module);
if (NULL == (f = dlsym(plugin->module, "prof_on_contact_offline")))
return;
func = (void (*)(const char *const, const char *const, const char *const))f;
func(barejid, resource, status);
}
void
c_on_contact_presence_hook(ProfPlugin *plugin, const char *const barejid, const char *const resource,
const char *const presence, const char *const status, const int priority)
{
void *f = NULL;
void (*func)(const char *const __barejid, const char *const __resource, const char *const __presence,
const char *const __status, const int __priority);
assert(plugin && plugin->module);
if (NULL == (f = dlsym(plugin->module, "prof_on_contact_presence")))
return;
func = (void (*)(const char *const, const char *const, const char *const, const char *const, const int))f;
func(barejid, resource, presence, status, priority);
}
void

View File

@ -39,30 +39,36 @@
void c_env_init(void);
ProfPlugin* c_plugin_create(const char * const filename);
void c_plugin_destroy(ProfPlugin * plugin);
ProfPlugin* c_plugin_create(const char *const filename);
void c_plugin_destroy(ProfPlugin *plugin);
void c_shutdown(void);
void c_init_hook(ProfPlugin *plugin, const char * const version, const char * const status);
void c_init_hook(ProfPlugin *plugin, const char *const version, const char *const status);
void c_on_start_hook(ProfPlugin *plugin);
void c_on_shutdown_hook(ProfPlugin *plugin);
void c_on_connect_hook(ProfPlugin *plugin, const char * const account_name, const char * const fulljid);
void c_on_disconnect_hook(ProfPlugin *plugin, const char * const account_name, const char * const fulljid);
void c_on_connect_hook(ProfPlugin *plugin, const char *const account_name, const char *const fulljid);
void c_on_disconnect_hook(ProfPlugin *plugin, const char *const account_name, const char *const fulljid);
char* c_pre_chat_message_display_hook(ProfPlugin *plugin, const char * const jid, const char *message);
void c_post_chat_message_display_hook(ProfPlugin *plugin, const char * const jid, const char *message);
char* c_pre_chat_message_send_hook(ProfPlugin *plugin, const char * const jid, const char *message);
void c_post_chat_message_send_hook(ProfPlugin *plugin, const char * const jid, const char *message);
char* c_pre_chat_message_display_hook(ProfPlugin *plugin, const char *const jid, const char *message);
void c_post_chat_message_display_hook(ProfPlugin *plugin, const char *const jid, const char *message);
char* c_pre_chat_message_send_hook(ProfPlugin *plugin, const char *const jid, const char *message);
void c_post_chat_message_send_hook(ProfPlugin *plugin, const char *const jid, const char *message);
char* c_pre_room_message_display_hook(ProfPlugin *plugin, const char * const room, const char * const nick, const char *message);
void c_post_room_message_display_hook(ProfPlugin *plugin, const char * const room, const char * const nick, const char *message);
char* c_pre_room_message_send_hook(ProfPlugin *plugin, const char * const room, const char *message);
void c_post_room_message_send_hook(ProfPlugin *plugin, const char * const room, const char *message);
char* c_pre_room_message_display_hook(ProfPlugin *plugin, const char *const room, const char *const nick,
const char *message);
void c_post_room_message_display_hook(ProfPlugin *plugin, const char *const room, const char *const nick,
const char *message);
char* c_pre_room_message_send_hook(ProfPlugin *plugin, const char *const room, const char *message);
void c_post_room_message_send_hook(ProfPlugin *plugin, const char *const room, const char *message);
char* c_pre_priv_message_display_hook(ProfPlugin *plugin, const char * const room, const char * const nick, const char *message);
void c_post_priv_message_display_hook(ProfPlugin *plugin, const char * const room, const char * const nick, const char *message);
char* c_pre_priv_message_send_hook(ProfPlugin *plugin, const char * const room, const char * const nick, const char * const message);
void c_post_priv_message_send_hook(ProfPlugin *plugin, const char * const room, const char * const nick, const char * const message);
char* c_pre_priv_message_display_hook(ProfPlugin *plugin, const char *const room, const char *const nick,
const char *message);
void c_post_priv_message_display_hook(ProfPlugin *plugin, const char *const room, const char *const nick,
const char *message);
char* c_pre_priv_message_send_hook(ProfPlugin *plugin, const char *const room, const char *const nick,
const char *const message);
void c_post_priv_message_send_hook(ProfPlugin *plugin, const char *const room, const char *const nick,
const char * const message);
char* c_on_message_stanza_send_hook(ProfPlugin *plugin, const char *const text);
gboolean c_on_message_stanza_receive_hook(ProfPlugin *plugin, const char *const text);
@ -73,4 +79,9 @@ gboolean c_on_presence_stanza_receive_hook(ProfPlugin *plugin, const char *const
char* c_on_iq_stanza_send_hook(ProfPlugin *plugin, const char *const text);
gboolean c_on_iq_stanza_receive_hook(ProfPlugin *plugin, const char *const text);
void c_on_contact_offline_hook(ProfPlugin *plugin, const char *const barejid, const char *const resource,
const char *const status);
void c_on_contact_presence_hook(ProfPlugin *plugin, const char *const barejid, const char *const resource,
const char *const presence, const char *const status, const int priority);
#endif

View File

@ -526,6 +526,28 @@ plugins_on_iq_stanza_receive(const char *const text)
return cont;
}
void
plugins_on_contact_offline(const char *const barejid, const char *const resource, const char *const status)
{
GSList *curr = plugins;
while (curr) {
ProfPlugin *plugin = curr->data;
plugin->on_contact_offline(plugin, barejid, resource, status);
curr = g_slist_next(curr);
}
}
void
plugins_on_contact_presence(const char *const barejid, const char *const resource, const char *const presence, const char *const status, const int priority)
{
GSList *curr = plugins;
while (curr) {
ProfPlugin *plugin = curr->data;
plugin->on_contact_presence(plugin, barejid, resource, presence, status, priority);
curr = g_slist_next(curr);
}
}
void
plugins_shutdown(void)
{

View File

@ -52,23 +52,30 @@ typedef struct prof_plugin_t {
void (*on_start_func)(struct prof_plugin_t* plugin);
void (*on_shutdown_func)(struct prof_plugin_t* plugin);
void (*on_connect_func)(struct prof_plugin_t* plugin, const char * const account_name, const char * const fulljid);
void (*on_disconnect_func)(struct prof_plugin_t* plugin, const char * const account_name, const char * const fulljid);
void (*on_connect_func)(struct prof_plugin_t* plugin, const char *const account_name, const char *const fulljid);
void (*on_disconnect_func)(struct prof_plugin_t* plugin, const char *const account_name,
const char *const fulljid);
char* (*pre_chat_message_display)(struct prof_plugin_t* plugin, const char * const jid, const char *message);
void (*post_chat_message_display)(struct prof_plugin_t* plugin, const char * const jid, const char *message);
char* (*pre_chat_message_send)(struct prof_plugin_t* plugin, const char * const jid, const char *message);
void (*post_chat_message_send)(struct prof_plugin_t* plugin, const char * const jid, const char *message);
char* (*pre_chat_message_display)(struct prof_plugin_t* plugin, const char *const jid, const char *message);
void (*post_chat_message_display)(struct prof_plugin_t* plugin, const char *const jid, const char *message);
char* (*pre_chat_message_send)(struct prof_plugin_t* plugin, const char *const jid, const char *message);
void (*post_chat_message_send)(struct prof_plugin_t* plugin, const char *const jid, const char *message);
char* (*pre_room_message_display)(struct prof_plugin_t* plugin, const char * const room, const char * const nick, const char *message);
void (*post_room_message_display)(struct prof_plugin_t* plugin, const char * const room, const char * const nick, const char *message);
char* (*pre_room_message_send)(struct prof_plugin_t* plugin, const char * const room, const char *message);
void (*post_room_message_send)(struct prof_plugin_t* plugin, const char * const room, const char *message);
char* (*pre_room_message_display)(struct prof_plugin_t* plugin, const char *const room, const char *const nick,
const char *message);
void (*post_room_message_display)(struct prof_plugin_t* plugin, const char *const room, const char *const nick,
const char *message);
char* (*pre_room_message_send)(struct prof_plugin_t* plugin, const char *const room, const char *message);
void (*post_room_message_send)(struct prof_plugin_t* plugin, const char *const room, const char *message);
char* (*pre_priv_message_display)(struct prof_plugin_t* plugin, const char * const room, const char * const nick, const char *message);
void (*post_priv_message_display)(struct prof_plugin_t* plugin, const char * const room, const char * const nick, const char *message);
char* (*pre_priv_message_send)(struct prof_plugin_t* plugin, const char * const room, const char * const nick, const char * const message);
void (*post_priv_message_send)(struct prof_plugin_t* plugin, const char * const room, const char * const nick, const char * const message);
char* (*pre_priv_message_display)(struct prof_plugin_t* plugin, const char *const room, const char *const nick,
const char *message);
void (*post_priv_message_display)(struct prof_plugin_t* plugin, const char *const room, const char *const nick,
const char *message);
char* (*pre_priv_message_send)(struct prof_plugin_t* plugin, const char *const room, const char *const nick,
const char *const message);
void (*post_priv_message_send)(struct prof_plugin_t* plugin, const char *const room, const char *const nick,
const char *const message);
char* (*on_message_stanza_send)(struct prof_plugin_t* plugin, const char *const text);
gboolean (*on_message_stanza_receive)(struct prof_plugin_t* plugin, const char *const text);
@ -78,37 +85,42 @@ typedef struct prof_plugin_t {
char* (*on_iq_stanza_send)(struct prof_plugin_t* plugin, const char *const text);
gboolean (*on_iq_stanza_receive)(struct prof_plugin_t* plugin, const char *const text);
void (*on_contact_offline)(struct prof_plugin_t* plugin, const char *const barejid, const char *const resource,
const char *const status);
void (*on_contact_presence)(struct prof_plugin_t* plugin, const char *const barejid, const char *const resource,
const char *const presence, const char *const status, const int priority);
} ProfPlugin;
void plugins_init(void);
GSList* plugins_get_list(void);
char* plugins_get_lang_string(ProfPlugin *plugin);
char* plugins_autocomplete(const char * const input);
char* plugins_autocomplete(const char *const input);
void plugins_reset_autocomplete(void);
void plugins_shutdown(void);
void plugins_on_start(void);
void plugins_on_shutdown(void);
void plugins_on_connect(const char * const account_name, const char * const fulljid);
void plugins_on_disconnect(const char * const account_name, const char * const fulljid);
void plugins_on_connect(const char *const account_name, const char *const fulljid);
void plugins_on_disconnect(const char *const account_name, const char *const fulljid);
char* plugins_pre_chat_message_display(const char * const jid, const char *message);
void plugins_post_chat_message_display(const char * const jid, const char *message);
char* plugins_pre_chat_message_send(const char * const jid, const char *message);
void plugins_post_chat_message_send(const char * const jid, const char *message);
char* plugins_pre_chat_message_display(const char *const jid, const char *message);
void plugins_post_chat_message_display(const char *const jid, const char *message);
char* plugins_pre_chat_message_send(const char *const jid, const char *message);
void plugins_post_chat_message_send(const char *const jid, const char *message);
char* plugins_pre_room_message_display(const char * const room, const char * const nick, const char *message);
void plugins_post_room_message_display(const char * const room, const char * const nick, const char *message);
char* plugins_pre_room_message_send(const char * const room, const char *message);
void plugins_post_room_message_send(const char * const room, const char *message);
char* plugins_pre_room_message_display(const char *const room, const char *const nick, const char *message);
void plugins_post_room_message_display(const char *const room, const char *const nick, const char *message);
char* plugins_pre_room_message_send(const char *const room, const char *message);
void plugins_post_room_message_send(const char *const room, const char *message);
char* plugins_pre_priv_message_display(const char * const jid, const char *message);
void plugins_post_priv_message_display(const char * const jid, const char *message);
char* plugins_pre_priv_message_send(const char * const jid, const char * const message);
void plugins_post_priv_message_send(const char * const jid, const char * const message);
char* plugins_pre_priv_message_display(const char *const jid, const char *message);
void plugins_post_priv_message_display(const char *const jid, const char *message);
char* plugins_pre_priv_message_send(const char *const jid, const char *const message);
void plugins_post_priv_message_send(const char *const jid, const char *const message);
void plugins_win_process_line(char *win, const char * const line);
void plugins_win_process_line(char *win, const char *const line);
char* plugins_on_message_stanza_send(const char *const text);
gboolean plugins_on_message_stanza_receive(const char *const text);
@ -119,6 +131,10 @@ gboolean plugins_on_presence_stanza_receive(const char *const text);
char* plugins_on_iq_stanza_send(const char *const text);
gboolean plugins_on_iq_stanza_receive(const char *const text);
void plugins_on_contact_offline(const char *const barejid, const char *const resource, const char *const status);
void plugins_on_contact_presence(const char *const barejid, const char *const resource, const char *const presence,
const char *const status, const int priority);
gboolean plugins_run_command(const char * const cmd);
void plugins_run_timed(void);
GList* plugins_get_command_names(void);

View File

@ -86,8 +86,8 @@ python_env_init(void)
allow_python_threads();
}
ProfPlugin *
python_plugin_create(const char * const filename)
ProfPlugin*
python_plugin_create(const char *const filename)
{
disable_python_threads();
gchar *module_name = g_strndup(filename, strlen(filename) - 3);
@ -121,6 +121,8 @@ python_plugin_create(const char * const filename)
plugin->on_presence_stanza_receive = python_on_presence_stanza_receive_hook;
plugin->on_iq_stanza_send = python_on_iq_stanza_send_hook;
plugin->on_iq_stanza_receive = python_on_iq_stanza_receive_hook;
plugin->on_contact_offline = python_on_contact_offline_hook;
plugin->on_contact_presence = python_on_contact_presence_hook;
g_free(module_name);
allow_python_threads();
@ -133,7 +135,7 @@ python_plugin_create(const char * const filename)
}
void
python_init_hook(ProfPlugin *plugin, const char * const version, const char * const status)
python_init_hook(ProfPlugin *plugin, const char *const version, const char *const status)
{
disable_python_threads();
PyObject *p_args = Py_BuildValue("ss", version, status);
@ -191,8 +193,7 @@ python_on_shutdown_hook(ProfPlugin *plugin)
}
void
python_on_connect_hook(ProfPlugin *plugin, const char * const account_name,
const char * const fulljid)
python_on_connect_hook(ProfPlugin *plugin, const char *const account_name, const char *const fulljid)
{
disable_python_threads();
PyObject *p_args = Py_BuildValue("ss", account_name, fulljid);
@ -212,8 +213,7 @@ python_on_connect_hook(ProfPlugin *plugin, const char * const account_name,
}
void
python_on_disconnect_hook(ProfPlugin *plugin, const char * const account_name,
const char * const fulljid)
python_on_disconnect_hook(ProfPlugin *plugin, const char *const account_name, const char *const fulljid)
{
disable_python_threads();
PyObject *p_args = Py_BuildValue("ss", account_name, fulljid);
@ -233,7 +233,7 @@ python_on_disconnect_hook(ProfPlugin *plugin, const char * const account_name,
}
char*
python_pre_chat_message_display_hook(ProfPlugin *plugin, const char * const jid, const char *message)
python_pre_chat_message_display_hook(ProfPlugin *plugin, const char *const jid, const char *message)
{
disable_python_threads();
PyObject *p_args = Py_BuildValue("ss", jid, message);
@ -269,7 +269,7 @@ python_pre_chat_message_display_hook(ProfPlugin *plugin, const char * const jid,
}
void
python_post_chat_message_display_hook(ProfPlugin *plugin, const char * const jid, const char *message)
python_post_chat_message_display_hook(ProfPlugin *plugin, const char *const jid, const char *message)
{
disable_python_threads();
PyObject *p_args = Py_BuildValue("ss", jid, message);
@ -326,7 +326,7 @@ python_pre_chat_message_send_hook(ProfPlugin *plugin, const char * const jid, co
}
void
python_post_chat_message_send_hook(ProfPlugin *plugin, const char * const jid, const char *message)
python_post_chat_message_send_hook(ProfPlugin *plugin, const char *const jid, const char *message)
{
disable_python_threads();
PyObject *p_args = Py_BuildValue("ss", jid, message);
@ -383,7 +383,8 @@ python_pre_room_message_display_hook(ProfPlugin *plugin, const char * const room
}
void
python_post_room_message_display_hook(ProfPlugin *plugin, const char * const room, const char * const nick, const char *message)
python_post_room_message_display_hook(ProfPlugin *plugin, const char *const room, const char *const nick,
const char *message)
{
disable_python_threads();
PyObject *p_args = Py_BuildValue("sss", room, nick, message);
@ -404,7 +405,7 @@ python_post_room_message_display_hook(ProfPlugin *plugin, const char * const roo
}
char*
python_pre_room_message_send_hook(ProfPlugin *plugin, const char * const room, const char *message)
python_pre_room_message_send_hook(ProfPlugin *plugin, const char *const room, const char *message)
{
disable_python_threads();
PyObject *p_args = Py_BuildValue("ss", room, message);
@ -440,7 +441,7 @@ python_pre_room_message_send_hook(ProfPlugin *plugin, const char * const room, c
}
void
python_post_room_message_send_hook(ProfPlugin *plugin, const char * const room, const char *message)
python_post_room_message_send_hook(ProfPlugin *plugin, const char *const room, const char *message)
{
disable_python_threads();
PyObject *p_args = Py_BuildValue("ss", room, message);
@ -461,7 +462,8 @@ python_post_room_message_send_hook(ProfPlugin *plugin, const char * const room,
}
char*
python_pre_priv_message_display_hook(ProfPlugin *plugin, const char * const room, const char * const nick, const char *message)
python_pre_priv_message_display_hook(ProfPlugin *plugin, const char *const room, const char *const nick,
const char *message)
{
disable_python_threads();
PyObject *p_args = Py_BuildValue("sss", room, nick, message);
@ -497,7 +499,8 @@ python_pre_priv_message_display_hook(ProfPlugin *plugin, const char * const room
}
void
python_post_priv_message_display_hook(ProfPlugin *plugin, const char * const room, const char * const nick, const char *message)
python_post_priv_message_display_hook(ProfPlugin *plugin, const char *const room, const char *const nick,
const char *message)
{
disable_python_threads();
PyObject *p_args = Py_BuildValue("sss", room, nick, message);
@ -518,7 +521,8 @@ python_post_priv_message_display_hook(ProfPlugin *plugin, const char * const roo
}
char*
python_pre_priv_message_send_hook(ProfPlugin *plugin, const char * const room, const char * const nick, const char * const message)
python_pre_priv_message_send_hook(ProfPlugin *plugin, const char *const room, const char *const nick,
const char *const message)
{
disable_python_threads();
PyObject *p_args = Py_BuildValue("sss", room, nick, message);
@ -554,7 +558,8 @@ python_pre_priv_message_send_hook(ProfPlugin *plugin, const char * const room, c
}
void
python_post_priv_message_send_hook(ProfPlugin *plugin, const char * const room, const char * const nick, const char * const message)
python_post_priv_message_send_hook(ProfPlugin *plugin, const char *const room, const char *const nick,
const char *const message)
{
disable_python_threads();
PyObject *p_args = Py_BuildValue("sss", room, nick, message);
@ -769,6 +774,50 @@ python_on_iq_stanza_receive_hook(ProfPlugin *plugin, const char *const text)
return TRUE;
}
void
python_on_contact_offline_hook(ProfPlugin *plugin, const char *const barejid, const char *const resource,
const char *const status)
{
disable_python_threads();
PyObject *p_args = Py_BuildValue("sss", barejid, resource, status);
PyObject *p_function;
PyObject *p_module = plugin->module;
if (PyObject_HasAttrString(p_module, "prof_on_contact_offline")) {
p_function = PyObject_GetAttrString(p_module, "prof_on_contact_offline");
python_check_error();
if (p_function && PyCallable_Check(p_function)) {
PyObject_CallObject(p_function, p_args);
python_check_error();
Py_XDECREF(p_function);
}
}
allow_python_threads();
}
void
python_on_contact_presence_hook(ProfPlugin *plugin, const char *const barejid, const char *const resource,
const char *const presence, const char *const status, const int priority)
{
disable_python_threads();
PyObject *p_args = Py_BuildValue("ssssi", barejid, resource, presence, status, priority);
PyObject *p_function;
PyObject *p_module = plugin->module;
if (PyObject_HasAttrString(p_module, "prof_on_contact_presence")) {
p_function = PyObject_GetAttrString(p_module, "prof_on_contact_presence");
python_check_error();
if (p_function && PyCallable_Check(p_function)) {
PyObject_CallObject(p_function, p_args);
python_check_error();
Py_XDECREF(p_function);
}
}
allow_python_threads();
}
void
python_check_error(void)
{

View File

@ -37,32 +37,38 @@
#include "plugins/plugins.h"
ProfPlugin* python_plugin_create(const char * const filename);
ProfPlugin* python_plugin_create(const char *const filename);
void python_plugin_destroy(ProfPlugin *plugin);
void python_check_error(void);
void allow_python_threads();
void disable_python_threads();
void python_init_hook(ProfPlugin *plugin, const char * const version, const char * const status);
void python_init_hook(ProfPlugin *plugin, const char *const version, const char *const status);
void python_on_start_hook(ProfPlugin *plugin);
void python_on_shutdown_hook(ProfPlugin *plugin);
void python_on_connect_hook(ProfPlugin *plugin, const char * const account_name, const char * const fulljid);
void python_on_disconnect_hook(ProfPlugin *plugin, const char * const account_name, const char * const fulljid);
void python_on_connect_hook(ProfPlugin *plugin, const char *const account_name, const char *const fulljid);
void python_on_disconnect_hook(ProfPlugin *plugin, const char *const account_name, const char *const fulljid);
char* python_pre_chat_message_display_hook(ProfPlugin *plugin, const char * const jid, const char *message);
void python_post_chat_message_display_hook(ProfPlugin *plugin, const char * const jid, const char *message);
char* python_pre_chat_message_send_hook(ProfPlugin *plugin, const char * const jid, const char *message);
void python_post_chat_message_send_hook(ProfPlugin *plugin, const char * const jid, const char *message);
char* python_pre_chat_message_display_hook(ProfPlugin *plugin, const char *const jid, const char *message);
void python_post_chat_message_display_hook(ProfPlugin *plugin, const char *const jid, const char *message);
char* python_pre_chat_message_send_hook(ProfPlugin *plugin, const char *const jid, const char *message);
void python_post_chat_message_send_hook(ProfPlugin *plugin, const char *const jid, const char *message);
char* python_pre_room_message_display_hook(ProfPlugin *plugin, const char * const room, const char * const nick, const char *message);
void python_post_room_message_display_hook(ProfPlugin *plugin, const char * const room, const char * const nick, const char *message);
char* python_pre_room_message_send_hook(ProfPlugin *plugin, const char * const room, const char *message);
void python_post_room_message_send_hook(ProfPlugin *plugin, const char * const room, const char *message);
char* python_pre_room_message_display_hook(ProfPlugin *plugin, const char *const room, const char *const nick,
const char *message);
void python_post_room_message_display_hook(ProfPlugin *plugin, const char *const room, const char *const nick,
const char *message);
char* python_pre_room_message_send_hook(ProfPlugin *plugin, const char *const room, const char *message);
void python_post_room_message_send_hook(ProfPlugin *plugin, const char *const room, const char *message);
char* python_pre_priv_message_display_hook(ProfPlugin *plugin, const char * const room, const char * const nick, const char *message);
void python_post_priv_message_display_hook(ProfPlugin *plugin, const char * const room, const char * const nick, const char *message);
char* python_pre_priv_message_send_hook(ProfPlugin *plugin, const char * const room, const char * const nick, const char * const message);
void python_post_priv_message_send_hook(ProfPlugin *plugin, const char * const room, const char * const nick, const char * const message);
char* python_pre_priv_message_display_hook(ProfPlugin *plugin, const char *const room, const char *const nick,
const char *message);
void python_post_priv_message_display_hook(ProfPlugin *plugin, const char *const room, const char *const nick,
const char *message);
char* python_pre_priv_message_send_hook(ProfPlugin *plugin, const char *const room, const char *const nick,
const char *const message);
void python_post_priv_message_send_hook(ProfPlugin *plugin, const char *const room, const char *const nick,
const char *const message);
char* python_on_message_stanza_send_hook(ProfPlugin *plugin, const char *const text);
gboolean python_on_message_stanza_receive_hook(ProfPlugin *plugin, const char *const text);
@ -71,4 +77,9 @@ gboolean python_on_presence_stanza_receive_hook(ProfPlugin *plugin, const char *
char* python_on_iq_stanza_send_hook(ProfPlugin *plugin, const char *const text);
gboolean python_on_iq_stanza_receive_hook(ProfPlugin *plugin, const char *const text);
void python_on_contact_offline_hook(ProfPlugin *plugin, const char *const barejid, const char *const resource,
const char *const status);
void python_on_contact_presence_hook(ProfPlugin *plugin, const char *const barejid, const char *const resource,
const char *const presence, const char *const status, const int priority);
#endif