gloox  1.0.1
nickname.cpp
1 /*
2  Copyright (c) 2007-2012 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 #include "nickname.h"
14 #include "tag.h"
15 
16 namespace gloox
17 {
18 
19  Nickname::Nickname( const Tag* tag )
21  {
22  if( tag )
23  m_nick = tag->cdata();
24  }
25 
26  const std::string& Nickname::filterString() const
27  {
28  static const std::string filter =
29  "/presence/nick[@xmlns='" + XMLNS_NICKNAME + "']"
30  "|/message/nick[@xmlns='" + XMLNS_NICKNAME + "']";
31  return filter;
32  }
33 
34  Tag* Nickname::tag() const
35  {
36  if( m_nick.empty() )
37  return 0;
38 
39  Tag* n = new Tag( "nick", XMLNS, XMLNS_NICKNAME );
40  n->setCData( m_nick );
41  return n;
42  }
43 
44 }