summaryrefslogtreecommitdiff
path: root/protocols/FacebookRM/src/contacts.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/FacebookRM/src/contacts.cpp')
-rw-r--r--protocols/FacebookRM/src/contacts.cpp70
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)