gloox  1.0.28
iodata.h
1 /*
2  Copyright (c) 2015-2023 by Jakob Schröter <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 #ifndef IODATA_H__
15 #define IODATA_H__
16 
17 #include "adhocplugin.h"
18 
19 #include "gloox.h"
20 #include "tag.h"
21 
22 #include <string>
23 
24 namespace gloox
25 {
26 
36  class GLOOX_API IOData : public AdhocPlugin
37  {
38  public:
42  enum Type
43  {
44  TypeIoSchemataGet,
53  };
54 
55  struct Status
56  {
57  int elapsed;
59  int remaining;
61  int percentage;
62  std::string info;
63  };
64 
69  IOData( Type type );
70 
75  IOData( const Tag* tag );
76 
80  virtual ~IOData();
81 
86  Type type() const { return m_type; }
87 
93  const Tag* in() const { return m_in; }
94 
102  void setIn( Tag* in );
103 
109  const Tag* out() const { return m_out; }
110 
118  void setOut( Tag* out );
119 
125  const Tag* error() const { return m_error; }
126 
134  void setError( Tag* error );
135 
140  void setDesc( const std::string& desc ) { m_desc = desc; }
141 
146  const std::string& desc() const { return m_desc; }
147 
152  void setStatus( Status status ) { m_status = status; }
153 
158  Status status() const { return m_status; }
159 
160  // reimplemented from AdhocPlugin/StanzaExtension
161  virtual Tag* tag() const;
162 
163  // reimplemented from AdhocPlugin/StanzaExtension
164  virtual IOData* clone() const;
165 
166  // reimplemented from AdhocPlugin/StanzaExtension
167  virtual const std::string& filterString() const { return EmptyString; }
168 
169  // reimplemented from AdhocPlugin/StanzaExtension
170  virtual StanzaExtension* newInstance( const Tag* /*tag*/ ) const { return 0; }
171 
175  operator bool() const { return m_type != TypeInvalid; }
176 
177  private:
178  Tag* m_in;
179  Tag* m_out;
180  Tag* m_error;
181 
182  std::string m_desc;
183 
184  Status m_status;
185 
186  Type m_type;
187 
188  };
189 
190 }
191 
192 #endif // IODATA_H__
A base class for Adhoc Command plugins (DataForm, IO Data, ...).
Definition: adhocplugin.h:39
This is an abstraction of the IO Data specification XEP-0244.
Definition: iodata.h:37
virtual StanzaExtension * newInstance(const Tag *) const
Definition: iodata.h:170
@ TypeStatus
Definition: iodata.h:51
@ TypeGetStatus
Definition: iodata.h:46
@ TypeOutput
Definition: iodata.h:49
@ TypeIoSchemataResult
Definition: iodata.h:48
@ TypeGetOutput
Definition: iodata.h:47
const Tag * error() const
Definition: iodata.h:125
void setStatus(Status status)
Definition: iodata.h:152
const std::string & desc() const
Definition: iodata.h:146
void setDesc(const std::string &desc)
Definition: iodata.h:140
const Tag * in() const
Definition: iodata.h:93
const Tag * out() const
Definition: iodata.h:109
virtual const std::string & filterString() const
Definition: iodata.h:167
Status status() const
Definition: iodata.h:158
Type type() const
Definition: iodata.h:86
This class abstracts a stanza extension, which is usually an XML child element in a specific namespac...
This is an abstraction of an XML element.
Definition: tag.h:47
The namespace for the gloox library.
Definition: adhoc.cpp:28
const std::string EmptyString
Definition: gloox.cpp:124
@ TypeInvalid
Definition: dataform.h:44