|
reSIProcate/stack
9694
|
Deprecated. More...
#include <Pidf.hxx>


Classes | |
| class | Tuple |
| Deprecated. More... | |
Public Member Functions | |
| RESIP_HeapCount (Pidf) | |
| Pidf (const Mime &contentType) | |
| Pidf (const Uri &entity) | |
| Pidf () | |
| Pidf (const Data &txt) | |
| Pidf (const HeaderFieldValue &hfv, const Mime &contentType) | |
| Pidf (const Data &txt, const Mime &contentType) | |
| Pidf (const Pidf &rhs) | |
| virtual | ~Pidf () |
| Pidf & | operator= (const Pidf &rhs) |
| virtual Contents * | clone () const |
| duplicate an Pidf object | |
| virtual EncodeStream & | encodeParsed (EncodeStream &str) const |
| virtual void | parse (ParseBuffer &pb) |
| void | setSimpleId (const Data &id) |
| void | setEntity (const Uri &entity) |
| const Uri & | getEntity () const |
| void | setSimpleStatus (bool online, const Data ¬e=Data::Empty, const Data &contact=Data::Empty) |
| bool | getSimpleStatus (Data *note=NULL) const |
| Data & | text () |
| std::vector< Tuple > & | getTuples () |
| const std::vector< Tuple > & | getTuples () const |
| int | getNumTuples () const |
| void | merge (const Pidf &other) |
Static Public Member Functions | |
| static const Mime & | getStaticType () |
| static bool | init () |
Static Public Attributes | |
| static const Pidf | Empty |
Private Attributes | |
| Data | mNote |
| Uri | mEntity |
| std::vector< Tuple > | mTuples |
Deprecated.
SIP body type for holding PIDF contents (MIME content-type application/pidf+xml).
| Pidf::Pidf | ( | const Mime & | contentType | ) |
Definition at line 40 of file Pidf.cxx.
: Contents(getStaticType()), mNote() { }
| Pidf::Pidf | ( | const Uri & | entity | ) | [explicit] |
Definition at line 79 of file Pidf.cxx.
: Contents(getStaticType()), mEntity(entity) { }
| Pidf::Pidf | ( | ) |
| Pidf::Pidf | ( | const Data & | txt | ) |
Definition at line 34 of file Pidf.cxx.
: Contents(getStaticType()), mNote(txt) { }
| Pidf::Pidf | ( | const HeaderFieldValue & | hfv, |
| const Mime & | contentType | ||
| ) |
| Pidf::Pidf | ( | const Pidf & | rhs | ) |
| Contents * Pidf::clone | ( | ) | const [virtual] |
| EncodeStream & Pidf::encodeParsed | ( | EncodeStream & | str | ) | const [virtual] |
Implements resip::LazyParser.
Definition at line 138 of file Pidf.cxx.
References CRLF, resip::LazyParser::encode(), mEntity, and mTuples.
Referenced by main().
{
str << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << Symbols::CRLF;
str << "<presence xmlns=\"urn:ietf:params:xml:ns:pidf\"" << Symbols::CRLF;
str << " entity=\"" << mEntity << "\">" << Symbols::CRLF;
for (vector<Tuple>::const_iterator i = mTuples.begin(); i != mTuples.end(); ++i)
{
Data status( (char*)( (i->status) ? "open" : "closed" ) );
str << " <tuple id=\"" << i->id << "\" ";
XMLCursor::encode(str, i->attributes);
str << ">" << Symbols::CRLF;
str << " <status><basic>" << status << "</basic></status>" << Symbols::CRLF;
if ( !i->contact.empty() )
{
str << " <contact priority=\"" << i->contactPriority << "\">" << i->contact << "</contact>" << Symbols::CRLF;
}
if ( !i->timeStamp.empty() )
{
str << " <timestamp>" << i->timeStamp << "</timestamp>" << Symbols::CRLF;
}
if ( !i->note.empty() )
{
str << " <note>" << i->note << "</note>" << Symbols::CRLF;
}
str << " </tuple>" << Symbols::CRLF;
}
str << "</presence>" << Symbols::CRLF;
return str;
}

| const Uri & Pidf::getEntity | ( | ) | const |
Definition at line 97 of file Pidf.cxx.
References resip::LazyParser::checkParsed(), and mEntity.
Referenced by main().
{
checkParsed();
return mEntity;
};

