From ea352472e5f4d44eb403fdba4d5dd6ef62c74572 Mon Sep 17 00:00:00 2001 From: MrDave Date: Sat, 3 Jul 2021 21:15:56 -0600 Subject: [PATCH] User friendly parameter options for webcontrol_interface --- src/conf.cpp | 16 ++++++++-------- src/conf.hpp | 2 +- src/webu.cpp | 4 ++-- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/conf.cpp b/src/conf.cpp index 24e6a86a..a431a3b6 100644 --- a/src/conf.cpp +++ b/src/conf.cpp @@ -2160,21 +2160,21 @@ static void conf_edit_webcontrol_parms(struct ctx_cam *cam, std::string &parm, e static void conf_edit_webcontrol_interface(struct ctx_cam *cam, std::string &parm, enum PARM_ACT pact) { - int parm_in; if (pact == PARM_ACT_DFLT) { - cam->conf->webcontrol_interface = 0; + cam->conf->webcontrol_interface = "default"; } else if (pact == PARM_ACT_SET) { - parm_in = atoi(parm.c_str()); - if ((parm_in < 0) || (parm_in > 3)) { - MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid webcontrol_interface %d"),parm_in); + if ((parm == "default") || (parm == "user")) { + cam->conf->webcontrol_interface = parm; + } else if (parm == "") { + cam->conf->webcontrol_interface = "default"; } else { - cam->conf->webcontrol_interface = parm_in; + MOTION_LOG(NTC, TYPE_ALL, NO_ERRNO, _("Invalid webcontrol_interface %s"), parm.c_str()); } } else if (pact == PARM_ACT_GET) { - parm = std::to_string(cam->conf->webcontrol_interface); + parm = cam->conf->webcontrol_interface; } else if (pact == PARM_ACT_LIST) { parm = "["; - parm = parm + "\"0\",\"1\",\"2\",\"3\""; + parm = parm + "\"default\",\"user\""; parm = parm + "]"; } return; diff --git a/src/conf.hpp b/src/conf.hpp index 5ba56f07..5f488243 100644 --- a/src/conf.hpp +++ b/src/conf.hpp @@ -144,7 +144,7 @@ bool webcontrol_ipv6; bool webcontrol_localhost; int webcontrol_parms; - int webcontrol_interface; + std::string webcontrol_interface; int webcontrol_auth_method; std::string webcontrol_authentication; bool webcontrol_tls; diff --git a/src/webu.cpp b/src/webu.cpp index 02650667..fb0af077 100644 --- a/src/webu.cpp +++ b/src/webu.cpp @@ -697,7 +697,7 @@ static mhdrslt webu_answer_post(struct ctx_webui *webui) webu_post_main(webui); pthread_mutex_unlock(&webui->motapp->mutex_post); - if (webui->motapp->cam_list[0]->conf->webcontrol_interface == 3) { + if (webui->motapp->cam_list[0]->conf->webcontrol_interface == "user") { webu_html_user(webui); } else { webu_html_page(webui); @@ -822,7 +822,7 @@ static mhdrslt webu_answer_get(struct ctx_webui *webui) } else { pthread_mutex_lock(&webui->motapp->mutex_post); - if (webui->motapp->cam_list[0]->conf->webcontrol_interface == 3) { + if (webui->motapp->cam_list[0]->conf->webcontrol_interface == "user") { webu_html_user(webui); } else { webu_html_page(webui);