/[resiprocate]/main/resip/dum/InviteSession.cxx
ViewVC logotype

Diff of /main/resip/dum/InviteSession.cxx

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 7544 by sgodin, Tue Jan 29 18:24:22 2008 UTC revision 7565 by sgodin, Mon Feb 18 20:51:11 2008 UTC
# Line 66  Line 66 
66       mSessionRefresher(false),       mSessionRefresher(false),
67       mSessionTimerSeq(0),       mSessionTimerSeq(0),
68       mSessionRefreshReInvite(false),       mSessionRefreshReInvite(false),
      mSentRefer(false),  
69       mReferSub(true),       mReferSub(true),
70       mCurrentEncryptionLevel(DialogUsageManager::None),       mCurrentEncryptionLevel(DialogUsageManager::None),
71       mProposedEncryptionLevel(DialogUsageManager::None),       mProposedEncryptionLevel(DialogUsageManager::None),
# Line 80  Line 79 
79  {  {
80     DebugLog ( << "^^^ InviteSession::~InviteSession " << this);     DebugLog ( << "^^^ InviteSession::~InviteSession " << this);
81     mDialog.mInviteSession = 0;     mDialog.mInviteSession = 0;
82       while(!mNITQueue.empty())
83       {
84          delete mNITQueue.front();
85          mNITQueue.pop();
86       }
87  }  }
88    
89  void  void
# Line 732  Line 736 
736  void  void
737  InviteSession::refer(const NameAddr& referTo, std::auto_ptr<resip::Contents> contents,bool referSub)  InviteSession::refer(const NameAddr& referTo, std::auto_ptr<resip::Contents> contents,bool referSub)
738  {  {
    if (mSentRefer)  
    {  
       throw UsageUseException("Attempted to send overlapping refer", __FILE__, __LINE__);  
    }  
   
739     if (isConnected()) // ?slg? likely not safe in any state except Connected - what should behaviour be if state is ReceivedReinvite?     if (isConnected()) // ?slg? likely not safe in any state except Connected - what should behaviour be if state is ReceivedReinvite?
740     {     {
       mSentRefer = true;  
       mReferSub = referSub;  
741        SharedPtr<SipMessage> refer(new SipMessage());        SharedPtr<SipMessage> refer(new SipMessage());
742        mDialog.makeRequest(*refer, REFER);        mDialog.makeRequest(*refer, REFER);
743        refer->header(h_ReferTo) = referTo;        refer->header(h_ReferTo) = referTo;
# Line 753  Line 750 
750           refer->header(h_Supporteds).push_back(Token(Symbols::NoReferSub));           refer->header(h_Supporteds).push_back(Token(Symbols::NoReferSub));
751        }        }
752    
753          if(mNitState == NitComplete)
754          {
755             mNitState = NitProceeding;
756             mReferSub = referSub;
757        send(refer);        send(refer);
758             return;
759          }
760          mNITQueue.push(new QueuedNIT(refer,referSub));
761          DebugLog(<< "refer - queuing NIT:" << refer->brief()<<endl);
762          return;
763     }     }
764     else     else
765     {     {
# Line 763  Line 769 
769     }     }
770  }  }
771    
772    void
773    InviteSession::nitComplete()
774    {
775       mNitState = NitComplete;
776       if (mNITQueue.size())
777       {
778          QueuedNIT *qn=mNITQueue.front();
779          mNITQueue.pop();
780          mNitState = NitProceeding;
781          mReferSub = qn->referSubscription();
782          DebugLog(<< "checkNITQueue - sending queued NIT:" << qn->getNIT()->brief()<<endl);
783          send(qn->getNIT());
784          delete qn;
785       }
786    }
787    
788  class InviteSessionReferCommand : public DumCommandAdapter  class InviteSessionReferCommand : public DumCommandAdapter
789  {  {
790  public:  public:
# Line 804  Line 826 
826        throw UsageUseException("Attempted to make a refer w/ and invalid replacement target", __FILE__, __LINE__);        throw UsageUseException("Attempted to make a refer w/ and invalid replacement target", __FILE__, __LINE__);
827     }     }
828    
    if (mSentRefer)  
    {  
       throw UsageUseException("Attempted to send overlapping refer", __FILE__, __LINE__);  
    }  
   
