summaryrefslogtreecommitdiff
path: root/protocols/FacebookRM/src/process.cpp
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2012-11-09 15:37:34 +0000
committerRobert Pösel <robyer@seznam.cz>2012-11-09 15:37:34 +0000
commit0b67a54741236361d1ad1adf557e73fd80d1eea9 (patch)
treeb71ce86076216c269420a833689f53a1bdb7d858 /protocols/FacebookRM/src/process.cpp
parent336718667f42e964f4deeb54f60d42ff392457d4 (diff)
Facebook: Show contacts on mobile with different MirVer (support for MobileState plugin)
git-svn-id: http://svn.miranda-ng.org/main/trunk@2259 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/FacebookRM/src/process.cpp')
-rw-r--r--protocols/FacebookRM/src/process.cpp49
1 files changed, 40 insertions, 9 deletions
diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp
index 21fc491f99..768bd342f2 100644
--- a/protocols/FacebookRM/src/process.cpp
+++ b/protocols/FacebookRM/src/process.cpp
@@ -42,16 +42,48 @@ void FacebookProto::ProcessBuddyList( void* data )
p->parse_buddy_list( data, &facy.buddies );
delete p;
- for ( List::Item< facebook_user >* i = facy.buddies.begin( ); i != NULL; )
- {
- LOG(" Now %s: %s", (i->data->status_id == ID_STATUS_OFFLINE ? "offline" : "online"), i->data->real_name.c_str());
+ bool use_mobile_status = DBGetContactSettingByte(NULL,m_szModuleName,FACEBOOK_KEY_LOAD_MOBILE, DEFAULT_LOAD_MOBILE) != 0;
- facebook_user* fbu;
+ for ( List::Item< facebook_user >* i = facy.buddies.begin( ); i != NULL; )
+ {
+ facebook_user* fbu = i->data;
+ bool on_mobile = false;
+
+ char *status;
+ switch (fbu->status_id) {
+ case ID_STATUS_OFFLINE:
+ status = "offline"; break;
+ case ID_STATUS_ONLINE:
+ status = "online"; break;
+ case ID_STATUS_ONTHEPHONE:
+ on_mobile = true;
+ status = "onthephone";
+
+ if (!use_mobile_status)
+ fbu->status_id = ID_STATUS_OFFLINE;
+ break;
+ }
+ LOG(" Now %s: %s", status, i->data->real_name.c_str());
- if ( i->data->status_id == ID_STATUS_OFFLINE || i->data->deleted )
+ if (!fbu->deleted && on_mobile && !fbu->handle)
{
- fbu = i->data;
+ HANDLE hContact = fbu->handle;
+ if (!hContact)
+ hContact = AddToContactList(fbu, FACEBOOK_CONTACT_FRIEND);
+
+ DBVARIANT dbv;
+ TCHAR* client = on_mobile ? _T(FACEBOOK_MOBILE) : _T(FACEBOOK_NAME);
+ if (!DBGetContactSettingTString(hContact,m_szModuleName,"MirVer",&dbv)) {
+ if (_tcscmp(dbv.ptszVal, client))
+ DBWriteContactSettingTString(hContact,m_szModuleName,"MirVer",client);
+ DBFreeVariant(&dbv);
+ } else {
+ DBWriteContactSettingTString(hContact,m_szModuleName,"MirVer",client);
+ }
+ }
+ if (fbu->status_id == ID_STATUS_OFFLINE || fbu->deleted)
+ {
if (fbu->handle)
DBWriteContactSettingWord(fbu->handle, m_szModuleName, "Status", ID_STATUS_OFFLINE);
@@ -59,12 +91,11 @@ void FacebookProto::ProcessBuddyList( void* data )
i = i->next;
facy.buddies.erase( to_delete );
} else {
- fbu = i->data;
i = i->next;
if (!fbu->handle) { // just been added
- fbu->handle = AddToContactList(fbu, FACEBOOK_CONTACT_FRIEND);
-
+ fbu->handle = AddToContactList(fbu, FACEBOOK_CONTACT_FRIEND);
+
if (!fbu->real_name.empty()) {
DBWriteContactSettingUTF8String(fbu->handle,m_szModuleName,FACEBOOK_KEY_NAME,fbu->real_name.c_str());
DBWriteContactSettingUTF8String(fbu->handle,m_szModuleName,FACEBOOK_KEY_NICK,fbu->real_name.c_str());