|
|
@ -10,29 +10,61 @@
|
|
|
|
#include <strophe.h>
|
|
|
|
#include <strophe.h>
|
|
|
|
|
|
|
|
|
|
|
|
#include "plugin.h"
|
|
|
|
#include "plugin.h"
|
|
|
|
#include "omemo.h"
|
|
|
|
|
|
|
|
#include "account.h"
|
|
|
|
#include "account.h"
|
|
|
|
|
|
|
|
#include "omemo.h"
|
|
|
|
#include "user.h"
|
|
|
|
#include "user.h"
|
|
|
|
#include "channel.h"
|
|
|
|
#include "channel.h"
|
|
|
|
#include "input.h"
|
|
|
|
#include "input.h"
|
|
|
|
#include "buffer.h"
|
|
|
|
#include "buffer.h"
|
|
|
|
#include "pgp.h"
|
|
|
|
#include "pgp.h"
|
|
|
|
|
|
|
|
#include "util.h"
|
|
|
|
|
|
|
|
|
|
|
|
const char *channel__transport_name(enum t_channel_transport transport)
|
|
|
|
const char *channel__transport_name(enum t_channel_transport transport)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
switch (transport)
|
|
|
|
switch (transport)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
case CHANNEL_TRANSPORT_PLAINTEXT:
|
|
|
|
case CHANNEL_TRANSPORT_PLAIN:
|
|
|
|
return "PLAINTEXT";
|
|
|
|
return "PLAINTEXT";
|
|
|
|
case CHANNEL_TRANSPORT_OMEMO:
|
|
|
|
case CHANNEL_TRANSPORT_OMEMO:
|
|
|
|
return "OMEMO";
|
|
|
|
return "OMEMO";
|
|
|
|
case CHANNEL_TRANSPORT_PGP:
|
|
|
|
case CHANNEL_TRANSPORT_PGP:
|
|
|
|
return "PGP";
|
|
|
|
return "PGP";
|
|
|
|
|
|
|
|
case CHANNEL_TRANSPORT_OTR:
|
|
|
|
|
|
|
|
return "OTR";
|
|
|
|
default:
|
|
|
|
default:
|
|
|
|
return NULL;
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void channel__set_transport(struct t_channel *channel, enum t_channel_transport transport, int force)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (force)
|
|
|
|
|
|
|
|
switch (transport)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
case CHANNEL_TRANSPORT_PLAIN:
|
|
|
|
|
|
|
|
channel->omemo.enabled = 0;
|
|
|
|
|
|
|
|
channel->pgp.enabled = 0;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CHANNEL_TRANSPORT_OMEMO:
|
|
|
|
|
|
|
|
channel->omemo.enabled = 1;
|
|
|
|
|
|
|
|
channel->pgp.enabled = 0;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case CHANNEL_TRANSPORT_PGP:
|
|
|
|
|
|
|
|
channel->omemo.enabled = 0;
|
|
|
|
|
|
|
|
channel->pgp.enabled = 1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (channel->transport != transport)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
channel->transport = transport;
|
|
|
|
|
|
|
|
weechat_printf_date_tags(channel->buffer, 0, NULL, "%s%sTransport: %s",
|
|
|
|
|
|
|
|
weechat_prefix("network"), weechat_color("gray"),
|
|
|
|
|
|
|
|
channel__transport_name(channel->transport));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
struct t_account *channel__account(struct t_channel *channel)
|
|
|
|
struct t_account *channel__account(struct t_channel *channel)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct t_account *ptr_account;
|
|
|
|
struct t_account *ptr_account;
|
|
|
@ -80,7 +112,7 @@ struct t_gui_buffer *channel__search_buffer(struct t_account *account,
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct t_hdata *hdata_buffer;
|
|
|
|
struct t_hdata *hdata_buffer;
|
|
|
|
struct t_gui_buffer *ptr_buffer;
|
|
|
|
struct t_gui_buffer *ptr_buffer;
|
|
|
|
const char *ptr_type, *ptr_account_name, *ptr_channel_name;
|
|
|
|
const char *ptr_type, *ptr_account_name, *ptr_remote_jid;
|
|
|
|
|
|
|
|
|
|
|
|
hdata_buffer = weechat_hdata_get("buffer");
|
|
|
|
hdata_buffer = weechat_hdata_get("buffer");
|
|
|
|
ptr_buffer = weechat_hdata_get_list(hdata_buffer, "gui_buffers");
|
|
|
|
ptr_buffer = weechat_hdata_get_list(hdata_buffer, "gui_buffers");
|
|
|
@ -91,18 +123,18 @@ struct t_gui_buffer *channel__search_buffer(struct t_account *account,
|
|
|
|
{
|
|
|
|
{
|
|
|
|
ptr_type = weechat_buffer_get_string(ptr_buffer, "localvar_type");
|
|
|
|
ptr_type = weechat_buffer_get_string(ptr_buffer, "localvar_type");
|
|
|
|
ptr_account_name = weechat_buffer_get_string(ptr_buffer,
|
|
|
|
ptr_account_name = weechat_buffer_get_string(ptr_buffer,
|
|
|
|
"localvar_server");
|
|
|
|
"localvar_account");
|
|
|
|
ptr_channel_name = weechat_buffer_get_string(ptr_buffer,
|
|
|
|
ptr_remote_jid = weechat_buffer_get_string(ptr_buffer,
|
|
|
|
"localvar_channel");
|
|
|
|
"localvar_remote_jid");
|
|
|
|
if (ptr_type && ptr_type[0]
|
|
|
|
if (ptr_type && ptr_type[0]
|
|
|
|
&& ptr_account_name && ptr_account_name[0]
|
|
|
|
&& ptr_account_name && ptr_account_name[0]
|
|
|
|
&& ptr_channel_name && ptr_channel_name[0]
|
|
|
|
&& ptr_remote_jid && ptr_remote_jid[0]
|
|
|
|
&& ( (( (type == CHANNEL_TYPE_MUC))
|
|
|
|
&& ( (( (type == CHANNEL_TYPE_MUC))
|
|
|
|
&& (strcmp(ptr_type, "channel") == 0))
|
|
|
|
&& (strcmp(ptr_type, "room") == 0))
|
|
|
|
|| (( (type == CHANNEL_TYPE_PM))
|
|
|
|
|| (( (type == CHANNEL_TYPE_PM))
|
|
|
|
&& (strcmp(ptr_type, "private") == 0)))
|
|
|
|
&& (strcmp(ptr_type, "private") == 0)))
|
|
|
|
&& (strcmp(ptr_account_name, account->name) == 0)
|
|
|
|
&& (strcmp(ptr_account_name, account->name) == 0)
|
|
|
|
&& (weechat_strcasecmp(ptr_channel_name, name) == 0))
|
|
|
|
&& (weechat_strcasecmp(ptr_remote_jid, name) == 0))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return ptr_buffer;
|
|
|
|
return ptr_buffer;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -119,13 +151,13 @@ struct t_gui_buffer *channel__create_buffer(struct t_account *account,
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct t_gui_buffer *ptr_buffer;
|
|
|
|
struct t_gui_buffer *ptr_buffer;
|
|
|
|
int buffer_created;
|
|
|
|
int buffer_created;
|
|
|
|
const char *short_name, *localvar_channel;
|
|
|
|
const char *short_name, *localvar_remote_jid;
|
|
|
|
char buffer_name[256];
|
|
|
|
char buffer_name[1024];
|
|
|
|
|
|
|
|
|
|
|
|
buffer_created = 0;
|
|
|
|
buffer_created = 0;
|
|
|
|
|
|
|
|
|
|
|
|
snprintf(buffer_name, sizeof(buffer_name),
|
|
|
|
snprintf(buffer_name, sizeof(buffer_name),
|
|
|
|
"xmpp.%s.%s", account->name, name);
|
|
|
|
"%s.%s", account->name, name);
|
|
|
|
|
|
|
|
|
|
|
|
ptr_buffer = channel__search_buffer(account, type, name);
|
|
|
|
ptr_buffer = channel__search_buffer(account, type, name);
|
|
|
|
if (ptr_buffer)
|
|
|
|
if (ptr_buffer)
|
|
|
@ -145,17 +177,19 @@ struct t_gui_buffer *channel__create_buffer(struct t_account *account,
|
|
|
|
|
|
|
|
|
|
|
|
if (buffer_created)
|
|
|
|
if (buffer_created)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
char *res = strrchr(name, '/');
|
|
|
|
if (!weechat_buffer_get_integer(ptr_buffer, "short_name_is_set"))
|
|
|
|
if (!weechat_buffer_get_integer(ptr_buffer, "short_name_is_set"))
|
|
|
|
weechat_buffer_set(ptr_buffer, "short_name", name);
|
|
|
|
weechat_buffer_set(ptr_buffer, "short_name",
|
|
|
|
|
|
|
|
res ? res + 1 : name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
short_name = weechat_buffer_get_string (ptr_buffer, "short_name");
|
|
|
|
short_name = weechat_buffer_get_string(ptr_buffer, "short_name");
|
|
|
|
localvar_channel = weechat_buffer_get_string(ptr_buffer,
|
|
|
|
localvar_remote_jid = weechat_buffer_get_string(ptr_buffer,
|
|
|
|
"localvar_channel");
|
|
|
|
"localvar_remote_jid");
|
|
|
|
|
|
|
|
|
|
|
|
if (!short_name ||
|
|
|
|
if (!short_name ||
|
|
|
|
(localvar_channel && (strcmp(localvar_channel, short_name) == 0)))
|
|
|
|
(localvar_remote_jid && (strcmp(localvar_remote_jid, short_name) == 0)))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
weechat_buffer_set(ptr_buffer, "short_name",
|
|
|
|
weechat_buffer_set(ptr_buffer, "short_name",
|
|
|
|
xmpp_jid_node(account->context, name));
|
|
|
|
xmpp_jid_node(account->context, name));
|
|
|
@ -165,20 +199,21 @@ struct t_gui_buffer *channel__create_buffer(struct t_account *account,
|
|
|
|
account_option_set(account, ACCOUNT_OPTION_NICKNAME,
|
|
|
|
account_option_set(account, ACCOUNT_OPTION_NICKNAME,
|
|
|
|
xmpp_jid_node(account->context, account_jid(account)));
|
|
|
|
xmpp_jid_node(account->context, account_jid(account)));
|
|
|
|
|
|
|
|
|
|
|
|
weechat_buffer_set(ptr_buffer, "name", name);
|
|
|
|
weechat_buffer_set(ptr_buffer, "notify",
|
|
|
|
|
|
|
|
(type == CHANNEL_TYPE_PM) ? "3" : "1");
|
|
|
|
weechat_buffer_set(ptr_buffer, "localvar_set_type",
|
|
|
|
weechat_buffer_set(ptr_buffer, "localvar_set_type",
|
|
|
|
(type == CHANNEL_TYPE_PM) ? "private" : "channel");
|
|
|
|
(type == CHANNEL_TYPE_PM) ? "private" : "channel");
|
|
|
|
weechat_buffer_set(ptr_buffer, "localvar_set_nick",
|
|
|
|
weechat_buffer_set(ptr_buffer, "localvar_set_nick",
|
|
|
|
account_nickname(account));
|
|
|
|
account_nickname(account));
|
|
|
|
weechat_buffer_set(ptr_buffer, "localvar_set_server", account->name);
|
|
|
|
weechat_buffer_set(ptr_buffer, "localvar_set_account", account->name);
|
|
|
|
weechat_buffer_set(ptr_buffer, "localvar_set_channel", name);
|
|
|
|
weechat_buffer_set(ptr_buffer, "localvar_set_remote_jid", name);
|
|
|
|
weechat_buffer_set(ptr_buffer, "input_multiline", "1");
|
|
|
|
weechat_buffer_set(ptr_buffer, "input_multiline", "1");
|
|
|
|
|
|
|
|
|
|
|
|
if (buffer_created)
|
|
|
|
if (buffer_created)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
(void) weechat_hook_signal_send ("logger_backlog",
|
|
|
|
(void) weechat_hook_signal_send("logger_backlog",
|
|
|
|
WEECHAT_HOOK_SIGNAL_POINTER,
|
|
|
|
WEECHAT_HOOK_SIGNAL_POINTER,
|
|
|
|
ptr_buffer);
|
|
|
|
ptr_buffer);
|
|
|
|
weechat_buffer_set(ptr_buffer, "input_get_unknown_commands", "1");
|
|
|
|
weechat_buffer_set(ptr_buffer, "input_get_unknown_commands", "1");
|
|
|
|
if (type != CHANNEL_TYPE_PM)
|
|
|
|
if (type != CHANNEL_TYPE_PM)
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -271,8 +306,15 @@ struct t_channel *channel__new(struct t_account *account,
|
|
|
|
new_channel->type = type;
|
|
|
|
new_channel->type = type;
|
|
|
|
new_channel->id = strdup(id);
|
|
|
|
new_channel->id = strdup(id);
|
|
|
|
new_channel->name = strdup(name);
|
|
|
|
new_channel->name = strdup(name);
|
|
|
|
new_channel->transport = CHANNEL_TRANSPORT_PLAINTEXT;
|
|
|
|
new_channel->transport = CHANNEL_TRANSPORT_PLAIN;
|
|
|
|
new_channel->pgp_id = NULL;
|
|
|
|
new_channel->omemo.enabled = type == CHANNEL_TYPE_PM ? 1 : 0;
|
|
|
|
|
|
|
|
new_channel->omemo.devicelist_requests = weechat_hashtable_new(64,
|
|
|
|
|
|
|
|
WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_POINTER, NULL, NULL);
|
|
|
|
|
|
|
|
new_channel->omemo.bundle_requests = weechat_hashtable_new(64,
|
|
|
|
|
|
|
|
WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_POINTER, NULL, NULL);
|
|
|
|
|
|
|
|
new_channel->pgp.enabled = 1;
|
|
|
|
|
|
|
|
new_channel->pgp.id = NULL;
|
|
|
|
|
|
|
|
new_channel->otr.enabled = 0;
|
|
|
|
|
|
|
|
|
|
|
|
new_channel->topic.value = NULL;
|
|
|
|
new_channel->topic.value = NULL;
|
|
|
|
new_channel->topic.creator = NULL;
|
|
|
|
new_channel->topic.creator = NULL;
|
|
|
@ -788,8 +830,8 @@ void channel__free(struct t_account *account,
|
|
|
|
free(channel->id);
|
|
|
|
free(channel->id);
|
|
|
|
if (channel->name)
|
|
|
|
if (channel->name)
|
|
|
|
free(channel->name);
|
|
|
|
free(channel->name);
|
|
|
|
if (channel->pgp_id)
|
|
|
|
if (channel->pgp.id)
|
|
|
|
free(channel->pgp_id);
|
|
|
|
free(channel->pgp.id);
|
|
|
|
if (channel->topic.value)
|
|
|
|
if (channel->topic.value)
|
|
|
|
free(channel->topic.value);
|
|
|
|
free(channel->topic.value);
|
|
|
|
if (channel->topic.creator)
|
|
|
|
if (channel->topic.creator)
|
|
|
@ -914,10 +956,13 @@ struct t_channel_member *channel__add_member(struct t_account *account,
|
|
|
|
user->profile.status_text ? " [" : "",
|
|
|
|
user->profile.status_text ? " [" : "",
|
|
|
|
user->profile.status_text ? user->profile.status_text : "",
|
|
|
|
user->profile.status_text ? user->profile.status_text : "",
|
|
|
|
user->profile.status_text ? "]" : "",
|
|
|
|
user->profile.status_text ? "]" : "",
|
|
|
|
user->profile.pgp_id ? weechat_color("gray") : "",
|
|
|
|
user->profile.pgp_id || user->profile.omemo ? weechat_color("gray") : "",
|
|
|
|
user->profile.pgp_id ? " with PGP:" : "",
|
|
|
|
user->profile.pgp_id || user->profile.omemo ? " with " : "",
|
|
|
|
|
|
|
|
user->profile.pgp_id ? "PGP:" : "",
|
|
|
|
user->profile.pgp_id ? user->profile.pgp_id : "",
|
|
|
|
user->profile.pgp_id ? user->profile.pgp_id : "",
|
|
|
|
user->profile.pgp_id ? weechat_color("reset") : "");
|
|
|
|
user->profile.omemo && user->profile.pgp_id ? " and " : "",
|
|
|
|
|
|
|
|
user->profile.omemo ? "OMEMO" : "",
|
|
|
|
|
|
|
|
user->profile.pgp_id || user->profile.omemo ? weechat_color("reset") : "");
|
|
|
|
|
|
|
|
|
|
|
|
return member;
|
|
|
|
return member;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -983,8 +1028,8 @@ struct t_channel_member *channel__remove_member(struct t_account *account,
|
|
|
|
return member;
|
|
|
|
return member;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void channel__send_message(struct t_account *account, struct t_channel *channel,
|
|
|
|
int channel__send_message(struct t_account *account, struct t_channel *channel,
|
|
|
|
const char *to, const char *body)
|
|
|
|
const char *to, const char *body)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
channel__send_reads(account, channel);
|
|
|
|
channel__send_reads(account, channel);
|
|
|
|
|
|
|
|
|
|
|
@ -997,17 +1042,51 @@ void channel__send_message(struct t_account *account, struct t_channel *channel,
|
|
|
|
xmpp_stanza_set_id(message, id);
|
|
|
|
xmpp_stanza_set_id(message, id);
|
|
|
|
xmpp_free(account->context, id);
|
|
|
|
xmpp_free(account->context, id);
|
|
|
|
|
|
|
|
|
|
|
|
char *url = strstr(body, "http");
|
|
|
|
if (account->omemo && channel->omemo.enabled)
|
|
|
|
if (channel->pgp_id)
|
|
|
|
{
|
|
|
|
|
|
|
|
xmpp_stanza_t *encrypted = omemo__encode(account, to, body);
|
|
|
|
|
|
|
|
if (!encrypted)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
weechat_printf_date_tags(channel->buffer, 0, "notify_none", "%s%s",
|
|
|
|
|
|
|
|
weechat_prefix("error"), "OMEMO Error");
|
|
|
|
|
|
|
|
channel__set_transport(channel, CHANNEL_TRANSPORT_PLAIN, 1);
|
|
|
|
|
|
|
|
xmpp_stanza_release(message);
|
|
|
|
|
|
|
|
return WEECHAT_RC_ERROR;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
xmpp_stanza_add_child(message, encrypted);
|
|
|
|
|
|
|
|
xmpp_stanza_release(encrypted);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xmpp_stanza_t *message__encryption = xmpp_stanza_new(account->context);
|
|
|
|
|
|
|
|
xmpp_stanza_set_name(message__encryption, "encryption");
|
|
|
|
|
|
|
|
xmpp_stanza_set_ns(message__encryption, "urn:xmpp:eme:0");
|
|
|
|
|
|
|
|
xmpp_stanza_set_attribute(message__encryption, "namespace",
|
|
|
|
|
|
|
|
"eu.siacs.conversations.axolotl");
|
|
|
|
|
|
|
|
xmpp_stanza_set_attribute(message__encryption, "name", "OMEMO");
|
|
|
|
|
|
|
|
xmpp_stanza_add_child(message, message__encryption);
|
|
|
|
|
|
|
|
xmpp_stanza_release(message__encryption);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xmpp_message_set_body(message, OMEMO_ADVICE);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
channel__set_transport(channel, CHANNEL_TRANSPORT_OMEMO, 0);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (channel->pgp.enabled && channel->pgp.id)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
xmpp_stanza_t *message__x = xmpp_stanza_new(account->context);
|
|
|
|
xmpp_stanza_t *message__x = xmpp_stanza_new(account->context);
|
|
|
|
xmpp_stanza_set_name(message__x, "x");
|
|
|
|
xmpp_stanza_set_name(message__x, "x");
|
|
|
|
xmpp_stanza_set_ns(message__x, "jabber:x:encrypted");
|
|
|
|
xmpp_stanza_set_ns(message__x, "jabber:x:encrypted");
|
|
|
|
|
|
|
|
|
|
|
|
xmpp_stanza_t *message__x__text = xmpp_stanza_new(account->context);
|
|
|
|
xmpp_stanza_t *message__x__text = xmpp_stanza_new(account->context);
|
|
|
|
char *ciphertext = pgp__encrypt(channel->buffer, account->pgp, account_pgp_keyid(account), channel->pgp_id, body);
|
|
|
|
char *ciphertext = pgp__encrypt(channel->buffer, account->pgp, account_pgp_keyid(account), channel->pgp.id, body);
|
|
|
|
if (ciphertext)
|
|
|
|
if (ciphertext)
|
|
|
|
xmpp_stanza_set_text(message__x__text, ciphertext);
|
|
|
|
xmpp_stanza_set_text(message__x__text, ciphertext);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
weechat_printf_date_tags(channel->buffer, 0, "notify_none", "%s%s",
|
|
|
|
|
|
|
|
weechat_prefix("error"), "PGP Error");
|
|
|
|
|
|
|
|
channel__set_transport(channel, CHANNEL_TRANSPORT_PLAIN, 1);
|
|
|
|
|
|
|
|
xmpp_stanza_release(message);
|
|
|
|
|
|
|
|
return WEECHAT_RC_ERROR;
|
|
|
|
|
|
|
|
}
|
|
|
|
free(ciphertext);
|
|
|
|
free(ciphertext);
|
|
|
|
|
|
|
|
|
|
|
|
xmpp_stanza_add_child(message__x, message__x__text);
|
|
|
|
xmpp_stanza_add_child(message__x, message__x__text);
|
|
|
@ -1026,28 +1105,17 @@ void channel__send_message(struct t_account *account, struct t_channel *channel,
|
|
|
|
|
|
|
|
|
|
|
|
xmpp_message_set_body(message, PGP_ADVICE);
|
|
|
|
xmpp_message_set_body(message, PGP_ADVICE);
|
|
|
|
|
|
|
|
|
|
|
|
if (ciphertext && channel->transport != CHANNEL_TRANSPORT_PGP)
|
|
|
|
channel__set_transport(channel, CHANNEL_TRANSPORT_PGP, 0);
|
|
|
|
{
|
|
|
|
|
|
|
|
channel->transport = CHANNEL_TRANSPORT_PGP;
|
|
|
|
|
|
|
|
weechat_printf_date_tags(channel->buffer, 0, NULL, "%s%sTransport: %s",
|
|
|
|
|
|
|
|
weechat_prefix("network"), weechat_color("gray"),
|
|
|
|
|
|
|
|
channel__transport_name(channel->transport));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
xmpp_message_set_body(message, body);
|
|
|
|
xmpp_message_set_body(message, body);
|
|
|
|
|
|
|
|
|
|
|
|
if (channel->transport != CHANNEL_TRANSPORT_PLAINTEXT)
|
|
|
|
channel__set_transport(channel, CHANNEL_TRANSPORT_PLAIN, 0);
|
|
|
|
{
|
|
|
|
|
|
|
|
channel->transport = CHANNEL_TRANSPORT_PLAINTEXT;
|
|
|
|
|
|
|
|
weechat_printf_date_tags(channel->buffer, 0, NULL, "%s%sTransport: %s",
|
|
|
|
|
|
|
|
weechat_prefix("network"), weechat_color("gray"),
|
|
|
|
|
|
|
|
channel__transport_name(channel->transport));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (url)
|
|
|
|
char *url = strstr(body, "http");
|
|
|
|
|
|
|
|
if (url && channel->transport == CHANNEL_TRANSPORT_PLAIN)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
xmpp_stanza_t *message__x = xmpp_stanza_new(account->context);
|
|
|
|
xmpp_stanza_t *message__x = xmpp_stanza_new(account->context);
|
|
|
|
xmpp_stanza_set_name(message__x, "x");
|
|
|
|
xmpp_stanza_set_name(message__x, "x");
|
|
|
@ -1070,11 +1138,28 @@ void channel__send_message(struct t_account *account, struct t_channel *channel,
|
|
|
|
|
|
|
|
|
|
|
|
xmpp_stanza_t *message__active = xmpp_stanza_new(account->context);
|
|
|
|
xmpp_stanza_t *message__active = xmpp_stanza_new(account->context);
|
|
|
|
xmpp_stanza_set_name(message__active, "active");
|
|
|
|
xmpp_stanza_set_name(message__active, "active");
|
|
|
|
xmpp_stanza_set_ns(message__active, "http://jabber./org/protocol/chatstates");
|
|
|
|
xmpp_stanza_set_ns(message__active, "http://jabber.org/protocol/chatstates");
|
|
|
|
|
|
|
|
|
|
|
|
xmpp_stanza_add_child(message, message__active);
|
|
|
|
xmpp_stanza_add_child(message, message__active);
|
|
|
|
xmpp_stanza_release(message__active);
|
|
|
|
xmpp_stanza_release(message__active);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xmpp_stanza_t *message__request = xmpp_stanza_new(account->context);
|
|
|
|
|
|
|
|
xmpp_stanza_set_name(message__request, "request");
|
|
|
|
|
|
|
|
xmpp_stanza_set_ns(message__request, "urn:xmpp:receipts");
|
|
|
|
|
|
|
|
xmpp_stanza_add_child(message, message__request);
|
|
|
|
|
|
|
|
xmpp_stanza_release(message__request);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xmpp_stanza_t *message__markable = xmpp_stanza_new(account->context);
|
|
|
|
|
|
|
|
xmpp_stanza_set_name(message__markable, "markable");
|
|
|
|
|
|
|
|
xmpp_stanza_set_ns(message__markable, "urn:xmpp:chat-markers:0");
|
|
|
|
|
|
|
|
xmpp_stanza_add_child(message, message__markable);
|
|
|
|
|
|
|
|
xmpp_stanza_release(message__markable);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xmpp_stanza_t *message__store = xmpp_stanza_new(account->context);
|
|
|
|
|
|
|
|
xmpp_stanza_set_name(message__store, "store");
|
|
|
|
|
|
|
|
xmpp_stanza_set_ns(message__store, "urn:xmpp:hints");
|
|
|
|
|
|
|
|
xmpp_stanza_add_child(message, message__store);
|
|
|
|
|
|
|
|
xmpp_stanza_release(message__store);
|
|
|
|
|
|
|
|
|
|
|
|
xmpp_send(account->connection, message);
|
|
|
|
xmpp_send(account->connection, message);
|
|
|
|
xmpp_stanza_release(message);
|
|
|
|
xmpp_stanza_release(message);
|
|
|
|
if (channel->type != CHANNEL_TYPE_MUC)
|
|
|
|
if (channel->type != CHANNEL_TYPE_MUC)
|
|
|
@ -1083,6 +1168,8 @@ void channel__send_message(struct t_account *account, struct t_channel *channel,
|
|
|
|
"%s\t%s",
|
|
|
|
"%s\t%s",
|
|
|
|
user__as_prefix_raw(account, account_jid(account)),
|
|
|
|
user__as_prefix_raw(account, account_jid(account)),
|
|
|
|
body);
|
|
|
|
body);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return WEECHAT_RC_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void channel__send_reads(struct t_account *account, struct t_channel *channel)
|
|
|
|
void channel__send_reads(struct t_account *account, struct t_channel *channel)
|
|
|
|