Skip to content

Commit

Permalink
Current version of Psi+ is 1.5.1943
Browse files Browse the repository at this point in the history
It is based on:
* psi: afa459a0
* plugins: 7a65467
* psimedia: 478567e
* resources: e32ef4b
  • Loading branch information
tehnick committed Jun 4, 2024
1 parent 9784cd1 commit 523dcd7
Show file tree
Hide file tree
Showing 6 changed files with 46 additions and 22 deletions.
28 changes: 16 additions & 12 deletions src/avatars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,20 +176,20 @@ class AvatarCache : public FileCache {
qWarning("avatars.cpp: Unexpected item payload");
}
} else if (n == PEP_AVATAR_METADATA_NS) {
auto id = item.id().toLatin1();
if (id == "current") {
return; // probably was in previous versions of xep
}
QByteArray hash = QByteArray::fromHex(id);
if (hash.size() < 20) {
// qDebug() << "not sha1";
return; // doesn't look like sha1 hash. just ignore it
}

if (item.payload().tagName() == QLatin1String(PEP_AVATAR_METADATA_TN)
&& item.payload().firstChildElement().isNull()) {
result = AvatarCache::instance()->removeIcon(AvatarCache::AvatarType, jidFull);
} else {
auto id = item.id().toLatin1();
if (id == "current") {
return; // probably was in previous versions of xep
}
QByteArray hash = QByteArray::fromHex(id);
if (hash.size() < 20) {
// qDebug() << "not sha1";
return; // doesn't look like sha1 hash. just ignore it
}

VCardFactory::instance()->ensureVCardUpdated(pa, jid, VCardFactory::InterestPhoto, hash);

for (QDomElement e = item.payload().firstChildElement(QLatin1String("info")); !e.isNull();
Expand Down Expand Up @@ -693,6 +693,7 @@ class AvatarCache : public FileCache {
jids.append(typedJid(iconType, jid));
md.insert(QLatin1String("jids"), jids);
item->setMetadata(md);
lazySync();
}

if (prevIcon) {
Expand Down Expand Up @@ -723,6 +724,7 @@ class AvatarCache : public FileCache {
} else {
md.insert(QLatin1String("jids"), jids);
item->setMetadata(md);
lazySync();
}
}

Expand Down Expand Up @@ -804,6 +806,7 @@ class AvatarCache : public FileCache {
if (jidsChanged) {
md.insert(QLatin1String("jids"), jids);
it.value()->setMetadata(md);
lazySync();
}
}
}
Expand Down Expand Up @@ -932,7 +935,7 @@ void AvatarFactory::setSelfAvatar(const QString &fileName)
account()->pepManager()->publish(PEP_AVATAR_DATA_NS, PubSubItem(id, el));
}
} else {
account()->pepManager()->disable(PEP_AVATAR_METADATA_TN, PEP_AVATAR_METADATA_NS, "current");
account()->pepManager()->disable(PEP_AVATAR_METADATA_TN, PEP_AVATAR_METADATA_NS, {});
}
}

Expand All @@ -959,8 +962,9 @@ void AvatarFactory::statusUpdate(const Jid &jid, const XMPP::Status &status, Fla
void AvatarFactory::ensureVCardUpdated(const Jid &jid, const QByteArray &hash, Flags flags)
{
if (!AvatarCache::instance()->ensureVCardUpdated(jid, hash, flags)) {
VCardFactory::instance()->ensureVCardUpdated(d->pa_, jid, flags2AvatarFlags(flags), hash);
// must request vcard
}
VCardFactory::instance()->ensureVCardUpdated(d->pa_, jid, flags2AvatarFlags(flags), hash);
}

QString AvatarFactory::getCacheDir()
Expand Down
17 changes: 12 additions & 5 deletions src/filecache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,14 @@ bool ctimeLessThan(FileCacheItem *a, FileCacheItem *b) { return a->created() < b

void FileCache::sync() { sync(false); }

void FileCache::lazySync() { _syncTimer->start(); }

void FileCache::sync(bool finishSession)
{
if (_syncTimer->isActive()) {
_syncTimer->stop();
}

QList<FileCacheItem *> loadedItems;
QList<FileCacheItem *> onDiskItems;
qint64 sumMemorySize = 0;
Expand All @@ -333,8 +339,9 @@ void FileCache::sync(bool finishSession)
sumFileSize += item->size();
onDiskItems.append(item);
}
} else if (!item->isRegistered()) { // just put to registry item without data and stop reviewing it
toRegistry(item); // save item to registry if not yet
}
if (!item->isRegistered()) { // just put to registry item without data and stop reviewing it
toRegistry(item); // save item to registry if not yet
}
}

Expand All @@ -351,9 +358,9 @@ void FileCache::sync(bool finishSession)
}
item->unload(); // will flush data to disk if necesary
sumMemorySize -= item->size();
if (!item->isRegistered()) {
toRegistry(item); // save item to registry if not yet
}
// if (!item->isRegistered()) {
// toRegistry(item); // save item to registry if not yet
// }
}
}

Expand Down
1 change: 1 addition & 0 deletions src/filecache.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ class FileCache : public QObject {

public slots:
void sync();
void lazySync();

private:
void toRegistry(FileCacheItem *);
Expand Down
4 changes: 3 additions & 1 deletion src/pepmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,9 @@ class PEPPublishTask : public Task {
pubsub.appendChild(publish);

QDomElement item = doc()->createElement("item");
item.setAttribute("id", it.id());
if (!it.id().isEmpty()) {
item.setAttribute("id", it.id());
}
publish.appendChild(item);

if (access != PEPManager::DefaultAccess) {
Expand Down
16 changes: 13 additions & 3 deletions src/vcardfactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,17 @@ VCardFactory::QueuedLoader::QueuedLoader(VCardFactory *vcf) : QObject(vcf), q(vc
timer_.setSingleShot(false);
timer_.setInterval(VcardReqInterval);
QObject::connect(&timer_, &QTimer::timeout, this, [this]() {
if (queue_.isEmpty()) {
timer_.stop();
return;
}
auto request = queue_.takeFirst();
auto task = request->execute();
if (task) {
connect(task, &JT_VCard::finished, this, [this, request]() {
// qDebug() << "received VCardRequest" << request->jid().full();
#ifdef VCF_DEBUG
qDebug() << "received VCardRequest" << request->jid().full();
#endif
emit vcardReceived(request);
jid2req.remove(request->jid());
request->deleteLater();
Expand All @@ -350,12 +356,16 @@ VCardRequest *VCardFactory::QueuedLoader::enqueue(PsiAccount *acc, const Jid &ji
}
auto req = jid2req[sanitized_jid];
if (!req) {
// qDebug() << "new VCardRequest" << sanitized_jid.full() << flags;
#ifdef VCF_DEBUG
qDebug() << "new VCardRequest" << sanitized_jid.full() << flags;
#endif
req = new VCardRequest(acc, sanitized_jid, flags);
jid2req[sanitized_jid] = req;
queue_.append(req);
} else {
// qDebug() << "merge VCardRequest" << sanitized_jid.full() << flags;
#ifdef VCF_DEBUG
qDebug() << "merge VCardRequest" << sanitized_jid.full() << flags;
#endif
req->merge(acc, sanitized_jid, flags);
}

Expand Down
2 changes: 1 addition & 1 deletion version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.5.1942 (2024-06-04, 314403d9)
1.5.1943 (2024-06-05, afa459a0)

0 comments on commit 523dcd7

Please sign in to comment.