[asterisk-commits] branch oej/00-labarea r18407 - in /team/oej/00-labarea: ./ channels/ include/...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Fri Apr 7 13:42:28 MST 2006


Author: oej
Date: Fri Apr  7 15:42:23 2006
New Revision: 18407

URL: http://svn.digium.com/view/asterisk?rev=18407&view=rev
Log:
Update

Modified:
    team/oej/00-labarea/channels/chan_sip.c
    team/oej/00-labarea/devicestate.c
    team/oej/00-labarea/include/asterisk/devicestate.h
    team/oej/00-labarea/include/asterisk/pbx.h
    team/oej/00-labarea/manager.c
    team/oej/00-labarea/pbx.c

Modified: team/oej/00-labarea/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/00-labarea/channels/chan_sip.c?rev=18407&r1=18406&r2=18407&view=diff
==============================================================================
--- team/oej/00-labarea/channels/chan_sip.c (original)
+++ team/oej/00-labarea/channels/chan_sip.c Fri Apr  7 15:42:23 2006
@@ -6388,7 +6388,7 @@
 /*! \brief Callback for the devicestate notification (SUBSCRIBE) support subsystem
 \note	If you add an "hint" priority to the extension in the dial plan,
 	you will get notifications on device state changes */
-static int cb_extensionstate(char *context, char* exten, int state, void *data)
+static int cb_extensionstate(char *context, char* exten, int state, void *data, char *channel)
 {
 	struct sip_pvt *p = data;
 
@@ -6410,7 +6410,7 @@
 	transmit_state_notify(p, state, 1);
 
 	if (option_debug > 1)
-		ast_verbose(VERBOSE_PREFIX_1 "Extension Changed %s new state %s for Notify User %s\n", exten, ast_extension_state2str(state), p->username);
+		ast_verbose(VERBOSE_PREFIX_1 "Extension Changed %s new state %s for Notify User %s Caused by %s\n", exten, ast_extension_state2str(state), p->username, S_OR(channel, "<device state change>"));
 	return 0;
 }
 

Modified: team/oej/00-labarea/devicestate.c
URL: http://svn.digium.com/view/asterisk/team/oej/00-labarea/devicestate.c?rev=18407&r1=18406&r2=18407&view=diff
==============================================================================
--- team/oej/00-labarea/devicestate.c (original)
+++ team/oej/00-labarea/devicestate.c Fri Apr  7 15:42:23 2006
@@ -64,6 +64,7 @@
 
 struct state_change {
 	AST_LIST_ENTRY(state_change) list;
+	char name[AST_CHANNEL_NAME];
 	char device[1];
 };
 
@@ -179,21 +180,22 @@
 }
 
 /*! \brief Notify callback watchers of change, and notify PBX core for hint updates */
-static void do_state_change(const char *device)
+static void do_state_change(struct state_change *change, const char *device)
 {
 	int state;
 	struct devstate_cb *devcb;
-
-	state = ast_device_state(device);
+	char *dev = (change ? change->device : device);
+
+	state = ast_device_state(dev);
 	if (option_debug > 2)
-		ast_log(LOG_DEBUG, "Changing state for %s - state %d (%s)\n", device, state, devstate2str(state));
+		ast_log(LOG_DEBUG, "Changing state for %s - state %d (%s) Channel: %s\n", dev, state, devstate2str(state), change ? (S_OR(change->name, "<none>")) : "<none>");
 
 	AST_LIST_LOCK(&devstate_cbs);
 	AST_LIST_TRAVERSE(&devstate_cbs, devcb, list)
-		devcb->callback(device, state, devcb->data);
+		devcb->callback(dev, state, devcb->data, change ? change->name : NULL);
 	AST_LIST_UNLOCK(&devstate_cbs);
 
-	ast_hint_state_changed(device);
+	ast_hint_state_changed(dev, change ? change->name : NULL);
 }
 
 static int __ast_device_state_changed_literal(char *buf)
@@ -202,14 +204,19 @@
 	struct state_change *change;
 
 	device = buf;
