~aleteoryx/muditaos

muditaos/module-apps/apps-common/notifications/NotificationData.hpp -rw-r--r-- 3.2 KiB
a405cad6Aleteoryx trim readme 6 days 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
// Copyright (c) 2017-2024, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/blob/master/LICENSE.md

#pragma once

#include <limits>
#include <list>

#include <ContactRecord.hpp>

namespace notifications
{
    enum class NotificationType
    {
        NotSeenSms,
        NotSeenCall,
        Tethering,
        AlarmSnooze,
        PhoneLock,
        BatteryTooHot
    };

    enum class NotificationPriority
    {
        Next,
        Highest,
        Lowest
    };

    enum class NotificationOnReceiveUpdate
    {
        PartialRebuild,
        FullRebuild,
    };

    class Notification
    {
        static constexpr auto highestPriority = std::numeric_limits<std::uint32_t>::max();
        static constexpr auto lowestPriority  = 0;
        static std::uint32_t priorityPool;

        NotificationType type;
        std::uint32_t priority;

      protected:
        explicit Notification(NotificationType type, NotificationPriority priorityType = NotificationPriority::Next);

      public:
        [[nodiscard]] auto getType() const noexcept -> NotificationType;
        [[nodiscard]] auto getPriority() const noexcept -> std::uint32_t;

        virtual ~Notification() = default;
    };

    class NotificationWithContact : public Notification
    {
        unsigned value = 0;
        std::optional<ContactRecord> record;

      protected:
        NotificationWithContact(NotificationType type, unsigned value, std::optional<ContactRecord> record);

      public:
        [[nodiscard]] auto hasRecord() const noexcept -> bool;
        [[nodiscard]] auto getRecord() const noexcept -> const ContactRecord &;
        [[nodiscard]] auto getValue() const noexcept -> unsigned;
    };

    class NotificationWithCounter : public Notification
    {
        unsigned value = 0;

      protected:
        explicit NotificationWithCounter(NotificationType type, unsigned value);

      public:
        [[nodiscard]] auto getValue() const noexcept -> unsigned;
    };

    class NotificationWithTime : public Notification
    {
        std::string formattedTime;

      protected:
        NotificationWithTime(NotificationType type, NotificationPriority priorityType, std::string formattedTime);

      public:
        [[nodiscard]] auto getTime() const noexcept -> const std::string &;
    };

    class NotSeenSMSNotification : public NotificationWithContact
    {
      public:
        NotSeenSMSNotification(unsigned value, std::optional<ContactRecord> record);
    };

    class NotSeenCallNotification : public NotificationWithContact
    {
      public:
        NotSeenCallNotification(unsigned value, std::optional<ContactRecord> record);
    };

    class TetheringNotification : public Notification
    {
      public:
        TetheringNotification();
    };

    class AlarmSnoozeNotification : public NotificationWithCounter
    {
      public:
        explicit AlarmSnoozeNotification(unsigned snoozeCount);
    };

    class PhoneLockNotification : public NotificationWithTime
    {
      public:
        explicit PhoneLockNotification(std::string formattedTime);
    };

    class BatteryTooHotNotification : public Notification
    {
      public:
        BatteryTooHotNotification();
    };
} // namespace notifications