mirror of https://github.com/bqv/weechat-xmpp
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
103 lines
2.7 KiB
C
103 lines
2.7 KiB
C
3 years ago
|
// 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/.
|
||
|
|
||
|
#include <stdlib.h>
|
||
|
#include <string.h>
|
||
|
#include <time.h>
|
||
|
#include <strophe.h>
|
||
3 years ago
|
#include <weechat/weechat-plugin.h>
|
||
3 years ago
|
|
||
3 years ago
|
#include "plugin.h"
|
||
|
#include "config.h"
|
||
|
#include "connection.h"
|
||
|
#include "command.h"
|
||
3 years ago
|
//#include "xmpp-workspace.h"
|
||
|
//#include "xmpp-buffer.h"
|
||
|
//#include "xmpp-completion.h"
|
||
3 years ago
|
|
||
|
|
||
3 years ago
|
WEECHAT_PLUGIN_NAME(WEECHAT_XMPP_PLUGIN_NAME);
|
||
3 years ago
|
WEECHAT_PLUGIN_DESCRIPTION(N_("XMPP protocol"));
|
||
|
WEECHAT_PLUGIN_AUTHOR("bqv <weechat@fron.io>");
|
||
3 years ago
|
WEECHAT_PLUGIN_VERSION(WEECHAT_XMPP_PLUGIN_VERSION);
|
||
3 years ago
|
WEECHAT_PLUGIN_LICENSE("MPL2");
|
||
|
WEECHAT_PLUGIN_PRIORITY(5500);
|
||
|
|
||
|
struct t_weechat_plugin *weechat_xmpp_plugin = NULL;
|
||
|
|
||
|
struct t_hook *xmpp_hook_timer = NULL;
|
||
|
|
||
|
struct t_gui_bar_item *xmpp_typing_bar_item = NULL;
|
||
|
|
||
|
int weechat_plugin_init(struct t_weechat_plugin *plugin, int argc, char *argv[])
|
||
|
{
|
||
3 years ago
|
(void) argc;
|
||
|
(void) argv;
|
||
3 years ago
|
|
||
|
weechat_plugin = plugin;
|
||
|
|
||
3 years ago
|
if (!xmpp_config_init())
|
||
|
return WEECHAT_RC_ERROR;
|
||
3 years ago
|
|
||
3 years ago
|
xmpp_config_read();
|
||
3 years ago
|
|
||
3 years ago
|
xmpp_connection_init();
|
||
3 years ago
|
|
||
3 years ago
|
xmpp_command_init();
|
||
|
|
||
3 years ago
|
//xmpp_completion_init();
|
||
|
|
||
3 years ago
|
xmpp_hook_timer = weechat_hook_timer(1 * 1000, 0, 1,
|
||
|
&xmpp_connection_autoconnect,
|
||
|
NULL, NULL);
|
||
|
|
||
|
xmpp_hook_timer = weechat_hook_timer(0.1 * 1000, 0, 0,
|
||
|
&xmpp_connection_check_events,
|
||
|
NULL, NULL);
|
||
3 years ago
|
|
||
|
if (!weechat_bar_search("typing"))
|
||
|
{
|
||
|
weechat_bar_new("typing", "off", "400", "window", "${typing}",
|
||
|
"bottom", "horizontal", "vertical",
|
||
3 years ago
|
"1", "1", "default", "default", "default", "default",
|
||
3 years ago
|
"off", "xmpp_typing");
|
||
|
}
|
||
|
|
||
|
//xmpp_typing_bar_item = weechat_bar_item_new("xmpp_typing",
|
||
|
// &xmpp_buffer_typing_bar_cb,
|
||
|
// NULL, NULL);
|
||
|
|
||
|
return WEECHAT_RC_OK;
|
||
|
}
|
||
|
|
||
|
int weechat_plugin_end(struct t_weechat_plugin *plugin)
|
||
|
{
|
||
3 years ago
|
// make C compiler happy
|
||
3 years ago
|
(void) plugin;
|
||
|
|
||
|
if (xmpp_typing_bar_item)
|
||
|
weechat_bar_item_remove(xmpp_typing_bar_item);
|
||
|
|
||
|
if (xmpp_hook_timer)
|
||
|
weechat_unhook(xmpp_hook_timer);
|
||
|
|
||
3 years ago
|
xmpp_config_write();
|
||
|
|
||
3 years ago
|
if (xmpp_connection)
|
||
|
{
|
||
|
xmpp_ctx_t *xmpp_context = xmpp_conn_get_context(xmpp_connection);
|
||
|
|
||
|
if (xmpp_conn_is_connected(xmpp_connection))
|
||
|
xmpp_disconnect(xmpp_connection);
|
||
3 years ago
|
|
||
3 years ago
|
xmpp_conn_release(xmpp_connection);
|
||
|
|
||
|
xmpp_ctx_free(xmpp_context);
|
||
|
}
|
||
3 years ago
|
|
||
3 years ago
|
xmpp_shutdown();
|
||
3 years ago
|
|
||
|
return WEECHAT_RC_OK;
|
||
|
}
|