1c2b37d2cSopenharmony_ci/*
2c2b37d2cSopenharmony_ci * Copyright (c) 2023 Huawei Device Co., Ltd.
3c2b37d2cSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4c2b37d2cSopenharmony_ci * you may not use this file except in compliance with the License.
5c2b37d2cSopenharmony_ci * You may obtain a copy of the License at
6c2b37d2cSopenharmony_ci *
7c2b37d2cSopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8c2b37d2cSopenharmony_ci *
9c2b37d2cSopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10c2b37d2cSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11c2b37d2cSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12c2b37d2cSopenharmony_ci * See the License for the specific language governing permissions and
13c2b37d2cSopenharmony_ci * limitations under the License.
14c2b37d2cSopenharmony_ci */
15c2b37d2cSopenharmony_ci
16c2b37d2cSopenharmony_ci#ifndef OS_ACCOUNT_SERVICES_ACCOUNTMGR_INCLUDE_ACCOUNT_EVENT_SUBSCRIBE_H
17c2b37d2cSopenharmony_ci#define OS_ACCOUNT_SERVICES_ACCOUNTMGR_INCLUDE_ACCOUNT_EVENT_SUBSCRIBE_H
18c2b37d2cSopenharmony_ci
19c2b37d2cSopenharmony_ci#include "account_error_no.h"
20c2b37d2cSopenharmony_ci#include "account_info.h"
21c2b37d2cSopenharmony_ci#ifdef HAS_CES_PART
22c2b37d2cSopenharmony_ci#include "common_event_data.h"
23c2b37d2cSopenharmony_ci#include "common_event_subscriber.h"
24c2b37d2cSopenharmony_ci#include "common_event_subscribe_info.h"
25c2b37d2cSopenharmony_ci#endif // HAS_CES_PART
26c2b37d2cSopenharmony_ci
27c2b37d2cSopenharmony_cinamespace OHOS {
28c2b37d2cSopenharmony_cinamespace AccountSA {
29c2b37d2cSopenharmony_ci#ifdef HAS_CES_PART
30c2b37d2cSopenharmony_cistruct AccountCommonEventCallback {
31c2b37d2cSopenharmony_ci    std::function<void(const std::int32_t callingUid)> OnPackageRemoved;
32c2b37d2cSopenharmony_ci};
33c2b37d2cSopenharmony_ci
34c2b37d2cSopenharmony_ciclass AccountEventSubscriberCallback final : public EventFwk::CommonEventSubscriber {
35c2b37d2cSopenharmony_cipublic:
36c2b37d2cSopenharmony_ci    explicit AccountEventSubscriberCallback(
37c2b37d2cSopenharmony_ci        const EventFwk::CommonEventSubscribeInfo &subscribeInfo, const AccountCommonEventCallback &callback);
38c2b37d2cSopenharmony_ci    ~AccountEventSubscriberCallback() = default;
39c2b37d2cSopenharmony_ci
40c2b37d2cSopenharmony_ci    void OnReceiveEvent(const EventFwk::CommonEventData &data) override;
41c2b37d2cSopenharmony_ci
42c2b37d2cSopenharmony_ciprivate:
43c2b37d2cSopenharmony_ci    AccountCommonEventCallback callback_;
44c2b37d2cSopenharmony_ci};
45c2b37d2cSopenharmony_ciclass AccountEventSubscriber {
46c2b37d2cSopenharmony_cipublic:
47c2b37d2cSopenharmony_ci    explicit AccountEventSubscriber(const AccountCommonEventCallback &callback);
48c2b37d2cSopenharmony_ci    ~AccountEventSubscriber();
49c2b37d2cSopenharmony_ci    bool CreateEventSubscribe();
50c2b37d2cSopenharmony_ci    bool DestroyEventSubscribe();
51c2b37d2cSopenharmony_ci
52c2b37d2cSopenharmony_ciprivate:
53c2b37d2cSopenharmony_ci    AccountCommonEventCallback callback_;
54c2b37d2cSopenharmony_ci    std::shared_ptr<AccountEventSubscriberCallback> subscriber_ = nullptr;
55c2b37d2cSopenharmony_ci};
56c2b37d2cSopenharmony_ci#endif // HAS_CES_PART
57c2b37d2cSopenharmony_ci} // namespace AccountSA
58c2b37d2cSopenharmony_ci} // namespace OHOS
59c2b37d2cSopenharmony_ci
60c2b37d2cSopenharmony_ci#endif  // OS_ACCOUNT_SERVICES_ACCOUNTMGR_INCLUDE_ACCOUNT_EVENT_SUBSCRIBE_H