|
reSIProcate/stack
9694
|
Base class for all SIP body types. More...
#include <Contents.hxx>


Public Member Functions | |
| Contents (const HeaderFieldValue &headerFieldValue, const Mime &contentsType) | |
| pass Mime instance for parameters | |
| Contents (const Mime &contentsType) | |
| Create a contents with a given mime type. | |
| Contents (const Contents &rhs) | |
| Copy constructor. | |
| Contents (const Contents &rhs, HeaderFieldValue::CopyPaddingEnum e) | |
| Contents (const HeaderFieldValue &headerFieldValue, HeaderFieldValue::CopyPaddingEnum e, const Mime &contentsType) | |
| virtual | ~Contents () |
| Contents & | operator= (const Contents &rhs) |
| Assignment operator. | |
| void | preParseHeaders (ParseBuffer &pb) |
| Preforms preparsing on the headers stored in the ParseBuffer pb. | |
| EncodeStream & | encodeHeaders (EncodeStream &str) const |
| encodes headers to an output stream | |
| virtual Contents * | getContents () |
| access to wrapped contents (signed, encrypted) | |
| Contents * | getContents (const Mime &) |
| virtual Data | getBodyData () const |
| virtual Contents * | clone () const =0 |
| returns a copy of a Contents object | |
| const Mime & | getType () const |
| getter for mime type of message | |
| bool | exists (const HeaderBase &headerType) const |
| checks to see if a header is present | |
| void | remove (const HeaderBase &headerType) |
| removes a header if it is present | |
| bool | exists (const MIME_Header &headerType) const |
| checks to see if a MIME header exists | |
| void | remove (const MIME_Header &headerType) |
| removes a MIME header if it is present | |
| const H_ContentType::Type & | header (const H_ContentType &headerType) const |
| returns the value of the Content-Type header Throws an Contents::Exception if the header doesn't exist. | |
| H_ContentType::Type & | header (const H_ContentType &headerType) |
| returns the value of the Content-Type header | |
| const H_ContentDisposition::Type & | header (const H_ContentDisposition &headerType) const |
| returns the value of the Content-Disposition header Throws an Contents::Exception if the header doesn't exist. | |
| H_ContentDisposition::Type & | header (const H_ContentDisposition &headerType) |
| returns the value of the Content-Disposition header | |
| const H_ContentTransferEncoding::Type & | header (const H_ContentTransferEncoding &headerType) const |
| returns the value of the Content-Transfer-Encoding header Throws an Contents::Exception if the header doesn't exist. | |
| H_ContentTransferEncoding::Type & | header (const H_ContentTransferEncoding &headerType) |
| returns the value of the Content-Transfer-Encoding header | |
| const H_ContentLanguages::Type & | header (const H_ContentLanguages &headerType) const |
| returns the value of the Content-Languages header Throws an Contents::Exception if the header doesn't exist. | |
| H_ContentLanguages::Type & | header (const H_ContentLanguages &headerType) |
| returns the value of the Content-Languages header | |
| const H_ContentID::Type & | header (const H_ContentID &headerType) const |
| returns the value of the Content-ID MIME header Throws an Contents::Exception if the header doesn't exist. | |
| H_ContentID::Type & | header (const H_ContentID &headerType) |
| returns the value of the Content-ID MIME header | |
| const H_ContentDescription::Type & | header (const H_ContentDescription &headerType) const |
| returns the Content-Description MIME header Throws an Contents::Exception if the header doesn't exist. | |
| H_ContentDescription::Type & | header (const H_ContentDescription &headerType) |
| returns the Content-Description MIME header | |
| int & | version () |
| returns the major version of MIME used by the contents | |
| int & | minorVersion () |
| returns the minor version of MIME used by the contents | |
| void | addBuffer (char *buf) |
Static Public Member Functions | |
| static Contents * | createContents (const Mime &contentType, const Data &contents) |
| factory method to create a Contents object from a mime type and a payload | |
Protected Member Functions | |
| void | clear () |
| void | init () |
| void | init (const Contents &orig) |
| void | freeMem () |
| virtual const Data & | errorContext () const |
Protected Attributes | |
| Mime | mType |
| H_ContentDisposition::Type * | mDisposition |
| H_ContentTransferEncoding::Type * | mTransferEncoding |
| H_ContentLanguages::Type * | mLanguages |
| Token * | mId |
| H_ContentDescription::Type * | mDescription |
| StringCategory * | mLength |
| int | mVersion |
| int | mMinorVersion |
| std::vector< char * > | mBufferList |
| Contents::Contents | ( | const HeaderFieldValue & | headerFieldValue, |
| const Mime & | contentsType | ||
| ) |
pass Mime instance for parameters
Definition at line 21 of file Contents.cxx.
References init().
: LazyParser(headerFieldValue), mType(contentType) { init(); }

