[asterisk-commits] branch oej/aum - r7423 in /team/oej/aum: include/asterisk/aum.h res/res_aum.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sat Dec 10 09:58:43 CST 2005


Author: oej
Date: Sat Dec 10 09:58:40 2005
New Revision: 7423

URL: http://svn.digium.com/view/asterisk?rev=7423&view=rev
Log:
- Added "aum show group <name>"
- Added parking context to configuration
- Added configuration for group contexts
- Note: Groups are still not really used for anything
- Note: Realtime groups are not enabled

Modified:
    team/oej/aum/include/asterisk/aum.h
    team/oej/aum/res/res_aum.c

Modified: team/oej/aum/include/asterisk/aum.h
URL: http://svn.digium.com/view/asterisk/team/oej/aum/include/asterisk/aum.h?rev=7423&r1=7422&r2=7423&view=diff
==============================================================================
--- team/oej/aum/include/asterisk/aum.h (original)
+++ team/oej/aum/include/asterisk/aum.h Sat Dec 10 09:58:40 2005
@@ -24,7 +24,7 @@
 /*!\file
  * \brief Asterisk User Managment - AUM - API
  * \arg Implemented in res_aum.c
- * \par See also
+ * \par For information on AUM, please see
  *  	\arg AUM_desc
  */
 
@@ -112,6 +112,7 @@
 	AUM_CNF_VMAILBOX,		/*!< Voicemail mailbox exten at context */
 	AUM_CNF_GROUP,			/*!< Group membership */
 	AUM_CNF_CALLBACKEXT,		/*!< Default extension */
+	AUM_CNF_PARKING,		/*!< Default parking context */
 	AUM_CNF_DISACONTEXT,		/*!< DISA context for disa() access */
 	AUM_CNF_SIPDOMAIN,		/*!< SIP DOMAIN this user belongs to (virtual PBX) */
 	AUM_CNF_SUBSCRIBECONTEXT,	/*!< SIP subscription context */
@@ -176,6 +177,7 @@
 	AUM_CONTEXT_VOICEMAIL,	/*!< Default voicemail context */
 	AUM_CONTEXT_DISA,	/*!< Default DISA context */
 	AUM_CONTEXT_SIPSUBSCRIBE,	/*!< Default context for SIP subscriptions */
+	AUM_CONTEXT_PARKING,	/*!< Default parking context */
 };
 
 /*! \brief Explanations of contexts */
@@ -327,6 +329,7 @@
 	int managerperm;			/*!< This group's permissions in manager */
 	struct aum_user_contextlist contexts;	/*!< Linked list of contexts this group use */
 	struct ast_variable *chanvars;
+	struct ast_ha	*acl;			/*!< Access control list for user */
 	char *description;			/*!< Description */
 	struct aum_user_grouplist members;	/*!< Members list */
 	char registrar[20];		/*!< Who added this object? */
@@ -379,7 +382,7 @@
 	\param Group name in text
 	\result struct aum_group pointer to group
 */
-struct aum_group *find_group_by_name(char *groupname);
+struct aum_group *find_aum_group_by_name(char *groupname);
 
 /*! \brief Find out if user belongs to group 
 	\param user AUM user object
@@ -430,6 +433,11 @@
 	\return character string pointer if context found, NULL if not found
 */
 char *aum_find_user_context(struct aum_user *user, enum aum_context_type type);
+
+/*! \brief Find parking context for a user 
+	\param user AUM user struct pointer
+*/
+#define aum_find_user_parking(user)	aum_find_user_context(user, AUM_CONTEXT_PARKING);
 
 /*--------- AUM String handling functions ----------------------*/
 /*! \brief Allocate AUM string - remember to deallocate

Modified: team/oej/aum/res/res_aum.c
URL: http://svn.digium.com/view/asterisk/team/oej/aum/res/res_aum.c?rev=7423&r1=7422&r2=7423&view=diff
==============================================================================
--- team/oej/aum/res/res_aum.c (original)
+++ team/oej/aum/res/res_aum.c Sat Dec 10 09:58:40 2005
@@ -346,6 +346,13 @@
 }
 
 /*----------------------------- CLI COMMANDS ----------------------*/
+/*! \brief  print_group: Print call group and pickup group ---*/
+static void  print_group(int fd, unsigned int group, int crlf) 
+{
+	char buf[256];
+	ast_cli(fd, crlf ? "%s\r\n" : "%s\n", ast_print_group(buf, sizeof(buf), group) );
+}
+
 
 /*! \brief CLI command description */
 static char cli_aum_show_stats_usage[] = 
@@ -440,15 +447,16 @@
 /*! \brief CLI command description */
 static char cli_aum_show_user_usage[] = 
 "Usage: aum show user <user>\n"
