Add a handler to avoid using invalid handle
[platform/core/appfw/app-core.git] / src / base / appcore_base.c
index 348f500..47527a0 100644 (file)
@@ -266,7 +266,7 @@ static void __on_low_memory(keynode_t *key, void *data)
        val = vconf_keynode_get_int(key);
 
        if (val >= VCONFKEY_SYSMAN_LOW_MEMORY_SOFT_WARNING) {
-               __invoke_callback(key, APPCORE_BASE_EVENT_LOW_MEMORY);
+               __invoke_callback(&val, APPCORE_BASE_EVENT_LOW_MEMORY);
                malloc_trim(0);
        }
 }
@@ -278,7 +278,7 @@ static void __on_low_battery(keynode_t *key, void *data)
        val = vconf_keynode_get_int(key);
 
        if (val <= VCONFKEY_SYSMAN_BAT_CRITICAL_LOW)
-               __invoke_callback(key, APPCORE_BASE_EVENT_LOW_BATTERY);
+               __invoke_callback(&val, APPCORE_BASE_EVENT_LOW_BATTERY);
 }
 
 static void __destroy_lang_info(gpointer data)
@@ -622,7 +622,7 @@ static void __on_region_change(keynode_t *key, void *data)
        const char *name;
 
        name = vconf_keynode_get_name(key);
-       if (!strcmp(name, VCONFKEY_REGIONFORMAT))
+       if (name && !strcmp(name, VCONFKEY_REGIONFORMAT))
                val = vconf_keynode_get_str(key);
 
        __update_region();
@@ -849,6 +849,11 @@ EXPORT_API int appcore_base_on_set_i18n(void)
        return 0;
 }
 
+EXPORT_API int appcore_base_set_i18n(const char *domain_name, const char *dir_name)
+{
+       return __set_i18n(domain_name, dir_name);
+}
+
 EXPORT_API int appcore_base_init(appcore_base_ops ops, int argc, char **argv, void *data)
 {
        int i;
@@ -1129,6 +1134,9 @@ EXPORT_API int appcore_base_remove_event(appcore_base_event_h handle)
        appcore_base_event_node *node = handle;
        enum appcore_base_event event;
 
+       if (!node || !g_list_find(__events, node))
+               return -1;
+
        event = node->type;
        __events = g_list_remove(__events, node);
        free(node);
@@ -1148,6 +1156,13 @@ EXPORT_API int appcore_base_raise_event(void *event, enum appcore_base_event typ
 
 EXPORT_API int appcore_base_get_rotation_state(enum appcore_base_rm *curr)
 {
+       if (curr == NULL)
+               return -1;
+
+       if (!__rotation.ref)
+               return -1;
+
+       *curr = __rotation.rm;
        return 0;
 }