From df8f8c91e438c4862e04ef9b1589e6042c64817e Mon Sep 17 00:00:00 2001 From: George Hazan Date: Tue, 7 Mar 2023 13:02:35 +0300 Subject: =?UTF-8?q?fixes=20#3408=20(Telegram:=20=D0=B5=D1=81=D0=BB=D0=B8?= =?UTF-8?q?=20=D0=BF=D1=80=D0=B8=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D0=B8=D0=B8=20=D0=BA=D0=BE=D0=BD=D1=82=D0=B0=D0=BA?= =?UTF-8?q?=D1=82=D0=B0=20=D1=83=D0=BA=D0=B0=D0=B7=D0=B0=D0=BD=D0=BE=20?= =?UTF-8?q?=D0=BA=D0=B0=D1=81=D1=82=D0=BE=D0=BC=D0=BD=D0=BE=D0=B5=20=D0=B8?= =?UTF-8?q?=D0=BC=D1=8F,=20=D1=82=D0=BE=20=D0=B8=20=D0=B2=20=D1=80=D0=BE?= =?UTF-8?q?=D1=81=D1=82=D0=B5=D1=80=20=D0=BD=D0=B0=20=D1=81=D0=B5=D1=80?= =?UTF-8?q?=D0=B2=D0=B5=D1=80=D0=B5=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D1=8F=D1=82=D1=8C=20=D1=81=20=D1=8D=D1=82=D0=B8=D0=BC=20=D0=B8?= =?UTF-8?q?=D0=BC=D0=B5=D0=BD=D0=B5=D0=BC)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/mir_app/src/addcontact.cpp | 29 +++++++++++++++++++++++------ 1 file 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) -- cgit v1.2.3