enlightenment_info: Add rotation feature into enlightenment_info for remote control... 37/55037/3 accepted/tizen/mobile/20151222.090804 accepted/tizen/tv/20151222.090815 accepted/tizen/wearable/20151222.090834 submit/tizen/20151222.072527
authorSeunghun Lee <shiin.lee@samsung.com>
Fri, 4 Dec 2015 07:31:24 +0000 (16:31 +0900)
committerGwanglim Lee <gl77.lee@samsung.com>
Tue, 22 Dec 2015 06:43:40 +0000 (22:43 -0800)
Change-Id: I7bd119888987942912da8da064feb69e51717f23

src/bin/Makefile.mk
src/bin/e_info_client.c
src/bin/e_info_server.c
src/bin/e_info_server.h
src/bin/e_info_shared_types.h [new file with mode: 0644]

index c46f482da4c4a53e304b055e8b90f2ebf30b9446..379331188d92c2c4ca90ce5ef92fe655bbabf8bc 100644 (file)
@@ -106,6 +106,7 @@ src/bin/e_ilist.h \
 src/bin/e_import_config_dialog.h \
 src/bin/e_import_dialog.h \
 src/bin/e_includes.h \
+src/bin/e_info_shared_types.h \
 src/bin/e_info_server.h \
 src/bin/e_init.h \
 src/bin/e_int_client_locks.h \
index 60bf18b719f94518356cd0e40218511468177deb..8e0e51c3997831cbae0f6ca19baf734f82f353ef 100644 (file)
@@ -1,4 +1,5 @@
 #include "e.h"
+#include "e_info_shared_types.h"
 #include <time.h>
 #include <dirent.h>
 
@@ -469,6 +470,86 @@ _e_info_client_proc_connected_clients(int argc, char **argv)
      }
 }
 
+#define ROTATION_USAGE \
+   "[COMMAND] [ARG]...\n" \
+   "\tset     : Set the orientation of zone (Usage: set [zone-no] [rval(0|90|180|270)]\n" \
+   "\tinfo    : Get the information of zone's rotation (Usage: info [zone-no]) (Not Implemented)\n" \
+   "\tenable  : Enable the rotation of zone (Usage: enable [zone-no]\n" \
+   "\tdisable : Disable the rotation of zone (Usage: disable [zone-no]\n"
+
+static void
+_cb_rotation_query(const Eldbus_Message *msg)
+{
+   (void)msg;
+   /* TODO: need implementation */
+}
+
+static void
+_e_info_client_proc_rotation(int argc, char **argv)
+{
+   E_Info_Rotation_Message req;
+   int32_t zone_num = -1;
+   int32_t rval = -1;
+   const int off_len = 2, cmd_len = 1;
+   Eina_Bool res = EINA_FALSE;
+
+   if (argc < off_len + cmd_len)
+     goto arg_err;
+
+   if (eina_streq(argv[off_len], "info"))
+     {
+        if (argc > off_len + cmd_len)
+          zone_num = atoi(argv[off_len + 1]);
+
+        res = _e_info_client_eldbus_message_with_args("rotation_query",
+                                                      _cb_rotation_query,
+                                                      "i", zone_num);
+     }
+   else
+     {
+        if (eina_streq(argv[off_len], "set"))
+          {
+             if (argc < off_len + cmd_len + 1)
+               goto arg_err;
+             else if (argc > off_len + cmd_len + 1)
+               {
+                  zone_num = atoi(argv[off_len + 1]);
+                  rval = atoi(argv[off_len + 2]);
+               }
+             else
+               rval = atoi(argv[off_len + 1]);
+
+             if ((rval < 0) || (rval > 270) || (rval % 90 != 0))
+               goto arg_err;
+
+             req = E_INFO_ROTATION_MESSAGE_SET;
+          }
+        else
+          {
+             if (argc > off_len + cmd_len)
+               zone_num = atoi(argv[off_len + 1]);
+
+             if (eina_streq(argv[off_len], "enable"))
+               req = E_INFO_ROTATION_MESSAGE_ENABLE;
+             else if (eina_streq(argv[off_len], "disable"))
+               req = E_INFO_ROTATION_MESSAGE_DISABLE;
+             else
+               goto arg_err;
+          }
+
+        res = _e_info_client_eldbus_message_with_args("rotation_message",
+                                                      NULL, "iii",
+                                                      req, zone_num, rval);
+     }
+
+   if (!res)
+     printf("_e_info_client_eldbus_message_with_args error");
+
+   return;
+arg_err:
+   printf("Usage: enlightenment_info -rotation %s", ROTATION_USAGE);
+}
+
 static struct
 {
    const char *option;
@@ -507,6 +588,12 @@ static struct
       "print connected clients on Enlightenment",
       _e_info_client_proc_connected_clients
    },
+   {
+      "rotation",
+      ROTATION_USAGE,
+      "Send a message about rotation",
+      _e_info_client_proc_rotation
+   },
 };
 
 static void
index d3288d26dd51b192bd85cd906437f41ae9ef35f2..dbe51b0c67f68314d6e47cbbd25d4fee60ca5bc5 100644 (file)
@@ -5,6 +5,8 @@
 #define PATH "/org/enlightenment/wm"
 #define IFACE "org.enlightenment.wm.info"
 
