|
reSIProcate/stack
9694
|
SIP body type for holding Multipart-Mixed body contents (MIME content-type multipart/mixed). More...
#include <MultipartMixedContents.hxx>


Classes | |
| class | Exception |
| Thrown when there is an error parsing a multi-part mixed contents envelope. More... | |
Public Types | |
| typedef std::vector< Contents * > | Parts |
Public Member Functions | |
| MultipartMixedContents () | |
| MultipartMixedContents (const Mime &contentType) | |
| MultipartMixedContents (const HeaderFieldValue &hfv, const Mime &contentType) | |
| MultipartMixedContents (const MultipartMixedContents &rhs) | |
| virtual | ~MultipartMixedContents () |
| MultipartMixedContents & | operator= (const MultipartMixedContents &rhs) |
| virtual Contents * | clone () const |
| duplicate an MultipartMixedContents object | |
| virtual EncodeStream & | encodeParsed (EncodeStream &str) const |
| virtual void | parse (ParseBuffer &pb) |
| Parts & | parts () |
| const Parts & | parts () const |
| void | setBoundary (const Data &boundary) |
Static Public Member Functions | |
| static const Mime & | getStaticType () |
| static bool | init () |
Protected Member Functions | |
| void | clear () |
Private Member Functions | |
| void | setBoundary () |
Private Attributes | |
| std::vector< Contents * > | mContents |
SIP body type for holding Multipart-Mixed body contents (MIME content-type multipart/mixed).
Definition at line 19 of file MultipartMixedContents.hxx.
| typedef std::vector<Contents*> resip::MultipartMixedContents::Parts |
Definition at line 39 of file MultipartMixedContents.hxx.
| MultipartMixedContents::MultipartMixedContents | ( | ) |
Definition at line 26 of file MultipartMixedContents.cxx.
References setBoundary().
Referenced by clone().
: Contents(getStaticType()), mContents() { setBoundary(); }

| MultipartMixedContents::MultipartMixedContents | ( | const Mime & | contentType | ) | [explicit] |
Definition at line 33 of file MultipartMixedContents.cxx.
References resip::Mime::exists(), resip::Contents::mType, and setBoundary().
: Contents(contentsType), mContents() { if (!mType.exists(p_boundary)) { setBoundary(); } }

| MultipartMixedContents::MultipartMixedContents | ( | const HeaderFieldValue & | hfv, |
| const Mime & | contentType | ||
| ) |
Definition at line 43 of file MultipartMixedContents.cxx.
References resip::Mime::exists(), resip::Contents::mType, and setBoundary().
: Contents(hfv, contentsType), mContents() { if (!mType.exists(p_boundary)) { setBoundary(); } }

| MultipartMixedContents::MultipartMixedContents | ( | const MultipartMixedContents & | rhs | ) |
Definition at line 53 of file MultipartMixedContents.cxx.
References mContents.
| MultipartMixedContents::~MultipartMixedContents | ( | ) | [virtual] |
Definition at line 93 of file MultipartMixedContents.cxx.
References clear().
{
clear();
}

| void MultipartMixedContents::clear | ( | void | ) | [protected] |
Reimplemented from resip::Contents.
Definition at line 84 of file MultipartMixedContents.cxx.
References mContents.
Referenced by operator=(), and ~MultipartMixedContents().
| Contents * MultipartMixedContents::clone | ( | ) | const [virtual] |
duplicate an MultipartMixedContents object
Implements resip::Contents.
Reimplemented in resip::MultipartSignedContents, resip::MultipartAlternativeContents, and resip::MultipartRelatedContents.
Definition at line 116 of file MultipartMixedContents.cxx.
References MultipartMixedContents().
{
return new MultipartMixedContents(*this);
}

| EncodeStream & MultipartMixedContents::encodeParsed | ( | EncodeStream & | str | ) | const [virtual] |
Implements resip::LazyParser.
Definition at line 129 of file MultipartMixedContents.cxx.
References resip::Symbols::CRLF, CRLF, resip::Symbols::DASHDASH, mContents, resip::Contents::mType, resip::ParserCategory::param(), resip::Data::Preallocate, resip::Data::replace(), and resip::Data::size().
{
const Data& boundaryToken = mType.param(p_boundary);
Data boundary(boundaryToken.size() + 2, Data::Preallocate);
boundary = Symbols::DASHDASH;
boundary += boundaryToken;
boundary.replace("\"", ""); // remove quotes
assert( mContents.size() > 0 );
bool first = true;
for (vector<Contents*>::const_iterator i = mContents.begin();
i != mContents.end(); ++i)
{
if (!first)
{
str << Symbols::CRLF;
}
else
{
first = false;
}
str << boundary << Symbols::CRLF;
(*i)->encodeHeaders(str);
(*i)->encode(str);
}
str << Symbols::CRLF << boundary << Symbols::DASHDASH;
return str;
}

| const Mime & MultipartMixedContents::getStaticType | ( | ) | [static] |
Reimplemented in resip::MultipartSignedContents, resip::MultipartAlternativeContents, and resip::MultipartRelatedContents.
Definition at line 122 of file MultipartMixedContents.cxx.
References type.
| bool MultipartMixedContents::init | ( | ) | [static] |
Reimplemented from resip::Contents.
Reimplemented in resip::MultipartSignedContents, resip::MultipartAlternativeContents, and resip::MultipartRelatedContents.
Definition at line 19 of file MultipartMixedContents.cxx.
{
static ContentsFactory<MultipartMixedContents> factory;
(void)factory;
return true;
}
| MultipartMixedContents & MultipartMixedContents::operator= | ( | const MultipartMixedContents & | rhs | ) |
Definition at line 99 of file MultipartMixedContents.cxx.
References clear(), and mContents.
{
if (this != &rhs)
{
Contents::operator=(rhs);
clear();
for (vector<Contents*>::iterator i = mContents.begin();
i != mContents.end(); ++i)
{
mContents.push_back( (*i)->clone() );
}
}
return *this;
}

