--- chan_agent.c Mon Jan 5 22:10:28 2004 +++ chan_agent2.c Wed Jan 7 23:20:46 2004 @@ -50,9 +50,11 @@ static char *app = "AgentLogin"; static char *app2 = "AgentCallbackLogin"; +static char *app3 = "AgentCallbackLogout"; static char *synopsis = "Call agent login"; static char *synopsis2 = "Call agent callback login"; +static char *synopsis3 = "Call agent callback logout"; static char *descrip = " AgentLogin([AgentNo][|options]):\n" @@ -69,6 +71,12 @@ "The agent's callback extension is called (optionally with the specified\n" "context. \n"; +static char *descrip3 = +" AgentCallbackLogout([AgentNo][|[options][exten]@context]):\n" +"Asks the agent to login to the system with callback. Always returns -1.\n" +"The agent's callback extension is called (optionally with the specified\n" +"context. \n"; + static char moh[80] = "default"; #define AST_MAX_AGENT 80 /* Agent ID or Password max length */ @@ -1025,7 +1033,7 @@ STANDARD_LOCAL_USER; LOCAL_USER_DECL; -static int __login_exec(struct ast_channel *chan, void *data, int callbackmode) +static int __login_exec(struct ast_channel *chan, void *data, int callbackmode, int logoutmode) { int res=0; int tries = 0; @@ -1115,7 +1123,9 @@ strncpy(tmpchan, exten, sizeof(tmpchan) - 1); res = 0; } else + if(!logoutmode) { res = ast_app_getdata(chan, "agent-newlocation", tmpchan+pos, sizeof(tmpchan) - 2, 0); + } if (!strlen(tmpchan) || ast_exists_extension(chan, context && strlen(context) ? context : "default", tmpchan, 1, NULL)) break; @@ -1302,12 +1312,17 @@ static int login_exec(struct ast_channel *chan, void *data) { - return __login_exec(chan, data, 0); + return __login_exec(chan, data, 0, 0); } static int callback_exec(struct ast_channel *chan, void *data) { - return __login_exec(chan, data, 1); + return __login_exec(chan, data, 1, 0); +} + +static int callbackout_exec(struct ast_channel *chan, void *data) +{ + return __login_exec(chan, data, 1, 1); } int load_module() @@ -1319,6 +1334,8 @@ } ast_register_application(app, login_exec, synopsis, descrip); ast_register_application(app2, callback_exec, synopsis2, descrip2); + ast_register_application(app3, callbackout_exec, synopsis3, descrip3); + ast_cli_register(&cli_show_agents); /* Read in the config */ read_agent_config();