-"	Lists details about one AUM user.\n"
+"	Lists details about one AUM user, either static or a realtime user in the realtime cache.\n"
+"	To load a user in the realtime cache, use \"aum load rtuser\"\n"
 "	For a list of all static users, use \"aum show users\"\n";
 
 /*! \brief CLI command "aum show user" */
 static int cli_aum_show_user(int fd, int argc, char *argv[])
 {
 	struct aum_group_member *member;
+	struct aum_context *context;
 	struct aum_address *addr;
-	struct aum_context *context;
 	struct aum_user *user;
 
 	if (argc != 4)
@@ -488,12 +496,87 @@
 	AST_LIST_TRAVERSE(&user->contexts, context, list) {
 		ast_cli(fd, " %s Context : %s\n", context_type2str(context->type), context->context);
 	};
+	ast_cli(fd, "  Callgroup:     ");
+	print_group(fd, user->callgroup, 0);
+	ast_cli(fd, "  Pickupgroup:   ");
+	print_group(fd, user->pickupgroup, 0);
 	ast_cli(fd, " Numeric ID :    %s\n", user->numuserid);
 	ast_cli(fd, " Secret :        %s\n", !ast_strlen_zero(user->secret) ? "<set>" : "<not set>");
 	ast_cli(fd, " Music class:    %s\n", user->musicclass);
 	ast_cli(fd, " Language:       %s\n", user->language);
 	ast_cli(fd, " Mailbox:        %s\n", user->mailbox);
 	ast_cli(fd, " ACL:            %s\n", (user->acl?"Yes (IP address restriction)":"No"));
+	if (user->chanvars) {
+		struct ast_variable *v;
+ 		ast_cli(fd, "  Variables    :\n");
+		for (v = user->chanvars ; v ; v = v->next)
+ 			ast_cli(fd, "                 %s = %s\n", v->name, v->value);
+	}
+	ast_cli(fd,"\n");
+	
+	return RESULT_SUCCESS;
+}
+
+/*! \brief CLI command description */
+static char cli_aum_show_group_usage[] = 
+"Usage: aum show group <group>\n"
+"	Lists details about one AUM group.\n"
+"	For a list of all static groups, use \"aum show groups\"\n";
+
+/*! \brief CLI command "aum show group" */
+static int cli_aum_show_group(int fd, int argc, char *argv[])
+{
+	struct aum_address *addr;
+	struct aum_context *context;
+	struct aum_group *group;
+	struct aum_group_member *member;
+	int groupmembers = 0;
+
+	if (argc != 4)
+		return RESULT_SHOWUSAGE;
+	ast_log(LOG_DEBUG, "Trying to find group %s to show... \n", argv[3]);
+
+	group = find_aum_group_by_name(argv[3]);
+	if (!group) {
+		ast_cli(fd, "- AUM group %s not found\n", argv[3]);
+		return RESULT_SUCCESS;
+	}
+	ast_cli(fd, "* Group:         %s\n", group->name);
+	AST_LIST_TRAVERSE(&group->members, member, list) {
+		groupmembers++;
+	};
+	ast_cli(fd, " Number of members: %d\n", groupmembers);
+
+	//if (ast_test_flag(group, AUM_USER_FLAG_REALTIME))
+		//ast_cli(fd, " Usertype:   Realtime (cached)\n");
+	//else
+		//ast_cli(fd, " Usertype:   Static\n");
+
+	//if (ast_test_flag(group, AUM_USER_FLAG_DISABLED))
+		//ast_cli(fd, " Status:     Disabled\n");
+	//else
+		//ast_cli(fd, " Status:     Enabled\n");
+
+	if (!ast_strlen_zero(group->description))
+		ast_cli(fd, " Description:       %s\n", group->description);
+	
+	AST_LIST_TRAVERSE(&group->contexts, context, list) {
+		ast_cli(fd, " %s Context : %s\n", context_type2str(context->type), context->context);
+	};
+	ast_cli(fd, "  Callgroups:    ");
+	print_group(fd, group->callgroup, 0);
+	ast_cli(fd, "  Pickupgroups:  ");
+	print_group(fd, group->pickupgroup, 0);
+	ast_cli(fd, " Music class:    %s\n", group->musicclass);
+	ast_cli(fd, " Language:       %s\n", group->language);
+	ast_cli(fd, " ACL:            %s\n", (group->acl?"Yes (IP address restriction)":"No"));
+	if (group->chanvars) {
+		struct ast_variable *v;
+ 		ast_cli(fd, "  Variables    :\n");
+		for (v = group->chanvars ; v ; v = v->next)
+ 			ast_cli(fd, "                 %s = %s\n", v->name, v->value);
+	}
+	ast_cli(fd,"\n");
 	
 	return RESULT_SUCCESS;
 }