| int Pidf::getNumTuples | ( | ) | const |
Definition at line 118 of file Pidf.cxx.
References resip::LazyParser::checkParsed(), and mTuples.
Referenced by main().
{
checkParsed();
return (int)mTuples.size();
}

| bool Pidf::getSimpleStatus | ( | Data * | note = NULL | ) | const |
Definition at line 344 of file Pidf.cxx.
References resip::LazyParser::checkParsed(), and mTuples.
{
checkParsed();
if (!mTuples.empty())
{
if (note)
{
*note = mTuples[0].note;
}
return mTuples[0].status;
}
return false;
}

| const Mime & Pidf::getStaticType | ( | ) | [static] |
| std::vector< Pidf::Tuple > & Pidf::getTuples | ( | ) |
Definition at line 104 of file Pidf.cxx.
References resip::LazyParser::checkParsed(), and mTuples.
Referenced by main(), and merge().
{
checkParsed();
return mTuples;
}

| const std::vector< Pidf::Tuple > & Pidf::getTuples | ( | ) | const |
Definition at line 111 of file Pidf.cxx.
References resip::LazyParser::checkParsed(), and mTuples.
{
checkParsed();
return mTuples;
}

| bool Pidf::init | ( | ) | [static] |
Reimplemented from resip::Contents.
Definition at line 19 of file Pidf.cxx.
{
static ContentsFactory<Pidf> factory;
(void)factory;
return true;
}
| void Pidf::merge | ( | const Pidf & | other | ) |
Definition at line 361 of file Pidf.cxx.
References getTuples(), mEntity, and setEntity().
Referenced by main().
{
vector<Tuple>& tuples = getTuples();
tuples.reserve(tuples.size() + other.getTuples().size());
setEntity(other.mEntity);
for (vector<Tuple>::const_iterator i = other.getTuples().begin();
i != other.getTuples().end(); ++i)
{
bool found = false;
for (vector<Tuple>::iterator j = getTuples().begin();
j != getTuples().end(); ++j)
{
if (i->id == j->id)
{
found = true;
*j = *i;
break;
}
}
if (!found)
{
tuples.push_back(*i);
}
}
}

| void Pidf::parse | ( | ParseBuffer & | pb | ) | [virtual] |
Implements resip::LazyParser.
Definition at line 171 of file Pidf.cxx.
References resip::Pidf::Tuple::attributes, resip::Data::c_str(), resip::Pidf::Tuple::contact, resip::Pidf::Tuple::contactPriority, resip::ParseBuffer::data(), DebugLog, resip::ParseBuffer::end(), resip::XMLCursor::firstChild(), resip::XMLCursor::getAttributes(), resip::XMLCursor::getTag(), resip::XMLCursor::getValue(), resip::Pidf::Tuple::id, mEntity, mNote, mTuples, resip::XMLCursor::nextSibling(), resip::Pidf::Tuple::note, resip::XMLCursor::parent(), resip::QValue::setValue(), resip::ParseBuffer::skipToEnd(), resip::ParseBuffer::start(), resip::Pidf::Tuple::status, and resip::Pidf::Tuple::timeStamp.
{
/*
REVISIT WHY THE BELOW WAS REMOVED
REMOVING IT SCREWS UP WHAT GOES OUT IN THE PUBLISH
*/
DebugLog(<< "Pidf::parse(" << Data(pb.start(), int(pb.end()-pb.start())) << ") ");
std::string pidf_namespace;
XMLCursor xml(pb);
XMLCursor::AttributeMap attr = xml.getAttributes();
XMLCursor::AttributeMap::const_iterator it =
std::find_if(attr.begin(), attr.end(), XMLCursor::AttributeValueEqual("urn:ietf:params:xml:ns:pidf"));
if ( it != attr.end() ) {
std::string key(it->first.data(), it->first.size());
size_t pos = key.find(':');
if ( pos != string::npos) {
pidf_namespace.assign(key, pos+1, key.size()-pos-1);
pidf_namespace.append(1, ':');
}
}
const std::string presence = pidf_namespace + "presence";
if (xml.getTag() == presence.c_str())
{
XMLCursor::AttributeMap::const_iterator i = xml.getAttributes().find("entity");
if (i != xml.getAttributes().end())
{
mEntity = Uri(i->second);
}
else
{
DebugLog(<< "no entity!");
}
if (xml.firstChild())
{
do
{
const std::string tuple = pidf_namespace + "tuple";
if (xml.getTag() == tuple.c_str())
{
Tuple t;
t.attributes = xml.getAttributes();
XMLCursor::AttributeMap::const_iterator i = xml.getAttributes().find("id");
if (i != xml.getAttributes().end())
{
t.id = i->second;
t.attributes.erase("id");
}
// look for status, contacts, notes -- take last of each for now
if (xml.firstChild())
{
do
{
const std::string status = pidf_namespace + "status";
const std::string contact = pidf_namespace + "contact";
const std::string note = pidf_namespace + "note";
const std::string timestamp = pidf_namespace + "timestamp";
if (xml.getTag() == status.c_str())
{
// look for basic
if (xml.firstChild())
{
do
{
std::string basic = pidf_namespace + "basic";
if (xml.getTag() == basic.c_str())
{
if (xml.firstChild())
{
t.status = (xml.getValue() == "open");
xml.parent();
}
}
} while (xml.nextSibling());
xml.parent();
}
}
else if (xml.getTag() == contact.c_str())
{
XMLCursor::AttributeMap::const_iterator i = xml.getAttributes().find("priority");
if (i != xml.getAttributes().end())
{
t.contactPriority.setValue(i->second);
}
if (xml.firstChild())
{
t.contact = xml.getValue();
xml.parent();
}
}
else if (xml.getTag() == note.c_str())
{
if (xml.firstChild())
{
t.note = xml.getValue();
xml.parent();
}
}
else if (xml.getTag() == timestamp.c_str())
{
if (xml.firstChild())
{
t.timeStamp = xml.getValue();
xml.parent();
}
}
} while (xml.nextSibling());
xml.parent();
}
mTuples.push_back(t);
}
} while (xml.nextSibling());
xml.parent();
}
}
else
{
DebugLog(<< "no presence tag!");
}
/*
REVISIT WHY THE ABOVE WAS REMOVED
*/
// THIS HERE IS THE ESSENCE OF WHAT IS USED.
// const char* anchor = pb.position();
const char* anchor = pb.start();
pb.skipToEnd();
pb.data(mNote, anchor);
DebugLog(<< "mNote is : " << mNote );
// END OF - ESSENCE
}

