gloox
1.0.1
Main Page
Related Pages
Namespaces
Classes
Files
File List
src
messageevent.cpp
1
/*
2
Copyright (c) 2005-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
#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
const
TagList
& l = tag->
children
();
32
TagList::const_iterator it = l.begin();
33
int
event
= 0;
34
for
( ; it != l.end(); ++it )
35
event
|= util::lookup2( (*it)->name(), eventValues );
36
if
(
event
)
37
m_event =
event
;
38
}
39
40
const
std::string&
MessageEvent::filterString
()
const
41
{
42
static
const
std::string filter =
"/message/x[@xmlns='"
+
XMLNS_X_EVENT
+
"']"
;
43
return
filter;
44
}
45
46
Tag
*
MessageEvent::tag
()
const
47
{
48
Tag
* x =
new
Tag
(
"x"
,
XMLNS
,
XMLNS_X_EVENT
);
49
50
if
( m_event &
MessageEventOffline
)
51
new
Tag
( x,
"offline"
);
52
if
( m_event &
MessageEventDelivered
)
53
new
Tag
( x,
"delivered"
);
54
if
( m_event &
MessageEventDisplayed
)
55
new
Tag
( x,
"displayed"
);
56
if
( m_event &
MessageEventComposing
)
57
new
Tag
( x,
"composing"
);
58
59
if
( !m_id.empty() )
60
new
Tag
( x,
"id"
, m_id );
61
62
return
x;
63
}
64
65
}
Generated on Sun Jun 30 2013 14:37:36 for gloox by
1.8.1.2