summaryrefslogtreecommitdiff
path: root/protocols/JabberG/src/obsoleted/jabber_form2.h.obsoleted
blob: 61bc9d8a14d8191fb99eb2b79a4358f3c3bf1f5a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
/*

Jabber Protocol Plugin for Miranda NG

Copyright (c) 2002-04  Santithorn Bunchua
Copyright (c) 2005-12  George Hazan
Copyright (c) 2007-09  Maxim Mluhov
Copyright (c) 2007-09  Victor Pavlychko
Copyright (C) 2012-19 Miranda NG team

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or ( at your option ) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

*/

enum TJabberDataFormType
{
	JDFT_BOOLEAN,
	JDFT_FIXED,
	JDFT_HIDDEN,
	JDFT_JID_MULTI,
	JDFT_JID_SINGLE,
	JDFT_LIST_MULTI,
	JDFT_LIST_SINGLE,
	JDFT_TEXT_MULTI,
	JDFT_TEXT_PRIVATE,
	JDFT_TEXT_SINGLE,
};

struct TJabberDataFormRegisry_Field
{
	TCHAR *field;
	TJabberDataFormType type;
	TCHAR *description_en;
	TCHAR *description_tr;
};

struct TJabberDataFormRegisry_Form
{
	TCHAR *form_type;
	TJabberDataFormRegisry_Field *fields;
	int count;
};

/////////////////////////////////////////////////////////////////////////////////////////
// Forwards
class CJabberDlgDataForm;
class CJabberDataField;
class CJabberDataFieldSet;
class CJabberDataForm;
class CJabberDlgDataPage;

/////////////////////////////////////////////////////////////////////////////////////////
// Data form classes
class CJabberDataField
{
public:
	struct TOption
	{
		TCHAR *label;
		TCHAR *value;
	};

	CJabberDataField(CJabberDataForm *form, XmlNode *node);
	~CJabberDataField();

	XmlNode *GetNode() { return m_node; }

	TCHAR *GetTypeName() { return m_typeName; }
	TJabberDataFormType GetType() { return m_type; }

	TCHAR *GetVar() { return m_var; }

	bool IsRequired() { return m_required; }
	TCHAR *GetDescription(int i) { return m_descriptions[i]; }
	TCHAR *GetLabel() { return m_label; }

	int GetValueCount() { return m_values.getCount(); }
	TCHAR *GetValue(int i = 0) { return m_values[i]; }

	int GetOptionCount() { return m_options.getCount(); }
	TOption *GetOption(int i) { return &(m_options[i]); }

private:
	XmlNode *m_node;
	CJabberDataFieldSet *m_fieldset;

	bool m_required;
	TCHAR *m_var;
	TCHAR *m_label;
	TCHAR *m_typeName;
	TJabberDataFormType m_type;

	OBJLIST<TOption> m_options;
	LIST<TCHAR> m_values;
	LIST<TCHAR> m_descriptions;
};

class CJabberDataFieldSet
{
public:
	CJabberDataFieldSet();

	int GetCount() { return m_fields.getCount(); }
	CJabberDataField *GetField(int i) { return &(m_fields[i]); }
	CJabberDataField *GetField(TCHAR *var);

	void AddField(CJabberDataField *field) { m_fields.insert(field, m_fields.getCount()); }

private:
	OBJLIST<CJabberDataField> m_fields;
};

class CJabberDataForm
{
public:
	enum TFormType { TYPE_NONE, TYPE_FORM, TYPE_SUBMIT, TYPE_CANCEL, TYPE_RESULT };

	CJabberDataForm(XmlNode *node);
	~CJabberDataForm();

	TCHAR *GetTypeName() const { return m_typename; }
	TFormType GetType() const { return m_type; }
	TCHAR *GetFormType() const { return m_form_type; }
	TCHAR *GetTitle() const { return m_title; }
	int GetInstructionsCount() const { return m_instructions.getCount(); }
	TCHAR *GetInstructions(int idx=0) const { return m_instructions[idx]; }

	CJabberDataFieldSet *GetFields() { return &m_fields; }

	CJabberDataFieldSet *GetReported() { return &m_reported; }
	int GetItemCount() { return m_items.getCount(); }
	CJabberDataFieldSet *GetItem(int i) { return &(m_items[i]); }

private:
	XmlNode *m_node;

	TCHAR *m_typename;
	TFormType m_type;

	TCHAR *m_form_type;
	TJabberDataFormRegisry_Form *m_form_type_info;

	TCHAR *m_title;
	LIST<TCHAR> m_instructions;

	CJabberDataFieldSet m_fields;
	CJabberDataFieldSet m_reported;
	OBJLIST<CJabberDataFieldSet> m_items;
};

/////////////////////////////////////////////////////////////////////////////////////////
// UI Control
class CCtrlJabberForm: public CCtrlBase
{
	typedef CCtrlBase CSuper;

public:
	static const TCHAR *ClassName;
	static bool RegisterClass();
	static bool UnregisterClass();

	CCtrlJabberForm(CDlgBase* dlg, int ctrlId);
	~CCtrlJabberForm();

	void OnInit();
	void SetDataForm(CJabberDataForm *pForm);
	XmlNode *FetchData();

protected:
	virtual LRESULT CustomWndProc(UINT msg, WPARAM wParam, LPARAM lParam);

private:
	static bool ClassRegistered;

	CJabberDataForm *m_pForm;
	CJabberDlgDataPage *m_pDlgPage;

	void SetupForm();
	void Layout();
};