[asterisk-commits] phsultan: branch phsultan/jabberreceive r163093 - in /team/phsultan/jabberrec...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Dec 11 11:02:36 CST 2008


Author: phsultan
Date: Thu Dec 11 11:02:36 2008
New Revision: 163093

URL: http://svn.digium.com/view/asterisk?view=rev&rev=163093
Log:
Bring SendText to chan_jingle too. Return values from functions, and post a debug message rather than a log.

Modified:
    team/phsultan/jabberreceive/channels/chan_gtalk.c
    team/phsultan/jabberreceive/channels/chan_jingle.c
    team/phsultan/jabberreceive/res/res_jabber.c

Modified: team/phsultan/jabberreceive/channels/chan_gtalk.c
URL: http://svn.digium.com/view/asterisk/team/phsultan/jabberreceive/channels/chan_gtalk.c?view=diff&rev=163093&r1=163092&r2=163093
==============================================================================
--- team/phsultan/jabberreceive/channels/chan_gtalk.c (original)
+++ team/phsultan/jabberreceive/channels/chan_gtalk.c Thu Dec 11 11:02:36 2008
@@ -1465,6 +1465,7 @@
 
 static int gtalk_sendtext(struct ast_channel *chan, const char *text)
 {
+	int res = 0;
 	struct aji_client *client = NULL;
 	struct gtalk_pvt *p = chan->tech_pvt;
 	
@@ -1479,7 +1480,7 @@
 	}
 	client = p->parent->connection;
 	ast_aji_send_chat(client, p->them, text);
-	return 0;
+	return res;
 }
 
 static int gtalk_digit_begin(struct ast_channel *chan, char digit)

Modified: team/phsultan/jabberreceive/channels/chan_jingle.c
URL: http://svn.digium.com/view/asterisk/team/phsultan/jabberreceive/channels/chan_jingle.c?view=diff&rev=163093&r1=163092&r2=163093
==============================================================================
--- team/phsultan/jabberreceive/channels/chan_jingle.c (original)
+++ team/phsultan/jabberreceive/channels/chan_jingle.c Thu Dec 11 11:02:36 2008
@@ -169,6 +169,7 @@
 
 /* Forward declarations */
 static struct ast_channel *jingle_request(const char *type, int format, void *data, int *cause);
+static int jingle_sendtext(struct ast_channel *ast, const char *text);
 static int jingle_digit_begin(struct ast_channel *ast, char digit);
 static int jingle_digit_end(struct ast_channel *ast, char digit, unsigned int duration);
 static int jingle_call(struct ast_channel *ast, char *dest, int timeout);
@@ -195,6 +196,7 @@
 	.description = "Jingle Channel Driver",
 	.capabilities = AST_FORMAT_AUDIO_MASK,
 	.requester = jingle_request,
+	.send_text = jingle_sendtext,
 	.send_digit_begin = jingle_digit_begin,
 	.send_digit_end = jingle_digit_end,
 	.bridge = ast_rtp_bridge,
@@ -1279,6 +1281,26 @@
 
 	return res;
 }
+
+static int jingle_sendtext(struct ast_channel *chan, const char *text)
+{
+	int res = 0;
+	struct aji_client *client = NULL;
+	struct jingle_pvt *p = chan->tech_pvt;
+
+
+	if (!p->parent) {
+		ast_log(LOG_ERROR, "Parent channel not found\n");
+		return -1;
+	}
+	if (!p->parent->connection) {
+		ast_log(LOG_ERROR, "XMPP client not found\n");
+		return -1; 
+	}
+	client = p->parent->connection;
+	ast_aji_send_chat(client, p->them, text);
+	return res;
+}               
 
 static int jingle_digit(struct ast_channel *ast, char digit, unsigned int duration)
 {

Modified: team/phsultan/jabberreceive/res/res_jabber.c
URL: http://svn.digium.com/view/asterisk/team/phsultan/jabberreceive/res/res_jabber.c?view=diff&rev=163093&r1=163092&r2=163093
==============================================================================
--- team/phsultan/jabberreceive/res/res_jabber.c (original)
+++ team/phsultan/jabberreceive/res/res_jabber.c Thu Dec 11 11:02:36 2008
@@ -779,7 +779,7 @@
  /*!
  * \brief Dial plan function to receive a message.
  * \param channel, and data, data is sender, variable.
- * \return received text or NULL.
+ * \return 1 on success, -1 on failure.
  */
 static int aji_recv_exec(struct ast_channel *chan, void *data)
 {
@@ -814,19 +814,21 @@
 			to *= 1000;
 		} else {
 			ast_log(LOG_WARNING, "Invalid timeout specified: '%s'\n", args.timeout);
-		}
-	}
-
-	ast_log(LOG_NOTICE, "Waiting for an XMPP message from %s\n", args.sender);
+			return -1;
+		}
+	}
+
+	ast_debug(3, "Waiting for an XMPP message from %s\n", args.sender);
 	buf = ast_recvtext(chan, to);
 	/* return if we timed out */
-	if (!buf)
+	if (!buf) {
 		return -1;
+	}
 	ast_copy_string(message, buf, sizeof(message));
 	variable = ast_skip_blanks(args.variable);
 	ast_trim_blanks(variable);
 	pbx_builtin_setvar_helper(chan, variable, message);
-	return 0;
+	return 1;
 }
 
 /*!
@@ -1590,7 +1592,6 @@
 				ast_queue_frame(chan, &f);
 			}
 			ast_channel_unlock(chan);
-			ast_debug(3, "chan was %s \n", chan ? "FOUND" : "NOT FOUND");
 			if (chan) {
 				break;
 			}




More information about the asterisk-commits mailing list