change muc

v1
Tony Olagbaiye 4 years ago
parent dba306a01e
commit 55626cd08f
No known key found for this signature in database
GPG Key ID: 9E2FF3BDEBDFC910

@ -16,7 +16,7 @@
[[https://github.com/bqv/weechat-xmpp/issues?q=is:issue+is:closed][file:https://img.shields.io/github/issues-closed/bqv/weechat-xmpp.svg]]
[[https://github.com/bqv/weechat-xmpp/blob/master/LICENSE][file:https://img.shields.io/github/license/bqv/weechat-xmpp.svg]]
[[https://github.com/bqv/weechat-extras/][file:https://img.shields.io/badge/weechat--extras-xmpp-blue.svg]]
[[https://github.com/bqv/weechat-extras/][file:https://inverse.chat/badge.svg?room=weechat@conference.hmm.st]]
[[https://github.com/bqv/weechat-extras/][file:https://inverse.chat/badge.svg?room=weechat@muc.xa0.uk]]
| Status: | XMPP for power users and digital masochists |
| Location: | [[http://github.com/bqv/weechat-xmpp]] |
@ -115,8 +115,10 @@
* [ ] OMEMO (libsignal-protocol-c / axc)
* [ ] Presence
* [X] Disco
* [ ] Disco response
* [X] Disco response
* [ ] Key Generation / storage (secured_data?)
* [X] Generation
* [ ] Storage
* [ ] Messages
* [ ] [#C] MUC PMs
* [ ] [#A] Send typing notifications

@ -697,7 +697,57 @@ void connection__handler(xmpp_conn_t *conn, xmpp_conn_event_t status,
xmpp_send(conn, children[0]);
xmpp_stanza_release(children[0]);
omemo__init(&account->omemo, 0, NULL);
struct t_hashtable *variables = weechat_hashtable_new (8,
WEECHAT_HASHTABLE_STRING,
WEECHAT_HASHTABLE_STRING,
NULL, NULL);
weechat_hashtable_set(variables, "account", account->name);
char *dev_str = weechat_string_eval_expression(
"${sec.data.xmpp_device_${account}}",
NULL, variables, NULL);
char *b64_id = weechat_string_eval_expression(
"${sec.data.xmpp_identity_${account}}",
NULL, variables, NULL);
weechat_hashtable_free(variables);
uint32_t dev_id = dev_str[0] ? atoi(dev_str) : 0;
uint8_t identity[128];
if (b64_id)
weechat_string_base_decode(64, b64_id, (char*)identity);
struct t_identity id_key = {
.key = b64_id ? identity : NULL,
.length = 4,
};
omemo__init(&account->omemo, dev_id, &id_key);
char account_id[64] = {0};
snprintf(account_id, sizeof(account_id), "%d", account->omemo->device_id);
if (weechat_strcasecmp(dev_str, account_id) != 0)
{
char **command = weechat_string_dyn_alloc(256);
weechat_string_dyn_concat(command, "/secure set ", -1);
weechat_string_dyn_concat(command, "xmpp_device_", -1);
weechat_string_dyn_concat(command, account->name, -1);
weechat_string_dyn_concat(command, " ", -1);
weechat_string_dyn_concat(command, account_id, -1);
weechat_command(account->buffer, *command);
weechat_string_dyn_free(command, 1);
}
char account_key[64] = {0};
weechat_string_base_encode(64, (char*)account->omemo->identity.key,
account->omemo->identity.length, account_key);
if (memcmp(identity, account->omemo->identity.key,
account->omemo->identity.length) != 0)
{
char **command = weechat_string_dyn_alloc(256);
weechat_string_dyn_concat(command, "/secure set ", -1);
weechat_string_dyn_concat(command, "xmpp_identity_", -1);
weechat_string_dyn_concat(command, account->name, -1);
weechat_string_dyn_concat(command, " ", -1);
weechat_string_dyn_concat(command, account_id, -1);
weechat_command(account->buffer, *command);
weechat_string_dyn_free(command, 1);
}
}
else
{

@ -9,8 +9,6 @@
void omemo__init(struct t_omemo **omemo, uint32_t device,
struct t_identity *identity)
{
const char* ns_devicelist = "eu.siacs.conversations.axolotl.devicelist";
const char* ft_devicelist = "eu.siacs.conversations.axolotl.devicelist+notify";
int rc;
srandom(time(NULL));

Loading…
Cancel
Save