1 /* 2 * Copyright (c) 2022 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 #ifndef OHOS_ABILITYRUNTIME_ICONNECTION_OBSERVER_H 17 #define OHOS_ABILITYRUNTIME_ICONNECTION_OBSERVER_H 18 19 #include "connection_data.h" 20 21 #ifdef WITH_DLP 22 #include "dlp_state_data.h" 23 #endif // WITH_DLP 24 25 #include "iremote_broker.h" 26 27 namespace OHOS { 28 namespace AbilityRuntime { 29 /** 30 * @class IConnectionObserver 31 * IConnectionObserver is used to notify connection relationship of extension component. 32 */ 33 class IConnectionObserver : public OHOS::IRemoteBroker { 34 public: 35 DECLARE_INTERFACE_DESCRIPTOR(u"ohos.abilityruntime.connectionobserver"); 36 37 /** 38 * called when extension was connected. 39 * 40 * @param data connection relationship data. 41 */ 42 virtual void OnExtensionConnected(const ConnectionData &data) = 0; 43 44 /** 45 * called when extension was disconnected. 46 * 47 * @param data connection relationship data. 48 */ 49 virtual void OnExtensionDisconnected(const ConnectionData &data) = 0; 50 51 #ifdef WITH_DLP 52 /** 53 * called when dlp ability was started. 54 * 55 * @param data dlp state data. 56 */ 57 virtual void OnDlpAbilityOpened(const DlpStateData &data) = 0; 58 59 /** 60 * called when dlp ability was terminated. 61 * 62 * @param data dlp state data. 63 */ 64 virtual void OnDlpAbilityClosed(const DlpStateData &data) = 0; 65 #endif // WITH_DLP 66 67 enum ConnectionObserverCmd { 68 // ipc id for OnExtensionConnected 69 ON_EXTENSION_CONNECTED = 0, 70 71 // ipc id for OnExtensionDisconnected 72 ON_EXTENSION_DISCONNECTED, 73 74 #ifdef WITH_DLP 75 // ipc id for OnDlpAbilityOpened 76 ON_DLP_ABILITY_OPENED, 77 78 // ipc id for OnExtensionDisconnected 79 ON_DLP_ABILITY_CLOSED, 80 #endif // WITH_DLP 81 82 // maximum of enum 83 CMD_MAX 84 }; 85 }; 86 } // namespace AbilityRuntime 87 } // namespace OHOS 88 #endif // OHOS_ABILITYRUNTIME_ICONNECTION_OBSERVER_H 89