static int _ctsvc_ipc_create(pims_ipc_h *p_ipc)
{
char sock_file[CTSVC_PATH_MAX_LEN] = {0};
- uid_t uid = 0;
+ uid_t uid = getuid();
- if (CONTACTS_ERROR_NONE != ctsvc_client_get_uid(&uid))
- return CONTACTS_ERROR_SYSTEM;
+ if (ctsvc_client_is_in_system_session()) {
+ if (CONTACTS_ERROR_NONE != ctsvc_client_get_active_uid(&uid))
+ return CONTACTS_ERROR_SYSTEM;
+ }
snprintf(sock_file, sizeof(sock_file), CTSVC_SOCK_PATH"/.%s", uid,
CTSVC_IPC_SERVICE);
if (NULL == __ipc) {
char sock_file[CTSVC_PATH_MAX_LEN] = {0};
- uid_t uid = 0;
+ uid_t uid = getuid();
- if (CONTACTS_ERROR_NONE != ctsvc_client_get_uid(&uid))
- return CONTACTS_ERROR_SYSTEM;
+ if (ctsvc_client_is_in_system_session()) {
+ if (CONTACTS_ERROR_NONE != ctsvc_client_get_active_uid(&uid))
+ return CONTACTS_ERROR_SYSTEM;
+ }
snprintf(sock_file, sizeof(sock_file), CTSVC_SOCK_PATH"/.%s_for_subscribe",
uid, CTSVC_IPC_SERVICE);
pims_ipc_destroy_for_subscribe(__ipc);
char sock_file[CTSVC_PATH_MAX_LEN] = {0};
- uid_t uid = 0;
+ uid_t uid = getuid();
- if (CONTACTS_ERROR_NONE != ctsvc_client_get_uid(&uid))
- return CONTACTS_ERROR_SYSTEM;
+ if (ctsvc_client_is_in_system_session()) {
+ if (CONTACTS_ERROR_NONE != ctsvc_client_get_active_uid(&uid))
+ return CONTACTS_ERROR_SYSTEM;
+ }
snprintf(sock_file, sizeof(sock_file), CTSVC_SOCK_PATH"/.%s_for_subscribe",
uid, CTSVC_IPC_SERVICE);
return (unsigned int)syscall(SYS_gettid);
}
-int ctsvc_client_get_uid(uid_t *uid)
+bool ctsvc_client_is_in_system_session()
{
- RETV_IF(NULL == uid, CONTACTS_ERROR_INVALID_PARAMETER);
-
int ret = 0;
- uid_t *active_user_list = NULL;
char *slice = NULL;
- *uid = getuid();
ret = sd_pid_get_slice(getpid(), &slice);
if (0 <= ret && slice) {
if (STRING_EQUAL == strncmp(slice, CTSVC_SYSTEM_SLICE, strlen(CTSVC_SYSTEM_SLICE))) {
- ret = sd_get_active_uids(&active_user_list);
- /* the number of active users is 1 in tizen3.0 */
- if (1 == ret && active_user_list) {
- *uid = active_user_list[0];
- INFO("uid = %d", *uid);
- } else {
- ERR("sd_get_active_uids() Fail(%d)", ret);
- free(active_user_list);
- free(slice);
- return CONTACTS_ERROR_SYSTEM;
- }
- free(active_user_list);
+ free(slice);
+ return TRUE;
}
- free(slice);
} else {
ERR("sd_pid_get_slice() Fail(%d)", ret);
}
- INFO("getuid() = %d, uid = %d", getuid(), *uid);
- return CONTACTS_ERROR_NONE;
+ free(slice);
+ return FALSE;
}
+int ctsvc_client_get_active_uid(uid_t *uid)
+{
+ int active_user_count = 0;
+ uid_t *active_user_list = NULL;
+
+ active_user_count = sd_get_active_uids(&active_user_list);
+ /* the number of active users is 1 in tizen3.0 */
+ if (1 == active_user_count && active_user_list) {
+ *uid = active_user_list[0];
+ INFO("active uid = %d", *uid);
+ } else {
+ ERR("sd_get_active_uids() Fail(%d)", active_user_count);
+ free(active_user_list);
+ return CONTACTS_ERROR_SYSTEM;
+ }
+
+ return CONTACTS_ERROR_NONE;
+}
unsigned int ctsvc_client_get_pid();
unsigned int ctsvc_client_get_tid();
-int ctsvc_client_get_uid(uid_t *uid);
+bool ctsvc_client_is_in_system_session();
+int ctsvc_client_get_active_uid(uid_t *uid);
#endif /* __CTSVC_CLIENT_UTILS_H__ */
#include <fcntl.h>
#include <unistd.h>
#include <sys/types.h>
+#include <pwd.h>
#include <sys/inotify.h>
#include "contacts.h"
#include "ctsvc_notify.h"
#include "ctsvc_view.h"
#include "ctsvc_handle.h"
+#include "ctsvc_inotify.h"
#include <stdbool.h>
#ifdef _CONTACTS_IPC_CLIENT
#include "ctsvc_client_ipc.h"
+#include "ctsvc_client_utils.h"
#endif
typedef struct {
return CONTACTS_ERROR_NONE;
}
-static inline const char* __ctsvc_noti_get_file_path(const char *view_uri)
+static int __ctsvc_noti_get_file_path(const char *view_uri, char **path)
{
ctsvc_record_type_e match = ctsvc_view_get_record_type(view_uri);
+ char *file = NULL;
+
switch ((int)match) {
case CTSVC_RECORD_ADDRESSBOOK:
- return CTSVC_NOTI_ADDRESSBOOK_CHANGED;
+ file = CTSVC_NOTI_ADDRESSBOOK_CHANGED;
+ break;
case CTSVC_RECORD_GROUP:
- return CTSVC_NOTI_GROUP_CHANGED;
+ file = CTSVC_NOTI_GROUP_CHANGED;
+ break;
case CTSVC_RECORD_PERSON:
- return CTSVC_NOTI_PERSON_CHANGED;
+ file = CTSVC_NOTI_PERSON_CHANGED;
+ break;
case CTSVC_RECORD_CONTACT:
case CTSVC_RECORD_SIMPLE_CONTACT:
- return CTSVC_NOTI_CONTACT_CHANGED;
+ file = CTSVC_NOTI_CONTACT_CHANGED;
+ break;
case CTSVC_RECORD_MY_PROFILE:
- return CTSVC_NOTI_MY_PROFILE_CHANGED;
+ file = CTSVC_NOTI_MY_PROFILE_CHANGED;
+ break;
case CTSVC_RECORD_NAME:
- return CTSVC_NOTI_NAME_CHANGED;
+ file = CTSVC_NOTI_NAME_CHANGED;
+ break;
case CTSVC_RECORD_COMPANY:
- return CTSVC_NOTI_COMPANY_CHANGED;
+ file = CTSVC_NOTI_COMPANY_CHANGED;
+ break;
case CTSVC_RECORD_NOTE:
- return CTSVC_NOTI_NOTE_CHANGED;
+ file = CTSVC_NOTI_NOTE_CHANGED;
+ break;
case CTSVC_RECORD_NUMBER:
- return CTSVC_NOTI_NUMBER_CHANGED;
+ file = CTSVC_NOTI_NUMBER_CHANGED;
+ break;
case CTSVC_RECORD_EMAIL:
- return CTSVC_NOTI_EMAIL_CHANGED;
+ file = CTSVC_NOTI_EMAIL_CHANGED;
+ break;
case CTSVC_RECORD_URL:
- return CTSVC_NOTI_URL_CHANGED;
+ file = CTSVC_NOTI_URL_CHANGED;
+ break;
case CTSVC_RECORD_EVENT:
- return CTSVC_NOTI_EVENT_CHANGED;
+ file = CTSVC_NOTI_EVENT_CHANGED;
+ break;
case CTSVC_RECORD_NICKNAME:
- return CTSVC_NOTI_NICKNAME_CHANGED;
+ file = CTSVC_NOTI_NICKNAME_CHANGED;
+ break;
case CTSVC_RECORD_ADDRESS:
- return CTSVC_NOTI_ADDRESS_CHANGED;
+ file = CTSVC_NOTI_ADDRESS_CHANGED;
+ break;
case CTSVC_RECORD_MESSENGER:
- return CTSVC_NOTI_MESSENGER_CHANGED;
+ file = CTSVC_NOTI_MESSENGER_CHANGED;
+ break;
case CTSVC_RECORD_GROUP_RELATION:
- return CTSVC_NOTI_GROUP_RELATION_CHANGED;
+ file = CTSVC_NOTI_GROUP_RELATION_CHANGED;
+ break;
case CTSVC_RECORD_ACTIVITY:
- return CTSVC_NOTI_ACTIVITY_CHANGED;
+ file = CTSVC_NOTI_ACTIVITY_CHANGED;
+ break;
case CTSVC_RECORD_ACTIVITY_PHOTO:
- return CTSVC_NOTI_ACTIVITY_PHOTO_CHANGED;
+ file = CTSVC_NOTI_ACTIVITY_PHOTO_CHANGED;
+ break;
case CTSVC_RECORD_PROFILE:
- return CTSVC_NOTI_PROFILE_CHANGED;
+ file = CTSVC_NOTI_PROFILE_CHANGED;
+ break;
case CTSVC_RECORD_RELATIONSHIP:
- return CTSVC_NOTI_RELATIONSHIP_CHANGED;
+ file = CTSVC_NOTI_RELATIONSHIP_CHANGED;
+ break;
case CTSVC_RECORD_IMAGE:
- return CTSVC_NOTI_IMAGE_CHANGED;
+ file = CTSVC_NOTI_IMAGE_CHANGED;
+ break;
case CTSVC_RECORD_EXTENSION:
- return CTSVC_NOTI_DATA_CHANGED;
+ file = CTSVC_NOTI_DATA_CHANGED;
+ break;
case CTSVC_RECORD_PHONELOG:
- return CTSVC_NOTI_PHONELOG_CHANGED;
+ file = CTSVC_NOTI_PHONELOG_CHANGED;
+ break;
case CTSVC_RECORD_SPEEDDIAL:
- return CTSVC_NOTI_SPEEDDIAL_CHANGED;
+ file = CTSVC_NOTI_SPEEDDIAL_CHANGED;
+ break;
case CTSVC_RECORD_SDN:
- return CTSVC_NOTI_SDN_CHANGED;
+ file = CTSVC_NOTI_SDN_CHANGED;
+ break;
case CTSVC_RECORD_SIP:
- return CTSVC_NOTI_SIP_CHANGED;
+ file = CTSVC_NOTI_SIP_CHANGED;
+ break;
case CTSVC_RECORD_RESULT:
default:
/* LCOV_EXCL_START */
ERR("The type(%s) is not supported", view_uri);
- return NULL;
+ return CONTACTS_ERROR_INVALID_PARAMETER;
/* LCOV_EXCL_STOP */
}
- return NULL;
+
+ *path = ctsvc_inotify_makepath(file);
+ if (NULL == *path) {
+ ERR("ctsvc_inotify_makepath() fail");
+ return CONTACTS_ERROR_SYSTEM;
+ }
+
+ return CONTACTS_ERROR_NONE;
}
int ctsvc_inotify_subscribe_ipc_ready(void (*cb)(void *), void *user_data)
{
- const char *noti_path = CTSVC_NOTI_IPC_READY;
+ char *noti_path = ctsvc_inotify_makepath(CTSVC_NOTI_IPC_READY);
struct socket_init_noti_info *noti_info = NULL;
+ if (NULL == noti_path) {
+ ERR("ctsvc_inotify_makepath() fail");
+ return CONTACTS_ERROR_SYSTEM;
+ }
+
if (NULL == _ctsvc_socket_init_noti_table)
_ctsvc_socket_init_noti_table = g_hash_table_new_full(g_str_hash, g_str_equal, free, free);
else
if (-1 == wd) {
/* LCOV_EXCL_START */
ERR("__ctsvc_inotify_get_wd() Fail(noti_path=%s, errno : %d)", noti_path, errno);
+ free(noti_path);
if (errno == EACCES)
return CONTACTS_ERROR_PERMISSION_DENIED;
return CONTACTS_ERROR_SYSTEM;
if (CONTACTS_ERROR_NONE != ret) {
/* LCOV_EXCL_START */
ERR("__ctsvc_inotify_watch() Fail");
+ free(noti_path);
return ret;
/* LCOV_EXCL_STOP */
}
if (NULL == noti_info) {
/* LCOV_EXCL_START */
ERR("calloc() return NULL");
+ free(noti_path);
return ret;
/* LCOV_EXCL_STOP */
}
noti_info->wd = wd;
noti_info->cb = cb;
noti_info->cb_data = user_data;
- g_hash_table_insert(_ctsvc_socket_init_noti_table, strdup(noti_path), noti_info);
+ g_hash_table_insert(_ctsvc_socket_init_noti_table, noti_path, noti_info);
}
noti_info->subscribe_count++;
return CONTACTS_ERROR_NONE;
int ctsvc_inotify_unsubscribe_ipc_ready()
{
- const char *noti_path = CTSVC_NOTI_IPC_READY;
+ RETV_IF(NULL == _ctsvc_socket_init_noti_table, CONTACTS_ERROR_INVALID_PARAMETER);
+
+ char *noti_path = ctsvc_inotify_makepath(CTSVC_NOTI_IPC_READY);
struct socket_init_noti_info *noti_info = NULL;
- RETV_IF(NULL == _ctsvc_socket_init_noti_table, CONTACTS_ERROR_INVALID_PARAMETER);
+ if (NULL == noti_path) {
+ ERR("ctsvc_inotify_makepath() fail");
+ return CONTACTS_ERROR_SYSTEM;
+ }
noti_info = g_hash_table_lookup(_ctsvc_socket_init_noti_table, noti_path);
if (NULL == noti_info) {
/* LCOV_EXCL_START */
ERR("g_hash_table_lookup() return NULL");
+ free(noti_path);
return CONTACTS_ERROR_INVALID_PARAMETER;
/* LCOV_EXCL_STOP */
}
noti_info->subscribe_count--;
}
+ free(noti_path);
return CONTACTS_ERROR_NONE;
}
-int ctsvc_inotify_subscribe(const char *view_uri, void *cb, void *data)
+int ctsvc_inotify_subscribe(const char *view_uri, contacts_db_changed_cb cb, void *data)
{
int ret, wd;
noti_info *noti, *same_noti = NULL;
GSList *it;
- const char *path;
+ char *path = NULL;
RETV_IF(NULL == cb, CONTACTS_ERROR_INVALID_PARAMETER);
RETVM_IF(__inoti_fd < 0, CONTACTS_ERROR_SYSTEM,
"__inoti_fd(%d) is invalid", __inoti_fd);
- path = __ctsvc_noti_get_file_path(view_uri);
- RETVM_IF(NULL == path, CONTACTS_ERROR_INVALID_PARAMETER,
- "__ctsvc_noti_get_file_path(%s) Fail", view_uri);
+ ret = __ctsvc_noti_get_file_path(view_uri, &path);
+ if (CONTACTS_ERROR_NONE != ret) {
+ ERR("__ctsvc_noti_get_file_path() fail(%d)", ret);
+ return ret;
+ }
wd = __ctsvc_inotify_get_wd(__inoti_fd, path);
if (-1 == wd) {
/* LCOV_EXCL_START */
ERR("__ctsvc_inotify_get_wd() Fail(errno : %d)", errno);
+ free(path);
if (errno == EACCES)
return CONTACTS_ERROR_PERMISSION_DENIED;
return CONTACTS_ERROR_SYSTEM;
__ctsvc_inotify_watch(__inoti_fd, path);
/* LCOV_EXCL_START */
ERR("The same callback(%s) is already exist", view_uri);
+ free(path);
return CONTACTS_ERROR_INVALID_PARAMETER;
/* LCOV_EXCL_STOP */
}
ret = __ctsvc_inotify_watch(__inoti_fd, path);
+ free(path);
RETVM_IF(CONTACTS_ERROR_NONE != ret, ret, "__ctsvc_inotify_watch() Fail");
noti = calloc(1, sizeof(noti_info));
return remain_cnt;
}
-int ctsvc_inotify_unsubscribe(const char *view_uri, void *cb, void *user_data)
+int ctsvc_inotify_unsubscribe(const char *view_uri, contacts_db_changed_cb cb, void *user_data)
{
int ret, wd;
- const char *path;
+ char *path = NULL;
RETV_IF(NULL == cb, CONTACTS_ERROR_INVALID_PARAMETER);
RETVM_IF(__inoti_fd < 0, CONTACTS_ERROR_SYSTEM,
"System : __inoti_fd(%d) is invalid", __inoti_fd);
- path = __ctsvc_noti_get_file_path(view_uri);
- RETVM_IF(NULL == path, CONTACTS_ERROR_INVALID_PARAMETER,
- "__ctsvc_noti_get_file_path(%s) Fail", view_uri);
+ ret = __ctsvc_noti_get_file_path(view_uri, &path);
+ if (CONTACTS_ERROR_NONE != ret) {
+ ERR("__ctsvc_noti_get_file_path() fail(%d)", ret);
+ return ret;
+ }
wd = __ctsvc_inotify_get_wd(__inoti_fd, path);
if (-1 == wd) {
/* LCOV_EXCL_START */
ERR("__ctsvc_inotify_get_wd() Fail(errno : %d)", errno);
+ free(path);
if (errno == EACCES)
return CONTACTS_ERROR_PERMISSION_DENIED;
return CONTACTS_ERROR_SYSTEM;
ret = __ctsvc_del_noti(&__noti_list, wd, view_uri, cb, user_data);
WARN_IF(ret < CONTACTS_ERROR_NONE, "__ctsvc_del_noti() Fail(%d)", ret);
- if (0 == ret)
+ if (0 == ret) {
+ free(path);
return inotify_rm_watch(__inoti_fd, wd);
+ }
- return __ctsvc_inotify_watch(__inoti_fd, path);
+ ret = __ctsvc_inotify_watch(__inoti_fd, path);
+ free(path);
+ return ret;
}
static void __clear_nslot_list(gpointer data, gpointer user_data)
}
}
+static const char* __ctsvc_inotify_get_username(uid_t uid)
+{
+ struct passwd pwd;
+ struct passwd* pwd_result;
+ char tmp[CTSVC_STR_SHORT_LEN];
+
+ int ret = getpwuid_r(uid, &pwd, tmp, sizeof(tmp), &pwd_result);
+ if (ret != 0 || pwd_result == NULL) {
+ ERR("getpwuid_r() fail");
+ return "";
+ }
+
+ return pwd.pw_name;
+}
+
+char* ctsvc_inotify_makepath(const char *file)
+{
+ RETV_IF(NULL == file, NULL);
+
+ static int user_name_max = 32;
+ int path_len = 0;
+ char *path = NULL;
+ uid_t uid = getuid();
+ const char* user_name = NULL;
+
+#ifdef _CONTACTS_IPC_CLIENT
+ if (ctsvc_client_is_in_system_session()) {
+ if (CONTACTS_ERROR_NONE != ctsvc_client_get_active_uid(&uid))
+ return NULL;
+ }
+#endif
+
+ path_len = strlen(CTSVC_NOTI_PATH) + user_name_max + strlen(file) + 1;
+ path = calloc(1, path_len);
+ if (NULL == path) {
+ ERR("calloc() fail");
+ return NULL;
+ }
+
+ user_name = __ctsvc_inotify_get_username(uid);
+ snprintf(path, path_len, CTSVC_NOTI_PATH"/%s", user_name, file);
+ DBG("%s", path);
+ return path;
+}
+
int ctsvc_inotify_subscribe_ipc_ready(void (*cb)(void *), void *user_data);
int ctsvc_inotify_unsubscribe_ipc_ready();
+char* ctsvc_inotify_makepath(const char *file);
#endif /* __CTSVC_INOTIFY_H__ */
#define CTSVC_VCARD_IMAGE_LOCATION tzplatform_mkpath(TZ_USER_SHARE, "vcard")
#define DATA_REPERTORY tzplatform_getenv(TZ_USER_DATA)
-#define CTSVC_NOTI_REPERTORY tzplatform_mkpath(TZ_USER_DATA, "contacts-svc")
-#define CTSVC_NOTI_IMG_REPERTORY tzplatform_mkpath(TZ_USER_DATA, "contacts-svc/img/")
+#define CTSVC_DATA_REPERTORY tzplatform_mkpath(TZ_USER_DATA, "contacts-svc")
+#define CTSVC_IMG_REPERTORY tzplatform_mkpath(TZ_USER_DATA, "contacts-svc/img/")
#define CTS_MY_IMAGE_LOCATION tzplatform_mkpath(TZ_USER_DATA, "contacts-svc/img/my")
#define CTS_GROUP_IMAGE_LOCATION tzplatform_mkpath(TZ_USER_DATA, "contacts-svc/img/group")
#define CTS_LOGO_IMAGE_LOCATION tzplatform_mkpath(TZ_USER_DATA, "contacts-svc/img/logo")
#define CTSVC_CONTACT_IMG_FULL_LOCATION tzplatform_mkpath(TZ_USER_DATA, "contacts-svc/img/contact")
-#define CTSVC_NOTI_IPC_READY tzplatform_mkpath(TZ_USER_DATA, "contacts-svc/.CONTACTS_SVC_IPC_READY")
-#define CTSVC_NOTI_ADDRESSBOOK_CHANGED tzplatform_mkpath(TZ_USER_DATA, "contacts-svc/.CONTACTS_SVC_AB_CHANGED")
-#define CTSVC_NOTI_GROUP_CHANGED tzplatform_mkpath(TZ_USER_DATA, "contacts-svc/.CONTACTS_SVC_GROUP_CHANGED")
-#define CTSVC_NOTI_PERSON_CHANGED tzplatform_mkpath(TZ_USER_DATA, "contacts-svc/.CONTACTS_SVC_PERSON_CHANGED")
-#define CTSVC_NOTI_CONTACT_CHANGED tzplatform_mkpath(TZ_USER_DATA, "contacts-svc/.CONTACTS_SVC_DB_CHANGED")
-#define CTSVC_NOTI_MY_PROFILE_CHANGED tzplatform_mkpath(TZ_USER_DATA, "contacts-svc/.CONTACTS_SVC_MY_PROFILE_CHANGED")
-#define CTSVC_NOTI_NAME_CHANGED tzplatform_mkpath(TZ_USER_DATA, "contacts-svc/.CONTACTS_SVC_NAME_CHANGED")
-#define CTSVC_NOTI_NUMBER_CHANGED tzplatform_mkpath(TZ_USER_DATA, "contacts-svc/.CONTACTS_SVC_NUMBER_CHANGED")
-#define CTSVC_NOTI_EMAIL_CHANGED tzplatform_mkpath(TZ_USER_DATA, "contacts-svc/.CONTACTS_SVC_EMAIL_CHANGED")
-#define CTSVC_NOTI_EVENT_CHANGED tzplatform_mkpath(TZ_USER_DATA, "contacts-svc/.CONTACTS_SVC_EVENT_CHANGED")
-#define CTSVC_NOTI_URL_CHANGED tzplatform_mkpath(TZ_USER_DATA, "contacts-svc/.CONTACTS_SVC_URL_CHANGED")
-#define CTSVC_NOTI_GROUP_RELATION_CHANGED tzplatform_mkpath(TZ_USER_DATA, "contacts-svc/.CONTACTS_SVC_GROUP_RELATION_CHANGED")
-#define CTSVC_NOTI_ADDRESS_CHANGED tzplatform_mkpath(TZ_USER_DATA, "contacts-svc/.CONTACTS_SVC_ADDRESS_CHANGED")
-#define CTSVC_NOTI_NOTE_CHANGED tzplatform_mkpath(TZ_USER_DATA, "contacts-svc/.CONTACTS_SVC_NOTE_CHANGED")
-#define CTSVC_NOTI_COMPANY_CHANGED tzplatform_mkpath(TZ_USER_DATA, "contacts-svc/.CONTACTS_SVC_COMPANY_CHANGED")
-#define CTSVC_NOTI_RELATIONSHIP_CHANGED tzplatform_mkpath(TZ_USER_DATA, "contacts-svc/.CONTACTS_SVC_RELATIONSHIP_CHANGED")
-#define CTSVC_NOTI_IMAGE_CHANGED tzplatform_mkpath(TZ_USER_DATA, "contacts-svc/.CONTACTS_SVC_IMAGE_CHANGED")
-#define CTSVC_NOTI_NICKNAME_CHANGED tzplatform_mkpath(TZ_USER_DATA, "contacts-svc/.CONTACTS_SVC_NICKNAME_CHANGED")
-#define CTSVC_NOTI_MESSENGER_CHANGED tzplatform_mkpath(TZ_USER_DATA, "contacts-svc/.CONTACTS_SVC_MESSENGER_CHANGED")
-#define CTSVC_NOTI_DATA_CHANGED tzplatform_mkpath(TZ_USER_DATA, "contacts-svc/.CONTACTS_SVC_DATA_CHANGED")
-#define CTSVC_NOTI_SDN_CHANGED tzplatform_mkpath(TZ_USER_DATA, "contacts-svc/.CONTACTS_SVC_SDN_CHANGED")
-#define CTSVC_NOTI_PROFILE_CHANGED tzplatform_mkpath(TZ_USER_DATA, "contacts-svc/.CONTACTS_SVC_PROFILE_CHANGED")
-#define CTSVC_NOTI_ACTIVITY_CHANGED tzplatform_mkpath(TZ_USER_DATA, "contacts-svc/.CONTACTS_SVC_ACTIVITY_CHANGED")
-#define CTSVC_NOTI_ACTIVITY_PHOTO_CHANGED tzplatform_mkpath(TZ_USER_DATA, "contacts-svc/.CONTACTS_SVC_ACTIVITY_PHOTO_CHANGED")
-#define CTSVC_NOTI_PHONELOG_CHANGED tzplatform_mkpath(TZ_USER_DATA, "contacts-svc/.CONTACTS_SVC_PLOG_CHANGED")
-#define CTSVC_NOTI_SPEEDDIAL_CHANGED tzplatform_mkpath(TZ_USER_DATA, "contacts-svc/.CONTACTS_SVC_SPEED_CHANGED")
-#define CTSVC_NOTI_SIP_CHANGED tzplatform_mkpath(TZ_USER_DATA, "contacts-svc/.CONTACTS_SVC_SIP_CHANGED")
+#define CTSVC_NOTI_PATH "/opt/usr/home/%s/data/contacts-svc"
+#define CTSVC_NOTI_IPC_READY ".CONTACTS_SVC_IPC_READY"
+#define CTSVC_NOTI_ADDRESSBOOK_CHANGED ".CONTACTS_SVC_AB_CHANGED"
+#define CTSVC_NOTI_GROUP_CHANGED ".CONTACTS_SVC_GROUP_CHANGED"
+#define CTSVC_NOTI_PERSON_CHANGED ".CONTACTS_SVC_PERSON_CHANGED"
+#define CTSVC_NOTI_CONTACT_CHANGED ".CONTACTS_SVC_DB_CHANGED"
+#define CTSVC_NOTI_MY_PROFILE_CHANGED ".CONTACTS_SVC_MY_PROFILE_CHANGED"
+#define CTSVC_NOTI_NAME_CHANGED ".CONTACTS_SVC_NAME_CHANGED"
+#define CTSVC_NOTI_NUMBER_CHANGED ".CONTACTS_SVC_NUMBER_CHANGED"
+#define CTSVC_NOTI_EMAIL_CHANGED ".CONTACTS_SVC_EMAIL_CHANGED"
+#define CTSVC_NOTI_EVENT_CHANGED ".CONTACTS_SVC_EVENT_CHANGED"
+#define CTSVC_NOTI_URL_CHANGED ".CONTACTS_SVC_URL_CHANGED"
+#define CTSVC_NOTI_GROUP_RELATION_CHANGED ".CONTACTS_SVC_GROUP_RELATION_CHANGED"
+#define CTSVC_NOTI_ADDRESS_CHANGED ".CONTACTS_SVC_ADDRESS_CHANGED"
+#define CTSVC_NOTI_NOTE_CHANGED ".CONTACTS_SVC_NOTE_CHANGED"
+#define CTSVC_NOTI_COMPANY_CHANGED ".CONTACTS_SVC_COMPANY_CHANGED"
+#define CTSVC_NOTI_RELATIONSHIP_CHANGED ".CONTACTS_SVC_RELATIONSHIP_CHANGED"
+#define CTSVC_NOTI_IMAGE_CHANGED ".CONTACTS_SVC_IMAGE_CHANGED"
+#define CTSVC_NOTI_NICKNAME_CHANGED ".CONTACTS_SVC_NICKNAME_CHANGED"
+#define CTSVC_NOTI_MESSENGER_CHANGED ".CONTACTS_SVC_MESSENGER_CHANGED"
+#define CTSVC_NOTI_DATA_CHANGED ".CONTACTS_SVC_DATA_CHANGED"
+#define CTSVC_NOTI_SDN_CHANGED ".CONTACTS_SVC_SDN_CHANGED"
+#define CTSVC_NOTI_PROFILE_CHANGED ".CONTACTS_SVC_PROFILE_CHANGED"
+#define CTSVC_NOTI_ACTIVITY_CHANGED ".CONTACTS_SVC_ACTIVITY_CHANGED"
+#define CTSVC_NOTI_ACTIVITY_PHOTO_CHANGED ".CONTACTS_SVC_ACTIVITY_PHOTO_CHANGED"
+#define CTSVC_NOTI_PHONELOG_CHANGED ".CONTACTS_SVC_PLOG_CHANGED"
+#define CTSVC_NOTI_SPEEDDIAL_CHANGED ".CONTACTS_SVC_SPEED_CHANGED"
+#define CTSVC_NOTI_SIP_CHANGED ".CONTACTS_SVC_SIP_CHANGED"
#define CTSVC_SETTING_DISPLAY_ORDER_CHANGED "contacts.setting.display_order"
#define CTSVC_SETTING_SORTING_ORDER_CHANGED "contacts.setting.sorting_order"
{
int ret;
struct sockaddr_un caddr;
+ uid_t uid = getuid();
if (0 < __ctsvc_conn_refcnt) {
__ctsvc_conn_refcnt++;
}
char sock_file[CTSVC_PATH_MAX_LEN] = {0};
-#ifdef _CONTACTS_IPC_CLIENT
- uid_t uid = 0;
- if (CONTACTS_ERROR_NONE != ctsvc_client_get_uid(&uid))
- return CONTACTS_ERROR_SYSTEM;
+#ifdef _CONTACTS_IPC_CLIENT
+ if (ctsvc_client_is_in_system_session()) {
+ if (CONTACTS_ERROR_NONE != ctsvc_client_get_active_uid(&uid))
+ return CONTACTS_ERROR_SYSTEM;
+ }
+#endif
snprintf(sock_file, sizeof(sock_file), CTSVC_SOCK_PATH"/%s", uid, CTSVC_SOCKET_FILE);
-#else
- snprintf(sock_file, sizeof(sock_file), CTSVC_SOCK_PATH"/%s", getuid(), CTSVC_SOCKET_FILE);
-#endif
+
bzero(&caddr, sizeof(caddr));
caddr.sun_family = AF_UNIX;
snprintf(caddr.sun_path, sizeof(caddr.sun_path), "%s", sock_file);
Name: contacts-service
Summary: Contacts Service
-Version: 0.13.61
+Version: 0.13.62
Release: 0
Group: Social & Content/Service
License: Apache-2.0
#include "contacts_db_status.h"
#include "ctsvc_internal.h"
#include "ctsvc_notify.h"
+#include "ctsvc_inotify.h"
#include "ctsvc_notification.h"
static TLS bool contact_change = false;
void ctsvc_noti_publish_socket_initialize(void)
{
- int fd = open(CTSVC_NOTI_IPC_READY, O_TRUNC | O_RDWR);
-
+ char *path = ctsvc_inotify_makepath(CTSVC_NOTI_IPC_READY);
+ if (NULL == path) {
+ ERR("ctsvc_inotify_makepath() fail");
+ return;
+ }
+ int fd = open(path, O_TRUNC | O_RDWR);
+ free(path);
if (0 <= fd)
close(fd);
}
static inline void __ctsvc_noti_publish_contact_change(void)
{
- int fd = open(CTSVC_NOTI_CONTACT_CHANGED, O_TRUNC | O_RDWR);
+ char *path = ctsvc_inotify_makepath(CTSVC_NOTI_CONTACT_CHANGED);
+ if (NULL == path) {
+ ERR("ctsvc_inotify_makepath() fail");
+ return;
+ }
+ int fd = open(path, O_TRUNC | O_RDWR);
+ free(path);
if (0 <= fd) {
close(fd);
contact_change = false;
static inline void __ctsvc_noti_publish_my_profile_change(void)
{
- int fd = open(CTSVC_NOTI_MY_PROFILE_CHANGED, O_TRUNC | O_RDWR);
+ char *path = ctsvc_inotify_makepath(CTSVC_NOTI_MY_PROFILE_CHANGED);
+ if (NULL == path) {
+ ERR("ctsvc_inotify_makepath() fail");
+ return;
+ }
+
+ int fd = open(path, O_TRUNC | O_RDWR);
+ free(path);
if (0 <= fd) {
close(fd);
my_profile_change = false;
static inline void __ctsvc_noti_publish_phonelog_change(void)
{
- int fd = open(CTSVC_NOTI_PHONELOG_CHANGED, O_TRUNC | O_RDWR);
+ char *path = ctsvc_inotify_makepath(CTSVC_NOTI_PHONELOG_CHANGED);
+ if (NULL == path) {
+ ERR("ctsvc_inotify_makepath() fail");
+ return;
+ }
+
+ int fd = open(path, O_TRUNC | O_RDWR);
+ free(path);
if (0 <= fd) {
close(fd);
phonelog_change = false;
static inline void __ctsvc_noti_publish_speed_change(void)
{
- int fd = open(CTSVC_NOTI_SPEEDDIAL_CHANGED, O_TRUNC | O_RDWR);
+ char *path = ctsvc_inotify_makepath(CTSVC_NOTI_SPEEDDIAL_CHANGED);
+ if (NULL == path) {
+ ERR("ctsvc_inotify_makepath() fail");
+ return;
+ }
+
+ int fd = open(path, O_TRUNC | O_RDWR);
+ free(path);
if (0 <= fd) {
close(fd);
speed_change = false;
static inline void __ctsvc_noti_publish_addressbook_change(void)
{
- int fd = open(CTSVC_NOTI_ADDRESSBOOK_CHANGED, O_TRUNC | O_RDWR);
+ char *path = ctsvc_inotify_makepath(CTSVC_NOTI_ADDRESSBOOK_CHANGED);
+ if (NULL == path) {
+ ERR("ctsvc_inotify_makepath() fail");
+ return;
+ }
+
+ int fd = open(path, O_TRUNC | O_RDWR);
+ free(path);
if (0 <= fd) {
close(fd);
addressbook_change = false;
static inline void __ctsvc_noti_publish_group_change(void)
{
- int fd = open(CTSVC_NOTI_GROUP_CHANGED, O_TRUNC | O_RDWR);
+ char *path = ctsvc_inotify_makepath(CTSVC_NOTI_GROUP_CHANGED);
+ if (NULL == path) {
+ ERR("ctsvc_inotify_makepath() fail");
+ return;
+ }
+
+ int fd = open(path, O_TRUNC | O_RDWR);
+ free(path);
if (0 <= fd) {
close(fd);
group_change = false;
static inline void __ctsvc_noti_publish_group_rel_change(void)
{
- int fd = open(CTSVC_NOTI_GROUP_RELATION_CHANGED, O_TRUNC | O_RDWR);
+ char *path = ctsvc_inotify_makepath(CTSVC_NOTI_GROUP_RELATION_CHANGED);
+ if (NULL == path) {
+ ERR("ctsvc_inotify_makepath() fail");
+ return;
+ }
+
+ int fd = open(path, O_TRUNC | O_RDWR);
+ free(path);
if (0 <= fd) {
close(fd);
group_rel_change = false;
static inline void __ctsvc_noti_publish_person_change(void)
{
- int fd = open(CTSVC_NOTI_PERSON_CHANGED, O_TRUNC | O_RDWR);
+ char *path = ctsvc_inotify_makepath(CTSVC_NOTI_PERSON_CHANGED);
+ if (NULL == path) {
+ ERR("ctsvc_inotify_makepath() fail");
+ return;
+ }
+
+ int fd = open(path, O_TRUNC | O_RDWR);
+ free(path);
if (0 <= fd) {
close(fd);
person_change = false;
static inline void __ctsvc_noti_publish_name_change(void)
{
- int fd = open(CTSVC_NOTI_NAME_CHANGED, O_TRUNC | O_RDWR);
+ char *path = ctsvc_inotify_makepath(CTSVC_NOTI_NAME_CHANGED);
+ if (NULL == path) {
+ ERR("ctsvc_inotify_makepath() fail");
+ return;
+ }
+
+ int fd = open(path, O_TRUNC | O_RDWR);
+ free(path);
if (0 <= fd) {
close(fd);
name_change = false;
static inline void __ctsvc_noti_publish_number_change(void)
{
- int fd = open(CTSVC_NOTI_NUMBER_CHANGED, O_TRUNC | O_RDWR);
+ char *path = ctsvc_inotify_makepath(CTSVC_NOTI_NUMBER_CHANGED);
+ if (NULL == path) {
+ ERR("ctsvc_inotify_makepath() fail");
+ return;
+ }
+
+ int fd = open(path, O_TRUNC | O_RDWR);
+ free(path);
if (0 <= fd) {
close(fd);
number_change = false;
static inline void __ctsvc_noti_publish_email_change(void)
{
- int fd = open(CTSVC_NOTI_EMAIL_CHANGED, O_TRUNC | O_RDWR);
+ char *path = ctsvc_inotify_makepath(CTSVC_NOTI_EMAIL_CHANGED);
+ if (NULL == path) {
+ ERR("ctsvc_inotify_makepath() fail");
+ return;
+ }
+
+ int fd = open(path, O_TRUNC | O_RDWR);
+ free(path);
if (0 <= fd) {
close(fd);
email_change = false;
static inline void __ctsvc_noti_publish_event_change(void)
{
- int fd = open(CTSVC_NOTI_EVENT_CHANGED, O_TRUNC | O_RDWR);
+ char *path = ctsvc_inotify_makepath(CTSVC_NOTI_EVENT_CHANGED);
+ if (NULL == path) {
+ ERR("ctsvc_inotify_makepath() fail");
+ return;
+ }
+
+ int fd = open(path, O_TRUNC | O_RDWR);
+ free(path);
if (0 <= fd) {
close(fd);
event_change = false;
static inline void __ctsvc_noti_publish_url_change(void)
{
- int fd = open(CTSVC_NOTI_URL_CHANGED, O_TRUNC | O_RDWR);
+ char *path = ctsvc_inotify_makepath(CTSVC_NOTI_URL_CHANGED);
+ if (NULL == path) {
+ ERR("ctsvc_inotify_makepath() fail");
+ return;
+ }
+
+ int fd = open(path, O_TRUNC | O_RDWR);
+ free(path);
if (0 <= fd) {
close(fd);
url_change = false;
static inline void __ctsvc_noti_publish_address_change(void)
{
- int fd = open(CTSVC_NOTI_ADDRESS_CHANGED, O_TRUNC | O_RDWR);
+ char *path = ctsvc_inotify_makepath(CTSVC_NOTI_ADDRESS_CHANGED);
+ if (NULL == path) {
+ ERR("ctsvc_inotify_makepath() fail");
+ return;
+ }
+
+ int fd = open(path, O_TRUNC | O_RDWR);
+ free(path);
if (0 <= fd) {
close(fd);
address_change = false;
static inline void __ctsvc_noti_publish_note_change(void)
{
- int fd = open(CTSVC_NOTI_NOTE_CHANGED, O_TRUNC | O_RDWR);
+ char *path = ctsvc_inotify_makepath(CTSVC_NOTI_NOTE_CHANGED);
+ if (NULL == path) {
+ ERR("ctsvc_inotify_makepath() fail");
+ return;
+ }
+
+ int fd = open(path, O_TRUNC | O_RDWR);
+ free(path);
if (0 <= fd) {
close(fd);
note_change = false;
static inline void __ctsvc_noti_publish_company_change(void)
{
- int fd = open(CTSVC_NOTI_COMPANY_CHANGED, O_TRUNC | O_RDWR);
+ char *path = ctsvc_inotify_makepath(CTSVC_NOTI_COMPANY_CHANGED);
+ if (NULL == path) {
+ ERR("ctsvc_inotify_makepath() fail");
+ return;
+ }
+
+ int fd = open(path, O_TRUNC | O_RDWR);
+ free(path);
if (0 <= fd) {
close(fd);
company_change = false;
static inline void __ctsvc_noti_publish_relationship_change(void)
{
- int fd = open(CTSVC_NOTI_RELATIONSHIP_CHANGED, O_TRUNC | O_RDWR);
+ char *path = ctsvc_inotify_makepath(CTSVC_NOTI_RELATIONSHIP_CHANGED);
+ if (NULL == path) {
+ ERR("ctsvc_inotify_makepath() fail");
+ return;
+ }
+
+ int fd = open(path, O_TRUNC | O_RDWR);
+ free(path);
if (0 <= fd) {
close(fd);
relationship_change = false;
static inline void __ctsvc_noti_publish_image_change(void)
{
- int fd = open(CTSVC_NOTI_IMAGE_CHANGED, O_TRUNC | O_RDWR);
+ char *path = ctsvc_inotify_makepath(CTSVC_NOTI_IMAGE_CHANGED);
+ if (NULL == path) {
+ ERR("ctsvc_inotify_makepath() fail");
+ return;
+ }
+
+ int fd = open(path, O_TRUNC | O_RDWR);
+ free(path);
if (0 <= fd) {
close(fd);
image_change = false;
static inline void __ctsvc_noti_publish_nickname_change(void)
{
- int fd = open(CTSVC_NOTI_NICKNAME_CHANGED, O_TRUNC | O_RDWR);
+ char *path = ctsvc_inotify_makepath(CTSVC_NOTI_NICKNAME_CHANGED);
+ if (NULL == path) {
+ ERR("ctsvc_inotify_makepath() fail");
+ return;
+ }
+
+ int fd = open(path, O_TRUNC | O_RDWR);
+ free(path);
if (0 <= fd) {
close(fd);
nickname_change = false;
static inline void __ctsvc_noti_publish_messenger_change(void)
{
- int fd = open(CTSVC_NOTI_MESSENGER_CHANGED, O_TRUNC | O_RDWR);
+ char *path = ctsvc_inotify_makepath(CTSVC_NOTI_MESSENGER_CHANGED);
+ if (NULL == path) {
+ ERR("ctsvc_inotify_makepath() fail");
+ return;
+ }
+
+ int fd = open(path, O_TRUNC | O_RDWR);
+ free(path);
if (0 <= fd) {
close(fd);
messenger_change = false;
static inline void __ctsvc_noti_publish_data_change(void)
{
- int fd = open(CTSVC_NOTI_DATA_CHANGED, O_TRUNC | O_RDWR);
+ char *path = ctsvc_inotify_makepath(CTSVC_NOTI_DATA_CHANGED);
+ if (NULL == path) {
+ ERR("ctsvc_inotify_makepath() fail");
+ return;
+ }
+
+ int fd = open(path, O_TRUNC | O_RDWR);
+ free(path);
if (0 <= fd) {
close(fd);
data_change = false;
static inline void __ctsvc_noti_publish_sdn_change(void)
{
- int fd = open(CTSVC_NOTI_SDN_CHANGED, O_TRUNC | O_RDWR);
+ char *path = ctsvc_inotify_makepath(CTSVC_NOTI_SDN_CHANGED);
+ if (NULL == path) {
+ ERR("ctsvc_inotify_makepath() fail");
+ return;
+ }
+
+ int fd = open(path, O_TRUNC | O_RDWR);
+ free(path);
if (0 <= fd) {
close(fd);
sdn_change = false;
static inline void __ctsvc_noti_publish_profile_change(void)
{
- int fd = open(CTSVC_NOTI_PROFILE_CHANGED, O_TRUNC | O_RDWR);
+ char *path = ctsvc_inotify_makepath(CTSVC_NOTI_PROFILE_CHANGED);
+ if (NULL == path) {
+ ERR("ctsvc_inotify_makepath() fail");
+ return;
+ }
+
+ int fd = open(path, O_TRUNC | O_RDWR);
+ free(path);
if (0 <= fd) {
close(fd);
profile_change = false;
static inline void __ctsvc_noti_publish_activity_change(void)
{
- int fd = open(CTSVC_NOTI_ACTIVITY_CHANGED, O_TRUNC | O_RDWR);
+ char *path = ctsvc_inotify_makepath(CTSVC_NOTI_ACTIVITY_CHANGED);
+ if (NULL == path) {
+ ERR("ctsvc_inotify_makepath() fail");
+ return;
+ }
+
+ int fd = open(path, O_TRUNC | O_RDWR);
+ free(path);
if (0 <= fd) {
close(fd);
activity_change = false;
static inline void __ctsvc_noti_publish_activity_photo_change(void)
{
- int fd = open(CTSVC_NOTI_ACTIVITY_PHOTO_CHANGED, O_TRUNC | O_RDWR);
+ char *path = ctsvc_inotify_makepath(CTSVC_NOTI_ACTIVITY_PHOTO_CHANGED);
+ if (NULL == path) {
+ ERR("ctsvc_inotify_makepath() fail");
+ return;
+ }
+
+ int fd = open(path, O_TRUNC | O_RDWR);
+ free(path);
if (0 <= fd) {
close(fd);
activity_photo_change = false;
static inline void __ctsvc_noti_publish_sip_change(void)
{
- int fd = open(CTSVC_NOTI_SIP_CHANGED, O_TRUNC | O_RDWR);
+ char *path = ctsvc_inotify_makepath(CTSVC_NOTI_SIP_CHANGED);
+ if (NULL == path) {
+ ERR("ctsvc_inotify_makepath() fail");
+ return;
+ }
+
+ int fd = open(path, O_TRUNC | O_RDWR);
+ free(path);
if (0 <= fd) {
close(fd);
sip_change = false;
#include "ctsvc_ipc_server.h"
#include "ctsvc_ipc_server2.h"
#include "ctsvc_notify.h"
+#include "ctsvc_inotify.h"
#define CTSVC_TIMEOUT_FOR_DEFAULT 0
return ctsvc_timeout_sec;
}
-void ctsvc_create_file_set_permission(const char *file, mode_t mode)
+void __ctsvc_create_rep_set_permission(const char *directory, mode_t mode)
+{
+ if (-1 == access(directory, F_OK))
+ mkdir(directory, mode);
+}
+
+void __ctsvc_create_noti_file_set_permission(const char *file, mode_t mode)
{
int fd;
- fd = creat(file, mode);
- if (0 <= fd)
+ char* path = ctsvc_inotify_makepath(file);
+ if (NULL == path) {
+ ERR("ctsvc_inotify_makepath() fail");
+ return;
+ }
+ fd = creat(path, mode);
+ if (0 <= fd) {
close(fd);
+ chmod(path, 0644);
+ }
+ free(path);
}
-void ctsvc_create_rep_set_permission(const char *directory, mode_t mode)
+/*
+void __ctsvc_create_noti_rep_set_permission(mode_t mode)
{
- if (-1 == access(directory, F_OK))
- mkdir(directory, mode);
+ char path[CTSVC_PATH_MAX_LEN] = {0};
+ snprintf(path, CTSVC_PATH_MAX_LEN, CTSVC_NOTI_PATH, getuid());
+
+ if (-1 == access(path, F_OK))
+ mkdir(path, mode);
}
+*/
int main(int argc, char *argv[])
{
ctsvc_server_check_schema();
- ctsvc_create_rep_set_permission(DATA_REPERTORY, 0755);
- ctsvc_create_rep_set_permission(CTSVC_NOTI_REPERTORY, 0775);
- ctsvc_create_rep_set_permission(CTSVC_NOTI_IMG_REPERTORY, 0750);
- ctsvc_create_rep_set_permission(CTSVC_VCARD_IMAGE_LOCATION, 0770);
- ctsvc_create_rep_set_permission(CTS_MY_IMAGE_LOCATION, 0750);
- ctsvc_create_rep_set_permission(CTS_GROUP_IMAGE_LOCATION, 0750);
- ctsvc_create_rep_set_permission(CTS_LOGO_IMAGE_LOCATION, 0750);
- ctsvc_create_rep_set_permission(CTSVC_CONTACT_IMG_FULL_LOCATION, 0750);
-
- ctsvc_create_file_set_permission(CTSVC_NOTI_IPC_READY, 0660);
- ctsvc_create_file_set_permission(CTSVC_NOTI_ADDRESSBOOK_CHANGED, 0660);
- ctsvc_create_file_set_permission(CTSVC_NOTI_GROUP_CHANGED, 0660);
- ctsvc_create_file_set_permission(CTSVC_NOTI_PERSON_CHANGED, 0660);
- ctsvc_create_file_set_permission(CTSVC_NOTI_CONTACT_CHANGED, 0660);
- ctsvc_create_file_set_permission(CTSVC_NOTI_MY_PROFILE_CHANGED, 0660);
- ctsvc_create_file_set_permission(CTSVC_NOTI_NAME_CHANGED, 0660);
- ctsvc_create_file_set_permission(CTSVC_NOTI_NUMBER_CHANGED, 0660);
- ctsvc_create_file_set_permission(CTSVC_NOTI_EMAIL_CHANGED, 0660);
- ctsvc_create_file_set_permission(CTSVC_NOTI_EVENT_CHANGED, 0660);
- ctsvc_create_file_set_permission(CTSVC_NOTI_URL_CHANGED, 0660);
- ctsvc_create_file_set_permission(CTSVC_NOTI_GROUP_RELATION_CHANGED, 0660);
- ctsvc_create_file_set_permission(CTSVC_NOTI_ADDRESS_CHANGED, 0660);
- ctsvc_create_file_set_permission(CTSVC_NOTI_NOTE_CHANGED, 0660);
- ctsvc_create_file_set_permission(CTSVC_NOTI_COMPANY_CHANGED, 0660);
- ctsvc_create_file_set_permission(CTSVC_NOTI_RELATIONSHIP_CHANGED, 0660);
- ctsvc_create_file_set_permission(CTSVC_NOTI_IMAGE_CHANGED, 0660);
- ctsvc_create_file_set_permission(CTSVC_NOTI_NICKNAME_CHANGED, 0660);
- ctsvc_create_file_set_permission(CTSVC_NOTI_MESSENGER_CHANGED, 0660);
- ctsvc_create_file_set_permission(CTSVC_NOTI_DATA_CHANGED, 0660);
- ctsvc_create_file_set_permission(CTSVC_NOTI_SDN_CHANGED, 0660);
- ctsvc_create_file_set_permission(CTSVC_NOTI_PROFILE_CHANGED, 0660);
- ctsvc_create_file_set_permission(CTSVC_NOTI_ACTIVITY_CHANGED, 0660);
- ctsvc_create_file_set_permission(CTSVC_NOTI_ACTIVITY_PHOTO_CHANGED, 0660);
- ctsvc_create_file_set_permission(CTSVC_NOTI_PHONELOG_CHANGED, 0660);
- ctsvc_create_file_set_permission(CTSVC_NOTI_SPEEDDIAL_CHANGED, 0660);
- ctsvc_create_file_set_permission(CTSVC_NOTI_SIP_CHANGED, 0660);
+ __ctsvc_create_rep_set_permission(DATA_REPERTORY, 0755);
+ __ctsvc_create_rep_set_permission(CTSVC_DATA_REPERTORY, 0775);
+ __ctsvc_create_rep_set_permission(CTSVC_IMG_REPERTORY, 0750);
+ __ctsvc_create_rep_set_permission(CTSVC_VCARD_IMAGE_LOCATION, 0770);
+ __ctsvc_create_rep_set_permission(CTS_MY_IMAGE_LOCATION, 0750);
+ __ctsvc_create_rep_set_permission(CTS_GROUP_IMAGE_LOCATION, 0750);
+ __ctsvc_create_rep_set_permission(CTS_LOGO_IMAGE_LOCATION, 0750);
+ __ctsvc_create_rep_set_permission(CTSVC_CONTACT_IMG_FULL_LOCATION, 0750);
+
+ //__ctsvc_create_noti_rep_set_permission(0744);
+ __ctsvc_create_noti_file_set_permission(CTSVC_NOTI_IPC_READY, CTS_SECURITY_DEFAULT_PERMISSION);
+ __ctsvc_create_noti_file_set_permission(CTSVC_NOTI_ADDRESSBOOK_CHANGED, CTS_SECURITY_DEFAULT_PERMISSION);
+ __ctsvc_create_noti_file_set_permission(CTSVC_NOTI_GROUP_CHANGED, CTS_SECURITY_DEFAULT_PERMISSION);
+ __ctsvc_create_noti_file_set_permission(CTSVC_NOTI_PERSON_CHANGED, CTS_SECURITY_DEFAULT_PERMISSION);
+ __ctsvc_create_noti_file_set_permission(CTSVC_NOTI_CONTACT_CHANGED, CTS_SECURITY_DEFAULT_PERMISSION);
+ __ctsvc_create_noti_file_set_permission(CTSVC_NOTI_MY_PROFILE_CHANGED, CTS_SECURITY_DEFAULT_PERMISSION);
+ __ctsvc_create_noti_file_set_permission(CTSVC_NOTI_NAME_CHANGED, CTS_SECURITY_DEFAULT_PERMISSION);
+ __ctsvc_create_noti_file_set_permission(CTSVC_NOTI_NUMBER_CHANGED, CTS_SECURITY_DEFAULT_PERMISSION);
+ __ctsvc_create_noti_file_set_permission(CTSVC_NOTI_EMAIL_CHANGED, CTS_SECURITY_DEFAULT_PERMISSION);
+ __ctsvc_create_noti_file_set_permission(CTSVC_NOTI_EVENT_CHANGED, CTS_SECURITY_DEFAULT_PERMISSION);
+ __ctsvc_create_noti_file_set_permission(CTSVC_NOTI_URL_CHANGED, CTS_SECURITY_DEFAULT_PERMISSION);
+ __ctsvc_create_noti_file_set_permission(CTSVC_NOTI_GROUP_RELATION_CHANGED, CTS_SECURITY_DEFAULT_PERMISSION);
+ __ctsvc_create_noti_file_set_permission(CTSVC_NOTI_ADDRESS_CHANGED, CTS_SECURITY_DEFAULT_PERMISSION);
+ __ctsvc_create_noti_file_set_permission(CTSVC_NOTI_NOTE_CHANGED, CTS_SECURITY_DEFAULT_PERMISSION);
+ __ctsvc_create_noti_file_set_permission(CTSVC_NOTI_COMPANY_CHANGED, CTS_SECURITY_DEFAULT_PERMISSION);
+ __ctsvc_create_noti_file_set_permission(CTSVC_NOTI_RELATIONSHIP_CHANGED, CTS_SECURITY_DEFAULT_PERMISSION);
+ __ctsvc_create_noti_file_set_permission(CTSVC_NOTI_IMAGE_CHANGED, CTS_SECURITY_DEFAULT_PERMISSION);
+ __ctsvc_create_noti_file_set_permission(CTSVC_NOTI_NICKNAME_CHANGED, CTS_SECURITY_DEFAULT_PERMISSION);
+ __ctsvc_create_noti_file_set_permission(CTSVC_NOTI_MESSENGER_CHANGED, CTS_SECURITY_DEFAULT_PERMISSION);
+ __ctsvc_create_noti_file_set_permission(CTSVC_NOTI_DATA_CHANGED, CTS_SECURITY_DEFAULT_PERMISSION);
+ __ctsvc_create_noti_file_set_permission(CTSVC_NOTI_SDN_CHANGED, CTS_SECURITY_DEFAULT_PERMISSION);
+ __ctsvc_create_noti_file_set_permission(CTSVC_NOTI_PROFILE_CHANGED, CTS_SECURITY_DEFAULT_PERMISSION);
+ __ctsvc_create_noti_file_set_permission(CTSVC_NOTI_ACTIVITY_CHANGED, CTS_SECURITY_DEFAULT_PERMISSION);
+ __ctsvc_create_noti_file_set_permission(CTSVC_NOTI_ACTIVITY_PHOTO_CHANGED, CTS_SECURITY_DEFAULT_PERMISSION);
+ __ctsvc_create_noti_file_set_permission(CTSVC_NOTI_PHONELOG_CHANGED, CTS_SECURITY_DEFAULT_PERMISSION);
+ __ctsvc_create_noti_file_set_permission(CTSVC_NOTI_SPEEDDIAL_CHANGED, CTS_SECURITY_DEFAULT_PERMISSION);
+ __ctsvc_create_noti_file_set_permission(CTSVC_NOTI_SIP_CHANGED, CTS_SECURITY_DEFAULT_PERMISSION);
/* update DB for compatability */
ctsvc_server_db_update();
#include "ctsvc_db_schema.h"
#include "ctsvc_db_sqlite.h"
#include "ctsvc_notify.h"
+#include "ctsvc_inotify.h"
#include "ctsvc_server_setting.h"
#include "ctsvc_normalize.h"
#include "ctsvc_localize.h"
ret = ctsvc_server_end_trans(true);
if (CONTACTS_ERROR_NONE == ret) {
int fd;
- fd = open(CTSVC_NOTI_CONTACT_CHANGED, O_TRUNC | O_RDWR);
- if (0 <= fd)
- close(fd);
- fd = open(CTSVC_NOTI_PERSON_CHANGED, O_TRUNC | O_RDWR);
- if (0 <= fd)
- close(fd);
+ char *path = ctsvc_inotify_makepath(CTSVC_NOTI_CONTACT_CHANGED);
+ if (NULL != path) {
+ fd = open(path, O_TRUNC | O_RDWR);
+ if (0 <= fd)
+ close(fd);
+ } else {
+ ERR("ctsvc_inotify_makepath() fail");
+ }
+ free(path);
+
+ path = ctsvc_inotify_makepath(CTSVC_NOTI_PERSON_CHANGED);
+ if (NULL != path) {
+ fd = open(path, O_TRUNC | O_RDWR);
+ if (0 <= fd)
+ close(fd);
+ } else {
+ ERR("ctsvc_inotify_makepath() fail");
+ }
+ free(path);
}
ctsvc_server_db_close();
ret = ctsvc_server_end_trans(true);
if (CONTACTS_ERROR_NONE == ret) {
int fd;
- fd = open(CTSVC_NOTI_CONTACT_CHANGED, O_TRUNC | O_RDWR);
- if (0 <= fd)
- close(fd);
- fd = open(CTSVC_NOTI_PERSON_CHANGED, O_TRUNC | O_RDWR);
- if (0 <= fd)
- close(fd);
+ char *path = ctsvc_inotify_makepath(CTSVC_NOTI_CONTACT_CHANGED);
+ if (NULL != path) {
+ fd = open(path, O_TRUNC | O_RDWR);
+ if (0 <= fd)
+ close(fd);
+ } else {
+ ERR("ctsvc_inotify_makepath() fail");
+ }
+ free(path);
+
+ path = ctsvc_inotify_makepath(CTSVC_NOTI_PERSON_CHANGED);
+ if (NULL != path) {
+ fd = open(path, O_TRUNC | O_RDWR);
+ if (0 <= fd)
+ close(fd);
+ } else {
+ ERR("ctsvc_inotify_makepath() fail");
+ }
+ free(path);
}
} else {
ctsvc_server_end_trans(false);
struct statfs buf;
long long size;
- ret = statfs(CTSVC_NOTI_IMG_REPERTORY, &buf);
+ ret = statfs(CTSVC_IMG_REPERTORY, &buf);
RETVM_IF(ret != 0, false, "statfs() Fail(%d)", ret);
size = (long long)buf.f_bavail * (buf.f_bsize);