From 5413f05df37646178533a24f80e0e0238982af36 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Sun, 5 Apr 2015 13:19:05 +0000 Subject: SkypeWeb: cleanup git-svn-id: http://svn.miranda-ng.org/main/trunk@12610 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/SkypeWeb/src/requests/endpoint.h | 7 +++-- protocols/SkypeWeb/src/skype_messages.cpp | 6 ++-- protocols/SkypeWeb/src/skype_poll_processing.cpp | 38 +++++++++++------------- protocols/SkypeWeb/src/skype_polling.cpp | 12 ++++---- protocols/SkypeWeb/src/skype_proto.cpp | 2 +- protocols/SkypeWeb/src/skype_request.cpp | 1 - 6 files changed, 31 insertions(+), 35 deletions(-) (limited to 'protocols/SkypeWeb') diff --git a/protocols/SkypeWeb/src/requests/endpoint.h b/protocols/SkypeWeb/src/requests/endpoint.h index bc5be2b096..11273e15cf 100644 --- a/protocols/SkypeWeb/src/requests/endpoint.h +++ b/protocols/SkypeWeb/src/requests/endpoint.h @@ -17,11 +17,12 @@ public: << CHAR_VALUE("Origin", "https://web.skype.com") << CHAR_VALUE("Connection", "keep-alive"); CMStringA data; + + int bitness = 32; #ifdef _WIN64 - data.AppendFormat ("{\"id\":\"messagingService\",\"type\":\"EndpointPresenceDoc\",\"selfLink\":\"uri\",\"privateInfo\":{\"epname\":\"Miranda\"},\"publicInfo\":{\"capabilities\":\"\",\"typ\":125,\"skypeNameVersion\":\"Miranda NG Skype\",\"nodeInfo\":\"xx\",\"version\":\"%s x64\"}}", MIRANDA_VERSION_STRING); -#else - data.AppendFormat("{\"id\":\"messagingService\",\"type\":\"EndpointPresenceDoc\",\"selfLink\":\"uri\",\"privateInfo\":{\"epname\":\"Miranda\"},\"publicInfo\":{\"capabilities\":\"\",\"typ\":125,\"skypeNameVersion\":\"Miranda NG Skype\",\"nodeInfo\":\"xx\",\"version\":\"%s x86\"}}", MIRANDA_VERSION_STRING); + bitness = 64; #endif + data.AppendFormat("{\"id\":\"messagingService\",\"type\":\"EndpointPresenceDoc\",\"selfLink\":\"uri\",\"privateInfo\":{\"epname\":\"Miranda\"},\"publicInfo\":{\"capabilities\":\"\",\"typ\":125,\"skypeNameVersion\":\"Miranda NG Skype\",\"nodeInfo\":\"xx\",\"version\":\"%s x%d\"}}", MIRANDA_VERSION_STRING, bitness); Body << VALUE(data); } diff --git a/protocols/SkypeWeb/src/skype_messages.cpp b/protocols/SkypeWeb/src/skype_messages.cpp index 6893feb2a3..577aef73cd 100644 --- a/protocols/SkypeWeb/src/skype_messages.cpp +++ b/protocols/SkypeWeb/src/skype_messages.cpp @@ -89,14 +89,14 @@ struct SendMessageParam // outcoming message flow int CSkypeProto::OnSendMessage(MCONTACT hContact, int flags, const char *szMessage) { - time_t timestamp = time(NULL); //InterlockedIncrement(&hMessageProcess); - if (!IsOnline()) { ProtoBroadcastAck(hContact, ACKTYPE_MESSAGE, ACKRESULT_FAILED, NULL, (LPARAM)"You cannot send when you are offline."); return 0; } + time_t timestamp = time(NULL); //InterlockedIncrement(&hMessageProcess); + SendMessageParam *param = new SendMessageParam(); param->hContact = hContact; param->hMessage = (HANDLE)timestamp; @@ -201,7 +201,7 @@ void CSkypeProto::OnGetServerHistory(const NETLIBHTTPREQUEST *response) bool isMe = IsMe(skypename); if (isMe) - flags |= DBEF_READ; + flags |= DBEF_SENT; MCONTACT hContact = IsMe(skypename) ? GetContact(ptrA(ContactUrlToName(conversationLink))) diff --git a/protocols/SkypeWeb/src/skype_poll_processing.cpp b/protocols/SkypeWeb/src/skype_poll_processing.cpp index fc20ed6683..fd55f67325 100644 --- a/protocols/SkypeWeb/src/skype_poll_processing.cpp +++ b/protocols/SkypeWeb/src/skype_poll_processing.cpp @@ -4,14 +4,14 @@ void CSkypeProto::ProcessEndpointPresenceRes(JSONNODE *node) { debugLogA("CSkypeProto::ProcessEndpointPresenceRes"); ptrA selfLink(mir_t2a(ptrT(json_as_string(json_get(node, "selfLink"))))); - char *skypename = ContactUrlToName(selfLink); + ptrA skypename(ContactUrlToName(selfLink)); if (skypename == NULL) return; MCONTACT hContact = GetContact(skypename); //"publicInfo":{"capabilities":"","typ":"11","skypeNameVersion":"0/7.1.0.105//","nodeInfo":"","version":"24"} JSONNODE *publicInfo = json_get(node, "publicInfo"); - if (publicInfo != NULL) + if (publicInfo != NULL) { ptrA skypeNameVersion(mir_t2a(ptrT(json_as_string(json_get(publicInfo, "skypeNameVersion"))))); ptrA version(mir_t2a(ptrT(json_as_string(json_get(publicInfo, "version"))))); @@ -42,9 +42,7 @@ void CSkypeProto::ProcessEndpointPresenceRes(JSONNODE *node) mir_snprintf(ver, SIZEOF(ver), "%s %s", skypeNameVersion, version); db_set_s(hContact, m_szModuleName, "MirVer", ver); } - } - } } @@ -54,18 +52,18 @@ void CSkypeProto::ProcessUserPresenceRes(JSONNODE *node) ptrA selfLink(mir_t2a(ptrT(json_as_string(json_get(node, "selfLink"))))); ptrA status(mir_t2a(ptrT(json_as_string(json_get(node, "status"))))); - char *skypename = ContactUrlToName(selfLink); + ptrA skypename(ContactUrlToName(selfLink)); if (skypename == NULL) { - if (IsMe(SelfUrlToName(selfLink))) + if (IsMe(ptrA(SelfUrlToName(selfLink)))) { - int iNewStatus = SkypeToMirandaStatus(status); - int old_status = m_iStatus; - m_iDesiredStatus = iNewStatus; - m_iStatus = iNewStatus; - if (old_status != iNewStatus) - ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, iNewStatus); - return; + int iNewStatus = SkypeToMirandaStatus(status); + int old_status = m_iStatus; + m_iDesiredStatus = iNewStatus; + m_iStatus = iNewStatus; + if (old_status != iNewStatus) + ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, iNewStatus); + return; } return; } @@ -80,17 +78,15 @@ void CSkypeProto::ProcessNewMessageRes(JSONNODE *node) ptrA messageType(mir_t2a(ptrT(json_as_string(json_get(node, "messagetype"))))); ptrA from(mir_t2a(ptrT(json_as_string(json_get(node, "from"))))); ptrA content(mir_t2a(ptrT(json_as_string(json_get(node, "content"))))); - ptrT composeTime(json_as_string (json_get(node, "composetime"))); + ptrT composeTime(json_as_string(json_get(node, "composetime"))); ptrA conversationLink(mir_t2a(ptrT(json_as_string(json_get(node, "conversationLink"))))); time_t timestamp = IsoToUnixTime(composeTime); - char *convname; if (strstr(conversationLink, "/19:")) - { - const char *chatname; - chatname = ContactUrlToName(conversationLink); - convname = mir_strdup(chatname); - return; //chats not supported - } + { + const char *chatname; + chatname = ContactUrlToName(conversationLink); + return; //chats not supported + } else if (strstr(conversationLink, "/8:")) { if (!mir_strcmpi(messageType, "Control/Typing")) diff --git a/protocols/SkypeWeb/src/skype_polling.cpp b/protocols/SkypeWeb/src/skype_polling.cpp index 528f9e7d53..5cd679aa8d 100644 --- a/protocols/SkypeWeb/src/skype_polling.cpp +++ b/protocols/SkypeWeb/src/skype_polling.cpp @@ -43,14 +43,14 @@ void CSkypeProto::ParsePollData(JSONNODE *data) void CSkypeProto::PollingThread(void*) { - debugLog(_T("CSkypeProto::PollingThread: entering")); + debugLogA(__FUNCTION__": entering"); ptrA regToken(getStringA("registrationToken")); - const char *server = getStringA("Server"); + ptrA server(getStringA("Server")); SubscriptionsRequest *request = new SubscriptionsRequest(regToken, server); - request->Send(m_hNetlibUser); - delete request; + request->Send(m_hNetlibUser); + delete request; int errors = 0; bool breaked = false; @@ -81,11 +81,11 @@ void CSkypeProto::PollingThread(void*) } m_hPollingThread = NULL; m_pollingConnection = NULL; - debugLog(_T("CSkypeProto::PollingThread: leaving")); + debugLogA(__FUNCTION__": leaving"); if (!isTerminated) { - debugLog(_T("CSkypeProto::PollingThread: unexpected termination; switching protocol to offline")); + debugLogA(__FUNCTION__": unexpected termination; switching protocol to offline"); SetStatus(ID_STATUS_OFFLINE); } } \ No newline at end of file diff --git a/protocols/SkypeWeb/src/skype_proto.cpp b/protocols/SkypeWeb/src/skype_proto.cpp index 38d466208b..35174e3eee 100644 --- a/protocols/SkypeWeb/src/skype_proto.cpp +++ b/protocols/SkypeWeb/src/skype_proto.cpp @@ -128,7 +128,7 @@ int CSkypeProto::SendContacts(MCONTACT, int, int, MCONTACT*) { return 0; } HANDLE CSkypeProto::SendFile(MCONTACT hContact, const PROTOCHAR *szDescription, PROTOCHAR **ppszFiles) { return 0; } int CSkypeProto::SendMsg(MCONTACT hContact, int flags, const char *msg) -{ +{ return OnSendMessage(hContact, flags, msg); } diff --git a/protocols/SkypeWeb/src/skype_request.cpp b/protocols/SkypeWeb/src/skype_request.cpp index b0026de980..be8c1f63dc 100644 --- a/protocols/SkypeWeb/src/skype_request.cpp +++ b/protocols/SkypeWeb/src/skype_request.cpp @@ -34,7 +34,6 @@ static void SkypeHttpResponse(const NETLIBHTTPREQUEST *response, void *arg) void CSkypeProto::PushRequest(HttpRequest *request) { requestQueue->Push(request); - return; } void CSkypeProto::PushRequest(HttpRequest *request, SkypeResponseCallback response) -- cgit v1.2.3