29 #include <pjsip_simple.h> 51 pjxpidf_pres *pres = body;
53 static pj_str_t STR_ADDR_PARAM = {
";user=ip", 8 };
54 char *statestring =
NULL, *pidfstate =
NULL, *pidfnote =
NULL;
58 char sanitized[PJSIP_MAX_URL_SIZE];
62 pj_xml_node *msnsubstatus;
65 &pidfstate, &pidfnote, &local_state, 0);
69 pj_strdup2(state_data->
pool, &attr->value, state_data->
exten);
72 "uri", &address, &attr);
76 uri.ptr = (
char*) pj_pool_alloc(state_data->
pool,
77 strlen(sanitized) + STR_ADDR_PARAM.slen);
78 pj_strcpy2( &uri, sanitized);
79 pj_strcat( &uri, &STR_ADDR_PARAM);
80 pj_strdup(state_data->
pool, &attr->value, &uri);
85 "status",
"status", &status, &attr);
86 pj_strdup2(state_data->
pool, &attr->value,
91 "msnsubstatus",
"substatus", &msnsubstatus, &attr);
92 pj_strdup2(state_data->
pool, &attr->value,
94 (local_state ==
NOTIFY_INUSE) ?
"onthephone" :
"offline");
99 #define MAX_STRING_GROWTHS 5 103 pjxpidf_pres *pres = body;
124 .
type =
"application",
125 .subtype =
"xpidf+xml",
134 .
type =
"application",
135 .subtype =
"cpim-pidf+xml",
177 .requires =
"res_pjsip,res_pjsip_pubsub",
Asterisk main include file. File version handling, generic pbx functions.
static int load_module(void)
const char * type
Content type In "plain/text", "plain" is the type.
size_t ast_str_size(const struct ast_str *buf)
Returns the current maximum length (without reallocation) of the current buffer.
static int xpidf_generate_body_content(void *body, void *data)
#define ast_str_make_space(buf, new_len)
char * ast_str_buffer(const struct ast_str *buf)
Returns the string buffer within the ast_str buf.
static struct ast_sip_pubsub_body_generator xpidf_body_generator
pj_xml_attr * ast_sip_presence_xml_create_attr(pj_pool_t *pool, pj_xml_node *node, const char *name, const char *value)
Create XML attribute.
static int unload_module(void)
char remote[PJSIP_MAX_URL_SIZE]
enum ast_extension_states exten_state
int ast_sip_pubsub_register_body_generator(struct ast_sip_pubsub_body_generator *generator)
Register a body generator with the pubsub core.
#define AST_SIP_EXTEN_STATE_DATA
char * ast_strip_quoted(char *s, const char *beg_quotes, const char *end_quotes)
Strip leading/trailing whitespace and quotes from a string.
void ast_sip_presence_exten_state_to_str(int state, char **statestring, char **pidfstate, char **pidfnote, enum ast_sip_pidf_state *local_state, unsigned int notify_early_inuse_ringing)
Convert extension state to relevant PIDF strings.
static void xpidf_to_string(void *body, struct ast_str **str)
#define ast_strdupa(s)
duplicate a string in memory from the stack
static void unregister_all(void)
#define AST_PJSIP_XML_PROLOG_LEN
Length of the XML prolog when printing presence or other XML in PJSIP.
char local[PJSIP_MAX_URL_SIZE]
static void * xpidf_allocate_body(void *data)
The descriptor of a dynamic string XXX storage will be optimized later if needed We use the ts field ...
Module has failed to load, may be in an inconsistent state.
void ast_sip_sanitize_xml(const char *input, char *output, size_t len)
Replace offensive XML characters with XML entities.
static struct ast_sip_pubsub_body_generator cpim_pidf_body_generator
AST_MODULE_INFO(ASTERISK_GPL_KEY, AST_MODFLAG_GLOBAL_SYMBOLS|AST_MODFLAG_LOAD_ORDER, "HTTP Phone Provisioning",.support_level=AST_MODULE_SUPPORT_EXTENDED,.load=load_module,.unload=unload_module,.reload=reload,.load_pri=AST_MODPRI_CHANNEL_DEPEND,.requires="http",)
structure used for presence XML bodies
void ast_str_update(struct ast_str *buf)
Update the length of the buffer, after using ast_str merely as a buffer.
#define MAX_STRING_GROWTHS
#define ASTERISK_GPL_KEY
The text the key() function should return.
Asterisk module definitions.
void ast_sip_presence_xml_find_node_attr(pj_pool_t *pool, pj_xml_node *parent, const char *node_name, const char *attr_name, pj_xml_node **node, pj_xml_attr **attr)
Find an attribute within a given node.
void ast_sip_pubsub_unregister_body_generator(struct ast_sip_pubsub_body_generator *generator)
Unregister a body generator with the pubsub core.