| Contents::Contents | ( | const Mime & | contentsType | ) |
Create a contents with a given mime type.
| contentsType | the mime type of the contents |
Definition at line 29 of file Contents.cxx.
References init().

| Contents::Contents | ( | const Contents & | rhs | ) |
Copy constructor.
| rhs | the Contents to be copied |
Definition at line 35 of file Contents.cxx.
References init().
: LazyParser(rhs) { init(rhs); }

| Contents::Contents | ( | const Contents & | rhs, |
| HeaderFieldValue::CopyPaddingEnum | e | ||
| ) |
Definition at line 41 of file Contents.cxx.
References init().
: LazyParser(rhs,e) { init(rhs); }

| Contents::Contents | ( | const HeaderFieldValue & | headerFieldValue, |
| HeaderFieldValue::CopyPaddingEnum | e, | ||
| const Mime & | contentsType | ||
| ) |
Definition at line 47 of file Contents.cxx.
References init().
: LazyParser(headerFieldValue,e), mType(contentsType) { init(); }

| Contents::~Contents | ( | ) | [virtual] |
Definition at line 57 of file Contents.cxx.
References freeMem().
{
freeMem();
}

| void Contents::addBuffer | ( | char * | buf | ) |
Definition at line 660 of file Contents.cxx.
References mBufferList.
{
mBufferList.push_back(buf);
}
| void resip::Contents::clear | ( | void | ) | [inline, protected] |
Reimplemented from resip::LazyParser.
Reimplemented in resip::MessageWaitingContents, and resip::MultipartMixedContents.
Definition at line 294 of file Contents.hxx.
References freeMem(), and init().

| virtual Contents* resip::Contents::clone | ( | ) | const [pure virtual] |
returns a copy of a Contents object
Implemented in resip::SdpContents, resip::Pkcs7SignedContents, resip::Pidf, resip::MessageWaitingContents, resip::SipFrag, resip::ApplicationSip, resip::MultipartMixedContents, resip::CpimContents, resip::MultipartSignedContents, resip::OctetContents, resip::Pkcs7Contents, resip::Pkcs8Contents, resip::X509Contents, resip::GenericContents, resip::PlainContents, resip::Rlmi, resip::InvalidContents, resip::ExternalBodyContents, resip::MultipartAlternativeContents, and resip::MultipartRelatedContents.
Referenced by extractFromPkcs7Recurse(), resip::SipMessage::init(), main(), resip::SipMessage::releaseContents(), and resip::SipMessage::setContents().
factory method to create a Contents object from a mime type and a payload
| contentType | the mime type of the contents |
| contents | the contents |
Definition at line 147 of file Contents.cxx.
References resip::Data::data(), resip::ContentsFactoryBase::getFactoryMap(), and resip::Data::size().
Referenced by resip::MultipartMixedContents::parse().
{
// !ass! why are we asserting that the Data doesn't own the buffer?
// .dlb. because this method is to be called only within a multipart
// !ass! HFV is an overlay -- then setting c->mIsMine to true ?? dlb Q
// .dlb. we are telling the content that it owns its HFV, not the data that it
// .dlb. owns its memory
// .bwc. So, we are _violating_ _encapsulation_, to make an assertion that the
// Data is an intermediate instead of owning the buffer itself? What do we
// care how this buffer is owned? All we require is that the buffer doesn't
// get dealloced/modified while we're still around. The assertion might mean
// that the Data will not do either of these things, but it affords no
// protection from the actual owner doing so. We are no more protected with
// the assertion, so I am removing it.
// assert(!contents.mMine);
HeaderFieldValue hfv(contents.data(), (unsigned int)contents.size());
// !bwc! This padding stuff is now the responsibility of the Contents class.
// if(contentType.subType()=="sipfrag"||contentType.subType()=="external-body")
// {
// // .bwc. The parser for sipfrag requires padding at the end of the hfv.
// HeaderFieldValue* temp = hfv;
// hfv = new HeaderFieldValue(*temp,HeaderFieldValue::CopyPadding);
// delete temp;
// }
Contents* c;
if (ContentsFactoryBase::getFactoryMap().find(contentType) != ContentsFactoryBase::getFactoryMap().end())
{
c = ContentsFactoryBase::getFactoryMap()[contentType]->create(hfv, contentType);
}
else
{
c = new OctetContents(hfv, contentType);
}
return c;
}

