00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
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
00021 namespace gloox
00022 {
00023
00032 class GLOOX_API Stanza : public Tag
00033 {
00034 public:
00035
00044 Stanza( const Tag *tag );
00045
00052 Stanza( const std::string& name, const std::string& cdata = "",
00053 const std::string& xmllang = "default", bool incoming = false );
00054
00058 virtual ~Stanza() {};
00059
00064 virtual StanzaSubType subtype() const { return m_subtype; };
00065
00070 virtual const JID& from() const { return m_from; };
00071
00076 virtual const JID& to() const { return m_to; };
00077
00082 virtual const std::string id() const { return m_id; };
00083
00088 virtual const std::string& xmlns() const { return m_xmlns; };
00089
00094 virtual Presence show() const { return m_show; };
00095
00105 virtual const std::string status( const std::string& lang = "default" ) const;
00106
00114 virtual int priority() const { return m_priority; };
00115
00125 virtual const std::string body( const std::string& lang = "default" ) const;
00126
00136 virtual const std::string subject( const std::string& lang = "default" ) const;
00137
00147 virtual const std::string errorText( const std::string& lang = "default" ) const;
00148
00153 virtual StanzaError error() const { return m_stanzaError; };
00154
00160 Tag* errorAppCondition() { return m_stanzaErrorAppCondition; };
00161
00166 virtual const std::string thread() const { return m_thread; };
00167
00172 const std::string& xmlLang() const { return m_xmllang; };
00173
00181 void finalize() { init(); };
00182
00188 virtual Stanza* clone() const;
00189
00201 static Stanza* createIqStanza( const JID& to, const std::string& id,
00202 StanzaSubType subtype = StanzaIqGet,
00203 const std::string& xmlns = "", Tag* tag = 0 );
00204
00215 static Stanza* createPresenceStanza( const JID& to, const std::string& msg = "",
00216 Presence status = PresenceAvailable,
00217 const std::string& xmllang = "" );
00218
00229 static Stanza* createMessageStanza( const JID& to, const std::string& body,
00230 StanzaSubType subtype = StanzaMessageChat,
00231 const std::string& subject = "", const std::string& thread = "",
00232 const std::string& xmllang = "" );
00233
00242 static Stanza* createSubscriptionStanza( const JID& to, const std::string& msg = "",
00243 StanzaSubType subtype = StanzaS10nSubscribe,
00244 const std::string& xmllang = "" );
00245
00246 protected:
00247 void init();
00248
00249 StanzaSubType m_subtype;
00250 Presence m_show;
00251 StanzaError m_stanzaError;
00252 StanzaErrorType m_stanzaErrorType;
00253 Tag *m_stanzaErrorAppCondition;
00254 StringMap m_errorText;
00255 StringMap m_body;
00256 StringMap m_subject;
00257 StringMap m_status;
00258 JID m_from;
00259 JID m_to;
00260 std::string m_xmlns;
00261 std::string m_id;
00262 std::string m_thread;
00263 std::string m_xmllang;
00264 int m_priority;
00265 };
00266
00267 }
00268
00269 #endif // STANZA_H__