From 14311c8786186effe490030c2e5625b6b6131e05 Mon Sep 17 00:00:00 2001 From: Ghislain MARY Date: Tue, 3 Oct 2017 17:30:37 +0200 Subject: [PATCH] Hacks::contactHasParam() can now be removed thanks to an update of belle-sip. --- src/chat/client-group-chat-room.cpp | 2 +- src/conference/session/call-session-p.h | 1 + src/conference/session/call-session.cpp | 11 +++++++++++ src/conference/session/call-session.h | 1 + src/hacks/hacks.cpp | 12 ------------ src/hacks/hacks.h | 1 - 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/chat/client-group-chat-room.cpp b/src/chat/client-group-chat-room.cpp index 32819fcbd..e5890910e 100644 --- a/src/chat/client-group-chat-room.cpp +++ b/src/chat/client-group-chat-room.cpp @@ -200,7 +200,7 @@ void ClientGroupChatRoom::onCallSessionStateChanged (const CallSession &session, Address addr(session.getRemoteContact()); addr.clean(); onConferenceCreated(addr); - if (Hacks::contactHasParam(session.getRemoteContact(), "isfocus")) + if (session.getRemoteContactAddress()->hasParam("isfocus")) eventHandler->subscribe(conferenceAddress); } } diff --git a/src/conference/session/call-session-p.h b/src/conference/session/call-session-p.h index 18f1fdf83..74c401c74 100644 --- a/src/conference/session/call-session-p.h +++ b/src/conference/session/call-session-p.h @@ -86,6 +86,7 @@ protected: CallSessionParams *params = nullptr; mutable CallSessionParams *currentParams = nullptr; CallSessionParams *remoteParams = nullptr; + mutable Address remoteContactAddress; std::string subject; LinphoneCallDir direction = LinphoneCallOutgoing; diff --git a/src/conference/session/call-session.cpp b/src/conference/session/call-session.cpp index 40347a8f5..c28da3455 100644 --- a/src/conference/session/call-session.cpp +++ b/src/conference/session/call-session.cpp @@ -1002,6 +1002,17 @@ string CallSession::getRemoteContact () const { return string(); } +const Address *CallSession::getRemoteContactAddress () const { + L_D(); + if (!d->op) { + return nullptr; + } + char *addrStr = sal_address_as_string(d->op->get_remote_contact_address()); + d->remoteContactAddress = Address(addrStr); + bctbx_free(addrStr); + return &d->remoteContactAddress; +} + const CallSessionParams * CallSession::getRemoteParams () { L_D(); if (d->op){ diff --git a/src/conference/session/call-session.h b/src/conference/session/call-session.h index 2495dab34..6116895fb 100644 --- a/src/conference/session/call-session.h +++ b/src/conference/session/call-session.h @@ -67,6 +67,7 @@ public: const Address& getRemoteAddress () const; std::string getRemoteAddressAsString () const; std::string getRemoteContact () const; + const Address *getRemoteContactAddress () const; const CallSessionParams *getRemoteParams (); LinphoneCallState getState () const; diff --git a/src/hacks/hacks.cpp b/src/hacks/hacks.cpp index b5caeadc7..80ef02920 100644 --- a/src/hacks/hacks.cpp +++ b/src/hacks/hacks.cpp @@ -30,16 +30,4 @@ LINPHONE_BEGIN_NAMESPACE // ----------------------------------------------------------------------------- -bool Hacks::contactHasParam(const string &contact, const string ¶mName) { - // This is very ugly!!! The handling of Contact headers and addresses is a real - // crap that really needs to be reworked. Meanwhile, we cannot get the params on the - // remote contact address and need to forge and parse a contact header. - ostringstream os; - os << "Contact: " << contact; - belle_sip_header_contact_t *contactHeader = belle_sip_header_contact_parse(os.str().c_str()); - bool result = belle_sip_parameters_has_parameter(BELLE_SIP_PARAMETERS(contactHeader), paramName.c_str()); - belle_sip_object_unref(contactHeader); - return result; -} - LINPHONE_END_NAMESPACE diff --git a/src/hacks/hacks.h b/src/hacks/hacks.h index bd8bd92f3..f1eccc9c7 100644 --- a/src/hacks/hacks.h +++ b/src/hacks/hacks.h @@ -31,7 +31,6 @@ LINPHONE_BEGIN_NAMESPACE // can be located more easily. class Hacks { public: - static bool contactHasParam(const std::string &contact, const std::string ¶mName); private: Hacks () = default;