| EncodeStream & Contents::encodeHeaders | ( | EncodeStream & | str | ) | const |
encodes headers to an output stream
| str | output stream destination for encoded headers |
Definition at line 580 of file Contents.cxx.
References resip::Symbols::COLON, resip::Symbols::COMMA, CRLF, exists(), header(), mDescription, mId, mLength, mMinorVersion, mTransferEncoding, mType, mVersion, resip::Symbols::PERIOD, and resip::Symbols::SPACE.
{
if (mVersion != 1 || mMinorVersion != 0)
{
str << "MIME-Version" << Symbols::COLON[0] << Symbols::SPACE[0]
<< mVersion << Symbols::PERIOD[0] << mMinorVersion
<< Symbols::CRLF;
}
str << "Content-Type" << Symbols::COLON[0] << Symbols::SPACE[0]
<< mType
<< Symbols::CRLF;
if (exists(h_ContentDisposition))
{
str << "Content-Disposition" << Symbols::COLON[0] << Symbols::SPACE[0];
header(h_ContentDisposition).encode(str);
str << Symbols::CRLF;
}
if (exists(h_ContentLanguages))
{
str << "Content-Languages" << Symbols::COLON[0] << Symbols::SPACE[0];
size_t count = 0;
size_t size = header(h_ContentLanguages).size();
for (H_ContentLanguages::Type::const_iterator
i = header(h_ContentLanguages).begin();
i != header(h_ContentLanguages).end(); ++i)
{
i->encode(str);
if (++count < size)
str << Symbols::COMMA << Symbols::SPACE;
}
str << Symbols::CRLF;
}
if (mTransferEncoding)
{
str << "Content-Transfer-Encoding" << Symbols::COLON[0] << Symbols::SPACE[0]
<< *mTransferEncoding
<< Symbols::CRLF;
}
if (mId)
{
str << "Content-Id" << Symbols::COLON[0] << Symbols::SPACE[0]
<< *mId
<< Symbols::CRLF;
}
if (mDescription)
{
str << "Content-Description" << Symbols::COLON[0] << Symbols::SPACE[0]
<< *mDescription
<< Symbols::CRLF;
}
if (mLength)
{
str << "Content-Length" << Symbols::COLON[0] << Symbols::SPACE[0]
<< *mLength
<< Symbols::CRLF;
}
str << Symbols::CRLF;
return str;
}

| const Data & Contents::errorContext | ( | ) | const [protected, virtual] |
Implements resip::LazyParser.
Definition at line 64 of file Contents.cxx.
References errorContextData.
{
return errorContextData;
}
| bool Contents::exists | ( | const HeaderBase & | headerType | ) | const |
checks to see if a header is present
| headerType | the header to check for |
Definition at line 188 of file Contents.cxx.
References resip::LazyParser::checkParsed(), resip::HeaderBase::getTypeNum(), mDisposition, mLanguages, and mTransferEncoding.
Referenced by encodeHeaders().
{
checkParsed();
switch (headerType.getTypeNum())
{
case Headers::ContentType :
{
return true;
}
case Headers::ContentDisposition :
{
return mDisposition != 0;
}
case Headers::ContentTransferEncoding :
{
return mTransferEncoding != 0;
}
case Headers::ContentLanguage :
{
return mLanguages != 0;
}
default : return false;
}
}

