diff options
-rw-r--r-- | protocols/VKontakte/src/misc.cpp | 35 | ||||
-rw-r--r-- | protocols/VKontakte/src/vk_avatars.cpp | 16 |
2 files changed, 27 insertions, 24 deletions
diff --git a/protocols/VKontakte/src/misc.cpp b/protocols/VKontakte/src/misc.cpp index e0b89acbff..4b6b9af959 100644 --- a/protocols/VKontakte/src/misc.cpp +++ b/protocols/VKontakte/src/misc.cpp @@ -78,7 +78,7 @@ MCONTACT CVkProto::FindChat(LONG dwUserid) bool CVkProto::CheckMid(int guid)
{
- for (int i=m_sendIds.getCount()-1; i >= 0; i--)
+ for (int i = m_sendIds.getCount() - 1; i >= 0; i--)
if ((int)m_sendIds[i] == guid) {
m_sendIds.remove(i);
return true;
@@ -217,22 +217,25 @@ static CMStringA getAttr(char *szSrc, LPCSTR szAttrName) return "";
*pEnd = 0;
+
char *p1 = strstr(szSrc, szAttrName);
if (p1 == NULL) {
-LBL_NotFound:
*pEnd = '>';
return "";
}
+
p1 += strlen(szAttrName);
- if (p1[0] != '=' || p1[1] != '\"')
- goto LBL_NotFound;
+ if (p1[0] != '=' || p1[1] != '\"'){
+ *pEnd = '>';
+ return "";
+ }
p1 += 2;
char *p2 = strchr(p1, '\"');
- if (p2 == NULL)
- goto LBL_NotFound;
-
*pEnd = '>';
+ if (p2 == NULL)
+ return "";
+
return CMStringA(p1, (int)(p2-p1));
}
@@ -262,20 +265,20 @@ bool CVkProto::AutoFillForm(char *pBody, CMStringA &szAction, CMStringA& szResul CMStringA name = getAttr(pFieldBeg, "name");
CMStringA value = getAttr(pFieldBeg, "value");
if (name == "email")
- value = ptrA( mir_utf8encodeT( ptrT( getTStringA("Login"))));
+ value = ptrA(mir_utf8encodeT(ptrT(getTStringA("Login"))));
else if (name == "pass")
- value = ptrA( mir_utf8encodeT( ptrT( GetUserStoredPassword())));
+ value = ptrA(mir_utf8encodeT(ptrT(GetUserStoredPassword())));
else if (name == "captcha_key") {
char *pCaptchaBeg = strstr(pFormBeg, "<img id=\"captcha\"");
if (pCaptchaBeg != NULL)
- if (!RunCaptchaForm( getAttr(pCaptchaBeg, "src"), value))
+ if (!RunCaptchaForm(getAttr(pCaptchaBeg, "src"), value))
return false;
}
if (!result.IsEmpty())
result.AppendChar('&');
result += name + "=";
- result += ptrA( mir_urlEncode(value));
+ result += ptrA(mir_urlEncode(value));
}
}
@@ -354,7 +357,7 @@ void CVkProto::GrabCookies(NETLIBHTTPREQUEST *nhr) {
debugLogA("CVkProto::GrabCookies");
for (int i=0; i < nhr->headersCount; i++) {
- if ( _stricmp(nhr->headers[i].szName, "Set-cookie"))
+ if (_stricmp(nhr->headers[i].szName, "Set-cookie"))
continue;
CMStringA szValue = nhr->headers[i].szValue, szCookieName, szCookieVal, szDomain;
@@ -462,7 +465,7 @@ MCONTACT CVkProto::MContactFromDbEvent(HANDLE hDbEvent) if (db_event_get(hDbEvent, &dbei)) return (MCONTACT)-1; - if ((dbei.eventType != EVENTTYPE_AUTHREQUEST) || (strcmp(dbei.szModule, m_szModuleName))) + if (dbei.eventType != EVENTTYPE_AUTHREQUEST || strcmp(dbei.szModule, m_szModuleName)) return (MCONTACT)-1; MCONTACT hContact = DbGetAuthEventContact(&dbei); @@ -539,7 +542,7 @@ bool tlstrstr(TCHAR* _s1, TCHAR* _s2) mir_sntprintf(s2, SIZEOF(s2), _T("%s"), _s2);
CharLowerBuff(s1, SIZEOF(s1));
CharLowerBuff(s2, SIZEOF(s2));
- return (_tcsstr(s1, s2) != NULL);
+ return _tcsstr(s1, s2) != NULL;
}
void CVkProto::ContactTypingThread(void *p)
@@ -571,7 +574,7 @@ void CVkProto::SetSrmmReadStatus(MCONTACT hContact) return; TCHAR ttime[64]; - _tcsftime(ttime, SIZEOF(ttime), _T("%X"), localtime(&time)); + _tcsftime(ttime, SIZEOF(ttime), L"%X", localtime(&time)); StatusTextData st = { 0 }; st.cbSize = sizeof(st); @@ -589,7 +592,7 @@ char* CVkProto::GetStickerId(const char* Msg, int &stickerid) if (iRes == 1){
mir_snprintf(HeadMsg, 32, "[sticker:%d]", stickerid);
size_t retLen = strlen(HeadMsg);
- if (retLen<strlen(Msg))
+ if (retLen < strlen(Msg))
retMsg = mir_strdup(&Msg[retLen]);
return retMsg;
}
diff --git a/protocols/VKontakte/src/vk_avatars.cpp b/protocols/VKontakte/src/vk_avatars.cpp index fc6cfee1a8..fc3ad42f6f 100644 --- a/protocols/VKontakte/src/vk_avatars.cpp +++ b/protocols/VKontakte/src/vk_avatars.cpp @@ -26,7 +26,7 @@ void CVkProto::OnReceiveAvatar(NETLIBHTTPREQUEST *reply, AsyncHttpRequest* pReq) GetAvatarFileName((MCONTACT)pReq->pUserInfo, AI.filename, SIZEOF(AI.filename));
AI.format = ProtoGetBufferFormat(reply->pData);
- FILE *out = _tfopen(AI.filename, _T("wb"));
+ FILE *out = _tfopen(AI.filename, L"wb");
if (out == NULL) {
ProtoBroadcastAck((MCONTACT)pReq->pUserInfo, ACKTYPE_AVATAR, ACKRESULT_FAILED, &AI, 0);
return;
@@ -75,7 +75,7 @@ INT_PTR CVkProto::SvcGetAvatarInfo(WPARAM wParam, LPARAM lParam) {
PROTO_AVATAR_INFORMATIONT* AI = (PROTO_AVATAR_INFORMATIONT*)lParam;
- ptrA szUrl( getStringA(AI->hContact, "AvatarUrl"));
+ ptrA szUrl(getStringA(AI->hContact, "AvatarUrl"));
if (szUrl == NULL)
return GAIR_NOAVATAR;
@@ -85,7 +85,7 @@ INT_PTR CVkProto::SvcGetAvatarInfo(WPARAM wParam, LPARAM lParam) AI->format = ProtoGetAvatarFormat(AI->filename);
- if ((::_taccess(AI->filename, 0) == 0) && !getBool(AI->hContact, "NeedNewAvatar", 0))
+ if (::_taccess(AI->filename, 0) == 0 && !getBool(AI->hContact, "NeedNewAvatar", 0))
return GAIR_SUCCESS;
if ( IsOnline()) {
@@ -125,7 +125,7 @@ INT_PTR CVkProto::SvcGetMyAvatar(WPARAM wParam, LPARAM lParam) void CVkProto::GetAvatarFileName(MCONTACT hContact, TCHAR* pszDest, size_t cbLen)
{
- int tPathLen = mir_sntprintf(pszDest, cbLen, _T("%s\\%S"), VARST(_T("%miranda_avatarcache%")), m_szModuleName);
+ int tPathLen = mir_sntprintf(pszDest, cbLen, L"%s\\%S", VARST(L"%miranda_avatarcache%"), m_szModuleName);
DWORD dwAttributes = GetFileAttributes(pszDest);
if (dwAttributes == 0xffffffff || (dwAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
@@ -133,8 +133,8 @@ void CVkProto::GetAvatarFileName(MCONTACT hContact, TCHAR* pszDest, size_t cbLen pszDest[ tPathLen++ ] = '\\';
- const TCHAR* szFileType = _T(".jpg");
- ptrT szUrl( getTStringA(hContact, "AvatarUrl"));
+ const TCHAR* szFileType = L".jpg";
+ ptrT szUrl(getTStringA(hContact, "AvatarUrl"));
if (szUrl) {
TCHAR *p = _tcsrchr(szUrl, '.');
if (p != NULL)
@@ -142,12 +142,12 @@ void CVkProto::GetAvatarFileName(MCONTACT hContact, TCHAR* pszDest, size_t cbLen }
LONG id = getDword(hContact, "ID", -1);
- mir_sntprintf(pszDest + tPathLen, MAX_PATH - tPathLen, _T("%d%s"), id, szFileType);
+ mir_sntprintf(pszDest + tPathLen, MAX_PATH - tPathLen, L"%d%s", id, szFileType);
}
void CVkProto::SetAvatarUrl(MCONTACT hContact, LPCTSTR ptszUrl)
{
- ptrT oldUrl( getTStringA(hContact, "AvatarUrl"));
+ ptrT oldUrl(getTStringA(hContact, "AvatarUrl"));
if (!lstrcmp(ptszUrl, oldUrl))
return;
|