[asterisk-commits] branch oej/siptransfer r20706 - in /team/oej/siptransfer: ./ apps/ build_tool...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sun Apr 16 15:45:48 MST 2006


Author: oej
Date: Sun Apr 16 17:45:30 2006
New Revision: 20706

URL: http://svn.digium.com/view/asterisk?rev=20706&view=rev
Log:
resolve conflict

Modified:
    team/oej/siptransfer/   (props changed)
    team/oej/siptransfer/Makefile
    team/oej/siptransfer/app.c
    team/oej/siptransfer/apps/app_voicemail.c
    team/oej/siptransfer/asterisk.c
    team/oej/siptransfer/build_tools/make_defaults_h
    team/oej/siptransfer/channel.c
    team/oej/siptransfer/channels/chan_agent.c
    team/oej/siptransfer/channels/chan_iax2.c
    team/oej/siptransfer/channels/chan_sip.c
    team/oej/siptransfer/configs/agents.conf.sample
    team/oej/siptransfer/configs/indications.conf.sample
    team/oej/siptransfer/configs/voicemail.conf.sample
    team/oej/siptransfer/file.c
    team/oej/siptransfer/http.c
    team/oej/siptransfer/image.c
    team/oej/siptransfer/include/asterisk.h
    team/oej/siptransfer/include/asterisk/lock.h
    team/oej/siptransfer/res/res_agi.c

Propchange: team/oej/siptransfer/
------------------------------------------------------------------------------
    automerge = Tokyo!

Propchange: team/oej/siptransfer/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Sun Apr 16 17:45:30 2006
@@ -1,1 +1,1 @@
-/trunk:1-20287
+/trunk:1-20426

Modified: team/oej/siptransfer/Makefile
URL: http://svn.digium.com/view/asterisk/team/oej/siptransfer/Makefile?rev=20706&r1=20705&r2=20706&view=diff
==============================================================================
--- team/oej/siptransfer/Makefile (original)
+++ team/oej/siptransfer/Makefile Sun Apr 16 17:45:30 2006
@@ -167,12 +167,13 @@
   ASTMANDIR=$(INSTALL_PREFIX)/usr/share/man
 endif
 endif
+ASTDATADIR?=$(ASTVARLIBDIR)
 
 # Asterisk.conf is located in ASTETCDIR or by using the -C flag
 # when starting Asterisk
 ASTCONFPATH=$(ASTETCDIR)/asterisk.conf
 MODULES_DIR=$(ASTLIBDIR)/modules
-AGI_DIR=$(ASTVARLIBDIR)/agi-bin
+AGI_DIR=$(ASTDATADIR)/agi-bin
 
 # If you use Apache, you may determine by a grep 'DocumentRoot' of your httpd.conf file
 HTTP_DOCSDIR=/var/www/html
@@ -566,42 +567,42 @@
 	# Should static HTTP be installed during make samples or even with its own target ala
 	# webvoicemail?  There are portions here that *could* be customized but might also be
 	# improved a lot.  I'll put it here for now.
