Client node now displays in all participants and presences, some additional checkups before querying empty clients, refactoring
This commit is contained in:
parent
76a9c5da0c
commit
21b40a9ccb
@ -360,9 +360,13 @@ void Core::Account::onPresenceReceived(const QXmppPresence& p_presence) {
|
|||||||
{"lastActivity", lastInteraction},
|
{"lastActivity", lastInteraction},
|
||||||
{"availability", p_presence.availableStatusType()}, //TODO check and handle invisible
|
{"availability", p_presence.availableStatusType()}, //TODO check and handle invisible
|
||||||
{"status", p_presence.statusText()},
|
{"status", p_presence.statusText()},
|
||||||
{"capabilityNode", p_presence.capabilityNode()},
|
{"client", QVariant::fromValue(
|
||||||
{"capabilityVer", p_presence.capabilityVer().toBase64()},
|
Shared::ClientId(
|
||||||
{"capabilityHash", p_presence.capabilityHash()}
|
p_presence.capabilityNode(),
|
||||||
|
p_presence.capabilityVer().toBase64(),
|
||||||
|
p_presence.capabilityHash())
|
||||||
|
)
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -51,6 +51,7 @@
|
|||||||
#include <shared/shared.h>
|
#include <shared/shared.h>
|
||||||
#include <shared/identity.h>
|
#include <shared/identity.h>
|
||||||
#include <shared/info.h>
|
#include <shared/info.h>
|
||||||
|
#include <shared/clientid.h>
|
||||||
#include "contact.h"
|
#include "contact.h"
|
||||||
#include "conference.h"
|
#include "conference.h"
|
||||||
#include <core/components/networkaccess.h>
|
#include <core/components/networkaccess.h>
|
||||||
|
@ -37,14 +37,10 @@ void Core::ClientCache::open() {
|
|||||||
void Core::ClientCache::close() {
|
void Core::ClientCache::close() {
|
||||||
db.close();}
|
db.close();}
|
||||||
|
|
||||||
|
bool Core::ClientCache::checkClient(const Shared::ClientId& p_id) {
|
||||||
bool Core::ClientCache::checkClient(const QString& node, const QString& ver, const QString& hash) {
|
QString id = p_id.getId();
|
||||||
QString id = node + "/" + ver;
|
|
||||||
if (requested.count(id) == 0 && !cache->checkRecord(id)) {
|
if (requested.count(id) == 0 && !cache->checkRecord(id)) {
|
||||||
Shared::ClientInfo& info = requested.insert(std::make_pair(id, Shared::ClientInfo())).first->second;
|
requested.emplace(id, p_id);
|
||||||
info.id.node = node;
|
|
||||||
info.id.verification = ver;
|
|
||||||
info.id.hash = hash;
|
|
||||||
emit requestClientInfo(id);
|
emit requestClientInfo(id);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
#include <cache.h>
|
#include <cache.h>
|
||||||
|
|
||||||
|
#include <shared/clientid.h>
|
||||||
#include <shared/clientinfo.h>
|
#include <shared/clientinfo.h>
|
||||||
#include <shared/identity.h>
|
#include <shared/identity.h>
|
||||||
|
|
||||||
@ -43,7 +44,7 @@ signals:
|
|||||||
void requestClientInfo(const QString& id);
|
void requestClientInfo(const QString& id);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
bool checkClient(const QString& node, const QString& ver, const QString& hash);
|
bool checkClient(const Shared::ClientId& id);
|
||||||
bool registerClientInfo(const QString& sourceFullJid, const QString& id, const std::set<Shared::Identity>& identities, const std::set<QString>& features);
|
bool registerClientInfo(const QString& sourceFullJid, const QString& id, const std::set<Shared::Identity>& identities, const std::set<QString>& features);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -157,7 +157,14 @@ void Core::Conference::onRoomParticipantAdded(const QString& p_name)
|
|||||||
{"availability", pres.availableStatusType()},
|
{"availability", pres.availableStatusType()},
|
||||||
{"status", pres.statusText()},
|
{"status", pres.statusText()},
|
||||||
{"affiliation", mi.affiliation()},
|
{"affiliation", mi.affiliation()},
|
||||||
{"role", mi.role()}
|
{"role", mi.role()},
|
||||||
|
{"client", QVariant::fromValue(
|
||||||
|
Shared::ClientId(
|
||||||
|
pres.capabilityNode(),
|
||||||
|
pres.capabilityVer().toBase64(),
|
||||||
|
pres.capabilityHash())
|
||||||
|
)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (hasAvatar) {
|
if (hasAvatar) {
|
||||||
@ -218,7 +225,14 @@ void Core::Conference::onRoomParticipantChanged(const QString& p_name)
|
|||||||
{"availability", pres.availableStatusType()},
|
{"availability", pres.availableStatusType()},
|
||||||
{"status", pres.statusText()},
|
{"status", pres.statusText()},
|
||||||
{"affiliation", mi.affiliation()},
|
{"affiliation", mi.affiliation()},
|
||||||
{"role", mi.role()}
|
{"role", mi.role()},
|
||||||
|
{"client", QVariant::fromValue(
|
||||||
|
Shared::ClientId(
|
||||||
|
pres.capabilityNode(),
|
||||||
|
pres.capabilityVer().toBase64(),
|
||||||
|
pres.capabilityHash())
|
||||||
|
)
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,8 @@
|
|||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#include "rosteritem.h"
|
#include "rosteritem.h"
|
||||||
#include "shared/global.h"
|
#include <shared/global.h>
|
||||||
|
#include <shared/clientid.h>
|
||||||
|
|
||||||
namespace Core
|
namespace Core
|
||||||
{
|
{
|
||||||
|
@ -347,8 +347,7 @@ Core::TrustHandler::Keys Core::TrustHandler::getKeys(const QString& protocol, co
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Shared::TrustLevel Core::TrustHandler::convert(Core::TrustHandler::TL level)
|
Shared::TrustLevel Core::TrustHandler::convert(Core::TrustHandler::TL level) {
|
||||||
{
|
|
||||||
switch (level) {
|
switch (level) {
|
||||||
case QXmpp::TrustLevel::Undecided: return Shared::TrustLevel::undecided;
|
case QXmpp::TrustLevel::Undecided: return Shared::TrustLevel::undecided;
|
||||||
case QXmpp::TrustLevel::AutomaticallyDistrusted: return Shared::TrustLevel::automaticallyDistrusted;
|
case QXmpp::TrustLevel::AutomaticallyDistrusted: return Shared::TrustLevel::automaticallyDistrusted;
|
||||||
@ -356,11 +355,11 @@ Shared::TrustLevel Core::TrustHandler::convert(Core::TrustHandler::TL level)
|
|||||||
case QXmpp::TrustLevel::AutomaticallyTrusted: return Shared::TrustLevel::automaticallyTrusted;
|
case QXmpp::TrustLevel::AutomaticallyTrusted: return Shared::TrustLevel::automaticallyTrusted;
|
||||||
case QXmpp::TrustLevel::ManuallyTrusted: return Shared::TrustLevel::manuallyTrusted;
|
case QXmpp::TrustLevel::ManuallyTrusted: return Shared::TrustLevel::manuallyTrusted;
|
||||||
case QXmpp::TrustLevel::Authenticated: return Shared::TrustLevel::authenticated;
|
case QXmpp::TrustLevel::Authenticated: return Shared::TrustLevel::authenticated;
|
||||||
|
default: throw 2413; //never supposed to get here, switch case if complete, this line is just to suppress a warning
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::TrustHandler::TL Core::TrustHandler::convert(Shared::TrustLevel level)
|
Core::TrustHandler::TL Core::TrustHandler::convert(Shared::TrustLevel level) {
|
||||||
{
|
|
||||||
switch (level) {
|
switch (level) {
|
||||||
case Shared::TrustLevel::undecided: return QXmpp::TrustLevel::Undecided;
|
case Shared::TrustLevel::undecided: return QXmpp::TrustLevel::Undecided;
|
||||||
case Shared::TrustLevel::automaticallyDistrusted: return QXmpp::TrustLevel::AutomaticallyDistrusted;
|
case Shared::TrustLevel::automaticallyDistrusted: return QXmpp::TrustLevel::AutomaticallyDistrusted;
|
||||||
@ -368,5 +367,6 @@ Core::TrustHandler::TL Core::TrustHandler::convert(Shared::TrustLevel level)
|
|||||||
case Shared::TrustLevel::automaticallyTrusted: return QXmpp::TrustLevel::AutomaticallyTrusted;
|
case Shared::TrustLevel::automaticallyTrusted: return QXmpp::TrustLevel::AutomaticallyTrusted;
|
||||||
case Shared::TrustLevel::manuallyTrusted: return QXmpp::TrustLevel::ManuallyTrusted;
|
case Shared::TrustLevel::manuallyTrusted: return QXmpp::TrustLevel::ManuallyTrusted;
|
||||||
case Shared::TrustLevel::authenticated: return QXmpp::TrustLevel::Authenticated;
|
case Shared::TrustLevel::authenticated: return QXmpp::TrustLevel::Authenticated;
|
||||||
|
default: throw 2413; //never supposed to get here, switch case if complete, this line is just to suppress a warning
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
230
core/squawk.cpp
230
core/squawk.cpp
@ -50,8 +50,7 @@ Core::Squawk::Squawk(QObject* parent):
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
Core::Squawk::~Squawk()
|
Core::Squawk::~Squawk() {
|
||||||
{
|
|
||||||
Accounts::const_iterator itr = accounts.begin();
|
Accounts::const_iterator itr = accounts.begin();
|
||||||
Accounts::const_iterator end = accounts.end();
|
Accounts::const_iterator end = accounts.end();
|
||||||
for (; itr != end; ++itr) {
|
for (; itr != end; ++itr) {
|
||||||
@ -59,13 +58,11 @@ Core::Squawk::~Squawk()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::onWalletOpened(bool success)
|
void Core::Squawk::onWalletOpened(bool success) {
|
||||||
{
|
|
||||||
qDebug() << "KWallet opened: " << success;
|
qDebug() << "KWallet opened: " << success;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::stop()
|
void Core::Squawk::stop() {
|
||||||
{
|
|
||||||
qDebug("Stopping squawk core..");
|
qDebug("Stopping squawk core..");
|
||||||
network.stop();
|
network.stop();
|
||||||
clientCache.close();
|
clientCache.close();
|
||||||
@ -110,8 +107,7 @@ void Core::Squawk::stop()
|
|||||||
emit quit();
|
emit quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::start()
|
void Core::Squawk::start() {
|
||||||
{
|
|
||||||
qDebug("Starting squawk core..");
|
qDebug("Starting squawk core..");
|
||||||
|
|
||||||
readSettings();
|
readSettings();
|
||||||
@ -120,8 +116,7 @@ void Core::Squawk::start()
|
|||||||
clientCache.open();
|
clientCache.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::newAccountRequest(const QMap<QString, QVariant>& map)
|
void Core::Squawk::newAccountRequest(const QMap<QString, QVariant>& map) {
|
||||||
{
|
|
||||||
QString name = map.value("name").toString();
|
QString name = map.value("name").toString();
|
||||||
QString login = map.value("login").toString();
|
QString login = map.value("login").toString();
|
||||||
QString server = map.value("server").toString();
|
QString server = map.value("server").toString();
|
||||||
@ -205,53 +200,47 @@ void Core::Squawk::addAccount(
|
|||||||
switch (passwordType) {
|
switch (passwordType) {
|
||||||
case Shared::AccountPassword::alwaysAsk:
|
case Shared::AccountPassword::alwaysAsk:
|
||||||
case Shared::AccountPassword::kwallet:
|
case Shared::AccountPassword::kwallet:
|
||||||
if (password == "") {
|
if (password == "")
|
||||||
acc->invalidatePassword();
|
acc->invalidatePassword();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (state != Shared::Availability::offline) {
|
if (state != Shared::Availability::offline) {
|
||||||
acc->setAvailability(state);
|
acc->setAvailability(state);
|
||||||
if (acc->getActive()) {
|
if (acc->getActive())
|
||||||
acc->connect();
|
acc->connect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void Core::Squawk::changeState(Shared::Availability p_state)
|
void Core::Squawk::changeState(Shared::Availability p_state) {
|
||||||
{
|
|
||||||
if (state != p_state) {
|
if (state != p_state) {
|
||||||
for (std::deque<Account*>::iterator itr = accounts.begin(), end = accounts.end(); itr != end; ++itr) {
|
for (std::deque<Account*>::iterator itr = accounts.begin(), end = accounts.end(); itr != end; ++itr) {
|
||||||
Account* acc = *itr;
|
Account* acc = *itr;
|
||||||
acc->setAvailability(p_state);
|
acc->setAvailability(p_state);
|
||||||
if (state == Shared::Availability::offline && acc->getActive()) {
|
if (state == Shared::Availability::offline && acc->getActive())
|
||||||
acc->connect();
|
acc->connect();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
state = p_state;
|
state = p_state;
|
||||||
|
|
||||||
emit stateChanged(p_state);
|
emit stateChanged(p_state);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::connectAccount(const QString& account)
|
void Core::Squawk::connectAccount(const QString& account) {
|
||||||
{
|
|
||||||
AccountsMap::const_iterator itr = amap.find(account);
|
AccountsMap::const_iterator itr = amap.find(account);
|
||||||
if (itr == amap.end()) {
|
if (itr == amap.end()) {
|
||||||
qDebug("An attempt to connect non existing account, skipping");
|
qDebug("An attempt to connect non existing account, skipping");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
itr->second->setActive(true);
|
itr->second->setActive(true);
|
||||||
if (state != Shared::Availability::offline) {
|
if (state != Shared::Availability::offline)
|
||||||
itr->second->connect();
|
itr->second->connect();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void Core::Squawk::disconnectAccount(const QString& account)
|
void Core::Squawk::disconnectAccount(const QString& account) {
|
||||||
{
|
|
||||||
AccountsMap::const_iterator itr = amap.find(account);
|
AccountsMap::const_iterator itr = amap.find(account);
|
||||||
if (itr == amap.end()) {
|
if (itr == amap.end()) {
|
||||||
qDebug("An attempt to connect non existing account, skipping");
|
qDebug("An attempt to connect non existing account, skipping");
|
||||||
@ -262,15 +251,14 @@ void Core::Squawk::disconnectAccount(const QString& account)
|
|||||||
itr->second->disconnect();
|
itr->second->disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::onAccountConnectionStateChanged(Shared::ConnectionState p_state)
|
void Core::Squawk::onAccountConnectionStateChanged(Shared::ConnectionState p_state) {
|
||||||
{
|
|
||||||
Account* acc = static_cast<Account*>(sender());
|
Account* acc = static_cast<Account*>(sender());
|
||||||
QMap<QString, QVariant> changes = {
|
QMap<QString, QVariant> changes = {
|
||||||
{"state", QVariant::fromValue(p_state)}
|
{"state", QVariant::fromValue(p_state)}
|
||||||
};
|
};
|
||||||
if (acc->getLastError() == Account::Error::none) {
|
if (acc->getLastError() == Account::Error::none)
|
||||||
changes.insert("error", "");
|
changes.insert("error", "");
|
||||||
}
|
|
||||||
emit changeAccount(acc->getName(), changes);
|
emit changeAccount(acc->getName(), changes);
|
||||||
|
|
||||||
#ifdef WITH_KWALLET
|
#ifdef WITH_KWALLET
|
||||||
@ -282,55 +270,48 @@ void Core::Squawk::onAccountConnectionStateChanged(Shared::ConnectionState p_sta
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::onAccountAddContact(const QString& jid, const QString& group, const QMap<QString, QVariant>& data)
|
void Core::Squawk::onAccountAddContact(const QString& jid, const QString& group, const QMap<QString, QVariant>& data) {
|
||||||
{
|
|
||||||
Account* acc = static_cast<Account*>(sender());
|
Account* acc = static_cast<Account*>(sender());
|
||||||
emit addContact(acc->getName(), jid, group, data);
|
emit addContact(acc->getName(), jid, group, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::onAccountAddGroup(const QString& name)
|
void Core::Squawk::onAccountAddGroup(const QString& name) {
|
||||||
{
|
|
||||||
Account* acc = static_cast<Account*>(sender());
|
Account* acc = static_cast<Account*>(sender());
|
||||||
emit addGroup(acc->getName(), name);
|
emit addGroup(acc->getName(), name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::onAccountRemoveGroup(const QString& name)
|
void Core::Squawk::onAccountRemoveGroup(const QString& name) {
|
||||||
{
|
|
||||||
Account* acc = static_cast<Account*>(sender());
|
Account* acc = static_cast<Account*>(sender());
|
||||||
emit removeGroup(acc->getName(), name);
|
emit removeGroup(acc->getName(), name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::onAccountChangeContact(const QString& jid, const QMap<QString, QVariant>& data)
|
void Core::Squawk::onAccountChangeContact(const QString& jid, const QMap<QString, QVariant>& data) {
|
||||||
{
|
|
||||||
Account* acc = static_cast<Account*>(sender());
|
Account* acc = static_cast<Account*>(sender());
|
||||||
emit changeContact(acc->getName(), jid, data);
|
emit changeContact(acc->getName(), jid, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::onAccountRemoveContact(const QString& jid)
|
void Core::Squawk::onAccountRemoveContact(const QString& jid) {
|
||||||
{
|
|
||||||
Account* acc = static_cast<Account*>(sender());
|
Account* acc = static_cast<Account*>(sender());
|
||||||
emit removeContact(acc->getName(), jid);
|
emit removeContact(acc->getName(), jid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::onAccountRemoveContact(const QString& jid, const QString& group)
|
void Core::Squawk::onAccountRemoveContact(const QString& jid, const QString& group) {
|
||||||
{
|
|
||||||
Account* acc = static_cast<Account*>(sender());
|
Account* acc = static_cast<Account*>(sender());
|
||||||
emit removeContact(acc->getName(), jid, group);
|
emit removeContact(acc->getName(), jid, group);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::onAccountAddPresence(const QString& jid, const QString& name, const QMap<QString, QVariant>& data)
|
void Core::Squawk::onAccountAddPresence(const QString& jid, const QString& name, const QMap<QString, QVariant>& data) {
|
||||||
{
|
|
||||||
Account* acc = static_cast<Account*>(sender());
|
Account* acc = static_cast<Account*>(sender());
|
||||||
emit addPresence(acc->getName(), jid, name, data);
|
emit addPresence(acc->getName(), jid, name, data);
|
||||||
|
|
||||||
//it's equal if a MUC sends its status with presence of the same jid (ex: muc@srv.im/muc@srv.im), it's not a client, so, no need to request
|
//it's equal if a MUC sends its status with presence of the same jid (ex: muc@srv.im/muc@srv.im), it's not a client, so, no need to request
|
||||||
if (jid != name) {
|
if (jid != name) {
|
||||||
QString node = data["capabilityNode"].toString();
|
const Shared::ClientId& id = data["client"].value<Shared::ClientId>();
|
||||||
QString ver = data["capabilityVer"].toString();
|
if (!id.valid())
|
||||||
QString hash = data["capabilityHash"].toString();
|
return;
|
||||||
if (!clientCache.checkClient(node, ver, hash)) {
|
|
||||||
acc->discoverInfo(jid + "/" + name, node + "/" + ver);
|
if (!clientCache.checkClient(id))
|
||||||
}
|
acc->discoverInfo(jid + "/" + name, id.getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,32 +328,27 @@ void Core::Squawk::onAccountInfoDiscovered(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::onAccountRemovePresence(const QString& jid, const QString& name)
|
void Core::Squawk::onAccountRemovePresence(const QString& jid, const QString& name) {
|
||||||
{
|
|
||||||
Account* acc = static_cast<Account*>(sender());
|
Account* acc = static_cast<Account*>(sender());
|
||||||
emit removePresence(acc->getName(), jid, name);
|
emit removePresence(acc->getName(), jid, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::onAccountAvailabilityChanged(Shared::Availability state)
|
void Core::Squawk::onAccountAvailabilityChanged(Shared::Availability state) {
|
||||||
{
|
|
||||||
Account* acc = static_cast<Account*>(sender());
|
Account* acc = static_cast<Account*>(sender());
|
||||||
emit changeAccount(acc->getName(), {{"availability", QVariant::fromValue(state)}});
|
emit changeAccount(acc->getName(), {{"availability", QVariant::fromValue(state)}});
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::onAccountChanged(const QMap<QString, QVariant>& data)
|
void Core::Squawk::onAccountChanged(const QMap<QString, QVariant>& data) {
|
||||||
{
|
|
||||||
Account* acc = static_cast<Account*>(sender());
|
Account* acc = static_cast<Account*>(sender());
|
||||||
emit changeAccount(acc->getName(), data);
|
emit changeAccount(acc->getName(), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::onAccountMessage(const Shared::Message& data)
|
void Core::Squawk::onAccountMessage(const Shared::Message& data) {
|
||||||
{
|
|
||||||
Account* acc = static_cast<Account*>(sender());
|
Account* acc = static_cast<Account*>(sender());
|
||||||
emit accountMessage(acc->getName(), data);
|
emit accountMessage(acc->getName(), data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::sendMessage(const QString& account, const Shared::Message& data)
|
void Core::Squawk::sendMessage(const QString& account, const Shared::Message& data) {
|
||||||
{
|
|
||||||
AccountsMap::const_iterator itr = amap.find(account);
|
AccountsMap::const_iterator itr = amap.find(account);
|
||||||
if (itr == amap.end()) {
|
if (itr == amap.end()) {
|
||||||
qDebug() << "An attempt to send a message with non existing account" << account << ", skipping";
|
qDebug() << "An attempt to send a message with non existing account" << account << ", skipping";
|
||||||
@ -382,8 +358,7 @@ void Core::Squawk::sendMessage(const QString& account, const Shared::Message& da
|
|||||||
itr->second->sendMessage(data);
|
itr->second->sendMessage(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::replaceMessage(const QString& account, const QString& originalId, const Shared::Message& data)
|
void Core::Squawk::replaceMessage(const QString& account, const QString& originalId, const Shared::Message& data) {
|
||||||
{
|
|
||||||
AccountsMap::const_iterator itr = amap.find(account);
|
AccountsMap::const_iterator itr = amap.find(account);
|
||||||
if (itr == amap.end()) {
|
if (itr == amap.end()) {
|
||||||
qDebug() << "An attempt to replace a message with non existing account" << account << ", skipping";
|
qDebug() << "An attempt to replace a message with non existing account" << account << ", skipping";
|
||||||
@ -393,8 +368,7 @@ void Core::Squawk::replaceMessage(const QString& account, const QString& origina
|
|||||||
itr->second->replaceMessage(originalId, data);
|
itr->second->replaceMessage(originalId, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::resendMessage(const QString& account, const QString& jid, const QString& id)
|
void Core::Squawk::resendMessage(const QString& account, const QString& jid, const QString& id) {
|
||||||
{
|
|
||||||
AccountsMap::const_iterator itr = amap.find(account);
|
AccountsMap::const_iterator itr = amap.find(account);
|
||||||
if (itr == amap.end()) {
|
if (itr == amap.end()) {
|
||||||
qDebug() << "An attempt to resend a message with non existing account" << account << ", skipping";
|
qDebug() << "An attempt to resend a message with non existing account" << account << ", skipping";
|
||||||
@ -404,8 +378,7 @@ void Core::Squawk::resendMessage(const QString& account, const QString& jid, con
|
|||||||
itr->second->resendMessage(jid, id);
|
itr->second->resendMessage(jid, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::requestArchive(const QString& account, const QString& jid, int count, const QString& before)
|
void Core::Squawk::requestArchive(const QString& account, const QString& jid, int count, const QString& before) {
|
||||||
{
|
|
||||||
AccountsMap::const_iterator itr = amap.find(account);
|
AccountsMap::const_iterator itr = amap.find(account);
|
||||||
if (itr == amap.end()) {
|
if (itr == amap.end()) {
|
||||||
qDebug("An attempt to request an archive of non existing account, skipping");
|
qDebug("An attempt to request an archive of non existing account, skipping");
|
||||||
@ -414,14 +387,12 @@ void Core::Squawk::requestArchive(const QString& account, const QString& jid, in
|
|||||||
itr->second->requestArchive(jid, count, before);
|
itr->second->requestArchive(jid, count, before);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::onAccountResponseArchive(const QString& jid, const std::list<Shared::Message>& list, bool last)
|
void Core::Squawk::onAccountResponseArchive(const QString& jid, const std::list<Shared::Message>& list, bool last) {
|
||||||
{
|
|
||||||
Account* acc = static_cast<Account*>(sender());
|
Account* acc = static_cast<Account*>(sender());
|
||||||
emit responseArchive(acc->getName(), jid, list, last);
|
emit responseArchive(acc->getName(), jid, list, last);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::modifyAccountRequest(const QString& name, const QMap<QString, QVariant>& map)
|
void Core::Squawk::modifyAccountRequest(const QString& name, const QMap<QString, QVariant>& map) {
|
||||||
{
|
|
||||||
AccountsMap::const_iterator itr = amap.find(name);
|
AccountsMap::const_iterator itr = amap.find(name);
|
||||||
if (itr == amap.end()) {
|
if (itr == amap.end()) {
|
||||||
qDebug("An attempt to modify non existing account, skipping");
|
qDebug("An attempt to modify non existing account, skipping");
|
||||||
@ -471,29 +442,24 @@ void Core::Squawk::modifyAccountRequest(const QString& name, const QMap<QString,
|
|||||||
}
|
}
|
||||||
|
|
||||||
mItr = map.find("login");
|
mItr = map.find("login");
|
||||||
if (mItr != map.end()) {
|
if (mItr != map.end())
|
||||||
acc->setLogin(mItr->toString());
|
acc->setLogin(mItr->toString());
|
||||||
}
|
|
||||||
|
|
||||||
mItr = map.find("password");
|
mItr = map.find("password");
|
||||||
if (mItr != map.end()) {
|
if (mItr != map.end())
|
||||||
acc->setPassword(mItr->toString());
|
acc->setPassword(mItr->toString());
|
||||||
}
|
|
||||||
|
|
||||||
mItr = map.find("resource");
|
mItr = map.find("resource");
|
||||||
if (mItr != map.end()) {
|
if (mItr != map.end())
|
||||||
acc->setResource(mItr->toString());
|
acc->setResource(mItr->toString());
|
||||||
}
|
|
||||||
|
|
||||||
mItr = map.find("server");
|
mItr = map.find("server");
|
||||||
if (mItr != map.end()) {
|
if (mItr != map.end())
|
||||||
acc->setServer(mItr->toString());
|
acc->setServer(mItr->toString());
|
||||||
}
|
|
||||||
|
|
||||||
mItr = map.find("passwordType");
|
mItr = map.find("passwordType");
|
||||||
if (mItr != map.end()) {
|
if (mItr != map.end())
|
||||||
acc->setPasswordType(Shared::Global::fromInt<Shared::AccountPassword>(mItr->toInt()));
|
acc->setPasswordType(Shared::Global::fromInt<Shared::AccountPassword>(mItr->toInt()));
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef WITH_KWALLET
|
#ifdef WITH_KWALLET
|
||||||
if (acc->getPasswordType() == Shared::AccountPassword::kwallet
|
if (acc->getPasswordType() == Shared::AccountPassword::kwallet
|
||||||
@ -505,28 +471,24 @@ void Core::Squawk::modifyAccountRequest(const QString& name, const QMap<QString,
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (state != Shared::Availability::offline) {
|
if (state != Shared::Availability::offline) {
|
||||||
if (activeChanged && acc->getActive()) {
|
if (activeChanged && acc->getActive())
|
||||||
acc->connect();
|
acc->connect();
|
||||||
} else if (!wentReconnecting && acc->getActive() && acc->getLastError() == Account::Error::authentication) {
|
else if (!wentReconnecting && acc->getActive() && acc->getLastError() == Account::Error::authentication)
|
||||||
acc->connect();
|
acc->connect();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
emit changeAccount(name, map);
|
emit changeAccount(name, map);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::onAccountError(const QString& text)
|
void Core::Squawk::onAccountError(const QString& text) {
|
||||||
{
|
|
||||||
Account* acc = static_cast<Account*>(sender());
|
Account* acc = static_cast<Account*>(sender());
|
||||||
emit changeAccount(acc->getName(), {{"error", text}});
|
emit changeAccount(acc->getName(), {{"error", text}});
|
||||||
|
|
||||||
if (acc->getLastError() == Account::Error::authentication) {
|
if (acc->getLastError() == Account::Error::authentication)
|
||||||
emit requestPassword(acc->getName(), true);
|
emit requestPassword(acc->getName(), true);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void Core::Squawk::removeAccountRequest(const QString& name)
|
void Core::Squawk::removeAccountRequest(const QString& name) {
|
||||||
{
|
|
||||||
AccountsMap::const_iterator itr = amap.find(name);
|
AccountsMap::const_iterator itr = amap.find(name);
|
||||||
if (itr == amap.end()) {
|
if (itr == amap.end()) {
|
||||||
qDebug() << "An attempt to remove non existing account " << name << " from core, skipping";
|
qDebug() << "An attempt to remove non existing account " << name << " from core, skipping";
|
||||||
@ -534,9 +496,8 @@ void Core::Squawk::removeAccountRequest(const QString& name)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Account* acc = itr->second;
|
Account* acc = itr->second;
|
||||||
if (acc->getState() != Shared::ConnectionState::disconnected) {
|
if (acc->getState() != Shared::ConnectionState::disconnected)
|
||||||
acc->disconnect();
|
acc->disconnect();
|
||||||
}
|
|
||||||
|
|
||||||
for (Accounts::const_iterator aItr = accounts.begin(); aItr != accounts.end(); ++aItr) {
|
for (Accounts::const_iterator aItr = accounts.begin(); aItr != accounts.end(); ++aItr) {
|
||||||
if (*aItr == acc) {
|
if (*aItr == acc) {
|
||||||
@ -556,8 +517,7 @@ void Core::Squawk::removeAccountRequest(const QString& name)
|
|||||||
acc->deleteLater();
|
acc->deleteLater();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::subscribeContact(const QString& account, const QString& jid, const QString& reason)
|
void Core::Squawk::subscribeContact(const QString& account, const QString& jid, const QString& reason) {
|
||||||
{
|
|
||||||
AccountsMap::const_iterator itr = amap.find(account);
|
AccountsMap::const_iterator itr = amap.find(account);
|
||||||
if (itr == amap.end()) {
|
if (itr == amap.end()) {
|
||||||
qDebug("An attempt to subscribe to the contact with non existing account, skipping");
|
qDebug("An attempt to subscribe to the contact with non existing account, skipping");
|
||||||
@ -567,8 +527,7 @@ void Core::Squawk::subscribeContact(const QString& account, const QString& jid,
|
|||||||
itr->second->subscribeToContact(jid, reason);
|
itr->second->subscribeToContact(jid, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::unsubscribeContact(const QString& account, const QString& jid, const QString& reason)
|
void Core::Squawk::unsubscribeContact(const QString& account, const QString& jid, const QString& reason) {
|
||||||
{
|
|
||||||
AccountsMap::const_iterator itr = amap.find(account);
|
AccountsMap::const_iterator itr = amap.find(account);
|
||||||
if (itr == amap.end()) {
|
if (itr == amap.end()) {
|
||||||
qDebug("An attempt to subscribe to the contact with non existing account, skipping");
|
qDebug("An attempt to subscribe to the contact with non existing account, skipping");
|
||||||
@ -578,8 +537,7 @@ void Core::Squawk::unsubscribeContact(const QString& account, const QString& jid
|
|||||||
itr->second->unsubscribeFromContact(jid, reason);
|
itr->second->unsubscribeFromContact(jid, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::removeContactRequest(const QString& account, const QString& jid)
|
void Core::Squawk::removeContactRequest(const QString& account, const QString& jid) {
|
||||||
{
|
|
||||||
AccountsMap::const_iterator itr = amap.find(account);
|
AccountsMap::const_iterator itr = amap.find(account);
|
||||||
if (itr == amap.end()) {
|
if (itr == amap.end()) {
|
||||||
qDebug("An attempt to remove contact from non existing account, skipping");
|
qDebug("An attempt to remove contact from non existing account, skipping");
|
||||||
@ -589,8 +547,7 @@ void Core::Squawk::removeContactRequest(const QString& account, const QString& j
|
|||||||
itr->second->removeContactRequest(jid);
|
itr->second->removeContactRequest(jid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::addContactRequest(const QString& account, const QString& jid, const QString& name, const QSet<QString>& groups)
|
void Core::Squawk::addContactRequest(const QString& account, const QString& jid, const QString& name, const QSet<QString>& groups) {
|
||||||
{
|
|
||||||
AccountsMap::const_iterator itr = amap.find(account);
|
AccountsMap::const_iterator itr = amap.find(account);
|
||||||
if (itr == amap.end()) {
|
if (itr == amap.end()) {
|
||||||
qDebug("An attempt to add contact to a non existing account, skipping");
|
qDebug("An attempt to add contact to a non existing account, skipping");
|
||||||
@ -600,26 +557,22 @@ void Core::Squawk::addContactRequest(const QString& account, const QString& jid,
|
|||||||
itr->second->addContactRequest(jid, name, groups);
|
itr->second->addContactRequest(jid, name, groups);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::onAccountAddRoom(const QString jid, const QMap<QString, QVariant>& data)
|
void Core::Squawk::onAccountAddRoom(const QString jid, const QMap<QString, QVariant>& data) {
|
||||||
{
|
|
||||||
Account* acc = static_cast<Account*>(sender());
|
Account* acc = static_cast<Account*>(sender());
|
||||||
emit addRoom(acc->getName(), jid, data);
|
emit addRoom(acc->getName(), jid, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::onAccountChangeRoom(const QString jid, const QMap<QString, QVariant>& data)
|
void Core::Squawk::onAccountChangeRoom(const QString jid, const QMap<QString, QVariant>& data) {
|
||||||
{
|
|
||||||
Account* acc = static_cast<Account*>(sender());
|
Account* acc = static_cast<Account*>(sender());
|
||||||
emit changeRoom(acc->getName(), jid, data);
|
emit changeRoom(acc->getName(), jid, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::onAccountRemoveRoom(const QString jid)
|
void Core::Squawk::onAccountRemoveRoom(const QString jid) {
|
||||||
{
|
|
||||||
Account* acc = static_cast<Account*>(sender());
|
Account* acc = static_cast<Account*>(sender());
|
||||||
emit removeRoom(acc->getName(), jid);
|
emit removeRoom(acc->getName(), jid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::setRoomJoined(const QString& account, const QString& jid, bool joined)
|
void Core::Squawk::setRoomJoined(const QString& account, const QString& jid, bool joined) {
|
||||||
{
|
|
||||||
AccountsMap::const_iterator itr = amap.find(account);
|
AccountsMap::const_iterator itr = amap.find(account);
|
||||||
if (itr == amap.end()) {
|
if (itr == amap.end()) {
|
||||||
qDebug() << "An attempt to set jouned to the room" << jid << "of non existing account" << account << ", skipping";
|
qDebug() << "An attempt to set jouned to the room" << jid << "of non existing account" << account << ", skipping";
|
||||||
@ -628,8 +581,7 @@ void Core::Squawk::setRoomJoined(const QString& account, const QString& jid, boo
|
|||||||
itr->second->setRoomJoined(jid, joined);
|
itr->second->setRoomJoined(jid, joined);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::setRoomAutoJoin(const QString& account, const QString& jid, bool joined)
|
void Core::Squawk::setRoomAutoJoin(const QString& account, const QString& jid, bool joined) {
|
||||||
{
|
|
||||||
AccountsMap::const_iterator itr = amap.find(account);
|
AccountsMap::const_iterator itr = amap.find(account);
|
||||||
if (itr == amap.end()) {
|
if (itr == amap.end()) {
|
||||||
qDebug() << "An attempt to set autoJoin to the room" << jid << "of non existing account" << account << ", skipping";
|
qDebug() << "An attempt to set autoJoin to the room" << jid << "of non existing account" << account << ", skipping";
|
||||||
@ -638,32 +590,27 @@ void Core::Squawk::setRoomAutoJoin(const QString& account, const QString& jid, b
|
|||||||
itr->second->setRoomAutoJoin(jid, joined);
|
itr->second->setRoomAutoJoin(jid, joined);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::onAccountAddRoomPresence(const QString& jid, const QString& nick, const QMap<QString, QVariant>& data)
|
void Core::Squawk::onAccountAddRoomPresence(const QString& jid, const QString& nick, const QMap<QString, QVariant>& data) {
|
||||||
{
|
|
||||||
Account* acc = static_cast<Account*>(sender());
|
Account* acc = static_cast<Account*>(sender());
|
||||||
emit addRoomParticipant(acc->getName(), jid, nick, data);
|
emit addRoomParticipant(acc->getName(), jid, nick, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::onAccountChangeRoomPresence(const QString& jid, const QString& nick, const QMap<QString, QVariant>& data)
|
void Core::Squawk::onAccountChangeRoomPresence(const QString& jid, const QString& nick, const QMap<QString, QVariant>& data) {
|
||||||
{
|
|
||||||
Account* acc = static_cast<Account*>(sender());
|
Account* acc = static_cast<Account*>(sender());
|
||||||
emit changeRoomParticipant(acc->getName(), jid, nick, data);
|
emit changeRoomParticipant(acc->getName(), jid, nick, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::onAccountRemoveRoomPresence(const QString& jid, const QString& nick)
|
void Core::Squawk::onAccountRemoveRoomPresence(const QString& jid, const QString& nick) {
|
||||||
{
|
|
||||||
Account* acc = static_cast<Account*>(sender());
|
Account* acc = static_cast<Account*>(sender());
|
||||||
emit removeRoomParticipant(acc->getName(), jid, nick);
|
emit removeRoomParticipant(acc->getName(), jid, nick);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::onAccountChangeMessage(const QString& jid, const QString& id, const QMap<QString, QVariant>& data)
|
void Core::Squawk::onAccountChangeMessage(const QString& jid, const QString& id, const QMap<QString, QVariant>& data) {
|
||||||
{
|
|
||||||
Account* acc = static_cast<Account*>(sender());
|
Account* acc = static_cast<Account*>(sender());
|
||||||
emit changeMessage(acc->getName(), jid, id, data);
|
emit changeMessage(acc->getName(), jid, id, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::removeRoomRequest(const QString& account, const QString& jid)
|
void Core::Squawk::removeRoomRequest(const QString& account, const QString& jid) {
|
||||||
{
|
|
||||||
AccountsMap::const_iterator itr = amap.find(account);
|
AccountsMap::const_iterator itr = amap.find(account);
|
||||||
if (itr == amap.end()) {
|
if (itr == amap.end()) {
|
||||||
qDebug() << "An attempt to remove the room" << jid << "of non existing account" << account << ", skipping";
|
qDebug() << "An attempt to remove the room" << jid << "of non existing account" << account << ", skipping";
|
||||||
@ -672,8 +619,7 @@ void Core::Squawk::removeRoomRequest(const QString& account, const QString& jid)
|
|||||||
itr->second->removeRoomRequest(jid);
|
itr->second->removeRoomRequest(jid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::addRoomRequest(const QString& account, const QString& jid, const QString& nick, const QString& password, bool autoJoin)
|
void Core::Squawk::addRoomRequest(const QString& account, const QString& jid, const QString& nick, const QString& password, bool autoJoin) {
|
||||||
{
|
|
||||||
AccountsMap::const_iterator itr = amap.find(account);
|
AccountsMap::const_iterator itr = amap.find(account);
|
||||||
if (itr == amap.end()) {
|
if (itr == amap.end()) {
|
||||||
qDebug() << "An attempt to add the room" << jid << "to non existing account" << account << ", skipping";
|
qDebug() << "An attempt to add the room" << jid << "to non existing account" << account << ", skipping";
|
||||||
@ -682,13 +628,11 @@ void Core::Squawk::addRoomRequest(const QString& account, const QString& jid, co
|
|||||||
itr->second->addRoomRequest(jid, nick, password, autoJoin);
|
itr->second->addRoomRequest(jid, nick, password, autoJoin);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::fileDownloadRequest(const QString& url)
|
void Core::Squawk::fileDownloadRequest(const QString& url) {
|
||||||
{
|
|
||||||
network.downladFile(url);
|
network.downladFile(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::addContactToGroupRequest(const QString& account, const QString& jid, const QString& groupName)
|
void Core::Squawk::addContactToGroupRequest(const QString& account, const QString& jid, const QString& groupName) {
|
||||||
{
|
|
||||||
AccountsMap::const_iterator itr = amap.find(account);
|
AccountsMap::const_iterator itr = amap.find(account);
|
||||||
if (itr == amap.end()) {
|
if (itr == amap.end()) {
|
||||||
qDebug() << "An attempt to add contact" << jid << "of non existing account" << account << "to the group" << groupName << ", skipping";
|
qDebug() << "An attempt to add contact" << jid << "of non existing account" << account << "to the group" << groupName << ", skipping";
|
||||||
@ -697,8 +641,7 @@ void Core::Squawk::addContactToGroupRequest(const QString& account, const QStrin
|
|||||||
itr->second->addContactToGroupRequest(jid, groupName);
|
itr->second->addContactToGroupRequest(jid, groupName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::removeContactFromGroupRequest(const QString& account, const QString& jid, const QString& groupName)
|
void Core::Squawk::removeContactFromGroupRequest(const QString& account, const QString& jid, const QString& groupName) {
|
||||||
{
|
|
||||||
AccountsMap::const_iterator itr = amap.find(account);
|
AccountsMap::const_iterator itr = amap.find(account);
|
||||||
if (itr == amap.end()) {
|
if (itr == amap.end()) {
|
||||||
qDebug() << "An attempt to add contact" << jid << "of non existing account" << account << "to the group" << groupName << ", skipping";
|
qDebug() << "An attempt to add contact" << jid << "of non existing account" << account << "to the group" << groupName << ", skipping";
|
||||||
@ -707,8 +650,7 @@ void Core::Squawk::removeContactFromGroupRequest(const QString& account, const Q
|
|||||||
itr->second->removeContactFromGroupRequest(jid, groupName);
|
itr->second->removeContactFromGroupRequest(jid, groupName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::renameContactRequest(const QString& account, const QString& jid, const QString& newName)
|
void Core::Squawk::renameContactRequest(const QString& account, const QString& jid, const QString& newName) {
|
||||||
{
|
|
||||||
AccountsMap::const_iterator itr = amap.find(account);
|
AccountsMap::const_iterator itr = amap.find(account);
|
||||||
if (itr == amap.end()) {
|
if (itr == amap.end()) {
|
||||||
qDebug() << "An attempt to rename contact" << jid << "of non existing account" << account << ", skipping";
|
qDebug() << "An attempt to rename contact" << jid << "of non existing account" << account << ", skipping";
|
||||||
@ -717,8 +659,7 @@ void Core::Squawk::renameContactRequest(const QString& account, const QString& j
|
|||||||
itr->second->renameContactRequest(jid, newName);
|
itr->second->renameContactRequest(jid, newName);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::requestInfo(const QString& account, const QString& jid)
|
void Core::Squawk::requestInfo(const QString& account, const QString& jid) {
|
||||||
{
|
|
||||||
AccountsMap::const_iterator itr = amap.find(account);
|
AccountsMap::const_iterator itr = amap.find(account);
|
||||||
if (itr == amap.end()) {
|
if (itr == amap.end()) {
|
||||||
qDebug() << "An attempt to request info about" << jid << "of non existing account" << account << ", skipping";
|
qDebug() << "An attempt to request info about" << jid << "of non existing account" << account << ", skipping";
|
||||||
@ -727,8 +668,7 @@ void Core::Squawk::requestInfo(const QString& account, const QString& jid)
|
|||||||
itr->second->requestInfo(jid);
|
itr->second->requestInfo(jid);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::updateInfo(const QString& account, const Shared::Info& info)
|
void Core::Squawk::updateInfo(const QString& account, const Shared::Info& info) {
|
||||||
{
|
|
||||||
AccountsMap::const_iterator itr = amap.find(account);
|
AccountsMap::const_iterator itr = amap.find(account);
|
||||||
if (itr == amap.end()) {
|
if (itr == amap.end()) {
|
||||||
qDebug() << "An attempt to update info to non existing account" << account << ", skipping";
|
qDebug() << "An attempt to update info to non existing account" << account << ", skipping";
|
||||||
@ -737,8 +677,7 @@ void Core::Squawk::updateInfo(const QString& account, const Shared::Info& info)
|
|||||||
itr->second->updateInfo(info);
|
itr->second->updateInfo(info);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::readSettings()
|
void Core::Squawk::readSettings() {
|
||||||
{
|
|
||||||
QSettings settings;
|
QSettings settings;
|
||||||
settings.beginGroup("core");
|
settings.beginGroup("core");
|
||||||
int size = settings.beginReadArray("accounts");
|
int size = settings.beginReadArray("accounts");
|
||||||
@ -772,8 +711,7 @@ void Core::Squawk::readSettings()
|
|||||||
emit ready();
|
emit ready();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::onAccountNeedPassword()
|
void Core::Squawk::onAccountNeedPassword() {
|
||||||
{
|
|
||||||
Account* acc = static_cast<Account*>(sender());
|
Account* acc = static_cast<Account*>(sender());
|
||||||
switch (acc->getPasswordType()) {
|
switch (acc->getPasswordType()) {
|
||||||
case Shared::AccountPassword::alwaysAsk:
|
case Shared::AccountPassword::alwaysAsk:
|
||||||
@ -796,13 +734,11 @@ void Core::Squawk::onAccountNeedPassword()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::onWalletRejectPassword(const QString& login)
|
void Core::Squawk::onWalletRejectPassword(const QString& login) {
|
||||||
{
|
|
||||||
emit requestPassword(login, false);
|
emit requestPassword(login, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::responsePassword(const QString& account, const QString& password)
|
void Core::Squawk::responsePassword(const QString& account, const QString& password) {
|
||||||
{
|
|
||||||
AccountsMap::const_iterator itr = amap.find(account);
|
AccountsMap::const_iterator itr = amap.find(account);
|
||||||
if (itr == amap.end()) {
|
if (itr == amap.end()) {
|
||||||
qDebug() << "An attempt to set password to non existing account" << account << ", skipping";
|
qDebug() << "An attempt to set password to non existing account" << account << ", skipping";
|
||||||
@ -811,24 +747,19 @@ void Core::Squawk::responsePassword(const QString& account, const QString& passw
|
|||||||
Account* acc = itr->second;
|
Account* acc = itr->second;
|
||||||
acc->setPassword(password);
|
acc->setPassword(password);
|
||||||
emit changeAccount(account, {{"password", password}});
|
emit changeAccount(account, {{"password", password}});
|
||||||
if (state != Shared::Availability::offline && acc->getActive()) {
|
if (state != Shared::Availability::offline && acc->getActive())
|
||||||
acc->connect();
|
acc->connect();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void Core::Squawk::onAccountUploadFileError(const QString& jid, const QString id, const QString& errorText)
|
void Core::Squawk::onAccountUploadFileError(const QString& jid, const QString id, const QString& errorText) {
|
||||||
{
|
|
||||||
Account* acc = static_cast<Account*>(sender());
|
Account* acc = static_cast<Account*>(sender());
|
||||||
emit fileError({{acc->getName(), jid, id}}, errorText, true);
|
emit fileError({{acc->getName(), jid, id}}, errorText, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::onLocalPathInvalid(const QString& path)
|
void Core::Squawk::onLocalPathInvalid(const QString& path) {
|
||||||
{
|
|
||||||
std::list<Shared::MessageInfo> list = network.reportPathInvalid(path);
|
std::list<Shared::MessageInfo> list = network.reportPathInvalid(path);
|
||||||
|
|
||||||
QMap<QString, QVariant> data({
|
QMap<QString, QVariant> data({{"attachPath", ""}});
|
||||||
{"attachPath", ""}
|
|
||||||
});
|
|
||||||
for (const Shared::MessageInfo& info : list) {
|
for (const Shared::MessageInfo& info : list) {
|
||||||
AccountsMap::const_iterator itr = amap.find(info.account);
|
AccountsMap::const_iterator itr = amap.find(info.account);
|
||||||
if (itr != amap.end()) {
|
if (itr != amap.end()) {
|
||||||
@ -839,8 +770,7 @@ void Core::Squawk::onLocalPathInvalid(const QString& path)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Core::Squawk::changeDownloadsPath(const QString& path)
|
void Core::Squawk::changeDownloadsPath(const QString& path) {
|
||||||
{
|
|
||||||
network.moveFilesDirectory(path);
|
network.moveFilesDirectory(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,10 +22,125 @@ Shared::ClientId::ClientId():
|
|||||||
hash()
|
hash()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
Shared::ClientId::ClientId(const QString& p_node, const QString& p_ver, const QString& p_hash):
|
||||||
|
node(p_node),
|
||||||
|
verification(p_ver),
|
||||||
|
hash(p_hash)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
Shared::ClientId::ClientId(const Shared::ClientId& other):
|
||||||
|
node(other.node),
|
||||||
|
verification(other.verification),
|
||||||
|
hash(other.hash)
|
||||||
|
{}
|
||||||
|
|
||||||
|
Shared::ClientId & Shared::ClientId::operator=(const Shared::ClientId& other) {
|
||||||
|
node = other.node;
|
||||||
|
verification = other.verification;
|
||||||
|
hash = other.hash;
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Shared::ClientId::operator==(const Shared::ClientId& other) const {
|
||||||
|
return hash == other.hash && verification == other.verification && node == other.node;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Shared::ClientId::operator!=(const Shared::ClientId& other) const {
|
||||||
|
return hash != other.hash && verification != other.verification && node != other.node;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Shared::ClientId::operator<(const Shared::ClientId& other) const {
|
||||||
|
if (hash < other.hash)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (hash > other.hash)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (verification < other.verification)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (verification > other.verification)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (node < other.node)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Shared::ClientId::operator>(const Shared::ClientId& other) const {
|
||||||
|
if (hash > other.hash)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (hash < other.hash)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (verification > other.verification)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (verification < other.verification)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (node > other.node)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Shared::ClientId::operator<=(const Shared::ClientId& other) const {
|
||||||
|
if (hash < other.hash)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (hash > other.hash)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (verification < other.verification)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (verification > other.verification)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (node < other.node)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (node > other.node)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Shared::ClientId::operator>=(const Shared::ClientId& other) const {
|
||||||
|
if (hash > other.hash)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (hash < other.hash)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (verification > other.verification)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (verification < other.verification)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (node > other.node)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (node < other.node)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
QString Shared::ClientId::getId() const {
|
QString Shared::ClientId::getId() const {
|
||||||
return node + "/" + verification;
|
return node + "/" + verification;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Shared::ClientId::valid() const {
|
||||||
|
return node.size() > 0 && verification.size() > 0 && hash.size() > 0;
|
||||||
|
}
|
||||||
|
|
||||||
QDataStream & Shared::ClientId::operator<<(QDataStream& stream) {
|
QDataStream & Shared::ClientId::operator<<(QDataStream& stream) {
|
||||||
stream >> node;
|
stream >> node;
|
||||||
stream >> verification;
|
stream >> verification;
|
||||||
|
@ -25,7 +25,18 @@ namespace Shared {
|
|||||||
class ClientId {
|
class ClientId {
|
||||||
public:
|
public:
|
||||||
ClientId();
|
ClientId();
|
||||||
|
ClientId(const QString& node, const QString& verification, const QString& hash);
|
||||||
|
ClientId(const ClientId& other);
|
||||||
|
ClientId& operator = (const ClientId& other);
|
||||||
|
|
||||||
|
bool operator == (const ClientId& other) const;
|
||||||
|
bool operator != (const ClientId& other) const;
|
||||||
|
bool operator < (const ClientId& other) const;
|
||||||
|
bool operator > (const ClientId& other) const;
|
||||||
|
bool operator <= (const ClientId& other) const;
|
||||||
|
bool operator >= (const ClientId& other) const;
|
||||||
|
|
||||||
|
bool valid() const;
|
||||||
QString getId() const;
|
QString getId() const;
|
||||||
|
|
||||||
QDataStream& operator << (QDataStream& stream);
|
QDataStream& operator << (QDataStream& stream);
|
||||||
@ -39,6 +50,8 @@ public:
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(Shared::ClientId)
|
||||||
|
|
||||||
QDataStream& operator << (QDataStream& stream, const Shared::ClientId& info);
|
QDataStream& operator << (QDataStream& stream, const Shared::ClientId& info);
|
||||||
QDataStream& operator >> (QDataStream& stream, Shared::ClientId& info);
|
QDataStream& operator >> (QDataStream& stream, Shared::ClientId& info);
|
||||||
|
|
||||||
|
@ -35,11 +35,22 @@ Shared::ClientInfo::ClientInfo():
|
|||||||
id(),
|
id(),
|
||||||
specificPresence() {}
|
specificPresence() {}
|
||||||
|
|
||||||
|
Shared::ClientInfo::ClientInfo(const QString& p_node, const QString& p_ver, const QString& p_hash) :
|
||||||
|
identities(),
|
||||||
|
extensions(),
|
||||||
|
id(p_node, p_ver, p_hash),
|
||||||
|
specificPresence() {}
|
||||||
|
|
||||||
|
Shared::ClientInfo::ClientInfo(const Shared::ClientId& p_id) :
|
||||||
|
identities(),
|
||||||
|
extensions(),
|
||||||
|
id(p_id),
|
||||||
|
specificPresence() {}
|
||||||
|
|
||||||
QString Shared::ClientInfo::getId() const {
|
QString Shared::ClientInfo::getId() const {
|
||||||
return id.getId();
|
return id.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
QDataStream & Shared::ClientInfo::operator >> (QDataStream& stream) const {
|
QDataStream & Shared::ClientInfo::operator >> (QDataStream& stream) const {
|
||||||
stream << id;
|
stream << id;
|
||||||
stream << (quint8)identities.size();
|
stream << (quint8)identities.size();
|
||||||
|
@ -31,6 +31,8 @@ namespace Shared {
|
|||||||
class ClientInfo {
|
class ClientInfo {
|
||||||
public:
|
public:
|
||||||
ClientInfo();
|
ClientInfo();
|
||||||
|
ClientInfo(const ClientId& id);
|
||||||
|
ClientInfo(const QString& node, const QString& verification, const QString& hash);
|
||||||
|
|
||||||
QString getId() const;
|
QString getId() const;
|
||||||
bool valid() const;
|
bool valid() const;
|
||||||
|
@ -1,28 +1,36 @@
|
|||||||
target_sources(squawk PRIVATE
|
set(SOURCE_FILES
|
||||||
abstractparticipant.cpp
|
abstractparticipant.cpp
|
||||||
abstractparticipant.h
|
|
||||||
account.cpp
|
account.cpp
|
||||||
account.h
|
|
||||||
accounts.cpp
|
accounts.cpp
|
||||||
accounts.h
|
|
||||||
contact.cpp
|
contact.cpp
|
||||||
contact.h
|
|
||||||
element.cpp
|
element.cpp
|
||||||
element.h
|
|
||||||
group.cpp
|
group.cpp
|
||||||
group.h
|
|
||||||
item.cpp
|
item.cpp
|
||||||
item.h
|
|
||||||
participant.cpp
|
participant.cpp
|
||||||
participant.h
|
|
||||||
presence.cpp
|
presence.cpp
|
||||||
presence.h
|
|
||||||
reference.cpp
|
reference.cpp
|
||||||
reference.h
|
|
||||||
room.cpp
|
room.cpp
|
||||||
room.h
|
|
||||||
roster.cpp
|
roster.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
set(HEADER_FILES
|
||||||
|
abstractparticipant.h
|
||||||
|
account.h
|
||||||
|
accounts.h
|
||||||
|
contact.h
|
||||||
|
element.h
|
||||||
|
group.h
|
||||||
|
item.h
|
||||||
|
participant.h
|
||||||
|
presence.h
|
||||||
|
reference.h
|
||||||
|
room.h
|
||||||
roster.h
|
roster.h
|
||||||
)
|
)
|
||||||
|
|
||||||
|
target_sources(squawk PRIVATE
|
||||||
|
${SOURCE_FILES}
|
||||||
|
${HEADER_FILES}
|
||||||
|
)
|
||||||
|
|
||||||
add_subdirectory(info)
|
add_subdirectory(info)
|
||||||
|
@ -18,40 +18,38 @@
|
|||||||
|
|
||||||
#include "abstractparticipant.h"
|
#include "abstractparticipant.h"
|
||||||
|
|
||||||
using namespace Models;
|
|
||||||
|
|
||||||
Models::AbstractParticipant::AbstractParticipant(Models::Item::Type p_type, const QMap<QString, QVariant>& data, Models::Item* parentItem):
|
Models::AbstractParticipant::AbstractParticipant(Models::Item::Type p_type, const QMap<QString, QVariant>& data, Models::Item* parentItem):
|
||||||
Item(p_type, data, parentItem),
|
Item(p_type, data, parentItem),
|
||||||
availability(Shared::Availability::offline),
|
availability(Shared::Availability::offline),
|
||||||
lastActivity(data.value("lastActivity").toDateTime()),
|
lastActivity(data.value("lastActivity").toDateTime()),
|
||||||
status(data.value("status").toString())
|
status(data.value("status").toString()),
|
||||||
|
client()
|
||||||
{
|
{
|
||||||
QMap<QString, QVariant>::const_iterator itr = data.find("availability");
|
QMap<QString, QVariant>::const_iterator itr = data.find("availability");
|
||||||
if (itr != data.end()) {
|
if (itr != data.end())
|
||||||
setAvailability(itr.value().toUInt());
|
setAvailability(itr.value().toUInt());
|
||||||
}
|
|
||||||
|
itr = data.find("client");
|
||||||
|
if (itr != data.end())
|
||||||
|
setClient(itr.value().value<Shared::ClientId>());
|
||||||
}
|
}
|
||||||
|
|
||||||
Models::AbstractParticipant::AbstractParticipant(const Models::AbstractParticipant& other):
|
Models::AbstractParticipant::AbstractParticipant(const Models::AbstractParticipant& other):
|
||||||
Item(other),
|
Item(other),
|
||||||
availability(other.availability),
|
availability(other.availability),
|
||||||
lastActivity(other.lastActivity),
|
lastActivity(other.lastActivity),
|
||||||
status(other.status)
|
status(other.status),
|
||||||
{
|
client(other.client)
|
||||||
|
{}
|
||||||
|
|
||||||
|
|
||||||
|
Models::AbstractParticipant::~AbstractParticipant() {}
|
||||||
|
|
||||||
|
int Models::AbstractParticipant::columnCount() const {
|
||||||
|
return 5;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QVariant Models::AbstractParticipant::data(int column) const {
|
||||||
Models::AbstractParticipant::~AbstractParticipant()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
int Models::AbstractParticipant::columnCount() const
|
|
||||||
{
|
|
||||||
return 4;
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant Models::AbstractParticipant::data(int column) const
|
|
||||||
{
|
|
||||||
switch (column) {
|
switch (column) {
|
||||||
case 0:
|
case 0:
|
||||||
return Item::data(column);
|
return Item::data(column);
|
||||||
@ -61,62 +59,71 @@ QVariant Models::AbstractParticipant::data(int column) const
|
|||||||
return QVariant::fromValue(availability);
|
return QVariant::fromValue(availability);
|
||||||
case 3:
|
case 3:
|
||||||
return status;
|
return status;
|
||||||
|
case 4:
|
||||||
|
return QVariant::fromValue(client);
|
||||||
default:
|
default:
|
||||||
return QVariant();
|
return QVariant();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Shared::Availability Models::AbstractParticipant::getAvailability() const
|
Shared::Availability Models::AbstractParticipant::getAvailability() const {
|
||||||
{
|
|
||||||
return availability;
|
return availability;
|
||||||
}
|
}
|
||||||
|
|
||||||
QDateTime Models::AbstractParticipant::getLastActivity() const
|
QDateTime Models::AbstractParticipant::getLastActivity() const {
|
||||||
{
|
|
||||||
return lastActivity;
|
return lastActivity;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Models::AbstractParticipant::getStatus() const
|
QString Models::AbstractParticipant::getStatus() const {
|
||||||
{
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Models::AbstractParticipant::setAvailability(Shared::Availability p_avail)
|
void Models::AbstractParticipant::setAvailability(Shared::Availability p_avail) {
|
||||||
{
|
|
||||||
if (availability != p_avail) {
|
if (availability != p_avail) {
|
||||||
availability = p_avail;
|
availability = p_avail;
|
||||||
changed(2);
|
changed(2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Models::AbstractParticipant::setAvailability(unsigned int avail)
|
void Models::AbstractParticipant::setAvailability(unsigned int avail) {
|
||||||
{
|
|
||||||
setAvailability(Shared::Global::fromInt<Shared::Availability>(avail));
|
setAvailability(Shared::Global::fromInt<Shared::Availability>(avail));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Models::AbstractParticipant::setLastActivity(const QDateTime& p_time)
|
void Models::AbstractParticipant::setLastActivity(const QDateTime& p_time) {
|
||||||
{
|
|
||||||
if (lastActivity != p_time) {
|
if (lastActivity != p_time) {
|
||||||
lastActivity = p_time;
|
lastActivity = p_time;
|
||||||
changed(1);
|
changed(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Models::AbstractParticipant::setStatus(const QString& p_state)
|
void Models::AbstractParticipant::setStatus(const QString& p_state) {
|
||||||
{
|
|
||||||
if (status != p_state) {
|
if (status != p_state) {
|
||||||
status = p_state;
|
status = p_state;
|
||||||
changed(3);
|
changed(3);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QIcon Models::AbstractParticipant::getStatusIcon(bool big) const
|
Shared::ClientId Models::AbstractParticipant::getClient() const {
|
||||||
{
|
return client;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Models::AbstractParticipant::getClientNode() const {
|
||||||
|
return client.node;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Models::AbstractParticipant::setClient(const Shared::ClientId& id) {
|
||||||
|
if (client != id) {
|
||||||
|
client = id;
|
||||||
|
changed(4);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
QIcon Models::AbstractParticipant::getStatusIcon(bool big) const {
|
||||||
return Shared::availabilityIcon(availability, big);
|
return Shared::availabilityIcon(availability, big);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Models::AbstractParticipant::update(const QString& key, const QVariant& value)
|
void Models::AbstractParticipant::update(const QString& key, const QVariant& value) {
|
||||||
{
|
|
||||||
if (key == "name") {
|
if (key == "name") {
|
||||||
setName(value.toString());
|
setName(value.toString());
|
||||||
} else if (key == "status") {
|
} else if (key == "status") {
|
||||||
@ -125,5 +132,7 @@ void Models::AbstractParticipant::update(const QString& key, const QVariant& val
|
|||||||
setAvailability(value.toUInt());
|
setAvailability(value.toUInt());
|
||||||
} else if (key == "lastActivity") {
|
} else if (key == "lastActivity") {
|
||||||
setLastActivity(value.toDateTime());
|
setLastActivity(value.toDateTime());
|
||||||
|
} else if (key == "client") {
|
||||||
|
setClient(value.value<Shared::ClientId>());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,9 +21,10 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "item.h"
|
#include "item.h"
|
||||||
#include "shared/enums.h"
|
#include <shared/enums.h>
|
||||||
#include "shared/icons.h"
|
#include <shared/icons.h>
|
||||||
#include "shared/global.h"
|
#include <shared/global.h>
|
||||||
|
#include <shared/clientid.h>
|
||||||
|
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
@ -52,12 +53,17 @@ public:
|
|||||||
void setStatus(const QString& p_state);
|
void setStatus(const QString& p_state);
|
||||||
virtual QIcon getStatusIcon(bool big = false) const;
|
virtual QIcon getStatusIcon(bool big = false) const;
|
||||||
|
|
||||||
|
Shared::ClientId getClient() const;
|
||||||
|
void setClient(const Shared::ClientId& id);
|
||||||
|
QString getClientNode() const;
|
||||||
|
|
||||||
virtual void update(const QString& key, const QVariant& value);
|
virtual void update(const QString& key, const QVariant& value);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Shared::Availability availability;
|
Shared::Availability availability;
|
||||||
QDateTime lastActivity;
|
QDateTime lastActivity;
|
||||||
QString status;
|
QString status;
|
||||||
|
Shared::ClientId client;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -26,52 +26,46 @@ Models::Participant::Participant(const QMap<QString, QVariant>& data, Models::It
|
|||||||
role(Shared::Role::unspecified)
|
role(Shared::Role::unspecified)
|
||||||
{
|
{
|
||||||
QMap<QString, QVariant>::const_iterator itr = data.find("affiliation");
|
QMap<QString, QVariant>::const_iterator itr = data.find("affiliation");
|
||||||
if (itr != data.end()) {
|
if (itr != data.end())
|
||||||
setAffiliation(itr.value().toUInt());
|
setAffiliation(itr.value().toUInt());
|
||||||
}
|
|
||||||
|
|
||||||
itr = data.find("role");
|
itr = data.find("role");
|
||||||
if (itr != data.end()) {
|
if (itr != data.end())
|
||||||
setRole(itr.value().toUInt());
|
setRole(itr.value().toUInt());
|
||||||
}
|
|
||||||
|
|
||||||
itr = data.find("avatarState");
|
itr = data.find("avatarState");
|
||||||
if (itr != data.end()) {
|
if (itr != data.end())
|
||||||
setAvatarState(itr.value().toUInt());
|
setAvatarState(itr.value().toUInt());
|
||||||
}
|
|
||||||
itr = data.find("avatarPath");
|
itr = data.find("avatarPath");
|
||||||
if (itr != data.end()) {
|
if (itr != data.end())
|
||||||
setAvatarPath(itr.value().toString());
|
setAvatarPath(itr.value().toString());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Models::Participant::~Participant()
|
Models::Participant::~Participant()
|
||||||
{
|
{}
|
||||||
|
|
||||||
|
int Models::Participant::columnCount() const {
|
||||||
|
return 9;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Models::Participant::columnCount() const
|
QVariant Models::Participant::data(int column) const {
|
||||||
{
|
|
||||||
return 8;
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant Models::Participant::data(int column) const
|
|
||||||
{
|
|
||||||
switch (column) {
|
switch (column) {
|
||||||
case 4:
|
|
||||||
return QVariant::fromValue(affiliation);
|
|
||||||
case 5:
|
case 5:
|
||||||
return QVariant::fromValue(role);
|
return QVariant::fromValue(affiliation);
|
||||||
case 6:
|
case 6:
|
||||||
return QVariant::fromValue(getAvatarState());
|
return QVariant::fromValue(role);
|
||||||
case 7:
|
case 7:
|
||||||
|
return QVariant::fromValue(getAvatarState());
|
||||||
|
case 8:
|
||||||
return getAvatarPath();
|
return getAvatarPath();
|
||||||
default:
|
default:
|
||||||
return AbstractParticipant::data(column);
|
return AbstractParticipant::data(column);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Models::Participant::update(const QString& key, const QVariant& value)
|
void Models::Participant::update(const QString& key, const QVariant& value) {
|
||||||
{
|
|
||||||
if (key == "affiliation") {
|
if (key == "affiliation") {
|
||||||
setAffiliation(value.toUInt());
|
setAffiliation(value.toUInt());
|
||||||
} else if (key == "role") {
|
} else if (key == "role") {
|
||||||
@ -85,67 +79,58 @@ void Models::Participant::update(const QString& key, const QVariant& value)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Shared::Affiliation Models::Participant::getAffiliation() const
|
Shared::Affiliation Models::Participant::getAffiliation() const {
|
||||||
{
|
|
||||||
return affiliation;
|
return affiliation;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Models::Participant::setAffiliation(Shared::Affiliation p_aff)
|
void Models::Participant::setAffiliation(Shared::Affiliation p_aff) {
|
||||||
{
|
|
||||||
if (p_aff != affiliation) {
|
if (p_aff != affiliation) {
|
||||||
affiliation = p_aff;
|
affiliation = p_aff;
|
||||||
changed(4);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Models::Participant::setAffiliation(unsigned int aff)
|
|
||||||
{
|
|
||||||
setAffiliation(Shared::Global::fromInt<Shared::Affiliation>(aff));
|
|
||||||
}
|
|
||||||
|
|
||||||
Shared::Role Models::Participant::getRole() const
|
|
||||||
{
|
|
||||||
return role;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Models::Participant::setRole(Shared::Role p_role)
|
|
||||||
{
|
|
||||||
if (p_role != role) {
|
|
||||||
role = p_role;
|
|
||||||
changed(5);
|
changed(5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Models::Participant::setRole(unsigned int p_role)
|
void Models::Participant::setAffiliation(unsigned int aff) {
|
||||||
{
|
setAffiliation(Shared::Global::fromInt<Shared::Affiliation>(aff));
|
||||||
setRole(Shared::Global::fromInt<Shared::Role>(p_role));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Models::Participant::getAvatarPath() const
|
Shared::Role Models::Participant::getRole() const {
|
||||||
{
|
return role;
|
||||||
return avatarPath;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Shared::Avatar Models::Participant::getAvatarState() const
|
void Models::Participant::setRole(Shared::Role p_role) {
|
||||||
{
|
if (p_role != role) {
|
||||||
return avatarState;
|
role = p_role;
|
||||||
}
|
|
||||||
|
|
||||||
void Models::Participant::setAvatarPath(const QString& path)
|
|
||||||
{
|
|
||||||
if (avatarPath != path) {
|
|
||||||
avatarPath = path;
|
|
||||||
changed(7);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Models::Participant::setAvatarState(Shared::Avatar p_state)
|
|
||||||
{
|
|
||||||
if (avatarState != p_state) {
|
|
||||||
avatarState = p_state;
|
|
||||||
changed(6);
|
changed(6);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Models::Participant::setAvatarState(unsigned int p_state)
|
void Models::Participant::setRole(unsigned int p_role) {
|
||||||
{setAvatarState(Shared::Global::fromInt<Shared::Avatar>(p_state));}
|
setRole(Shared::Global::fromInt<Shared::Role>(p_role));
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Models::Participant::getAvatarPath() const {
|
||||||
|
return avatarPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
Shared::Avatar Models::Participant::getAvatarState() const {
|
||||||
|
return avatarState;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Models::Participant::setAvatarPath(const QString& path) {
|
||||||
|
if (avatarPath != path) {
|
||||||
|
avatarPath = path;
|
||||||
|
changed(8);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Models::Participant::setAvatarState(Shared::Avatar p_state) {
|
||||||
|
if (avatarState != p_state) {
|
||||||
|
avatarState = p_state;
|
||||||
|
changed(7);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Models::Participant::setAvatarState(unsigned int p_state) {
|
||||||
|
setAvatarState(Shared::Global::fromInt<Shared::Avatar>(p_state));
|
||||||
|
}
|
||||||
|
@ -21,14 +21,8 @@
|
|||||||
|
|
||||||
Models::Presence::Presence(const QMap<QString, QVariant>& data, Item* parentItem):
|
Models::Presence::Presence(const QMap<QString, QVariant>& data, Item* parentItem):
|
||||||
AbstractParticipant(Item::presence, data, parentItem)
|
AbstractParticipant(Item::presence, data, parentItem)
|
||||||
{
|
{}
|
||||||
}
|
|
||||||
|
|
||||||
Models::Presence::~Presence()
|
Models::Presence::~Presence()
|
||||||
{
|
{}
|
||||||
}
|
|
||||||
|
|
||||||
int Models::Presence::columnCount() const
|
|
||||||
{
|
|
||||||
return 4;
|
|
||||||
}
|
|
||||||
|
@ -34,8 +34,6 @@ class Presence : public Models::AbstractParticipant
|
|||||||
public:
|
public:
|
||||||
explicit Presence(const QMap<QString, QVariant> &data, Item *parentItem = 0);
|
explicit Presence(const QMap<QString, QVariant> &data, Item *parentItem = 0);
|
||||||
~Presence();
|
~Presence();
|
||||||
|
|
||||||
int columnCount() const override;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -225,6 +225,7 @@ QVariant Models::Roster::data (const QModelIndex& index, int role) const
|
|||||||
if (s.size() > 0) {
|
if (s.size() > 0) {
|
||||||
str += "\n" + tr("Status: ") + s;
|
str += "\n" + tr("Status: ") + s;
|
||||||
}
|
}
|
||||||
|
str += "\n" + tr("Client: ") + contact->getClientNode();
|
||||||
|
|
||||||
result = str;
|
result = str;
|
||||||
}
|
}
|
||||||
@ -240,7 +241,8 @@ QVariant Models::Roster::data (const QModelIndex& index, int role) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
str += tr("Affiliation: ") + Shared::Global::getName(p->getAffiliation()) + "\n";
|
str += tr("Affiliation: ") + Shared::Global::getName(p->getAffiliation()) + "\n";
|
||||||
str += tr("Role: ") + Shared::Global::getName(p->getRole());
|
str += tr("Role: ") + Shared::Global::getName(p->getRole()) + "\n";
|
||||||
|
str += tr("Client: ") + p->getClientNode();
|
||||||
|
|
||||||
result = str;
|
result = str;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user