From 63afce56f08e031e45a6a33f56af0f312c8bfc91 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Sat, 16 Aug 2014 17:26:20 +0000 Subject: Tox: added tox icon git-svn-id: http://svn.miranda-ng.org/main/trunk@10204 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Tox/src/tox_contacts.cpp | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'protocols/Tox/src/tox_contacts.cpp') diff --git a/protocols/Tox/src/tox_contacts.cpp b/protocols/Tox/src/tox_contacts.cpp index 4bad40f78e..fe02760f78 100644 --- a/protocols/Tox/src/tox_contacts.cpp +++ b/protocols/Tox/src/tox_contacts.cpp @@ -1,8 +1,18 @@ #include "common.h" +WORD CToxProto::GetContactStatus(MCONTACT hContact) +{ + return getWord(hContact, "Status", ID_STATUS_OFFLINE); +} + +bool CToxProto::IsContactOnline(MCONTACT hContact) +{ + return GetContactStatus(hContact) == ID_STATUS_ONLINE; +} + void CToxProto::SetContactStatus(MCONTACT hContact, WORD status) { - WORD oldStatus = getWord(hContact, "Status", ID_STATUS_OFFLINE); + WORD oldStatus = GetContactStatus(hContact); if (oldStatus != status) { setWord(hContact, "Status", status); @@ -13,7 +23,7 @@ void CToxProto::SetAllContactsStatus(WORD status) { for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) { - setWord(hContact, "Status", status); + SetContactStatus(hContact, status); } } @@ -112,4 +122,25 @@ void CToxProto::LoadContactList() //tox_get_last_online } } +} + +void CToxProto::SearchByIdAsync(void* arg) +{ + std::string clientId = mir_utf8encodeT((TCHAR*)arg); + clientId.erase(clientId.begin() + TOX_CLIENT_ID_SIZE * 2, clientId.end()); + + MCONTACT hContact = FindContact(clientId.c_str()); + if (hContact) + { + ShowNotification(TranslateT("Contact already in your contact list"), 0, hContact); + ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)1, 0); + return; + } + + PROTOSEARCHRESULT psr = { sizeof(PROTOSEARCHRESULT) }; + psr.flags = PSR_TCHAR; + psr.id = (TCHAR*)arg; + + ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_DATA, (HANDLE)1, (LPARAM)&psr); + ProtoBroadcastAck(NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, (HANDLE)1, 0); } \ No newline at end of file -- cgit v1.2.3