diff options
author | Robert Pösel <robyer@seznam.cz> | 2016-08-28 12:00:29 +0000 |
---|---|---|
committer | Robert Pösel <robyer@seznam.cz> | 2016-08-28 12:00:29 +0000 |
commit | c98539ee79a0d7e6ee2c20172a3387d6e38674d7 (patch) | |
tree | bfca89ed4bc57bdae1ba613c10565ae4d89e220e /protocols | |
parent | 2dce488713913a350803cd188919984b5d9b4f90 (diff) |
SkypeWeb: Show better names for chat contacts
Based on idea of olegtarasov - https://github.com/miranda-ng/miranda-ng/pull/8
It primarily uses custom nicks (changed via chatroom), then it tries to get custom name of the contact in our contact list, or his nick (if custom name is not present), or as last option his id.
Also custom name is used on more places (when adding new contact, or kicking contact - and also the "initiator" of the kick).
git-svn-id: http://svn.miranda-ng.org/main/trunk@17211 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols')
-rw-r--r-- | protocols/SkypeWeb/src/skype_chatrooms.cpp | 48 | ||||
-rw-r--r-- | protocols/SkypeWeb/src/skype_proto.h | 1 |
2 files changed, 42 insertions, 7 deletions
diff --git a/protocols/SkypeWeb/src/skype_chatrooms.cpp b/protocols/SkypeWeb/src/skype_chatrooms.cpp index 35e40e9045..2e67171846 100644 --- a/protocols/SkypeWeb/src/skype_chatrooms.cpp +++ b/protocols/SkypeWeb/src/skype_chatrooms.cpp @@ -442,9 +442,11 @@ void CSkypeProto::AddMessageToChat(const wchar_t *chat_id, const wchar_t *from, {
GCDEST gcd = { m_szModuleName, chat_id, isAction ? GC_EVENT_ACTION : GC_EVENT_MESSAGE };
GCEVENT gce = { sizeof(GCEVENT), &gcd };
+
+ ptrW tnick(GetChatContactNick(_T2A(chat_id), _T2A(from), _T2A(from)));
gce.bIsMe = IsMe(_T2A(from));
- gce.ptszNick = from;
+ gce.ptszNick = tnick;
gce.time = timestamp;
gce.ptszUID = from;
@@ -536,15 +538,47 @@ char *CSkypeProto::GetChatUsers(const wchar_t *chat_id) return gci.pszUsers;
}
+wchar_t* CSkypeProto::GetChatContactNick(const char *chat_id, const char *id, const char *name) {
+ // Check if there is custom nick for this chat contact
+ if (chat_id != NULL) {
+ if (wchar_t *tname = db_get_wsa(FindChatRoom(chat_id), "UsersNicks", id))
+ return tname;
+ }
+
+ // Check if we have this contact in database
+ if (IsMe(id))
+ {
+ // Return my nick
+ if (wchar_t *tname = getWStringA(NULL, "Nick"))
+ return tname;
+ }
+ else
+ {
+ MCONTACT hContact = FindContact(id);
+ if (hContact != NULL) {
+ // Primarily return custom name
+ if (wchar_t *tname = db_get_wsa(hContact, "CList", "MyHandle"))
+ return tname;
+
+ // If not exists, then user nick
+ if (wchar_t *tname = getWStringA(hContact, "Nick"))
+ return tname;
+ }
+ }
+
+ // Return default value as nick - given name or user id
+ if (name != NULL)
+ return mir_a2u_cp(name, CP_UTF8);
+ else
+ return mir_a2u(id);
+}
+
void CSkypeProto::AddChatContact(const wchar_t *tchat_id, const char *id, const char *name, const wchar_t *role, bool isChange)
{
if (IsChatContact(tchat_id, id))
return;
- ptrW tnick(mir_a2u_cp(name, CP_UTF8));
- if (wchar_t *tmp = db_get_wsa(FindChatRoom(_T2A(tchat_id)), "UsersNicks", id))
- tnick = tmp;
-
+ ptrW tnick(GetChatContactNick(_T2A(tchat_id), id, name));
ptrW tid(mir_a2u(id));
GCDEST gcd = { m_szModuleName, tchat_id, GC_EVENT_JOIN };
@@ -565,9 +599,9 @@ void CSkypeProto::RemoveChatContact(const wchar_t *tchat_id, const char *id, con if (IsMe(id))
return;
- ptrW tnick(mir_a2u_cp(name, CP_UTF8));
+ ptrW tnick(GetChatContactNick(_T2A(tchat_id), id, name));
+ ptrW tinitiator(GetChatContactNick(_T2A(tchat_id), initiator, initiator));
ptrW tid(mir_a2u(id));
- ptrW tinitiator(mir_a2u(initiator));
GCDEST gcd = { m_szModuleName, tchat_id, isKick ? GC_EVENT_KICK : GC_EVENT_PART };
GCEVENT gce = { sizeof(gce), &gcd };
diff --git a/protocols/SkypeWeb/src/skype_proto.h b/protocols/SkypeWeb/src/skype_proto.h index 964bbc1ac5..d9414dea98 100644 --- a/protocols/SkypeWeb/src/skype_proto.h +++ b/protocols/SkypeWeb/src/skype_proto.h @@ -350,6 +350,7 @@ private: void AddMessageToChat(const wchar_t *chat_id, const wchar_t *from, const char *content, bool isAction, int emoteOffset, time_t timestamp, bool isLoading = false);
void AddChatContact(const wchar_t *tchat_id, const char *id, const char *name, const wchar_t *role, bool isChange = false);
void RemoveChatContact(const wchar_t *tchat_id, const char *id, const char *name, bool isKick = false, const char *initiator = "");
+ wchar_t *GetChatContactNick(const char *chat_id, const char *id, const char *name);
void RenameChat(const char *chat_id, const char *name);
void ChangeChatTopic(const char * chat_id, const char *topic, const char *initiator);
|