[asterisk-commits] markster: branch markster/usersconf r40655 - in /team/markster/usersconf: ./ ...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sun Aug 20 09:16:44 MST 2006


Author: markster
Date: Sun Aug 20 11:16:43 2006
New Revision: 40655

URL: http://svn.digium.com/view/asterisk?rev=40655&view=rev
Log:
Merged revisions 40424,40426,40452,40489,40521,40561,40563,40566,40599-40600,40602,40632 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/trunk

................
r40424 | russell | 2006-08-18 19:33:44 -0500 (Fri, 18 Aug 2006) | 2 lines

convert lists of constants in channel.h to enums instead of #defines

................
r40426 | qwell | 2006-08-18 19:53:54 -0500 (Fri, 18 Aug 2006) | 8 lines

Fix a bug with app_voicemail when trying to use app_directory to leave messages
to another user (options 3, 5, 2).

If the context/extension didn't exist in the dialplan (and why should it have to?),
it would fail, saying that it's an "invalid extension".

(issue BE-71)

................
r40452 | qwell | 2006-08-18 20:06:53 -0500 (Fri, 18 Aug 2006) | 1 line

Blocking 1.2 rev 40446 from merging to trunk
................
r40489 | russell | 2006-08-18 22:50:15 -0500 (Fri, 18 Aug 2006) | 2 lines

suppress warnings introduced by putting states in an enum

................
r40521 | kpfleming | 2006-08-19 12:05:43 -0500 (Sat, 19 Aug 2006) | 2 lines

deprecate chan_agent callback mode

................
r40561 | qwell | 2006-08-19 20:25:02 -0500 (Sat, 19 Aug 2006) | 6 lines

Fix minor display issues in "skinny show devices".

Patch by wedhorn with minor modifications by me.

Issue 7766

................
r40563 | qwell | 2006-08-19 20:27:24 -0500 (Sat, 19 Aug 2006) | 2 lines

Make the CIPC device string useful

................
r40566 | file | 2006-08-19 20:42:41 -0500 (Sat, 19 Aug 2006) | 2 lines

kpfleming didn't break trunk, it was the aliens. (fix it so that the Makefile references the new name for the XML tree, menuselect-tree)

................
r40599 | file | 2006-08-19 23:25:28 -0500 (Sat, 19 Aug 2006) | 2 lines

Properly check to see if parkingnum is a number (issue #7762 reported by robf)

................
r40600 | qwell | 2006-08-19 23:39:57 -0500 (Sat, 19 Aug 2006) | 4 lines

Converted device2str and control2str to use thread local storage.

Thanks Russell.

................
r40602 | file | 2006-08-19 23:51:06 -0500 (Sat, 19 Aug 2006) | 9 lines

Blocked revisions 40601 via svnmerge

........
r40601 | file | 2006-08-20 00:49:48 -0400 (Sun, 20 Aug 2006) | 2 lines

Turn media level c= parsing on by default (issue #7725 reported by psm)

........

................
r40632 | tilghman | 2006-08-20 10:46:00 -0500 (Sun, 20 Aug 2006) | 2 lines

Convert func_odbc to use the prepare_and_execute callback, which helps with a database reconnection issue (bug 7693)

................

Modified:
    team/markster/usersconf/   (props changed)
    team/markster/usersconf/.cleancount
    team/markster/usersconf/Makefile
    team/markster/usersconf/UPGRADE.txt
    team/markster/usersconf/apps/app_directory.c
    team/markster/usersconf/apps/app_voicemail.c
    team/markster/usersconf/channel.c
    team/markster/usersconf/channels/chan_agent.c
    team/markster/usersconf/channels/chan_skinny.c
    team/markster/usersconf/channels/chan_vpb.cc
    team/markster/usersconf/funcs/func_odbc.c
    team/markster/usersconf/include/asterisk/channel.h
    team/markster/usersconf/res/res_features.c
    team/markster/usersconf/res/res_odbc.c

Propchange: team/markster/usersconf/
------------------------------------------------------------------------------
Binary property 'branch-1.2-blocked' - no diff available.

Propchange: team/markster/usersconf/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Sun Aug 20 11:16:43 2006
@@ -1,1 +1,1 @@
-/trunk:1-40407
+/trunk:1-40654

Modified: team/markster/usersconf/.cleancount
URL: http://svn.digium.com/view/asterisk/team/markster/usersconf/.cleancount?rev=40655&r1=40654&r2=40655&view=diff
==============================================================================
--- team/markster/usersconf/.cleancount (original)
+++ team/markster/usersconf/.cleancount Sun Aug 20 11:16:43 2006
@@ -1,1 +1,1 @@
-20
+21

Modified: team/markster/usersconf/Makefile
URL: http://svn.digium.com/view/asterisk/team/markster/usersconf/Makefile?rev=40655&r1=40654&r2=40655&view=diff
==============================================================================
--- team/markster/usersconf/Makefile (original)
+++ team/markster/usersconf/Makefile Sun Aug 20 11:16:43 2006
@@ -414,7 +414,7 @@
 	@echo "****"
 	@exit 1
 
-menuselect.makeopts menuselect.makedeps: menuselect/menuselect makeopts.xml
+menuselect.makeopts menuselect.makedeps: menuselect/menuselect menuselect-tree
 	menuselect/menuselect --check-deps $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS) menuselect.makeopts
 
 #ifneq ($(wildcard tags),)
@@ -541,7 +541,7 @@
 	@$(MAKE) -C mxml clean
 	@$(MAKE) -C menuselect dist-clean
 	@$(MAKE) -C sounds dist-clean
-	rm -f menuselect.makeopts makeopts makeopts.xml menuselect.makedeps
+	rm -f menuselect.makeopts makeopts menuselect-tree menuselect.makedeps
 	rm -f config.log config.status
 	rm -rf autom4te.cache
 	rm -f include/asterisk/autoconfig.h
@@ -902,7 +902,7 @@
 	rm -rf $(DESTDIR)$(ASTETCDIR)
 	rm -rf $(DESTDIR)$(ASTLOGDIR)
 
-menuselect: menuselect/menuselect makeopts.xml
+menuselect: menuselect/menuselect menuselect-tree
 	- at menuselect/menuselect $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS) menuselect.makeopts && echo "menuselect changes saved!" || echo "menuselect changes NOT saved!"
 
 menuselect/menuselect: menuselect/menuselect.c menuselect/menuselect_curses.c menuselect/menuselect_stub.c menuselect/menuselect.h menuselect/linkedlists.h config.status mxml/libmxml.a
