reSIProcate/stack  9694
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | Private Attributes
resip::Pidf Class Reference

Deprecated. More...

#include <Pidf.hxx>

Inheritance diagram for resip::Pidf:
Inheritance graph
[legend]
Collaboration diagram for resip::Pidf:
Collaboration graph
[legend]

List of all members.

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 ()
Pidfoperator= (const Pidf &rhs)
virtual Contentsclone () const
 duplicate an Pidf object
virtual EncodeStreamencodeParsed (EncodeStream &str) const
virtual void parse (ParseBuffer &pb)
void setSimpleId (const Data &id)
void setEntity (const Uri &entity)
const UrigetEntity () const
void setSimpleStatus (bool online, const Data &note=Data::Empty, const Data &contact=Data::Empty)
bool getSimpleStatus (Data *note=NULL) const
Datatext ()
std::vector< Tuple > & getTuples ()
const std::vector< Tuple > & getTuples () const
int getNumTuples () const
void merge (const Pidf &other)

Static Public Member Functions

static const MimegetStaticType ()
static bool init ()

Static Public Attributes

static const Pidf Empty

Private Attributes

Data mNote
Uri mEntity
std::vector< TuplemTuples

Detailed Description

Deprecated.

Deprecated:

SIP body type for holding PIDF contents (MIME content-type application/pidf+xml).

Definition at line 22 of file Pidf.hxx.


Constructor & Destructor Documentation

Pidf::Pidf ( const Mime contentType)

Definition at line 40 of file Pidf.cxx.

Pidf::Pidf ( const Uri entity) [explicit]

Definition at line 79 of file Pidf.cxx.

   : Contents(getStaticType()),
     mEntity(entity)
{
}
Pidf::Pidf ( )

Definition at line 28 of file Pidf.cxx.

Referenced by clone().

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 
)

Definition at line 46 of file Pidf.cxx.

   : Contents(hfv, contentsType),
     mNote()
{
}
Pidf::Pidf ( const Data txt,
const Mime contentType 
)

Definition at line 52 of file Pidf.cxx.

   : Contents(contentType),
     mNote(txt)
{
}
Pidf::Pidf ( const Pidf rhs)

Definition at line 71 of file Pidf.cxx.

   : Contents(rhs),
     mNote(rhs.mNote),
     mEntity(rhs.mEntity),
     mTuples(rhs.mTuples)
{
}
Pidf::~Pidf ( ) [virtual]

Definition at line 85 of file Pidf.cxx.

{
}

Member Function Documentation

Contents * Pidf::clone ( ) const [virtual]

duplicate an Pidf object

Returns:
pointer to a new Pidf object

Implements resip::Contents.

Definition at line 125 of file Pidf.cxx.

References Pidf().

{
   return new Pidf(*this);
}

Here is the call graph for this function:

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;
}

Here is the call graph for this function:

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; 
};

Here is the call graph for this function:

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();
}

Here is the call graph for this function:

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;
}

Here is the call graph for this function:

const Mime & Pidf::getStaticType ( ) [static]

Definition at line 131 of file Pidf.cxx.

References type.

{
   static Mime type("application","pidf+xml");
   return type;
}
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;
}

Here is the call graph for this function:

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;
}

Here is the call graph for this function:

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);
      }
   }
}

Here is the call graph for this function:

Pidf & Pidf::operator= ( const Pidf rhs)

Definition at line 59 of file Pidf.cxx.

References mEntity, mNote, and mTuples.

{
   if (this != &rhs)
   {
      Contents::operator=(rhs);
      mNote = rhs.mNote;
      mEntity = rhs.mEntity;
      mTuples = rhs.mTuples;
   }
   return *this;
}
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
}

Here is the call graph for this function:

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;
}

Here is the call graph for this function:

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;
}

Here is the call graph for this function:

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;
}

Here is the call graph for this function:

Data& resip::Pidf::text ( ) [inline]

Definition at line 57 of file Pidf.hxx.

References resip::LazyParser::checkParsed(), and mNote.

{checkParsed(); return mNote;}

Here is the call graph for this function:


Member Data Documentation

const Pidf Pidf::Empty [static]

Definition at line 25 of file Pidf.hxx.

Referenced by setSimpleStatus().

Definition at line 89 of file Pidf.hxx.

Referenced by encodeParsed(), getEntity(), merge(), operator=(), parse(), and setEntity().

Definition at line 87 of file Pidf.hxx.

Referenced by operator=(), parse(), and text().

std::vector<Tuple> resip::Pidf::mTuples [private]

The documentation for this class was generated from the following files: