• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2022-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 #include "interaction_manager.h"
17 
18 #include "devicestatus_define.h"
19 #include "drag_data.h"
20 #ifdef OHOS_BUILD_ENABLE_INTENTION_FRAMEWORK
21 #include "intention_manager.h"
22 #else
23 #include "interaction_manager_impl.h"
24 #endif // OHOS_BUILD_ENABLE_INTENTION_FRAMEWORK
25 
26 namespace OHOS {
27 namespace Msdp {
28 namespace DeviceStatus {
29 
30 InteractionManager *InteractionManager::instance_ = new (std::nothrow) InteractionManager();
31 
GetInstance()32 InteractionManager *InteractionManager::GetInstance()
33 {
34     return instance_;
35 }
36 
RegisterCoordinationListener(std::shared_ptr<ICoordinationListener> listener,bool isCompatible)37 int32_t InteractionManager::RegisterCoordinationListener(std::shared_ptr<ICoordinationListener> listener,
38     bool isCompatible)
39 {
40     return INTER_MGR_IMPL.RegisterCoordinationListener(listener, isCompatible);
41 }
42 
UnregisterCoordinationListener(std::shared_ptr<ICoordinationListener> listener,bool isCompatible)43 int32_t InteractionManager::UnregisterCoordinationListener(std::shared_ptr<ICoordinationListener> listener,
44     bool isCompatible)
45 {
46     return INTER_MGR_IMPL.UnregisterCoordinationListener(listener, isCompatible);
47 }
48 
PrepareCoordination(std::function<void (const std::string &,CoordinationMessage)> callback,bool isCompatible)49 int32_t InteractionManager::PrepareCoordination(std::function<void(const std::string&, CoordinationMessage)> callback,
50     bool isCompatible)
51 {
52     return INTER_MGR_IMPL.PrepareCoordination(callback, isCompatible);
53 }
54 
UnprepareCoordination(std::function<void (const std::string &,CoordinationMessage)> callback,bool isCompatible)55 int32_t InteractionManager::UnprepareCoordination(std::function<void(const std::string&, CoordinationMessage)> callback,
56     bool isCompatible)
57 {
58     return INTER_MGR_IMPL.UnprepareCoordination(callback, isCompatible);
59 }
60 
ActivateCoordination(const std::string & remoteNetworkId,int32_t startDeviceId,std::function<void (const std::string &,CoordinationMessage)> callback,bool isCompatible)61 int32_t InteractionManager::ActivateCoordination(const std::string &remoteNetworkId, int32_t startDeviceId,
62     std::function<void(const std::string&, CoordinationMessage)> callback, bool isCompatible)
63 {
64     return INTER_MGR_IMPL.ActivateCoordination(remoteNetworkId, startDeviceId, callback, isCompatible);
65 }
66 
DeactivateCoordination(bool isUnchained,std::function<void (const std::string &,CoordinationMessage)> callback,bool isCompatible)67 int32_t InteractionManager::DeactivateCoordination(bool isUnchained,
68     std::function<void(const std::string&, CoordinationMessage)> callback, bool isCompatible)
69 {
70     return INTER_MGR_IMPL.DeactivateCoordination(isUnchained, callback, isCompatible);
71 }
72 
GetCoordinationState(const std::string & networkId,std::function<void (bool)> callback,bool isCompatible)73 int32_t InteractionManager::GetCoordinationState(
74     const std::string &networkId, std::function<void(bool)> callback, bool isCompatible)
75 {
76     return INTER_MGR_IMPL.GetCoordinationState(networkId, callback, isCompatible);
77 }
78 
UpdateDragStyle(DragCursorStyle style)79 int32_t InteractionManager::UpdateDragStyle(DragCursorStyle style)
80 {
81     return INTER_MGR_IMPL.UpdateDragStyle(style);
82 }
83 
StartDrag(const DragData & dragData,std::shared_ptr<IStartDragListener> listener)84 int32_t InteractionManager::StartDrag(const DragData &dragData, std::shared_ptr<IStartDragListener> listener)
85 {
86     return INTER_MGR_IMPL.StartDrag(dragData, listener);
87 }
88 
StopDrag(const DragDropResult & dropResult)89 int32_t InteractionManager::StopDrag(const DragDropResult &dropResult)
90 {
91     return INTER_MGR_IMPL.StopDrag(dropResult);
92 }
93 
GetDragTargetPid()94 int32_t InteractionManager::GetDragTargetPid()
95 {
96     return INTER_MGR_IMPL.GetDragTargetPid();
97 }
98 
GetUdKey(std::string & udKey)99 int32_t InteractionManager::GetUdKey(std::string &udKey)
100 {
101     return INTER_MGR_IMPL.GetUdKey(udKey);
102 }
103 
AddDraglistener(DragListenerPtr listener)104 int32_t InteractionManager::AddDraglistener(DragListenerPtr listener)
105 {
106     return INTER_MGR_IMPL.AddDraglistener(listener);
107 }
108 
RemoveDraglistener(DragListenerPtr listener)109 int32_t InteractionManager::RemoveDraglistener(DragListenerPtr listener)
110 {
111     return INTER_MGR_IMPL.RemoveDraglistener(listener);
112 }
113 
AddSubscriptListener(SubscriptListenerPtr listener)114 int32_t InteractionManager::AddSubscriptListener(SubscriptListenerPtr listener)
115 {
116     return INTER_MGR_IMPL.AddSubscriptListener(listener);
117 }
118 
RemoveSubscriptListener(SubscriptListenerPtr listener)119 int32_t InteractionManager::RemoveSubscriptListener(SubscriptListenerPtr listener)
120 {
121     return INTER_MGR_IMPL.RemoveSubscriptListener(listener);
122 }
123 
SetDragWindowVisible(bool visible,bool isForce)124 int32_t InteractionManager::SetDragWindowVisible(bool visible, bool isForce)
125 {
126     return INTER_MGR_IMPL.SetDragWindowVisible(visible, isForce);
127 }
128 
GetShadowOffset(int32_t & offsetX,int32_t & offsetY,int32_t & width,int32_t & height)129 int32_t InteractionManager::GetShadowOffset(int32_t &offsetX, int32_t &offsetY, int32_t &width, int32_t &height)
130 {
131     return INTER_MGR_IMPL.GetShadowOffset(offsetX, offsetY, width, height);
132 }
133 
UpdateShadowPic(const ShadowInfo & shadowInfo)134 int32_t InteractionManager::UpdateShadowPic(const ShadowInfo &shadowInfo)
135 {
136     return INTER_MGR_IMPL.UpdateShadowPic(shadowInfo);
137 }
138 
GetDragData(DragData & dragData)139 int32_t InteractionManager::GetDragData(DragData &dragData)
140 {
141     return INTER_MGR_IMPL.GetDragData(dragData);
142 }
143 
GetDragState(DragState & dragState)144 int32_t InteractionManager::GetDragState(DragState &dragState)
145 {
146     return INTER_MGR_IMPL.GetDragState(dragState);
147 }
148 
AddHotAreaListener(std::shared_ptr<IHotAreaListener> listener)149 int32_t InteractionManager::AddHotAreaListener(std::shared_ptr<IHotAreaListener> listener)
150 {
151     return INTER_MGR_IMPL.AddHotAreaListener(listener);
152 }
153 
RemoveHotAreaListener(std::shared_ptr<IHotAreaListener> listener)154 int32_t InteractionManager::RemoveHotAreaListener(std::shared_ptr<IHotAreaListener> listener)
155 {
156     return INTER_MGR_IMPL.RemoveHotAreaListener(listener);
157 }
158 
UpdatePreviewStyle(const PreviewStyle & previewStyle)159 int32_t InteractionManager::UpdatePreviewStyle(const PreviewStyle &previewStyle)
160 {
161     return INTER_MGR_IMPL.UpdatePreviewStyle(previewStyle);
162 }
163 
UpdatePreviewStyleWithAnimation(const PreviewStyle & previewStyle,const PreviewAnimation & animation)164 int32_t InteractionManager::UpdatePreviewStyleWithAnimation(const PreviewStyle &previewStyle,
165     const PreviewAnimation &animation)
166 {
167     return INTER_MGR_IMPL.UpdatePreviewStyleWithAnimation(previewStyle, animation);
168 }
169 
GetDragSummary(std::map<std::string,int64_t> & summarys)170 int32_t InteractionManager::GetDragSummary(std::map<std::string, int64_t> &summarys)
171 {
172     return INTER_MGR_IMPL.GetDragSummary(summarys);
173 }
174 
GetDragAction(DragAction & dragAction)175 int32_t InteractionManager::GetDragAction(DragAction &dragAction)
176 {
177     return INTER_MGR_IMPL.GetDragAction(dragAction);
178 }
179 
EnterTextEditorArea(bool enable)180 int32_t InteractionManager::EnterTextEditorArea(bool enable)
181 {
182     return INTER_MGR_IMPL.EnterTextEditorArea(enable);
183 }
184 
GetExtraInfo(std::string & extraInfo)185 int32_t InteractionManager::GetExtraInfo(std::string &extraInfo)
186 {
187     return INTER_MGR_IMPL.GetExtraInfo(extraInfo);
188 }
189 
AddPrivilege()190 int32_t InteractionManager::AddPrivilege()
191 {
192     return INTER_MGR_IMPL.AddPrivilege();
193 }
194 } // namespace DeviceStatus
195 } // namespace Msdp
196 } // namespace OHOS
197