@@ -912,7 +912,7 @@
 	@cd mxml && unset CFLAGS AST_LIBS && test -f config.h || ./configure
 	$(MAKE) -C mxml libmxml.a
 
-makeopts.xml: $(foreach dir,$(MOD_SUBDIRS),$(wildcard $(dir)/*.c) $(wildcard $(dir)/*.cc)) build_tools/cflags.xml sounds/sounds.xml
+menuselect-tree: $(foreach dir,$(MOD_SUBDIRS),$(wildcard $(dir)/*.c) $(wildcard $(dir)/*.cc)) build_tools/cflags.xml sounds/sounds.xml
 	@echo "Generating list of available modules ..."
 	@build_tools/prep_moduledeps > $@
 

Modified: team/markster/usersconf/UPGRADE.txt
URL: http://svn.digium.com/view/asterisk/team/markster/usersconf/UPGRADE.txt?rev=40655&r1=40654&r2=40655&view=diff
==============================================================================
--- team/markster/usersconf/UPGRADE.txt (original)
+++ team/markster/usersconf/UPGRADE.txt Sun Aug 20 11:16:43 2006
@@ -293,6 +293,13 @@
 * Support for MFC/R2 has been removed, as it has not been functional for some
   time and it has no maintainer.
 
+The Agent channel:
+
+* Callback mode (AgentCallbackLogin) is now deprecated, since the entire function
+  it provided can be done using dialplan logic, without requiring additional
+  channel and module locks (which frequently caused deadlocks). An example of
+  how to do this using AEL dialplan is in doc/queues-with-callback-members.txt.
+
 The G726-32 codec:
 
 * It has been determined that previous versions of Asterisk used the wrong codeword
@@ -360,5 +367,5 @@
   starting music on hold on the channel. An example for how this would be
   useful is in an enterprise network of Asterisk servers. When one phone on one
   server puts a phone on a different server on hold, the remote server will be
-  responsibile for playing the hold music to its local phone that was put on
+  responsible for playing the hold music to its local phone that was put on
   hold instead of the far end server across the network playing the music.

Modified: team/markster/usersconf/apps/app_directory.c
URL: http://svn.digium.com/view/asterisk/team/markster/usersconf/apps/app_directory.c?rev=40655&r1=40654&r2=40655&view=diff
==============================================================================
--- team/markster/usersconf/apps/app_directory.c (original)
+++ team/markster/usersconf/apps/app_directory.c Sun Aug 20 11:16:43 2006
@@ -259,7 +259,8 @@
  *           '*' for skipped entry from directory
  */
 static int play_mailbox_owner(struct ast_channel *chan, char *context,
-		char *dialcontext, char *ext, char *name, int readext)
+		char *dialcontext, char *ext, char *name, int readext,
+		int fromappvm)
 {
 	int res = 0;
 	int loop;
@@ -311,12 +312,17 @@
 		if (res < 0) /* User hungup, so jump out now */
 			break;
 		if (res == '1') {	/* Name selected */
-			if (ast_goto_if_exists(chan, dialcontext, ext, 1)) {
-				ast_log(LOG_WARNING,
-					"Can't find extension '%s' in context '%s'.  "
-					"Did you pass the wrong context to Directory?\n",
-					ext, dialcontext);
-				res = -1;
+			if (fromappvm) {
+				/* We still want to set the exten though */
+				ast_copy_string(chan->exten, ext, sizeof(chan->exten));
+			} else {
+				if (ast_goto_if_exists(chan, dialcontext, ext, 1)) {
+					ast_log(LOG_WARNING,
+						"Can't find extension '%s' in context '%s'.  "
+						"Did you pass the wrong context to Directory?\n",
+						ext, dialcontext);
+					res = -1;
+				}
 			}
 			break;
 		}
@@ -388,7 +394,7 @@
 	return cfg;
 }
 
-static int do_directory(struct ast_channel *chan, struct ast_config *cfg, struct ast_config *ucfg, char *context, char *dialcontext, char digit, int last, int readext)
+static int do_directory(struct ast_channel *chan, struct ast_config *cfg, struct ast_config *ucfg, char *context, char *dialcontext, char digit, int last, int readext, int fromappvm)
 {
 	/* Read in the first three digits..  "digit" is the first digit, already read */
 	char ext[NUMDIGITS + 1], *cat;
@@ -467,7 +473,7 @@
 
 			if (v) {
 				/* We have a match -- play a greeting if they have it */
-				res = play_mailbox_owner(chan, context, dialcontext, v->name, name, readext);
+				res = play_mailbox_owner(chan, context, dialcontext, v->name, name, readext, fromappvm);
 				switch (res) {
 					case -1:
 						/* user pressed '1' but extension does not exist, or
@@ -564,6 +570,7 @@
 	struct ast_config *cfg, *ucfg;
 	int last = 1;
 	int readext = 0;
+	int fromappvm = 0;
 	char *dirintro, *parse;
 	AST_DECLARE_APP_ARGS(args,
 		AST_APP_ARG(vmcontext);
@@ -587,6 +594,8 @@
 			last = 0;
 		if (strchr(args.options, 'e'))
 			readext = 1;
+		if (strchr(args.options, 'v'))
+			fromappvm = 1;
 	}
 
 	if (ast_strlen_zero(args.dialcontext))	
@@ -617,7 +626,7 @@
 		if (!res)
 			res = ast_waitfordigit(chan, 5000);
 		if (res > 0) {
-			res = do_directory(chan, cfg, ucfg, args.vmcontext, args.dialcontext, res, last, readext);
+			res = do_directory(chan, cfg, ucfg, args.vmcontext, args.dialcontext, res, last, readext, fromappvm);
 			if (res > 0) {
 				res = ast_waitstream(chan, AST_DIGIT_ANY);
 				ast_stopstream(chan);

Modified: team/markster/usersconf/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/markster/usersconf/apps/app_voicemail.c?rev=40655&r1=40654&r2=40655&view=diff
==============================================================================
--- team/markster/usersconf/apps/app_voicemail.c (original)
+++ team/markster/usersconf/apps/app_voicemail.c Sun Aug 20 11:16:43 2006
@@ -3871,13 +3871,15 @@
 			
 			app = pbx_findapp("Directory");
 			if (app) {
-				/* make mackup copies */
+				char vmcontext[256];
+				/* make backup copies */
 				memcpy(old_context, chan->context, sizeof(chan->context));
 				memcpy(old_exten, chan->exten, sizeof(chan->exten));
 				old_priority = chan->priority;
 				
 				/* call the the Directory, changes the channel */
-				res = pbx_exec(chan, app, context ? context : "default");
+				sprintf(vmcontext, "%s||v", context ? context : "default");
+				res = pbx_exec(chan, app, vmcontext);
 				
 				ast_copy_string(username, chan->exten, sizeof(username));
 				

Modified: team/markster/usersconf/channel.c
URL: http://svn.digium.com/view/asterisk/team/markster/usersconf/channel.c?rev=40655&r1=40654&r2=40655&view=diff
==============================================================================
--- team/markster/usersconf/channel.c (original)
+++ team/markster/usersconf/channel.c Sun Aug 20 11:16:43 2006
@@ -492,7 +492,7 @@
 }
 
 /*! \brief Gives the string form of a given channel state */
-char *ast_state2str(int state)
+char *ast_state2str(enum ast_channel_state state)
 {
 	char *buf;
 
@@ -1563,6 +1563,8 @@
 		break;
 	case AST_STATE_UP:
 		ast_cdr_answer(chan->cdr);
+		break;
+	default:
 		break;
 	}
 	ast_channel_unlock(chan);
@@ -3340,7 +3342,7 @@
 				);
 }
 
-int ast_setstate(struct ast_channel *chan, int state)
+int ast_setstate(struct ast_channel *chan, enum ast_channel_state state)
 {
 	int oldstate = chan->_state;
 

Modified: team/markster/usersconf/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/team/markster/usersconf/channels/chan_agent.c?rev=40655&r1=40654&r2=40655&view=diff
==============================================================================
--- team/markster/usersconf/channels/chan_agent.c (original)
+++ team/markster/usersconf/channels/chan_agent.c Sun Aug 20 11:16:43 2006
@@ -2137,6 +2137,19 @@
 	return __login_exec(chan, data, 0);
 }
 
+static void callback_deprecated(void)
+{
+	static int depwarning = 0;
+
+	if (!depwarning) {
+		depwarning = 1;
+
+		ast_log(LOG_WARNING, "AgentCallbackLogin is deprecated and will be removed in a future release.\n");
+		ast_log(LOG_WARNING, "See doc/queues-with-callback-members.txt for an example of how to achieve\n");
+		ast_log(LOG_WARNING, "the same functionality using only dialplan logic.\n");
+	}
+}
+
 /*!
  *  Called by the AgentCallbackLogin application (from the dial plan).
  * 
@@ -2147,6 +2160,8 @@
  */
 static int callback_exec(struct ast_channel *chan, void *data)
 {
+	callback_deprecated();
+
 	return __login_exec(chan, data, 1);
 }
 
@@ -2167,6 +2182,8 @@
 	char *ackcall_s = astman_get_header(m, "AckCall");
 	struct agent_pvt *p;
 	int login_state = 0;
+
+	callback_deprecated();
 
 	if (ast_strlen_zero(agent)) {
 		astman_send_error(s, m, "No agent specified");

Modified: team/markster/usersconf/channels/chan_skinny.c
URL: http://svn.digium.com/view/asterisk/team/markster/usersconf/channels/chan_skinny.c?rev=40655&r1=40654&r2=40655&view=diff
==============================================================================
--- team/markster/usersconf/channels/chan_skinny.c (original)
+++ team/markster/usersconf/channels/chan_skinny.c Sun Aug 20 11:16:43 2006
@@ -72,6 +72,7 @@
 #include "asterisk/stringfields.h"
 #include "asterisk/astobj.h"
 #include "asterisk/abstract_jb.h"
+#include "asterisk/threadstorage.h"
 
 /*************************************
  * Skinny/Asterisk Protocol Settings *
@@ -123,6 +124,12 @@
 	.impl = ""
 };
 static struct ast_jb_conf global_jbconf;
+
+AST_THREADSTORAGE(device2str_threadbuf, device2str_threadbuf_init);
+#define DEVICE2STR_BUFSIZE   15
+
+AST_THREADSTORAGE(control2str_threadbuf, control2str_threadbuf_init);
+#define CONTROL2STR_BUFSIZE   100
 
 /*********************
  * Protocol Messages *
@@ -1696,6 +1703,75 @@
 	return RESULT_SUCCESS;
 }
 
+static char *device2str(int type)
+{
+	static char *tmp;
+
+	switch (type) {
+	case SKINNY_DEVICE_NONE:
+		return "No Device";
+	case SKINNY_DEVICE_30SPPLUS:
+		return "30SP Plus";
+	case SKINNY_DEVICE_12SPPLUS:
+		return "12SP Plus";
+	case SKINNY_DEVICE_12SP:
+		return "12SP";
+	case SKINNY_DEVICE_12:
+		return "12";
+	case SKINNY_DEVICE_30VIP:
+		return "30VIP";
+	case SKINNY_DEVICE_7910:
+		return "7910";
+	case SKINNY_DEVICE_7960:
+		return "7960";
+	case SKINNY_DEVICE_7940:
+		return "7940";
+	case SKINNY_DEVICE_7935:
+		return "7935";
+	case SKINNY_DEVICE_ATA186:
+		return "ATA186";
+	case SKINNY_DEVICE_7941:
+		return "7941";
+	case SKINNY_DEVICE_7971:
+		return "7971";
+	case SKINNY_DEVICE_7985:
+		return "7985";
+	case SKINNY_DEVICE_7911:
+		return "7911";
+	case SKINNY_DEVICE_7961GE:
+		return "7961GE";
+	case SKINNY_DEVICE_7941GE:
+		return "7941GE";
+	case SKINNY_DEVICE_7905:
+		return "7905";
+	case SKINNY_DEVICE_7920:
+		return "7920";
+	case SKINNY_DEVICE_7970:
+		return "7970";
+	case SKINNY_DEVICE_7912:
+		return "7912";
+	case SKINNY_DEVICE_7902:
+		return "7902";
+	case SKINNY_DEVICE_CIPC:
+		return "IP Communicator";
+	case SKINNY_DEVICE_7961:
+		return "7961";
+	case SKINNY_DEVICE_7936:
+		return "7936";
+	case SKINNY_DEVICE_SCCPGATEWAY_AN:
+		return "SCCPGATEWAY_AN";
+	case SKINNY_DEVICE_SCCPGATEWAY_BRI:
+		return "SCCPGATEWAY_BRI";
+	case SKINNY_DEVICE_UNKNOWN:
+		return "Unknown";
+	default:
+		if (!(tmp = ast_threadstorage_get(&device2str_threadbuf, DEVICE2STR_BUFSIZE)))
+			return "Unknown";
+		snprintf(tmp, DEVICE2STR_BUFSIZE, "UNKNOWN-%d", type);
+		return tmp;
+	}
+}
+
 static int skinny_show_devices(int fd, int argc, char *argv[])
 {
 	struct skinny_device *d;
@@ -1707,19 +1783,19 @@
 	}
 	ast_mutex_lock(&devicelock);
 
-	ast_cli(fd, "Name                 DeviceId         IP              TypeId R NL\n");
-	ast_cli(fd, "-------------------- ---------------- --------------- ------ - --\n");
+	ast_cli(fd, "Name                 DeviceId         IP              Type            R NL\n");
+	ast_cli(fd, "-------------------- ---------------- --------------- --------------- - --\n");
 	for (d = devices; d; d = d->next) {
 		numlines = 0;
 		for (l = d->lines; l; l = l->next) {
 			numlines++;
 		}
 
-		ast_cli(fd, "%-20s %-16s %-15s %6X %c %2d\n",
+		ast_cli(fd, "%-20s %-16s %-15s %-15s %c %2d\n",
 				d->name,
 				d->id,
-				ast_inet_ntoa(d->addr.sin_addr),
-				d->type,
+				d->session?ast_inet_ntoa(d->session->sin.sin_addr):"",
+				device2str(d->type),
 				d->registered?'Y':'N',
 				numlines);
 	}
@@ -2402,7 +2478,7 @@
 }
 
 static char *control2str(int ind) {
-	static char tmp[100];
+	static char *tmp;
 
 	switch (ind) {
 	case AST_CONTROL_HANGUP:
@@ -2441,9 +2517,12 @@
 		return "Unhold";
 	case -1:
 		return "Stop tone";
-	}
-	snprintf(tmp, 100, "UNKNOWN-%d", ind);
-	return tmp;
+	default:
+		if (!(tmp = ast_threadstorage_get(&control2str_threadbuf, CONTROL2STR_BUFSIZE)))
+                        return "Unknown";
+		snprintf(tmp, CONTROL2STR_BUFSIZE, "UNKNOWN-%d", ind);
+		return tmp;
+	}
 }
 
 

Modified: team/markster/usersconf/channels/chan_vpb.cc
URL: http://svn.digium.com/view/asterisk/team/markster/usersconf/channels/chan_vpb.cc?rev=40655&r1=40654&r2=40655&view=diff
==============================================================================
--- team/markster/usersconf/channels/chan_vpb.cc (original)
+++ team/markster/usersconf/channels/chan_vpb.cc Sun Aug 20 11:16:43 2006
@@ -339,7 +339,7 @@
 
 } *iflist = NULL;
 
-static struct ast_channel *vpb_new(struct vpb_pvt *i, int state, char *context);
+static struct ast_channel *vpb_new(struct vpb_pvt *i, enum ast_channel_state state, char *context);
 static void *do_chanreads(void *pvt);
 
 static struct ast_channel *vpb_request(const char *type, int format, void *data, int *cause);
@@ -2618,7 +2618,7 @@
 	return NULL;
 }
 
-static struct ast_channel *vpb_new(struct vpb_pvt *me, int state, char *context)
+static struct ast_channel *vpb_new(struct vpb_pvt *me, enum ast_channel_state state, char *context)
 {
 	struct ast_channel *tmp; 
 	char cid_num[256];

Modified: team/markster/usersconf/funcs/func_odbc.c
URL: http://svn.digium.com/view/asterisk/team/markster/usersconf/funcs/func_odbc.c?rev=40655&r1=40654&r2=40655&view=diff
==============================================================================
--- team/markster/usersconf/funcs/func_odbc.c (original)
+++ team/markster/usersconf/funcs/func_odbc.c Sun Aug 20 11:16:43 2006
@@ -68,16 +68,27 @@
 
 AST_LIST_HEAD_STATIC(queries, acf_odbc_query);
 
-#ifdef NEEDTRACE
-static void acf_odbc_error(SQLHSTMT stmt, int res)
-{
-	char state[10] = "", diagnostic[256] = "";
-	SQLINTEGER nativeerror = 0;
-	SQLSMALLINT diagbytes = 0;
-	SQLGetDiagRec(SQL_HANDLE_STMT, stmt, 1, state, &nativeerror, diagnostic, sizeof(diagnostic), &diagbytes);
-	ast_log(LOG_WARNING, "SQL return value %d: error %s: %s (len %d)\n", res, state, diagnostic, diagbytes);
-}
-#endif
+static SQLHSTMT generic_prepare(struct odbc_obj *obj, void *data)
+{
+	int res;
+	char *sql = data;
+	SQLHSTMT stmt;
+
+	res = SQLAllocHandle (SQL_HANDLE_STMT, obj->con, &stmt);
+	if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
+		ast_log(LOG_WARNING, "SQL Alloc Handle failed!\n");
+		return NULL;
+	}
+
+	res = SQLPrepare(stmt, (unsigned char *)sql, SQL_NTS);
+	if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
+		ast_log(LOG_WARNING, "SQL Prepare failed![%s]\n", sql);
+		SQLFreeHandle (SQL_HANDLE_STMT, stmt);
+		return NULL;
+	}
+
+	return stmt;
+}
 
 /*
  * Master control routine
@@ -87,7 +98,7 @@
 	struct odbc_obj *obj;
 	struct acf_odbc_query *query;
 	char *t, buf[2048]="", varname[15];
-	int res, i, retry=0;
+	int i;
 	AST_DECLARE_APP_ARGS(values,
 		AST_APP_ARG(field)[100];
 	);
@@ -95,13 +106,7 @@
 		AST_APP_ARG(field)[100];
 	);
 	SQLHSTMT stmt;
-	SQLINTEGER nativeerror=0, numfields=0, rows=0;
-	SQLSMALLINT diagbytes=0;
-	unsigned char state[10], diagnostic[256];
-#ifdef NEEDTRACE
-	SQLINTEGER enable = 1;
-	char *tracefile = "/tmp/odbc.trace";
-#endif
+	SQLINTEGER rows=0;
 
 	AST_LIST_LOCK(&queries);
 	AST_LIST_TRAVERSE(&queries, query, list) {
@@ -119,7 +124,7 @@
 	obj = odbc_request_obj(query->dsn, 0);
 
 	if (!obj) {
-		ast_log(LOG_ERROR, "No such DSN registered (or out of connections): %s (check res_odbc.conf)\n", query->dsn);
+		ast_log(LOG_ERROR, "No database handle available with the name of '%s' (check res_odbc.conf)\n", query->dsn);
 		AST_LIST_UNLOCK(&queries);
 		return -1;
 	}
@@ -166,50 +171,9 @@
 
 	AST_LIST_UNLOCK(&queries);
 
-retry_write:
-#ifdef NEEDTRACE
-	SQLSetConnectAttr(obj->con, SQL_ATTR_TRACE, &enable, SQL_IS_INTEGER);
-	SQLSetConnectAttr(obj->con, SQL_ATTR_TRACEFILE, tracefile, strlen(tracefile));
-#endif
-
-	res = SQLAllocHandle (SQL_HANDLE_STMT, obj->con, &stmt);
-	if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
-		ast_log(LOG_WARNING, "SQL Alloc Handle failed!\n");
-		pbx_builtin_setvar_helper(chan, "ODBCROWS", "-1");
-		return -1;
-	}
-
-	res = SQLPrepare(stmt, (unsigned char *)buf, SQL_NTS);
-	if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
-		ast_log(LOG_WARNING, "SQL Prepare failed![%s]\n", buf);
-		SQLFreeHandle (SQL_HANDLE_STMT, stmt);
-		pbx_builtin_setvar_helper(chan, "ODBCROWS", "-1");
-		return -1;
-	}
-
-	res = SQLExecute(stmt);
-	if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
-		if (res == SQL_ERROR) {
-			SQLGetDiagField(SQL_HANDLE_STMT, stmt, 1, SQL_DIAG_NUMBER, &numfields, SQL_IS_INTEGER, &diagbytes);
-			for (i = 0; i <= numfields; i++) {
-				SQLGetDiagRec(SQL_HANDLE_STMT, stmt, i + 1, state, &nativeerror, diagnostic, sizeof(diagnostic), &diagbytes);
-				ast_log(LOG_WARNING, "SQL Execute returned an error %d: %s: %s (%d)\n", res, state, diagnostic, diagbytes);
-				if (i > 10) {
-					ast_log(LOG_WARNING, "Oh, that was good.  There are really %d diagnostics?\n", (int)numfields);
-					break;
-				}
-			}
-		}
-		SQLFreeHandle(SQL_HANDLE_STMT, stmt);
-		odbc_release_obj(obj);
-		/* All handles are now invalid (after a disconnect), so we gotta redo all handles */
-		obj = odbc_request_obj(query->dsn, 1);
-		if (!retry) {
-			retry = 1;
-			goto retry_write;
-		}
-		rows = -1;
-	} else {
+	stmt = odbc_prepare_and_execute(obj, generic_prepare, buf);
+
+	if (stmt) {
 		/* Rows affected */
 		SQLRowCount(stmt, &rows);
 	}
@@ -221,11 +185,10 @@
 	snprintf(varname, sizeof(varname), "%d", (int)rows);
 	pbx_builtin_setvar_helper(chan, "ODBCROWS", varname);
 
-	if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
-		ast_log(LOG_WARNING, "SQL Execute error!\n[%s]\n\n", buf);
-	}
-
-	SQLFreeHandle(SQL_HANDLE_STMT, stmt);
+	if (stmt)
+		SQLFreeHandle(SQL_HANDLE_STMT, stmt);
+	if (obj)
+		odbc_release_obj(obj);
 
 	return 0;
 }
@@ -242,10 +205,6 @@
 	SQLHSTMT stmt;
 	SQLSMALLINT colcount=0;
 	SQLINTEGER indicator;
-#ifdef NEEDTRACE
-	SQLINTEGER enable = 1;
-	char *tracefile = "/tmp/odbc.trace";
-#endif
 
 	AST_LIST_LOCK(&queries);
 	AST_LIST_TRAVERSE(&queries, query, list) {
@@ -268,11 +227,6 @@
 		return -1;
 	}
 
-#ifdef NEEDTRACE
-	SQLSetConnectAttr(obj->con, SQL_ATTR_TRACE, &enable, SQL_IS_INTEGER);
-	SQLSetConnectAttr(obj->con, SQL_ATTR_TRACEFILE, tracefile, strlen(tracefile));
-#endif
-
 	AST_STANDARD_APP_ARGS(args, s);
 	for (x = 0; x < args.argc; x++) {
 		snprintf(varname, sizeof(varname), "ARG%d", x + 1);
@@ -292,23 +246,10 @@
 
 	AST_LIST_UNLOCK(&queries);
 
-	res = SQLAllocHandle (SQL_HANDLE_STMT, obj->con, &stmt);
-	if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
-		ast_log(LOG_WARNING, "SQL Alloc Handle failed!\n");
-		return -1;
-	}
-
-	res = SQLPrepare(stmt, (unsigned char *)sql, SQL_NTS);
-	if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
-		ast_log(LOG_WARNING, "SQL Prepare failed![%s]\n", sql);
-		SQLFreeHandle (SQL_HANDLE_STMT, stmt);
-		return -1;
-	}
-
-	res = odbc_smart_execute(obj, stmt);
-	if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
-		ast_log(LOG_WARNING, "SQL Execute error!\n[%s]\n\n", sql);
-		SQLFreeHandle (SQL_HANDLE_STMT, stmt);
+	stmt = odbc_prepare_and_execute(obj, generic_prepare, sql);
+
+	if (!stmt) {
+		odbc_release_obj(obj);
 		return -1;
 	}
 
