Asterisk - The Open Source Telephony Project GIT-master-b023714
Loading...
Searching...
No Matches
Functions | Variables
res_pjsip_pidf_eyebeam_body_supplement.c File Reference
#include "asterisk.h"
#include <pjsip.h>
#include <pjsip_simple.h>
#include <pjlib.h>
#include "asterisk/module.h"
#include "asterisk/res_pjsip.h"
#include "asterisk/res_pjsip_pubsub.h"
#include "asterisk/res_pjsip_presence_xml.h"
#include "asterisk/res_pjsip_body_generator_types.h"
Include dependency graph for res_pjsip_pidf_eyebeam_body_supplement.c:

Go to the source code of this file.

Functions

static void __reg_module (void)
 
static void __unreg_module (void)
 
static void add_eyebeam (pj_pool_t *pool, pj_xml_node *node, const char *pidfstate)
 
struct ast_moduleAST_MODULE_SELF_SYM (void)
 
static int load_module (void)
 
static int pidf_supplement_body (void *body, void *data)
 
static int unload_module (void)
 

Variables

static struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "PJSIP PIDF Eyebeam supplement" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_CHANNEL_DEPEND, .requires = "res_pjsip,res_pjsip_pubsub", }
 
static const struct ast_module_infoast_module_info = &__mod_info
 
static struct ast_sip_pubsub_body_supplement pidf_supplement
 

Function Documentation

◆ __reg_module()

static void __reg_module ( void  )
static

Definition at line 113 of file res_pjsip_pidf_eyebeam_body_supplement.c.

◆ __unreg_module()

static void __unreg_module ( void  )
static

Definition at line 113 of file res_pjsip_pidf_eyebeam_body_supplement.c.

◆ add_eyebeam()

static void add_eyebeam ( pj_pool_t *  pool,
pj_xml_node *  node,
const char *  pidfstate 
)
static

Definition at line 47 of file res_pjsip_pidf_eyebeam_body_supplement.c.

48{
49 static const char *XMLNS_DM_PREFIX = "xmlns:dm";
50 static const char *XMLNS_DM = "urn:ietf:params:xml:ns:pidf:data-model";
51
52 static const char *XMLNS_RPID_PREFIX = "xmlns:rpid";
53 static const char *XMLNS_RPID = "urn:ietf:params:xml:ns:pidf:rpid";
54
55 pj_xml_node *person = ast_sip_presence_xml_create_node(pool, node, "dm:person");
56
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);
60 char *act_str = ast_alloca(str_size);
61
62 /* Safe */
63 strcpy(act_str, "rpid:");
64 strcat(act_str, pidfstate);
65
66 ast_sip_presence_xml_create_node(pool, activities, act_str);
67 }
68
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);
71}
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
Definition astmm.h:288
pj_xml_node * ast_sip_presence_xml_create_node(pj_pool_t *pool, pj_xml_node *parent, const char *name)
Create XML node.
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.

References ast_alloca, ast_sip_presence_xml_create_attr(), and ast_sip_presence_xml_create_node().

Referenced by pidf_supplement_body().

◆ AST_MODULE_SELF_SYM()

struct ast_module * AST_MODULE_SELF_SYM ( void  )

Definition at line 113 of file res_pjsip_pidf_eyebeam_body_supplement.c.

◆ load_module()

static int load_module ( void  )
static

Definition at line 93 of file res_pjsip_pidf_eyebeam_body_supplement.c.

94{
97 }
99}
@ AST_MODULE_LOAD_SUCCESS
Definition module.h:70
@ AST_MODULE_LOAD_DECLINE
Module has failed to load, may be in an inconsistent state.
Definition module.h:78
static struct ast_sip_pubsub_body_supplement pidf_supplement
int ast_sip_pubsub_register_body_supplement(struct ast_sip_pubsub_body_supplement *supplement)
Register a body generator with the pubsub core.

References AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, ast_sip_pubsub_register_body_supplement(), and pidf_supplement.

◆ pidf_supplement_body()

static int pidf_supplement_body ( void *  body,
void *  data 
)
static

Definition at line 73 of file res_pjsip_pidf_eyebeam_body_supplement.c.

74{
75 pjpidf_pres *pres = body;
76 struct ast_sip_exten_state_data *state_data = data;
77 char *statestring = NULL, *pidfstate = NULL, *pidfnote = NULL;
78 enum ast_sip_pidf_state local_state;
79
80 ast_sip_presence_exten_state_to_str(state_data->exten_state, &statestring,
81 &pidfstate, &pidfnote, &local_state, 0);
82
83 add_eyebeam(state_data->pool, pres, pidfstate);
84 return 0;
85}
static void add_eyebeam(pj_pool_t *pool, pj_xml_node *node, const char *pidfstate)
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.
#define NULL
Definition resample.c:96
structure used for presence XML bodies
enum ast_extension_states exten_state

References add_eyebeam(), ast_sip_presence_exten_state_to_str(), ast_sip_exten_state_data::exten_state, NULL, and ast_sip_exten_state_data::pool.

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 101 of file res_pjsip_pidf_eyebeam_body_supplement.c.

102{
104 return 0;
105}
void ast_sip_pubsub_unregister_body_supplement(struct ast_sip_pubsub_body_supplement *supplement)
Unregister a body generator with the pubsub core.

References ast_sip_pubsub_unregister_body_supplement(), and pidf_supplement.

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "PJSIP PIDF Eyebeam supplement" , .key = ASTERISK_GPL_KEY , .buildopt_sum = AST_BUILDOPT_SUM, .support_level = AST_MODULE_SUPPORT_CORE, .load = load_module, .unload = unload_module, .load_pri = AST_MODPRI_CHANNEL_DEPEND, .requires = "res_pjsip,res_pjsip_pubsub", }
static

Definition at line 113 of file res_pjsip_pidf_eyebeam_body_supplement.c.

◆ ast_module_info

const struct ast_module_info* ast_module_info = &__mod_info
static

Definition at line 113 of file res_pjsip_pidf_eyebeam_body_supplement.c.

◆ pidf_supplement

struct ast_sip_pubsub_body_supplement pidf_supplement
static
Initial value:
= {
.type = "application",
.subtype = "pidf+xml",
.supplement_body = pidf_supplement_body,
}
static int pidf_supplement_body(void *body, void *data)

Definition at line 87 of file res_pjsip_pidf_eyebeam_body_supplement.c.

87 {
88 .type = "application",
89 .subtype = "pidf+xml",
90 .supplement_body = pidf_supplement_body,
91};

Referenced by load_module(), and unload_module().