aboutsummaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-rw-r--r--include/Channel.hpp4
-rw-r--r--include/User.hpp36
2 files changed, 30 insertions, 10 deletions
diff --git a/include/Channel.hpp b/include/Channel.hpp
index 93f3725..6e944c3 100644
--- a/include/Channel.hpp
+++ b/include/Channel.hpp
@@ -51,8 +51,8 @@ namespace dchat
void deleteMessage(const odhtdb::Hash &id, const odhtdb::Signature::PublicKey &requestedByUser);
void addUserLocally(User *user);
- bool addUser(const odhtdb::Signature::PublicKey &userId, const std::string &groupId);
- void replaceLocalUser(User *newLocalUser);
+ bool addUser(const odhtdb::Signature::PublicKey &userId, const odhtdb::DataView &groupId);
+ void replaceLocalUser(OnlineLocalUser *newOnlineLocalUser);
void changeNick(const std::string &newNick);
void processEvent(const sf::Event &event);
diff --git a/include/User.hpp b/include/User.hpp
index a83b9dc..85418dc 100644
--- a/include/User.hpp
+++ b/include/User.hpp
@@ -1,11 +1,7 @@
#pragma once
#include <string>
-
-namespace odhtdb
-{
- class User;
-}
+#include <odhtdb/Signature.hpp>
namespace dchat
{
@@ -14,7 +10,8 @@ namespace dchat
public:
enum class Type
{
- ONLINE,
+ ONLINE_REMOTE_USER,
+ ONLINE_LOCAL_USER,
OFFLINE,
SYSTEM
};
@@ -22,6 +19,7 @@ namespace dchat
User(Type type);
virtual ~User(){}
virtual const std::string& getName() const = 0;
+ virtual bool isOnlineUser() const { return false; }
const Type type;
std::string avatarUrl;
@@ -30,11 +28,33 @@ namespace dchat
class OnlineUser : public User
{
public:
- OnlineUser(const odhtdb::User *databaseUser);
+ OnlineUser(const std::string &name, Type type);
+ virtual ~OnlineUser(){}
+
virtual const std::string& getName() const override;
+ virtual const odhtdb::Signature::PublicKey& getPublicKey() const = 0;
+
+ bool isOnlineUser() const override { return true; }
std::string name;
- const odhtdb::User *databaseUser;
+ };
+
+ class OnlineRemoteUser : public OnlineUser
+ {
+ public:
+ OnlineRemoteUser(const std::string &name, const odhtdb::Signature::PublicKey &publicKey);
+ virtual const odhtdb::Signature::PublicKey& getPublicKey() const override;
+
+ const odhtdb::Signature::PublicKey publicKey;
+ };
+
+ class OnlineLocalUser : public OnlineUser
+ {
+ public:
+ OnlineLocalUser(const std::string &name, const odhtdb::Signature::KeyPair &keyPair);
+ virtual const odhtdb::Signature::PublicKey& getPublicKey() const override;
+
+ const odhtdb::Signature::KeyPair keyPair;
};
class OfflineUser : public User