summaryrefslogtreecommitdiff
path: root/src/service/smtp.hpp
blob: 1c71accf0000ac2f80b0a06e45eaaf16c33f453c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#pragma once

#include <boost/asio/io_service.hpp>

#include <sdbusplus/asio/connection.hpp>
#include <sdbusplus/asio/object_server.hpp>

#include "management/mail.hpp"
#include "management/settings.hpp"

namespace smtp::service
{
    using ConnectionPtr = std::shared_ptr<sdbusplus::asio::connection>;
    using InterfacePtr = std::shared_ptr<sdbusplus::asio::dbus_interface>;
    using ObjectServerPtr = std::shared_ptr<sdbusplus::asio::object_server>;

    class Smtp
    {
    public:
        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 CreateSettingsManagerInterface( ConnectionPtr connection );
        void CreateMailManagerInterface( ConnectionPtr connection );
        void AddProperties();
        void AddMessagerMethods();
        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 mManagerSettingsInterface;
        InterfacePtr mManagerMailInterface;

        ObjectServerPtr mObjectServer;
        manage::Settings mSettingsStorage;
        manage::Mail mMailTo;
    };
}