gloox
1.0.28
src
vcardupdate.cpp
1
/*
2
Copyright (c) 2006-2023 by Jakob Schröter <js@camaya.net>
3
This file is part of the gloox library. http://camaya.net/gloox
4
5
This software is distributed under a license. The full license
6
agreement can be found in the file LICENSE in this distribution.
7
This software may not be copied, modified, sold or distributed
8
other than expressed in the named license agreement.
9
10
This software is distributed without any warranty.
11
*/
12
13
14
#include "vcardupdate.h"
15
#include "tag.h"
16
17
namespace
gloox
18
{
19
20
VCardUpdate::VCardUpdate
()
21
:
StanzaExtension
(
ExtVCardUpdate
),
22
m_notReady( true ), m_noImage( true ), m_valid( true ), m_hasPhoto( false )
23
{
24
}
25
26
VCardUpdate::VCardUpdate
(
const
std::string&
hash
)
27
:
StanzaExtension
(
ExtVCardUpdate
),
28
m_hash(
hash
), m_notReady( false ), m_noImage( false ), m_valid( true ), m_hasPhoto( false )
29
{
30
if
( m_hash.empty() )
31
m_noImage =
true
;
32
}
33
34
VCardUpdate::VCardUpdate
(
const
Tag
*
tag
)
35
:
StanzaExtension
(
ExtVCardUpdate
),
36
m_notReady( true ), m_noImage( true ), m_valid( false ), m_hasPhoto( false )
37
{
38
if
(
tag
&&
tag
->name() ==
"x"
&&
tag
->hasAttribute(
XMLNS
,
XMLNS_X_VCARD_UPDATE
) )
39
{
40
m_valid = true;
41
if( tag->hasChild(
"photo"
) )
42
{
43
m_notReady = false;
44
if( tag->hasChild(
"photo"
) )
45
m_hasPhoto = true;
46
47
m_hash = tag->findChild(
"photo"
)->cdata();
48
if( !m_hash.empty() )
49
m_noImage = false;
50
}
51
}
52
}
53
54
VCardUpdate::~VCardUpdate
()
55
{
56
}
57
58
const
std::string&
VCardUpdate::filterString
()
const
59
{
60
static
const
std::string filter =
"/presence/x[@xmlns='"
+
XMLNS_X_VCARD_UPDATE
+
"']"
;
61
return
filter;
62
}
63
64
Tag
*
VCardUpdate::tag
()
const
65
{
66
if
( !m_valid )
67
return
0;
68
69
Tag
* x =
new
Tag
(
"x"
,
XMLNS
,
XMLNS_X_VCARD_UPDATE
);
70
if
( !m_notReady )
71
{
72
Tag
* p =
new
Tag
( x,
"photo"
);
73
if
( !m_noImage )
74
p->
setCData
( m_hash );
75
}
76
return
x;
77
}
78
79
}
gloox::StanzaExtension::StanzaExtension
StanzaExtension(int type)
Definition
stanzaextension.h:211
gloox::Tag
This is an abstraction of an XML element.
Definition
tag.h:47
gloox::Tag::setCData
bool setCData(const std::string &cdata)
Definition
tag.cpp:447
gloox::VCardUpdate::hash
const std::string & hash() const
Definition
vcardupdate.h:65
gloox::VCardUpdate::VCardUpdate
VCardUpdate()
Definition
vcardupdate.cpp:20
gloox::VCardUpdate::filterString
virtual const std::string & filterString() const
Definition
vcardupdate.cpp:58
gloox::VCardUpdate::tag
Tag * tag() const
Definition
vcardupdate.cpp:64
gloox::VCardUpdate::~VCardUpdate
virtual ~VCardUpdate()
Definition
vcardupdate.cpp:54
gloox
The namespace for the gloox library.
Definition
adhoc.cpp:28
gloox::XMLNS_X_VCARD_UPDATE
const std::string XMLNS_X_VCARD_UPDATE
Definition
gloox.cpp:57
gloox::XMLNS
const std::string XMLNS
Definition
gloox.cpp:122
gloox::ExtVCardUpdate
@ ExtVCardUpdate
Definition
stanzaextension.h:33
Generated on
for gloox by
1.15.0