summaryrefslogtreecommitdiff
path: root/include/appcore-internal.h
blob: f16c2144e143364dcfaf86826ffb6aebd21e3709 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
/*
 *  app-core
 *
 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
 *
 * Contact: Jayoun Lee <airjany@samsung.com>, Sewook Park <sewook7.park@samsung.com>, Jaeho Lee <jaeho81.lee@samsung.com>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */



#ifndef __APPCORE_INTERNAL_H__
#define __APPCORE_INTERNAL_H__

#define LOG_TAG "APP_CORE"

#include <stdio.h>
#include <stdbool.h>
#include <dlog.h>
#include "appcore-common.h"


#ifndef EXPORT_API
#  define EXPORT_API __attribute__ ((visibility("default")))
#endif

#ifndef _DLOG_H_
#  define _ERR(fmt, arg...) \
	do { fprintf(stderr, "appcore: "fmt"\n", ##arg); } while (0)

#  define _INFO(fmt, arg...) \
	do { fprintf(stdout, fmt"\n", ##arg); } while (0)

#  define _DBG(fmt, arg...) \
	do { \
		if (getenv("APPCORE_DEBUG")) { \
			fprintf(stdout,	fmt"\n", ##arg); \
		} \
	} while (0)
#else
#  define _ERR(fmt, arg...) \
	do { \
		fprintf(stderr, "appcore: "fmt"\n", ##arg); \
		LOGE(fmt, ##arg); \
	} while (0)
#  define _INFO(...) LOGI(__VA_ARGS__)
#  define _DBG(...) LOGD(__VA_ARGS__)
#endif

#define _warn_if(expr, fmt, arg...) do { \
		if (expr) { \
			_ERR(fmt, ##arg); \
		} \
	} while (0)

#define _ret_if(expr) do { \
		if (expr) { \
			return; \
		} \
	} while (0)

#define _retv_if(expr, val) do { \
		if (expr) { \
			return (val); \
		} \
	} while (0)

#define _retm_if(expr, fmt, arg...) do { \
		if (expr) { \
			_ERR(fmt, ##arg); \
			return; \
		} \
	} while (0)

#define _retvm_if(expr, val, fmt, arg...) do { \
		if (expr) { \
			_ERR(fmt, ##arg); \
			return (val); \
		} \
	} while (0)

/**
 * Appcore internal state
 */
enum app_state {
	AS_NONE,
	AS_CREATED,
	AS_RUNNING,
	AS_PAUSED,
	AS_DYING,
};

/**
 * Appcore internal event
 */
enum app_event {
	AE_UNKNOWN,
	AE_CREATE,
	AE_TERMINATE,
	AE_TERMINATE_BGAPP,
	AE_PAUSE,
	AE_RESUME,
	AE_RAISE,
	AE_LOWER,
	AE_RESET,
	AE_LOWMEM_POST,
	AE_MEM_FLUSH,
	AE_MAX
};

/**
 * Appcore internal system event
 */
enum sys_event {
	SE_UNKNOWN,
	SE_LOWMEM,
	SE_LOWBAT,
	SE_LANGCHG,
	SE_REGIONCHG,
	SE_SUSPENDED_STATE,
	SE_MAX
};

/**
 * Appcore system event operation
 */
struct sys_op {
	int (*func) (void *, void *);
	void *data;
};

/**
 * Appcore internal structure
 */
struct appcore {
	int state;
	unsigned int tid;
	bool suspended_state;
	bool allowed_bg;

	const struct ui_ops *ops;
	struct sys_op sops[SE_MAX];
};

/**
 * Appcore UI operation
 */
struct ui_ops {
	void *data;
	void (*cb_app) (enum app_event evnt, void *data, bundle *b);
};

/* appcore-i18n.c */
extern void update_lang(void);
extern int set_i18n(const char *domainname, const char *dirname);
void update_region(void);


/* appcore-X.c */
extern int x_raise_win(pid_t pid);
extern int x_pause_win(pid_t pid);

/* appcore-util.c */
/* extern void stack_trim(void);*/

int appcore_pause_rotation_cb(void);
int appcore_resume_rotation_cb(void);

struct ui_wm_rotate {
	int (*set_rotation_cb) (int (*cb)(void *event_info, enum appcore_rm, void *), void *data);
	int (*unset_rotation_cb) (void);
	int (*get_rotation_state) (enum appcore_rm *curr);
	int (*pause_rotation_cb) (void);
	int (*resume_rotation_cb) (void);
};
int appcore_set_wm_rotation(struct ui_wm_rotate* wm_rotate);

void appcore_group_attach();
void appcore_group_lower();
unsigned int appcore_get_main_window(void);
#if defined(WAYLAND)
unsigned int appcore_get_main_surface(void);
#endif
void appcore_get_app_core(struct appcore **ac);

#define ENV_START "APP_START_TIME"

#define MEMORY_FLUSH_ACTIVATE

#endif				/* __APPCORE_INTERNAL_H__ */