From 54c0d6f7c41d3bc882ff339af8c01545e03606a9 Mon Sep 17 00:00:00 2001
From: Moises Silva <moy@sangoma.com>
Date: Wed, 19 Jan 2011 11:38:27 -0500
Subject: [PATCH 1/8] freetdm: workaround for Visual C++ 9.0 failing to compile
 ftdm feature macros

---
 libs/freetdm/src/include/private/ftdm_core.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libs/freetdm/src/include/private/ftdm_core.h b/libs/freetdm/src/include/private/ftdm_core.h
index fbe42d33da..7cf0934f57 100644
--- a/libs/freetdm/src/include/private/ftdm_core.h
+++ b/libs/freetdm/src/include/private/ftdm_core.h
@@ -132,8 +132,8 @@ extern "C" {
 
 
 #define ftdm_channel_test_feature(obj, flag) ((obj)->features & flag)
-#define ftdm_channel_set_feature(obj, flag) (obj)->features |= (flag)
-#define ftdm_channel_clear_feature(obj, flag) (obj)->features &= ~(flag)
+#define ftdm_channel_set_feature(obj, flag) (obj)->features = (ftdm_channel_feature_t)((obj)->features | flag)
+#define ftdm_channel_clear_feature(obj, flag) (obj)->features = (ftdm_channel_feature_t)((obj)->features & ( ~(flag) ))
 #define ftdm_channel_set_member_locked(obj, _m, _v) ftdm_mutex_lock(obj->mutex); obj->_m = _v; ftdm_mutex_unlock(obj->mutex)
 
 /*!

From bd39ad2269d302748fd55e96431b221ba6c7be6b Mon Sep 17 00:00:00 2001
From: Brian West <brian@freeswitch.org>
Date: Wed, 19 Jan 2011 11:33:01 -0600
Subject: [PATCH 2/8] FS-2995: sigh... mr collins you said you fixed this

---
 conf/lang/en/dir/sounds.xml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/conf/lang/en/dir/sounds.xml b/conf/lang/en/dir/sounds.xml
index 2bdc1492ec..15ecec304a 100644
--- a/conf/lang/en/dir/sounds.xml
+++ b/conf/lang/en/dir/sounds.xml
@@ -16,7 +16,7 @@
 			<match>
 				<action function="play-file" data="directory/dir-to_search_by.wav"/>
 				<action function="play-file" data="directory/dir-first_name.wav"/>
-				<action function="play-file" data="directory/dir-press.wav"/>
+				<action function="play-file" data="voicemail/vm-press.wav"/>
 				<action function="say" data="$2" method="pronounced" type="name_spelled"/>
 			</match>
 		</input>
@@ -24,7 +24,7 @@
 			<match>
 				<action function="play-file" data="directory/dir-to_search_by.wav"/>
 				<action function="play-file" data="directory/dir-last_name.wav"/>
-				<action function="play-file" data="directory/dir-press.wav"/>
+				<action function="play-file" data="voicemail/vm-press.wav"/>
 				<action function="say" data="$2" method="pronounced" type="name_spelled"/>
 			</match>
 		</input>

From afc027473f7fc8a3ec233fb1848f728fc94f56b6 Mon Sep 17 00:00:00 2001
From: Brian West <brian@freeswitch.org>
Date: Wed, 19 Jan 2011 11:35:48 -0600
Subject: [PATCH 3/8] FS-2989: Places ;fs_path= within the contact string <...>
 when using NDLB-connectile-dysfunction-2.0, instead of just appending to the
 end of the contact string.

---
 src/mod/endpoints/mod_sofia/sofia_reg.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/src/mod/endpoints/mod_sofia/sofia_reg.c b/src/mod/endpoints/mod_sofia/sofia_reg.c
index f644ff772b..631cbdb14b 100644
--- a/src/mod/endpoints/mod_sofia/sofia_reg.c
+++ b/src/mod/endpoints/mod_sofia/sofia_reg.c
@@ -1139,7 +1139,13 @@ uint8_t sofia_reg_handle_register(nua_t *nua, sofia_profile_t *profile, nua_hand
 					switch_url_encode(my_contact_str, path_encoded + 20, path_encoded_len - 20);
 					reg_desc = "Registered(AUTO-NAT-2.0)";
 					exptime = 30;
-					switch_snprintf(contact_str + strlen(contact_str), sizeof(contact_str) - strlen(contact_str), "%s", path_encoded);
+
+					/* place fs_path (the encoded path) inside the <...> of the contact string, if possible */
+					if (contact_str[strlen(contact_str) - 1] == '>') {
+						switch_snprintf(contact_str + strlen(contact_str) - 1, sizeof(contact_str) - strlen(contact_str) + 1, "%s>", path_encoded);
+					} else {
+						switch_snprintf(contact_str + strlen(contact_str), sizeof(contact_str) - strlen(contact_str), "%s", path_encoded);
+					}
 					free(path_encoded);
 				} else {
 					if (*received_data && sofia_test_pflag(profile, PFLAG_RECIEVED_IN_NAT_REG_CONTACT)) {

From ea9021a24a6ce0606a2c12f3cab8f2bf0fc12db3 Mon Sep 17 00:00:00 2001
From: Brian West <brian@freeswitch.org>
Date: Wed, 19 Jan 2011 11:38:36 -0600
Subject: [PATCH 4/8] FS-2998: prefix-a-leg not respected for url submission

---
 src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c b/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c
index a439ab8203..78d97ce259 100644
--- a/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c
+++ b/src/mod/xml_int/mod_xml_cdr/mod_xml_cdr.c
@@ -340,7 +340,7 @@ static switch_status_t my_on_reporting(switch_core_session_t *session)
 				switch_yield(globals.delay * 1000000);
 			}
 
-			destUrl = switch_mprintf("%s?uuid=%s", globals.urls[globals.url_index], switch_core_session_get_uuid(session));
+			destUrl = switch_mprintf("%s?uuid=%s%s", globals.urls[globals.url_index], a_prefix, switch_core_session_get_uuid(session));
 			curl_easy_setopt(curl_handle, CURLOPT_URL, destUrl);
 
 			if (!strncasecmp(destUrl, "https", 5)) {

From 1fcffcfbc3fe6c2f21e5767fc760fdbc0c89aa68 Mon Sep 17 00:00:00 2001
From: David Yat Sin <dyatsin@sangoma.com>
Date: Wed, 19 Jan 2011 14:18:23 -0500
Subject: [PATCH 5/8] added documentation

---
 libs/freetdm/docs/io_modules.txt | 13 +++++++++++++
 1 file changed, 13 insertions(+)
 create mode 100644 libs/freetdm/docs/io_modules.txt

diff --git a/libs/freetdm/docs/io_modules.txt b/libs/freetdm/docs/io_modules.txt
new file mode 100644
index 0000000000..a164bbb249
--- /dev/null
+++ b/libs/freetdm/docs/io_modules.txt
@@ -0,0 +1,13 @@
+Last Updated: Jan 19, 2011
+
+== BACKGROUND ==
+
+The IO module provides an abstracted IO interface to FreeTDM. 
+
+== SHUTDOWN ==
+Upon global shutdown, for each channel FIO_CLOSE_FUNCTION will be called. 
+When FIO_CLOSE_FUNCTION is called, all waiters on this channel shall be signalled.
+If FIO_WAIT_FUNCTION is called on a function that has already been closed, this function shall return FTDM_TIMEOUT without blocking.
+FIO_CHANNEL_DESTROY will eventually be called, and IO module is responsible for clearing all internal states and free allocated memory upon channel destroy. 
+
+

From 6fd468043b284ee30085cf86be16ba99725d6462 Mon Sep 17 00:00:00 2001
From: David Yat Sin <dyatsin@sangoma.com>
Date: Wed, 19 Jan 2011 14:46:28 -0500
Subject: [PATCH 6/8] freetdm: fix for closing d-channel when channel is
 already closed by freetdm core

---
 libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c
index f2afd1cf9c..e7053c1d43 100644
--- a/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c
+++ b/libs/freetdm/src/ftmod/ftmod_sangoma_isdn/ftmod_sangoma_isdn.c
@@ -394,8 +394,7 @@ static void *ftdm_sangoma_isdn_dchan_run(ftdm_thread_t *me, void *obj)
 			default:
 				ftdm_log_chan_msg(dchan, FTDM_LOG_CRIT, "Unhandled IO event\n");
 		}
-	}
-	ftdm_channel_close(&dchan);
+	}	
 	return NULL;
 }
 

