gloox
1.0.9
Main Page
Related Pages
Namespaces
Classes
Files
File List
src
receipt.cpp
1
/*
2
Copyright (c) 2007-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
#include "receipt.h"
14
#include "tag.h"
15
#include "util.h"
16
17
namespace
gloox
18
{
19
20
/* chat state type values */
21
static
const
char
* receiptValues [] = {
22
"request"
,
23
"received"
24
};
25
26
static
inline
Receipt::ReceiptType
receiptType(
const
std::string& type )
27
{
28
return
(
Receipt::ReceiptType
)util::lookup( type, receiptValues );
29
}
30
31
Receipt::Receipt
(
const
Tag
* tag )
32
:
StanzaExtension
(
ExtReceipt
), m_rcpt( Invalid )
33
{
34
if
( !tag )
35
return
;
36
37
m_rcpt = receiptType( tag->
name
() );
38
m_id = tag->
findAttribute
(
"id"
);
39
}
40
41
const
std::string&
Receipt::filterString
()
const
42
{
43
static
const
std::string filter =
44
"/message/request[@xmlns='"
+
XMLNS_RECEIPTS
+
"']"
45
"|/message/received[@xmlns='"
+
XMLNS_RECEIPTS
+
"']"
;
46
return
filter;
47
}
48
49
Tag
*
Receipt::tag
()
const
50
{
51
if
( m_rcpt ==
Invalid
)
52
return
0;
53
54
Tag
*
tag
=
new
Tag
( util::lookup( m_rcpt, receiptValues ),
XMLNS
,
XMLNS_RECEIPTS
);
55
if
( !m_id.empty() )
56
tag->
addAttribute
(
"id"
, m_id );
57
return
tag
;
58
}
59
60
}
Generated on Tue Oct 15 2013 19:25:21 for gloox by
1.8.1.2