Implement WatchSurface 39/226339/11
authorhyunho <hhstark.kang@samsung.com>
Mon, 2 Mar 2020 01:56:09 +0000 (10:56 +0900)
committerHyunho Kang <hhstark.kang@samsung.com>
Tue, 3 Mar 2020 01:54:02 +0000 (01:54 +0000)
Change-Id: I455f499b049586a8ac2b8f6f9da39e713c0f9705
Signed-off-by: hyunho <hhstark.kang@samsung.com>
22 files changed:
ambient-viewer/CMakeLists.txt
ambient-viewer/src/ambient-viewer.cc
ambient-viewer/src/ambient-viewer.h [deleted file]
ambient-viewer/src/ambient-viewer.hh [new file with mode: 0644]
ambient-viewer/src/iambient-viewer.h [deleted file]
ambient-viewer/src/iambient-viewer.hh [new file with mode: 0644]
ambient-viewer/src/internal.cc
ambient-viewer/src/internal.h [deleted file]
ambient-viewer/src/internal.hh [new file with mode: 0644]
ambient-viewer/src/isurface.h [deleted file]
ambient-viewer/src/isurface.hh [new file with mode: 0644]
ambient-viewer/src/stub.cc
ambient-viewer/src/top-app-surface.cc
ambient-viewer/src/top-app-surface.h [deleted file]
ambient-viewer/src/top-app-surface.hh [new file with mode: 0644]
ambient-viewer/src/watch-surface.cc
ambient-viewer/src/watch-surface.h [deleted file]
ambient-viewer/src/watch-surface.hh [new file with mode: 0644]
packaging/libwidget_viewer.spec
unittest/src/test_ambient_viewer.cc
watch-holder/src/watch_holder.hh
watch-holder/src/watch_mirror.hh

index d3fe7741caecb0e417b3dc0fd8abaa53c496faf9..c8ce3e7b74cdb65a65ade1155fd8ce29b3d27fc9 100644 (file)
@@ -42,9 +42,7 @@ SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${PROJECT_NAME}
 
 INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR})
 INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/ambient_viewer.h DESTINATION include/${PROJECT_NAME})
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/include/ambient_viewer_surface.h DESTINATION include/${PROJECT_NAME})
-#INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include DESTINATION include/${PROJECT_NAME}
-#      FILES_MATCHING PATTERN "*.h")
-#INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src DESTINATION include/${PROJECT_NAME}
-#      FILES_MATCHING PATTERN "*.h")
+INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION include/${PROJECT_NAME} FILES_MATCHING
+       PATTERN "*.h")
+INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src/ DESTINATION include/${PROJECT_NAME} FILES_MATCHING
+       PATTERN "*.hh")
\ No newline at end of file
index 5f57076f4c906ef651e5043343708ec71bb0e7f3..1d99bfe25ad8a56fe622d3c6ef16d5075b770024 100644 (file)
 
 #include <aul.h>
 #include <bundle.h>
+#include <bundle_cpp.h>
 #include <dlog.h>
 #include <aul_app_com.h>
+#include <uuid/uuid.h>
 
-#include "ambient-viewer.h"
-#include "top-app-surface.h"
-#include "watch-surface.h"
+#include "ambient-viewer.hh"
+#include "top-app-surface.hh"
+#include "watch-surface.hh"
 
 #ifdef LOG_TAG
 #undef LOG_TAG
 
 #define LOG_TAG "AMBIENT_VIEWER"
 
