[asterisk-commits] oej: branch oej/sip-callpickup-1.2 r73883 - in /team/oej/sip-callpickup-1.2: ...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Jul 8 07:52:28 CDT 2007


Author: oej
Date: Sun Jul  8 07:52:27 2007
New Revision: 73883

URL: http://svn.digium.com/view/asterisk?view=rev&rev=73883
Log:
We need the caller ID too to do a proper call pickup

Modified:
    team/oej/sip-callpickup-1.2/channel.c
    team/oej/sip-callpickup-1.2/channels/chan_sip.c
    team/oej/sip-callpickup-1.2/devicestate.c
    team/oej/sip-callpickup-1.2/include/asterisk/devicestate.h
    team/oej/sip-callpickup-1.2/include/asterisk/pbx.h
    team/oej/sip-callpickup-1.2/manager.c
    team/oej/sip-callpickup-1.2/pbx.c

Modified: team/oej/sip-callpickup-1.2/channel.c
URL: http://svn.digium.com/view/asterisk/team/oej/sip-callpickup-1.2/channel.c?view=diff&rev=73883&r1=73882&r2=73883
==============================================================================
--- team/oej/sip-callpickup-1.2/channel.c (original)
+++ team/oej/sip-callpickup-1.2/channel.c Sun Jul  8 07:52:27 2007
@@ -972,7 +972,7 @@
 	free(chan);
 	ast_mutex_unlock(&chlock);
 
-	ast_device_state_changed_literal(name, name);
+	ast_device_state_changed_literal(name, name, NULL);
 }
 
 int ast_channel_spy_add(struct ast_channel *chan, struct ast_channel_spy *spy)
@@ -3275,7 +3275,7 @@
 		return 0;
 
 	chan->_state = state;
-	ast_device_state_changed_literal(chan->name, chan->name);
+	ast_device_state_changed_literal(chan->name, chan->name, state == AST_STATE_RINGING ? &chan->cid : NULL);
 	manager_event(EVENT_FLAG_CALL,
 		      (oldstate == AST_STATE_DOWN && !ast_test_flag(chan, AST_FLAG_NOTNEW)) ? "Newchannel" : "Newstate",
 		      "Channel: %s\r\n"

Modified: team/oej/sip-callpickup-1.2/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/sip-callpickup-1.2/channels/chan_sip.c?view=diff&rev=73883&r1=73882&r2=73883
==============================================================================
--- team/oej/sip-callpickup-1.2/channels/chan_sip.c (original)
+++ team/oej/sip-callpickup-1.2/channels/chan_sip.c Sun Jul  8 07:52:27 2007
@@ -6576,7 +6576,7 @@
 /*! \brief  cb_extensionstate: Callback for the devicestate notification (SUBSCRIBE) support subsystem ---*/
 /*    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, const char *channel)
+static int cb_extensionstate(char *context, char* exten, int state, void *data, const char *channel, const struct ast_callerid *cid)
 {
 	struct sip_pvt *p = data;
 
@@ -6601,6 +6601,12 @@
 
 	if (option_verbose > 1)
 		ast_verbose(VERBOSE_PREFIX_1 "Extension Changed %s new state %s for Notify User %s (channel %s)\n", exten, ast_extension_state2str(state), p->username, channel ? channel : "<none>");
+	if (option_debug > 1 && state == AST_STATE_RINGING) {
+		if (cid)
+			ast_log(LOG_DEBUG, "=== Ringing state. Caller ID name %s, caller ID num %s\n", cid->cid_name, cid->cid_num);
+		else
+			ast_log(LOG_DEBUG, "=== Ringing state. No Caller ID data???????? \n");
+	}
 
 	ast_mutex_unlock(&p->lock);
 

Modified: team/oej/sip-callpickup-1.2/devicestate.c
URL: http://svn.digium.com/view/asterisk/team/oej/sip-callpickup-1.2/devicestate.c?view=diff&rev=73883&r1=73882&r2=73883
==============================================================================
--- team/oej/sip-callpickup-1.2/devicestate.c (original)
+++ team/oej/sip-callpickup-1.2/devicestate.c Sun Jul  8 07:52:27 2007
@@ -62,8 +62,9 @@
 
 struct state_change {
 	AST_LIST_ENTRY(state_change) list;
+	char channel[AST_CHANNEL_NAME];
+	const struct ast_callerid *cid;		/* Should we risk the fact that this can disappear during the call notification? */
 	char device[1];
-	char channel[1];
 };
 
 static AST_LIST_HEAD_STATIC(state_changes, state_change);
