Index: apps/app_queue.c =================================================================== --- apps/app_queue.c (revision 55913) +++ apps/app_queue.c (working copy) @@ -297,6 +297,7 @@ int dynamic; /*!< Are we dynamically added? */ int status; /*!< Status of queue member */ int paused; /*!< Are we paused (not accepting calls)? */ + int autopaused; /*!< Did we automatically get paused? */ time_t lastcall; /*!< When last successful call was hungup */ unsigned int dead:1; /*!< Used to detect members deleted in realtime */ unsigned int delme:1; /*!< Flag to delete entry on reload */ @@ -334,6 +335,7 @@ unsigned int strategy:3; unsigned int maskmemberstatus:1; unsigned int realtime:1; + unsigned int agentautopause:1; /*!< Automatically pause an agent who is In Use / Busy */ int announcefrequency; /*!< How often to announce their position */ int periodicannouncefrequency; /*!< How often to play periodic announcement */ int roundingseconds; /*!< How many seconds do we round to? */ @@ -439,7 +441,11 @@ ast_mutex_lock(&q->lock); for (member = q->members; member; member = member->next) { - if (member->paused) continue; + if (!q->agentautopause) { + if (member->paused) continue; + } else { + if (member->paused && !member->autopaused) continue; + } switch (member->status) { case AST_DEVICE_INVALID: @@ -518,6 +524,20 @@ if (strcasecmp(sc->dev, interface)) continue; + if ((sc->state == 2 || sc->state == 3) && q->agentautopause == 1) { + if (option_debug) + ast_log(LOG_DEBUG, "Member '%s' autopaused due to state '%d' (%s)\n", cur->interface, sc->state, devstate2str(sc->state)); + cur->paused = 1; + cur->autopaused = 1; + } else { + if (cur->autopaused == 1) { + if (option_debug) + ast_log(LOG_DEBUG, "Member '%s' un-autopaused due to state '%d' (%s)\n", cur->interface, sc->state, devstate2str(sc->state)); + cur->paused = 0; + cur->autopaused =0; + } + } + if (cur->status != sc->state) { cur->status = sc->state; if (q->maskmemberstatus) @@ -828,6 +848,8 @@ q->leavewhenempty = 0; } else if (!strcasecmp(param, "eventmemberstatus")) { q->maskmemberstatus = !ast_true(val); + } else if (!strcasecmp(param, "agentautopause")) { + q->agentautopause = ast_true(val); } else if (!strcasecmp(param, "eventwhencalled")) { q->eventwhencalled = ast_true(val); } else if (!strcasecmp(param, "reportholdtime")) { @@ -2588,6 +2610,7 @@ if (new_member != NULL) { new_member->dynamic = 1; new_member->next = q->members; + new_member->autopaused = 0; q->members = new_member; manager_event(EVENT_FLAG_AGENT, "QueueMemberAdded", "Queue: %s\r\n"