rpms/asterisk/F-8 asterisk-1.4.16-alternate-extensions.patch, NONE, 1.1 asterisk-1.4.16-alternate-voicemail.patch, NONE, 1.1 asterisk-1.4.16-appconference.patch, NONE, 1.1 asterisk-1.4.16-autoconf.patch, NONE, 1.1 asterisk-1.4.16-chanmobile.patch, NONE, 1.1 asterisk-1.4.16-initscripts.patch, NONE, 1.1 asterisk-1.4.16-libcap.patch, NONE, 1.1 asterisk-1.4.16-optimization.patch, NONE, 1.1 asterisk-1.4.16-spandspfax.patch, NONE, 1.1 asterisk-1.4.16-system-imap.patch, NONE, 1.1 .cvsignore, 1.2, 1.3 asterisk.spec, 1.2, 1.3 sources, 1.2, 1.3 asterisk-1.4.14-alternate-extensions.patch, 1.1, NONE asterisk-1.4.14-alternate-voicemail.patch, 1.1, NONE asterisk-1.4.14-appconference.patch, 1.1, NONE asterisk-1.4.14-autoconf.patch, 1.1, NONE asterisk-1.4.14-chanmobile.patch, 1.1, NONE asterisk-1.4.14-initscripts.patch, 1.1, NONE asterisk-1.4.14-libcap.patch, 1.1, NONE asterisk-1.4.14-optimization.patch, 1.1, NONE asterisk-1.4.14-spandspfax.patch, 1.1, NONE asterisk-1.4.14-system-imap.patch, 1.1, NONE

Jeffrey C. Ollie (jcollie) fedora-extras-commits at redhat.com
Wed Dec 19 05:33:27 UTC 2007


Author: jcollie

Update of /cvs/pkgs/rpms/asterisk/F-8
In directory cvs-int.fedora.redhat.com:/tmp/cvs-serv1076

Modified Files:
	.cvsignore asterisk.spec sources 
Added Files:
	asterisk-1.4.16-alternate-extensions.patch 
	asterisk-1.4.16-alternate-voicemail.patch 
	asterisk-1.4.16-appconference.patch 
	asterisk-1.4.16-autoconf.patch 
	asterisk-1.4.16-chanmobile.patch 
	asterisk-1.4.16-initscripts.patch asterisk-1.4.16-libcap.patch 
	asterisk-1.4.16-optimization.patch 
	asterisk-1.4.16-spandspfax.patch 
	asterisk-1.4.16-system-imap.patch 
Removed Files:
	asterisk-1.4.14-alternate-extensions.patch 
	asterisk-1.4.14-alternate-voicemail.patch 
	asterisk-1.4.14-appconference.patch 
	asterisk-1.4.14-autoconf.patch 
	asterisk-1.4.14-chanmobile.patch 
	asterisk-1.4.14-initscripts.patch asterisk-1.4.14-libcap.patch 
	asterisk-1.4.14-optimization.patch 
	asterisk-1.4.14-spandspfax.patch 
	asterisk-1.4.14-system-imap.patch 
Log Message:
Update to 1.4.16

asterisk-1.4.16-alternate-extensions.patch:

--- NEW FILE asterisk-1.4.16-alternate-extensions.patch ---
>From bf6bbce50cf7486e1627605c7808c5a74acb3c45 Mon Sep 17 00:00:00 2001
From: Jeffrey C. Ollie <jcollie at pc21224.campus.dmacc.edu>
Date: Thu, 8 Nov 2007 16:32:56 -0600
Subject: [PATCH] Allow alternate extensions to be specified in users.conf

---
 pbx/pbx_config.c |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/pbx/pbx_config.c b/pbx/pbx_config.c
index 6d0ec2e..969c77a 100644
--- a/pbx/pbx_config.c
+++ b/pbx/pbx_config.c
@@ -2357,11 +2357,14 @@ static void pbx_load_users(void)
 {
 	struct ast_config *cfg;
 	char *cat, *chan;
+	char *ext;
 	const char *zapchan;
 	const char *hasexten;
+	const char *altexts;
 	char tmp[256];
 	char iface[256];
 	char zapcopy[256];
+	char altcopy[256];
 	char *c;
 	int len;
 	int hasvoicemail;
@@ -2441,6 +2444,17 @@ static void pbx_load_users(void)
 			} else {
 				ast_add_extension2(con, 0, cat, 1, NULL, NULL, "Dial", strdup("${HINT}"), ast_free, registrar);
 			}
+			altexts = ast_variable_retrieve(cfg, cat, "alternateexts");
+			if (!ast_strlen_zero(altexts)) {
+				snprintf(tmp, sizeof(tmp), "%s|1", cat);
+				ast_copy_string(altcopy, altexts, sizeof(altcopy));
+				c = altcopy;
+				ext = strsep(&c, ",");
+				while (ext) {
+					ast_add_extension2(con, 0, ext, 1, NULL, NULL, "Goto", strdup(tmp), ast_free, registrar);
+					ext = strsep(&c, ",");
+				}
+			}
 		}
 	}
 	ast_config_destroy(cfg);
-- 
1.5.3.6


asterisk-1.4.16-alternate-voicemail.patch:

--- NEW FILE asterisk-1.4.16-alternate-voicemail.patch ---
>From f8476ffc82e9e320890dd486572621c29e8c621d Mon Sep 17 00:00:00 2001
From: Jeffrey C. Ollie <jcollie at pc21224.campus.dmacc.edu>
Date: Thu, 8 Nov 2007 15:52:36 -0600
Subject: [PATCH] Modify modules.conf so that different voicemail modules can be loaded.

---
 configs/modules.conf.sample |   27 +++++++++++++++++++++++++++
 1 files changed, 27 insertions(+), 0 deletions(-)

diff --git a/configs/modules.conf.sample b/configs/modules.conf.sample
index 0c92e1d..43c3f48 100644
--- a/configs/modules.conf.sample
+++ b/configs/modules.conf.sample
@@ -36,3 +36,30 @@ load => res_musiconhold.so
 ;
 noload => chan_alsa.so
 ;noload => chan_oss.so
+
+;
+; Voicemail storage selection
+;
+; Comment out the "noload" lines for the voicemail
+; storage system that you want.  Leave the ones that
+; you don't want uncommented.
+;
+
+;
+; Voicemail with IMAP storage
+;
+noload => app_directory_imap.so
+noload => app_voicemail_imap.so
+
+;
+; Voicemail with ODBC storage
+;
+noload => app_directory_odbc.so
+noload => app_voicemail_odbc.so
+
+;
+; Voicemail with filesystem storage
+;
+;noload => app_directory_plain.so
+;noload => app_voicemail_plain.so
+
-- 
1.5.3.6


asterisk-1.4.16-appconference.patch:

--- NEW FILE asterisk-1.4.16-appconference.patch ---
>From 5fdceb7064e63067e16e8d27ae084ccb1f9d0f60 Mon Sep 17 00:00:00 2001
From: Jeffrey C. Ollie <jeff at ocjtech.us>
Date: Sun, 18 Nov 2007 22:23:17 -0600
Subject: [PATCH] Add app_conference rev 911

---
 apps/Makefile                      |   14 +
 apps/app_conference.c              |  113 ++
 apps/conference/CLI.txt            |   96 +
 apps/conference/Flags.txt          |   31 +
 apps/conference/LICENSE            |  341 ++++
 apps/conference/README             |  125 ++
 apps/conference/README.videoswitch |   87 +
 apps/conference/TODO               |    4 +
 apps/conference/app_conference.h   |  244 +++
 apps/conference/cli.c              | 1265 ++++++++++++++
 apps/conference/cli.h              |   99 ++
 apps/conference/common.h           |   63 +
 apps/conference/conf_frame.h       |   73 +
 apps/conference/conference.c       | 2923 +++++++++++++++++++++++++++++++
 apps/conference/conference.h       |  194 +++
 apps/conference/frame.c            |  679 ++++++++
 apps/conference/frame.h            |   75 +
 apps/conference/member.c           | 3332 ++++++++++++++++++++++++++++++++++++
 apps/conference/member.h           |  315 ++++
 19 files changed, 10073 insertions(+), 0 deletions(-)
 create mode 100644 apps/app_conference.c
 create mode 100644 apps/conference/CLI.txt
 create mode 100644 apps/conference/Flags.txt
 create mode 100644 apps/conference/LICENSE
 create mode 100644 apps/conference/README
 create mode 100644 apps/conference/README.videoswitch
 create mode 100644 apps/conference/TODO
 create mode 100644 apps/conference/app_conference.h
 create mode 100644 apps/conference/cli.c
 create mode 100644 apps/conference/cli.h
 create mode 100644 apps/conference/common.h
 create mode 100644 apps/conference/conf_frame.h
 create mode 100644 apps/conference/conference.c
 create mode 100644 apps/conference/conference.h
 create mode 100644 apps/conference/frame.c
 create mode 100644 apps/conference/frame.h
 create mode 100644 apps/conference/member.c
 create mode 100644 apps/conference/member.h

diff --git a/apps/Makefile b/apps/Makefile
index 4006c9a..cf33505 100644
--- a/apps/Makefile
+++ b/apps/Makefile
@@ -44,4 +44,18 @@ endif
 
 all: _all
 
+app_conference.o: ASTCFLAGS+=-DSILDET=2 -Iconference
+
+conference/conference.o: ASTCFLAGS+=-DSILDET=2 -Iconference
+
+conference/member.o: ASTCFLAGS+=-DSILDET=2 -Iconference
+
+conference/frame.o: ASTCFLAGS+=-DSILDET=2 -Iconference
+
+conference/cli.o: ASTCFLAGS+=-DSILDET=2 -Iconference
+
+app_conference.so: app_conference.o conference/conference.o conference/member.o conference/frame.o conference/cli.o
+	$(ECHO_PREFIX) echo "   [LD] $^ -> $@"
+	$(CMD_PREFIX) $(CXX) $(PTHREAD_CFLAGS) $(ASTLDFLAGS) $(SOLINK) -o $@ $^ -lspeex
+
 include $(ASTTOPDIR)/Makefile.moddir_rules
diff --git a/apps/app_conference.c b/apps/app_conference.c
new file mode 100644
index 0000000..824d5dd
--- /dev/null
+++ b/apps/app_conference.c
@@ -0,0 +1,113 @@
+/*
+ * app_conference
+ *
+ * A channel independent conference application for Asterisk
+ *
+ * Copyright (C) 2002, 2003 Junghanns.NET GmbH
+ * Copyright (C) 2003, 2004 HorizonLive.com, Inc.
+ * Copyright (C) 2005, 2006 HorizonWimba, Inc.
+ * Copyright (C) 2007 Wimba, Inc.
+ *
+ * Klaus-Peter Junghanns <kapejod at ns1.jnetdns.de>
+ *
+ * Video Conferencing support added by
+ * Neil Stratford <neils at vipadia.com>
+ * Copyright (C) 2005, 2005 Vipadia Limited
+ *
+ * VAD driven video conferencing, text message support
+ * and miscellaneous enhancements added by
+ * Mihai Balea <mihai at hates dot ms>
+ *
+ * This program may be modified and distributed under the
+ * terms of the GNU General Public License. You should have received
+ * a copy of the GNU General Public License along with this
+ * program; if not, write to the Free Software Foundation, Inc.
+ * 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include "asterisk.h"
+
+// SVN revision number, provided by make
+#ifndef REVISION
+#define REVISION "unknown"
+#endif
+
+static char *revision = REVISION;
+
+ASTERISK_FILE_VERSION(__FILE__, REVISION)
+
+#include "app_conference.h"
+#include "common.h"
+
+/*
+ * a conference has n + 1 threads, where n is the number of
+ * members and 1 is a conference thread which sends audio
+ * back to the members.
+ *
+ * each member thread reads frames from the channel and
+ * add's them to the member's frame queue.
+ *
+ * the conference thread reads frames from each speaking members
+ * queue, mixes them, and then re-queues them for the member thread
+ * to send back to the user.
+ */
+
+static char *app = "Conference";
+static char *synopsis = "Channel Independent Conference";
+static char *descrip = "Channel Independent Conference Application";
+
+static int app_conference_main(struct ast_channel* chan, void* data)
+{
+	int res ;
+	struct ast_module_user *u ;
+
+	u = ast_module_user_add(chan);
+
+	// call member thread function
+	res = member_exec( chan, data ) ;
+
+	ast_module_user_remove(u);
+
+	return res ;
+}
+
+static int unload_module( void )
+{
+	ast_log( LOG_NOTICE, "unloading app_conference module\n" ) ;
+
+	ast_module_user_hangup_all();
+
+	unregister_conference_cli() ;
+
+	return ast_unregister_application( app ) ;
+}
+
+static int load_module( void )
+{
+	ast_log( LOG_NOTICE, "Loading app_conference module, revision=%s\n", revision) ;
+
+	init_conference() ;
+
+	register_conference_cli() ;
+
+	return ast_register_application( app, app_conference_main, synopsis, descrip ) ;
+}
+
+// increment a timeval by ms milliseconds
+void add_milliseconds(struct timeval* tv, long ms)
+{
+	// add the microseconds to the microseconds field
+	tv->tv_usec += ( ms * 1000 ) ;
+
+	// calculate the number of seconds to increment
+	long s = ( tv->tv_usec / 1000000 ) ;
+
+	// adjust the microsends field
+	if ( s > 0 ) tv->tv_usec -= ( s * 1000000 ) ;
+
+	// increment the seconds field
+	tv->tv_sec += s ;
+}
+
+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY,
+		"Channel Independent Conference Application");
diff --git a/apps/conference/CLI.txt b/apps/conference/CLI.txt
new file mode 100644
index 0000000..48acf5a
--- /dev/null
+++ b/apps/conference/CLI.txt
@@ -0,0 +1,96 @@
+Current command line used by app_conference
+Please note that app_conference is still work in progress, so this document might be outdated. As always, the source code is the definitive reference (cli.[ch] and conference.[ch]).  You can also obtain help/usage information by using Asterisk CLI help system ("help conference")
+
+A member in a conference can be referred to by its id or by its channel.  Id is a positive number assigned automatically when the member joins the conference.  Channel is Asterisk channel identifier. To obtain a list of member ids and channels in a conference, do:
+
+*CLI> conference list <conference name>
[...9839 lines suppressed...]
+	// input/output smoother
+	struct ast_smoother *inSmoother;
+	struct ast_packer *outPacker;
+	int smooth_size_in;
+	int smooth_size_out;
+	int smooth_multiple;
+
+	// frames needed by conference_exec
+	unsigned int inFramesNeeded ;
+	unsigned int inVideoFramesNeeded ;
+
+	// used when caching last frame
+	conf_frame* inFramesLast ;
+	unsigned int inFramesRepeatLast ;
+	unsigned short okayToCacheLast ;
+
+	// LL output frame queue
+	conf_frame* outFrames ;
+	conf_frame* outFramesTail ;
+	unsigned int outFramesCount ;
+	conf_frame* outVideoFrames ;
+	conf_frame* outVideoFramesTail ;
+	unsigned int outVideoFramesCount ;
+	conf_frame* outDTMFFrames ;
+	conf_frame* outDTMFFramesTail ;
+	unsigned int outDTMFFramesCount ;
+	conf_frame* outTextFrames ;
+	conf_frame* outTextFramesTail ;
+	unsigned int outTextFramesCount ;
+
+	// LL video switched flag
+	short conference;
+
+	// switch video by VAD?
+	short vad_switch;
+	// switch by dtmf?
+	short dtmf_switch;
+	// relay dtmf to manager?
+	short dtmf_relay;
+	// initial nat delay flag
+	short first_frame_received;
+	// does text messages?
+	short does_text;
+
+
+	// time we last dropped a frame
+	struct timeval last_in_dropped ;
+	struct timeval last_out_dropped ;
+
+	// ( not currently used )
+	// int samplesperframe ;
+
+	// used for determining need to mix frames
+	// and for management interface notification
+	// and for VAD based video switching
+	short speaking_state_notify ;
+	short speaking_state ; // This flag will be true if this member or any of its drivers is speaking
+	short local_speaking_state; // This flag will be true only if this member is speaking
+	struct timeval last_state_change;
+	int speaker_count; // Number of drivers (including this member) that are speaking
+
+	// pointer to next member in single-linked list
+	struct ast_conf_member* next ;
+
+	// accounting values
+	unsigned long frames_in ;
+	unsigned long frames_in_dropped ;
+	unsigned long frames_out ;
+	unsigned long frames_out_dropped ;
+
+	unsigned long video_frames_in ;
+	unsigned long video_frames_in_dropped ;
+	unsigned long video_frames_out ;
+	unsigned long video_frames_out_dropped ;
+
+	unsigned long dtmf_frames_in ;
+	unsigned long dtmf_frames_in_dropped ;
+	unsigned long dtmf_frames_out ;
+	unsigned long dtmf_frames_out_dropped ;
+
+	unsigned long text_frames_in ;
+	unsigned long text_frames_in_dropped ;
+	unsigned long text_frames_out ;
+	unsigned long text_frames_out_dropped ;
+
+	// for counting sequentially dropped frames
+	unsigned int sequential_drops ;
+	unsigned long since_dropped ;
+
+	// start time
+	struct timeval time_entered ;
+	struct timeval lastsent_timeval ;
+
+	// flag indicating we should remove this member
+	short remove_flag ;
+	short kick_flag ;
+
+#if ( SILDET == 2 )
+	// pointer to speex preprocessor dsp
+	SpeexPreprocessState *dsp ;
+        // number of frames to ignore speex_preprocess()
+	int ignore_speex_count;
+#else
+	// placeholder when preprocessing is not enabled
+	void* dsp ;
+#endif
+
+	// audio format this member is using
+	int write_format ;
+	int read_format ;
+
+	int write_format_index ;
+	int read_format_index ;
+
+	// member frame translators
+	struct ast_trans_pvt* to_slinear ;
+	struct ast_trans_pvt* from_slinear ;
+
+	// For playing sounds
+	struct ast_conf_soundq *soundq;
+	struct ast_conf_soundq *videoq;
+	
+	// Enter/leave sounds
+	char * enter_snd;
+	char * leave_snd;
+
+	// Pointer to another member that will be driven from this member's audio
+	struct ast_conf_member *driven_member;
+} ;
+
+struct conf_member
+{
+	struct ast_conf_member* realmember ;
+	struct conf_member* next ;
+} ;
+
+//
+// function declarations
+//
+
+int member_exec( struct ast_channel* chan, void* data ) ;
+
+struct ast_conf_member* check_active_video( int id, struct ast_conference *conf );
+
+struct ast_conf_member* create_member( struct ast_channel* chan, const char* data ) ;
+struct ast_conf_member* delete_member( struct ast_conf_member* member ) ;
+
+// incoming queue
+int queue_incoming_frame( struct ast_conf_member* member, struct ast_frame* fr ) ;
+int queue_incoming_video_frame( struct ast_conf_member* member, const struct ast_frame* fr ) ;
+int queue_incoming_dtmf_frame( struct ast_conf_member* member, const struct ast_frame* fr ) ;
+conf_frame* get_incoming_frame( struct ast_conf_member* member ) ;
+conf_frame* get_incoming_video_frame( struct ast_conf_member* member ) ;
+conf_frame* get_incoming_dtmf_frame( struct ast_conf_member* member ) ;
+
+// outgoing queue
+int queue_outgoing_frame( struct ast_conf_member* member, const struct ast_frame* fr, struct timeval delivery ) ;
+int __queue_outgoing_frame( struct ast_conf_member* member, const struct ast_frame* fr, struct timeval delivery ) ;
+conf_frame* get_outgoing_frame( struct ast_conf_member* member ) ;
+
+int queue_outgoing_video_frame( struct ast_conf_member* member, const struct ast_frame* fr, struct timeval delivery ) ;
+conf_frame* get_outgoing_video_frame( struct ast_conf_member* member ) ;
+int queue_outgoing_dtmf_frame( struct ast_conf_member* member, const struct ast_frame* fr ) ;
+int queue_outgoing_text_frame( struct ast_conf_member* member, const struct ast_frame* fr ) ;
+conf_frame* get_outgoing_dtmf_frame( struct ast_conf_member* member ) ;
+conf_frame* get_outgoing_text_frame( struct ast_conf_member* member ) ;
+
+void send_state_change_notifications( struct ast_conf_member* member ) ;
+
+int increment_speaker_count(struct ast_conf_member *member, int lock);
+int decrement_speaker_count(struct ast_conf_member *member, int lock);
+
+void member_process_spoken_frames(struct ast_conference* conf,
+				  struct ast_conf_member *member,
+				  struct conf_frame **spoken_frames,
+				  long time_diff,
+				 int *listener_count,
+				 int *speaker_count);
+
+void member_process_outgoing_frames(struct ast_conference* conf,
+				    struct ast_conf_member *member,
+				    struct conf_frame *send_frames);
+
+//
+// packer functions
+//
+
+struct ast_packer;
+
+extern struct ast_packer *ast_packer_new(int bytes);
+extern void ast_packer_set_flags(struct ast_packer *packer, int flags);
+extern int ast_packer_get_flags(struct ast_packer *packer);
+extern void ast_packer_free(struct ast_packer *s);
+extern void ast_packer_reset(struct ast_packer *s, int bytes);
+extern int ast_packer_feed(struct ast_packer *s, const struct ast_frame *f);
+extern struct ast_frame *ast_packer_read(struct ast_packer *s);
+#endif
-- 
1.5.3.6


