From b96fa2b498afb19bda93d0cd1e399589d17d3d3e Mon Sep 17 00:00:00 2001 From: MikalaiR Date: Sat, 2 May 2015 11:27:20 +0000 Subject: SkypeWeb: Sound on call cancel. Minor fixes. git-svn-id: http://svn.miranda-ng.org/main/trunk@13369 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/SkypeWeb/src/skype_chatrooms.cpp | 4 ++-- protocols/SkypeWeb/src/skype_proto.cpp | 34 +++++++++++++++++++++++++++--- protocols/SkypeWeb/src/skype_trouter.cpp | 7 +++--- 3 files changed, 37 insertions(+), 8 deletions(-) (limited to 'protocols/SkypeWeb/src') diff --git a/protocols/SkypeWeb/src/skype_chatrooms.cpp b/protocols/SkypeWeb/src/skype_chatrooms.cpp index 24d77aef8d..0477c27fdb 100644 --- a/protocols/SkypeWeb/src/skype_chatrooms.cpp +++ b/protocols/SkypeWeb/src/skype_chatrooms.cpp @@ -328,8 +328,8 @@ void CSkypeProto::OnChatEvent(JSONNODE *node) { HXML xmlId = xi.getChildByPath(xmlNode, _T("id"), 0); HXML xmlRole = xi.getChildByPath(xmlNode, _T("role"), 0); - xId = xmlNode != NULL ? mir_t2a(xi.getText(xmlId)) : NULL; - xRole = xmlNode != NULL ? mir_t2a(xi.getText(xmlRole)) : NULL; + xId = xmlId != NULL ? mir_t2a(xi.getText(xmlId)) : NULL; + xRole = xmlRole != NULL ? mir_t2a(xi.getText(xmlRole)) : NULL; } xi.destroyNode(xml); initiator = ParseUrl(xinitiator, "8:"); diff --git a/protocols/SkypeWeb/src/skype_proto.cpp b/protocols/SkypeWeb/src/skype_proto.cpp index b11462fdd4..0d3b1f7578 100644 --- a/protocols/SkypeWeb/src/skype_proto.cpp +++ b/protocols/SkypeWeb/src/skype_proto.cpp @@ -60,10 +60,13 @@ PROTO(protoName, userName), password(NULL) dbEventType.descr = Translate("Incoming call"); dbEventType.eventIcon = GetIconHandle("inc_call"); CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&dbEventType); + //hooks m_hCallHook = CreateHookableEvent(MODULE"/IncomingCall"); + //sounds - SkinAddNewSoundEx("skype_inc_call", "SkypeWeb", LPGEN("Incoming call sound")); + SkinAddNewSoundEx("skype_inc_call", "SkypeWeb", LPGEN("Incoming call sound") ); + SkinAddNewSoundEx("skype_call_canceled", "SkypeWeb", LPGEN("Incoming call canceled sound") ); } CSkypeProto::~CSkypeProto() @@ -107,7 +110,30 @@ MCONTACT CSkypeProto::AddToList(int, PROTOSEARCHRESULT *psr) return hContact; } -MCONTACT CSkypeProto::AddToListByEvent(int, int, MEVENT) { return 0; } +MCONTACT CSkypeProto::AddToListByEvent(int, int, MEVENT hDbEvent) +{ + DBEVENTINFO dbei = { sizeof(dbei) }; + if ((dbei.cbBlob = db_event_getBlobSize(hDbEvent)) == (DWORD)(-1)) + return NULL; + if ((dbei.pBlob=(PBYTE)alloca(dbei.cbBlob)) == NULL) + return NULL; + if (db_event_get(hDbEvent, &dbei)) + return NULL; + if (strcmp(dbei.szModule, m_szModuleName)) + return NULL; + if (dbei.eventType != EVENTTYPE_AUTHREQUEST) + return NULL; + + char *nick = (char*)(dbei.pBlob + sizeof(DWORD)*2); + char *firstName = nick + strlen(nick) + 1; + char *lastName = firstName + strlen(firstName) + 1; + char *skypename = lastName + strlen(lastName) + 1; + + char *newSkypename = (dbei.flags & DBEF_UTF) ? mir_utf8decodeA(skypename) : skypename; + MCONTACT hContact = AddContact(newSkypename); + mir_free(newSkypename); + return hContact; +} int CSkypeProto::Authorize(MEVENT hDbEvent) { @@ -256,12 +282,14 @@ int CSkypeProto::OnEvent(PROTOEVENTTYPE iEventType, WPARAM wParam, LPARAM lParam int CSkypeProto::OnPreShutdown(WPARAM, LPARAM) { debugLogA(__FUNCTION__); - + isTerminated = true; if (m_pollingConnection) CallService(MS_NETLIB_SHUTDOWN, (WPARAM)m_pollingConnection, 0); if (m_TrouterConnection) CallService(MS_NETLIB_SHUTDOWN, (WPARAM)m_TrouterConnection, 0); + requestQueue->Stop(); + return 0; } \ No newline at end of file diff --git a/protocols/SkypeWeb/src/skype_trouter.cpp b/protocols/SkypeWeb/src/skype_trouter.cpp index ff45e744cd..854a4e75d7 100644 --- a/protocols/SkypeWeb/src/skype_trouter.cpp +++ b/protocols/SkypeWeb/src/skype_trouter.cpp @@ -28,7 +28,7 @@ void CSkypeProto::OnCreateTrouter(const NETLIBHTTPREQUEST *response) ptrA instance(mir_t2a(ptrT(json_as_string(json_get(root, "instance"))))); ptrA socketio(mir_t2a(ptrT(json_as_string(json_get(root, "socketio"))))); ptrA url(mir_t2a(ptrT(json_as_string(json_get(root, "url"))))); - setString("Trouter_ccid", ccid); + setString("Trouter_ccid", ccid); setString("Trouter_connId", connId); setString("Trouter_instance", instance); setString("Trouter_socketio", socketio); @@ -130,6 +130,7 @@ void CSkypeProto::OnTrouterEvent(JSONNODE *body, JSONNODE *headers) case 104: //call canceled: callerId=""; conversationId=NULL; callId=call id { ptrA callId(mir_t2a(ptrT(json_as_string(json_get(body, "callId"))))); + SkinPlaySound("skype_call_canceled"); break; } } @@ -179,8 +180,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); - OnTrouterEvent(jsonBody, headers); + JSONNODE *body = json_parse(szBody); + OnTrouterEvent(body, headers); } m_TrouterConnection = response->nlc; -- cgit v1.2.3