summaryrefslogtreecommitdiff
path: root/protocols/FacebookRM/src
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2014-04-04 14:27:34 +0000
committerRobert Pösel <robyer@seznam.cz>2014-04-04 14:27:34 +0000
commit5d05c51db250c3d4cd37dbd802fc044890e32412 (patch)
treedb22461c219ddc5f671574fb943c9979b4587497 /protocols/FacebookRM/src
parentfe3eb8ad9dfaee5e45ca306534f011c4e96aa31d (diff)
Facebook: Fix size of downloaded avatars (use 50x50 for smaller and 180x180 for bigger)
git-svn-id: http://svn.miranda-ng.org/main/trunk@8852 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM/src')
-rw-r--r--protocols/FacebookRM/src/avatars.cpp36
1 files changed, 25 insertions, 11 deletions
diff --git a/protocols/FacebookRM/src/avatars.cpp b/protocols/FacebookRM/src/avatars.cpp
index 358018219a..f02a4a2e52 100644
--- a/protocols/FacebookRM/src/avatars.cpp
+++ b/protocols/FacebookRM/src/avatars.cpp
@@ -55,18 +55,32 @@ void FacebookProto::CheckAvatarChange(MCONTACT hContact, std::string image_url)
return;
bool big_avatars = getBool(FACEBOOK_KEY_BIG_AVATARS, DEFAULT_BIG_AVATARS);
-
- // We've got url to avatar of default size 32x32px, let's change it to slightly bigger (50x50px) - looks like maximum size for square format
- std::tstring::size_type pos = image_url.rfind("/s32x32/");
- if (pos != std::wstring::npos)
- image_url = image_url.replace(pos, 8, big_avatars ? "/s200x200/" : "/s50x50/");
-
- if (big_avatars)
- {
- pos = image_url.rfind("_q.");
- if (pos != std::wstring::npos)
- image_url = image_url.replace(pos, 3, "_s.");
+
+ // We've got url to avatar of default size 32x32px, let's change it to bigger one
+ std::tstring::size_type pos, pos2;
+
+ // Remove cropping and use bigger size
+ pos = image_url.find("/t1.0-1/");
+ if (pos != std::tstring::npos) {
+ pos += 8;
+
+ 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, big_avatars ? "p180x180" : "p50x50");
}
+
+ // Allow big images
+ pos = image_url.rfind("_s.");
+ if (pos == std::tstring::npos)
+ pos = image_url.rfind("_t.");
+
+ if (pos != std::tstring::npos)
+ image_url = image_url.replace(pos, 3, "_q.");
DBVARIANT dbv;
bool update_required = true;