Modified flushing memory logic
[platform/core/appfw/app-core.git] / include / appcore_base.h
1 /*
2  * Copyright (c) 2016 Samsung Electronics Co., Ltd. All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17 #pragma once
18
19 #include <stdbool.h>
20 #include <libintl.h>
21 #include <bundle.h>
22 #include <aul.h>
23
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27
28 enum appcore_base_rm {
29         APPCORE_BASE_RM_UNKNOWN,
30         APPCORE_BASE_RM_PORTRAIT_NORMAL,
31         APPCORE_BASE_RM_PORTRAIT_REVERSE,
32         APPCORE_BASE_RM_LANDSCAPE_NORMAL,
33         APPCORE_BASE_RM_LANDSCAPE_REVERSE,
34 };
35
36 enum appcore_base_event {
37         APPCORE_BASE_EVENT_START,
38         APPCORE_BASE_EVENT_LOW_MEMORY,
39         APPCORE_BASE_EVENT_LOW_BATTERY,
40         APPCORE_BASE_EVENT_LANG_CHANGE,
41         APPCORE_BASE_EVENT_DEVICE_ORIENTATION_CHANGED,
42         APPCORE_BASE_EVENT_REGION_CHANGE,
43         APPCORE_BASE_EVENT_SUSPENDED_STATE_CHANGE,
44         APPCORE_BASE_EVENT_UPDATE_REQUESTED,
45         APPCORE_BASE_EVENT_MAX,
46 };
47
48 enum appcore_base_suspended_state {
49         APPCORE_BASE_SUSPENDED_STATE_WILL_ENTER_SUSPEND = 0,
50         APPCORE_BASE_SUSPENDED_STATE_DID_EXIT_FROM_SUSPEND
51 };
52
53
54 typedef int (*appcore_base_event_cb)(void *event, void *data);
55 typedef void *appcore_base_event_h;
56
57 typedef struct _appcore_base_ops {
58         int (*create) (void *data);
59         int (*terminate) (void *data);
60         int (*control) (bundle *b, void *data);
61         int (*receive)(aul_type type, bundle *b, void *data);
62         int (*set_i18n)(void *data);
63         void (*init)(int argc, char **argv, void *data);
64         void (*finish)(void);
65         void (*run)(void *data);
66         void (*exit)(void *data);
67         void (*set_event)(enum appcore_base_event event, void *data);
68         void (*unset_event)(enum appcore_base_event event, void *data);
69         void (*trim_memory)(void *data);
70 } appcore_base_ops;
71
72 int appcore_base_on_receive(aul_type type, bundle *b);
73 int appcore_base_on_create(void);
74 int appcore_base_on_control(bundle *b);
75 int appcore_base_on_terminate(void);
76 int appcore_base_on_set_i18n(void);
77 void appcore_base_on_set_event(enum appcore_base_event event);
78 void appcore_base_on_unset_event(enum appcore_base_event event);
79 int appcore_base_on_trim_memory(void);
80 int appcore_base_init(appcore_base_ops ops, int argc, char **argv, void *data);
81 void appcore_base_fini(void);
82 appcore_base_ops appcore_base_get_default_ops(void);
83 appcore_base_event_h appcore_base_add_event(enum appcore_base_event event,
84                 appcore_base_event_cb cb, void *data);
85 int appcore_base_remove_event(appcore_base_event_h handle);
86 int appcore_base_raise_event(void *event, enum appcore_base_event type);
87 int appcore_base_flush_memory(void);
88 int appcore_base_get_rotation_state(enum appcore_base_rm *curr);
89 bool appcore_base_is_bg_allowed(void);
90 bool appcore_base_is_suspended(void);
91 void appcore_base_toggle_suspended_state(void);
92 int appcore_base_set_i18n(const char *domain_name, const char *dir_name);
93 void appcore_base_exit(void);
94 void appcore_base_add_suspend_timer(void);
95 void appcore_base_remove_suspend_timer(void);
96
97 #ifdef __cplusplus
98 }
99 #endif
100
101