#pragma once #include #include #include #include #include #include #include #include #include #include namespace erebos { using std::optional; using std::shared_ptr; using std::string; using std::vector; struct ContactData; class Contact { public: Contact(vector> data); Contact(const Contact &) = default; Contact(Contact &&) = default; Contact & operator=(const Contact &) = default; Contact & operator=(Contact &&) = default; optional identity() const; optional customName() const; Contact customName(const Storage & st, const string & name) const; string name() const; bool operator==(const Contact &) const; bool operator!=(const Contact &) const; vector> data() const; Digest leastRoot() const; private: struct Priv; shared_ptr p; Contact(shared_ptr p): p(p) {} friend class ContactService; }; DECLARE_SHARED_TYPE(Set) struct ContactData { static ContactData load(const Ref &); Ref store(const Storage &) const; vector> prev; vector>> identity; optional name; }; template<> struct Mergeable { using Component = ContactData; static vector> components(const Contact & c) { return c.data(); } static Contact merge(vector> x) { return Contact(move(x)); } }; struct ContactAccepted; class ContactService : public PairingService { public: ContactService(Config &&, const Server &); virtual ~ContactService(); UUID uuid() const override; void request(const Peer &); protected: virtual Stored handlePairingComplete(const Peer &) override; virtual void handlePairingResult(Context &, Stored) override; const Server & server; }; template class Signed; struct ContactAccepted { static ContactAccepted load(const Ref &); Ref store(const Storage &) const; }; }