Tizen 2.1 base
[platform/core/system/sync-agent.git] / src / framework / event / oma_dm_alert_api.c
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 #include <stdio.h>
19 #include <stdlib.h>
20 #include <string.h>
21
22 //#define COMPONENT_TAG APP
23 #ifndef SYNC_AGENT_LOG
24 #undef LOG_TAG
25 #define LOG_TAG "OMADM_CLIENT"
26 #endif
27
28 #include <sync_agent.h>
29
30 #include "oma_dm_alert_api.h"
31 #include "oma_dm_api_common_internal.h"
32
33 #ifndef EXPORT_API
34 #define EXPORT_API __attribute__ ((visibility("default")))
35 #endif
36
37 #define OMA_DM_ALERT_CONFIG_FILE        "/usr/share/oma-dm-cfg/fw-init/omadmalertui_fw_config.xml"
38
39 static int (*_get_alert_noti_callback(int noti_id)) (sync_agent_event_data_s * request, void *data);
40
41 static int __display_noti_cb(sync_agent_event_data_s * request, void *data);
42 static int __confirmation_noti_cb(sync_agent_event_data_s * request, void *data);
43 static int __input_text_noti_cb(sync_agent_event_data_s * request, void *data);
44 static int __single_choice_noti_cb(sync_agent_event_data_s * request, void *data);
45 static int __multiple_choice_noti_cb(sync_agent_event_data_s * request, void *data);
46 static int __default_noti_cb(sync_agent_event_data_s * request, void *data);
47
48 EXPORT_API sync_agent_dm_error_e sync_agent_dm_alert_init()
49 {
50         _EXTERN_FUNC_ENTER;
51
52         sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_SUCCESS;
53
54         sync_agent_init_error_e init_error = sync_agent_init(OMA_DM_ALERT_CONFIG_FILE);
55         if (init_error != SYNC_AGENT_INIT_SUCCESS) {
56                 _DEBUG_ERROR("sync_agent_init() failed !! - err : %d", init_error);
57                 result = UI_SYNC_AGENT_DM_FAIL;
58         }
59
60         sync_agent_event_error_e err = sync_agent_run_noti_listener("omadm_alert_ui");
61         if (err != SYNC_AGENT_EVENT_SUCCESS) {
62                 _DEBUG_ERROR("sync_agent_run_noti_listener() failed !! - err : %d", err);
63                 result = UI_SYNC_AGENT_DM_FAIL;
64         }
65
66         int noti_id = NOTI_ALERT_DISPLAY;
67         for (; noti_id < NOTI_NUM; noti_id++) {
68                 err = sync_agent_set_noti_callback(noti_id, _get_alert_noti_callback(noti_id), NULL);
69                 if (err != SYNC_AGENT_EVENT_SUCCESS) {
70                         _DEBUG_ERROR("sync_agent_set_noti_callback(noti_id : %d) failed - err : %d !!", noti_id, err);
71                         result = UI_SYNC_AGENT_DM_FAIL;
72                         break;
73                 }
74         }
75
76         _EXTERN_FUNC_EXIT;
77
78         return result;
79 }
80
81 EXPORT_API sync_agent_dm_error_e sync_agent_dm_alert_deinit()
82 {
83         _EXTERN_FUNC_ENTER;
84
85         sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_SUCCESS;
86         sync_agent_deinit_error_e deinit = SYNC_AGENT_DEINIT_SUCCESS;
87
88         deinit = sync_agent_deinit();
89         if (deinit != SYNC_AGENT_DEINIT_SUCCESS) {
90                 _DEBUG_ERROR("sync_agent_deinit() failed !!");
91                 result = UI_SYNC_AGENT_DM_FAIL;
92         }
93         /*
94            sync_agent_event_error_e err = sync_agent_stop_noti_listener();
95            if (err != SYNC_AGENT_EVENT_SUCCESS) {
96            _DEBUG_INFO("sync_agent_stop_noti_listener() failed !! - err : %d", err);
97            result = UI_SYNC_AGENT_DM_FAIL;
98            }
99
100            err = sync_agent_clean_event_handler();
101            if (err != SYNC_AGENT_EVENT_SUCCESS) {
102            _DEBUG_ERROR("sync_agent_clean_event_handler() failed !! - err : %d", err);
103            result = UI_SYNC_AGENT_DM_FAIL;
104            }
105          */
106         _EXTERN_FUNC_EXIT;
107
108         return result;
109 }
110
111 /*
112 sync_agent_dm_error_e sync_agent_alert_display(int response_type)
113 {
114         _EXTERN_FUNC_ENTER;
115
116         // called by setted timer (alert_option->max_t)
117
118         int api_result = SYNC_AGENT_DM_API_RESULT_SUCCESS;
119         sync_agent_dm_error_e result = SYNC_AGENT_DM_SUCCESS;
120         sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
121         sync_agent_event_data_s *request_event = NULL;
122         sync_agent_event_data_s *response_event = NULL;
123         uic_type type = UIC_DISPLAY_TYPE;
124
125         request_event = sync_agent_create_event(EVENT_UIC_ALERT);
126         if (request_event == NULL) {
127                 _DEBUG_ERROR("request_event is NULL !!");
128                 _EXTERN_FUNC_EXIT;
129                 return SYNC_AGENT_DM_FAIL;
130         }
131
132         _DEBUG_VERBOSE("event num : %d", EVENT_UIC_ALERT);
133
134         sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &response_type);
135         _DEBUG_VERBOSE("response_type : %d", response_type);
136
137         sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &type);
138         _DEBUG_VERBOSE("UIC TYPE : %d", type);
139
140         response_event = sync_agent_send_event(request_event, &error);
141         if (error != SYNC_AGENT_EVENT_SUCCESS) {
142                 _DEBUG_ERROR("sync_agent_send_event() failed !! - err = %d", error);
143                 sync_agent_free_event(request_event);
144                 _EXTERN_FUNC_EXIT;
145                 return SYNC_AGENT_DM_FAIL;
146         }
147
148         if (response_event == NULL) {
149                 _DEBUG_ERROR("response_event is NULL !!");
150                 sync_agent_free_event(request_event);
151                 _EXTERN_FUNC_EXIT;
152                 return SYNC_AGENT_DM_FAIL;
153         }
154
155         sync_agent_get_event_data_param(response_event, &api_result);
156         if (api_result != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
157                 _DEBUG_ERROR("api_result : failed !!");
158                 sync_agent_free_event(request_event);
159                 sync_agent_free_event_data(response_event);
160                 _EXTERN_FUNC_EXIT;
161                 return SYNC_AGENT_DM_FAIL;
162         }
163
164          free request & response event
165         sync_agent_free_event(request_event);
166         sync_agent_free_event_data(response_event);
167
168         _EXTERN_FUNC_EXIT;
169
170         return result;
171 }*/
172
173 EXPORT_API sync_agent_dm_error_e sync_agent_dm_alert_confirmation(int response_type)
174 {
175         _EXTERN_FUNC_ENTER;
176
177         /*
178          * called by setted timer (alert_option->max_t)
179          *
180          * or
181          *
182          * called by click button
183          *
184          */
185
186         int api_result = SYNC_AGENT_DM_API_RESULT_SUCCESS;
187         sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_SUCCESS;
188         sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
189         sync_agent_event_data_s *request_event = NULL;
190         sync_agent_event_data_s *response_event = NULL;
191         uic_type type = UIC_CONFIRMATION_TYPE;
192
193         request_event = sync_agent_create_event(EVENT_UIC_ALERT);
194         if (request_event == NULL) {
195                 _DEBUG_ERROR("request_event is NULL !!");
196                 _EXTERN_FUNC_EXIT;
197                 return UI_SYNC_AGENT_DM_FAIL;
198         }
199
200         _DEBUG_VERBOSE("event num : %d", EVENT_UIC_ALERT);
201
202         sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &response_type);
203         sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &type);
204
205         _DEBUG_VERBOSE("response_type : %d", response_type);
206         _DEBUG_VERBOSE("UIC TYPE : %d", type);
207
208         response_event = sync_agent_send_event(request_event, &error);
209         if (error != SYNC_AGENT_EVENT_SUCCESS) {
210                 _DEBUG_ERROR("sync_agent_send_event() failed !! - err = %d", error);
211                 sync_agent_free_event(request_event);
212                 _EXTERN_FUNC_EXIT;
213                 return UI_SYNC_AGENT_DM_FAIL;
214         }
215
216         if (response_event == NULL) {
217                 _DEBUG_ERROR("response_event is NULL !!");
218                 sync_agent_free_event(request_event);
219                 _EXTERN_FUNC_EXIT;
220                 return UI_SYNC_AGENT_DM_FAIL;
221         }
222
223         sync_agent_get_event_data_param(response_event, &api_result);
224         if (api_result != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
225                 _DEBUG_ERROR("api_result : failed !!");
226                 sync_agent_free_event(request_event);
227                 sync_agent_free_event_data(response_event);
228                 _EXTERN_FUNC_EXIT;
229                 return UI_SYNC_AGENT_DM_FAIL;
230         }
231
232         /* free request & response event */
233         sync_agent_free_event(request_event);
234         sync_agent_free_event_data(response_event);
235
236         /*
237          *
238          * must do destroy UI
239          *
240          * */
241
242         _EXTERN_FUNC_EXIT;
243
244         return result;
245 }
246
247 EXPORT_API sync_agent_dm_error_e sync_agent_dm_alert_inputtext(int response_type, char *text)
248 {
249         _EXTERN_FUNC_ENTER;
250
251         /*
252          * called by setted timer (alert_option->max_t)
253          *
254          * or
255          *
256          * called by click button
257          *
258          */
259
260         int api_result = SYNC_AGENT_DM_API_RESULT_SUCCESS;
261         sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_SUCCESS;
262         sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
263         sync_agent_event_data_s *request_event = NULL;
264         sync_agent_event_data_s *response_event = NULL;
265
266         uic_type type = UIC_INPUT_TEXT_TYPE;
267
268         request_event = sync_agent_create_event(EVENT_UIC_ALERT);
269         if (request_event == NULL) {
270                 _DEBUG_ERROR("request_event is NULL !!");
271                 _EXTERN_FUNC_EXIT;
272                 return UI_SYNC_AGENT_DM_FAIL;
273         }
274
275         _DEBUG_VERBOSE("event num : %d", EVENT_UIC_ALERT);
276
277         sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &response_type);
278         sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &type);
279         sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, text);
280
281         _DEBUG_VERBOSE("response_type : %d", response_type);
282         _DEBUG_VERBOSE("UIC TYPE : %d", type);
283         _DEBUG_VERBOSE("text : %s", text);
284
285         response_event = sync_agent_send_event(request_event, &error);
286         if (error != SYNC_AGENT_EVENT_SUCCESS) {
287                 _DEBUG_ERROR("sync_agent_send_event() failed !! - err = %d", error);
288                 sync_agent_free_event(request_event);
289                 _EXTERN_FUNC_EXIT;
290                 return UI_SYNC_AGENT_DM_FAIL;
291         }
292
293         if (response_event == NULL) {
294                 _DEBUG_ERROR("response_event is NULL !!");
295                 sync_agent_free_event(request_event);
296                 _EXTERN_FUNC_EXIT;
297                 return UI_SYNC_AGENT_DM_FAIL;
298         }
299
300         sync_agent_get_event_data_param(response_event, &api_result);
301         if (api_result != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
302                 _DEBUG_ERROR("api_result : failed !!");
303                 sync_agent_free_event(request_event);
304                 sync_agent_free_event_data(response_event);
305                 _EXTERN_FUNC_EXIT;
306                 return UI_SYNC_AGENT_DM_FAIL;
307         }
308
309         /* free request & response event */
310         sync_agent_free_event(request_event);
311         sync_agent_free_event_data(response_event);
312
313         /*
314          *
315          * must do destroy UI
316          *
317          * */
318
319         _EXTERN_FUNC_EXIT;
320
321         return result;
322 }
323
324 EXPORT_API sync_agent_dm_error_e sync_agent_dm_alert_single_choice(int response_type, int selected_count, char *selected_number)
325 {
326         _EXTERN_FUNC_ENTER;
327
328         /*
329          * called by setted timer (alert_option->max_t)
330          *
331          * or
332          *
333          * called by click button
334          *
335          */
336
337         int api_result = SYNC_AGENT_DM_API_RESULT_SUCCESS;
338         sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_SUCCESS;
339         sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
340         sync_agent_event_data_s *request_event = NULL;
341         sync_agent_event_data_s *response_event = NULL;
342
343         uic_type type = UIC_SINGLE_CHOICE_TYPE;
344
345         request_event = sync_agent_create_event(EVENT_UIC_ALERT);
346         if (request_event == NULL) {
347                 _DEBUG_ERROR("request_event is NULL !!");
348                 _EXTERN_FUNC_EXIT;
349                 return UI_SYNC_AGENT_DM_FAIL;
350         }
351
352         _DEBUG_VERBOSE("event num : %d", EVENT_UIC_ALERT);
353
354         sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &response_type);
355         sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &type);
356         sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &selected_count);
357         sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, selected_number);
358
359         _DEBUG_VERBOSE("response_type : %d", response_type);
360         _DEBUG_VERBOSE("UIC TYPE : %d", type);
361         _DEBUG_VERBOSE("selected_count : %d", selected_count);
362         _DEBUG_VERBOSE("selected_number : %s", selected_number);
363
364         response_event = sync_agent_send_event(request_event, &error);
365         if (error != SYNC_AGENT_EVENT_SUCCESS) {
366                 _DEBUG_ERROR("sync_agent_send_event() failed !! - err = %d", error);
367                 sync_agent_free_event(request_event);
368                 _EXTERN_FUNC_EXIT;
369                 return UI_SYNC_AGENT_DM_FAIL;
370         }
371
372         if (response_event == NULL) {
373                 _DEBUG_ERROR("response_event is NULL !!");
374                 sync_agent_free_event(request_event);
375                 _EXTERN_FUNC_EXIT;
376                 return UI_SYNC_AGENT_DM_FAIL;
377         }
378
379         sync_agent_get_event_data_param(response_event, &api_result);
380         if (api_result != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
381                 _DEBUG_ERROR("api_result : failed !!");
382                 sync_agent_free_event(request_event);
383                 sync_agent_free_event_data(response_event);
384                 _EXTERN_FUNC_EXIT;
385                 return UI_SYNC_AGENT_DM_FAIL;
386         }
387
388         /* free request & response event */
389         sync_agent_free_event(request_event);
390         sync_agent_free_event_data(response_event);
391
392         /*
393          *
394          * must do destroy UI
395          *
396          * */
397
398         _EXTERN_FUNC_EXIT;
399
400         return result;
401 }
402
403 EXPORT_API sync_agent_dm_error_e sync_agent_dm_alert_multiple_choice(int response_type, GList * out_data_list)
404 {
405         _EXTERN_FUNC_ENTER;
406
407         /*
408          * called by setted timer (alert_option->max_t)
409          *
410          * or
411          *
412          * called by click button
413          *
414          */
415
416         int api_result = SYNC_AGENT_DM_API_RESULT_SUCCESS;
417         sync_agent_dm_error_e result = UI_SYNC_AGENT_DM_SUCCESS;
418         sync_agent_event_error_e error = SYNC_AGENT_EVENT_SUCCESS;
419         sync_agent_event_data_s *request_event = NULL;
420         sync_agent_event_data_s *response_event = NULL;
421
422         uic_type type = UIC_MULTIPLE_CHOICE_TYPE;
423
424         GList *iter = NULL;
425         int count = g_list_length(out_data_list);
426
427         request_event = sync_agent_create_event(EVENT_UIC_ALERT);
428         if (request_event == NULL) {
429                 _DEBUG_ERROR("request_event is NULL !!");
430                 _EXTERN_FUNC_EXIT;
431                 return UI_SYNC_AGENT_DM_FAIL;
432         }
433
434         _DEBUG_VERBOSE("event num : %d", EVENT_UIC_ALERT);
435
436         sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &response_type);
437         sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &type);
438         sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_INTEGER, &count);
439
440         _DEBUG_VERBOSE("response_type : %d", response_type);
441         _DEBUG_VERBOSE("UIC TYPE : %d", type);
442         _DEBUG_VERBOSE("selected_count : %d", count);
443
444         for (iter = out_data_list; iter != NULL; iter = g_list_next(iter)) {
445                 sync_agent_append_event_data_param(request_event, SYNC_AGENT_EVENT_PARAM_TYPE_STRING, (char *)(iter->data));
446                 _DEBUG_VERBOSE("selected_number : %s", (char *)(iter->data));
447         }
448
449         response_event = sync_agent_send_event(request_event, &error);
450         if (error != SYNC_AGENT_EVENT_SUCCESS) {
451                 _DEBUG_ERROR("sync_agent_send_event() failed !! - err = %d", error);
452                 sync_agent_free_event(request_event);
453                 _EXTERN_FUNC_EXIT;
454                 return UI_SYNC_AGENT_DM_FAIL;
455         }
456
457         if (response_event == NULL) {
458                 _DEBUG_ERROR("response_event is NULL !!");
459                 sync_agent_free_event(request_event);
460                 _EXTERN_FUNC_EXIT;
461                 return UI_SYNC_AGENT_DM_FAIL;
462         }
463
464         sync_agent_get_event_data_param(response_event, &api_result);
465         if (api_result != SYNC_AGENT_DM_API_RESULT_SUCCESS) {
466                 _DEBUG_ERROR("api_result : failed !!");
467                 sync_agent_free_event(request_event);
468                 sync_agent_free_event_data(response_event);
469                 _EXTERN_FUNC_EXIT;
470                 return UI_SYNC_AGENT_DM_FAIL;
471         }
472
473         /* free request & response event */
474         sync_agent_free_event(request_event);
475         sync_agent_free_event_data(response_event);
476
477         /*
478          *
479          * must do destroy UI
480          *
481          * */
482
483         _EXTERN_FUNC_EXIT;
484
485         return result;
486 }
487
488 static int (*_get_alert_noti_callback(int noti_id)) (sync_agent_event_data_s * request, void *data) {
489         _EXTERN_FUNC_ENTER;
490
491         _DEBUG_INFO("start (noti_type : %d)", noti_id);
492
493         _EXTERN_FUNC_EXIT;
494
495         switch (noti_id) {
496         case NOTI_ALERT_DISPLAY:
497                 return __display_noti_cb;
498                 break;
499         case NOTI_ALERT_CONFIRMATION:
500                 return __confirmation_noti_cb;
501                 break;
502         case NOTI_ALERT_INPUTTEXT:
503                 return __input_text_noti_cb;
504                 break;
505         case NOTI_ALERT_SINGLE_CHOICE:
506                 return __single_choice_noti_cb;
507                 break;
508         case NOTI_ALERT_MULTIPLE_CHOICE:
509                 return __multiple_choice_noti_cb;
510                 break;
511         default:
512                 return __default_noti_cb;
513                 break;
514         }
515
516         return 0;
517 }
518
519 static int __display_noti_cb(sync_agent_event_data_s * request, void *data)
520 {
521         _INNER_FUNC_ENTER;
522
523         sync_agent_dm_alert_option_s *alert_option = (sync_agent_dm_alert_option_s *) calloc(1, sizeof(sync_agent_dm_alert_option_s));
524         if (alert_option == NULL) {
525                 _DEBUG_ERROR("calloc fail");
526                 return 0;
527         }
528         char *display_string = NULL;
529
530         sync_agent_get_event_data_param(request, &(alert_option->min_t));
531         sync_agent_get_event_data_param(request, &(alert_option->max_t));
532         sync_agent_get_event_data_param(request, &(alert_option->default_data));
533         sync_agent_get_event_data_param(request, &(alert_option->maxlen));
534         sync_agent_get_event_data_param(request, &(alert_option->input_type));
535         sync_agent_get_event_data_param(request, &(alert_option->echo_type));
536         sync_agent_get_event_data_param(request, &display_string);
537
538         _DEBUG_VERBOSE("min_t : %s", alert_option->min_t);
539         _DEBUG_VERBOSE("max_t : %s", alert_option->max_t);
540         _DEBUG_VERBOSE("default_data : %s", alert_option->default_data);
541         _DEBUG_VERBOSE("maxlen : %s", alert_option->maxlen);
542         _DEBUG_VERBOSE("input_type : %s", alert_option->input_type);
543         _DEBUG_VERBOSE("echo_type : %s", alert_option->echo_type);
544         _DEBUG_VERBOSE("display_string : %s", display_string);
545
546         /*
547          * must coding alert UI
548          * timer setting alert_option->max_t
549          *
550          */
551
552         if (alert_option != NULL) {
553                 if (alert_option->min_t != NULL)
554                         g_free(alert_option->min_t);
555                 if (alert_option->max_t != NULL)
556                         g_free(alert_option->max_t);
557                 if (alert_option->default_data != NULL)
558                         g_free(alert_option->default_data);
559                 if (alert_option->maxlen != NULL)
560                         g_free(alert_option->maxlen);
561                 if (alert_option->input_type != NULL)
562                         g_free(alert_option->input_type);
563                 if (alert_option->echo_type != NULL)
564                         g_free(alert_option->echo_type);
565
566                 g_free(alert_option);
567         }
568
569         if (display_string != NULL)
570                 g_free(display_string);
571
572         if (request != NULL) {
573                 if (request->size != NULL)
574                         g_free(request->size);
575                 g_free(request);
576         }
577
578         _INNER_FUNC_EXIT;
579
580         return 0;
581 }
582
583 static int __confirmation_noti_cb(sync_agent_event_data_s * request, void *data)
584 {
585         _INNER_FUNC_ENTER;
586
587         sync_agent_dm_alert_option_s *alert_option = (sync_agent_dm_alert_option_s *) calloc(1, sizeof(sync_agent_dm_alert_option_s));
588         if (alert_option == NULL) {
589                 _DEBUG_ERROR("calloc fail");
590                 return 0;
591         }
592         char *display_string = NULL;
593
594         sync_agent_get_event_data_param(request, &(alert_option->min_t));
595         sync_agent_get_event_data_param(request, &(alert_option->max_t));
596         sync_agent_get_event_data_param(request, &(alert_option->default_data));
597         sync_agent_get_event_data_param(request, &(alert_option->maxlen));
598         sync_agent_get_event_data_param(request, &(alert_option->input_type));
599         sync_agent_get_event_data_param(request, &(alert_option->echo_type));
600         sync_agent_get_event_data_param(request, &display_string);
601
602         _DEBUG_VERBOSE("min_t : %s", alert_option->min_t);
603         _DEBUG_VERBOSE("max_t : %s", alert_option->max_t);
604         _DEBUG_VERBOSE("default_data : %s", alert_option->default_data);
605         _DEBUG_VERBOSE("maxlen : %s", alert_option->maxlen);
606         _DEBUG_VERBOSE("input_type : %s", alert_option->input_type);
607         _DEBUG_VERBOSE("echo_type : %s", alert_option->echo_type);
608         _DEBUG_VERBOSE("display_string : %s", display_string);
609
610         /*
611          * must coding alert UI
612          * timer setting alert_option->max_t
613          *
614          */
615
616         if (alert_option != NULL) {
617                 if (alert_option->min_t != NULL)
618                         g_free(alert_option->min_t);
619                 if (alert_option->max_t != NULL)
620                         g_free(alert_option->max_t);
621                 if (alert_option->default_data != NULL)
622                         g_free(alert_option->default_data);
623                 if (alert_option->maxlen != NULL)
624                         g_free(alert_option->maxlen);
625                 if (alert_option->input_type != NULL)
626                         g_free(alert_option->input_type);
627                 if (alert_option->echo_type != NULL)
628                         g_free(alert_option->echo_type);
629
630                 g_free(alert_option);
631         }
632
633         if (display_string != NULL)
634                 g_free(display_string);
635
636         if (request != NULL) {
637                 if (request->size != NULL)
638                         g_free(request->size);
639                 g_free(request);
640         }
641
642         _INNER_FUNC_EXIT;
643
644         return 0;
645 }
646
647 static int __input_text_noti_cb(sync_agent_event_data_s * request, void *data)
648 {
649         _INNER_FUNC_ENTER;
650
651         sync_agent_dm_alert_option_s *alert_option = (sync_agent_dm_alert_option_s *) calloc(1, sizeof(sync_agent_dm_alert_option_s));
652         if (alert_option == NULL) {
653                 _DEBUG_ERROR("calloc fail");
654                 return 0;
655         }
656         char *display_string = NULL;
657
658         sync_agent_get_event_data_param(request, &(alert_option->min_t));
659         sync_agent_get_event_data_param(request, &(alert_option->max_t));
660         sync_agent_get_event_data_param(request, &(alert_option->default_data));
661         sync_agent_get_event_data_param(request, &(alert_option->maxlen));
662         sync_agent_get_event_data_param(request, &(alert_option->input_type));
663         sync_agent_get_event_data_param(request, &(alert_option->echo_type));
664         sync_agent_get_event_data_param(request, &display_string);
665
666         _DEBUG_VERBOSE("min_t : %s", alert_option->min_t);
667         _DEBUG_VERBOSE("max_t : %s", alert_option->max_t);
668         _DEBUG_VERBOSE("default_data : %s", alert_option->default_data);
669         _DEBUG_VERBOSE("maxlen : %s", alert_option->maxlen);
670         _DEBUG_VERBOSE("input_type : %s", alert_option->input_type);
671         _DEBUG_VERBOSE("echo_type : %s", alert_option->echo_type);
672         _DEBUG_VERBOSE("display_string : %s", display_string);
673
674         /*
675          * must coding alert UI
676          * timer setting alert_option->max_t
677          *
678          */
679
680         if (alert_option != NULL) {
681                 if (alert_option->min_t != NULL)
682                         g_free(alert_option->min_t);
683                 if (alert_option->max_t != NULL)
684                         g_free(alert_option->max_t);
685                 if (alert_option->default_data != NULL)
686                         g_free(alert_option->default_data);
687                 if (alert_option->maxlen != NULL)
688                         g_free(alert_option->maxlen);
689                 if (alert_option->input_type != NULL)
690                         g_free(alert_option->input_type);
691                 if (alert_option->echo_type != NULL)
692                         g_free(alert_option->echo_type);
693
694                 g_free(alert_option);
695         }
696
697         if (display_string != NULL)
698                 g_free(display_string);
699
700         if (request != NULL) {
701                 if (request->size != NULL)
702                         g_free(request->size);
703                 g_free(request);
704         }
705
706         _INNER_FUNC_EXIT;
707
708         return 0;
709 }
710
711 static int __single_choice_noti_cb(sync_agent_event_data_s * request, void *data)
712 {
713         _INNER_FUNC_ENTER;
714
715         sync_agent_dm_alert_option_s *alert_option = (sync_agent_dm_alert_option_s *) calloc(1, sizeof(sync_agent_dm_alert_option_s));
716         if (alert_option == NULL) {
717                 _DEBUG_ERROR("calloc fail");
718                 return 0;
719         }
720         char *display_string = NULL;
721         int item_count = 0;
722         char *item = NULL;
723
724         sync_agent_get_event_data_param(request, &(alert_option->min_t));
725         sync_agent_get_event_data_param(request, &(alert_option->max_t));
726         sync_agent_get_event_data_param(request, &(alert_option->default_data));
727         sync_agent_get_event_data_param(request, &(alert_option->maxlen));
728         sync_agent_get_event_data_param(request, &(alert_option->input_type));
729         sync_agent_get_event_data_param(request, &(alert_option->echo_type));
730         sync_agent_get_event_data_param(request, &display_string);
731         sync_agent_get_event_data_param(request, &item_count);
732         sync_agent_get_event_data_param(request, &item);
733
734         _DEBUG_VERBOSE("min_t : %s", alert_option->min_t);
735         _DEBUG_VERBOSE("max_t : %s", alert_option->max_t);
736         _DEBUG_VERBOSE("default_data : %s", alert_option->default_data);
737         _DEBUG_VERBOSE("maxlen : %s", alert_option->maxlen);
738         _DEBUG_VERBOSE("input_type : %s", alert_option->input_type);
739         _DEBUG_VERBOSE("echo_type : %s", alert_option->echo_type);
740         _DEBUG_VERBOSE("display_string : %s", display_string);
741         _DEBUG_VERBOSE("item_count : %d", item_count);
742         _DEBUG_VERBOSE("item : %s", item);
743
744         /*
745          * must coding alert UI
746          * timer setting alert_option->max_t
747          *
748          */
749
750         if (alert_option != NULL) {
751                 if (alert_option->min_t != NULL)
752                         g_free(alert_option->min_t);
753                 if (alert_option->max_t != NULL)
754                         g_free(alert_option->max_t);
755                 if (alert_option->default_data != NULL)
756                         g_free(alert_option->default_data);
757                 if (alert_option->maxlen != NULL)
758                         g_free(alert_option->maxlen);
759                 if (alert_option->input_type != NULL)
760                         g_free(alert_option->input_type);
761                 if (alert_option->echo_type != NULL)
762                         g_free(alert_option->echo_type);
763
764                 g_free(alert_option);
765         }
766
767         if (display_string != NULL)
768                 g_free(display_string);
769
770         if (item != NULL)
771                 g_free(item);
772
773         if (request != NULL) {
774                 if (request->size != NULL)
775                         g_free(request->size);
776                 g_free(request);
777         }
778
779         _INNER_FUNC_EXIT;
780
781         return 0;
782 }
783
784 static int __multiple_choice_noti_cb(sync_agent_event_data_s * request, void *data)
785 {
786         _INNER_FUNC_ENTER;
787
788         sync_agent_dm_alert_option_s *alert_option = (sync_agent_dm_alert_option_s *) calloc(1, sizeof(sync_agent_dm_alert_option_s));
789         if (alert_option == NULL) {
790                 _DEBUG_ERROR("calloc fail");
791                 return 0;
792         }
793         char *display_string = NULL;
794         int item_count = 0;
795         int i = 0;
796         char *item = NULL;
797         GList *item_list = NULL;
798         GList *iter = NULL;
799
800         sync_agent_get_event_data_param(request, &(alert_option->min_t));
801         sync_agent_get_event_data_param(request, &(alert_option->max_t));
802         sync_agent_get_event_data_param(request, &(alert_option->default_data));
803         sync_agent_get_event_data_param(request, &(alert_option->maxlen));
804         sync_agent_get_event_data_param(request, &(alert_option->input_type));
805         sync_agent_get_event_data_param(request, &(alert_option->echo_type));
806         sync_agent_get_event_data_param(request, &display_string);
807         sync_agent_get_event_data_param(request, &item_count);
808
809         _DEBUG_VERBOSE("min_t : %s", alert_option->min_t);
810         _DEBUG_VERBOSE("max_t : %s", alert_option->max_t);
811         _DEBUG_VERBOSE("default_data : %s", alert_option->default_data);
812         _DEBUG_VERBOSE("maxlen : %s", alert_option->maxlen);
813         _DEBUG_VERBOSE("input_type : %s", alert_option->input_type);
814         _DEBUG_VERBOSE("echo_type : %s", alert_option->echo_type);
815         _DEBUG_VERBOSE("display_string : %s", display_string);
816         _DEBUG_VERBOSE("item_count : %d", item_count);
817
818         for (; i < item_count; i++) {
819                 char *item = NULL;
820                 sync_agent_get_event_data_param(request, &item);
821                 _DEBUG_VERBOSE("item : %s", item);
822                 item_list = g_list_append(item_list, item);
823         }
824
825         /*
826          * must coding alert UI
827          * timer setting alert_option->max_t
828          *
829          */
830
831         if (alert_option != NULL) {
832                 if (alert_option->min_t != NULL)
833                         g_free(alert_option->min_t);
834                 if (alert_option->max_t != NULL)
835                         g_free(alert_option->max_t);
836                 if (alert_option->default_data != NULL)
837                         g_free(alert_option->default_data);
838                 if (alert_option->maxlen != NULL)
839                         g_free(alert_option->maxlen);
840                 if (alert_option->input_type != NULL)
841                         g_free(alert_option->input_type);
842                 if (alert_option->echo_type != NULL)
843                         g_free(alert_option->echo_type);
844
845                 g_free(alert_option);
846         }
847
848         if (display_string != NULL)
849                 g_free(display_string);
850
851         if (item_list != NULL) {
852                 for (iter = item_list; iter != NULL;) {
853                         item = (char *)(iter->data);
854                         iter = g_list_next(iter);
855                         item_list = g_list_remove(item_list, item);
856                         g_free(item);
857                 }
858
859                 g_list_free(item_list);
860         }
861
862         if (request != NULL) {
863                 if (request->size != NULL)
864                         g_free(request->size);
865                 g_free(request);
866         }
867
868         _INNER_FUNC_EXIT;
869
870         return 0;
871 }
872
873 static int __default_noti_cb(sync_agent_event_data_s * request, void *data)
874 {
875         _INNER_FUNC_ENTER;
876
877         _INNER_FUNC_EXIT;
878
879         return 0;
880 }