diff options
author | Robert Pösel <robyer@seznam.cz> | 2014-05-10 17:38:59 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2014-05-10 17:38:59 +0000 |
commit | 8762a11a5053c1a7f12d6390c4edfa86533e796f (patch) | |
tree | 0cbf0168b951d0feae49b81ffc0ccf5e3318c8d5 /protocols/FacebookRM/src/contacts.cpp | |
parent | e3c0c006f5e87f16060b09b59f24e02a3faccf44 (diff) |
Facebook: Fix loading some contact with names at first login; version bump
git-svn-id: http://svn.miranda-ng.org/main/trunk@9157 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM/src/contacts.cpp')
-rw-r--r-- | protocols/FacebookRM/src/contacts.cpp | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/protocols/FacebookRM/src/contacts.cpp b/protocols/FacebookRM/src/contacts.cpp index 241782ddca..3191289146 100644 --- a/protocols/FacebookRM/src/contacts.cpp +++ b/protocols/FacebookRM/src/contacts.cpp @@ -171,57 +171,57 @@ void FacebookProto::LoadContactInfo(facebook_user* fbu) } } -MCONTACT FacebookProto::AddToContactList(facebook_user* fbu, ContactType type, bool dont_check) +MCONTACT FacebookProto::AddToContactList(facebook_user* fbu, ContactType type, bool force_save) { MCONTACT hContact; - if (!dont_check) { - // First, check if this contact exists - hContact = ContactIDToHContact(fbu->user_id); - if(hContact) - return hContact; - } + // First, check if this contact exists + hContact = ContactIDToHContact(fbu->user_id); - // If not, make a new contact! - hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0); - if(hContact) - { - if(CallService(MS_PROTO_ADDTOCONTACT,hContact,(LPARAM)m_szModuleName) == 0) - { - setString(hContact, FACEBOOK_KEY_ID, fbu->user_id.c_str()); + // If we have contact and don't need to force save data, just return it + if (hContact && !force_save) + return hContact; - std::string homepage = FACEBOOK_URL_PROFILE + fbu->user_id; - setString(hContact, "Homepage", homepage.c_str()); - setTString(hContact, "MirVer", fbu->getMirVer()); + // If not, try to make a new contact + if (!hContact) { + hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0); - db_unset(hContact, "CList", "MyHandle"); + if (hContact && CallService(MS_PROTO_ADDTOCONTACT, hContact, (LPARAM)m_szModuleName) != 0) { + CallService(MS_DB_CONTACT_DELETE, hContact, 0); + hContact = NULL; + } + } - ptrT group( getTStringA(NULL, FACEBOOK_KEY_DEF_GROUP)); - if (group) - db_set_ts(hContact, "CList", "Group", group); + // If we have some contact, we'll save its data + if (hContact) { + setString(hContact, FACEBOOK_KEY_ID, fbu->user_id.c_str()); - if (!fbu->real_name.empty()) { - SaveName(hContact, fbu); - } + std::string homepage = FACEBOOK_URL_PROFILE + fbu->user_id; + setString(hContact, "Homepage", homepage.c_str()); + setTString(hContact, "MirVer", fbu->getMirVer()); - if (fbu->gender) - setByte(hContact, "Gender", fbu->gender); + db_unset(hContact, "CList", "MyHandle"); - if (!fbu->image_url.empty()) - setString(hContact, FACEBOOK_KEY_AV_URL, fbu->image_url.c_str()); + ptrT group( getTStringA(NULL, FACEBOOK_KEY_DEF_GROUP)); + if (group) + db_set_ts(hContact, "CList", "Group", group); - setByte(hContact, FACEBOOK_KEY_CONTACT_TYPE, type); + if (!fbu->real_name.empty()) + SaveName(hContact, fbu); - if (getByte(FACEBOOK_KEY_DISABLE_STATUS_NOTIFY, 0)) - CallService(MS_IGNORE_IGNORE, hContact, (LPARAM)IGNOREEVENT_USERONLINE); + if (fbu->gender) + setByte(hContact, "Gender", fbu->gender); - return hContact; - } + if (!fbu->image_url.empty()) + setString(hContact, FACEBOOK_KEY_AV_URL, fbu->image_url.c_str()); - CallService(MS_DB_CONTACT_DELETE,hContact,0); + setByte(hContact, FACEBOOK_KEY_CONTACT_TYPE, type); + + if (getByte(FACEBOOK_KEY_DISABLE_STATUS_NOTIFY, 0)) + CallService(MS_IGNORE_IGNORE, hContact, (LPARAM)IGNOREEVENT_USERONLINE); } - return 0; + return hContact; } void FacebookProto::SetAllContactStatuses(int status) |