summaryrefslogtreecommitdiff
path: root/src/message.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/message.h')
-rw-r--r--src/message.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/message.h b/src/message.h
new file mode 100644
index 0000000..48487ba
--- /dev/null
+++ b/src/message.h
@@ -0,0 +1,57 @@
+#pragma once
+
+#include <erebos/identity.h>
+#include <erebos/message.h>
+#include <erebos/storage.h>
+
+#include <mutex>
+#include <vector>
+
+namespace chrono = std::chrono;
+using chrono::system_clock;
+using std::mutex;
+using std::optional;
+using std::string;
+using std::vector;
+
+namespace erebos {
+
+struct DirectMessageData
+{
+ static optional<DirectMessageData> load(const Ref &);
+ Ref store(const Storage &) const;
+
+ vector<Stored<DirectMessageData>> prev;
+ Identity from;
+ ZonedTime time;
+ string text;
+};
+
+struct DirectMessage::Priv
+{
+ Stored<DirectMessageData> data;
+};
+
+struct DirectMessageThread::Priv
+{
+ const Identity peer;
+ const vector<Stored<DirectMessageData>> head;
+
+ static DirectMessageThread getThreadLocked(const Identity & peer);
+ static DirectMessageThread updateThreadLocked(const Identity & peer,
+ vector<Stored<DirectMessageData>> && head);
+};
+
+struct DirectMessageThread::Iterator::Priv
+{
+ optional<DirectMessage> current;
+ vector<Stored<DirectMessageData>> next;
+};
+
+struct DirectMessageService::Priv
+{
+ static vector<ThreadWatcher> watchers;
+ static mutex watcherLock;
+};
+
+}