| bool Contents::exists | ( | const MIME_Header & | headerType | ) | const |
checks to see if a MIME header exists
| headerType | the MIME header to check for |
Definition at line 214 of file Contents.cxx.
References mDescription, and mId.
{
if (&type == &h_ContentID)
{
return mId != 0;
}
if (&type == &h_ContentDescription)
{
return mDescription != 0;
}
assert(false);
return false;
}
| void resip::Contents::freeMem | ( | ) | [inline, protected] |
Definition at line 322 of file Contents.hxx.
References mBufferList, mDescription, mDisposition, mId, mLanguages, mLength, and mTransferEncoding.
Referenced by clear(), operator=(), and ~Contents().
{
delete mDisposition;
delete mTransferEncoding;
delete mLanguages;
delete mId;
delete mDescription;
delete mLength;
for (std::vector<char*>::iterator i = mBufferList.begin();
i != mBufferList.end(); i++)
{
delete [] *i;
}
}
| Data Contents::getBodyData | ( | ) | const [virtual] |
Definition at line 653 of file Contents.cxx.
References resip::LazyParser::checkParsed(), and resip::Data::from().
Referenced by main(), and resip::TuIM::processMessageRequest().
{
checkParsed();
return Data::from(*this);
}

| virtual Contents* resip::Contents::getContents | ( | ) | [inline, virtual] |
access to wrapped contents (signed, encrypted)
Definition at line 100 of file Contents.hxx.
Referenced by main(), and test7().
{return this;}
| const Mime& resip::Contents::getType | ( | ) | const [inline] |
getter for mime type of message
Definition at line 118 of file Contents.hxx.
References mType.
Referenced by findRlmi(), preParseHeaders(), resip::TuIM::processMessageRequest(), resip::TuIM::processNotifyRequest(), resip::TuIM::processSipFrag(), and test7().
{return mType;}
| const H_ContentType::Type & Contents::header | ( | const H_ContentType & | headerType | ) | const |
returns the value of the Content-Type header Throws an Contents::Exception if the header doesn't exist.
retval = contents.header(Headers::ContentType);
Definition at line 279 of file Contents.cxx.
References mType.
Referenced by encodeHeaders(), resip::SipMessage::getContents(), main(), preParseHeaders(), resip::TuIM::sendPage(), and setContentsHeaders().
{
return mType;
}
| H_ContentType::Type & Contents::header | ( | const H_ContentType & | headerType | ) |
returns the value of the Content-Type header
retval = contents.header(Headers::ContentType);
Definition at line 285 of file Contents.cxx.
References mType.
{
return mType;
}
| const H_ContentDisposition::Type & Contents::header | ( | const H_ContentDisposition & | headerType | ) | const |
returns the value of the Content-Disposition header Throws an Contents::Exception if the header doesn't exist.
retval = contents.header(Headers::ContentDisposition);
Definition at line 291 of file Contents.cxx.
References resip::LazyParser::checkParsed(), ErrLog, and mDisposition.
{
checkParsed();
if (mDisposition == 0)
{
ErrLog(<< "You called "
"Contents::header(const H_ContentDisposition& headerType) _const_ "
"without first calling exists(), and the header does not exist. Our"
" behavior in this scenario is to implicitly create the header(using const_cast!); "
"this is probably not what you want, but it is either this or "
"assert/throw an exception. Since this has been the behavior for "
"so long, we are not throwing here, _yet_. You need to fix your "
"code, before we _do_ start throwing. This is why const-correctness"
" should never be made a TODO item </rant>");
Contents* ncthis = const_cast<Contents*>(this);
ncthis->mDisposition = new H_ContentDisposition::Type;
}
return *mDisposition;
}

| H_ContentDisposition::Type & Contents::header | ( | const H_ContentDisposition & | headerType | ) |
returns the value of the Content-Disposition header
retval = contents.header(Headers::ContentDisposition);
Definition at line 312 of file Contents.cxx.
References resip::LazyParser::checkParsed(), and mDisposition.
{
checkParsed();
if (mDisposition == 0)
{
mDisposition = new H_ContentDisposition::Type;
}
return *mDisposition;
}

