Fix native agent transfer, add UPGRADE.txt for notes about backwards compatibility...
authorMark Spencer <markster@digium.com>
Mon, 14 Feb 2005 23:20:01 +0000 (23:20 +0000)
committerMark Spencer <markster@digium.com>
Mon, 14 Feb 2005 23:20:01 +0000 (23:20 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@5031 65c4cc65-6c06-0410-ace0-fbb531ad65f3

UPGRADE.txt [new file with mode: 0755]
channels/chan_agent.c
channels/chan_local.c
channels/chan_sip.c
configs/agents.conf.sample

diff --git a/UPGRADE.txt b/UPGRADE.txt
new file mode 100755 (executable)
index 0000000..6304b45
--- /dev/null
@@ -0,0 +1,16 @@
+Information for Upgrading From Asterisk 1.0
+===========================================
+
+Agents:
+
+* The default for ackcall has been changed to "no" instead of "yes" 
+  because of a bug which caused the "yes" behavior to generally act like
+  "no".  You may need to adjust the value if your agents behave 
+  differently than you expect with respect to acknowledgement.
+
+Dialing:
+
+* The Caller*ID of the outbound leg is now the extension that was 
+  called, rather than the Caller*ID of the inbound leg of the call.  The 
+  "o" flag for Dial can be used to restore the original behavior if 
+  desired.
index 3895ddd..842616f 100755 (executable)
@@ -360,6 +360,8 @@ static struct ast_frame *agent_read(struct ast_channel *ast)
                           for us when the PBX instance that called login finishes */
                        if (!ast_strlen_zero(p->loginchan)) {
                                p->chan->_bridge = NULL;
+                               if (p->chan)
+                                       ast_log(LOG_DEBUG, "Bridge on '%s' being cleared (2)\n", p->chan->name);
                                ast_hangup(p->chan);
                                if (p->wrapuptime) {
                                        gettimeofday(&p->lastdisc, NULL);
@@ -375,8 +377,9 @@ static struct ast_frame *agent_read(struct ast_channel *ast)
                        p->acknowledged = 0;
                }
        }
-       if ((p->chan && (p->chan->_state != AST_STATE_UP)) && f && (f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_ANSWER)) {
+       if (p->chan && f && (f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_ANSWER)) {
 /* TC */
+               ast_log(LOG_DEBUG, "Got answer on %s\n", p->chan->name);
                if (p->ackcall) {
                        if (option_verbose > 2)
                                ast_verbose(VERBOSE_PREFIX_3 "%s answered, waiting for '#' to acknowledge\n", p->chan->name);
@@ -385,10 +388,8 @@ static struct ast_frame *agent_read(struct ast_channel *ast)
                        f = &null_frame;
                } else {
                        p->acknowledged = 1;
+                       ast_frfree(f);
                        f = &answer_frame;
-                       if (p->chan)
-                               p->chan->_bridge = ast;
-
         }
        }
        if (f && (f->frametype == AST_FRAME_DTMF) && (f->subclass == '#')) {
@@ -398,8 +399,6 @@ static struct ast_frame *agent_read(struct ast_channel *ast)
                        p->acknowledged = 1;
                        ast_frfree(f);
                        f = &answer_frame;
-                       if (p->chan)
-                               p->chan->_bridge = ast;
                }
        }
        if (f && (f->frametype == AST_FRAME_DTMF) && (f->subclass == '*')) {
@@ -408,6 +407,13 @@ static struct ast_frame *agent_read(struct ast_channel *ast)
                f = NULL;
        }
        CLEANUP(ast,p);
+       if (p->chan && !p->chan->_bridge) {
+               if (strcasecmp(p->chan->type, "Local")) {
+                       p->chan->_bridge = ast;
+                       if (p->chan)
+                               ast_log(LOG_DEBUG, "Bridge on '%s' being set to '%s' (3)\n", p->chan->name, p->chan->_bridge->name);
+               }
+       }
        ast_mutex_unlock(&p->lock);
        if (recordagentcalls && f == &answer_frame)
                agent_start_monitoring(ast,0);
@@ -563,8 +569,6 @@ static int agent_call(struct ast_channel *ast, char *dest, int timeout)
                        if (recordagentcalls)
                                agent_start_monitoring(ast,0);
                        p->acknowledged = 1;
-                       if (p->chan)
-                               p->chan->_bridge = ast;
                }
                res = 0;
        }
