#include "asterisk.h"
#include <sys/time.h>
#include <sys/signal.h>
#include <netinet/in.h>
#include <ctype.h>
#include "asterisk/lock.h"
#include "asterisk/file.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/app.h"
#include "asterisk/linkedlists.h"
#include "asterisk/module.h"
#include "asterisk/translate.h"
#include "asterisk/say.h"
#include "asterisk/features.h"
#include "asterisk/musiconhold.h"
#include "asterisk/cli.h"
#include "asterisk/manager.h"
#include "asterisk/config.h"
#include "asterisk/monitor.h"
#include "asterisk/utils.h"
#include "asterisk/causes.h"
#include "asterisk/astdb.h"
#include "asterisk/devicestate.h"
#include "asterisk/stringfields.h"
#include "asterisk/event.h"
#include "asterisk/astobj2.h"
#include "asterisk/strings.h"
#include "asterisk/global_datastores.h"
#include "asterisk/taskprocessor.h"

Go to the source code of this file.
Data Structures | |
| struct | call_queue |
| struct | callattempt |
| We define a custom "local user" structure because we use it not only for keeping track of what is in use but also for keeping track of who we're dialing. More... | |
| struct | member |
| struct | penalty_rule |
| struct | queue_end_bridge |
| struct | queue_ent |
| struct | queue_transfer_ds |
| struct | rule_list |
| struct | rule_lists |
| struct | statechange |
| struct | strategy |
Defines | |
| #define | ANNOUNCEHOLDTIME_ALWAYS 1 |
| #define | ANNOUNCEHOLDTIME_ONCE 2 |
| #define | ANNOUNCEPOSITION_LIMIT 4 |
| #define | ANNOUNCEPOSITION_MORE_THAN 3 |
| #define | ANNOUNCEPOSITION_NO 2 |
| #define | ANNOUNCEPOSITION_YES 1 |
| #define | AST_MAX_WATCHERS 256 |
| #define | DEFAULT_MIN_ANNOUNCE_FREQUENCY 15 |
| #define | DEFAULT_RETRY 5 |
| #define | DEFAULT_TIMEOUT 15 |
| #define | MAX_PERIODIC_ANNOUNCEMENTS 10 |
| #define | MAX_QUEUE_BUCKETS 53 |
| #define | PM_MAX_LEN 8192 |
| #define | QUEUE_EVENT_VARIABLES 3 |
| #define | queue_t_ref(a, b) queue_ref(a) |
| #define | queue_t_unref(a, b) queue_unref(a) |
| #define | queues_t_link(c, q, tag) ao2_t_link(c,q,tag) |
| #define | queues_t_unlink(c, q, tag) ao2_t_unlink(c,q,tag) |
| #define | RECHECK 1 |
| #define | RES_EXISTS (-1) |
| #define | RES_NOSUCHQUEUE (-3) |
| #define | RES_NOT_DYNAMIC (-4) |
| #define | RES_OKAY 0 |
| #define | RES_OUTOFMEMORY (-2) |
Enumerations | |
| enum | { QUEUE_STRATEGY_RINGALL = 0, QUEUE_STRATEGY_LEASTRECENT, QUEUE_STRATEGY_FEWESTCALLS, QUEUE_STRATEGY_RANDOM, QUEUE_STRATEGY_RRMEMORY, QUEUE_STRATEGY_LINEAR, QUEUE_STRATEGY_WRANDOM } |
| enum | agent_complete_reason { CALLER, AGENT, TRANSFER } |
| enum | empty_conditions { QUEUE_EMPTY_PENALTY = (1 << 0), QUEUE_EMPTY_PAUSED = (1 << 1), QUEUE_EMPTY_INUSE = (1 << 2), QUEUE_EMPTY_RINGING = (1 << 3), QUEUE_EMPTY_UNAVAILABLE = (1 << 4), QUEUE_EMPTY_INVALID = (1 << 5), QUEUE_EMPTY_UNKNOWN = (1 << 6), QUEUE_EMPTY_WRAPUP = (1 << 7) } |
| enum | queue_reload_mask { QUEUE_RELOAD_PARAMETERS = (1 << 0), QUEUE_RELOAD_MEMBER = (1 << 1), QUEUE_RELOAD_RULES = (1 << 2), QUEUE_RESET_STATS = (1 << 3) } |
| enum | queue_result { QUEUE_UNKNOWN = 0, QUEUE_TIMEOUT = 1, QUEUE_JOINEMPTY = 2, QUEUE_LEAVEEMPTY = 3, QUEUE_JOINUNAVAIL = 4, QUEUE_LEAVEUNAVAIL = 5, QUEUE_FULL = 6, QUEUE_CONTINUE = 7 } |
| enum | queue_timeout_priority { TIMEOUT_PRIORITY_APP, TIMEOUT_PRIORITY_CONF } |
Functions | |
| static char * | __queues_show (struct mansession *s, int fd, int argc, char **argv) |
| Show queue(s) status and statistics. | |
| static void | __reg_module (void) |
| static void | __unreg_module (void) |
| static int | add_to_queue (const char *queuename, const char *interface, const char *membername, int penalty, int paused, int dump, const char *state_interface) |
| Add member to queue. | |
| static struct call_queue * | alloc_queue (const char *queuename) |
| static int | aqm_exec (struct ast_channel *chan, void *data) |
| AddQueueMember application. | |
| static int | attended_transfer_occurred (struct ast_channel *chan) |
| mechanism to tell if a queue caller was atxferred by a queue member. | |
| static int | calc_metric (struct call_queue *q, struct member *mem, int pos, struct queue_ent *qe, struct callattempt *tmp) |
| Calculate the metric of each member in the outgoing callattempts. | |
| static void | clear_queue (struct call_queue *q) |
| static int | clear_stats (const char *queuename) |
| Facilitates resetting statistics for a queue. | |
| static int | compare_weight (struct call_queue *rq, struct member *member) |
| static char * | complete_queue (const char *line, const char *word, int pos, int state) |
| static char * | complete_queue_add_member (const char *line, const char *word, int pos, int state) |
| static char * | complete_queue_pause_member (const char *line, const char *word, int pos, int state) |
| static char * | complete_queue_remove_member (const char *line, const char *word, int pos, int state) |
| static char * | complete_queue_rule_show (const char *line, const char *word, int pos, int state) |
| static char * | complete_queue_set_member_penalty (const char *line, const char *word, int pos, int state) |
| static char * | complete_queue_show (const char *line, const char *word, int pos, int state) |
| static int | compress_char (const char c) |
| static void | copy_rules (struct queue_ent *qe, const char *rulename) |
| Copy rule from global list into specified queue. | |
| static struct member * | create_queue_member (const char *interface, const char *membername, int penalty, int paused, const char *state_interface) |
| allocate space for new queue member and set fields based on parameters passed | |
| static void | destroy_queue (void *obj) |
| Free queue's member list then its string fields. | |
| static void | device_state_cb (const struct ast_event *event, void *unused) |
| static void | do_hang (struct callattempt *o) |
| common hangup actions | |
| static void | do_print (struct mansession *s, int fd, const char *str) |
| direct ouput to manager or cli with proper terminator | |
| static void | dump_queue_members (struct call_queue *pm_queue) |
| Dump all members in a specific queue to the database. | |
| static void | end_bridge_callback (void *data) |
| static void | end_bridge_callback_data_fixup (struct ast_bridge_config *bconfig, struct ast_channel *originator, struct ast_channel *terminator) |
| static struct callattempt * | find_best (struct callattempt *outgoing) |
| find the entry with the best metric, or NULL | |
| static struct call_queue * | find_queue_by_name_rt (const char *queuename, struct ast_variable *queue_vars, struct ast_config *member_config) |
| Reload a single queue via realtime. | |
| static void | free_members (struct call_queue *q, int all) |
| Iterate through queue's member list and delete them. | |
| static int | get_member_penalty (char *queuename, char *interface) |
| static int | get_member_status (struct call_queue *q, int max_penalty, int min_penalty, enum empty_conditions conditions) |
| Check if members are available. | |
| static char * | handle_queue_add_member (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| static char * | handle_queue_pause_member (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| static char * | handle_queue_reload (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| static char * | handle_queue_remove_member (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| static char * | handle_queue_reset (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| static char * | handle_queue_rule_show (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| static char * | handle_queue_set_member_penalty (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| static int | handle_statechange (void *datap) |
| set a member's status based on device state of that member's interface | |
| static void | hangupcalls (struct callattempt *outgoing, struct ast_channel *exception, int cancel_answered_elsewhere) |
| Hang up a list of outgoing calls. | |
| static void | init_queue (struct call_queue *q) |
| Initialize Queue default values. | |
| static void | insert_entry (struct call_queue *q, struct queue_ent *prev, struct queue_ent *new, int *pos) |
| Insert the 'new' entry after the 'prev' entry of queue 'q'. | |
| static int | insert_penaltychange (const char *list_name, const char *content, const int linenum) |
| Change queue penalty by adding rule. | |
| static const char * | int2strat (int strategy) |
| static struct member * | interface_exists (struct call_queue *q, const char *interface) |
| static int | is_our_turn (struct queue_ent *qe) |
| Check if we should start attempting to call queue members. | |
| static int | join_queue (char *queuename, struct queue_ent *qe, enum queue_result *reason) |
| static int | kill_dead_members (void *obj, void *arg, int flags) |
| static int | kill_dead_queues (void *obj, void *arg, int flags) |
| static void | leave_queue (struct queue_ent *qe) |
| Caller leaving queue. | |
| static int | load_module (void) |
| static struct call_queue * | load_realtime_queue (const char *queuename) |
| static int | manager_add_queue_member (struct mansession *s, const struct message *m) |
| static int | manager_pause_queue_member (struct mansession *s, const struct message *m) |
| static int | manager_queue_log_custom (struct mansession *s, const struct message *m) |
| static int | manager_queue_member_penalty (struct mansession *s, const struct message *m) |
| static int | manager_queue_reload (struct mansession *s, const struct message *m) |
| static int | manager_queue_reset (struct mansession *s, const struct message *m) |
| static int | manager_queue_rule_show (struct mansession *s, const struct message *m) |
| static int | manager_queues_show (struct mansession *s, const struct message *m) |
| static int | manager_queues_status (struct mansession *s, const struct message *m) |
| Queue status info via AMI. | |
| static int | manager_queues_summary (struct mansession *s, const struct message *m) |
| Summary of queue info via the AMI. | |
| static int | manager_remove_queue_member (struct mansession *s, const struct message *m) |
| static int | mark_dead_and_unfound (void *obj, void *arg, int flags) |
| static int | mark_member_dead (void *obj, void *arg, int flags) |
| static int | member_cmp_fn (void *obj1, void *obj2, int flags) |
| static int | member_hash_fn (const void *obj, const int flags) |
| static int | num_available_members (struct call_queue *q) |
| Get the number of members available to accept a call. | |
| static void | parse_empty_options (const char *value, enum empty_conditions *empty, int joinempty) |
| static int | play_file (struct ast_channel *chan, const char *filename) |
| static int | pqm_exec (struct ast_channel *chan, void *data) |
| PauseQueueMember application. | |
| static int | ql_exec (struct ast_channel *chan, void *data) |
| QueueLog application. | |
| static int | queue_cmp_cb (void *obj, void *arg, int flags) |
| static int | queue_exec (struct ast_channel *chan, void *data) |
| The starting point for all queue calls. | |
| static int | queue_function_memberpenalty_read (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) |
| Dialplan function QUEUE_MEMBER_PENALTY() Gets the members penalty. | |
| static int | queue_function_memberpenalty_write (struct ast_channel *chan, const char *cmd, char *data, const char *value) |
| Dialplan function QUEUE_MEMBER_PENALTY() Sets the members penalty. | |
| static int | queue_function_qac (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) |
| Get number either busy / free or total members of a specific queue. | |
| static int | queue_function_qac_dep (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) |
| Get the total number of members in a specific queue (Deprecated). | |
| static int | queue_function_queuememberlist (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) |
| Dialplan function QUEUE_MEMBER_LIST() Get list of members in a specific queue. | |
| static int | queue_function_queuewaitingcount (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) |
| Dialplan function QUEUE_WAITING_COUNT() Get number callers waiting in a specific queue. | |
| static int | queue_function_var (struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) |
| create interface var with all queue details. | |
| static int | queue_hash_cb (const void *obj, const int flags) |
| static struct call_queue * | queue_ref (struct call_queue *q) |
| static void | queue_set_global_params (struct ast_config *cfg) |
| static void | queue_set_param (struct call_queue *q, const char *param, const char *val, int linenum, int failunknown) |
| Configure a queue parameter. | |
| static char * | queue_show (struct ast_cli_entry *e, int cmd, struct ast_cli_args *a) |
| static void | queue_transfer_destroy (void *data) |
| static void | queue_transfer_fixup (void *data, struct ast_channel *old_chan, struct ast_channel *new_chan) |
| Log an attended transfer when a queue caller channel is masqueraded. | |
| static struct call_queue * | queue_unref (struct call_queue *q) |
| static void | recalc_holdtime (struct queue_ent *qe, int newholdtime) |
| static void | record_abandoned (struct queue_ent *qe) |
| Record that a caller gave up on waiting in queue. | |
| static int | reload (void) |
| static int | reload_handler (int reload, struct ast_flags *mask, const char *queuename) |
| The command center for all reload operations. | |
| static void | reload_queue_members (void) |
| Reload dynamic queue members persisted into the astdb. | |
| static int | reload_queue_rules (int reload) |
| Reload the rules defined in queuerules.conf. | |
| static int | reload_queues (int reload, struct ast_flags *mask, const char *queuename) |
| reload the queues.conf file | |
| static void | reload_single_member (const char *memberdata, struct call_queue *q) |
| reload information pertaining to a single member | |
| static void | reload_single_queue (struct ast_config *cfg, struct ast_flags *mask, const char *queuename) |
| Reload information pertaining to a particular queue. | |
| static int | remove_from_queue (const char *queuename, const char *interface) |
| Remove member from queue. | |
| static int | ring_entry (struct queue_ent *qe, struct callattempt *tmp, int *busies) |
| Part 2 of ring_one. | |
| static int | ring_one (struct queue_ent *qe, struct callattempt *outgoing, int *busies) |
| Place a call to a queue member. | |
| static void | rna (int rnatime, struct queue_ent *qe, char *interface, char *membername, int pause) |
| RNA == Ring No Answer. Common code that is executed when we try a queue member and they don't answer. | |
| static int | rqm_exec (struct ast_channel *chan, void *data) |
| RemoveQueueMember application. | |
| static void | rt_handle_member_record (struct call_queue *q, char *interface, const char *rt_uniqueid, const char *membername, const char *penalty_str, const char *paused_str, const char *state_interface) |
| Find rt member record to update otherwise create one. | |
| static int | say_periodic_announcement (struct queue_ent *qe, int ringing) |
| Playback announcement to queued members if peroid has elapsed. | |
| static int | say_position (struct queue_ent *qe, int ringing) |
| static void | send_agent_complete (const struct queue_ent *qe, const char *queuename, const struct ast_channel *peer, const struct member *member, time_t callstart, char *vars, size_t vars_len, enum agent_complete_reason rsn) |
| Send out AMI message with member call completion status information. | |
| static int | set_member_paused (const char *queuename, const char *interface, const char *reason, int paused) |
| static int | set_member_penalty (char *queuename, char *interface, int penalty) |
| static void | set_queue_result (struct ast_channel *chan, enum queue_result res) |
| sets the QUEUESTATUS channel variable | |
| static void | set_queue_variables (struct call_queue *q, struct ast_channel *chan) |
| Set variables of queue. | |
| static struct ast_datastore * | setup_transfer_datastore (struct queue_ent *qe, struct member *member, time_t starttime, int callcompletedinsl) |
| create a datastore for storing relevant info to log attended transfers in the queue_log | |
| static int | store_next_lin (struct queue_ent *qe, struct callattempt *outgoing) |
| Search for best metric and add to Linear queue. | |
| static int | store_next_rr (struct queue_ent *qe, struct callattempt *outgoing) |
| Search for best metric and add to Round Robbin queue. | |
| static int | strat2int (const char *strategy) |
| static int | try_calling (struct queue_ent *qe, const char *options, char *announceoverride, const char *url, int *tries, int *noption, const char *agi, const char *macro, const char *gosub, int ringing) |
| A large function which calls members, updates statistics, and bridges the caller and a member. | |
| static int | unload_module (void) |
| static void | update_qe_rule (struct queue_ent *qe) |
| update rules for queues | |
| static int | update_queue (struct call_queue *q, struct member *member, int callcompletedinsl, int newtalktime) |
| update the queue status | |
| static int | update_realtime_member_field (struct member *mem, const char *queue_name, const char *field, const char *value) |
| static void | update_realtime_members (struct call_queue *q) |
| static int | update_status (struct call_queue *q, struct member *m, const int status) |
| set a member's status based on device state of that member's state_interface. | |
| static int | upqm_exec (struct ast_channel *chan, void *data) |
| UnPauseQueueMember application. | |
| static int | valid_exit (struct queue_ent *qe, char digit) |
| Check for valid exit from queue via goto. | |
| static char * | vars2manager (struct ast_channel *chan, char *vars, size_t len) |
| convert "\n" to "\nVariable: " ready for manager to use | |
| static int | wait_a_bit (struct queue_ent *qe) |
| static struct callattempt * | wait_for_answer (struct queue_ent *qe, struct callattempt *outgoing, int *to, char *digit, int prebusies, int caller_disconnect, int forwardsallowed) |
| Wait for a member to answer the call. | |
| static int | wait_our_turn (struct queue_ent *qe, int ringing, enum queue_result *reason) |
| The waiting areas for callers who are not actively calling members. | |
Variables | |
| static struct ast_module_info | __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "True Call Queueing" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .reload = reload, } |
| static char * | app = "Queue" |
| static char * | app_aqm = "AddQueueMember" |
| static char * | app_pqm = "PauseQueueMember" |
| static char * | app_ql = "QueueLog" |
| static char * | app_rqm = "RemoveQueueMember" |
| static char * | app_upqm = "UnpauseQueueMember" |
| static struct ast_module_info * | ast_module_info = &__mod_info |
| static int | autofill_default = 0 |
| queues.conf [general] option | |
| static struct ast_cli_entry | cli_queue [] |
| static struct ast_event_sub * | device_state_sub |
| Subscription to device state change events. | |
| static struct ast_taskprocessor * | devicestate_tps |
| static int | montype_default = 0 |
| queues.conf [general] option | |
| static const char * | pm_family = "Queue/PersistentMembers" |
| Persistent Members astdb family. | |
| static const char | qpm_cmd_usage [] |
| static const char | qsmp_cmd_usage [] |
| static int | queue_persistent_members = 0 |
| queues.conf [general] option | |
| struct { | |
| enum queue_result id | |
| char * text | |
| } | queue_results [] |
| static struct ast_datastore_info | queue_transfer_info |
| a datastore used to help correctly log attended transfers of queue callers | |
| static struct ast_custom_function | queuemembercount_dep |
| static struct ast_custom_function | queuemembercount_function |
| static struct ast_custom_function | queuememberlist_function |
| static struct ast_custom_function | queuememberpenalty_function |
| static struct ao2_container * | queues |
| static struct ast_custom_function | queuevar_function |
| static struct ast_custom_function | queuewaitingcount_function |
| static const char | qum_cmd_usage [] |
| static int | shared_lastcall = 0 |
| queues.conf [general] option | |
| static struct strategy | strategies [] |
| static int | update_cdr = 0 |
| queues.conf [general] option | |
| static int | use_weight = 0 |
| queues.conf per-queue weight option | |
These features added by David C. Troy <dave@toad.net>:
Added servicelevel statistic by Michiel Betel <michiel@betel.nl> Added Priority jumping code for adding and removing queue members by Jonathan Stanton <asterisk@doilooklikeicare.com>
Fixed to work with CVS as of 2004-02-25 and released as 1.07a by Matthew Enger <m.enger@xi.com.au>
Definition in file app_queue.c.
| #define ANNOUNCEHOLDTIME_ALWAYS 1 |
| #define ANNOUNCEHOLDTIME_ONCE 2 |
| #define ANNOUNCEPOSITION_LIMIT 4 |
We not announce position more than <limit>
Definition at line 708 of file app_queue.c.
Referenced by queue_set_param(), and say_position().
| #define ANNOUNCEPOSITION_MORE_THAN 3 |
We say "Currently there are more than <limit>"
Definition at line 707 of file app_queue.c.
Referenced by queue_set_param(), and say_position().
| #define ANNOUNCEPOSITION_NO 2 |
We don't announce position
Definition at line 706 of file app_queue.c.
Referenced by queue_set_param().
| #define ANNOUNCEPOSITION_YES 1 |
We announce position
Definition at line 705 of file app_queue.c.
Referenced by init_queue(), queue_set_param(), and say_position().
| #define AST_MAX_WATCHERS 256 |
Definition at line 2845 of file app_queue.c.
| #define DEFAULT_MIN_ANNOUNCE_FREQUENCY 15 |
The minimum number of seconds between position announcements \ The default value of 15 provides backwards compatibility
Definition at line 530 of file app_queue.c.
Referenced by init_queue().
| #define DEFAULT_RETRY 5 |
| #define DEFAULT_TIMEOUT 15 |
| #define MAX_PERIODIC_ANNOUNCEMENTS 10 |
The maximum periodic announcements we can have
Definition at line 529 of file app_queue.c.
Referenced by destroy_queue(), init_queue(), and queue_set_param().
| #define MAX_QUEUE_BUCKETS 53 |
| #define PM_MAX_LEN 8192 |
Definition at line 555 of file app_queue.c.
Referenced by dump_queue_members(), and reload_queue_members().
| #define QUEUE_EVENT_VARIABLES 3 |
Definition at line 694 of file app_queue.c.
Referenced by queue_set_param(), ring_entry(), rna(), send_agent_complete(), and try_calling().
| #define queue_t_ref | ( | a, | |||
| b | ) | queue_ref(a) |
| #define queue_t_unref | ( | a, | |||
| b | ) | queue_unref(a) |
Definition at line 883 of file app_queue.c.
Referenced by __queues_show(), clear_stats(), compare_weight(), complete_queue(), complete_queue_remove_member(), end_bridge_callback(), find_queue_by_name_rt(), get_member_penalty(), handle_statechange(), leave_queue(), manager_queues_status(), manager_queues_summary(), queue_function_qac(), queue_function_qac_dep(), queue_function_queuememberlist(), queue_function_queuewaitingcount(), queue_function_var(), reload_queue_members(), reload_single_queue(), remove_from_queue(), set_member_paused(), set_member_penalty(), unload_module(), and update_queue().
| #define queues_t_link | ( | c, | |||
| q, | |||||
| tag | ) | ao2_t_link(c,q,tag) |
Definition at line 884 of file app_queue.c.
Referenced by find_queue_by_name_rt(), and reload_single_queue().
| #define queues_t_unlink | ( | c, | |||
| q, | |||||
| tag | ) | ao2_t_unlink(c,q,tag) |
Definition at line 885 of file app_queue.c.
Referenced by find_queue_by_name_rt(), leave_queue(), and unload_module().
| #define RECHECK 1 |
Recheck every second to see we we're at the top yet
Definition at line 528 of file app_queue.c.
Referenced by wait_our_turn().
| #define RES_EXISTS (-1) |
Entry already exists
Definition at line 535 of file app_queue.c.
Referenced by add_to_queue(), aqm_exec(), handle_queue_add_member(), handle_queue_remove_member(), manager_add_queue_member(), manager_remove_queue_member(), remove_from_queue(), and rqm_exec().
| #define RES_NOSUCHQUEUE (-3) |
No such queue
Definition at line 537 of file app_queue.c.
Referenced by add_to_queue(), aqm_exec(), handle_queue_add_member(), handle_queue_remove_member(), manager_add_queue_member(), manager_remove_queue_member(), remove_from_queue(), and rqm_exec().
| #define RES_NOT_DYNAMIC (-4) |
Member is not dynamic
Definition at line 538 of file app_queue.c.
Referenced by handle_queue_add_member(), handle_queue_remove_member(), manager_remove_queue_member(), remove_from_queue(), and rqm_exec().
| #define RES_OKAY 0 |
Action completed
Definition at line 534 of file app_queue.c.
Referenced by add_to_queue(), aqm_exec(), handle_queue_add_member(), handle_queue_remove_member(), manager_add_queue_member(), manager_remove_queue_member(), remove_from_queue(), and rqm_exec().
| #define RES_OUTOFMEMORY (-2) |
Out of memory
Definition at line 536 of file app_queue.c.
Referenced by add_to_queue(), aqm_exec(), handle_queue_add_member(), handle_queue_remove_member(), manager_add_queue_member(), manager_remove_queue_member(), and reload_queue_members().
| anonymous enum |
| QUEUE_STRATEGY_RINGALL | |
| QUEUE_STRATEGY_LEASTRECENT | |
| QUEUE_STRATEGY_FEWESTCALLS | |
| QUEUE_STRATEGY_RANDOM | |
| QUEUE_STRATEGY_RRMEMORY | |
| QUEUE_STRATEGY_LINEAR | |
| QUEUE_STRATEGY_WRANDOM |
Definition at line 493 of file app_queue.c.
00493 { 00494 QUEUE_STRATEGY_RINGALL = 0, 00495 QUEUE_STRATEGY_LEASTRECENT, 00496 QUEUE_STRATEGY_FEWESTCALLS, 00497 QUEUE_STRATEGY_RANDOM, 00498 QUEUE_STRATEGY_RRMEMORY, 00499 QUEUE_STRATEGY_LINEAR, 00500 QUEUE_STRATEGY_WRANDOM 00501 };
| enum empty_conditions |
| QUEUE_EMPTY_PENALTY | |
| QUEUE_EMPTY_PAUSED | |
| QUEUE_EMPTY_INUSE | |
| QUEUE_EMPTY_RINGING | |
| QUEUE_EMPTY_UNAVAILABLE | |
| QUEUE_EMPTY_INVALID | |
| QUEUE_EMPTY_UNKNOWN | |
| QUEUE_EMPTY_WRAPUP |
Definition at line 680 of file app_queue.c.
00680 { 00681 QUEUE_EMPTY_PENALTY = (1 << 0), 00682 QUEUE_EMPTY_PAUSED = (1 << 1), 00683 QUEUE_EMPTY_INUSE = (1 << 2), 00684 QUEUE_EMPTY_RINGING = (1 << 3), 00685 QUEUE_EMPTY_UNAVAILABLE = (1 << 4), 00686 QUEUE_EMPTY_INVALID = (1 << 5), 00687 QUEUE_EMPTY_UNKNOWN = (1 << 6), 00688 QUEUE_EMPTY_WRAPUP = (1 << 7), 00689 };
| enum queue_reload_mask |
Definition at line 503 of file app_queue.c.
00503 { 00504 QUEUE_RELOAD_PARAMETERS = (1 << 0), 00505 QUEUE_RELOAD_MEMBER = (1 << 1), 00506 QUEUE_RELOAD_RULES = (1 << 2), 00507 QUEUE_RESET_STATS = (1 << 3), 00508 };
| enum queue_result |
| QUEUE_UNKNOWN | |
| QUEUE_TIMEOUT | |
| QUEUE_JOINEMPTY | |
| QUEUE_LEAVEEMPTY | |
| QUEUE_JOINUNAVAIL | |
| QUEUE_LEAVEUNAVAIL | |
| QUEUE_FULL | |
| QUEUE_CONTINUE |
Definition at line 578 of file app_queue.c.
00578 { 00579 QUEUE_UNKNOWN = 0, 00580 QUEUE_TIMEOUT = 1, 00581 QUEUE_JOINEMPTY = 2, 00582 QUEUE_LEAVEEMPTY = 3, 00583 QUEUE_JOINUNAVAIL = 4, 00584 QUEUE_LEAVEUNAVAIL = 5, 00585 QUEUE_FULL = 6, 00586 QUEUE_CONTINUE = 7, 00587 };
Definition at line 603 of file app_queue.c.
00603 { 00604 TIMEOUT_PRIORITY_APP, 00605 TIMEOUT_PRIORITY_CONF, 00606 };
| static char* __queues_show | ( | struct mansession * | s, | |
| int | fd, | |||
| int | argc, | |||
| char ** | argv | |||
| ) | [static] |
Show queue(s) status and statistics.
List the queues strategy, calls processed, members logged in, other queue statistics such as avg hold time.
Definition at line 6084 of file app_queue.c.
References ao2_container_count(), ao2_iterator_destroy(), AO2_ITERATOR_DONTLOCK, ao2_iterator_init(), ao2_iterator_next, ao2_lock(), ao2_ref, ao2_t_iterator_next, ao2_unlock(), ast_category_browse(), ast_check_realtime(), ast_config_destroy(), ast_devstate2str(), ast_load_realtime_multientry(), ast_str_alloca, ast_str_append(), ast_str_buffer(), ast_str_set(), ast_strlen_zero(), member::calls, call_queue::callsabandoned, call_queue::callscompleted, call_queue::callscompletedinsl, queue_ent::chan, CLI_SHOWUSAGE, CLI_SUCCESS, call_queue::count, do_print(), member::dynamic, call_queue::head, call_queue::holdtime, int2strat(), member::interface, member::lastcall, load_realtime_queue(), call_queue::maxlen, member::membername, call_queue::members, ast_channel::name, call_queue::name, queue_ent::next, member::paused, member::penalty, queue_ent::pos, queue_ent::prio, queue_t_unref, queues, member::realtime, call_queue::realtime, SENTINEL, call_queue::servicelevel, queue_ent::start, member::status, call_queue::strategy, call_queue::talktime, and call_queue::weight.
Referenced by manager_queues_show(), and queue_show().
06085 { 06086 struct call_queue *q; 06087 struct ast_str *out = ast_str_alloca(240); 06088 int found = 0; 06089 time_t now = time(NULL); 06090 struct ao2_iterator queue_iter; 06091 struct ao2_iterator mem_iter; 06092 06093 if (argc != 2 && argc != 3) 06094 return CLI_SHOWUSAGE; 06095 06096 if (argc == 3) { /* specific queue */ 06097 if ((q = load_realtime_queue(argv[2]))) { 06098 queue_t_unref(q, "Done with temporary pointer"); 06099 } 06100 } else if (ast_check_realtime("queues")) { 06101 /* This block is to find any queues which are defined in realtime but 06102 * which have not yet been added to the in-core container 06103 */ 06104 struct ast_config *cfg = ast_load_realtime_multientry("queues", "name LIKE", "%", SENTINEL); 06105 char *queuename; 06106 if (cfg) { 06107 for (queuename = ast_category_browse(cfg, NULL); !ast_strlen_zero(queuename); queuename = ast_category_browse(cfg, queuename)) { 06108 if ((q = load_realtime_queue(queuename))) { 06109 queue_t_unref(q, "Done with temporary pointer"); 06110 } 06111 } 06112 ast_config_destroy(cfg); 06113 } 06114 } 06115 06116 queue_iter = ao2_iterator_init(queues, AO2_ITERATOR_DONTLOCK); 06117 ao2_lock(queues); 06118 while ((q = ao2_t_iterator_next(&queue_iter, "Iterate through queues"))) { 06119 float sl; 06120 struct call_queue *realtime_queue = NULL; 06121 06122 ao2_lock(q); 06123 /* This check is to make sure we don't print information for realtime 06124 * queues which have been deleted from realtime but which have not yet 06125 * been deleted from the in-core container 06126 */ 06127 if (q->realtime && !(realtime_queue = load_realtime_queue(q->name))) { 06128 ao2_unlock(q); 06129 queue_t_unref(q, "Done with iterator"); 06130 continue; 06131 } else if (q->realtime) { 06132 queue_t_unref(realtime_queue, "Queue is already in memory"); 06133 } 06134 if (argc == 3 && strcasecmp(q->name, argv[2])) { 06135 ao2_unlock(q); 06136 queue_t_unref(q, "Done with iterator"); 06137 continue; 06138 } 06139 found = 1; 06140 06141 ast_str_set(&out, 0, "%s has %d calls (max ", q->name, q->count); 06142 if (q->maxlen) 06143 ast_str_append(&out, 0, "%d", q->maxlen); 06144 else 06145 ast_str_append(&out, 0, "unlimited"); 06146 sl = 0; 06147 if (q->callscompleted > 0) 06148 sl = 100 * ((float) q->callscompletedinsl / (float) q->callscompleted); 06149 ast_str_append(&out, 0, ") in '%s' strategy (%ds holdtime, %ds talktime), W:%d, C:%d, A:%d, SL:%2.1f%% within %ds", 06150 int2strat(q->strategy), q->holdtime, q->talktime, q->weight, 06151 q->callscompleted, q->callsabandoned,sl,q->servicelevel); 06152 do_print(s, fd, ast_str_buffer(out)); 06153 if (!ao2_container_count(q->members)) 06154 do_print(s, fd, " No Members"); 06155 else { 06156 struct member *mem; 06157 06158 do_print(s, fd, " Members: "); 06159 mem_iter = ao2_iterator_init(q->members, 0); 06160 while ((mem = ao2_iterator_next(&mem_iter))) { 06161 ast_str_set(&out, 0, " %s", mem->membername); 06162 if (strcasecmp(mem->membername, mem->interface)) { 06163 ast_str_append(&out, 0, " (%s)", mem->interface); 06164 } 06165 if (mem->penalty) 06166 ast_str_append(&out, 0, " with penalty %d", mem->penalty); 06167 ast_str_append(&out, 0, "%s%s%s (%s)", 06168 mem->dynamic ? " (dynamic)" : "", 06169 mem->realtime ? " (realtime)" : "", 06170 mem->paused ? " (paused)" : "", 06171 ast_devstate2str(mem->status)); 06172 if (mem->calls) 06173 ast_str_append(&out, 0, " has taken %d calls (last was %ld secs ago)", 06174 mem->calls, (long) (time(NULL) - mem->lastcall)); 06175 else 06176 ast_str_append(&out, 0, " has taken no calls yet"); 06177 do_print(s, fd, ast_str_buffer(out)); 06178 ao2_ref(mem, -1); 06179 } 06180 ao2_iterator_destroy(&mem_iter); 06181 } 06182 if (!q->head) 06183 do_print(s, fd, " No Callers"); 06184 else { 06185 struct queue_ent *qe; 06186 int pos = 1; 06187 06188 do_print(s, fd, " Callers: "); 06189 for (qe = q->head; qe; qe = qe->next) { 06190 ast_str_set(&out, 0, " %d. %s (wait: %ld:%2.2ld, prio: %d)", 06191 pos++, qe->chan->name, (long) (now - qe->start) / 60, 06192 (long) (now - qe->start) % 60, qe->prio); 06193 do_print(s, fd, ast_str_buffer(out)); 06194 } 06195 } 06196 do_print(s, fd, ""); /* blank line between entries */ 06197 ao2_unlock(q); 06198 queue_t_unref(q, "Done with iterator"); /* Unref the iterator's reference */ 06199 } 06200 ao2_iterator_destroy(&queue_iter); 06201 ao2_unlock(queues); 06202 if (!found) { 06203 if (argc == 3) 06204 ast_str_set(&out, 0, "No such queue: %s.", argv[2]); 06205 else 06206 ast_str_set(&out, 0, "No queues."); 06207 do_print(s, fd, ast_str_buffer(out)); 06208 } 06209 return CLI_SUCCESS; 06210 }
| static void __reg_module | ( | void | ) | [static] |
Definition at line 7293 of file app_queue.c.
| static void __unreg_module | ( | void | ) | [static] |
Definition at line 7293 of file app_queue.c.
| static int add_to_queue | ( | const char * | queuename, | |
| const char * | interface, | |||
| const char * | membername, | |||
| int | penalty, | |||
| int | paused, | |||
| int | dump, | |||
| const char * | state_interface | |||
| ) | [static] |
Add member to queue.
| RES_NOT_DYNAMIC | when they aren't a RT member | |
| RES_NOSUCHQUEUE | queue does not exist | |
| RES_OKAY | added member from queue | |
| RES_EXISTS | queue exists but no members | |
| RES_OUT_OF_MEMORY | queue exists but not enough memory to create member |
Definition at line 4468 of file app_queue.c.
References ao2_link, ao2_lock(), ao2_ref, ao2_unlock(), member::calls, create_queue_member(), dump_queue_members(), member::dynamic, EVENT_FLAG_AGENT, member::interface, interface_exists(), member::lastcall, load_realtime_queue(), manager_event, call_queue::membercount, member::membername, call_queue::members, call_queue::name, member::paused, member::penalty, queues, RES_EXISTS, RES_NOSUCHQUEUE, RES_OKAY, RES_OUTOFMEMORY, and member::status.
Referenced by aqm_exec(), handle_queue_add_member(), manager_add_queue_member(), and reload_queue_members().
04469 { 04470 struct call_queue *q; 04471 struct member *new_member, *old_member; 04472 int res = RES_NOSUCHQUEUE; 04473 04474 /*! \note Ensure the appropriate realtime queue is loaded. Note that this 04475 * short-circuits if the queue is already in memory. */ 04476 if (!(q = load_realtime_queue(queuename))) 04477 return res; 04478 04479 ao2_lock(queues); 04480 04481 ao2_lock(q); 04482 if ((old_member = interface_exists(q, interface)) == NULL) { 04483 if ((new_member = create_queue_member(interface, membername, penalty, paused, state_interface))) { 04484 new_member->dynamic = 1; 04485 ao2_link(q->members, new_member); 04486 q->membercount++; 04487 manager_event(EVENT_FLAG_AGENT, "QueueMemberAdded", 04488 "Queue: %s\r\n" 04489 "Location: %s\r\n" 04490 "MemberName: %s\r\n" 04491 "Membership: %s\r\n" 04492 "Penalty: %d\r\n" 04493 "CallsTaken: %d\r\n" 04494 "LastCall: %d\r\n" 04495 "Status: %d\r\n" 04496 "Paused: %d\r\n", 04497 q->name, new_member->interface, new_member->membername, 04498 "dynamic", 04499 new_member->penalty, new_member->calls, (int) new_member->lastcall, 04500 new_member->status, new_member->paused); 04501 04502 ao2_ref(new_member, -1); 04503 new_member = NULL; 04504 04505 if (dump) 04506 dump_queue_members(q); 04507 04508 res = RES_OKAY; 04509 } else { 04510 res = RES_OUTOFMEMORY; 04511 } 04512 } else { 04513 ao2_ref(old_member, -1); 04514 res = RES_EXISTS; 04515 } 04516 ao2_unlock(q); 04517 ao2_unlock(queues); 04518 04519 return res; 04520 }
| static struct call_queue* alloc_queue | ( | const char * | queuename | ) | [static, read] |
Definition at line 1684 of file app_queue.c.
References ao2_t_alloc, ast_copy_string(), destroy_queue(), and call_queue::name.
Referenced by find_queue_by_name_rt(), and reload_single_queue().
01685 { 01686 struct call_queue *q; 01687 01688 if ((q = ao2_t_alloc(sizeof(*q), destroy_queue, "Allocate queue"))) { 01689 ast_copy_string(q->name, queuename, sizeof(q->name)); 01690 } 01691 return q; 01692 }
| static int aqm_exec | ( | struct ast_channel * | chan, | |
| void * | data | |||
| ) | [static] |
AddQueueMember application.
Definition at line 4904 of file app_queue.c.
References add_to_queue(), AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_log(), ast_queue_log(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), LOG_ERROR, LOG_NOTICE, LOG_WARNING, ast_channel::name, parse(), pbx_builtin_setvar_helper(), RES_EXISTS, RES_NOSUCHQUEUE, RES_OKAY, RES_OUTOFMEMORY, and ast_channel::uniqueid.
Referenced by load_module().
04905 { 04906 int res=-1; 04907 char *parse, *temppos = NULL; 04908 AST_DECLARE_APP_ARGS(args, 04909 AST_APP_ARG(queuename); 04910 AST_APP_ARG(interface); 04911 AST_APP_ARG(penalty); 04912 AST_APP_ARG(options); 04913 AST_APP_ARG(membername); 04914 AST_APP_ARG(state_interface); 04915 ); 04916 int penalty = 0; 04917 04918 if (ast_strlen_zero(data)) { 04919 ast_log(LOG_WARNING, "AddQueueMember requires an argument (queuename[,interface[,penalty[,options[,membername[,stateinterface]]]]])\n"); 04920 return -1; 04921 } 04922 04923 parse = ast_strdupa(data); 04924 04925 AST_STANDARD_APP_ARGS(args, parse); 04926 04927 if (ast_strlen_zero(args.interface)) { 04928 args.interface = ast_strdupa(chan->name); 04929 temppos = strrchr(args.interface, '-'); 04930 if (temppos) 04931 *temppos = '\0'; 04932 } 04933 04934 if (!ast_strlen_zero(args.penalty)) { 04935 if ((sscanf(args.penalty, "%30d", &penalty) != 1) || penalty < 0) { 04936 ast_log(LOG_WARNING, "Penalty '%s' is invalid, must be an integer >= 0\n", args.penalty); 04937 penalty = 0; 04938 } 04939 } 04940 04941 switch (add_to_queue(args.queuename, args.interface, args.membername, penalty, 0, queue_persistent_members, args.state_interface)) { 04942 case RES_OKAY: 04943 ast_queue_log(args.queuename, chan->uniqueid, args.interface, "ADDMEMBER", "%s", ""); 04944 ast_log(LOG_NOTICE, "Added interface '%s' to queue '%s'\n", args.interface, args.queuename); 04945 pbx_builtin_setvar_helper(chan, "AQMSTATUS", "ADDED"); 04946 res = 0; 04947 break; 04948 case RES_EXISTS: 04949 ast_log(LOG_WARNING, "Unable to add interface '%s' to queue '%s': Already there\n", args.interface, args.queuename); 04950 pbx_builtin_setvar_helper(chan, "AQMSTATUS", "MEMBERALREADY"); 04951 res = 0; 04952 break; 04953 case RES_NOSUCHQUEUE: 04954 ast_log(LOG_WARNING, "Unable to add interface to queue '%s': No such queue\n", args.queuename); 04955 pbx_builtin_setvar_helper(chan, "AQMSTATUS", "NOSUCHQUEUE"); 04956 res = 0; 04957 break; 04958 case RES_OUTOFMEMORY: 04959 ast_log(LOG_ERROR, "Out of memory adding member %s to queue %s\n", args.interface, args.queuename); 04960 break; 04961 } 04962 04963 return res; 04964 }
| static int attended_transfer_occurred | ( | struct ast_channel * | chan | ) | [static] |
mechanism to tell if a queue caller was atxferred by a queue member.
When a caller is atxferred, then the queue_transfer_info datastore is removed from the channel. If it's still there after the bridge is broken, then the caller was not atxferred.
Definition at line 3491 of file app_queue.c.
References ast_channel_datastore_find(), and queue_transfer_info.
Referenced by try_calling().
03492 { 03493 return ast_channel_datastore_find(chan, &queue_transfer_info, NULL) ? 0 : 1; 03494 }
| static int calc_metric | ( | struct call_queue * | q, | |
| struct member * | mem, | |||
| int | pos, | |||
| struct queue_ent * | qe, | |||
| struct callattempt * | tmp | |||
| ) | [static] |
Calculate the metric of each member in the outgoing callattempts.
A numeric metric is given to each member depending on the ring strategy used by the queue. Members with lower metrics will be called before members with higher metrics
| -1 | if penalties are exceeded | |
| 0 | otherwise |
Definition at line 3330 of file app_queue.c.
References ast_log(), ast_random(), member::calls, member::lastcall, queue_ent::linpos, queue_ent::linwrapped, LOG_WARNING, queue_ent::max_penalty, callattempt::metric, queue_ent::min_penalty, member::penalty, QUEUE_STRATEGY_FEWESTCALLS, QUEUE_STRATEGY_LEASTRECENT, QUEUE_STRATEGY_LINEAR, QUEUE_STRATEGY_RANDOM, QUEUE_STRATEGY_RINGALL, QUEUE_STRATEGY_RRMEMORY, QUEUE_STRATEGY_WRANDOM, call_queue::rrpos, call_queue::strategy, and call_queue::wrapped.
Referenced by try_calling().
03331 { 03332 if ((qe->max_penalty && (mem->penalty > qe->max_penalty)) || (qe->min_penalty && (mem->penalty < qe->min_penalty))) 03333 return -1; 03334 03335 switch (q->strategy) { 03336 case QUEUE_STRATEGY_RINGALL: 03337 /* Everyone equal, except for penalty */ 03338 tmp->metric = mem->penalty * 1000000; 03339 break; 03340 case QUEUE_STRATEGY_LINEAR: 03341 if (pos < qe->linpos) { 03342 tmp->metric = 1000 + pos; 03343 } else { 03344 if (pos > qe->linpos) 03345 /* Indicate there is another priority */ 03346 qe->linwrapped = 1; 03347 tmp->metric = pos; 03348 } 03349 tmp->metric += mem->penalty * 1000000; 03350 break; 03351 case QUEUE_STRATEGY_RRMEMORY: 03352 if (pos < q->rrpos) { 03353 tmp->metric = 1000 + pos; 03354 } else { 03355 if (pos > q->rrpos) 03356 /* Indicate there is another priority */ 03357 q->wrapped = 1; 03358 tmp->metric = pos; 03359 } 03360 tmp->metric += mem->penalty * 1000000; 03361 break; 03362 case QUEUE_STRATEGY_RANDOM: 03363 tmp->metric = ast_random() % 1000; 03364 tmp->metric += mem->penalty * 1000000; 03365 break; 03366 case QUEUE_STRATEGY_WRANDOM: 03367 tmp->metric = ast_random() % ((1 + mem->penalty) * 1000); 03368 break; 03369 case QUEUE_STRATEGY_FEWESTCALLS: 03370 tmp->metric = mem->calls; 03371 tmp->metric += mem->penalty * 1000000; 03372 break; 03373 case QUEUE_STRATEGY_LEASTRECENT: 03374 if (!mem->lastcall) 03375 tmp->metric = 0; 03376 else 03377 tmp->metric = 1000000 - (time(NULL) - mem->lastcall); 03378 tmp->metric += mem->penalty * 1000000; 03379 break; 03380 default: 03381 ast_log(LOG_WARNING, "Can't calculate metric for unknown strategy %d\n", q->strategy); 03382 break; 03383 } 03384 return 0; 03385 }
| static void clear_queue | ( | struct call_queue * | q | ) | [static] |
Definition at line 1256 of file app_queue.c.
References ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_ref, member::calls, call_queue::callsabandoned, call_queue::callscompleted, call_queue::callscompletedinsl, call_queue::holdtime, member::lastcall, call_queue::members, and call_queue::talktime.
Referenced by clear_stats(), and find_queue_by_name_rt().
01257 { 01258 q->holdtime = 0; 01259 q->callscompleted = 0; 01260 q->callsabandoned = 0; 01261 q->callscompletedinsl = 0; 01262 q->talktime = 0; 01263 01264 if (q->members) { 01265 struct member *mem; 01266 struct ao2_iterator mem_iter = ao2_iterator_init(q->members, 0); 01267 while ((mem = ao2_iterator_next(&mem_iter))) { 01268 mem->calls = 0; 01269 mem->lastcall = 0; 01270 ao2_ref(mem, -1); 01271 } 01272 ao2_iterator_destroy(&mem_iter); 01273 } 01274 }
| static int clear_stats | ( | const char * | queuename | ) | [static] |
Facilitates resetting statistics for a queue.
This function actually does not reset any statistics, but rather finds a call_queue struct which corresponds to the passed-in queue name and passes that structure to the clear_queue function. If no queuename is passed in, then all queues will have their statistics reset.
| queuename | The name of the queue to reset the statistics for. If this is NULL or zero-length, then this means to reset the statistics for all queues |
| void |
Definition at line 6025 of file app_queue.c.
References ao2_iterator_destroy(), ao2_iterator_init(), ao2_lock(), ao2_t_iterator_next, ao2_unlock(), ast_strlen_zero(), clear_queue(), call_queue::name, queue_t_unref, and queues.
Referenced by reload_handler().
06026 { 06027 struct call_queue *q; 06028 struct ao2_iterator queue_iter = ao2_iterator_init(queues, 0); 06029 while ((q = ao2_t_iterator_next(&queue_iter, "Iterate through queues"))) { 06030 ao2_lock(q); 06031 if (ast_strlen_zero(queuename) || !strcasecmp(q->name, queuename)) 06032 clear_queue(q); 06033 ao2_unlock(q); 06034 queue_t_unref(q, "Done with iterator"); 06035 } 06036 ao2_iterator_destroy(&queue_iter); 06037 return 0; 06038 }
| static int compare_weight | ( | struct call_queue * | rq, | |
| struct member * | member | |||
| ) | [static] |
Definition at line 2382 of file app_queue.c.
References ao2_find, ao2_iterator_destroy(), ao2_iterator_init(), ao2_lock(), ao2_ref, ao2_t_iterator_next, ao2_unlock(), ast_debug, call_queue::count, member::interface, call_queue::members, call_queue::name, num_available_members(), OBJ_POINTER, queue_t_unref, queues, and call_queue::weight.
Referenced by ring_entry().
02383 { 02384 struct call_queue *q; 02385 struct member *mem; 02386 int found = 0; 02387 struct ao2_iterator queue_iter; 02388 02389 /* q's lock and rq's lock already set by try_calling() 02390 * to solve deadlock */ 02391 queue_iter = ao2_iterator_init(queues, 0); 02392 while ((q = ao2_t_iterator_next(&queue_iter, "Iterate through queues"))) { 02393 if (q == rq) { /* don't check myself, could deadlock */ 02394 queue_t_unref(q, "Done with iterator"); 02395 continue; 02396 } 02397 ao2_lock(q); 02398 if (q->count && q->members) { 02399 if ((mem = ao2_find(q->members, member, OBJ_POINTER))) { 02400 ast_debug(1, "Found matching member %s in queue '%s'\n", mem->interface, q->name); 02401 if (q->weight > rq->weight && q->count >= num_available_members(q)) { 02402 ast_debug(1, "Queue '%s' (weight %d, calls %d) is preferred over '%s' (weight %d, calls %d)\n", q->name, q->weight, q->count, rq->name, rq->weight, rq->count); 02403 found = 1; 02404 } 02405 ao2_ref(mem, -1); 02406 } 02407 } 02408 ao2_unlock(q); 02409 queue_t_unref(q, "Done with iterator"); 02410 if (found) { 02411 break; 02412 } 02413 } 02414 ao2_iterator_destroy(&queue_iter); 02415 return found; 02416 }
| static char* complete_queue | ( | const char * | line, | |
| const char * | word, | |||
| int | pos, | |||
| int | state | |||
| ) | [static] |
Definition at line 6212 of file app_queue.c.
References ao2_iterator_destroy(), ao2_iterator_init(), ao2_t_iterator_next, ast_strdup, call_queue::name, queue_t_unref, and queues.
Referenced by complete_queue_add_member(), complete_queue_pause_member(), complete_queue_remove_member(), complete_queue_set_member_penalty(), complete_queue_show(), handle_queue_reload(), and handle_queue_reset().
06213 { 06214 struct call_queue *q; 06215 char *ret = NULL; 06216 int which = 0; 06217 int wordlen = strlen(word); 06218 struct ao2_iterator queue_iter; 06219 06220 queue_iter = ao2_iterator_init(queues, 0); 06221 while ((q = ao2_t_iterator_next(&queue_iter, "Iterate through queues"))) { 06222 if (!strncasecmp(word, q->name, wordlen) && ++which > state) { 06223 ret = ast_strdup(q->name); 06224 queue_t_unref(q, "Done with iterator"); 06225 break; 06226 } 06227 queue_t_unref(q, "Done with iterator"); 06228 } 06229 ao2_iterator_destroy(&queue_iter); 06230 06231 return ret; 06232 }
| static char* complete_queue_add_member | ( | const char * | line, | |
| const char * | word, | |||
| int | pos, | |||
| int | state | |||
| ) | [static] |
Definition at line 6644 of file app_queue.c.
References ast_malloc, ast_strdup, complete_queue(), and num.
Referenced by handle_queue_add_member().
06645 { 06646 /* 0 - queue; 1 - add; 2 - member; 3 - <interface>; 4 - to; 5 - <queue>; 6 - penalty; 7 - <penalty>; 8 - as; 9 - <membername> */ 06647 switch (pos) { 06648 case 3: /* Don't attempt to complete name of interface (infinite possibilities) */ 06649 return NULL; 06650 case 4: /* only one possible match, "to" */ 06651 return state == 0 ? ast_strdup("to") : NULL; 06652 case 5: /* <queue> */ 06653 return complete_queue(line, word, pos, state); 06654 case 6: /* only one possible match, "penalty" */ 06655 return state == 0 ? ast_strdup("penalty") : NULL; 06656 case 7: 06657 if (state < 100) { /* 0-99 */ 06658 char *num; 06659 if ((num = ast_malloc(3))) { 06660 sprintf(num, "%d", state); 06661 } 06662 return num; 06663 } else { 06664 return NULL; 06665 } 06666 case 8: /* only one possible match, "as" */ 06667 return state == 0 ? ast_strdup("as") : NULL; 06668 case 9: /* Don't attempt to complete name of member (infinite possibilities) */ 06669 return NULL; 06670 default: 06671 return NULL; 06672 } 06673 }
| static char* complete_queue_pause_member | ( | const char * | line, | |
| const char * | word, | |||
| int | pos, | |||
| int | state | |||
| ) | [static] |
Definition at line 6865 of file app_queue.c.
References ast_strdup, and complete_queue().
Referenced by handle_queue_pause_member().
06866 { 06867 /* 0 - queue; 1 - pause; 2 - member; 3 - <interface>; 4 - queue; 5 - <queue>; 6 - reason; 7 - <reason> */ 06868 switch (pos) { 06869 case 3: /* Don't attempt to complete name of interface (infinite possibilities) */ 06870 return NULL; 06871 case 4: /* only one possible match, "queue" */ 06872 return state == 0 ? ast_strdup("queue") : NULL; 06873 case 5: /* <queue> */ 06874 return complete_queue(line, word, pos, state); 06875 case 6: /* "reason" */ 06876 return state == 0 ? ast_strdup("reason") : NULL; 06877 case 7: /* Can't autocomplete a reason, since it's 100% customizeable */ 06878 return NULL; 06879 default: 06880 return NULL; 06881 } 06882 }
| static char* complete_queue_remove_member | ( | const char * | line, | |
| const char * | word, | |||
| int | pos, | |||
| int | state | |||
| ) | [static] |
Definition at line 6774 of file app_queue.c.
References ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_lock(), ao2_ref, ao2_t_iterator_next, ao2_unlock(), ast_strdup, complete_queue(), member::interface, member::membername, call_queue::members, queue_t_unref, and queues.
Referenced by handle_queue_remove_member().
06775 { 06776 int which = 0; 06777 struct call_queue *q; 06778 struct member *m; 06779 struct ao2_iterator queue_iter; 06780 struct ao2_iterator mem_iter; 06781 int wordlen = strlen(word); 06782 06783 /* 0 - queue; 1 - remove; 2 - member; 3 - <member>; 4 - from; 5 - <queue> */ 06784 if (pos > 5 || pos < 3) 06785 return NULL; 06786 if (pos == 4) /* only one possible match, 'from' */ 06787 return (state == 0 ? ast_strdup("from") : NULL); 06788 06789 if (pos == 5) /* No need to duplicate code */ 06790 return complete_queue(line, word, pos, state); 06791 06792 /* here is the case for 3, <member> */ 06793 queue_iter = ao2_iterator_init(queues, 0); 06794 while ((q = ao2_t_iterator_next(&queue_iter, "Iterate through queues"))) { 06795 ao2_lock(q); 06796 mem_iter = ao2_iterator_init(q->members, 0); 06797 while ((m = ao2_iterator_next(&mem_iter))) { 06798 if (!strncasecmp(word, m->membername, wordlen) && ++which > state) { 06799 char *tmp; 06800 ao2_unlock(q); 06801 tmp = ast_strdup(m->interface); 06802 ao2_ref(m, -1); 06803 queue_t_unref(q, "Done with iterator, returning interface name"); 06804 ao2_iterator_destroy(&mem_iter); 06805 ao2_iterator_destroy(&queue_iter); 06806 return tmp; 06807 } 06808 ao2_ref(m, -1); 06809 } 06810 ao2_iterator_destroy(&mem_iter); 06811 ao2_unlock(q); 06812 queue_t_unref(q, "Done with iterator"); 06813 } 06814 ao2_iterator_destroy(&queue_iter); 06815 06816 return NULL; 06817 }
| static char* complete_queue_rule_show | ( | const char * | line, | |
| const char * | word, | |||
| int | pos, | |||
| int | state | |||
| ) | [static] |
Definition at line 6998 of file app_queue.c.
References AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_strdup, and rule_list::name.
Referenced by handle_queue_rule_show().
06999 { 07000 int which = 0; 07001 struct rule_list *rl_iter; 07002 int wordlen = strlen(word); 07003 char *ret = NULL; 07004 if (pos != 3) /* Wha? */ { 07005 return NULL; 07006 } 07007 07008 AST_LIST_LOCK(&rule_lists); 07009 AST_LIST_TRAVERSE(&rule_lists, rl_iter, list) { 07010 if (!strncasecmp(word, rl_iter->name, wordlen) && ++which > state) { 07011 ret = ast_strdup(rl_iter->name); 07012 break; 07013 } 07014 } 07015 AST_LIST_UNLOCK(&rule_lists); 07016 07017 return ret; 07018 }
| static char* complete_queue_set_member_penalty | ( | const char * | line, | |
| const char * | word, | |||
| int | pos, | |||
| int | state | |||
| ) | [static] |
Definition at line 6935 of file app_queue.c.
References ast_strdup, and complete_queue().
Referenced by handle_queue_set_member_penalty().
06936 { 06937 /* 0 - queue; 1 - set; 2 - penalty; 3 - <penalty>; 4 - on; 5 - <member>; 6 - in; 7 - <queue>;*/ 06938 switch (pos) { 06939 case 4: 06940 if (state == 0) { 06941 return ast_strdup("on"); 06942 } else { 06943 return NULL; 06944 } 06945 case 6: 06946 if (state == 0) { 06947 return ast_strdup("in"); 06948 } else { 06949 return NULL; 06950 } 06951 case 7: 06952 return complete_queue(line, word, pos, state); 06953 default: 06954 return NULL; 06955 } 06956 }
| static char* complete_queue_show | ( | const char * | line, | |
| const char * | word, | |||
| int | pos, | |||
| int | state | |||
| ) | [static] |
Definition at line 6234 of file app_queue.c.
References complete_queue().
Referenced by queue_show().
06235 { 06236 if (pos == 2) 06237 return complete_queue(line, word, pos, state); 06238 return NULL; 06239 }
| static int compress_char | ( | const char | c | ) | [static] |
Definition at line 1150 of file app_queue.c.
Referenced by member_hash_fn().
01151 { 01152 if (c < 32) 01153 return 0; 01154 else if (c > 96) 01155 return c - 64; 01156 else 01157 return c - 32; 01158 }
| static void copy_rules | ( | struct queue_ent * | qe, | |
| const char * | rulename | |||
| ) | [static] |
Copy rule from global list into specified queue.
Definition at line 5001 of file app_queue.c.
References ast_calloc, AST_LIST_INSERT_TAIL, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_log(), ast_strlen_zero(), call_queue::defaultrule, LOG_ERROR, penalty_rule::max_relative, penalty_rule::max_value, penalty_rule::min_relative, penalty_rule::min_value, rule_list::name, queue_ent::parent, queue_ent::qe_rules, rule_list::rules, and penalty_rule::time.
Referenced by queue_exec().
05002 { 05003 struct penalty_rule *pr_iter; 05004 struct rule_list *rl_iter; 05005 const char *tmp = ast_strlen_zero(rulename) ? qe->parent->defaultrule : rulename; 05006 AST_LIST_LOCK(&rule_lists); 05007 AST_LIST_TRAVERSE(&rule_lists, rl_iter, list) { 05008 if (!strcasecmp(rl_iter->name, tmp)) 05009 break; 05010 } 05011 if (rl_iter) { 05012 AST_LIST_TRAVERSE(&rl_iter->rules, pr_iter, list) { 05013 struct penalty_rule *new_pr = ast_calloc(1, sizeof(*new_pr)); 05014 if (!new_pr) { 05015 ast_log(LOG_ERROR, "Memory allocation error when copying penalty rules! Aborting!\n"); 05016 AST_LIST_UNLOCK(&rule_lists); 05017 break; 05018 } 05019 new_pr->time = pr_iter->time; 05020 new_pr->max_value = pr_iter->max_value; 05021 new_pr->min_value = pr_iter->min_value; 05022 new_pr->max_relative = pr_iter->max_relative; 05023 new_pr->min_relative = pr_iter->min_relative; 05024 AST_LIST_INSERT_TAIL(&qe->qe_rules, new_pr, list); 05025 } 05026 } 05027 AST_LIST_UNLOCK(&rule_lists); 05028 }
| static struct member* create_queue_member | ( | const char * | interface, | |
| const char * | membername, | |||
| int | penalty, | |||
| int | paused, | |||
| const char * | state_interface | |||
| ) | [static, read] |
allocate space for new queue member and set fields based on parameters passed
Definition at line 1125 of file app_queue.c.
References ao2_alloc, ast_copy_string(), ast_log(), ast_strlen_zero(), member::interface, LOG_WARNING, member::membername, member::paused, member::penalty, member::state_interface, and member::status.
Referenced by add_to_queue(), reload_single_member(), and rt_handle_member_record().
01126 { 01127 struct member *cur; 01128 01129 if ((cur = ao2_alloc(sizeof(*cur), NULL))) { 01130 cur->penalty = penalty; 01131 cur->paused = paused; 01132 ast_copy_string(cur->interface, interface, sizeof(cur->interface)); 01133 if (!ast_strlen_zero(state_interface)) 01134 ast_copy_string(cur->state_interface, state_interface, sizeof(cur->state_interface)); 01135 else 01136 ast_copy_string(cur->state_interface, interface, sizeof(cur->state_interface)); 01137 if (!ast_strlen_zero(membername)) 01138 ast_copy_string(cur->membername, membername, sizeof(cur->membername)); 01139 else 01140 ast_copy_string(cur->membername, interface, sizeof(cur->membername)); 01141 if (!strchr(cur->interface, '/')) 01142 ast_log(LOG_WARNING, "No location at interface '%s'\n", interface); 01143 cur->status = ast_device_state(cur->state_interface); 01144 } 01145 01146 return cur; 01147 }
| static void destroy_queue | ( | void * | obj | ) | [static] |
Free queue's member list then its string fields.
Definition at line 1671 of file app_queue.c.
References ao2_ref, free, free_members(), MAX_PERIODIC_ANNOUNCEMENTS, call_queue::members, and call_queue::sound_periodicannounce.
Referenced by alloc_queue().
01672 { 01673 struct call_queue *q = obj; 01674 int i; 01675 01676 free_members(q, 1); 01677 for (i = 0; i < MAX_PERIODIC_ANNOUNCEMENTS; i++) { 01678 if (q->sound_periodicannounce[i]) 01679 free(q->sound_periodicannounce[i]); 01680 } 01681 ao2_ref(q->members, -1); 01682 }
| static void device_state_cb | ( | const struct ast_event * | event, | |
| void * | unused | |||
| ) | [static] |
Definition at line 1098 of file app_queue.c.
References ast_calloc, ast_event_get_ie_str(), ast_event_get_ie_uint(), AST_EVENT_IE_DEVICE, AST_EVENT_IE_STATE, ast_free, ast_log(), ast_strlen_zero(), ast_taskprocessor_push(), statechange::dev, handle_statechange(), LOG_ERROR, and statechange::state.
Referenced by load_module().
01099 { 01100 enum ast_device_state state; 01101 const char *device; 01102 struct statechange *sc; 01103 size_t datapsize; 01104 01105 state = ast_event_get_ie_uint(event, AST_EVENT_IE_STATE); 01106 device = ast_event_get_ie_str(event, AST_EVENT_IE_DEVICE); 01107 01108 if (ast_strlen_zero(device)) { 01109 ast_log(LOG_ERROR, "Received invalid event that had no device IE\n"); 01110 return; 01111 } 01112 datapsize = sizeof(*sc) + strlen(device) + 1; 01113 if (!(sc = ast_calloc(1, datapsize))) { 01114 ast_log(LOG_ERROR, "failed to calloc a state change struct\n"); 01115 return; 01116 } 01117 sc->state = state; 01118 strcpy(sc->dev, device); 01119 if (ast_taskprocessor_push(devicestate_tps, handle_statechange, sc) < 0) { 01120 ast_free(sc); 01121 } 01122 }
| static void do_hang | ( | struct callattempt * | o | ) | [static] |
common hangup actions
Definition at line 2419 of file app_queue.c.
References ast_hangup(), callattempt::chan, and callattempt::stillgoing.
Referenced by ring_entry(), and wait_for_answer().
02420 { 02421 o->stillgoing = 0; 02422 ast_hangup(o->chan); 02423 o->chan = NULL; 02424 }
| static void do_print | ( | struct mansession * | s, | |
| int | fd, | |||
| const char * | str | |||
| ) | [static] |
direct ouput to manager or cli with proper terminator
Definition at line 6070 of file app_queue.c.
References ast_cli(), and astman_append().
Referenced by __queues_show().
06071 { 06072 if (s) 06073 astman_append(s, "%s\r\n", str); 06074 else 06075 ast_cli(fd, "%s\n", str); 06076 }
| static void dump_queue_members | ( | struct call_queue * | pm_queue | ) | [static] |
Dump all members in a specific queue to the database.
<pm_family>/<queuename> = <interface>;<penalty>;<paused>;<state_interface>[|...]
Definition at line 4370 of file app_queue.c.
References ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_ref, ast_db_del(), ast_db_put(), ast_log(), member::dynamic, member::interface, LOG_WARNING, member::membername, call_queue::members, call_queue::name, member::paused, member::penalty, PM_MAX_LEN, and member::state_interface.
Referenced by add_to_queue(), remove_from_queue(), and set_member_paused().
04371 { 04372 struct member *cur_member; 04373 char value[PM_MAX_LEN]; 04374 int value_len = 0; 04375 int res; 04376 struct ao2_iterator mem_iter; 04377 04378 memset(value, 0, sizeof(value)); 04379 04380 if (!pm_queue) 04381 return; 04382 04383 mem_iter = ao2_iterator_init(pm_queue->members, 0); 04384 while ((cur_member = ao2_iterator_next(&mem_iter))) { 04385 if (!cur_member->dynamic) { 04386 ao2_ref(cur_member, -1); 04387 continue; 04388 } 04389 04390 res = snprintf(value + value_len, sizeof(value) - value_len, "%s%s;%d;%d;%s;%s", 04391 value_len ? "|" : "", cur_member->interface, cur_member->penalty, cur_member->paused, cur_member->membername, cur_member->state_interface); 04392 04393 ao2_ref(cur_member, -1); 04394 04395 if (res != strlen(value + value_len)) { 04396 ast_log(LOG_WARNING, "Could not create persistent member string, out of space\n"); 04397 break; 04398 } 04399 value_len += res; 04400 } 04401 ao2_iterator_destroy(&mem_iter); 04402 04403 if (value_len && !cur_member) { 04404 if (ast_db_put(pm_family, pm_queue->name, value)) 04405 ast_log(LOG_WARNING, "failed to create persistent dynamic entry!\n"); 04406 } else 04407 /* Delete the entry if the queue is empty or there is an error */ 04408 ast_db_del(pm_family, pm_queue->name); 04409 }
| static void end_bridge_callback | ( | void * | data | ) | [static] |
Definition at line 3538 of file app_queue.c.
References ao2_lock(), ao2_ref, ao2_unlock(), queue_end_bridge::chan, queue_ent::chan, queue_end_bridge::q, queue_t_unref, and set_queue_variables().
Referenced by try_calling().
03539 { 03540 struct queue_end_bridge *qeb = data; 03541 struct call_queue *q = qeb->q; 03542 struct ast_channel *chan = qeb->chan; 03543 03544 if (ao2_ref(qeb, -1) == 1) { 03545 ao2_lock(q); 03546 set_queue_variables(q, chan); 03547 ao2_unlock(q); 03548 /* This unrefs the reference we made in try_calling when we allocated qeb */ 03549 queue_t_unref(q, "Expire bridge_config reference"); 03550 } 03551 }
| static void end_bridge_callback_data_fixup | ( | struct ast_bridge_config * | bconfig, | |
| struct ast_channel * | originator, | |||
| struct ast_channel * | terminator | |||
| ) | [static] |
Definition at line 3531 of file app_queue.c.
References ao2_ref, queue_end_bridge::chan, and ast_bridge_config::end_bridge_callback_data.
Referenced by try_calling().
03532 { 03533 struct queue_end_bridge *qeb = bconfig->end_bridge_callback_data; 03534 ao2_ref(qeb, +1); 03535 qeb->chan = originator; 03536 }
| static struct callattempt* find_best | ( | struct callattempt * | outgoing | ) | [static, read] |
find the entry with the best metric, or NULL
Definition at line 2632 of file app_queue.c.
References callattempt::metric, and callattempt::q_next.
Referenced by ring_one(), store_next_lin(), and store_next_rr().
02633 { 02634 struct callattempt *best = NULL, *cur; 02635 02636 for (cur = outgoing; cur; cur = cur->q_next) { 02637 if (cur->stillgoing && /* Not already done */ 02638 !cur->chan && /* Isn't already going */ 02639 (!best || cur->metric < best->metric)) { /* We haven't found one yet, or it's better */ 02640 best = cur; 02641 } 02642 } 02643 02644 return best; 02645 }
| static struct call_queue* find_queue_by_name_rt | ( | const char * | queuename, | |
| struct ast_variable * | queue_vars, | |||
| struct ast_config * | member_config | |||
| ) | [static, read] |
Reload a single queue via realtime.
Check for statically defined queue first, check if deleted RT queue, check for new RT queue, if queue vars are not defined init them with defaults. reload RT queue vars, set RT queue members dead and reload them, return finished queue.
| the | queue, | |
| NULL | if it doesn't exist. |
Definition at line 1704 of file app_queue.c.
References alloc_queue(), ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_lock(), ao2_ref, ao2_t_find, ao2_unlink, ao2_unlock(), ast_category_browse(), ast_copy_string(), ast_debug, ast_log(), ast_queue_log(), ast_strlen_zero(), ast_variable_retrieve(), clear_queue(), member::dead, call_queue::dead, init_queue(), member::interface, LOG_WARNING, call_queue::membercount, call_queue::members, ast_variable::name, call_queue::name, ast_variable::next, OBJ_POINTER, queue_set_param(), QUEUE_STRATEGY_RINGALL, queue_t_unref, queues, queues_t_link, queues_t_unlink, member::realtime, call_queue::realtime, rt_handle_member_record(), S_OR, strat2int(), call_queue::strategy, and ast_variable::value.
Referenced by load_realtime_queue().
01705 { 01706 struct ast_variable *v; 01707 struct call_queue *q, tmpq; 01708 struct member *m; 01709 struct ao2_iterator mem_iter; 01710 char *interface = NULL; 01711 const char *tmp_name; 01712 char *tmp; 01713 char tmpbuf[64]; /* Must be longer than the longest queue param name. */ 01714 01715 ast_copy_string(tmpq.name, queuename, sizeof(tmpq.name)); 01716 01717 /* Static queues override realtime. */ 01718 if ((q = ao2_t_find(queues, &tmpq, OBJ_POINTER, "Check if static queue exists"))) { 01719 ao2_lock(q); 01720 if (!q->realtime) { 01721 if (q->dead) { 01722 ao2_unlock(q); 01723 queue_t_unref(q, "Queue is dead; can't return it"); 01724 return NULL; 01725 } else { 01726 ast_log(LOG_WARNING, "Static queue '%s' already exists. Not loading from realtime\n", q->name); 01727 ao2_unlock(q); 01728 return q; 01729 } 01730 } 01731 } else if (!member_config) 01732 /* Not found in the list, and it's not realtime ... */ 01733 return NULL; 01734 01735 /* Check if queue is defined in realtime. */ 01736 if (!queue_vars) { 01737 /* Delete queue from in-core list if it has been deleted in realtime. */ 01738 if (q) { 01739 /*! \note Hmm, can't seem to distinguish a DB failure from a not 01740 found condition... So we might delete an in-core queue 01741 in case of DB failure. */ 01742 ast_debug(1, "Queue %s not found in realtime.\n", queuename); 01743 01744 q->dead = 1; 01745 /* Delete if unused (else will be deleted when last caller leaves). */ 01746 queues_t_unlink(queues, q, "Unused; removing from container"); 01747 ao2_unlock(q); 01748 queue_t_unref(q, "Queue is dead; can't return it"); 01749 } 01750 return NULL; 01751 } 01752 01753 /* Create a new queue if an in-core entry does not exist yet. */ 01754 if (!q) { 01755 struct ast_variable *tmpvar = NULL; 01756 if (!(q = alloc_queue(queuename))) 01757 return NULL; 01758 ao2_lock(q); 01759 clear_queue(q); 01760 q->realtime = 1; 01761 q->membercount = 0; 01762 /*Before we initialize the queue, we need to set the strategy, so that linear strategy 01763 * will allocate the members properly 01764 */ 01765 for (tmpvar = queue_vars; tmpvar; tmpvar = tmpvar->next) { 01766 if (!strcasecmp(tmpvar->name, "strategy")) { 01767 q->strategy = strat2int(tmpvar->value); 01768 if (q->strategy < 0) { 01769 ast_log(LOG_WARNING, "'%s' isn't a valid strategy for queue '%s', using ringall instead\n", 01770 tmpvar->value, q->name); 01771 q->strategy = QUEUE_STRATEGY_RINGALL; 01772 } 01773 break; 01774 } 01775 } 01776 /* We traversed all variables and didn't find a strategy */ 01777 if (!tmpvar) 01778 q->strategy = QUEUE_STRATEGY_RINGALL; 01779 queues_t_link(queues, q, "Add queue to container"); 01780 } 01781 init_queue(q); /* Ensure defaults for all parameters not set explicitly. */ 01782 01783 memset(tmpbuf, 0, sizeof(tmpbuf)); 01784 for (v = queue_vars; v; v = v->next) { 01785 /* Convert to dashes `-' from underscores `_' as the latter are more SQL friendly. */ 01786 if ((tmp = strchr(v->name, '_'))) { 01787 ast_copy_string(tmpbuf, v->name, sizeof(tmpbuf)); 01788 tmp_name = tmpbuf; 01789 tmp = tmpbuf; 01790 while ((tmp = strchr(tmp, '_'))) 01791 *tmp++ = '-'; 01792 } else 01793 tmp_name = v->name; 01794 01795 if (!ast_strlen_zero(v->value)) { 01796 /* Don't want to try to set the option if the value is empty */ 01797 queue_set_param(q, tmp_name, v->value, -1, 0); 01798 } 01799 } 01800 01801 /* Temporarily set realtime members dead so we can detect deleted ones. 01802 * Also set the membercount correctly for realtime*/ 01803 mem_iter = ao2_iterator_init(q->members, 0); 01804 while ((m = ao2_iterator_next(&mem_iter))) { 01805 q->membercount++; 01806 if (m->realtime) 01807 m->dead = 1; 01808 ao2_ref(m, -1); 01809 } 01810 ao2_iterator_destroy(&mem_iter); 01811 01812 while ((interface = ast_category_browse(member_config, interface))) { 01813 rt_handle_member_record(q, interface, 01814 ast_variable_retrieve(member_config, interface, "uniqueid"), 01815 S_OR(ast_variable_retrieve(member_config, interface, "membername"),interface), 01816 ast_variable_retrieve(member_config, interface, "penalty"), 01817 ast_variable_retrieve(member_config, interface, "paused"), 01818 S_OR(ast_variable_retrieve(member_config, interface, "state_interface"),interface)); 01819 } 01820 01821 /* Delete all realtime members that have been deleted in DB. */ 01822 mem_iter = ao2_iterator_init(q->members, 0); 01823 while ((m = ao2_iterator_next(&mem_iter))) { 01824 if (m->dead) { 01825 ast_queue_log(q->name, "REALTIME", m->interface, "REMOVEMEMBER", "%s", ""); 01826 ao2_unlink(q->members, m); 01827 q->membercount--; 01828 } 01829 ao2_ref(m, -1); 01830 } 01831 ao2_iterator_destroy(&mem_iter); 01832 01833 ao2_unlock(q); 01834 01835 return q; 01836 }
| static void free_members | ( | struct call_queue * | q, | |
| int | all | |||
| ) | [static] |
Iterate through queue's member list and delete them.
Definition at line 1654 of file app_queue.c.
References ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_ref, ao2_unlink, member::dynamic, call_queue::membercount, and call_queue::members.
Referenced by destroy_queue().
01655 { 01656 /* Free non-dynamic members */ 01657 struct member *cur; 01658 struct ao2_iterator mem_iter = ao2_iterator_init(q->members, 0); 01659 01660 while ((cur = ao2_iterator_next(&mem_iter))) { 01661 if (all || !cur->dynamic) { 01662 ao2_unlink(q->members, cur); 01663 q->membercount--; 01664 } 01665 ao2_ref(cur, -1); 01666 } 01667 ao2_iterator_destroy(&mem_iter); 01668 }
| static int get_member_penalty | ( | char * | queuename, | |
| char * | interface | |||
| ) | [static] |
Definition at line 4648 of file app_queue.c.
References ao2_lock(), ao2_ref, ao2_t_find, ao2_unlock(), ast_copy_string(), ast_log(), interface_exists(), LOG_ERROR, call_queue::name, OBJ_POINTER, member::penalty, queue_t_unref, queues, and RESULT_FAILURE.
Referenced by queue_function_memberpenalty_read().
04649 { 04650 int foundqueue = 0, penalty; 04651 struct call_queue *q, tmpq; 04652 struct member *mem; 04653 04654 ast_copy_string(tmpq.name, queuename, sizeof(tmpq.name)); 04655 if ((q = ao2_t_find(queues, &tmpq, OBJ_POINTER, "Search for queue"))) { 04656 foundqueue = 1; 04657 ao2_lock(q); 04658 if ((mem = interface_exists(q, interface))) { 04659 penalty = mem->penalty; 04660 ao2_ref(mem, -1); 04661 ao2_unlock(q); 04662 queue_t_unref(q, "Search complete"); 04663 return penalty; 04664 } 04665 ao2_unlock(q); 04666 queue_t_unref(q, "Search complete"); 04667 } 04668 04669 /* some useful debuging */ 04670 if (foundqueue) 04671 ast_log (LOG_ERROR, "Invalid queuename\n"); 04672 else 04673 ast_log (LOG_ERROR, "Invalid interface\n"); 04674 04675 return RESULT_FAILURE; 04676 }
| static int get_member_status | ( | struct call_queue * | q, | |
| int | max_penalty, | |||
| int | min_penalty, | |||
| enum empty_conditions | conditions | |||
| ) | [static] |
Check if members are available.
This function checks to see if members are available to be called. If any member is available, the function immediately returns 0. If no members are available, then -1 is returned.
Definition at line 949 of file app_queue.c.
References ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_lock(), ao2_ref, ao2_unlock(), ast_debug, AST_DEVICE_INUSE, AST_DEVICE_INVALID, AST_DEVICE_RINGING, AST_DEVICE_UNAVAILABLE, AST_DEVICE_UNKNOWN, member::lastcall, member::membername, call_queue::members, member::paused, member::penalty, QUEUE_EMPTY_INUSE, QUEUE_EMPTY_INVALID, QUEUE_EMPTY_PAUSED, QUEUE_EMPTY_PENALTY, QUEUE_EMPTY_RINGING, QUEUE_EMPTY_UNAVAILABLE, QUEUE_EMPTY_UNKNOWN, QUEUE_EMPTY_WRAPUP, member::status, and call_queue::wrapuptime.
Referenced by join_queue(), queue_exec(), and wait_our_turn().
00950 { 00951 struct member *member; 00952 struct ao2_iterator mem_iter; 00953 00954 ao2_lock(q); 00955 mem_iter = ao2_iterator_init(q->members, 0); 00956 for (; (member = ao2_iterator_next(&mem_iter)); ao2_ref(member, -1)) { 00957 if ((max_penalty && (member->penalty > max_penalty)) || (min_penalty && (member->penalty < min_penalty))) { 00958 if (conditions & QUEUE_EMPTY_PENALTY) { 00959 ast_debug(4, "%s is unavailable because his penalty is not between %d and %d\n", member->membername, min_penalty, max_penalty); 00960 continue; 00961 } 00962 } 00963 00964 switch (member->status) { 00965 case AST_DEVICE_INVALID: 00966 if (conditions & QUEUE_EMPTY_INVALID) { 00967 ast_debug(4, "%s is unavailable because his device state is 'invalid'\n", member->membername); 00968 break; 00969 } 00970 goto default_case; 00971 case AST_DEVICE_UNAVAILABLE: 00972 if (conditions & QUEUE_EMPTY_UNAVAILABLE) { 00973 ast_debug(4, "%s is unavailable because his device state is 'unavailable'\n", member->membername); 00974 break; 00975 } 00976 goto default_case; 00977 case AST_DEVICE_INUSE: 00978 if (conditions & QUEUE_EMPTY_INUSE) { 00979 ast_debug(4, "%s is unavailable because his device state is 'inuse'\n", member->membername); 00980 break; 00981 } 00982 goto default_case; 00983 case AST_DEVICE_RINGING: 00984 if (conditions & QUEUE_EMPTY_RINGING) { 00985 ast_debug(4, "%s is unavailable because his device state is 'ringing'\n", member->membername); 00986 break; 00987 } 00988 case AST_DEVICE_UNKNOWN: 00989 if (conditions & QUEUE_EMPTY_UNKNOWN) { 00990 ast_debug(4, "%s is unavailable because his device state is 'unknown'\n", member->membername); 00991 break; 00992 } 00993 /* Fall-through */ 00994 default: 00995 default_case: 00996 if (member->paused && (conditions & QUEUE_EMPTY_PAUSED)) { 00997 ast_debug(4, "%s is unavailable because he is paused'\n", member->membername); 00998 break; 00999 } else if ((conditions & QUEUE_EMPTY_WRAPUP) && member->lastcall && q->wrapuptime && (time(NULL) - q->wrapuptime < member->lastcall)) { 01000 ast_debug(4, "%s is unavailable because it has only been %d seconds since his last call (wrapup time is %d)\n", member->membername, (int) (time(NULL) - member->lastcall), q->wrapuptime); 01001 break; 01002 } else { 01003 ao2_unlock(q); 01004 ao2_ref(member, -1); 01005 ao2_iterator_destroy(&mem_iter); 01006 ast_debug(4, "%s is available.\n", member->membername); 01007 return 0; 01008 } 01009 break; 01010 } 01011 } 01012 ao2_iterator_destroy(&mem_iter); 01013 01014 ao2_unlock(q); 01015 return -1; 01016 }
| static char* handle_queue_add_member | ( | struct ast_cli_entry * | e, | |
| int | cmd, | |||
| struct ast_cli_args * | a | |||
| ) | [static] |
Definition at line 6700 of file app_queue.c.
References add_to_queue(), ast_cli_args::argc, ast_cli_args::argv, ast_cli(), ast_queue_log(), CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, complete_queue_add_member(), ast_cli_args::fd, ast_cli_args::line, ast_cli_args::n, ast_cli_args::pos, RES_EXISTS, RES_NOSUCHQUEUE, RES_NOT_DYNAMIC, RES_OKAY, RES_OUTOFMEMORY, ast_cli_entry::usage, and ast_cli_args::word.
06701 { 06702 char *queuename, *interface, *membername = NULL, *state_interface = NULL; 06703 int penalty; 06704 06705 switch ( cmd ) { 06706 case CLI_INIT: 06707 e->command = "queue add member"; 06708 e->usage = 06709 "Usage: queue add member <channel> to <queue> [[[penalty <penalty>] as <membername>] state_interface <interface>]\n" 06710 " Add a channel to a queue with optionally: a penalty, membername and a state_interface\n"; 06711 return NULL; 06712 case CLI_GENERATE: 06713 return complete_queue_add_member(a->line, a->word, a->pos, a->n); 06714 } 06715 06716 if ((a->argc != 6) && (a->argc != 8) && (a->argc != 10) && (a->argc != 12)) { 06717 return CLI_SHOWUSAGE; 06718 } else if (strcmp(a->argv[4], "to")) { 06719 return CLI_SHOWUSAGE; 06720 } else if ((a->argc >= 8) && strcmp(a->argv[6], "penalty")) { 06721 return CLI_SHOWUSAGE; 06722 } else if ((a->argc >= 10) && strcmp(a->argv[8], "as")) { 06723 return CLI_SHOWUSAGE; 06724 } else if ((a->argc == 12) && strcmp(a->argv[10], "state_interface")) { 06725 return CLI_SHOWUSAGE; 06726 } 06727 06728 queuename = a->argv[5]; 06729 interface = a->argv[3]; 06730 if (a->argc >= 8) { 06731 if (sscanf(a->argv[7], "%30d", &penalty) == 1) { 06732 if (penalty < 0) { 06733 ast_cli(a->fd, "Penalty must be >= 0\n"); 06734 penalty = 0; 06735 } 06736 } else { 06737 ast_cli(a->fd, "Penalty must be an integer >= 0\n"); 06738 penalty = 0; 06739 } 06740 } else { 06741 penalty = 0; 06742 } 06743 06744 if (a->argc >= 10) { 06745 membername = a->argv[9]; 06746 } 06747 06748 if (a->argc >= 12) { 06749 state_interface = a->argv[11]; 06750 } 06751 06752 switch (add_to_queue(queuename, interface, membername, penalty, 0, queue_persistent_members, state_interface)) { 06753 case RES_OKAY: 06754 ast_queue_log(queuename, "CLI", interface, "ADDMEMBER", "%s", ""); 06755 ast_cli(a->fd, "Added interface '%s' to queue '%s'\n", interface, queuename); 06756 return CLI_SUCCESS; 06757 case RES_EXISTS: 06758 ast_cli(a->fd, "Unable to add interface '%s' to queue '%s': Already there\n", interface, queuename); 06759 return CLI_FAILURE; 06760 case RES_NOSUCHQUEUE: 06761 ast_cli(a->fd, "Unable to add interface to queue '%s': No such queue\n", queuename); 06762 return CLI_FAILURE; 06763 case RES_OUTOFMEMORY: 06764 ast_cli(a->fd, "Out of memory\n"); 06765 return CLI_FAILURE; 06766 case RES_NOT_DYNAMIC: 06767 ast_cli(a->fd, "Member not dynamic\n"); 06768 return CLI_FAILURE; 06769 default: 06770 return CLI_FAILURE; 06771 } 06772 }
| static char* handle_queue_pause_member | ( | struct ast_cli_entry * | e, | |
| int | cmd, | |||
| struct ast_cli_args * | a | |||
| ) | [static] |
Definition at line 6884 of file app_queue.c.
References ast_cli_args::argc, ast_cli_args::argv, ast_cli(), ast_strlen_zero(), CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, complete_queue_pause_member(), ast_cli_args::fd, ast_cli_args::line, ast_cli_args::n, ast_cli_args::pos, RESULT_SUCCESS, set_member_paused(), ast_cli_entry::usage, and word.
06885 { 06886 char *queuename, *interface, *reason; 06887 int paused; 06888 06889 switch (cmd) { 06890 case CLI_INIT: 06891 e->command = "queue {pause|unpause} member"; 06892 e->usage = 06893 "Usage: queue {pause|unpause} member <member> [queue <queue> [reason <reason>]]\n" 06894 " Pause or unpause a queue member. Not specifying a particular queue\n" 06895 " will pause or unpause a member across all queues to which the member\n" 06896 " belongs.\n"; 06897 return NULL; 06898 case CLI_GENERATE: 06899 return complete_queue_pause_member(a->line, a-> word, a->pos, a->n); 06900 } 06901 06902 if (a->argc < 4 || a->argc == 5 || a->argc == 7 || a->argc > 8) { 06903 return CLI_SHOWUSAGE; 06904 } else if (a->argc >= 5 && strcmp(a->argv[4], "queue")) { 06905 return CLI_SHOWUSAGE; 06906 } else if (a->argc == 8 && strcmp(a->argv[6], "reason")) { 06907 return CLI_SHOWUSAGE; 06908 } 06909 06910 06911 interface = a->argv[3]; 06912 queuename = a->argc >= 6 ? a->argv[5] : NULL; 06913 reason = a->argc == 8 ? a->argv[7] : NULL; 06914 paused = !strcasecmp(a->argv[1], "pause"); 06915 06916 if (set_member_paused(queuename, interface, reason, paused) == RESULT_SUCCESS) { 06917 ast_cli(a->fd, "%spaused interface '%s'", paused ? "" : "un", interface); 06918 if (!ast_strlen_zero(queuename)) 06919 ast_cli(a->fd, " in queue '%s'", queuename); 06920 if (!ast_strlen_zero(reason)) 06921 ast_cli(a->fd, " for reason '%s'", reason); 06922 ast_cli(a->fd, "\n"); 06923 return CLI_SUCCESS; 06924 } else { 06925 ast_cli(a->fd, "Unable to %spause interface '%s'", paused ? "" : "un", interface); 06926 if (!ast_strlen_zero(queuename)) 06927 ast_cli(a->fd, " in queue '%s'", queuename); 06928 if (!ast_strlen_zero(reason)) 06929 ast_cli(a->fd, " for reason '%s'", reason); 06930 ast_cli(a->fd, "\n"); 06931 return CLI_FAILURE; 06932 } 06933 }
| static char* handle_queue_reload | ( | struct ast_cli_entry * | e, | |
| int | cmd, | |||
| struct ast_cli_args * | a | |||
| ) | [static] |
Definition at line 7093 of file app_queue.c.
References ast_cli_args::argc, ast_cli_args::argv, AST_FLAGS_ALL, ast_set_flag, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, complete_queue(), ast_cli_args::line, ast_cli_args::n, ast_cli_args::pos, QUEUE_RELOAD_MEMBER, QUEUE_RELOAD_PARAMETERS, QUEUE_RELOAD_RULES, reload_handler(), ast_cli_entry::usage, and ast_cli_args::word.
07094 { 07095 struct ast_flags mask = {0,}; 07096 int i; 07097 07098 switch (cmd) { 07099 case CLI_INIT: 07100 e->command = "queue reload {parameters|members|rules|all}"; 07101 e->usage = 07102 "Usage: queue reload {parameters|members|rules|all} [<queuenames>]\n" 07103 "Reload queues. If <queuenames> are specified, only reload information pertaining\n" 07104 "to <queuenames>. One of 'parameters,' 'members,' 'rules,' or 'all' must be\n" 07105 "specified in order to know what information to reload. Below is an explanation\n" 07106 "of each of these qualifiers.\n" 07107 "\n" 07108 "\t'members' - reload queue members from queues.conf\n" 07109 "\t'parameters' - reload all queue options except for queue members\n" 07110 "\t'rules' - reload the queuerules.conf file\n" 07111 "\t'all' - reload queue rules, parameters, and members\n" 07112 "\n" 07113 "Note: the 'rules' qualifier here cannot actually be applied to a specific queue.\n" 07114 "Use of the 'rules' qualifier causes queuerules.conf to be reloaded. Even if only\n" 07115 "one queue is specified when using this command, reloading queue rules may cause\n" 07116 "other queues to be affected\n"; 07117 return NULL; 07118 case CLI_GENERATE: 07119 if (a->pos >= 3) { 07120 return complete_queue(a->line, a->word, a->pos, a->n); 07121 } else { 07122 return NULL; 07123 } 07124 } 07125 07126 if (a->argc < 3) 07127 return CLI_SHOWUSAGE; 07128 07129 if (!strcasecmp(a->argv[2], "rules")) { 07130 ast_set_flag(&mask, QUEUE_RELOAD_RULES); 07131 } else if (!strcasecmp(a->argv[2], "members")) { 07132 ast_set_flag(&mask, QUEUE_RELOAD_MEMBER); 07133 } else if (!strcasecmp(a->argv[2], "parameters")) { 07134 ast_set_flag(&mask, QUEUE_RELOAD_PARAMETERS); 07135 } else if (!strcasecmp(a->argv[2], "all")) { 07136 ast_set_flag(&mask, AST_FLAGS_ALL); 07137 } 07138 07139 if (a->argc == 3) { 07140 reload_handler(1, &mask, NULL); 07141 return CLI_SUCCESS; 07142 } 07143 07144 for (i = 3; i < a->argc; ++i) { 07145 reload_handler(1, &mask, a->argv[i]); 07146 } 07147 07148 return CLI_SUCCESS; 07149 }
| static char* handle_queue_remove_member | ( | struct ast_cli_entry * | e, | |
| int | cmd, | |||
| struct ast_cli_args * | a | |||
| ) | [static] |
Definition at line 6819 of file app_queue.c.
References ast_cli_args::argc, ast_cli_args::argv, ast_cli(), ast_queue_log(), CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, complete_queue_remove_member(), ast_cli_args::fd, ast_cli_args::line, ast_cli_args::n, ast_cli_args::pos, remove_from_queue(), RES_EXISTS, RES_NOSUCHQUEUE, RES_NOT_DYNAMIC, RES_OKAY, RES_OUTOFMEMORY, ast_cli_entry::usage, and ast_cli_args::word.
06820 { 06821 char *queuename, *interface; 06822 06823 switch (cmd) { 06824 case CLI_INIT: 06825 e->command = "queue remove member"; 06826 e->usage = 06827 "Usage: queue remove member <channel> from <queue>\n" 06828 " Remove a specific channel from a queue.\n"; 06829 return NULL; 06830 case CLI_GENERATE: 06831 return complete_queue_remove_member(a->line, a->word, a->pos, a->n); 06832 } 06833 06834 if (a->argc != 6) { 06835 return CLI_SHOWUSAGE; 06836 } else if (strcmp(a->argv[4], "from")) { 06837 return CLI_SHOWUSAGE; 06838 } 06839 06840 queuename = a->argv[5]; 06841 interface = a->argv[3]; 06842 06843 switch (remove_from_queue(queuename, interface)) { 06844 case RES_OKAY: 06845 ast_queue_log(queuename, "CLI", interface, "REMOVEMEMBER", "%s", ""); 06846 ast_cli(a->fd, "Removed interface '%s' from queue '%s'\n", interface, queuename); 06847 return CLI_SUCCESS; 06848 case RES_EXISTS: 06849 ast_cli(a->fd, "Unable to remove interface '%s' from queue '%s': Not there\n", interface, queuename); 06850 return CLI_FAILURE; 06851 case RES_NOSUCHQUEUE: 06852 ast_cli(a->fd, "Unable to remove interface from queue '%s': No such queue\n", queuename); 06853 return CLI_FAILURE; 06854 case RES_OUTOFMEMORY: 06855 ast_cli(a->fd, "Out of memory\n"); 06856 return CLI_FAILURE; 06857 case RES_NOT_DYNAMIC: 06858 ast_cli(a->fd, "Unable to remove interface '%s' from queue '%s': Member is not dynamic\n", interface, queuename); 06859 return CLI_FAILURE; 06860 default: 06861 return CLI_FAILURE; 06862 } 06863 }
| static char* handle_queue_reset | ( | struct ast_cli_entry * | e, | |
| int | cmd, | |||
| struct ast_cli_args * | a | |||
| ) | [static] |
Definition at line 7054 of file app_queue.c.
References ast_cli_args::argc, ast_cli_args::argv, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, complete_queue(), ast_cli_args::line, ast_cli_args::n, ast_cli_args::pos, QUEUE_RESET_STATS, reload_handler(), ast_cli_entry::usage, and ast_cli_args::word.
07055 { 07056 struct ast_flags mask = {QUEUE_RESET_STATS,}; 07057 int i; 07058 07059 switch (cmd) { 07060 case CLI_INIT: 07061 e->command = "queue reset stats"; 07062 e->usage = 07063 "Usage: queue reset stats [<queuenames>]\n" 07064 "\n" 07065 "Issuing this command will reset statistics for\n" 07066 "<queuenames>, or for all queues if no queue is\n" 07067 "specified.\n"; 07068 return NULL; 07069 case CLI_GENERATE: 07070 if (a->pos >= 3) { 07071 return complete_queue(a->line, a->word, a->pos, a->n); 07072 } else { 07073 return NULL; 07074 } 07075 } 07076 07077 if (a->argc < 3) { 07078 return CLI_SHOWUSAGE; 07079 } 07080 07081 if (a->argc == 3) { 07082 reload_handler(1, &mask, NULL); 07083 return CLI_SUCCESS; 07084 } 07085 07086 for (i = 3; i < a->argc; ++i) { 07087 reload_handler(1, &mask, a->argv[i]); 07088 } 07089 07090 return CLI_SUCCESS; 07091 }
| static char* handle_queue_rule_show | ( | struct ast_cli_entry * | e, | |
| int | cmd, | |||
| struct ast_cli_args * | a | |||
| ) | [static] |
Definition at line 7020 of file app_queue.c.
References ast_cli_args::argc, ast_cli_args::argv, ast_cli(), AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_strlen_zero(), CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, complete_queue_rule_show(), ast_cli_args::fd, ast_cli_args::line, penalty_rule::max_relative, penalty_rule::max_value, penalty_rule::min_relative, penalty_rule::min_value, ast_cli_args::n, rule_list::name, ast_cli_args::pos, rule_list::rules, penalty_rule::time, ast_cli_entry::usage, and ast_cli_args::word.
07021 { 07022 char *rule; 07023 struct rule_list *rl_iter; 07024 struct penalty_rule *pr_iter; 07025 switch (cmd) { 07026 case CLI_INIT: 07027 e->command = "queue show rules"; 07028 e->usage = 07029 "Usage: queue show rules [rulename]\n" 07030 " Show the list of rules associated with rulename. If no\n" 07031 " rulename is specified, list all rules defined in queuerules.conf\n"; 07032 return NULL; 07033 case CLI_GENERATE: 07034 return complete_queue_rule_show(a->line, a->word, a->pos, a->n); 07035 } 07036 07037 if (a->argc != 3 && a->argc != 4) 07038 return CLI_SHOWUSAGE; 07039 07040 rule = a->argc == 4 ? a->argv[3] : ""; 07041 AST_LIST_LOCK(&rule_lists); 07042 AST_LIST_TRAVERSE(&rule_lists, rl_iter, list) { 07043 if (ast_strlen_zero(rule) || !strcasecmp(rl_iter->name, rule)) { 07044 ast_cli(a->fd, "Rule: %s\n", rl_iter->name); 07045 AST_LIST_TRAVERSE(&rl_iter->rules, pr_iter, list) { 07046 ast_cli(a->fd, "\tAfter %d seconds, adjust QUEUE_MAX_PENALTY %s %d and adjust QUEUE_MIN_PENALTY %s %d\n", pr_iter->time, pr_iter->max_relative ? "by" : "to", pr_iter->max_value, pr_iter->min_relative ? "by" : "to", pr_iter->min_value); 07047 } 07048 } 07049 } 07050 AST_LIST_UNLOCK(&rule_lists); 07051 return CLI_SUCCESS; 07052 }
| static char* handle_queue_set_member_penalty | ( | struct ast_cli_entry * | e, | |
| int | cmd, | |||
| struct ast_cli_args * | a | |||
| ) | [static] |
Definition at line 6958 of file app_queue.c.
References ast_cli_args::argc, ast_cli_args::argv, ast_cli(), CLI_FAILURE, CLI_GENERATE, CLI_INIT, CLI_SHOWUSAGE, CLI_SUCCESS, ast_cli_entry::command, complete_queue_set_member_penalty(), ast_cli_args::fd, ast_cli_args::line, ast_cli_args::n, ast_cli_args::pos, RESULT_FAILURE, RESULT_SUCCESS, set_member_penalty(), ast_cli_entry::usage, and ast_cli_args::word.
06959 { 06960 char *queuename = NULL, *interface; 06961 int penalty = 0; 06962 06963 switch (cmd) { 06964 case CLI_INIT: 06965 e->command = "queue set penalty"; 06966 e->usage = 06967 "Usage: queue set penalty <penalty> on <interface> [in <queue>]\n" 06968 " Set a member's penalty in the queue specified. If no queue is specified\n" 06969 " then that interface's penalty is set in all queues to which that interface is a member\n"; 06970 return NULL; 06971 case CLI_GENERATE: 06972 return complete_queue_set_member_penalty(a->line, a->word, a->pos, a->n); 06973 } 06974 06975 if (a->argc != 6 && a->argc != 8) { 06976 return CLI_SHOWUSAGE; 06977 } else if (strcmp(a->argv[4], "on") || (a->argc > 6 && strcmp(a->argv[6], "in"))) { 06978 return CLI_SHOWUSAGE; 06979 } 06980 06981 if (a->argc == 8) 06982 queuename = a->argv[7]; 06983 interface = a->argv[5]; 06984 penalty = atoi(a->argv[3]); 06985 06986 switch (set_member_penalty(queuename, interface, penalty)) { 06987 case RESULT_SUCCESS: 06988 ast_cli(a->fd, "Set penalty on interface '%s' from queue '%s'\n", interface, queuename); 06989 return CLI_SUCCESS; 06990 case RESULT_FAILURE: 06991 ast_cli(a->fd, "Failed to set penalty on interface '%s' from queue '%s'\n", interface, queuename); 06992 return CLI_FAILURE; 06993 default: 06994 return CLI_FAILURE; 06995 } 06996 }
| static int handle_statechange | ( | void * | datap | ) | [static] |
set a member's status based on device state of that member's interface
Definition at line 1054 of file app_queue.c.
References ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_lock(), ao2_ref, ao2_t_iterator_next, ao2_unlock(), ast_copy_string(), ast_debug, ast_devstate2str(), ast_free, statechange::dev, call_queue::found, call_queue::members, queue_t_unref, queues, statechange::state, member::state_interface, and update_status().
Referenced by device_state_cb().
01055 { 01056 struct statechange *sc = datap; 01057 struct ao2_iterator miter, qiter; 01058 struct member *m; 01059 struct call_queue *q; 01060 char interface[80], *slash_pos; 01061 int found = 0; 01062 01063 qiter = ao2_iterator_init(queues, 0); 01064 while ((q = ao2_t_iterator_next(&qiter, "Iterate over queues"))) { 01065 ao2_lock(q); 01066 01067 miter = ao2_iterator_init(q->members, 0); 01068 for (; (m = ao2_iterator_next(&miter)); ao2_ref(m, -1)) { 01069 ast_copy_string(interface, m->state_interface, sizeof(interface)); 01070 01071 if ((slash_pos = strchr(interface, '/'))) 01072 if (!strncasecmp(interface, "Local/", 6) && (slash_pos = strchr(slash_pos + 1, '/'))) 01073 *slash_pos = '\0'; 01074 01075 if (!strcasecmp(interface, sc->dev)) { 01076 found = 1; 01077 update_status(q, m, sc->state); 01078 ao2_ref(m, -1); 01079 break; 01080 } 01081 } 01082 ao2_iterator_destroy(&miter); 01083 01084 ao2_unlock(q); 01085 queue_t_unref(q, "Done with iterator"); 01086 } 01087 ao2_iterator_destroy(&qiter); 01088 01089 if (found) 01090 ast_debug(1, "Device '%s' changed to state '%d' (%s)\n", sc->dev, sc->state, ast_devstate2str(sc->state)); 01091 else 01092 ast_debug(3, "Device '%s' changed to state '%d' (%s) but we don't care because they're not a member of any queue.\n", sc->dev, sc->state, ast_devstate2str(sc->state)); 01093 01094 ast_free(sc); 01095 return 0; 01096 }
| static void hangupcalls | ( | struct callattempt * | outgoing, | |
| struct ast_channel * | exception, | |||
| int | cancel_answered_elsewhere | |||
| ) | [static] |
Hang up a list of outgoing calls.
Definition at line 2311 of file app_queue.c.
References ao2_ref, AST_FLAG_ANSWERED_ELSEWHERE, ast_free, ast_hangup(), ast_set_flag, callattempt::chan, callattempt::member, and callattempt::q_next.
Referenced by try_calling().
02312 { 02313 struct callattempt *oo; 02314 02315 while (outgoing) { 02316 /* If someone else answered the call we should indicate this in the CANCEL */ 02317 /* Hangup any existing lines we have open */ 02318 if (outgoing->chan && (outgoing->chan != exception)) { 02319 if (exception || cancel_answered_elsewhere) 02320 ast_set_flag(outgoing->chan, AST_FLAG_ANSWERED_ELSEWHERE); 02321 ast_hangup(outgoing->chan); 02322 } 02323 oo = outgoing; 02324 outgoing = outgoing->q_next; 02325 if (oo->member) 02326 ao2_ref(oo->member, -1); 02327 ast_free(oo); 02328 } 02329 }
| static void init_queue | ( | struct call_queue * | q | ) | [static] |
Initialize Queue default values.
Definition at line 1182 of file app_queue.c.
References call_queue::announcefrequency, call_queue::announceholdtime, call_queue::announceposition, ANNOUNCEPOSITION_YES, call_queue::announcepositionlimit, ao2_container_alloc, ast_copy_string(), ast_free, AST_LIST_REMOVE_HEAD, ast_str_create(), ast_str_set(), call_queue::autofill, call_queue::dead, DEFAULT_MIN_ANNOUNCE_FREQUENCY, DEFAULT_RETRY, DEFAULT_TIMEOUT, call_queue::eventwhencalled, call_queue::found, call_queue::joinempty, call_queue::leavewhenempty, call_queue::maskmemberstatus, MAX_PERIODIC_ANNOUNCEMENTS, call_queue::maxlen, member_cmp_fn(), member_hash_fn(), call_queue::memberdelay, call_queue::members, call_queue::minannouncefrequency, call_queue::monfmt, call_queue::montype, call_queue::numperiodicannounce, call_queue::periodicannouncefrequency, call_queue::queue_quantity1, call_queue::queue_quantity2, QUEUE_STRATEGY_LINEAR, call_queue::randomperiodicannounce, call_queue::reportholdtime, call_queue::retry, call_queue::ringinuse, call_queue::roundingseconds, call_queue::rules, call_queue::servicelevel, call_queue::setinterfacevar, call_queue::setqueueentryvar, call_queue::setqueuevar, call_queue::sound_calls, call_queue::sound_holdtime, call_queue::sound_minute, call_queue::sound_minutes, call_queue::sound_next, call_queue::sound_periodicannounce, call_queue::sound_reporthold, call_queue::sound_seconds, call_queue::sound_thanks, call_queue::sound_thereare, call_queue::strategy, call_queue::timeout, TIMEOUT_PRIORITY_APP, call_queue::timeoutpriority, call_queue::timeoutrestart, call_queue::weight, and call_queue::wrapuptime.
Referenced by find_queue_by_name_rt(), and reload_single_queue().
01183 { 01184 int i; 01185 struct penalty_rule *pr_iter; 01186 01187 q->dead = 0; 01188 q->retry = DEFAULT_RETRY; 01189 q->timeout = DEFAULT_TIMEOUT; 01190 q->maxlen = 0; 01191 q->announcefrequency = 0; 01192 q->minannouncefrequency = DEFAULT_MIN_ANNOUNCE_FREQUENCY; 01193 q->announceholdtime = 1; 01194 q->announcepositionlimit = 10; /* Default 10 positions */ 01195 q->announceposition = ANNOUNCEPOSITION_YES; /* Default yes */ 01196 q->roundingseconds = 0; /* Default - don't announce seconds */ 01197 q->servicelevel = 0; 01198 q->ringinuse = 1; 01199 q->setinterfacevar = 0; 01200 q->setqueuevar = 0; 01201 q->setqueueentryvar = 0; 01202 q->autofill = autofill_default; 01203 q->montype = montype_default; 01204 q->monfmt[0] = '\0'; 01205 q->reportholdtime = 0; 01206 q->wrapuptime = 0; 01207 q->joinempty = 0; 01208 q->leavewhenempty = 0; 01209 q->memberdelay = 0; 01210 q->maskmemberstatus = 0; 01211 q->eventwhencalled = 0; 01212 q->weight = 0; 01213 q->timeoutrestart = 0; 01214 q->periodicannouncefrequency = 0; 01215 q->randomperiodicannounce = 0; 01216 q->numperiodicannounce = 0; 01217 q->timeoutpriority = TIMEOUT_PRIORITY_APP; 01218 if (!q->members) { 01219 if (q->strategy == QUEUE_STRATEGY_LINEAR) 01220 /* linear strategy depends on order, so we have to place all members in a single bucket */ 01221 q->members = ao2_container_alloc(1, member_hash_fn, member_cmp_fn); 01222 else 01223 q->members = ao2_container_alloc(37, member_hash_fn, member_cmp_fn); 01224 } 01225 q->found = 1; 01226 01227 ast_copy_string(q->sound_next, "queue-youarenext", sizeof(q->sound_next)); 01228 ast_copy_string(q->sound_thereare, "queue-thereare", sizeof(q->sound_thereare)); 01229 ast_copy_string(q->sound_calls, "queue-callswaiting", sizeof(q->sound_calls)); 01230 ast_copy_string(q->sound_holdtime, "queue-holdtime", sizeof(q->sound_holdtime)); 01231 ast_copy_string(q->sound_minutes, "queue-minutes", sizeof(q->sound_minutes)); 01232 ast_copy_string(q->sound_minute, "queue-minute", sizeof(q->sound_minute)); 01233 ast_copy_string(q->sound_seconds, "queue-seconds", sizeof(q->sound_seconds)); 01234 ast_copy_string(q->sound_thanks, "queue-thankyou", sizeof(q->sound_thanks)); 01235 ast_copy_string(q->sound_reporthold, "queue-reporthold", sizeof(q->sound_reporthold)); 01236 ast_copy_string(q->queue_quantity1, "queue-quantity1", sizeof(q->queue_quantity1)); 01237 ast_copy_string(q->queue_quantity2, "queue-quantity2", sizeof(q->queue_quantity2)); 01238 01239 if (!q->sound_periodicannounce[0]) { 01240 q->sound_periodicannounce[0] = ast_str_create(32); 01241 } 01242 01243 if (q->sound_periodicannounce[0]) { 01244 ast_str_set(&q->sound_periodicannounce[0], 0, "queue-periodic-announce"); 01245 } 01246 01247 for (i = 1; i < MAX_PERIODIC_ANNOUNCEMENTS; i++) { 01248 if (q->sound_periodicannounce[i]) 01249 ast_str_set(&q->sound_periodicannounce[i], 0, "%s", ""); 01250 } 01251 01252 while ((pr_iter = AST_LIST_REMOVE_HEAD(&q->rules,list))) 01253 ast_free(pr_iter); 01254 }
| static void insert_entry | ( | struct call_queue * | q, | |
| struct queue_ent * | prev, | |||
| struct queue_ent * | new, | |||
| int * | pos | |||
| ) | [inline, static] |
Insert the 'new' entry after the 'prev' entry of queue 'q'.
Definition at line 919 of file app_queue.c.
References call_queue::head, queue_ent::next, and queue_ref().
Referenced by join_queue().
00920 { 00921 struct queue_ent *cur; 00922 00923 if (!q || !new) 00924 return; 00925 if (prev) { 00926 cur = prev->next; 00927 prev->next = new; 00928 } else { 00929 cur = q->head; 00930 q->head = new; 00931 } 00932 new->next = cur; 00933 00934 /* every queue_ent must have a reference to it's parent call_queue, this 00935 * reference does not go away until the end of the queue_ent's life, meaning 00936 * that even when the queue_ent leaves the call_queue this ref must remain. */ 00937 queue_ref(q); 00938 new->parent = q; 00939 new->pos = ++(*pos); 00940 new->opos = *pos; 00941 }
| static int insert_penaltychange | ( | const char * | list_name, | |
| const char * | content, | |||
| const int | linenum | |||
| ) | [static] |
Change queue penalty by adding rule.
Check rule for errors with time or fomatting, see if rule is relative to rest of queue, iterate list of rules to find correct insertion point, insert and return.
| -1 | on failure | |
| 0 | on success |
Definition at line 1285 of file app_queue.c.
References ast_calloc, ast_free, AST_LIST_INSERT_BEFORE_CURRENT, AST_LIST_INSERT_TAIL, AST_LIST_TRAVERSE, AST_LIST_TRAVERSE_SAFE_BEGIN, AST_LIST_TRAVERSE_SAFE_END, ast_log(), ast_strdupa, ast_strlen_zero(), LOG_WARNING, penalty_rule::max_relative, penalty_rule::max_value, penalty_rule::min_relative, penalty_rule::min_value, rule_list::name, rule_list::rules, and penalty_rule::time.
Referenced by reload_queue_rules().
01286 { 01287 char *timestr, *maxstr, *minstr, *contentdup; 01288 struct penalty_rule *rule = NULL, *rule_iter; 01289 struct rule_list *rl_iter; 01290 int penaltychangetime, inserted = 0; 01291 01292 if (!(rule = ast_calloc(1, sizeof(*rule)))) { 01293 return -1; 01294 } 01295 01296 contentdup = ast_strdupa(content); 01297 01298 if (!(maxstr = strchr(contentdup, ','))) { 01299 ast_log(LOG_WARNING, "Improperly formatted penaltychange rule at line %d. Ignoring.\n", linenum); 01300 ast_free(rule); 01301 return -1; 01302 } 01303 01304 *maxstr++ = '\0'; 01305 timestr = contentdup; 01306 01307 if ((penaltychangetime = atoi(timestr)) < 0) { 01308 ast_log(LOG_WARNING, "Improper time parameter specified for penaltychange rule at line %d. Ignoring.\n", linenum); 01309 ast_free(rule); 01310 return -1; 01311 } 01312 01313 rule->time = penaltychangetime; 01314 01315 if ((minstr = strchr(maxstr,','))) 01316 *minstr++ = '\0'; 01317 01318 /* The last check will evaluate true if either no penalty change is indicated for a given rule 01319 * OR if a min penalty change is indicated but no max penalty change is */ 01320 if (*maxstr == '+' || *maxstr == '-' || *maxstr == '\0') { 01321 rule->max_relative = 1; 01322 } 01323 01324 rule->max_value = atoi(maxstr); 01325 01326 if (!ast_strlen_zero(minstr)) { 01327 if (*minstr == '+' || *minstr == '-') 01328 rule->min_relative = 1; 01329 rule->min_value = atoi(minstr); 01330 } else /*there was no minimum specified, so assume this means no change*/ 01331 rule->min_relative = 1; 01332 01333 /*We have the rule made, now we need to insert it where it belongs*/ 01334 AST_LIST_TRAVERSE(&rule_lists, rl_iter, list){ 01335 if (strcasecmp(rl_iter->name, list_name)) 01336 continue; 01337 01338 AST_LIST_TRAVERSE_SAFE_BEGIN(&rl_iter->rules, rule_iter, list) { 01339 if (rule->time < rule_iter->time) { 01340 AST_LIST_INSERT_BEFORE_CURRENT(rule, list); 01341 inserted = 1; 01342 break; 01343 } 01344 } 01345 AST_LIST_TRAVERSE_SAFE_END; 01346 01347 if (!inserted) { 01348 AST_LIST_INSERT_TAIL(&rl_iter->rules, rule, list); 01349 } 01350 } 01351 01352 return 0; 01353 }
| static const char* int2strat | ( | int | strategy | ) | [static] |
Definition at line 837 of file app_queue.c.
References ARRAY_LEN, strategy::name, and strategies.
Referenced by __queues_show(), manager_queues_status(), queue_function_var(), and set_queue_variables().
00838 { 00839 int x; 00840 00841 for (x = 0; x < ARRAY_LEN(strategies); x++) { 00842 if (strategy == strategies[x].strategy) 00843 return strategies[x].name; 00844 } 00845 00846 return "<unknown>"; 00847 }
| static struct member* interface_exists | ( | struct call_queue * | q, | |
| const char * | interface | |||
| ) | [static, read] |
Definition at line 4344 of file app_queue.c.
References ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_ref, member::interface, and call_queue::members.
Referenced by add_to_queue(), get_member_penalty(), set_member_paused(), and set_member_penalty().
04345 { 04346 struct member *mem; 04347 struct ao2_iterator mem_iter; 04348 04349 if (!q) 04350 return NULL; 04351 04352 mem_iter = ao2_iterator_init(q->members, 0); 04353 while ((mem = ao2_iterator_next(&mem_iter))) { 04354 if (!strcasecmp(interface, mem->interface)) { 04355 ao2_iterator_destroy(&mem_iter); 04356 return mem; 04357 } 04358 ao2_ref(mem, -1); 04359 } 04360 ao2_iterator_destroy(&mem_iter); 04361 04362 return NULL; 04363 }
| static int is_our_turn | ( | struct queue_ent * | qe | ) | [static] |
Check if we should start attempting to call queue members.
A simple process, really. Count the number of members who are available to take our call and then see if we are in a position in the queue at which a member could accept our call.
| [in] | qe | The caller who wants to know if it is his turn |
| 0 | It is not our turn | |
| 1 | It is our turn |
Definition at line 3131 of file app_queue.c.
References ao2_lock(), ao2_unlock(), ast_debug, call_queue::autofill, queue_ent::chan, call_queue::head, ast_channel::name, queue_ent::next, num_available_members(), queue_ent::parent, queue_ent::pending, and queue_ent::pos.
Referenced by queue_exec(), and wait_our_turn().
03132 { 03133 struct queue_ent *ch; 03134 int res; 03135 int avl; 03136 int idx = 0; 03137 /* This needs a lock. How many members are available to be served? */ 03138 ao2_lock(qe->parent); 03139 03140 avl = num_available_members(qe->parent); 03141 03142 ch = qe->parent->head; 03143 03144 ast_debug(1, "There %s %d available %s.\n", avl != 1 ? "are" : "is", avl, avl != 1 ? "members" : "member"); 03145 03146 while ((idx < avl) && (ch) && (ch != qe)) { 03147 if (!ch->pending) 03148 idx++; 03149 ch = ch->next; 03150 } 03151 03152 ao2_unlock(qe->parent); 03153 /* If the queue entry is within avl [the number of available members] calls from the top ... 03154 * Autofill and position check added to support autofill=no (as only calls 03155 * from the front of the queue are valid when autofill is disabled) 03156 */ 03157 if (ch && idx < avl && (qe->parent->autofill || qe->pos == 1)) { 03158 ast_debug(1, "It's our turn (%s).\n", qe->chan->name); 03159 res = 1; 03160 } else { 03161 ast_debug(1, "It's not our turn (%s).\n", qe->chan->name); 03162 res = 0; 03163 } 03164 03165 return res; 03166 }
| static int join_queue | ( | char * | queuename, | |
| struct queue_ent * | qe, | |||
| enum queue_result * | reason | |||
| ) | [static] |
Definition at line 1963 of file app_queue.c.
References call_queue::announce, queue_ent::announce, ao2_lock(), ao2_unlock(), ast_copy_string(), ast_debug, queue_ent::chan, ast_channel::cid, ast_callerid::cid_name, ast_callerid::cid_num, call_queue::context, queue_ent::context, call_queue::count, EVENT_FLAG_CALL, get_member_status(), call_queue::head, insert_entry(), call_queue::joinempty, load_realtime_queue(), manager_event, queue_ent::max_penalty, call_queue::maxlen, queue_ent::min_penalty, call_queue::moh, queue_ent::moh, call_queue::name, ast_channel::name, queue_ent::next, queue_ent::pos, queue_ent::prio, QUEUE_FULL, QUEUE_JOINEMPTY, QUEUE_UNKNOWN, queues, S_OR, status, and ast_channel::uniqueid.
Referenced by queue_exec().
01964 { 01965 struct call_queue *q; 01966 struct queue_ent *cur, *prev = NULL; 01967 int res = -1; 01968 int pos = 0; 01969 int inserted = 0; 01970 01971 if (!(q = load_realtime_queue(queuename))) 01972 return res; 01973 01974 ao2_lock(queues); 01975 ao2_lock(q); 01976 01977 /* This is our one */ 01978 if (q->joinempty) { 01979 int status = 0; 01980 if ((status = get_member_status(q, qe->max_penalty, qe->min_penalty, q->joinempty))) { 01981 *reason = QUEUE_JOINEMPTY; 01982 ao2_unlock(q); 01983 ao2_unlock(queues); 01984 return res; 01985 } 01986 } 01987 if (*reason == QUEUE_UNKNOWN && q->maxlen && (q->count >= q->maxlen)) 01988 *reason = QUEUE_FULL; 01989 else if (*reason == QUEUE_UNKNOWN) { 01990 /* There's space for us, put us at the right position inside 01991 * the queue. 01992 * Take into account the priority of the calling user */ 01993 inserted = 0; 01994 prev = NULL; 01995 cur = q->head; 01996 while (cur) { 01997 /* We have higher priority than the current user, enter 01998 * before him, after all the other users with priority 01999 * higher or equal to our priority. */ 02000 if ((!inserted) && (qe->prio > cur->prio)) { 02001 insert_entry(q, prev, qe, &pos); 02002 inserted = 1; 02003 } 02004 cur->pos = ++pos; 02005 prev = cur; 02006 cur = cur->next; 02007 } 02008 /* No luck, join at the end of the queue */ 02009 if (!inserted) 02010 insert_entry(q, prev, qe, &pos); 02011 ast_copy_string(qe->moh, q->moh, sizeof(qe->moh)); 02012 ast_copy_string(qe->announce, q->announce, sizeof(qe->announce)); 02013 ast_copy_string(qe->context, q->context, sizeof(qe->context)); 02014 q->count++; 02015 res = 0; 02016 manager_event(EVENT_FLAG_CALL, "Join", 02017 "Channel: %s\r\nCallerIDNum: %s\r\nCallerIDName: %s\r\nQueue: %s\r\nPosition: %d\r\nCount: %d\r\nUniqueid: %s\r\n", 02018 qe->chan->name, 02019 S_OR(qe->chan->cid.cid_num, "unknown"), /* XXX somewhere else it is <unknown> */ 02020 S_OR(qe->chan->cid.cid_name, "unknown"), 02021 q->name, qe->pos, q->count, qe->chan->uniqueid ); 02022 ast_debug(1, "Queue '%s' Join, Channel '%s', Position '%d'\n", q->name, qe->chan->name, qe->pos ); 02023 } 02024 ao2_unlock(q); 02025 ao2_unlock(queues); 02026 02027 return res; 02028 }
| static int kill_dead_members | ( | void * | obj, | |
| void * | arg, | |||
| int | flags | |||
| ) | [static] |
Definition at line 5804 of file app_queue.c.
References CMP_MATCH, member::delme, member::dynamic, call_queue::membercount, member::state_interface, and member::status.
Referenced by reload_single_queue().
05805 { 05806 struct member *member = obj; 05807 struct call_queue *q = arg; 05808 05809 if (!member->delme) { 05810 if (member->dynamic) { 05811 /* dynamic members were not counted toward the member count 05812 * when reloading members from queues.conf, so we do that here 05813 */ 05814 q->membercount++; 05815 } 05816 member->status = ast_device_state(member->state_interface); 05817 return 0; 05818 } else { 05819 q->membercount--; 05820 return CMP_MATCH; 05821 } 05822 }
| static int kill_dead_queues | ( | void * | obj, | |
| void * | arg, | |||
| int | flags | |||
| ) | [static] |
Definition at line 5942 of file app_queue.c.
References ast_strlen_zero(), CMP_MATCH, call_queue::dead, and call_queue::name.
Referenced by reload_queues().
05943 { 05944 struct call_queue *q = obj; 05945 char *queuename = arg; 05946 if ((ast_strlen_zero(queuename) || !strcasecmp(queuename, q->name)) && q->dead) { 05947 return CMP_MATCH; 05948 } else { 05949 return 0; 05950 } 05951 }
| static void leave_queue | ( | struct queue_ent * | qe | ) | [static] |
Caller leaving queue.
Search the queue to find the leaving client, if found remove from queue create manager event, move others up the queue.
Definition at line 2254 of file app_queue.c.
References ao2_lock(), ao2_unlock(), ast_debug, ast_free, AST_LIST_REMOVE_HEAD, ast_load_realtime(), ast_variables_destroy(), queue_ent::chan, call_queue::count, call_queue::dead, EVENT_FLAG_CALL, call_queue::head, manager_event, call_queue::name, ast_channel::name, queue_ent::next, queue_ent::parent, queue_ent::pos, queue_ent::qe_rules, queue_t_ref, queue_t_unref, queues, queues_t_unlink, call_queue::realtime, SENTINEL, ast_channel::uniqueid, and var.
Referenced by queue_exec(), try_calling(), and wait_our_turn().
02255 { 02256 struct call_queue *q; 02257 struct queue_ent *current, *prev = NULL; 02258 struct penalty_rule *pr_iter; 02259 int pos = 0; 02260 02261 if (!(q = qe->parent)) 02262 return; 02263 queue_t_ref(q, "Copy queue pointer from queue entry"); 02264 ao2_lock(q); 02265 02266 prev = NULL; 02267 for (current = q->head; current; current = current->next) { 02268 if (current == qe) { 02269 q->count--; 02270 02271 /* Take us out of the queue */ 02272 manager_event(EVENT_FLAG_CALL, "Leave", 02273 "Channel: %s\r\nQueue: %s\r\nCount: %d\r\nUniqueid: %s\r\n", 02274 qe->chan->name, q->name, q->count, qe->chan->uniqueid); 02275 ast_debug(1, "Queue '%s' Leave, Channel '%s'\n", q->name, qe->chan->name ); 02276 /* Take us out of the queue */ 02277 if (prev) 02278 prev->next = current->next; 02279 else 02280 q->head = current->next; 02281 /* Free penalty rules */ 02282 while ((pr_iter = AST_LIST_REMOVE_HEAD(&qe->qe_rules, list))) 02283 ast_free(pr_iter); 02284 } else { 02285 /* Renumber the people after us in the queue based on a new count */ 02286 current->pos = ++pos; 02287 prev = current; 02288 } 02289 } 02290 ao2_unlock(q); 02291 02292 /*If the queue is a realtime queue, check to see if it's still defined in real time*/ 02293 if (q->realtime) { 02294 struct ast_variable *var; 02295 if (!(var = ast_load_realtime("queues", "name", q->name, SENTINEL))) { 02296 q->dead = 1; 02297 } else { 02298 ast_variables_destroy(var); 02299 } 02300 } 02301 02302 if (q->dead) { 02303 /* It's dead and nobody is in it, so kill it */ 02304 queues_t_unlink(queues, q, "Queue is now dead; remove it from the container"); 02305 } 02306 /* unref the explicit ref earlier in the function */ 02307 queue_t_unref(q, "Expire copied reference"); 02308 }
| static int load_module | ( | void | ) | [static] |
Definition at line 7221 of file app_queue.c.
References ao2_container_alloc, aqm_exec(), ARRAY_LEN, ast_add_extension2(), ast_cli_register_multiple(), ast_context_find_or_create(), ast_custom_function_register, AST_EVENT_DEVICE_STATE, AST_EVENT_IE_END, ast_event_subscribe(), AST_FLAGS_ALL, ast_free_ptr, ast_log(), ast_manager_register, AST_MODULE_LOAD_DECLINE, ast_realtime_require_field(), ast_register_application_xml, ast_strdup, ast_taskprocessor_get(), cli_queue, device_state_cb(), EVENT_FLAG_AGENT, LOG_ERROR, LOG_WARNING, manager_add_queue_member(), manager_pause_queue_member(), manager_queue_log_custom(), manager_queue_member_penalty(), manager_queue_reload(), manager_queue_reset(), manager_queue_rule_show(), manager_queues_show(), manager_queues_status(), manager_queues_summary(), manager_remove_queue_member(), MAX_QUEUE_BUCKETS, pqm_exec(), ql_exec(), queue_cmp_cb(), queue_exec(), queue_hash_cb(), queuemembercount_dep, queuemembercount_function, queuememberlist_function, queuememberpenalty_function, queues, queuevar_function, queuewaitingcount_function, reload_handler(), reload_queue_members(), RQ_INTEGER1, RQ_UINTEGER2, rqm_exec(), SENTINEL, and upqm_exec().
07222 { 07223 int res; 07224 struct ast_context *con; 07225 struct ast_flags mask = {AST_FLAGS_ALL, }; 07226 07227 queues = ao2_container_alloc(MAX_QUEUE_BUCKETS, queue_hash_cb, queue_cmp_cb); 07228 07229 use_weight = 0; 07230 07231 if (reload_handler(0, &mask, NULL)) 07232 return AST_MODULE_LOAD_DECLINE; 07233 07234 con = ast_context_find_or_create(NULL, NULL, "app_queue_gosub_virtual_context", "app_queue"); 07235 if (!con) 07236 ast_log(LOG_ERROR, "Queue virtual context 'app_queue_gosub_virtual_context' does not exist and unable to create\n"); 07237 else 07238 ast_add_extension2(con, 1, "s", 1, NULL, NULL, "NoOp", ast_strdup(""), ast_free_ptr, "app_queue"); 07239 07240 if (queue_persistent_members) 07241 reload_queue_members(); 07242 07243 ast_cli_register_multiple(cli_queue, ARRAY_LEN(cli_queue)); 07244 res = ast_register_application_xml(app, queue_exec); 07245 res |= ast_register_application_xml(app_aqm, aqm_exec); 07246 res |= ast_register_application_xml(app_rqm, rqm_exec); 07247 res |= ast_register_application_xml(app_pqm, pqm_exec); 07248 res |= ast_register_application_xml(app_upqm, upqm_exec); 07249 res |= ast_register_application_xml(app_ql, ql_exec); 07250 res |= ast_manager_register("Queues", 0, manager_queues_show, "Queues"); 07251 res |= ast_manager_register("QueueStatus", 0, manager_queues_status, "Queue Status"); 07252 res |= ast_manager_register("QueueSummary", 0, manager_queues_summary, "Queue Summary"); 07253 res |= ast_manager_register("QueueAdd", EVENT_FLAG_AGENT, manager_add_queue_member, "Add interface to queue."); 07254 res |= ast_manager_register("QueueRemove", EVENT_FLAG_AGENT, manager_remove_queue_member, "Remove interface from queue."); 07255 res |= ast_manager_register("QueuePause", EVENT_FLAG_AGENT, manager_pause_queue_member, "Makes a queue member temporarily unavailable"); 07256 res |= ast_manager_register("QueueLog", EVENT_FLAG_AGENT, manager_queue_log_custom, "Adds custom entry in queue_log"); 07257 res |= ast_manager_register("QueuePenalty", EVENT_FLAG_AGENT, manager_queue_member_penalty, "Set the penalty for a queue member"); 07258 res |= ast_manager_register("QueueRule", 0, manager_queue_rule_show, "Queue Rules"); 07259 res |= ast_manager_register("QueueReload", 0, manager_queue_reload, "Reload a queue, queues, or any sub-section of a queue or queues"); 07260 res |= ast_manager_register("QueueReset", 0, manager_queue_reset, "Reset queue statistics"); 07261 res |= ast_custom_function_register(&queuevar_function); 07262 res |= ast_custom_function_register(&queuemembercount_function); 07263 res |= ast_custom_function_register(&queuemembercount_dep); 07264 res |= ast_custom_function_register(&queuememberlist_function); 07265 res |= ast_custom_function_register(&queuewaitingcount_function); 07266 res |= ast_custom_function_register(&queuememberpenalty_function); 07267 07268 if (!(devicestate_tps = ast_taskprocessor_get("app_queue", 0))) { 07269 ast_log(LOG_WARNING, "devicestate taskprocessor reference failed - devicestate notifications will not occur\n"); 07270 } 07271 07272 if (!(device_state_sub = ast_event_subscribe(AST_EVENT_DEVICE_STATE, device_state_cb, NULL, AST_EVENT_IE_END))) { 07273 res = -1; 07274 } 07275 07276 ast_realtime_require_field("queue_members", "paused", RQ_INTEGER1, 1, "uniqueid", RQ_UINTEGER2, 5, SENTINEL); 07277 07278 return res ? AST_MODULE_LOAD_DECLINE : 0; 07279 }
| static struct call_queue* load_realtime_queue | ( | const char * | queuename | ) | [static, read] |
Definition at line 1838 of file app_queue.c.
References ao2_lock(), ao2_t_find, ao2_unlock(), ast_atomic_fetchadd_int(), ast_config_destroy(), ast_copy_string(), ast_load_realtime(), ast_load_realtime_multientry(), ast_log(), ast_variables_destroy(), find_queue_by_name_rt(), LOG_ERROR, OBJ_POINTER, queues, call_queue::realtime, SENTINEL, update_realtime_members(), and call_queue::weight.
Referenced by __queues_show(), add_to_queue(), join_queue(), queue_function_qac(), queue_function_qac_dep(), and reload_queue_members().
01839 { 01840 struct ast_variable *queue_vars; 01841 struct ast_config *member_config = NULL; 01842 struct call_queue *q = NULL, tmpq; 01843 int prev_weight = 0; 01844 01845 /* Find the queue in the in-core list first. */ 01846 ast_copy_string(tmpq.name, queuename, sizeof(tmpq.name)); 01847 q = ao2_t_find(queues, &tmpq, OBJ_POINTER, "Look for queue in memory first"); 01848 01849 if (!q || q->realtime) { 01850 /*! \note Load from realtime before taking the "queues" container lock, to avoid blocking all 01851 queue operations while waiting for the DB. 01852 01853 This will be two separate database transactions, so we might 01854 see queue parameters as they were before another process 01855 changed the queue and member list as it was after the change. 01856 Thus we might see an empty member list when a queue is 01857 deleted. In practise, this is unlikely to cause a problem. */ 01858 01859 queue_vars = ast_load_realtime("queues", "name", queuename, SENTINEL); 01860 if (queue_vars) { 01861 member_config = ast_load_realtime_multientry("queue_members", "interface LIKE", "%", "queue_name", queuename, SENTINEL); 01862 if (!member_config) { 01863 ast_log(LOG_ERROR, "no queue_members defined in your config (extconfig.conf).\n"); 01864 ast_variables_destroy(queue_vars); 01865 return NULL; 01866 } 01867 } 01868 if (q) { 01869 prev_weight = q->weight ? 1 : 0; 01870 } 01871 01872 ao2_lock(queues); 01873 01874 q = find_queue_by_name_rt(queuename, queue_vars, member_config); 01875 if (member_config) { 01876 ast_config_destroy(member_config); 01877 } 01878 if (queue_vars) { 01879 ast_variables_destroy(queue_vars); 01880 } 01881 /* update the use_weight value if the queue's has gained or lost a weight */ 01882 if (q) { 01883 if (!q->weight && prev_weight) { 01884 ast_atomic_fetchadd_int(&use_weight, -1); 01885 } 01886 if (q->weight && !prev_weight) { 01887 ast_atomic_fetchadd_int(&use_weight, +1); 01888 } 01889 } 01890 /* Other cases will end up with the proper value for use_weight */ 01891 ao2_unlock(queues); 01892 01893 } else { 01894 update_realtime_members(q); 01895 } 01896 return q; 01897 }
| static int manager_add_queue_member | ( | struct mansession * | s, | |
| const struct message * | m | |||
| ) | [static] |
Definition at line 6467 of file app_queue.c.
References add_to_queue(), ast_queue_log(), ast_strlen_zero(), ast_true(), astman_get_header(), astman_send_ack(), astman_send_error(), RES_EXISTS, RES_NOSUCHQUEUE, RES_OKAY, and RES_OUTOFMEMORY.
Referenced by load_module().
06468 { 06469 const char *queuename, *interface, *penalty_s, *paused_s, *membername, *state_interface; 06470 int paused, penalty = 0; 06471 06472 queuename = astman_get_header(m, "Queue"); 06473 interface = astman_get_header(m, "Interface"); 06474 penalty_s = astman_get_header(m, "Penalty"); 06475 paused_s = astman_get_header(m, "Paused"); 06476 membername = astman_get_header(m, "MemberName"); 06477 state_interface = astman_get_header(m, "StateInterface"); 06478 06479 if (ast_strlen_zero(queuename)) { 06480 astman_send_error(s, m, "'Queue' not specified."); 06481 return 0; 06482 } 06483 06484 if (ast_strlen_zero(interface)) { 06485 astman_send_error(s, m, "'Interface' not specified."); 06486 return 0; 06487 } 06488 06489 if (ast_strlen_zero(penalty_s)) 06490 penalty = 0; 06491 else if (sscanf(penalty_s, "%30d", &penalty) != 1 || penalty < 0) 06492 penalty = 0; 06493 06494 if (ast_strlen_zero(paused_s)) 06495 paused = 0; 06496 else 06497 paused = abs(ast_true(paused_s)); 06498 06499 switch (add_to_queue(queuename, interface, membername, penalty, paused, queue_persistent_members, state_interface)) { 06500 case RES_OKAY: 06501 ast_queue_log(queuename, "MANAGER", interface, "ADDMEMBER", "%s", ""); 06502 astman_send_ack(s, m, "Added interface to queue"); 06503 break; 06504 case RES_EXISTS: 06505 astman_send_error(s, m, "Unable to add interface: Already there"); 06506 break; 06507 case RES_NOSUCHQUEUE: 06508 astman_send_error(s, m, "Unable to add interface to queue: No such queue"); 06509 break; 06510 case RES_OUTOFMEMORY: 06511 astman_send_error(s, m, "Out of memory"); 06512 break; 06513 } 06514 06515 return 0; 06516 }
| static int manager_pause_queue_member | ( | struct mansession * | s, | |
| const struct message * | m | |||
| ) | [static] |
Definition at line 6552 of file app_queue.c.
References ast_strlen_zero(), ast_true(), astman_get_header(), astman_send_ack(), astman_send_error(), and set_member_paused().
Referenced by load_module().
06553 { 06554 const char *queuename, *interface, *paused_s, *reason; 06555 int paused; 06556 06557 interface = astman_get_header(m, "Interface"); 06558 paused_s = astman_get_header(m, "Paused"); 06559 queuename = astman_get_header(m, "Queue"); /* Optional - if not supplied, pause the given Interface in all queues */ 06560 reason = astman_get_header(m, "Reason"); /* Optional - Only used for logging purposes */ 06561 06562 if (ast_strlen_zero(interface) || ast_strlen_zero(paused_s)) { 06563 astman_send_error(s, m, "Need 'Interface' and 'Paused' parameters."); 06564 return 0; 06565 } 06566 06567 paused = abs(ast_true(paused_s)); 06568 06569 if (set_member_paused(queuename, interface, reason, paused)) 06570 astman_send_error(s, m, "Interface not found"); 06571 else 06572 astman_send_ack(s, m, paused ? "Interface paused successfully" : "Interface unpaused successfully"); 06573 return 0; 06574 }
| static int manager_queue_log_custom | ( | struct mansession * | s, | |
| const struct message * | m | |||
| ) | [static] |
Definition at line 6576 of file app_queue.c.
References ast_queue_log(), ast_strlen_zero(), astman_get_header(), astman_send_ack(), astman_send_error(), and S_OR.
Referenced by load_module().
06577 { 06578 const char *queuename, *event, *message, *interface, *uniqueid; 06579 06580 queuename = astman_get_header(m, "Queue"); 06581 uniqueid = astman_get_header(m, "UniqueId"); 06582 interface = astman_get_header(m, "Interface"); 06583 event = astman_get_header(m, "Event"); 06584 message = astman_get_header(m, "Message"); 06585 06586 if (ast_strlen_zero(queuename) || ast_strlen_zero(event)) { 06587 astman_send_error(s, m, "Need 'Queue' and 'Event' parameters."); 06588 return 0; 06589 } 06590 06591 ast_queue_log(queuename, S_OR(uniqueid, "NONE"), interface, event, "%s", message); 06592 astman_send_ack(s, m, "Event added successfully"); 06593 06594 return 0; 06595 }
| static int manager_queue_member_penalty | ( | struct mansession * | s, | |
| const struct message * | m | |||
| ) | [static] |
Definition at line 6675 of file app_queue.c.
References ast_strlen_zero(), astman_get_header(), astman_send_ack(), astman_send_error(), and set_member_penalty().
Referenced by load_module().
06676 { 06677 const char *queuename, *interface, *penalty_s; 06678 int penalty; 06679 06680 interface = astman_get_header(m, "Interface"); 06681 penalty_s = astman_get_header(m, "Penalty"); 06682 /* Optional - if not supplied, set the penalty value for the given Interface in all queues */ 06683 queuename = astman_get_header(m, "Queue"); 06684 06685 if (ast_strlen_zero(interface) || ast_strlen_zero(penalty_s)) { 06686 astman_send_error(s, m, "Need 'Interface' and 'Penalty' parameters."); 06687 return 0; 06688 } 06689 06690 penalty = atoi(penalty_s); 06691 06692 if (set_member_penalty((char *)queuename, (char *)interface, penalty)) 06693 astman_send_error(s, m, "Invalid interface, queuename or penalty"); 06694 else 06695 astman_send_ack(s, m, "Interface penalty set successfully"); 06696 06697 return 0; 06698 }
| static int manager_queue_reload | ( | struct mansession * | s, | |
| const struct message * | m | |||
| ) | [static] |
Definition at line 6597 of file app_queue.c.
References AST_FLAGS_ALL, ast_set_flag, astman_get_header(), astman_send_ack(), astman_send_error(), QUEUE_RELOAD_MEMBER, QUEUE_RELOAD_PARAMETERS, QUEUE_RELOAD_RULES, reload_handler(), and S_OR.
Referenced by load_module().
06598 { 06599 struct ast_flags mask = {0,}; 06600 const char *queuename = NULL; 06601 int header_found = 0; 06602 06603 queuename = astman_get_header(m, "Queue"); 06604 if (!strcasecmp(S_OR(astman_get_header(m, "Members"), ""), "yes")) { 06605 ast_set_flag(&mask, QUEUE_RELOAD_MEMBER); 06606 header_found = 1; 06607 } 06608 if (!strcasecmp(S_OR(astman_get_header(m, "Rules"), ""), "yes")) { 06609 ast_set_flag(&mask, QUEUE_RELOAD_RULES); 06610 header_found = 1; 06611 } 06612 if (!strcasecmp(S_OR(astman_get_header(m, "Parameters"), ""), "yes")) { 06613 ast_set_flag(&mask, QUEUE_RELOAD_PARAMETERS); 06614 header_found = 1; 06615 } 06616 06617 if (!header_found) { 06618 ast_set_flag(&mask, AST_FLAGS_ALL); 06619 } 06620 06621 if (!reload_handler(1, &mask, queuename)) { 06622 astman_send_ack(s, m, "Queue reloaded successfully"); 06623 } else { 06624 astman_send_error(s, m, "Error encountered while reloading queue"); 06625 } 06626 return 0; 06627 }
| static int manager_queue_reset | ( | struct mansession * | s, | |
| const struct message * | m | |||
| ) | [static] |
Definition at line 6629 of file app_queue.c.
References astman_get_header(), astman_send_ack(), astman_send_error(), QUEUE_RESET_STATS, and reload_handler().
Referenced by load_module().
06630 { 06631 const char *queuename = NULL; 06632 struct ast_flags mask = {QUEUE_RESET_STATS,}; 06633 06634 queuename = astman_get_header(m, "Queue"); 06635 06636 if (!reload_handler(1, &mask, queuename)) { 06637 astman_send_ack(s, m, "Queue stats reset successfully"); 06638 } else { 06639 astman_send_error(s, m, "Error encountered while resetting queue stats"); 06640 } 06641 return 0; 06642 }
| static int manager_queue_rule_show | ( | struct mansession * | s, | |
| const struct message * | m | |||
| ) | [static] |
Definition at line 6270 of file app_queue.c.
References AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_strlen_zero(), astman_append(), astman_get_header(), penalty_rule::max_relative, penalty_rule::max_value, penalty_rule::min_relative, penalty_rule::min_value, rule_list::name, RESULT_SUCCESS, rule_list::rules, and penalty_rule::time.
Referenced by load_module().
06271 { 06272 const char *rule = astman_get_header(m, "Rule"); 06273 struct rule_list *rl_iter; 06274 struct penalty_rule *pr_iter; 06275 06276 AST_LIST_LOCK(&rule_lists); 06277 AST_LIST_TRAVERSE(&rule_lists, rl_iter, list) { 06278 if (ast_strlen_zero(rule) || !strcasecmp(rule, rl_iter->name)) { 06279 astman_append(s, "RuleList: %s\r\n", rl_iter->name); 06280 AST_LIST_TRAVERSE(&rl_iter->rules, pr_iter, list) { 06281 astman_append(s, "Rule: %d,%s%d,%s%d\r\n", pr_iter->time, pr_iter->max_relative && pr_iter->max_value >= 0 ? "+" : "", pr_iter->max_value, pr_iter->min_relative && pr_iter->min_value >= 0 ? "+" : "", pr_iter->min_value ); 06282 } 06283 if (!ast_strlen_zero(rule)) 06284 break; 06285 } 06286 } 06287 AST_LIST_UNLOCK(&rule_lists); 06288 06289 astman_append(s, "\r\n\r\n"); 06290 06291 return RESULT_SUCCESS; 06292 }
| static int manager_queues_show | ( | struct mansession * | s, | |
| const struct message * | m | |||
| ) | [static] |
Definition at line 6260 of file app_queue.c.
References __queues_show(), astman_append(), and RESULT_SUCCESS.
Referenced by load_module().
06261 { 06262 char *a[] = { "queue", "show" }; 06263 06264 __queues_show(s, -1, 2, a); 06265 astman_append(s, "\r\n\r\n"); /* Properly terminate Manager output */ 06266 06267 return RESULT_SUCCESS; 06268 }
| static int manager_queues_status | ( | struct mansession * | s, | |
| const struct message * | m | |||
| ) | [static] |
Queue status info via AMI.
Definition at line 6370 of file app_queue.c.
References ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_lock(), ao2_ref, ao2_t_iterator_next, ao2_unlock(), ast_strlen_zero(), astman_append(), astman_get_header(), astman_send_ack(), member::calls, call_queue::callsabandoned, call_queue::callscompleted, call_queue::callscompletedinsl, queue_ent::chan, ast_channel::cid, ast_callerid::cid_name, ast_callerid::cid_num, call_queue::count, member::dynamic, call_queue::head, call_queue::holdtime, int2strat(), member::interface, member::lastcall, call_queue::maxlen, member::membername, call_queue::members, ast_channel::name, call_queue::name, queue_ent::next, member::paused, member::penalty, queue_ent::pos, queue_t_unref, queues, RESULT_SUCCESS, S_OR, call_queue::servicelevel, queue_ent::start, member::status, call_queue::strategy, call_queue::talktime, ast_channel::uniqueid, and call_queue::weight.
Referenced by load_module().
06371 { 06372 time_t now; 06373 int pos; 06374 const char *id = astman_get_header(m,"ActionID"); 06375 const char *queuefilter = astman_get_header(m,"Queue"); 06376 const char *memberfilter = astman_get_header(m,"Member"); 06377 char idText[256] = ""; 06378 struct call_queue *q; 06379 struct queue_ent *qe; 06380 float sl = 0; 06381 struct member *mem; 06382 struct ao2_iterator queue_iter; 06383 struct ao2_iterator mem_iter; 06384 06385 astman_send_ack(s, m, "Queue status will follow"); 06386 time(&now); 06387 if (!ast_strlen_zero(id)) 06388 snprintf(idText, sizeof(idText), "ActionID: %s\r\n", id); 06389 06390 queue_iter = ao2_iterator_init(queues, 0); 06391 while ((q = ao2_t_iterator_next(&queue_iter, "Iterate through queues"))) { 06392 ao2_lock(q); 06393 06394 /* List queue properties */ 06395 if (ast_strlen_zero(queuefilter) || !strcmp(q->name, queuefilter)) { 06396 sl = ((q->callscompleted > 0) ? 100 * ((float)q->callscompletedinsl / (float)q->callscompleted) : 0); 06397 astman_append(s, "Event: QueueParams\r\n" 06398 "Queue: %s\r\n" 06399 "Max: %d\r\n" 06400 "Strategy: %s\r\n" 06401 "Calls: %d\r\n" 06402 "Holdtime: %d\r\n" 06403 "TalkTime: %d\r\n" 06404 "Completed: %d\r\n" 06405 "Abandoned: %d\r\n" 06406 "ServiceLevel: %d\r\n" 06407 "ServicelevelPerf: %2.1f\r\n" 06408 "Weight: %d\r\n" 06409 "%s" 06410 "\r\n", 06411 q->name, q->maxlen, int2strat(q->strategy), q->count, q->holdtime, q->talktime, q->callscompleted, 06412 q->callsabandoned, q->servicelevel, sl, q->weight, idText); 06413 /* List Queue Members */ 06414 mem_iter = ao2_iterator_init(q->members, 0); 06415 while ((mem = ao2_iterator_next(&mem_iter))) { 06416 if (ast_strlen_zero(memberfilter) || !strcmp(mem->interface, memberfilter) || !strcmp(mem->membername, memberfilter)) { 06417 astman_append(s, "Event: QueueMember\r\n" 06418 "Queue: %s\r\n" 06419 "Name: %s\r\n" 06420 "Location: %s\r\n" 06421 "Membership: %s\r\n" 06422 "Penalty: %d\r\n" 06423 "CallsTaken: %d\r\n" 06424 "LastCall: %d\r\n" 06425 "Status: %d\r\n" 06426 "Paused: %d\r\n" 06427 "%s" 06428 "\r\n", 06429 q->name, mem->membername, mem->interface, mem->dynamic ? "dynamic" : "static", 06430 mem->penalty, mem->calls, (int)mem->lastcall, mem->status, mem->paused, idText); 06431 } 06432 ao2_ref(mem, -1); 06433 } 06434 ao2_iterator_destroy(&mem_iter); 06435 /* List Queue Entries */ 06436 pos = 1; 06437 for (qe = q->head; qe; qe = qe->next) { 06438 astman_append(s, "Event: QueueEntry\r\n" 06439 "Queue: %s\r\n" 06440 "Position: %d\r\n" 06441 "Channel: %s\r\n" 06442 "Uniqueid: %s\r\n" 06443 "CallerIDNum: %s\r\n" 06444 "CallerIDName: %s\r\n" 06445 "Wait: %ld\r\n" 06446 "%s" 06447 "\r\n", 06448 q->name, pos++, qe->chan->name, qe->chan->uniqueid, 06449 S_OR(qe->chan->cid.cid_num, "unknown"), 06450 S_OR(qe->chan->cid.cid_name, "unknown"), 06451 (long) (now - qe->start), idText); 06452 } 06453 } 06454 ao2_unlock(q); 06455 queue_t_unref(q, "Done with iterator"); 06456 } 06457 ao2_iterator_destroy(&queue_iter); 06458 06459 astman_append(s, 06460 "Event: QueueStatusComplete\r\n" 06461 "%s" 06462 "\r\n",idText); 06463 06464 return RESULT_SUCCESS; 06465 }
| static int manager_queues_summary | ( | struct mansession * | s, | |
| const struct message * | m | |||
| ) | [static] |
Summary of queue info via the AMI.
Definition at line 6295 of file app_queue.c.
References ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_lock(), ao2_ref, ao2_t_iterator_next, ao2_unlock(), AST_DEVICE_INVALID, AST_DEVICE_NOT_INUSE, AST_DEVICE_UNAVAILABLE, AST_DEVICE_UNKNOWN, ast_strlen_zero(), astman_append(), astman_get_header(), astman_send_ack(), call_queue::head, call_queue::holdtime, call_queue::members, call_queue::name, queue_ent::next, member::paused, queue_t_unref, queues, RESULT_SUCCESS, queue_ent::start, member::status, and call_queue::talktime.
Referenced by load_module().
06296 { 06297 time_t now; 06298 int qmemcount = 0; 06299 int qmemavail = 0; 06300 int qchancount = 0; 06301 int qlongestholdtime = 0; 06302 const char *id = astman_get_header(m, "ActionID"); 06303 const char *queuefilter = astman_get_header(m, "Queue"); 06304 char idText[256] = ""; 06305 struct call_queue *q; 06306 struct queue_ent *qe; 06307 struct member *mem; 06308 struct ao2_iterator queue_iter; 06309 struct ao2_iterator mem_iter; 06310 06311 astman_send_ack(s, m, "Queue summary will follow"); 06312 time(&now); 06313 if (!ast_strlen_zero(id)) 06314 snprintf(idText, 256, "ActionID: %s\r\n", id); 06315 queue_iter = ao2_iterator_init(queues, 0); 06316 while ((q = ao2_t_iterator_next(&queue_iter, "Iterate through queues"))) { 06317 ao2_lock(q); 06318 06319 /* List queue properties */ 06320 if (ast_strlen_zero(queuefilter) || !strcmp(q->name, queuefilter)) { 06321 /* Reset the necessary local variables if no queuefilter is set*/ 06322 qmemcount = 0; 06323 qmemavail = 0; 06324 qchancount = 0; 06325 qlongestholdtime = 0; 06326 06327 /* List Queue Members */ 06328 mem_iter = ao2_iterator_init(q->members, 0); 06329 while ((mem = ao2_iterator_next(&mem_iter))) { 06330 if ((mem->status != AST_DEVICE_UNAVAILABLE) && (mem->status != AST_DEVICE_INVALID)) { 06331 ++qmemcount; 06332 if (((mem->status == AST_DEVICE_NOT_INUSE) || (mem->status == AST_DEVICE_UNKNOWN)) && !(mem->paused)) { 06333 ++qmemavail; 06334 } 06335 } 06336 ao2_ref(mem, -1); 06337 } 06338 ao2_iterator_destroy(&mem_iter); 06339 for (qe = q->head; qe; qe = qe->next) { 06340 if ((now - qe->start) > qlongestholdtime) { 06341 qlongestholdtime = now - qe->start; 06342 } 06343 ++qchancount; 06344 } 06345 astman_append(s, "Event: QueueSummary\r\n" 06346 "Queue: %s\r\n" 06347 "LoggedIn: %d\r\n" 06348 "Available: %d\r\n" 06349 "Callers: %d\r\n" 06350 "HoldTime: %d\r\n" 06351 "TalkTime: %d\r\n" 06352 "LongestHoldTime: %d\r\n" 06353 "%s" 06354 "\r\n", 06355 q->name, qmemcount, qmemavail, qchancount, q->holdtime, q->talktime, qlongestholdtime, idText); 06356 } 06357 ao2_unlock(q); 06358 queue_t_unref(q, "Done with iterator"); 06359 } 06360 ao2_iterator_destroy(&queue_iter); 06361 astman_append(s, 06362 "Event: QueueSummaryComplete\r\n" 06363 "%s" 06364 "\r\n", idText); 06365 06366 return RESULT_SUCCESS; 06367 }
| static int manager_remove_queue_member | ( | struct mansession * | s, | |
| const struct message * | m | |||
| ) | [static] |
Definition at line 6518 of file app_queue.c.
References ast_queue_log(), ast_strlen_zero(), astman_get_header(), astman_send_ack(), astman_send_error(), remove_from_queue(), RES_EXISTS, RES_NOSUCHQUEUE, RES_NOT_DYNAMIC, RES_OKAY, and RES_OUTOFMEMORY.
Referenced by load_module().
06519 { 06520 const char *queuename, *interface; 06521 06522 queuename = astman_get_header(m, "Queue"); 06523 interface = astman_get_header(m, "Interface"); 06524 06525 if (ast_strlen_zero(queuename) || ast_strlen_zero(interface)) { 06526 astman_send_error(s, m, "Need 'Queue' and 'Interface' parameters."); 06527 return 0; 06528 } 06529 06530 switch (remove_from_queue(queuename, interface)) { 06531 case RES_OKAY: 06532 ast_queue_log(queuename, "MANAGER", interface, "REMOVEMEMBER", "%s", ""); 06533 astman_send_ack(s, m, "Removed interface from queue"); 06534 break; 06535 case RES_EXISTS: 06536 astman_send_error(s, m, "Unable to remove interface: Not there"); 06537 break; 06538 case RES_NOSUCHQUEUE: 06539 astman_send_error(s, m, "Unable to remove interface from queue: No such queue"); 06540 break; 06541 case RES_OUTOFMEMORY: 06542 astman_send_error(s, m, "Out of memory"); 06543 break; 06544 case RES_NOT_DYNAMIC: 06545 astman_send_error(s, m, "Member not dynamic"); 06546 break; 06547 } 06548 06549 return 0; 06550 }
| static int mark_dead_and_unfound | ( | void * | obj, | |
| void * | arg, | |||
| int | flags | |||
| ) | [static] |
Definition at line 5931 of file app_queue.c.
References ast_strlen_zero(), call_queue::dead, call_queue::found, call_queue::name, and call_queue::realtime.
Referenced by reload_queues().
05932 { 05933 struct call_queue *q = obj; 05934 char *queuename = arg; 05935 if (!q->realtime && (ast_strlen_zero(queuename) || !strcasecmp(queuename, q->name))) { 05936 q->dead = 1; 05937 q->found = 0; 05938 } 05939 return 0; 05940 }
| static int mark_member_dead | ( | void * | obj, | |
| void * | arg, | |||
| int | flags | |||
| ) | [static] |
Definition at line 5795 of file app_queue.c.
References member::delme, and member::dynamic.
Referenced by reload_single_queue().
05796 { 05797 struct member *member = obj; 05798 if (!member->dynamic) { 05799 member->delme = 1; 05800 } 05801 return 0; 05802 }
| static int member_cmp_fn | ( | void * | obj1, | |
| void * | obj2, | |||
| int | flags | |||
| ) | [static] |
Definition at line 1172 of file app_queue.c.
References CMP_MATCH, CMP_STOP, and member::interface.
Referenced by init_queue().
01173 { 01174 struct member *mem1 = obj1, *mem2 = obj2; 01175 return strcasecmp(mem1->interface, mem2->interface) ? 0 : CMP_MATCH | CMP_STOP; 01176 }
| static int member_hash_fn | ( | const void * | obj, | |
| const int | flags | |||
| ) | [static] |
Definition at line 1160 of file app_queue.c.
References compress_char(), and member::interface.
Referenced by init_queue().
01161 { 01162 const struct member *mem = obj; 01163 const char *chname = strchr(mem->interface, '/'); 01164 int ret = 0, i; 01165 if (!chname) 01166 chname = mem->interface; 01167 for (i = 0; i < 5 && chname[i]; i++) 01168 ret += compress_char(chname[i]) << (i * 6); 01169 return ret; 01170 }
| static int num_available_members | ( | struct call_queue * | q | ) | [static] |
Get the number of members available to accept a call.
| [in] | q | The queue for which we are couting the number of available members |
Definition at line 2339 of file app_queue.c.
References ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_ref, AST_DEVICE_INUSE, AST_DEVICE_NOT_INUSE, AST_DEVICE_UNKNOWN, call_queue::autofill, call_queue::members, member::paused, QUEUE_STRATEGY_RINGALL, call_queue::ringinuse, member::status, and call_queue::strategy.
Referenced by compare_weight(), and is_our_turn().
02340 { 02341 struct member *mem; 02342 int avl = 0; 02343 struct ao2_iterator mem_iter; 02344 02345 mem_iter = ao2_iterator_init(q->members, 0); 02346 while ((mem = ao2_iterator_next(&mem_iter))) { 02347 switch (mem->status) { 02348 case AST_DEVICE_INUSE: 02349 if (!q->ringinuse) 02350 break; 02351 /* else fall through */ 02352 case AST_DEVICE_NOT_INUSE: 02353 case AST_DEVICE_UNKNOWN: 02354 if (!mem->paused) { 02355 avl++; 02356 } 02357 break; 02358 } 02359 ao2_ref(mem, -1); 02360 02361 /* If autofill is not enabled or if the queue's strategy is ringall, then 02362 * we really don't care about the number of available members so much as we 02363 * do that there is at least one available. 02364 * 02365 * In fact, we purposely will return from this function stating that only 02366 * one member is available if either of those conditions hold. That way, 02367 * functions which determine what action to take based on the number of available 02368 * members will operate properly. The reasoning is that even if multiple 02369 * members are available, only the head caller can actually be serviced. 02370 */ 02371 if ((!q->autofill || q->strategy == QUEUE_STRATEGY_RINGALL) && avl) { 02372 break; 02373 } 02374 } 02375 ao2_iterator_destroy(&mem_iter); 02376 02377 return avl; 02378 }
| static void parse_empty_options | ( | const char * | value, | |
| enum empty_conditions * | empty, | |||
| int | joinempty | |||
| ) | [static] |
Definition at line 1355 of file app_queue.c.
References ast_false(), ast_log(), ast_strdupa, ast_true(), LOG_WARNING, QUEUE_EMPTY_INUSE, QUEUE_EMPTY_INVALID, QUEUE_EMPTY_PAUSED, QUEUE_EMPTY_PENALTY, QUEUE_EMPTY_RINGING, QUEUE_EMPTY_UNAVAILABLE, QUEUE_EMPTY_UNKNOWN, QUEUE_EMPTY_WRAPUP, and strsep().
Referenced by queue_set_param().
01356 { 01357 char *value_copy = ast_strdupa(value); 01358 char *option = NULL; 01359 while ((option = strsep(&value_copy, ","))) { 01360 if (!strcasecmp(option, "paused")) { 01361 *empty |= QUEUE_EMPTY_PAUSED; 01362 } else if (!strcasecmp(option, "penalty")) { 01363 *empty |= QUEUE_EMPTY_PENALTY; 01364 } else if (!strcasecmp(option, "inuse")) { 01365 *empty |= QUEUE_EMPTY_INUSE; 01366 } else if (!strcasecmp(option, "ringing")) { 01367 *empty |= QUEUE_EMPTY_RINGING; 01368 } else if (!strcasecmp(option, "invalid")) { 01369 *empty |= QUEUE_EMPTY_INVALID; 01370 } else if (!strcasecmp(option, "wrapup")) { 01371 *empty |= QUEUE_EMPTY_WRAPUP; 01372 } else if (!strcasecmp(option, "unavailable")) { 01373 *empty |= QUEUE_EMPTY_UNAVAILABLE; 01374 } else if (!strcasecmp(option, "unknown")) { 01375 *empty |= QUEUE_EMPTY_UNKNOWN; 01376 } else if (!strcasecmp(option, "loose")) { 01377 *empty = (QUEUE_EMPTY_PENALTY | QUEUE_EMPTY_INVALID); 01378 } else if (!strcasecmp(option, "strict")) { 01379 *empty = (QUEUE_EMPTY_PENALTY | QUEUE_EMPTY_INVALID | QUEUE_EMPTY_PAUSED | QUEUE_EMPTY_UNAVAILABLE); 01380 } else if ((ast_false(option) && joinempty) || (ast_true(option) && !joinempty)) { 01381 *empty = (QUEUE_EMPTY_PENALTY | QUEUE_EMPTY_INVALID | QUEUE_EMPTY_PAUSED); 01382 } else if ((ast_false(option) && !joinempty) || (ast_true(option) && joinempty)) { 01383 *empty = 0; 01384 } else { 01385 ast_log(LOG_WARNING, "Unknown option %s for '%s'\n", option, joinempty ? "joinempty" : "leavewhenempty"); 01386 } 01387 } 01388 }
| static int play_file | ( | struct ast_channel * | chan, | |
| const char * | filename | |||
| ) | [static] |
Definition at line 2030 of file app_queue.c.
References AST_DIGIT_ANY, ast_fileexists(), ast_stopstream(), ast_streamfile(), ast_strlen_zero(), ast_waitstream(), and ast_channel::language.
Referenced by say_periodic_announcement(), say_position(), and try_calling().
02031 { 02032 int res; 02033 02034 if (ast_strlen_zero(filename)) { 02035 return 0; 02036 } 02037 02038 if (!ast_fileexists(filename, NULL, chan->language)) { 02039 return 0; 02040 } 02041 02042 ast_stopstream(chan); 02043 02044 res = ast_streamfile(chan, filename, chan->language); 02045 if (!res) 02046 res = ast_waitstream(chan, AST_DIGIT_ANY); 02047 02048 ast_stopstream(chan); 02049 02050 return res; 02051 }
| static int pqm_exec | ( | struct ast_channel * | chan, | |
| void * | data | |||
| ) | [static] |
PauseQueueMember application.
Definition at line 4775 of file app_queue.c.
References AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_log(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), LOG_WARNING, parse(), pbx_builtin_setvar_helper(), and set_member_paused().
Referenced by load_module().
04776 { 04777 char *parse; 04778 AST_DECLARE_APP_ARGS(args, 04779 AST_APP_ARG(queuename); 04780 AST_APP_ARG(interface); 04781 AST_APP_ARG(options); 04782 AST_APP_ARG(reason); 04783 ); 04784 04785 if (ast_strlen_zero(data)) { 04786 ast_log(LOG_WARNING, "PauseQueueMember requires an argument ([queuename],interface[,options][,reason])\n"); 04787 return -1; 04788 } 04789 04790 parse = ast_strdupa(data); 04791 04792 AST_STANDARD_APP_ARGS(args, parse); 04793 04794 if (ast_strlen_zero(args.interface)) { 04795 ast_log(LOG_WARNING, "Missing interface argument to PauseQueueMember ([queuename],interface[,options[,reason]])\n"); 04796 return -1; 04797 } 04798 04799 if (set_member_paused(args.queuename, args.interface, args.reason, 1)) { 04800 ast_log(LOG_WARNING, "Attempt to pause interface %s, not found\n", args.interface); 04801 pbx_builtin_setvar_helper(chan, "PQMSTATUS", "NOTFOUND"); 04802 return 0; 04803 } 04804 04805 pbx_builtin_setvar_helper(chan, "PQMSTATUS", "PAUSED"); 04806 04807 return 0; 04808 }
| static int ql_exec | ( | struct ast_channel * | chan, | |
| void * | data | |||
| ) | [static] |
QueueLog application.
Definition at line 4967 of file app_queue.c.
References AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_log(), ast_queue_log(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), LOG_WARNING, and parse().
Referenced by load_module().
04968 { 04969 char *parse; 04970 04971 AST_DECLARE_APP_ARGS(args, 04972 AST_APP_ARG(queuename); 04973 AST_APP_ARG(uniqueid); 04974 AST_APP_ARG(membername); 04975 AST_APP_ARG(event); 04976 AST_APP_ARG(params); 04977 ); 04978 04979 if (ast_strlen_zero(data)) { 04980 ast_log(LOG_WARNING, "QueueLog requires arguments (queuename,uniqueid,membername,event[,additionalinfo]\n"); 04981 return -1; 04982 } 04983 04984 parse = ast_strdupa(data); 04985 04986 AST_STANDARD_APP_ARGS(args, parse); 04987 04988 if (ast_strlen_zero(args.queuename) || ast_strlen_zero(args.uniqueid) 04989 || ast_strlen_zero(args.membername) || ast_strlen_zero(args.event)) { 04990 ast_log(LOG_WARNING, "QueueLog requires arguments (queuename,uniqueid,membername,event[,additionalinfo])\n"); 04991 return -1; 04992 } 04993 04994 ast_queue_log(args.queuename, args.uniqueid, args.membername, args.event, 04995 "%s", args.params ? args.params : ""); 04996 04997 return 0; 04998 }
| static int queue_cmp_cb | ( | void * | obj, | |
| void * | arg, | |||
| int | flags | |||
| ) | [static] |
Definition at line 868 of file app_queue.c.
References CMP_MATCH, CMP_STOP, and call_queue::name.
Referenced by load_module().
00869 { 00870 struct call_queue *q = obj, *q2 = arg; 00871 return !strcasecmp(q->name, q2->name) ? CMP_MATCH | CMP_STOP : 0; 00872 }
| static int queue_exec | ( | struct ast_channel * | chan, | |
| void * | data | |||
| ) | [static] |
The starting point for all queue calls.
The process involved here is to 1. Parse the options specified in the call to Queue() 2. Join the queue 3. Wait in a loop until it is our turn to try calling a queue member 4. Attempt to call a queue member 5. If 4. did not result in a bridged call, then check for between call options such as periodic announcements etc. 6. Try 4 again unless some condition (such as an expiration time) causes us to exit the queue.
Definition at line 5042 of file app_queue.c.
References call_queue::announcefrequency, AST_APP_ARG, ast_channel_lock, ast_channel_unlock, AST_CONTROL_RINGING, ast_debug, AST_DECLARE_APP_ARGS, ast_indicate(), AST_LIST_FIRST, ast_log(), ast_moh_start(), ast_moh_stop(), ast_queue_log(), AST_STANDARD_APP_ARGS, ast_stopstream(), ast_strdupa, ast_strlen_zero(), ast_verb, queue_ent::chan, ast_channel::cid, ast_callerid::cid_num, copy_rules(), queue_ent::digits, queue_ent::expire, get_member_status(), queue_ent::handled, is_our_turn(), join_queue(), queue_ent::last_periodic_announce_sound, queue_ent::last_periodic_announce_time, queue_ent::last_pos, queue_ent::last_pos_said, leave_queue(), call_queue::leavewhenempty, LOG_WARNING, queue_ent::max_penalty, call_queue::membercount, queue_ent::min_penalty, queue_ent::moh, call_queue::name, ast_channel::name, queue_ent::opos, queue_ent::parent, parse(), pbx_builtin_getvar_helper(), call_queue::periodicannouncefrequency, queue_ent::pos, queue_ent::pr, queue_ent::prio, queue_ent::qe_rules, QUEUE_CONTINUE, QUEUE_LEAVEEMPTY, QUEUE_TIMEOUT, QUEUE_UNKNOWN, queue_unref(), record_abandoned(), S_OR, say_periodic_announcement(), say_position(), set_queue_result(), set_queue_variables(), queue_ent::start, status, stop, penalty_rule::time, try_calling(), ast_channel::uniqueid, update_qe_rule(), update_realtime_members(), url, queue_ent::valid_digits, wait_a_bit(), and wait_our_turn().
Referenced by load_module().
05043 { 05044 int res=-1; 05045 int ringing=0; 05046 const char *user_priority; 05047 const char *max_penalty_str; 05048 const char *min_penalty_str; 05049 int prio; 05050 int qcontinue = 0; 05051 int max_penalty, min_penalty; 05052 enum queue_result reason = QUEUE_UNKNOWN; 05053 /* whether to exit Queue application after the timeout hits */ 05054 int tries = 0; 05055 int noption = 0; 05056 char *parse; 05057 int makeannouncement = 0; 05058 AST_DECLARE_APP_ARGS(args, 05059 AST_APP_ARG(queuename); 05060 AST_APP_ARG(options); 05061 AST_APP_ARG(url); 05062 AST_APP_ARG(announceoverride); 05063 AST_APP_ARG(queuetimeoutstr); 05064 AST_APP_ARG(agi); 05065 AST_APP_ARG(macro); 05066 AST_APP_ARG(gosub); 05067 AST_APP_ARG(rule); 05068 ); 05069 /* Our queue entry */ 05070 struct queue_ent qe = { 0 }; 05071 05072 if (ast_strlen_zero(data)) { 05073 ast_log(LOG_WARNING, "Queue requires an argument: queuename[,options[,URL[,announceoverride[,timeout[,agi[,macro[,gosub[,rule]]]]]]]]\n"); 05074 return -1; 05075 } 05076 05077 parse = ast_strdupa(data); 05078 AST_STANDARD_APP_ARGS(args, parse); 05079 05080 /* Setup our queue entry */ 05081 qe.start = time(NULL); 05082 05083 /* set the expire time based on the supplied timeout; */ 05084 if (!ast_strlen_zero(args.queuetimeoutstr)) 05085 qe.expire = qe.start + atoi(args.queuetimeoutstr); 05086 else 05087 qe.expire = 0; 05088 05089 /* Get the priority from the variable ${QUEUE_PRIO} */ 05090 ast_channel_lock(chan); 05091 user_priority = pbx_builtin_getvar_helper(chan, "QUEUE_PRIO"); 05092 if (user_priority) { 05093 if (sscanf(user_priority, "%30d", &prio) == 1) { 05094 ast_debug(1, "%s: Got priority %d from ${QUEUE_PRIO}.\n", chan->name, prio); 05095 } else { 05096 ast_log(LOG_WARNING, "${QUEUE_PRIO}: Invalid value (%s), channel %s.\n", 05097 user_priority, chan->name); 05098 prio = 0; 05099 } 05100 } else { 05101 ast_debug(3, "NO QUEUE_PRIO variable found. Using default.\n"); 05102 prio = 0; 05103 } 05104 05105 /* Get the maximum penalty from the variable ${QUEUE_MAX_PENALTY} */ 05106 05107 if ((max_penalty_str = pbx_builtin_getvar_helper(chan, "QUEUE_MAX_PENALTY"))) { 05108 if (sscanf(max_penalty_str, "%30d", &max_penalty) == 1) { 05109 ast_debug(1, "%s: Got max penalty %d from ${QUEUE_MAX_PENALTY}.\n", chan->name, max_penalty); 05110 } else { 05111 ast_log(LOG_WARNING, "${QUEUE_MAX_PENALTY}: Invalid value (%s), channel %s.\n", 05112 max_penalty_str, chan->name); 05113 max_penalty = 0; 05114 } 05115 } else { 05116 max_penalty = 0; 05117 } 05118 05119 if ((min_penalty_str = pbx_builtin_getvar_helper(chan, "QUEUE_MIN_PENALTY"))) { 05120 if (sscanf(min_penalty_str, "%30d", &min_penalty) == 1) { 05121 ast_debug(1, "%s: Got min penalty %d from ${QUEUE_MIN_PENALTY}.\n", chan->name, min_penalty); 05122 } else { 05123 ast_log(LOG_WARNING, "${QUEUE_MIN_PENALTY}: Invalid value (%s), channel %s.\n", 05124 min_penalty_str, chan->name); 05125 min_penalty = 0; 05126 } 05127 } else { 05128 min_penalty = 0; 05129 } 05130 ast_channel_unlock(chan); 05131 05132 if (args.options && (strchr(args.options, 'r'))) 05133 ringing = 1; 05134 05135 if (args.options && (strchr(args.options, 'c'))) 05136 qcontinue = 1; 05137 05138 ast_debug(1, "queue: %s, options: %s, url: %s, announce: %s, expires: %ld, priority: %d\n", 05139 args.queuename, args.options, args.url, args.announceoverride, (long)qe.expire, prio); 05140 05141 qe.chan = chan; 05142 qe.prio = prio; 05143 qe.max_penalty = max_penalty; 05144 qe.min_penalty = min_penalty; 05145 qe.last_pos_said = 0; 05146 qe.last_pos = 0; 05147 qe.last_periodic_announce_time = time(NULL); 05148 qe.last_periodic_announce_sound = 0; 05149 qe.valid_digits = 0; 05150 if (join_queue(args.queuename, &qe, &reason)) { 05151 ast_log(LOG_WARNING, "Unable to join queue '%s'\n", args.queuename); 05152 set_queue_result(chan, reason); 05153 return 0; 05154 } 05155 ast_queue_log(args.queuename, chan->uniqueid, "NONE", "ENTERQUEUE", "%s|%s", S_OR(args.url, ""), 05156 S_OR(chan->cid.cid_num, "")); 05157 copy_rules(&qe, args.rule); 05158 qe.pr = AST_LIST_FIRST(&qe.qe_rules); 05159 check_turns: 05160 if (ringing) { 05161 ast_indicate(chan, AST_CONTROL_RINGING); 05162 } else { 05163 ast_moh_start(chan, qe.moh, NULL); 05164 } 05165 05166 /* This is the wait loop for callers 2 through maxlen */ 05167 res = wait_our_turn(&qe, ringing, &reason); 05168 if (res) { 05169 goto stop; 05170 } 05171 05172 makeannouncement = 0; 05173 05174 for (;;) { 05175 /* This is the wait loop for the head caller*/ 05176 /* To exit, they may get their call answered; */ 05177 /* they may dial a digit from the queue context; */ 05178 /* or, they may timeout. */ 05179 05180 /* Leave if we have exceeded our queuetimeout */ 05181 if (qe.expire && (time(NULL) >= qe.expire)) { 05182 record_abandoned(&qe); 05183 reason = QUEUE_TIMEOUT; 05184 res = 0; 05185 ast_queue_log(args.queuename, chan->uniqueid,"NONE", "EXITWITHTIMEOUT", "%d|%d|%ld", 05186 qe.pos, qe.opos, (long) time(NULL) - qe.start); 05187 break; 05188 } 05189 05190 if (makeannouncement) { 05191 /* Make a position announcement, if enabled */ 05192 if (qe.parent->announcefrequency) 05193 if ((res = say_position(&qe,ringing))) 05194 goto stop; 05195 } 05196 makeannouncement = 1; 05197 05198 /* Make a periodic announcement, if enabled */ 05199 if (qe.parent->periodicannouncefrequency) 05200 if ((res = say_periodic_announcement(&qe,ringing))) 05201 goto stop; 05202 05203 /* Leave if we have exceeded our queuetimeout */ 05204 if (qe.expire && (time(NULL) >= qe.expire)) { 05205 record_abandoned(&qe); 05206 reason = QUEUE_TIMEOUT; 05207 res = 0; 05208 ast_queue_log(args.queuename, chan->uniqueid, "NONE", "EXITWITHTIMEOUT", "%d", qe.pos); 05209 break; 05210 } 05211 05212 /* see if we need to move to the next penalty level for this queue */ 05213 while (qe.pr && ((time(NULL) - qe.start) > qe.pr->time)) { 05214 update_qe_rule(&qe); 05215 } 05216 05217 /* Try calling all queue members for 'timeout' seconds */ 05218 res = try_calling(&qe, args.options, args.announceoverride, args.url, &tries, &noption, args.agi, args.macro, args.gosub, ringing); 05219 if (res) { 05220 goto stop; 05221 } 05222 05223 if (qe.parent->leavewhenempty) { 05224 int status = 0; 05225 if ((status = get_member_status(qe.parent, qe.max_penalty, qe.min_penalty, qe.parent->leavewhenempty))) { 05226 record_abandoned(&qe); 05227 reason = QUEUE_LEAVEEMPTY; 05228 ast_queue_log(args.queuename, chan->uniqueid, "NONE", "EXITEMPTY", "%d|%d|%ld", qe.pos, qe.opos, (long)(time(NULL) - qe.start)); 05229 res = 0; 05230 break; 05231 } 05232 } 05233 05234 /* exit after 'timeout' cycle if 'n' option enabled */ 05235 if (noption && tries >= qe.parent->membercount) { 05236 ast_verb(3, "Exiting on time-out cycle\n"); 05237 ast_queue_log(args.queuename, chan->uniqueid, "NONE", "EXITWITHTIMEOUT", "%d", qe.pos); 05238 record_abandoned(&qe); 05239 reason = QUEUE_TIMEOUT; 05240 res = 0; 05241 break; 05242 } 05243 05244 05245 /* Leave if we have exceeded our queuetimeout */ 05246 if (qe.expire && (time(NULL) >= qe.expire)) { 05247 record_abandoned(&qe); 05248 reason = QUEUE_TIMEOUT; 05249 res = 0; 05250 ast_queue_log(qe.parent->name, qe.chan->uniqueid,"NONE", "EXITWITHTIMEOUT", "%d|%d|%ld", qe.pos, qe.opos, (long) time(NULL) - qe.start); 05251 break; 05252 } 05253 05254 /* If using dynamic realtime members, we should regenerate the member list for this queue */ 05255 update_realtime_members(qe.parent); 05256 /* OK, we didn't get anybody; wait for 'retry' seconds; may get a digit to exit with */ 05257 res = wait_a_bit(&qe); 05258 if (res) 05259 goto stop; 05260 05261 /* Since this is a priority queue and 05262 * it is not sure that we are still at the head 05263 * of the queue, go and check for our turn again. 05264 */ 05265 if (!is_our_turn(&qe)) { 05266 ast_debug(1, "Darn priorities, going back in queue (%s)!\n", qe.chan->name); 05267 goto check_turns; 05268 } 05269 } 05270 05271 stop: 05272 if (res) { 05273 if (res < 0) { 05274 if (!qe.handled) { 05275 record_abandoned(&qe); 05276 ast_queue_log(args.queuename, chan->uniqueid, "NONE", "ABANDON", 05277 "%d|%d|%ld", qe.pos, qe.opos, 05278 (long) time(NULL) - qe.start); 05279 res = -1; 05280 } else if (qcontinue) { 05281 reason = QUEUE_CONTINUE; 05282 res = 0; 05283 } 05284 } else if (qe.valid_digits) { 05285 ast_queue_log(args.queuename, chan->uniqueid, "NONE", "EXITWITHKEY", 05286 "%s|%d", qe.digits, qe.pos); 05287 } 05288 } 05289 05290 /* Don't allow return code > 0 */ 05291 if (res >= 0) { 05292 res = 0; 05293 if (ringing) { 05294 ast_indicate(chan, -1); 05295 } else { 05296 ast_moh_stop(chan); 05297 } 05298 ast_stopstream(chan); 05299 } 05300 05301 set_queue_variables(qe.parent, qe.chan); 05302 05303 leave_queue(&qe); 05304 if (reason != QUEUE_UNKNOWN) 05305 set_queue_result(chan, reason); 05306 05307 if (qe.parent) { 05308 /* every queue_ent is given a reference to it's parent call_queue when it joins the queue. 05309 * This ref must be taken away right before the queue_ent is destroyed. In this case 05310 * the queue_ent is about to be returned on the stack */ 05311 qe.parent = queue_unref(qe.parent); 05312 } 05313 05314 return res; 05315 }
| static int queue_function_memberpenalty_read | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | data, | |||
| char * | buf, | |||
| size_t | len | |||
| ) | [static] |
Dialplan function QUEUE_MEMBER_PENALTY() Gets the members penalty.
Definition at line 5547 of file app_queue.c.
References AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_log(), AST_STANDARD_APP_ARGS, ast_strlen_zero(), get_member_penalty(), and LOG_ERROR.
05548 { 05549 int penalty; 05550 AST_DECLARE_APP_ARGS(args, 05551 AST_APP_ARG(queuename); 05552 AST_APP_ARG(interface); 05553 ); 05554 /* Make sure the returned value on error is NULL. */ 05555 buf[0] = '\0'; 05556 05557 if (ast_strlen_zero(data)) { 05558 ast_log(LOG_ERROR, "Missing argument. QUEUE_MEMBER_PENALTY(<queuename>,<interface>)\n"); 05559 return -1; 05560 } 05561 05562 AST_STANDARD_APP_ARGS(args, data); 05563 05564 if (args.argc < 2) { 05565 ast_log(LOG_ERROR, "Missing argument. QUEUE_MEMBER_PENALTY(<queuename>,<interface>)\n"); 05566 return -1; 05567 } 05568 05569 penalty = get_member_penalty (args.queuename, args.interface); 05570 05571 if (penalty >= 0) /* remember that buf is already '\0' */ 05572 snprintf (buf, len, "%d", penalty); 05573 05574 return 0; 05575 }
| static int queue_function_memberpenalty_write | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | data, | |||
| const char * | value | |||
| ) | [static] |
Dialplan function QUEUE_MEMBER_PENALTY() Sets the members penalty.
Definition at line 5578 of file app_queue.c.
References AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_log(), AST_STANDARD_APP_ARGS, ast_strlen_zero(), LOG_ERROR, and set_member_penalty().
05579 { 05580 int penalty; 05581 AST_DECLARE_APP_ARGS(args, 05582 AST_APP_ARG(queuename); 05583 AST_APP_ARG(interface); 05584 ); 05585 05586 if (ast_strlen_zero(data)) { 05587 ast_log(LOG_ERROR, "Missing argument. QUEUE_MEMBER_PENALTY(<queuename>,<interface>)\n"); 05588 return -1; 05589 } 05590 05591 AST_STANDARD_APP_ARGS(args, data); 05592 05593 if (args.argc < 2) { 05594 ast_log(LOG_ERROR, "Missing argument. QUEUE_MEMBER_PENALTY(<queuename>,<interface>)\n"); 05595 return -1; 05596 } 05597 05598 penalty = atoi(value); 05599 05600 if (ast_strlen_zero(args.interface)) { 05601 ast_log (LOG_ERROR, "<interface> parameter can't be null\n"); 05602 return -1; 05603 } 05604 05605 /* if queuename = NULL then penalty will be set for interface in all the queues. */ 05606 if (set_member_penalty(args.queuename, args.interface, penalty)) { 05607 ast_log(LOG_ERROR, "Invalid interface, queue or penalty\n"); 05608 return -1; 05609 } 05610 05611 return 0; 05612 }
| static int queue_function_qac | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | data, | |||
| char * | buf, | |||
| size_t | len | |||
| ) | [static] |
Get number either busy / free or total members of a specific queue.
| number | of members (busy / free / total) | |
| -1 | on error |
Definition at line 5368 of file app_queue.c.
References ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_lock(), ao2_ref, ao2_unlock(), AST_DEVICE_INVALID, AST_DEVICE_NOT_INUSE, AST_DEVICE_UNAVAILABLE, ast_log(), ast_strlen_zero(), call_queue::count, load_realtime_queue(), LOG_ERROR, LOG_WARNING, call_queue::membercount, call_queue::members, member::paused, queue_t_unref, and member::status.
05369 { 05370 int count = 0; 05371 struct member *m; 05372 struct ao2_iterator mem_iter; 05373 struct call_queue *q; 05374 char *option; 05375 05376 if (ast_strlen_zero(data)) { 05377 ast_log(LOG_ERROR, "%s requires an argument: queuename\n", cmd); 05378 return -1; 05379 } 05380 05381 if ((option = strchr(data, ','))) 05382 *option++ = '\0'; 05383 else 05384 option = "logged"; 05385 if ((q = load_realtime_queue(data))) { 05386 ao2_lock(q); 05387 if (!strcasecmp(option, "logged")) { 05388 mem_iter = ao2_iterator_init(q->members, 0); 05389 while ((m = ao2_iterator_next(&mem_iter))) { 05390 /* Count the agents who are logged in and presently answering calls */ 05391 if ((m->status != AST_DEVICE_UNAVAILABLE) && (m->status != AST_DEVICE_INVALID)) { 05392 count++; 05393 } 05394 ao2_ref(m, -1); 05395 } 05396 ao2_iterator_destroy(&mem_iter); 05397 } else if (!strcasecmp(option, "free")) { 05398 mem_iter = ao2_iterator_init(q->members, 0); 05399 while ((m = ao2_iterator_next(&mem_iter))) { 05400 /* Count the agents who are logged in and presently answering calls */ 05401 if ((m->status == AST_DEVICE_NOT_INUSE) && (!m->paused)) { 05402 count++; 05403 } 05404 ao2_ref(m, -1); 05405 } 05406 ao2_iterator_destroy(&mem_iter); 05407 } else /* must be "count" */ 05408 count = q->membercount; 05409 ao2_unlock(q); 05410 queue_t_unref(q, "Done with temporary reference in QUEUE_MEMBER()"); 05411 } else 05412 ast_log(LOG_WARNING, "queue %s was not found\n", data); 05413 05414 snprintf(buf, len, "%d", count); 05415 05416 return 0; 05417 }
| static int queue_function_qac_dep | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | data, | |||
| char * | buf, | |||
| size_t | len | |||
| ) | [static] |
Get the total number of members in a specific queue (Deprecated).
| number | of members | |
| -1 | on error |
Definition at line 5424 of file app_queue.c.
References ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_lock(), ao2_ref, ao2_unlock(), AST_DEVICE_INVALID, AST_DEVICE_UNAVAILABLE, ast_log(), ast_strlen_zero(), call_queue::count, load_realtime_queue(), LOG_ERROR, LOG_NOTICE, LOG_WARNING, call_queue::members, queue_t_unref, and member::status.
05425 { 05426 int count = 0; 05427 struct member *m; 05428 struct call_queue *q; 05429 struct ao2_iterator mem_iter; 05430 static int depflag = 1; 05431 05432 if (depflag) { 05433 depflag = 0; 05434 ast_log(LOG_NOTICE, "The function QUEUE_MEMBER_COUNT has been deprecated in favor of the QUEUE_MEMBER function and will not be in further releases.\n"); 05435 } 05436 05437 if (ast_strlen_zero(data)) { 05438 ast_log(LOG_ERROR, "%s requires an argument: queuename\n", cmd); 05439 return -1; 05440 } 05441 05442 if ((q = load_realtime_queue(data))) { 05443 ao2_lock(q); 05444 mem_iter = ao2_iterator_init(q->members, 0); 05445 while ((m = ao2_iterator_next(&mem_iter))) { 05446 /* Count the agents who are logged in and presently answering calls */ 05447 if ((m->status != AST_DEVICE_UNAVAILABLE) && (m->status != AST_DEVICE_INVALID)) { 05448 count++; 05449 } 05450 ao2_ref(m, -1); 05451 } 05452 ao2_iterator_destroy(&mem_iter); 05453 ao2_unlock(q); 05454 queue_t_unref(q, "Done with temporary reference in QUEUE_MEMBER_COUNT"); 05455 } else 05456 ast_log(LOG_WARNING, "queue %s was not found\n", data); 05457 05458 snprintf(buf, len, "%d", count); 05459 05460 return 0; 05461 }
| static int queue_function_queuememberlist | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | data, | |||
| char * | buf, | |||
| size_t | len | |||
| ) | [static] |
Dialplan function QUEUE_MEMBER_LIST() Get list of members in a specific queue.
Definition at line 5499 of file app_queue.c.
References ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_lock(), ao2_ref, ao2_t_find, ao2_unlock(), ast_copy_string(), ast_log(), ast_strlen_zero(), member::interface, LOG_ERROR, LOG_WARNING, call_queue::members, call_queue::name, OBJ_POINTER, queue_t_unref, and queues.
05500 { 05501 struct call_queue *q, tmpq; 05502 struct member *m; 05503 05504 /* Ensure an otherwise empty list doesn't return garbage */ 05505 buf[0] = '\0'; 05506 05507 if (ast_strlen_zero(data)) { 05508 ast_log(LOG_ERROR, "QUEUE_MEMBER_LIST requires an argument: queuename\n"); 05509 return -1; 05510 } 05511 05512 ast_copy_string(tmpq.name, data, sizeof(tmpq.name)); 05513 if ((q = ao2_t_find(queues, &tmpq, OBJ_POINTER, "Find for QUEUE_MEMBER_LIST()"))) { 05514 int buflen = 0, count = 0; 05515 struct ao2_iterator mem_iter = ao2_iterator_init(q->members, 0); 05516 05517 ao2_lock(q); 05518 while ((m = ao2_iterator_next(&mem_iter))) { 05519 /* strcat() is always faster than printf() */ 05520 if (count++) { 05521 strncat(buf + buflen, ",", len - buflen - 1); 05522 buflen++; 05523 } 05524 strncat(buf + buflen, m->interface, len - buflen - 1); 05525 buflen += strlen(m->interface); 05526 /* Safeguard against overflow (negative length) */ 05527 if (buflen >= len - 2) { 05528 ao2_ref(m, -1); 05529 ast_log(LOG_WARNING, "Truncating list\n"); 05530 break; 05531 } 05532 ao2_ref(m, -1); 05533 } 05534 ao2_iterator_destroy(&mem_iter); 05535 ao2_unlock(q); 05536 queue_t_unref(q, "Done with QUEUE_MEMBER_LIST()"); 05537 } else 05538 ast_log(LOG_WARNING, "queue %s was not found\n", data); 05539 05540 /* We should already be terminated, but let's make sure. */ 05541 buf[len - 1] = '\0'; 05542 05543 return 0; 05544 }
| static int queue_function_queuewaitingcount | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | data, | |||
| char * | buf, | |||
| size_t | len | |||
| ) | [static] |
Dialplan function QUEUE_WAITING_COUNT() Get number callers waiting in a specific queue.
Definition at line 5464 of file app_queue.c.
References ao2_lock(), ao2_t_find, ao2_unlock(), ast_copy_string(), ast_load_realtime(), ast_log(), ast_strlen_zero(), ast_variables_destroy(), call_queue::count, LOG_ERROR, LOG_WARNING, call_queue::name, OBJ_POINTER, queue_t_unref, queues, SENTINEL, and var.
05465 { 05466 int count = 0; 05467 struct call_queue *q, tmpq; 05468 struct ast_variable *var = NULL; 05469 05470 buf[0] = '\0'; 05471 05472 if (ast_strlen_zero(data)) { 05473 ast_log(LOG_ERROR, "QUEUE_WAITING_COUNT requires an argument: queuename\n"); 05474 return -1; 05475 } 05476 05477 ast_copy_string(tmpq.name, data, sizeof(tmpq.name)); 05478 if ((q = ao2_t_find(queues, &tmpq, OBJ_POINTER, "Find for QUEUE_WAITING_COUNT()"))) { 05479 ao2_lock(q); 05480 count = q->count; 05481 ao2_unlock(q); 05482 queue_t_unref(q, "Done with reference in QUEUE_WAITING_COUNT()"); 05483 } else if ((var = ast_load_realtime("queues", "name", data, SENTINEL))) { 05484 /* if the queue is realtime but was not found in memory, this 05485 * means that the queue had been deleted from memory since it was 05486 * "dead." This means it has a 0 waiting count 05487 */ 05488 count = 0; 05489 ast_variables_destroy(var); 05490 } else 05491 ast_log(LOG_WARNING, "queue %s was not found\n", data); 05492 05493 snprintf(buf, len, "%d", count); 05494 05495 return 0; 05496 }
| static int queue_function_var | ( | struct ast_channel * | chan, | |
| const char * | cmd, | |||
| char * | data, | |||
| char * | buf, | |||
| size_t | len | |||
| ) | [static] |
create interface var with all queue details.
| 0 | on success | |
| -1 | on error |
Definition at line 5322 of file app_queue.c.
References ao2_lock(), ao2_t_find, ao2_unlock(), ast_copy_string(), ast_log(), ast_strlen_zero(), call_queue::callsabandoned, call_queue::callscompleted, call_queue::callscompletedinsl, call_queue::count, call_queue::holdtime, int2strat(), LOG_ERROR, LOG_WARNING, call_queue::maxlen, call_queue::name, OBJ_POINTER, pbx_builtin_setvar_multiple(), queue_t_unref, queues, call_queue::servicelevel, call_queue::setqueuevar, call_queue::strategy, and call_queue::talktime.
05323 { 05324 int res = -1; 05325 struct call_queue *q, tmpq; 05326 char interfacevar[256] = ""; 05327 float sl = 0; 05328 05329 if (ast_strlen_zero(data)) { 05330 ast_log(LOG_ERROR, "%s requires an argument: queuename\n", cmd); 05331 return -1; 05332 } 05333 05334 ast_copy_string(tmpq.name, data, sizeof(tmpq.name)); 05335 if ((q = ao2_t_find(queues, &tmpq, OBJ_POINTER, "Find for QUEUE() function"))) { 05336 ao2_lock(q); 05337 if (q->setqueuevar) { 05338 sl = 0; 05339 res = 0; 05340 05341 if (q->callscompleted > 0) { 05342 sl = 100 * ((float) q->callscompletedinsl / (float) q->callscompleted); 05343 } 05344 05345 snprintf(interfacevar, sizeof(interfacevar), 05346 "QUEUEMAX=%d,QUEUESTRATEGY=%s,QUEUECALLS=%d,QUEUEHOLDTIME=%d,QUEUETALKTIME=%d,QUEUECOMPLETED=%d,QUEUEABANDONED=%d,QUEUESRVLEVEL=%d,QUEUESRVLEVELPERF=%2.1f", 05347 q->maxlen, int2strat(q->strategy), q->count, q->holdtime, q->talktime, q->callscompleted, q->callsabandoned, q->servicelevel, sl); 05348 05349 pbx_builtin_setvar_multiple(chan, interfacevar); 05350 } 05351 05352 ao2_unlock(q); 05353 queue_t_unref(q, "Done with QUEUE() function"); 05354 } else { 05355 ast_log(LOG_WARNING, "queue %s was not found\n", data); 05356 } 05357 05358 snprintf(buf, len, "%d", res); 05359 05360 return 0; 05361 }
| static int queue_hash_cb | ( | const void * | obj, | |
| const int | flags | |||
| ) | [static] |
Definition at line 861 of file app_queue.c.
References ast_str_case_hash(), and call_queue::name.
Referenced by load_module().
00862 { 00863 const struct call_queue *q = obj; 00864 00865 return ast_str_case_hash(q->name); 00866 }
| static struct call_queue* queue_ref | ( | struct call_queue * | q | ) | [static, read] |
Definition at line 886 of file app_queue.c.
References ao2_ref.
Referenced by insert_entry().
00887 { 00888 ao2_ref(q, 1); 00889 return q; 00890 }
| static void queue_set_global_params | ( | struct ast_config * | cfg | ) | [static] |
Set the global queue parameters as defined in the "general" section of queues.conf
Definition at line 5699 of file app_queue.c.
References ast_true(), and ast_variable_retrieve().
Referenced by reload_queues().
05700 { 05701 const char *general_val = NULL; 05702 queue_persistent_members = 0; 05703 if ((general_val = ast_variable_retrieve(cfg, "general", "persistentmembers"))) 05704 queue_persistent_members = ast_true(general_val); 05705 autofill_default = 0; 05706 if ((general_val = ast_variable_retrieve(cfg, "general", "autofill"))) 05707 autofill_default = ast_true(general_val); 05708 montype_default = 0; 05709 if ((general_val = ast_variable_retrieve(cfg, "general", "monitor-type"))) { 05710 if (!strcasecmp(general_val, "mixmonitor")) 05711 montype_default = 1; 05712 } 05713 update_cdr = 0; 05714 if ((general_val = ast_variable_retrieve(cfg, "general", "updatecdr"))) 05715 update_cdr = ast_true(general_val); 05716 shared_lastcall = 0; 05717 if ((general_val = ast_variable_retrieve(cfg, "general", "shared_lastcall"))) 05718 shared_lastcall = ast_true(general_val); 05719 }
| static void queue_set_param | ( | struct call_queue * | q, | |
| const char * | param, | |||
| const char * | val, | |||
| int | linenum, | |||
| int | failunknown | |||
| ) | [static] |
Configure a queue parameter.
The failunknown flag is set for config files (and static realtime) to show errors for unknown parameters. It is cleared for dynamic realtime to allow extra fields in the tables.
Definition at line 1398 of file app_queue.c.
References call_queue::announce, call_queue::announcefrequency, call_queue::announceholdtime, ANNOUNCEHOLDTIME_ALWAYS, ANNOUNCEHOLDTIME_ONCE, call_queue::announceposition, ANNOUNCEPOSITION_LIMIT, ANNOUNCEPOSITION_MORE_THAN, ANNOUNCEPOSITION_NO, ANNOUNCEPOSITION_YES, call_queue::announcepositionlimit, ast_copy_string(), ast_debug, ast_log(), ast_str_create(), ast_str_set(), ast_strdupa, ast_true(), call_queue::autofill, call_queue::autopause, buf, call_queue::context, DEFAULT_RETRY, DEFAULT_TIMEOUT, call_queue::defaultrule, call_queue::eventwhencalled, call_queue::joinempty, call_queue::leavewhenempty, LOG_WARNING, call_queue::maskmemberstatus, MAX_PERIODIC_ANNOUNCEMENTS, call_queue::maxlen, call_queue::memberdelay, call_queue::membergosub, call_queue::membermacro, call_queue::minannouncefrequency, call_queue::moh, call_queue::monfmt, call_queue::montype, call_queue::name, call_queue::numperiodicannounce, parse_empty_options(), call_queue::periodicannouncefrequency, QUEUE_EVENT_VARIABLES, call_queue::queue_quantity1, call_queue::queue_quantity2, QUEUE_STRATEGY_LINEAR, QUEUE_STRATEGY_RINGALL, call_queue::randomperiodicannounce, call_queue::reportholdtime, call_queue::retry, call_queue::ringinuse, call_queue::roundingseconds, s, call_queue::servicelevel, call_queue::setinterfacevar, call_queue::setqueueentryvar, call_queue::setqueuevar, call_queue::sound_callerannounce, call_queue::sound_calls, call_queue::sound_holdtime, call_queue::sound_minute, call_queue::sound_minutes, call_queue::sound_next, call_queue::sound_periodicannounce, call_queue::sound_reporthold, call_queue::sound_seconds, call_queue::sound_thanks, call_queue::sound_thereare, strat2int(), call_queue::strategy, strsep(), call_queue::timeout, TIMEOUT_PRIORITY_APP, TIMEOUT_PRIORITY_CONF, call_queue::timeoutpriority, call_queue::timeoutrestart, call_queue::weight, and call_queue::wrapuptime.
Referenced by find_queue_by_name_rt(), and reload_single_queue().
01399 { 01400 if (!strcasecmp(param, "musicclass") || 01401 !strcasecmp(param, "music") || !strcasecmp(param, "musiconhold")) { 01402 ast_copy_string(q->moh, val, sizeof(q->moh)); 01403 } else if (!strcasecmp(param, "announce")) { 01404 ast_copy_string(q->announce, val, sizeof(q->announce)); 01405 } else if (!strcasecmp(param, "context")) { 01406 ast_copy_string(q->context, val, sizeof(q->context)); 01407 } else if (!strcasecmp(param, "timeout")) { 01408 q->timeout = atoi(val); 01409 if (q->timeout < 0) 01410 q->timeout = DEFAULT_TIMEOUT; 01411 } else if (!strcasecmp(param, "ringinuse")) { 01412 q->ringinuse = ast_true(val); 01413 } else if (!strcasecmp(param, "setinterfacevar")) { 01414 q->setinterfacevar = ast_true(val); 01415 } else if (!strcasecmp(param, "setqueuevar")) { 01416 q->setqueuevar = ast_true(val); 01417 } else if (!strcasecmp(param, "setqueueentryvar")) { 01418 q->setqueueentryvar = ast_true(val); 01419 } else if (!strcasecmp(param, "monitor-format")) { 01420 ast_copy_string(q->monfmt, val, sizeof(q->monfmt)); 01421 } else if (!strcasecmp(param, "membermacro")) { 01422 ast_copy_string(q->membermacro, val, sizeof(q->membermacro)); 01423 } else if (!strcasecmp(param, "membergosub")) { 01424 ast_copy_string(q->membergosub, val, sizeof(q->membergosub)); 01425 } else if (!strcasecmp(param, "queue-youarenext")) { 01426 ast_copy_string(q->sound_next, val, sizeof(q->sound_next)); 01427 } else if (!strcasecmp(param, "queue-thereare")) { 01428 ast_copy_string(q->sound_thereare, val, sizeof(q->sound_thereare)); 01429 } else if (!strcasecmp(param, "queue-callswaiting")) { 01430 ast_copy_string(q->sound_calls, val, sizeof(q->sound_calls)); 01431 } else if (!strcasecmp(param, "queue-quantity1")) { 01432 ast_copy_string(q->queue_quantity1, val, sizeof(q->queue_quantity1)); 01433 } else if (!strcasecmp(param, "queue-quantity2")) { 01434 ast_copy_string(q->queue_quantity2, val, sizeof(q->queue_quantity2)); 01435 } else if (!strcasecmp(param, "queue-holdtime")) { 01436 ast_copy_string(q->sound_holdtime, val, sizeof(q->sound_holdtime)); 01437 } else if (!strcasecmp(param, "queue-minutes")) { 01438 ast_copy_string(q->sound_minutes, val, sizeof(q->sound_minutes)); 01439 } else if (!strcasecmp(param, "queue-minute")) { 01440 ast_copy_string(q->sound_minute, val, sizeof(q->sound_minute)); 01441 } else if (!strcasecmp(param, "queue-seconds")) { 01442 ast_copy_string(q->sound_seconds, val, sizeof(q->sound_seconds)); 01443 } else if (!strcasecmp(param, "queue-thankyou")) { 01444 ast_copy_string(q->sound_thanks, val, sizeof(q->sound_thanks)); 01445 } else if (!strcasecmp(param, "queue-callerannounce")) { 01446 ast_copy_string(q->sound_callerannounce, val, sizeof(q->sound_callerannounce)); 01447 } else if (!strcasecmp(param, "queue-reporthold")) { 01448 ast_copy_string(q->sound_reporthold, val, sizeof(q->sound_reporthold)); 01449 } else if (!strcasecmp(param, "announce-frequency")) { 01450 q->announcefrequency = atoi(val); 01451 } else if (!strcasecmp(param, "min-announce-frequency")) { 01452 q->minannouncefrequency = atoi(val); 01453 ast_debug(1, "%s=%s for queue '%s'\n", param, val, q->name); 01454 } else if (!strcasecmp(param, "announce-round-seconds")) { 01455 q->roundingseconds = atoi(val); 01456 /* Rounding to any other values just doesn't make sense... */ 01457 if (!(q->roundingseconds == 0 || q->roundingseconds == 5 || q->roundingseconds == 10 01458 || q->roundingseconds == 15 || q->roundingseconds == 20 || q->roundingseconds == 30)) { 01459 if (linenum >= 0) { 01460 ast_log(LOG_WARNING, "'%s' isn't a valid value for %s " 01461 "using 0 instead for queue '%s' at line %d of queues.conf\n", 01462 val, param, q->name, linenum); 01463 } else { 01464 ast_log(LOG_WARNING, "'%s' isn't a valid value for %s " 01465 "using 0 instead for queue '%s'\n", val, param, q->name); 01466 } 01467 q->roundingseconds=0; 01468 } 01469 } else if (!strcasecmp(param, "announce-holdtime")) { 01470 if (!strcasecmp(val, "once")) 01471 q->announceholdtime = ANNOUNCEHOLDTIME_ONCE; 01472 else if (ast_true(val)) 01473 q->announceholdtime = ANNOUNCEHOLDTIME_ALWAYS; 01474 else 01475 q->announceholdtime = 0; 01476 } else if (!strcasecmp(param, "announce-position")) { 01477 if (!strcasecmp(val, "limit")) 01478 q->announceposition = ANNOUNCEPOSITION_LIMIT; 01479 else if (!strcasecmp(val, "more")) 01480 q->announceposition = ANNOUNCEPOSITION_MORE_THAN; 01481 else if (ast_true(val)) 01482 q->announceposition = ANNOUNCEPOSITION_YES; 01483 else 01484 q->announceposition = ANNOUNCEPOSITION_NO; 01485 } else if (!strcasecmp(param, "announce-position-limit")) { 01486 q->announcepositionlimit = atoi(val); 01487 } else if (!strcasecmp(param, "periodic-announce")) { 01488 if (strchr(val, ',')) { 01489 char *s, *buf = ast_strdupa(val); 01490 unsigned int i = 0; 01491 01492 while ((s = strsep(&buf, ",|"))) { 01493 if (!q->sound_periodicannounce[i]) 01494 q->sound_periodicannounce[i] = ast_str_create(16); 01495 ast_str_set(&q->sound_periodicannounce[i], 0, "%s", s); 01496 i++; 01497 if (i == MAX_PERIODIC_ANNOUNCEMENTS) 01498 break; 01499 } 01500 q->numperiodicannounce = i; 01501 } else { 01502 ast_str_set(&q->sound_periodicannounce[0], 0, "%s", val); 01503 q->numperiodicannounce = 1; 01504 } 01505 } else if (!strcasecmp(param, "periodic-announce-frequency")) { 01506 q->periodicannouncefrequency = atoi(val); 01507 } else if (!strcasecmp(param, "random-periodic-announce")) { 01508 q->randomperiodicannounce = ast_true(val); 01509 } else if (!strcasecmp(param, "retry")) { 01510 q->retry = atoi(val); 01511 if (q->retry <= 0) 01512 q->retry = DEFAULT_RETRY; 01513 } else if (!strcasecmp(param, "wrapuptime")) { 01514 q->wrapuptime = atoi(val); 01515 } else if (!strcasecmp(param, "autofill")) { 01516 q->autofill = ast_true(val); 01517 } else if (!strcasecmp(param, "monitor-type")) { 01518 if (!strcasecmp(val, "mixmonitor")) 01519 q->montype = 1; 01520 } else if (!strcasecmp(param, "autopause")) { 01521 q->autopause = ast_true(val); 01522 } else if (!strcasecmp(param, "maxlen")) { 01523 q->maxlen = atoi(val); 01524 if (q->maxlen < 0) 01525 q->maxlen = 0; 01526 } else if (!strcasecmp(param, "servicelevel")) { 01527 q->servicelevel= atoi(val); 01528 } else if (!strcasecmp(param, "strategy")) { 01529 int strategy; 01530 01531 /* We are a static queue and already have set this, no need to do it again */ 01532 if (failunknown) { 01533 return; 01534 } 01535 strategy = strat2int(val); 01536 if (strategy < 0) { 01537 ast_log(LOG_WARNING, "'%s' isn't a valid strategy for queue '%s', using ringall instead\n", 01538 val, q->name); 01539 q->strategy = QUEUE_STRATEGY_RINGALL; 01540 } 01541 if (strategy == q->strategy) { 01542 return; 01543 } 01544 if (strategy == QUEUE_STRATEGY_LINEAR) { 01545 ast_log(LOG_WARNING, "Changing to the linear strategy currently requires asterisk to be restarted.\n"); 01546 return; 01547 } 01548 q->strategy = strategy; 01549 } else if (!strcasecmp(param, "joinempty")) { 01550 parse_empty_options(val, &q->joinempty, 1); 01551 } else if (!strcasecmp(param, "leavewhenempty")) { 01552 parse_empty_options(val, &q->leavewhenempty, 0); 01553 } else if (!strcasecmp(param, "eventmemberstatus")) { 01554 q->maskmemberstatus = !ast_true(val); 01555 } else if (!strcasecmp(param, "eventwhencalled")) { 01556 if (!strcasecmp(val, "vars")) { 01557 q->eventwhencalled = QUEUE_EVENT_VARIABLES; 01558 } else { 01559 q->eventwhencalled = ast_true(val) ? 1 : 0; 01560 } 01561 } else if (!strcasecmp(param, "reportholdtime")) { 01562 q->reportholdtime = ast_true(val); 01563 } else if (!strcasecmp(param, "memberdelay")) { 01564 q->memberdelay = atoi(val); 01565 } else if (!strcasecmp(param, "weight")) { 01566 q->weight = atoi(val); 01567 } else if (!strcasecmp(param, "timeoutrestart")) { 01568 q->timeoutrestart = ast_true(val); 01569 } else if (!strcasecmp(param, "defaultrule")) { 01570 ast_copy_string(q->defaultrule, val, sizeof(q->defaultrule)); 01571 } else if (!strcasecmp(param, "timeoutpriority")) { 01572 if (!strcasecmp(val, "conf")) { 01573 q->timeoutpriority = TIMEOUT_PRIORITY_CONF; 01574 } else { 01575 q->timeoutpriority = TIMEOUT_PRIORITY_APP; 01576 } 01577 } else if (failunknown) { 01578 if (linenum >= 0) { 01579 ast_log(LOG_WARNING, "Unknown keyword in queue '%s': %s at line %d of queues.conf\n", 01580 q->name, param, linenum); 01581 } else { 01582 ast_log(LOG_WARNING, "Unknown keyword in queue '%s': %s\n", q->name, param); 01583 } 01584 } 01585 }
| static char* queue_show | ( | struct ast_cli_entry * | e, | |
| int | cmd, | |||
| struct ast_cli_args * | a | |||
| ) | [static] |
Definition at line 6241 of file app_queue.c.
References __queues_show(), ast_cli_args::argc, ast_cli_args::argv, CLI_GENERATE, CLI_INIT, ast_cli_entry::command, complete_queue_show(), ast_cli_args::fd, ast_cli_args::line, ast_cli_args::n, ast_cli_args::pos, ast_cli_entry::usage, and ast_cli_args::word.
06242 { 06243 switch ( cmd ) { 06244 case CLI_INIT: 06245 e->command = "queue show"; 06246 e->usage = 06247 "Usage: queue show\n" 06248 " Provides summary information on a specified queue.\n"; 06249 return NULL; 06250 case CLI_GENERATE: 06251 return complete_queue_show(a->line, a->word, a->pos, a->n); 06252 } 06253 06254 return __queues_show(NULL, a->fd, a->argc, a->argv); 06255 }
| static void queue_transfer_destroy | ( | void * | data | ) | [static] |
Definition at line 3437 of file app_queue.c.
References ast_free.
03438 { 03439 struct queue_transfer_ds *qtds = data; 03440 ast_free(qtds); 03441 }
| static void queue_transfer_fixup | ( | void * | data, | |
| struct ast_channel * | old_chan, | |||
| struct ast_channel * | new_chan | |||
| ) | [static] |
Log an attended transfer when a queue caller channel is masqueraded.
When a caller is masqueraded, we want to log a transfer. Fixup time is the closest we can come to when the actual transfer occurs. This happens during the masquerade after datastores are moved from old_chan to new_chan. This is why new_chan is referenced for exten, context, and datastore information.
At the end of this, we want to remove the datastore so that this fixup function is not called on any future masquerades of the caller during the current call.
Definition at line 3460 of file app_queue.c.
References ast_channel_datastore_find(), ast_channel_datastore_remove(), ast_log(), ast_queue_log(), queue_transfer_ds::callcompletedinsl, queue_ent::chan, ast_channel::context, ast_channel::exten, LOG_WARNING, queue_transfer_ds::member, member::membername, call_queue::name, queue_ent::opos, queue_ent::parent, queue_transfer_ds::qe, queue_transfer_info, queue_ent::start, queue_transfer_ds::starttime, ast_channel::uniqueid, and update_queue().
03461 { 03462 struct queue_transfer_ds *qtds = data; 03463 struct queue_ent *qe = qtds->qe; 03464 struct member *member = qtds->member; 03465 time_t callstart = qtds->starttime; 03466 int callcompletedinsl = qtds->callcompletedinsl; 03467 struct ast_datastore *datastore; 03468 03469 ast_queue_log(qe->parent->name, qe->chan->uniqueid, member->membername, "TRANSFER", "%s|%s|%ld|%ld|%d", 03470 new_chan->exten, new_chan->context, (long) (callstart - qe->start), 03471 (long) (time(NULL) - callstart), qe->opos); 03472 03473 update_queue(qe->parent, member, callcompletedinsl, (time(NULL) - callstart)); 03474 03475 /* No need to lock the channels because they are already locked in ast_do_masquerade */ 03476 if ((datastore = ast_channel_datastore_find(old_chan, &queue_transfer_info, NULL))) { 03477 ast_channel_datastore_remove(old_chan, datastore); 03478 } else { 03479 ast_log(LOG_WARNING, "Can't find the queue_transfer datastore.\n"); 03480 } 03481 }
| static struct call_queue* queue_unref | ( | struct call_queue * | q | ) | [static, read] |
Definition at line 892 of file app_queue.c.
References ao2_ref.
Referenced by queue_exec().
00893 { 00894 ao2_ref(q, -1); 00895 return q; 00896 }
| static void recalc_holdtime | ( | struct queue_ent * | qe, | |
| int | newholdtime | |||
| ) | [static] |
Definition at line 2235 of file app_queue.c.
References ao2_lock(), ao2_unlock(), call_queue::holdtime, and queue_ent::parent.
Referenced by try_calling().
02236 { 02237 int oldvalue; 02238 02239 /* Calculate holdtime using an exponential average */ 02240 /* Thanks to SRT for this contribution */ 02241 /* 2^2 (4) is the filter coefficient; a higher exponent would give old entries more weight */ 02242 02243 ao2_lock(qe->parent); 02244 oldvalue = qe->parent->holdtime; 02245 qe->parent->holdtime = (((oldvalue << 2) - oldvalue) + newholdtime) >> 2; 02246 ao2_unlock(qe->parent); 02247 }
| static void record_abandoned | ( | struct queue_ent * | qe | ) | [static] |
Record that a caller gave up on waiting in queue.
Definition at line 2795 of file app_queue.c.
References ao2_lock(), ao2_unlock(), call_queue::callsabandoned, queue_ent::chan, EVENT_FLAG_AGENT, manager_event, call_queue::name, queue_ent::opos, queue_ent::parent, queue_ent::pos, set_queue_variables(), queue_ent::start, and ast_channel::uniqueid.
Referenced by queue_exec(), and try_calling().
02796 { 02797 ao2_lock(qe->parent); 02798 set_queue_variables(qe->parent, qe->chan); 02799 manager_event(EVENT_FLAG_AGENT, "QueueCallerAbandon", 02800 "Queue: %s\r\n" 02801 "Uniqueid: %s\r\n" 02802 "Position: %d\r\n" 02803 "OriginalPosition: %d\r\n" 02804 "HoldTime: %d\r\n", 02805 qe->parent->name, qe->chan->uniqueid, qe->pos, qe->opos, (int)(time(NULL) - qe->start)); 02806 02807 qe->parent->callsabandoned++; 02808 ao2_unlock(qe->parent); 02809 }
| static int reload | ( | void | ) | [static] |
Definition at line 7281 of file app_queue.c.
References AST_FLAGS_ALL, ast_unload_realtime(), and reload_handler().
07282 { 07283 struct ast_flags mask = {AST_FLAGS_ALL,}; 07284 ast_unload_realtime("queue_members"); 07285 reload_handler(1, &mask, NULL); 07286 return 0; 07287 }
| static int reload_handler | ( | int | reload, | |
| struct ast_flags * | mask, | |||
| const char * | queuename | |||
| ) | [static] |
The command center for all reload operations.
Whenever any piece of queue information is to be reloaded, this function is called. It interprets the flags set in the mask parameter and acts based on how they are set.
| reload | True if we are reloading information, false if we are loading information for the first time. | |
| mask | A bitmask which tells the handler what actions to take | |
| queuename | The name of the queue on which we wish to take action |
| 0 | All reloads were successful | |
| non-zero | There was a failure |
Definition at line 6053 of file app_queue.c.
References ast_test_flag, clear_stats(), QUEUE_RELOAD_MEMBER, QUEUE_RELOAD_PARAMETERS, QUEUE_RELOAD_RULES, QUEUE_RESET_STATS, reload_queue_rules(), and reload_queues().
Referenced by handle_queue_reload(), handle_queue_reset(), load_module(), manager_queue_reload(), manager_queue_reset(), and reload().
06054 { 06055 int res = 0; 06056 06057 if (ast_test_flag(mask, QUEUE_RELOAD_RULES)) { 06058 res |= reload_queue_rules(reload); 06059 } 06060 if (ast_test_flag(mask, QUEUE_RESET_STATS)) { 06061 res |= clear_stats(queuename); 06062 } 06063 if (ast_test_flag(mask, (QUEUE_RELOAD_PARAMETERS | QUEUE_RELOAD_MEMBER))) { 06064 res |= reload_queues(reload, mask, queuename); 06065 } 06066 return res; 06067 }
| static void reload_queue_members | ( | void | ) | [static] |
Reload dynamic queue members persisted into the astdb.
Definition at line 4679 of file app_queue.c.
References add_to_queue(), ao2_lock(), ao2_t_find, ao2_unlock(), ast_copy_string(), ast_db_del(), ast_db_freetree(), ast_db_get(), ast_db_gettree(), ast_debug, ast_log(), ast_strlen_zero(), errno, member::interface, ast_db_entry::key, load_realtime_queue(), LOG_ERROR, LOG_NOTICE, LOG_WARNING, member::membername, call_queue::name, ast_db_entry::next, OBJ_POINTER, member::paused, member::penalty, PM_MAX_LEN, queue_t_unref, queues, RES_OUTOFMEMORY, member::state_interface, and strsep().
Referenced by load_module().
04680 { 04681 char *cur_ptr; 04682 const char *queue_name; 04683 char *member; 04684 char *interface; 04685 char *membername = NULL; 04686 char *state_interface; 04687 char *penalty_tok; 04688 int penalty = 0; 04689 char *paused_tok; 04690 int paused = 0; 04691 struct ast_db_entry *db_tree; 04692 struct ast_db_entry *entry; 04693 struct call_queue *cur_queue; 04694 char queue_data[PM_MAX_LEN]; 04695 04696 ao2_lock(queues); 04697 04698 /* Each key in 'pm_family' is the name of a queue */ 04699 db_tree = ast_db_gettree(pm_family, NULL); 04700 for (entry = db_tree; entry; entry = entry->next) { 04701 04702 queue_name = entry->key + strlen(pm_family) + 2; 04703 04704 { 04705 struct call_queue tmpq; 04706 ast_copy_string(tmpq.name, queue_name, sizeof(tmpq.name)); 04707 cur_queue = ao2_t_find(queues, &tmpq, OBJ_POINTER, "Reload queue members"); 04708 } 04709 04710 if (!cur_queue) 04711 cur_queue = load_realtime_queue(queue_name); 04712 04713 if (!cur_queue) { 04714 /* If the queue no longer exists, remove it from the 04715 * database */ 04716 ast_log(LOG_WARNING, "Error loading persistent queue: '%s': it does not exist\n", queue_name); 04717 ast_db_del(pm_family, queue_name); 04718 continue; 04719 } 04720 04721 if (ast_db_get(pm_family, queue_name, queue_data, PM_MAX_LEN)) { 04722 queue_t_unref(cur_queue, "Expire reload reference"); 04723 continue; 04724 } 04725 04726 cur_ptr = queue_data; 04727 while ((member = strsep(&cur_ptr, ",|"))) { 04728 if (ast_strlen_zero(member)) 04729 continue; 04730 04731 interface = strsep(&member, ";"); 04732 penalty_tok = strsep(&member, ";"); 04733 paused_tok = strsep(&member, ";"); 04734 membername = strsep(&member, ";"); 04735 state_interface = strsep(&member, ";"); 04736 04737 if (!penalty_tok) { 04738 ast_log(LOG_WARNING, "Error parsing persistent member string for '%s' (penalty)\n", queue_name); 04739 break; 04740 } 04741 penalty = strtol(penalty_tok, NULL, 10); 04742 if (errno == ERANGE) { 04743 ast_log(LOG_WARNING, "Error converting penalty: %s: Out of range.\n", penalty_tok); 04744 break; 04745 } 04746 04747 if (!paused_tok) { 04748 ast_log(LOG_WARNING, "Error parsing persistent member string for '%s' (paused)\n", queue_name); 04749 break; 04750 } 04751 paused = strtol(paused_tok, NULL, 10); 04752 if ((errno == ERANGE) || paused < 0 || paused > 1) { 04753 ast_log(LOG_WARNING, "Error converting paused: %s: Expected 0 or 1.\n", paused_tok); 04754 break; 04755 } 04756 04757 ast_debug(1, "Reload Members: Queue: %s Member: %s Name: %s Penalty: %d Paused: %d\n", queue_name, interface, membername, penalty, paused); 04758 04759 if (add_to_queue(queue_name, interface, membername, penalty, paused, 0, state_interface) == RES_OUTOFMEMORY) { 04760 ast_log(LOG_ERROR, "Out of Memory when reloading persistent queue member\n"); 04761 break; 04762 } 04763 } 04764 queue_t_unref(cur_queue, "Expire reload reference"); 04765 } 04766 04767 ao2_unlock(queues); 04768 if (db_tree) { 04769 ast_log(LOG_NOTICE, "Queue members successfully reloaded from database.\n"); 04770 ast_db_freetree(db_tree); 04771 } 04772 }
| static int reload_queue_rules | ( | int | reload | ) | [static] |
Reload the rules defined in queuerules.conf.
| reload | If 1, then only process queuerules.conf if the file has changed since the last time we inspected it. |
Definition at line 5651 of file app_queue.c.
References ast_calloc, ast_category_browse(), ast_config_destroy(), ast_config_load, ast_copy_string(), ast_free, AST_LIST_INSERT_TAIL, AST_LIST_LOCK, AST_LIST_REMOVE_HEAD, AST_LIST_UNLOCK, ast_log(), AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_SUCCESS, ast_variable_browse(), CONFIG_FLAG_FILEUNCHANGED, CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEUNCHANGED, insert_penaltychange(), ast_variable::lineno, LOG_ERROR, LOG_NOTICE, LOG_WARNING, ast_variable::name, rule_list::name, ast_variable::next, rule_list::rules, and ast_variable::value.
Referenced by reload_handler().
05652 { 05653 struct ast_config *cfg; 05654 struct rule_list *rl_iter, *new_rl; 05655 struct penalty_rule *pr_iter; 05656 char *rulecat = NULL; 05657 struct ast_variable *rulevar = NULL; 05658 struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; 05659 05660 if (!(cfg = ast_config_load("queuerules.conf", config_flags))) { 05661 ast_log(LOG_NOTICE, "No queuerules.conf file found, queues will not follow penalty rules\n"); 05662 return AST_MODULE_LOAD_SUCCESS; 05663 } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) { 05664 ast_log(LOG_NOTICE, "queuerules.conf has not changed since it was last loaded. Not taking any action.\n"); 05665 return AST_MODULE_LOAD_SUCCESS; 05666 } else if (cfg == CONFIG_STATUS_FILEINVALID) { 05667 ast_log(LOG_ERROR, "Config file queuerules.conf is in an invalid format. Aborting.\n"); 05668 return AST_MODULE_LOAD_SUCCESS; 05669 } 05670 05671 AST_LIST_LOCK(&rule_lists); 05672 while ((rl_iter = AST_LIST_REMOVE_HEAD(&rule_lists, list))) { 05673 while ((pr_iter = AST_LIST_REMOVE_HEAD(&rl_iter->rules, list))) 05674 ast_free(pr_iter); 05675 ast_free(rl_iter); 05676 } 05677 while ((rulecat = ast_category_browse(cfg, rulecat))) { 05678 if (!(new_rl = ast_calloc(1, sizeof(*new_rl)))) { 05679 AST_LIST_UNLOCK(&rule_lists); 05680 return AST_MODULE_LOAD_FAILURE; 05681 } else { 05682 ast_copy_string(new_rl->name, rulecat, sizeof(new_rl->name)); 05683 AST_LIST_INSERT_TAIL(&rule_lists, new_rl, list); 05684 for (rulevar = ast_variable_browse(cfg, rulecat); rulevar; rulevar = rulevar->next) 05685 if(!strcasecmp(rulevar->name, "penaltychange")) 05686 insert_penaltychange(new_rl->name, rulevar->value, rulevar->lineno); 05687 else 05688 ast_log(LOG_WARNING, "Don't know how to handle rule type '%s' on line %d\n", rulevar->name, rulevar->lineno); 05689 } 05690 } 05691 AST_LIST_UNLOCK(&rule_lists); 05692 05693 ast_config_destroy(cfg); 05694 05695 return AST_MODULE_LOAD_SUCCESS; 05696 }
| static int reload_queues | ( | int | reload, | |
| struct ast_flags * | mask, | |||
| const char * | queuename | |||
| ) | [static] |
reload the queues.conf file
This function reloads the information in the general section of the queues.conf file and potentially more, depending on the value of mask.
| reload | 0 if we are calling this the first time, 1 every other time | |
| mask | Gives flags telling us what information to actually reload | |
| queuename | If set to a non-zero string, then only reload information from that particular queue. Otherwise inspect all queues |
| -1 | Failure occurred | |
| 0 | All clear! |
Definition at line 5965 of file app_queue.c.
References ao2_callback, ao2_lock(), ao2_unlock(), ast_category_browse(), ast_config_destroy(), ast_config_load, ast_log(), ast_strlen_zero(), ast_test_flag, CONFIG_FLAG_FILEUNCHANGED, CONFIG_STATUS_FILEINVALID, CONFIG_STATUS_FILEUNCHANGED, kill_dead_queues(), LOG_ERROR, LOG_NOTICE, mark_dead_and_unfound(), OBJ_MULTIPLE, OBJ_NODATA, OBJ_UNLINK, QUEUE_RELOAD_PARAMETERS, queue_set_global_params(), queues, and reload_single_queue().
Referenced by reload_handler().
05966 { 05967 struct ast_config *cfg; 05968 char *cat; 05969 struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 }; 05970 const int queue_reload = ast_test_flag(mask, QUEUE_RELOAD_PARAMETERS); 05971 05972 if (!(cfg = ast_config_load("queues.conf", config_flags))) { 05973 ast_log(LOG_NOTICE, "No call queueing config file (queues.conf), so no call queues\n"); 05974 return -1; 05975 } else if (cfg == CONFIG_STATUS_FILEUNCHANGED) { 05976 return 0; 05977 } else if (cfg == CONFIG_STATUS_FILEINVALID) { 05978 ast_log(LOG_ERROR, "Config file queues.conf is in an invalid format. Aborting.\n"); 05979 return -1; 05980 } 05981 05982 /* We've made it here, so it looks like we're doing operations on all queues. */ 05983 ao2_lock(queues); 05984 05985 /* Mark all queues as dead for the moment if we're reloading queues. 05986 * For clarity, we could just be reloading members, in which case we don't want to mess 05987 * with the other queue parameters at all*/ 05988 if (queue_reload) { 05989 ao2_callback(queues, OBJ_NODATA, mark_dead_and_unfound, (char *) queuename); 05990 } 05991 05992 /* Chug through config file */ 05993 cat = NULL; 05994 while ((cat = ast_category_browse(cfg, cat)) ) { 05995 if (!strcasecmp(cat, "general") && queue_reload) { 05996 queue_set_global_params(cfg); 05997 continue; 05998 } 05999 if (ast_strlen_zero(queuename) || !strcasecmp(cat, queuename)) 06000 reload_single_queue(cfg, mask, cat); 06001 } 06002 06003 ast_config_destroy(cfg); 06004 /* Unref all the dead queues if we were reloading queues */ 06005 if (queue_reload) { 06006 ao2_callback(queues, OBJ_NODATA | OBJ_MULTIPLE | OBJ_UNLINK, kill_dead_queues, (char *) queuename); 06007 } 06008 ao2_unlock(queues); 06009 return 0; 06010 }
| static void reload_single_member | ( | const char * | memberdata, | |
| struct call_queue * | q | |||
| ) | [static] |
reload information pertaining to a single member
This function is called when a member = line is encountered in queues.conf.
| memberdata | The part after member = in the config file | |
| q | The queue to which this member belongs |
Definition at line 5729 of file app_queue.c.
References ao2_find, ao2_link, ao2_ref, AST_APP_ARG, ast_copy_string(), AST_DECLARE_APP_ARGS, ast_log(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strip(), ast_strlen_zero(), create_queue_member(), member::interface, LOG_WARNING, call_queue::membercount, call_queue::members, OBJ_POINTER, OBJ_UNLINK, parse(), member::paused, and member::penalty.
Referenced by reload_single_queue().
05730 { 05731 char *membername, *interface, *state_interface, *tmp; 05732 char *parse; 05733 struct member *cur, *newm; 05734 struct member tmpmem; 05735 int penalty; 05736 AST_DECLARE_APP_ARGS(args, 05737 AST_APP_ARG(interface); 05738 AST_APP_ARG(penalty); 05739 AST_APP_ARG(membername); 05740 AST_APP_ARG(state_interface); 05741 ); 05742 05743 if (ast_strlen_zero(memberdata)) { 05744 ast_log(LOG_WARNING, "Empty queue member definition. Moving on!\n"); 05745 return; 05746 } 05747 05748 /* Add a new member */ 05749 parse = ast_strdupa(memberdata); 05750 05751 AST_STANDARD_APP_ARGS(args, parse); 05752 05753 interface = args.interface; 05754 if (!ast_strlen_zero(args.penalty)) { 05755 tmp = args.penalty; 05756 ast_strip(tmp); 05757 penalty = atoi(tmp); 05758 if (penalty < 0) { 05759 penalty = 0; 05760 } 05761 } else { 05762 penalty = 0; 05763 } 05764 05765 if (!ast_strlen_zero(args.membername)) { 05766 membername = args.membername; 05767 ast_strip(membername); 05768 } else { 05769 membername = interface; 05770 } 05771 05772 if (!ast_strlen_zero(args.state_interface)) { 05773 state_interface = args.state_interface; 05774 ast_strip(state_interface); 05775 } else { 05776 state_interface = interface; 05777 } 05778 05779 /* Find the old position in the list */ 05780 ast_copy_string(tmpmem.interface, interface, sizeof(tmpmem.interface)); 05781 cur = ao2_find(q->members, &tmpmem, OBJ_POINTER | OBJ_UNLINK); 05782 if ((newm = create_queue_member(interface, membername, penalty, cur ? cur->paused : 0, state_interface))) { 05783 ao2_link(q->members, newm); 05784 ao2_ref(newm, -1); 05785 } 05786 newm = NULL; 05787 05788 if (cur) { 05789 ao2_ref(cur, -1); 05790 } else { 05791 q->membercount++; 05792 } 05793 }
| static void reload_single_queue | ( | struct ast_config * | cfg, | |
| struct ast_flags * | mask, | |||
| const char * | queuename | |||
| ) | [static] |
Reload information pertaining to a particular queue.
Once we have isolated a queue within reload_queues, we call this. This will either reload information for the queue or if we're just reloading member information, we'll just reload that without touching other settings within the queue
| cfg | The configuration which we are reading | |
| mask | Tells us what information we need to reload | |
| queuename | The name of the queue we are reloading information from |
| void |
Definition at line 5835 of file app_queue.c.
References alloc_queue(), ao2_callback, ao2_lock(), ao2_t_find, ao2_unlock(), ast_atomic_fetchadd_int(), ast_copy_string(), ast_log(), ast_test_flag, ast_variable_browse(), ast_variable_retrieve(), call_queue::found, init_queue(), kill_dead_members(), ast_variable::lineno, LOG_WARNING, mark_member_dead(), call_queue::membercount, call_queue::members, ast_variable::name, call_queue::name, ast_variable::next, OBJ_MULTIPLE, OBJ_NODATA, OBJ_POINTER, OBJ_UNLINK, QUEUE_RELOAD_MEMBER, QUEUE_RELOAD_PARAMETERS, queue_set_param(), QUEUE_STRATEGY_RINGALL, queue_t_unref, queues, queues_t_link, reload_single_member(), strat2int(), call_queue::strategy, ast_variable::value, var, and call_queue::weight.
Referenced by reload_queues().
05836 { 05837 int new; 05838 struct call_queue *q = NULL; 05839 /*We're defining a queue*/ 05840 struct call_queue tmpq; 05841 const char *tmpvar; 05842 const int queue_reload = ast_test_flag(mask, QUEUE_RELOAD_PARAMETERS); 05843 const int member_reload = ast_test_flag(mask, QUEUE_RELOAD_MEMBER); 05844 int prev_weight = 0; 05845 struct ast_variable *var; 05846 05847 ast_copy_string(tmpq.name, queuename, sizeof(tmpq.name)); 05848 if (!(q = ao2_t_find(queues, &tmpq, OBJ_POINTER, "Find queue for reload"))) { 05849 if (queue_reload) { 05850 /* Make one then */ 05851 if (!(q = alloc_queue(queuename))) { 05852 return; 05853 } 05854 } else { 05855 /* Since we're not reloading queues, this means that we found a queue 05856 * in the configuration file which we don't know about yet. Just return. 05857 */ 05858 return; 05859 } 05860 new = 1; 05861 } else { 05862 new = 0; 05863 } 05864 05865 if (!new) { 05866 ao2_lock(q); 05867 prev_weight = q->weight ? 1 : 0; 05868 } 05869 /* Check if we already found a queue with this name in the config file */ 05870 if (q->found) { 05871 ast_log(LOG_WARNING, "Queue '%s' already defined! Skipping!\n", queuename); 05872 if (!new) { 05873 /* It should be impossible to *not* hit this case*/ 05874 ao2_unlock(q); 05875 } 05876 queue_t_unref(q, "We exist! Expiring temporary pointer"); 05877 return; 05878 } 05879 /* Due to the fact that the "linear" strategy will have a different allocation 05880 * scheme for queue members, we must devise the queue's strategy before other initializations. 05881 * To be specific, the linear strategy needs to function like a linked list, meaning the ao2 05882 * container used will have only a single bucket instead of the typical number. 05883 */ 05884 if (queue_reload) { 05885 if ((tmpvar = ast_variable_retrieve(cfg, queuename, "strategy"))) { 05886 q->strategy = strat2int(tmpvar); 05887 if (q->strategy < 0) { 05888 ast_log(LOG_WARNING, "'%s' isn't a valid strategy for queue '%s', using ringall instead\n", 05889 tmpvar, q->name); 05890 q->strategy = QUEUE_STRATEGY_RINGALL; 05891 } 05892 } else { 05893 q->strategy = QUEUE_STRATEGY_RINGALL; 05894 } 05895 init_queue(q); 05896 } 05897 if (member_reload) { 05898 q->membercount = 0; 05899 ao2_callback(q->members, OBJ_NODATA, mark_member_dead, NULL); 05900 } 05901 for (var = ast_variable_browse(cfg, queuename); var; var = var->next) { 05902 if (member_reload && !strcasecmp(var->name, "member")) { 05903 reload_single_member(var->value, q); 05904 } else if (queue_reload) { 05905 queue_set_param(q, var->name, var->value, var->lineno, 1); 05906 } 05907 } 05908 /* At this point, we've determined if the queue has a weight, so update use_weight 05909 * as appropriate 05910 */ 05911 if (!q->weight && prev_weight) { 05912 ast_atomic_fetchadd_int(&use_weight, -1); 05913 } 05914 else if (q->weight && !prev_weight) { 05915 ast_atomic_fetchadd_int(&use_weight, +1); 05916 } 05917 05918 /* Free remaining members marked as delme */ 05919 if (member_reload) { 05920 ao2_callback(q->members, OBJ_NODATA | OBJ_MULTIPLE | OBJ_UNLINK, kill_dead_members, q); 05921 } 05922 05923 if (new) { 05924 queues_t_link(queues, q, "Add queue to container"); 05925 } else { 05926 ao2_unlock(q); 05927 } 05928 queue_t_unref(q, "Expiring creation reference"); 05929 }
| static int remove_from_queue | ( | const char * | queuename, | |
| const char * | interface | |||
| ) | [static] |
Remove member from queue.
| RES_NOT_DYNAMIC | when they aren't a RT member | |
| RES_NOSUCHQUEUE | queue does not exist | |
| RES_OKAY | removed member from queue | |
| RES_EXISTS | queue exists but no members |
Definition at line 4417 of file app_queue.c.
References ao2_find, ao2_lock(), ao2_ref, ao2_t_find, ao2_unlink, ao2_unlock(), ast_copy_string(), dump_queue_members(), member::dynamic, EVENT_FLAG_AGENT, member::interface, manager_event, call_queue::membercount, member::membername, call_queue::members, call_queue::name, OBJ_POINTER, queue_t_unref, queues, RES_EXISTS, RES_NOSUCHQUEUE, RES_NOT_DYNAMIC, and RES_OKAY.
Referenced by handle_queue_remove_member(), manager_remove_queue_member(), and rqm_exec().
04418 { 04419 struct call_queue *q, tmpq; 04420 struct member *mem, tmpmem; 04421 int res = RES_NOSUCHQUEUE; 04422 04423 ast_copy_string(tmpq.name, queuename, sizeof(tmpq.name)); 04424 ast_copy_string(tmpmem.interface, interface, sizeof(tmpmem.interface)); 04425 if ((q = ao2_t_find(queues, &tmpq, OBJ_POINTER, "Temporary reference for interface removal"))) { 04426 ao2_lock(queues); 04427 ao2_lock(q); 04428 if ((mem = ao2_find(q->members, &tmpmem, OBJ_POINTER))) { 04429 /* XXX future changes should beware of this assumption!! */ 04430 if (!mem->dynamic) { 04431 ao2_ref(mem, -1); 04432 ao2_unlock(q); 04433 queue_t_unref(q, "Interface wasn't dynamic, expiring temporary reference"); 04434 ao2_unlock(queues); 04435 return RES_NOT_DYNAMIC; 04436 } 04437 q->membercount--; 04438 manager_event(EVENT_FLAG_AGENT, "QueueMemberRemoved", 04439 "Queue: %s\r\n" 04440 "Location: %s\r\n" 04441 "MemberName: %s\r\n", 04442 q->name, mem->interface, mem->membername); 04443 ao2_unlink(q->members, mem); 04444 ao2_ref(mem, -1); 04445 04446 if (queue_persistent_members) 04447 dump_queue_members(q); 04448 04449 res = RES_OKAY; 04450 } else { 04451 res = RES_EXISTS; 04452 } 04453 ao2_unlock(q); 04454 ao2_unlock(queues); 04455 queue_t_unref(q, "Expiring temporary reference"); 04456 } 04457 04458 return res; 04459 }
| static int ring_entry | ( | struct queue_ent * | qe, | |
| struct callattempt * | tmp, | |||
| int * | busies | |||
| ) | [static] |
Part 2 of ring_one.
Does error checking before attempting to request a channel and call a member. This function is only called from ring_one(). Failure can occur if:
| 1 | on success to reach a free agent | |
| 0 | on failure to get agent. |
Definition at line 2478 of file app_queue.c.
References ast_cdr::accountcode, ast_channel::adsicpe, ast_cdr::amaflags, ao2_lock(), ao2_unlock(), ast_channel::appl, ast_call(), ast_cdr_busy(), ast_cdr_isset_unanswered(), ast_cdr_setdestchan(), ast_channel_datastore_inherit(), ast_channel_inherit_variables(), ast_channel_lock, ast_channel_unlock, ast_copy_string(), ast_debug, AST_DEVICE_NOT_INUSE, AST_DEVICE_UNKNOWN, AST_FLAG_ANSWERED_ELSEWHERE, ast_free, ast_request(), ast_set_flag, ast_strdup, ast_string_field_set, ast_strlen_zero(), ast_verb, queue_ent::cancel_answered_elsewhere, ast_channel::cdr, callattempt::chan, queue_ent::chan, ast_cdr::channel, ast_channel::cid, ast_callerid::cid_ani, ast_callerid::cid_name, ast_callerid::cid_num, ast_cdr::clid, compare_weight(), ast_channel::context, ast_channel::data, ast_cdr::dcontext, dialcontext, do_hang(), ast_cdr::dst, EVENT_FLAG_AGENT, call_queue::eventwhencalled, ast_channel::exten, callattempt::interface, ast_cdr::lastapp, callattempt::lastcall, ast_cdr::lastdata, callattempt::lastqueue, queue_ent::linpos, manager_event, callattempt::member, member::membername, ast_channel::name, call_queue::name, ast_channel::nativeformats, queue_ent::parent, member::paused, pbx_builtin_getvar_helper(), ast_channel::priority, QUEUE_EVENT_VARIABLES, call_queue::ringinuse, call_queue::rrpos, ast_cdr::src, member::state_interface, member::status, status, callattempt::stillgoing, ast_channel::uniqueid, update_status(), ast_cdr::userfield, vars2manager(), ast_channel::whentohangup, and call_queue::wrapuptime.
Referenced by ring_one().
02479 { 02480 int res; 02481 int status; 02482 char tech[256]; 02483 char *location; 02484 const char *macrocontext, *macroexten; 02485 02486 /* on entry here, we know that tmp->chan == NULL */ 02487 if ((tmp->lastqueue && tmp->lastqueue->wrapuptime && (time(NULL) - tmp->lastcall < tmp->lastqueue->wrapuptime)) || 02488 (!tmp->lastqueue && qe->parent->wrapuptime && (time(NULL) - tmp->lastcall < qe->parent->wrapuptime))) { 02489 ast_debug(1, "Wrapuptime not yet expired on queue %s for %s\n", 02490 (tmp->lastqueue ? tmp->lastqueue->name : qe->parent->name), tmp->interface); 02491 if (qe->chan->cdr) 02492 ast_cdr_busy(qe->chan->cdr); 02493 tmp->stillgoing = 0; 02494 (*busies)++; 02495 return 0; 02496 } 02497 02498 if (!qe->parent->ringinuse && (tmp->member->status != AST_DEVICE_NOT_INUSE) && (tmp->member->status != AST_DEVICE_UNKNOWN)) { 02499 ast_debug(1, "%s in use, can't receive call\n", tmp->interface); 02500 if (qe->chan->cdr) 02501 ast_cdr_busy(qe->chan->cdr); 02502 tmp->stillgoing = 0; 02503 return 0; 02504 } 02505 02506 if (tmp->member->paused) { 02507 ast_debug(1, "%s paused, can't receive call\n", tmp->interface); 02508 if (qe->chan->cdr) 02509 ast_cdr_busy(qe->chan->cdr); 02510 tmp->stillgoing = 0; 02511 return 0; 02512 } 02513 if (use_weight && compare_weight(qe->parent,tmp->member)) { 02514 ast_debug(1, "Priority queue delaying call to %s:%s\n", qe->parent->name, tmp->interface); 02515 if (qe->chan->cdr) 02516 ast_cdr_busy(qe->chan->cdr); 02517 tmp->stillgoing = 0; 02518 (*busies)++; 02519 return 0; 02520 } 02521 02522 ast_copy_string(tech, tmp->interface, sizeof(tech)); 02523 if ((location = strchr(tech, '/'))) 02524 *location++ = '\0'; 02525 else 02526 location = ""; 02527 02528 /* Request the peer */ 02529 tmp->chan = ast_request(tech, qe->chan->nativeformats, location, &status); 02530 if (!tmp->chan) { /* If we can't, just go on to the next call */ 02531 if (qe->chan->cdr) 02532 ast_cdr_busy(qe->chan->cdr); 02533 tmp->stillgoing = 0; 02534 02535 ao2_lock(qe->parent); 02536 update_status(qe->parent, tmp->member, ast_device_state(tmp->member->state_interface)); 02537 qe->parent->rrpos++; 02538 qe->linpos++; 02539 ao2_unlock(qe->parent); 02540 02541 (*busies)++; 02542 return 0; 02543 } 02544 02545 if (qe->cancel_answered_elsewhere) { 02546 ast_set_flag(tmp->chan, AST_FLAG_ANSWERED_ELSEWHERE); 02547 } 02548 tmp->chan->appl = "AppQueue"; 02549 tmp->chan->data = "(Outgoing Line)"; 02550 memset(&tmp->chan->whentohangup, 0, sizeof(tmp->chan->whentohangup)); 02551 if (tmp->chan->cid.cid_num) 02552 ast_free(tmp->chan->cid.cid_num); 02553 tmp->chan->cid.cid_num = ast_strdup(qe->chan->cid.cid_num); 02554 if (tmp->chan->cid.cid_name) 02555 ast_free(tmp->chan->cid.cid_name); 02556 tmp->chan->cid.cid_name = ast_strdup(qe->chan->cid.cid_name); 02557 if (tmp->chan->cid.cid_ani) 02558 ast_free(tmp->chan->cid.cid_ani); 02559 tmp->chan->cid.cid_ani = ast_strdup(qe->chan->cid.cid_ani); 02560 02561 /* Inherit specially named variables from parent channel */ 02562 ast_channel_inherit_variables(qe->chan, tmp->chan); 02563 ast_channel_datastore_inherit(qe->chan, tmp->chan); 02564 02565 /* Presense of ADSI CPE on outgoing channel follows ours */ 02566 tmp->chan->adsicpe = qe->chan->adsicpe; 02567 02568 /* Inherit context and extension */ 02569 ast_channel_lock(qe->chan); 02570 macrocontext = pbx_builtin_getvar_helper(qe->chan, "MACRO_CONTEXT"); 02571 ast_string_field_set(tmp->chan, dialcontext, ast_strlen_zero(macrocontext) ? qe->chan->context : macrocontext); 02572 macroexten = pbx_builtin_getvar_helper(qe->chan, "MACRO_EXTEN"); 02573 if (!ast_strlen_zero(macroexten)) 02574 ast_copy_string(tmp->chan->exten, macroexten, sizeof(tmp->chan->exten)); 02575 else 02576 ast_copy_string(tmp->chan->exten, qe->chan->exten, sizeof(tmp->chan->exten)); 02577 if (ast_cdr_isset_unanswered()) { 02578 /* they want to see the unanswered dial attempts! */ 02579 /* set up the CDR fields on all the CDRs to give sensical information */ 02580 ast_cdr_setdestchan(tmp->chan->cdr, tmp->chan->name); 02581 strcpy(tmp->chan->cdr->clid, qe->chan->cdr->clid); 02582 strcpy(tmp->chan->cdr->channel, qe->chan->cdr->channel); 02583 strcpy(tmp->chan->cdr->src, qe->chan->cdr->src); 02584 strcpy(tmp->chan->cdr->dst, qe->chan->exten); 02585 strcpy(tmp->chan->cdr->dcontext, qe->chan->context); 02586 strcpy(tmp->chan->cdr->lastapp, qe->chan->cdr->lastapp); 02587 strcpy(tmp->chan->cdr->lastdata, qe->chan->cdr->lastdata); 02588 tmp->chan->cdr->amaflags = qe->chan->cdr->amaflags; 02589 strcpy(tmp->chan->cdr->accountcode, qe->chan->cdr->accountcode); 02590 strcpy(tmp->chan->cdr->userfield, qe->chan->cdr->userfield); 02591 } 02592 ast_channel_unlock(qe->chan); 02593 02594 /* Place the call, but don't wait on the answer */ 02595 if ((res = ast_call(tmp->chan, location, 0))) { 02596 /* Again, keep going even if there's an error */ 02597 ast_debug(1, "ast call on peer returned %d\n", res); 02598 ast_verb(3, "Couldn't call %s\n", tmp->interface); 02599 do_hang(tmp); 02600 (*busies)++; 02601 update_status(qe->parent, tmp->member, ast_device_state(tmp->member->state_interface)); 02602 return 0; 02603 } else if (qe->parent->eventwhencalled) { 02604 char vars[2048]; 02605 02606 manager_event(EVENT_FLAG_AGENT, "AgentCalled", 02607 "Queue: %s\r\n" 02608 "AgentCalled: %s\r\n" 02609 "AgentName: %s\r\n" 02610 "ChannelCalling: %s\r\n" 02611 "DestinationChannel: %s\r\n" 02612 "CallerIDNum: %s\r\n" 02613 "CallerIDName: %s\r\n" 02614 "Context: %s\r\n" 02615 "Extension: %s\r\n" 02616 "Priority: %d\r\n" 02617 "Uniqueid: %s\r\n" 02618 "%s", 02619 qe->parent->name, tmp->interface, tmp->member->membername, qe->chan->name, tmp->chan->name, 02620 tmp->chan->cid.cid_num ? tmp->chan->cid.cid_num : "unknown", 02621 tmp->chan->cid.cid_name ? tmp->chan->cid.cid_name : "unknown", 02622 qe->chan->context, qe->chan->exten, qe->chan->priority, qe->chan->uniqueid, 02623 qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES ? vars2manager(qe->chan, vars, sizeof(vars)) : ""); 02624 ast_verb(3, "Called %s\n", tmp->interface); 02625 } 02626 02627 update_status(qe->parent, tmp->member, ast_device_state(tmp->member->state_interface)); 02628 return 1; 02629 }
| static int ring_one | ( | struct queue_ent * | qe, | |
| struct callattempt * | outgoing, | |||
| int * | busies | |||
| ) | [static] |
Place a call to a queue member.
Once metrics have been calculated for each member, this function is used to place a call to the appropriate member (or members). The low-level channel-handling and error detection is handled in ring_entry
| 1 | if a member was called successfully | |
| 0 | otherwise |
Definition at line 2657 of file app_queue.c.
References ast_debug, callattempt::chan, queue_ent::expire, find_best(), callattempt::interface, callattempt::metric, queue_ent::parent, callattempt::q_next, QUEUE_STRATEGY_RINGALL, ring_entry(), callattempt::stillgoing, and call_queue::strategy.
Referenced by try_calling(), and wait_for_answer().
02658 { 02659 int ret = 0; 02660 02661 while (ret == 0) { 02662 struct callattempt *best = find_best(outgoing); 02663 if (!best) { 02664 ast_debug(1, "Nobody left to try ringing in queue\n"); 02665 break; 02666 } 02667 if (qe->parent->strategy == QUEUE_STRATEGY_RINGALL) { 02668 struct callattempt *cur; 02669 /* Ring everyone who shares this best metric (for ringall) */ 02670 for (cur = outgoing; cur; cur = cur->q_next) { 02671 if (cur->stillgoing && !cur->chan && cur->metric <= best->metric) { 02672 ast_debug(1, "(Parallel) Trying '%s' with metric %d\n", cur->interface, cur->metric); 02673 ret |= ring_entry(qe, cur, busies); 02674 } 02675 } 02676 } else { 02677 /* Ring just the best channel */ 02678 ast_debug(1, "Trying '%s' with metric %d\n", best->interface, best->metric); 02679 ret = ring_entry(qe, best, busies); 02680 } 02681 02682 /* If we have timed out, break out */ 02683 if (qe->expire && (time(NULL) >= qe->expire)) { 02684 ast_debug(1, "Queue timed out while ringing members.\n"); 02685 ret = 0; 02686 break; 02687 } 02688 } 02689 02690 return ret; 02691 }
| static void rna | ( | int | rnatime, | |
| struct queue_ent * | qe, | |||
| char * | interface, | |||
| char * | membername, | |||
| int | pause | |||
| ) | [static] |
RNA == Ring No Answer. Common code that is executed when we try a queue member and they don't answer.
Definition at line 2812 of file app_queue.c.
References ast_queue_log(), ast_verb, call_queue::autopause, queue_ent::chan, EVENT_FLAG_AGENT, call_queue::eventwhencalled, manager_event, ast_channel::name, call_queue::name, queue_ent::parent, QUEUE_EVENT_VARIABLES, set_member_paused(), ast_channel::uniqueid, and vars2manager().
Referenced by wait_for_answer().
02813 { 02814 ast_verb(3, "Nobody picked up in %d ms\n", rnatime); 02815 if (qe->parent->eventwhencalled) { 02816 char vars[2048]; 02817 02818 manager_event(EVENT_FLAG_AGENT, "AgentRingNoAnswer", 02819 "Queue: %s\r\n" 02820 "Uniqueid: %s\r\n" 02821 "Channel: %s\r\n" 02822 "Member: %s\r\n" 02823 "MemberName: %s\r\n" 02824 "Ringtime: %d\r\n" 02825 "%s", 02826 qe->parent->name, 02827 qe->chan->uniqueid, 02828 qe->chan->name, 02829 interface, 02830 membername, 02831 rnatime, 02832 qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES ? vars2manager(qe->chan, vars, sizeof(vars)) : ""); 02833 } 02834 ast_queue_log(qe->parent->name, qe->chan->uniqueid, membername, "RINGNOANSWER", "%d", rnatime); 02835 if (qe->parent->autopause && pause) { 02836 if (!set_member_paused(qe->parent->name, interface, "Auto-Pause", 1)) { 02837 ast_verb(3, "Auto-Pausing Queue Member %s in queue %s since they failed to answer.\n", interface, qe->parent->name); 02838 } else { 02839 ast_verb(3, "Failed to pause Queue Member %s in queue %s!\n", interface, qe->parent->name); 02840 } 02841 } 02842 return; 02843 }
| static int rqm_exec | ( | struct ast_channel * | chan, | |
| void * | data | |||
| ) | [static] |
RemoveQueueMember application.
Definition at line 4847 of file app_queue.c.
References AST_APP_ARG, ast_debug, AST_DECLARE_APP_ARGS, ast_log(), ast_queue_log(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), LOG_NOTICE, LOG_WARNING, ast_channel::name, parse(), pbx_builtin_setvar_helper(), remove_from_queue(), RES_EXISTS, RES_NOSUCHQUEUE, RES_NOT_DYNAMIC, RES_OKAY, and ast_channel::uniqueid.
Referenced by load_module().
04848 { 04849 int res=-1; 04850 char *parse, *temppos = NULL; 04851 AST_DECLARE_APP_ARGS(args, 04852 AST_APP_ARG(queuename); 04853 AST_APP_ARG(interface); 04854 AST_APP_ARG(options); 04855 ); 04856 04857 04858 if (ast_strlen_zero(data)) { 04859 ast_log(LOG_WARNING, "RemoveQueueMember requires an argument (queuename[,interface[,options]])\n"); 04860 return -1; 04861 } 04862 04863 parse = ast_strdupa(data); 04864 04865 AST_STANDARD_APP_ARGS(args, parse); 04866 04867 if (ast_strlen_zero(args.interface)) { 04868 args.interface = ast_strdupa(chan->name); 04869 temppos = strrchr(args.interface, '-'); 04870 if (temppos) 04871 *temppos = '\0'; 04872 } 04873 04874 ast_debug(1, "queue: %s, member: %s\n", args.queuename, args.interface); 04875 04876 switch (remove_from_queue(args.queuename, args.interface)) { 04877 case RES_OKAY: 04878 ast_queue_log(args.queuename, chan->uniqueid, args.interface, "REMOVEMEMBER", "%s", ""); 04879 ast_log(LOG_NOTICE, "Removed interface '%s' from queue '%s'\n", args.interface, args.queuename); 04880 pbx_builtin_setvar_helper(chan, "RQMSTATUS", "REMOVED"); 04881 res = 0; 04882 break; 04883 case RES_EXISTS: 04884 ast_debug(1, "Unable to remove interface '%s' from queue '%s': Not there\n", args.interface, args.queuename); 04885 pbx_builtin_setvar_helper(chan, "RQMSTATUS", "NOTINQUEUE"); 04886 res = 0; 04887 break; 04888 case RES_NOSUCHQUEUE: 04889 ast_log(LOG_WARNING, "Unable to remove interface from queue '%s': No such queue\n", args.queuename); 04890 pbx_builtin_setvar_helper(chan, "RQMSTATUS", "NOSUCHQUEUE"); 04891 res = 0; 04892 break; 04893 case RES_NOT_DYNAMIC: 04894 ast_log(LOG_WARNING, "Unable to remove interface from queue '%s': '%s' is not a dynamic member\n", args.queuename, args.interface); 04895 pbx_builtin_setvar_helper(chan, "RQMSTATUS", "NOTDYNAMIC"); 04896 res = 0; 04897 break; 04898 } 04899 04900 return res; 04901 }
| static void rt_handle_member_record | ( | struct call_queue * | q, | |
| char * | interface, | |||
| const char * | rt_uniqueid, | |||
| const char * | membername, | |||
| const char * | penalty_str, | |||
| const char * | paused_str, | |||
| const char * | state_interface | |||
| ) | [static] |
Find rt member record to update otherwise create one.
Search for member in queue, if found update penalty/paused state, if no member exists create one flag it as a RT member and add to queue member list.
Definition at line 1593 of file app_queue.c.
References ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_link, ao2_ref, ast_copy_string(), ast_log(), ast_queue_log(), ast_strlen_zero(), create_queue_member(), member::dead, member::interface, LOG_WARNING, call_queue::membercount, call_queue::members, call_queue::name, member::paused, member::penalty, member::realtime, member::rt_uniqueid, S_OR, and member::state_interface.
Referenced by find_queue_by_name_rt(), and update_realtime_members().
01594 { 01595 struct member *m; 01596 struct ao2_iterator mem_iter; 01597 int penalty = 0; 01598 int paused = 0; 01599 int found = 0; 01600 01601 if (ast_strlen_zero(rt_uniqueid)) { 01602 ast_log(LOG_WARNING, "Realtime field uniqueid is empty for member %s\n", S_OR(membername, "NULL")); 01603 return; 01604 } 01605 01606 if (penalty_str) { 01607 penalty = atoi(penalty_str); 01608 if (penalty < 0) 01609 penalty = 0; 01610 } 01611 01612 if (paused_str) { 01613 paused = atoi(paused_str); 01614 if (paused < 0) 01615 paused = 0; 01616 } 01617 01618 /* Find member by realtime uniqueid and update */ 01619 mem_iter = ao2_iterator_init(q->members, 0); 01620 while ((m = ao2_iterator_next(&mem_iter))) { 01621 if (!strcasecmp(m->rt_uniqueid, rt_uniqueid)) { 01622 m->dead = 0; /* Do not delete this one. */ 01623 ast_copy_string(m->rt_uniqueid, rt_uniqueid, sizeof(m->rt_uniqueid)); 01624 if (paused_str) 01625 m->paused = paused; 01626 if (strcasecmp(state_interface, m->state_interface)) { 01627 ast_copy_string(m->state_interface, state_interface, sizeof(m->state_interface)); 01628 } 01629 m->penalty = penalty; 01630 found = 1; 01631 ao2_ref(m, -1); 01632 break; 01633 } 01634 ao2_ref(m, -1); 01635 } 01636 ao2_iterator_destroy(&mem_iter); 01637 01638 /* Create a new member */ 01639 if (!found) { 01640 if ((m = create_queue_member(interface, membername, penalty, paused, state_interface))) { 01641 m->dead = 0; 01642 m->realtime = 1; 01643 ast_copy_string(m->rt_uniqueid, rt_uniqueid, sizeof(m->rt_uniqueid)); 01644 ast_queue_log(q->name, "REALTIME", m->interface, "ADDMEMBER", "%s", ""); 01645 ao2_link(q->members, m); 01646 ao2_ref(m, -1); 01647 m = NULL; 01648 q->membercount++; 01649 } 01650 } 01651 }
| static int say_periodic_announcement | ( | struct queue_ent * | qe, | |
| int | ringing | |||
| ) | [static] |
Playback announcement to queued members if peroid has elapsed.
Definition at line 2742 of file app_queue.c.
References AST_CONTROL_RINGING, ast_indicate(), ast_moh_start(), ast_moh_stop(), ast_random(), ast_str_buffer(), ast_str_strlen(), ast_verb, queue_ent::chan, queue_ent::last_periodic_announce_sound, queue_ent::last_periodic_announce_time, queue_ent::moh, call_queue::numperiodicannounce, queue_ent::parent, call_queue::periodicannouncefrequency, play_file(), call_queue::randomperiodicannounce, call_queue::sound_periodicannounce, and valid_exit().
Referenced by queue_exec(), and wait_our_turn().
02743 { 02744 int res = 0; 02745 time_t now; 02746 02747 /* Get the current time */ 02748 time(&now); 02749 02750 /* Check to see if it is time to announce */ 02751 if ((now - qe->last_periodic_announce_time) < qe->parent->periodicannouncefrequency) 02752 return 0; 02753 02754 /* Stop the music on hold so we can play our own file */ 02755 if (ringing) 02756 ast_indicate(qe->chan,-1); 02757 else 02758 ast_moh_stop(qe->chan); 02759 02760 ast_verb(3, "Playing periodic announcement\n"); 02761 02762 if (qe->parent->randomperiodicannounce && qe->parent->numperiodicannounce) { 02763 qe->last_periodic_announce_sound = ((unsigned long) ast_random()) % qe->parent->numperiodicannounce; 02764 } else if (qe->last_periodic_announce_sound >= qe->parent->numperiodicannounce || 02765 ast_str_strlen(qe->parent->sound_periodicannounce[qe->last_periodic_announce_sound]) == 0) { 02766 qe->last_periodic_announce_sound = 0; 02767 } 02768 02769 /* play the announcement */ 02770 res = play_file(qe->chan, ast_str_buffer(qe->parent->sound_periodicannounce[qe->last_periodic_announce_sound])); 02771 02772 if (res > 0 && !valid_exit(qe, res)) 02773 res = 0; 02774 02775 /* Resume Music on Hold if the caller is going to stay in the queue */ 02776 if (!res) { 02777 if (ringing) 02778 ast_indicate(qe->chan, AST_CONTROL_RINGING); 02779 else 02780 ast_moh_start(qe->chan, qe->moh, NULL); 02781 } 02782 02783 /* update last_periodic_announce_time */ 02784 qe->last_periodic_announce_time = now; 02785 02786 /* Update the current periodic announcement to the next announcement */ 02787 if (!qe->parent->randomperiodicannounce) { 02788 qe->last_periodic_announce_sound++; 02789 } 02790 02791 return res; 02792 }
| static int say_position | ( | struct queue_ent * | qe, | |
| int | ringing | |||
| ) | [static] |
Definition at line 2091 of file app_queue.c.
References call_queue::announcefrequency, call_queue::announceholdtime, ANNOUNCEHOLDTIME_ONCE, call_queue::announceposition, ANNOUNCEPOSITION_LIMIT, ANNOUNCEPOSITION_MORE_THAN, ANNOUNCEPOSITION_YES, call_queue::announcepositionlimit, AST_CONTROL_RINGING, AST_DIGIT_ANY, ast_indicate(), ast_moh_start(), ast_moh_stop(), ast_say_number(), ast_verb, queue_ent::chan, call_queue::holdtime, ast_channel::language, queue_ent::last_pos, queue_ent::last_pos_said, call_queue::minannouncefrequency, queue_ent::moh, ast_channel::name, call_queue::name, queue_ent::parent, play_file(), queue_ent::pos, call_queue::queue_quantity1, call_queue::queue_quantity2, call_queue::roundingseconds, call_queue::sound_calls, call_queue::sound_holdtime, call_queue::sound_minute, call_queue::sound_minutes, call_queue::sound_next, call_queue::sound_seconds, call_queue::sound_thanks, call_queue::sound_thereare, queue_ent::start, and valid_exit().
Referenced by queue_exec(), and wait_our_turn().
02092 { 02093 int res = 0, avgholdmins, avgholdsecs, announceposition = 0; 02094 int say_thanks = 1; 02095 time_t now; 02096 02097 /* Let minannouncefrequency seconds pass between the start of each position announcement */ 02098 time(&now); 02099 if ((now - qe->last_pos) < qe->parent->minannouncefrequency) 02100 return 0; 02101 02102 /* If either our position has changed, or we are over the freq timer, say position */ 02103 if ((qe->last_pos_said == qe->pos) && ((now - qe->last_pos) < qe->parent->announcefrequency)) 02104 return 0; 02105 02106 if (ringing) { 02107 ast_indicate(qe->chan,-1); 02108 } else { 02109 ast_moh_stop(qe->chan); 02110 } 02111 02112 if (qe->parent->announceposition == ANNOUNCEPOSITION_YES || 02113 qe->parent->announceposition == ANNOUNCEPOSITION_MORE_THAN || 02114 (qe->parent->announceposition == ANNOUNCEPOSITION_LIMIT && 02115 qe->pos <= qe->parent->announcepositionlimit)) 02116 announceposition = 1; 02117 02118 02119 if (announceposition == 1) { 02120 /* Say we're next, if we are */ 02121 if (qe->pos == 1) { 02122 res = play_file(qe->chan, qe->parent->sound_next); 02123 if (res) 02124 goto playout; 02125 else 02126 goto posout; 02127 } else { 02128 if (qe->parent->announceposition == ANNOUNCEPOSITION_MORE_THAN && qe->pos > qe->parent->announcepositionlimit){ 02129 /* More than Case*/ 02130 res = play_file(qe->chan, qe->parent->queue_quantity1); 02131 if (res) 02132 goto playout; 02133 res = ast_say_number(qe->chan, qe->parent->announcepositionlimit, AST_DIGIT_ANY, qe->chan->language, NULL); /* Needs gender */ 02134 if (res) 02135 goto playout; 02136 } else { 02137 /* Normal Case */ 02138 res = play_file(qe->chan, qe->parent->sound_thereare); 02139 if (res) 02140 goto playout; 02141 res = ast_say_number(qe->chan, qe->pos, AST_DIGIT_ANY, qe->chan->language, NULL); /* Needs gender */ 02142 if (res) 02143 goto playout; 02144 } 02145 if (qe->parent->announceposition == ANNOUNCEPOSITION_MORE_THAN && qe->pos > qe->parent->announcepositionlimit){ 02146 /* More than Case*/ 02147 res = play_file(qe->chan, qe->parent->queue_quantity2); 02148 if (res) 02149 goto playout; 02150 } else { 02151 res = play_file(qe->chan, qe->parent->sound_calls); 02152 if (res) 02153 goto playout; 02154 } 02155 } 02156 } 02157 /* Round hold time to nearest minute */ 02158 avgholdmins = abs(((qe->parent->holdtime + 30) - (now - qe->start)) / 60); 02159 02160 /* If they have specified a rounding then round the seconds as well */ 02161 if (qe->parent->roundingseconds) { 02162 avgholdsecs = (abs(((qe->parent->holdtime + 30) - (now - qe->start))) - 60 * avgholdmins) / qe->parent->roundingseconds; 02163 avgholdsecs *= qe->parent->roundingseconds; 02164 } else { 02165 avgholdsecs = 0; 02166 } 02167 02168 ast_verb(3, "Hold time for %s is %d minute(s) %d seconds\n", qe->parent->name, avgholdmins, avgholdsecs); 02169 02170 /* If the hold time is >1 min, if it's enabled, and if it's not 02171 supposed to be only once and we have already said it, say it */ 02172 if ((avgholdmins+avgholdsecs) > 0 && qe->parent->announceholdtime && 02173 ((qe->parent->announceholdtime == ANNOUNCEHOLDTIME_ONCE && !qe->last_pos) || 02174 !(qe->parent->announceholdtime == ANNOUNCEHOLDTIME_ONCE))) { 02175 res = play_file(qe->chan, qe->parent->sound_holdtime); 02176 if (res) 02177 goto playout; 02178 02179 if (avgholdmins >= 1) { 02180 res = ast_say_number(qe->chan, avgholdmins, AST_DIGIT_ANY, qe->chan->language, NULL); 02181 if (res) 02182 goto playout; 02183 02184 if (avgholdmins == 1) { 02185 res = play_file(qe->chan, qe->parent->sound_minute); 02186 if (res) 02187 goto playout; 02188 } else { 02189 res = play_file(qe->chan, qe->parent->sound_minutes); 02190 if (res) 02191 goto playout; 02192 } 02193 } 02194 if (avgholdsecs >= 1) { 02195 res = ast_say_number(qe->chan, avgholdsecs, AST_DIGIT_ANY, qe->chan->language, NULL); 02196 if (res) 02197 goto playout; 02198 02199 res = play_file(qe->chan, qe->parent->sound_seconds); 02200 if (res) 02201 goto playout; 02202 } 02203 } else if (qe->parent->announceholdtime && !qe->parent->announceposition) { 02204 say_thanks = 0; 02205 } 02206 02207 posout: 02208 if (qe->parent->announceposition) { 02209 ast_verb(3, "Told %s in %s their queue position (which was %d)\n", 02210 qe->chan->name, qe->parent->name, qe->pos); 02211 } 02212 if (say_thanks) { 02213 res = play_file(qe->chan, qe->parent->sound_thanks); 02214 } 02215 playout: 02216 02217 if ((res > 0 && !valid_exit(qe, res))) 02218 res = 0; 02219 02220 /* Set our last_pos indicators */ 02221 qe->last_pos = now; 02222 qe->last_pos_said = qe->pos; 02223 02224 /* Don't restart music on hold if we're about to exit the caller from the queue */ 02225 if (!res) { 02226 if (ringing) { 02227 ast_indicate(qe->chan, AST_CONTROL_RINGING); 02228 } else { 02229 ast_moh_start(qe->chan, qe->moh, NULL); 02230 } 02231 } 02232 return res; 02233 }
| static void send_agent_complete | ( | const struct queue_ent * | qe, | |
| const char * | queuename, | |||
| const struct ast_channel * | peer, | |||
| const struct member * | member, | |||
| time_t | callstart, | |||
| char * | vars, | |||
| size_t | vars_len, | |||
| enum agent_complete_reason | rsn | |||
| ) | [static] |
Send out AMI message with member call completion status information.
Definition at line 3394 of file app_queue.c.
References AGENT, CALLER, queue_ent::chan, EVENT_FLAG_AGENT, call_queue::eventwhencalled, member::interface, manager_event, member::membername, ast_channel::name, queue_ent::parent, QUEUE_EVENT_VARIABLES, queue_ent::start, TRANSFER, ast_channel::uniqueid, and vars2manager().
Referenced by try_calling().
03397 { 03398 const char *reason = NULL; /* silence dumb compilers */ 03399 03400 if (!qe->parent->eventwhencalled) 03401 return; 03402 03403 switch (rsn) { 03404 case CALLER: 03405 reason = "caller"; 03406 break; 03407 case AGENT: 03408 reason = "agent"; 03409 break; 03410 case TRANSFER: 03411 reason = "transfer"; 03412 break; 03413 } 03414 03415 manager_event(EVENT_FLAG_AGENT, "AgentComplete", 03416 "Queue: %s\r\n" 03417 "Uniqueid: %s\r\n" 03418 "Channel: %s\r\n" 03419 "Member: %s\r\n" 03420 "MemberName: %s\r\n" 03421 "HoldTime: %ld\r\n" 03422 "TalkTime: %ld\r\n" 03423 "Reason: %s\r\n" 03424 "%s", 03425 queuename, qe->chan->uniqueid, peer->name, member->interface, member->membername, 03426 (long)(callstart - qe->start), (long)(time(NULL) - callstart), reason, 03427 qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES ? vars2manager(qe->chan, vars, vars_len) : ""); 03428 }
| static int set_member_paused | ( | const char * | queuename, | |
| const char * | interface, | |||
| const char * | reason, | |||
| int | paused | |||
| ) | [static] |
Definition at line 4522 of file app_queue.c.
References ao2_iterator_destroy(), ao2_iterator_init(), ao2_lock(), ao2_ref, ao2_t_iterator_next, ao2_unlock(), ast_debug, ast_log(), ast_queue_log(), ast_strlen_zero(), dump_queue_members(), EVENT_FLAG_AGENT, member::interface, interface_exists(), LOG_WARNING, manager_event, member::membername, call_queue::name, member::paused, queue_t_unref, queues, member::realtime, RESULT_FAILURE, RESULT_SUCCESS, S_OR, and update_realtime_member_field().
Referenced by handle_queue_pause_member(), manager_pause_queue_member(), pqm_exec(), rna(), and upqm_exec().
04523 { 04524 int found = 0; 04525 struct call_queue *q; 04526 struct member *mem; 04527 struct ao2_iterator queue_iter; 04528 int failed; 04529 04530 /* Special event for when all queues are paused - individual events still generated */ 04531 /* XXX In all other cases, we use the membername, but since this affects all queues, we cannot */ 04532 if (ast_strlen_zero(queuename)) 04533 ast_queue_log("NONE", "NONE", interface, (paused ? "PAUSEALL" : "UNPAUSEALL"), "%s", ""); 04534 04535 queue_iter = ao2_iterator_init(queues, 0); 04536 while ((q = ao2_t_iterator_next(&queue_iter, "Iterate over queues"))) { 04537 ao2_lock(q); 04538 if (ast_strlen_zero(queuename) || !strcasecmp(q->name, queuename)) { 04539 if ((mem = interface_exists(q, interface))) { 04540 if (mem->paused == paused) { 04541 ast_debug(1, "%spausing already-%spaused queue member %s:%s\n", (paused ? "" : "un"), (paused ? "" : "un"), q->name, interface); 04542 } 04543 04544 failed = 0; 04545 if (mem->realtime) { 04546 failed = update_realtime_member_field(mem, q->name, "paused", paused ? "1" : "0"); 04547 } 04548 04549 if (failed) { 04550 ast_log(LOG_WARNING, "Failed %spausing realtime queue member %s:%s\n", (paused ? "" : "un"), q->name, interface); 04551 ao2_ref(mem, -1); 04552 ao2_unlock(q); 04553 queue_t_unref(q, "Done with iterator"); 04554 continue; 04555 } 04556 found++; 04557 mem->paused = paused; 04558 04559 if (queue_persistent_members) 04560 dump_queue_members(q); 04561 04562 ast_queue_log(q->name, "NONE", mem->membername, (paused ? "PAUSE" : "UNPAUSE"), "%s", S_OR(reason, "")); 04563 04564 if (!ast_strlen_zero(reason)) { 04565 manager_event(EVENT_FLAG_AGENT, "QueueMemberPaused", 04566 "Queue: %s\r\n" 04567 "Location: %s\r\n" 04568 "MemberName: %s\r\n" 04569 "Paused: %d\r\n" 04570 "Reason: %s\r\n", 04571 q->name, mem->interface, mem->membername, paused, reason); 04572 } else { 04573 manager_event(EVENT_FLAG_AGENT, "QueueMemberPaused", 04574 "Queue: %s\r\n" 04575 "Location: %s\r\n" 04576 "MemberName: %s\r\n" 04577 "Paused: %d\r\n", 04578 q->name, mem->interface, mem->membername, paused); 04579 } 04580 ao2_ref(mem, -1); 04581 } 04582 } 04583 04584 if (!ast_strlen_zero(queuename) && !strcasecmp(queuename, q->name)) { 04585 ao2_unlock(q); 04586 queue_t_unref(q, "Done with iterator"); 04587 break; 04588 } 04589 04590 ao2_unlock(q); 04591 queue_t_unref(q, "Done with iterator"); 04592 } 04593 ao2_iterator_destroy(&queue_iter); 04594 04595 return found ? RESULT_SUCCESS : RESULT_FAILURE; 04596 }
| static int set_member_penalty | ( | char * | queuename, | |
| char * | interface, | |||
| int | penalty | |||
| ) | [static] |
Definition at line 4599 of file app_queue.c.
References ao2_iterator_destroy(), ao2_iterator_init(), ao2_lock(), ao2_ref, ao2_t_iterator_next, ao2_unlock(), ast_log(), ast_queue_log(), ast_strlen_zero(), EVENT_FLAG_AGENT, member::interface, interface_exists(), LOG_ERROR, manager_event, call_queue::name, member::penalty, queue_t_unref, queues, RESULT_FAILURE, and RESULT_SUCCESS.
Referenced by handle_queue_set_member_penalty(), manager_queue_member_penalty(), and queue_function_memberpenalty_write().
04600 { 04601 int foundinterface = 0, foundqueue = 0; 04602 struct call_queue *q; 04603 struct member *mem; 04604 struct ao2_iterator queue_iter; 04605 04606 if (penalty < 0) { 04607 ast_log(LOG_ERROR, "Invalid penalty (%d)\n", penalty); 04608 return RESULT_FAILURE; 04609 } 04610 04611 queue_iter = ao2_iterator_init(queues, 0); 04612 while ((q = ao2_t_iterator_next(&queue_iter, "Iterate through queues"))) { 04613 ao2_lock(q); 04614 if (ast_strlen_zero(queuename) || !strcasecmp(q->name, queuename)) { 04615 foundqueue++; 04616 if ((mem = interface_exists(q, interface))) { 04617 foundinterface++; 04618 mem->penalty = penalty; 04619 04620 ast_queue_log(q->name, "NONE", interface, "PENALTY", "%d", penalty); 04621 manager_event(EVENT_FLAG_AGENT, "QueueMemberPenalty", 04622 "Queue: %s\r\n" 04623 "Location: %s\r\n" 04624 "Penalty: %d\r\n", 04625 q->name, mem->interface, penalty); 04626 ao2_ref(mem, -1); 04627 } 04628 } 04629 ao2_unlock(q); 04630 queue_t_unref(q, "Done with iterator"); 04631 } 04632 ao2_iterator_destroy(&queue_iter); 04633 04634 if (foundinterface) { 04635 return RESULT_SUCCESS; 04636 } else if (!foundqueue) { 04637 ast_log (LOG_ERROR, "Invalid queuename\n"); 04638 } else { 04639 ast_log (LOG_ERROR, "Invalid interface\n"); 04640 } 04641 04642 return RESULT_FAILURE; 04643 }
| static void set_queue_result | ( | struct ast_channel * | chan, | |
| enum queue_result | res | |||
| ) | [static] |
sets the QUEUESTATUS channel variable
Definition at line 825 of file app_queue.c.
References ARRAY_LEN, pbx_builtin_setvar_helper(), queue_results, and text.
Referenced by queue_exec().
00826 { 00827 int i; 00828 00829 for (i = 0; i < ARRAY_LEN(queue_results); i++) { 00830 if (queue_results[i].id == res) { 00831 pbx_builtin_setvar_helper(chan, "QUEUESTATUS", queue_results[i].text); 00832 return; 00833 } 00834 } 00835 }
| static void set_queue_variables | ( | struct call_queue * | q, | |
| struct ast_channel * | chan | |||
| ) | [static] |
Set variables of queue.
Definition at line 900 of file app_queue.c.
References call_queue::callsabandoned, call_queue::callscompleted, call_queue::callscompletedinsl, call_queue::count, call_queue::holdtime, int2strat(), call_queue::maxlen, call_queue::name, pbx_builtin_setvar_multiple(), call_queue::servicelevel, call_queue::setqueuevar, call_queue::strategy, and call_queue::talktime.
Referenced by end_bridge_callback(), queue_exec(), record_abandoned(), and try_calling().
00901 { 00902 char interfacevar[256]=""; 00903 float sl = 0; 00904 00905 if (q->setqueuevar) { 00906 sl = 0; 00907 if (q->callscompleted > 0) 00908 sl = 100 * ((float) q->callscompletedinsl / (float) q->callscompleted); 00909 00910 snprintf(interfacevar, sizeof(interfacevar), 00911 "QUEUENAME=%s,QUEUEMAX=%d,QUEUESTRATEGY=%s,QUEUECALLS=%d,QUEUEHOLDTIME=%d,QUEUETALKTIME=%d,QUEUECOMPLETED=%d,QUEUEABANDONED=%d,QUEUESRVLEVEL=%d,QUEUESRVLEVELPERF=%2.1f", 00912 q->name, q->maxlen, int2strat(q->strategy), q->count, q->holdtime, q->talktime, q->callscompleted, q->callsabandoned, q->servicelevel, sl); 00913 00914 pbx_builtin_setvar_multiple(chan, interfacevar); 00915 } 00916 }
| static struct ast_datastore* setup_transfer_datastore | ( | struct queue_ent * | qe, | |
| struct member * | member, | |||
| time_t | starttime, | |||
| int | callcompletedinsl | |||
| ) | [static, read] |
create a datastore for storing relevant info to log attended transfers in the queue_log
Definition at line 3498 of file app_queue.c.
References ast_calloc, ast_channel_datastore_add(), ast_channel_lock, ast_channel_unlock, ast_datastore_alloc, ast_log(), queue_transfer_ds::callcompletedinsl, queue_ent::chan, ast_datastore::data, LOG_WARNING, queue_transfer_ds::member, queue_transfer_ds::qe, queue_transfer_info, and queue_transfer_ds::starttime.
Referenced by try_calling().
03499 { 03500 struct ast_datastore *ds; 03501 struct queue_transfer_ds *qtds = ast_calloc(1, sizeof(*qtds)); 03502 03503 if (!qtds) { 03504 ast_log(LOG_WARNING, "Memory allocation error!\n"); 03505 return NULL; 03506 } 03507 03508 ast_channel_lock(qe->chan); 03509 if (!(ds = ast_datastore_alloc(&queue_transfer_info, NULL))) { 03510 ast_channel_unlock(qe->chan); 03511 ast_log(LOG_WARNING, "Unable to create transfer datastore. queue_log will not show attended transfer\n"); 03512 return NULL; 03513 } 03514 03515 qtds->qe = qe; 03516 /* This member is refcounted in try_calling, so no need to add it here, too */ 03517 qtds->member = member; 03518 qtds->starttime = starttime; 03519 qtds->callcompletedinsl = callcompletedinsl; 03520 ds->data = qtds; 03521 ast_channel_datastore_add(qe->chan, ds); 03522 ast_channel_unlock(qe->chan); 03523 return ds; 03524 }
| static int store_next_lin | ( | struct queue_ent * | qe, | |
| struct callattempt * | outgoing | |||
| ) | [static] |
Search for best metric and add to Linear queue.
Definition at line 2718 of file app_queue.c.
References ast_debug, find_best(), callattempt::interface, queue_ent::linpos, queue_ent::linwrapped, and callattempt::metric.
Referenced by try_calling().
02719 { 02720 struct callattempt *best = find_best(outgoing); 02721 02722 if (best) { 02723 /* Ring just the best channel */ 02724 ast_debug(1, "Next is '%s' with metric %d\n", best->interface, best->metric); 02725 qe->linpos = best->metric % 1000; 02726 } else { 02727 /* Just increment rrpos */ 02728 if (qe->linwrapped) { 02729 /* No more channels, start over */ 02730 qe->linpos = 0; 02731 } else { 02732 /* Prioritize next entry */ 02733 qe->linpos++; 02734 } 02735 } 02736 qe->linwrapped = 0; 02737 02738 return 0; 02739 }
| static int store_next_rr | ( | struct queue_ent * | qe, | |
| struct callattempt * | outgoing | |||
| ) | [static] |
Search for best metric and add to Round Robbin queue.
Definition at line 2694 of file app_queue.c.
References ast_debug, find_best(), callattempt::interface, callattempt::metric, queue_ent::parent, call_queue::rrpos, and call_queue::wrapped.
Referenced by try_calling().
02695 { 02696 struct callattempt *best = find_best(outgoing); 02697 02698 if (best) { 02699 /* Ring just the best channel */ 02700 ast_debug(1, "Next is '%s' with metric %d\n", best->interface, best->metric); 02701 qe->parent->rrpos = best->metric % 1000; 02702 } else { 02703 /* Just increment rrpos */ 02704 if (qe->parent->wrapped) { 02705 /* No more channels, start over */ 02706 qe->parent->rrpos = 0; 02707 } else { 02708 /* Prioritize next entry */ 02709 qe->parent->rrpos++; 02710 } 02711 } 02712 qe->parent->wrapped = 0; 02713 02714 return 0; 02715 }
| static int strat2int | ( | const char * | strategy | ) | [static] |
Definition at line 849 of file app_queue.c.
References ARRAY_LEN, and strategies.
Referenced by find_queue_by_name_rt(), queue_set_param(), and reload_single_queue().
00850 { 00851 int x; 00852 00853 for (x = 0; x < ARRAY_LEN(strategies); x++) { 00854 if (!strcasecmp(strategy, strategies[x].name)) 00855 return strategies[x].strategy; 00856 } 00857 00858 return -1; 00859 }
| static int try_calling | ( | struct queue_ent * | qe, | |
| const char * | options, | |||
| char * | announceoverride, | |||
| const char * | url, | |||
| int * | tries, | |||
| int * | noption, | |||
| const char * | agi, | |||
| const char * | macro, | |||
| const char * | gosub, | |||
| int | ringing | |||
| ) | [static] |
A large function which calls members, updates statistics, and bridges the caller and a member.
Here is the process of this function 1. Process any options passed to the Queue() application. Options here mean the third argument to Queue() 2. Iterate trough the members of the queue, creating a callattempt corresponding to each member. During this iteration, we also check the dialed_interfaces datastore to see if we have already attempted calling this member. If we have, we do not create a callattempt. This is in place to prevent call forwarding loops. Also during each iteration, we call calc_metric to determine which members should be rung when. 3. Call ring_one to place a call to the appropriate member(s) 4. Call wait_for_answer to wait for an answer. If no one answers, return. 5. Take care of any holdtime announcements, member delays, or other options which occur after a call has been answered. 6. Start the monitor or mixmonitor if the option is set 7. Remove the caller from the queue to allow other callers to advance 8. Bridge the call. 9. Do any post processing after the call has disconnected.
| [in] | qe | the queue_ent structure which corresponds to the caller attempting to reach members |
| [in] | options | the options passed as the third parameter to the Queue() application |
| [in] | announceoverride | filename to play to user when waiting |
| [in] | url | the url passed as the fourth parameter to the Queue() application |
| [in,out] | tries | the number of times we have tried calling queue members |
| [out] | noption | set if the call to Queue() has the 'n' option set. |
| [in] | agi | the agi passed as the fifth parameter to the Queue() application |
| [in] | macro | the macro passed as the sixth parameter to the Queue() application |
| [in] | gosub | the gosub passed as the seventh parameter to the Queue() application |
| [in] | ringing | 1 if the 'r' option is set, otherwise 0 |
Definition at line 3580 of file app_queue.c.
References ast_channel::_softhangup, ast_channel::_state, AGENT, queue_ent::announce, ao2_alloc, ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_lock(), ao2_ref, ao2_unlock(), asprintf, ast_autoservice_start(), ast_autoservice_stop(), ast_bridge_call(), ast_calloc, ast_cdr_failed(), AST_CDR_FLAG_LOCKED, AST_CDR_FLAG_POST_DISABLED, ast_cdr_isset_unanswered(), ast_cdr_setdestchan(), ast_channel_datastore_add(), ast_channel_datastore_find(), ast_channel_datastore_remove(), ast_channel_lock, ast_channel_make_compatible(), ast_channel_sendurl(), ast_channel_setoption(), ast_channel_supports_html(), ast_channel_unlock, ast_check_hangup(), ast_clear_flag, ast_copy_string(), ast_datastore_alloc, ast_datastore_free(), ast_debug, AST_DIGIT_ANY, AST_FEATURE_AUTOMIXMON, AST_FEATURE_AUTOMON, AST_FEATURE_DISCONNECT, AST_FEATURE_NO_H_EXTEN, AST_FEATURE_PARKCALL, AST_FEATURE_REDIRECT, AST_FLAG_ANSWERED_ELSEWHERE, ast_free, ast_hangup(), ast_indicate(), AST_LIST_HEAD, AST_LIST_HEAD_INIT, AST_LIST_INSERT_TAIL, AST_LIST_LOCK, AST_LIST_TRAVERSE, AST_LIST_UNLOCK, ast_log(), AST_MAX_CONTEXT, AST_MAX_EXTENSION, ast_moh_stop(), ast_monitor_setjoinfiles(), ast_monitor_start(), AST_OPTION_TONE_VERIFY, ast_pbx_run_args(), ast_queue_log(), ast_random(), ast_safe_sleep(), ast_say_number(), ast_set_flag, AST_STATE_UP, ast_strdupa, ast_strlen_zero(), ast_test_flag, attended_transfer_occurred(), calc_metric(), CALLER, member::calls, queue_ent::cancel_answered_elsewhere, ast_channel::cdr, queue_end_bridge::chan, callattempt::chan, queue_ent::chan, ast_channel::context, ast_datastore::data, DATASTORE_INHERIT_FOREVER, di, dialed_interface_info, ast_cdr::dstchannel, member::dynamic, end_bridge_callback(), ast_bridge_config::end_bridge_callback, ast_bridge_config::end_bridge_callback_data, end_bridge_callback_data_fixup(), ast_bridge_config::end_bridge_callback_data_fixup, errno, EVENT_FLAG_AGENT, call_queue::eventwhencalled, queue_ent::expire, ast_channel::exten, ast_bridge_config::features_callee, ast_bridge_config::features_caller, free, queue_ent::handled, hangupcalls(), ast_datastore::inheritance, callattempt::interface, ast_dialed_interface::interface, member::interface, ast_channel::language, member::lastcall, callattempt::lastcall, member::lastqueue, callattempt::lastqueue, leave_queue(), LOG_ERROR, LOG_NOTICE, LOG_WARNING, manager_event, callattempt::member, call_queue::membercount, call_queue::memberdelay, call_queue::membergosub, call_queue::membermacro, member::membername, call_queue::members, call_queue::monfmt, call_queue::montype, call_queue::name, ast_channel::name, ast_pbx_args::no_hangup_chan, callattempt::oldstatus, queue_ent::opos, queue_ent::parent, pbx_builtin_getvar_helper(), pbx_builtin_setvar_multiple(), pbx_exec(), pbx_findapp(), pbx_substitute_variables_helper(), member::penalty, queue_ent::pending, play_file(), queue_ent::pos, ast_channel::priority, queue_end_bridge::q, callattempt::q_next, QUEUE_EVENT_VARIABLES, QUEUE_STRATEGY_LINEAR, QUEUE_STRATEGY_RRMEMORY, queue_t_ref, queue_transfer_info, queues, member::realtime, recalc_holdtime(), record_abandoned(), call_queue::reportholdtime, ring_one(), send_agent_complete(), call_queue::servicelevel, set_queue_variables(), call_queue::setinterfacevar, call_queue::setqueueentryvar, setup_transfer_datastore(), call_queue::sound_callerannounce, call_queue::sound_minutes, call_queue::sound_reporthold, call_queue::sound_seconds, queue_ent::start, member::status, callattempt::stillgoing, store_next_lin(), store_next_rr(), call_queue::strategy, ast_channel::tech, call_queue::timeout, TIMEOUT_PRIORITY_APP, call_queue::timeoutpriority, TRANSFER, ast_channel_tech::type, ast_cdr::uniqueid, ast_channel::uniqueid, update_queue(), vars2manager(), wait_for_answer(), X_REC_IN, and X_REC_OUT.
Referenced by queue_exec().
03581 { 03582 struct member *cur; 03583 struct callattempt *outgoing = NULL; /* the list of calls we are building */ 03584 int to, orig; 03585 char oldexten[AST_MAX_EXTENSION]=""; 03586 char oldcontext[AST_MAX_CONTEXT]=""; 03587 char queuename[256]=""; 03588 char interfacevar[256]=""; 03589 struct ast_channel *peer; 03590 struct ast_channel *which; 03591 struct callattempt *lpeer; 03592 struct member *member; 03593 struct ast_app *application; 03594 int res = 0, bridge = 0; 03595 int numbusies = 0; 03596 int x=0; 03597 char *announce = NULL; 03598 char digit = 0; 03599 time_t callstart; 03600 time_t now = time(NULL); 03601 struct ast_bridge_config bridge_config; 03602 char nondataquality = 1; 03603 char *agiexec = NULL; 03604 char *macroexec = NULL; 03605 char *gosubexec = NULL; 03606 int ret = 0; 03607 const char *monitorfilename; 03608 const char *monitor_exec; 03609 const char *monitor_options; 03610 char tmpid[256], tmpid2[256]; 03611 char meid[1024], meid2[1024]; 03612 char mixmonargs[1512]; 03613 struct ast_app *mixmonapp = NULL; 03614 char *p; 03615 char vars[2048]; 03616 int forwardsallowed = 1; 03617 int callcompletedinsl; 03618 struct ao2_iterator memi; 03619 struct ast_datastore *datastore, *transfer_ds; 03620 struct queue_end_bridge *queue_end_bridge = NULL; 03621 const int need_weight = use_weight; 03622 03623 ast_channel_lock(qe->chan); 03624 datastore = ast_channel_datastore_find(qe->chan, &dialed_interface_info, NULL); 03625 ast_channel_unlock(qe->chan); 03626 03627 memset(&bridge_config, 0, sizeof(bridge_config)); 03628 tmpid[0] = 0; 03629 meid[0] = 0; 03630 time(&now); 03631 03632 /* If we've already exceeded our timeout, then just stop 03633 * This should be extremely rare. queue_exec will take care 03634 * of removing the caller and reporting the timeout as the reason. 03635 */ 03636 if (qe->expire && now >= qe->expire) { 03637 res = 0; 03638 goto out; 03639 } 03640 03641 for (; options && *options; options++) 03642 switch (*options) { 03643 case 't': 03644 ast_set_flag(&(bridge_config.features_callee), AST_FEATURE_REDIRECT); 03645 break; 03646 case 'T': 03647 ast_set_flag(&(bridge_config.features_caller), AST_FEATURE_REDIRECT); 03648 break; 03649 case 'w': 03650 ast_set_flag(&(bridge_config.features_callee), AST_FEATURE_AUTOMON); 03651 break; 03652 case 'W': 03653 ast_set_flag(&(bridge_config.features_caller), AST_FEATURE_AUTOMON); 03654 break; 03655 case 'c': 03656 ast_set_flag(&(bridge_config.features_caller), AST_FEATURE_NO_H_EXTEN); 03657 break; 03658 case 'd': 03659 nondataquality = 0; 03660 break; 03661 case 'h': 03662 ast_set_flag(&(bridge_config.features_callee), AST_FEATURE_DISCONNECT); 03663 break; 03664 case 'H': 03665 ast_set_flag(&(bridge_config.features_caller), AST_FEATURE_DISCONNECT); 03666 break; 03667 case 'k': 03668 ast_set_flag(&(bridge_config.features_callee), AST_FEATURE_PARKCALL); 03669 break; 03670 case 'K': 03671 ast_set_flag(&(bridge_config.features_caller), AST_FEATURE_PARKCALL); 03672 break; 03673 case 'n': 03674 if (qe->parent->strategy == QUEUE_STRATEGY_RRMEMORY || qe->parent->strategy == QUEUE_STRATEGY_LINEAR) 03675 (*tries)++; 03676 else 03677 *tries = qe->parent->membercount; 03678 *noption = 1; 03679 break; 03680 case 'i': 03681 forwardsallowed = 0; 03682 break; 03683 case 'x': 03684 ast_set_flag(&(bridge_config.features_callee), AST_FEATURE_AUTOMIXMON); 03685 break; 03686 case 'X': 03687 ast_set_flag(&(bridge_config.features_caller), AST_FEATURE_AUTOMIXMON); 03688 break; 03689 case 'C': 03690 qe->cancel_answered_elsewhere = 1; 03691 break; 03692 03693 } 03694 03695 /* if the calling channel has the ANSWERED_ELSEWHERE flag set, make sure this is inherited. 03696 (this is mainly to support chan_local) 03697 */ 03698 if (ast_test_flag(qe->chan, AST_FLAG_ANSWERED_ELSEWHERE)) { 03699 qe->cancel_answered_elsewhere = 1; 03700 } 03701 03702 /* Hold the lock while we setup the outgoing calls */ 03703 if (need_weight) 03704 ao2_lock(queues); 03705 ao2_lock(qe->parent); 03706 ast_debug(1, "%s is trying to call a queue member.\n", 03707 qe->chan->name); 03708 ast_copy_string(queuename, qe->parent->name, sizeof(queuename)); 03709 if (!ast_strlen_zero(qe->announce)) 03710 announce = qe->announce; 03711 if (!ast_strlen_zero(announceoverride)) 03712 announce = announceoverride; 03713 03714 memi = ao2_iterator_init(qe->parent->members, 0); 03715 while ((cur = ao2_iterator_next(&memi))) { 03716 struct callattempt *tmp = ast_calloc(1, sizeof(*tmp)); 03717 struct ast_dialed_interface *di; 03718 AST_LIST_HEAD(, ast_dialed_interface) *dialed_interfaces; 03719 if (!tmp) { 03720 ao2_ref(cur, -1); 03721 ao2_unlock(qe->parent); 03722 ao2_iterator_destroy(&memi); 03723 if (need_weight) 03724 ao2_unlock(queues); 03725 goto out; 03726 } 03727 if (!datastore) { 03728 if (!(datastore = ast_datastore_alloc(&dialed_interface_info, NULL))) { 03729 ao2_ref(cur, -1); 03730 ao2_unlock(qe->parent); 03731 ao2_iterator_destroy(&memi); 03732 if (need_weight) 03733 ao2_unlock(queues); 03734 free(tmp); 03735 goto out; 03736 } 03737 datastore->inheritance = DATASTORE_INHERIT_FOREVER; 03738 if (!(dialed_interfaces = ast_calloc(1, sizeof(*dialed_interfaces)))) { 03739 ao2_ref(cur, -1); 03740 ao2_unlock(&qe->parent); 03741 ao2_iterator_destroy(&memi); 03742 if (need_weight) 03743 ao2_unlock(queues); 03744 free(tmp); 03745 goto out; 03746 } 03747 datastore->data = dialed_interfaces; 03748 AST_LIST_HEAD_INIT(dialed_interfaces); 03749 03750 ast_channel_lock(qe->chan); 03751 ast_channel_datastore_add(qe->chan, datastore); 03752 ast_channel_unlock(qe->chan); 03753 } else 03754 dialed_interfaces = datastore->data; 03755 03756 AST_LIST_LOCK(dialed_interfaces); 03757 AST_LIST_TRAVERSE(dialed_interfaces, di, list) { 03758 if (!strcasecmp(cur->interface, di->interface)) { 03759 ast_debug(1, "Skipping dialing interface '%s' since it has already been dialed\n", 03760 di->interface); 03761 break; 03762 } 03763 } 03764 AST_LIST_UNLOCK(dialed_interfaces); 03765 03766 if (di) { 03767 free(tmp); 03768 continue; 03769 } 03770 03771 /* It is always ok to dial a Local interface. We only keep track of 03772 * which "real" interfaces have been dialed. The Local channel will 03773 * inherit this list so that if it ends up dialing a real interface, 03774 * it won't call one that has already been called. */ 03775 if (strncasecmp(cur->interface, "Local/", 6)) { 03776 if (!(di = ast_calloc(1, sizeof(*di) + strlen(cur->interface)))) { 03777 ao2_ref(cur, -1); 03778 ao2_unlock(qe->parent); 03779 ao2_iterator_destroy(&memi); 03780 if (need_weight) 03781 ao2_unlock(queues); 03782 free(tmp); 03783 goto out; 03784 } 03785 strcpy(di->interface, cur->interface); 03786 03787 AST_LIST_LOCK(dialed_interfaces); 03788 AST_LIST_INSERT_TAIL(dialed_interfaces, di, list); 03789 AST_LIST_UNLOCK(dialed_interfaces); 03790 } 03791 03792 tmp->stillgoing = -1; 03793 tmp->member = cur; 03794 tmp->oldstatus = cur->status; 03795 tmp->lastcall = cur->lastcall; 03796 tmp->lastqueue = cur->lastqueue; 03797 ast_copy_string(tmp->interface, cur->interface, sizeof(tmp->interface)); 03798 /* Special case: If we ring everyone, go ahead and ring them, otherwise 03799 just calculate their metric for the appropriate strategy */ 03800 if (!calc_metric(qe->parent, cur, x++, qe, tmp)) { 03801 /* Put them in the list of outgoing thingies... We're ready now. 03802 XXX If we're forcibly removed, these outgoing calls won't get 03803 hung up XXX */ 03804 tmp->q_next = outgoing; 03805 outgoing = tmp; 03806 /* If this line is up, don't try anybody else */ 03807 if (outgoing->chan && (outgoing->chan->_state == AST_STATE_UP)) 03808 break; 03809 } else { 03810 ao2_ref(cur, -1); 03811 ast_free(tmp); 03812 } 03813 } 03814 ao2_iterator_destroy(&memi); 03815 03816 if (qe->parent->timeoutpriority == TIMEOUT_PRIORITY_APP) { 03817 /* Application arguments have higher timeout priority (behaviour for <=1.6) */ 03818 if (qe->expire && (!qe->parent->timeout || (qe->expire - now) <= qe->parent->timeout)) 03819 to = (qe->expire - now) * 1000; 03820 else 03821 to = (qe->parent->timeout) ? qe->parent->timeout * 1000 : -1; 03822 } else { 03823 /* Config timeout is higher priority thatn application timeout */ 03824 if (qe->expire && qe->expire<=now) { 03825 to = 0; 03826 } else if (qe->parent->timeout) { 03827 to = qe->parent->timeout * 1000; 03828 } else { 03829 to = -1; 03830 } 03831 } 03832 orig = to; 03833 ++qe->pending; 03834 ao2_unlock(qe->parent); 03835 ring_one(qe, outgoing, &numbusies); 03836 if (need_weight) 03837 ao2_unlock(queues); 03838 lpeer = wait_for_answer(qe, outgoing, &to, &digit, numbusies, ast_test_flag(&(bridge_config.features_caller), AST_FEATURE_DISCONNECT), forwardsallowed); 03839 /* The ast_channel_datastore_remove() function could fail here if the 03840 * datastore was moved to another channel during a masquerade. If this is 03841 * the case, don't free the datastore here because later, when the channel 03842 * to which the datastore was moved hangs up, it will attempt to free this 03843 * datastore again, causing a crash 03844 */ 03845 ast_channel_lock(qe->chan); 03846 if (datastore && !ast_channel_datastore_remove(qe->chan, datastore)) { 03847 ast_datastore_free(datastore); 03848 } 03849 ast_channel_unlock(qe->chan); 03850 ao2_lock(qe->parent); 03851 if (qe->parent->strategy == QUEUE_STRATEGY_RRMEMORY) { 03852 store_next_rr(qe, outgoing); 03853 } 03854 if (qe->parent->strategy == QUEUE_STRATEGY_LINEAR) { 03855 store_next_lin(qe, outgoing); 03856 } 03857 ao2_unlock(qe->parent); 03858 peer = lpeer ? lpeer->chan : NULL; 03859 if (!peer) { 03860 qe->pending = 0; 03861 if (to) { 03862 /* Must gotten hung up */ 03863 res = -1; 03864 } else { 03865 /* User exited by pressing a digit */ 03866 res = digit; 03867 } 03868 if (res == -1) 03869 ast_debug(1, "%s: Nobody answered.\n", qe->chan->name); 03870 if (ast_cdr_isset_unanswered()) { 03871 /* channel contains the name of one of the outgoing channels 03872 in its CDR; zero out this CDR to avoid a dual-posting */ 03873 struct callattempt *o; 03874 for (o = outgoing; o; o = o->q_next) { 03875 if (!o->chan) { 03876 continue; 03877 } 03878 if (strcmp(o->chan->cdr->dstchannel, qe->chan->cdr->dstchannel) == 0) { 03879 ast_set_flag(o->chan->cdr, AST_CDR_FLAG_POST_DISABLED); 03880 break; 03881 } 03882 } 03883 } 03884 } else { /* peer is valid */ 03885 /* Ah ha! Someone answered within the desired timeframe. Of course after this 03886 we will always return with -1 so that it is hung up properly after the 03887 conversation. */ 03888 if (!strcmp(qe->chan->tech->type, "DAHDI")) 03889 ast_channel_setoption(qe->chan, AST_OPTION_TONE_VERIFY, &nondataquality, sizeof(nondataquality), 0); 03890 if (!strcmp(peer->tech->type, "DAHDI")) 03891 ast_channel_setoption(peer, AST_OPTION_TONE_VERIFY, &nondataquality, sizeof(nondataquality), 0); 03892 /* Update parameters for the queue */ 03893 time(&now); 03894 recalc_holdtime(qe, (now - qe->start)); 03895 ao2_lock(qe->parent); 03896 callcompletedinsl = ((now - qe->start) <= qe->parent->servicelevel); 03897 ao2_unlock(qe->parent); 03898 member = lpeer->member; 03899 /* Increment the refcount for this member, since we're going to be using it for awhile in here. */ 03900 ao2_ref(member, 1); 03901 hangupcalls(outgoing, peer, qe->cancel_answered_elsewhere); 03902 outgoing = NULL; 03903 if (announce || qe->parent->reportholdtime || qe->parent->memberdelay) { 03904 int res2; 03905 03906 res2 = ast_autoservice_start(qe->chan); 03907 if (!res2) { 03908 if (qe->parent->memberdelay) { 03909 ast_log(LOG_NOTICE, "Delaying member connect for %d seconds\n", qe->parent->memberdelay); 03910 res2 |= ast_safe_sleep(peer, qe->parent->memberdelay * 1000); 03911 } 03912 if (!res2 && announce) { 03913 play_file(peer, announce); 03914 } 03915 if (!res2 && qe->parent->reportholdtime) { 03916 if (!play_file(peer, qe->parent->sound_reporthold)) { 03917 int holdtime, holdtimesecs; 03918 03919 time(&now); 03920 holdtime = abs((now - qe->start) / 60); 03921 holdtimesecs = abs((now - qe->start) % 60); 03922 if (holdtime > 0) { 03923 ast_say_number(peer, holdtime, AST_DIGIT_ANY, peer->language, NULL); 03924 play_file(peer, qe->parent->sound_minutes); 03925 } 03926 if (holdtimesecs > 1) { 03927 ast_say_number(peer, holdtimesecs, AST_DIGIT_ANY, peer->language, NULL); 03928 play_file(peer, qe->parent->sound_seconds); 03929 } 03930 } 03931 } 03932 } 03933 res2 |= ast_autoservice_stop(qe->chan); 03934 if (ast_check_hangup(peer)) { 03935 /* Agent must have hung up */ 03936 ast_log(LOG_WARNING, "Agent on %s hungup on the customer.\n", peer->name); 03937 ast_queue_log(queuename, qe->chan->uniqueid, member->membername, "AGENTDUMP", "%s", ""); 03938 if (qe->parent->eventwhencalled) 03939 manager_event(EVENT_FLAG_AGENT, "AgentDump", 03940 "Queue: %s\r\n" 03941 "Uniqueid: %s\r\n" 03942 "Channel: %s\r\n" 03943 "Member: %s\r\n" 03944 "MemberName: %s\r\n" 03945 "%s", 03946 queuename, qe->chan->uniqueid, peer->name, member->interface, member->membername, 03947 qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES ? vars2manager(qe->chan, vars, sizeof(vars)) : ""); 03948 ast_hangup(peer); 03949 ao2_ref(member, -1); 03950 goto out; 03951 } else if (res2) { 03952 /* Caller must have hung up just before being connected*/ 03953 ast_log(LOG_NOTICE, "Caller was about to talk to agent on %s but the caller hungup.\n", peer->name); 03954 ast_queue_log(queuename, qe->chan->uniqueid, member->membername, "ABANDON", "%d|%d|%ld", qe->pos, qe->opos, (long) time(NULL) - qe->start); 03955 record_abandoned(qe); 03956 ast_hangup(peer); 03957 ao2_ref(member, -1); 03958 return -1; 03959 } 03960 } 03961 /* Stop music on hold */ 03962 if (ringing) 03963 ast_indicate(qe->chan,-1); 03964 else 03965 ast_moh_stop(qe->chan); 03966 /* If appropriate, log that we have a destination channel */ 03967 if (qe->chan->cdr) 03968 ast_cdr_setdestchan(qe->chan->cdr, peer->name); 03969 /* Make sure channels are compatible */ 03970 res = ast_channel_make_compatible(qe->chan, peer); 03971 if (res < 0) { 03972 ast_queue_log(queuename, qe->chan->uniqueid, member->membername, "SYSCOMPAT", "%s", ""); 03973 ast_log(LOG_WARNING, "Had to drop call because I couldn't make %s compatible with %s\n", qe->chan->name, peer->name); 03974 record_abandoned(qe); 03975 ast_cdr_failed(qe->chan->cdr); 03976 ast_hangup(peer); 03977 ao2_ref(member, -1); 03978 return -1; 03979 } 03980 03981 /* Play announcement to the caller telling it's his turn if defined */ 03982 if (!ast_strlen_zero(qe->parent->sound_callerannounce)) { 03983 if (play_file(qe->chan, qe->parent->sound_callerannounce)) 03984 ast_log(LOG_WARNING, "Announcement file '%s' is unavailable, continuing anyway...\n", qe->parent->sound_callerannounce); 03985 } 03986 03987 ao2_lock(qe->parent); 03988 /* if setinterfacevar is defined, make member variables available to the channel */ 03989 /* use pbx_builtin_setvar to set a load of variables with one call */ 03990 if (qe->parent->setinterfacevar) { 03991 snprintf(interfacevar, sizeof(interfacevar), "MEMBERINTERFACE=%s,MEMBERNAME=%s,MEMBERCALLS=%d,MEMBERLASTCALL=%ld,MEMBERPENALTY=%d,MEMBERDYNAMIC=%d,MEMBERREALTIME=%d", 03992 member->interface, member->membername, member->calls, (long)member->lastcall, member->penalty, member->dynamic, member->realtime); 03993 pbx_builtin_setvar_multiple(qe->chan, interfacevar); 03994 pbx_builtin_setvar_multiple(peer, interfacevar); 03995 } 03996 03997 /* if setqueueentryvar is defined, make queue entry (i.e. the caller) variables available to the channel */ 03998 /* use pbx_builtin_setvar to set a load of variables with one call */ 03999 if (qe->parent->setqueueentryvar) { 04000 snprintf(interfacevar, sizeof(interfacevar), "QEHOLDTIME=%ld,QEORIGINALPOS=%d", 04001 (long) time(NULL) - qe->start, qe->opos); 04002 pbx_builtin_setvar_multiple(qe->chan, interfacevar); 04003 pbx_builtin_setvar_multiple(peer, interfacevar); 04004 } 04005 04006 /* try to set queue variables if configured to do so*/ 04007 set_queue_variables(qe->parent, qe->chan); 04008 set_queue_variables(qe->parent, peer); 04009 ao2_unlock(qe->parent); 04010 04011 ast_channel_lock(qe->chan); 04012 if ((monitorfilename = pbx_builtin_getvar_helper(qe->chan, "MONITOR_FILENAME"))) { 04013 monitorfilename = ast_strdupa(monitorfilename); 04014 } 04015 ast_channel_unlock(qe->chan); 04016 /* Begin Monitoring */ 04017 if (qe->parent->monfmt && *qe->parent->monfmt) { 04018 if (!qe->parent->montype) { 04019 const char *monexec, *monargs; 04020 ast_debug(1, "Starting Monitor as requested.\n"); 04021 ast_channel_lock(qe->chan); 04022 if ((monexec = pbx_builtin_getvar_helper(qe->chan, "MONITOR_EXEC")) || (monargs = pbx_builtin_getvar_helper(qe->chan, "MONITOR_EXEC_ARGS"))) { 04023 which = qe->chan; 04024 monexec = monexec ? ast_strdupa(monexec) : NULL; 04025 } 04026 else 04027 which = peer; 04028 ast_channel_unlock(qe->chan); 04029 if (ast_monitor_start) { 04030 if (monitorfilename) { 04031 ast_monitor_start(which, qe->parent->monfmt, monitorfilename, 1, X_REC_IN | X_REC_OUT); 04032 } else if (qe->chan->cdr && ast_monitor_start) { 04033 ast_monitor_start(which, qe->parent->monfmt, qe->chan->cdr->uniqueid, 1, X_REC_IN | X_REC_OUT); 04034 } else if (ast_monitor_start) { 04035 /* Last ditch effort -- no CDR, make up something */ 04036 snprintf(tmpid, sizeof(tmpid), "chan-%lx", ast_random()); 04037 ast_monitor_start(which, qe->parent->monfmt, tmpid, 1, X_REC_IN | X_REC_OUT); 04038 } 04039 } 04040 if (!ast_strlen_zero(monexec) && ast_monitor_setjoinfiles) { 04041 ast_monitor_setjoinfiles(which, 1); 04042 } 04043 } else { 04044 mixmonapp = pbx_findapp("MixMonitor"); 04045 04046 if (mixmonapp) { 04047 ast_debug(1, "Starting MixMonitor as requested.\n"); 04048 if (!monitorfilename) { 04049 if (qe->chan->cdr) 04050 ast_copy_string(tmpid, qe->chan->cdr->uniqueid, sizeof(tmpid)); 04051 else 04052 snprintf(tmpid, sizeof(tmpid), "chan-%lx", ast_random()); 04053 } else { 04054 const char *m = monitorfilename; 04055 for (p = tmpid2; p < tmpid2 + sizeof(tmpid2) - 1; p++, m++) { 04056 switch (*m) { 04057 case '^': 04058 if (*(m + 1) == '{') 04059 *p = '$'; 04060 break; 04061 case ',': 04062 *p++ = '\\'; 04063 /* Fall through */ 04064 default: 04065 *p = *m; 04066 } 04067 if (*m == '\0') 04068 break; 04069 } 04070 if (p == tmpid2 + sizeof(tmpid2)) 04071 tmpid2[sizeof(tmpid2) - 1] = '\0'; 04072 04073 pbx_substitute_variables_helper(qe->chan, tmpid2, tmpid, sizeof(tmpid) - 1); 04074 } 04075 04076 ast_channel_lock(qe->chan); 04077 if ((monitor_exec = pbx_builtin_getvar_helper(qe->chan, "MONITOR_EXEC"))) { 04078 monitor_exec = ast_strdupa(monitor_exec); 04079 } 04080 if ((monitor_options = pbx_builtin_getvar_helper(qe->chan, "MONITOR_OPTIONS"))) { 04081 monitor_options = ast_strdupa(monitor_options); 04082 } else { 04083 monitor_options = ""; 04084 } 04085 ast_channel_unlock(qe->chan); 04086 04087 if (monitor_exec) { 04088 const char *m = monitor_exec; 04089 for (p = meid2; p < meid2 + sizeof(meid2) - 1; p++, m++) { 04090 switch (*m) { 04091 case '^': 04092 if (*(m + 1) == '{') 04093 *p = '$'; 04094 break; 04095 case ',': 04096 *p++ = '\\'; 04097 /* Fall through */ 04098 default: 04099 *p = *m; 04100 } 04101 if (*m == '\0') 04102 break; 04103 } 04104 if (p == meid2 + sizeof(meid2)) 04105 meid2[sizeof(meid2) - 1] = '\0'; 04106 04107 pbx_substitute_variables_helper(qe->chan, meid2, meid, sizeof(meid) - 1); 04108 } 04109 04110 snprintf(tmpid2, sizeof(tmpid2), "%s.%s", tmpid, qe->parent->monfmt); 04111 04112 if (!ast_strlen_zero(monitor_exec)) 04113 snprintf(mixmonargs, sizeof(mixmonargs), "%s,b%s,%s", tmpid2, monitor_options, monitor_exec); 04114 else 04115 snprintf(mixmonargs, sizeof(mixmonargs), "%s,b%s", tmpid2, monitor_options); 04116 04117 ast_debug(1, "Arguments being passed to MixMonitor: %s\n", mixmonargs); 04118 /* We purposely lock the CDR so that pbx_exec does not update the application data */ 04119 if (qe->chan->cdr) 04120 ast_set_flag(qe->chan->cdr, AST_CDR_FLAG_LOCKED); 04121 ret = pbx_exec(qe->chan, mixmonapp, mixmonargs); 04122 if (qe->chan->cdr) 04123 ast_clear_flag(qe->chan->cdr, AST_CDR_FLAG_LOCKED); 04124 04125 } else { 04126 ast_log(LOG_WARNING, "Asked to run MixMonitor on this call, but cannot find the MixMonitor app!\n"); 04127 } 04128 } 04129 } 04130 /* Drop out of the queue at this point, to prepare for next caller */ 04131 leave_queue(qe); 04132 if (!ast_strlen_zero(url) && ast_channel_supports_html(peer)) { 04133 ast_debug(1, "app_queue: sendurl=%s.\n", url); 04134 ast_channel_sendurl(peer, url); 04135 } 04136 04137 /* run a macro for this connection if defined. The macro simply returns, no action is taken on the result */ 04138 /* use macro from dialplan if passed as a option, otherwise use the default queue macro */ 04139 if (!ast_strlen_zero(macro)) { 04140 macroexec = ast_strdupa(macro); 04141 } else { 04142 if (qe->parent->membermacro) 04143 macroexec = ast_strdupa(qe->parent->membermacro); 04144 } 04145 04146 if (!ast_strlen_zero(macroexec)) { 04147 ast_debug(1, "app_queue: macro=%s.\n", macroexec); 04148 04149 res = ast_autoservice_start(qe->chan); 04150 if (res) { 04151 ast_log(LOG_ERROR, "Unable to start autoservice on calling channel\n"); 04152 res = -1; 04153 } 04154 04155 application = pbx_findapp("Macro"); 04156 04157 if (application) { 04158 res = pbx_exec(peer, application, macroexec); 04159 ast_debug(1, "Macro exited with status %d\n", res); 04160 res = 0; 04161 } else { 04162 ast_log(LOG_ERROR, "Could not find application Macro\n"); 04163 res = -1; 04164 } 04165 04166 if (ast_autoservice_stop(qe->chan) < 0) { 04167 ast_log(LOG_ERROR, "Could not stop autoservice on calling channel\n"); 04168 res = -1; 04169 } 04170 } 04171 04172 /* run a gosub for this connection if defined. The gosub simply returns, no action is taken on the result */ 04173 /* use gosub from dialplan if passed as a option, otherwise use the default queue gosub */ 04174 if (!ast_strlen_zero(gosub)) { 04175 gosubexec = ast_strdupa(gosub); 04176 } else { 04177 if (qe->parent->membergosub) 04178 gosubexec = ast_strdupa(qe->parent->membergosub); 04179 } 04180 04181 if (!ast_strlen_zero(gosubexec)) { 04182 ast_debug(1, "app_queue: gosub=%s.\n", gosubexec); 04183 04184 res = ast_autoservice_start(qe->chan); 04185 if (res) { 04186 ast_log(LOG_ERROR, "Unable to start autoservice on calling channel\n"); 04187 res = -1; 04188 } 04189 04190 application = pbx_findapp("Gosub"); 04191 04192 if (application) { 04193 char *gosub_args, *gosub_argstart; 04194 04195 /* Set where we came from */ 04196 ast_copy_string(peer->context, "app_queue_gosub_virtual_context", sizeof(peer->context)); 04197 ast_copy_string(peer->exten, "s", sizeof(peer->exten)); 04198 peer->priority = 0; 04199 04200 gosub_argstart = strchr(gosubexec, ','); 04201 if (gosub_argstart) { 04202 *gosub_argstart = 0; 04203 if (asprintf(&gosub_args, "%s,s,1(%s)", gosubexec, gosub_argstart + 1) < 0) { 04204 ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno)); 04205 gosub_args = NULL; 04206 } 04207 *gosub_argstart = ','; 04208 } else { 04209 if (asprintf(&gosub_args, "%s,s,1", gosubexec) < 0) { 04210 ast_log(LOG_WARNING, "asprintf() failed: %s\n", strerror(errno)); 04211 gosub_args = NULL; 04212 } 04213 } 04214 if (gosub_args) { 04215 res = pbx_exec(peer, application, gosub_args); 04216 if (!res) { 04217 struct ast_pbx_args args; 04218 memset(&args, 0, sizeof(args)); 04219 args.no_hangup_chan = 1; 04220 ast_pbx_run_args(peer, &args); 04221 } 04222 ast_free(gosub_args); 04223 ast_debug(1, "Gosub exited with status %d\n", res); 04224 } else { 04225 ast_log(LOG_ERROR, "Could not Allocate string for Gosub arguments -- Gosub Call Aborted!\n"); 04226 } 04227 } else { 04228 ast_log(LOG_ERROR, "Could not find application Gosub\n"); 04229 res = -1; 04230 } 04231 04232 if (ast_autoservice_stop(qe->chan) < 0) { 04233 ast_log(LOG_ERROR, "Could not stop autoservice on calling channel\n"); 04234 res = -1; 04235 } 04236 } 04237 04238 if (!ast_strlen_zero(agi)) { 04239 ast_debug(1, "app_queue: agi=%s.\n", agi); 04240 application = pbx_findapp("agi"); 04241 if (application) { 04242 agiexec = ast_strdupa(agi); 04243 ret = pbx_exec(qe->chan, application, agiexec); 04244 } else 04245 ast_log(LOG_WARNING, "Asked to execute an AGI on this channel, but could not find application (agi)!\n"); 04246 } 04247 qe->handled++; 04248 ast_queue_log(queuename, qe->chan->uniqueid, member->membername, "CONNECT", "%ld|%s|%ld", (long) time(NULL) - qe->start, peer->uniqueid, 04249 (long)(orig - to > 0 ? (orig - to) / 1000 : 0)); 04250 if (update_cdr && qe->chan->cdr) 04251 ast_copy_string(qe->chan->cdr->dstchannel, member->membername, sizeof(qe->chan->cdr->dstchannel)); 04252 if (qe->parent->eventwhencalled) 04253 manager_event(EVENT_FLAG_AGENT, "AgentConnect", 04254 "Queue: %s\r\n" 04255 "Uniqueid: %s\r\n" 04256 "Channel: %s\r\n" 04257 "Member: %s\r\n" 04258 "MemberName: %s\r\n" 04259 "Holdtime: %ld\r\n" 04260 "BridgedChannel: %s\r\n" 04261 "Ringtime: %ld\r\n" 04262 "%s", 04263 queuename, qe->chan->uniqueid, peer->name, member->interface, member->membername, 04264 (long) time(NULL) - qe->start, peer->uniqueid, (long)(orig - to > 0 ? (orig - to) / 1000 : 0), 04265 qe->parent->eventwhencalled == QUEUE_EVENT_VARIABLES ? vars2manager(qe->chan, vars, sizeof(vars)) : ""); 04266 ast_copy_string(oldcontext, qe->chan->context, sizeof(oldcontext)); 04267 ast_copy_string(oldexten, qe->chan->exten, sizeof(oldexten)); 04268 04269 if ((queue_end_bridge = ao2_alloc(sizeof(*queue_end_bridge), NULL))) { 04270 queue_end_bridge->q = qe->parent; 04271 queue_end_bridge->chan = qe->chan; 04272 bridge_config.end_bridge_callback = end_bridge_callback; 04273 bridge_config.end_bridge_callback_data = queue_end_bridge; 04274 bridge_config.end_bridge_callback_data_fixup = end_bridge_callback_data_fixup; 04275 /* Since queue_end_bridge can survive beyond the life of this call to Queue, we need 04276 * to make sure to increase the refcount of this queue so it cannot be freed until we 04277 * are done with it. We remove this reference in end_bridge_callback. 04278 */ 04279 queue_t_ref(qe->parent, "For bridge_config reference"); 04280 } 04281 04282 time(&callstart); 04283 transfer_ds = setup_transfer_datastore(qe, member, callstart, callcompletedinsl); 04284 bridge = ast_bridge_call(qe->chan,peer, &bridge_config); 04285 04286 /* If the queue member did an attended transfer, then the TRANSFER already was logged in the queue_log 04287 * when the masquerade occurred. These other "ending" queue_log messages are unnecessary, except for 04288 * the AgentComplete manager event 04289 */ 04290 ast_channel_lock(qe->chan); 04291 if (!attended_transfer_occurred(qe->chan)) { 04292 struct ast_datastore *tds; 04293 04294 /* detect a blind transfer */ 04295 if (!(qe->chan->_softhangup | peer->_softhangup) && (strcasecmp(oldcontext, qe->chan->context) || strcasecmp(oldexten, qe->chan->exten))) { 04296 ast_queue_log(queuename, qe->chan->uniqueid, member->membername, "TRANSFER", "%s|%s|%ld|%ld|%d", 04297 qe->chan->exten, qe->chan->context, (long) (callstart - qe->start), 04298 (long) (time(NULL) - callstart), qe->opos); 04299 send_agent_complete(qe, queuename, peer, member, callstart, vars, sizeof(vars), TRANSFER); 04300 } else if (ast_check_hangup(qe->chan)) { 04301 ast_queue_log(queuename, qe->chan->uniqueid, member->membername, "COMPLETECALLER", "%ld|%ld|%d", 04302 (long) (callstart - qe->start), (long) (time(NULL) - callstart), qe->opos); 04303 send_agent_complete(qe, queuename, peer, member, callstart, vars, sizeof(vars), CALLER); 04304 } else { 04305 ast_queue_log(queuename, qe->chan->uniqueid, member->membername, "COMPLETEAGENT", "%ld|%ld|%d", 04306 (long) (callstart - qe->start), (long) (time(NULL) - callstart), qe->opos); 04307 send_agent_complete(qe, queuename, peer, member, callstart, vars, sizeof(vars), AGENT); 04308 } 04309 if ((tds = ast_channel_datastore_find(qe->chan, &queue_transfer_info, NULL))) { 04310 ast_channel_datastore_remove(qe->chan, tds); 04311 } 04312 update_queue(qe->parent, member, callcompletedinsl, (time(NULL) - callstart)); 04313 } else { 04314 /* We already logged the TRANSFER on the queue_log, but we still need to send the AgentComplete event */ 04315 send_agent_complete(qe, queuename, peer, member, callstart, vars, sizeof(vars), TRANSFER); 04316 } 04317 04318 if (transfer_ds) { 04319 ast_datastore_free(transfer_ds); 04320 } 04321 ast_channel_unlock(qe->chan); 04322 ast_hangup(peer); 04323 res = bridge ? bridge : 1; 04324 ao2_ref(member, -1); 04325 } 04326 out: 04327 hangupcalls(outgoing, NULL, qe->cancel_answered_elsewhere); 04328 04329 return res; 04330 }
| static int unload_module | ( | void | ) | [static] |
Definition at line 7171 of file app_queue.c.
References ao2_iterator_destroy(), ao2_iterator_init(), ao2_ref, ao2_t_iterator_next, ARRAY_LEN, ast_cli_unregister_multiple(), ast_context_destroy(), ast_context_find(), ast_context_remove_extension2(), ast_custom_function_unregister(), ast_event_unsubscribe(), ast_manager_unregister(), ast_taskprocessor_unreference(), ast_unload_realtime(), ast_unregister_application(), cli_queue, queue_t_unref, queuemembercount_dep, queuemembercount_function, queuememberlist_function, queuememberpenalty_function, queues, queues_t_unlink, queuevar_function, and queuewaitingcount_function.
07172 { 07173 int res; 07174 struct ast_context *con; 07175 struct ao2_iterator q_iter; 07176 struct call_queue *q = NULL; 07177 07178 ast_cli_unregister_multiple(cli_queue, ARRAY_LEN(cli_queue)); 07179 res = ast_manager_unregister("QueueStatus"); 07180 res |= ast_manager_unregister("Queues"); 07181 res |= ast_manager_unregister("QueueRule"); 07182 res |= ast_manager_unregister("QueueSummary"); 07183 res |= ast_manager_unregister("QueueAdd"); 07184 res |= ast_manager_unregister("QueueRemove"); 07185 res |= ast_manager_unregister("QueuePause"); 07186 res |= ast_manager_unregister("QueueLog"); 07187 res |= ast_manager_unregister("QueuePenalty"); 07188 res |= ast_unregister_application(app_aqm); 07189 res |= ast_unregister_application(app_rqm); 07190 res |= ast_unregister_application(app_pqm); 07191 res |= ast_unregister_application(app_upqm); 07192 res |= ast_unregister_application(app_ql); 07193 res |= ast_unregister_application(app); 07194 res |= ast_custom_function_unregister(&queuevar_function); 07195 res |= ast_custom_function_unregister(&queuemembercount_function); 07196 res |= ast_custom_function_unregister(&queuemembercount_dep); 07197 res |= ast_custom_function_unregister(&queuememberlist_function); 07198 res |= ast_custom_function_unregister(&queuewaitingcount_function); 07199 res |= ast_custom_function_unregister(&queuememberpenalty_function); 07200 07201 if (device_state_sub) 07202 ast_event_unsubscribe(device_state_sub); 07203 07204 if ((con = ast_context_find("app_queue_gosub_virtual_context"))) { 07205 ast_context_remove_extension2(con, "s", 1, NULL, 0); 07206 ast_context_destroy(con, "app_queue"); /* leave no trace */ 07207 } 07208 07209 q_iter = ao2_iterator_init(queues, 0); 07210 while ((q = ao2_t_iterator_next(&q_iter, "Iterate through queues"))) { 07211 queues_t_unlink(queues, q, "Remove queue from container due to unload"); 07212 queue_t_unref(q, "Done with iterator"); 07213 } 07214 ao2_iterator_destroy(&q_iter); 07215 ao2_ref(queues, -1); 07216 devicestate_tps = ast_taskprocessor_unreference(devicestate_tps); 07217 ast_unload_realtime("queue_members"); 07218 return res; 07219 }
| static void update_qe_rule | ( | struct queue_ent * | qe | ) | [static] |
update rules for queues
Calculate min/max penalties making sure if relative they stay within bounds. Update queues penalty and set dialplan vars, goto next list entry.
Definition at line 3174 of file app_queue.c.
References ast_debug, AST_LIST_NEXT, queue_ent::chan, queue_ent::max_penalty, penalty_rule::max_relative, penalty_rule::max_value, queue_ent::min_penalty, penalty_rule::min_relative, penalty_rule::min_value, ast_channel::name, pbx_builtin_setvar_helper(), queue_ent::pr, and penalty_rule::time.
Referenced by queue_exec(), and wait_our_turn().
03175 { 03176 int max_penalty = qe->pr->max_relative ? qe->max_penalty + qe->pr->max_value : qe->pr->max_value; 03177 int min_penalty = qe->pr->min_relative ? qe->min_penalty + qe->pr->min_value : qe->pr->min_value; 03178 char max_penalty_str[20], min_penalty_str[20]; 03179 /* a relative change to the penalty could put it below 0 */ 03180 if (max_penalty < 0) 03181 max_penalty = 0; 03182 if (min_penalty < 0) 03183 min_penalty = 0; 03184 if (min_penalty > max_penalty) 03185 min_penalty = max_penalty; 03186 snprintf(max_penalty_str, sizeof(max_penalty_str), "%d", max_penalty); 03187 snprintf(min_penalty_str, sizeof(min_penalty_str), "%d", min_penalty); 03188 pbx_builtin_setvar_helper(qe->chan, "QUEUE_MAX_PENALTY", max_penalty_str); 03189 pbx_builtin_setvar_helper(qe->chan, "QUEUE_MIN_PENALTY", min_penalty_str); 03190 qe->max_penalty = max_penalty; 03191 qe->min_penalty = min_penalty; 03192 ast_debug(3, "Setting max penalty to %d and min penalty to %d for caller %s since %d seconds have elapsed\n", qe->max_penalty, qe->min_penalty, qe->chan->name, qe->pr->time); 03193 qe->pr = AST_LIST_NEXT(qe->pr, list); 03194 }
| static int update_queue | ( | struct call_queue * | q, | |
| struct member * | member, | |||
| int | callcompletedinsl, | |||
| int | newtalktime | |||
| ) | [static] |
update the queue status
| Always | 0 |
Definition at line 3282 of file app_queue.c.
References ao2_find, ao2_iterator_destroy(), ao2_iterator_init(), ao2_lock(), ao2_ref, ao2_t_iterator_next, ao2_unlock(), member::calls, call_queue::callscompleted, call_queue::callscompletedinsl, member::lastcall, member::lastqueue, call_queue::members, OBJ_POINTER, queue_t_unref, queues, and call_queue::talktime.
Referenced by queue_transfer_fixup(), and try_calling().
03283 { 03284 int oldtalktime; 03285 03286 struct member *mem; 03287 struct call_queue *qtmp; 03288 struct ao2_iterator queue_iter; 03289 03290 if (shared_lastcall) { 03291 queue_iter = ao2_iterator_init(queues, 0); 03292 while ((qtmp = ao2_t_iterator_next(&queue_iter, "Iterate through queues"))) { 03293 ao2_lock(qtmp); 03294 if ((mem = ao2_find(qtmp->members, member, OBJ_POINTER))) { 03295 time(&mem->lastcall); 03296 mem->calls++; 03297 mem->lastqueue = q; 03298 ao2_ref(mem, -1); 03299 } 03300 ao2_unlock(qtmp); 03301 queue_t_unref(qtmp, "Done with iterator"); 03302 } 03303 ao2_iterator_destroy(&queue_iter); 03304 } else { 03305 ao2_lock(q); 03306 time(&member->lastcall); 03307 member->calls++; 03308 member->lastqueue = q; 03309 ao2_unlock(q); 03310 } 03311 ao2_lock(q); 03312 q->callscompleted++; 03313 if (callcompletedinsl) 03314 q->callscompletedinsl++; 03315 /* Calculate talktime using the same exponential average as holdtime code*/ 03316 oldtalktime = q->talktime; 03317 q->talktime = (((oldtalktime << 2) - oldtalktime) + newtalktime) >> 2; 03318 ao2_unlock(q); 03319 return 0; 03320 }
| static int update_realtime_member_field | ( | struct member * | mem, | |
| const char * | queue_name, | |||
| const char * | field, | |||
| const char * | value | |||
| ) | [static] |
Definition at line 1899 of file app_queue.c.
References ast_strlen_zero(), ast_update_realtime(), member::rt_uniqueid, and SENTINEL.
Referenced by set_member_paused().
01900 { 01901 int ret = -1; 01902 01903 if (ast_strlen_zero(mem->rt_uniqueid)) 01904 return ret; 01905 01906 if ((ast_update_realtime("queue_members", "uniqueid", mem->rt_uniqueid, field, value, SENTINEL)) > 0) 01907 ret = 0; 01908 01909 return ret; 01910 }
| static void update_realtime_members | ( | struct call_queue * | q | ) | [static] |
Definition at line 1913 of file app_queue.c.
References ao2_iterator_destroy(), ao2_iterator_init(), ao2_iterator_next, ao2_lock(), ao2_ref, ao2_unlink, ao2_unlock(), ast_category_browse(), ast_config_destroy(), ast_debug, ast_load_realtime_multientry(), ast_queue_log(), ast_variable_retrieve(), member::dead, member::interface, call_queue::membercount, call_queue::members, call_queue::name, queues, member::realtime, rt_handle_member_record(), S_OR, and SENTINEL.
Referenced by load_realtime_queue(), and queue_exec().
01914 { 01915 struct ast_config *member_config = NULL; 01916 struct member *m; 01917 char *interface = NULL; 01918 struct ao2_iterator mem_iter; 01919 01920 if (!(member_config = ast_load_realtime_multientry("queue_members", "interface LIKE", "%", "queue_name", q->name , SENTINEL))) { 01921 /*This queue doesn't have realtime members*/ 01922 ast_debug(3, "Queue %s has no realtime members defined. No need for update\n", q->name); 01923 return; 01924 } 01925 01926 ao2_lock(queues); 01927 ao2_lock(q); 01928 01929 /* Temporarily set realtime members dead so we can detect deleted ones.*/ 01930 mem_iter = ao2_iterator_init(q->members, 0); 01931 while ((m = ao2_iterator_next(&mem_iter))) { 01932 if (m->realtime) 01933 m->dead = 1; 01934 ao2_ref(m, -1); 01935 } 01936 ao2_iterator_destroy(&mem_iter); 01937 01938 while ((interface = ast_category_browse(member_config, interface))) { 01939 rt_handle_member_record(q, interface, 01940 ast_variable_retrieve(member_config, interface, "uniqueid"), 01941 S_OR(ast_variable_retrieve(member_config, interface, "membername"), interface), 01942 ast_variable_retrieve(member_config, interface, "penalty"), 01943 ast_variable_retrieve(member_config, interface, "paused"), 01944 S_OR(ast_variable_retrieve(member_config, interface, "state_interface"), interface)); 01945 } 01946 01947 /* Delete all realtime members that have been deleted in DB. */ 01948 mem_iter = ao2_iterator_init(q->members, 0); 01949 while ((m = ao2_iterator_next(&mem_iter))) { 01950 if (m->dead) { 01951 ast_queue_log(q->name, "REALTIME", m->interface, "REMOVEMEMBER", "%s", ""); 01952 ao2_unlink(q->members, m); 01953 q->membercount--; 01954 } 01955 ao2_ref(m, -1); 01956 } 01957 ao2_iterator_destroy(&mem_iter); 01958 ao2_unlock(q); 01959 ao2_unlock(queues); 01960 ast_config_destroy(member_config); 01961 }
| static int update_status | ( | struct call_queue * | q, | |
| struct member * | m, | |||
| const int | status | |||
| ) | [static] |
set a member's status based on device state of that member's state_interface.
Lock interface list find sc, iterate through each queues queue_member list for member to update state inside queues
Definition at line 1029 of file app_queue.c.
References EVENT_FLAG_AGENT, and manager_event.
Referenced by handle_statechange(), and ring_entry().
01030 { 01031 m->status = status; 01032 01033 if (q->maskmemberstatus) 01034 return 0; 01035 01036 manager_event(EVENT_FLAG_AGENT, "QueueMemberStatus", 01037 "Queue: %s\r\n" 01038 "Location: %s\r\n" 01039 "MemberName: %s\r\n" 01040 "Membership: %s\r\n" 01041 "Penalty: %d\r\n" 01042 "CallsTaken: %d\r\n" 01043 "LastCall: %d\r\n" 01044 "Status: %d\r\n" 01045 "Paused: %d\r\n", 01046 q->name, m->interface, m->membername, m->dynamic ? "dynamic" : m->realtime ? "realtime" : "static", 01047 m->penalty, m->calls, (int)m->lastcall, m->status, m->paused 01048 ); 01049 01050 return 0; 01051 }
| static int upqm_exec | ( | struct ast_channel * | chan, | |
| void * | data | |||
| ) | [static] |
UnPauseQueueMember application.
Definition at line 4811 of file app_queue.c.
References AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_log(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), LOG_WARNING, parse(), pbx_builtin_setvar_helper(), and set_member_paused().
Referenced by load_module().
04812 { 04813 char *parse; 04814 AST_DECLARE_APP_ARGS(args, 04815 AST_APP_ARG(queuename); 04816 AST_APP_ARG(interface); 04817 AST_APP_ARG(options); 04818 AST_APP_ARG(reason); 04819 ); 04820 04821 if (ast_strlen_zero(data)) { 04822 ast_log(LOG_WARNING, "UnpauseQueueMember requires an argument ([queuename],interface[,options[,reason]])\n"); 04823 return -1; 04824 } 04825 04826 parse = ast_strdupa(data); 04827 04828 AST_STANDARD_APP_ARGS(args, parse); 04829 04830 if (ast_strlen_zero(args.interface)) { 04831 ast_log(LOG_WARNING, "Missing interface argument to PauseQueueMember ([queuename],interface[,options[,reason]])\n"); 04832 return -1; 04833 } 04834 04835 if (set_member_paused(args.queuename, args.interface, args.reason, 0)) { 04836 ast_log(LOG_WARNING, "Attempt to unpause interface %s, not found\n", args.interface); 04837 pbx_builtin_setvar_helper(chan, "UPQMSTATUS", "NOTFOUND"); 04838 return 0; 04839 } 04840 04841 pbx_builtin_setvar_helper(chan, "UPQMSTATUS", "UNPAUSED"); 04842 04843 return 0; 04844 }
| static int valid_exit | ( | struct queue_ent * | qe, | |
| char | digit | |||
| ) | [static] |
Check for valid exit from queue via goto.
| 0 | if failure | |
| 1 | if successful |
Definition at line 2058 of file app_queue.c.
References ast_canmatch_extension(), ast_goto_if_exists(), ast_strlen_zero(), queue_ent::chan, ast_channel::cid, ast_callerid::cid_num, queue_ent::context, queue_ent::digits, and queue_ent::valid_digits.
Referenced by say_periodic_announcement(), say_position(), wait_a_bit(), wait_for_answer(), and wait_our_turn().
02059 { 02060 int digitlen = strlen(qe->digits); 02061 02062 /* Prevent possible buffer overflow */ 02063 if (digitlen < sizeof(qe->digits) - 2) { 02064 qe->digits[digitlen] = digit; 02065 qe->digits[digitlen + 1] = '\0'; 02066 } else { 02067 qe->digits[0] = '\0'; 02068 return 0; 02069 } 02070 02071 /* If there's no context to goto, short-circuit */ 02072 if (ast_strlen_zero(qe->context)) 02073 return 0; 02074 02075 /* If the extension is bad, then reset the digits to blank */ 02076 if (!ast_canmatch_extension(qe->chan, qe->context, qe->digits, 1, qe->chan->cid.cid_num)) { 02077 qe->digits[0] = '\0'; 02078 return 0; 02079 } 02080 02081 /* We have an exact match */ 02082 if (!ast_goto_if_exists(qe->chan, qe->context, qe->digits, 1)) { 02083 qe->valid_digits = 1; 02084 /* Return 1 on a successful goto */ 02085 return 1; 02086 } 02087 02088 return 0; 02089 }
| static char* vars2manager | ( | struct ast_channel * | chan, | |
| char * | vars, | |||
| size_t | len | |||
| ) | [static] |
convert "\n" to "\nVariable: " ready for manager to use
Definition at line 2427 of file app_queue.c.
References ast_copy_string(), ast_str_buffer(), ast_str_thread_get(), buf, and pbx_builtin_serialize_variables().
Referenced by ring_entry(), rna(), send_agent_complete(), and try_calling().
02428 { 02429 struct ast_str *buf = ast_str_thread_get(&ast_str_thread_global_buf, len + 1); 02430 char *tmp; 02431 02432 if (pbx_builtin_serialize_variables(chan, &buf)) { 02433 int i, j; 02434 02435 /* convert "\n" to "\nVariable: " */ 02436 strcpy(vars, "Variable: "); 02437 tmp = ast_str_buffer(buf); 02438 02439 for (i = 0, j = 10; (i < len - 1) && (j < len - 1); i++, j++) { 02440 vars[j] = tmp[i]; 02441 02442 if (tmp[i + 1] == '\0') 02443 break; 02444 if (tmp[i] == '\n') { 02445 vars[j++] = '\r'; 02446 vars[j++] = '\n'; 02447 02448 ast_copy_string(&(vars[j]), "Variable: ", len - j); 02449 j += 9; 02450 } 02451 } 02452 if (j > len - 3) 02453 j = len - 3; 02454 vars[j++] = '\r'; 02455 vars[j++] = '\n'; 02456 vars[j] = '\0'; 02457 } else { 02458 /* there are no channel variables; leave it blank */ 02459 *vars = '\0'; 02460 } 02461 return vars; 02462 }
| static int wait_a_bit | ( | struct queue_ent * | qe | ) | [static] |
Definition at line 4332 of file app_queue.c.
References ast_waitfordigit(), queue_ent::chan, queue_ent::parent, call_queue::retry, and valid_exit().
Referenced by queue_exec().
04333 { 04334 /* Don't need to hold the lock while we setup the outgoing calls */ 04335 int retrywait = qe->parent->retry * 1000; 04336 04337 int res = ast_waitfordigit(qe->chan, retrywait); 04338 if (res > 0 && !valid_exit(qe, res)) 04339 res = 0; 04340 04341 return res; 04342 }
| static struct callattempt* wait_for_answer | ( | struct queue_ent * | qe, | |
| struct callattempt * | outgoing, | |||
| int * | to, | |||
| char * | digit, | |||
| int | prebusies, | |||
| int | caller_disconnect, | |||
| int | forwardsallowed | |||
| ) | [static, read] |
Wait for a member to answer the call.
| [in] | qe | the queue_ent corresponding to the caller in the queue |
| [in] | outgoing | the list of callattempts. Relevant ones will have their chan and stillgoing parameters non-zero |
| [in] | to | the amount of time (in milliseconds) to wait for a response |
| [out] | digit | if a user presses a digit to exit the queue, this is the digit the caller pressed |
| [in] | prebusies | number of busy members calculated prior to calling wait_for_answer |
| [in] | caller_disconnect | if the 'H' option is used when calling Queue(), this is used to detect if the caller pressed * to disconnect the call |
| [in] | forwardsallowed | used to detect if we should allow call forwarding, based on the 'i' option to Queue() |
Definition at line 2856 of file app_queue.c.
References ast_channel::_state, ast_channel::accountcode, accountcode, ast_call(), ast_cdr_busy(), ast_channel_datastore_inherit(), ast_channel_inherit_variables(), AST_CONTROL_ANSWER, AST_CONTROL_BUSY, AST_CONTROL_CONGESTION, AST_CONTROL_HANGUP, AST_CONTROL_OFFHOOK, AST_CONTROL_RINGING, ast_copy_string(), ast_debug, AST_FRAME_CONTROL, AST_FRAME_DTMF, ast_free, ast_frfree, ast_hangup(), ast_log(), AST_MAX_WATCHERS, ast_poll_channel_add(), ast_poll_channel_del(), ast_read(), ast_request(), AST_STATE_UP, ast_strdup, ast_string_field_set, ast_strlen_zero(), ast_verb, ast_waitfor_n(), ast_channel::call_forward, callattempt::call_next, ast_channel::cdr, ast_channel::cdrflags, callattempt::chan, queue_ent::chan, ast_channel::cid, ast_callerid::cid_ani, ast_callerid::cid_name, ast_callerid::cid_num, ast_callerid::cid_rdnis, ast_channel::context, ast_frame::data, do_hang(), ast_channel::exten, f, ast_frame::frametype, ast_channel::hangupcause, callattempt::interface, member::interface, LOG_NOTICE, ast_channel::macroexten, callattempt::member, member::membername, ast_channel::name, call_queue::name, ast_channel::nativeformats, queue_ent::parent, queue_ent::pos, callattempt::q_next, QUEUE_STRATEGY_RINGALL, ring_one(), rna(), S_OR, queue_ent::start, starttime, status, callattempt::stillgoing, call_queue::strategy, ast_frame::subclass, ast_channel::tech, call_queue::timeoutrestart, ast_frame::uint32, and valid_exit().
Referenced by try_calling().
02857 { 02858 const char *queue = qe->parent->name; 02859 struct callattempt *o, *start = NULL, *prev = NULL; 02860 int status; 02861 int numbusies = prebusies; 02862 int numnochan = 0; 02863 int stillgoing = 0; 02864 int orig = *to; 02865 struct ast_frame *f; 02866 struct callattempt *peer = NULL; 02867 struct ast_channel *winner; 02868 struct ast_channel *in = qe->chan; 02869 char on[80] = ""; 02870 char membername[80] = ""; 02871 long starttime = 0; 02872 long endtime = 0; 02873 #ifdef HAVE_EPOLL 02874 struct callattempt *epollo; 02875 #endif 02876 02877 starttime = (long) time(NULL); 02878 #ifdef HAVE_EPOLL 02879 for (epollo = outgoing; epollo; epollo = epollo->q_next) { 02880 if (epollo->chan) 02881 ast_poll_channel_add(in, epollo->chan); 02882 } 02883 #endif 02884 02885 while (*to && !peer) { 02886 int numlines, retry, pos = 1; 02887 struct ast_channel *watchers[AST_MAX_WATCHERS]; 02888 watchers[0] = in; 02889 start = NULL; 02890 02891 for (retry = 0; retry < 2; retry++) { 02892 numlines = 0; 02893 for (o = outgoing; o; o = o->q_next) { /* Keep track of important channels */ 02894 if (o->stillgoing) { /* Keep track of important channels */ 02895 stillgoing = 1; 02896 if (o->chan) { 02897 watchers[pos++] = o->chan; 02898 if (!start) 02899 start = o; 02900 else 02901 prev->call_next = o; 02902 prev = o; 02903 } 02904 } 02905 numlines++; 02906 } 02907 if (pos > 1 /* found */ || !stillgoing /* nobody listening */ || 02908 (qe->parent->strategy != QUEUE_STRATEGY_RINGALL) /* ring would not be delivered */) 02909 break; 02910 /* On "ringall" strategy we only move to the next penalty level 02911 when *all* ringing phones are done in the current penalty level */ 02912 ring_one(qe, outgoing, &numbusies); 02913 /* and retry... */ 02914 } 02915 if (pos == 1 /* not found */) { 02916 if (numlines == (numbusies + numnochan)) { 02917 ast_debug(1, "Everyone is busy at this time\n"); 02918 } else { 02919 ast_debug(3, "No one is answering queue '%s' (%d numlines / %d busies / %d failed channels)\n", queue, numlines, numbusies, numnochan); 02920 } 02921 *to = 0; 02922 return NULL; 02923 } 02924 02925 /* Poll for events from both the incoming channel as well as any outgoing channels */ 02926 winner = ast_waitfor_n(watchers, pos, to); 02927 02928 /* Service all of the outgoing channels */ 02929 for (o = start; o; o = o->call_next) { 02930 if (o->stillgoing && (o->chan) && (o->chan->_state == AST_STATE_UP)) { 02931 if (!peer) { 02932 ast_verb(3, "%s answered %s\n", o->chan->name, in->name); 02933 peer = o; 02934 } 02935 } else if (o->chan && (o->chan == winner)) { 02936 02937 ast_copy_string(on, o->member->interface, sizeof(on)); 02938 ast_copy_string(membername, o->member->membername, sizeof(membername)); 02939 02940 if (!ast_strlen_zero(o->chan->call_forward) && !forwardsallowed) { 02941 ast_verb(3, "Forwarding %s to '%s' prevented.\n", in->name, o->chan->call_forward); 02942 numnochan++; 02943 do_hang(o); 02944 winner = NULL; 02945 continue; 02946 } else if (!ast_strlen_zero(o->chan->call_forward)) { 02947 char tmpchan[256]; 02948 char *stuff; 02949 char *tech; 02950 02951 ast_copy_string(tmpchan, o->chan->call_forward, sizeof(tmpchan)); 02952 if ((stuff = strchr(tmpchan, '/'))) { 02953 *stuff++ = '\0'; 02954 tech = tmpchan; 02955 } else { 02956 snprintf(tmpchan, sizeof(tmpchan), "%s@%s", o->chan->call_forward, o->chan->context); 02957 stuff = tmpchan; 02958 tech = "Local"; 02959 } 02960 /* Before processing channel, go ahead and check for forwarding */ 02961 ast_verb(3, "Now forwarding %s to '%s/%s' (thanks to %s)\n", in->name, tech, stuff, o->chan->name); 02962 /* Setup parameters */ 02963 o->chan = ast_request(tech, in->nativeformats, stuff, &status); 02964 if (!o->chan) { 02965 ast_log(LOG_NOTICE, "Unable to create local channel for call forward to '%s/%s'\n", tech, stuff); 02966 o->stillgoing = 0; 02967 numnochan++; 02968 } else { 02969 ast_channel_inherit_variables(in, o->chan); 02970 ast_channel_datastore_inherit(in, o->chan); 02971 if (o->chan->cid.cid_num) 02972 ast_free(o->chan->cid.cid_num); 02973 o->chan->cid.cid_num = ast_strdup(in->cid.cid_num); 02974 02975 if (o->chan->cid.cid_name) 02976 ast_free(o->chan->cid.cid_name); 02977 o->chan->cid.cid_name = ast_strdup(in->cid.cid_name); 02978 02979 ast_string_field_set(o->chan, accountcode, in->accountcode); 02980 o->chan->cdrflags = in->cdrflags; 02981 02982 if (in->cid.cid_ani) { 02983 if (o->chan->cid.cid_ani) 02984 ast_free(o->chan->cid.cid_ani); 02985 o->chan->cid.cid_ani = ast_strdup(in->cid.cid_ani); 02986 } 02987 if (o->chan->cid.cid_rdnis) 02988 ast_free(o->chan->cid.cid_rdnis); 02989 o->chan->cid.cid_rdnis = ast_strdup(S_OR(in->macroexten, in->exten)); 02990 if (ast_call(o->chan, tmpchan, 0)) { 02991 ast_log(LOG_NOTICE, "Failed to dial on local channel for call forward to '%s'\n", tmpchan); 02992 do_hang(o); 02993 numnochan++; 02994 } 02995 } 02996 /* Hangup the original channel now, in case we needed it */ 02997 ast_hangup(winner); 02998 continue; 02999 } 03000 f = ast_read(winner); 03001 if (f) { 03002 if (f->frametype == AST_FRAME_CONTROL) { 03003 switch (f->subclass) { 03004 case AST_CONTROL_ANSWER: 03005 /* This is our guy if someone answered. */ 03006 if (!peer) { 03007 ast_verb(3, "%s answered %s\n", o->chan->name, in->name); 03008 peer = o; 03009 } 03010 break; 03011 case AST_CONTROL_BUSY: 03012 ast_verb(3, "%s is busy\n", o->chan->name); 03013 if (in->cdr) 03014 ast_cdr_busy(in->cdr); 03015 do_hang(o); 03016 endtime = (long) time(NULL); 03017 endtime -= starttime; 03018 rna(endtime * 1000, qe, on, membername, 0); 03019 if (qe->parent->strategy != QUEUE_STRATEGY_RINGALL) { 03020 if (qe->parent->timeoutrestart) 03021 *to = orig; 03022 /* Have enough time for a queue member to answer? */ 03023 if (*to > 500) { 03024 ring_one(qe, outgoing, &numbusies); 03025 starttime = (long) time(NULL); 03026 } 03027 } 03028 numbusies++; 03029 break; 03030 case AST_CONTROL_CONGESTION: 03031 ast_verb(3, "%s is circuit-busy\n", o->chan->name); 03032 if (in->cdr) 03033 ast_cdr_busy(in->cdr); 03034 endtime = (long) time(NULL); 03035 endtime -= starttime; 03036 rna(endtime * 1000, qe, on, membername, 0); 03037 do_hang(o); 03038 if (qe->parent->strategy != QUEUE_STRATEGY_RINGALL) { 03039 if (qe->parent->timeoutrestart) 03040 *to = orig; 03041 if (*to > 500) { 03042 ring_one(qe, outgoing, &numbusies); 03043 starttime = (long) time(NULL); 03044 } 03045 } 03046 numbusies++; 03047 break; 03048 case AST_CONTROL_RINGING: 03049 ast_verb(3, "%s is ringing\n", o->chan->name); 03050 break; 03051 case AST_CONTROL_OFFHOOK: 03052 /* Ignore going off hook */ 03053 break; 03054 default: 03055 ast_debug(1, "Dunno what to do with control type %d\n", f->subclass); 03056 } 03057 } 03058 ast_frfree(f); 03059 } else { /* ast_read() returned NULL */ 03060 endtime = (long) time(NULL) - starttime; 03061 rna(endtime * 1000, qe, on, membername, 1); 03062 do_hang(o); 03063 if (qe->parent->strategy != QUEUE_STRATEGY_RINGALL) { 03064 if (qe->parent->timeoutrestart) 03065 *to = orig; 03066 if (*to > 500) { 03067 ring_one(qe, outgoing, &numbusies); 03068 starttime = (long) time(NULL); 03069 } 03070 } 03071 } 03072 } 03073 } 03074 03075 /* If we received an event from the caller, deal with it. */ 03076 if (winner == in) { 03077 f = ast_read(in); 03078 if (!f || ((f->frametype == AST_FRAME_CONTROL) && (f->subclass == AST_CONTROL_HANGUP))) { 03079 /* Got hung up */ 03080 *to = -1; 03081 if (f) { 03082 if (f->data.uint32) { 03083 in->hangupcause = f->data.uint32; 03084 } 03085 ast_frfree(f); 03086 } 03087 return NULL; 03088 } 03089 if ((f->frametype == AST_FRAME_DTMF) && caller_disconnect && (f->subclass == '*')) { 03090 ast_verb(3, "User hit %c to disconnect call.\n", f->subclass); 03091 *to = 0; 03092 ast_frfree(f); 03093 return NULL; 03094 } 03095 if ((f->frametype == AST_FRAME_DTMF) && valid_exit(qe, f->subclass)) { 03096 ast_verb(3, "User pressed digit: %c\n", f->subclass); 03097 *to = 0; 03098 *digit = f->subclass; 03099 ast_frfree(f); 03100 return NULL; 03101 } 03102 ast_frfree(f); 03103 } 03104 if (!*to) { 03105 for (o = start; o; o = o->call_next) 03106 rna(orig, qe, o->interface, o->member->membername, 1); 03107 } 03108 } 03109 03110 #ifdef HAVE_EPOLL 03111 for (epollo = outgoing; epollo; epollo = epollo->q_next) { 03112 if (epollo->chan) 03113 ast_poll_channel_del(in, epollo->chan); 03114 } 03115 #endif 03116 03117 return peer; 03118 }
| static int wait_our_turn | ( | struct queue_ent * | qe, | |
| int | ringing, | |||
| enum queue_result * | reason | |||
| ) | [static] |
The waiting areas for callers who are not actively calling members.
This function is one large loop. This function will return if a caller either exits the queue or it becomes that caller's turn to attempt calling queue members. Inside the loop, we service the caller with periodic announcements, holdtime announcements, etc. as configured in queues.conf
| 0 | if the caller's turn has arrived | |
| -1 | if the caller should exit the queue. |
Definition at line 3206 of file app_queue.c.
References call_queue::announcefrequency, ast_queue_log(), ast_waitfordigit(), queue_ent::chan, queue_ent::expire, get_member_status(), is_our_turn(), leave_queue(), call_queue::leavewhenempty, queue_ent::max_penalty, queue_ent::min_penalty, call_queue::name, queue_ent::opos, queue_ent::parent, call_queue::periodicannouncefrequency, queue_ent::pos, queue_ent::pr, QUEUE_LEAVEEMPTY, QUEUE_TIMEOUT, RECHECK, say_periodic_announcement(), say_position(), queue_ent::start, status, penalty_rule::time, ast_channel::uniqueid, update_qe_rule(), and valid_exit().
Referenced by queue_exec().
03207 { 03208 int res = 0; 03209 03210 /* This is the holding pen for callers 2 through maxlen */ 03211 for (;;) { 03212 03213 if (is_our_turn(qe)) 03214 break; 03215 03216 /* If we have timed out, break out */ 03217 if (qe->expire && (time(NULL) >= qe->expire)) { 03218 *reason = QUEUE_TIMEOUT; 03219 break; 03220 } 03221 03222 if (qe->parent->leavewhenempty) { 03223 int status = 0; 03224 03225 if ((status = get_member_status(qe->parent, qe->max_penalty, qe->min_penalty, qe->parent->leavewhenempty))) { 03226 *reason = QUEUE_LEAVEEMPTY; 03227 ast_queue_log(qe->parent->name, qe->chan->uniqueid, "NONE", "EXITEMPTY", "%d|%d|%ld", qe->pos, qe->opos, (long) time(NULL) - qe->start); 03228 leave_queue(qe); 03229 break; 03230 } 03231 } 03232 03233 /* Make a position announcement, if enabled */ 03234 if (qe->parent->announcefrequency && 03235 (res = say_position(qe,ringing))) 03236 break; 03237 03238 /* If we have timed out, break out */ 03239 if (qe->expire && (time(NULL) >= qe->expire)) { 03240 *reason = QUEUE_TIMEOUT; 03241 break; 03242 } 03243 03244 /* Make a periodic announcement, if enabled */ 03245 if (qe->parent->periodicannouncefrequency && 03246 (res = say_periodic_announcement(qe,ringing))) 03247 break; 03248 03249 /* see if we need to move to the next penalty level for this queue */ 03250 while (qe->pr && ((time(NULL) - qe->start) >= qe->pr->time)) { 03251 update_qe_rule(qe); 03252 } 03253 03254 /* If we have timed out, break out */ 03255 if (qe->expire && (time(NULL) >= qe->expire)) { 03256 *reason = QUEUE_TIMEOUT; 03257 break; 03258 } 03259 03260 /* Wait a second before checking again */ 03261 if ((res = ast_waitfordigit(qe->chan, RECHECK * 1000))) { 03262 if (res > 0 && !valid_exit(qe, res)) 03263 res = 0; 03264 else 03265 break; 03266 } 03267 03268 /* If we have timed out, break out */ 03269 if (qe->expire && (time(NULL) >= qe->expire)) { 03270 *reason = QUEUE_TIMEOUT; 03271 break; 03272 } 03273 } 03274 03275 return res; 03276 }
struct ast_module_info __mod_info = { .name = AST_MODULE, .flags = AST_MODFLAG_DEFAULT , .description = "True Call Queueing" , .key = "This paragraph is copyright (c) 2006 by Digium, Inc. \In order for your module to load, it must return this \key via a function called \"key\". Any code which \includes this paragraph must be licensed under the GNU \General Public License version 2 or later (at your \option). In addition to Digium's general reservations \of rights, Digium expressly reserves the right to \allow other parties to license this paragraph under \different terms. Any use of Digium, Inc. trademarks or \logos (including \"Asterisk\" or \"Digium\") without \express written permission of Digium, Inc. is prohibited.\n" , .buildopt_sum = AST_BUILDOPT_SUM, .load = load_module, .unload = unload_module, .reload = reload, } [static] |
Definition at line 7293 of file app_queue.c.
char* app = "Queue" [static] |
Definition at line 540 of file app_queue.c.
char* app_aqm = "AddQueueMember" [static] |
Definition at line 542 of file app_queue.c.
char* app_pqm = "PauseQueueMember" [static] |
Definition at line 546 of file app_queue.c.
char* app_ql = "QueueLog" [static] |
Definition at line 550 of file app_queue.c.
char* app_rqm = "RemoveQueueMember" [static] |
Definition at line 544 of file app_queue.c.
char* app_upqm = "UnpauseQueueMember" [static] |
Definition at line 548 of file app_queue.c.
struct ast_module_info* ast_module_info = &__mod_info [static] |
Definition at line 7293 of file app_queue.c.
int autofill_default = 0 [static] |
struct ast_cli_entry cli_queue[] [static] |
struct ast_event_sub* device_state_sub [static] |
struct ast_taskprocessor* devicestate_tps [static] |
Definition at line 524 of file app_queue.c.
| enum queue_result id |
Definition at line 590 of file app_queue.c.
Referenced by _sip_show_peers(), _skinny_show_devices(), _skinny_show_lines(), amixer_max(), idemodulator(), and setamixer().
int montype_default = 0 [static] |
const char* pm_family = "Queue/PersistentMembers" [static] |
const char qpm_cmd_usage[] [static] |
Initial value:
"Usage: queue pause member <channel> in <queue> reason <reason>\n"
Definition at line 7151 of file app_queue.c.
const char qsmp_cmd_usage[] [static] |
Initial value:
"Usage: queue set member penalty <channel> from <queue> <penalty>\n"
Definition at line 7157 of file app_queue.c.
int queue_persistent_members = 0 [static] |
| struct { ... } queue_results[] |
Referenced by set_queue_result().
struct ast_datastore_info queue_transfer_info [static] |
Initial value:
{
.type = "queue_transfer",
.chan_fixup = queue_transfer_fixup,
.destroy = queue_transfer_destroy,
}
Definition at line 3445 of file app_queue.c.
Referenced by attended_transfer_occurred(), queue_transfer_fixup(), setup_transfer_datastore(), and try_calling().
struct ast_custom_function queuemembercount_dep [static] |
Initial value:
{
.name = "QUEUE_MEMBER_COUNT",
.read = queue_function_qac_dep,
}
Definition at line 5624 of file app_queue.c.
Referenced by load_module(), and unload_module().
struct ast_custom_function queuemembercount_function [static] |
Initial value:
{
.name = "QUEUE_MEMBER",
.read = queue_function_qac,
}
Definition at line 5619 of file app_queue.c.
Referenced by load_module(), and unload_module().
struct ast_custom_function queuememberlist_function [static] |
Initial value:
{
.name = "QUEUE_MEMBER_LIST",
.read = queue_function_queuememberlist,
}
Definition at line 5634 of file app_queue.c.
Referenced by load_module(), and unload_module().
struct ast_custom_function queuememberpenalty_function [static] |
Initial value:
{
.name = "QUEUE_MEMBER_PENALTY",
.read = queue_function_memberpenalty_read,
.write = queue_function_memberpenalty_write,
}
Definition at line 5639 of file app_queue.c.
Referenced by load_module(), and unload_module().
struct ao2_container* queues [static] |
Definition at line 818 of file app_queue.c.
Referenced by __queues_show(), add_to_queue(), clear_stats(), compare_weight(), complete_queue(), complete_queue_remove_member(), find_queue_by_name_rt(), get_member_penalty(), handle_statechange(), join_queue(), leave_queue(), load_module(), load_realtime_queue(), manager_queues_status(), manager_queues_summary(), queue_function_queuememberlist(), queue_function_queuewaitingcount(), queue_function_var(), reload_queue_members(), reload_queues(), reload_single_queue(), remove_from_queue(), set_member_paused(), set_member_penalty(), try_calling(), unload_module(), update_queue(), and update_realtime_members().
struct ast_custom_function queuevar_function [static] |
Initial value:
{
.name = "QUEUE_VARIABLES",
.read = queue_function_var,
}
Definition at line 5614 of file app_queue.c.
Referenced by load_module(), and unload_module().
struct ast_custom_function queuewaitingcount_function [static] |
Initial value:
{
.name = "QUEUE_WAITING_COUNT",
.read = queue_function_queuewaitingcount,
}
Definition at line 5629 of file app_queue.c.
Referenced by load_module(), and unload_module().
const char qum_cmd_usage[] [static] |
Initial value:
"Usage: queue unpause member <channel> in <queue> reason <reason>\n"
Definition at line 7154 of file app_queue.c.
int shared_lastcall = 0 [static] |
struct strategy strategies[] [static] |
Referenced by int2strat(), and strat2int().
| char* text |
Definition at line 591 of file app_queue.c.
Referenced by _sip_show_peer(), build_reply_digest(), check_auth(), festival_exec(), handle_response(), iconv_read(), method_match(), parse_sip_options(), process_sdp(), reqprep(), sendtext_exec(), set_queue_result(), and sip_new().
int update_cdr = 0 [static] |
queues.conf [general] option
Definition at line 576 of file app_queue.c.
Referenced by login_exec().
int use_weight = 0 [static] |
1.5.9