@@ -178,7 +179,7 @@
 }
 
 /*--- do_state_change: Notify callback watchers of change, and notify PBX core for hint updates */
-static void do_state_change(const char *device, const char *channel)
+static void do_state_change(const char *device, const char *channel, const struct ast_callerid *cid)
 {
 	int state;
 	struct devstate_cb *devcb;
@@ -192,10 +193,10 @@
 		devcb->callback(device, state, devcb->data);
 	AST_LIST_UNLOCK(&devstate_cbs);
 
-	ast_hint_state_changed(device, channel);
-}
-
-static int __ast_device_state_changed_literal(char *buf, const char *channel)
+	ast_hint_state_changed(device, channel, cid);
+}
+
+static int __ast_device_state_changed_literal(char *buf, const char *channel, const struct ast_callerid *cid)
 {
 	char *device;
 	struct state_change *change = NULL;
@@ -214,12 +215,13 @@
 	if (!change) {
 		/* we could not allocate a change struct, or */
 		/* there is no background thread, so process the change now */
-		do_state_change(device, channel);
+		do_state_change(device, channel, cid);
 	} else {
 		/* queue the change */
 		strcpy(change->device, device);
 		if (channel)
 			strcpy(change->channel, channel);
+		change->cid = cid;
 		AST_LIST_LOCK(&state_changes);
 		AST_LIST_INSERT_TAIL(&state_changes, change, list);
 		if (AST_LIST_FIRST(&state_changes) == change)
@@ -231,11 +233,11 @@
 	return 1;
 }
 
-int ast_device_state_changed_literal(const char *dev, const char *channel)
+int ast_device_state_changed_literal(const char *dev, const char *channel, const struct ast_callerid *cid)
 {
 	char *buf;
 	buf = ast_strdupa(dev);
-	return __ast_device_state_changed_literal(buf, channel);
+	return __ast_device_state_changed_literal(buf, channel, cid);
 }
 
 /*--- ast_device_state_changed: Accept change notification, add it to change queue */
@@ -247,7 +249,7 @@
 	va_start(ap, fmt);
 	vsnprintf(buf, sizeof(buf), fmt, ap);
 	va_end(ap);
-	return __ast_device_state_changed_literal(buf, NULL);
+	return __ast_device_state_changed_literal(buf, NULL, NULL);
 }
 
 /*--- do_devstate_changes: Go through the dev state change queue and update changes in the dev state thread */
@@ -263,7 +265,7 @@
 			/* we got an entry, so unlock the list while we process it */
 			AST_LIST_UNLOCK(&state_changes);
 			ast_log(LOG_DEBUG, "=== Unqueueing device state change for %s (channel %s)\n", cur->device, cur->channel ? cur->channel : "<none>");
