summaryrefslogtreecommitdiff
path: root/res/res_pjsip_mwi.c
diff options
context:
space:
mode:
authorKevin Harwell <kharwell@digium.com>2013-11-23 17:26:57 +0000
committerKevin Harwell <kharwell@digium.com>2013-11-23 17:26:57 +0000
commit05cbf8df9b2ea0b41e049698b9f51ee4365ceab0 (patch)
tree896d138372ec9fc2f443374c6f200a0f67725fbb /res/res_pjsip_mwi.c
parent14a74529344ef5229f100c81bc969f34e27112b3 (diff)
res_pjsip: AMI commands and events.
Created the following AMI commands and corresponding events for res_pjsip: PJSIPShowEndpoints - Provides a listing of all pjsip endpoints and a few select attributes on each. Events: EndpointList - for each endpoint a few attributes. EndpointlistComplete - after all endpoints have been listed. PJSIPShowEndpoint - Provides a detail list of attributes for a specified endpoint. Events: EndpointDetail - attributes on an endpoint. AorDetail - raised for each AOR on an endpoint. AuthDetail - raised for each associated inbound and outbound auth TransportDetail - transport attributes. IdentifyDetail - attributes for the identify object associated with the endpoint. EndpointDetailComplete - last event raised after all detail events. PJSIPShowRegistrationsInbound - Provides a detail listing of all inbound registrations. Events: InboundRegistrationDetail - inbound registration attributes for each registration. InboundRegistrationDetailComplete - raised after all detail records have been listed. PJSIPShowRegistrationsOutbound - Provides a detail listing of all outbound registrations. Events: OutboundRegistrationDetail - outbound registration attributes for each registration. OutboundRegistrationDetailComplete - raised after all detail records have been listed. PJSIPShowSubscriptionsInbound - A detail listing of all inbound subscriptions and their attributes. Events: SubscriptionDetail - on each subscription detailed attributes SubscriptionDetailComplete - raised after all detail records have been listed. PJSIPShowSubscriptionsOutbound - A detail listing of all outboundbound subscriptions and their attributes. Events: SubscriptionDetail - on each subscription detailed attributes SubscriptionDetailComplete - raised after all detail records have been listed. (issue ASTERISK-22609) Reported by: Matt Jordan Review: https://reviewboard.asterisk.org/r/2959/ ........ Merged revisions 403131 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@403133 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_pjsip_mwi.c')
-rw-r--r--res/res_pjsip_mwi.c46
1 files changed, 43 insertions, 3 deletions
diff --git a/res/res_pjsip_mwi.c b/res/res_pjsip_mwi.c
index bd865eec4..4f32f382a 100644
--- a/res/res_pjsip_mwi.c
+++ b/res/res_pjsip_mwi.c
@@ -54,6 +54,7 @@ static void mwi_notify_response(struct ast_sip_subscription *sub, pjsip_rx_data
static void mwi_notify_request(struct ast_sip_subscription *sub, pjsip_rx_data *rdata,
struct ast_sip_subscription_response_data *response_data);
static int mwi_refresh_subscription(struct ast_sip_subscription *sub);
+static void mwi_to_ami(struct ast_sip_subscription *sub, struct ast_str **buf);
static struct ast_sip_subscription_handler mwi_handler = {
.event_name = "message-summary",
@@ -67,6 +68,7 @@ static struct ast_sip_subscription_handler mwi_handler = {
.notify_response = mwi_notify_response,
.notify_request = mwi_notify_request,
.refresh_subscription = mwi_refresh_subscription,
+ .to_ami = mwi_to_ami,
};
/*!
@@ -118,11 +120,11 @@ static struct mwi_stasis_subscription *mwi_stasis_subscription_alloc(const char
{
struct mwi_stasis_subscription *mwi_stasis_sub;
struct stasis_topic *topic;
-
+
if (!mwi_sub) {
return NULL;
}
-
+
mwi_stasis_sub = ao2_alloc(sizeof(*mwi_stasis_sub) + strlen(mailbox), NULL);
if (!mwi_stasis_sub) {
return NULL;
@@ -209,7 +211,7 @@ static struct mwi_subscription *mwi_subscription_alloc(struct ast_sip_endpoint *
static int mwi_sub_hash(const void *obj, int flags)
{
const struct mwi_subscription *mwi_sub = obj;
-
+
return ast_str_hash(mwi_sub->id);
}
@@ -572,6 +574,44 @@ static int mwi_refresh_subscription(struct ast_sip_subscription *sub)
return 0;
}
+static void mwi_subscription_mailboxes_str(struct ao2_container *stasis_subs,
+ struct ast_str **str)
+{
+ int num = ao2_container_count(stasis_subs);
+
+ struct mwi_stasis_subscription *node;
+ struct ao2_iterator i = ao2_iterator_init(stasis_subs, 0);
+
+ while ((node = ao2_iterator_next(&i))) {
+ if (--num) {
+ ast_str_append(str, 0, "%s,", node->mailbox);
+ } else {
+ ast_str_append(str, 0, "%s", node->mailbox);
+ }
+ ao2_ref(node, -1);
+ }
+ ao2_iterator_destroy(&i);
+}
+
+static void mwi_to_ami(struct ast_sip_subscription *sub,
+ struct ast_str **buf)
+{
+ struct mwi_subscription *mwi_sub;
+ RAII_VAR(struct ast_datastore *, mwi_datastore,
+ ast_sip_subscription_get_datastore(sub, "MWI datastore"), ao2_cleanup);
+
+ if (!mwi_datastore) {
+ return;
+ }
+
+ mwi_sub = mwi_datastore->data;
+
+ ast_str_append(buf, 0, "SubscriptionType: mwi\r\n");
+ ast_str_append(buf, 0, "Mailboxes: ");
+ mwi_subscription_mailboxes_str(mwi_sub->stasis_subs, buf);
+ ast_str_append(buf, 0, "\r\n");
+}
+
static int serialized_notify(void *userdata)
{
struct mwi_subscription *mwi_sub = userdata;