keyrouter: Rename grabbed for more suitable name 21/278221/1
authorSeunghun Lee <shiin.lee@samsung.com>
Fri, 10 Jun 2022 01:42:34 +0000 (10:42 +0900)
committerSooChan Lim <sc1.lim@samsung.com>
Mon, 18 Jul 2022 05:58:58 +0000 (14:58 +0900)
The variable 'grabbed' was only used to check to see if the associated
client has been privileged. So, it's better to rename 'grabbed' to
'privileged'. Plus, it should be determined when checking privilege.

Change-Id: Ibc3956b6ab6e21bf8fd3d58d9a1c4fbcce1aec67

src/keyrouter/keyrouter.c
src/keyrouter/keyrouter.h

index 62753dd8ad5674b65120707a2c95474813f949ac..9d70fceac9e733dc4467e5b89f2f31528621107e 100644 (file)
@@ -120,8 +120,6 @@ keyrouter_handle_keygrab_set(struct wl_client *client,
 
     res = keyrouter_grab_grab_key(keyrouter->keyrouter_grab,
         mode, key, (void *)client);
-    if (res == TIZEN_KEYROUTER_ERROR_NONE && keyrouter_client->grabbed != true)
-        keyrouter_client->grabbed = true;
 
     tizen_keyrouter_send_keygrab_notify(resource, surface, key, mode, res);
 }
@@ -210,8 +208,6 @@ keyrouter_handle_keygrab_set_list(struct wl_client *client,
         } else {
             res = keyrouter_grab_grab_key(keyrouter->keyrouter_grab,
                 grab_data->mode, grab_data->key, (void *)client);
-            if (res == TIZEN_KEYROUTER_ERROR_NONE && keyrouter_client->grabbed != true)
-                keyrouter_client->grabbed = true;
 
             grab_data->err = res;
         }
@@ -381,13 +377,16 @@ keyrouter_check_privilege(struct ds_tizen_keyrouter_client *keyrouter_client,
             return true;
     }
 
-    // grabbed client is already checked the privilege before.
-    if (keyrouter_client->grabbed)
+    // already checked the privilege before.
+    if (keyrouter_client->privileged)
         return true;
 
     wl_client_get_credentials(client, &pid, &uid, &gid);
 
-    return tizen_security_check_privilege(pid, uid, "http://tizen.org/privilege/keygrab");
+    keyrouter_client->privileged = tizen_security_check_privilege(pid, uid,
+            "http://tizen.org/privilege/keygrab");
+
+    return keyrouter_client->privileged;
 }
 
 static void
index 3d8834624f21bc2fb171bc8ea800814c87e2e098..ab10f9be0ad90940f4f9c272d52a00a134429ee0 100644 (file)
@@ -66,7 +66,7 @@ struct ds_tizen_keyrouter_client
 
     struct wl_resource *resource;
 
-    bool grabbed;
+    bool privileged;
 
     struct wl_list link; // ds_tizen_keyrouter::clients
 };