asterisk-1.4.16-autoconf.patch:

--- NEW FILE asterisk-1.4.16-autoconf.patch ---
>From 3b5f7cfaadc19fdc122742b1d2ff4313d33fd0c8 Mon Sep 17 00:00:00 2001
From: Jeffrey C. Ollie <jeff at ocjtech.us>
Date: Sun, 18 Nov 2007 22:30:31 -0600
Subject: [PATCH] Update configure script.

---
 configure                        |  993 +++++++++++++++++++++++++++++++++++++-
 include/asterisk/autoconfig.h.in |    6 +
 2 files changed, 974 insertions(+), 25 deletions(-)

diff --git a/configure b/configure
index 8fcf1b9..104811a 100755
--- a/configure
+++ b/configure
@@ -1,5 +1,5 @@
 #! /bin/sh
-# From configure.ac Revision: 92463 .
+# From configure.ac Revision.
 # Guess values for system-dependent variables and create Makefiles.
 # Generated by GNU Autoconf 2.61 for asterisk 1.4.
 #
@@ -721,10 +721,18 @@ ALSA_LIB
 ALSA_INCLUDE
 ALSA_DIR
 PBX_ALSA
+BLUETOOTH_LIB
+BLUETOOTH_INCLUDE
+BLUETOOTH_DIR
+PBX_BLUETOOTH
 CURL_LIB
 CURL_INCLUDE
 CURL_DIR
 PBX_CURL
+CAP_LIB
+CAP_INCLUDE
+CAP_DIR
+PBX_CAP
 CURSES_LIB
 CURSES_INCLUDE
 CURSES_DIR
@@ -1510,7 +1518,9 @@ Optional Packages:
   --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
   --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
   --with-asound=PATH      use Advanced Linux Sound Architecture files in PATH
+  --with-bluetooth=PATH   use Bluetooth Support files in PATH
   --with-curl=PATH        use cURL files in PATH
+  --with-cap=PATH         use POSIX 1.e capabilities files in PATH
   --with-curses=PATH      use curses files in PATH
   --with-gnutls=PATH      use GNU TLS support (used for iksemel only) files in
                           PATH
@@ -7670,6 +7680,34 @@ PBX_ALSA=0
 
 
 
+BLUETOOTH_DESCRIP="Bluetooth Support"
+BLUETOOTH_OPTION="bluetooth"
+
+# Check whether --with-bluetooth was given.
+if test "${with_bluetooth+set}" = set; then
+  withval=$with_bluetooth;
+case ${withval} in
+     n|no)
+     USE_BLUETOOTH=no
+     ;;
+     y|ye|yes)
+     BLUETOOTH_MANDATORY="yes"
+     ;;
+     *)
+     BLUETOOTH_DIR="${withval}"
+     BLUETOOTH_MANDATORY="yes"
+     ;;
+esac
+
+fi
+
+PBX_BLUETOOTH=0
+
+
+
+
+
+
 CURL_DESCRIP="cURL"
 CURL_OPTION="curl"
 
@@ -7698,6 +7736,34 @@ PBX_CURL=0
 
 
 
+CAP_DESCRIP="POSIX 1.e capabilities"
+CAP_OPTION="cap"
+
+# Check whether --with-cap was given.
+if test "${with_cap+set}" = set; then
+  withval=$with_cap;
+case ${withval} in
+     n|no)
+     USE_CAP=no
+     ;;
+     y|ye|yes)
+     CAP_MANDATORY="yes"
+     ;;
+     *)
+     CAP_DIR="${withval}"
+     CAP_MANDATORY="yes"
+     ;;
+esac
+
+fi
+
+PBX_CAP=0
+
+
+
+
+
+
 CURSES_DESCRIP="curses"
 CURSES_OPTION="curses"
 
@@ -11988,13 +12054,11 @@ _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-#include <sys/types.h> /* for off_t */
-     #include <stdio.h>
+#include <stdio.h>
 int
 main ()
 {
-int (*fp) (FILE *, off_t, int) = fseeko;
-     return fseeko (stdin, 0, 0) && fp (stdin, 0, 0);
+return fseeko (stdin, 0, 0) && (fseeko) (stdin, 0, 0);
   ;
   return 0;
 }
@@ -12034,13 +12098,11 @@ cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
 #define _LARGEFILE_SOURCE 1
-#include <sys/types.h> /* for off_t */
-     #include <stdio.h>
+#include <stdio.h>
 int
 main ()
 {
-int (*fp) (FILE *, off_t, int) = fseeko;
-     return fseeko (stdin, 0, 0) && fp (stdin, 0, 0);
+return fseeko (stdin, 0, 0) && (fseeko) (stdin, 0, 0);
   ;
   return 0;
 }
@@ -16757,6 +16819,415 @@ fi
 
 
 
+if test "${USE_BLUETOOTH}" != "no"; then
+   pbxlibdir=""
+   if test "x${BLUETOOTH_DIR}" != "x"; then
+      if test -d ${BLUETOOTH_DIR}/lib; then
+      	 pbxlibdir="-L${BLUETOOTH_DIR}/lib"
+      else
+      	 pbxlibdir="-L${BLUETOOTH_DIR}"
+      fi
+   fi
+   { echo "$as_me:$LINENO: checking for ba2str in -lbluetooth" >&5
+echo $ECHO_N "checking for ba2str in -lbluetooth... $ECHO_C" >&6; }
+if test "${ac_cv_lib_bluetooth_ba2str+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lbluetooth ${pbxlibdir}  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char ba2str ();
+int
+main ()
+{
+return ba2str ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_lib_bluetooth_ba2str=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_lib_bluetooth_ba2str=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_bluetooth_ba2str" >&5
+echo "${ECHO_T}$ac_cv_lib_bluetooth_ba2str" >&6; }
+if test $ac_cv_lib_bluetooth_ba2str = yes; then
+  AST_BLUETOOTH_FOUND=yes
+else
+  AST_BLUETOOTH_FOUND=no
+fi
+
+
+   if test "${AST_BLUETOOTH_FOUND}" = "yes"; then
+      BLUETOOTH_LIB="-lbluetooth "
+      BLUETOOTH_HEADER_FOUND="1"
+      if test "x${BLUETOOTH_DIR}" != "x"; then
+         BLUETOOTH_LIB="${pbxlibdir} ${BLUETOOTH_LIB}"
+	 BLUETOOTH_INCLUDE="-I${BLUETOOTH_DIR}/include"
+	 saved_cppflags="${CPPFLAGS}"
+	 CPPFLAGS="${CPPFLAGS} -I${BLUETOOTH_DIR}/include"
+	 if test "xbluetooth/bluetooth.h" != "x" ; then
+	    as_ac_Header=`echo "ac_cv_header_${BLUETOOTH_DIR}/include/bluetooth/bluetooth.h" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for ${BLUETOOTH_DIR}/include/bluetooth/bluetooth.h" >&5
+echo $ECHO_N "checking for ${BLUETOOTH_DIR}/include/bluetooth/bluetooth.h... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking ${BLUETOOTH_DIR}/include/bluetooth/bluetooth.h usability" >&5
+echo $ECHO_N "checking ${BLUETOOTH_DIR}/include/bluetooth/bluetooth.h usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <${BLUETOOTH_DIR}/include/bluetooth/bluetooth.h>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking ${BLUETOOTH_DIR}/include/bluetooth/bluetooth.h presence" >&5
+echo $ECHO_N "checking ${BLUETOOTH_DIR}/include/bluetooth/bluetooth.h presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <${BLUETOOTH_DIR}/include/bluetooth/bluetooth.h>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: ${BLUETOOTH_DIR}/include/bluetooth/bluetooth.h: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: ${BLUETOOTH_DIR}/include/bluetooth/bluetooth.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ${BLUETOOTH_DIR}/include/bluetooth/bluetooth.h: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: ${BLUETOOTH_DIR}/include/bluetooth/bluetooth.h: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: ${BLUETOOTH_DIR}/include/bluetooth/bluetooth.h: present but cannot be compiled" >&5
+echo "$as_me: WARNING: ${BLUETOOTH_DIR}/include/bluetooth/bluetooth.h: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ${BLUETOOTH_DIR}/include/bluetooth/bluetooth.h:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: ${BLUETOOTH_DIR}/include/bluetooth/bluetooth.h:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ${BLUETOOTH_DIR}/include/bluetooth/bluetooth.h: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: ${BLUETOOTH_DIR}/include/bluetooth/bluetooth.h: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ${BLUETOOTH_DIR}/include/bluetooth/bluetooth.h:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: ${BLUETOOTH_DIR}/include/bluetooth/bluetooth.h:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ${BLUETOOTH_DIR}/include/bluetooth/bluetooth.h: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: ${BLUETOOTH_DIR}/include/bluetooth/bluetooth.h: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ${BLUETOOTH_DIR}/include/bluetooth/bluetooth.h: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: ${BLUETOOTH_DIR}/include/bluetooth/bluetooth.h: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## ------------------------------- ##
+## Report this to www.asterisk.org ##
+## ------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for ${BLUETOOTH_DIR}/include/bluetooth/bluetooth.h" >&5
+echo $ECHO_N "checking for ${BLUETOOTH_DIR}/include/bluetooth/bluetooth.h... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  BLUETOOTH_HEADER_FOUND=1
+else
+  BLUETOOTH_HEADER_FOUND=0
+fi
+
+
+	 fi
+	 CPPFLAGS="${saved_cppflags}"
+      else
+	 if test "xbluetooth/bluetooth.h" != "x" ; then
+            if test "${ac_cv_header_bluetooth_bluetooth_h+set}" = set; then
+  { echo "$as_me:$LINENO: checking for bluetooth/bluetooth.h" >&5
+echo $ECHO_N "checking for bluetooth/bluetooth.h... $ECHO_C" >&6; }
+if test "${ac_cv_header_bluetooth_bluetooth_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_header_bluetooth_bluetooth_h" >&5
+echo "${ECHO_T}$ac_cv_header_bluetooth_bluetooth_h" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking bluetooth/bluetooth.h usability" >&5
+echo $ECHO_N "checking bluetooth/bluetooth.h usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <bluetooth/bluetooth.h>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking bluetooth/bluetooth.h presence" >&5
+echo $ECHO_N "checking bluetooth/bluetooth.h presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <bluetooth/bluetooth.h>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: bluetooth/bluetooth.h: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: bluetooth/bluetooth.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: bluetooth/bluetooth.h: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: bluetooth/bluetooth.h: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: bluetooth/bluetooth.h: present but cannot be compiled" >&5
+echo "$as_me: WARNING: bluetooth/bluetooth.h: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: bluetooth/bluetooth.h:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: bluetooth/bluetooth.h:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: bluetooth/bluetooth.h: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: bluetooth/bluetooth.h: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: bluetooth/bluetooth.h:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: bluetooth/bluetooth.h:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: bluetooth/bluetooth.h: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: bluetooth/bluetooth.h: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: bluetooth/bluetooth.h: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: bluetooth/bluetooth.h: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## ------------------------------- ##
+## Report this to www.asterisk.org ##
+## ------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for bluetooth/bluetooth.h" >&5
+echo $ECHO_N "checking for bluetooth/bluetooth.h... $ECHO_C" >&6; }
+if test "${ac_cv_header_bluetooth_bluetooth_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_header_bluetooth_bluetooth_h=$ac_header_preproc
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_header_bluetooth_bluetooth_h" >&5
+echo "${ECHO_T}$ac_cv_header_bluetooth_bluetooth_h" >&6; }
+
+fi
+if test $ac_cv_header_bluetooth_bluetooth_h = yes; then
+  BLUETOOTH_HEADER_FOUND=1
+else
+  BLUETOOTH_HEADER_FOUND=0
+fi
+
+
+	 fi
+      fi
+      if test "x${BLUETOOTH_HEADER_FOUND}" = "x0" ; then
+         if test -n "${BLUETOOTH_MANDATORY}" ;
+         then
+            { echo "$as_me:$LINENO: ***" >&5
+echo "$as_me: ***" >&6;}
+            { echo "$as_me:$LINENO: *** It appears that you do not have the bluetooth development package installed." >&5
+echo "$as_me: *** It appears that you do not have the bluetooth development package installed." >&6;}
+            { echo "$as_me:$LINENO: *** Please install it to include ${BLUETOOTH_DESCRIP} support, or re-run configure" >&5
+echo "$as_me: *** Please install it to include ${BLUETOOTH_DESCRIP} support, or re-run configure" >&6;}
+            { echo "$as_me:$LINENO: *** without explicitly specifying --with-${BLUETOOTH_OPTION}" >&5
+echo "$as_me: *** without explicitly specifying --with-${BLUETOOTH_OPTION}" >&6;}
+            exit 1
+         fi
+         BLUETOOTH_LIB=""
+         BLUETOOTH_INCLUDE=""
+         PBX_BLUETOOTH=0
+      else
+         PBX_BLUETOOTH=1
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_BLUETOOTH 1
+_ACEOF
+
+      fi
+   elif test -n "${BLUETOOTH_MANDATORY}";
+   then
+      { echo "$as_me:$LINENO: ***" >&5
+echo "$as_me: ***" >&6;}
+      { echo "$as_me:$LINENO: *** The ${BLUETOOTH_DESCRIP} installation on this system appears to be broken." >&5
+echo "$as_me: *** The ${BLUETOOTH_DESCRIP} installation on this system appears to be broken." >&6;}
+      { echo "$as_me:$LINENO: *** Either correct the installation, or run configure" >&5
+echo "$as_me: *** Either correct the installation, or run configure" >&6;}
+      { echo "$as_me:$LINENO: *** without explicitly specifying --with-${BLUETOOTH_OPTION}" >&5
+echo "$as_me: *** without explicitly specifying --with-${BLUETOOTH_OPTION}" >&6;}
+      exit 1
+   fi
+fi
+
+
+
 if test "${USE_CURSES}" != "no"; then
    pbxlibdir=""
    if test "x${CURSES_DIR}" != "x"; then
@@ -17165,6 +17636,417 @@ echo "$as_me: *** without explicitly specifying --with-${CURSES_OPTION}" >&6;}
 fi
 
 
+if test "x${host_os}" = "xlinux-gnu" ; then
+
+if test "${USE_CAP}" != "no"; then
+   pbxlibdir=""
+   if test "x${CAP_DIR}" != "x"; then
+      if test -d ${CAP_DIR}/lib; then
+      	 pbxlibdir="-L${CAP_DIR}/lib"
+      else
+      	 pbxlibdir="-L${CAP_DIR}"
+      fi
+   fi
+   { echo "$as_me:$LINENO: checking for cap_from_text in -lcap" >&5
+echo $ECHO_N "checking for cap_from_text in -lcap... $ECHO_C" >&6; }
+if test "${ac_cv_lib_cap_cap_from_text+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lcap ${pbxlibdir}  $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char cap_from_text ();
+int
+main ()
+{
+return cap_from_text ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_lib_cap_cap_from_text=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_lib_cap_cap_from_text=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_cap_cap_from_text" >&5
+echo "${ECHO_T}$ac_cv_lib_cap_cap_from_text" >&6; }
+if test $ac_cv_lib_cap_cap_from_text = yes; then
+  AST_CAP_FOUND=yes
+else
+  AST_CAP_FOUND=no
+fi
+
+
+   if test "${AST_CAP_FOUND}" = "yes"; then
+      CAP_LIB="-lcap "
+      CAP_HEADER_FOUND="1"
+      if test "x${CAP_DIR}" != "x"; then
+         CAP_LIB="${pbxlibdir} ${CAP_LIB}"
+	 CAP_INCLUDE="-I${CAP_DIR}/include"
+	 saved_cppflags="${CPPFLAGS}"
+	 CPPFLAGS="${CPPFLAGS} -I${CAP_DIR}/include"
+	 if test "xsys/capability.h" != "x" ; then
+	    as_ac_Header=`echo "ac_cv_header_${CAP_DIR}/include/sys/capability.h" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for ${CAP_DIR}/include/sys/capability.h" >&5
+echo $ECHO_N "checking for ${CAP_DIR}/include/sys/capability.h... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking ${CAP_DIR}/include/sys/capability.h usability" >&5
+echo $ECHO_N "checking ${CAP_DIR}/include/sys/capability.h usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <${CAP_DIR}/include/sys/capability.h>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking ${CAP_DIR}/include/sys/capability.h presence" >&5
+echo $ECHO_N "checking ${CAP_DIR}/include/sys/capability.h presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <${CAP_DIR}/include/sys/capability.h>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: ${CAP_DIR}/include/sys/capability.h: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: ${CAP_DIR}/include/sys/capability.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ${CAP_DIR}/include/sys/capability.h: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: ${CAP_DIR}/include/sys/capability.h: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: ${CAP_DIR}/include/sys/capability.h: present but cannot be compiled" >&5
+echo "$as_me: WARNING: ${CAP_DIR}/include/sys/capability.h: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ${CAP_DIR}/include/sys/capability.h:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: ${CAP_DIR}/include/sys/capability.h:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ${CAP_DIR}/include/sys/capability.h: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: ${CAP_DIR}/include/sys/capability.h: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ${CAP_DIR}/include/sys/capability.h:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: ${CAP_DIR}/include/sys/capability.h:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ${CAP_DIR}/include/sys/capability.h: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: ${CAP_DIR}/include/sys/capability.h: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ${CAP_DIR}/include/sys/capability.h: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: ${CAP_DIR}/include/sys/capability.h: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## ------------------------------- ##
+## Report this to www.asterisk.org ##
+## ------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for ${CAP_DIR}/include/sys/capability.h" >&5
+echo $ECHO_N "checking for ${CAP_DIR}/include/sys/capability.h... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  CAP_HEADER_FOUND=1
+else
+  CAP_HEADER_FOUND=0
+fi
+
+
+	 fi
+	 CPPFLAGS="${saved_cppflags}"
+      else
+	 if test "xsys/capability.h" != "x" ; then
+            if test "${ac_cv_header_sys_capability_h+set}" = set; then
+  { echo "$as_me:$LINENO: checking for sys/capability.h" >&5
+echo $ECHO_N "checking for sys/capability.h... $ECHO_C" >&6; }
+if test "${ac_cv_header_sys_capability_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_header_sys_capability_h" >&5
+echo "${ECHO_T}$ac_cv_header_sys_capability_h" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking sys/capability.h usability" >&5
+echo $ECHO_N "checking sys/capability.h usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <sys/capability.h>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking sys/capability.h presence" >&5
+echo $ECHO_N "checking sys/capability.h presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <sys/capability.h>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: sys/capability.h: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: sys/capability.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: sys/capability.h: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: sys/capability.h: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: sys/capability.h: present but cannot be compiled" >&5
+echo "$as_me: WARNING: sys/capability.h: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: sys/capability.h:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: sys/capability.h:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: sys/capability.h: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: sys/capability.h: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: sys/capability.h:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: sys/capability.h:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: sys/capability.h: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: sys/capability.h: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: sys/capability.h: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: sys/capability.h: in the future, the compiler will take precedence" >&2;}
+    ( cat <<\_ASBOX
+## ------------------------------- ##
+## Report this to www.asterisk.org ##
+## ------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for sys/capability.h" >&5
+echo $ECHO_N "checking for sys/capability.h... $ECHO_C" >&6; }
+if test "${ac_cv_header_sys_capability_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_header_sys_capability_h=$ac_header_preproc
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_header_sys_capability_h" >&5
+echo "${ECHO_T}$ac_cv_header_sys_capability_h" >&6; }
+
+fi
+if test $ac_cv_header_sys_capability_h = yes; then
+  CAP_HEADER_FOUND=1
+else
+  CAP_HEADER_FOUND=0
+fi
+
+
+	 fi
+      fi
+      if test "x${CAP_HEADER_FOUND}" = "x0" ; then
+         if test -n "${CAP_MANDATORY}" ;
+         then
+            { echo "$as_me:$LINENO: ***" >&5
+echo "$as_me: ***" >&6;}
+            { echo "$as_me:$LINENO: *** It appears that you do not have the cap development package installed." >&5
+echo "$as_me: *** It appears that you do not have the cap development package installed." >&6;}
+            { echo "$as_me:$LINENO: *** Please install it to include ${CAP_DESCRIP} support, or re-run configure" >&5
+echo "$as_me: *** Please install it to include ${CAP_DESCRIP} support, or re-run configure" >&6;}
+            { echo "$as_me:$LINENO: *** without explicitly specifying --with-${CAP_OPTION}" >&5
+echo "$as_me: *** without explicitly specifying --with-${CAP_OPTION}" >&6;}
+            exit 1
+         fi
+         CAP_LIB=""
+         CAP_INCLUDE=""
+         PBX_CAP=0
+      else
+         PBX_CAP=1
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_CAP 1
+_ACEOF
+
+      fi
+   elif test -n "${CAP_MANDATORY}";
+   then
+      { echo "$as_me:$LINENO: ***" >&5
+echo "$as_me: ***" >&6;}
+      { echo "$as_me:$LINENO: *** The ${CAP_DESCRIP} installation on this system appears to be broken." >&5
+echo "$as_me: *** The ${CAP_DESCRIP} installation on this system appears to be broken." >&6;}
+      { echo "$as_me:$LINENO: *** Either correct the installation, or run configure" >&5
+echo "$as_me: *** Either correct the installation, or run configure" >&6;}
+      { echo "$as_me:$LINENO: *** without explicitly specifying --with-${CAP_OPTION}" >&5
+echo "$as_me: *** without explicitly specifying --with-${CAP_OPTION}" >&6;}
+      exit 1
+   fi
+fi
+
+fi
+
 GSM_INTERNAL="yes"
 
 GSM_SYSTEM="yes"
