1 /*
2  * Copyright (c) 2023 Shenzhen Kaihong Digital Industry Development 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 OHOS_SHARING_SCENE_SERVICE_H
17 #define OHOS_SHARING_SCENE_SERVICE_H
18 
19 #include <memory>
20 #include "scene_format.h"
21 
22 namespace OHOS {
23 namespace Sharing {
24 
25 class SceneServiceListener {
26 public:
27     using Ptr = std::shared_ptr<SceneServiceListener>;
28 
29     virtual ~SceneServiceListener() = default;
30 
31     virtual int32_t OnServiceInfo(SceneFormat &formatData, SceneFormat &formatReply) = 0;
32 };
33 
34 class SceneService {
35 public:
36     using Ptr = std::shared_ptr<SceneService>;
37 
38     virtual ~SceneService() = default;
39 
GetInteractionId()40     uint32_t GetInteractionId()
41     {
42         SHARING_LOGD("trace.");
43         return interactionId_;
44     }
45 
SetInteractionId(uint32_t interactionId)46     void SetInteractionId(uint32_t interactionId)
47     {
48         SHARING_LOGD("trace.");
49         interactionId_ = interactionId;
50     }
51 
SetListener(std::weak_ptr<SceneServiceListener> listener)52     void SetListener(std::weak_ptr<SceneServiceListener> listener)
53     {
54         SHARING_LOGD("trace.");
55         serviceListener_ = listener;
56     }
57 
58 public:
59     virtual void HandleMsg(SceneFormat &formatData) = 0;
60 
61 protected:
62     uint32_t interactionId_ = -1;
63     std::weak_ptr<SceneServiceListener> serviceListener_;
64 };
65 
66 } // namespace Sharing
67 } // namespace OHOS
68 #endif