[Freeswitch-branches] [commit] r10847 - freeswitch/branches/cseket/src/mod/applications/mod_voicemail

FreeSWITCH SVN cseket at freeswitch.org
Wed Dec 17 02:17:08 PST 2008


Author: cseket
Date: Wed Dec 17 05:17:07 2008
New Revision: 10847

Log:
MODAPP-177

Modified:
   freeswitch/branches/cseket/src/mod/applications/mod_voicemail/mod_voicemail.c

Modified: freeswitch/branches/cseket/src/mod/applications/mod_voicemail/mod_voicemail.c
==============================================================================
--- freeswitch/branches/cseket/src/mod/applications/mod_voicemail/mod_voicemail.c	(original)
+++ freeswitch/branches/cseket/src/mod/applications/mod_voicemail/mod_voicemail.c	Wed Dec 17 05:17:07 2008
@@ -51,7 +51,7 @@
 
 static switch_status_t voicemail_inject(const char *data);
 
-const char *global_cf = "voicemail.conf";
+static const char *global_cf = "voicemail.conf";
 static struct {
 	switch_hash_t *profile_hash;
 	int debug;
@@ -273,7 +273,6 @@
 		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", global_cf);
 		return profile;
 	}
-	
 	if (!(x_profiles = switch_xml_child(cfg, "profiles"))) {
 		goto end;
 	}
@@ -1666,12 +1665,11 @@
 #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)
+static void voicemail_check_main(switch_core_session_t *session, vm_profile_t *profile, const char *domain_name, const char *id, int auth)
 {
 	vm_check_state_t vm_check_state = VM_CHECK_START;
 	switch_channel_t *channel = switch_core_session_get_channel(session);
 	switch_caller_profile_t *caller_profile = switch_channel_get_caller_profile(channel);
-	vm_profile_t *profile;
 	switch_xml_t x_domain = NULL, x_domain_root = NULL, x_user = NULL, x_params, x_param;
 	switch_status_t status;
 	char pass_buf[80] = "", *mypass = NULL, id_buf[80] = "", *myfolder = NULL;
@@ -1692,7 +1690,7 @@
 	switch_input_args_t args = { 0 };
 	const char *caller_id_name = NULL;
 	const char *caller_id_number = NULL;
-	
+
 	if (!(caller_id_name = switch_channel_get_variable(channel, "effective_caller_id_name"))) {
 		caller_id_name = caller_profile->caller_id_name;
 	}
@@ -1701,11 +1699,6 @@
 		caller_id_number = caller_profile->caller_id_number;
 	}
 
-	if (!(profile = get_profile(profile_name))) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error invalid profile %s\n", profile_name);
-		return;
-	}
-
 	timeout = profile->digit_timeout;
 	attempts = profile->max_login_attempts;
 	status = switch_ivr_phrase_macro(session, VM_HELLO_MACRO, NULL, NULL, &args);
@@ -2216,8 +2209,6 @@
 
   end:
 
-	switch_thread_rwlock_unlock(profile->rwlock);
-
 	if (switch_channel_ready(channel)) {
 		if (failed) {
 			status = switch_ivr_phrase_macro(session, VM_ABORT_MACRO, NULL, NULL, NULL);
@@ -2681,12 +2672,11 @@
 	return status;
 }
 
-static switch_status_t voicemail_leave_main(switch_core_session_t *session, const char *profile_name, const char *domain_name, const char *id)
+static switch_status_t voicemail_leave_main(switch_core_session_t *session, vm_profile_t *profile, const char *domain_name, const char *id)
 {
 	switch_channel_t *channel = switch_core_session_get_channel(session);
 	char sql[256];
 	prefs_callback_t cbt;
-	vm_profile_t *profile;
 	char *uuid = switch_core_session_get_uuid(session);
 	char *file_path = NULL;
 	char *dir_path = NULL;
@@ -2732,11 +2722,6 @@
 
 	memset(&cbt, 0, sizeof(cbt));
 
-	if (!(profile = get_profile(profile_name))) {
-		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error invalid profile %s\n", profile_name);
- 		return SWITCH_STATUS_FALSE;;
-	}
-
 	if (id) {
 		int ok = 1;
 		switch_event_t *params = NULL;
@@ -2875,7 +2860,7 @@
 	if (*buf != '\0') {
 greet_key_press:
 		if (!strcasecmp(buf, profile->main_menu_key)) {
-			voicemail_check_main(session, profile_name, domain_name, id, 0);
+			voicemail_check_main(session, profile, domain_name, id, 0);
 		} else if (!strcasecmp(buf, profile->operator_key) && !switch_strlen_zero(profile->operator_key)) {
 			int argc;
 			char *argv[4];
@@ -2977,8 +2962,6 @@
 
  end:
 
-	switch_thread_rwlock_unlock(profile->rwlock);
-
 	if (x_domain_root) {
 		switch_xml_free(x_domain_root);
 		x_domain_root = NULL;
@@ -3002,6 +2985,7 @@
 	int argc = 0;
 	char *argv[6] = { 0 };
 	char *mydata = NULL;
+	vm_profile_t * profile = NULL;
 	const char *profile_name = NULL;
 	const char *domain_name = NULL;
 	const char *id = NULL;
@@ -3059,11 +3043,19 @@
 		return;
 	}
 
+	if (!(profile = get_profile(profile_name))) {
+		switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error invalid profile %s\n", profile_name);
+		return;
+	}
+
 	if (check) {
-		voicemail_check_main(session, profile_name, domain_name, id, auth);
+		voicemail_check_main(session, profile, domain_name, id, auth);
 	} else {
-		voicemail_leave_main(session, profile_name, domain_name, id);
+		voicemail_leave_main(session, profile, domain_name, id);
 	}
+
+	switch_thread_rwlock_unlock(profile->rwlock);
+	
 }
 
 #define BOXCOUNT_SYNTAX "<user>@<domain>[|[new|saved|new-urgent|saved-urgent|all]]"



More information about the Freeswitch-branches mailing list