summaryrefslogtreecommitdiff
path: root/protocols/SkypeWeb/src
diff options
context:
space:
mode:
authorMikalaiR <nikolay.romanovich@narod.ru>2015-04-30 13:11:42 +0000
committerMikalaiR <nikolay.romanovich@narod.ru>2015-04-30 13:11:42 +0000
commitea9403c8ff0b188f74f0fe2d101c4497485dbdaa (patch)
treea1a5bbf8b485dc1a440bdfc9c55402a949daab4c /protocols/SkypeWeb/src
parent2aa1775c7bbba890746d13aa155c77a781304f7a (diff)
SkypeWeb: Notification on incoming call.
git-svn-id: http://svn.miranda-ng.org/main/trunk@13289 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/SkypeWeb/src')
-rw-r--r--protocols/SkypeWeb/src/common.h4
-rw-r--r--protocols/SkypeWeb/src/resource.h3
-rw-r--r--protocols/SkypeWeb/src/skype_icons.cpp3
-rw-r--r--protocols/SkypeWeb/src/skype_messages.cpp11
-rw-r--r--protocols/SkypeWeb/src/skype_proto.cpp9
-rw-r--r--protocols/SkypeWeb/src/skype_proto.h3
-rw-r--r--protocols/SkypeWeb/src/skype_trouter.cpp18
7 files changed, 39 insertions, 12 deletions
diff --git a/protocols/SkypeWeb/src/common.h b/protocols/SkypeWeb/src/common.h
index 62b8891ada..d7d18ed018 100644
--- a/protocols/SkypeWeb/src/common.h
+++ b/protocols/SkypeWeb/src/common.h
@@ -103,6 +103,6 @@ enum SKYPE_LOGIN_ERROR
#define POLLING_ERRORS_LIMIT 3
-#define SKYPE_DB_EVENT_TYPE_ACTION 10001
-
+#define SKYPE_DB_EVENT_TYPE_ACTION 10001
+#define SKYPE_DB_EVENT_TYPE_INCOMING_CALL 10002
#endif //_COMMON_H_ \ No newline at end of file
diff --git a/protocols/SkypeWeb/src/resource.h b/protocols/SkypeWeb/src/resource.h
index cc6ecaf79b..58149ea76f 100644
--- a/protocols/SkypeWeb/src/resource.h
+++ b/protocols/SkypeWeb/src/resource.h
@@ -16,6 +16,7 @@
#define IDI_SYNCHISTORY 117
#define IDI_BLOCKUSER 118
#define IDI_UNBLOCKUSER 119
+#define IDI_CALL 120
#define IDC_AUTOSYNC 1028
#define IDC_LOCALTIME 1029
#define IDC_RADIO1 1030
@@ -32,7 +33,7 @@
//
#ifdef APSTUDIO_INVOKED
#ifndef APSTUDIO_READONLY_SYMBOLS
-#define _APS_NEXT_RESOURCE_VALUE 120
+#define _APS_NEXT_RESOURCE_VALUE 121
#define _APS_NEXT_COMMAND_VALUE 40001
#define _APS_NEXT_CONTROL_VALUE 1042
#define _APS_NEXT_SYMED_VALUE 101
diff --git a/protocols/SkypeWeb/src/skype_icons.cpp b/protocols/SkypeWeb/src/skype_icons.cpp
index a5e12cde4b..5ff4c0453f 100644
--- a/protocols/SkypeWeb/src/skype_icons.cpp
+++ b/protocols/SkypeWeb/src/skype_icons.cpp
@@ -23,7 +23,8 @@ IconInfo CSkypeProto::Icons[] =
{ LPGENT("Create new chat icon"), "conference", IDI_CONFERENCE },
{ LPGENT("Sync history icon"), "synchistory", IDI_SYNCHISTORY},
{ LPGENT("Block user icon"), "user_block", IDI_BLOCKUSER },
- { LPGENT("Unblock user icon"), "user_unblock", IDI_UNBLOCKUSER }
+ { LPGENT("Unblock user icon"), "user_unblock", IDI_UNBLOCKUSER },
+ { LPGENT("Incoming call icon"), "inc_call", IDI_CALL }
};
void CSkypeProto::InitIcons()
{
diff --git a/protocols/SkypeWeb/src/skype_messages.cpp b/protocols/SkypeWeb/src/skype_messages.cpp
index b5cb528aa7..26ce4c644b 100644
--- a/protocols/SkypeWeb/src/skype_messages.cpp
+++ b/protocols/SkypeWeb/src/skype_messages.cpp
@@ -66,6 +66,17 @@ 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)
+{
+ const char *message = Translate("Incoming call");
+ size_t messageLength = mir_strlen(message);
+ size_t cbBlob = messageLength;
+ PBYTE pBlob = (PBYTE)mir_alloc(cbBlob);
+ memcpy(pBlob, message, messageLength);
+
+ return AddEventToDb(hContact, SKYPE_DB_EVENT_TYPE_INCOMING_CALL, timestamp, flags, (DWORD)cbBlob, pBlob);
+}
+
/* MESSAGE RECEIVING */
// incoming message flow
diff --git a/protocols/SkypeWeb/src/skype_proto.cpp b/protocols/SkypeWeb/src/skype_proto.cpp
index cc30702395..1e2bc97e4b 100644
--- a/protocols/SkypeWeb/src/skype_proto.cpp
+++ b/protocols/SkypeWeb/src/skype_proto.cpp
@@ -52,6 +52,11 @@ PROTO<CSkypeProto>(protoName, userName), password(NULL)
dbEventType.eventType = SKYPE_DB_EVENT_TYPE_ACTION;
dbEventType.descr = Translate("Action");
CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&dbEventType);
+
+ dbEventType.eventType = SKYPE_DB_EVENT_TYPE_INCOMING_CALL;
+ dbEventType.descr = Translate("Incoming Call");
+ dbEventType.eventIcon = GetIconHandle("inc_call");
+ CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&dbEventType);
}
CSkypeProto::~CSkypeProto()
@@ -171,6 +176,8 @@ int CSkypeProto::SetStatus(int iNewStatus)
isTerminated = true;
if (m_pollingConnection)
CallService(MS_NETLIB_SHUTDOWN, (WPARAM)m_pollingConnection, 0);
+ if (m_TrouterConnection)
+ CallService(MS_NETLIB_SHUTDOWN, (WPARAM)m_TrouterConnection, 0);
if (m_iStatus > ID_STATUS_CONNECTING + 1)
{
@@ -246,6 +253,8 @@ int CSkypeProto::OnPreShutdown(WPARAM, LPARAM)
isTerminated = true;
if (m_pollingConnection)
CallService(MS_NETLIB_SHUTDOWN, (WPARAM)m_pollingConnection, 0);
+ if (m_TrouterConnection)
+ CallService(MS_NETLIB_SHUTDOWN, (WPARAM)m_TrouterConnection, 0);
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 85c7cfcbd7..52d4477b47 100644
--- a/protocols/SkypeWeb/src/skype_proto.h
+++ b/protocols/SkypeWeb/src/skype_proto.h
@@ -150,6 +150,7 @@ private:
void OnTrouterPoliciesCreated(const NETLIBHTTPREQUEST *response);
void OnGetTrouter(const NETLIBHTTPREQUEST *response);
void OnHealth(const NETLIBHTTPREQUEST *response);
+ void OnTrouterEvent(JSONNODE *body, JSONNODE *headers);
void __cdecl CSkypeProto::TRouterThread(void*);
// profile
@@ -206,7 +207,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);
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 2e0c24d996..06c09a72c8 100644
--- a/protocols/SkypeWeb/src/skype_trouter.cpp
+++ b/protocols/SkypeWeb/src/skype_trouter.cpp
@@ -89,6 +89,16 @@ void CSkypeProto::OnHealth(const NETLIBHTTPREQUEST *response)
SendRequest(new GetTrouterRequest(socketIo, connId, st, se, sig, instance, ccid), &CSkypeProto::OnGetTrouter);
}
+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")));
+
+ MCONTACT hContact = FindContact(_T2A(uid));
+ if (hContact != NULL)
+ AddCallToDb(hContact, time(NULL), 0);
+}
+
void CSkypeProto::TRouterThread(void*)
{
debugLogA(__FUNCTION__": entering");
@@ -133,14 +143,8 @@ void CSkypeProto::TRouterThread(void*)
JSONROOT root(json);
ptrA szBody(mir_t2a(ptrT(json_as_string(json_get(root, "body")))));
JSONNODE *headers = json_get(root, "headers");
-
JSONROOT jsonBody(szBody);
-
- ptrT displayname(json_as_string(json_get(jsonBody, "displayName")));
- ptrT uid(json_as_string(json_get(jsonBody, "conversationId")));
- MCONTACT hContact = FindContact(_T2A(uid));
- if (uid != NULL)
- ShowNotification(uid, TranslateT("Incoming call"), 0, hContact);
+ OnTrouterEvent(jsonBody, headers);
}
m_TrouterConnection = response->nlc;