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