Index: asterisk/channels/chan_agent.c =================================================================== RCS file: /usr/cvsroot/asterisk/channels/chan_agent.c,v retrieving revision 1.77 diff -r1.77 chan_agent.c 66c66 < " 's' -- silent login - do not announce the login ok segment\n"; --- > " 's' -- silent login - do not announce the login ok segment after agent logged in/off\n"; 70c70 < "Asks the agent to login to the system with callback. Always returns -1.\n" --- > "Asks the agent to login to the system with callback.\n" 72c72,74 < "context. \n"; --- > "context. \n" > "The option string may contain zero or more of the following characters:\n" > " 's' -- silent login - do not announce the login ok segment agent logged in/off\n"; 83a86 > #define AST_MAX_FILENAME_LEN 256 91a95,97 > static int maxlogintries = 3; > static char agentgoodbye[AST_MAX_FILENAME_LEN] = "vm-goodbye"; > 259c265 < } --- > } 792c798 < if (!strcasecmp(v->name, "agent")) { --- > if (!strcasecmp(v->name, "agent") && !ast_strlen_zero(v->value)) { 794c800 < } else if (!strcasecmp(v->name, "group")) { --- > } else if (!strcasecmp(v->name, "group") && !ast_strlen_zero(v->value)) { 796c802 < } else if (!strcasecmp(v->name, "autologoff")) { --- > } else if (!strcasecmp(v->name, "autologoff") && !ast_strlen_zero(v->value)) { 800c806 < } else if (!strcasecmp(v->name, "ackcall")) { --- > } else if (!strcasecmp(v->name, "ackcall") && !ast_strlen_zero(v->value)) { 804c810 < ackcall = 1; --- > ackcall = 1; 807c813 < } else if (!strcasecmp(v->name, "wrapuptime")) { --- > } else if (!strcasecmp(v->name, "wrapuptime") && !ast_strlen_zero(v->value)) { 811c817,823 < } else if (!strcasecmp(v->name, "musiconhold")) { --- > } else if (!strcasecmp(v->name, "maxlogintries") && !ast_strlen_zero(v->value)) { > maxlogintries = atoi(v->value); > if (maxlogintries < 0) > maxlogintries = 0; > } else if (!strcasecmp(v->name, "goodbye") && !ast_strlen_zero(v->value)) { > strcpy(agentgoodbye,v->value); > } else if (!strcasecmp(v->name, "musiconhold") && !ast_strlen_zero(v->value)) { 813,815c825,830 < } else if (!strcasecmp(v->name, "updatecdr")) { < updatecdr = ast_true(v->value); < } else if (!strcasecmp(v->name, "recordagentcalls")) { --- > } else if (!strcasecmp(v->name, "updatecdr") && !ast_strlen_zero(v->value)) { > if (ast_true(v->value)) > updatecdr = 1; > else > updatecdr = 0; > } else if (!strcasecmp(v->name, "recordagentcalls") && !ast_strlen_zero(v->value)) { 817c832 < } else if (!strcasecmp(v->name, "createlink")) { --- > } else if (!strcasecmp(v->name, "createlink") && !ast_strlen_zero(v->value)) { 819c834 < } else if (!strcasecmp(v->name, "recordformat")) { --- > } else if (!strcasecmp(v->name, "recordformat") && !ast_strlen_zero(v->value)) { 825c840 < } else if (!strcasecmp(v->name, "urlprefix")) { --- > } else if (!strcasecmp(v->name, "urlprefix") && !ast_strlen_zero(v->value)) { 829c844 < } else if (!strcasecmp(v->name, "savecallsin")) { --- > } else if (!strcasecmp(v->name, "savecallsin") && !ast_strlen_zero(v->value)) { 1141a1157 > int max_login_tries = maxlogintries; 1144a1161 > int login_state = 0; 1152a1170,1172 > char option; > char badoption[2]; > char *tmpoptions = NULL; 1155c1175,1178 < int play_announcement; --- > int play_announcement = 1; > char agent_goodbye[AST_MAX_FILENAME_LEN]; > strcpy(agent_goodbye, agentgoodbye); > int update_cdr = updatecdr; 1162a1186,1208 > /* Set Channel Specific Login Overrides */ > if (pbx_builtin_getvar_helper(chan, "AGENTLMAXLOGINTRIES") && strlen(pbx_builtin_getvar_helper(chan, "AGENTLMAXLOGINTRIES"))) { > max_login_tries = atoi(pbx_builtin_getvar_helper(chan, "AGENTMAXLOGINTRIES")); > if (max_login_tries < 0) > max_login_tries = 0; > tmpoptions=pbx_builtin_getvar_helper(chan, "AGENTMAXLOGINTRIES"); > ast_verbose(VERBOSE_PREFIX_3 "Saw variable AGENTMAXLOGINTRIES=%s, setting max_login_tries to: %d on Channel '%s'.\n",tmpoptions,max_login_tries,chan->name); > } > if (pbx_builtin_getvar_helper(chan, "AGENTUPDATECDR") && strlen(pbx_builtin_getvar_helper(chan, "AGENTUPDATECDR"))) { > if (ast_true(pbx_builtin_getvar_helper(chan, "AGENTUPDATECDR"))) > update_cdr = 1; > else > update_cdr = 0; > tmpoptions=pbx_builtin_getvar_helper(chan, "AGENTUPDATECDR"); > ast_verbose(VERBOSE_PREFIX_3 "Saw variable AGENTUPDATECDR=%s, setting update_cdr to: %d on Channel '%s'.\n",tmpoptions,update_cdr,chan->name); > } > if (pbx_builtin_getvar_helper(chan, "AGENTGOODBYE") && strlen(pbx_builtin_getvar_helper(chan, "AGENTGOODBYE"))) { > strcpy(agent_goodbye, pbx_builtin_getvar_helper(chan, "AGENTGOODBYE")); > tmpoptions=pbx_builtin_getvar_helper(chan, "AGENTGOODBYE"); > ast_verbose(VERBOSE_PREFIX_3 "Saw variable AGENTGOODBYE=%s, setting agent_goodbye to: %s on Channel '%s'.\n",tmpoptions,agent_goodbye,chan->name); > } > /* End Channel Specific Login Overrides */ > /* Read command line options */ 1179a1226,1239 > if( options ) { > while(*options) { > option = (char)options[0]; > if (option=='s') > play_announcement = 0; > else { > badoption[0] = option; > badoption[1] = '\0'; > tmpoptions=badoption; > ast_verbose(VERBOSE_PREFIX_3 "Warning: option %s is unknown.\n",tmpoptions); > } > options++; > } > } 1180a1241 > /* End command line options */ 1190c1251,1252 < while (!res && (tries < 3)) { --- > while (!res && (max_login_tries==0 || tries < max_login_tries)) { > tries++; 1218a1281,1307 > login_state = 1; /* Successful Login */ > /* Set Channel Specific Agent Overides */ > if (pbx_builtin_getvar_helper(chan, "AGENTACKCALL") && strlen(pbx_builtin_getvar_helper(chan, "AGENTACKCALL"))) { > if (!strcasecmp(pbx_builtin_getvar_helper(chan, "AGENTACKCALL"), "always")) > p->ackcall = 2; > else if (ast_true(pbx_builtin_getvar_helper(chan, "AGENTACKCALL"))) > p->ackcall = 1; > else > p->ackcall = 0; > tmpoptions=pbx_builtin_getvar_helper(chan, "AGENTACKCALL"); > ast_verbose(VERBOSE_PREFIX_3 "Saw variable AGENTACKCALL=%s, setting ackcall to: %d for Agent '%s'.\n",tmpoptions,p->ackcall,p->agent); > } > if (pbx_builtin_getvar_helper(chan, "AGENTAUTOLOGOFF") && strlen(pbx_builtin_getvar_helper(chan, "AGENTAUTOLOGOFF"))) { > p->autologoff = atoi(pbx_builtin_getvar_helper(chan, "AGENTAUTOLOGOFF")); > if (p->autologoff < 0) > p->autologoff = 0; > tmpoptions=pbx_builtin_getvar_helper(chan, "AGENTAUTOLOGOFF"); > ast_verbose(VERBOSE_PREFIX_3 "Saw variable AGENTAUTOLOGOFF=%s, setting autologff to: %d for Agent '%s'.\n",tmpoptions,p->autologoff,p->agent); > } > if (pbx_builtin_getvar_helper(chan, "AGENTWRAPUPTIME") && strlen(pbx_builtin_getvar_helper(chan, "AGENTWRAPUPTIME"))) { > p->wrapuptime = atoi(pbx_builtin_getvar_helper(chan, "AGENTWRAPUPTIME")); > if (p->wrapuptime < 0) > p->wrapuptime = 0; > tmpoptions=pbx_builtin_getvar_helper(chan, "AGENTWRAPUPTIME"); > ast_verbose(VERBOSE_PREFIX_3 "Saw variable AGENTWRAPUPTIME=%s, setting wrapuptime to: %d for Agent '%s'.\n",tmpoptions,p->wrapuptime,p->agent); > } > /* End Channel Specific Agent Overides */ 1254a1344 > exten = tmpchan; 1259c1349 < strncpy(last_loginchan, p->loginchan, sizeof(last_loginchan) - 1); --- > strncpy(last_loginchan, p->loginchan, sizeof(last_loginchan) - 1); 1262c1352,1353 < if (ast_strlen_zero(p->loginchan)) --- > if (ast_strlen_zero(p->loginchan)) { > login_state = 2; 1263a1355 > } 1274c1366 < if(updatecdr && chan->cdr) --- > if(update_cdr && chan->cdr) 1282,1285c1374 < play_announcement = 1; < if( options ) < if( strchr( options, 's' ) ) < play_announcement = 0; --- > 1288c1377 < if( !res && play_announcement ) --- > if( !res && play_announcement==1 ) 1318c1407 < if (option_verbose > 2) --- > if (option_verbose > 2) 1336,1340d1424 < res = ast_streamfile(chan, "vm-goodbye", chan->language); < if (!res) < res = ast_waitstream(chan, ""); < if (!res) < res = ast_safe_sleep(chan, 1000); 1356c1440 < if (updatecdr && chan->cdr) --- > if (update_cdr && chan->cdr) 1461c1545 < if (!res) --- > if (!res && (max_login_tries==0 || tries < max_login_tries)) { 1462a1547 > } 1466c1551,1587 < /* Always hangup */ --- > if (!res) > res = ast_safe_sleep(chan, 500); > > /* AgentLogin() exit */ > if (!callbackmode) { > return -1; > } > /* AgentCallbackLogin() exit*/ > else { > /* Set variables */ > if (login_state > 0) { > pbx_builtin_setvar_helper(chan, "AGENTNUMBER", user); > if (login_state==1) { > pbx_builtin_setvar_helper(chan, "AGENTSTATUS", "on"); > pbx_builtin_setvar_helper(chan, "AGENTEXTEN", exten); > } > else { > pbx_builtin_setvar_helper(chan, "AGENTSTATUS", "off"); > } > } > else { > pbx_builtin_setvar_helper(chan, "AGENTSTATUS", "fail"); > } > if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 1, chan->callerid)) > return 0; > /* Do we need to play agent-goodbye now that we will be hanging up? */ > if (play_announcement==1) { > if (!res) > res = ast_safe_sleep(chan, 1000); > res = ast_streamfile(chan, agent_goodbye, chan->language); > if (!res) > res = ast_waitstream(chan, ""); > if (!res) > res = ast_safe_sleep(chan, 1000); > } > } > /* We should never get here if next priority exists when in callbackmode */ Index: asterisk/configs/agents.conf.sample =================================================================== RCS file: /usr/cvsroot/asterisk/configs/agents.conf.sample,v retrieving revision 1.11 diff -r1.11 agents.conf.sample 34a35,70 > ; Define maxlogintries to set the limit of failed login attempts. > ; The value should be an integer. Default is "3". > ; Setting to 0 will disable maxlogintries. > ; > ;maxlogintries=3 > ; > ; Define playannouncement to enable/disable playing of agent logged in/off > ; and goodbye message. Default is "yes". Valid values are boolean. > ; This option is the same as option 's' on AgentCallbackLogin() > ; > ;playannouncement=yes > ; > ; Define playgoodbye to enalbe/disable playing of goodbye message. > ; playannouncemnet must be enabled for goodbye to be played. > ; Default is "yes". Valid values are boolean. > ; > ;playgoodbye=yes > ; > ; Define hangupcall to adjust if the call is hungup when exiting function > ; AgentCallbackLogin(). This option has no effect on AgentLogin() or > ; AgentMonitorOutgoing(). Default is "always". > ; Valid values are: never, always, loginfail, loginok > ; Short versions are: no, yes, fail, ok > ; Upon exiting due to login failure, the priority will be increased by 100. > ; > ;hangupcall=always > ; > ; The values autologoff, ackcall, wrapuptime, updatecdr, maxlogintries, > ; playannouncement, playgoodbye, and hangupcall can be adjusted in > ; extensions.conf for individual extensions when using AgentLogin() or > ; AgentCallaackLogin(). Not all variables apply to both functions. > ; Use the following convention with SetVar to make on-the-fly adjustments: > ; variable name is "AGENT" + option in all caps. Values are the same. > ; Ex: exten => s,1,SetVar(AGENTMAXLOGINTRIES=0) > ; exten => s,2,AgentCallbackLogin() > ; 65a102,104 > ; The file to play when saying goodbye. The default is vm-goodbye > ;goodbye=vm-goodbye > ; Index: asterisk/doc/README.variables =================================================================== RCS file: /usr/cvsroot/asterisk/doc/README.variables,v retrieving revision 1.19 diff -r1.19 README.variables 72a73,74 > ${AGENTSTATUS} Status of agent upon exiting AgentCallbackLogin(). set to on/off/fail > ${AGENTEXTEN} The callback extension of the agent logged in via AgentCallbackLogin().