summaryrefslogtreecommitdiff
path: root/apps/app_voicemail.c
diff options
context:
space:
mode:
authorGeorge Joseph <george.joseph@fairview5.com>2015-12-30 09:49:03 -0700
committerGeorge Joseph <george.joseph@fairview5.com>2016-01-04 16:28:48 -0700
commit4ec85a9f076d64d01110da32817e40fb96cd5321 (patch)
treeafeb222c5a92466a99705baa2a5ed11e4c6f3f3b /apps/app_voicemail.c
parentf42036bf6b4a188dd9a083669c9a00e37203e51c (diff)
voicemail: Move app_voicemail / res_mwi_external conflict to runtime
The menuselect conflict between app_voicemail and res_mwi_external makes it hard to package 1 version of Asterisk. There no actual build dependencies between the 2 so moving this check to runtime seems like a better solution. The ast_vm_register and ast_vm_greeter_register functions in app.c were modified to return AST_MODULE_LOAD_DECLINE instead of -1 if there is already a voicemail module registered. The modules' load_module functions were then modified to return DECLINE instead of -1 to the loader. Since -1 is interpreted by the loader as AST_MODULE_LOAD_FAILURE, the modules were incorrectly causing Asterisk to stop so this needed to be cleaned up anyway. Now you can build both and use modules.conf to decide which voicemail implementation to load. The default menuselect options still build app_voicemail and not res_mwi_external but if both ARE built, res_mwi_external will load first and become the voicemail provider unless modules.conf rules prevent it. This is noted in CHANGES. Change-Id: I7d98d4e8a3b87b8df9e51c2608f0da6ddfb89247
Diffstat (limited to 'apps/app_voicemail.c')
-rw-r--r--apps/app_voicemail.c45
1 files changed, 33 insertions, 12 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 19bd896af..0755c44b0 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -48,7 +48,6 @@
/*** MODULEINFO
<defaultenabled>yes</defaultenabled>
- <conflict>res_mwi_external</conflict>
<use type="module">res_adsi</use>
<use type="module">res_smdi</use>
<support_level>core</support_level>
@@ -14702,10 +14701,14 @@ static int unload_module(void)
*
* Module loading including tests for configuration or dependencies.
* This function can return AST_MODULE_LOAD_FAILURE, AST_MODULE_LOAD_DECLINE,
- * or AST_MODULE_LOAD_SUCCESS. If a dependency or environment variable fails
- * tests return AST_MODULE_LOAD_FAILURE. If the module can not load the
- * configuration file or other non-critical problem return
- * AST_MODULE_LOAD_DECLINE. On success return AST_MODULE_LOAD_SUCCESS.
+ * or AST_MODULE_LOAD_SUCCESS.
+ *
+ * If a dependency, allocation or environment variable fails tests, return AST_MODULE_LOAD_FAILURE.
+ *
+ * If the module can't load the configuration file, can't register as a provider or
+ * has another issue not fatal to Asterisk itself, return AST_MODULE_LOAD_DECLINE.
+ *
+ * On success return AST_MODULE_LOAD_SUCCESS.
*/
static int load_module(void)
{
@@ -14714,7 +14717,7 @@ static int load_module(void)
umask(my_umask);
if (!(inprocess_container = ao2_container_alloc(573, inprocess_hash_fn, inprocess_cmp_fn))) {
- return AST_MODULE_LOAD_DECLINE;
+ return AST_MODULE_LOAD_FAILURE;
}
/* compute the location of the voicemail spool directory */
@@ -14724,8 +14727,10 @@ static int load_module(void)
ast_log(AST_LOG_WARNING, "failed to reference mwi subscription taskprocessor. MWI will not work\n");
}
- if ((res = load_config(0)))
- return res;
+ if ((res = load_config(0))) {
+ unload_module();
+ return AST_MODULE_LOAD_DECLINE;
+ }
res = ast_register_application_xml(app, vm_exec);
res |= ast_register_application_xml(app2, vm_execmain);
@@ -14746,10 +14751,26 @@ static int load_module(void)
res |= AST_TEST_REGISTER(test_voicemail_vm_info);
#endif
- res |= ast_vm_register(&vm_table);
- res |= ast_vm_greeter_register(&vm_greeter_table);
if (res) {
- return res;
+ ast_log(LOG_ERROR, "Failure registering applications, functions or tests\n");
+ unload_module();
+ return AST_MODULE_LOAD_DECLINE;
+ }
+
+ /* ast_vm_register may return DECLINE if another module registered for vm */
+ res = ast_vm_register(&vm_table);
+ if (res) {
+ ast_log(LOG_ERROR, "Failure registering as a voicemail provider\n");
+ unload_module();
+ return AST_MODULE_LOAD_DECLINE;
+ }
+
+ /* ast_vm_greeter_register may return DECLINE if another module registered as a greeter */
+ res = ast_vm_greeter_register(&vm_greeter_table);
+ if (res) {
+ ast_log(LOG_ERROR, "Failure registering as a greeter provider\n");
+ unload_module();
+ return AST_MODULE_LOAD_DECLINE;
}
ast_cli_register_multiple(cli_voicemail, ARRAY_LEN(cli_voicemail));
@@ -14762,7 +14783,7 @@ static int load_module(void)
ast_realtime_require_field("voicemail", "uniqueid", RQ_UINTEGER3, 11, "password", RQ_CHAR, 10, SENTINEL);
ast_realtime_require_field("voicemail_data", "filename", RQ_CHAR, 30, "duration", RQ_UINTEGER3, 5, SENTINEL);
- return res;
+ return AST_MODULE_LOAD_SUCCESS;
}
static int dialout(struct ast_channel *chan, struct ast_vm_user *vmu, char *num, char *outgoing_context)