/* pre-requisite to use ecore_wl2 APIs */
#define EFL_BETA_API_SUPPORT
+#define MAX_STR 1024
+
#include <Ecore_Wl2.h>
#include <Ecore_Input.h>
#include <PUI.h>
pui_h ph;
int ani_idx;
int n_animation;
+ int manual_idx;
Ecore_Wl2_Display *ewd;
Ecore_Wl2_Window *win;
}
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;
+ int idx = -1;
+
+ 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;
eina_array_push(_ecore_event_hdls, h);
}
-int main()
+int main(int argc, char **argv)
{
app_data_t *app = NULL;
const char *socket_name = NULL;
}
app->ani_idx = 0;
+ app->manual_idx = -1;
app->ewd = ecore_wl2_display_connect(socket_name);
if (!app->ewd)
}
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: