4 * Copyright (c) 2000 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
24 #include <bluetooth.h>
27 #include "indicator.h"
34 #define ICON_PRIORITY INDICATOR_PRIORITY_MINICTRL3
35 #define MODULE_NAME "call"
36 #define MINICONTROL_VOICE_NAME "[voicecall-quickpanel]"
37 #define MINICONTROL_VIDEO_NAME "[videocall-quickpanel]"
39 static int register_call_module(void *data);
40 static int unregister_call_module(void);
41 static void show_call_icon( void *data);
44 CALL_UI_STATUS_NONE = 0,
46 CALL_UI_STATUS_OUTGOING,
47 CALL_UI_STATUS_ACTIVE,
53 .type = INDICATOR_IMG_ICON,
55 .priority = ICON_PRIORITY,
56 .always_top = EINA_TRUE,
57 .exist_in_view = EINA_FALSE,
59 .obj_exist = EINA_FALSE,
60 .area = INDICATOR_ICON_AREA_MINICTRL,
61 .init = register_call_module,
62 .fini = unregister_call_module,
63 .minictrl_control = NULL //mctrl_monitor_cb
66 static int bt_state = 0;
68 static const char *icon_path[] = {
69 "Call/B03_Call_Duringcall.png",
70 "Call/B03_Call_bluetooth.png",
74 static void set_app_state(void* data)
79 static void show_image_icon(void *data)
82 call.img_obj.data = icon_path[1];
84 call.img_obj.data = icon_path[0];
89 static void hide_image_icon(void)
94 static void icon_animation_set(enum indicator_icon_ani type)
96 icon_ani_set(&call, type);
99 static void __bt_ag_sco_state_changed_cb(int result, bool connected, const char *remote_address, bt_audio_profile_type_e type, void *user_data)
103 if (connected) bt_state=1;
106 vconf_get_int(VCONFKEY_CALL_STATE, &status);
108 if (status != VCONFKEY_CALL_OFF) show_call_icon(user_data);
111 static void register_bt_state( void *data)
115 error = bt_initialize();
116 if (error != BT_ERROR_NONE) _E("bt_initialize return [%d]", error);
118 error = bt_audio_initialize();
119 if (error != BT_ERROR_NONE) _E("bt_audio_initialize return [%d]", error);
121 error = bt_audio_set_connection_state_changed_cb(__bt_ag_sco_state_changed_cb, data); // callback µî·Ï
122 if (error != BT_ERROR_NONE) _E("bt_ag_set_sco_state_changed_cb return [%d]", error);
126 static void unregister_bt_state( void )
130 error = bt_audio_unset_connection_state_changed_cb();
131 if (error != BT_ERROR_NONE) _E("bt_ag_unset_sco_state_changed_cb return [%d]", error);
133 error = bt_audio_deinitialize();
134 if (error != BT_ERROR_NONE) _E("bt_audio_deinitialize return [%d]", error);
136 error = bt_deinitialize();
137 if (error != BT_ERROR_NONE) _E("bt_audio_deinitialize return [%d]", error);
140 static void show_call_icon( void *data)
147 ret = vconf_get_int(VCONFKEY_CALL_STATE, &status);
149 _E("Failed to get VCONFKEY_CALL_STATE!");
154 case VCONFKEY_CALL_VOICE_CONNECTING:
155 case VCONFKEY_CALL_VIDEO_CONNECTING:
156 show_image_icon(data);
157 icon_animation_set(ICON_ANI_BLINK);
159 case VCONFKEY_CALL_VOICE_ACTIVE:
160 case VCONFKEY_CALL_VIDEO_ACTIVE:
161 show_image_icon(data);
162 icon_animation_set(ICON_ANI_NONE);
164 case VCONFKEY_CALL_OFF:
168 _E("Invalid value %d", status);
173 static void indicator_call_change_cb(keynode_t *node, void *data)
180 ret = vconf_get_int(VCONFKEY_CALL_STATE, &status);
182 _E("Failed to get VCONFKEY_CALL_STATE!");
187 case VCONFKEY_CALL_VOICE_CONNECTING:
188 case VCONFKEY_CALL_VIDEO_CONNECTING:
189 show_image_icon(data);
190 icon_animation_set(ICON_ANI_BLINK);
192 case VCONFKEY_CALL_VOICE_ACTIVE:
193 case VCONFKEY_CALL_VIDEO_ACTIVE:
194 show_image_icon(data);
195 icon_animation_set(ICON_ANI_NONE);
197 case VCONFKEY_CALL_OFF:
201 _E("Invalid value %d", status);
206 static int register_call_module(void *data)
214 ret = vconf_notify_key_changed(VCONFKEY_CALL_STATE, indicator_call_change_cb, data);
215 register_bt_state(data);
216 if (ret != OK) _E("Failed to register VCONFKEY_CALL_STATE callback!");
221 static int unregister_call_module(void)
225 ret = vconf_ignore_key_changed(VCONFKEY_CALL_STATE, indicator_call_change_cb);
226 unregister_bt_state();
227 if (ret != OK) _E("Failed to register VCONFKEY_CALL_STATE callback!");