| const H_ContentTransferEncoding::Type & Contents::header | ( | const H_ContentTransferEncoding & | headerType | ) | const |
returns the value of the Content-Transfer-Encoding header Throws an Contents::Exception if the header doesn't exist.
retval = contents.header(Headers::ContentTransferEncoding);
Definition at line 323 of file Contents.cxx.
References resip::LazyParser::checkParsed(), ErrLog, and mTransferEncoding.
{
checkParsed();
if (mTransferEncoding == 0)
{
ErrLog(<< "You called "
"Contents::header(const H_ContentTransferEncoding& headerType) _const_ "
"without first calling exists(), and the header does not exist. Our"
" behavior in this scenario is to implicitly create the header(using const_cast!); "
"this is probably not what you want, but it is either this or "
"assert/throw an exception. Since this has been the behavior for "
"so long, we are not throwing here, _yet_. You need to fix your "
"code, before we _do_ start throwing. This is why const-correctness"
" should never be made a TODO item </rant>");
Contents* ncthis = const_cast<Contents*>(this);
ncthis->mTransferEncoding = new H_ContentTransferEncoding::Type;
}
return *mTransferEncoding;
}

| H_ContentTransferEncoding::Type & Contents::header | ( | const H_ContentTransferEncoding & | headerType | ) |
returns the value of the Content-Transfer-Encoding header
retval = contents.header(Headers::ContentTransferEncoding);
Definition at line 344 of file Contents.cxx.
References resip::LazyParser::checkParsed(), and mTransferEncoding.
{
checkParsed();
if (mTransferEncoding == 0)
{
mTransferEncoding = new H_ContentTransferEncoding::Type;
}
return *mTransferEncoding;
}

| const H_ContentLanguages::Type & Contents::header | ( | const H_ContentLanguages & | headerType | ) | const |
returns the value of the Content-Languages header Throws an Contents::Exception if the header doesn't exist.
retval = contents.header(Headers::ContentLanguages);
Definition at line 355 of file Contents.cxx.
References resip::LazyParser::checkParsed(), ErrLog, and mLanguages.
{
checkParsed();
if (mLanguages == 0)
{
ErrLog(<< "You called "
"Contents::header(const H_ContentLanguages& headerType) _const_ "
"without first calling exists(), and the header does not exist. Our"
" behavior in this scenario is to implicitly create the header(using const_cast!); "
"this is probably not what you want, but it is either this or "
"assert/throw an exception. Since this has been the behavior for "
"so long, we are not throwing here, _yet_. You need to fix your "
"code, before we _do_ start throwing. This is why const-correctness"
" should never be made a TODO item </rant>");
Contents* ncthis = const_cast<Contents*>(this);
ncthis->mLanguages = new H_ContentLanguages::Type;
}
return *mLanguages;
}

| H_ContentLanguages::Type & Contents::header | ( | const H_ContentLanguages & | headerType | ) |
returns the value of the Content-Languages header
retval = contents.header(Headers::ContentLanguages);
Definition at line 376 of file Contents.cxx.
References resip::LazyParser::checkParsed(), and mLanguages.
{
checkParsed();
if (mLanguages == 0)
{
mLanguages = new H_ContentLanguages::Type;
}
return *mLanguages;
}

| const H_ContentID::Type & Contents::header | ( | const H_ContentID & | headerType | ) | const |
returns the value of the Content-ID MIME header Throws an Contents::Exception if the header doesn't exist.
retval = contents.header(Headers::ContentId);
Definition at line 419 of file Contents.cxx.
References resip::LazyParser::checkParsed(), ErrLog, and mId.
{
checkParsed();
if (mId == 0)
{
ErrLog(<< "You called "
"Contents::header(const H_ContentID& headerType) _const_ "
"without first calling exists(), and the header does not exist. Our"
" behavior in this scenario is to implicitly create the header(using const_cast!); "
"this is probably not what you want, but it is either this or "
"assert/throw an exception. Since this has been the behavior for "
"so long, we are not throwing here, _yet_. You need to fix your "
"code, before we _do_ start throwing. This is why const-correctness"
" should never be made a TODO item </rant>");
Contents* ncthis = const_cast<Contents*>(this);
ncthis->mId = new H_ContentID::Type;
}
return *mId;
}

