|
|
|
@ -35,6 +35,7 @@ const long EVENT_LOOP_INTERVAL = 200;
@@ -35,6 +35,7 @@ const long EVENT_LOOP_INTERVAL = 200;
|
|
|
|
|
struct t_weechat_plugin *weechat_xmpp_plugin = NULL; |
|
|
|
|
struct t_config_option *opt_jid = NULL; |
|
|
|
|
struct t_config_option *opt_password = NULL; |
|
|
|
|
struct t_config_option *opt_autoconnect = NULL; |
|
|
|
|
xmpp_ctx_t *xmpp_ctx = NULL; |
|
|
|
|
xmpp_conn_t *xmpp_conn = NULL; |
|
|
|
|
|
|
|
|
@ -290,6 +291,15 @@ void weechat_config_init() {
@@ -290,6 +291,15 @@ void weechat_config_init() {
|
|
|
|
|
1, NULL, NULL, NULL, |
|
|
|
|
NULL, NULL, NULL, |
|
|
|
|
NULL, NULL, NULL); |
|
|
|
|
opt_autoconnect = |
|
|
|
|
weechat_config_new_option(file, sect_account, "autoconnect", "boolean", |
|
|
|
|
"Whether to connect to XMPP when WeeChat is started.", |
|
|
|
|
NULL, 0, 0, "off", "off", |
|
|
|
|
0, NULL, NULL, NULL, |
|
|
|
|
NULL, NULL, NULL, |
|
|
|
|
NULL, NULL, NULL); |
|
|
|
|
|
|
|
|
|
weechat_config_read(file); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int on_event_loop_timer(const void *xmpp_ctx_ptr, void *data, int remaining_calls) { |
|
|
|
@ -298,6 +308,13 @@ int on_event_loop_timer(const void *xmpp_ctx_ptr, void *data, int remaining_call
@@ -298,6 +308,13 @@ int on_event_loop_timer(const void *xmpp_ctx_ptr, void *data, int remaining_call
|
|
|
|
|
return WEECHAT_RC_OK; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int maybe_autoconnect(const void *data1, void *data, int remaining_calls) { |
|
|
|
|
if (weechat_config_boolean (opt_autoconnect)) { |
|
|
|
|
xmpp_connect(); |
|
|
|
|
} |
|
|
|
|
return WEECHAT_RC_OK; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int weechat_plugin_init(struct t_weechat_plugin *plugin, int argc, char **argv) { |
|
|
|
|
weechat_plugin = plugin; |
|
|
|
@ -328,6 +345,12 @@ int weechat_plugin_init(struct t_weechat_plugin *plugin, int argc, char **argv)
@@ -328,6 +345,12 @@ int weechat_plugin_init(struct t_weechat_plugin *plugin, int argc, char **argv)
|
|
|
|
|
return WEECHAT_RC_ERROR; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
struct t_hook *ac_hook = weechat_hook_timer(1, 0, 1, &maybe_autoconnect, NULL, NULL); |
|
|
|
|
if (!ac_hook) { |
|
|
|
|
weechat_printf(NULL, "%sxmpp: autoconnect hook failed", weechat_prefix("error")); |
|
|
|
|
return WEECHAT_RC_ERROR; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
weechat_printf(NULL, "xmpp: plugin loaded"); |
|
|
|
|
return WEECHAT_RC_OK; |
|
|
|
|
} |
|
|
|
|