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
|
/*
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-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.
*/
#include "stdafx.h"
#define TAG_MAX_LEN 128
#define ATTR_MAX_LEN 8192
/////////////////////////////////////////////////////////////////////////////////////////
// XmlNodeIq class members
XmlNodeIq::XmlNodeIq(const char *type, int id, const char *to) :
XmlNode("iq")
{
if (type != nullptr)
m_hXml->SetAttribute("type", type);
if (to != nullptr)
m_hXml->SetAttribute("to", to);
if (id != -1)
XmlAddAttrID(*this, id);
}
XmlNodeIq::XmlNodeIq(const char *type, const char *idStr, const char *to) :
XmlNode("iq")
{
if (type != nullptr)
m_hXml->SetAttribute("type", type);
if (to != nullptr)
m_hXml->SetAttribute("to", to);
if (idStr != nullptr)
m_hXml->SetAttribute("id", idStr);
}
XmlNodeIq::XmlNodeIq(const char *type, TiXmlElement *node, const char *to) :
XmlNode("iq")
{
if (type != nullptr)
m_hXml->SetAttribute("type", type);
if (to != nullptr)
m_hXml->SetAttribute("to", to);
if (node != nullptr) {
const char *iqId = XmlGetAttr(node, "id");
if (iqId != nullptr)
m_hXml->SetAttribute("id", iqId);
}
}
XmlNodeIq::XmlNodeIq(CJabberIqInfo *pInfo) :
XmlNode("iq")
{
if (pInfo) {
if (pInfo->GetCharIqType() != nullptr)
m_hXml->SetAttribute("type", pInfo->GetCharIqType());
if (pInfo->GetReceiver() != nullptr)
m_hXml->SetAttribute("to", pInfo->GetReceiver());
if (pInfo->GetIqId() != -1)
XmlAddAttrID(*this, pInfo->GetIqId());
}
}
XmlNodeIq::XmlNodeIq(const char *type, CJabberIqInfo *pInfo) :
XmlNode("iq")
{
if (type != nullptr)
m_hXml->SetAttribute("type", type);
if (pInfo) {
if (pInfo->GetFrom() != nullptr)
m_hXml->SetAttribute("to", pInfo->GetFrom());
if (pInfo->GetIdStr() != nullptr)
m_hXml->SetAttribute("id", pInfo->GetIdStr());
}
}
/////////////////////////////////////////////////////////////////////////////////////////
// XmlNode class members
XmlNode::XmlNode(const char *pszName)
{
m_hXml = NewElement(pszName); InsertEndChild(m_hXml);
}
XmlNode::XmlNode(const char *pszName, const char *ptszText)
{
m_hXml = NewElement(pszName); InsertEndChild(m_hXml);
if (ptszText)
m_hXml->SetText(ptszText);
}
/////////////////////////////////////////////////////////////////////////////////////////
TiXmlElement* __fastcall operator<<(TiXmlElement *node, const XCHILDNS &child)
{
TiXmlElement *res = XmlAddChild(node, child.name);
res->SetAttribute("xmlns", child.ns);
return res;
}
TiXmlElement* __fastcall operator<<(TiXmlElement *node, const XQUERY &child)
{
TiXmlElement *res = XmlAddChild(node, "query");
res->SetAttribute("xmlns", child.ns);
return res;
}
/////////////////////////////////////////////////////////////////////////////////////////
void XmlAddAttrID(TiXmlElement *hXml, int id)
{
char text[100];
mir_snprintf(text, JABBER_IQID "%d", id);
hXml->SetAttribute("id", text);
}
|