summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorclaiff <claiff@mail.ru>2022-09-19 14:03:14 +0300
committerclaiff <claiff@mail.ru>2022-09-21 14:28:10 +0300
commit7a446d48b9270dbe2628b462a54a7a23ff43c572 (patch)
tree8e677b755c3cb529a40ee17078828bc8cc73bf31
parent629929ebbe386277c25740bc0f4971aac38444d0 (diff)
downloadobmc-sila-smtp-7a446d48b9270dbe2628b462a54a7a23ff43c572.tar.xz
temp
-rw-r--r--CMakeLists.txt142
-rw-r--r--src/checker/errors/mail/empty.cpp9
-rw-r--r--src/checker/errors/mail/empty.hpp17
-rw-r--r--src/checker/errors/settings/host_number.cpp36
-rw-r--r--src/checker/errors/settings/host_number.hpp17
-rw-r--r--src/checker/errors/types/imails_error.hpp19
-rw-r--r--src/checker/errors/types/isettings_error.hpp22
-rw-r--r--src/checker/registrator_mails.cpp22
-rw-r--r--src/checker/registrator_mails.hpp19
-rw-r--r--src/checker/registrator_settings.hpp35
-rw-r--r--src/file/mail.cpp31
-rw-r--r--src/file/mail.hpp6
-rw-r--r--src/file/settings.cpp15
-rw-r--r--src/file/settings.hpp10
-rw-r--r--src/management/builder/mail.cpp23
-rw-r--r--src/management/builder/mail.hpp (renamed from src/managment/builder/mail.hpp)2
-rw-r--r--src/management/builder/settings.cpp29
-rw-r--r--src/management/builder/settings.hpp (renamed from src/managment/builder/settings.hpp)2
-rw-r--r--src/management/general.hpp (renamed from src/managment/general.hpp)0
-rw-r--r--src/management/logger.cpp (renamed from src/managment/logger.cpp)0
-rw-r--r--src/management/logger.hpp (renamed from src/managment/logger.hpp)0
-rw-r--r--src/management/mail.cpp71
-rw-r--r--src/management/mail.hpp30
-rw-r--r--src/management/settings.cpp (renamed from src/managment/settings.cpp)0
-rw-r--r--src/management/settings.hpp (renamed from src/managment/settings.hpp)0
-rw-r--r--src/managment/builder/mail.cpp14
-rw-r--r--src/managment/builder/settings.cpp18
-rw-r--r--src/managment/mail.cpp72
-rw-r--r--src/managment/mail.hpp28
29 files changed, 458 insertions, 231 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 11f62b1..6a1916b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -15,62 +15,60 @@ set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -Os -flto")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0")
if(NOT ${YOCTO_DEPENDENCIES})
- include(ExternalProject)
-
- ExternalProject_Add(
- Boost
- URL "https://boostorg.jfrog.io/artifactory/main/release/1.76.0/source/boost_1_76_0.tar.bz2"
- URL_MD5 "33334dd7f862e8ac9fe1cc7c6584fb6d"
- SOURCE_DIR ${CMAKE_BINARY_DIR}/src/boost
- BINARY_DIR ${CMAKE_BINARY_DIR}/libs/boost
- CONFIGURE_COMMAND cd <SOURCE_DIR> && ./bootstrap.sh
- BUILD_COMMAND cd <SOURCE_DIR> && ./b2 --exec-prefix=<BINARY_DIR>
- --prefix=<BINARY_DIR> --with-system --with-coroutine install
- INSTALL_COMMAND ""
- UPDATE_COMMAND "")
-
- set(CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/libs/boost/ ${CMAKE_PREFIX_PATH})
- include_directories(SYSTEM ${CMAKE_BINARY_DIR}/libs/boost/include)
- link_directories(SYSTEM ${CMAKE_BINARY_DIR}/libs/boost/lib)
-
- ExternalProject_Add(
- sdbusplus-project
- PREFIX ${CMAKE_BINARY_DIR}/sdbusplus-project
- GIT_REPOSITORY https://github.com/openbmc/sdbusplus.git
- GIT_TAG afe80cf2e5dc4aefe3b041adeb0230e61929bf12
- SOURCE_DIR ${CMAKE_BINARY_DIR}/sdbusplus-src
- BINARY_DIR ${CMAKE_BINARY_DIR}/sdbusplus-build
- CONFIGURE_COMMAND ""
- BUILD_COMMAND cd ${CMAKE_BINARY_DIR}/sdbusplus-src && ./bootstrap.sh &&
- ./configure --enable-transaction && make -j libsdbusplus.la
- INSTALL_COMMAND ""
- LOG_DOWNLOAD ON
- UPDATE_COMMAND "")
-
- include_directories(${CMAKE_BINARY_DIR}/sdbusplus-src)
- link_directories(${CMAKE_BINARY_DIR}/sdbusplus-src/.libs)
-
- # Boost related definitions
- add_definitions(-DBOOST_COROUTINES_NO_DEPRECATION_WARNING)
- add_definitions(-DBOOST_ERROR_CODE_HEADER_ONLY)
- add_definitions(-DBOOST_SYSTEM_NO_DEPRECATED)
- add_definitions(-DBOOST_ALL_NO_LIB)
- add_definitions(-DBOOST_NO_RTTI)
- add_definitions(-DBOOST_NO_TYPEID)
- add_definitions(-DBOOST_ASIO_DISABLE_THREADS)
+ include(ExternalProject)
+
+ ExternalProject_Add(
+ Boost
+ URL "https://boostorg.jfrog.io/artifactory/main/release/1.76.0/source/boost_1_76_0.tar.bz2"
+ URL_MD5 "33334dd7f862e8ac9fe1cc7c6584fb6d"
+ SOURCE_DIR ${CMAKE_BINARY_DIR}/src/boost
+ BINARY_DIR ${CMAKE_BINARY_DIR}/libs/boost
+ CONFIGURE_COMMAND cd <SOURCE_DIR> && ./bootstrap.sh
+ BUILD_COMMAND cd <SOURCE_DIR> && ./b2 --exec-prefix=<BINARY_DIR>
+ --prefix=<BINARY_DIR> --with-system --with-coroutine install
+ INSTALL_COMMAND ""
+ UPDATE_COMMAND ""
+ )
+
+ set(CMAKE_PREFIX_PATH ${CMAKE_BINARY_DIR}/libs/boost/ ${CMAKE_PREFIX_PATH})
+ include_directories(SYSTEM ${CMAKE_BINARY_DIR}/libs/boost/include)
+ link_directories(SYSTEM ${CMAKE_BINARY_DIR}/libs/boost/lib)
+
+ ExternalProject_Add(
+ sdbusplus-project
+ PREFIX ${CMAKE_BINARY_DIR}/sdbusplus-project
+ GIT_REPOSITORY https://github.com/openbmc/sdbusplus.git
+ GIT_TAG afe80cf2e5dc4aefe3b041adeb0230e61929bf12
+ SOURCE_DIR ${CMAKE_BINARY_DIR}/sdbusplus-src
+ BINARY_DIR ${CMAKE_BINARY_DIR}/sdbusplus-build
+ CONFIGURE_COMMAND ""
+ BUILD_COMMAND cd ${CMAKE_BINARY_DIR}/sdbusplus-src && ./bootstrap.sh &&
+ ./configure --enable-transaction && make -j libsdbusplus.la
+ INSTALL_COMMAND ""
+ LOG_DOWNLOAD ON
+ UPDATE_COMMAND ""
+ )
+
+ include_directories(${CMAKE_BINARY_DIR}/sdbusplus-src)
+ link_directories(${CMAKE_BINARY_DIR}/sdbusplus-src/.libs)
+
+ add_definitions(-DBOOST_COROUTINES_NO_DEPRECATION_WARNING)
+ add_definitions(-DBOOST_ERROR_CODE_HEADER_ONLY)
+ add_definitions(-DBOOST_SYSTEM_NO_DEPRECATED)
+ add_definitions(-DBOOST_ALL_NO_LIB)
+ add_definitions(-DBOOST_NO_RTTI)
+ add_definitions(-DBOOST_NO_TYPEID)
+ add_definitions(-DBOOST_ASIO_DISABLE_THREADS)
else()
- # Include Boost library. This allows specify exact version of BOOST to be
- # used, especially important while using valgrind, to point BOOST that is
- # compiled with valgrind support
- if(${BOOST_VERSION})
- find_package(Boost ${BOOST_VERSION} EXACT)
- else()
- find_package(Boost 1.69 REQUIRED COMPONENTS coroutine context)
- endif()
- message("++ Using Boost version: " ${Boost_VERSION})
-
- include_directories(${Boost_INCLUDE_DIRS})
- link_directories(${Boost_LIBRARY_DIRS})
+ if(${BOOST_VERSION})
+ find_package(Boost ${BOOST_VERSION} EXACT)
+ else()
+ find_package(Boost 1.69 REQUIRED COMPONENTS coroutine context)
+ endif()
+ message("++ Using Boost version: " ${Boost_VERSION})
+
+ include_directories(${Boost_INCLUDE_DIRS})
+ link_directories(${Boost_LIBRARY_DIRS})
endif()
include_directories(src)
@@ -78,11 +76,12 @@ include_directories(src)
set(SRC_DIR src)
set(MESSAGE_DIR src/message)
set(SERVICE_DIR src/service)
-set(MANAGMENT_DIR src/managment)
+set(MANAGEMENT_DIR src/management)
set(FILE_DIR src/file)
set(PARSER_DIR src/file/parser)
-set(MANAGER_BUILDER_DIR src/managment/builder)
+set(MANAGER_BUILDER_DIR src/management/builder)
set(CONVERTER_DIR src/converter)
+set(CHECKER_DIR src/checker)
set(SRC_FILES
${SRC_DIR}/main.cpp
@@ -108,13 +107,13 @@ set(SRC_FILES
${MESSAGE_DIR}/builder/types/imessage_builder.hpp
${MESSAGE_DIR}/builder/types/idecorator.hpp
- ${MANAGMENT_DIR}/mail.hpp
- ${MANAGMENT_DIR}/mail.cpp
- ${MANAGMENT_DIR}/settings.hpp
- ${MANAGMENT_DIR}/settings.cpp
- ${MANAGMENT_DIR}/logger.hpp
- ${MANAGMENT_DIR}/logger.cpp
- ${MANAGMENT_DIR}/general.hpp
+ ${MANAGEMENT_DIR}/mail.hpp
+ ${MANAGEMENT_DIR}/mail.cpp
+ ${MANAGEMENT_DIR}/settings.hpp
+ ${MANAGEMENT_DIR}/settings.cpp
+ ${MANAGEMENT_DIR}/logger.hpp
+ ${MANAGEMENT_DIR}/logger.cpp
+ ${MANAGEMENT_DIR}/general.hpp
${FILE_DIR}/mail.hpp
${FILE_DIR}/mail.cpp
@@ -137,12 +136,25 @@ set(SRC_FILES
${MANAGER_BUILDER_DIR}/settings.cpp
${MANAGER_BUILDER_DIR}/mail.hpp
${MANAGER_BUILDER_DIR}/mail.cpp
+
+ ${CHECKER_DIR}/registrator_mails.hpp
+ ${CHECKER_DIR}/registrator_mails.cpp
+ ${CHECKER_DIR}/registrator_settings.hpp
+
+ ${CHECKER_DIR}/errors/settings/host_number.cpp
+ ${CHECKER_DIR}/errors/settings/host_number.hpp
+ ${CHECKER_DIR}/errors/mail/empty.hpp
+ ${CHECKER_DIR}/errors/mail/empty.cpp
+
+ ${CHECKER_DIR}/errors/types/imails_error.hpp
+ ${CHECKER_DIR}/errors/types/isettings_error.hpp
)
add_executable(smtp ${SRC_FILES})
if(NOT ${YOCTO_DEPENDENCIES})
- add_dependencies(smtp sdbusplus-project)
+ add_dependencies(smtp sdbusplus-project)
endif()
+
target_link_libraries(smtp boost_context)
target_link_libraries(smtp sdbusplus)
target_link_libraries(smtp systemd)
diff --git a/src/checker/errors/mail/empty.cpp b/src/checker/errors/mail/empty.cpp
new file mode 100644
index 0000000..06f6f4c
--- /dev/null
+++ b/src/checker/errors/mail/empty.cpp
@@ -0,0 +1,9 @@
+#include "empty.hpp"
+
+namespace smtp::checker::errors::settings
+{
+ bool Empty::Check( std::string const& line ) const
+ {
+ return !line.empty();
+ }
+}
diff --git a/src/checker/errors/mail/empty.hpp b/src/checker/errors/mail/empty.hpp
new file mode 100644
index 0000000..9e8c0da
--- /dev/null
+++ b/src/checker/errors/mail/empty.hpp
@@ -0,0 +1,17 @@
+#pragma once
+
+#include "checker/errors/types/imails_error.hpp"
+
+namespace smtp::checker::errors::settings
+{
+ class Empty : public types::IError
+ {
+ public:
+ Empty() = default;
+ ~Empty() override = default;
+
+ bool Check( std::string const& line ) const override;
+ };
+}
+
+
diff --git a/src/checker/errors/settings/host_number.cpp b/src/checker/errors/settings/host_number.cpp
new file mode 100644
index 0000000..3580265
--- /dev/null
+++ b/src/checker/errors/settings/host_number.cpp
@@ -0,0 +1,36 @@
+#include "host_number.hpp"
+#include "managment/logger.hpp"
+#include <stdexcept>
+namespace smtp::checker::errors::settings
+{
+ bool HostNumber::Check( const manage::SettingsFileDataType& line ) const
+ {
+ //TODO общее использование полей
+ auto find = line.find("host");
+ if(find == line.end())
+ {
+ manage::Logger::LogError("Host doesn't found");
+ return false;
+ }
+ int host_as_int{};
+ auto host_as_string = find->second;
+ if(host_as_string.empty())
+ {
+ return true;
+ }
+
+ try
+ {
+ host_as_int = std::stoi( host_as_string );
+ }
+ catch( std::invalid_argument const& ex )
+ {
+ manage::Logger::LogError("Host doesn't entered by numbers");
+ }
+ catch( std::out_of_range const& ex )
+ {
+ manage::Logger::LogError("Host out of range");
+ }
+ return host_as_int >= 0 && host_as_int <= 65535;
+ }
+}
diff --git a/src/checker/errors/settings/host_number.hpp b/src/checker/errors/settings/host_number.hpp
new file mode 100644
index 0000000..1f2bfe7
--- /dev/null
+++ b/src/checker/errors/settings/host_number.hpp
@@ -0,0 +1,17 @@
+#pragma once
+
+#include "checker/errors/types/isettings_error.hpp"
+
+namespace smtp::checker::errors::settings
+{
+ class HostNumber : public types::IErrorSettings
+ {
+ public:
+ HostNumber() = default;
+ ~HostNumber() override = default;
+
+ virtual bool Check( const manage::SettingsFileDataType& line ) const override;
+ };
+}
+
+
diff --git a/src/checker/errors/types/imails_error.hpp b/src/checker/errors/types/imails_error.hpp
new file mode 100644
index 0000000..d696bbd
--- /dev/null
+++ b/src/checker/errors/types/imails_error.hpp
@@ -0,0 +1,19 @@
+#pragma once
+
+#include <memory>
+#include <string>
+
+namespace smtp::checker::errors::types
+{
+ class IError
+ {
+ public:
+ IError() = default;
+ virtual ~IError() = default;
+
+ virtual bool Check( std::string const& line ) const = 0;
+ };
+ using IErrorPtr = std::shared_ptr<IError>;
+}
+
+
diff --git a/src/checker/errors/types/isettings_error.hpp b/src/checker/errors/types/isettings_error.hpp
new file mode 100644
index 0000000..d5a788f
--- /dev/null
+++ b/src/checker/errors/types/isettings_error.hpp
@@ -0,0 +1,22 @@
+//
+// Created by claiff on 18.09.22.
+//
+
+#pragma once
+
+#include <memory>
+
+#include "managment/general.hpp"
+
+namespace smtp::checker::errors::types
+{
+ class IErrorSettings
+ {
+ public:
+ IErrorSettings() = default;
+ virtual ~IErrorSettings() = default;
+
+ virtual bool Check( manage::SettingsFileDataType const& line ) const = 0;
+ };
+ using IErrorSettingsPtr = std::shared_ptr<IErrorSettings>;
+} \ No newline at end of file
diff --git a/src/checker/registrator_mails.cpp b/src/checker/registrator_mails.cpp
new file mode 100644
index 0000000..7e844c0
--- /dev/null
+++ b/src/checker/registrator_mails.cpp
@@ -0,0 +1,22 @@
+#include "registrator_mails.hpp"
+
+namespace smtp::checker
+{
+ void RegistratorMails::Add(errors::types::IErrorPtr const& error )
+ {
+ mErrors.push_back( error );
+ }
+
+ bool RegistratorMails::Check( std::string const& line ) const
+ {
+ for( const auto& error : mErrors )
+ {
+ if( !error->Check( line ) )
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+} // namespace smtp::checker
diff --git a/src/checker/registrator_mails.hpp b/src/checker/registrator_mails.hpp
new file mode 100644
index 0000000..86eb41a
--- /dev/null
+++ b/src/checker/registrator_mails.hpp
@@ -0,0 +1,19 @@
+#pragma once
+
+#include "errors/types/imails_error.hpp"
+#include <list>
+
+namespace smtp::checker
+{
+ class RegistratorMails
+ {
+ public:
+ RegistratorMails() = default;
+ ~RegistratorMails() = default;
+
+ void Add( errors::types::IErrorPtr const &error );
+ bool Check( std::string const& line ) const;
+ private:
+ std::list<errors::types::IErrorPtr> mErrors;
+ };
+} // namespace smtp::checker
diff --git a/src/checker/registrator_settings.hpp b/src/checker/registrator_settings.hpp
new file mode 100644
index 0000000..fbd12f5
--- /dev/null
+++ b/src/checker/registrator_settings.hpp
@@ -0,0 +1,35 @@
+#pragma once
+
+#include "errors/types/isettings_error.hpp"
+#include <list>
+
+namespace smtp::checker
+{
+ class RegistratorSettings
+ {
+ public:
+ RegistratorSettings() = default;
+ ~RegistratorSettings() = default;
+
+ void Add( errors::types::IErrorSettingsPtr const& error )
+ {
+ mErrors.push_back( error );
+ }
+
+ template<typename T>
+ bool Check( T const& line ) const
+ {
+ for( const auto& error: mErrors )
+ {
+ if( !error->Check( line ))
+ {
+ return false;
+ }
+ }
+ return true;
+ }
+
+ private:
+ std::list < errors::types::IErrorSettingsPtr > mErrors;
+ };
+}
diff --git a/src/file/mail.cpp b/src/file/mail.cpp
index 5452136..c728edc 100644
--- a/src/file/mail.cpp
+++ b/src/file/mail.cpp
@@ -5,8 +5,9 @@
namespace smtp::file
{
- Mail::Mail( std::string const& path_file )
+ Mail::Mail( std::string const& path_file, checker::RegistratorMails const& registrator_errors )
: mPathFile( path_file )
+ , mRegistratorErrors( registrator_errors )
{
}
@@ -23,11 +24,10 @@ namespace smtp::file
while ( std::getline( mail_file, line ) )
{
- auto parsed_data = GetMailFromLine( line );
- if( parsed_data )
- {
- result.push_back( *parsed_data );
- }
+ if( mRegistratorErrors.Check( line ) )
+ {
+ result.push_back( line );
+ }
}
mail_file.close();
return result;
@@ -41,23 +41,14 @@ namespace smtp::file
manage::Logger::LogError( "Unable to open file to write " + mPathFile );
return false;
}
- for( const auto& pair : data )
+ for( const auto& mail : data )
{
- mail_file << pair << "\n";
+ if( mRegistratorErrors.Check( mail ) )
+ {
+ mail_file << mail << "\n";
+ }
}
mail_file.close();
return true;
}
-
- std::optional<std::string> Mail::GetMailFromLine( std::string const& line ) const
- {
- //TODO registrator if checking parsing
- auto pos = line.find('@');
- if(pos == std::string::npos)
- {
- return {};
- }
- return line;
- }
-
}
diff --git a/src/file/mail.hpp b/src/file/mail.hpp
index 34050bf..2860c79 100644
--- a/src/file/mail.hpp
+++ b/src/file/mail.hpp
@@ -4,21 +4,21 @@
#include <optional>
#include "managment/general.hpp"
+#include "checker/registrator_mails.hpp"
namespace smtp::file
{
class Mail
{
public:
- explicit Mail( std::string const& path_file );
+ explicit Mail( std::string const& path_file, checker::RegistratorMails const& registrator_errors );
~Mail() = default;
manage::MailsSet Read() const;
bool Write( manage::MailsSet const& data ) const;
private:
- std::optional<std::string> GetMailFromLine( std::string const& line ) const;
-
std::string mPathFile;
+ checker::RegistratorMails mRegistratorErrors;
};
}
diff --git a/src/file/settings.cpp b/src/file/settings.cpp
index 83c1037..a856f6e 100644
--- a/src/file/settings.cpp
+++ b/src/file/settings.cpp
@@ -5,8 +5,9 @@
namespace smtp::file
{
- Settings::Settings( std::string const& path_file)
+ Settings::Settings( std::string const& path_file, checker::RegistratorSettings const& registrator_errors )
: mPathFile( path_file )
+ , mRegistratorErrors( registrator_errors )
{
}
@@ -23,7 +24,7 @@ namespace smtp::file
return SetParsedData( parsed_data );
}
- ParsedStoreType Settings::GetParsedStore() const
+ manage::SettingsFileDataType Settings::GetParsedStore() const
{
std::ifstream settings_file{ mPathFile, std::fstream::in };
if ( !settings_file.is_open() )
@@ -32,18 +33,18 @@ namespace smtp::file
return {};
}
std::string line{};
- ParsedStoreType result;
+ manage::SettingsFileDataType result;
while ( std::getline( settings_file, line ) )
{
- auto parsed_data = parser::Settings{}.Parse(line);
- result.insert( parsed_data );
+ auto parsed_data = parser::Settings{}.Parse( line );
+ result.insert( parsed_data );
}
settings_file.close();
- return result;
+ return mRegistratorErrors.Check(result) ? result : manage::SettingsFileDataType{};
}
- bool Settings::SetParsedData( ParsedStoreType const& parsed_data ) const
+ bool Settings::SetParsedData( manage::SettingsFileDataType const& parsed_data ) const
{
std::ofstream settings_file{ mPathFile, std::fstream::out | std::fstream::trunc };
if ( !settings_file.is_open() )
diff --git a/src/file/settings.hpp b/src/file/settings.hpp
index fb77b1e..7e5ce63 100644
--- a/src/file/settings.hpp
+++ b/src/file/settings.hpp
@@ -6,25 +6,27 @@
#include "converter/full.hpp"
#include "parser/settings.hpp"
#include "managment/general.hpp"
+#include "checker/registrator_settings.hpp"
namespace smtp::file
{
- using ParsedStoreType = std::unordered_map<std::string, std::string>;
+
class Settings
{
public:
- explicit Settings( std::string const& path_file );
+ explicit Settings( std::string const& path_file, checker::RegistratorSettings const& registrator_errors );
~Settings() = default;
manage::SettingsFields Read() const;
bool Write( manage::SettingsFields const& settings_fields ) const;
private:
- ParsedStoreType GetParsedStore() const;
- bool SetParsedData( ParsedStoreType const& parsed_data ) const;
+ manage::SettingsFileDataType GetParsedStore() const;
+ bool SetParsedData( manage::SettingsFileDataType const& parsed_data ) const;
std::string BuildParam( std::pair<std::string, std::string> const& data ) const;
std::string mPathFile;
+ checker::RegistratorSettings mRegistratorErrors;
};
}
diff --git a/src/management/builder/mail.cpp b/src/management/builder/mail.cpp
new file mode 100644
index 0000000..f72803f
--- /dev/null
+++ b/src/management/builder/mail.cpp
@@ -0,0 +1,23 @@
+#include "mail.hpp"
+#include "file/mail.hpp"
+
+namespace smtp::manage::builder
+{
+ smtp::manage::Mail Mail::Build() const
+ {
+ static const std::string PATH = {"/var/lib/smtp/mails.txt"};
+
+ auto registrator = BuildErrorRegistrator();
+ file::Mail file_manipulator{PATH, registrator};
+ return smtp::manage::Mail{file_manipulator};
+ }
+
+ checker::RegistratorMails Mail::BuildErrorRegistrator() const
+ {
+ checker::RegistratorMails result;
+
+
+ return result;
+ }
+
+}
diff --git a/src/managment/builder/mail.hpp b/src/management/builder/mail.hpp
index ae53202..ad1de36 100644
--- a/src/managment/builder/mail.hpp
+++ b/src/management/builder/mail.hpp
@@ -1,6 +1,7 @@
#pragma once
#include "managment/mail.hpp"
+#include "checker/registrator_mails.hpp"
namespace smtp::manage::builder
{
@@ -11,6 +12,7 @@ namespace smtp::manage::builder
~Mail() = default;
smtp::manage::Mail Build() const;
+ checker::RegistratorMails BuildErrorRegistrator() const;
};
}
diff --git a/src/management/builder/settings.cpp b/src/management/builder/settings.cpp
new file mode 100644
index 0000000..d5a5e3b
--- /dev/null
+++ b/src/management/builder/settings.cpp
@@ -0,0 +1,29 @@
+#include "settings.hpp"
+#include "checker/errors/settings/host_number.hpp"
+
+namespace smtp::manage::builder
+{
+
+ smtp::manage::Settings Settings::Build() const
+ {
+ auto file_manipulator = GetFileSettings();
+ return smtp::manage::Settings{file_manipulator};
+ }
+
+ file::Settings Settings::GetFileSettings() const
+ {
+ static const std::string PATH = "/var/lib/smtp/settings.txt";
+
+ auto registrator = BuildErrorRegistrator();
+ return file::Settings{PATH, registrator};
+ }
+
+ checker::RegistratorSettings Settings::BuildErrorRegistrator() const
+ {
+ checker::RegistratorSettings result;
+
+ result.Add( std::make_shared < checker::errors::settings::HostNumber >());
+ return result;
+ }
+
+}
diff --git a/src/managment/builder/settings.hpp b/src/management/builder/settings.hpp
index 1089b06..67b7481 100644
--- a/src/managment/builder/settings.hpp
+++ b/src/management/builder/settings.hpp
@@ -2,6 +2,7 @@
#include "managment/settings.hpp"
#include "file/settings.hpp"
+#include "checker/registrator_settings.hpp"
namespace smtp::manage::builder
{
@@ -14,6 +15,7 @@ namespace smtp::manage::builder
smtp::manage::Settings Build() const;
private:
file::Settings GetFileSettings() const;
+ checker::RegistratorSettings BuildErrorRegistrator() const;
};
}
diff --git a/src/managment/general.hpp b/src/management/general.hpp
index ed1a789..ed1a789 100644
--- a/src/managment/general.hpp
+++ b/src/management/general.hpp
diff --git a/src/managment/logger.cpp b/src/management/logger.cpp
index 0c55394..0c55394 100644
--- a/src/managment/logger.cpp
+++ b/src/management/logger.cpp
diff --git a/src/managment/logger.hpp b/src/management/logger.hpp
index 315e17e..315e17e 100644
--- a/src/managment/logger.hpp
+++ b/src/management/logger.hpp
diff --git a/src/management/mail.cpp b/src/management/mail.cpp
new file mode 100644
index 0000000..5c3c276
--- /dev/null
+++ b/src/management/mail.cpp
@@ -0,0 +1,71 @@
+#include <algorithm>
+
+#include "mail.hpp"
+
+namespace smtp::manage
+{
+ Mail::Mail( file::Mail const& file_reader )
+ : mFileReader( file_reader )
+ {
+ mMails = mFileReader.Read();
+ }
+
+ MailsSet Mail::GetMailToSend() const
+ {
+ return mMails;
+ }
+
+ bool Mail::AddMailsToSend( MailsSet const& mails_to_add )
+ {
+ auto merged_mails = GetMergedMails( mails_to_add );
+
+ auto result = mFileReader.Write( merged_mails );
+ if( result )
+ {
+ mMails = merged_mails;
+ }
+ return result;
+ }
+
+ bool Mail::DeleteMailToSend( MailsSet const& mail_to_send )
+ {
+ auto mails_to_delete = GetItersectionMails( mail_to_send );
+ auto result_set_after_delete = GetMailsAfterDelete( mails_to_delete );
+ auto result_of_delete = mFileReader.Write( result_set_after_delete );
+ if( result_of_delete )
+ {
+ mMails = result_set_after_delete;
+ }
+ return result_of_delete;
+ }
+
+ MailsSet Mail::GetMergedMails( MailsSet const& mails_to_add )
+ {
+ auto result = mails_to_add;
+ result.merge( mMails );
+ return result;
+ }
+
+ MailsSet Mail::GetItersectionMails( MailsSet const& mail_to_send )
+ {
+ MailsSet result;
+
+ auto sorted_mail_to_send = mail_to_send;
+ sorted_mail_to_send.sort();
+ mMails.sort();
+ std::set_intersection( mMails.cbegin(), mMails.cend(),
+ sorted_mail_to_send.cbegin(), sorted_mail_to_send.cend(),
+ std::back_inserter( result ));
+ return result;
+ }
+
+ MailsSet Mail::GetMailsAfterDelete( MailsSet const& result_set_after_delete )
+ {
+ auto result = mMails;
+ for( const auto& element_to_delete: result_set_after_delete )
+ {
+ result.remove( element_to_delete );
+ }
+ return result;
+ }
+}
diff --git a/src/management/mail.hpp b/src/management/mail.hpp
new file mode 100644
index 0000000..12b79ab
--- /dev/null
+++ b/src/management/mail.hpp
@@ -0,0 +1,30 @@
+#pragma once
+
+#include <set>
+#include <string>
+
+#include "file/mail.hpp"
+#include "checker/registrator_mails.hpp"
+
+namespace smtp::manage
+{
+ class Mail
+ {
+ public:
+ explicit Mail( file::Mail const& file_reader );
+ ~Mail() = default;
+
+ MailsSet GetMailToSend() const;
+ bool AddMailsToSend( MailsSet const& mails );
+ bool DeleteMailToSend( MailsSet const& mail_to_send );
+ private:
+ MailsSet GetMergedMails( MailsSet const& mails_to_add );
+ MailsSet GetItersectionMails( MailsSet const& mail_to_send );
+ MailsSet GetMailsAfterDelete( MailsSet const& result_set_after_delete );
+
+ MailsSet mMails;
+ file::Mail mFileReader;
+
+ };
+
+}
diff --git a/src/managment/settings.cpp b/src/management/settings.cpp
index 65888aa..65888aa 100644
--- a/src/managment/settings.cpp
+++ b/src/management/settings.cpp
diff --git a/src/managment/settings.hpp b/src/management/settings.hpp
index 3c0a15d..3c0a15d 100644
--- a/src/managment/settings.hpp
+++ b/src/management/settings.hpp
diff --git a/src/managment/builder/mail.cpp b/src/managment/builder/mail.cpp
deleted file mode 100644
index da8dff5..0000000
--- a/src/managment/builder/mail.cpp
+++ /dev/null
@@ -1,14 +0,0 @@
-#include "mail.hpp"
-#include "file/mail.hpp"
-
-namespace smtp::manage::builder
-{
- smtp::manage::Mail Mail::Build() const
- {
- static const std::string PATH = {"/var/lib/smtp/mails.txt"};
-
- file::Mail file_manipulator{PATH};
- return smtp::manage::Mail{ file_manipulator };
- }
-
-}
diff --git a/src/managment/builder/settings.cpp b/src/managment/builder/settings.cpp
deleted file mode 100644
index cd08c57..0000000
--- a/src/managment/builder/settings.cpp
+++ /dev/null
@@ -1,18 +0,0 @@
-#include "settings.hpp"
-
-namespace smtp::manage::builder
-{
-
- smtp::manage::Settings Settings::Build() const
- {
- auto file_manipulator = GetFileSettings();
- return smtp::manage::Settings{ file_manipulator };
- }
-
- file::Settings Settings::GetFileSettings() const
- {
- static const std::string PATH = {"/var/lib/smtp/settings.txt"};
- return file::Settings{PATH};
- }
-
-}
diff --git a/src/managment/mail.cpp b/src/managment/mail.cpp
deleted file mode 100644
index ccde362..0000000
--- a/src/managment/mail.cpp
+++ /dev/null
@@ -1,72 +0,0 @@
-#include <algorithm>
-
-#include "mail.hpp"
-
-namespace smtp::manage
-{
- Mail::Mail( file::Mail const& file_reader )
- : mFileReader( file_reader )
- {
- mMails = mFileReader.Read();
- }
-
- MailsSet Mail::GetMailToSend() const
- {
- return mMails;
- }
-
- bool Mail::AddMailsToSend( MailsSet const& mails_to_add )
- {
- auto merged_mails = GetMergedMails( mails_to_add );
-
- auto result = mFileReader.Write( merged_mails );
- if( result )
- {
- mMails = merged_mails;
- }
- return result;
- }
-
- bool Mail::DeleteMailToSend( MailsSet const& mail_to_send )
- {
- auto mails_to_delete = GetItersectionMails( mail_to_send );
- auto result_set_after_delete = GetMailsAfterDelete( mails_to_delete );
- auto result_of_delete = mFileReader.Write( result_set_after_delete );
- if(result_of_delete)
- {
- mMails = result_set_after_delete;
- }
- return result_of_delete;
- }
-
- MailsSet Mail::GetMergedMails( MailsSet const& mails_to_add )
- {
- auto result = mails_to_add;
- result.merge( mMails );
- return result;
- }
-
- MailsSet Mail::GetItersectionMails( MailsSet const& mail_to_send )
- {
- MailsSet result;
-
- auto sorted_mail_to_send = mail_to_send;
- sorted_mail_to_send.sort();
- mMails.sort();
- std::set_intersection( mMails.cbegin(), mMails.cend(),
- sorted_mail_to_send.cbegin(), sorted_mail_to_send.cend(),
- std::back_inserter( result ));
- return result;
- }
-
- MailsSet Mail::GetMailsAfterDelete( MailsSet const& result_set_after_delete)
- {
- auto result = mMails;
- for(const auto& element_to_delete : result_set_after_delete)
- {
- result.remove( element_to_delete );
- }
- return result;
- }
-
-}
diff --git a/src/managment/mail.hpp b/src/managment/mail.hpp
deleted file mode 100644
index d6dfeef..0000000
--- a/src/managment/mail.hpp
+++ /dev/null
@@ -1,28 +0,0 @@
-#pragma once
-
-#include <set>
-#include <string>
-
-#include "file/mail.hpp"
-
-namespace smtp::manage
-{
-
- class Mail
- {
- public:
- explicit Mail( file::Mail const& file_reader );
- ~Mail() = default;
-
- MailsSet GetMailToSend() const;
- bool AddMailsToSend( MailsSet const& mails );
- bool DeleteMailToSend(MailsSet const&mail_to_send );
- private:
- MailsSet GetMergedMails( MailsSet const& mails_to_add );
- MailsSet GetItersectionMails( MailsSet const& mail_to_send );
- MailsSet GetMailsAfterDelete( MailsSet const& result_set_after_delete);
- MailsSet mMails;
- file::Mail mFileReader;
- };
-
-}