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.
90 lines
2.3 KiB
C++
90 lines
2.3 KiB
C++
4 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 <strophe.h>
|
||
|
#include <stdlib.h>
|
||
3 years ago
|
#include <stdint.h>
|
||
4 years ago
|
#include <weechat/weechat-plugin.h>
|
||
|
|
||
3 years ago
|
#include "plugin.hh"
|
||
3 years ago
|
#include "account.hh"
|
||
|
#include "channel.hh"
|
||
3 years ago
|
#include "buffer.hh"
|
||
|
#include "message.hh"
|
||
|
#include "input.hh"
|
||
4 years ago
|
|
||
|
int input__data(struct t_gui_buffer *buffer, const char *text)
|
||
|
{
|
||
|
struct t_account *account = NULL;
|
||
|
struct t_channel *channel = NULL;
|
||
|
|
||
|
buffer__get_account_and_channel(buffer, &account, &channel);
|
||
|
|
||
|
if (!account)
|
||
|
return WEECHAT_RC_ERROR;
|
||
|
|
||
|
if (channel)
|
||
|
{
|
||
|
if (!account->is_connected)
|
||
|
{
|
||
|
weechat_printf(buffer,
|
||
|
_("%s%s: you are not connected to server"),
|
||
|
weechat_prefix("error"), WEECHAT_XMPP_PLUGIN_NAME);
|
||
|
return WEECHAT_RC_OK;
|
||
|
}
|
||
|
|
||
3 years ago
|
if (channel__send_message(account, channel, channel->id, text) == WEECHAT_RC_OK)
|
||
|
return WEECHAT_RC_OK;
|
||
|
else
|
||
|
{
|
||
|
return WEECHAT_RC_OK_EAT;
|
||
|
}
|
||
4 years ago
|
}
|
||
|
else
|
||
|
{
|
||
|
weechat_printf(buffer,
|
||
|
_("%s%s: this buffer is not a channel!"),
|
||
|
weechat_prefix("error"), WEECHAT_XMPP_PLUGIN_NAME);
|
||
3 years ago
|
return WEECHAT_RC_OK;
|
||
4 years ago
|
}
|
||
|
}
|
||
|
|
||
|
int input__data_cb(const void *pointer, void *data,
|
||
3 years ago
|
struct t_gui_buffer *buffer,
|
||
|
const char *text)
|
||
4 years ago
|
{
|
||
|
(void) pointer;
|
||
|
(void) data;
|
||
|
|
||
|
return input__data(buffer, text);
|
||
|
}
|
||
3 years ago
|
|
||
|
int input__typing(struct t_gui_buffer *buffer)
|
||
|
{
|
||
|
struct t_account *account = NULL;
|
||
|
struct t_channel *channel = NULL;
|
||
|
|
||
|
buffer__get_account_and_channel(buffer, &account, &channel);
|
||
|
|
||
|
if (account && account->is_connected && channel)
|
||
|
{
|
||
3 years ago
|
channel__send_reads(account, channel);
|
||
3 years ago
|
channel__send_typing(account, channel, NULL);
|
||
|
}
|
||
|
|
||
|
return WEECHAT_RC_OK;
|
||
|
}
|
||
|
|
||
|
int input__text_changed_cb(const void *pointer, void *data,
|
||
|
const char *signal, const char *type_data,
|
||
|
void *signal_data)
|
||
|
{
|
||
|
(void) pointer;
|
||
|
(void) data;
|
||
|
(void) signal;
|
||
|
(void) type_data;
|
||
|
|
||
3 years ago
|
return input__typing((struct t_gui_buffer*)signal_data);
|
||
3 years ago
|
}
|