@@ -316,6 +257,7 @@
 	if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
 		ast_log(LOG_WARNING, "SQL Column Count error!\n[%s]\n\n", sql);
 		SQLFreeHandle (SQL_HANDLE_STMT, stmt);
+		odbc_release_obj(obj);
 		return -1;
 	}
 
@@ -323,15 +265,18 @@
 
 	res = SQLFetch(stmt);
 	if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
+		int res1 = -1;
 		if (res == SQL_NO_DATA) {
 			if (option_verbose > 3) {
 				ast_verbose(VERBOSE_PREFIX_4 "Found no rows [%s]\n", sql);
 			}
+			res1 = 0;
 		} else if (option_verbose > 3) {
 			ast_log(LOG_WARNING, "Error %d in FETCH [%s]\n", res, sql);
 		}
 		SQLFreeHandle(SQL_HANDLE_STMT, stmt);
-		return 0;
+		odbc_release_obj(obj);
+		return res1;
 	}
 
 	for (x = 0; x < colcount; x++) {
@@ -348,6 +293,7 @@
 		if ((res != SQL_SUCCESS) && (res != SQL_SUCCESS_WITH_INFO)) {
 			ast_log(LOG_WARNING, "SQL Get Data error!\n[%s]\n\n", sql);
 			SQLFreeHandle(SQL_HANDLE_STMT, stmt);
+			odbc_release_obj(obj);
 			return -1;
 		}
 
@@ -371,6 +317,7 @@
 	buf[buflen - 1] = '\0';
 
 	SQLFreeHandle(SQL_HANDLE_STMT, stmt);
+	odbc_release_obj(obj);
 	return 0;
 }
 

