From: Kyeonghun Lee Date: Thu, 22 Dec 2016 07:12:34 +0000 (+0900) Subject: use sd_get_active_uids() instead of sd_get_uids() for getting active user id X-Git-Tag: submit/tizen_3.0/20161226.023614~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F00%2F106600%2F2;p=platform%2Fcore%2Fmessaging%2Fmsg-service.git use sd_get_active_uids() instead of sd_get_uids() for getting active user id Change-Id: I91f1790686d5a13398e0b942956b90ae346497f6 Signed-off-by: Kyeonghun Lee --- diff --git a/utils/MsgUtilFunction.cpp b/utils/MsgUtilFunction.cpp index 61851c6..554dbf6 100755 --- a/utils/MsgUtilFunction.cpp +++ b/utils/MsgUtilFunction.cpp @@ -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; }