diff options
author | Paweł Szewczyk <p.szewczyk@samsung.com> | 2019-02-25 16:05:19 +0100 |
---|---|---|
committer | Maciej Slodczyk <m.slodczyk2@partner.samsung.com> | 2019-03-22 16:45:02 +0100 |
commit | a8b2bd84bfda64b09e9c0fca728a2dddff624e42 (patch) | |
tree | e0a9dbca62de4100dfa3062bbb34be5f95371310 | |
parent | 5cf94cd3ef5e7fd330ab6dc29b8b9e4e4f70f925 (diff) | |
download | activationd-a8b2bd84bfda64b09e9c0fca728a2dddff624e42.tar.gz activationd-a8b2bd84bfda64b09e9c0fca728a2dddff624e42.tar.bz2 activationd-a8b2bd84bfda64b09e9c0fca728a2dddff624e42.zip |
add basic vconf listener
Change-Id: I473018b09ecbc9bdec8fbdbe9b64071bff544541
Signed-off-by: Maciej Slodczyk <m.slodczyk2@partner.samsung.com>
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | activationd/Makefile.am | 49 | ||||
-rw-r--r-- | activationd/event_types/vconf_key_changed_event.c | 193 | ||||
-rw-r--r-- | activationd/include/vconf_key_changed_event.h | 66 | ||||
-rw-r--r-- | activationd/listeners/vconf.c | 322 | ||||
-rw-r--r-- | configure.ac | 10 | ||||
-rw-r--r-- | include/common.h | 28 | ||||
-rw-r--r-- | modules.conf.d/vconf_listener.conf.d/50-default.conf | 3 | ||||
-rw-r--r-- | packaging/activationd.spec | 17 | ||||
-rw-r--r-- | src/epc.c | 2 | ||||
-rw-r--r-- | src/util/common.c | 4 |
11 files changed, 693 insertions, 3 deletions
diff --git a/Makefile.am b/Makefile.am index 004ce9f..2f985a6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -139,3 +139,5 @@ install-data-local: $(MKDIR_P) $(DESTDIR)$(pkglibdir)/available-modules $(MKDIR_P) $(DESTDIR)$(sysconfdir)/epc/available-modules $(MKDIR_P) $(DESTDIR)$(sysconfdir)/epc/enabled-modules + +SUBDIRS = activationd diff --git a/activationd/Makefile.am b/activationd/Makefile.am new file mode 100644 index 0000000..f2fea38 --- /dev/null +++ b/activationd/Makefile.am @@ -0,0 +1,49 @@ +AM_LDFLAGS = $(VCONF_LIBS) \ + -Wl,--gc-sections \ + -Wl,--as-needed \ + -avoid-version \ + -module \ + -shared \ + -pie + +AM_CPPFLAGS = -I${top_srcdir}/include \ + -I${top_srcdir}/activationd/include + +basetarget = $(basename $(notdir $@)) +modname = $(basetarget) +name_fix = $(subst $(comma),_,$(subst -,_,$1)) + +AM_CFLAGS = \ + -Wall \ + -Wchar-subscripts \ + -Wformat-security \ + -Wmissing-declarations \ + -Wmissing-prototypes \ + -Wnested-externs \ + -Wpointer-arith \ + -Wshadow \ + -Wsign-compare \ + -Wstrict-prototypes \ + -Wtype-limits \ + -D_GNU_SOURCE=1 \ + -fPIE \ + -rdynamic \ + $(GLIB_CFLAGS) \ + $(VCONF_CFLAGS) \ + -D"EPC_MODNAME_T=$(call name_fix,$(modname))" + +modulesdir = $(pkglibdir)/available-modules +modules_LTLIBRARIES = \ + vconf_key_changed_event.la \ + vconf_listener.la + +vconf_key_changed_event_la_SOURCES = event_types/vconf_key_changed_event.c +vconf_listener_la_SOURCES = listeners/vconf.c +vconf_listener_config_DATA = ../modules.conf.d/vconf_listener.conf.d/50-default.conf +vconf_listener_configdir = $(modulesconfigdir)/vconf_listener.conf.d + +configdir = $(prefix)/lib/epc +modulesconfigdir = $(configdir)/modules.conf.d + +install-data-local: + $(MKDIR_P) $(DESTDIR)${vconf_listener_configdir} diff --git a/activationd/event_types/vconf_key_changed_event.c b/activationd/event_types/vconf_key_changed_event.c new file mode 100644 index 0000000..be87016 --- /dev/null +++ b/activationd/event_types/vconf_key_changed_event.c @@ -0,0 +1,193 @@ +/* + * This file is part of epc. + * + * Copyright © 2019 Samsung Electronics + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <stdio.h> +#include <errno.h> +#include <malloc.h> + +#include "vconf_key_changed_event.h" + +static int allocate_vkc_event(struct epc_event_type *type, + void *data, struct epc_event **ev) +{ + struct vconf_key_changed_event *vkc_ev; + struct vconf_key_changed_event_data *vkc_ev_data = data; + int ret; + + vkc_ev = calloc(1, sizeof(*vkc_ev)); + if (!vkc_ev) + return -ENOMEM; + + ret = epc_event_init_internal(type, &vkc_ev->event); + if (ret) + goto cleanup; + + vkc_ev->event_time = vkc_ev_data->event_time; + vkc_ev->key_name = vkc_ev_data->key_name; + vkc_ev->oldval = vkc_ev_data->oldval; + vkc_ev->newval = vkc_ev_data->newval; + + *ev = &vkc_ev->event; + return 0; +cleanup: + free(vkc_ev); + + return ret; +} + +static int deserialize_vkc_event(struct epc_event_type *type, + struct epc_object *data, struct epc_event **ev) +{ + int ret = -EINVAL; + struct vconf_key_changed_event_data vkc_ev_data; + struct epc_object *obj; + memset(&vkc_ev_data, 0, sizeof(vkc_ev_data)); + + list_for_each_entry(obj, &data->val.children, node) { + const bool oldval_match = !strcmp(VKC_EV_OLDVAL, obj->key); + const bool newval_match = !strcmp(VKC_EV_NEWVAL, obj->key); + + switch (obj->type) { + case TYPE_TIME_T: + if (!strcmp(VKC_EV_TIME, obj->key)) + vkc_ev_data.event_time = obj->val.time; + break; + case TYPE_BOOL: + if (oldval_match) { + vkc_ev_data.oldval.value.b = obj->val.b; + vkc_ev_data.oldval.type = VKC_BOOL; + } else if (newval_match) { + vkc_ev_data.newval.value.b = obj->val.b; + vkc_ev_data.newval.type = VKC_BOOL; + } + break; + case TYPE_INT: + if (oldval_match) { + vkc_ev_data.oldval.value.i = obj->val.i; + vkc_ev_data.oldval.type = VKC_INT; + } else if (newval_match) { + vkc_ev_data.newval.value.i = obj->val.i; + vkc_ev_data.newval.type = VKC_INT; + } + break; + case TYPE_DOUBLE: + if (oldval_match) { + vkc_ev_data.oldval.value.d = obj->val.d; + vkc_ev_data.oldval.type = VKC_DOUBLE; + } else if (newval_match) { + vkc_ev_data.newval.value.d = obj->val.d; + vkc_ev_data.newval.type = VKC_DOUBLE; + } + break; + case TYPE_STRING: + if (!strcmp(VKC_EV_NAME, obj->key)) { + vkc_ev_data.key_name = obj->val.s; + } else if (oldval_match) { + vkc_ev_data.oldval.value.s = obj->val.s; + vkc_ev_data.oldval.type = VKC_STRING; + } else if (newval_match) { + vkc_ev_data.newval.value.s = obj->val.s; + vkc_ev_data.newval.type = VKC_STRING; + } + break; + } + } + + ret = allocate_vkc_event(type, &vkc_ev_data, ev); + if (ret < 0) + goto finish; + + ret = epc_event_deserialize_internal(data, type, *ev); + if (ret < 0) { + struct vconf_key_changed_event *vkc_ev = + to_vconf_key_changed_event(*ev); + free(vkc_ev); + goto finish; + } + ret = 0; +finish: + return ret; +} + +static void vkc_event_release(struct epc_event *ev) +{ + struct vconf_key_changed_event *vkc_ev = + to_vconf_key_changed_event(ev); + + if (vkc_ev->key_name) + free(vkc_ev->key_name); + if (vkc_ev->oldval.type == VKC_STRING) + free(vkc_ev->oldval.value.s); + if (vkc_ev->newval.type == VKC_STRING) + free(vkc_ev->newval.value.s); + + epc_event_cleanup_internal(&vkc_ev->event); + free(vkc_ev); +} + +static void vkc_event_serialize(struct epc_event *ev, struct epc_object *out) +{ + struct vconf_key_changed_event *vkc_ev = + to_vconf_key_changed_event(ev); + epc_event_serialize_internal(ev, out); + epc_object_append_string(out, VKC_EV_NAME, vkc_ev->key_name); + + switch (vkc_ev->oldval.type) { + case VKC_BOOL: + epc_object_append_bool(out, VKC_EV_OLDVAL, vkc_ev->oldval.value.b); + break; + case VKC_INT: + epc_object_append_int(out, VKC_EV_OLDVAL, vkc_ev->oldval.value.i); + break; + case VKC_DOUBLE: + epc_object_append_double(out, VKC_EV_OLDVAL, vkc_ev->oldval.value.d); + break; + case VKC_STRING: + epc_object_append_string(out, VKC_EV_OLDVAL, vkc_ev->oldval.value.s); + break; + } + + switch (vkc_ev->newval.type) { + case VKC_BOOL: + epc_object_append_bool(out, VKC_EV_NEWVAL, vkc_ev->newval.value.b); + break; + case VKC_INT: + epc_object_append_int(out, VKC_EV_NEWVAL, vkc_ev->newval.value.i); + break; + case VKC_DOUBLE: + epc_object_append_double(out, VKC_EV_NEWVAL, vkc_ev->newval.value.d); + break; + case VKC_STRING: + epc_object_append_string(out, VKC_EV_NEWVAL, vkc_ev->newval.value.s); + break; + } + epc_object_append_time_t(out, VKC_EV_TIME, vkc_ev->event_time); +} + +static struct epc_event_type vconf_key_changed_event_type = { + .name = VCONF_KEY_CHANGED_EVENT_ID, + .default_ops = { + .release = vkc_event_release, + .serialize = vkc_event_serialize, + }, + .allocate_event = allocate_vkc_event, + .deserialize_event = deserialize_vkc_event, + .node = LIST_HEAD_INIT(vconf_key_changed_event_type.node), +}; + +EPC_EVENT_TYPE_REGISTER(vconf_key_changed_event_type, vconf_key_changed_et) diff --git a/activationd/include/vconf_key_changed_event.h b/activationd/include/vconf_key_changed_event.h new file mode 100644 index 0000000..62f1708 --- /dev/null +++ b/activationd/include/vconf_key_changed_event.h @@ -0,0 +1,66 @@ +/* + * This file is a part of epc. + * + * Copyright © 2019 Samsung Electronics + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef _EPC_VCONF_KEY_CHANGED_EVENT_H +#define _EPC_VCONF_KEY_CHANGED_EVENT_H + +#include <time.h> +#include "event.h" + +#define VCONF_KEY_CHANGED_EVENT_ID "vconf_key_changed" +#define VKC_EV_TIME "et" +#define VKC_EV_NAME "name" +#define VKC_EV_OLDVAL "oldval" +#define VKC_EV_NEWVAL "newval" + +enum vkc_type { + VKC_BOOL, + VKC_INT, + VKC_DOUBLE, + VKC_STRING +}; + +struct vkc_value { + enum vkc_type type; + union { + bool b; + int i; + double d; + char *s; + } value; +}; + +struct vconf_key_changed_event { + struct epc_event event; + char *key_name; + struct vkc_value oldval; + struct vkc_value newval; + time_t event_time; +}; + +struct vconf_key_changed_event_data { + char *key_name; + struct vkc_value oldval; + struct vkc_value newval; + time_t event_time; +}; + +#define to_vconf_key_changed_event(EVENT) \ + container_of(EVENT, struct vconf_key_changed_event, event) + +#endif /* _EPC_VCONF_KEY_CHANGED_EVENT_H */ diff --git a/activationd/listeners/vconf.c b/activationd/listeners/vconf.c new file mode 100644 index 0000000..0ab8925 --- /dev/null +++ b/activationd/listeners/vconf.c @@ -0,0 +1,322 @@ +/* + * This file is part of epc. + * + * Copyright © 2019 Samsung Electronics + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include <vconf.h> +#include <glib.h> +#include <time.h> + +#include "log.h" +#include "module.h" +#include "common.h" +#include "list.h" +#include "json-config.h" +#include "event_processor.h" +#include "vconf_key_changed_event.h" + +struct vconf_kv { + char *name; + struct vkc_value val; + struct list_head node; +}; + +struct vconf_listener { + struct epc_module module; + struct list_head keys; +}; + +#define to_vconf_listener(MOD) \ + container_of(MOD, struct vconf_listener, module) + +static struct vconf_kv *find_vconf_kv(struct vconf_listener *l, const char *name) +{ + struct vconf_kv *k = NULL; + + list_for_each_entry(k, &l->keys, node) { + if (!strcmp(k->name, name)) + return k; + } + return NULL; +} + +static int copy_vkc_value(struct vkc_value *from, struct vkc_value *to) +{ + to->type = from->type; + switch (from->type){ + case VKC_BOOL: + to->value.b = from->value.b; + break; + case VKC_INT: + to->value.i = from->value.i; + break; + case VKC_DOUBLE: + to->value.d = from->value.d; + break; + case VKC_STRING: + to->value.s = strdup(from->value.s); + if (!to->value.s) + return -ENOMEM; + break; + } + return 0; +} + +static int set_object_value(struct vconf_kv *k, keynode_t *node) +{ + assert (k); + assert (node); + int ret = 0; + + switch(vconf_keynode_get_type(node)) { + case VCONF_TYPE_INT:{ + int value = vconf_keynode_get_int(node); + k->val.value.i = value; + k->val.type = VKC_INT; + }break; + case VCONF_TYPE_BOOL:{ + int value = vconf_keynode_get_bool(node); + if (value == -1) { + ret = -1; + break; + } + k->val.value.b = value; + k->val.type = VKC_BOOL; + }break; + case VCONF_TYPE_DOUBLE:{ + double value = vconf_keynode_get_dbl(node); + k->val.value.d = value; + k->val.type = VKC_DOUBLE; + }break; + case VCONF_TYPE_STRING:{ + char *value = vconf_keynode_get_str(node); + if (!value) { + ret = -1; + break; + } + k->val.value.s = strdup(value); + if (!k->val.value.s) + return -1; + k->val.type = VKC_STRING; + }break; + default: + ret = -1; + break; + } + + return ret; +} + +static void on_vconf_key_changed(keynode_t *key, void *data) +{ + struct vconf_listener *l = (struct vconf_listener *)data; + char *name = NULL; + struct vconf_key_changed_event_data vkc_ev_data = {}; + struct epc_event *ev; + struct timespec ts; + int ret = 0; + + if (clock_gettime(CLOCK_MONOTONIC, &ts) < 0) { + log_error_errno(errno, "Unable to get timestamp : %m"); + return; + } + + name = vconf_keynode_get_name(key); + if (!name) { + log_debug("vconf: key name not found (key=%s)", name); + return; + } + + struct vconf_kv *k = find_vconf_kv(l, name); + if (!k) { + log_debug("vconf: key-value pair not found (key=%s)", name); + return; + } + + vkc_ev_data.event_time = ts.tv_sec; + vkc_ev_data.key_name = strdup(name); + if (vkc_ev_data.key_name == NULL) + goto finish; + + if (copy_vkc_value(&k->val, &vkc_ev_data.oldval) < 0) + goto finish; + + if (k->val.type == VKC_STRING) { + free(k->val.value.s); + k->val.value.s = NULL; + } + + if (set_object_value(k, key) < 0) + goto finish; + + if (copy_vkc_value(&k->val, &vkc_ev_data.newval) < 0) + goto finish; + + ret = epc_event_create(VCONF_KEY_CHANGED_EVENT_ID, &vkc_ev_data, &ev); + if (ret) { + log_error_errno(ret, "Unable to allocate an event: %m."); + goto finish; + } + + ret = event_processor_report_event(ev); + epc_event_unref(ev); + if (ret) + log_error_errno(ret, "Unable to report event: %m"); + return; +finish: + free(vkc_ev_data.key_name); + if (vkc_ev_data.oldval.type == VKC_STRING) + free(vkc_ev_data.oldval.value.s); + if (vkc_ev_data.newval.type == VKC_STRING) + free(vkc_ev_data.newval.value.s); + + return; +} + +static int add_key(struct vconf_listener *l, const char *key, keynode_t *node) +{ + int ret = 0; + struct vconf_kv *k; + + assert (l); + assert (key); + //assert (node); /* it's ok to be null */ + + k = (struct vconf_kv*)malloc(sizeof(struct vconf_kv)); + if (k == NULL) { + ret = -ENOMEM; + goto cleanup; + } + + k->name = strdup(key); + if (k->name == NULL) { + ret = -ENOMEM; + goto cleanup; + } + + if (node != NULL && set_object_value(k, node) < 0) { + ret = -EINVAL; + goto cleanup; + } + + list_add_tail(&k->node, &l->keys); + vconf_notify_key_changed(key, on_vconf_key_changed, l); + return 0; + +cleanup: + if (k) { + free(k->name); + free(k); + } + return ret; +} + +static void cleanup(struct vconf_listener *l) +{ + struct vconf_kv *k, *next; + + list_for_each_entry_safe(k, next, &l->keys, node) { + list_del(&k->node); + free(k->name); + if (k->val.type == VKC_STRING) + free(k->val.value.s); + free(k); + } +} + +static int vconf_listener_init(struct epc_module *module, + struct epc_config *config, + sd_event* event) +{ + struct vconf_listener *listener = to_vconf_listener(module); + int ret = 0; + json_object *arr, *val; + keylist_t *klist; + keynode_t *knode; + + INIT_LIST_HEAD(&listener->keys); + + if (!json_object_object_get_ex(config->root, "keys", &arr)) { + log_error("Config does not contain 'keys' parameter."); + ret = -EINVAL; + goto cleanup; + } + + if (!json_object_is_type(arr, json_type_array)) { + log_error("Config value is not an array"); + ret = -EINVAL; + goto cleanup; + } + + for (size_t i = 0; i < json_object_array_length(arr); i++) { + knode = NULL; + val = json_object_array_get_idx(arr, i); + if (val == NULL) { + log_error("vconf: no specified key (%zu)\n", i); + ret = -EINVAL; + goto cleanup; + } + + klist = vconf_keylist_new(); + if (!klist) { + log_error("vconf: could not create keylist for %s\n", json_object_get_string(val)); + continue; + } + + ret = vconf_get(klist, json_object_get_string(val), VCONF_GET_ALL); + if (ret < 0) { + log_debug("vconf: keylist does not contain key %s\n", json_object_get_string(val)); + goto free_list; + } + + ret = vconf_keylist_lookup(klist, json_object_get_string(val), &knode); + if (ret <= 0) { + log_debug("vconf_keylist_lookup failed for %s\n", json_object_get_string(val)); + //goto free_list; + } + + ret = add_key(listener, json_object_get_string(val), knode); + if (ret < 0) + log_error("vconf: could not add key\n"); + + free_list: + vconf_keylist_free(klist); + } + return 0; + +cleanup: + cleanup(listener); + return ret; +} + +static void vconf_listener_cleanup(struct epc_module *module) +{ + struct vconf_listener *listener = to_vconf_listener(module); + cleanup(listener); +} + +struct vconf_listener vconf_listener = { + .module = { + .name = "vconf_listener", + .type = EPC_MODULE_TYPE_LISTENER, + + .init = vconf_listener_init, + .cleanup = vconf_listener_cleanup, + .node = LIST_HEAD_INIT(vconf_listener.module.node), + }, +}; + +EPC_MODULE_REGISTER(&vconf_listener.module) diff --git a/configure.ac b/configure.ac index 0ecdff9..70a5b56 100644 --- a/configure.ac +++ b/configure.ac @@ -125,13 +125,20 @@ PKG_CHECK_MODULES(JSON_C, AS_IF([test "x$have_json_c" = "xno"], AC_MSG_ERROR([json-c not found])) +PKG_CHECK_MODULES(VCONF, + [vconf], + have_vconf=yes, + have_vconf=no) +AS_IF([test "x$have_vconf" = "xno"], + AC_MSG_ERROR([vconf not found])) + AC_CHECK_FUNCS([ \ printf\ ]) AC_CONFIG_HEADERS(config.h) AC_CONFIG_FILES([ - Makefile + Makefile activationd/Makefile ]) LT_INIT @@ -151,6 +158,7 @@ AC_MSG_RESULT([ libsystemd: ${have_libsystemd} glib ${have_glib} + vconf ${have_vconf} modules: ${ENABLED_MODULES/ /} ]) diff --git a/include/common.h b/include/common.h index 0817a6d..b905f20 100644 --- a/include/common.h +++ b/include/common.h @@ -76,6 +76,8 @@ enum epc_object_type { TYPE_INT, TYPE_TIMESPEC, TYPE_TIME_T, + TYPE_BOOL, + TYPE_DOUBLE, TYPE_UUID, TYPE_OBJECT, }; @@ -103,6 +105,8 @@ union epc_object_value { int i; struct timespec ts; time_t time; + bool b; + double d; sd_id128_t uuid; struct list_head children; }; @@ -163,6 +167,18 @@ static inline int epc_object_append_int(struct epc_object *obj, return epc_object_append_new(obj, key, TYPE_INT, &val); } +static inline int epc_object_append_bool(struct epc_object *obj, + const char *key, bool val) +{ + return epc_object_append_new(obj, key, TYPE_BOOL, &val); +} + +static inline int epc_object_append_double(struct epc_object *obj, + const char *key, double val) +{ + return epc_object_append_new(obj, key, TYPE_DOUBLE, &val); +} + static inline int epc_object_append_time_t(struct epc_object *obj, const char *key, time_t val) { @@ -192,6 +208,18 @@ static inline int epc_object_get_string(struct epc_object *obj, return epc_object_get_val(obj, key, TYPE_STRING, val); } +static inline int epc_object_get_double(struct epc_object *obj, + const char *key, double *val) +{ + return epc_object_get_val(obj, key, TYPE_DOUBLE, val); +} + +static inline int epc_object_get_bool(struct epc_object *obj, + const char *key, bool *val) +{ + return epc_object_get_val(obj, key, TYPE_BOOL, val); +} + static inline int epc_object_get_oid(struct epc_object *obj, const char *key, epc_oid_t *val) { diff --git a/modules.conf.d/vconf_listener.conf.d/50-default.conf b/modules.conf.d/vconf_listener.conf.d/50-default.conf new file mode 100644 index 0000000..9d8f09c --- /dev/null +++ b/modules.conf.d/vconf_listener.conf.d/50-default.conf @@ -0,0 +1,3 @@ +{ + "keys":[ "db/test/key1", "db/test/key2", "db/test/key3" ] +} diff --git a/packaging/activationd.spec b/packaging/activationd.spec index 3fe1504..88763a3 100644 --- a/packaging/activationd.spec +++ b/packaging/activationd.spec @@ -7,7 +7,9 @@ Source1001: %{name}.manifest Summary: Event-based activation daemon Group: System/Monitoring -%define with_activationd_glib_support 0 +%define with_activationd_glib_support 1 + +BuildRequires: pkgconfig(vconf) %description Activationd allows starting systemd units based on various system events. @@ -88,8 +90,19 @@ do echo %{enabled_moduledir}/${mod}.so >> extra-files; done -%files +for mod in vconf_listener \ + vconf_key_changed_event +do + ln -s %{moduledir}/${mod}.so %{buildroot}/%{moduleconfdir}/${mod}.so; + ln -s ../available-modules/${mod}.so %{buildroot}/%{enabled_moduledir}/${mod}.so; + echo %{moduledir}/${mod}.so >> activationd-files; + echo %{moduleconfdir}/${mod}.so >> activationd-files; + echo %{enabled_moduledir}/${mod}.so >> activationd-files; +done + +%files -f activationd-files %license COPYING +%{_prefix}/lib/epc/modules.conf.d/vconf_listener.conf.d/50-default.conf %files -n event-processing-core -f epc-files %license COPYING @@ -36,6 +36,8 @@ #include "json-config.h" #include "database.h" +#define EPC_GLIB_MAINLOOP + static int terminate = 0; enum epc_running_modes { diff --git a/src/util/common.c b/src/util/common.c index 0d9d431..7bb175d 100644 --- a/src/util/common.c +++ b/src/util/common.c @@ -47,6 +47,8 @@ static const size_t data_size[] = { [TYPE_INT] = sizeof(int), [TYPE_TIMESPEC] = sizeof(struct timespec), [TYPE_TIME_T] = sizeof(time_t), + [TYPE_BOOL] = sizeof(bool), + [TYPE_DOUBLE] = sizeof(double), [TYPE_UUID] = sizeof(sd_id128_t), [TYPE_OBJECT] = sizeof(struct list_head), }; @@ -57,6 +59,8 @@ static char *epc_object_type_names[] = { [TYPE_INT] = "TYPE_INT", [TYPE_TIMESPEC] = "TYPE_TIMESPEC", [TYPE_TIME_T] = "TYPE_TIME_T", + [TYPE_BOOL] = "TYPE_BOOL", + [TYPE_DOUBLE] = "TYPE_DOUBLE", [TYPE_UUID] = "TYPE_UUID", [TYPE_OBJECT] = "TYPE_OBJECT", }; |