diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2015-05-30 20:55:00 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2015-05-30 20:55:00 +0000 |
commit | 1a3d8165a7ea32cb104cbcc0509101f809e6e6a0 (patch) | |
tree | c319c9b998c04cce0e440898eb065319456599b3 | |
parent | ec0d546b1b38bc4b4383647ee3f9a2f603dfd46e (diff) |
Tox: contacts search/add improvements
git-svn-id: http://svn.miranda-ng.org/main/trunk@13914 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | protocols/Tox/src/tox_contacts.cpp | 22 | ||||
-rw-r--r-- | protocols/Tox/src/tox_proto.cpp | 3 | ||||
-rw-r--r-- | protocols/Tox/src/tox_proto.h | 2 | ||||
-rw-r--r-- | protocols/Tox/src/tox_search.cpp | 2 |
4 files changed, 13 insertions, 16 deletions
diff --git a/protocols/Tox/src/tox_contacts.cpp b/protocols/Tox/src/tox_contacts.cpp index 3ec9c3b1d5..8441573384 100644 --- a/protocols/Tox/src/tox_contacts.cpp +++ b/protocols/Tox/src/tox_contacts.cpp @@ -63,7 +63,7 @@ MCONTACT CToxProto::GetContact(const char *pubKey) return hContact;
}
-MCONTACT CToxProto::AddContact(const char *address, const TCHAR *dnsId, bool isTemporary)
+MCONTACT CToxProto::AddContact(const char *address, const TCHAR *nick, const TCHAR *dnsId, bool isTemporary)
{
MCONTACT hContact = GetContact(address);
if (!hContact)
@@ -73,7 +73,10 @@ MCONTACT CToxProto::AddContact(const char *address, const TCHAR *dnsId, bool isT setString(hContact, TOX_SETTINGS_ID, address);
- if (dnsId && mir_tstrlen(dnsId))
+ if (mir_tstrlen(nick))
+ setTString(hContact, "Nick", dnsId);
+
+ if (mir_tstrlen(dnsId))
setTString(hContact, TOX_SETTINGS_DNS, dnsId);
DBVARIANT dbv;
@@ -121,7 +124,7 @@ void CToxProto::LoadFriendList(void*) continue;
}
ToxHexAddress pubKey(data, TOX_PUBLIC_KEY_SIZE);
- MCONTACT hContact = AddContact(pubKey, _T(""));
+ MCONTACT hContact = AddContact(pubKey);
if (hContact)
{
delSetting(hContact, "Auth");
@@ -130,7 +133,7 @@ void CToxProto::LoadFriendList(void*) TOX_ERR_FRIEND_QUERY getNameResult;
uint8_t nick[TOX_MAX_NAME_LENGTH] = { 0 };
if (tox_friend_get_name(tox, friendNumber, nick, &getNameResult))
- setWString(hContact, "Nick", ptrT(mir_utf8decodeW((char*)nick)));
+ setTString(hContact, "Nick", ptrT(mir_utf8decodeT((char*)nick)));
else
debugLogA(__FUNCTION__": failed to get friend name (%d)", getNameResult);
@@ -163,15 +166,13 @@ INT_PTR CToxProto::OnRequestAuth(WPARAM hContact, LPARAM lParam) return addFriendResult;
}
- // trim address to public key
- setString(hContact, TOX_SETTINGS_ID, address.ToHex().GetPubKey());
db_unset(hContact, "CList", "NotOnList");
delSetting(hContact, "Grant");
uint8_t nick[TOX_MAX_NAME_LENGTH] = { 0 };
TOX_ERR_FRIEND_QUERY errorFriendQuery;
if (tox_friend_get_name(tox, friendNumber, nick, &errorFriendQuery))
- setWString(hContact, "Nick", ptrT(mir_utf8decodeW((char*)nick)));
+ setTString(hContact, "Nick", ptrT(mir_utf8decodeT((char*)nick)));
else
debugLogA(__FUNCTION__": failed to get friend name (%d)", errorFriendQuery);
@@ -192,8 +193,6 @@ INT_PTR CToxProto::OnGrantAuth(WPARAM hContact, LPARAM) return error;
}
- // trim address to public key
- // setString(hContact, TOX_SETTINGS_ID, pubKey.ToHex());
db_unset(hContact, "CList", "NotOnList");
delSetting(hContact, "Grant");
@@ -205,10 +204,7 @@ INT_PTR CToxProto::OnGrantAuth(WPARAM hContact, LPARAM) int CToxProto::OnContactDeleted(MCONTACT hContact, LPARAM)
{
if (!IsOnline())
- {
- // TODO: warn
return 0;
- }
if (!isChatRoom(hContact))
{
@@ -239,7 +235,7 @@ void CToxProto::OnFriendRequest(Tox*, const uint8_t *pubKey, const uint8_t *mess CToxProto *proto = (CToxProto*)arg;
ToxHexAddress address(pubKey);
- MCONTACT hContact = proto->AddContact(address, _T(""));
+ MCONTACT hContact = proto->AddContact(address);
if (!hContact)
{
proto->debugLogA(__FUNCTION__": failed to create contact");
diff --git a/protocols/Tox/src/tox_proto.cpp b/protocols/Tox/src/tox_proto.cpp index 0e7d157c45..c9762e2360 100644 --- a/protocols/Tox/src/tox_proto.cpp +++ b/protocols/Tox/src/tox_proto.cpp @@ -75,8 +75,9 @@ MCONTACT CToxProto::AddToList(int flags, PROTOSEARCHRESULT *psr) ShowNotification(TranslateT("Contact already in your contact list"), 0, hContact);
return NULL;
}
+ ptrT nick(mir_tstrdup(psr->nick));
ptrT dnsId(mir_tstrdup(psr->email));
- return AddContact(address, dnsId, flags & PALF_TEMPORARY);
+ return AddContact(address, nick, dnsId, flags & PALF_TEMPORARY);
}
int CToxProto::Authorize(MEVENT hDbEvent)
diff --git a/protocols/Tox/src/tox_proto.h b/protocols/Tox/src/tox_proto.h index c815815fd7..1d9d0ed5f7 100644 --- a/protocols/Tox/src/tox_proto.h +++ b/protocols/Tox/src/tox_proto.h @@ -154,7 +154,7 @@ private: MCONTACT GetContact(const int friendNumber);
MCONTACT GetContact(const char *pubKey);
- MCONTACT AddContact(const char *address, const TCHAR *dnsId = NULL, bool isTemporary = false);
+ MCONTACT AddContact(const char *address, const TCHAR *nick = NULL, const TCHAR *dnsId = NULL, bool isTemporary = false);
MCONTACT GetContactFromAuthEvent(MEVENT hEvent);
diff --git a/protocols/Tox/src/tox_search.cpp b/protocols/Tox/src/tox_search.cpp index 7b57f54eb0..10f2fc68f5 100644 --- a/protocols/Tox/src/tox_search.cpp +++ b/protocols/Tox/src/tox_search.cpp @@ -129,7 +129,7 @@ void CToxProto::SearchByNameAsync(void *arg) {
PROTOSEARCHRESULT psr = { sizeof(PROTOSEARCHRESULT) };
psr.flags = PSR_TCHAR;
- psr.id = mir_a2t(address);
+ psr.id = mir_utf8decodeT(address);
psr.nick = mir_utf8decodeT(name);
TCHAR email[MAX_PATH];
|