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