[asterisk-commits] pcadach: branch pcadach/chan_h323-live r43065 - /team/pcadach/chan_h323-live/...

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sat Sep 16 23:42:43 MST 2006


Author: pcadach
Date: Sun Sep 17 01:42:42 2006
New Revision: 43065

URL: http://svn.digium.com/view/asterisk?rev=43065&view=rev
Log:
Provide userconf support for chan_h323 too

Modified:
    team/pcadach/chan_h323-live/channels/chan_h323.c

Modified: team/pcadach/chan_h323-live/channels/chan_h323.c
URL: http://svn.digium.com/view/asterisk/team/pcadach/chan_h323-live/channels/chan_h323.c?rev=43065&r1=43064&r2=43065&view=diff
==============================================================================
--- team/pcadach/chan_h323-live/channels/chan_h323.c (original)
+++ team/pcadach/chan_h323-live/channels/chan_h323.c Sun Sep 17 01:42:42 2006
@@ -1191,7 +1191,7 @@
 	}
 }
 
-static struct oh323_alias *build_alias(const char *name, struct ast_variable *v, int realtime)
+static struct oh323_alias *build_alias(const char *name, struct ast_variable *v, struct ast_variable *alt, int realtime)
 {
 	struct oh323_alias *alias;
 	int found = 0;
@@ -1207,7 +1207,7 @@
 	}
 	if (!found && name)
 		strncpy(alias->name, name, sizeof(alias->name) - 1);
-	for (; v; v = v->next) {
+	for (; v || ((v = alt) && !(alt = NULL)); v = v->next) {
 		if (!strcasecmp(v->name, "e164")) {
 			strncpy(alias->e164, v->value, sizeof(alias->e164) - 1);
 		} else if (!strcasecmp(v->name, "prefix")) {
@@ -1244,7 +1244,7 @@
 		}
 	}
 
-	a = build_alias(alias, var, 1);
+	a = build_alias(alias, var, NULL, 1);
 
 	ast_variables_destroy(var);
 
@@ -1314,6 +1314,10 @@
 		options->progress_audio = ast_true(v->value);
 	} else if (!strcasecmp(v->name, "callerid")) {
 		ast_callerid_split(v->value, options->cid_name, sizeof(options->cid_name), options->cid_num, sizeof(options->cid_num));
+	} else if (!strcasecmp(v->name, "fullname")) {
+		ast_copy_string(options->cid_name, v->value, sizeof(options->cid_name));
+	} else if (!strcasecmp(v->name, "cid_number")) {
+		ast_copy_string(options->cid_num, v->value, sizeof(options->cid_num));
 	} else
 		return 1;
 
@@ -1321,7 +1325,7 @@
 }
 #undef DEPRECATED
 
-static struct oh323_user *build_user(char *name, struct ast_variable *v, int realtime)
+static struct oh323_user *build_user(char *name, struct ast_variable *v, struct ast_variable *alt, int realtime)
 {
 	struct oh323_user *user;
 	struct ast_ha *oldha;
@@ -1352,7 +1356,7 @@
 	}
 #endif
 