| void MultipartMixedContents::parse | ( | ParseBuffer & | pb | ) | [virtual] |
Implements resip::LazyParser.
Definition at line 164 of file MultipartMixedContents.cxx.
References resip::ParseBuffer::assertNotEof(), resip::Symbols::COLON, resip::Symbols::CR, resip::Contents::createContents(), CRLF, resip::Symbols::CRLFCRLF, resip::Symbols::DASHDASH, resip::ParseBuffer::data(), resip::ParseBuffer::eof(), resip::Symbols::LF, mContents, resip::Contents::mType, resip::ParserCategory::param(), resip::Mime::parse(), resip::ParseBuffer::position(), resip::Data::Preallocate, resip::ParseBuffer::reset(), resip::Data::size(), resip::ParseBuffer::skipChar(), resip::ParseBuffer::skipN(), resip::ParseBuffer::skipToChar(), resip::ParseBuffer::skipToChars(), resip::ParseBuffer::skipToTermCRLF(), and resip::ParseBuffer::skipWhitespace().
{
const Data& boundaryToken = mType.param(p_boundary);
Data boundary(boundaryToken.size() + 4, Data::Preallocate);
boundary += Symbols::CRLF;
boundary += Symbols::DASHDASH;
boundary += boundaryToken;
Data boundaryNoCRLF(boundaryToken.size() + 2, Data::Preallocate);
boundaryNoCRLF += Symbols::DASHDASH;
boundaryNoCRLF += boundaryToken;
pb.skipToChars(boundaryNoCRLF);
pb.skipN((int)boundaryNoCRLF.size());
pb.assertNotEof();
do
{
// skip over boundary
if( pb.eof() || *pb.position() != Symbols::CR[0] )
{
throw Exception("Invalid line ending, missing CR",__FILE__,__LINE__);
}
pb.skipChar();
if( pb.eof() || *pb.position() != Symbols::LF[0] )
{
throw Exception("Invalid line ending, missing LF",__FILE__,__LINE__);
}
pb.skipChar();
pb.assertNotEof();
const char* headerStart = pb.position();
// pull out contents type only
pb.skipToChars("Content-Type");
if (pb.eof())
{
pb.reset(headerStart);
pb.skipToChars("CONTENT-TYPE");
}
pb.assertNotEof();
pb.skipToChar(Symbols::COLON[0]);
pb.skipChar();
pb.assertNotEof();
pb.skipWhitespace();
const char* typeStart = pb.position();
pb.assertNotEof();
// determine contents-type header buffer
pb.skipToTermCRLF();
pb.assertNotEof();
ParseBuffer subPb(typeStart, pb.position() - typeStart);
Mime contentType;
contentType.parse(subPb);
pb.assertNotEof();
// determine body start
pb.reset(typeStart);
const char* bodyStart = pb.skipToChars(Symbols::CRLFCRLF);
pb.assertNotEof();
bodyStart += 4;
// determine contents body buffer
pb.skipToChars(boundary);
pb.assertNotEof();
Data tmp;
pb.data(tmp, bodyStart);
// create contents against body
mContents.push_back(createContents(contentType, tmp));
// pre-parse headers
ParseBuffer headersPb(headerStart, bodyStart-4-headerStart);
mContents.back()->preParseHeaders(headersPb);
pb.skipN((int)boundary.size());
const char* loc = pb.position();
pb.skipChar();
pb.skipChar();
Data next;
pb.data(next, loc);
if ( next == Symbols::DASHDASH )
{
break;
}
pb.reset( loc );
}
while ( !pb.eof() );
}

| Parts& resip::MultipartMixedContents::parts | ( | ) | [inline] |
Definition at line 40 of file MultipartMixedContents.hxx.
References resip::LazyParser::checkParsed(), and mContents.
Referenced by extractFromPkcs7Recurse(), findRlmi(), getSdpRecurse(), main(), resip::TuIM::processMessageRequest(), resip::TuIM::processSipFrag(), and traverseMulti().
{checkParsed(); return mContents;}

| const Parts& resip::MultipartMixedContents::parts | ( | ) | const [inline] |
Definition at line 41 of file MultipartMixedContents.hxx.
References resip::LazyParser::checkParsed(), and mContents.
{checkParsed(); return mContents;}

| void MultipartMixedContents::setBoundary | ( | const Data & | boundary | ) |
Definition at line 78 of file MultipartMixedContents.cxx.
References resip::Contents::mType, and resip::ParserCategory::param().

| void MultipartMixedContents::setBoundary | ( | ) | [private] |
Definition at line 71 of file MultipartMixedContents.cxx.
References resip::Random::getRandomHex(), resip::Contents::mType, and resip::ParserCategory::param().
Referenced by MultipartMixedContents().
{
Data boundaryToken = Random::getRandomHex(8);
mType.param(p_boundary) = boundaryToken;
}

std::vector<Contents*> resip::MultipartMixedContents::mContents [private] |
Definition at line 65 of file MultipartMixedContents.hxx.
Referenced by clear(), encodeParsed(), MultipartMixedContents(), operator=(), parse(), and parts().
1.7.5.1