summaryrefslogtreecommitdiff
path: root/include/erebos/attach.h
blob: dab01105d5a0b5566b18305f3e645d4fc704b7cf (plain)
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
#pragma once

#include <erebos/pairing.h>

#include <future>
#include <mutex>
#include <optional>
#include <string>
#include <vector>

namespace erebos {

using std::mutex;
using std::optional;
using std::promise;
using std::string;
using std::vector;

struct AttachIdentity;

class AttachService : public PairingService<AttachIdentity>
{
public:
	AttachService();
	virtual ~AttachService();

	UUID uuid() const override;

	void attachTo(const Peer &);

protected:
	virtual Stored<AttachIdentity> handlePairingComplete(const Peer &) override;
	virtual void handlePairingResult(Context &, Stored<AttachIdentity>) override;

	mutex handlerLock;
};

template<class T> class Signed;

struct AttachIdentity
{
	Stored<Signed<struct IdentityData>> identity;
	vector<vector<uint8_t>> keys;

	static AttachIdentity load(const Ref &);
	Ref store(const Storage &) const;
};

}