summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMikalaiR <nikolay.romanovich@narod.ru>2015-08-09 09:09:29 +0000
committerMikalaiR <nikolay.romanovich@narod.ru>2015-08-09 09:09:29 +0000
commit45898e008336c419f9d4b07ccfa46fde30226db0 (patch)
tree1a3ea8a7e16df2005226c95948f50d5f9e8411ae
parent37293d2f4ab8a9ed5cb90ae606ff96f01bd72f78 (diff)
SkypeWeb: fix mirver, more optimizations
git-svn-id: http://svn.miranda-ng.org/main/trunk@14880 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r--protocols/SkypeWeb/src/skype_events.cpp2
-rw-r--r--protocols/SkypeWeb/src/skype_poll_processing.cpp85
-rw-r--r--protocols/SkypeWeb/src/skype_proto.cpp9
-rw-r--r--protocols/SkypeWeb/src/skype_utils.h21
4 files changed, 60 insertions, 57 deletions
diff --git a/protocols/SkypeWeb/src/skype_events.cpp b/protocols/SkypeWeb/src/skype_events.cpp
index b6442d1b93..637da3e35c 100644
--- a/protocols/SkypeWeb/src/skype_events.cpp
+++ b/protocols/SkypeWeb/src/skype_events.cpp
@@ -23,7 +23,7 @@ INT_PTR CSkypeProto::GetEventText(WPARAM, LPARAM lParam)
DBEVENTGETTEXT *pEvent = (DBEVENTGETTEXT *)lParam;
CMStringA szText;
- bool bUseBB = db_get_b(NULL, pEvent->dbei->szModule, "UseBBCodes", 1);
+ BOOL bUseBB = db_get_b(NULL, pEvent->dbei->szModule, "UseBBCodes", 1);
switch (pEvent->dbei->eventType)
{
case SKYPE_DB_EVENT_TYPE_EDITED_MESSAGE:
diff --git a/protocols/SkypeWeb/src/skype_poll_processing.cpp b/protocols/SkypeWeb/src/skype_poll_processing.cpp
index 06390a3a62..b005047d69 100644
--- a/protocols/SkypeWeb/src/skype_poll_processing.cpp
+++ b/protocols/SkypeWeb/src/skype_poll_processing.cpp
@@ -22,8 +22,6 @@ void CSkypeProto::ProcessEndpointPresenceRes(const JSONNode &node)
debugLogA("CSkypeProto::ProcessEndpointPresenceRes");
std::string selfLink = node["selfLink"].as_string();
CMStringA skypename(UrlToSkypename(selfLink.c_str()));
- if (skypename.IsEmpty())
- return;
MCONTACT hContact = FindContact(skypename);
if (hContact == NULL)
@@ -31,61 +29,48 @@ void CSkypeProto::ProcessEndpointPresenceRes(const JSONNode &node)
const JSONNode &publicInfo = node["publicInfo"];
const JSONNode &privateInfo = node["privateInfo"];
- CMStringA MirVer = "";
+ CMStringA MirVer;
if (publicInfo)
{
std::string skypeNameVersion = publicInfo["skypeNameVersion"].as_string();
std::string version = publicInfo["version"].as_string();
std::string typ = publicInfo["typ"].as_string();
- if (!typ.empty())
+ int iTyp = atoi(typ.c_str());
+ switch (iTyp)
{
- int iTyp = atoi(typ.c_str());
- switch (iTyp)
- {
- case 17:
- MirVer.Append("Skype (Android)");
- break;
- case 16:
- MirVer.Append("Skype (iOS)");
- break;
- case 12:
- MirVer.Append("Skype (WinRT)");
- break;
- case 15:
- MirVer.Append("Skype (WP)");
- break;
- case 13:
- MirVer.Append("Skype (OSX)");
+ case 0:
+ case 1:
+ MirVer.AppendFormat("Skype (Web) %s", ParseUrl(version.c_str(), "/"));
+ break;
+ case 10:
+ MirVer.AppendFormat("Skype (XBOX) %s", ParseUrl(skypeNameVersion.c_str(), "/"));
+ break;
+ case 17:
+ MirVer.AppendFormat("Skype (Android) %s", ParseUrl(skypeNameVersion.c_str(), "/"));
+ break;
+ case 16:
+ MirVer.AppendFormat("Skype (iOS) %s", ParseUrl(skypeNameVersion.c_str(), "/"));
+ break;
+ case 12:
+ MirVer.AppendFormat("Skype (WinRT) %s", ParseUrl(skypeNameVersion.c_str(), "/"));
+ break;
+ case 15:
+ MirVer.AppendFormat("Skype (WP) %s", ParseUrl(skypeNameVersion.c_str(), "/"));
+ break;
+ case 13:
+ MirVer.AppendFormat("Skype (OSX) %s", ParseUrl(skypeNameVersion.c_str(), "/"));
break;
- case 11:
- MirVer.Append("Skype (Windows)");
- break;
- case 14:
- MirVer.Append("Skype (Linux)");
- break;
- case 10:
- MirVer.Append("Skype (XBOX)");
- break;
- case 1:
- MirVer.Append("Skype (Web)");
- break;
- case 125:
- MirVer.Append("Miranda NG Skype");
- break;
- default:
- {
- if (!mir_strcmpi(typ.c_str(), "website"))
- MirVer.Append("Skype (Outlook)");
- else
- MirVer.Append("Skype (Unknown)");
- break;
- }
- }
- MirVer.AppendChar(' ');
- if (iTyp == 125)
- MirVer.Append(version.c_str());
- else
- MirVer.Append(ParseUrl(skypeNameVersion.c_str(), "/"));
+ case 11:
+ MirVer.AppendFormat("Skype (Windows) %s", ParseUrl(skypeNameVersion.c_str(), "/"));
+ break;
+ case 14:
+ MirVer.AppendFormat("Skype (Linux) %s", ParseUrl(skypeNameVersion.c_str(), "/"));
+ break;
+ case 125:
+ MirVer.AppendFormat("Miranda NG Skype %s", version.c_str());
+ break;
+ default:
+ MirVer.Append("Skype (Unknown)");
}
}
if (privateInfo != NULL)
diff --git a/protocols/SkypeWeb/src/skype_proto.cpp b/protocols/SkypeWeb/src/skype_proto.cpp
index 037b1a3c66..d8fc158319 100644
--- a/protocols/SkypeWeb/src/skype_proto.cpp
+++ b/protocols/SkypeWeb/src/skype_proto.cpp
@@ -118,12 +118,9 @@ MCONTACT CSkypeProto::AddToListByEvent(int, int, MEVENT hDbEvent)
if (dbei.eventType != EVENTTYPE_AUTHREQUEST)
return NULL;
- char *nick = (char*)(dbei.pBlob + sizeof(DWORD) * 2);
- char *firstName = nick + mir_strlen(nick) + 1;
- char *lastName = firstName + mir_strlen(firstName) + 1;
- char *skypename = lastName + mir_strlen(lastName) + 1;
-
- MCONTACT hContact = AddContact(skypename);
+ DB_AUTH_BLOB blob(dbei.pBlob);
+
+ MCONTACT hContact = AddContact(blob.get_id());
return hContact;
}
diff --git a/protocols/SkypeWeb/src/skype_utils.h b/protocols/SkypeWeb/src/skype_utils.h
index f4f7c14035..b50b65546a 100644
--- a/protocols/SkypeWeb/src/skype_utils.h
+++ b/protocols/SkypeWeb/src/skype_utils.h
@@ -35,6 +35,7 @@ class DB_AUTH_BLOB
pCurBlob += sizeof(DWORD);
*((PDWORD)pCurBlob) = (DWORD)hContact;
pCurBlob += sizeof(DWORD);
+
if (szNick) { mir_strcpy((char*)pCurBlob, szNick ); pCurBlob += mir_strlen(szNick ); } pCurBlob += 1;
if (szFirstName){ mir_strcpy((char*)pCurBlob, szFirstName); pCurBlob += mir_strlen(szFirstName); } pCurBlob += 1;
if (szLastName) { mir_strcpy((char*)pCurBlob, szLastName ); pCurBlob += mir_strlen(szLastName ); } pCurBlob += 1;
@@ -49,10 +50,30 @@ public:
DB_AUTH_BLOB(MCONTACT _hContact, LPCSTR nick, LPCSTR fname, LPCSTR lname, LPCSTR id, LPCSTR reason)
: hContact(_hContact), szNick(mir_strdup(nick)), szFirstName(mir_strdup(fname)), szLastName(mir_strdup(lname)), szId(mir_strdup(id)), szReason(mir_strdup(reason)) {}
+ __inline explicit DB_AUTH_BLOB(PBYTE blob)
+ {
+ PBYTE pCurBlob = blob;
+ pCurBlob += sizeof(DWORD);
+ hContact = *(PDWORD)pCurBlob;
+ pCurBlob += sizeof(DWORD);
+ szNick = mir_strdup((char*)pCurBlob); pCurBlob += mir_strlen((char*)pCurBlob) + 1;
+ szFirstName = mir_strdup((char*)pCurBlob); pCurBlob += mir_strlen((char*)pCurBlob) + 1;
+ szLastName = mir_strdup((char*)pCurBlob); pCurBlob += mir_strlen((char*)pCurBlob) + 1;
+ szId = mir_strdup((char*)pCurBlob); pCurBlob += mir_strlen((char*)pCurBlob) + 1;
+ szReason = mir_strdup((char*)pCurBlob);
+ }
+
__inline size_t size(){ return ((sizeof(DWORD) * 2) + (mir_strlen(szNick) + 1) + (mir_strlen(szFirstName) + 1) + (mir_strlen(szLastName) + 1) + (mir_strlen(szId) + 1) + (mir_strlen(szReason) + 1)); }
__inline operator char*(){ return (char*)makeBlob(); };
__inline operator BYTE*(){ return makeBlob(); };
+
+ __inline MCONTACT get_hcontact() { return hContact; }
+ __inline char *get_nick() { return mir_strdup(szNick); }
+ __inline char *get_firstname() { return mir_strdup(szFirstName); }
+ __inline char *get_lastname() { return mir_strdup(szLastName); }
+ __inline char *get_id() { return mir_strdup(szId); }
+ __inline char *get_reason() { return mir_strdup(szReason); }
};