Honor context in agent callback login
authorMark Spencer <markster@digium.com>
Sun, 3 Aug 2003 18:22:12 +0000 (18:22 +0000)
committerMark Spencer <markster@digium.com>
Sun, 3 Aug 2003 18:22:12 +0000 (18:22 +0000)
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@1254 65c4cc65-6c06-0410-ace0-fbb531ad65f3

channels/chan_agent.c

index 0d96e8f..45bbe05 100755 (executable)
@@ -836,6 +836,7 @@ static int __login_exec(struct ast_channel *chan, void *data, int callbackmode)
        char info[512];
        char *opt_user = NULL;
        char *options = NULL;
+       char *context = NULL;
        int play_announcement;
        char *filename = "agent-loginok";
        
@@ -849,6 +850,13 @@ static int __login_exec(struct ast_channel *chan, void *data, int callbackmode)
                if (options) {
                        *options = '\0';
                        options++;
+                       if (callbackmode) {
+                               context = strchr(options, '@');
+                               if (context) {
+                                       *context = '\0';
+                                       context++;
+                               }
+                       }
                }
        }
 
@@ -895,7 +903,10 @@ static int __login_exec(struct ast_channel *chan, void *data, int callbackmode)
                                                        /* Retrieve login chan */
                                                        res = ast_app_getdata(chan, "agent-newlocation", tmpchan, sizeof(tmpchan) - 1, 0);
                                                        if (!res) {
-                                                               strncpy(p->loginchan, tmpchan, sizeof(p->loginchan) - 1);
+                                                               if (context && strlen(context))
+                                                                       snprintf(p->loginchan, sizeof(p->loginchan), "%s@%s", tmpchan, context);
+                                                               else
+                                                                       strncpy(p->loginchan, tmpchan, sizeof(p->loginchan) - 1);
                                                                if (!strlen(p->loginchan))
                                                                        filename = "agent-loggedoff";
                                                                p->acknowledged = 0;