]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
mod_voicemail_ivr: Additional change for settings support.
authorMarc Olivier Chouinard <mochouinard@moctel.com>
Sun, 25 Dec 2011 18:37:23 +0000 (13:37 -0500)
committerMarc Olivier Chouinard <mochouinard@moctel.com>
Sun, 25 Dec 2011 18:37:23 +0000 (13:37 -0500)
src/mod/applications/mod_voicemail_ivr/config.c
src/mod/applications/mod_voicemail_ivr/config.h
src/mod/applications/mod_voicemail_ivr/mod_voicemail_ivr.c

index 63304d2ebe439cfdc312fc00b98431b2a35d743b..33be76e9e70e282df892dbf53b1ac23951c3ec9a 100644 (file)
@@ -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);
+       }
+}
index a78dc6304025e34a16ceda67fb40ff63db638a47..de5fb51609384c6cec85be2c3e01c48d6b452280 100644 (file)
@@ -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);
index a576b45536380a838d686030011a23d9ee60e89d..51bfa6a52109febd15f1d2980f7d0a2763581df7 100644 (file)
@@ -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);
                        }