[asterisk-commits] branch oej/metermaids-trunk r35581 - in /team/oej/metermaids-trunk: ./ res/

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Jun 22 14:08:21 MST 2006


Author: oej
Date: Thu Jun 22 16:08:21 2006
New Revision: 35581

URL: http://svn.digium.com/view/asterisk?rev=35581&view=rev
Log:
- Implemented new metermaids, so add hint as
	exten => ollepark,hint,park:701 at parkedcalls
- Also tried implementing in meetme, not tested yet
	exten => olleconf,hint,meetme:1234
- Old stuff is still around, will be deleted soon

Modified:
    team/oej/metermaids-trunk/devicestate.c
    team/oej/metermaids-trunk/res/res_features.c

Modified: team/oej/metermaids-trunk/devicestate.c
URL: http://svn.digium.com/view/asterisk/team/oej/metermaids-trunk/devicestate.c?rev=35581&r1=35580&r2=35581&view=diff
==============================================================================
--- team/oej/metermaids-trunk/devicestate.c (original)
+++ team/oej/metermaids-trunk/devicestate.c Thu Jun 22 16:08:21 2006
@@ -142,17 +142,17 @@
 	tech = strsep(&buf, "/");
 	number = buf;
 	if (!number) {
-		number = strsep(&tech, ":");
-		if (!number)
+		provider = strsep(&tech, ":");
+		if (!provider)
 			return AST_DEVICE_INVALID;
 		/* We have a provider */
-		provider = tech;
+		number = tech;
 		tech = NULL;
 	}
 
 	if (provider)  {
 		if(option_debug > 2)
-			ast_log(LOG_DEBUG, "Checking if I can find provider for %s\n", provider);
+			ast_log(LOG_DEBUG, "Checking if I can find provider for \"%s\" - number: %s\n", provider, number);
 		return getproviderstate(provider, number);
 	}
 	if (option_debug > 3)
@@ -219,13 +219,14 @@
 static int getproviderstate(const char *provider, const char *address)
 {
 	struct devstate_prov *devprov;
-	int res = -1;
+	int res = AST_DEVICE_INVALID;
 
 
 	AST_LIST_LOCK(&devstate_provs);
 	AST_LIST_TRAVERSE_SAFE_BEGIN(&devstate_provs, devprov, list) {
 		if(option_debug > 4)
 			ast_log(LOG_DEBUG, "Checking provider %s with %s\n", devprov->label, provider);
+
 		if (!strcasecmp(devprov->label, provider)) {
 			res = devprov->callback(address);
 			break;
@@ -233,7 +234,7 @@
 	}
 	AST_LIST_TRAVERSE_SAFE_END;
 	AST_LIST_UNLOCK(&devstate_provs);
-	return res == -1 ? AST_DEVICE_INVALID : res;
+	return res;
 }
 
 /*! \brief Add device state watcher */
@@ -367,6 +368,7 @@
 	return NULL;
 }
 
+/*! \brief test for watching group:groupname - but it does not work */
 static int groupstate(const char *data)
 {
 	char *buf = ast_strdupa(data);
@@ -374,12 +376,8 @@
 	int count = 0;
 
 	if (option_debug > 2)
-		ast_log(LOG_DEBUG, "Group state checking for %s\n", buf);
-
-	if (buf) {
-		*buf = '\0';
-		buf++;
-	}
+		ast_log(LOG_DEBUG, "Group state checking for group %s Category %s\n", group, buf);
+
 	count = ast_app_group_get_count(group, buf);
 
 	if (!count)

Modified: team/oej/metermaids-trunk/res/res_features.c
URL: http://svn.digium.com/view/asterisk/team/oej/metermaids-trunk/res/res_features.c?rev=35581&r1=35580&r2=35581&view=diff
==============================================================================
--- team/oej/metermaids-trunk/res/res_features.c (original)
+++ team/oej/metermaids-trunk/res/res_features.c Thu Jun 22 16:08:21 2006
@@ -353,9 +353,33 @@
 	}
 	if (option_debug > 3)
 		ast_log(LOG_DEBUG, "Notification of state change to metermaids %s@%s\n", exten, context);
+
+	/* New system */
+	ast_device_state_changed("park:%s@%s", exten, context);
 	return;
 }
 
+/*! \brief metermaids callback from devicestate.c */
+static int metermaidstate(const char *data)
+{
+	int res = AST_DEVICE_INVALID;
+	char *context = ast_strdupa(data);
+	char *exten;
+
+	exten = strsep(&context, "@");
+	if (!context)
+		return res;
+	
+	if (option_debug > 3)
+		ast_log(LOG_DEBUG, "Checking state of exten %s in context %s\n", exten, context);
+
+	res = ast_exists_extension(NULL, context, exten, 1, NULL);
+
+	if (!res)
+		return AST_DEVICE_NOT_INUSE;
+	else
+		return AST_DEVICE_INUSE;
+}
 
 /*! \brief Park a call 
  	\note We put the user in the parking list, then wake up the parking thread to be sure it looks
@@ -2308,6 +2332,8 @@
 	/* Register watcher for parking lots */
         watchid = ast_park_metermaid_add(&local_watcher, NULL);
 
+	res |= ast_devstate_prov_add("Park", metermaidstate);
+
 	return res;
 }
 
@@ -2322,6 +2348,7 @@
 	ast_cli_unregister(&showfeatures);
 	ast_cli_unregister(&showparked);
 	ast_unregister_application(parkcall);
+	ast_devstate_prov_del("Park");
 	return ast_unregister_application(parkedcall);
 }
 



More information about the asterisk-commits mailing list