mirror of
https://github.com/mudita/MuditaOS.git
synced 2026-04-20 15:07:17 -04:00
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.
70 lines
2.0 KiB
C++
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)
|
|
{}
|