You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

80 lines
1.8 KiB
C++

// 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/.
3 years ago
#pragma once
3 years ago
#include <memory>
#include <functional>
#include <cstdint>
#include <string>
#include <strophe.h>
#include <lmdb++.h>
#include <signal_protocol.h>
3 years ago
3 years ago
#include "signal.hh"
struct t_account;
3 years ago
3 years ago
extern const char *OMEMO_ADVICE;
4 years ago
3 years ago
namespace weechat::xmpp {
4 years ago
3 years ago
struct t_pre_key {
const char *id;
const char *public_key;
4 years ago
};
3 years ago
struct omemo
{
3 years ago
libsignal::context context;
libsignal::store_context store_context;
lmdb::env db_env = nullptr;
struct dbi {
lmdb::dbi omemo;
} dbi;
3 years ago
std::string db_path;
3 years ago
libsignal::identity_key_pair identity;
3 years ago
std::uint32_t device_id;
3 years ago
3 years ago
class bundle_request
{
public:
std::string id;
std::string jid;
std::string device;
std::string message_text;
};
3 years ago
class devicelist_request
{
public:
std::string id;
bundle_request bundle_req;
};
3 years ago
~omemo();
3 years ago
3 years ago
inline operator bool() { return this->context && this->store_context &&
this->identity && this->device_id != 0; }
4 years ago
3 years ago
xmpp_stanza_t *get_bundle(xmpp_ctx_t *context, char *from, char *to);
void init(struct t_gui_buffer *buffer, const char *account_name);
void handle_devicelist(const char *jid, xmpp_stanza_t *items);
void handle_bundle(const char *jid, std::uint32_t device_id,
xmpp_stanza_t *items);
char *decode(struct t_account *account, const char *jid,
xmpp_stanza_t *encrypted);
xmpp_stanza_t *encode(struct t_account *account, const char *jid,
const char *unencrypted);
};
3 years ago
}