[asterisk-commits] mmichelson: branch mmichelson/pub_sub r385169 - /team/mmichelson/pub_sub/res/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Apr 10 08:52:25 CDT 2013


Author: mmichelson
Date: Wed Apr 10 08:52:21 2013
New Revision: 385169

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=385169
Log:
Fill in some maintenance on the pubsub core.

* Un-stubbed method to send a request
* Initialize the evsub module on startup
* Register the event package with PJSIP when a subscription handler registers


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=385169&r1=385168&r2=385169
==============================================================================
--- team/mmichelson/pub_sub/res/res_sip_pubsub.c (original)
+++ team/mmichelson/pub_sub/res/res_sip_pubsub.c Wed Apr 10 08:52:21 2013
@@ -187,8 +187,8 @@
 
 int ast_sip_subscription_send_request(struct ast_sip_subscription *sub, pjsip_tx_data *tdata)
 {
-	/* XXX STUB */
-	return 0;
+	return pjsip_evsub_send_request(ast_sip_subscription_get_evsub(sub),
+			tdata) == PJ_SUCCESS ? 0 : -1;
 }
 
 static void subscription_datastore_destroy(void *obj)
@@ -267,6 +267,27 @@
 int ast_sip_register_subscription_handler(struct ast_sip_subscription_handler *handler)
 {
 	/* TODO Ensure duplicate events can't get registered */
+	pj_str_t event;
+	pj_str_t accept[AST_SIP_MAX_ACCEPT];
+	int i;
+
+	if (ast_strlen_zero(handler->event_name)) {
+		ast_log(LOG_ERROR, "No event package specifief for subscription handler. Cannot register\n");
+		return -1;
+	}
+
+	if (ast_strlen_zero(handler->accept[0])) {
+		ast_log(LOG_ERROR, "Subscription handler must supply at least one 'Accept' format\n");
+		return -1;
+	}
+
+	pj_cstr(&event, handler->event_name);
+	for (i = 0; i < AST_SIP_MAX_ACCEPT && !ast_strlen_zero(handler->accept[i]); ++i) {
+		pj_cstr(&accept[i], handler->accept[i]);
+	}
+
+	pjsip_evsub_register_pkg(&sub_module, &event, DEFAULT_EXPIRES, i, accept);
+
 	SCOPED_LOCK(lock, &subscription_handlers, AST_RWLIST_WRLOCK, AST_RWLIST_UNLOCK);
 	AST_RWLIST_INSERT_TAIL(&subscription_handlers, handler, next);
 	ast_module_ref(ast_module_info->self);
@@ -505,6 +526,7 @@
 
 static int load_module(void)
 {
+	pjsip_evsub_init_module(ast_sip_pjsip_endpoint());
 	if (ast_sip_register_service(&sub_module)) {
 		return AST_MODULE_LOAD_DECLINE;
 	}




More information about the asterisk-commits mailing list