diff options
author | Robert Pösel <robyer@seznam.cz> | 2014-05-18 09:47:19 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2014-05-18 09:47:19 +0000 |
commit | e63ffcd3b3c8598d28ee899bd2537b02c02d8d39 (patch) | |
tree | 12eeef452ab23f5b60022f91b04ba049c5787789 /protocols/FacebookRM/src/contacts.cpp | |
parent | 40b63e431bc8c68c91a32ca7a62337b97da30b91 (diff) |
Facebook: Refactor various working threads and updating contacts procedure; Version bump
This should eliminate creation of duplicite contacts, maybe made little slower or faster logging in...
git-svn-id: http://svn.miranda-ng.org/main/trunk@9217 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM/src/contacts.cpp')
-rw-r--r-- | protocols/FacebookRM/src/contacts.cpp | 55 |
1 files changed, 24 insertions, 31 deletions
diff --git a/protocols/FacebookRM/src/contacts.cpp b/protocols/FacebookRM/src/contacts.cpp index 5c82419ac1..2fb0d5fb70 100644 --- a/protocols/FacebookRM/src/contacts.cpp +++ b/protocols/FacebookRM/src/contacts.cpp @@ -171,50 +171,43 @@ void FacebookProto::LoadContactInfo(facebook_user* fbu) } } -MCONTACT FacebookProto::AddToContactList(facebook_user* fbu, ContactType type, bool force_save) +MCONTACT FacebookProto::AddToContactList(facebook_user* fbu, ContactType type, bool force_add) { - MCONTACT hContact; + // First, check if this contact exists (and if does, just return it) + if (!force_add) { + MCONTACT hContact = ContactIDToHContact(fbu->user_id); - // First, check if this contact exists - hContact = ContactIDToHContact(fbu->user_id); - - // If we have contact and don't need to force save data, just return it - if (hContact && !force_save) - return hContact; - - force_save = !hContact; + if (hContact) + return hContact; + } - // If not, try to make a new contact - if (!hContact) { - hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0); + // Try to make a new contact + MCONTACT hContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0); - if (hContact && CallService(MS_PROTO_ADDTOCONTACT, hContact, (LPARAM)m_szModuleName) != 0) { - CallService(MS_DB_CONTACT_DELETE, hContact, 0); - hContact = NULL; - } + if (hContact && CallService(MS_PROTO_ADDTOCONTACT, hContact, (LPARAM)m_szModuleName) != 0) { + CallService(MS_DB_CONTACT_DELETE, hContact, 0); + hContact = NULL; } // If we have some contact, we'll save its data if (hContact) { - if (force_save) { - // Save these values only when adding new contact, not when updating existing - setString(hContact, FACEBOOK_KEY_ID, fbu->user_id.c_str()); + // Save these values only when adding new contact, not when updating existing + setString(hContact, FACEBOOK_KEY_ID, fbu->user_id.c_str()); - std::string homepage = FACEBOOK_URL_PROFILE + fbu->user_id; - setString(hContact, "Homepage", homepage.c_str()); - setTString(hContact, "MirVer", fbu->getMirVer()); + std::string homepage = FACEBOOK_URL_PROFILE + fbu->user_id; + setString(hContact, "Homepage", homepage.c_str()); + setTString(hContact, "MirVer", fbu->getMirVer()); - db_unset(hContact, "CList", "MyHandle"); + db_unset(hContact, "CList", "MyHandle"); - ptrT group(getTStringA(NULL, FACEBOOK_KEY_DEF_GROUP)); - if (group) - db_set_ts(hContact, "CList", "Group", group); + ptrT group(getTStringA(NULL, FACEBOOK_KEY_DEF_GROUP)); + if (group) + db_set_ts(hContact, "CList", "Group", group); - setByte(hContact, FACEBOOK_KEY_CONTACT_TYPE, type); + setByte(hContact, FACEBOOK_KEY_CONTACT_TYPE, type); - if (getByte(FACEBOOK_KEY_DISABLE_STATUS_NOTIFY, 0)) - CallService(MS_IGNORE_IGNORE, hContact, (LPARAM)IGNOREEVENT_USERONLINE); - } + if (getByte(FACEBOOK_KEY_DISABLE_STATUS_NOTIFY, 0)) + CallService(MS_IGNORE_IGNORE, hContact, (LPARAM)IGNOREEVENT_USERONLINE); if (!fbu->real_name.empty()) SaveName(hContact, fbu); |