app_voicemail: Voicemail callback registration/unregistration function improvements.

* The voicemail registration/unregistration functions now take a struct of
callbacks instead of a lengthy parameter list of callbacks.

* The voicemail registration/unregistration functions now prevent a
competing module from interfering with an already registered callback
supplying module.


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@403643 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Richard Mudgett
2013-12-11 19:19:24 +00:00
parent ce423d2ea4
commit 8183bba99a
4 changed files with 202 additions and 189 deletions

View File

@@ -14225,6 +14225,25 @@ AST_TEST_DEFINE(test_voicemail_vm_info)
}
#endif /* defined(TEST_FRAMEWORK) */
static const struct ast_vm_functions vm_table = {
.module_version = VM_MODULE_VERSION,
.module_name = AST_MODULE,
.has_voicemail = has_voicemail,
.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,
.mailbox_snapshot_destroy = vm_mailbox_snapshot_destroy,
.msg_move = vm_msg_move,
.msg_remove = vm_msg_remove,
.msg_forward = vm_msg_forward,
.msg_play = vm_msg_play,
};
static int reload(void)
{
return load_config(1);
@@ -14254,7 +14273,7 @@ static int unload_module(void)
res |= AST_TEST_UNREGISTER(test_voicemail_vm_info);
#endif
ast_cli_unregister_multiple(cli_voicemail, ARRAY_LEN(cli_voicemail));
ast_uninstall_vm_functions();
ast_vm_unregister(vm_table.module_name);
#ifdef TEST_FRAMEWORK
ast_uninstall_vm_test_functions();
#endif
@@ -14321,17 +14340,13 @@ static int load_module(void)
res |= AST_TEST_REGISTER(test_voicemail_vm_info);
#endif
res |= ast_vm_register(&vm_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));
ast_install_vm_functions(has_voicemail, inboxcount, inboxcount2, messagecount, sayname, msg_create_from_file,
vm_index_to_foldername,
vm_mailbox_snapshot_create, vm_mailbox_snapshot_destroy,
vm_msg_move, vm_msg_remove, vm_msg_forward, vm_msg_play);
#ifdef TEST_FRAMEWORK
ast_install_vm_test_functions(vm_test_create_user, vm_test_destroy_user);
#endif