gloox
1.1-svn
Main Page
Related Pages
Namespaces
Classes
Files
File List
src
chatstate.cpp
1
/*
2
Copyright (c) 2007-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
#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
{
37
if
( tag )
38
m_state = chatStateType( tag->
name
() );
39
}
40
41
const
std::string&
ChatState::filterString
()
const
42
{
43
static
const
std::string filter =
44
"/message/active[@xmlns='"
+
XMLNS_CHAT_STATES
+
"']"
45
"|/message/composing[@xmlns='"
+
XMLNS_CHAT_STATES
+
"']"
46
"|/message/paused[@xmlns='"
+
XMLNS_CHAT_STATES
+
"']"
47
"|/message/inactive[@xmlns='"
+
XMLNS_CHAT_STATES
+
"']"
48
"|/message/gone[@xmlns='"
+
XMLNS_CHAT_STATES
+
"']"
;
49
return
filter;
50
}
51
52
Tag
*
ChatState::tag
()
const
53
{
54
if
( m_state ==
ChatStateInvalid
)
55
return
0;
56
57
return
new
Tag
( util::lookup2( m_state, stateValues ),
XMLNS
,
XMLNS_CHAT_STATES
);
58
}
59
60
}
Generated on Thu Jun 27 2013 13:43:26 for gloox by
1.8.1.2