Files
MuditaOS/module-apps/notifications/NotificationData.cpp
Michał Kamoń 46c57aaa88 [EGD-6599] Add single number call notification
This PR adds proper notification on call notifications coming from
single number. To that end following changes have been introduced:
 * extension of Notification DB record with contact_id filed
 * use of `ContactRecordInterface` in `NotificationsRecordInterface`
 * extension of `Increment` query to require `PhoneNumber::View`
 * multiple minor changes on path from creating/handling
 `NotificationsRecord` to displaying respective notification.
2021-05-06 14:39:53 +02:00

70 lines
2.0 KiB
C++

// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#include "NotificationData.hpp"
#include <gsl_assert>
uint32_t notifications::Notification::priorityPool = 0;
using namespace notifications;
Notification::Notification(NotificationType type, NotificationPriority priorityType) : type{type}
{
switch (priorityType) {
case NotificationPriority::Next:
if (priorityPool == highestPriority) {
priorityPool = 0;
}
priority = ++priorityPool;
break;
case NotificationPriority::Highest:
priority = highestPriority;
break;
case NotificationPriority::Lowest:
priority = lowestPriority;
break;
}
}
auto Notification::getType() const noexcept -> NotificationType
{
return type;
}
auto Notification::getPriority() const noexcept -> uint32_t
{
return priority;
}
NotificationWithContact::NotificationWithContact(NotificationType type,
unsigned value,
std::optional<ContactRecord> record)
: Notification(type), value{value}, record{std::move(record)}
{}
auto NotificationWithContact::hasRecord() const noexcept -> bool
{
return record.has_value();
}
auto NotificationWithContact::getRecord() const noexcept -> const ContactRecord &
{
Expects(hasRecord());
return record.value();
}
auto NotificationWithContact::getValue() const noexcept -> unsigned
{
return value;
}
NotSeenSMSNotification::NotSeenSMSNotification(unsigned value, std::optional<ContactRecord> record)
: NotificationWithContact(NotificationType::NotSeenSms, value, std::move(record))
{}
NotSeenCallNotification::NotSeenCallNotification(unsigned value, std::optional<ContactRecord> record)
: NotificationWithContact(NotificationType::NotSeenCall, value, std::move(record))
{}
TetheringNotification::TetheringNotification() : Notification(NotificationType::Tethering)
{}