diff options
Diffstat (limited to 'protocols/Tox')
-rw-r--r-- | protocols/Tox/src/stdafx.h | 4 | ||||
-rw-r--r-- | protocols/Tox/src/tox_accounts.cpp | 4 | ||||
-rw-r--r-- | protocols/Tox/src/tox_avatars.cpp | 52 | ||||
-rw-r--r-- | protocols/Tox/src/tox_chatrooms.cpp | 8 | ||||
-rw-r--r-- | protocols/Tox/src/tox_contacts.cpp | 28 | ||||
-rw-r--r-- | protocols/Tox/src/tox_core.cpp | 10 | ||||
-rw-r--r-- | protocols/Tox/src/tox_logger.h | 28 | ||||
-rw-r--r-- | protocols/Tox/src/tox_messages.cpp | 8 | ||||
-rw-r--r-- | protocols/Tox/src/tox_multimedia.cpp | 50 | ||||
-rw-r--r-- | protocols/Tox/src/tox_netlib.cpp | 4 | ||||
-rw-r--r-- | protocols/Tox/src/tox_network.cpp | 38 | ||||
-rw-r--r-- | protocols/Tox/src/tox_options.cpp | 22 | ||||
-rw-r--r-- | protocols/Tox/src/tox_profile.cpp | 28 | ||||
-rw-r--r-- | protocols/Tox/src/tox_proto.cpp | 62 | ||||
-rw-r--r-- | protocols/Tox/src/tox_proto.h | 18 | ||||
-rw-r--r-- | protocols/Tox/src/tox_services.cpp | 2 | ||||
-rw-r--r-- | protocols/Tox/src/tox_transfer.cpp | 52 | ||||
-rw-r--r-- | protocols/Tox/src/tox_utils.cpp | 26 |
18 files changed, 242 insertions, 202 deletions
diff --git a/protocols/Tox/src/stdafx.h b/protocols/Tox/src/stdafx.h index 3374130495..fed628c81b 100644 --- a/protocols/Tox/src/stdafx.h +++ b/protocols/Tox/src/stdafx.h @@ -13,11 +13,10 @@ #define SAFE_RELEASE(punk) if ((punk) != NULL) { (punk)->Release(); (punk) = NULL; }
DEFINE_PROPERTYKEY(PKEY_Device_FriendlyName, 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 14);
-#include <string>
#include <vector>
#include <regex>
-#include <queue>
#include <map>
+#include <algorithm>
#include <newpluginapi.h>
@@ -54,6 +53,7 @@ struct CToxProto; #include "resource.h"
#include "tox_icons.h"
#include "tox_menus.h"
+#include "tox_logger.h"
#include "tox_address.h"
#include "tox_dialogs.h"
#include "tox_profile.h"
diff --git a/protocols/Tox/src/tox_accounts.cpp b/protocols/Tox/src/tox_accounts.cpp index 1751d261c9..fd86624318 100644 --- a/protocols/Tox/src/tox_accounts.cpp +++ b/protocols/Tox/src/tox_accounts.cpp @@ -42,10 +42,10 @@ int CToxProto::OnAccountLoaded(WPARAM, LPARAM) int CToxProto::OnAccountRenamed(WPARAM, LPARAM)
{
- std::tstring newPath = GetToxProfilePath();
+ ptrT newPath(GetToxProfilePath());
TCHAR oldPath[MAX_PATH];
mir_sntprintf(oldPath, MAX_PATH, _T("%s\\%s.tox"), VARST(_T("%miranda_userdata%")), accountName);
- _trename(oldPath, newPath.c_str());
+ _trename(oldPath, newPath);
mir_free(accountName);
accountName = mir_tstrdup(m_tszUserName);
diff --git a/protocols/Tox/src/tox_avatars.cpp b/protocols/Tox/src/tox_avatars.cpp index 2aede1cbe1..47c50d3fc2 100644 --- a/protocols/Tox/src/tox_avatars.cpp +++ b/protocols/Tox/src/tox_avatars.cpp @@ -1,9 +1,9 @@ #include "stdafx.h"
-std::tstring CToxProto::GetAvatarFilePath(MCONTACT hContact)
+TCHAR* CToxProto::GetAvatarFilePath(MCONTACT hContact)
{
- TCHAR path[MAX_PATH];
- mir_sntprintf(path, _T("%s\\%S"), VARST(_T("%miranda_avatarcache%")), m_szModuleName);
+ TCHAR *path = (TCHAR*)mir_calloc(MAX_PATH * sizeof(TCHAR) + 1);
+ mir_sntprintf(path, MAX_PATH, _T("%s\\%S"), VARST(_T("%miranda_avatarcache%")), m_szModuleName);
DWORD dwAttributes = GetFileAttributes(path);
if (dwAttributes == 0xffffffff || (dwAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
@@ -11,7 +11,7 @@ std::tstring CToxProto::GetAvatarFilePath(MCONTACT hContact) ptrT address(getTStringA(hContact, TOX_SETTINGS_ID));
if (address == NULL)
- return _T("");
+ return mir_tstrdup(_T(""));
if (hContact && mir_tstrlen(address) > TOX_PUBLIC_KEY_SIZE * 2)
address[TOX_PUBLIC_KEY_SIZE * 2] = 0;
@@ -20,12 +20,12 @@ std::tstring CToxProto::GetAvatarFilePath(MCONTACT hContact) return path;
}
-void CToxProto::SetToxAvatar(std::tstring path)
+void CToxProto::SetToxAvatar(const TCHAR* path)
{
- FILE *hFile = _tfopen(path.c_str(), L"rb");
+ FILE *hFile = _tfopen(path, L"rb");
if (!hFile)
{
- debugLogA(__FUNCTION__": failed to open avatar file");
+ logger->Log(__FUNCTION__": failed to open avatar file");
return;
}
@@ -35,7 +35,7 @@ void CToxProto::SetToxAvatar(std::tstring path) if (length > TOX_MAX_AVATAR_SIZE)
{
fclose(hFile);
- debugLogA(__FUNCTION__": new avatar size is excessive");
+ logger->Log(__FUNCTION__": new avatar size is excessive");
return;
}
@@ -43,7 +43,7 @@ void CToxProto::SetToxAvatar(std::tstring path) if (fread(data, sizeof(uint8_t), length, hFile) != length)
{
fclose(hFile);
- debugLogA(__FUNCTION__": failed to read avatar file");
+ logger->Log(__FUNCTION__": failed to read avatar file");
mir_free(data);
return;
}
@@ -58,7 +58,7 @@ void CToxProto::SetToxAvatar(std::tstring path) {
db_free(&dbv);
mir_free(data);
- debugLogA(__FUNCTION__": new avatar is same with old");
+ logger->Log(__FUNCTION__": new avatar is same with old");
return;
}
db_free(&dbv);
@@ -77,7 +77,7 @@ void CToxProto::SetToxAvatar(std::tstring path) if (friendNumber == UINT32_MAX)
{
mir_free(data);
- debugLogA(__FUNCTION__": failed to set new avatar");
+ logger->Log(__FUNCTION__": failed to set new avatar");
return;
}
@@ -86,7 +86,7 @@ void CToxProto::SetToxAvatar(std::tstring path) if (error != TOX_ERR_FILE_SEND_OK)
{
mir_free(data);
- debugLogA(__FUNCTION__": failed to set new avatar");
+ logger->Log(__FUNCTION__": failed to set new avatar");
return;
}
@@ -94,7 +94,7 @@ void CToxProto::SetToxAvatar(std::tstring path) transfer->pfts.flags |= PFTS_SENDING;
memcpy(transfer->hash, hash, TOX_HASH_LENGTH);
transfer->pfts.hContact = hContact;
- transfer->hFile = _tfopen(path.c_str(), L"rb");
+ transfer->hFile = _tfopen(path, L"rb");
transfers.Add(transfer);
}
}
@@ -131,10 +131,10 @@ INT_PTR CToxProto::GetAvatarInfo(WPARAM, LPARAM lParam) ptrA address(getStringA(pai->hContact, TOX_SETTINGS_ID));
if (address != NULL)
{
- std::tstring path = GetAvatarFilePath(pai->hContact);
+ ptrT path(GetAvatarFilePath(pai->hContact));
if (IsFileExists(path))
{
- mir_tstrncpy(pai->filename, path.c_str(), _countof(pai->filename));
+ mir_tstrncpy(pai->filename, path, _countof(pai->filename));
pai->format = PA_FORMAT_PNG;
return GAIR_SUCCESS;
@@ -146,24 +146,24 @@ INT_PTR CToxProto::GetAvatarInfo(WPARAM, LPARAM lParam) INT_PTR CToxProto::GetMyAvatar(WPARAM wParam, LPARAM lParam)
{
- std::tstring path = GetAvatarFilePath();
+ ptrT path(GetAvatarFilePath());
if (IsFileExists(path))
- mir_tstrncpy((TCHAR*)wParam, path.c_str(), (int)lParam);
+ mir_tstrncpy((TCHAR*)wParam, path, (int)lParam);
return 0;
}
INT_PTR CToxProto::SetMyAvatar(WPARAM, LPARAM lParam)
{
- debugLogA("CToxProto::SetMyAvatar: setting avatar");
+ logger->Log("CToxProto::SetMyAvatar: setting avatar");
TCHAR *path = (TCHAR*)lParam;
- std::tstring avatarPath = GetAvatarFilePath();
+ ptrT avatarPath(GetAvatarFilePath());
if (path != NULL)
{
- debugLogA("CToxProto::SetMyAvatar: copy new avatar");
- if (!CopyFile(path, avatarPath.c_str(), FALSE))
+ logger->Log("CToxProto::SetMyAvatar: copy new avatar");
+ if (!CopyFile(path, avatarPath, FALSE))
{
- debugLogA("CToxProto::SetMyAvatar: failed to copy new avatar to avatar cache");
+ logger->Log("CToxProto::SetMyAvatar: failed to copy new avatar to avatar cache");
return 0;
}
@@ -187,14 +187,14 @@ INT_PTR CToxProto::SetMyAvatar(WPARAM, LPARAM lParam) tox_file_send(toxThread->tox, friendNumber, TOX_FILE_KIND_AVATAR, 0, NULL, NULL, 0, &error);
if (error != TOX_ERR_FILE_SEND_OK)
{
- debugLogA(__FUNCTION__": failed to unset avatar (%d)", error);
+ logger->Log(__FUNCTION__": failed to unset avatar (%d)", error);
return 0;
}
}
}
if (IsFileExists(avatarPath))
- DeleteFile(avatarPath.c_str());
+ DeleteFile(avatarPath);
delSetting(TOX_SETTINGS_AVATAR_HASH);
@@ -206,9 +206,9 @@ void CToxProto::OnGotFriendAvatarInfo(AvatarTransferParam *transfer) if (transfer->pfts.totalBytes == 0)
{
MCONTACT hConact = transfer->pfts.hContact;
- std::tstring path = GetAvatarFilePath(hConact);
+ ptrT path(GetAvatarFilePath(hConact));
if (IsFileExists(path))
- DeleteFile(path.c_str());
+ DeleteFile(path);
transfers.Remove(transfer);
delSetting(hConact, TOX_SETTINGS_AVATAR_HASH);
diff --git a/protocols/Tox/src/tox_chatrooms.cpp b/protocols/Tox/src/tox_chatrooms.cpp index cff9447d84..0ae894be98 100644 --- a/protocols/Tox/src/tox_chatrooms.cpp +++ b/protocols/Tox/src/tox_chatrooms.cpp @@ -49,7 +49,7 @@ void CToxProto::LoadChatRoomList(void*) uint32_t count = tox_count_chatlist(toxThread->tox);
if (count == 0)
{
- debugLogA("CToxProto::LoadGroupChatList: your group chat list is empty");
+ logger->Log("CToxProto::LoadGroupChatList: your group chat list is empty");
return;
}
int32_t *groupChats = (int32_t*)mir_alloc(count * sizeof(int32_t));
@@ -189,21 +189,21 @@ void CToxProto::OnGroupChatInvite(Tox *tox, int32_t friendNumber, uint8_t type, if (type == TOX_GROUPCHAT_TYPE_AV)
{
- proto->debugLogA("CToxProto::OnGroupChatInvite: audio chat is not supported yet");
+ proto->logger->Log("CToxProto::OnGroupChatInvite: audio chat is not supported yet");
return;
}
int groupNumber = tox_join_groupchat(tox, friendNumber, data, length);
if (groupNumber == TOX_ERROR)
{
- proto->debugLogA("CToxProto::OnFriendRequest: failed to join to group chat");
+ proto->logger->Log("CToxProto::OnFriendRequest: failed to join to group chat");
return;
}
MCONTACT hContact = proto->AddChatRoom(groupNumber);
if (!hContact)
{
- proto->debugLogA("CToxProto::OnFriendRequest: failed to create group chat");
+ proto->logger->Log("CToxProto::OnFriendRequest: failed to create group chat");
}
}
diff --git a/protocols/Tox/src/tox_contacts.cpp b/protocols/Tox/src/tox_contacts.cpp index 5bf327f060..05ad622089 100644 --- a/protocols/Tox/src/tox_contacts.cpp +++ b/protocols/Tox/src/tox_contacts.cpp @@ -43,7 +43,7 @@ MCONTACT CToxProto::GetContact(const int friendNumber) TOX_ERR_FRIEND_GET_PUBLIC_KEY error;
if (!tox_friend_get_public_key(toxThread->tox, friendNumber, data, &error))
{
- debugLogA(__FUNCTION__": failed to get friend public key (%d)", error);
+ logger->Log(__FUNCTION__": failed to get friend public key (%d)", error);
return NULL;
}
ToxHexAddress pubKey(data, TOX_PUBLIC_KEY_SIZE);
@@ -101,7 +101,7 @@ uint32_t CToxProto::GetToxFriendNumber(MCONTACT hContact) TOX_ERR_FRIEND_BY_PUBLIC_KEY error;
uint32_t friendNumber = tox_friend_by_public_key(toxThread->tox, pubKey.GetPubKey(), &error);
if (error != TOX_ERR_FRIEND_BY_PUBLIC_KEY_OK)
- debugLogA(__FUNCTION__": failed to get friend number (%d)", error);
+ logger->Log(__FUNCTION__": failed to get friend number (%d)", error);
return friendNumber;
}
@@ -120,7 +120,7 @@ void CToxProto::LoadFriendList(void*) TOX_ERR_FRIEND_GET_PUBLIC_KEY getPublicKeyResult;
if (!tox_friend_get_public_key(toxThread->tox, friendNumber, data, &getPublicKeyResult))
{
- debugLogA(__FUNCTION__": failed to get friend public key (%d)", getPublicKeyResult);
+ logger->Log(__FUNCTION__": failed to get friend public key (%d)", getPublicKeyResult);
continue;
}
ToxHexAddress pubKey(data, TOX_PUBLIC_KEY_SIZE);
@@ -135,14 +135,14 @@ void CToxProto::LoadFriendList(void*) if (tox_friend_get_name(toxThread->tox, friendNumber, nick, &getNameResult))
setTString(hContact, "Nick", ptrT(mir_utf8decodeT((char*)nick)));
else
- debugLogA(__FUNCTION__": failed to get friend name (%d)", getNameResult);
+ logger->Log(__FUNCTION__": failed to get friend name (%d)", getNameResult);
TOX_ERR_FRIEND_GET_LAST_ONLINE getLastOnlineResult;
uint64_t timestamp = tox_friend_get_last_online(toxThread->tox, friendNumber, &getLastOnlineResult);
if (getLastOnlineResult == TOX_ERR_FRIEND_GET_LAST_ONLINE_OK)
setDword(hContact, "LastEventDateTS", timestamp);
else
- debugLogA(__FUNCTION__": failed to get friend last online (%d)", getLastOnlineResult);
+ logger->Log(__FUNCTION__": failed to get friend last online (%d)", getLastOnlineResult);
}
}
mir_free(friends);
@@ -162,7 +162,7 @@ INT_PTR CToxProto::OnRequestAuth(WPARAM hContact, LPARAM lParam) int32_t friendNumber = tox_friend_add(toxThread->tox, address, (uint8_t*)reason, length, &addFriendResult);
if (addFriendResult != TOX_ERR_FRIEND_ADD_OK)
{
- debugLogA(__FUNCTION__": failed to request auth (%d)", addFriendResult);
+ logger->Log(__FUNCTION__": failed to request auth (%d)", addFriendResult);
return addFriendResult;
}
@@ -174,7 +174,7 @@ INT_PTR CToxProto::OnRequestAuth(WPARAM hContact, LPARAM lParam) if (tox_friend_get_name(toxThread->tox, friendNumber, nick, &errorFriendQuery))
setTString(hContact, "Nick", ptrT(mir_utf8decodeT((char*)nick)));
else
- debugLogA(__FUNCTION__": failed to get friend name (%d)", errorFriendQuery);
+ logger->Log(__FUNCTION__": failed to get friend name (%d)", errorFriendQuery);
return 0;
}
@@ -189,7 +189,7 @@ INT_PTR CToxProto::OnGrantAuth(WPARAM hContact, LPARAM) tox_friend_add_norequest(toxThread->tox, pubKey, &error);
if (error != TOX_ERR_FRIEND_ADD_OK)
{
- debugLogA(__FUNCTION__": failed to grant auth (%d)", error);
+ logger->Log(__FUNCTION__": failed to grant auth (%d)", error);
return error;
}
@@ -212,7 +212,7 @@ int CToxProto::OnContactDeleted(MCONTACT hContact, LPARAM) TOX_ERR_FRIEND_DELETE error;
if (!tox_friend_delete(toxThread->tox, friendNumber, &error))
{
- debugLogA(__FUNCTION__": failed to delete friend (%d)", error);
+ logger->Log(__FUNCTION__": failed to delete friend (%d)", error);
return error;
}
SaveToxProfile();
@@ -238,7 +238,7 @@ void CToxProto::OnFriendRequest(Tox*, const uint8_t *pubKey, const uint8_t *mess MCONTACT hContact = proto->AddContact(address);
if (!hContact)
{
- proto->debugLogA(__FUNCTION__": failed to create contact");
+ proto->logger->Log(__FUNCTION__": failed to create contact");
return;
}
@@ -323,13 +323,13 @@ void CToxProto::OnConnectionStatusChanged(Tox*, uint32_t friendNumber, TOX_CONNE proto->ResumeIncomingTransfers(friendNumber);
// update avatar
- std::tstring avatarPath = proto->GetAvatarFilePath();
+ ptrT avatarPath(proto->GetAvatarFilePath());
if (IsFileExists(avatarPath))
{
- FILE *hFile = _tfopen(avatarPath.c_str(), L"rb");
+ FILE *hFile = _tfopen(avatarPath, L"rb");
if (!hFile)
{
- proto->debugLogA(__FUNCTION__": failed to open avatar file");
+ proto->logger->Log(__FUNCTION__": failed to open avatar file");
return;
}
@@ -349,7 +349,7 @@ void CToxProto::OnConnectionStatusChanged(Tox*, uint32_t friendNumber, TOX_CONNE uint32_t fileNumber = tox_file_send(proto->toxThread->tox, friendNumber, TOX_FILE_KIND_AVATAR, length, hash, NULL, 0, &error);
if (error != TOX_ERR_FILE_SEND_OK)
{
- proto->debugLogA(__FUNCTION__": failed to set new avatar");
+ proto->logger->Log(__FUNCTION__": failed to set new avatar");
return;
}
diff --git a/protocols/Tox/src/tox_core.cpp b/protocols/Tox/src/tox_core.cpp index 043f904c75..929c0c2536 100644 --- a/protocols/Tox/src/tox_core.cpp +++ b/protocols/Tox/src/tox_core.cpp @@ -6,7 +6,7 @@ Tox_Options* CToxProto::GetToxOptions() Tox_Options *options = tox_options_new(&error);
if (error != TOX_ERR_OPTIONS_NEW_OK)
{
- debugLogA(__FUNCTION__": failed to initialize tox options (%d)", error);
+ logger->Log(__FUNCTION__": failed to initialize tox options (%d)", error);
return NULL;
}
@@ -22,7 +22,7 @@ Tox_Options* CToxProto::GetToxOptions() {
if (nlus.proxyType == PROXYTYPE_HTTP || nlus.proxyType == PROXYTYPE_HTTPS)
{
- debugLogA("CToxProto::InitToxCore: setting http user proxy config");
+ logger->Log("CToxProto::InitToxCore: setting http user proxy config");
options->proxy_type = TOX_PROXY_TYPE_HTTP;
mir_strcpy((char*)&options->proxy_host[0], nlus.szProxyServer);
options->proxy_port = nlus.wProxyPort;
@@ -30,7 +30,7 @@ Tox_Options* CToxProto::GetToxOptions() if (nlus.proxyType == PROXYTYPE_SOCKS4 || nlus.proxyType == PROXYTYPE_SOCKS5)
{
- debugLogA(__FUNCTION__": setting socks user proxy config");
+ logger->Log(__FUNCTION__": setting socks user proxy config");
options->proxy_type = TOX_PROXY_TYPE_SOCKS5;
mir_strcpy((char*)&options->proxy_host[0], nlus.szProxyServer);
options->proxy_port = nlus.wProxyPort;
@@ -43,7 +43,7 @@ Tox_Options* CToxProto::GetToxOptions() bool CToxProto::InitToxCore(ToxThreadData *toxThread)
{
- debugLogA(__FUNCTION__": initializing tox core");
+ logger->Log(__FUNCTION__": initializing tox core");
Tox_Options *options = GetToxOptions();
if (options == NULL)
@@ -55,7 +55,7 @@ bool CToxProto::InitToxCore(ToxThreadData *toxThread) toxThread->tox = tox_new(options, &initError);
if (initError != TOX_ERR_NEW_OK)
{
- debugLogA(__FUNCTION__": failed to initialize tox core (%d)", initError);
+ logger->Log(__FUNCTION__": failed to initialize tox core (%d)", initError);
ShowNotification(ToxErrorToString(initError), TranslateT("Unable to initialize Tox core"), MB_ICONERROR);
tox_options_free(options);
return false;
diff --git a/protocols/Tox/src/tox_logger.h b/protocols/Tox/src/tox_logger.h new file mode 100644 index 0000000000..b460f87de7 --- /dev/null +++ b/protocols/Tox/src/tox_logger.h @@ -0,0 +1,28 @@ +#ifndef _TOX_LOGGER_H_
+#define _TOX_LOGGER_H_
+
+class CLogger
+{
+private:
+ HANDLE hNetlibUser;
+
+public:
+ CLogger(HANDLE hNetlibUser) : hNetlibUser(hNetlibUser) {}
+
+ __inline void Log(LPCSTR szFormat, ...) const
+ {
+ va_list args;
+ va_start(args, szFormat);
+ CallService(MS_NETLIB_LOG, (WPARAM)hNetlibUser, (LPARAM)(CMStringA().FormatV(szFormat, args)));
+ va_end(args);
+ }
+ __inline void Log(LPCWSTR wszFormat, ...) const
+ {
+ va_list args;
+ va_start(args, wszFormat);
+ CallService(MS_NETLIB_LOGW, (WPARAM)hNetlibUser, (LPARAM)(CMStringW().FormatV(wszFormat, args)));
+ va_end(args);
+ }
+};
+
+#endif //_TOX_LOGGER_H_
\ No newline at end of file diff --git a/protocols/Tox/src/tox_messages.cpp b/protocols/Tox/src/tox_messages.cpp index fe3b205b0b..6212ab91a4 100644 --- a/protocols/Tox/src/tox_messages.cpp +++ b/protocols/Tox/src/tox_messages.cpp @@ -77,7 +77,7 @@ int CToxProto::OnSendMessage(MCONTACT hContact, const char *szMessage) int messageId = tox_friend_send_message(toxThread->tox, friendNumber, type, msg, msgLen, &sendError);
if (sendError != TOX_ERR_FRIEND_SEND_MESSAGE_OK)
{
- debugLogA(__FUNCTION__": failed to send message for %d (%d)", friendNumber, sendError);
+ logger->Log(__FUNCTION__": failed to send message for %d (%d)", friendNumber, sendError);
return 0;
}
@@ -134,7 +134,7 @@ void CToxProto::GetStatusMessageAsync(void* arg) size_t size = tox_friend_get_status_message_size(toxThread->tox, friendNumber, &error);
if (error != TOX_ERR_FRIEND_QUERY::TOX_ERR_FRIEND_QUERY_OK)
{
- debugLogA(__FUNCTION__": failed to get status message for (%d) (%d)", friendNumber, error);
+ logger->Log(__FUNCTION__": failed to get status message for (%d) (%d)", friendNumber, error);
ProtoBroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_FAILED, (HANDLE)hContact, 0);
return;
}
@@ -142,7 +142,7 @@ void CToxProto::GetStatusMessageAsync(void* arg) ptrA statusMessage((char*)mir_calloc(size + 1));
if (!tox_friend_get_status_message(toxThread->tox, friendNumber, (uint8_t*)(char*)statusMessage, &error))
{
- debugLogA(__FUNCTION__": failed to get status message for (%d) (%d)", friendNumber, error);
+ logger->Log(__FUNCTION__": failed to get status message for (%d) (%d)", friendNumber, error);
ProtoBroadcastAck(hContact, ACKTYPE_AWAYMSG, ACKRESULT_FAILED, (HANDLE)hContact, 0);
return;
}
@@ -160,7 +160,7 @@ int CToxProto::OnUserIsTyping(MCONTACT hContact, int type) TOX_ERR_SET_TYPING error;
if (!tox_self_set_typing(toxThread->tox, friendNumber, type == PROTOTYPE_SELFTYPING_ON, &error))
- debugLogA(__FUNCTION__": failed to send typing (%d)", error);
+ logger->Log(__FUNCTION__": failed to send typing (%d)", error);
return 0;
}
diff --git a/protocols/Tox/src/tox_multimedia.cpp b/protocols/Tox/src/tox_multimedia.cpp index ca034a188c..2bdbb34a49 100644 --- a/protocols/Tox/src/tox_multimedia.cpp +++ b/protocols/Tox/src/tox_multimedia.cpp @@ -75,7 +75,7 @@ void CToxIncomingCall::OnAnswer(CCtrlBase*) return;
if (toxav_answer(m_proto->toxThread->toxAv, m_proto->calls[hContact], cSettings) == TOX_ERROR)
- m_proto->debugLogA(__FUNCTION__": failed to start call");
+ m_proto->logger->Log(__FUNCTION__": failed to start call");
}
//////////////////////////////////////////////////////////////////////////////////////////////
@@ -130,7 +130,7 @@ void CToxOutgoingCall::OnCall(CCtrlBase*) if (toxav_call(m_proto->toxThread->toxAv, &callId, friendNumber, cSettings, 10) == TOX_ERROR)
{
mir_free(cSettings);
- m_proto->debugLogA(__FUNCTION__": failed to start outgoing call");
+ m_proto->logger->Log(__FUNCTION__": failed to start outgoing call");
return;
}
mir_free(cSettings);
@@ -188,7 +188,7 @@ ToxAvCSettings* CToxProto::GetAudioCSettings() MMRESULT error = waveInGetDevCaps(deviceId, &wic, sizeof(WAVEINCAPS));
if (error != MMSYSERR_NOERROR)
{
- debugLogA(__FUNCTION__": failed to get input device caps (%d)", error);
+ logger->Log(__FUNCTION__": failed to get input device caps (%d)", error);
TCHAR errorMessage[MAX_PATH];
waveInGetErrorText(error, errorMessage, _countof(errorMessage));
@@ -243,7 +243,7 @@ ToxAvCSettings* CToxProto::GetAudioCSettings() }
else
{
- debugLogA(__FUNCTION__": failed to parse input device caps");
+ logger->Log(__FUNCTION__": failed to parse input device caps");
mir_free(cSettings);
return NULL;
}
@@ -261,7 +261,7 @@ void CToxProto::OnAvInvite(void*, int32_t callId, void *arg) int friendNumber = toxav_get_peer_id(proto->toxThread->toxAv, callId, 0);
if (friendNumber == TOX_ERROR)
{
- proto->debugLogA(__FUNCTION__": failed to get friend number");
+ proto->logger->Log(__FUNCTION__": failed to get friend number");
toxav_reject(proto->toxThread->toxAv, callId, NULL);
return;
}
@@ -269,7 +269,7 @@ void CToxProto::OnAvInvite(void*, int32_t callId, void *arg) MCONTACT hContact = proto->GetContact(friendNumber);
if (hContact == NULL)
{
- proto->debugLogA(__FUNCTION__": failed to find contact");
+ proto->logger->Log(__FUNCTION__": failed to find contact");
toxav_reject(proto->toxThread->toxAv, callId, NULL);
return;
}
@@ -277,14 +277,14 @@ void CToxProto::OnAvInvite(void*, int32_t callId, void *arg) ToxAvCSettings cSettings;
if (toxav_get_peer_csettings(proto->toxThread->toxAv, callId, 0, &cSettings) != av_ErrorNone)
{
- proto->debugLogA(__FUNCTION__": failed to get codec settings");
+ proto->logger->Log(__FUNCTION__": failed to get codec settings");
toxav_reject(proto->toxThread->toxAv, callId, NULL);
return;
}
if (cSettings.call_type != av_TypeAudio)
{
- proto->debugLogA(__FUNCTION__": video call is unsupported");
+ proto->logger->Log(__FUNCTION__": video call is unsupported");
toxav_reject(proto->toxThread->toxAv, callId, Translate("Video call is unsupported"));
return;
}
@@ -346,14 +346,14 @@ void CToxProto::OnAvCancel(void*, int32_t callId, void *arg) int friendNumber = toxav_get_peer_id(proto->toxThread->toxAv, callId, 0);
if (friendNumber == TOX_ERROR)
{
- proto->debugLogA(__FUNCTION__": failed to get friend number");
+ proto->logger->Log(__FUNCTION__": failed to get friend number");
return;
}
MCONTACT hContact = proto->GetContact(friendNumber);
if (hContact == NULL)
{
- proto->debugLogA(__FUNCTION__": failed to find contact");
+ proto->logger->Log(__FUNCTION__": failed to find contact");
return;
}
@@ -391,14 +391,14 @@ void CToxProto::OnAvReject(void*, int32_t callId, void *arg) int friendNumber = toxav_get_peer_id(proto->toxThread->toxAv, callId, 0);
if (friendNumber == TOX_ERROR)
{
- proto->debugLogA(__FUNCTION__": failed to get friend number");
+ proto->logger->Log(__FUNCTION__": failed to get friend number");
return;
}
MCONTACT hContact = proto->GetContact(friendNumber);
if (hContact == NULL)
{
- proto->debugLogA(__FUNCTION__": failed to find contact");
+ proto->logger->Log(__FUNCTION__": failed to find contact");
return;
}
@@ -415,14 +415,14 @@ void CToxProto::OnAvCallTimeout(void*, int32_t callId, void *arg) int friendNumber = toxav_get_peer_id(proto->toxThread->toxAv, callId, 0);
if (friendNumber == TOX_ERROR)
{
- proto->debugLogA(__FUNCTION__": failed to get friend number");
+ proto->logger->Log(__FUNCTION__": failed to get friend number");
return;
}
MCONTACT hContact = proto->GetContact(friendNumber);
if (hContact == NULL)
{
- proto->debugLogA(__FUNCTION__": failed to find contact");
+ proto->logger->Log(__FUNCTION__": failed to find contact");
return;
}
@@ -460,14 +460,14 @@ void CToxProto::OnAvStart(void*, int32_t callId, void *arg) int cSettingsError = toxav_get_peer_csettings(proto->toxThread->toxAv, callId, 0, &cSettings);
if (cSettingsError != av_ErrorNone)
{
- proto->debugLogA(__FUNCTION__": failed to get codec settings (%d)", cSettingsError);
+ proto->logger->Log(__FUNCTION__": failed to get codec settings (%d)", cSettingsError);
toxav_hangup(proto->toxThread->toxAv, callId);
return;
}
if (cSettings.call_type != av_TypeAudio)
{
- proto->debugLogA(__FUNCTION__": video call is unsupported");
+ proto->logger->Log(__FUNCTION__": video call is unsupported");
toxav_hangup(proto->toxThread->toxAv, callId);
return;
}
@@ -484,7 +484,7 @@ void CToxProto::OnAvStart(void*, int32_t callId, void *arg) MMRESULT error = waveOutOpen(&proto->hOutDevice, deviceId, &wfx, (DWORD_PTR)WaveOutCallback, (DWORD_PTR)proto, CALLBACK_FUNCTION);
if (error != MMSYSERR_NOERROR)
{
- proto->debugLogA(__FUNCTION__": failed to open audio device (%d)", error);
+ proto->logger->Log(__FUNCTION__": failed to open audio device (%d)", error);
toxav_hangup(proto->toxThread->toxAv, callId);
TCHAR errorMessage[MAX_PATH];
@@ -499,7 +499,7 @@ void CToxProto::OnAvStart(void*, int32_t callId, void *arg) int friendNumber = toxav_get_peer_id(proto->toxThread->toxAv, callId, 0);
if (friendNumber == TOX_ERROR)
{
- proto->debugLogA(__FUNCTION__": failed to get friend number");
+ proto->logger->Log(__FUNCTION__": failed to get friend number");
toxav_hangup(proto->toxThread->toxAv, callId);
return;
}
@@ -507,14 +507,14 @@ void CToxProto::OnAvStart(void*, int32_t callId, void *arg) MCONTACT hContact = proto->GetContact(friendNumber);
if (hContact == NULL)
{
- proto->debugLogA(__FUNCTION__": failed to find contact");
+ proto->logger->Log(__FUNCTION__": failed to find contact");
toxav_hangup(proto->toxThread->toxAv, callId);
return;
}
if (toxav_prepare_transmission(proto->toxThread->toxAv, callId, false) == TOX_ERROR)
{
- proto->debugLogA(__FUNCTION__": failed to prepare audio transmition");
+ proto->logger->Log(__FUNCTION__": failed to prepare audio transmition");
toxav_hangup(proto->toxThread->toxAv, callId);
return;
}
@@ -539,14 +539,14 @@ void CToxProto::OnAvEnd(void*, int32_t callId, void *arg) int friendNumber = toxav_get_peer_id(proto->toxThread->toxAv, callId, 0);
if (friendNumber == TOX_ERROR)
{
- proto->debugLogA(__FUNCTION__": failed to get friend number");
+ proto->logger->Log(__FUNCTION__": failed to get friend number");
return;
}
MCONTACT hContact = proto->GetContact(friendNumber);
if (hContact == NULL)
{
- proto->debugLogA(__FUNCTION__": failed to find contact");
+ proto->logger->Log(__FUNCTION__": failed to find contact");
return;
}
@@ -572,7 +572,7 @@ void CToxProto::OnAvPeerTimeout(void *av, int32_t callId, void *arg) return;
default:
- proto->debugLogA(__FUNCTION__": failed to handle callState");
+ proto->logger->Log(__FUNCTION__": failed to handle callState");
break;
}
}
@@ -591,14 +591,14 @@ void CToxProto::OnFriendAudio(void*, int32_t, const int16_t *PCM, uint16_t size, MMRESULT error = waveOutPrepareHeader(proto->hOutDevice, header, sizeof(WAVEHDR));
if (error != MMSYSERR_NOERROR)
{
- proto->debugLogA(__FUNCTION__": failed to prepare audio buffer (%d)", error);
+ proto->logger->Log(__FUNCTION__": failed to prepare audio buffer (%d)", error);
return;
}
error = waveOutWrite(proto->hOutDevice, header, sizeof(WAVEHDR));
if (error != MMSYSERR_NOERROR)
{
- proto->debugLogA(__FUNCTION__": failed to play audio samples (%d)", error);
+ proto->logger->Log(__FUNCTION__": failed to play audio samples (%d)", error);
return;
}
}
\ No newline at end of file diff --git a/protocols/Tox/src/tox_netlib.cpp b/protocols/Tox/src/tox_netlib.cpp index 4c1ae3e09f..580a024360 100644 --- a/protocols/Tox/src/tox_netlib.cpp +++ b/protocols/Tox/src/tox_netlib.cpp @@ -12,7 +12,9 @@ void CToxProto::InitNetlib() nlu.szSettingsModule = m_szModuleName;
hNetlib = (HANDLE)CallService(MS_NETLIB_REGISTERUSER, 0, (LPARAM)&nlu);
- debugLogA("Setting protocol/module name to '%s'", m_szModuleName);
+ logger = new CLogger(hNetlib);
+
+ logger->Log("Setting protocol/module name to '%s'", m_szModuleName);
}
void CToxProto::UninitNetlib()
diff --git a/protocols/Tox/src/tox_network.cpp b/protocols/Tox/src/tox_network.cpp index 03134d1034..956378d9c4 100644 --- a/protocols/Tox/src/tox_network.cpp +++ b/protocols/Tox/src/tox_network.cpp @@ -12,9 +12,9 @@ void CToxProto::BootstrapNode(const char *address, int port, const char *hexKey) ToxBinAddress binKey(hexKey, TOX_PUBLIC_KEY_SIZE * 2);
TOX_ERR_BOOTSTRAP error;
if (!tox_bootstrap(toxThread->tox, address, port, binKey, &error))
- debugLogA(__FUNCTION__ ": failed to bootstrap node %s:%d \"%s\" (%d)", address, port, hexKey, error);
+ logger->Log(__FUNCTION__ ": failed to bootstrap node %s:%d \"%s\" (%d)", address, port, hexKey, error);
if (!tox_add_tcp_relay(toxThread->tox, address, port, binKey, &error))
- debugLogA(__FUNCTION__ ": failed to add tcp relay %s:%d \"%s\" (%d)", address, port, hexKey, error);
+ logger->Log(__FUNCTION__ ": failed to add tcp relay %s:%d \"%s\" (%d)", address, port, hexKey, error);
}
void CToxProto::BootstrapNodesFromDb(bool isIPv6)
@@ -78,7 +78,7 @@ void CToxProto::BootstrapNodesFromIni(bool isIPv6) void CToxProto::BootstrapNodes()
{
- debugLogA(__FUNCTION__": bootstraping DHT");
+ logger->Log(__FUNCTION__": bootstraping DHT");
bool isIPv6 = getBool("EnableIPv6", 0);
BootstrapNodesFromDb(isIPv6);
BootstrapNodesFromIni(isIPv6);
@@ -89,20 +89,20 @@ void CToxProto::TryConnect() if (tox_self_get_connection_status(toxThread->tox) != TOX_CONNECTION_NONE)
{
toxThread->isConnected = true;
- debugLogA(__FUNCTION__": successfuly connected to DHT");
+ logger->Log(__FUNCTION__": successfuly connected to DHT");
ForkThread(&CToxProto::LoadFriendList, NULL);
m_iStatus = m_iDesiredStatus;
ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)ID_STATUS_CONNECTING, m_iStatus);
tox_self_set_status(toxThread->tox, MirandaToToxStatus(m_iStatus));
- debugLogA(__FUNCTION__": changing status from %i to %i", ID_STATUS_CONNECTING, m_iDesiredStatus);
+ logger->Log(__FUNCTION__": changing status from %i to %i", ID_STATUS_CONNECTING, m_iDesiredStatus);
}
else if (m_iStatus++ > TOX_MAX_CONNECT_RETRIES)
{
SetStatus(ID_STATUS_OFFLINE);
ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, (HANDLE)NULL, LOGINERR_NONETWORK);
- debugLogA(__FUNCTION__": failed to connect to DHT");
+ logger->Log(__FUNCTION__": failed to connect to DHT");
}
}
@@ -116,7 +116,7 @@ void CToxProto::CheckConnection(int &retriesCount) {
if (retriesCount < TOX_MAX_DISCONNECT_RETRIES)
{
- debugLogA(__FUNCTION__": restored connection with DHT");
+ logger->Log(__FUNCTION__": restored connection with DHT");
retriesCount = TOX_MAX_DISCONNECT_RETRIES;
}
}
@@ -125,7 +125,7 @@ void CToxProto::CheckConnection(int &retriesCount) if (retriesCount == TOX_MAX_DISCONNECT_RETRIES)
{
retriesCount--;
- debugLogA(__FUNCTION__": lost connection with DHT");
+ logger->Log(__FUNCTION__": lost connection with DHT");
}
else if (retriesCount % 50 == 0)
{
@@ -135,21 +135,21 @@ void CToxProto::CheckConnection(int &retriesCount) else if (!(--retriesCount))
{
toxThread->isConnected = false;
- debugLogA(__FUNCTION__": disconnected from DHT");
+ logger->Log(__FUNCTION__": disconnected from DHT");
SetStatus(ID_STATUS_OFFLINE);
}
}
}
-void DoTox(ToxThreadData *toxThread)
+void DoTox(ToxThreadData &toxThread)
{
{
- mir_cslock lock(toxThread->toxLock);
- tox_iterate(toxThread->tox);
- if (toxThread->toxAv)
- toxav_do(toxThread->toxAv);
+ mir_cslock lock(toxThread.toxLock);
+ tox_iterate(toxThread.tox);
+ if (toxThread.toxAv)
+ toxav_do(toxThread.toxAv);
}
- uint32_t interval = tox_iteration_interval(toxThread->tox);
+ uint32_t interval = tox_iteration_interval(toxThread.tox);
Sleep(interval);
}
@@ -158,13 +158,13 @@ void CToxProto::PollingThread(void*) ToxThreadData toxThread;
this->toxThread = &toxThread;
- debugLogA(__FUNCTION__": entering");
+ logger->Log(__FUNCTION__": entering");
if (!InitToxCore(&toxThread))
{
SetStatus(ID_STATUS_OFFLINE);
ProtoBroadcastAck(NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, (HANDLE)NULL, LOGINERR_WRONGPASSWORD);
- debugLogA(__FUNCTION__": leaving");
+ logger->Log(__FUNCTION__": leaving");
return;
}
@@ -175,11 +175,11 @@ void CToxProto::PollingThread(void*) while (!toxThread.isTerminated)
{
CheckConnection(retriesCount);
- DoTox(&toxThread);
+ DoTox(toxThread);
}
UninitToxCore(&toxThread);
toxThread.isConnected = false;
- debugLogA(__FUNCTION__": leaving");
+ logger->Log(__FUNCTION__": leaving");
}
\ No newline at end of file diff --git a/protocols/Tox/src/tox_options.cpp b/protocols/Tox/src/tox_options.cpp index ddebf72d92..8ce1da4526 100644 --- a/protocols/Tox/src/tox_options.cpp +++ b/protocols/Tox/src/tox_options.cpp @@ -26,7 +26,7 @@ void CToxOptionsMain::OnInitDialog() {
CToxDlgBase::OnInitDialog();
- std::tstring profilePath = m_proto->GetToxProfilePath();
+ ptrT profilePath(m_proto->GetToxProfilePath());
if (CToxProto::IsFileExists(profilePath))
{
m_toxAddress.Enable();
@@ -64,13 +64,13 @@ void CToxOptionsMain::ProfileCreate_OnClick(CCtrlButton*) {
ToxThreadData toxThread;
- std::tstring profilePath = m_proto->GetToxProfilePath();
+ ptrT profilePath(m_proto->GetToxProfilePath());
if (!m_proto->IsFileExists(profilePath))
{
- HANDLE hProfile = CreateFile(profilePath.c_str(), GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
+ HANDLE hProfile = CreateFile(profilePath, GENERIC_READ | GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
if (hProfile == NULL)
{
- m_proto->debugLogA(__FUNCTION__": failed to create tox profile");
+ m_proto->logger->Log(__FUNCTION__": failed to create tox profile");
return;
}
CloseHandle(hProfile);
@@ -79,7 +79,7 @@ void CToxOptionsMain::ProfileCreate_OnClick(CCtrlButton*) toxThread.tox = tox_new(NULL, &initError);
if (initError != TOX_ERR_NEW_OK)
{
- m_proto->debugLogA(__FUNCTION__": failed to load tox profile (%d)", initError);
+ m_proto->logger->Log(__FUNCTION__": failed to load tox profile (%d)", initError);
return;
}
}
@@ -131,10 +131,10 @@ void CToxOptionsMain::ProfileImport_OnClick(CCtrlButton*) return;
}
- std::tstring defaultProfilePath = m_proto->GetToxProfilePath();
- if (mir_tstrcmpi(profilePath, defaultProfilePath.c_str()) != 0)
+ ptrT defaultProfilePath(m_proto->GetToxProfilePath());
+ if (mir_tstrcmpi(profilePath, defaultProfilePath) != 0)
{
- CopyFile(profilePath, defaultProfilePath.c_str(), FALSE);
+ CopyFile(profilePath, defaultProfilePath, FALSE);
}
m_profileCreate.OnClick(&m_profileCreate);
@@ -162,9 +162,9 @@ void CToxOptionsMain::ProfileExport_OnClick(CCtrlButton*) if (!GetSaveFileName(&ofn))
return;
- std::tstring defaultProfilePath = m_proto->GetToxProfilePath();
- if (mir_tstrcmpi(profilePath, defaultProfilePath.c_str()) != 0)
- CopyFile(defaultProfilePath.c_str(), profilePath, FALSE);
+ ptrT defaultProfilePath(m_proto->GetToxProfilePath());
+ if (mir_tstrcmpi(profilePath, defaultProfilePath) != 0)
+ CopyFile(defaultProfilePath, profilePath, FALSE);
}
void CToxOptionsMain::OnApply()
diff --git a/protocols/Tox/src/tox_profile.cpp b/protocols/Tox/src/tox_profile.cpp index 82754c5d6c..796cdf6606 100644 --- a/protocols/Tox/src/tox_profile.cpp +++ b/protocols/Tox/src/tox_profile.cpp @@ -2,14 +2,14 @@ HANDLE CToxProto::hProfileFolderPath;
-std::tstring CToxProto::GetToxProfilePath()
+TCHAR* CToxProto::GetToxProfilePath()
{
return GetToxProfilePath(m_tszUserName);
}
-std::tstring CToxProto::GetToxProfilePath(const TCHAR *accountName)
+TCHAR* CToxProto::GetToxProfilePath(const TCHAR *accountName)
{
- TCHAR profilePath[MAX_PATH];
+ TCHAR *profilePath = (TCHAR*)mir_calloc(MAX_PATH * sizeof(TCHAR) + 1);
TCHAR profileRootPath[MAX_PATH];
FoldersGetCustomPathT(hProfileFolderPath, profileRootPath, _countof(profileRootPath), VARST(_T("%miranda_userdata%")));
mir_sntprintf(profilePath, MAX_PATH, _T("%s\\%s.tox"), profileRootPath, accountName);
@@ -18,22 +18,22 @@ std::tstring CToxProto::GetToxProfilePath(const TCHAR *accountName) bool CToxProto::LoadToxProfile(Tox_Options *options)
{
- debugLogA(__FUNCTION__": loading tox profile");
+ logger->Log(__FUNCTION__": loading tox profile");
mir_cslock locker(profileLock);
size_t size = 0;
uint8_t *data = NULL;
- std::tstring profilePath = GetToxProfilePath();
+ ptrT profilePath(GetToxProfilePath());
if (!IsFileExists(profilePath))
return false;
- FILE *profile = _tfopen(profilePath.c_str(), _T("rb"));
+ FILE *profile = _tfopen(profilePath, _T("rb"));
if (profile == NULL)
{
ShowNotification(TranslateT("Unable to open Tox profile"), MB_ICONERROR);
- debugLogA(__FUNCTION__": failed to open tox profile");
+ logger->Log(__FUNCTION__": failed to open tox profile");
return false;
}
@@ -51,7 +51,7 @@ bool CToxProto::LoadToxProfile(Tox_Options *options) {
fclose(profile);
ShowNotification(TranslateT("Unable to read Tox profile"), MB_ICONERROR);
- debugLogA(__FUNCTION__": failed to read tox profile");
+ logger->Log(__FUNCTION__": failed to read tox profile");
mir_free(data);
return false;
}
@@ -74,7 +74,7 @@ bool CToxProto::LoadToxProfile(Tox_Options *options) if (!tox_pass_decrypt(data, size, (uint8_t*)(char*)password, mir_strlen(password), encryptedData, &coreDecryptError))
{
ShowNotification(TranslateT("Unable to decrypt Tox profile"), MB_ICONERROR);
- debugLogA(__FUNCTION__": failed to decrypt tox profile (%d)", coreDecryptError);
+ logger->Log(__FUNCTION__": failed to decrypt tox profile (%d)", coreDecryptError);
mir_free(data);
return false;
}
@@ -111,18 +111,18 @@ void CToxProto::SaveToxProfile() TOX_ERR_ENCRYPTION coreEncryptError;
if (!tox_pass_encrypt(data, size, (uint8_t*)(char*)password, mir_strlen(password), data, &coreEncryptError))
{
- debugLogA(__FUNCTION__": failed to encrypt tox profile");
+ logger->Log(__FUNCTION__": failed to encrypt tox profile");
mir_free(data);
return;
}
size += TOX_PASS_ENCRYPTION_EXTRA_LENGTH;
}
- std::tstring profilePath = GetToxProfilePath();
- FILE *profile = _tfopen(profilePath.c_str(), _T("wb"));
+ ptrT profilePath(GetToxProfilePath());
+ FILE *profile = _tfopen(profilePath, _T("wb"));
if (profile == NULL)
{
- debugLogA(__FUNCTION__": failed to open tox profile");
+ logger->Log(__FUNCTION__": failed to open tox profile");
mir_free(data);
return;
}
@@ -130,7 +130,7 @@ void CToxProto::SaveToxProfile() size_t written = fwrite(data, sizeof(char), size, profile);
if (size != written)
{
- debugLogA(__FUNCTION__": failed to write tox profile");
+ logger->Log(__FUNCTION__": failed to write tox profile");
}
fclose(profile);
diff --git a/protocols/Tox/src/tox_proto.cpp b/protocols/Tox/src/tox_proto.cpp index d2f9b943de..a9b749f184 100644 --- a/protocols/Tox/src/tox_proto.cpp +++ b/protocols/Tox/src/tox_proto.cpp @@ -145,25 +145,9 @@ int CToxProto::SetStatus(int iNewStatus) if (iNewStatus == m_iDesiredStatus)
return 0;
- switch (iNewStatus)
- {
- case ID_STATUS_FREECHAT:
- case ID_STATUS_ONTHEPHONE:
- iNewStatus = ID_STATUS_ONLINE;
- break;
-
- case ID_STATUS_NA:
- case ID_STATUS_OUTTOLUNCH:
- iNewStatus = ID_STATUS_AWAY;
- break;
-
- case ID_STATUS_DND:
- case ID_STATUS_INVISIBLE:
- iNewStatus = ID_STATUS_OCCUPIED;
- break;
- }
+ iNewStatus = MapStatus(iNewStatus);
- debugLogA("CToxProto::SetStatus: changing status from %i to %i", m_iStatus, iNewStatus);
+ logger->Log("CToxProto::SetStatus: changing status from %i to %i", m_iStatus, iNewStatus);
int old_status = m_iStatus;
m_iDesiredStatus = iNewStatus;
@@ -172,8 +156,10 @@ int CToxProto::SetStatus(int iNewStatus) {
// logout
if (toxThread)
- toxThread->isTerminated = true;
- toxThread = NULL;
+ {
+ toxThread->Stop();
+ toxThread = NULL;
+ }
if (!Miranda_Terminated())
{
@@ -182,27 +168,25 @@ int CToxProto::SetStatus(int iNewStatus) }
m_iStatus = m_iDesiredStatus = ID_STATUS_OFFLINE;
+ ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, m_iStatus);
+ return 0;
}
- else
- {
- if (old_status == ID_STATUS_CONNECTING)
- {
- return 0;
- }
- if (old_status == ID_STATUS_OFFLINE && !IsOnline())
- {
- // login
- m_iStatus = ID_STATUS_CONNECTING;
+ if (old_status == ID_STATUS_CONNECTING)
+ return 0;
- hPollingThread = ForkThreadEx(&CToxProto::PollingThread, 0, NULL);
- }
- else
- {
- // set tox status
- m_iStatus = iNewStatus;
- tox_self_set_status(toxThread->tox, MirandaToToxStatus(iNewStatus));
- }
+ if (old_status == ID_STATUS_OFFLINE && !IsOnline())
+ {
+ // login
+ m_iStatus = ID_STATUS_CONNECTING;
+
+ hPollingThread = ForkThreadEx(&CToxProto::PollingThread, NULL, NULL);
+ }
+ else
+ {
+ // set tox status
+ m_iStatus = iNewStatus;
+ tox_self_set_status(toxThread->tox, MirandaToToxStatus(iNewStatus));
}
ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)old_status, m_iStatus);
@@ -227,7 +211,7 @@ int CToxProto::SetAwayMsg(int, const TCHAR *msg) T2Utf statusMessage(msg);
TOX_ERR_SET_INFO error;
if (tox_self_set_status_message(toxThread->tox, (uint8_t*)(char*)statusMessage, min(TOX_MAX_STATUS_MESSAGE_LENGTH, mir_strlen(statusMessage)), &error))
- debugLogA("CToxProto::SetAwayMsg: failed to set status status message %s (%d)", msg, error);
+ logger->Log("CToxProto::SetAwayMsg: failed to set status status message %s (%d)", msg, error);
}
return 0;
diff --git a/protocols/Tox/src/tox_proto.h b/protocols/Tox/src/tox_proto.h index 9b8b2e171c..5c42073af0 100644 --- a/protocols/Tox/src/tox_proto.h +++ b/protocols/Tox/src/tox_proto.h @@ -12,6 +12,8 @@ struct ToxThreadData ToxThreadData() : tox(NULL), toxAv(NULL),
isConnected(false), isTerminated(false) { }
+
+ void Stop() { isTerminated = true; }
};
struct CToxProto : public PROTO<CToxProto>
@@ -87,12 +89,13 @@ private: TCHAR *accountName;
HANDLE hNetlib, hPollingThread;
CTransferList transfers;
+ CLogger *logger;
static HANDLE hProfileFolderPath;
// tox profile
- std::tstring GetToxProfilePath();
- static std::tstring CToxProto::GetToxProfilePath(const TCHAR *accountName);
+ TCHAR* GetToxProfilePath();
+ static TCHAR* CToxProto::GetToxProfilePath(const TCHAR *accountName);
bool LoadToxProfile(Tox_Options *options);
void SaveToxProfile();
@@ -250,8 +253,8 @@ private: void ResumeIncomingTransfers(uint32_t friendNumber);
// avatars
- std::tstring GetAvatarFilePath(MCONTACT hContact = NULL);
- void SetToxAvatar(std::tstring path);
+ TCHAR* GetAvatarFilePath(MCONTACT hContact = NULL);
+ void SetToxAvatar(const TCHAR* path);
INT_PTR __cdecl GetAvatarCaps(WPARAM wParam, LPARAM lParam);
INT_PTR __cdecl GetAvatarInfo(WPARAM, LPARAM lParam);
@@ -283,15 +286,16 @@ private: static void OnAvPeerTimeout(void*, int32_t callId, void *arg);
// utils
- TOX_USER_STATUS MirandaToToxStatus(int status);
- int ToxToMirandaStatus(TOX_USER_STATUS userstatus);
+ static int MapStatus(int status);
+ static TOX_USER_STATUS MirandaToToxStatus(int status);
+ static int ToxToMirandaStatus(TOX_USER_STATUS userstatus);
static TCHAR* ToxErrorToString(TOX_ERR_NEW error);
static void ShowNotification(const TCHAR *message, int flags = 0, MCONTACT hContact = NULL);
static void ShowNotification(const TCHAR *caption, const TCHAR *message, int flags = 0, MCONTACT hContact = NULL);
- static bool IsFileExists(std::tstring path);
+ static bool IsFileExists(const TCHAR* path);
MEVENT AddEventToDb(MCONTACT hContact, WORD type, DWORD timestamp, DWORD flags, PBYTE pBlob, size_t cbBlob);
diff --git a/protocols/Tox/src/tox_services.cpp b/protocols/Tox/src/tox_services.cpp index 2a2c188e59..c5ead26307 100644 --- a/protocols/Tox/src/tox_services.cpp +++ b/protocols/Tox/src/tox_services.cpp @@ -10,7 +10,7 @@ INT_PTR CToxProto::SetMyNickname(WPARAM wParam, LPARAM lParam) T2Utf szNick8(nickname);
TOX_ERR_SET_INFO error;
if (!tox_self_set_name(toxThread->tox, szNick8, mir_strlen(szNick8), &error))
- debugLogA(__FUNCTION__": failed to set nick name");
+ logger->Log(__FUNCTION__": failed to set nick name");
}
return 0;
diff --git a/protocols/Tox/src/tox_transfer.cpp b/protocols/Tox/src/tox_transfer.cpp index cef5c4bec9..fb6e6f7a48 100644 --- a/protocols/Tox/src/tox_transfer.cpp +++ b/protocols/Tox/src/tox_transfer.cpp @@ -14,7 +14,7 @@ void CToxProto::OnFriendFile(Tox*, uint32_t friendNumber, uint32_t fileNumber, u {
case TOX_FILE_KIND_AVATAR:
{
- proto->debugLogA(__FUNCTION__": incoming avatar (%d) from (%d)", fileNumber, friendNumber);
+ proto->logger->Log(__FUNCTION__": incoming avatar (%d) from (%d)", fileNumber, friendNumber);
ptrT address(proto->getTStringA(hContact, TOX_SETTINGS_ID));
TCHAR avatarName[MAX_PATH];
@@ -29,7 +29,7 @@ void CToxProto::OnFriendFile(Tox*, uint32_t friendNumber, uint32_t fileNumber, u tox_file_get_file_id(proto->toxThread->tox, friendNumber, fileNumber, transfer->hash, &error);
if (error != TOX_ERR_FILE_GET_OK)
{
- proto->debugLogA(__FUNCTION__": unable to get avatar hash (%d) from (%d) cause (%d)", fileNumber, friendNumber, error);
+ proto->logger->Log(__FUNCTION__": unable to get avatar hash (%d) from (%d) cause (%d)", fileNumber, friendNumber, error);
memset(transfer->hash, 0, TOX_HASH_LENGTH);
}
proto->OnGotFriendAvatarInfo(transfer);
@@ -38,7 +38,7 @@ void CToxProto::OnFriendFile(Tox*, uint32_t friendNumber, uint32_t fileNumber, u case TOX_FILE_KIND_DATA:
{
- proto->debugLogA(__FUNCTION__": incoming file (%d) from (%d)", fileNumber, friendNumber);
+ proto->logger->Log(__FUNCTION__": incoming file (%d) from (%d)", fileNumber, friendNumber);
ptrA rawName((char*)mir_alloc(filenameLength + 1));
memcpy(rawName, fileName, filenameLength);
@@ -62,7 +62,7 @@ void CToxProto::OnFriendFile(Tox*, uint32_t friendNumber, uint32_t fileNumber, u break;
default:
- proto->debugLogA(__FUNCTION__": unsupported transfer (%d) from (%d) with type (%d)", fileNumber, friendNumber, kind);
+ proto->logger->Log(__FUNCTION__": unsupported transfer (%d) from (%d) with type (%d)", fileNumber, friendNumber, kind);
return;
}
}
@@ -110,17 +110,17 @@ int CToxProto::OnFileResume(HANDLE hTransfer, int *action, const TCHAR **szFilen TCHAR *mode = *action == FILERESUME_OVERWRITE ? _T("wb") : _T("ab");
if (!transfer->OpenFile(mode))
{
- debugLogA(__FUNCTION__": failed to open file (%d) from (%d)", transfer->fileNumber, transfer->friendNumber);
+ logger->Log(__FUNCTION__": failed to open file (%d) from (%d)", transfer->fileNumber, transfer->friendNumber);
tox_file_control(toxThread->tox, transfer->friendNumber, transfer->fileNumber, TOX_FILE_CONTROL_CANCEL, NULL);
transfers.Remove(transfer);
return NULL;
}
TOX_ERR_FILE_CONTROL error;
- debugLogA(__FUNCTION__": start receiving file (%d) from (%d)", transfer->fileNumber, transfer->friendNumber);
+ logger->Log(__FUNCTION__": start receiving file (%d) from (%d)", transfer->fileNumber, transfer->friendNumber);
if (!tox_file_control(toxThread->tox, transfer->friendNumber, transfer->fileNumber, TOX_FILE_CONTROL_RESUME, &error))
{
- debugLogA(__FUNCTION__": failed to start receiving of file(%d) from (%d) cause (%d)", transfer->fileNumber, transfer->friendNumber, error);
+ logger->Log(__FUNCTION__": failed to start receiving of file(%d) from (%d) cause (%d)", transfer->fileNumber, transfer->friendNumber, error);
ProtoBroadcastAck(transfer->pfts.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, (HANDLE)transfer, 0);
tox_file_control(toxThread->tox, transfer->friendNumber, transfer->fileNumber, TOX_FILE_CONTROL_CANCEL, NULL);
transfers.Remove(transfer);
@@ -131,10 +131,10 @@ int CToxProto::OnFileResume(HANDLE hTransfer, int *action, const TCHAR **szFilen void CToxProto::OnTransferCompleted(FileTransferParam *transfer)
{
- debugLogA(__FUNCTION__": finised the transfer of file (%d) from (%d)", transfer->fileNumber, transfer->friendNumber);
+ logger->Log(__FUNCTION__": finised the transfer of file (%d) from (%d)", transfer->fileNumber, transfer->friendNumber);
bool isFileFullyTransfered = transfer->pfts.currentFileProgress == transfer->pfts.currentFileSize;
if (!isFileFullyTransfered)
- debugLogA(__FUNCTION__": file (%d) from (%d) is transferred not completely", transfer->fileNumber, transfer->friendNumber);
+ logger->Log(__FUNCTION__": file (%d) from (%d) is transferred not completely", transfer->fileNumber, transfer->friendNumber);
if (transfer->transferType == TOX_FILE_KIND_AVATAR)
{
@@ -154,7 +154,7 @@ void CToxProto::OnDataReceiving(Tox*, uint32_t friendNumber, uint32_t fileNumber FileTransferParam *transfer = proto->transfers.Get(friendNumber, fileNumber);
if (transfer == NULL)
{
- proto->debugLogA(__FUNCTION__": failed to find transfer (%d) from (%d)", fileNumber, friendNumber);
+ proto->logger->Log(__FUNCTION__": failed to find transfer (%d) from (%d)", fileNumber, friendNumber);
return;
}
@@ -168,7 +168,7 @@ void CToxProto::OnDataReceiving(Tox*, uint32_t friendNumber, uint32_t fileNumber MCONTACT hContact = proto->GetContact(friendNumber);
if (hContact == NULL)
{
- proto->debugLogA(__FUNCTION__": cannot find contact by number (%d)", friendNumber);
+ proto->logger->Log(__FUNCTION__": cannot find contact by number (%d)", friendNumber);
tox_file_control(proto->toxThread->tox, friendNumber, fileNumber, TOX_FILE_CONTROL_CANCEL, NULL);
return;
}
@@ -179,7 +179,7 @@ void CToxProto::OnDataReceiving(Tox*, uint32_t friendNumber, uint32_t fileNumber if (fwrite(data, sizeof(uint8_t), length, transfer->hFile) != length)
{
- proto->debugLogA(__FUNCTION__": failed write to file (%d)", fileNumber);
+ proto->logger->Log(__FUNCTION__": failed write to file (%d)", fileNumber);
proto->ProtoBroadcastAck(transfer->pfts.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, (HANDLE)transfer, 0);
tox_file_control(proto->toxThread->tox, friendNumber, fileNumber, TOX_FILE_CONTROL_CANCEL, NULL);
return;
@@ -202,7 +202,7 @@ HANDLE CToxProto::OnSendFile(MCONTACT hContact, const TCHAR*, TCHAR **ppszFiles) FILE *hFile = _tfopen(ppszFiles[0], _T("rb"));
if (hFile == NULL)
{
- debugLogA(__FUNCTION__": cannot open file %s", ppszFiles[0]);
+ logger->Log(__FUNCTION__": cannot open file %s", ppszFiles[0]);
return NULL;
}
@@ -221,12 +221,12 @@ HANDLE CToxProto::OnSendFile(MCONTACT hContact, const TCHAR*, TCHAR **ppszFiles) uint32_t fileNumber = tox_file_send(toxThread->tox, friendNumber, TOX_FILE_KIND_DATA, fileSize, NULL, (uint8_t*)name, mir_strlen(name), &sendError);
if (sendError != TOX_ERR_FILE_SEND_OK)
{
- debugLogA(__FUNCTION__": failed to send file (%d) to (%d) cause (%d)", fileNumber, friendNumber, sendError);
+ logger->Log(__FUNCTION__": failed to send file (%d) to (%d) cause (%d)", fileNumber, friendNumber, sendError);
mir_free(fileDir);
mir_free(name);
return NULL;
}
- debugLogA(__FUNCTION__": start sending file (%d) to (%d)", fileNumber, friendNumber);
+ logger->Log(__FUNCTION__": start sending file (%d) to (%d)", fileNumber, friendNumber);
FileTransferParam *transfer = new FileTransferParam(friendNumber, fileNumber, fileName, fileSize);
transfer->pfts.flags |= PFTS_SENDING;
@@ -246,17 +246,17 @@ void CToxProto::OnFileSendData(Tox*, uint32_t friendNumber, uint32_t fileNumber, FileTransferParam *transfer = proto->transfers.Get(friendNumber, fileNumber);
if (transfer == NULL)
{
- proto->debugLogA(__FUNCTION__": failed to find transfer (%d) to (%d)", fileNumber, friendNumber);
+ proto->logger->Log(__FUNCTION__": failed to find transfer (%d) to (%d)", fileNumber, friendNumber);
return;
}
if (length == 0)
{
// file sending is finished
- proto->debugLogA(__FUNCTION__": finised the transfer of file (%d) to (%d)", fileNumber, friendNumber);
+ proto->logger->Log(__FUNCTION__": finised the transfer of file (%d) to (%d)", fileNumber, friendNumber);
bool isFileFullyTransfered = transfer->pfts.currentFileProgress == transfer->pfts.currentFileSize;
if (!isFileFullyTransfered)
- proto->debugLogA(__FUNCTION__": file (%d) is not completely transferred to (%d)", fileNumber, friendNumber);
+ proto->logger->Log(__FUNCTION__": file (%d) is not completely transferred to (%d)", fileNumber, friendNumber);
proto->ProtoBroadcastAck(transfer->pfts.hContact, ACKTYPE_FILE, isFileFullyTransfered ? ACKRESULT_SUCCESS : ACKRESULT_FAILED, (HANDLE)transfer, 0);
proto->transfers.Remove(transfer);
return;
@@ -269,7 +269,7 @@ void CToxProto::OnFileSendData(Tox*, uint32_t friendNumber, uint32_t fileNumber, uint8_t *data = (uint8_t*)mir_alloc(length);
if (fread(data, sizeof(uint8_t), length, transfer->hFile) != length)
{
- proto->debugLogA(__FUNCTION__": failed to read from file (%d) to (%d)", fileNumber, friendNumber);
+ proto->logger->Log(__FUNCTION__": failed to read from file (%d) to (%d)", fileNumber, friendNumber);
proto->ProtoBroadcastAck(transfer->pfts.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, (HANDLE)transfer, 0);
tox_file_control(proto->toxThread->tox, transfer->friendNumber, transfer->fileNumber, TOX_FILE_CONTROL_CANCEL, NULL);
mir_free(data);
@@ -284,7 +284,7 @@ void CToxProto::OnFileSendData(Tox*, uint32_t friendNumber, uint32_t fileNumber, mir_free(data);
return;
}
- proto->debugLogA(__FUNCTION__": failed to send file chunk (%d) to (%d) cause (%d)", fileNumber, friendNumber, error);
+ proto->logger->Log(__FUNCTION__": failed to send file chunk (%d) to (%d) cause (%d)", fileNumber, friendNumber, error);
proto->ProtoBroadcastAck(transfer->pfts.hContact, ACKTYPE_FILE, ACKRESULT_FAILED, (HANDLE)transfer, 0);
tox_file_control(proto->toxThread->tox, transfer->friendNumber, transfer->fileNumber, TOX_FILE_CONTROL_CANCEL, NULL);
mir_free(data);
@@ -303,7 +303,7 @@ void CToxProto::OnFileSendData(Tox*, uint32_t friendNumber, uint32_t fileNumber, int CToxProto::OnFileCancel(MCONTACT, HANDLE hTransfer)
{
FileTransferParam *transfer = (FileTransferParam*)hTransfer;
- debugLogA(__FUNCTION__": Transfer (%d) is canceled", transfer->fileNumber);
+ logger->Log(__FUNCTION__": Transfer (%d) is canceled", transfer->fileNumber);
tox_file_control(toxThread->tox, transfer->friendNumber, transfer->fileNumber, TOX_FILE_CONTROL_CANCEL, NULL);
transfers.Remove(transfer);
@@ -318,11 +318,11 @@ void CToxProto::PauseOutgoingTransfers(uint32_t friendNumber) FileTransferParam *transfer = transfers.GetAt(i);
if (transfer->friendNumber == friendNumber && transfer->GetDirection() == 0)
{
- debugLogA(__FUNCTION__": sending ask to pause the transfer of file (%d) to (%d)", transfer->fileNumber, transfer->friendNumber);
+ logger->Log(__FUNCTION__": sending ask to pause the transfer of file (%d) to (%d)", transfer->fileNumber, transfer->friendNumber);
TOX_ERR_FILE_CONTROL error;
if (!tox_file_control(toxThread->tox, transfer->friendNumber, transfer->fileNumber, TOX_FILE_CONTROL_PAUSE, &error))
{
- debugLogA(__FUNCTION__": failed to pause the transfer (%d) to (%d) cause(%d)", transfer->fileNumber, transfer->friendNumber, error);
+ logger->Log(__FUNCTION__": failed to pause the transfer (%d) to (%d) cause(%d)", transfer->fileNumber, transfer->friendNumber, error);
tox_file_control(toxThread->tox, transfer->friendNumber, transfer->fileNumber, TOX_FILE_CONTROL_CANCEL, NULL);
}
}
@@ -337,11 +337,11 @@ void CToxProto::ResumeIncomingTransfers(uint32_t friendNumber) FileTransferParam *transfer = transfers.GetAt(i);
if (transfer->friendNumber == friendNumber && transfer->GetDirection() == 1)
{
- debugLogA(__FUNCTION__": sending ask to resume the transfer of file (%d) from (%d) cause(%d)", transfer->fileNumber, transfer->friendNumber);
+ logger->Log(__FUNCTION__": sending ask to resume the transfer of file (%d) from (%d) cause(%d)", transfer->fileNumber, transfer->friendNumber);
TOX_ERR_FILE_CONTROL error;
if (!tox_file_control(toxThread->tox, transfer->friendNumber, transfer->fileNumber, TOX_FILE_CONTROL_RESUME, &error))
{
- debugLogA(__FUNCTION__": failed to resume the transfer (%d) from (%d) cause(%d)", transfer->fileNumber, transfer->friendNumber, error);
+ logger->Log(__FUNCTION__": failed to resume the transfer (%d) from (%d) cause(%d)", transfer->fileNumber, transfer->friendNumber, error);
tox_file_control(toxThread->tox, transfer->friendNumber, transfer->fileNumber, TOX_FILE_CONTROL_CANCEL, NULL);
}
}
@@ -358,7 +358,7 @@ void CToxProto::OnFileRequest(Tox*, uint32_t friendNumber, uint32_t fileNumber, FileTransferParam *transfer = proto->transfers.Get(friendNumber, fileNumber);
if (transfer == NULL)
{
- proto->debugLogA(__FUNCTION__": failed to find transfer (%d)", fileNumber);
+ proto->logger->Log(__FUNCTION__": failed to find transfer (%d)", fileNumber);
return;
}
diff --git a/protocols/Tox/src/tox_utils.cpp b/protocols/Tox/src/tox_utils.cpp index e0a3e9f514..da18be8bdb 100644 --- a/protocols/Tox/src/tox_utils.cpp +++ b/protocols/Tox/src/tox_utils.cpp @@ -1,5 +1,27 @@ #include "stdafx.h"
+int CToxProto::MapStatus(int status)
+{
+ switch (status)
+ {
+ case ID_STATUS_FREECHAT:
+ case ID_STATUS_ONTHEPHONE:
+ status = ID_STATUS_ONLINE;
+ break;
+
+ case ID_STATUS_NA:
+ case ID_STATUS_OUTTOLUNCH:
+ status = ID_STATUS_AWAY;
+ break;
+
+ case ID_STATUS_DND:
+ case ID_STATUS_INVISIBLE:
+ status = ID_STATUS_OCCUPIED;
+ break;
+ }
+ return status;
+}
+
TOX_USER_STATUS CToxProto::MirandaToToxStatus(int status)
{
TOX_USER_STATUS userstatus = TOX_USER_STATUS_NONE;
@@ -87,9 +109,9 @@ void CToxProto::ShowNotification(const TCHAR *message, int flags, MCONTACT hCont ShowNotification(_T(MODULE), message, flags, hContact);
}
-bool CToxProto::IsFileExists(std::tstring path)
+bool CToxProto::IsFileExists(const TCHAR* path)
{
- return _taccess(path.c_str(), 0) == 0;
+ return _taccess(path, 0) == 0;
}
MEVENT CToxProto::AddEventToDb(MCONTACT hContact, WORD type, DWORD timestamp, DWORD flags, PBYTE pBlob, size_t cbBlob)
|