return r;
}
+
+SWITCH_DECLARE(void) switch_channel_set_presence_data_vals(switch_channel_t *channel, const char *presence_data_cols)
+{
+ if (!zstr(presence_data_cols)) {
+ char *cols[128] = { 0 };
+ char header_name[128] = "";
+ int col_count = 0, i = 0;
+ char *data_copy = NULL;
+
+ if (zstr(presence_data_cols)) {
+ presence_data_cols = switch_channel_get_variable_dup(channel, "presence_data_cols", SWITCH_FALSE, -1);
+ if (zstr(presence_data_cols)) {
+ return;
+ }
+ }
+
+ data_copy = strdup(presence_data_cols);
+
+ col_count = switch_split(data_copy, ':', cols);
+
+ for (i = 0; i < col_count; i++) {
+ const char *val = NULL;
+ switch_snprintf(header_name, sizeof(header_name), "PD-%s", cols[i]);
+ val = switch_channel_get_variable(channel, cols[i]);
+ switch_channel_set_profile_var(channel, header_name, val);
+ }
+
+ switch_safe_free(data_copy);
+ }
+}
+
+
SWITCH_DECLARE(switch_status_t) switch_channel_set_variable_var_check(switch_channel_t *channel,
const char *varname, const char *value, switch_bool_t var_check)
{
if ((v = switch_channel_get_variable(channel, "presence_data_cols"))) {
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Presence-Data-Cols", v);
+ switch_event_add_presence_data_cols(channel, event, "PD-");
}
if ((v = switch_channel_get_variable(channel, "call_uuid"))) {
return r;
}
+SWITCH_DECLARE(void) switch_event_add_presence_data_cols(switch_channel_t *channel, switch_event_t *event, const char *prefix)
+{
+ const char *data;
+
+ if (!prefix) prefix = "";
+
+ if ((data = switch_channel_get_variable(channel, "presence_data_cols"))) {
+ char *cols[128] = { 0 };
+ char header_name[128] = "";
+ int col_count = 0, i = 0;
+ char *data_copy = NULL;
+ data_copy = strdup(data);
+
+ col_count = switch_split(data_copy, ':', cols);
+
+ for (i = 0; i < col_count; i++) {
+ const char *val = NULL;
+ switch_snprintf(header_name, sizeof(header_name), "%s%s", prefix, cols[i]);
+
+ val = switch_channel_get_variable(channel, cols[i]);
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, header_name, val);
+ }
+
+ switch_safe_free(data_copy);
+ }
+
+}
/* For Emacs:
if (switch_channel_test_flag(channel, CF_BRIDGE_ORIGINATOR)) {
if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_BRIDGE) == SWITCH_STATUS_SUCCESS) {
+ switch_core_session_t *other_session;
+
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridge-A-Unique-ID", switch_core_session_get_uuid(session));
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridge-B-Unique-ID", msg.string_arg);
switch_channel_event_set_data(channel, event);
+ if ((other_session = switch_core_session_locate(msg.string_arg))) {
+ switch_channel_t *other_channel = switch_core_session_get_channel(other_session);
+ switch_event_add_presence_data_cols(other_channel, event, "Bridge-B-PD-");
+ switch_core_session_rwunlock(other_session);
+ }
switch_event_fire(&event);
}
}
}
}
- switch_core_session_rwunlock(other_session);
- }
+ if (switch_channel_test_flag(channel, CF_BRIDGE_ORIGINATOR)) {
+ switch_channel_clear_flag_recursive(channel, CF_BRIDGE_ORIGINATOR);
+ if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_UNBRIDGE) == SWITCH_STATUS_SUCCESS) {
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridge-A-Unique-ID", switch_core_session_get_uuid(session));
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridge-B-Unique-ID", uuid);
+ switch_event_add_presence_data_cols(other_channel, event, "Bridge-B-PD-");
+ switch_channel_event_set_data(channel, event);
+ switch_event_fire(&event);
+ }
+ }
- if (switch_channel_test_flag(channel, CF_BRIDGE_ORIGINATOR)) {
- switch_channel_clear_flag_recursive(channel, CF_BRIDGE_ORIGINATOR);
- if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_UNBRIDGE) == SWITCH_STATUS_SUCCESS) {
- switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridge-A-Unique-ID", switch_core_session_get_uuid(session));
- switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridge-B-Unique-ID", uuid);
- switch_channel_event_set_data(channel, event);
- switch_event_fire(&event);
+ switch_core_session_rwunlock(other_session);
+ } else {
+ if (switch_channel_test_flag(channel, CF_BRIDGE_ORIGINATOR)) {
+ switch_channel_clear_flag_recursive(channel, CF_BRIDGE_ORIGINATOR);
+ if (switch_event_create(&event, SWITCH_EVENT_CHANNEL_UNBRIDGE) == SWITCH_STATUS_SUCCESS) {
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridge-A-Unique-ID", switch_core_session_get_uuid(session));
+ switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridge-B-Unique-ID", uuid);
+ switch_channel_event_set_data(channel, event);
+ switch_event_fire(&event);
+ }
}
}
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridge-A-Unique-ID", switch_core_session_get_uuid(session));
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridge-B-Unique-ID", switch_core_session_get_uuid(peer_session));
switch_channel_event_set_data(caller_channel, event);
+ switch_event_add_presence_data_cols(peer_channel, event, "Bridge-B-PD-");
switch_event_fire(&event);
br = 1;
}
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridge-A-Unique-ID", switch_core_session_get_uuid(session));
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Bridge-B-Unique-ID", switch_core_session_get_uuid(peer_session));
switch_channel_event_set_data(caller_channel, event);
+ switch_event_add_presence_data_cols(peer_channel, event, "Bridge-B-PD-");
switch_event_fire(&event);
}