summaryrefslogtreecommitdiff
path: root/src/service
diff options
context:
space:
mode:
Diffstat (limited to 'src/service')
-rw-r--r--src/service/settings.cpp54
-rw-r--r--src/service/settings.hpp36
-rw-r--r--src/service/smtp.cpp15
-rw-r--r--src/service/smtp.hpp8
4 files changed, 12 insertions, 101 deletions
diff --git a/src/service/settings.cpp b/src/service/settings.cpp
deleted file mode 100644
index 075aafa..0000000
--- a/src/service/settings.cpp
+++ /dev/null
@@ -1,54 +0,0 @@
-#include "settings.hpp"
-
-namespace smtp::service
-{
-
- Settings::Settings()
- : mSettingsFields{}
- {
-
- }
-
- Settings::Settings( SettingsFields data )
- : mSettingsFields(data)
- {
-
- }
-
- bool Settings::CheckAndSetSettings(SettingsFields data)
- {
- mSettingsFields = data;
- return true;
- }
-
- bool Settings::IsNeedAuth() const noexcept
- {
- return mSettingsFields.is_need_auth;
- }
-
- bool Settings::IsNeedSsl() const noexcept
- {
- return mSettingsFields.is_need_ssl;
- }
-
- std::string Settings::GetUserName() const
- {
- return mSettingsFields.username;
- }
-
- std::string Settings::GetPassword() const
- {
- return mSettingsFields.password;
- }
-
- std::string Settings::GetHost() const
- {
- return mSettingsFields.host;
- }
-
- std::string Settings::GetPort() const
- {
- return mSettingsFields.port;
- }
-
-}
diff --git a/src/service/settings.hpp b/src/service/settings.hpp
deleted file mode 100644
index b6319f6..0000000
--- a/src/service/settings.hpp
+++ /dev/null
@@ -1,36 +0,0 @@
-#pragma once
-
-#include <string>
-
-namespace smtp::service
-{
- struct SettingsFields
- {
- bool is_need_auth;
- bool is_need_ssl;
- std::string username;
- std::string password;
- std::string host;
- std::string port;
- };
-
- class Settings
- {
- public:
- Settings();
- explicit Settings( SettingsFields data );
- ~Settings() = default;
-
- bool CheckAndSetSettings( SettingsFields data );
-
- bool IsNeedAuth() const noexcept;
- bool IsNeedSsl() const noexcept;
-
- std::string GetUserName() const;
- std::string GetPassword() const;
- std::string GetHost() const;
- std::string GetPort() const;
- private:
- SettingsFields mSettingsFields;
- };
-}
diff --git a/src/service/smtp.cpp b/src/service/smtp.cpp
index 818a4de..e85dda0 100644
--- a/src/service/smtp.cpp
+++ b/src/service/smtp.cpp
@@ -1,6 +1,6 @@
#include "smtp.hpp"
#include "message/sender.hpp"
-
+#include <iostream>
namespace smtp::service
{
static constexpr char HOST_PROPERTY[] = "Host";
@@ -11,7 +11,8 @@ namespace smtp::service
// Constructors
//
- Smtp::Smtp( ConnectionPtr connection )
+ Smtp::Smtp( ConnectionPtr connection, manage::Settings const& settings, manage::Mail const& mail_to )
+ :mSettingsStorage(settings), mMailTo(mail_to)
{
std::string from{"claiff@mail.ru"};
std::string to{"claiff1990@gmail.com"};
@@ -19,8 +20,8 @@ namespace smtp::service
std::string subject{"subject"};
std::string text{"text"};
- mSettingsStorage.CheckAndSetSettings({true, true, "claiff@mail.ru","nZZbXq7FbwWAqpPpy3YL", "smtp.mail.ru", "" });
- message::Sender{ mSettingsStorage }.Send( "claiff@mail.ru", "claiff1990@gmail.com", {"claiff@mail.ru"}, "subject", "text" );
+ // mSettingsStorage.CheckAndSetSettings({true, true, "claiff@mail.ru","nZZbXq7FbwWAqpPpy3YL", "smtp.mail.ru", "" });
+ message::Sender{ mSettingsStorage, mMailTo }.Send( "claiff@mail.ru", "subject", "text" );
// CreateService( connection );
// CreateInterface( connection );
@@ -64,11 +65,9 @@ namespace smtp::service
static constexpr char SMTP_CHANGE_PARAMETERS_METHOD_NAME[] = "ChangeParameters";
mInterface->register_method(SMTP_SEND_MESSAGE_METHOD_NAME, [this]( std::string const& mail_from,
- std::string const& mail_to,
- std::list<std::string> const& cc,
std::string const& theme,
std::string const& text )
- { return message::Sender{ mSettingsStorage }.Send( mail_from, mail_to, cc, theme, text );});
+ { return message::Sender{ mSettingsStorage, mMailTo }.Send( mail_from, theme, text );});
mInterface->register_method(SMTP_CHANGE_PARAMETERS_METHOD_NAME, [this]( bool is_need_auth,
@@ -84,7 +83,7 @@ namespace smtp::service
std::string const& user, std::string const& password,
std::string const& host, std::string const& port )
{
- auto is_settings_norm = mSettingsStorage.CheckAndSetSettings({is_need_auth, is_need_ssl,
+ auto is_settings_norm = mSettingsStorage.SetSettings({is_need_auth, is_need_ssl,
user, password, host, port});
if(!is_settings_norm)
{
diff --git a/src/service/smtp.hpp b/src/service/smtp.hpp
index c311645..0284f42 100644
--- a/src/service/smtp.hpp
+++ b/src/service/smtp.hpp
@@ -5,7 +5,8 @@
#include <sdbusplus/asio/connection.hpp>
#include <sdbusplus/asio/object_server.hpp>
-#include "settings.hpp"
+#include "managment/mail.hpp"
+#include "managment/settings.hpp"
namespace smtp::service
{
@@ -16,7 +17,7 @@ namespace smtp::service
class Smtp
{
public:
- Smtp( ConnectionPtr connection );
+ Smtp( ConnectionPtr connection, manage::Settings const& settings, manage::Mail const& mail_to );
~Smtp() = default;
private:
void FillStorageByDefault();
@@ -30,6 +31,7 @@ namespace smtp::service
InterfacePtr mInterface;
ObjectServerPtr mObjectServer;
- Settings mSettingsStorage;
+ manage::Settings mSettingsStorage;
+ manage::Mail mMailTo;
};
}