From 0fdc272b25c7918359ae5b0f27277ff1926bcb75 Mon Sep 17 00:00:00 2001
From: Moises Silva <moy@sangoma.com>
Date: Wed, 19 Jan 2011 15:53:01 -0500
Subject: [PATCH 7/8] freetdm: open wanpipe devices as non-exclusive if
 possible

---
 libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c b/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c
index e2b08255ac..3b384cdf32 100644
--- a/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c
+++ b/libs/freetdm/src/ftmod/ftmod_wanpipe/ftmod_wanpipe.c
@@ -239,7 +239,11 @@ static unsigned wp_open_range(ftdm_span_t *span, unsigned spanno, unsigned start
 			ftdm_log(FTDM_LOG_ERROR, "span %d channel %d cannot be configured as smg_prid_nfas, you need to compile freetdm with newer libsangoma\n", spanno, x);
 #endif
 		} else {
+#ifdef LIBSANGOMA_VERSION
+			sockfd = __tdmv_api_open_span_chan(spanno, x);
+#else
 			sockfd = tdmv_api_open_span_chan(spanno, x);
+#endif
 		}
 
 		if (sockfd == FTDM_INVALID_SOCKET) {

From 9bb344783d39da5dc3e57d48b59f551ba9a2fa4d Mon Sep 17 00:00:00 2001
From: Moises Silva <moy@sangoma.com>
Date: Wed, 19 Jan 2011 16:25:33 -0500
Subject: [PATCH 8/8] freetdm: remove collision event string

---
 libs/freetdm/src/include/freetdm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libs/freetdm/src/include/freetdm.h b/libs/freetdm/src/include/freetdm.h
index 8d67df3edc..aed40541a3 100644
--- a/libs/freetdm/src/include/freetdm.h
+++ b/libs/freetdm/src/include/freetdm.h
@@ -430,7 +430,7 @@ typedef enum {
 } ftdm_signal_event_t;
 #define SIGNAL_STRINGS "START", "STOP", "RELEASED", "UP", "FLASH", "PROCEED", "RINGING", "PROGRESS", \
 		"PROGRESS_MEDIA", "ALARM_TRAP", "ALARM_CLEAR", \
-		"COLLECTED_DIGIT", "ADD_CALL", "RESTART", "SIGSTATUS_CHANGED", "COLLISION", "FACILITY", \
+		"COLLECTED_DIGIT", "ADD_CALL", "RESTART", "SIGSTATUS_CHANGED", "FACILITY", \
 		"TRACE", "TRACE_RAW", "INDICATION_COMPLETED", "DIALING", "INVALID"
 /*! \brief Move from string to ftdm_signal_event_t and viceversa */
 FTDM_STR2ENUM_P(ftdm_str2ftdm_signal_event, ftdm_signal_event2str, ftdm_signal_event_t)