[asterisk-commits] mjordan: trunk r392607 - /trunk/res/res_fax.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Sat Jun 22 17:42:35 CDT 2013


Author: mjordan
Date: Sat Jun 22 17:42:34 2013
New Revision: 392607

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=392607
Log:
Properly extract channel variables for the SendFAX/ReceiveFAX Stasis messages

By the time something extracts the pointers from ast_json_pack, the channels
will already be disposed of. This patch properly pulls the information out of
the variables and packs them into the JSON blob.

Modified:
    trunk/res/res_fax.c

Modified: trunk/res/res_fax.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/res_fax.c?view=diff&rev=392607&r1=392606&r2=392607
==============================================================================
--- trunk/res/res_fax.c (original)
+++ trunk/res/res_fax.c Sat Jun 22 17:42:34 2013
@@ -1783,18 +1783,33 @@
 		SCOPED_CHANNELLOCK(lock, chan);
 
 		remote_station_id = S_OR(pbx_builtin_getvar_helper(chan, "REMOTESTATIONID"), "");
+		if (!ast_strlen_zero(remote_station_id)) {
+			remote_station_id = ast_strdupa(remote_station_id);
+		}
 		local_station_id = S_OR(pbx_builtin_getvar_helper(chan, "LOCALSTATIONID"), "");
+		if (!ast_strlen_zero(local_station_id)) {
+			local_station_id = ast_strdupa(local_station_id);
+		}
 		fax_pages = S_OR(pbx_builtin_getvar_helper(chan, "FAXPAGES"), "");
+		if (!ast_strlen_zero(fax_pages)) {
+			fax_pages = ast_strdupa(fax_pages);
+		}
 		fax_resolution = S_OR(pbx_builtin_getvar_helper(chan, "FAXRESOLUTION"), "");
+		if (!ast_strlen_zero(fax_resolution)) {
+			fax_resolution = ast_strdupa(fax_resolution);
+		}
 		fax_bitrate = S_OR(pbx_builtin_getvar_helper(chan, "FAXBITRATE"), "");
+		if (!ast_strlen_zero(fax_bitrate)) {
+			fax_bitrate = ast_strdupa(fax_bitrate);
+		}
 
 		json_object = ast_json_pack("{s: s, s: s, s: s, s: s, s: s, s: s, s: O}",
 				"type", "receive",
-				"remote_station_id", remote_station_id,
-				"local_station_id", local_station_id,
-				"fax_pages", fax_pages,
-				"fax_resolution", fax_resolution,
-				"fax_bitrate", fax_bitrate,
+				"remote_station_id", S_OR(remote_station_id, ""),
+				"local_station_id", S_OR(local_station_id, ""),
+				"fax_pages", S_OR(fax_pages, ""),
+				"fax_resolution", S_OR(fax_resolution, ""),
+				"fax_bitrate", S_OR(fax_bitrate, ""),
 				"filenames", json_array);
 		if (!json_object) {
 			return -1;
@@ -2274,18 +2289,33 @@
 		SCOPED_CHANNELLOCK(lock, chan);
 
 		remote_station_id = S_OR(pbx_builtin_getvar_helper(chan, "REMOTESTATIONID"), "");
+		if (!ast_strlen_zero(remote_station_id)) {
+			remote_station_id = ast_strdupa(remote_station_id);
+		}
 		local_station_id = S_OR(pbx_builtin_getvar_helper(chan, "LOCALSTATIONID"), "");
+		if (!ast_strlen_zero(local_station_id)) {
+			local_station_id = ast_strdupa(local_station_id);
+		}
 		fax_pages = S_OR(pbx_builtin_getvar_helper(chan, "FAXPAGES"), "");
+		if (!ast_strlen_zero(fax_pages)) {
+			fax_pages = ast_strdupa(fax_pages);
+		}
 		fax_resolution = S_OR(pbx_builtin_getvar_helper(chan, "FAXRESOLUTION"), "");
+		if (!ast_strlen_zero(fax_resolution)) {
+			fax_resolution = ast_strdupa(fax_resolution);
+		}
 		fax_bitrate = S_OR(pbx_builtin_getvar_helper(chan, "FAXBITRATE"), "");
+		if (!ast_strlen_zero(fax_bitrate)) {
+			fax_bitrate = ast_strdupa(fax_bitrate);
+		}
 
 		json_obj = ast_json_pack("{s: s, s: s, s: s, s: s, s: s, s: s, s: o}",
 				"type", "send"
-				"remote_station_id", remote_station_id,
-				"local_station_id", local_station_id,
-				"fax_pages", fax_pages,
-				"fax_resolution", fax_resolution,
-				"fax_bitrate", fax_bitrate,
+				"remote_station_id", S_OR(remote_station_id, ""),
+				"local_station_id", S_OR(local_station_id, ""),
+				"fax_pages", S_OR(fax_pages, ""),
+				"fax_resolution", S_OR(fax_resolution, ""),
+				"fax_bitrate", S_OR(fax_bitrate, ""),
 				"filenames", json_filenames);
 		if (!json_obj) {
 			return -1;




More information about the asterisk-commits mailing list