diff options
author | MikalaiR <nikolay.romanovich@narod.ru> | 2015-04-05 19:32:47 +0000 |
---|---|---|
committer | MikalaiR <nikolay.romanovich@narod.ru> | 2015-04-05 19:32:47 +0000 |
commit | 3ffa79499e8b9c270fa33c1f1b90ef9b09fe43be (patch) | |
tree | 7e44a4b7c319bf4dfc98a4f332a09a78333a765d /protocols/SkypeWeb/src | |
parent | a5b3b10b0fb74f875aabda2db2e21311c02bdfee (diff) |
SkypeWeb: History sync reworked.
git-svn-id: http://svn.miranda-ng.org/main/trunk@12618 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/SkypeWeb/src')
-rw-r--r-- | protocols/SkypeWeb/src/requests/messages.h | 4 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/skype_events.cpp | 2 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/skype_menus.cpp | 8 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/skype_menus.h | 5 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/skype_messages.cpp | 10 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/skype_proto.h | 1 |
6 files changed, 22 insertions, 8 deletions
diff --git a/protocols/SkypeWeb/src/requests/messages.h b/protocols/SkypeWeb/src/requests/messages.h index d58fc131aa..81a0d12b92 100644 --- a/protocols/SkypeWeb/src/requests/messages.h +++ b/protocols/SkypeWeb/src/requests/messages.h @@ -42,8 +42,8 @@ public: class GetHistoryRequest : public HttpRequest
{
public:
- GetHistoryRequest(const char *regToken, int time, const char *server = "client-s.gateway.messenger.live.com") :
- HttpRequest(REQUEST_GET, FORMAT, "%s/v1/users/ME/conversations?startTime=%d&pageSize=100&view=msnp24Equivalent&targetType=Passport|Skype|Lync|Thread", server, time)
+ GetHistoryRequest(const char *regToken, const char *username/* int time*/, const char *server = "client-s.gateway.messenger.live.com") :
+ HttpRequest(REQUEST_GET, FORMAT, "%s/v1/users/ME/conversations/8:%s/messages?startTime=0&pageSize=100&view=msnp24Equivalent&targetType=Passport|Skype|Lync|Thread", server, mir_urlEncode(username)/*, time*/)
{
Headers
<< CHAR_VALUE("Accept", "application/json, text/javascript")
diff --git a/protocols/SkypeWeb/src/skype_events.cpp b/protocols/SkypeWeb/src/skype_events.cpp index db91d9f1b8..f471302fda 100644 --- a/protocols/SkypeWeb/src/skype_events.cpp +++ b/protocols/SkypeWeb/src/skype_events.cpp @@ -137,8 +137,6 @@ void CSkypeProto::OnGetRegInfo(const NETLIBHTTPREQUEST *response) m_iStatus = m_iDesiredStatus;
ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)ID_STATUS_CONNECTING, m_iStatus);
PushRequest(new SetStatusRequest(ptrA(getStringA("registrationToken")), MirandaToSkypeStatus(m_iStatus), getStringA("Server")), &CSkypeProto::OnSetStatus);
- PushRequest(new GetHistoryRequest(ptrA(getStringA("registrationToken")), getDword("LastMsgTime", time(NULL)), ptrA(getStringA("Server"))), &CSkypeProto::OnGetServerHistory);
-
}
void CSkypeProto::OnGetEndpoint(const NETLIBHTTPREQUEST *response)
diff --git a/protocols/SkypeWeb/src/skype_menus.cpp b/protocols/SkypeWeb/src/skype_menus.cpp index 0bb9092828..3f7885e830 100644 --- a/protocols/SkypeWeb/src/skype_menus.cpp +++ b/protocols/SkypeWeb/src/skype_menus.cpp @@ -19,6 +19,7 @@ int CSkypeProto::OnPrebuildContactMenu(WPARAM hContact, LPARAM) Menu_ShowItem(ContactMenuItems[CMI_AUTH_REQUEST], isCtrlPressed || isAuthNeed);
Menu_ShowItem(ContactMenuItems[CMI_AUTH_GRANT], isCtrlPressed || isGrantNeed);
+ Menu_ShowItem(ContactMenuItems[CMI_GETSERVERHISTORY], true);
return 0;
}
@@ -55,6 +56,13 @@ void CSkypeProto::InitMenus() mi.icolibItem = LoadSkinnedIconHandle(SKINICON_AUTH_GRANT);
ContactMenuItems[CMI_AUTH_GRANT] = Menu_AddContactMenuItem(&mi);
CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::OnGrantAuth>);
+
+ mi.pszService = MODULE"/GetHistory";
+ mi.ptszName = LPGENT("Get server history");
+ mi.position = CMI_POSITION + CMI_GETSERVERHISTORY;
+ mi.icolibItem = LoadSkinnedIconHandle(SKINICON_AUTH_GRANT);
+ ContactMenuItems[CMI_GETSERVERHISTORY] = Menu_AddContactMenuItem(&mi);
+ CreateServiceFunction(mi.pszService, GlobalService<&CSkypeProto::GetContactHistory>);
}
void CSkypeProto::UninitMenus()
diff --git a/protocols/SkypeWeb/src/skype_menus.h b/protocols/SkypeWeb/src/skype_menus.h index 6930ddeb2f..5a0fcaed6d 100644 --- a/protocols/SkypeWeb/src/skype_menus.h +++ b/protocols/SkypeWeb/src/skype_menus.h @@ -2,8 +2,9 @@ #define _SKYPE_MENUS_H_
#define CMI_POSITION -201001000
-#define CMI_AUTH_REQUEST 1
-#define CMI_AUTH_GRANT 2
+#define CMI_AUTH_REQUEST 0
+#define CMI_AUTH_GRANT 1
+#define CMI_GETSERVERHISTORY 2
#define CMI_MAX 3 // this item shall be the last one
#define SMI_POSITION 200000
diff --git a/protocols/SkypeWeb/src/skype_messages.cpp b/protocols/SkypeWeb/src/skype_messages.cpp index ae43e0a500..6debc0257e 100644 --- a/protocols/SkypeWeb/src/skype_messages.cpp +++ b/protocols/SkypeWeb/src/skype_messages.cpp @@ -178,10 +178,10 @@ void CSkypeProto::OnGetServerHistory(const NETLIBHTTPREQUEST *response) if (root == NULL)
return;
- JSONNODE *conversations = json_as_array(json_get(root, "conversations"));
+ JSONNODE *conversations = json_as_array(json_get(root, "messages"));
for (size_t i = 0; i < json_size(conversations); i++)
{
- JSONNODE *message = json_get(json_at(conversations, i), "lastMessage");
+ JSONNODE *message = json_at(conversations, i);
ptrA clientMsgId(mir_t2a(ptrT(json_as_string(json_get(message, "clientmessageid")))));
ptrA skypeEditedId(mir_t2a(ptrT(json_as_string(json_get(message, "skypeeditedid")))));
@@ -210,4 +210,10 @@ void CSkypeProto::OnGetServerHistory(const NETLIBHTTPREQUEST *response) AddMessageToDb(hContact, timestamp, flags, clientMsgId, content, emoteOffset);
}
}
+}
+
+INT_PTR CSkypeProto::GetContactHistory(WPARAM hContact, LPARAM lParam)
+{
+ PushRequest(new GetHistoryRequest(ptrA(getStringA("registrationToken")), ptrA(db_get_sa(hContact, m_szModuleName, "Skypename")), ptrA(getStringA("Server"))), &CSkypeProto::OnGetServerHistory);
+ return 0;
}
\ No newline at end of file diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h index 27db01cf6d..6757aba4dd 100644 --- a/protocols/SkypeWeb/src/skype_proto.h +++ b/protocols/SkypeWeb/src/skype_proto.h @@ -170,6 +170,7 @@ private: INT_PTR __cdecl OnRequestAuth(WPARAM hContact, LPARAM lParam);
INT_PTR __cdecl OnGrantAuth(WPARAM hContact, LPARAM);
+ INT_PTR __cdecl GetContactHistory(WPARAM hContact, LPARAM lParam);
int __cdecl OnContactDeleted(MCONTACT, LPARAM);
|