summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorRobert Pösel <robyer@seznam.cz>2013-11-19 16:58:01 +0000
committerRobert Pösel <robyer@seznam.cz>2013-11-19 16:58:01 +0000
commit8586f966f558d317d79b3ec25d0bf21d3d92498d (patch)
treeb0e7c9e04d8a841cc9eb546372624fb7f1a91799 /protocols
parent0e80ad0d4c150fa947849cdad07a7d0d34d7340e (diff)
Facebook: Correctly load contacts on mobile phone that are online right now (also removed old related option)
git-svn-id: http://svn.miranda-ng.org/main/trunk@6936 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r--protocols/FacebookRM/proto_facebook/res/Phone.icobin5430 -> 5430 bytes
-rw-r--r--protocols/FacebookRM/res/facebook.rc4
-rw-r--r--protocols/FacebookRM/src/constants.h6
-rw-r--r--protocols/FacebookRM/src/contacts.cpp6
-rw-r--r--protocols/FacebookRM/src/db.h1
-rw-r--r--protocols/FacebookRM/src/dialogs.cpp2
-rw-r--r--protocols/FacebookRM/src/entities.h12
-rw-r--r--protocols/FacebookRM/src/json.cpp37
-rw-r--r--protocols/FacebookRM/src/process.cpp34
-rw-r--r--protocols/FacebookRM/src/proto.cpp1
-rw-r--r--protocols/FacebookRM/src/resource.h1
11 files changed, 65 insertions, 39 deletions
diff --git a/protocols/FacebookRM/proto_facebook/res/Phone.ico b/protocols/FacebookRM/proto_facebook/res/Phone.ico
index 34521ddbde..c1a28c0b65 100644
--- a/protocols/FacebookRM/proto_facebook/res/Phone.ico
+++ b/protocols/FacebookRM/proto_facebook/res/Phone.ico
Binary files differ
diff --git a/protocols/FacebookRM/res/facebook.rc b/protocols/FacebookRM/res/facebook.rc
index 365528336a..c025a8f628 100644
--- a/protocols/FacebookRM/res/facebook.rc
+++ b/protocols/FacebookRM/res/facebook.rc
@@ -115,10 +115,8 @@ BEGIN
EDITTEXT IDC_GROUP,84,84,123,13,ES_AUTOHSCROLL
CONTROL "Automatically set 'Ignore status change' flag",IDC_SET_IGNORE_STATUS,
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,101,271,10
- GROUPBOX "Contacts Settings",IDC_STATIC,7,72,291,70
+ GROUPBOX "Contacts Settings",IDC_STATIC,7,72,291,60
CONTROL "Use bigger avatars",IDC_BIGGER_AVATARS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,114,271,10
- CONTROL "Load contacts with 'On the Mobile' status",IDC_LOAD_MOBILE,
- "Button",BS_AUTOCHECKBOX | WS_TABSTOP,17,127,271,10
END
IDD_OPTIONS_EVENTS DIALOGEX 0, 0, 305, 210
diff --git a/protocols/FacebookRM/src/constants.h b/protocols/FacebookRM/src/constants.h
index 3ce1fdb01a..5d1c6f98a6 100644
--- a/protocols/FacebookRM/src/constants.h
+++ b/protocols/FacebookRM/src/constants.h
@@ -24,7 +24,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// Product management
#define FACEBOOK_NAME "Facebook"
-#define FACEBOOK_MOBILE "Facebook (Mobile)"
#define FACEBOOK_URL_HOMEPAGE "http://www.facebook.com"
#define FACEBOOK_URL_REQUESTS "http://www.facebook.com/n/?reqs.php"
#define FACEBOOK_URL_MESSAGES "http://www.facebook.com/n/?inbox"
@@ -41,6 +40,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define FACEBOOK_SERVER_APPS "apps.facebook.com"
#define FACEBOOK_SERVER_DOMAIN "facebook.com"
+// Facebook clients
+#define FACEBOOK_CLIENT "Facebook"
+#define FACEBOOK_CLIENT_MOBILE "Facebook (Mobile)"
+
// Limits
#define FACEBOOK_MESSAGE_LIMIT 200000 // this is guessed limit, in reality it is bigger
#define FACEBOOK_MESSAGE_LIMIT_TEXT "200000"
@@ -63,7 +66,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define DEFAULT_BIG_AVATARS 0
#define DEFAULT_DISCONNECT_CHAT 0
#define DEFAULT_MAP_STATUSES 0
-#define DEFAULT_LOAD_MOBILE 0
#define DEFAULT_CUSTOM_SMILEYS 0
#define DEFAULT_LOCAL_TIME 0
#define DEFAULT_LOAD_PAGES 0
diff --git a/protocols/FacebookRM/src/contacts.cpp b/protocols/FacebookRM/src/contacts.cpp
index 432c00187f..adef0e21b0 100644
--- a/protocols/FacebookRM/src/contacts.cpp
+++ b/protocols/FacebookRM/src/contacts.cpp
@@ -115,7 +115,7 @@ HANDLE FacebookProto::AddToContactList(facebook_user* fbu, ContactType type, boo
std::string homepage = FACEBOOK_URL_PROFILE + fbu->user_id;
setString(hContact, "Homepage", homepage.c_str());
- setString(hContact, "MirVer", fbu->status_id == ID_STATUS_ONTHEPHONE ? FACEBOOK_MOBILE : FACEBOOK_NAME);
+ setTString(hContact, "MirVer", fbu->mobile ? _T(FACEBOOK_CLIENT_MOBILE) : _T(FACEBOOK_CLIENT));
db_unset(hContact, "CList", "MyHandle");
@@ -155,8 +155,8 @@ void FacebookProto::SetAllContactStatuses(int status, bool reset_client)
if (reset_client) {
ptrT mirver( getTStringA(hContact, "MirVer"));
- if (!mirver || _tcscmp(mirver, _T(FACEBOOK_NAME)))
- setTString(hContact, "MirVer", _T(FACEBOOK_NAME));
+ if (!mirver || _tcscmp(mirver, _T(FACEBOOK_CLIENT)))
+ setTString(hContact, "MirVer", _T(FACEBOOK_CLIENT));
}
if (getWord(hContact, "Status", 0) != status)
diff --git a/protocols/FacebookRM/src/db.h b/protocols/FacebookRM/src/db.h
index 3103070e67..03e4ed507d 100644
--- a/protocols/FacebookRM/src/db.h
+++ b/protocols/FacebookRM/src/db.h
@@ -44,7 +44,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define FACEBOOK_KEY_BIG_AVATARS "UseBigAvatars"
#define FACEBOOK_KEY_DISCONNECT_CHAT "DisconnectChatEnable"
#define FACEBOOK_KEY_MAP_STATUSES "MapStatuses"
-#define FACEBOOK_KEY_LOAD_MOBILE "LoadMobile"
#define FACEBOOK_KEY_CUSTOM_SMILEYS "CustomSmileys"
#define FACEBOOK_KEY_MESSAGE_ID "LastMessageId"
#define FACEBOOK_KEY_SERVER_TYPE "ServerType"
diff --git a/protocols/FacebookRM/src/dialogs.cpp b/protocols/FacebookRM/src/dialogs.cpp
index 6381f86eb7..3df11ce99c 100644
--- a/protocols/FacebookRM/src/dialogs.cpp
+++ b/protocols/FacebookRM/src/dialogs.cpp
@@ -377,7 +377,6 @@ INT_PTR CALLBACK FBOptionsProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
LoadDBCheckState(proto, hwnd, IDC_SET_IGNORE_STATUS, FACEBOOK_KEY_DISABLE_STATUS_NOTIFY, DEFAULT_DISABLE_STATUS_NOTIFY);
LoadDBCheckState(proto, hwnd, IDC_BIGGER_AVATARS, FACEBOOK_KEY_BIG_AVATARS, DEFAULT_BIG_AVATARS);
- LoadDBCheckState(proto, hwnd, IDC_LOAD_MOBILE, FACEBOOK_KEY_LOAD_MOBILE, DEFAULT_LOAD_MOBILE);
} return TRUE;
@@ -423,7 +422,6 @@ INT_PTR CALLBACK FBOptionsProc(HWND hwnd, UINT message, WPARAM wparam, LPARAM lp
StoreDBCheckState(proto, hwnd, IDC_SET_IGNORE_STATUS, FACEBOOK_KEY_DISABLE_STATUS_NOTIFY);
StoreDBCheckState(proto, hwnd, IDC_BIGGER_AVATARS, FACEBOOK_KEY_BIG_AVATARS);
- StoreDBCheckState(proto, hwnd, IDC_LOAD_MOBILE, FACEBOOK_KEY_LOAD_MOBILE);
return TRUE;
}
diff --git a/protocols/FacebookRM/src/entities.h b/protocols/FacebookRM/src/entities.h
index f1fc57055e..a52c3ed701 100644
--- a/protocols/FacebookRM/src/entities.h
+++ b/protocols/FacebookRM/src/entities.h
@@ -36,6 +36,8 @@ struct facebook_user
std::string image_url;
bool deleted;
+ bool idle;
+ bool mobile;
facebook_user()
{
@@ -43,19 +45,21 @@ struct facebook_user
this->user_id = this->real_name = this->image_url = "";
this->status_id = ID_STATUS_OFFLINE;
this->gender = this->last_active = 0;
- this->deleted = false;
+ this->deleted = this->idle = this->mobile = false;
}
facebook_user(facebook_user* fu)
{
this->handle = fu->handle;
- this->image_url = fu->image_url;
+ this->user_id = fu->user_id;
this->real_name = fu->real_name;
this->status_id = fu->status_id;
- this->user_id = fu->user_id;
this->gender = fu->gender;
this->last_active = fu->last_active;
- this->deleted = fu->deleted;
+ this->image_url = fu->image_url;
+ this->deleted = fu->deleted;
+ this->idle = fu->idle;
+ this->mobile = fu->mobile;
}
};
diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp
index b5d23b9af5..a103a6f29c 100644
--- a/protocols/FacebookRM/src/json.cpp
+++ b/protocols/FacebookRM/src/json.cpp
@@ -80,7 +80,8 @@ int facebook_json_parser::parse_buddy_list(void* data, List::List< facebook_user
current->user_id = id;
}
- current->status_id = ID_STATUS_ONTHEPHONE;
+ current->status_id = ID_STATUS_OFFLINE;
+ current->mobile = true;
}
}
@@ -100,10 +101,36 @@ int facebook_json_parser::parse_buddy_list(void* data, List::List< facebook_user
current->status_id = ID_STATUS_ONLINE;
- // In new version of Facebook "i" means "offline"
- JSONNODE *idle = json_get(it, "i");
- if (idle != NULL && json_as_bool(idle))
- current->status_id = ID_STATUS_OFFLINE;
+ JSONNODE *p = json_get(it, "p");
+ if (p != NULL) {
+ JSONNODE *status = json_get(p, "status"); // this seems to be "active" everytime
+ JSONNODE *webStatus = json_get(p, "webStatus"); // "active", "idle" or "offline"
+ JSONNODE *fbAppStatus = json_get(p, "fbAppStatus"); // "offline" or "active"
+ JSONNODE *messengerStatus = json_get(p, "messengerStatus"); // "offline" or "active"
+ JSONNODE *otherStatus = json_get(p, "otherStatus"); // "offline" or "active" - this seems to be "active" when webStatus is "idle" or "active" only
+
+ // this may never happen
+ if (json_as_pstring(status) != "active")
+ current->status_id = ID_STATUS_OFFLINE;
+
+ // "webStatus" and "otherStatus" are marked as "WEB" on FB website
+ if (json_as_pstring(webStatus) == "active" || json_as_pstring(otherStatus) == "active") {
+ current->status_id = ID_STATUS_ONLINE;
+ current->mobile = false;
+ }
+
+ // "fbAppStatus" and "messengerStatus" are marked as "MOBILE" on FB website
+ if (json_as_pstring(fbAppStatus) == "active" || json_as_pstring(messengerStatus) == "active") {
+ current->status_id = ID_STATUS_ONTHEPHONE;
+ current->mobile = true;
+ }
+
+ // this is not marked anyhow on website (yet?)
+ current->idle = json_as_pstring(webStatus) == "idle"
+ || json_as_pstring(otherStatus) == "idle"
+ || json_as_pstring(fbAppStatus) == "idle"
+ || json_as_pstring(messengerStatus) == "idle";
+ }
}
}
diff --git a/protocols/FacebookRM/src/process.cpp b/protocols/FacebookRM/src/process.cpp
index 5a9ffb26f5..d62271b1a3 100644
--- a/protocols/FacebookRM/src/process.cpp
+++ b/protocols/FacebookRM/src/process.cpp
@@ -42,28 +42,24 @@ void FacebookProto::ProcessBuddyList(void* data)
p->parse_buddy_list(data, &facy.buddies);
delete p;
- bool use_mobile_status = getByte(FACEBOOK_KEY_LOAD_MOBILE, DEFAULT_LOAD_MOBILE) != 0;
-
for (List::Item< facebook_user >* i = facy.buddies.begin(); i != NULL;)
{
facebook_user* fbu = i->data;
- bool on_mobile = false;
- char *status;
+ std::string 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 = "Phone";
-
- if (!use_mobile_status)
- fbu->status_id = ID_STATUS_OFFLINE;
- break;
+ status = "Mobile"; break;
}
- debugLogA(" Now %s: %s", status, fbu->user_id.c_str());
+
+ if (fbu->idle)
+ status += " (idle)";
+
+ debugLogA(" Now %s: %s", status.c_str(), fbu->user_id.c_str());
if (!fbu->deleted)
{
@@ -71,14 +67,16 @@ void FacebookProto::ProcessBuddyList(void* data)
if (!hContact)
hContact = AddToContactList(fbu, CONTACT_FRIEND);
- DBVARIANT dbv;
- TCHAR* client = on_mobile ? _T(FACEBOOK_MOBILE) : _T(FACEBOOK_NAME);
- if (!getTString(hContact, "MirVer", &dbv)) {
- if (_tcscmp(dbv.ptszVal, client))
- setTString(hContact, "MirVer", client);
- db_free(&dbv);
+ ptrT client( getTStringA(hContact, "MirVer"));
+ if (!client || _tcscmp(client, fbu->mobile ? _T(FACEBOOK_CLIENT_MOBILE) : _T(FACEBOOK_CLIENT)))
+ setTString(hContact, "MirVer", fbu->mobile ? _T(FACEBOOK_CLIENT_MOBILE) : _T(FACEBOOK_CLIENT));
+
+ if (getDword(fbu->handle, "IdleTS", 0) != fbu->last_active) {
+ if ((fbu->idle || fbu->status_id == ID_STATUS_OFFLINE) && fbu->last_active > 0)
+ setDword(fbu->handle, "IdleTS", fbu->last_active);
+ else
+ delSetting(fbu->handle, "IdleTS");
}
- else setTString(hContact, "MirVer", client);
}
if (fbu->status_id == ID_STATUS_OFFLINE || fbu->deleted)
diff --git a/protocols/FacebookRM/src/proto.cpp b/protocols/FacebookRM/src/proto.cpp
index df81e435ae..99c1c9becd 100644
--- a/protocols/FacebookRM/src/proto.cpp
+++ b/protocols/FacebookRM/src/proto.cpp
@@ -54,6 +54,7 @@ FacebookProto::FacebookProto(const char* proto_name,const TCHAR* username) :
HookProtoEvent(ME_GC_BUILDMENU, &FacebookProto::OnGCMenuHook);
db_set_resident(m_szModuleName, "Status");
+ db_set_resident(m_szModuleName, "IdleTS");
db_set_resident(m_szModuleName, FACEBOOK_KEY_MESSAGE_ID);
InitHotkeys();
diff --git a/protocols/FacebookRM/src/resource.h b/protocols/FacebookRM/src/resource.h
index ff12fa5cd8..e13e3b76b6 100644
--- a/protocols/FacebookRM/src/resource.h
+++ b/protocols/FacebookRM/src/resource.h
@@ -26,7 +26,6 @@
#define IDC_DISCONNECT_CHAT 1028
#define IDC_BIGGER_AVATARS 1030
#define IDC_MAP_STATUSES 1032
-#define IDC_LOAD_MOBILE 1033
#define IDC_CUSTOM_SMILEYS 1034
#define IDC_USE_LOCAL_TIME 1035
#define IDC_LOAD_PAGES 1036