From: Hwankyu Jhun Date: Sun, 25 Aug 2019 07:31:09 +0000 (+0900) Subject: Support Seamless Effect X-Git-Tag: submit/tizen/20191014.064156~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F45%2F212645%2F55;p=platform%2Fcore%2Fappfw%2Fscreen-connector.git Support Seamless Effect Adds: - screen_connector_launcher_service - screen_connector_launcher_service_evas - screen_connector_shared_widget_launch Requires: - https://review.tizen.org/gerrit/#/c/platform/core/appfw/amd/+/212912/ - https://review.tizen.org/gerrit/#/c/platform/core/appfw/app-core/+/215390/ - https://review.tizen.org/gerrit/#/c/platform/core/appfw/aul-1/+/212287/ - https://review.tizen.org/gerrit/#/c/platform/core/appfw/screen-connector/+/212645/ - https://review.tizen.org/gerrit/#/c/platform/core/appfw/widget-viewer/+/213445/ Change-Id: Iadf0983dd75a3f3c3b21e8eac1e3b9bceb306b5e Signed-off-by: Hwankyu Jhun --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 9afb333..219e233 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,8 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +ADD_SUBDIRECTORY(screen_connector_launcher_service) +ADD_SUBDIRECTORY(screen_connector_launcher_service_evas) +ADD_SUBDIRECTORY(screen_connector_shared_widget_launch) ADD_SUBDIRECTORY(screen_connector_provider) ADD_SUBDIRECTORY(screen_connector_remote_surface) ADD_SUBDIRECTORY(screen_connector_remote_surface_evas) @@ -7,6 +10,7 @@ ADD_SUBDIRECTORY(screen_connector_watcher) ADD_SUBDIRECTORY(screen_connector_watcher_evas) ADD_SUBDIRECTORY(unittest) +ADD_DEPENDENCIES(screen_connector_launcher_service_evas screen_connector_launcher_service) ADD_DEPENDENCIES(screen_connector_remote_surface_evas screen_connector_remote_surface) ADD_DEPENDENCIES(screen_connector_watcher screen_connector_remote_surface) ADD_DEPENDENCIES(screen_connector_watcher_evas screen_connector_watcher screen_connector_remote_surface_evas) diff --git a/packaging/libscreen_connector.spec b/packaging/libscreen_connector.spec index d90c7f0..213a6a7 100644 --- a/packaging/libscreen_connector.spec +++ b/packaging/libscreen_connector.spec @@ -10,6 +10,9 @@ Source1002: %{name}_watcher_evas.manifest Source1003: %{name}_provider.manifest Source1004: %{name}_remote_surface.manifest Source1005: %{name}_remote_surface_evas.manifest +Source1006: %{name}_launcher_service.manifest +Source1007: %{name}_launcher_service_evas.manifest +Source1008: %{name}_shared_widget_launch.manifest BuildRequires: cmake BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(aul) @@ -20,6 +23,7 @@ BuildRequires: pkgconfig(elementary) BuildRequires: pkgconfig(wayland-client) BuildRequires: pkgconfig(ecore-wl2) BuildRequires: pkgconfig(gmock) +BuildRequires: pkgconfig(tzsh-launcher-service) %description API for creating a new instance of the widget and managing its life-cycle. @@ -39,6 +43,9 @@ cp %{SOURCE1002} . cp %{SOURCE1003} . cp %{SOURCE1004} . cp %{SOURCE1005} . +cp %{SOURCE1006} . +cp %{SOURCE1007} . +cp %{SOURCE1008} . %build @@ -231,5 +238,103 @@ GTest for screen-connector %files -n gtest-screen-connector %{_bindir}/gtest-screen-connector +################################################# +# libscreen_connector_launcher_service +################################################# +%package -n %{name}_launcher_service +Summary: Library for developing the screen connector launcher service +Group: Applications/Core Applications +License: Apache-2.0 + +%description -n %{name}_launcher_service +Launcher Service APIs to develop the screen connector launcher application. + +%package -n %{name}_launcher_service-devel +Summary: Screen connector launcher application development library (dev) +Group: Development/Libraries +Requires: %{name}_launcher_service + +%description -n %{name}_launcher_service-devel +Header & package files to support development of the launcher applications. + +%post -n %{name}_launcher_service -p /sbin/ldconfig + +%postun -n %{name}_launcher_service -p /sbin/ldconfig + +%files -n %{name}_launcher_service +%manifest %{name}_launcher_service.manifest +%attr(0644,root,root) %{_libdir}/%{name}_launcher_service.so.* +%license LICENSE + +%files -n %{name}_launcher_service-devel +%{_includedir}/screen_connector_launcher_service/*.h +%{_libdir}/pkgconfig/screen_connector_launcher_service.pc +%attr(0644,root,root) %{_libdir}/%{name}_launcher_service.so + +################################################# +# libscreen_connector_launcher_service_evas +################################################# +%package -n %{name}_launcher_service_evas +Summary: Library for developing the screen connector launcher service evas +Group: Applications/Core Applications +License: Apache-2.0 + +%description -n %{name}_launcher_service_evas +Launcher Service Evas APIs to develop the screen connector launcher application. + +%package -n %{name}_launcher_service_evas-devel +Summary: Screen connector launcher service evas application development library (dev) +Group: Development/Libraries +Requires: %{name}_launcher_service_evas + +%description -n %{name}_launcher_service_evas-devel +Header & package files to support development of the launcher service evas applications. + +%post -n %{name}_launcher_service_evas -p /sbin/ldconfig + +%postun -n %{name}_launcher_service_evas -p /sbin/ldconfig + +%files -n %{name}_launcher_service_evas +%manifest %{name}_launcher_service_evas.manifest +%attr(0644,root,root) %{_libdir}/%{name}_launcher_service_evas.so.* +%license LICENSE + +%files -n %{name}_launcher_service_evas-devel +%{_includedir}/screen_connector_launcher_service_evas/* +%{_libdir}/pkgconfig/screen_connector_launcher_service_evas.pc +%attr(0644,root,root) %{_libdir}/%{name}_launcher_service_evas.so + +################################################# +# libscreen_connector_shared_widget_launch +################################################# +%package -n %{name}_shared_widget_launch +Summary: Library for developing the screen connector shared launch widget +Group: Applications/Core Applications +License: Apache-2.0 + +%description -n %{name}_shared_widget_launch +Shared Widget Launch APIs to develop the screen connector launcher application. + +%package -n %{name}_shared_widget_launch-devel +Summary: Screen connector shared widget launch application development library (dev) +Group: Development/Libraries +Requires: %{name}_launcher_service_evas + +%description -n %{name}_shared_widget_launch-devel +Header & package files to support development of the shared widget launch applications. + +%post -n %{name}_shared_widget_launch -p /sbin/ldconfig + +%postun -n %{name}_shared_widget_launch -p /sbin/ldconfig + +%files -n %{name}_shared_widget_launch +%manifest %{name}_shared_widget_launch.manifest +%attr(0644,root,root) %{_libdir}/%{name}_shared_widget_launch.so.* +%license LICENSE + +%files -n %{name}_shared_widget_launch-devel +%{_includedir}/screen_connector_shared_widget_launch/* +%{_libdir}/pkgconfig/screen_connector_shared_widget_launch.pc +%attr(0644,root,root) %{_libdir}/%{name}_shared_widget_launch.so # End of a file diff --git a/packaging/libscreen_connector_launcher_service.manifest b/packaging/libscreen_connector_launcher_service.manifest new file mode 100644 index 0000000..a76fdba --- /dev/null +++ b/packaging/libscreen_connector_launcher_service.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/packaging/libscreen_connector_launcher_service_evas.manifest b/packaging/libscreen_connector_launcher_service_evas.manifest new file mode 100644 index 0000000..a76fdba --- /dev/null +++ b/packaging/libscreen_connector_launcher_service_evas.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/packaging/libscreen_connector_shared_widget_launch.manifest b/packaging/libscreen_connector_shared_widget_launch.manifest new file mode 100644 index 0000000..a76fdba --- /dev/null +++ b/packaging/libscreen_connector_shared_widget_launch.manifest @@ -0,0 +1,5 @@ + + + + + diff --git a/screen_connector_common/evas_object.h b/screen_connector_common/evas_object.h new file mode 100644 index 0000000..fd12435 --- /dev/null +++ b/screen_connector_common/evas_object.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2019 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 SCREEN_CONNECTOR_COMMON_EVAS_OBJECT_H_ +#define SCREEN_CONNECTOR_COMMON_EVAS_OBJECT_H_ + +#include + +#include "screen_connector_common/export.h" +#include "screen_connector_common/handle.h" + +namespace screen_connector { + +class EXPORT EvasObject : public Handle { + public: + EvasObject(Evas_Object* raw, bool owner) : Handle(raw, owner) {} + virtual ~EvasObject() { + if (IsOwner()) { + evas_object_del(GetRaw()); + } + } +}; + +} // namespace screen_connector + +#endif // SCREEN_CONNECTOR_COMMON_EVAS_OBJECT_H_ diff --git a/screen_connector_common/export.h b/screen_connector_common/export.h new file mode 100644 index 0000000..a1b0c57 --- /dev/null +++ b/screen_connector_common/export.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2019 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 SCREEN_CONNECTOR_COMMON_EXPORT_H_ +#define SCREEN_CONNECTOR_COMMON_EXPORT_H_ + +#ifdef EXPORT +#undef EXPORT +#endif +#define EXPORT __attribute__((visibility("default"))) + +#endif // SCREEN_CONNECTOR_COMMON_EXPORT_H_ diff --git a/screen_connector_common/handle.h b/screen_connector_common/handle.h new file mode 100644 index 0000000..b175313 --- /dev/null +++ b/screen_connector_common/handle.h @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2019 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 SCREEN_CONNECTOR_COMMON_HANDLE_H_ +#define SCREEN_CONNECTOR_COMMON_HANDLE_H_ + +#include "screen_connector_common/export.h" + +namespace screen_connector { + +template +class EXPORT Handle { + public: + explicit Handle(T raw, bool owner) : raw_(raw), owner_(owner) { } + virtual ~Handle() { } + + T GetRaw() const { + return raw_; + } + + bool IsOwner() { + return owner_; + } + + private: + T raw_; + bool owner_; +}; + +} // namespace screen_connector + +#endif // SCREEN_CONNECTOR_COMMON_HANDLE_H_ diff --git a/screen_connector_common/tzsh.h b/screen_connector_common/tzsh.h new file mode 100644 index 0000000..761e783 --- /dev/null +++ b/screen_connector_common/tzsh.h @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2019 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 SCREEN_CONNECTOR_COMMON_TZSH_H_ +#define SCREEN_CONNECTOR_COMMON_TZSH_H_ + +#include +#include +#include + +#include "screen_connector_common/export.h" +#include "screen_connector_common/handle.h" + +namespace screen_connector { + +class EXPORT Tzsh : public Handle { + public: + explicit Tzsh(tzsh_h raw) : Handle(raw, true) { } + virtual ~Tzsh() { + if (GetRaw() != nullptr) { + tzsh_destroy(GetRaw()); + } + } +}; + +} // namespace screen_connector + +#endif // SCREEN_CONNECTOR_COMMON_TZSH_H_ diff --git a/screen_connector_common/tzsh_window.h b/screen_connector_common/tzsh_window.h new file mode 100644 index 0000000..c28b62c --- /dev/null +++ b/screen_connector_common/tzsh_window.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2019 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 SCREEN_CONNECTOR_COMMON_TZSH_WINDOW_H_ +#define SCREEN_CONNECTOR_COMMON_TZSH_WINDOW_H_ + +#include +#include +#include + +#include "screen_connector_common/export.h" +#include "screen_connector_common/handle.h" + +namespace screen_connector { + +class EXPORT TzshWindow : public Handle { + public: + explicit TzshWindow(tzsh_window raw) : Handle(raw, false) { } + virtual ~TzshWindow() { } +}; + +} // namespace screen_connector + +#endif // SCREEN_CONNECTOR_COMMON_TZSH_WINDOW_H_ diff --git a/screen_connector_common/util.h b/screen_connector_common/util.h new file mode 100644 index 0000000..43d4493 --- /dev/null +++ b/screen_connector_common/util.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2019 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 SCREEN_CONNECTOR_COMMON_UTIL_H_ +#define SCREEN_CONNECTOR_COMMON_UTIL_H_ + +#include + +#include "screen_connector_common/evas_object.h" +#include "screen_connector_common/export.h" +#include "screen_connector_common/wl2_window.h" + +namespace screen_connector { +namespace util { + +EXPORT std::shared_ptr GetWl2Window(Evas_Object* win) { + Ecore_Wl2_Window* wl2_win = + reinterpret_cast(elm_win_wl_window_get(win)); + return std::shared_ptr(new Wl2Window(wl2_win)); +} + +} // namespace util +} // namespace screen_connector + +#endif // SCREEN_CONNECTOR_COMMON_UTIL_H_ diff --git a/screen_connector_common/wl2_window.h b/screen_connector_common/wl2_window.h new file mode 100644 index 0000000..76a02f4 --- /dev/null +++ b/screen_connector_common/wl2_window.h @@ -0,0 +1,36 @@ +/* + * Copyright (c) 2019 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 SCREEN_CONNECTOR_COMMON_WL2_WINDOW_H_ +#define SCREEN_CONNECTOR_COMMON_WL2_WINDOW_H_ + +#include + +#include "screen_connector_common/export.h" +#include "screen_connector_common/handle.h" + +namespace screen_connector { + +class EXPORT Wl2Window : public Handle { + public: + explicit Wl2Window(Ecore_Wl2_Window* raw) + : Handle(raw, false) { } + virtual ~Wl2Window() { } +}; + +} // namespace screen_connector + +#endif // SCREEN_CONNECTOR_COMMON_WL2_WINDOW_H_ diff --git a/screen_connector_common/wl_buffer.h b/screen_connector_common/wl_buffer.h new file mode 100644 index 0000000..32e3518 --- /dev/null +++ b/screen_connector_common/wl_buffer.h @@ -0,0 +1,54 @@ +/* + * Copyright (c) 2019 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 SCREEN_CONNECTOR_COMMON_WL_BUFFER_H_ +#define SCREEN_CONNECTOR_COMMON_WL_BUFFER_H_ + +#include +#include +#include +#include +#include +#include +#include + +#include "screen_connector_common/export.h" +#include "screen_connector_common/handle.h" + +namespace screen_connector { + +class EXPORT WlBuffer : public Handle { + public: + WlBuffer(struct wl_buffer* raw, struct tizen_remote_surface* trs) + : Handle(raw, true), trs_(trs) { } + + virtual ~WlBuffer() { + if (GetRaw() != nullptr) { + tizen_remote_surface_release(trs_, GetRaw()); + tbm_surface_h tbm_surface = static_cast( + wl_buffer_get_user_data(GetRaw())); + tbm_surface_internal_unref(tbm_surface); + wl_buffer_destroy(GetRaw()); + } + } + + private: + struct tizen_remote_surface* trs_; +}; + +} // namespace screen_connector + +#endif // SCREEN_CONNECTOR_COMMON_WL_BUFFER_H_ diff --git a/screen_connector_common/wl_surface.h b/screen_connector_common/wl_surface.h new file mode 100644 index 0000000..07ac40d --- /dev/null +++ b/screen_connector_common/wl_surface.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2019 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 SCREEN_CONNECTOR_COMMON_WL_SURFACE_H_ +#define SCREEN_CONNECTOR_COMMON_WL_SURFACE_H_ + +#include + +#include "screen_connector_common/export.h" +#include "screen_connector_common/handle.h" + +namespace screen_connector { + +class EXPORT WlSurface : public Handle { + public: + explicit WlSurface(struct wl_surface* raw) + : Handle(raw, false) { } + + virtual ~WlSurface() { } +}; + +} // namespace screen_connector + +#endif // SCREEN_CONNECTOR_COMMON_WL_SURFACE_H_ diff --git a/screen_connector_launcher_service/CMakeLists.txt b/screen_connector_launcher_service/CMakeLists.txt new file mode 100644 index 0000000..3a182ff --- /dev/null +++ b/screen_connector_launcher_service/CMakeLists.txt @@ -0,0 +1,53 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(screen_connector_launcher_service CXX) + +SET(PREFIX "${CMAKE_INSTALL_PREFIX}") +SET(PROJECT_NAME "${PROJECT_NAME}") +SET(LIBDIR ${LIB_INSTALL_DIR}) +SET(INCLUDEDIR "\${prefix}/include/${PROJECT_NAME}") +SET(VERSION_MAJOR "${MAJORVER}") +SET(VERSION "${FULLVER}") + +INCLUDE(FindPkgConfig) +pkg_check_modules(screen_connector_launcher_service REQUIRED + dlog + aul + wayland-tbm-client + wayland-client + ecore-wl2 + tizen-remote-surface-client + tzsh-launcher-service + glib-2.0 +) + +FOREACH(flag ${screen_connector_launcher_service_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall -Werror -Winline") + +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -std=c++11") +SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") +SET(CMAKE_CXX_FLAGS_RELEASE "-O2") + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../) + +AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCES) +ADD_LIBRARY (${PROJECT_NAME} SHARED ${SOURCES}) + +SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${VERSION_MAJOR}) +SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${VERSION}) + +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${screen_connector_launcher_service_LDFLAGS} "-lpthread") + +CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY) +SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${PROJECT_NAME}.pc") + +INSTALL(TARGETS ${PROJECT_NAME} + DESTINATION ${LIB_INSTALL_DIR}) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc + DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) +INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/ + DESTINATION include/${PROJECT_NAME} + FILES_MATCHING PATTERN "*.h" + PATTERN "*_internal.h" EXCLUDE + PATTERN "*_implementation.h" EXCLUDE) diff --git a/screen_connector_launcher_service/LICENSE b/screen_connector_launcher_service/LICENSE new file mode 100644 index 0000000..ea408f9 --- /dev/null +++ b/screen_connector_launcher_service/LICENSE @@ -0,0 +1,204 @@ +Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. + diff --git a/screen_connector_launcher_service/direction.h b/screen_connector_launcher_service/direction.h new file mode 100644 index 0000000..2e5df5b --- /dev/null +++ b/screen_connector_launcher_service/direction.h @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2019 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 SCREEN_CONNECTOR_LAUNCHER_SERVICE_DIRECTION_H_ +#define SCREEN_CONNECTOR_LAUNCHER_SERVICE_DIRECTION_H_ + +#include +#include + +#include +#include + +#include "screen_connector_common/export.h" + +namespace screen_connector { + +enum class EXPORT Direction { + Forward = TZSH_LAUNCHER_SERVICE_DIRECTION_FORWARD, + Backward = TZSH_LAUNCHER_SERVICE_DIRECTION_BACKWARD, +}; + +} // namespace screen_connector + +#endif // SCREEN_CONNECTOR_LAUNCHER_SERVICE_DIRECTION_H_ diff --git a/screen_connector_launcher_service/error.h b/screen_connector_launcher_service/error.h new file mode 100644 index 0000000..0b34d0d --- /dev/null +++ b/screen_connector_launcher_service/error.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2019 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 SCREEN_CONNECTOR_LAUNCHER_SERVICE_ERROR_H_ +#define SCREEN_CONNECTOR_LAUNCHER_SERVICE_ERROR_H_ + +#include +#include + +#include +#include + +#include "screen_connector_common/export.h" + +namespace screen_connector { + +enum class EXPORT Error { + None = TZSH_LAUNCHER_SERVICE_ERROR_NONE, + Disqualified = TZSH_LAUNCHER_SERVICE_ERROR_DISQUALIFIED, + WrongRequest = TZSH_LAUNCHER_SERVICE_ERROR_WRONG_REQUEST, +}; + +} // namespace screen_connector + +#endif // SCREEN_CONNECTOR_LAUNCHER_SERVICE_ERROR_H_ diff --git a/screen_connector_launcher_service/image_file.h b/screen_connector_launcher_service/image_file.h new file mode 100644 index 0000000..6545fa2 --- /dev/null +++ b/screen_connector_launcher_service/image_file.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2019 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 SCREEN_CONNECTOR_LAUNCHER_SERVICE_IMAGE_FILE_H_ +#define SCREEN_CONNECTOR_LAUNCHER_SERVICE_IMAGE_FILE_H_ + +#include +#include + +#include "screen_connector_common/export.h" +#include "screen_connector_common/handle.h" + +namespace screen_connector { + +class EXPORT ImageFile : public Handle { + public: + ImageFile(int32_t fd, uint32_t size) + : Handle(fd, true), size_(size) { } + + virtual ~ImageFile() { + if (GetRaw() > 0) + close(GetRaw()); + } + + uint32_t GetSize() const { + return size_; + } + + private: + uint32_t size_; +}; + +} // namespace screen_connector + +#endif // SCREEN_CONNECTOR_LAUNCHER_SERVICE_IMAGE_FILE_H_ diff --git a/screen_connector_launcher_service/image_type.h b/screen_connector_launcher_service/image_type.h new file mode 100644 index 0000000..595b906 --- /dev/null +++ b/screen_connector_launcher_service/image_type.h @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2019 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 SCREEN_CONNECTOR_LAUNCHER_SERVICE_IMAGE_TYPE_H_ +#define SCREEN_CONNECTOR_LAUNCHER_SERVICE_IMAGE_TYPE_H_ + +#include +#include + +#include +#include + +#include "screen_connector_common/export.h" + +namespace screen_connector { + +enum class EXPORT ImageType { + RemoteSurfaceTBM, + RemoteSurfaceImageFile, + SplashScreenImage, + SplashScreenEdje, +}; + +} // namespace screen_connector + +#endif // SCREEN_CONNECTOR_LAUNCHER_SERVICE_IMAGE_TYPE_H_ diff --git a/screen_connector_launcher_service/launcher_service.cc b/screen_connector_launcher_service/launcher_service.cc new file mode 100644 index 0000000..82eaae9 --- /dev/null +++ b/screen_connector_launcher_service/launcher_service.cc @@ -0,0 +1,203 @@ +/* + * Copyright (c) 2019 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. + */ + +#include "screen_connector_launcher_service/launcher_service.h" +#include "screen_connector_launcher_service/launcher_service_implementation.h" +#include "screen_connector_launcher_service/log_internal.h" + +namespace screen_connector { + +LauncherService::Impl::Impl(LauncherService* parent, + std::shared_ptr wl2_win, + LauncherService::IEventListener* listener) + : parent_(parent), + wl2_win_(std::move(wl2_win)), + listener_(listener), + trs_mgr_(new TizenRemoteSurfaceManager()), + tzsh_(new Tzsh(tzsh_create(TZSH_TOOLKIT_TYPE_EFL))) { + auto win_id = ecore_wl2_window_id_get(wl2_win_->GetRaw()); + tls_ = std::unique_ptr(new TzshLauncherService( + tzsh_launcher_service_create(tzsh_->GetRaw(), + static_cast(win_id)))); + tls_->SetListener(this); + + auto surface = ecore_wl2_window_surface_get(wl2_win_->GetRaw()); + wl_surface_ = std::shared_ptr(new WlSurface(surface)); +} + +int LauncherService::Impl::Launch(const std::string& app_id, + const std::string& inst_id, + int pid, + uint32_t serial) { + return tls_->Launch(app_id, inst_id, pid, serial); +} + +int LauncherService::Impl::LaunchWithSharedWidget(const std::string& app_id, + const std::string& inst_id, + int pid, + uint32_t serial) { + return tls_->LaunchWithSharedWidget(app_id, inst_id, pid, serial); +} + +int LauncherService::Impl::Launching(uint32_t serial) { + return tls_->Launching(serial); +} + +int LauncherService::Impl::LaunchCancel(uint32_t serial) { + int ret = tls_->LaunchCancel(serial); + done_ = true; + return ret; +} + +int LauncherService::Impl::LaunchDone(uint32_t serial) { + int ret = tls_->LaunchDone(serial); + done_ = true; + return ret; +} + +void LauncherService::Impl::OnRawBufferUpdated( + std::shared_ptr wl_buffer, + uint32_t time, + uint32_t serial) { +} + +void LauncherService::Impl::OnRawBufferMissing(uint32_t serial) { +} + +void LauncherService::Impl::OnRawBufferChanged(uint32_t type, + std::shared_ptr wl_buffer, + int32_t fd, + uint32_t size, + uint32_t time, + Direction direction, + int32_t x, + int32_t y, + const std::string& shared_widget_info, + uint32_t serial) { + + if (done_) { + _W("Skip"); + return; + } + + if (type == TIZEN_REMOTE_SURFACE_BUFFER_TYPE_TBM) { + raw_image_ = std::shared_ptr(new RawImage(direction, x, y, + shared_widget_info, wl_buffer)); + listener_->OnPrepareEvent(raw_image_, serial); + } else if (type == TIZEN_REMOTE_SURFACE_BUFFER_TYPE_IMAGE_FILE) { + raw_image_ = std::shared_ptr(new RawImage(direction, x, y, + shared_widget_info, + std::shared_ptr(new ImageFile(fd, size)))); + listener_->OnPrepareEvent(raw_image_, serial); + } else { + _W("Unknown type(%u)", type); + } +} + +void LauncherService::Impl::OnInputFilterChanged(uint32_t event_filter, + uint32_t serial) { +} + +void LauncherService::Impl::OnPrepareEvent(uint32_t target_type, + uint32_t target_res_id, + const std::string& file_path, + const std::string& file_group, + Direction direction, + int32_t x, + int32_t y, + const std::string& shared_widget_info, + uint32_t serial) { + if (target_type == TZSH_LAUNCHER_SERVICE_TARGET_TYPE_REMOTE_SURFACE) { + done_ = false; + listener_->OnResetEvent(serial); + raw_image_.reset(); + trs_.reset(trs_mgr_->CreateTizenRemoteSurface(target_res_id, + wl_surface_, direction, x, y, shared_widget_info, serial)); + trs_->AddListener(this); + trs_->Redirect(); + } else if (target_type == TZSH_LAUNCHER_SERVICE_TARGET_TYPE_IMAGE) { + raw_image_ = std::shared_ptr(new RawImage(direction, x, y, + shared_widget_info, file_path)); + listener_->OnPrepareEvent(raw_image_, serial); + } else if (target_type == TZSH_LAUNCHER_SERVICE_TARGET_TYPE_EDJE) { + raw_image_ = std::shared_ptr( + new RawImage(direction, x, y, shared_widget_info, + file_path, file_group)); + listener_->OnPrepareEvent(raw_image_, serial); + } else { + _W("Unknown target type(%u)", target_type); + listener_->OnErrorEvent(Error::WrongRequest, serial); + } +} + +void LauncherService::Impl::OnStopEvent(uint32_t serial) { + listener_->OnStopEvent(serial); + listener_->OnResetEvent(serial); + raw_image_.reset(); + trs_.reset(); +} + +void LauncherService::Impl::OnErrorEvent(Error error, uint32_t serial) { + if (error == Error::None) + return; + + if (error == Error::Disqualified) { + _E("Launcher has to clear LauncherService"); + listener_->OnErrorEvent(error, serial); + } else { + _W("Wrong request"); + listener_->OnErrorEvent(error, serial); + } +} + +void LauncherService::Impl::OnCleanupEvent(uint32_t serial) { + listener_->OnCleanUpEvent(serial); +} + +LauncherService::LauncherService(std::shared_ptr wl2_win, + IEventListener* listener) + : impl_(new Impl(this, std::move(wl2_win), listener)) { +} + +LauncherService::~LauncherService() = default; + +int LauncherService::Launch(const std::string& app_id, + const std::string& inst_id, + int pid, + uint32_t serial) { + return impl_->Launch(app_id, inst_id, pid, serial); +} + +int LauncherService::LaunchWithSharedWidget(const std::string& app_id, + const std::string& inst_id, + int pid, + uint32_t serial) { + return impl_->LaunchWithSharedWidget(app_id, inst_id, pid, serial); +} + +int LauncherService::Launching(uint32_t serial) { + return impl_->Launching(serial); +} + +int LauncherService::LaunchCancel(uint32_t serial) { + return impl_->LaunchCancel(serial); +} + +int LauncherService::LaunchDone(uint32_t serial) { + return impl_->LaunchDone(serial); +} + +} // namespace screen_connector diff --git a/screen_connector_launcher_service/launcher_service.h b/screen_connector_launcher_service/launcher_service.h new file mode 100644 index 0000000..3ef2c3a --- /dev/null +++ b/screen_connector_launcher_service/launcher_service.h @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 SCREEN_CONNECTOR_LAUNCHER_SERVICE_LAUNCHER_SERVICE_H_ +#define SCREEN_CONNECTOR_LAUNCHER_SERVICE_LAUNCHER_SERVICE_H_ + +#include +#include + +#include "screen_connector_common/export.h" +#include "screen_connector_common/wl2_window.h" +#include "screen_connector_launcher_service/error.h" +#include "screen_connector_launcher_service/raw_image.h" + +namespace screen_connector { + +class EXPORT LauncherService { + public: + class EXPORT IEventListener { + public: + virtual void OnPrepareEvent(std::shared_ptr raw_image, + uint32_t serial) = 0; + virtual void OnStopEvent(uint32_t serial) = 0; + virtual void OnErrorEvent(Error error, + uint32_t serial) = 0; + virtual void OnCleanUpEvent(uint32_t serial) = 0; + virtual void OnResetEvent(uint32_t serial) = 0; + }; + + LauncherService(std::shared_ptr wl2_win, + IEventListener* listener); + virtual ~LauncherService(); + + int Launch(const std::string& app_id, + const std::string& inst_id, + int pid, + uint32_t serial); + int LaunchWithSharedWidget(const std::string& app_id, + const std::string& inst_id, + int pid, + uint32_t serial); + int Launching(uint32_t serial); + int LaunchCancel(uint32_t serial); + int LaunchDone(uint32_t serial); + + private: + class Impl; + std::unique_ptr impl_; +}; + +} // namespace screen_connector + +#endif // SCREEN_CONNECTOR_LAUNCHER_SERVICE_LAUNCHER_SERVICE_H_ diff --git a/screen_connector_launcher_service/launcher_service_implementation.h b/screen_connector_launcher_service/launcher_service_implementation.h new file mode 100644 index 0000000..0afd237 --- /dev/null +++ b/screen_connector_launcher_service/launcher_service_implementation.h @@ -0,0 +1,108 @@ +/* + * Copyright (c) 2019 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 SCREEN_CONNECTOR_LAUNCHER_SERVICE_LAUNCHER_SERVICE_IMPLEMENTATION_H_ +#define SCREEN_CONNECTOR_LAUNCHER_SERVICE_LAUNCHER_SERVICE_IMPLEMENTATION_H_ + +#include + +#include +#include + +#include "screen_connector_common/handle.h" +#include "screen_connector_common/tzsh.h" +#include "screen_connector_common/wl_buffer.h" +#include "screen_connector_common/wl_surface.h" +#include "screen_connector_launcher_service/launcher_service.h" +#include "screen_connector_launcher_service/tizen_remote_surface_internal.h" +#include "screen_connector_launcher_service/tizen_remote_surface_manager_internal.h" +#include "screen_connector_launcher_service/tzsh_launcher_service_internal.h" + +namespace screen_connector { + +class LauncherService::Impl : TizenRemoteSurface::IEventListener, + TzshLauncherService::IEventListener { + public: + // TizenRemoteSurface::IEventListener + void OnRawBufferUpdated(std::shared_ptr wl_buffer, + uint32_t time, + uint32_t serial) override; + void OnRawBufferMissing(uint32_t serial) override; + void OnRawBufferChanged(uint32_t type, + std::shared_ptr wl_buffer, + int32_t fd, + uint32_t size, + uint32_t time, + Direction direction, + int32_t x, + int32_t y, + const std::string& shared_widget_info, + uint32_t serial) override; + void OnInputFilterChanged(uint32_t event_filter, + uint32_t serial) override; + + // TzshLauncherService::IEventListener + void OnPrepareEvent(uint32_t target_type, + uint32_t target_res_id, + const std::string& file_path, + const std::string& file_group, + Direction direction, + int32_t x, + int32_t y, + const std::string& shared_widget_info, + uint32_t serial) override; + void OnStopEvent(uint32_t serial) override; + void OnErrorEvent(Error error, + uint32_t serial) override; + void OnCleanupEvent(uint32_t serial) override; + + virtual ~Impl() = default; + + int Launch(const std::string& app_id, + const std::string& inst_id, + int pid, + uint32_t serial); + int LaunchWithSharedWidget(const std::string& app_id, + const std::string& inst_id, + int pid, + uint32_t serial); + int Launching(uint32_t serial); + int LaunchCancel(uint32_t serial); + int LaunchDone(uint32_t serial); + + private: + friend class LauncherService; + + Impl(LauncherService* parent, + std::shared_ptr wl2_win, + LauncherService::IEventListener* listener); + + private: + LauncherService* parent_; + std::shared_ptr wl2_win_; + LauncherService::IEventListener* listener_; + std::unique_ptr trs_mgr_; + std::unique_ptr tzsh_; + std::unique_ptr tls_; + std::shared_ptr wl_surface_; + std::unique_ptr trs_; + std::shared_ptr raw_image_; + bool done_ = false; +}; + +} // namespace screen_connector + +#endif // SCREEN_CONNECTOR_LAUNCHER_SERVICE_LAUNCHER_SERVICE_IMPLEMENTATION_H_ diff --git a/screen_connector_launcher_service/log_internal.h b/screen_connector_launcher_service/log_internal.h new file mode 100644 index 0000000..01db3c7 --- /dev/null +++ b/screen_connector_launcher_service/log_internal.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2019 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 SCREEN_CONNECTOR_LAUNCHER_SERVICE_LOG_INTERNAL_H_ +#define SCREEN_CONNECTOR_LAUNCHER_SERVICE_LOG_INTERNAL_H_ + +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif + +#define LOG_TAG "SCLS" + +#ifdef _E +#undef _E +#endif +#define _E LOGE + +#ifdef _W +#undef _W +#endif +#define _W LOGW + +#ifdef _I +#undef _I +#endif +#define _I LOGI + +#ifdef _D +#undef _D +#endif +#define _D LOGD + +#endif // SCREEN_CONNECTOR_LAUNCHER_SERVICE_LOG_INTERNAL_H_ diff --git a/screen_connector_launcher_service/raw_image.cc b/screen_connector_launcher_service/raw_image.cc new file mode 100644 index 0000000..4edaa3b --- /dev/null +++ b/screen_connector_launcher_service/raw_image.cc @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2019 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. + */ + +#include "screen_connector_launcher_service/raw_image.h" +#include "screen_connector_launcher_service/log_internal.h" + +namespace screen_connector { + +RawImage::RawImage(Direction direction, + int32_t x, int32_t y, + std::string shared_widget_info, + std::shared_ptr image_file) + : image_type_(ImageType::RemoteSurfaceImageFile), + direction_(direction), + x_(x), y_(y), + shared_widget_info_(std::move(shared_widget_info)) { + image_file_ = std::move(image_file); +} + +RawImage::RawImage(Direction direction, + int32_t x, int32_t y, + std::string shared_widget_info, + std::shared_ptr wl_buffer) + : image_type_(ImageType::RemoteSurfaceTBM), + direction_(direction), + x_(x), y_(y), + shared_widget_info_(std::move(shared_widget_info)) { + wl_buffer_ = std::move(wl_buffer); +} + +RawImage::RawImage(Direction direction, + int32_t x, int32_t y, + std::string shared_widget_info, + std::string file_path) + : image_type_(ImageType::SplashScreenImage), + direction_(direction), + x_(x), y_(y), + shared_widget_info_(std::move(shared_widget_info)) { + file_path_ = std::move(file_path); +} + +RawImage::RawImage(Direction direction, + int32_t x, int32_t y, + std::string shared_widget_info, + std::string file_path, + std::string file_group) + : image_type_(ImageType::SplashScreenEdje), + direction_(direction), + x_(x), y_(y), + shared_widget_info_(std::move(shared_widget_info)) { + file_path_ = std::move(file_path); + file_group_ = std::move(file_group); +} + +RawImage::~RawImage() = default; + +ImageType RawImage::GetImageType() const { + return image_type_; +} + +Direction RawImage::GetDirection() const { + return direction_; +} + +int32_t RawImage::GetPositionX() const { + return x_; +} + +int32_t RawImage::GetPositionY() const { + return y_; +} + +std::string RawImage::GetSharedWidgetInfo() const { + return shared_widget_info_; +} + +std::shared_ptr RawImage::GetWlBuffer() const { + return wl_buffer_; +} + +std::shared_ptr RawImage::GetImageFile() const { + return image_file_; +} + +std::string RawImage::GetFilePath() const { + return file_path_; +} + +std::string RawImage::GetFileGroup() const { + return file_group_; +} + +} // namespace screen_connector diff --git a/screen_connector_launcher_service/raw_image.h b/screen_connector_launcher_service/raw_image.h new file mode 100644 index 0000000..2f7e743 --- /dev/null +++ b/screen_connector_launcher_service/raw_image.h @@ -0,0 +1,78 @@ +/* + * Copyright (c) 2019 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 SCREEN_CONNECTOR_LAUNCHER_SERVICE_RAW_IMAGE_H_ +#define SCREEN_CONNECTOR_LAUNCHER_SERVICE_RAW_IMAGE_H_ + +#include + +#include +#include + +#include "screen_connector_common/handle.h" +#include "screen_connector_common/wl_buffer.h" +#include "screen_connector_launcher_service/direction.h" +#include "screen_connector_launcher_service/image_file.h" +#include "screen_connector_launcher_service/image_type.h" + +namespace screen_connector { + +class EXPORT RawImage { + public: + RawImage(Direction direction, + int32_t x, int32_t y, + std::string shared_widget_info, + std::shared_ptr image_file); + RawImage(Direction direction, + int32_t x, int32_t y, + std::string shared_widget_info, + std::shared_ptr wl_buffer); + RawImage(Direction direction, + int32_t x, int32_t y, + std::string shared_widget_info, + std::string file_path); + RawImage(Direction direction, + int32_t x, int32_t y, + std::string shared_widget_info, + std::string file_path, + std::string file_group); + virtual ~RawImage(); + + Direction GetDirection() const; + ImageType GetImageType() const; + int32_t GetPositionX() const; + int32_t GetPositionY() const; + std::string GetSharedWidgetInfo() const; + std::shared_ptr GetImageFile() const; + std::shared_ptr GetWlBuffer() const; + std::string GetFileGroup() const; + std::string GetFilePath() const; + + private: + ImageType image_type_; + Direction direction_; + int32_t x_; + int32_t y_; + std::string shared_widget_info_; + std::shared_ptr wl_buffer_; + std::shared_ptr image_file_; + std::string file_path_; + std::string file_group_; +}; + +} // namespace screen_connector + +#endif // SCREEN_CONNECTOR_LAUNCHER_SERVICE_RAW_IMAGE_H_ diff --git a/screen_connector_launcher_service/screen_connector_launcher_service.pc.in b/screen_connector_launcher_service/screen_connector_launcher_service.pc.in new file mode 100644 index 0000000..0c41770 --- /dev/null +++ b/screen_connector_launcher_service/screen_connector_launcher_service.pc.in @@ -0,0 +1,12 @@ +prefix=@PREFIX@ +exec_prefix=@EXEC_PREFIX@ +libdir=@LIBDIR@ +includedir=@INCLUDEDIR@ + +Name: screen_connector_launcher_service +Description: Support development of the Screen Connector Launcher Service library +Version: @VERSION@ +Requires: tzsh-launcher-service +Libs: -L${libdir} -lscreen_connector_launcher_service +Cflags: -I${includedir} +cppflags: -I${includedir} diff --git a/screen_connector_launcher_service/tizen_remote_surface_internal.cc b/screen_connector_launcher_service/tizen_remote_surface_internal.cc new file mode 100644 index 0000000..5a6d15e --- /dev/null +++ b/screen_connector_launcher_service/tizen_remote_surface_internal.cc @@ -0,0 +1,125 @@ +/* + * Copyright (c) 2019 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. + */ + +#include "screen_connector_launcher_service/tizen_remote_surface_internal.h" + +namespace screen_connector { + +TizenRemoteSurface::TizenRemoteSurface(struct tizen_remote_surface* raw, + Direction direction, + int32_t x, int32_t y, + std::string shared_widget_info, + uint32_t serial) + : Handle(raw, true), + direction_(direction), + x_(x), y_(y), + shared_widget_info_(std::move(shared_widget_info)), + serial_(serial) { +} + +TizenRemoteSurface::~TizenRemoteSurface() { + if (GetRaw() != nullptr) { + tizen_remote_surface_set_user_data(GetRaw(), NULL); + tizen_remote_surface_unredirect(GetRaw()); + tizen_remote_surface_destroy(GetRaw()); + } +} + +struct tizen_remote_surface* TizenRemoteSurface::GetHandle() const { + return GetRaw(); + } + +void TizenRemoteSurface::AddListener(IEventListener* listener) { + static const struct tizen_remote_surface_listener rs_Listener = { + BufferUpdatedCB, + BufferMissingCB, + BufferChangedCB, + InputEventFilterCB, + }; + + listener_ = listener; + tizen_remote_surface_add_listener(GetRaw(), &rs_Listener, this); +} + +TizenRemoteSurface::IEventListener* TizenRemoteSurface::GetListener() { + return listener_; +} + +Direction TizenRemoteSurface::GetDirection() const { + return direction_; +} + +int32_t TizenRemoteSurface::GetPositionX() const { + return x_; +} + +int32_t TizenRemoteSurface::GetPositionY() const { + return y_; +} + +const std::string& TizenRemoteSurface::GetSharedWidgetInfo() const { + return shared_widget_info_; +} + +uint32_t TizenRemoteSurface::GetSerial() const { + return serial_; +} + +void TizenRemoteSurface::Redirect() { + tizen_remote_surface_redirect(GetRaw()); +} + +void TizenRemoteSurface::BufferUpdatedCB(void* data, + struct tizen_remote_surface* trs, + struct wl_buffer* buffer, + uint32_t time) { +} + +void TizenRemoteSurface::BufferMissingCB(void* data, + struct tizen_remote_surface* trs) { + TizenRemoteSurface* rs = static_cast(data); + IEventListener* l = rs->GetListener(); + l->OnRawBufferMissing(rs->GetSerial()); +} + +void TizenRemoteSurface::BufferChangedCB(void* data, + struct tizen_remote_surface* trs, + uint32_t type, + struct wl_buffer* tbm, + int32_t img_fd, + uint32_t img_file_size, + uint32_t time, + struct wl_array* keys) { + TizenRemoteSurface* rs = static_cast(data); + IEventListener* l = rs->GetListener(); + l->OnRawBufferChanged(type, std::make_shared(tbm, trs), + img_fd, img_file_size, time, + rs->GetDirection(), + rs->GetPositionX(), + rs->GetPositionY(), + rs->GetSharedWidgetInfo(), + rs->GetSerial()); +} + +void TizenRemoteSurface::InputEventFilterCB(void* data, + struct tizen_remote_surface* trs, + uint32_t event_filter) { + TizenRemoteSurface* rs = static_cast(data); + IEventListener* l = rs->GetListener(); + l->OnInputFilterChanged(event_filter, rs->GetSerial()); +} + +} // namespace screen_connector diff --git a/screen_connector_launcher_service/tizen_remote_surface_internal.h b/screen_connector_launcher_service/tizen_remote_surface_internal.h new file mode 100644 index 0000000..2448ecc --- /dev/null +++ b/screen_connector_launcher_service/tizen_remote_surface_internal.h @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2019 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 SCREEN_CONNECTOR_LAUNCHER_SERVICE_TIZEN_REMOTE_SURFACE_INTERNAL_H_ +#define SCREEN_CONNECTOR_LAUNCHER_SERVICE_TIZEN_REMOTE_SURFACE_INTERNAL_H_ + +#include +#include +#include + +#include +#include + +#include "screen_connector_common/handle.h" +#include "screen_connector_common/wl_buffer.h" +#include "screen_connector_launcher_service/direction.h" + +namespace screen_connector { + +class TizenRemoteSurface : public Handle { + public: + class IEventListener { + public: + virtual void OnRawBufferUpdated(std::shared_ptr wl_buffer, + uint32_t time, + uint32_t serial) = 0; + virtual void OnRawBufferMissing(uint32_t serial) = 0; + virtual void OnRawBufferChanged(uint32_t type, + std::shared_ptr wl_buffer, + int32_t fd, + uint32_t size, + uint32_t time, + Direction direction, + int32_t x, + int32_t y, + const std::string& shared_widget_info, + uint32_t serial) = 0; + virtual void OnInputFilterChanged(uint32_t event_filter, + uint32_t serial) = 0; + }; + + TizenRemoteSurface(struct tizen_remote_surface* raw, + Direction direction, + int32_t x, int32_t y, + std::string shared_widget_info, + uint32_t serial); + virtual ~TizenRemoteSurface(); + + struct tizen_remote_surface* GetHandle() const; + + void AddListener(IEventListener* listener); + IEventListener* GetListener(); + + Direction GetDirection() const; + int32_t GetPositionX() const; + int32_t GetPositionY() const; + const std::string& GetSharedWidgetInfo() const; + uint32_t GetSerial() const; + void Redirect(); + + private: + static void BufferUpdatedCB(void* data, + struct tizen_remote_surface* trs, + struct wl_buffer* buffer, + uint32_t time); + static void BufferMissingCB(void* data, + struct tizen_remote_surface* trs); + static void BufferChangedCB(void* data, + struct tizen_remote_surface* trs, + uint32_t type, + struct wl_buffer* tbm, + int32_t img_fd, + uint32_t img_file_size, + uint32_t time, + struct wl_array* keys); + static void InputEventFilterCB(void* data, + struct tizen_remote_surface* trs, + uint32_t event_filter); + + private: + Direction direction_; + int32_t x_; + int32_t y_; + std::string shared_widget_info_; + uint32_t serial_; + IEventListener* listener_ = nullptr; +}; + +} // namespace screen_connector + +#endif // SCREEN_CONNECTOR_LAUNCHER_SERVICE_TIZEN_REMOTE_SURFACE_INTERNAL_H_ diff --git a/screen_connector_launcher_service/tizen_remote_surface_manager_internal.cc b/screen_connector_launcher_service/tizen_remote_surface_manager_internal.cc new file mode 100644 index 0000000..61b8cc2 --- /dev/null +++ b/screen_connector_launcher_service/tizen_remote_surface_manager_internal.cc @@ -0,0 +1,85 @@ +/* + * Copyright (c) 2019 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. + */ + +#include +#include +#include +#include +#include + +#include "screen_connector_launcher_service/tizen_remote_surface_manager_internal.h" +#include "screen_connector_launcher_service/log_internal.h" + +namespace screen_connector { + +TizenRemoteSurfaceManager::TizenRemoteSurfaceManager() { + if (!ecore_wl2_init()) { + _E("ecore_wl2_init() is failed"); + return; + } + + Ecore_Wl2_Display* wl2_dpy = ecore_wl2_connected_display_get(NULL); + if (wl2_dpy == nullptr) + wl2_dpy = ecore_wl2_display_connect(NULL); + + struct wl_display* wl_dpy = ecore_wl2_display_get(wl2_dpy); + tbm_client_ = wayland_tbm_client_init(wl_dpy); + tbm_ = wayland_tbm_client_get_wl_tbm(tbm_client_); + + struct wl_registry* registry = ecore_wl2_display_registry_get(wl2_dpy); + Eina_Iterator* iter = ecore_wl2_display_globals_get(wl2_dpy); + + Ecore_Wl2_Global* global = nullptr; + EINA_ITERATOR_FOREACH(iter, global) { + if (!strcmp(global->interface, "tizen_remote_surface_manager")) { + tzrs_mgr_ = static_cast( + wl_registry_bind(registry, global->id, + &tizen_remote_surface_manager_interface, global->version)); + if (tzrs_mgr_) + break; + } + } + eina_iterator_free(iter); +} + +TizenRemoteSurfaceManager::~TizenRemoteSurfaceManager() { + if (tzrs_mgr_) { + tizen_remote_surface_manager_destroy(tzrs_mgr_); + } + + if (tbm_client_) { + wayland_tbm_client_deinit(tbm_client_); + } + + ecore_wl2_display_disconnect(ecore_wl2_connected_display_get(NULL)); + ecore_wl2_shutdown(); +} + +TizenRemoteSurface* TizenRemoteSurfaceManager::CreateTizenRemoteSurface( + uint32_t res, + std::shared_ptr surface, + Direction direction, + int32_t x, int32_t y, + std::string shared_widget_info, + uint32_t serial) { + struct tizen_remote_surface* tzrs = + tizen_remote_surface_manager_create_surface_with_wl_surface(tzrs_mgr_, + res, tbm_, surface->GetRaw()); + return new (std::nothrow) TizenRemoteSurface(tzrs, direction, x, y, + std::move(shared_widget_info), serial); +} + +} // namespace screen_connector diff --git a/screen_connector_launcher_service/tizen_remote_surface_manager_internal.h b/screen_connector_launcher_service/tizen_remote_surface_manager_internal.h new file mode 100644 index 0000000..3aeb193 --- /dev/null +++ b/screen_connector_launcher_service/tizen_remote_surface_manager_internal.h @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2019 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 SCREEN_CONNECTOR_LAUNCHER_SERVICE_TIZEN_REMOTE_SURFACE_MANAGER_INTERNAL_H_ +#define SCREEN_CONNECTOR_LAUNCHER_SERVICE_TIZEN_REMOTE_SURFACE_MANAGER_INTERNAL_H_ + +#include +#include +#include +#include +#include + +#include "screen_connector_common/handle.h" +#include "screen_connector_common/wl_surface.h" +#include "screen_connector_launcher_service/tizen_remote_surface_internal.h" + +namespace screen_connector { + +class TizenRemoteSurfaceManager { + public: + TizenRemoteSurfaceManager(); + virtual ~TizenRemoteSurfaceManager(); + + TizenRemoteSurface* CreateTizenRemoteSurface(uint32_t res, + std::shared_ptr surface, + Direction direction, + int32_t x, int32_t y, + std::string shared_widget_info, + uint32_t serial); + + private: + struct tizen_remote_surface_manager* tzrs_mgr_ = nullptr; + struct wayland_tbm_client* tbm_client_ = nullptr; + struct wl_tbm* tbm_ = nullptr; +}; + +} // namespace screen_connector + +#endif // SCREEN_CONNECTOR_LAUNCHER_SERVICE_TIZEN_REMOTE_SURFACE_MANAGER_INTERNAL_H_ diff --git a/screen_connector_launcher_service/tzsh_launcher_service_internal.cc b/screen_connector_launcher_service/tzsh_launcher_service_internal.cc new file mode 100644 index 0000000..7858f97 --- /dev/null +++ b/screen_connector_launcher_service/tzsh_launcher_service_internal.cc @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2019 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. + */ + +#include "screen_connector_common/handle.h" +#include "screen_connector_launcher_service/tzsh_launcher_service_internal.h" +#include "screen_connector_launcher_service/log_internal.h" + +namespace screen_connector { + +TzshLauncherService::TzshLauncherService(tzsh_launcher_service_h raw) + : Handle(raw, true) { +} + +TzshLauncherService::~TzshLauncherService() { + tzsh_launcher_service_destroy(GetRaw()); +} + +tzsh_launcher_service_h TzshLauncherService::GetHandle() const { + return GetRaw(); +} + +void TzshLauncherService::SetListener(IEventListener* listener) { + listener_ = listener; + + int ret = tzsh_launcher_service_prepare_cb_set(GetRaw(), PrepareCB, + listener_); + if (ret != TZSH_ERROR_NONE) + _E("Failed to set prepare callback. error(%d)", ret); + + ret = tzsh_launcher_service_stop_cb_set(GetRaw(), StopCB, listener_); + if (ret != TZSH_ERROR_NONE) + _E("Failed to set stop callback. error(%d)", ret); + + ret = tzsh_launcher_service_error_cb_set(GetRaw(), ErrorCB, listener_); + if (ret != TZSH_ERROR_NONE) + _E("Failed to set error callback. error(%d)", ret); + + ret = tzsh_launcher_service_cleanup_cb_set(GetRaw(), CleanupCB, listener_); + if (ret != TZSH_ERROR_NONE) + _E("Failed to set cleanup callback. error(%d)", ret); +} + +int TzshLauncherService::Launch(const std::string& app_id, + const std::string& inst_id, + int pid, + uint32_t serial) { + return tzsh_launcher_service_launch(GetRaw(), app_id.c_str(), + inst_id.c_str(), pid, serial); +} + +int TzshLauncherService::LaunchWithSharedWidget(const std::string& app_id, + const std::string& inst_id, + int pid, + uint32_t serial) { + return tzsh_launcher_service_launch_with_shared_widget(GetRaw(), + app_id.c_str(), inst_id.c_str(), pid, serial); +} + +int TzshLauncherService::Launching(uint32_t serial) { + return tzsh_launcher_service_launching(GetRaw(), serial); +} + +int TzshLauncherService::LaunchCancel(uint32_t serial) { + return tzsh_launcher_service_launch_cancel(GetRaw(), serial); +} + +int TzshLauncherService::LaunchDone(uint32_t serial) { + return tzsh_launcher_service_launch_done(GetRaw(), serial); +} + +void TzshLauncherService::PrepareCB(void* data, + tzsh_launcher_service_h service, + tzsh_launcher_service_target_type_e target_type, + uint32_t target_res_id, + const char* target_path, + const char* target_group, + tzsh_launcher_service_direction_e direction, + int32_t x, + int32_t y, + const char* target_widget_info, + uint32_t serial) { + IEventListener* listener = static_cast(data); + std::string file_path(target_path ? target_path : ""); + std::string file_group(target_group ? target_group : ""); + std::string shared_widget_info(target_widget_info ? target_widget_info : ""); + listener->OnPrepareEvent(static_cast(target_type), + target_res_id, file_path, file_group, + static_cast(direction), x, y, + shared_widget_info, serial); +} + +void TzshLauncherService::StopCB(void* data, + tzsh_launcher_service_h service, + uint32_t serial) { + IEventListener* listener = static_cast(data); + listener->OnStopEvent(serial); +} + +void TzshLauncherService::ErrorCB(void* data, + tzsh_launcher_service_h service, + tzsh_launcher_service_error_e error, + uint32_t serial) { + IEventListener* listener = static_cast(data); + listener->OnErrorEvent(static_cast(error), serial); +} + +void TzshLauncherService::CleanupCB(void* data, + tzsh_launcher_service_h service, + uint32_t serial) { + IEventListener* listener = static_cast(data); + listener->OnCleanupEvent(serial); +} + +} // namespace screen_connector diff --git a/screen_connector_launcher_service/tzsh_launcher_service_internal.h b/screen_connector_launcher_service/tzsh_launcher_service_internal.h new file mode 100644 index 0000000..158df11 --- /dev/null +++ b/screen_connector_launcher_service/tzsh_launcher_service_internal.h @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2019 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 SCREEN_CONNECTOR_LAUNCHER_SERVICE_TZSH_LAUNCHER_SERVICE_INTERNAL_H_ +#define SCREEN_CONNECTOR_LAUNCHER_SERVICE_TZSH_LAUNCHER_SERVICE_INTERNAL_H_ + +#include +#include +#include + +#include +#include + +#include "screen_connector_common/handle.h" +#include "screen_connector_launcher_service/direction.h" +#include "screen_connector_launcher_service/error.h" + +namespace screen_connector { + +class TzshLauncherService : public Handle { + public: + class IEventListener { + public: + virtual void OnPrepareEvent(uint32_t target_type, + uint32_t target_res_id, + const std::string& file_path, + const std::string& file_group, + Direction direction, + int32_t x, + int32_t y, + const std::string& shared_widget_info, + uint32_t serial) = 0; + virtual void OnStopEvent(uint32_t serial) = 0; + virtual void OnErrorEvent(Error error, + uint32_t serial) = 0; + virtual void OnCleanupEvent(uint32_t serial) = 0; + }; + + explicit TzshLauncherService(tzsh_launcher_service_h raw); + virtual ~TzshLauncherService(); + + tzsh_launcher_service_h GetHandle() const; + void SetListener(IEventListener* listener); + + int Launch(const std::string& app_id, + const std::string& inst_id, + int pid, + uint32_t serial); + int LaunchWithSharedWidget(const std::string& app_id, + const std::string& inst_id, + int pid, + uint32_t serial); + int Launching(uint32_t serial); + int LaunchCancel(uint32_t serial); + int LaunchDone(uint32_t serial); + + private: + static void PrepareCB(void* data, + tzsh_launcher_service_h service, + tzsh_launcher_service_target_type_e target_type, + uint32_t target_res_id, + const char* target_path, + const char* target_group, + tzsh_launcher_service_direction_e direction, + int32_t x, + int32_t y, + const char* shared_widget_info, + uint32_t serial); + static void StopCB(void* data, + tzsh_launcher_service_h service, + uint32_t serial); + static void ErrorCB(void* data, + tzsh_launcher_service_h service, + tzsh_launcher_service_error_e error, + uint32_t serial); + static void CleanupCB(void* data, + tzsh_launcher_service_h service, + uint32_t serial); + + private: + IEventListener* listener_ = nullptr; +}; + +} // namespace screen_connector + +#endif // SCREEN_CONNECTOR_LAUNCHER_SERVICE_TZSH_LAUNCHER_SERVICE_INTERNAL_H_ diff --git a/screen_connector_launcher_service_evas/CMakeLists.txt b/screen_connector_launcher_service_evas/CMakeLists.txt new file mode 100644 index 0000000..fe05001 --- /dev/null +++ b/screen_connector_launcher_service_evas/CMakeLists.txt @@ -0,0 +1,55 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.8) +PROJECT(screen_connector_launcher_service_evas CXX) + +SET(PREFIX "${CMAKE_INSTALL_PREFIX}") +SET(PROJECT_NAME "${PROJECT_NAME}") +SET(LIBDIR ${LIB_INSTALL_DIR}) +SET(INCLUDEDIR "\${prefix}/include/${PROJECT_NAME}") +SET(VERSION_MAJOR "${MAJORVER}") +SET(VERSION "${FULLVER}") + +INCLUDE(FindPkgConfig) +pkg_check_modules(screen_connector_launcher_service_evas REQUIRED + dlog + aul + wayland-tbm-client + wayland-client + ecore-wl2 + tizen-remote-surface-client + tzsh-launcher-service + glib-2.0 + elementary +) + +FOREACH(flag ${screen_connector_launcher_service_evas_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall -Werror -Winline") + +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -std=c++11") +SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") +SET(CMAKE_CXX_FLAGS_RELEASE "-O2") + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../) +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include) + +AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCES) +ADD_LIBRARY (${PROJECT_NAME} SHARED ${SOURCES}) + +SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${VERSION_MAJOR}) +SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${VERSION}) + +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${screen_connector_launcher_service_evas_LDFLAGS} "-lpthread") + +CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY) +SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${PROJECT_NAME}.pc") + +INSTALL(TARGETS ${PROJECT_NAME} + DESTINATION ${LIB_INSTALL_DIR}) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc + DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) +INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/ + DESTINATION include/${PROJECT_NAME} + FILES_MATCHING PATTERN "*.h" + PATTERN "*_internal.h" EXCLUDE + PATTERN "*_implementation.h" EXCLUDE) diff --git a/screen_connector_launcher_service_evas/LICENSE b/screen_connector_launcher_service_evas/LICENSE new file mode 100644 index 0000000..ea408f9 --- /dev/null +++ b/screen_connector_launcher_service_evas/LICENSE @@ -0,0 +1,204 @@ +Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. + diff --git a/screen_connector_launcher_service_evas/evas_event_interface.h b/screen_connector_launcher_service_evas/evas_event_interface.h new file mode 100644 index 0000000..7a596cb --- /dev/null +++ b/screen_connector_launcher_service_evas/evas_event_interface.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2019 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 SCREEN_CONNECTOR_LAUNCHER_SERVICE_EVAS_EVAS_EVENT_INTERFACE_H_ +#define SCREEN_CONNECTOR_LAUNCHER_SERVICE_EVAS_EVAS_EVENT_INTERFACE_H_ + +#include + +#include + +#include "screen_connector_common/export.h" +#include "screen_connector_common/evas_object.h" +#include "screen_connector_launcher_service/direction.h" +#include "screen_connector_launcher_service/error.h" +#include "screen_connector_launcher_service/image_type.h" + +namespace screen_connector { + +class EXPORT IEvasEvent { + public: + virtual void OnEvasPrepareEvent(const EvasObject& image, + ImageType image_type, + Direction direction, + int32_t x, + int32_t y, + const std::string& shared_widget_info, + uint32_t serial) = 0; + virtual void OnEvasStopEvent(uint32_t serial) = 0; + virtual void OnEvasErrorEvent(Error error, uint32_t serial) = 0; + virtual void OnEvasCleanUpEvent(uint32_t serial) = 0; +}; + +} // namespace screen_connector + +#endif // SCREEN_CONNECTOR_LAUNCHER_SERVICE_EVAS_EVAS_EVENT_INTERFACE_H_ diff --git a/screen_connector_launcher_service_evas/image_internal.cc b/screen_connector_launcher_service_evas/image_internal.cc new file mode 100644 index 0000000..40d329b --- /dev/null +++ b/screen_connector_launcher_service_evas/image_internal.cc @@ -0,0 +1,126 @@ +/* + * Copyright (c) 2019 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. + */ + +#include +#include +#include + +#include "screen_connector_launcher_service_evas/image_internal.h" +#include "screen_connector_launcher_service_evas/log_internal.h" + +namespace screen_connector { + +Image::Image(Evas_Object* raw) : EvasObject(raw, true) { +} + +Image::~Image() = default; + +void Image::Update(std::shared_ptr raw_image) { + raw_image_ = std::move(raw_image); + if (GetImageType() == ImageType::RemoteSurfaceTBM) { + Update(raw_image_->GetWlBuffer()); + } else if (GetImageType() == ImageType::RemoteSurfaceImageFile) { + Update(raw_image_->GetImageFile()); + } else if (GetImageType() == ImageType::SplashScreenImage) { + Update(raw_image_->GetFilePath()); + } else if (GetImageType() == ImageType::SplashScreenEdje) { + Update(raw_image_->GetFilePath(), raw_image_->GetFileGroup()); + } +} + +void Image::Reset() { + if (raw_image_.get() != nullptr && + raw_image_->GetImageType() == ImageType::RemoteSurfaceTBM) { + evas_object_image_native_surface_set(GetRaw(), nullptr); + raw_image_.reset(); + } +} + +void Image::Update(std::shared_ptr image_file) { + void* map = mmap(NULL, image_file->GetSize(), PROT_READ, MAP_SHARED, + image_file->GetRaw(), 0); + + evas_object_image_alpha_set(GetRaw(), EINA_TRUE); + char format[] = "png"; + evas_object_image_memfile_set(GetRaw(), map, image_file->GetSize(), + format, NULL); + + int width; + int height; + evas_object_image_size_get(GetRaw(), &width, &height); + evas_object_image_fill_set(GetRaw(), 0, 0, width, height); + evas_object_resize(GetRaw(), width, height); + + munmap(map, image_file->GetSize()); +} + +void Image::Update(std::shared_ptr wl_buffer) { + tbm_surface_h tbm_surface = static_cast( + wl_buffer_get_user_data(wl_buffer->GetRaw())); + int width = tbm_surface_get_width(tbm_surface); + int height = tbm_surface_get_height(tbm_surface); + + Evas_Native_Surface ns; + memset(&ns, 0, sizeof(Evas_Native_Surface)); + ns.version = EVAS_NATIVE_SURFACE_VERSION; + ns.type = EVAS_NATIVE_SURFACE_TBM; + ns.data.tbm.buffer = tbm_surface; + + evas_object_image_alpha_set(GetRaw(), EINA_TRUE); + evas_object_image_size_set(GetRaw(), width, height); + evas_object_image_native_surface_set(GetRaw(), &ns); + evas_object_image_pixels_dirty_set(GetRaw(), EINA_TRUE); +} + +void Image::Update(std::string file_path) { + evas_object_move(GetRaw(), 0, 0); + evas_object_image_file_set(GetRaw(), file_path.c_str(), NULL); + + Evas_Load_Error err = evas_object_image_load_error_get(GetRaw()); + if (err != EVAS_LOAD_ERROR_NONE) + _E("error(%d)", err); +} + +void Image::Update(std::string file_path, std::string file_group) { + evas_object_move(GetRaw(), 0, 0); + edje_object_file_set(GetRaw(), file_path.c_str(), file_group.c_str()); +} + +void Image::SetSize(int32_t width, int32_t height) { + evas_object_image_size_set(GetRaw(), width, height); +} + +ImageType Image::GetImageType() const { + return raw_image_->GetImageType(); +} + +Direction Image::GetDirection() const { + return raw_image_->GetDirection(); +} + +int32_t Image::GetPositionX() const { + return raw_image_->GetPositionX(); +} + +int32_t Image::GetPositionY() const { + return raw_image_->GetPositionY(); +} + +std::string Image::GetSharedWidgetInfo() const { + return raw_image_->GetSharedWidgetInfo(); +} + +} // namespace screen_connector diff --git a/screen_connector_launcher_service_evas/image_internal.h b/screen_connector_launcher_service_evas/image_internal.h new file mode 100644 index 0000000..6b14573 --- /dev/null +++ b/screen_connector_launcher_service_evas/image_internal.h @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2019 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 SCREEN_CONNECTOR_LAUNCHER_SERVICE_EVAS_IMAGE_INTERNAL_H_ +#define SCREEN_CONNECTOR_LAUNCHER_SERVICE_EVAS_IMAGE_INTERNAL_H_ + +#include + +#include "screen_connector_common/evas_object.h" +#include "screen_connector_launcher_service/direction.h" +#include "screen_connector_launcher_service/image_type.h" +#include "screen_connector_launcher_service/raw_image.h" + +namespace screen_connector { + +class Image : public EvasObject { + public: + Image(Evas_Object* raw); + virtual ~Image(); + + public: + void Reset(); + void Update(std::shared_ptr raw_image); + void SetSize(int32_t width, int32_t height); + + ImageType GetImageType() const; + Direction GetDirection() const; + int32_t GetPositionX() const; + int32_t GetPositionY() const; + std::string GetSharedWidgetInfo() const; + + private: + void Update(std::shared_ptr image_file); + void Update(std::shared_ptr wl_buffer); + void Update(std::string file_path); + void Update(std::string file_path, std::string file_group); + + private: + std::shared_ptr raw_image_; +}; + +} // namespace screen_connector + +#endif // SCREEN_CONNECTOR_LAUNCHER_SERVICE_EVAS_IMAGE_INTERNAL_H_ diff --git a/screen_connector_launcher_service_evas/include/screen_connector_launcher_service_evas.h b/screen_connector_launcher_service_evas/include/screen_connector_launcher_service_evas.h new file mode 100644 index 0000000..1ef1b9b --- /dev/null +++ b/screen_connector_launcher_service_evas/include/screen_connector_launcher_service_evas.h @@ -0,0 +1,122 @@ +/* + * Copyright (c) 2019 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 SCREEN_CONNECTOR_LAUNCHER_SERVICE_EVAS_INCLUDE_SCREEN_CONNECTOR_LAUNCHER_SERVICE_EVAS_H_ +#define SCREEN_CONNECTOR_LAUNCHER_SERVICE_EVAS_INCLUDE_SCREEN_CONNECTOR_LAUNCHER_SERVICE_EVAS_H_ + +#include +#include + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + SCREEN_CONNECTOR_LAUNCHER_SERVICE_EVAS_ERROR_NONE, + SCREEN_CONNECTOR_LAUNCHER_SERVICE_EVAS_ERROR_DISQUALIFIED, + SCREEN_CONNECTOR_LAUNCHER_SERVICE_EVAS_ERROR_WRONG_REQUEST, +} screen_connector_launcher_service_evas_error_e; + +typedef enum { + SCREEN_CONNECTOR_LAUNCHER_SERVICE_EVAS_DIRECTION_FORWARD, + SCREEN_CONNECTOR_LAUNCHER_SERVICE_EVAS_DIRECTION_BACKWARD, +} screen_connector_launcher_service_evas_direction_e; + +typedef enum { + SCREEN_CONNECTOR_LAUNCHER_SERVICE_EVAS_IMAGE_TYPE_REMOTE_SURFACE_TBM, + SCREEN_CONNECTOR_LAUNCHER_SERVICE_EVAS_IMAGE_TYPE_REMOTE_SURFACE_IMAGE_FILE, + SCREEN_CONNECTOR_LAUNCHER_SERVICE_EVAS_IMAGE_TYPE_SPLASH_SCREEN_IMAGE, + SCREEN_CONNECTOR_LAUNCHER_SERVICE_EVAS_IMAGE_TYPE_SPLASH_SCREEN_EDJE, +} screen_connector_launcher_service_evas_image_type_e; + +typedef void* screen_connector_launcher_service_evas_h; + +typedef void (*screen_connector_launcher_service_evas_prepare_cb)( + Evas_Object* image, + screen_connector_launcher_service_evas_image_type_e image_type, + screen_connector_launcher_service_evas_direction_e direction, + int32_t x, + int32_t y, + const char* shared_widget_info, + uint32_t serial, + void* user_data); + +typedef void (*screen_connector_launcher_service_evas_stop_cb)( + uint32_t serial, + void* user_data); + +typedef void (*screen_connector_launcher_service_evas_error_cb)( + screen_connector_launcher_service_evas_error_e error, + uint32_t serial, + void* user_data); + +typedef void (*screen_connector_launcher_service_evas_cleanup_cb)( + uint32_t serial, + void* user_data); + +typedef struct { + screen_connector_launcher_service_evas_prepare_cb prepare; + screen_connector_launcher_service_evas_stop_cb stop; + screen_connector_launcher_service_evas_error_cb error; + screen_connector_launcher_service_evas_cleanup_cb cleanup; +} screen_connector_launcher_service_evas_ops; + +int screen_connector_launcher_service_evas_create( + Evas_Object* win, + screen_connector_launcher_service_evas_h* handle); + +int screen_connector_launcher_service_evas_destroy( + screen_connector_launcher_service_evas_h handle); + +int screen_connector_launcher_service_evas_set_ops( + screen_connector_launcher_service_evas_h handle, + screen_connector_launcher_service_evas_ops *ops, + void* user_data); + +int screen_connector_launcher_service_evas_launch( + screen_connector_launcher_service_evas_h handle, + const char* app_id, + const char* inst_id, + int pid, + uint32_t serial); + +int screen_connector_launcher_service_evas_launch_with_shared_widget( + screen_connector_launcher_service_evas_h handle, + const char* app_id, + const char* inst_id, + int pid, + uint32_t serial); + +int screen_connector_launcher_service_evas_launching( + screen_connector_launcher_service_evas_h handle, + uint32_t serial); + +int screen_connector_launcher_service_evas_launch_cancel( + screen_connector_launcher_service_evas_h handle, + uint32_t serial); + +int screen_connector_launcher_service_evas_launch_done( + screen_connector_launcher_service_evas_h handle, + uint32_t serial); + +#ifdef __cplusplus +} +#endif + +#endif // SCREEN_CONNECTOR_LAUNCHER_SERVICE_EVAS_INCLUDE_SCREEN_CONNECTOR_LAUNCHER_SERVICE_EVAS_H_ diff --git a/screen_connector_launcher_service_evas/launcher_service_evas.cc b/screen_connector_launcher_service_evas/launcher_service_evas.cc new file mode 100644 index 0000000..076bfb6 --- /dev/null +++ b/screen_connector_launcher_service_evas/launcher_service_evas.cc @@ -0,0 +1,152 @@ +/* + * Copyright (c) 2019 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. + */ + +#include "screen_connector_common/util.h" +#include "screen_connector_launcher_service_evas/launcher_service_evas.h" +#include "screen_connector_launcher_service_evas/launcher_service_evas_implementation.h" +#include "screen_connector_launcher_service_evas/log_internal.h" + +namespace screen_connector { + +LauncherServiceEvas::Impl::Impl(LauncherServiceEvas* parent, + std::shared_ptr win) + : parent_(parent), win_(std::move(win)) { +} + +const EvasObject& LauncherServiceEvas::Impl::GetWindow() { + return *win_.get(); +} + +const Image& LauncherServiceEvas::Impl::GetImage() { + return *image_.get(); +} + +void LauncherServiceEvas::Impl::Update(std::shared_ptr raw_image) { + ImageType type = raw_image->GetImageType(); + if (type == ImageType::RemoteSurfaceTBM) { + if (rs_img_.get() == nullptr) { + _D("First added"); + rs_img_.reset(new Image(CreateEvasObjectImage())); + } + rs_img_->Update(raw_image); + image_ = rs_img_; + } else if (type == ImageType::RemoteSurfaceImageFile) { + if (rs_img_.get() == nullptr) { + _D("First added"); + rs_img_.reset(new Image(CreateEvasObjectImage())); + } + rs_img_->Update(raw_image); + image_ = rs_img_; + } else if (type == ImageType::SplashScreenImage) { + if (ss_img_.get() == nullptr) { + _D("First added"); + ss_img_.reset(new Image(CreateEvasObjectImage())); + } + ss_img_->Update(raw_image); + image_ = ss_img_; + } else if (type == ImageType::SplashScreenEdje) { + if (ss_edje_.get() == nullptr) { + _D("First added"); + ss_edje_.reset(new Image(CreateEdjeObject())); + } + ss_edje_->Update(raw_image); + + int width; + int height; + elm_win_screen_size_get(win_->GetRaw(), NULL, NULL, &width, &height); + ss_edje_->SetSize(width, height); + image_ = ss_edje_; + } +} + +void LauncherServiceEvas::Impl::Reset() { + if (rs_img_.get() != nullptr) { + _D("Reset raw image"); + rs_img_->Reset(); + } +} + +Evas_Object* LauncherServiceEvas::Impl::CreateEvasObjectImage() { + Evas_Object* raw = evas_object_image_filled_add( + evas_object_evas_get(win_->GetRaw())); + return raw; +} + +Evas_Object* LauncherServiceEvas::Impl::CreateEdjeObject() { + Evas_Object* raw = edje_object_add(evas_object_evas_get(win_->GetRaw())); + return raw; +} + +LauncherServiceEvas::LauncherServiceEvas(std::shared_ptr win) + : LauncherService(util::GetWl2Window(win->GetRaw()), this), + impl_(new Impl(this, std::move(win))) { +} + +LauncherServiceEvas::~LauncherServiceEvas() = default; + +const EvasObject& LauncherServiceEvas::GetWindow() { + return impl_->GetWindow(); +} + +const EvasObject& LauncherServiceEvas::GetImage() { + return impl_->GetImage(); +} + +void LauncherServiceEvas::OnEvasPrepareEvent(const EvasObject& image, + ImageType image_type, + Direction direction, + int32_t x, + int32_t y, + const std::string& shared_widget_info, + uint32_t serial) { +} + +void LauncherServiceEvas::OnEvasStopEvent(uint32_t serial) { +} + +void LauncherServiceEvas::OnEvasErrorEvent(Error error, + uint32_t serial) { +} + +void LauncherServiceEvas::OnEvasCleanUpEvent(uint32_t serial) { +} + +void LauncherServiceEvas::OnPrepareEvent(std::shared_ptr raw_image, + uint32_t serial) { + impl_->Update(raw_image); + const Image& image = impl_->GetImage(); + OnEvasPrepareEvent(image, image.GetImageType(), image.GetDirection(), + image.GetPositionX(), image.GetPositionY(), + image.GetSharedWidgetInfo(), serial); +} + +void LauncherServiceEvas::OnStopEvent(uint32_t serial) { + OnEvasStopEvent(serial); +} + +void LauncherServiceEvas::OnErrorEvent(Error error, uint32_t serial) { + OnEvasErrorEvent(error, serial); +} + +void LauncherServiceEvas::OnCleanUpEvent(uint32_t serial) { + OnEvasCleanUpEvent(serial); +} + +void LauncherServiceEvas::OnResetEvent(uint32_t serial) { + impl_->Reset(); +} + +} // namespace screen_connector diff --git a/screen_connector_launcher_service_evas/launcher_service_evas.h b/screen_connector_launcher_service_evas/launcher_service_evas.h new file mode 100644 index 0000000..bf1baf6 --- /dev/null +++ b/screen_connector_launcher_service_evas/launcher_service_evas.h @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2019 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 SCREEN_CONNECTOR_LAUNCHER_SERVICE_EVAS_LAUNCHER_SERVICE_EVAS_H_ +#define SCREEN_CONNECTOR_LAUNCHER_SERVICE_EVAS_LAUNCHER_SERVICE_EVAS_H_ + +#include +#include + +#include "screen_connector_common/evas_object.h" +#include "screen_connector_common/export.h" +#include "screen_connector_launcher_service/launcher_service.h" +#include "screen_connector_launcher_service_evas/evas_event_interface.h" + +namespace screen_connector { + +class EXPORT LauncherServiceEvas : public LauncherService, + public LauncherService::IEventListener, + public IEvasEvent { + public: + LauncherServiceEvas(std::shared_ptr win); + virtual ~LauncherServiceEvas(); + + const EvasObject& GetWindow(); + const EvasObject& GetImage(); + + public: + void OnEvasPrepareEvent(const EvasObject& image, + ImageType type, + Direction direction, + int32_t x, + int32_t y, + const std::string& shared_widget_info, + uint32_t serial) override; + void OnEvasStopEvent(uint32_t serial) override; + void OnEvasErrorEvent(Error error, + uint32_t serial) override; + void OnEvasCleanUpEvent(uint32_t serial) override; + + private: + void OnPrepareEvent(std::shared_ptr raw_image, + uint32_t serial); + void OnStopEvent(uint32_t serial); + void OnErrorEvent(Error error, + uint32_t serial); + void OnCleanUpEvent(uint32_t serial); + void OnResetEvent(uint32_t serial); + + private: + class Impl; + std::unique_ptr impl_; +}; + +} // namespace screen_connector + +#endif // SCREEN_CONNECTOR_LAUNCHER_SERVICE_EVAS_LAUNCHER_SERVICE_EVAS_H_ diff --git a/screen_connector_launcher_service_evas/launcher_service_evas_implementation.h b/screen_connector_launcher_service_evas/launcher_service_evas_implementation.h new file mode 100644 index 0000000..08d1ea7 --- /dev/null +++ b/screen_connector_launcher_service_evas/launcher_service_evas_implementation.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2019 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 SCREEN_CONNECTOR_LAUNCHER_SERVICE_EVAS_LAUNCHER_SERVICE_EVAS_IMPLEMENTATION_H_ +#define SCREEN_CONNECTOR_LAUNCHER_SERVICE_EVAS_LAUNCHER_SERVICE_EVAS_IMPLEMENTATION_H_ + +#include +#include + +#include "screen_connector_launcher_service_evas/launcher_service_evas.h" +#include "screen_connector_launcher_service_evas/image_internal.h" + +namespace screen_connector { + +class LauncherServiceEvas::Impl { + public: + virtual ~Impl() = default; + + const EvasObject& GetWindow(); + const Image& GetImage(); + void Update(std::shared_ptr raw_image); + void Reset(); + + private: + Evas_Object* CreateEvasObjectImage(); + Evas_Object* CreateEdjeObject(); + + private: + friend class LauncherServiceEvas; + Impl(LauncherServiceEvas* parent, std::shared_ptr win); + + private: + LauncherServiceEvas* parent_; + std::shared_ptr win_; + std::shared_ptr image_; + std::shared_ptr rs_img_; + std::shared_ptr ss_img_; + std::shared_ptr ss_edje_; +}; + +} // namespace screen_connector + +#endif // SCREEN_CONNECTOR_LAUNCHER_SERVICE_EVAS_LAUNCHER_SERVICE_EVAS_IMPLEMENTATION_H_ diff --git a/screen_connector_launcher_service_evas/log_internal.h b/screen_connector_launcher_service_evas/log_internal.h new file mode 100644 index 0000000..cfd4527 --- /dev/null +++ b/screen_connector_launcher_service_evas/log_internal.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2019 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 SCREEN_CONNECTOR_LAUNCHER_SERVICE_EVAS_LOG_INTERNAL_H_ +#define SCREEN_CONNECTOR_LAUNCHER_SERVICE_EVAS_LOG_INTERNAL_H_ + +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif + +#define LOG_TAG "SCLS_EVAS" + +#ifdef _E +#undef _E +#endif +#define _E LOGE + +#ifdef _W +#undef _W +#endif +#define _W LOGW + +#ifdef _I +#undef _I +#endif +#define _I LOGI + +#ifdef _D +#undef _D +#endif +#define _D LOGD + +#endif // SCREEN_CONNECTOR_LAUNCHER_SERVICE_EVAS_LOG_INTERNAL_H_ diff --git a/screen_connector_launcher_service_evas/screen_connector_launcher_service_evas.pc.in b/screen_connector_launcher_service_evas/screen_connector_launcher_service_evas.pc.in new file mode 100644 index 0000000..535606f --- /dev/null +++ b/screen_connector_launcher_service_evas/screen_connector_launcher_service_evas.pc.in @@ -0,0 +1,12 @@ +prefix=@PREFIX@ +exec_prefix=@EXEC_PREFIX@ +libdir=@LIBDIR@ +includedir=@INCLUDEDIR@ + +Name: screen_connector_launcher_service_evas +Description: Support development of the Screen Connector Launcher Service Evas library +Version: @VERSION@ +Requires: screen_connector_launcher_service elementary +Libs: -L${libdir} -lscreen_connector_launcher_service -lscreen_connector_launcher_service_evas +Cflags: -I${includedir} -I${includedir}/include +cppflags: -I${includedir} -I${includedir}/include diff --git a/screen_connector_launcher_service_evas/stub.cc b/screen_connector_launcher_service_evas/stub.cc new file mode 100644 index 0000000..7e302ed --- /dev/null +++ b/screen_connector_launcher_service_evas/stub.cc @@ -0,0 +1,223 @@ +/* + * Copyright (c) 2019 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. + */ + +#include "screen_connector_common/export.h" +#include "screen_connector_launcher_service_evas/include/screen_connector_launcher_service_evas.h" +#include "screen_connector_launcher_service_evas/launcher_service_evas.h" +#include "screen_connector_launcher_service_evas/log_internal.h" + +namespace { + +static screen_connector_launcher_service_evas_error_e __convert_error( + screen_connector::Error error) { + if (error == screen_connector::Error::Disqualified) { + return SCREEN_CONNECTOR_LAUNCHER_SERVICE_EVAS_ERROR_DISQUALIFIED; + } else if (error == screen_connector::Error::WrongRequest) { + return SCREEN_CONNECTOR_LAUNCHER_SERVICE_EVAS_ERROR_WRONG_REQUEST; + } else { + return SCREEN_CONNECTOR_LAUNCHER_SERVICE_EVAS_ERROR_NONE; + } +} + +static screen_connector_launcher_service_evas_direction_e __convert_direction( + screen_connector::Direction direction) { + if (direction == screen_connector::Direction::Forward) + return SCREEN_CONNECTOR_LAUNCHER_SERVICE_EVAS_DIRECTION_FORWARD; + + return SCREEN_CONNECTOR_LAUNCHER_SERVICE_EVAS_DIRECTION_BACKWARD; +} + +static screen_connector_launcher_service_evas_image_type_e __convert_image_type( + screen_connector::ImageType image_type) { + if (image_type == screen_connector::ImageType::RemoteSurfaceTBM) { + return SCREEN_CONNECTOR_LAUNCHER_SERVICE_EVAS_IMAGE_TYPE_REMOTE_SURFACE_TBM; + } else if (image_type == screen_connector::ImageType::RemoteSurfaceImageFile) { + return SCREEN_CONNECTOR_LAUNCHER_SERVICE_EVAS_IMAGE_TYPE_REMOTE_SURFACE_IMAGE_FILE; + } else if (image_type == screen_connector::ImageType::SplashScreenImage) { + return SCREEN_CONNECTOR_LAUNCHER_SERVICE_EVAS_IMAGE_TYPE_SPLASH_SCREEN_IMAGE; + } else { + return SCREEN_CONNECTOR_LAUNCHER_SERVICE_EVAS_IMAGE_TYPE_SPLASH_SCREEN_EDJE; + } +} + +class LauncherServiceEvasStub : public screen_connector::LauncherServiceEvas { + public: + LauncherServiceEvasStub(std::shared_ptr win) + : screen_connector::LauncherServiceEvas(std::move(win)) { + } + + void SetOps(screen_connector_launcher_service_evas_ops* ops, + void* user_data) { + ops_ = *ops; + user_data_ = user_data; + } + + void OnEvasPrepareEvent(const screen_connector::EvasObject& image, + screen_connector::ImageType image_type, + screen_connector::Direction direction, + int32_t x, + int32_t y, + const std::string& shared_widget_info, + uint32_t serial) override { + if (ops_.prepare) { + ops_.prepare(image.GetRaw(), + __convert_image_type(image_type), + __convert_direction(direction), + x, + y, + shared_widget_info.c_str(), + serial, + user_data_); + } + } + + void OnEvasStopEvent(uint32_t serial) override { + if (ops_.stop) { + ops_.stop(serial, user_data_); + } + } + + void OnEvasErrorEvent(screen_connector::Error error, + uint32_t serial) override { + if (ops_.error) { + ops_.error(__convert_error(error), serial, user_data_); + } + } + + void OnEvasCleanUpEvent(uint32_t serial) override { + if (ops_.cleanup) { + ops_.cleanup(serial, user_data_); + } + } + + private: + screen_connector_launcher_service_evas_ops ops_; + void* user_data_; +}; + +} // namespace + +extern "C" EXPORT int screen_connector_launcher_service_evas_create( + Evas_Object* win, + screen_connector_launcher_service_evas_h* handle) { + if (win == nullptr || handle == nullptr) { + _E("Invalid parameter"); + return -EINVAL; + } + + auto ls = new (std::nothrow) LauncherServiceEvasStub( + std::shared_ptr( + new (std::nothrow) screen_connector::EvasObject(win, false))); + + *handle = static_cast(ls); + + return 0; +} + +extern "C" EXPORT int screen_connector_launcher_service_evas_destroy( + screen_connector_launcher_service_evas_h handle) { + if (handle == nullptr) { + _E("Invalid parameter"); + return -EINVAL; + } + + auto ls = static_cast(handle); + delete ls; + + return 0; +} + +extern "C" EXPORT int screen_connector_launcher_service_evas_set_ops( + screen_connector_launcher_service_evas_h handle, + screen_connector_launcher_service_evas_ops* ops, + void* user_data) { + if (handle == nullptr || ops == nullptr) { + _E("Invalid parameter"); + return -EINVAL; + } + + auto ls = static_cast(handle); + ls->SetOps(ops, user_data); + + return 0; +} + +extern "C" EXPORT int screen_connector_launcher_service_evas_launch( + screen_connector_launcher_service_evas_h handle, + const char* app_id, + const char* inst_id, + int pid, + uint32_t serial) { + if (handle == nullptr || app_id == nullptr || pid < -1) { + _E("Invalid parameter"); + return -EINVAL; + } + + auto ls = static_cast(handle); + return ls->Launch(app_id, inst_id, pid, serial); +} + +extern "C" EXPORT int +screen_connector_launcher_service_evas_launch_with_shared_widget ( + screen_connector_launcher_service_evas_h handle, + const char* app_id, + const char* inst_id, + int pid, + uint32_t serial) { + if (handle == nullptr || app_id == nullptr || pid < -1) { + _E("Invalid parameter"); + return -EINVAL; + } + + auto ls = static_cast(handle); + return ls->LaunchWithSharedWidget(app_id, inst_id, pid, serial); +} + +extern "C" EXPORT int screen_connector_launcher_service_evas_launching( + screen_connector_launcher_service_evas_h handle, + uint32_t serial) { + if (handle == nullptr) { + _E("Invalid parameter"); + return -EINVAL; + } + + auto ls = static_cast(handle); + return ls->Launching(serial); +} + +extern "C" EXPORT int screen_connector_launcher_service_evas_launch_cancel( + screen_connector_launcher_service_evas_h handle, + uint32_t serial) { + if (handle == nullptr) { + _E("Invalid parameter"); + return -EINVAL; + } + + auto ls = static_cast(handle); + return ls->LaunchCancel(serial); +} + +extern "C" EXPORT int screen_connector_launcher_service_evas_launch_done( + screen_connector_launcher_service_evas_h handle, + uint32_t serial) { + if (handle == nullptr) { + _E("Invalid parameter"); + return -EINVAL; + } + + auto ls = static_cast(handle); + return ls->LaunchDone(serial); +} diff --git a/screen_connector_shared_widget_launch/CMakeLists.txt b/screen_connector_shared_widget_launch/CMakeLists.txt new file mode 100644 index 0000000..55d2cf3 --- /dev/null +++ b/screen_connector_shared_widget_launch/CMakeLists.txt @@ -0,0 +1,51 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +PROJECT(screen_connector_shared_widget_launch CXX) + +SET(PREFIX "${CMAKE_INSTALL_PREFIX}") +SET(PROJECT_NAME "${PROJECT_NAME}") +SET(LIBDIR ${LIB_INSTALL_DIR}) +SET(INCLUDEDIR "\${prefix}/include/${PROJECT_NAME}") +SET(VERSION_MAJOR "${MAJORVER}") +SET(VERSION "${FULLVER}") + +INCLUDE(FindPkgConfig) +pkg_check_modules(screen_connector_shared_widget_launch REQUIRED + dlog + aul + wayland-client + ecore-wl2 + tzsh-shared-widget-launch + glib-2.0 +) + +FOREACH(flag ${screen_connector_shared_widget_launch_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) +SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -fvisibility=hidden -Wall -Werror -Winline") + +SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS} -std=c++11") +SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") +SET(CMAKE_CXX_FLAGS_RELEASE "-O2") + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../) + +AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} SOURCES) +ADD_LIBRARY (${PROJECT_NAME} SHARED ${SOURCES}) + +SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES SOVERSION ${VERSION_MAJOR}) +SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES VERSION ${VERSION}) + +TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${screen_connector_shared_widget_launch_LDFLAGS} "-lpthread") + +CONFIGURE_FILE(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY) +SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES "${PROJECT_NAME}.pc") + +INSTALL(TARGETS ${PROJECT_NAME} + DESTINATION ${LIB_INSTALL_DIR}) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc + DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) +INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/ + DESTINATION include/${PROJECT_NAME} + FILES_MATCHING PATTERN "*.h" + PATTERN "*_internal.h" EXCLUDE + PATTERN "*_implementation.h" EXCLUDE) diff --git a/screen_connector_shared_widget_launch/LICENSE b/screen_connector_shared_widget_launch/LICENSE new file mode 100644 index 0000000..ea408f9 --- /dev/null +++ b/screen_connector_shared_widget_launch/LICENSE @@ -0,0 +1,204 @@ +Copyright (c) 2019 Samsung Electronics Co., Ltd. All rights reserved. + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. + diff --git a/screen_connector_shared_widget_launch/include/screen_connector_shared_widget_launch.h b/screen_connector_shared_widget_launch/include/screen_connector_shared_widget_launch.h new file mode 100644 index 0000000..ed18aaf --- /dev/null +++ b/screen_connector_shared_widget_launch/include/screen_connector_shared_widget_launch.h @@ -0,0 +1,62 @@ +/* + * Copyright (c) 2019 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 SCREEN_CONNECTOR_SHARED_WIDGET_LAUNCH_INCLUDE_SCREEN_CONNECTOR_SHARED_WIDGET_LAUNCH_H_ +#define SCREEN_CONNECTOR_SHARED_WIDGET_LAUNCH_INCLUDE_SCREEN_CONNECTOR_SHARED_WIDGET_LAUNCH_H_ + +#include + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + SCREEN_CONNECTOR_SHARED_WIDGET_LAUNCH_PREPARE_STATE_WIDGET_SHOW, + SCREEN_CONNECTOR_SHARED_WIDGET_LAUNCH_PREPARE_STATE_WIDGET_HIDE, +} screen_connector_shared_widget_launch_prepare_state_e; + +typedef void* screen_connector_shared_widget_launch_h; + +typedef void (*screen_connector_shared_widget_launch_prepare_cb)( + screen_connector_shared_widget_launch_prepare_state_e prepare_state, + uint32_t serial, + void* user_data); + +int screen_connector_shared_widget_launch_create(Ecore_Wl2_Window* wl2_win, + screen_connector_shared_widget_launch_h* handle); + +int screen_connector_shared_widget_launch_destroy( + screen_connector_shared_widget_launch_h handle); + +int screen_connector_shared_widget_launch_prepare_cb_set( + screen_connector_shared_widget_launch_h handle, + screen_connector_shared_widget_launch_prepare_cb callback, + void* user_data); + +int screen_connector_shared_widget_launch_prepare_done( + screen_connector_shared_widget_launch_h handle, + const char* shared_widget_info, + screen_connector_shared_widget_launch_prepare_state_e prepare_state, + uint32_t serial); + +#ifdef __cplusplus +} +#endif + +#endif // SCREEN_CONNECTOR_SHARED_WIDGET_LAUNCH_INCLUDE_SCREEN_CONNECTOR_SHARED_WIDGET_LAUNCH_H_ diff --git a/screen_connector_shared_widget_launch/log_internal.h b/screen_connector_shared_widget_launch/log_internal.h new file mode 100644 index 0000000..08e34f4 --- /dev/null +++ b/screen_connector_shared_widget_launch/log_internal.h @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2019 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 SCREEN_CONNECTOR_SHARED_WIDGET_LAUNCH_LOG_INTERNAL_H_ +#define SCREEN_CONNECTOR_SHARED_WIDGET_LAUNCH_LOG_INTERNAL_H_ + +#include + +#ifdef LOG_TAG +#undef LOG_TAG +#endif + +#define LOG_TAG "SCSWL" + +#ifdef _E +#undef _E +#endif +#define _E LOGE + +#ifdef _W +#undef _W +#endif +#define _W LOGW + +#ifdef _I +#undef _I +#endif +#define _I LOGI + +#ifdef _D +#undef _D +#endif +#define _D LOGD + +#endif // SCREEN_CONNECTOR_SHARED_WIDGET_LAUNCH_LOG_INTERNAL_H_ diff --git a/screen_connector_shared_widget_launch/prepare_state.h b/screen_connector_shared_widget_launch/prepare_state.h new file mode 100644 index 0000000..9eb5825 --- /dev/null +++ b/screen_connector_shared_widget_launch/prepare_state.h @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2019 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 SCREEN_CONNECTOR_SHARED_WIDGET_LAUNCH_PREPARE_STATE_H_ +#define SCREEN_CONNECTOR_SHARED_WIDGET_LAUNCH_PREPARE_STATE_H_ + +#include + +#include "screen_connector_common/export.h" + +namespace screen_connector { + +enum class EXPORT PrepareState { + WIDGET_SHOW = TZSH_SHARED_WIDGET_LAUNCH_PREPARE_STATE_WIDGET_SHOW, + WIDGET_HIDE = TZSH_SHARED_WIDGET_LAUNCH_PREPARE_STATE_WIDGET_HIDE, +}; + +} // namespace screen_connector + +#endif // SCREEN_CONNECTOR_SHARED_WIDGET_LAUNCH_PREPARE_STATE_H_ diff --git a/screen_connector_shared_widget_launch/screen_connector_shared_widget_launch.pc.in b/screen_connector_shared_widget_launch/screen_connector_shared_widget_launch.pc.in new file mode 100644 index 0000000..2e235e8 --- /dev/null +++ b/screen_connector_shared_widget_launch/screen_connector_shared_widget_launch.pc.in @@ -0,0 +1,12 @@ +prefix=@PREFIX@ +exec_prefix=@EXEC_PREFIX@ +libdir=@LIBDIR@ +includedir=@INCLUDEDIR@ + +Name: screen_connector_shared_widget_launch +Description: Support development of the Screen Connector Shared Widget Launch library +Version: @VERSION@ +Requires: tzsh-shared-widget-launch +Libs: -L${libdir} -lscreen_connector_shared_widget_launch +Cflags: -I${includedir} -I${includedir}/include +cppflags: -I${includedir} -I${includedir}/include diff --git a/screen_connector_shared_widget_launch/shared_widget_launch.cc b/screen_connector_shared_widget_launch/shared_widget_launch.cc new file mode 100644 index 0000000..42c8e3c --- /dev/null +++ b/screen_connector_shared_widget_launch/shared_widget_launch.cc @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2019 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. + */ + +#include "screen_connector_shared_widget_launch/shared_widget_launch.h" +#include "screen_connector_shared_widget_launch/shared_widget_launch_implementation.h" + +namespace screen_connector { + +SharedWidgetLaunch::Impl::Impl(SharedWidgetLaunch* parent, + std::shared_ptr wl2_win, + SharedWidgetLaunch::IEventListener* listener) + : parent_(parent), + wl2_win_(std::move(wl2_win)), + listener_(listener), + tzsh_(new Tzsh(tzsh_create(TZSH_TOOLKIT_TYPE_EFL))) { + auto win_id = ecore_wl2_window_id_get(wl2_win_->GetRaw()); + tzsh_swl_.reset(new TzshSharedWidgetLaunch( + tzsh_shared_widget_launch_create(tzsh_->GetRaw(), + static_cast(win_id)))); + tzsh_swl_->SetListener(this); +} + +void SharedWidgetLaunch::Impl::PrepareDone( + const std::string& shared_widget_info, + PrepareState state, + uint32_t serial) { + tzsh_swl_->PrepareDone(shared_widget_info, state, serial); +} + +void SharedWidgetLaunch::Impl::OnPrepareEvent(PrepareState state, + uint32_t serial) { + listener_->OnPrepareEvent(state, serial); +} + +SharedWidgetLaunch::SharedWidgetLaunch(std::shared_ptr wl2_win, + IEventListener* listener) + : impl_(new Impl(this, std::move(wl2_win), listener)) { +} + +SharedWidgetLaunch::~SharedWidgetLaunch() = default; + +void SharedWidgetLaunch::PrepareDone(const std::string& shared_widget_info, + PrepareState state, + uint32_t serial) { + impl_->PrepareDone(shared_widget_info, state, serial); +} + +} // namespace screen_connector diff --git a/screen_connector_shared_widget_launch/shared_widget_launch.h b/screen_connector_shared_widget_launch/shared_widget_launch.h new file mode 100644 index 0000000..f8b6808 --- /dev/null +++ b/screen_connector_shared_widget_launch/shared_widget_launch.h @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2019 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 SCREEN_CONNECTOR_SHARED_WIDGET_LAUNCH_SHARED_WIDGET_LAUNCH_H_ +#define SCREEN_CONNECTOR_SHARED_WIDGET_LAUNCH_SHARED_WIDGET_LAUNCH_H_ + +#include + +#include +#include + +#include "screen_connector_common/export.h" +#include "screen_connector_common/wl2_window.h" +#include "screen_connector_shared_widget_launch/prepare_state.h" + +namespace screen_connector { + +class EXPORT SharedWidgetLaunch { + public: + class EXPORT IEventListener { + public: + virtual void OnPrepareEvent(PrepareState state, uint32_t serial) = 0; + }; + + explicit SharedWidgetLaunch(std::shared_ptr wl2_win, + IEventListener* listener); + virtual ~SharedWidgetLaunch(); + + void PrepareDone(const std::string& shared_widget_info, + PrepareState state, + uint32_t serial); + + private: + class Impl; + std::unique_ptr impl_; +}; + +} // namespace screen_connector + +#endif // SCREEN_CONNECTOR_SHARED_WIDGET_LAUNCH_SHARED_WIDGET_LAUNCH_H_ diff --git a/screen_connector_shared_widget_launch/shared_widget_launch_implementation.h b/screen_connector_shared_widget_launch/shared_widget_launch_implementation.h new file mode 100644 index 0000000..47c1b59 --- /dev/null +++ b/screen_connector_shared_widget_launch/shared_widget_launch_implementation.h @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2019 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 SCREEN_CONNECTOR_SHARED_WIDGET_LAUNCH_SHARED_WIDGET_LAUNCH_IMPLEMENTATION_H_ +#define SCREEN_CONNECTOR_SHARED_WIDGET_LAUNCH_SHARED_WIDGET_LAUNCH_IMPLEMENTATION_H_ + +#include +#include + +#include "screen_connector_common/wl2_window.h" +#include "screen_connector_common/tzsh.h" +#include "screen_connector_shared_widget_launch/shared_widget_launch.h" +#include "screen_connector_shared_widget_launch/tzsh_shared_widget_launch_internal.h" + +namespace screen_connector { + +class SharedWidgetLaunch::Impl : public TzshSharedWidgetLaunch::IEventListener { + public: + virtual ~Impl() = default; + + void PrepareDone(const std::string& shared_widget_info, + PrepareState state, + uint32_t serial); + + void OnPrepareEvent(PrepareState state, uint32_t serial) override; + + private: + friend class SharedWidgetLaunch; + Impl(SharedWidgetLaunch* parent, + std::shared_ptr wl2_win, + SharedWidgetLaunch::IEventListener* listener); + + private: + SharedWidgetLaunch* parent_; + std::shared_ptr wl2_win_; + SharedWidgetLaunch::IEventListener* listener_; + std::unique_ptr tzsh_; + std::unique_ptr tzsh_swl_; +}; + +} // namespace screen_connector + +#endif // SCREEN_CONNECTOR_SHARED_WIDGET_LAUNCH_SHARED_WIDGET_LAUNCH_IMPLEMENTATION_H_ diff --git a/screen_connector_shared_widget_launch/stub.cc b/screen_connector_shared_widget_launch/stub.cc new file mode 100644 index 0000000..89b7b86 --- /dev/null +++ b/screen_connector_shared_widget_launch/stub.cc @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2019 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. + */ + +#include "screen_connector_common/export.h" +#include "screen_connector_common/wl2_window.h" +#include "screen_connector_shared_widget_launch/include/screen_connector_shared_widget_launch.h" +#include "screen_connector_shared_widget_launch/log_internal.h" +#include "screen_connector_shared_widget_launch/shared_widget_launch.h" + +namespace { + +class SharedWidgetLaunchStub : public screen_connector::SharedWidgetLaunch, + public screen_connector::SharedWidgetLaunch::IEventListener { + public: + explicit SharedWidgetLaunchStub( + std::shared_ptr wl2_win) + : screen_connector::SharedWidgetLaunch(std::move(wl2_win), this) { + } + + virtual ~SharedWidgetLaunchStub() = default; + + void SetPrepareCB(screen_connector_shared_widget_launch_prepare_cb cb, + void* user_data) { + prepare_cb_ = cb; + user_data_ = user_data; + } + + void OnPrepareEvent(screen_connector::PrepareState state, + uint32_t serial) override { + if (!prepare_cb_) + return; + + screen_connector_shared_widget_launch_prepare_state_e prepare_state = + static_cast(state); + + prepare_cb_(prepare_state, serial, user_data_); + } + + private: + screen_connector_shared_widget_launch_prepare_cb prepare_cb_ = nullptr; + void* user_data_ = nullptr; +}; + +extern "C" EXPORT int screen_connector_shared_widget_launch_create( + Ecore_Wl2_Window* wl2_win, + screen_connector_shared_widget_launch_h* handle) { + if (wl2_win == nullptr || handle == nullptr) { + _E("Invalid parameter"); + return -EINVAL; + } + + auto swl = new (std::nothrow) SharedWidgetLaunchStub( + std::shared_ptr( + new (std::nothrow) screen_connector::Wl2Window(wl2_win))); + + *handle = static_cast(swl); + + return 0; +} + +extern "C" EXPORT int screen_connector_shared_widget_launch_destroy( + screen_connector_shared_widget_launch_h handle) { + if (handle == nullptr) { + _E("Invalid parameter"); + return -EINVAL; + } + + auto swl = static_cast(handle); + delete swl; + + return 0; +} + +extern "C" EXPORT int screen_connector_shared_widget_launch_prepare_cb_set( + screen_connector_shared_widget_launch_h handle, + screen_connector_shared_widget_launch_prepare_cb callback, + void* user_data) { + if (handle == nullptr || callback == nullptr) { + _E("Invalid parameter"); + return -EINVAL; + } + + auto swl = static_cast(handle); + swl->SetPrepareCB(callback, user_data); + + return 0; +} + +extern "C" EXPORT int screen_connector_shared_widget_launch_prepare_done( + screen_connector_shared_widget_launch_h handle, + const char* shared_widget_info, + screen_connector_shared_widget_launch_prepare_state_e state, + uint32_t serial) { + if (handle == nullptr || shared_widget_info == nullptr) { + _E("Invalid parameter"); + return -EINVAL; + } + + auto swl = static_cast(handle); + swl->PrepareDone(shared_widget_info, + static_cast(state), serial); + + return 0; +} + +} // namespace diff --git a/screen_connector_shared_widget_launch/tzsh_shared_widget_launch_internal.cc b/screen_connector_shared_widget_launch/tzsh_shared_widget_launch_internal.cc new file mode 100644 index 0000000..6d1f643 --- /dev/null +++ b/screen_connector_shared_widget_launch/tzsh_shared_widget_launch_internal.cc @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2019 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. + */ + +#include "screen_connector_shared_widget_launch/tzsh_shared_widget_launch_internal.h" +#include "screen_connector_shared_widget_launch/log_internal.h" + +namespace screen_connector { + +TzshSharedWidgetLaunch::TzshSharedWidgetLaunch(tzsh_shared_widget_launch_h raw) + : Handle(raw, true) { +} + +TzshSharedWidgetLaunch::~TzshSharedWidgetLaunch() { + tzsh_shared_widget_launch_destroy(GetRaw()); +} + +tzsh_shared_widget_launch_h TzshSharedWidgetLaunch::GetHandle() const { + return GetRaw(); +} + +void TzshSharedWidgetLaunch::SetListener( + TzshSharedWidgetLaunch::IEventListener* listener) { + listener_ = listener; + tzsh_shared_widget_launch_prepare_cb_set(GetRaw(), PrepareCB, listener_); +} + +int TzshSharedWidgetLaunch::PrepareDone(const std::string& shared_widget_info, + PrepareState state, + uint32_t serial) { + return tzsh_shared_widget_launch_prepare_done(GetRaw(), + shared_widget_info.c_str(), + static_cast(state), + serial); +} + +void TzshSharedWidgetLaunch::PrepareCB(void* data, + tzsh_shared_widget_launch_h tzsh_swl, + tzsh_shared_widget_launch_prepare_state_e state, + uint32_t serial) { + auto listener = static_cast(data); + listener->OnPrepareEvent(static_cast(state), serial); +} + +} // namespace screen_connector diff --git a/screen_connector_shared_widget_launch/tzsh_shared_widget_launch_internal.h b/screen_connector_shared_widget_launch/tzsh_shared_widget_launch_internal.h new file mode 100644 index 0000000..d1af38a --- /dev/null +++ b/screen_connector_shared_widget_launch/tzsh_shared_widget_launch_internal.h @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2019 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 SCREEN_CONNECTOR_SHARED_WIDGET_LAUNCH_TZSH_SHARED_WIDGET_LAUNCH_INTERNAL_H_ +#define SCREEN_CONNECTOR_SHARED_WIDGET_LAUNCH_TZSH_SHARED_WIDGET_LAUNCH_INTERNAL_H_ + +#include +#include +#include + +#include +#include + +#include "screen_connector_common/handle.h" +#include "screen_connector_shared_widget_launch/prepare_state.h" + +namespace screen_connector { + +class TzshSharedWidgetLaunch : public Handle { + public: + class IEventListener { + public: + virtual void OnPrepareEvent(PrepareState state, uint32_t serial) = 0; + }; + + explicit TzshSharedWidgetLaunch(tzsh_shared_widget_launch_h raw); + virtual ~TzshSharedWidgetLaunch(); + + tzsh_shared_widget_launch_h GetHandle() const; + void SetListener(IEventListener* listener); + + int PrepareDone(const std::string& shared_widget_info, + PrepareState state, + uint32_t serial); + + private: + static void PrepareCB(void* data, + tzsh_shared_widget_launch_h tzsh_swl, + tzsh_shared_widget_launch_prepare_state_e state, + uint32_t serial); + + private: + IEventListener* listener_ = nullptr; +}; + +} // namespace screen_connector + +#endif // SCREEN_CONNECTOR_SHARED_WIDGET_LAUNCH_TZSH_SHARED_WIDGET_LAUNCH_INTERNAL_H_