use sd_get_active_uids() instead of sd_get_uids() for getting active user id 00/106600/2
authorKyeonghun Lee <kh9090.lee@samsung.com>
Thu, 22 Dec 2016 07:12:34 +0000 (16:12 +0900)
committerKyeonghun Lee <kh9090.lee@samsung.com>
Thu, 22 Dec 2016 07:14:55 +0000 (16:14 +0900)
Change-Id: I91f1790686d5a13398e0b942956b90ae346497f6
Signed-off-by: Kyeonghun Lee <kh9090.lee@samsung.com>
utils/MsgUtilFunction.cpp

index 61851c6..554dbf6 100755 (executable)
@@ -1226,30 +1226,20 @@ gchar * msg_replace_non_ascii_char(const gchar *pszText, gunichar replacementCha
 static int __find_login_user(uid_t *uid)
 {
        uid_t *uids = NULL;
-       char *state = NULL;
 
-       int uids_len = sd_get_uids(&uids);
-       if (uids_len <= 0)
+       int uids_len = sd_get_active_uids(&uids);
+       if (uids == NULL)
                return -1;
 
-       for (int i = 0; i < uids_len; i++) {
-               if (sd_uid_get_state(uids[i], &state) < 0) {
-                       free(uids);
-                       return -1;
-               } else {
-                       if (g_strcmp0(state, "online") == 0) {
-                               *uid = uids[i];
-                               free(uids);
-                               free(state);
-                               return 0;
-                       }
-               }
-
-               free(state);
+       if (uids_len != 1) {
+               free(uids);
+               return -1;
        }
 
+       *uid = uids[0];
+
        free(uids);
-       return -1;
+       return 0;
 }