diff options
author | Hwankyu Jhun <h.jhun@samsung.com> | 2019-11-12 11:07:38 +0900 |
---|---|---|
committer | Hwankyu Jhun <h.jhun@samsung.com> | 2019-11-13 11:13:02 +0900 |
commit | 2dc408b3ec13b80ecbd51c723731658b9722c646 (patch) | |
tree | 23f54e543adcc97df54489bfa051cce911647274 /screen_connector_launcher_service | |
parent | c669e2175d0d47a779582572487257a4cb47a521 (diff) | |
download | screen-connector-2dc408b3ec13b80ecbd51c723731658b9722c646.tar.gz screen-connector-2dc408b3ec13b80ecbd51c723731658b9722c646.tar.bz2 screen-connector-2dc408b3ec13b80ecbd51c723731658b9722c646.zip |
Add screen-connector-launcher-service C API
Adds:
- screen_connector_launcher_service_create()
- screen_connector_launcher_service_destroy()
- screen_connector_launcher_service_set_ops()
- screen_connector_launcher_service_launch()
- screen_connector_launcher_service_launch_with_shared_widget()
- screen_connector_launcher_service_launching()
- screen_connector_launcher_service_launch_cancel()
- screen_connector_launcher_service_launch_done()
- screen_connector_launcher_service_image_get_direction()
- screen_connector_launcher_service_image_get_type()
- screen_connector_launcher_service_image_get_position_x()
- screen_connector_launcher_service_image_get_position_y()
- screen_connector_launcher_service_image_get_shared_widget_info()
- screen_connector_launcher_service_image_get_tbm_surface_info()
- screen_connector_launcher_service_image_get_image_file()
- screen_connector_launcher_service_image_get_file_path()
- screen_connector_launcher_service_image_get_file_group()
Change-Id: I71d7d98868e5d905a37221fbdc6aa59ebb1aa117
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
Diffstat (limited to 'screen_connector_launcher_service')
4 files changed, 595 insertions, 6 deletions
diff --git a/screen_connector_launcher_service/CMakeLists.txt b/screen_connector_launcher_service/CMakeLists.txt index 3a182ff..ac0c8d6 100644 --- a/screen_connector_launcher_service/CMakeLists.txt +++ b/screen_connector_launcher_service/CMakeLists.txt @@ -10,14 +10,15 @@ SET(VERSION "${FULLVER}") INCLUDE(FindPkgConfig) pkg_check_modules(screen_connector_launcher_service REQUIRED - dlog aul - wayland-tbm-client - wayland-client + dlog ecore-wl2 + glib-2.0 + libtbm tizen-remote-surface-client tzsh-launcher-service - glib-2.0 + wayland-client + wayland-tbm-client ) FOREACH(flag ${screen_connector_launcher_service_CFLAGS}) @@ -30,6 +31,7 @@ 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}) diff --git a/screen_connector_launcher_service/include/screen_connector_launcher_service.h b/screen_connector_launcher_service/include/screen_connector_launcher_service.h new file mode 100644 index 0000000..ce433ee --- /dev/null +++ b/screen_connector_launcher_service/include/screen_connector_launcher_service.h @@ -0,0 +1,161 @@ +/* + * 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_INCLUDE_SCREEN_CONNECTOR_LAUNCHER_SERVICE_H_ +#define SCREEN_CONNECTOR_LAUNCHER_SERVICE_INCLUDE_SCREEN_CONNECTOR_LAUNCHER_SERVICE_H_ + +#include <stdbool.h> +#include <stdint.h> + +#include <Ecore_Wl2.h> +#include <tbm_surface.h> +#include <tizen.h> + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + SCREEN_CONNECTOR_LAUNCHER_SERVICE_ERROR_NONE, + SCREEN_CONNECTOR_LAUNCHER_SERVICE_ERROR_DISQUALIFIED, + SCREEN_CONNECTOR_LAUNCHER_SERVICE_ERROR_WRONG_REQUEST, +} screen_connector_launcher_service_error_e; + +typedef enum { + SCREEN_CONNECTOR_LAUNCHER_SERVICE_DIRECTION_FORWARD, + SCREEN_CONNECTOR_LAUNCHER_SERVICE_DIRECTION_BACKWARD, +} screen_connector_launcher_service_direction_e; + +typedef enum { + SCREEN_CONNECTOR_LAUNCHER_SERVICE_IMAGE_TYPE_REMOTE_SURFACE_TBM, + SCREEN_CONNECTOR_LAUNCHER_SERVICE_IMAGE_TYPE_REMOTE_SURFACE_IMAGE_FILE, + SCREEN_CONNECTOR_LAUNCHER_SERVICE_IMAGE_TYPE_SPLASH_SCREEN_IMAGE, + SCREEN_CONNECTOR_LAUNCHER_SERVICE_IMAGE_TYPE_SPLASH_SCREEN_EDJE, +} screen_connector_launcher_service_image_type_e; + +typedef void* screen_connector_launcher_service_h; + +typedef void* screen_connector_launcher_service_image_h; + +typedef void (*screen_connector_launcher_service_prepare_cb)( + screen_connector_launcher_service_image_h image, + uint32_t serial, + void* user_data); + +typedef void (*screen_connector_launcher_service_stop_cb)( + uint32_t serial, + void* user_data); + +typedef void (*screen_connector_launcher_service_error_cb)( + screen_connector_launcher_service_error_e error, + uint32_t serial, + void* user_data); + +typedef void (*screen_connector_launcher_service_cleanup_cb)( + uint32_t serial, + void* user_data); + +typedef void (*screen_connector_launcher_service_reset_cb)( + uint32_t serial, + void* user_data); + +typedef struct { + screen_connector_launcher_service_prepare_cb prepare; + screen_connector_launcher_service_stop_cb stop; + screen_connector_launcher_service_error_cb error; + screen_connector_launcher_service_cleanup_cb cleanup; + screen_connector_launcher_service_reset_cb reset; +} screen_connector_launcher_service_ops; + +int screen_connector_launcher_service_create( + Ecore_Wl2_Window* wl2_win, + screen_connector_launcher_service_h* handle); + +int screen_connector_launcher_service_destroy( + screen_connector_launcher_service_h handle); + +int screen_connector_launcher_service_set_ops( + screen_connector_launcher_service_h handle, + screen_connector_launcher_service_ops *ops, + void* user_data); + +int screen_connector_launcher_service_launch( + screen_connector_launcher_service_h handle, + const char* app_id, + const char* inst_id, + int pid, + uint32_t serial); + +int screen_connector_launcher_service_launch_with_shared_widget( + screen_connector_launcher_service_h handle, + const char* app_id, + const char* inst_id, + int pid, + uint32_t serial); + +int screen_connector_launcher_service_launching( + screen_connector_launcher_service_h handle, + uint32_t serial); + +int screen_connector_launcher_service_launch_cancel( + screen_connector_launcher_service_h handle, + uint32_t serial); + +int screen_connector_launcher_service_launch_done( + screen_connector_launcher_service_h handle, + uint32_t serial); + +int screen_connector_launcher_service_image_get_direction( + screen_connector_launcher_service_image_h handle, + screen_connector_launcher_service_direction_e* direction); + +int screen_connector_launcher_service_image_get_type( + screen_connector_launcher_service_image_h handle, + screen_connector_launcher_service_image_type_e *image_type); + +int screen_connector_launcher_service_image_get_position_x( + screen_connector_launcher_service_image_h handle, + int32_t* x); + +int screen_connector_launcher_service_image_get_position_y( + screen_connector_launcher_service_image_h handle, + int32_t* y); + +int screen_connector_launcher_service_image_get_shared_widget_info( + screen_connector_launcher_service_image_h handle, + char** shared_widget_info); + +int screen_connector_launcher_service_image_get_tbm_surface_info( + screen_connector_launcher_service_image_h handle, + tbm_surface_info_s** tbm_surface_info); + +int screen_connector_launcher_service_image_get_image_file( + screen_connector_launcher_service_image_h handle, + int32_t* fd, uint32_t* size); + +int screen_connector_launcher_service_image_get_file_path( + screen_connector_launcher_service_image_h handle, + char** file_path); + +int screen_connector_launcher_service_image_get_file_group( + screen_connector_launcher_service_image_h handle, + char** file_group); + +#ifdef __cplusplus +} +#endif + +#endif // SCREEN_CONNECTOR_LAUNCHER_SERVICE_INCLUDE_SCREEN_CONNECTOR_LAUNCHER_SERVICE_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 index 0c41770..93ce8ea 100644 --- a/screen_connector_launcher_service/screen_connector_launcher_service.pc.in +++ b/screen_connector_launcher_service/screen_connector_launcher_service.pc.in @@ -6,7 +6,7 @@ includedir=@INCLUDEDIR@ Name: screen_connector_launcher_service Description: Support development of the Screen Connector Launcher Service library Version: @VERSION@ -Requires: tzsh-launcher-service +Requires: tzsh-launcher-service libtbm ecore-wl2 Libs: -L${libdir} -lscreen_connector_launcher_service -Cflags: -I${includedir} +Cflags: -I${includedir} -I${includedir}/include cppflags: -I${includedir} diff --git a/screen_connector_launcher_service/stub.cc b/screen_connector_launcher_service/stub.cc new file mode 100644 index 0000000..d6d71f7 --- /dev/null +++ b/screen_connector_launcher_service/stub.cc @@ -0,0 +1,426 @@ +/* + * 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/include/screen_connector_launcher_service.h" +#include "screen_connector_launcher_service/launcher_service.h" +#include "screen_connector_launcher_service/log_internal.h" + +namespace { + +static screen_connector_launcher_service_error_e __convert_error( + screen_connector::Error error) { + if (error == screen_connector::Error::Disqualified) { + return SCREEN_CONNECTOR_LAUNCHER_SERVICE_ERROR_DISQUALIFIED; + } else if (error == screen_connector::Error::WrongRequest) { + return SCREEN_CONNECTOR_LAUNCHER_SERVICE_ERROR_WRONG_REQUEST; + } else { + return SCREEN_CONNECTOR_LAUNCHER_SERVICE_ERROR_NONE; + } +} + +static screen_connector_launcher_service_direction_e __convert_direction( + screen_connector::Direction direction) { + if (direction == screen_connector::Direction::Forward) + return SCREEN_CONNECTOR_LAUNCHER_SERVICE_DIRECTION_FORWARD; + + return SCREEN_CONNECTOR_LAUNCHER_SERVICE_DIRECTION_BACKWARD; +} + +static screen_connector_launcher_service_image_type_e __convert_image_type( + screen_connector::ImageType image_type) { + if (image_type == screen_connector::ImageType::RemoteSurfaceTBM) { + return SCREEN_CONNECTOR_LAUNCHER_SERVICE_IMAGE_TYPE_REMOTE_SURFACE_TBM; + } else if (image_type == screen_connector::ImageType::RemoteSurfaceImageFile) { + return SCREEN_CONNECTOR_LAUNCHER_SERVICE_IMAGE_TYPE_REMOTE_SURFACE_IMAGE_FILE; + } else if (image_type == screen_connector::ImageType::SplashScreenImage) { + return SCREEN_CONNECTOR_LAUNCHER_SERVICE_IMAGE_TYPE_SPLASH_SCREEN_IMAGE; + } else { + return SCREEN_CONNECTOR_LAUNCHER_SERVICE_IMAGE_TYPE_SPLASH_SCREEN_EDJE; + } +} + +class LauncherServiceStub + : public screen_connector::LauncherService, + public screen_connector::LauncherService::IEventListener { + public: + LauncherServiceStub(std::shared_ptr<screen_connector::Wl2Window> wl2_win) + : screen_connector::LauncherService(std::move(wl2_win), this) { + } + + void SetOps(screen_connector_launcher_service_ops* ops, + void* user_data) { + ops_ = *ops; + user_data_ = user_data; + } + + void OnPrepareEvent(std::shared_ptr<screen_connector::RawImage> image, + uint32_t serial) override { + raw_image_ = std::move(image); + if (ops_.prepare) { + ops_.prepare(reinterpret_cast<void*>(&raw_image_), serial, user_data_); + } + } + + void OnStopEvent(uint32_t serial) override { + if (ops_.stop) { + ops_.stop(serial, user_data_); + } + } + + void OnErrorEvent(screen_connector::Error error, + uint32_t serial) override { + if (ops_.error) { + ops_.error(__convert_error(error), serial, user_data_); + } + } + + void OnCleanUpEvent(uint32_t serial) override { + if (ops_.cleanup) { + ops_.cleanup(serial, user_data_); + } + } + + void OnResetEvent(uint32_t serial) override { + if (ops_.reset) { + ops_.reset(serial, user_data_); + } + raw_image_.reset(); + } + + private: + screen_connector_launcher_service_ops ops_ = { 0, }; + void* user_data_ = nullptr; + std::shared_ptr<screen_connector::RawImage> raw_image_; +}; + +} // namespace + +extern "C" EXPORT int screen_connector_launcher_service_create( + Ecore_Wl2_Window* wl2_win, + screen_connector_launcher_service_h* handle) { + if (wl2_win == nullptr || handle == nullptr) { + _E("Invalid parameter"); + return -EINVAL; + } + + auto ls = new (std::nothrow) LauncherServiceStub( + std::shared_ptr<screen_connector::Wl2Window>( + new (std::nothrow) screen_connector::Wl2Window(wl2_win))); + + *handle = static_cast<void*>(ls); + + return 0; +} + +extern "C" EXPORT int screen_connector_launcher_service_destroy( + screen_connector_launcher_service_h handle) { + if (handle == nullptr) { + _E("Invalid parameter"); + return -EINVAL; + } + + auto ls = static_cast<LauncherServiceStub*>(handle); + delete ls; + + return 0; +} + +extern "C" EXPORT int screen_connector_launcher_service_set_ops( + screen_connector_launcher_service_h handle, + screen_connector_launcher_service_ops* ops, + void* user_data) { + if (handle == nullptr || ops == nullptr) { + _E("Invalid parameter"); + return -EINVAL; + } + + auto ls = static_cast<LauncherServiceStub*>(handle); + ls->SetOps(ops, user_data); + + return 0; +} + +extern "C" EXPORT int screen_connector_launcher_service_launch( + screen_connector_launcher_service_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<LauncherServiceStub*>(handle); + return ls->Launch(app_id, inst_id, pid, serial); +} + +extern "C" EXPORT int +screen_connector_launcher_service_launch_with_shared_widget ( + screen_connector_launcher_service_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<LauncherServiceStub*>(handle); + return ls->LaunchWithSharedWidget(app_id, inst_id, pid, serial); +} + +extern "C" EXPORT int screen_connector_launcher_service_launching( + screen_connector_launcher_service_h handle, + uint32_t serial) { + if (handle == nullptr) { + _E("Invalid parameter"); + return -EINVAL; + } + + auto ls = static_cast<LauncherServiceStub*>(handle); + return ls->Launching(serial); +} + +extern "C" EXPORT int screen_connector_launcher_service_launch_cancel( + screen_connector_launcher_service_h handle, + uint32_t serial) { + if (handle == nullptr) { + _E("Invalid parameter"); + return -EINVAL; + } + + auto ls = static_cast<LauncherServiceStub*>(handle); + return ls->LaunchCancel(serial); +} + +extern "C" EXPORT int screen_connector_launcher_service_launch_done( + screen_connector_launcher_service_h handle, + uint32_t serial) { + if (handle == nullptr) { + _E("Invalid parameter"); + return -EINVAL; + } + + auto ls = static_cast<LauncherServiceStub*>(handle); + return ls->LaunchDone(serial); +} + +extern "C" EXPORT int screen_connector_launcher_service_image_get_direction( + screen_connector_launcher_service_image_h handle, + screen_connector_launcher_service_direction_e* direction) { + if (handle == nullptr || direction == nullptr) { + _E("Invalid parameter"); + return -EINVAL; + } + + auto img_ptr = + reinterpret_cast<std::shared_ptr<screen_connector::RawImage>*>(handle); + auto img = img_ptr->get(); + if (img == nullptr) { + _E("Invalid parameter"); + return -EINVAL; + } + + *direction = __convert_direction(img->GetDirection()); + + return 0; +} + +extern "C" EXPORT int screen_connector_launcher_service_image_get_type( + screen_connector_launcher_service_image_h handle, + screen_connector_launcher_service_image_type_e* image_type) { + if (handle == nullptr || image_type == nullptr) { + _E("Invalid parameter"); + return -EINVAL; + } + + auto img_ptr = + reinterpret_cast<std::shared_ptr<screen_connector::RawImage>*>(handle); + auto img = img_ptr->get(); + if (img == nullptr) { + _E("Invalid parameter"); + return -EINVAL; + } + + *image_type = __convert_image_type(img->GetImageType()); + + return 0; +} + +extern "C" EXPORT int screen_connector_launcher_service_image_get_position_x( + screen_connector_launcher_service_image_h handle, + int32_t* x) { + if (handle == nullptr || x == nullptr) { + _E("Invalid parameter"); + return -EINVAL; + } + + auto img_ptr = + reinterpret_cast<std::shared_ptr<screen_connector::RawImage>*>(handle); + auto img = img_ptr->get(); + if (img == nullptr) { + _E("Invalid parameter"); + return -EINVAL; + } + + *x = img->GetPositionX(); + + return 0; +} + +extern "C" EXPORT int screen_connector_launcher_service_image_get_position_y( + screen_connector_launcher_service_image_h handle, + int32_t* y) { + if (handle == nullptr || y == nullptr) { + _E("Invalid parameter"); + return -EINVAL; + } + + auto img_ptr = + reinterpret_cast<std::shared_ptr<screen_connector::RawImage>*>(handle); + auto img = img_ptr->get(); + if (img == nullptr) { + _E("Invalid parameter"); + return -EINVAL; + } + + *y = img->GetPositionY(); + + return 0; +} + +extern "C" EXPORT int +screen_connector_launcher_service_image_get_shared_widget_info( + screen_connector_launcher_service_image_h handle, + char** shared_widget_info) { + if (handle == nullptr || shared_widget_info == nullptr) { + _E("Invalid parameter"); + return -EINVAL; + } + + auto img_ptr = + reinterpret_cast<std::shared_ptr<screen_connector::RawImage>*>(handle); + auto img = img_ptr->get(); + if (img == nullptr) { + _E("Invalid parameter"); + return -EINVAL; + } + + *shared_widget_info = strdup(img->GetSharedWidgetInfo().c_str()); + if (*shared_widget_info == nullptr) { + _E("Out of memory"); + return -ENOMEM; + } + + return 0; +} + +extern "C" EXPORT int +screen_connector_launcher_service_image_get_tbm_surface_info( + screen_connector_launcher_service_image_h handle, + tbm_surface_info_s** tbm_surface_info) { + if (handle == nullptr || tbm_surface_info == nullptr) { + _E("Invalid parameter"); + return -EINVAL; + } + + auto img_ptr = + reinterpret_cast<std::shared_ptr<screen_connector::RawImage>*>(handle); + auto img = img_ptr->get(); + if (img == nullptr) { + _E("Invalid parameter"); + return -EINVAL; + } + + *tbm_surface_info = img->GetWlBuffer()->GetTbmSurfaceInfo(); + + return 0; +} + +extern "C" EXPORT int screen_connector_launcher_service_image_get_image_file( + screen_connector_launcher_service_image_h handle, + int32_t* fd, uint32_t* size) { + if (handle == nullptr || fd == nullptr || size == nullptr) { + _E("Invalid parameter"); + return -EINVAL; + } + + auto img_ptr = + reinterpret_cast<std::shared_ptr<screen_connector::RawImage>*>(handle); + auto img = img_ptr->get(); + if (img == nullptr) { + _E("Invalid parameter"); + return -EINVAL; + } + + *fd = img->GetImageFile()->GetRaw(); + *size = img->GetImageFile()->GetSize(); + + return 0; +} + +extern "C" EXPORT int screen_connector_launcher_service_image_get_file_path( + screen_connector_launcher_service_image_h handle, + char** file_path) { + if (handle == nullptr || file_path == nullptr) { + _E("Invalid parameter"); + return -EINVAL; + } + + auto img_ptr = + reinterpret_cast<std::shared_ptr<screen_connector::RawImage>*>(handle); + auto img = img_ptr->get(); + if (img == nullptr) { + _E("Invalid parameter"); + return -EINVAL; + } + + *file_path = strdup(img->GetFilePath().c_str()); + if (*file_path == nullptr) { + _E("Out of memory"); + return -ENOMEM; + } + + return 0; +} + +extern "C" EXPORT int screen_connector_launcher_service_image_get_file_group( + screen_connector_launcher_service_image_h handle, + char** file_group) { + if (handle == nullptr || file_group == nullptr) { + _E("Invalid parameter"); + return -EINVAL; + } + + auto img_ptr = + reinterpret_cast<std::shared_ptr<screen_connector::RawImage>*>(handle); + auto img = img_ptr->get(); + if (img == nullptr) { + _E("Invalid parameter"); + return -EINVAL; + } + + *file_group = strdup(img->GetFileGroup().c_str()); + if (*file_group == nullptr) { + _E("Out of memory"); + return -ENOMEM; + } + + return 0; +} |