From 48266e479d1fcf5153b29c612866845990fccad8 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 21 May 2015 16:11:58 +0000 Subject: war against atavisms continues - everything that goes to PSS_MESSAGE should be sent as utf8 string; - thus PREF_UNICODE & PREF_UTF support discontinued, these constants are removed; - support for PREF_UNICODE & PREF_UTF in protocols also removed; - PREF_UNICODE used in file transfers (PROTOFILERECVT) replaced with PRFF_UNICODE / PRFF_TCHAR git-svn-id: http://svn.miranda-ng.org/main/trunk@13734 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Tox/src/tox_transfer.cpp | 84 +++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 43 deletions(-) (limited to 'protocols/Tox/src/tox_transfer.cpp') diff --git a/protocols/Tox/src/tox_transfer.cpp b/protocols/Tox/src/tox_transfer.cpp index dce86334ae..e1460b3d53 100644 --- a/protocols/Tox/src/tox_transfer.cpp +++ b/protocols/Tox/src/tox_transfer.cpp @@ -10,54 +10,52 @@ void CToxProto::OnFriendFile(Tox*, uint32_t friendNumber, uint32_t fileNumber, u MCONTACT hContact = proto->GetContact(friendNumber); if (hContact) { - switch (kind) - { + switch (kind) { case TOX_FILE_KIND_AVATAR: - { - ptrT address(proto->getTStringA(hContact, TOX_SETTINGS_ID)); - TCHAR avatarName[MAX_PATH]; - mir_sntprintf(avatarName, MAX_PATH, _T("%s.png"), address); - - AvatarTransferParam *transfer = new AvatarTransferParam(friendNumber, fileNumber, avatarName, fileSize); - transfer->pfts.flags |= PFTS_RECEIVING; - transfer->pfts.hContact = hContact; - proto->transfers.Add(transfer); - - TOX_ERR_FILE_GET error; - tox_file_get_file_id(proto->tox, friendNumber, fileNumber, transfer->hash, &error); - if (error != TOX_ERR_FILE_GET_OK) { - proto->debugLogA(__FUNCTION__": unable to get avatar hash (%d)", error); - memset(transfer->hash, 0, TOX_HASH_LENGTH); + ptrT address(proto->getTStringA(hContact, TOX_SETTINGS_ID)); + TCHAR avatarName[MAX_PATH]; + mir_sntprintf(avatarName, MAX_PATH, _T("%s.png"), address); + + AvatarTransferParam *transfer = new AvatarTransferParam(friendNumber, fileNumber, avatarName, fileSize); + transfer->pfts.flags |= PFTS_RECEIVING; + transfer->pfts.hContact = hContact; + proto->transfers.Add(transfer); + + TOX_ERR_FILE_GET error; + tox_file_get_file_id(proto->tox, friendNumber, fileNumber, transfer->hash, &error); + if (error != TOX_ERR_FILE_GET_OK) { + proto->debugLogA(__FUNCTION__": unable to get avatar hash (%d)", error); + memset(transfer->hash, 0, TOX_HASH_LENGTH); + } + proto->OnGotFriendAvatarInfo(transfer); } - proto->OnGotFriendAvatarInfo(transfer); - } - break; + break; case TOX_FILE_KIND_DATA: - { - ptrA rawName((char*)mir_alloc(filenameLength + 1)); - memcpy(rawName, fileName, filenameLength); - rawName[filenameLength] = 0; - TCHAR *name = mir_utf8decodeT(rawName); - - FileTransferParam *transfer = new FileTransferParam(friendNumber, fileNumber, name, fileSize); - transfer->pfts.flags |= PFTS_RECEIVING; - transfer->pfts.hContact = hContact; - proto->transfers.Add(transfer); - - PROTORECVFILET pre = { 0 }; - pre.flags = PREF_TCHAR; - pre.fileCount = 1; - pre.timestamp = time(NULL); - pre.tszDescription = _T(""); - pre.ptszFiles = (TCHAR**)mir_alloc(sizeof(TCHAR*) * 2); - pre.ptszFiles[0] = name; - pre.ptszFiles[1] = NULL; - pre.lParam = (LPARAM)transfer; - ProtoChainRecvFile(hContact, &pre); - } - break; + { + ptrA rawName((char*)mir_alloc(filenameLength + 1)); + memcpy(rawName, fileName, filenameLength); + rawName[filenameLength] = 0; + TCHAR *name = mir_utf8decodeT(rawName); + + FileTransferParam *transfer = new FileTransferParam(friendNumber, fileNumber, name, fileSize); + transfer->pfts.flags |= PFTS_RECEIVING; + transfer->pfts.hContact = hContact; + proto->transfers.Add(transfer); + + PROTORECVFILET pre = { 0 }; + pre.dwFlags = PRFF_TCHAR; + pre.fileCount = 1; + pre.timestamp = time(NULL); + pre.tszDescription = _T(""); + pre.ptszFiles = (TCHAR**)mir_alloc(sizeof(TCHAR*) * 2); + pre.ptszFiles[0] = name; + pre.ptszFiles[1] = NULL; + pre.lParam = (LPARAM)transfer; + ProtoChainRecvFile(hContact, &pre); + } + break; default: proto->debugLogA(__FUNCTION__": unsupported transfer type (%d)", kind); -- cgit v1.2.3