-	mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/static-http
+	mkdir -p $(DESTDIR)$(ASTDATADIR)/static-http
 	for x in static-http/*; do \
-		install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/static-http ; \
-	done
-	mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/digits
-	mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/priv-callerintros
+		install -m 644 $$x $(DESTDIR)$(ASTDATADIR)/static-http ; \
+	done
+	mkdir -p $(DESTDIR)$(ASTDATADIR)/sounds/digits
+	mkdir -p $(DESTDIR)$(ASTDATADIR)/sounds/priv-callerintros
 	for x in sounds/digits/*.gsm; do \
 		if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \
-			$(INSTALL) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/digits ; \
+			$(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/sounds/digits ; \
 		else \
 			echo "No description for $$x"; \
 			exit 1; \
 		fi; \
 	done
-	mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/dictate
+	mkdir -p $(DESTDIR)$(ASTDATADIR)/sounds/dictate
 	for x in sounds/dictate/*.gsm; do \
 		if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \
-			$(INSTALL) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/dictate ; \
+			$(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/sounds/dictate ; \
 		else \
 			echo "No description for $$x"; \
 			exit 1; \
 		fi; \
 	done
-	mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/letters
+	mkdir -p $(DESTDIR)$(ASTDATADIR)/sounds/letters
 	for x in sounds/letters/*.gsm; do \
 		if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \
-			$(INSTALL) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/letters ; \
+			$(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/sounds/letters ; \
 		else \
 			echo "No description for $$x"; \
 			exit 1; \
 		fi; \
 	done
-	mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/phonetic
+	mkdir -p $(DESTDIR)$(ASTDATADIR)/sounds/phonetic
 	for x in sounds/phonetic/*.gsm; do \
 		if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \
-			$(INSTALL) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/phonetic ; \
+			$(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/sounds/phonetic ; \
 		else \
 			echo "No description for $$x"; \
 			exit 1; \
@@ -609,16 +610,16 @@
 	done
 	for x in sounds/demo-* sounds/vm-* sounds/transfer* sounds/pbx-* sounds/ss-* sounds/beep* sounds/dir-* sounds/conf-* sounds/agent-* sounds/invalid* sounds/tt-* sounds/auth-* sounds/privacy-* sounds/queue-* sounds/spy-* sounds/priv-* sounds/screen-* sounds/hello-*; do \
 		if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \
-			$(INSTALL) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds ; \
+			$(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/sounds ; \
 		else \
 			echo "No description for $$x"; \
 			exit 1; \
 		fi; \
 	done
-	mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/mohmp3
-	mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/images
+	mkdir -p $(DESTDIR)$(ASTDATADIR)/mohmp3
+	mkdir -p $(DESTDIR)$(ASTDATADIR)/images
 	for x in images/*.jpg; do \
-		$(INSTALL) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/images ; \
+		$(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/images ; \
 	done
 	mkdir -p $(DESTDIR)$(AGI_DIR)
 
@@ -678,21 +679,21 @@
 	if [ -n "$(OLDHEADERS)" ]; then \
 		rm -f $(addprefix $(DESTDIR)$(ASTHEADERDIR)/,$(OLDHEADERS)) ;\
 	fi
-	mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds
+	mkdir -p $(DESTDIR)$(ASTDATADIR)/sounds
 	mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-csv
 	mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-custom
-	mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/keys
-	mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/firmware
-	mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/firmware/iax
+	mkdir -p $(DESTDIR)$(ASTDATADIR)/keys
+	mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware
+	mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware/iax
 	mkdir -p $(DESTDIR)$(ASTMANDIR)/man8
-	$(INSTALL) -m 644 keys/iaxtel.pub $(DESTDIR)$(ASTVARLIBDIR)/keys
-	$(INSTALL) -m 644 keys/freeworlddialup.pub $(DESTDIR)$(ASTVARLIBDIR)/keys
+	$(INSTALL) -m 644 keys/iaxtel.pub $(DESTDIR)$(ASTDATADIR)/keys
+	$(INSTALL) -m 644 keys/freeworlddialup.pub $(DESTDIR)$(ASTDATADIR)/keys
 	$(INSTALL) -m 644 asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8
 	$(INSTALL) -m 644 contrib/scripts/astgenkey.8 $(DESTDIR)$(ASTMANDIR)/man8
 	$(INSTALL) -m 644 contrib/scripts/autosupport.8 $(DESTDIR)$(ASTMANDIR)/man8
 	$(INSTALL) -m 644 contrib/scripts/safe_asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8
 	if [ -d contrib/firmware/iax ]; then \
-		$(INSTALL) -m 644 contrib/firmware/iax/iaxy.bin $(DESTDIR)$(ASTVARLIBDIR)/firmware/iax/iaxy.bin; \
+		$(INSTALL) -m 644 contrib/firmware/iax/iaxy.bin $(DESTDIR)$(ASTDATADIR)/firmware/iax/iaxy.bin; \
 	else \
 		echo "You need to do cvs update -d not just cvs update" ; \
 	fi 
@@ -779,6 +780,7 @@
 		echo "astetcdir => $(ASTETCDIR)" ; \
 		echo "astmoddir => $(MODULES_DIR)" ; \
 		echo "astvarlibdir => $(ASTVARLIBDIR)" ; \
+		echo "astdatadir => $(ASTDATADIR)" ; \
 		echo "astagidir => $(AGI_DIR)" ; \
 		echo "astspooldir => $(ASTSPOOLDIR)" ; \
 		echo "astrundir => $(ASTVARRUNDIR)" ; \
@@ -796,28 +798,28 @@
 	else \
 		echo "Skipping asterisk.conf creation"; \
 	fi
-	mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds ; \
+	mkdir -p $(DESTDIR)$(ASTDATADIR)/sounds ; \
 	for x in sounds/demo-*; do \
 		if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \
-			$(INSTALL) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds ; \
+			$(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/sounds ; \
 		else \
 			echo "No description for $$x"; \
 			exit 1; \
 		fi; \
 	done
-	mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/mohmp3 ; \
+	mkdir -p $(DESTDIR)$(ASTDATADIR)/mohmp3 ; \
 	for x in sounds/*.mp3; do \
-		$(INSTALL) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/mohmp3 ; \
-	done
-	rm -f $(DESTDIR)$(ASTVARLIBDIR)/mohmp3/sample-hold.mp3
+		$(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/mohmp3 ; \
+	done
+	rm -f $(DESTDIR)$(ASTDATADIR)/mohmp3/sample-hold.mp3
 	mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/INBOX
 	:> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/unavail.gsm
 	for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isunavail; do \
-		cat $(DESTDIR)$(ASTVARLIBDIR)/sounds/$$x.gsm >> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/unavail.gsm ; \
+		cat $(DESTDIR)$(ASTDATADIR)/sounds/$$x.gsm >> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/unavail.gsm ; \
 	done
 	:> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/busy.gsm
 	for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isonphone; do \
-		cat $(DESTDIR)$(ASTVARLIBDIR)/sounds/$$x.gsm >> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/busy.gsm ; \
+		cat $(DESTDIR)$(ASTDATADIR)/sounds/$$x.gsm >> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/busy.gsm ; \
 	done
 
 webvmail:
@@ -939,8 +941,8 @@
 	rm -f $(DESTDIR)$(ASTSBINDIR)/astgenkey
 	rm -f $(DESTDIR)$(ASTSBINDIR)/autosupport
 	rm -rf $(DESTDIR)$(ASTHEADERDIR)
-	rm -rf $(DESTDIR)$(ASTVARLIBDIR)/sounds
-	rm -rf $(DESTDIR)$(ASTVARLIBDIR)/firmware
+	rm -rf $(DESTDIR)$(ASTDATADIR)/sounds
+	rm -rf $(DESTDIR)$(ASTDATADIR)/firmware
 	rm -rf $(DESTDIR)$(ASTMANDIR)/man8
 	for x in $(SUBDIRS); do $(MAKE) -C $$x uninstall || exit 1 ; done
 
@@ -961,6 +963,7 @@
 uninstall-all: _uninstall
 	rm -rf $(DESTDIR)$(ASTLIBDIR)
 	rm -rf $(DESTDIR)$(ASTVARLIBDIR)
+	rm -rf $(DESTDIR)$(ASTDATADIR)
 	rm -rf $(DESTDIR)$(ASTSPOOLDIR)
 	rm -rf $(DESTDIR)$(ASTETCDIR)
 	rm -rf $(DESTDIR)$(ASTLOGDIR)

Modified: team/oej/siptransfer/app.c
URL: http://svn.digium.com/view/asterisk/team/oej/siptransfer/app.c?rev=20706&r1=20705&r2=20706&view=diff
==============================================================================
--- team/oej/siptransfer/app.c (original)
+++ team/oej/siptransfer/app.c Sun Apr 16 17:45:30 2006
@@ -414,7 +414,7 @@
 		if (filename[0] == '/') 
 			ast_copy_string(tmpf, filename, sizeof(tmpf));
 		else
-			snprintf(tmpf, sizeof(tmpf), "%s/%s/%s", (char *)ast_config_AST_VAR_DIR, "sounds", filename);
+			snprintf(tmpf, sizeof(tmpf), "%s/%s/%s", (char *)ast_config_AST_DATA_DIR, "sounds", filename);
 		fd = open(tmpf, O_RDONLY);
 		if (fd < 0){
 			ast_log(LOG_WARNING, "Unable to open file '%s': %s\n", tmpf, strerror(errno));

Modified: team/oej/siptransfer/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/oej/siptransfer/apps/app_voicemail.c?rev=20706&r1=20705&r2=20706&view=diff
==============================================================================
--- team/oej/siptransfer/apps/app_voicemail.c (original)
+++ team/oej/siptransfer/apps/app_voicemail.c Sun Apr 16 17:45:30 2006
@@ -237,6 +237,7 @@
 	char dialout[80];
 	char uniqueid[20];		/*!< Unique integer identifier */
 	char exit[80];
+	char attachfmt[20];		/*!< Attachment format */
 	unsigned int flags;		/*!< VM_ flags */	
 	int saydurationm;
 	int maxmsg;			/*!< Maximum number of msgs per folder for this mailbox */
