10fbfc30aSopenharmony_ci/*
20fbfc30aSopenharmony_ci * Copyright (c) 2022 Huawei Device Co., Ltd.
30fbfc30aSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
40fbfc30aSopenharmony_ci * you may not use this file except in compliance with the License.
50fbfc30aSopenharmony_ci * You may obtain a copy of the License at
60fbfc30aSopenharmony_ci *
70fbfc30aSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
80fbfc30aSopenharmony_ci *
90fbfc30aSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
100fbfc30aSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
110fbfc30aSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
120fbfc30aSopenharmony_ci * See the License for the specific language governing permissions and
130fbfc30aSopenharmony_ci * limitations under the License.
140fbfc30aSopenharmony_ci */
150fbfc30aSopenharmony_ci
160fbfc30aSopenharmony_ci#ifndef CALENDAR_DEFINE_H
170fbfc30aSopenharmony_ci#define CALENDAR_DEFINE_H
180fbfc30aSopenharmony_ci#include <string>
190fbfc30aSopenharmony_ci#include <string_view>
200fbfc30aSopenharmony_ci#include <vector>
210fbfc30aSopenharmony_ci#include <optional>
220fbfc30aSopenharmony_ci#include <variant>
230fbfc30aSopenharmony_ci
240fbfc30aSopenharmony_ciusing std::string;
250fbfc30aSopenharmony_ciusing std::string_view;
260fbfc30aSopenharmony_ciusing std::vector;
270fbfc30aSopenharmony_ciusing std::optional;
280fbfc30aSopenharmony_ciusing std::variant;
290fbfc30aSopenharmony_ci
300fbfc30aSopenharmony_cinamespace OHOS::CalendarApi {
310fbfc30aSopenharmony_ci
320fbfc30aSopenharmony_cistruct CalendarAccount {
330fbfc30aSopenharmony_ci    std::string name;  // readonly
340fbfc30aSopenharmony_ci    std::string type;
350fbfc30aSopenharmony_ci    optional<string> displayName;
360fbfc30aSopenharmony_ci};
370fbfc30aSopenharmony_ci
380fbfc30aSopenharmony_ci
390fbfc30aSopenharmony_cienum EventType {
400fbfc30aSopenharmony_ci    Normal = 0,
410fbfc30aSopenharmony_ci    Important = 1
420fbfc30aSopenharmony_ci};
430fbfc30aSopenharmony_ci
440fbfc30aSopenharmony_cistruct Location {
450fbfc30aSopenharmony_ci    optional<string> location;
460fbfc30aSopenharmony_ci    optional<double> longitude;
470fbfc30aSopenharmony_ci    optional<double> latitude;
480fbfc30aSopenharmony_ci
490fbfc30aSopenharmony_ci    bool operator==(const Location& other) const
500fbfc30aSopenharmony_ci    {
510fbfc30aSopenharmony_ci        return location == other.location && longitude == other.longitude && latitude == other.latitude;
520fbfc30aSopenharmony_ci    }
530fbfc30aSopenharmony_ci};
540fbfc30aSopenharmony_ci
550fbfc30aSopenharmony_cienum RoleType  {
560fbfc30aSopenharmony_ci    NONE = 0,
570fbfc30aSopenharmony_ci    PARTICIPANT = 1,
580fbfc30aSopenharmony_ci    ORGANIZER = 2,
590fbfc30aSopenharmony_ci};
600fbfc30aSopenharmony_ci
610fbfc30aSopenharmony_cistruct Attendee {
620fbfc30aSopenharmony_ci    string name;
630fbfc30aSopenharmony_ci    string email;
640fbfc30aSopenharmony_ci    optional<RoleType> role;
650fbfc30aSopenharmony_ci    bool operator==(const Attendee& other) const
660fbfc30aSopenharmony_ci    {
670fbfc30aSopenharmony_ci        return name == other.name && email == other.email && role.value_or(NONE) == other.role.value_or(NONE);
680fbfc30aSopenharmony_ci    }
690fbfc30aSopenharmony_ci};
700fbfc30aSopenharmony_ci
710fbfc30aSopenharmony_cienum RecurrenceType {
720fbfc30aSopenharmony_ci    NORULE = -1,
730fbfc30aSopenharmony_ci    YEARLY = 0,
740fbfc30aSopenharmony_ci    MONTHLY = 1,
750fbfc30aSopenharmony_ci    WEEKLY = 2,
760fbfc30aSopenharmony_ci    DAILY = 3,
770fbfc30aSopenharmony_ci};
780fbfc30aSopenharmony_ci
790fbfc30aSopenharmony_cistruct RecurrenceRule {
800fbfc30aSopenharmony_ci    RecurrenceType recurrenceFrequency;
810fbfc30aSopenharmony_ci    optional<bool> enable;
820fbfc30aSopenharmony_ci    optional<int64_t> expire;
830fbfc30aSopenharmony_ci    optional<int64_t> count;
840fbfc30aSopenharmony_ci    optional<int64_t> interval;
850fbfc30aSopenharmony_ci    optional<vector<int64_t>> excludedDates;
860fbfc30aSopenharmony_ci    optional<vector<int64_t>> daysOfWeek;
870fbfc30aSopenharmony_ci    optional<vector<int64_t>> daysOfMonth ;
880fbfc30aSopenharmony_ci    optional<vector<int64_t>> daysOfYear;
890fbfc30aSopenharmony_ci    optional<vector<int64_t>> weeksOfMonth;
900fbfc30aSopenharmony_ci    optional<vector<int64_t>> weeksOfYear;
910fbfc30aSopenharmony_ci    optional<vector<int64_t>> monthsOfYear;
920fbfc30aSopenharmony_ci};
930fbfc30aSopenharmony_ci
940fbfc30aSopenharmony_cistruct EventService {
950fbfc30aSopenharmony_ci    string type;
960fbfc30aSopenharmony_ci    string uri;
970fbfc30aSopenharmony_ci    optional<string> description;
980fbfc30aSopenharmony_ci};
990fbfc30aSopenharmony_ci
1000fbfc30aSopenharmony_cistruct Event {
1010fbfc30aSopenharmony_ci    optional<int> id;
1020fbfc30aSopenharmony_ci    EventType type;
1030fbfc30aSopenharmony_ci    optional<Location> location;
1040fbfc30aSopenharmony_ci    optional<string> title;
1050fbfc30aSopenharmony_ci    int64_t startTime;
1060fbfc30aSopenharmony_ci    int64_t endTime;
1070fbfc30aSopenharmony_ci    optional<bool> isAllDay;
1080fbfc30aSopenharmony_ci    vector<Attendee> attendees;
1090fbfc30aSopenharmony_ci    optional<string> timeZone;
1100fbfc30aSopenharmony_ci    optional<vector<int>> reminderTime;
1110fbfc30aSopenharmony_ci    optional<RecurrenceRule> recurrenceRule;
1120fbfc30aSopenharmony_ci    optional<string> description;
1130fbfc30aSopenharmony_ci    optional<EventService> service;
1140fbfc30aSopenharmony_ci    optional<string> identifier;
1150fbfc30aSopenharmony_ci    optional<bool> isLunar;
1160fbfc30aSopenharmony_ci};
1170fbfc30aSopenharmony_ci
1180fbfc30aSopenharmony_ci
1190fbfc30aSopenharmony_cistruct CalendarConfig {
1200fbfc30aSopenharmony_ci    optional<bool> enableReminder;
1210fbfc30aSopenharmony_ci    variant<string, int64_t> color;
1220fbfc30aSopenharmony_ci    bool operator==(const CalendarConfig& other) const
1230fbfc30aSopenharmony_ci    {
1240fbfc30aSopenharmony_ci        return enableReminder == other.enableReminder && color == other.color;
1250fbfc30aSopenharmony_ci    }
1260fbfc30aSopenharmony_ci};
1270fbfc30aSopenharmony_ci
1280fbfc30aSopenharmony_ci}  // namespace OHOS::CalendarApi
1290fbfc30aSopenharmony_ci
1300fbfc30aSopenharmony_ci
1310fbfc30aSopenharmony_ci#endif