From 23c7dff74e580a06adb8b2d22a35d3c4771cfae8 Mon Sep 17 00:00:00 2001 From: Mark Michelson Date: Thu, 7 Aug 2014 19:42:43 +0000 Subject: [PATCH] Revert previous patch since it had some unreviewed content in it. git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/12@420386 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- include/asterisk/res_pjsip_pubsub.h | 21 +----------------- main/bridge.c | 8 ++----- res/res_pjsip_dialog_info_body_generator.c | 1 - res/res_pjsip_exten_state.c | 8 +------ res/res_pjsip_mwi.c | 7 +----- res/res_pjsip_mwi_body_generator.c | 1 - res/res_pjsip_pidf_body_generator.c | 1 - res/res_pjsip_pubsub.c | 25 ++++++---------------- res/res_pjsip_xpidf_body_generator.c | 2 -- 9 files changed, 12 insertions(+), 62 deletions(-) diff --git a/include/asterisk/res_pjsip_pubsub.h b/include/asterisk/res_pjsip_pubsub.h index 128379d078..d46cbae30d 100644 --- a/include/asterisk/res_pjsip_pubsub.h +++ b/include/asterisk/res_pjsip_pubsub.h @@ -221,18 +221,11 @@ struct ast_sip_subscription_response_data { struct ast_sip_body *body; }; -/*! - * \brief Type information for NOTIFY/PUBLISH body data - */ -#define AST_SIP_EXTEN_STATE_DATA "ast_sip_exten_state_data" -#define AST_SIP_MESSAGE_ACCUMULATOR "ast_sip_message_accumulator" - #define AST_SIP_MAX_ACCEPT 32 struct ast_sip_subscription_handler { /*! The name of the event this handler deals with */ const char *event_name; - const char *body_type; /*! The types of body this handler accepts. * * \note This option has no bearing when the handler is used in the @@ -573,8 +566,6 @@ struct ast_sip_pubsub_body_generator { * In "plain/text", "text" is the subtype */ const char *subtype; - /*! The type of body that the body generator takes as input */ - const char *body_type; /*! * \brief allocate body structure. * @@ -654,16 +645,6 @@ struct ast_sip_pubsub_body_supplement { AST_LIST_ENTRY(ast_sip_pubsub_body_supplement) list; }; -/*! - * \brief Data used to create bodies for NOTIFY/PUBLISH requests. - */ -struct ast_sip_body_data { - /*! The type of the data */ - const char *body_type; - /*! The actual data from which the body is generated */ - void *body_data; -}; - /*! * \since 13.0.0 * \brief Generate body content for a PUBLISH or NOTIFY @@ -681,7 +662,7 @@ struct ast_sip_body_data { * \retval non-zero Failure */ int ast_sip_pubsub_generate_body_content(const char *content_type, - const char *content_subtype, struct ast_sip_body_data *data, struct ast_str **str); + const char *content_subtype, void *data, struct ast_str **str); /*! * \since 13.0.0 diff --git a/main/bridge.c b/main/bridge.c index fb77fcb6b3..a2d3438d28 100644 --- a/main/bridge.c +++ b/main/bridge.c @@ -3879,12 +3879,8 @@ static void stasis_publish_data_init(struct ast_channel *to_transferee, publication->to_transfer_target.bridge = to_target_bridge; } - if (to_transferee_bridge) { - publication->transferee_channel = ast_bridge_peer(to_transferee_bridge, to_transferee); - } - if (to_target_bridge) { - publication->target_channel = ast_bridge_peer(to_target_bridge, to_transfer_target); - } + publication->transferee_channel = ast_bridge_peer(to_transferee_bridge, to_transferee); + publication->target_channel = ast_bridge_peer(to_target_bridge, to_transfer_target); } /* diff --git a/res/res_pjsip_dialog_info_body_generator.c b/res/res_pjsip_dialog_info_body_generator.c index f7045e594b..c6d53dc7b3 100644 --- a/res/res_pjsip_dialog_info_body_generator.c +++ b/res/res_pjsip_dialog_info_body_generator.c @@ -187,7 +187,6 @@ static void dialog_info_to_string(void *body, struct ast_str **str) static struct ast_sip_pubsub_body_generator dialog_info_body_generator = { .type = "application", .subtype = "dialog-info+xml", - .body_type = AST_SIP_EXTEN_STATE_DATA, .allocate_body = dialog_info_allocate_body, .generate_body_content = dialog_info_generate_body_content, .to_string = dialog_info_to_string, diff --git a/res/res_pjsip_exten_state.c b/res/res_pjsip_exten_state.c index 2e133f926e..e452b240d7 100644 --- a/res/res_pjsip_exten_state.c +++ b/res/res_pjsip_exten_state.c @@ -81,7 +81,6 @@ static void to_ami(struct ast_sip_subscription *sub, struct ast_sip_subscription_handler presence_handler = { .event_name = "presence", - .body_type = AST_SIP_EXTEN_STATE_DATA, .accept = { DEFAULT_PRESENCE_BODY, }, .default_accept = DEFAULT_PRESENCE_BODY, .subscription_shutdown = subscription_shutdown, @@ -94,7 +93,6 @@ struct ast_sip_subscription_handler presence_handler = { struct ast_sip_subscription_handler dialog_handler = { .event_name = "dialog", - .body_type = AST_SIP_EXTEN_STATE_DATA, .accept = { DEFAULT_DIALOG_BODY, }, .default_accept = DEFAULT_DIALOG_BODY, .subscription_shutdown = subscription_shutdown, @@ -182,16 +180,12 @@ static void create_send_notify(struct exten_state_subscription *exten_state_sub, const pj_str_t *reason_str_ptr = NULL; pjsip_tx_data *tdata; struct ast_sip_body body; - struct ast_sip_body_data body_data = { - .body_type = AST_SIP_EXTEN_STATE_DATA, - .body_data = exten_state_data, - }; body.type = ast_sip_subscription_get_body_type(exten_state_sub->sip_sub); body.subtype = ast_sip_subscription_get_body_subtype(exten_state_sub->sip_sub); if (ast_sip_pubsub_generate_body_content(body.type, body.subtype, - &body_data, &body_text)) { + exten_state_data, &body_text)) { ast_log(LOG_ERROR, "Unable to create body on NOTIFY request\n"); return; } diff --git a/res/res_pjsip_mwi.c b/res/res_pjsip_mwi.c index f30e494478..f25a7c48f9 100644 --- a/res/res_pjsip_mwi.c +++ b/res/res_pjsip_mwi.c @@ -63,7 +63,6 @@ static void mwi_to_ami(struct ast_sip_subscription *sub, struct ast_str **buf); static struct ast_sip_subscription_handler mwi_handler = { .event_name = "message-summary", - .body_type = AST_SIP_MESSAGE_ACCUMULATOR, .accept = { MWI_TYPE"/"MWI_SUBTYPE, }, .default_accept = MWI_TYPE"/"MWI_SUBTYPE, .subscription_shutdown = mwi_subscription_shutdown, @@ -433,10 +432,6 @@ static void send_mwi_notify(struct mwi_subscription *sub, pjsip_evsub_state stat pjsip_tx_data *tdata; pj_str_t reason_str; struct ast_sip_body body; - struct ast_sip_body_data body_data = { - .body_type = AST_SIP_MESSAGE_ACCUMULATOR, - .body_data = &counter, - }; body.type = sub->is_solicited ? ast_sip_subscription_get_body_type(sub->sip_sub) : @@ -453,7 +448,7 @@ static void send_mwi_notify(struct mwi_subscription *sub, pjsip_evsub_state stat reason_str_ptr = &reason_str; } - if (ast_sip_pubsub_generate_body_content(body.type, body.subtype, &body_data, &body_text)) { + if (ast_sip_pubsub_generate_body_content(body.type, body.subtype, &counter, &body_text)) { ast_log(LOG_WARNING, "Unable to generate SIP MWI NOTIFY body.\n"); return; } diff --git a/res/res_pjsip_mwi_body_generator.c b/res/res_pjsip_mwi_body_generator.c index 4e6f814d80..9a721dbf47 100644 --- a/res/res_pjsip_mwi_body_generator.c +++ b/res/res_pjsip_mwi_body_generator.c @@ -85,7 +85,6 @@ static void mwi_destroy_body(void *body) static struct ast_sip_pubsub_body_generator mwi_generator = { .type = MWI_TYPE, .subtype = MWI_SUBTYPE, - .body_type = AST_SIP_MESSAGE_ACCUMULATOR, .allocate_body = mwi_allocate_body, .generate_body_content = mwi_generate_body_content, .to_string = mwi_to_string, diff --git a/res/res_pjsip_pidf_body_generator.c b/res/res_pjsip_pidf_body_generator.c index cd4840e13a..2c99f5cfda 100644 --- a/res/res_pjsip_pidf_body_generator.c +++ b/res/res_pjsip_pidf_body_generator.c @@ -109,7 +109,6 @@ static void pidf_to_string(void *body, struct ast_str **str) static struct ast_sip_pubsub_body_generator pidf_body_generator = { .type = "application", .subtype = "pidf+xml", - .body_type = AST_SIP_EXTEN_STATE_DATA, .allocate_body = pidf_allocate_body, .generate_body_content = pidf_generate_body_content, .to_string = pidf_to_string, diff --git a/res/res_pjsip_pubsub.c b/res/res_pjsip_pubsub.c index f4d9dbc253..be97991baa 100644 --- a/res/res_pjsip_pubsub.c +++ b/res/res_pjsip_pubsub.c @@ -366,7 +366,7 @@ static void subscription_persistence_remove(struct ast_sip_subscription *sub) static struct ast_sip_subscription_handler *find_sub_handler_for_event_name(const char *event_name); static struct ast_sip_pubsub_body_generator *find_body_generator(char accept[AST_SIP_MAX_ACCEPT][64], - size_t num_accept, const char *body_type); + size_t num_accept); /*! \brief Retrieve a handler using the Event header of an rdata message */ static struct ast_sip_subscription_handler *subscription_get_handler_from_rdata(pjsip_rx_data *rdata) @@ -414,7 +414,7 @@ static struct ast_sip_pubsub_body_generator *subscription_get_generator_from_rda num_accept_headers = 1; } - return find_body_generator(accept, num_accept_headers, handler->body_type); + return find_body_generator(accept, num_accept_headers); } /*! \brief Callback function to perform the actual recreation of a subscription */ @@ -1092,7 +1092,7 @@ static struct ast_sip_pubsub_body_generator *find_body_generator_accept(const ch } static struct ast_sip_pubsub_body_generator *find_body_generator(char accept[AST_SIP_MAX_ACCEPT][64], - size_t num_accept, const char *body_type) + size_t num_accept) { int i; struct ast_sip_pubsub_body_generator *generator = NULL; @@ -1101,12 +1101,6 @@ static struct ast_sip_pubsub_body_generator *find_body_generator(char accept[AST generator = find_body_generator_accept(accept[i]); if (generator) { ast_debug(3, "Body generator %p found for accept type %s\n", generator, accept[i]); - if (strcmp(generator->body_type, body_type)) { - ast_log(LOG_WARNING, "Body generator '%s/%s'(%p) does not accept the type of data this event generates\n", - generator->type, generator->subtype, generator); - generator = NULL; - continue; - } break; } else { ast_debug(3, "No body generator found for accept type %s\n", accept[i]); @@ -1517,7 +1511,7 @@ const char *ast_sip_subscription_get_body_subtype(struct ast_sip_subscription *s } int ast_sip_pubsub_generate_body_content(const char *type, const char *subtype, - struct ast_sip_body_data *data, struct ast_str **str) + void *data, struct ast_str **str) { struct ast_sip_pubsub_body_supplement *supplement; struct ast_sip_pubsub_body_generator *generator; @@ -1531,19 +1525,14 @@ int ast_sip_pubsub_generate_body_content(const char *type, const char *subtype, return -1; } - if (strcmp(data->body_type, generator->body_type)) { - ast_log(LOG_WARNING, "Body generator does not accept the type of data provided\n"); - return -1; - } - - body = generator->allocate_body(data->body_data); + body = generator->allocate_body(data); if (!body) { ast_log(LOG_WARNING, "Unable to allocate a NOTIFY body of type %s/%s\n", type, subtype); return -1; } - if (generator->generate_body_content(body, data->body_data)) { + if (generator->generate_body_content(body, data)) { res = -1; goto end; } @@ -1552,7 +1541,7 @@ int ast_sip_pubsub_generate_body_content(const char *type, const char *subtype, AST_RWLIST_TRAVERSE(&body_supplements, supplement, list) { if (!strcmp(generator->type, supplement->type) && !strcmp(generator->subtype, supplement->subtype)) { - res = supplement->supplement_body(body, data->body_data); + res = supplement->supplement_body(body, data); if (res) { break; } diff --git a/res/res_pjsip_xpidf_body_generator.c b/res/res_pjsip_xpidf_body_generator.c index 42158ef39c..a844cab936 100644 --- a/res/res_pjsip_xpidf_body_generator.c +++ b/res/res_pjsip_xpidf_body_generator.c @@ -126,7 +126,6 @@ static void xpidf_to_string(void *body, struct ast_str **str) static struct ast_sip_pubsub_body_generator xpidf_body_generator = { .type = "application", .subtype = "xpidf+xml", - .body_type = AST_SIP_EXTEN_STATE_DATA, .allocate_body = xpidf_allocate_body, .generate_body_content = xpidf_generate_body_content, .to_string = xpidf_to_string, @@ -136,7 +135,6 @@ static struct ast_sip_pubsub_body_generator xpidf_body_generator = { static struct ast_sip_pubsub_body_generator cpim_pidf_body_generator = { .type = "application", .subtype = "cpim-pidf+xml", - .body_type = AST_SIP_EXTEN_STATE_DATA, .allocate_body = xpidf_allocate_body, .generate_body_content = xpidf_generate_body_content, .to_string = xpidf_to_string, -- 2.47.2