aboutsummaryrefslogtreecommitdiffstats
path: root/funcs
diff options
context:
space:
mode:
authorfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2008-01-08 19:53:52 +0000
committerfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2008-01-08 19:53:52 +0000
commit32be5ddcb013b94488569e3715f79a43af703f9f (patch)
tree61b48ff74f3acab2a1a61b386f6ad46eb5e6fa00 /funcs
parentffaf83dc83fce81de133db1f3c194c61d74bb4a2 (diff)
If no group has been provided to the GROUP_COUNT dialplan function then use the first one specific to the channel.
(closes issue #11077) Reported by: m4him git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@97152 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'funcs')
-rw-r--r--funcs/func_groupcount.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/funcs/func_groupcount.c b/funcs/func_groupcount.c
index 93ec1e52f..281d9d055 100644
--- a/funcs/func_groupcount.c
+++ b/funcs/func_groupcount.c
@@ -45,6 +45,24 @@ static int group_count_function_read(struct ast_channel *chan, char *cmd,
ast_app_group_split_group(data, group, sizeof(group), category,
sizeof(category));
+ /* If no group has been provided let's find one */
+ if (ast_strlen_zero(group)) {
+ struct ast_group_info *gi = NULL;
+
+ ast_app_group_list_lock();
+ for (gi = ast_app_group_list_head(); gi; gi = AST_LIST_NEXT(gi, list)) {
+ if (gi->chan != chan)
+ continue;
+ if (ast_strlen_zero(category) || (!ast_strlen_zero(gi->category) && !strcasecmp(gi->category, category)))
+ break;
+ }
+ if (gi) {
+ ast_copy_string(group, gi->group, sizeof(group));
+ ast_copy_string(category, gi->category, sizeof(category));
+ }
+ ast_app_group_list_unlock();
+ }
+
if ((count = ast_app_group_get_count(group, category)) == -1)
ast_log(LOG_NOTICE, "No group could be found for channel '%s'\n", chan->name);
else