|
|
@ -86,7 +86,7 @@ int connection__presence_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void
|
|
|
|
struct t_account *account = (struct t_account *)userdata;
|
|
|
|
struct t_account *account = (struct t_account *)userdata;
|
|
|
|
struct t_user *user;
|
|
|
|
struct t_user *user;
|
|
|
|
struct t_channel *channel;
|
|
|
|
struct t_channel *channel;
|
|
|
|
xmpp_stanza_t *iq__x_signed, *iq__x_muc_user, *show, *idle, *iq__x__item, *iq__c, *iq__status;
|
|
|
|
xmpp_stanza_t *pres__x_signed, *pres__x_muc_user, *show, *idle, *pres__x__item, *pres__c, *pres__status;
|
|
|
|
const char *from, *from_bare, *from_res, *type, *role = NULL, *affiliation = NULL, *jid = NULL;
|
|
|
|
const char *from, *from_bare, *from_res, *type, *role = NULL, *affiliation = NULL, *jid = NULL;
|
|
|
|
const char *show__text = NULL, *idle__since = NULL, *certificate = NULL, *node = NULL, *ver = NULL;
|
|
|
|
const char *show__text = NULL, *idle__since = NULL, *certificate = NULL, *node = NULL, *ver = NULL;
|
|
|
|
char *clientid = NULL, *status;
|
|
|
|
char *clientid = NULL, *status;
|
|
|
@ -101,18 +101,18 @@ int connection__presence_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void
|
|
|
|
show__text = show ? xmpp_stanza_get_text(show) : NULL;
|
|
|
|
show__text = show ? xmpp_stanza_get_text(show) : NULL;
|
|
|
|
idle = xmpp_stanza_get_child_by_name_and_ns(stanza, "idle", "urn:xmpp:idle:1");
|
|
|
|
idle = xmpp_stanza_get_child_by_name_and_ns(stanza, "idle", "urn:xmpp:idle:1");
|
|
|
|
idle__since = idle ? xmpp_stanza_get_attribute(idle, "since") : NULL;
|
|
|
|
idle__since = idle ? xmpp_stanza_get_attribute(idle, "since") : NULL;
|
|
|
|
iq__x_signed = xmpp_stanza_get_child_by_name_and_ns(
|
|
|
|
pres__x_signed = xmpp_stanza_get_child_by_name_and_ns(
|
|
|
|
stanza, "x", "jabber:x:signed");
|
|
|
|
stanza, "x", "jabber:x:signed");
|
|
|
|
if (iq__x_signed)
|
|
|
|
if (pres__x_signed)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
certificate = xmpp_stanza_get_text(iq__x_signed);
|
|
|
|
certificate = xmpp_stanza_get_text(pres__x_signed);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
iq__c = xmpp_stanza_get_child_by_name_and_ns(
|
|
|
|
pres__c = xmpp_stanza_get_child_by_name_and_ns(
|
|
|
|
stanza, "c", "http://jabber.org/protocol/caps");
|
|
|
|
stanza, "c", "http://jabber.org/protocol/caps");
|
|
|
|
if (iq__c)
|
|
|
|
if (pres__c)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
node = xmpp_stanza_get_attribute(iq__c, "node");
|
|
|
|
node = xmpp_stanza_get_attribute(pres__c, "node");
|
|
|
|
ver = xmpp_stanza_get_attribute(iq__c, "ver");
|
|
|
|
ver = xmpp_stanza_get_attribute(pres__c, "ver");
|
|
|
|
if (node && ver)
|
|
|
|
if (node && ver)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
int len = strlen(node)+1+strlen(ver);
|
|
|
|
int len = strlen(node)+1+strlen(ver);
|
|
|
@ -120,25 +120,25 @@ int connection__presence_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void
|
|
|
|
snprintf(clientid, len, "%s#%s", node, ver);
|
|
|
|
snprintf(clientid, len, "%s#%s", node, ver);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
iq__status = xmpp_stanza_get_child_by_name(stanza, "status");
|
|
|
|
pres__status = xmpp_stanza_get_child_by_name(stanza, "status");
|
|
|
|
status = iq__status ? xmpp_stanza_get_text(iq__status) : NULL;
|
|
|
|
status = pres__status ? xmpp_stanza_get_text(pres__status) : NULL;
|
|
|
|
iq__x_muc_user = xmpp_stanza_get_child_by_name_and_ns(
|
|
|
|
pres__x_muc_user = xmpp_stanza_get_child_by_name_and_ns(
|
|
|
|
stanza, "x", "http://jabber.org/protocol/muc#user");
|
|
|
|
stanza, "x", "http://jabber.org/protocol/muc#user");
|
|
|
|
|
|
|
|
|
|
|
|
channel = channel__search(account, from_bare);
|
|
|
|
channel = channel__search(account, from_bare);
|
|
|
|
if (weechat_strcasecmp(type, "unavailable") && !iq__x_muc_user && !channel)
|
|
|
|
if (weechat_strcasecmp(type, "unavailable") != 0 && !pres__x_muc_user && !channel)
|
|
|
|
channel = channel__new(account, CHANNEL_TYPE_PM, from_bare, from_bare);
|
|
|
|
channel = channel__new(account, CHANNEL_TYPE_PM, from_bare, from_bare);
|
|
|
|
|
|
|
|
|
|
|
|
if (iq__x_muc_user)
|
|
|
|
if (pres__x_muc_user)
|
|
|
|
for (iq__x__item = xmpp_stanza_get_children(iq__x_muc_user);
|
|
|
|
for (pres__x__item = xmpp_stanza_get_children(pres__x_muc_user);
|
|
|
|
iq__x__item; iq__x__item = xmpp_stanza_get_next(iq__x__item))
|
|
|
|
pres__x__item; pres__x__item = xmpp_stanza_get_next(pres__x__item))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (weechat_strcasecmp(xmpp_stanza_get_name(iq__x__item), "item") != 0)
|
|
|
|
if (weechat_strcasecmp(xmpp_stanza_get_name(pres__x__item), "item") != 0)
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
role = xmpp_stanza_get_attribute(iq__x__item, "role");
|
|
|
|
role = xmpp_stanza_get_attribute(pres__x__item, "role");
|
|
|
|
affiliation = xmpp_stanza_get_attribute(iq__x__item, "affiliation");
|
|
|
|
affiliation = xmpp_stanza_get_attribute(pres__x__item, "affiliation");
|
|
|
|
jid = xmpp_stanza_get_attribute(iq__x__item, "jid");
|
|
|
|
jid = xmpp_stanza_get_attribute(pres__x__item, "jid");
|
|
|
|
|
|
|
|
|
|
|
|
user = user__search(account, from);
|
|
|
|
user = user__search(account, from);
|
|
|
|
if (!user)
|
|
|
|
if (!user)
|
|
|
@ -209,7 +209,7 @@ int connection__message_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void *
|
|
|
|
|
|
|
|
|
|
|
|
struct t_account *account = (struct t_account *)userdata;
|
|
|
|
struct t_account *account = (struct t_account *)userdata;
|
|
|
|
struct t_channel *channel;
|
|
|
|
struct t_channel *channel;
|
|
|
|
xmpp_stanza_t *x, *body, *delay, *topic, *replace, *request, *markable, *composing, *sent, *received, *result, *forwarded;
|
|
|
|
xmpp_stanza_t *x, *body, *delay, *topic, *replace, *request, *markable, *composing, *sent, *received, *result, *forwarded, *event, *items, *item, *list, *device, *encrypted, **children;
|
|
|
|
const char *type, *from, *nick, *from_bare, *to, *to_bare, *id, *thread, *replace_id, *timestamp;
|
|
|
|
const char *type, *from, *nick, *from_bare, *to, *to_bare, *id, *thread, *replace_id, *timestamp;
|
|
|
|
char *text, *intext, *difftext = NULL, *cleartext = NULL;
|
|
|
|
char *text, *intext, *difftext = NULL, *cleartext = NULL;
|
|
|
|
struct tm time = {0};
|
|
|
|
struct tm time = {0};
|
|
|
@ -222,6 +222,9 @@ int connection__message_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void *
|
|
|
|
if (topic != NULL)
|
|
|
|
if (topic != NULL)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
intext = xmpp_stanza_get_text(topic);
|
|
|
|
intext = xmpp_stanza_get_text(topic);
|
|
|
|
|
|
|
|
type = xmpp_stanza_get_type(stanza);
|
|
|
|
|
|
|
|
if (type != NULL && strcmp(type, "error") == 0)
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
from = xmpp_stanza_get_from(stanza);
|
|
|
|
from = xmpp_stanza_get_from(stanza);
|
|
|
|
if (from == NULL)
|
|
|
|
if (from == NULL)
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
@ -229,7 +232,12 @@ int connection__message_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void *
|
|
|
|
from = xmpp_jid_resource(account->context, from);
|
|
|
|
from = xmpp_jid_resource(account->context, from);
|
|
|
|
channel = channel__search(account, from_bare);
|
|
|
|
channel = channel__search(account, from_bare);
|
|
|
|
if (!channel)
|
|
|
|
if (!channel)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (weechat_strcasecmp(type, "groupchat") == 0)
|
|
|
|
|
|
|
|
channel = channel__new(account, CHANNEL_TYPE_MUC, from_bare, from_bare);
|
|
|
|
|
|
|
|
else
|
|
|
|
channel = channel__new(account, CHANNEL_TYPE_PM, from_bare, from_bare);
|
|
|
|
channel = channel__new(account, CHANNEL_TYPE_PM, from_bare, from_bare);
|
|
|
|
|
|
|
|
}
|
|
|
|
channel__update_topic(channel, intext ? intext : "", from, 0);
|
|
|
|
channel__update_topic(channel, intext ? intext : "", from, 0);
|
|
|
|
if (intext != NULL)
|
|
|
|
if (intext != NULL)
|
|
|
|
xmpp_free(account->context, intext);
|
|
|
|
xmpp_free(account->context, intext);
|
|
|
@ -297,6 +305,69 @@ int connection__message_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void *
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
event = xmpp_stanza_get_child_by_name_and_ns(
|
|
|
|
|
|
|
|
stanza, "event", "http://jabber.org/protocol/pubsub#event");
|
|
|
|
|
|
|
|
if (event)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
items = xmpp_stanza_get_child_by_name(event, "items");
|
|
|
|
|
|
|
|
if (items)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
const char *items_node = xmpp_stanza_get_attribute(items, "node");
|
|
|
|
|
|
|
|
from = xmpp_stanza_get_from(stanza);
|
|
|
|
|
|
|
|
to = xmpp_stanza_get_to(stanza);
|
|
|
|
|
|
|
|
if (items_node
|
|
|
|
|
|
|
|
&& weechat_strcasecmp(items_node,
|
|
|
|
|
|
|
|
"eu.siacs.conversations.axolotl.devicelist") == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
item = xmpp_stanza_get_child_by_name(items, "item");
|
|
|
|
|
|
|
|
if (item)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
list = xmpp_stanza_get_child_by_name_and_ns(
|
|
|
|
|
|
|
|
item, "list", "eu.siacs.conversations.axolotl");
|
|
|
|
|
|
|
|
if (list)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (account->omemo)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
omemo__handle_devicelist(account->omemo, from,
|
|
|
|
|
|
|
|
items);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
children = malloc(sizeof(*children) * (3 + 1));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (device = xmpp_stanza_get_children(list);
|
|
|
|
|
|
|
|
device; device = xmpp_stanza_get_next(device))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
const char *name = xmpp_stanza_get_name(device);
|
|
|
|
|
|
|
|
if (weechat_strcasecmp(name, "device") != 0)
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const char *device_id = xmpp_stanza_get_id(device);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char bundle_node[128] = {0};
|
|
|
|
|
|
|
|
snprintf(bundle_node, sizeof(bundle_node),
|
|
|
|
|
|
|
|
"eu.siacs.conversations.axolotl.bundles:%s",
|
|
|
|
|
|
|
|
device_id);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
children[1] = NULL;
|
|
|
|
|
|
|
|
children[0] =
|
|
|
|
|
|
|
|
stanza__iq_pubsub_items(account->context, NULL,
|
|
|
|
|
|
|
|
strdup(bundle_node));
|
|
|
|
|
|
|
|
children[0] =
|
|
|
|
|
|
|
|
stanza__iq_pubsub(account->context, NULL, children,
|
|
|
|
|
|
|
|
with_noop("http://jabber.org/protocol/pubsub"));
|
|
|
|
|
|
|
|
children[0] =
|
|
|
|
|
|
|
|
stanza__iq(account->context, NULL, children, NULL, strdup("fetch1"),
|
|
|
|
|
|
|
|
strdup(to), strdup(from), strdup("get"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xmpp_send(conn, children[0]);
|
|
|
|
|
|
|
|
xmpp_stanza_release(children[0]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
type = xmpp_stanza_get_type(stanza);
|
|
|
|
type = xmpp_stanza_get_type(stanza);
|
|
|
@ -382,6 +453,12 @@ int connection__message_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void *
|
|
|
|
weechat_list_add(channel->unreads, unread->id, WEECHAT_LIST_POS_END, unread);
|
|
|
|
weechat_list_add(channel->unreads, unread->id, WEECHAT_LIST_POS_END, unread);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
encrypted = xmpp_stanza_get_child_by_name_and_ns(stanza, "encrypted",
|
|
|
|
|
|
|
|
"eu.siacs.conversations.axolotl");
|
|
|
|
|
|
|
|
if (encrypted && account->omemo)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
omemo__decode(account->omemo, from_bare, encrypted);
|
|
|
|
|
|
|
|
}
|
|
|
|
x = xmpp_stanza_get_child_by_name_and_ns(stanza, "x", "jabber:x:encrypted");
|
|
|
|
x = xmpp_stanza_get_child_by_name_and_ns(stanza, "x", "jabber:x:encrypted");
|
|
|
|
intext = xmpp_stanza_get_text(body);
|
|
|
|
intext = xmpp_stanza_get_text(body);
|
|
|
|
if (x)
|
|
|
|
if (x)
|
|
|
@ -557,7 +634,7 @@ int connection__message_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void *
|
|
|
|
weechat_string_dyn_concat(dyn_tags, replace_id, -1);
|
|
|
|
weechat_string_dyn_concat(dyn_tags, replace_id, -1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (date != 0)
|
|
|
|
if (date != 0 || encrypted)
|
|
|
|
weechat_string_dyn_concat(dyn_tags, ",notify_none", -1);
|
|
|
|
weechat_string_dyn_concat(dyn_tags, ",notify_none", -1);
|
|
|
|
else if (channel->type == CHANNEL_TYPE_PM
|
|
|
|
else if (channel->type == CHANNEL_TYPE_PM
|
|
|
|
&& weechat_strcasecmp(from_bare, account_jid(account)) != 0)
|
|
|
|
&& weechat_strcasecmp(from_bare, account_jid(account)) != 0)
|
|
|
@ -609,11 +686,12 @@ int connection__iq_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void *userd
|
|
|
|
{
|
|
|
|
{
|
|
|
|
struct t_account *account = (struct t_account *)userdata;
|
|
|
|
struct t_account *account = (struct t_account *)userdata;
|
|
|
|
xmpp_stanza_t *reply, *query, *identity, *feature, *x, *field, *value, *text, *fin;
|
|
|
|
xmpp_stanza_t *reply, *query, *identity, *feature, *x, *field, *value, *text, *fin;
|
|
|
|
xmpp_stanza_t *pubsub, *items, *item, *list, *device, **children;
|
|
|
|
xmpp_stanza_t *pubsub, *items, *item, *list, *bundle, *device;
|
|
|
|
xmpp_stanza_t *storage, *conference, *nick;
|
|
|
|
xmpp_stanza_t *storage, *conference, *nick;
|
|
|
|
static struct utsname osinfo;
|
|
|
|
static struct utsname osinfo;
|
|
|
|
|
|
|
|
|
|
|
|
const char *id = xmpp_stanza_get_id(stanza);
|
|
|
|
const char *id = xmpp_stanza_get_id(stanza);
|
|
|
|
|
|
|
|
const char *from = xmpp_stanza_get_from(stanza);
|
|
|
|
query = xmpp_stanza_get_child_by_name_and_ns(
|
|
|
|
query = xmpp_stanza_get_child_by_name_and_ns(
|
|
|
|
stanza, "query", "http://jabber.org/protocol/disco#info");
|
|
|
|
stanza, "query", "http://jabber.org/protocol/disco#info");
|
|
|
|
const char *type = xmpp_stanza_get_attribute(stanza, "type");
|
|
|
|
const char *type = xmpp_stanza_get_attribute(stanza, "type");
|
|
|
@ -836,7 +914,7 @@ int connection__iq_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void *userd
|
|
|
|
stanza, "pubsub", "http://jabber.org/protocol/pubsub");
|
|
|
|
stanza, "pubsub", "http://jabber.org/protocol/pubsub");
|
|
|
|
if (pubsub)
|
|
|
|
if (pubsub)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
const char *items_node, *item_id, *device_id, *ns, *node;
|
|
|
|
const char *items_node, *item_id, *device_id;
|
|
|
|
|
|
|
|
|
|
|
|
items = xmpp_stanza_get_child_by_name(pubsub, "items");
|
|
|
|
items = xmpp_stanza_get_child_by_name(pubsub, "items");
|
|
|
|
if (items)
|
|
|
|
if (items)
|
|
|
@ -855,23 +933,24 @@ int connection__iq_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void *userd
|
|
|
|
item, "list", "eu.siacs.conversations.axolotl");
|
|
|
|
item, "list", "eu.siacs.conversations.axolotl");
|
|
|
|
if (list && account->omemo)
|
|
|
|
if (list && account->omemo)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
account__free_device_all(account);
|
|
|
|
omemo__handle_devicelist(account->omemo, from, items);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (weechat_strcasecmp(account_jid(account), from) == 0)
|
|
|
|
|
|
|
|
{
|
|
|
|
struct t_account_device *dev;
|
|
|
|
struct t_account_device *dev;
|
|
|
|
char id[64] = {0};
|
|
|
|
char id[64] = {0};
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
|
|
|
|
account__free_device_all(account);
|
|
|
|
|
|
|
|
|
|
|
|
dev = malloc(sizeof(struct t_account_device));
|
|
|
|
dev = malloc(sizeof(struct t_account_device));
|
|
|
|
|
|
|
|
|
|
|
|
dev->id = account->omemo->device_id;
|
|
|
|
dev->id = account->omemo->device_id;
|
|
|
|
snprintf(id, sizeof(id), "%d", dev->id);
|
|
|
|
snprintf(id, sizeof(id), "%d", dev->id);
|
|
|
|
dev->name = strdup(id);
|
|
|
|
dev->name = strdup(id);
|
|
|
|
|
|
|
|
dev->label = strdup("weechat");
|
|
|
|
account__add_device(account, dev);
|
|
|
|
account__add_device(account, dev);
|
|
|
|
|
|
|
|
|
|
|
|
children = malloc(sizeof(xmpp_stanza_t *) * 128);
|
|
|
|
free(dev->label);
|
|
|
|
children[i++] = stanza__iq_pubsub_publish_item_list_device(
|
|
|
|
|
|
|
|
account->context, NULL, with_noop(dev->name));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
free(dev->name);
|
|
|
|
free(dev->name);
|
|
|
|
free(dev);
|
|
|
|
free(dev);
|
|
|
|
|
|
|
|
|
|
|
@ -887,90 +966,42 @@ int connection__iq_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void *userd
|
|
|
|
dev = malloc(sizeof(struct t_account_device));
|
|
|
|
dev = malloc(sizeof(struct t_account_device));
|
|
|
|
dev->id = atoi(device_id);
|
|
|
|
dev->id = atoi(device_id);
|
|
|
|
dev->name = strdup(device_id);
|
|
|
|
dev->name = strdup(device_id);
|
|
|
|
|
|
|
|
dev->label = NULL;
|
|
|
|
account__add_device(account, dev);
|
|
|
|
account__add_device(account, dev);
|
|
|
|
|
|
|
|
|
|
|
|
children[i++] = stanza__iq_pubsub_publish_item_list_device(
|
|
|
|
free(dev->label);
|
|
|
|
account->context, NULL, with_noop(dev->name));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
free(dev->name);
|
|
|
|
free(dev->name);
|
|
|
|
free(dev);
|
|
|
|
free(dev);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
children[i] = NULL;
|
|
|
|
reply = account__get_devicelist(account);
|
|
|
|
node = "eu.siacs.conversations.axolotl";
|
|
|
|
|
|
|
|
children[0] = stanza__iq_pubsub_publish_item_list(
|
|
|
|
|
|
|
|
account->context, NULL, children, with_noop(node));
|
|
|
|
|
|
|
|
children[1] = NULL;
|
|
|
|
|
|
|
|
children[0] = stanza__iq_pubsub_publish_item(
|
|
|
|
|
|
|
|
account->context, NULL, children, with_noop("current"));
|
|
|
|
|
|
|
|
ns = "http://jabber.org/protocol/pubsub";
|
|
|
|
|
|
|
|
children[0] = stanza__iq_pubsub_publish(account->context,
|
|
|
|
|
|
|
|
NULL, children,
|
|
|
|
|
|
|
|
with_noop(ns));
|
|
|
|
|
|
|
|
children[0] = stanza__iq_pubsub(account->context, NULL,
|
|
|
|
|
|
|
|
children, with_noop(""));
|
|
|
|
|
|
|
|
reply = stanza__iq(account->context, xmpp_stanza_reply(stanza),
|
|
|
|
|
|
|
|
children, NULL, strdup("announce1"),
|
|
|
|
|
|
|
|
NULL, NULL, strdup("set"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xmpp_send(conn, reply);
|
|
|
|
xmpp_send(conn, reply);
|
|
|
|
xmpp_stanza_release(reply);
|
|
|
|
xmpp_stanza_release(reply);
|
|
|
|
|
|
|
|
}
|
|
|
|
char bundle_node[128] = {0};
|
|
|
|
}
|
|
|
|
snprintf(bundle_node, sizeof(bundle_node),
|
|
|
|
}
|
|
|
|
"eu.siacs.conversations.axolotl.bundles:%d",
|
|
|
|
}
|
|
|
|
account->omemo->device_id);
|
|
|
|
if (items_node
|
|
|
|
|
|
|
|
&& strncmp(items_node,
|
|
|
|
xmpp_stanza_t *textchild[2] = {NULL};
|
|
|
|
"eu.siacs.conversations.axolotl.bundles",
|
|
|
|
textchild[0] = xmpp_stanza_new(account->context);
|
|
|
|
strnlen(items_node,
|
|
|
|
xmpp_stanza_set_text(textchild[0], "b64enc1");
|
|
|
|
strlen("eu.siacs.conversations.axolotl.bundles"))) == 0)
|
|
|
|
children[0] = stanza__iq_pubsub_publish_item_bundle_signedPreKeyPublic(
|
|
|
|
{
|
|
|
|
account->context, NULL, textchild, with_noop("1"));
|
|
|
|
item = xmpp_stanza_get_child_by_name(items, "item");
|
|
|
|
textchild[0] = xmpp_stanza_new(account->context);
|
|
|
|
if (item)
|
|
|
|
xmpp_stanza_set_text(textchild[0], "b64enc2");
|
|
|
|
{
|
|
|
|
children[1] = stanza__iq_pubsub_publish_item_bundle_signedPreKeySignature(
|
|
|
|
bundle = xmpp_stanza_get_child_by_name_and_ns(item, "bundle", "eu.siacs.conversations.axolotl");
|
|
|
|
account->context, NULL, textchild);
|
|
|
|
if (bundle)
|
|
|
|
textchild[0] = xmpp_stanza_new(account->context);
|
|
|
|
{
|
|
|
|
xmpp_stanza_set_text(textchild[0], "b64enc3");
|
|
|
|
size_t node_prefix =
|
|
|
|
children[2] = stanza__iq_pubsub_publish_item_bundle_identityKey(
|
|
|
|
strlen("eu.siacs.conversations.axolotl.bundles:");
|
|
|
|
account->context, NULL, textchild);
|
|
|
|
if (account->omemo && strlen(items_node) > node_prefix)
|
|
|
|
textchild[0] = xmpp_stanza_new(account->context);
|
|
|
|
{
|
|
|
|
xmpp_stanza_set_text(textchild[0], "b64enc4");
|
|
|
|
omemo__handle_bundle(account->omemo, from,
|
|
|
|
children[3] = stanza__iq_pubsub_publish_item_bundle_prekeys_preKeyPublic(
|
|
|
|
strtol(items_node+node_prefix,
|
|
|
|
account->context, NULL, textchild, with_noop("1"));
|
|
|
|
NULL, 10),
|
|
|
|
textchild[0] = xmpp_stanza_new(account->context);
|
|
|
|
items);
|
|
|
|
xmpp_stanza_set_text(textchild[0], "b64enc5");
|
|
|
|
}
|
|
|
|
children[4] = stanza__iq_pubsub_publish_item_bundle_prekeys_preKeyPublic(
|
|
|
|
|
|
|
|
account->context, NULL, textchild, with_noop("2"));
|
|
|
|
|
|
|
|
textchild[0] = xmpp_stanza_new(account->context);
|
|
|
|
|
|
|
|
xmpp_stanza_set_text(textchild[0], "b64enc6");
|
|
|
|
|
|
|
|
children[5] = stanza__iq_pubsub_publish_item_bundle_prekeys_preKeyPublic(
|
|
|
|
|
|
|
|
account->context, NULL, textchild, with_noop("3"));
|
|
|
|
|
|
|
|
children[6] = NULL;
|
|
|
|
|
|
|
|
children[3] = stanza__iq_pubsub_publish_item_bundle_prekeys(
|
|
|
|
|
|
|
|
account->context, NULL, &children[3]);
|
|
|
|
|
|
|
|
children[4] = NULL;
|
|
|
|
|
|
|
|
ns = "eu.siacs.conversations.axolotl";
|
|
|
|
|
|
|
|
children[0] = stanza__iq_pubsub_publish_item_bundle(
|
|
|
|
|
|
|
|
account->context, NULL, children, with_noop(ns));
|
|
|
|
|
|
|
|
children[1] = NULL;
|
|
|
|
|
|
|
|
children[0] = stanza__iq_pubsub_publish_item(
|
|
|
|
|
|
|
|
account->context, NULL, children, with_noop("current"));
|
|
|
|
|
|
|
|
children[0] = stanza__iq_pubsub_publish(account->context,
|
|
|
|
|
|
|
|
NULL, children,
|
|
|
|
|
|
|
|
with_noop(bundle_node));
|
|
|
|
|
|
|
|
children[0] =
|
|
|
|
|
|
|
|
stanza__iq_pubsub(account->context, NULL, children,
|
|
|
|
|
|
|
|
with_noop("http://jabber.org/protocol/pubsub"));
|
|
|
|
|
|
|
|
children[0] =
|
|
|
|
|
|
|
|
stanza__iq(account->context, NULL, children, NULL, strdup("announce2"),
|
|
|
|
|
|
|
|
strdup(account_jid(account)), strdup(account_jid(account)),
|
|
|
|
|
|
|
|
strdup("set"));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
xmpp_send(conn, children[0]);
|
|
|
|
|
|
|
|
xmpp_stanza_release(children[0]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
free(children);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -1185,6 +1216,12 @@ void connection__handler(xmpp_conn_t *conn, xmpp_conn_event_t status,
|
|
|
|
|
|
|
|
|
|
|
|
omemo__init(account->buffer, &account->omemo, account->name);
|
|
|
|
omemo__init(account->buffer, &account->omemo, account->name);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
children[0] =
|
|
|
|
|
|
|
|
omemo__get_bundle(account->context,
|
|
|
|
|
|
|
|
strdup(account_jid(account)), NULL, account->omemo);
|
|
|
|
|
|
|
|
xmpp_send(conn, children[0]);
|
|
|
|
|
|
|
|
xmpp_stanza_release(children[0]);
|
|
|
|
|
|
|
|
|
|
|
|
(void) weechat_hook_signal_send("xmpp_account_connected",
|
|
|
|
(void) weechat_hook_signal_send("xmpp_account_connected",
|
|
|
|
WEECHAT_HOOK_SIGNAL_STRING, account->name);
|
|
|
|
WEECHAT_HOOK_SIGNAL_STRING, account->name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|