@@ -451,7 +452,9 @@
 {
 	int x;
 	if (!strcasecmp(var, "attach")) {
-		ast_set2_flag(vmu, ast_true(value), VM_ATTACH);	
+		ast_set2_flag(vmu, ast_true(value), VM_ATTACH);
+	} else if (!strcasecmp(var, "attachfmt")) {
+		ast_copy_string(vmu->attachfmt, value, sizeof(vmu->attachfmt));
 	} else if (!strcasecmp(var, "serveremail")) {
 		ast_copy_string(vmu->serveremail, value, sizeof(vmu->serveremail));
 	} else if (!strcasecmp(var, "language")) {
@@ -3291,6 +3294,10 @@
 	make_dir(todir, sizeof(todir), vmu->context, vmu->mailbox, "INBOX");
 	make_file(fn, sizeof(fn), todir, msgnum);
 	snprintf(ext_context, sizeof(ext_context), "%s@%s", vmu->mailbox, vmu->context);
+
+	if (!ast_strlen_zero(vmu->attachfmt)) {
+		fmt = vmu->attachfmt;
+	}
 
 	/* Attach only the first format */
 	if ((fmt = ast_strdupa(fmt))) {

Modified: team/oej/siptransfer/asterisk.c
URL: http://svn.digium.com/view/asterisk/team/oej/siptransfer/asterisk.c?rev=20706&r1=20705&r2=20706&view=diff
==============================================================================
--- team/oej/siptransfer/asterisk.c (original)
+++ team/oej/siptransfer/asterisk.c Sun Apr 16 17:45:30 2006
@@ -206,6 +206,7 @@
 char ast_config_AST_SPOOL_DIR[AST_CONFIG_MAX_PATH];
 char ast_config_AST_MONITOR_DIR[AST_CONFIG_MAX_PATH];
 char ast_config_AST_VAR_DIR[AST_CONFIG_MAX_PATH];
+char ast_config_AST_DATA_DIR[AST_CONFIG_MAX_PATH];
 char ast_config_AST_LOG_DIR[AST_CONFIG_MAX_PATH];
 char ast_config_AST_AGI_DIR[AST_CONFIG_MAX_PATH];
 char ast_config_AST_DB[AST_CONFIG_MAX_PATH];
@@ -2081,6 +2082,7 @@
 	ast_copy_string(ast_config_AST_MODULE_DIR, AST_MODULE_DIR, sizeof(ast_config_AST_MODULE_DIR));
  	snprintf(ast_config_AST_MONITOR_DIR, sizeof(ast_config_AST_MONITOR_DIR) - 1, "%s/monitor", ast_config_AST_SPOOL_DIR);
 	ast_copy_string(ast_config_AST_VAR_DIR, AST_VAR_DIR, sizeof(ast_config_AST_VAR_DIR));
+	ast_copy_string(ast_config_AST_DATA_DIR, AST_DATA_DIR, sizeof(ast_config_AST_DATA_DIR));
 	ast_copy_string(ast_config_AST_LOG_DIR, AST_LOG_DIR, sizeof(ast_config_AST_LOG_DIR));
 	ast_copy_string(ast_config_AST_AGI_DIR, AST_AGI_DIR, sizeof(ast_config_AST_AGI_DIR));
 	ast_copy_string(ast_config_AST_DB, AST_DB, sizeof(ast_config_AST_DB));
@@ -2116,6 +2118,8 @@
 		} else if (!strcasecmp(v->name, "astvarlibdir")) {
 			ast_copy_string(ast_config_AST_VAR_DIR, v->value, sizeof(ast_config_AST_VAR_DIR));
 			snprintf(ast_config_AST_DB, sizeof(ast_config_AST_DB), "%s/astdb", v->value);
+		} else if (!strcasecmp(v->name, "astdatadir")) {
+			ast_copy_string(ast_config_AST_DATA_DIR, v->value, sizeof(ast_config_AST_DATA_DIR));
 			snprintf(ast_config_AST_KEY_DIR, sizeof(ast_config_AST_KEY_DIR), "%s/keys", v->value);
 		} else if (!strcasecmp(v->name, "astlogdir")) {
 			ast_copy_string(ast_config_AST_LOG_DIR, v->value, sizeof(ast_config_AST_LOG_DIR));

Modified: team/oej/siptransfer/build_tools/make_defaults_h
URL: http://svn.digium.com/view/asterisk/team/oej/siptransfer/build_tools/make_defaults_h?rev=20706&r1=20705&r2=20706&view=diff
==============================================================================
--- team/oej/siptransfer/build_tools/make_defaults_h (original)
+++ team/oej/siptransfer/build_tools/make_defaults_h Sun Apr 16 17:45:30 2006
@@ -11,6 +11,7 @@
 #define AST_MODULE_DIR "${INSTALL_PATH}${MODULES_DIR}"
 #define AST_SPOOL_DIR  "${INSTALL_PATH}${ASTSPOOLDIR}"
 #define AST_VAR_DIR    "${INSTALL_PATH}${ASTVARLIBDIR}"
+#define AST_DATA_DIR   "${INSTALL_PATH}${ASTDATADIR}"
 #define AST_LOG_DIR    "${INSTALL_PATH}${ASTLOGDIR}"
 #define AST_AGI_DIR    "${INSTALL_PATH}${AGI_DIR}"
 #define AST_KEY_DIR    "${INSTALL_PATH}${ASTVARLIBDIR}/keys"
@@ -19,7 +20,7 @@
 
 #define AST_CONFIG_FILE "${INSTALL_PATH}${ASTCONFPATH}"
 
-#define AST_SOUNDS     "${INSTALL_PATH}${ASTVARLIBDIR}/sounds"
-#define AST_IMAGES     "${INSTALL_PATH}${ASTVARLIBDIR}/images"
+#define AST_SOUNDS     "${INSTALL_PATH}${ASTDATADIR}/sounds"
+#define AST_IMAGES     "${INSTALL_PATH}${ASTDATADIR}/images"
 
 END

Modified: team/oej/siptransfer/channel.c
URL: http://svn.digium.com/view/asterisk/team/oej/siptransfer/channel.c?rev=20706&r1=20705&r2=20706&view=diff
==============================================================================
--- team/oej/siptransfer/channel.c (original)
+++ team/oej/siptransfer/channel.c Sun Apr 16 17:45:30 2006
@@ -1413,7 +1413,7 @@
 
 	/* Don't actually hang up a channel that will masquerade as someone else, or
 	   if someone is going to masquerade as us */
-	ast_mutex_lock(&chan->lock);
+	ast_channel_lock(chan);
 
 	detach_spies(chan);		/* get rid of spies */
 
@@ -1424,14 +1424,14 @@
 
 	if (chan->masq) {
 		ast_log(LOG_WARNING, "%s getting hung up, but someone is trying to masq into us?!?\n", chan->name);
-		ast_mutex_unlock(&chan->lock);
+		ast_channel_unlock(chan);
 		return 0;
 	}
 	/* If this channel is one which will be masqueraded into something,
 	   mark it as a zombie already, so we know to free it later */
 	if (chan->masqr) {
 		ast_set_flag(chan, AST_FLAG_ZOMBIE);
-		ast_mutex_unlock(&chan->lock);
+		ast_channel_unlock(chan);
 		return 0;
 	}
 	free_translation(chan);
@@ -1469,7 +1469,7 @@
 			ast_log(LOG_DEBUG, "Hanging up zombie '%s'\n", chan->name);
 	}
 			
-	ast_mutex_unlock(&chan->lock);
+	ast_channel_unlock(chan);
 	manager_event(EVENT_FLAG_CALL, "Hangup",
 			"Channel: %s\r\n"
 			"Uniqueid: %s\r\n"
@@ -1487,7 +1487,7 @@
 int ast_answer(struct ast_channel *chan)
 {
 	int res = 0;
-	ast_mutex_lock(&chan->lock);
+	ast_channel_lock(chan);
 	/* Stop if we're a zombie or need a soft hangup */
 	if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) {
 		ast_mutex_unlock(&chan->lock);
@@ -1501,7 +1501,7 @@
 		ast_setstate(chan, AST_STATE_UP);
 		if (chan->cdr)
 			ast_cdr_answer(chan->cdr);
-		ast_mutex_unlock(&chan->lock);
+		ast_channel_unlock(chan);
 		return res;
 		break;
 	case AST_STATE_UP:
@@ -1509,7 +1509,7 @@
 			ast_cdr_answer(chan->cdr);
 		break;
 	}
-	ast_mutex_unlock(&chan->lock);
+	ast_channel_unlock(chan);
 	return 0;
 }
 
@@ -1551,7 +1551,7 @@
 {
 	int res = 0;
 
-	ast_mutex_lock(&chan->lock);
+	ast_channel_lock(chan);
 
 	if (chan->generatordata) {
 		if (chan->generator && chan->generator->release)
@@ -1569,7 +1569,7 @@
 		chan->generator = gen;
 	}
 
-	ast_mutex_unlock(&chan->lock);
+	ast_channel_unlock(chan);
 
 	return res;
 }
@@ -1614,12 +1614,12 @@
 	
 	/* Perform any pending masquerades */
 	for (x=0; x < n; x++) {
-		ast_mutex_lock(&c[x]->lock);
+		ast_channel_lock(c[x]);
 		if (c[x]->masq) {
 			if (ast_do_masquerade(c[x])) {
 				ast_log(LOG_WARNING, "Masquerade failed\n");
 				*ms = -1;
-				ast_mutex_unlock(&c[x]->lock);
+				ast_channel_unlock(c[x]);
 				return NULL;
 			}
 		}
@@ -1630,13 +1630,13 @@
 			if (diff < 1) {
 				/* Should already be hungup */
 				c[x]->_softhangup |= AST_SOFTHANGUP_TIMEOUT;
-				ast_mutex_unlock(&c[x]->lock);
+				ast_channel_unlock(c[x]);
 				return c[x];
 			}
 			if (!whentohangup || (diff < whentohangup))
 				whentohangup = diff;
 		}
-		ast_mutex_unlock(&c[x]->lock);
+		ast_channel_unlock(c[x]);
 	}
 	/* Wait full interval */
 	rms = *ms;
@@ -1751,31 +1751,7 @@
 /* XXX never to be called with ms = -1 */
 int ast_waitfordigit(struct ast_channel *c, int ms)
 {
-	/* XXX Should I be merged with waitfordigit_full XXX */
-	struct ast_frame *f;
-	int result = 0;
-
-	/* Stop if we're a zombie or need a soft hangup */
-	if (ast_test_flag(c, AST_FLAG_ZOMBIE) || ast_check_hangup(c))
-		return -1;
-
-	/* Wait for a digit, no more than ms milliseconds total. */
-	while(ms && !result) {
-		ms = ast_waitfor(c, ms);
-		if (ms < 0) /* Error */
-			result = -1;
-		else if (ms > 0) {
-			/* Read something */
-			f = ast_read(c);
-			if (f) {
-				if (f->frametype == AST_FRAME_DTMF)
-					result = f->subclass;
-				ast_frfree(f);
-			} else
-				result = -1;
-		}
-	}
-	return result;
+	return ast_waitfordigit_full(c, ms, -1, -1);
 }
 
 int ast_settimeout(struct ast_channel *c, int samples, int (*func)(void *data), void *data)
@@ -1798,19 +1774,18 @@
 
 int ast_waitfordigit_full(struct ast_channel *c, int ms, int audiofd, int cmdfd)
 {
-	struct ast_frame *f;
-	struct ast_channel *rchan;
-	int outfd;
-	int res;
 
 	/* Stop if we're a zombie or need a soft hangup */
 	if (ast_test_flag(c, AST_FLAG_ZOMBIE) || ast_check_hangup(c))
 		return -1;
 	/* Wait for a digit, no more than ms milliseconds total. */
-	while(ms) {
+	while (ms) {
+		struct ast_channel *rchan;
+		int outfd;
+
 		errno = 0;
 		rchan = ast_waitfor_nandfds(&c, 1, &cmdfd, (cmdfd > -1) ? 1 : 0, NULL, &outfd, &ms);
-		if ((!rchan) && (outfd < 0) && (ms)) {
+		if (!rchan && outfd < 0 && ms) {
 			if (errno == 0 || errno == EINTR)
 				continue;
 			ast_log(LOG_WARNING, "Wait failed (%s)\n", strerror(errno));
@@ -1819,10 +1794,10 @@
 			/* The FD we were watching has something waiting */
 			return 1;
 		} else if (rchan) {
-			f = ast_read(c);
-			if(!f) {
+			int res;
+			struct ast_frame *f = ast_read(c);
+			if (!f)
 				return -1;
-			}
 
 			switch(f->frametype) {
 			case AST_FRAME_DTMF:
@@ -1863,14 +1838,14 @@
 	void *data;
 	int res;
 #endif
-	ast_mutex_lock(&chan->lock);
+	ast_channel_lock(chan);
 	if (chan->masq) {
 		if (ast_do_masquerade(chan)) {
 			ast_log(LOG_WARNING, "Failed to perform masquerade\n");
 			f = NULL;
 		} else
 			f =  &ast_null_frame;
-		ast_mutex_unlock(&chan->lock);
+		ast_channel_unlock(chan);
 		return f;
 	}
 
@@ -1878,7 +1853,7 @@
 	if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan)) {
 		if (chan->generator)
 			ast_deactivate_generator(chan);
-		ast_mutex_unlock(&chan->lock);
+		ast_channel_unlock(chan);
 		return NULL;
 	}
 	prestate = chan->_state;
@@ -1889,7 +1864,7 @@
 		chan->dtmff.subclass = chan->dtmfq[0];
 		/* Drop first digit */
 		memmove(chan->dtmfq, chan->dtmfq + 1, sizeof(chan->dtmfq) - 1);
-		ast_mutex_unlock(&chan->lock);
+		ast_channel_unlock(chan);
 		return &chan->dtmff;
 	}
 	
@@ -1917,7 +1892,7 @@
 			ioctl(chan->timingfd, ZT_TIMERACK, &blah);
 			func = chan->timingfunc;
 			data = chan->timingdata;
-			ast_mutex_unlock(&chan->lock);
+			ast_channel_unlock(chan);
 			if (func) {
 #if 0
 				ast_log(LOG_DEBUG, "Calling private function\n");
@@ -1925,10 +1900,10 @@
 				func(data);
 			} else {
 				blah = 0;
-				ast_mutex_lock(&chan->lock);
+				ast_channel_lock(chan);
 				ioctl(chan->timingfd, ZT_TIMERCONFIG, &blah);
 				chan->timingdata = NULL;
-				ast_mutex_unlock(&chan->lock);
+				ast_channel_unlock(chan);
 			}
 			return &ast_null_frame;
 		} else
@@ -2318,28 +2293,28 @@
 	int res = -1;
 	struct ast_frame *f = NULL;
 	/* Stop if we're a zombie or need a soft hangup */
-	ast_mutex_lock(&chan->lock);
+	ast_channel_lock(chan);
 	if (ast_test_flag(chan, AST_FLAG_ZOMBIE) || ast_check_hangup(chan))  {
-		ast_mutex_unlock(&chan->lock);
+		ast_channel_unlock(chan);
 		return -1;
 	}
 	/* Handle any pending masquerades */
 	if (chan->masq) {
 		if (ast_do_masquerade(chan)) {
 			ast_log(LOG_WARNING, "Failed to perform masquerade\n");
-			ast_mutex_unlock(&chan->lock);
+			ast_channel_unlock(chan);
 			return -1;
 		}
 	}
 	if (chan->masqr) {
-		ast_mutex_unlock(&chan->lock);
+		ast_channel_unlock(chan);
 		return 0;
 	}
 	if (chan->generatordata) {
 		if (ast_test_flag(chan, AST_FLAG_WRITE_INT))
 			ast_deactivate_generator(chan);
 		else {
-			ast_mutex_unlock(&chan->lock);
+			ast_channel_unlock(chan);
 			return 0;
 		}
 	}
@@ -2366,9 +2341,9 @@
 		break;
 	case AST_FRAME_DTMF:
 		ast_clear_flag(chan, AST_FLAG_BLOCKING);
-		ast_mutex_unlock(&chan->lock);
+		ast_channel_unlock(chan);
 		res = do_senddigit(chan,fr->subclass);
-		ast_mutex_lock(&chan->lock);
+		ast_channel_lock(chan);
 		CHECK_BLOCKING(chan);
 		break;
 	case AST_FRAME_TEXT:
@@ -2444,7 +2419,7 @@
 		else
 			chan->fout++;
 	}
-	ast_mutex_unlock(&chan->lock);
+	ast_channel_unlock(chan);
 	return res;
 }
 
@@ -2473,7 +2448,7 @@
 	}
 	
 	/* Now we have a good choice for both. */
