gloox  1.0.27
softwareversion.cpp
1 /*
2  Copyright (c) 2008-2023 by Jakob Schröter <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 
15 #include "softwareversion.h"
16 #include "tag.h"
17 
18 namespace gloox
19 {
20 
21  SoftwareVersion::SoftwareVersion( const std::string& name,
22  const std::string& version,
23  const std::string& os )
24  : StanzaExtension( ExtVersion ), m_name( name ), m_version( version ), m_os( os )
25  {
26  }
27 
30  {
31  if( !tag )
32  return;
33 
34  Tag* t = tag->findChild( "name" );
35  if( t )
36  m_name = t->cdata();
37 
38  t = tag->findChild( "version" );
39  if( t )
40  m_version = t->cdata();
41 
42  t = tag->findChild( "os" );
43  if( t )
44  m_os = t->cdata();
45  }
46 
48  {
49  }
50 
51  const std::string& SoftwareVersion::filterString() const
52  {
53  static const std::string filter = "/iq/query[@xmlns='" + XMLNS_VERSION + "']";
54  return filter;
55  }
56 
58  {
59  Tag* t = new Tag( "query" );
60  t->setXmlns( XMLNS_VERSION );
61 
62  if( !m_name.empty() )
63  new Tag( t, "name", m_name );
64 
65  if( !m_version.empty() )
66  new Tag( t, "version", m_version );
67 
68  if( !m_os.empty() )
69  new Tag( t, "os", m_os );
70 
71  return t;
72  }
73 
74 }
virtual const std::string & filterString() const
SoftwareVersion(const std::string &name, const std::string &version, const std::string &os)
virtual Tag * tag() const
This class abstracts a stanza extension, which is usually an XML child element in a specific namespac...
This is an abstraction of an XML element.
Definition: tag.h:47
Tag * findChild(const std::string &name) const
Definition: tag.cpp:624
const std::string cdata() const
Definition: tag.cpp:497
bool setXmlns(const std::string &xmlns, const std::string &prefix=EmptyString)
Definition: tag.cpp:522
The namespace for the gloox library.
Definition: adhoc.cpp:28
const std::string XMLNS_VERSION
Definition: gloox.cpp:39