From 86bfc6359c392866bf6d67075881d2812398a686 Mon Sep 17 00:00:00 2001 From: Tony Olagbaiye Date: Sat, 26 Jun 2021 02:31:45 +0100 Subject: [PATCH] efforts --- .dir-locals.el | 4 +- Makefile | 7 +- slack-command.c | 4 +- slack-completion.c | 4 +- slack-config.h | 57 ------- slack-workspace.c | 2 +- slack-config.c => xmpp-config.c | 269 ++++++++++++++++++-------------- xmpp-config.h | 59 +++++++ xmpp.c | 55 ++++--- 9 files changed, 258 insertions(+), 203 deletions(-) delete mode 100644 slack-config.h rename slack-config.c => xmpp-config.c (51%) create mode 100644 xmpp-config.h diff --git a/.dir-locals.el b/.dir-locals.el index 6166711..89604c0 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -3,10 +3,10 @@ ((c-mode (eval . (setq-local flycheck-clang-include-path - (list (expand-file-name "libwebsockets/include" (projectile-project-root)) + (list (expand-file-name "libstrophe" (projectile-project-root)) (expand-file-name "json-c" (projectile-project-root))))) (eval . (setq-local company-clang-arguments - (list (concat "-I" (expand-file-name "libwebsockets/include" (projectile-project-root))) + (list (concat "-I" (expand-file-name "libstrophe" (projectile-project-root))) (concat "-I" (expand-file-name "json-c" (projectile-project-root)))))) (eval . (setq-local tags-table-list (expand-file-name ".git/tags" (projectile-project-root)))) (flycheck-clang-warnings . ("all" "extra" "error-implicit-function-declaration" "no-missing-field-initializers")) diff --git a/Makefile b/Makefile index b40bb4a..94bb22e 100644 --- a/Makefile +++ b/Makefile @@ -6,13 +6,14 @@ RM=rm -f FIND=find CFLAGS+=$(DBGCFLAGS) -fno-omit-frame-pointer -fPIC -std=gnu99 -g -Wall -Wextra -Werror-implicit-function-declaration -Wno-missing-field-initializers -Ilibstrophe -Ijson-c LDFLAGS+=-shared -g $(DBGCFLAGS) $(DBGLDFLAGS) -LDLIBS= +LDLIBS=-lssl -lxml2 PREFIX ?= /usr/local LIBDIR ?= $(PREFIX)/lib INSTALL ?= /usr/bin/install SRCS=xmpp.c \ + xmpp-config.c \ OLDSRCS=slack.c \ slack-api.c \ @@ -48,10 +49,10 @@ OBJS=$(subst .c,.o,$(SRCS)) libstrophe/.libs/libstrophe.a json-c/libjson-c.a all: libstrophe/.libs/libstrophe.a json-c/libjson-c.a weechat-xmpp weechat-xmpp: $(OBJS) - $(CC) $(LDFLAGS) -o xmpp.so $(OBJS) $(LDLIBS) + $(CC) $(LDFLAGS) -o xmpp.so $(OBJS) $(LDLIBS) libstrophe/.libs/libstrophe.a: - cd libstrophe && ./bootstrap.sh && env CFLAGS= LDFLAGS= ./configure + cd libstrophe && ./bootstrap.sh && env CFLAGS=-fPIC LDFLAGS= ./configure $(MAKE) -C libstrophe libstrophe: libstrophe/.libs/libstrophe.a diff --git a/slack-command.c b/slack-command.c index b2dd04d..201ff4d 100644 --- a/slack-command.c +++ b/slack-command.c @@ -307,7 +307,7 @@ int slack_command_slack(const void *pointer, void *data, struct t_gui_buffer *buffer, int argc, char **argv, char **argv_eol) { - /* make C compiler happy */ + (void) pointer; (void) data; (void) buffer; @@ -353,7 +353,7 @@ int slack_command_me(const void *pointer, void *data, struct t_slack_request *request; char *text; - /* make C compiler happy */ + (void) pointer; (void) data; (void) buffer; diff --git a/slack-completion.c b/slack-completion.c index 1002e0c..c8c6e80 100644 --- a/slack-completion.c +++ b/slack-completion.c @@ -54,7 +54,7 @@ int slack_completion_channel_nicks_cb(const void *pointer, void *data, struct t_slack_channel_member *ptr_member; struct t_slack_user *ptr_user; - /* make C compiler happy */ + (void) pointer; (void) data; (void) completion_item; @@ -108,7 +108,7 @@ int slack_completion_workspaces_cb(const void *pointer, void *data, { struct t_slack_workspace *ptr_workspace; - /* make C compiler happy */ + (void) pointer; (void) data; (void) completion_item; diff --git a/slack-config.h b/slack-config.h deleted file mode 100644 index 19d10b3..0000000 --- a/slack-config.h +++ /dev/null @@ -1,57 +0,0 @@ -// This Source Code Form is subject to the terms of the Mozilla Public -// License, version 2.0. If a copy of the MPL was not distributed with this -// file, You can obtain one at http://mozilla.org/MPL/2.0/. - -#ifndef _SLACK_CONFIG_H_ -#define _SLACK_CONFIG_H_ - -#define SLACK_CONFIG_NAME "slack" - -enum t_slack_config_nick_completion -{ - SLACK_CONFIG_NICK_COMPLETION_SMART_OFF = 0, - SLACK_CONFIG_NICK_COMPLETION_SMART_SPEAKERS, - SLACK_CONFIG_NICK_COMPLETION_SMART_SPEAKERS_HIGHLIGHTS, -}; - -extern struct t_config_file *slack_config_file; - -extern struct t_config_section *slack_config_section_workspace_default; -extern struct t_config_section *slack_config_section_workspace; - -extern struct t_config_option *slack_config_look_nick_completion_smart; - -extern struct t_config_option *slack_config_workspace_default[]; - -int slack_config_workspace_check_value_cb(const void *pointer, void *data, - struct t_config_option *option, - const char *value); - -void slack_config_workspace_change_cb(const void *pointer, void *data, - struct t_config_option *option); - -struct t_config_option *slack_config_workspace_new_option (struct t_config_file *config_file, - struct t_config_section *section, - int index_option, - const char *option_name, - const char *default_value, - const char *value, - int null_value_allowed, - int (*callback_check_value)(const void *pointer, - void *data, - struct t_config_option *option, - const char *value), - const void *callback_check_value_pointer, - void *callback_check_value_data, - void (*callback_change)(const void *pointer, - void *data, - struct t_config_option *option), - const void *callback_change_pointer, - void *callback_change_data); - -extern int slack_config_init(); -extern int slack_config_read(); -extern int slack_config_write(); -extern void slack_config_free(); - -#endif /*SLACK_CONFIG_H*/ diff --git a/slack-workspace.c b/slack-workspace.c index 23228fe..358cb24 100644 --- a/slack-workspace.c +++ b/slack-workspace.c @@ -823,7 +823,7 @@ int slack_workspace_timer_cb(const void *pointer, void *data, int remaining_call struct t_slack_workspace *ptr_workspace; struct t_slack_request *ptr_request; - /* make C compiler happy */ + (void) pointer; (void) data; (void) remaining_calls; diff --git a/slack-config.c b/xmpp-config.c similarity index 51% rename from slack-config.c rename to xmpp-config.c index 62d125e..5783fdf 100644 --- a/slack-config.c +++ b/xmpp-config.c @@ -4,33 +4,36 @@ #include #include +#include +#include -#include "weechat-plugin.h" -#include "slack.h" -#include "slack-config.h" -#include "slack-workspace.h" +#include "xmpp.h" +#include "xmpp-config.h" -struct t_config_file *slack_config_file; +struct t_config_file *xmpp_config_file; -struct t_config_section *slack_config_section_workspace_default; -struct t_config_section *slack_config_section_workspace; +//struct t_config_section *xmpp_config_section_workspace_default; +//struct t_config_section *xmpp_config_section_workspace; -struct t_config_option *slack_config_look_nick_completion_smart; +struct t_config_option *xmpp_config_serverdef_jid; +struct t_config_option *xmpp_config_serverdef_password; +struct t_config_option *xmpp_config_look_nick_completion_smart; -struct t_config_option *slack_config_workspace_default[SLACK_WORKSPACE_NUM_OPTIONS]; +/* +struct t_config_option *xmpp_config_workspace_default[XMPP_WORKSPACE_NUM_OPTIONS]; -int slack_config_workspace_check_value_cb(const void *pointer, void *data, - struct t_config_option *option, +int xmpp_config_workspace_check_value_cb(const void *pointer, void *data, + struct t_config_option *option, const char *value) { (void) pointer; (void) data; (void) option; (void) value; - return 1; + return 1; } -void slack_config_workspace_change_cb(const void *pointer, void *data, +void xmpp_config_workspace_change_cb(const void *pointer, void *data, struct t_config_option *option) { (void) pointer; @@ -38,7 +41,7 @@ void slack_config_workspace_change_cb(const void *pointer, void *data, (void) option; } -void slack_config_workspace_default_change_cb(const void *pointer, void *data, +void xmpp_config_workspace_default_change_cb(const void *pointer, void *data, struct t_config_option *option) { (void) pointer; @@ -47,7 +50,7 @@ void slack_config_workspace_default_change_cb(const void *pointer, void *data, } struct t_config_option * -slack_config_workspace_new_option (struct t_config_file *config_file, +xmpp_config_workspace_new_option (struct t_config_file *config_file, struct t_config_section *section, int index_option, const char *option_name, @@ -66,17 +69,17 @@ slack_config_workspace_new_option (struct t_config_file *config_file, const void *callback_change_pointer, void *callback_change_data) { - struct t_config_option *new_option; + struct t_config_option *new_option; new_option = NULL; switch (index_option) { - case SLACK_WORKSPACE_OPTION_TOKEN: + case XMPP_WORKSPACE_OPTION_TOKEN: new_option = weechat_config_new_option ( config_file, section, option_name, "string", - N_("slack api token"), + N_("xmpp api token"), NULL, 0, 0, default_value, value, null_value_allowed, @@ -88,62 +91,47 @@ slack_config_workspace_new_option (struct t_config_file *config_file, callback_change_data, NULL, NULL, NULL); break; - case SLACK_WORKSPACE_NUM_OPTIONS: + case XMPP_WORKSPACE_NUM_OPTIONS: break; } return new_option; } -void slack_config_workspace_create_default_options(struct t_config_section *section) +void xmpp_config_workspace_create_default_options(struct t_config_section *section) { int i; - for (i = 0; i < SLACK_WORKSPACE_NUM_OPTIONS; i++) - { - slack_config_workspace_default[i] = slack_config_workspace_new_option( - slack_config_file, - section, - i, - slack_workspace_options[i][0], - slack_workspace_options[i][1], - slack_workspace_options[i][1], - 0, - &slack_config_workspace_check_value_cb, - slack_workspace_options[i][0], - NULL, - &slack_config_workspace_default_change_cb, - slack_workspace_options[i][0], - NULL); - } -} - -int slack_config_reload (const void *pointer, void *data, - struct t_config_file *config_file) -{ - /* make C compiler happy */ - (void) pointer; - (void) data; - - //weechat_config_section_free_options(slack_config_section_workspace_default); - //weechat_config_section_free_options(slack_config_section_workspace); - //slack_workspace_free_all(); - - return weechat_config_reload(config_file); + for (i = 0; i < XMPP_WORKSPACE_NUM_OPTIONS; i++) + { + xmpp_config_workspace_default[i] = xmpp_config_workspace_new_option( + xmpp_config_file, + section, + i, + xmpp_workspace_options[i][0], + xmpp_workspace_options[i][1], + xmpp_workspace_options[i][1], + 0, + &xmpp_config_workspace_check_value_cb, + xmpp_workspace_options[i][0], + NULL, + &xmpp_config_workspace_default_change_cb, + xmpp_workspace_options[i][0], + NULL); + } } -int slack_config_workspace_read_cb (const void *pointer, void *data, +int xmpp_config_workspace_read_cb (const void *pointer, void *data, struct t_config_file *config_file, struct t_config_section *section, const char *option_name, const char *value) { - struct t_slack_workspace *ptr_workspace; + struct t_xmpp_workspace *ptr_workspace; int index_option, rc, i; char *pos_option, *workspace_domain; - /* make C compiler happy */ (void) pointer; (void) data; (void) config_file; @@ -161,18 +149,18 @@ int slack_config_workspace_read_cb (const void *pointer, void *data, pos_option++; if (workspace_domain) { - index_option = slack_workspace_search_option(pos_option); + index_option = xmpp_workspace_search_option(pos_option); if (index_option >= 0) { - ptr_workspace = slack_workspace_search(workspace_domain); + ptr_workspace = xmpp_workspace_search(workspace_domain); if (!ptr_workspace) - ptr_workspace = slack_workspace_alloc(workspace_domain); + ptr_workspace = xmpp_workspace_alloc(workspace_domain); if (ptr_workspace) { if (ptr_workspace->reloading_from_config && !ptr_workspace->reloaded_from_config) { - for (i = 0; i < SLACK_WORKSPACE_NUM_OPTIONS; i++) + for (i = 0; i < XMPP_WORKSPACE_NUM_OPTIONS; i++) { weechat_config_option_set( ptr_workspace->options[i], NULL, 1); @@ -187,7 +175,7 @@ int slack_config_workspace_read_cb (const void *pointer, void *data, weechat_printf( NULL, _("%s%s: error adding workspace \"%s\""), - weechat_prefix("error"), SLACK_PLUGIN_NAME, + weechat_prefix("error"), XMPP_PLUGIN_NAME, workspace_domain); } } @@ -201,30 +189,29 @@ int slack_config_workspace_read_cb (const void *pointer, void *data, weechat_printf( NULL, _("%s%s: error creating workspace option \"%s\""), - weechat_prefix("error"), SLACK_PLUGIN_NAME, option_name); + weechat_prefix("error"), XMPP_PLUGIN_NAME, option_name); } return rc; } -int slack_config_workspace_write_cb (const void *pointer, void *data, +int xmpp_config_workspace_write_cb (const void *pointer, void *data, struct t_config_file *config_file, const char *section_name) { - struct t_slack_workspace *ptr_workspace; + struct t_xmpp_workspace *ptr_workspace; int i; - /* make C compiler happy */ (void) pointer; (void) data; if (!weechat_config_write_line(config_file, section_name, NULL)) return WEECHAT_CONFIG_WRITE_ERROR; - for (ptr_workspace = slack_workspaces; ptr_workspace; + for (ptr_workspace = xmpp_workspaces; ptr_workspace; ptr_workspace = ptr_workspace->next_workspace) { - for (i = 0; i < SLACK_WORKSPACE_NUM_OPTIONS; i++) + for (i = 0; i < XMPP_WORKSPACE_NUM_OPTIONS; i++) { if (!weechat_config_write_option(config_file, ptr_workspace->options[i])) @@ -234,19 +221,35 @@ int slack_config_workspace_write_cb (const void *pointer, void *data, return WEECHAT_CONFIG_WRITE_OK; } +*/ + +int xmpp_config_reload (const void *pointer, void *data, + struct t_config_file *config_file) +{ + (void) pointer; + (void) data; + + //weechat_config_section_free_options(xmpp_config_section_workspace_default); + //weechat_config_section_free_options(xmpp_config_section_workspace); + //xmpp_workspace_free_all(); + + return weechat_config_reload(config_file); +} -int slack_config_init() +int xmpp_config_init() { - struct t_config_section *ptr_section; + struct t_config_section *ptr_section_serverdef; + struct t_config_section *ptr_section_server; + struct t_config_section *ptr_section_look; - slack_config_file = weechat_config_new(SLACK_CONFIG_NAME, - &slack_config_reload, NULL, NULL); + xmpp_config_file = weechat_config_new(XMPP_CONFIG_NAME, + &xmpp_config_reload, NULL, NULL); - if(!slack_config_file) + if(!xmpp_config_file) return 0; - ptr_section = weechat_config_new_section( - slack_config_file, "look", + ptr_section_serverdef = weechat_config_new_section( + xmpp_config_file, "server_default", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, @@ -254,24 +257,17 @@ int slack_config_init() NULL, NULL, NULL, NULL, NULL, NULL); - if (!ptr_section) - { - weechat_config_free(slack_config_file); - slack_config_file = NULL; - return 0; - } - - slack_config_look_nick_completion_smart = weechat_config_new_option ( - slack_config_file, ptr_section, - "nick_completion_smart", "integer", - N_("smart completion for nicks (completes first with last speakers): " - "speakers = all speakers (including highlights), " - "speakers_highlights = only speakers with highlight"), - "off|speakers|speakers_highlights", 0, 0, "speakers", NULL, 0, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); + ptr_section_server = weechat_config_new_section( + xmpp_config_file, "server", + 0, 0, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL, + NULL, NULL, NULL); - ptr_section = weechat_config_new_section( - slack_config_file, "workspace_default", + ptr_section_look = weechat_config_new_section( + xmpp_config_file, "look", 0, 0, NULL, NULL, NULL, NULL, NULL, NULL, @@ -279,52 +275,93 @@ int slack_config_init() NULL, NULL, NULL, NULL, NULL, NULL); - if (!ptr_section) + if (!ptr_section_serverdef + || !ptr_section_server + || !ptr_section_look) { - weechat_config_free(slack_config_file); - slack_config_file = NULL; + weechat_config_free(xmpp_config_file); + xmpp_config_file = NULL; return 0; } - slack_config_section_workspace_default = ptr_section; - - slack_config_workspace_create_default_options(ptr_section); + xmpp_config_serverdef_jid = weechat_config_new_option ( + xmpp_config_file, ptr_section_serverdef, + "jid", "string", + N_("XMPP Server JID"), + NULL, 0, 0, "", "", 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); - ptr_section = weechat_config_new_section( - slack_config_file, "workspace", - 0, 0, - &slack_config_workspace_read_cb, NULL, NULL, - &slack_config_workspace_write_cb, NULL, NULL, - NULL, NULL, NULL, - NULL, NULL, NULL, - NULL, NULL, NULL); + xmpp_config_serverdef_password = weechat_config_new_option ( + xmpp_config_file, ptr_section_serverdef, + "password", "string", + N_("XMPP Server Password"), + NULL, 0, 0, "", "", 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); - if (!ptr_section) - { - weechat_config_free(slack_config_file); - slack_config_file = NULL; - return 0; - } + xmpp_config_look_nick_completion_smart = weechat_config_new_option ( + xmpp_config_file, ptr_section_look, + "nick_completion_smart", "integer", + N_("smart completion for nicks (completes first with last speakers): " + "speakers = all speakers (including highlights), " + "speakers_highlights = only speakers with highlight"), + "off|speakers|speakers_highlights", 0, 0, "speakers", NULL, 0, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); - slack_config_section_workspace = ptr_section; + //ptr_section = weechat_config_new_section( + // xmpp_config_file, "workspace_default", + // 0, 0, + // NULL, NULL, NULL, + // NULL, NULL, NULL, + // NULL, NULL, NULL, + // NULL, NULL, NULL, + // NULL, NULL, NULL); + + //if (!ptr_section) + //{ + // weechat_config_free(xmpp_config_file); + // xmpp_config_file = NULL; + // return 0; + //} + + //xmpp_config_section_workspace_default = ptr_section; + + //xmpp_config_workspace_create_default_options(ptr_section); + + // ptr_section = weechat_config_new_section( + // xmpp_config_file, "workspace", + // 0, 0, + // &xmpp_config_workspace_read_cb, NULL, NULL, + // &xmpp_config_workspace_write_cb, NULL, NULL, + // NULL, NULL, NULL, + // NULL, NULL, NULL, + // NULL, NULL, NULL); + + //if (!ptr_section) + //{ + // weechat_config_free(xmpp_config_file); + // xmpp_config_file = NULL; + // return 0; + //} + + //xmpp_config_section_workspace = ptr_section; return 1; } -int slack_config_read() +int xmpp_config_read() { - int rc; + int rc; - rc = weechat_config_read(slack_config_file); + rc = weechat_config_read(xmpp_config_file); return rc; } -int slack_config_write() +int xmpp_config_write() { - return weechat_config_write(slack_config_file); + return weechat_config_write(xmpp_config_file); } -void slack_config_free() +void xmpp_config_free() { } diff --git a/xmpp-config.h b/xmpp-config.h new file mode 100644 index 0000000..c514960 --- /dev/null +++ b/xmpp-config.h @@ -0,0 +1,59 @@ +// This Source Code Form is subject to the terms of the Mozilla Public +// License, version 2.0. If a copy of the MPL was not distributed with this +// file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#ifndef _XMPP_CONFIG_H_ +#define _XMPP_CONFIG_H_ + +#define XMPP_CONFIG_NAME "xmpp" + +enum t_xmpp_config_nick_completion +{ + XMPP_CONFIG_NICK_COMPLETION_SMART_OFF = 0, + XMPP_CONFIG_NICK_COMPLETION_SMART_SPEAKERS, + XMPP_CONFIG_NICK_COMPLETION_SMART_SPEAKERS_HIGHLIGHTS, +}; + +extern struct t_config_file *xmpp_config_file; + +//extern struct t_config_section *xmpp_config_section_workspace_default; +//extern struct t_config_section *xmpp_config_section_workspace; + +extern struct t_config_option *xmpp_config_serverdef_jid; +extern struct t_config_option *xmpp_config_serverdef_password; +extern struct t_config_option *xmpp_config_look_nick_completion_smart; + +//extern struct t_config_option *xmpp_config_workspace_default[]; + +//int xmpp_config_workspace_check_value_cb(const void *pointer, void *data, +// struct t_config_option *option, +// const char *value); + +//void xmpp_config_workspace_change_cb(const void *pointer, void *data, +// struct t_config_option *option); + +//struct t_config_option *xmpp_config_workspace_new_option (struct t_config_file *config_file, +// struct t_config_section *section, +// int index_option, +// const char *option_name, +// const char *default_value, +// const char *value, +// int null_value_allowed, +// int (*callback_check_value)(const void *pointer, +// void *data, +// struct t_config_option *option, +// const char *value), +// const void *callback_check_value_pointer, +// void *callback_check_value_data, +// void (*callback_change)(const void *pointer, +// void *data, +// struct t_config_option *option), +// const void *callback_change_pointer, +// void *callback_change_data); + +extern int xmpp_config_init(); +extern int xmpp_config_read(); +extern int xmpp_config_write(); +extern void xmpp_config_free(); + +#endif /*XMPP_CONFIG_H*/ diff --git a/xmpp.c b/xmpp.c index d9ce258..7e5974e 100644 --- a/xmpp.c +++ b/xmpp.c @@ -7,10 +7,10 @@ #include #include #include +#include -#include "weechat/weechat-plugin.h" #include "xmpp.h" -//#include "slack-config.h" +#include "xmpp-config.h" //#include "slack-command.h" //#include "slack-workspace.h" //#include "slack-api.h" @@ -31,34 +31,47 @@ struct t_hook *xmpp_hook_timer = NULL; struct t_gui_bar_item *xmpp_typing_bar_item = NULL; -void xmpp_lwsl_emit_weechat(int level, const char *line) +xmpp_ctx_t *xmpp_context = NULL; + +xmpp_conn_t *xmpp_connection = NULL; + +void xmpp_log_emit_weechat(void *const userdata, const xmpp_log_level_t level, const char *const area, const char *const msg) { - char buf[50]; - //lwsl_timestamp(level, buf, sizeof(buf)); + (void) userdata; + time_t date = time(NULL); + const char *timestamp = weechat_util_get_time_string(&date); weechat_printf( NULL, - _("%s%s: %s%s"), + _("%s%s %d | %s: %s - %s"), weechat_prefix("error"), XMPP_PLUGIN_NAME, - buf, line); + level, timestamp, area, msg); } +xmpp_log_t xmpp_logger = { + &xmpp_log_emit_weechat, + NULL +}; + int weechat_plugin_init(struct t_weechat_plugin *plugin, int argc, char *argv[]) { - (void) argc; - (void) argv; + (void) argc; + (void) argv; weechat_plugin = plugin; - //lws_set_log_level(LLL_ERR | LLL_WARN /*| LLL_NOTICE | LLL_INFO | LLL_DEBUG - // | LLL_PARSER | LLL_HEADER | LLL_EXT | LLL_CLIENT - // | LLL_LATENCY | LLL_USER | LLL_COUNT*/, - // xmpp_lwsl_emit_weechat); + if (!xmpp_config_init()) + return WEECHAT_RC_ERROR; - //if (!xmpp_config_init()) - // return WEECHAT_RC_ERROR; + xmpp_config_read(); - //xmpp_config_read(); + xmpp_initialize(); + xmpp_context = xmpp_ctx_new(NULL, &xmpp_logger); + xmpp_connection = xmpp_conn_new(xmpp_context); + xmpp_conn_set_jid(xmpp_connection, + weechat_config_string(xmpp_config_serverdef_jid)); + xmpp_conn_set_pass(xmpp_connection, + weechat_config_string(xmpp_config_serverdef_password)); //xmpp_command_init(); @@ -87,7 +100,7 @@ int weechat_plugin_init(struct t_weechat_plugin *plugin, int argc, char *argv[]) int weechat_plugin_end(struct t_weechat_plugin *plugin) { - /* make C compiler happy */ + // make C compiler happy (void) plugin; if (xmpp_typing_bar_item) @@ -96,11 +109,13 @@ int weechat_plugin_end(struct t_weechat_plugin *plugin) if (xmpp_hook_timer) weechat_unhook(xmpp_hook_timer); - //xmpp_config_write(); + xmpp_config_write(); + + xmpp_conn_release(xmpp_connection); - //xmpp_workspace_disconnect_all(); + xmpp_ctx_free(xmpp_context); - //xmpp_workspace_free_all(); + xmpp_shutdown(); return WEECHAT_RC_OK; }