Asterisk - The Open Source Telephony Project GIT-master-d856a3e
|
Out-of-call text message support. More...
Go to the source code of this file.
Data Structures | |
struct | ast_msg_data_attribute |
struct | ast_msg_handler |
An external processor of received messages. More... | |
struct | ast_msg_tech |
A message technology. More... | |
Functions | |
struct ast_msg * | ast_msg_alloc (void) |
Allocate a message. More... | |
struct ast_msg_data * | ast_msg_data_alloc (enum ast_msg_data_source_type source, struct ast_msg_data_attribute attributes[], size_t count) |
Allocates an ast_msg_data structure. More... | |
struct ast_msg_data * | ast_msg_data_alloc2 (enum ast_msg_data_source_type source_type, const char *to, const char *from, const char *content_type, const char *body) |
Allocates an ast_msg_data structure. More... | |
struct ast_msg_data * | ast_msg_data_dup (struct ast_msg_data *msg) |
Clone an ast_msg_data structure. More... | |
const char * | ast_msg_data_get_attribute (struct ast_msg_data *msg, enum ast_msg_data_attribute_type attribute_type) |
Get attribute from ast_msg_data. More... | |
size_t | ast_msg_data_get_length (struct ast_msg_data *msg) |
Get length of the structure. More... | |
enum ast_msg_data_source_type | ast_msg_data_get_source_type (struct ast_msg_data *msg) |
Get "source type" from ast_msg_data. More... | |
int | ast_msg_data_queue_frame (struct ast_channel *channel, struct ast_msg_data *msg) |
Queue an AST_FRAME_TEXT_DATA frame containing an ast_msg_data structure. More... | |
struct ast_msg * | ast_msg_destroy (struct ast_msg *msg) |
Destroy an ast_msg. More... | |
const char * | ast_msg_get_body (const struct ast_msg *msg) |
Get the body of a message. More... | |
const char * | ast_msg_get_endpoint (const struct ast_msg *msg) |
Retrieve the endpoint associated with this message. More... | |
const char * | ast_msg_get_from (const struct ast_msg *msg) |
Retrieve the source of this message. More... | |
const char * | ast_msg_get_tech (const struct ast_msg *msg) |
Retrieve the technology associated with this message. More... | |
const char * | ast_msg_get_to (const struct ast_msg *msg) |
Retrieve the destination of this message. More... | |
const char * | ast_msg_get_var (struct ast_msg *msg, const char *name) |
Get the specified variable on the message. More... | |
int | ast_msg_handler_register (const struct ast_msg_handler *handler) |
Register a ast_msg_handler . More... | |
int | ast_msg_handler_unregister (const struct ast_msg_handler *handler) |
Unregister a ast_msg_handler . More... | |
int | ast_msg_has_destination (const struct ast_msg *msg) |
Determine if a particular message has a destination via some handler. More... | |
int | ast_msg_queue (struct ast_msg *msg) |
Queue a message for routing through the dialplan. More... | |
struct ast_msg * | ast_msg_ref (struct ast_msg *msg) |
Bump a msg's ref count. More... | |
int | ast_msg_send (struct ast_msg *msg, const char *to, const char *from) |
Send a msg directly to an endpoint. More... | |
int | ast_msg_set_body (struct ast_msg *msg, const char *fmt,...) |
Set the 'body' text of a message (in UTF-8) More... | |
int | ast_msg_set_context (struct ast_msg *msg, const char *fmt,...) |
Set the dialplan context for this message. More... | |
int | ast_msg_set_endpoint (struct ast_msg *msg, const char *fmt,...) |
Set the technology's endpoint associated with this message. More... | |
int | ast_msg_set_exten (struct ast_msg *msg, const char *fmt,...) |
Set the dialplan extension for this message. More... | |
int | ast_msg_set_from (struct ast_msg *msg, const char *fmt,...) |
Set the 'from' URI of a message. More... | |
int | ast_msg_set_tech (struct ast_msg *msg, const char *fmt,...) |
Set the technology associated with this message. More... | |
int | ast_msg_set_to (struct ast_msg *msg, const char *fmt,...) |
Set the 'to' URI of a message. More... | |
int | ast_msg_set_var (struct ast_msg *msg, const char *name, const char *value) |
Set a variable on the message going to the dialplan. More... | |
int | ast_msg_set_var_outbound (struct ast_msg *msg, const char *name, const char *value) |
Set a variable on the message being sent to a message tech directly. More... | |
int | ast_msg_tech_register (const struct ast_msg_tech *tech) |
Register a message technology. More... | |
int | ast_msg_tech_unregister (const struct ast_msg_tech *tech) |
Unregister a message technology. More... | |
void | ast_msg_var_iterator_destroy (struct ast_msg_var_iterator *iter) |
Destroy a message variable iterator. More... | |
struct ast_msg_var_iterator * | ast_msg_var_iterator_init (const struct ast_msg *msg) |
Create a new message variable iterator. More... | |
int | ast_msg_var_iterator_next (const struct ast_msg *msg, struct ast_msg_var_iterator *iter, const char **name, const char **value) |
Get the next variable name and value that is set for sending outbound. More... | |
int | ast_msg_var_iterator_next_received (const struct ast_msg *msg, struct ast_msg_var_iterator *iter, const char **name, const char **value) |
Get the next variable name and value that was set on a received message. More... | |
void | ast_msg_var_unref_current (struct ast_msg_var_iterator *iter) |
Unref a message var from inside an iterator loop. More... | |
Out-of-call text message support.
The purpose of this API is to provide support for text messages that are not session based. The messages are passed into the Asterisk core to be routed through the dialplan or another interface and potentially sent back out through a message technology that has been registered through this API.
Definition in file message.h.
struct ast_msg * ast_msg_alloc | ( | void | ) |
Allocate a message.
Allocate a message for the purposes of passing it into the Asterisk core to be routed through the dialplan. If ast_msg_queue() is not called, this message must be destroyed using ast_msg_destroy(). Otherwise, the message core code will take care of it.
Definition at line 432 of file main/message.c.
References ao2_alloc, AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_list, ao2_ref, ast_string_field_init, ast_string_field_set, voicemailpwcheck::context, msg_data_cmp_fn(), msg_destructor(), NULL, and ast_msg::vars.
Referenced by action_messagesend(), AST_TEST_DEFINE(), module_on_rx_request(), msg_datastore_find_or_create(), send_message(), and xmpp_pak_message().
Destroy an ast_msg.
This should only be called on a message if it was not passed on to ast_msg_queue().
NULL | always. |
Definition at line 462 of file main/message.c.
Referenced by ast_msg_safe_destroy(), module_on_rx_request(), msg_data_destroy(), send_message(), and xmpp_pak_message().
const char * ast_msg_get_body | ( | const struct ast_msg * | msg | ) |
Get the body of a message.
Definition at line 545 of file main/message.c.
References ast_msg::body.
Referenced by AST_TEST_DEFINE(), msg_send(), msg_to_json(), and xmpp_send_cb().
const char * ast_msg_get_endpoint | ( | const struct ast_msg * | msg | ) |
Retrieve the endpoint associated with this message.
msg | The message to get the endpoint from |
NULL | or empty string if the message has no associated endpoint |
Definition at line 565 of file main/message.c.
References ast_msg::endpoint.
Referenced by AST_TEST_DEFINE(), and msg_to_endpoint().
const char * ast_msg_get_from | ( | const struct ast_msg * | msg | ) |
Retrieve the source of this message.
msg | The message to get the soure from |
NULL | or empty string if the message has no source |
Definition at line 550 of file main/message.c.
References ast_msg::from.
Referenced by AST_TEST_DEFINE(), msg_send(), and msg_to_json().
const char * ast_msg_get_tech | ( | const struct ast_msg * | msg | ) |
Retrieve the technology associated with this message.
msg | The message to get the technology from |
NULL | or empty string if the message has no associated technology |
Definition at line 560 of file main/message.c.
References ast_msg::tech.
Referenced by AST_TEST_DEFINE(), and msg_to_endpoint().
const char * ast_msg_get_to | ( | const struct ast_msg * | msg | ) |
Retrieve the destination of this message.
msg | The message to get the destination from |
NULL | or empty string if the message has no destination |
Definition at line 555 of file main/message.c.
References ast_msg::to.
Referenced by AST_TEST_DEFINE(), msg_send(), msg_to_json(), and test_msg_has_destination_cb().
const char * ast_msg_get_var | ( | struct ast_msg * | msg, |
const char * | name | ||
) |
Get the specified variable on the message.
Definition at line 634 of file main/message.c.
References ao2_ref, msg_data::msg, msg_data_find(), name, NULL, msg_data::value, and ast_msg::vars.
Referenced by AST_TEST_DEFINE(), msg_data_func_read(), and update_content_type().
int ast_msg_handler_register | ( | const struct ast_msg_handler * | handler | ) |
Register a ast_msg_handler
.
handler | The handler to register |
0 | Success |
non-zero | Error |
Definition at line 1657 of file main/message.c.
References ast_log, ast_rwlock_unlock, ast_rwlock_wrlock, AST_VECTOR_APPEND, ast_verb, handler(), LOG_ERROR, match(), msg_handler_find_by_tech_name(), msg_handlers, and msg_handlers_lock.
Referenced by ast_msg_init(), AST_TEST_DEFINE(), and messaging_init().
int ast_msg_handler_unregister | ( | const struct ast_msg_handler * | handler | ) |
Unregister a ast_msg_handler
.
handler | The handler to unregister |
0 | Success |
non-zero | Error |
Definition at line 1699 of file main/message.c.
References ast_log, ast_rwlock_unlock, ast_rwlock_wrlock, AST_VECTOR_ELEM_CLEANUP_NOOP, AST_VECTOR_REMOVE_CMP_UNORDERED, ast_verb, handler(), LOG_ERROR, match(), msg_handler_cmp(), msg_handlers, and msg_handlers_lock.
Referenced by AST_TEST_DEFINE(), message_shutdown(), and messaging_cleanup().
int ast_msg_has_destination | ( | const struct ast_msg * | msg | ) |
Determine if a particular message has a destination via some handler.
msg | The message to check |
0 | if the message has no handler that can find a destination |
1 | if the message has a handler that can find a destination |
Definition at line 951 of file main/message.c.
References ast_debug, ast_rwlock_rdlock, ast_rwlock_unlock, AST_VECTOR_GET, AST_VECTOR_SIZE, handler(), msg_handlers, msg_handlers_lock, and result.
Referenced by AST_TEST_DEFINE(), and module_on_rx_request().
int ast_msg_queue | ( | struct ast_msg * | msg | ) |
Queue a message for routing through the dialplan.
Regardless of the return value of this function, this funciton will take care of ensuring that the message object is properly destroyed when needed.
0 | message successfully queued |
non-zero | failure, message not sent to dialplan |
Definition at line 972 of file main/message.c.
References ao2_ref, ast_taskprocessor_push(), msg_q_cb(), and msg_q_tp.
Referenced by AST_TEST_DEFINE(), module_on_rx_request(), and xmpp_pak_message().
Bump a msg's ref count.
Definition at line 456 of file main/message.c.
References ao2_ref.
Referenced by msg_data_create().
int ast_msg_send | ( | struct ast_msg * | msg, |
const char * | to, | ||
const char * | from | ||
) |
Send a msg directly to an endpoint.
Regardless of the return value of this function, this funciton will take care of ensuring that the message object is properly destroyed when needed.
0 | message successfully queued to be sent out |
non-zero | failure, message not get sent out. |
Definition at line 1397 of file main/message.c.
References ao2_ref, ast_log, ast_rwlock_rdlock, ast_rwlock_unlock, ast_strdupa, ast_strlen_zero(), LOG_ERROR, msg_find_by_tech_name(), ast_msg_tech::msg_send, msg_tech, msg_techs_lock, NULL, S_OR, and strsep().
Referenced by AST_TEST_DEFINE(), and send_message().
int ast_msg_set_body | ( | struct ast_msg * | msg, |
const char * | fmt, | ||
... | |||
) |
Set the 'body' text of a message (in UTF-8)
0 | success |
-1 | failure |
Definition at line 490 of file main/message.c.
References ast_string_field_build_va, and ast_msg::body.
Referenced by action_messagesend(), AST_TEST_DEFINE(), msg_func_write(), rx_data_to_ast_msg(), send_message(), and xmpp_pak_message().
int ast_msg_set_context | ( | struct ast_msg * | msg, |
const char * | fmt, | ||
... | |||
) |
Set the dialplan context for this message.
0 | success |
-1 | failure |
Definition at line 501 of file main/message.c.
References ast_string_field_build_va, and voicemailpwcheck::context.
Referenced by AST_TEST_DEFINE(), rx_data_to_ast_msg(), and xmpp_pak_message().
int ast_msg_set_endpoint | ( | struct ast_msg * | msg, |
const char * | fmt, | ||
... | |||
) |
Set the technology's endpoint associated with this message.
0 | success |
-1 | failure |
Definition at line 534 of file main/message.c.
References ast_string_field_build_va, and ast_msg::endpoint.
Referenced by AST_TEST_DEFINE(), rx_data_to_ast_msg(), and xmpp_pak_message().
int ast_msg_set_exten | ( | struct ast_msg * | msg, |
const char * | fmt, | ||
... | |||
) |
Set the dialplan extension for this message.
0 | success |
-1 | failure |
Definition at line 512 of file main/message.c.
References ast_string_field_build_va, and ast_msg::exten.
Referenced by AST_TEST_DEFINE(), and rx_data_to_ast_msg().
int ast_msg_set_from | ( | struct ast_msg * | msg, |
const char * | fmt, | ||
... | |||
) |
Set the 'from' URI of a message.
0 | success |
-1 | failure |
Definition at line 479 of file main/message.c.
References ast_string_field_build_va, and ast_msg::from.
Referenced by AST_TEST_DEFINE(), msg_func_write(), rx_data_to_ast_msg(), send_message(), and xmpp_pak_message().
int ast_msg_set_tech | ( | struct ast_msg * | msg, |
const char * | fmt, | ||
... | |||
) |
Set the technology associated with this message.
0 | success |
-1 | failure |
Definition at line 523 of file main/message.c.
References ast_string_field_build_va, and ast_msg::tech.
Referenced by AST_TEST_DEFINE(), rx_data_to_ast_msg(), and xmpp_pak_message().
int ast_msg_set_to | ( | struct ast_msg * | msg, |
const char * | fmt, | ||
... | |||
) |
Set the 'to' URI of a message.
0 | success |
-1 | failure |
Definition at line 468 of file main/message.c.
References ast_string_field_build_va, and ast_msg::to.
Referenced by AST_TEST_DEFINE(), msg_func_write(), rx_data_to_ast_msg(), send_message(), and xmpp_pak_message().
int ast_msg_set_var | ( | struct ast_msg * | msg, |
const char * | name, | ||
const char * | value | ||
) |
Set a variable on the message going to the dialplan.
msg | |
name | Name of variable to set |
value | Value of variable to set |
0 | success |
-1 | failure |
Definition at line 629 of file main/message.c.
References msg_data::msg, msg_set_var_full(), name, and value.
Referenced by AST_TEST_DEFINE(), headers_to_vars(), rx_data_to_ast_msg(), and xmpp_pak_message().
int ast_msg_set_var_outbound | ( | struct ast_msg * | msg, |
const char * | name, | ||
const char * | value | ||
) |
Set a variable on the message being sent to a message tech directly.
msg | |
name | Name of variable to set |
value | Value of variable to set |
0 | success |
-1 | failure |
Definition at line 624 of file main/message.c.
References msg_data::msg, msg_set_var_full(), name, and value.
Referenced by action_messagesend(), AST_TEST_DEFINE(), msg_data_func_write(), and send_message().
int ast_msg_tech_register | ( | const struct ast_msg_tech * | tech | ) |
Register a message technology.
0 | success |
non-zero | failure |
Definition at line 1597 of file main/message.c.
References ast_log, ast_rwlock_unlock, ast_rwlock_wrlock, AST_VECTOR_APPEND, ast_verb, LOG_ERROR, match(), msg_find_by_tech_name(), msg_techs, msg_techs_lock, and ast_msg_tech::name.
Referenced by AST_TEST_DEFINE(), and load_module().
int ast_msg_tech_unregister | ( | const struct ast_msg_tech * | tech | ) |
Unregister a message technology.
0 | success |
non-zero | failure |
Definition at line 1638 of file main/message.c.
References ast_log, ast_rwlock_unlock, ast_rwlock_wrlock, AST_VECTOR_ELEM_CLEANUP_NOOP, AST_VECTOR_REMOVE_CMP_UNORDERED, ast_verb, LOG_ERROR, match(), msg_tech_cmp(), msg_techs, msg_techs_lock, and ast_msg_tech::name.
Referenced by AST_TEST_DEFINE(), load_module(), and unload_module().
void ast_msg_var_iterator_destroy | ( | struct ast_msg_var_iterator * | iter | ) |
Destroy a message variable iterator.
iter | Iterator to be destroyed |
Definition at line 720 of file main/message.c.
References ao2_iterator_destroy(), ast_free, ast_msg_var_unref_current(), and ast_msg_var_iterator::iter.
Referenced by AST_TEST_DEFINE(), msg_to_json(), and vars_to_headers().
struct ast_msg_var_iterator * ast_msg_var_iterator_init | ( | const struct ast_msg * | msg | ) |
Create a new message variable iterator.
msg | A message whose variables are to be iterated over |
Definition at line 658 of file main/message.c.
References ao2_iterator_init(), ast_calloc, ast_msg_var_iterator::iter, NULL, and ast_msg::vars.
Referenced by AST_TEST_DEFINE(), msg_to_json(), and vars_to_headers().
int ast_msg_var_iterator_next | ( | const struct ast_msg * | msg, |
struct ast_msg_var_iterator * | iter, | ||
const char ** | name, | ||
const char ** | value | ||
) |
Get the next variable name and value that is set for sending outbound.
msg | The message with the variables |
iter | An iterator created with ast_msg_var_iterator_init |
name | A pointer to the name result pointer |
value | A pointer to the value result pointer |
0 | No more entries |
1 | Valid entry |
Definition at line 703 of file main/message.c.
References ast_msg_var_iterator_get_next(), msg_data::msg, name, and value.
Referenced by AST_TEST_DEFINE(), and vars_to_headers().
int ast_msg_var_iterator_next_received | ( | const struct ast_msg * | msg, |
struct ast_msg_var_iterator * | iter, | ||
const char ** | name, | ||
const char ** | value | ||
) |
Get the next variable name and value that was set on a received message.
msg | The message with the variables |
iter | An iterator created with ast_msg_var_iterator_init |
name | A pointer to the name result pointer |
value | A pointer to the value result pointer |
0 | No more entries |
1 | Valid entry |
Definition at line 708 of file main/message.c.
References ast_msg_var_iterator_get_next(), msg_data::msg, name, and value.
Referenced by msg_to_json().
void ast_msg_var_unref_current | ( | struct ast_msg_var_iterator * | iter | ) |
Unref a message var from inside an iterator loop.
Definition at line 714 of file main/message.c.
References ao2_cleanup, ast_msg_var_iterator::current_used, and NULL.
Referenced by ast_msg_var_iterator_destroy(), AST_TEST_DEFINE(), msg_to_json(), and vars_to_headers().