summaryrefslogtreecommitdiff
path: root/apps/app_dial.c
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2015-09-24 12:37:07 -0500
committerRichard Mudgett <rmudgett@digium.com>2015-09-25 12:40:31 -0500
commitfdf0bcb04a0c768fac80adbf41164210586ab403 (patch)
treedf10307d4a7114f9005110f47f6b8226464e0f03 /apps/app_dial.c
parent6392fdf6dc3805fc08834ec0061601d880729ed1 (diff)
app_dial.c: Factor out a connected line update routine.
Replace inlined code with update_connected_line_from_peer(). ASTERISK-25423 Reported by: John Hardin Change-Id: Ia14f18def417645cd7fb453e1bdac682630a5091
Diffstat (limited to 'apps/app_dial.c')
-rw-r--r--apps/app_dial.c71
1 files changed, 32 insertions, 39 deletions
diff --git a/apps/app_dial.c b/apps/app_dial.c
index 46014c639..c70de13d6 100644
--- a/apps/app_dial.c
+++ b/apps/app_dial.c
@@ -1047,6 +1047,34 @@ static void publish_dial_end_event(struct ast_channel *in, struct dial_head *out
}
}
+/*!
+ * \internal
+ * \brief Update connected line on chan from peer.
+ * \since 13.6.0
+ *
+ * \param chan Channel to get connected line updated.
+ * \param peer Channel providing connected line information.
+ * \param is_caller Non-zero if chan is the calling channel.
+ *
+ * \return Nothing
+ */
+static void update_connected_line_from_peer(struct ast_channel *chan, struct ast_channel *peer, int is_caller)
+{
+ struct ast_party_connected_line connected_caller;
+
+ ast_party_connected_line_init(&connected_caller);
+
+ ast_channel_lock(peer);
+ ast_connected_line_copy_from_caller(&connected_caller, ast_channel_caller(peer));
+ ast_channel_unlock(peer);
+ connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
+ if (ast_channel_connected_line_sub(peer, chan, &connected_caller, 0)
+ && ast_channel_connected_line_macro(peer, chan, &connected_caller, is_caller, 0)) {
+ ast_channel_update_connected_line(chan, &connected_caller, NULL);
+ }
+ ast_party_connected_line_free(&connected_caller);
+}
+
static struct ast_channel *wait_for_answer(struct ast_channel *in,
struct dial_head *out_chans, int *to, struct ast_flags64 *peerflags,
char *opt_args[],
@@ -1067,7 +1095,6 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
int single = outgoing && !AST_LIST_NEXT(outgoing, node);
int caller_entertained = outgoing
&& ast_test_flag64(outgoing, OPT_MUSICBACK | OPT_RINGBACK);
- struct ast_party_connected_line connected_caller;
struct ast_str *featurecode = ast_str_alloca(AST_FEATURE_MAX_LEN + 1);
int cc_recall_core_id;
int is_cc_recall;
@@ -1075,7 +1102,6 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
int num_ringing = 0;
struct timeval start = ast_tvnow();
- ast_party_connected_line_init(&connected_caller);
if (single) {
/* Turn off hold music, etc */
if (!caller_entertained) {
@@ -1096,15 +1122,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
if (!ast_test_flag64(outgoing, OPT_IGNORE_CONNECTEDLINE)
&& !ast_test_flag64(outgoing, DIAL_CALLERID_ABSENT)) {
- ast_channel_lock(outgoing->chan);
- ast_connected_line_copy_from_caller(&connected_caller, ast_channel_caller(outgoing->chan));
- ast_channel_unlock(outgoing->chan);
- connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
- if (ast_channel_connected_line_sub(outgoing->chan, in, &connected_caller, 0) &&
- ast_channel_connected_line_macro(outgoing->chan, in, &connected_caller, 1, 0)) {
- ast_channel_update_connected_line(in, &connected_caller, NULL);
- }
- ast_party_connected_line_free(&connected_caller);
+ update_connected_line_from_peer(in, outgoing->chan, 1);
}
}
@@ -1165,15 +1183,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
ast_channel_update_connected_line(in, &o->connected, NULL);
}
} else if (!ast_test_flag64(o, DIAL_CALLERID_ABSENT)) {
- ast_channel_lock(c);
- ast_connected_line_copy_from_caller(&connected_caller, ast_channel_caller(c));
- ast_channel_unlock(c);
- connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
- if (ast_channel_connected_line_sub(c, in, &connected_caller, 0) &&
- ast_channel_connected_line_macro(c, in, &connected_caller, 1, 0)) {
- ast_channel_update_connected_line(in, &connected_caller, NULL);
- }
- ast_party_connected_line_free(&connected_caller);
+ update_connected_line_from_peer(in, c, 1);
}
}
if (o->aoc_s_rate_list) {
@@ -1231,16 +1241,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
if (single && o->chan
&& !ast_test_flag64(o, OPT_IGNORE_CONNECTEDLINE)
&& !ast_test_flag64(o, DIAL_CALLERID_ABSENT)) {
- ast_channel_lock(o->chan);
- ast_connected_line_copy_from_caller(&connected_caller,
- ast_channel_caller(o->chan));
- ast_channel_unlock(o->chan);
- connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
- if (ast_channel_connected_line_sub(o->chan, in, &connected_caller, 0) &&
- ast_channel_connected_line_macro(o->chan, in, &connected_caller, 1, 0)) {
- ast_channel_update_connected_line(in, &connected_caller, NULL);
- }
- ast_party_connected_line_free(&connected_caller);
+ update_connected_line_from_peer(in, o->chan, 1);
}
continue;
}
@@ -1271,15 +1272,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
ast_channel_update_connected_line(in, &o->connected, NULL);
}
} else if (!ast_test_flag64(o, DIAL_CALLERID_ABSENT)) {
- ast_channel_lock(c);
- ast_connected_line_copy_from_caller(&connected_caller, ast_channel_caller(c));
- ast_channel_unlock(c);
- connected_caller.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
- if (ast_channel_connected_line_sub(c, in, &connected_caller, 0) &&
- ast_channel_connected_line_macro(c, in, &connected_caller, 1, 0)) {
- ast_channel_update_connected_line(in, &connected_caller, NULL);
- }
- ast_party_connected_line_free(&connected_caller);
+ update_connected_line_from_peer(in, c, 1);
}
}
if (o->aoc_s_rate_list) {