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.

91 lines
2.4 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 "account.h"
#include "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 client protocol"));
3 years ago
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;
3 years ago
struct t_hook *weechat_xmpp_process_timer = NULL;
3 years ago
3 years ago
struct t_gui_bar_item *weechat_xmpp_typing_bar_item = NULL;
3 years ago
int weechat_plugin_init(struct t_weechat_plugin *plugin, int argc, char *argv[])
{
3 years ago
(void) argc;
(void) argv;
3 years ago
3 years ago
weechat_xmpp_plugin = plugin;
3 years ago
3 years ago
if (!config__init())
3 years ago
return WEECHAT_RC_ERROR;
3 years ago
3 years ago
config__read();
3 years ago
3 years ago
connection__init();
3 years ago
3 years ago
command__init();
3 years ago
//completion__init();
3 years ago
3 years ago
weechat_xmpp_process_timer = weechat_hook_timer(TIMER_INTERVAL_SEC * 1000, 0, 0,
3 years ago
&account__timer_cb,
NULL, NULL);
3 years ago
if (!weechat_bar_search("typing"))
{
weechat_bar_new("typing", "off", "400", "window", "${typing}",
"bottom", "horizontal", "vertical",
"1", "1", "default", "default", "default", "default",
3 years ago
"off", "xmpp_typing");
}
3 years ago
weechat_xmpp_typing_bar_item = weechat_bar_item_new("xmpp_typing",
&buffer__typing_bar_cb,
NULL, NULL);
3 years ago
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;
3 years ago
if (weechat_xmpp_typing_bar_item)
weechat_bar_item_remove(weechat_xmpp_typing_bar_item);
3 years ago
3 years ago
if (weechat_xmpp_process_timer)
weechat_unhook(weechat_xmpp_process_timer);
3 years ago
3 years ago
config__write();
3 years ago
account__disconnect_all();
3 years ago
3 years ago
account__free_all();
3 years ago
3 years ago
xmpp_shutdown();
3 years ago
return WEECHAT_RC_OK;
}