• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 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 OS_ACCOUNT_SERVICES_ACCOUNTMGR_INCLUDE_ACCOUNT_EVENT_SUBSCRIBE_H
17 #define OS_ACCOUNT_SERVICES_ACCOUNTMGR_INCLUDE_ACCOUNT_EVENT_SUBSCRIBE_H
18 
19 #include "account_error_no.h"
20 #include "account_info.h"
21 #ifdef HAS_CES_PART
22 #include "common_event_data.h"
23 #include "common_event_subscriber.h"
24 #include "common_event_subscribe_info.h"
25 #endif // HAS_CES_PART
26 
27 namespace OHOS {
28 namespace AccountSA {
29 #ifdef HAS_CES_PART
30 struct AccountCommonEventCallback {
31     std::function<void(const std::int32_t callingUid)> OnPackageRemoved;
32 };
33 
34 class AccountEventSubscriberCallback final : public EventFwk::CommonEventSubscriber {
35 public:
36     explicit AccountEventSubscriberCallback(
37         const EventFwk::CommonEventSubscribeInfo &subscribeInfo, const AccountCommonEventCallback &callback);
38     ~AccountEventSubscriberCallback() = default;
39 
40     void OnReceiveEvent(const EventFwk::CommonEventData &data) override;
41 
42 private:
43     AccountCommonEventCallback callback_;
44 };
45 class AccountEventSubscriber {
46 public:
47     explicit AccountEventSubscriber(const AccountCommonEventCallback &callback);
48     bool CreateEventSubscribe();
49     bool DestroyEventSubscribe();
50 
51 private:
52     AccountCommonEventCallback callback_;
53     std::shared_ptr<AccountEventSubscriberCallback> subscriber_ = nullptr;
54 };
55 #endif // HAS_CES_PART
56 } // namespace AccountSA
57 } // namespace OHOS
58 
59 #endif  // OS_ACCOUNT_SERVICES_ACCOUNTMGR_INCLUDE_ACCOUNT_EVENT_SUBSCRIBE_H