gloox
1.0.9
Main Page
Related Pages
Namespaces
Classes
Files
File List
src
chatstate.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 "chatstate.h"
14
#include "tag.h"
15
#include "util.h"
16
17
namespace
gloox
18
{
19
20
/* chat state type values */
21
static
const
char
* stateValues [] = {
22
"active"
,
23
"composing"
,
24
"paused"
,
25
"inactive"
,
26
"gone"
27
};
28
29
static
inline
ChatStateType
chatStateType(
const
std::string& type )
30
{
31
return
(
ChatStateType
)util::lookup2( type, stateValues );
32
}
33
34
ChatState::ChatState
(
const
Tag
* tag )
35
:
StanzaExtension
(
ExtChatState
),
36
m_state(
ChatStateInvalid
)
37
{
38
if
( tag )
39
m_state = chatStateType( tag->
name
() );
40
}
41
42
const
std::string&
ChatState::filterString
()
const
43
{
44
static
const
std::string filter =
45
"/message/active[@xmlns='"
+
XMLNS_CHAT_STATES
+
"']"
46
"|/message/composing[@xmlns='"
+
XMLNS_CHAT_STATES
+
"']"
47
"|/message/paused[@xmlns='"
+
XMLNS_CHAT_STATES
+
"']"
48
"|/message/inactive[@xmlns='"
+
XMLNS_CHAT_STATES
+
"']"
49
"|/message/gone[@xmlns='"
+
XMLNS_CHAT_STATES
+
"']"
;
50
return
filter;
51
}
52
53
Tag
*
ChatState::tag
()
const
54
{
55
if
( m_state ==
ChatStateInvalid
)
56
return
0;
57
58
return
new
Tag
( util::lookup2( m_state, stateValues ),
XMLNS
,
XMLNS_CHAT_STATES
);
59
}
60
61
}
Generated on Tue Oct 15 2013 19:25:20 for gloox by
1.8.1.2