~aleteoryx/muditaos

ref: 6eeb1d75704ae9b97e002c3d7b058ac532b14128 muditaos/module-apps/application-desktop/widgets/DBNotificationsHandler.hpp -rw-r--r-- 1.1 KiB
6eeb1d75 — DariuszSabala [BH-628] Cleaned up module-vfs cmake 4 years ago
                                                                                
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
46
47
48
// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md

#pragma once

#include <map>

namespace db
{
    class NotificationMessage;
    class QueryResult;
} // namespace db

namespace app
{
    class Application;

    class DBNotificationsBaseHandler
    {
      public:
        enum class Type
        {
            notReadSMS,
            notReadCall
        };

        [[nodiscard]] virtual bool hasNotification(Type type) const = 0;
        virtual ~DBNotificationsBaseHandler()                       = default;
    };

    class DBNotificationsHandler : public DBNotificationsBaseHandler
    {
        Application *ownerApp = nullptr;
        std::map<Type, int> notifications;

        void setNotification(Type type, int value);

      public:
        explicit DBNotificationsHandler(Application *ownerApp);

        void initHandler();
        bool handle(db::NotificationMessage *msg);
        bool handle(db::QueryResult *msg);

        [[nodiscard]] bool hasNotification(Type type) const override;
    };

} // namespace app