1 /* 2 * Copyright (c) 2025 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 #ifndef CALENDAR_MANAGER_FFI_H 16 #define CALENDAR_MANAGER_FFI_H 17 #include <cstdint> 18 #include <string> 19 #include <vector> 20 #include "cj_common_ffi.h" 21 #include "ffi_remote_data.h" 22 #include "cj_native_util.h" 23 24 extern "C" { 25 struct CCalendarAccount { 26 char* name; 27 char* type; 28 char* displayName; 29 }; 30 31 struct CLocation { 32 char* location; 33 double longitude; 34 double latitude; 35 }; 36 37 struct CAttendee { 38 char* name; 39 char* email; 40 int64_t role; 41 }; 42 43 struct CArrAttendee { 44 CAttendee* head; 45 int64_t size; 46 }; 47 48 struct CRecurrenceRule { 49 int64_t recurrenceFrequency; 50 int64_t expire; 51 int64_t count; 52 int64_t interval; 53 CArrI64 excludedDates; 54 CArrI64 daysOfWeek; 55 CArrI64 daysOfMonth ; 56 CArrI64 daysOfYear; 57 CArrI64 weeksOfMonth; 58 CArrI64 weeksOfYear; 59 CArrI64 monthsOfYear; 60 }; 61 62 struct CEventService { 63 char* type; 64 char* uri; 65 char* description; 66 }; 67 68 struct CEvent { 69 int64_t type; 70 int64_t startTime; 71 int64_t endTime; 72 int64_t id; 73 char* title; 74 CLocation location; 75 bool isAllDay; 76 CArrAttendee attendee; 77 char* timeZone; 78 CArrI64 reminderTime; 79 CRecurrenceRule recurrenceRule; 80 char* description; 81 CEventService service; 82 char* identifier; 83 bool isLunar; 84 }; 85 86 struct CArrEvents { 87 CEvent* head; 88 int64_t size; 89 }; 90 91 struct CCalendarConfig { 92 bool enableReminder; 93 int64_t color; 94 }; 95 96 const int32_t CJ_ERR_ILLEGAL_INSTANCE = -1; 97 const int32_t CJ_ERR_OUT_OF_MEMORY = -2; 98 const int32_t CJ_ERR_NULL_PTR = -3; 99 100 // calendar manager 101 FFI_EXPORT void FfiOHOSGetCalendarManager(int64_t contextId, int32_t* errcode); 102 FFI_EXPORT int64_t FfiOHOSCalendarManagerCreateCalendar( 103 CCalendarAccount calendarAccount, int64_t* calendarId, int32_t* errcode); 104 FFI_EXPORT void FfiOHOSCalendarManagerdeleteCalendar(int64_t calendarId, int32_t* errcode); 105 FFI_EXPORT int64_t FfiOHOSCalendarManagerGetCalendar( 106 CCalendarAccount calendarAccount, int64_t* calendarId, int32_t* errcode); 107 FFI_EXPORT CArrI64 FfiOHOSCalendarManagerGetAllCalendars(int32_t* errcode); 108 FFI_EXPORT int64_t FfiOHOSCalendarManagerEditerEvent(char* eventstr, int32_t* errcode); 109 // calendar 110 FFI_EXPORT int64_t FfiOHOSCalendarAddEvent(int64_t id, CEvent event, int32_t* errcode); 111 FFI_EXPORT void FfiOHOSCalendarAddEvents(int64_t id, CArrEvents event, int32_t* errcode); 112 FFI_EXPORT void FfiOHOSCalendarDeleteEvent(int64_t id, int64_t eventId, int32_t* errcode); 113 FFI_EXPORT void FfiOHOSCalendarDeleteEvents(int64_t id, CArrI64 eventIds, int32_t* errcode); 114 FFI_EXPORT void FfiOHOSCalendarUpdateEvent(int64_t id, CEvent event, int32_t* errcode); 115 FFI_EXPORT CArrEvents FfiOHOSCalendarGetEvents( 116 int64_t id, int64_t eventFilterId, CArrString eventKey, int32_t* errcode); 117 FFI_EXPORT CCalendarConfig FfiOHOSCalendarGetConfig(int64_t id, int32_t* errcode); 118 FFI_EXPORT void FfiOHOSCalendarSetConfig(int64_t id, CCalendarConfig cCalendarConfig, int32_t* errcode); 119 FFI_EXPORT CCalendarAccount FfiOHOSCalendarGetAccount(int64_t id, int32_t* errcode); 120 //event filter 121 FFI_EXPORT int64_t FfiOHOSEventFilterFilterById(CArrI64 idsCArr, int32_t* errcode); 122 FFI_EXPORT int64_t FfiOHOSEventFilterFilterByTime(int64_t startTime, int64_t end, int32_t* errcode); 123 FFI_EXPORT int64_t FfiOHOSEventFilterFilterByTitle(char* title, int32_t* errcode); 124 } 125 126 #endif