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
19 changed files with 407 additions and 317 deletions
|
@ -360,9 +360,13 @@ void Core::Account::onPresenceReceived(const QXmppPresence& p_presence) {
|
|||
{"lastActivity", lastInteraction},
|
||||
{"availability", p_presence.availableStatusType()}, //TODO check and handle invisible
|
||||
{"status", p_presence.statusText()},
|
||||
{"capabilityNode", p_presence.capabilityNode()},
|
||||
{"capabilityVer", p_presence.capabilityVer().toBase64()},
|
||||
{"capabilityHash", p_presence.capabilityHash()}
|
||||
{"client", QVariant::fromValue(
|
||||
Shared::ClientId(
|
||||
p_presence.capabilityNode(),
|
||||
p_presence.capabilityVer().toBase64(),
|
||||
p_presence.capabilityHash())
|
||||
)
|
||||
}
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#include <shared/shared.h>
|
||||
#include <shared/identity.h>
|
||||
#include <shared/info.h>
|
||||
#include <shared/clientid.h>
|
||||
#include "contact.h"
|
||||
#include "conference.h"
|
||||
#include <core/components/networkaccess.h>
|
||||
|
|
|
@ -37,14 +37,10 @@ void Core::ClientCache::open() {
|
|||
void Core::ClientCache::close() {
|
||||
db.close();}
|
||||
|
||||
|
||||
bool Core::ClientCache::checkClient(const QString& node, const QString& ver, const QString& hash) {
|
||||
QString id = node + "/" + ver;
|
||||
bool Core::ClientCache::checkClient(const Shared::ClientId& p_id) {
|
||||
QString id = p_id.getId();
|
||||
if (requested.count(id) == 0 && !cache->checkRecord(id)) {
|
||||
Shared::ClientInfo& info = requested.insert(std::make_pair(id, Shared::ClientInfo())).first->second;
|
||||
info.id.node = node;
|
||||
info.id.verification = ver;
|
||||
info.id.hash = hash;
|
||||
requested.emplace(id, p_id);
|
||||
emit requestClientInfo(id);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
|
||||
#include <cache.h>
|
||||
|
||||
#include <shared/clientid.h>
|
||||
#include <shared/clientinfo.h>
|
||||
#include <shared/identity.h>
|
||||
|
||||
|
@ -43,7 +44,7 @@ signals:
|
|||
void requestClientInfo(const QString& id);
|
||||
|
||||
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);
|
||||
|
||||
private:
|
||||
|
|
|
@ -157,7 +157,14 @@ void Core::Conference::onRoomParticipantAdded(const QString& p_name)
|
|||
{"availability", pres.availableStatusType()},
|
||||
{"status", pres.statusText()},
|
||||
{"affiliation", mi.affiliation()},
|
||||
{"role", mi.role()}
|
||||
{"role", mi.role()},
|
||||
{"client", QVariant::fromValue(
|
||||
Shared::ClientId(
|
||||
pres.capabilityNode(),
|
||||
pres.capabilityVer().toBase64(),
|
||||
pres.capabilityHash())
|
||||
)
|
||||
}
|
||||
};
|
||||
|
||||
if (hasAvatar) {
|
||||
|
@ -218,7 +225,14 @@ void Core::Conference::onRoomParticipantChanged(const QString& p_name)
|
|||
{"availability", pres.availableStatusType()},
|
||||
{"status", pres.statusText()},
|
||||
{"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 "rosteritem.h"
|
||||
#include "shared/global.h"
|
||||
#include <shared/global.h>
|
||||
#include <shared/clientid.h>
|
||||
|
||||
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) {
|
||||
case QXmpp::TrustLevel::Undecided: return Shared::TrustLevel::undecided;
|
||||
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::ManuallyTrusted: return Shared::TrustLevel::manuallyTrusted;
|
||||
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) {
|
||||
case Shared::TrustLevel::undecided: return QXmpp::TrustLevel::Undecided;
|
||||
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::manuallyTrusted: return QXmpp::TrustLevel::ManuallyTrusted;
|
||||
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
|
||||
}
|
||||
}
|
||||
|
|
232
core/squawk.cpp
232
core/squawk.cpp
|
@ -50,8 +50,7 @@ Core::Squawk::Squawk(QObject* parent):
|
|||
#endif
|
||||
}
|
||||
|
||||
Core::Squawk::~Squawk()
|
||||
{
|
||||
Core::Squawk::~Squawk() {
|
||||
Accounts::const_iterator itr = accounts.begin();
|
||||
Accounts::const_iterator end = accounts.end();
|
||||
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;
|
||||
}
|
||||
|
||||
void Core::Squawk::stop()
|
||||
{
|
||||
void Core::Squawk::stop() {
|
||||
qDebug("Stopping squawk core..");
|
||||
network.stop();
|
||||
clientCache.close();
|
||||
|
@ -110,8 +107,7 @@ void Core::Squawk::stop()
|
|||
emit quit();
|
||||
}
|
||||
|
||||
void Core::Squawk::start()
|
||||
{
|
||||
void Core::Squawk::start() {
|
||||
qDebug("Starting squawk core..");
|
||||
|
||||
readSettings();
|
||||
|
@ -120,8 +116,7 @@ void Core::Squawk::start()
|
|||
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 login = map.value("login").toString();
|
||||
QString server = map.value("server").toString();
|
||||
|
@ -205,31 +200,28 @@ void Core::Squawk::addAccount(
|
|||
switch (passwordType) {
|
||||
case Shared::AccountPassword::alwaysAsk:
|
||||
case Shared::AccountPassword::kwallet:
|
||||
if (password == "") {
|
||||
if (password == "")
|
||||
acc->invalidatePassword();
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (state != Shared::Availability::offline) {
|
||||
acc->setAvailability(state);
|
||||
if (acc->getActive()) {
|
||||
if (acc->getActive())
|
||||
acc->connect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Core::Squawk::changeState(Shared::Availability p_state)
|
||||
{
|
||||
void Core::Squawk::changeState(Shared::Availability p_state) {
|
||||
if (state != p_state) {
|
||||
for (std::deque<Account*>::iterator itr = accounts.begin(), end = accounts.end(); itr != end; ++itr) {
|
||||
Account* acc = *itr;
|
||||
acc->setAvailability(p_state);
|
||||
if (state == Shared::Availability::offline && acc->getActive()) {
|
||||
if (state == Shared::Availability::offline && acc->getActive())
|
||||
acc->connect();
|
||||
}
|
||||
}
|
||||
state = p_state;
|
||||
|
||||
|
@ -237,21 +229,18 @@ void Core::Squawk::changeState(Shared::Availability p_state)
|
|||
}
|
||||
}
|
||||
|
||||
void Core::Squawk::connectAccount(const QString& account)
|
||||
{
|
||||
void Core::Squawk::connectAccount(const QString& account) {
|
||||
AccountsMap::const_iterator itr = amap.find(account);
|
||||
if (itr == amap.end()) {
|
||||
qDebug("An attempt to connect non existing account, skipping");
|
||||
return;
|
||||
}
|
||||
itr->second->setActive(true);
|
||||
if (state != Shared::Availability::offline) {
|
||||
if (state != Shared::Availability::offline)
|
||||
itr->second->connect();
|
||||
}
|
||||
}
|
||||
|
||||
void Core::Squawk::disconnectAccount(const QString& account)
|
||||
{
|
||||
void Core::Squawk::disconnectAccount(const QString& account) {
|
||||
AccountsMap::const_iterator itr = amap.find(account);
|
||||
if (itr == amap.end()) {
|
||||
qDebug("An attempt to connect non existing account, skipping");
|
||||
|
@ -262,15 +251,14 @@ void Core::Squawk::disconnectAccount(const QString& account)
|
|||
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());
|
||||
QMap<QString, QVariant> changes = {
|
||||
{"state", QVariant::fromValue(p_state)}
|
||||
};
|
||||
if (acc->getLastError() == Account::Error::none) {
|
||||
if (acc->getLastError() == Account::Error::none)
|
||||
changes.insert("error", "");
|
||||
}
|
||||
|
||||
emit changeAccount(acc->getName(), changes);
|
||||
|
||||
#ifdef WITH_KWALLET
|
||||
|
@ -282,55 +270,48 @@ void Core::Squawk::onAccountConnectionStateChanged(Shared::ConnectionState p_sta
|
|||
#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());
|
||||
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());
|
||||
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());
|
||||
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());
|
||||
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());
|
||||
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());
|
||||
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());
|
||||
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
|
||||
if (jid != name) {
|
||||
QString node = data["capabilityNode"].toString();
|
||||
QString ver = data["capabilityVer"].toString();
|
||||
QString hash = data["capabilityHash"].toString();
|
||||
if (!clientCache.checkClient(node, ver, hash)) {
|
||||
acc->discoverInfo(jid + "/" + name, node + "/" + ver);
|
||||
}
|
||||
const Shared::ClientId& id = data["client"].value<Shared::ClientId>();
|
||||
if (!id.valid())
|
||||
return;
|
||||
|
||||
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());
|
||||
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());
|
||||
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());
|
||||
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());
|
||||
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);
|
||||
if (itr == amap.end()) {
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
if (itr == amap.end()) {
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
if (itr == amap.end()) {
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
if (itr == amap.end()) {
|
||||
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);
|
||||
}
|
||||
|
||||
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());
|
||||
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);
|
||||
if (itr == amap.end()) {
|
||||
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");
|
||||
if (mItr != map.end()) {
|
||||
if (mItr != map.end())
|
||||
acc->setLogin(mItr->toString());
|
||||
}
|
||||
|
||||
mItr = map.find("password");
|
||||
if (mItr != map.end()) {
|
||||
if (mItr != map.end())
|
||||
acc->setPassword(mItr->toString());
|
||||
}
|
||||
|
||||
mItr = map.find("resource");
|
||||
if (mItr != map.end()) {
|
||||
if (mItr != map.end())
|
||||
acc->setResource(mItr->toString());
|
||||
}
|
||||
|
||||
mItr = map.find("server");
|
||||
if (mItr != map.end()) {
|
||||
if (mItr != map.end())
|
||||
acc->setServer(mItr->toString());
|
||||
}
|
||||
|
||||
mItr = map.find("passwordType");
|
||||
if (mItr != map.end()) {
|
||||
if (mItr != map.end())
|
||||
acc->setPasswordType(Shared::Global::fromInt<Shared::AccountPassword>(mItr->toInt()));
|
||||
}
|
||||
|
||||
#ifdef WITH_KWALLET
|
||||
if (acc->getPasswordType() == Shared::AccountPassword::kwallet
|
||||
|
@ -505,28 +471,24 @@ void Core::Squawk::modifyAccountRequest(const QString& name, const QMap<QString,
|
|||
#endif
|
||||
|
||||
if (state != Shared::Availability::offline) {
|
||||
if (activeChanged && acc->getActive()) {
|
||||
if (activeChanged && acc->getActive())
|
||||
acc->connect();
|
||||
} else if (!wentReconnecting && acc->getActive() && acc->getLastError() == Account::Error::authentication) {
|
||||
else if (!wentReconnecting && acc->getActive() && acc->getLastError() == Account::Error::authentication)
|
||||
acc->connect();
|
||||
}
|
||||
}
|
||||
|
||||
emit changeAccount(name, map);
|
||||
}
|
||||
|
||||
void Core::Squawk::onAccountError(const QString& text)
|
||||
{
|
||||
void Core::Squawk::onAccountError(const QString& text) {
|
||||
Account* acc = static_cast<Account*>(sender());
|
||||
emit changeAccount(acc->getName(), {{"error", text}});
|
||||
|
||||
if (acc->getLastError() == Account::Error::authentication) {
|
||||
if (acc->getLastError() == Account::Error::authentication)
|
||||
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);
|
||||
if (itr == amap.end()) {
|
||||
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;
|
||||
if (acc->getState() != Shared::ConnectionState::disconnected) {
|
||||
if (acc->getState() != Shared::ConnectionState::disconnected)
|
||||
acc->disconnect();
|
||||
}
|
||||
|
||||
for (Accounts::const_iterator aItr = accounts.begin(); aItr != accounts.end(); ++aItr) {
|
||||
if (*aItr == acc) {
|
||||
|
@ -556,8 +517,7 @@ void Core::Squawk::removeAccountRequest(const QString& name)
|
|||
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);
|
||||
if (itr == amap.end()) {
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
if (itr == amap.end()) {
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
if (itr == amap.end()) {
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
if (itr == amap.end()) {
|
||||
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);
|
||||
}
|
||||
|
||||
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());
|
||||
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());
|
||||
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());
|
||||
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);
|
||||
if (itr == amap.end()) {
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
if (itr == amap.end()) {
|
||||
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);
|
||||
}
|
||||
|
||||
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());
|
||||
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());
|
||||
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());
|
||||
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());
|
||||
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);
|
||||
if (itr == amap.end()) {
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
if (itr == amap.end()) {
|
||||
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);
|
||||
}
|
||||
|
||||
void Core::Squawk::fileDownloadRequest(const QString& url)
|
||||
{
|
||||
void Core::Squawk::fileDownloadRequest(const QString& 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);
|
||||
if (itr == amap.end()) {
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
if (itr == amap.end()) {
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
if (itr == amap.end()) {
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
if (itr == amap.end()) {
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
if (itr == amap.end()) {
|
||||
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);
|
||||
}
|
||||
|
||||
void Core::Squawk::readSettings()
|
||||
{
|
||||
void Core::Squawk::readSettings() {
|
||||
QSettings settings;
|
||||
settings.beginGroup("core");
|
||||
int size = settings.beginReadArray("accounts");
|
||||
|
@ -772,8 +711,7 @@ void Core::Squawk::readSettings()
|
|||
emit ready();
|
||||
}
|
||||
|
||||
void Core::Squawk::onAccountNeedPassword()
|
||||
{
|
||||
void Core::Squawk::onAccountNeedPassword() {
|
||||
Account* acc = static_cast<Account*>(sender());
|
||||
switch (acc->getPasswordType()) {
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
if (itr == amap.end()) {
|
||||
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;
|
||||
acc->setPassword(password);
|
||||
emit changeAccount(account, {{"password", password}});
|
||||
if (state != Shared::Availability::offline && acc->getActive()) {
|
||||
if (state != Shared::Availability::offline && acc->getActive())
|
||||
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());
|
||||
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);
|
||||
|
||||
QMap<QString, QVariant> data({
|
||||
{"attachPath", ""}
|
||||
});
|
||||
QMap<QString, QVariant> data({{"attachPath", ""}});
|
||||
for (const Shared::MessageInfo& info : list) {
|
||||
AccountsMap::const_iterator itr = amap.find(info.account);
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue