[asterisk-commits] branch 1.2 r36725 - /branches/1.2/channels/
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Sun Jul 2 21:19:10 MST 2006
Author: russell
Date: Sun Jul 2 23:19:09 2006
New Revision: 36725
URL: http://svn.digium.com/view/asterisk?rev=36725&view=rev
Log:
use ast_set_callerid to be more consistent and to make sure that the
"callerid" option in the conf files is always handled the same way and sets ANI
(issue #7285, gkloepfer)
Modified:
branches/1.2/channels/chan_agent.c
branches/1.2/channels/chan_features.c
branches/1.2/channels/chan_h323.c
branches/1.2/channels/chan_iax2.c
branches/1.2/channels/chan_local.c
branches/1.2/channels/chan_mgcp.c
branches/1.2/channels/chan_misdn.c
branches/1.2/channels/chan_modem.c
branches/1.2/channels/chan_phone.c
branches/1.2/channels/chan_sip.c
branches/1.2/channels/chan_skinny.c
Modified: branches/1.2/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/channels/chan_agent.c?rev=36725&r1=36724&r2=36725&view=diff
==============================================================================
--- branches/1.2/channels/chan_agent.c (original)
+++ branches/1.2/channels/chan_agent.c Sun Jul 2 23:19:09 2006
@@ -661,18 +661,8 @@
/* Call on this agent */
if (option_verbose > 2)
ast_verbose(VERBOSE_PREFIX_3 "outgoing agentcall, to agent '%s', on '%s'\n", p->agent, p->chan->name);
- if (p->chan->cid.cid_num)
- free(p->chan->cid.cid_num);
- if (ast->cid.cid_num)
- p->chan->cid.cid_num = strdup(ast->cid.cid_num);
- else
- p->chan->cid.cid_num = NULL;
- if (p->chan->cid.cid_name)
- free(p->chan->cid.cid_name);
- if (ast->cid.cid_name)
- p->chan->cid.cid_name = strdup(ast->cid.cid_name);
- else
- p->chan->cid.cid_name = NULL;
+ ast_set_callerid(p->chan,
+ ast->cid.cid_num, ast->cid.cid_name, NULL);
ast_channel_inherit_variables(ast, p->chan);
res = ast_call(p->chan, p->loginchan, 0);
CLEANUP(ast,p);
Modified: branches/1.2/channels/chan_features.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/channels/chan_features.c?rev=36725&r1=36724&r2=36725&view=diff
==============================================================================
--- branches/1.2/channels/chan_features.c (original)
+++ branches/1.2/channels/chan_features.c Sun Jul 2 23:19:09 2006
@@ -328,25 +328,14 @@
ast_mutex_lock(&p->lock);
x = indexof(p, ast, 0);
if (!x && p->subchan) {
- if (p->owner->cid.cid_num)
- p->subchan->cid.cid_num = strdup(p->owner->cid.cid_num);
- else
- p->subchan->cid.cid_num = NULL;
-
- if (p->owner->cid.cid_name)
- p->subchan->cid.cid_name = strdup(p->owner->cid.cid_name);
- else
- p->subchan->cid.cid_name = NULL;
+ ast_set_callerid(p->subchan,
+ p->owner->cid.cid_num, p->owner->cid.cid_name,
+ p->owner->cid.cid_ani ? p->owner->cid.cid_ani : p->owner->cid.cid_num);
if (p->owner->cid.cid_rdnis)
p->subchan->cid.cid_rdnis = strdup(p->owner->cid.cid_rdnis);
else
p->subchan->cid.cid_rdnis = NULL;
-
- if (p->owner->cid.cid_ani)
- p->subchan->cid.cid_ani = strdup(p->owner->cid.cid_ani);
- else
- p->subchan->cid.cid_ani = NULL;
p->subchan->cid.cid_pres = p->owner->cid.cid_pres;
strncpy(p->subchan->language, p->owner->language, sizeof(p->subchan->language) - 1);
Modified: branches/1.2/channels/chan_h323.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/channels/chan_h323.c?rev=36725&r1=36724&r2=36725&view=diff
==============================================================================
--- branches/1.2/channels/chan_h323.c (original)
+++ branches/1.2/channels/chan_h323.c Sun Jul 2 23:19:09 2006
@@ -769,16 +769,17 @@
if (pvt->amaflags) {
ch->amaflags = pvt->amaflags;
}
- if (!ast_strlen_zero(pvt->cid_num)) {
- ch->cid.cid_num = strdup(pvt->cid_num);
- } else if (!ast_strlen_zero(pvt->cd.call_source_e164)) {
- ch->cid.cid_num = strdup(pvt->cd.call_source_e164);
- }
- if (!ast_strlen_zero(pvt->cid_name)) {
- ch->cid.cid_name = strdup(pvt->cid_name);
- } else if (!ast_strlen_zero(pvt->cd.call_source_name)) {
- ch->cid.cid_name = strdup(pvt->cd.call_source_name);
- }
+
+ /*
+ * If cid_num and cdi.call_source_e164 are both null, then
+ * ast_set_callerid will do the right thing and leave the
+ * cid_num and cid_ani for the channel alone.
+ */
+ ast_set_callerid(ch,
+ !ast_strlen_zero(pvt->cid_num) ? pvt->cid_num : pvt->cd.call_source_e164,
+ pvt->cid_name,
+ !ast_strlen_zero(pvt->cid_num) ? pvt->cid_num : pvt->cd.call_source_e164);
+
if (!ast_strlen_zero(pvt->rdnis)) {
ch->cid.cid_rdnis = strdup(pvt->rdnis);
}
Modified: branches/1.2/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/channels/chan_iax2.c?rev=36725&r1=36724&r2=36725&view=diff
==============================================================================
--- branches/1.2/channels/chan_iax2.c (original)
+++ branches/1.2/channels/chan_iax2.c Sun Jul 2 23:19:09 2006
@@ -3412,12 +3412,8 @@
tmp->writeformat = ast_best_codec(capability);
tmp->tech_pvt = CALLNO_TO_PTR(i->callno);
- if (!ast_strlen_zero(i->cid_num))
- tmp->cid.cid_num = strdup(i->cid_num);
- if (!ast_strlen_zero(i->cid_name))
- tmp->cid.cid_name = strdup(i->cid_name);
- if (!ast_strlen_zero(i->ani))
- tmp->cid.cid_ani = strdup(i->ani);
+ ast_set_callerid(tmp, i->cid_num, i->cid_name,
+ i->ani ? i->ani : i->cid_num);
if (!ast_strlen_zero(i->language))
ast_copy_string(tmp->language, i->language, sizeof(tmp->language));
if (!ast_strlen_zero(i->dnid))
Modified: branches/1.2/channels/chan_local.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/channels/chan_local.c?rev=36725&r1=36724&r2=36725&view=diff
==============================================================================
--- branches/1.2/channels/chan_local.c (original)
+++ branches/1.2/channels/chan_local.c Sun Jul 2 23:19:09 2006
@@ -336,25 +336,15 @@
size_t len, namelen;
ast_mutex_lock(&p->lock);
- if (p->owner->cid.cid_num)
- p->chan->cid.cid_num = strdup(p->owner->cid.cid_num);
- else
- p->chan->cid.cid_num = NULL;
-
- if (p->owner->cid.cid_name)
- p->chan->cid.cid_name = strdup(p->owner->cid.cid_name);
- else
- p->chan->cid.cid_name = NULL;
+
+ ast_set_callerid(p->chan,
+ p->owner->cid.cid_num, p->owner->cid.cid_name,
+ p->owner->cid.cid_ani ? p->chan->cid.cid_ani : p->owner->cid.cid_num);
if (p->owner->cid.cid_rdnis)
p->chan->cid.cid_rdnis = strdup(p->owner->cid.cid_rdnis);
else
p->chan->cid.cid_rdnis = NULL;
-
- if (p->owner->cid.cid_ani)
- p->chan->cid.cid_ani = strdup(p->owner->cid.cid_ani);
- else
- p->chan->cid.cid_ani = NULL;
p->chan->cid.cid_pres = p->owner->cid.cid_pres;
Modified: branches/1.2/channels/chan_mgcp.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/channels/chan_mgcp.c?rev=36725&r1=36724&r2=36725&view=diff
==============================================================================
--- branches/1.2/channels/chan_mgcp.c (original)
+++ branches/1.2/channels/chan_mgcp.c Sun Jul 2 23:19:09 2006
@@ -1428,10 +1428,7 @@
strncpy(tmp->call_forward, i->call_forward, sizeof(tmp->call_forward) - 1);
strncpy(tmp->context, i->context, sizeof(tmp->context)-1);
strncpy(tmp->exten, i->exten, sizeof(tmp->exten)-1);
- if (!ast_strlen_zero(i->cid_num))
- tmp->cid.cid_num = strdup(i->cid_num);
- if (!ast_strlen_zero(i->cid_name))
- tmp->cid.cid_name = strdup(i->cid_name);
+ ast_set_callerid(tmp, i->cid_num, i->cid_name, i->cid_num);
if (!i->adsi)
tmp->adsicpe = AST_ADSI_UNAVAILABLE;
tmp->priority = 1;
@@ -2621,21 +2618,10 @@
/*res = tone_zone_play_tone(p->subs[index].zfd, -1);*/
ast_indicate(chan, -1);
strncpy(chan->exten, exten, sizeof(chan->exten)-1);
- if (!ast_strlen_zero(p->cid_num)) {
- if (!p->hidecallerid) {
- /* SC: free existing chan->callerid */
- if (chan->cid.cid_num)
- free(chan->cid.cid_num);
- chan->cid.cid_num = strdup(p->cid_num);
- /* SC: free existing chan->callerid */
- if (chan->cid.cid_name)
- free(chan->cid.cid_name);
- chan->cid.cid_name = strdup(p->cid_name);
- }
- if (chan->cid.cid_ani)
- free(chan->cid.cid_ani);
- chan->cid.cid_ani = strdup(p->cid_num);
- }
+ ast_set_callerid(chan,
+ p->hidecallerid ? "" : p->cid_num,
+ p->hidecallerid ? "" : p->cid_name,
+ chan->cid.cid_ani ? NULL : p->cid_num);
ast_setstate(chan, AST_STATE_RING);
/*zt_enable_ec(p);*/
if (p->dtmfmode & MGCP_DTMF_HYBRID) {
@@ -2692,12 +2678,7 @@
}
/* Disable Caller*ID if enabled */
p->hidecallerid = 1;
- if (chan->cid.cid_num)
- free(chan->cid.cid_num);
- chan->cid.cid_num = NULL;
- if (chan->cid.cid_name)
- free(chan->cid.cid_name);
- chan->cid.cid_name = NULL;
+ ast_set_callerid(chan, "", "", NULL);
/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_DIALRECALL);*/
transmit_notify_request(sub, "L/sl");
len = 0;
@@ -2776,14 +2757,7 @@
}
/* Enable Caller*ID if enabled */
p->hidecallerid = 0;
- if (chan->cid.cid_num)
- free(chan->cid.cid_num);
- if (!ast_strlen_zero(p->cid_num))
- chan->cid.cid_num = strdup(p->cid_num);
- if (chan->cid.cid_name)
- free(chan->cid.cid_name);
- if (!ast_strlen_zero(p->cid_name))
- chan->cid.cid_name = strdup(p->cid_name);
+ ast_set_callerid(chan, p->cid_num, p->cid_name, NULL);
/*res = tone_zone_play_tone(p->subs[index].zfd, ZT_TONE_DIALRECALL);*/
transmit_notify_request(sub, "L/sl");
len = 0;
Modified: branches/1.2/channels/chan_misdn.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/channels/chan_misdn.c?rev=36725&r1=36724&r2=36725&view=diff
==============================================================================
--- branches/1.2/channels/chan_misdn.c (original)
+++ branches/1.2/channels/chan_misdn.c Sun Jul 2 23:19:09 2006
@@ -2164,10 +2164,7 @@
char *cid_name, *cid_num;
ast_callerid_parse(callerid, &cid_name, &cid_num);
- if (cid_name)
- tmp->cid.cid_name=strdup(cid_name);
- if (cid_num)
- tmp->cid.cid_num=strdup(cid_num);
+ ast_set_callerid(tmp, cid_num, cid_name, cid_num);
}
{
Modified: branches/1.2/channels/chan_modem.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/channels/chan_modem.c?rev=36725&r1=36724&r2=36725&view=diff
==============================================================================
--- branches/1.2/channels/chan_modem.c (original)
+++ branches/1.2/channels/chan_modem.c Sun Jul 2 23:19:09 2006
@@ -576,10 +576,7 @@
tmp->tech_pvt = i;
strncpy(tmp->context, i->context, sizeof(tmp->context)-1);
- if (!ast_strlen_zero(i->cid_num))
- tmp->cid.cid_num = strdup(i->cid_num);
- if (!ast_strlen_zero(i->cid_name))
- tmp->cid.cid_name = strdup(i->cid_name);
+ ast_set_callerid(tmp, i->cid_num, i->cid_name, i->cid_num);
if (!ast_strlen_zero(i->language))
strncpy(tmp->language,i->language, sizeof(tmp->language)-1);
Modified: branches/1.2/channels/chan_phone.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/channels/chan_phone.c?rev=36725&r1=36724&r2=36725&view=diff
==============================================================================
--- branches/1.2/channels/chan_phone.c (original)
+++ branches/1.2/channels/chan_phone.c Sun Jul 2 23:19:09 2006
@@ -825,10 +825,7 @@
strncpy(tmp->exten, "s", sizeof(tmp->exten) - 1);
if (!ast_strlen_zero(i->language))
strncpy(tmp->language, i->language, sizeof(tmp->language)-1);
- if (!ast_strlen_zero(i->cid_num))
- tmp->cid.cid_num = strdup(i->cid_num);
- if (!ast_strlen_zero(i->cid_name))
- tmp->cid.cid_name = strdup(i->cid_name);
+ ast_set_callerid(tmp, i->cid_num, i->cid_name, i->cid_num);
i->owner = tmp;
ast_mutex_lock(&usecnt_lock);
usecnt++;
Modified: branches/1.2/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/channels/chan_sip.c?rev=36725&r1=36724&r2=36725&view=diff
==============================================================================
--- branches/1.2/channels/chan_sip.c (original)
+++ branches/1.2/channels/chan_sip.c Sun Jul 2 23:19:09 2006
@@ -2817,10 +2817,7 @@
ast_mutex_unlock(&usecnt_lock);
ast_copy_string(tmp->context, i->context, sizeof(tmp->context));
ast_copy_string(tmp->exten, i->exten, sizeof(tmp->exten));
- if (!ast_strlen_zero(i->cid_num))
- tmp->cid.cid_num = strdup(i->cid_num);
- if (!ast_strlen_zero(i->cid_name))
- tmp->cid.cid_name = strdup(i->cid_name);
+ ast_set_callerid(tmp, i->cid_num, i->cid_name, i->cid_num);
if (!ast_strlen_zero(i->rdnis))
tmp->cid.cid_rdnis = strdup(i->rdnis);
if (!ast_strlen_zero(i->exten) && strcmp(i->exten, "s"))
Modified: branches/1.2/channels/chan_skinny.c
URL: http://svn.digium.com/view/asterisk/branches/1.2/channels/chan_skinny.c?rev=36725&r1=36724&r2=36725&view=diff
==============================================================================
--- branches/1.2/channels/chan_skinny.c (original)
+++ branches/1.2/channels/chan_skinny.c Sun Jul 2 23:19:09 2006
@@ -1741,11 +1741,12 @@
getforward = 0;
} else {
strncpy(chan->exten, exten, sizeof(chan->exten)-1);
+
if (!ast_strlen_zero(l->cid_num)) {
- if (!l->hidecallerid) {
- chan->cid.cid_num = strdup(l->cid_num);
- chan->cid.cid_ani = strdup(l->cid_num);
- }
+ ast_set_callerid(chan,
+ l->hidecallerid ? "" : l->cid_num,
+ l->hidecallerid ? "" : l->cid_name,
+ chan->cid.cid_ani ? NULL : l->cid_num);
ast_setstate(chan, AST_STATE_RING);
res = ast_pbx_run(chan);
if (res) {
@@ -1792,14 +1793,7 @@
}
/* Disable Caller*ID if enabled */
l->hidecallerid = 1;
- if (chan->cid.cid_num) {
- free(chan->cid.cid_num);
- }
- chan->cid.cid_num = NULL;
- if (chan->cid.cid_name) {
- free(chan->cid.cid_name);
- }
- chan->cid.cid_name = NULL;
+ ast_set_callerid(chan, "", "", NULL);
transmit_tone(s, SKINNY_DIALTONE);
len = 0;
memset(exten, 0, sizeof(exten));
@@ -1873,18 +1867,7 @@
}
/* Enable Caller*ID if enabled */
l->hidecallerid = 0;
- if (chan->cid.cid_num) {
- free(chan->cid.cid_num);
- }
- if (!ast_strlen_zero(l->cid_num)) {
- chan->cid.cid_num = strdup(l->cid_num);
- }
- if (chan->cid.cid_name) {
- free(chan->cid.cid_name);
- }
- if (!ast_strlen_zero(l->cid_name)) {
- chan->cid.cid_name = strdup(l->cid_name);
- }
+ ast_set_callerid(chan, l->cid_num, l->cid_name, NULL);
transmit_tone(s, SKINNY_DIALTONE);
len = 0;
memset(exten, 0, sizeof(exten));
@@ -2296,12 +2279,7 @@
strncpy(tmp->call_forward, l->call_forward, sizeof(tmp->call_forward) - 1);
strncpy(tmp->context, l->context, sizeof(tmp->context)-1);
strncpy(tmp->exten,l->exten, sizeof(tmp->exten)-1);
- if (!ast_strlen_zero(l->cid_num)) {
- tmp->cid.cid_num = strdup(l->cid_num);
- }
- if (!ast_strlen_zero(l->cid_name)) {
- tmp->cid.cid_name = strdup(l->cid_name);
- }
+ ast_set_callerid(tmp, l->cid_num, l->cid_name, l->cid_num);
tmp->priority = 1;
tmp->adsicpe = AST_ADSI_UNAVAILABLE;
More information about the asterisk-commits
mailing list