Modified: team/markster/usersconf/include/asterisk/channel.h
URL: http://svn.digium.com/view/asterisk/team/markster/usersconf/include/asterisk/channel.h?rev=40655&r1=40654&r2=40655&view=diff
==============================================================================
--- team/markster/usersconf/include/asterisk/channel.h (original)
+++ team/markster/usersconf/include/asterisk/channel.h Sun Aug 20 11:16:43 2006
@@ -274,6 +274,44 @@
 #define	DEBUGCHAN_FLAG  0x80000000
 #define	FRAMECOUNT_INC(x)	( ((x) & DEBUGCHAN_FLAG) | ((x++) & ~DEBUGCHAN_FLAG) )
 
+enum ast_channel_adsicpe {
+	AST_ADSI_UNKNOWN,
+	AST_ADSI_AVAILABLE,
+	AST_ADSI_UNAVAILABLE,
+	AST_ADSI_OFFHOOKONLY,
+};
+
+/*! 
+ * \brief ast_channel states
+ *
+ * \note Bits 0-15 of state are reserved for the state (up/down) of the line
+ *       Bits 16-32 of state are reserved for flags
+ */
+enum ast_channel_state {
+	/*! Channel is down and available */
+	AST_STATE_DOWN,
+	/*! Channel is down, but reserved */
+	AST_STATE_RESERVED,
+	/*! Channel is off hook */
+	AST_STATE_OFFHOOK,
+	/*! Digits (or equivalent) have been dialed */
+	AST_STATE_DIALING,
+	/*! Line is ringing */
+	AST_STATE_RING,
+	/*! Remote end is ringing */
+	AST_STATE_RINGING,
+	/*! Line is up */
+	AST_STATE_UP,
+	/*! Line is busy */
+	AST_STATE_BUSY,
+	/*! Digits (or equivalent) have been dialed while offhook */
+	AST_STATE_DIALING_OFFHOOK,
+	/*! Channel has detected an incoming call and is waiting for ring */
+	AST_STATE_PRERING,
+
+	/*! Do not transmit voice data */
+	AST_STATE_MUTE = (1 << 16),
+};
 
 /*! \brief Main Channel structure associated with a channel. 
  * This is the side of it mostly used by the pbx and call management.
@@ -334,7 +372,7 @@
 	int (*timingfunc)(void *data);
 	void *timingdata;
 
-	int _state;					/*!< State of line -- Don't write directly, use ast_setstate */
+	enum ast_channel_state _state;			/*!< State of line -- Don't write directly, use ast_setstate */
 	int rings;					/*!< Number of rings so far */
 	struct ast_callerid cid;			/*!< Caller ID, name, presentation etc */
 	char dtmfq[AST_MAX_EXTENSION];			/*!< Any/all queued DTMF characters */
