Exemple #1
0
void Annotations::handlePrivateXML( const Tag* xml )
{
    if( !xml )
        return;

    AnnotationsList aList;
    const TagList& l = xml->children();
    TagList::const_iterator it = l.begin();
    for( ; it != l.end(); ++it )
    {
        if( (*it)->name() == "note" )
        {
            const std::string& jid = (*it)->findAttribute( "jid" );
            const std::string& note = (*it)->cdata();

            if( !jid.empty() && !note.empty() )
            {
                const std::string& cdate = (*it)->findAttribute( "cdate" );
                const std::string& mdate = (*it)->findAttribute( "mdate" );
                AnnotationsListItem item;
                item.jid = jid;
                item.cdate = cdate;
                item.mdate = mdate;
                item.note = note;
                aList.push_back( item );
            }
        }
    }

    if( m_annotationsHandler )
        m_annotationsHandler->handleAnnotations( aList );
}
    virtual void handleAnnotations( const AnnotationsList &aList )
    {
      printf( "received notes...\n" );
      AnnotationsList::const_iterator it = aList.begin();
      for( ; it != aList.end(); it++ )
      {
        printf( "jid: %s, note: %s, cdate: %s, mdate: %s\n", (*it).jid.c_str(),
                (*it).note.c_str(), (*it).cdate.c_str(), (*it).mdate.c_str() );
      }

      AnnotationsList mybList;

      AnnotationsListItem bItem;
      bItem.jid = "*****@*****.**";
      bItem.note = "my lover & friend. 2 > 3";
      mybList.push_back( bItem );

      bItem.jid = "*****@*****.**";
      bItem.note = "oh my sweetest love...";
      bItem.cdate = "20040924T15:23:21";
      bItem.mdate = "20040924T15:23:21";
      mybList.push_back( bItem );

      a->storeAnnotations( mybList );
    }
Exemple #3
0
void Annotations::storeAnnotations( const AnnotationsList& aList )
{
    Tag* s = new Tag( "storage", XMLNS, XMLNS_ANNOTATIONS );

    AnnotationsList::const_iterator it = aList.begin();
    for( ; it != aList.end(); ++it )
    {
        Tag* n = new Tag( s, "note", (*it).note );
        n->addAttribute( "jid", (*it).jid );
        n->addAttribute( "cdate", (*it).cdate );
        n->addAttribute( "mdate", (*it).mdate );
    }

    storeXML( s, this );
}