gloox 1.0

nickname.cpp

00001 /*
00002   Copyright (c) 2007-2009 by Jakob Schroeter <js@camaya.net>
00003   This file is part of the gloox library. http://camaya.net/gloox
00004 
00005   This software is distributed under a license. The full license
00006   agreement can be found in the file LICENSE in this distribution.
00007   This software may not be copied, modified, sold or distributed
00008   other than expressed in the named license agreement.
00009 
00010   This software is distributed without any warranty.
00011 */
00012 
00013 #include "nickname.h"
00014 #include "tag.h"
00015 
00016 namespace gloox
00017 {
00018 
00019   Nickname::Nickname( const Tag* tag )
00020     : StanzaExtension( ExtNickname )
00021   {
00022     if( tag )
00023       m_nick = tag->cdata();
00024   }
00025 
00026   const std::string& Nickname::filterString() const
00027   {
00028     static const std::string filter =
00029            "/presence/nick[@xmlns='" + XMLNS_NICKNAME + "']"
00030            "|/message/nick[@xmlns='" + XMLNS_NICKNAME + "']";
00031     return filter;
00032   }
00033 
00034   Tag* Nickname::tag() const
00035   {
00036     if( m_nick.empty() )
00037       return 0;
00038 
00039     Tag* n = new Tag( "nick", XMLNS, XMLNS_NICKNAME );
00040     n->setCData( m_nick );
00041     return n;
00042   }
00043 
00044 }