diff --git a/src/mod/applications/mod_voicemail_ivr/config.c b/src/mod/applications/mod_voicemail_ivr/config.c index 63304d2ebe..33be76e9e7 100644 --- a/src/mod/applications/mod_voicemail_ivr/config.c +++ b/src/mod/applications/mod_voicemail_ivr/config.c @@ -38,8 +38,6 @@ const char *global_cf = "voicemail_ivr.conf"; void populate_profile_menu_event(vmivr_profile_t *profile, vmivr_menu_profile_t *menu) { switch_xml_t cfg, xml, x_profiles, x_profile, x_keys, x_phrases, x_menus, x_menu, x_settings; - free_profile_menu_event(menu); - if (!(xml = switch_xml_open_cfg(global_cf, &cfg, NULL))) { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Open of %s failed\n", global_cf); goto end; @@ -48,10 +46,18 @@ void populate_profile_menu_event(vmivr_profile_t *profile, vmivr_menu_profile_t goto end; } - if (profile->event_settings) { + if (profile->event_settings && menu->event_settings) { + /* TODO Replace this with a switch_event_merge_not_set(...) */ + switch_event_t *menu_default; + switch_event_create(&menu_default, SWITCH_EVENT_REQUEST_PARAMS); + switch_event_merge(menu_default, menu->event_settings); + switch_event_destroy(&menu->event_settings); + switch_event_create(&menu->event_settings, SWITCH_EVENT_REQUEST_PARAMS); - switch_event_merge(menu->event_settings, profile->event_settings); - } + switch_event_merge(menu->event_settings, profile->event_settings); + switch_event_merge(menu->event_settings, menu_default); + switch_event_destroy(&menu_default); + } if ((x_profile = switch_xml_find_child(x_profiles, "profile", "name", profile->name))) { @@ -93,9 +99,9 @@ void free_profile_menu_event(vmivr_menu_profile_t *menu) { if (menu->event_phrases) { switch_event_destroy(&menu->event_phrases); } - if (menu->event_settings) { - switch_event_destroy(&menu->event_settings); - } + if (menu->event_settings) { + switch_event_destroy(&menu->event_settings); + } } @@ -132,6 +138,8 @@ vmivr_profile_t *get_profile(switch_core_session_t *session, const char *profile profile->menu_check_main = "std_main_menu"; profile->menu_check_terminate = "std_purge"; + /* TODO Create event_settings and add default settings here */ + if ((x_settings = switch_xml_child(x_profile, "settings"))) { switch_event_import_xml(switch_xml_child(x_settings, "param"), "name", "value", &profile->event_settings); } @@ -184,3 +192,8 @@ end: return profile; } +void free_profile(vmivr_profile_t *profile) { + if (profile->event_settings) { + switch_event_destroy(&profile->event_settings); + } +} diff --git a/src/mod/applications/mod_voicemail_ivr/config.h b/src/mod/applications/mod_voicemail_ivr/config.h index a78dc63040..de5fb51609 100644 --- a/src/mod/applications/mod_voicemail_ivr/config.h +++ b/src/mod/applications/mod_voicemail_ivr/config.h @@ -87,6 +87,7 @@ struct vmivr_menu_profile { typedef struct vmivr_menu_profile vmivr_menu_profile_t; vmivr_profile_t *get_profile(switch_core_session_t *session, const char *profile_name); +void free_profile(vmivr_profile_t *profile); void free_profile_menu_event(vmivr_menu_profile_t *menu); void populate_profile_menu_event(vmivr_profile_t *profile, vmivr_menu_profile_t *menu); diff --git a/src/mod/applications/mod_voicemail_ivr/mod_voicemail_ivr.c b/src/mod/applications/mod_voicemail_ivr/mod_voicemail_ivr.c index a576b45536..51bfa6a521 100644 --- a/src/mod/applications/mod_voicemail_ivr/mod_voicemail_ivr.c +++ b/src/mod/applications/mod_voicemail_ivr/mod_voicemail_ivr.c @@ -93,7 +93,9 @@ SWITCH_STANDARD_APP(voicemail_ivr_function) } if (fPtrTerminate) { fPtrTerminate(session, profile); - } + } + free_profile(profile); + } else { switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Profile '%s' not found\n", profile_name); }