1
0
mirror of https://github.com/qTox/qTox.git synced 2024-03-22 14:00:36 +08:00

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.
This commit is contained in:
Anthony Bilinski 2022-03-28 01:26:30 -07:00
parent 71c3f997b4
commit cfe18f8340
No known key found for this signature in database
GPG Key ID: 2AA8E0DA1B31FB3C
5 changed files with 13 additions and 0 deletions

View File

@ -41,6 +41,7 @@ public:
const uint8_t* getData() const; const uint8_t* getData() const;
bool isEmpty() const; bool isEmpty() const;
virtual int getSize() const = 0; virtual int getSize() const = 0;
virtual std::unique_ptr<ChatId> clone() const = 0;
protected: protected:
ChatId(); ChatId();

View File

@ -67,3 +67,8 @@ int GroupId::getSize() const
{ {
return size; return size;
} }
std::unique_ptr<ChatId> GroupId::clone() const
{
return std::unique_ptr<ChatId>(new GroupId(*this));
}

View File

@ -31,4 +31,5 @@ public:
explicit GroupId(const QByteArray& rawId); explicit GroupId(const QByteArray& rawId);
explicit GroupId(const uint8_t* rawId); explicit GroupId(const uint8_t* rawId);
int getSize() const override; int getSize() const override;
std::unique_ptr<ChatId> clone() const override;
}; };

View File

@ -87,3 +87,8 @@ int ToxPk::getSize() const
{ {
return size; return size;
} }
std::unique_ptr<ChatId> ToxPk::clone() const
{
return std::unique_ptr<ChatId>(new ToxPk(*this));
}

View File

@ -33,4 +33,5 @@ public:
explicit ToxPk(const uint8_t* rawId); explicit ToxPk(const uint8_t* rawId);
explicit ToxPk(const QString& pk); explicit ToxPk(const QString& pk);
int getSize() const override; int getSize() const override;
std::unique_ptr<ChatId> clone() const override;
}; };