829     if (isConnected())  // ?slg? likely not safe in any state except Connected - what should behaviour be if state is ReceivedReinvite?     if (isConnected())  // ?slg? likely not safe in any state except Connected - what should behaviour be if state is ReceivedReinvite?
830     {     {
       mSentRefer = true;  
       mReferSub = referSub;  
831        SharedPtr<SipMessage> refer(new SipMessage());              SharedPtr<SipMessage> refer(new SipMessage());      
832        mDialog.makeRequest(*refer, REFER);        mDialog.makeRequest(*refer, REFER);
833    
# Line 834  Line 849 
849           refer->header(h_Supporteds).push_back(Token(Symbols::NoReferSub));           refer->header(h_Supporteds).push_back(Token(Symbols::NoReferSub));
850        }        }
851    
852          if(mNitState == NitComplete)
853          {
854             mNitState = NitProceeding;
855             mReferSub = referSub;
856        send(refer);        send(refer);
857             return;
858          }
859          mNITQueue.push(new QueuedNIT(refer,referSub));
860          DebugLog(<< "refer/replace - queuing NIT:" << refer->brief()<<endl);
861          return;
862     }     }
863     else     else
864     {     {
# Line 881  Line 905 
905  void  void
906  InviteSession::info(const Contents& contents)  InviteSession::info(const Contents& contents)
907  {  {
    if (mNitState == NitComplete)  
    {  
908        if (isConnected())  // ?slg? likely not safe in any state except Connected - what should behaviour be if state is ReceivedReinvite?        if (isConnected())  // ?slg? likely not safe in any state except Connected - what should behaviour be if state is ReceivedReinvite?
909        {        {
          mNitState = NitProceeding;  
910           SharedPtr<SipMessage> info(new SipMessage());           SharedPtr<SipMessage> info(new SipMessage());
911           mDialog.makeRequest(*info, INFO);           mDialog.makeRequest(*info, INFO);
912           // !jf! handle multipart here           // !jf! handle multipart here
913           info->setContents(&contents);           info->setContents(&contents);
914           DumHelper::setOutgoingEncryptionLevel(*info, mCurrentEncryptionLevel);           DumHelper::setOutgoingEncryptionLevel(*info, mCurrentEncryptionLevel);
915          if (mNitState == NitComplete)
916          {
917             mNitState = NitProceeding;
918           send(info);           send(info);
919             return;
920          }
921          mNITQueue.push(new QueuedNIT(info));
922          DebugLog(<< "refer - queuing NIT:" << info->brief()<<endl);
923          return;
924        }        }
925        else        else
926        {        {
# Line 900  Line 929 
929           throw UsageUseException("Can't send INFO before Connected", __FILE__, __LINE__);           throw UsageUseException("Can't send INFO before Connected", __FILE__, __LINE__);
930        }        }
931     }     }
    else  
    {  
       throw UsageUseException("Cannot start a non-invite transaction until the previous one has completed",  
                               __FILE__, __LINE__);  
    }  
 }  
932    
933  class InviteSessionInfoCommand : public DumCommandAdapter  class InviteSessionInfoCommand : public DumCommandAdapter
934  {  {
# Line 939  Line 962 
962  void  void
963  InviteSession::message(const Contents& contents)  InviteSession::message(const Contents& contents)
964  {  {
    if (mNitState == NitComplete)  
    {  
965        if (isConnected())  // ?slg? likely not safe in any state except Connected - what should behaviour be if state is ReceivedReinvite?        if (isConnected())  // ?slg? likely not safe in any state except Connected - what should behaviour be if state is ReceivedReinvite?
966        {        {
          mNitState = NitProceeding;  
967           SharedPtr<SipMessage> message(new SipMessage());           SharedPtr<SipMessage> message(new SipMessage());
968           mDialog.makeRequest(*message, MESSAGE);           mDialog.makeRequest(*message, MESSAGE);
969           // !jf! handle multipart here           // !jf! handle multipart here
970           message->setContents(&contents);           message->setContents(&contents);
971           DumHelper::setOutgoingEncryptionLevel(*message, mCurrentEncryptionLevel);           DumHelper::setOutgoingEncryptionLevel(*message, mCurrentEncryptionLevel);
          send(message);  
972           InfoLog (<< "Trying to send MESSAGE: " << message);           InfoLog (<< "Trying to send MESSAGE: " << message);
973          if (mNitState == NitComplete)
974          {
975             mNitState = NitProceeding;
976             send(message);
977             return;
978          }
979          mNITQueue.push(new QueuedNIT(message));
980          DebugLog(<< "refer - queuing NIT:" << message->brief()<<endl);
981          return;
982        }        }
983        else        else
984        {        {
# Line 959  Line 987 
987           throw UsageUseException("Can't send MESSAGE before Connected", __FILE__, __LINE__);           throw UsageUseException("Can't send MESSAGE before Connected", __FILE__, __LINE__);
988        }        }
989     }     }
    else  
    {  
       throw UsageUseException("Cannot start a non-invite transaction until the previous one has completed",  
                               __FILE__, __LINE__);  
    }  
 }  
990    
991  class InviteSessionMessageCommand : public DumCommandAdapter  class InviteSessionMessageCommand : public DumCommandAdapter
992  {  {
# Line 1990  Line 2012 
2012     else     else
2013     {     {
2014        assert(mNitState == NitProceeding);        assert(mNitState == NitProceeding);
       mNitState = NitComplete;  
2015        //!dcm! -- toss away 1xx to an info?        //!dcm! -- toss away 1xx to an info?
2016        if (msg.header(h_StatusLine).statusCode() >= 300)        if (msg.header(h_StatusLine).statusCode() >= 300)
2017        {        {
# Line 2000  Line 2021 
2021        {        {
2022           handler->onInfoSuccess(getSessionHandle(), msg);           handler->onInfoSuccess(getSessionHandle(), msg);
2023        }        }
2024          nitComplete();
2025     }     }
2026  }  }
2027    
# Line 2105  Line 2127 
2127     else     else
2128     {     {
2129        assert(mNitState == NitProceeding);        assert(mNitState == NitProceeding);
       mNitState = NitComplete;  
2130        //!dcm! -- toss away 1xx to an message?        //!dcm! -- toss away 1xx to an message?
2131        if (msg.header(h_StatusLine).statusCode() >= 300)        if (msg.header(h_StatusLine).statusCode() >= 300)
2132        {        {
# Line 2115  Line 2136 
2136        {        {
2137           handler->onMessageSuccess(getSessionHandle(), msg);           handler->onMessageSuccess(getSessionHandle(), msg);
2138        }        }
2139          nitComplete();
2140     }     }
2141  }  }
2142    
# Line 2970  Line 2992 
2992   */   */
2993    
2994    
2995    

Legend:
Removed from v.7544  
changed lines
  Added in v.7565

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27