reSIProcate/DialogUsageManager  9694
InviteSessionCreator.cxx
Go to the documentation of this file.
00001 #include "resip/stack/MultipartMixedContents.hxx"
00002 #include "resip/stack/MultipartAlternativeContents.hxx"
00003 #include "resip/dum/InviteSessionCreator.hxx"
00004 #include "resip/stack/SdpContents.hxx"
00005 #include "resip/dum/DialogUsageManager.hxx"
00006 #include "resip/dum/MasterProfile.hxx"
00007 #include "resip/dum/DumHelper.hxx"
00008 
00009 using namespace resip;
00010 
00011 InviteSessionCreator::InviteSessionCreator(DialogUsageManager& dum,
00012                                            const NameAddr& target,
00013                                            SharedPtr<UserProfile> userProfile,
00014                                            const Contents* initial,
00015                                            DialogUsageManager::EncryptionLevel level,
00016                                            const Contents* alternative,
00017                                            ServerSubscriptionHandle serverSub)
00018    : BaseCreator(dum, userProfile),
00019      mState(Initialized),
00020      mServerSub(serverSub),
00021      mEncryptionLevel(level)
00022 {
00023    makeInitialRequest(target, INVITE);
00024    if (userProfile->isAnonymous())
00025    {
00026       mLastRequest->header(h_Privacys).push_back(PrivacyCategory(Symbols::id));
00027    }
00028    
00029    DumHelper::setOutgoingEncryptionLevel(*mLastRequest, level);
00030    if(mDum.getMasterProfile()->getSupportedOptionTags().find(Token(Symbols::Timer)))
00031    {
00032       assert(userProfile.get());
00033       if(userProfile->getDefaultSessionTime() >= 90)
00034       {
00035          getLastRequest()->header(h_SessionExpires).value() = userProfile->getDefaultSessionTime();
00036          getLastRequest()->header(h_MinSE).value() = 90;  // Absolute minimum specified by RFC4028
00037       }
00038    }
00039 
00040    std::auto_ptr<Contents> initialOffer;
00041    if (initial)
00042    {
00043       if (alternative)
00044       {
00045          MultipartAlternativeContents* mac = new MultipartAlternativeContents;
00046          mac->parts().push_back(alternative->clone());
00047          mac->parts().push_back(initial->clone());
00048          initialOffer.reset(mac);
00049       }
00050       else
00051       {
00052          initialOffer.reset(initial->clone());
00053       }
00054       getLastRequest()->setContents(initialOffer);
00055    }
00056    //100rel 
00057    switch(mDum.getMasterProfile()->getUacReliableProvisionalMode())
00058    {
00059       case MasterProfile::Never:
00060          //no support, do nothing
00061          break;
00062       case MasterProfile::Supported:
00063          getLastRequest()->header(h_Supporteds).push_back(Token(Symbols::C100rel));
00064          break;
00065       case MasterProfile::Required:
00066          getLastRequest()->header(h_Requires).push_back(Token(Symbols::C100rel));
00067          break;
00068       default:
00069          assert(0);
00070    }
00071 }
00072 
00073 InviteSessionCreator::~InviteSessionCreator()
00074 {
00075 }
00076 
00077 void
00078 InviteSessionCreator::end()
00079 {
00080    assert(0);
00081 }
00082 
00083 void
00084 InviteSessionCreator::dispatch(const SipMessage& msg)
00085 {
00086    // !jf! does this have to do with CANCELing all of the branches associated
00087    // with a single invite request
00088 }
00089 
00090 const Contents*
00091 InviteSessionCreator::getInitialOffer()
00092 {
00093    return getLastRequest()->getContents();
00094 }
00095 
00096 
00097 /* ====================================================================
00098  * The Vovida Software License, Version 1.0 
00099  * 
00100  * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved.
00101  * 
00102  * Redistribution and use in source and binary forms, with or without
00103  * modification, are permitted provided that the following conditions
00104  * are met:
00105  * 
00106  * 1. Redistributions of source code must retain the above copyright
00107  *    notice, this list of conditions and the following disclaimer.
00108  * 
00109  * 2. Redistributions in binary form must reproduce the above copyright
00110  *    notice, this list of conditions and the following disclaimer in
00111  *    the documentation and/or other materials provided with the
00112  *    distribution.
00113  * 
00114  * 3. The names "VOCAL", "Vovida Open Communication Application Library",
00115  *    and "Vovida Open Communication Application Library (VOCAL)" must
00116  *    not be used to endorse or promote products derived from this
00117  *    software without prior written permission. For written
00118  *    permission, please contact vocal@vovida.org.
00119  *
00120  * 4. Products derived from this software may not be called "VOCAL", nor
00121  *    may "VOCAL" appear in their name, without prior written
00122  *    permission of Vovida Networks, Inc.
00123  * 
00124  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
00125  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00126  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
00127  * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
00128  * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
00129  * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
00130  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00131  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00132  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00133  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00134  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
00135  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
00136  * DAMAGE.
00137  * 
00138  * ====================================================================
00139  * 
00140  * This software consists of voluntary contributions made by Vovida
00141  * Networks, Inc. and many individuals on behalf of Vovida Networks,
00142  * Inc.  For more information on Vovida Networks, Inc., please see
00143  * <http://www.vovida.org/>.
00144  *
00145  */