Tizen 2.1 base
[platform/core/system/sync-agent.git] / src / framework / event / config.h
1 /*
2  * sync-agent
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 #ifndef CONFIG_H_
19 #define CONFIG_H_
20
21 #include "event/error.h"
22 #include "event/handler.h"
23 #include "event/ui_api.h"
24 #include "event/spec.h"
25
26 /**
27  * @file        Event_Config.h
28  * @brief       Event/Notification Configuration Manager
29  */
30
31 /** @addtogroup event
32  *      @{
33  */
34
35 #define EVENT_COMMUNICATION_PATH_EVENT          "/tmp/agent_fw_event_"
36 #define EVENT_REPLY_COMMUNICATION_PATH_EVENT    "/tmp/agent_fw_event_reply_"
37 #define EVENT_COMMUNICATION_PATH_NOTI   "/tmp/agent_fw_noti_"
38 #define EVENT_REPLY_COMMUNICATION_PATH_NOTI     "/tmp/agent_fw_noti_reply_"
39
40 #define EVENT_MAX_STREAM_SIZE 102400
41
42 /**
43  * @brief       Get real notification socket path file from noti_key (Agent -> UI)
44  * @param[in]   noti_key notification key string
45  * @return      Operation result
46  * @retval      notification socket path success
47  * @retval      NULL error
48  */
49 const char *event_get_noti_path(const char *noti_key);
50
51 /**
52  * @brief Get real event socket path file (UI -> Agent)
53  * @return Operation result
54  * @retval event socket path success
55  * @retval NULL error
56  */
57 const char *event_get_event_path();
58
59 /**
60  * @brief       Load to memory event specification from event specification file
61  * @param[in]   event_key event key string
62  * @param[in]   config_file event specification file
63  * @return Operation result
64  * @retval SYNC_AGENT_EVENT_SUCCESS     success
65  * @retval SYNC_AGENT_EVENT_FAIL error
66  */
67 sync_agent_event_error_e event_set_event_spec_from_config_file(const char *event_key, const char *config_file);
68
69 /**
70  * @brief       Free event specification from memory
71  * @return Operation result
72  * @retval SYNC_AGENT_EVENT_SUCCESS success
73  * @retval SYNC_AGENT_EVENT_FAIL error
74  */
75 sync_agent_event_error_e event_clean_event_spec();
76
77 /**
78  * @brief       Load to memory notification specification from notification specification file
79  * @param[in] noti_key notification key string
80  * @param[in]   config_file notification specification file
81  * @return Operation result
82  * @retval SYNC_AGENT_EVENT_SUCCESS success
83  * @retval SYNC_AGENT_EVENT_FAIL error
84  */
85 sync_agent_event_error_e event_set_noti_spec_from_config_file(const char *noti_key, const char *config_file);
86
87 /**
88  * @brief       Free notification specification from memory
89  * @return Operation result
90  * @retval SYNC_AGENT_EVENT_SUCCESS success
91  * @retval other error code error
92  */
93 sync_agent_event_error_e event_clean_noti_spec();
94
95 /**
96  * @brief       Register Event Callback function, callback will be called when receive event
97  * @param[in]   event_num event number wrote in event specification file
98  * @param[in]   callback event callback function
99  * @return Operation result
100  * @retval SYNC_AGENT_EVENT_SUCCESS success
101  * @retval SYNC_AGENT_EVENT_FAIL error
102  */
103 sync_agent_event_error_e event_register_event_callback(int event_num, sync_agent_event_cb callback);
104
105 /**
106  * @brief       Register Notification Callback function, callback will be called when receive event
107  * @param[in]   noti_num notification number wrote in notification specification file
108  * @param[in]   callback notification callback function
109  * @param[in]   data data used in callback function
110  * @return Operation result code
111  * @retval SYNC_AGENT_EVENT_SUCCESS     success
112  * @retval SYNC_AGENT_EVENT_FAIL error
113  */
114 sync_agent_event_error_e event_register_noti_callback(int noti_num, sync_agent_noti_cb callback, void *data);   /* only UI */
115
116 /**
117  * @brief       Get Event Callback function pointer
118  * @param[in]   event_num event number wrote in event specification file
119  * @return Event Callback function pointer
120  * @retval function pointer success
121  * @retval NULL error
122  */
123 sync_agent_event_cb event_get_event_callback(int event_num);
124
125 /**
126  * @brief       Get Notification Callback function pointer, this function is for only UI
127  * @param[in]   noti_num notification number wrote in notification specification file
128  * @return Notification Callback function pointer
129  * @retval function pointer success
130  * @retval NULL error
131  */
132 sync_agent_noti_cb event_get_noti_callback(int noti_num);
133
134 /**
135  * @brief       Get additional notification data, this function is for only UI
136  * @param[in] noti_num notification number wrote in notification specification file
137  * @return additional data
138  * @retval additional data success
139  * @retval NULL error or data not exist
140  */
141 void *event_get_noti_callback_additional_param(int noti_num);
142
143 /**
144  * @brief       Get event type
145  * @param[in]   event_num event number wrote in notification specification file
146  * @return event type
147  * @retval event type success
148  * @retval 0 error
149  */
150 event_type_e event_get_event_type(int event_num);
151
152 /**
153  * @brief       Get notification type
154  * @param[in]   noti_key means destination UI
155  * @param[in]   noti_num notification number wrote in notification specification file
156  * @return notification type
157  * @retval notification type success
158  * @retval 0 error
159  */
160 noti_type_e event_get_noti_type(const char *noti_key, int noti_num);
161
162 /**
163  *      @}
164  */
165
166 #endif                          /* CONFIG_H_ */