gloox
1.1-svn
Main Page
Related Pages
Namespaces
Classes
Files
File List
src
bob.cpp
1
/*
2
Copyright (c) 2009 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
15
#include "bob.h"
16
#include "base64.h"
17
#include "tag.h"
18
19
#include <cstdlib>
20
21
namespace
gloox
22
{
23
24
BOB::BOB
(
const
Tag
* tag )
25
:
StanzaExtension
(
ExtBOB
)
26
{
27
if
( !tag || tag->
name
() !=
"data"
|| tag->
xmlns
() !=
XMLNS_BOB
)
28
return
;
29
30
m_cid = tag->
findAttribute
(
"cid"
);
31
m_maxage = strtol( tag->
findAttribute
(
"max-age"
).c_str(), 0, 10 );
32
m_type = tag->
findAttribute
(
"type"
);
33
m_data = tag->
cdata
();
34
}
35
36
BOB::BOB
(
const
std::string& cid,
const
std::string& type,
37
const
std::string& data,
int
maxage )
38
:
StanzaExtension
(
ExtBOB
), m_cid( cid ), m_type( type ),
39
m_data( Base64::encode64( data ) ), m_maxage( maxage )
40
{
41
}
42
43
const
std::string
BOB::data
()
const
44
{
45
return
Base64::decode64
( m_data );
46
}
47
48
const
std::string&
BOB::filterString
()
const
49
{
50
static
const
std::string filter =
"/iq/data[@xmlns='"
+
XMLNS_BOB
+
"']"
51
"|/presence/data[@xmlns='"
+
XMLNS_BOB
+
"']"
52
"|/message/data[@xmlns='"
+
XMLNS_BOB
+
"']"
;
53
return
filter;
54
}
55
56
Tag
*
BOB::tag
()
const
57
{
58
if
( m_cid.empty() || m_type.empty() )
59
return
0;
60
61
Tag
* t =
new
Tag
(
"data"
);
62
t->
setXmlns
(
XMLNS_BOB
);
63
t->
addAttribute
(
"cid"
, m_cid );
64
t->
addAttribute
(
"type"
, m_type );
65
t->
addAttribute
(
"max-age"
, m_maxage );
66
t->
setCData
( m_data );
67
68
return
t;
69
}
70
71
}
Generated on Thu Jun 27 2013 13:43:26 for gloox by
1.8.1.2