gloox
1.0.9
Main Page
Related Pages
Namespaces
Classes
Files
File List
src
delayeddelivery.cpp
1
/*
2
Copyright (c) 2006-2013 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 "delayeddelivery.h"
15
16
#include "tag.h"
17
18
namespace
gloox
19
{
20
21
DelayedDelivery::DelayedDelivery
(
const
JID
& from,
const
std::string stamp,
const
std::string& reason )
22
:
StanzaExtension
(
ExtDelay
), m_from( from ), m_stamp( stamp ), m_reason( reason ), m_valid( false )
23
{
24
if
( !m_stamp.empty() )
25
m_valid =
true
;
26
}
27
28
29
DelayedDelivery::DelayedDelivery
(
const
Tag
* tag )
30
:
StanzaExtension
(
ExtDelay
), m_valid( false )
31
{
32
if
( !tag || !tag->
hasAttribute
(
"stamp"
) )
33
return
;
34
35
if
( !( tag->
name
() ==
"x"
&& tag->
hasAttribute
(
XMLNS
,
XMLNS_X_DELAY
) ) )
36
if
( !( tag->
name
() ==
"delay"
&& tag->
hasAttribute
(
XMLNS
,
XMLNS_DELAY
) ) )
37
return
;
38
39
m_reason = tag->
cdata
();
40
m_stamp = tag->
findAttribute
(
"stamp"
);
41
m_from = tag->
findAttribute
(
"from"
);
42
m_valid =
true
;
43
}
44
45
DelayedDelivery::~DelayedDelivery
()
46
{
47
}
48
49
const
std::string&
DelayedDelivery::filterString
()
const
50
{
51
static
const
std::string filter =
52
"/presence/delay[@xmlns='"
+
XMLNS_DELAY
+
"']"
53
"|/message/delay[@xmlns='"
+
XMLNS_DELAY
+
"']"
54
"|/presence/x[@xmlns='"
+
XMLNS_X_DELAY
+
"']"
55
"|/message/x[@xmlns='"
+
XMLNS_X_DELAY
+
"']"
;
56
return
filter;
57
}
58
59
Tag
*
DelayedDelivery::tag
()
const
60
{
61
if
( !m_valid )
62
return
0;
63
64
Tag
* t =
new
Tag
(
"delay"
);
65
t->
addAttribute
(
XMLNS
,
XMLNS_DELAY
);
66
if
( m_from )
67
t->
addAttribute
(
"from"
, m_from.
full
() );
68
if
( !m_stamp.empty() )
69
t->
addAttribute
(
"stamp"
, m_stamp );
70
if
( !m_reason.empty() )
71
t->
setCData
( m_reason );
72
return
t;
73
}
74
75
}
Generated on Tue Oct 15 2013 19:25:20 for gloox by
1.8.1.2