⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dialogusagemanager.cxx

📁 这是国外的resip协议栈
💻 CXX
📖 第 1 页 / 共 5 页
字号:
voidDialogUsageManager::addExternalMessageHandler(ExternalMessageHandler* handler){   std::vector<ExternalMessageHandler*>::iterator found = std::find(mExternalMessageHandlers.begin(), mExternalMessageHandlers.end(), handler);   if (found == mExternalMessageHandlers.end())   {      mExternalMessageHandlers.push_back(handler);   }}void DialogUsageManager::removeExternalMessageHandler(ExternalMessageHandler* handler){   std::vector<ExternalMessageHandler*>::iterator found = std::find(mExternalMessageHandlers.begin(), mExternalMessageHandlers.end(), handler);   if (found != mExternalMessageHandlers.end())   {      mExternalMessageHandlers.erase(found);   }}void DialogUsageManager::clearExternalMessageHandler(){   std::vector<ExternalMessageHandler*> empty;   empty.swap(mExternalMessageHandlers);}DialogSet*DialogUsageManager::makeUacDialogSet(BaseCreator* creator, AppDialogSet* appDs){   if (mDumShutdownHandler)   {      throw DumException("Cannot create new sessions when DUM is shutting down.", __FILE__, __LINE__);   }   if (appDs == 0)   {      appDs = new AppDialogSet(*this);   }   DialogSet* ds = new DialogSet(creator, *this);   appDs->mDialogSet = ds;   ds->mAppDialogSet = appDs;   StackLog ( << "************* Adding DialogSet ***************" );   StackLog ( << "Before: " << Inserter(mDialogSetMap) );   mDialogSetMap[ds->getId()] = ds;   StackLog ( << "After: " << Inserter(mDialogSetMap) );   return ds;}SharedPtr<SipMessage>DialogUsageManager::makeNewSession(BaseCreator* creator, AppDialogSet* appDs){   makeUacDialogSet(creator, appDs);   return creator->getLastRequest();}voidDialogUsageManager::makeResponse(SipMessage& response,                                 const SipMessage& request,                                 int responseCode,                                 const Data& reason) const{   assert(request.isRequest());   Helper::makeResponse(response, request, responseCode, reason);}voidDialogUsageManager::sendResponse(const SipMessage& response){   assert(response.isResponse());   mStack.send(response, this);}SharedPtr<SipMessage>DialogUsageManager::makeInviteSession(const NameAddr& target, const SharedPtr<UserProfile>& userProfile, const SdpContents* initialOffer, AppDialogSet* appDs){   return makeInviteSession(target, userProfile, initialOffer, None, 0, appDs);}SharedPtr<SipMessage>DialogUsageManager::makeInviteSession(const NameAddr& target, const SdpContents* initialOffer, AppDialogSet* appDs){   return makeInviteSession(target, getMasterUserProfile(), initialOffer, None, 0, appDs);}SharedPtr<SipMessage>DialogUsageManager::makeInviteSession(const NameAddr& target,                                       const SharedPtr<UserProfile>& userProfile,                                       const SdpContents* initialOffer,                                       EncryptionLevel level,                                       const SdpContents* alternative,                                       AppDialogSet* appDs){   SharedPtr<SipMessage> inv = makeNewSession(new InviteSessionCreator(*this, target, userProfile, initialOffer, level, alternative), appDs);   DumHelper::setOutgoingEncryptionLevel(*inv, level);   return inv;}SharedPtr<SipMessage>DialogUsageManager::makeInviteSession(const NameAddr& target,                                       const SdpContents* initialOffer,                                       EncryptionLevel level,                                       const SdpContents* alternative,                                      AppDialogSet* appDs){   return makeInviteSession(target, getMasterUserProfile(), initialOffer, level, alternative, appDs);}SharedPtr<SipMessage>DialogUsageManager::makeInviteSessionFromRefer(const SipMessage& refer,                                               ServerSubscriptionHandle serverSub,                                               const SdpContents* initialOffer,                                               AppDialogSet* appDs){   return makeInviteSessionFromRefer(refer, serverSub, initialOffer, None, 0, appDs);}SharedPtr<SipMessage>DialogUsageManager::makeInviteSessionFromRefer(const SipMessage& refer,                                               const SharedPtr<UserProfile>& userProfile,                                                const SdpContents* initialOffer,                                               AppDialogSet* appDs){   ServerSubscriptionHandle empty;   return makeInviteSessionFromRefer(refer, userProfile, empty, initialOffer, None, 0, appDs);}SharedPtr<SipMessage>DialogUsageManager::makeInviteSessionFromRefer(const SipMessage& refer,                                               ServerSubscriptionHandle serverSub,                                               const SdpContents* initialOffer,                                               EncryptionLevel level,                                               const SdpContents* alternative,                                               AppDialogSet* appDs){   return makeInviteSessionFromRefer(refer, serverSub.isValid() ? serverSub->mDialog.mDialogSet.getUserProfile() : getMasterUserProfile(), serverSub, initialOffer, level, alternative, appDs);}SharedPtr<SipMessage>DialogUsageManager::makeInviteSessionFromRefer(const SipMessage& refer,                                               const SharedPtr<UserProfile>& userProfile,                                                ServerSubscriptionHandle serverSub,                                               const SdpContents* initialOffer,                                               EncryptionLevel level,                                               const SdpContents* alternative,                                               AppDialogSet* appDs){   if (serverSub.isValid())   {      DebugLog(<< "implicit subscription");      //generate and send 100      SipFrag contents;      contents.message().header(h_StatusLine).statusCode() = 100;      contents.message().header(h_StatusLine).reason() = "Trying";      //will be cloned...ServerSub may not have the most efficient API possible      serverSub->setSubscriptionState(Active);      SharedPtr<SipMessage> notify = serverSub->update(&contents);//   mInviteSessionHandler->onReadyToSend(InviteSessionHandle::NotValid(), notify);      serverSub->send(notify);   }   //19.1.5   NameAddr target = refer.header(h_ReferTo);   target.uri().removeEmbedded();   target.uri().remove(p_method);   // !jf! this code assumes you have a UserProfile   SharedPtr<SipMessage> inv = makeNewSession(new InviteSessionCreator(*this,                                                                       target,                                                                       userProfile,                                                                       initialOffer, level, alternative, serverSub), appDs);   DumHelper::setOutgoingEncryptionLevel(*inv, level);   //could pass dummy target, then apply merge rules from 19.1.5...or   //makeNewSession would use rules from 19.1.5   if (refer.exists(h_ReferredBy))   {      inv->header(h_ReferredBy) = refer.header(h_ReferredBy);   }   const Uri& referTo = refer.header(h_ReferTo).uri();   //19.1.5   if (referTo.hasEmbedded() && referTo.embedded().exists(h_Replaces))   {      inv->header(h_Replaces) = referTo.embedded().header(h_Replaces);   }   return inv;}SharedPtr<SipMessage>DialogUsageManager::makeRefer(const NameAddr& target, const SharedPtr<UserProfile>& userProfile, const H_ReferTo::Type& referTo, AppDialogSet* appDs){   return makeNewSession(new SubscriptionCreator(*this, target, userProfile, referTo), appDs);}SharedPtr<SipMessage>DialogUsageManager::makeRefer(const NameAddr& target, const H_ReferTo::Type& referTo, AppDialogSet* appDs){   return makeNewSession(new SubscriptionCreator(*this, target, getMasterUserProfile(), referTo), appDs);}SharedPtr<SipMessage>DialogUsageManager::makeSubscription(const NameAddr& target, const SharedPtr<UserProfile>& userProfile, const Data& eventType, AppDialogSet* appDs){   assert(userProfile.get());   return makeNewSession(new SubscriptionCreator(*this, target, userProfile, eventType, userProfile->getDefaultSubscriptionTime()), appDs);}SharedPtr<SipMessage>DialogUsageManager::makeSubscription(const NameAddr& target, const SharedPtr<UserProfile>& userProfile, const Data& eventType,                                     UInt32 subscriptionTime, AppDialogSet* appDs){   return makeNewSession(new SubscriptionCreator(*this, target, userProfile, eventType, subscriptionTime), appDs);}SharedPtr<SipMessage>DialogUsageManager::makeSubscription(const NameAddr& target, const SharedPtr<UserProfile>& userProfile, const Data& eventType,                                     UInt32 subscriptionTime, int refreshInterval, AppDialogSet* appDs){   return makeNewSession(new SubscriptionCreator(*this, target, userProfile, eventType, subscriptionTime, refreshInterval), appDs);}SharedPtr<SipMessage>DialogUsageManager::makeSubscription(const NameAddr& target, const Data& eventType, AppDialogSet* appDs){   return makeNewSession(new SubscriptionCreator(*this, target, getMasterUserProfile(), eventType, getMasterProfile()->getDefaultSubscriptionTime()), appDs);}SharedPtr<SipMessage>DialogUsageManager::makeSubscription(const NameAddr& target, const Data& eventType,                                     UInt32 subscriptionTime, AppDialogSet* appDs){   return makeNewSession(new SubscriptionCreator(*this, target, getMasterUserProfile(), eventType, subscriptionTime), appDs);}SharedPtr<SipMessage>DialogUsageManager::makeSubscription(const NameAddr& target, const Data& eventType,                                     UInt32 subscriptionTime, int refreshInterval, AppDialogSet* appDs){   return makeNewSession(new SubscriptionCreator(*this, target, getMasterUserProfile(), eventType, subscriptionTime, refreshInterval), appDs);}SharedPtr<SipMessage>DialogUsageManager::makeRegistration(const NameAddr& target, const SharedPtr<UserProfile>& userProfile, AppDialogSet* appDs){   assert(userProfile.get());   return makeNewSession(new RegistrationCreator(*this, target, userProfile, userProfile->getDefaultRegistrationTime()), appDs);}SharedPtr<SipMessage>DialogUsageManager::makeRegistration(const NameAddr& target, const SharedPtr<UserProfile>& userProfile, UInt32 registrationTime, AppDialogSet* appDs){   return makeNewSession(new RegistrationCreator(*this, target, userProfile, registrationTime), appDs);}SharedPtr<SipMessage>DialogUsageManager::makeRegistration(const NameAddr& target, AppDialogSet* appDs){   return makeNewSession(new RegistrationCreator(*this, target, getMasterUserProfile(), getMasterProfile()->getDefaultRegistrationTime()), appDs);}SharedPtr<SipMessage>DialogUsageManager::makeRegistration(const NameAddr& target, UInt32 registrationTime, AppDialogSet* appDs){   return makeNewSession(new RegistrationCreator(*this, target, getMasterUserProfile(), registrationTime), appDs);}SharedPtr<SipMessage>DialogUsageManager::makePublication(const NameAddr& targetDocument,                                    const SharedPtr<UserProfile>& userProfile,                                    const Contents& body,                                    const Data& eventType,                                    UInt32 expiresSeconds,                                    AppDialogSet* appDs){   return makeNewSession(new PublicationCreator(*this, targetDocument, userProfile, body, eventType, expiresSeconds), appDs);}SharedPtr<SipMessage>DialogUsageManager::makePublication(const NameAddr& targetDocument,                                    const Contents& body,                                    const Data& eventType,                                    UInt32 expiresSeconds,                                    AppDialogSet* appDs){   return makeNewSession(new PublicationCreator(*this, targetDocument, getMasterUserProfile(), body, eventType, expiresSeconds), appDs);}SharedPtr<SipMessage>DialogUsageManager::makeOutOfDialogRequest(const NameAddr& target, const SharedPtr<UserProfile>& userProfile, const MethodTypes meth, AppDialogSet* appDs){   return makeNewSession(new OutOfDialogReqCreator(*this, meth, target, userProfile), appDs);}SharedPtr<SipMessage>DialogUsageManager::makeOutOfDialogRequest(const NameAddr& target, const MethodTypes meth, AppDialogSet* appDs){   return makeNewSession(new OutOfDialogReqCreator(*this, meth, target, getMasterUserProfile()), appDs);}ClientPagerMessageHandleDialogUsageManager::makePagerMessage(const NameAddr& target, const SharedPtr<UserProfile>& userProfile, AppDialogSet* appDs){   if (!mClientPagerMessageHandler)   {      throw DumException("Cannot send MESSAGE messages without a ClientPagerMessageHandler", __FILE__, __LINE__);   }   DialogSet* ds = makeUacDialogSet(new PagerMessageCreator(*this, target, userProfile), appDs);   ClientPagerMessage* cpm = new ClientPagerMessage(*this, *ds);   ds->mClientPagerMessage = cpm;   return cpm->getHandle();}ClientPagerMessageHandleDialogUsageManager::makePagerMessage(const NameAddr& target, AppDialogSet* appDs){   return makePagerMessage(target, getMasterUserProfile(), appDs);}voidDialogUsageManager::send(SharedPtr<SipMessage> msg){   // !slg! There is probably a more efficient way to get the userProfile here (pass it in?)   DialogSet* ds = findDialogSet(DialogSetId(*msg));   UserProfile* userProfile;   if (ds == 0)   {      userProfile = getMasterUserProfile().get();   }   else   {      userProfile = ds->getUserProfile().get();   }   assert(userProfile);   if (!userProfile->isAnonymous() && userProfile->hasUserAgent())   {      msg->header(h_UserAgent).value() = userProfile->getUserAgent();   }   if (userProfile->isAnonymous())   {      msg->remove(h_ReplyTo);      msg->remove(h_UserAgent);      msg->remove(h_Organization);      msg->remove(h_Server);      msg->remove(h_Subject);      msg->remove(h_InReplyTo);      msg->remove(h_CallInfos);      msg->remove(h_Warnings);   }      assert(userProfile);   if (msg->isRequest()        && userProfile->hasProxyRequires()        && msg->header(h_RequestLine).method() != ACK        && msg->header(h_RequestLine).method() != CANCEL)   {      msg->header(h_ProxyRequires) = userProfile->getProxyRequires();   }      if (msg->isRequest())   {      // We may not need to call reset() if makeRequest is always used.      if (msg->header(h_RequestLine).method() != CANCEL &&          msg->header(h_RequestLine).method() != ACK &&          msg->exists(h_Vias))      {         msg->header(h_Vias).front().param(p_branch).reset();      }      if (msg->exists(h_Vias))      {         if(!userProfile->getRportEnabled())         {            msg->header(h_Vias).front().remove(p_rport);         }         int fixedTransportPort = userProfile->getFixedTransportPort();         if(fixedTransportPort != 0)         {            msg->header(h_Vias).front().sentPort() = fixedTransportPort;         }         const Data& fixedTransportInterface = userProfile->getFixedTransportInterface();         if(!fixedTransportInterface.empty())         {            msg->header(h_Vias).front().sentHost() = fixedTransportInterface;         }      }      if (mClientAuthManager.get() && msg->header(h_RequestLine).method() != ACK)      {         mClientAuthManager->addAuthentication(*msg);      }      // Add outbound decorator from userprofile      SharedPtr<MessageDecorator> outboundDecorator = userProfile->getOutboundDecorator();      if (outboundDecorator.get())      {         msg->addOutboundDecorator(outboundDecorator.get());      }   }   DebugLog (<< "SEND: " << std::endl << std::endl << *msg);   OutgoingEvent* event = new OutgoingEvent(msg);   outgoingProcess(auto_ptr<Message>(event));}void DialogUsageManager::outgoingProcess(auto_ptr<Message> message){   Data tid = Data::Empty;   {      OutgoingEvent* sipMsg = dynamic_cast<OutgoingEvent*>(message.get());      if (sipMsg)      {         tid = sipMsg->getTransactionId();      }            DumFeatureMessage* featureMsg = dynamic_cast<DumFeatureMessage*>(message.get());      if (featureMsg)      {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -