summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2015-09-24 14:20:24 -0500
committerRichard Mudgett <rmudgett@digium.com>2015-09-25 12:31:24 -0500
commit6bf304bf251e31ab7c7a4d89508445b84fb5d551 (patch)
tree27df1e302a639081c8a01d6d02e0fb9be8e0e9ae /apps
parente36b5f1e8e1fd1e805184fca015bb0808b5e7fb8 (diff)
app_queue.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: I33bbd033596fcb0208d41d8970369b4e87b806f3
Diffstat (limited to 'apps')
-rw-r--r--apps/app_queue.c51
1 files changed, 30 insertions, 21 deletions
diff --git a/apps/app_queue.c b/apps/app_queue.c
index dbaa16718..2ca3a9e8e 100644
--- a/apps/app_queue.c
+++ b/apps/app_queue.c
@@ -4561,6 +4561,34 @@ static void rna(int rnatime, struct queue_ent *qe, struct ast_channel *peer, cha
return;
}
+/*!
+ * \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);
+}
+
#define AST_MAX_WATCHERS 256
/*!
* \brief Wait for a member to answer the call
@@ -4595,12 +4623,9 @@ static struct callattempt *wait_for_answer(struct queue_ent *qe, struct callatte
#ifdef HAVE_EPOLL
struct callattempt *epollo;
#endif
- struct ast_party_connected_line connected_caller;
char *inchan_name;
struct timeval start_time_tv = ast_tvnow();
- ast_party_connected_line_init(&connected_caller);
-
ast_channel_lock(qe->chan);
inchan_name = ast_strdupa(ast_channel_name(qe->chan));
ast_channel_unlock(qe->chan);
@@ -4685,15 +4710,7 @@ static struct callattempt *wait_for_answer(struct queue_ent *qe, struct callatte
ast_channel_update_connected_line(in, &o->connected, NULL);
}
} else if (!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);
}
}
if (o->aoc_s_rate_list) {
@@ -4856,15 +4873,7 @@ static struct callattempt *wait_for_answer(struct queue_ent *qe, struct callatte
ast_channel_update_connected_line(in, &o->connected, NULL);
}
} else if (!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);
}
}
if (o->aoc_s_rate_list) {