forked from blue/squawk
first ever received and cached client data!
This commit is contained in:
parent
037dabbe06
commit
c50cd1140e
11 changed files with 297 additions and 60 deletions
|
@ -14,12 +14,14 @@
|
|||
// You should have received a copy of the GNU General Public License
|
||||
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
#include "clientcache.h"
|
||||
|
||||
#include <QDebug>
|
||||
|
||||
Core::ClientCache::ClientCache():
|
||||
requested(),
|
||||
cache("clients")
|
||||
cache("clients"),
|
||||
specific()
|
||||
{
|
||||
cache.open();
|
||||
}
|
||||
|
@ -39,9 +41,9 @@ bool Core::ClientCache::checkClient(const QString& node, const QString& ver, con
|
|||
QString id = node + "/" + ver;
|
||||
if (requested.count(id) == 0 && !cache.checkRecord(id)) {
|
||||
Shared::ClientInfo& info = requested.insert(std::make_pair(id, Shared::ClientInfo())).first->second;
|
||||
info.capabilitiesNode = node;
|
||||
info.capabilitiesVerification = ver;
|
||||
info.capabilitiesHash = hash;
|
||||
info.node = node;
|
||||
info.verification = ver;
|
||||
info.hash = hash;
|
||||
emit requestClientInfo(id);
|
||||
return false;
|
||||
}
|
||||
|
@ -49,7 +51,28 @@ bool Core::ClientCache::checkClient(const QString& node, const QString& ver, con
|
|||
return true;
|
||||
}
|
||||
|
||||
bool Core::ClientCache::registerClientInfo (
|
||||
const QString& sourceFullJid,
|
||||
const QString& id,
|
||||
const std::set<Shared::Identity>& identities,
|
||||
const std::set<QString>& features)
|
||||
{
|
||||
std::map<QString, Shared::ClientInfo>::iterator itr = requested.find(id);
|
||||
if (itr != requested.end()) {
|
||||
Shared::ClientInfo& info = itr->second;
|
||||
info.identities = identities;
|
||||
info.extensions = features;
|
||||
|
||||
bool Core::ClientCache::registerClientInfo(const QString& sourceFullJid, const QString& id, const Shared::Identity& identity, const std::set<QString>& features) {
|
||||
|
||||
bool valid = info.valid();
|
||||
if (valid) {
|
||||
cache.addRecord(id, info);
|
||||
} else {
|
||||
info.specificPresence = sourceFullJid;
|
||||
specific.insert(std::make_pair(sourceFullJid, info));
|
||||
}
|
||||
requested.erase(id);
|
||||
return valid;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -43,11 +43,12 @@ signals:
|
|||
|
||||
public slots:
|
||||
bool checkClient(const QString& node, const QString& ver, const QString& hash);
|
||||
bool registerClientInfo(const QString& sourceFullJid, const QString& id, const Shared::Identity& identity, 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:
|
||||
std::map<QString, Shared::ClientInfo> requested;
|
||||
Cache<Shared::ClientInfo> cache;
|
||||
std::map<QString, Shared::ClientInfo> specific;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue