00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "annotations.h"
00016 #include "clientbase.h"
00017
00018
00019 namespace gloox
00020 {
00021
00022 Annotations::Annotations( ClientBase* parent )
00023 : PrivateXML( parent ),
00024 m_annotationsHandler( 0 )
00025 {
00026 }
00027
00028 Annotations::~Annotations()
00029 {
00030 }
00031
00032 void Annotations::storeAnnotations( const AnnotationsList& aList )
00033 {
00034 Tag* s = new Tag( "storage", XMLNS, XMLNS_ANNOTATIONS );
00035
00036 AnnotationsList::const_iterator it = aList.begin();
00037 for( ; it != aList.end(); ++it )
00038 {
00039 Tag* n = new Tag( s, "note", (*it).note );
00040 n->addAttribute( "jid", (*it).jid );
00041 n->addAttribute( "cdate", (*it).cdate );
00042 n->addAttribute( "mdate", (*it).mdate );
00043 }
00044
00045 storeXML( s, this );
00046 }
00047
00048 void Annotations::requestAnnotations()
00049 {
00050 requestXML( "storage", XMLNS_ANNOTATIONS, this );
00051 }
00052
00053 void Annotations::handlePrivateXML( const Tag* xml )
00054 {
00055 AnnotationsList aList;
00056 const TagList& l = xml->children();
00057 TagList::const_iterator it = l.begin();
00058 for( ; it != l.end(); ++it )
00059 {
00060 if( (*it)->name() == "note" )
00061 {
00062 const std::string& jid = (*it)->findAttribute( "jid" );
00063 const std::string& note = (*it)->cdata();
00064
00065 if( !jid.empty() && !note.empty() )
00066 {
00067 const std::string& cdate = (*it)->findAttribute( "cdate" );
00068 const std::string& mdate = (*it)->findAttribute( "mdate" );
00069 AnnotationsListItem item;
00070 item.jid = jid;
00071 item.cdate = cdate;
00072 item.mdate = mdate;
00073 item.note = note;
00074 aList.push_back( item );
00075 }
00076 }
00077 }
00078
00079 if( m_annotationsHandler )
00080 m_annotationsHandler->handleAnnotations( aList );
00081 }
00082
00083 void Annotations::handlePrivateXMLResult( const std::string& , PrivateXMLResult )
00084 {
00085 }
00086
00087 }