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.

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