📄 sipto.cxx
字号:
voidSipTo::decode( const Data& tostr ){ try { parse(tostr); } catch (SipToParserException&) { if (SipParserMode::sipParserMode()) { cpLog(LOG_ERR, "Failed to Decode in decode() :o( "); throw SipToParserException("failed in Decode", __FILE__, __LINE__, DECODE_TO_FAILED); } }}const SipTo& SipTo::operator = (const SipTo& srcTo){ if (&srcTo != this) { toUrl = duplicateUrl(srcTo.toUrl); displayName = srcTo.displayName; tag = srcTo.tag; token = srcTo.token; qstring = srcTo.qstring; tokenMap = srcTo.tokenMap; } return (*this);}const bool SipTo::operator<(const SipTo& srcTo) const{ bool less; if ( (toUrl != 0) && (srcTo.toUrl != 0) ) { less = ( toUrl->isLessThan(srcTo.toUrl)); } else if ( (toUrl == 0) && (srcTo.toUrl != 0) ) { less = true; } else { less = false; } if ( less || (tag < srcTo.tag) || (token < srcTo.token) || (qstring < srcTo.qstring) ) { return true; } return false;}const bool SipTo::operator>(const SipTo& srcTo) const{ return (srcTo < *this);}const bool SipTo::operator ==(const SipTo& srcTo) const{ cpLog(LOG_DEBUG_STACK, "SipTo ::operator =="); bool equal = false; if ( (toUrl != 0) && (srcTo.toUrl != 0) ) { equal = ( toUrl->areEqual(srcTo.toUrl)); } else if ( (toUrl == 0) && (srcTo.toUrl == 0) ) { equal = true; } else { equal = false; } if (equal == false) { cpLog(LOG_DEBUG_STACK, " url match failed" ); if (toUrl != 0) { cpLog(LOG_DEBUG_STACK, "this.url = %s" , toUrl->encode().logData() ); }#ifdef __linux__ if (srcTo.toUrl != 0) { cpLog(LOG_DEBUG_STACK, "other.url = %s" , srcTo.toUrl->encode().logData() ); }#endif } equal = equal && (tag == srcTo.tag); cpLog(LOG_DEBUG_STACK, " tags equal is : %d", equal); cpLog(LOG_DEBUG_STACK, "this.tag = %s", getTag().logData()); cpLog(LOG_DEBUG_STACK, "other.Tag = %s", srcTo.getTag().logData()); equal = (equal && (tokenMap == srcTo.tokenMap)); cpLog(LOG_DEBUG_STACK, " tokenmap equal: %d", equal); cpLog(LOG_DEBUG_STACK, " to operator == final result: %d", equal); return equal;}voidSipTo::setPort(int portNum){ setPortData(Data(portNum));}void SipTo::setPortData(const Data& newport){ if (urlType == TEL_URL) { return; } if (toUrl == 0) { toUrl = new SipUrl(); } if (toUrl != 0) { if (toUrl->getType() == SIP_URL) { Sptr <SipUrl> sipUrl; (sipUrl.dynamicCast(toUrl))->setPort(newport); } }}DataSipTo::getPortData() const{ Data toUrlport; if (toUrl != 0) { if (toUrl->getType() == SIP_URL) { Sptr <SipUrl> sipUrl; toUrlport = (sipUrl.dynamicCast(toUrl))->getPort(); } } return toUrlport;} void SipTo::setTokenDetails(const Data& intoken, const Data& tokenValue){ tokenMap[intoken] = tokenValue;}Sptr < SipTo::TokenMapTo >SipTo::getTokenDetails() const{ Sptr < SipTo::TokenMapTo > dupMap = new TokenMapTo(tokenMap) ; return dupMap;}Data SipTo::getTokenValue(const Data& intoken) const{ Data ret; TokenMapTo::const_iterator check = tokenMap.find(intoken); ; if (check != tokenMap.end()) { ret = check -> second; } return ret;}intSipTo::getPort() const{ int p = getPortData().convertInt(); return p;}void SipTo::setUser(const Data& newuser){ if (toUrl == 0) { if (urlType == SIP_URL) { toUrl = new SipUrl(); } else if (urlType == TEL_URL) { toUrl = new TelUrl(); } } if (toUrl != 0) { toUrl->setUserValue(newuser); } //display name defaulted to user. if (displayName.length() == 0) { displayName = newuser; }}Data SipTo::getUser() const{ Data toUser; if (toUrl != 0) { toUser = toUrl->getUserValue(); } return toUser;}void SipTo::setDisplayName(const Data& name){ displayName = name;}const Data& SipTo::getDisplayName() const{ return displayName;} void SipTo::setHost(const Data& newhost){ if (urlType == TEL_URL) { //the user might set this to TelUrl, and then call setHost. //so, then , we should not create a SipUrl object. return; } if (toUrl == 0) { toUrl = new SipUrl(); } if (toUrl != 0) { if (toUrl->getType() == SIP_URL) { Sptr <SipUrl> sipUrl; (sipUrl.dynamicCast(toUrl))->setHost(newhost); } }} Data SipTo::getHost() const{ Data toHost; if (toUrl != 0) { if (toUrl->getType() == SIP_URL) { Sptr<SipUrl> sipUrl; toHost = (sipUrl.dynamicCast(toUrl))->getHost(); } } return toHost;}Data SipTo::encode() const{ Data sipTo; if (toUrl != 0) { sipTo = TO; sipTo += SP; if (displayName.length()) { sipTo += displayName; } sipTo += "<"; sipTo += toUrl->encode(); sipTo+= ">"; Data tagparam = getTag(); if (tagparam.length() > 0) { sipTo += ";"; sipTo += "tag="; sipTo += tagparam; } TokenMapTo::const_iterator i = tokenMap.begin(); if (i != tokenMap.end()) { sipTo += ";"; } while (i != tokenMap.end()) { Data token1 = i->first; Data tokenValue1 = i->second; sipTo += token1; if (tokenValue1.length() > 0) { sipTo += "="; sipTo += tokenValue1; } ++i; if ( i != tokenMap.end()) { sipTo += ";"; } } sipTo += CRLF; } return sipTo;}Sptr<BaseUrl> SipTo::getUrl() const{ return duplicateUrl(toUrl, true);}void SipTo::setUrl(Sptr<BaseUrl> tourl){ toUrl = duplicateUrl(tourl);}SipHeader*SipTo::duplicate() const{ return new SipTo(*this);}boolSipTo::compareSipHeader(SipHeader* msg) const{ SipTo* otherMsg = dynamic_cast<SipTo*>(msg); if(otherMsg != 0) { return (*this == *otherMsg); } else { return false; }}/* Local Variables: *//* c-file-style: "stroustrup" *//* indent-tabs-mode: nil *//* c-file-offsets: ((access-label . -) (inclass . ++)) *//* c-basic-offset: 4 *//* End: */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -