Shared namespace refactoring, enum class refactoring, going offline related crash fix

This commit is contained in:
Blue 2020-04-04 01:28:15 +03:00
parent b309100f99
commit ddfb3419cc
59 changed files with 1948 additions and 1695 deletions

View File

@ -25,9 +25,25 @@ message("Build type: ${CMAKE_BUILD_TYPE}")
set(squawk_SRC set(squawk_SRC
main.cpp main.cpp
global.cpp
exception.cpp exception.cpp
signalcatcher.cpp signalcatcher.cpp
shared/global.cpp
shared/utils.cpp
shared/message.cpp
shared/vcard.cpp
shared/icons.cpp
)
set(squawk_HEAD
exception.h
signalcatcher.h
shared.h
shared/enums.h
shared/message.h
shared/global.h
shared/utils.h
shared/vcard.h
shared/icons.h
) )
configure_file(resources/images/logo.svg squawk.svg COPYONLY) configure_file(resources/images/logo.svg squawk.svg COPYONLY)
@ -46,7 +62,7 @@ add_custom_target(translations ALL DEPENDS ${QM_FILES})
qt5_add_resources(RCC resources/resources.qrc) qt5_add_resources(RCC resources/resources.qrc)
add_executable(squawk ${squawk_SRC} ${RCC}) add_executable(squawk ${squawk_SRC} ${squawk_HEAD} ${RCC})
target_link_libraries(squawk Qt5::Widgets) target_link_libraries(squawk Qt5::Widgets)
option(SYSTEM_QXMPP "Use system qxmpp lib" ON) option(SYSTEM_QXMPP "Use system qxmpp lib" ON)

View File