-	for (; v; v = v->next) {
+	for (; v || ((v = alt) && !(alt = NULL)); v = v->next) {
 		if (!update_common_options(v, &user->options))
 			continue;
 		if (!strcasecmp(v->name, "context")) {
@@ -1420,14 +1424,14 @@
 		return NULL;
 	}
 
-	user = build_user(username, var, 1);
+	user = build_user(username, var, NULL, 1);
 	
 	ast_variables_destroy(var);
 
 	return user;
 }
 
-static struct oh323_peer *build_peer(const char *name, struct ast_variable *v, int realtime)
+static struct oh323_peer *build_peer(const char *name, struct ast_variable *v, struct ast_variable *alt, int realtime)
 {
 	struct oh323_peer *peer;
 	struct ast_ha *oldha;
@@ -1459,7 +1463,7 @@
 	/* Default settings for mailbox */
 	peer->mailbox[0] = '\0';
 
-	for (; v; v = v->next) {
+	for (; v || ((v = alt) && !(alt = NULL)); v = v->next) {
 		if (!update_common_options(v, &peer->options))
 			continue;
 		if (!strcasecmp(v->name, "host")) {
@@ -1523,7 +1527,7 @@
 	}
 
 	/* Peer found in realtime, now build it in memory */
-	peer = build_peer(peername, var, 1);
+	peer = build_peer(peername, var, NULL, 1);
 
 	ast_variables_destroy(var);
 
@@ -2605,7 +2609,7 @@
 static int reload_config(int is_reload)
 {	
 	int format;
-	struct ast_config *cfg;
+	struct ast_config *cfg, *ucfg;
 	struct ast_variable *v;
 	struct oh323_peer *peer = NULL;
 	struct oh323_user *user = NULL;
@@ -2616,7 +2620,7 @@
 	int is_user, is_peer, is_alias;
 	char _gatekeeper[100];
 	int gk_discover, gk_disable, gk_changed;
-	
+
 	cfg = ast_config_load(config);
 
 	/* We *must* have a config file otherwise stop immediately */
@@ -2652,14 +2656,34 @@
 	/* Copy the default jb config over global_jbconf */
 	memcpy(&global_jbconf, &default_jbconf, sizeof(struct ast_jb_conf));
 
-	v = ast_variable_browse(cfg, "general");
-	while (v) {
+	/* Load configuration from users.conf */
+	ucfg = ast_config_load("users.conf");
+	if (ucfg) {
+		struct ast_variable *gen;
+		int genhas_h323;
+		char *has_h323;
+
+		genhas_h323 = ast_true(ast_variable_retrieve(ucfg, "general", "hash323"));
+		gen = ast_variable_browse(ucfg, "general");
+		for (cat = ast_category_browse(ucfg, NULL); cat; cat = ast_category_browse(ucfg, cat)) {
+			if (strcasecmp(cat, "general")) {
+				has_h323 = ast_variable_retrieve(ucfg, cat, "hash323");
+				if (ast_true(has_h323) || (!has_h323 && genhas_h323)) {
+					peer = build_peer(cat, gen, ast_variable_browse(ucfg, cat), 0);
+					if (peer) {
+						AST_OBJ_CONTAINER_LINK(&peerl, peer);
+						ASTOBJ_UNREF(peer, oh323_destory_peer);
+					}
+				}
+			}
+		}
+		ast_config_destroy(ucfg);
+	}
+
+	for (v = ast_variable_browse(cfg, "general"); v; v = v->next) {
 		/* handle jb conf */
-		if (!ast_jb_read_conf(&global_jbconf, v->name, v->value)) {
-			v = v->next;
+		if (!ast_jb_read_conf(&global_jbconf, v->name, v->value))
 			continue;
-		}
-
 		/* Create the interface list */
 		if (!strcasecmp(v->name, "port")) {
 			h323_signalling_port = (int)strtol(v->value, NULL, 10);
@@ -2710,11 +2734,9 @@
 		} else if (!update_common_options(v, &global_options)) {
 			/* dummy */
 		}
-		v = v->next;	
 	}
 	
-	cat = ast_category_browse(cfg, NULL);
-	while(cat) {
+	for (cat = ast_category_browse(cfg, NULL); cat; cat = ast_category_browse(cfg, cat)) {
 		if (strcasecmp(cat, "general")) {
 			utype = ast_variable_retrieve(cfg, cat, "type");
 			if (utype) {
@@ -2732,21 +2754,21 @@
 					continue;
 				}
 				if (is_user) {
-					user = build_user(cat, ast_variable_browse(cfg, cat), 0);
+					user = build_user(cat, ast_variable_browse(cfg, cat), NULL, 0);
 					if (user) {
 						ASTOBJ_CONTAINER_LINK(&userl, user);
 						ASTOBJ_UNREF(user, oh323_destroy_user);
 					}
 				}
 				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, oh323_destroy_peer);
 					}
 				}
 				if (is_alias) {
-					alias = build_alias(cat, ast_variable_browse(cfg, cat), 0);
+					alias = build_alias(cat, ast_variable_browse(cfg, cat), NULL, 0);
 					if (alias) {
 						ASTOBJ_CONTAINER_LINK(&aliasl, alias);
 						ASTOBJ_UNREF(alias, oh323_destroy_alias);
@@ -2756,7 +2778,6 @@
 				ast_log(LOG_WARNING, "Section '%s' lacks type\n", cat);
 			}
 		}
-		cat = ast_category_browse(cfg, cat);
 	}
 	ast_config_destroy(cfg);
 



More information about the asterisk-commits mailing list