1 /*
2  * Copyright (c) 2024 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_IDISTRIBUTED_ACCOUNT_SUBSCRIBE_H
17 #define OS_ACCOUNT_SERVICES_ACCOUNTMGR_INCLUDE_IDISTRIBUTED_ACCOUNT_SUBSCRIBE_H
18 
19 #include "account_error_no.h"
20 #include "distributed_account_subscribe_callback.h"
21 #include "iremote_object.h"
22 
23 namespace OHOS {
24 namespace AccountSA {
25 struct DistributedSubscribeRecord {
26     sptr<IRemoteObject> eventListener_;
27     std::set<DISTRIBUTED_ACCOUNT_SUBSCRIBE_TYPE> types_;
28 
DistributedSubscribeRecordDistributedSubscribeRecord29     DistributedSubscribeRecord() : eventListener_(nullptr)
30     {}
DistributedSubscribeRecordDistributedSubscribeRecord31     DistributedSubscribeRecord(sptr<IRemoteObject> eventListener) : eventListener_(eventListener)
32     {}
33 };
34 
35 using DistributedSubscribeRecordPtr = std::shared_ptr<DistributedSubscribeRecord>;
36 
37 class IDistributedAccountSubscribe {
38 public:
39     virtual ErrCode SubscribeDistributedAccountEvent(const DISTRIBUTED_ACCOUNT_SUBSCRIBE_TYPE type,
40         const sptr<IRemoteObject> &eventListener) = 0;
41     virtual ErrCode UnsubscribeDistributedAccountEvent(const DISTRIBUTED_ACCOUNT_SUBSCRIBE_TYPE type,
42         const sptr<IRemoteObject> &eventListener) = 0;
43     virtual ErrCode UnsubscribeDistributedAccountEvent(const sptr<IRemoteObject> &eventListener) = 0;
44     virtual ErrCode Publish(const int id, DISTRIBUTED_ACCOUNT_SUBSCRIBE_TYPE subscribeType) = 0;
45 };
46 }  // namespace AccountSA
47 }  // namespace OHOS
48 
49 #endif  // OS_ACCOUNT_SERVICES_ACCOUNTMGR_INCLUDE_IDISTRIBUTED_ACCOUNT_SUBSCRIBE_H
50