@ -30,7 +30,7 @@ Account::Account(const QString& p_login, const QString& p_server, const QString&
client(), client(),
config(), config(),
presence(), presence(),
state(Shared::disconnected), state(Shared::ConnectionState::disconnected),
groups(), groups(),
cm(new QXmppCarbonManager()), cm(new QXmppCarbonManager()),
am(new QXmppMamManager()), am(new QXmppMamManager()),
@ -182,9 +182,9 @@ Shared::ConnectionState Core::Account::getState() const
void Core::Account::connect() void Core::Account::connect()
{ {
if (state == Shared::disconnected) { if (state == Shared::ConnectionState::disconnected) {
reconnectTimes = maxReconnectTimes; reconnectTimes = maxReconnectTimes;
state = Shared::connecting; state = Shared::ConnectionState::connecting;
client.connectToServer(config, presence); client.connectToServer(config, presence);
emit connectionStateChanged(state); emit connectionStateChanged(state);
} else { } else {
@ -195,19 +195,19 @@ void Core::Account::connect()
void Core::Account::disconnect() void Core::Account::disconnect()
{ {
reconnectTimes = 0; reconnectTimes = 0;
if (state != Shared::disconnected) { if (state != Shared::ConnectionState::disconnected) {
clearConferences(); clearConferences();
client.disconnectFromServer(); client.disconnectFromServer();
state = Shared::disconnected; state = Shared::ConnectionState::disconnected;
emit connectionStateChanged(state); emit connectionStateChanged(state);
} }
} }
void Core::Account::onClientConnected() void Core::Account::onClientConnected()
{ {
if (state == Shared::connecting) { if (state == Shared::ConnectionState::connecting) {
reconnectTimes = maxReconnectTimes; reconnectTimes = maxReconnectTimes;
state = Shared::connected; state = Shared::ConnectionState::connected;
dm->requestItems(getServer()); dm->requestItems(getServer());
dm->requestInfo(getServer()); dm->requestInfo(getServer());
emit connectionStateChanged(state); emit connectionStateChanged(state);
@ -219,16 +219,16 @@ void Core::Account::onClientConnected()
void Core::Account::onClientDisconnected() void Core::Account::onClientDisconnected()
{ {
clearConferences(); clearConferences();
if (state != Shared::disconnected) { if (state != Shared::ConnectionState::disconnected) {
if (reconnectTimes > 0) { if (reconnectTimes > 0) {
qDebug() << "Account" << name << "is reconnecting for" << reconnectTimes << "more times"; qDebug() << "Account" << name << "is reconnecting for" << reconnectTimes << "more times";
--reconnectTimes; --reconnectTimes;
state = Shared::connecting; state = Shared::ConnectionState::connecting;
client.connectToServer(config, presence); client.connectToServer(config, presence);
emit connectionStateChanged(state); emit connectionStateChanged(state);
} else { } else {
qDebug() << "Account" << name << "has been disconnected"; qDebug() << "Account" << name << "has been disconnected";
state = Shared::disconnected; state = Shared::ConnectionState::disconnected;
emit connectionStateChanged(state); emit connectionStateChanged(state);
} }
} else { } else {
@ -238,7 +238,7 @@ void Core::Account::onClientDisconnected()
void Core::Account::reconnect() void Core::Account::reconnect()
{ {
if (state == Shared::connected) { if (state == Shared::ConnectionState::connected) {
++reconnectTimes; ++reconnectTimes;
client.disconnectFromServer(); client.disconnectFromServer();
} else { } else {
@ -281,7 +281,7 @@ void Core::Account::onRosterReceived()
void Core::Account::setReconnectTimes(unsigned int times) void Core::Account::setReconnectTimes(unsigned int times)
{ {
maxReconnectTimes = times; maxReconnectTimes = times;
if (state == Shared::connected) { if (state == Shared::ConnectionState::connected) {
reconnectTimes = times; reconnectTimes = times;
} }
} }
@ -355,7 +355,7 @@ void Core::Account::addedAccount(const QString& jid)
if (newContact) { if (newContact) {
QMap<QString, QVariant> cData({ QMap<QString, QVariant> cData({
{"name", re.name()}, {"name", re.name()},
{"state", state} {"state", QVariant::fromValue(state)}
}); });
Archive::AvatarInfo info; Archive::AvatarInfo info;
@ -427,7 +427,7 @@ void Core::Account::onPresenceReceived(const QXmppPresence& p_presence)
if (jid == myJid) { if (jid == myJid) {
if (resource == getResource()) { if (resource == getResource()) {
emit availabilityChanged(p_presence.availableStatusType()); emit availabilityChanged(static_cast<Shared::Availability>(p_presence.availableStatusType()));
} else { } else {
if (!ownVCardRequestInProgress) { if (!ownVCardRequestInProgress) {
switch (p_presence.vCardUpdateType()) { switch (p_presence.vCardUpdateType()) {
@ -521,22 +521,26 @@ void Core::Account::setServer(const QString& p_server)
Shared::Availability Core::Account::getAvailability() const Shared::Availability Core::Account::getAvailability() const
{ {
if (state == Shared::connected) { if (state == Shared::ConnectionState::connected) {
QXmppPresence::AvailableStatusType pres = presence.availableStatusType(); QXmppPresence::AvailableStatusType pres = presence.availableStatusType();
return static_cast<Shared::Availability>(pres); //they are compatible; return static_cast<Shared::Availability>(pres); //they are compatible;
} else { } else {
return Shared::offline; return Shared::Availability::offline;
} }
} }
void Core::Account::setAvailability(Shared::Availability avail) void Core::Account::setAvailability(Shared::Availability avail)
{ {
if (avail == Shared::Availability::offline) {
disconnect(); //TODO not sure how to do here - changing state may cause connection or disconnection
} else {
QXmppPresence::AvailableStatusType pres = static_cast<QXmppPresence::AvailableStatusType>(avail); QXmppPresence::AvailableStatusType pres = static_cast<QXmppPresence::AvailableStatusType>(avail);
presence.setAvailableStatusType(pres); presence.setAvailableStatusType(pres);
if (state != Shared::disconnected) { //TODO not sure how to do here - changing state may cause connection or disconnection if (state != Shared::ConnectionState::disconnected) {
client.setClientPresence(presence); client.setClientPresence(presence);
} }
}
} }
QString Core::Account::getResource() const QString Core::Account::getResource() const
@ -624,7 +628,7 @@ void Core::Account::sendMessage(Shared::Message data)
QString jid = data.getPenPalJid(); QString jid = data.getPenPalJid();
QString id = data.getId(); QString id = data.getId();
RosterItem* ri = getRosterItem(jid); RosterItem* ri = getRosterItem(jid);
if (state == Shared::connected) { if (state == Shared::ConnectionState::connected) {
QXmppMessage msg(getFullJid(), data.getTo(), data.getBody(), data.getThread()); QXmppMessage msg(getFullJid(), data.getTo(), data.getBody(), data.getThread());
msg.setId(id); msg.setId(id);
msg.setType(static_cast<QXmppMessage::Type>(data.getType())); //it is safe here, my type is compatible msg.setType(static_cast<QXmppMessage::Type>(data.getType())); //it is safe here, my type is compatible
@ -660,7 +664,7 @@ void Core::Account::sendMessage(Shared::Message data)
void Core::Account::sendMessage(const Shared::Message& data, const QString& path) void Core::Account::sendMessage(const Shared::Message& data, const QString& path)
{ {
if (state == Shared::connected) { if (state == Shared::ConnectionState::connected) {
QString url = network->getFileRemoteUrl(path); QString url = network->getFileRemoteUrl(path);
if (url.size() != 0) { if (url.size() != 0) {
sendMessageWithLocalUploadedFile(data, url); sendMessageWithLocalUploadedFile(data, url);
@ -727,9 +731,9 @@ bool Core::Account::handleChatMessage(const QXmppMessage& msg, bool outgoing, bo
cnt = new Contact(jid, name); cnt = new Contact(jid, name);
contacts.insert(std::make_pair(jid, cnt)); contacts.insert(std::make_pair(jid, cnt));
outOfRosterContacts.insert(jid); outOfRosterContacts.insert(jid);
cnt->setSubscriptionState(Shared::unknown); cnt->setSubscriptionState(Shared::SubscriptionState::unknown);
emit addContact(jid, "", QMap<QString, QVariant>({ emit addContact(jid, "", QMap<QString, QVariant>({
{"state", Shared::unknown} {"state", QVariant::fromValue(Shared::SubscriptionState::unknown)}
})); }));
handleNewContact(cnt); handleNewContact(cnt);
} }
@ -963,7 +967,7 @@ void Core::Account::onContactGroupAdded(const QString& group)
QMap<QString, QVariant> cData({ QMap<QString, QVariant> cData({
{"name", contact->getName()}, {"name", contact->getName()},
{"state", contact->getSubscriptionState()} {"state", QVariant::fromValue(contact->getSubscriptionState())}
}); });
addToGroup(contact->jid, group); addToGroup(contact->jid, group);
emit addContact(contact->jid, group, cData); emit addContact(contact->jid, group, cData);
@ -993,7 +997,7 @@ void Core::Account::onContactSubscriptionStateChanged(Shared::SubscriptionState
{ {
Contact* contact = static_cast<Contact*>(sender()); Contact* contact = static_cast<Contact*>(sender());
QMap<QString, QVariant> cData({ QMap<QString, QVariant> cData({
{"state", cstate}, {"state", QVariant::fromValue(cstate)},
}); });
emit changeContact(contact->jid, cData); emit changeContact(contact->jid, cData);
} }
@ -1031,7 +1035,7 @@ Shared::SubscriptionState Core::Account::castSubscriptionState(QXmppRosterIq::It
{ {
Shared::SubscriptionState state; Shared::SubscriptionState state;
if (qs == QXmppRosterIq::Item::NotSet) { if (qs == QXmppRosterIq::Item::NotSet) {
state = Shared::unknown; state = Shared::SubscriptionState::unknown;
} else { } else {
state = static_cast<Shared::SubscriptionState>(qs); state = static_cast<Shared::SubscriptionState>(qs);
} }
@ -1145,7 +1149,7 @@ void Core::Account::onClientError(QXmppClient::Error err)
void Core::Account::subscribeToContact(const QString& jid, const QString& reason) void Core::Account::subscribeToContact(const QString& jid, const QString& reason)
{ {
if (state == Shared::connected) { if (state == Shared::ConnectionState::connected) {
rm->subscribe(jid, reason); rm->subscribe(jid, reason);
} else { } else {
qDebug() << "An attempt to subscribe account " << name << " to contact " << jid << " but the account is not in the connected state, skipping"; qDebug() << "An attempt to subscribe account " << name << " to contact " << jid << " but the account is not in the connected state, skipping";
@ -1154,7 +1158,7 @@ void Core::Account::subscribeToContact(const QString& jid, const QString& reason
void Core::Account::unsubscribeFromContact(const QString& jid, const QString& reason) void Core::Account::unsubscribeFromContact(const QString& jid, const QString& reason)
{ {
if (state == Shared::connected) { if (state == Shared::ConnectionState::connected) {
rm->unsubscribe(jid, reason); rm->unsubscribe(jid, reason);
} else { } else {
qDebug() << "An attempt to unsubscribe account " << name << " from contact " << jid << " but the account is not in the connected state, skipping"; qDebug() << "An attempt to unsubscribe account " << name << " from contact " << jid << " but the account is not in the connected state, skipping";
@ -1163,7 +1167,7 @@ void Core::Account::unsubscribeFromContact(const QString& jid, const QString& re
void Core::Account::removeContactRequest(const QString& jid) void Core::Account::removeContactRequest(const QString& jid)
{ {
if (state == Shared::connected) { if (state == Shared::ConnectionState::connected) {
std::set<QString>::const_iterator itr = outOfRosterContacts.find(jid); std::set<QString>::const_iterator itr = outOfRosterContacts.find(jid);
if (itr != outOfRosterContacts.end()) { if (itr != outOfRosterContacts.end()) {
outOfRosterContacts.erase(itr); outOfRosterContacts.erase(itr);
@ -1179,7 +1183,7 @@ void Core::Account::removeContactRequest(const QString& jid)
void Core::Account::addContactRequest(const QString& jid, const QString& name, const QSet<QString>& groups) void Core::Account::addContactRequest(const QString& jid, const QString& name, const QSet<QString>& groups)
{ {
if (state == Shared::connected) { if (state == Shared::ConnectionState::connected) {
std::map<QString, QString>::const_iterator itr = queuedContacts.find(jid); std::map<QString, QString>::const_iterator itr = queuedContacts.find(jid);
if (itr != queuedContacts.end()) { if (itr != queuedContacts.end()) {
qDebug() << "An attempt to add contact " << jid << " to account " << name << " but the account is already queued for adding, skipping"; qDebug() << "An attempt to add contact " << jid << " to account " << name << " but the account is already queued for adding, skipping";

View File

@ -43,7 +43,7 @@
#include <QXmppVCardManager.h> #include <QXmppVCardManager.h>
#include <QXmppMessageReceiptManager.h> #include <QXmppMessageReceiptManager.h>
#include "global.h" #include "shared.h"
#include "contact.h" #include "contact.h"
#include "conference.h" #include "conference.h"
#include "networkaccess.h" #include "networkaccess.h"
@ -101,8 +101,8 @@ public slots:
signals: signals:
void changed(const QMap<QString, QVariant>& data); void changed(const QMap<QString, QVariant>& data);
void connectionStateChanged(int); void connectionStateChanged(Shared::ConnectionState);
void availabilityChanged(int); void availabilityChanged(Shared::Availability);
void addGroup(const QString& name); void addGroup(const QString& name);
void removeGroup(const QString& name); void removeGroup(const QString& name);
void addRoom(const QString& jid, const QMap<QString, QVariant>& data); void addRoom(const QString& jid, const QMap<QString, QVariant>& data);

View File

@ -24,7 +24,7 @@
#include <QMimeDatabase> #include <QMimeDatabase>
#include <QMimeType> #include <QMimeType>
#include "global.h" #include "shared/message.h"
#include "exception.h" #include "exception.h"
#include <lmdb.h> #include <lmdb.h>
#include <list> #include <list>

View File

@ -22,7 +22,7 @@
Core::Contact::Contact(const QString& pJid, const QString& account, QObject* parent): Core::Contact::Contact(const QString& pJid, const QString& account, QObject* parent):
RosterItem(pJid, account, parent), RosterItem(pJid, account, parent),
groups(), groups(),
subscriptionState(Shared::unknown) subscriptionState(Shared::SubscriptionState::unknown)
{ {
} }

View File

@ -31,7 +31,9 @@
#include <QXmppVCardIq.h> #include <QXmppVCardIq.h>
#include <QXmppPresence.h> #include <QXmppPresence.h>
#include "../global.h" #include "shared/enums.h"
#include "shared/message.h"
#include "shared/vcard.h"
#include "archive.h" #include "archive.h"
namespace Core { namespace Core {

View File

@ -146,8 +146,8 @@ void Core::Squawk::addAccount(const QString& login, const QString& server, const
{"name", name}, {"name", name},
{"password", password}, {"password", password},
{"resource", resource}, {"resource", resource},
{"state", Shared::disconnected}, {"state", QVariant::fromValue(Shared::ConnectionState::disconnected)},
{"offline", Shared::offline}, {"offline", QVariant::fromValue(Shared::Availability::offline)},
{"error", ""}, {"error", ""},
{"avatarPath", acc->getAvatarPath()} {"avatarPath", acc->getAvatarPath()}
}; };
@ -155,14 +155,11 @@ void Core::Squawk::addAccount(const QString& login, const QString& server, const
emit newAccount(map); emit newAccount(map);
} }
void Core::Squawk::changeState(int p_state) void Core::Squawk::changeState(Shared::Availability p_state)
{ {
Shared::Availability avail; if (state != p_state) {
if (p_state < Shared::availabilityLowest && p_state > Shared::availabilityHighest) { state = p_state;
qDebug("An attempt to set invalid availability to Squawk core, skipping");
} }
avail = static_cast<Shared::Availability>(p_state);
state = avail;
for (std::deque<Account*>::iterator itr = accounts.begin(), end = accounts.end(); itr != end; ++itr) { for (std::deque<Account*>::iterator itr = accounts.begin(), end = accounts.end(); itr != end; ++itr) {
(*itr)->setAvailability(state); (*itr)->setAvailability(state);
@ -190,20 +187,20 @@ void Core::Squawk::disconnectAccount(const QString& account)
itr->second->disconnect(); itr->second->disconnect();
} }
void Core::Squawk::onAccountConnectionStateChanged(int state) void Core::Squawk::onAccountConnectionStateChanged(Shared::ConnectionState p_state)
{ {
Account* acc = static_cast<Account*>(sender()); Account* acc = static_cast<Account*>(sender());
emit changeAccount(acc->getName(), {{"state", state}}); emit changeAccount(acc->getName(), {{"state", QVariant::fromValue(p_state)}});
if (state == Shared::disconnected) { if (p_state == Shared::ConnectionState::disconnected) {
bool equals = true; bool equals = true;
for (Accounts::const_iterator itr = accounts.begin(), end = accounts.end(); itr != end; itr++) { for (Accounts::const_iterator itr = accounts.begin(), end = accounts.end(); itr != end; itr++) {
if ((*itr)->getState() != Shared::disconnected) { if ((*itr)->getState() != Shared::ConnectionState::disconnected) {
equals = false; equals = false;
} }
} }
if (equals) { if (equals && state != Shared::Availability::offline) {
state = Shared::offline; state = Shared::Availability::offline;
emit stateChanged(state); emit stateChanged(state);
} }
} }
@ -257,10 +254,10 @@ void Core::Squawk::onAccountRemovePresence(const QString& jid, const QString& na
emit removePresence(acc->getName(), jid, name); emit removePresence(acc->getName(), jid, name);
} }
void Core::Squawk::onAccountAvailabilityChanged(int state) void Core::Squawk::onAccountAvailabilityChanged(Shared::Availability state)
{ {
Account* acc = static_cast<Account*>(sender()); Account* acc = static_cast<Account*>(sender());
emit changeAccount(acc->getName(), {{"availability", state}}); emit changeAccount(acc->getName(), {{"availability", QVariant::fromValue(state)}});
} }
void Core::Squawk::onAccountChanged(const QMap<QString, QVariant>& data) void Core::Squawk::onAccountChanged(const QMap<QString, QVariant>& data)
@ -324,7 +321,7 @@ void Core::Squawk::modifyAccountRequest(const QString& name, const QMap<QString,
Core::Account* acc = itr->second; Core::Account* acc = itr->second;
Shared::ConnectionState st = acc->getState(); Shared::ConnectionState st = acc->getState();
if (st != Shared::disconnected) { if (st != Shared::ConnectionState::disconnected) {
acc->reconnect(); acc->reconnect();
} }
@ -367,7 +364,7 @@ void Core::Squawk::removeAccountRequest(const QString& name)
} }
Account* acc = itr->second; Account* acc = itr->second;
if (acc->getState() != Shared::disconnected) { if (acc->getState() != Shared::ConnectionState::disconnected) {
acc->disconnect(); acc->disconnect();
} }

View File

@ -28,7 +28,9 @@
#include <deque> #include <deque>
#include "account.h" #include "account.h"
#include "../global.h" #include "shared/enums.h"
#include "shared/message.h"
#include "shared/global.h"
#include "networkaccess.h" #include "networkaccess.h"
namespace Core namespace Core
@ -54,7 +56,7 @@ signals:
void changeContact(const QString& account, const QString& jid, const QMap<QString, QVariant>& data); void changeContact(const QString& account, const QString& jid, const QMap<QString, QVariant>& data);
void addPresence(const QString& account, const QString& jid, const QString& name, const QMap<QString, QVariant>& data); void addPresence(const QString& account, const QString& jid, const QString& name, const QMap<QString, QVariant>& data);
void removePresence(const QString& account, const QString& jid, const QString& name); void removePresence(const QString& account, const QString& jid, const QString& name);
void stateChanged(int state); void stateChanged(Shared::Availability state);
void accountMessage(const QString& account, const Shared::Message& data); void accountMessage(const QString& account, const Shared::Message& data);
void responseArchive(const QString& account, const QString& jid, const std::list<Shared::Message>& list); void responseArchive(const QString& account, const QString& jid, const std::list<Shared::Message>& list);
void addRoom(const QString& account, const QString jid, const QMap<QString, QVariant>& data); void addRoom(const QString& account, const QString jid, const QMap<QString, QVariant>& data);
@ -79,7 +81,7 @@ public slots:
void removeAccountRequest(const QString& name); void removeAccountRequest(const QString& name);
void connectAccount(const QString& account); void connectAccount(const QString& account);
void disconnectAccount(const QString& account); void disconnectAccount(const QString& account);
void changeState(int state); void changeState(Shared::Availability state);
void sendMessage(const QString& account, const Shared::Message& data); void sendMessage(const QString& account, const Shared::Message& data);
void sendMessage(const QString& account, const Shared::Message& data, const QString& path); void sendMessage(const QString& account, const Shared::Message& data, const QString& path);
void requestArchive(const QString& account, const QString& jid, int count, const QString& before); void requestArchive(const QString& account, const QString& jid, int count, const QString& before);
@ -112,8 +114,8 @@ private:
void addAccount(const QString& login, const QString& server, const QString& password, const QString& name, const QString& resource); void addAccount(const QString& login, const QString& server, const QString& password, const QString& name, const QString& resource);
private slots: private slots:
void onAccountConnectionStateChanged(int state); void onAccountConnectionStateChanged(Shared::ConnectionState state);
void onAccountAvailabilityChanged(int state); void onAccountAvailabilityChanged(Shared::Availability state);
void onAccountChanged(const QMap<QString, QVariant>& data); void onAccountChanged(const QMap<QString, QVariant>& data);
void onAccountAddGroup(const QString& name); void onAccountAddGroup(const QString& name);
void onAccountError(const QString& text); void onAccountError(const QString& text);

View File

@ -1,765 +0,0 @@
/*
* Squawk messenger.
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "global.h"
#include <uuid/uuid.h>
#include <QApplication>
#include <QPalette>
#include <QIcon>
#include <QDebug>
Shared::Message::Message(Shared::Message::Type p_type):
jFrom(),
rFrom(),
jTo(),
rTo(),
id(),
body(),
time(),
thread(),
type(p_type),
outgoing(false),
forwarded(false),
state(State::delivered),
edited(false)
{
}
Shared::Message::Message():
jFrom(),
rFrom(),
jTo(),
rTo(),
id(),
body(),
time(),
thread(),
type(Message::normal),
outgoing(false),
forwarded(false),
state(State::delivered),
edited(false),
errorText(),
originalMessage(),
lastModified()
{
}
QString Shared::Message::getBody() const
{
return body;
}
QString Shared::Message::getFrom() const
{
QString from = jFrom;
if (rFrom.size() > 0) {
from += "/" + rFrom;
}
return from;
}
QString Shared::Message::getTo() const
{
QString to = jTo;
if (rTo.size() > 0) {
to += "/" + rTo;
}
return to;
}
QString Shared::Message::getId() const
{
return id;
}
QDateTime Shared::Message::getTime() const
{
return time;
}
void Shared::Message::setBody(const QString& p_body)
{
body = p_body;
}
void Shared::Message::setFrom(const QString& from)
{
QStringList list = from.split("/");
if (list.size() == 1) {
jFrom = from;
} else {
jFrom = list.front();
rFrom = list.back();
}
}
void Shared::Message::setTo(const QString& to)
{
QStringList list = to.split("/");
if (list.size() == 1) {
jTo = to;
} else {
jTo = list.front();
rTo = list.back();
}
}
void Shared::Message::setId(const QString& p_id)
{
id = p_id;
}
void Shared::Message::setTime(const QDateTime& p_time)
{
time = p_time;
}
QString Shared::Message::getFromJid() const
{
return jFrom;
}
QString Shared::Message::getFromResource() const
{
return rFrom;
}
QString Shared::Message::getToJid() const
{
return jTo;
}
QString Shared::Message::getToResource() const
{
return rTo;
}
QString Shared::Message::getErrorText() const
{
return errorText;
}
QString Shared::Message::getPenPalJid() const
{
if (outgoing) {
return jTo;
} else {
return jFrom;
}
}
QString Shared::Message::getPenPalResource() const
{
if (outgoing) {
return rTo;
} else {
return rFrom;
}
}
Shared::Message::State Shared::Message::getState() const
{
return state;
}
bool Shared::Message::getEdited() const
{
return edited;
}
void Shared::Message::setFromJid(const QString& from)
{
jFrom = from;
}
void Shared::Message::setFromResource(const QString& from)
{
rFrom = from;
}
void Shared::Message::setToJid(const QString& to)
{
jTo = to;
}
void Shared::Message::setToResource(const QString& to)
{
rTo = to;
}
void Shared::Message::setErrorText(const QString& err)
{
if (state == State::error) {
errorText = err;
}
}
bool Shared::Message::getOutgoing() const
{
return outgoing;
}
void Shared::Message::setOutgoing(bool og)
{
outgoing = og;
}
bool Shared::Message::getForwarded() const
{
return forwarded;
}
void Shared::Message::generateRandomId()
{
id = generateUUID();
}
QString Shared::Message::getThread() const
{
return thread;
}
void Shared::Message::setForwarded(bool fwd)
{
forwarded = fwd;
}
void Shared::Message::setThread(const QString& p_body)
{
thread = p_body;
}
QDateTime Shared::Message::getLastModified() const
{
return lastModified;
}
QString Shared::Message::getOriginalBody() const
{
return originalMessage;
}
Shared::Message::Type Shared::Message::getType() const
{
return type;
}
void Shared::Message::setType(Shared::Message::Type t)
{
type = t;
}
void Shared::Message::setState(Shared::Message::State p_state)
{
state = p_state;
if (state != State::error) {
errorText = "";
}
}
bool Shared::Message::serverStored() const
{
return state == State::delivered || state == State::sent;
}
void Shared::Message::setEdited(bool p_edited)
{
edited = p_edited;
}
void Shared::Message::serialize(QDataStream& data) const
{
data << jFrom;
data << rFrom;
data << jTo;
data << rTo;
data << id;
data << body;
data << time;
data << thread;
data << (quint8)type;
data << outgoing;
data << forwarded;
data << oob;
data << (quint8)state;
data << edited;
if (state == State::error) {
data << errorText;
}
if (edited) {
data << originalMessage;
data << lastModified;
}
}
void Shared::Message::deserialize(QDataStream& data)
{
data >> jFrom;
data >> rFrom;
data >> jTo;
data >> rTo;
data >> id;
data >> body;
data >> time;
data >> thread;
quint8 t;
data >> t;
type = static_cast<Type>(t);
data >> outgoing;
data >> forwarded;
data >> oob;
quint8 s;
data >> s;
state = static_cast<State>(s);
data >> edited;
if (state == State::error) {
data >> errorText;
}
if (edited) {
data >> originalMessage;
data >> lastModified;
}
}
bool Shared::Message::change(const QMap<QString, QVariant>& data)
{
QMap<QString, QVariant>::const_iterator itr = data.find("state");
if (itr != data.end()) {
setState(static_cast<State>(itr.value().toUInt()));
}
if (state == State::error) {
itr = data.find("errorText");
if (itr != data.end()) {
setErrorText(itr.value().toString());
}
}
bool idChanged = false;
itr = data.find("id");
if (itr != data.end()) {
QString newId = itr.value().toString();
if (id != newId) {
setId(newId);
idChanged = true;
}
}
itr = data.find("body");
if (itr != data.end()) {
QMap<QString, QVariant>::const_iterator dItr = data.find("stamp");
QDateTime correctionDate;
if (dItr != data.end()) {
correctionDate = dItr.value().toDateTime();
} else {
correctionDate = QDateTime::currentDateTimeUtc(); //in case there is no information about time of this correction it's applied
}
if (!edited || lastModified < correctionDate) {
originalMessage = body;
lastModified = correctionDate;
setBody(itr.value().toString());
setEdited(true);
}
}
return idChanged;
}
QString Shared::generateUUID()
{
uuid_t uuid;
uuid_generate(uuid);
char uuid_str[36];
uuid_unparse_lower(uuid, uuid_str);
return uuid_str;
}
void Shared::Message::setCurrentTime()
{
time = QDateTime::currentDateTimeUtc();
}
QString Shared::Message::getOutOfBandUrl() const
{
return oob;
}
bool Shared::Message::hasOutOfBandUrl() const
{
return oob.size() > 0;
}
void Shared::Message::setOutOfBandUrl(const QString& url)
{
oob = url;
}
bool Shared::Message::storable() const
{
return id.size() > 0 && (body.size() > 0 || oob.size()) > 0;
}
Shared::VCard::Contact::Contact(Shared::VCard::Contact::Role p_role, bool p_prefered):
role(p_role),
prefered(p_prefered)
{}
Shared::VCard::Email::Email(const QString& addr, Shared::VCard::Contact::Role p_role, bool p_prefered):
Contact(p_role, p_prefered),
address(addr)
{}
Shared::VCard::Phone::Phone(const QString& nmbr, Shared::VCard::Phone::Type p_type, Shared::VCard::Contact::Role p_role, bool p_prefered):
Contact(p_role, p_prefered),
number(nmbr),
type(p_type)
{}
Shared::VCard::Address::Address(const QString& zCode, const QString& cntry, const QString& rgn, const QString& lclty, const QString& strt, const QString& ext, Shared::VCard::Contact::Role p_role, bool p_prefered):
Contact(p_role, p_prefered),
zipCode(zCode),
country(cntry),
region(rgn),
locality(lclty),
street(strt),
external(ext)
{}
Shared::VCard::VCard():
fullName(),
firstName(),
middleName(),
lastName(),
nickName(),
description(),
url(),
organizationName(),
organizationUnit(),
organizationRole(),
jobTitle(),
birthday(),
photoType(Avatar::empty),
photoPath(),
receivingTime(QDateTime::currentDateTimeUtc()),
emails(),
phones(),
addresses()
{}
Shared::VCard::VCard(const QDateTime& creationTime):
fullName(),
firstName(),
middleName(),
lastName(),
nickName(),
description(),
url(),
organizationName(),
organizationUnit(),
organizationRole(),
jobTitle(),
birthday(),
photoType(Avatar::empty),
photoPath(),
receivingTime(creationTime),
emails(),
phones(),
addresses()
{
}
QString Shared::VCard::getAvatarPath() const
{
return photoPath;
}
Shared::Avatar Shared::VCard::getAvatarType() const
{
return photoType;
}
QDate Shared::VCard::getBirthday() const
{
return birthday;
}
QString Shared::VCard::getDescription() const
{
return description;
}
QString Shared::VCard::getFirstName() const
{
return firstName;
}
QString Shared::VCard::getLastName() const
{
return lastName;
}
QString Shared::VCard::getMiddleName() const
{
return middleName;
}
QString Shared::VCard::getNickName() const
{
return nickName;
}
void Shared::VCard::setAvatarPath(const QString& path)
{
if (path != photoPath) {
photoPath = path;
}
}
void Shared::VCard::setAvatarType(Shared::Avatar type)
{
if (photoType != type) {
photoType = type;
}
}
void Shared::VCard::setBirthday(const QDate& date)
{
if (date.isValid() && birthday != date) {
birthday = date;
}
}
void Shared::VCard::setDescription(const QString& descr)
{
if (description != descr) {
description = descr;
}
}
void Shared::VCard::setFirstName(const QString& first)
{
if (firstName != first) {
firstName = first;
}
}
void Shared::VCard::setLastName(const QString& last)
{
if (lastName != last) {
lastName = last;
}
}
void Shared::VCard::setMiddleName(const QString& middle)
{
if (middleName != middle) {
middleName = middle;
}
}
void Shared::VCard::setNickName(const QString& nick)
{
if (nickName != nick) {
nickName = nick;
}
}
QString Shared::VCard::getFullName() const
{
return fullName;
}
QString Shared::VCard::getUrl() const
{
return url;
}
void Shared::VCard::setFullName(const QString& name)
{
if (fullName != name) {
fullName = name;
}
}
void Shared::VCard::setUrl(const QString& u)
{
if (url != u) {
url = u;
}
}
QString Shared::VCard::getOrgName() const
{
return organizationName;
}
QString Shared::VCard::getOrgRole() const
{
return organizationRole;
}
QString Shared::VCard::getOrgTitle() const
{
return jobTitle;
}
QString Shared::VCard::getOrgUnit() const
{
return organizationUnit;
}
void Shared::VCard::setOrgName(const QString& name)
{
if (organizationName != name) {
organizationName = name;
}
}
void Shared::VCard::setOrgRole(const QString& role)
{
if (organizationRole != role) {
organizationRole = role;
}
}
void Shared::VCard::setOrgTitle(const QString& title)
{
if (jobTitle != title) {
jobTitle = title;
}
}
void Shared::VCard::setOrgUnit(const QString& unit)
{
if (organizationUnit != unit) {
organizationUnit = unit;
}
}
QDateTime Shared::VCard::getReceivingTime() const
{
return receivingTime;
}
std::deque<Shared::VCard::Email> & Shared::VCard::getEmails()
{
return emails;
}
std::deque<Shared::VCard::Address> & Shared::VCard::getAddresses()
{
return addresses;
}
std::deque<Shared::VCard::Phone> & Shared::VCard::getPhones()
{
return phones;
}
const std::deque<Shared::VCard::Email> & Shared::VCard::getEmails() const
{
return emails;
}
const std::deque<Shared::VCard::Address> & Shared::VCard::getAddresses() const
{
return addresses;
}
const std::deque<Shared::VCard::Phone> & Shared::VCard::getPhones() const
{
return phones;
}
const std::deque<QString>Shared::VCard::Contact::roleNames = {"Not specified", "Personal", "Business"};
const std::deque<QString>Shared::VCard::Phone::typeNames = {"Fax", "Pager", "Voice", "Cell", "Video", "Modem", "Other"};
QIcon Shared::availabilityIcon(Shared::Availability av, bool big)
{
const std::deque<QString>& fallback = QApplication::palette().window().color().lightnessF() > 0.5 ?
big ?
Shared::fallbackAvailabilityThemeIconsDarkBig:
Shared::fallbackAvailabilityThemeIconsDarkSmall:
big ?
Shared::fallbackAvailabilityThemeIconsLightBig:
Shared::fallbackAvailabilityThemeIconsLightSmall;
return QIcon::fromTheme(availabilityThemeIcons[av], QIcon(fallback[av]));
}
QIcon Shared::subscriptionStateIcon(Shared::SubscriptionState ss, bool big)
{
const std::deque<QString>& fallback = QApplication::palette().window().color().lightnessF() > 0.5 ?
big ?
Shared::fallbackSubscriptionStateThemeIconsDarkBig:
Shared::fallbackSubscriptionStateThemeIconsDarkSmall:
big ?
Shared::fallbackSubscriptionStateThemeIconsLightBig:
Shared::fallbackSubscriptionStateThemeIconsLightSmall;
return QIcon::fromTheme(subscriptionStateThemeIcons[ss], QIcon(fallback[ss]));
}
QIcon Shared::connectionStateIcon(Shared::ConnectionState cs, bool big)
{
const std::deque<QString>& fallback = QApplication::palette().window().color().lightnessF() > 0.5 ?
big ?
Shared::fallbackConnectionStateThemeIconsDarkBig:
Shared::fallbackConnectionStateThemeIconsDarkSmall:
big ?
Shared::fallbackConnectionStateThemeIconsLightBig:
Shared::fallbackConnectionStateThemeIconsLightSmall;
return QIcon::fromTheme(connectionStateThemeIcons[cs], QIcon(fallback[cs]));
}
static const QString ds = ":images/fallback/dark/small/";
static const QString db = ":images/fallback/dark/big/";
static const QString ls = ":images/fallback/light/small/";
static const QString lb = ":images/fallback/light/big/";
QIcon Shared::icon(const QString& name, bool big)
{
std::map<QString, std::pair<QString, QString>>::const_iterator itr = icons.find(name);
if (itr != icons.end()) {
const QString& prefix = QApplication::palette().window().color().lightnessF() > 0.5 ?
big ? db : ds:
big ? lb : ls;
return QIcon::fromTheme(itr->second.first, QIcon(prefix + itr->second.second + ".svg"));
} else {
qDebug() << "Icon" << name << "not found";
return QIcon::fromTheme(name);
}
}
QString Shared::iconPath(const QString& name, bool big)
{
QString result = "";
std::map<QString, std::pair<QString, QString>>::const_iterator itr = icons.find(name);
if (itr != icons.end()) {
const QString& prefix = QApplication::palette().window().color().lightnessF() > 0.5 ?
big ? db : ds:
big ? lb : ls;
result = prefix + itr->second.second + ".svg";
}
return result;
}

512
global.h
View File

@ -1,512 +0,0 @@
/*
* Squawk messenger.
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GLOBAL_H
#define GLOBAL_H
#include <QString>
#include <QMap>
#include <QCoreApplication>
#include <deque>
#include <QDateTime>
#include <QDataStream>
#include <QColor>
namespace Shared {
enum ConnectionState {
disconnected,
connecting,
connected,
error
};
enum Availability {
online,
away,
extendedAway,
busy,
chatty,
invisible,
offline
};
enum SubscriptionState {
none,
from,
to,
both,
unknown
};
enum class Affiliation {
unspecified,
outcast,
nobody,
member,
admin,
owner
};
enum class Role {
unspecified,
nobody,
visitor,
participant,
moderator
};
enum class Avatar {
empty,
autocreated,
valid
};
static const Availability availabilityHighest = offline;
static const Availability availabilityLowest = online;
static const SubscriptionState subscriptionStateHighest = unknown;
static const SubscriptionState subscriptionStateLowest = none;
static const Affiliation affiliationHighest = Affiliation::owner;
static const Affiliation affiliationLowest = Affiliation::unspecified;
static const Role roleHighest = Role::moderator;
static const Role roleLowest = Role::unspecified;
static const std::deque<QString> connectionStateNames = {"Disconnected", "Connecting", "Connected", "Error"};
static const std::deque<QString> connectionStateThemeIcons = {"state-offline", "state-sync", "state-ok", "state-error"};
static const std::deque<QString> availabilityThemeIcons = {
"user-online",
"user-away",
"user-away-extended",
"user-busy",
"chatty",
"user-invisible",
"user-offline"
};
static const std::deque<QString> availabilityNames = {"Online", "Away", "Absent", "Busy", "Chatty", "Invisible", "Offline"};
static const std::deque<QString> subscriptionStateThemeIcons = {"edit-none", "arrow-down-double", "arrow-up-double", "dialog-ok", "question"};
static const std::deque<QString> subscriptionStateNames = {"None", "From", "To", "Both", "Unknown"};
static const std::deque<QString> affiliationNames = {"Unspecified", "Outcast", "Nobody", "Member", "Admin", "Owner"};
static const std::deque<QString> roleNames = {"Unspecified", "Nobody", "Visitor", "Participant", "Moderator"};
static const std::deque<QString> messageStateNames = {"Pending", "Sent", "Delivered", "Error"};
static const std::deque<QString> messageStateThemeIcons = {"state-offline", "state-sync", "state-ok", "state-error"};
QString generateUUID();
static const std::vector<QColor> colorPalette = {
QColor(244, 27, 63),
QColor(21, 104, 156),
QColor(38, 156, 98),
QColor(247, 103, 101),
QColor(121, 37, 117),
QColor(242, 202, 33),
QColor(168, 22, 63),
QColor(35, 100, 52),
QColor(52, 161, 152),
QColor(239, 53, 111),
QColor(237, 234, 36),
QColor(153, 148, 194),
QColor(211, 102, 151),
QColor(194, 63, 118),
QColor(249, 149, 51),
QColor(244, 206, 109),
QColor(121, 105, 153),
QColor(244, 199, 30),
QColor(28, 112, 28),
QColor(172, 18, 20),
QColor(25, 66, 110),
QColor(25, 149, 104),
QColor(214, 148, 0),
QColor(203, 47, 57),
QColor(4, 54, 84),
QColor(116, 161, 97),
QColor(50, 68, 52),
QColor(237, 179, 20),
QColor(69, 114, 147),
QColor(242, 212, 31),
QColor(248, 19, 20),
QColor(84, 102, 84),
QColor(25, 53, 122),
QColor(91, 91, 109),
QColor(17, 17, 80),
QColor(54, 54, 94)
};
class Message {
public:
enum Type {
error,
normal,
chat,
groupChat,
headline
};
enum class State {
pending,
sent,
delivered,
error
};
Message(Type p_type);
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);
void setThread(const QString& p_body);
void setOutgoing(bool og);
void setForwarded(bool fwd);
void setType(Type t);
void setCurrentTime();
void setOutOfBandUrl(const QString& url);
void setState(State p_state);
void setEdited(bool p_edited);
void setErrorText(const QString& err);
bool change(const QMap<QString, QVariant>& data);
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;
QString getThread() const;
bool getOutgoing() const;
bool getForwarded() const;
Type getType() const;
bool hasOutOfBandUrl() const;
bool storable() const;
QString getOutOfBandUrl() const;
State getState() const;
bool getEdited() const;
QString getErrorText() const;
QString getPenPalJid() const;
QString getPenPalResource() const;
void generateRandomId();
bool serverStored() const;
QDateTime getLastModified() const;
QString getOriginalBody() const;
void serialize(QDataStream& data) const;
void deserialize(QDataStream& data);
private:
QString jFrom;
QString rFrom;
QString jTo;
QString rTo;
QString id;
QString body;
QDateTime time;
QString thread;
Type type;
bool outgoing;
bool forwarded;
QString oob;
State state;
bool edited;
QString errorText;
QString originalMessage;
QDateTime lastModified;
};
class VCard {
class Contact {
public:
enum Role {
none,
home,
work
};
static const std::deque<QString> roleNames;
Contact(Role p_role = none, bool p_prefered = false);
Role role;
bool prefered;
};
public:
class Email : public Contact {
public:
Email(const QString& address, Role p_role = none, bool p_prefered = false);
QString address;
};
class Phone : public Contact {
public:
enum Type {
fax,
pager,
voice,
cell,
video,
modem,
other
};
static const std::deque<QString> typeNames;
Phone(const QString& number, Type p_type = voice, Role p_role = none, bool p_prefered = false);
QString number;
Type type;
};
class Address : public Contact {
public:
Address(
const QString& zCode = "",
const QString& cntry = "",
const QString& rgn = "",
const QString& lclty = "",
const QString& strt = "",
const QString& ext = "",
Role p_role = none,
bool p_prefered = false
);
QString zipCode;
QString country;
QString region;
QString locality;
QString street;
QString external;
};
VCard();
VCard(const QDateTime& creationTime);
QString getFullName() const;
void setFullName(const QString& name);
QString getFirstName() const;
void setFirstName(const QString& first);
QString getMiddleName() const;
void setMiddleName(const QString& middle);
QString getLastName() const;
void setLastName(const QString& last);
QString getNickName() const;
void setNickName(const QString& nick);
QString getDescription() const;
void setDescription(const QString& descr);
QString getUrl() const;
void setUrl(const QString& u);
QDate getBirthday() const;
void setBirthday(const QDate& date);
Avatar getAvatarType() const;
void setAvatarType(Avatar type);
QString getAvatarPath() const;
void setAvatarPath(const QString& path);
QString getOrgName() const;
void setOrgName(const QString& name);
QString getOrgUnit() const;
void setOrgUnit(const QString& unit);
QString getOrgRole() const;
void setOrgRole(const QString& role);
QString getOrgTitle() const;
void setOrgTitle(const QString& title);
QDateTime getReceivingTime() const;
std::deque<Email>& getEmails();
const std::deque<Email>& getEmails() const;
std::deque<Phone>& getPhones();
const std::deque<Phone>& getPhones() const;
std::deque<Address>& getAddresses();
const std::deque<Address>& getAddresses() const;
private:
QString fullName;
QString firstName;
QString middleName;
QString lastName;
QString nickName;
QString description;
QString url;
QString organizationName;
QString organizationUnit;
QString organizationRole;
QString jobTitle;
QDate birthday;
Avatar photoType;
QString photoPath;
QDateTime receivingTime;
std::deque<Email> emails;
std::deque<Phone> phones;
std::deque<Address> addresses;
};
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"
};
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"
};
static const std::deque<QString> fallbackConnectionStateThemeIconsLightBig = {
":images/fallback/light/big/state-offline.svg",
":images/fallback/light/big/state-sync.svg",
":images/fallback/light/big/state-ok.svg",
":images/fallback/light/big/state-error.svg"
};
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"
};
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"
};
static const std::deque<QString> fallbackConnectionStateThemeIconsLightSmall = {
":images/fallback/light/small/state-offline.svg",
":images/fallback/light/small/state-sync.svg",
":images/fallback/light/small/state-ok.svg",
":images/fallback/light/small/state-error.svg"
};
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"
};
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"
};
static const std::deque<QString> fallbackConnectionStateThemeIconsDarkBig = {
":images/fallback/dark/big/state-offline.svg",
":images/fallback/dark/big/state-sync.svg",
":images/fallback/dark/big/state-ok.svg",
":images/fallback/dark/big/state-error.svg"
};
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"
};
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"
};
static const std::deque<QString> fallbackConnectionStateThemeIconsDarkSmall = {
":images/fallback/dark/small/state-offline.svg",
":images/fallback/dark/small/state-sync.svg",
":images/fallback/dark/small/state-ok.svg",
":images/fallback/dark/small/state-error.svg"
};
QIcon availabilityIcon(Availability av, bool big = false);
QIcon subscriptionStateIcon(SubscriptionState ss, bool big = false);
QIcon connectionStateIcon(ConnectionState cs, bool big = false);
QIcon icon(const QString& name, bool big = false);
QString iconPath(const QString& name, bool big = false);
static const std::map<QString, std::pair<QString, QString>> icons = {
{"user-online", {"user-online", "online"}},
{"user-away", {"user-away", "away"}},
{"user-away-extended", {"user-away-extended", "absent"}},
{"user-busy", {"user-busy", "busy"}},
{"user-chatty", {"chatty", "chatty"}},
{"user-invisible", {"user-invisible", "invisible"}},
{"user-offline", {"offline", "offline"}},
{"edit-none", {"edit-none", "edit-none"}},
{"arrow-down-double", {"arrow-down-double", "arrow-down-double"}},
{"arrow-up-double", {"arrow-up-double", "arrow-up-double"}},
{"dialog-ok", {"dialog-ok", "dialog-ok"}},
{"question", {"question", "question"}},
{"state-offline", {"state-offline", "state-offline"}},
{"state-sync", {"state-sync", "state-sync"}},
{"state-ok", {"state-ok", "state-ok"}},
{"state-error", {"state-error", "state-error"}},
{"edit-copy", {"edit-copy", "copy"}},
{"edit-delete", {"edit-delete", "edit-delete"}},
{"edit-rename", {"edit-rename", "edit-rename"}},
{"mail-message", {"mail-message", "mail-message"}},
{"mail-attachment", {"mail-attachment", "mail-attachment"}},
{"network-connect", {"network-connect", "network-connect"}},
{"network-disconnect", {"network-disconnect", "network-disconnect"}},
{"news-subscribe", {"news-subscribe", "news-subscribe"}},
{"news-unsubscribe", {"news-unsubscribe", "news-unsubscribe"}},
{"view-refresh", {"view-refresh", "view-refresh"}},
{"send", {"document-send", "send"}},
{"clean", {"edit-clear-all", "clean"}},
{"user", {"user", "user"}},
{"user-properties", {"user-properties", "user-properties"}},
{"group", {"group", "group"}},
{"group-new", {"resurce-group-new", "group-new"}},
{"favorite", {"favorite", "favorite"}},
{"unfavorite", {"draw-star", "unfavorite"}},
{"list-add", {"list-add", "add"}},
};
};
#endif // GLOBAL_H

View File

@ -19,6 +19,7 @@
#include "ui/squawk.h" #include "ui/squawk.h"
#include "core/squawk.h" #include "core/squawk.h"
#include "signalcatcher.h" #include "signalcatcher.h"
#include "shared/global.h"
#include <QtWidgets/QApplication> #include <QtWidgets/QApplication>
#include <QtCore/QThread> #include <QtCore/QThread>
#include <QtCore/QObject> #include <QtCore/QObject>
@ -33,6 +34,8 @@ int main(int argc, char *argv[])
qRegisterMetaType<Shared::VCard>("Shared::VCard"); qRegisterMetaType<Shared::VCard>("Shared::VCard");
qRegisterMetaType<std::list<Shared::Message>>("std::list<Shared::Message>"); qRegisterMetaType<std::list<Shared::Message>>("std::list<Shared::Message>");
qRegisterMetaType<QSet<QString>>("QSet<QString>"); qRegisterMetaType<QSet<QString>>("QSet<QString>");
qRegisterMetaType<Shared::ConnectionState>("Shared::ConnectionState");
qRegisterMetaType<Shared::Availability>("Shared::Availability");
QApplication app(argc, argv); QApplication app(argc, argv);
SignalCatcher sc(&app); SignalCatcher sc(&app);
@ -72,6 +75,8 @@ int main(int argc, char *argv[])
icon.addFile(":images/logo.svg", QSize(512, 512)); icon.addFile(":images/logo.svg", QSize(512, 512));
QApplication::setWindowIcon(icon); QApplication::setWindowIcon(icon);
new Shared::Global(); //translates enums
Squawk w; Squawk w;
w.show(); w.show();

29
shared.h Normal file
View File

@ -0,0 +1,29 @@
/*
* Squawk messenger.
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SHARED_H
#define SHARED_H
#include "shared/enums.h"
#include "shared/utils.h"
#include "shared/icons.h"
#include "shared/message.h"
#include "shared/vcard.h"
#include "shared/global.h"
#endif // SHARED_H

114
shared/enums.h Normal file
View File

@ -0,0 +1,114 @@
/*
* Squawk messenger.
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SHARED_ENUMS_H
#define SHARED_ENUMS_H
#include <deque>
#include <QString>
#include <QObject>
namespace Shared {
Q_NAMESPACE
enum class ConnectionState {
disconnected,
connecting,
connected,
error
};
Q_ENUM_NS(ConnectionState)
static const std::deque<QString> connectionStateThemeIcons = {"state-offline", "state-sync", "state-ok", "state-error"};
static const ConnectionState connectionStateHighest = ConnectionState::error;
static const ConnectionState connectionStateLowest = ConnectionState::disconnected;
enum class Availability {
online,
away,
extendedAway,
busy,
chatty,
invisible,
offline
};
Q_ENUM_NS(Availability)
static const Availability availabilityHighest = Availability::offline;
static const Availability availabilityLowest = Availability::online;
static const std::deque<QString> availabilityThemeIcons = {
"user-online",
"user-away",
"user-away-extended",
"user-busy",
"chatty",
"user-invisible",
"user-offline"
};
static const std::deque<QString> availabilityNames = {"Online", "Away", "Absent", "Busy", "Chatty", "Invisible", "Offline"};
enum class SubscriptionState {
none,
from,
to,
both,
unknown
};
Q_ENUM_NS(SubscriptionState)
static const SubscriptionState subscriptionStateHighest = SubscriptionState::unknown;
static const SubscriptionState subscriptionStateLowest = SubscriptionState::none;
static const std::deque<QString> subscriptionStateThemeIcons = {"edit-none", "arrow-down-double", "arrow-up-double", "dialog-ok", "question"};
static const std::deque<QString> subscriptionStateNames = {"None", "From", "To", "Both", "Unknown"};
enum class Affiliation {
unspecified,
outcast,
nobody,
member,
admin,
owner
};
Q_ENUM_NS(Affiliation)
static const Affiliation affiliationHighest = Affiliation::owner;
static const Affiliation affiliationLowest = Affiliation::unspecified;
static const std::deque<QString> affiliationNames = {"Unspecified", "Outcast", "Nobody", "Member", "Admin", "Owner"};
enum class Role {
unspecified,
nobody,
visitor,
participant,
moderator
};
Q_ENUM_NS(Role)
static const Role roleHighest = Role::moderator;
static const Role roleLowest = Role::unspecified;
static const std::deque<QString> roleNames = {"Unspecified", "Nobody", "Visitor", "Participant", "Moderator"};
enum class Avatar {
empty,
autocreated,
valid
};
Q_ENUM_NS(Avatar)
static const std::deque<QString> messageStateNames = {"Pending", "Sent", "Delivered", "Error"};
static const std::deque<QString> messageStateThemeIcons = {"state-offline", "state-sync", "state-ok", "state-error"};
}
#endif // SHARED_ENUMS_H

170
shared/global.cpp Normal file
View File

@ -0,0 +1,170 @@
/*
* Squawk messenger.
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "global.h"
#include "enums.h"
Shared::Global* Shared::Global::instance = 0;
Shared::Global::Global():
availability({
tr("Online"),
tr("Away"),
tr("Absent"),
tr("Busy"),
tr("Chatty"),
tr("Invisible"),
tr("Offline")
}),
connectionState({
tr("Disconnected"),
tr("Connecting"),
tr("Connected"),
tr("Error")
}),
subscriptionState({
tr("None"),
tr("From"),
tr("To"),
tr("Both"),
tr("Unknown")
}),
affiliation({
tr("Unspecified"),
tr("Outcast"),
tr("Nobody"),
tr("Member"),
tr("Admin"),
tr("Owner")
}),
role({
tr("Unspecified"),
tr("Nobody"),
tr("Visitor"),
tr("Participant"),
tr("Moderator")
}),
messageState({
tr("Pending"),
tr("Sent"),
tr("Delivered"),
tr("Error")
})
{
if (instance != 0) {
throw 551;
}
instance = this;
}
Shared::Global * Shared::Global::getInstance()
{
return instance;
}
QString Shared::Global::getName(Message::State rl)
{
return instance->messageState[int(rl)];
}
QString Shared::Global::getName(Shared::Affiliation af)
{
return instance->affiliation[int(af)];
}
QString Shared::Global::getName(Shared::Availability av)
{
return instance->availability[int(av)];
}
QString Shared::Global::getName(Shared::ConnectionState cs)
{
return instance->connectionState[int(cs)];
}
QString Shared::Global::getName(Shared::Role rl)
{
return instance->role[int(rl)];
}
QString Shared::Global::getName(Shared::SubscriptionState ss)
{
return instance->subscriptionState[int(ss)];
}
template<>
Shared::Availability Shared::Global::fromInt(int src)
{
if (src < static_cast<int>(Shared::availabilityLowest) && src > static_cast<int>(Shared::availabilityHighest)) {
qDebug("An attempt to set invalid availability to Squawk core, skipping");
}
return static_cast<Shared::Availability>(src);
}
template<>
Shared::Availability Shared::Global::fromInt(unsigned int src)
{
if (src < static_cast<int>(Shared::availabilityLowest) && src > static_cast<int>(Shared::availabilityHighest)) {
qDebug("An attempt to set invalid availability to Squawk core, skipping");
}
return static_cast<Shared::Availability>(src);
}
template<>
Shared::ConnectionState Shared::Global::fromInt(int src)
{
if (src < static_cast<int>(Shared::connectionStateLowest) && src > static_cast<int>(Shared::connectionStateHighest)) {
qDebug("An attempt to set invalid availability to Squawk core, skipping");
}
return static_cast<Shared::ConnectionState>(src);
}
template<>
Shared::ConnectionState Shared::Global::fromInt(unsigned int src)
{
if (src < static_cast<int>(Shared::connectionStateLowest) && src > static_cast<int>(Shared::connectionStateHighest)) {
qDebug("An attempt to set invalid availability to Squawk core, skipping");
}
return static_cast<Shared::ConnectionState>(src);
}
template<>
Shared::SubscriptionState Shared::Global::fromInt(int src)
{
if (src < static_cast<int>(Shared::subscriptionStateLowest) && src > static_cast<int>(Shared::subscriptionStateHighest)) {
qDebug("An attempt to set invalid availability to Squawk core, skipping");
}
return static_cast<Shared::SubscriptionState>(src);
}
template<>
Shared::SubscriptionState Shared::Global::fromInt(unsigned int src)
{
if (src < static_cast<int>(Shared::subscriptionStateLowest) && src > static_cast<int>(Shared::subscriptionStateHighest)) {
qDebug("An attempt to set invalid availability to Squawk core, skipping");
}
return static_cast<Shared::SubscriptionState>(src);
}

64
shared/global.h Normal file
View File

@ -0,0 +1,64 @@
/*
* Squawk messenger.
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SHARED_GLOBAL_H
#define SHARED_GLOBAL_H
#include "enums.h"
#include "message.h"
#include <map>
#include <QCoreApplication>
#include <QDebug>
namespace Shared {
class Global {
Q_DECLARE_TR_FUNCTIONS(Global)
public:
Global();
static Global* getInstance();
static QString getName(Availability av);
static QString getName(ConnectionState cs);
static QString getName(SubscriptionState ss);
static QString getName(Affiliation af);
static QString getName(Role rl);
static QString getName(Message::State rl);
const std::deque<QString> availability;
const std::deque<QString> connectionState;
const std::deque<QString> subscriptionState;
const std::deque<QString> affiliation;
const std::deque<QString> role;
const std::deque<QString> messageState;
template<typename T>
static T fromInt(int src);
template<typename T>
static T fromInt(unsigned int src);
private:
static Global* instance;
};
}
#endif // SHARED_GLOBAL_H

96
shared/icons.cpp Normal file
View File

@ -0,0 +1,96 @@
/*
* Squawk messenger.
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "icons.h"
#include <QApplication>
#include <QPalette>
#include <QDebug>
QIcon Shared::availabilityIcon(Shared::Availability av, bool big)
{
const std::deque<QString>& fallback = QApplication::palette().window().color().lightnessF() > 0.5 ?
big ?
Shared::fallbackAvailabilityThemeIconsDarkBig:
Shared::fallbackAvailabilityThemeIconsDarkSmall:
big ?
Shared::fallbackAvailabilityThemeIconsLightBig:
Shared::fallbackAvailabilityThemeIconsLightSmall;
return QIcon::fromTheme(availabilityThemeIcons[static_cast<int>(av)], QIcon(fallback[static_cast<int>(av)]));
}
QIcon Shared::subscriptionStateIcon(Shared::SubscriptionState ss, bool big)
{
const std::deque<QString>& fallback = QApplication::palette().window().color().lightnessF() > 0.5 ?
big ?
Shared::fallbackSubscriptionStateThemeIconsDarkBig:
Shared::fallbackSubscriptionStateThemeIconsDarkSmall:
big ?
Shared::fallbackSubscriptionStateThemeIconsLightBig:
Shared::fallbackSubscriptionStateThemeIconsLightSmall;
return QIcon::fromTheme(subscriptionStateThemeIcons[static_cast<int>(ss)], QIcon(fallback[static_cast<int>(ss)]));
}
QIcon Shared::connectionStateIcon(Shared::ConnectionState cs, bool big)
{
const std::deque<QString>& fallback = QApplication::palette().window().color().lightnessF() > 0.5 ?
big ?
Shared::fallbackConnectionStateThemeIconsDarkBig:
Shared::fallbackConnectionStateThemeIconsDarkSmall:
big ?
Shared::fallbackConnectionStateThemeIconsLightBig:
Shared::fallbackConnectionStateThemeIconsLightSmall;
return QIcon::fromTheme(connectionStateThemeIcons[static_cast<int>(cs)], QIcon(fallback[static_cast<int>(cs)]));
}
static const QString ds = ":images/fallback/dark/small/";
static const QString db = ":images/fallback/dark/big/";
static const QString ls = ":images/fallback/light/small/";
static const QString lb = ":images/fallback/light/big/";
QIcon Shared::icon(const QString& name, bool big)
{
std::map<QString, std::pair<QString, QString>>::const_iterator itr = icons.find(name);
if (itr != icons.end()) {
const QString& prefix = QApplication::palette().window().color().lightnessF() > 0.5 ?
big ? db : ds:
big ? lb : ls;
return QIcon::fromTheme(itr->second.first, QIcon(prefix + itr->second.second + ".svg"));
} else {
qDebug() << "Icon" << name << "not found";
return QIcon::fromTheme(name);
}
}
QString Shared::iconPath(const QString& name, bool big)
{
QString result = "";
std::map<QString, std::pair<QString, QString>>::const_iterator itr = icons.find(name);
if (itr != icons.end()) {
const QString& prefix = QApplication::palette().window().color().lightnessF() > 0.5 ?
big ? db : ds:
big ? lb : ls;
result = prefix + itr->second.second + ".svg";
}
return result;
}

176
shared/icons.h Normal file
View File

@ -0,0 +1,176 @@
/*
* Squawk messenger.
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SHARED_ICONS_H
#define SHARED_ICONS_H
#include <QIcon>
#include <map>
#include "enums.h"
namespace Shared {
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"
};
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"
};
static const std::deque<QString> fallbackConnectionStateThemeIconsLightBig = {
":images/fallback/light/big/state-offline.svg",
":images/fallback/light/big/state-sync.svg",
":images/fallback/light/big/state-ok.svg",
":images/fallback/light/big/state-error.svg"
};
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"
};
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"
};
static const std::deque<QString> fallbackConnectionStateThemeIconsLightSmall = {
":images/fallback/light/small/state-offline.svg",
":images/fallback/light/small/state-sync.svg",
":images/fallback/light/small/state-ok.svg",
":images/fallback/light/small/state-error.svg"
};
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"
};
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"
};
static const std::deque<QString> fallbackConnectionStateThemeIconsDarkBig = {
":images/fallback/dark/big/state-offline.svg",
":images/fallback/dark/big/state-sync.svg",
":images/fallback/dark/big/state-ok.svg",
":images/fallback/dark/big/state-error.svg"
};
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"
};
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"
};
static const std::deque<QString> fallbackConnectionStateThemeIconsDarkSmall = {
":images/fallback/dark/small/state-offline.svg",
":images/fallback/dark/small/state-sync.svg",
":images/fallback/dark/small/state-ok.svg",
":images/fallback/dark/small/state-error.svg"
};
QIcon availabilityIcon(Availability av, bool big = false);
QIcon subscriptionStateIcon(SubscriptionState ss, bool big = false);
QIcon connectionStateIcon(ConnectionState cs, bool big = false);
QIcon icon(const QString& name, bool big = false);
QString iconPath(const QString& name, bool big = false);
static const std::map<QString, std::pair<QString, QString>> icons = {
{"user-online", {"user-online", "online"}},
{"user-away", {"user-away", "away"}},
{"user-away-extended", {"user-away-extended", "absent"}},
{"user-busy", {"user-busy", "busy"}},
{"user-chatty", {"chatty", "chatty"}},
{"user-invisible", {"user-invisible", "invisible"}},
{"user-offline", {"offline", "offline"}},
{"edit-none", {"edit-none", "edit-none"}},
{"arrow-down-double", {"arrow-down-double", "arrow-down-double"}},
{"arrow-up-double", {"arrow-up-double", "arrow-up-double"}},
{"dialog-ok", {"dialog-ok", "dialog-ok"}},
{"question", {"question", "question"}},
{"state-offline", {"state-offline", "state-offline"}},
{"state-sync", {"state-sync", "state-sync"}},
{"state-ok", {"state-ok", "state-ok"}},
{"state-error", {"state-error", "state-error"}},
{"edit-copy", {"edit-copy", "copy"}},
{"edit-delete", {"edit-delete", "edit-delete"}},
{"edit-rename", {"edit-rename", "edit-rename"}},
{"mail-message", {"mail-message", "mail-message"}},
{"mail-attachment", {"mail-attachment", "mail-attachment"}},
{"network-connect", {"network-connect", "network-connect"}},
{"network-disconnect", {"network-disconnect", "network-disconnect"}},
{"news-subscribe", {"news-subscribe", "news-subscribe"}},
{"news-unsubscribe", {"news-unsubscribe", "news-unsubscribe"}},
{"view-refresh", {"view-refresh", "view-refresh"}},
{"send", {"document-send", "send"}},
{"clean", {"edit-clear-all", "clean"}},
{"user", {"user", "user"}},
{"user-properties", {"user-properties", "user-properties"}},
{"group", {"group", "group"}},
{"group-new", {"resurce-group-new", "group-new"}},
{"favorite", {"favorite", "favorite"}},
{"unfavorite", {"draw-star", "unfavorite"}},
{"list-add", {"list-add", "add"}},
};
}
#endif // SHARED_ICONS_H

399
shared/message.cpp Normal file
View File

@ -0,0 +1,399 @@
/*
* Squawk messenger.
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "message.h"
#include "utils.h"
Shared::Message::Message(Shared::Message::Type p_type):
jFrom(),
rFrom(),
jTo(),
rTo(),
id(),
body(),
time(),
thread(),
type(p_type),
outgoing(false),
forwarded(false),
state(State::delivered),
edited(false) {}
Shared::Message::Message():
jFrom(),
rFrom(),
jTo(),
rTo(),
id(),
body(),
time(),
thread(),
type(Message::normal),
outgoing(false),
forwarded(false),
state(State::delivered),
edited(false),
errorText(),
originalMessage(),
lastModified() {}
QString Shared::Message::getBody() const
{
return body;
}
QString Shared::Message::getFrom() const
{
QString from = jFrom;
if (rFrom.size() > 0) {
from += "/" + rFrom;
}
return from;
}
QString Shared::Message::getTo() const
{
QString to = jTo;
if (rTo.size() > 0) {
to += "/" + rTo;
}
return to;
}
QString Shared::Message::getId() const
{
return id;
}
QDateTime Shared::Message::getTime() const
{
return time;
}
void Shared::Message::setBody(const QString& p_body)
{
body = p_body;
}
void Shared::Message::setFrom(const QString& from)
{
QStringList list = from.split("/");
if (list.size() == 1) {
jFrom = from;
} else {
jFrom = list.front();
rFrom = list.back();
}
}
void Shared::Message::setTo(const QString& to)
{
QStringList list = to.split("/");
if (list.size() == 1) {
jTo = to;
} else {
jTo = list.front();
rTo = list.back();
}
}
void Shared::Message::setId(const QString& p_id)
{
id = p_id;
}
void Shared::Message::setTime(const QDateTime& p_time)
{
time = p_time;
}
QString Shared::Message::getFromJid() const
{
return jFrom;
}
QString Shared::Message::getFromResource() const
{
return rFrom;
}
QString Shared::Message::getToJid() const
{
return jTo;
}
QString Shared::Message::getToResource() const
{
return rTo;
}
QString Shared::Message::getErrorText() const
{
return errorText;
}
QString Shared::Message::getPenPalJid() const
{
if (outgoing) {
return jTo;
} else {
return jFrom;
}
}
QString Shared::Message::getPenPalResource() const
{
if (outgoing) {
return rTo;
} else {
return rFrom;
}
}
Shared::Message::State Shared::Message::getState() const
{
return state;
}
bool Shared::Message::getEdited() const
{
return edited;
}
void Shared::Message::setFromJid(const QString& from)
{
jFrom = from;
}
void Shared::Message::setFromResource(const QString& from)
{
rFrom = from;
}
void Shared::Message::setToJid(const QString& to)
{
jTo = to;
}
void Shared::Message::setToResource(const QString& to)
{
rTo = to;
}
void Shared::Message::setErrorText(const QString& err)
{
if (state == State::error) {
errorText = err;
}
}
bool Shared::Message::getOutgoing() const
{
return outgoing;
}
void Shared::Message::setOutgoing(bool og)
{
outgoing = og;
}
bool Shared::Message::getForwarded() const
{
return forwarded;
}
void Shared::Message::generateRandomId()
{
id = generateUUID();
}
QString Shared::Message::getThread() const
{
return thread;
}
void Shared::Message::setForwarded(bool fwd)
{
forwarded = fwd;
}
void Shared::Message::setThread(const QString& p_body)
{
thread = p_body;
}
QDateTime Shared::Message::getLastModified() const
{
return lastModified;
}
QString Shared::Message::getOriginalBody() const
{
return originalMessage;
}
Shared::Message::Type Shared::Message::getType() const
{
return type;
}
void Shared::Message::setType(Shared::Message::Type t)
{
type = t;
}
void Shared::Message::setState(Shared::Message::State p_state)
{
state = p_state;
if (state != State::error) {
errorText = "";
}
}
bool Shared::Message::serverStored() const
{
return state == State::delivered || state == State::sent;
}
void Shared::Message::setEdited(bool p_edited)
{
edited = p_edited;
}
void Shared::Message::serialize(QDataStream& data) const
{
data << jFrom;
data << rFrom;
data << jTo;
data << rTo;
data << id;
data << body;
data << time;
data << thread;
data << (quint8)type;
data << outgoing;
data << forwarded;
data << oob;
data << (quint8)state;
data << edited;
if (state == State::error) {
data << errorText;
}
if (edited) {
data << originalMessage;
data << lastModified;
}
}
void Shared::Message::deserialize(QDataStream& data)
{
data >> jFrom;
data >> rFrom;
data >> jTo;
data >> rTo;
data >> id;
data >> body;
data >> time;
data >> thread;
quint8 t;
data >> t;
type = static_cast<Type>(t);
data >> outgoing;
data >> forwarded;
data >> oob;
quint8 s;
data >> s;
state = static_cast<State>(s);
data >> edited;
if (state == State::error) {
data >> errorText;
}
if (edited) {
data >> originalMessage;
data >> lastModified;
}
}
bool Shared::Message::change(const QMap<QString, QVariant>& data)
{
QMap<QString, QVariant>::const_iterator itr = data.find("state");
if (itr != data.end()) {
setState(static_cast<State>(itr.value().toUInt()));
}
if (state == State::error) {
itr = data.find("errorText");
if (itr != data.end()) {
setErrorText(itr.value().toString());
}
}
bool idChanged = false;
itr = data.find("id");
if (itr != data.end()) {
QString newId = itr.value().toString();
if (id != newId) {
setId(newId);
idChanged = true;
}
}
itr = data.find("body");
if (itr != data.end()) {
QMap<QString, QVariant>::const_iterator dItr = data.find("stamp");
QDateTime correctionDate;
if (dItr != data.end()) {
correctionDate = dItr.value().toDateTime();
} else {
correctionDate = QDateTime::currentDateTimeUtc(); //in case there is no information about time of this correction it's applied
}
if (!edited || lastModified < correctionDate) {
originalMessage = body;
lastModified = correctionDate;
setBody(itr.value().toString());
setEdited(true);
}
}
return idChanged;
}
void Shared::Message::setCurrentTime()
{
time = QDateTime::currentDateTimeUtc();
}
QString Shared::Message::getOutOfBandUrl() const
{
return oob;
}
bool Shared::Message::hasOutOfBandUrl() const
{
return oob.size() > 0;
}
void Shared::Message::setOutOfBandUrl(const QString& url)
{
oob = url;
}
bool Shared::Message::storable() const
{
return id.size() > 0 && (body.size() > 0 || oob.size()) > 0;
}

125
shared/message.h Normal file
View File

@ -0,0 +1,125 @@
/*
* Squawk messenger.
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <QString>
#include <QDateTime>
#include <QVariant>
#include <QMap>
#include <QDataStream>
#ifndef SHAPER_MESSAGE_H
#define SHAPER_MESSAGE_H
namespace Shared {
/**
* @todo write docs
*/
class Message {
public:
enum Type {
error,
normal,
chat,
groupChat,
headline
};
enum class State {
pending,
sent,
delivered,
error
};
Message(Type p_type);
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);
void setThread(const QString& p_body);
void setOutgoing(bool og);
void setForwarded(bool fwd);
void setType(Type t);
void setCurrentTime();
void setOutOfBandUrl(const QString& url);
void setState(State p_state);
void setEdited(bool p_edited);
void setErrorText(const QString& err);
bool change(const QMap<QString, QVariant>& data);
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;
QString getThread() const;
bool getOutgoing() const;
bool getForwarded() const;
Type getType() const;
bool hasOutOfBandUrl() const;
bool storable() const;
QString getOutOfBandUrl() const;
State getState() const;
bool getEdited() const;
QString getErrorText() const;
QString getPenPalJid() const;
QString getPenPalResource() const;
void generateRandomId();
bool serverStored() const;
QDateTime getLastModified() const;
QString getOriginalBody() const;
void serialize(QDataStream& data) const;
void deserialize(QDataStream& data);
private:
QString jFrom;
QString rFrom;
QString jTo;
QString rTo;
QString id;
QString body;
QDateTime time;
QString thread;
Type type;
bool outgoing;
bool forwarded;
QString oob;
State state;
bool edited;
QString errorText;
QString originalMessage;
QDateTime lastModified;
};
}
#endif // SHAPER_MESSAGE_H

29
shared/utils.cpp Normal file
View File

@ -0,0 +1,29 @@
/*
* Squawk messenger.
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "utils.h"
QString Shared::generateUUID()
{
uuid_t uuid;
uuid_generate(uuid);
char uuid_str[36];
uuid_unparse_lower(uuid, uuid_str);
return uuid_str;
}

72
shared/utils.h Normal file
View File

@ -0,0 +1,72 @@
/*
* Squawk messenger.
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SHARED_UTILS_H
#define SHARED_UTILS_H
#include <QString>
#include <QColor>
#include <uuid/uuid.h>
#include <vector>
namespace Shared {
QString generateUUID();
static const std::vector<QColor> colorPalette = {
QColor(244, 27, 63),
QColor(21, 104, 156),
QColor(38, 156, 98),
QColor(247, 103, 101),
QColor(121, 37, 117),
QColor(242, 202, 33),
QColor(168, 22, 63),
QColor(35, 100, 52),
QColor(52, 161, 152),
QColor(239, 53, 111),
QColor(237, 234, 36),
QColor(153, 148, 194),
QColor(211, 102, 151),
QColor(194, 63, 118),
QColor(249, 149, 51),
QColor(244, 206, 109),
QColor(121, 105, 153),
QColor(244, 199, 30),
QColor(28, 112, 28),
QColor(172, 18, 20),
QColor(25, 66, 110),
QColor(25, 149, 104),
QColor(214, 148, 0),
QColor(203, 47, 57),
QColor(4, 54, 84),
QColor(116, 161, 97),
QColor(50, 68, 52),
QColor(237, 179, 20),
QColor(69, 114, 147),
QColor(242, 212, 31),
QColor(248, 19, 20),
QColor(84, 102, 84),
QColor(25, 53, 122),
QColor(91, 91, 109),
QColor(17, 17, 80),
QColor(54, 54, 94)
};
}
#endif // SHARED_UTILS_H

288
shared/vcard.cpp Normal file
View File

@ -0,0 +1,288 @@
/*
* Squawk messenger.
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "vcard.h"
Shared::VCard::Contact::Contact(Shared::VCard::Contact::Role p_role, bool p_prefered):
role(p_role),
prefered(p_prefered) {}
Shared::VCard::Email::Email(const QString& addr, Shared::VCard::Contact::Role p_role, bool p_prefered):
Contact(p_role, p_prefered),
address(addr) {}
Shared::VCard::Phone::Phone(const QString& nmbr, Shared::VCard::Phone::Type p_type, Shared::VCard::Contact::Role p_role, bool p_prefered):
Contact(p_role, p_prefered),
number(nmbr),
type(p_type) {}
Shared::VCard::Address::Address(const QString& zCode, const QString& cntry, const QString& rgn, const QString& lclty, const QString& strt, const QString& ext, Shared::VCard::Contact::Role p_role, bool p_prefered):
Contact(p_role, p_prefered),
zipCode(zCode),
country(cntry),
region(rgn),
locality(lclty),
street(strt),
external(ext) {}
Shared::VCard::VCard():
fullName(),
firstName(),
middleName(),
lastName(),
nickName(),
description(),
url(),
organizationName(),
organizationUnit(),
organizationRole(),
jobTitle(),
birthday(),
photoType(Avatar::empty),
photoPath(),
receivingTime(QDateTime::currentDateTimeUtc()),
emails(),
phones(),
addresses() {}
Shared::VCard::VCard(const QDateTime& creationTime):
fullName(),
firstName(),
middleName(),
lastName(),
nickName(),
description(),
url(),
organizationName(),
organizationUnit(),
organizationRole(),
jobTitle(),
birthday(),
photoType(Avatar::empty),
photoPath(),
receivingTime(creationTime),
emails(),
phones(),
addresses() {}
QString Shared::VCard::getAvatarPath() const
{
return photoPath;
}
Shared::Avatar Shared::VCard::getAvatarType() const
{
return photoType;
}
QDate Shared::VCard::getBirthday() const
{
return birthday;
}
QString Shared::VCard::getDescription() const
{
return description;
}
QString Shared::VCard::getFirstName() const
{
return firstName;
}
QString Shared::VCard::getLastName() const
{
return lastName;
}
QString Shared::VCard::getMiddleName() const
{
return middleName;
}
QString Shared::VCard::getNickName() const
{
return nickName;
}
void Shared::VCard::setAvatarPath(const QString& path)
{
if (path != photoPath) {
photoPath = path;
}
}
void Shared::VCard::setAvatarType(Shared::Avatar type)
{
if (photoType != type) {
photoType = type;
}
}
void Shared::VCard::setBirthday(const QDate& date)
{
if (date.isValid() && birthday != date) {
birthday = date;
}
}
void Shared::VCard::setDescription(const QString& descr)
{
if (description != descr) {
description = descr;
}
}
void Shared::VCard::setFirstName(const QString& first)
{
if (firstName != first) {
firstName = first;
}
}
void Shared::VCard::setLastName(const QString& last)
{
if (lastName != last) {
lastName = last;
}
}
void Shared::VCard::setMiddleName(const QString& middle)
{
if (middleName != middle) {
middleName = middle;
}
}
void Shared::VCard::setNickName(const QString& nick)
{
if (nickName != nick) {
nickName = nick;
}
}
QString Shared::VCard::getFullName() const
{
return fullName;
}
QString Shared::VCard::getUrl() const
{
return url;
}
void Shared::VCard::setFullName(const QString& name)
{
if (fullName != name) {
fullName = name;
}
}
void Shared::VCard::setUrl(const QString& u)
{
if (url != u) {
url = u;
}
}
QString Shared::VCard::getOrgName() const
{
return organizationName;
}
QString Shared::VCard::getOrgRole() const
{
return organizationRole;
}
QString Shared::VCard::getOrgTitle() const
{
return jobTitle;
}
QString Shared::VCard::getOrgUnit() const
{
return organizationUnit;
}
void Shared::VCard::setOrgName(const QString& name)
{
if (organizationName != name) {
organizationName = name;
}
}
void Shared::VCard::setOrgRole(const QString& role)
{
if (organizationRole != role) {
organizationRole = role;
}
}
void Shared::VCard::setOrgTitle(const QString& title)
{
if (jobTitle != title) {
jobTitle = title;
}
}
void Shared::VCard::setOrgUnit(const QString& unit)
{
if (organizationUnit != unit) {
organizationUnit = unit;
}
}
QDateTime Shared::VCard::getReceivingTime() const
{
return receivingTime;
}
std::deque<Shared::VCard::Email> & Shared::VCard::getEmails()
{
return emails;
}
std::deque<Shared::VCard::Address> & Shared::VCard::getAddresses()
{
return addresses;
}
std::deque<Shared::VCard::Phone> & Shared::VCard::getPhones()
{
return phones;
}
const std::deque<Shared::VCard::Email> & Shared::VCard::getEmails() const
{
return emails;
}
const std::deque<Shared::VCard::Address> & Shared::VCard::getAddresses() const
{
return addresses;
}
const std::deque<Shared::VCard::Phone> & Shared::VCard::getPhones() const
{
return phones;
}
const std::deque<QString>Shared::VCard::Contact::roleNames = {"Not specified", "Personal", "Business"};
const std::deque<QString>Shared::VCard::Phone::typeNames = {"Fax", "Pager", "Voice", "Cell", "Video", "Modem", "Other"};

152
shared/vcard.h Normal file
View File

@ -0,0 +1,152 @@
/*
* Squawk messenger.
* Copyright (C) 2019 Yury Gubich <blue@macaw.me>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SHARED_VCARD_H
#define SHARED_VCARD_H
#include <QString>
#include <QDateTime>
#include <deque>
#include "enums.h"
namespace Shared {
class VCard {
class Contact {
public:
enum Role {
none,
home,
work
};
static const std::deque<QString> roleNames;
Contact(Role p_role = none, bool p_prefered = false);
Role role;
bool prefered;
};
public:
class Email : public Contact {
public:
Email(const QString& address, Role p_role = none, bool p_prefered = false);
QString address;
};
class Phone : public Contact {
public:
enum Type {
fax,
pager,
voice,
cell,
video,
modem,
other
};
static const std::deque<QString> typeNames;
Phone(const QString& number, Type p_type = voice, Role p_role = none, bool p_prefered = false);
QString number;
Type type;
};
class Address : public Contact {
public:
Address(
const QString& zCode = "",
const QString& cntry = "",
const QString& rgn = "",
const QString& lclty = "",
const QString& strt = "",
const QString& ext = "",
Role p_role = none,
bool p_prefered = false
);
QString zipCode;
QString country;
QString region;
QString locality;
QString street;
QString external;
};
VCard();
VCard(const QDateTime& creationTime);
QString getFullName() const;
void setFullName(const QString& name);
QString getFirstName() const;
void setFirstName(const QString& first);
QString getMiddleName() const;
void setMiddleName(const QString& middle);
QString getLastName() const;
void setLastName(const QString& last);
QString getNickName() const;
void setNickName(const QString& nick);
QString getDescription() const;
void setDescription(const QString& descr);
QString getUrl() const;
void setUrl(const QString& u);
QDate getBirthday() const;
void setBirthday(const QDate& date);
Avatar getAvatarType() const;
void setAvatarType(Avatar type);
QString getAvatarPath() const;
void setAvatarPath(const QString& path);
QString getOrgName() const;
void setOrgName(const QString& name);
QString getOrgUnit() const;
void setOrgUnit(const QString& unit);
QString getOrgRole() const;
void setOrgRole(const QString& role);
QString getOrgTitle() const;
void setOrgTitle(const QString& title);
QDateTime getReceivingTime() const;
std::deque<Email>& getEmails();
const std::deque<Email>& getEmails() const;
std::deque<Phone>& getPhones();
const std::deque<Phone>& getPhones() const;
std::deque<Address>& getAddresses();
const std::deque<Address>& getAddresses() const;
private:
QString fullName;
QString firstName;
QString middleName;
QString lastName;
QString nickName;
QString description;
QString url;
QString organizationName;
QString organizationUnit;
QString organizationRole;
QString jobTitle;
QDate birthday;
Avatar photoType;
QString photoPath;
QDateTime receivingTime;
std::deque<Email> emails;
std::deque<Phone> phones;
std::deque<Address> addresses;
};
}
#endif // SHARED_VCARD_H

View File

@ -4,93 +4,63 @@
<context> <context>
<name>Account</name> <name>Account</name>
<message> <message>
<location filename="../ui/widgets/account.ui" line="14"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_account.h" line="127"/>
<source>Account</source> <source>Account</source>
<translatorcomment>Заголовок окна</translatorcomment> <translatorcomment>Заголовок окна</translatorcomment>
<translation>Учетная запись</translation> <translation>Учетная запись</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/account.ui" line="40"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_account.h" line="129"/>
<source>Your account login</source> <source>Your account login</source>
<translation>Имя пользователя Вашей учетной записи</translation> <translation>Имя пользователя Вашей учетной записи</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/account.ui" line="43"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_account.h" line="131"/>
<source>john_smith1987</source> <source>john_smith1987</source>
<translation>ivan_ivanov1987</translation> <translation>ivan_ivanov1987</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/account.ui" line="50"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_account.h" line="132"/>
<source>Server</source> <source>Server</source>
<translation>Сервер</translation> <translation>Сервер</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/account.ui" line="57"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_account.h" line="134"/>
<source>A server address of your account. Like 404.city or macaw.me</source> <source>A server address of your account. Like 404.city or macaw.me</source>
<translation>Адресс сервера вашей учетной записи (выглядит как 404.city или macaw.me)</translation> <translation>Адресс сервера вашей учетной записи (выглядит как 404.city или macaw.me)</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/account.ui" line="60"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_account.h" line="136"/>
<source>macaw.me</source> <source>macaw.me</source>
<translation>macaw.me</translation> <translation>macaw.me</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/account.ui" line="67"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_account.h" line="137"/>
<source>Login</source> <source>Login</source>
<translation>Имя учетной записи</translation> <translation>Имя учетной записи</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/account.ui" line="74"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_account.h" line="138"/>
<source>Password</source> <source>Password</source>
<translation>Пароль</translation> <translation>Пароль</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/account.ui" line="81"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_account.h" line="140"/>
<source>Password of your account</source> <source>Password of your account</source>
<translation>Пароль вашей учетной записи</translation> <translation>Пароль вашей учетной записи</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/account.ui" line="103"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_account.h" line="145"/>
<source>Name</source> <source>Name</source>
<translation>Имя</translation> <translation>Имя</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/account.ui" line="110"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_account.h" line="147"/>
<source>Just a name how would you call this account, doesn&apos;t affect anything</source> <source>Just a name how would you call this account, doesn&apos;t affect anything</source>
<translation>Просто имя, то как Вы называете свою учетную запись, может быть любым</translation> <translation>Просто имя, то как Вы называете свою учетную запись, может быть любым</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/account.ui" line="113"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_account.h" line="149"/>
<source>John</source> <source>John</source>
<translation>Иван</translation> <translation>Иван</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/account.ui" line="120"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_account.h" line="150"/>
<source>Resource</source> <source>Resource</source>
<translation>Ресурс</translation> <translation>Ресурс</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/account.ui" line="127"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_account.h" line="152"/>
<source>A resource name like &quot;Home&quot; or &quot;Work&quot;</source> <source>A resource name like &quot;Home&quot; or &quot;Work&quot;</source>
<translation>Имя этой программы для ваших контактов, может быть &quot;Home&quot; или &quot;Phone&quot;</translation> <translation>Имя этой программы для ваших контактов, может быть &quot;Home&quot; или &quot;Phone&quot;</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/account.ui" line="130"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_account.h" line="154"/>
<source>QXmpp</source> <source>QXmpp</source>
<translatorcomment>Ресурс по умолчанию</translatorcomment> <translatorcomment>Ресурс по умолчанию</translatorcomment>
<translation>QXmpp</translation> <translation>QXmpp</translation>
@ -99,45 +69,30 @@
<context> <context>
<name>Accounts</name> <name>Accounts</name>
<message> <message>
<location filename="../ui/widgets/accounts.ui" line="14"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_accounts.h" line="108"/>
<source>Accounts</source> <source>Accounts</source>
<translation>Учетные записи</translation> <translation>Учетные записи</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/accounts.ui" line="45"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_accounts.h" line="109"/>
<source>Delete</source> <source>Delete</source>
<translation>Удалить</translation> <translation>Удалить</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/accounts.ui" line="86"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_accounts.h" line="110"/>
<source>Add</source> <source>Add</source>
<translation>Добавить</translation> <translation>Добавить</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/accounts.ui" line="96"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_accounts.h" line="111"/>
<source>Edit</source> <source>Edit</source>
<translation>Редактировать</translation> <translation>Редактировать</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/accounts.ui" line="106"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_accounts.h" line="112"/>
<source>Change password</source> <source>Change password</source>
<translation>Изменить пароль</translation> <translation>Изменить пароль</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/accounts.ui" line="129"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_accounts.h" line="113"/>
<location filename="../ui/widgets/accounts.cpp" line="125"/>
<location filename="../ui/widgets/accounts.cpp" line="128"/>
<source>Connect</source> <source>Connect</source>
<translation>Подключить</translation> <translation>Подключить</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/accounts.cpp" line="122"/>
<source>Disconnect</source> <source>Disconnect</source>
<translation>Отключить</translation> <translation>Отключить</translation>
</message> </message>
@ -145,16 +100,21 @@
<context> <context>
<name>Conversation</name> <name>Conversation</name>
<message> <message>
<location filename="../ui/widgets/conversation.ui" line="449"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_conversation.h" line="324"/>
<source>Type your message here...</source> <source>Type your message here...</source>
<translation>Введите сообщение...</translation> <translation>Введите сообщение...</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/conversation.cpp" line="284"/>
<source>Chose a file to send</source> <source>Chose a file to send</source>
<translation>Выберите файл для отправки</translation> <translation>Выберите файл для отправки</translation>
</message> </message>
<message>
<source>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:&apos;Liberation Sans&apos;; font-size:10pt; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</source>
<translation></translation>
</message>
</context> </context>
<context> <context>
<name>Global</name> <name>Global</name>
@ -260,43 +220,43 @@
</message> </message>
<message> <message>
<source>Not specified</source> <source>Not specified</source>
<translation>Не указан</translation> <translation type="vanished">Не указан</translation>
</message> </message>
<message> <message>
<source>Personal</source> <source>Personal</source>
<translation>Личный</translation> <translation type="vanished">Личный</translation>
</message> </message>
<message> <message>
<source>Business</source> <source>Business</source>
<translation>Рабочий</translation> <translation type="vanished">Рабочий</translation>
</message> </message>
<message> <message>
<source>Fax</source> <source>Fax</source>
<translation>Факс</translation> <translation type="vanished">Факс</translation>
</message> </message>
<message> <message>
<source>Pager</source> <source>Pager</source>
<translation>Пэйджер</translation> <translation type="vanished">Пэйджер</translation>
</message> </message>
<message> <message>
<source>Voice</source> <source>Voice</source>
<translation>Стационарный</translation> <translation type="vanished">Стационарный</translation>
</message> </message>
<message> <message>
<source>Cell</source> <source>Cell</source>
<translation>Мобильный</translation> <translation type="vanished">Мобильный</translation>
</message> </message>
<message> <message>
<source>Video</source> <source>Video</source>
<translation>Видеофон</translation> <translation type="vanished">Видеофон</translation>
</message> </message>
<message> <message>
<source>Modem</source> <source>Modem</source>
<translation>Модем</translation> <translation type="vanished">Модем</translation>
</message> </message>
<message> <message>
<source>Other</source> <source>Other</source>
<translation>Другой</translation> <translation type="vanished">Другой</translation>
</message> </message>
<message> <message>
<source>Pending</source> <source>Pending</source>
@ -314,63 +274,43 @@
<context> <context>
<name>JoinConference</name> <name>JoinConference</name>
<message> <message>
<location filename="../ui/widgets/joinconference.ui" line="14"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_joinconference.h" line="116"/>
<source>Join new conference</source> <source>Join new conference</source>
<translatorcomment>Заголовок окна</translatorcomment> <translatorcomment>Заголовок окна</translatorcomment>
<translation>Присоединиться к новой беседе</translation> <translation>Присоединиться к новой беседе</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/joinconference.ui" line="22"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_joinconference.h" line="117"/>
<source>JID</source> <source>JID</source>
<translation>JID</translation> <translation>JID</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/joinconference.ui" line="29"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_joinconference.h" line="119"/>
<source>Room JID</source> <source>Room JID</source>
<translation>Jabber-идентификатор беседы</translation> <translation>Jabber-идентификатор беседы</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/joinconference.ui" line="32"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_joinconference.h" line="121"/>
<source>identifier@conference.server.org</source> <source>identifier@conference.server.org</source>
<translation>identifier@conference.server.org</translation> <translation>identifier@conference.server.org</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/joinconference.ui" line="39"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_joinconference.h" line="122"/>
<source>Account</source> <source>Account</source>
<translation>Учетная запись</translation> <translation>Учетная запись</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/joinconference.ui" line="49"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_joinconference.h" line="123"/>
<source>Join on login</source> <source>Join on login</source>
<translation>Автовход</translation> <translation>Автовход</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/joinconference.ui" line="56"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_joinconference.h" line="125"/>
<source>If checked Squawk will try to join this conference on login</source> <source>If checked Squawk will try to join this conference on login</source>
<translation>Если стоит галочка Squawk автоматически присоединится к этой беседе при подключении</translation> <translation>Если стоит галочка Squawk автоматически присоединится к этой беседе при подключении</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/joinconference.ui" line="66"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_joinconference.h" line="128"/>
<source>Nick name</source> <source>Nick name</source>
<translation>Псевдоним</translation> <translation>Псевдоним</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/joinconference.ui" line="73"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_joinconference.h" line="130"/>
<source>Your nick name for that conference. If you leave this field empty your account name will be used as a nick name</source> <source>Your nick name for that conference. If you leave this field empty your account name will be used as a nick name</source>
<translation>Ваш псевдоним в этой беседе, если оставите это поле пустым - будет использовано имя Вашей учетной записи</translation> <translation>Ваш псевдоним в этой беседе, если оставите это поле пустым - будет использовано имя Вашей учетной записи</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/joinconference.ui" line="76"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_joinconference.h" line="132"/>
<source>John</source> <source>John</source>
<translation>Ivan</translation> <translation>Ivan</translation>
</message> </message>
@ -379,10 +319,9 @@
<name>Message</name> <name>Message</name>
<message> <message>
<source>Download</source> <source>Download</source>
<translation>Скачать</translation> <translation type="vanished">Скачать</translation>
</message> </message>
<message> <message>
<location filename="../ui/utils/message.cpp" line="172"/>
<source>Open</source> <source>Open</source>
<translation>Открыть</translation> <translation>Открыть</translation>
</message> </message>
@ -390,23 +329,18 @@
<context> <context>
<name>MessageLine</name> <name>MessageLine</name>
<message> <message>
<location filename="../ui/utils/messageline.cpp" line="146"/>
<source>Downloading...</source> <source>Downloading...</source>
<translation>Скачивается...</translation> <translation>Скачивается...</translation>
</message> </message>
<message> <message>
<location filename="../ui/utils/messageline.cpp" line="258"/>
<location filename="../ui/utils/messageline.cpp" line="324"/>
<source>Download</source> <source>Download</source>
<translation>Скачать</translation> <translation>Скачать</translation>
</message> </message>
<message> <message>
<location filename="../ui/utils/messageline.cpp" line="259"/>
<source>Push the button to daownload the file</source> <source>Push the button to daownload the file</source>
<translation>Нажмите на кнопку что бы загрузить файл</translation> <translation>Нажмите на кнопку что бы загрузить файл</translation>
</message> </message>
<message> <message>
<location filename="../ui/utils/messageline.cpp" line="319"/>
<source>Error uploading file: %1 <source>Error uploading file: %1
You can try again</source> You can try again</source>
<translation>Ошибка загрузки файла на сервер: <translation>Ошибка загрузки файла на сервер:
@ -414,12 +348,10 @@ You can try again</source>
Для того, что бы попробовать снова нажмите на кнопку</translation> Для того, что бы попробовать снова нажмите на кнопку</translation>
</message> </message>
<message> <message>
<location filename="../ui/utils/messageline.cpp" line="320"/>
<source>Upload</source> <source>Upload</source>
<translation>Загрузить</translation> <translation>Загрузить</translation>
</message> </message>
<message> <message>
<location filename="../ui/utils/messageline.cpp" line="325"/>
<source>Error downloading file: %1 <source>Error downloading file: %1
You can try again</source> You can try again</source>
<translation>Ошибка скачивания файла: <translation>Ошибка скачивания файла:
@ -427,7 +359,6 @@ You can try again</source>
Вы можете попробовать снова</translation> Вы можете попробовать снова</translation>
</message> </message>
<message> <message>
<location filename="../ui/utils/messageline.cpp" line="336"/>
<source>Uploading...</source> <source>Uploading...</source>
<translation>Загружается...</translation> <translation>Загружается...</translation>
</message> </message>
@ -436,40 +367,36 @@ You can try again</source>
<name>Models::Accounts</name> <name>Models::Accounts</name>
<message> <message>
<source>Name</source> <source>Name</source>
<translation>Имя</translation> <translation type="vanished">Имя</translation>
</message> </message>
<message> <message>
<source>Server</source> <source>Server</source>
<translation>Сервер</translation> <translation type="vanished">Сервер</translation>
</message> </message>
<message> <message>
<source>State</source> <source>State</source>
<translation>Состояние</translation> <translation type="vanished">Состояние</translation>
</message> </message>
<message> <message>
<source>Error</source> <source>Error</source>
<translation>Ошибка</translation> <translation type="vanished">Ошибка</translation>
</message> </message>
</context> </context>
<context> <context>
<name>Models::Room</name> <name>Models::Room</name>
<message> <message>
<location filename="../ui/models/room.cpp" line="196"/>
<source>Subscribed</source> <source>Subscribed</source>
<translation>Вы состоите в беседе</translation> <translation>Вы состоите в беседе</translation>
</message> </message>
<message> <message>
<location filename="../ui/models/room.cpp" line="198"/>
<source>Temporarily unsubscribed</source> <source>Temporarily unsubscribed</source>
<translation>Вы временно не состоите в беседе</translation> <translation>Вы временно не состоите в беседе</translation>
</message> </message>
<message> <message>
<location filename="../ui/models/room.cpp" line="202"/>
<source>Temporarily subscribed</source> <source>Temporarily subscribed</source>
<translation>Вы временно состоите в беседе</translation> <translation>Вы временно состоите в беседе</translation>
</message> </message>
<message> <message>
<location filename="../ui/models/room.cpp" line="204"/>
<source>Unsubscribed</source> <source>Unsubscribed</source>
<translation>Вы не состоите в беседе</translation> <translation>Вы не состоите в беседе</translation>
</message> </message>
@ -477,67 +404,47 @@ You can try again</source>
<context> <context>
<name>Models::Roster</name> <name>Models::Roster</name>
<message> <message>
<location filename="../ui/models/roster.cpp" line="80"/>
<source>New messages</source> <source>New messages</source>
<translation>Есть непрочитанные сообщения</translation> <translation>Есть непрочитанные сообщения</translation>
</message> </message>
<message> <message>
<location filename="../ui/models/roster.cpp" line="178"/>
<location filename="../ui/models/roster.cpp" line="204"/>
<location filename="../ui/models/roster.cpp" line="241"/>
<location filename="../ui/models/roster.cpp" line="253"/>
<source>New messages: </source> <source>New messages: </source>
<translation>Новых сообщений: </translation> <translation>Новых сообщений: </translation>
</message> </message>
<message> <message>
<location filename="../ui/models/roster.cpp" line="180"/>
<source>Jabber ID: </source> <source>Jabber ID: </source>
<translation>Идентификатор: </translation> <translation>Идентификатор: </translation>
</message> </message>
<message> <message>
<location filename="../ui/models/roster.cpp" line="184"/>
<location filename="../ui/models/roster.cpp" line="207"/>
<location filename="../ui/models/roster.cpp" line="220"/>
<source>Availability: </source> <source>Availability: </source>
<translation>Доступность: </translation> <translation>Доступность: </translation>
</message> </message>
<message> <message>
<location filename="../ui/models/roster.cpp" line="188"/>
<location filename="../ui/models/roster.cpp" line="210"/>
<location filename="../ui/models/roster.cpp" line="223"/>
<source>Status: </source> <source>Status: </source>
<translation>Статус: </translation> <translation>Статус: </translation>
</message> </message>
<message> <message>
<location filename="../ui/models/roster.cpp" line="191"/>
<location filename="../ui/models/roster.cpp" line="193"/>
<location filename="../ui/models/roster.cpp" line="255"/>
<source>Subscription: </source> <source>Subscription: </source>
<translation>Подписка: </translation> <translation>Подписка: </translation>
</message> </message>
<message> <message>
<location filename="../ui/models/roster.cpp" line="226"/>
<source>Affiliation: </source> <source>Affiliation: </source>
<translatorcomment>Я правда не знаю, как это объяснить, не то что перевести</translatorcomment> <translatorcomment>Я правда не знаю, как это объяснить, не то что перевести</translatorcomment>
<translation>Причастность: </translation> <translation>Причастность: </translation>
</message> </message>
<message> <message>
<location filename="../ui/models/roster.cpp" line="229"/>
<source>Role: </source> <source>Role: </source>
<translation>Роль: </translation> <translation>Роль: </translation>
</message> </message>
<message> <message>
<location filename="../ui/models/roster.cpp" line="243"/>
<source>Online contacts: </source> <source>Online contacts: </source>
<translation>Контакстов в сети: </translation> <translation>Контакстов в сети: </translation>
</message> </message>
<message> <message>
<location filename="../ui/models/roster.cpp" line="244"/>
<source>Total contacts: </source> <source>Total contacts: </source>
<translation>Всего контактов: </translation> <translation>Всего контактов: </translation>
</message> </message>
<message> <message>
<location filename="../ui/models/roster.cpp" line="257"/>
<source>Members: </source> <source>Members: </source>
<translation>Участников: </translation> <translation>Участников: </translation>
</message> </message>
@ -545,58 +452,40 @@ You can try again</source>
<context> <context>
<name>NewContact</name> <name>NewContact</name>
<message> <message>
<location filename="../ui/widgets/newcontact.ui" line="14"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_newcontact.h" line="103"/>
<source>Add new contact</source> <source>Add new contact</source>
<translatorcomment>Заголовок окна</translatorcomment> <translatorcomment>Заголовок окна</translatorcomment>
<translation>Добавление нового контакта</translation> <translation>Добавление нового контакта</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/newcontact.ui" line="22"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_newcontact.h" line="104"/>
<source>Account</source> <source>Account</source>
<translation>Учетная запись</translation> <translation>Учетная запись</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/newcontact.ui" line="29"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_newcontact.h" line="106"/>
<source>An account that is going to have new contact</source> <source>An account that is going to have new contact</source>
<translation>Учетная запись для которой будет добавлен контакт</translation> <translation>Учетная запись для которой будет добавлен контакт</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/newcontact.ui" line="36"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_newcontact.h" line="108"/>
<source>JID</source> <source>JID</source>
<translation>JID</translation> <translation>JID</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/newcontact.ui" line="43"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_newcontact.h" line="110"/>
<source>Jabber id of your new contact</source> <source>Jabber id of your new contact</source>
<translation>Jabber-идентификатор нового контакта</translation> <translation>Jabber-идентификатор нового контакта</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/newcontact.ui" line="46"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_newcontact.h" line="112"/>
<source>name@server.dmn</source> <source>name@server.dmn</source>
<translatorcomment>Placeholder поля ввода JID</translatorcomment> <translatorcomment>Placeholder поля ввода JID</translatorcomment>
<translation>name@server.dmn</translation> <translation>name@server.dmn</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/newcontact.ui" line="53"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_newcontact.h" line="113"/>
<source>Name</source> <source>Name</source>
<translation>Имя</translation> <translation>Имя</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/newcontact.ui" line="60"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_newcontact.h" line="115"/>
<source>The way this new contact will be labeled in your roster (optional)</source> <source>The way this new contact will be labeled in your roster (optional)</source>
<translation>То, как будет подписан контакт в вашем списке контактов (не обязательно)</translation> <translation>То, как будет подписан контакт в вашем списке контактов (не обязательно)</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/newcontact.ui" line="63"/>
<location filename="../build/ui/widgets/squawkWidgets_autogen/include/ui_newcontact.h" line="117"/>
<source>John Smith</source> <source>John Smith</source>
<translation>Иван Иванов</translation> <translation>Иван Иванов</translation>
</message> </message>
@ -604,99 +493,70 @@ You can try again</source>
<context> <context>
<name>Squawk</name> <name>Squawk</name>
<message> <message>
<location filename="../ui/squawk.ui" line="14"/>
<location filename="../build/ui/squawkUI_autogen/include/ui_squawk.h" line="137"/>
<source>squawk</source> <source>squawk</source>
<translation>Squawk</translation> <translation>Squawk</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.ui" line="78"/>
<location filename="../build/ui/squawkUI_autogen/include/ui_squawk.h" line="143"/>
<source>Settings</source> <source>Settings</source>
<translation>Настройки</translation> <translation>Настройки</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.ui" line="84"/>
<location filename="../build/ui/squawkUI_autogen/include/ui_squawk.h" line="144"/>
<source>Squawk</source> <source>Squawk</source>
<translation>Squawk</translation> <translation>Squawk</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.ui" line="99"/>
<location filename="../build/ui/squawkUI_autogen/include/ui_squawk.h" line="138"/>
<source>Accounts</source> <source>Accounts</source>
<translation>Учетные записи</translation> <translation>Учетные записи</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.ui" line="108"/>
<location filename="../build/ui/squawkUI_autogen/include/ui_squawk.h" line="139"/>
<source>Quit</source> <source>Quit</source>
<translation>Выйти</translation> <translation>Выйти</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.ui" line="120"/>
<location filename="../build/ui/squawkUI_autogen/include/ui_squawk.h" line="140"/>
<source>Add contact</source> <source>Add contact</source>
<translation>Добавить контакт</translation> <translation>Добавить контакт</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.ui" line="132"/>
<location filename="../build/ui/squawkUI_autogen/include/ui_squawk.h" line="141"/>
<source>Add conference</source> <source>Add conference</source>
<translation>Присоединиться к беседе</translation> <translation>Присоединиться к беседе</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.cpp" line="60"/>
<source>Contact list</source> <source>Contact list</source>
<translation>Список контактов</translation> <translation>Список контактов</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.cpp" line="558"/>
<source>Disconnect</source> <source>Disconnect</source>
<translation>Отключить</translation> <translation>Отключить</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.cpp" line="564"/>
<source>Connect</source> <source>Connect</source>
<translation>Подключить</translation> <translation>Подключить</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.cpp" line="570"/>
<location filename="../ui/squawk.cpp" line="668"/>
<source>VCard</source> <source>VCard</source>
<translation>Карточка</translation> <translation>Карточка</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.cpp" line="574"/>
<location filename="../ui/squawk.cpp" line="672"/>
<location filename="../ui/squawk.cpp" line="712"/>
<source>Remove</source> <source>Remove</source>
<translation>Удалить</translation> <translation>Удалить</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.cpp" line="586"/>
<source>Open dialog</source> <source>Open dialog</source>
<translation>Открыть диалог</translation> <translation>Открыть диалог</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.cpp" line="596"/>
<location filename="../ui/squawk.cpp" line="693"/>
<source>Unsubscribe</source> <source>Unsubscribe</source>
<translation>Отписаться</translation> <translation>Отписаться</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.cpp" line="606"/>
<location filename="../ui/squawk.cpp" line="702"/>
<source>Subscribe</source> <source>Subscribe</source>
<translation>Подписаться</translation> <translation>Подписаться</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.cpp" line="617"/>
<source>Rename</source> <source>Rename</source>
<translation>Переименовать</translation> <translation>Переименовать</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.cpp" line="630"/>
<source>Input new name for %1 <source>Input new name for %1
or leave it empty for the contact or leave it empty for the contact
to be displayed as %1</source> to be displayed as %1</source>
@ -706,269 +566,197 @@ to be displayed as %1</source>
%1</translation> %1</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.cpp" line="631"/>
<source>Renaming %1</source> <source>Renaming %1</source>
<translation>Назначение имени контакту %1</translation> <translation>Назначение имени контакту %1</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.cpp" line="637"/>
<source>Groups</source> <source>Groups</source>
<translation>Группы</translation> <translation>Группы</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.cpp" line="652"/>
<source>New group</source> <source>New group</source>
<translation>Создать новую группу</translation> <translation>Создать новую группу</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.cpp" line="662"/>
<source>New group name</source> <source>New group name</source>
<translation>Имя группы</translation> <translation>Имя группы</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.cpp" line="663"/>
<source>Add %1 to a new group</source> <source>Add %1 to a new group</source>
<translation>Добавление %1 в новую группу</translation> <translation>Добавление %1 в новую группу</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.cpp" line="684"/>
<source>Open conversation</source> <source>Open conversation</source>
<translation>Открыть окно беседы</translation> <translation>Открыть окно беседы</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.cpp" line="789"/>
<source>%1 account card</source> <source>%1 account card</source>
<translation>Карточка учетной записи %1</translation> <translation>Карточка учетной записи %1</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.cpp" line="791"/>
<source>%1 contact card</source> <source>%1 contact card</source>
<translation>Карточка контакта %1</translation> <translation>Карточка контакта %1</translation>
</message> </message>
<message> <message>
<location filename="../ui/squawk.cpp" line="803"/>
<source>Downloading vCard</source> <source>Downloading vCard</source>
<translation>Получение карточки</translation> <translation>Получение карточки</translation>
</message> </message>
<message>
<source>Attached file</source>
<translation>Прикрепленный файл</translation>
</message>
</context> </context>
<context> <context>
<name>VCard</name> <name>VCard</name>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="65"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="612"/>
<source>Received 12.07.2007 at 17.35</source> <source>Received 12.07.2007 at 17.35</source>
<translation>Не обновлялось</translation> <translation>Не обновлялось</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="100"/>
<location filename="../ui/widgets/vcard/vcard.ui" line="425"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="624"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="627"/>
<source>General</source> <source>General</source>
<translation>Общее</translation> <translation>Общее</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="130"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="613"/>
<source>Organization</source> <source>Organization</source>
<translation>Место работы</translation> <translation>Место работы</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="180"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="614"/>
<source>Middle name</source> <source>Middle name</source>
<translation>Среднее имя</translation> <translation>Среднее имя</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="190"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="615"/>
<source>First name</source> <source>First name</source>
<translation>Имя</translation> <translation>Имя</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="200"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="616"/>
<source>Last name</source> <source>Last name</source>
<translation>Фамилия</translation> <translation>Фамилия</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="226"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="617"/>
<source>Nick name</source> <source>Nick name</source>
<translation>Псевдоним</translation> <translation>Псевдоним</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="252"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="618"/>
<source>Birthday</source> <source>Birthday</source>
<translation>Дата рождения</translation> <translation>Дата рождения</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="272"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="619"/>
<source>Organization name</source> <source>Organization name</source>
<translation>Название организации</translation> <translation>Название организации</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="298"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="620"/>
<source>Unit / Department</source> <source>Unit / Department</source>
<translation>Отдел</translation> <translation>Отдел</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="324"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="621"/>
<source>Role / Profession</source> <source>Role / Profession</source>
<translation>Профессия</translation> <translation>Профессия</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="350"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="622"/>
<source>Job title</source> <source>Job title</source>
<translation>Наименование должности</translation> <translation>Наименование должности</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="390"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="623"/>
<source>Full name</source> <source>Full name</source>
<translation>Полное имя</translation> <translation>Полное имя</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="460"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="625"/>
<source>Personal information</source> <source>Personal information</source>
<translation>Личная информация</translation> <translation>Личная информация</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="653"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="629"/>
<source>Addresses</source> <source>Addresses</source>
<translation>Адреса</translation> <translation>Адреса</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="682"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="630"/>
<source>E-Mail addresses</source> <source>E-Mail addresses</source>
<translation>Адреса электронной почты</translation> <translation>Адреса электронной почты</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="767"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="633"/>
<source>Phone numbers</source> <source>Phone numbers</source>
<translation>Номера телефонов</translation> <translation>Номера телефонов</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="522"/>
<location filename="../ui/widgets/vcard/vcard.ui" line="546"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="628"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="634"/>
<source>Contact</source> <source>Contact</source>
<translation>Контактная информация</translation> <translation>Контактная информация</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="713"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="631"/>
<source>Jabber ID</source> <source>Jabber ID</source>
<translation>Jabber ID</translation> <translation>Jabber ID</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="739"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="632"/>
<source>Web site</source> <source>Web site</source>
<translation>Веб сайт</translation> <translation>Веб сайт</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="798"/>
<location filename="../ui/widgets/vcard/vcard.ui" line="822"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="635"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="636"/>
<source>Description</source> <source>Description</source>
<translation>Описание</translation> <translation>Описание</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="859"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="610"/>
<source>Set avatar</source> <source>Set avatar</source>
<translation>Установить иконку</translation> <translation>Установить иконку</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.ui" line="868"/>
<location filename="../build/ui/widgets/vcard/vCardUI_autogen/include/ui_vcard.h" line="611"/>
<source>Clear avatar</source> <source>Clear avatar</source>
<translation>Убрать иконку</translation> <translation>Убрать иконку</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.cpp" line="93"/>
<source>Account %1 card</source> <source>Account %1 card</source>
<translation>Карточка учетной записи %1</translation> <translation>Карточка учетной записи %1</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.cpp" line="108"/>
<source>Contact %1 card</source> <source>Contact %1 card</source>
<translation>Карточка контакта %1</translation> <translation>Карточка контакта %1</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.cpp" line="170"/>
<source>Received %1 at %2</source> <source>Received %1 at %2</source>
<translation>Получено %1 в %2</translation> <translation>Получено %1 в %2</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.cpp" line="221"/>
<source>Chose your new avatar</source> <source>Chose your new avatar</source>
<translation>Выберите новую иконку</translation> <translation>Выберите новую иконку</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.cpp" line="223"/>
<source>Images (*.png *.jpg *.jpeg)</source> <source>Images (*.png *.jpg *.jpeg)</source>
<translation>Изображения (*.png *.jpg *.jpeg)</translation> <translation>Изображения (*.png *.jpg *.jpeg)</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.cpp" line="310"/>
<source>Add email address</source> <source>Add email address</source>
<translation>Добавить адрес электронной почты</translation> <translation>Добавить адрес электронной почты</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.cpp" line="320"/>
<source>Unset this email as preferred</source> <source>Unset this email as preferred</source>
<translation>Убрать отметку &quot;предпочтительный&quot; с этого адреса</translation> <translation>Убрать отметку &quot;предпочтительный&quot; с этого адреса</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.cpp" line="323"/>
<source>Set this email as preferred</source> <source>Set this email as preferred</source>
<translation>Отметить этот адрес как &quot;предпочтительный&quot;</translation> <translation>Отметить этот адрес как &quot;предпочтительный&quot;</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.cpp" line="328"/>
<source>Remove selected email addresses</source> <source>Remove selected email addresses</source>
<translation>Удалить выбранные адреса</translation> <translation>Удалить выбранные адреса</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.cpp" line="333"/>
<source>Copy selected emails to clipboard</source> <source>Copy selected emails to clipboard</source>
<translation>Скопировать выбранные адреса в буфер обмена</translation> <translation>Скопировать выбранные адреса в буфер обмена</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.cpp" line="338"/>
<source>Add phone number</source> <source>Add phone number</source>
<translation>Добавить номер телефона</translation> <translation>Добавить номер телефона</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.cpp" line="348"/>
<source>Unset this phone as preferred</source> <source>Unset this phone as preferred</source>
<translation>Убрать отметку &quot;предпочтительный&quot; с этого номера</translation> <translation>Убрать отметку &quot;предпочтительный&quot; с этого номера</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.cpp" line="351"/>
<source>Set this phone as preferred</source> <source>Set this phone as preferred</source>
<translation>Отметить этот номер как &quot;предпочтительный&quot;</translation> <translation>Отметить этот номер как &quot;предпочтительный&quot;</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.cpp" line="356"/>
<source>Remove selected phone numbers</source> <source>Remove selected phone numbers</source>
<translation>Удалить выбранные телефонные номера</translation> <translation>Удалить выбранные телефонные номера</translation>
</message> </message>
<message> <message>
<location filename="../ui/widgets/vcard/vcard.cpp" line="361"/>
<source>Copy selected phones to clipboard</source> <source>Copy selected phones to clipboard</source>
<translation>Скопировать выбранные телефонные номера в буфер обмена</translation> <translation>Скопировать выбранные телефонные номера в буфер обмена</translation>
</message> </message>

View File

@ -22,7 +22,7 @@ using namespace Models;
Models::AbstractParticipant::AbstractParticipant(Models::Item::Type p_type, const QMap<QString, QVariant>& data, Models::Item* parentItem): Models::AbstractParticipant::AbstractParticipant(Models::Item::Type p_type, const QMap<QString, QVariant>& data, Models::Item* parentItem):
Item(p_type, data, parentItem), Item(p_type, data, parentItem),
availability(Shared::offline), availability(Shared::Availability::offline),
lastActivity(data.value("lastActivity").toDateTime()), lastActivity(data.value("lastActivity").toDateTime()),
status(data.value("status").toString()) status(data.value("status").toString())
{ {
@ -58,7 +58,7 @@ QVariant Models::AbstractParticipant::data(int column) const
case 1: case 1:
return lastActivity; return lastActivity;
case 2: case 2:
return availability; return QVariant::fromValue(availability);
case 3: case 3:
return status; return status;
default: default:
@ -91,15 +91,9 @@ void Models::AbstractParticipant::setAvailability(Shared::Availability p_avail)
void Models::AbstractParticipant::setAvailability(unsigned int avail) void Models::AbstractParticipant::setAvailability(unsigned int avail)
{ {
if (avail <= Shared::availabilityHighest) { setAvailability(Shared::Global::fromInt<Shared::Availability>(avail));
Shared::Availability state = static_cast<Shared::Availability>(avail);
setAvailability(state);
} else {
qDebug("An attempt to set wrong state to the contact");
}
} }
void Models::AbstractParticipant::setLastActivity(const QDateTime& p_time) void Models::AbstractParticipant::setLastActivity(const QDateTime& p_time)
{ {
if (lastActivity != p_time) { if (lastActivity != p_time) {

View File

@ -21,8 +21,12 @@
#include "item.h" #include "item.h"
#include "../../global.h" #include "shared/enums.h"
#include "shared/icons.h"
#include "shared/global.h"
#include <QIcon> #include <QIcon>
#include <QDateTime>
namespace Models { namespace Models {

View File

@ -27,8 +27,8 @@ Models::Account::Account(const QMap<QString, QVariant>& data, Models::Item* pare
resource(data.value("resource").toString()), resource(data.value("resource").toString()),
error(data.value("error").toString()), error(data.value("error").toString()),
avatarPath(data.value("avatarPath").toString()), avatarPath(data.value("avatarPath").toString()),
state(Shared::disconnected), state(Shared::ConnectionState::disconnected),
availability(Shared::offline) availability(Shared::Availability::offline)
{ {
QMap<QString, QVariant>::const_iterator sItr = data.find("state"); QMap<QString, QVariant>::const_iterator sItr = data.find("state");
if (sItr != data.end()) { if (sItr != data.end()) {
@ -49,7 +49,7 @@ void Models::Account::setState(Shared::ConnectionState p_state)
if (state != p_state) { if (state != p_state) {
state = p_state; state = p_state;
changed(2); changed(2);
if (state == Shared::disconnected) { if (state == Shared::ConnectionState::disconnected) {
toOfflineState(); toOfflineState();
} }
} }
@ -57,22 +57,12 @@ void Models::Account::setState(Shared::ConnectionState p_state)
void Models::Account::setAvailability(unsigned int p_state) void Models::Account::setAvailability(unsigned int p_state)
{ {
if (p_state <= Shared::availabilityHighest) { setAvailability(Shared::Global::fromInt<Shared::Availability>(p_state));
Shared::Availability state = static_cast<Shared::Availability>(p_state);
setAvailability(state);
} else {
qDebug() << "An attempt to set invalid availability " << p_state << " to the account " << name;
}
} }
void Models::Account::setState(unsigned int p_state) void Models::Account::setState(unsigned int p_state)
{ {
if (p_state <= Shared::subscriptionStateHighest) { setState(Shared::Global::fromInt<Shared::ConnectionState>(p_state));
Shared::ConnectionState state = static_cast<Shared::ConnectionState>(p_state);
setState(state);
} else {
qDebug() << "An attempt to set invalid subscription state " << p_state << " to the account " << name;
}
} }
Shared::Availability Models::Account::getAvailability() const Shared::Availability Models::Account::getAvailability() const
@ -90,10 +80,10 @@ void Models::Account::setAvailability(Shared::Availability p_avail)
QIcon Models::Account::getStatusIcon(bool big) const QIcon Models::Account::getStatusIcon(bool big) const
{ {
if (state == Shared::connected) { if (state == Shared::ConnectionState::connected) {
return Shared::availabilityIcon(availability, big); return Shared::availabilityIcon(availability, big);
} else if (state == Shared::disconnected) { } else if (state == Shared::ConnectionState::disconnected) {
return Shared::availabilityIcon(Shared::offline, big); return Shared::availabilityIcon(Shared::Availability::offline, big);
} else { } else {
return Shared::connectionStateIcon(state); return Shared::connectionStateIcon(state);
} }
@ -152,7 +142,7 @@ QVariant Models::Account::data(int column) const
case 1: case 1:
return server; return server;
case 2: case 2:
return QCoreApplication::translate("Global", Shared::connectionStateNames[state].toLatin1()); return Shared::Global::getName(state);
case 3: case 3:
return error; return error;
case 4: case 4:
@ -160,7 +150,7 @@ QVariant Models::Account::data(int column) const
case 5: case 5:
return password; return password;
case 6: case 6:
return QCoreApplication::translate("Global", Shared::availabilityNames[availability].toLatin1()); return Shared::Global::getName(availability);
case 7: case 7:
return resource; return resource;
case 8: case 8:
@ -226,7 +216,7 @@ void Models::Account::setError(const QString& p_resource)
void Models::Account::toOfflineState() void Models::Account::toOfflineState()
{ {
setAvailability(Shared::offline); setAvailability(Shared::Availability::offline);
Item::toOfflineState(); Item::toOfflineState();
} }

View File

@ -19,7 +19,10 @@
#ifndef MODELS_ACCOUNT_H #ifndef MODELS_ACCOUNT_H
#define MODELS_ACCOUNT_H #define MODELS_ACCOUNT_H
#include "../../global.h" #include "shared/enums.h"
#include "shared/utils.h"
#include "shared/icons.h"
#include "shared/global.h"
#include "item.h" #include "item.h"
#include <QVariant> #include <QVariant>
#include <QIcon> #include <QIcon>

View File

@ -17,7 +17,7 @@
*/ */
#include "accounts.h" #include "accounts.h"
#include "../../global.h" #include "shared/icons.h"
#include <QIcon> #include <QIcon>
#include <QDebug> #include <QDebug>

View File

@ -23,8 +23,8 @@
Models::Contact::Contact(const QString& p_jid ,const QMap<QString, QVariant> &data, Item *parentItem): Models::Contact::Contact(const QString& p_jid ,const QMap<QString, QVariant> &data, Item *parentItem):
Item(Item::contact, data, parentItem), Item(Item::contact, data, parentItem),
jid(p_jid), jid(p_jid),
availability(Shared::offline), availability(Shared::Availability::offline),
state(Shared::none), state(Shared::SubscriptionState::none),
avatarState(Shared::Avatar::empty), avatarState(Shared::Avatar::empty),
presences(), presences(),
messages(), messages(),
@ -66,22 +66,12 @@ void Models::Contact::setJid(const QString p_jid)
void Models::Contact::setAvailability(unsigned int p_state) void Models::Contact::setAvailability(unsigned int p_state)
{ {
if (p_state <= Shared::availabilityHighest) { setAvailability(Shared::Global::fromInt<Shared::Availability>(p_state));
Shared::Availability state = static_cast<Shared::Availability>(p_state);
setAvailability(state);
} else {
qDebug() << "An attempt to set invalid availability " << p_state << " to the contact " << jid;
}
} }
void Models::Contact::setState(unsigned int p_state) void Models::Contact::setState(unsigned int p_state)
{ {
if (p_state <= Shared::subscriptionStateHighest) { setState(Shared::Global::fromInt<Shared::SubscriptionState>(p_state));
Shared::SubscriptionState state = static_cast<Shared::SubscriptionState>(p_state);
setState(state);
} else {
qDebug() << "An attempt to set invalid subscription state " << p_state << " to the contact " << jid;
}
} }
Shared::Availability Models::Contact::getAvailability() const Shared::Availability Models::Contact::getAvailability() const
@ -123,15 +113,15 @@ QVariant Models::Contact::data(int column) const
case 1: case 1:
return jid; return jid;
case 2: case 2:
return state; return QVariant::fromValue(state);
case 3: case 3:
return availability; return QVariant::fromValue(availability);
case 4: case 4:
return getMessagesCount(); return getMessagesCount();
case 5: case 5:
return getStatus(); return getStatus();
case 6: case 6:
return static_cast<quint8>(getAvatarState()); return QVariant::fromValue(getAvatarState());
case 7: case 7:
return getAvatarPath(); return getAvatarPath();
default: default:
@ -216,7 +206,7 @@ void Models::Contact::refresh()
setAvailability(presence->getAvailability()); setAvailability(presence->getAvailability());
setStatus(presence->getStatus()); setStatus(presence->getStatus());
} else { } else {
setAvailability(Shared::offline); setAvailability(Shared::Availability::offline);
setStatus(""); setStatus("");
} }
@ -258,7 +248,7 @@ QIcon Models::Contact::getStatusIcon(bool big) const
{ {
if (getMessagesCount() > 0) { if (getMessagesCount() > 0) {
return Shared::icon("mail-message", big); return Shared::icon("mail-message", big);
} else if (state == Shared::both || state == Shared::to) { } else if (state == Shared::SubscriptionState::both || state == Shared::SubscriptionState::to) {
return Shared::availabilityIcon(availability, big);; return Shared::availabilityIcon(availability, big);;
} else { } else {
return Shared::subscriptionStateIcon(state, big); return Shared::subscriptionStateIcon(state, big);
@ -276,7 +266,7 @@ void Models::Contact::addMessage(const Shared::Message& data)
// the only issue is to find out when the sender is gone offline // the only issue is to find out when the sender is gone offline
Presence* pr = new Presence({}); Presence* pr = new Presence({});
pr->setName(res); pr->setName(res);
pr->setAvailability(Shared::invisible); pr->setAvailability(Shared::Availability::invisible);
pr->setLastActivity(QDateTime::currentDateTimeUtc()); pr->setLastActivity(QDateTime::currentDateTimeUtc());
presences.insert(res, pr); presences.insert(res, pr);
appendChild(pr); appendChild(pr);

View File

@ -21,7 +21,11 @@
#include "item.h" #include "item.h"
#include "presence.h" #include "presence.h"
#include "global.h" #include "shared/enums.h"
#include "shared/message.h"
#include "shared/icons.h"
#include "shared/global.h"
#include <QMap> #include <QMap>
#include <QIcon> #include <QIcon>
#include <deque> #include <deque>

View File

@ -96,7 +96,7 @@ unsigned int Models::Group::getOnlineContacts() const
for (std::deque<Models::Item*>::const_iterator itr = childItems.begin(), end = childItems.end(); itr != end; ++itr) { for (std::deque<Models::Item*>::const_iterator itr = childItems.begin(), end = childItems.end(); itr != end; ++itr) {
Models::Contact* cnt = static_cast<Models::Contact*>(*itr); Models::Contact* cnt = static_cast<Models::Contact*>(*itr);
if (cnt->getAvailability() != Shared::offline) { if (cnt->getAvailability() != Shared::Availability::offline) {
++amount; ++amount;
} }
} }

View File

@ -238,7 +238,7 @@ Shared::Availability Models::Item::getAccountAvailability() const
{ {
const Account* acc = static_cast<const Account*>(getParentAccount()); const Account* acc = static_cast<const Account*>(getParentAccount());
if (acc == 0) { if (acc == 0) {
return Shared::offline; return Shared::Availability::offline;
} }
return acc->getAvailability(); return acc->getAvailability();
} }
@ -247,7 +247,7 @@ Shared::ConnectionState Models::Item::getAccountConnectionState() const
{ {
const Account* acc = static_cast<const Account*>(getParentAccount()); const Account* acc = static_cast<const Account*>(getParentAccount());
if (acc == 0) { if (acc == 0) {
return Shared::disconnected; return Shared::ConnectionState::disconnected;
} }
return acc->getState(); return acc->getState();
} }

View File

@ -25,7 +25,7 @@
#include <deque> #include <deque>
#include "../../global.h" #include "shared/enums.h"
namespace Models { namespace Models {

View File

@ -17,6 +17,7 @@
*/ */
#include "presence.h" #include "presence.h"
#include "shared/icons.h"
Models::Presence::Presence(const QMap<QString, QVariant>& data, Item* parentItem): Models::Presence::Presence(const QMap<QString, QVariant>& data, Item* parentItem):
AbstractParticipant(Item::presence, data, parentItem), AbstractParticipant(Item::presence, data, parentItem),

View File

@ -20,7 +20,9 @@
#define MODELS_PRESENCE_H #define MODELS_PRESENCE_H
#include "abstractparticipant.h" #include "abstractparticipant.h"
#include "../../global.h" #include "shared/enums.h"
#include "shared/message.h"
#include <QDateTime> #include <QDateTime>
#include <QIcon> #include <QIcon>

View File

@ -17,6 +17,8 @@
*/ */
#include "room.h" #include "room.h"
#include "shared/icons.h"
#include <QIcon> #include <QIcon>
#include <QDebug> #include <QDebug>
@ -194,15 +196,15 @@ QIcon Models::Room::getStatusIcon(bool big) const
} else { } else {
if (autoJoin) { if (autoJoin) {
if (joined) { if (joined) {
return Shared::connectionStateIcon(Shared::connected, big); return Shared::connectionStateIcon(Shared::ConnectionState::connected, big);
} else { } else {
return Shared::connectionStateIcon(Shared::disconnected, big); return Shared::connectionStateIcon(Shared::ConnectionState::disconnected, big);
} }
} else { } else {
if (joined) { if (joined) {
return Shared::connectionStateIcon(Shared::connecting, big); return Shared::connectionStateIcon(Shared::ConnectionState::connecting, big);
} else { } else {
return Shared::connectionStateIcon(Shared::error, big); return Shared::connectionStateIcon(Shared::ConnectionState::error, big);
} }
} }
} }

View File

@ -21,7 +21,8 @@
#include "item.h" #include "item.h"
#include "participant.h" #include "participant.h"
#include "global.h" #include "shared/enums.h"
#include "shared/message.h"
namespace Models { namespace Models {

View File

@ -181,7 +181,7 @@ QVariant Models::Roster::data (const QModelIndex& index, int role) const
switch (item->type) { switch (item->type) {
case Item::account: { case Item::account: {
Account* acc = static_cast<Account*>(item); Account* acc = static_cast<Account*>(item);
result = QCoreApplication::translate("Global", Shared::availabilityNames[acc->getAvailability()].toLatin1()); result = Shared::Global::getName(acc->getAvailability());
} }
break; break;
case Item::contact: { case Item::contact: {
@ -193,18 +193,18 @@ QVariant Models::Roster::data (const QModelIndex& index, int role) const
} }
str += tr("Jabber ID: ") + contact->getJid() + "\n"; str += tr("Jabber ID: ") + contact->getJid() + "\n";
Shared::SubscriptionState ss = contact->getState(); Shared::SubscriptionState ss = contact->getState();
if (ss == Shared::both || ss == Shared::to) { if (ss == Shared::SubscriptionState::both || ss == Shared::SubscriptionState::to) {
Shared::Availability av = contact->getAvailability(); Shared::Availability av = contact->getAvailability();
str += tr("Availability: ") + QCoreApplication::translate("Global", Shared::availabilityNames[av].toLatin1()); str += tr("Availability: ") + Shared::Global::getName(av);
if (av != Shared::offline) { if (av != Shared::Availability::offline) {
QString s = contact->getStatus(); QString s = contact->getStatus();
if (s.size() > 0) { if (s.size() > 0) {
str += "\n" + tr("Status: ") + s; str += "\n" + tr("Status: ") + s;
} }
} }
str += "\n" + tr("Subscription: ") + QCoreApplication::translate("Global", Shared::subscriptionStateNames[ss].toLatin1()); str += "\n" + tr("Subscription: ") + Shared::Global::getName(ss);
} else { } else {
str += tr("Subscription: ") + QCoreApplication::translate("Global", Shared::subscriptionStateNames[ss].toLatin1()); str += tr("Subscription: ") + Shared::Global::getName(ss);
} }
result = str; result = str;
@ -218,7 +218,7 @@ QVariant Models::Roster::data (const QModelIndex& index, int role) const
str += tr("New messages: ") + std::to_string(mc).c_str() + "\n"; str += tr("New messages: ") + std::to_string(mc).c_str() + "\n";
} }
Shared::Availability av = contact->getAvailability(); Shared::Availability av = contact->getAvailability();
str += tr("Availability: ") + QCoreApplication::translate("Global", Shared::availabilityNames[av].toLatin1()); str += tr("Availability: ") + Shared::Global::getName(av);
QString s = contact->getStatus(); QString s = contact->getStatus();
if (s.size() > 0) { if (s.size() > 0) {
str += "\n" + tr("Status: ") + s; str += "\n" + tr("Status: ") + s;
@ -231,18 +231,14 @@ QVariant Models::Roster::data (const QModelIndex& index, int role) const
Participant* p = static_cast<Participant*>(item); Participant* p = static_cast<Participant*>(item);
QString str(""); QString str("");
Shared::Availability av = p->getAvailability(); Shared::Availability av = p->getAvailability();
str += tr("Availability: ") + QCoreApplication::translate("Global", Shared::availabilityNames[av].toLatin1()) + "\n"; str += tr("Availability: ") + Shared::Global::getName(av) + "\n";
QString s = p->getStatus(); QString s = p->getStatus();
if (s.size() > 0) { if (s.size() > 0) {
str += tr("Status: ") + s + "\n"; str += tr("Status: ") + s + "\n";
} }
str += tr("Affiliation: ") + str += tr("Affiliation: ") + Shared::Global::getName(p->getAffiliation()) + "\n";
QCoreApplication::translate("Global", str += tr("Role: ") + Shared::Global::getName(p->getRole());
Shared::affiliationNames[static_cast<unsigned int>(p->getAffiliation())].toLatin1()) + "\n";
str += tr("Role: ") +
QCoreApplication::translate("Global",
Shared::roleNames[static_cast<unsigned int>(p->getRole())].toLatin1());
result = str; result = str;
} }

View File

@ -24,7 +24,8 @@
#include <map> #include <map>
#include <QVector> #include <QVector>
#include "global.h" #include "shared/message.h"
#include "shared/global.h"
#include "accounts.h" #include "accounts.h"
#include "item.h" #include "item.h"
#include "account.h" #include "account.h"

View File

@ -41,11 +41,11 @@ Squawk::Squawk(QWidget *parent) :
m_ui->roster->header()->setStretchLastSection(false); m_ui->roster->header()->setStretchLastSection(false);
m_ui->roster->header()->setSectionResizeMode(0, QHeaderView::Stretch); m_ui->roster->header()->setSectionResizeMode(0, QHeaderView::Stretch);
for (unsigned int i = Shared::availabilityLowest; i < Shared::availabilityHighest + 1; ++i) { for (int i = static_cast<int>(Shared::availabilityLowest); i < static_cast<int>(Shared::availabilityHighest) + 1; ++i) {
Shared::Availability av = static_cast<Shared::Availability>(i); Shared::Availability av = static_cast<Shared::Availability>(i);
m_ui->comboBox->addItem(Shared::availabilityIcon(av), QCoreApplication::translate("Global", Shared::availabilityNames[av].toLatin1())); m_ui->comboBox->addItem(Shared::availabilityIcon(av), Shared::Global::getName(av));
} }
m_ui->comboBox->setCurrentIndex(Shared::offline); m_ui->comboBox->setCurrentIndex(static_cast<int>(Shared::Availability::offline));
connect(m_ui->actionAccounts, &QAction::triggered, this, &Squawk::onAccounts); connect(m_ui->actionAccounts, &QAction::triggered, this, &Squawk::onAccounts);
connect(m_ui->actionAddContact, &QAction::triggered, this, &Squawk::onNewContact); connect(m_ui->actionAddContact, &QAction::triggered, this, &Squawk::onNewContact);
@ -173,25 +173,26 @@ void Squawk::newAccount(const QMap<QString, QVariant>& account)
void Squawk::onComboboxActivated(int index) void Squawk::onComboboxActivated(int index)
{ {
if (index != Shared::offline) { Shared::Availability av = Shared::Global::fromInt<Shared::Availability>(index);
if (av != Shared::Availability::offline) {
int size = rosterModel.accountsModel->rowCount(QModelIndex()); int size = rosterModel.accountsModel->rowCount(QModelIndex());
if (size > 0) { if (size > 0) {
emit changeState(index); emit changeState(av);
for (int i = 0; i < size; ++i) { for (int i = 0; i < size; ++i) {
Models::Account* acc = rosterModel.accountsModel->getAccount(i); Models::Account* acc = rosterModel.accountsModel->getAccount(i);
if (acc->getState() == Shared::disconnected) { if (acc->getState() == Shared::ConnectionState::disconnected) {
emit connectAccount(acc->getName()); emit connectAccount(acc->getName());
} }
} }
} else { } else {
m_ui->comboBox->setCurrentIndex(Shared::offline); m_ui->comboBox->setCurrentIndex(static_cast<int>(Shared::Availability::offline));
} }
} else { } else {
emit changeState(index); emit changeState(av);
int size = rosterModel.accountsModel->rowCount(QModelIndex()); int size = rosterModel.accountsModel->rowCount(QModelIndex());
for (int i = 0; i != size; ++i) { for (int i = 0; i != size; ++i) {
Models::Account* acc = rosterModel.accountsModel->getAccount(i); Models::Account* acc = rosterModel.accountsModel->getAccount(i);
if (acc->getState() != Shared::disconnected) { if (acc->getState() != Shared::ConnectionState::disconnected) {
emit disconnectAccount(acc->getName()); emit disconnectAccount(acc->getName());
} }
} }
@ -273,9 +274,9 @@ void Squawk::removePresence(const QString& account, const QString& jid, const QS
rosterModel.removePresence(account, jid, name); rosterModel.removePresence(account, jid, name);
} }
void Squawk::stateChanged(int state) void Squawk::stateChanged(Shared::Availability state)
{ {
m_ui->comboBox->setCurrentIndex(state); m_ui->comboBox->setCurrentIndex(static_cast<int>(state));
} }
void Squawk::onRosterItemDoubleClicked(const QModelIndex& item) void Squawk::onRosterItemDoubleClicked(const QModelIndex& item)
@ -600,14 +601,14 @@ void Squawk::onRosterContextMenu(const QPoint& point)
contextMenu->clear(); contextMenu->clear();
bool hasMenu = false; bool hasMenu = false;
bool active = item->getAccountConnectionState() == Shared::connected; bool active = item->getAccountConnectionState() == Shared::ConnectionState::connected;
switch (item->type) { switch (item->type) {
case Models::Item::account: { case Models::Item::account: {
Models::Account* acc = static_cast<Models::Account*>(item); Models::Account* acc = static_cast<Models::Account*>(item);
hasMenu = true; hasMenu = true;
QString name = acc->getName(); QString name = acc->getName();
if (acc->getState() != Shared::disconnected) { if (acc->getState() != Shared::ConnectionState::disconnected) {
QAction* con = contextMenu->addAction(Shared::icon("network-disconnect"), tr("Disconnect")); QAction* con = contextMenu->addAction(Shared::icon("network-disconnect"), tr("Disconnect"));
con->setEnabled(active); con->setEnabled(active);
connect(con, &QAction::triggered, [this, name]() { connect(con, &QAction::triggered, [this, name]() {
@ -644,8 +645,8 @@ void Squawk::onRosterContextMenu(const QPoint& point)
Shared::SubscriptionState state = cnt->getState(); Shared::SubscriptionState state = cnt->getState();
switch (state) { switch (state) {
case Shared::both: case Shared::SubscriptionState::both:
case Shared::to: { case Shared::SubscriptionState::to: {
QAction* unsub = contextMenu->addAction(Shared::icon("news-unsubscribe"), tr("Unsubscribe")); QAction* unsub = contextMenu->addAction(Shared::icon("news-unsubscribe"), tr("Unsubscribe"));
unsub->setEnabled(active); unsub->setEnabled(active);
connect(unsub, &QAction::triggered, [this, cnt]() { connect(unsub, &QAction::triggered, [this, cnt]() {
@ -653,9 +654,9 @@ void Squawk::onRosterContextMenu(const QPoint& point)
}); });
} }
break; break;
case Shared::from: case Shared::SubscriptionState::from:
case Shared::unknown: case Shared::SubscriptionState::unknown:
case Shared::none: { case Shared::SubscriptionState::none: {
QAction* sub = contextMenu->addAction(Shared::icon("news-subscribe"), tr("Subscribe")); QAction* sub = contextMenu->addAction(Shared::icon("news-subscribe"), tr("Subscribe"));
sub->setEnabled(active); sub->setEnabled(active);
connect(sub, &QAction::triggered, [this, cnt]() { connect(sub, &QAction::triggered, [this, cnt]() {
@ -882,7 +883,7 @@ void Squawk::readSettings()
if (settings.contains("availability")) { if (settings.contains("availability")) {
int avail = settings.value("availability").toInt(); int avail = settings.value("availability").toInt();
m_ui->comboBox->setCurrentIndex(avail); m_ui->comboBox->setCurrentIndex(avail);
emit stateChanged(avail); emit stateChanged(Shared::Global::fromInt<Shared::Availability>(avail));
int size = settings.beginReadArray("connectedAccounts"); int size = settings.beginReadArray("connectedAccounts");
for (int i = 0; i < size; ++i) { for (int i = 0; i < size; ++i) {
@ -909,7 +910,7 @@ void Squawk::writeSettings()
int size = rosterModel.accountsModel->rowCount(QModelIndex()); int size = rosterModel.accountsModel->rowCount(QModelIndex());
for (int i = 0; i < size; ++i) { for (int i = 0; i < size; ++i) {
Models::Account* acc = rosterModel.accountsModel->getAccount(i); Models::Account* acc = rosterModel.accountsModel->getAccount(i);
if (acc->getState() != Shared::disconnected) { if (acc->getState() != Shared::ConnectionState::disconnected) {
settings.setArrayIndex(i); settings.setArrayIndex(i);
settings.setValue("name", acc->getName()); settings.setValue("name", acc->getName());
} }

View File

@ -38,7 +38,7 @@
#include "models/roster.h" #include "models/roster.h"
#include "widgets/vcard/vcard.h" #include "widgets/vcard/vcard.h"
#include "global.h" #include "shared.h"
namespace Ui { namespace Ui {
class Squawk; class Squawk;
@ -61,7 +61,7 @@ signals:
void removeAccountRequest(const QString&); void removeAccountRequest(const QString&);
void connectAccount(const QString&); void connectAccount(const QString&);
void disconnectAccount(const QString&); void disconnectAccount(const QString&);
void changeState(int state); void changeState(Shared::Availability state);
void sendMessage(const QString& account, const Shared::Message& data); void sendMessage(const QString& account, const Shared::Message& data);
void sendMessage(const QString& account, const Shared::Message& data, const QString& path); void sendMessage(const QString& account, const Shared::Message& data, const QString& path);
void requestArchive(const QString& account, const QString& jid, int count, const QString& before); void requestArchive(const QString& account, const QString& jid, int count, const QString& before);
@ -93,7 +93,7 @@ public slots:
void changeContact(const QString& account, const QString& jid, const QMap<QString, QVariant>& data); void changeContact(const QString& account, const QString& jid, const QMap<QString, QVariant>& data);
void addPresence(const QString& account, const QString& jid, const QString& name, const QMap<QString, QVariant>& data); void addPresence(const QString& account, const QString& jid, const QString& name, const QMap<QString, QVariant>& data);
void removePresence(const QString& account, const QString& jid, const QString& name); void removePresence(const QString& account, const QString& jid, const QString& name);
void stateChanged(int state); void stateChanged(Shared::Availability state);
void accountMessage(const QString& account, const Shared::Message& data); void accountMessage(const QString& account, const Shared::Message& data);
void responseArchive(const QString& account, const QString& jid, const std::list<Shared::Message>& list); void responseArchive(const QString& account, const QString& jid, const std::list<Shared::Message>& list);
void addRoom(const QString& account, const QString jid, const QMap<QString, QVariant>& data); void addRoom(const QString& account, const QString jid, const QMap<QString, QVariant>& data);

View File

@ -16,12 +16,12 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>. * along with this program. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include "message.h"
#include <QDebug> #include <QDebug>
#include <QMimeDatabase> #include <QMimeDatabase>
#include <QPixmap> #include <QPixmap>
#include <QFileInfo> #include <QFileInfo>
#include <QRegularExpression> #include <QRegularExpression>
#include "message.h"
const QRegularExpression urlReg("(?<!<a\\shref=['\"])(?<!<img\\ssrc=['\"])(" const QRegularExpression urlReg("(?<!<a\\shref=['\"])(?<!<img\\ssrc=['\"])("
"(?:https?|ftp):\\/\\/" "(?:https?|ftp):\\/\\/"
@ -346,7 +346,7 @@ void Message::setState()
{ {
Shared::Message::State state = msg.getState(); Shared::Message::State state = msg.getState();
QIcon q(Shared::icon(Shared::messageStateThemeIcons[static_cast<uint8_t>(state)])); QIcon q(Shared::icon(Shared::messageStateThemeIcons[static_cast<uint8_t>(state)]));
QString tt = QCoreApplication::translate("Global", Shared::messageStateNames[static_cast<uint8_t>(state)].toLatin1()); QString tt = Shared::Global::getName(state);
if (state == Shared::Message::State::error) { if (state == Shared::Message::State::error) {
QString errText = msg.getErrorText(); QString errText = msg.getErrorText();
if (errText.size() > 0) { if (errText.size() > 0) {

View File

@ -31,7 +31,9 @@
#include <QUrl> #include <QUrl>
#include <QMap> #include <QMap>
#include "global.h" #include "shared/message.h"
#include "shared/icons.h"
#include "shared/global.h"
#include "resizer.h" #include "resizer.h"
#include "image.h" #include "image.h"

View File

@ -18,6 +18,7 @@
#include "messageline.h" #include "messageline.h"
#include <QDebug> #include <QDebug>
#include <QCoreApplication>
#include <cmath> #include <cmath>
MessageLine::MessageLine(bool p_room, QWidget* parent): MessageLine::MessageLine(bool p_room, QWidget* parent):

View File

@ -26,7 +26,7 @@
#include <QResizeEvent> #include <QResizeEvent>
#include <QIcon> #include <QIcon>
#include "global.h" #include "shared/message.h"
#include "message.h" #include "message.h"
#include "progress.h" #include "progress.h"

View File

@ -18,6 +18,8 @@
#include "progress.h" #include "progress.h"
#include "shared/icons.h"
Progress::Progress(quint16 p_size, QWidget* parent): Progress::Progress(quint16 p_size, QWidget* parent):
QWidget(parent), QWidget(parent),
pixmap(new QGraphicsPixmapItem(Shared::icon("view-refresh", true).pixmap(p_size))), pixmap(new QGraphicsPixmapItem(Shared::icon("view-refresh", true).pixmap(p_size))),

View File

@ -27,8 +27,6 @@
#include <QVariantAnimation> #include <QVariantAnimation>
#include <QGridLayout> #include <QGridLayout>
#include "../../global.h"
/** /**
* @todo write docs * @todo write docs
*/ */

View File

@ -115,7 +115,7 @@ void Accounts::updateConnectButton()
bool allConnected = true; bool allConnected = true;
for (int i = 0; i < selectionSize && allConnected; ++i) { for (int i = 0; i < selectionSize && allConnected; ++i) {
const Models::Account* mAcc = model->getAccount(sm->selectedRows().at(i).row()); const Models::Account* mAcc = model->getAccount(sm->selectedRows().at(i).row());
allConnected = mAcc->getState() == Shared::connected; allConnected = mAcc->getState() == Shared::ConnectionState::connected;
} }
if (allConnected) { if (allConnected) {
toDisconnect = true; toDisconnect = true;

View File

@ -58,7 +58,7 @@ void Chat::updateState()
{ {
Shared::Availability av = contact->getAvailability(); Shared::Availability av = contact->getAvailability();
statusIcon->setPixmap(Shared::availabilityIcon(av, true).pixmap(40)); statusIcon->setPixmap(Shared::availabilityIcon(av, true).pixmap(40));
statusIcon->setToolTip(QCoreApplication::translate("Global", Shared::availabilityNames[av].toLatin1())); statusIcon->setToolTip(Shared::Global::getName(av));
} }
void Chat::handleSendMessage(const QString& text) void Chat::handleSendMessage(const QString& text)

View File

@ -20,7 +20,9 @@
#define CHAT_H #define CHAT_H
#include "conversation.h" #include "conversation.h"
#include "../models/contact.h" #include "ui/models/contact.h"
#include "shared/icons.h"
#include "shared/global.h"
namespace Ui namespace Ui
{ {

View File

@ -19,6 +19,7 @@
#include "conversation.h" #include "conversation.h"
#include "ui_conversation.h" #include "ui_conversation.h"
#include "ui/utils/dropshadoweffect.h" #include "ui/utils/dropshadoweffect.h"
#include "shared/icons.h"
#include <QDebug> #include <QDebug>
#include <QScrollBar> #include <QScrollBar>
@ -27,6 +28,7 @@
#include <QMimeDatabase> #include <QMimeDatabase>
#include <unistd.h> #include <unistd.h>
#include <QAbstractTextDocumentLayout> #include <QAbstractTextDocumentLayout>
#include <QCoreApplication>
Conversation::Conversation(bool muc, Models::Account* acc, const QString pJid, const QString pRes, QWidget* parent): Conversation::Conversation(bool muc, Models::Account* acc, const QString pJid, const QString pRes, QWidget* parent):
QWidget(parent), QWidget(parent),

View File

@ -23,7 +23,7 @@
#include <QScopedPointer> #include <QScopedPointer>
#include <QMap> #include <QMap>
#include "global.h" #include "shared/message.h"
#include "order.h" #include "order.h"
#include "ui/models/account.h" #include "ui/models/account.h"
#include "ui/utils/messageline.h" #include "ui/utils/messageline.h"

View File

@ -18,6 +18,9 @@
#include "emailsmodel.h" #include "emailsmodel.h"
#include "shared/icons.h"
#include <QCoreApplication>
UI::VCard::EMailsModel::EMailsModel(bool p_edit, QObject* parent): UI::VCard::EMailsModel::EMailsModel(bool p_edit, QObject* parent):
QAbstractTableModel(parent), QAbstractTableModel(parent),
edit(p_edit), edit(p_edit),

View File

@ -24,7 +24,7 @@
#include <deque> #include <deque>
#include "global.h" #include "shared/vcard.h"
namespace UI { namespace UI {
namespace VCard { namespace VCard {

View File

@ -18,6 +18,9 @@
#include "phonesmodel.h" #include "phonesmodel.h"
#include "shared/icons.h"
#include <QCoreApplication>
UI::VCard::PhonesModel::PhonesModel(bool p_edit, QObject* parent): UI::VCard::PhonesModel::PhonesModel(bool p_edit, QObject* parent):
QAbstractTableModel(parent), QAbstractTableModel(parent),
edit(p_edit), edit(p_edit),

View File

@ -22,7 +22,7 @@
#include <QAbstractTableModel> #include <QAbstractTableModel>
#include <QIcon> #include <QIcon>
#include "global.h" #include "shared/vcard.h"
namespace UI { namespace UI {
namespace VCard { namespace VCard {

View File

@ -18,7 +18,7 @@
#include "vcard.h" #include "vcard.h"
#include "ui_vcard.h" #include "ui_vcard.h"
#include "shared/icons.h"
#include <QDebug> #include <QDebug>
#include <algorithm> #include <algorithm>

View File

@ -36,7 +36,7 @@
#include <set> #include <set>
#include "global.h" #include "shared/vcard.h"
#include "emailsmodel.h" #include "emailsmodel.h"
#include "phonesmodel.h" #include "phonesmodel.h"
#include "ui/utils/progress.h" #include "ui/utils/progress.h"