From 69dd602796a84509f922cb621416e92a340842b1 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Thu, 2 Mar 2023 14:50:13 +0300 Subject: =?UTF-8?q?fixes=20#3363=20(Jabber:=20=D0=B4=D0=BE=D0=B1=D0=B0?= =?UTF-8?q?=D0=B2=D0=B8=D1=82=D1=8C=20=D1=81=D0=BE=D0=BE=D0=B1=D1=89=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D0=BE=20=D1=82=D0=BE=D0=BC,=20=D1=87?= =?UTF-8?q?=D1=82=D0=BE=20=D0=BA=D0=BB=D0=B8=D0=B5=D0=BD=D1=82=20=D1=81?= =?UTF-8?q?=D0=BE=D0=B1=D0=B5=D1=81=D0=B5=D0=B4=D0=BD=D0=B8=D0=BA=D0=B0=20?= =?UTF-8?q?=D0=BD=D0=B5=20=D0=BF=D0=BE=D0=B4=D0=B4=D0=B5=D1=80=D0=B6=D0=B8?= =?UTF-8?q?=D0=B2=D0=B0=D0=B5=D1=82=20=D0=B7=D0=B2=D0=BE=D0=BD=D0=BA=D0=B8?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- protocols/JabberG/src/jabber_api.cpp | 1 + protocols/JabberG/src/jabber_list.cpp | 10 ++++++++++ protocols/JabberG/src/jabber_proto.h | 1 + protocols/JabberG/src/jabber_voip.cpp | 15 +++++++++++---- 4 files changed, 23 insertions(+), 4 deletions(-) (limited to 'protocols/JabberG') diff --git a/protocols/JabberG/src/jabber_api.cpp b/protocols/JabberG/src/jabber_api.cpp index 775102599e..70c94ead16 100644 --- a/protocols/JabberG/src/jabber_api.cpp +++ b/protocols/JabberG/src/jabber_api.cpp @@ -64,6 +64,7 @@ char* CJabberProto::GetBestResourceName(const char *jid) { if (jid == nullptr) return nullptr; + const char *p = strchr(jid, '/'); if (p == nullptr) { mir_cslock lck(m_csLists); diff --git a/protocols/JabberG/src/jabber_list.cpp b/protocols/JabberG/src/jabber_list.cpp index da6cfb955d..12c56fc6cb 100644 --- a/protocols/JabberG/src/jabber_list.cpp +++ b/protocols/JabberG/src/jabber_list.cpp @@ -371,6 +371,16 @@ JABBER_RESOURCE_STATUS* JABBER_LIST_ITEM::getTemp() return m_pItemResource; } +pResourceStatus CJabberProto::ListGetBestResource(const char *jid) +{ + mir_cslock lck(m_csLists); + JABBER_LIST_ITEM *LI = ListGetItemPtr(LIST_ROSTER, jid); + if (LI == nullptr) + return nullptr; + + return pResourceStatus(LI->getBestResource()); +} + char* CJabberProto::ListGetBestClientResourceNamePtr(const char *jid) { mir_cslock lck(m_csLists); diff --git a/protocols/JabberG/src/jabber_proto.h b/protocols/JabberG/src/jabber_proto.h index f10a4866ba..50415aef70 100644 --- a/protocols/JabberG/src/jabber_proto.h +++ b/protocols/JabberG/src/jabber_proto.h @@ -649,6 +649,7 @@ struct CJabberProto : public PROTO, public IJabberInterface int ListFindNext(JABBER_LIST list, int fromOffset); pResourceStatus ListFindResource(JABBER_LIST list, const char *jid); + pResourceStatus ListGetBestResource(const char *jid); bool ListAddResource(JABBER_LIST list, const char *jid, int status, const char *statusMessage, int priority = 0, const char *nick = nullptr); void ListRemoveResource(JABBER_LIST list, const char *jid); diff --git a/protocols/JabberG/src/jabber_voip.cpp b/protocols/JabberG/src/jabber_voip.cpp index 27147af5f0..85d8ad3f12 100644 --- a/protocols/JabberG/src/jabber_voip.cpp +++ b/protocols/JabberG/src/jabber_voip.cpp @@ -484,12 +484,19 @@ bool CJabberProto::VOIPCallIinitiate(MCONTACT hContact) if (!hasJingle()) return false; - CMStringA jid(ptrA(getUStringA(hContact, "jid"))); + CMStringA jid(getMStringA(hContact, "jid")); if (jid.IsEmpty()) return false; - ptrA szResource(GetBestResourceName(jid)); - if (szResource) - jid = MakeJid(jid, szResource); + + auto r = ListGetBestResource(jid); + if (r) { + if (!(r->m_pCaps->GetCaps() & JABBER_CAPS_JINGLE)) { + MsgPopup(hContact, TranslateT("Client's program does not support voice calls"), TranslateT("Error")); + return false; + } + + jid = MakeJid(jid, r->m_szResourceName); + } unsigned char tmp[16]; Utils_GetRandom(tmp, sizeof(tmp)); -- cgit v1.2.3