summaryrefslogtreecommitdiff
path: root/protocols/JabberG
diff options
context:
space:
mode:
authorGeorge Hazan <george.hazan@gmail.com>2015-05-22 16:04:17 +0000
committerGeorge Hazan <george.hazan@gmail.com>2015-05-22 16:04:17 +0000
commite2c2a1f5a84c6c9b705dc85c6a2dd1f97edd57e4 (patch)
treeba79bdcede96f80039f8b88d2791f198b9ec2981 /protocols/JabberG
parentf8e34b5f83f3ce5f39d541e9068b6b8cb6d92acd (diff)
T2Utf - handy replacement for ptrA<mir_utf8decodeT()>
git-svn-id: http://svn.miranda-ng.org/main/trunk@13758 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/JabberG')
-rw-r--r--protocols/JabberG/src/jabber_archive.cpp4
-rw-r--r--protocols/JabberG/src/jabber_byte.cpp19
-rw-r--r--protocols/JabberG/src/jabber_file.cpp4
-rw-r--r--protocols/JabberG/src/jabber_iqid.cpp2
-rw-r--r--protocols/JabberG/src/jabber_misc.cpp11
-rw-r--r--protocols/JabberG/src/jabber_opt.cpp5
-rw-r--r--protocols/JabberG/src/jabber_proto.cpp4
-rw-r--r--protocols/JabberG/src/jabber_secur.cpp9
-rw-r--r--protocols/JabberG/src/jabber_thread.cpp8
9 files changed, 27 insertions, 39 deletions
diff --git a/protocols/JabberG/src/jabber_archive.cpp b/protocols/JabberG/src/jabber_archive.cpp
index 18fbec6911..21e686c742 100644
--- a/protocols/JabberG/src/jabber_archive.cpp
+++ b/protocols/JabberG/src/jabber_archive.cpp
@@ -288,14 +288,14 @@ void CJabberProto::OnIqResultGetCollection(HXML iqNode, CJabberIqInfo*)
if (!tszBody || !tszSecs)
continue;
- ptrA szEventText( mir_utf8encodeT(tszBody));
+ T2Utf szEventText(tszBody);
DBEVENTINFO dbei = { sizeof(DBEVENTINFO) };
dbei.eventType = EVENTTYPE_MESSAGE;
dbei.szModule = m_szModuleName;
dbei.cbBlob = (DWORD)mir_strlen(szEventText);
dbei.flags = DBEF_READ + DBEF_UTF + from;
- dbei.pBlob = (PBYTE)(char*)szEventText;
+ dbei.pBlob = szEventText;
dbei.timestamp = tmStart + _ttol(tszSecs) - timezone;
if (!IsDuplicateEvent(hContact, dbei))
db_event_add(hContact, &dbei);
diff --git a/protocols/JabberG/src/jabber_byte.cpp b/protocols/JabberG/src/jabber_byte.cpp
index b9910d9b5d..ffbc79d77f 100644
--- a/protocols/JabberG/src/jabber_byte.cpp
+++ b/protocols/JabberG/src/jabber_byte.cpp
@@ -367,7 +367,7 @@ int CJabberProto::ByteSendParse(HANDLE hConn, JABBER_BYTE_TRANSFER *jbt, char* b
mir_free(szInitiatorJid);
mir_free(szTargetJid);
- ptrA szAuthString(mir_utf8encodeT(text));
+ T2Utf szAuthString(text);
debugLogA("Auth: '%s'", szAuthString);
JabberShaStrBuf buf;
@@ -516,7 +516,7 @@ int CJabberProto::ByteSendProxyParse(HANDLE hConn, JABBER_BYTE_TRANSFER *jbt, ch
mir_free(szInitiatorJid);
mir_free(szTargetJid);
- char* szAuthString = mir_utf8encodeT(text);
+ T2Utf szAuthString(text);
debugLogA("Auth: '%s'", szAuthString);
JabberShaStrBuf buf;
@@ -524,7 +524,6 @@ int CJabberProto::ByteSendProxyParse(HANDLE hConn, JABBER_BYTE_TRANSFER *jbt, ch
Netlib_Send(hConn, (char*)data, 47, 0);
jbt->state = JBT_CONNECT;
- mir_free(szAuthString);
}
else jbt->state = JBT_SOCKSERR;
break;
@@ -705,12 +704,13 @@ int CJabberProto::ByteReceiveParse(HANDLE hConn, JABBER_BYTE_TRANSFER *jbt, char
data[4] = 40;
TCHAR text[JABBER_MAX_JID_LEN * 2];
- TCHAR *szInitiatorJid = JabberPrepareJid(jbt->srcJID);
- TCHAR *szTargetJid = JabberPrepareJid(jbt->dstJID);
- mir_sntprintf(text, SIZEOF(text), _T("%s%s%s"), jbt->sid, szInitiatorJid, szTargetJid);
- mir_free(szInitiatorJid);
- mir_free(szTargetJid);
- char* szAuthString = mir_utf8encodeT(text);
+ {
+ ptrT szInitiatorJid(JabberPrepareJid(jbt->srcJID));
+ ptrT szTargetJid(JabberPrepareJid(jbt->dstJID));
+ mir_sntprintf(text, SIZEOF(text), _T("%s%s%s"), jbt->sid, szInitiatorJid, szTargetJid);
+ }
+
+ T2Utf szAuthString(text);
debugLogA("Auth: '%s'", szAuthString);
JabberShaStrBuf buf;
@@ -718,7 +718,6 @@ int CJabberProto::ByteReceiveParse(HANDLE hConn, JABBER_BYTE_TRANSFER *jbt, char
Netlib_Send(hConn, (char*)data, 47, 0);
jbt->state = JBT_CONNECT;
- mir_free(szAuthString);
}
else jbt->state = JBT_SOCKSERR;
break;
diff --git a/protocols/JabberG/src/jabber_file.cpp b/protocols/JabberG/src/jabber_file.cpp
index 1c51a3b87e..d962cac51e 100644
--- a/protocols/JabberG/src/jabber_file.cpp
+++ b/protocols/JabberG/src/jabber_file.cpp
@@ -277,7 +277,7 @@ void __cdecl CJabberProto::FileServerThread(filetransfer *ft)
else
p = ft->std.ptszFiles[i];
- char *pFileName = mir_urlEncode(ptrA(mir_utf8encodeT(p)));
+ ptrA pFileName(mir_urlEncode(T2Utf(p)));
if (pFileName != NULL) {
ft->szId = JabberId2string(SerialNext());
@@ -290,8 +290,6 @@ void __cdecl CJabberProto::FileServerThread(filetransfer *ft)
char szAddr[256];
mir_snprintf(szAddr, SIZEOF(szAddr), "http://%s:%d/%s", myAddr, nlb.wPort, pFileName);
- mir_free(pFileName);
-
size_t len = mir_tstrlen(ptszResource) + mir_tstrlen(ft->jid) + 2;
TCHAR *fulljid = (TCHAR *)alloca(sizeof(TCHAR) * len);
mir_sntprintf(fulljid, len, _T("%s/%s"), ft->jid, ptszResource);
diff --git a/protocols/JabberG/src/jabber_iqid.cpp b/protocols/JabberG/src/jabber_iqid.cpp
index a109b3bea3..59594259fa 100644
--- a/protocols/JabberG/src/jabber_iqid.cpp
+++ b/protocols/JabberG/src/jabber_iqid.cpp
@@ -217,7 +217,7 @@ void CJabberProto::OnIqResultGetAuth(HXML iqNode, CJabberIqInfo*)
query << XCHILD(_T("username"), m_ThreadInfo->conn.username);
if (xmlGetChild(queryNode, "digest") != NULL && m_ThreadInfo->szStreamId) {
JabberShaStrBuf buf;
- ptrA str(mir_utf8encodeT(m_ThreadInfo->conn.password));
+ T2Utf str(m_ThreadInfo->conn.password);
char text[200];
mir_snprintf(text, SIZEOF(text), "%s%s", m_ThreadInfo->szStreamId, str);
query << XCHILD(_T("digest"), _A2T(JabberSha1(text, buf)));
diff --git a/protocols/JabberG/src/jabber_misc.cpp b/protocols/JabberG/src/jabber_misc.cpp
index 7072c507db..672857fe74 100644
--- a/protocols/JabberG/src/jabber_misc.cpp
+++ b/protocols/JabberG/src/jabber_misc.cpp
@@ -73,11 +73,11 @@ void CJabberProto::DBAddAuthRequest(const TCHAR *jid, const TCHAR *nick)
MCONTACT hContact = DBCreateContact(jid, nick, TRUE, TRUE);
delSetting(hContact, "Hidden");
- char* szJid = mir_utf8encodeT(jid);
- char* szNick = mir_utf8encodeT(nick);
+ T2Utf szJid(jid);
+ T2Utf szNick(nick);
- //blob is: uin(DWORD), hContact(DWORD), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ), reason(ASCIIZ)
- //blob is: 0(DWORD), hContact(DWORD), nick(ASCIIZ), ""(ASCIIZ), ""(ASCIIZ), email(ASCIIZ), ""(ASCIIZ)
+ // blob is: uin(DWORD), hContact(DWORD), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ), reason(ASCIIZ)
+ // blob is: 0(DWORD), hContact(DWORD), nick(ASCIIZ), ""(ASCIIZ), ""(ASCIIZ), email(ASCIIZ), ""(ASCIIZ)
DBEVENTINFO dbei = { sizeof(DBEVENTINFO) };
dbei.szModule = m_szModuleName;
dbei.timestamp = (DWORD)time(NULL);
@@ -95,9 +95,6 @@ void CJabberProto::DBAddAuthRequest(const TCHAR *jid, const TCHAR *nick)
db_event_add(NULL, &dbei);
debugLogA("Setup DBAUTHREQUEST with nick='%s' jid='%s'", szNick, szJid);
-
- mir_free(szJid);
- mir_free(szNick);
}
///////////////////////////////////////////////////////////////////////////////
diff --git a/protocols/JabberG/src/jabber_opt.cpp b/protocols/JabberG/src/jabber_opt.cpp
index 5afc459a87..bdf8e06dc0 100644
--- a/protocols/JabberG/src/jabber_opt.cpp
+++ b/protocols/JabberG/src/jabber_opt.cpp
@@ -1232,11 +1232,8 @@ void CJabberProto::_RosterExportToFile(HWND hwndDlg)
fwrite(header, 1, sizeof(header) - 1 /* for zero terminator */, fp);
TCHAR *xtmp = xi.toString(root, NULL);
- char *tmp = mir_utf8encodeT(xtmp);
+ fputs(T2Utf(xtmp), fp);
xi.freeMem(xtmp);
-
- fwrite(tmp, 1, mir_strlen(tmp), fp);
- mir_free(tmp);
fclose(fp);
}
diff --git a/protocols/JabberG/src/jabber_proto.cpp b/protocols/JabberG/src/jabber_proto.cpp
index ac27168eb1..c7b61995a2 100644
--- a/protocols/JabberG/src/jabber_proto.cpp
+++ b/protocols/JabberG/src/jabber_proto.cpp
@@ -804,8 +804,8 @@ HANDLE __cdecl CJabberProto::SearchByName(const TCHAR *nick, const TCHAR *firstN
int __cdecl CJabberProto::RecvMsg(MCONTACT hContact, PROTORECVEVENT *evt)
{
- ptrA szResUtf(mir_utf8encodeT((LPCTSTR)evt->lParam));
- evt->pCustomData = szResUtf;
+ T2Utf szResUtf((LPCTSTR)evt->lParam);
+ evt->pCustomData = (char*)szResUtf;
evt->cbCustomDataSize = (DWORD)mir_strlen(szResUtf);
Proto_RecvMessage(hContact, evt);
return 0;
diff --git a/protocols/JabberG/src/jabber_secur.cpp b/protocols/JabberG/src/jabber_secur.cpp
index ce2cafb2fc..a364050197 100644
--- a/protocols/JabberG/src/jabber_secur.cpp
+++ b/protocols/JabberG/src/jabber_secur.cpp
@@ -157,9 +157,8 @@ char* TMD5Auth::getChallenge(const TCHAR *challenge)
CallService(MS_UTILS_GETRANDOM, sizeof(digest), (LPARAM)digest);
mir_snprintf(cnonce, SIZEOF(cnonce), "%08x%08x%08x%08x", htonl(digest[0]), htonl(digest[1]), htonl(digest[2]), htonl(digest[3]));
- ptrA uname(mir_utf8encodeT(info->conn.username)),
- passw(mir_utf8encodeT(info->conn.password)),
- serv(mir_utf8encode(info->conn.server));
+ T2Utf uname(info->conn.username), passw(info->conn.password);
+ ptrA serv(mir_utf8encode(info->conn.server));
mir_md5_init(&ctx);
mir_md5_append(&ctx, (BYTE*)(char*)uname, (int)mir_strlen(uname));
@@ -304,7 +303,7 @@ char* TScramAuth::getChallenge(const TCHAR *challenge)
char* TScramAuth::getInitialRequest()
{
- ptrA uname(mir_utf8encodeT(info->conn.username));
+ T2Utf uname(info->conn.username);
unsigned char nonce[24];
CallService(MS_UTILS_GETRANDOM, sizeof(nonce), (LPARAM)nonce);
@@ -339,7 +338,7 @@ TPlainAuth::~TPlainAuth()
char* TPlainAuth::getInitialRequest()
{
- ptrA uname(mir_utf8encodeT(info->conn.username)), passw(mir_utf8encodeT(info->conn.password));
+ T2Utf uname(info->conn.username), passw(info->conn.password);
size_t size = 2 * mir_strlen(uname) + mir_strlen(passw) + mir_strlen(info->conn.server) + 4;
char *toEncode = (char*)alloca(size);
diff --git a/protocols/JabberG/src/jabber_thread.cpp b/protocols/JabberG/src/jabber_thread.cpp
index 917a0af363..c5c18a6453 100644
--- a/protocols/JabberG/src/jabber_thread.cpp
+++ b/protocols/JabberG/src/jabber_thread.cpp
@@ -205,15 +205,14 @@ void CJabberProto::xmlStreamInitializeNow(ThreadData *info)
xmlAddAttr(stream, _T("version"), _T("1.0"));
LPTSTR xmlQuery = xi.toString(n, NULL);
- char* buf = mir_utf8encodeT(xmlQuery);
+ T2Utf buf(xmlQuery);
int bufLen = (int)mir_strlen(buf);
if (bufLen > 2) {
- strdel(buf + bufLen - 2, 1);
+ strdel((char*)buf + bufLen - 2, 1);
bufLen--;
}
info->send(buf, bufLen);
- mir_free(buf);
xi.freeMem(xmlQuery);
xi.destroyNode(n);
}
@@ -1987,9 +1986,8 @@ int ThreadData::send(HXML node)
*q = 0;
- char* utfStr = mir_utf8encodeT(str);
+ T2Utf utfStr(str);
int result = send(utfStr, (int)mir_strlen(utfStr));
- mir_free(utfStr);
xi.freeMem(str);
return result;