v1
Tony Olagbaiye 3 years ago
parent f5d97c4bd8
commit 609d9963b5
No known key found for this signature in database
GPG Key ID: 9E2FF3BDEBDFC910

@ -24,6 +24,7 @@ SRCS=plugin.c \
message.c \
omemo.c \
user.c \
util.c \
xmpp/presence.c \
xmpp/iq.c \

@ -119,7 +119,8 @@
* [X] Disco response
* [ ] Key Generation / storage (secured_data?)
* [X] Generation
* [ ] Storage
* [X] Storage
* [ ] Announce
* [ ] Messages
* [ ] [#C] MUC PMs
* [ ] [#A] Send typing notifications
@ -128,6 +129,10 @@
* [ ] Message Carbons
* [ ] Service Disco
* [ ] Bookmarks / Roster
* [X] Autojoin bookmarks
* [ ] Add bookmarks
* [ ] Delete bookmarks
* [ ] Roster
* [ ] OTR (libotr)
* [ ] PGP (libgpgme)
* [ ] Room Explorer (https://search.jabber.network/docs/api)

@ -19,6 +19,7 @@
#include "channel.h"
#include "connection.h"
#include "omemo.h"
#include "util.h"
void connection__init()
{
@ -221,8 +222,53 @@ int connection__message_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void *
if (strlen(tag) > strlen("id_") &&
weechat_strcasecmp(tag+strlen("id_"), replace_id) == 0)
{
orig = weechat_hdata_string(weechat_hdata_get("line_data"),
line_data, "message");
struct t_arraylist *orig_lines = weechat_arraylist_new(
0, 0, 0, NULL, NULL, NULL, NULL);
char *msg = (char*)weechat_hdata_string(weechat_hdata_get("line_data"),
line_data, "message");
weechat_arraylist_insert(orig_lines, 0, msg);
while (msg)
{
last_line = weechat_hdata_pointer(weechat_hdata_get("line"),
last_line, "prev_line");
if (last_line)
line_data = weechat_hdata_pointer(weechat_hdata_get("line"),
last_line, "data");
else
line_data = NULL;
msg = NULL;
if (line_data)
{
tags_count = weechat_hdata_integer(weechat_hdata_get("line_data"),
line_data, "tags_count");
for (n_tag = 0; n_tag < tags_count; n_tag++)
{
snprintf(str_tag, sizeof(str_tag), "%d|tags_array", n_tag);
tag = weechat_hdata_string(weechat_hdata_get("line_data"),
line_data, str_tag);
if (strlen(tag) > strlen("id_") &&
weechat_strcasecmp(tag+strlen("id_"), replace_id) == 0)
{
msg = (char*)weechat_hdata_string(weechat_hdata_get("line_data"),
line_data, "message");
break;
}
}
}
if (msg)
weechat_arraylist_insert(orig_lines, 0, msg);
}
char **orig_message = weechat_string_dyn_alloc(256);
for (int i = 0; i < weechat_arraylist_size(orig_lines); i++)
weechat_string_dyn_concat(orig_message,
weechat_arraylist_get(orig_lines, i),
-1);
orig = *orig_message;
weechat_string_dyn_free(orig_message, 0);
break;
}
}
@ -640,26 +686,53 @@ int connection__iq_handler(xmpp_conn_t *conn, xmpp_stanza_t *stanza, void *userd
}
children[i] = NULL;
ns = "eu.siacs.conversations.axolotl";
node = "eu.siacs.conversations.axolotl";
children[0] = stanza__iq_pubsub_publish_item_list(
account->context, NULL, children, with_noop(ns));
account->context, NULL, children, with_noop(node));
children[1] = NULL;
children[0] = stanza__iq_pubsub_publish_item(
account->context, NULL, children, with_noop("current"));
node = "http://jabber.org/protocol/pubsub";
ns = "http://jabber.org/protocol/pubsub";
children[0] = stanza__iq_pubsub_publish(account->context,
NULL, children,
with_noop(node));
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"));
free(children);
xmpp_send(conn, 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);
children[1] = NULL;
children[0] = NULL;
ns = "eu.siacs.conversations.axolotl";
children[0] = stanza__iq_pubsub_publish_item_bundle(
account->context, NULL, NULL, 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);
}
}
}

