[asterisk-commits] trunk r28484 - /trunk/channels/chan_local.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri May 19 00:56:56 MST 2006


Author: oej
Date: Fri May 19 02:56:56 2006
New Revision: 28484

URL: http://svn.digium.com/view/asterisk?rev=28484&view=rev
Log:
Add simple devicestate for chan_local

Modified:
    trunk/channels/chan_local.c

Modified: trunk/channels/chan_local.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_local.c?rev=28484&r1=28483&r2=28484&view=diff
==============================================================================
--- trunk/channels/chan_local.c (original)
+++ trunk/channels/chan_local.c Fri May 19 02:56:56 2006
@@ -60,6 +60,7 @@
 #include "asterisk/musiconhold.h"
 #include "asterisk/manager.h"
 #include "asterisk/stringfields.h"
+#include "asterisk/devicestate.h"
 
 static const char tdesc[] = "Local Proxy Channel Driver";
 
@@ -75,6 +76,7 @@
 static int local_indicate(struct ast_channel *ast, int condition, const void *data, size_t datalen);
 static int local_fixup(struct ast_channel *oldchan, struct ast_channel *newchan);
 static int local_sendhtml(struct ast_channel *ast, int subclass, const char *data, int datalen);
+static int local_devicestate(void *data);
 
 /* PBX interface structure for channel registration */
 static const struct ast_channel_tech local_tech = {
@@ -92,6 +94,7 @@
 	.indicate = local_indicate,
 	.fixup = local_fixup,
 	.send_html = local_sendhtml,
+	.devicestate = local_devicestate,
 };
 
 struct local_pvt {
@@ -110,6 +113,28 @@
 };
 
 static AST_LIST_HEAD_STATIC(locals, local_pvt);
+
+/*! \brief Adds devicestate to local channels */
+static int local_devicestate(void *data)
+{
+	char *exten;
+	char *context;
+
+	int res;
+		
+	exten = ast_strdupa(data);
+	if ((context  = strchr(exten, '@'))) {
+		*context = '\0';
+		context = context + 1;
+	}
+	if (option_debug > 2)
+		ast_log(LOG_DEBUG, "Checking if extension %s@%s exists (devicestate)\n", exten, context);
+	res = ast_exists_extension(NULL, context, exten, 1, NULL);
+	if (!res)
+		return AST_DEVICE_NOT_INUSE;
+	else
+		return AST_DEVICE_INUSE;
+}
 
 static int local_queue_frame(struct local_pvt *p, int isoutbound, struct ast_frame *f, struct ast_channel *us)
 {



More information about the asterisk-commits mailing list