Add DD_LIST_FOREACH_SAFE function
[platform/core/system/libsvi.git] / src / common.h
1 /*
2  * libfeedback
3  * Copyright (c) 2012 Samsung Electronics Co., Ltd.
4  *
5  * Licensed under the Apache License, Version 2.0 (the License);
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18
19 #ifndef __COMMON_H__
20 #define __COMMON_H__
21
22 #include <stdbool.h>
23 #include <errno.h>
24 #include <mm_sound_private.h>
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 /**
31  * @file common.h
32  * @brief This file contains the common information
33  */
34
35 #ifndef __CONSTRUCTOR__
36 #define __CONSTRUCTOR__ __attribute__ ((constructor))
37 #endif
38
39 #ifndef __DESTRUCTOR__
40 #define __DESTRUCTOR__ __attribute__ ((destructor))
41 #endif
42
43 #ifndef __DD_LIST__
44 #define __DD_LIST__
45 #include <glib.h>
46 typedef GList dd_list;
47 #define DD_LIST_PREPEND(a, b)       \
48         a = g_list_prepend(a, b)
49 #define DD_LIST_APPEND(a, b)        \
50         a = g_list_append(a, b)
51 #define DD_LIST_REMOVE(a, b)        \
52         a = g_list_remove(a, b)
53 #define DD_LIST_FOREACH(head, elem, node)   \
54         for (elem = head; elem && ((node = elem->data) != NULL); elem = elem->next, node = NULL)
55 #define DD_LIST_FOREACH_SAFE(head, elem, elem_next, node)       \
56     for (elem = head, elem_next=g_list_next(elem), node = NULL; \
57             elem && ((node = elem->data) != NULL);      \
58             elem = elem_next, elem_next = g_list_next(elem), node=NULL)
59 #endif
60
61 #define FEEDBACK_DATA_DIR                       FEEDBACK_SYS_SHARE"/feedback"
62 #define FEEDBACK_ORIGIN_DATA_DIR        FEEDBACK_SYS_RO_SHARE"/feedback"
63
64 #define FEEDBACK_RETRY_CNT       1
65
66 #define DEFAULT_VIB_LEVEL       3
67 #define HAPTIC_FEEDBACK_STEP    20 /**< feedback max / slider step */
68
69 #define ARR_SIZE(arr) (sizeof(arr)/sizeof((arr)[0]))
70 #define FEEDBACK_LEVEL(x)   ((x)? ((x/2)+1): 0)
71
72 int is_sound_mode(void);
73 int is_touch_sndstatus(void);
74 int is_keytone_sndstatus(void);
75 int is_vibration_mode(void);
76
77 #ifdef __cplusplus
78 }
79 #endif
80
81 #endif