-	ast_mutex_lock(&chan->lock);
+	ast_channel_lock(chan);
 	*rawformat = native;
 	/* User perspective is fmt */
 	*format = fmt;
@@ -2487,7 +2462,7 @@
 	else
 		/* writing */
 		*trans = ast_translator_build_path(*rawformat, *format);
-	ast_mutex_unlock(&chan->lock);
+	ast_channel_unlock(chan);
 	if (option_debug)
 		ast_log(LOG_DEBUG, "Set channel %s to %s format %s\n", chan->name,
 			direction ? "write" : "read", ast_getformatname(fmt));
@@ -2723,56 +2698,21 @@
 
 int ast_readstring(struct ast_channel *c, char *s, int len, int timeout, int ftimeout, char *enders)
 {
-	int pos=0;
+	return ast_readstring_full(c, s, len, timeout, ftimeout, enders, -1, -1);
+}
+
+int ast_readstring_full(struct ast_channel *c, char *s, int len, int timeout, int ftimeout, char *enders, int audiofd, int ctrlfd)
+{
+	int pos = 0;	/* index in the buffer where we accumulate digits */
 	int to = ftimeout;
-	int d;
-
-	/* XXX Merge with full version? XXX */
+
 	/* Stop if we're a zombie or need a soft hangup */
 	if (ast_test_flag(c, AST_FLAG_ZOMBIE) || ast_check_hangup(c))
 		return -1;
 	if (!len)
 		return -1;
 	for (;;) {
-		if (c->stream) {
-			d = ast_waitstream(c, AST_DIGIT_ANY);
-			ast_stopstream(c);
-			usleep(1000);
-			if (!d)
-				d = ast_waitfordigit(c, to);
-		} else {
-			d = ast_waitfordigit(c, to);
-		}
-		if (d < 0)
-			return -1;
-		if (d == 0) {
-			s[pos]='\0';
-			return 1;
-		}
-		if (!strchr(enders, d))
-			s[pos++] = d;
-		if (strchr(enders, d) || (pos >= len)) {
-			s[pos]='\0';
-			return 0;
-		}
-		to = timeout;
-	}
-	/* Never reached */
-	return 0;
-}
-
-int ast_readstring_full(struct ast_channel *c, char *s, int len, int timeout, int ftimeout, char *enders, int audiofd, int ctrlfd)
-{
-	int pos=0;
-	int to = ftimeout;
-	int d;
-
-	/* Stop if we're a zombie or need a soft hangup */
-	if (ast_test_flag(c, AST_FLAG_ZOMBIE) || ast_check_hangup(c))
-		return -1;
-	if (!len)
-		return -1;
-	for (;;) {
+		int d;
 		if (c->stream) {
 			d = ast_waitstream_full(c, AST_DIGIT_ANY, audiofd, ctrlfd);
 			ast_stopstream(c);
@@ -3020,9 +2960,10 @@
 	   while the features are nice, the cost is very high in terms of pure nastiness. XXX */
 
 	/* We need the clone's lock, too */
-	ast_mutex_lock(&clone->lock);
-
-	ast_log(LOG_DEBUG, "Got clone lock for masquerade on '%s' at %p\n", clone->name, &clone->lock);
+	ast_channel_lock(clone);
+
+	if (option_debug > 1)
+		ast_log(LOG_DEBUG, "Got clone lock for masquerade on '%s' at %p\n", clone->name, &clone->lock);
 
 	/* Having remembered the original read/write formats, we turn off any translation on either
 	   one */
@@ -3121,7 +3062,7 @@
 		res = clone->tech->hangup(clone);
 	if (res) {
 		ast_log(LOG_WARNING, "Hangup failed!  Strange things may happen!\n");
-		ast_mutex_unlock(&clone->lock);
+		ast_channel_unlock(clone);
 		return -1;
 	}
 	
@@ -3186,7 +3127,8 @@
 	/* Copy the music class */
 	ast_string_field_set(original, musicclass, clone->musicclass);
 
-	ast_log(LOG_DEBUG, "Putting channel %s in %d/%d formats\n", original->name, wformat, rformat);
+	if (option_debug)
+		ast_log(LOG_DEBUG, "Putting channel %s in %d/%d formats\n", original->name, wformat, rformat);
 
 	/* Okay.  Last thing is to let the channel driver know about all this mess, so he
 	   can fix up everything as best as possible */
@@ -3195,7 +3137,7 @@
 		if (res) {
 			ast_log(LOG_WARNING, "Channel for type '%s' could not fixup channel %s\n",
 				original->tech->type, original->name);
-			ast_mutex_unlock(&clone->lock);
+			ast_channel_unlock(clone);
 			return -1;
 		}
 	} else
@@ -3206,8 +3148,9 @@
 	   a zombie so nothing tries to touch it.  If it's already been marked as a
 	   zombie, then free it now (since it already is considered invalid). */
 	if (ast_test_flag(clone, AST_FLAG_ZOMBIE)) {
-		ast_log(LOG_DEBUG, "Destroying channel clone '%s'\n", clone->name);
-		ast_mutex_unlock(&clone->lock);
+		if (option_debug)
+			ast_log(LOG_DEBUG, "Destroying channel clone '%s'\n", clone->name);
+		ast_channel_unlock(clone);
 		manager_event(EVENT_FLAG_CALL, "Hangup",
 			"Channel: %s\r\n"
 			"Uniqueid: %s\r\n"
@@ -3223,13 +3166,14 @@
 		ast_log(LOG_DEBUG, "Released clone lock on '%s'\n", clone->name);
 		ast_set_flag(clone, AST_FLAG_ZOMBIE);
 		ast_queue_frame(clone, &ast_null_frame);
-		ast_mutex_unlock(&clone->lock);
+		ast_channel_unlock(clone);
 	}
 	
 	/* Signal any blocker */
 	if (ast_test_flag(original, AST_FLAG_BLOCKING))
 		pthread_kill(original->blocker, SIGURG);
-	ast_log(LOG_DEBUG, "Done Masquerading %s (%d)\n", original->name, original->_state);
+	if (option_debug)
+		ast_log(LOG_DEBUG, "Done Masquerading %s (%d)\n", original->name, original->_state);
 	return 0;
 }
 
@@ -4278,7 +4222,7 @@
 
 /*! \brief Lock AST channel (and print debugging output)
 \note	You need to enable DEBUG_CHANNEL_LOCKS for this function */
-int __ast_channel_trylock(struct ast_channel *chan)
+int ast_channel_trylock(struct ast_channel *chan)
 {
 	int res;
 

Modified: team/oej/siptransfer/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/team/oej/siptransfer/channels/chan_agent.c?rev=20706&r1=20705&r2=20706&view=diff
==============================================================================
--- team/oej/siptransfer/channels/chan_agent.c (original)
+++ team/oej/siptransfer/channels/chan_agent.c Sun Apr 16 17:45:30 2006
@@ -156,6 +156,7 @@
 static int autologoff;
 static int wrapuptime;
 static int ackcall;
+static int endcall;
 static int multiplelogin = 1;
 static int autologoffunavail = 0;
 
@@ -498,7 +499,7 @@
  				p->acknowledged = 1;
  				ast_frfree(f);
  				f = &answer_frame;
- 			} else if (f->subclass == '*') {
+ 			} else if (f->subclass == '*' && endcall) {
  				/* terminates call */
  				ast_frfree(f);
  				f = NULL;
@@ -988,6 +989,7 @@
 	autologoff = 0;
 	wrapuptime = 0;
 	ackcall = 0;
+	endcall = 1;
 	cfg = ast_config_load(config);
 	if (!cfg) {
 		ast_log(LOG_NOTICE, "No agent configuration found -- agent support disabled\n");
@@ -1032,6 +1034,8 @@
 				ackcall = 1;
 			else
 				ackcall = 0;
+		} else if (!strcasecmp(v->name, "endcall")) {
+			endcall = ast_true(v->value);
 		} else if (!strcasecmp(v->name, "wrapuptime")) {
 			wrapuptime = atoi(v->value);
 			if (wrapuptime < 0)

Modified: team/oej/siptransfer/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/oej/siptransfer/channels/chan_iax2.c?rev=20706&r1=20705&r2=20706&view=diff
==============================================================================
--- team/oej/siptransfer/channels/chan_iax2.c (original)
+++ team/oej/siptransfer/channels/chan_iax2.c Sun Apr 16 17:45:30 2006
@@ -1530,7 +1530,7 @@
 		cur = cur->next;
 	}
 	/* Now that we've freed them, load the new ones */
-	snprintf(dir, sizeof(dir), "%s/firmware/iax", (char *)ast_config_AST_VAR_DIR);
+	snprintf(dir, sizeof(dir), "%s/firmware/iax", (char *)ast_config_AST_DATA_DIR);
 	fwd = opendir(dir);
 	if (fwd) {
 		while((de = readdir(fwd))) {

Modified: team/oej/siptransfer/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/oej/siptransfer/channels/chan_sip.c?rev=20706&r1=20705&r2=20706&view=diff
==============================================================================
--- team/oej/siptransfer/channels/chan_sip.c (original)
+++ team/oej/siptransfer/channels/chan_sip.c Sun Apr 16 17:45:30 2006
@@ -938,8 +938,6 @@
 	int lastms;			/*!<  How long last response took (in ms), or -1 for no response */
 	int maxms;			/*!<  Max ms we will accept for the host to be up, 0 to not monitor */
 	struct timeval ps;		/*!<  Ping send time */
-	enum transfermodes allowtransfer;   /*!< Allow transfer modes */
-	
 	struct sockaddr_in defaddr;	/*!<  Default IP address, used until registration */
 	struct ast_ha *ha;		/*!<  Access control list */
 	struct ast_variable *chanvars;	/*!<  Variables to set for channel created by user */
@@ -1088,7 +1086,7 @@
 static int sip_send_mwi_to_peer(struct sip_peer *peer);
 static int sip_scheddestroy(struct sip_pvt *p, int ms);
 
-/*------Request handling functions */
+/*------Request handling functions (called from handle_request() )*/
 static int handle_request_invite(struct sip_pvt *p, struct sip_request *req, int debug, int seqno, struct sockaddr_in *sin, int *recount, char *e);
 static int handle_request_refer(struct sip_pvt *p, struct sip_request *req, int debug, int ignore, int seqno, int *nounlock);
 static int handle_request_bye(struct sip_pvt *p, struct sip_request *req);
@@ -1098,6 +1096,8 @@
 static int handle_request_subscribe(struct sip_pvt *p, struct sip_request *req, struct sockaddr_in *sin, int seqno, char *e);
 static void handle_request_info(struct sip_pvt *p, struct sip_request *req);
 static int handle_request_options(struct sip_pvt *p, struct sip_request *req);
+/*------ Response handling functions (called from handle_response() ) */
+static int handle_response_peerpoke(struct sip_pvt *p, int resp, char *rest, struct sip_request *req, int seqno);
 
 /*----- RTP interface functions */
 static int sip_set_rtp_peer(struct ast_channel *chan, struct ast_rtp *rtp, struct ast_rtp *vrtp, int codecs, int nat_active);
@@ -1127,119 +1127,6 @@
 	.send_text = sip_sendtext,
 };
 
-/*! \brief Unlock AST channel (and print debugging output) */
-int ast_channel_unlock(struct ast_channel *chan)
-{
-	int res = 0;
-	if (option_debug > 3) {
-		ast_log(LOG_DEBUG, "::::==== Unlocking AST channel %s\n", chan->name);
-	}
-	if (!chan) {
-		ast_log(LOG_DEBUG, "::::==== Unlocking non-existing channel \n");
-	return 0;
-	}
-
-	res = ast_mutex_unlock(&chan->lock);
-
-	if (option_debug > 3) {
-#ifdef __linux__
-		int count = 0;
-#ifdef DEBUG_THREADS
-		if ((count = chan->lock.mutex.__m_count))
-#else
-	//      if ((count = chan->lock.__m_count))
-#endif
-		ast_log(LOG_DEBUG, ":::=== Still have %d locks (recursive)\n", count);
-#endif
-		if (!res)
-			ast_log(LOG_DEBUG, "::::==== Channel %s was unlocked\n", chan->name);
-			if (res == EINVAL) {
-				ast_log(LOG_DEBUG, "::::==== Channel %s had no lock by this thread. Failed unlocking\n", chan->name);
-			}
-		}
-		if (res == EPERM) {
-		/* We had no lock, so okay any way*/
-		if (option_debug > 3)
-			ast_log(LOG_DEBUG, "::::==== Channel %s was not locked at all \n", chan->name);
-			res = 0;
-	}
-	return res;
-}
-
-/*! \brief Lock AST channel (and print debugging output) */
-int ast_channel_lock(struct ast_channel *chan)
-{
-	int res;
-
-	if (option_debug > 3)
-		ast_log(LOG_DEBUG, "====:::: Locking AST channel %s\n", chan->name);
-
-	res = ast_mutex_lock(&chan->lock);
-
-	if (option_debug > 3) {
-#ifdef __linux__
-		int count = 0;
-#ifdef DEBUG_THREADS
-		if ((count = chan->lock.mutex.__m_count))
-#else
-		if ((count = chan->lock.__m_count))
-#endif
-		ast_log(LOG_DEBUG, ":::=== Now have %d locks (recursive)\n", count);
-#endif
-		if (!res)
-			ast_log(LOG_DEBUG, "::::==== Channel %s was locked\n", chan->name);
-		if (res == EDEADLK) {
-		/* We had no lock, so okey any way */
-		if (option_debug > 3)
-			ast_log(LOG_DEBUG, "::::==== Channel %s was not locked by us. Lock would cause deadlock.\n", chan->name);
-		}
-		if (res == EINVAL) {
-			if (option_debug > 3)
-				ast_log(LOG_DEBUG, "::::==== Channel %s lock failed. No mutex.\n", chan->name);
-		}
-	}
-	return res;
-}
-
-/*! \brief Lock AST channel (and print debugging output) */
-int ast_channel_trylock(struct ast_channel *chan, char *who)
-{
-	int res;
-
-	if (option_debug > 3)
-		ast_log(LOG_DEBUG, "====:::: %s: Trying to lock AST channel %s\n", who, chan->name);
-	res = ast_mutex_trylock(&chan->lock);
-
-	if (option_debug > 3) {
-#ifdef __linux__
-		int count = 0;
-#ifdef DEBUG_THREADS
-		if ((count = chan->lock.mutex.__m_count))
-#else
-		if ((count = chan->lock.__m_count))
-#endif
-		ast_log(LOG_DEBUG, ":::=== Now have %d locks (recursive)\n", count);
-#endif
-		if (!res)
-			ast_log(LOG_DEBUG, "::::==== Channel %s was locked\n", chan->name);
-		if (res == EBUSY) {
-		/* We failed to lock */
-		if (option_debug > 3)
-			ast_log(LOG_DEBUG, "::::==== Channel %s failed to lock. Not waiting around...\n", chan->name);
-		}
-		if (res == EDEADLK) {
-			/* We had no lock, so okey any way*/
-			if (option_debug > 3)
-				ast_log(LOG_DEBUG, "::::==== Channel %s was not locked. Lock would cause deadlock.\n", chan->name);
-		}
-		if (res == EINVAL) {
-			if (option_debug > 3)
-				ast_log(LOG_DEBUG, "::::==== Channel %s lock failed. No mutex.\n", chan->name);
-		}
-	}
-	return res;
-}
-
 /*! \brief Convert transfer status to string */
 static char *referstatus2str(enum referstatus rstatus)
 {
@@ -1261,20 +1148,6 @@
 	set_rtp_peer: sip_set_rtp_peer,
 	get_codec: sip_get_codec,
 };
-
-/*! \brief Convert transfer status to string */
-static char *referstatus2str(enum referstatus rstatus)
-{
-	int i = (sizeof(referstatusstrings) / sizeof(referstatusstrings[0]));
-	int x;
-
-	for (x = 0; x < i; x++) {
-		if (referstatusstrings[x].status ==  rstatus)
-			return (char *) referstatusstrings[x].text;
-	}
-	return "";
-}
-
 
 /*! \brief returns true if 'name' (with optional trailing whitespace)
  * matches the sip method 'id'.
@@ -1490,7 +1363,7 @@
 	int reschedule = DEFAULT_RETRANS;
 
 	/* Lock channel */
-	ast_channel_lock(&pkt->owner);
+	ast_mutex_lock(&pkt->owner->lock);
 
 	if (pkt->retrans < MAX_RETRANS) {
 		pkt->retrans++;
@@ -1527,7 +1400,7 @@
 
 		append_history(pkt->owner, "ReTx", "%d %s", reschedule, pkt->data);
 		__sip_xmit(pkt->owner, pkt->data, pkt->packetlen);
-		ast_channel_unlock(&pkt->owner);
+		ast_mutex_unlock(&pkt->owner->lock);
 		return  reschedule;
 	} 
 	/* Too many retries */
@@ -7106,7 +6979,7 @@
 			ast_mutex_lock(&sip_pvt_ptr->lock);
 
 			if (option_debug > 3)				 
-		ast_log(LOG_DEBUG, "Matched %s call - their tag is %s Our tag is %s\n", ast_test_flag(&sip_pvt_ptr->flags[0], SIP_OUTGOING) ? "OUTGOING": "INCOMING", sip_pvt_ptr->theirtag, sip_pvt_ptr->tag);
+				ast_log(LOG_DEBUG, "Matched %s call - their tag is %s Our tag is %s\n", ast_test_flag(&sip_pvt_ptr->flags[0], SIP_OUTGOING) ? "OUTGOING": "INCOMING", sip_pvt_ptr->theirtag, sip_pvt_ptr->tag);
 			/* Their tag is fromtag, our tag is to-tag */
 
 			if (pedanticsipchecking) {
@@ -7127,7 +7000,7 @@
 				ast_log(LOG_DEBUG, "Found match for callid %s\n", callid);
 
 			if (sip_pvt_ptr->owner) {
-				while(ast_channel_trylock(sip_pvt_ptr->owner, "getsippvt...")) {
+				while(ast_channel_trylock(sip_pvt_ptr->owner)) {
 					if (option_debug > 3)
 						ast_log(LOG_DEBUG, "Locked channel %s\n", sip_pvt_ptr->owner->name);
 					ast_mutex_unlock(&sip_pvt_ptr->lock);
@@ -10414,58 +10287,53 @@
 }
 
 /*! \brief Handle qualification responses (OPTIONS) */
-static int handle_response_peerpoke(struct sip_pvt *p, int resp, char *rest, struct sip_request *req, int ignore, int seqno, int sipmethod)
+static int handle_response_peerpoke(struct sip_pvt *p, int resp, char *rest, struct sip_request *req, int seqno)
 {
 	struct sip_peer *peer;
 	int pingtime;
 	struct timeval tv;
-
-	if (resp != 100) {
-		int statechanged = 0;
-		int newstate = 0;
-		peer = p->relatedpeer;
-		gettimeofday(&tv, NULL);
-		pingtime = ast_tvdiff_ms(tv, peer->ps);
-		if (pingtime < 1)
-			pingtime = 1;
-		if ((peer->lastms < 0)  || (peer->lastms > peer->maxms)) {
-			if (pingtime <= peer->maxms) {
-				ast_log(LOG_NOTICE, "Peer '%s' is now REACHABLE! (%dms / %dms)\n", peer->name, pingtime, peer->maxms);
-				statechanged = 1;
-				newstate = 1;
-			}
-		} else if ((peer->lastms > 0) && (peer->lastms <= peer->maxms)) {
-			if (pingtime > peer->maxms) {
-				ast_log(LOG_NOTICE, "Peer '%s' is now TOO LAGGED! (%dms / %dms)\n", peer->name, pingtime, peer->maxms);
-				statechanged = 1;
-				newstate = 2;
-			}
-		}
-		if (!peer->lastms)
+	int statechanged = 0;
+	int newstate = 0;
+
+	if (resp == 100) 	/* Trying */
+		return 1;
+
+	peer = p->relatedpeer;
+	gettimeofday(&tv, NULL);
+	pingtime = ast_tvdiff_ms(tv, peer->ps);
+	if (pingtime < 1)
+		pingtime = 1;
+	if ((peer->lastms < 0)  || (peer->lastms > peer->maxms)) {
+		if (pingtime <= peer->maxms) {
+			ast_log(LOG_NOTICE, "Peer '%s' is now REACHABLE! (%dms / %dms)\n", peer->name, pingtime, peer->maxms);
 			statechanged = 1;
-		peer->lastms = pingtime;
-		peer->call = NULL;
-		if (statechanged) {
-			ast_device_state_changed("SIP/%s", peer->name);
-			if (newstate == 2) {
-				manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "Peer: SIP/%s\r\nPeerStatus: Lagged\r\nTime: %d\r\n", peer->name, pingtime);
-			} else {
-				manager_event(EVENT_FLAG_SYSTEM, "PeerStatus", "Peer: SIP/%s\r\nPeerStatus: Reachable\r\nTime: %d\r\n", peer->name, pingtime);
-			}
-		}
-
-		if (peer->pokeexpire > -1)
-			ast_sched_del(sched, peer->pokeexpire);
-		if (sipmethod == SIP_INVITE)	/* Does this really happen? */
-			transmit_request(p, SIP_ACK, seqno, XMIT_UNRELIABLE, 0);
-		ast_set_flag(&p->flags[0], SIP_NEEDDESTROY);	
-
-		/* Try again eventually */
-		if ((peer->lastms < 0)  || (peer->lastms > peer->maxms))
-			peer->pokeexpire = ast_sched_add(sched, DEFAULT_FREQ_NOTOK, sip_poke_peer_s, peer);
-		else
-			peer->pokeexpire = ast_sched_add(sched, DEFAULT_FREQ_OK, sip_poke_peer_s, peer);
-	}
+			newstate = 1;
+		}
+	} else if ((peer->lastms > 0) && (peer->lastms <= peer->maxms)) {

[... 223 lines stripped ...]


More information about the asterisk-commits mailing list