diff options
Diffstat (limited to 'protocols/Tox/src')
-rw-r--r-- | protocols/Tox/src/tox_contacts.cpp | 1 | ||||
-rw-r--r-- | protocols/Tox/src/tox_messages.cpp | 25 | ||||
-rw-r--r-- | protocols/Tox/src/tox_multimedia.cpp | 3 | ||||
-rw-r--r-- | protocols/Tox/src/tox_proto.cpp | 7 | ||||
-rw-r--r-- | protocols/Tox/src/tox_proto.h | 2 | ||||
-rw-r--r-- | protocols/Tox/src/tox_transfer.cpp | 84 |
6 files changed, 54 insertions, 68 deletions
diff --git a/protocols/Tox/src/tox_contacts.cpp b/protocols/Tox/src/tox_contacts.cpp index 95491995a1..2611f185a1 100644 --- a/protocols/Tox/src/tox_contacts.cpp +++ b/protocols/Tox/src/tox_contacts.cpp @@ -255,7 +255,6 @@ void CToxProto::OnFriendRequest(Tox*, const uint8_t *pubKey, const uint8_t *mess proto->delSetting(hContact, "Auth");
PROTORECVEVENT pre = { 0 };
- pre.flags = PREF_UTF;
pre.timestamp = time(NULL);
pre.lParam = (DWORD)(sizeof(DWORD) * 2 + address.GetLength() + length + 5);
diff --git a/protocols/Tox/src/tox_messages.cpp b/protocols/Tox/src/tox_messages.cpp index d6e77e1ab7..895e4e9aa1 100644 --- a/protocols/Tox/src/tox_messages.cpp +++ b/protocols/Tox/src/tox_messages.cpp @@ -18,17 +18,14 @@ void CToxProto::OnFriendMessage(Tox*, uint32_t friendNumber, TOX_MESSAGE_TYPE ty length -= 3;
mir_strncpy(rawMessage, (const char*)&message[4], length);
}
- else
- mir_strncpy(rawMessage, (const char*)message, length + 1);
+ else mir_strncpy(rawMessage, (const char*)message, length + 1);
rawMessage[length] = 0;
PROTORECVEVENT recv = { 0 };
- recv.flags = PREF_UTF;
+ recv.flags = 0;
recv.timestamp = time(NULL);
recv.szMessage = rawMessage;
- recv.lParam = type == TOX_MESSAGE_TYPE_NORMAL
- ? EVENTTYPE_MESSAGE : DB_EVENT_ACTION;
-
+ recv.lParam = type == TOX_MESSAGE_TYPE_NORMAL ? EVENTTYPE_MESSAGE : DB_EVENT_ACTION;
ProtoChainRecvMsg(hContact, &recv);
CallService(MS_PROTO_CONTACTISTYPING, hContact, (LPARAM)PROTOTYPE_CONTACTTYPING_OFF);
@@ -55,24 +52,16 @@ int CToxProto::OnReceiveMessage(MCONTACT hContact, PROTORECVEVENT *pre) /* MESSAGE SENDING */
// outcoming message flow
-int CToxProto::OnSendMessage(MCONTACT hContact, int flags, const char *szMessage)
+int CToxProto::OnSendMessage(MCONTACT hContact, const char *szMessage)
{
int32_t friendNumber = GetToxFriendNumber(hContact);
if (friendNumber == UINT32_MAX)
return 0;
- ptrA message;
- if (flags & PREF_UNICODE)
- message = mir_utf8encodeW((wchar_t*)&szMessage[mir_strlen(szMessage) + 1]);
- else //if (flags & PREF_UTF)
- message = mir_strdup(szMessage);
- //else
- //message = mir_utf8encode(szMessage);
-
- size_t msgLen = mir_strlen(message);
- uint8_t *msg = (uint8_t*)(char*)message;
+ size_t msgLen = mir_strlen(szMessage);
+ uint8_t *msg = (uint8_t*)szMessage;
TOX_MESSAGE_TYPE type = TOX_MESSAGE_TYPE_NORMAL;
- if (strncmp(message, "/me ", 4) == 0)
+ if (strncmp(szMessage, "/me ", 4) == 0)
{
msg += 4; msgLen -= 4;
type = TOX_MESSAGE_TYPE_ACTION;
diff --git a/protocols/Tox/src/tox_multimedia.cpp b/protocols/Tox/src/tox_multimedia.cpp index 0fe92349d5..0325794eb2 100644 --- a/protocols/Tox/src/tox_multimedia.cpp +++ b/protocols/Tox/src/tox_multimedia.cpp @@ -295,9 +295,10 @@ void CToxProto::OnAvInvite(void*, int32_t callId, void *arg) PROTORECVEVENT recv = { 0 };
recv.timestamp = time(NULL);
recv.lParam = callId;
- recv.flags = PREF_UTF;
recv.szMessage = mir_utf8encodeT(message);
ProtoChainRecv(hContact, PSR_AUDIO, hContact, (LPARAM)&recv);
+
+ mir_free(recv.szMessage);
}
// save event to db
diff --git a/protocols/Tox/src/tox_proto.cpp b/protocols/Tox/src/tox_proto.cpp index caa507c315..ab48ce60a2 100644 --- a/protocols/Tox/src/tox_proto.cpp +++ b/protocols/Tox/src/tox_proto.cpp @@ -49,8 +49,7 @@ DWORD_PTR CToxProto::GetCaps(int type, MCONTACT) case PFLAGNUM_3:
return PF2_ONLINE | PF2_SHORTAWAY | PF2_LIGHTDND;
case PFLAGNUM_4:
- return PF4_IMSENDUTF | PF4_SINGLEFILEONLY | PF4_SUPPORTTYPING | PF4_AVATARS
- | PF4_FORCEADDED | PF4_NOAUTHDENYREASON | PF4_FORCEAUTH;
+ return PF4_SINGLEFILEONLY | PF4_SUPPORTTYPING | PF4_AVATARS | PF4_FORCEADDED | PF4_NOAUTHDENYREASON | PF4_FORCEAUTH;
case PFLAG_UNIQUEIDTEXT:
return (INT_PTR)"Tox ID";
case PFLAG_UNIQUEIDSETTING:
@@ -136,9 +135,9 @@ int CToxProto::RecvMsg(MCONTACT hContact, PROTORECVEVENT *pre) return OnReceiveMessage(hContact, pre);
}
-int CToxProto::SendMsg(MCONTACT hContact, int flags, const char *msg)
+int CToxProto::SendMsg(MCONTACT hContact, int, const char *msg)
{
- return OnSendMessage(hContact, flags, msg);
+ return OnSendMessage(hContact, msg);
}
HANDLE CToxProto::SendFile(MCONTACT hContact, const PROTOCHAR *msg, PROTOCHAR **ppszFiles)
diff --git a/protocols/Tox/src/tox_proto.h b/protocols/Tox/src/tox_proto.h index 97b87f27eb..bdb9b82c7d 100644 --- a/protocols/Tox/src/tox_proto.h +++ b/protocols/Tox/src/tox_proto.h @@ -210,7 +210,7 @@ private: // messages
int OnReceiveMessage(MCONTACT hContact, PROTORECVEVENT *pre);
- int OnSendMessage(MCONTACT hContact, int flags, const char *message);
+ int OnSendMessage(MCONTACT hContact, const char *message);
static void OnFriendMessage(Tox *tox, uint32_t friendNumber, TOX_MESSAGE_TYPE type, const uint8_t *message, size_t length, void *arg);
static void OnReadReceipt(Tox *tox, uint32_t friendNumber, uint32_t messageId, void *arg);
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);
|