+#define NOTIFY_CHANGED_EVENT_APPID_KEY "__NOTIFY_CHANGED_EVENT_APPID_KEY__"
+#define NOTIFY_CHANGED_EVENT_RID_KEY "__NOTIFY_CHANGED_EVENT_RID_KEY__"
+
+using namespace std;
 using namespace tizen_base;
 namespace ambient_viewer {
 
-AmbientViewer::AmbientViewer(std::shared_ptr<screen_connector::EvasObject> win)
+AmbientViewer::AmbientViewer(Evas_Object* win)
     : win_(win) {
   char appid_buf[512] = {0, };
   if (aul_app_get_appid_bypid(
@@ -53,13 +59,41 @@ AmbientViewer::AmbientViewer(std::shared_ptr<screen_connector::EvasObject> win)
 
 AmbientViewer::~AmbientViewer() = default;
 
-void AmbientViewer::Monitor() {
-  char appid[512] = {0, };
-  if (aul_app_get_appid_bypid(getpid(), appid, sizeof(appid)) != AUL_R_OK)
-    LOGE("Failed to get appid (%d)", getpid());
+string AmbientViewer::GetUUID(string rid) const {
+  char uuid[37];
+  uuid_t u;
 
-  top_app_surface_ = std::make_shared<TopAppSurface>(win_, this);
-  watch_surface_ = std::make_shared<WatchSurface>(appid, win_, this);
+  uuid_generate(u);
+  uuid_unparse(u, uuid);
+  return string(uuid) + rid;
+}
+
+void AmbientViewer::OnChangedSignal(keynode_t *node, void *user_data) {
+  AmbientViewer* viewer = (AmbientViewer*)user_data;
+  const char* raw = vconf_get_str(VCONFKEY_WATCH_CURRENT_WATCH_INFO);
+  if (raw == nullptr || strlen(raw) == 0)
+    return;
+  try {
+    Bundle data(raw);
+    string appid = data.GetString(NOTIFY_CHANGED_EVENT_APPID_KEY);
+    string rid = data.GetString(NOTIFY_CHANGED_EVENT_RID_KEY);
+    viewer->watch_surface_ = make_shared<WatchSurface>(
+      stoi(rid), viewer->GetUUID(rid), appid, viewer->win_, viewer);
+  } catch (const std::exception& e) {
+    LOGE("Exception occurred : %s", e.what());
+    return;
+  }
+}
+
+void AmbientViewer::Monitor() {
+  top_app_surface_ = std::make_shared<TopAppSurface>(
+      make_shared<screen_connector::EvasObject>(win_, false), this);
+  if (vconf_notify_key_changed(
+      VCONFKEY_WATCH_CURRENT_WATCH_INFO, OnChangedSignal, this) != 0) {
+    LOGE("failed to listen on changed signal");
+    return;
+  }
+  OnChangedSignal(nullptr, this);
 }
 
 void AmbientViewer::Unmonitor() {
@@ -67,6 +101,10 @@ void AmbientViewer::Unmonitor() {
   watch_surface_.reset();
 }
 
+void AmbientViewer::OnReceived(AmbientViewer::EventType ev, std::string sender,
+    Bundle extra) {
+}
+
 int AmbientViewer::NotifyAmbientEvent(bool enter, AmbientViewer::Direction dir,
     Bundle extra) {
   bundle* b;
diff --git a/ambient-viewer/src/ambient-viewer.h b/ambient-viewer/src/ambient-viewer.h
deleted file mode 100644 (file)
index d500e57..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * 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_AMBIENT_VIEWER_H__
-#define __AMBIENT_VIEWER_AMBIENT_VIEWER_H__
-
-#include <aul.h>
-#include <aul_app_com.h>
-#include <bundle.h>
-#include <bundle_cpp.h>
-
-#include <string>
-#include <memory>
-
-#include "iambient-viewer.h"
-#include "isurface.h"
-
-#ifndef EXPORT_API
-#define EXPORT_API __attribute__((visibility("default")))
-#endif
-
-namespace ambient_viewer {
-
-class EXPORT_API AmbientViewer : public IAmbientViewer {
- public:
-  enum EventType {
-    EVENT_AOD_PREPARE,
-    EVENT_AOD_READY,
-    EVENT_WATCH_CHANGED,
-  };
-
-  enum Direction {
-    DIRECTION_VIEWER_AND_WATCH,
-    DIRECTION_VIEWER_AND_TOP_APP,
-    DIRECTION_ALL,
-  };
-
- public:
-  AmbientViewer(std::shared_ptr<screen_connector::EvasObject> win);
-
-  virtual ~AmbientViewer();
-  virtual void OnReceived(EventType ev, std::string sender, tizen_base::Bundle extra) = 0;
-
-  void Monitor();
-  void Unmonitor();
-  int NotifyAmbientEvent(bool enter, Direction dir, tizen_base::Bundle extra);
-  const ISurface& GetWatchSurface() const;
-  const ISurface& GetTopAppSurface() const;
-
- private:
-  static int OnReceiveSignal(const char *endpoint, aul_app_com_result_e e,
-      bundle *envelope, void *user_data);
-
-  std::shared_ptr<screen_connector::EvasObject> win_;
-  std::shared_ptr<ISurface> watch_surface_;
-  std::shared_ptr<ISurface> top_app_surface_;
-  aul_app_com_connection_h receive_signal_conn_;
-};
-
-}  // namespace ambient_viewer
-
-#endif  // __AMBIENT_VIEWER_AMBIENT_VIEWER_H__
diff --git a/ambient-viewer/src/ambient-viewer.hh b/ambient-viewer/src/ambient-viewer.hh
new file mode 100644 (file)
index 0000000..6d7f5f8
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * 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_AMBIENT_VIEWER_H__
+#define __AMBIENT_VIEWER_AMBIENT_VIEWER_H__
+
+#include <aul_app_com.h>
+#include <bundle.h>
+#include <bundle_cpp.h>
+#include <vconf.h>
+
+#include <string>
+#include <memory>
+
+#include "iambient-viewer.hh"
+#include "isurface.hh"
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__((visibility("default")))
+#endif
+
+namespace ambient_viewer {
+
+class EXPORT_API AmbientViewer : public IAmbientViewer {
+ public:
+  enum EventType {
+    EVENT_AOD_PREPARE,
+    EVENT_AOD_READY,
+    EVENT_WATCH_CHANGED,
+  };
+
+  enum Direction {
+    DIRECTION_VIEWER_AND_WATCH,
+    DIRECTION_VIEWER_AND_TOP_APP,
+    DIRECTION_ALL,
+  };
+
+ public:
+  AmbientViewer(Evas_Object* win);
+  virtual ~AmbientViewer();
+  void Monitor();
+  void Unmonitor();
+  virtual void OnReceived(EventType ev, std::string sender, tizen_base::Bundle extra) = 0;
+  int NotifyAmbientEvent(bool enter, Direction dir, tizen_base::Bundle extra);
+  const ISurface& GetWatchSurface() const;
+  const ISurface& GetTopAppSurface() const;
+
+ private:
+  std::string GetUUID(std::string rid) const;
+  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::shared_ptr<ISurface> watch_surface_;
+  std::shared_ptr<ISurface> top_app_surface_;
+  aul_app_com_connection_h receive_signal_conn_ = nullptr;
+};
+
+}  // namespace ambient_viewer
+
+#endif  // __AMBIENT_VIEWER_AMBIENT_VIEWER_H__
diff --git a/ambient-viewer/src/iambient-viewer.h b/ambient-viewer/src/iambient-viewer.h
deleted file mode 100644 (file)
index 04c3e79..0000000
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * 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_IAMBIENTVIEWER_H__
-#define __AMBIENT_VIEWER_IAMBIENTVIEWER_H__
-
-#ifndef EXPORT_API
-#define EXPORT_API __attribute__((visibility("default")))
-#endif
-
-#include <string>
-
-#include "isurface.h"
-
-namespace ambient_viewer {
-
-class EXPORT_API IAmbientViewer {
-   public:
-    virtual ~IAmbientViewer() = default;
-    virtual void OnAdded(const ISurface& surface) = 0;
-    virtual void OnUpdated(const ISurface& surface) = 0;
-    virtual void OnRemoved(const ISurface& surface) = 0;
-};
-
-}  //namespace ambient_viewer
-
-#endif // __AMBIENT_VIEWER_IAMBIENTVIEWER_H__
diff --git a/ambient-viewer/src/iambient-viewer.hh b/ambient-viewer/src/iambient-viewer.hh
new file mode 100644 (file)
index 0000000..165b2b0
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * 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_IAMBIENTVIEWER_H__
+#define __AMBIENT_VIEWER_IAMBIENTVIEWER_H__
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__((visibility("default")))
+#endif
+
+#include <string>
+
+#include "isurface.hh"
+
+namespace ambient_viewer {
+
+class EXPORT_API IAmbientViewer {
+   public:
+    virtual ~IAmbientViewer() = default;
+    virtual void OnAdded(const ISurface& surface) = 0;
+    virtual void OnUpdated(const ISurface& surface) = 0;
+    virtual void OnRemoved(const ISurface& surface) = 0;
+};
+
+}  //namespace ambient_viewer
+
+#endif // __AMBIENT_VIEWER_IAMBIENTVIEWER_H__
index a986620203da0b36809aa280c986bbd20246b993..c3fd82df769f65fd1bd22212f8b1647827845889 100644 (file)
 
 #include <system_info.h>
 
-#include "internal.h"
+#include "internal.hh"
 
 #define KEY_SCREEN_SHAPE_CIRCLE "http://tizen.org/feature/screen.shape.circle"
 
 namespace ambient_viewer::internal {
 
-float _GetOpr(void* source_data, int width, int height) {
+float GetOpr(void* source_data, int width, int height) {
   int *source;
   int x;
   int y;
diff --git a/ambient-viewer/src/internal.h b/ambient-viewer/src/internal.h
deleted file mode 100644 (file)
index a0c2259..0000000
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * 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_INTERNAL_H__
-#define __AMBIENT_VIEWER_INTERNAL_H__
-
-namespace ambient_viewer::internal {
-
-  float _GetOpr(void* source_data, int width, int height);
-
-}  // namespace ambient_viewer::internal
-
-#endif  // __AMBIENT_VIEWER_INTERNAL_H__
-
-
-
diff --git a/ambient-viewer/src/internal.hh b/ambient-viewer/src/internal.hh
new file mode 100644 (file)
index 0000000..0457719
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * 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_INTERNAL_H__
+#define __AMBIENT_VIEWER_INTERNAL_H__
+
+namespace ambient_viewer::internal {
+
+  float GetOpr(void* source_data, int width, int height);
+
+}  // namespace ambient_viewer::internal
+
+#endif  // __AMBIENT_VIEWER_INTERNAL_H__
+
+
+
diff --git a/ambient-viewer/src/isurface.h b/ambient-viewer/src/isurface.h
deleted file mode 100644 (file)
index 5d940f2..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * 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_ISURFACE_H__
-#define __AMBIENT_VIEWER_ISURFACE_H__
-
-#ifndef EXPORT_API
-#define EXPORT_API __attribute__((visibility("default")))
-#endif
-
-#include <evas_object.h>
-
-#include <string>
-
-namespace ambient_viewer {
-
-class EXPORT_API ISurface {
- public:
-  virtual ~ISurface() = default;
-  virtual screen_connector::EvasObject& GetCurrentImage() const = 0;
-  virtual bool IsWatch() const = 0;
-  virtual std::string GetAppId() const = 0;
-  virtual std::string GetInstId() const = 0;
-  virtual float GetOpr() const = 0;
-};
-
-}  //namespace ambient_viewer
-
-#endif // __AMBIENT_VIEWER_ISURFACE_H__
diff --git a/ambient-viewer/src/isurface.hh b/ambient-viewer/src/isurface.hh
new file mode 100644 (file)
index 0000000..768e8a1
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * 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_ISURFACE_H__
+#define __AMBIENT_VIEWER_ISURFACE_H__
+
+#ifndef EXPORT_API
+#define EXPORT_API __attribute__((visibility("default")))
+#endif
+
+#include <Elementary.h>
+
+#include <string>
+
+namespace ambient_viewer {
+
+class EXPORT_API ISurface {
+ public:
+  virtual ~ISurface() = default;
+  virtual Evas_Object* GetCurrentImage() const = 0;
+  virtual bool IsWatch() const = 0;
+  virtual std::string GetAppId() const = 0;
+  virtual std::string GetInstId() const = 0;
+  virtual float GetOpr() const = 0;
+};
+
+}  //namespace ambient_viewer
+
+#endif // __AMBIENT_VIEWER_ISURFACE_H__
index cfbb7370d82d8d1834e67f62cfbad30d19a36184..8f618d78a85ff38e7f0a372b688a24b76a1abc0d 100644 (file)
  */
 
 #include <dlog.h>
-#include <remote_surface_watcher.h>
+#include <bundle_cpp.h>
 
 #include "ambient_viewer.h"
 #include "ambient_viewer_surface.h"
 #include "ambient_viewer_common.h"
 
-#include "ambient-viewer.h"
-#include "isurface.h"
+#include "ambient-viewer.hh"
+#include "isurface.hh"
 
 using namespace std;
 using namespace tizen_base;
 using namespace ambient_viewer;
-using namespace screen_connector;
 
 class MonitorCallbackInfo {
  public:
@@ -79,7 +78,7 @@ class ReceiveCallbackInfo {
 
 class AmbientViewerStub : public AmbientViewer {
  public:
-  AmbientViewerStub(std::shared_ptr<EvasObject> win)
+  AmbientViewerStub(Evas_Object* win)
     : AmbientViewer(win) {
   }
 
@@ -132,8 +131,7 @@ extern "C" EXPORT_API int ambient_viewer_create(Evas_Object *win,
     return AMBIENT_VIEWER_ERROR_INVALID_PARAMETER;
   }
 
-  AmbientViewerStub* h = new (nothrow) AmbientViewerStub(
-    shared_ptr<EvasObject>(new EvasObject(win, false)));
+  AmbientViewerStub* h = new (nothrow) AmbientViewerStub(win);
   if (h == nullptr) {
     LOGE("out of memory");
     return AMBIENT_VIEWER_ERROR_OUT_OF_MEMORY;
@@ -285,7 +283,7 @@ extern "C" EXPORT_API int ambient_viewer_surface_get_cur_image(
   }
 
   const ISurface* surface = static_cast<const ISurface*>(handle);
-  *image = surface->GetCurrentImage().GetRaw();
+  *image = surface->GetCurrentImage();
 
   return AMBIENT_VIEWER_ERROR_NONE;
 }
index daedd9526a60eabaad610edde13f22121e16c0e4..76aecc94a96a1e193e7e573cf783b11b5885b57c 100644 (file)
  * limitations under the License.
  */
 
+#include <dlog.h>
 
-#include "top-app-surface.h"
-#include "internal.h"
+#include "top-app-surface.hh"
+#include "internal.hh"
 
-using namespace ambient_viewer::internal;
-using namespace screen_connector;
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "AMBIENT_VIEWER"
 
 namespace ambient_viewer {
 
 TopAppSurface::TopAppSurface(
-    std::shared_ptr<EvasObject> surface, IAmbientViewer* listener)
-    : RemoteSurfaceWatcher(RemoteSurface::UI, surface), listener_(listener) {
+    std::shared_ptr<screen_connector::EvasObject> surface, IAmbientViewer* listener)
+    : screen_connector::RemoteSurfaceWatcher(
+          screen_connector::RemoteSurface::UI, surface), listener_(listener) {
 }
 
 TopAppSurface::~TopAppSurface() = default;
 
-EvasObject& TopAppSurface::GetCurrentImage() const {
-  return *image_;
+Evas_Object* TopAppSurface::GetCurrentImage() const {
+  return image_;
 }
 
 bool TopAppSurface::IsWatch() const {
@@ -60,9 +65,9 @@ float TopAppSurface::GetOpr() const {
   if (image_ == nullptr)
     return 0;
 
-  evas_object_geometry_get(image_->GetRaw(), nullptr, nullptr, &width, &height);
+  evas_object_geometry_get(image_, nullptr, nullptr, &width, &height);
 
-  ns = evas_object_image_native_surface_get(image_->GetRaw());
+  ns = evas_object_image_native_surface_get(image_);
   if (ns == nullptr) {
     return 0;
   }
@@ -84,7 +89,7 @@ float TopAppSurface::GetOpr() const {
     return 0;
   }
 
-  opr = _GetOpr(source_data, width, height);
+  opr = ambient_viewer::internal::GetOpr(source_data, width, height);
 
   tbm_surface_unmap(surface);
 
@@ -95,15 +100,17 @@ void TopAppSurface::OnWatcherAdded(const std::string& appId,
                             const std::string& instId, const int pid) {
   app_id_ = appId;
   inst_id_ = instId;
-
-  listener_->OnAdded(*this);
 }
 
 void TopAppSurface::OnWatcherChanged(const std::string& appId,
                             const std::string& instId, const int pid,
-                            const EvasObject& image) {
-  *image_ = image;
-  listener_->OnUpdated(*this);
+                            const screen_connector::EvasObject& image) {
+  bool added = (image_ == nullptr);
+  image_ = image.GetRaw();
+  if (added)
+    listener_->OnAdded(*this);
+  else
+    listener_->OnUpdated(*this);
 }
 
 void TopAppSurface::OnWatcherRemoved(const std::string& appId,
diff --git a/ambient-viewer/src/top-app-surface.h b/ambient-viewer/src/top-app-surface.h
deleted file mode 100644 (file)
index c044d75..0000000
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * 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_TOP_APP_SURFACE_H__
-#define __AMBIENT_VIEWER_TOP_APP_SURFACE_H__
-
-#include <remote_surface_watcher.h>
-
-#include <string>
-#include <memory>
-
-#include "iambient-viewer.h"
-#include "isurface.h"
-#include "ambient-viewer.h"
-
-namespace ambient_viewer {
-
-class TopAppSurface : public screen_connector::RemoteSurfaceWatcher,
-    public ISurface {
- public:
-  screen_connector::EvasObject& GetCurrentImage() const override;
-  bool IsWatch() const override;
-  std::string GetAppId() const override;
-  std::string GetInstId() const override;
-  float GetOpr() const override;
-
-  TopAppSurface(std::shared_ptr<screen_connector::EvasObject> surface,
-    IAmbientViewer* listener);
-  virtual ~TopAppSurface();
-
- private:
-  void OnWatcherAdded(const std::string& appId, const std::string& instId,
-                    const int pid) override;
-  void OnWatcherChanged(const std::string& appId, const std::string& instId,
-                    const int pid,
-                    const screen_connector::EvasObject& image) override;
-  void OnWatcherRemoved(const std::string& appId, const std::string& instId,
-                    const int pid) override;
-
- private:
-  std::shared_ptr<screen_connector::EvasObject> image_;
-  std::string app_id_;
-  std::string inst_id_;
-
-  IAmbientViewer* listener_;
-};
-
-}  // namespace ambient_viewer
-
-#endif // __AMBIENT_VIEWER_TOP_APP_SURFACE_H__
diff --git a/ambient-viewer/src/top-app-surface.hh b/ambient-viewer/src/top-app-surface.hh
new file mode 100644 (file)
index 0000000..0a539c2
--- /dev/null
@@ -0,0 +1,63 @@
+/*
+ * 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_TOP_APP_SURFACE_H__
+#define __AMBIENT_VIEWER_TOP_APP_SURFACE_H__
+
+#include <remote_surface_watcher.h>
+
+#include <string>
+#include <memory>
+
+#include "iambient-viewer.hh"
+#include "isurface.hh"
+#include "ambient-viewer.hh"
+
+namespace ambient_viewer {
+
+class TopAppSurface : public screen_connector::RemoteSurfaceWatcher,
+    public ISurface {
+ public:
+  Evas_Object* GetCurrentImage() const override;
+  bool IsWatch() const override;
+  std::string GetAppId() const override;
+  std::string GetInstId() const override;
+  float GetOpr() const override;
+
+  TopAppSurface(std::shared_ptr<screen_connector::EvasObject> surface,
+    IAmbientViewer* listener);
+  virtual ~TopAppSurface();
+
+ private:
+  void OnWatcherAdded(const std::string& appId, const std::string& instId,
+                    const int pid) override;
+  void OnWatcherChanged(const std::string& appId, const std::string& instId,
+                    const int pid,
+                    const screen_connector::EvasObject& image) override;
+  void OnWatcherRemoved(const std::string& appId, const std::string& instId,
+                    const int pid) override;
+
+ private:
+  Evas_Object* image_ = nullptr;
+  std::string app_id_;
+  std::string inst_id_;
+
+  IAmbientViewer* listener_;
+};
+
+}  // namespace ambient_viewer
+
+#endif // __AMBIENT_VIEWER_TOP_APP_SURFACE_H__
index 7b516f93b7914c1603274926e64e69123413b140..7f455d9ec9585eebae37c2470d19d29e9957d02f 100644 (file)
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
+#include <dlog.h>
 
-#include "watch-surface.h"
-#include "internal.h"
+#include "watch-surface.hh"
+#include "internal.hh"
 
-using namespace std;
-using namespace ambient_viewer::internal;
-using namespace screen_connector;
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "AMBIENT_VIEWER"
 
 namespace ambient_viewer {
 
-WatchSurface::WatchSurface(string appid,
-    shared_ptr<EvasObject> surface, IAmbientViewer* listener)
-    : RemoteSurfaceEvas(appid, RemoteSurface::WATCH, surface),
-      listener_(listener) {
+WatchSurface::WatchSurface(
+    int rid, std::string id, std::string appid,
+    Evas_Object* viewer_win, IAmbientViewer* listener)
+    : RemoteSurfaceEvas(rid, id, RemoteSurface::WATCH,
+        std::make_shared<screen_connector::EvasObject>(viewer_win, false)),
+        appid_(appid), listener_(listener) {
+  LOGI("WatchSurface created (%s)", appid.c_str());
 }
 
 WatchSurface::~WatchSurface() = default;
 
-EvasObject& WatchSurface::GetCurrentImage() const {
-  return *image_;
+Evas_Object* WatchSurface::GetCurrentImage() const {
+  return image_;
 }
 
 bool WatchSurface::IsWatch() const {
@@ -40,7 +46,7 @@ bool WatchSurface::IsWatch() const {
 }
 
 std::string WatchSurface::GetAppId() const {
-  return app_id_;
+  return appid_;
 }
 
 std::string WatchSurface::GetInstId() const {
@@ -61,9 +67,9 @@ float WatchSurface::GetOpr() const {
   if (image_ == nullptr)
     return 0;
 
-  evas_object_geometry_get(image_->GetRaw(), nullptr, nullptr, &width, &height);
+  evas_object_geometry_get(image_, nullptr, nullptr, &width, &height);
 
-  ns = evas_object_image_native_surface_get(image_->GetRaw());
+  ns = evas_object_image_native_surface_get(image_);
   if (ns == nullptr) {
     return 0;
   }
@@ -85,8 +91,7 @@ float WatchSurface::GetOpr() const {
     return 0;
   }
 
-  opr = _GetOpr(source_data, width, height);
-
+  opr = ambient_viewer::internal::GetOpr(source_data, width, height);
   tbm_surface_unmap(surface);
 
   return opr;
@@ -94,25 +99,24 @@ float WatchSurface::GetOpr() const {
 
 void WatchSurface::OnEvasAdded(const std::string& appId,
                             const std::string& instId, int pid,
-                            const EvasObject& image) {
-  app_id_ = appId;
+                            const screen_connector::EvasObject& image) {
   inst_id_ = instId;
-  *image_ = image;
+  image_ = image.GetRaw();
 
   listener_->OnAdded(*this);
 }
 
 void WatchSurface::OnEvasRemoved(const std::string& appId,
                             const std::string& instId, int pid,
-                            const EvasObject& image) {
+                            const screen_connector::EvasObject& image) {
   image_ = nullptr;
   listener_->OnRemoved(*this);
 }
 
 void WatchSurface::OnEvasChanged(const std::string& appId,
                             const std::string& instId, int pid,
-                            const EvasObject& image) {
-  *image_ = image;
+                            const screen_connector::EvasObject& image) {
+  image_ = image.GetRaw();
   listener_->OnUpdated(*this);
 }
 
diff --git a/ambient-viewer/src/watch-surface.h b/ambient-viewer/src/watch-surface.h
deleted file mode 100644 (file)
index 33fe89e..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * 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_WATCH_SURFACE_H__
-#define __AMBIENT_VIEWER_WATCH_SURFACE_H__
-
-#include <remote_surface_evas.h>
-
-#include <string>
-#include <memory>
-
-#include "iambient-viewer.h"
-#include "isurface.h"
-#include "ambient-viewer.h"
-
-namespace ambient_viewer {
-
-class WatchSurface : public screen_connector::RemoteSurfaceEvas, public ISurface {
- public:
-  screen_connector::EvasObject& GetCurrentImage() const override;
-  bool IsWatch() const override;
-  std::string GetAppId() const override;
-  std::string GetInstId() const override;
-  float GetOpr() const override;
-
-  WatchSurface(std::string appid,
-    std::shared_ptr<screen_connector::EvasObject> surface,
-    IAmbientViewer* listener);
-  virtual ~WatchSurface();
-
- private:
-  void OnEvasAdded(const std::string& appId, const std::string& instId,
-                    int pid, const screen_connector::EvasObject& image) override;
-  void OnEvasRemoved(const std::string& appId, const std::string& instId,
-                    int pid, const screen_connector::EvasObject& image) override;
-  void OnEvasChanged(const std::string& appId, const std::string& instId,
-                    int pid, const screen_connector::EvasObject& image) override;
-
- private:
-  std::shared_ptr<screen_connector::EvasObject> image_;
-  std::string app_id_;
-  std::string inst_id_;
-
-  IAmbientViewer* listener_;
-};
-
-}  // namespace ambient_viewer
-
-#endif // __AMBIENT_VIEWER_WATCH_SURFACE_H__
diff --git a/ambient-viewer/src/watch-surface.hh b/ambient-viewer/src/watch-surface.hh
new file mode 100644 (file)
index 0000000..2b3f1b4
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+ * 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_WATCH_SURFACE_H__
+#define __AMBIENT_VIEWER_WATCH_SURFACE_H__
+
+#include <remote_surface_evas.h>
+
+#include <string>
+#include <memory>
+
+#include "iambient-viewer.hh"
+#include "isurface.hh"
+#include "ambient-viewer.hh"
+
+namespace ambient_viewer {
+
+class WatchSurface : public screen_connector::RemoteSurfaceEvas, public ISurface {
+ public:
+  Evas_Object* GetCurrentImage() const override;
+  bool IsWatch() const override;
+  std::string GetAppId() const override;
+  std::string GetInstId() const override;
+  float GetOpr() const override;
+  WatchSurface(int rid, std::string id, std::string appid,
+      Evas_Object* viewer_win, IAmbientViewer* listener);
+  virtual ~WatchSurface();
+
+ private:
+  void OnEvasAdded(const std::string& appId, const std::string& instId,
+                    int pid, const screen_connector::EvasObject& image) override;
+  void OnEvasRemoved(const std::string& appId, const std::string& instId,
+                    int pid, const screen_connector::EvasObject& image) override;
+  void OnEvasChanged(const std::string& appId, const std::string& instId,
+                    int pid, const screen_connector::EvasObject& image) override;
+
+ private:
+  Evas_Object* image_ = nullptr;
+  std::string appid_;
+  std::string inst_id_;
+
+  IAmbientViewer* listener_;
+};
+
+}  // namespace ambient_viewer
+
+#endif // __AMBIENT_VIEWER_WATCH_SURFACE_H__
index 61090b1cf38fc8c6b8ad9464d4cabd227e210d8d..1170a46a87960aff0037343de1a9a217c9b365fa 100644 (file)
@@ -353,6 +353,7 @@ Header & package configuration of ambient-viewer
 
 %files -n ambient-viewer-devel
 %{_includedir}/ambient-viewer/*.h
+%{_includedir}/ambient-viewer/*.hh
 %{_libdir}/pkgconfig/ambient-viewer.pc
 %{_libdir}/libambient-viewer.so
 # End of a file
index 5dc85179ea42de58f576ebb78cd0f70e420a22f1..87227d80d32d468b7c7895c75bb2c7929826a6ee 100644 (file)
 #include <gtest/gtest.h>
 #include <gmock/gmock.h>
 
-#include <ambient-viewer.h>
+#include <ambient-viewer.hh>
 
 using namespace std;
 using namespace ambient_viewer;
-using namespace screen_connector;
 using namespace tizen_base;
 
 class AmbientViewerStub : public AmbientViewer {
  public:
-  AmbientViewerStub(std::shared_ptr<EvasObject> win)
+  AmbientViewerStub(Evas_Object* win)
     : AmbientViewer(win) {
   }
   void OnAdded(const ISurface& surface) override {}
@@ -42,7 +41,7 @@ class AmbientViewerTest : public ::testing::Test {
 
   virtual void SetUp() {
     Evas_Object* win = elm_win_add(NULL, "Widget Viewer", ELM_WIN_BASIC);
-    stub = new AmbientViewerStub(shared_ptr<EvasObject>(new EvasObject(win, false)));
+    stub = new AmbientViewerStub(win);
   }
   virtual void TearDown() {
     delete stub;
index 5ab3bef62bf9eabad1b71c4e47e4632e1a25e1b7..cdf92a5d782dd00dc77bd794b3d9adcafee4c35d 100644 (file)
@@ -54,9 +54,9 @@ class EXPORT_API WatchHolder : public Watch::IEvent, public AmbientListener {
   std::string appid_;
   Evas_Object* win_;
   std::list<std::shared_ptr<Watch>> stack_;
-  aul_app_com_connection_h launch_signal_conn_;
-  aul_app_com_connection_h dead_signal_conn_;
-  aul_app_com_connection_h ambient_changed_signal_conn_;
+  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;
 };
 
 }  // namespace watch_holder
index f7863062aa3ff8f03c2f42328b829d0f19455003..adbd12b0a5f3608978a23279fbf626a9eb5cf601 100644 (file)
@@ -56,6 +56,7 @@ class EXPORT_API WatchMirror : public Watch::IEvent, public AmbientListener {
  private:
   std::string appid_;
   Evas_Object* win_;
+  aul_app_com_connection_h watch_changed_conn_ = nullptr;
   std::list<std::shared_ptr<Watch>> stack_;
 };