1 /* 2 * Copyright (c) 2024 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_request_factory.h" 17 18 #include "ans_log_wrapper.h" 19 #include "reminder_request_alarm.h" 20 #include "reminder_request_calendar.h" 21 #include "reminder_request_timer.h" 22 23 24 #include <memory> 25 #include <thread> 26 27 namespace OHOS { 28 namespace Notification { CreateReminderRequest(ReminderRequest::ReminderType reminderType)29ReminderRequest* ReminderRequestFactory::CreateReminderRequest(ReminderRequest::ReminderType reminderType) 30 { 31 ReminderRequest* reminderRequest = nullptr; 32 switch (reminderType) { 33 case (ReminderRequest::ReminderType::TIMER): { 34 ANSR_LOGI("Create timer"); 35 reminderRequest = new (std::nothrow) ReminderRequestTimer(); 36 break; 37 } 38 case (ReminderRequest::ReminderType::ALARM): { 39 ANSR_LOGI("Create alarm"); 40 reminderRequest = new (std::nothrow) ReminderRequestAlarm(); 41 break; 42 } 43 case (ReminderRequest::ReminderType::CALENDAR): { 44 ANSR_LOGI("Create calendar"); 45 reminderRequest = new (std::nothrow) ReminderRequestCalendar(); 46 break; 47 } 48 default: { 49 ANSR_LOGE("Create ReminderRequest fail."); 50 return nullptr; 51 } 52 } 53 if (reminderRequest == nullptr) { 54 ANSR_LOGE("CreateReminderRequest fail."); 55 return nullptr; 56 } 57 reminderRequest->SetReminderType(reminderType); 58 return reminderRequest; 59 } 60 61 } // namespace Notification 62 } // namespace OHOS 63