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 /**
17 * @addtogroup Bluetooth
18 * @{
19 *
20 * @brief Defines map mce observer manager object.
21 *
22 */
23
24 /**
25 * @file map_mce_observer_manager.cpp
26 *
27 * @brief map mce observer manager file .
28 *
29 */
30
31 #include "map_mce_observer_manager.h"
32 #include "log.h"
33 #include "interface_profile_map_mce.h"
34
35 namespace OHOS {
36 namespace bluetooth {
MapMceObserverManager()37 MapMceObserverManager::MapMceObserverManager()
38 {
39 LOG_INFO("%{public}s execute", __PRETTY_FUNCTION__);
40 }
41
~MapMceObserverManager()42 MapMceObserverManager::~MapMceObserverManager()
43 {
44 LOG_INFO("%{public}s execute", __PRETTY_FUNCTION__);
45 }
46
RegisterObserver(IProfileMapMceObserver & serviceCallback)47 void MapMceObserverManager::RegisterObserver(IProfileMapMceObserver &serviceCallback)
48 {
49 LOG_INFO("%{public}s execute", __PRETTY_FUNCTION__);
50 observerMgrListMap_.Register(serviceCallback);
51 }
52
53 // rpc force disconnect , distroy all instance stm client
DeregisterObserver(IProfileMapMceObserver & serviceCallback)54 void MapMceObserverManager::DeregisterObserver(IProfileMapMceObserver &serviceCallback)
55 {
56 LOG_INFO("%{public}s execute", __PRETTY_FUNCTION__);
57 observerMgrListMap_.Register(serviceCallback);
58 }
59
ExcuteObserverOnMapActionCompleted(const std::string & device,const IProfileMapAction & action,MapExecuteStatus status)60 void MapMceObserverManager::ExcuteObserverOnMapActionCompleted(
61 const std::string &device, const IProfileMapAction &action, MapExecuteStatus status)
62 {
63 LOG_INFO("%{public}s enter", __PRETTY_FUNCTION__);
64 RawAddress tmpRawAddr(device);
65 observerMgrListMap_.ForEach([tmpRawAddr, action, status](IProfileMapMceObserver &observer) {
66 observer.OnMapActionCompleted(tmpRawAddr, action, status);
67 });
68 }
69
ExcuteObserverOnMapEventReported(const std::string & device,const IProfileMapEventReport & report)70 void MapMceObserverManager::ExcuteObserverOnMapEventReported(
71 const std::string &device, const IProfileMapEventReport &report)
72 {
73 LOG_INFO("%{public}s execute", __PRETTY_FUNCTION__);
74 RawAddress tmpRawAddr(device);
75 observerMgrListMap_.ForEach(
76 [tmpRawAddr, report](IProfileMapMceObserver &observer) { observer.OnMapEventReported(tmpRawAddr, report); });
77 }
78
ExcuteObserverOnConnectionStateChanged(const std::string & device,int state)79 void MapMceObserverManager::ExcuteObserverOnConnectionStateChanged(const std::string &device, int state)
80 {
81 LOG_INFO("%{public}s execute", __PRETTY_FUNCTION__);
82 RawAddress tmpRawAddr(device);
83 observerMgrListMap_.ForEach([tmpRawAddr, state](IProfileMapMceObserver &observer) {
84 observer.OnConnectionStateChanged(tmpRawAddr, state);
85 });
86 }
87
ExcuteObserverOnBmessageCompleted(const RawAddress & deviceAddress,const IProfileBMessage & bmsg,MapExecuteStatus status)88 void MapMceObserverManager::ExcuteObserverOnBmessageCompleted(
89 const RawAddress &deviceAddress, const IProfileBMessage &bmsg, MapExecuteStatus status)
90 {
91 LOG_INFO("%{public}s execute", __PRETTY_FUNCTION__);
92 RawAddress tmpRawAddr(deviceAddress);
93 observerMgrListMap_.ForEach([tmpRawAddr, bmsg, status](IProfileMapMceObserver &observer) {
94 observer.OnBmessageCompleted(tmpRawAddr, bmsg, status);
95 });
96 }
97
ExcuteObserverOnMessagesListingCompleted(const RawAddress & deviceAddress,const IProfileMessagesListing & listing,MapExecuteStatus status)98 void MapMceObserverManager::ExcuteObserverOnMessagesListingCompleted(
99 const RawAddress &deviceAddress, const IProfileMessagesListing &listing, MapExecuteStatus status)
100 {
101 LOG_INFO("%{public}s execute", __PRETTY_FUNCTION__);
102 RawAddress tmpRawAddr(deviceAddress);
103 observerMgrListMap_.ForEach([tmpRawAddr, listing, status](IProfileMapMceObserver &observer) {
104 observer.OnMessagesListingCompleted(tmpRawAddr, listing, status);
105 });
106 }
107
ExcuteObserverOnConversationListingCompleted(const RawAddress & deviceAddress,const IProfileConversationListing & listing,MapExecuteStatus status)108 void MapMceObserverManager::ExcuteObserverOnConversationListingCompleted(
109 const RawAddress &deviceAddress, const IProfileConversationListing &listing, MapExecuteStatus status)
110 {
111 LOG_INFO("%{public}s execute", __PRETTY_FUNCTION__);
112 RawAddress tmpRawAddr(deviceAddress);
113 observerMgrListMap_.ForEach([tmpRawAddr, listing, status](IProfileMapMceObserver &observer) {
114 observer.OnConversationListingCompleted(tmpRawAddr, listing, status);
115 });
116 }
117 } // namespace bluetooth
118 } // namespace OHOS
119