gloox
1.0.24
src
chatstate.cpp
1
/*
2
Copyright (c) 2007-2019 by Jakob Schröter <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
static_cast<
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
}
gloox::StanzaExtension
This class abstracts a stanza extension, which is usually an XML child element in a specific namespac...
Definition:
stanzaextension.h:204
gloox::ExtChatState
@ ExtChatState
Definition:
stanzaextension.h:50
gloox::ChatState::ChatState
ChatState(const Tag *tag)
Definition:
chatstate.cpp:34
gloox::ChatStateInvalid
@ ChatStateInvalid
Definition:
gloox.h:1112
gloox::ChatState::tag
Tag * tag() const
Definition:
chatstate.cpp:53
gloox::ChatStateType
ChatStateType
Definition:
gloox.h:1105
gloox::XMLNS
const std::string XMLNS
Definition:
gloox.cpp:122
gloox::XMLNS_CHAT_STATES
const std::string XMLNS_CHAT_STATES
Definition:
gloox.cpp:30
gloox
The namespace for the gloox library.
Definition:
adhoc.cpp:28
gloox::Tag
This is an abstraction of an XML element.
Definition:
tag.h:47
gloox::ChatState::filterString
virtual const std::string & filterString() const
Definition:
chatstate.cpp:42
gloox::Tag::name
const std::string & name() const
Definition:
tag.h:394
Generated on Mon Aug 17 2020 01:21:43 for gloox by
1.8.18