forked from blue/squawk
Shared namespace refactoring, enum class refactoring, going offline related crash fix
This commit is contained in:
parent
b309100f99
commit
ddfb3419cc
@ -25,9 +25,25 @@ message("Build type: ${CMAKE_BUILD_TYPE}")
|
||||
|
||||
set(squawk_SRC
|
||||
main.cpp
|
||||
global.cpp
|
||||
exception.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)
|
||||
@ -46,7 +62,7 @@ add_custom_target(translations ALL DEPENDS ${QM_FILES})
|
||||
|
||||
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)
|
||||
|
||||
option(SYSTEM_QXMPP "Use system qxmpp lib" ON)
|
||||
|
@ -30,7 +30,7 @@ Account::Account(const QString& p_login, const QString& p_server, const QString&
|
||||
client(),
|
||||
config(),
|
||||
presence(),
|
||||
state(Shared::disconnected),
|
||||
state(Shared::ConnectionState::disconnected),
|
||||
groups(),
|
||||
cm(new QXmppCarbonManager()),
|
||||
am(new QXmppMamManager()),
|
||||
@ -182,9 +182,9 @@ Shared::ConnectionState Core::Account::getState() const
|
||||
|
||||
void Core::Account::connect()
|
||||
{
|
||||
if (state == Shared::disconnected) {
|
||||
if (state == Shared::ConnectionState::disconnected) {
|
||||
reconnectTimes = maxReconnectTimes;
|
||||
state = Shared::connecting;
|
||||
state = Shared::ConnectionState::connecting;
|
||||
client.connectToServer(config, presence);
|
||||
emit connectionStateChanged(state);
|
||||
} else {
|
||||
@ -195,19 +195,19 @@ void Core::Account::connect()
|
||||
void Core::Account::disconnect()
|
||||
{
|
||||
reconnectTimes = 0;
|
||||
if (state != Shared::disconnected) {
|
||||
if (state != Shared::ConnectionState::disconnected) {
|
||||
clearConferences();
|
||||
client.disconnectFromServer();
|
||||
state = Shared::disconnected;
|
||||
state = Shared::ConnectionState::disconnected;
|
||||
emit connectionStateChanged(state);
|
||||
}
|
||||
}
|
||||
|
||||
void Core::Account::onClientConnected()
|
||||
{
|
||||
if (state == Shared::connecting) {
|
||||
if (state == Shared::ConnectionState::connecting) {
|
||||
reconnectTimes = maxReconnectTimes;
|
||||
state = Shared::connected;
|
||||
state = Shared::ConnectionState::connected;
|
||||
dm->requestItems(getServer());
|
||||
dm->requestInfo(getServer());
|
||||
emit connectionStateChanged(state);
|
||||
@ -219,16 +219,16 @@ void Core::Account::onClientConnected()
|
||||
void Core::Account::onClientDisconnected()
|
||||
{
|
||||
clearConferences();
|
||||
if (state != Shared::disconnected) {
|
||||
if (state != Shared::ConnectionState::disconnected) {
|
||||
if (reconnectTimes > 0) {
|
||||
qDebug() << "Account" << name << "is reconnecting for" << reconnectTimes << "more times";
|
||||
--reconnectTimes;
|
||||
state = Shared::connecting;
|
||||
state = Shared::ConnectionState::connecting;
|
||||
client.connectToServer(config, presence);
|
||||
emit connectionStateChanged(state);
|
||||
} else {
|
||||
qDebug() << "Account" << name << "has been disconnected";
|
||||
state = Shared::disconnected;
|
||||
state = Shared::ConnectionState::disconnected;
|
||||
emit connectionStateChanged(state);
|
||||
}
|
||||
} else {
|
||||
@ -238,7 +238,7 @@ void Core::Account::onClientDisconnected()
|
||||
|
||||
void Core::Account::reconnect()
|
||||
{
|
||||
if (state == Shared::connected) {
|
||||
if (state == Shared::ConnectionState::connected) {
|
||||
++reconnectTimes;
|
||||
client.disconnectFromServer();
|
||||
} else {
|
||||
@ -281,7 +281,7 @@ void Core::Account::onRosterReceived()
|
||||
void Core::Account::setReconnectTimes(unsigned int times)
|
||||
{
|
||||
maxReconnectTimes = times;
|
||||
if (state == Shared::connected) {
|
||||
if (state == Shared::ConnectionState::connected) {
|
||||
reconnectTimes = times;
|
||||
}
|
||||
}
|
||||
@ -355,7 +355,7 @@ void Core::Account::addedAccount(const QString& jid)
|
||||
if (newContact) {
|
||||
QMap<QString, QVariant> cData({
|
||||
{"name", re.name()},
|
||||
{"state", state}
|
||||
{"state", QVariant::fromValue(state)}
|
||||
});
|
||||
|
||||
Archive::AvatarInfo info;
|
||||
@ -427,7 +427,7 @@ void Core::Account::onPresenceReceived(const QXmppPresence& p_presence)
|
||||
|
||||
if (jid == myJid) {
|
||||
if (resource == getResource()) {
|
||||
emit availabilityChanged(p_presence.availableStatusType());
|
||||
emit availabilityChanged(static_cast<Shared::Availability>(p_presence.availableStatusType()));
|
||||
} else {
|
||||
if (!ownVCardRequestInProgress) {
|
||||
switch (p_presence.vCardUpdateType()) {
|
||||
@ -521,22 +521,26 @@ void Core::Account::setServer(const QString& p_server)
|
||||
|
||||
Shared::Availability Core::Account::getAvailability() const
|
||||
{
|
||||
if (state == Shared::connected) {
|
||||
if (state == Shared::ConnectionState::connected) {
|
||||
QXmppPresence::AvailableStatusType pres = presence.availableStatusType();
|
||||
return static_cast<Shared::Availability>(pres); //they are compatible;
|
||||
} else {
|
||||
return Shared::offline;
|
||||
return Shared::Availability::offline;
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
QString Core::Account::getResource() const
|
||||
@ -624,7 +628,7 @@ void Core::Account::sendMessage(Shared::Message data)
|
||||
QString jid = data.getPenPalJid();
|
||||
QString id = data.getId();
|
||||
RosterItem* ri = getRosterItem(jid);
|
||||
if (state == Shared::connected) {
|
||||
if (state == Shared::ConnectionState::connected) {
|
||||
QXmppMessage msg(getFullJid(), data.getTo(), data.getBody(), data.getThread());
|
||||
msg.setId(id);
|
||||
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)
|
||||
{
|
||||
if (state == Shared::connected) {
|
||||
if (state == Shared::ConnectionState::connected) {
|
||||
QString url = network->getFileRemoteUrl(path);
|
||||
if (url.size() != 0) {
|
||||
sendMessageWithLocalUploadedFile(data, url);
|
||||
@ -727,9 +731,9 @@ bool Core::Account::handleChatMessage(const QXmppMessage& msg, bool outgoing, bo
|
||||
cnt = new Contact(jid, name);
|
||||
contacts.insert(std::make_pair(jid, cnt));
|
||||
outOfRosterContacts.insert(jid);
|
||||
cnt->setSubscriptionState(Shared::unknown);
|
||||
cnt->setSubscriptionState(Shared::SubscriptionState::unknown);
|
||||
emit addContact(jid, "", QMap<QString, QVariant>({
|
||||
{"state", Shared::unknown}
|
||||
{"state", QVariant::fromValue(Shared::SubscriptionState::unknown)}
|
||||
}));
|
||||
handleNewContact(cnt);
|
||||
}
|
||||
@ -963,7 +967,7 @@ void Core::Account::onContactGroupAdded(const QString& group)
|
||||
|
||||
QMap<QString, QVariant> cData({
|
||||
{"name", contact->getName()},
|
||||
{"state", contact->getSubscriptionState()}
|
||||
{"state", QVariant::fromValue(contact->getSubscriptionState())}
|
||||
});
|
||||
addToGroup(contact->jid, group);
|
||||
emit addContact(contact->jid, group, cData);
|
||||
@ -993,7 +997,7 @@ void Core::Account::onContactSubscriptionStateChanged(Shared::SubscriptionState
|
||||
{
|
||||
Contact* contact = static_cast<Contact*>(sender());
|
||||
QMap<QString, QVariant> cData({
|
||||
{"state", cstate},
|
||||
{"state", QVariant::fromValue(cstate)},
|
||||
});
|
||||
emit changeContact(contact->jid, cData);
|
||||
}
|
||||
@ -1031,7 +1035,7 @@ Shared::SubscriptionState Core::Account::castSubscriptionState(QXmppRosterIq::It
|
||||
{
|
||||
Shared::SubscriptionState state;
|
||||
if (qs == QXmppRosterIq::Item::NotSet) {
|
||||
state = Shared::unknown;
|
||||
state = Shared::SubscriptionState::unknown;
|
||||
} else {
|
||||
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)
|
||||
{
|
||||
if (state == Shared::connected) {
|
||||
if (state == Shared::ConnectionState::connected) {
|
||||
rm->subscribe(jid, reason);
|
||||
} else {
|
||||
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)
|
||||
{
|
||||
if (state == Shared::connected) {
|
||||
if (state == Shared::ConnectionState::connected) {
|
||||
rm->unsubscribe(jid, reason);
|
||||
} else {
|
||||
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)
|
||||
{
|
||||
if (state == Shared::connected) {
|
||||
if (state == Shared::ConnectionState::connected) {
|
||||
std::set<QString>::const_iterator itr = outOfRosterContacts.find(jid);
|
||||
if (itr != outOfRosterContacts.end()) {
|
||||
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)
|
||||
{
|
||||
if (state == Shared::connected) {
|
||||
if (state == Shared::ConnectionState::connected) {
|
||||
std::map<QString, QString>::const_iterator itr = queuedContacts.find(jid);
|
||||
if (itr != queuedContacts.end()) {
|
||||
qDebug() << "An attempt to add contact " << jid << " to account " << name << " but the account is already queued for adding, skipping";
|
||||
|
@ -43,7 +43,7 @@
|
||||
#include <QXmppVCardManager.h>
|
||||
#include <QXmppMessageReceiptManager.h>
|
||||
|
||||
#include "global.h"
|
||||
#include "shared.h"
|
||||
#include "contact.h"
|
||||
#include "conference.h"
|
||||
#include "networkaccess.h"
|
||||
@ -101,8 +101,8 @@ public slots:
|
||||
|
||||
signals:
|
||||
void changed(const QMap<QString, QVariant>& data);
|
||||
void connectionStateChanged(int);
|
||||
void availabilityChanged(int);
|
||||
void connectionStateChanged(Shared::ConnectionState);
|
||||
void availabilityChanged(Shared::Availability);
|
||||
void addGroup(const QString& name);
|
||||
void removeGroup(const QString& name);
|
||||
void addRoom(const QString& jid, const QMap<QString, QVariant>& data);
|
||||
|
@ -24,7 +24,7 @@
|
||||
#include <QMimeDatabase>
|
||||
#include <QMimeType>
|
||||
|
||||
#include "global.h"
|
||||
#include "shared/message.h"
|
||||
#include "exception.h"
|
||||
#include <lmdb.h>
|
||||
#include <list>
|
||||
|
@ -22,7 +22,7 @@
|
||||
Core::Contact::Contact(const QString& pJid, const QString& account, QObject* parent):
|
||||
RosterItem(pJid, account, parent),
|
||||
groups(),
|
||||
subscriptionState(Shared::unknown)
|
||||
subscriptionState(Shared::SubscriptionState::unknown)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -31,7 +31,9 @@
|
||||
#include <QXmppVCardIq.h>
|
||||
#include <QXmppPresence.h>
|
||||
|
||||
#include "../global.h"
|
||||
#include "shared/enums.h"
|
||||
#include "shared/message.h"
|
||||
#include "shared/vcard.h"
|
||||
#include "archive.h"
|
||||
|
||||
namespace Core {
|
||||
|
@ -146,8 +146,8 @@ void Core::Squawk::addAccount(const QString& login, const QString& server, const
|
||||
{"name", name},
|
||||
{"password", password},
|
||||
{"resource", resource},
|
||||
{"state", Shared::disconnected},
|
||||
{"offline", Shared::offline},
|
||||
{"state", QVariant::fromValue(Shared::ConnectionState::disconnected)},
|
||||
{"offline", QVariant::fromValue(Shared::Availability::offline)},
|
||||
{"error", ""},
|
||||
{"avatarPath", acc->getAvatarPath()}
|
||||
};
|
||||
@ -155,14 +155,11 @@ void Core::Squawk::addAccount(const QString& login, const QString& server, const
|
||||
emit newAccount(map);
|
||||
}
|
||||
|
||||
void Core::Squawk::changeState(int p_state)
|
||||
void Core::Squawk::changeState(Shared::Availability p_state)
|
||||
{
|
||||
Shared::Availability avail;
|
||||
if (p_state < Shared::availabilityLowest && p_state > Shared::availabilityHighest) {
|
||||
qDebug("An attempt to set invalid availability to Squawk core, skipping");
|
||||
if (state != p_state) {
|
||||
state = p_state;
|
||||
}
|
||||
avail = static_cast<Shared::Availability>(p_state);
|
||||
state = avail;
|
||||
|
||||
for (std::deque<Account*>::iterator itr = accounts.begin(), end = accounts.end(); itr != end; ++itr) {
|
||||
(*itr)->setAvailability(state);
|
||||
@ -190,20 +187,20 @@ void Core::Squawk::disconnectAccount(const QString& account)
|
||||
itr->second->disconnect();
|
||||
}
|
||||
|
||||
void Core::Squawk::onAccountConnectionStateChanged(int state)
|
||||
void Core::Squawk::onAccountConnectionStateChanged(Shared::ConnectionState p_state)
|
||||
{
|
||||
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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
if (equals) {
|
||||
state = Shared::offline;
|
||||
if (equals && state != Shared::Availability::offline) {
|
||||
state = Shared::Availability::offline;
|
||||
emit stateChanged(state);
|
||||
}
|
||||
}
|
||||
@ -257,10 +254,10 @@ void Core::Squawk::onAccountRemovePresence(const QString& jid, const QString& na
|
||||
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());
|
||||
emit changeAccount(acc->getName(), {{"availability", state}});
|
||||
emit changeAccount(acc->getName(), {{"availability", QVariant::fromValue(state)}});
|
||||
}
|
||||
|
||||
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;
|
||||
Shared::ConnectionState st = acc->getState();
|
||||
|
||||
if (st != Shared::disconnected) {
|
||||
if (st != Shared::ConnectionState::disconnected) {
|
||||
acc->reconnect();
|
||||
}
|
||||
|
||||
@ -367,7 +364,7 @@ void Core::Squawk::removeAccountRequest(const QString& name)
|
||||
}
|
||||
|
||||
Account* acc = itr->second;
|
||||
if (acc->getState() != Shared::disconnected) {
|
||||
if (acc->getState() != Shared::ConnectionState::disconnected) {
|
||||
acc->disconnect();
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,9 @@
|
||||
#include <deque>
|
||||
|
||||
#include "account.h"
|
||||
#include "../global.h"
|
||||
#include "shared/enums.h"
|
||||
#include "shared/message.h"
|
||||
#include "shared/global.h"
|
||||
#include "networkaccess.h"
|
||||
|
||||
namespace Core
|
||||
@ -54,7 +56,7 @@ signals:
|
||||
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 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 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);
|
||||
@ -79,7 +81,7 @@ public slots:
|
||||
void removeAccountRequest(const QString& name);
|
||||
void connectAccount(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, const QString& path);
|
||||
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);
|
||||
|
||||
private slots:
|
||||
void onAccountConnectionStateChanged(int state);
|
||||
void onAccountAvailabilityChanged(int state);
|
||||
void onAccountConnectionStateChanged(Shared::ConnectionState state);
|
||||
void onAccountAvailabilityChanged(Shared::Availability state);
|
||||
void onAccountChanged(const QMap<QString, QVariant>& data);
|
||||
void onAccountAddGroup(const QString& name);
|
||||
void onAccountError(const QString& text);
|
||||
|
765
global.cpp
765
global.cpp
@ -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
512
global.h
@ -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
|
5
main.cpp
5
main.cpp
@ -19,6 +19,7 @@
|
||||
#include "ui/squawk.h"
|
||||
#include "core/squawk.h"
|
||||
#include "signalcatcher.h"
|
||||
#include "shared/global.h"
|
||||
#include <QtWidgets/QApplication>
|
||||
#include <QtCore/QThread>
|
||||
#include <QtCore/QObject>
|
||||
@ -33,6 +34,8 @@ int main(int argc, char *argv[])
|
||||
qRegisterMetaType<Shared::VCard>("Shared::VCard");
|
||||
qRegisterMetaType<std::list<Shared::Message>>("std::list<Shared::Message>");
|
||||
qRegisterMetaType<QSet<QString>>("QSet<QString>");
|
||||
qRegisterMetaType<Shared::ConnectionState>("Shared::ConnectionState");
|
||||
qRegisterMetaType<Shared::Availability>("Shared::Availability");
|
||||
|
||||
QApplication app(argc, argv);
|
||||
SignalCatcher sc(&app);
|
||||
@ -72,6 +75,8 @@ int main(int argc, char *argv[])
|
||||
icon.addFile(":images/logo.svg", QSize(512, 512));
|
||||
QApplication::setWindowIcon(icon);
|
||||
|
||||
new Shared::Global(); //translates enums
|
||||
|
||||
Squawk w;
|
||||
w.show();
|
||||
|
||||
|
29
shared.h
Normal file
29
shared.h
Normal 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
114
shared/enums.h
Normal 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
170
shared/global.cpp
Normal 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
64
shared/global.h
Normal 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
96
shared/icons.cpp
Normal 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
176
shared/icons.h
Normal 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
399
shared/message.cpp
Normal 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
125
shared/message.h
Normal 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
29
shared/utils.cpp
Normal 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
72
shared/utils.h
Normal 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
288
shared/vcard.cpp
Normal 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
152
shared/vcard.h
Normal 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
|
@ -4,93 +4,63 @@
|
||||
<context>
|
||||
<name>Account</name>
|
||||
<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>
|
||||
<translatorcomment>Заголовок окна</translatorcomment>
|
||||
<translation>Учетная запись</translation>
|
||||
</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>
|
||||
<translation>Имя пользователя Вашей учетной записи</translation>
|
||||
</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>
|
||||
<translation>ivan_ivanov1987</translation>
|
||||
</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>
|
||||
<translation>Сервер</translation>
|
||||
</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>
|
||||
<translation>Адресс сервера вашей учетной записи (выглядит как 404.city или macaw.me)</translation>
|
||||
</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>
|
||||
<translation>macaw.me</translation>
|
||||
</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>
|
||||
<translation>Имя учетной записи</translation>
|
||||
</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>
|
||||
<translation>Пароль</translation>
|
||||
</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>
|
||||
<translation>Пароль вашей учетной записи</translation>
|
||||
</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>
|
||||
<translation>Имя</translation>
|
||||
</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't affect anything</source>
|
||||
<translation>Просто имя, то как Вы называете свою учетную запись, может быть любым</translation>
|
||||
</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>
|
||||
<translation>Иван</translation>
|
||||
</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>
|
||||
<translation>Ресурс</translation>
|
||||
</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 "Home" or "Work"</source>
|
||||
<translation>Имя этой программы для ваших контактов, может быть "Home" или "Phone"</translation>
|
||||
</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>
|
||||
<translatorcomment>Ресурс по умолчанию</translatorcomment>
|
||||
<translation>QXmpp</translation>
|
||||
@ -99,45 +69,30 @@
|
||||
<context>
|
||||
<name>Accounts</name>
|
||||
<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>
|
||||
<translation>Учетные записи</translation>
|
||||
</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>
|
||||
<translation>Удалить</translation>
|
||||
</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>
|
||||
<translation>Добавить</translation>
|
||||
</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>
|
||||
<translation>Редактировать</translation>
|
||||
</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>
|
||||
<translation>Изменить пароль</translation>
|
||||
</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>
|
||||
<translation>Подключить</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/widgets/accounts.cpp" line="122"/>
|
||||
<source>Disconnect</source>
|
||||
<translation>Отключить</translation>
|
||||
</message>
|
||||
@ -145,16 +100,21 @@
|
||||
<context>
|
||||
<name>Conversation</name>
|
||||
<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>
|
||||
<translation>Введите сообщение...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/widgets/conversation.cpp" line="284"/>
|
||||
<source>Chose a file to send</source>
|
||||
<translation>Выберите файл для отправки</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'Liberation Sans'; font-size:10pt; font-weight:400; font-style:normal;">
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html></source>
|
||||
<translation></translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Global</name>
|
||||
@ -260,43 +220,43 @@
|
||||
</message>
|
||||
<message>
|
||||
<source>Not specified</source>
|
||||
<translation>Не указан</translation>
|
||||
<translation type="vanished">Не указан</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Personal</source>
|
||||
<translation>Личный</translation>
|
||||
<translation type="vanished">Личный</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Business</source>
|
||||
<translation>Рабочий</translation>
|
||||
<translation type="vanished">Рабочий</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Fax</source>
|
||||
<translation>Факс</translation>
|
||||
<translation type="vanished">Факс</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Pager</source>
|
||||
<translation>Пэйджер</translation>
|
||||
<translation type="vanished">Пэйджер</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Voice</source>
|
||||
<translation>Стационарный</translation>
|
||||
<translation type="vanished">Стационарный</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Cell</source>
|
||||
<translation>Мобильный</translation>
|
||||
<translation type="vanished">Мобильный</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Video</source>
|
||||
<translation>Видеофон</translation>
|
||||
<translation type="vanished">Видеофон</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Modem</source>
|
||||
<translation>Модем</translation>
|
||||
<translation type="vanished">Модем</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Other</source>
|
||||
<translation>Другой</translation>
|
||||
<translation type="vanished">Другой</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Pending</source>
|
||||
@ -314,63 +274,43 @@
|
||||
<context>
|
||||
<name>JoinConference</name>
|
||||
<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>
|
||||
<translatorcomment>Заголовок окна</translatorcomment>
|
||||
<translation>Присоединиться к новой беседе</translation>
|
||||
</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>
|
||||
<translation>JID</translation>
|
||||
</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>
|
||||
<translation>Jabber-идентификатор беседы</translation>
|
||||
</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>
|
||||
<translation>identifier@conference.server.org</translation>
|
||||
</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>
|
||||
<translation>Учетная запись</translation>
|
||||
</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>
|
||||
<translation>Автовход</translation>
|
||||
</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>
|
||||
<translation>Если стоит галочка Squawk автоматически присоединится к этой беседе при подключении</translation>
|
||||
</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>
|
||||
<translation>Псевдоним</translation>
|
||||
</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>
|
||||
<translation>Ваш псевдоним в этой беседе, если оставите это поле пустым - будет использовано имя Вашей учетной записи</translation>
|
||||
</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>
|
||||
<translation>Ivan</translation>
|
||||
</message>
|
||||
@ -379,10 +319,9 @@
|
||||
<name>Message</name>
|
||||
<message>
|
||||
<source>Download</source>
|
||||
<translation>Скачать</translation>
|
||||
<translation type="vanished">Скачать</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/utils/message.cpp" line="172"/>
|
||||
<source>Open</source>
|
||||
<translation>Открыть</translation>
|
||||
</message>
|
||||
@ -390,23 +329,18 @@
|
||||
<context>
|
||||
<name>MessageLine</name>
|
||||
<message>
|
||||
<location filename="../ui/utils/messageline.cpp" line="146"/>
|
||||
<source>Downloading...</source>
|
||||
<translation>Скачивается...</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/utils/messageline.cpp" line="258"/>
|
||||
<location filename="../ui/utils/messageline.cpp" line="324"/>
|
||||
<source>Download</source>
|
||||
<translation>Скачать</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/utils/messageline.cpp" line="259"/>
|
||||
<source>Push the button to daownload the file</source>
|
||||
<translation>Нажмите на кнопку что бы загрузить файл</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/utils/messageline.cpp" line="319"/>
|
||||
<source>Error uploading file: %1
|
||||
You can try again</source>
|
||||
<translation>Ошибка загрузки файла на сервер:
|
||||
@ -414,12 +348,10 @@ You can try again</source>
|
||||
Для того, что бы попробовать снова нажмите на кнопку</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/utils/messageline.cpp" line="320"/>
|
||||
<source>Upload</source>
|
||||
<translation>Загрузить</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/utils/messageline.cpp" line="325"/>
|
||||
<source>Error downloading file: %1
|
||||
You can try again</source>
|
||||
<translation>Ошибка скачивания файла:
|
||||
@ -427,7 +359,6 @@ You can try again</source>
|
||||
Вы можете попробовать снова</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/utils/messageline.cpp" line="336"/>
|
||||
<source>Uploading...</source>
|
||||
<translation>Загружается...</translation>
|
||||
</message>
|
||||
@ -436,40 +367,36 @@ You can try again</source>
|
||||
<name>Models::Accounts</name>
|
||||
<message>
|
||||
<source>Name</source>
|
||||
<translation>Имя</translation>
|
||||
<translation type="vanished">Имя</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Server</source>
|
||||
<translation>Сервер</translation>
|
||||
<translation type="vanished">Сервер</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>State</source>
|
||||
<translation>Состояние</translation>
|
||||
<translation type="vanished">Состояние</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Error</source>
|
||||
<translation>Ошибка</translation>
|
||||
<translation type="vanished">Ошибка</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>Models::Room</name>
|
||||
<message>
|
||||
<location filename="../ui/models/room.cpp" line="196"/>
|
||||
<source>Subscribed</source>
|
||||
<translation>Вы состоите в беседе</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/models/room.cpp" line="198"/>
|
||||
<source>Temporarily unsubscribed</source>
|
||||
<translation>Вы временно не состоите в беседе</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/models/room.cpp" line="202"/>
|
||||
<source>Temporarily subscribed</source>
|
||||
<translation>Вы временно состоите в беседе</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/models/room.cpp" line="204"/>
|
||||
<source>Unsubscribed</source>
|
||||
<translation>Вы не состоите в беседе</translation>
|
||||
</message>
|
||||
@ -477,67 +404,47 @@ You can try again</source>
|
||||
<context>
|
||||
<name>Models::Roster</name>
|
||||
<message>
|
||||
<location filename="../ui/models/roster.cpp" line="80"/>
|
||||
<source>New messages</source>
|
||||
<translation>Есть непрочитанные сообщения</translation>
|
||||
</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>
|
||||
<translation>Новых сообщений: </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/models/roster.cpp" line="180"/>
|
||||
<source>Jabber ID: </source>
|
||||
<translation>Идентификатор: </translation>
|
||||
</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>
|
||||
<translation>Доступность: </translation>
|
||||
</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>
|
||||
<translation>Статус: </translation>
|
||||
</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>
|
||||
<translation>Подписка: </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/models/roster.cpp" line="226"/>
|
||||
<source>Affiliation: </source>
|
||||
<translatorcomment>Я правда не знаю, как это объяснить, не то что перевести</translatorcomment>
|
||||
<translation>Причастность: </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/models/roster.cpp" line="229"/>
|
||||
<source>Role: </source>
|
||||
<translation>Роль: </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/models/roster.cpp" line="243"/>
|
||||
<source>Online contacts: </source>
|
||||
<translation>Контакстов в сети: </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/models/roster.cpp" line="244"/>
|
||||
<source>Total contacts: </source>
|
||||
<translation>Всего контактов: </translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/models/roster.cpp" line="257"/>
|
||||
<source>Members: </source>
|
||||
<translation>Участников: </translation>
|
||||
</message>
|
||||
@ -545,58 +452,40 @@ You can try again</source>
|
||||
<context>
|
||||
<name>NewContact</name>
|
||||
<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>
|
||||
<translatorcomment>Заголовок окна</translatorcomment>
|
||||
<translation>Добавление нового контакта</translation>
|
||||
</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>
|
||||
<translation>Учетная запись</translation>
|
||||
</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>
|
||||
<translation>Учетная запись для которой будет добавлен контакт</translation>
|
||||
</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>
|
||||
<translation>JID</translation>
|
||||
</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>
|
||||
<translation>Jabber-идентификатор нового контакта</translation>
|
||||
</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>
|
||||
<translatorcomment>Placeholder поля ввода JID</translatorcomment>
|
||||
<translation>name@server.dmn</translation>
|
||||
</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>
|
||||
<translation>Имя</translation>
|
||||
</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>
|
||||
<translation>То, как будет подписан контакт в вашем списке контактов (не обязательно)</translation>
|
||||
</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>
|
||||
<translation>Иван Иванов</translation>
|
||||
</message>
|
||||
@ -604,99 +493,70 @@ You can try again</source>
|
||||
<context>
|
||||
<name>Squawk</name>
|
||||
<message>
|
||||
<location filename="../ui/squawk.ui" line="14"/>
|
||||
<location filename="../build/ui/squawkUI_autogen/include/ui_squawk.h" line="137"/>
|
||||
<source>squawk</source>
|
||||
<translation>Squawk</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/squawk.ui" line="78"/>
|
||||
<location filename="../build/ui/squawkUI_autogen/include/ui_squawk.h" line="143"/>
|
||||
<source>Settings</source>
|
||||
<translation>Настройки</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/squawk.ui" line="84"/>
|
||||
<location filename="../build/ui/squawkUI_autogen/include/ui_squawk.h" line="144"/>
|
||||
<source>Squawk</source>
|
||||
<translation>Squawk</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/squawk.ui" line="99"/>
|
||||
<location filename="../build/ui/squawkUI_autogen/include/ui_squawk.h" line="138"/>
|
||||
<source>Accounts</source>
|
||||
<translation>Учетные записи</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/squawk.ui" line="108"/>
|
||||
<location filename="../build/ui/squawkUI_autogen/include/ui_squawk.h" line="139"/>
|
||||
<source>Quit</source>
|
||||
<translation>Выйти</translation>
|
||||
</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>
|
||||
<translation>Добавить контакт</translation>
|
||||
</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>
|
||||
<translation>Присоединиться к беседе</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/squawk.cpp" line="60"/>
|
||||
<source>Contact list</source>
|
||||
<translation>Список контактов</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/squawk.cpp" line="558"/>
|
||||
<source>Disconnect</source>
|
||||
<translation>Отключить</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/squawk.cpp" line="564"/>
|
||||
<source>Connect</source>
|
||||
<translation>Подключить</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/squawk.cpp" line="570"/>
|
||||
<location filename="../ui/squawk.cpp" line="668"/>
|
||||
<source>VCard</source>
|
||||
<translation>Карточка</translation>
|
||||
</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>
|
||||
<translation>Удалить</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/squawk.cpp" line="586"/>
|
||||
<source>Open dialog</source>
|
||||
<translation>Открыть диалог</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/squawk.cpp" line="596"/>
|
||||
<location filename="../ui/squawk.cpp" line="693"/>
|
||||
<source>Unsubscribe</source>
|
||||
<translation>Отписаться</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/squawk.cpp" line="606"/>
|
||||
<location filename="../ui/squawk.cpp" line="702"/>
|
||||
<source>Subscribe</source>
|
||||
<translation>Подписаться</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/squawk.cpp" line="617"/>
|
||||
<source>Rename</source>
|
||||
<translation>Переименовать</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/squawk.cpp" line="630"/>
|
||||
<source>Input new name for %1
|
||||
or leave it empty for the contact
|
||||
to be displayed as %1</source>
|
||||
@ -706,269 +566,197 @@ to be displayed as %1</source>
|
||||
%1</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/squawk.cpp" line="631"/>
|
||||
<source>Renaming %1</source>
|
||||
<translation>Назначение имени контакту %1</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/squawk.cpp" line="637"/>
|
||||
<source>Groups</source>
|
||||
<translation>Группы</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/squawk.cpp" line="652"/>
|
||||
<source>New group</source>
|
||||
<translation>Создать новую группу</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/squawk.cpp" line="662"/>
|
||||
<source>New group name</source>
|
||||
<translation>Имя группы</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/squawk.cpp" line="663"/>
|
||||
<source>Add %1 to a new group</source>
|
||||
<translation>Добавление %1 в новую группу</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/squawk.cpp" line="684"/>
|
||||
<source>Open conversation</source>
|
||||
<translation>Открыть окно беседы</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/squawk.cpp" line="789"/>
|
||||
<source>%1 account card</source>
|
||||
<translation>Карточка учетной записи %1</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/squawk.cpp" line="791"/>
|
||||
<source>%1 contact card</source>
|
||||
<translation>Карточка контакта %1</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/squawk.cpp" line="803"/>
|
||||
<source>Downloading vCard</source>
|
||||
<translation>Получение карточки</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>Attached file</source>
|
||||
<translation>Прикрепленный файл</translation>
|
||||
</message>
|
||||
</context>
|
||||
<context>
|
||||
<name>VCard</name>
|
||||
<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>
|
||||
<translation>Не обновлялось</translation>
|
||||
</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>
|
||||
<translation>Общее</translation>
|
||||
</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>
|
||||
<translation>Место работы</translation>
|
||||
</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>
|
||||
<translation>Среднее имя</translation>
|
||||
</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>
|
||||
<translation>Имя</translation>
|
||||
</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>
|
||||
<translation>Фамилия</translation>
|
||||
</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>
|
||||
<translation>Псевдоним</translation>
|
||||
</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>
|
||||
<translation>Дата рождения</translation>
|
||||
</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>
|
||||
<translation>Название организации</translation>
|
||||
</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>
|
||||
<translation>Отдел</translation>
|
||||
</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>
|
||||
<translation>Профессия</translation>
|
||||
</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>
|
||||
<translation>Наименование должности</translation>
|
||||
</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>
|
||||
<translation>Полное имя</translation>
|
||||
</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>
|
||||
<translation>Личная информация</translation>
|
||||
</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>
|
||||
<translation>Адреса</translation>
|
||||
</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>
|
||||
<translation>Адреса электронной почты</translation>
|
||||
</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>
|
||||
<translation>Номера телефонов</translation>
|
||||
</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>
|
||||
<translation>Контактная информация</translation>
|
||||
</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>
|
||||
<translation>Jabber ID</translation>
|
||||
</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>
|
||||
<translation>Веб сайт</translation>
|
||||
</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>
|
||||
<translation>Описание</translation>
|
||||
</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>
|
||||
<translation>Установить иконку</translation>
|
||||
</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>
|
||||
<translation>Убрать иконку</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/widgets/vcard/vcard.cpp" line="93"/>
|
||||
<source>Account %1 card</source>
|
||||
<translation>Карточка учетной записи %1</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/widgets/vcard/vcard.cpp" line="108"/>
|
||||
<source>Contact %1 card</source>
|
||||
<translation>Карточка контакта %1</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/widgets/vcard/vcard.cpp" line="170"/>
|
||||
<source>Received %1 at %2</source>
|
||||
<translation>Получено %1 в %2</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/widgets/vcard/vcard.cpp" line="221"/>
|
||||
<source>Chose your new avatar</source>
|
||||
<translation>Выберите новую иконку</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/widgets/vcard/vcard.cpp" line="223"/>
|
||||
<source>Images (*.png *.jpg *.jpeg)</source>
|
||||
<translation>Изображения (*.png *.jpg *.jpeg)</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/widgets/vcard/vcard.cpp" line="310"/>
|
||||
<source>Add email address</source>
|
||||
<translation>Добавить адрес электронной почты</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/widgets/vcard/vcard.cpp" line="320"/>
|
||||
<source>Unset this email as preferred</source>
|
||||
<translation>Убрать отметку "предпочтительный" с этого адреса</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/widgets/vcard/vcard.cpp" line="323"/>
|
||||
<source>Set this email as preferred</source>
|
||||
<translation>Отметить этот адрес как "предпочтительный"</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/widgets/vcard/vcard.cpp" line="328"/>
|
||||
<source>Remove selected email addresses</source>
|
||||
<translation>Удалить выбранные адреса</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/widgets/vcard/vcard.cpp" line="333"/>
|
||||
<source>Copy selected emails to clipboard</source>
|
||||
<translation>Скопировать выбранные адреса в буфер обмена</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/widgets/vcard/vcard.cpp" line="338"/>
|
||||
<source>Add phone number</source>
|
||||
<translation>Добавить номер телефона</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/widgets/vcard/vcard.cpp" line="348"/>
|
||||
<source>Unset this phone as preferred</source>
|
||||
<translation>Убрать отметку "предпочтительный" с этого номера</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/widgets/vcard/vcard.cpp" line="351"/>
|
||||
<source>Set this phone as preferred</source>
|
||||
<translation>Отметить этот номер как "предпочтительный"</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/widgets/vcard/vcard.cpp" line="356"/>
|
||||
<source>Remove selected phone numbers</source>
|
||||
<translation>Удалить выбранные телефонные номера</translation>
|
||||
</message>
|
||||
<message>
|
||||
<location filename="../ui/widgets/vcard/vcard.cpp" line="361"/>
|
||||
<source>Copy selected phones to clipboard</source>
|
||||
<translation>Скопировать выбранные телефонные номера в буфер обмена</translation>
|
||||
</message>
|
||||
|
@ -22,7 +22,7 @@ using namespace Models;
|
||||
|
||||
Models::AbstractParticipant::AbstractParticipant(Models::Item::Type p_type, const QMap<QString, QVariant>& data, Models::Item* parentItem):
|
||||
Item(p_type, data, parentItem),
|
||||
availability(Shared::offline),
|
||||
availability(Shared::Availability::offline),
|
||||
lastActivity(data.value("lastActivity").toDateTime()),
|
||||
status(data.value("status").toString())
|
||||
{
|
||||
@ -58,7 +58,7 @@ QVariant Models::AbstractParticipant::data(int column) const
|
||||
case 1:
|
||||
return lastActivity;
|
||||
case 2:
|
||||
return availability;
|
||||
return QVariant::fromValue(availability);
|
||||
case 3:
|
||||
return status;
|
||||
default:
|
||||
@ -91,15 +91,9 @@ void Models::AbstractParticipant::setAvailability(Shared::Availability p_avail)
|
||||
|
||||
void Models::AbstractParticipant::setAvailability(unsigned int avail)
|
||||
{
|
||||
if (avail <= Shared::availabilityHighest) {
|
||||
Shared::Availability state = static_cast<Shared::Availability>(avail);
|
||||
setAvailability(state);
|
||||
} else {
|
||||
qDebug("An attempt to set wrong state to the contact");
|
||||
}
|
||||
setAvailability(Shared::Global::fromInt<Shared::Availability>(avail));
|
||||
}
|
||||
|
||||
|
||||
void Models::AbstractParticipant::setLastActivity(const QDateTime& p_time)
|
||||
{
|
||||
if (lastActivity != p_time) {
|
||||
|
@ -21,8 +21,12 @@
|
||||
|
||||
|
||||
#include "item.h"
|
||||
#include "../../global.h"
|
||||
#include "shared/enums.h"
|
||||
#include "shared/icons.h"
|
||||
#include "shared/global.h"
|
||||
|
||||
#include <QIcon>
|
||||
#include <QDateTime>
|
||||
|
||||
namespace Models {
|
||||
|
||||
|
@ -27,8 +27,8 @@ Models::Account::Account(const QMap<QString, QVariant>& data, Models::Item* pare
|
||||
resource(data.value("resource").toString()),
|
||||
error(data.value("error").toString()),
|
||||
avatarPath(data.value("avatarPath").toString()),
|
||||
state(Shared::disconnected),
|
||||
availability(Shared::offline)
|
||||
state(Shared::ConnectionState::disconnected),
|
||||
availability(Shared::Availability::offline)
|
||||
{
|
||||
QMap<QString, QVariant>::const_iterator sItr = data.find("state");
|
||||
if (sItr != data.end()) {
|
||||
@ -49,7 +49,7 @@ void Models::Account::setState(Shared::ConnectionState p_state)
|
||||
if (state != p_state) {
|
||||
state = p_state;
|
||||
changed(2);
|
||||
if (state == Shared::disconnected) {
|
||||
if (state == Shared::ConnectionState::disconnected) {
|
||||
toOfflineState();
|
||||
}
|
||||
}
|
||||
@ -57,22 +57,12 @@ void Models::Account::setState(Shared::ConnectionState p_state)
|
||||
|
||||
void Models::Account::setAvailability(unsigned int p_state)
|
||||
{
|
||||
if (p_state <= Shared::availabilityHighest) {
|
||||
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;
|
||||
}
|
||||
setAvailability(Shared::Global::fromInt<Shared::Availability>(p_state));
|
||||
}
|
||||
|
||||
void Models::Account::setState(unsigned int p_state)
|
||||
{
|
||||
if (p_state <= Shared::subscriptionStateHighest) {
|
||||
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;
|
||||
}
|
||||
setState(Shared::Global::fromInt<Shared::ConnectionState>(p_state));
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
if (state == Shared::connected) {
|
||||
if (state == Shared::ConnectionState::connected) {
|
||||
return Shared::availabilityIcon(availability, big);
|
||||
} else if (state == Shared::disconnected) {
|
||||
return Shared::availabilityIcon(Shared::offline, big);
|
||||
} else if (state == Shared::ConnectionState::disconnected) {
|
||||
return Shared::availabilityIcon(Shared::Availability::offline, big);
|
||||
} else {
|
||||
return Shared::connectionStateIcon(state);
|
||||
}
|
||||
@ -152,7 +142,7 @@ QVariant Models::Account::data(int column) const
|
||||
case 1:
|
||||
return server;
|
||||
case 2:
|
||||
return QCoreApplication::translate("Global", Shared::connectionStateNames[state].toLatin1());
|
||||
return Shared::Global::getName(state);
|
||||
case 3:
|
||||
return error;
|
||||
case 4:
|
||||
@ -160,7 +150,7 @@ QVariant Models::Account::data(int column) const
|
||||
case 5:
|
||||
return password;
|
||||
case 6:
|
||||
return QCoreApplication::translate("Global", Shared::availabilityNames[availability].toLatin1());
|
||||
return Shared::Global::getName(availability);
|
||||
case 7:
|
||||
return resource;
|
||||
case 8:
|
||||
@ -226,7 +216,7 @@ void Models::Account::setError(const QString& p_resource)
|
||||
|
||||
void Models::Account::toOfflineState()
|
||||
{
|
||||
setAvailability(Shared::offline);
|
||||
setAvailability(Shared::Availability::offline);
|
||||
Item::toOfflineState();
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,10 @@
|
||||
#ifndef 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 <QVariant>
|
||||
#include <QIcon>
|
||||
|
@ -17,7 +17,7 @@
|
||||
*/
|
||||
|
||||
#include "accounts.h"
|
||||
#include "../../global.h"
|
||||
#include "shared/icons.h"
|
||||
|
||||
#include <QIcon>
|
||||
#include <QDebug>
|
||||
|
@ -23,8 +23,8 @@
|
||||
Models::Contact::Contact(const QString& p_jid ,const QMap<QString, QVariant> &data, Item *parentItem):
|
||||
Item(Item::contact, data, parentItem),
|
||||
jid(p_jid),
|
||||
availability(Shared::offline),
|
||||
state(Shared::none),
|
||||
availability(Shared::Availability::offline),
|
||||
state(Shared::SubscriptionState::none),
|
||||
avatarState(Shared::Avatar::empty),
|
||||
presences(),
|
||||
messages(),
|
||||
@ -66,22 +66,12 @@ void Models::Contact::setJid(const QString p_jid)
|
||||
|
||||
void Models::Contact::setAvailability(unsigned int p_state)
|
||||
{
|
||||
if (p_state <= Shared::availabilityHighest) {
|
||||
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;
|
||||
}
|
||||
setAvailability(Shared::Global::fromInt<Shared::Availability>(p_state));
|
||||
}
|
||||
|
||||
void Models::Contact::setState(unsigned int p_state)
|
||||
{
|
||||
if (p_state <= Shared::subscriptionStateHighest) {
|
||||
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;
|
||||
}
|
||||
setState(Shared::Global::fromInt<Shared::SubscriptionState>(p_state));
|
||||
}
|
||||
|
||||
Shared::Availability Models::Contact::getAvailability() const
|
||||
@ -123,15 +113,15 @@ QVariant Models::Contact::data(int column) const
|
||||
case 1:
|
||||
return jid;
|
||||
case 2:
|
||||
return state;
|
||||
return QVariant::fromValue(state);
|
||||
case 3:
|
||||
return availability;
|
||||
return QVariant::fromValue(availability);
|
||||
case 4:
|
||||
return getMessagesCount();
|
||||
case 5:
|
||||
return getStatus();
|
||||
case 6:
|
||||
return static_cast<quint8>(getAvatarState());
|
||||
return QVariant::fromValue(getAvatarState());
|
||||
case 7:
|
||||
return getAvatarPath();
|
||||
default:
|
||||
@ -216,7 +206,7 @@ void Models::Contact::refresh()
|
||||
setAvailability(presence->getAvailability());
|
||||
setStatus(presence->getStatus());
|
||||
} else {
|
||||
setAvailability(Shared::offline);
|
||||
setAvailability(Shared::Availability::offline);
|
||||
setStatus("");
|
||||
}
|
||||
|
||||
@ -258,7 +248,7 @@ QIcon Models::Contact::getStatusIcon(bool big) const
|
||||
{
|
||||
if (getMessagesCount() > 0) {
|
||||
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);;
|
||||
} else {
|
||||
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
|
||||
Presence* pr = new Presence({});
|
||||
pr->setName(res);
|
||||
pr->setAvailability(Shared::invisible);
|
||||
pr->setAvailability(Shared::Availability::invisible);
|
||||
pr->setLastActivity(QDateTime::currentDateTimeUtc());
|
||||
presences.insert(res, pr);
|
||||
appendChild(pr);
|
||||
|
@ -21,7 +21,11 @@
|
||||
|
||||
#include "item.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 <QIcon>
|
||||
#include <deque>
|
||||
|
@ -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) {
|
||||
Models::Contact* cnt = static_cast<Models::Contact*>(*itr);
|
||||
if (cnt->getAvailability() != Shared::offline) {
|
||||
if (cnt->getAvailability() != Shared::Availability::offline) {
|
||||
++amount;
|
||||
}
|
||||
}
|
||||
|
@ -238,7 +238,7 @@ Shared::Availability Models::Item::getAccountAvailability() const
|
||||
{
|
||||
const Account* acc = static_cast<const Account*>(getParentAccount());
|
||||
if (acc == 0) {
|
||||
return Shared::offline;
|
||||
return Shared::Availability::offline;
|
||||
}
|
||||
return acc->getAvailability();
|
||||
}
|
||||
@ -247,7 +247,7 @@ Shared::ConnectionState Models::Item::getAccountConnectionState() const
|
||||
{
|
||||
const Account* acc = static_cast<const Account*>(getParentAccount());
|
||||
if (acc == 0) {
|
||||
return Shared::disconnected;
|
||||
return Shared::ConnectionState::disconnected;
|
||||
}
|
||||
return acc->getState();
|
||||
}
|
||||
|
@ -25,7 +25,7 @@
|
||||
|
||||
#include <deque>
|
||||
|
||||
#include "../../global.h"
|
||||
#include "shared/enums.h"
|
||||
|
||||
namespace Models {
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
*/
|
||||
|
||||
#include "presence.h"
|
||||
#include "shared/icons.h"
|
||||
|
||||
Models::Presence::Presence(const QMap<QString, QVariant>& data, Item* parentItem):
|
||||
AbstractParticipant(Item::presence, data, parentItem),
|
||||
|
@ -20,7 +20,9 @@
|
||||
#define MODELS_PRESENCE_H
|
||||
|
||||
#include "abstractparticipant.h"
|
||||
#include "../../global.h"
|
||||
#include "shared/enums.h"
|
||||
#include "shared/message.h"
|
||||
|
||||
#include <QDateTime>
|
||||
#include <QIcon>
|
||||
|
||||
|
@ -17,6 +17,8 @@
|
||||
*/
|
||||
|
||||
#include "room.h"
|
||||
#include "shared/icons.h"
|
||||
|
||||
#include <QIcon>
|
||||
#include <QDebug>
|
||||
|
||||
@ -194,15 +196,15 @@ QIcon Models::Room::getStatusIcon(bool big) const
|
||||
} else {
|
||||
if (autoJoin) {
|
||||
if (joined) {
|
||||
return Shared::connectionStateIcon(Shared::connected, big);
|
||||
return Shared::connectionStateIcon(Shared::ConnectionState::connected, big);
|
||||
} else {
|
||||
return Shared::connectionStateIcon(Shared::disconnected, big);
|
||||
return Shared::connectionStateIcon(Shared::ConnectionState::disconnected, big);
|
||||
}
|
||||
} else {
|
||||
if (joined) {
|
||||
return Shared::connectionStateIcon(Shared::connecting, big);
|
||||
return Shared::connectionStateIcon(Shared::ConnectionState::connecting, big);
|
||||
} else {
|
||||
return Shared::connectionStateIcon(Shared::error, big);
|
||||
return Shared::connectionStateIcon(Shared::ConnectionState::error, big);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -21,7 +21,8 @@
|
||||
|
||||
#include "item.h"
|
||||
#include "participant.h"
|
||||
#include "global.h"
|
||||
#include "shared/enums.h"
|
||||
#include "shared/message.h"
|
||||
|
||||
namespace Models {
|
||||
|
||||
|
@ -181,7 +181,7 @@ QVariant Models::Roster::data (const QModelIndex& index, int role) const
|
||||
switch (item->type) {
|
||||
case Item::account: {
|
||||
Account* acc = static_cast<Account*>(item);
|
||||
result = QCoreApplication::translate("Global", Shared::availabilityNames[acc->getAvailability()].toLatin1());
|
||||
result = Shared::Global::getName(acc->getAvailability());
|
||||
}
|
||||
break;
|
||||
case Item::contact: {
|
||||
@ -193,18 +193,18 @@ QVariant Models::Roster::data (const QModelIndex& index, int role) const
|
||||
}
|
||||
str += tr("Jabber ID: ") + contact->getJid() + "\n";
|
||||
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();
|
||||
str += tr("Availability: ") + QCoreApplication::translate("Global", Shared::availabilityNames[av].toLatin1());
|
||||
if (av != Shared::offline) {
|
||||
str += tr("Availability: ") + Shared::Global::getName(av);
|
||||
if (av != Shared::Availability::offline) {
|
||||
QString s = contact->getStatus();
|
||||
if (s.size() > 0) {
|
||||
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 {
|
||||
str += tr("Subscription: ") + QCoreApplication::translate("Global", Shared::subscriptionStateNames[ss].toLatin1());
|
||||
str += tr("Subscription: ") + Shared::Global::getName(ss);
|
||||
}
|
||||
|
||||
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";
|
||||
}
|
||||
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();
|
||||
if (s.size() > 0) {
|
||||
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);
|
||||
QString str("");
|
||||
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();
|
||||
if (s.size() > 0) {
|
||||
str += tr("Status: ") + s + "\n";
|
||||
}
|
||||
|
||||
str += tr("Affiliation: ") +
|
||||
QCoreApplication::translate("Global",
|
||||
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());
|
||||
str += tr("Affiliation: ") + Shared::Global::getName(p->getAffiliation()) + "\n";
|
||||
str += tr("Role: ") + Shared::Global::getName(p->getRole());
|
||||
|
||||
result = str;
|
||||
}
|
||||
|
@ -24,7 +24,8 @@
|
||||
#include <map>
|
||||
#include <QVector>
|
||||
|
||||
#include "global.h"
|
||||
#include "shared/message.h"
|
||||
#include "shared/global.h"
|
||||
#include "accounts.h"
|
||||
#include "item.h"
|
||||
#include "account.h"
|
||||
|
@ -41,11 +41,11 @@ Squawk::Squawk(QWidget *parent) :
|
||||
m_ui->roster->header()->setStretchLastSection(false);
|
||||
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);
|
||||
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->actionAddContact, &QAction::triggered, this, &Squawk::onNewContact);
|
||||
@ -173,25 +173,26 @@ void Squawk::newAccount(const QMap<QString, QVariant>& account)
|
||||
|
||||
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());
|
||||
if (size > 0) {
|
||||
emit changeState(index);
|
||||
emit changeState(av);
|
||||
for (int i = 0; i < size; ++i) {
|
||||
Models::Account* acc = rosterModel.accountsModel->getAccount(i);
|
||||
if (acc->getState() == Shared::disconnected) {
|
||||
if (acc->getState() == Shared::ConnectionState::disconnected) {
|
||||
emit connectAccount(acc->getName());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
m_ui->comboBox->setCurrentIndex(Shared::offline);
|
||||
m_ui->comboBox->setCurrentIndex(static_cast<int>(Shared::Availability::offline));
|
||||
}
|
||||
} else {
|
||||
emit changeState(index);
|
||||
emit changeState(av);
|
||||
int size = rosterModel.accountsModel->rowCount(QModelIndex());
|
||||
for (int i = 0; i != size; ++i) {
|
||||
Models::Account* acc = rosterModel.accountsModel->getAccount(i);
|
||||
if (acc->getState() != Shared::disconnected) {
|
||||
if (acc->getState() != Shared::ConnectionState::disconnected) {
|
||||
emit disconnectAccount(acc->getName());
|
||||
}
|
||||
}
|
||||
@ -273,9 +274,9 @@ void Squawk::removePresence(const QString& account, const QString& jid, const QS
|
||||
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)
|
||||
@ -600,14 +601,14 @@ void Squawk::onRosterContextMenu(const QPoint& point)
|
||||
|
||||
contextMenu->clear();
|
||||
bool hasMenu = false;
|
||||
bool active = item->getAccountConnectionState() == Shared::connected;
|
||||
bool active = item->getAccountConnectionState() == Shared::ConnectionState::connected;
|
||||
switch (item->type) {
|
||||
case Models::Item::account: {
|
||||
Models::Account* acc = static_cast<Models::Account*>(item);
|
||||
hasMenu = true;
|
||||
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"));
|
||||
con->setEnabled(active);
|
||||
connect(con, &QAction::triggered, [this, name]() {
|
||||
@ -644,8 +645,8 @@ void Squawk::onRosterContextMenu(const QPoint& point)
|
||||
|
||||
Shared::SubscriptionState state = cnt->getState();
|
||||
switch (state) {
|
||||
case Shared::both:
|
||||
case Shared::to: {
|
||||
case Shared::SubscriptionState::both:
|
||||
case Shared::SubscriptionState::to: {
|
||||
QAction* unsub = contextMenu->addAction(Shared::icon("news-unsubscribe"), tr("Unsubscribe"));
|
||||
unsub->setEnabled(active);
|
||||
connect(unsub, &QAction::triggered, [this, cnt]() {
|
||||
@ -653,9 +654,9 @@ void Squawk::onRosterContextMenu(const QPoint& point)
|
||||
});
|
||||
}
|
||||
break;
|
||||
case Shared::from:
|
||||
case Shared::unknown:
|
||||
case Shared::none: {
|
||||
case Shared::SubscriptionState::from:
|
||||
case Shared::SubscriptionState::unknown:
|
||||
case Shared::SubscriptionState::none: {
|
||||
QAction* sub = contextMenu->addAction(Shared::icon("news-subscribe"), tr("Subscribe"));
|
||||
sub->setEnabled(active);
|
||||
connect(sub, &QAction::triggered, [this, cnt]() {
|
||||
@ -882,7 +883,7 @@ void Squawk::readSettings()
|
||||
if (settings.contains("availability")) {
|
||||
int avail = settings.value("availability").toInt();
|
||||
m_ui->comboBox->setCurrentIndex(avail);
|
||||
emit stateChanged(avail);
|
||||
emit stateChanged(Shared::Global::fromInt<Shared::Availability>(avail));
|
||||
|
||||
int size = settings.beginReadArray("connectedAccounts");
|
||||
for (int i = 0; i < size; ++i) {
|
||||
@ -909,7 +910,7 @@ void Squawk::writeSettings()
|
||||
int size = rosterModel.accountsModel->rowCount(QModelIndex());
|
||||
for (int i = 0; i < size; ++i) {
|
||||
Models::Account* acc = rosterModel.accountsModel->getAccount(i);
|
||||
if (acc->getState() != Shared::disconnected) {
|
||||
if (acc->getState() != Shared::ConnectionState::disconnected) {
|
||||
settings.setArrayIndex(i);
|
||||
settings.setValue("name", acc->getName());
|
||||
}
|
||||
|
@ -38,7 +38,7 @@
|
||||
#include "models/roster.h"
|
||||
#include "widgets/vcard/vcard.h"
|
||||
|
||||
#include "global.h"
|
||||
#include "shared.h"
|
||||
|
||||
namespace Ui {
|
||||
class Squawk;
|
||||
@ -61,7 +61,7 @@ signals:
|
||||
void removeAccountRequest(const QString&);
|
||||
void connectAccount(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, const QString& path);
|
||||
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 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 stateChanged(int state);
|
||||
void stateChanged(Shared::Availability state);
|
||||
void accountMessage(const QString& account, const Shared::Message& data);
|
||||
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);
|
||||
|
@ -16,12 +16,12 @@
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "message.h"
|
||||
#include <QDebug>
|
||||
#include <QMimeDatabase>
|
||||
#include <QPixmap>
|
||||
#include <QFileInfo>
|
||||
#include <QRegularExpression>
|
||||
#include "message.h"
|
||||
|
||||
const QRegularExpression urlReg("(?<!<a\\shref=['\"])(?<!<img\\ssrc=['\"])("
|
||||
"(?:https?|ftp):\\/\\/"
|
||||
@ -346,7 +346,7 @@ void Message::setState()
|
||||
{
|
||||
Shared::Message::State state = msg.getState();
|
||||
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) {
|
||||
QString errText = msg.getErrorText();
|
||||
if (errText.size() > 0) {
|
||||
|
@ -31,7 +31,9 @@
|
||||
#include <QUrl>
|
||||
#include <QMap>
|
||||
|
||||
#include "global.h"
|
||||
#include "shared/message.h"
|
||||
#include "shared/icons.h"
|
||||
#include "shared/global.h"
|
||||
#include "resizer.h"
|
||||
#include "image.h"
|
||||
|
||||
|
@ -18,6 +18,7 @@
|
||||
|
||||
#include "messageline.h"
|
||||
#include <QDebug>
|
||||
#include <QCoreApplication>
|
||||
#include <cmath>
|
||||
|
||||
MessageLine::MessageLine(bool p_room, QWidget* parent):
|
||||
|
@ -26,7 +26,7 @@
|
||||
#include <QResizeEvent>
|
||||
#include <QIcon>
|
||||
|
||||
#include "global.h"
|
||||
#include "shared/message.h"
|
||||
#include "message.h"
|
||||
#include "progress.h"
|
||||
|
||||
|
@ -18,6 +18,8 @@
|
||||
|
||||
#include "progress.h"
|
||||
|
||||
#include "shared/icons.h"
|
||||
|
||||
Progress::Progress(quint16 p_size, QWidget* parent):
|
||||
QWidget(parent),
|
||||
pixmap(new QGraphicsPixmapItem(Shared::icon("view-refresh", true).pixmap(p_size))),
|
||||
|
@ -27,8 +27,6 @@
|
||||
#include <QVariantAnimation>
|
||||
#include <QGridLayout>
|
||||
|
||||
#include "../../global.h"
|
||||
|
||||
/**
|
||||
* @todo write docs
|
||||
*/
|
||||
|
@ -115,7 +115,7 @@ void Accounts::updateConnectButton()
|
||||
bool allConnected = true;
|
||||
for (int i = 0; i < selectionSize && allConnected; ++i) {
|
||||
const Models::Account* mAcc = model->getAccount(sm->selectedRows().at(i).row());
|
||||
allConnected = mAcc->getState() == Shared::connected;
|
||||
allConnected = mAcc->getState() == Shared::ConnectionState::connected;
|
||||
}
|
||||
if (allConnected) {
|
||||
toDisconnect = true;
|
||||
|
@ -58,7 +58,7 @@ void Chat::updateState()
|
||||
{
|
||||
Shared::Availability av = contact->getAvailability();
|
||||
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)
|
||||
|
@ -20,7 +20,9 @@
|
||||
#define CHAT_H
|
||||
|
||||
#include "conversation.h"
|
||||
#include "../models/contact.h"
|
||||
#include "ui/models/contact.h"
|
||||
#include "shared/icons.h"
|
||||
#include "shared/global.h"
|
||||
|
||||
namespace Ui
|
||||
{
|
||||
|
@ -19,6 +19,7 @@
|
||||
#include "conversation.h"
|
||||
#include "ui_conversation.h"
|
||||
#include "ui/utils/dropshadoweffect.h"
|
||||
#include "shared/icons.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QScrollBar>
|
||||
@ -27,6 +28,7 @@
|
||||
#include <QMimeDatabase>
|
||||
#include <unistd.h>
|
||||
#include <QAbstractTextDocumentLayout>
|
||||
#include <QCoreApplication>
|
||||
|
||||
Conversation::Conversation(bool muc, Models::Account* acc, const QString pJid, const QString pRes, QWidget* parent):
|
||||
QWidget(parent),
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include <QScopedPointer>
|
||||
#include <QMap>
|
||||
|
||||
#include "global.h"
|
||||
#include "shared/message.h"
|
||||
#include "order.h"
|
||||
#include "ui/models/account.h"
|
||||
#include "ui/utils/messageline.h"
|
||||
|
@ -18,6 +18,9 @@
|
||||
|
||||
#include "emailsmodel.h"
|
||||
|
||||
#include "shared/icons.h"
|
||||
#include <QCoreApplication>
|
||||
|
||||
UI::VCard::EMailsModel::EMailsModel(bool p_edit, QObject* parent):
|
||||
QAbstractTableModel(parent),
|
||||
edit(p_edit),
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include <deque>
|
||||
|
||||
#include "global.h"
|
||||
#include "shared/vcard.h"
|
||||
|
||||
namespace UI {
|
||||
namespace VCard {
|
||||
|
@ -18,6 +18,9 @@
|
||||
|
||||
#include "phonesmodel.h"
|
||||
|
||||
#include "shared/icons.h"
|
||||
#include <QCoreApplication>
|
||||
|
||||
UI::VCard::PhonesModel::PhonesModel(bool p_edit, QObject* parent):
|
||||
QAbstractTableModel(parent),
|
||||
edit(p_edit),
|
||||
|
@ -22,7 +22,7 @@
|
||||
#include <QAbstractTableModel>
|
||||
#include <QIcon>
|
||||
|
||||
#include "global.h"
|
||||
#include "shared/vcard.h"
|
||||
|
||||
namespace UI {
|
||||
namespace VCard {
|
||||
|
@ -18,7 +18,7 @@
|
||||
|
||||
#include "vcard.h"
|
||||
#include "ui_vcard.h"
|
||||
|
||||
#include "shared/icons.h"
|
||||
#include <QDebug>
|
||||
|
||||
#include <algorithm>
|
||||
|
@ -36,7 +36,7 @@
|
||||
|
||||
#include <set>
|
||||
|
||||
#include "global.h"
|
||||
#include "shared/vcard.h"
|
||||
#include "emailsmodel.h"
|
||||
#include "phonesmodel.h"
|
||||
#include "ui/utils/progress.h"
|
||||
|
Loading…
Reference in New Issue
Block a user