2 * Copyright (c) 2020 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef WATCH_HOLDER_BASE_SRC_WATCH_BASE_HH_
18 #define WATCH_HOLDER_BASE_SRC_WATCH_BASE_HH_
20 #include <bundle_cpp.h>
24 #include <screen_connector_remote_surface/remote_surface.h>
27 #include "sharable_watch_base_interface.hh"
29 namespace watch_holder {
31 class EXPORT_API WatchBase : public screen_connector::RemoteSurface,
32 public virtual ISharableWatchBase {
36 virtual void OnBound(const WatchBase& watch) = 0;
37 virtual void OnAdded(const WatchBase& watch) = 0;
38 virtual void OnUpdated(const WatchBase& watch) = 0;
39 virtual void OnRemoved(const WatchBase& watch) = 0;
42 WatchBase(std::string appid,
43 std::shared_ptr<screen_connector::WlSurface> surface,
44 tizen_base::Bundle extra,
45 IEvent* listener, bool mock = false);
46 WatchBase(int rid, std::string id, std::string appid,
47 std::shared_ptr<screen_connector::WlSurface> surface,
48 tizen_base::Bundle extra,
49 IEvent* listener, bool mock = false);
50 WatchBase(std::string appid,
51 std::shared_ptr<screen_connector::WlSurface> surface,
52 IEvent* listener, bool mock = false);
53 WatchBase(int rid, std::string id, std::string appid,
54 std::shared_ptr<screen_connector::WlSurface> surface,
55 IEvent* listener, bool mock = false);
58 void Resume() override;
59 void Pause() override;
62 void Bind(std::shared_ptr<screen_connector::WlSurface> surface);
65 std::shared_ptr<screen_connector::WlBuffer> GetCurrentImage() const override;
66 int NotifyChangedEvent() const;
67 bool IsBound() const override;
68 std::string GetAppId() const;
69 int GetPid() const override;
71 tizen_base::Bundle GetExtra() const override;
72 bool IsFaulted() const override;
73 void BlockUpdate(bool enable) override;
74 IEvent* GetListener();
75 virtual void OnAdded(const std::string& appId, const std::string& instId,
76 int pid, std::shared_ptr<screen_connector::WlBuffer> tbm);
77 virtual void OnRemoved(const std::string& appId, const std::string& instId,
78 int pid, std::shared_ptr<screen_connector::WlBuffer> tbm);
79 virtual void OnChanged(const std::string& appId, const std::string& instId,
80 int pid, std::shared_ptr<screen_connector::WlBuffer> tbm);
83 friend class WatchHolderBase;
84 void OnBufferAdded(const std::string& appId,
85 const std::string& instId, int pid) override;
86 void OnBufferRemoved(const std::string& appId,
87 const std::string& instId, int pid) override;
88 void OnBufferChanged(int type,
89 std::shared_ptr<screen_connector::WlBuffer> tbm,
90 int fd, uint32_t size, uint32_t time) override;
91 void SetFaulted(bool is_faulted);
97 std::shared_ptr<screen_connector::WlBuffer> current_buffer_ = nullptr;
98 tizen_base::Bundle extra_data_;
99 bool is_faulted_ = false;
100 bool is_bound_ = false;
103 } // namespace watch_holder
105 #endif // WATCH_HOLDER_BASE_SRC_WATCH_BASE_HH_