@@ -27922,9 +28804,9 @@ if test "${USE_SPANDSP}" != "no"; then
    pbxlibdir=""
    if test "x${SPANDSP_DIR}" != "x"; then
       if test -d ${SPANDSP_DIR}/lib; then
-	 pbxlibdir="-L${SPANDSP_DIR}/lib"
+      	 pbxlibdir="-L${SPANDSP_DIR}/lib"
       else
-	 pbxlibdir="-L${SPANDSP_DIR}"
+      	 pbxlibdir="-L${SPANDSP_DIR}"
       fi
    fi
    { echo "$as_me:$LINENO: checking for fax_init in -lspandsp" >&5
@@ -28117,7 +28999,12 @@ echo "$as_me: WARNING: ${SPANDSP_DIR}/include/spandsp.h:     section \"Present B
 echo "$as_me: WARNING: ${SPANDSP_DIR}/include/spandsp.h: proceeding with the preprocessor's result" >&2;}
     { echo "$as_me:$LINENO: WARNING: ${SPANDSP_DIR}/include/spandsp.h: in the future, the compiler will take precedence" >&5
 echo "$as_me: WARNING: ${SPANDSP_DIR}/include/spandsp.h: in the future, the compiler will take precedence" >&2;}
-
+    ( cat <<\_ASBOX
+## ------------------------------- ##
+## Report this to www.asterisk.org ##
+## ------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
     ;;
 esac
 { echo "$as_me:$LINENO: checking for ${SPANDSP_DIR}/include/spandsp.h" >&5
@@ -28254,7 +29141,12 @@ echo "$as_me: WARNING: spandsp.h:     section \"Present But Cannot Be Compiled\"
 echo "$as_me: WARNING: spandsp.h: proceeding with the preprocessor's result" >&2;}
     { echo "$as_me:$LINENO: WARNING: spandsp.h: in the future, the compiler will take precedence" >&5
 echo "$as_me: WARNING: spandsp.h: in the future, the compiler will take precedence" >&2;}
-
+    ( cat <<\_ASBOX
+## ------------------------------- ##
+## Report this to www.asterisk.org ##
+## ------------------------------- ##
+_ASBOX
+     ) | sed "s/^/$as_me: WARNING:     /" >&2
     ;;
 esac
 { echo "$as_me:$LINENO: checking for spandsp.h" >&5
@@ -34667,10 +35559,18 @@ ALSA_LIB!$ALSA_LIB$ac_delim
 ALSA_INCLUDE!$ALSA_INCLUDE$ac_delim
 ALSA_DIR!$ALSA_DIR$ac_delim
 PBX_ALSA!$PBX_ALSA$ac_delim
+BLUETOOTH_LIB!$BLUETOOTH_LIB$ac_delim
+BLUETOOTH_INCLUDE!$BLUETOOTH_INCLUDE$ac_delim
+BLUETOOTH_DIR!$BLUETOOTH_DIR$ac_delim
+PBX_BLUETOOTH!$PBX_BLUETOOTH$ac_delim
 CURL_LIB!$CURL_LIB$ac_delim
 CURL_INCLUDE!$CURL_INCLUDE$ac_delim
 CURL_DIR!$CURL_DIR$ac_delim
 PBX_CURL!$PBX_CURL$ac_delim
+CAP_LIB!$CAP_LIB$ac_delim
+CAP_INCLUDE!$CAP_INCLUDE$ac_delim
+CAP_DIR!$CAP_DIR$ac_delim
+PBX_CAP!$PBX_CAP$ac_delim
 CURSES_LIB!$CURSES_LIB$ac_delim
 CURSES_INCLUDE!$CURSES_INCLUDE$ac_delim
 CURSES_DIR!$CURSES_DIR$ac_delim
@@ -34752,14 +35652,6 @@ PRI_INCLUDE!$PRI_INCLUDE$ac_delim
 PRI_DIR!$PRI_DIR$ac_delim
 PBX_PRI!$PBX_PRI$ac_delim
 PWLIB_LIB!$PWLIB_LIB$ac_delim
-PWLIB_INCLUDE!$PWLIB_INCLUDE$ac_delim
-PWLIB_DIR!$PWLIB_DIR$ac_delim
-PBX_PWLIB!$PBX_PWLIB$ac_delim
-OPENH323_LIB!$OPENH323_LIB$ac_delim
-OPENH323_INCLUDE!$OPENH323_INCLUDE$ac_delim
-OPENH323_DIR!$OPENH323_DIR$ac_delim
-PBX_OPENH323!$PBX_OPENH323$ac_delim
-QT_LIB!$QT_LIB$ac_delim
 _ACEOF
 
   if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
@@ -34801,6 +35693,14 @@ _ACEOF
 ac_delim='%!_!# '
 for ac_last_try in false false false false false :; do
   cat >conf$$subs.sed <<_ACEOF
+PWLIB_INCLUDE!$PWLIB_INCLUDE$ac_delim
+PWLIB_DIR!$PWLIB_DIR$ac_delim
+PBX_PWLIB!$PBX_PWLIB$ac_delim
+OPENH323_LIB!$OPENH323_LIB$ac_delim
+OPENH323_INCLUDE!$OPENH323_INCLUDE$ac_delim
+OPENH323_DIR!$OPENH323_DIR$ac_delim
+PBX_OPENH323!$PBX_OPENH323$ac_delim
+QT_LIB!$QT_LIB$ac_delim
 QT_INCLUDE!$QT_INCLUDE$ac_delim
 QT_DIR!$QT_DIR$ac_delim
 PBX_QT!$PBX_QT$ac_delim
@@ -34890,6 +35790,47 @@ PBX_ZAPTEL_VLDTMF!$PBX_ZAPTEL_VLDTMF$ac_delim
 PBX_ZAPTEL_TRANSCODE!$PBX_ZAPTEL_TRANSCODE$ac_delim
 EDITLINE_LIB!$EDITLINE_LIB$ac_delim
 PBX_H323!$PBX_H323$ac_delim
+_ACEOF
+
+  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 97; then
+    break
+  elif $ac_last_try; then
+    { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
+echo "$as_me: error: could not make $CONFIG_STATUS" >&2;}
+   { (exit 1); exit 1; }; }
+  else
+    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+  fi
+done
+
+ac_eof=`sed -n '/^CEOF[0-9]*$/s/CEOF/0/p' conf$$subs.sed`
+if test -n "$ac_eof"; then
+  ac_eof=`echo "$ac_eof" | sort -nru | sed 1q`
+  ac_eof=`expr $ac_eof + 1`
+fi
+
+cat >>$CONFIG_STATUS <<_ACEOF
+cat >"\$tmp/subs-3.sed" <<\CEOF$ac_eof
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+_ACEOF
+sed '
+s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g
+s/^/s,@/; s/!/@,|#_!!_#|/
+:n
+t n
+s/'"$ac_delim"'$/,g/; t
+s/$/\\/; p
+N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n
+' >>$CONFIG_STATUS <conf$$subs.sed
+rm -f conf$$subs.sed
+cat >>$CONFIG_STATUS <<_ACEOF
+CEOF$ac_eof
+_ACEOF
+
+
+ac_delim='%!_!# '
+for ac_last_try in false false false false false :; do
+  cat >conf$$subs.sed <<_ACEOF
 PBX_IXJUSER!$PBX_IXJUSER$ac_delim
 GTKCONFIG!$GTKCONFIG$ac_delim
 PBX_GTK!$PBX_GTK$ac_delim
@@ -34903,7 +35844,7 @@ CURL_CONFIG!$CURL_CONFIG$ac_delim
 LTLIBOBJS!$LTLIBOBJS$ac_delim
 _ACEOF
 
-  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 96; then
+  if test `sed -n "s/.*$ac_delim\$/X/p" conf$$subs.sed | grep -c X` = 11; then
     break
   elif $ac_last_try; then
     { { echo "$as_me:$LINENO: error: could not make $CONFIG_STATUS" >&5
@@ -34921,8 +35862,8 @@ if test -n "$ac_eof"; then
 fi
 
 cat >>$CONFIG_STATUS <<_ACEOF
-cat >"\$tmp/subs-3.sed" <<\CEOF$ac_eof
-/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+cat >"\$tmp/subs-4.sed" <<\CEOF$ac_eof
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b end
 _ACEOF
 sed '
 s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g
@@ -34935,6 +35876,8 @@ N; s/^.*\n//; s/[,\\&]/\\&/g; s/@/@|#_!!_#|/g; b n
 ' >>$CONFIG_STATUS <conf$$subs.sed
 rm -f conf$$subs.sed
 cat >>$CONFIG_STATUS <<_ACEOF
+:end
+s/|#_!!_#|//g
 CEOF$ac_eof
 _ACEOF
 
@@ -35182,7 +36125,7 @@ s&@abs_builddir@&$ac_abs_builddir&;t t
 s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
 s&@INSTALL@&$ac_INSTALL&;t t
 $ac_datarootdir_hack
-" $ac_file_inputs | sed -f "$tmp/subs-1.sed" | sed -f "$tmp/subs-2.sed" | sed -f "$tmp/subs-3.sed" | sed 's/|#_!!_#|//g' >$tmp/out
+" $ac_file_inputs | sed -f "$tmp/subs-1.sed" | sed -f "$tmp/subs-2.sed" | sed -f "$tmp/subs-3.sed" | sed -f "$tmp/subs-4.sed" >$tmp/out
 
 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
   { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
diff --git a/include/asterisk/autoconfig.h.in b/include/asterisk/autoconfig.h.in
index 47fcad9..3c90d4c 100644
--- a/include/asterisk/autoconfig.h.in
+++ b/include/asterisk/autoconfig.h.in
@@ -59,9 +59,15 @@
 /* Define to 1 if your GCC C compiler supports the 'unused' attribute. */
 #undef HAVE_ATTRIBUTE_unused
 
+/* Define to indicate the ${BLUETOOTH_DESCRIP} library */
+#undef HAVE_BLUETOOTH
+
 /* Define to 1 if you have the `bzero' function. */
 #undef HAVE_BZERO
 
+/* Define to indicate the ${CAP_DESCRIP} library */
+#undef HAVE_CAP
+
 /* Define to 1 if your system has a working `chown' function. */
 #undef HAVE_CHOWN
 
-- 
1.5.3.6


asterisk-1.4.16-chanmobile.patch:

--- NEW FILE asterisk-1.4.16-chanmobile.patch ---
>From 90c23e041c9c4f215f62f617873766d13c5a9063 Mon Sep 17 00:00:00 2001
From: Jeffrey C. Ollie <jeff at ocjtech.us>
Date: Sun, 18 Nov 2007 22:25:43 -0600
Subject: [PATCH] Add chan_mobile (backported from asterisk-addons trunk).

---
 build_tools/menuselect-deps.in |    1 +
 channels/Makefile              |    2 +
 channels/chan_mobile.c         | 2126 ++++++++++++++++++++++++++++++++++++++++
 configs/mobile.conf.sample     |   60 ++
 configure.ac                   |    3 +
 doc/chan_mobile.txt            |  240 +++++
 makeopts.in                    |    3 +
 7 files changed, 2435 insertions(+), 0 deletions(-)
 create mode 100644 channels/chan_mobile.c
 create mode 100644 configs/mobile.conf.sample
 create mode 100644 doc/chan_mobile.txt

diff --git a/build_tools/menuselect-deps.in b/build_tools/menuselect-deps.in
index fb10545..4f12adb 100644
--- a/build_tools/menuselect-deps.in
+++ b/build_tools/menuselect-deps.in
@@ -1,4 +1,5 @@
 ASOUND=@PBX_ALSA@
+BLUETOOTH=@PBX_BLUETOOTH@
 CURL=@PBX_CURL@
 FREETDS=@PBX_FREETDS@
 GSM=@PBX_GSM@
diff --git a/channels/Makefile b/channels/Makefile
index f5e96c7..9844128 100644
--- a/channels/Makefile
+++ b/channels/Makefile
@@ -124,4 +124,6 @@ misdn/isdn_lib.o: ASTCFLAGS+=-Wno-strict-aliasing
 
 $(if $(filter chan_misdn,$(EMBEDDED_MODS)),modules.link,chan_misdn.so): chan_misdn.o misdn_config.o misdn/isdn_lib.o misdn/isdn_msg_parser.o
 
+chan_mobile.so: LIBS+=$(BLUETOOTH_LIB)
+
 chan_vpb.oo: ASTCFLAGS:=$(filter-out -Wdeclaration-after-statement,$(ASTCFLAGS))
diff --git a/channels/chan_mobile.c b/channels/chan_mobile.c
new file mode 100644
index 0000000..69c871f
--- /dev/null
+++ b/channels/chan_mobile.c
@@ -0,0 +1,2126 @@
+/*
+ * Asterisk -- An open source telephony toolkit.
+ *
+ * Copyright (C) 1999 - 2006, Digium, Inc.
+ *
+ * Mark Spencer <markster at digium.com>
+ *
+ * See http://www.asterisk.org for more information about
+ * the Asterisk project. Please do not directly contact
+ * any of the maintainers of this project for assistance;
+ * the project provides a web site, mailing lists and IRC
+ * channels for your use.
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License Version 2. See the LICENSE file
+ * at the top of the source tree.
+ */
+
+/*! \file
+ *
+ * \brief Bluetooth Mobile Device channel driver
+ *
+ * \author Dave Bowerman <david.bowerman at gmail.com>
+ *
+ * \ingroup channel_drivers
+ */
+
+/*** MODULEINFO
+	<depend>bluetooth</depend>
+ ***/
+
+#include <asterisk.h>
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
+
+#include <stdio.h>
+#include <string.h>
+#include <sys/socket.h>
+#include <sys/time.h>
+#include <errno.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <arpa/inet.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <signal.h>
+
+#include <bluetooth/bluetooth.h>
+#include <bluetooth/hci.h>
+#include <bluetooth/hci_lib.h>
+#include <bluetooth/sdp.h>
+#include <bluetooth/sdp_lib.h>
+#include <bluetooth/rfcomm.h>
+#include <bluetooth/sco.h>
+#include <bluetooth/l2cap.h>
+
+#include <asterisk/lock.h>
+#include <asterisk/channel.h>
+#include <asterisk/config.h>
+#include <asterisk/logger.h>
+#include <asterisk/module.h>
+#include <asterisk/pbx.h>
+#include <asterisk/options.h>
+#include <asterisk/utils.h>
+#include <asterisk/linkedlists.h>
+#include <asterisk/cli.h>
+#include <asterisk/devicestate.h>
+#include <asterisk/causes.h>
+#include <asterisk/dsp.h>
+#include <asterisk/app.h>
+#include <asterisk/manager.h>
+
+#define AST_MODULE "chan_mobile"
+
+#define MBL_CONFIG "mobile.conf"
+
+#define DEVICE_FRAME_SIZE 48
+#define DEVICE_FRAME_FORMAT AST_FORMAT_SLINEAR
+#define CHANNEL_FRAME_SIZE 320
+
+static int prefformat = DEVICE_FRAME_FORMAT;
+
+static int discovery_interval = 60;			/* The device discovery interval, default 60 seconds. */
+static pthread_t discovery_thread = AST_PTHREADT_NULL;	/* The discovery thread */
+static sdp_session_t *sdp_session;
+
+enum mbl_type {
+	MBL_TYPE_PHONE,
+	MBL_TYPE_HEADSET
+};
+
+enum mbl_state {
+	MBL_STATE_INIT = 0,
+	MBL_STATE_INIT1,
+	MBL_STATE_INIT2,
+	MBL_STATE_INIT3,
+	MBL_STATE_INIT4,
+	MBL_STATE_INIT5,
+	MBL_STATE_INIT6,
+	MBL_STATE_PREIDLE,
+	MBL_STATE_IDLE,
+	MBL_STATE_DIAL,
+	MBL_STATE_DIAL1,
+	MBL_STATE_OUTGOING,
+	MBL_STATE_RING,
+	MBL_STATE_RING2,
+	MBL_STATE_RING3,
+	MBL_STATE_INCOMING,
+	MBL_STATE_HANGUP,
+	MBL_STATE_INSMS,
+	MBL_STATE_OUTSMS,
+	MBL_STATE_OUTSMS1,
+	MBL_STATE_OUTSMS2
+};
+
+struct adapter_pvt {
+	int dev_id;					/* device id */
+	int hci_socket;					/* device descriptor */
+	char id[31];					/* the 'name' from mobile.conf */
+	bdaddr_t addr;					/* adddress of adapter */
+	unsigned int inuse:1;				/* are we in use ? */
+	unsigned int alignment_detection:1;		/* do alignment detection on this adpater? */
+	int sco_socket;
+	AST_LIST_ENTRY(adapter_pvt) entry;
+};
+
+static AST_LIST_HEAD_STATIC(adapters, adapter_pvt);
+
+struct mbl_pvt {
+	struct ast_channel *owner;			/* Channel we belong to, possibly NULL */
+	struct ast_frame fr;				/* "null" frame */
+	enum mbl_type type;				/* Phone or Headset */
+	char id[31];					/* The id from mobile.conf */
+	int group;					/* group number for group dialling */
+	bdaddr_t addr;					/* address of device */
+	struct adapter_pvt *adapter;			/* the adapter we use */
+	char context[AST_MAX_CONTEXT];			/* the context for incoming calls */
+	char connected;					/* is it connected? */
+	int rfcomm_port;				/* rfcomm port number */
+	int rfcomm_socket;				/* rfcomm socket descriptor */
+	char rfcomm_buf[256];
+	char io_buf[CHANNEL_FRAME_SIZE + AST_FRIENDLY_OFFSET];
+	char io_save_buf[DEVICE_FRAME_SIZE];
+	int io_save_len;
+	int io_pipe[2];
+	int sco_socket;					/* sco socket descriptor */
+	pthread_t sco_listener_thread;			/* inbound sco listener for this device */
+	enum mbl_state state;				/* monitor thread current state */
+	pthread_t monitor_thread;			/* monitor thread handle */
+	char dial_number[AST_MAX_EXTENSION];		/* number for the monitor thread to dial */
+	int dial_timeout;
+	char ciev_call_0[4];				/* dynamically built reponse strings */
+	char ciev_call_1[4];
+	char ciev_callsetup_0[4];
[...2122 lines suppressed...]
+
+See configs/mobile.conf.sample for an example and an explanation of the configuration.
+
+
+Using chan_mobile :-
+
+chan_mobile.so must be loaded either by loading it using the Asterisk CLI, or by adding it to /etc/asterisk/modules.conf
+
+Search for your bluetooth devices using the CLI command 'mobile search'. Be patient with this command as
+it will take 8 - 10 seconds to do the discovery. This requires a free adapter.
+
+Headsets will generally have to be put into 'pairing' mode before they will show up here.
+
+This will return something like the following :-
+
+*CLI> mobile search
+Address           Name                           Usable Type    Port
+00:12:56:90:6E:00 LG TU500                       Yes    Phone   4
+00:80:C8:35:52:78 Toaster                        No     Headset 0
+00:0B:9E:11:74:A5 Hello II Plus                  Yes    Headset 1
+00:0F:86:0E:AE:42 Daves Blackberry               Yes    Phone   7
+
+This is a list of all bluetooth devices seen and whether or not they are usable with chan_mobile.
+The Address field contains the 'bd address' of the device. This is like an ethernet mac address.
+The Name field is whatever is configured into the device as its name.
+The Usable field tells you whether or not the device supports the Bluetooth Handsfree Profile or Headset profile.
+The Type field tells you whether the device is usable as a Phone line (FXO) or a headset (FXS)
+The Port field is the number to put in the configuration file.
+
+Choose which device(s) you want to use and edit /etc/asterisk/mobile.conf. There is a sample included
+with the Asterisk-addons source under configs/mobile.conf.sample.
+
+Be sure to configure the right bd address and port number from the search. If you want inbound
+calls on a device to go to a specific context, add a context= line, otherwise the default will
+be used. The 'id' of the device [bitinbrackets] can be anything you like, just make it unique.
+
+If you are configuring a Headset be sure to include the type=headset line, if left out it defaults
+to phone.
+
+The CLI command 'mobile show devices' can be used at any time to show the status of configured devices,
+and whether or not the device is capable of sending / receiving SMS via bluetooth.
+
+*CLI> mobile show devices 
+ID              Address           Group Adapter         Connected State SMS
+headset         00:0B:9E:11:AE:C6 0     blue            No        Init  No 
+LGTU550         00:E0:91:7F:46:44 1     dlink           No        Init  No 
+*CLI>
+
+As each phone is connected you will see a message on the Asterisk console :-
+
+ Loaded chan_mobile.so => (Bluetooth Mobile Device Channel Driver)
+    -- Bluetooth Device blackberry has connected.
+    -- Bluetooth Device dave has connected.
+
+To make outbound calls, add something to you Dialplan like the following :- (modify to suit)
+
+; Calls via LGTU5500
+exten => _9X.,1,Dial(Mobile/LGTU550/${EXTEN:1},45)
+exten => _9X.,n,Hangup
+
+To use channel groups, add an entry to each phones definition in mobile.conf like group=n
+where n is a number.
+
+Then if you do something like Dial(Mobile/g1/123456) Asterisk will dial 123456 on the first
+connected free phone in group 1.
+
+Phones which do not have a specific 'group=n' will be in group 0.
+
+
+To dial out on a headset, you need to use some other mechanism, because the headset is not likely
+to have all the needed buttons on it. res_clioriginate is good for this :-
+
+*CLI> originate Mobile/headset extension NNNNN at context
+
+This will call your headset, once you answer, Asterisk will call NNNNN at context context
+
+Dialplan hints :-
+
+chan_mobile supports 'device status' so you can do somthing like
+
+exten => 1234,hint,SIP/30&Mobile/dave&Mobile/blackberry
+
+
+MobileStatus Application :-
+
+chan_mobile also registers an application named MobileStatus. You can use this in your Dialplan
+to determine the 'state' of a device.
+
+For example, suppose you wanted to call dave's extension, but only if he was in the office. You could
+test to see if his mobile phone was attached to Asterisk, if it is dial his extension, otherwise dial his
+mobile phone.
+
+exten => 40,1,MobileStatus(dave,DAVECELL)
+exten => 40,2,GotoIf($["${DAVECELL}" = "1"]?3:5)
+exten => 40,3,Dial(ZAP/g1/0427466412,45,tT)
+exten => 40,4,Hangup
+exten => 40,5,Dial(SIP/40,45,tT)
+exten => 40,6,Hangup
+
+MobileStatus sets the value of the given variable to :-
+
+1 = Disconnected. i.e. Device not in range of Asterisk, or turned off etc etc
+2 = Connected and Not on a call. i.e. Free
+3 = Connected and on a call. i.e. Busy
+
+
+SMS Sending / Receiving
+
+If Asterisk has detected your mobile phone is capable of SMS via bluetooth, you will be able to send and
+receive SMS.
+
+Incoming SMS's cause Asterisk to create an inbound call to the context you defined in mobile.conf or the default
+context if you did not define one. The call will start at extension 'sms'. Two channel variables will be available,
+SMSSRC = the number of the originator of the SMS and SMSTXT which is the text of the SMS.
+This is not a voice call, so grab the values of the variables and hang the call up.
+
+So, to handle incoming SMS's, do something like the following in your dialplan
+
+[incoming-mobile]
+exten => sms,1,Verbose(Incoming SMS from ${SMSSRC} ${SMSTXT})
+exten => sms,n,Hangup()
+
+The above will just print the message on the console.
+
+If you use res_jabber, you could do something like this :-
+
+[incoming-mobile]
+exten => sms,1,JabberSend(transport,user at jabber.somewhere.com,SMS from ${SMSRC} ${SMSTXT})
+exten => sms,2,Hangup()
+
+To send an SMS, use the application MobileSendSMS like the following :-
+
+exten => 99,1,MobileSendSMS(dave,0427123456,Hello World)
+
+This will send 'Hello World' via device 'dave' to '0427123456'
+
+
+DTMF Debouncing :-
+
+DTMF detection varies from phone to phone. There is a configuration variable that allows you to tune
+this to your needs. e.g. in mobile.conf
+
+[LGTU550]
+address=00:12:56:90:6E:00
+port=4
+context=incoming-mobile
+dtmfskip=50
+
+change dtmfskip to suit your phone. The default is 200. The larger the number, the more chance of missed DTMF.
+The smaller the number the more chance of multiple digits being detected.
+
+
+Debugging :-
+
+Different phone manufacturers have different interpretations of the Bluetooth Handsfree Profile Spec.
+This means that not all phones work the same way, particularly in the connection setup / initialisation
+sequence. I've tried to make chan_mobile as general as possible, but it may need modification to
+support some phone i've never tested.
+
+Some phones, most notably Sony Ericsson 'T' series, dont quite conform to the Bluetooth HFP spec.
+chan_mobile will detect these and adapt accordingly. The T-610 and T-630 have been tested and
+work fine.
+
+If your phone doesnt behave has expected, turn on Asterisk debugging with 'core set debug 1'.
+
+This will log a bunch of debug messages indicating what the phone is doing, importantly the rfcomm
+conversation between Asterisk and the phone. This can be used to sort out what your phone is doing
+and make chan_mobile support it.
+
+Be aware also, that just about all mobile phones behave differently. For example my LG TU500 wont dial unless
+the phone is a the 'idle' screen. i.e. if the phone is showing a 'menu' on the display, when you dial via
+Asterisk, the call will not work. chan_mobile handles this, but there may be other phones that do
+other things too...
+
+Important: Watch what your mobile phone is doing the first few times. Asterisk wont make random calls but
+if chan_mobile fails to hangup for some reason and you get a huge bill from your telco, dont blame me ;)
+
+
+Feedback, Support, Please can you make Mobile Phone X work... etc :-
+
+as always, bugs should be reported at http://bugs.digium.com
+
+email me at   david.bowerman at gmail.com   or dseeb_ on #asterisk & #asterisk-dev irc.
diff --git a/makeopts.in b/makeopts.in
index a81503c..ac67901 100644
--- a/makeopts.in
+++ b/makeopts.in
@@ -67,6 +67,9 @@ AST_DECLARATION_AFTER_STATEMENT=@AST_DECLARATION_AFTER_STATEMENT@
 ASOUND_INCLUDE=@ALSA_INCLUDE@
 ASOUND_LIB=@ALSA_LIB@
 
+BLUETOOTH_LIB=@BLUETOOTH_LIB@
+BLUETOOTH_INCLUDE=@BLUETOOTH_INCLUDE@
+
 CURL_INCLUDE=@CURL_INCLUDE@
 CURL_LIB=@CURL_LIB@
 
-- 
1.5.3.6


asterisk-1.4.16-initscripts.patch:

--- NEW FILE asterisk-1.4.16-initscripts.patch ---
>From cc796206f187ff1d3f4bebde7381fcf5505db759 Mon Sep 17 00:00:00 2001
From: Jeffrey C. Ollie <jeff at ocjtech.us>
Date: Sun, 18 Nov 2007 21:47:59 -0600
Subject: [PATCH] Modify init scripts for better Fedora compatibility.

---
 contrib/init.d/rc.redhat.asterisk |   54 +++++++++++++++----------------------
 contrib/sysconfig/asterisk        |    9 ++++++
 2 files changed, 31 insertions(+), 32 deletions(-)
 create mode 100644 contrib/sysconfig/asterisk

diff --git a/contrib/init.d/rc.redhat.asterisk b/contrib/init.d/rc.redhat.asterisk
index 27d633e..f160af4 100755
--- a/contrib/init.d/rc.redhat.asterisk
+++ b/contrib/init.d/rc.redhat.asterisk
@@ -3,7 +3,7 @@
 #
 # asterisk    Starts, Stops and Reloads Asterisk.
 #
-# chkconfig: 2345 90 60
+# chkconfig: - 90 60
 # description: Asterisk PBX and telephony daemon.
 # processname: asterisk
 # pidfile: /var/run/asterisk.pid
@@ -20,59 +20,49 @@
 # - Added support for -U and -G command line options
 # - Modified "reload" to call asterisk -rx 'reload' 
 
-# Use this option to specify a different configuration directory
-#AST_CONFIG=/etc/asterisk
+# Do not modify this script to change any of the settings, instead
+# edit /etc/sysconfig/asterisk
+
+# Specify the configuration file
+AST_CONFIG=/etc/asterisk/asterisk.conf
 
 # Installation directory
 AST_SBIN=/usr/sbin
 
-# Uncomment the following and set them to the user/groups that you
-# want to run Asterisk as. NOTE: this requires substantial work to
-# be sure that Asterisk's environment has permission to write the
-# files required  for  its  operation, including logs, its comm
-# socket, the asterisk database, etc.
-#AST_USER="asterisk"
-#AST_GROUP="asterisk"
+# The user/group that Asterisk will run as.
+AST_USER="asterisk"
+AST_GROUP="asterisk"
 
-# Source function library.
-. /etc/rc.d/init.d/functions
+# Allow configuration overrides in /etc/sysconfig/asterisk
+CONFIG0=`readlink $0`
+if [ "$CONFIG0" = "" ]; then
+	CONFIGFILE=/etc/sysconfig/`basename $0`
+else
+	CONFIGFILE=/etc/sysconfig/`basename $CONFIG0`
+fi
+[ -f $CONFIGFILE ] && . $CONFIGFILE
 
 if ! [ -x $AST_SBIN/asterisk ] ; then
 	echo "ERROR: $AST_SBIN/asterisk not found"
 	exit 0
 fi
 
-if ! [ -d $AST_CONFIG ] ; then
-	echo "ERROR: $AST_CONFIG directory not found"
+if ! [ -f $AST_CONFIG ] ; then
+	echo "ERROR: $AST_CONFIG not found"
 	exit 0
 fi
 
-# Uncomment this ONLY if you know what you are doing.
-# export LD_ASSUME_KERNEL=2.4.1
+# Source function library.
+. /etc/rc.d/init.d/functions
 
 # Full path to asterisk binary
 DAEMON=$AST_SBIN/asterisk
 
-# Full path to safe_asterisk script
-SAFE_ASTERISK=$AST_SBIN/safe_asterisk
-
-# Allow configuration overrides in /etc/sysconfig/asterisk
-CONFIG0=`readlink $0`
-if [ "$CONFIG0" = "" ]; then
-	CONFIGFILE=/etc/sysconfig/`basename $0`
-else
-	CONFIGFILE=/etc/sysconfig/`basename $CONFIG0`
-fi
-[ -x $CONFIGFILE ] && . $CONFIGFILE
-
 RETVAL=0
 
 start() {
 	# Start daemons.
 	echo -n $"Starting asterisk: "
-        if [ -f $SAFE_ASTERISK ] ; then
-		DAEMON=$SAFE_ASTERISK
-	fi
 	if [ $AST_USER ] ; then
 		ASTARGS="-U $AST_USER"
 	fi
@@ -91,7 +81,7 @@ start() {
 
 stop() {
 	# Stop daemons.
-	echo -n $"Shutting down asterisk: "
+	echo -n $"Stopping asterisk: "
 	killproc asterisk
 	RETVAL=$?
 	[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/asterisk
diff --git a/contrib/sysconfig/asterisk b/contrib/sysconfig/asterisk
new file mode 100644
index 0000000..05f5adb
--- /dev/null
+++ b/contrib/sysconfig/asterisk
@@ -0,0 +1,9 @@
+# Specify the configuration file
+AST_CONFIG=/etc/asterisk/asterisk.conf
+
+# Installation directory
+AST_SBIN=/usr/sbin
+
+# The user/group that Asterisk will run as.
+AST_USER="asterisk"
+AST_GROUP="asterisk"
-- 
1.5.3.6


asterisk-1.4.16-libcap.patch:

--- NEW FILE asterisk-1.4.16-libcap.patch ---
>From a7efa0ed8b28de55ef0fa2b39fefc3753ce1db8a Mon Sep 17 00:00:00 2001
From: Jeffrey C. Ollie <jcollie at pc21224.campus.dmacc.edu>
Date: Thu, 8 Nov 2007 16:42:56 -0600
Subject: [PATCH] Backport patch that lets Asterisk set the TOS byte even when running as non-root.

---
 CHANGES          |    5 +++++
 configure.ac     |    5 +++++
 doc/security.txt |    7 +++++++
 main/Makefile    |    3 +++
 main/asterisk.c  |   30 +++++++++++++++++++++++++-----
 makeopts.in      |    3 +++
 6 files changed, 48 insertions(+), 5 deletions(-)

diff --git a/CHANGES b/CHANGES
index faa1855..7825d58 100644
--- a/CHANGES
+++ b/CHANGES
@@ -339,3 +339,8 @@ Changes since Asterisk 1.2:
          1. aelparse -- compile .ael files outside of asterisk
     * New manager events:
          1. OriginateResponse event comes to replace OriginateSuccess and OriginateFailure
+
+    * Ability to use libcap to set high ToS bits when non-root on
+      Linux. If configure is unable to find libcap then you can use
+      --with-cap to specify the path.
+
diff --git a/configure.ac b/configure.ac
index 1488a1e..17ecb3d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -169,6 +169,7 @@ AC_SUBST(AST_DEVMODE)
 
 AST_EXT_LIB_SETUP([ALSA], [Advanced Linux Sound Architecture], [asound])
 AST_EXT_LIB_SETUP([CURL], [cURL], [curl])
+AST_EXT_LIB_SETUP([CAP], [POSIX 1.e capabilities], [cap])
 AST_EXT_LIB_SETUP([CURSES], [curses], [curses])
 AST_EXT_LIB_SETUP([GNUTLS], [GNU TLS support (used for iksemel only)], [gnutls])
 AST_EXT_LIB_SETUP([GSM], [GSM], [gsm], [, or 'internal'])
@@ -395,6 +396,10 @@ AST_EXT_LIB_CHECK([ALSA], [asound], [snd_spcm_init], [alsa/asoundlib.h], [-lm -l
 
 AST_EXT_LIB_CHECK([CURSES], [curses], [initscr], [curses.h])
 
+if test "x${host_os}" = "xlinux-gnu" ; then
+  AST_EXT_LIB_CHECK([CAP], [cap], [cap_from_text], [sys/capability.h])
+fi
+
 GSM_INTERNAL="yes"
 AC_SUBST(GSM_INTERNAL)
 GSM_SYSTEM="yes"
diff --git a/doc/security.txt b/doc/security.txt
index 0801679..3adf536 100644
--- a/doc/security.txt
+++ b/doc/security.txt
@@ -28,6 +28,13 @@ The IAX2 protocol supports strong RSA key authentication as well as
 AES encryption of voice and signalling. The SIP channel does not
 support encryption in this version of Asterisk.
 
+By default, if you have libcap available, Asterisk will try to retain the
+CAP_NET_ADMIN capability when running as a non-root user. If you do not need
+that capability you may want to configure Asterisk with --without-cap; however,
+this will prevent Asterisk from being able to mark high ToS bits under Linux.
+More information on CAP_NET_ADMIN is available at:
+http://www.lids.org/lids-howto/node48.html
+
 * DIALPLAN SECURITY
 
 First and foremost remember this:
diff --git a/main/Makefile b/main/Makefile
index 4f405b5..cee9e13 100644
--- a/main/Makefile
+++ b/main/Makefile
@@ -55,6 +55,9 @@ ifneq ($(findstring $(OSARCH), linux-gnu uclinux linux-uclibc ),)
   ifneq ($(findstring LOADABLE_MODULES,$(MENUSELECT_CFLAGS)),)
   AST_LIBS+=-ldl
   endif
+  ifneq (x$(CAP_LIB),x)
+    AST_LIBS+=$(CAP_LIB)
+  endif
   AST_LIBS+=-lpthread $(EDITLINE_LIB) -lm -lresolv
 else
   AST_LIBS+=$(EDITLINE_LIB) -lm
diff --git a/main/asterisk.c b/main/asterisk.c
index 202a190..bd8cd9b 100644
--- a/main/asterisk.c
+++ b/main/asterisk.c
@@ -82,13 +82,12 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include <sys/stat.h>
 #ifdef linux
 #include <sys/prctl.h>
-#endif
+#ifdef HAVE_CAP
+#include <sys/capability.h>
+#endif /* HAVE_CAP */
+#endif /* linux */
 #include <regex.h>
 
-#ifdef linux
-#include <sys/prctl.h>
-#endif
-
 #if  defined(__FreeBSD__) || defined( __NetBSD__ ) || defined(SOLARIS)
 #include <netdb.h>
 #if defined(SOLARIS)
@@ -2734,6 +2733,10 @@ int main(int argc, char *argv[])
 	}
 
 	if (runuser && !ast_test_flag(&ast_options, AST_OPT_FLAG_REMOTE)) {
+#ifdef HAVE_CAP
+		cap_t cap;
+		int has_cap = 1;
+#endif /* HAVE_CAP */
 		struct passwd *pw;
 		pw = getpwnam(runuser);
 		if (!pw) {
@@ -2744,6 +2747,12 @@ int main(int argc, char *argv[])
 			ast_log(LOG_ERROR, "Asterisk started as nonroot, but runuser '%s' requested.\n", runuser);
 			exit(1);
 		}
+#ifdef HAVE_CAP
+		if (prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0)) {
+			ast_log(LOG_WARNING, "Unable to keep capabilities.\n");
+			has_cap  = 0;
+		}
+#endif /* HAVE_CAP */
 		if (!rungroup) {
 			if (setgid(pw->pw_gid)) {
 				ast_log(LOG_WARNING, "Unable to setgid to %d!\n", (int)pw->pw_gid);
@@ -2760,6 +2769,17 @@ int main(int argc, char *argv[])
 		}
 		if (option_verbose)
 			ast_verbose("Running as user '%s'\n", runuser);
+#ifdef HAVE_CAP
+		if (has_cap) {
+			cap = cap_from_text("cap_net_admin=ep");
+			if (cap_set_proc(cap)) {
+				ast_log(LOG_WARNING, "Unable to install capabilities.\n");
+			}
+			if (cap_free(cap)) {
+				ast_log(LOG_WARNING, "Unable to drop capabilities.\n");
+			}
+		}
+#endif /* HAVE_CAP */
 	}
 
 #endif /* __CYGWIN__ */
diff --git a/makeopts.in b/makeopts.in
index 8138dd8..a81503c 100644
--- a/makeopts.in
+++ b/makeopts.in
@@ -189,3 +189,6 @@ TERMCAP_DIR=@TERMCAP_DIR@
 TINFO_INCLUDE=@TINFO_INCLUDE@
 TINFO_LIB=@TINFO_LIB@
 TINFO_DIR=@TINFO_DIR@
+
+CAP_LIB=@CAP_LIB@
+CAP_INCLUDE=@CAP_INCLUDE@
-- 
1.5.3.6


asterisk-1.4.16-optimization.patch:

--- NEW FILE asterisk-1.4.16-optimization.patch ---
>From 910a5c383dd583d11010eaed678e249b7f00b6dc Mon Sep 17 00:00:00 2001
From: Jeffrey C. Ollie <jcollie at pc21224.campus.dmacc.edu>
Date: Thu, 8 Nov 2007 16:42:14 -0600
Subject: [PATCH] Pick proper optimization flags for Fedora.

---
 Makefile |   16 ++++++++++++----
 1 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index 04a7b44..e8fae1d 100644
--- a/Makefile
+++ b/Makefile
@@ -196,10 +196,16 @@ ifeq ($(OSARCH),linux-gnu)
 endif
 
 ifeq ($(findstring -save-temps,$(ASTCFLAGS)),)
-ASTCFLAGS+=-pipe
+  ifeq ($(findstring -pipe,$(ASTCFLAGS)),)
+    ASTCFLAGS+=-pipe
+  endif
+endif
+
+ifeq ($(findstring -Wall,$(ASTCFLAGS)),)
+  ASTCFLAGS+=-Wall
 endif
 
-ASTCFLAGS+=-Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG)
+ASTCFLAGS+=-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG)
 
 ASTCFLAGS+=-include $(ASTTOPDIR)/include/asterisk/autoconfig.h
 
@@ -212,8 +218,10 @@ ifneq ($(findstring BSD,$(OSARCH)),)
   ASTLDFLAGS+=-L/usr/local/lib
 endif
 
-ifneq ($(PROC),ultrasparc)
-  ASTCFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi)
+ifeq ($(findstring -march,$(ASTCFLAGS)),)
+  ifneq ($(PROC),ultrasparc)
+    ASTCFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi)
+  endif
 endif
 
 ifeq ($(PROC),ppc)
-- 
1.5.3.6


asterisk-1.4.16-spandspfax.patch:

--- NEW FILE asterisk-1.4.16-spandspfax.patch ---
>From e9bd907b6bc3f68e1cbabe13358472da68d6198a Mon Sep 17 00:00:00 2001
From: Jeffrey C. Ollie <jeff at ocjtech.us>
Date: Mon, 12 Nov 2007 15:51:12 -0600
Subject: [PATCH] Add FAX apps.

---
 apps/app_rxfax.c                 |  380 +++++++++++++++++++++++++++++++++
 apps/app_txfax.c                 |  306 ++++++++++++++++++++++++++
 build_tools/menuselect-deps.in   |    1 +
 configure                        |  436 ++++++++++++++++++++++++++++++++++++++
 configure.ac                     |    3 +
 include/asterisk/autoconfig.h.in |    3 +
 makeopts.in                      |    3 +
 7 files changed, 1132 insertions(+), 0 deletions(-)
 create mode 100644 apps/app_rxfax.c
 create mode 100644 apps/app_txfax.c

diff --git a/apps/app_rxfax.c b/apps/app_rxfax.c
new file mode 100644
index 0000000..bd81ea1
--- /dev/null
+++ b/apps/app_rxfax.c
@@ -0,0 +1,380 @@
+/*
+ * Asterisk -- A telephony toolkit for Linux.
+ *
+ * Trivial application to receive a TIFF FAX file
+ *
+ * Copyright (C) 2003, Steve Underwood
+ *
+ * Steve Underwood <steveu at coppice.org>
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License
+ */
+
+/*** MODULEINFO
+         <depend>spandsp</depend>
+***/
+
+#include "asterisk.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision:$")
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <inttypes.h>
+#include <pthread.h>
+#include <errno.h>
+#include <tiffio.h>
+
+#include <spandsp.h>
+
+#include "asterisk/lock.h"
+#include "asterisk/file.h"
+#include "asterisk/logger.h"
+#include "asterisk/channel.h"
+#include "asterisk/pbx.h"
+#include "asterisk/module.h"
+#include "asterisk/manager.h"
+
+#ifndef AST_MODULE
+#define AST_MODULE "app_rxfax"
+#endif
+
+static char *app = "RxFAX";
+
+static char *synopsis = "Receive a FAX to a file";
+
+static char *descrip =
+"  RxFAX(filename[|caller][|debug]): Receives a FAX from the channel into the\n"
+"given filename. If the file exists it will be overwritten. The file\n"
+"should be in TIFF/F format.\n"
+"The \"caller\" option makes the application behave as a calling machine,\n"
+"rather than the answering machine. The default behaviour is to behave as\n"
+"an answering machine.\n"
+"Uses LOCALSTATIONID to identify itself to the remote end.\n"
+"     LOCALHEADERINFO to generate a header line on each page.\n"
+"Sets REMOTESTATIONID to the sender CSID.\n"
+"     FAXPAGES to the number of pages received.\n"
+"     FAXBITRATE to the transmition rate.\n"
+"     FAXRESOLUTION to the resolution.\n"
+"Returns -1 when the user hangs up.\n"
+"Returns 0 otherwise.\n";
+
+#define MAX_BLOCK_SIZE 240
+
+static void span_message(int level, const char *msg)
+{
+    int ast_level;
+
+    if (level == SPAN_LOG_WARNING)
+        ast_level = __LOG_WARNING;
+    else if (level == SPAN_LOG_WARNING)
+        ast_level = __LOG_WARNING;
+    else
+        ast_level = __LOG_DEBUG;
+    ast_log(ast_level, __FILE__, __LINE__, __PRETTY_FUNCTION__, msg);
+}
+/*- End of function --------------------------------------------------------*/
+
+#if 0
+static void t30_flush(t30_state_t *s, int which)
+{
+    /* TODO: */
+}
+/*- End of function --------------------------------------------------------*/
+#endif
+
+static void phase_e_handler(t30_state_t *s, void *user_data, int result)
+{
+    struct ast_channel *chan;
+    t30_stats_t t;
+    char local_ident[21];
+    char far_ident[21];
+    char buf[11];
+
+    chan = (struct ast_channel *) user_data;
+    if (result == T30_ERR_OK)
+    {
+        t30_get_transfer_statistics(s, &t);
+        t30_get_far_ident(s, far_ident);
+        t30_get_local_ident(s, local_ident);
+        ast_log(LOG_DEBUG, "==============================================================================\n");
+        ast_log(LOG_DEBUG, "Fax successfully received.\n");
+        ast_log(LOG_DEBUG, "Remote station id: %s\n", far_ident);
+        ast_log(LOG_DEBUG, "Local station id:  %s\n", local_ident);
+        ast_log(LOG_DEBUG, "Pages transferred: %i\n", t.pages_transferred);
+        ast_log(LOG_DEBUG, "Image resolution:  %i x %i\n", t.x_resolution, t.y_resolution);
+        ast_log(LOG_DEBUG, "Transfer Rate:     %i\n", t.bit_rate);
+        ast_log(LOG_DEBUG, "==============================================================================\n");
+        manager_event(EVENT_FLAG_CALL,
+                      "FaxReceived", "Channel: %s\nExten: %s\nCallerID: %s\nRemoteStationID: %s\nLocalStationID: %s\nPagesTransferred: %i\nResolution: %i\nTransferRate: %i\nFileName: %s\n",
+                      chan->name,
+                      chan->exten,
+                      (chan->cid.cid_num)  ?  chan->cid.cid_num  :  "",
+                      far_ident,
+                      local_ident,
+                      t.pages_transferred,
+                      t.y_resolution,
+                      t.bit_rate,
+                      s->rx_file);
+        pbx_builtin_setvar_helper(chan, "REMOTESTATIONID", far_ident);
+        snprintf(buf, sizeof(buf), "%i", t.pages_transferred);
+        pbx_builtin_setvar_helper(chan, "FAXPAGES", buf);
+        snprintf(buf, sizeof(buf), "%i", t.y_resolution);
+        pbx_builtin_setvar_helper(chan, "FAXRESOLUTION", buf);
+        snprintf(buf, sizeof(buf), "%i", t.bit_rate);
+        pbx_builtin_setvar_helper(chan, "FAXBITRATE", buf);
+    }
+    else
+    {
+        ast_log(LOG_DEBUG, "==============================================================================\n");
+        ast_log(LOG_DEBUG, "Fax receive not successful - result (%d) %s.\n", result, t30_completion_code_to_str(result));
+        ast_log(LOG_DEBUG, "==============================================================================\n");
+    }
+}
+/*- End of function --------------------------------------------------------*/
+
+static void phase_d_handler(t30_state_t *s, void *user_data, int result)
+{
+    struct ast_channel *chan;
+    t30_stats_t t;
+
+    chan = (struct ast_channel *) user_data;
+    if (result)
+    {
+        t30_get_transfer_statistics(s, &t);
+        ast_log(LOG_DEBUG, "==============================================================================\n");
+        ast_log(LOG_DEBUG, "Pages transferred:  %i\n", t.pages_transferred);
+        ast_log(LOG_DEBUG, "Image size:         %i x %i\n", t.width, t.length);
+        ast_log(LOG_DEBUG, "Image resolution    %i x %i\n", t.x_resolution, t.y_resolution);
+        ast_log(LOG_DEBUG, "Transfer Rate:      %i\n", t.bit_rate);
+        ast_log(LOG_DEBUG, "Bad rows            %i\n", t.bad_rows);
+        ast_log(LOG_DEBUG, "Longest bad row run %i\n", t.longest_bad_row_run);
+        ast_log(LOG_DEBUG, "Compression type    %i\n", t.encoding);
+        ast_log(LOG_DEBUG, "Image size (bytes)  %i\n", t.image_size);
+        ast_log(LOG_DEBUG, "==============================================================================\n");
+    }
+}
+/*- End of function --------------------------------------------------------*/
+
+static int rxfax_exec(struct ast_channel *chan, void *data)
+{
+    int res = 0;
+    char template_file[256];
+    char target_file[256];
+    char *s;
+    char *t;
+    char *v;
+    const char *x;
+    int option;
+    int len;
+    int i;
+    fax_state_t fax;
+    int calling_party;
+    int verbose;
+    int samples;
+
+    struct ast_module_user *u;
+    struct ast_frame *inf = NULL;
+    struct ast_frame outf;
+
+    int original_read_fmt;
+    int original_write_fmt;
+
+    uint8_t __buf[sizeof(uint16_t)*MAX_BLOCK_SIZE + 2*AST_FRIENDLY_OFFSET];
+    uint8_t *buf = __buf + AST_FRIENDLY_OFFSET;
+
+    if (chan == NULL)
+    {
+        ast_log(LOG_WARNING, "Fax receive channel is NULL. Giving up.\n");
+        return -1;
+    }
+
+    span_set_message_handler(span_message);
+
+    /* The next few lines of code parse out the filename and header from the input string */
+    if (data == NULL)
+    {
+        /* No data implies no filename or anything is present */
+        ast_log(LOG_WARNING, "Rxfax requires an argument (filename)\n");
+        return -1;
+    }
+
+    calling_party = FALSE;
+    verbose = FALSE;
+    target_file[0] = '\0';
+
+    for (option = 0, v = s = data;  v;  option++, s++)
+    {
+        t = s;
+        v = strchr(s, '|');
+        s = (v)  ?  v  :  s + strlen(s);
+        strncpy((char *) buf, t, s - t);
+        buf[s - t] = '\0';
+        if (option == 0)
+        {
+            /* The first option is always the file name */
+            len = s - t;
+            if (len > 255)
+                len = 255;
+            strncpy(target_file, t, len);
+            target_file[len] = '\0';
+            /* Allow the use of %d in the file name for a wild card of sorts, to
+               create a new file with the specified name scheme */
+            if ((x = strchr(target_file, '%'))  &&  x[1] == 'd')
+            {
+                strcpy(template_file, target_file);
+                i = 0;
+                do
+                {
+                    snprintf(target_file, 256, template_file, 1);
+                    i++;
+                }
+                while (ast_fileexists(target_file, "", chan->language) != -1);
+            }
+        }
+        else if (strncmp("caller", t, s - t) == 0)
+        {
+            calling_party = TRUE;
+        }
+        else if (strncmp("debug", t, s - t) == 0)
+        {
+            verbose = TRUE;
+        }
+    }
+
+    /* Done parsing */
+
+    u = ast_module_user_add(chan);
+
+    if (chan->_state != AST_STATE_UP)
+    {
+        /* Shouldn't need this, but checking to see if channel is already answered
+         * Theoretically asterisk should already have answered before running the app */
+        res = ast_answer(chan);
+    }
+
+    if (!res)
+    {
+        original_read_fmt = chan->readformat;
+        if (original_read_fmt != AST_FORMAT_SLINEAR)
+        {
+            res = ast_set_read_format(chan, AST_FORMAT_SLINEAR);
+            if (res < 0)
+            {
+                ast_log(LOG_WARNING, "Unable to set to linear read mode, giving up\n");
+                return -1;
+            }
+        }
+        original_write_fmt = chan->writeformat;
+        if (original_write_fmt != AST_FORMAT_SLINEAR)
+        {
+            res = ast_set_write_format(chan, AST_FORMAT_SLINEAR);
+            if (res < 0)
+            {
+                ast_log(LOG_WARNING, "Unable to set to linear write mode, giving up\n");
+                res = ast_set_read_format(chan, original_read_fmt);
+                if (res)
+                    ast_log(LOG_WARNING, "Unable to restore read format on '%s'\n", chan->name);
+                return -1;
+            }
+        }
+        fax_init(&fax, calling_party);
+        if (verbose)
+            fax.logging.level = SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW;
+        x = pbx_builtin_getvar_helper(chan, "LOCALSTATIONID");
+        if (x  &&  x[0])
+            t30_set_local_ident(&fax.t30_state, x);
+        x = pbx_builtin_getvar_helper(chan, "LOCALHEADERINFO");
+        if (x  &&  x[0])
+            t30_set_header_info(&fax.t30_state, x);
+        t30_set_rx_file(&fax.t30_state, target_file, -1);
+        //t30_set_phase_b_handler(&fax.t30_state, phase_b_handler, chan);
+        t30_set_phase_d_handler(&fax.t30_state, phase_d_handler, chan);
+        t30_set_phase_e_handler(&fax.t30_state, phase_e_handler, chan);
+        t30_set_ecm_capability(&fax.t30_state, TRUE);
+        t30_set_supported_compressions(&fax.t30_state, T30_SUPPORT_T4_1D_COMPRESSION | T30_SUPPORT_T4_2D_COMPRESSION | T30_SUPPORT_T6_COMPRESSION);
+        while (ast_waitfor(chan, -1) > -1)
+        {
+            inf = ast_read(chan);
+            if (inf == NULL)
+            {
+                res = -1;
+                break;
+            }
+            if (inf->frametype == AST_FRAME_VOICE)
+            {
+                if (fax_rx(&fax, inf->data, inf->samples))
+                    break;
+                samples = (inf->samples <= MAX_BLOCK_SIZE)  ?  inf->samples  :  MAX_BLOCK_SIZE;
+                len = fax_tx(&fax, (int16_t *) &buf[AST_FRIENDLY_OFFSET], samples);
+                if (len)
+                {
+                    memset(&outf, 0, sizeof(outf));
+                    outf.frametype = AST_FRAME_VOICE;
+                    outf.subclass = AST_FORMAT_SLINEAR;
+                    outf.datalen = len*sizeof(int16_t);
+                    outf.samples = len;
+                    outf.data = &buf[AST_FRIENDLY_OFFSET];
+                    outf.offset = AST_FRIENDLY_OFFSET;
+                    outf.src = "RxFAX";
+                    if (ast_write(chan, &outf) < 0)
+                    {
+                        ast_log(LOG_WARNING, "Unable to write frame to channel; %s\n", strerror(errno));
+                        break;
+                    }
+                }
+            }
+            ast_frfree(inf);
+        }
+        if (inf == NULL)
+        {
+            ast_log(LOG_DEBUG, "Got hangup\n");
+            res = -1;
+        }
+        if (original_read_fmt != AST_FORMAT_SLINEAR)
+        {
+            res = ast_set_read_format(chan, original_read_fmt);
+            if (res)
+                ast_log(LOG_WARNING, "Unable to restore read format on '%s'\n", chan->name);
+        }
+        if (original_write_fmt != AST_FORMAT_SLINEAR)
+        {
+            res = ast_set_write_format(chan, original_write_fmt);
+            if (res)
+                ast_log(LOG_WARNING, "Unable to restore write format on '%s'\n", chan->name);
+        }
+        t30_terminate(&fax.t30_state);
+    }
+    else
+    {
+        ast_log(LOG_WARNING, "Could not answer channel '%s'\n", chan->name);
+    }
+    ast_module_user_remove(u);
+    return res;
+}
+/*- End of function --------------------------------------------------------*/
+
+static int unload_module(void)
+{
+	int res;
+
+	ast_module_user_hangup_all();
+
+	res = ast_unregister_application(app);
+
+
+	return res;
+}
+/*- End of function --------------------------------------------------------*/
+
+static int load_module(void)
+{
+	return ast_register_application(app, rxfax_exec, synopsis, descrip);
+}
+/*- End of function --------------------------------------------------------*/
+
+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Trivial FAX Receive Application");
+
+/*- End of file ------------------------------------------------------------*/
diff --git a/apps/app_txfax.c b/apps/app_txfax.c
new file mode 100644
index 0000000..713ecf1
--- /dev/null
+++ b/apps/app_txfax.c
@@ -0,0 +1,306 @@
+/*
+ * Asterisk -- A telephony toolkit for Linux.
+ *
+ * Trivial application to send a TIFF file as a FAX
+ *
+ * Copyright (C) 2003, Steve Underwood
+ *
+ * Steve Underwood <steveu at coppice.org>
+ *
+ * This program is free software, distributed under the terms of
+ * the GNU General Public License
+ */
+
+/*** MODULEINFO
+         <depend>spandsp</depend>
+***/
+
+#include "asterisk.h"
+
+ASTERISK_FILE_VERSION(__FILE__, "$Revision:$")
+
+#include <string.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <inttypes.h>
+#include <pthread.h>
+#include <errno.h>
+#include <tiffio.h>
+
+#include <spandsp.h>
+
+#include "asterisk/lock.h"
+#include "asterisk/file.h"
+#include "asterisk/logger.h"
+#include "asterisk/channel.h"
+#include "asterisk/pbx.h"
+#include "asterisk/module.h"
+
+#ifndef AST_MODULE
+#define AST_MODULE "app_txfax"
+#endif
+
+static char *app = "TxFAX";
+
+static char *synopsis = "Send a FAX file";
+
+static char *descrip =
+"  TxFAX(filename[|caller][|debug]):  Send a given TIFF file to the channel as a FAX.\n"
+"The \"caller\" option makes the application behave as a calling machine,\n"
+"rather than the answering machine. The default behaviour is to behave as\n"
+"an answering machine.\n"
+"Uses LOCALSTATIONID to identify itself to the remote end.\n"
+"     LOCALHEADERINFO to generate a header line on each page.\n"
+"Sets REMOTESTATIONID to the receiver CSID.\n"
+"Returns -1 when the user hangs up, or if the file does not exist.\n"
+"Returns 0 otherwise.\n";
+
+#define MAX_BLOCK_SIZE 240
+
+static void span_message(int level, const char *msg)
+{
+    int ast_level;
+
+    if (level == SPAN_LOG_WARNING)
+        ast_level = __LOG_WARNING;
+    else if (level == SPAN_LOG_WARNING)
+        ast_level = __LOG_WARNING;
+    else
+        ast_level = __LOG_DEBUG;
+    ast_log(ast_level, __FILE__, __LINE__, __PRETTY_FUNCTION__, msg);
+}
+/*- End of function --------------------------------------------------------*/
+
+#if 0
+static void t30_flush(t30_state_t *s, int which)
+{
+    /* TODO: */
+}
+/*- End of function --------------------------------------------------------*/
+#endif
+
+static void phase_e_handler(t30_state_t *s, void *user_data, int result)
+{
+    struct ast_channel *chan;
+    char far_ident[21];
+
+    chan = (struct ast_channel *) user_data;
+    if (result == T30_ERR_OK)
+    {
+        t30_get_far_ident(s, far_ident);
+        pbx_builtin_setvar_helper(chan, "REMOTESTATIONID", far_ident);
+    }
+    else
+    {
+        ast_log(LOG_DEBUG, "==============================================================================\n");
+        ast_log(LOG_DEBUG, "Fax send not successful - result (%d) %s.\n", result, t30_completion_code_to_str(result));
+        ast_log(LOG_DEBUG, "==============================================================================\n");
+    }
+}
+/*- End of function --------------------------------------------------------*/
+
+static int txfax_exec(struct ast_channel *chan, void *data)
+{
+    int res = 0;
+    char source_file[256];
+    char *s;
+    char *t;
+    char *v;
+    const char *x;
+    int option;
+    int len;
+    fax_state_t fax;
+    int calling_party;
+    int verbose;
+    int samples;
+
+    struct ast_module_user *u;
+    struct ast_frame *inf = NULL;
+    struct ast_frame outf;
+
+    int original_read_fmt;
+    int original_write_fmt;
+
+    uint8_t __buf[sizeof(uint16_t)*MAX_BLOCK_SIZE + 2*AST_FRIENDLY_OFFSET];
+    uint8_t *buf = __buf + AST_FRIENDLY_OFFSET;
+
+    if (chan == NULL)
+    {
+        ast_log(LOG_WARNING, "Fax transmit channel is NULL. Giving up.\n");
+        return -1;
+    }
+
+    span_set_message_handler(span_message);
+
+    /* The next few lines of code parse out the filename and header from the input string */
+    if (data == NULL)
+    {
+        /* No data implies no filename or anything is present */
+        ast_log(LOG_WARNING, "Txfax requires an argument (filename)\n");
+        return -1;
+    }
+
+    calling_party = FALSE;
+    verbose = FALSE;
+    source_file[0] = '\0';
+
+    for (option = 0, v = s = data;  v;  option++, s++)
+    {
+        t = s;
+        v = strchr(s, '|');
+        s = (v)  ?  v  :  s + strlen(s);
+        strncpy((char *) buf, t, s - t);
+        buf[s - t] = '\0';
+        if (option == 0)
+        {
+            /* The first option is always the file name */
+            len = s - t;
+            if (len > 255)
+                len = 255;
+            strncpy(source_file, t, len);
+            source_file[len] = '\0';
+        }
+        else if (strncmp("caller", t, s - t) == 0)
+        {
+            calling_party = TRUE;
+        }
+        else if (strncmp("debug", t, s - t) == 0)
+        {
+            verbose = TRUE;
+        }
+    }
+
+    /* Done parsing */
+
+    u = ast_module_user_add(chan);
+
+    if (chan->_state != AST_STATE_UP)
+    {
+        /* Shouldn't need this, but checking to see if channel is already answered
+         * Theoretically asterisk should already have answered before running the app */
+        res = ast_answer(chan);
+    }
+
+    if (!res)
+    {
+        original_read_fmt = chan->readformat;
+        if (original_read_fmt != AST_FORMAT_SLINEAR)
+        {
+            res = ast_set_read_format(chan, AST_FORMAT_SLINEAR);
+            if (res < 0)
+            {
+                ast_log(LOG_WARNING, "Unable to set to linear read mode, giving up\n");
+                return -1;
+            }
+        }
+        original_write_fmt = chan->writeformat;
+        if (original_write_fmt != AST_FORMAT_SLINEAR)
+        {
+            res = ast_set_write_format(chan, AST_FORMAT_SLINEAR);
+            if (res < 0)
+            {
+                ast_log(LOG_WARNING, "Unable to set to linear write mode, giving up\n");
+                res = ast_set_read_format(chan, original_read_fmt);
+                if (res)
+                    ast_log(LOG_WARNING, "Unable to restore read format on '%s'\n", chan->name);
+                return -1;
+            }
+        }
+        fax_init(&fax, calling_party);
+        if (verbose)
+	    fax.logging.level = SPAN_LOG_SHOW_SEVERITY | SPAN_LOG_SHOW_PROTOCOL | SPAN_LOG_FLOW;
+
+        x = pbx_builtin_getvar_helper(chan, "LOCALSTATIONID");
+        if (x  &&  x[0])
+            t30_set_local_ident(&fax.t30_state, x);
+        x = pbx_builtin_getvar_helper(chan, "LOCALHEADERINFO");
+        if (x  &&  x[0])
+            t30_set_header_info(&fax.t30_state, x);
+        t30_set_tx_file(&fax.t30_state, source_file, -1, -1);
+        //t30_set_phase_b_handler(&fax.t30_state, phase_b_handler, chan);
+        //t30_set_phase_d_handler(&fax.t30_state, phase_d_handler, chan);
+        t30_set_phase_e_handler(&fax.t30_state, phase_e_handler, chan);
+        t30_set_ecm_capability(&fax.t30_state, TRUE);
+        t30_set_supported_compressions(&fax.t30_state, T30_SUPPORT_T4_1D_COMPRESSION | T30_SUPPORT_T4_2D_COMPRESSION | T30_SUPPORT_T6_COMPRESSION);
+        while (ast_waitfor(chan, -1) > -1)
+        {
+            inf = ast_read(chan);
+            if (inf == NULL)
+            {
+                res = -1;
+                break;
+            }
+            if (inf->frametype == AST_FRAME_VOICE)
+            {
+                if (fax_rx(&fax, inf->data, inf->samples))
+                    break;
+                samples = (inf->samples <= MAX_BLOCK_SIZE)  ?  inf->samples  :  MAX_BLOCK_SIZE;
+                len = fax_tx(&fax, (int16_t *) &buf[AST_FRIENDLY_OFFSET], samples);
+                if (len)
+                {
+                    memset(&outf, 0, sizeof(outf));
+                    outf.frametype = AST_FRAME_VOICE;
+                    outf.subclass = AST_FORMAT_SLINEAR;
+                    outf.datalen = len*sizeof(int16_t);
+                    outf.samples = len;
+                    outf.data = &buf[AST_FRIENDLY_OFFSET];
+                    outf.offset = AST_FRIENDLY_OFFSET;
+                    if (ast_write(chan, &outf) < 0)
+                    {
+                        ast_log(LOG_WARNING, "Unable to write frame to channel; %s\n", strerror(errno));
+                        break;
+                    }
+                }
+            }
+            ast_frfree(inf);
+        }
+        if (inf == NULL)
+        {
+            ast_log(LOG_DEBUG, "Got hangup\n");
+            res = -1;
+        }
+        if (original_read_fmt != AST_FORMAT_SLINEAR)
+        {
+            res = ast_set_read_format(chan, original_read_fmt);
+            if (res)
+                ast_log(LOG_WARNING, "Unable to restore read format on '%s'\n", chan->name);
+        }
+        if (original_write_fmt != AST_FORMAT_SLINEAR)
+        {
+            res = ast_set_write_format(chan, original_write_fmt);
+            if (res)
+                ast_log(LOG_WARNING, "Unable to restore write format on '%s'\n", chan->name);
+        }
+        t30_terminate(&fax.t30_state);
+    }
+    else
+    {
+        ast_log(LOG_WARNING, "Could not answer channel '%s'\n", chan->name);
+    }
+    ast_module_user_remove(u);
+    return res;
+}
+/*- End of function --------------------------------------------------------*/
+
+static int unload_module(void)
+{
+	int res;
+
+	ast_module_user_hangup_all();
+
+	res = ast_unregister_application(app);
+
+
+	return res;
+}
+/*- End of function --------------------------------------------------------*/
+
+static int load_module(void)
+{
+    return ast_register_application(app, txfax_exec, synopsis, descrip);
+}
+/*- End of function --------------------------------------------------------*/
+
+AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Trivial FAX Transmit Application");
+
+/*- End of file ------------------------------------------------------------*/
diff --git a/build_tools/menuselect-deps.in b/build_tools/menuselect-deps.in
index 60a53b4..fb10545 100644
--- a/build_tools/menuselect-deps.in
+++ b/build_tools/menuselect-deps.in
@@ -22,6 +22,7 @@ POPT=@PBX_POPT@
 PRI=@PBX_PRI@
 QT=@PBX_QT@
 RADIUS=@PBX_RADIUS@
+SPANDSP=@PBX_SPANDSP@
 SPEEX=@PBX_SPEEX@
 SQLITE=@PBX_SQLITE@
 SSL=@PBX_OPENSSL@
diff --git a/configure b/configure
index fb3bdbf..8fcf1b9 100755
--- a/configure
+++ b/configure
@@ -821,6 +821,10 @@ RADIUS_LIB
 RADIUS_INCLUDE
 RADIUS_DIR
 PBX_RADIUS
+SPANDSP_LIB
+SPANDSP_INCLUDE
+SPANDSP_DIR
+PBX_SPANDSP
 SPEEX_LIB
 SPEEX_INCLUDE
 SPEEX_DIR
@@ -1532,6 +1536,7 @@ Optional Packages:
   --with-h323=PATH        use OpenH323 files in PATH
   --with-qt=PATH          use Qt files in PATH
   --with-radius=PATH      use Radius Client files in PATH
+  --with-spandsp=PATH     use spandsp Library files in PATH
   --with-speex=PATH       use Speex files in PATH
   --with-sqlite=PATH      use SQLite files in PATH
   --with-suppserv=PATH    use mISDN Supplemental Services files in PATH
@@ -8365,6 +8370,34 @@ PBX_RADIUS=0
 
 
 
+SPANDSP_DESCRIP="spandsp Library"
+SPANDSP_OPTION="spandsp"
+
+# Check whether --with-spandsp was given.
+if test "${with_spandsp+set}" = set; then
+  withval=$with_spandsp;
+case ${withval} in
+     n|no)
+     USE_SPANDSP=no
+     ;;
+     y|ye|yes)
+     SPANDSP_MANDATORY="yes"
+     ;;
+     *)
+     SPANDSP_DIR="${withval}"
+     SPANDSP_MANDATORY="yes"
+     ;;
+esac
+
+fi
+
+PBX_SPANDSP=0
+
+
+
+
+
+
 SPEEX_DESCRIP="Speex"
 SPEEX_OPTION="speex"
 
@@ -27885,6 +27918,405 @@ fi
 
 
 
+if test "${USE_SPANDSP}" != "no"; then
+   pbxlibdir=""
+   if test "x${SPANDSP_DIR}" != "x"; then
+      if test -d ${SPANDSP_DIR}/lib; then
+	 pbxlibdir="-L${SPANDSP_DIR}/lib"
+      else
+	 pbxlibdir="-L${SPANDSP_DIR}"
+      fi
+   fi
+   { echo "$as_me:$LINENO: checking for fax_init in -lspandsp" >&5
+echo $ECHO_N "checking for fax_init in -lspandsp... $ECHO_C" >&6; }
+if test "${ac_cv_lib_spandsp_fax_init+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lspandsp ${pbxlibdir} -ltiff $LIBS"
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char fax_init ();
+int
+main ()
+{
+return fax_init ();
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.$ac_objext conftest$ac_exeext
+if { (ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_link") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest$ac_exeext &&
+       $as_test_x conftest$ac_exeext; then
+  ac_cv_lib_spandsp_fax_init=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_cv_lib_spandsp_fax_init=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
+      conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_lib_spandsp_fax_init" >&5
+echo "${ECHO_T}$ac_cv_lib_spandsp_fax_init" >&6; }
+if test $ac_cv_lib_spandsp_fax_init = yes; then
+  AST_SPANDSP_FOUND=yes
+else
+  AST_SPANDSP_FOUND=no
+fi
+
+
+   if test "${AST_SPANDSP_FOUND}" = "yes"; then
+      SPANDSP_LIB="-lspandsp -ltiff"
+      SPANDSP_HEADER_FOUND="1"
+      if test "x${SPANDSP_DIR}" != "x"; then
+         SPANDSP_LIB="${pbxlibdir} ${SPANDSP_LIB}"
+	 SPANDSP_INCLUDE="-I${SPANDSP_DIR}/include"
+	 saved_cppflags="${CPPFLAGS}"
+	 CPPFLAGS="${CPPFLAGS} -I${SPANDSP_DIR}/include"
+	 if test "xspandsp.h" != "x" ; then
+	    as_ac_Header=`echo "ac_cv_header_${SPANDSP_DIR}/include/spandsp.h" | $as_tr_sh`
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  { echo "$as_me:$LINENO: checking for ${SPANDSP_DIR}/include/spandsp.h" >&5
+echo $ECHO_N "checking for ${SPANDSP_DIR}/include/spandsp.h... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking ${SPANDSP_DIR}/include/spandsp.h usability" >&5
+echo $ECHO_N "checking ${SPANDSP_DIR}/include/spandsp.h usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <${SPANDSP_DIR}/include/spandsp.h>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking ${SPANDSP_DIR}/include/spandsp.h presence" >&5
+echo $ECHO_N "checking ${SPANDSP_DIR}/include/spandsp.h presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <${SPANDSP_DIR}/include/spandsp.h>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: ${SPANDSP_DIR}/include/spandsp.h: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: ${SPANDSP_DIR}/include/spandsp.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ${SPANDSP_DIR}/include/spandsp.h: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: ${SPANDSP_DIR}/include/spandsp.h: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: ${SPANDSP_DIR}/include/spandsp.h: present but cannot be compiled" >&5
+echo "$as_me: WARNING: ${SPANDSP_DIR}/include/spandsp.h: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ${SPANDSP_DIR}/include/spandsp.h:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: ${SPANDSP_DIR}/include/spandsp.h:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ${SPANDSP_DIR}/include/spandsp.h: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: ${SPANDSP_DIR}/include/spandsp.h: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ${SPANDSP_DIR}/include/spandsp.h:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: ${SPANDSP_DIR}/include/spandsp.h:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ${SPANDSP_DIR}/include/spandsp.h: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: ${SPANDSP_DIR}/include/spandsp.h: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: ${SPANDSP_DIR}/include/spandsp.h: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: ${SPANDSP_DIR}/include/spandsp.h: in the future, the compiler will take precedence" >&2;}
+
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for ${SPANDSP_DIR}/include/spandsp.h" >&5
+echo $ECHO_N "checking for ${SPANDSP_DIR}/include/spandsp.h... $ECHO_C" >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  eval "$as_ac_Header=\$ac_header_preproc"
+fi
+ac_res=`eval echo '${'$as_ac_Header'}'`
+	       { echo "$as_me:$LINENO: result: $ac_res" >&5
+echo "${ECHO_T}$ac_res" >&6; }
+
+fi
+if test `eval echo '${'$as_ac_Header'}'` = yes; then
+  SPANDSP_HEADER_FOUND=1
+else
+  SPANDSP_HEADER_FOUND=0
+fi
+
+
+	 fi
+	 CPPFLAGS="${saved_cppflags}"
+      else
+	 if test "xspandsp.h" != "x" ; then
+            if test "${ac_cv_header_spandsp_h+set}" = set; then
+  { echo "$as_me:$LINENO: checking for spandsp.h" >&5
+echo $ECHO_N "checking for spandsp.h... $ECHO_C" >&6; }
+if test "${ac_cv_header_spandsp_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_header_spandsp_h" >&5
+echo "${ECHO_T}$ac_cv_header_spandsp_h" >&6; }
+else
+  # Is the header compilable?
+{ echo "$as_me:$LINENO: checking spandsp.h usability" >&5
+echo $ECHO_N "checking spandsp.h usability... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+$ac_includes_default
+#include <spandsp.h>
+_ACEOF
+rm -f conftest.$ac_objext
+if { (ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_compile") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } && {
+	 test -z "$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then
+  ac_header_compiler=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_header_compiler=no
+fi
+
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_compiler" >&5
+echo "${ECHO_T}$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ echo "$as_me:$LINENO: checking spandsp.h presence" >&5
+echo $ECHO_N "checking spandsp.h presence... $ECHO_C" >&6; }
+cat >conftest.$ac_ext <<_ACEOF
+/* confdefs.h.  */
+_ACEOF
+cat confdefs.h >>conftest.$ac_ext
+cat >>conftest.$ac_ext <<_ACEOF
+/* end confdefs.h.  */
+#include <spandsp.h>
+_ACEOF
+if { (ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval "echo \"\$as_me:$LINENO: $ac_try_echo\"") >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.er1
+  ac_status=$?
+  grep -v '^ *+' conftest.er1 >conftest.err
+  rm -f conftest.er1
+  cat conftest.err >&5
+  echo "$as_me:$LINENO: \$? = $ac_status" >&5
+  (exit $ac_status); } >/dev/null && {
+	 test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+	 test ! -s conftest.err
+       }; then
+  ac_header_preproc=yes
+else
+  echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+  ac_header_preproc=no
+fi
+
+rm -f conftest.err conftest.$ac_ext
+{ echo "$as_me:$LINENO: result: $ac_header_preproc" >&5
+echo "${ECHO_T}$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in
+  yes:no: )
+    { echo "$as_me:$LINENO: WARNING: spandsp.h: accepted by the compiler, rejected by the preprocessor!" >&5
+echo "$as_me: WARNING: spandsp.h: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { echo "$as_me:$LINENO: WARNING: spandsp.h: proceeding with the compiler's result" >&5
+echo "$as_me: WARNING: spandsp.h: proceeding with the compiler's result" >&2;}
+    ac_header_preproc=yes
+    ;;
+  no:yes:* )
+    { echo "$as_me:$LINENO: WARNING: spandsp.h: present but cannot be compiled" >&5
+echo "$as_me: WARNING: spandsp.h: present but cannot be compiled" >&2;}
+    { echo "$as_me:$LINENO: WARNING: spandsp.h:     check for missing prerequisite headers?" >&5
+echo "$as_me: WARNING: spandsp.h:     check for missing prerequisite headers?" >&2;}
+    { echo "$as_me:$LINENO: WARNING: spandsp.h: see the Autoconf documentation" >&5
+echo "$as_me: WARNING: spandsp.h: see the Autoconf documentation" >&2;}
+    { echo "$as_me:$LINENO: WARNING: spandsp.h:     section \"Present But Cannot Be Compiled\"" >&5
+echo "$as_me: WARNING: spandsp.h:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { echo "$as_me:$LINENO: WARNING: spandsp.h: proceeding with the preprocessor's result" >&5
+echo "$as_me: WARNING: spandsp.h: proceeding with the preprocessor's result" >&2;}
+    { echo "$as_me:$LINENO: WARNING: spandsp.h: in the future, the compiler will take precedence" >&5
+echo "$as_me: WARNING: spandsp.h: in the future, the compiler will take precedence" >&2;}
+
+    ;;
+esac
+{ echo "$as_me:$LINENO: checking for spandsp.h" >&5
+echo $ECHO_N "checking for spandsp.h... $ECHO_C" >&6; }
+if test "${ac_cv_header_spandsp_h+set}" = set; then
+  echo $ECHO_N "(cached) $ECHO_C" >&6
+else
+  ac_cv_header_spandsp_h=$ac_header_preproc
+fi
+{ echo "$as_me:$LINENO: result: $ac_cv_header_spandsp_h" >&5
+echo "${ECHO_T}$ac_cv_header_spandsp_h" >&6; }
+
+fi
+if test $ac_cv_header_spandsp_h = yes; then
+  SPANDSP_HEADER_FOUND=1
+else
+  SPANDSP_HEADER_FOUND=0
+fi
+
+
+	 fi
+      fi
+      if test "x${SPANDSP_HEADER_FOUND}" = "x0" ; then
+         if test -n "${SPANDSP_MANDATORY}" ;
+         then
+            { echo "$as_me:$LINENO: ***" >&5
+echo "$as_me: ***" >&6;}
+            { echo "$as_me:$LINENO: *** It appears that you do not have the spandsp development package installed." >&5
+echo "$as_me: *** It appears that you do not have the spandsp development package installed." >&6;}
+            { echo "$as_me:$LINENO: *** Please install it to include ${SPANDSP_DESCRIP} support, or re-run configure" >&5
+echo "$as_me: *** Please install it to include ${SPANDSP_DESCRIP} support, or re-run configure" >&6;}
+            { echo "$as_me:$LINENO: *** without explicitly specifying --with-${SPANDSP_OPTION}" >&5
+echo "$as_me: *** without explicitly specifying --with-${SPANDSP_OPTION}" >&6;}
+            exit 1
+         fi
+         SPANDSP_LIB=""
+         SPANDSP_INCLUDE=""
+         PBX_SPANDSP=0
+      else
+         PBX_SPANDSP=1
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_SPANDSP 1
+_ACEOF
+
+      fi
+   elif test -n "${SPANDSP_MANDATORY}";
+   then
+      { echo "$as_me:$LINENO: ***" >&5
+echo "$as_me: ***" >&6;}
+      { echo "$as_me:$LINENO: *** The ${SPANDSP_DESCRIP} installation on this system appears to be broken." >&5
+echo "$as_me: *** The ${SPANDSP_DESCRIP} installation on this system appears to be broken." >&6;}
+      { echo "$as_me:$LINENO: *** Either correct the installation, or run configure" >&5
+echo "$as_me: *** Either correct the installation, or run configure" >&6;}
+      { echo "$as_me:$LINENO: *** without explicitly specifying --with-${SPANDSP_OPTION}" >&5
+echo "$as_me: *** without explicitly specifying --with-${SPANDSP_OPTION}" >&6;}
+      exit 1
+   fi
+fi
+
+
+
 if test "${USE_SPEEX}" != "no"; then
    pbxlibdir=""
    if test "x${SPEEX_DIR}" != "x"; then
@@ -34376,6 +34808,10 @@ RADIUS_LIB!$RADIUS_LIB$ac_delim
 RADIUS_INCLUDE!$RADIUS_INCLUDE$ac_delim
 RADIUS_DIR!$RADIUS_DIR$ac_delim
 PBX_RADIUS!$PBX_RADIUS$ac_delim
+SPANDSP_LIB!$SPANDSP_LIB$ac_delim
+SPANDSP_INCLUDE!$SPANDSP_INCLUDE$ac_delim
+SPANDSP_DIR!$SPANDSP_DIR$ac_delim
+PBX_SPANDSP!$PBX_SPANDSP$ac_delim
 SPEEX_LIB!$SPEEX_LIB$ac_delim
 SPEEX_INCLUDE!$SPEEX_INCLUDE$ac_delim
 SPEEX_DIR!$SPEEX_DIR$ac_delim
diff --git a/configure.ac b/configure.ac
index 4b074ba..1488a1e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -193,6 +193,7 @@ AST_EXT_LIB_SETUP([PWLIB], [PWlib], [pwlib])
 AST_EXT_LIB_SETUP([OPENH323], [OpenH323], [h323])
 AST_EXT_LIB_SETUP([QT], [Qt], [qt])
 AST_EXT_LIB_SETUP([RADIUS], [Radius Client], [radius])
+AST_EXT_LIB_SETUP([SPANDSP], [spandsp Library], [spandsp])
 AST_EXT_LIB_SETUP([SPEEX], [Speex], [speex])
 AST_EXT_LIB_SETUP([SQLITE], [SQLite], [sqlite])
 AST_EXT_LIB_SETUP([SUPPSERV], [mISDN Supplemental Services], [suppserv])
@@ -958,6 +959,8 @@ AC_LANG_POP
 
 AST_EXT_LIB_CHECK([RADIUS], [radiusclient-ng], [rc_read_config], [radiusclient-ng.h])
 
+AST_EXT_LIB_CHECK([SPANDSP], [spandsp], [fax_init], [spandsp.h], [-ltiff])
+
 AST_EXT_LIB_CHECK([SPEEX], [speex], [speex_encode], [speex/speex.h], [-lm])
 
 AST_EXT_LIB_CHECK([SQLITE], [sqlite], [sqlite_exec], [sqlite.h])
diff --git a/include/asterisk/autoconfig.h.in b/include/asterisk/autoconfig.h.in
index d5a6faa..47fcad9 100644
--- a/include/asterisk/autoconfig.h.in
+++ b/include/asterisk/autoconfig.h.in
@@ -323,6 +323,9 @@
 /* Define to 1 if you have the `socket' function. */
 #undef HAVE_SOCKET
 
+/* Define to indicate the ${SPANDSP_DESCRIP} library */
+#undef HAVE_SPANDSP
+
 /* Define to indicate the ${SPEEX_DESCRIP} library */
 #undef HAVE_SPEEX
 
diff --git a/makeopts.in b/makeopts.in
index 193ec3c..8138dd8 100644
--- a/makeopts.in
+++ b/makeopts.in
@@ -141,6 +141,9 @@ QT_LIB=@QT_LIB@
 RADIUS_INCLUDE=@RADIUS_INCLUDE@
 RADIUS_LIB=@RADIUS_LIB@
 
+SPANDSP_INCLUDE=@SPANDSP_INCLUDE@
+SPANDSP_LIB=@SPANDSP_LIB@
+
 SPEEX_INCLUDE=@SPEEX_INCLUDE@
 SPEEX_LIB=@SPEEX_LIB@
 
-- 
1.5.3.6


asterisk-1.4.16-system-imap.patch:

--- NEW FILE asterisk-1.4.16-system-imap.patch ---
>From 964b72f05f056a6a494e8650c37f7172320fb9cd Mon Sep 17 00:00:00 2001
From: Jeffrey C. Ollie <jcollie at pc21224.campus.dmacc.edu>
Date: Thu, 8 Nov 2007 15:47:38 -0600
Subject: [PATCH] Patch so that system IMAP library can be used.

---
 apps/app_voicemail.c |   10 ++++++++++
 configure            |   37 ++++++++++++++++++++++++++++---------
 configure.ac         |   36 +++++++++++++++++++++++++++---------
 doc/imapstorage.txt  |   34 ++++++++++++++++------------------
 4 files changed, 81 insertions(+), 36 deletions(-)

diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index fec54fc..d455a0f 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -70,10 +70,16 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include <ctype.h>
 #include <signal.h>
 #include <pwd.h>
+#ifdef USE_SYSTEM_IMAP
+#include <imap/c-client.h>
+#include <imap/imap4r1.h>
+#include <imap/linkage.h>
+#else
 #include "c-client.h"
 #include "imap4r1.h"
 #include "linkage.h"
 #endif
+#endif
 #include "asterisk/lock.h"
 #include "asterisk/file.h"
 #include "asterisk/logger.h"
@@ -4708,7 +4714,11 @@ static int init_mailstream(struct vm_state *vms, int box)
 
 	if (delimiter == '\0') {		/* did not probe the server yet */
 		char *cp;
+#if USE_SYSTEM_IMAP
+#include <imap/linkage.c>
+#else
 #include "linkage.c"
+#endif
 		/* Connect to INBOX first to get folders delimiter */
 		imap_mailbox_name(tmp, sizeof(tmp), vms, 0, 1);
 		stream = mail_open (stream, tmp, debug ? OP_DEBUG : NIL);
diff --git a/configure b/configure
index f296f05..fb3bdbf 100755
--- a/configure
+++ b/configure
@@ -18652,7 +18652,10 @@ fi
 fi
 
 if test "${USE_IMAP_TK}" != "no"; then
-   if test "${IMAP_TK_DIR}" = ""; then
+   if test "${IMAP_TK_DIR}" = "system" ; then
+      { echo "$as_me:$LINENO: Checking for system c-client library..." >&5
+echo "$as_me: Checking for system c-client library..." >&6;}
+   elif test "${IMAP_TK_DIR}" = ""; then
       IMAP_TK_DIR=`pwd`"/../imap-2004g"
       if test  -n "${IMAP_TK_MANDATORY}"; then
 	 { echo "$as_me:$LINENO: The --with-imap option does not search your system for installed" >&5
@@ -18665,22 +18668,34 @@ echo "$as_me: the configure script will assume you have placed built the c-clien
 echo "$as_me: files at ${IMAP_TK_DIR}, as outlined in the doc/imapstorage.txt file." >&6;}
       fi
    fi
-   { echo "$as_me:$LINENO: checking for UW IMAP Toolkit c-client library" >&5
+   if test "${IMAP_TK_DIR}" != "system" ; then
+      { echo "$as_me:$LINENO: checking for UW IMAP Toolkit c-client library" >&5
 echo $ECHO_N "checking for UW IMAP Toolkit c-client library... $ECHO_C" >&6; }
+   fi
    saved_cppflags="${CPPFLAGS}"
    saved_libs="${LIBS}"
-   if test -f ${IMAP_TK_DIR}/c-client/LDFLAGS ; then
+   if test "${IMAP_TK_DIR}" = "system" ; then
+      imap_ldflags=""
+      imap_libs="-lc-client"
+      imap_include="-DUSE_SYSTEM_IMAP"
+   elif test -f ${IMAP_TK_DIR}/c-client/LDFLAGS ; then
       imap_ldflags=`cat ${IMAP_TK_DIR}/c-client/LDFLAGS`
+      imap_libs="${IMAP_TK_DIR}/c-client/c-client.a"
+      imap_include="-I${IMAP_TK_DIR}/c-client"
    fi
-   CPPFLAGS="${CPPFLAGS} -I${IMAP_TK_DIR}/c-client"
-   LIBS="${LIBS} ${IMAP_TK_DIR}/c-client/c-client.a "`echo ${imap_ldflags}`
+   CPPFLAGS="${CPPFLAGS} ${imap_include}"
+   LIBS="${LIBS} ${imap_libs} "`echo ${imap_ldflags}`
    cat >conftest.$ac_ext <<_ACEOF
 /* confdefs.h.  */
 _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-#include "c-client.h"
+#ifdef USE_SYSTEM_IMAP
+		#include <imap/c-client.h>
+		#else
+		#include "c-client.h"
+		#endif
 		void mm_searched (MAILSTREAM *stream,unsigned long number)
 		{
 		}
@@ -18773,7 +18788,11 @@ _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
-#include "c-client.h"
+#ifdef USE_SYSTEM_IMAP
+	 #include <imap/c-client.h>
+	 #else
+	 #include "c-client.h"
+	 #endif
          void mm_searched (MAILSTREAM *stream,unsigned long number)
          {
          }
@@ -18865,8 +18884,8 @@ rm -f core conftest.err conftest.$ac_objext conftest_ipa8_conftest.oo \
    if test "${ac_cv_imap_tk}" = "yes"; then
       { echo "$as_me:$LINENO: result: yes" >&5
 echo "${ECHO_T}yes" >&6; }
-      IMAP_TK_LIB="${IMAP_TK_DIR}/c-client/c-client.a "`echo ${imap_ldflags}`
-      IMAP_TK_INCLUDE="-I${IMAP_TK_DIR}/c-client"
+      IMAP_TK_LIB="${imap_libs}"`echo ${imap_ldflags}`
+      IMAP_TK_INCLUDE="${imap_include}"
       PBX_IMAP_TK=1
 
 cat >>confdefs.h <<\_ACEOF
diff --git a/configure.ac b/configure.ac
index 8f1d95c..4b074ba 100644
--- a/configure.ac
+++ b/configure.ac
@@ -467,7 +467,9 @@ if test "${PBX_IKSEMEL}" = 1; then
 fi
 
 if test "${USE_IMAP_TK}" != "no"; then
-   if test "${IMAP_TK_DIR}" = ""; then
+   if test "${IMAP_TK_DIR}" = "system" ; then
+      AC_MSG_NOTICE([Checking for system c-client library...])
+   elif test "${IMAP_TK_DIR}" = ""; then
       IMAP_TK_DIR=`pwd`"/../imap-2004g"
       if test  -n "${IMAP_TK_MANDATORY}"; then
 	 AC_MSG_NOTICE([The --with-imap option does not search your system for installed])
@@ -476,17 +478,29 @@ if test "${USE_IMAP_TK}" != "no"; then
 	 AC_MSG_NOTICE([files at ${IMAP_TK_DIR}, as outlined in the doc/imapstorage.txt file.])
       fi
    fi
-   AC_MSG_CHECKING(for UW IMAP Toolkit c-client library)
+   if test "${IMAP_TK_DIR}" != "system" ; then
+      AC_MSG_CHECKING(for UW IMAP Toolkit c-client library)
+   fi
    saved_cppflags="${CPPFLAGS}"
    saved_libs="${LIBS}"
-   if test -f ${IMAP_TK_DIR}/c-client/LDFLAGS ; then
+   if test "${IMAP_TK_DIR}" = "system" ; then
+      imap_ldflags=""
+      imap_libs="-lc-client"
+      imap_include="-DUSE_SYSTEM_IMAP"
+   elif test -f ${IMAP_TK_DIR}/c-client/LDFLAGS ; then
       imap_ldflags=`cat ${IMAP_TK_DIR}/c-client/LDFLAGS`
+      imap_libs="${IMAP_TK_DIR}/c-client/c-client.a"
+      imap_include="-I${IMAP_TK_DIR}/c-client"
    fi
-   CPPFLAGS="${CPPFLAGS} -I${IMAP_TK_DIR}/c-client"
-   LIBS="${LIBS} ${IMAP_TK_DIR}/c-client/c-client.a "`echo ${imap_ldflags}`
+   CPPFLAGS="${CPPFLAGS} ${imap_include}"
+   LIBS="${LIBS} ${imap_libs} "`echo ${imap_ldflags}`
    AC_LINK_IFELSE(
 	AC_LANG_PROGRAM(
-		[#include "c-client.h"
+		[#ifdef USE_SYSTEM_IMAP
+		#include <imap/c-client.h>
+		#else
+		#include "c-client.h"
+		#endif
 		void mm_searched (MAILSTREAM *stream,unsigned long number)
 		{
 		}
@@ -542,7 +556,11 @@ if test "${USE_IMAP_TK}" != "no"; then
    if test "${ac_cv_imap_tk}" = "yes"; then
    AC_LINK_IFELSE(
       AC_LANG_PROGRAM(
-         [#include "c-client.h"
+         [#ifdef USE_SYSTEM_IMAP
+	 #include <imap/c-client.h>
+	 #else
+	 #include "c-client.h"
+	 #endif
          void mm_searched (MAILSTREAM *stream,unsigned long number)
          {
          }
@@ -600,8 +618,8 @@ if test "${USE_IMAP_TK}" != "no"; then
    LIBS="${saved_libs}"
    if test "${ac_cv_imap_tk}" = "yes"; then
       AC_MSG_RESULT(yes) 
-      IMAP_TK_LIB="${IMAP_TK_DIR}/c-client/c-client.a "`echo ${imap_ldflags}`
-      IMAP_TK_INCLUDE="-I${IMAP_TK_DIR}/c-client"
+      IMAP_TK_LIB="${imap_libs}"`echo ${imap_ldflags}`
+      IMAP_TK_INCLUDE="${imap_include}"
       PBX_IMAP_TK=1
       AC_DEFINE([HAVE_IMAP_TK], 1, [Define if your system has the UW IMAP Toolkit c-client library.])
       if test "${ac_cv_imap_tk2006}" = "yes"; then
diff --git a/doc/imapstorage.txt b/doc/imapstorage.txt
index 1e5484b..d292b5d 100644
--- a/doc/imapstorage.txt
+++ b/doc/imapstorage.txt
@@ -38,10 +38,11 @@ Installation Notes
 --------------------------------------
 University of Washington IMAP C-Client
 --------------------------------------
-You will need a source distribution of University of Washington's IMAP
-c-client (http://www.washington.edu/imap/).  Asterisk supports both the
-2004 and 2006 versions of c-client, however mail_expunge_full is enabled
-in the 2006 version.
+If you do not have the University of Washington's IMAP c-client
+installed on your system, you will need to download the c-client
+source distribution (http://www.washington.edu/imap/) and compile it.
+Asterisk supports both the 2004 and 2006 versions of c-client, however
+mail_expunge_full is enabled in the 2006 version.
 
 Note that Asterisk only uses the 'client' portion of the UW IMAP toolkit,
 but building it also builds an IMAP server and various other utilities.
@@ -68,20 +69,17 @@ need to run 'make install'.
 ------------------
 Compiling Asterisk 
 ------------------
-
-Configure with ./configure --with-imap=/usr/src/imap
-or where ever you built thfe UWashington IMAP Toolkit. When you run
-'make menuselect', choose 'Voicemail Build Options' and the
-IMAP_STORAGE option should be available for selection.
-
-Note that the --with-imap option will NOT search your system for an
-installed copy of the IMAP Toolkit c-client library; the Asterisk
-Makefiles and configure script are designed to build against an
-unpacked and compiled source tree of the IMAP Toolkit, not a binary
-distribution.
-
-After selecting it, use the 'x' key to exit menuselect and save
-your changes, and the build/install Asterisk normally.
+To use the system c-client library, configure Asterisk with
+./configure --with-imap=system. If you downloaded the c-client source
+and compiled it according to the above instructions, configure
+Asterisk with with ./configure --with-imap=/usr/src/imap or where ever
+you built the UWashington IMAP Toolkit. When you run 'make
+menuselect', choose 'Voicemail Build Options' and the IMAP_STORAGE
+option should be available for selection.
+
+After selecting the IMAP_STORAGE option, use the 'x' key to exit
+menuselect and save your changes, and the build/install Asterisk
+normally.
 
 ---------------------
 Modify voicemail.conf
-- 
1.5.3.6



Index: .cvsignore
===================================================================
RCS file: /cvs/pkgs/rpms/asterisk/F-8/.cvsignore,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- .cvsignore	12 Dec 2007 05:38:36 -0000	1.2
+++ .cvsignore	19 Dec 2007 05:32:53 -0000	1.3
@@ -1 +1 @@
-asterisk-1.4.15-stripped.tar.gz
+asterisk-1.4.16-stripped.tar.gz


Index: asterisk.spec
===================================================================
RCS file: /cvs/pkgs/rpms/asterisk/F-8/asterisk.spec,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- asterisk.spec	16 Dec 2007 03:36:37 -0000	1.2
+++ asterisk.spec	19 Dec 2007 05:32:53 -0000	1.3
@@ -2,8 +2,8 @@
 
 Summary: The Open Source PBX
 Name: asterisk
-Version: 1.4.15
-Release: 7%{?dist}
+Version: 1.4.16
+Release: 1%{?dist}
 License: GPLv2
 Group: Applications/Internet
 URL: http://www.asterisk.org/
@@ -20,13 +20,13 @@
 #
 # MD5 Sums
 # ========
-# c2f87a1343a7bf7eb4925c06ef962976  asterisk-1.4.15.tar.gz
-# a548cfe60e86013eac0851ef585d01ed  asterisk-1.4.15-stripped.tar.gz
+# 2bc92ed77ba1dede35da744cca046ac0  asterisk-1.4.16.tar.gz
+# 76a17563c4f6e3cc7b4457377db0b85b  asterisk-1.4.16-stripped.tar.gz
 #
 # SHA1 Sums
 # =========
-# c9d934a5a6ed374aebdc9152b65af1b76e603e39  asterisk-1.4.15.tar.gz
-# a55daa6b9a991bcaa08417e0addf27274471dc3c  asterisk-1.4.15-stripped.tar.gz
+# 996ef122e2cd11a348c6679133019b664a8535ee  asterisk-1.4.16.tar.gz
+# e4ec1416016dc757ad8a6aad3eeefc49b4d0e76c  asterisk-1.4.16-stripped.tar.gz
 
 Source0: asterisk-%{version}-stripped.tar.gz
 Source1: asterisk-logrotate
@@ -34,16 +34,16 @@
 Source3: menuselect.makeopts
 Source4: asterisk-strip.sh
 
-Patch1:  asterisk-1.4.14-initscripts.patch
-Patch2:  asterisk-1.4.14-system-imap.patch
-Patch3:  asterisk-1.4.14-alternate-voicemail.patch
-Patch4:  asterisk-1.4.14-spandspfax.patch
-Patch5:  asterisk-1.4.14-appconference.patch
-Patch6:  asterisk-1.4.14-alternate-extensions.patch
-Patch7:  asterisk-1.4.14-optimization.patch
-Patch8:  asterisk-1.4.14-libcap.patch
-Patch9:  asterisk-1.4.14-chanmobile.patch
-Patch10: asterisk-1.4.14-autoconf.patch
+Patch1:  asterisk-1.4.16-initscripts.patch
+Patch2:  asterisk-1.4.16-system-imap.patch
+Patch3:  asterisk-1.4.16-alternate-voicemail.patch
+Patch4:  asterisk-1.4.16-spandspfax.patch
+Patch5:  asterisk-1.4.16-appconference.patch
+Patch6:  asterisk-1.4.16-alternate-extensions.patch
+Patch7:  asterisk-1.4.16-optimization.patch
+Patch8:  asterisk-1.4.16-libcap.patch
+Patch9:  asterisk-1.4.16-chanmobile.patch
+Patch10: asterisk-1.4.16-autoconf.patch
 
 BuildRoot: %{_tmppath}/%{name}-%{version}-root-%(%{__id_u} -n)
 
@@ -876,6 +876,9 @@
 %{_libdir}/asterisk/modules/codec_zap.so
 
 %changelog
+* Tue Dec 18 2007 Jeffrey C. Ollie <jeff at ocjtech.us> - 1.4.16-1
+- Update to 1.4.16 to fix security bug.
+
 * Sat Dec 15 2007 Jeffrey C. Ollie <jeff at ocjtech.us> - 1.4.15-7
 - Really, really fix the build problems on devel.
 


Index: sources
===================================================================
RCS file: /cvs/pkgs/rpms/asterisk/F-8/sources,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- sources	12 Dec 2007 05:38:36 -0000	1.2
+++ sources	19 Dec 2007 05:32:53 -0000	1.3
@@ -1 +1 @@
-a548cfe60e86013eac0851ef585d01ed  asterisk-1.4.15-stripped.tar.gz
+76a17563c4f6e3cc7b4457377db0b85b  asterisk-1.4.16-stripped.tar.gz


--- asterisk-1.4.14-alternate-extensions.patch DELETED ---


--- asterisk-1.4.14-alternate-voicemail.patch DELETED ---


--- asterisk-1.4.14-appconference.patch DELETED ---


--- asterisk-1.4.14-autoconf.patch DELETED ---


--- asterisk-1.4.14-chanmobile.patch DELETED ---


--- asterisk-1.4.14-initscripts.patch DELETED ---


--- asterisk-1.4.14-libcap.patch DELETED ---


--- asterisk-1.4.14-optimization.patch DELETED ---


--- asterisk-1.4.14-spandspfax.patch DELETED ---


--- asterisk-1.4.14-system-imap.patch DELETED ---




More information about the fedora-extras-commits mailing list