From 1eec1e5f5b57fb56fbfeb56fc57777153c14df82 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Tue, 23 Sep 2014 20:28:25 +0000 Subject: Tox: avatars support part one git-svn-id: http://svn.miranda-ng.org/main/trunk@10568 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Tox/Tox_12.vcxproj | 1 + protocols/Tox/Tox_12.vcxproj.filters | 3 +++ protocols/Tox/src/common.h | 2 ++ protocols/Tox/src/tox_account.cpp | 4 ++++ protocols/Tox/src/tox_proto.cpp | 9 ++++++++- protocols/Tox/src/tox_proto.h | 11 +++++++++++ 6 files changed, 29 insertions(+), 1 deletion(-) (limited to 'protocols') diff --git a/protocols/Tox/Tox_12.vcxproj b/protocols/Tox/Tox_12.vcxproj index 455a12b2db..bcc2ddd6e5 100644 --- a/protocols/Tox/Tox_12.vcxproj +++ b/protocols/Tox/Tox_12.vcxproj @@ -211,6 +211,7 @@ + diff --git a/protocols/Tox/Tox_12.vcxproj.filters b/protocols/Tox/Tox_12.vcxproj.filters index 5ae989f241..06f6e9dc92 100644 --- a/protocols/Tox/Tox_12.vcxproj.filters +++ b/protocols/Tox/Tox_12.vcxproj.filters @@ -74,6 +74,9 @@ Source Files + + Source Files + diff --git a/protocols/Tox/src/common.h b/protocols/Tox/src/common.h index 240b8817d7..fb36ce1557 100644 --- a/protocols/Tox/src/common.h +++ b/protocols/Tox/src/common.h @@ -29,6 +29,7 @@ #include #include #include +#include #include #include @@ -45,6 +46,7 @@ extern HINSTANCE g_hInstance; #define TOX_SETTINGS_ID "ToxID" #define TOX_SETTINGS_GROUP "DefaultGroup" +#define TOX_SETTINGS_AVATAR_HASH "AvatarHash" #define TOX_DB_EVENT_TYPE_ACTION 10001 diff --git a/protocols/Tox/src/tox_account.cpp b/protocols/Tox/src/tox_account.cpp index c975276811..8af024e9f8 100644 --- a/protocols/Tox/src/tox_account.cpp +++ b/protocols/Tox/src/tox_account.cpp @@ -51,9 +51,13 @@ void CToxProto::InitToxCore() tox_callback_user_status(tox, OnUserStatusChanged, this); tox_callback_read_receipt(tox, OnReadReceipt, this); tox_callback_connection_status(tox, OnConnectionStatusChanged, this); + // file transfers tox_callback_file_control(tox, OnFileRequest, this); tox_callback_file_send_request(tox, OnFriendFile, this); tox_callback_file_data(tox, OnFileData, this); + // avatars + tox_callback_avatar_info(tox, OnGotFriendAvatarInfo, this); + tox_callback_avatar_data(tox, OnGotFriendAvatarData, this); LoadToxData(); diff --git a/protocols/Tox/src/tox_proto.cpp b/protocols/Tox/src/tox_proto.cpp index 7106d88af6..19d830d97b 100644 --- a/protocols/Tox/src/tox_proto.cpp +++ b/protocols/Tox/src/tox_proto.cpp @@ -39,6 +39,12 @@ PROTO(protoName, userName) dbEventType.eventType = TOX_DB_EVENT_TYPE_ACTION; dbEventType.descr = "Tox action"; CallService(MS_DB_EVENT_REGISTERTYPE, 0, (LPARAM)&dbEventType); + + // avatars + /*CreateProtoService(PS_GETAVATARCAPS, &CToxProto::GetAvatarCaps); + CreateProtoService(PS_GETAVATARINFOT, &CToxProto::GetAvatarInfo); + CreateProtoService(PS_GETMYAVATART, &CToxProto::GetMyAvatar); + CreateProtoService(PS_SETMYAVATART, &CToxProto::SetMyAvatar);*/ } CToxProto::~CToxProto() @@ -57,7 +63,8 @@ DWORD_PTR __cdecl CToxProto::GetCaps(int type, MCONTACT hContact) case PFLAGNUM_2: return PF2_ONLINE | PF2_SHORTAWAY | PF2_LIGHTDND; case PFLAGNUM_4: - return PF4_IMSENDUTF | PF4_SINGLEFILEONLY | PF4_NOAUTHDENYREASON | PF4_FORCEAUTH | PF4_FORCEADDED | PF4_SUPPORTTYPING; + return PF4_IMSENDUTF | PF4_SINGLEFILEONLY | PF4_NOAUTHDENYREASON |PF4_FORCEAUTH + | PF4_FORCEADDED | PF4_SUPPORTTYPING | PF4_AVATARS; case PFLAG_UNIQUEIDTEXT: return (INT_PTR)"Tox ID"; case PFLAG_UNIQUEIDSETTING: diff --git a/protocols/Tox/src/tox_proto.h b/protocols/Tox/src/tox_proto.h index 7051e5c381..b0cda8f390 100644 --- a/protocols/Tox/src/tox_proto.h +++ b/protocols/Tox/src/tox_proto.h @@ -197,6 +197,17 @@ private: static void OnFriendFile(Tox *tox, int32_t number, uint8_t fileNumber, uint64_t fileSize, const uint8_t *fileName, uint16_t length, void *arg); static void OnFileData(Tox *tox, int32_t number, uint8_t fileNumber, const uint8_t *data, uint16_t length, void *arg); + // avatars + TCHAR* GetContactAvatarFilePath(MCONTACT hContact); + + INT_PTR __cdecl GetAvatarCaps(WPARAM wParam, LPARAM lParam); + INT_PTR __cdecl GetAvatarInfo(WPARAM, LPARAM lParam); + INT_PTR __cdecl GetMyAvatar(WPARAM wParam, LPARAM lParam); + INT_PTR __cdecl SetMyAvatar(WPARAM wParam, LPARAM lParam); + + static void OnGotFriendAvatarInfo(Tox *tox, int32_t number, uint8_t format, uint8_t *hash, void *arg); + static void OnGotFriendAvatarData(Tox *tox, int32_t number, uint8_t format, uint8_t *hash, uint8_t *data, uint32_t length, void *arg); + // utils TOX_USERSTATUS MirandaToToxStatus(int status); int ToxToMirandaStatus(TOX_USERSTATUS userstatus); -- cgit v1.2.3