gloox  1.1-svn
jinglecontent.cpp
1 /*
2  Copyright (c) 2008-2009 by Jakob Schroeter <js@camaya.net>
3  This file is part of the gloox library. http://camaya.net/gloox
4 
5  This software is distributed under a license. The full license
6  agreement can be found in the file LICENSE in this distribution.
7  This software may not be copied, modified, sold or distributed
8  other than expressed in the named license agreement.
9 
10  This software is distributed without any warranty.
11 */
12 
13 
14 #include "jinglecontent.h"
15 #include "jingledescription.h"
16 #include "jingletransport.h"
17 #include "util.h"
18 
19 namespace gloox
20 {
21 
22  namespace Jingle
23  {
24 
25  static const char* creatorValues [] = {
26  "initiator",
27  "responder"
28  };
29 
30  static inline Content::Creator creatorType( const std::string& type )
31  {
32  return (Content::Creator)util::lookup( type, creatorValues );
33  }
34 
35  static const char* sendersValues [] = {
36  "initiator",
37  "responder",
38  "both"
39  };
40 
41  static inline Content::Senders sendersType( const std::string& type )
42  {
43  return (Content::Senders)util::lookup( type, sendersValues );
44  }
45 
47  const std::string& name, Creator creator,
48  Senders senders, const std::string& disposition )
49  : m_description( desc ), m_transport( trans ),
50  m_creator( creator ), m_disposition( disposition ), m_name( name ), m_senders( senders )
51  {
52  }
53 
54  Content::Content( const Tag* tag )
55  {
56 
57  }
58 
60  {
61  }
62 
63  const std::string& Content::filterString() const
64  {
65  static const std::string filter = "content";
66  return filter;
67  }
68 
69  Tag* Content::tag() const
70  {
71  if( m_creator == InvalidCreator || m_name.empty() )
72  return 0;
73 
74  Tag* t = new Tag( "content" );
75  t->addAttribute( "creator", util::lookup( m_creator, creatorValues ) );
76  t->addAttribute( "disposition", m_disposition );
77  t->addAttribute( "name", m_name );
78  t->addAttribute( "senders", util::lookup( m_senders, sendersValues ) );
79 
80  if( m_description )
81  t->addChild( m_description->tag() );
82  if( m_transport )
83  t->addChild( m_transport->tag() );
84 
85  return t;
86  }
87 
89  {
90  return 0;
91  }
92 
93  }
94 
95 }