| resip::Pidf::RESIP_HeapCount | ( | Pidf | ) |
| void Pidf::setEntity | ( | const Uri & | entity | ) |
Definition at line 90 of file Pidf.cxx.
References resip::LazyParser::checkParsed(), and mEntity.
Referenced by main(), merge(), and resip::TuIM::TuIM().
{
checkParsed();
mEntity = entity;
}

| void Pidf::setSimpleId | ( | const Data & | id | ) |
Definition at line 315 of file Pidf.cxx.
References resip::LazyParser::checkParsed(), and mTuples.
Referenced by resip::TuIM::TuIM().
{
checkParsed();
if (mTuples.empty())
{
Tuple t;
mTuples.push_back(t);
}
mTuples[0].id = id;
}

| void Pidf::setSimpleStatus | ( | bool | online, |
| const Data & | note = Data::Empty, |
||
| const Data & | contact = Data::Empty |
||
| ) |
Definition at line 327 of file Pidf.cxx.
References resip::LazyParser::checkParsed(), Empty, and mTuples.
Referenced by resip::TuIM::setMyPresence(), and resip::TuIM::TuIM().
{
checkParsed();
if (mTuples.empty())
{
Tuple t;
mTuples.push_back(t);
}
mTuples[0].status = online;
mTuples[0].contact = contact;
mTuples[0].contactPriority = 1000; // 1.0
mTuples[0].note = note;
mTuples[0].timeStamp = Data::Empty;
}

| Data& resip::Pidf::text | ( | ) | [inline] |
Definition at line 57 of file Pidf.hxx.
References resip::LazyParser::checkParsed(), and mNote.
{checkParsed(); return mNote;}

const Pidf Pidf::Empty [static] |
Definition at line 25 of file Pidf.hxx.
Referenced by setSimpleStatus().
Uri resip::Pidf::mEntity [private] |
Definition at line 89 of file Pidf.hxx.
Referenced by encodeParsed(), getEntity(), merge(), operator=(), parse(), and setEntity().
Data resip::Pidf::mNote [private] |
Definition at line 87 of file Pidf.hxx.
Referenced by operator=(), parse(), and text().
std::vector<Tuple> resip::Pidf::mTuples [private] |
Definition at line 90 of file Pidf.hxx.
Referenced by encodeParsed(), getNumTuples(), getSimpleStatus(), getTuples(), operator=(), parse(), setSimpleId(), and setSimpleStatus().
1.7.5.1