[asterisk-commits] file: branch file/pjsip-outbound-publish r419934 - /team/file/pjsip-outbound-...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Sun Aug 3 17:43:02 CDT 2014
Author: file
Date: Sun Aug 3 17:42:52 2014
New Revision: 419934
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=419934
Log:
Separate publishing of device and mailbox state.
Modified:
team/file/pjsip-outbound-publish/res/res_pjsip_publish_asterisk.c
Modified: team/file/pjsip-outbound-publish/res/res_pjsip_publish_asterisk.c
URL: http://svnview.digium.com/svn/asterisk/team/file/pjsip-outbound-publish/res/res_pjsip_publish_asterisk.c?view=diff&rev=419934&r1=419933&r2=419934
==============================================================================
--- team/file/pjsip-outbound-publish/res/res_pjsip_publish_asterisk.c (original)
+++ team/file/pjsip-outbound-publish/res/res_pjsip_publish_asterisk.c Sun Aug 3 17:42:52 2014
@@ -52,8 +52,11 @@
Publish is <emphasis>COMPLETELY</emphasis> separate from the rest of
<literal>pjsip.conf</literal>.
</para></description>
- <configOption name="publish">
- <synopsis>Optional name of a publish item that can be used to publish a request for full state information.</synopsis>
+ <configOption name="devicestate_publish">
+ <synopsis>Optional name of a publish item that can be used to publish a request for full device state information.</synopsis>
+ </configOption>
+ <configOption name="mailboxstate_publish">
+ <synopsis>Optional name of a publish item that can be used to publish a request for full mailbox state information.</synopsis>
</configOption>
<configOption name="device_state" default="no">
<synopsis>Whether we should permit incoming device state events.</synopsis>
@@ -75,8 +78,8 @@
</configInfo>
***/
-/*! \brief Structure which contains Asterisk publisher state information */
-struct asterisk_publisher_state {
+/*! \brief Structure which contains Asterisk device state publisher state information */
+struct asterisk_devicestate_publisher_state {
/*! \brief The publish client to send PUBLISH messages on */
struct ast_sip_outbound_publish_client *client;
/*! \brief Device state subscription */
@@ -87,6 +90,12 @@
regex_t device_state_regex;
/*! \brief Device state should be filtered */
unsigned int device_state_filter;
+};
+
+/*! \brief Structure which contains Asterisk mailbox publisher state information */
+struct asterisk_mwi_publisher_state {
+ /*! \brief The publish client to send PUBLISH messages on */
+ struct ast_sip_outbound_publish_client *client;
/*! \brief Mailbox state subscription */
struct stasis_subscription *mailbox_state_subscription;
/*! \brief Send outbound mailbox events */
@@ -103,8 +112,10 @@
SORCERY_OBJECT(details);
/*! \brief Stringfields */
AST_DECLARE_STRING_FIELDS(
- /*! \brief Optional name of a publish item, used to request the remote side update us */
- AST_STRING_FIELD(publish);
+ /*! \brief Optional name of a device state publish item, used to request the remote side update us */
+ AST_STRING_FIELD(devicestate_publish);
+ /*! \brief Optional name of a mailbox state publish item, used to request the remote side update us */
+ AST_STRING_FIELD(mailboxstate_publish);
);
/*! \brief Accept inbound device state events */
unsigned int device_state;
@@ -120,26 +131,40 @@
unsigned int mailbox_state_filter;
};
-/*! \brief Destroy callback for Asterisk publisher state information from datastore */
-static void asterisk_publisher_state_destroy(void *obj)
-{
- struct asterisk_publisher_state *publisher_state = obj;
+/*! \brief Destroy callback for Asterisk devicestate publisher state information from datastore */
+static void asterisk_devicestate_publisher_state_destroy(void *obj)
+{
+ struct asterisk_devicestate_publisher_state *publisher_state = obj;
ao2_cleanup(publisher_state->client);
if (publisher_state->device_state_filter) {
regfree(&publisher_state->device_state_regex);
}
+}
+
+/*! \brief Datastore for attaching devicestate publisher state information */
+static const struct ast_datastore_info asterisk_devicestate_publisher_state_datastore = {
+ .type = "asterisk-devicestate-publisher",
+ .destroy = asterisk_devicestate_publisher_state_destroy,
+};
+
+/*! \brief Destroy callback for Asterisk mwi publisher state information from datastore */
+static void asterisk_mwi_publisher_state_destroy(void *obj)
+{
+ struct asterisk_mwi_publisher_state *publisher_state = obj;
+
+ ao2_cleanup(publisher_state->client);
if (publisher_state->mailbox_state_filter) {
regfree(&publisher_state->mailbox_state_regex);
}
}
-/*! \brief Datastore for attaching dialog-info+xml state information */
-static const struct ast_datastore_info asterisk_publisher_state_datastore = {
- .type = "asterisk-publisher",
- .destroy = asterisk_publisher_state_destroy,
+/*! \brief Datastore for attaching devicestate publisher state information */
+static const struct ast_datastore_info asterisk_mwi_publisher_state_datastore = {
+ .type = "asterisk-mwi-publisher",
+ .destroy = asterisk_mwi_publisher_state_destroy,
};
/*!
@@ -151,7 +176,7 @@
static void asterisk_publisher_devstate_cb(void *data, struct stasis_subscription *sub, struct stasis_message *msg)
{
struct ast_datastore *datastore = data;
- struct asterisk_publisher_state *publisher_state = datastore->data;
+ struct asterisk_devicestate_publisher_state *publisher_state = datastore->data;
struct ast_device_state_message *dev_state;
char eid_str[20];
struct ast_json *json;
@@ -210,7 +235,7 @@
static void asterisk_publisher_mwistate_cb(void *data, struct stasis_subscription *sub, struct stasis_message *msg)
{
struct ast_datastore *datastore = data;
- struct asterisk_publisher_state *publisher_state = datastore->data;
+ struct asterisk_mwi_publisher_state *publisher_state = datastore->data;
struct ast_mwi_state *mwi_state;
char eid_str[20];
struct ast_json *json;
@@ -264,7 +289,7 @@
{
struct stasis_message *msg = obj;
struct ast_datastore *datastore = arg;
- struct asterisk_publisher_state *publisher_state = datastore->data;
+ struct asterisk_devicestate_publisher_state *publisher_state = datastore->data;
asterisk_publisher_devstate_cb(arg, publisher_state->device_state_subscription, msg);
@@ -275,7 +300,7 @@
{
struct stasis_message *msg = obj;
struct ast_datastore *datastore = arg;
- struct asterisk_publisher_state *publisher_state = datastore->data;
+ struct asterisk_mwi_publisher_state *publisher_state = datastore->data;
asterisk_publisher_mwistate_cb(arg, publisher_state->mailbox_state_subscription, msg);
@@ -297,20 +322,21 @@
return 0;
}
-static int asterisk_start_publishing(struct ast_sip_outbound_publish *configuration,
+static int asterisk_start_devicestate_publishing(struct ast_sip_outbound_publish *configuration,
struct ast_sip_outbound_publish_client *client)
{
RAII_VAR(struct ast_datastore *, datastore, NULL, ao2_cleanup);
- struct asterisk_publisher_state *publisher_state;
+ struct asterisk_devicestate_publisher_state *publisher_state;
const char *value;
struct ao2_container *cached;
- datastore = ast_sip_publish_client_alloc_datastore(&asterisk_publisher_state_datastore, "asterisk-publisher");
+ datastore = ast_sip_publish_client_alloc_datastore(&asterisk_devicestate_publisher_state_datastore,
+ "asterisk-devicestate-publisher");
if (!datastore) {
return -1;
}
- publisher_state = ast_calloc(1, sizeof(struct asterisk_publisher_state));
+ publisher_state = ast_calloc(1, sizeof(struct asterisk_devicestate_publisher_state));
if (!publisher_state) {
return -1;
}
@@ -324,10 +350,71 @@
publisher_state->device_state_filter = 1;
}
- value = ast_sorcery_object_get_extended(configuration, "device_state");
- if (!ast_strlen_zero(value)) {
- publisher_state->device_state = ast_true(value);
- }
+ publisher_state->client = ao2_bump(client);
+
+ if (ast_sip_publish_client_add_datastore(client, datastore)) {
+ return -1;
+ }
+
+ publisher_state->device_state_subscription = stasis_subscribe(ast_device_state_topic_all(),
+ asterisk_publisher_devstate_cb, ao2_bump(datastore));
+ if (!publisher_state->device_state_subscription) {
+ ast_sip_publish_client_remove_datastore(client, "asterisk-publisher");
+ return -1;
+ }
+
+ cached = stasis_cache_dump(ast_device_state_cache(), NULL);
+ ao2_callback(cached, OBJ_NODATA, cached_devstate_cb, datastore);
+ ao2_ref(cached, -1);
+
+ return 0;
+}
+
+static int asterisk_stop_devicestate_publishing(struct ast_sip_outbound_publish_client *client)
+{
+ RAII_VAR(struct ast_datastore *, datastore, ast_sip_publish_client_get_datastore(client, "asterisk-devicestate-publisher"),
+ ao2_cleanup);
+ struct asterisk_devicestate_publisher_state *publisher_state;
+
+ if (!datastore) {
+ return 0;
+ }
+
+ publisher_state = datastore->data;
+ if (publisher_state->device_state_subscription) {
+ stasis_unsubscribe_and_join(publisher_state->device_state_subscription);
+ ao2_ref(datastore, -1);
+ }
+
+ ast_sip_publish_client_remove_datastore(client, "asterisk-devicestate-publisher");
+
+ return 0;
+}
+
+struct ast_sip_event_publisher_handler asterisk_devicestate_publisher_handler = {
+ .event_name = "asterisk-devicestate",
+ .start_publishing = asterisk_start_devicestate_publishing,
+ .stop_publishing = asterisk_stop_devicestate_publishing,
+};
+
+static int asterisk_start_mwi_publishing(struct ast_sip_outbound_publish *configuration,
+ struct ast_sip_outbound_publish_client *client)
+{
+ RAII_VAR(struct ast_datastore *, datastore, NULL, ao2_cleanup);
+ struct asterisk_mwi_publisher_state *publisher_state;
+ const char *value;
+ struct ao2_container *cached;
+
+ datastore = ast_sip_publish_client_alloc_datastore(&asterisk_mwi_publisher_state_datastore, "asterisk-mwi-publisher");
+ if (!datastore) {
+ return -1;
+ }
+
+ publisher_state = ast_calloc(1, sizeof(struct asterisk_mwi_publisher_state));
+ if (!publisher_state) {
+ return -1;
+ }
+ datastore->data = publisher_state;
value = ast_sorcery_object_get_extended(configuration, "mailbox_state_filter");
if (!ast_strlen_zero(value)) {
@@ -337,78 +424,51 @@
publisher_state->mailbox_state_filter = 1;
}
- value = ast_sorcery_object_get_extended(configuration, "mailbox_state");
- if (!ast_strlen_zero(value)) {
- publisher_state->mailbox_state = ast_true(value);
- }
-
publisher_state->client = ao2_bump(client);
if (ast_sip_publish_client_add_datastore(client, datastore)) {
return -1;
}
- if (publisher_state->device_state) {
- publisher_state->device_state_subscription = stasis_subscribe(ast_device_state_topic_all(),
- asterisk_publisher_devstate_cb, ao2_bump(datastore));
- if (!publisher_state->device_state_subscription) {
- ast_sip_publish_client_remove_datastore(client, "asterisk-publisher");
- return -1;
- }
-
- cached = stasis_cache_dump(ast_device_state_cache(), NULL);
- ao2_callback(cached, OBJ_NODATA, cached_devstate_cb, datastore);
- ao2_ref(cached, -1);
- }
-
- if (publisher_state->mailbox_state) {
- publisher_state->mailbox_state_subscription = stasis_subscribe(ast_mwi_topic_all(),
- asterisk_publisher_mwistate_cb, ao2_bump(datastore));
- if (!publisher_state->mailbox_state_subscription) {
- if (publisher_state->device_state_subscription) {
- stasis_unsubscribe_and_join(publisher_state->device_state_subscription);
- }
- ast_sip_publish_client_remove_datastore(client, "asterisk-publisher");
- return -1;
- }
-
- cached = stasis_cache_dump(ast_mwi_state_cache(), NULL);
- ao2_callback(cached, OBJ_NODATA, cached_mwistate_cb, datastore);
- ao2_ref(cached, -1);
- }
-
- return 0;
-}
-
-static int asterisk_stop_publishing(struct ast_sip_outbound_publish_client *client)
-{
- RAII_VAR(struct ast_datastore *, datastore, ast_sip_publish_client_get_datastore(client, "asterisk-publisher"),
+ publisher_state->mailbox_state_subscription = stasis_subscribe(ast_mwi_topic_all(),
+ asterisk_publisher_mwistate_cb, ao2_bump(datastore));
+ if (!publisher_state->mailbox_state_subscription) {
+ ast_sip_publish_client_remove_datastore(client, "asterisk-mwi-publisher");
+ return -1;
+ }
+
+ cached = stasis_cache_dump(ast_mwi_state_cache(), NULL);
+ ao2_callback(cached, OBJ_NODATA, cached_mwistate_cb, datastore);
+ ao2_ref(cached, -1);
+
+ return 0;
+}
+
+static int asterisk_stop_mwi_publishing(struct ast_sip_outbound_publish_client *client)
+{
+ RAII_VAR(struct ast_datastore *, datastore, ast_sip_publish_client_get_datastore(client, "asterisk-mwi-publisher"),
ao2_cleanup);
- struct asterisk_publisher_state *publisher_state;
+ struct asterisk_mwi_publisher_state *publisher_state;
if (!datastore) {
return 0;
}
publisher_state = datastore->data;
- if (publisher_state->device_state_subscription) {
- stasis_unsubscribe_and_join(publisher_state->device_state_subscription);
- ao2_ref(datastore, -1);
- }
if (publisher_state->mailbox_state_subscription) {
stasis_unsubscribe_and_join(publisher_state->mailbox_state_subscription);
ao2_ref(datastore, -1);
}
- ast_sip_publish_client_remove_datastore(client, "asterisk-publisher");
-
- return 0;
-}
-
-struct ast_sip_event_publisher_handler asterisk_publisher_handler = {
- .event_name = "asterisk",
- .start_publishing = asterisk_start_publishing,
- .stop_publishing = asterisk_stop_publishing,
+ ast_sip_publish_client_remove_datastore(client, "asterisk-mwi-publisher");
+
+ return 0;
+}
+
+struct ast_sip_event_publisher_handler asterisk_mwi_publisher_handler = {
+ .event_name = "asterisk-mwi",
+ .start_publishing = asterisk_start_mwi_publishing,
+ .stop_publishing = asterisk_stop_mwi_publishing,
};
static int asterisk_publication_new(struct ast_sip_endpoint *endpoint, const char *resource, const char *event_configuration)
@@ -491,51 +551,40 @@
return 0;
}
-static int asterisk_publication_refresh(struct ast_sip_publication *pub, struct asterisk_publication_config *config,
- struct ast_eid *pubsub_eid, struct ast_json *json)
+static int asterisk_publication_devicestate_refresh(struct ast_sip_publication *pub,
+ struct asterisk_publication_config *config, struct ast_eid *pubsub_eid, struct ast_json *json)
{
struct ast_sip_outbound_publish_client *client;
struct ast_datastore *datastore;
- struct asterisk_publisher_state *publisher_state;
struct ao2_container *cached;
- if (ast_strlen_zero(config->publish)) {
- return 0;
- }
-
- client = ast_sip_publish_client_get(config->publish);
+ if (ast_strlen_zero(config->devicestate_publish)) {
+ return 0;
+ }
+
+ client = ast_sip_publish_client_get(config->devicestate_publish);
if (!client) {
- ast_log(LOG_ERROR, "Received refresh request on publication '%s' but publish '%s' is not available\n",
- ast_sorcery_object_get_id(config), config->publish);
- return 0;
- }
-
- datastore = ast_sip_publish_client_get_datastore(client, "asterisk-publisher");
+ ast_log(LOG_ERROR, "Received refresh request for devicestate on publication '%s' but publish '%s' is not available\n",
+ ast_sorcery_object_get_id(config), config->devicestate_publish);
+ return 0;
+ }
+
+ datastore = ast_sip_publish_client_get_datastore(client, "asterisk-devicestate-publisher");
if (!datastore) {
ao2_ref(client, -1);
return 0;
}
- publisher_state = datastore->data;
-
- if (publisher_state->device_state) {
- cached = stasis_cache_dump(ast_device_state_cache(), NULL);
- ao2_callback(cached, OBJ_NODATA, cached_devstate_cb, datastore);
- ao2_ref(cached, -1);
- }
-
- if (publisher_state->mailbox_state) {
- cached = stasis_cache_dump(ast_mwi_state_cache(), NULL);
- ao2_callback(cached, OBJ_NODATA, cached_mwistate_cb, datastore);
- ao2_ref(cached, -1);
- }
-
+
+ cached = stasis_cache_dump(ast_device_state_cache(), NULL);
+ ao2_callback(cached, OBJ_NODATA, cached_devstate_cb, datastore);
+ ao2_ref(cached, -1);
ao2_ref(client, -1);
ao2_ref(datastore, -1);
return 0;
}
-static int asterisk_publication_state_change(struct ast_sip_publication *pub, pjsip_msg_body *body,
+static int asterisk_publication_devicestate_state_change(struct ast_sip_publication *pub, pjsip_msg_body *body,
enum ast_sip_publish_state state)
{
RAII_VAR(struct asterisk_publication_config *, config, ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "asterisk-publication",
@@ -585,10 +634,98 @@
return -1;
} else if (!strcmp(type, "devicestate")) {
res = asterisk_publication_devicestate(pub, config, &pubsub_eid, json);
+ } else if (!strcmp(type, "refresh")) {
+ res = asterisk_publication_devicestate_refresh(pub, config, &pubsub_eid, json);
+ }
+
+ return res;
+}
+
+static int asterisk_publication_mwi_refresh(struct ast_sip_publication *pub,
+ struct asterisk_publication_config *config, struct ast_eid *pubsub_eid, struct ast_json *json)
+{
+ struct ast_sip_outbound_publish_client *client;
+ struct ast_datastore *datastore;
+ struct ao2_container *cached;
+
+ if (ast_strlen_zero(config->mailboxstate_publish)) {
+ return 0;
+ }
+
+ client = ast_sip_publish_client_get(config->mailboxstate_publish);
+ if (!client) {
+ ast_log(LOG_ERROR, "Received refresh request for mwi state on publication '%s' but publish '%s' is not available\n",
+ ast_sorcery_object_get_id(config), config->mailboxstate_publish);
+ return 0;
+ }
+
+ datastore = ast_sip_publish_client_get_datastore(client, "asterisk-mwi-publisher");
+ if (!datastore) {
+ ao2_ref(client, -1);
+ return 0;
+ }
+
+ cached = stasis_cache_dump(ast_mwi_state_cache(), NULL);
+ ao2_callback(cached, OBJ_NODATA, cached_mwistate_cb, datastore);
+ ao2_ref(cached, -1);
+ ao2_ref(client, -1);
+ ao2_ref(datastore, -1);
+
+ return 0;
+}
+
+static int asterisk_publication_mwi_state_change(struct ast_sip_publication *pub, pjsip_msg_body *body,
+ enum ast_sip_publish_state state)
+{
+ RAII_VAR(struct asterisk_publication_config *, config, ast_sorcery_retrieve_by_id(ast_sip_get_sorcery(), "asterisk-publication",
+ ast_sip_publication_get_event_configuration(pub)), ao2_cleanup);
+ RAII_VAR(struct ast_json *, json, NULL, ast_json_unref);
+ const char *eid, *type;
+ struct ast_eid pubsub_eid;
+ int res = -1;
+
+ /* If no configuration exists for this publication it has most likely been removed, so drop this immediately */
+ if (!config) {
+ return -1;
+ }
+
+ /* If no body exists this is a refresh and can be ignored */
+ if (!body) {
+ return 0;
+ }
+
+ /* We only accept JSON for content */
+ if (pj_strcmp2(&body->content_type.type, "application") ||
+ pj_strcmp2(&body->content_type.subtype, "json")) {
+ ast_debug(2, "Received unsupported content type for Asterisk event on resource '%s'\n",
+ ast_sorcery_object_get_id(config));
+ return -1;
+ }
+
+ json = ast_json_load_buf(body->data, body->len, NULL);
+ if (!json) {
+ ast_debug(1, "Received unparseable JSON event for resource '%s'\n",
+ ast_sorcery_object_get_id(config));
+ return -1;
+ }
+
+ eid = ast_json_string_get(ast_json_object_get(json, "eid"));
+ if (!eid) {
+ ast_debug(1, "Received event without eid for resource '%s'\n",
+ ast_sorcery_object_get_id(config));
+ return -1;
+ }
+ ast_str_to_eid(&pubsub_eid, eid);
+
+ type = ast_json_string_get(ast_json_object_get(json, "type"));
+ if (!type) {
+ ast_debug(1, "Received event without type for resource '%s'\n",
+ ast_sorcery_object_get_id(config));
+ return -1;
} else if (!strcmp(type, "mailboxstate")) {
res = asterisk_publication_mailboxstate(pub, config, &pubsub_eid, json);
} else if (!strcmp(type, "refresh")) {
- res = asterisk_publication_refresh(pub, config, &pubsub_eid, json);
+ res = asterisk_publication_mwi_refresh(pub, config, &pubsub_eid, json);
}
return res;
@@ -599,17 +736,21 @@
struct asterisk_publication_config *config = obj;
struct ast_sip_outbound_publish_client *client;
- if (ast_strlen_zero(config->publish)) {
- return 0;
- }
-
- client = ast_sip_publish_client_get(config->publish);
- if (!client) {
- return 0;
- }
-
- ast_sip_publish_client_send(client, arg);
- ao2_ref(client, -1);
+ if (!ast_strlen_zero(config->devicestate_publish)) {
+ client = ast_sip_publish_client_get(config->devicestate_publish);
+ if (client) {
+ ast_sip_publish_client_send(client, arg);
+ ao2_ref(client, -1);
+ }
+ }
+
+ if (!ast_strlen_zero(config->mailboxstate_publish)) {
+ client = ast_sip_publish_client_get(config->mailboxstate_publish);
+ if (client) {
+ ast_sip_publish_client_send(client, arg);
+ ao2_ref(client, -1);
+ }
+ }
return 0;
}
@@ -655,10 +796,16 @@
ao2_ref(publications, -1);
}
-struct ast_sip_publish_handler asterisk_publication_handler = {
- .event_name = "asterisk",
+struct ast_sip_publish_handler asterisk_devicestate_publication_handler = {
+ .event_name = "asterisk-devicestate",
.new_publication = asterisk_publication_new,
- .publication_state_change = asterisk_publication_state_change,
+ .publication_state_change = asterisk_publication_devicestate_state_change,
+};
+
+struct ast_sip_publish_handler asterisk_mwi_publication_handler = {
+ .event_name = "asterisk-mwi",
+ .new_publication = asterisk_publication_new,
+ .publication_state_change = asterisk_publication_mwi_state_change,
};
/*! \brief Destructor function for Asterisk publication configuration */
@@ -714,22 +861,38 @@
}
ast_sorcery_object_field_register(ast_sip_get_sorcery(), "asterisk-publication", "type", "", OPT_NOOP_T, 0, 0);
- ast_sorcery_object_field_register(ast_sip_get_sorcery(), "asterisk-publication", "publish", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct asterisk_publication_config, publish));
+ ast_sorcery_object_field_register(ast_sip_get_sorcery(), "asterisk-publication", "devicestate_publish", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct asterisk_publication_config, devicestate_publish));
+ ast_sorcery_object_field_register(ast_sip_get_sorcery(), "asterisk-publication", "mailboxstate_publish", "", OPT_STRINGFIELD_T, 0, STRFLDSET(struct asterisk_publication_config, mailboxstate_publish));
ast_sorcery_object_field_register(ast_sip_get_sorcery(), "asterisk-publication", "device_state", "no", OPT_BOOL_T, 1, FLDSET(struct asterisk_publication_config, device_state));
ast_sorcery_object_field_register_custom(ast_sip_get_sorcery(), "asterisk-publication", "device_state_filter", "", regex_filter_handler, NULL, NULL, 0, 0);
ast_sorcery_object_field_register(ast_sip_get_sorcery(), "asterisk-publication", "mailbox_state", "no", OPT_BOOL_T, 1, FLDSET(struct asterisk_publication_config, mailbox_state));
ast_sorcery_object_field_register_custom(ast_sip_get_sorcery(), "asterisk-publication", "mailbox_state_filter", "", regex_filter_handler, NULL, NULL, 0, 0);
ast_sorcery_reload_object(ast_sip_get_sorcery(), "asterisk-publication");
- if (ast_sip_register_publish_handler(&asterisk_publication_handler)) {
+ if (ast_sip_register_publish_handler(&asterisk_devicestate_publication_handler)) {
ast_log(LOG_WARNING, "Unable to register event publication handler %s\n",
- asterisk_publication_handler.event_name);
+ asterisk_devicestate_publication_handler.event_name);
return AST_MODULE_LOAD_DECLINE;
}
- if (ast_sip_register_event_publisher_handler(&asterisk_publisher_handler)) {
+ if (ast_sip_register_publish_handler(&asterisk_mwi_publication_handler)) {
+ ast_log(LOG_WARNING, "Unable to register event publication handler %s\n",
+ asterisk_mwi_publication_handler.event_name);
+ ast_sip_unregister_publish_handler(&asterisk_devicestate_publication_handler);
+ return AST_MODULE_LOAD_DECLINE;
+ }
+ if (ast_sip_register_event_publisher_handler(&asterisk_devicestate_publisher_handler)) {
ast_log(LOG_WARNING, "Unable to register event publisher handler %s\n",
- asterisk_publisher_handler.event_name);
- ast_sip_unregister_publish_handler(&asterisk_publication_handler);
+ asterisk_devicestate_publisher_handler.event_name);
+ ast_sip_unregister_publish_handler(&asterisk_devicestate_publication_handler);
+ ast_sip_unregister_publish_handler(&asterisk_mwi_publication_handler);
+ return AST_MODULE_LOAD_DECLINE;
+ }
+ if (ast_sip_register_event_publisher_handler(&asterisk_mwi_publisher_handler)) {
+ ast_log(LOG_WARNING, "Unable to register event publisher handler %s\n",
+ asterisk_mwi_publisher_handler.event_name);
+ ast_sip_unregister_event_publisher_handler(&asterisk_mwi_publisher_handler);
+ ast_sip_unregister_publish_handler(&asterisk_devicestate_publication_handler);
+ ast_sip_unregister_publish_handler(&asterisk_mwi_publication_handler);
return AST_MODULE_LOAD_DECLINE;
}
@@ -747,8 +910,10 @@
static int unload_module(void)
{
- ast_sip_unregister_publish_handler(&asterisk_publication_handler);
- ast_sip_unregister_event_publisher_handler(&asterisk_publisher_handler);
+ ast_sip_unregister_publish_handler(&asterisk_devicestate_publication_handler);
+ ast_sip_unregister_publish_handler(&asterisk_mwi_publication_handler);
+ ast_sip_unregister_event_publisher_handler(&asterisk_devicestate_publisher_handler);
+ ast_sip_unregister_event_publisher_handler(&asterisk_mwi_publisher_handler);
return 0;
}
More information about the asterisk-commits
mailing list