1f857971dSopenharmony_ci/* 2f857971dSopenharmony_ci * Copyright (C) 2023 Huawei Device Co., Ltd. 3f857971dSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4f857971dSopenharmony_ci * you may not use this file except in compliance with the License. 5f857971dSopenharmony_ci * You may obtain a copy of the License at 6f857971dSopenharmony_ci * 7f857971dSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8f857971dSopenharmony_ci * 9f857971dSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10f857971dSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11f857971dSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12f857971dSopenharmony_ci * See the License for the specific language governing permissions and 13f857971dSopenharmony_ci * limitations under the License. 14f857971dSopenharmony_ci */ 15f857971dSopenharmony_ci 16f857971dSopenharmony_ci//! Plugin manager related definitions. 17f857971dSopenharmony_ci 18f857971dSopenharmony_ciuse std::any::Any; 19f857971dSopenharmony_ci 20f857971dSopenharmony_ciuse ipc_rust::BorrowedMsgParcel; 21f857971dSopenharmony_ci 22f857971dSopenharmony_ciuse fusion_utils_rust::{ define_enum, FusionResult, FusionErrorCode }; 23f857971dSopenharmony_ci 24f857971dSopenharmony_ciuse crate::CallingContext; 25f857971dSopenharmony_ci 26f857971dSopenharmony_cidefine_enum! { 27f857971dSopenharmony_ci Intention { 28f857971dSopenharmony_ci Basic, 29f857971dSopenharmony_ci Drag, 30f857971dSopenharmony_ci Coordination 31f857971dSopenharmony_ci } 32f857971dSopenharmony_ci} 33f857971dSopenharmony_ci 34f857971dSopenharmony_ci/// Interface between service modules and intention framework. 35f857971dSopenharmony_cipub trait IPlugin: Any + Send + Sync + std::panic::RefUnwindSafe { 36f857971dSopenharmony_ci /// Enable this service. 37f857971dSopenharmony_ci fn enable(&self, context: &CallingContext, data: &BorrowedMsgParcel, reply: &mut BorrowedMsgParcel) -> FusionResult<()>; 38f857971dSopenharmony_ci /// Disable this service. 39f857971dSopenharmony_ci fn disable(&self, context: &CallingContext, data: &BorrowedMsgParcel, reply: &mut BorrowedMsgParcel) -> FusionResult<()>; 40f857971dSopenharmony_ci /// Start work of this service. 41f857971dSopenharmony_ci fn start(&self, context: &CallingContext, data: &BorrowedMsgParcel, reply: &mut BorrowedMsgParcel) -> FusionResult<()>; 42f857971dSopenharmony_ci /// Stop work of this service. 43f857971dSopenharmony_ci fn stop(&self, context: &CallingContext, data: &BorrowedMsgParcel, reply: &mut BorrowedMsgParcel) -> FusionResult<()>; 44f857971dSopenharmony_ci /// Add a watch to a state of this service. 45f857971dSopenharmony_ci fn add_watch(&self, context: &CallingContext, id: u32, data: &BorrowedMsgParcel, reply: &mut BorrowedMsgParcel) -> FusionResult<()>; 46f857971dSopenharmony_ci /// Remove a watch to a state of this service. 47f857971dSopenharmony_ci fn remove_watch(&self, context: &CallingContext, id: u32, data: &BorrowedMsgParcel, reply: &mut BorrowedMsgParcel) -> FusionResult<()>; 48f857971dSopenharmony_ci /// Set a paramenter of this service. 49f857971dSopenharmony_ci fn set_param(&self, context: &CallingContext, id: u32, data: &BorrowedMsgParcel, reply: &mut BorrowedMsgParcel) -> FusionResult<()>; 50f857971dSopenharmony_ci /// Get a parameter of this service. 51f857971dSopenharmony_ci fn get_param(&self, context: &CallingContext, id: u32, data: &BorrowedMsgParcel, reply: &mut BorrowedMsgParcel) -> FusionResult<()>; 52f857971dSopenharmony_ci /// Interact with this service. This interface supplements functions of previous intefaces. 53f857971dSopenharmony_ci /// Functionalities of this interface is service spicific. 54f857971dSopenharmony_ci fn control(&self, context: &CallingContext, id: u32, data: &BorrowedMsgParcel, reply: &mut BorrowedMsgParcel) -> FusionResult<()>; 55f857971dSopenharmony_ci} 56