diff options
author | George Hazan <ghazan@miranda.im> | 2023-03-07 13:02:35 +0300 |
---|---|---|
committer | George Hazan <ghazan@miranda.im> | 2023-03-07 13:02:35 +0300 |
commit | df8f8c91e438c4862e04ef9b1589e6042c64817e (patch) | |
tree | b982df4b5950b98f352a6cec26541ad1de372557 | |
parent | f9cdf7391b9510c73b5041e624d84dae093ffd0d (diff) |
fixes #3408 (Telegram: если при добавлении контакта указано кастомное имя, то и в ростер на сервере добавлять с этим именем)
-rw-r--r-- | src/mir_app/src/addcontact.cpp | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/src/mir_app/src/addcontact.cpp b/src/mir_app/src/addcontact.cpp index 2eda1400ca..a33e83d041 100644 --- a/src/mir_app/src/addcontact.cpp +++ b/src/mir_app/src/addcontact.cpp @@ -104,20 +104,37 @@ public: bool OnApply() override
{
+ CMStringW wszHandle(ptrW(m_myHandle.GetText()));
+
MCONTACT hContact = 0;
if (m_hDbEvent)
hContact = (MCONTACT)CallProtoServiceInt(0, m_szProto, PS_ADDTOLISTBYEVENT, 0, m_hDbEvent);
- else if (m_psr)
+ else if (m_psr) {
+ if (!wszHandle.IsEmpty()) {
+ CMStringW wszFirstName, wszLastName;
+ int idx = wszHandle.Find(' ');
+ if (idx != -1) {
+ wszFirstName = wszHandle.Left(idx);
+ wszLastName = wszHandle.Right(wszHandle.GetLength() - idx - 1);
+ }
+ else wszFirstName = wszHandle;
+
+ if (!wszFirstName.IsEmpty())
+ replaceStrW(m_psr->firstName.w, wszFirstName.Detach());
+
+ if (!wszLastName.IsEmpty())
+ replaceStrW(m_psr->lastName.w, wszLastName.Detach());
+ }
+
hContact = (MCONTACT)CallProtoServiceInt(0, m_szProto, PS_ADDTOLIST, 0, (LPARAM)m_psr);
- else
- hContact = m_hContact;
+ }
+ else hContact = m_hContact;
if (hContact == 0) // something went wrong
return false;
- ptrW szHandle(m_myHandle.GetText());
- if (mir_wstrlen(szHandle))
- db_set_ws(hContact, "CList", "MyHandle", szHandle);
+ if (mir_wstrlen(wszHandle))
+ db_set_ws(hContact, "CList", "MyHandle", wszHandle);
MGROUP iGroup = m_group.GetCurData();
if (iGroup >= 0)
|