}
n->wd = t->wd;
- n->keyname = strndup(t->keyname, BUF_LEN);
+ n->keyname = strndup(t->keyname, VCONF_KEY_PATH_LEN);
n->cb_data = t->cb_data;
n->cb = t->cb;
struct inotify_event ie;
GList *l_notilist = NULL;
- INFO("vconf noti function");
+ //INFO("vconf noti function");
fd = g_io_channel_unix_get_fd(src);
r = read(fd, &ie, sizeof(ie));
while (r > 0) {
- INFO("read event from GIOChannel. pid : %d", getpid());
+ //INFO("read event from GIOChannel. pid : %d", getpid());
- pthread_mutex_lock(&_kdb_g_ns_mutex);
- l_notilist = _vconf_copy_noti_list(g_notilist);
- pthread_mutex_unlock(&_kdb_g_ns_mutex);
+ if (ie.mask & INOTY_EVENT_MASK) {
+ pthread_mutex_lock(&_kdb_g_ns_mutex);
+ l_notilist = _vconf_copy_noti_list(g_notilist);
+ pthread_mutex_unlock(&_kdb_g_ns_mutex);
- if (l_notilist) {
+ if (l_notilist) {
- struct noti_node *t = NULL;
- GList *noti_list = NULL;
- keynode_t* keynode = NULL;
+ struct noti_node *t = NULL;
+ GList *noti_list = NULL;
- retvm_if(!(ie.mask & INOTY_EVENT_MASK), TRUE,
- "Invalid argument: ie.mask(%d), ie.len(%d)",
- ie.mask, ie.len);
+ noti_list = g_list_first(l_notilist);
- noti_list = g_list_first(l_notilist);
+ while (noti_list) {
+ t = noti_list->data;
- while (noti_list) {
- t = noti_list->data;
-
- keynode_t* keynode = _vconf_keynode_new();
- retvm_if(keynode == NULL, TRUE, "key malloc fail");
+ keynode_t* keynode = _vconf_keynode_new();
+ if (keynode == NULL) {
+ ERR("key malloc fail");
+ break;
+ }
- if( (t) && (t->wd == ie.wd) ) {
- if ((ie.mask & IN_DELETE_SELF)) {
- INFO("Notify that key(%s) is deleted", t->keyname);
- _vconf_keynode_set_keyname(keynode, (const char *)t->keyname);
- _vconf_keynode_set_null(keynode);
- t->cb(keynode, t->cb_data);
- _vconf_kdb_del_notify(t->keyname, t->cb);
- } else {
- _vconf_keynode_set_keyname(keynode, t->keyname);
- _vconf_get_key(keynode);
- t->cb(keynode, t->cb_data);
+ if( (t) && (t->wd == ie.wd) ) {
+ if ((ie.mask & IN_DELETE_SELF)) {
+ INFO("Notify that key(%s) is deleted", t->keyname);
+ _vconf_keynode_set_keyname(keynode, (const char *)t->keyname);
+ _vconf_keynode_set_null(keynode);
+ t->cb(keynode, t->cb_data);
+ _vconf_kdb_del_notify(t->keyname, t->cb);
+ } else {
+ _vconf_keynode_set_keyname(keynode, t->keyname);
+ _vconf_get_key(keynode);
+ INFO("key(%s) is changed. cb(%p) called", t->keyname, t->cb);
+ t->cb(keynode, t->cb_data);
+ }
}
- }
- _vconf_keynode_free(keynode);
+ _vconf_keynode_free(keynode);
- noti_list = g_list_next(noti_list);
- }
+ noti_list = g_list_next(noti_list);
+ }
- _vconf_free_noti_list(l_notilist);
+ _vconf_free_noti_list(l_notilist);
+ }
}
if (ie.len > 0)
int
_vconf_kdb_add_notify(const char *keyname, vconf_callback_fn cb, void *data)
{
- char path[KEY_PATH];
- int wd, r;
+ char path[VCONF_KEY_PATH_LEN];
+ int wd;
struct noti_node t, *n;
char err_buf[ERR_LEN] = { 0, };
int ret = 0;
}
n->wd = wd;
- n->keyname = strndup(keyname, BUF_LEN);
+ n->keyname = strndup(keyname, VCONF_KEY_PATH_LEN);
n->cb_data = data;
n->cb = cb;
int r = 0;
struct noti_node *n = NULL;
struct noti_node t;
- char path[KEY_PATH] = { 0, };
+ char path[VCONF_KEY_PATH_LEN] = { 0, };
char err_buf[ERR_LEN] = { 0, };
int del = 0;
- int remain = 0;
int ret = 0;
int func_ret = VCONF_OK;
GList *noti_list;