14 #include "jinglefiletransfer.h"
28 static const char* typeValues [] = {
37 : m_type( type ), m_files( files )
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" );