[asterisk-commits] mmichelson: branch mmichelson/caller_id r384512 - /team/mmichelson/caller_id/...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Apr 1 17:13:00 CDT 2013
Author: mmichelson
Date: Mon Apr 1 17:12:57 2013
New Revision: 384512
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=384512
Log:
More progress. This mostly just moved some common logic into its own function.
One thing that still needs to be addressed is chan_gulp's role in connected line
updates.
Modified:
team/mmichelson/caller_id/res/res_sip_caller_id.c
Modified: team/mmichelson/caller_id/res/res_sip_caller_id.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/caller_id/res/res_sip_caller_id.c?view=diff&rev=384512&r1=384511&r2=384512
==============================================================================
--- team/mmichelson/caller_id/res/res_sip_caller_id.c (original)
+++ team/mmichelson/caller_id/res/res_sip_caller_id.c Mon Apr 1 17:12:57 2013
@@ -52,33 +52,6 @@
}
}
-static int get_id_from_from(struct pjsip_rx_data *rdata, struct ast_party_id *id)
-{
- pjsip_fromto_hdr *from = pjsip_msg_find_hdr(rdata->msg_info.msg,
- PJSIP_H_FROM, rdata->msg_info.msg->hdr.next);
- pjsip_name_addr *id_name_addr;
-
- if (!from) {
- /* This had better not happen */
- return -1;
- }
-
- id_name_addr = (pjsip_name_addr *)from->uri;
- set_id_from_nameaddr(id_name_addr, id);
-
- if (!id->number.valid) {
- return -1;
- }
-
- return 0;
-}
-
-static int caller_id_incoming_request(struct ast_sip_session *session, pjsip_rx_data *rdata)
-{
- get_id_from_from(rdata, &session->id);
- return 0;
-}
-
static int get_id_from_pai(pjsip_rx_data *rdata, struct ast_party_id *id)
{
pj_str_t pai_str = { "P-Asserted-Identity", 19 };
@@ -105,28 +78,80 @@
return 0;
}
-static void caller_id_incoming_response(struct ast_sip_session *session, pjsip_rx_data *rdata)
+static int get_id_from_from(struct pjsip_rx_data *rdata, struct ast_party_id *id)
+{
+ pjsip_fromto_hdr *from = pjsip_msg_find_hdr(rdata->msg_info.msg,
+ PJSIP_H_FROM, rdata->msg_info.msg->hdr.next);
+ pjsip_name_addr *id_name_addr;
+
+ if (!from) {
+ /* This had better not happen */
+ return -1;
+ }
+
+ id_name_addr = (pjsip_name_addr *)from->uri;
+ set_id_from_nameaddr(id_name_addr, id);
+
+ if (!id->number.valid) {
+ return -1;
+ }
+
+ return 0;
+}
+
+static void update_incoming_connected_line(struct ast_sip_session *session, pjsip_rx_data *rdata)
{
struct ast_party_connected_line connected;
- struct ast_set_party_connected_line update_connected;
-
- if (!session->channel) {
- return;
- }
ast_party_connected_line_init(&connected);
- if (!get_id_from_pai(rdata, &connected.id)) {
+ if (get_id_from_pai(rdata, &connected.id)) {
+ return;
+ }
+ if (connected.id.number.valid &&
+ (ast_strlen_zero(session->id.number.str) ||
+ strcmp(session->id.number.str, connected.id.number.str)) ||
+ connected.id.name.valid &&
+ (ast_strlen_zero(session->id.name.str) ||
+ strcmp(session->id.name.str, connected.id.name.str))) {
+ struct ast_set_party_connected_line update_connected;
memset(&update_connected, 0, sizeof(update_connected));
-
update_connected.id.number = 1;
update_connected.id.name = 1;
-
+
ast_set_party_id_all(&update_connected.priv);
connected.source = AST_CONNECTED_LINE_UPDATE_SOURCE_ANSWER;
ast_channel_queue_connected_line_update(session->channel, &connected, &update_connected);
}
ast_party_connected_line_free(&connected);
+}
+
+static int caller_id_incoming_request(struct ast_sip_session *session, pjsip_rx_data *rdata)
+{
+ if (session->inv_session->state < PJSIP_INV_STATE_CONFIRMED) {
+ /* Initial inbound INVITE. Set the session ID directly */
+ if (get_id_from_pai(rdata, &session->id)) {
+ get_id_from_from(rdata, &session->id);
+ }
+ } else {
+ /* Reinvite. Check for changes to the ID and queue a connected line
+ * update if necessary
+ */
+ update_incoming_connected_line(session, rdata);
+ }
+ return 0;
+}
+
+static void caller_id_incoming_response(struct ast_sip_session *session, pjsip_rx_data *rdata)
+{
+ struct ast_party_connected_line connected;
+ struct ast_set_party_connected_line update_connected;
+
+ if (!session->channel) {
+ return;
+ }
+
+ update_incoming_connected_line(session, rdata);
}
static void set_from_header(pj_pool_t *pool, pjsip_fromto_hdr *from, struct ast_party_id *caller)
More information about the asterisk-commits
mailing list