• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 FOUNDATION_EVENT_CESFWK_SERVICES_INCLUDE_STATIC_SUBSCRIBER_CONNECTION_H
17 #define FOUNDATION_EVENT_CESFWK_SERVICES_INCLUDE_STATIC_SUBSCRIBER_CONNECTION_H
18 
19 #include "ability_connect_callback_stub.h"
20 #include "common_event_data.h"
21 #include "static_subscriber_proxy.h"
22 
23 namespace OHOS {
24 namespace EventFwk {
25 class StaticSubscriberConnection : public AAFwk::AbilityConnectionStub {
26 public:
27     /**
28      * Constructor.
29      *
30      * @param event, Indicates the common event data.
31      */
StaticSubscriberConnection(const CommonEventData & event)32     explicit StaticSubscriberConnection(const CommonEventData& event) : event_(event) {}
33 
34     /**
35      * OnAbilityConnectDone, Ability Manager Service notify caller ability the result of connect.
36      *
37      * @param element, Indicates elementName of service ability.
38      * @param remoteObject, Indicates the session proxy of service ability.
39      * @param resultCode, Returns ERR_OK on success, others on failure.
40      */
41     void OnAbilityConnectDone(
42         const AppExecFwk::ElementName &element, const sptr<IRemoteObject> &remoteObject, int resultCode) override;
43 
44     /**
45      * OnAbilityDisconnectDone, Ability Manager Service notify caller ability the result of disconnect.
46      *
47      * @param element, Indicates elementName of service ability.
48      * @param resultCode, Returns ERR_OK on success, others on failure.
49      */
50     void OnAbilityDisconnectDone(const AppExecFwk::ElementName &element, int resultCode) override;
51 
52 private:
53     sptr<StaticSubscriberProxy> proxy_ = nullptr;
54     CommonEventData event_;
55 };
56 }  // namespace EventFwk
57 }  // namespace OHOS
58 #endif  // FOUNDATION_EVENT_CESFWK_SERVICES_INCLUDE_STATIC_SUBSCRIBER_CONNECTION_H
59