aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_meetme.c
diff options
context:
space:
mode:
authorfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2008-04-18 18:15:11 +0000
committerfile <file@f38db490-d61c-443f-a65b-d21fe96a405b>2008-04-18 18:15:11 +0000
commit4fabc3fc0286871888c46be5111469eecaddd797 (patch)
tree2d5eee23ad90f620416c1e05ff84cf603a7bb7aa /apps/app_meetme.c
parent1b556f00bb0b3b4b247a13742bba2b690a45bf91 (diff)
Add MEETME_INFO dialplan function that allows querying various properties of a Meetme conference.
(closes issue #11691) Reported by: junky Patches: meetme_info.patch uploaded by jpeeler (license 325) git-svn-id: http://svn.digium.com/svn/asterisk/trunk@114261 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_meetme.c')
-rw-r--r--apps/app_meetme.c86
1 files changed, 86 insertions, 0 deletions
diff --git a/apps/app_meetme.c b/apps/app_meetme.c
index 5f265a1d7..1243a255a 100644
--- a/apps/app_meetme.c
+++ b/apps/app_meetme.c
@@ -5525,6 +5525,88 @@ static int sla_load_config(int reload)
return res;
}
+static int acf_meetme_info_eval(char *keyword, struct ast_conference *conf)
+{
+ if (!strcasecmp("lock", keyword)) {
+ return conf->locked;
+ } else if (!strcasecmp("parties", keyword)) {
+ return conf->users;
+ } else if (!strcasecmp("activity", keyword)) {
+ time_t now;
+ now = time(NULL);
+ return (now - conf->start);
+ } else if (!strcasecmp("dynamic", keyword)) {
+ return conf->isdynamic;
+ } else {
+ return -1;
+ }
+
+}
+
+static int acf_meetme_info(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
+{
+ struct ast_conference *conf;
+ char *parse;
+ int result = -2; /* only non-negative numbers valid, -1 is used elsewhere */
+ AST_DECLARE_APP_ARGS(args,
+ AST_APP_ARG(keyword);
+ AST_APP_ARG(confno);
+ );
+
+ if (ast_strlen_zero(data)) {
+ ast_log(LOG_ERROR, "Syntax: MEETME_INFO() requires two arguments\n");
+ return -1;
+ }
+
+ parse = ast_strdupa(data);
+ AST_STANDARD_APP_ARGS(args, parse);
+
+ if (ast_strlen_zero(args.keyword)) {
+ ast_log(LOG_ERROR, "Syntax: MEETME_INFO() requires a keyword\n");
+ return -1;
+ }
+
+ if (ast_strlen_zero(args.confno)) {
+ ast_log(LOG_ERROR, "Syntax: MEETME_INFO() requires a conference number\n");
+ return -1;
+ }
+
+ AST_LIST_LOCK(&confs);
+ AST_LIST_TRAVERSE(&confs, conf, list) {
+ if (!strcmp(args.confno, conf->confno)) {
+ result = acf_meetme_info_eval(args.keyword, conf);
+ break;
+ }
+ }
+ AST_LIST_UNLOCK(&confs);
+
+ if (result > -1) {
+ snprintf(buf, len, "%d", result);
+ } else if (result == -1) {
+ snprintf(buf, len, "%s %s", "Error: invalid keyword:", args.keyword);
+ } else if (result == -2) {
+ snprintf(buf, len, "Error: conference (%s) not found", args.confno);
+ }
+
+ return 0;
+}
+
+
+static struct ast_custom_function meetme_info_acf = {
+ .name = "MEETME_INFO",
+ .synopsis = "Query a given conference of various properties.",
+ .syntax = "MEETME_INFO(<keyword>,<confno>)",
+ .read = acf_meetme_info,
+ .desc =
+"Returns information from a given keyword. (For booleans 1-true, 0-false)\n"
+" Options:\n"
+" lock - boolean of whether the corresponding conference is locked\n"
+" parties - number of parties in a given conference\n"
+" activity - duration of conference in seconds\n"
+" dynamic - boolean of whether the corresponding coference is dynamic\n",
+};
+
+
static int load_config(int reload)
{
load_config_meetme();
@@ -5558,6 +5640,8 @@ static int unload_module(void)
ast_devstate_prov_del("SLA");
sla_destroy();
+
+ res |= ast_custom_function_unregister(&meetme_info_acf);
return res;
}
@@ -5587,6 +5671,8 @@ static int load_module(void)
res |= ast_devstate_prov_add("Meetme", meetmestate);
res |= ast_devstate_prov_add("SLA", sla_state);
+ res |= ast_custom_function_register(&meetme_info_acf);
+
return res;
}