From be94f38009b80e372a3b2bdf5998e40d4b19c5a9 Mon Sep 17 00:00:00 2001 From: russell Date: Sat, 10 Feb 2007 00:40:57 +0000 Subject: Merged revisions 53810 via svnmerge from https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r53810 | russell | 2007-02-09 18:35:09 -0600 (Fri, 09 Feb 2007) | 24 lines Merge team/russell/sla_rewrite This is a completely new implementation of the SLA functionality introduced in Asterisk 1.4. It is now functional and ready for testing. However, I will be adding some additional features over the next week, as well. For information on how to set this up, see configs/sla.conf.sample and doc/sla.txt. In addition to the changes in app_meetme.c for the SLA implementation itself, this merge brings in various other changes: chan_sip: - Add the ability to indicate HOLD state in NOTIFY messages. - Queue HOLD and UNHOLD control frames even if the channel is not bridged to another channel. linkedlists.h: - Add support for rwlock based linked lists. dial.c: - Add the ability to run ast_dial_start() without a reference channel to inherit information from. ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@53817 f38db490-d61c-443f-a65b-d21fe96a405b --- main/dial.c | 53 +++++++++++++++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 22 deletions(-) (limited to 'main') diff --git a/main/dial.c b/main/dial.c index 74311eaee..8e4f7528c 100644 --- a/main/dial.c +++ b/main/dial.c @@ -228,33 +228,37 @@ static int begin_dial(struct ast_dial *dial, struct ast_channel *chan) ast_copy_string(numsubst, channel->device, sizeof(numsubst)); /* Request that the channel be created */ - if (!(channel->owner = ast_request(channel->tech, chan->nativeformats, numsubst, &channel->cause))) + if (!(channel->owner = ast_request(channel->tech, + chan ? chan->nativeformats : AST_FORMAT_AUDIO_MASK, numsubst, &channel->cause))) { continue; + } channel->owner->appl = "AppDial2"; channel->owner->data = "(Outgoing Line)"; channel->owner->whentohangup = 0; /* Inherit everything from he who spawned this Dial */ - ast_channel_inherit_variables(chan, channel->owner); - - /* Copy over callerid information */ - S_REPLACE(channel->owner->cid.cid_num, ast_strdup(chan->cid.cid_num)); - S_REPLACE(channel->owner->cid.cid_name, ast_strdup(chan->cid.cid_name)); - S_REPLACE(channel->owner->cid.cid_ani, ast_strdup(chan->cid.cid_ani)); - S_REPLACE(channel->owner->cid.cid_rdnis, ast_strdup(chan->cid.cid_rdnis)); - - ast_string_field_set(channel->owner, language, chan->language); - ast_string_field_set(channel->owner, accountcode, chan->accountcode); - channel->owner->cdrflags = chan->cdrflags; - if (ast_strlen_zero(channel->owner->musicclass)) - ast_string_field_set(channel->owner, musicclass, chan->musicclass); - - channel->owner->cid.cid_pres = chan->cid.cid_pres; - channel->owner->cid.cid_ton = chan->cid.cid_ton; - channel->owner->cid.cid_tns = chan->cid.cid_tns; - channel->owner->adsicpe = chan->adsicpe; - channel->owner->transfercapability = chan->transfercapability; + if (chan) { + ast_channel_inherit_variables(chan, channel->owner); + + /* Copy over callerid information */ + S_REPLACE(channel->owner->cid.cid_num, ast_strdup(chan->cid.cid_num)); + S_REPLACE(channel->owner->cid.cid_name, ast_strdup(chan->cid.cid_name)); + S_REPLACE(channel->owner->cid.cid_ani, ast_strdup(chan->cid.cid_ani)); + S_REPLACE(channel->owner->cid.cid_rdnis, ast_strdup(chan->cid.cid_rdnis)); + + ast_string_field_set(channel->owner, language, chan->language); + ast_string_field_set(channel->owner, accountcode, chan->accountcode); + channel->owner->cdrflags = chan->cdrflags; + if (ast_strlen_zero(channel->owner->musicclass)) + ast_string_field_set(channel->owner, musicclass, chan->musicclass); + + channel->owner->cid.cid_pres = chan->cid.cid_pres; + channel->owner->cid.cid_ton = chan->cid.cid_ton; + channel->owner->cid.cid_tns = chan->cid.cid_tns; + channel->owner->adsicpe = chan->adsicpe; + channel->owner->transfercapability = chan->transfercapability; + } /* Actually call the device */ if ((res = ast_call(channel->owner, numsubst, 0))) { @@ -530,12 +534,16 @@ enum ast_dial_result ast_dial_run(struct ast_dial *dial, struct ast_channel *cha enum ast_dial_result res = AST_DIAL_RESULT_TRYING; /* Ensure required arguments are passed */ - if (!dial || !chan) + if (!dial || (!chan && !async)) { + ast_log(LOG_DEBUG, "invalid #1\n"); return AST_DIAL_RESULT_INVALID; + } /* If there are no channels to dial we can't very well try to dial them */ - if (AST_LIST_EMPTY(&dial->channels)) + if (AST_LIST_EMPTY(&dial->channels)) { + ast_log(LOG_DEBUG, "invalid #2\n"); return AST_DIAL_RESULT_INVALID; + } /* Dial each requested channel */ if (!begin_dial(dial, chan)) @@ -543,6 +551,7 @@ enum ast_dial_result ast_dial_run(struct ast_dial *dial, struct ast_channel *cha /* If we are running async spawn a thread and send it away... otherwise block here */ if (async) { + dial->status = AST_DIAL_RESULT_TRYING; /* Try to create a thread */ if (ast_pthread_create(&dial->thread, NULL, async_dial, dial)) { /* Failed to create the thread - hangup all dialed channels and return failed */ -- cgit v1.2.3