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;
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))) {
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);
+ }
}
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);
}
return profile;
}
+void free_profile(vmivr_profile_t *profile) {
+ if (profile->event_settings) {
+ switch_event_destroy(&profile->event_settings);
+ }
+}