mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05:00
Added account_name and fulljid to on_connect hook
This commit is contained in:
parent
6db8fe848c
commit
c5e39e0f54
@ -10,8 +10,8 @@ module RubyTest
|
||||
Prof::cons_show("RubyTest: on_start")
|
||||
end
|
||||
|
||||
def self.prof_on_connect()
|
||||
Prof::cons_show("RubyTest: on_connect")
|
||||
def self.prof_on_connect(account_name, fulljid)
|
||||
Prof::cons_show("RubyTest: on_connect, " + account_name + ", " + fulljid)
|
||||
end
|
||||
|
||||
def self.prof_on_message_received(jid, message)
|
||||
|
@ -8,8 +8,8 @@ def prof_init(version, status):
|
||||
def prof_on_start():
|
||||
prof.cons_show("python-test: on_start")
|
||||
|
||||
def prof_on_connect():
|
||||
prof.cons_show("python-test: on_connect")
|
||||
def prof_on_connect(account_name, fulljid):
|
||||
prof.cons_show("python-test: on_connect, " + account_name + ", " + fulljid)
|
||||
|
||||
def prof_on_message_received(jid, message):
|
||||
prof.cons_show("python-test: on_message_received, " + jid + ", " + message)
|
||||
|
@ -17,9 +17,9 @@ prof_on_start (void)
|
||||
}
|
||||
|
||||
void
|
||||
prof_on_connect (void)
|
||||
prof_on_connect (const char * const account_name, const char * const fulljid)
|
||||
{
|
||||
fprintf (stderr, "called %s with no args\n", __func__);
|
||||
fprintf (stderr, "called %s with args=<%s, %s>\n", __func__, account_name, fulljid);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -81,17 +81,17 @@ c_on_start_hook (ProfPlugin *plugin)
|
||||
|
||||
|
||||
void
|
||||
c_on_connect_hook (ProfPlugin *plugin)
|
||||
c_on_connect_hook (ProfPlugin *plugin, const char * const account_name, const char * const fulljid)
|
||||
{
|
||||
void * f = NULL;
|
||||
void (*func)(void);
|
||||
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 (*)(void)) f;
|
||||
func ();
|
||||
func = (void (*)(const char * const, const char * const)) f;
|
||||
func (account_name, fulljid);
|
||||
}
|
||||
|
||||
|
||||
|
@ -7,7 +7,7 @@ ProfPlugin* c_plugin_create(const char * const filename);
|
||||
|
||||
void c_init_hook(ProfPlugin *plugin, const char * const version, const char * const status);
|
||||
void c_on_start_hook (ProfPlugin *plugin);
|
||||
void c_on_connect_hook (ProfPlugin *plugin);
|
||||
void c_on_connect_hook (ProfPlugin *plugin, const char * const account_name, const char * const fulljid);
|
||||
void c_on_message_received_hook(ProfPlugin *plugin, const char * const jid, const char * const message);
|
||||
void c_close_library (ProfPlugin * plugin);
|
||||
|
||||
|
@ -99,12 +99,12 @@ plugins_on_start(void)
|
||||
}
|
||||
|
||||
void
|
||||
plugins_on_connect(void)
|
||||
plugins_on_connect(const char * const account_name, const char * const fulljid)
|
||||
{
|
||||
GSList *curr = plugins;
|
||||
while (curr != NULL) {
|
||||
ProfPlugin *plugin = curr->data;
|
||||
plugin->on_connect_func(plugin);
|
||||
plugin->on_connect_func(plugin, account_name, fulljid);
|
||||
curr = g_slist_next(curr);
|
||||
}
|
||||
}
|
||||
|
@ -36,14 +36,15 @@ typedef struct prof_plugin_t {
|
||||
void (*init_func)(struct prof_plugin_t* plugin, const char * const version,
|
||||
const char * const status);
|
||||
void (*on_start_func)(struct prof_plugin_t* plugin);
|
||||
void (*on_connect_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_message_received_func)(struct prof_plugin_t* plugin,
|
||||
const char * const jid, const char * const message);
|
||||
} ProfPlugin;
|
||||
|
||||
void plugins_init(void);
|
||||
void plugins_on_start(void);
|
||||
void plugins_on_connect(void);
|
||||
void plugins_on_connect(const char * const account_name, const char * const fulljid);
|
||||
void plugins_on_message_received(const char * const jid, const char * const message);
|
||||
void plugins_shutdown(void);
|
||||
gboolean plugins_run_command(const char * const cmd);
|
||||
|
@ -104,8 +104,10 @@ python_on_start_hook(ProfPlugin *plugin)
|
||||
}
|
||||
|
||||
void
|
||||
python_on_connect_hook(ProfPlugin *plugin)
|
||||
python_on_connect_hook(ProfPlugin *plugin, const char * const account_name,
|
||||
const char * const fulljid)
|
||||
{
|
||||
PyObject *p_args = Py_BuildValue("ss", account_name, fulljid);
|
||||
PyObject *p_function;
|
||||
|
||||
PyObject *p_module = plugin->module;
|
||||
@ -113,7 +115,7 @@ python_on_connect_hook(ProfPlugin *plugin)
|
||||
p_function = PyObject_GetAttrString(p_module, "prof_on_connect");
|
||||
python_check_error();
|
||||
if (p_function && PyCallable_Check(p_function)) {
|
||||
PyObject_CallObject(p_function, NULL);
|
||||
PyObject_CallObject(p_function, p_args);
|
||||
python_check_error();
|
||||
Py_XDECREF(p_function);
|
||||
}
|
||||
@ -121,7 +123,8 @@ python_on_connect_hook(ProfPlugin *plugin)
|
||||
}
|
||||
|
||||
void
|
||||
python_on_message_received_hook(ProfPlugin *plugin, const char * const jid, const char * const message)
|
||||
python_on_message_received_hook(ProfPlugin *plugin, const char * const jid,
|
||||
const char * const message)
|
||||
{
|
||||
PyObject *p_args = Py_BuildValue("ss", jid, message);
|
||||
PyObject *p_function;
|
||||
|
@ -29,7 +29,7 @@ ProfPlugin* python_plugin_create(const char * const filename);
|
||||
|
||||
void python_init_hook(ProfPlugin *plugin, const char * const version, const char * const status);
|
||||
void python_on_start_hook(ProfPlugin *plugin);
|
||||
void python_on_connect_hook(ProfPlugin *plugin);
|
||||
void python_on_connect_hook(ProfPlugin *plugin, const char * const account_name, const char * const fulljid);
|
||||
void python_on_message_received_hook(ProfPlugin *plugin, const char * const jid, const char * const message);
|
||||
|
||||
void python_check_error(void);
|
||||
|
@ -83,16 +83,20 @@ ruby_on_start_hook(ProfPlugin *plugin)
|
||||
}
|
||||
|
||||
void
|
||||
ruby_on_connect_hook(ProfPlugin *plugin)
|
||||
ruby_on_connect_hook(ProfPlugin *plugin, const char * const account_name,
|
||||
const char * const fulljid)
|
||||
{
|
||||
VALUE v_account_name = rb_str_new2(account_name);
|
||||
VALUE v_fulljid = rb_str_new2(fulljid);
|
||||
VALUE module = (VALUE) plugin->module;
|
||||
if (_method_exists(plugin, "prof_on_connect")) {
|
||||
rb_funcall(module, rb_intern("prof_on_connect"), 0);
|
||||
rb_funcall(module, rb_intern("prof_on_connect"), 2, v_account_name, v_fulljid);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
ruby_on_message_received_hook(ProfPlugin *plugin, const char * const jid, const char * const message)
|
||||
ruby_on_message_received_hook(ProfPlugin *plugin, const char * const jid,
|
||||
const char * const message)
|
||||
{
|
||||
VALUE v_jid = rb_str_new2(jid);
|
||||
VALUE v_message = rb_str_new2(message);
|
||||
|
@ -29,7 +29,7 @@ ProfPlugin* ruby_plugin_create(const char * const filename);
|
||||
|
||||
void ruby_init_hook(ProfPlugin *plugin, const char * const version, const char * const status);
|
||||
void ruby_on_start_hook(ProfPlugin *plugin);
|
||||
void ruby_on_connect_hook(ProfPlugin *plugin);
|
||||
void ruby_on_connect_hook(ProfPlugin *plugin, const char * const account_name, const char * const fulljid);
|
||||
void ruby_on_message_received_hook(ProfPlugin *plugin, const char * const jid, const char * const message);
|
||||
|
||||
void ruby_check_error(void);
|
||||
|
@ -635,11 +635,14 @@ _roster_handle_result(xmpp_conn_t * const conn, xmpp_stanza_t * const stanza,
|
||||
item = xmpp_stanza_get_next(item);
|
||||
}
|
||||
|
||||
char *account_name = jabber_get_account_name();
|
||||
const char *fulljid = jabber_get_fulljid();
|
||||
|
||||
contact_presence_t conn_presence =
|
||||
accounts_get_login_presence(jabber_get_account_name());
|
||||
accounts_get_login_presence(account_name);
|
||||
presence_update(conn_presence, NULL, 0);
|
||||
|
||||
plugins_on_connect();
|
||||
plugins_on_connect(account_name, fulljid);
|
||||
}
|
||||
|
||||
return 1;
|
||||
|
Loading…
Reference in New Issue
Block a user