From f78293531000cdbf366e938b54ac986d73b2d8d8 Mon Sep 17 00:00:00 2001 From: claiff Date: Tue, 20 Sep 2022 12:42:33 +0300 Subject: fix problem with boolean settings --- .../interfaces/bmcweb/0017-update-smtp.patch | 124 ++++++--------------- .../meta-cp2-5422/recipes-support/smtp/smtp.bb | 10 +- 2 files changed, 41 insertions(+), 93 deletions(-) diff --git a/meta-ibs/meta-cp2-5422/recipes-phosphor/interfaces/bmcweb/0017-update-smtp.patch b/meta-ibs/meta-cp2-5422/recipes-phosphor/interfaces/bmcweb/0017-update-smtp.patch index 33ffdfd7b8..bddd20eb58 100644 --- a/meta-ibs/meta-cp2-5422/recipes-phosphor/interfaces/bmcweb/0017-update-smtp.patch +++ b/meta-ibs/meta-cp2-5422/recipes-phosphor/interfaces/bmcweb/0017-update-smtp.patch @@ -1,20 +1,21 @@ -From 6f909553ae9526dea232731e440b2ae4d844e000 Mon Sep 17 00:00:00 2001 +From bca2ba057ca525a92d4370b2b287263c19bb20ea Mon Sep 17 00:00:00 2001 From: claiff Date: Fri, 16 Sep 2022 12:15:45 +0300 Subject: [PATCH] update smtp +Signed-off-by: claiff --- meson.build | 4 +- - .../include/utils/smtp/add_mails_parser.hpp | 22 ++ - .../utils/smtp/delete_mails_parser.hpp | 22 ++ + .../include/utils/smtp/add_mails_parser.hpp | 22 +++ + .../utils/smtp/delete_mails_parser.hpp | 22 +++ ...ers_parser.hpp => set_settings_parser.hpp} | 10 +- - redfish-core/lib/smtp.hpp | 226 +++++++++++++++--- - .../src/utils/smtp/add_mails_parser.cpp | 22 ++ - .../utils/smtp/change_parameters_parser.cpp | 62 ----- - .../src/utils/smtp/delete_mails_parser.cpp | 23 ++ - .../src/utils/smtp/set_settings_parser.cpp | 96 ++++++++ + redfish-core/lib/smtp.hpp | 184 ++++++++++++++---- + .../src/utils/smtp/add_mails_parser.cpp | 22 +++ + .../utils/smtp/change_parameters_parser.cpp | 62 ------ + .../src/utils/smtp/delete_mails_parser.cpp | 23 +++ + .../src/utils/smtp/set_settings_parser.cpp | 88 +++++++++ redfish-core/ut/smtp_reader_parser_test.cpp | 6 +- - 10 files changed, 387 insertions(+), 106 deletions(-) + 10 files changed, 335 insertions(+), 108 deletions(-) create mode 100644 redfish-core/include/utils/smtp/add_mails_parser.hpp create mode 100644 redfish-core/include/utils/smtp/delete_mails_parser.hpp rename redfish-core/include/utils/smtp/{change_parameters_parser.hpp => set_settings_parser.hpp} (63%) @@ -24,7 +25,7 @@ Subject: [PATCH] update smtp create mode 100644 redfish-core/src/utils/smtp/set_settings_parser.cpp diff --git a/meson.build b/meson.build -index c1d253fb..d7ce2c44 100644 +index 7e01c9df..2f204764 100644 --- a/meson.build +++ b/meson.build @@ -376,7 +376,9 @@ srcfiles_bmcweb = [ @@ -132,12 +133,15 @@ index ee18b57b..46db143a 100644 }; } diff --git a/redfish-core/lib/smtp.hpp b/redfish-core/lib/smtp.hpp -index 1bd798f7..dd49f982 100644 +index 1bd798f7..49ac9340 100644 --- a/redfish-core/lib/smtp.hpp +++ b/redfish-core/lib/smtp.hpp -@@ -5,17 +5,24 @@ - #include +@@ -2,20 +2,25 @@ + #include + #include +-#include +- #include "utils/smtp/send_message_parser.hpp" -#include "utils/smtp/change_parameters_parser.hpp" +#include "utils/smtp/set_settings_parser.hpp" @@ -164,7 +168,7 @@ index 1bd798f7..dd49f982 100644 { static constexpr char FIRST_DELIMITER = '&'; static constexpr int ZERO_POSITION = 0; -@@ -23,15 +30,19 @@ namespace redfish +@@ -23,7 +28,7 @@ namespace redfish auto position = function_with_parameters.find(FIRST_DELIMITER); if( position == std::string::npos ) { @@ -173,20 +177,7 @@ index 1bd798f7..dd49f982 100644 } return function_with_parameters.substr( ZERO_POSITION, position ); } - - inline void SendMail( std::string const& function_with_parameters, std::shared_ptr const& asyncResp ) - { -+ std::cout << "SendMail" << std::endl; - auto parsing_result = parser::SendMessage{function_with_parameters}; -- -+ std::cout << "GetMethodName" << parsing_result.GetMethodName() << std::endl; -+ std::cout << "GetFrom" << parsing_result.GetFrom() << std::endl; -+ std::cout << "GetSubject" << parsing_result.GetSubject() << std::endl; -+ std::cout << "GetText" << parsing_result.GetText() << std::endl; - crow::connections::systemBus->async_method_call([asyncResp](const boost::system::error_code& error_code, bool result){ - if (error_code.value() == EBADR || - error_code == boost::system::errc::host_unreachable) -@@ -48,19 +59,24 @@ namespace redfish +@@ -48,18 +53,16 @@ namespace redfish } asyncResp->res.jsonValue["result"] = result; }, @@ -204,20 +195,11 @@ index 1bd798f7..dd49f982 100644 + inline void SetSettings( std::string const& function_with_parameters, std::shared_ptr const& asyncResp ) { - auto parsing_result = parser::ChangeParameters{function_with_parameters}; -- -+ std::cout << "SetSettings" << std::endl; + auto parsing_result = parser::SetSettings{function_with_parameters}; -+ std::cout << "GetMethodName" << parsing_result.GetMethodName() << std::endl; -+ std::cout << "GetIsNeedAuth" << parsing_result.GetIsNeedAuth() << std::endl; -+ std::cout << "GetIsNeedSsl" << parsing_result.GetIsNeedSsl() << std::endl; -+ std::cout << "GetUser" << parsing_result.GetUser() << std::endl; -+ std::cout << "GetPassword" << parsing_result.GetPassword() << std::endl; -+ std::cout << "GetHost" << parsing_result.GetHost() << std::endl; -+ std::cout << "GetPort" << parsing_result.GetPort() << std::endl; + crow::connections::systemBus->async_method_call([asyncResp](const boost::system::error_code& error_code, bool result){ if (error_code.value() == EBADR || - error_code == boost::system::errc::host_unreachable) -@@ -77,13 +93,129 @@ namespace redfish +@@ -77,13 +80,114 @@ namespace redfish } asyncResp->res.jsonValue["result"] = result; }, @@ -234,7 +216,6 @@ index 1bd798f7..dd49f982 100644 + + inline void GetSettings( std::shared_ptr const& asyncResp ) + { -+ std::cout << "GetSettings" << std::endl; + crow::connections::systemBus->async_method_call([asyncResp](const boost::system::error_code& error_code, std::string const& result ){ + if (error_code.value() == EBADR || + error_code == boost::system::errc::host_unreachable) @@ -249,7 +230,6 @@ index 1bd798f7..dd49f982 100644 + std::cout << "respHandler DBus error" << std::endl; + return; + } -+ std::cout << "result" << std::endl; + auto parsing_result = parser::SetSettings{result}; + asyncResp->res.jsonValue["host"] = parsing_result.GetHost(); + asyncResp->res.jsonValue["is_need_auth"] = parsing_result.GetIsNeedAuth(); @@ -264,7 +244,6 @@ index 1bd798f7..dd49f982 100644 + + inline void GetMails( std::shared_ptr const& asyncResp ) + { -+ std::cout << "GetMails" << std::endl; + crow::connections::systemBus->async_method_call([asyncResp](const boost::system::error_code& error_code, std::list const& mails){ + if (error_code.value() == EBADR || + error_code == boost::system::errc::host_unreachable) @@ -287,13 +266,7 @@ index 1bd798f7..dd49f982 100644 + + inline void AddMails( std::string const& function_with_parameters, std::shared_ptr const& asyncResp ) + { -+ std::cout << "AddMails" << std::endl; + auto parsing_result = parser::AddMails{function_with_parameters}; -+ std::cout << "parsing_result.GetMethodName() " << parsing_result.GetMethodName() << std::endl; -+ for(const auto& mail : parsing_result.GetMails()) -+ { -+ std::cout << "parsing_result.GetMails() " << mail << std::endl; -+ } + + crow::connections::systemBus->async_method_call([asyncResp](const boost::system::error_code& error_code, bool result){ + if (error_code.value() == EBADR || @@ -318,13 +291,7 @@ index 1bd798f7..dd49f982 100644 + + inline void DeleteMails( std::string const& function_with_parameters, std::shared_ptr const& asyncResp ) + { -+ std::cout << "DeleteMails" << std::endl; + auto parsing_result = parser::DeleteMails{function_with_parameters}; -+ std::cout << "parsing_result.GetMethodName()" << parsing_result.GetMethodName() << std::endl; -+ for(const auto& mail : parsing_result.GetDeleteMails()) -+ { -+ std::cout << "parsing_result.GetDeleteMails() " << mail << std::endl; -+ } + crow::connections::systemBus->async_method_call([asyncResp](const boost::system::error_code& error_code, bool result){ + if (error_code.value() == EBADR || + error_code == boost::system::errc::host_unreachable) @@ -348,10 +315,11 @@ index 1bd798f7..dd49f982 100644 } inline void FillResp(crow::Response& resp, const dbus::utility::DBusPropertiesMap& properties) -@@ -130,23 +262,23 @@ namespace redfish +@@ -129,24 +233,6 @@ namespace redfish + { return; } - +- - crow::connections::systemBus->async_method_call([asyncResp](const boost::system::error_code& error_code, - const dbus::utility::DBusPropertiesMap& properties) - { @@ -361,33 +329,18 @@ index 1bd798f7..dd49f982 100644 - messages::internalError(asyncResp->res); - return; - } -+// crow::connections::systemBus->async_method_call([asyncResp](const boost::system::error_code& error_code, -+// const dbus::utility::DBusPropertiesMap& properties) -+// { -+// if (error_code) -+// { -+// BMCWEB_LOG_DEBUG << "DBUS response error " << error_code; -+// messages::internalError(asyncResp->res); -+// return; -+// } - +- - FillResp(asyncResp->res, properties); - }, SERVICE_PATH, OBJECT_PATH, "org.freedesktop.DBus.Properties", - "GetAll", "xyz.openbmc_project.SMTP"); -+// FillResp(asyncResp->res, properties); -+// }, SERVICE_PATH, OBJECT_PATH, "org.freedesktop.DBus.Properties", -+// "GetAll", "xyz.openbmc_project.SMTP"); - +- - asyncResp->res.jsonValue["@odata.type"] ="#SmtpCollection"; - asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Smtp"; - asyncResp->res.jsonValue["Name"] = "Smtp Collection"; -+// asyncResp->res.jsonValue["@odata.type"] ="#SmtpCollection"; -+// asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Smtp"; -+// asyncResp->res.jsonValue["Name"] = "Smtp Collection"; }); } -@@ -162,29 +294,47 @@ namespace redfish +@@ -162,29 +248,47 @@ namespace redfish const std::string& function_with_parameters) { static constexpr std::string_view SEND_MAIL_METHOD_NAME = "SendMail"; @@ -414,9 +367,8 @@ index 1bd798f7..dd49f982 100644 - asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Smtp/" + *function_name; + asyncResp->res.jsonValue["@odata.id"] = "/redfish/v1/Smtp/" + function_name; asyncResp->res.jsonValue["Name"] = "Smtp Collection"; -- + - if(*function_name == SEND_MAIL_METHOD_NAME) -+ std::cout << "function_name " << function_name << std::endl; + if(function_name == SEND_MAIL_METHOD_NAME) { smtp::SendMail(function_with_parameters, asyncResp); @@ -572,10 +524,10 @@ index 00000000..ead3bbfb +} diff --git a/redfish-core/src/utils/smtp/set_settings_parser.cpp b/redfish-core/src/utils/smtp/set_settings_parser.cpp new file mode 100644 -index 00000000..d5071b05 +index 00000000..d184b183 --- /dev/null +++ b/redfish-core/src/utils/smtp/set_settings_parser.cpp -@@ -0,0 +1,96 @@ +@@ -0,0 +1,88 @@ +#include "utils/smtp/set_settings_parser.hpp" +#include + @@ -585,17 +537,9 @@ index 00000000..d5071b05 + { + static const std::string DELIMITER_ON_LINE = "&"; + auto parsed_data = ParseLine(function_with_parameters, DELIMITER_ON_LINE); -+ std::cout << "aaaa" <