gloox 1.0
|
00001 /* 00002 Copyright (c) 2005-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 #ifndef STANZA_H__ 00015 #define STANZA_H__ 00016 00017 #include "gloox.h" 00018 #include "tag.h" 00019 #include "jid.h" 00020 #include "stanzaextension.h" 00021 00022 namespace gloox 00023 { 00024 00025 class Error; 00026 00033 class GLOOX_API Stanza 00034 { 00035 public: 00039 virtual ~Stanza(); 00040 00045 void setFrom( const JID& from ) { m_from = from; } 00046 00051 const JID& from() const { return m_from; } 00052 00057 const JID& to() const { return m_to; } 00058 00063 const std::string& id() const { return m_id; } 00064 00069 const Error* error() const; 00070 00076 const std::string& xmlLang() const { return m_xmllang; } 00077 00085 void addExtension( const StanzaExtension* se ); 00086 00092 const StanzaExtension* findExtension( int type ) const; 00093 00103 template< class T > 00104 inline const T* findExtension( int type ) const 00105 { 00106 return static_cast<const T*>( findExtension( type ) ); 00107 } 00108 00113 const StanzaExtensionList& extensions() const { return m_extensionList; } 00114 00118 void removeExtensions(); 00119 00127 virtual Tag* tag() const = 0; 00128 00129 protected: 00135 Stanza( Tag* tag ); 00136 00142 Stanza( const JID& to ); 00143 00144 StanzaExtensionList m_extensionList; 00145 std::string m_id; 00146 std::string m_xmllang; 00147 JID m_from; 00148 JID m_to; 00149 00150 static const std::string& findLang( const StringMap* map, 00151 const std::string& defaultData, 00152 const std::string& lang ); 00153 00154 static void setLang( StringMap** map, 00155 std::string& defaultLang, 00156 const Tag* tag ); 00157 00158 static void setLang( StringMap** map, 00159 std::string& defaultLang, 00160 const std::string& data, 00161 const std::string& xmllang ); 00162 00163 static void getLangs( const StringMap* map, 00164 const std::string& defaultData, 00165 const std::string& name, Tag* tag ); 00166 00167 private: 00168 Stanza( const Stanza& ); 00169 00170 }; 00171 00172 } 00173 00174 #endif // STANZA_H__