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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
|
/*
Jabber Protocol Plugin for Miranda NG
Copyright (c) 2002-04 Santithorn Bunchua
Copyright (c) 2005-12 George Hazan
Copyright (c) 2007 Maxim Mluhov
Copyright (C) 2012-24 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.
*/
#ifndef _JABBER_XML_H_
#define _JABBER_XML_H_
#define JCPF_IN 0x01UL
#define JCPF_OUT 0x02UL
#define JCPF_ERROR 0x04UL
void XmlAddAttrID(TiXmlElement*, int id);
class XmlNodeHash : public tinyxml2::XMLVisitor
{
mir_md5_state_t state;
void add(const char *);
public:
XmlNodeHash();
CMStringA getResult();
virtual bool VisitEnter(const TiXmlElement &, const tinyxml2::XMLAttribute *);
};
/////////////////////////////////////////////////////////////////////////////////////////
class XmlNode : public TiXmlDocument, private MNonCopyable
{
protected:
TiXmlElement *m_hXml;
public:
XmlNode(const char *name);
XmlNode(const char *pszName, const char *ptszText);
__forceinline void operator +=(const TiXmlElement *pNode)
{
m_hXml->InsertEndChild(pNode->DeepClone(this)->ToElement());
}
__forceinline TiXmlElement* node() const
{ return m_hXml;
}
__forceinline operator TiXmlElement*()
{ return m_hXml;
}
};
class CJabberIqInfo;
struct XmlNodeIq : public XmlNode
{
XmlNodeIq(const char *type, int id = -1, const char *to = nullptr);
XmlNodeIq(const char *type, const char *idStr, const char *to);
XmlNodeIq(const char *type, TiXmlElement *node, const char *to);
// new request
XmlNodeIq(CJabberIqInfo *pInfo);
// answer to request
XmlNodeIq(const char *type, CJabberIqInfo *pInfo);
};
typedef void (*JABBER_XML_CALLBACK)(TiXmlElement*, void*);
/////////////////////////////////////////////////////////////////////////////////////////
struct XATTR
{
const char *name, *value;
__forceinline XATTR(const char *_name, const char *_value) :
name(_name),
value(_value)
{}
};
__forceinline TiXmlElement *operator<<(TiXmlElement *node, const XATTR& attr)
{
XmlAddAttr(node, attr.name, attr.value);
return node;
}
/////////////////////////////////////////////////////////////////////////////////////////
struct XATTRI
{
const char *name;
int value;
__forceinline XATTRI(const char *_name, int _value) :
name(_name),
value(_value)
{}
};
__forceinline TiXmlElement *operator<<(TiXmlElement *node, const XATTRI& attr)
{
node->SetAttribute(attr.name, attr.value);
return node;
}
/////////////////////////////////////////////////////////////////////////////////////////
struct XATTRI64
{
const char *name;
__int64 value;
__forceinline XATTRI64(const char *_name, __int64 _value) :
name(_name),
value(_value)
{}
};
__forceinline TiXmlElement *operator<<(TiXmlElement *node, const XATTRI64& attr)
{
node->SetAttribute(attr.name, attr.value);
return node;
}
/////////////////////////////////////////////////////////////////////////////////////////
struct XATTRID
{
int id;
__forceinline XATTRID(int _value) :
id(_value)
{}
};
__forceinline TiXmlElement *operator<<(TiXmlElement *node, const XATTRID& attr)
{
node->SetAttribute("id", attr.id);
return node;
}
/////////////////////////////////////////////////////////////////////////////////////////
struct XCHILD
{
const char *name, *value;
__forceinline XCHILD(const char *_name, const char *_value = nullptr) :
name(_name),
value(_value)
{}
};
__forceinline TiXmlElement *operator<<(TiXmlElement *node, const XCHILD &child)
{
return XmlAddChildA(node, child.name, child.value);
}
/////////////////////////////////////////////////////////////////////////////////////////
struct XCHILDNS
{
const char *name, *ns;
__forceinline XCHILDNS(const char *_name, const char *_ns) :
name(_name),
ns(_ns)
{}
};
TiXmlElement* __fastcall operator<<(TiXmlElement *node, const XCHILDNS &child);
/////////////////////////////////////////////////////////////////////////////////////////
struct XQUERY
{
const char *ns;
__forceinline XQUERY(const char *_ns) :
ns(_ns)
{}
};
TiXmlElement* __fastcall operator<<(TiXmlElement *node, const XQUERY& child);
#endif
|