summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2014-06-20 17:06:42 +0000
committerRichard Mudgett <rmudgett@digium.com>2014-06-20 17:06:42 +0000
commit86e8ab5ed47bccf0ee80acfd711eb81b0991522c (patch)
treefcd846af640f5a6dd9b91d732907729ae7ccb6a8 /apps
parent577632dec957bfec258918a381133a3c41411b37 (diff)
voicemail API callbacks: Extract the sayname API call to its own registerd callback.
* Extract the sayname API call to its own registerd callback. This allows the app_directory and app_chanspy applications to say a mailbox owner's name using an alternate provider when app_voicemail is not available because you are using res_mwi_external. app_directory still uses the voicemail.conf file. AFS-64 #close Reported by: Mark Michelson git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@416830 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps')
-rw-r--r--apps/app_chanspy.c12
-rw-r--r--apps/app_directory.c9
-rw-r--r--apps/app_voicemail.c36
3 files changed, 52 insertions, 5 deletions
diff --git a/apps/app_chanspy.c b/apps/app_chanspy.c
index 306e6e84b..47f755e5f 100644
--- a/apps/app_chanspy.c
+++ b/apps/app_chanspy.c
@@ -864,6 +864,15 @@ static struct ast_autochan *next_channel(struct ast_channel_iterator *iter,
return NULL;
}
+static int spy_sayname(struct ast_channel *chan, const char *mailbox, const char *context)
+{
+ char *mailbox_id;
+
+ mailbox_id = ast_alloca(strlen(mailbox) + strlen(context) + 2);
+ sprintf(mailbox_id, "%s@%s", mailbox, context); /* Safe */
+ return ast_app_sayname(chan, mailbox_id);
+}
+
static int common_exec(struct ast_channel *chan, struct ast_flags *flags,
int volfactor, const int fd, struct spy_dtmf_options *user_options,
const char *mygroup, const char *myenforced, const char *spec, const char *exten,
@@ -1078,8 +1087,9 @@ static int common_exec(struct ast_channel *chan, struct ast_flags *flags,
if (ast_test_flag(flags, OPTION_NAME)) {
const char *local_context = S_OR(name_context, "default");
const char *local_mailbox = S_OR(mailbox, ptr);
+
if (local_mailbox) {
- res = ast_app_sayname(chan, local_mailbox, local_context);
+ res = spy_sayname(chan, local_mailbox, local_context);
} else {
res = -1;
}
diff --git a/apps/app_directory.c b/apps/app_directory.c
index 3afb19f29..350401e46 100644
--- a/apps/app_directory.c
+++ b/apps/app_directory.c
@@ -26,7 +26,6 @@
*/
/*** MODULEINFO
- <depend>app_voicemail</depend>
<support_level>core</support_level>
***/
#include "asterisk.h"
@@ -290,7 +289,13 @@ static int play_mailbox_owner(struct ast_channel *chan, const char *context,
const char *ext, const char *name, struct ast_flags *flags)
{
int res = 0;
- if ((res = ast_app_sayname(chan, ext, context)) >= 0) {
+ char *mailbox_id;
+
+ mailbox_id = ast_alloca(strlen(ext) + strlen(context) + 2);
+ sprintf(mailbox_id, "%s@%s", ext, context); /* Safe */
+
+ res = ast_app_sayname(chan, mailbox_id);
+ if (res >= 0) {
ast_stopstream(chan);
/* If Option 'e' was specified, also read the extension number with the name */
if (ast_test_flag(flags, OPT_SAYEXTENSION)) {
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 891d23360..d392dd515 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -13669,6 +13669,29 @@ static int sayname(struct ast_channel *chan, const char *mailbox, const char *co
return res;
}
+/*!
+ * \internal
+ * \brief Play a recorded user name for the mailbox to the specified channel.
+ *
+ * \param chan Where to play the recorded name file.
+ * \param mailbox_id The mailbox name.
+ *
+ * \retval 0 Name played without interruption
+ * \retval dtmf ASCII value of the DTMF which interrupted playback.
+ * \retval -1 Unable to locate mailbox or hangup occurred.
+ */
+static int vm_sayname(struct ast_channel *chan, const char *mailbox_id)
+{
+ char *context;
+ char *mailbox;
+
+ if (ast_strlen_zero(mailbox_id)
+ || separate_mailbox(ast_strdupa(mailbox_id), &mailbox, &context)) {
+ return -1;
+ }
+ return sayname(chan, mailbox, context);
+}
+
static void read_password_from_file(const char *secretfn, char *password, int passwordlen) {
struct ast_config *pwconf;
struct ast_flags config_flags = { 0 };
@@ -14286,7 +14309,6 @@ static const struct ast_vm_functions vm_table = {
.inboxcount = inboxcount,
.inboxcount2 = inboxcount2,
.messagecount = messagecount,
- .sayname = sayname,
.copy_recording_to_vm = msg_create_from_file,
.index_to_foldername = vm_index_to_foldername,
.mailbox_snapshot_create = vm_mailbox_snapshot_create,
@@ -14297,6 +14319,13 @@ static const struct ast_vm_functions vm_table = {
.msg_play = vm_msg_play,
};
+static const struct ast_vm_greeter_functions vm_greeter_table = {
+ .module_version = VM_GREETER_MODULE_VERSION,
+ .module_name = AST_MODULE,
+
+ .sayname = vm_sayname,
+};
+
static int reload(void)
{
return load_config(1);
@@ -14327,6 +14356,7 @@ static int unload_module(void)
#endif
ast_cli_unregister_multiple(cli_voicemail, ARRAY_LEN(cli_voicemail));
ast_vm_unregister(vm_table.module_name);
+ ast_vm_greeter_unregister(vm_greeter_table.module_name);
#ifdef TEST_FRAMEWORK
ast_uninstall_vm_test_functions();
#endif
@@ -14394,8 +14424,10 @@ static int load_module(void)
#endif
res |= ast_vm_register(&vm_table);
- if (res)
+ res |= ast_vm_greeter_register(&vm_greeter_table);
+ if (res) {
return res;
+ }
ast_cli_register_multiple(cli_voicemail, ARRAY_LEN(cli_voicemail));
ast_data_register_multiple(vm_data_providers, ARRAY_LEN(vm_data_providers));