[asterisk-commits] bweschke: branch bweschke/originate_w_jabber r95375 - in /team/bweschke/origi...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sun Dec 30 10:09:45 CST 2007


Author: bweschke
Date: Sun Dec 30 10:09:44 2007
New Revision: 95375

URL: http://svn.digium.com/view/asterisk?view=rev&rev=95375
Log:
 Building the same XMPP call progress signaling into app_dial that is already in the manager Originate action. This branch is now functional in initial unit testing as far as the original objective that it was setup for. 


Modified:
    team/bweschke/originate_w_jabber/apps/app_dial.c
    team/bweschke/originate_w_jabber/include/asterisk/channel.h
    team/bweschke/originate_w_jabber/main/channel.c

Modified: team/bweschke/originate_w_jabber/apps/app_dial.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/originate_w_jabber/apps/app_dial.c?view=diff&rev=95375&r1=95374&r2=95375
==============================================================================
--- team/bweschke/originate_w_jabber/apps/app_dial.c (original)
+++ team/bweschke/originate_w_jabber/apps/app_dial.c Sun Dec 30 10:09:44 2007
@@ -198,6 +198,11 @@
 "    W    - Allow the calling party to enable recording of the call by sending\n"
 "           the DTMF sequence defined for one-touch recording in features.conf.\n";
 
+int xmppsignaling = 0;
+const char *origjid;
+const char *xmppcid;
+const char *xmppclient;
+
 /* RetryDial App by Anthony Minessale II <anthmct at yahoo.com> Jan/2005 */
 static char *rapp = "RetryDial";
 static char *rsynopsis = "Place a call, retrying on failure allowing optional exit extension.";
@@ -307,6 +312,21 @@
 	struct dial_localuser *next;
 };
 
