tizen 2.3 release
[framework/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 <dlog.h>
31 #include "appcore-common.h"
32
33
34 #ifndef EXPORT_API
35 #  define EXPORT_API __attribute__ ((visibility("default")))
36 #endif
37
38 #  define _ERR(fmt, arg...) LOGE(fmt, ##arg)
39 #  define _INFO(...) LOGI(__VA_ARGS__)
40 #  define _DBG(...) LOGD(__VA_ARGS__)
41
42 #define _warn_if(expr, fmt, arg...) do { \
43                 if (expr) { \
44                         _ERR(fmt, ##arg); \
45                 } \
46         } while (0)
47
48 #define _ret_if(expr) do { \
49                 if (expr) { \
50                         return; \
51                 } \
52         } while (0)
53
54 #define _retv_if(expr, val) do { \
55                 if (expr) { \
56                         return (val); \
57                 } \
58         } while (0)
59
60 #define _retm_if(expr, fmt, arg...) do { \
61                 if (expr) { \
62                         _ERR(fmt, ##arg); \
63                         return; \
64                 } \
65         } while (0)
66
67 #define _retvm_if(expr, val, fmt, arg...) do { \
68                 if (expr) { \
69                         _ERR(fmt, ##arg); \
70                         return (val); \
71                 } \
72         } while (0)
73
74 #define goto_if(expr, val) do { \
75                         if(expr) { \
76                                 _ERR("(%s) -> goto", #expr); \
77                                 goto val; \
78                         } \
79                 } while (0)
80
81 #define break_if(expr) { \
82                         if(expr) { \
83                                 _ERR("(%s) -> break", #expr); \
84                                 break; \
85                         } \
86                 }
87
88 #define continue_if(expr) { \
89                         if(expr) { \
90                                 _ERR("(%s) -> continue", #expr); \
91                                 continue; \
92                         } \
93                 }
94
95 /**
96  * Appcore internal state
97  */
98 enum app_state {
99         AS_NONE,
100         AS_CREATED,
101         AS_RUNNING,
102         AS_PAUSED,
103         AS_DYING,
104 };
105
106 /**
107  * Appcore internal event
108  */
109 enum app_event {
110         AE_UNKNOWN,
111         AE_CREATE,
112         AE_TERMINATE,
113         AE_PAUSE,
114         AE_RESUME,
115         AE_RESET,
116         AE_LOWMEM_POST,
117         AE_MEM_FLUSH,
118         AE_MAX
119 };
120
121 /**
122  * Appcore internal system event
123  */
124 enum sys_event {
125         SE_UNKNOWN,
126         SE_LOWMEM,
127         SE_LOWBAT,
128         SE_LANGCHG,
129         SE_REGIONCHG,
130         SE_MAX
131 };
132
133 /**
134  * Appcore system event operation
135  */
136 struct sys_op {
137         int (*func) (void *, void *);
138         void *data;
139 };
140
141 /**
142  * Appcore internal structure
143  */
144 struct appcore {
145         int state;
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 /* appcore-i18n.c */
160 extern void update_lang(void);
161 extern int set_i18n(const char *domainname, const char *dirname);
162 void update_region(void);
163
164
165 /* appcore-X.c */
166 extern int x_raise_win(pid_t pid);
167
168 /* appcore-util.c */
169 /* extern void stack_trim(void);*/
170
171 int appcore_pause_rotation_cb(void);
172 int appcore_resume_rotation_cb(void);
173
174 struct ui_wm_rotate {
175    int (*set_rotation_cb) (int (*cb) (void *event_info, enum appcore_rm, void *), void *data);
176    int (*unset_rotation_cb) (void);
177    int (*get_rotation_state) (enum appcore_rm *curr);
178    int (*pause_rotation_cb) (void);
179    int (*resume_rotation_cb) (void);
180 };
181 int appcore_set_wm_rotation(struct ui_wm_rotate* wm_rotate);
182
183 #define ENV_START "APP_START_TIME"
184
185 #define MEMORY_FLUSH_ACTIVATE
186
187 #define APPID_MAX 256
188
189 #endif                          /* __APPCORE_INTERNAL_H__ */