gloox
0.9.9.12
Main Page
Related Pages
Namespaces
Classes
Files
File List
src
vcardupdate.cpp
1
/*
2
Copyright (c) 2006-2008 by Jakob Schroeter <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 )
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 )
29
{
30
if
( m_hash.empty() )
31
{
32
m_noImage =
true
;
33
m_valid =
false
;
34
}
35
}
36
37
VCardUpdate::VCardUpdate
(
Tag
*tag )
38
:
StanzaExtension
(
ExtVCardUpdate
),
39
m_notReady( true ), m_noImage( true ), m_valid( false )
40
{
41
if
( tag && tag->
name
() ==
"x"
&& tag->
hasAttribute
(
"xmlns"
,
XMLNS_X_VCARD_UPDATE
) )
42
{
43
m_valid =
true
;
44
if
( tag->
hasChild
(
"photo"
) )
45
{
46
m_notReady =
false
;
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
Tag
*
VCardUpdate::tag
()
const
59
{
60
if
( !m_valid )
61
return
0;
62
63
Tag
*x =
new
Tag
(
"x"
);
64
x->
addAttribute
(
"xmlns"
,
XMLNS_X_VCARD_UPDATE
);
65
if
( m_notReady )
66
return
x;
67
68
Tag
*p =
new
Tag
( x,
"photo"
);
69
if
( m_noImage )
70
return
x;
71
72
p->
setCData
( m_hash );
73
74
return
x;
75
}
76
77
}
Generated on Thu Jun 27 2013 13:05:48 for gloox by
1.8.1.2