diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2014-08-07 13:49:07 +0000 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2014-08-07 13:49:07 +0000 |
commit | 84f85ceac0f993be95dda89584749ea59fe5b8e7 (patch) | |
tree | 2231a79773b63436a9586f6cf1f35f1893c80793 /protocols/Tox/src/tox_contacts.cpp | |
parent | c56192dd999c079ebd935a6736315de3a5d60a05 (diff) |
Tox added from branch
git-svn-id: http://svn.miranda-ng.org/main/trunk@10115 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Tox/src/tox_contacts.cpp')
-rw-r--r-- | protocols/Tox/src/tox_contacts.cpp | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/protocols/Tox/src/tox_contacts.cpp b/protocols/Tox/src/tox_contacts.cpp new file mode 100644 index 0000000000..263e922595 --- /dev/null +++ b/protocols/Tox/src/tox_contacts.cpp @@ -0,0 +1,70 @@ +#include "common.h"
+
+bool CToxProto::IsProtoContact(MCONTACT hContact)
+{
+ return ::lstrcmpiA(::GetContactProto(hContact), m_szModuleName) == 0;
+}
+
+MCONTACT CToxProto::GetContactByUserId(const wchar_t *userId)
+{
+ MCONTACT hContact = NULL;
+
+ //EnterCriticalSection(&contact_search_lock);
+
+ for (hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName))
+ {
+ ptrW cUserId(::db_get_wsa(hContact, m_szModuleName, "UserID"));
+ if (lstrcmpi(cUserId, userId) == 0)
+ break;
+ }
+
+ //LeaveCriticalSection(&contact_search_lock);
+
+ return hContact;
+}
+
+MCONTACT CToxProto::AddContact(const wchar_t *userId, const wchar_t *nick, bool isHidden)
+{
+ MCONTACT hContact = GetContactByUserId(userId);
+ if ( !hContact)
+ {
+ hContact = (MCONTACT)::CallService(MS_DB_CONTACT_ADD, 0, 0);
+ ::CallService(MS_PROTO_ADDTOCONTACT, hContact, (LPARAM)m_szModuleName);
+
+ db_set_b(hContact, "CList", "NotOnList", 1);
+
+ if (isHidden)
+ db_set_b(hContact, "CList", "Hidden", 1);
+
+ setWString(hContact, "UserId", userId);
+ setWString(hContact, "Nick", nick);
+ }
+
+ return hContact;
+}
+
+void __cdecl CToxProto::SearchByUidAsync(void* arg)
+{
+ ptrW userId((wchar_t*)arg);
+
+ //MCONTACT hContact = GetContactByUserId(userId);
+ //if (hContact)
+ //{
+ // ShowNotification(TranslateT("Contact already in your contact list"), 0, hContact);
+ // ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)TOX_SEARCH_BYUID, 0);
+ // return;
+ //}
+
+ //// there will be placed code
+ //// that will search for contact by userId
+ // ...
+ // ...
+ //// and call
+ PROTOSEARCHRESULT psr = {0};
+ psr.cbSize = sizeof(psr);
+ //// get user id [and nick]
+ //psr.id = userId;
+ //psr.nick = nick;
+
+ ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)TOX_SEARCH_BYUID, (LPARAM)&psr);
+}
\ No newline at end of file |