1 /* 2 * Copyright (c) 2020 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 16 /** 17 * @addtogroup AbilityKit 18 * @{ 19 * 20 * @brief Provides ability-related functions, including ability lifecycle callbacks and functions for connecting to or 21 * disconnecting from Particle Abilities. 22 * 23 * Abilities are classified into Feature Abilities and Particle Abilities. Feature Abilities support the Page template, 24 * and Particle Abilities support the Service template. An ability using the Page template is called a Page ability for 25 * short and that using the Service template is called a Service ability. 26 * 27 * @since 1.0 28 * @version 1.0 29 */ 30 31 /** 32 * @file ability_connection.h 33 * @brief Declares callbacks to be invoked when a remote Service ability is connected or disconnected. 34 * 35 * You must override the callbacks provided in {@link IAbilityConnection} to implement your processing logic for 36 * Service connection and disconnection. 37 * 38 * @since 1.0 39 * @version 1.0 40 */ 41 42 #ifndef OHOS_ABILITY_CONNECTION_H 43 #define OHOS_ABILITY_CONNECTION_H 44 45 #include "element_name.h" 46 #include "liteipc_adapter.h" 47 48 typedef struct IAbilityConnection IAbilityConnection; 49 50 /** 51 * @brief Provides callbacks to be invoked when a remote Service ability is connected or disconnected. 52 */ 53 struct IAbilityConnection { 54 /** 55 * @brief Called when a client is connected to a Service ability. 56 * 57 * This callback is invoked to receive the connection result after a client is connected to a Service ability. 58 * 59 * @param elementName Indicates the pointer to the information about the connected Service ability. 60 * @param serviceSid Indicates the pointer to the remote proxy object of the Service ability. 61 * @param resultCode Indicates the connection result code. The value <b>0</b> indicates a successful connection, 62 * and any other value indicates a connection failure. 63 * @param data Indicates the pointer to the data stored during the connection. 64 */ 65 void (*OnAbilityConnectDone)(ElementName *elementName, SvcIdentity *serviceSid, int resultCode, void *data); 66 67 /** 68 * @brief Called after all connections to a Service ability are disconnected. 69 * 70 * This callback is invoked to receive the disconnection result after the connected Service ability crashes or is 71 * killed. If the Service ability exits unexpectedly, all its connections are disconnected, and each ability 72 * previously connected to it will call 73 * {@link OnAbilityDisconnectDone(ElementName *elementName, int resultCode, void *data)}. 74 * 75 * @param elementName Indicates the pointer to the information about the disconnected Service ability. 76 * @param resultCode Indicates the disconnection result code. The value <b>0</b> indicates a successful 77 * disconnection, and any other value indicates a disconnection failure. 78 * @param data Indicates the pointer to the data stored during the connection. 79 */ 80 void (*OnAbilityDisconnectDone)(ElementName *elementName, int resultCode, void *data); 81 }; 82 #endif // OHOS_ABILITY_CONNECTION_H 83