diff --git a/sflphone-common/src/dbus/callmanager.cpp b/sflphone-common/src/dbus/callmanager.cpp index ce9c544c6644cef0799f28c7ad79b9c84e5513c9..a5498d0e6488c756ceecf97a173fa93aaf7bda8b 100644 --- a/sflphone-common/src/dbus/callmanager.cpp +++ b/sflphone-common/src/dbus/callmanager.cpp @@ -464,5 +464,6 @@ CallManager::setPBXEnrollment (const std::string& callID, const bool& yesNo) void CallManager::sendTextMessage (const std::string& callID, const std::string& message) { - Manager::instance().sendTextMessage (callID, message); + if (!Manager::instance().sendTextMessage (callID, message)) + throw CallManagerException(); } diff --git a/sflphone-common/src/managerimpl.cpp b/sflphone-common/src/managerimpl.cpp index b78acd54e8938d581b9502d47521756ad47596a9..ccdfa03f8afdb004de41d531bbec9753dc703084 100644 --- a/sflphone-common/src/managerimpl.cpp +++ b/sflphone-common/src/managerimpl.cpp @@ -1712,6 +1712,34 @@ void ManagerImpl::incomingMessage (const CallID& callID, const std::string& from, const std::string& message) { + SIPVoIPLink *link = NULL; + + if (participToConference (callID)) { + _debug ("Manager: Particip to a conference, send message to everyone"); + + Conference *conf = getConferenceFromCallID (callID); + + ParticipantSet participants = conf->getParticipantList(); + ParticipantSet::iterator iter_participant = participants.begin(); + + while (iter_participant != participants.end()) { + + AccountID accountId = getAccountFromCall (*iter_participant); + + _debug ("Manager: Send message to %s, (%s)", (*iter_participant).c_str(), accountId.c_str()); + + if (*iter_participant != callID) { + + link = SIPVoIPLink::instance (""); // dynamic_cast<SIPVoIPLink *> (getAccountLink (*iter_participant)); + + if (link) + link->sendTextMessage (*iter_participant, message); + } + + iter_participant++; + } + } + if (_dbus) { _dbus->getCallManager()->incomingMessage (callID, from, message); } @@ -1719,23 +1747,48 @@ void ManagerImpl::incomingMessage (const CallID& callID, //THREAD=VoIP -void ManagerImpl::sendTextMessage (const CallID& callID, const std::string& message) +bool ManagerImpl::sendTextMessage (const CallID& callID, const std::string& message) { + SIPVoIPLink * link = NULL; - if (participToConference (callID)) + if (participToConference (callID)) { _debug ("Manager: Particip to a conference, send message on everyone"); - AccountID accountId = getAccountFromCall (callID); + Conference *conf = getConferenceFromCallID (callID); - SIPVoIPLink * link = NULL; - link = dynamic_cast<SIPVoIPLink *> (getAccountLink (accountId)); + ParticipantSet participants = conf->getParticipantList(); + ParticipantSet::iterator iter_participant = participants.begin(); + + while (iter_participant != participants.end()) { + + AccountID accountId = getAccountFromCall (*iter_participant); - if (link == NULL) { - _debug ("Manager: Failed to get sip link"); - throw CallManagerException(); + _debug ("Manager: Send message to %s (%s)", (*iter_participant).c_str(), accountId.c_str()); + link = SIPVoIPLink::instance (""); // dynamic_cast<SIPVoIPLink *> (getAccountLink (*iter_participant)); + + + if (link) + link->sendTextMessage (*iter_participant, message); + + iter_participant++; + } + + } else { + + AccountID accountId = getAccountFromCall (callID); + + link = dynamic_cast<SIPVoIPLink *> (getAccountLink (accountId)); + + if (link == NULL) { + _debug ("Manager: Failed to get sip link"); + return false; + } + + _debug ("Manager: Send message to %s (%s)", callID.c_str(), accountId.c_str()); + link->sendTextMessage (callID, message); } - link->sendTextMessage (callID, message); + return true; } //THREAD=VoIP CALL=Outgoing diff --git a/sflphone-common/src/managerimpl.h b/sflphone-common/src/managerimpl.h index 1ee15be86772c7c36110dbc225e8c2a301a74d31..db6c91ccf705d10148ed118d493cbbd8ac1c5286 100644 --- a/sflphone-common/src/managerimpl.h +++ b/sflphone-common/src/managerimpl.h @@ -452,7 +452,7 @@ class ManagerImpl * @param callID The call to send the message * @param message The content of the message */ - void sendTextMessage (const CallID& callID, const std::string& message); + bool sendTextMessage (const CallID& callID, const std::string& message); /** * Notify the client he has voice mails diff --git a/sflphone-common/src/sip/sipvoiplink.cpp b/sflphone-common/src/sip/sipvoiplink.cpp index 2c520811a7bd7a0df4abab1218bc8006c50768d7..a9cb6ff1e4163c85bfbafa8174eab26e31b9f8e3 100644 --- a/sflphone-common/src/sip/sipvoiplink.cpp +++ b/sflphone-common/src/sip/sipvoiplink.cpp @@ -1064,6 +1064,7 @@ SIPVoIPLink::onhold (const CallID& id) bool SIPVoIPLink::sendTextMessage (const std::string& callID, const std::string& message) { + _debug ("SipVoipLink: Send text message to %s", callID.c_str()); SIPCall *call = getSIPCall (callID); pj_status_t status = !PJ_SUCCESS;