add presence to mod_valet_parking subscribe to the lot name for general stats or individual slots to monitor with park+ prefix *note* this used to be used in mod_fifo which now will use queue+ going forward
This commit is contained in:
parent
34ddeb754f
commit
9daa42c1b5
|
@ -887,7 +887,7 @@ static switch_status_t conference_add_member(conference_obj_t *conference, confe
|
||||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO);
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO);
|
||||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", conference->name);
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", conference->name);
|
||||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", conference->name, conference->domain);
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", conference->name, conference->domain);
|
||||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Active (%d caller%s)", conference->count, conference->count == 1 ? "" : "s");
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "force-status", "Active (%d caller%s)", conference->count, conference->count == 1 ? "" : "s");
|
||||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
|
||||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog");
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog");
|
||||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_count", "%d", EC++);
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_count", "%d", EC++);
|
||||||
|
@ -1108,7 +1108,7 @@ static switch_status_t conference_del_member(conference_obj_t *conference, confe
|
||||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO);
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO);
|
||||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", conference->name);
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", conference->name);
|
||||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", conference->name, conference->domain);
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", conference->name, conference->domain);
|
||||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Active (%d caller%s)", conference->count, conference->count == 1 ? "" : "s");
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "force-status", "Active (%d caller%s)", conference->count, conference->count == 1 ? "" : "s");
|
||||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
|
||||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog");
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog");
|
||||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_count", "%d", EC++);
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_count", "%d", EC++);
|
||||||
|
@ -1702,7 +1702,7 @@ static void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, v
|
||||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO);
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO);
|
||||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", conference->name);
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", conference->name);
|
||||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", conference->name, conference->domain);
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", conference->name, conference->domain);
|
||||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "status", "Inactive");
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "force-status", "Inactive");
|
||||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", "idle");
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", "idle");
|
||||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
|
||||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog");
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog");
|
||||||
|
@ -7195,7 +7195,7 @@ static void pres_event_handler(switch_event_t *event)
|
||||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO);
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO);
|
||||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", conference->name);
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", conference->name);
|
||||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", conference->name, conference->domain);
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", conference->name, conference->domain);
|
||||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "status", "Active (%d caller%s)", conference->count, conference->count == 1 ? "" : "s");
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "force-status", "Active (%d caller%s)", conference->count, conference->count == 1 ? "" : "s");
|
||||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
|
||||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog");
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog");
|
||||||
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_count", "%d", EC++);
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_count", "%d", EC++);
|
||||||
|
@ -7209,7 +7209,7 @@ static void pres_event_handler(switch_event_t *event)
|
||||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO);
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO);
|
||||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", conf_name);
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", conf_name);
|
||||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", to);
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", to);
|
||||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "status", "Idle");
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "force-status", "Idle");
|
||||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", "idle");
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", "idle");
|
||||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
|
||||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog");
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog");
|
||||||
|
@ -7250,7 +7250,7 @@ static void send_presence(switch_event_types_t id)
|
||||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO);
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", CONF_CHAT_PROTO);
|
||||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", name);
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", name);
|
||||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", name);
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", name);
|
||||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "status", status ? status : "Available");
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "force-status", status ? status : "Available");
|
||||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", "idle");
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", "idle");
|
||||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
|
||||||
switch_event_fire(&event);
|
switch_event_fire(&event);
|
||||||
|
|
|
@ -1928,7 +1928,7 @@ static void send_presence(fifo_node_t *node)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
|
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
|
||||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", "park");
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", "queue");
|
||||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", node->name);
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", node->name);
|
||||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", node->name);
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", node->name);
|
||||||
if ((wait_count = node_caller_count(node)) > 0) {
|
if ((wait_count = node_caller_count(node)) > 0) {
|
||||||
|
@ -1959,7 +1959,7 @@ static void pres_event_handler(switch_event_t *event)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!to || strncasecmp(to, "park+", 5)) {
|
if (!to || strncasecmp(to, "queue+", 5)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,9 @@
|
||||||
*/
|
*/
|
||||||
#include <switch.h>
|
#include <switch.h>
|
||||||
#define VALET_EVENT "valet_parking::info"
|
#define VALET_EVENT "valet_parking::info"
|
||||||
|
#define VALET_PROTO "park"
|
||||||
|
|
||||||
|
|
||||||
/* Prototypes */
|
/* Prototypes */
|
||||||
SWITCH_MODULE_LOAD_FUNCTION(mod_valet_parking_load);
|
SWITCH_MODULE_LOAD_FUNCTION(mod_valet_parking_load);
|
||||||
|
|
||||||
|
@ -42,6 +45,7 @@ typedef struct {
|
||||||
char ext[256];
|
char ext[256];
|
||||||
char uuid[SWITCH_UUID_FORMATTED_LENGTH + 1];
|
char uuid[SWITCH_UUID_FORMATTED_LENGTH + 1];
|
||||||
time_t timeout;
|
time_t timeout;
|
||||||
|
int bridged;
|
||||||
} valet_token_t;
|
} valet_token_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -181,6 +185,129 @@ static valet_token_t *next_id(switch_core_session_t *session, valet_lot_t *lot,
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int valet_lot_count(valet_lot_t *lot)
|
||||||
|
{
|
||||||
|
switch_hash_index_t *i_hi;
|
||||||
|
const void *i_var;
|
||||||
|
void *i_val;
|
||||||
|
valet_token_t *token;
|
||||||
|
int count = 0;
|
||||||
|
time_t now;
|
||||||
|
|
||||||
|
now = switch_epoch_time_now(NULL);
|
||||||
|
|
||||||
|
switch_mutex_lock(lot->mutex);
|
||||||
|
for (i_hi = switch_hash_first(NULL, lot->hash); i_hi; i_hi = switch_hash_next(i_hi)) {
|
||||||
|
switch_hash_this(i_hi, &i_var, NULL, &i_val);
|
||||||
|
token = (valet_token_t *) i_val;
|
||||||
|
if (token->timeout > 0 && (token->timeout < now || token->timeout == 1)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
switch_mutex_unlock(lot->mutex);
|
||||||
|
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int EC = 0;
|
||||||
|
|
||||||
|
static void valet_send_presence(const char *lot_name, valet_lot_t *lot, valet_token_t *token, switch_bool_t in)
|
||||||
|
{
|
||||||
|
|
||||||
|
char *domain_name, *dup_domain_name = NULL;
|
||||||
|
switch_event_t *event;
|
||||||
|
int count;
|
||||||
|
|
||||||
|
if ((domain_name = strchr(lot_name, '@'))) {
|
||||||
|
domain_name++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (zstr(domain_name)) {
|
||||||
|
dup_domain_name = switch_core_get_variable_dup("domain");
|
||||||
|
domain_name = dup_domain_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (zstr(domain_name)) {
|
||||||
|
domain_name = "cluecon.com";
|
||||||
|
}
|
||||||
|
|
||||||
|
count = valet_lot_count(lot);
|
||||||
|
|
||||||
|
if (count > 0) {
|
||||||
|
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", VALET_PROTO);
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", lot_name);
|
||||||
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", lot_name, domain_name);
|
||||||
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "force-status", "Active (%d caller%s)", count, count == 1 ? "" : "s");
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", "active");
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog");
|
||||||
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_count", "%d", EC++);
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "unique-id", lot_name);
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "channel-state", "CS_ROUTING");
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "answer-state", "confirmed");
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-direction", "inbound");
|
||||||
|
switch_event_fire(&event);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", VALET_PROTO);
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", lot_name);
|
||||||
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", lot_name, domain_name);
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "force-status", "Empty");
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", "idle");
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog");
|
||||||
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_count", "%d", EC++);
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "unique-id", lot_name);
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "channel-state", "CS_HANGUP");
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "answer-state", "terminated");
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-direction", "inbound");
|
||||||
|
switch_event_fire(&event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (in) {
|
||||||
|
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", VALET_PROTO);
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", token->ext);
|
||||||
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", token->ext, domain_name);
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "force-status", token->bridged == 0 ? "Holding" : "Active");
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", "active");
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog");
|
||||||
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_count", "%d", EC++);
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "unique-id", token->ext);
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "channel-state", "CS_ROUTING");
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "answer-state", "confirmed");
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-direction", token->bridged == 0 ? "outbound" : "inbound");
|
||||||
|
switch_event_fire(&event);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", VALET_PROTO);
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", token->ext);
|
||||||
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", token->ext, domain_name);
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "force-status", "Empty");
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", "idle");
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog");
|
||||||
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_count", "%d", EC++);
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "unique-id", token->ext);
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "channel-state", "CS_HANGUP");
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "answer-state", "terminated");
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-direction", "inbound");
|
||||||
|
switch_event_fire(&event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch_safe_free(dup_domain_name);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#define VALET_APP_SYNTAX "<lotname> <extension>|[ask [<min>] [<max>] [<to>] [<prompt>]|auto in [min] [max]]"
|
#define VALET_APP_SYNTAX "<lotname> <extension>|[ask [<min>] [<max>] [<to>] [<prompt>]|auto in [min] [max]]"
|
||||||
SWITCH_STANDARD_APP(valet_parking_function)
|
SWITCH_STANDARD_APP(valet_parking_function)
|
||||||
|
@ -299,6 +426,8 @@ SWITCH_STANDARD_APP(valet_parking_function)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!token) {
|
if (!token) {
|
||||||
|
|
||||||
|
|
||||||
switch_mutex_lock(lot->mutex);
|
switch_mutex_lock(lot->mutex);
|
||||||
if ((token = (valet_token_t *) switch_core_hash_find(lot->hash, ext))) {
|
if ((token = (valet_token_t *) switch_core_hash_find(lot->hash, ext))) {
|
||||||
switch_core_session_t *b_session;
|
switch_core_session_t *b_session;
|
||||||
|
@ -329,6 +458,8 @@ SWITCH_STANDARD_APP(valet_parking_function)
|
||||||
switch_event_fire(&event);
|
switch_event_fire(&event);
|
||||||
switch_core_session_rwunlock(b_session);
|
switch_core_session_rwunlock(b_session);
|
||||||
token->timeout = 0;
|
token->timeout = 0;
|
||||||
|
token->bridged = 1;
|
||||||
|
|
||||||
switch_ivr_uuid_bridge(switch_core_session_get_uuid(session), token->uuid);
|
switch_ivr_uuid_bridge(switch_core_session_get_uuid(session), token->uuid);
|
||||||
switch_mutex_unlock(lot->mutex);
|
switch_mutex_unlock(lot->mutex);
|
||||||
return;
|
return;
|
||||||
|
@ -340,6 +471,7 @@ SWITCH_STANDARD_APP(valet_parking_function)
|
||||||
|
|
||||||
switch_zmalloc(token, sizeof(*token));
|
switch_zmalloc(token, sizeof(*token));
|
||||||
switch_set_string(token->uuid, switch_core_session_get_uuid(session));
|
switch_set_string(token->uuid, switch_core_session_get_uuid(session));
|
||||||
|
switch_set_string(token->ext, ext);
|
||||||
switch_core_hash_insert(lot->hash, ext, token);
|
switch_core_hash_insert(lot->hash, ext, token);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -395,7 +527,7 @@ SWITCH_STANDARD_APP(valet_parking_function)
|
||||||
switch_event_fire(&event);
|
switch_event_fire(&event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
valet_send_presence(lot_name, lot, token, SWITCH_TRUE);
|
||||||
|
|
||||||
|
|
||||||
args.input_callback = valet_on_dtmf;
|
args.input_callback = valet_on_dtmf;
|
||||||
|
@ -412,6 +544,13 @@ SWITCH_STANDARD_APP(valet_parking_function)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (token) {
|
||||||
|
token->timeout = 1;
|
||||||
|
valet_send_presence(lot_name, lot, token, SWITCH_FALSE);
|
||||||
|
token = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, VALET_EVENT) == SWITCH_STATUS_SUCCESS) {
|
if (switch_event_create_subclass(&event, SWITCH_EVENT_CUSTOM, VALET_EVENT) == SWITCH_STATUS_SUCCESS) {
|
||||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Valet-Lot-Name", lot_name);
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Valet-Lot-Name", lot_name);
|
||||||
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Valet-Extension", ext);
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "Valet-Extension", ext);
|
||||||
|
@ -428,7 +567,7 @@ SWITCH_STANDARD_APP(valet_parking_function)
|
||||||
if (token) {
|
if (token) {
|
||||||
token->timeout = 1;
|
token->timeout = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SWITCH_STANDARD_API(valet_info_function)
|
SWITCH_STANDARD_API(valet_info_function)
|
||||||
|
@ -475,6 +614,140 @@ SWITCH_STANDARD_API(valet_info_function)
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void pres_event_handler(switch_event_t *event)
|
||||||
|
{
|
||||||
|
char *to = switch_event_get_header(event, "to");
|
||||||
|
char *dup_to = NULL, *lot_name, *domain_name, *dup_domain_name = NULL;
|
||||||
|
valet_lot_t *lot;
|
||||||
|
|
||||||
|
|
||||||
|
if (!to || strncasecmp(to, "park+", 5)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(dup_to = strdup(to))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
lot_name = dup_to + 5;
|
||||||
|
|
||||||
|
if ((domain_name = strchr(lot_name, '@'))) {
|
||||||
|
domain_name++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (zstr(domain_name)) {
|
||||||
|
dup_domain_name = switch_core_get_variable_dup("domain");
|
||||||
|
domain_name = dup_domain_name;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (zstr(domain_name)) {
|
||||||
|
domain_name = "cluecon.com";
|
||||||
|
}
|
||||||
|
|
||||||
|
if ((lot = valet_find_lot(lot_name))) {
|
||||||
|
int count = valet_lot_count(lot);
|
||||||
|
|
||||||
|
if (count) {
|
||||||
|
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
|
||||||
|
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", VALET_PROTO);
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", lot_name);
|
||||||
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", lot_name, domain_name);
|
||||||
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "force-status", "Active (%d caller%s)", count, count == 1 ? "" : "s");
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", "active");
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog");
|
||||||
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_count", "%d", EC++);
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "unique-id", lot_name);
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "channel-state", "CS_ROUTING");
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "answer-state", "confirmed");
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-direction", "inbound");
|
||||||
|
switch_event_fire(&event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", VALET_PROTO);
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", lot_name);
|
||||||
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", lot_name, domain_name);
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "force-status", "Empty");
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", "idle");
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog");
|
||||||
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_count", "%d", EC++);
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "unique-id", lot_name);
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "channel-state", "CS_HANGUP");
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "answer-state", "terminated");
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-direction", "inbound");
|
||||||
|
switch_event_fire(&event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
switch_console_callback_match_t *matches = NULL;
|
||||||
|
switch_console_callback_match_node_t *m;
|
||||||
|
switch_hash_index_t *hi;
|
||||||
|
const void *var;
|
||||||
|
void *val;
|
||||||
|
|
||||||
|
switch_mutex_lock(globals.mutex);
|
||||||
|
for (hi = switch_hash_first(NULL, globals.hash); hi; hi = switch_hash_next(hi)) {
|
||||||
|
switch_hash_this(hi, &var, NULL, &val);
|
||||||
|
switch_console_push_match(&matches, (const char *) var);
|
||||||
|
}
|
||||||
|
switch_mutex_unlock(globals.mutex);
|
||||||
|
|
||||||
|
if (matches) {
|
||||||
|
valet_token_t *token;
|
||||||
|
|
||||||
|
for (m = matches->head; m; m = m->next) {
|
||||||
|
lot = valet_find_lot(m->val);
|
||||||
|
switch_mutex_lock(lot->mutex);
|
||||||
|
|
||||||
|
if ((token = (valet_token_t *) switch_core_hash_find(lot->hash, lot_name))) {
|
||||||
|
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", VALET_PROTO);
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", lot_name);
|
||||||
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "from", "%s@%s", lot_name, domain_name);
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "force-status", "Active");
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog");
|
||||||
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_count", "%d", EC++);
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "unique-id", lot_name);
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "channel-state", "CS_ROUTING");
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "answer-state", token->bridged == 0 ? "early" : "confirmed");
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-direction", token->bridged == 0 ? "outbound" : "inbound");
|
||||||
|
switch_event_fire(&event);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch_mutex_unlock(lot->mutex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
if (switch_event_create(&event, SWITCH_EVENT_PRESENCE_IN) == SWITCH_STATUS_SUCCESS) {
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "proto", VALET_PROTO);
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "login", lot_name);
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "from", to);
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "force-status", "Empty");
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "rpid", "idle");
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "event_type", "presence");
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "alt_event_type", "dialog");
|
||||||
|
switch_event_add_header(event, SWITCH_STACK_BOTTOM, "event_count", "%d", EC++);
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "unique-id", lot_name);
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "channel-state", "CS_HANGUP");
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "answer-state", "terminated");
|
||||||
|
switch_event_add_header_string(event, SWITCH_STACK_BOTTOM, "call-direction", "inbound");
|
||||||
|
switch_event_fire(&event);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch_safe_free(dup_to);
|
||||||
|
switch_safe_free(dup_domain_name);
|
||||||
|
}
|
||||||
|
|
||||||
/* Macro expands to: switch_status_t mod_valet_parking_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool) */
|
/* Macro expands to: switch_status_t mod_valet_parking_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool) */
|
||||||
SWITCH_MODULE_LOAD_FUNCTION(mod_valet_parking_load)
|
SWITCH_MODULE_LOAD_FUNCTION(mod_valet_parking_load)
|
||||||
{
|
{
|
||||||
|
@ -487,6 +760,8 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_valet_parking_load)
|
||||||
return SWITCH_STATUS_TERM;
|
return SWITCH_STATUS_TERM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch_event_bind(modname, SWITCH_EVENT_PRESENCE_PROBE, SWITCH_EVENT_SUBCLASS_ANY, pres_event_handler, NULL);
|
||||||
|
|
||||||
memset(&globals, 0, sizeof(globals));
|
memset(&globals, 0, sizeof(globals));
|
||||||
|
|
||||||
globals.pool = pool;
|
globals.pool = pool;
|
||||||
|
|
|
@ -1298,7 +1298,7 @@ static char *translate_rpid(char *in)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!strcasecmp(in, "idle")) {
|
if (!strcasecmp(in, "idle")) {
|
||||||
r = "busy";
|
r = "online";
|
||||||
}
|
}
|
||||||
|
|
||||||
end:
|
end:
|
||||||
|
@ -1555,6 +1555,7 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
|
||||||
const char *force_direction = switch_str_nil(switch_event_get_header(helper->event, "force-direction"));
|
const char *force_direction = switch_str_nil(switch_event_get_header(helper->event, "force-direction"));
|
||||||
const char *uuid = switch_str_nil(switch_event_get_header(helper->event, "unique-id"));
|
const char *uuid = switch_str_nil(switch_event_get_header(helper->event, "unique-id"));
|
||||||
const char *event_status = switch_str_nil(switch_event_get_header(helper->event, "status"));
|
const char *event_status = switch_str_nil(switch_event_get_header(helper->event, "status"));
|
||||||
|
const char *force_event_status = switch_str_nil(switch_event_get_header(helper->event, "force-status"));
|
||||||
const char *astate = switch_str_nil(switch_event_get_header(helper->event, "astate"));
|
const char *astate = switch_str_nil(switch_event_get_header(helper->event, "astate"));
|
||||||
const char *answer_state = switch_str_nil(switch_event_get_header(helper->event, "answer-state"));
|
const char *answer_state = switch_str_nil(switch_event_get_header(helper->event, "answer-state"));
|
||||||
const char *dft_state;
|
const char *dft_state;
|
||||||
|
@ -1565,6 +1566,11 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
|
||||||
char *clean_from_user = NULL;
|
char *clean_from_user = NULL;
|
||||||
int force_status = 0;
|
int force_status = 0;
|
||||||
|
|
||||||
|
|
||||||
|
if (force_event_status && !event_status) {
|
||||||
|
event_status = force_event_status;
|
||||||
|
}
|
||||||
|
|
||||||
if (!strcasecmp(direction, "inbound")) {
|
if (!strcasecmp(direction, "inbound")) {
|
||||||
from_id = switch_str_nil(switch_event_get_header(helper->event, "Caller-Destination-Number"));
|
from_id = switch_str_nil(switch_event_get_header(helper->event, "Caller-Destination-Number"));
|
||||||
} else {
|
} else {
|
||||||
|
@ -1767,6 +1773,13 @@ static int sofia_presence_sub_callback(void *pArg, int argc, char **argv, char *
|
||||||
status = dialog_status;
|
status = dialog_status;
|
||||||
switch_set_string(status_line, status);
|
switch_set_string(status_line, status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if (!zstr(force_event_status)) {
|
||||||
|
switch_set_string(status_line, force_event_status);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (!zstr(dialog_rpid)) {
|
if (!zstr(dialog_rpid)) {
|
||||||
prpid = rpid = dialog_rpid;
|
prpid = rpid = dialog_rpid;
|
||||||
|
|
Loading…
Reference in New Issue