summaryrefslogtreecommitdiff
path: root/protocols/FacebookRM
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2014-08-06 12:36:26 +0000
committerRobert Pösel <robyer@seznam.cz>2014-08-06 12:36:26 +0000
commit586cfe1dc5e8ca0aad7c958f311d2a501f10e54f (patch)
tree3b35dbcf3acdebd6bbe99e48d97f0b7507e4e34a /protocols/FacebookRM
parentb2b39f287691a6e12530fde185ba008397d77d90 (diff)
Facebook: Fixed downloading bigger sizes of avatars (thanks Vojtěch Kinkor)
git-svn-id: http://svn.miranda-ng.org/main/trunk@10089 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM')
-rw-r--r--protocols/FacebookRM/src/avatars.cpp58
1 files changed, 31 insertions, 27 deletions
diff --git a/protocols/FacebookRM/src/avatars.cpp b/protocols/FacebookRM/src/avatars.cpp
index ea247fac1f..fbbada49e4 100644
--- a/protocols/FacebookRM/src/avatars.cpp
+++ b/protocols/FacebookRM/src/avatars.cpp
@@ -38,7 +38,7 @@ bool FacebookProto::GetDbAvatarInfo(PROTO_AVATAR_INFORMATIONT &ai, std::string *
if (!getTString(ai.hContact, FACEBOOK_KEY_ID, &dbv)) {
std::string ext = new_url.substr(new_url.rfind('.'), 4);
std::tstring filename = GetAvatarFolder() + L'\\' + dbv.ptszVal + (TCHAR*)_A2T(ext.c_str());
- db_free(&dbv);
+ db_free(&dbv);
_tcsncpy_s(ai.filename, filename.c_str(), _TRUNCATE);
ai.format = ProtoGetAvatarFormat(ai.filename);
@@ -53,35 +53,39 @@ void FacebookProto::CheckAvatarChange(MCONTACT hContact, std::string image_url)
// Facebook contacts always have some avatar - keep avatar in database even if we have loaded empty one (e.g. for 'On Mobile' contacts)
if (image_url.empty())
return;
-
+
+ // First remove all eventual parameters
+ std::tstring::size_type pos = image_url.find("?");
+ if (pos != std::tstring::npos)
+ image_url = image_url.substr(0, pos);
+
+ utils::text::replace_first(&image_url, "/v/", "/");
+
// We've got url to avatar of default size 32x32px, let's change it to bigger one
- if (image_url.find("oh=") == std::tstring::npos) {
- // We can change avatar size only when there are no parameters (hashes) in URL
- if (getBool(FACEBOOK_KEY_BIG_AVATARS, DEFAULT_BIG_AVATARS)) {
- // Remove cropping and use bigger size
- std::tstring::size_type pos = image_url.find("/t1.0-1/");
- if (pos != std::tstring::npos) {
- pos += 8;
-
- std::tstring::size_type pos2 = image_url.find("/", pos);
- if (pos2 != std::tstring::npos && image_url.find("/", pos2 + 1) != std::tstring::npos)
- pos2 = image_url.find("/", pos2 + 1);
-
- // TODO: crop it somehow to square image
-
- if (pos2 != std::tstring::npos)
- image_url.replace(pos, pos2 - pos, "p180x180");
-
- // Allow big images
- if ((pos = image_url.rfind("_s.")) != std::tstring::npos || (pos = image_url.rfind("_t.")) != std::tstring::npos) {
- image_url = image_url.replace(pos, 3, "_q.");
- }
+ if (getBool(FACEBOOK_KEY_BIG_AVATARS, DEFAULT_BIG_AVATARS)) {
+ // Remove cropping and use bigger size
+ pos = image_url.find("/t1.0-1/");
+ if (pos != std::tstring::npos) {
+ pos += 8;
+
+ std::tstring::size_type pos2 = image_url.find("/", pos);
+ if (pos2 != std::tstring::npos && image_url.find("/", pos2 + 1) != std::tstring::npos)
+ pos2 = image_url.find("/", pos2 + 1);
+
+ // TODO: crop it somehow to square image
+
+ if (pos2 != std::tstring::npos)
+ image_url.replace(pos, pos2 - pos, "p180x180");
+
+ // Allow big images
+ if ((pos = image_url.rfind("_s.")) != std::tstring::npos || (pos = image_url.rfind("_t.")) != std::tstring::npos) {
+ image_url = image_url.replace(pos, 3, "_q.");
}
- } else {
- // Try to get slighly bigger (but still square) image
- utils::text::replace_first(&image_url, ".32.32/", ".50.50/");
- utils::text::replace_first(&image_url, "32x32/", "50x50/");
}
+ } else {
+ // Try to get slighly bigger (but still square) image
+ utils::text::replace_first(&image_url, ".32.32/", ".50.50/");
+ utils::text::replace_first(&image_url, "32x32/", "50x50/");
}
// Check for avatar change