gloox
1.0.9
Main Page
Related Pages
Namespaces
Classes
Files
File List
src
messageevent.cpp
1
/*
2
Copyright (c) 2005-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 "messageevent.h"
14
#include "tag.h"
15
#include "util.h"
16
17
namespace
gloox
18
{
19
20
/* chat state type values */
21
static
const
char
* eventValues [] = {
22
"offline"
,
23
"delivered"
,
24
"displayed"
,
25
"composing"
26
};
27
28
MessageEvent::MessageEvent
(
const
Tag
* tag )
29
:
StanzaExtension
(
ExtMessageEvent
), m_event(
MessageEventCancel
)
30
{
31
if
( !tag )
32
return
;
33
34
const
TagList
& l = tag->
children
();
35
TagList::const_iterator it = l.begin();
36
int
event
= 0;
37
for
( ; it != l.end(); ++it )
38
event
|= util::lookup2( (*it)->name(), eventValues );
39
if
(
event
)
40
m_event =
event
;
41
}
42
43
const
std::string&
MessageEvent::filterString
()
const
44
{
45
static
const
std::string filter =
"/message/x[@xmlns='"
+
XMLNS_X_EVENT
+
"']"
;
46
return
filter;
47
}
48
49
Tag
*
MessageEvent::tag
()
const
50
{
51
Tag
* x =
new
Tag
(
"x"
,
XMLNS
,
XMLNS_X_EVENT
);
52
53
if
( m_event &
MessageEventOffline
)
54
new
Tag
( x,
"offline"
);
55
if
( m_event &
MessageEventDelivered
)
56
new
Tag
( x,
"delivered"
);
57
if
( m_event &
MessageEventDisplayed
)
58
new
Tag
( x,
"displayed"
);
59
if
( m_event &
MessageEventComposing
)
60
new
Tag
( x,
"composing"
);
61
62
if
( !m_id.empty() )
63
new
Tag
( x,
"id"
, m_id );
64
65
return
x;
66
}
67
68
}
Generated on Tue Oct 15 2013 19:25:21 for gloox by
1.8.1.2