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" );
57 else if( name ==
"checksum" || name ==
"abort" || name ==
"received" )
62 m_type = (
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 )
78 f.size = t ? atoi( t->
cdata().c_str() ) : -1;
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" );
An abstraction of a Jingle plugin. This is part of Jingle (XEP-0166 et al.)
const std::string XMLNS_HASHES
std::list< std::string > StringList
virtual Plugin * newInstance(const Tag *tag) const
std::list< Tag * > TagList
virtual const StringList features() const
bool setCData(const std::string &cdata)
const Tag * findTag(const std::string &expression) const
virtual const std::string & filterString() const
FileTransfer(Type type, const FileList &files)
std::list< File > FileList
The namespace for the gloox library.
const std::string & xmlns() const
bool hasAttribute(const std::string &name, const std::string &value=EmptyString) const
const std::string cdata() const
virtual Tag * tag() const
bool addAttribute(Attribute *attr)
const std::string XMLNS_JINGLE_FILE_TRANSFER
const std::string & name() const
TagList findChildren(const std::string &name, const std::string &xmlns=EmptyString) const
Tag * findChild(const std::string &name) const
const std::string EmptyString
This is an abstraction of an XML element.