summaryrefslogtreecommitdiff
path: root/protocols/Tox/src/tox_utils.cpp
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2014-08-12 19:29:57 +0000
committerAlexander Lantsev <aunsane@gmail.com>2014-08-12 19:29:57 +0000
commit79f5521815e208cb694bbc814ee88429e20328b6 (patch)
tree62f552526e0626aa55285684f0fe12081a91349c /protocols/Tox/src/tox_utils.cpp
parent4e5548a98703325099017bf6bf04b2fb5edefbd4 (diff)
Tox: getting friend request
git-svn-id: http://svn.miranda-ng.org/main/trunk@10170 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Tox/src/tox_utils.cpp')
-rw-r--r--protocols/Tox/src/tox_utils.cpp61
1 files changed, 26 insertions, 35 deletions
diff --git a/protocols/Tox/src/tox_utils.cpp b/protocols/Tox/src/tox_utils.cpp
index 4876b7e9fd..95743b9412 100644
--- a/protocols/Tox/src/tox_utils.cpp
+++ b/protocols/Tox/src/tox_utils.cpp
@@ -55,6 +55,32 @@ HANDLE CToxProto::AddDbEvent(MCONTACT hContact, WORD type, DWORD timestamp, DWOR
return db_event_add(hContact, &dbei);
}
+void CToxProto::RaiseAuthRequestEvent(DWORD timestamp, const char* toxId, const char* reason)
+{
+ MCONTACT hContact = this->AddContact(toxId);
+
+ /*blob is: 0(DWORD), hContact(DWORD), nick(ASCIIZ), firstName(ASCIIZ), lastName(ASCIIZ), sid(ASCIIZ), reason(ASCIIZ)*/
+ DWORD cbBlob = (DWORD)
+ (sizeof(DWORD) * 2 +
+ strlen(toxId) +
+ strlen(reason) +
+ 5);
+
+ PBYTE pBlob, pCurBlob;
+ pCurBlob = pBlob = (PBYTE)mir_calloc(cbBlob);
+
+ *((PDWORD)pCurBlob) = 0;
+ pCurBlob += sizeof(DWORD);
+ *((PDWORD)pCurBlob) = (DWORD)hContact;
+ pCurBlob += sizeof(DWORD);
+ pCurBlob += 3;
+ strcpy((char *)pCurBlob, toxId);
+ pCurBlob += strlen(toxId) + 1;
+ strcpy((char *)pCurBlob, reason);
+
+ AddDbEvent(hContact, EVENTTYPE_AUTHREQUEST, timestamp, DBEF_UTF, cbBlob, pBlob);
+}
+
std::vector<uint8_t> CToxProto::HexStringToData(std::string hex)
{
std::stringstream ss;
@@ -153,38 +179,3 @@ int CToxProto::SaveToxData(const char *path)
return res;
}
-
-#define FRADDR_TOSTR_CHUNK_LEN 8
-
-void CToxProto::fraddr_to_str(uint8_t *id_bin, char *id_str)
-{
- uint32_t i, delta = 0, pos_extra, sum_extra = 0;
-
- for (i = 0; i < TOX_FRIEND_ADDRESS_SIZE; i++) {
- sprintf(&id_str[2 * i + delta], "%02hhX", id_bin[i]);
-
- if ((i + 1) == TOX_CLIENT_ID_SIZE)
- pos_extra = 2 * (i + 1) + delta;
-
- if (i >= TOX_CLIENT_ID_SIZE)
- sum_extra |= id_bin[i];
-
- if (!((i + 1) % FRADDR_TOSTR_CHUNK_LEN)) {
- id_str[2 * (i + 1) + delta] = ' ';
- delta++;
- }
- }
-
- id_str[2 * i + delta] = 0;
-
- if (!sum_extra)
- id_str[pos_extra] = 0;
-}
-
-void CToxProto::get_id(Tox *m, char *data)
-{
- int offset = strlen(data);
- uint8_t address[TOX_FRIEND_ADDRESS_SIZE];
- tox_get_address(m, address);
- fraddr_to_str(address, data + offset);
-}