(jabber) Throttle own VCard updates; move avatar-cache to /tmp/
This commit is contained in:
parent
150fd736e1
commit
8cca8a324e
|
@ -61,7 +61,8 @@ JabberHandler::JabberHandler()
|
||||||
:
|
:
|
||||||
fClient(NULL),
|
fClient(NULL),
|
||||||
fVCardManager(NULL),
|
fVCardManager(NULL),
|
||||||
fSession(NULL)
|
fSession(NULL),
|
||||||
|
fLastOwnVCard(0)
|
||||||
{
|
{
|
||||||
fAvatars = new BList();
|
fAvatars = new BList();
|
||||||
}
|
}
|
||||||
|
@ -1021,10 +1022,9 @@ JabberHandler::_SetupAvatarCache()
|
||||||
|
|
||||||
BPath path;
|
BPath path;
|
||||||
|
|
||||||
if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK)
|
if (find_directory(B_SYSTEM_TEMP_DIRECTORY, &path) != B_OK)
|
||||||
return B_ERROR;
|
return B_ERROR;
|
||||||
|
|
||||||
path.Append("Cardie/Cache/Accounts");
|
|
||||||
path.Append(GetName());
|
path.Append(GetName());
|
||||||
|
|
||||||
if (create_directory(path.Path(), 0755) != B_OK)
|
if (create_directory(path.Path(), 0755) != B_OK)
|
||||||
|
@ -1928,6 +1928,14 @@ JabberHandler::handleVCard(const gloox::JID& jid, const gloox::VCard* card)
|
||||||
if (!card)
|
if (!card)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
// Throttles updates to your own VCard― ime some servers spam for no reason
|
||||||
|
if (jid.bare() == fJid.bare()) {
|
||||||
|
bigtime_t last = fLastOwnVCard;
|
||||||
|
fLastOwnVCard = time(NULL);
|
||||||
|
if (fLastOwnVCard - last < 60)
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
gloox::VCard::Name name = card->name();
|
gloox::VCard::Name name = card->name();
|
||||||
gloox::VCard::Photo photo = card->photo();
|
gloox::VCard::Photo photo = card->photo();
|
||||||
BString nick(card->nickname().c_str());
|
BString nick(card->nickname().c_str());
|
||||||
|
|
|
@ -126,6 +126,7 @@ private:
|
||||||
BPath fAvatarCachePath;
|
BPath fAvatarCachePath;
|
||||||
BMessage fAvatarCache;
|
BMessage fAvatarCache;
|
||||||
BList* fAvatars;
|
BList* fAvatars;
|
||||||
|
bigtime_t fLastOwnVCard; // Last time VCard updated
|
||||||
|
|
||||||
void _SendMessage(BMessage* msg);
|
void _SendMessage(BMessage* msg);
|
||||||
void _MessageSent(const char* id, const char* subject,
|
void _MessageSent(const char* id, const char* subject,
|
||||||
|
|
Ŝarĝante…
Reference in New Issue