1
0
Fork 0
forked from blue/squawk

work progress: trust manager. DOESN'T START!

This commit is contained in:
Blue 2022-12-19 18:43:24 +03:00
parent 0b61b6e928
commit db3bc358a7
Signed by untrusted user: blue
GPG key ID: 9B203B252A63EE38
20 changed files with 634 additions and 55 deletions

View file

@ -19,27 +19,28 @@
#include <QDebug>
Core::ClientCache::ClientCache():
db("clients"),
cache(db.addCache<QString, Shared::ClientInfo>("info")),
requested(),
cache("clients"),
specific()
{
cache.open();
db.open();
}
Core::ClientCache::~ClientCache() {
cache.close();
db.close();
}
void Core::ClientCache::open() {
cache.open();}
db.open();}
void Core::ClientCache::close() {
cache.close();}
db.close();}
bool Core::ClientCache::checkClient(const QString& node, const QString& ver, const QString& hash) {
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;
info.node = node;
info.verification = ver;
@ -65,7 +66,7 @@ bool Core::ClientCache::registerClientInfo (
bool valid = info.valid();
if (valid) {
cache.addRecord(id, info);
cache->addRecord(id, info);
} else {
info.specificPresence = sourceFullJid;
specific.insert(std::make_pair(sourceFullJid, info));

View file

@ -23,7 +23,8 @@
#include <QObject>
#include <QString>
#include <core/storage/cache.h>
#include <cache.h>
#include <shared/clientinfo.h>
#include <shared/identity.h>
@ -46,8 +47,9 @@ public slots:
bool registerClientInfo(const QString& sourceFullJid, const QString& id, const std::set<Shared::Identity>& identities, const std::set<QString>& features);
private:
DataBase db;
DataBase::Cache<QString, Shared::ClientInfo>* cache;
std::map<QString, Shared::ClientInfo> requested;
Cache<QString, Shared::ClientInfo> cache;
std::map<QString, Shared::ClientInfo> specific;
};