From cfe18f834011237bc5503fc4aaed732914e170a2 Mon Sep 17 00:00:00 2001 From: Anthony Bilinski Date: Mon, 28 Mar 2022 01:26:30 -0700 Subject: [PATCH] refactor(ContactId): Add clone function to ChatId interface So that History can load history messages without needing to know what type of Chat the messages are from. --- src/core/chatid.h | 1 + src/core/groupid.cpp | 5 +++++ src/core/groupid.h | 1 + src/core/toxpk.cpp | 5 +++++ src/core/toxpk.h | 1 + 5 files changed, 13 insertions(+) diff --git a/src/core/chatid.h b/src/core/chatid.h index d3bf9da6e..c75edbdb9 100644 --- a/src/core/chatid.h +++ b/src/core/chatid.h @@ -41,6 +41,7 @@ public: const uint8_t* getData() const; bool isEmpty() const; virtual int getSize() const = 0; + virtual std::unique_ptr clone() const = 0; protected: ChatId(); diff --git a/src/core/groupid.cpp b/src/core/groupid.cpp index 296742113..680eb505a 100644 --- a/src/core/groupid.cpp +++ b/src/core/groupid.cpp @@ -67,3 +67,8 @@ int GroupId::getSize() const { return size; } + +std::unique_ptr GroupId::clone() const +{ + return std::unique_ptr(new GroupId(*this)); +} diff --git a/src/core/groupid.h b/src/core/groupid.h index 65e2db7bd..00fcee463 100644 --- a/src/core/groupid.h +++ b/src/core/groupid.h @@ -31,4 +31,5 @@ public: explicit GroupId(const QByteArray& rawId); explicit GroupId(const uint8_t* rawId); int getSize() const override; + std::unique_ptr clone() const override; }; diff --git a/src/core/toxpk.cpp b/src/core/toxpk.cpp index 7f1bfc2ff..6556946e8 100644 --- a/src/core/toxpk.cpp +++ b/src/core/toxpk.cpp @@ -87,3 +87,8 @@ int ToxPk::getSize() const { return size; } + +std::unique_ptr ToxPk::clone() const +{ + return std::unique_ptr(new ToxPk(*this)); +} diff --git a/src/core/toxpk.h b/src/core/toxpk.h index 8bf7033c9..29845f432 100644 --- a/src/core/toxpk.h +++ b/src/core/toxpk.h @@ -33,4 +33,5 @@ public: explicit ToxPk(const uint8_t* rawId); explicit ToxPk(const QString& pk); int getSize() const override; + std::unique_ptr clone() const override; };