2019-03-31 21:05:09 +00:00
|
|
|
#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
|
|
|
|
2019-03-31 21:05:09 +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,
|
2019-06-22 20:37:22 +00:00
|
|
|
invisible,
|
2019-04-07 14:02:41 +00:00
|
|
|
offline
|
|
|
|
};
|
|
|
|
|
2019-04-07 20:14:15 +00:00
|
|
|
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;
|
|
|
|
|
2019-04-07 20:14:15 +00:00
|
|
|
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 = {
|
2019-06-22 20:37:22 +00:00
|
|
|
"user-online",
|
|
|
|
"user-away",
|
|
|
|
"user-away-extended",
|
|
|
|
"user-busy",
|
2019-06-23 21:09:39 +00:00
|
|
|
"chatty",
|
2019-06-22 20:37:22 +00:00
|
|
|
"user-invisible",
|
|
|
|
"user-offline"
|
2019-04-07 20:14:15 +00:00
|
|
|
};
|
2019-06-22 20:37:22 +00:00
|
|
|
static const std::deque<QString> availabilityNames = {"Online", "Away", "Absent", "Busy", "Chatty", "Invisible", "Offline"};
|
2019-04-07 20:14:15 +00:00
|
|
|
|
|
|
|
static const std::deque<QString> subscriptionStateThemeIcons = {"edit-none", "arrow-down-double", "arrow-up-double", "dialog-ok", "question"};
|
2019-06-21 19:33:38 +00:00
|
|
|
static const std::deque<QString> subscriptionStateNames = {"None", "From", "To", "Both", "Unknown"};
|
2019-04-02 15:46:18 +00:00
|
|
|
|
2019-05-15 17:36:37 +00:00
|
|
|
QString generateUUID();
|
|
|
|
|
2019-04-10 20:53:42 +00:00
|
|
|
class Message {
|
|
|
|
public:
|
2019-04-11 14:58:59 +00:00
|
|
|
enum Type {
|
|
|
|
error,
|
|
|
|
normal,
|
|
|
|
chat,
|
|
|
|
groupChat,
|
|
|
|
headline
|
|
|
|
};
|
|
|
|
Message(Type p_type);
|
2019-04-10 20:53:42 +00:00
|
|
|
Message();
|
2019-04-11 14:58:59 +00:00
|
|
|
|
|
|
|
void setFrom(const QString& from);
|
2019-04-12 05:51:36 +00:00
|
|
|
void setFromResource(const QString& from);
|
|
|
|
void setFromJid(const QString& from);
|
2019-04-11 14:58:59 +00:00
|
|
|
void setTo(const QString& to);
|
2019-04-12 05:51:36 +00:00
|
|
|
void setToResource(const QString& to);
|
|
|
|
void setToJid(const QString& to);
|
2019-04-11 14:58:59 +00:00
|
|
|
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);
|
2019-04-12 05:51:36 +00:00
|
|
|
void setOutgoing(bool og);
|
2019-04-12 15:22:10 +00:00
|
|
|
void setForwarded(bool fwd);
|
|
|
|
void setType(Type t);
|
2019-05-15 17:36:37 +00:00
|
|
|
void setCurrentTime();
|
2019-04-11 14:58:59 +00:00
|
|
|
|
|
|
|
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;
|
2019-04-12 05:51:36 +00:00
|
|
|
bool getOutgoing() const;
|
2019-04-12 15:22:10 +00:00
|
|
|
bool getForwarded() const;
|
|
|
|
Type getType() const;
|
2019-04-11 14:58:59 +00:00
|
|
|
|
|
|
|
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;
|
2019-04-11 14:58:59 +00:00
|
|
|
QString id;
|
|
|
|
QString body;
|
2019-04-10 20:53:42 +00:00
|
|
|
QDateTime time;
|
2019-04-12 15:22:10 +00:00
|
|
|
QString thread;
|
2019-04-11 14:58:59 +00:00
|
|
|
Type type;
|
2019-04-12 05:51:36 +00:00
|
|
|
bool outgoing;
|
2019-04-12 15:22:10 +00:00
|
|
|
bool forwarded;
|
2019-04-10 20:53:42 +00:00
|
|
|
};
|
|
|
|
|
2019-06-23 21:09:39 +00:00
|
|
|
static const std::deque<QString> fallbackAvailabilityThemeIconsLightBig = {
|
|
|
|
":images/fallback/light/big/online.svg",
|
|
|
|
":images/fallback/light/big/away.svg",
|
|
|
|
":images/fallback/light/big/absent.svg",
|
|
|
|
":images/fallback/light/big/busy.svg",
|
|
|
|
":images/fallback/light/big/chatty.svg",
|
|
|
|
":images/fallback/light/big/invisible.svg",
|
|
|
|
":images/fallback/light/big/offline.svg"
|
|
|
|
};
|
|
|
|
|
2019-06-24 14:16:03 +00:00
|
|
|
static const std::deque<QString> fallbackSubscriptionStateThemeIconsLightBig = {
|
|
|
|
":images/fallback/light/big/edit-none.svg",
|
|
|
|
":images/fallback/light/big/arrow-down-double.svg",
|
|
|
|
":images/fallback/light/big/arrow-up-double.svg",
|
|
|
|
":images/fallback/light/big/dialog-ok.svg",
|
|
|
|
":images/fallback/light/big/question.svg"
|
|
|
|
};
|
|
|
|
|
2019-06-23 21:09:39 +00:00
|
|
|
static const std::deque<QString> fallbackAvailabilityThemeIconsLightSmall = {
|
|
|
|
":images/fallback/light/small/online.svg",
|
|
|
|
":images/fallback/light/small/away.svg",
|
|
|
|
":images/fallback/light/small/absent.svg",
|
|
|
|
":images/fallback/light/small/busy.svg",
|
|
|
|
":images/fallback/light/small/chatty.svg",
|
|
|
|
":images/fallback/light/small/invisible.svg",
|
|
|
|
":images/fallback/light/small/offline.svg"
|
|
|
|
};
|
|
|
|
|
2019-06-24 14:16:03 +00:00
|
|
|
static const std::deque<QString> fallbackSubscriptionStateThemeIconsLightSmall = {
|
|
|
|
":images/fallback/light/small/edit-none.svg",
|
|
|
|
":images/fallback/light/small/arrow-down-double.svg",
|
|
|
|
":images/fallback/light/small/arrow-up-double.svg",
|
|
|
|
":images/fallback/light/small/dialog-ok.svg",
|
|
|
|
":images/fallback/light/small/question.svg"
|
|
|
|
};
|
|
|
|
|
2019-06-23 21:09:39 +00:00
|
|
|
static const std::deque<QString> fallbackAvailabilityThemeIconsDarkBig = {
|
|
|
|
":images/fallback/dark/big/online.svg",
|
|
|
|
":images/fallback/dark/big/away.svg",
|
|
|
|
":images/fallback/dark/big/absent.svg",
|
|
|
|
":images/fallback/dark/big/busy.svg",
|
|
|
|
":images/fallback/dark/big/chatty.svg",
|
|
|
|
":images/fallback/dark/big/invisible.svg",
|
|
|
|
":images/fallback/dark/big/offline.svg"
|
|
|
|
};
|
|
|
|
|
2019-06-24 14:16:03 +00:00
|
|
|
static const std::deque<QString> fallbackSubscriptionStateThemeIconsDarkBig = {
|
|
|
|
":images/fallback/dark/big/edit-none.svg",
|
|
|
|
":images/fallback/dark/big/arrow-down-double.svg",
|
|
|
|
":images/fallback/dark/big/arrow-up-double.svg",
|
|
|
|
":images/fallback/dark/big/dialog-ok.svg",
|
|
|
|
":images/fallback/dark/big/question.svg"
|
|
|
|
};
|
|
|
|
|
2019-06-23 21:09:39 +00:00
|
|
|
static const std::deque<QString> fallbackAvailabilityThemeIconsDarkSmall = {
|
|
|
|
":images/fallback/dark/small/online.svg",
|
|
|
|
":images/fallback/dark/small/away.svg",
|
|
|
|
":images/fallback/dark/small/absent.svg",
|
|
|
|
":images/fallback/dark/small/busy.svg",
|
|
|
|
":images/fallback/dark/small/chatty.svg",
|
|
|
|
":images/fallback/dark/small/invisible.svg",
|
|
|
|
":images/fallback/dark/small/offline.svg"
|
|
|
|
};
|
|
|
|
|
2019-06-24 14:16:03 +00:00
|
|
|
static const std::deque<QString> fallbackSubscriptionStateThemeIconsDarkSmall = {
|
|
|
|
":images/fallback/dark/small/edit-none.svg",
|
|
|
|
":images/fallback/dark/small/arrow-down-double.svg",
|
|
|
|
":images/fallback/dark/small/arrow-up-double.svg",
|
|
|
|
":images/fallback/dark/small/dialog-ok.svg",
|
|
|
|
":images/fallback/dark/small/question.svg"
|
|
|
|
};
|
|
|
|
|
2019-06-23 21:09:39 +00:00
|
|
|
QIcon availabilityIcon(Availability av, bool big = false);
|
2019-06-24 14:16:03 +00:00
|
|
|
QIcon subscriptionStateIcon(SubscriptionState ss, bool big = false);
|
2019-06-23 21:09:39 +00:00
|
|
|
|
2019-03-31 21:05:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // GLOBAL_H
|