From 4ae41dd1bd6da60c8c32f4396a9853feaa3ca987 Mon Sep 17 00:00:00 2001 From: Chris Rienzo Date: Wed, 14 Aug 2013 18:00:30 -0400 Subject: [PATCH] mod_rayo: move alias definition to config file, tweak console command completion to make testing easier --- conf/rayo/autoload_configs/rayo.conf.xml | 207 +++++++ .../conf/autoload_configs/rayo.conf.xml | 207 +++++++ src/mod/event_handlers/mod_rayo/mod_rayo.c | 504 +++++++++--------- src/mod/event_handlers/mod_rayo/mod_rayo.h | 1 + .../event_handlers/mod_rayo/rayo_components.c | 2 +- 5 files changed, 681 insertions(+), 240 deletions(-) diff --git a/conf/rayo/autoload_configs/rayo.conf.xml b/conf/rayo/autoload_configs/rayo.conf.xml index 248fd47ccf..35419319bc 100644 --- a/conf/rayo/autoload_configs/rayo.conf.xml +++ b/conf/rayo/autoload_configs/rayo.conf.xml @@ -47,4 +47,211 @@ + + + ]]> + ]]> + ]]> + ]]> + ]]> + ]]> + ]]> + ]]> + ]]> + ]]> + ]]> + ]]> + ]]> + ]]> + ]]> + ]]> + ]]> + ]]> + ]]> + + + + +

Please press a digit.

]]]]> +
+
+ + + 0123456789]]]]> + + + + ]]> +
+ + + + +

Please press a digit.

]]]]> +
+
+ + + 0123456789]]]]> + + + + ]]> +
+ + + + +

Please press a digit.

]]]]> +
+
+ + + 0123456789]]]]> + + + + ]]> +
+ + + + +

Please press a digit.

]]]]> +
+
+ + + 0123456789]]]]> + + + + ]]> +
+ + + + +

Please press a digit.

]]]]> +
+
+ + + 0123456789]]]]> + + + + ]]> +
+ + + + +

Please press a digit.

]]]]> +
+
+ + + 0123456789]]]]> + + + + ]]> +
+ + + + +

Please press a digit.

]]]]> +
+
+ + + 0123456789]]]]> + + + + ]]> +
+ + + + 0123456789]]]]> + + + ]]> + + + + + yesno + ]]]]> + + + ]]> + + + + + yesno + ]]]]> + + + ]]> + + + + + + yesno + ]]]]> + + + ]]> + + + + + + yesno + ]]]]> + + + ]]> + + +
+ diff --git a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/rayo.conf.xml b/src/mod/event_handlers/mod_rayo/conf/autoload_configs/rayo.conf.xml index 248fd47ccf..35419319bc 100644 --- a/src/mod/event_handlers/mod_rayo/conf/autoload_configs/rayo.conf.xml +++ b/src/mod/event_handlers/mod_rayo/conf/autoload_configs/rayo.conf.xml @@ -47,4 +47,211 @@ + + + ]]> + ]]> + ]]> + ]]> + ]]> + ]]> + ]]> + ]]> + ]]> + ]]> + ]]> + ]]> + ]]> + ]]> + ]]> + ]]> + ]]> + ]]> + ]]> + + + + +

Please press a digit.

]]]]> +
+
+ + + 0123456789]]]]> + + + + ]]> +
+ + + + +

Please press a digit.

]]]]> +
+
+ + + 0123456789]]]]> + + + + ]]> +
+ + + + +

Please press a digit.

]]]]> +
+
+ + + 0123456789]]]]> + + + + ]]> +
+ + + + +

Please press a digit.

]]]]> +
+
+ + + 0123456789]]]]> + + + + ]]> +
+ + + + +

Please press a digit.

]]]]> +
+
+ + + 0123456789]]]]> + + + + ]]> +
+ + + + +

Please press a digit.

]]]]> +
+
+ + + 0123456789]]]]> + + + + ]]> +
+ + + + +

