From 6163df27ad6fd2a5da5d9bbb48bb457d8a07a2b6 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Mon, 16 Jan 2017 18:20:37 +0300 Subject: DB_AUTH_BLOB: handy piece of code moved into the core --- protocols/IcqOscarJ/src/fam_04message.cpp | 17 ++++--------- protocols/IcqOscarJ/src/fam_13servclist.cpp | 37 ++++++----------------------- 2 files changed, 12 insertions(+), 42 deletions(-) (limited to 'protocols/IcqOscarJ/src') diff --git a/protocols/IcqOscarJ/src/fam_04message.cpp b/protocols/IcqOscarJ/src/fam_04message.cpp index 1d2b182bd9..ff2438da29 100644 --- a/protocols/IcqOscarJ/src/fam_04message.cpp +++ b/protocols/IcqOscarJ/src/fam_04message.cpp @@ -1627,20 +1627,13 @@ void CIcqProto::handleMessageTypes(DWORD dwUin, char *szUID, DWORD dwTimestamp, break; } { + DB_AUTH_BLOB blob(hContact, pszMsgField[0], pszMsgField[1], pszMsgField[2], pszMsgField[3], pszMsgField[5]); + *(PBYTE)blob = dwUin; + PROTORECVEVENT pre = { 0 }; pre.timestamp = dwTimestamp; - pre.lParam = sizeof(DWORD) * 2 + mir_strlen(pszMsgField[0]) + mir_strlen(pszMsgField[1]) + mir_strlen(pszMsgField[2]) + mir_strlen(pszMsgField[3]) + mir_strlen(pszMsgField[5]) + 5; - - // blob is: uin(DWORD), hcontact(HANDLE), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ), reason(ASCIIZ) - char *szBlob, *pCurBlob = szBlob = (char *)_alloca(pre.lParam); - *(DWORD*)pCurBlob = dwUin; pCurBlob += sizeof(DWORD); - *(DWORD*)pCurBlob = DWORD(hContact); pCurBlob += sizeof(DWORD); - mir_strcpy((char*)pCurBlob, pszMsgField[0]); pCurBlob += mir_strlen((char*)pCurBlob) + 1; - mir_strcpy((char*)pCurBlob, pszMsgField[1]); pCurBlob += mir_strlen((char*)pCurBlob) + 1; - mir_strcpy((char*)pCurBlob, pszMsgField[2]); pCurBlob += mir_strlen((char*)pCurBlob) + 1; - mir_strcpy((char*)pCurBlob, pszMsgField[3]); pCurBlob += mir_strlen((char*)pCurBlob) + 1; - mir_strcpy((char*)pCurBlob, pszMsgField[5]); - pre.szMessage = (char *)szBlob; + pre.lParam = blob.size(); + pre.szMessage = blob; ProtoChainRecv(hContact, PSR_AUTH, 0, (LPARAM)&pre); } break; diff --git a/protocols/IcqOscarJ/src/fam_13servclist.cpp b/protocols/IcqOscarJ/src/fam_13servclist.cpp index 3c11e20a7f..3e7b1004db 100644 --- a/protocols/IcqOscarJ/src/fam_13servclist.cpp +++ b/protocols/IcqOscarJ/src/fam_13servclist.cpp @@ -1377,53 +1377,30 @@ void CIcqProto::handleRecvAuthRequest(unsigned char *buf, size_t wLen) int bAdded; MCONTACT hContact = HContactFromUID(dwUin, szUid, &bAdded); - PROTORECVEVENT pre = { 0 }; - pre.timestamp = time(NULL); - pre.lParam = sizeof(DWORD) * 2 + 5; // Prepare reason char *szReason = (char*)SAFE_MALLOC(wReasonLen + 1); - int nReasonLen = 0; if (szReason) { memcpy(szReason, buf, wReasonLen); szReason[wReasonLen] = '\0'; - nReasonLen = (int)mir_strlen(szReason); } // Read nick name from DB - char *szNick = NULL; + char *szNick; if (dwUin) szNick = getSettingStringUtf(hContact, "Nick", NULL); else szNick = null_strdup(szUid); - size_t nNickLen = mir_strlen(szNick); - - pre.lParam += nNickLen + nReasonLen; + DB_AUTH_BLOB blob(hContact, szNick, 0, 0, 0, szReason); + *(DWORD*)(PBYTE)blob = dwUin; setByte(hContact, "Grant", 1); - /*blob is: uin(DWORD), hcontact(HANDLE), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ), reason(ASCIIZ)*/ - char *szBlob = (char *)_alloca(pre.lParam); - char *pCurBlob = szBlob; - *(DWORD*)pCurBlob = dwUin; pCurBlob += sizeof(DWORD); - *(DWORD*)pCurBlob = DWORD(hContact); pCurBlob += sizeof(DWORD); - - if (nNickLen) { // if we have nick we add it, otherwise keep trailing zero - memcpy(pCurBlob, szNick, nNickLen); - pCurBlob += nNickLen; - } - *pCurBlob = 0; pCurBlob++; // Nick - *pCurBlob = 0; pCurBlob++; // FirstName - *pCurBlob = 0; pCurBlob++; // LastName - *pCurBlob = 0; pCurBlob++; // email - if (nReasonLen) { - memcpy(pCurBlob, szReason, nReasonLen); - pCurBlob += nReasonLen; - } - *pCurBlob = 0; // Reason - pre.szMessage = szBlob; - // TODO: Change for new auth system, include all known informations + PROTORECVEVENT pre = { 0 }; + pre.timestamp = time(NULL); + pre.lParam = blob.size(); + pre.szMessage = blob; ProtoChainRecv(hContact, PSR_AUTH, 0, (LPARAM)&pre); SAFE_FREE(&szNick); -- cgit v1.2.3