[svn-commits] mmichelson: branch group/CCSS r229674 - /team/group/CCSS/channels/chan_sip.c

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Nov 12 10:56:06 CST 2009


Author: mmichelson
Date: Thu Nov 12 10:56:03 2009
New Revision: 229674

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=229674
Log:
Add callbacks to event_state_compositor struct and place them
where they should go.

Next step is to provide a means to initialize them as necessary.


Modified:
    team/group/CCSS/channels/chan_sip.c

Modified: team/group/CCSS/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/team/group/CCSS/channels/chan_sip.c?view=diff&rev=229674&r1=229673&r2=229674
==============================================================================
--- team/group/CCSS/channels/chan_sip.c (original)
+++ team/group/CCSS/channels/chan_sip.c Thu Nov 12 10:56:03 2009
@@ -1734,6 +1734,17 @@
 	int core_id;
 };
 
+struct event_state_compositor;
+
+typedef int (*publish_callback)(struct sip_pvt *, struct sip_request *, struct event_state_compositor *, struct sip_esc_entry *);
+
+struct sip_publish_callbacks {
+	publish_callback initial_handler;
+	publish_callback refresh_handler;
+	publish_callback modify_handler;
+	publish_callback remove_handler;
+};
+
 /*!
  * \brief The Event State Compositors
  *
@@ -1750,6 +1761,7 @@
 	enum subscriptiontype event;
 	const char * name;
 	struct ao2_container *compositor;
+	struct sip_publish_callbacks *callbacks;
 } event_state_compositors [] = {
 	{CALL_COMPLETION, "call-completion", },
 };
@@ -22466,19 +22478,25 @@
 static int handle_sip_publish_initial(struct sip_pvt *p, struct sip_request *req, struct event_state_compositor *esc, const int expires)
 {
 	struct sip_esc_entry *esc_entry = create_esc_entry(esc, req, expires);
+	int res = 0;
 
 	if (!esc_entry) {
 		return -1;
 	}
 
+	if (esc->callbacks->initial_handler) {
+		res = esc->callbacks->initial_handler(p, req, esc, esc_entry);
+	}
+
 	ao2_ref(esc_entry, -1);
-	return 0;
+	return res;
 }
 
 static int handle_sip_publish_refresh(struct sip_pvt *p, struct sip_request *req, struct event_state_compositor *esc, const char * const eid, const int expires)
 {
 	struct sip_esc_entry *esc_entry = get_esc_entry(eid, esc);
 	int expires_ms = expires * 1000;
+	int res = 0;
 	/* A refresh is pretty simple. We need to verify that the eid corresponds to an esc entry of ours.
 	 * If it does, great. We just reschedule destruction of the entry for later.
 	 */
@@ -22489,30 +22507,51 @@
 
 	AST_SCHED_REPLACE(esc_entry->sched_id, sched, expires_ms, publish_expire, esc_entry);
 
+	if (esc->callbacks->refresh_handler) {
+		res = esc->callbacks->refresh_handler(p, req, esc, esc_entry);
+	}
+
 	ao2_ref(esc_entry, -1);
-	return 0;
+	return res;
 }
 
 static int handle_sip_publish_modify(struct sip_pvt *p, struct sip_request *req, struct event_state_compositor *esc, const char * const eid, const int expires)
 {
-	/* This is where some real work can be done. When a PUBLISH modifies state, that's when the ESC
-	 * actually has to take some sort of action. In the case of the CC ESC, this means reporting to the
-	 * CC core that a caller is either busy or available, depending on the circumstances
-	 */
-
-	/* XXX STUB */
-	return 0;
+	struct sip_esc_entry *esc_entry = get_esc_entry(eid, esc);
+	int expires_ms = expires * 1000;
+	int res = 0;
+
+	if (!esc_entry) {
+		return -1;
+	}
+
+	AST_SCHED_REPLACE(esc_entry->sched_id, sched, expires_ms, publish_expire, esc_entry);
+
+	if (esc->callbacks->modify_handler) {
+		res = esc->callbacks->modify_handler(p, req, esc, esc_entry);
+	}
+
+	return res;
 }
 
 static int handle_sip_publish_remove(struct sip_pvt *p, struct sip_request *req, struct event_state_compositor *esc, const char * const eid)
 {
-	/* This should be relatively simple. Just find the esc entry, delete its scheduler entry, unlink it, unref it, and it
-	 * goes away automatically. Now, there of course may be specific actions to be taken by ESCs as a result of receiving
-	 * a PUBLISH remove request.
-	 */
-
-	/* XXX STUB */
-	return 0;
+	struct sip_esc_entry *esc_entry = get_esc_entry(eid, esc);
+	int res = 0;
+
+	if (!esc_entry) {
+		return -1;
+	}
+
+	AST_SCHED_DEL(sched, esc_entry->sched_id);
+	ao2_unlink(esc->compositor, esc_entry);
+
+	if (esc->callbacks->remove_handler) {
+		res = esc->callbacks->remove_handler(p, req, esc, esc_entry);
+	}
+
+	ao2_ref(esc_entry, -1);
+	return res;
 }
 
 static int handle_request_publish(struct sip_pvt *p, struct sip_request *req, struct sockaddr_in *sin, const char *uri)




More information about the svn-commits mailing list