From 98ea54f7f9eac65c369538e0f293ac7ec3e8db51 Mon Sep 17 00:00:00 2001 From: MikalaiR Date: Sat, 9 May 2015 18:20:41 +0000 Subject: SkypeWeb: TRouter refactoring. git-svn-id: http://svn.miranda-ng.org/main/trunk@13499 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/SkypeWeb/src/skype_contacts.cpp | 56 ++++++++++++++++++------------- 1 file changed, 33 insertions(+), 23 deletions(-) (limited to 'protocols/SkypeWeb/src/skype_contacts.cpp') diff --git a/protocols/SkypeWeb/src/skype_contacts.cpp b/protocols/SkypeWeb/src/skype_contacts.cpp index 72237b51d0..f4f1f87e99 100644 --- a/protocols/SkypeWeb/src/skype_contacts.cpp +++ b/protocols/SkypeWeb/src/skype_contacts.cpp @@ -130,37 +130,47 @@ void CSkypeProto::LoadContactsAuth(const NETLIBHTTPREQUEST *response) node = json_get(item, "sender"); ptrA skypename(mir_t2a(ptrT(json_as_string(node)))); - JSONNODE *node = json_get(root, "greeting"); + node = json_get(root, "greeting"); CMStringA reason = ptrA(mir_t2a(ptrT(json_as_string(node)))); + node = json_get(root, "event_time"); + ptrT eventTimeStr(json_as_string(node)); + time_t eventTime = IsoToUnixTime(eventTimeStr); + if (reason == "null") reason.Empty(); MCONTACT hContact = AddContact(skypename); if (hContact) { - delSetting(hContact, "Auth"); - - PROTORECVEVENT pre = { 0 }; - pre.flags = PREF_UTF; - pre.timestamp = time(NULL); - pre.lParam = (DWORD)(sizeof(DWORD) * 2 + mir_strlen(skypename) + reason.GetLength() + 5); - - /*blob is: 0(DWORD), hContact(DWORD), nick(ASCIIZ), firstName(ASCIIZ), lastName(ASCIIZ), id(ASCIIZ), reason(ASCIIZ)*/ - PBYTE pBlob, pCurBlob; - pCurBlob = pBlob = (PBYTE)mir_calloc(pre.lParam); - - *((PDWORD)pCurBlob) = 0; - pCurBlob += sizeof(DWORD); - *((PDWORD)pCurBlob) = (DWORD)hContact; - pCurBlob += sizeof(DWORD); - pCurBlob += 3; - mir_strcpy((char*)pCurBlob, skypename); - pCurBlob += mir_strlen(skypename) + 1; - mir_strcpy((char*)pCurBlob, reason); - pre.szMessage = (char*)pBlob; - - ProtoChainRecv(hContact, PSR_AUTH, 0, (LPARAM)&pre); + time_t lastEventTime = db_get_dw(hContact, m_szModuleName, "LastAuthRequestTime", 0); + + if (lastEventTime == 0 || lastEventTime < eventTime) + { + db_set_dw(hContact, m_szModuleName,"LastAuthRequestTime", eventTime); + delSetting(hContact, "Auth"); + + PROTORECVEVENT pre = { 0 }; + pre.flags = PREF_UTF; + pre.timestamp = time(NULL); + pre.lParam = (DWORD)(sizeof(DWORD) * 2 + mir_strlen(skypename) + reason.GetLength() + 5); + + /*blob is: 0(DWORD), hContact(DWORD), nick(ASCIIZ), firstName(ASCIIZ), lastName(ASCIIZ), id(ASCIIZ), reason(ASCIIZ)*/ + PBYTE pBlob, pCurBlob; + pCurBlob = pBlob = (PBYTE)mir_calloc(pre.lParam); + + *((PDWORD)pCurBlob) = 0; + pCurBlob += sizeof(DWORD); + *((PDWORD)pCurBlob) = (DWORD)hContact; + pCurBlob += sizeof(DWORD); + pCurBlob += 3; + mir_strcpy((char*)pCurBlob, skypename); + pCurBlob += mir_strlen(skypename) + 1; + mir_strcpy((char*)pCurBlob, reason); + pre.szMessage = (char*)pBlob; + + ProtoChainRecv(hContact, PSR_AUTH, 0, (LPARAM)&pre); + } } } json_delete(items); -- cgit v1.2.3