29 #include <pjsip_simple.h>
34 #include "asterisk/res_pjsip.h"
35 #include "asterisk/res_pjsip_pubsub.h"
36 #include "asterisk/res_pjsip_presence_xml.h"
37 #include "asterisk/res_pjsip_body_generator_types.h"
39 static int pidf_supplement_body(
void *body,
void *data)
53 if (!(node = ast_sip_presence_xml_create_node(
54 state_data->
pool, body,
"tuple"))) {
55 ast_log(LOG_WARNING,
"Unable to create PIDF tuple\n");
59 ast_sip_presence_xml_create_attr(
60 state_data->
pool, node,
"id",
"digium-presence");
62 if (!(node = ast_sip_presence_xml_create_node(
63 state_data->
pool, node,
"status"))) {
64 ast_log(LOG_WARNING,
"Unable to create PIDF tuple status\n");
68 if (!(node = ast_sip_presence_xml_create_node(
69 state_data->
pool, node,
"digium_presence"))) {
70 ast_log(LOG_WARNING,
"Unable to create digium presence\n");
75 ast_sip_sanitize_xml(state_data->
presence_message, sanitized,
sizeof(sanitized));
76 pj_strdup2(state_data->
pool, &node->content, sanitized);
79 ast_sip_presence_xml_create_attr(
84 ast_sip_sanitize_xml(state_data->
presence_subtype, sanitized,
sizeof(sanitized));
85 ast_sip_presence_xml_create_attr(
86 state_data->
pool, node,
"subtype", sanitized);
93 .
type =
"application",
94 .subtype =
"pidf+xml",
95 .supplement_body = pidf_supplement_body,
98 static int load_module(
void)
100 if (ast_sip_pubsub_register_body_supplement(&pidf_supplement)) {
106 static int unload_module(
void)
108 ast_sip_pubsub_unregister_body_supplement(&pidf_supplement);
112 AST_MODULE_INFO(
ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER,
"PJSIP PIDF Sangoma presence supplement",
113 .support_level = AST_MODULE_SUPPORT_CORE,
115 .unload = unload_module,
117 .requires =
"res_pjsip,res_pjsip_pubsub",
Asterisk main include file. File version handling, generic pbx functions.
const char * type
Content type In "plain/text", "plain" is the type.
enum ast_presence_state presence_state
Presence state management.
Module has failed to load, may be in an inconsistent state.
structure used for presence XML bodies
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
const char * ast_presence_state2str(enum ast_presence_state state)
Convert presence state to text string for output.