summaryrefslogtreecommitdiff
path: root/protocols
diff options
context:
space:
mode:
authorMikalaiR <nikolay.romanovich@narod.ru>2015-05-01 17:30:38 +0000
committerMikalaiR <nikolay.romanovich@narod.ru>2015-05-01 17:30:38 +0000
commit835dab85f2585c4c3fda5e4d21384aa19edb8104 (patch)
treee67cc3c62049b181e4604bb6eecc9fc3d7c86cfe /protocols
parentb9852a65f0facc5c2e7239f4751050f12bc15a4d (diff)
SkypeWeb: Optimizations.
git-svn-id: http://svn.miranda-ng.org/main/trunk@13338 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r--protocols/SkypeWeb/src/skype_messages.cpp6
-rw-r--r--protocols/SkypeWeb/src/skype_proto.h2
-rw-r--r--protocols/SkypeWeb/src/skype_trouter.cpp46
-rw-r--r--protocols/SkypeWeb/src/skype_utils.cpp2
4 files changed, 36 insertions, 20 deletions
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