gloox 1.0
|
00001 /* 00002 Copyright (c) 2006-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 00014 #include "gpgencrypted.h" 00015 #include "tag.h" 00016 00017 namespace gloox 00018 { 00019 00020 GPGEncrypted::GPGEncrypted( const std::string& encrypted ) 00021 : StanzaExtension( ExtGPGEncrypted ), 00022 m_encrypted( encrypted ), m_valid( true ) 00023 { 00024 if( m_encrypted.empty() ) 00025 m_valid = false; 00026 } 00027 00028 GPGEncrypted::GPGEncrypted( const Tag* tag ) 00029 : StanzaExtension( ExtGPGEncrypted ), 00030 m_valid( false ) 00031 { 00032 if( tag && tag->name() == "x" && tag->hasAttribute( XMLNS, XMLNS_X_GPGENCRYPTED ) ) 00033 { 00034 m_valid = true; 00035 m_encrypted = tag->cdata(); 00036 } 00037 } 00038 00039 GPGEncrypted::~GPGEncrypted() 00040 { 00041 } 00042 00043 const std::string& GPGEncrypted::filterString() const 00044 { 00045 static const std::string filter = "/message/x[@xmlns='" + XMLNS_X_GPGENCRYPTED + "']"; 00046 return filter; 00047 } 00048 00049 Tag* GPGEncrypted::tag() const 00050 { 00051 if( !m_valid ) 00052 return 0; 00053 00054 Tag* x = new Tag( "x", m_encrypted ); 00055 x->addAttribute( XMLNS, XMLNS_X_GPGENCRYPTED ); 00056 00057 return x; 00058 } 00059 00060 }