gloox
1.0.1
Main Page
Related Pages
Namespaces
Classes
Files
File List
src
delayeddelivery.cpp
1
/*
2
Copyright (c) 2006-2012 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
if
( !( tag->
name
() ==
"x"
&& tag->
hasAttribute
(
XMLNS
,
XMLNS_X_DELAY
) ) )
35
if
( !( tag->
name
() ==
"delay"
&& tag->
hasAttribute
(
XMLNS
,
XMLNS_DELAY
) ) )
36
return
;
37
38
m_reason = tag->
cdata
();
39
m_stamp = tag->
findAttribute
(
"stamp"
);
40
m_from = tag->
findAttribute
(
"from"
);
41
m_valid =
true
;
42
}
43
44
DelayedDelivery::~DelayedDelivery
()
45
{
46
}
47
48
const
std::string&
DelayedDelivery::filterString
()
const
49
{
50
static
const
std::string filter =
51
"/presence/delay[@xmlns='"
+
XMLNS_DELAY
+
"']"
52
"|/message/delay[@xmlns='"
+
XMLNS_DELAY
+
"']"
53
"|/presence/x[@xmlns='"
+
XMLNS_X_DELAY
+
"']"
54
"|/message/x[@xmlns='"
+
XMLNS_X_DELAY
+
"']"
;
55
return
filter;
56
}
57
58
Tag
*
DelayedDelivery::tag
()
const
59
{
60
if
( !m_valid )
61
return
0;
62
63
Tag
* t =
new
Tag
(
"delay"
);
64
t->
addAttribute
(
XMLNS
,
XMLNS_DELAY
);
65
if
( m_from )
66
t->
addAttribute
(
"from"
, m_from.
full
() );
67
if
( !m_stamp.empty() )
68
t->
addAttribute
(
"stamp"
, m_stamp );
69
if
( !m_reason.empty() )
70
t->
setCData
( m_reason );
71
return
t;
72
}
73
74
}
Generated on Sun Jun 30 2013 14:37:36 for gloox by
1.8.1.2