29 #include <pjsip_simple.h>
33 #include "asterisk/res_pjsip.h"
34 #include "asterisk/res_pjsip_pubsub.h"
35 #include "asterisk/res_pjsip_presence_xml.h"
36 #include "asterisk/res_pjsip_body_generator_types.h"
47 static void add_eyebeam(pj_pool_t *
pool, pj_xml_node *
node,
const char *pidfstate)
49 static const char *XMLNS_DM_PREFIX =
"xmlns:dm";
50 static const char *XMLNS_DM =
"urn:ietf:params:xml:ns:pidf:data-model";
52 static const char *XMLNS_RPID_PREFIX =
"xmlns:rpid";
53 static const char *XMLNS_RPID =
"urn:ietf:params:xml:ns:pidf:rpid";
55 pj_xml_node *person = ast_sip_presence_xml_create_node(pool, node,
"dm:person");
57 if (pidfstate[0] !=
'-') {
58 pj_xml_node *activities = ast_sip_presence_xml_create_node(pool, person,
"rpid:activities");
59 size_t str_size =
sizeof(
"rpid:") + strlen(pidfstate);
63 strcpy(act_str,
"rpid:");
64 strcat(act_str, pidfstate);
66 ast_sip_presence_xml_create_node(pool, activities, act_str);
69 ast_sip_presence_xml_create_attr(pool, node, XMLNS_DM_PREFIX, XMLNS_DM);
70 ast_sip_presence_xml_create_attr(pool, node, XMLNS_RPID_PREFIX, XMLNS_RPID);
73 static int pidf_supplement_body(
void *body,
void *data)
75 pjpidf_pres *pres = body;
77 char *statestring = NULL, *pidfstate = NULL, *pidfnote = NULL;
78 enum ast_sip_pidf_state local_state;
80 ast_sip_presence_exten_state_to_str(state_data->
exten_state, &statestring,
81 &pidfstate, &pidfnote, &local_state, 0);
83 add_eyebeam(state_data->
pool, pres, pidfstate);
88 .
type =
"application",
89 .subtype =
"pidf+xml",
90 .supplement_body = pidf_supplement_body,
93 static int load_module(
void)
95 if (ast_sip_pubsub_register_body_supplement(&pidf_supplement)) {
101 static int unload_module(
void)
103 ast_sip_pubsub_unregister_body_supplement(&pidf_supplement);
107 AST_MODULE_INFO(
ASTERISK_GPL_KEY, AST_MODFLAG_LOAD_ORDER,
"PJSIP PIDF Eyebeam supplement",
108 .support_level = AST_MODULE_SUPPORT_CORE,
110 .unload = unload_module,
112 .requires =
"res_pjsip,res_pjsip_pubsub",
Asterisk main include file. File version handling, generic pbx functions.
static pj_pool_t * pool
Global memory pool for configuration and timers.
enum ast_extension_states exten_state
const char * type
Content type In "plain/text", "plain" is the type.
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
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.