diff --git a/Makefile b/Makefile
index 04dbd77..306715e 100644
--- a/Makefile
+++ b/Makefile
@@ -4,10 +4,10 @@ ifdef DEBUG
endif
RM=rm -f
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)
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
LIBDIR ?= $(PREFIX)/lib
@@ -22,6 +22,7 @@ SRCS=plugin.c \
connection.c \
input.c \
message.c \
+ omemo.c \
user.c \
DEPS=axc/build/libaxc.a
diff --git a/README.org b/README.org
index 9decce2..d5cc9d0 100644
--- a/README.org
+++ b/README.org
@@ -81,6 +81,7 @@
* [X] Opening PMs (/chat)
** TODO [#A] Implement essential functionality (milestone v0.2)
* [X] Opening PMs with initial message
+ * [X] OOB media messages
* [ ] [#B] Handle wide errors gracefully
* [ ] [#B] Event-driven MUC entrance
* [ ] MUCs
diff --git a/channel.c b/channel.c
index 8ea3510..7c2f9b3 100644
--- a/channel.c
+++ b/channel.c
@@ -612,6 +612,29 @@ void channel__send_message(struct t_account *account, struct t_channel *channel,
? "groupchat" : "chat",
to, NULL);
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_stanza_release(message);
if (channel->type != CHANNEL_TYPE_MUC)
diff --git a/command.c b/command.c
index 55dacac..e409df3 100644
--- a/command.c
+++ b/command.c
@@ -380,9 +380,9 @@ int command__enter(const void *pointer, void *data,
xmpp_stanza_set_name(pres__x, "x");
xmpp_stanza_set_ns(pres__x, "http://jabber.org/protocol/muc");
xmpp_stanza_add_child(pres, pres__x);
+ xmpp_stanza_release(pres__x);
xmpp_send(ptr_account->connection, pres);
- xmpp_stanza_release(pres__x);
xmpp_stanza_release(pres);
if (argc > 2)
diff --git a/connection.c b/connection.c
index 6e57c60..fd962c9 100644
--- a/connection.c
+++ b/connection.c
@@ -191,7 +191,8 @@ void connection__handler(xmpp_conn_t *conn, xmpp_conn_event_t status,
(void)stream_error;
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, presence_handler, NULL, "presence", NULL, account);
@@ -200,6 +201,17 @@ void connection__handler(xmpp_conn_t *conn, xmpp_conn_event_t status,
/* Send initial so that we appear online to contacts */
pres = xmpp_presence_new(account->context);
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_stanza_release(pres);
} else {
diff --git a/omemo.c b/omemo.c
new file mode 100644
index 0000000..affb2b0
--- /dev/null
+++ b/omemo.c
@@ -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
+
+#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";
+}
diff --git a/omemo.h b/omemo.h
new file mode 100644
index 0000000..7fb146c
--- /dev/null
+++ b/omemo.h
@@ -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*/