From 887abb55d8fe93f158ce21eb1ecce4375ddabccb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20P=C3=B6sel?= Date: Wed, 19 Mar 2014 00:12:54 +0000 Subject: Facebook: Implemented function to manually refresh contact info; version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@8656 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/FacebookRM/src/json.cpp | 7 +++++++ protocols/FacebookRM/src/proto.cpp | 28 ++++++++++++++++++++++++++++ protocols/FacebookRM/src/stubs.cpp | 6 ------ protocols/FacebookRM/src/version.h | 2 +- 4 files changed, 36 insertions(+), 7 deletions(-) (limited to 'protocols/FacebookRM/src') diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp index ee2c9abbab..34b23a1fc9 100644 --- a/protocols/FacebookRM/src/json.cpp +++ b/protocols/FacebookRM/src/json.cpp @@ -165,6 +165,12 @@ void parseUser(JSONNODE *it, facebook_user *fbu) { fbu->user_id = json_name(it); + JSONNODE *id = json_get(it, "id"); + if (id == NULL || json_as_pstring(id) == "0" || json_as_pstring(id).empty()) { + // this user has deleted account or is just unavailable for us (e.g., ignore list) -> don't read dummy name and avatar and rather ignore that completely + return; + } + JSONNODE *name = json_get(it, "name"); JSONNODE *thumbSrc = json_get(it, "thumbSrc"); JSONNODE *gender = json_get(it, "gender"); @@ -187,6 +193,7 @@ void parseUser(JSONNODE *it, facebook_user *fbu) case 2: // male fbu->gender = 77; break; + // case 7: not available female? } } diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp index 7ec20b4790..1627cecb13 100644 --- a/protocols/FacebookRM/src/proto.cpp +++ b/protocols/FacebookRM/src/proto.cpp @@ -311,6 +311,34 @@ int FacebookProto::AuthDeny(HANDLE hDbEvent, const PROTOCHAR *reason) return 0; } +int FacebookProto::GetInfo(MCONTACT hContact, int infoType) +{ + facebook_user fbu; + fbu.user_id = ptrA(getStringA(hContact, FACEBOOK_KEY_ID)); + + if (fbu.user_id.empty()) + return 1; + + LoadContactInfo(&fbu); + + // TODO: don't duplicate code this way, refactor all this userInfo loading + + std::string homepage = FACEBOOK_URL_PROFILE + fbu.user_id; + setString(hContact, "Homepage", homepage.c_str()); + + if (!fbu.real_name.empty()) { + SaveName(hContact, &fbu); + } + + if (fbu.gender) + setByte(hContact, "Gender", fbu.gender); + + if (!fbu.image_url.empty()) + setString(hContact, FACEBOOK_KEY_AV_URL, fbu.image_url.c_str()); + + return 1; +} + ////////////////////////////////////////////////////////////////////////////// // SERVICES diff --git a/protocols/FacebookRM/src/stubs.cpp b/protocols/FacebookRM/src/stubs.cpp index 47553993e6..e53960636f 100644 --- a/protocols/FacebookRM/src/stubs.cpp +++ b/protocols/FacebookRM/src/stubs.cpp @@ -52,12 +52,6 @@ int FacebookProto::FileResume(HANDLE hTransfer,int *action,const PROTOCHAR **fil return 1; } -int FacebookProto::GetInfo(MCONTACT hContact, int infoType) -{ - // TODO: Most probably some ProtoAck should be here instead - return 1; -} - HWND FacebookProto::SearchAdvanced(HWND owner) { return NULL; diff --git a/protocols/FacebookRM/src/version.h b/protocols/FacebookRM/src/version.h index 96e0535f12..b1525a0be3 100644 --- a/protocols/FacebookRM/src/version.h +++ b/protocols/FacebookRM/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0 #define __MINOR_VERSION 2 #define __RELEASE_NUM 3 -#define __BUILD_NUM 1 +#define __BUILD_NUM 2 #include -- cgit v1.2.3