From: Sung-Jin Park Date: Fri, 6 Sep 2019 01:55:41 +0000 (+0900) Subject: pui-samples: remove from package X-Git-Tag: accepted/tizen/5.5/unified/20200102.014046~17 X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Flibpui.git;a=commitdiff_plain;h=263f40fab08fd1aaa55b7fd2e6a0a6d0c6224547 pui-samples: remove from package pui-samples has been moved to another repository. Change-Id: I41e1845ed83c5689e3aadecb7f31cfd313365dd4 Signed-off-by: Sung-Jin Park --- diff --git a/Makefile.am b/Makefile.am index bfabf5d..5562005 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = src backends samples +SUBDIRS = src backends pkgconfigdir = $(libdir)/pkgconfig pkgconfig_DATA = pkgconfig/libpui.pc diff --git a/configure.ac b/configure.ac index 832fed7..05d3903 100644 --- a/configure.ac +++ b/configure.ac @@ -58,18 +58,10 @@ DEFAULT_BACKEND_LIBS="$DEFAULT_BACKEND_LIBS $LIBPUI_LIB " AC_SUBST(DEFAULT_BACKEND_CFLAGS) AC_SUBST(DEFAULT_BACKEND_LIBS) -# samples -SAMPLES_REQUIRES="ecore-wl2 ecore-input" -PKG_CHECK_MODULES(SAMPLES, $[SAMPLES_REQUIRES]) - -SAMPLES_CFLAGS="$LIBPUI_DIR $SAMPLES_CFLAGS " -SAMPLES_LIBS="$LIBPUI_LIB $SAMPLES_LIBS " - # Output files AC_CONFIG_FILES([ Makefile src/Makefile -samples/Makefile backends/Makefile pkgconfig/libpui.pc ]) diff --git a/packaging/libpui.spec b/packaging/libpui.spec index 93fc01b..6017a0e 100644 --- a/packaging/libpui.spec +++ b/packaging/libpui.spec @@ -42,14 +42,6 @@ Requires: %{name} = %{version}-%{release} %description default-backend Default Backend of Tizen Headless Platform User Interaction Library -###### samples -%package samples -Summary: samples for libpui package -Requires: %{name} = %{version}-%{release} - -%description samples -This package includes samples files. - ###### executing %prep %setup -q @@ -91,8 +83,3 @@ cp -fr backends/res/* %{buildroot}/%{ANIDATA_DIR}/ %license COPYING %{_libdir}/*default*.so* %{ANIDATA_DIR}/* - -%files samples -%manifest %{name}.manifest -%defattr(-,root,root,-) -%{_bindir}/pui_sample* diff --git a/samples/Makefile.am b/samples/Makefile.am deleted file mode 100644 index d8170e8..0000000 --- a/samples/Makefile.am +++ /dev/null @@ -1,9 +0,0 @@ -bin_PROGRAMS = pui_sample - -AM_CPPFLAGS = $(GCC_CFLAGS) -I$(top_srcdir)/src -I$(top_srcdir)/include -pui_sample_ldadd = $(top_builddir)/src/libpui.la - -pui_sample_CFLAGS = $(AM_CFLAGS) $(SAMPLES_CFLAGS) -pui_sample_LDADD = $(SAMPLES_LIBS) $(pui_sample_ldadd) - -pui_sample_SOURCES = PUI_sample.c diff --git a/samples/PUI_sample.c b/samples/PUI_sample.c deleted file mode 100644 index c024a84..0000000 --- a/samples/PUI_sample.c +++ /dev/null @@ -1,515 +0,0 @@ -/* - * Copyright © 2019 Samsung Electronics co., Ltd. All Rights Reserved. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice (including the - * next paragraph) shall be included in all copies or substantial - * portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#include -#include - -#define NUM_ECORE_EVENT_HANDLERS 7 - -/* pre-requisite to use ecore_wl2 APIs */ -#define EFL_BETA_API_SUPPORT - -#define MAX_STR 1024 - -#include -#include -#include - -int gpid; - -#define debug_error(msg, ...) \ - do { \ - fprintf(stderr, "[PUI sample][ERROR][PID:%d][%s] " msg, gpid, __FUNCTION__, ##__VA_ARGS__); \ - } while(0) - -#define debug_info(msg, ...) \ - do { \ - fprintf(stdout, "[PUI sample][INFO][PID:%d][%s] " msg, gpid, __FUNCTION__, ##__VA_ARGS__); \ - } while(0) - -typedef struct _animation animation_t; -struct _animation -{ - pui_id id; - pui_ani_cmd cmd; - int repeat; -}; - -typedef struct app_data app_data_t; -struct app_data -{ - pui_h ph; - int ani_idx; - int n_animation; - int manual_idx; - - Ecore_Wl2_Display *ewd; - Ecore_Wl2_Window *win; -}; - -static Eina_Array *_ecore_event_hdls = NULL; -static animation_t ani_collection[] = { - { "system/easy_setup", PUI_ANI_CMD_START, -1 }, - { "system/processing", PUI_ANI_CMD_START, -1 }, - { "system/sw_update_done", PUI_ANI_CMD_START, 1 }, - { "system/mic_off", PUI_ANI_CMD_START, 1 }, - { "voice/listening", PUI_ANI_CMD_START, 1 }, - { "voice/streaming", PUI_ANI_CMD_START, -1 }, - { "voice/processing", PUI_ANI_CMD_START, -1 }, - { "voice/speaking", PUI_ANI_CMD_START, -1 }, - { "voice/timeout", PUI_ANI_CMD_START, 1 }, - { "notification/normal", PUI_ANI_CMD_START, 1 }, - { "notification/emergency", PUI_ANI_CMD_START, -1 }, - { "notification/network_error", PUI_ANI_CMD_START, -1 }, - { "notification/error", PUI_ANI_CMD_START, -1 }, - { "notification/alarm", PUI_ANI_CMD_START, 1 }, - { "bt/pairing", PUI_ANI_CMD_START, -1 }, - { "bt/connected", PUI_ANI_CMD_START, 3 } -}; - -pui_ani_h ani_handles[sizeof(ani_collection) / sizeof(animation_t)]; - -static void -ani_collection_play(app_data_t *app) -{ - pui_error e = PUI_ERROR_NONE; - pui_ani_h ani_h = NULL; - - if (!app->ph) - { - debug_error("Invalid pui_h handle !\n"); - return; - } - - while (!ani_handles[app->ani_idx]) - { - app->ani_idx++; - - if (++app->ani_idx >= app->n_animation) - app->ani_idx = 0; - } - - debug_info("Animation(%s) will be started !\n", pui_ani_get_id(ani_handles[app->ani_idx])); - - /* play animation */ - ani_h = ani_handles[app->ani_idx]; - e = pui_ani_control(ani_h, PUI_ANI_CMD_START, ani_collection[app->ani_idx].repeat); - - if (PUI_ERROR_NONE != e) - { - debug_error("Failed on playing an animation ! (cmd:%d, repeat:%d)\n", PUI_ANI_CMD_START, ani_collection[app->ani_idx].repeat); - return; - } - - if (++app->ani_idx >= app->n_animation) - app->ani_idx = 0; - - return; -} - -static Eina_Bool -_cb_key_up(void *data EINA_UNUSED, int type EINA_UNUSED, void *event) -{ - app_data_t *app = (app_data_t *)data; - Ecore_Event_Key *ev = event; - - debug_info("KEY: name:%s, sym:%s, code:%d\n", ev->keyname, ev->key, ev->keycode); - - ani_collection_play(app); - - return ECORE_CALLBACK_PASS_ON; -} - -static Eina_Bool -_cb_focus_in(void *data, int type EINA_UNUSED, void *event) -{ - app_data_t *app = (app_data_t *)data; - Ecore_Wl2_Event_Focus_In *ev = (Ecore_Wl2_Event_Focus_In *)event; - - debug_info("\n"); - - /* TODO */ - (void) app; - (void) ev; - - return ECORE_CALLBACK_PASS_ON; -} - -static Eina_Bool -_cb_focus_out(void *data, int type EINA_UNUSED, void *event) -{ - app_data_t *app = (app_data_t *)data; - Ecore_Wl2_Event_Focus_Out *ev = (Ecore_Wl2_Event_Focus_Out *)event; - - debug_info("\n"); - - /* TODO */ - (void) app; - (void) ev; - - return ECORE_CALLBACK_PASS_ON; -} - -static Eina_Bool -_cb_visibility_change(void *data, int type EINA_UNUSED, void *event) -{ - app_data_t *app = (app_data_t *)data; - Ecore_Wl2_Event_Window_Visibility_Change *ev; - - (void) app; - ev = event; - debug_info("Visibility change (window=0x%x, fully_obscured=%d)\n", ev->win, ev->fully_obscured); - - return ECORE_CALLBACK_PASS_ON; -} - -static Eina_Bool -_cb_ani_started(void *data, int type EINA_UNUSED, void *event) -{ - app_data_t *app = (app_data_t *)data; - PUI_Event_Animation_Status *ev; - - (void) app; - ev = event; - debug_info("[%s] ani id=%s, status=%d, window=0x%x\n", __FUNCTION__, pui_ani_get_id(ev->ani_h), ev->status, ev->win); - - return ECORE_CALLBACK_PASS_ON; -} - -static Eina_Bool -_cb_ani_stopped(void *data, int type EINA_UNUSED, void *event) -{ - app_data_t *app = (app_data_t *)data; - PUI_Event_Animation_Status *ev; - - (void) app; - ev = event; - debug_info("[%s] ani id=%s, status=%d, window=0x%x\n", __FUNCTION__, pui_ani_get_id(ev->ani_h), ev->status, ev->win); - - /* decrease animation idx for starting from stopped animation */ - //app->ani_idx--; - - return ECORE_CALLBACK_PASS_ON; -} - -static Eina_Bool -_cb_ani_ready_to_resume(void *data, int type EINA_UNUSED, void *event) -{ - app_data_t *app = (app_data_t *)data; - PUI_Event_Animation_Status *ev; - - (void) app; - ev = event; - debug_info("[%s] ani id=%s, status=%d, window=0x%x\n", __FUNCTION__, pui_ani_get_id(ev->ani_h), ev->status, ev->win); - - /* resume animation */ - app->ani_idx--; - ani_collection_play(app); - - return ECORE_CALLBACK_PASS_ON; -} - -static void -_ani_play(app_data_t *app, const char *ani_type, int repeat) -{ - pui_error e = PUI_ERROR_NONE; - pui_ani_h ani_h = NULL; - int idx = -1; - - if (!app->ph) - { - debug_error("Invalid pui_h handle !\n"); - return; - } - - for (int i = 0; i < app->n_animation; i++) - { - if (!strncmp(ani_collection[i].id, ani_type, strlen(ani_type))) - { - idx = i; - break; - } - } - if (idx < 0) - { - debug_error("%s is not supported animation id.\n", ani_type); - return; - } - - debug_info("Animation(%s) will be started !\n", pui_ani_get_id(ani_handles[idx])); - - /* play animation */ - ani_h = ani_handles[idx]; - e = pui_ani_control(ani_h, PUI_ANI_CMD_START, repeat); - - if (PUI_ERROR_NONE != e) - { - debug_error("Failed on playing an animation ! (cmd:%d, repeat:%d)\n", PUI_ANI_CMD_START, repeat); - return; - } - - app->manual_idx = idx; -} - -static void -_ani_stop(app_data_t *app) -{ - pui_error e = PUI_ERROR_NONE; - pui_ani_h ani_h = NULL; - - if (!app->ph) - { - debug_error("Invalid pui_h handle !\n"); - return; - } - - if (app->manual_idx < 0) - { - debug_info("manual animation is not started\n"); - return; - } - - debug_info("Animation(%s) will be stop !\n", pui_ani_get_id(ani_handles[app->manual_idx])); - - /* play animation */ - ani_h = ani_handles[app->manual_idx]; - e = pui_ani_control(ani_h, PUI_ANI_CMD_STOP, -1); - - if (PUI_ERROR_NONE != e) - { - debug_error("Failed on stop an animation ! (cmd:%d)\n", PUI_ANI_CMD_STOP); - } - - app->manual_idx = -1; -} - - -static void -_usage(void) -{ - printf(" Supported commands: help (Print this help text)\n"); - printf(" : q/quit (Quit program)\n"); - printf(" : play {ani_id} {repeat} (play manual animation)\n"); - printf(" ex> play system/processing 2\n"); - printf(" : stop (stop manual animation)\n"); - printf("\n"); -} - -static void -_process_options(app_data_t *app, char *options) -{ - char *tmp, *buf_ptr; - int count = 0; - char ani_type[MAX_STR] = {0, }; - int repeat = 0; - - tmp = strtok_r(options, " ", &buf_ptr); - if (!tmp) return; - - if (!strncmp(options, "q", MAX_STR) || !strncmp(options, "quit", MAX_STR)) { - ecore_main_loop_quit(); - } - else if (!strncmp(options, "help", MAX_STR)) { - _usage(); - } - else if (!strncmp(tmp, "play", sizeof("play"))) { - while (tmp) { - tmp = strtok_r(NULL, " ", &buf_ptr); - if (tmp) { - switch (count) { - case 0: - strncpy(ani_type, tmp, MAX_STR - 1); - break; - case 1: - repeat = atoi(tmp); - break; - default: - break; - } - } - count++; - } - if (strlen(ani_type) <= 0) { - printf("Please input valid arguments for ani type\n"); - _usage(); - } - else - _ani_play(app, ani_type, repeat); - } - else if (!strncmp(tmp, "stop", sizeof("stop"))) { - _ani_stop(app); - } - else { - printf("Invalid arguments\n"); - _usage(); - } -} - -static Eina_Bool -_stdin_cb(void *data, Ecore_Fd_Handler *handler EINA_UNUSED) -{ - app_data_t *app = (app_data_t *)data; - char c, buf[MAX_STR] = {0, }; - int count = 0; - - while ((c = getchar()) != EOF) { - if (c == '\n') break; - if (count >= MAX_STR) break; - - buf[count] = c; - count++; - } - - _process_options(app, buf); - - return ECORE_CALLBACK_RENEW; -} - - -static void -event_handlers_init(app_data_t *app) -{ - Ecore_Event_Handler *h = NULL; - _ecore_event_hdls = eina_array_new(NUM_ECORE_EVENT_HANDLERS); - - h = ecore_event_handler_add(ECORE_EVENT_KEY_UP, _cb_key_up, app); - eina_array_push(_ecore_event_hdls, h); - - h = ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_IN, _cb_focus_in, app); - eina_array_push(_ecore_event_hdls, h); - - h = ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_OUT, _cb_focus_out, app); - eina_array_push(_ecore_event_hdls, h); - - h = ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_VISIBILITY_CHANGE, _cb_visibility_change, app); - eina_array_push(_ecore_event_hdls, h); - - h = ecore_event_handler_add(PUI_EVENT_ANI_STARTED, _cb_ani_started, app); - eina_array_push(_ecore_event_hdls, h); - - h = ecore_event_handler_add(PUI_EVENT_ANI_STOPPED, _cb_ani_stopped, app); - eina_array_push(_ecore_event_hdls, h); - - h = ecore_event_handler_add(PUI_EVENT_ANI_READY_TO_RESUME, _cb_ani_ready_to_resume, app); - eina_array_push(_ecore_event_hdls, h); -} - -int main(int argc, char **argv) -{ - app_data_t *app = NULL; - const char *socket_name = NULL; - - gpid = getpid(); - - if (!ecore_wl2_init()) - { - debug_error("Failed to init ecore wl2 !\n"); - return EXIT_SUCCESS; - } - - socket_name = getenv("WAYLAND_DISPLAY"); - - if (!socket_name) - socket_name = "wayland-0"; - - app = (app_data_t *)calloc(1, sizeof(app_data_t)); - - if (!app) - { - debug_error("Failed to allocate app data !\n"); - goto err; - } - - app->ani_idx = 0; - app->manual_idx = -1; - app->ewd = ecore_wl2_display_connect(socket_name); - - if (!app->ewd) - { - debug_error("Failed to connect to display !\n"); - goto err; - } - - app->win = ecore_wl2_window_new(app->ewd, NULL, 0, 0, 1, 1); - - if (!app->win) - { - debug_error("Failed to create a window !\n"); - goto err; - } - - ecore_wl2_window_alpha_set(app->win, EINA_FALSE); - ecore_wl2_window_show(app->win); - ecore_wl2_window_commit(app->win, EINA_TRUE); - ecore_wl2_window_activate(app->win); - - if (!pui_init()) - { - debug_error("Failed to init pui !\n"); - goto err; - } - - app->ph = pui_create(app->win); - - if (!app->ph) - { - debug_error("Failed to create PUI handle !\n"); - goto err; - } - - app->n_animation = sizeof(ani_collection) / sizeof(animation_t); - - for(int i=0;in_animation;i++) - { - ani_handles[i] = pui_ani_create(app->ph, ani_collection[i].id); - - if (!ani_handles[i]) - debug_error("Failed to create pui ani handle !(id:%s)\n", ani_collection[i].id); - } - - event_handlers_init(app); - if (argc >= 2 && !strncmp(argv[1], "stdin", sizeof("stdin"))) - { - ecore_main_fd_handler_add(STDIN_FILENO, ECORE_FD_READ, _stdin_cb, app, NULL, NULL); - } - - ecore_main_loop_begin(); -err: - if (app->n_animation > 0) - { - for(int i=0;in_animation;i++) - { - pui_ani_destroy(ani_handles[i]); - } - } - - if (app->ph) - pui_destroy(app->ph); - - pui_shutdown(); - ecore_wl2_shutdown(); - - return EXIT_SUCCESS; -}