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
|
/****************************************************************************
**
** Jreen
**
** Copyright © 2011 Ruslan Nigmatullin <euroelessar@yandex.ru>
**
*****************************************************************************
**
** $JREEN_BEGIN_LICENSE$
** 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, see http://www.gnu.org/licenses/.
** $JREEN_END_LICENSE$
**
****************************************************************************/
#include "stanza.h"
#include "stanza_p.h"
#include "error.h"
#include <QTextStream>
namespace Jreen
{
Stanza::Stanza(const Stanza &stanza)
{
if(stanza.d_ptr)
stanza.d_ptr->ref.ref();
d_ptr = stanza.d_ptr;
}
Stanza &Stanza::operator =(const Stanza &stanza)
{
if(stanza.d_ptr)
stanza.d_ptr->ref.ref();
if(!d_ptr->ref.deref())
delete d_ptr;
d_ptr = stanza.d_ptr;
return *this;
}
Stanza::Stanza(StanzaPrivate &sp)
{
d_ptr = &sp;
}
Stanza::~Stanza()
{
if(d_ptr && !d_ptr->ref.deref())
delete d_ptr;
}
void Stanza::setFrom(const JID &jid)
{
d_ptr->from = jid;
}
const JID &Stanza::from() const
{
return d_ptr->from;
}
const JID &Stanza::to() const
{
return d_ptr->to;
}
const QString &Stanza::id() const
{
return d_ptr->id;
}
void Stanza::addExtension(Payload::Ptr se)
{
d_ptr->extensions.insert(se->payloadType(), se);
}
PayloadList Stanza::payloads() const
{
return d_ptr->extensions;
}
void Stanza::removePayloads()
{
d_ptr->extensions.clear();
}
void Stanza::removePayload(int id)
{
d_ptr->extensions.remove(id);
}
Error::Ptr Stanza::error() const
{
return payload<Error>();
}
}
|