diff options
-rw-r--r-- | protocols/FacebookRM/src/client.h | 1 | ||||
-rw-r--r-- | protocols/FacebookRM/src/connection.cpp | 1 | ||||
-rw-r--r-- | protocols/FacebookRM/src/constants.h | 1 | ||||
-rw-r--r-- | protocols/FacebookRM/src/contacts.cpp | 21 | ||||
-rw-r--r-- | protocols/FacebookRM/src/json.cpp | 4 | ||||
-rw-r--r-- | protocols/FacebookRM/src/messages.cpp | 3 | ||||
-rw-r--r-- | protocols/FacebookRM/src/proto.h | 18 |
7 files changed, 38 insertions, 11 deletions
diff --git a/protocols/FacebookRM/src/client.h b/protocols/FacebookRM/src/client.h index b20d7d70e7..a1fca8e1e0 100644 --- a/protocols/FacebookRM/src/client.h +++ b/protocols/FacebookRM/src/client.h @@ -105,6 +105,7 @@ public: std::string get_privacy_type();
std::map<MCONTACT, bool> ignore_read;
+ std::set<MCONTACT> typing; // store info about typing contacts, because Facebook doesn't send "stopped typing" event when there is actual message being sent
char* load_cookies();
void store_headers(http::response* resp, NETLIBHTTPHEADER* headers, int headers_count);
diff --git a/protocols/FacebookRM/src/connection.cpp b/protocols/FacebookRM/src/connection.cpp index c29b8ba8d0..14abd9cd4b 100644 --- a/protocols/FacebookRM/src/connection.cpp +++ b/protocols/FacebookRM/src/connection.cpp @@ -55,6 +55,7 @@ void FacebookProto::ChangeStatus(void*) facy.buddies.clear();
facy.messages_ignore.clear();
facy.pages.clear();
+ facy.typing.clear();
if (facy.hMsgCon)
Netlib_CloseHandle(facy.hMsgCon);
diff --git a/protocols/FacebookRM/src/constants.h b/protocols/FacebookRM/src/constants.h index 6d1ffac66d..d4f8f62ec2 100644 --- a/protocols/FacebookRM/src/constants.h +++ b/protocols/FacebookRM/src/constants.h @@ -56,6 +56,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. #define FACEBOOK_TIMEOUTS_LIMIT 3
#define FACEBOOK_GROUP_NAME_LIMIT 100
#define FACEBOOK_MESSAGES_ON_OPEN_LIMIT 99
+#define FACEBOOK_TYPING_TIME 60
// Defaults
#define FACEBOOK_MINIMAL_POLL_RATE 10
diff --git a/protocols/FacebookRM/src/contacts.cpp b/protocols/FacebookRM/src/contacts.cpp index 276c4474ae..808bdef735 100644 --- a/protocols/FacebookRM/src/contacts.cpp +++ b/protocols/FacebookRM/src/contacts.cpp @@ -413,3 +413,24 @@ int FacebookProto::OnContactDeleted(WPARAM wParam,LPARAM) return 0; } + + +void FacebookProto::StartTyping(MCONTACT hContact) { + // ignore if contact is already typing + if (facy.typing.find(hContact) != facy.typing.end()) + return; + + // show notification and insert into typing set + CallService(MS_PROTO_CONTACTISTYPING, hContact, (LPARAM)FACEBOOK_TYPING_TIME); + facy.typing.insert(hContact); +} + +void FacebookProto::StopTyping(MCONTACT hContact) { + // ignore if contact is not typing + if (facy.typing.find(hContact) == facy.typing.end()) + return; + + // show notification and remove from typing set + CallService(MS_PROTO_CONTACTISTYPING, hContact, (LPARAM)PROTOTYPE_CONTACTTYPING_OFF); + facy.typing.erase(hContact); +}
\ No newline at end of file diff --git a/protocols/FacebookRM/src/json.cpp b/protocols/FacebookRM/src/json.cpp index 59c44a65c8..f29913600c 100644 --- a/protocols/FacebookRM/src/json.cpp +++ b/protocols/FacebookRM/src/json.cpp @@ -582,9 +582,9 @@ int facebook_json_parser::parse_messages(void* data, std::vector< facebook_messa JSONNODE *st = json_get(it, "st");
if (json_as_int(st) == 1)
- CallService(MS_PROTO_CONTACTISTYPING, hContact, (LPARAM)60);
+ proto->StartTyping(hContact);
else
- CallService(MS_PROTO_CONTACTISTYPING, hContact, (LPARAM)PROTOTYPE_CONTACTTYPING_OFF);
+ proto->StopTyping(hContact);
} else if (t == "ttyp") {
// multi chat typing notification
diff --git a/protocols/FacebookRM/src/messages.cpp b/protocols/FacebookRM/src/messages.cpp index 800f5c27be..aae8a55ca5 100644 --- a/protocols/FacebookRM/src/messages.cpp +++ b/protocols/FacebookRM/src/messages.cpp @@ -24,7 +24,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. int FacebookProto::RecvMsg(MCONTACT hContact, PROTORECVEVENT *pre)
{
- //CallService(MS_PROTO_CONTACTISTYPING, hContact, (LPARAM)PROTOTYPE_CONTACTTYPING_OFF);
+ StopTyping(hContact);
+
CallService(MS_MSG_SETSTATUSTEXT, (WPARAM)hContact, NULL);
return Proto_RecvMessage(hContact, pre);
diff --git a/protocols/FacebookRM/src/proto.h b/protocols/FacebookRM/src/proto.h index d669007f89..47e4dde821 100644 --- a/protocols/FacebookRM/src/proto.h +++ b/protocols/FacebookRM/src/proto.h @@ -190,14 +190,16 @@ public: void __cdecl SendPokeWorker(void*); // Contacts handling - bool IsMyContact(MCONTACT, bool include_chat = false); - MCONTACT ContactIDToHContact(std::string); - MCONTACT ChatIDToHContact(std::tstring); - std::string ThreadIDToContactID(std::string thread_id); - void FacebookProto::LoadContactInfo(facebook_user* fbu); - MCONTACT AddToContactList(facebook_user*, ContactType type, bool force_add = false); - void SetAllContactStatuses(int status); - MCONTACT HContactFromAuthEvent(HANDLE hEvent); + bool IsMyContact(MCONTACT, bool include_chat = false); + MCONTACT ContactIDToHContact(std::string); + MCONTACT ChatIDToHContact(std::tstring); + std::string ThreadIDToContactID(std::string thread_id); + void LoadContactInfo(facebook_user* fbu); + MCONTACT AddToContactList(facebook_user*, ContactType type, bool force_add = false); + void SetAllContactStatuses(int status); + MCONTACT HContactFromAuthEvent(HANDLE hEvent); + void StartTyping(MCONTACT hContact); + void StopTyping(MCONTACT hContact); // Chats handling void AddChat(const TCHAR *id, const TCHAR *name); |