1
0
forked from blue/squawk

first thoughts on message states

This commit is contained in:
Blue 2020-01-02 15:04:49 +03:00
parent 52efc2b1a4
commit 5a59d54b18
2 changed files with 47 additions and 4 deletions

View File

@ -34,7 +34,9 @@ Shared::Message::Message(Shared::Message::Type p_type):
thread(), thread(),
type(p_type), type(p_type),
outgoing(false), outgoing(false),
forwarded(false) forwarded(false),
state(State::delivered),
edited(false)
{ {
} }
@ -49,7 +51,9 @@ Shared::Message::Message():
thread(), thread(),
type(Message::normal), type(Message::normal),
outgoing(false), outgoing(false),
forwarded(false) forwarded(false),
state(State::delivered),
edited(false)
{ {
} }
@ -161,6 +165,16 @@ QString Shared::Message::getPenPalResource() const
} }
} }
Shared::Message::State Shared::Message::getState() const
{
return state;
}
bool Shared::Message::getEdited() const
{
return edited;
}
void Shared::Message::setFromJid(const QString& from) void Shared::Message::setFromJid(const QString& from)
{ {
jFrom = from; jFrom = from;
@ -226,6 +240,16 @@ void Shared::Message::setType(Shared::Message::Type t)
type = t; type = t;
} }
void Shared::Message::setState(Shared::Message::State p_state)
{
state = p_state;
}
void Shared::Message::setEdited(bool p_edited)
{
edited = p_edited;
}
void Shared::Message::serialize(QDataStream& data) const void Shared::Message::serialize(QDataStream& data) const
{ {
data << jFrom; data << jFrom;
@ -236,11 +260,12 @@ void Shared::Message::serialize(QDataStream& data) const
data << body; data << body;
data << time; data << time;
data << thread; data << thread;
quint8 t = type; data << (quint8)type;
data << t;
data << outgoing; data << outgoing;
data << forwarded; data << forwarded;
data << oob; data << oob;
data << (quint8)state;
data << edited;
} }
void Shared::Message::deserialize(QDataStream& data) void Shared::Message::deserialize(QDataStream& data)
@ -259,6 +284,10 @@ void Shared::Message::deserialize(QDataStream& data)
data >> outgoing; data >> outgoing;
data >> forwarded; data >> forwarded;
data >> oob; data >> oob;
quint8 s;
data >> s;
state = static_cast<State>(s);
data >> edited;
} }
QString Shared::generateUUID() QString Shared::generateUUID()

View File

@ -157,6 +157,14 @@ public:
groupChat, groupChat,
headline headline
}; };
enum class State {
pending,
sent,
delivered,
error
};
Message(Type p_type); Message(Type p_type);
Message(); Message();
@ -175,6 +183,8 @@ public:
void setType(Type t); void setType(Type t);
void setCurrentTime(); void setCurrentTime();
void setOutOfBandUrl(const QString& url); void setOutOfBandUrl(const QString& url);
void setState(State p_state);
void setEdited(bool p_edited);
QString getFrom() const; QString getFrom() const;
QString getFromJid() const; QString getFromJid() const;
@ -192,6 +202,8 @@ public:
bool hasOutOfBandUrl() const; bool hasOutOfBandUrl() const;
bool storable() const; bool storable() const;
QString getOutOfBandUrl() const; QString getOutOfBandUrl() const;
State getState() const;
bool getEdited() const;
QString getPenPalJid() const; QString getPenPalJid() const;
QString getPenPalResource() const; QString getPenPalResource() const;
@ -213,6 +225,8 @@ private:
bool outgoing; bool outgoing;
bool forwarded; bool forwarded;
QString oob; QString oob;
State state;
bool edited;
}; };
class VCard { class VCard {