| H_ContentID::Type & Contents::header | ( | const H_ContentID & | headerType | ) |
returns the value of the Content-ID MIME header
retval = contents.header(Headers::ContentId);
Definition at line 440 of file Contents.cxx.
References resip::LazyParser::checkParsed(), and mId.
{
checkParsed();
if (mId == 0)
{
mId = new H_ContentID::Type;
}
return *mId;
}

| const H_ContentDescription::Type & Contents::header | ( | const H_ContentDescription & | headerType | ) | const |
returns the Content-Description MIME header Throws an Contents::Exception if the header doesn't exist.
retval = contents.header(Headers::ContentDescription)
Definition at line 387 of file Contents.cxx.
References resip::LazyParser::checkParsed(), ErrLog, and mDescription.
{
checkParsed();
if (mDescription == 0)
{
ErrLog(<< "You called "
"Contents::header(const H_ContentDescription& headerType) _const_ "
"without first calling exists(), and the header does not exist. Our"
" behavior in this scenario is to implicitly create the header(using const_cast!); "
"this is probably not what you want, but it is either this or "
"assert/throw an exception. Since this has been the behavior for "
"so long, we are not throwing here, _yet_. You need to fix your "
"code, before we _do_ start throwing. This is why const-correctness"
" should never be made a TODO item </rant>");
Contents* ncthis = const_cast<Contents*>(this);
ncthis->mDescription = new H_ContentDescription::Type;
}
return *mDescription;
}

| H_ContentDescription::Type & Contents::header | ( | const H_ContentDescription & | headerType | ) |
returns the Content-Description MIME header
retval = contents.header(Headers::ContentDescription)
Definition at line 408 of file Contents.cxx.
References resip::LazyParser::checkParsed(), and mDescription.
{
checkParsed();
if (mDescription == 0)
{
mDescription = new H_ContentDescription::Type;
}
return *mDescription;
}

| void resip::Contents::init | ( | ) | [inline, protected] |
Reimplemented in resip::SdpContents, resip::MessageWaitingContents, resip::Pkcs7SignedContents, resip::Pidf, resip::MultipartMixedContents, resip::SipFrag, resip::CpimContents, resip::OctetContents, resip::Pkcs7Contents, resip::Pkcs8Contents, resip::PlainContents, resip::Rlmi, resip::X509Contents, resip::ApplicationSip, resip::MultipartSignedContents, resip::ExternalBodyContents, resip::MultipartAlternativeContents, and resip::MultipartRelatedContents.
Definition at line 301 of file Contents.hxx.
References mBufferList, mDescription, mDisposition, mId, mLanguages, mLength, mMinorVersion, mTransferEncoding, and mVersion.
Referenced by clear(), Contents(), and operator=().
{
mBufferList.clear();
mDisposition = 0;
mTransferEncoding = 0;
mLanguages = 0;
mId = 0;
mDescription = 0;
mLength = 0;
mVersion = 1;
mMinorVersion = 0;
}
| void Contents::init | ( | const Contents & | orig | ) | [protected] |
Definition at line 83 of file Contents.cxx.
References mBufferList, mDescription, mDisposition, mId, mLanguages, mLength, mMinorVersion, mTransferEncoding, mType, and mVersion.
{
mBufferList.clear();
mType = orig.mType;
if (orig.mDisposition)
{
mDisposition = new H_ContentDisposition::Type(*orig.mDisposition);
}
else
{
mDisposition = 0;
}
if (orig.mTransferEncoding)
{
mTransferEncoding = new H_ContentTransferEncoding::Type(*orig.mTransferEncoding);
}
else
{
mTransferEncoding = 0;
}
if (orig.mLanguages)
{
mLanguages = new H_ContentLanguages::Type(*orig.mLanguages);
}
else
{
mLanguages = 0;
}
if (orig.mId)
{
mId = new Token(*orig.mId);
}
else
{
mId = 0;
}
if (orig.mDescription)
{
mDescription = new StringCategory(*orig.mDescription);
}
else
{
mDescription = 0;
}
if(orig.mLength)
{
mLength = new StringCategory(*orig.mLength);
}
else
{
mLength = 0;
}
mVersion = orig.mVersion;
mMinorVersion = orig.mMinorVersion;
}
| int& resip::Contents::minorVersion | ( | ) | [inline] |
returns the minor version of MIME used by the contents
Definition at line 280 of file Contents.hxx.
References mMinorVersion.
{return mMinorVersion;}
Assignment operator.
| rhs | Contents object to be copied |
Definition at line 70 of file Contents.cxx.
References freeMem(), and init().
{
if (this != &rhs)
{
freeMem();
LazyParser::operator=(rhs);
init(rhs);
}
return *this;
}

