summaryrefslogtreecommitdiff
path: root/protocols/SkypeWeb
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/SkypeWeb')
-rw-r--r--protocols/SkypeWeb/src/skype_polling.cpp31
-rw-r--r--protocols/SkypeWeb/src/skype_proto.h22
-rw-r--r--protocols/SkypeWeb/src/skype_utils.cpp5
3 files changed, 27 insertions, 31 deletions
diff --git a/protocols/SkypeWeb/src/skype_polling.cpp b/protocols/SkypeWeb/src/skype_polling.cpp
index 612547b1ee..b1b91a8d6f 100644
--- a/protocols/SkypeWeb/src/skype_polling.cpp
+++ b/protocols/SkypeWeb/src/skype_polling.cpp
@@ -17,39 +17,40 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "stdafx.h"
-void CSkypeProto::ParsePollData(const JSONNode &data)
+void CSkypeProto::ParsePollData(void *pData)
{
debugLogA("CSkypeProto::ParsePollData");
+ JSONNode data = JSONNode::parse(ptrA((char*)pData));
+ if (!data) return;
+
const JSONNode &node = data["eventMessages"];
- if (!node)
- return;
+ if (!node) return;
- const JSONNode &messages = node.as_array();
- for (size_t i = 0; i < messages.size(); i++)
+ for (auto it = node.begin(); it != node.end(); ++it)
{
- const JSONNode &message = messages.at(i);
+ const JSONNode &message = *it;
const JSONNode &resType = message["resourceType"];
const JSONNode &resource = message["resource"];
std::string resourceType = resType.as_string();
- if (!mir_strcmpi(resourceType.c_str(), "NewMessage"))
+ if (resourceType == "NewMessage")
{
ProcessNewMessageRes(resource);
}
- else if (!mir_strcmpi(resourceType.c_str(), "UserPresence"))
+ else if (resourceType == "UserPresence")
{
ProcessUserPresenceRes(resource);
}
- else if (!mir_strcmpi(resourceType.c_str(), "EndpointPresence"))
+ else if (resourceType == "EndpointPresence")
{
ProcessEndpointPresenceRes(resource);
}
- else if (!mir_strcmpi(resourceType.c_str(), "ConversationUpdate"))
+ else if (resourceType == "ConversationUpdate")
{
ProcessConversationUpdateRes(resource);
}
- else if (!mir_strcmpi(resourceType.c_str(), "ThreadUpdate"))
+ else if (resourceType == "ThreadUpdate")
{
ProcessThreadUpdateRes(resource);
}
@@ -79,11 +80,9 @@ void CSkypeProto::PollingThread(void*)
{
if (response->pData)
{
- JSONNode root = JSONNode::parse(response->pData);
- if (root["eventMessages"])
- {
- ParsePollData(root);
- }
+ void *pData = mir_alloc(response->dataLength);
+ memcpy(pData, response->pData, response->dataLength);
+ ForkThread(&CSkypeProto::ParsePollData, pData);
}
}
else
diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h
index ac07cb4eea..9e70268c7c 100644
--- a/protocols/SkypeWeb/src/skype_proto.h
+++ b/protocols/SkypeWeb/src/skype_proto.h
@@ -295,7 +295,7 @@ private:
//polling
void __cdecl PollingThread(void*);
- void ParsePollData(const JSONNode &data);
+ void __cdecl ParsePollData(void *pData);
void ProcessEndpointPresenceRes(const JSONNode &node);
void ProcessUserPresenceRes(const JSONNode &node);
void ProcessNewMessageRes(const JSONNode &node);
@@ -309,15 +309,17 @@ private:
{ return (m_iStatus > ID_STATUS_OFFLINE && m_hPollingThread);
}
- bool IsMe(const char *skypeName);
+ __forceinline bool IsMe(const char *szSkypename)
+ { return (!mir_strcmpi(szSkypename, m_szSelfSkypeName) || !mir_strcmp(szSkypename, ptrA(getStringA("SelfEndpointName"))));
+ }
MEVENT AddEventToDb(MCONTACT hContact, WORD type, DWORD timestamp, DWORD flags, DWORD cbBlob, PBYTE pBlob);
- time_t IsoToUnixTime(const char *stamp);
- char *RemoveHtml(const char *text);
- CMStringA GetStringChunk(const char *haystack, const char *start, const char *end);
+ static time_t IsoToUnixTime(const char *stamp);
+ static char *RemoveHtml(const char *text);
+ static CMStringA GetStringChunk(const char *haystack, const char *start, const char *end);
- int SkypeToMirandaStatus(const char *status);
- const char *MirandaToSkypeStatus(int status);
+ static int SkypeToMirandaStatus(const char *status);
+ static const char *MirandaToSkypeStatus(int status);
void ShowNotification(const TCHAR *message, MCONTACT hContact = NULL);
void ShowNotification(const TCHAR *caption, const TCHAR *message, MCONTACT hContact = NULL, int type = 0);
@@ -325,12 +327,12 @@ private:
static LRESULT CALLBACK PopupDlgProcCall(HWND hPopup, UINT uMsg, WPARAM wParam, LPARAM lParam);
- CMStringA ParseUrl(const char *url, const char *token);
+ static CMStringA ParseUrl(const char *url, const char *token);
void SetSrmmReadStatus(MCONTACT hContact);
- CMStringA UrlToSkypename(const char *url);
- CMStringA GetServerFromUrl(const char *url);
+ static CMStringA UrlToSkypename(const char *url);
+ static CMStringA GetServerFromUrl(const char *url);
//---Timers
void CALLBACK SkypeUnsetTimer();
diff --git a/protocols/SkypeWeb/src/skype_utils.cpp b/protocols/SkypeWeb/src/skype_utils.cpp
index 11e149adbc..756eba91d6 100644
--- a/protocols/SkypeWeb/src/skype_utils.cpp
+++ b/protocols/SkypeWeb/src/skype_utils.cpp
@@ -418,11 +418,6 @@ char *CSkypeProto::RemoveHtml(const char *text)
return mir_strdup(new_string.c_str());
}
-bool CSkypeProto::IsMe(const char *skypeName)
-{
- return (!mir_strcmpi(skypeName, m_szSelfSkypeName) || !mir_strcmp(skypeName, ptrA(getStringA("SelfEndpointName"))));
-}
-
const char *CSkypeProto::MirandaToSkypeStatus(int status)
{
switch (status)