00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef DATAFORM_H__
00015 #define DATAFORM_H__
00016
00017 #include "dataformfieldcontainer.h"
00018 #include "stanzaextension.h"
00019
00020 #include <string>
00021 #include <list>
00022
00023 namespace gloox
00024 {
00025
00026 class Tag;
00027 class DataFormItem;
00028 class DataFormReported;
00029
00033 enum FormType
00034 {
00035 TypeForm,
00037 TypeSubmit,
00039 TypeCancel,
00041 TypeResult,
00044 TypeInvalid
00046 };
00047
00056 class GLOOX_API DataForm : public StanzaExtension, public DataFormFieldContainer
00057 {
00058 public:
00066 DataForm( FormType type, const StringList& instructions, const std::string& title = EmptyString );
00067
00075 DataForm( FormType type, const std::string& title = EmptyString );
00076
00081 DataForm( const Tag* tag );
00082
00087 DataForm( const DataForm& form );
00088
00092 virtual ~DataForm();
00093
00098 const std::string& title() const { return m_title; }
00099
00105 void setTitle( const std::string& title ) { m_title = title; }
00106
00111 const StringList& instructions() const { return m_instructions; }
00112
00120 void setInstructions( const StringList& instructions ) { m_instructions = instructions; }
00121
00127 FormType type() const { return m_type; }
00128
00133 void setType( FormType type ) { m_type = type; }
00134
00141 bool parse( const Tag* tag );
00142
00146 operator bool() const { return m_type != TypeInvalid; }
00147
00148
00149 virtual const std::string& filterString() const;
00150
00151
00152 virtual StanzaExtension* newInstance( const Tag* tag ) const
00153 {
00154 return new DataForm( tag );
00155 }
00156
00157
00158 virtual Tag* tag() const;
00159
00160 protected:
00161 FormType m_type;
00162
00163 private:
00164 StringList m_instructions;
00165
00166 std::string m_title;
00167
00168 };
00169
00170 }
00171
00172 #endif // DATAFORM_H__