-			do_state_change(cur->device, cur->channel);
+			do_state_change(cur->device, cur->channel, cur->cid);
 			free(cur);
 			AST_LIST_LOCK(&state_changes);
 		} else {

Modified: team/oej/sip-callpickup-1.2/include/asterisk/devicestate.h
URL: http://svn.digium.com/view/asterisk/team/oej/sip-callpickup-1.2/include/asterisk/devicestate.h?view=diff&rev=73883&r1=73882&r2=73883
==============================================================================
--- team/oej/sip-callpickup-1.2/include/asterisk/devicestate.h (original)
+++ team/oej/sip-callpickup-1.2/include/asterisk/devicestate.h Sun Jul  8 07:52:27 2007
@@ -88,7 +88,7 @@
  * on channel-related events.
  * Returns 0 on success, -1 on failure
  */
-int ast_device_state_changed_literal(const char *device, const char *channel);
+int ast_device_state_changed_literal(const char *device, const char *channel, const struct ast_callerid *cid);
 
 /*! \brief Registers a device state change callback 
  * \param callback Callback

Modified: team/oej/sip-callpickup-1.2/include/asterisk/pbx.h
URL: http://svn.digium.com/view/asterisk/team/oej/sip-callpickup-1.2/include/asterisk/pbx.h?view=diff&rev=73883&r1=73882&r2=73883
==============================================================================
--- team/oej/sip-callpickup-1.2/include/asterisk/pbx.h (original)
+++ team/oej/sip-callpickup-1.2/include/asterisk/pbx.h Sun Jul  8 07:52:27 2007
@@ -80,7 +80,7 @@
 struct ast_ignorepat;
 struct ast_sw;
 
-typedef int (*ast_state_cb_type)(char *context, char* id, enum ast_extension_states state, void *data, const char *channel);
+typedef int (*ast_state_cb_type)(char *context, char* id, enum ast_extension_states state, void *data, const char *channel, const struct ast_callerid *cid);
 
 /*! Data structure associated with a custom function */
 struct ast_custom_function {
@@ -659,7 +659,7 @@
  */
 void ast_func_write(struct ast_channel *chan, const char *in, const char *value);
 
-void ast_hint_state_changed(const char *device, const char *channel);
+void ast_hint_state_changed(const char *device, const char *channel, const struct ast_callerid *cid);
 
 #if defined(__cplusplus) || defined(c_plusplus)
 }

Modified: team/oej/sip-callpickup-1.2/manager.c
URL: http://svn.digium.com/view/asterisk/team/oej/sip-callpickup-1.2/manager.c?view=diff&rev=73883&r1=73882&r2=73883
==============================================================================
--- team/oej/sip-callpickup-1.2/manager.c (original)
+++ team/oej/sip-callpickup-1.2/manager.c Sun Jul  8 07:52:27 2007
@@ -1573,7 +1573,7 @@
 	return 0;
 }
 
-static int manager_state_cb(char *context, char *exten, int state, void *data, const char *channel)
+static int manager_state_cb(char *context, char *exten, int state, void *data, const char *channel, const struct ast_callerid *cid)
 {
 	/* 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/sip-callpickup-1.2/pbx.c
URL: http://svn.digium.com/view/asterisk/team/oej/sip-callpickup-1.2/pbx.c?view=diff&rev=73883&r1=73882&r2=73883
==============================================================================
--- team/oej/sip-callpickup-1.2/pbx.c (original)
+++ team/oej/sip-callpickup-1.2/pbx.c Sun Jul  8 07:52:27 2007
@@ -1903,7 +1903,7 @@
 	return ast_extension_state2(e);    		/* Check all devices in the hint */
 }
 
-void ast_hint_state_changed(const char *device, const char *channel)
+void ast_hint_state_changed(const char *device, const char *channel, const struct ast_callerid *cid)
 {
 	struct ast_hint *hint;
 	struct ast_state_cb *cblist;
@@ -1931,11 +1931,11 @@
 			
 			/* For general callbacks */
 			for (cblist = statecbs; cblist; cblist = cblist->next)
-				cblist->callback(hint->exten->parent->name, hint->exten->exten, state, cblist->data, channel);
+				cblist->callback(hint->exten->parent->name, hint->exten->exten, state, cblist->data, channel, cid);
 			
 			/* For extension callbacks */
 			for (cblist = hint->callbacks; cblist; cblist = cblist->next)
-				cblist->callback(hint->exten->parent->name, hint->exten->exten, state, cblist->data, channel);
+				cblist->callback(hint->exten->parent->name, hint->exten->exten, state, cblist->data, channel, cid);
 			
 			hint->laststate = state;
 			break;
@@ -2176,7 +2176,7 @@
 				/* Notify with -1 and remove all callbacks */
 				cbprev = cblist;	    
 				cblist = cblist->next;
-				cbprev->callback(list->exten->parent->name, list->exten->exten, AST_EXTENSION_DEACTIVATED, cbprev->data, NULL);
+				cbprev->callback(list->exten->parent->name, list->exten->exten, AST_EXTENSION_DEACTIVATED, cbprev->data, NULL, NULL);
 				free(cbprev);
 	    		}
 	    		list->callbacks = NULL;
@@ -3799,7 +3799,7 @@
 			while (thiscb) {
 				prevcb = thiscb;	    
 				thiscb = thiscb->next;
-				prevcb->callback(this->context, this->exten, AST_EXTENSION_REMOVED, prevcb->data, NULL);
+				prevcb->callback(this->context, this->exten, AST_EXTENSION_REMOVED, prevcb->data, NULL, NULL);
 				free(prevcb);
 	    		}
 		} else {




More information about the asterisk-commits mailing list