Asterisk - The Open Source Telephony Project
18.5.0
|
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 418 of file message.c.
References ao2_alloc, AO2_ALLOC_OPT_LOCK_MUTEX, ao2_container_alloc_list, ao2_ref, ast_string_field_init, ast_string_field_set, context, msg_data::msg, 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(), receive_message(), 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().
Definition at line 448 of file message.c.
Referenced by ast_msg_safe_destroy(), module_on_rx_request(), msg_data_destroy(), receive_message(), 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 531 of file message.c.
References ast_msg::body.
Referenced by AST_TEST_DEFINE(), msg_send(), msg_to_json(), sip_msg_send(), 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 |
The | endpoint associated with the message |
NULL | or empty string if the message has no associated endpoint |
Definition at line 551 of file 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 |
The | source of the message |
NULL | or empty string if the message has no source |
Definition at line 536 of file 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 |
The | technology of the message |
NULL | or empty string if the message has no associated technology |
Definition at line 546 of file 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 |
The | destination of the message |
NULL | or empty string if the message has no destination |
Definition at line 541 of file 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 620 of file message.c.
References ao2_ref, msg_data_find(), 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 1629 of file message.c.
References ast_log, ast_rwlock_unlock, ast_rwlock_wrlock, AST_VECTOR_APPEND, ast_verb, LOG_ERROR, match(), msg_handler_find_by_tech_name(), and ast_msg_handler::name.
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 1671 of file 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_handler_cmp(), and ast_msg_handler::name.
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 937 of file message.c.
References ast_debug, ast_rwlock_rdlock, ast_rwlock_unlock, AST_VECTOR_GET, AST_VECTOR_SIZE, handler(), ast_msg_handler::has_destination, ast_msg_handler::name, and result.
Referenced by AST_TEST_DEFINE(), module_on_rx_request(), and receive_message().
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 958 of file message.c.
References ao2_ref, ast_taskprocessor_push(), and msg_q_cb().
Referenced by AST_TEST_DEFINE(), module_on_rx_request(), receive_message(), and xmpp_pak_message().
Bump a msg's ref count.
Definition at line 442 of file message.c.
References ao2_ref, and msg_data::msg.
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 1369 of file 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, 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 476 of file message.c.
References ast_string_field_build_va, and ast_msg::body.
Referenced by action_messagesend(), AST_TEST_DEFINE(), msg_func_write(), receive_message(), 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 487 of file message.c.
References ast_string_field_build_va, and context.
Referenced by AST_TEST_DEFINE(), receive_message(), 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 520 of file message.c.
References ast_string_field_build_va, and ast_msg::endpoint.
Referenced by AST_TEST_DEFINE(), receive_message(), 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 498 of file message.c.
References ast_string_field_build_va, and exten.
Referenced by AST_TEST_DEFINE(), receive_message(), 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 465 of file message.c.
References ast_string_field_build_va, and msg_data::from.
Referenced by AST_TEST_DEFINE(), msg_func_write(), receive_message(), 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 509 of file message.c.
References ast_string_field_build_va, and ast_msg::tech.
Referenced by AST_TEST_DEFINE(), receive_message(), 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 454 of file message.c.
References ast_string_field_build_va, and ast_msg::to.
Referenced by AST_TEST_DEFINE(), msg_func_write(), receive_message(), 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 615 of file message.c.
References msg_set_var_full().
Referenced by AST_TEST_DEFINE(), headers_to_vars(), receive_message(), rx_data_to_ast_msg(), set_message_vars_from_req(), 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 610 of file message.c.
References msg_set_var_full().
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 1569 of file message.c.
References ast_log, ast_rwlock_unlock, ast_rwlock_wrlock, AST_VECTOR_APPEND, ast_verb, LOG_ERROR, match(), msg_find_by_tech_name(), 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 1610 of file 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(), 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 706 of file 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(), sip_msg_send(), 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 644 of file 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(), sip_msg_send(), 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 689 of file message.c.
References ast_msg_var_iterator_get_next().
Referenced by AST_TEST_DEFINE(), sip_msg_send(), 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 694 of file message.c.
References ast_msg_var_iterator_get_next().
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 700 of file 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(), sip_msg_send(), and vars_to_headers().