[asterisk-commits] mmichelson: branch group/CCSS r215956 - /team/group/CCSS/main/ccss.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Sep 3 11:37:02 CDT 2009


Author: mmichelson
Date: Thu Sep  3 11:36:59 2009
New Revision: 215956

URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=215956
Log:
Fill in some generic device monitor callbacks


Modified:
    team/group/CCSS/main/ccss.c

Modified: team/group/CCSS/main/ccss.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/group/CCSS/main/ccss.c?view=diff&rev=215956&r1=215955&r2=215956
==============================================================================
--- team/group/CCSS/main/ccss.c (original)
+++ team/group/CCSS/main/ccss.c Thu Sep  3 11:36:59 2009
@@ -1265,21 +1265,55 @@
 	.destructor = cc_generic_monitor_destructor,
 };
 
+/*!
+ * \brief private data for generic device monitor
+ */
+struct generic_monitor_pvt {
+	/*!
+	 * Handle for event subscription to device state
+	 */
+	struct ast_event_sub *sub;
+};
+
 static int cc_generic_monitor_init(struct ast_cc_monitor *monitor, const int core_id)
 {
+	struct generic_monitor_pvt *gen_mon_pvt = ast_calloc(1, sizeof(*gen_mon_pvt));
+
+	if (!gen_mon_pvt) {
+		return -1;
+	}
+	return 0;
+}
+
+static void generic_monitor_devstate_cb(const struct ast_event *event, void *userdata)
+{
 	/* STUB */
-	return 0;
+	return;
 }
 
 static int cc_generic_monitor_request_cc(struct ast_cc_monitor *monitor, const int core_id)
 {
-	/* STUB */
+	struct generic_monitor_pvt *gen_mon_pvt = monitor->private_data;
+
+	if (gen_mon_pvt->sub) {
+		return 0;
+	}
+	
+	if (!(gen_mon_pvt->sub = ast_event_subscribe(
+			AST_EVENT_DEVICE_STATE, generic_monitor_devstate_cb, NULL, monitor, 
+			AST_EVENT_IE_DEVICE, AST_EVENT_IE_PLTYPE_STR, monitor->name))) {
+		return -1;
+	}
 	return 0;
 }
 
 static int cc_generic_monitor_suspend(struct ast_cc_monitor *monitor, const int core_id)
 {
-	/* STUB */
+	/* Generic monitors don't do anything special when a request
+	 * for monitor suspension occurs. The parent link will be
+	 * marked as being suspended, and that can factor into the
+	 * the device monitor's decisions.
+	 */
 	return 0;
 }
 
@@ -1291,13 +1325,19 @@
 
 static int cc_generic_monitor_unsuspend(struct ast_cc_monitor *monitor, const int core_id)
 {
-	/* STUB */
+	/* Since we don't suspend a generic monitor, we can't really
+	 * unsuspend it either.
+	 */
 	return 0;
 }
 
 static void cc_generic_monitor_destructor(void *monitor)
 {
-	/* STUB */
+	struct ast_cc_monitor *mon = monitor;
+	struct generic_monitor_pvt *gen_mon_pvt = mon->private_data;
+
+	gen_mon_pvt->sub = ast_event_unsubscribe(gen_mon_pvt->sub);
+	ast_free(gen_mon_pvt);
 	return;
 }
 




More information about the asterisk-commits mailing list