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