[asterisk-commits] markster: trunk r43382 - /trunk/channels/chan_agent.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Wed Sep 20 15:09:46 MST 2006


Author: markster
Date: Wed Sep 20 17:09:45 2006
New Revision: 43382

URL: http://svn.digium.com/view/asterisk?rev=43382&view=rev
Log:
Fix agent parsing of users.conf

Modified:
    trunk/channels/chan_agent.c

Modified: trunk/channels/chan_agent.c
URL: http://svn.digium.com/view/asterisk/trunk/channels/chan_agent.c?rev=43382&r1=43381&r2=43382&view=diff
==============================================================================
--- trunk/channels/chan_agent.c (original)
+++ trunk/channels/chan_agent.c Wed Sep 20 17:09:45 2006
@@ -1006,9 +1006,13 @@
 static int read_agent_config(void)
 {
 	struct ast_config *cfg;
+	struct ast_config *ucfg;
 	struct ast_variable *v;
 	struct agent_pvt *p;
 	const char *general_val;
+	const char *catname;
+	const char *hasagent;
+	int genhasagent;
 
 	group = 0;
 	autologoff = 0;
@@ -1103,6 +1107,28 @@
 			ast_copy_string(beep, v->value, sizeof(beep));
 		}
 		v = v->next;
+	}
+	if ((ucfg = ast_config_load("users.conf"))) {
+		genhasagent = ast_true(ast_variable_retrieve(ucfg, "general", "hasagent"));
+		catname = ast_category_browse(ucfg, NULL);
+		while(catname) {
+			if (strcasecmp(catname, "general")) {
+				hasagent = ast_variable_retrieve(ucfg, catname, "hasagent");
+				if (ast_true(hasagent) || (!hasagent && genhasagent)) {
+					char tmp[256];
+					const char *fullname = ast_variable_retrieve(ucfg, catname, "fullname");
+					const char *secret = ast_variable_retrieve(ucfg, catname, "secret");
+					if (!fullname)
+						fullname = "";
+					if (!secret)
+						secret = "";
+					snprintf(tmp, sizeof(tmp), "%s,%s,%s", catname, secret,fullname);
+					add_agent(tmp, 0);
+				}
+			}
+			catname = ast_category_browse(ucfg, catname);
+		}
+		ast_config_destroy(ucfg);
 	}
 	AST_LIST_TRAVERSE_SAFE_BEGIN(&agents, p, list) {
 		if (p->dead) {



More information about the asterisk-commits mailing list