2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
21 #include "bluetooth-api.h"
22 #include "bt-internal-types.h"
24 #include "bt-service-common.h"
25 #include "bt-service-event.h"
27 static GDBusConnection *event_conn;
28 static GDBusConnection *hf_local_term_event_conn;
30 #ifdef TIZEN_FEATURE_BT_HPS
31 int _bt_send_to_hps(void)
38 retv_if(event_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
40 ret = g_dbus_connection_emit_signal(event_conn, NULL,
41 "/org/projectx/httpproxy",
42 "org.projectx.httpproxy_service",
47 BT_ERR("D-Bus API failure: errCode[%x], \
49 error->code, error->message);
50 g_clear_error(&error);
52 return BLUETOOTH_ERROR_INTERNAL;
55 return BLUETOOTH_ERROR_NONE;
59 int _bt_send_event(int event_type, int event, GVariant *param)
63 GDBusMessage *msg1 = NULL;
65 retv_if(event_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
67 BT_DBG("event_type [%d], event [%d]", event_type, event);
70 case BT_ADAPTER_EVENT:
71 path = BT_ADAPTER_PATH;
73 case BT_LE_ADAPTER_EVENT:
74 path = BT_LE_ADAPTER_PATH;
77 path = BT_DEVICE_PATH;
82 case BT_HID_DEVICE_EVENT:
83 path = BT_HID_DEVICE_PATH;
85 case BT_HEADSET_EVENT:
86 path = BT_HEADSET_PATH;
91 case BT_AVRCP_CONTROL_EVENT:
92 path = BT_AVRCP_CONTROL_PATH;
94 case BT_NETWORK_EVENT:
95 path = BT_NETWORK_PATH;
97 case BT_OPP_CLIENT_EVENT:
98 path = BT_OPP_CLIENT_PATH;
100 case BT_OPP_SERVER_EVENT:
101 path = BT_OPP_SERVER_PATH;
103 case BT_MAP_CLIENT_EVENT:
104 path = BT_MAP_CLIENT_PATH;
106 case BT_PBAP_CLIENT_EVENT:
107 path = BT_PBAP_CLIENT_PATH;
109 case BT_RFCOMM_CLIENT_EVENT:
110 path = BT_RFCOMM_CLIENT_PATH;
112 case BT_RFCOMM_SERVER_EVENT:
113 path = BT_RFCOMM_SERVER_PATH;
115 case BT_A2DP_SOURCE_EVENT:
116 path = BT_A2DP_SOURCE_PATH;
122 case BT_GATT_SERVER_EVENT:
123 path = BT_GATT_SERVER_PATH;
126 #ifdef TIZEN_GATT_CLIENT
127 case BT_GATT_CLIENT_EVENT:
128 path = BT_GATT_CLIENT_PATH;
132 #ifdef TIZEN_FEATURE_BT_AVC_TARGET
133 case BT_AUDIO_AVC_EVENT:
134 path = BT_AUDIO_AVC_PATH;
138 BT_ERR("Unknown event");
139 return BLUETOOTH_ERROR_INTERNAL;
143 case BLUETOOTH_EVENT_ENABLED:
145 BT_INFO_C("### BT Enabled");
147 case BLUETOOTH_EVENT_DISABLED:
148 signal = BT_DISABLED;
149 BT_INFO_C("### BT Disabled");
151 case BLUETOOTH_EVENT_DISABLED_BATTERY_DATA:
152 signal = BT_DISABLED_BATTERY_DATA;
153 BT_INFO_C("### Sending battery data for last session");
155 case BLUETOOTH_EVENT_LE_ENABLED:
156 signal = BT_LE_ENABLED;
158 case BLUETOOTH_EVENT_LE_DISABLED:
159 signal = BT_LE_DISABLED;
161 case BLUETOOTH_EVENT_LOCAL_NAME_CHANGED:
162 signal = BT_ADAPTER_NAME_CHANGED;
164 case BLUETOOTH_EVENT_DISCOVERABLE_MODE_CHANGED:
165 signal = BT_DISCOVERABLE_MODE_CHANGED;
167 case BLUETOOTH_EVENT_DISCOVERABLE_TIMEOUT_CHANGED:
168 signal = BT_DISCOVERABLE_TIMEOUT_CHANGED;
170 case BLUETOOTH_EVENT_CONNECTABLE_CHANGED:
171 signal = BT_CONNECTABLE_CHANGED;
173 case BLUETOOTH_EVENT_DISCOVERY_STARTED:
174 signal = BT_DISCOVERY_STARTED;
176 case BLUETOOTH_EVENT_REMOTE_DEVICE_FOUND:
177 signal = BT_DEVICE_FOUND;
179 case BLUETOOTH_EVENT_DISCOVERY_FINISHED:
180 signal = BT_DISCOVERY_FINISHED;
182 case BLUETOOTH_EVENT_LE_DISCOVERY_STARTED:
183 signal = BT_LE_DISCOVERY_STARTED;
185 case BLUETOOTH_EVENT_REMOTE_LE_DEVICE_FOUND:
186 signal = BT_LE_DEVICE_FOUND;
188 case BLUETOOTH_EVENT_LE_DISCOVERY_FINISHED:
189 signal = BT_LE_DISCOVERY_FINISHED;
191 case BLUETOOTH_EVENT_ADVERTISING_STARTED:
192 signal = BT_ADVERTISING_STARTED;
194 case BLUETOOTH_EVENT_ADVERTISING_STOPPED:
195 signal = BT_ADVERTISING_STOPPED;
197 case BLUETOOTH_EVENT_ADVERTISING_MANUFACTURER_DATA_CHANGED:
198 signal = BT_ADVERTISING_MANUFACTURER_DATA_CHANGED;
200 case BLUETOOTH_EVENT_SCAN_RESPONSE_MANUFACTURER_DATA_CHANGED:
201 signal = BT_SCAN_RESPONSE_MANUFACTURER_DATA_CHANGED;
203 case BLUETOOTH_EVENT_MANUFACTURER_DATA_CHANGED:
204 signal = BT_MANUFACTURER_DATA_CHANGED;
206 case BLUETOOTH_EVENT_BONDING_FINISHED:
207 signal = BT_BOND_CREATED;
209 case BLUETOOTH_EVENT_BONDED_DEVICE_REMOVED:
210 signal = BT_BOND_DESTROYED;
212 case BLUETOOTH_EVENT_DEVICE_AUTHORIZED:
213 signal = BT_DEVICE_AUTHORIZED;
215 case BLUETOOTH_EVENT_DEVICE_UNAUTHORIZED:
216 signal = BT_DEVICE_UNAUTHORIZED;
218 case BLUETOOTH_EVENT_RSSI_ENABLED:
219 signal = BT_RSSI_MONITORING_ENABLED;
221 case BLUETOOTH_EVENT_RSSI_ALERT:
222 signal = BT_RSSI_ALERT;
224 case BLUETOOTH_EVENT_RAW_RSSI:
225 signal = BT_RAW_RSSI_EVENT;
227 case BLUETOOTH_EVENT_SUPPORTED_PROFILE_TRUSTED:
228 signal = BT_SUPPORTED_PROFILE_TRUSTED;
230 case BLUETOOTH_EVENT_KEYBOARD_PASSKEY_DISPLAY:
231 signal = BT_KBD_PASSKEY_DISPLAY_REQ_RECEIVED;
233 case BLUETOOTH_EVENT_PIN_REQUEST:
234 signal = BT_PIN_REQ_RECEIVED;
236 case BLUETOOTH_EVENT_PASSKEY_REQUEST:
237 signal = BT_PASSKEY_REQ_RECEIVED;
239 case BLUETOOTH_EVENT_PASSKEY_CONFIRM_REQUEST:
240 signal = BT_PASSKEY_CFM_REQ_RECEIVED;
242 case BLUETOOTH_EVENT_SERVICE_SEARCHED:
243 signal = BT_SERVICE_SEARCHED;
245 case BLUETOOTH_HID_CONNECTED:
246 signal = BT_INPUT_CONNECTED;
247 BT_INFO_C("### Connected [HID]");
249 case BLUETOOTH_HID_DISCONNECTED:
250 signal = BT_INPUT_DISCONNECTED;
251 BT_INFO_C("### Disconnected [HID]");
253 case BLUETOOTH_HID_DEVICE_CONNECTED:
254 signal = BT_INPUT_HID_DEVICE_CONNECTED;
255 BT_INFO_C("### Connected [HIDDevice]");
257 case BLUETOOTH_HID_DEVICE_DISCONNECTED:
258 signal = BT_INPUT_HID_DEVICE_DISCONNECTED;
259 BT_INFO_C("### Disconnected [HIDDevice]");
261 case BLUETOOTH_PBAP_CONNECTED:
262 signal = BT_PBAP_CONNECTED;
263 BT_INFO_C("### Connected [PBAP Client]");
265 case BLUETOOTH_PBAP_DISCONNECTED:
266 signal = BT_PBAP_DISCONNECTED;
267 BT_INFO_C("### Disconnected [PBAP Client]");
269 case BLUETOOTH_PBAP_PHONEBOOK_SIZE:
270 signal = BT_PBAP_PHONEBOOK_SIZE;
272 case BLUETOOTH_PBAP_PHONEBOOK_PULL:
273 signal = BT_PBAP_PHONEBOOK_PULL;
275 case BLUETOOTH_PBAP_VCARD_LIST:
276 signal = BT_PBAP_VCARD_LIST;
278 case BLUETOOTH_PBAP_VCARD_PULL:
279 signal = BT_PBAP_VCARD_PULL;
281 case BLUETOOTH_PBAP_PHONEBOOK_SEARCH:
282 signal = BT_PBAP_SEARCH_PHONEBOOK;
284 case BLUETOOTH_EVENT_AG_CONNECTED:
285 signal = BT_HEADSET_CONNECTED;
286 BT_INFO_C("### Connected [HSP/HFP]");
288 case BLUETOOTH_EVENT_AG_DISCONNECTED:
289 signal = BT_HEADSET_DISCONNECTED;
290 BT_INFO_C("### Disconnected [HSP/HFP]");
292 case BLUETOOTH_EVENT_AV_CONNECTED:
293 signal = BT_STEREO_HEADSET_CONNECTED;
294 BT_INFO_C("### Connected [A2DP]");
296 case BLUETOOTH_EVENT_AV_DISCONNECTED:
297 signal = BT_STEREO_HEADSET_DISCONNECTED;
298 BT_INFO_C("### Disconnected [A2DP]");
300 case BLUETOOTH_EVENT_AV_SOURCE_CONNECTED:
301 signal = BT_A2DP_SOURCE_CONNECTED;
302 BT_INFO_C("### Connected [A2DP Source]");
304 case BLUETOOTH_EVENT_AV_SOURCE_DISCONNECTED:
305 signal = BT_A2DP_SOURCE_DISCONNECTED;
306 BT_INFO_C("### Disconnected [A2DP Source]");
308 case BLUETOOTH_EVENT_AG_AUDIO_CONNECTED:
309 signal = BT_SCO_CONNECTED;
310 BT_INFO_C("### Connected [SCO]");
312 case BLUETOOTH_EVENT_AG_AUDIO_DISCONNECTED:
313 signal = BT_SCO_DISCONNECTED;
314 BT_INFO_C("### Disonnected [SCO]");
316 case BLUETOOTH_EVENT_AG_SPEAKER_GAIN:
317 signal = BT_SPEAKER_GAIN;
319 case BLUETOOTH_EVENT_AG_MIC_GAIN:
320 signal = BT_MICROPHONE_GAIN;
322 case BLUETOOTH_EVENT_NETWORK_CONNECTED:
323 signal = BT_NETWORK_CONNECTED;
324 BT_INFO_C("Connected [Newwork]");
326 case BLUETOOTH_EVENT_NETWORK_DISCONNECTED:
327 signal = BT_NETWORK_DISCONNECTED;
328 BT_INFO_C("Disconnected [Newwork]");
330 case BLUETOOTH_EVENT_NETWORK_SERVER_CONNECTED:
331 signal = BT_NETWORK_SERVER_CONNECTED;
332 BT_INFO_C("Connected [Network Server]");
334 case BLUETOOTH_EVENT_NETWORK_SERVER_DISCONNECTED:
335 signal = BT_NETWORK_SERVER_DISCONNECTED;
336 BT_INFO_C("Disconnected [Network Server]");
338 case BLUETOOTH_EVENT_OPC_CONNECTED:
339 signal = BT_OPP_CONNECTED;
340 BT_INFO_C("Connected [OPP]");
342 case BLUETOOTH_EVENT_OPC_DISCONNECTED:
343 signal = BT_OPP_DISCONNECTED;
344 BT_INFO_C("Disconnected [OPP]");
346 case BLUETOOTH_EVENT_MAP_CONNECTED:
347 signal = BT_MAP_CONNECTED;
348 BT_INFO_C("Connected [MAP]");
350 case BLUETOOTH_EVENT_MAP_DISCONNECTED:
351 signal = BT_MAP_DISCONNECTED;
352 BT_INFO_C("Disconnected [MAP]");
354 case BLUETOOTH_EVENT_MAP_LIST_FOLDERS_COMPLETE:
355 signal = BT_MAP_LIST_FOLDERS_COMPLETE;
356 BT_INFO_C("Completed list folders operation[MAP]");
358 case BLUETOOTH_EVENT_MAP_LIST_FILTER_FIELD_COMPLETE:
359 signal = BT_MAP_FILTER_FIELDS_COMPLETE;
360 BT_INFO_C("Completed list filters field operation[MAP]");
362 case BLUETOOTH_EVENT_MAP_LIST_MESSAGES_COMPLETE:
363 signal = BT_MAP_LIST_MESSAGES_COMPLETE;
364 BT_INFO_C("Completed list messages operation [MAP]");
366 case BLUETOOTH_EVENT_MAP_GET_MESSAGE_COMPLETE:
367 signal = BT_MAP_GET_MESSAGE_COMPLETE;
368 BT_INFO_C("Completed get message operation [MAP]");
370 case BLUETOOTH_EVENT_MAP_PUSH_MESSAGE_COMPLETE:
371 signal = BT_MAP_PUSH_MESSAGE_COMPLETE;
372 BT_INFO_C("Completed push message operation [MAP]");
374 case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_CONNECTED:
375 signal = BT_TRANSFER_CONNECTED;
377 case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_DISCONNECTED:
378 signal = BT_TRANSFER_DISCONNECTED;
380 case BLUETOOTH_EVENT_OPC_TRANSFER_STARTED:
381 case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_STARTED:
382 signal = BT_TRANSFER_STARTED;
384 case BLUETOOTH_EVENT_OPC_TRANSFER_PROGRESS:
385 case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_PROGRESS:
386 signal = BT_TRANSFER_PROGRESS;
388 case BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE:
389 case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_COMPLETED:
390 signal = BT_TRANSFER_COMPLETED;
392 case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_AUTHORIZE:
393 signal = BT_TRANSFER_AUTHORIZED;
395 case BLUETOOTH_EVENT_OBEX_SERVER_CONNECTION_AUTHORIZE:
396 case BLUETOOTH_EVENT_RFCOMM_AUTHORIZE:
397 signal = BT_CONNECTION_AUTHORIZED;
399 case BLUETOOTH_EVENT_RFCOMM_CONNECTED:
400 signal = BT_RFCOMM_CONNECTED;
402 case BLUETOOTH_EVENT_RFCOMM_DISCONNECTED:
403 signal = BT_RFCOMM_DISCONNECTED;
405 case BLUETOOTH_EVENT_RFCOMM_DATA_RECEIVED:
406 signal = BT_RFCOMM_DATA_RECEIVED;
408 case BLUETOOTH_EVENT_RFCOMM_SERVER_REMOVED:
409 signal = BT_RFCOMM_SERVER_REMOVED;
411 case BLUETOOTH_EVENT_DEVICE_CONNECTED:
412 signal = BT_DEVICE_CONNECTED;
414 case BLUETOOTH_EVENT_DEVICE_DISCONNECTED:
415 signal = BT_DEVICE_DISCONNECTED;
417 case BLUETOOTH_EVENT_AVRCP_CONNECTED:
418 case BLUETOOTH_EVENT_AVRCP_CONTROL_CONNECTED:
419 signal = BT_AVRCP_CONNECTED;
420 BT_INFO_C("Connected [AVRCP]");
422 case BLUETOOTH_EVENT_AVRCP_DISCONNECTED:
423 case BLUETOOTH_EVENT_AVRCP_CONTROL_DISCONNECTED:
424 signal = BT_AVRCP_DISCONNECTED;
425 BT_INFO_C("Disconnected [AVRCP]");
427 case BLUETOOTH_EVENT_AVRCP_SETTING_SHUFFLE_STATUS:
428 case BLUETOOTH_EVENT_AVRCP_CONTROL_SHUFFLE_STATUS:
429 signal = BT_MEDIA_SHUFFLE_STATUS;
431 case BLUETOOTH_EVENT_AVRCP_SETTING_EQUALIZER_STATUS:
432 case BLUETOOTH_EVENT_AVRCP_CONTROL_EQUALIZER_STATUS:
433 signal = BT_MEDIA_EQUALIZER_STATUS;
435 case BLUETOOTH_EVENT_AVRCP_SETTING_REPEAT_STATUS:
436 case BLUETOOTH_EVENT_AVRCP_CONTROL_REPEAT_STATUS:
437 signal = BT_MEDIA_REPEAT_STATUS;
439 case BLUETOOTH_EVENT_AVRCP_SETTING_SCAN_STATUS:
440 case BLUETOOTH_EVENT_AVRCP_CONTROL_SCAN_STATUS:
441 signal = BT_MEDIA_SCAN_STATUS;
443 case BLUETOOTH_EVENT_AVRCP_SONG_POSITION_STATUS:
444 signal = BT_MEDIA_POSITION_STATUS;
446 case BLUETOOTH_EVENT_AVRCP_PLAY_STATUS_CHANGED:
447 signal = BT_MEDIA_PLAY_STATUS;
449 case BLUETOOTH_EVENT_AVRCP_TRACK_CHANGED:
450 signal = BT_MEDIA_TRACK_CHANGE;
452 case BLUETOOTH_EVENT_AVRCP_DELAY_CHANGED:
453 signal = BT_MEDIA_DELAY_CHANGE;
455 case BLUETOOTH_EVENT_AVRCP_VOLUME_CHANGED:
456 signal = BT_MEDIA_VOLUME_CHANGE;
458 #ifdef TIZEN_GATT_CLIENT
459 case BLUETOOTH_EVENT_GATT_SERVER_CONNECTED: /* GATT Server and Client */
460 signal = BT_GATT_SERVER_CONNECTED;
461 BT_INFO_C("### Connected [GATT server]");
463 case BLUETOOTH_EVENT_GATT_SERVER_DISCONNECTED: /* GATT Client and Server */
464 signal = BT_GATT_SERVER_DISCONNECTED;
465 BT_INFO_C("### Disconnected [GATT server]");
467 case BLUETOOTH_EVENT_GATT_CLIENT_CONNECTED: /* GATT Server and Client */
468 signal = BT_GATT_CLIENT_CONNECTED;
469 BT_INFO_C("### Connected [GATT client]");
471 case BLUETOOTH_EVENT_GATT_CLIENT_DISCONNECTED: /* GATT Client and Server */
472 signal = BT_GATT_CLIENT_DISCONNECTED;
473 BT_INFO_C("### Disconnected [GATT client]");
476 case BLUETOOTH_EVENT_GATT_CONNECTED:
477 signal = BT_GATT_CONNECTED;
478 BT_INFO_C("### Connected [GATT]");
480 case BLUETOOTH_EVENT_GATT_DISCONNECTED:
481 signal = BT_GATT_DISCONNECTED;
482 BT_INFO_C("### Disconnected [GATT]");
485 case BLUETOOTH_EVENT_GATT_ATT_MTU_CHANGED:
486 signal = BT_GATT_REQ_ATT_MTU_CHANGED;
488 case BLUETOOTH_EVENT_GATT_SERVER_ATT_MTU_CHANGED:
489 signal = BT_GATT_SERVER_ATT_MTU_CHANGED;
492 case BLUETOOTH_EVENT_GATT_SERVER_VALUE_CHANGED:
493 signal = BT_GATT_VALUE_CHANGED;
495 case BLUETOOTH_EVENT_GATT_SERVER_READ_REQUESTED:
496 signal = BT_GATT_SERVER_READ_REQ;
498 case BLUETOOTH_EVENT_GATT_SERVER_NOTIFICATION_COMPLETED:
499 signal = BT_GATT_SERVER_NOTIFICATION_COMPLETED;
501 case BLUETOOTH_EVENT_GATT_SERVER_NOTIFICATION_STATE_CHANGED:
502 signal = BT_GATT_SERVER_NOTIFICATION_CHANGED;
504 case BLUETOOTH_EVENT_GATT_SERVER_ACQUIRE_WRITE:
505 signal = BT_GATT_SERVER_ACQUIRE_WRITE;
507 case BLUETOOTH_EVENT_GATT_SERVER_ACQUIRE_NOTIFY:
508 signal = BT_GATT_SERVER_ACQUIRE_NOTIFICATION;
511 #ifdef TIZEN_GATT_CLIENT
512 case BLUETOOTH_EVENT_GATT_READ_CHAR: /* GATT Client */
513 signal = BT_GATT_CLIENT_READ_CHAR;
515 case BLUETOOTH_EVENT_GATT_WRITE_CHAR: /* GATT Client */
516 signal = BT_GATT_CLIENT_WRITE_CHAR;
518 case BLUETOOTH_EVENT_GATT_READ_DESC: /* GATT Client */
519 signal = BT_GATT_CLIENT_READ_DESC;
521 case BLUETOOTH_EVENT_GATT_WRITE_DESC: /* GATT Client */
522 signal = BT_GATT_CLIENT_WRITE_DESC;
524 case BLUETOOTH_EVENT_GATT_CLIENT_SERVICE_CHANGED: /* GATT Client */
525 signal = BT_GATT_CLIENT_SERVICE_CHANGED;
529 case BLUETOOTH_EVENT_IPSP_INIT_STATE_CHANGED:
530 signal = BT_IPSP_INITIALIZED;
532 case BLUETOOTH_EVENT_IPSP_CONNECTED:
533 signal = BT_IPSP_CONNECTED;
535 case BLUETOOTH_EVENT_IPSP_DISCONNECTED:
536 signal = BT_IPSP_DISCONNECTED;
538 case BLUETOOTH_EVENT_GATT_CHAR_VAL_CHANGED:
539 signal = BT_GATT_CHAR_VAL_CHANGED;
541 case BLUETOOTH_EVENT_LE_DATA_LENGTH_CHANGED:
542 signal = BT_LE_DATA_LENGTH_CHANGED;
544 case BLUETOOTH_EVENT_PXP_PROPERTY_CHANGED:
545 signal = BT_PXP_PROPERTY_CHANGED;
547 case BLUETOOTH_EVENT_OTP_SERVER_STATE_CHANGED:
548 signal = BT_OTP_SERVER_STATE_CHANGED;
550 case BLUETOOTH_EVENT_OTC_STATE_CHANGED:
551 signal = BT_OTC_STATE_CHANGED;
553 #ifdef TIZEN_FEATURE_BT_AVC_TARGET
554 case BLUETOOTH_EVENT_AUDIO_AVC_MODE_CHANGED:
555 signal = BT_AUDIO_AVC_MODE_CHANGED;
559 BT_ERR("Unknown event");
560 return BLUETOOTH_ERROR_INTERNAL;
563 BT_DBG("Path : %s", path);
564 BT_INFO_C("Signal : %s", signal);
566 msg1 = g_dbus_message_new_signal(path, BT_EVENT_SERVICE, signal);
567 g_dbus_message_set_body(msg1, param);
568 if (!g_dbus_connection_send_message(event_conn, msg1, G_DBUS_SEND_MESSAGE_FLAGS_NONE, 0, NULL))
569 BT_ERR("Error while sending");
571 g_object_unref(msg1);
573 #ifdef TIZEN_FEATURE_BT_HPS
574 if (g_strcmp0(signal, BT_LE_ENABLED) == 0)
578 return BLUETOOTH_ERROR_NONE;
581 int _bt_send_event_to_dest(const char* dest, int event_type,
582 int event, GVariant *param)
586 GError *error = NULL;
588 retv_if(event_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
590 BT_DBG("event_type [%d], event [%d]", event_type, event);
592 switch (event_type) {
593 case BT_ADAPTER_EVENT:
594 path = BT_ADAPTER_PATH;
596 case BT_LE_ADAPTER_EVENT:
597 path = BT_LE_ADAPTER_PATH;
599 case BT_DEVICE_EVENT:
600 path = BT_DEVICE_PATH;
609 path = BT_HDP_DEVICE_PATH;
612 BT_ERR("Unknown event");
613 return BLUETOOTH_ERROR_INTERNAL;
617 case BLUETOOTH_EVENT_ADVERTISING_STARTED:
618 signal = BT_ADVERTISING_STARTED;
620 case BLUETOOTH_EVENT_ADVERTISING_STOPPED:
621 signal = BT_ADVERTISING_STOPPED;
623 case BLUETOOTH_EVENT_PASSKEY_NOTIFICATION:
624 signal = BT_PASSKEY_NOTIFICATION;
626 case BLUETOOTH_EVENT_LE_DISCOVERY_STARTED:
627 signal = BT_LE_DISCOVERY_STARTED;
629 case BLUETOOTH_EVENT_REMOTE_LE_DEVICE_FOUND:
630 signal = BT_LE_DEVICE_FOUND;
632 case BLUETOOTH_EVENT_LE_DISCOVERY_FINISHED:
633 signal = BT_LE_DISCOVERY_FINISHED;
635 case BLUETOOTH_EVENT_GATT_CHAR_VAL_CHANGED:
636 signal = BT_GATT_CHAR_VAL_CHANGED;
638 case BLUETOOTH_EVENT_TDS_ACTIVATION_REQUESTED:
639 signal = BT_TDS_ACTIVATION_REQUESTED;
641 case BLUETOOTH_EVENT_TDS_TRANSPORT_DATA_RECEIVED:
642 signal = BT_TDS_TRANSPORT_DATA_RECEIVED;
644 case BLUETOOTH_EVENT_TDS_ACTIVATION_INDICATION:
645 signal = BT_TDS_ACTIVATION_INDICATION;
647 case BLUETOOTH_EVENT_TDS_CONTROL_POINT_ENABLED:
648 signal = BT_TDS_CONTROL_POINT_ENABLED;
650 case BLUETOOTH_EVENT_TDS_ACTIVATION_RESULT:
651 signal = BT_TDS_ACTIVATION_RESULT;
653 case BLUETOOTH_EVENT_OTP_READ_CHAR_VAL:
654 signal = BT_OTP_READ_CHAR_VAL;
656 case BLUETOOTH_EVENT_OTP_NOTIFICATION_ENABLED:
657 signal = BT_OTP_NOTIFICATION_ENABLED;
659 case BLUETOOTH_EVENT_OTP_WRITE_CHAR_VAL:
660 signal = BT_OTP_WRITE_CHAR_VAL;
662 case BLUETOOTH_EVENT_OTP_INDICATION:
663 signal = BT_OTP_INDICATION;
665 case BLUETOOTH_EVENT_HDP_CONNECTED:
666 signal = BT_HDP_CONNECTED;
668 case BLUETOOTH_EVENT_HDP_DISCONNECTED:
669 signal = BT_HDP_DISCONNECTED;
672 BT_ERR("Unknown event");
673 return BLUETOOTH_ERROR_INTERNAL;
676 BT_INFO_C("Signal : %s", signal);
678 if (!g_dbus_connection_emit_signal(event_conn, dest, path, BT_EVENT_SERVICE,
679 signal, param, &error)) {
680 BT_ERR("Error while sending Signal: %s", signal);
682 BT_ERR("Error Code [%d], Error Message [%s]",
683 error->code, error->message);
684 g_clear_error(&error);
688 return BLUETOOTH_ERROR_NONE;
691 int _bt_send_hf_local_term_event(char *address)
693 GError *error = NULL;
695 retv_if(hf_local_term_event_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
697 if (!g_dbus_connection_emit_signal(hf_local_term_event_conn, NULL,
698 BT_HF_LOCAL_TERM_EVENT_PATH,
699 BT_HF_LOCAL_TERM_EVENT_INTERFACE,
700 BT_HF_LOCAL_TERM, g_variant_new("s", address),
702 BT_ERR("Error while sending Signal: %s", address);
704 BT_ERR("Error Code [%d], Error Message [%s]",
705 error->code, error->message);
706 g_clear_error(&error);
710 return BLUETOOTH_ERROR_NONE;
713 /* To send the event from service daemon to application*/
714 int _bt_init_service_event_sender(void)
716 GDBusConnection *conn;
720 BT_ERR("Event handler is already exist");
721 return BLUETOOTH_ERROR_INTERNAL;
724 conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
727 BT_ERR("conn == NULL");
729 BT_ERR("Code[%d], Message[%s]",
730 err->code, err->message);
734 return BLUETOOTH_ERROR_INTERNAL;
738 return BLUETOOTH_ERROR_NONE;
741 void _bt_deinit_service_event_sender(void)
744 g_object_unref(event_conn);
749 int _bt_init_hf_local_term_event_sender(void)
751 GDBusConnection *conn;
754 if (hf_local_term_event_conn) {
755 BT_ERR("Event handler is already exist");
756 return BLUETOOTH_ERROR_INTERNAL;
759 conn = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
762 BT_ERR("conn == NULL");
764 BT_ERR("Code[%d], Message[%s]",
765 err->code, err->message);
769 return BLUETOOTH_ERROR_INTERNAL;
772 hf_local_term_event_conn = conn;
774 return BLUETOOTH_ERROR_NONE;
777 void _bt_deinit_hf_local_term_event_sender(void)
779 if (hf_local_term_event_conn) {
780 g_object_unref(hf_local_term_event_conn);
781 hf_local_term_event_conn = NULL;
785 int _bt_send_dump_signal(char *signal)
787 GError *error = NULL;
788 int32_t pid = getpid();
790 retv_if(event_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
792 if (!g_dbus_connection_emit_signal(event_conn, NULL,
793 BT_DUMP_SERVICE_PATH,
794 BT_DUMP_SERVICE_INTERFACE,
795 signal, g_variant_new("(i)", pid),
797 BT_ERR("Error while sending Signal: %s", signal);
799 BT_ERR("Error Code [%d], Error Message [%s]",
800 error->code, error->message);
801 g_clear_error(&error);
805 return BLUETOOTH_ERROR_NONE;