[asterisk-commits] kpfleming: branch qwell/cli-reverbification r43210 - in /team/qwell/cli-rever...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Mon Sep 18 12:47:34 MST 2006


Author: kpfleming
Date: Mon Sep 18 14:47:33 2006
New Revision: 43210

URL: http://svn.digium.com/view/asterisk?rev=43210&view=rev
Log:
update to trunk

Added:
    team/qwell/cli-reverbification/channels/chan_gtalk.c
      - copied unchanged from r43208, trunk/channels/chan_gtalk.c
    team/qwell/cli-reverbification/configs/gtalk.conf.sample
      - copied unchanged from r43208, trunk/configs/gtalk.conf.sample
    team/qwell/cli-reverbification/configs/users.conf.sample
      - copied unchanged from r43208, trunk/configs/users.conf.sample
Modified:
    team/qwell/cli-reverbification/   (props changed)
    team/qwell/cli-reverbification/Makefile.moddir_rules
    team/qwell/cli-reverbification/apps/app_directory.c
    team/qwell/cli-reverbification/apps/app_meetme.c
    team/qwell/cli-reverbification/apps/app_voicemail.c
    team/qwell/cli-reverbification/build_tools/prep_moduledeps
    team/qwell/cli-reverbification/channels/chan_agent.c
    team/qwell/cli-reverbification/channels/chan_iax2.c
    team/qwell/cli-reverbification/channels/chan_jingle.c
    team/qwell/cli-reverbification/channels/chan_sip.c
    team/qwell/cli-reverbification/channels/chan_skinny.c
    team/qwell/cli-reverbification/channels/chan_zap.c
    team/qwell/cli-reverbification/configs/extensions.conf.sample
    team/qwell/cli-reverbification/configs/func_odbc.conf.sample
    team/qwell/cli-reverbification/configs/indications.conf.sample
    team/qwell/cli-reverbification/configs/skinny.conf.sample
    team/qwell/cli-reverbification/configs/voicemail.conf.sample
    team/qwell/cli-reverbification/configs/zapata.conf.sample
    team/qwell/cli-reverbification/configure
    team/qwell/cli-reverbification/configure.ac
    team/qwell/cli-reverbification/doc/jingle.txt
    team/qwell/cli-reverbification/include/asterisk/config.h
    team/qwell/cli-reverbification/include/asterisk/pbx.h
    team/qwell/cli-reverbification/main/Makefile
    team/qwell/cli-reverbification/main/asterisk.c
    team/qwell/cli-reverbification/main/config.c
    team/qwell/cli-reverbification/main/manager.c
    team/qwell/cli-reverbification/main/pbx.c
    team/qwell/cli-reverbification/pbx/pbx_config.c
    team/qwell/cli-reverbification/res/res_config_pgsql.c

Propchange: team/qwell/cli-reverbification/
------------------------------------------------------------------------------
Binary property 'branch-1.2-blocked' - no diff available.

Propchange: team/qwell/cli-reverbification/
------------------------------------------------------------------------------
Binary property 'branch-1.2-merged' - no diff available.

Propchange: team/qwell/cli-reverbification/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Mon Sep 18 14:47:33 2006
@@ -1,1 +1,1 @@
-/trunk:1-42999
+/trunk:1-43209

Modified: team/qwell/cli-reverbification/Makefile.moddir_rules
URL: http://svn.digium.com/view/asterisk/team/qwell/cli-reverbification/Makefile.moddir_rules?rev=43210&r1=43209&r2=43210&view=diff
==============================================================================
--- team/qwell/cli-reverbification/Makefile.moddir_rules (original)
+++ team/qwell/cli-reverbification/Makefile.moddir_rules Mon Sep 18 14:47:33 2006
@@ -34,7 +34,7 @@
 
 define module_so_template
 $(1)=$(1).so
-$(1).so: CFLAGS+=-fPIC
+$(1).so: CFLAGS+=-fpic
 $(1).so: LIBS+=$(foreach dep,$(MENUSELECT_DEPENDS_$(1)),$$(value $(dep)_LIB))
 $(1).so: LDFLAGS+=$(foreach dep,$(MENUSELECT_DEPENDS_$(1)),$$(value $(dep)_LDFLAGS))
 $(1).so: $(2)

Modified: team/qwell/cli-reverbification/apps/app_directory.c
URL: http://svn.digium.com/view/asterisk/team/qwell/cli-reverbification/apps/app_directory.c?rev=43210&r1=43209&r2=43210&view=diff
==============================================================================
--- team/qwell/cli-reverbification/apps/app_directory.c (original)
+++ team/qwell/cli-reverbification/apps/app_directory.c Mon Sep 18 14:47:33 2006
@@ -393,10 +393,10 @@
 	return cfg;
 }
 
-static int do_directory(struct ast_channel *chan, struct ast_config *cfg, char *context, char *dialcontext, char digit, int last, int readext, int fromappvm)
+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];
+	char ext[NUMDIGITS + 1], *cat;
 	char name[80] = "";
 	struct ast_variable *v;
 	int res;
