e_info_client/server: support aux message 88/81488/6 sandbox/gwanglim/devel
authorMinJeong Kim <minjjj.kim@samsung.com>
Tue, 26 Jul 2016 11:32:47 +0000 (20:32 +0900)
committerGwanglim Lee <gl77.lee@samsung.com>
Wed, 3 Aug 2016 11:35:44 +0000 (04:35 -0700)
can make instant aux message by enlightenment_info

Change-Id: Ia8da3f27356c3b8b616d7e1f062c37daa11dcbb2
Signed-off-by: MinJeong Kim <minjjj.kim@samsung.com>
src/bin/e_info_client.c
src/bin/e_info_server.c

index 74bb9d30a6e4c0c50b529f8c01e1edfbb15a8b45..ff741a0db2b167ccaa92cc09bb24dde5f03a27a7 100644 (file)
@@ -51,6 +51,7 @@ static int keepRunning = 1;
 static void end_program(int sig);
 static Eina_Bool _e_info_client_eldbus_message(const char *method, E_Info_Message_Cb cb);
 static Eina_Bool _e_info_client_eldbus_message_with_args(const char *method, E_Info_Message_Cb cb, const char *signature, ...);
+static void _e_info_client_eldbus_message_cb(void *data, const Eldbus_Message *msg, Eldbus_Pending *p);
 
 static E_Win_Info *
 _e_win_info_new(Ecore_Window id, uint32_t res_id, int pid, Eina_Bool alpha, int opaque, const char *name, int x, int y, int w, int h, int layer, int visible, int visibility, int iconic, int frame_visible, int focused, int hwc, int pl_zpos, const char *layer_name)
@@ -1485,6 +1486,48 @@ _e_info_client_proc_hwc(int argc, char **argv)
 
 }
 
+static void
+_e_info_client_proc_aux_message(int argc, char **argv)
+{
+   const char *win, *key, *val;
+   Eldbus_Message *msg;
+   Eldbus_Message_Iter *itr, *opt_itr;
+   Eldbus_Pending *p;
+   int i;
+
+   if (argc < 5)
+     {
+        printf("Error Check Args: enlightenment_info -aux_msg [window] [key] [val] [options]\n");
+        return;
+     }
+
+   win = argv[2];
+   key = argv[3];
+   val = argv[4];
+
+   msg = eldbus_proxy_method_call_new(e_info_client.proxy, "aux_msg");
+   itr = eldbus_message_iter_get(msg);
+   eldbus_message_iter_basic_append(itr, 's', win);
+   eldbus_message_iter_basic_append(itr, 's', key);
+   eldbus_message_iter_basic_append(itr, 's', val);
+
+   opt_itr = eldbus_message_iter_container_new(itr, 'a', "s");
+   for (i = 5; i < argc; i++)
+     eldbus_message_iter_basic_append(opt_itr, 's', argv[i]);
+   eldbus_message_iter_container_close(itr, opt_itr);
+
+   p = eldbus_proxy_send(e_info_client.proxy, msg,
+                        _e_info_client_eldbus_message_cb,
+                         NULL, -1);
+   if (!p)
+     {
+        printf("\"aux_msg\" proxy_send error");
+        return;
+     }
+
+   ecore_main_loop_begin();
+}
+
 static struct
 {
    const char *option;
@@ -1609,6 +1652,12 @@ static struct
       "[on: 1, off: 0]",
       "On/Off the hw composite",
       _e_info_client_proc_hwc
+   },
+   {
+      "aux_msg",
+      "[window] [key] [value] [options]",
+      "send aux message to client",
+      _e_info_client_proc_aux_message
    }
 };
 
index bfd8a1df55f629f3320303c82bd8d02540a9be2d..223fe1ad472eee9a1abc6fa821807edb647b986a 100644 (file)
@@ -1566,6 +1566,58 @@ e_info_server_cb_hwc(const Eldbus_Service_Interface *iface EINA_UNUSED, const El
    return reply;
 }
 
+static Eldbus_Message *
+e_info_server_cb_aux_message(const Eldbus_Service_Interface *iface EINA_UNUSED, const Eldbus_Message *msg)
+{
+   Eldbus_Message *reply = eldbus_message_method_return_new(msg);
+   Eldbus_Message_Iter *opt_iter;
+   const char *win_str, *key, *val, *opt;
+   Eina_List *options = NULL;
+   int32_t win_id = 0;
+   E_Client *ec;
+   Evas_Object *o;
+
+   if (!e_policy)
+     {
+        ERR("e_policy is not initialized!");
+        return reply;
+     }
+
+   if (!eldbus_message_arguments_get(msg, "sssa(s)", &win_str, &key, &val, &opt_iter))
+     {
+        ERR("Error getting arguments.");
+        return reply;
+     }
+
+   while (eldbus_message_iter_get_and_next(opt_iter, 's', &opt))
+     {
+        const char *str;
+
+        str = eina_stringshare_add(opt);
+        options = eina_list_append(options, str);
+     }
+
+   sscanf(win_str, "%x", &win_id);
+   for (o = evas_object_top_get(e_comp->evas); o; o = evas_object_below_get(o))
+     {
+        ec = evas_object_data_get(o, "E_Client");
+        if (!ec) continue;
+
+        Ecore_Window win = e_client_util_win_get(ec);
+
+        if (win == win_id)
+          {
+             e_policy_aux_message_send(ec, key, val, options);
+             break;
+          }
+     }
+
+   EINA_LIST_FREE(options, opt)
+      eina_stringshare_del(opt);
+
+   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 },
@@ -1593,6 +1645,7 @@ static const Eldbus_Method methods[] = {
    { "get_keygrab_status", ELDBUS_ARGS({"s", "get_keygrab_status"}), NULL, _e_info_server_cb_keygrab_status_get, 0},
    { "get_module_info", ELDBUS_ARGS({"ss", "get_module_info"}), NULL, _e_info_server_cb_module_info_get, 0},
    { "hwc", ELDBUS_ARGS({"i", "hwc"}), NULL, e_info_server_cb_hwc, 0},
+   { "aux_msg", ELDBUS_ARGS({"s","window id" }, {"s", "key"}, {"s", "value"}, {"as", "options"}), NULL, e_info_server_cb_aux_message, 0},
    { NULL, NULL, NULL, NULL, 0 }
 };