hacky impl of oob

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

@ -4,10 +4,10 @@ ifdef DEBUG
endif endif
RM=rm -f RM=rm -f
FIND=find FIND=find
INCLUDES=-Ilibstrophe $(shell xml2-config --cflags) INCLUDES=-Ilibstrophe $(shell xml2-config --cflags) $(shell pkg-config --cflags glib-2.0) $(shell pkg-config --cflags libsignal-protocol-c)
CFLAGS+=$(DBGCFLAGS) -fno-omit-frame-pointer -fPIC -std=gnu99 -g -Wall -Wextra -Werror-implicit-function-declaration -Wno-missing-field-initializers -D_XOPEN_SOURCE=700 $(INCLUDES) CFLAGS+=$(DBGCFLAGS) -fno-omit-frame-pointer -fPIC -std=gnu99 -g -Wall -Wextra -Werror-implicit-function-declaration -Wno-missing-field-initializers -D_XOPEN_SOURCE=700 $(INCLUDES)
LDFLAGS+=$(DBGLDFLAGS) -shared -g $(DBGCFLAGS) LDFLAGS+=$(DBGLDFLAGS) -shared -g $(DBGCFLAGS)
LDLIBS=-lstrophe -lpthread $(shell xml2-config --libs) LDLIBS=-lstrophe -lpthread $(shell xml2-config --libs) $(shell pkg-config --libs glib-2.0) $(shell pkg-config --libs libsignal-protocol-c)
PREFIX ?= /usr/local PREFIX ?= /usr/local
LIBDIR ?= $(PREFIX)/lib LIBDIR ?= $(PREFIX)/lib
@ -22,6 +22,7 @@ SRCS=plugin.c \
connection.c \ connection.c \
input.c \ input.c \
message.c \ message.c \
omemo.c \
user.c \ user.c \
DEPS=axc/build/libaxc.a DEPS=axc/build/libaxc.a

@ -81,6 +81,7 @@
* [X] Opening PMs (/chat) * [X] Opening PMs (/chat)
** TODO [#A] Implement essential functionality (milestone v0.2) ** TODO [#A] Implement essential functionality (milestone v0.2)
* [X] Opening PMs with initial message * [X] Opening PMs with initial message
* [X] OOB media messages
* [ ] [#B] Handle wide errors gracefully * [ ] [#B] Handle wide errors gracefully
* [ ] [#B] Event-driven MUC entrance * [ ] [#B] Event-driven MUC entrance
* [ ] MUCs * [ ] MUCs

@ -612,6 +612,29 @@ void channel__send_message(struct t_account *account, struct t_channel *channel,
? "groupchat" : "chat", ? "groupchat" : "chat",
to, NULL); to, NULL);
xmpp_message_set_body(message, body); xmpp_message_set_body(message, body);
char *url = strstr(body, "http");
if (url)
{
struct xmpp_stanza_t *message__x = xmpp_stanza_new(account->context);
xmpp_stanza_set_name(message__x, "x");
xmpp_stanza_set_ns(message__x, "jabber:x:oob");
struct xmpp_stanza_t *message__x__url = xmpp_stanza_new(account->context);
xmpp_stanza_set_name(message__x__url, "url");
struct xmpp_stanza_t *message__x__url__text = xmpp_stanza_new(account->context);
xmpp_stanza_set_text(message__x__url__text, url);
xmpp_stanza_add_child(message__x__url, message__x__url__text);
xmpp_stanza_release(message__x__url__text);
xmpp_stanza_add_child(message__x, message__x__url);
xmpp_stanza_release(message__x__url);
xmpp_stanza_add_child(message, message__x);
xmpp_stanza_release(message__x);
}
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)

@ -380,9 +380,9 @@ int command__enter(const void *pointer, void *data,
xmpp_stanza_set_name(pres__x, "x"); xmpp_stanza_set_name(pres__x, "x");
xmpp_stanza_set_ns(pres__x, "http://jabber.org/protocol/muc"); xmpp_stanza_set_ns(pres__x, "http://jabber.org/protocol/muc");
xmpp_stanza_add_child(pres, pres__x); xmpp_stanza_add_child(pres, pres__x);
xmpp_stanza_release(pres__x);
xmpp_send(ptr_account->connection, pres); xmpp_send(ptr_account->connection, pres);
xmpp_stanza_release(pres__x);
xmpp_stanza_release(pres); xmpp_stanza_release(pres);
if (argc > 2) if (argc > 2)

@ -191,7 +191,8 @@ void connection__handler(xmpp_conn_t *conn, xmpp_conn_event_t status,
(void)stream_error; (void)stream_error;
if (status == XMPP_CONN_CONNECT) { if (status == XMPP_CONN_CONNECT) {
xmpp_stanza_t *pres; xmpp_stanza_t *pres, *pres__c;
char cap_hash[28+1] = {0};
xmpp_handler_add(conn, version_handler, "jabber:iq:version", "iq", NULL, account); xmpp_handler_add(conn, version_handler, "jabber:iq:version", "iq", NULL, account);
xmpp_handler_add(conn, presence_handler, NULL, "presence", NULL, account); xmpp_handler_add(conn, presence_handler, NULL, "presence", NULL, account);
@ -200,6 +201,17 @@ void connection__handler(xmpp_conn_t *conn, xmpp_conn_event_t status,
/* Send initial <presence/> so that we appear online to contacts */ /* Send initial <presence/> so that we appear online to contacts */
pres = xmpp_presence_new(account->context); pres = xmpp_presence_new(account->context);
xmpp_stanza_set_from(pres, account_jid(account)); xmpp_stanza_set_from(pres, account_jid(account));
pres__c = xmpp_stanza_new(account->context);
xmpp_stanza_set_name(pres__c, "c");
xmpp_stanza_set_ns(pres__c, "http://jabber.org/protocol/caps");
xmpp_stanza_set_attribute(pres__c, "hash", "sha-1");
xmpp_stanza_set_attribute(pres__c, "node", "http://weechat.org");
snprintf(cap_hash, sizeof(cap_hash), "%027d=", time(NULL));
xmpp_stanza_set_attribute(pres__c, "ver", cap_hash);
xmpp_stanza_add_child(pres, pres__c);
xmpp_stanza_release(pres__c);
xmpp_send(conn, pres); xmpp_send(conn, pres);
xmpp_stanza_release(pres); xmpp_stanza_release(pres);
} else { } else {

@ -0,0 +1,16 @@
// 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 "omemo/src/libomemo.h"
#include "axc/src/axc.h"
#include "omemo.h"
void omemo__init()
{
const char* ns_devicelist = "eu.siacs.conversations.axolotl.devicelist";
const char* ft_devicelist = "eu.siacs.conversations.axolotl.devicelist+notify";
}

@ -0,0 +1,10 @@
// 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/.
#ifndef _WEECHAT_XMPP_OMEMO_H_
#define _WEECHAT_XMPP_OMEMO_H_
void omemo__init();
#endif /*WEECHAT_XMPP_OMEMO_H*/
Loading…
Cancel
Save