@@ -411,7 +411,7 @@
 		return -1;
 	}
 	if (digit == '0') {
-		if (!ast_goto_if_exists(chan, chan->context, "o", 1) ||
+		if (!ast_goto_if_exists(chan, dialcontext, "o", 1) ||
 		    (!ast_strlen_zero(chan->macrocontext) &&
 		     !ast_goto_if_exists(chan, chan->macrocontext, "o", 1))) {
 			return 0;
@@ -422,7 +422,7 @@
 		}
 	}	
 	if (digit == '*') {
-		if (!ast_goto_if_exists(chan, chan->context, "a", 1) ||
+		if (!ast_goto_if_exists(chan, dialcontext, "a", 1) ||
 		    (!ast_strlen_zero(chan->macrocontext) &&
 		     !ast_goto_if_exists(chan, chan->macrocontext, "a", 1))) {
 			return 0;
@@ -499,6 +499,58 @@
 			}
 		}
 
+		if (!res && ucfg) {
+			/* Search users.conf for all names which start with those digits */
+			for (cat = ast_category_browse(ucfg, NULL); cat && !res ; cat = ast_category_browse(ucfg, cat)) {
+				if (!strcasecmp(cat, "general"))
+					continue;
+				if (!ast_true(ast_config_option(ucfg, cat, "hasdirectory")))
+					continue;
+				
+				/* Find all candidate extensions */
+				if ((pos = ast_variable_retrieve(ucfg, cat, "fullname"))) {
+					ast_copy_string(name, pos, sizeof(name));
+					/* Grab the last name */
+					if (last && strrchr(pos,' '))
+						pos = strrchr(pos, ' ') + 1;
+					conv = convert(pos);
+					if (conv) {
+						if (!strcmp(conv, ext)) {
+							/* Match! */
+							found++;
+							/* We have a match -- play a greeting if they have it */
+							res = play_mailbox_owner(chan, context, dialcontext, cat, name, readext, fromappvm);
+							switch (res) {
+							case -1:
+								/* user pressed '1' but extension does not exist, or
+								 * user hungup
+								 */
+								lastuserchoice = 0;
+								break;
+							case '1':
+								/* user pressed '1' and extensions exists;
+								   play_mailbox_owner will already have done
+								   a goto() on the channel
+								 */
+								lastuserchoice = res;
+								break;
+							case '*':
+								/* user pressed '*' to skip something found */
+								lastuserchoice = res;
+								res = 0;
+								break;
+							default:
+								break;
+							}
+							free(conv);
+							break;
+						}
+						free(conv);
+					}
+				}
+			}
+		}
+			
 		if (lastuserchoice != '1') {
 			res = ast_streamfile(chan, found ? "dir-nomore" : "dir-nomatch", chan->language);
 			if (!res)
@@ -514,7 +566,7 @@
 {
 	int res = 0;
 	struct ast_module_user *u;
-	struct ast_config *cfg;
+	struct ast_config *cfg, *ucfg;
 	int last = 1;
 	int readext = 0;
 	int fromappvm = 0;
@@ -554,6 +606,8 @@
 		ast_module_user_remove(u);
 		return -1;
 	}
+	
+	ucfg = ast_config_load("users.conf");
 
 	dirintro = ast_variable_retrieve(cfg, args.vmcontext, "directoryintro");
 	if (ast_strlen_zero(dirintro))
@@ -571,7 +625,7 @@
 		if (!res)
 			res = ast_waitfordigit(chan, 5000);
 		if (res > 0) {
-			res = do_directory(chan, cfg, args.vmcontext, args.dialcontext, res, last, readext, fromappvm);
+			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);
@@ -581,6 +635,8 @@
 		}
 		break;
 	}
+	if (ucfg)
+		ast_config_destroy(ucfg);
 	ast_config_destroy(cfg);
 	ast_module_user_remove(u);
 	return res;

Modified: team/qwell/cli-reverbification/apps/app_meetme.c
URL: http://svn.digium.com/view/asterisk/team/qwell/cli-reverbification/apps/app_meetme.c?rev=43210&r1=43209&r2=43210&view=diff
==============================================================================
--- team/qwell/cli-reverbification/apps/app_meetme.c (original)
+++ team/qwell/cli-reverbification/apps/app_meetme.c Mon Sep 18 14:47:33 2006
@@ -1419,6 +1419,8 @@
 						}
 					}
 				} else if(currentmarked >= 1 && lastmarked == 0) {
+					/* Marked user entered, so cancel timeout */
+					timeout = 0;
 					if (confflags & CONFFLAG_MONITOR)
 						ztc.confmode = ZT_CONF_CONFMON | ZT_CONF_LISTENER;
 					else if (confflags & CONFFLAG_TALKER)

Modified: team/qwell/cli-reverbification/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/qwell/cli-reverbification/apps/app_voicemail.c?rev=43210&r1=43209&r2=43210&view=diff
==============================================================================
--- team/qwell/cli-reverbification/apps/app_voicemail.c (original)
+++ team/qwell/cli-reverbification/apps/app_voicemail.c Mon Sep 18 14:47:33 2006
@@ -404,6 +404,8 @@
 #define tdesc "Comedian Mail (Voicemail System)"
 #endif
 
+static char userscontext[AST_MAX_EXTENSION] = "default";
+
 static char *addesc = "Comedian Mail";
 
 static char *synopsis_vm =
@@ -641,9 +643,32 @@
 	}	
 }
 
