1 /*
2 * Copyright (c) 2021-2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include "reminder_helper.h"
17
18 #include "ans_log_wrapper.h"
19 #include "ans_notification.h"
20 #include "notification_helper.h"
21 #include "singleton.h"
22
23 namespace OHOS {
24 namespace Notification {
PublishReminder(ReminderRequest & reminder)25 ErrCode ReminderHelper::PublishReminder(ReminderRequest &reminder)
26 {
27 ANSR_LOGI("PublishReminder start");
28 NotificationHelper::AddSlotByType(reminder.GetSlotType());
29 return DelayedSingleton<AnsNotification>::GetInstance()->PublishReminder(reminder);
30 }
31
CancelReminder(const int32_t reminderId)32 ErrCode ReminderHelper::CancelReminder(const int32_t reminderId)
33 {
34 ANSR_LOGI("CancelReminder start");
35 return DelayedSingleton<AnsNotification>::GetInstance()->CancelReminder(reminderId);
36 }
37
CancelAllReminders()38 ErrCode ReminderHelper::CancelAllReminders()
39 {
40 ANSR_LOGI("CancelAllReminders start");
41 return DelayedSingleton<AnsNotification>::GetInstance()->CancelAllReminders();
42 }
43
GetValidReminders(std::vector<sptr<ReminderRequest>> & validReminders)44 ErrCode ReminderHelper::GetValidReminders(std::vector<sptr<ReminderRequest>> &validReminders)
45 {
46 ANSR_LOGI("GetValidReminders start");
47 return DelayedSingleton<AnsNotification>::GetInstance()->GetValidReminders(validReminders);
48 }
49
AddNotificationSlot(const NotificationSlot & slot)50 ErrCode ReminderHelper::AddNotificationSlot(const NotificationSlot &slot)
51 {
52 ANSR_LOGI("AddNotificationSlot start");
53 return DelayedSingleton<AnsNotification>::GetInstance()->AddNotificationSlot(slot);
54 }
55
RemoveNotificationSlot(const NotificationConstant::SlotType & slotType)56 ErrCode ReminderHelper::RemoveNotificationSlot(const NotificationConstant::SlotType &slotType)
57 {
58 ANSR_LOGI("RemoveNotificationSlot start");
59 return DelayedSingleton<AnsNotification>::GetInstance()->RemoveNotificationSlot(slotType);
60 }
61
AddExcludeDate(const int32_t reminderId,const uint64_t date)62 ErrCode ReminderHelper::AddExcludeDate(const int32_t reminderId, const uint64_t date)
63 {
64 ANSR_LOGI("AddExcludeDate start");
65 return DelayedSingleton<AnsNotification>::GetInstance()->AddExcludeDate(reminderId, date);
66 }
67
DelExcludeDates(const int32_t reminderId)68 ErrCode ReminderHelper::DelExcludeDates(const int32_t reminderId)
69 {
70 ANSR_LOGI("DelExcludeDates start");
71 return DelayedSingleton<AnsNotification>::GetInstance()->DelExcludeDates(reminderId);
72 }
73
GetExcludeDates(const int32_t reminderId,std::vector<uint64_t> & dates)74 ErrCode ReminderHelper::GetExcludeDates(const int32_t reminderId, std::vector<uint64_t>& dates)
75 {
76 ANSR_LOGI("GetExcludeDates start");
77 return DelayedSingleton<AnsNotification>::GetInstance()->GetExcludeDates(reminderId, dates);
78 }
79 }
80 }