• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 #ifndef NATIVE_CALENDAR_H
17 #define NATIVE_CALENDAR_H
18 #include <vector>
19 #include "calendar_define.h"
20 #include "event_filter.h"
21 #include "uri.h"
22 using Uri = OHOS::Uri;
23 namespace OHOS::CalendarApi::Native {
24 class Calendar final {
25 public:
26     Calendar(int id);
27     Calendar(CalendarAccount account, int id);
Calendar(Calendar && other)28     Calendar(Calendar&& other) : m_account(std::move(other.m_account)), m_id(other.m_id)
29     {
30     }
Calendar(const Calendar & other)31     Calendar(const Calendar& other) : m_account(other.m_account), m_id(other.m_id)
32     {
33     }
34 
35     Calendar() = delete;
36     ~Calendar() = default;
37     int AddEvent(const Event& event);
38     int AddEvents(const std::vector<Event>& events);
39     bool DeleteEvent(int id);
40     int DeleteEvents(const std::vector<int>& id);
41     void DeleteAllEvents();
42     bool UpdateEvent(const Event& event);
43     int UpdateEvents(const std::vector<Event>& events);
44     CalendarConfig GetConfig();
45     bool SetConfig(const CalendarConfig& config);
46     std::vector<Event> GetEvents(std::shared_ptr<EventFilter> filter, const std::vector<string>& eventKey);
47     std::vector<Attendee> GetAttendeesByEventId(int id);
48     std::optional<std::vector<int>> GetRemindersByEventId(int id);
49     void InsertReminders(int eventId, vector<int> reminders);
GetAccount()50     CalendarAccount GetAccount() const
51     {
52         return m_account;
53     }
GetId()54     int GetId() const
55     {
56         return m_id;
57     }
58 private:
59     CalendarAccount m_account;
60     CalendarConfig m_config;
61     int m_id;
62     std::unique_ptr<Uri> m_eventUri;
63     std::unique_ptr<Uri> m_attendeeUri;
64     std::unique_ptr<Uri> m_calendarUri;
65     std::unique_ptr<Uri> m_reminderUrl;
66 };
67 }  // namespace OHOS::Calendar
68 #endif  //  NATIVE_CALENDAR_H