@@ -350,7 +388,7 @@
 	struct ast_pbx *pbx;				/*!< PBX private structure for this channel */
 	int amaflags;					/*!< Set BEFORE PBX is started to determine AMA flags */
 	struct ast_cdr *cdr;				/*!< Call Detail Record */
-	int adsicpe;					/*!< Whether or not ADSI is detected on CPE */
+	enum ast_channel_adsicpe adsicpe;		/*!< Whether or not ADSI is detected on CPE */
 
 	struct tone_zone *zone;				/*!< Tone zone as set in indications.conf or
 								in the CHANNEL dialplan function */
@@ -392,30 +430,45 @@
 	AST_LIST_HEAD_NOLOCK(datastores, ast_datastore) datastores;
 };
 
-/*! \defgroup chanprop Channel tech properties:
-	\brief Channels have this property if they can accept input with jitter; i.e. most VoIP channels */
-/*! @{ */
-#define AST_CHAN_TP_WANTSJITTER	(1 << 0)	
-
-/*! \brief Channels have this property if they can create jitter; i.e. most VoIP channels */
-#define AST_CHAN_TP_CREATESJITTER (1 << 1)
-
-#define AST_FLAG_DEFER_DTMF	(1 << 1)	/*!< if dtmf should be deferred */
-#define AST_FLAG_WRITE_INT	(1 << 2)	/*!< if write should be interrupt generator */
-#define AST_FLAG_BLOCKING	(1 << 3)	/*!< if we are blocking */
-#define AST_FLAG_ZOMBIE		(1 << 4)	/*!< if we are a zombie */
-#define AST_FLAG_EXCEPTION	(1 << 5)	/*!< if there is a pending exception */
-#define AST_FLAG_MOH		(1 << 6)	/*!< XXX anthm promises me this will disappear XXX listening to moh */
-#define AST_FLAG_SPYING		(1 << 7)	/*!< is spying on someone */
-#define AST_FLAG_NBRIDGE	(1 << 8)	/*!< is it in a native bridge */
-#define AST_FLAG_IN_AUTOLOOP	(1 << 9)	/*!< the channel is in an auto-incrementing dialplan processor,
-						   so when ->priority is set, it will get incremented before
-						   finding the next priority to run */
-#define AST_FLAG_OUTGOING	(1 << 10)	/*!< Is this call outgoing */
-#define AST_FLAG_WHISPER	(1 << 11)	/*!< Is this channel being whispered on */
-
-/* @} */
-
+/*! \brief ast_channel_tech Properties */
+enum {
+	/*! \brief Channels have this property if they can accept input with jitter; 
+	 *         i.e. most VoIP channels */
+	AST_CHAN_TP_WANTSJITTER = (1 << 0),
+	/*! \brief Channels have this property if they can create jitter; 
+	 *         i.e. most VoIP channels */
+	AST_CHAN_TP_CREATESJITTER = (1 << 1),
+};
+
+/*! \brief ast_channel flags */
+enum {
+	/*! Queue incoming dtmf, to be released when this flag is turned off */
+	AST_FLAG_DEFER_DTMF =  (1 << 1),
+	/*! write should be interrupt generator */
+	AST_FLAG_WRITE_INT =   (1 << 2),
+	/*! a thread is blocking on this channel */
+	AST_FLAG_BLOCKING =    (1 << 3),
+	/*! This is a zombie channel */
+	AST_FLAG_ZOMBIE =      (1 << 4),
+	/*! There is an exception pending */
+	AST_FLAG_EXCEPTION =   (1 << 5),
+	/*! Listening to moh XXX anthm promises me this will disappear XXX */
+	AST_FLAG_MOH =         (1 << 6),
+	/*! This channel is spying on another channel */
+	AST_FLAG_SPYING =      (1 << 7),
+	/*! This channel is in a native bridge */
+	AST_FLAG_NBRIDGE =     (1 << 8),
+	/*! the channel is in an auto-incrementing dialplan processor,
+	 *  so when ->priority is set, it will get incremented before
+	 *  finding the next priority to run */
+	AST_FLAG_IN_AUTOLOOP = (1 << 9),
+	/*! This is an outgoing call */
+	AST_FLAG_OUTGOING =    (1 << 10),
+	/*! This channel is being whispered on */
+	AST_FLAG_WHISPER =     (1 << 11),
+};
+
+/*! \brief ast_bridge_config flags */
 enum {
 	AST_FEATURE_PLAY_WARNING = (1 << 0),
 	AST_FEATURE_REDIRECT =     (1 << 1),
@@ -464,53 +517,25 @@
 	struct ast_channel *parent_channel;
 };
 
