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 CJ_CALENDAR_H 16 #define CJ_CALENDAR_H 17 18 #include <cstdint> 19 #include <vector> 20 #include "calendar_manager_ffi.h" 21 #include "cj_common_ffi.h" 22 #include "ffi_remote_data.h" 23 #include "cj_native_calendar.h" 24 25 namespace OHOS { 26 namespace CalendarApi { 27 std::vector<int64_t> ArrayI64ToVector(CArrI64 arr); 28 CArrI64 VectorToArrayI64(const std::vector<int64_t> &vec, int32_t* errcode); 29 char *IMallocCString(const std::string &origin); 30 class CJCalendar : public OHOS::FFI::FFIData { 31 DECL_TYPE(CJCalendar, OHOS::FFI::FFIData) 32 public: 33 explicit CJCalendar(std::shared_ptr<Native::CJNativeCalendar> calendar); 34 ~CJCalendar() override = default; 35 std::shared_ptr<Native::CJNativeCalendar>& GetNative(); 36 Event CEventToEvent(CEvent event); 37 void CArrAttendeeFree(CArrAttendee cArrAttendee); 38 void CRecurrenceRuleFree(CRecurrenceRule cRecurrenceRule); 39 void CArrEventfree(CArrEvents arr); 40 CArrEvents VectorToCArrEvents(std::vector<Event> events, int32_t* errcode); 41 RecurrenceRule BuildNativeRecurrenceRule(CRecurrenceRule recurrenceRule); 42 CRecurrenceRule BuildCRecurrenceRule(RecurrenceRule nativeRecurrenceRule, int32_t* errcode); 43 CLocation BuildCLocation(Location location); 44 CArrAttendee BuildCArrAttendee(vector<Attendee> attendees, int32_t* errcode); 45 int64_t AddEvent(CEvent event, int32_t* errcode); 46 void AddEvents(CArrEvents event, int32_t* errcode); 47 void DeleteEvent(int64_t eventId, int32_t* errcode); 48 void DeleteEvents(CArrI64 eventIds, int32_t* errcode); 49 void UpdateEvent(CEvent event, int32_t* errcode); 50 CArrEvents GetEvents(int64_t eventFilterId, CArrString eventKey, int32_t* errcode); 51 CCalendarConfig GetConfig(int32_t* errcode); 52 void SetConfig(CCalendarConfig config, int32_t* errcode); 53 CCalendarAccount GetAccount(int32_t* errcode); 54 std::shared_ptr<OHOS::CalendarApi::Native::CJNativeCalendar> calendar_ = nullptr; 55 }; 56 57 } 58 } 59 60 #endif // CJ_CALENDAR_H