gloox  1.0.1
privatexml.h
1 /*
2  Copyright (c) 2004-2012 by Jakob Schroeter <js@camaya.net>
3  This file is part of the gloox library. http://camaya.net/gloox
4 
5  This software is distributed under a license. The full license
6  agreement can be found in the file LICENSE in this distribution.
7  This software may not be copied, modified, sold or distributed
8  other than expressed in the named license agreement.
9 
10  This software is distributed without any warranty.
11 */
12 
13 
14 
15 #ifndef PRIVATEXML_H__
16 #define PRIVATEXML_H__
17 
18 #include "iqhandler.h"
19 #include "privatexmlhandler.h"
20 
21 #include <string>
22 #include <list>
23 #include <map>
24 
25 namespace gloox
26 {
27 
28  class ClientBase;
29  class Tag;
30  class Stanza;
31 
37  class GLOOX_API PrivateXML : public IqHandler
38  {
39  public:
46  PrivateXML( ClientBase* parent );
47 
51  virtual ~PrivateXML();
52 
60  std::string requestXML( const std::string& tag, const std::string& xmlns, PrivateXMLHandler* pxh );
61 
69  std::string storeXML( const Tag* tag, PrivateXMLHandler* pxh );
70 
71  // reimplemented from IqHandler.
72  virtual bool handleIq( const IQ& iq ) { (void)iq; return false; }
73 
74  // reimplemented from IqHandler.
75  virtual void handleIqID( const IQ& iq, int context );
76 
77  protected:
78  ClientBase* m_parent;
79 
80  private:
81 #ifdef PRIVATEXML_TEST
82  public:
83 #endif
84 
90  class Query : public StanzaExtension
91  {
92  public:
98  Query( const std::string& tag, const std::string& xmlns )
100  {
101  m_privateXML = new Tag( tag, XMLNS, xmlns );
102  }
103 
109  Query( const Tag* tag = 0 );
110 
114  ~Query() { delete m_privateXML; }
115 
120  const Tag* privateXML() const { return m_privateXML; }
121 
122  // reimplemented from StanzaExtension
123  virtual const std::string& filterString() const;
124 
125  // reimplemented from StanzaExtension
126  virtual StanzaExtension* newInstance( const Tag* tag ) const
127  {
128  return new Query( tag );
129  }
130 
131  // reimplemented from StanzaExtension
132  virtual Tag* tag() const;
133 
134  // reimplemented from StanzaExtension
135  virtual StanzaExtension* clone() const
136  {
137  Query* q = new Query();
138  q->m_privateXML = m_privateXML ? m_privateXML->clone() : 0;
139  return q;
140  }
141 
142  private:
143  const Tag* m_privateXML;
144 
145  };
146 
147  enum IdType
148  {
149  RequestXml,
150  StoreXml
151  };
152 
153  typedef std::map<std::string, PrivateXMLHandler*> TrackMap;
154 
155  TrackMap m_track;
156  };
157 
158 }
159 
160 #endif // PRIVATEXML_H__