@@ -530,6 +613,7 @@
 /*! \brief CLI entries for the AUM module */
 static struct ast_cli_entry my_clis[] = {
 	{ { "aum", "show", "groups", NULL }, cli_aum_show_groups, "List AUM groups", cli_aum_show_groups_usage },
+	{ { "aum", "show", "group", NULL }, cli_aum_show_group, "List details of AUM group", cli_aum_show_group_usage },
 	{ { "aum", "show", "users", NULL }, cli_aum_show_users, "List AUM users", cli_aum_show_users_usage },
 	{ { "aum", "show", "user", NULL }, cli_aum_show_user, "List details of AUM user", cli_aum_show_user_usage },
 	{ { "aum", "show", "stats", NULL }, cli_aum_show_stats, "Display AUM statistics", cli_aum_show_stats_usage },
@@ -754,6 +838,7 @@
 	{ AUM_CNF_DEFCONTEXT,	"context" 	,AUM_CONFOBJ_USER & AUM_CONFOBJ_GROUP },
 	{ AUM_CNF_SUBSCRIBECONTEXT,	"subscribecontext" 	,AUM_CONFOBJ_USER & AUM_CONFOBJ_GROUP },
 	{ AUM_CNF_DISACONTEXT,	"disacontext" 	,AUM_CONFOBJ_USER & AUM_CONFOBJ_GROUP },
+	{ AUM_CNF_PARKING,	"parking" 	,AUM_CONFOBJ_USER & AUM_CONFOBJ_GROUP },
 	{ AUM_CNF_CID,		"callerid" 	,AUM_CONFOBJ_USER },
 	{ AUM_CNF_CALLERPRES,	"callerpres" 	,AUM_CONFOBJ_USER & AUM_CONFOBJ_GROUP },
 	{ AUM_CNF_ACCOUNTCODE,	"accountcode" 	,AUM_CONFOBJ_USER & AUM_CONFOBJ_GROUP },
@@ -905,6 +990,9 @@
 
 	if (type == AUM_CONTEXT_NONE) {
 		switch (option) {
+		case AUM_CNF_PARKING:
+			type = AUM_CONTEXT_PARKING;
+			break;
 		case AUM_CNF_DISACONTEXT:
 			type = AUM_CONTEXT_DISA;
 			break;
@@ -1057,7 +1145,7 @@
 	struct aum_context *context;
 	enum aum_config_options option;
 
-	/* Check if username exists already */
+	/* Check if username exists already, do not check realtime again */
 	if (find_aum_user(username, FALSE)) {
 		ast_log(LOG_WARNING, "Ignoring duplicate user %s\n", username);
 		return NULL;
@@ -1101,7 +1189,7 @@
 		case AUM_CNF_VMAILBOX:
 			break;
 		case AUM_CNF_GROUP:
-			if (add_user_to_group(find_group_by_name(x->value), user) < 0)
+			if (add_user_to_group(find_aum_group_by_name(x->value), user) < 0)
 				ast_log(LOG_ERROR, "Could not add user %s to group %s\n", user->name, x->value);
 			break;
 		case AUM_CNF_CALLBACKEXT:
@@ -1109,6 +1197,7 @@
 		case AUM_CNF_DEFCONTEXT:
 		case AUM_CNF_SUBSCRIBECONTEXT:
 		case AUM_CNF_DISACONTEXT:
+		case AUM_CNF_PARKING:
 			break;
 			context = build_context(AUM_CONTEXT_NONE, option, x->value);
 			if (context)
@@ -1232,6 +1321,7 @@
 static struct aum_group *aum_build_group(char *groupname, struct ast_variable *x, int realtime)
 {
 	struct aum_group *group;
+	struct aum_context *context;
 	enum aum_config_options option;
 
 	group = aum_allocate(sizeof(struct aum_group));
@@ -1256,6 +1346,17 @@
 		switch (option) {
 		case AUM_CNF_GROUPDESC:
 			group->description = strdup(x->value);
+			break;
+		case AUM_CNF_DEFCONTEXT:
+		case AUM_CNF_SUBSCRIBECONTEXT:
+		case AUM_CNF_DISACONTEXT:
+		case AUM_CNF_PARKING:
+			break;
+			context = build_context(AUM_CONTEXT_NONE, option, x->value);
+			if (context)
+				AST_LIST_INSERT_TAIL(&group->contexts, context, list);
+			else
+				ast_log(LOG_ERROR, "Context %s not added for group %s\n", x->value, groupname);
 			break;
 		case AUM_CNF_NOT_FOUND:
 			ast_log(LOG_NOTICE, "Configuration label unknown in AUM configuration: %s\n", x->name);
@@ -1683,7 +1784,7 @@
 }
 
 
-struct aum_group *find_group_by_name(char *groupname)
+struct aum_group *find_aum_group_by_name(char *groupname)
 {
 	struct aum_group *res;
 	if (ast_strlen_zero(groupname))
@@ -1728,7 +1829,7 @@
 
 int aum_group_test(struct aum_user *user, char *groupname) 
 {
-	return aum_group_test_full(user, find_group_by_name(groupname));
+	return aum_group_test_full(user, find_aum_group_by_name(groupname));
 }
 
 /*! \brief Initialize charset conversion handlers */



More information about the asterisk-commits mailing list