diff --git a/apps/telepathy/Connection.cxx b/apps/telepathy/Connection.cxx old mode 100644 new mode 100755 index 43b57f4d3f..bb672a5fa7 --- a/apps/telepathy/Connection.cxx +++ b/apps/telepathy/Connection.cxx @@ -5,7 +5,7 @@ * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the @@ -264,7 +264,7 @@ tr::Connection::requestHandles(uint handleType, const QStringList &identifiers, } Q_FOREACH(const QString &identifier, identifiers) { - ensureHandle(identifier); + ensureHandle(identifier); result.append(mIdentifiers[identifier]); } @@ -312,13 +312,13 @@ tr::Connection::createChannel(const QVariantMap &request, Tp::DBusError *error) baseChannel->setTargetID(targetID); baseChannel->setInitiatorHandle(initiatorHandle); */ - ParticipantHandle participantHandle = -1; + ParticipantHandle participantHandle = -1 ; + recon::ConversationHandle cHandle = 1; // FIXME - hardcoded default value, should create new Conversation bool incoming = false; StackLog(<<"createChannel - channelType = " << channelType.toUtf8().constData() << " and contact = " << targetID.toUtf8().constData()); if(channelType == TP_QT_IFACE_CHANNEL_TYPE_CALL) { - recon::ConversationHandle cHandle = 1; // FIXME - hardcoded default value, should create new Conversation - //recon::ConversationHandle cHandle = myConversationManager->createConversation(); - //myConversationManager->createLocalParticipant(); + cHandle = myConversationManager->createConversation(); + myConversationManager->createLocalParticipant(); if(!request.contains("participantHandle")) { // Outgoing call @@ -338,7 +338,7 @@ tr::Connection::createChannel(const QVariantMap &request, Tp::DBusError *error) //return baseChannel; - SipCallChannel *channel = new SipCallChannel(incoming, this, targetID, targetHandle, participantHandle); + SipCallChannel *channel = new SipCallChannel(incoming, this, targetID, targetHandle, cHandle, participantHandle); channel->baseChannel()->setInitiatorHandle(initiatorHandle); return channel->baseChannel(); } @@ -364,5 +364,3 @@ tr::Connection::getContactAttributes(const Tp::UIntList &handles, const QStringL } return attributesMap; } - - diff --git a/apps/telepathy/MyConversationManager.cxx b/apps/telepathy/MyConversationManager.cxx old mode 100644 new mode 100755 index 4a3224b4c6..eaa6ebf942 --- a/apps/telepathy/MyConversationManager.cxx +++ b/apps/telepathy/MyConversationManager.cxx @@ -28,6 +28,7 @@ // Test Prompts for cache testing #include "playback_prompt.h" #include "record_prompt.h" +#include "../../resip/recon/ConversationManager.hxx" #define RESIPROCATE_SUBSYSTEM ReconSubsystem::RECON @@ -40,15 +41,17 @@ MyConversationManager::MyConversationManager(bool localAudioEnabled, MediaInterf mLocalAudioEnabled(localAudioEnabled), mAutoAnswerEnabled(autoAnswerEnabled), mConnection(connection) -{ +{ + QObject::connect(this,SIGNAL(participantDestroyed(recon::ParticipantHandle)),this,SLOT(onParticipantDestroyed(recon::ParticipantHandle))); + QObject::connect(this,SIGNAL(conversationDestroyed(recon::ConversationHandle)),this,SLOT(onConversationDestroyed(recon::ConversationHandle))); } void MyConversationManager::startup() -{ +{ if(mLocalAudioEnabled) { - // Create initial local participant and conversation + // Create initial local participant and conversation ParticipantHandle ph = createLocalParticipant(); DebugLog(<<"createLocalParticipant returned handle " << ph); addParticipant(createConversation(), ph); @@ -74,7 +77,7 @@ MyConversationManager::startup() resip::Data buffer(Data::Share, (const char *)record_prompt, sizeof(record_prompt)); resip::Data name("record"); addBufferToMediaResourceCache(name, buffer, 0); - } + } } ConversationHandle @@ -108,7 +111,16 @@ MyConversationManager::createLocalParticipant() mLocalParticipantHandles.push_back(partHandle); return partHandle; } - +void +MyConversationManager::destroyParticipant(ParticipantHandle partHandle) { + ConversationManager::destroyParticipant(partHandle); + emit participantDestroyed(partHandle); +} +void +MyConversationManager::destroyConversation(ConversationHandle convHandle) { + ConversationManager::destroyConversation(convHandle); + emit conversationDestroyed(convHandle); +} void MyConversationManager::onConversationDestroyed(ConversationHandle convHandle) { @@ -171,13 +183,19 @@ MyConversationManager::onRequestOutgoingParticipant(ParticipantHandle partHandle addParticipant(convHandle, partHandle); }*/ } - + void MyConversationManager::onParticipantTerminated(ParticipantHandle partHandle, unsigned int statusCode) { InfoLog(<< "onParticipantTerminated: handle=" << partHandle); + destroyParticipant(partHandle); + if(mRemoteParticipantHandles.size()==0){ + destroyConversation(mConversationHandles.front()); + conversationDestroyed(mConversationHandles.front()); + } + } - + void MyConversationManager::onParticipantProceeding(ParticipantHandle partHandle, const SipMessage& msg) { @@ -185,7 +203,7 @@ MyConversationManager::onParticipantProceeding(ParticipantHandle partHandle, con } void -MyConversationManager::onRelatedConversation(ConversationHandle relatedConvHandle, ParticipantHandle relatedPartHandle, +MyConversationManager::onRelatedConversation(ConversationHandle relatedConvHandle, ParticipantHandle relatedPartHandle, ConversationHandle origConvHandle, ParticipantHandle origPartHandle) { InfoLog(<< "onRelatedConversation: relatedConvHandle=" << relatedConvHandle << " relatedPartHandle=" << relatedPartHandle @@ -199,7 +217,7 @@ MyConversationManager::onParticipantAlerting(ParticipantHandle partHandle, const { InfoLog(<< "onParticipantAlerting: handle=" << partHandle << " msg=" << msg.brief()); } - + void MyConversationManager::onParticipantConnected(ParticipantHandle partHandle, const SipMessage& msg) { @@ -266,4 +284,3 @@ MyConversationManager::displayInfo() InfoLog(<< output); } } - diff --git a/apps/telepathy/MyConversationManager.hxx b/apps/telepathy/MyConversationManager.hxx old mode 100644 new mode 100755 index 4481e57692..bb3524649b --- a/apps/telepathy/MyConversationManager.hxx +++ b/apps/telepathy/MyConversationManager.hxx @@ -46,11 +46,13 @@ public: virtual ~MyConversationManager() {}; virtual void startup(); - + virtual recon::ConversationHandle createConversation(); virtual recon::ParticipantHandle createRemoteParticipant(recon::ConversationHandle convHandle, resip::NameAddr& destination, recon::ConversationManager::ParticipantForkSelectMode forkSelectMode = recon::ConversationManager::ForkSelectAutomatic); virtual recon::ParticipantHandle createMediaResourceParticipant(recon::ConversationHandle convHandle, const resip::Uri& mediaUrl); virtual recon::ParticipantHandle createLocalParticipant(); + virtual void destroyParticipant(recon::ParticipantHandle partHandle); + virtual void destroyConversation(recon::ConversationHandle convHandle); virtual void onConversationDestroyed(recon::ConversationHandle convHandle); virtual void onParticipantDestroyed(recon::ParticipantHandle partHandle); virtual void onDtmfEvent(recon::ParticipantHandle partHandle, int dtmf, int duration, bool up); @@ -58,7 +60,7 @@ public: virtual void onRequestOutgoingParticipant(recon::ParticipantHandle partHandle, const resip::SipMessage& msg, recon::ConversationProfile& conversationProfile); virtual void onParticipantTerminated(recon::ParticipantHandle partHandle, unsigned int statusCode); virtual void onParticipantProceeding(recon::ParticipantHandle partHandle, const resip::SipMessage& msg); - virtual void onRelatedConversation(recon::ConversationHandle relatedConvHandle, recon::ParticipantHandle relatedPartHandle, + virtual void onRelatedConversation(recon::ConversationHandle relatedConvHandle, recon::ParticipantHandle relatedPartHandle, recon::ConversationHandle origConvHandle, recon::ParticipantHandle origPartHandle); virtual void onParticipantAlerting(recon::ParticipantHandle partHandle, const resip::SipMessage& msg); virtual void onParticipantConnected(recon::ParticipantHandle partHandle, const resip::SipMessage& msg); @@ -66,6 +68,10 @@ public: virtual void onParticipantRedirectFailure(recon::ParticipantHandle partHandle, unsigned int statusCode); virtual void displayInfo(); +Q_SIGNALS: +void conversationDestroyed(recon::ConversationHandle convHandle); +void participantDestroyed(recon::ParticipantHandle partHandle); + protected: std::list mConversationHandles; std::list mLocalParticipantHandles; @@ -79,4 +85,3 @@ protected: } #endif - diff --git a/apps/telepathy/SipCallChannel.cxx b/apps/telepathy/SipCallChannel.cxx old mode 100644 new mode 100755 index d3fdc7e029..a34ec0e1ef --- a/apps/telepathy/SipCallChannel.cxx +++ b/apps/telepathy/SipCallChannel.cxx @@ -34,11 +34,12 @@ using namespace tr; using namespace resip; using namespace recon; -SipCallChannel::SipCallChannel(bool incoming, Connection* connection, QString peer, uint targetHandle, ParticipantHandle participantHandle) +SipCallChannel::SipCallChannel(bool incoming, Connection* connection, QString peer, uint targetHandle, ConversationHandle conversationHandle, ParticipantHandle participantHandle) : mIncoming(incoming), mConnection(connection), mPeer(peer), mTargetHandle(targetHandle), + mConversationHandle(conversationHandle), mParticipantHandle(participantHandle) { mBaseChannel = Tp::BaseChannel::create(mConnection, TP_QT_IFACE_CHANNEL_TYPE_CALL, Tp::HandleTypeContact, targetHandle); @@ -102,13 +103,20 @@ SipCallChannel::baseChannel() { return mBaseChannel; } - +bool +SipCallChannel::getIncoming(){ + return mIncoming; +} void SipCallChannel::onHangupComplete(bool status) { if (!status) { InfoLog(<<"onHangupComplete, status = false"); } + else { + InfoLog(<<"onHangupComplete, status = true"); + mConnection->getConversationManager().destroyConversation(mConversationHandle); + } } void @@ -116,13 +124,29 @@ SipCallChannel::onAnswerComplete(bool status) { if (!status) { InfoLog(<<"onAnswerComplete, status = false"); - } + } } void SipCallChannel::onHangup(uint reason, const QString &detailedReason, const QString &message, Tp::DBusError* error) -{ - mConnection->getConversationManager().destroyParticipant(mParticipantHandle); +{ + bool incoming = SipCallChannel::getIncoming(); + QVariantMap stateDetails; + Tp::CallStateReason csreason; + csreason.actor = 0; + csreason.reason = Tp::CallStateChangeReasonUserRequested; + csreason.message=""; + if (incoming) + { + csreason.DBusReason = "org.freedesktop.Telepathy.Error.Rejected"; + mCallChannel->setCallState(Tp::CallStateEnded, 0, csreason, stateDetails); + } + else{ + csreason.DBusReason = "org.freedesktop.Telepathy.Error.Cancelled"; + mCallChannel->setCallState(Tp::CallStateEnded, 0, csreason, stateDetails); + } + mConnection->getConversationManager().destroyParticipant(mParticipantHandle); + emit hangupComplete(true); } void diff --git a/apps/telepathy/SipCallChannel.hxx b/apps/telepathy/SipCallChannel.hxx old mode 100644 new mode 100755 index 4852e8def6..b653192a07 --- a/apps/telepathy/SipCallChannel.hxx +++ b/apps/telepathy/SipCallChannel.hxx @@ -39,9 +39,9 @@ class SipCallChannel : public QObject { Q_OBJECT public: - SipCallChannel(bool incoming, Connection* connection, QString peer, uint targetHandle, recon::ParticipantHandle participantHandle); + SipCallChannel(bool incoming, Connection* connection, QString peer, uint targetHandle, recon::ConversationHandle conversationHandle, recon::ParticipantHandle participantHandle); Tp::BaseChannelPtr baseChannel(); - + bool getIncoming(); void onHangup(uint reason, const QString &detailedReason, const QString &message, Tp::DBusError* error); void onAccept(Tp::DBusError*); void onMuteStateChanged(const Tp::LocalMuteState &state, Tp::DBusError *error); @@ -53,12 +53,16 @@ private Q_SLOTS: void onAnswerComplete(bool success); void onHangupComplete(bool success); +Q_SIGNALS: + void hangupComplete(bool status); + void answerComplete(bool status); private: bool mIncoming; Connection* mConnection; QString mPeer; uint mTargetHandle; + recon::ConversationHandle mConversationHandle; recon::ParticipantHandle mParticipantHandle; QString mObjPath; Tp::BaseChannelPtr mBaseChannel; @@ -72,5 +76,3 @@ private: } #endif - -