diff options
-rw-r--r-- | protocols/Tox/bin/x64/libtox.dll | bin | 3947782 -> 3955846 bytes | |||
-rw-r--r-- | protocols/Tox/bin/x86/libtox.dll | bin | 3293572 -> 3301072 bytes | |||
-rw-r--r-- | protocols/Tox/res/resource.rc | 6 | ||||
-rw-r--r-- | protocols/Tox/src/tox_profile.cpp | 15 | ||||
-rw-r--r-- | protocols/Tox/src/tox_proto.h | 4 | ||||
-rw-r--r-- | protocols/Tox/src/tox_transfer.cpp | 38 |
6 files changed, 31 insertions, 32 deletions
diff --git a/protocols/Tox/bin/x64/libtox.dll b/protocols/Tox/bin/x64/libtox.dll Binary files differindex 0bb4918bfe..385a6d3177 100644 --- a/protocols/Tox/bin/x64/libtox.dll +++ b/protocols/Tox/bin/x64/libtox.dll diff --git a/protocols/Tox/bin/x86/libtox.dll b/protocols/Tox/bin/x86/libtox.dll Binary files differindex 307215fbbf..8d29046034 100644 --- a/protocols/Tox/bin/x86/libtox.dll +++ b/protocols/Tox/bin/x86/libtox.dll diff --git a/protocols/Tox/res/resource.rc b/protocols/Tox/res/resource.rc index 9d2991b214..3b12e9d37d 100644 --- a/protocols/Tox/res/resource.rc +++ b/protocols/Tox/res/resource.rc @@ -86,13 +86,13 @@ FONT 8, "MS Shell Dlg", 400, 0, 0x1 BEGIN
LTEXT "Name:",IDC_STATIC,12,24,54,12
EDITTEXT IDC_NAME,66,23,120,12,ES_AUTOHSCROLL
- LTEXT "Password:",IDC_STATIC,12,40,54,12
+ LTEXT "Password:",IDC_STATIC,12,40,54,12,NOT WS_VISIBLE
EDITTEXT IDC_TOXID,66,7,100,12,ES_AUTOHSCROLL | ES_READONLY | WS_DISABLED
LTEXT "Default group:",IDC_STATIC,12,56,54,12
EDITTEXT IDC_GROUP,66,54,120,12,ES_AUTOHSCROLL
PUSHBUTTON "C",IDC_CLIPBOARD,170,7,16,13,WS_DISABLED
LTEXT "Tox ID:",IDC_STATIC,12,9,54,8
- EDITTEXT IDC_PASSWORD,66,38,120,12,ES_PASSWORD | ES_AUTOHSCROLL
+ EDITTEXT IDC_PASSWORD,66,38,120,12,ES_PASSWORD | ES_AUTOHSCROLL | NOT WS_VISIBLE
END
IDD_OPTIONS_MAIN DIALOGEX 0, 0, 312, 234
@@ -113,7 +113,7 @@ BEGIN EDITTEXT IDC_GROUP,81,65,219,12,ES_AUTOHSCROLL
PUSHBUTTON "C",IDC_CLIPBOARD,284,17,16,13,WS_DISABLED
LTEXT "Password:",IDC_STATIC,12,51,69,8,NOT WS_VISIBLE
- EDITTEXT IDC_PASSWORD,81,49,219,12,ES_PASSWORD | ES_AUTOHSCROLL
+ EDITTEXT IDC_PASSWORD,81,49,219,12,ES_PASSWORD | ES_AUTOHSCROLL | NOT WS_VISIBLE
END
IDD_PROFILE_IMPORT DIALOGEX 0, 0, 313, 87
diff --git a/protocols/Tox/src/tox_profile.cpp b/protocols/Tox/src/tox_profile.cpp index 4ee3abc526..898899bff1 100644 --- a/protocols/Tox/src/tox_profile.cpp +++ b/protocols/Tox/src/tox_profile.cpp @@ -18,11 +18,16 @@ std::tstring CToxProto::GetToxProfilePath(const TCHAR *accountName) bool CToxProto::LoadToxProfile()
{
std::tstring profilePath = GetToxProfilePath();
+ if (!IsFileExists(profilePath))
+ {
+ return true;
+ }
+
FILE *profile = _tfopen(profilePath.c_str(), _T("rb"));
if (profile == NULL)
{
debugLogA("CToxProto::LoadToxData: could not open tox profile");
- return true;
+ return false;
}
fseek(profile, 0, SEEK_END);
@@ -84,7 +89,7 @@ bool CToxProto::LoadToxProfile() void CToxProto::SaveToxProfile()
{
- size_t size = 0;
+ /*size_t size = 0;
uint8_t *data = NULL;
{
@@ -107,7 +112,11 @@ void CToxProto::SaveToxProfile() data = (uint8_t*)mir_calloc(size);
tox_save(tox, data);
}
- }
+ }*/
+
+ size_t size = tox_size(tox);
+ uint8_t *data = (uint8_t*)mir_calloc(size);
+ tox_save(tox, data);
std::tstring profilePath = GetToxProfilePath();
FILE *profile = _tfopen(profilePath.c_str(), _T("wb"));
diff --git a/protocols/Tox/src/tox_proto.h b/protocols/Tox/src/tox_proto.h index faf7baa84b..7dc29878b9 100644 --- a/protocols/Tox/src/tox_proto.h +++ b/protocols/Tox/src/tox_proto.h @@ -45,6 +45,10 @@ struct FileTransferParam }
mir_free(pfts.pszFiles[0]);
mir_free(pfts.pszFiles);
+ if (hFile)
+ {
+ fclose(hFile);
+ }
}
};
diff --git a/protocols/Tox/src/tox_transfer.cpp b/protocols/Tox/src/tox_transfer.cpp index 03ebe2c467..22af0bb711 100644 --- a/protocols/Tox/src/tox_transfer.cpp +++ b/protocols/Tox/src/tox_transfer.cpp @@ -54,7 +54,7 @@ void CToxProto::OnFriendFile(Tox *tox, int32_t number, uint8_t fileNumber, uint6 }
// file request is allowed
-HANDLE __cdecl CToxProto::FileAllow(MCONTACT hContact, HANDLE hTransfer, const PROTOCHAR* tszPath)
+HANDLE __cdecl CToxProto::FileAllow(MCONTACT hContact, HANDLE hTransfer, const PROTOCHAR *tszPath)
{
std::string id = getStringA(hContact, TOX_SETTINGS_ID);
std::vector<uint8_t> clientId = HexStringToData(id);
@@ -70,7 +70,7 @@ HANDLE __cdecl CToxProto::FileAllow(MCONTACT hContact, HANDLE hTransfer, const P if (!ProtoBroadcastAck(hContact, ACKTYPE_FILE, ACKRESULT_FILERESUME, (HANDLE)transfer, (LPARAM)&transfer->pfts))
{
- transfer->hFile = _tfopen(transfer->pfts.tszCurrentFile, _T("ab"));
+ transfer->hFile = _tfopen(transfer->pfts.tszCurrentFile, _T("wb"));
tox_file_send_control(tox, number, 1, transfer->number, TOX_FILECONTROL_ACCEPT, NULL, 0);
}
@@ -128,8 +128,6 @@ void CToxProto::OnFileData(Tox *tox, int32_t number, uint8_t fileNumber, const u MCONTACT hContact = proto->FindContact(number);
if (hContact)
{
- //mir_cslock lck(proto->toxLock);
-
FileTransferParam *transfer = proto->transfers.at(fileNumber);
if (transfer->hFile == NULL)
@@ -164,14 +162,15 @@ HANDLE __cdecl CToxProto::SendFile(MCONTACT hContact, const PROTOCHAR* szDescrip fileDir[fileDirLength] = '\0';
size_t fileSize = 0;
- FILE *file = _tfopen(ppszFiles[0], _T("rb"));
- if (file != NULL)
+ FILE *hFile = _tfopen(ppszFiles[0], _T("rb"));
+ if (hFile == NULL)
{
- fseek(file, 0, SEEK_END);
- fileSize = ftell(file);
- fseek(file, 0, SEEK_SET);
- fclose(file);
+ debugLogA("CToxProto::SendFilesAsync: cannot open file");
+ return NULL;
}
+ fseek(hFile, 0, SEEK_END);
+ fileSize = ftell(hFile);
+ fseek(hFile, 0, SEEK_SET);
char *name = mir_utf8encodeW(fileName);
int fileNumber = tox_new_file_sender(tox, number, fileSize, (uint8_t*)name, strlen(name));
@@ -185,6 +184,7 @@ HANDLE __cdecl CToxProto::SendFile(MCONTACT hContact, const PROTOCHAR* szDescrip transfer->pfts.hContact = hContact;
transfer->pfts.flags |= PFTS_SENDING;
transfer->pfts.tszWorkingDir = fileDir;
+ transfer->hFile = hFile;
AddToTransferList(transfer);
return (HANDLE)transfer;
@@ -207,23 +207,14 @@ void CToxProto::SendFileAsync(void* arg) TCHAR filePath[MAX_PATH];
mir_sntprintf(filePath, SIZEOF(filePath), _T("%s%s"), transfer->pfts.tszWorkingDir, transfer->pfts.tszCurrentFile);
- FILE *hFile = _wfopen(filePath, _T("rb"));
- if (!hFile)
- {
- ProtoBroadcastAck(transfer->pfts.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, (HANDLE)transfer, 0);
- tox_file_send_control(tox, number, transfer->GetTransferStatus(), transfer->number, TOX_FILECONTROL_KILL, NULL, 0);
- return;
- }
-
size_t chunkSize = min(fileSize, (size_t)tox_file_data_size(tox, number));
uint8_t *data = (uint8_t*)mir_alloc(TOX_FILE_BLOCK_SIZE);
- while (!feof(hFile) && fileProgress < fileSize && !transfer->isTerminated)
+ while (!feof(transfer->hFile) && fileProgress < fileSize && !transfer->isTerminated)
{
// read file by block of TOX_FILE_BLOCK_SIZE
size_t blockSize = min(chunkSize * (TOX_FILE_BLOCK_SIZE / chunkSize), fileSize - fileProgress);
- if (fread(data, sizeof(uint8_t), blockSize, hFile) != blockSize)
+ if (fread(data, sizeof(uint8_t), blockSize, transfer->hFile) != blockSize)
{
- fclose(hFile);
ProtoBroadcastAck(transfer->pfts.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, (HANDLE)transfer, 0);
tox_file_send_control(tox, number, transfer->GetTransferStatus(), transfer->number, TOX_FILECONTROL_KILL, NULL, 0);
return;
@@ -252,7 +243,6 @@ void CToxProto::SendFileAsync(void* arg) ProtoBroadcastAck(transfer->pfts.hContact, ACKTYPE_FILE, ACKRESULT_DATA, (HANDLE)transfer, (LPARAM)&transfer->pfts);
}
}
- fclose(hFile);
mir_free(data);
if (!transfer->isTerminated)
@@ -319,10 +309,6 @@ void CToxProto::OnFileRequest(Tox *tox, int32_t number, uint8_t receive_send, ui {
tox_file_send_control(proto->tox, number, 1, fileNumber, TOX_FILECONTROL_FINISHED, NULL, 0);
}
- if (transfer->hFile)
- {
- fclose(transfer->hFile);
- }
proto->ProtoBroadcastAck(transfer->pfts.hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, (HANDLE)transfer, 0);
proto->RemoveFromTransferList(transfer);
break;
|