mirror of
https://github.com/profanity-im/profanity.git
synced 2025-07-26 12:14:28 -04:00
Plugins: Added on_chat_win_focus
This commit is contained in:
parent
bfdc3b8807
commit
271278dd20
@ -105,6 +105,7 @@ c_plugin_create(const char *const filename)
|
|||||||
plugin->on_iq_stanza_receive = c_on_iq_stanza_receive_hook;
|
plugin->on_iq_stanza_receive = c_on_iq_stanza_receive_hook;
|
||||||
plugin->on_contact_offline = c_on_contact_offline_hook;
|
plugin->on_contact_offline = c_on_contact_offline_hook;
|
||||||
plugin->on_contact_presence = c_on_contact_presence_hook;
|
plugin->on_contact_presence = c_on_contact_presence_hook;
|
||||||
|
plugin->on_chat_win_focus = c_on_chat_win_focus_hook;
|
||||||
|
|
||||||
g_string_free(path, TRUE);
|
g_string_free(path, TRUE);
|
||||||
g_free(module_name);
|
g_free(module_name);
|
||||||
@ -472,6 +473,20 @@ c_on_contact_presence_hook(ProfPlugin *plugin, const char *const barejid, const
|
|||||||
func(barejid, resource, presence, status, priority);
|
func(barejid, resource, presence, status, priority);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
c_on_chat_win_focus_hook(ProfPlugin *plugin, const char *const barejid)
|
||||||
|
{
|
||||||
|
void *f = NULL;
|
||||||
|
void (*func)(const char *const __barejid);
|
||||||
|
assert(plugin && plugin->module);
|
||||||
|
|
||||||
|
if (NULL == (f = dlsym(plugin->module, "prof_on_chat_win_focus")))
|
||||||
|
return;
|
||||||
|
|
||||||
|
func = (void (*)(const char *const))f;
|
||||||
|
func(barejid);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
c_plugin_destroy(ProfPlugin *plugin)
|
c_plugin_destroy(ProfPlugin *plugin)
|
||||||
{
|
{
|
||||||
|
@ -84,4 +84,6 @@ void c_on_contact_offline_hook(ProfPlugin *plugin, const char *const barejid, co
|
|||||||
void c_on_contact_presence_hook(ProfPlugin *plugin, const char *const barejid, const char *const resource,
|
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);
|
const char *const presence, const char *const status, const int priority);
|
||||||
|
|
||||||
|
void c_on_chat_win_focus_hook(ProfPlugin *plugin, const char *const barejid);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -548,6 +548,17 @@ plugins_on_contact_presence(const char *const barejid, const char *const resourc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
plugins_on_chat_win_focus(const char *const barejid)
|
||||||
|
{
|
||||||
|
GSList *curr = plugins;
|
||||||
|
while (curr) {
|
||||||
|
ProfPlugin *plugin = curr->data;
|
||||||
|
plugin->on_chat_win_focus(plugin, barejid);
|
||||||
|
curr = g_slist_next(curr);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
plugins_shutdown(void)
|
plugins_shutdown(void)
|
||||||
{
|
{
|
||||||
|
@ -90,6 +90,8 @@ typedef struct prof_plugin_t {
|
|||||||
const char *const status);
|
const char *const status);
|
||||||
void (*on_contact_presence)(struct prof_plugin_t* plugin, const char *const barejid, const char *const resource,
|
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);
|
const char *const presence, const char *const status, const int priority);
|
||||||
|
|
||||||
|
void (*on_chat_win_focus)(struct prof_plugin_t* plugin, const char *const barejid);
|
||||||
} ProfPlugin;
|
} ProfPlugin;
|
||||||
|
|
||||||
void plugins_init(void);
|
void plugins_init(void);
|
||||||
@ -135,6 +137,8 @@ void plugins_on_contact_offline(const char *const barejid, const char *const res
|
|||||||
void plugins_on_contact_presence(const char *const barejid, const char *const resource, const char *const presence,
|
void plugins_on_contact_presence(const char *const barejid, const char *const resource, const char *const presence,
|
||||||
const char *const status, const int priority);
|
const char *const status, const int priority);
|
||||||
|
|
||||||
|
void plugins_on_chat_win_focus(const char *const barejid);
|
||||||
|
|
||||||
gboolean plugins_run_command(const char * const cmd);
|
gboolean plugins_run_command(const char * const cmd);
|
||||||
void plugins_run_timed(void);
|
void plugins_run_timed(void);
|
||||||
GList* plugins_get_command_names(void);
|
GList* plugins_get_command_names(void);
|
||||||
|
@ -123,6 +123,7 @@ python_plugin_create(const char *const filename)
|
|||||||
plugin->on_iq_stanza_receive = python_on_iq_stanza_receive_hook;
|
plugin->on_iq_stanza_receive = python_on_iq_stanza_receive_hook;
|
||||||
plugin->on_contact_offline = python_on_contact_offline_hook;
|
plugin->on_contact_offline = python_on_contact_offline_hook;
|
||||||
plugin->on_contact_presence = python_on_contact_presence_hook;
|
plugin->on_contact_presence = python_on_contact_presence_hook;
|
||||||
|
plugin->on_chat_win_focus = python_on_chat_win_focus_hook;
|
||||||
g_free(module_name);
|
g_free(module_name);
|
||||||
|
|
||||||
allow_python_threads();
|
allow_python_threads();
|
||||||
@ -818,6 +819,27 @@ python_on_contact_presence_hook(ProfPlugin *plugin, const char *const barejid, c
|
|||||||
allow_python_threads();
|
allow_python_threads();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
python_on_chat_win_focus_hook(ProfPlugin *plugin, const char *const barejid)
|
||||||
|
{
|
||||||
|
disable_python_threads();
|
||||||
|
PyObject *p_args = Py_BuildValue("(s)", barejid);
|
||||||
|
PyObject *p_function;
|
||||||
|
|
||||||
|
PyObject *p_module = plugin->module;
|
||||||
|
if (PyObject_HasAttrString(p_module, "prof_on_chat_win_focus")) {
|
||||||
|
p_function = PyObject_GetAttrString(p_module, "prof_on_chat_win_focus");
|
||||||
|
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
|
void
|
||||||
python_check_error(void)
|
python_check_error(void)
|
||||||
{
|
{
|
||||||
|
@ -82,4 +82,6 @@ void python_on_contact_offline_hook(ProfPlugin *plugin, const char *const bareji
|
|||||||
void python_on_contact_presence_hook(ProfPlugin *plugin, const char *const barejid, const char *const resource,
|
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);
|
const char *const presence, const char *const status, const int priority);
|
||||||
|
|
||||||
|
void python_on_chat_win_focus_hook(ProfPlugin *plugin, const char *const barejid);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -46,6 +46,8 @@
|
|||||||
#include "ui/ui.h"
|
#include "ui/ui.h"
|
||||||
#include "ui/statusbar.h"
|
#include "ui/statusbar.h"
|
||||||
#include "window_list.h"
|
#include "window_list.h"
|
||||||
|
#include "plugins/plugins.h"
|
||||||
|
|
||||||
|
|
||||||
static GHashTable *windows;
|
static GHashTable *windows;
|
||||||
static int current;
|
static int current;
|
||||||
@ -324,6 +326,7 @@ wins_set_current_by_num(int i)
|
|||||||
ProfChatWin *chatwin = (ProfChatWin*) window;
|
ProfChatWin *chatwin = (ProfChatWin*) window;
|
||||||
assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
|
assert(chatwin->memcheck == PROFCHATWIN_MEMCHECK);
|
||||||
chatwin->unread = 0;
|
chatwin->unread = 0;
|
||||||
|
plugins_on_chat_win_focus(chatwin->barejid);
|
||||||
} else if (window->type == WIN_MUC) {
|
} else if (window->type == WIN_MUC) {
|
||||||
ProfMucWin *mucwin = (ProfMucWin*) window;
|
ProfMucWin *mucwin = (ProfMucWin*) window;
|
||||||
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
|
assert(mucwin->memcheck == PROFMUCWIN_MEMCHECK);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user