-	if ((tmp = strrchr(device, '-')))
-		*tmp = '\0';
 
 	if (change_thread == AST_PTHREADT_NULL || !(change = ast_calloc(1, sizeof(*change) + strlen(device)))) {
 		/* we could not allocate a change struct, or */
 		/* there is no background thread, so process the change now */
-		do_state_change(device);
+		ast_log(LOG_DEBUG, "------- No thred or whatever, changing state of %s anyway\n", device);
+		do_state_change(NULL, device);
 	} else {
+		if ((tmp = strrchr(device, '-'))) {
+			/* Channel name, save that for the future notification */
+			ast_copy_string(change->name, buf, sizeof(change->name));
+			*tmp = '\0';
+		}
+		ast_log(LOG_DEBUG, "---- Queueing devicestate change for %s (name %s)\n", buf, change->name[0] ? change->name : "<none>");
 		/* queue the change */
 		strcpy(change->device, device);
 		AST_LIST_LOCK(&state_changes);
@@ -254,7 +261,7 @@
 		if (cur) {
 			/* we got an entry, so unlock the list while we process it */
 			AST_LIST_UNLOCK(&state_changes);
-			do_state_change(cur->device);
+			do_state_change(cur, NULL);
 			free(cur);
 			AST_LIST_LOCK(&state_changes);
 		} else {

Modified: team/oej/00-labarea/include/asterisk/devicestate.h
URL: http://svn.digium.com/view/asterisk/team/oej/00-labarea/include/asterisk/devicestate.h?rev=18407&r1=18406&r2=18407&view=diff
==============================================================================
--- team/oej/00-labarea/include/asterisk/devicestate.h (original)
+++ team/oej/00-labarea/include/asterisk/devicestate.h Fri Apr  7 15:42:23 2006
@@ -42,7 +42,7 @@
 /*! Device is ringing */
 #define AST_DEVICE_RINGING	6
 
-typedef int (*ast_devstate_cb_type)(const char *dev, int state, void *data);
+typedef int (*ast_devstate_cb_type)(const char *dev, int state, void *data, const char *name);
 
 /*! \brief Convert device state to text string for output 
  * \param devstate Current device state 

Modified: team/oej/00-labarea/include/asterisk/pbx.h
URL: http://svn.digium.com/view/asterisk/team/oej/00-labarea/include/asterisk/pbx.h?rev=18407&r1=18406&r2=18407&view=diff
==============================================================================
--- team/oej/00-labarea/include/asterisk/pbx.h (original)
+++ team/oej/00-labarea/include/asterisk/pbx.h Fri Apr  7 15:42:23 2006
@@ -61,7 +61,7 @@
 struct ast_sw;
 
 /*! \brief Typedef for devicestate and hint callbacks */
-typedef int (*ast_state_cb_type)(char *context, char* id, enum ast_extension_states state, void *data);
+typedef int (*ast_state_cb_type)(char *context, char* id, enum ast_extension_states state, void *data, const char *channel);
 
 /*! \brief Data structure associated with a custom dialplan function */
 struct ast_custom_function {
@@ -798,7 +798,7 @@
  */
 int ast_func_write(struct ast_channel *chan, char *function, const char *value);
 
-void ast_hint_state_changed(const char *device);
+void ast_hint_state_changed(const char *device, const char *channel);
 
 #if defined(__cplusplus) || defined(c_plusplus)
 }

Modified: team/oej/00-labarea/manager.c
URL: http://svn.digium.com/view/asterisk/team/oej/00-labarea/manager.c?rev=18407&r1=18406&r2=18407&view=diff
==============================================================================
--- team/oej/00-labarea/manager.c (original)
+++ team/oej/00-labarea/manager.c Fri Apr  7 15:42:23 2006
@@ -2028,7 +2028,7 @@
 	return 0;
 }
 
-static int manager_state_cb(char *context, char *exten, int state, void *data)
+static int manager_state_cb(char *context, char *exten, int state, void *data, char *channel)
 {
 	/* Notify managers of change */
 	manager_event(EVENT_FLAG_CALL, "ExtensionStatus", "Exten: %s\r\nContext: %s\r\nStatus: %d\r\n", exten, context, state);

Modified: team/oej/00-labarea/pbx.c
URL: http://svn.digium.com/view/asterisk/team/oej/00-labarea/pbx.c?rev=18407&r1=18406&r2=18407&view=diff
==============================================================================
--- team/oej/00-labarea/pbx.c (original)
+++ team/oej/00-labarea/pbx.c Fri Apr  7 15:42:23 2006
@@ -1749,7 +1749,7 @@
 	return ast_extension_state2(e);    		/* Check all devices in the hint */
 }
 
-void ast_hint_state_changed(const char *device)
+void ast_hint_state_changed(const char *device, const char *channel)
 {
 	struct ast_hint *hint;
 	struct ast_state_cb *cblist;
@@ -1758,6 +1758,8 @@
 	char *cur;
 	int state;
 
+	ast_log(LOG_DEBUG, "----- hint_state_changed: device %s channel %s\n", S_OR(device,"<none>"), S_OR(channel,"<none>"));
+
 	AST_LIST_LOCK(&hints);
 
 	AST_LIST_TRAVERSE(&hints, hint, list) {
@@ -1777,11 +1779,11 @@
 			
 			/* For general callbacks */
 			for (cblist = statecbs; cblist; cblist = cblist->next)
-				cblist->callback(hint->exten->parent->name, hint->exten->exten, state, cblist->data);
+				cblist->callback(hint->exten->parent->name, hint->exten->exten, state, cblist->data, channel);
 			
 			/* For extension callbacks */
 			for (cblist = hint->callbacks; cblist; cblist = cblist->next)
-				cblist->callback(hint->exten->parent->name, hint->exten->exten, state, cblist->data);
+				cblist->callback(hint->exten->parent->name, hint->exten->exten, state, cblist->data, channel);
 			
 			hint->laststate = state;
 			break;
@@ -1998,7 +2000,7 @@
 				/* Notify with -1 and remove all callbacks */
 				cbprev = cblist;	    
 				cblist = cblist->next;
-				cbprev->callback(hint->exten->parent->name, hint->exten->exten, AST_EXTENSION_DEACTIVATED, cbprev->data);
+				cbprev->callback(hint->exten->parent->name, hint->exten->exten, AST_EXTENSION_DEACTIVATED, cbprev->data, NULL);
 				free(cbprev);
 	    		}
 	    		hint->callbacks = NULL;
@@ -3576,7 +3578,7 @@
 			while (thiscb) {
 				prevcb = thiscb;	    
 				thiscb = thiscb->next;
-				prevcb->callback(this->context, this->exten, AST_EXTENSION_REMOVED, prevcb->data);
+				prevcb->callback(this->context, this->exten, AST_EXTENSION_REMOVED, prevcb->data, NULL);
 				free(prevcb);
 	    		}
 		} else {



More information about the asterisk-commits mailing list