summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorclaiff <claiff@mail.ru>2022-09-20 16:05:35 +0300
committerclaiff <claiff@mail.ru>2022-09-20 16:05:35 +0300
commita282ae6418c85db1aae5a2823dd37d56e56e5249 (patch)
tree00fb2677007f87b5572d088d0421e3075291f8ac
parent7485f26f35c9cfc1489a2e425fee57a2b51059a9 (diff)
downloadobmc-sila-smtp-a282ae6418c85db1aae5a2823dd37d56e56e5249.tar.xz
temp
-rw-r--r--CMakeLists.txt14
-rw-r--r--src/logger/logger_set.cpp5
-rw-r--r--src/logger/phosphor.cpp6
-rw-r--r--src/message/sender.hpp48
-rw-r--r--src/service/smtp.cpp18
-rw-r--r--src/service/smtp.hpp12
6 files changed, 53 insertions, 50 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e3e2153..56bc523 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -86,7 +86,6 @@ else()
find_package (PkgConfig REQUIRED)
pkg_check_modules (LOGGING phosphor-logging REQUIRED)
-
endif()
include_directories(src)
@@ -169,10 +168,6 @@ endif()
add_executable(${PROJECT_NAME} ${SRC_FILES} ${PHOSPHOR_LOGGING_FILES})
-target_compile_definitions (
- ${PROJECT_NAME} PRIVATE $<$<BOOL:${ADD_JOURNAL_LOGGING}>: -DADD_JOURNAL_LOGGING>
-)
-
if(NOT ${YOCTO_DEPENDENCIES})
add_dependencies(${PROJECT_NAME} sdbusplus-project)
elseif(${ADD_PHOSPHOR_LOGGING})
@@ -187,3 +182,12 @@ target_link_libraries(${PROJECT_NAME} curl)
install(TARGETS ${PROJECT_NAME} DESTINATION bin)
install(FILES ${PROJECT_SOURCE_DIR}/xyz.openbmc_project.SMTP.service
DESTINATION /lib/systemd/system/)
+
+target_compile_definitions (
+ ${PROJECT_NAME} PRIVATE $<$<BOOL:${ADD_JOURNAL_LOGGING}>: -DADD_JOURNAL_LOGGING>
+
+)
+
+target_compile_definitions (
+ ${PROJECT_NAME} PRIVATE $<$<BOOL:${ADD_PHOSPHOR_LOGGING}>: -DADD_PHOSPHOR_LOGGING>
+)
diff --git a/src/logger/logger_set.cpp b/src/logger/logger_set.cpp
index 8a061ed..6ea6d58 100644
--- a/src/logger/logger_set.cpp
+++ b/src/logger/logger_set.cpp
@@ -1,6 +1,7 @@
#include "logger_set.hpp"
#include "journal.hpp"
-
+#include "phosphor.hpp"
+#include <iostream>
namespace smtp::logger
{
std::shared_ptr < LoggerSet > LoggerSet::mInstance = nullptr;
@@ -27,7 +28,7 @@ namespace smtp::logger
loggers.push_back( std::make_shared < Journal >());
#endif
#ifdef ADD_PHOSPHOR_LOGGING
- loggers.push_back( std::make_shared < Journal >());
+ loggers.push_back( std::make_shared < Phosphor >());
#endif
mInstance.reset( new LoggerSet( loggers ));
}
diff --git a/src/logger/phosphor.cpp b/src/logger/phosphor.cpp
index 48bb49e..d3c81b0 100644
--- a/src/logger/phosphor.cpp
+++ b/src/logger/phosphor.cpp
@@ -1,4 +1,6 @@
#include <phosphor-logging/elog-errors.hpp>
+#include <phosphor-logging/elog.hpp>
+#include <xyz/openbmc_project/Common/error.hpp>
#include "phosphor.hpp"
@@ -6,6 +8,8 @@ namespace smtp::logger
{
void Phosphor::LogError( std::string const& message ) const
{
- phosphor::logging::log < phosphor::logging::level::ERR >( message.c_str());
+ using InternalFailure =
+ sdbusplus::xyz::openbmc_project::Common::Error::InternalFailure;
+ phosphor::logging::commit<InternalFailure>(message);
}
} \ No newline at end of file
diff --git a/src/message/sender.hpp b/src/message/sender.hpp
index ca2c3ff..d19e209 100644
--- a/src/message/sender.hpp
+++ b/src/message/sender.hpp
@@ -7,32 +7,32 @@
#include "managment/settings.hpp"
#include "managment/mail.hpp"
+
namespace smtp::message
{
- struct WriteThis
- {
- int counter;
- };
-
- class Sender
- {
- public:
- Sender( manage::Settings& settings_storage, manage::Mail const& mail_to );
- ~Sender() = default;
-
- bool Send( std::string const& mail_from, std::string const& subject, std::string const& text );
- private:
- void UpdateMailText( std::string const& mail_from, std::string const& subject, std::string const& textt ) const;
- void InitSenders( std::string const& mail_from, std::list<std::string> const& mail_to );
- void FillRecipients(CURL* curl, curl_slist* recipients );
- std::string GetHostPortData() const;
- static size_t ReadCallBack( void *ptr, size_t size, size_t nmemb, void *userp );
-
- manage::Settings& mSettingsStorage;
- manage::Mail const& mMailTo;
-
- bool InitCurl( CURL* curl, WriteThis const& upload_ctx, std::string const& mail_from );
- };
+ struct WriteThis
+ {
+ int counter;
+ };
+
+ class Sender
+ {
+ public:
+ Sender( manage::Settings& settings_storage, manage::Mail const& mail_to );
+ ~Sender() = default;
+
+ bool Send( std::string const& mail_from, std::string const& subject, std::string const& text );
+ private:
+ void UpdateMailText( std::string const& mail_from, std::string const& subject, std::string const& textt ) const;
+ void FillRecipients( CURL* curl, curl_slist* recipients );
+ std::string GetHostPortData() const;
+ static size_t ReadCallBack( void* ptr, size_t size, size_t nmemb, void* userp );
+
+ manage::Settings& mSettingsStorage;
+ manage::Mail const& mMailTo;
+
+ bool InitCurl( CURL* curl, WriteThis const& upload_ctx, std::string const& mail_from );
+ };
}
diff --git a/src/service/smtp.cpp b/src/service/smtp.cpp
index 702de2d..7b1ca70 100644
--- a/src/service/smtp.cpp
+++ b/src/service/smtp.cpp
@@ -11,7 +11,7 @@ namespace smtp::service
:mSettingsStorage(settings), mMailTo(mail_to)
{
CreateService( connection );
- CreateMessagerInterface( connection );
+ CreateMessengerInterface( connection );
CreateSettingsManagerInterface( connection );
CreateMailManagerInterface( connection );
}
@@ -27,17 +27,17 @@ namespace smtp::service
connection->request_name( SMTP_BUS_NAME );
}
- void Smtp::CreateMessagerInterface( ConnectionPtr connection )
+ void Smtp::CreateMessengerInterface( ConnectionPtr connection )
{
static constexpr char SMTP_OBJECT_NAME[] = "/xyz/openbmc_project/SMTP/Messenger";
static constexpr char SMTP_INTERFACE_NAME[] = "xyz.openbmc_project.Messenger";
mObjectServer = std::make_shared<sdbusplus::asio::object_server>( connection );
- mMessagerInterface = mObjectServer->add_interface( SMTP_OBJECT_NAME, SMTP_INTERFACE_NAME );
+ mMessengerInterface = mObjectServer->add_interface( SMTP_OBJECT_NAME, SMTP_INTERFACE_NAME );
- AddMessagerMethods();
+ AddMessengerMethods();
- mMessagerInterface->initialize();
+ mMessengerInterface->initialize();
}
void Smtp::CreateSettingsManagerInterface(ConnectionPtr connection)
@@ -66,13 +66,13 @@ namespace smtp::service
mManagerMailInterface->initialize();
}
- void Smtp::AddMessagerMethods()
+ void Smtp::AddMessengerMethods()
{
static constexpr char SMTP_SEND_MESSAGE_METHOD_NAME[] = "SendMail";
- mMessagerInterface->register_method(SMTP_SEND_MESSAGE_METHOD_NAME, [this]( std::string const& mail_from,
- std::string const& theme,
- std::string const& text )
+ mMessengerInterface->register_method( SMTP_SEND_MESSAGE_METHOD_NAME, [this]( std::string const& mail_from,
+ std::string const& theme,
+ std::string const& text )
{ return message::Sender{ mSettingsStorage, mMailTo }.Send( mail_from, theme, text );});
}
diff --git a/src/service/smtp.hpp b/src/service/smtp.hpp
index a52c9c0..edf964e 100644
--- a/src/service/smtp.hpp
+++ b/src/service/smtp.hpp
@@ -20,21 +20,15 @@ namespace smtp::service
Smtp( ConnectionPtr connection, manage::Settings const& settings, manage::Mail const& mail_to );
~Smtp() = default;
private:
- void FillStorageByDefault();
void CreateService( ConnectionPtr bus );
- void CreateMessagerInterface( ConnectionPtr connection );
+ void CreateMessengerInterface( ConnectionPtr connection );
void CreateSettingsManagerInterface( ConnectionPtr connection );
void CreateMailManagerInterface( ConnectionPtr connection );
- void AddProperties();
- void AddMessagerMethods();
+ void AddMessengerMethods();
void AddSettingsManagerMethods();
void AddMailManagerMethods();
- bool RefreshSettings( bool is_need_auth, bool is_need_ssl,
- std::string const& user, std::string const& password,
- std::string const& host, std::string const& port );
-
- InterfacePtr mMessagerInterface;
+ InterfacePtr mMessengerInterface;
InterfacePtr mManagerSettingsInterface;
InterfacePtr mManagerMailInterface;