1
0
Fork 0
forked from blue/squawk

some new shared classes, little reorganization, preparation to cache client info

This commit is contained in:
Blue 2022-08-22 23:29:43 +03:00
parent 2ae75a4b91
commit 037dabbe06
Signed by untrusted user: blue
GPG key ID: 9B203B252A63EE38
20 changed files with 297 additions and 32 deletions

View file

@ -28,9 +28,10 @@ Core::Squawk::Squawk(QObject* parent):
amap(),
state(Shared::Availability::offline),
network(),
isInitialized(false)
isInitialized(false),
clientCache(),
#ifdef WITH_KWALLET
,kwallet()
kwallet()
#endif
{
connect(&network, &NetworkAccess::loadFileProgress, this, &Squawk::fileProgress);
@ -67,6 +68,7 @@ void Core::Squawk::stop()
{
qDebug("Stopping squawk core..");
network.stop();
clientCache.close();
if (isInitialized) {
QSettings settings;
@ -115,6 +117,7 @@ void Core::Squawk::start()
readSettings();
isInitialized = true;
network.start();
clientCache.open();
}
void Core::Squawk::newAccountRequest(const QMap<QString, QVariant>& map)
@ -180,6 +183,8 @@ void Core::Squawk::addAccount(
connect(acc, &Account::receivedVCard, this, &Squawk::responseVCard);
connect(acc, &Account::uploadFileError, this, &Squawk::onAccountUploadFileError);
connect(acc, &Account::infoDiscovered, this, &Squawk::onAccountInfoDiscovered);
QMap<QString, QVariant> map = {
{"login", login},
@ -314,6 +319,27 @@ void Core::Squawk::onAccountAddPresence(const QString& jid, const QString& name,
{
Account* acc = static_cast<Account*>(sender());
emit addPresence(acc->getName(), jid, name, data);
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);
}
}
void Core::Squawk::onAccountInfoDiscovered(
const QString& address,
const QString& node,
const std::list<Shared::Identity>& identities,
const std::set<QString>& features)
{
Account* acc = static_cast<Account*>(sender());
if (identities.size() != 1 || clientCache.registerClientInfo(address, node, identities.back(), features)) {
qDebug() << "Account" << acc->getName() << "received an ill-formed client discovery response from" << address << "about" << node;
return;
}
}
void Core::Squawk::onAccountRemovePresence(const QString& jid, const QString& name)