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//! Proxy for `Drag` service. 17f857971dSopenharmony_ci 18f857971dSopenharmony_ci#![allow(dead_code)] 19f857971dSopenharmony_ci#![allow(unused_variables)] 20f857971dSopenharmony_ci 21f857971dSopenharmony_ciuse std::ffi::{ c_char, CString }; 22f857971dSopenharmony_ciuse fusion_data_rust::{ Intention, DefaultReply, DragData }; 23f857971dSopenharmony_ciuse fusion_utils_rust::{ call_debug_enter, FusionResult, FusionErrorCode }; 24f857971dSopenharmony_ciuse fusion_ipc_client_rust::FusionIpcClient; 25f857971dSopenharmony_ciuse ipc_rust::{ MsgParcel, Deserialize }; 26f857971dSopenharmony_ciuse hilog_rust::{ debug, error, hilog, HiLogLabel, LogType }; 27f857971dSopenharmony_ci 28f857971dSopenharmony_ciconst LOG_LABEL: HiLogLabel = HiLogLabel { 29f857971dSopenharmony_ci log_type: LogType::LogCore, 30f857971dSopenharmony_ci domain: 0xD002220, 31f857971dSopenharmony_ci tag: "FusionDragClient" 32f857971dSopenharmony_ci}; 33f857971dSopenharmony_ci 34f857971dSopenharmony_ci/// Definition of proxy for `Drag` service. 35f857971dSopenharmony_ci#[derive(Default)] 36f857971dSopenharmony_cipub struct DragClient(i32); 37f857971dSopenharmony_ci 38f857971dSopenharmony_ciimpl DragClient { 39f857971dSopenharmony_ci /// Request service to change to [`DRAG`] mode. 40f857971dSopenharmony_ci pub fn start_drag(&self, drag_data: &DragData, ipc_client: &FusionIpcClient) -> FusionResult<i32> 41f857971dSopenharmony_ci { 42f857971dSopenharmony_ci call_debug_enter!("DragClient::start_drag"); 43f857971dSopenharmony_ci match MsgParcel::new() { 44f857971dSopenharmony_ci Some(mut reply_parcel) => { 45f857971dSopenharmony_ci let mut borrowed_reply_parcel = reply_parcel.borrowed(); 46f857971dSopenharmony_ci debug!(LOG_LABEL, "Call ipc_client::start()"); 47f857971dSopenharmony_ci ipc_client.start(Intention::Drag, drag_data, &mut borrowed_reply_parcel)?; 48f857971dSopenharmony_ci 49f857971dSopenharmony_ci match DefaultReply::deserialize(&borrowed_reply_parcel) { 50f857971dSopenharmony_ci Ok(x) => { 51f857971dSopenharmony_ci Ok(x.reply) 52f857971dSopenharmony_ci } 53f857971dSopenharmony_ci Err(_) => { 54f857971dSopenharmony_ci error!(LOG_LABEL, "Failed to deserialize DefaultReply"); 55f857971dSopenharmony_ci Err(FusionErrorCode::Fail) 56f857971dSopenharmony_ci } 57f857971dSopenharmony_ci } 58f857971dSopenharmony_ci } 59f857971dSopenharmony_ci None => { 60f857971dSopenharmony_ci error!(LOG_LABEL, "Can not instantiate MsgParcel"); 61f857971dSopenharmony_ci Err(FusionErrorCode::Fail) 62f857971dSopenharmony_ci } 63f857971dSopenharmony_ci } 64f857971dSopenharmony_ci } 65f857971dSopenharmony_ci} 66