Release version 1.9.12
[platform/core/appfw/app-core.git] / include / appcore-internal.h
1 /*
2  *  app-core
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
5  *
6  * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  *
20  */
21
22
23
24 #ifndef __APPCORE_INTERNAL_H__
25 #define __APPCORE_INTERNAL_H__
26
27 #define LOG_TAG "APP_CORE"
28
29 #include <stdio.h>
30 #include <stdbool.h>
31 #include <dlog.h>
32 #include "appcore-common.h"
33
34
35 #ifndef EXPORT_API
36 #  define EXPORT_API __attribute__ ((visibility("default")))
37 #endif
38
39 #ifndef _DLOG_H_
40 #define _ERR(fmt, arg...) fprintf(stderr, "appcore: "fmt"\n", ##arg)
41 #define _INFO(fmt, arg...) fprintf(stdout, fmt"\n", ##arg)
42 #define _DBG(fmt, arg...) \
43         do { \
44                 if (getenv("APPCORE_DEBUG")) { \
45                         fprintf(stdout, fmt"\n", ##arg); \
46                 } \
47         } while (0)
48 #else
49 #define _ERR(fmt, arg...) LOGE(fmt, ##arg)
50 #define _INFO(...) LOGI(__VA_ARGS__)
51 #define _DBG(...) LOGD(__VA_ARGS__)
52 #endif
53
54 #define _warn_if(expr, fmt, arg...) do { \
55                 if (expr) { \
56                         _ERR(fmt, ##arg); \
57                 } \
58         } while (0)
59
60 #define _ret_if(expr) do { \
61                 if (expr) { \
62                         return; \
63                 } \
64         } while (0)
65
66 #define _retv_if(expr, val) do { \
67                 if (expr) { \
68                         return (val); \
69                 } \
70         } while (0)
71
72 #define _retm_if(expr, fmt, arg...) do { \
73                 if (expr) { \
74                         _ERR(fmt, ##arg); \
75                         return; \
76                 } \
77         } while (0)
78
79 #define _retvm_if(expr, val, fmt, arg...) do { \
80                 if (expr) { \
81                         _ERR(fmt, ##arg); \
82                         return (val); \
83                 } \
84         } while (0)
85
86 /**
87  * Appcore internal state
88  */
89 enum app_state {
90         AS_NONE,
91         AS_CREATED,
92         AS_RUNNING,
93         AS_PAUSED,
94         AS_DYING,
95 };
96
97 /**
98  * Appcore internal event
99  */
100 enum app_event {
101         AE_UNKNOWN,
102         AE_CREATE,
103         AE_TERMINATE,
104         AE_TERMINATE_BGAPP,
105         AE_PAUSE,
106         AE_RESUME,
107         AE_RAISE,
108         AE_LOWER,
109         AE_RESET,
110         AE_LOWMEM_POST,
111         AE_MEM_FLUSH,
112         AE_UPDATE_REQUESTED,
113         AE_MAX
114 };
115
116 /**
117  * Appcore internal system event
118  */
119 enum sys_event {
120         SE_UNKNOWN,
121         SE_LOWMEM,
122         SE_LOWBAT,
123         SE_LANGCHG,
124         SE_REGIONCHG,
125         SE_SUSPENDED_STATE,
126         SE_UPDATE_REQUESTED,
127         SE_MAX
128 };
129
130 /**
131  * Appcore system event operation
132  */
133 struct sys_op {
134         int (*func) (void *, void *);
135         void *data;
136 };
137
138 /**
139  * Appcore internal structure
140  */
141 struct appcore {
142         int state;
143         unsigned int tid;
144         bool suspended_state;
145         bool allowed_bg;
146
147         const struct ui_ops *ops;
148         struct sys_op sops[SE_MAX];
149 };
150
151 /**
152  * Appcore UI operation
153  */
154 struct ui_ops {
155         void *data;
156         void (*cb_app) (enum app_event evnt, void *data, bundle *b);
157 };
158
159 struct ui_wm_rotate {
160         int (*set_rotation_cb) (int (*cb)(void *event_info, enum appcore_rm, void *), void *data);
161         int (*unset_rotation_cb) (void);
162         int (*get_rotation_state) (enum appcore_rm *curr);
163         int (*pause_rotation_cb) (void);
164         int (*resume_rotation_cb) (void);
165 };
166 void appcore_group_attach();
167 void appcore_group_lower();
168 unsigned int appcore_get_main_window(void);
169 unsigned int appcore_get_main_surface(void);
170
171 #define ENV_START "APP_START_TIME"
172
173 #endif                          /* __APPCORE_INTERNAL_H__ */