+static int send_xmpp_progress(const char *jabberclient, const char *origjid, const char *chandata, const char *xmppcid, const char *progressmsg)
+{
+        char *chatmsg = NULL;
+
+        if (!(chatmsg = ast_calloc(1, 512)))
+                return 0;
+
+        snprintf(chatmsg, 511, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<click2call><action>progress</action><callid>%s</callid><message>%s: %s</message></click2call>\n", xmppcid, chandata, progressmsg);
+
+        ast_aji_send_msg(jabberclient, origjid, chatmsg);
+
+        ast_free(chatmsg);
+
+        return 1;
+}
 
 static void hanguptree(struct dial_localuser *outgoing, struct ast_channel *exception)
 {
@@ -314,6 +334,9 @@
 	struct dial_localuser *oo;
 	while (outgoing) {
 		/* Hangup any existing lines we have open */
+		if (xmppsignaling)	
+			if (outgoing->chan && (outgoing->chan != exception) && !send_xmpp_progress(xmppclient, origjid, pbx_builtin_getvar_helper(outgoing->chan, "DIALEDPEERNUMBER"), xmppcid, "channel timeout/hangup"))
+				ast_log(LOG_WARNING, "Problem sending XMPP message");
 		if (outgoing->chan && (outgoing->chan != exception))
 			ast_hangup(outgoing->chan);
 		oo = outgoing;
@@ -566,6 +589,10 @@
 			if (f->frametype == AST_FRAME_CONTROL) {
 				switch(f->subclass) {
 				case AST_CONTROL_ANSWER:
+					if (xmppsignaling)	
+						if (!send_xmpp_progress(xmppclient, origjid, pbx_builtin_getvar_helper(winner, "DIALEDPEERNUMBER"), xmppcid, "channel answered"))
+							ast_log(LOG_WARNING, "Problem sending XMPP message");
+
 					/* This is our guy if someone answered. */
 					if (!peer) {
 						if (option_verbose > 2)
@@ -588,6 +615,9 @@
 					c->hangupcause = AST_CAUSE_NORMAL_CLEARING;
 					break;
 				case AST_CONTROL_BUSY:
+					if (xmppsignaling)	
+						if (!send_xmpp_progress(xmppclient, origjid, pbx_builtin_getvar_helper(winner, "DIALEDPEERNUMBER"), xmppcid, "channel busy"))
+							ast_log(LOG_WARNING, "Problem sending XMPP message");
 					if (option_verbose > 2)
 						ast_verbose(VERBOSE_PREFIX_3 "%s is busy\n", c->name);
 					in->hangupcause = c->hangupcause;
@@ -597,6 +627,9 @@
 					HANDLE_CAUSE(AST_CAUSE_BUSY, in);
 					break;
 				case AST_CONTROL_CONGESTION:
+					if (xmppsignaling)	
+						if (!send_xmpp_progress(xmppclient, origjid, pbx_builtin_getvar_helper(winner, "DIALEDPEERNUMBER"), xmppcid, "channel congestion"))
+							ast_log(LOG_WARNING, "Problem sending XMPP message");
 					if (option_verbose > 2)
 						ast_verbose(VERBOSE_PREFIX_3 "%s is circuit-busy\n", c->name);
 					in->hangupcause = c->hangupcause;
@@ -606,6 +639,9 @@
 					HANDLE_CAUSE(AST_CAUSE_CONGESTION, in);
 					break;
 				case AST_CONTROL_RINGING:
+					if (xmppsignaling)	
+						if (!send_xmpp_progress(xmppclient, origjid, pbx_builtin_getvar_helper(winner, "DIALEDPEERNUMBER"), xmppcid, "channel ringing"))
+							ast_log(LOG_WARNING, "Problem sending XMPP message");
 					if (option_verbose > 2)
 						ast_verbose(VERBOSE_PREFIX_3 "%s is ringing\n", c->name);
 					/* Setup early media if appropriate */
@@ -617,6 +653,9 @@
 					}
 					break;
 				case AST_CONTROL_PROGRESS:
+					if (xmppsignaling)	
+						if (!send_xmpp_progress(xmppclient, origjid, pbx_builtin_getvar_helper(winner, "DIALEDPEERNUMBER"), xmppcid, "channel progress"))
+							ast_log(LOG_WARNING, "Problem sending XMPP message");
 					if (option_verbose > 2)
 						ast_verbose (VERBOSE_PREFIX_3 "%s is making progress passing it to %s\n", c->name, in->name);
 					/* Setup early media if appropriate */
@@ -1092,7 +1131,21 @@
 	} else {
 		outbound_group = pbx_builtin_getvar_helper(chan, "OUTBOUND_GROUP");
 	}
-	    
+	
+        if (!ast_strlen_zero(pbx_builtin_getvar_helper(chan, "orig_jabberclient"))) {
+                if (option_debug > 2)
+                        ast_log(LOG_DEBUG, "This dial wants XMPP call progress signaling.\n");
+                if (!ast_strlen_zero(pbx_builtin_getvar_helper(chan, "orig_origjid")) && !ast_strlen_zero(pbx_builtin_getvar_helper(chan, "orig_callid"))) {
+                	xmppsignaling = 1;
+
+			xmppclient = pbx_builtin_getvar_helper(chan, "orig_jabberclient");
+			origjid = pbx_builtin_getvar_helper(chan, "orig_origjid");
+			xmppcid = pbx_builtin_getvar_helper(chan, "orig_callid");
+		} else {
+                        ast_log(LOG_WARNING, "XMPP call progress was requested on a request and dial, but not all required parameters are set for it.\n");
+                }
+	}
+    
 	ast_copy_flags(peerflags, &opts, OPT_DTMF_EXIT | OPT_GO_ON | OPT_ORIGINAL_CLID | OPT_CALLER_HANGUP | OPT_IGNORE_FORWARDING);
 	/* loop through the list of dial destinations */
 	rest = args.peers;
@@ -1272,6 +1325,9 @@
 			free(tmp);
 			continue;
 		} else {
+			if (xmppsignaling)	
+				if (!send_xmpp_progress(xmppclient, origjid, numsubst, xmppcid, "channel start"))
+					ast_log(LOG_WARNING, "Problem sending XMPP message");
 			senddialevent(chan, tmp->chan);
 			if (option_verbose > 2)
 				ast_verbose(VERBOSE_PREFIX_3 "Called %s\n", numsubst);
@@ -1698,8 +1754,14 @@
 				ast_channel_setoption(chan,
 					AST_OPTION_OPRMODE,&oprmode,sizeof(struct oprmode),0);
 			}
+			if (xmppsignaling)	
+				if (!send_xmpp_progress(xmppclient, origjid, numsubst, xmppcid, "bridging channels"))
+					ast_log(LOG_WARNING, "Problem sending XMPP message");
 			res = ast_bridge_call(chan,peer,&config);
 			time(&end_time);
+			if (xmppsignaling)	
+				if (!send_xmpp_progress(xmppclient, origjid, numsubst, xmppcid, "bridge complete"))
+					ast_log(LOG_WARNING, "Problem sending XMPP message");
 			{
 				char toast[80];
 				snprintf(toast, sizeof(toast), "%ld", (long)(end_time - answer_time));

Modified: team/bweschke/originate_w_jabber/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/team/bweschke/originate_w_jabber/include/asterisk/channel.h?view=diff&rev=95375&r1=95374&r2=95375
==============================================================================
--- team/bweschke/originate_w_jabber/include/asterisk/channel.h (original)
+++ team/bweschke/originate_w_jabber/include/asterisk/channel.h Sun Dec 30 10:09:44 2007
@@ -572,6 +572,9 @@
 	CHANNEL_MANAGER_RELOAD,
 };
 
+/*! \brief Send a jabber message */
+int ast_aji_send_msg(const char *jabberclient, const char *origjid, const char *msg);
+
 /*! \brief Create a channel datastore structure */
 struct ast_datastore *ast_channel_datastore_alloc(const struct ast_datastore_info *info, char *uid);
 

Modified: team/bweschke/originate_w_jabber/main/channel.c
URL: http://svn.digium.com/view/asterisk/team/bweschke/originate_w_jabber/main/channel.c?view=diff&rev=95375&r1=95374&r2=95375
==============================================================================
--- team/bweschke/originate_w_jabber/main/channel.c (original)
+++ team/bweschke/originate_w_jabber/main/channel.c Sun Dec 30 10:09:44 2007
@@ -3245,6 +3245,10 @@
 
 				/* Ignore these */
 				case AST_CONTROL_PROGRESS:
+					if (xmppsignaling)
+						if (!send_xmpp_progress(xmppclient, origjid, (char *)data, xmppcid, "channel progress"))
+							ast_log(LOG_WARNING, "Problem sending XMPP message");
+					break;
 				case AST_CONTROL_PROCEEDING:
 				case AST_CONTROL_HOLD:
 				case AST_CONTROL_UNHOLD:
@@ -4683,7 +4687,6 @@
 	return group;
 }
 
-
 void ast_install_aji_functions(int(*send_chat_ptr)(const char *, const char *, const char *))
 {
 	ast_aji_send_chat_ptr = send_chat_ptr;
@@ -4692,6 +4695,14 @@
 void ast_uninstall_aji_functions(void)
 {
 	ast_aji_send_chat_ptr = NULL;
+}
+
+int ast_aji_send_msg(const char *jabberclient, const char *origjid, const char *msg) 
+{
+	if (ast_aji_send_chat_ptr) 
+		ast_aji_send_chat_ptr(jabberclient, origjid, msg);
+
+	return 1;
 }
 
 static int (*ast_moh_start_ptr)(struct ast_channel *, const char *, const char *) = NULL;




More information about the asterisk-commits mailing list