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 operator ==OHOS::CalendarApi::Location49 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 struct Attendee { 62 string name; 63 string email; 64 optional<RoleType> role; operator ==OHOS::CalendarApi::Attendee65 bool operator==(const Attendee& other) const 66 { 67 return name == other.name && email == other.email && role.value_or(NONE) == other.role.value_or(NONE); 68 } 69 }; 70 71 enum RecurrenceType { 72 NORULE = -1, 73 YEARLY = 0, 74 MONTHLY = 1, 75 WEEKLY = 2, 76 DAILY = 3, 77 }; 78 79 struct RecurrenceRule { 80 RecurrenceType recurrenceFrequency; 81 optional<bool> enable; 82 optional<int64_t> expire; 83 optional<int64_t> count; 84 optional<int64_t> interval; 85 optional<vector<int64_t>> excludedDates; 86 optional<vector<int64_t>> daysOfWeek; 87 optional<vector<int64_t>> daysOfMonth ; 88 optional<vector<int64_t>> daysOfYear; 89 optional<vector<int64_t>> weeksOfMonth; 90 optional<vector<int64_t>> weeksOfYear; 91 optional<vector<int64_t>> monthsOfYear; 92 }; 93 94 struct EventService { 95 string type; 96 string uri; 97 optional<string> description; 98 }; 99 100 struct Event { 101 optional<int> id; 102 EventType type; 103 optional<Location> location; 104 optional<string> title; 105 int64_t startTime; 106 int64_t endTime; 107 optional<bool> isAllDay; 108 vector<Attendee> attendees; 109 optional<string> timeZone; 110 optional<vector<int>> reminderTime; 111 optional<RecurrenceRule> recurrenceRule; 112 optional<string> description; 113 optional<EventService> service; 114 optional<string> identifier; 115 optional<bool> isLunar; 116 }; 117 118 119 struct CalendarConfig { 120 optional<bool> enableReminder; 121 variant<string, int64_t> color; operator ==OHOS::CalendarApi::CalendarConfig122 bool operator==(const CalendarConfig& other) const 123 { 124 return enableReminder == other.enableReminder && color == other.color; 125 } 126 }; 127 128 } // namespace OHOS::CalendarApi 129 130 131 #endif