Please press a digit.

]]]]> +
+
+ + + 0123456789]]]]> + + + + ]]> +
+ + + + 0123456789]]]]> + + + ]]> + + + + + yesno + ]]]]> + + + ]]> + + + + + yesno + ]]]]> + + + ]]> + + + + + + yesno + ]]]]> + + + ]]> + + + + + + yesno + ]]]]> + + + ]]> + + +
+ diff --git a/src/mod/event_handlers/mod_rayo/mod_rayo.c b/src/mod/event_handlers/mod_rayo/mod_rayo.c index 69f8b2271b..be66fe877c 100644 --- a/src/mod/event_handlers/mod_rayo/mod_rayo.c +++ b/src/mod/event_handlers/mod_rayo/mod_rayo.c @@ -239,6 +239,12 @@ static void rayo_console_client_send(struct rayo_actor *client, struct rayo_mess static void on_client_presence(struct rayo_client *rclient, iks *node); +typedef switch_bool_t (* rayo_actor_match_fn)(struct rayo_actor *); + +static switch_bool_t is_call_actor(struct rayo_actor *actor); + + + /** * @param msg to check * @return true if message was sent by admin client (console) @@ -827,7 +833,7 @@ int rayo_actor_seq_next(struct rayo_actor *actor) static struct rayo_call *rayo_call_locate(const char *call_uuid, const char *file, int line) { struct rayo_actor *actor = rayo_actor_locate_by_id(call_uuid, file, line); - if (actor && !strcmp(RAT_CALL, actor->type)) { + if (actor && is_call_actor(actor)) { return RAYO_CALL(actor); } else if (actor) { RAYO_UNLOCK(actor); @@ -3077,6 +3083,21 @@ static void on_xmpp_stream_destroy(struct xmpp_stream *stream) } } +/** + * Add an alias to an API command + * @param alias_name + * @param alias_target + * @param alias_cmd + */ +static void rayo_add_cmd_alias(const char *alias_name, const char *alias_target, const char *alias_cmd) +{ + if (zstr(alias_target)) { + alias_target = "all"; + } + switch_console_set_complete(switch_core_sprintf(globals.pool, "add rayo %s ::rayo::list_%s", alias_name, alias_target)); + switch_core_hash_insert(globals.cmd_aliases, alias_name, alias_cmd); +} + /** * Process module XML configuration * @param pool memory pool to allocate from @@ -3262,6 +3283,22 @@ static switch_status_t do_config(switch_memory_pool_t *pool, const char *config_ } } + /* get aliases */ + { + switch_xml_t aliases = switch_xml_child(cfg, "aliases"); + if (aliases) { + switch_xml_t alias; + switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_DEBUG, "Setting configured aliases\n"); + for (alias = switch_xml_child(aliases, "alias"); alias; alias = alias->next) { + const char *alias_name = switch_xml_attr_soft(alias, "name"); + const char *alias_target = switch_xml_attr_soft(alias, "target"); + if (!zstr(alias_name) && !zstr(alias->txt)) { + rayo_add_cmd_alias(alias_name, alias_target, alias->txt); + } + } + } + } + done: switch_xml_free(xml); @@ -3360,12 +3397,6 @@ static void send_console_command(struct rayo_client *client, const char *to, con iks *command = NULL; iksparser *p = iks_dom_new(&command); - /* check if aliased */ - const char *alias = switch_core_hash_find(globals.cmd_aliases, command_str); - if (!zstr(alias)) { - command_str = alias; - } - if (iks_parse(p, command_str, 0, 1) == IKS_OK && command) { char *str; iks *iq = NULL; @@ -3404,14 +3435,15 @@ static void send_console_command(struct rayo_client *client, const char *to, con /** * Send command to rayo actor */ -static int command_api(const char *cmd, switch_stream_handle_t *stream) +static int command_api(char *cmd, switch_stream_handle_t *stream) { - char *cmd_dup = strdup(cmd); char *argv[2] = { 0 }; - int argc = switch_separate_string(cmd_dup, ' ', argv, sizeof(argv) / sizeof(argv[0])); - - if (argc != 2) { - free(cmd_dup); + if (!zstr(cmd)) { + int argc = switch_separate_string(cmd, ' ', argv, sizeof(argv) / sizeof(argv[0])); + if (argc != 2) { + return 0; + } + } else { return 0; } @@ -3419,7 +3451,22 @@ static int command_api(const char *cmd, switch_stream_handle_t *stream) send_console_command(globals.console, argv[0], argv[1]); stream->write_function(stream, "+OK\n"); - free(cmd_dup); + return 1; +} + +/** + * Send command to rayo actor + */ +static int alias_api(const char *cmd, char *jid, switch_stream_handle_t *stream) +{ + if (zstr(cmd) || zstr(jid)) { + return 0; + } + + /* send command */ + send_console_command(globals.console, jid, cmd); + stream->write_function(stream, "+OK\n"); + return 1; } @@ -3443,14 +3490,15 @@ static void send_console_message(struct rayo_client *client, const char *to, con /** * Send message to rayo actor */ -static int message_api(const char *msg, switch_stream_handle_t *stream) +static int message_api(char *cmd, switch_stream_handle_t *stream) { - char *msg_dup = strdup(msg); char *argv[2] = { 0 }; - int argc = switch_separate_string(msg_dup, ' ', argv, sizeof(argv) / sizeof(argv[0])); - - if (argc != 2) { - free(msg_dup); + if (!zstr(cmd)) { + int argc = switch_separate_string(cmd, ' ', argv, sizeof(argv) / sizeof(argv[0])); + if (argc != 2) { + return 0; + } + } else { return 0; } @@ -3458,7 +3506,6 @@ static int message_api(const char *msg, switch_stream_handle_t *stream) send_console_message(globals.console, argv[0], argv[1]); stream->write_function(stream, "+OK\n"); - free(msg_dup); return 1; } @@ -3484,151 +3531,238 @@ static void send_console_presence(struct rayo_client *client, const char *to, in /** * Send console presence */ -static int presence_api(const char *cmd, switch_stream_handle_t *stream) +static int presence_api(char *cmd, switch_stream_handle_t *stream) { - char *cmd_dup = strdup(cmd); - char *argv[2] = { 0 }; - int argc = switch_separate_string(cmd_dup, ' ', argv, sizeof(argv) / sizeof(argv[0])); int is_online = 0; - - if (argc != 2) { - free(cmd_dup); + char *argv[2] = { 0 }; + if (!zstr(cmd)) { + int argc = switch_separate_string(cmd, ' ', argv, sizeof(argv) / sizeof(argv[0])); + if (argc != 2) { + return 0; + } + } else { return 0; } if (!strcmp("online", argv[1])) { is_online = 1; } else if (strcmp("offline", argv[1])) { - free(cmd_dup); return 0; } /* send presence */ send_console_presence(globals.console, argv[0], is_online); stream->write_function(stream, "+OK\n"); - free(cmd_dup); return 1; } -#define RAYO_API_SYNTAX "status | (cmd ) | (msg ) | (presence )" +#define RAYO_API_SYNTAX "status | ( ) | (cmd ) | (msg ) | (presence )" SWITCH_STANDARD_API(rayo_api) { + const char *alias; + char *cmd_dup = strdup(cmd); + char *argv[2] = { 0 }; int success = 0; - if (!strncmp("status", cmd, 6)) { - success = dump_api(cmd + 6, stream); - } else if (!strncmp("cmd", cmd, 3)) { - success = command_api(cmd + 3, stream); - } else if (!strncmp("msg", cmd, 3)) { - success = message_api(cmd + 3, stream); - } else if (!strncmp("presence", cmd, 8)) { - success = presence_api(cmd + 8, stream); + + switch_separate_string(cmd_dup, ' ', argv, sizeof(argv) / sizeof(argv[0])); + + /* check if a command alias */ + alias = switch_core_hash_find(globals.cmd_aliases, argv[0]); + + if (!zstr(alias)) { + success = alias_api(alias, argv[1], stream); + } else if (!strcmp("cmd", argv[0])) { + success = command_api(argv[1], stream); + } else if (!strcmp("status", argv[0])) { + success = dump_api(argv[1], stream); + } else if (!strcmp("msg", argv[0])) { + success = message_api(argv[1], stream); + } else if (!strcmp("presence", argv[0])) { + success = presence_api(argv[1], stream); } if (!success) { stream->write_function(stream, "-ERR: USAGE %s\n", RAYO_API_SYNTAX); } + free(cmd_dup); + return SWITCH_STATUS_SUCCESS; } +/** + * Console auto-completion for actors given validation function + */ +static switch_status_t list_actors(const char *line, const char *cursor, switch_console_callback_match_t **matches, rayo_actor_match_fn match) +{ + switch_hash_index_t *hi; + void *val; + const void *vvar; + switch_console_callback_match_t *my_matches = NULL; + switch_status_t status = SWITCH_STATUS_FALSE; + struct rayo_actor *actor; + + switch_mutex_lock(globals.actors_mutex); + for (hi = switch_hash_first(NULL, globals.actors); hi; hi = switch_hash_next(hi)) { + switch_hash_this(hi, &vvar, NULL, &val); + + actor = (struct rayo_actor *) val; + if (match(actor)) { + switch_console_push_match(&my_matches, (const char *) vvar); + } + } + switch_mutex_unlock(globals.actors_mutex); + + if (my_matches) { + *matches = my_matches; + status = SWITCH_STATUS_SUCCESS; + } + + return status; +} + +/** + * @return true if internal actor + */ +static switch_bool_t is_internal_actor(struct rayo_actor *actor) +{ + return strcmp(RAT_CLIENT, actor->type) && strcmp(RAT_PEER_SERVER, actor->type); +} + /** * Console auto-completion for all internal actors */ -switch_status_t list_internal(const char *line, const char *cursor, switch_console_callback_match_t **matches) +static switch_status_t list_internal(const char *line, const char *cursor, switch_console_callback_match_t **matches) { - switch_hash_index_t *hi; - void *val; - const void *vvar; - switch_console_callback_match_t *my_matches = NULL; - switch_status_t status = SWITCH_STATUS_FALSE; - struct rayo_actor *actor; + return list_actors(line, cursor, matches, is_internal_actor); +} - switch_mutex_lock(globals.actors_mutex); - for (hi = switch_hash_first(NULL, globals.actors); hi; hi = switch_hash_next(hi)) { - switch_hash_this(hi, &vvar, NULL, &val); - - actor = (struct rayo_actor *) val; - if (strcmp(RAT_CLIENT, actor->type) && strcmp(RAT_PEER_SERVER, actor->type)) { - switch_console_push_match(&my_matches, (const char *) vvar); - } - } - switch_mutex_unlock(globals.actors_mutex); - - if (my_matches) { - *matches = my_matches; - status = SWITCH_STATUS_SUCCESS; - } - - return status; +/** + * @return true if external actor + */ +static switch_bool_t is_external_actor(struct rayo_actor *actor) +{ + return !strcmp(RAT_CLIENT, actor->type) || !strcmp(RAT_PEER_SERVER, actor->type); } /** * Console auto-completion for all external actors */ -switch_status_t list_external(const char *line, const char *cursor, switch_console_callback_match_t **matches) +static switch_status_t list_external(const char *line, const char *cursor, switch_console_callback_match_t **matches) { - switch_hash_index_t *hi; - void *val; - const void *vvar; - switch_console_callback_match_t *my_matches = NULL; - switch_status_t status = SWITCH_STATUS_FALSE; - struct rayo_actor *actor; + return list_actors(line, cursor, matches, is_external_actor); +} - switch_mutex_lock(globals.actors_mutex); - for (hi = switch_hash_first(NULL, globals.actors); hi; hi = switch_hash_next(hi)) { - switch_hash_this(hi, &vvar, NULL, &val); - - actor = (struct rayo_actor *) val; - if (!strcmp(RAT_CLIENT, actor->type) || !strcmp(RAT_PEER_SERVER, actor->type)) { - switch_console_push_match(&my_matches, (const char *) vvar); - } - } - switch_mutex_unlock(globals.actors_mutex); - - if (my_matches) { - *matches = my_matches; - status = SWITCH_STATUS_SUCCESS; - } - - return status; +/** + * @return true + */ +static switch_bool_t is_any_actor(struct rayo_actor *actor) +{ + return SWITCH_TRUE; } /** * Console auto-completion for all actors */ -switch_status_t list_all(const char *line, const char *cursor, switch_console_callback_match_t **matches) +static switch_status_t list_all(const char *line, const char *cursor, switch_console_callback_match_t **matches) { - switch_hash_index_t *hi; - void *val; - const void *vvar; - switch_console_callback_match_t *my_matches = NULL; - switch_status_t status = SWITCH_STATUS_FALSE; - - switch_mutex_lock(globals.actors_mutex); - for (hi = switch_hash_first(NULL, globals.actors); hi; hi = switch_hash_next(hi)) { - switch_hash_this(hi, &vvar, NULL, &val); - switch_console_push_match(&my_matches, (const char *) vvar); - } - switch_mutex_unlock(globals.actors_mutex); - - if (my_matches) { - *matches = my_matches; - status = SWITCH_STATUS_SUCCESS; - } - - return status; + return list_actors(line, cursor, matches, is_any_actor); } /** - * Add an alias to an API command - * @param alias_name - * @param alias_cmd + * @return true if a server */ -static void rayo_add_cmd_alias(const char *alias_name, const char *alias_cmd) +static switch_bool_t is_server_actor(struct rayo_actor *actor) { - char *cmd = switch_core_sprintf(globals.pool, "add rayo cmd ::rayo::list_actors %s", alias_name); - switch_console_set_complete(cmd); - switch_core_hash_insert(globals.cmd_aliases, alias_name, alias_cmd); + return !strcmp(RAT_SERVER, actor->type); +} + +/** + * Console auto-completion for all servers + */ +static switch_status_t list_server(const char *line, const char *cursor, switch_console_callback_match_t **matches) +{ + return list_actors(line, cursor, matches, is_server_actor); +} + +/** + * @return true if a call + */ +static switch_bool_t is_call_actor(struct rayo_actor *actor) +{ + return !strcmp(RAT_CALL, actor->type); +} + +/** + * Console auto-completion for all calls + */ +static switch_status_t list_call(const char *line, const char *cursor, switch_console_callback_match_t **matches) +{ + return list_actors(line, cursor, matches, is_call_actor); +} + +/** + * @return true if a component + */ +switch_bool_t is_component_actor(struct rayo_actor *actor) +{ + return !strncmp(RAT_COMPONENT, actor->type, strlen(RAT_COMPONENT)); +} + +/** + * Console auto-completion for all components + */ +static switch_status_t list_component(const char *line, const char *cursor, switch_console_callback_match_t **matches) +{ + return list_actors(line, cursor, matches, is_component_actor); +} + +/** + * @return true if a record component + */ +static switch_bool_t is_record_actor(struct rayo_actor *actor) +{ + return is_component_actor(actor) && !strcmp(actor->subtype, "record"); +} + +/** + * Console auto-completion for all components + */ +static switch_status_t list_record(const char *line, const char *cursor, switch_console_callback_match_t **matches) +{ + return list_actors(line, cursor, matches, is_record_actor); +} + +/** + * @return true if an output component + */ +static switch_bool_t is_output_actor(struct rayo_actor *actor) +{ + return is_component_actor(actor) && !strcmp(actor->subtype, "output"); +} + +/** + * Console auto-completion for all components + */ +static switch_status_t list_output(const char *line, const char *cursor, switch_console_callback_match_t **matches) +{ + return list_actors(line, cursor, matches, is_output_actor); +} + +/** + * @return true if an input component + */ +static switch_bool_t is_input_actor(struct rayo_actor *actor) +{ + return is_component_actor(actor) && !strcmp(actor->subtype, "input"); +} + +/** + * Console auto-completion for all components + */ +static switch_status_t list_input(const char *line, const char *cursor, switch_console_callback_match_t **matches) +{ + return list_actors(line, cursor, matches, is_input_actor); } /** @@ -3708,134 +3842,20 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_rayo_load) globals.console = rayo_console_client_create(); switch_console_set_complete("add rayo status"); - switch_console_set_complete("add rayo cmd ::rayo::list_internal"); switch_console_set_complete("add rayo msg ::rayo::list_external"); - switch_console_set_complete("add rayo presence ::rayo::list_all online"); - switch_console_set_complete("add rayo presence ::rayo::list_all offline"); + switch_console_set_complete("add rayo cmd ::rayo::list_all"); + switch_console_set_complete("add rayo presence ::rayo::list_server online"); + switch_console_set_complete("add rayo presence ::rayo::list_server offline"); + switch_console_add_complete_func("::rayo::list_all", list_all); switch_console_add_complete_func("::rayo::list_internal", list_internal); switch_console_add_complete_func("::rayo::list_external", list_external); - switch_console_add_complete_func("::rayo::list_all", list_all); + switch_console_add_complete_func("::rayo::list_server", list_server); + switch_console_add_complete_func("::rayo::list_call", list_call); + switch_console_add_complete_func("::rayo::list_component", list_component); + switch_console_add_complete_func("::rayo::list_record", list_record); + switch_console_add_complete_func("::rayo::list_output", list_output); + switch_console_add_complete_func("::rayo::list_input", list_input); - rayo_add_cmd_alias("ping", ""); - rayo_add_cmd_alias("answer", ""); - rayo_add_cmd_alias("hangup", ""); - rayo_add_cmd_alias("stop", ""); - rayo_add_cmd_alias("pause", ""); - rayo_add_cmd_alias("resume", ""); - rayo_add_cmd_alias("speed-up", ""); - rayo_add_cmd_alias("speed-down", ""); - rayo_add_cmd_alias("volume-up", ""); - rayo_add_cmd_alias("volume-down", ""); - rayo_add_cmd_alias("record", ""); - rayo_add_cmd_alias("record_pause", ""); - rayo_add_cmd_alias("record_resume", ""); - rayo_add_cmd_alias("prompt_barge", "" - "

Please press a digit.

]]>
" - "" - "" - "0123456789]]>" - "" - "
"); - - rayo_add_cmd_alias("prompt_barge_mrcp", "" - "

Please press a digit.

]]>
" - "" - "" - "0123456789]]>" - "" - "
"); - - rayo_add_cmd_alias("prompt_no_barge", "" - "