-#define AST_CDR_TRANSFER	(1 << 0)
-#define AST_CDR_FORWARD		(1 << 1)
-#define AST_CDR_CALLWAIT	(1 << 2)
-#define AST_CDR_CONFERENCE	(1 << 3)
-
-#define AST_ADSI_UNKNOWN	(0)
-#define AST_ADSI_AVAILABLE	(1)
-#define AST_ADSI_UNAVAILABLE	(2)
-#define AST_ADSI_OFFHOOKONLY	(3)
-
-#define AST_SOFTHANGUP_DEV		(1 << 0)	/*!< Soft hangup by device */
-#define AST_SOFTHANGUP_ASYNCGOTO	(1 << 1)	/*!< Soft hangup for async goto */
-#define AST_SOFTHANGUP_SHUTDOWN		(1 << 2)
-#define AST_SOFTHANGUP_TIMEOUT		(1 << 3)
-#define AST_SOFTHANGUP_APPUNLOAD	(1 << 4)
-#define AST_SOFTHANGUP_EXPLICIT		(1 << 5)
-#define AST_SOFTHANGUP_UNBRIDGE     (1 << 6)
-
-
-/*! \defgroup ChanState Channel states
-\brief Bits 0-15 of state are reserved for the state (up/down) of the line */
-/*! @{ */
-/*! Channel is down and available */
-#define AST_STATE_DOWN		0		
-/*! Channel is down, but reserved */
-#define AST_STATE_RESERVED	1		
-/*! Channel is off hook */
-#define AST_STATE_OFFHOOK	2		
-/*! Digits (or equivalent) have been dialed */
-#define AST_STATE_DIALING	3		
-/*! Line is ringing */
-#define AST_STATE_RING		4		
-/*! Remote end is ringing */
-#define AST_STATE_RINGING	5		
-/*! Line is up */
-#define AST_STATE_UP		6		
-/*! Line is busy */
-#define AST_STATE_BUSY  	7		
-/*! Digits (or equivalent) have been dialed while offhook */
-#define AST_STATE_DIALING_OFFHOOK	8
-/*! Channel has detected an incoming call and is waiting for ring */
-#define AST_STATE_PRERING       9
-
-/* Bits 16-32 of state are reserved for flags (See \ref ChanState ) */
-/*! Do not transmit voice data */
-#define AST_STATE_MUTE		(1 << 16)	
-/*! @} */
+enum {
+	AST_CDR_TRANSFER =   (1 << 0),
+	AST_CDR_FORWARD =    (1 << 1),
+	AST_CDR_CALLWAIT =   (1 << 2),
+	AST_CDR_CONFERENCE = (1 << 3),
+};
+
+enum {
+	/*! Soft hangup by device */
+	AST_SOFTHANGUP_DEV =       (1 << 0),
+	/*! Soft hangup for async goto */
+	AST_SOFTHANGUP_ASYNCGOTO = (1 << 1),
+	AST_SOFTHANGUP_SHUTDOWN =  (1 << 2),
+	AST_SOFTHANGUP_TIMEOUT =   (1 << 3),
+	AST_SOFTHANGUP_APPUNLOAD = (1 << 4),
+	AST_SOFTHANGUP_EXPLICIT =  (1 << 5),
+	AST_SOFTHANGUP_UNBRIDGE =  (1 << 6),
+};
+
 
 /*! \brief Channel reload reasons for manager events at load or reload of configuration */
 enum channelreloadreason {
@@ -536,7 +561,7 @@
 struct ast_datastore *ast_channel_datastore_find(struct ast_channel *chan, const struct ast_datastore_info *info, char *uid);
 
 /*! \brief Change the state of a channel */
-int ast_setstate(struct ast_channel *chan, int state);
+int ast_setstate(struct ast_channel *chan, enum ast_channel_state);
 
 /*! \brief Create a channel structure 
     \return Returns NULL on failure to allocate.
@@ -973,7 +998,7 @@
  * Give a name to a state 
  * Returns the text form of the binary state given
  */
-char *ast_state2str(int state);
+char *ast_state2str(enum ast_channel_state);
 
 /*! Gives the string form of a given transfer capability */
 /*!

Modified: team/markster/usersconf/res/res_features.c
URL: http://svn.digium.com/view/asterisk/team/markster/usersconf/res/res_features.c?rev=40655&r1=40654&r2=40655&view=diff
==============================================================================
--- team/markster/usersconf/res/res_features.c (original)
+++ team/markster/usersconf/res/res_features.c Sun Aug 20 11:16:43 2006
@@ -422,7 +422,7 @@
 			notify_metermaids(pu->parkingexten, parking_con);
 	}
 	/* Tell the peer channel the number of the parking space */
-	if (peer && !pu->parkingnum == -1) /* Only say number if it's a number */
+	if (peer && pu->parkingnum != -1) /* Only say number if it's a number */
 		ast_say_digits(peer, pu->parkingnum, "", peer->language);
 	if (pu->notquiteyet) {
 		/* Wake up parking thread if we're really done */

Modified: team/markster/usersconf/res/res_odbc.c
URL: http://svn.digium.com/view/asterisk/team/markster/usersconf/res/res_odbc.c?rev=40655&r1=40654&r2=40655&view=diff
==============================================================================
--- team/markster/usersconf/res/res_odbc.c (original)
+++ team/markster/usersconf/res/res_odbc.c Sun Aug 20 11:16:43 2006
@@ -120,6 +120,10 @@
 				continue;
 			}
 			break;
+		} else {
+			ast_log(LOG_WARNING, "SQL Prepare failed.  Attempting a reconnect...\n");
+			odbc_obj_disconnect(obj);
+			odbc_obj_connect(obj);
 		}
 	}
 



More information about the asterisk-commits mailing list