diff options
Diffstat (limited to 'protocols/Tox/src')
-rw-r--r-- | protocols/Tox/src/tox_account.cpp | 3 | ||||
-rw-r--r-- | protocols/Tox/src/tox_contacts.cpp | 8 | ||||
-rw-r--r-- | protocols/Tox/src/tox_events.cpp | 52 | ||||
-rw-r--r-- | protocols/Tox/src/tox_proto.cpp | 23 | ||||
-rw-r--r-- | protocols/Tox/src/tox_proto.h | 2 |
5 files changed, 44 insertions, 44 deletions
diff --git a/protocols/Tox/src/tox_account.cpp b/protocols/Tox/src/tox_account.cpp index 40ded847e6..7363f69c7c 100644 --- a/protocols/Tox/src/tox_account.cpp +++ b/protocols/Tox/src/tox_account.cpp @@ -27,7 +27,8 @@ void CToxProto::InitToxCore() tox = tox_new(&options);
tox_callback_friend_request(tox, OnFriendRequest, this);
tox_callback_friend_message(tox, OnFriendMessage, this);
- tox_callback_friend_action(tox, OnAction, this);
+ tox_callback_typing_change(tox, OnFriendTyping, this);
+ //tox_callback_friend_action(tox, OnAction, this);
tox_callback_name_change(tox, OnFriendNameChange, this);
tox_callback_status_message(tox, OnStatusMessageChanged, this);
tox_callback_user_status(tox, OnUserStatusChanged, this);
diff --git a/protocols/Tox/src/tox_contacts.cpp b/protocols/Tox/src/tox_contacts.cpp index ea08d4338d..4bb4c583a2 100644 --- a/protocols/Tox/src/tox_contacts.cpp +++ b/protocols/Tox/src/tox_contacts.cpp @@ -118,9 +118,13 @@ void CToxProto::LoadContactList() tox_get_name(tox, friends[i], &username[0]);
std::string nick(username.begin(), username.end());
setWString(hContact, "Nick", ptrW(Utf8DecodeW(nick.c_str())));
- }
- //tox_get_last_online
+ uint64_t timestamp = tox_get_last_online(tox, friends[i]);
+ if (timestamp)
+ {
+ setDword(hContact, "LastEventDateTS", timestamp);
+ }
+ }
}
}
}
diff --git a/protocols/Tox/src/tox_events.cpp b/protocols/Tox/src/tox_events.cpp index eeedc29ac2..3857267c88 100644 --- a/protocols/Tox/src/tox_events.cpp +++ b/protocols/Tox/src/tox_events.cpp @@ -3,7 +3,6 @@ int CToxProto::OnAccountLoaded(WPARAM, LPARAM)
{
HookEventObj(ME_OPT_INITIALISE, OnOptionsInit, this);
- //HookEventObj(ME_USERINFO_INITIALISE, OnUserInfoInit, this);
HookEventObj(ME_PROTO_ACCLISTCHANGED, OnAccountListChanged, this);
InitNetlib();
@@ -71,42 +70,6 @@ int CToxProto::OnOptionsInit(void *obj, WPARAM wParam, LPARAM) return 0;
}
-int CToxProto::OnUserInfoInit(void *obj, WPARAM wParam, LPARAM hContact)
-{
- return 0;
-
- CToxProto *proto = (CToxProto*)obj;
-
- if ((!proto->IsProtoContact(hContact) && hContact))
- return 0;
-
- OPTIONSDIALOGPAGE odp = { sizeof(odp) };
- odp.flags = ODPF_TCHAR | ODPF_USERINFOTAB | ODPF_DONTTRANSLATE;
- odp.hInstance = g_hInstance;
- odp.dwInitParam = (LPARAM)obj;
- odp.position = -1900000000;
- odp.ptszTitle = proto->m_tszUserName;
-
- if (hContact)
- {
- char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, hContact, 0);
- if (szProto != NULL && !strcmp(szProto, proto->m_szModuleName)) {
- //odp.pfnDlgProc = SkypeDlgProc;
- //odp.pszTemplate = MAKEINTRESOURCEA(IDD_INFO_SKYPE);
- UserInfo_AddPage(wParam, &odp);
- }
- }
- else
- {
- //odp.pfnDlgProc = ContactSkypeDlgProc;
- //odp.pszTemplate = MAKEINTRESOURCEA(IDD_OWNINFO_CONTACT);
- odp.ptszTab = LPGENT("Contacts");
- UserInfo_AddPage(wParam, &odp);
- }
-
- return 0;
-}
-
int CToxProto::OnContactDeleted(MCONTACT hContact, LPARAM lParam)
{
if (hContact)
@@ -183,6 +146,21 @@ void CToxProto::OnFriendMessage(Tox *tox, const int friendnumber, const uint8_t }
}
+void CToxProto::OnFriendTyping(Tox *tox, const int friendnumber, uint8_t isTyping, void *arg)
+{
+ CToxProto *proto = (CToxProto*)arg;
+
+ std::vector<uint8_t> clientId(TOX_CLIENT_ID_SIZE);
+ tox_get_client_id(tox, friendnumber, &clientId[0]);
+ std::string toxId = proto->DataToHexString(clientId);
+
+ MCONTACT hContact = proto->FindContact(toxId.c_str());
+ if (hContact)
+ {
+ CallService(MS_PROTO_CONTACTISTYPING, hContact, (LPARAM)isTyping);
+ }
+}
+
void CToxProto::OnFriendNameChange(Tox *tox, const int friendnumber, const uint8_t *name, const uint16_t nameSize, void *arg)
{
CToxProto *proto = (CToxProto*)arg;
diff --git a/protocols/Tox/src/tox_proto.cpp b/protocols/Tox/src/tox_proto.cpp index 0bcba5d09b..7682f80216 100644 --- a/protocols/Tox/src/tox_proto.cpp +++ b/protocols/Tox/src/tox_proto.cpp @@ -1,7 +1,7 @@ #include "common.h"
CToxProto::CToxProto(const char* protoName, const TCHAR* userName) :
- PROTO<CToxProto>(protoName, userName)
+PROTO<CToxProto>(protoName, userName)
{
InitToxCore();
@@ -44,7 +44,7 @@ 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_NOAUTHDENYREASON | PF4_FORCEAUTH | PF4_FORCEADDED;
+ return PF4_IMSENDUTF | PF4_NOAUTHDENYREASON | PF4_FORCEAUTH | PF4_FORCEADDED | PF4_SUPPORTTYPING;
case PFLAG_UNIQUEIDTEXT:
return (INT_PTR)"Tox ID";
case PFLAG_UNIQUEIDSETTING:
@@ -229,7 +229,24 @@ HANDLE __cdecl CToxProto::GetAwayMsg(MCONTACT hContact) { return 0; } int __cdecl CToxProto::RecvAwayMsg(MCONTACT hContact, int mode, PROTORECVEVENT* evt) { return 0; }
int __cdecl CToxProto::SetAwayMsg(int iStatus, const PROTOCHAR* msg) { return 0; }
-int __cdecl CToxProto::UserIsTyping(MCONTACT hContact, int type) { return 0; }
+int __cdecl CToxProto::UserIsTyping(MCONTACT hContact, int type)
+{
+ if (hContact && IsOnline())
+ {
+ std::string toxId(getStringA(hContact, TOX_SETTINGS_ID));
+ std::vector<uint8_t> clientId = HexStringToData(toxId);
+
+ uint32_t number = tox_get_friend_number(tox, clientId.data());
+
+ if (number >= 0)
+ {
+ tox_set_user_is_typing(tox, number, type);
+ return 0;
+ }
+ }
+
+ return 1;
+}
int __cdecl CToxProto::OnEvent(PROTOEVENTTYPE iEventType, WPARAM wParam, LPARAM lParam)
{
diff --git a/protocols/Tox/src/tox_proto.h b/protocols/Tox/src/tox_proto.h index abce39d012..c2f982c4a3 100644 --- a/protocols/Tox/src/tox_proto.h +++ b/protocols/Tox/src/tox_proto.h @@ -105,10 +105,10 @@ private: INT_PTR __cdecl OnAccountManagerInit(WPARAM, LPARAM);
static int __cdecl OnAccountListChanged(void *obj, WPARAM wParam, LPARAM lParam);
static int __cdecl OnOptionsInit(void *obj, WPARAM wParam, LPARAM lParam);
- static int __cdecl OnUserInfoInit(void *obj, WPARAM wParam, LPARAM lParam);
static void OnFriendRequest(Tox *tox, const uint8_t *userId, const uint8_t *message, const uint16_t messageSize, void *arg);
static void OnFriendMessage(Tox *tox, const int friendnumber, const uint8_t *message, const uint16_t messageSize, void *arg);
+ static void OnFriendTyping(Tox *tox, const int friendnumber, uint8_t isTyping, void *arg);
static void OnFriendNameChange(Tox *tox, const int friendnumber, const uint8_t *name, const uint16_t nameSize, void *arg);
static void OnStatusMessageChanged(Tox *tox, const int friendnumber, const uint8_t* message, const uint16_t messageSize, void *arg);
static void OnUserStatusChanged(Tox *tox, int32_t friendnumber, uint8_t usertatus, void *arg);
|