diff options
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/FacebookRM/src/contacts.cpp | 70 | ||||
-rw-r--r-- | protocols/FacebookRM/src/process.cpp | 12 | ||||
-rw-r--r-- | protocols/FacebookRM/src/proto.h | 2 | ||||
-rw-r--r-- | protocols/FacebookRM/src/version.h | 2 |
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>
|