+EAPI int E_EVENT_INFO_ROTATION_MESSAGE = -1;
+
 typedef struct _E_Info_Server
 {
    Eldbus_Connection *conn;
@@ -551,6 +553,83 @@ _e_info_server_cb_eina_log_path(const Eldbus_Service_Interface *iface EINA_UNUSE
    return reply;
 }
 
+static Eldbus_Message *
+_e_info_server_cb_rotation_query(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
+{
+   Eldbus_Message *reply = eldbus_message_method_return_new(msg);
+
+   /* TODO: need implementation */
+
+   return reply;
+}
+
+static void
+_e_info_event_rotation_free(void *data EINA_UNUSED, void *event)
+{
+   E_Event_Info_Rotation_Message *ev = event;
+
+   e_object_unref(E_OBJECT(ev->zone));
+   free(ev);
+}
+
+static Eldbus_Message *
+_e_info_server_cb_rotation_message(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
+{
+   Eldbus_Message *reply = eldbus_message_method_return_new(msg);
+   E_Event_Info_Rotation_Message *ev;
+   E_Info_Rotation_Message rot_msg;
+   E_Zone *z;
+   Eina_List *l;
+   uint32_t zone_num;
+   uint32_t rval;
+
+   if (!eldbus_message_arguments_get(msg, "iii", &rot_msg, &zone_num, &rval))
+     {
+        ERR("Error getting arguments.");
+        return reply;
+     }
+
+   if (rot_msg == E_INFO_ROTATION_MESSAGE_SET)
+     {
+        /* check if rval is valid */
+        if ((rval < 0) || (rval > 270) || (rval % 90 != 0))
+          return reply;
+     }
+
+   ev = E_NEW(E_Event_Info_Rotation_Message, 1);
+   if (EINA_UNLIKELY(!ev))
+     {
+        ERR("Failed to allocate ""E_Event_Info_Rotation_Message""");
+        return reply;
+     }
+
+   if (zone_num == -1)
+     ev->zone = e_zone_current_get(e_comp);
+   else
+     {
+        EINA_LIST_FOREACH(e_comp->zones, l, z)
+          {
+             if (z->num == zone_num)
+               ev->zone = z;
+          }
+     }
+
+   if (!ev->zone)
+     {
+        ERR("Failed to found zone by given num: num %d", zone_num);
+        free(ev);
+        return reply;
+     }
+
+   e_object_ref(E_OBJECT(ev->zone));
+   ev->message = rot_msg;
+   ev->rotation = rval;
+
+   ecore_event_add(E_EVENT_INFO_ROTATION_MESSAGE, ev, _e_info_event_rotation_free, NULL);
+
+   return reply;
+}
+
 static const Eldbus_Method methods[] = {
    { "get_window_info", NULL, ELDBUS_ARGS({"a("VALUE_TYPE_FOR_TOPVWINS")", "array of ec"}), _e_info_server_cb_window_info_get, 0 },
    { "dump_topvwins", ELDBUS_ARGS({"s", "directory"}), NULL, _e_info_server_cb_topvwins_dump, 0 },
@@ -558,6 +637,8 @@ static const Eldbus_Method methods[] = {
    { "eina_log_path", ELDBUS_ARGS({"s", "eina log path"}), NULL, _e_info_server_cb_eina_log_path, 0 },
    { "get_window_prop", ELDBUS_ARGS({"us", "query_mode_value"}), ELDBUS_ARGS({"a(ss)", "array_of_ec"}), _e_info_server_cb_window_prop_get, 0},
    { "get_connected_clients", NULL, ELDBUS_ARGS({"a(ss)", "array of ec"}), _e_info_server_cb_connected_clients_get, 0 },
+   { "rotation_query", ELDBUS_ARGS({"i", "query_rotation"}), NULL, _e_info_server_cb_rotation_query, 0},
+   { "rotation_message", ELDBUS_ARGS({"iii", "rotation_message"}), NULL, _e_info_server_cb_rotation_message, 0},
    { NULL, NULL, NULL, NULL, 0 }
 };
 
@@ -578,6 +659,8 @@ e_info_server_init(void)
                                                            &iface_desc);
    EINA_SAFETY_ON_NULL_GOTO(e_info_server.iface, err);
 
+   E_EVENT_INFO_ROTATION_MESSAGE = ecore_event_type_new();
+
    return 1;
 
 err:
index 9943d2408f1a4f118dd9169f880b833b29d9486d..84d20bcac6e63620eacd0ebb33222de7d806d88c 100644 (file)
@@ -3,6 +3,19 @@
 #ifndef E_INFO_SERVER_H
 #define E_INFO_SERVER_H
 
+#include <e_info_shared_types.h>
+
+typedef struct E_Event_Info_Rotation_Message E_Event_Info_Rotation_Message;
+
+struct E_Event_Info_Rotation_Message
+{
+   E_Zone *zone;
+   E_Info_Rotation_Message message;
+   int rotation;
+};
+
+EAPI extern int E_EVENT_INFO_ROTATION_MESSAGE;
+
 EINTERN int e_info_server_init(void);
 EINTERN int e_info_server_shutdown(void);
 
diff --git a/src/bin/e_info_shared_types.h b/src/bin/e_info_shared_types.h
new file mode 100644 (file)
index 0000000..8085a60
--- /dev/null
@@ -0,0 +1,11 @@
+#ifndef _E_INFO_SHARED_TYPES_
+#define _E_INFO_SHARED_TYPES_
+
+typedef enum
+{
+   E_INFO_ROTATION_MESSAGE_SET,
+   E_INFO_ROTATION_MESSAGE_ENABLE,
+   E_INFO_ROTATION_MESSAGE_DISABLE
+} E_Info_Rotation_Message;
+
+#endif /* end of _E_INFO_SHARED_TYPES_ */