| void Contents::preParseHeaders | ( | ParseBuffer & | pb | ) |
Preforms preparsing on the headers stored in the ParseBuffer pb.
| pb | a ParseBuffer containing the headers to preparse |
Definition at line 452 of file Contents.cxx.
References resip::Symbols::COLON, resip::Symbols::COMMA, resip::ParseBuffer::data(), resip::ParseBuffer::end(), resip::ParseBuffer::eof(), ErrLog, getType(), header(), resip::isEqualNoCase(), resip::Symbols::LPAREN, mDescription, mDisposition, mId, mLanguages, mLength, mMinorVersion, mTransferEncoding, mVersion, resip::StringCategory::parse(), resip::Token::parse(), resip::Symbols::PERIOD, resip::ParseBuffer::position(), resip::Symbols::RPAREN, resip::ParseBuffer::skipChar(), resip::ParseBuffer::skipToOneOf(), resip::ParseBuffer::skipToTermCRLF(), resip::ParseBuffer::skipWhitespace(), type, and resip::ParseBuffer::Whitespace.
{
const char* start = pb.position();
Data all( start, pb.end()-start);
Data headerName;
try
{
while (!pb.eof())
{
const char* anchor = pb.skipWhitespace();
pb.skipToOneOf(Symbols::COLON, ParseBuffer::Whitespace);
pb.data(headerName, anchor);
pb.skipWhitespace();
pb.skipChar(Symbols::COLON[0]);
anchor = pb.skipWhitespace();
pb.skipToTermCRLF();
Headers::Type type = Headers::getType(headerName.data(), (int)headerName.size());
ParseBuffer subPb(anchor, pb.position() - anchor);
switch (type)
{
case Headers::ContentType :
{
// already set
break;
}
case Headers::ContentDisposition :
{
mDisposition = new H_ContentDisposition::Type;
mDisposition->parse(subPb);
break;
}
case Headers::ContentTransferEncoding :
{
mTransferEncoding = new H_ContentTransferEncoding::Type;
mTransferEncoding->parse(subPb);
break;
}
// !dlb! not sure this ever happens?
case Headers::ContentLanguage :
{
if (mLanguages == 0)
{
mLanguages = new H_ContentLanguages::Type;
}
subPb.skipWhitespace();
while (!subPb.eof() && *subPb.position() != Symbols::COMMA[0])
{
H_ContentLanguages::Type::value_type tmp;
header(h_ContentLanguages).push_back(tmp);
header(h_ContentLanguages).back().parse(subPb);
subPb.skipLWS();
}
break; // .kw. added -- this is needed, right?
}
default :
{
if (isEqualNoCase(headerName, "Content-Transfer-Encoding"))
{
mTransferEncoding = new StringCategory();
mTransferEncoding->parse(subPb);
}
else if (isEqualNoCase(headerName, "Content-Description"))
{
mDescription = new StringCategory();
mDescription->parse(subPb);
}
else if (isEqualNoCase(headerName, "Content-Id"))
{
mId = new Token();
mId->parse(subPb);
}
// Some people put this in ...
else if (isEqualNoCase(headerName, "Content-Length"))
{
mLength = new StringCategory();
mLength->parse(subPb);
}
else if (isEqualNoCase(headerName, "MIME-Version"))
{
subPb.skipWhitespace();
if (!subPb.eof() && *subPb.position() == Symbols::LPAREN[0])
{
subPb.skipToEndQuote(Symbols::RPAREN[0]);
subPb.skipChar(Symbols::RPAREN[0]);
}
mVersion = subPb.integer();
if (!subPb.eof() && *subPb.position() == Symbols::LPAREN[0])
{
subPb.skipToEndQuote(Symbols::RPAREN[0]);
subPb.skipChar(Symbols::RPAREN[0]);
}
subPb.skipChar(Symbols::PERIOD[0]);
if (!subPb.eof() && *subPb.position() == Symbols::LPAREN[0])
{
subPb.skipToEndQuote(Symbols::RPAREN[0]);
subPb.skipChar(Symbols::RPAREN[0]);
}
mMinorVersion = subPb.integer();
}
else
{
// add to application headers someday
std::cerr << "Unknown MIME Content- header: " << headerName << std::endl;
ErrLog(<< "Unknown MIME Content- header: " << headerName);
assert(false);
}
}
}
}
}
catch (ParseException & e )
{
ErrLog( << "Some problem parsing contents: " << e );
throw e;
}
}

