properly display connected channel name in 'agents' manager action for non-callback...
authorKevin P. Fleming <kpfleming@digium.com>
Thu, 13 Oct 2005 21:59:25 +0000 (21:59 +0000)
committerKevin P. Fleming <kpfleming@digium.com>
Thu, 13 Oct 2005 21:59:25 +0000 (21:59 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@6766 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_agent.c

index 1f5a34c..ea910c7 100755 (executable)
@@ -1399,16 +1399,7 @@ static int action_agents(struct mansession *s, struct message *m)
                /* Set a default status. It 'should' get changed. */
                status = "AGENT_UNKNOWN";
 
-               if(p->chan) {
-                       loginChan = p->loginchan;
-                       if(p->owner && p->owner->_bridge) {
-                               talkingtoChan = p->chan->cid.cid_num;
-                               status = "AGENT_ONCALL";
-                       } else {
-                               talkingtoChan = "n/a";
-                               status = "AGENT_IDLE";
-                       }
-               } else if(!ast_strlen_zero(p->loginchan)) {
+               if (!ast_strlen_zero(p->loginchan)) {
                        loginChan = p->loginchan;
                        talkingtoChan = "n/a";
                        status = "AGENT_IDLE";
@@ -1416,6 +1407,15 @@ static int action_agents(struct mansession *s, struct message *m)
                                snprintf(chanbuf, sizeof(chanbuf), " %s (Confirmed)", p->loginchan);
                                loginChan = chanbuf;
                        }
+               } else if (p->chan) {
+                       loginChan = ast_strdupa(p->chan->name);
+                       if (p->owner && p->owner->_bridge) {
+                               talkingtoChan = p->chan->cid.cid_num;
+                               status = "AGENT_ONCALL";
+                       } else {
+                               talkingtoChan = "n/a";
+                               status = "AGENT_IDLE";
+                       }
                } else {
                        loginChan = "n/a";
                        talkingtoChan = "n/a";
@@ -2175,10 +2175,9 @@ static int action_agent_callback_login(struct mansession *s, struct message *m)
                }
                ast_mutex_lock(&p->lock);
                login_state = 1; /* Successful Login */
-               ast_copy_string(p->loginchan, exten, sizeof(p->loginchan));
                
                if (ast_strlen_zero(context))
-                       snprintf(p->loginchan, sizeof(p->loginchan), "%s", exten);
+                       ast_copy_string(p->loginchan, exten, sizeof(p->loginchan));
                else
                        snprintf(p->loginchan, sizeof(p->loginchan), "%s@%s", exten, context);