--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef AMBIENT_VIEWER_SRC_AMBIENT_VIEWER_IMPLEMENTATION_HH_
+#define AMBIENT_VIEWER_SRC_AMBIENT_VIEWER_IMPLEMENTATION_HH_
+
+
+#include <aul_app_com.h>
+
+#include <string>
+#include <memory>
+#include <list>
+
+#include "ambient-viewer.hh"
+
+namespace ambient_viewer {
+
+class AmbientViewer::Impl {
+ public:
+ virtual ~Impl();
+
+ private:
+ friend class AmbientViewer;
+ Impl(AmbientViewer* parent, Evas_Object* win);
+
+ private:
+ AmbientViewer* parent_;
+ std::string GetUUID(std::string rid) const;
+ static int OnDeadSignal(const char* endpoint, aul_app_com_result_e e,
+ bundle* envelope, void* user_data);
+ static void OnChangedSignal(keynode_t* node, void* user_data);
+ static int OnReceiveSignal(const char* endpoint, aul_app_com_result_e e,
+ bundle* envelope, void* user_data);
+ Evas_Object* win_;
+ std::list<std::shared_ptr<ISurface>> watch_stack_;
+ std::shared_ptr<ISurface> top_app_surface_;
+ aul_app_com_connection_h dead_signal_conn_ = nullptr;
+ aul_app_com_connection_h receive_signal_conn_ = nullptr;
+};
+
+} // namespace ambient_viewer
+
+#endif // AMBIENT_VIEWER_SRC_AMBIENT_VIEWER_IMPLEMENTATION_HH_
#include <uuid/uuid.h>
#include <stdexcept>
+#include "ambient-viewer-implementation.hh"
#include "ambient-viewer.hh"
#include "top-app-surface.hh"
#include "watch-surface.hh"
using namespace tizen_base;
namespace ambient_viewer {
+AmbientViewer::Impl::Impl(AmbientViewer* parent, Evas_Object* win)
+ : parent_(parent), win_(win) {
+}
+AmbientViewer::Impl::~Impl() = default;
+
AmbientViewer::AmbientViewer(Evas_Object* win)
- : win_(win) {
- if (aul_app_com_create("aod.ambientevent", nullptr, OnReceiveSignal,
- this, &receive_signal_conn_) != AUL_R_OK) {
+ : impl_(new Impl(this, win)) {
+ if (aul_app_com_create("aod.ambientevent", nullptr, impl_->OnReceiveSignal,
+ this, &impl_->receive_signal_conn_) != AUL_R_OK) {
LOGE("Failed to listen send extra signal");
}
if (aul_app_com_create("watch.dead", nullptr,
- OnDeadSignal, this, &dead_signal_conn_) != AUL_R_OK) {
+ impl_->OnDeadSignal, this, &impl_->dead_signal_conn_) != AUL_R_OK) {
LOGE("failed to listen dead signal");
}
}
AmbientViewer::~AmbientViewer() {
- if (receive_signal_conn_)
- aul_app_com_leave(receive_signal_conn_);
- if (dead_signal_conn_)
- aul_app_com_leave(dead_signal_conn_);
+ if (impl_->receive_signal_conn_)
+ aul_app_com_leave(impl_->receive_signal_conn_);
+ if (impl_->dead_signal_conn_)
+ aul_app_com_leave(impl_->dead_signal_conn_);
}
std::shared_ptr<ISurface> AmbientViewer::CreateWatchSurface(int rid,
return make_shared<TopAppSurface>(std::move(surface), listener, mock);
}
-string AmbientViewer::GetUUID(string rid) const {
+string AmbientViewer::Impl::GetUUID(string rid) const {
char uuid[37];
uuid_t u;
return string(uuid) + rid;
}
-void AmbientViewer::OnChangedSignal(keynode_t *node, void *user_data) {
+void AmbientViewer::Impl::OnChangedSignal(keynode_t *node, void *user_data) {
AmbientViewer* viewer = (AmbientViewer*)user_data;
char* raw = vconf_get_str(VCONFKEY_WATCH_CURRENT_WATCH_INFO);
unique_ptr<char, decltype(free)*> safe_raw(raw, free);
Bundle data(safe_raw.get());
string appid = data.GetString(NOTIFY_CHANGED_EVENT_APPID_KEY);
LOGW("changed (%s)", appid.c_str());
- if (!viewer->watch_stack_.empty()) {
- if (viewer->watch_stack_.back()->GetAppId() == appid) {
+ if (!viewer->impl_->watch_stack_.empty()) {
+ if (viewer->impl_->watch_stack_.back()->GetAppId() == appid) {
LOGW("Already activated watch(%s)", appid.c_str());
return;
}
}
string rid = data.GetString(NOTIFY_CHANGED_EVENT_RID_KEY);
- viewer->watch_stack_.push_back(viewer->CreateWatchSurface(
- stoi(rid), viewer->GetUUID(rid), appid, viewer->win_, viewer));
+ viewer->impl_->watch_stack_.push_back(viewer->CreateWatchSurface(
+ stoi(rid), viewer->impl_->GetUUID(rid), appid, viewer->impl_->win_, viewer));
viewer->OnReceived(EVENT_WATCH_CHANGED, appid, data);
} catch (const std::exception& e) {
LOGE("Exception occurred : %s", e.what());
}
}
-int AmbientViewer::OnDeadSignal(const char *endpoint, aul_app_com_result_e e,
+int AmbientViewer::Impl::OnDeadSignal(const char *endpoint, aul_app_com_result_e e,
bundle *envelope, void *user_data) {
AmbientViewer* viewer = (AmbientViewer*)user_data;
Bundle data(envelope, false, false);
string appid = data.GetString(AUL_K_APPID);
LOGW("Watch(%s) DEAD", appid.c_str());
list<shared_ptr<ISurface>>::iterator it;
- for (it = viewer->watch_stack_.begin(); it != viewer->watch_stack_.end(); ++it) {
+ for (it = viewer->impl_->watch_stack_.begin(); it != viewer->impl_->watch_stack_.end(); ++it) {
if ((*it)->GetAppId() == appid) {
- viewer->watch_stack_.erase(it);
+ viewer->impl_->watch_stack_.erase(it);
LOGW("REMOVE DEAD WATCH (%s)", appid.c_str());
break;
}
void AmbientViewer::Monitor(bool full) {
if (full) {
- top_app_surface_ = CreateTopAppSurface(
- make_shared<screen_connector::EvasObject>(win_, false), this);
+ impl_->top_app_surface_ = CreateTopAppSurface(
+ make_shared<screen_connector::EvasObject>(impl_->win_, false), this);
}
if (vconf_notify_key_changed(
- VCONFKEY_WATCH_CURRENT_WATCH_INFO, OnChangedSignal, this) != 0) {
+ VCONFKEY_WATCH_CURRENT_WATCH_INFO, impl_->OnChangedSignal, this) != 0) {
LOGE("failed to listen on changed signal");
return;
}
- OnChangedSignal(nullptr, this);
+ impl_->OnChangedSignal(nullptr, this);
}
void AmbientViewer::Unmonitor() {
- vconf_ignore_key_changed(VCONFKEY_WATCH_CURRENT_WATCH_INFO, OnChangedSignal);
- top_app_surface_.reset();
- watch_stack_.clear();
+ vconf_ignore_key_changed(
+ VCONFKEY_WATCH_CURRENT_WATCH_INFO, impl_->OnChangedSignal);
+ impl_->top_app_surface_.reset();
+ impl_->watch_stack_.clear();
}
void AmbientViewer::BlockUpdate(bool enable) {
- if (top_app_surface_ != nullptr && top_app_surface_.get() != nullptr) {
- top_app_surface_->BlockUpdate(enable);
+ if (impl_->top_app_surface_ != nullptr && impl_->top_app_surface_.get() != nullptr) {
+ impl_->top_app_surface_->BlockUpdate(enable);
LOGW("Top App Block Update (%d)", enable);
}
- if (watch_stack_.empty()) {
+ if (impl_->watch_stack_.empty()) {
LOGW("Empty stack!");
return;
}
- watch_stack_.back()->BlockUpdate(enable);
+ impl_->watch_stack_.back()->BlockUpdate(enable);
LOGW("Watch Block Update (%d)", enable);
}
}
const ISurface& AmbientViewer::GetWatchSurface() const {
- if (watch_stack_.empty()) {
+ if (impl_->watch_stack_.empty()) {
LOGE("watch surface stack is empty !");
throw std::runtime_error("watch surface stack is empty !");
}
- return *watch_stack_.back();
+ return *impl_->watch_stack_.back();
}
const ISurface& AmbientViewer::GetTopAppSurface() const {
- return *top_app_surface_;
+ return *impl_->top_app_surface_;
}
-int AmbientViewer::OnReceiveSignal(const char* endpoint, aul_app_com_result_e e,
- bundle* envelope, void* user_data) {
+int AmbientViewer::Impl::OnReceiveSignal(const char* endpoint,
+ aul_app_com_result_e e, bundle* envelope, void* user_data) {
AmbientViewer* av = (AmbientViewer*)user_data;
LOGD("OnReceiveSignal");
IAmbientViewer* listener, bool mock = false);
private:
- std::string GetUUID(std::string rid) const;
- static int OnDeadSignal(const char *endpoint, aul_app_com_result_e e,
- bundle *envelope, void *user_data);
- static void OnChangedSignal(keynode_t *node, void *user_data);
- static int OnReceiveSignal(const char *endpoint, aul_app_com_result_e e,
- bundle *envelope, void *user_data);
- Evas_Object* win_;
- std::list<std::shared_ptr<ISurface>> watch_stack_;
- std::shared_ptr<ISurface> top_app_surface_;
- aul_app_com_connection_h dead_signal_conn_ = nullptr;
- aul_app_com_connection_h receive_signal_conn_ = nullptr;
+ class Impl;
+ std::unique_ptr<Impl> impl_;
};
} // namespace ambient_viewer
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef AMBIENT_VIEWER_SRC_TOP_APP_SURFACE_IMPLEMENTATION_HH_
+#define AMBIENT_VIEWER_SRC_TOP_APP_SURFACE_IMPLEMENTATION_HH_
+
+#include <remote_surface_watcher.h>
+
+#include <string>
+
+#include "top-app-surface.hh"
+
+namespace ambient_viewer {
+
+class TopAppSurface::Impl {
+ public:
+ virtual ~Impl();
+
+ private:
+ friend class TopAppSurface;
+ Impl(TopAppSurface* parent, IAmbientViewer* listener);
+
+ private:
+ TopAppSurface* parent_;
+ Evas_Object* image_ = nullptr;
+ std::string app_id_;
+ std::string inst_id_;
+ int pid_ = 0;
+ IAmbientViewer* listener_;
+};
+
+} // namespace ambient_viewer
+
+#endif // AMBIENT_VIEWER_SRC_TOP_APP_SURFACE_IMPLEMENTATION_HH_
#include <dlog.h>
+#include "top-app-surface-implementation.hh"
#include "top-app-surface.hh"
#include "util.hh"
namespace ambient_viewer {
+TopAppSurface::Impl::Impl(TopAppSurface* parent,
+ IAmbientViewer* listener) : parent_(parent), listener_(listener) {
+}
+TopAppSurface::Impl::~Impl() = default;
+
TopAppSurface::TopAppSurface(
std::shared_ptr<screen_connector::EvasObject> surface,
IAmbientViewer* listener, bool mock)
: screen_connector::RemoteSurfaceWatcher(
screen_connector::RemoteSurface::UI, surface, true, mock),
- listener_(listener) {
+ impl_(new Impl(this, listener)) {
}
TopAppSurface::~TopAppSurface() = default;
Evas_Object* TopAppSurface::GetCurrentImage() const {
- return image_;
+ return impl_->image_;
}
bool TopAppSurface::IsWatch() const {
}
std::string TopAppSurface::GetAppId() const {
- return app_id_;
+ return impl_->app_id_;
}
std::string TopAppSurface::GetInstId() const {
- return inst_id_;
+ return impl_->inst_id_;
}
float TopAppSurface::GetOpr() const {
tbm_surface_info_s info = {0, };
void* source_data;
- if (image_ == nullptr)
+ if (impl_->image_ == nullptr)
return 0;
- evas_object_geometry_get(image_, nullptr, nullptr, &width, &height);
+ evas_object_geometry_get(impl_->image_, nullptr, nullptr, &width, &height);
- ns = evas_object_image_native_surface_get(image_);
+ ns = evas_object_image_native_surface_get(impl_->image_);
if (ns == nullptr) {
return 0;
}
void TopAppSurface::OnWatcherAdded(const std::string& appId,
const std::string& instId, const int pid) {
LOGD("WatcherAdded (%s:%s:%d)", appId.c_str(), instId.c_str(), pid);
- if (app_id_ == "" && inst_id_ == "") {
- app_id_ = appId;
- inst_id_ = instId;
- pid_ = pid;
+ if (impl_->app_id_ == "" && impl_->inst_id_ == "") {
+ impl_->app_id_ = appId;
+ impl_->inst_id_ = instId;
+ impl_->pid_ = pid;
}
}
const std::string& instId, const int pid,
const screen_connector::EvasObject& image) {
LOGD("WatcherChanged (%s:%s:%d)", appId.c_str(), instId.c_str(), pid);
- if (app_id_ == appId && instId == inst_id_) {
- bool not_added = image_ == nullptr;
+ if (impl_->app_id_ == appId && instId == impl_->inst_id_) {
+ bool not_added = impl_->image_ == nullptr;
- image_ = image.GetRaw();
+ impl_->image_ = image.GetRaw();
if (not_added)
- listener_->OnAdded(*this);
+ impl_->listener_->OnAdded(*this);
else
- listener_->OnUpdated(*this);
+ impl_->listener_->OnUpdated(*this);
}
}
void TopAppSurface::OnWatcherRemoved(const std::string& appId,
const std::string& instId, const int pid) {
LOGD("WatcherRemoved (%s:%s:%d)", appId.c_str(), instId.c_str(), pid);
- if (app_id_ == appId && instId == inst_id_) {
- app_id_ = "";
- inst_id_ = "";
- pid_ = 0;
- listener_->OnRemoved(*this);
- image_ = nullptr;
+ if (impl_->app_id_ == appId && instId == impl_->inst_id_) {
+ impl_->app_id_ = "";
+ impl_->inst_id_ = "";
+ impl_->pid_ = 0;
+ impl_->listener_->OnRemoved(*this);
+ impl_->image_ = nullptr;
}
}
void TopAppSurface::OnWatcherFocusChanged(const std::string& appId,
const std::string& instId, const int pid) {
LOGD("WatcherFocusChanged (%s:%s:%d)", appId.c_str(), instId.c_str(), pid);
- if (app_id_ != appId || instId != inst_id_)
- OnWatcherRemoved(app_id_, inst_id_, pid_);
+ if (impl_->app_id_ != appId || instId != impl_->inst_id_)
+ OnWatcherRemoved(impl_->app_id_, impl_->inst_id_, impl_->pid_);
- app_id_ = appId;
- inst_id_ = instId;
- pid_ = pid;
+ impl_->app_id_ = appId;
+ impl_->inst_id_ = instId;
+ impl_->pid_ = pid;
}
} // namespace ambient_viewer
const std::string& instId, const int pid) override;
private:
- Evas_Object* image_ = nullptr;
- std::string app_id_;
- std::string inst_id_;
- int pid_ = 0;
-
- IAmbientViewer* listener_;
+ class Impl;
+ std::unique_ptr<Impl> impl_;
};
} // namespace ambient_viewer
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef AMBIENT_VIEWER_SRC_WATCH_SURFACE_IMPLEMENTATION_HH_
+#define AMBIENT_VIEWER_SRC_WATCH_SURFACE_IMPLEMENTATION_HH_
+
+#include <remote_surface_watcher.h>
+
+#include <string>
+
+#include "watch-surface.hh"
+
+namespace ambient_viewer {
+
+class WatchSurface::Impl {
+ public:
+ virtual ~Impl();
+
+ private:
+ friend class WatchSurface;
+ Impl(WatchSurface* parent, std::string appid, IAmbientViewer* listener);
+
+ private:
+ WatchSurface* parent_;
+ Evas_Object* image_ = nullptr;
+ std::string appid_;
+ std::string inst_id_;
+
+ IAmbientViewer* listener_;
+};
+
+} // namespace ambient_viewer
+
+#endif // AMBIENT_VIEWER_SRC_WATCH_SURFACE_IMPLEMENTATION_HH_
*/
#include <dlog.h>
+#include "watch-surface-implementation.hh"
#include "watch-surface.hh"
#include "util.hh"
namespace ambient_viewer {
+WatchSurface::Impl::Impl(WatchSurface* parent, std::string appid,
+ IAmbientViewer* listener)
+ : parent_(parent), appid_(appid), listener_(listener) {
+}
+WatchSurface::Impl::~Impl() = default;
+
WatchSurface::WatchSurface(
int rid, std::string id, std::string appid,
Evas_Object* viewer_win, IAmbientViewer* listener, bool mock)
: RemoteSurfaceEvas(rid, id, RemoteSurface::WATCH,
- std::make_shared<screen_connector::EvasObject>(viewer_win, false), mock),
- appid_(appid), listener_(listener) {
+ std::make_shared<screen_connector::EvasObject>(
+ viewer_win, false), mock),
+ impl_(new Impl(this, appid, listener)) {
RemoteSurfaceEvas::SetAutoVisibility(false);
LOGI("WatchSurface created (%s)", appid.c_str());
}
WatchSurface::~WatchSurface() {
- LOGI("WatchSurface DESTROYED (%s)", appid_.c_str());
+ LOGI("WatchSurface DESTROYED (%s)", impl_->appid_.c_str());
}
Evas_Object* WatchSurface::GetCurrentImage() const {
- return image_;
+ return impl_->image_;
}
bool WatchSurface::IsWatch() const {
}
std::string WatchSurface::GetAppId() const {
- return appid_;
+ return impl_->appid_;
}
std::string WatchSurface::GetInstId() const {
- return inst_id_;
+ return impl_->inst_id_;
}
float WatchSurface::GetOpr() const {
tbm_surface_info_s info = {0, };
void* source_data;
- if (image_ == nullptr)
+ if (impl_->image_ == nullptr)
return 0;
- evas_object_geometry_get(image_, nullptr, nullptr, &width, &height);
+ evas_object_geometry_get(impl_->image_, nullptr, nullptr, &width, &height);
- ns = evas_object_image_native_surface_get(image_);
+ ns = evas_object_image_native_surface_get(impl_->image_);
if (ns == nullptr) {
return 0;
}
void WatchSurface::OnEvasAdded(const std::string& appId,
const std::string& instId, int pid,
const screen_connector::EvasObject& image) {
- inst_id_ = instId;
- image_ = image.GetRaw();
+ impl_->inst_id_ = instId;
+ impl_->image_ = image.GetRaw();
- listener_->OnAdded(*this);
+ impl_->listener_->OnAdded(*this);
}
void WatchSurface::OnEvasRemoved(const std::string& appId,
const std::string& instId, int pid,
const screen_connector::EvasObject& image) {
- image_ = nullptr;
- listener_->OnRemoved(*this);
- LOGW("watch surface removed (%s) (%d)", appid_.c_str(), pid);
+ impl_->image_ = nullptr;
+ impl_->listener_->OnRemoved(*this);
+ LOGW("watch surface removed (%s) (%d)", impl_->appid_.c_str(), pid);
}
void WatchSurface::OnEvasChanged(const std::string& appId,
const std::string& instId, int pid,
const screen_connector::EvasObject& image) {
- image_ = image.GetRaw();
- listener_->OnUpdated(*this);
+ impl_->image_ = image.GetRaw();
+ impl_->listener_->OnUpdated(*this);
}
} // namespace ambient_viewer
int pid, const screen_connector::EvasObject& image) override;
private:
- Evas_Object* image_ = nullptr;
- std::string appid_;
- std::string inst_id_;
-
- IAmbientViewer* listener_;
+ class Impl;
+ std::unique_ptr<Impl> impl_;
};
} // namespace ambient_viewer
#include <dlog.h>
#include "common.hh"
+#include "ambient_listener_implementation.hh"
#include "ambient_listener.hh"
#ifdef LOG_TAG
namespace watch_holder {
-AmbientListener::AmbientListener() {
+AmbientListener::AmbientListener() : impl_(new Impl(this)) {
if (aul_app_com_create("watch.ambientchange", nullptr, OnAmbientChangedSignal,
- this, &ambient_changed_signal_conn_) != AUL_R_OK) {
+ this, &impl_->ambient_changed_signal_conn_) != AUL_R_OK) {
LOGE("Failed to listen watch.ambientchange signal");
}
if (aul_app_com_create("aod.ambientevent", nullptr, OnReceiveSignal,
- this, &ambient_event_signal_conn_) != AUL_R_OK) {
+ this, &impl_->ambient_event_signal_conn_) != AUL_R_OK) {
LOGE("Failed to listen aod.ambientevent signal");
}
}
return -1;
}
- tizen_base::Bundle b = tizen_base::Bundle(envelope, true, true);
+ tizen_base::Bundle b(envelope, true, true);
std::string event_type = b.GetString("__APP_AMBIENT_EVENT__");
LOGI("event type (%s)", event_type.c_str());
int type = stoi(event_type);
}
AmbientListener::~AmbientListener() {
- if (ambient_changed_signal_conn_)
- aul_app_com_leave(ambient_changed_signal_conn_);
+ if (impl_->ambient_changed_signal_conn_)
+ aul_app_com_leave(impl_->ambient_changed_signal_conn_);
- if (ambient_event_signal_conn_)
- aul_app_com_leave(ambient_event_signal_conn_);
+ if (impl_->ambient_event_signal_conn_)
+ aul_app_com_leave(impl_->ambient_event_signal_conn_);
}
+AmbientListener::Impl::Impl(AmbientListener* parent)
+ : parent_(parent) {
+}
+AmbientListener::Impl::~Impl() = default;
+
} // namespace watch_holder
#include <aul_app_com.h>
#include <string>
+#include <memory>
#include "common.hh"
tizen_base::Bundle extra) = 0;
private:
- aul_app_com_connection_h ambient_changed_signal_conn_ = nullptr;
- aul_app_com_connection_h ambient_event_signal_conn_ = nullptr;
+ class Impl;
+ std::unique_ptr<Impl> impl_;
};
} // namespace watch_holder
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef WATCH_HOLDER_BASE_SRC_AMBIENT_LISTENER_IMPLEMENTATION_HH_
+#define WATCH_HOLDER_BASE_SRC_AMBIENT_LISTENER_IMPLEMENTATION_HH_
+
+
+#include <bundle_cpp.h>
+#include <aul_app_com.h>
+
+#include <string>
+
+#include "ambient_listener.hh"
+
+namespace watch_holder {
+
+class AmbientListener::Impl {
+ public:
+ virtual ~Impl();
+
+ private:
+ friend class AmbientListener;
+ Impl(AmbientListener* parent);
+
+ private:
+ AmbientListener* parent_;
+ aul_app_com_connection_h ambient_changed_signal_conn_ = nullptr;
+ aul_app_com_connection_h ambient_event_signal_conn_ = nullptr;
+};
+
+} // namespace watch_holder
+
+#endif // WATCH_HOLDER_BASE_SRC_AMBIENT_LISTENER_IMPLEMENTATION_HH_
#include <aul_app_com.h>
#include <vconf.h>
+#include "watch_base_implementation.hh"
#include "watch_base.hh"
#ifdef LOG_TAG
std::shared_ptr<WlSurface> surface,
tizen_base::Bundle extra, IEvent* listener, bool mock)
: RemoteSurface(appid, RemoteSurface::WATCH, surface, mock),
- appid_(appid), listener_(listener), extra_data_(extra) {
+ impl_(new Impl(this, appid, listener, extra)) {
}
WatchBase::WatchBase(int rid, std::string id, std::string appid,
std::shared_ptr<WlSurface> surface,
tizen_base::Bundle extra, IEvent* listener, bool mock)
: RemoteSurface(rid, id, RemoteSurface::WATCH, surface, mock),
- appid_(appid), listener_(listener), extra_data_(extra) {
+ impl_(new Impl(this, appid, listener, extra)) {
}
WatchBase::WatchBase(std::string appid,
std::shared_ptr<screen_connector::WlSurface> surface,
IEvent* listener, bool mock)
: RemoteSurface(appid, RemoteSurface::WATCH, surface, mock),
- appid_(appid), listener_(listener) {
+ impl_(new Impl(this, appid, listener)) {
}
WatchBase::WatchBase(int rid, std::string id, std::string appid,
std::shared_ptr<screen_connector::WlSurface> surface,
IEvent* listener, bool mock)
: RemoteSurface(rid, id, RemoteSurface::WATCH, surface, mock),
- appid_(appid), listener_(listener) {
+ impl_(new Impl(this, appid, listener)) {
}
WatchBase::~WatchBase() = default;
+
+WatchBase::Impl::Impl(WatchBase* parent, std::string appid,
+ WatchBase::IEvent* listener, tizen_base::Bundle extra)
+ : parent_(parent), appid_(appid), listener_(listener), extra_data_(extra) {
+}
+
+WatchBase::Impl::Impl(WatchBase* parent, std::string appid,
+ WatchBase::IEvent* listener)
+ : parent_(parent), appid_(appid), listener_(listener) {
+}
+
+WatchBase::Impl::~Impl() = default;
+
+
void WatchBase::Resume() {
RemoteSurface::SendVisibility(true);
}
}
int WatchBase::Terminate() {
- LOGW("Terminate (%d)", pid_);
- return aul_terminate_pid(pid_);
+ LOGW("Terminate (%d)", impl_->pid_);
+ return aul_terminate_pid(impl_->pid_);
}
void WatchBase::BlockUpdate(bool enable) {
}
int WatchBase::GetPid() const {
- return pid_;
+ return impl_->pid_;
}
bool WatchBase::IsBound() const {
- return is_bound_;
+ return impl_->is_bound_;
}
string WatchBase::GetAppId() const {
- return appid_;
+ return impl_->appid_;
}
bool WatchBase::IsFaulted() const {
- return is_faulted_;
+ return impl_->is_faulted_;
}
void WatchBase::Bind(std::shared_ptr<WlSurface> surface) {
RemoteSurface::Bind(surface);
- is_bound_ = true;
+ impl_->is_bound_ = true;
}
void WatchBase::Unbind() {
RemoteSurface::Unbind();
- is_bound_ = false;
+ impl_->is_bound_ = false;
}
std::shared_ptr<WlBuffer> WatchBase::GetCurrentImage() const {
- return current_buffer_;
+ return impl_->current_buffer_;
}
tizen_base::Bundle WatchBase::GetExtra() const {
- return extra_data_;
+ return impl_->extra_data_;
}
void WatchBase::SetFaulted(bool faulted) {
- is_faulted_ = faulted;
+ impl_->is_faulted_ = faulted;
}
void WatchBase::OnBufferAdded(const std::string& appId,
const std::string& instId, int pid) {
- pid_ = pid;
+ impl_->pid_ = pid;
}
void WatchBase::OnBufferRemoved(const std::string& appId,
const std::string& instId, int pid) {
- if (current_buffer_ == nullptr)
+ if (impl_->current_buffer_ == nullptr)
return;
- OnRemoved(appId, instId, pid, current_buffer_);
- current_buffer_ = nullptr;
+ OnRemoved(appId, instId, pid, impl_->current_buffer_);
+ impl_->current_buffer_ = nullptr;
}
void WatchBase::OnBufferChanged(int type,
if (GetType() == RemoteSurface::WATCH && RemoteSurface::IsBound())
return;
- if (current_buffer_ == nullptr) {
+ if (impl_->current_buffer_ == nullptr) {
LOGD("first added !!!! %d %s", type, GetAppId().c_str());
OnAdded(GetAppId(), GetInstId(), GetPid(), tbm);
} else {
OnChanged(GetAppId(), GetInstId(), GetPid(), tbm);
}
- current_buffer_ = tbm;
+ impl_->current_buffer_ = tbm;
}
void WatchBase::OnAdded(const std::string& appId, const std::string& instId,
int pid, std::shared_ptr<screen_connector::WlBuffer> tbm) {
- pid_ = pid;
- listener_->OnAdded(*this);
+ impl_->pid_ = pid;
+ impl_->listener_->OnAdded(*this);
}
void WatchBase::OnRemoved(const std::string& appId, const std::string& instId,
int pid, std::shared_ptr<screen_connector::WlBuffer> tbm) {
- listener_->OnRemoved(*this);
+ impl_->listener_->OnRemoved(*this);
}
void WatchBase::OnChanged(const std::string& appId, const std::string& instId,
int pid, std::shared_ptr<screen_connector::WlBuffer> tbm) {
- listener_->OnUpdated(*this);
+ impl_->listener_->OnUpdated(*this);
}
int WatchBase::NotifyChangedEvent() const {
tizen_base::Bundle b;
- b.Add(NOTIFY_CHANGED_EVENT_APPID_KEY, appid_);
+ b.Add(NOTIFY_CHANGED_EVENT_APPID_KEY, impl_->appid_);
b.Add(NOTIFY_CHANGED_EVENT_RID_KEY, to_string(GetRid()));
int ret = vconf_set_str(
VCONFKEY_WATCH_CURRENT_WATCH_INFO, (const char*)b.ToRaw().first.get());
}
WatchBase::IEvent* WatchBase::GetListener() {
- return listener_;
+ return impl_->listener_;
}
} // namespace watch_holder
void SetFaulted(bool is_faulted);
private:
- int pid_ = 0;
- std::string appid_;
- IEvent* listener_;
- std::shared_ptr<screen_connector::WlBuffer> current_buffer_ = nullptr;
- tizen_base::Bundle extra_data_;
- bool is_faulted_ = false;
- bool is_bound_ = false;
+ class Impl;
+ std::unique_ptr<Impl> impl_;
};
} // namespace watch_holder
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef WATCH_HOLDER_BASE_SRC_WATCH_BASE_IMPLEMENTATION_HH_
+#define WATCH_HOLDER_BASE_SRC_WATCH_BASE_IMPLEMENTATION_HH_
+
+#include <bundle_cpp.h>
+
+#include <string>
+#include <memory>
+#include <screen_connector_remote_surface/remote_surface.h>
+
+#include "watch_base.hh"
+
+namespace watch_holder {
+
+class WatchBase::Impl {
+ public:
+ virtual ~Impl();
+
+ private:
+ friend class WatchBase;
+ Impl(WatchBase* parent, std::string appid, WatchBase::IEvent* listener,
+ tizen_base::Bundle extra);
+ Impl(WatchBase* parent, std::string appid, WatchBase::IEvent* listener);
+
+ private:
+ WatchBase* parent_;
+ int pid_ = 0;
+ std::string appid_;
+ WatchBase::IEvent* listener_;
+ std::shared_ptr<screen_connector::WlBuffer> current_buffer_ = nullptr;
+ tizen_base::Bundle extra_data_;
+ bool is_faulted_ = false;
+ bool is_bound_ = false;
+};
+
+} // namespace watch_holder
+
+#endif // WATCH_HOLDER_BASE_SRC_WATCH_BASE_IMPLEMENTATION_HH_
#include <utility>
+#include "watch_holder_base_implementation.hh"
#include "watch_holder_base.hh"
#ifdef LOG_TAG
namespace watch_holder {
WatchHolderBase::~WatchHolderBase() {
- if (dead_signal_conn_)
- aul_app_com_leave(dead_signal_conn_);
- if (launch_signal_conn_)
- aul_app_com_leave(launch_signal_conn_);
+ if (impl_->launch_signal_conn_)
+ aul_app_com_leave(impl_->launch_signal_conn_);
+ if (impl_->launch_signal_conn_)
+ aul_app_com_leave(impl_->launch_signal_conn_);
}
-WatchHolderBase::WatchHolderBase(
- std::shared_ptr<screen_connector::WlSurface> surface, int w, int h)
- : surface_(surface), w_(w), h_(h) {
+WatchHolderBase::WatchHolderBase(int w, int h)
+ : impl_(new Impl(this, w, h)) {
if (aul_app_com_create("watch.dead", nullptr,
- OnDeadSignal, this, &dead_signal_conn_) != AUL_R_OK) {
+ impl_->OnDeadSignal, this, &impl_->launch_signal_conn_) != AUL_R_OK) {
LOGE("failed to create status");
}
- if (aul_app_com_create("watch.launch", nullptr, OnLaunchSignal,
- this, &launch_signal_conn_) != AUL_R_OK) {
+ if (aul_app_com_create("watch.launch", nullptr, impl_->OnLaunchSignal,
+ this, &impl_->launch_signal_conn_) != AUL_R_OK) {
LOGE("Failed to listen watch.launch signal");
}
getpid(), appid_buf, sizeof(appid_buf)) != AUL_R_OK) {
LOGE("Failed to get appid (%d)", getpid());
}
- appid_ = appid_buf;
+ impl_->appid_ = appid_buf;
}
+WatchHolderBase::Impl::Impl(WatchHolderBase* parent, int w, int h)
+ : parent_(parent), w_(w), h_(h) {
+}
+
+WatchHolderBase::Impl::~Impl() = default;
+
int WatchHolderBase::Launch(
string watch_appid, bool background, bundle* extra) {
Bundle data;
if (extra != nullptr)
data = Bundle(extra, true, true);
aul_svc_set_appid(data.GetHandle(), watch_appid.c_str());
- data.Add("WATCH_WIDTH", std::to_string(w_));
- data.Add("WATCH_HEIGHT", std::to_string(h_));
+ data.Add("WATCH_WIDTH", std::to_string(impl_->w_));
+ data.Add("WATCH_HEIGHT", std::to_string(impl_->h_));
data.Add("WATCH_BG_LAUNCH", std::to_string((int)background));
- data.Add(AUL_K_WIDGET_VIEWER, appid_);
+ data.Add(AUL_K_WIDGET_VIEWER, impl_->appid_);
if (extra != nullptr)
- extra_map_[watch_appid] = Bundle(extra, true, true);
+ impl_->extra_map_[watch_appid] = Bundle(extra, true, true);
int pid = appsvc_run_service(data.GetHandle(), 0, nullptr, nullptr);
if (pid < 0) {
}
const std::list<std::shared_ptr<WatchBase>>& WatchHolderBase::GetStack() const {
- return stack_;
+ return impl_->stack_;
}
std::shared_ptr<WatchBase> WatchHolderBase::GetCurrent() const {
- if (stack_.empty()) {
+ if (impl_->stack_.empty()) {
LOGW("Empty stack!");
return nullptr;
}
- return stack_.back();
+ return impl_->stack_.back();
}
void WatchHolderBase::OnAmbientChanged(bool enter, const Bundle& extra) {
tizen_base::Bundle extra) {
}
-int WatchHolderBase::OnDeadSignal(const char *endpoint, aul_app_com_result_e e,
+int WatchHolderBase::Impl::OnDeadSignal(const char *endpoint, aul_app_com_result_e e,
bundle *envelope, void *user_data) {
WatchHolderBase* holder = (WatchHolderBase*)user_data;
Bundle data(envelope, false, false);
string is_faulted = data.GetString(AUL_K_IS_FAULT);
LOGW("WatchBase(%s)(%s) DEAD", appid.c_str(), pid.c_str());
list<shared_ptr<WatchBase>>::iterator it;
- for (it = holder->stack_.begin(); it != holder->stack_.end(); ++it) {
+ for (it = holder->impl_->stack_.begin(); it != holder->impl_->stack_.end(); ++it) {
if ((*it)->GetAppId() == appid &&
pid == to_string((*it)->GetPid())) {
(*it)->SetFaulted(is_faulted == "true");
holder->OnDead(**it);
- holder->stack_.erase(it);
+ holder->impl_->stack_.erase(it);
LOGW("REMOVE DEAD WATCH (%s)(%s)", appid.c_str(), pid.c_str());
break;
}
return 0;
}
-int WatchHolderBase::OnLaunchSignal(const char *endpoint,
+int WatchHolderBase::Impl::OnLaunchSignal(const char *endpoint,
aul_app_com_result_e res, bundle *envelope, void *user_data) {
Bundle launch_data(envelope, false, false);
WatchHolderBase* holder = (WatchHolderBase*)user_data;
string viewer_appid = launch_data.GetString(AUL_K_WIDGET_VIEWER);
- if (viewer_appid != holder->appid_) {
- LOGE("It's not mine (%s:%s)", viewer_appid.c_str(), holder->appid_.c_str());
+ if (viewer_appid != holder->impl_->appid_) {
+ LOGE("It's not mine (%s:%s)", viewer_appid.c_str(), holder->impl_->appid_.c_str());
return 0;
}
string watch_appid = launch_data.GetString(AUL_K_APPID);
- if (holder->extra_map_.find(watch_appid) != holder->extra_map_.end()) {
- Bundle extra(holder->extra_map_[watch_appid]);
- holder->stack_.push_back(holder->CreateWatch(
+ if (holder->impl_->extra_map_.find(watch_appid) != holder->impl_->extra_map_.end()) {
+ Bundle extra(holder->impl_->extra_map_[watch_appid]);
+ holder->impl_->stack_.push_back(holder->CreateWatch(
watch_appid, extra));
- holder->extra_map_.erase(watch_appid);
+ holder->impl_->extra_map_.erase(watch_appid);
} else {
- holder->stack_.push_back(holder->CreateWatch(watch_appid));
+ holder->impl_->stack_.push_back(holder->CreateWatch(watch_appid));
}
holder->OnLaunched(*holder->GetCurrent());
LOGI("LAUNCH DONE (%s)", viewer_appid.c_str());
class EXPORT_API WatchHolderBase
: public WatchBase::IEvent, public AmbientListener {
public:
- WatchHolderBase(
- std::shared_ptr<screen_connector::WlSurface> surface, int w, int h);
+ WatchHolderBase(int w, int h);
virtual ~WatchHolderBase() = 0;
int Launch(std::string appid, bool background, bundle* extra);
const std::list<std::shared_ptr<WatchBase>>& GetStack() const;
std::string appid, tizen_base::Bundle extra, bool mock = false) = 0;
private:
- static int OnDeadSignal(const char *endpoint, aul_app_com_result_e e,
- bundle *envelope, void *user_data);
- static int OnLaunchSignal(const char *endpoint,
- aul_app_com_result_e res, bundle *envelope, void *user_data);
-
- private:
- std::string appid_;
- std::map<std::string, tizen_base::Bundle> extra_map_;
- std::list<std::shared_ptr<WatchBase>> stack_;
- aul_app_com_connection_h launch_signal_conn_ = nullptr;
- aul_app_com_connection_h dead_signal_conn_ = nullptr;
- aul_app_com_connection_h ambient_changed_signal_conn_ = nullptr;
- std::shared_ptr<screen_connector::WlSurface> surface_;
- int w_;
- int h_;
+ class Impl;
+ std::unique_ptr<Impl> impl_;
};
} // namespace watch_holder
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef WATCH_HOLDER_BASE_SRC_WATCH_HOLDER_BASE_IMPLEMENTATION_HH_
+#define WATCH_HOLDER_BASE_SRC_WATCH_HOLDER_BASE_IMPLEMENTATION_HH_
+
+#include <bundle_cpp.h>
+
+#include <string>
+#include <list>
+#include <map>
+#include <memory>
+#include <screen_connector_remote_surface/remote_surface.h>
+
+#include "watch_holder_base.hh"
+
+namespace watch_holder {
+
+class WatchHolderBase::Impl {
+ public:
+ virtual ~Impl();
+
+ private:
+ friend class WatchHolderBase;
+ Impl(WatchHolderBase* parent, int w, int h);
+
+ static int OnDeadSignal(const char *endpoint, aul_app_com_result_e e,
+ bundle *envelope, void *user_data);
+ static int OnLaunchSignal(const char *endpoint,
+ aul_app_com_result_e res, bundle *envelope, void *user_data);
+
+ private:
+ WatchHolderBase* parent_;
+ std::string appid_;
+ std::map<std::string, tizen_base::Bundle> extra_map_;
+ std::list<std::shared_ptr<WatchBase>> stack_;
+ aul_app_com_connection_h launch_signal_conn_ = nullptr;
+ aul_app_com_connection_h dead_signal_conn_ = nullptr;
+ aul_app_com_connection_h ambient_changed_signal_conn_ = nullptr;
+ int w_;
+ int h_;
+};
+
+} // namespace watch_holder
+
+#endif // WATCH_HOLDER_BASE_SRC_WATCH_HOLDER_BASE_IMPLEMENTATION_HH_
#include <appsvc.h>
#include <uuid/uuid.h>
+#include "watch_mirror_base_implementation.hh"
#include "watch_mirror_base.hh"
#include "bundle_cpp.h"
using namespace std;
namespace watch_holder {
-WatchMirrorBase::~WatchMirrorBase() = default;
-WatchMirrorBase::WatchMirrorBase(
- shared_ptr<screen_connector::WlSurface> surface) {
+WatchMirrorBase::Impl::Impl(WatchMirrorBase* parent) : parent_(parent) {
}
-string WatchMirrorBase::GetUUID(string rid) const {
+WatchMirrorBase::Impl::~Impl() = default;
+WatchMirrorBase::~WatchMirrorBase() {
+ vconf_ignore_key_changed(VCONFKEY_WATCH_CURRENT_WATCH_INFO,
+ impl_->OnChangedSignal);
+}
+
+WatchMirrorBase::WatchMirrorBase() : impl_(new Impl(this)) {
+}
+
+string WatchMirrorBase::Impl::GetUUID(string rid) const {
char uuid[37];
uuid_t u;
return string(uuid) + rid;
}
-void WatchMirrorBase::OnChangedSignal(keynode_t *node, void *user_data) {
+void WatchMirrorBase::Impl::OnChangedSignal(keynode_t *node, void *user_data) {
WatchMirrorBase* mirror = (WatchMirrorBase*)user_data;
const char* raw = vconf_get_str(VCONFKEY_WATCH_CURRENT_WATCH_INFO);
if (raw == nullptr || strlen(raw) == 0) {
Bundle data(raw_str);
string appid = data.GetString(NOTIFY_CHANGED_EVENT_APPID_KEY);
string rid = data.GetString(NOTIFY_CHANGED_EVENT_RID_KEY);
- mirror->stack_.push_back(mirror->CreateWatch(
- stoi(rid), mirror->GetUUID(rid), appid));
- mirror->OnChanged(stoi(rid), mirror->GetUUID(rid), appid);
+ mirror->impl_->stack_.push_back(mirror->CreateWatch(
+ stoi(rid), mirror->impl_->GetUUID(rid), appid));
+ mirror->OnChanged(stoi(rid), mirror->impl_->GetUUID(rid), appid);
} catch (const std::exception& e) {
LOGE("Exception occurred : %s", e.what());
return;
int WatchMirrorBase::Listen() {
if (vconf_notify_key_changed(
- VCONFKEY_WATCH_CURRENT_WATCH_INFO, OnChangedSignal, this) != 0) {
+ VCONFKEY_WATCH_CURRENT_WATCH_INFO, impl_->OnChangedSignal, this) != 0) {
LOGE("failed to listen on changed signal");
return -1;
}
- OnChangedSignal(nullptr, this);
+ impl_->OnChangedSignal(nullptr, this);
return 0;
}
std::shared_ptr<ISharableWatchBase> WatchMirrorBase::GetCurrent() const {
- if (stack_.empty()) {
+ if (impl_->stack_.empty()) {
LOGW("Empty stack!");
return nullptr;
}
- return stack_.back();
+ return impl_->stack_.back();
}
void WatchMirrorBase::AddWatch(shared_ptr<WatchBase> watch) {
- stack_.push_back(watch);
+ impl_->stack_.push_back(watch);
}
void WatchMirrorBase::OnAmbientChanged(bool enter, const Bundle& extra) {
void WatchMirrorBase::OnBound(const WatchBase& watch) {
}
-void WatchMirrorBase::OnChanged(int, std::string inst_id, std::string appid) {
-}
-
-} // namespace watch_holder
\ No newline at end of file
+} // namespace watch_holder
class EXPORT_API WatchMirrorBase : public WatchBase::IEvent, public AmbientListener {
public:
- WatchMirrorBase(std::shared_ptr<screen_connector::WlSurface> surface);
+ WatchMirrorBase();
virtual ~WatchMirrorBase() = 0;
int Listen();
std::shared_ptr<ISharableWatchBase> GetCurrent() const;
tizen_base::Bundle extra) override;
void AddWatch(std::shared_ptr<WatchBase> watch);
- private:
- std::string GetUUID(std::string rid) const;
- void OnAdded(const WatchBase& watch) final;
- void OnUpdated(const WatchBase& watch) final;
- void OnRemoved(const WatchBase& watch) final;
- void OnBound(const WatchBase& watch) final;
- virtual void OnChanged(int, std::string inst_id, std::string appid);
- static void OnChangedSignal(keynode_t *node, void *user_data);
-
protected:
virtual std::shared_ptr<WatchBase> CreateWatch(int rid, std::string id,
std::string appid, bool mock = false) = 0;
virtual std::shared_ptr<WatchBase> CreateWatch(int rid, std::string id,
std::string appid, tizen_base::Bundle extra, bool mock = false) = 0;
+ virtual void OnChanged(int rid, std::string inst_id, std::string appid) = 0;
+ void OnAdded(const WatchBase& watch) override;
+ void OnUpdated(const WatchBase& watch) override;
+ void OnRemoved(const WatchBase& watch) override;
+ void OnBound(const WatchBase& watch) override;
private:
- std::string appid_;
- aul_app_com_connection_h watch_changed_conn_ = nullptr;
- std::list<std::shared_ptr<WatchBase>> stack_;
+ class Impl;
+ std::unique_ptr<Impl> impl_;
};
} // namespace watch_holder
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef WATCH_HOLDER_BASE_SRC_WATCH_MIRROR_BASE_IMPLEMENTATION_HH_
+#define WATCH_HOLDER_BASE_SRC_WATCH_MIRROR_BASE_IMPLEMENTATION_HH_
+
+#include <bundle_cpp.h>
+
+#include <string>
+#include <list>
+#include <map>
+#include <memory>
+#include <screen_connector_remote_surface/remote_surface.h>
+
+#include "watch_mirror_base.hh"
+
+namespace watch_holder {
+
+class WatchMirrorBase::Impl {
+ public:
+ virtual ~Impl();
+
+ private:
+ friend class WatchMirrorBase;
+ Impl(WatchMirrorBase* parent);
+ std::string GetUUID(std::string rid) const;
+ static void OnChangedSignal(keynode_t *node, void *user_data);
+
+ private:
+ WatchMirrorBase* parent_;
+ std::list<std::shared_ptr<WatchBase>> stack_;
+};
+
+} // namespace watch_holder
+
+#endif // WATCH_HOLDER_BASE_SRC_WATCH_MIRROR_BASE_IMPLEMENTATION_HH_
#include <vconf.h>
#include <screen_connector_remote_surface_evas/util.h>
+#include "watch_implementation.hh"
#include "watch.hh"
#ifdef LOG_TAG
using namespace screen_connector;
namespace watch_holder {
+Watch::Impl::Impl(Watch* parent, Evas_Object* viewer_win)
+ : parent_(parent), viewer_win_(viewer_win),
+ image_event_listener_((screen_connector::ImageEventListener*)parent) {
+}
+Watch::Impl::~Impl() = default;
+
Watch::Watch(std::string appid, Evas_Object* viewer_win,
tizen_base::Bundle extra, IEvent* listener, bool mock)
: WatchBase(appid, screen_connector::util::GetWlSurface(viewer_win),
- extra, listener, mock),
- viewer_win_(make_shared<EvasObject>(viewer_win, false)),
- image_event_listner_(make_shared<ImageEventListener>(this)) {
+ extra, listener, mock), impl_(new Impl(this, viewer_win)) {
}
Watch::Watch(int rid, std::string id, std::string appid,
WatchBase::IEvent* listener, bool mock)
: WatchBase(rid, id, appid,
screen_connector::util::GetWlSurface(viewer_win), extra, listener, mock),
- viewer_win_(make_shared<EvasObject>(viewer_win, false)),
- image_event_listner_(make_shared<ImageEventListener>(this)) {
+ impl_(new Impl(this, viewer_win)) {
}
Watch::Watch(std::string appid, Evas_Object* viewer_win,
IEvent* listener, bool mock)
: WatchBase(appid, screen_connector::util::GetWlSurface(viewer_win),
listener, mock),
- viewer_win_(make_shared<EvasObject>(viewer_win, false)),
- image_event_listner_(make_shared<ImageEventListener>(this)) {
+ impl_(new Impl(this, viewer_win)) {
}
Watch::Watch(int rid, std::string id, std::string appid,
Evas_Object* viewer_win, WatchBase::IEvent* listener, bool mock)
: WatchBase(rid, id, appid,
screen_connector::util::GetWlSurface(viewer_win), listener, mock),
- viewer_win_(make_shared<EvasObject>(viewer_win, false)),
- image_event_listner_(make_shared<ImageEventListener>(this)) {
+ impl_(new Impl(this, viewer_win)) {
}
Watch::~Watch() = default;
void Watch::OnAuxMsg(void *data, Evas_Object *o, void *ev_info) {
Watch* wa = (Watch*)data;
- if (wa->bind_win_ == nullptr) {
+ if (wa->impl_->bind_win_ == nullptr) {
LOGW("Null bind win");
return;
}
Elm_Win_Aux_Message *msg = (Elm_Win_Aux_Message *)ev_info;
- const char *key = elm_win_aux_msg_key_get(wa->bind_win_, msg);
- const char *val = elm_win_aux_msg_val_get(wa->bind_win_, msg);
+ const char *key = elm_win_aux_msg_key_get(wa->impl_->bind_win_, msg);
+ const char *val = elm_win_aux_msg_val_get(wa->impl_->bind_win_, msg);
if (key == nullptr || val == nullptr) {
LOGW("Null msg data");
if (!strcmp(key, "tz_remote_surface_mng") && !strcmp(val, "prebind")) {
wa->GetListener()->OnBound(*wa);
LOGI("Start bind mode !!");
- evas_object_smart_callback_del(wa->bind_win_,
+ evas_object_smart_callback_del(wa->impl_->bind_win_,
"aux,msg,received", OnAuxMsg);
}
}
void Watch::Bind(Evas_Object* win) {
- bind_win_ = win;
+ impl_->bind_win_ = win;
elm_win_aux_hint_add(win, "wm.policy.win.msg.use", "1");
evas_object_smart_callback_add(win, "aux,msg,received",
OnAuxMsg, this);
void Watch::NoRenderPush(int timeout) {
LOGI("No render push start");
- elm_win_norender_push(evas_object_evas_get(viewer_win_->GetRaw()));
- no_render_timer_ = g_timeout_add(timeout,
+ elm_win_norender_push(evas_object_evas_get(impl_->viewer_win_));
+ impl_->no_render_timer_ = g_timeout_add(timeout,
[](gpointer user_data)->gboolean {
Watch* wa = static_cast<Watch*>(user_data);
- elm_win_norender_pop(evas_object_evas_get(wa->viewer_win_->GetRaw()));
- wa->no_render_timer_ = 0;
+ elm_win_norender_pop(evas_object_evas_get(wa->impl_->viewer_win_));
+ wa->impl_->no_render_timer_ = 0;
LOGW("No render push timeout!");
return G_SOURCE_REMOVE;
}, this);
}
Evas_Object* Watch::GetCurrentImageEvas() const {
- return current_image_->GetRaw();
+ return impl_->current_image_->GetRaw();
}
void Watch::OnAdded(const string& appid, const string& inst_id,
int pid, shared_ptr<WlBuffer> tbm) {
- current_image_.reset(new Image(evas_object_image_filled_add(
- evas_object_evas_get(viewer_win_->GetRaw())),
- image_event_listner_.get(), inst_id, pid, this));
+ impl_->current_image_.reset(new Image(evas_object_image_filled_add(
+ evas_object_evas_get(impl_->viewer_win_)),
+ impl_->image_event_listener_, inst_id, pid, this));
WatchBase::OnAdded(appid, inst_id, pid, tbm);
}
void Watch::OnRemoved(const string& appid, const string& inst_id,
int pid, shared_ptr<WlBuffer> tbm) {
WatchBase::OnRemoved(appid, inst_id, pid, tbm);
- current_image_ = nullptr;
+ impl_->current_image_ = nullptr;
}
void Watch::OnChanged(const string& appid, const string& inst_id,
int pid, shared_ptr<WlBuffer> tbm) {
- current_image_->Update(tbm);
+ impl_->current_image_->Update(tbm);
WatchBase::OnChanged(appid, inst_id, pid, tbm);
}
static void OnAuxMsg(void *data, Evas_Object *o, void *ev_info);
private:
- Evas_Object* bind_win_ = nullptr;
- int no_render_timer_ = 0;
- std::unique_ptr<screen_connector::Image> current_image_ = nullptr;
- std::shared_ptr<screen_connector::EvasObject> viewer_win_ = nullptr;
- std::shared_ptr<screen_connector::ImageEventListener> image_event_listner_ = nullptr;
+ class Impl;
+ std::unique_ptr<Impl> impl_;
};
} // namespace watch_holder
#include <aul_svc.h>
#include <screen_connector_remote_surface_evas/util.h>
+#include <utility>
+
#include "util.hh"
+#include "watch_holder_implementation.hh"
#include "watch_holder.hh"
#include "bundle_cpp.h"
using namespace std;
namespace watch_holder {
-WatchHolder::~WatchHolder() = default;
+WatchHolder::Impl::Impl(WatchHolder* parent, Evas_Object* win)
+ : parent_(parent), viewer_win_(win) {
+}
+WatchHolder::Impl::~Impl() = default;
+WatchHolder::~WatchHolder() = default;
WatchHolder::WatchHolder(Evas_Object* win) :
- WatchHolderBase(screen_connector::util::GetWlSurface(win),
- util::GetWidth(win), util::GetHeight(win)), viewer_win_(win) {
+ WatchHolderBase(util::GetWidth(win), util::GetHeight(win)),
+ impl_(new Impl(this, win)) {
}
std::shared_ptr<WatchBase> WatchHolder::CreateWatch(std::string appid,
bool mock) {
return make_shared<Watch>(
- std::move(appid), viewer_win_, this, mock);
+ std::move(appid), impl_->viewer_win_, this, mock);
}
std::shared_ptr<WatchBase> WatchHolder::CreateWatch(int rid, std::string id,
std::string appid, bool mock) {
return make_shared<Watch>(rid, std::move(id),
- std::move(appid), viewer_win_, this, mock);
+ std::move(appid), impl_->viewer_win_, this, mock);
}
std::shared_ptr<WatchBase> WatchHolder::CreateWatch(std::string appid,
tizen_base::Bundle extra, bool mock) {
- return make_shared<Watch>(std::move(appid), viewer_win_, std::move(extra),
- this, mock);
+ return make_shared<Watch>(std::move(appid), impl_->viewer_win_,
+ std::move(extra), this, mock);
}
std::shared_ptr<WatchBase> WatchHolder::CreateWatch(int rid, std::string id,
std::string appid, tizen_base::Bundle extra, bool mock) {
return make_shared<Watch>(rid, std::move(id), std::move(appid),
- viewer_win_, std::move(extra), this, mock);
+ impl_->viewer_win_, std::move(extra), this, mock);
}
shared_ptr<Watch> WatchHolder::Cast(shared_ptr<WatchBase> watch) {
std::string appid, tizen_base::Bundle extra, bool mock = false) override;
private:
- Evas_Object* viewer_win_;
+ class Impl;
+ std::unique_ptr<Impl> impl_;
};
} // namespace watch_holder
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef WATCH_HOLDER_SRC_WATCH_HOLDER_IMPLEMENTATION_HH_
+#define WATCH_HOLDER_SRC_WATCH_HOLDER_IMPLEMENTATION_HH_
+
+#include <Evas.h>
+
+#include <string>
+
+#include "watch_holder.hh"
+
+namespace watch_holder {
+
+class WatchHolder::Impl {
+ public:
+ virtual ~Impl();
+
+ private:
+ friend class WatchHolder;
+ Impl(WatchHolder* parent, Evas_Object* viewer_win);
+
+ private:
+ WatchHolder* parent_;
+ Evas_Object* viewer_win_;
+};
+
+} // namespace watch_holder
+
+#endif // WATCH_HOLDER_SRC_WATCH_HOLDER_IMPLEMENTATION_HH_
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef WATCH_HOLDER_SRC_WATCH_IMPLEMENTATION_HH_
+#define WATCH_HOLDER_SRC_WATCH_IMPLEMENTATION_HH_
+
+#include <Evas.h>
+#include <bundle_cpp.h>
+
+#include <memory>
+#include <string>
+#include <screen_connector_remote_surface_evas/remote_surface_evas.h>
+#include <screen_connector_remote_surface_evas/image.h>
+#include <screen_connector_remote_surface_evas/image_event_listener.h>
+
+#include "watch.hh"
+
+namespace watch_holder {
+
+class Watch::Impl {
+ public:
+ virtual ~Impl();
+
+ private:
+ friend class Watch;
+ Impl(Watch* parent, Evas_Object* viewer_win);
+
+ private:
+ Watch* parent_;
+ Evas_Object* bind_win_ = nullptr;
+ int no_render_timer_ = 0;
+ std::unique_ptr<screen_connector::Image> current_image_ = nullptr;
+ Evas_Object* viewer_win_ = nullptr;
+ screen_connector::ImageEventListener* image_event_listener_ = nullptr;
+};
+
+} // namespace watch_holder
+
+#endif // WATCH_HOLDER_SRC_WATCH_IMPLEMENTATION_HH_
#include <utility>
+#include "watch_mirror_implementation.hh"
#include "watch_mirror.hh"
#include "watch.hh"
#include "util.hh"
using namespace std;
namespace watch_holder {
+WatchMirror::Impl::Impl(WatchMirror* parent, Evas_Object* win)
+ : parent_(parent), viewer_win_(win) {
+}
+WatchMirror::Impl::~Impl() = default;
+
WatchMirror::~WatchMirror() = default;
-WatchMirror::WatchMirror(Evas_Object* win)
- : WatchMirrorBase(screen_connector::util::GetWlSurface(win)),
- viewer_win_(win) {
+WatchMirror::WatchMirror(Evas_Object* win) : WatchMirrorBase(),
+ impl_(new Impl(this, win)) {
}
void WatchMirror::OnChanged(const ISharableWatchBase& watch) {
void WatchMirror::OnChanged(int rid, std::string inst_id, std::string appid) {
WatchMirrorBase::AddWatch(make_shared<Watch>(
- rid, inst_id, appid, viewer_win_, nullptr, this));
+ rid, inst_id, appid, impl_->viewer_win_, nullptr, this));
shared_ptr<ISharableWatchBase> cur = WatchMirrorBase::GetCurrent();
OnChanged(*cur.get());
}
std::shared_ptr<WatchBase> WatchMirror::CreateWatch(int rid, std::string id,
std::string appid, bool mock) {
return make_shared<Watch>(rid, std::move(id), std::move(appid),
- viewer_win_, this, mock);
+ impl_->viewer_win_, this, mock);
}
std::shared_ptr<WatchBase> WatchMirror::CreateWatch(int rid, std::string id,
std::string appid, tizen_base::Bundle extra, bool mock) {
return make_shared<Watch>(rid, std::move(id), std::move(appid),
- viewer_win_, std::move(extra), this, mock);
+ impl_->viewer_win_, std::move(extra), this, mock);
}
} // namespace watch_holder
std::string appid, bool mock = false) override;
std::shared_ptr<WatchBase> CreateWatch(int rid, std::string id,
std::string appid, tizen_base::Bundle extra, bool mock = false) override;
+ void OnChanged(int rid, std::string inst_id, std::string appid) override;
private:
- void OnChanged(int, std::string inst_id, std::string appid) override;
-
- private:
- Evas_Object* viewer_win_;
+ class Impl;
+ std::unique_ptr<Impl> impl_;
};
} // namespace watch_holder
--- /dev/null
+/*
+ * Copyright (c) 2020 Samsung Electronics Co., Ltd.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef WATCH_HOLDER_SRC_WATCH_MIRROR_IMPLEMENTATION_HH_
+#define WATCH_HOLDER_SRC_WATCH_MIRROR_IMPLEMENTATION_HH_
+
+#include <Evas.h>
+
+#include <string>
+
+#include "watch_mirror.hh"
+
+namespace watch_holder {
+
+class WatchMirror::Impl {
+ public:
+ virtual ~Impl();
+
+ private:
+ friend class WatchMirror;
+ Impl(WatchMirror* parent, Evas_Object* viewer_win);
+
+ private:
+ WatchMirror* parent_;
+ Evas_Object* viewer_win_;
+};
+
+} // namespace watch_holder
+
+#endif // WATCH_HOLDER_SRC_WATCH_MIRROR_IMPLEMENTATION_HH_