stanza.h

00001 /*
00002   Copyright (c) 2005 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 
00021 namespace gloox
00022 {
00023 
00031   class GLOOX_EXPORT Stanza : public Tag
00032   {
00033     public:
00034 
00043       Stanza( Tag *tag );
00044 
00051       Stanza( const std::string& name, const std::string& cdata = "",
00052               const std::string& xmllang = "default" );
00053 
00057       virtual ~Stanza() {};
00058 
00063       virtual StanzaSubType subtype() const { return m_subtype; };
00064 
00069       virtual const JID& from() const { return m_from; };
00070 
00075       virtual const JID& to() const { return m_to; };
00076 
00081       virtual const std::string id() const { return m_id; };
00082 
00087       virtual const std::string& xmlns() const { return m_xmlns; };
00088 
00093       virtual PresenceStatus show() const { return m_show; };
00094 
00104       virtual const std::string status( const std::string& lang = "default" ) const;
00105 
00115       virtual const std::string body( const std::string& lang = "default" ) const;
00116 
00126       virtual const std::string subject( const std::string& lang = "default" ) const;
00127 
00137       virtual const std::string errorText( const std::string& lang = "default" ) const;
00138 
00143       virtual StanzaError error() const { return m_stanzaError; };
00144 
00150       Tag* errorAppCondition() { return m_stanzaErrorAppCondition; };
00151 
00156       virtual const std::string thread() const { return m_thread; };
00157 
00162       const std::string& xmlLang() const { return m_xmllang; };
00163 
00171       void finalize() { init(); };
00172 
00178       virtual Stanza* clone( bool = true );
00179 
00191       static Stanza* createIqStanza( const JID& to, const std::string& id,
00192                                      StanzaSubType subtype = STANZA_IQ_GET,
00193                                      const std::string& xmlns = "", Tag* tag = 0 );
00194 
00203       static Stanza* createPresenceStanza( const JID& to, const std::string& msg = "",
00204                                            PresenceStatus status = PRESENCE_AVAILABLE,
00205                                            const std::string& xmllang = "" );
00206 
00217       static Stanza* createMessageStanza( const JID& to, const std::string& body,
00218                                           StanzaSubType subtype = STANZA_MESSAGE_CHAT,
00219                                           const std::string& subject = "", const std::string& thread = "",
00220                                           const std::string& xmllang = "" );
00221 
00230       static Stanza* createSubscriptionStanza( const JID& to, const std::string& msg = "",
00231                                                StanzaSubType subtype = STANZA_S10N_SUBSCRIBE,
00232                                                const std::string& xmllang = "" );
00233 
00234     protected:
00235       void init();
00236 
00237       StanzaSubType m_subtype;
00238       PresenceStatus m_show;
00239       StanzaError m_stanzaError;
00240       StanzaErrorType m_stanzaErrorType;
00241       Tag *m_stanzaErrorAppCondition;
00242       StringMap m_errorText;
00243       StringMap m_body;
00244       StringMap m_subject;
00245       StringMap m_status;
00246       JID m_from;
00247       JID m_to;
00248       std::string m_xmlns;
00249       std::string m_id;
00250       std::string m_thread;
00251       std::string m_xmllang;
00252       int m_priority;
00253   };
00254 
00255 }
00256 
00257 #endif // STANZA_H__

Generated on Mon Jan 16 16:19:54 2006 for gloox by  doxygen 1.4.6