]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
automerge commit
authorAutomerge script <automerge@asterisk.org>
Mon, 3 Jul 2006 05:04:12 +0000 (05:04 +0000)
committerAutomerge script <automerge@asterisk.org>
Mon, 3 Jul 2006 05:04:12 +0000 (05:04 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.2-netsec@36750 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_agent.c
channels/chan_features.c
channels/chan_h323.c
channels/chan_iax2.c
channels/chan_local.c
channels/chan_mgcp.c
channels/chan_misdn.c
channels/chan_modem.c
channels/chan_phone.c
channels/chan_sip.c
channels/chan_skinny.c

index 0d0c9eba1dc0c58bde6ea5c466b6761bea9de841..e41ee0994d6b6ab5ee8291710fb2aba5701869b2 100644 (file)
@@ -661,18 +661,8 @@ static int agent_call(struct ast_channel *ast, char *dest, int timeout)
                /* 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);
index 97bbdf8eda3f33b2513af6befa944ecd0e0a61e4..38565ee41c3edd8d1d2089d49b9fa3ae5cfec579 100644 (file)
@@ -328,26 +328,15 @@ static int features_call(struct ast_channel *ast, char *dest, int timeout)
                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);
                        strncpy(p->subchan->accountcode, p->owner->accountcode, sizeof(p->subchan->accountcode) - 1);
index ee0bdbd1ddf09ef59cba1bd8335df1c48ea120ce..d9057a16cd0b51d9818bcfe92f934d08dfd2ee42 100644 (file)
@@ -769,16 +769,17 @@ static struct ast_channel *__oh323_new(struct oh323_pvt *pvt, int state, const c
                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);
                }
index 387e673f6e4c826cc31ff366179a1dd62d093297..1f0afe67b8c9730a5eba2fa253dfdc1b0b4c1a55 100644 (file)
@@ -3412,12 +3412,8 @@ static struct ast_channel *ast_iax2_new(int callno, int state, int capability)
                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))
index 8dc46033ccd1dbf4f5b48c35943dcca53f1f661f..06900590270cdcae28de16fe4f1d0a99a47e758b 100644 (file)
@@ -336,26 +336,16 @@ static int local_call(struct ast_channel *ast, char *dest, int timeout)
        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;
 
        strncpy(p->chan->language, p->owner->language, sizeof(p->chan->language) - 1);
index 7538fd9d74a8c0aa533f6439810ebf43c7f50303..9fca447b08e591c1534208bf6b7e07e56ef8eac9 100644 (file)
@@ -1428,10 +1428,7 @@ static struct ast_channel *mgcp_new(struct mgcp_subchannel *sub, int state)
                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 @@ static void *mgcp_ss(void *data)
                                        /*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 @@ static void *mgcp_ss(void *data)
                        }
                        /* 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 @@ static void *mgcp_ss(void *data)
                        }
                        /* 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;
index 46296c18fc5e186b0e1e6f9627a10b95ea480be5..2538d35836a270427cd63d346f2d536014c69117 100644 (file)
@@ -2164,10 +2164,7 @@ struct ast_channel *misdn_new(struct chan_list *chlist, int state, char * name,
                        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);
                }
 
                {
index 09adc4733a383cc430b63760f12c50c00d5489f7..8e5e8d79fcb4c190082bfc4fc51a2116011fbcf6 100644 (file)
@@ -576,10 +576,7 @@ struct ast_channel *ast_modem_new(struct ast_modem_pvt *i, int state)
                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);
index c1d5527163efad327f5b68d8cef8cde687fab446..0cb57fc11253cbb027f99a6560634c301fed76e8 100644 (file)
@@ -825,10 +825,7 @@ static struct ast_channel *phone_new(struct phone_pvt *i, int state, char *conte
                        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++;
index 1fc0ddebf6ec6310086534b5987573e219fcb8f9..6b0472500973d44e7cfa781251abea38bcabfe5c 100644 (file)
@@ -2855,10 +2855,7 @@ static struct ast_channel *sip_new(struct sip_pvt *i, int state, char *title)
        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"))
index 37321a3551b902296a301e24c119bb21af65e862..c35b0281089941f467cbaa590e9cda021b2f7861 100644 (file)
@@ -1741,11 +1741,12 @@ static void *skinny_ss(void *data)
                                        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 @@ static void *skinny_ss(void *data)
                        }
                        /* 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 @@ static void *skinny_ss(void *data)
                                }
                                /* 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 @@ static struct ast_channel *skinny_new(struct skinny_subchannel *sub, int state)
                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;