Asterisk - The Open Source Telephony Project  18.5.0
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 = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "30ef0c93b36035ec78c9cfd712d36d9b" , .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.

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

Referenced by pidf_supplement_body().

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 }
Definition: test_heap.c:38
static pj_pool_t * pool
Global memory pool for configuration and timers.
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.
Definition: presence_xml.c:140
#define ast_alloca(size)
call __builtin_alloca to ensure we get gcc builtin semantics
Definition: astmm.h:290
pj_xml_node * ast_sip_presence_xml_create_node(pj_pool_t *pool, pj_xml_node *parent, const char *name)
Create XML node.
Definition: presence_xml.c:152

◆ 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.

References AST_MODULE_LOAD_DECLINE, AST_MODULE_LOAD_SUCCESS, and ast_sip_pubsub_register_body_supplement().

Referenced by unload_module().

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

◆ 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.

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.

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)
enum ast_extension_states exten_state
#define NULL
Definition: resample.c:96
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.
Definition: presence_xml.c:84
structure used for presence XML bodies
ast_sip_pidf_state

◆ unload_module()

static int unload_module ( void  )
static

Definition at line 101 of file res_pjsip_pidf_eyebeam_body_supplement.c.

References AST_MODFLAG_LOAD_ORDER, AST_MODPRI_CHANNEL_DEPEND, AST_MODULE_INFO(), AST_MODULE_SUPPORT_CORE, ast_sip_pubsub_unregister_body_supplement(), ASTERISK_GPL_KEY, and load_module().

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

Variable Documentation

◆ __mod_info

struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_LOAD_ORDER , .description = "PJSIP PIDF Eyebeam supplement" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = "30ef0c93b36035ec78c9cfd712d36d9b" , .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.