• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 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 FM_IMMS_PROJECT_IMCOMMONEVENTMANAGER_H
17 #define FM_IMMS_PROJECT_IMCOMMONEVENTMANAGER_H
18 
19 #include <mutex>
20 #include "common_event_subscriber.h"
21 #include "common_event_subscribe_info.h"
22 #include "common_event_data.h"
23 #include "matching_skills.h"
24 
25 namespace OHOS {
26 namespace MiscServices {
27 class ImCommonEventManager : public RefBase {
28 public:
29     ImCommonEventManager();
30     ~ImCommonEventManager();
31     static sptr<ImCommonEventManager> GetInstance();
32     bool SubscribeEvent(const std::string &event);
33     bool UnsubscribeEvent();
34 
35     class EventSubscriber : public EventFwk::CommonEventSubscriber {
36     public:
EventSubscriber(const EventFwk::CommonEventSubscribeInfo & subscribeInfo)37         EventSubscriber(const EventFwk::CommonEventSubscribeInfo &subscribeInfo)
38             : EventFwk::CommonEventSubscriber(subscribeInfo) {}
39         void OnReceiveEvent(const EventFwk::CommonEventData &data);
40         void startUser(int32_t newUserId);
41     };
42 
43 private:
44     static std::mutex instanceLock_;
45     static sptr<ImCommonEventManager> instance_;
46 };
47 } // namespace MiscServices
48 } // namespace OHOS
49 #endif // FM_IMMS_PROJECT_IPLATFORMCALLBACK_H
50