| void Contents::remove | ( | const HeaderBase & | headerType | ) |
removes a header if it is present
| headerType | the header to remove |
Definition at line 231 of file Contents.cxx.
References resip::HeaderBase::getTypeNum(), mDisposition, mLanguages, and mTransferEncoding.
{
switch (headerType.getTypeNum())
{
case Headers::ContentDisposition :
{
delete mDisposition;
mDisposition = 0;
break;
}
case Headers::ContentLanguage :
{
delete mLanguages;
mLanguages = 0;
break;
}
case Headers::ContentTransferEncoding :
{
delete mTransferEncoding;
mTransferEncoding = 0;
break;
}
default :
;
}
}

| void Contents::remove | ( | const MIME_Header & | headerType | ) |
removes a MIME header if it is present
| headerType | the MIME header to remove |
Definition at line 259 of file Contents.cxx.
References mDescription, and mId.
{
if (&type == &h_ContentID)
{
delete mId;
mId = 0;
return;
}
if (&type == &h_ContentDescription)
{
delete mDescription;
mDescription = 0;
return;
}
assert(false);
}
| int& resip::Contents::version | ( | ) | [inline] |
returns the major version of MIME used by the contents
Definition at line 275 of file Contents.hxx.
References mVersion.
{return mVersion;}
std::vector<char*> resip::Contents::mBufferList [protected] |
Definition at line 361 of file Contents.hxx.
Referenced by addBuffer(), freeMem(), and init().
H_ContentDescription::Type* resip::Contents::mDescription [protected] |
Definition at line 352 of file Contents.hxx.
Referenced by encodeHeaders(), exists(), freeMem(), header(), init(), preParseHeaders(), and remove().
H_ContentDisposition::Type* resip::Contents::mDisposition [protected] |
Definition at line 344 of file Contents.hxx.
Referenced by exists(), freeMem(), header(), init(), preParseHeaders(), and remove().
Token* resip::Contents::mId [protected] |
Definition at line 350 of file Contents.hxx.
Referenced by encodeHeaders(), exists(), freeMem(), header(), init(), preParseHeaders(), and remove().
H_ContentLanguages::Type* resip::Contents::mLanguages [protected] |
Definition at line 348 of file Contents.hxx.
Referenced by exists(), freeMem(), header(), init(), preParseHeaders(), and remove().
StringCategory* resip::Contents::mLength [protected] |
Definition at line 354 of file Contents.hxx.
Referenced by encodeHeaders(), freeMem(), init(), and preParseHeaders().
int resip::Contents::mMinorVersion [protected] |
Definition at line 359 of file Contents.hxx.
Referenced by encodeHeaders(), init(), minorVersion(), and preParseHeaders().
H_ContentTransferEncoding::Type* resip::Contents::mTransferEncoding [protected] |
Definition at line 346 of file Contents.hxx.
Referenced by encodeHeaders(), exists(), freeMem(), header(), init(), resip::Pkcs7Contents::parse(), preParseHeaders(), and remove().
Mime resip::Contents::mType [protected] |
Definition at line 342 of file Contents.hxx.
Referenced by encodeHeaders(), resip::MultipartMixedContents::encodeParsed(), getType(), header(), init(), resip::MultipartMixedContents::MultipartMixedContents(), resip::MultipartMixedContents::parse(), and resip::MultipartMixedContents::setBoundary().
int resip::Contents::mVersion [protected] |
Definition at line 357 of file Contents.hxx.
Referenced by resip::SdpContents::Session::encode(), encodeHeaders(), init(), resip::SdpContents::Session::operator=(), resip::SdpContents::Session::parse(), preParseHeaders(), and version().
1.7.5.1