summaryrefslogtreecommitdiff
path: root/protocols/FacebookRM
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2014-05-10 17:38:59 +0000
committerRobert Pösel <robyer@seznam.cz>2014-05-10 17:38:59 +0000
commit8762a11a5053c1a7f12d6390c4edfa86533e796f (patch)
tree0cbf0168b951d0feae49b81ffc0ccf5e3318c8d5 /protocols/FacebookRM
parente3c0c006f5e87f16060b09b59f24e02a3faccf44 (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')
-rw-r--r--protocols/FacebookRM/src/contacts.cpp70
-rw-r--r--protocols/FacebookRM/src/process.cpp12
-rw-r--r--protocols/FacebookRM/src/proto.h2
-rw-r--r--protocols/FacebookRM/src/version.h2
4 files changed, 42 insertions, 44 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)
diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp
index fbbbb0c657..8b4778f8b2 100644
--- a/protocols/FacebookRM/src/process.cpp
+++ b/protocols/FacebookRM/src/process.cpp
@@ -232,15 +232,13 @@ void FacebookProto::ProcessFriendList(void* data)
}
// Check remaining contacts in map and add them to contact list
- for (std::map< std::string, facebook_user* >::iterator iter = friends.begin(); iter != friends.end(); ++iter) {
- facebook_user *fbu = iter->second;
+ for (std::map< std::string, facebook_user* >::iterator it = friends.begin(); it != friends.end(); ) {
+ if (!it->second->deleted)
+ AddToContactList(it->second, CONTACT_FRIEND, true); // there could be race-condition between this thread and channel/buddy_list thread, so this contact might be created already
- if (!fbu->deleted)
- MCONTACT hContact = AddToContactList(fbu, CONTACT_FRIEND/*, true*/); // This contact is surely new ...am I sure? ...I'm not, so "true" is commented now
-
- delete fbu;
+ delete it->second;
+ it = friends.erase(it);
}
-
friends.clear();
debugLogA("***** Friend list processed");
diff --git a/protocols/FacebookRM/src/proto.h b/protocols/FacebookRM/src/proto.h
index ad15eaa9a9..1cc6cce4f9 100644
--- a/protocols/FacebookRM/src/proto.h
+++ b/protocols/FacebookRM/src/proto.h
@@ -192,7 +192,7 @@ public:
MCONTACT ChatIDToHContact(std::tstring);
std::string ThreadIDToContactID(std::string thread_id);
void FacebookProto::LoadContactInfo(facebook_user* fbu);
- MCONTACT AddToContactList(facebook_user*, ContactType type, bool dont_check = false);
+ MCONTACT AddToContactList(facebook_user*, ContactType type, bool force_save = false);
void SetAllContactStatuses(int status);
MCONTACT HContactFromAuthEvent(HANDLE hEvent);
diff --git a/protocols/FacebookRM/src/version.h b/protocols/FacebookRM/src/version.h
index 73f39e1249..12c19d23ed 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 4
-#define __BUILD_NUM 0
+#define __BUILD_NUM 1
#include <stdver.h>