Add file that apparently got missed in the merge.
[asterisk/asterisk.git] / include / asterisk / res_pjsip_presence_xml.h
1 /*
2  * asterisk -- An open source telephony toolkit.
3  *
4  * Copyright (C) 2014, Digium, Inc.
5  *
6  * Mark Michelson <mmichelson@digium.com>
7  *
8  * See http://www.asterisk.org for more information about
9  * the Asterisk project. Please do not directly contact
10  * any of the maintainers of this project for assistance;
11  * the project provides a web site, mailing lists and IRC
12  * channels for your use.
13  *
14  * This program is free software, distributed under the terms of
15  * the GNU General Public License Version 2. See the LICENSE file
16  * at the top of the source tree.
17  */
18
19 /*!
20  * PIDF state
21  */
22 enum ast_sip_pidf_state {
23         /*! Device is not in use */
24         NOTIFY_OPEN,
25         /*! Device is in use or ringing */
26         NOTIFY_INUSE,
27         /*! Device is unavailable, on hold, or busy */
28         NOTIFY_CLOSED
29 };
30
31 /*!
32  * \brief Replace offensive XML characters with XML entities
33  *
34  * " = &quot;
35  * < = &lt;
36  * > = &gt;
37  * ' = &apos;
38  * & = &amp;
39  *
40  * \param input String to sanitize
41  * \param[out] output Sanitized string
42  * \param len Size of output buffer
43  */
44 void ast_sip_sanitize_xml(const char *input, char *output, size_t len);
45
46 /*!
47  * \brief Convert extension state to relevant PIDF strings
48  *
49  * \param state The extension state
50  * \param[out] statestring
51  * \param[out] pidfstate
52  * \param[out] pidfnote
53  * \param[out] local_state
54  */
55 void ast_sip_presence_exten_state_to_str(int state, char **statestring,
56                 char **pidfstate, char **pidfnote, enum ast_sip_pidf_state *local_state);
57
58 /*!
59  * \brief Create XML attribute
60  *
61  * \param pool Allocation pool
62  * \param node Node to add attribute to
63  * \param name The attribute name
64  * \param value The attribute value
65  *
66  * \return The created attribute
67  */
68 pj_xml_attr *ast_sip_presence_xml_create_attr(pj_pool_t *pool,
69                 pj_xml_node *node, const char *name, const char *value);
70
71 /*!
72  * \brief Create XML node
73  *
74  * \param pool Allocation pool
75  * \param parent Node that will be parent to the created node
76  * \param name The name for the new node
77  * \return The created node
78  */
79 pj_xml_node *ast_sip_presence_xml_create_node(pj_pool_t *pool,
80                 pj_xml_node *parent, const char* name);
81
82 /*!
83  * \brief Find an attribute within a given node
84  *
85  * Given a starting node, this will find an attribute that belongs
86  * to a specific node. If the node does not exist, it will be created
87  * under the passed-in parent. If the attribute does not exist, then
88  * it will be created on the node with an empty string as its value.
89  *
90  * \param pool Allocation pool
91  * \param parent Starting node for search
92  * \param node_name Name of node where to find attribute
93  * \param attr_name Name of attribute to find
94  * \param[out] node Node that was found or created
95  * \param[out] attr Attribute that was found or created
96  * \return The found attribute
97  */
98 void ast_sip_presence_xml_find_node_attr(pj_pool_t* pool,
99                 pj_xml_node *parent, const char *node_name, const char *attr_name,
100                 pj_xml_node **node, pj_xml_attr **attr);