#define EPC_AD_UNIT_NAME "UnitName"
#define EPC_AD_UNIT_ACTION "UnitAction"
-int epc_fill_for_srv_restart(struct epc_object *obj, char *service_path);
+int epc_fill_for_srv_restart(struct epc_object *obj, const char *service_path);
-int epc_fill_for_srv_recover(struct epc_object *obj, char *service_path, char *recovery);
+int epc_fill_for_srv_recover(struct epc_object *obj, const char *service_path, const char *recovery);
-int epc_fill_for_unit_start(struct epc_object *obj, char *unit_path);
-int epc_fill_for_unit_action(struct epc_object *obj, char *action);
+int epc_fill_for_unit_start(struct epc_object *obj, const char *unit_path);
+int epc_fill_for_unit_action(struct epc_object *obj, const char *action);
#define epc_fill_for_reboot(o) \
epc_object_fill_empty(o)
#include "log.h"
#include "action.h"
-int epc_fill_for_srv_restart(struct epc_object *obj, char *service_path)
+int epc_fill_for_srv_restart(struct epc_object *obj, const char *service_path)
{
int ret;
return 0;
}
-int epc_fill_for_srv_recover(struct epc_object *obj, char *service_path, char *recovery)
+int epc_fill_for_srv_recover(struct epc_object *obj, const char *service_path, const char *recovery)
{
int ret;
return 0;
}
-int epc_fill_for_unit_start(struct epc_object *obj, char *unit_path)
+int epc_fill_for_unit_start(struct epc_object *obj, const char *unit_path)
{
int ret;
return 0;
}
-int epc_fill_for_unit_action(struct epc_object *obj, char *unit_action)
+int epc_fill_for_unit_action(struct epc_object *obj, const char *unit_action)
{
int ret;
#include "json-config.h"
#include "vconf_key_changed_event.h"
+#include "dbus_signal_event.h"
#define MODULE_NAME "activation_decision_maker"
struct list_head rules;
};
+enum rule_type {
+ RULE_TYPE_VCONF,
+ RULE_TYPE_DBUS
+};
+
struct rule {
const char *event;
+ enum rule_type type;
void *ev_data;
bool match_oldval;
bool match_newval;
const char *action;
const char *target;
+ struct json_object *match;
struct list_head node;
};
static int activation_event_match(struct epc_event_handler *handler,
struct epc_event *ev)
{
- if (strcmp(ev->type->name, VCONF_KEY_CHANGED_EVENT_ID) == 0)
+ if (strcmp(ev->type->name, VCONF_KEY_CHANGED_EVENT_ID) == 0 ||
+ strcmp (ev->type->name, DBUS_SIGNAL_EVENT_ID) == 0)
return 1;
return 0;
case VKC_STRING:
return strcmp(a->value.s, b->value.s) == 0;
}
+ return 0;
}
static int vconf_rule_match(struct rule *r, struct epc_event *event)
return 1;
}
+static int dbus_rule_match(struct rule *r, struct epc_event *event)
+{
+ struct dbus_signal_event *ev = to_dbus_signal_event(event);
+ struct dbus_signal_event_data *ev_data = r->ev_data;
+
+ if (ev_data->event_id && strcmp(ev_data->event_id, ev->event_id))
+ return 0;
+
+ if (ev->params && r->match && !epc_object_match_pattern(ev->params, r->match))
+ return 0;
+
+ return 1;
+}
+
+
static int execute_rule(struct rule *r, struct epc_event *ev)
{
struct dm_event_data ev_data = {
if (strcmp(r->event, ev->type->name))
continue;
- if (!strcmp(ev->type->name, VCONF_KEY_CHANGED_EVENT_ID) == 0 ||
- !vconf_rule_match(r, ev))
+ if ((!strcmp(ev->type->name, VCONF_KEY_CHANGED_EVENT_ID) == 0 ||
+ (r->type == RULE_TYPE_VCONF && !vconf_rule_match(r, ev))) &&
+ (!strcmp(ev->type->name, DBUS_SIGNAL_EVENT_ID) == 0 ||
+ (r->type == RULE_TYPE_DBUS && !dbus_rule_match(r, ev))))
continue;
ret = execute_rule(r, ev);
{
struct json_object *node = NULL;
enum json_type type;
- char *str;
+ const char *str;
if (!json_object_object_get_ex(root, key, &node)) {
log_debug("Config does not contain %s parameter", key);
r->match_newval = ret >= 0;
r->ev_data = evd;
+ r->type = RULE_TYPE_VCONF;
+ return 0;
+}
+
+static int parse_dbus_data(json_object *root, struct rule *r)
+{
+ struct dbus_signal_event_data *evd;
+
+ evd = calloc(1, sizeof(*evd));
+ if (!evd)
+ return -ENOMEM;
+
+ r->match = NULL;
+ (void) get_config_field(root, "id", &evd->event_id, json_type_string);
+ (void) get_config_field(root, "match", &r->match, json_type_object);
+
+ r->ev_data = evd;
+ r->type = RULE_TYPE_DBUS;
return 0;
}
{
int ret;
struct rule *r;
- char *str;
r = calloc(1, sizeof(*r));
if (!r) {
if (strcmp(r->event, VCONF_KEY_CHANGED_EVENT_ID) == 0) {
parse_vconf_data(root, r);
+ } else if (strcmp(r->event, DBUS_SIGNAL_EVENT_ID) == 0) {
+ parse_dbus_data(root, r);
} else {
log_warning("Event type %s is not supported by activationd module\n", r->event);
goto out;
struct activation_decision_maker, eh);
clean_rules(dm);
+ return 0;
}
static struct activation_decision_maker activation_dm = {