Merge "app_queue: Add change priority of call"
authorGeorge Joseph <gjoseph@digium.com>
Tue, 18 Jul 2017 14:37:36 +0000 (09:37 -0500)
committerGerrit Code Review <gerrit2@gerrit.digium.api>
Tue, 18 Jul 2017 14:37:36 +0000 (09:37 -0500)
1  2 
apps/app_queue.c

@@@ -10871,8 -10970,277 +11020,9 @@@ static struct ast_cli_entry cli_queue[
        AST_CLI_DEFINE(handle_queue_set_member_ringinuse, "Set ringinuse for a channel of a specified queue"),
        AST_CLI_DEFINE(handle_queue_reload, "Reload queues, members, queue rules, or parameters"),
        AST_CLI_DEFINE(handle_queue_reset, "Reset statistics for a queue"),
+       AST_CLI_DEFINE(handle_queue_change_priority_caller, "Change priority caller on queue"),
  };
  
 -/* struct call_queue astdata mapping. */
 -#define DATA_EXPORT_CALL_QUEUE(MEMBER)                                        \
 -      MEMBER(call_queue, name, AST_DATA_STRING)                       \
 -      MEMBER(call_queue, moh, AST_DATA_STRING)                        \
 -      MEMBER(call_queue, announce, AST_DATA_STRING)                   \
 -      MEMBER(call_queue, context, AST_DATA_STRING)                    \
 -      MEMBER(call_queue, membermacro, AST_DATA_STRING)                \
 -      MEMBER(call_queue, membergosub, AST_DATA_STRING)                \
 -      MEMBER(call_queue, defaultrule, AST_DATA_STRING)                \
 -      MEMBER(call_queue, sound_next, AST_DATA_STRING)                 \
 -      MEMBER(call_queue, sound_thereare, AST_DATA_STRING)             \
 -      MEMBER(call_queue, sound_calls, AST_DATA_STRING)                \
 -      MEMBER(call_queue, queue_quantity1, AST_DATA_STRING)            \
 -      MEMBER(call_queue, queue_quantity2, AST_DATA_STRING)            \
 -      MEMBER(call_queue, sound_holdtime, AST_DATA_STRING)             \
 -      MEMBER(call_queue, sound_minutes, AST_DATA_STRING)              \
 -      MEMBER(call_queue, sound_minute, AST_DATA_STRING)               \
 -      MEMBER(call_queue, sound_seconds, AST_DATA_STRING)              \
 -      MEMBER(call_queue, sound_thanks, AST_DATA_STRING)               \
 -      MEMBER(call_queue, sound_callerannounce, AST_DATA_STRING)       \
 -      MEMBER(call_queue, sound_reporthold, AST_DATA_STRING)           \
 -      MEMBER(call_queue, dead, AST_DATA_BOOLEAN)                      \
 -      MEMBER(call_queue, ringinuse, AST_DATA_BOOLEAN)                 \
 -      MEMBER(call_queue, announce_to_first_user, AST_DATA_BOOLEAN)    \
 -      MEMBER(call_queue, setinterfacevar, AST_DATA_BOOLEAN)           \
 -      MEMBER(call_queue, setqueuevar, AST_DATA_BOOLEAN)               \
 -      MEMBER(call_queue, setqueueentryvar, AST_DATA_BOOLEAN)          \
 -      MEMBER(call_queue, reportholdtime, AST_DATA_BOOLEAN)            \
 -      MEMBER(call_queue, wrapped, AST_DATA_BOOLEAN)                   \
 -      MEMBER(call_queue, timeoutrestart, AST_DATA_BOOLEAN)            \
 -      MEMBER(call_queue, announceholdtime, AST_DATA_INTEGER)          \
 -      MEMBER(call_queue, realtime, AST_DATA_BOOLEAN)                  \
 -      MEMBER(call_queue, found, AST_DATA_BOOLEAN)                     \
 -      MEMBER(call_queue, announcepositionlimit, AST_DATA_INTEGER)     \
 -      MEMBER(call_queue, announcefrequency, AST_DATA_SECONDS)         \
 -      MEMBER(call_queue, minannouncefrequency, AST_DATA_SECONDS)      \
 -      MEMBER(call_queue, periodicannouncefrequency, AST_DATA_SECONDS) \
 -      MEMBER(call_queue, numperiodicannounce, AST_DATA_INTEGER)       \
 -      MEMBER(call_queue, randomperiodicannounce, AST_DATA_INTEGER)    \
 -      MEMBER(call_queue, roundingseconds, AST_DATA_SECONDS)           \
 -      MEMBER(call_queue, holdtime, AST_DATA_SECONDS)                  \
 -      MEMBER(call_queue, talktime, AST_DATA_SECONDS)                  \
 -      MEMBER(call_queue, callscompleted, AST_DATA_INTEGER)            \
 -      MEMBER(call_queue, callsabandoned, AST_DATA_INTEGER)            \
 -      MEMBER(call_queue, servicelevel, AST_DATA_INTEGER)              \
 -      MEMBER(call_queue, callscompletedinsl, AST_DATA_INTEGER)        \
 -      MEMBER(call_queue, monfmt, AST_DATA_STRING)                     \
 -      MEMBER(call_queue, montype, AST_DATA_INTEGER)                   \
 -      MEMBER(call_queue, count, AST_DATA_INTEGER)                     \
 -      MEMBER(call_queue, maxlen, AST_DATA_INTEGER)                    \
 -      MEMBER(call_queue, wrapuptime, AST_DATA_SECONDS)                \
 -      MEMBER(call_queue, retry, AST_DATA_SECONDS)                     \
 -      MEMBER(call_queue, timeout, AST_DATA_SECONDS)                   \
 -      MEMBER(call_queue, weight, AST_DATA_INTEGER)                    \
 -      MEMBER(call_queue, autopause, AST_DATA_INTEGER)                 \
 -      MEMBER(call_queue, timeoutpriority, AST_DATA_INTEGER)           \
 -      MEMBER(call_queue, rrpos, AST_DATA_INTEGER)                     \
 -      MEMBER(call_queue, memberdelay, AST_DATA_INTEGER)               \
 -      MEMBER(call_queue, autofill, AST_DATA_INTEGER)                  \
 -      MEMBER(call_queue, members, AST_DATA_CONTAINER)
 -
 -AST_DATA_STRUCTURE(call_queue, DATA_EXPORT_CALL_QUEUE);
 -
 -/* struct member astdata mapping. */
 -#define DATA_EXPORT_MEMBER(MEMBER)                                    \
 -      MEMBER(member, interface, AST_DATA_STRING)                      \
 -      MEMBER(member, state_interface, AST_DATA_STRING)                \
 -      MEMBER(member, membername, AST_DATA_STRING)                     \
 -      MEMBER(member, penalty, AST_DATA_INTEGER)                       \
 -      MEMBER(member, calls, AST_DATA_INTEGER)                         \
 -      MEMBER(member, dynamic, AST_DATA_INTEGER)                       \
 -      MEMBER(member, realtime, AST_DATA_INTEGER)                      \
 -      MEMBER(member, status, AST_DATA_INTEGER)                        \
 -      MEMBER(member, paused, AST_DATA_BOOLEAN)                        \
 -      MEMBER(member, rt_uniqueid, AST_DATA_STRING)
 -
 -AST_DATA_STRUCTURE(member, DATA_EXPORT_MEMBER);
 -
 -#define DATA_EXPORT_QUEUE_ENT(MEMBER)                                         \
 -      MEMBER(queue_ent, moh, AST_DATA_STRING)                                 \
 -      MEMBER(queue_ent, announce, AST_DATA_STRING)                            \
 -      MEMBER(queue_ent, context, AST_DATA_STRING)                             \
 -      MEMBER(queue_ent, digits, AST_DATA_STRING)                              \
 -      MEMBER(queue_ent, valid_digits, AST_DATA_INTEGER)                       \
 -      MEMBER(queue_ent, pos, AST_DATA_INTEGER)                                \
 -      MEMBER(queue_ent, prio, AST_DATA_INTEGER)                               \
 -      MEMBER(queue_ent, last_pos_said, AST_DATA_INTEGER)                      \
 -      MEMBER(queue_ent, last_periodic_announce_time, AST_DATA_INTEGER)        \
 -      MEMBER(queue_ent, last_periodic_announce_sound, AST_DATA_INTEGER)       \
 -      MEMBER(queue_ent, last_pos, AST_DATA_INTEGER)                           \
 -      MEMBER(queue_ent, opos, AST_DATA_INTEGER)                               \
 -      MEMBER(queue_ent, handled, AST_DATA_INTEGER)                            \
 -      MEMBER(queue_ent, pending, AST_DATA_INTEGER)                            \
 -      MEMBER(queue_ent, max_penalty, AST_DATA_INTEGER)                        \
 -      MEMBER(queue_ent, min_penalty, AST_DATA_INTEGER)                        \
 -      MEMBER(queue_ent, linpos, AST_DATA_INTEGER)                             \
 -      MEMBER(queue_ent, linwrapped, AST_DATA_INTEGER)                         \
 -      MEMBER(queue_ent, start, AST_DATA_INTEGER)                              \
 -      MEMBER(queue_ent, expire, AST_DATA_INTEGER)                             \
 -      MEMBER(queue_ent, cancel_answered_elsewhere, AST_DATA_INTEGER)
 -
 -AST_DATA_STRUCTURE(queue_ent, DATA_EXPORT_QUEUE_ENT);
 -
 -/*!
 - * \internal
 - * \brief Add a queue to the data_root node.
 - * \param[in] search The search tree.
 - * \param[in] data_root The main result node.
 - * \param[in] queue The queue to add.
 - */
 -static void queues_data_provider_get_helper(const struct ast_data_search *search,
 -      struct ast_data *data_root, struct call_queue *queue)
 -{
 -      struct ao2_iterator im;
 -      struct member *member;
 -      struct queue_ent *qe;
 -      struct ast_data *data_queue, *data_members = NULL, *enum_node;
 -      struct ast_data *data_member, *data_callers = NULL, *data_caller, *data_caller_channel;
 -
 -      data_queue = ast_data_add_node(data_root, "queue");
 -      if (!data_queue) {
 -              return;
 -      }
 -
 -      ast_data_add_structure(call_queue, data_queue, queue);
 -
 -      ast_data_add_str(data_queue, "strategy", int2strat(queue->strategy));
 -      ast_data_add_int(data_queue, "membercount", ao2_container_count(queue->members));
 -
 -      /* announce position */
 -      enum_node = ast_data_add_node(data_queue, "announceposition");
 -      if (!enum_node) {
 -              return;
 -      }
 -      switch (queue->announceposition) {
 -      case ANNOUNCEPOSITION_LIMIT:
 -              ast_data_add_str(enum_node, "text", "limit");
 -              break;
 -      case ANNOUNCEPOSITION_MORE_THAN:
 -              ast_data_add_str(enum_node, "text", "more");
 -              break;
 -      case ANNOUNCEPOSITION_YES:
 -              ast_data_add_str(enum_node, "text", "yes");
 -              break;
 -      case ANNOUNCEPOSITION_NO:
 -              ast_data_add_str(enum_node, "text", "no");
 -              break;
 -      default:
 -              ast_data_add_str(enum_node, "text", "unknown");
 -              break;
 -      }
 -      ast_data_add_int(enum_node, "value", queue->announceposition);
 -
 -      /* add queue members */
 -      im = ao2_iterator_init(queue->members, 0);
 -      while ((member = ao2_iterator_next(&im))) {
 -              if (!data_members) {
 -                      data_members = ast_data_add_node(data_queue, "members");
 -                      if (!data_members) {
 -                              ao2_ref(member, -1);
 -                              continue;
 -                      }
 -              }
 -
 -              data_member = ast_data_add_node(data_members, "member");
 -              if (!data_member) {
 -                      ao2_ref(member, -1);
 -                      continue;
 -              }
 -
 -              ast_data_add_structure(member, data_member, member);
 -
 -              ao2_ref(member, -1);
 -      }
 -      ao2_iterator_destroy(&im);
 -
 -      /* include the callers inside the result. */
 -      if (queue->head) {
 -              for (qe = queue->head; qe; qe = qe->next) {
 -                      if (!data_callers) {
 -                              data_callers = ast_data_add_node(data_queue, "callers");
 -                              if (!data_callers) {
 -                                      continue;
 -                              }
 -                      }
 -
 -                      data_caller = ast_data_add_node(data_callers, "caller");
 -                      if (!data_caller) {
 -                              continue;
 -                      }
 -
 -                      ast_data_add_structure(queue_ent, data_caller, qe);
 -
 -                      /* add the caller channel. */
 -                      data_caller_channel = ast_data_add_node(data_caller, "channel");
 -                      if (!data_caller_channel) {
 -                              continue;
 -                      }
 -
 -                      ast_channel_data_add_structure(data_caller_channel, qe->chan, 1);
 -              }
 -      }
 -
 -      /* if this queue doesn't match remove the added queue. */
 -      if (!ast_data_search_match(search, data_queue)) {
 -              ast_data_remove_node(data_root, data_queue);
 -      }
 -}
 -
 -/*!
 - * \internal
 - * \brief Callback used to generate the queues tree.
 - * \param[in] search The search pattern tree.
 - * \retval NULL on error.
 - * \retval non-NULL The generated tree.
 - */
 -static int queues_data_provider_get(const struct ast_data_search *search,
 -      struct ast_data *data_root)
 -{
 -      struct ao2_iterator i;
 -      struct call_queue *queue, *queue_realtime = NULL;
 -      struct ast_config *cfg;
 -
 -      /* load realtime queues. */
 -      cfg = ast_load_realtime_multientry("queues", "name LIKE", "%", SENTINEL);
 -      if (cfg) {
 -              char *category = NULL;
 -              while ((category = ast_category_browse(cfg, category))) {
 -                      const char *queuename = ast_variable_retrieve(cfg, category, "name");
 -                      if ((queue = find_load_queue_rt_friendly(queuename))) {
 -                              queue_unref(queue);
 -                      }
 -              }
 -              ast_config_destroy(cfg);
 -      }
 -
 -      /* static queues. */
 -      i = ao2_iterator_init(queues, 0);
 -      while ((queue = ao2_iterator_next(&i))) {
 -              ao2_lock(queue);
 -              if (queue->realtime) {
 -                      queue_realtime = find_load_queue_rt_friendly(queue->name);
 -                      if (!queue_realtime) {
 -                              ao2_unlock(queue);
 -                              queue_unref(queue);
 -                              continue;
 -                      }
 -                      queue_unref(queue_realtime);
 -              }
 -
 -              queues_data_provider_get_helper(search, data_root, queue);
 -              ao2_unlock(queue);
 -              queue_unref(queue);
 -      }
 -      ao2_iterator_destroy(&i);
 -
 -      return 0;
 -}
 -
 -static const struct ast_data_handler queues_data_provider = {
 -      .version = AST_DATA_HANDLER_VERSION,
 -      .get = queues_data_provider_get
 -};
 -
 -static const struct ast_data_entry queue_data_providers[] = {
 -      AST_DATA_ENTRY("asterisk/application/queue/list", &queues_data_provider),
 -};
 -
  static struct stasis_message_router *agent_router;
  static struct stasis_forward *topic_forwarder;