+static void apply_options_full(struct ast_vm_user *retval, struct ast_variable *var)
+{
+	struct ast_variable *tmp;
+	tmp = var;
+	while (tmp) {
+		if (!strcasecmp(tmp->name, "password")) {
+			ast_copy_string(retval->password, tmp->value, sizeof(retval->password));
+		} else if (!strcasecmp(tmp->name, "uniqueid")) {
+			ast_copy_string(retval->uniqueid, tmp->value, sizeof(retval->uniqueid));
+		} else if (!strcasecmp(tmp->name, "pager")) {
+			ast_copy_string(retval->pager, tmp->value, sizeof(retval->pager));
+		} else if (!strcasecmp(tmp->name, "email")) {
+			ast_copy_string(retval->email, tmp->value, sizeof(retval->email));
+		} else if (!strcasecmp(tmp->name, "fullname")) {
+			ast_copy_string(retval->fullname, tmp->value, sizeof(retval->fullname));
+		} else if (!strcasecmp(tmp->name, "context")) {
+			ast_copy_string(retval->context, tmp->value, sizeof(retval->context));
+		} else
+			apply_option(retval, tmp->name, tmp->value);
+		tmp = tmp->next;
+	} 
+}
+
 static struct ast_vm_user *find_user_realtime(struct ast_vm_user *ivm, const char *context, const char *mailbox)
 {
-	struct ast_variable *var, *tmp;
+	struct ast_variable *var;
 	struct ast_vm_user *retval;
 
 	if ((retval = (ivm ? ivm : ast_calloc(1, sizeof(*retval))))) {
@@ -659,25 +684,7 @@
 		else
 			var = ast_load_realtime("voicemail", "mailbox", mailbox, "context", context, NULL);
 		if (var) {
-			tmp = var;
-			while (tmp) {
-				printf("%s => %s\n", tmp->name, tmp->value);
-				if (!strcasecmp(tmp->name, "password")) {
-					ast_copy_string(retval->password, tmp->value, sizeof(retval->password));
-				} else if (!strcasecmp(tmp->name, "uniqueid")) {
-					ast_copy_string(retval->uniqueid, tmp->value, sizeof(retval->uniqueid));
-				} else if (!strcasecmp(tmp->name, "pager")) {
-					ast_copy_string(retval->pager, tmp->value, sizeof(retval->pager));
-				} else if (!strcasecmp(tmp->name, "email")) {
-					ast_copy_string(retval->email, tmp->value, sizeof(retval->email));
-				} else if (!strcasecmp(tmp->name, "fullname")) {
-					ast_copy_string(retval->fullname, tmp->value, sizeof(retval->fullname));
-				} else if (!strcasecmp(tmp->name, "context")) {
-					ast_copy_string(retval->context, tmp->value, sizeof(retval->context));
-				} else
-					apply_option(retval, tmp->name, tmp->value);
-				tmp = tmp->next;
-			} 
+			apply_options_full(retval, var);
 			ast_variables_destroy(var);
 		} else { 
 			if (!ivm) 
@@ -6573,6 +6580,26 @@
 	return res;
 }
 
+static struct ast_vm_user *find_or_create(char *context, char *mbox)
+{
+	struct ast_vm_user *vmu;
+	AST_LIST_TRAVERSE(&users, vmu, list) {
+		if (ast_test_flag((&globalflags), VM_SEARCH) && !strcasecmp(mbox, vmu->mailbox))
+			break;
+		if (context && (!strcasecmp(context, vmu->context)) && (!strcasecmp(mbox, vmu->mailbox)))
+			break;
+	}
+	
+	if (!vmu) {
+		if ((vmu = ast_calloc(1, sizeof(*vmu)))) {
+			ast_copy_string(vmu->context, context, sizeof(vmu->context));
+			ast_copy_string(vmu->mailbox, mbox, sizeof(vmu->mailbox));
+			AST_LIST_INSERT_TAIL(&users, vmu, list);
+		}
+	}
+	return vmu;
+}
+
 static int append_mailbox(char *context, char *mbox, char *data)
 {
 	/* Assumes lock is already held */
@@ -6582,10 +6609,7 @@
 	struct ast_vm_user *vmu;
 
 	ast_copy_string(tmp, data, sizeof(tmp));
-	if ((vmu = ast_calloc(1, sizeof(*vmu)))) {
-		ast_copy_string(vmu->context, context, sizeof(vmu->context));
-		ast_copy_string(vmu->mailbox, mbox, sizeof(vmu->mailbox));
-
+	if ((vmu = find_or_create(context, mbox))) {
 		populate_defaults(vmu);
 
 		stringp = tmp;
@@ -6599,8 +6623,6 @@
 			ast_copy_string(vmu->pager, s, sizeof(vmu->pager));
 		if (stringp && (s = strsep(&stringp, ","))) 
 			apply_options(vmu, s);
-		
-		AST_LIST_INSERT_TAIL(&users, vmu, list);
 	}
 	return 0;
 }
@@ -6823,7 +6845,7 @@
 {
 	struct ast_vm_user *cur;
 	struct vm_zone *zcur;
-	struct ast_config *cfg;
+	struct ast_config *cfg, *ucfg;
 	char *cat;
 	struct ast_variable *var;
 	char *notifystr = NULL;
@@ -6853,6 +6875,7 @@
 	char *thresholdstr;
 	char *fmt;
 	char *astemail;
+	char *ucontext;
 	char *astmailcmd = SENDMAIL;
 	char *astforcename;
 	char *astforcegreet;
@@ -6884,6 +6907,9 @@
 	if (cfg) {
 		/* General settings */
 
+		if (!(ucontext = ast_variable_retrieve(cfg, "general", "userscontext")))
+			ucontext = "default";
+		ast_copy_string(userscontext, ucontext, sizeof(userscontext));
 		/* Attach voice message to mail message ? */
 		if (!(astattach = ast_variable_retrieve(cfg, "general", "attach"))) 
 			astattach = "yes";
@@ -7169,6 +7195,18 @@
 		if (!(astdirfwd = ast_variable_retrieve(cfg, "general", "usedirectory"))) 
 			astdirfwd = "no";
 		ast_set2_flag((&globalflags), ast_true(astdirfwd), VM_DIRECFORWARD);	
+		if ((ucfg = ast_config_load("users.conf"))) {	
+			for (cat = ast_category_browse(ucfg, NULL); cat ; cat = ast_category_browse(ucfg, cat)) {
+				if (!ast_true(ast_config_option(ucfg, cat, "hasvoicemail")))
+					continue;
+				if ((cur = find_or_create(userscontext, cat))) {
+					populate_defaults(cur);
+					apply_options_full(cur, ast_variable_browse(ucfg, cat));
+					ast_copy_string(cur->context, userscontext, sizeof(cur->context));
+				}
+			}
+			ast_config_destroy(ucfg);
+		}
 		cat = ast_category_browse(cfg, NULL);
 		while (cat) {
 			if (strcasecmp(cat, "general")) {

Modified: team/qwell/cli-reverbification/build_tools/prep_moduledeps
URL: http://svn.digium.com/view/asterisk/team/qwell/cli-reverbification/build_tools/prep_moduledeps?rev=43210&r1=43209&r2=43210&view=diff
==============================================================================
--- team/qwell/cli-reverbification/build_tools/prep_moduledeps (original)
+++ team/qwell/cli-reverbification/build_tools/prep_moduledeps Mon Sep 18 14:47:33 2006
@@ -28,7 +28,7 @@
 	echo -e "\t</category>"
 }
 
-echo "<?xml version="1.0"?>"
+echo "<?xml version=\"1.0\"?>"
 echo
 echo "<menu name=\"Asterisk Module Selection\">"
 rm -f .makeoptstmp

Modified: team/qwell/cli-reverbification/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/team/qwell/cli-reverbification/channels/chan_agent.c?rev=43210&r1=43209&r2=43210&view=diff
==============================================================================
--- team/qwell/cli-reverbification/channels/chan_agent.c (original)
+++ team/qwell/cli-reverbification/channels/chan_agent.c Mon Sep 18 14:47:33 2006
@@ -196,7 +196,6 @@
 	char loginchan[80];            /**< channel they logged in from */
 	char logincallerid[80];        /**< Caller ID they had when they logged in */
 	struct ast_channel *chan;      /**< Channel we use */
-	struct ast_module_user *u;	/*! reference to keep our module in memory while in use */
 	AST_LIST_ENTRY(agent_pvt) list;	/**< Next Agent in the linked list. */
 };
 
@@ -739,8 +738,6 @@
 	 * agent_request() is followed immediately by agent_hangup()
 	 * as in apps/app_chanisavail.c:chanavail_exec()
 	 */
-
-	ast_module_user_remove(p->u);
 
 	if (option_debug)
 		ast_log(LOG_DEBUG, "Hangup called for state %s\n", ast_state2str(ast->_state));

Modified: team/qwell/cli-reverbification/channels/chan_iax2.c
URL: http://svn.digium.com/view/asterisk/team/qwell/cli-reverbification/channels/chan_iax2.c?rev=43210&r1=43209&r2=43210&view=diff
==============================================================================
--- team/qwell/cli-reverbification/channels/chan_iax2.c (original)
+++ team/qwell/cli-reverbification/channels/chan_iax2.c Mon Sep 18 14:47:33 2006
@@ -798,8 +798,9 @@
 static int send_command_transfer(struct chan_iax2_pvt *, char, int, unsigned int, const unsigned char *, int);
 static struct ast_channel *iax2_request(const char *type, int format, void *data, int *cause);
 static struct ast_frame *iax2_read(struct ast_channel *c);
-static struct iax2_peer *build_peer(const char *name, struct ast_variable *v, int temponly);
-static struct iax2_user *build_user(const char *name, struct ast_variable *v, int temponly);
+static struct iax2_peer *build_peer(const char *name, struct ast_variable *v, struct ast_variable *alt, int temponly);
+static struct iax2_user *build_user(const char *name, struct ast_variable *v, struct ast_variable *alt, int temponly);
+static void realtime_update_peer(const char *peername, struct sockaddr_in *sin, time_t regtime);
 static void destroy_user(struct iax2_user *user);
 static void prune_peers(void);
 
@@ -2445,7 +2446,7 @@
 	if (!var)
 		return NULL;
 
-	peer = build_peer(peername, var, ast_test_flag((&globalflags), IAX_RTCACHEFRIENDS) ? 0 : 1);
+	peer = build_peer(peername, var, NULL, ast_test_flag((&globalflags), IAX_RTCACHEFRIENDS) ? 0 : 1);
 	
 	if (!peer)
 		return NULL;
@@ -2496,6 +2497,7 @@
 		time(&nowtime);
 		if ((nowtime - regseconds) > IAX_DEFAULT_REG_EXPIRE) {
 			memset(&peer->addr, 0, sizeof(peer->addr));
+			realtime_update_peer(peer->name, &peer->addr, 0);
 			if (option_debug)
 				ast_log(LOG_DEBUG, "realtime_peer: Bah, '%s' is expired (%d/%d/%d)!\n",
 						peername, (int)(nowtime - regseconds), (int)regseconds, (int)nowtime);
@@ -2532,7 +2534,7 @@
 		tmp = tmp->next;
 	}
 
-	user = build_user(username, var, !ast_test_flag((&globalflags), IAX_RTCACHEFRIENDS));
+	user = build_user(username, var, NULL, !ast_test_flag((&globalflags), IAX_RTCACHEFRIENDS));
 	if (!user)
 		return NULL;
 
@@ -8242,17 +8244,20 @@
 
 		
 /*! \brief Create peer structure based on configuration */
-static struct iax2_peer *build_peer(const char *name, struct ast_variable *v, int temponly)
+static struct iax2_peer *build_peer(const char *name, struct ast_variable *v, struct ast_variable *alt, int temponly)
 {
 	struct iax2_peer *peer = NULL;
 	struct ast_ha *oldha = NULL;
 	int maskfound=0;
 	int found=0;
+	int firstpass=1;
 
 	AST_LIST_LOCK(&peers);
 	if (!temponly) {
 		AST_LIST_TRAVERSE(&peers, peer, entry) {
 			if (!strcmp(peer->name, name)) {	
+				if (!ast_test_flag(peer, IAX_DELME))
+					firstpass = 0;
 				break;
 			}
 		}
@@ -8260,8 +8265,10 @@
 		peer = NULL;	
 	if (peer) {
 		found++;
-		oldha = peer->ha;
-		peer->ha = NULL;
+		if (firstpass) {
+			oldha = peer->ha;
+			peer->ha = NULL;
+		}
 		AST_LIST_REMOVE(&peers, peer, entry);
 		AST_LIST_UNLOCK(&peers);
  	} else {
@@ -8277,25 +8284,29 @@
 		}
 	}
 	if (peer) {
-		ast_copy_flags(peer, &globalflags, IAX_USEJITTERBUF | IAX_FORCEJITTERBUF);
-		peer->encmethods = iax2_encryption;
-		peer->adsi = adsi;
-		/* NOT ANY MORE: peer->secret[0] = '\0'; */
-		ast_string_field_set(peer,secret,"");
-		if (!found) {
-			ast_string_field_set(peer, name, name);
-			peer->addr.sin_port = htons(IAX_DEFAULT_PORTNO);
-			peer->expiry = min_reg_expire;
-		}
-		peer->prefs = prefs;
-		peer->capability = iax2_capability;
-		peer->smoothing = 0;
-		peer->pokefreqok = DEFAULT_FREQ_OK;
-		peer->pokefreqnotok = DEFAULT_FREQ_NOTOK;
-		/* NO MORE: peer->context[0] = '\0';
-		   peer->peercontext[0] = '\0'; */
-		ast_string_field_set(peer,context,"");
-		ast_string_field_set(peer,peercontext,"");
+		if (firstpass) {
+			ast_copy_flags(peer, &globalflags, IAX_USEJITTERBUF | IAX_FORCEJITTERBUF);
+			peer->encmethods = iax2_encryption;
+			peer->adsi = adsi;
+			ast_string_field_set(peer,secret,"");
+			if (!found) {
+				ast_string_field_set(peer, name, name);
+				peer->addr.sin_port = htons(IAX_DEFAULT_PORTNO);
+				peer->expiry = min_reg_expire;
+			}
+			peer->prefs = prefs;
+			peer->capability = iax2_capability;
+			peer->smoothing = 0;
+			peer->pokefreqok = DEFAULT_FREQ_OK;
+			peer->pokefreqnotok = DEFAULT_FREQ_NOTOK;
+			ast_string_field_set(peer,context,"");
+			ast_string_field_set(peer,peercontext,"");
+		}
+
+		if (!v) {
+			v = alt;
+			alt = NULL;
+		}
 		while(v) {
 			if (!strcasecmp(v->name, "secret")) {
 				ast_string_field_set(peer, secret, v->value);
@@ -8402,6 +8413,12 @@
 				ast_string_field_set(peer, cid_name, name2);
 				ast_string_field_set(peer, cid_num, num2);
 				ast_set_flag(peer, IAX_HASCALLERID);	
+			} else if (!strcasecmp(v->name, "fullname")) {
+				ast_string_field_set(peer, cid_name, v->value);
+				ast_set_flag(peer, IAX_HASCALLERID);	
+			} else if (!strcasecmp(v->name, "cid_number")) {
+				ast_string_field_set(peer, cid_num, v->value);
+				ast_set_flag(peer, IAX_HASCALLERID);	
 			} else if (!strcasecmp(v->name, "sendani")) {
 				ast_set2_flag(peer, ast_true(v->value), IAX_SENDANI);	
 			} else if (!strcasecmp(v->name, "inkeys")) {
@@ -8433,7 +8450,11 @@
 				peer->adsi = ast_true(v->value);
 			}/* else if (strcasecmp(v->name,"type")) */
 			/*	ast_log(LOG_WARNING, "Ignoring %s\n", v->name); */
-			v=v->next;
+			v = v->next;
+			if (!v) {
+				v = alt;
+				alt = NULL;
+			}
 		}
 		if (!peer->authmethods)
 			peer->authmethods = IAX_AUTH_MD5 | IAX_AUTH_PLAINTEXT;
@@ -8447,13 +8468,14 @@
 }
 
 /*! \brief Create in-memory user structure from configuration */
-static struct iax2_user *build_user(const char *name, struct ast_variable *v, int temponly)
+static struct iax2_user *build_user(const char *name, struct ast_variable *v, struct ast_variable *alt, int temponly)
 {
 	struct iax2_user *user = NULL;
 	struct iax2_context *con, *conl = NULL;
 	struct ast_ha *oldha = NULL;
 	struct iax2_context *oldcon = NULL;
 	int format;
+	int firstpass=1;
 	int oldcurauthreq = 0;
 	char *varname = NULL, *varval = NULL;
 	struct ast_variable *tmpvar = NULL;
@@ -8462,18 +8484,22 @@
 	if (!temponly) {
 		AST_LIST_TRAVERSE(&users, user, entry) {
 			if (!strcmp(user->name, name)) {	
+				if (!ast_test_flag(user, IAX_DELME))
+					firstpass = 0;
 				break;
 			}
 		}
 	} else
 		user = NULL;
-	
+
 	if (user) {
-		oldcurauthreq = user->curauthreq;
-		oldha = user->ha;
-		oldcon = user->contexts;
-		user->ha = NULL;
-		user->contexts = NULL;
+		if (firstpass) {
+			oldcurauthreq = user->curauthreq;
+			oldha = user->ha;
+			oldcon = user->contexts;
+			user->ha = NULL;
+			user->contexts = NULL;
+		}
 		/* Already in the list, remove it and it will be added back (or FREE'd) */
 		AST_LIST_REMOVE(&users, user, entry);
 		AST_LIST_UNLOCK(&users);
@@ -8481,22 +8507,30 @@
 		AST_LIST_UNLOCK(&users);
 		/* This is going to memset'd to 0 in the next block */
 		user = ast_calloc(sizeof(*user),1);
-		if (ast_string_field_init(user, 32)) {
-			free(user);
-			user = NULL;
-		}
 	}
 	
 	if (user) {
-		user->maxauthreq = maxauthreq;
-		user->curauthreq = oldcurauthreq;
-		user->prefs = prefs;
-		user->capability = iax2_capability;
-		user->encmethods = iax2_encryption;
-		user->adsi = adsi;
-		ast_string_field_set(user, name, name);
-		ast_string_field_set(user, language, language);
-		ast_copy_flags(user, &globalflags, IAX_USEJITTERBUF | IAX_FORCEJITTERBUF | IAX_CODEC_USER_FIRST | IAX_CODEC_NOPREFS | IAX_CODEC_NOCAP);	
+		if (firstpass) {
+			ast_string_field_free_all(user);
+			memset(user, 0, sizeof(struct iax2_user));
+			if (ast_string_field_init(user, 32)) {
+				free(user);
+				user = NULL;
+			}
+			user->maxauthreq = maxauthreq;
+			user->curauthreq = oldcurauthreq;
+			user->prefs = prefs;
+			user->capability = iax2_capability;
+			user->encmethods = iax2_encryption;
+			user->adsi = adsi;
+			ast_string_field_set(user, name, name);
+			ast_string_field_set(user, language, language);
+			ast_copy_flags(user, &globalflags, IAX_USEJITTERBUF | IAX_FORCEJITTERBUF | IAX_CODEC_USER_FIRST | IAX_CODEC_NOPREFS | IAX_CODEC_NOCAP);	
+		}
+		if (!v) {
+			v = alt;
+			alt = NULL;
+		}
 		while(v) {
 			if (!strcasecmp(v->name, "context")) {
 				con = build_context(v->value);
@@ -8576,6 +8610,12 @@
 				ast_string_field_set(user, cid_name, name2);
 				ast_string_field_set(user, cid_num, num2);
 				ast_set_flag(user, IAX_HASCALLERID);	
+			} else if (!strcasecmp(v->name, "fullname")) {
+				ast_string_field_set(user, cid_name, v->value);
+				ast_set_flag(user, IAX_HASCALLERID);	
+			} else if (!strcasecmp(v->name, "cid_number")) {
+				ast_string_field_set(user, cid_num, v->value);
+				ast_set_flag(user, IAX_HASCALLERID);	
 			} else if (!strcasecmp(v->name, "accountcode")) {
 				ast_string_field_set(user, accountcode, v->value);
 			} else if (!strcasecmp(v->name, "mohinterpret")) {
@@ -8602,6 +8642,10 @@
 			}/* else if (strcasecmp(v->name,"type")) */
 			/*	ast_log(LOG_WARNING, "Ignoring %s\n", v->name); */
 			v = v->next;
+			if (!v) {
+				v = alt;
+				alt = NULL;
+			}
 		}
 		if (!user->authmethods) {
 			if (!ast_strlen_zero(user->secret)) {
@@ -8748,7 +8792,7 @@
 /*! \brief Load configuration */
 static int set_config(char *config_file, int reload)
 {
-	struct ast_config *cfg;
+	struct ast_config *cfg, *ucfg;
 	int capability=iax2_capability;
 	struct ast_variable *v;
 	char *cat;
@@ -9001,13 +9045,71 @@
 		min_reg_expire = max_reg_expire;
 	}
 	iax2_capability = capability;
+	
+	ucfg = ast_config_load("users.conf");
+	if (ucfg) {
+		struct ast_variable *gen;
+		int genhasiax;
+		int genregisteriax;
+		char *hasiax, *registeriax;
+		
+		genhasiax = ast_true(ast_variable_retrieve(ucfg, "general", "hasiax"));
+		genregisteriax = ast_true(ast_variable_retrieve(ucfg, "general", "registeriax"));
+		gen = ast_variable_browse(ucfg, "general");
+		cat = ast_category_browse(ucfg, NULL);
+		while (cat) {
+			if (strcasecmp(cat, "general")) {
+				hasiax = ast_variable_retrieve(ucfg, cat, "hasiax");
+				registeriax = ast_variable_retrieve(ucfg, cat, "registeriax");
+				if (ast_true(hasiax) || (!hasiax && genhasiax)) {
+					/* Start with general parameters, then specific parameters, user and peer */
+					user = build_user(cat, gen, ast_variable_browse(ucfg, cat), 0);
+					if (user) {
+						AST_LIST_LOCK(&users);
+						AST_LIST_INSERT_HEAD(&users, user, entry);
+						AST_LIST_UNLOCK(&users);
+					}
+					peer = build_peer(cat, gen, ast_variable_browse(ucfg, cat), 0);
+					if (peer) {
+						AST_LIST_LOCK(&peers);
+						AST_LIST_INSERT_HEAD(&peers, peer, entry);
+						AST_LIST_UNLOCK(&peers);
+						if (ast_test_flag(peer, IAX_DYNAMIC))
+							reg_source_db(peer);
+					}
+				}
+				if (ast_true(registeriax) || (!registeriax && genregisteriax)) {
+					char tmp[256];
+					char *host = ast_variable_retrieve(ucfg, cat, "host");
+					char *username = ast_variable_retrieve(ucfg, cat, "username");
+					char *secret = ast_variable_retrieve(ucfg, cat, "secret");
+					if (!host)
+						host = ast_variable_retrieve(ucfg, "general", "host");
+					if (!username)
+						username = ast_variable_retrieve(ucfg, "general", "username");
+					if (!secret)
+						secret = ast_variable_retrieve(ucfg, "general", "secret");
+					if (!ast_strlen_zero(username) && !ast_strlen_zero(host)) {
+						if (!ast_strlen_zero(secret))
+							snprintf(tmp, sizeof(tmp), "%s:%s@%s", username, secret, host);
+						else
+							snprintf(tmp, sizeof(tmp), "%s@%s", username, host);
+						iax2_register(tmp, 0);
+					}
+				}
+			}
+			cat = ast_category_browse(ucfg, cat);
+		}
+		ast_config_destroy(ucfg);
+	}
+	
 	cat = ast_category_browse(cfg, NULL);
 	while(cat) {
 		if (strcasecmp(cat, "general")) {
 			utype = ast_variable_retrieve(cfg, cat, "type");
 			if (utype) {
 				if (!strcasecmp(utype, "user") || !strcasecmp(utype, "friend")) {
-					user = build_user(cat, ast_variable_browse(cfg, cat), 0);
+					user = build_user(cat, ast_variable_browse(cfg, cat), NULL, 0);
 					if (user) {
 						AST_LIST_LOCK(&users);
 						AST_LIST_INSERT_HEAD(&users, user, entry);
@@ -9015,7 +9117,7 @@
 					}
 				}
 				if (!strcasecmp(utype, "peer") || !strcasecmp(utype, "friend")) {
-					peer = build_peer(cat, ast_variable_browse(cfg, cat), 0);
+					peer = build_peer(cat, ast_variable_browse(cfg, cat), NULL, 0);
 					if (peer) {
 						AST_LIST_LOCK(&peers);
 						AST_LIST_INSERT_HEAD(&peers, peer, entry);

Modified: team/qwell/cli-reverbification/channels/chan_jingle.c
URL: http://svn.digium.com/view/asterisk/team/qwell/cli-reverbification/channels/chan_jingle.c?rev=43210&r1=43209&r2=43210&view=diff
==============================================================================
--- team/qwell/cli-reverbification/channels/chan_jingle.c (original)
+++ team/qwell/cli-reverbification/channels/chan_jingle.c Mon Sep 18 14:47:33 2006
@@ -156,7 +156,7 @@
 };
 
 struct jingle_container {
-        ASTOBJ_CONTAINER_COMPONENTS(struct jingle);
+	ASTOBJ_CONTAINER_COMPONENTS(struct jingle);
 };
 
 static const char desc[] = "Jingle Channel";
@@ -521,7 +521,7 @@
 					"unsupported-dtmf-method xmlns='http://jabber.org/protocol/jingle/info/dtmf#errors'");
 			return -1;
 		}
-		if ((dtmfnode  = iks_find(pak->x, "dtmf"))) {
+		if ((dtmfnode = iks_find(pak->x, "dtmf"))) {
 			if((dtmf = iks_find_attrib(dtmfnode, "code"))) {
 				if(iks_find_with_attrib(pak->x, "dtmf", "action", "button-up")) {
 					struct ast_frame f = {AST_FRAME_DTMF_BEGIN, };
@@ -995,7 +995,7 @@
 	struct jingle_pvt *p = NULL, *tmp = NULL;
 	struct aji_client *c = client->connection;
 	struct jingle_candidate *newcandidate = NULL;
-	iks  *traversenodes = NULL, *receipt = NULL;
+	iks *traversenodes = NULL, *receipt = NULL;
 	newcandidate = ast_calloc(1, sizeof(*newcandidate));
 	if (!newcandidate)
 		return 0;
@@ -1533,7 +1533,7 @@
 				member->connection = client;
 				iks_filter_add_rule(client->f, jingle_parser, member, IKS_RULE_TYPE,
 									IKS_PAK_IQ, IKS_RULE_FROM_PARTIAL, member->user,
-									IKS_RULE_NS, "http://www.google.com/session",
+									IKS_RULE_NS, "http://jabber.org/protocol/jingle",
 									IKS_RULE_DONE);
 			} else {
 				ast_log(LOG_ERROR, "connection referenced not found!\n");
@@ -1640,7 +1640,7 @@
 						ASTOBJ_WRLOCK(member);
 						member->connection = iterator;
 						iks_filter_add_rule(iterator->f, jingle_parser, member, IKS_RULE_TYPE, IKS_PAK_IQ, IKS_RULE_NS,
-										"http://www.google.com/session", IKS_RULE_DONE);
+										"http://jabber.org/protocol/jingle", IKS_RULE_DONE);
 						ASTOBJ_UNLOCK(member);
 						ASTOBJ_CONTAINER_LINK(&jingles, member);
 						ASTOBJ_UNLOCK(iterator);
@@ -1715,9 +1715,9 @@
 			ASTOBJ_WRLOCK(iterator);
 			privates = iterator->p;
 			while(privates) {
-			    if (privates->owner)
-			        ast_softhangup(privates->owner, AST_SOFTHANGUP_APPUNLOAD);
-			    privates = privates->next;
+				if (privates->owner)
+					ast_softhangup(privates->owner, AST_SOFTHANGUP_APPUNLOAD);
+				privates = privates->next;
 			}
 			iterator->p = NULL;
 			ASTOBJ_UNLOCK(iterator);

Modified: team/qwell/cli-reverbification/channels/chan_sip.c
URL: http://svn.digium.com/view/asterisk/team/qwell/cli-reverbification/channels/chan_sip.c?rev=43210&r1=43209&r2=43210&view=diff
==============================================================================
--- team/qwell/cli-reverbification/channels/chan_sip.c (original)
+++ team/qwell/cli-reverbification/channels/chan_sip.c Mon Sep 18 14:47:33 2006
@@ -1365,7 +1365,7 @@
 
 /*--- Device object handling */
 static struct sip_peer *temp_peer(const char *name);
-static struct sip_peer *build_peer(const char *name, struct ast_variable *v, int realtime);
+static struct sip_peer *build_peer(const char *name, struct ast_variable *v, struct ast_variable *alt, int realtime);
 static struct sip_user *build_user(const char *name, struct ast_variable *v, int realtime);
 static int update_call_counter(struct sip_pvt *fup, int event);
 static void sip_destroy_peer(struct sip_peer *peer);
@@ -2357,7 +2357,7 @@
 	}
 
 	/* Peer found in realtime, now build it in memory */
-	peer = build_peer(newpeername, var, !ast_test_flag(&global_flags[1], SIP_PAGE2_RTCACHEFRIENDS));
+	peer = build_peer(newpeername, var, NULL, !ast_test_flag(&global_flags[1], SIP_PAGE2_RTCACHEFRIENDS));
 	if (!peer) {
 		ast_variables_destroy(var);
 		return NULL;
@@ -15134,6 +15134,10 @@
 			ast_copy_string(user->md5secret, v->value, sizeof(user->md5secret));
 		} else if (!strcasecmp(v->name, "callerid")) {
 			ast_callerid_split(v->value, user->cid_name, sizeof(user->cid_name), user->cid_num, sizeof(user->cid_num));
+		} else if (!strcasecmp(v->name, "fullname")) {
+			ast_copy_string(user->cid_name, v->value, sizeof(user->cid_name));
+		} else if (!strcasecmp(v->name, "cid_number")) {
+			ast_copy_string(user->cid_num, v->value, sizeof(user->cid_num));
 		} else if (!strcasecmp(v->name, "callgroup")) {
 			user->callgroup = ast_get_group(v->value);
 		} else if (!strcasecmp(v->name, "pickupgroup")) {
@@ -15259,12 +15263,13 @@
 }
 
 /*! \brief Build peer from configuration (file or realtime static/dynamic) */
-static struct sip_peer *build_peer(const char *name, struct ast_variable *v, int realtime)
+static struct sip_peer *build_peer(const char *name, struct ast_variable *v, struct ast_variable *alt, int realtime)
 {
 	struct sip_peer *peer = NULL;
 	struct ast_ha *oldha = NULL;
 	int obproxyfound=0;
 	int found=0;
+	int firstpass=1;
 	int format=0;		/* Ama flags */
 	time_t regseconds = 0;
 	char *varname = NULL, *varval = NULL;
@@ -15284,6 +15289,8 @@
 	if (peer) {
 		/* Already in the list, remove it and it will be added back (or FREE'd)  */
 		found++;
+		if (!(peer->objflags & ASTOBJ_FLAG_MARKED))
+			firstpass = 0;
  	} else {
 		if (!(peer = ast_calloc(1, sizeof(*peer))))
 			return NULL;
@@ -15295,11 +15302,12 @@
 		ASTOBJ_INIT(peer);
 	}
 	/* Note that our peer HAS had its reference count incrased */
-
-	peer->lastmsgssent = -1;
-	oldha = peer->ha;
-	peer->ha = NULL;
-	set_peer_defaults(peer);	/* Set peer defaults */
+	if (firstpass) {
+		peer->lastmsgssent = -1;
+		oldha = peer->ha;
+		peer->ha = NULL;
+		set_peer_defaults(peer);	/* Set peer defaults */
+	}
 	if (!found && name)
 			ast_copy_string(peer->name, name, sizeof(peer->name));
 
@@ -15309,7 +15317,7 @@
 		peer->chanvars = NULL;
 		/* XXX should unregister ? */
 	}
-	for (; v; v = v->next) {
+	for (; v || ((v = alt) && !(alt=NULL)); v = v->next) {
 		if (handle_common_options(&peerflags[0], &mask[0], v))
 			continue;
 		if (realtime && !strcasecmp(v->name, "regseconds")) {
@@ -15329,6 +15337,10 @@
 			peer->auth = add_realm_authentication(peer->auth, v->value, v->lineno);
 		else if (!strcasecmp(v->name, "callerid")) {
 			ast_callerid_split(v->value, peer->cid_name, sizeof(peer->cid_name), peer->cid_num, sizeof(peer->cid_num));
+		} else if (!strcasecmp(v->name, "fullname")) {
+			ast_copy_string(peer->cid_name, v->value, sizeof(peer->cid_name));
+		} else if (!strcasecmp(v->name, "cid_number")) {
+			ast_copy_string(peer->cid_num, v->value, sizeof(peer->cid_num));
 		} else if (!strcasecmp(v->name, "context")) {
 			ast_copy_string(peer->context, v->value, sizeof(peer->context));
 		} else if (!strcasecmp(v->name, "subscribecontext")) {
@@ -15517,7 +15529,7 @@
  */
 static int reload_config(enum channelreloadreason reason)
 {
-	struct ast_config *cfg;
+	struct ast_config *cfg, *ucfg;
 	struct ast_variable *v;
 	struct sip_peer *peer;
 	struct sip_user *user;
@@ -15879,6 +15891,58 @@
  			authl = add_realm_authentication(authl, v->value, v->lineno);
  	}
 	
+	ucfg = ast_config_load("users.conf");
+	if (ucfg) {
+		struct ast_variable *gen;
+		int genhassip, genregistersip;
+		char *hassip, *registersip;
+		
+		genhassip = ast_true(ast_variable_retrieve(ucfg, "general", "hassip"));
+		genregistersip = ast_true(ast_variable_retrieve(ucfg, "general", "registersip"));
+		gen = ast_variable_browse(ucfg, "general");
+		cat = ast_category_browse(ucfg, NULL);
+		while (cat) {
+			if (strcasecmp(cat, "general")) {
+				hassip = ast_variable_retrieve(ucfg, cat, "hassip");
+				registersip = ast_variable_retrieve(ucfg, cat, "registersip");
+				if (ast_true(hassip) || (!hassip && genhassip)) {
+					peer = build_peer(cat, gen, ast_variable_browse(ucfg, cat), 0);
+					if (peer) {
+						ASTOBJ_CONTAINER_LINK(&peerl,peer);
+						ASTOBJ_UNREF(peer, sip_destroy_peer);
+						peer_count++;
+					}
+				}
+				if (ast_true(registersip) || (!registersip && genregistersip)) {
+					char tmp[256];
+					char *host = ast_variable_retrieve(ucfg, cat, "host");
+					char *username = ast_variable_retrieve(ucfg, cat, "username");
+					char *secret = ast_variable_retrieve(ucfg, cat, "secret");
+					char *contact = ast_variable_retrieve(ucfg, cat, "contact");
+					if (!host)
+						host = ast_variable_retrieve(ucfg, "general", "host");
+					if (!username)
+						username = ast_variable_retrieve(ucfg, "general", "username");
+					if (!secret)
+						secret = ast_variable_retrieve(ucfg, "general", "secret");
+					if (!contact)
+						contact = "s";
+					if (!ast_strlen_zero(username) && !ast_strlen_zero(host)) {
+						if (!ast_strlen_zero(secret))
+							snprintf(tmp, sizeof(tmp), "%s:%s@%s/%s", username, secret, host, contact);
+						else
+							snprintf(tmp, sizeof(tmp), "%s@%s/%s", username, host, contact);
+						if (sip_register(tmp, 0) == 0)
+							registry_count++;
+					}
+				}
+			}
+			cat = ast_category_browse(ucfg, cat);
+		}
+		ast_config_destroy(ucfg);
+	}
+	
+
 	/* Load peers, users and friends */
 	cat = NULL;
 	while ( (cat = ast_category_browse(cfg, cat)) ) {
@@ -15910,7 +15974,7 @@
 				}
 			}
 			if (is_peer) {
-				peer = build_peer(cat, ast_variable_browse(cfg, cat), 0);
+				peer = build_peer(cat, ast_variable_browse(cfg, cat), NULL, 0);
 				if (peer) {
 					ASTOBJ_CONTAINER_LINK(&peerl,peer);
 					ASTOBJ_UNREF(peer, sip_destroy_peer);

Modified: team/qwell/cli-reverbification/channels/chan_skinny.c
URL: http://svn.digium.com/view/asterisk/team/qwell/cli-reverbification/channels/chan_skinny.c?rev=43210&r1=43209&r2=43210&view=diff
==============================================================================
--- team/qwell/cli-reverbification/channels/chan_skinny.c (original)
+++ team/qwell/cli-reverbification/channels/chan_skinny.c Mon Sep 18 14:47:33 2006
@@ -139,67 +139,67 @@
 /* no additional struct */
 
 #define REGISTER_MESSAGE 0x0001
-typedef struct register_message {
+struct register_message {
 	char name[16];
 	uint32_t userId;
 	uint32_t instance;
 	uint32_t ip;
 	uint32_t type;
 	uint32_t maxStreams;
-} register_message;
+};
 
 #define IP_PORT_MESSAGE	0x0002
 
 #define KEYPAD_BUTTON_MESSAGE 0x0003
-typedef struct keypad_button_message {
+struct keypad_button_message {
 	uint32_t button;
 	uint32_t lineInstance;
 	uint32_t callReference;
-} keypad_button_message;
+};
 
 #define STIMULUS_MESSAGE 0x0005
-typedef struct stimulus_message {
+struct stimulus_message {
 	uint32_t stimulus;
 	uint32_t stimulusInstance;
 	uint32_t unknown1;
-} stimulus_message;
+};
 
 #define OFFHOOK_MESSAGE 0x0006
-typedef struct offhook_message {
+struct offhook_message {
 	uint32_t unknown1;
 	uint32_t unknown2;
-} offhook_message;
+};
 
 #define ONHOOK_MESSAGE 0x0007
-typedef struct onhook_message {
+struct onhook_message {
 	uint32_t unknown1;
 	uint32_t unknown2;
-} onhook_message;
+};
 
 #define CAPABILITIES_RES_MESSAGE 0x0010
-typedef struct station_capabilities {
+struct station_capabilities {
 	uint32_t codec;
 	uint32_t frames;
 	union {
 		char res[8];
 		uint64_t rate;
 	} payloads;

[... 3199 lines stripped ...]


More information about the asterisk-commits mailing list