summaryrefslogtreecommitdiff
path: root/protocols/JabberG
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2013-08-15 08:01:11 +0000
committerGeorge Hazan <george.hazan@gmail.com>2013-08-15 08:01:11 +0000
commitc68165979e5741aa201a9ac951e37fee4ca362cc (patch)
tree61313e23466d16a31904b442ca2ee20f738926c9 /protocols/JabberG
parent6082f8c569cd3df0ebdcec61a223027868207473 (diff)
we use bin2hex now instead of mir_snprintf("%02x")
git-svn-id: http://svn.miranda-ng.org/main/trunk@5699 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/JabberG')
-rw-r--r--protocols/JabberG/src/jabber.h1
-rw-r--r--protocols/JabberG/src/jabber_file.cpp2
-rw-r--r--protocols/JabberG/src/jabber_iqid.cpp3
-rw-r--r--protocols/JabberG/src/jabber_svc.cpp3
-rw-r--r--protocols/JabberG/src/jabber_util.cpp26
-rw-r--r--protocols/JabberG/src/jabber_vcard.cpp5
6 files changed, 7 insertions, 33 deletions
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) {