• 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 
45 struct Location {
46     optional<string> location;
47     optional<int> longitude;
48     optional<int> latitude;
49 
50     bool operator==(const Location& other) const
51     {
52         return location == other.location && longitude == other.longitude && latitude == other.latitude;
53     }
54 };
55 
56 struct Attendee {
57     string name;
58     string email;
59     bool operator==(const Attendee& other) const
60     {
61         return name == other.name && email == other.email;
62     }
63 };
64 
65 enum RecurrenceType {
66     YEARLY = 0,
67     MONTHLY = 1,
68     WEEKLY = 2,
69     DAILY = 3,
70 };
71 
72 struct RecurrenceRule {
73     RecurrenceType recurrenceFrequency;
74     optional<bool> enable;
75     optional<int> expire;
76 };
77 
78 struct EventService {
79     string type;
80     string uri;
81     optional<string> description;
82 };
83 
84 struct Event {
85     optional<int> id;
86     EventType type;
87     optional<Location> location;
88     optional<string> title;
89     int64_t startTime;
90     int64_t endTime;
91     optional<bool> isAllDay;
92     vector<Attendee> attendees;
93     optional<string> timeZone;
94     optional<vector<int>> reminderTime;
95     optional<RecurrenceRule> recurrenceRule;
96     optional<string> description;
97     optional<EventService> service;
98 };
99 
100 
101 struct CalendarConfig {
102     optional<bool> enableReminder;
103     variant<string, int64_t> color;
104     bool operator==(const CalendarConfig& other) const
105     {
106         return enableReminder == other.enableReminder && color == other.color;
107     }
108 };
109 
110 }  // namespace OHOS::CalendarApi
111 
112 
113 #endif