diff options
author | MikalaiR <nikolay.romanovich@narod.ru> | 2015-04-14 12:35:37 +0000 |
---|---|---|
committer | MikalaiR <nikolay.romanovich@narod.ru> | 2015-04-14 12:35:37 +0000 |
commit | fff952e50f44761fa85ca90819ac97c47e77b553 (patch) | |
tree | 156381ae99a3f4bae3dc42b2bc24650f67daa5a7 /protocols/SkypeWeb/src/skype_polling.cpp | |
parent | 67228766fe401efef624b9c24a14d2fb5248e56c (diff) |
SkypeWeb: More improvements.
git-svn-id: http://svn.miranda-ng.org/main/trunk@12802 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/SkypeWeb/src/skype_polling.cpp')
-rw-r--r-- | protocols/SkypeWeb/src/skype_polling.cpp | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/protocols/SkypeWeb/src/skype_polling.cpp b/protocols/SkypeWeb/src/skype_polling.cpp index 1472a2364b..be69a83bdd 100644 --- a/protocols/SkypeWeb/src/skype_polling.cpp +++ b/protocols/SkypeWeb/src/skype_polling.cpp @@ -14,7 +14,6 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
#include "common.h"
#define POLLING_ERRORS_LIMIT 3
@@ -30,26 +29,26 @@ void CSkypeProto::ParsePollData(JSONNODE *data) {
JSONNODE *message = json_at(messages, i);
JSONNODE *resType = json_get(message, "resourceType");
- TCHAR *resourceType = json_as_string(resType);
+ ptrA resourceType(mir_t2a(ptrT(json_as_string(resType))));
JSONNODE *resource = json_get(message, "resource");
- if (!mir_tstrcmpi(resourceType, L"NewMessage"))
+ if (!mir_strcmpi(resourceType, "NewMessage"))
{
ProcessNewMessageRes(resource);
}
- else if (!mir_tstrcmpi(resourceType, L"UserPresence"))
+ else if (!mir_strcmpi(resourceType, "UserPresence"))
{
ProcessUserPresenceRes(resource);
}
- else if (!mir_tstrcmpi(resourceType, L"EndpointPresence"))
+ else if (!mir_strcmpi(resourceType, "EndpointPresence"))
{
ProcessEndpointPresenceRes(resource);
}
- else if (!mir_tstrcmpi(resourceType, L"ConversationUpdate"))
+ else if (!mir_strcmpi(resourceType, "ConversationUpdate"))
{
ProcessConversationUpdateRes(resource);
}
- else if (!mir_tstrcmpi(resourceType, L"ThreadUpdate"))
+ else if (!mir_strcmpi(resourceType, "ThreadUpdate"))
{
ProcessThreadUpdateRes(resource);
}
@@ -72,21 +71,30 @@ void CSkypeProto::PollingThread(void*) request->nlc = m_pollingConnection;
NETLIBHTTPREQUEST *response = request->Send(m_hNetlibUser);
- if (response)
+ if (response == NULL)
+ {
+ errors++;
+ continue;
+ }
+
+ if (response->resultCode != 200)
{
- if (response->pData)
+ errors++;
+ }
+
+ if (response->pData)
+ {
+ JSONROOT root(response->pData);
+ JSONNODE *errorCode = json_get(root, "errorCode");
+ if (errorCode != NULL)
{
- JSONROOT root(response->pData);
- if (json_get(root, "errorCode") != NULL)
- {
- errors++;
- continue;
- }
- ParsePollData(root);
+ errors++;
+ debugLogA(__FUNCTION__": polling error %s", ptrA(mir_t2a(ptrT(json_as_string(errorCode)))));
}
- m_pollingConnection = response->nlc;
- CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)response);
+ ParsePollData(root);
}
+ m_pollingConnection = response->nlc;
+ CallService(MS_NETLIB_FREEHTTPREQUESTSTRUCT, 0, (LPARAM)response);
delete request;
}
@@ -96,7 +104,6 @@ void CSkypeProto::PollingThread(void*) debugLogA(__FUNCTION__": unexpected termination; switching protocol to offline");
SetStatus(ID_STATUS_OFFLINE);
}
-
m_hPollingThread = NULL;
m_pollingConnection = NULL;
debugLogA(__FUNCTION__": leaving");
|