summaryrefslogtreecommitdiff
path: root/protocols/IcqOscarJ/src
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2017-01-16 18:20:37 +0300
committerGeorge Hazan <ghazan@miranda.im>2017-01-16 18:20:37 +0300
commit6163df27ad6fd2a5da5d9bbb48bb457d8a07a2b6 (patch)
treed0523b56e1b987789c6622916a31e8f356076d23 /protocols/IcqOscarJ/src
parente021b02022a37bd23b599801026d631f5fd9f48c (diff)
DB_AUTH_BLOB: handy piece of code moved into the core
Diffstat (limited to 'protocols/IcqOscarJ/src')
-rw-r--r--protocols/IcqOscarJ/src/fam_04message.cpp17
-rw-r--r--protocols/IcqOscarJ/src/fam_13servclist.cpp37
2 files changed, 12 insertions, 42 deletions
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);