vconf: add debug message about type mismatch 96/201996/16
authorMaciej Slodczyk <m.slodczyk2@partner.samsung.com>
Thu, 21 Mar 2019 11:12:08 +0000 (12:12 +0100)
committerMaciej Slodczyk <m.slodczyk2@partner.samsung.com>
Tue, 26 Mar 2019 15:58:36 +0000 (15:58 +0000)
Change-Id: Ied0cd7e0e0a00ac2b933c6065f85cac7398f7429
Signed-off-by: Maciej Slodczyk <m.slodczyk2@partner.samsung.com>
src/decision_makers/activation_dm.c

index fcccecacf962b1fa45b00b223d6034e8cc998287..1d2327f9fde8ef008b538d51739abee187f7bb97 100644 (file)
@@ -47,6 +47,22 @@ struct rule {
        struct list_head node;
 };
 
+static const char *vkc_type_to_string(enum vkc_type t)
+{
+       switch (t) {
+       case VKC_BOOL:
+               return "bool";
+       case VKC_INT:
+               return "int";
+       case VKC_DOUBLE:
+               return "double";
+       case VKC_STRING:
+               return "string";
+       default:
+               return "unknown";
+       }
+}
+
 static int activation_event_match(struct epc_event_handler *handler,
                struct epc_event *ev)
 {
@@ -59,7 +75,7 @@ static int activation_event_match(struct epc_event_handler *handler,
 static int vconf_field_cmp(struct vkc_value *a, struct vkc_value *b)
 {
        if (a->type != b->type)
-               return 0;
+               return -1;
 
        switch (a->type){
        case VKC_BOOL:
@@ -77,15 +93,36 @@ static int vconf_rule_match(struct rule *r, struct epc_event *event)
 {
        struct vconf_key_changed_event *ev = to_vconf_key_changed_event(event);
        struct vconf_key_changed_event_data *ev_data = r->ev_data;
+       int ret;
 
        if (ev_data->key_name && strcmp(ev_data->key_name, ev->key_name))
                return 0;
 
-       if (r->match_oldval && !vconf_field_cmp(&ev_data->oldval, &ev->oldval))
-               return 0;
+       if (r->match_oldval) {
+               ret = vconf_field_cmp(&ev_data->oldval, &ev->oldval);
+               if (ret < 0) {
+                       log_error("vconf type mismatch - oldval for key %s: %s instead of %s",
+                                       ev_data->key_name,
+                                       vkc_type_to_string(ev->oldval.type),
+                                       vkc_type_to_string(ev_data->oldval.type));
+               }
 
-       if (r->match_newval && !vconf_field_cmp(&ev_data->newval, &ev->newval))
-               return 0;
+               if (ret <= 0)
+                       return 0;
+       }
+
+       if (r->match_newval) {
+               ret = vconf_field_cmp(&ev_data->newval, &ev->newval);
+               if (ret < 0) {
+                       log_error("vconf type mismatch - newval for key %s: %s instead of %s",
+                                       ev_data->key_name,
+                                       vkc_type_to_string(ev->newval.type),
+                                       vkc_type_to_string(ev_data->newval.type));
+               }
+
+               if (ret <= 0)
+                       return 0;
+       }
 
        return 1;
 }