• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 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 #ifndef CALENDAR_DEFINE_H
17 #define CALENDAR_DEFINE_H
18 #include <string>
19 #include <string_view>
20 #include <vector>
21 #include <optional>
22 #include <variant>
23 
24 using std::string;
25 using std::string_view;
26 using std::vector;
27 using std::optional;
28 using std::variant;
29 
30 namespace OHOS::CalendarApi {
31 
32 struct CalendarAccount {
33     std::string name;  // readonly
34     std::string type;
35     optional<string> displayName;
36 };
37 
38 
39 enum EventType {
40     Normal = 0,
41     Important = 1
42 };
43 
44 struct Location {
45     optional<string> location;
46     optional<double> longitude;
47     optional<double> latitude;
48 
49     bool operator==(const Location& other) const
50     {
51         return location == other.location && longitude == other.longitude && latitude == other.latitude;
52     }
53 };
54 
55 enum RoleType  {
56     NONE = 0,
57     PARTICIPANT = 1,
58     ORGANIZER = 2,
59 };
60 
61 enum AttendeeStatus {
62     UNKNOWN = 0,
63     TENTATIVE = 1,
64     ACCEPTED = 2,
65     DECLINED = 3,
66     UNRESPONSIVE = 4,
67 };
68 
69 enum AttendeeType {
70     REQUIRED = 1,
71     OPTIONAL = 2,
72     RESOURCE = 3,
73 };
74 
75 struct Attendee {
76     string name;
77     string email;
78     optional<RoleType> role;
79     optional<AttendeeStatus> status;
80     optional<AttendeeType> type;
81     bool operator==(const Attendee& other) const
82     {
83         return name == other.name && email == other.email && role.value_or(NONE) == other.role.value_or(NONE) &&
84                status == other.status &&
85                type == other.type;
86     }
87 };
88 
89 enum RecurrenceType {
90     NORULE = -1,
91     YEARLY = 0,
92     MONTHLY = 1,
93     WEEKLY = 2,
94     DAILY = 3,
95 };
96 
97 struct RecurrenceRule {
98     RecurrenceType recurrenceFrequency;
99     optional<bool> enable;
100     optional<int64_t> expire;
101     optional<int64_t> count;
102     optional<int64_t> interval;
103     optional<vector<int64_t>> excludedDates;
104     optional<vector<int64_t>> daysOfWeek;
105     optional<vector<int64_t>> daysOfMonth ;
106     optional<vector<int64_t>> daysOfYear;
107     optional<vector<int64_t>> weeksOfMonth;
108     optional<vector<int64_t>> weeksOfYear;
109     optional<vector<int64_t>> monthsOfYear;
110 };
111 
112 struct EventService {
113     string type;
114     string uri;
115     optional<string> description;
116 };
117 
118 struct Event {
119     optional<int> id;
120     EventType type;
121     optional<Location> location;
122     optional<string> title;
123     int64_t startTime;
124     int64_t endTime;
125     optional<bool> isAllDay;
126     vector<Attendee> attendees;
127     optional<string> timeZone;
128     optional<vector<int>> reminderTime;
129     optional<RecurrenceRule> recurrenceRule;
130     optional<string> description;
131     optional<EventService> service;
132     optional<string> identifier;
133     optional<bool> isLunar;
134     optional<int64_t> instanceStartTime;
135     optional<int64_t> instanceEndTime;
136 };
137 
138 
139 struct CalendarConfig {
140     optional<bool> enableReminder;
141     variant<string, int64_t> color;
142     bool operator==(const CalendarConfig& other) const
143     {
144         return enableReminder == other.enableReminder && color == other.color;
145     }
146 };
147 
148 }  // namespace OHOS::CalendarApi
149 
150 
151 #endif