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

📄 sipreferredby.cxx

📁 SIP(Session Initiation Protocol)是由IETF定义
💻 CXX
📖 第 1 页 / 共 2 页
字号:
/* ==================================================================== * The Vovida Software License, Version 1.0  *  * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved. *  * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: *  * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. *  * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in *    the documentation and/or other materials provided with the *    distribution. *  * 3. The names "VOCAL", "Vovida Open Communication Application Library", *    and "Vovida Open Communication Application Library (VOCAL)" must *    not be used to endorse or promote products derived from this *    software without prior written permission. For written *    permission, please contact vocal@vovida.org. * * 4. Products derived from this software may not be called "VOCAL", nor *    may "VOCAL" appear in their name, without prior written *    permission of Vovida Networks, Inc. *  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH * DAMAGE. *  * ==================================================================== *  * This software consists of voluntary contributions made by Vovida * Networks, Inc. and many individuals on behalf of Vovida Networks, * Inc.  For more information on Vovida Networks, Inc., please see * <http://www.vovida.org/>. * */static const char* const SipReferredBy_cxx_version =    "$Id: SipReferredBy.cxx,v 1.14 2002/11/09 02:15:50 derekm Exp $";#include "global.h"#include "SipReferredBy.hxx"#include "symbols.hxx"#include "SipParserMode.hxx"#include "BaseUrl.hxx"#include "SipUrl.hxx"#include "TelUrl.hxx"#include "Sptr.hxx"using namespace Vocal;stringSipReferredByParserException::getName( void ) const{    return "SipReferredByParserException";}SipReferredBy::SipReferredBy(UrlType uType)    :    referrerUrl(),    referencedUrl(),    displayName(),    address(),    pgpMap(),    authScheme("pgp"),    //   basicCookie(),    tokenMutex(){}SipReferredBy::~SipReferredBy(){}SipReferredBy::SipReferredBy(const SipReferredBy& src)        :        referrerUrl(duplicateUrl(src.referrerUrl)),	urlType(src.urlType),        referencedUrl(src.referencedUrl),        displayName(src.displayName),        address(src.address),        pgpMap(src.pgpMap),        authScheme(src.authScheme)        //basicCookie(src.basicCookie){}SipReferredBy::SipReferredBy( const Data& data )    :    referrerUrl(),    referencedUrl(),    displayName(),    address(),    pgpMap(),    authScheme("pgp"),    //basicCookie(),    tokenMutex(){    try    {        decode(data);	if (referrerUrl.getPtr() != 0)	{	    urlType = referrerUrl->getType();	}    }    catch (SipReferredByParserException&)    {        if (SipParserMode::sipParserMode())        {            cpLog(LOG_ERR, "Failed to Decodein Constructor :o( ");            throw SipReferredByParserException("failed in Decode", __FILE__, __LINE__, DECODE_REFERREDBY_FAILED);        }    }}voidSipReferredBy::scanReferrerUrl( const Data & tmpdata){    Data data = tmpdata;    Data sipdata;    int ret = data.match("<", &sipdata, true);    if (ret == NOT_FOUND)    {        Data value;        Data tmpval;        int retn = data.match("\n", &value, true) ;        if (retn == NOT_FOUND)        {	    // AmyS - 05/16/02 Decode the BaseUrl here.	    tmpval = value;	    referrerUrl = BaseUrl::decode(data);/*            if (SipParserMode::sipParserMode())            {                cpLog(LOG_ERR, "Failed to Decode in Constructor :o( ");                throw SipReferredByParserException("failed in Decode", __FILE__, __LINE__, DECODE_REFERREDBY_FAILED);             } */        }        else if (retn == FIRST)        {            if (SipParserMode::sipParserMode())            {                cpLog(LOG_ERR, "Failed to Decode in Constructor :o( ");                throw SipReferredByParserException("failed in Decode", __FILE__, __LINE__, DECODE_REFERREDBY_FAILED);            }        }        else if (retn == FOUND)        {            tmpval = value;            Data refdata;            int retval = tmpval.match(SP, &refdata, true);            if ( retval == FOUND)            {                referrerUrl = BaseUrl::decode(tmpval);                scanReferencedUrl(refdata);            }        }    }    else if (ret == FIRST)    {        try        {            parseUrl(data);        }        catch (SipReferredByParserException&)        {            if (SipParserMode::sipParserMode())            {                cpLog(LOG_ERR, "Failed to Decode in Scan SIPTO :o( ");                throw SipReferredByParserException("failed in Decode in scan SipReferredBy", __FILE__, __LINE__, PARSE_REFERRERURL_FAILED);            }        }    }    else if (ret == FOUND)    {        parseNameInfo(sipdata);        Data urlvalue;        parseUrl(data);    }}voidSipReferredBy::scanReferencedUrl( const Data & tmpdata){    Data sipdata;    Data data;    Data sdata = tmpdata;    int ret = sdata.match(":", &sipdata, true);    if (ret == NOT_FOUND)    {        if (SipParserMode::sipParserMode())        {            cpLog(LOG_ERR, "Failed to Decode in Constructor :o( ");            throw SipReferredByParserException("failed in Decode", __FILE__, __LINE__, DECODE_REFERREDBY_FAILED);        }    }    else if (ret == FOUND)    {        Data urldata;        referencedUrl = sipdata;        int retn = sdata.match("//", &urldata, true);        if (retn == FIRST)        {            Data urData;            int retl = sdata.match(CRLF, &urData, true);            if ( retl == FOUND)            {                urData.removeSpaces();                address = urData;            }            else if ( retl == NOT_FOUND)            {                sdata.removeSpaces();                address = sdata;            }        }        else        {            sipdata.removeSpaces();            if ( sipdata == "sip")            {                Data urData;                int retl = sdata.match(CRLF, &urData, true);                if ( retl == FOUND)                {                    address = urData;                }                else if ( retl == NOT_FOUND)                {                    address = sdata;                }            }            else            {                if (SipParserMode::sipParserMode())                {                    cpLog(LOG_ERR, "Failed to Decode in Scan SIPTO :o( ");                    throw SipReferredByParserException("failed in Decode in scan SipReferredBy", __FILE__, __LINE__, PARSE_REFERENCEDURL_FAILED);                }            }        }    }    else if (ret == FIRST)    {        if (SipParserMode::sipParserMode())        {            cpLog(LOG_ERR, "Failed to Decode in Scan SIPTO :o( ");            throw SipReferredByParserException("failed in Decode in scan SipReferredBy", __FILE__, __LINE__, PARSE_REFERENCEDURL_FAILED);        }    }}voidSipReferredBy::parse( const Data& refertodata){    Data data = refertodata;    try    {        Data tempdata;        int ret = data.match("pgp", &tempdata, true);        if ( ret == FIRST)        { // exception            if (SipParserMode::sipParserMode())            {                cpLog(LOG_ERR, "Failed to Decode in Parse :o( ");                throw SipReferredByParserException("failed in Decode", __FILE__, __LINE__, DECODE_REFERREDBY_FAILED);            }        }        if ( ret == FOUND)        {            scanAuthTokens(data);            scanReferrerUrl(tempdata);        }        if ( ret == NOT_FOUND)        {            scanReferrerUrl(data);        }    }    catch (SipReferredByParserException exception)    {        if (SipParserMode::sipParserMode())        {            cpLog(LOG_ERR, "Failed to Decode in Parse :o( ");            throw SipReferredByParserException("failed in Decode", __FILE__, __LINE__, DECODE_REFERREDBY_FAILED);        }    }}voidSipReferredBy::parseUrl(const Data& data){    Data urlvalue = data;    Data avalue;    int retur = urlvalue.match(">", &avalue, true);    if (retur == NOT_FOUND)    {        if (SipParserMode::sipParserMode())        {            cpLog(LOG_ERR, "Failed to Parse in ParseUrl() :o( ");            throw SipReferredByParserException("failed in Decode", __FILE__, __LINE__, PARSE_REFERRERURL_FAILED);        }    }    else if (retur == FIRST)    {        if (SipParserMode::sipParserMode())        {            cpLog(LOG_ERR, "Failed to Parse in ParseUrl()  :o( ");            throw SipReferredByParserException("failed in Decode", __FILE__, __LINE__, PARSE_REFERRERURL_FAILED);        }    }    else if (retur == FOUND)    {        referrerUrl = BaseUrl::decode(avalue);        scanReferencedUrl(avalue);    }}voidSipReferredBy::parseNameInfo(const Data& data){    Data newnameinfo;    Data nameinfo = data;    int ret = nameinfo.match(":", &newnameinfo, true);    Data newnameinf;    ret = nameinfo.match(" ", &newnameinf, true);    setDisplayName(nameinfo);}void SipReferredBy::setDisplayName(const Data& name){    displayName = name;}voidSipReferredBy::decode( const Data& alsostr ){    try    {        Data palsostr = REFERRED_BY;

⌨️ 快捷键说明

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