[Request]Update Flora license version
[apps/home/clock.git] / ring / src / ring_fwk_vconf.c
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.1 (the License);
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *     http://floralicense.org/license/
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an AS IS BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16
17
18 #include "ring_fwk_vconf.h"
19 #include "ring_fwk_util.h"
20 #include "ring_fwk_sound.h"
21
22 /**********************************************************************
23 ******************define, struct ,typedef, union, enum, global val *************************************
24 ***********************************************************************/
25
26 //
27 typedef struct _noti_callback {
28         char *setting_key;
29         void (*noti_func) (keynode_t *, void *);
30 } noti_callback;
31 /**********************************************************************
32 ******************Local function declear, extern function declear*************************************
33 ***********************************************************************/
34 static void alarm_vconfkey_call_state_cb(keynode_t *key, void *data);
35
36 /**********************************************************************
37 ******************Global val , static global val*************************************
38 ***********************************************************************/
39 #define ALARM_NOTI_MAX            1
40 static noti_callback s_notis[ALARM_NOTI_MAX] = {
41         {VCONFKEY_CALL_STATE, alarm_vconfkey_call_state_cb},
42 };
43
44 /**********************************************************************
45 ******************Local function ref*************************************
46 ***********************************************************************/
47
48 /**
49 * send
50 * This function is  used to handle vconf key: VCONFKEY_ALARM_UPDATE
51 * @param           data[in]           pointer to data
52 * @return          void
53 * @exception
54 */
55 static void alarm_vconfkey_call_state_cb(keynode_t *key, void *data)
56 {
57         retm_if(!data, "data is NULL");
58         int call_state = vconf_keynode_get_int(key);
59         struct appdata *ad = (struct appdata *)data;
60         retm_if(!ad->data_s, "ad->data_s is NULL");
61         if (IS_CALL_STATE(call_state)) {
62                 //call coming,exit alarmring
63                 evas_object_hide(ad->win_main);
64
65         } else {
66                 evas_object_show(ad->win_main);
67                 ring_volume_play_sound(ad);
68         }
69 }
70
71 /**********************************************************************
72 ******************Global function ref*************************************
73 ***********************************************************************/
74
75 /**
76 * send
77 * This function is  used to init noti of vconf
78 * @param           data[in]           pointer to data
79 * @return          when success, return SUCCESS  or FAILED if error
80 * @exception
81 */
82 int ring_noti_init(void *data)
83 {
84         //set cb
85         struct appdata *ad = (struct appdata *)data;
86         int i = 0;
87         for (i = 0; i < ALARM_NOTI_MAX; i++) {
88                 if (0 !=
89                     vconf_notify_key_changed(s_notis[i].setting_key,
90                                              s_notis[i].noti_func, ad)) {
91                         return FAILED;
92                 }
93         }
94         return SUCCESS;
95 }
96
97 /**
98 * send
99 * This function is  used to fini noti of vconf
100 * @param           void
101 * @return          void
102 * @exception
103 */
104 void ring_noti_fini()
105 {
106         int i;
107         for (i = 0; i < ALARM_NOTI_MAX; i++) {
108                 vconf_ignore_key_changed(s_notis[i].setting_key,
109                                          s_notis[i].noti_func);
110         }
111 }