Reduce action related IPC 39/136239/1
authorShinwoo Kim <cinoo.kim@samsung.com>
Fri, 19 May 2017 10:48:06 +0000 (19:48 +0900)
committerShinwoo Kim <cinoo.kim@samsung.com>
Thu, 29 Jun 2017 00:03:56 +0000 (09:03 +0900)
If there are more than 10 actions on an object, then more than 10 IPC occurs for
doing more than 10th action.

Change-Id: Ide01c3f871684163d53c52f17ac10bdd65a73a49

atk-adaptor/adaptors/action-adaptor.c

index a6c409d..b74a033 100644 (file)
@@ -22,6 +22,7 @@
  * Boston, MA 02111-1307, USA.
  */
 
+#include <string.h>
 #include <atk/atk.h>
 #include <droute/droute.h>
 #include "bridge.h"
@@ -227,6 +228,46 @@ impl_DoAction (DBusConnection * bus, DBusMessage * message, void *user_data)
   return NULL;
 }
 
+static DBusMessage *
+impl_DoActionName (DBusConnection * bus, DBusMessage * message, void *user_data)
+{
+  AtkAction *action = (AtkAction *) user_data;
+  const char *action_name = NULL;
+  gint count;
+  gint i, index = -1;
+  dbus_bool_t rv = TRUE;
+  DBusMessage *reply;
+
+  g_return_val_if_fail (ATK_IS_ACTION (user_data),
+                        droute_not_yet_handled_error (message));
+  if (!dbus_message_get_args
+      (message, NULL, DBUS_TYPE_STRING, &action_name, DBUS_TYPE_INVALID))
+    {
+      return droute_invalid_arguments_error (message);
+    }
+  reply = dbus_message_new_method_return (message);
+  if (reply)
+    {
+      dbus_message_append_args (reply, DBUS_TYPE_BOOLEAN, &rv,
+                                DBUS_TYPE_INVALID);
+    }
+  dbus_connection_send (bus, reply, NULL);
+  dbus_message_unref (reply);
+
+  count = atk_action_get_n_actions (action);
+  for (i = 0; i < count; i++)
+    {
+      const char *name = atk_action_get_name (action, i);
+      if (name && !strcmp(name, action_name))
+        {
+          index = i;
+          break;
+        }
+    }
+  atk_action_do_action (action, index);
+  return NULL;
+}
+
 DRouteMethod methods[] = {
   {impl_get_description, "GetDescription"}
   ,
@@ -240,6 +281,8 @@ DRouteMethod methods[] = {
   ,
   {impl_DoAction, "DoAction"}
   ,
+  {impl_DoActionName, "DoActionName"}
+  ,
   {NULL, NULL}
 };