low-memory: send low-memory event to eventsystem 67/56567/1
authorChulHo Song <ch81.song@samsung.com>
Thu, 24 Sep 2015 08:22:10 +0000 (17:22 +0900)
committerChulHo Song <ch81.song@samsung.com>
Mon, 11 Jan 2016 08:21:08 +0000 (17:21 +0900)
Conflicts:
src/msgproc_vconf.cpp

Change-Id: I45ce9179c88f1c5e52c773146c1442f218e7e35a
Signed-off-by: ChulHo Song <ch81.song@samsung.com>
(cherry picked from commit 1810d82ece73fe711892f41974738b8989bc8007)

CMakeLists.txt
packaging/emuld.spec
src/msgproc_vconf.cpp

index e4c9355dc41ae37b013963e41760f1eaef59bc42..4f143a6edc03e91b2e6c0d0a4c0ea0fb89d23e5e 100644 (file)
@@ -93,6 +93,7 @@ SET(PKG_MODULE
     ecore
     edbus
     capi-network-connection
+    eventsystem
 )
 
 pkg_check_modules(PKGS REQUIRED ${PKG_MODULE})
index c113fad7e8f9f8dbfaa7a861faa6fd60ec2b1dfc..5bc605131dfae97ef45891cb72b3a86f1ceab2f5 100644 (file)
@@ -14,6 +14,7 @@ BuildRequires: pkgconfig(glib-2.0)
 BuildRequires: pkgconfig(edbus)
 BuildRequires: pkgconfig(ecore)
 BuildRequires: pkgconfig(capi-network-connection)
+BuildRequires: pkgconfig(eventsystem)
 
 %description
 A emulator daemon is used for communication between guest and host
index 826851617908079db6017d22de2b8a910d738ea1..40c596aac367f779baa0c57423d88994044e2ed1 100644 (file)
@@ -30,6 +30,9 @@
 
 #include <stdio.h>
 #include "emuld.h"
+#include <bundle.h>
+#include <eventsystem.h>
+#include <vconf-internal-sysman-keys.h>
 
 static void* get_vconf_value(void* data)
 {
@@ -63,6 +66,7 @@ static void* set_vconf_value(void* data)
     pthread_detach(pthread_self());
 
     vconf_res_type *vrt = (vconf_res_type*)data;
+    int val = -1;
 
     if (!check_possible_vconf_key(vrt->vconf_key)) {
         LOGERR("%s is not available key.");
@@ -88,7 +92,7 @@ static void* set_vconf_value(void* data)
 
         /* TODO: to be implemented another type */
         if (vrt->vconf_type == VCONF_TYPE_INT) {
-            int val = atoi(vrt->vconf_val);
+            val = atoi(vrt->vconf_val);
             vconf_set_int(vrt->vconf_key, val);
             LOGDEBUG("key: %s, val: %d", vrt->vconf_key, val);
         } else if (vrt->vconf_type == VCONF_TYPE_DOUBLE) {
@@ -102,8 +106,37 @@ static void* set_vconf_value(void* data)
         } else {
             LOGERR("undefined vconf type");
         }
-    }
 
+        /* Low memory event */
+        if (!strcmp(vrt->vconf_key, VCONF_LOW_MEMORY))
+        {
+            bundle* b = bundle_create();
+            if (!b) {
+                LOGWARN("failed to create bundle");
+                goto out;
+            }
+            switch (val)
+            {
+                case VCONFKEY_SYSMAN_LOW_MEMORY_NORMAL:
+                    bundle_add_str(b, EVT_KEY_LOW_MEMORY, EVT_VAL_MEMORY_NORMAL);
+                    eventsystem_send_system_event(SYS_EVENT_LOW_MEMORY, b);
+                    break;
+                case VCONFKEY_SYSMAN_LOW_MEMORY_SOFT_WARNING:
+                    bundle_add_str(b, EVT_KEY_LOW_MEMORY, EVT_VAL_MEMORY_SOFT_WARNING);
+                    eventsystem_send_system_event(SYS_EVENT_LOW_MEMORY, b);
+                    break;
+                case VCONFKEY_SYSMAN_LOW_MEMORY_HARD_WARNING:
+                    bundle_add_str(b, EVT_KEY_LOW_MEMORY, EVT_VAL_MEMORY_HARD_WARNING);
+                    eventsystem_send_system_event(SYS_EVENT_LOW_MEMORY, b);
+                    break;
+                default:
+                    LOGWARN("undefined low memory value(%d)", val);
+                    break;
+            }
+            bundle_free(b);
+        }
+    }
+out:
     free(vrt->vconf_key);
     free(vrt->vconf_val);
     free(vrt);