14#include "jinglefiletransfer.h"
28 static const char* typeValues [] = {
47 std::string name =
tag->name();
48 if( name ==
"description" )
50 const Tag* c = tag->findTag(
"description/offer|description/request" );
53 parseFileList( c->findChildren(
"file" ) );
57 else if( name ==
"checksum" || name ==
"abort" || name ==
"received" )
59 parseFileList( tag->findChildren(
"file" ) );
62 m_type =
static_cast<Type
>( util::lookup( name, typeValues ) );
65 void FileTransfer::parseFileList(
const TagList& files )
67 TagList::const_iterator it = files.begin();
68 for( ; it != files.end(); ++it )
71 Tag *t = (*it)->findChild(
"name" );
73 t = (*it)->findChild(
"desc" );
75 t = (*it)->findChild(
"date" );
77 t = (*it)->findChild(
"size" );
78 f.size = t ? atoi( t->cdata().c_str() ) : -1;
79 t = (*it)->findChild(
"range" );
83 f.offset = t->hasAttribute(
"offset" ) ? atoi( t->findAttribute(
"offset" ).c_str() ) : -1;
88 f.hash_algo = t->findAttribute(
"algo" );
91 m_files.push_back( f );
129 Tag* o =
new Tag( r, util::lookup( m_type, typeValues ) );
130 FileList::const_iterator it = m_files.begin();
131 for( ; it != m_files.end(); ++it )
133 Tag* f =
new Tag( o,
"file" );
134 new Tag( f,
"date", (*it).date );
135 new Tag( f,
"name", (*it).
name );
136 new Tag( f,
"desc", (*it).desc );
137 new Tag( f,
"size", util::long2string( (*it).size ) );
142 new Tag( f,
"range",
"offset", (*it).offset ? util::long2string( (*it).offset ) :
EmptyString );
151 FileList::const_iterator it = m_files.begin();
152 Tag* f =
new Tag( r,
"file" );
153 new Tag( f,
"date", (*it).date );
154 new Tag( f,
"name", (*it).
name );
155 new Tag( f,
"desc", (*it).desc );
156 new Tag( f,
"size", util::long2string( (*it).size ) );
161 new Tag( f,
"range" );
std::list< File > FileList
FileTransfer(Type type, const FileList &files)
virtual Plugin * newInstance(const Tag *tag) const
virtual const StringList features() const
virtual const std::string & filterString() const
const FileList & files() const
virtual Tag * tag() const
Plugin(JinglePluginType type)
This is an abstraction of an XML element.
const std::string & name() const
bool setCData(const std::string &cdata)
bool addAttribute(Attribute *attr)
The namespace containing Jingle-related (XEP-0166 et. al.) classes.
The namespace for the gloox library.
std::list< Tag * > TagList
std::list< std::string > StringList
const std::string EmptyString
const std::string XMLNS_HASHES
const std::string XMLNS_JINGLE_FILE_TRANSFER