@@ -892,7 +896,7 @@ static int read_agent_config(void)
        group = 0;
        autologoff = 0;
        wrapuptime = 0;
-       ackcall = 1;
+       ackcall = 0;
        cfg = ast_config_load(config);
        if (!cfg) {
                ast_log(LOG_NOTICE, "No agent configuration found -- agent support disabled\n");
index b1998f1..e6ee964 100755 (executable)
@@ -139,28 +139,28 @@ static void check_bridge(struct local_pvt *p, int isoutbound)
 {
        if (p->alreadymasqed || p->nooptimization)
                return;
-       if (isoutbound && p->chan && ast_bridged_channel(p->chan) && p->owner) {
+       if (isoutbound && p->chan && p->chan->_bridge /* Not ast_bridged_channel!  Only go one step! */ && p->owner) {
                /* Masquerade bridged channel into owner */
                /* Lock everything we need, one by one, and give up if
                   we can't get everything.  Remember, we'll get another
                   chance in just a little bit */
-               if (!ast_mutex_trylock(&(ast_bridged_channel(p->chan))->lock)) {
+               if (!ast_mutex_trylock(&(p->chan->_bridge)->lock)) {
                        if (!ast_mutex_trylock(&p->owner->lock)) {
-                               ast_channel_masquerade(p->owner, ast_bridged_channel(p->chan));
+                               ast_channel_masquerade(p->owner, p->chan->_bridge);
                                p->alreadymasqed = 1;
                                ast_mutex_unlock(&p->owner->lock);
                        }
-                       ast_mutex_unlock(&(ast_bridged_channel(p->chan)->lock));
+                       ast_mutex_unlock(&(p->chan->_bridge)->lock);
                }
-       } else if (!isoutbound && p->owner && ast_bridged_channel(p->owner) && p->chan) {
+       } else if (!isoutbound && p->owner && p->owner->_bridge && p->chan) {
                /* Masquerade bridged channel into chan */
-               if (!ast_mutex_trylock(&(ast_bridged_channel(p->owner)->lock))) {
+               if (!ast_mutex_trylock(&(p->owner->_bridge)->lock)) {
                        if (!ast_mutex_trylock(&p->chan->lock)) {
-                               ast_channel_masquerade(p->chan, ast_bridged_channel(p->owner));
+                               ast_channel_masquerade(p->chan, p->owner->_bridge);
                                p->alreadymasqed = 1;
                                ast_mutex_unlock(&p->chan->lock);
                        }
-                       ast_mutex_unlock(&(ast_bridged_channel(p->owner)->lock));
+                       ast_mutex_unlock(&(p->owner->_bridge)->lock);
                }
        }
 }
index cfd9607..5e21641 100755 (executable)
@@ -8186,6 +8186,7 @@ static int handle_request(struct sip_pvt *p, struct sip_request *req, struct soc
                                        if (c) {
                                                transfer_to = ast_bridged_channel(c);
                                                if (transfer_to) {
+                                                       ast_log(LOG_DEBUG, "Got SIP blind transfer, applying to '%s'\n", transfer_to->name);
                                                        ast_moh_stop(transfer_to);
                                                        if (!strcmp(p->refer_to, ast_parking_ext())) {
                                                                /* Must release c's lock now, because it will not longer
@@ -8202,6 +8203,7 @@ static int handle_request(struct sip_pvt *p, struct sip_request *req, struct soc
                                                                ast_async_goto(transfer_to,p->context, p->refer_to,1);
                                                        }
                                                } else {
+                                                       ast_log(LOG_DEBUG, "Got SIP blind transfer but nothing to transfer to.\n");
                                                        ast_queue_hangup(p->owner);
                                                }
                                        }
index fb41c71..c47100b 100755 (executable)
@@ -18,9 +18,9 @@ persistentagents=yes
 ;autologoff=15
 ;
 ; Define ackcall to require an acknowledgement by '#' when
-; an agent logs in using agentcallbacklogin.  Default is "yes".
+; an agent logs in using agentcallbacklogin.  Default is "no".
 ;
-;ackcall=yes
+;ackcall=no
 ;
 ; Define wrapuptime.  This is the minimum amount of time when
 ; after disconnecting before the caller can receive a new call