diff options
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/Gadu-Gadu/src/avatar.cpp | 8 | ||||
-rw-r--r-- | protocols/Gadu-Gadu/src/oauth.cpp | 6 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber.h | 1 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_file.cpp | 2 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_iqid.cpp | 3 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_svc.cpp | 3 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_util.cpp | 26 | ||||
-rw-r--r-- | protocols/JabberG/src/jabber_vcard.cpp | 5 |
8 files changed, 10 insertions, 44 deletions
diff --git a/protocols/Gadu-Gadu/src/avatar.cpp b/protocols/Gadu-Gadu/src/avatar.cpp index 42685a821f..400182613c 100644 --- a/protocols/Gadu-Gadu/src/avatar.cpp +++ b/protocols/Gadu-Gadu/src/avatar.cpp @@ -109,18 +109,14 @@ bool GGPROTO::getAvatarFileInfo(uin_t uin, char **avatarurl, char **avatarts) char *gg_avatarhash(char *param)
{
- mir_sha1_byte_t digest[MIR_SHA1_HASH_SIZE];
char *result;
- int i;
if (param == NULL || (result = (char *)mir_alloc(MIR_SHA1_HASH_SIZE * 2 + 1)) == NULL)
return NULL;
+ mir_sha1_byte_t digest[MIR_SHA1_HASH_SIZE];
mir_sha1_hash((BYTE*)param, (int)strlen(param), digest);
- for (i = 0; i < MIR_SHA1_HASH_SIZE; i++)
- mir_snprintf(result + (i<<1), 2, "%02x", digest[i]);
-
- return result;
+ return bin2hex(digest, sizeof(digest), result);
}
void GGPROTO::requestAvatarTransfer(HANDLE hContact, char *szAvatarURL)
diff --git a/protocols/Gadu-Gadu/src/oauth.cpp b/protocols/Gadu-Gadu/src/oauth.cpp index 701b0508bc..e2484a3838 100644 --- a/protocols/Gadu-Gadu/src/oauth.cpp +++ b/protocols/Gadu-Gadu/src/oauth.cpp @@ -273,11 +273,7 @@ char *oauth_generate_nonce() mir_md5_byte_t digest[16];
mir_md5_hash((BYTE*)(char*)str, (int)strlen(str), digest);
-
- char *result = (char *)mir_alloc(32 + 1);
- for (int i = 0; i < 16; i++)
- mir_snprintf(result + (i<<1), 2, "%02x", digest[i]);
- return result;
+ return bin2hex(digest, sizeof(digest), (char *)mir_alloc(32 + 1));
}
char *oauth_auth_header(const char *httpmethod, const char *url, OAUTHSIGNMETHOD signmethod,
diff --git a/protocols/JabberG/src/jabber.h b/protocols/JabberG/src/jabber.h index 294072106e..6303e824b2 100644 --- a/protocols/JabberG/src/jabber.h +++ b/protocols/JabberG/src/jabber.h @@ -744,7 +744,6 @@ TCHAR* __stdcall JabberStrFixLines(const TCHAR *str); char* __stdcall JabberUnixToDos(const char* str);
WCHAR* __stdcall JabberUnixToDosW(const WCHAR* str);
void __stdcall JabberHttpUrlDecode(TCHAR* str);
-TCHAR* __stdcall JabberHttpUrlEncode(const TCHAR *str);
int __stdcall JabberCombineStatus(int status1, int status2);
TCHAR* __stdcall JabberErrorStr(int errorCode);
TCHAR* __stdcall JabberErrorMsg(HXML errorNode, int* errorCode = NULL);
diff --git a/protocols/JabberG/src/jabber_file.cpp b/protocols/JabberG/src/jabber_file.cpp index aed856545a..62d1fa49ef 100644 --- a/protocols/JabberG/src/jabber_file.cpp +++ b/protocols/JabberG/src/jabber_file.cpp @@ -293,7 +293,7 @@ void __cdecl CJabberProto::FileServerThread(filetransfer *ft) else
p = ft->std.ptszFiles[i];
- TCHAR *pFileName = JabberHttpUrlEncode(p);
+ char *pFileName = mir_urlEncode( ptrA( mir_utf8encodeT(p)));
if (pFileName != NULL) {
int id = SerialNext();
if (ft->iqId) mir_free(ft->iqId);
diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp index f584333bbe..ea759258f5 100644 --- a/protocols/JabberG/src/jabber_iqid.cpp +++ b/protocols/JabberG/src/jabber_iqid.cpp @@ -1480,8 +1480,7 @@ LBL_ErrFormat: mir_sha1_init(&sha);
mir_sha1_append(&sha, (mir_sha1_byte_t*)(char*)body, resultLen);
mir_sha1_finish(&sha, digest);
- for (int i=0; i<20; i++)
- mir_snprintf(buffer + (i << 1), 2, "%02x", digest[i]);
+ bin2hex(digest, sizeof(digest), buffer);
GetAvatarFileName(hContact, tszFileName, SIZEOF(tszFileName));
_tcsncpy(AI.filename, tszFileName, SIZEOF(AI.filename));
diff --git a/protocols/JabberG/src/jabber_svc.cpp b/protocols/JabberG/src/jabber_svc.cpp index 6dd9166276..4048dccf74 100644 --- a/protocols/JabberG/src/jabber_svc.cpp +++ b/protocols/JabberG/src/jabber_svc.cpp @@ -324,8 +324,7 @@ INT_PTR __cdecl CJabberProto::JabberSetAvatar(WPARAM, LPARAM lParam) DeleteFile(tFileName);
char buf[MIR_SHA1_HASH_SIZE*2+1];
- for (int i=0; i<MIR_SHA1_HASH_SIZE; i++)
- mir_snprintf(buf + (i << 1), 2, "%02x", digest[i]);
+ bin2hex(digest, sizeof(digest), buf);
m_options.AvatarType = ProtoGetBufferFormat(pResult);
diff --git a/protocols/JabberG/src/jabber_util.cpp b/protocols/JabberG/src/jabber_util.cpp index f9488f09d9..a33c8640bd 100644 --- a/protocols/JabberG/src/jabber_util.cpp +++ b/protocols/JabberG/src/jabber_util.cpp @@ -349,8 +349,7 @@ char* __stdcall JabberSha1(char* str) char *result = (char*)mir_alloc(41);
if (result)
- for (int i=0; i < 20; i++)
- mir_snprintf(result + (i << 1), 2, "%02x", digest[i]);
+ bin2hex(digest, sizeof(digest), result);
return result;
}
@@ -437,26 +436,6 @@ WCHAR* __stdcall JabberUnixToDosW(const WCHAR* str) return res;
}
-TCHAR* __stdcall JabberHttpUrlEncode(const TCHAR *str)
-{
- TCHAR *p, *q, *res;
-
- if (str == NULL) return NULL;
- size_t size = 3 * _tcslen(str) + 1;
- res = (TCHAR *)mir_alloc(size);
- for (p = (TCHAR*)str, q = res; *p!='\0'; p++,q++) {
- if ((*p>='A' && *p<='Z') || (*p>='a' && *p<='z') || (*p>='0' && *p<='9') || strchr("$-_.+!*'(),", *p) != NULL) {
- *q = *p;
- }
- else {
- mir_sntprintf(q, size, _T("%%%02X"), *p);
- q += 2;
- }
- }
- *q = '\0';
- return res;
-}
-
void __stdcall JabberHttpUrlDecode(TCHAR* str)
{
TCHAR *p, *q;
@@ -1651,8 +1630,7 @@ void __cdecl CJabberProto::LoadHttpAvatars(void* param) mir_sha1_init(&sha);
mir_sha1_append(&sha, (mir_sha1_byte_t*)res->pData, res->dataLength);
mir_sha1_finish(&sha, digest);
- for (int i=0; i<20; i++)
- mir_snprintf(buffer + (i << 1), 2, "%02x", digest[i]);
+ bin2hex(digest, sizeof(digest), buffer);
ptrA cmpsha( getStringA(AI.hContact, "AvatarSaved"));
if (cmpsha == NULL || strnicmp(cmpsha, buffer, sizeof(buffer))) {
diff --git a/protocols/JabberG/src/jabber_vcard.cpp b/protocols/JabberG/src/jabber_vcard.cpp index d916441f3c..21cf96574c 100644 --- a/protocols/JabberG/src/jabber_vcard.cpp +++ b/protocols/JabberG/src/jabber_vcard.cpp @@ -1178,9 +1178,8 @@ void CJabberProto::SetServerVcard(BOOL bPhotoChanged, TCHAR* szPhotoFileName) mir_sha1_finish(&sha1ctx, digest);
char buf[MIR_SHA1_HASH_SIZE*2+1];
- for (int j=0; j<MIR_SHA1_HASH_SIZE; j++)
- mir_snprintf(buf + (j << 1), 2, "%02x", digest[j]);
-
+ bin2hex(digest, sizeof(digest), buf);
+
m_options.AvatarType = ProtoGetBufferFormat(buffer);
if (bPhotoChanged) {
|