From: Robert J. <rjo...@us...> - 2007-06-29 06:59:58
|
Update of /cvsroot/openh323/opal/src/sip In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv28556/src/sip Modified Files: sipcon.cxx sipep.cxx sippdu.cxx Log Message: Major improvement to the "product info", normalising H.221 and User-Agent mechanisms. Index: sipep.cxx =================================================================== RCS file: /cvsroot/openh323/opal/src/sip/sipep.cxx,v retrieving revision 2.174 retrieving revision 2.175 diff -C2 -d -r2.174 -r2.175 *** sipep.cxx 25 Jun 2007 05:16:20 -0000 2.174 --- sipep.cxx 29 Jun 2007 06:59:58 -0000 2.175 *************** *** 25,28 **** --- 25,31 ---- * * $Log$ + * Revision 2.175 2007/06/29 06:59:58 rjongbloed + * Major improvement to the "product info", normalising H.221 and User-Agent mechanisms. + * * Revision 2.174 2007/06/25 05:16:20 rjongbloed * Changed GetDefaultTransport() so can return multiple transport names eg udp$ AND tcp$. *************** *** 690,694 **** maxRetries = 10; lastSentCSeq = 0; - userAgentString = "OPAL/2.0"; transactions.DisallowDeleteObjects(); --- 693,696 ---- *************** *** 1708,1712 **** PString SIPEndPoint::GetUserAgent() const ! { return userAgentString; } --- 1710,1714 ---- PString SIPEndPoint::GetUserAgent() const ! { return userAgentString; } Index: sippdu.cxx =================================================================== RCS file: /cvsroot/openh323/opal/src/sip/sippdu.cxx,v retrieving revision 2.131 retrieving revision 2.132 diff -C2 -d -r2.131 -r2.132 *** sippdu.cxx 10 Jun 2007 08:55:13 -0000 2.131 --- sippdu.cxx 29 Jun 2007 06:59:58 -0000 2.132 *************** *** 25,28 **** --- 25,31 ---- * * $Log$ + * Revision 2.132 2007/06/29 06:59:58 rjongbloed + * Major improvement to the "product info", normalising H.221 and User-Agent mechanisms. + * * Revision 2.131 2007/06/10 08:55:13 rjongbloed * Major rework of how SIP utilises sockets, using new "socket bundling" subsystem. *************** *** 1241,1247 **** ! void SIPMIMEInfo::SetUserAgent(const SIPEndPoint & sipep) { ! SetAt("User-Agent", sipep.GetUserAgent()); // no compact form } --- 1244,1330 ---- ! void SIPMIMEInfo::SetUserAgent(const PString & v) { ! SetAt("User-Agent", v); // no compact form ! } ! ! ! PString SIPMIMEInfo::GetOrganization() const ! { ! return (*this)(PCaselessString("Organization")); // no compact form ! } ! ! ! void SIPMIMEInfo::SetOrganization(const PString & v) ! { ! SetAt("Organization", v); // no compact form ! } ! ! ! void SIPMIMEInfo::GetProductInfo(OpalProductInfo & info) ! { ! PCaselessString str = GetUserAgent(); ! if (str.IsEmpty()) { ! str = (*this)("Server"); ! if (str.IsEmpty()) ! return; // Have nothing, change nothing ! } ! ! // This is not strictly correct according to he BNF, but we cheat ! // and assume that the prod/ver tokens are first and if there is an ! // explicit comment field, it is always last. If any other prod/ver ! // tokens are present, then they will end up as the comments too. ! // All other variations just end up as one big comment ! ! static const char TokenChars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-.!%*_+`'~"; ! PINDEX endFirstToken = str.FindSpan(TokenChars); ! if (endFirstToken == 0) { ! info.name = str; ! info.vendor = info.version = PString::Empty(); ! info.manufacturerCode = info.t35Extension = info.t35CountryCode = 0; ! return; ! } ! ! PINDEX endSecondToken = str[endFirstToken] == '/' ? str.FindSpan(TokenChars, endFirstToken+1) : endFirstToken; ! ! info.name = str.Left(endFirstToken); ! info.version = str(endFirstToken+1, endSecondToken); ! info.vendor = GetOrganization(); ! } ! ! ! void SIPMIMEInfo::SetProductInfo(const PString & ua, const OpalProductInfo & info) ! { ! PString userAgent = ua; ! if (userAgent.IsEmpty()) { ! ! static const char TokenChars[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-.!%*_+`'~"; ! ! PINDEX pos; ! PCaselessString temp = info.name; ! while ((pos = temp.FindSpan(TokenChars)) != P_MAX_INDEX) ! temp.Delete(pos, 1); ! if (!temp.IsEmpty()) { ! userAgent = temp; ! ! temp = info.version; ! while ((pos = temp.FindSpan(TokenChars)) != P_MAX_INDEX) ! temp.Delete(pos, 1); ! if (!temp.IsEmpty()) ! userAgent += '/' + temp; ! ! temp = info.vendor; ! temp.Replace("(", "\\(", TRUE); ! temp.Replace(")", "\\)", TRUE); ! if (!temp.IsEmpty()) ! userAgent += " (" + temp + ')'; ! } ! } ! ! if (!userAgent.IsEmpty()) ! SetUserAgent(userAgent); // no compact form ! ! if (!info.vendor.IsEmpty()) ! SetOrganization(info.vendor); // no compact form } *************** *** 2460,2464 **** { mime.SetDate() ; // now ! mime.SetUserAgent(connection.GetEndPoint()); // normally 'OPAL/2.0' connection.BuildSDP(sdp, rtpSessions, OpalMediaFormat::DefaultAudioSessionID); --- 2543,2547 ---- { mime.SetDate() ; // now ! mime.SetProductInfo(connection.GetEndPoint().GetUserAgent(), connection.GetProductInfo()); connection.BuildSDP(sdp, rtpSessions, OpalMediaFormat::DefaultAudioSessionID); *************** *** 2479,2483 **** { mime.SetDate() ; // now ! mime.SetUserAgent(connection.GetEndPoint()); // normally 'OPAL/2.0' rtpSessions = sm; --- 2562,2566 ---- { mime.SetDate() ; // now ! mime.SetProductInfo(connection.GetEndPoint().GetUserAgent(), connection.GetProductInfo()); rtpSessions = sm; *************** *** 2498,2502 **** { mime.SetDate() ; // now ! mime.SetUserAgent(connection.GetEndPoint()); // normally 'OPAL/2.0' connection.BuildSDP(sdp, rtpSessions, rtpSessionId); --- 2581,2585 ---- { mime.SetDate() ; // now ! mime.SetProductInfo(connection.GetEndPoint().GetUserAgent(), connection.GetProductInfo()); connection.BuildSDP(sdp, rtpSessions, rtpSessionId); *************** *** 2553,2557 **** viaAddress); ! mime.SetUserAgent(ep); // normally 'OPAL/2.0' SIPURL contact = endpoint.GetLocalURL(trans, address.GetUserName()); mime.SetContact(contact); --- 2636,2640 ---- viaAddress); ! mime.SetProductInfo(ep.GetUserAgent(), ep.GetProductInfo()); SIPURL contact = endpoint.GetLocalURL(trans, address.GetUserName()); mime.SetContact(contact); *************** *** 2604,2608 **** SIPURL contact = endpoint.GetLocalURL(trans, SIPURL(localPartyAddress).GetUserName()); ! mime.SetUserAgent(ep); // normally 'OPAL/2.0' mime.SetContact(contact); mime.SetAccept(acceptField); --- 2687,2691 ---- SIPURL contact = endpoint.GetLocalURL(trans, SIPURL(localPartyAddress).GetUserName()); ! mime.SetProductInfo(ep.GetUserAgent(), ep.GetProductInfo()); mime.SetContact(contact); mime.SetAccept(acceptField); *************** *** 2635,2639 **** viaAddress); ! mime.SetUserAgent(ep); SIPURL contact = endpoint.GetLocalURL(trans, targetAddress.GetUserName()); mime.SetContact(contact); --- 2718,2722 ---- viaAddress); ! mime.SetProductInfo(ep.GetUserAgent(), ep.GetProductInfo()); SIPURL contact = endpoint.GetLocalURL(trans, targetAddress.GetUserName()); mime.SetContact(contact); *************** *** 2668,2672 **** void SIPRefer::Construct(SIPConnection & connection, OpalTransport & /*transport*/, const PString & refer, const PString & referred_by) { ! mime.SetUserAgent(connection.GetEndPoint()); // normally 'OPAL/2.0' mime.SetReferTo(refer); if(!referred_by.IsEmpty()) --- 2751,2755 ---- void SIPRefer::Construct(SIPConnection & connection, OpalTransport & /*transport*/, const PString & refer, const PString & referred_by) { ! mime.SetProductInfo(connection.GetEndPoint().GetUserAgent(), connection.GetProductInfo()); mime.SetReferTo(refer); if(!referred_by.IsEmpty()) *************** *** 2682,2686 **** PStringStream str; ! mime.SetUserAgent(connection.GetEndPoint()); // normally 'OPAL/2.0' mime.SetSubscriptionState("terminated;reason=noresource"); // Do not keep an internal state mime.SetEvent("refer"); --- 2765,2769 ---- PStringStream str; ! mime.SetProductInfo(connection.GetEndPoint().GetUserAgent(), connection.GetProductInfo()); mime.SetSubscriptionState("terminated;reason=noresource"); // Do not keep an internal state mime.SetEvent("refer"); Index: sipcon.cxx =================================================================== RCS file: /cvsroot/openh323/opal/src/sip/sipcon.cxx,v retrieving revision 2.235 retrieving revision 2.236 diff -C2 -d -r2.235 -r2.236 *** sipcon.cxx 28 Jun 2007 12:08:26 -0000 2.235 --- sipcon.cxx 29 Jun 2007 06:59:58 -0000 2.236 *************** *** 25,28 **** --- 25,31 ---- * * $Log$ + * Revision 2.236 2007/06/29 06:59:58 rjongbloed + * Major improvement to the "product info", normalising H.221 and User-Agent mechanisms. + * * Revision 2.235 2007/06/28 12:08:26 rjongbloed * Simplified mutex strategy to avoid some wierd deadlocks. All locking of access *************** *** 2116,2119 **** --- 2119,2123 ---- } + void SIPConnection::OnReceivedResponse(SIPTransaction & transaction, SIP_PDU & response) { *************** *** 2140,2145 **** SIPURL url(remotePartyAddress); remotePartyName = url.GetDisplayName (); ! remoteApplication = response.GetMIME().GetUserAgent (); ! remoteApplication.Replace ('/', '\t'); // get the route set from the Record-Route response field (in reverse order) --- 2144,2148 ---- SIPURL url(remotePartyAddress); remotePartyName = url.GetDisplayName (); ! response.GetMIME().GetProductInfo(remoteProductInfo); // get the route set from the Record-Route response field (in reverse order) *************** *** 2317,2322 **** SIPURL url(remotePartyAddress); remotePartyName = url.GetDisplayName (); ! remoteApplication = mime.GetUserAgent (); ! remoteApplication.Replace ('/', '\t'); localPartyAddress = mime.GetTo() + ";tag=" + GetTag(); // put a real random mime.SetTo(localPartyAddress); --- 2320,2324 ---- SIPURL url(remotePartyAddress); remotePartyName = url.GetDisplayName (); ! mime.GetProductInfo(remoteProductInfo); localPartyAddress = mime.GetTo() + ";tag=" + GetTag(); // put a real random mime.SetTo(localPartyAddress); *************** *** 2650,2655 **** SIPURL url(remotePartyAddress); remotePartyName = url.GetDisplayName (); ! remoteApplication = request.GetMIME ().GetUserAgent (); ! remoteApplication.Replace ('/', '\t'); Release(EndedByRemoteUser); --- 2652,2656 ---- SIPURL url(remotePartyAddress); remotePartyName = url.GetDisplayName (); ! response.GetMIME().GetProductInfo(remoteProductInfo); Release(EndedByRemoteUser); *************** *** 3059,3067 **** SIP_PDU response(*originalInvite, code, contact, extra); ! if (NULL != sdp) response.SetSDP(*sdp); if (response.GetStatusCode()/100 != 1) ackTimer = endpoint.GetAckTimeout(); ! return SendPDU(response, originalInvite->GetViaAddress(endpoint)); } --- 3060,3070 ---- SIP_PDU response(*originalInvite, code, contact, extra); ! if (NULL != sdp) ! response.SetSDP(*sdp); ! response.GetMIME().SetProductInfo(endpoint.GetUserAgent(), GetProductInfo()); if (response.GetStatusCode()/100 != 1) ackTimer = endpoint.GetAckTimeout(); ! return SendPDU(response, originalInvite->GetViaAddress(endpoint)); } |