-
Notifications
You must be signed in to change notification settings - Fork 4
/
omemo.hh
80 lines (60 loc) · 2.11 KB
/
omemo.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// 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/.
#pragma once
#include <memory>
#include <functional>
#include <cstdint>
#include <string>
#include <strophe.h>
#include <lmdb++.h>
#include <signal_protocol.h>
#include "signal.hh"
extern const char *OMEMO_ADVICE;
namespace weechat {
class account;
namespace xmpp {
struct t_pre_key {
const char *id;
const char *public_key;
};
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;
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();
inline operator bool() { return this->context && this->store_context &&
this->identity && this->device_id != 0; }
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(weechat::account *account, const char *jid,
xmpp_stanza_t *encrypted);
xmpp_stanza_t *encode(weechat::account *account, const char *jid,
const char *unencrypted);
};
}
}