summaryrefslogtreecommitdiff
path: root/res
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2014-08-11 18:32:37 +0000
committerMark Michelson <mmichelson@digium.com>2014-08-11 18:32:37 +0000
commitef70c08dc7e074bee599c01a6850499ce8889ed6 (patch)
tree69db30c50c43cf49ffa3eccbcfa00cd868a678e8 /res
parent1b500d2fa1eb4b158a663e2f20bf2ffa3523a707 (diff)
Improve call forwarding reporting, especially with regards to ARI.
This patch addresses a few issues: 1) The order of Dial events have been changed when performing a call forward. The order has now been altered to 1) Dial begins dialing channel A. 2) When A forwards the call to B, we issue the dial end event to channel A, indicating the dial is being canceled due to a forward to B. 3) When the call to channel B occurs, we then issue a new dial begin to channel B. 2) Call forwards are now reported on the calling channel, not the peer channel. 3) AMI DialEnd events have been altered to display the extension the call is being forwarded to when relevant. 4) You can now get the values of channel variables for channels that are not currently in the Stasis application. This brings the retrieval of channel variables more in line with the rest of channel read operations since they may be performed on channels not in Stasis. ASTERISK-24134 #close Reported by Matt Jordan ASTERISK-24138 #close Reported by Matt Jordan Patches: forward-shenanigans.diff uploaded by Matt Jordan (License #6283) Review: https://reviewboard.asterisk.org/r/3899 git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/13@420794 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res')
-rw-r--r--res/ari/resource_channels.c39
-rw-r--r--res/res_pjsip_pubsub.c5
-rw-r--r--res/stasis/app.c4
-rw-r--r--res/stasis/control.c28
4 files changed, 38 insertions, 38 deletions
diff --git a/res/ari/resource_channels.c b/res/ari/resource_channels.c
index d0a1be32e..729eeec67 100644
--- a/res/ari/resource_channels.c
+++ b/res/ari/resource_channels.c
@@ -929,7 +929,8 @@ void ast_ari_channels_get_channel_var(struct ast_variable *headers,
{
RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
RAII_VAR(struct stasis_app_control *, control, NULL, ao2_cleanup);
- RAII_VAR(char *, value, NULL, ast_free);
+ RAII_VAR(struct ast_str *, value, ast_str_create(32), ast_free);
+ RAII_VAR(struct ast_channel *, channel, NULL, ast_channel_cleanup);
ast_assert(response != NULL);
@@ -940,15 +941,41 @@ void ast_ari_channels_get_channel_var(struct ast_variable *headers,
return;
}
- control = find_control(response, args->channel_id);
- if (control == NULL) {
- /* response filled in by find_control */
+ if (ast_strlen_zero(args->channel_id)) {
+ ast_ari_response_error(
+ response, 400, "Bad Request",
+ "Channel ID is required");
+ return;
+ }
+
+ channel = ast_channel_get_by_name(args->channel_id);
+ if (!channel) {
+ ast_ari_response_error(
+ response, 404, "Channel Not Found",
+ "Provided channel was not found");
return;
}
- value = stasis_app_control_get_channel_var(control, args->variable);
+ /* You may be tempted to lock the channel you're about to read from. You
+ * would be wrong. Some dialplan functions put the channel into
+ * autoservice, which deadlocks if the channel is already locked.
+ * ast_str_retrieve_variable() does its own locking, and the dialplan
+ * functions need to as well. We should be fine without the lock.
+ */
+
+ if (args->variable[strlen(args->variable) - 1] == ')') {
+ if (ast_func_read2(channel, args->variable, &value, 0)) {
+ ast_ari_response_alloc_failed(response);
+ return;
+ }
+ } else {
+ if (!ast_str_retrieve_variable(&value, 0, channel, NULL, args->variable)) {
+ ast_ari_response_alloc_failed(response);
+ return;
+ }
+ }
- if (!(json = ast_json_pack("{s: s}", "value", S_OR(value, "")))) {
+ if (!(json = ast_json_pack("{s: s}", "value", S_OR(ast_str_buffer(value), "")))) {
ast_ari_response_alloc_failed(response);
return;
}
diff --git a/res/res_pjsip_pubsub.c b/res/res_pjsip_pubsub.c
index f9b64f85f..90be60d4e 100644
--- a/res/res_pjsip_pubsub.c
+++ b/res/res_pjsip_pubsub.c
@@ -2032,10 +2032,13 @@ int ast_sip_subscription_notify(struct ast_sip_subscription *sub, void *notify_d
if (sub->tree->notification_batch_interval) {
return schedule_notification(sub->tree);
} else {
+ int res;
/* See the note in pubsub_on_rx_refresh() for why sub->tree is refbumped here */
ao2_ref(sub->tree, +1);
- return send_notify(sub->tree, 0);
+ res = send_notify(sub->tree, 0);
ao2_ref(sub->tree, -1);
+
+ return res;
}
}
diff --git a/res/stasis/app.c b/res/stasis/app.c
index 745969615..245936734 100644
--- a/res/stasis/app.c
+++ b/res/stasis/app.c
@@ -1073,9 +1073,7 @@ static int unsubscribe(struct stasis_app *app, const char *kind, const char *id,
forwards = ao2_find(app->forwards, id, OBJ_SEARCH_KEY | OBJ_NOLOCK);
if (!forwards) {
- ast_log(LOG_WARNING,
- "App '%s' not subscribed to %s '%s'\n",
- app->name, kind, id);
+ ast_debug(3, "App '%s' not subscribed to %s '%s'\n", app->name, kind, id);
return -1;
}
forwards->interested--;
diff --git a/res/stasis/control.c b/res/stasis/control.c
index 0a9669d3b..e53d93c06 100644
--- a/res/stasis/control.c
+++ b/res/stasis/control.c
@@ -565,34 +565,6 @@ int stasis_app_control_unmute(struct stasis_app_control *control, unsigned int d
return 0;
}
-char *stasis_app_control_get_channel_var(struct stasis_app_control *control, const char *variable)
-{
- RAII_VAR(struct ast_str *, tmp, ast_str_create(32), ast_free);
-
- /* You may be tempted to lock the channel you're about to read from. You
- * would be wrong. Some dialplan functions put the channel into
- * autoservice, which deadlocks if the channel is already locked.
- * ast_str_retrieve_variable() does its own locking, and the dialplan
- * functions need to as well. We should be fine without the lock.
- */
-
- if (!tmp) {
- return NULL;
- }
-
- if (variable[strlen(variable) - 1] == ')') {
- if (ast_func_read2(control->channel, variable, &tmp, 0)) {
- return NULL;
- }
- } else {
- if (!ast_str_retrieve_variable(&tmp, 0, control->channel, NULL, variable)) {
- return NULL;
- }
- }
-
- return ast_strdup(ast_str_buffer(tmp));
-}
-
int stasis_app_control_set_channel_var(struct stasis_app_control *control, const char *variable, const char *value)
{
return pbx_builtin_setvar_helper(control->channel, variable, value);