@ -13,10 +13,4 @@ int connection__connect(struct t_account *account, xmpp_conn_t **connection,
void connection__process(xmpp_ctx_t *context, xmpp_conn_t *connection,
const unsigned long timeout);
static inline int
char_cmp(const void *p1, const void *p2)
{
return *(const char *)p1 == *(const char *)p2;
}
#endif /*WEECHAT_XMPP_CONNECTION_H*/

@ -0,0 +1,14 @@
// 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 <weechat/weechat-plugin.h>
#include "plugin.h"
#include "util.h"
int char_cmp(const void *p1, const void *p2)
{
return *(const char *)p1 == *(const char *)p2;
}

@ -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_UTIL_H_
#define _WEECHAT_XMPP_UTIL_H_
int char_cmp(const void *p1, const void *p2);
#endif /*WEECHAT_XMPP_UTIL_H*/

@ -213,6 +213,75 @@ xmpp_stanza_t *stanza__iq_pubsub_publish_item_list_device(xmpp_ctx_t *context, x
return parent;
}
xmpp_stanza_t *stanza__iq_pubsub_publish_item_bundle(xmpp_ctx_t *context, xmpp_stanza_t *base,
xmpp_stanza_t **children, struct t_string *ns)
{
xmpp_stanza_t *parent = base;
xmpp_stanza_t **child = children;
if (!parent)
{
parent = xmpp_stanza_new(context);
xmpp_stanza_set_name(parent, "bundle");
}
if (ns)
{
xmpp_stanza_set_ns(parent, ns->value);
ns->finalize(ns);
free(ns);
}
while (child && *child)
{
xmpp_stanza_add_child(parent, *child);
xmpp_stanza_release(*child++);
}
return parent;
}
xmpp_stanza_t *stanza__iq_pubsub_publish_item_bundle_signedPreKeyPublic(
xmpp_ctx_t *context, xmpp_stanza_t *base, struct t_string *id)
{
xmpp_stanza_t *parent = base;
if (!parent)
{
parent = xmpp_stanza_new(context);
xmpp_stanza_set_name(parent, "signedPreKeyPublic");
}
if (id)
{
xmpp_stanza_set_id(parent, id->value);
id->finalize(id);
free(id);
}
return parent;
}
xmpp_stanza_t *stanza__iq_pubsub_publish_item_bundle_signedPreKeySignature(
xmpp_ctx_t *context, xmpp_stanza_t *base, struct t_string *signedPreKeySignature)
{
}
xmpp_stanza_t *stanza__iq_pubsub_publish_item_bundle_identityKey(
xmpp_ctx_t *context, xmpp_stanza_t *base, struct t_string *identityKey)
{
}
xmpp_stanza_t *stanza__iq_pubsub_publish_item_bundle_preKeys(
xmpp_ctx_t *context, xmpp_stanza_t *base, struct t_string *preKeys)
{
}
xmpp_stanza_t *stanza__iq_pubsub_publish_item_bundle_preKeys_preKeyPublic(
xmpp_ctx_t *context, xmpp_stanza_t *base, struct t_string *preKeyPublic)
{
}
xmpp_stanza_t *stanza__iq_ping(xmpp_ctx_t *context, xmpp_stanza_t *base,
struct t_string *ns)
{

@ -74,6 +74,24 @@ xmpp_stanza_t *stanza__iq_pubsub_publish_item_list(xmpp_ctx_t *context, xmpp_sta
xmpp_stanza_t *stanza__iq_pubsub_publish_item_list_device(xmpp_ctx_t *context, xmpp_stanza_t *base,
struct t_string *id);
xmpp_stanza_t *stanza__iq_pubsub_publish_item_bundle(xmpp_ctx_t *context, xmpp_stanza_t *base,
xmpp_stanza_t **children, struct t_string *ns);
xmpp_stanza_t *stanza__iq_pubsub_publish_item_bundle_signedPreKeyPublic(
xmpp_ctx_t *context, xmpp_stanza_t *base, struct t_string *signedPreKeyId);
xmpp_stanza_t *stanza__iq_pubsub_publish_item_bundle_signedPreKeySignature(
xmpp_ctx_t *context, xmpp_stanza_t *base, struct t_string *signedPreKeySignature);
xmpp_stanza_t *stanza__iq_pubsub_publish_item_bundle_identityKey(
xmpp_ctx_t *context, xmpp_stanza_t *base, struct t_string *identityKey);
xmpp_stanza_t *stanza__iq_pubsub_publish_item_bundle_preKeys(
xmpp_ctx_t *context, xmpp_stanza_t *base, struct t_string *preKeys);
xmpp_stanza_t *stanza__iq_pubsub_publish_item_bundle_preKeys_preKeyPublic(
xmpp_ctx_t *context, xmpp_stanza_t *base, struct t_string *preKeyPublic);
xmpp_stanza_t *stanza__iq_ping(xmpp_ctx_t *context, xmpp_stanza_t *base,
struct t_string *ns);

Loading…
Cancel
Save