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:
commit
f4f5b36814
@ -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);
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
@ -256,7 +258,8 @@ c_pre_room_message_display_hook(ProfPlugin *plugin, const char * const room, con
|
||||
}
|
||||
|
||||
void
|
||||
c_post_room_message_display_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);
|
||||
@ -312,7 +315,8 @@ c_pre_priv_message_display_hook(ProfPlugin *plugin, const char * const room, con
|
||||
}
|
||||
|
||||
void
|
||||
c_post_priv_message_display_hook(ProfPlugin *plugin, const char * const room, const char * const nick, const char *message)
|
||||
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);
|
||||
@ -437,6 +441,37 @@ c_on_iq_stanza_receive_hook(ProfPlugin *plugin, const char *const text)
|
||||
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
|
||||
c_plugin_destroy(ProfPlugin *plugin)
|
||||
{
|
||||
|
@ -54,15 +54,21 @@ void c_post_chat_message_display_hook(ProfPlugin *plugin, const char * const ji
|
||||
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_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
|
||||
|
@ -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)
|
||||
{
|
||||
|
@ -53,22 +53,29 @@ typedef struct prof_plugin_t {
|
||||
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_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_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_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,6 +85,11 @@ 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);
|
||||
@ -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);
|
||||
|
@ -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();
|
||||
@ -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);
|
||||
@ -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);
|
||||
@ -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)
|
||||
{
|
||||
|
@ -54,15 +54,21 @@ void python_post_chat_message_display_hook(ProfPlugin *plugin, const char * con
|
||||
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_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
|
||||
|
Loading…
Reference in New Issue
Block a user