summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoshua Colp <jcolp@digium.com>2008-04-18 18:15:11 +0000
committerJoshua Colp <jcolp@digium.com>2008-04-18 18:15:11 +0000
commite52ae018311032925da11e66a3493bbe217cc052 (patch)
tree2d5eee23ad90f620416c1e05ff84cf603a7bb7aa
parent0e821d72016baa4cf0a2993522f1f8a9163ff5b7 (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: https://origsvn.digium.com/svn/asterisk/trunk@114261 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r--CHANGES2
-rw-r--r--apps/app_meetme.c86
2 files changed, 88 insertions, 0 deletions
diff --git a/CHANGES b/CHANGES
index 90911a438..db4253c51 100644
--- a/CHANGES
+++ b/CHANGES
@@ -426,6 +426,8 @@ MeetMe Changes
for the "meetme" command.
* Added the ability to specify the music on hold class used to play into the
conference when there is only one member and the M option is used.
+ * Added MEETME_INFO dialplan function which provides a way to query
+ various properties of a Meetme conference.
Other Dialplan Application Changes
----------------------------------
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;
}