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 <Ecore_X.h>
25 #include <minicontrol-monitor.h>
26 #include <bluetooth.h>
27 //#include <bluetooth_extention.h>
30 #include "indicator.h"
37 #define ICON_PRIORITY INDICATOR_PRIORITY_MINICTRL3
38 #define MODULE_NAME "call"
39 #define MINICONTROL_VOICE_NAME "[voicecall-quickpanel]"
40 #define MINICONTROL_VIDEO_NAME "[videocall-quickpanel]"
42 static int register_call_module(void *data);
43 static int unregister_call_module(void);
44 static void show_call_icon( void *data);
47 CALL_UI_STATUS_NONE = 0,
49 CALL_UI_STATUS_OUTGOING,
50 CALL_UI_STATUS_ACTIVE,
56 .type = INDICATOR_IMG_ICON,
58 .priority = ICON_PRIORITY,
59 .always_top = EINA_TRUE,
60 .exist_in_view = EINA_FALSE,
62 .obj_exist = EINA_FALSE,
63 .area = INDICATOR_ICON_AREA_MINICTRL,
64 .init = register_call_module,
65 .fini = unregister_call_module,
66 .minictrl_control = NULL //mctrl_monitor_cb
69 static int bt_state = 0;
71 static const char *icon_path[] = {
72 "Call/B03_Call_Duringcall.png",
73 "Call/B03_Call_bluetooth.png",
77 static void set_app_state(void* data)
82 static void show_image_icon(void *data)
85 call.img_obj.data = icon_path[1];
87 call.img_obj.data = icon_path[0];
92 static void hide_image_icon(void)
97 static void icon_animation_set(enum indicator_icon_ani type)
99 icon_ani_set(&call, type);
102 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)
106 if (connected) bt_state=1;
109 vconf_get_int(VCONFKEY_CALL_STATE, &status);
111 if (status != VCONFKEY_CALL_OFF) show_call_icon(user_data);
114 static void register_bt_state( void *data)
118 error = bt_initialize();
119 if (error != BT_ERROR_NONE) _E("bt_initialize return [%d]", error);
121 error = bt_audio_initialize();
122 if (error != BT_ERROR_NONE) _E("bt_audio_initialize return [%d]", error);
124 error = bt_audio_set_connection_state_changed_cb(__bt_ag_sco_state_changed_cb, data); // callback µî·Ï
125 if (error != BT_ERROR_NONE) _E("bt_ag_set_sco_state_changed_cb return [%d]", error);
129 static void unregister_bt_state( void )
133 error = bt_audio_unset_connection_state_changed_cb();
134 if (error != BT_ERROR_NONE) _E("bt_ag_unset_sco_state_changed_cb return [%d]", error);
136 error = bt_audio_deinitialize();
137 if (error != BT_ERROR_NONE) _E("bt_audio_deinitialize return [%d]", error);
139 error = bt_deinitialize();
140 if (error != BT_ERROR_NONE) _E("bt_audio_deinitialize return [%d]", error);
143 static void show_call_icon( void *data)
150 ret = vconf_get_int(VCONFKEY_CALL_STATE, &status);
152 _E("Failed to get VCONFKEY_CALL_STATE!");
157 case VCONFKEY_CALL_VOICE_CONNECTING:
158 case VCONFKEY_CALL_VIDEO_CONNECTING:
159 show_image_icon(data);
160 icon_animation_set(ICON_ANI_BLINK);
162 case VCONFKEY_CALL_VOICE_ACTIVE:
163 case VCONFKEY_CALL_VIDEO_ACTIVE:
164 show_image_icon(data);
165 icon_animation_set(ICON_ANI_NONE);
167 case VCONFKEY_CALL_OFF:
171 _E("Invalid value %d", status);
176 static void indicator_call_change_cb(keynode_t *node, void *data)
184 ret = vconf_get_int(VCONFKEY_CALL_STATE, &status);
186 _E("Failed to get VCONFKEY_CALL_STATE!");
191 case VCONFKEY_CALL_VOICE_CONNECTING:
192 case VCONFKEY_CALL_VIDEO_CONNECTING:
193 show_image_icon(data);
194 icon_animation_set(ICON_ANI_BLINK);
196 case VCONFKEY_CALL_VOICE_ACTIVE:
197 case VCONFKEY_CALL_VIDEO_ACTIVE:
198 show_image_icon(data);
199 icon_animation_set(ICON_ANI_NONE);
201 case VCONFKEY_CALL_OFF:
205 _E("Invalid value %d", status);
210 static int register_call_module(void *data)
218 ret = vconf_notify_key_changed(VCONFKEY_CALL_STATE, indicator_call_change_cb, data);
219 register_bt_state(data);
220 if (ret != OK) _E("Failed to register VCONFKEY_CALL_STATE callback!");
225 static int unregister_call_module(void)
229 ret = vconf_ignore_key_changed(VCONFKEY_CALL_STATE, indicator_call_change_cb);
230 unregister_bt_state();
231 if (ret != OK) _E("Failed to register VCONFKEY_CALL_STATE callback!");