From 835dab85f2585c4c3fda5e4d21384aa19edb8104 Mon Sep 17 00:00:00 2001 From: MikalaiR Date: Fri, 1 May 2015 17:30:38 +0000 Subject: SkypeWeb: Optimizations. git-svn-id: http://svn.miranda-ng.org/main/trunk@13338 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/SkypeWeb/src/skype_messages.cpp | 6 ++-- protocols/SkypeWeb/src/skype_proto.h | 2 +- protocols/SkypeWeb/src/skype_trouter.cpp | 46 ++++++++++++++++++++----------- protocols/SkypeWeb/src/skype_utils.cpp | 2 +- 4 files changed, 36 insertions(+), 20 deletions(-) (limited to 'protocols/SkypeWeb') diff --git a/protocols/SkypeWeb/src/skype_messages.cpp b/protocols/SkypeWeb/src/skype_messages.cpp index 1e32973535..d259963bc3 100644 --- a/protocols/SkypeWeb/src/skype_messages.cpp +++ b/protocols/SkypeWeb/src/skype_messages.cpp @@ -66,13 +66,15 @@ MEVENT CSkypeProto::AddMessageToDb(MCONTACT hContact, DWORD timestamp, DWORD fla return AddEventToDb(hContact, emoteOffset == 0 ? EVENTTYPE_MESSAGE : SKYPE_DB_EVENT_TYPE_ACTION, timestamp, flags, (DWORD)cbBlob, pBlob); } -MEVENT CSkypeProto::AddCallToDb(MCONTACT hContact, DWORD timestamp, DWORD flags) +MEVENT CSkypeProto::AddCallToDb(MCONTACT hContact, DWORD timestamp, DWORD flags, const char *callId) { const char *message = Translate("Incoming call"); + size_t callIdLength = mir_strlen(callId); size_t messageLength = mir_strlen(message); - size_t cbBlob = messageLength; + size_t cbBlob = messageLength + callIdLength; PBYTE pBlob = (PBYTE)mir_alloc(cbBlob); memcpy(pBlob, message, messageLength); + memcpy(pBlob + messageLength, callId, callIdLength); return AddEventToDb(hContact, SKYPE_DB_EVENT_TYPE_INCOMING_CALL, timestamp, flags, (DWORD)cbBlob, pBlob); } diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h index 5ac4fd4974..13b0dc16af 100644 --- a/protocols/SkypeWeb/src/skype_proto.h +++ b/protocols/SkypeWeb/src/skype_proto.h @@ -209,7 +209,7 @@ private: MEVENT GetMessageFromDb(MCONTACT hContact, const char *messageId, LONGLONG timestamp = 0); MEVENT AddMessageToDb(MCONTACT hContact, DWORD timestamp, DWORD flags, const char *messageId, char *content, int emoteOffset = 0); - MEVENT AddCallToDb(MCONTACT hContact, DWORD timestamp, DWORD flags); + MEVENT AddCallToDb(MCONTACT hContact, DWORD timestamp, DWORD flags, const char *callId); int OnReceiveMessage(const char *messageId, const char *url, time_t timestamp, char *content, int emoteOffset = 0, bool isRead = false); int SaveMessageToDb(MCONTACT hContact, PROTORECVEVENT *pre); diff --git a/protocols/SkypeWeb/src/skype_trouter.cpp b/protocols/SkypeWeb/src/skype_trouter.cpp index c4a8b62932..c89e184fad 100644 --- a/protocols/SkypeWeb/src/skype_trouter.cpp +++ b/protocols/SkypeWeb/src/skype_trouter.cpp @@ -93,29 +93,43 @@ void CSkypeProto::OnTrouterEvent(JSONNODE *body, JSONNODE *headers) { ptrT displayname(json_as_string(json_get(body, "displayName"))); ptrT uid(json_as_string(json_get(body, "conversationId"))); + ptrA callId(mir_t2a(ptrT(json_as_string(json_get(body, "callId"))))); + int evt = json_as_int(json_get(body, "evt")); - MCONTACT hContact = FindContact(_T2A(uid)); - if (hContact != NULL) + switch (evt) { - MEVENT hEvent = AddCallToDb(hContact, time(NULL), DBEF_READ); - SkinPlaySound("skype_inc_call"); + case 100: //incoming call + { + if (uid != NULL) + { + MCONTACT hContact = AddContact(_T2A(uid), true); - CLISTEVENT cle = { sizeof(cle) }; - cle.flags |= CLEF_TCHAR; - cle.hContact = hContact; - cle.hDbEvent = hEvent; - cle.lParam = SKYPE_DB_EVENT_TYPE_INCOMING_CALL; - cle.hIcon = Skin_GetIconByHandle(GetIconHandle("inc_call")); + MEVENT hEvent = AddCallToDb(hContact, time(NULL), DBEF_READ, callId); + SkinPlaySound("skype_inc_call"); - CMStringA service(FORMAT, "%s/IncomingCallCLE", GetContactProto(hContact)); - cle.pszService = service.GetBuffer(); + CLISTEVENT cle = { sizeof(cle) }; + cle.flags |= CLEF_TCHAR; + cle.hContact = hContact; + cle.hDbEvent = hEvent; + cle.lParam = SKYPE_DB_EVENT_TYPE_INCOMING_CALL; + cle.hIcon = Skin_GetIconByHandle(GetIconHandle("inc_call")); - CMString tooltip(FORMAT, TranslateT("Incoming call from %s"), pcli->pfnGetContactDisplayName(hContact, 0)); - cle.ptszTooltip = tooltip.GetBuffer(); + CMStringA service(FORMAT, "%s/IncomingCallCLE", GetContactProto(hContact)); + cle.pszService = service.GetBuffer(); - CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)&cle); + CMString tooltip(FORMAT, TranslateT("Incoming call from %s"), pcli->pfnGetContactDisplayName(hContact, 0)); + cle.ptszTooltip = tooltip.GetBuffer(); - ShowNotification(pcli->pfnGetContactDisplayName(hContact, 0), TranslateT("Incoming call"), 0, hContact, SKYPE_DB_EVENT_TYPE_INCOMING_CALL); + CallService(MS_CLIST_ADDEVENT, 0, (LPARAM)&cle); + + ShowNotification(pcli->pfnGetContactDisplayName(hContact, 0), TranslateT("Incoming call"), 0, hContact, SKYPE_DB_EVENT_TYPE_INCOMING_CALL); + } + break; + } + case 104: //call canceled + { + break; + } } } diff --git a/protocols/SkypeWeb/src/skype_utils.cpp b/protocols/SkypeWeb/src/skype_utils.cpp index 097e9345af..d9a825763b 100644 --- a/protocols/SkypeWeb/src/skype_utils.cpp +++ b/protocols/SkypeWeb/src/skype_utils.cpp @@ -466,7 +466,7 @@ void CSkypeProto::ShowNotification(const TCHAR *caption, const TCHAR *message, i _tcsncpy(ppd.lptzText, message, MAX_SECONDLINE); if (type == SKYPE_DB_EVENT_TYPE_INCOMING_CALL) { - ppd.lchIcon = Skin_GetIcon("inc_call"); + ppd.lchIcon = Skin_GetIconByHandle(GetIconHandle("inc_call")); ppd.PluginWindowProc = PopupDlgProcCall; } else -- cgit v1.2.3