squawk/global.h

120 lines
2.8 KiB
C
Raw Normal View History

#ifndef GLOBAL_H
#define GLOBAL_H
2019-04-02 15:46:18 +00:00
#include <QString>
#include <deque>
2019-04-10 20:53:42 +00:00
#include <QDateTime>
2019-04-15 22:35:09 +00:00
#include <QDataStream>
2019-04-02 15:46:18 +00:00
namespace Shared {
enum ConnectionState {
disconnected,
connecting,
connected,
error
};
2019-04-07 14:02:41 +00:00
enum Availability {
online,
away,
extendedAway,
busy,
chatty,
offline
};
enum SubscriptionState {
none,
from,
to,
both,
unknown
};
2019-04-07 14:02:41 +00:00
static const Availability availabilityHighest = offline;
static const Availability availabilityLowest = online;
static const SubscriptionState subscriptionStateHighest = unknown;
static const SubscriptionState subscriptionStateLowest = none;
static const std::deque<QString> connectionStateNames = {"Disconnected", "Connecting", "Connected", "Error"};
static const std::deque<QString> connectionStateThemeIcons = {"network-disconnect", "view-refresh", "network-connect", "state-error"};
static const std::deque<QString> availabilityThemeIcons = {
"im-user-online",
"im-user-away",
"im-user-away",
"im-user-busy",
"im-user-online",
"im-user-offline"
};
static const std::deque<QString> availabilityNames = {"Online", "Away", "Absent", "Busy", "Chatty", "Offline"};
static const std::deque<QString> subscriptionStateThemeIcons = {"edit-none", "arrow-down-double", "arrow-up-double", "dialog-ok", "question"};
2019-04-02 15:46:18 +00:00
2019-04-10 20:53:42 +00:00
class Message {
public:
enum Type {
error,
normal,
chat,
groupChat,
headline
};
Message(Type p_type);
2019-04-10 20:53:42 +00:00
Message();
void setFrom(const QString& from);
void setFromResource(const QString& from);
void setFromJid(const QString& from);
void setTo(const QString& to);
void setToResource(const QString& to);
void setToJid(const QString& to);
void setTime(const QDateTime& p_time);
void setId(const QString& p_id);
void setBody(const QString& p_body);
2019-04-12 15:22:10 +00:00
void setThread(const QString& p_body);
void setOutgoing(bool og);
2019-04-12 15:22:10 +00:00
void setForwarded(bool fwd);
void setType(Type t);
QString getFrom() const;
QString getFromJid() const;
QString getFromResource() const;
QString getTo() const;
QString getToJid() const;
QString getToResource() const;
QDateTime getTime() const;
QString getId() const;
QString getBody() const;
2019-04-12 15:22:10 +00:00
QString getThread() const;
bool getOutgoing() const;
2019-04-12 15:22:10 +00:00
bool getForwarded() const;
Type getType() const;
QString getPenPalJid() const;
QString getPenPalResource() const;
2019-04-12 15:22:10 +00:00
void generateRandomId();
2019-04-10 20:53:42 +00:00
2019-04-15 22:35:09 +00:00
void serialize(QDataStream& data) const;
void deserialize(QDataStream& data);
2019-04-10 20:53:42 +00:00
private:
QString jFrom;
QString rFrom;
QString jTo;
QString rTo;
QString id;
QString body;
2019-04-10 20:53:42 +00:00
QDateTime time;
2019-04-12 15:22:10 +00:00
QString thread;
Type type;
bool outgoing;
2019-04-12 15:22:10 +00:00
bool forwarded;
2019-04-10 20:53:42 +00:00
};
};
#endif // GLOBAL_H