Please press a digit.

]]>
" - "" - "" - "0123456789]]>" - "" - "
"); - - rayo_add_cmd_alias("prompt_long", "" - "" - "" - "" - "0123456789]]>" - "" - ""); - - rayo_add_cmd_alias("prompt_multi_digit", "" - "" - "" - "" - "0123456789]]>" - "" - ""); - - rayo_add_cmd_alias("prompt_terminator", "" - "" - "" - "" - "0123456789]]>" - "" - ""); - - rayo_add_cmd_alias("prompt_input_bad", "" - "" - "" - "" - "0123456789]]>" - "" - ""); - - rayo_add_cmd_alias("prompt_output_bad", "" - "" - "" - "" - "0123456789]]>" - "" - ""); - rayo_add_cmd_alias("input", "" - "" - "0123456789*#]]>" - ""); - rayo_add_cmd_alias("output_bad", - ""); - rayo_add_cmd_alias("join_mixer_duplex", - ""); - rayo_add_cmd_alias("join_mixer_send", - ""); - rayo_add_cmd_alias("join_mixer_recv", - ""); - rayo_add_cmd_alias("unjoin_mixer", - ""); - rayo_add_cmd_alias("unjoin", - ""); - rayo_add_cmd_alias("input_voice_yesno_unimrcp", - "" - "" - "yesno]]>"); -rayo_add_cmd_alias("input_voice_yesno_unimrcp_timeout", - "" - "" - "yesno]]>"); - rayo_add_cmd_alias("input_voice_yesno_pocketsphinx", - "" - "" - "yesno]]>"); - rayo_add_cmd_alias("input_voice_yesno_default", - "" - "" - "yesno]]>"); return SWITCH_STATUS_SUCCESS; } @@ -3844,9 +3864,15 @@ rayo_add_cmd_alias("input_voice_yesno_unimrcp_timeout", */ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_rayo_shutdown) { + switch_console_del_complete_func("::rayo::list_all"); switch_console_del_complete_func("::rayo::list_internal"); switch_console_del_complete_func("::rayo::list_external"); - switch_console_del_complete_func("::rayo::list_all"); + switch_console_del_complete_func("::rayo::list_server"); + switch_console_del_complete_func("::rayo::list_call"); + switch_console_del_complete_func("::rayo::list_component"); + switch_console_del_complete_func("::rayo::list_record"); + switch_console_del_complete_func("::rayo::list_output"); + switch_console_del_complete_func("::rayo::list_input"); switch_console_set_complete("del rayo"); /* stop XMPP streams */ diff --git a/src/mod/event_handlers/mod_rayo/mod_rayo.h b/src/mod/event_handlers/mod_rayo/mod_rayo.h index f4602cc6b9..260c811a45 100644 --- a/src/mod/event_handlers/mod_rayo/mod_rayo.h +++ b/src/mod/event_handlers/mod_rayo/mod_rayo.h @@ -162,6 +162,7 @@ extern const char *rayo_call_get_dcp_jid(struct rayo_call *call); #define rayo_component_init(component, pool, type, subtype, id, parent, client_jid) _rayo_component_init(component, pool, type, subtype, id, parent, client_jid, __FILE__, __LINE__) extern struct rayo_component *_rayo_component_init(struct rayo_component *component, switch_memory_pool_t *pool, const char *type, const char *subtype, const char *id, struct rayo_actor *parent, const char *client_jid, const char *file, int line); +extern switch_bool_t is_component_actor(struct rayo_actor *); typedef iks *(*rayo_actor_xmpp_handler)(struct rayo_actor *, struct rayo_message *, void *); extern void rayo_actor_command_handler_add(const char *type, const char *subtype, const char *name, rayo_actor_xmpp_handler fn); diff --git a/src/mod/event_handlers/mod_rayo/rayo_components.c b/src/mod/event_handlers/mod_rayo/rayo_components.c index d8a8854f52..b376e97770 100644 --- a/src/mod/event_handlers/mod_rayo/rayo_components.c +++ b/src/mod/event_handlers/mod_rayo/rayo_components.c @@ -40,7 +40,7 @@ struct rayo_component *rayo_component_locate(const char *id, const char *file, int line) { struct rayo_actor *actor = rayo_actor_locate_by_id(id, file, line); - if (actor && !strncmp(RAT_COMPONENT, actor->type, strlen(RAT_COMPONENT))) { + if (actor && is_component_actor(actor)) { return RAYO_COMPONENT(actor); } else if (actor) { RAYO_UNLOCK(actor);