[asterisk-commits] mmichelson: branch mmichelson/pub_sub r385046 - /team/mmichelson/pub_sub/res/
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Mon Apr 8 16:49:48 CDT 2013
Author: mmichelson
Date: Mon Apr 8 16:49:43 2013
New Revision: 385046
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=385046
Log:
Fill in evsub allocation routine.
This compiles, but it's not especially useful since we don't yet supply
any callbacks for the subscription.
Modified:
team/mmichelson/pub_sub/res/res_sip_pubsub.c
Modified: team/mmichelson/pub_sub/res/res_sip_pubsub.c
URL: http://svnview.digium.com/svn/asterisk/team/mmichelson/pub_sub/res/res_sip_pubsub.c?view=diff&rev=385046&r1=385045&r2=385046
==============================================================================
--- team/mmichelson/pub_sub/res/res_sip_pubsub.c (original)
+++ team/mmichelson/pub_sub/res/res_sip_pubsub.c Mon Apr 8 16:49:43 2013
@@ -77,15 +77,50 @@
static void subscription_destructor(void *obj)
{
struct ast_sip_subscription *sub = obj;
+
ao2_cleanup(sub->datastores);
ao2_cleanup(sub->endpoint);
ast_taskprocessor_unreference(sub->serializer);
}
+static pjsip_evsub *allocate_evsub(const char *event, enum ast_sip_subscription_role role,
+ struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata)
+{
+ pjsip_dialog *dlg;
+ pjsip_evsub *evsub;
+ /* PJSIP is kind enough to have some built-in support for certain
+ * events. We need to use the correct initialization function for the
+ * built-in events
+ */
+ if (role == AST_SIP_NOTIFIER) {
+ pjsip_dlg_create_uas(pjsip_ua_instance(), rdata, NULL, &dlg);
+ if (!strcmp(event, "message-summary")) {
+ pjsip_mwi_create_uas(dlg, NULL, rdata, &evsub);
+ } else if (!strcmp(event, "presence")) {
+ pjsip_pres_create_uas(dlg, NULL, rdata, &evsub);
+ } else {
+ pjsip_evsub_create_uas(dlg, NULL, rdata, 0, &evsub);
+ }
+ } else {
+ dlg = ast_sip_create_dialog(endpoint, NULL, NULL);
+ if (!strcmp(event, "message-summary")) {
+ pjsip_mwi_create_uac(dlg, NULL, 0, &evsub);
+ } else if (!strcmp(event, "presence")) {
+ pjsip_pres_create_uac(dlg, NULL, 0, &evsub);
+ } else {
+ pj_str_t pj_event;
+ pj_cstr(&pj_event, event);
+ pjsip_evsub_create_uac(dlg, NULL, &pj_event, 0, &evsub);
+ }
+ }
+ return evsub;
+}
+
struct ast_sip_subscription *ast_sip_create_subscription(const struct ast_sip_subscription_handler *handler,
enum ast_sip_subscription_role role, struct ast_sip_endpoint *endpoint, pjsip_rx_data *rdata)
{
struct ast_sip_subscription *sub = ao2_alloc(sizeof(*sub), subscription_destructor);
+
if (!sub) {
return NULL;
}
@@ -99,6 +134,7 @@
ao2_ref(sub, -1);
return NULL;
}
+ sub->evsub = allocate_evsub(handler->event_name, role, endpoint, rdata);
ao2_ref(endpoint, +1);
sub->endpoint = endpoint;
sub->handler = handler;
@@ -120,8 +156,7 @@
pjsip_evsub *ast_sip_subscription_get_evsub(struct ast_sip_subscription *sub)
{
- /* XXX STUB */
- return NULL;
+ return sub->evsub;
}
int ast_sip_subscription_send_request(struct ast_sip_subscription *sub, pjsip_tx_data *tdata)
@@ -270,6 +305,7 @@
RAII_VAR(struct ast_sip_endpoint *, endpoint, NULL, ao2_cleanup);
struct ast_sip_subscription *sub;
int i;
+
if (pjsip_method_cmp(&rdata->msg_info.msg->line.req.method, pjsip_get_subscribe_method())) {
return PJ_FALSE;
}
More information about the asterisk-commits
mailing list