}
+#define FREE_DOMAIN_ROOT() if (x_domain_root) switch_xml_free(x_domain_root); x_user = x_domain = x_domain_root = NULL
+
+
static void voicemail_check_main(switch_core_session_t *session, const char *profile_name, const char *domain_name, const char *id, int auth)
{
vm_check_state_t vm_check_state = VM_CHECK_START;
mypass = NULL;
myfolder = "inbox";
vm_check_state = VM_CHECK_AUTH;
- if (x_domain_root) {
- switch_xml_free(x_domain_root);
- }
- x_user = x_domain = x_domain_root = NULL;
+ FREE_DOMAIN_ROOT();
}
break;
case VM_CHECK_FOLDER_SUMMARY:
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "mailbox", myid);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "destination_number", caller_profile->destination_number);
switch_event_add_header_string(params, SWITCH_STACK_BOTTOM, "caller_id_number", caller_id_number);
-
-
+
+
if (switch_xml_locate_user("id", myid, domain_name, switch_channel_get_variable(channel, "network_addr"),
&x_domain_root, &x_domain, &x_user, params) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING, "can't find user [%s@%s]\n", myid, domain_name);
thepass = cbt.password;
}
}
- switch_xml_free(x_domain_root);
- x_domain_root = NULL;
if (!auth) {
if (switch_strlen_zero(cbt.password) && !strcmp(cbt.password, mypass)) {
}
}
+ FREE_DOMAIN_ROOT();
if (auth) {
if (!dir_path) {
if (switch_dir_make_recursive(dir_path, SWITCH_DEFAULT_DIR_PERMS, switch_core_session_get_pool(session)) != SWITCH_STATUS_SUCCESS) {
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error creating %s\n", dir_path);
- return;
+ goto end;
}
}
} else {
goto failed;
}
-
+
continue;
failed:
+
+ FREE_DOMAIN_ROOT();
+
status = switch_ivr_phrase_macro(session, VM_FAIL_AUTH_MACRO, NULL, NULL, NULL);
myid = id;
mypass = NULL;
if (x_domain_root) {
switch_xml_free(x_domain_root);
+ x_domain_root = NULL;
}
}
if (x_domain_root) {
switch_xml_free(x_domain_root);
+ x_domain_root = NULL;
}
switch_safe_free(file_path);