rtmp-services: Preserve settings if service renamed

Due to the recent renaming of hitbox to smashcast, old settings for
hitbox would not be shown in the service UI.  This change preserves the
user's service settings even if the service name has been changed, shows
the setting and marks it as invalid to the user, and prevents the UI
from selecting a value that doesn't match the user's last selection.
This commit is contained in:
jp9000 2017-05-19 01:14:57 -07:00
parent eb7fb990b7
commit 13c59ef18c

View File

@ -111,6 +111,8 @@ static void add_service(obs_property_t *list, json_t *service, bool show_all,
obs_property_list_add_string(list, name, name);
}
static inline json_t *find_service(json_t *root, const char *name);
static void add_services(obs_property_t *list, json_t *root, bool show_all,
const char *cur_service)
{
@ -126,6 +128,13 @@ static void add_services(obs_property_t *list, json_t *root, bool show_all,
json_array_foreach (root, index, service) {
add_service(list, service, show_all, cur_service);
}
service = find_service(root, cur_service);
if (!service && cur_service && *cur_service) {
obs_property_list_insert_string(list, 0, cur_service,
cur_service);
obs_property_list_item_disable(list, 0, true);
}
}
static json_t *open_json_file(const char *file)
@ -263,12 +272,20 @@ static bool service_selected(obs_properties_t *props, obs_property_t *p,
return false;
service = find_service(root, name);
if (!service)
return false;
if (!service) {
const char *server = obs_data_get_string(settings, "server");
obs_property_list_insert_string(p, 0, name, name);
obs_property_list_item_disable(p, 0, true);
p = obs_properties_get(props, "server");
obs_property_list_insert_string(p, 0, server, server);
obs_property_list_item_disable(p, 0, true);
return true;
}
fill_servers(obs_properties_get(props, "server"), service, name);
UNUSED_PARAMETER(p);
return true;
}