4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Hocheol Seo <hocheol.seo@samsung.com>
7 * Girishashok Joshi <girish.joshi@samsung.com>
8 * Chanyeol Park <chanyeol.park@samsung.com>
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
24 #include <dbus/dbus-glib.h>
25 #include <dbus/dbus.h>
29 #include <mime_type.h>
31 #include "bluetooth-api.h"
32 #include "bt-internal-types.h"
34 #include "bt-service-common.h"
35 #include "bt-service-event.h"
36 #include "bt-service-util.h"
37 #include "bt-service-opp-client.h"
38 #include "bt-service-obex-agent.h"
40 static GSList *transfer_list = NULL;
42 bt_sending_info_t *sending_info;
43 static int file_offset = 0;
45 static gboolean __bt_sending_release();
46 static void _bt_remove_session();
48 static int __bt_opp_client_start_sending(int request_id, char *address,
49 char **file_name_array, int file_count);
51 static GQuark __bt_opc_error_quark(void)
53 static GQuark quark = 0;
55 quark = g_quark_from_static_string("agent");
60 static void __bt_free_transfer_info(bt_transfer_info_t *info)
65 g_object_unref(info->proxy);
67 if (info->properties_proxy)
68 g_object_unref(info->properties_proxy);
71 g_free(info->transfer_name);
72 g_free(info->file_name);
76 static void __bt_free_sending_info(bt_sending_info_t *info)
80 /* Free the sending variable */
81 __bt_free_transfer_info(info->transfer_info);
83 g_free(info->file_name_array);
85 g_free(info->address);
89 static void __bt_value_free(GValue *value)
95 static gboolean __bt_cancel_push_cb(gpointer data)
99 int result = BLUETOOTH_ERROR_CANCEL_BY_USER;
101 retv_if(sending_info == NULL, FALSE);
102 sending_info->result = result;
104 /* Send the event in only error none case */
105 _bt_send_event(BT_OPP_CLIENT_EVENT,
106 BLUETOOTH_EVENT_OPC_CONNECTED,
107 DBUS_TYPE_INT32, &result,
108 DBUS_TYPE_STRING, &sending_info->address,
109 DBUS_TYPE_INT32, &sending_info->request_id,
112 __bt_free_sending_info(sending_info);
115 _bt_opp_client_event_deinit();
117 BT_DBG("Length of transfer list is %d", g_slist_length(transfer_list));
119 /*Operate remain works*/
120 if (g_slist_length(transfer_list) > 0) {
121 bt_sending_data_t *node = NULL;
123 node = transfer_list->data;
125 BT_ERR("data is NULL");
129 transfer_list = g_slist_remove(transfer_list, node);
131 if (__bt_opp_client_start_sending(node->request_id,
132 node->address, node->file_path,
133 node->file_count) != BLUETOOTH_ERROR_NONE) {
134 BT_ERR("Fail to start sending");
141 gboolean _bt_obex_client_progress(const char *transfer_path, int transferred)
145 int percentage_progress;
147 int result = BLUETOOTH_ERROR_NONE;
149 retv_if(sending_info == NULL, TRUE);
150 retv_if(sending_info->transfer_info == NULL, TRUE);
152 if (g_strcmp0(sending_info->transfer_info->transfer_path,
153 transfer_path) != 0) {
154 BT_INFO("Path mismatch, previous transfer failed! Returning");
158 size = sending_info->transfer_info->size;
161 percentage_progress = (int)(((gdouble)transferred /
162 (gdouble)size) * 100);
164 percentage_progress = 0;
166 sending_info->transfer_info->transfer_status = BT_TRANSFER_STATUS_PROGRESS;
167 sending_info->result = result;
169 /* Send the event in only error none case */
170 _bt_send_event(BT_OPP_CLIENT_EVENT,
171 BLUETOOTH_EVENT_OPC_TRANSFER_PROGRESS,
172 DBUS_TYPE_INT32, &result,
173 DBUS_TYPE_STRING, &sending_info->transfer_info->file_name,
174 DBUS_TYPE_UINT64, &sending_info->transfer_info->size,
175 DBUS_TYPE_INT32, &percentage_progress,
176 DBUS_TYPE_INT32, &sending_info->request_id,
184 gboolean _bt_obex_client_completed(const char *transfer_path, gboolean success)
188 int result = BLUETOOTH_ERROR_NONE;
190 retv_if(sending_info == NULL, TRUE);
191 retv_if(sending_info->transfer_info == NULL, TRUE);
193 if (g_strcmp0(sending_info->transfer_info->transfer_path,
194 transfer_path) != 0) {
195 BT_INFO("Path mismatch, previous transfer failed! Returning");
199 result = (success == TRUE) ? BLUETOOTH_ERROR_NONE : BLUETOOTH_ERROR_CANCEL;
201 sending_info->transfer_info->transfer_status = BT_TRANSFER_STATUS_COMPLETED;
202 sending_info->result = result;
204 if (!success) { /*In case of remote device reject, we need to send BLUETOOTH_EVENT_OPC_DISCONNECTED */
205 BT_DBG("completed with error");
206 if (!sending_info->is_canceled) {
207 _bt_send_event(BT_OPP_CLIENT_EVENT,
208 BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE,
209 DBUS_TYPE_INT32, &result,
210 DBUS_TYPE_STRING, &sending_info->transfer_info->file_name,
211 DBUS_TYPE_UINT64, &sending_info->transfer_info->size,
212 DBUS_TYPE_INT32, &sending_info->request_id,
215 __bt_free_transfer_info(sending_info->transfer_info);
216 sending_info->transfer_info = NULL;
217 /* Reset the file offset as we will cancelled remaining files also */
221 _bt_send_event(BT_OPP_CLIENT_EVENT,
222 BLUETOOTH_EVENT_OPC_DISCONNECTED,
223 DBUS_TYPE_INT32, &sending_info->result,
224 DBUS_TYPE_STRING, &sending_info->address,
225 DBUS_TYPE_INT32, &sending_info->request_id,
228 __bt_sending_release();
229 /* Sending info should not freed after sending_release it's
230 * already freed in that API and if any pending request is
231 * present then it recreate sending_info again.
232 * And if we free it here then CreateSession method call will
233 * made but RemoveSession method call will not done.
236 BT_DBG("complete success");
237 /* Send the event in only error none case */
238 _bt_send_event(BT_OPP_CLIENT_EVENT,
239 BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE,
240 DBUS_TYPE_INT32, &result,
241 DBUS_TYPE_STRING, &sending_info->transfer_info->file_name,
242 DBUS_TYPE_UINT64, &sending_info->transfer_info->size,
243 DBUS_TYPE_INT32, &sending_info->request_id,
246 __bt_free_transfer_info(sending_info->transfer_info);
247 sending_info->transfer_info = NULL;
255 gboolean _bt_obex_client_started(const char *transfer_path)
259 int result = BLUETOOTH_ERROR_NONE;
261 DBusGConnection *g_conn;
262 DBusGProxy *properties_proxy;
263 DBusGProxy *transfer_proxy;
265 if (sending_info == NULL || sending_info->is_canceled == TRUE) {
266 result = BLUETOOTH_ERROR_CANCEL_BY_USER;
270 /* Get the session bus. */
271 g_conn = _bt_get_session_gconn();
272 retv_if(g_conn == NULL, FALSE);
274 properties_proxy = dbus_g_proxy_new_for_name(g_conn, BT_OBEXD_DBUS_NAME,
275 transfer_path, BT_PROPERTIES_INTERFACE);
277 retv_if(properties_proxy == NULL, FALSE);
279 sending_info->transfer_info->properties_proxy = properties_proxy;
281 transfer_proxy = dbus_g_proxy_new_for_name(g_conn, BT_OBEXD_DBUS_NAME,
282 transfer_path, BT_OBEX_TRANSFER_INTERFACE);
284 retv_if(transfer_proxy == NULL, FALSE);
286 sending_info->transfer_info->proxy = transfer_proxy;
288 sending_info->transfer_info->transfer_status = BT_TRANSFER_STATUS_STARTED;
289 sending_info->result = result;
291 _bt_send_event(BT_OPP_CLIENT_EVENT,
292 BLUETOOTH_EVENT_OPC_TRANSFER_STARTED,
293 DBUS_TYPE_INT32, &result,
294 DBUS_TYPE_STRING, &sending_info->transfer_info->file_name,
295 DBUS_TYPE_UINT64, &sending_info->transfer_info->size,
296 DBUS_TYPE_INT32, &sending_info->request_id,
302 error = g_error_new(__bt_opc_error_quark(), BT_OBEX_AGENT_ERROR_CANCEL,
311 static void __bt_free_sending_data(gpointer data)
314 bt_sending_data_t *info = data;
316 ret_if(info == NULL);
318 for (i = 0; i < info->file_count; i++) {
319 g_free(info->file_path[i]);
322 _bt_delete_request_id(info->request_id);
324 g_free(info->file_path);
325 g_free(info->address);
329 static void __bt_sending_release_cb(DBusGProxy *proxy, DBusGProxyCall *call,
333 ret_if(sending_info == NULL);
335 GError *error = NULL;
336 int result = BLUETOOTH_ERROR_NONE;
338 if (dbus_g_proxy_end_call(proxy, call, &error,
339 G_TYPE_INVALID) == FALSE) {
340 BT_ERR("%s", error->message);
343 result = BLUETOOTH_ERROR_INTERNAL;
346 BT_DBG("Session Removed");
349 sending_info->result = result;
350 /* Send the event in only error none case */
351 _bt_send_event(BT_OPP_CLIENT_EVENT,
352 BLUETOOTH_EVENT_OPC_DISCONNECTED,
353 DBUS_TYPE_INT32, &sending_info->result,
354 DBUS_TYPE_STRING, &sending_info->address,
355 DBUS_TYPE_INT32, &sending_info->request_id,
358 __bt_free_sending_info(sending_info);
361 _bt_opp_client_event_deinit();
363 /* Operate remain works */
364 if (g_slist_length(transfer_list) > 0) {
365 bt_sending_data_t *data = NULL;
367 data = transfer_list->data;
371 transfer_list = g_slist_remove(transfer_list, data);
373 BT_DBG("calling __bt_opp_client_start_sending");
375 if (__bt_opp_client_start_sending(data->request_id,
376 data->address, data->file_path,
377 data->file_count) != BLUETOOTH_ERROR_NONE) {
384 g_slist_free_full(transfer_list,
385 (GDestroyNotify)__bt_free_sending_data);
386 transfer_list = NULL;
393 static void _bt_remove_session()
395 DBusGConnection *g_conn;
396 DBusGProxy *session_proxy;
397 DBusGProxyCall *proxy_call;
399 g_conn = _bt_get_session_gconn();
400 ret_if(g_conn == NULL);
402 session_proxy = dbus_g_proxy_new_for_name(g_conn, BT_OBEXD_DBUS_NAME,
404 BT_OBEX_CLIENT_INTERFACE);
406 ret_if(session_proxy == NULL);
408 proxy_call = dbus_g_proxy_begin_call(session_proxy, "RemoveSession",
409 __bt_sending_release_cb, NULL, NULL,
410 DBUS_TYPE_G_OBJECT_PATH, sending_info->session_path,
412 if (proxy_call == NULL) {
413 BT_ERR("Fail to Remove session");
414 g_object_unref(session_proxy);
419 static gboolean __bt_sending_release()
423 retv_if(sending_info == NULL, FALSE);
425 _bt_remove_session();
430 void _bt_opc_disconnected(const char *session_path)
434 ret_if(sending_info == NULL);
436 if (g_strcmp0(sending_info->session_path,
437 session_path) != 0) {
438 BT_INFO("Path mismatch, previous transfer failed! Returning");
442 if (sending_info->transfer_info) {
443 BT_INFO("sending_info is not NULL");
444 if (sending_info->transfer_info->transfer_status == BT_TRANSFER_STATUS_PROGRESS ||
445 sending_info->transfer_info->transfer_status == BT_TRANSFER_STATUS_STARTED) {
446 BT_INFO("Abnormal termination");
448 _bt_send_event(BT_OPP_CLIENT_EVENT,
449 BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE,
450 DBUS_TYPE_INT32, &sending_info->result,
451 DBUS_TYPE_STRING, &sending_info->transfer_info->file_name,
452 DBUS_TYPE_UINT64, &sending_info->transfer_info->size,
453 DBUS_TYPE_INT32, &sending_info->request_id,
455 __bt_free_transfer_info(sending_info->transfer_info);
459 _bt_send_event(BT_OPP_CLIENT_EVENT,
460 BLUETOOTH_EVENT_OPC_DISCONNECTED,
461 DBUS_TYPE_INT32, &sending_info->result,
462 DBUS_TYPE_STRING, &sending_info->address,
463 DBUS_TYPE_INT32, &sending_info->request_id,
467 __bt_free_sending_info(sending_info);
473 void _bt_sending_files(void)
477 DBusGConnection *g_conn;
478 DBusGProxy *client_proxy;
481 GHashTable *hash = NULL;
482 GValue *value = NULL;
483 const char *transfer_name;
484 const char *file_name;
486 char *mimetype = NULL;
490 if (sending_info == NULL)
493 if (file_offset < sending_info->file_count){
494 /* Get the session bus. */
495 g_conn = _bt_get_session_gconn();
496 ret_if(g_conn == NULL);
498 client_proxy = dbus_g_proxy_new_for_name(g_conn,
500 sending_info->session_path,
501 BT_OBEX_OBJECT_PUSH_INTERFACE);
503 ret_if(client_proxy == NULL);
505 BT_DBG("Calling SendFile");
506 ext = strrchr(sending_info->file_name_array[file_offset], '.');
508 if(!strcmp(ext+1, "imy"))
509 mimetype = g_strdup("audio/imelody");
511 if (!dbus_g_proxy_call(client_proxy, "SendFile", &err,
513 sending_info->file_name_array[file_offset],
514 G_TYPE_STRING, mimetype,
515 G_TYPE_INVALID, DBUS_TYPE_G_OBJECT_PATH, &path,
516 dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
517 &hash, G_TYPE_INVALID)) {
519 BT_ERR("Calling SendFile failed: [%s]\n", err->message);
531 __bt_free_transfer_info(sending_info->transfer_info);
533 sending_info->transfer_info = g_malloc0(sizeof(bt_transfer_info_t));
535 value = g_hash_table_lookup(hash, "Name");
536 transfer_name = value ? g_value_get_string(value) : NULL;
538 value = g_hash_table_lookup(hash, "Filename");
539 file_name = value ? g_value_get_string(value) : NULL;
541 value = g_hash_table_lookup(hash, "Size");
542 size = value ? g_value_get_uint64(value) : 0;
544 sending_info->transfer_info->transfer_name = g_strdup(transfer_name);
545 sending_info->transfer_info->file_name = g_strdup(file_name);
546 sending_info->transfer_info->size = size;
547 sending_info->transfer_info->transfer_path = path;
548 sending_info->transfer_info->transfer_status = BT_TRANSFER_STATUS_QUEUED;
549 sending_info->result = BLUETOOTH_ERROR_NONE;
551 g_hash_table_destroy(hash);
556 __bt_sending_release();
562 static void __bt_create_session_cb(DBusGProxy *proxy, DBusGProxyCall *call,
567 GError *error = NULL;
568 int result = BLUETOOTH_ERROR_NONE;
569 char *session_path = NULL;
571 if (dbus_g_proxy_end_call(proxy, call, &error,
572 DBUS_TYPE_G_OBJECT_PATH, &session_path, G_TYPE_INVALID) == FALSE) {
574 BT_ERR("%s", error->message);
577 result = BLUETOOTH_ERROR_INTERNAL;
579 BT_DBG("Session created");
580 if(sending_info != NULL)
581 sending_info->session_path = g_strdup(session_path);
583 g_free(session_path);
584 g_object_unref(proxy);
585 ret_if(sending_info == NULL);
587 sending_info->sending_proxy = NULL;
588 sending_info->result = result;
590 /* Send the event in only error none case */
591 _bt_send_event(BT_OPP_CLIENT_EVENT,
592 BLUETOOTH_EVENT_OPC_CONNECTED,
593 DBUS_TYPE_INT32, &result,
594 DBUS_TYPE_STRING, &sending_info->address,
595 DBUS_TYPE_INT32, &sending_info->request_id,
598 if (result != BLUETOOTH_ERROR_NONE) {
599 BT_ERR("Calling __bt_sending_release");
600 __bt_sending_release();
602 __bt_free_sending_info(sending_info);
605 BT_DBG("Calling sending_files");
612 static int __bt_opp_client_start_sending(int request_id, char *address,
613 char **file_name_array, int file_count)
619 DBusGConnection *g_conn;
620 DBusGProxy *client_proxy;
621 DBusGProxyCall *proxy_call;
625 BT_CHECK_PARAMETER(address, return);
626 BT_CHECK_PARAMETER(file_name_array, return);
628 /* Get the session bus. */
629 g_conn = _bt_get_session_gconn();
630 retv_if(g_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
632 client_proxy = dbus_g_proxy_new_for_name(g_conn, BT_OBEX_SERVICE_NAME,
633 BT_OBEX_CLIENT_PATH, BT_OBEX_CLIENT_INTERFACE);
635 retv_if(client_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
637 BT_DBG("client_proxy is not NULL");
639 hash = g_hash_table_new_full(g_str_hash, g_str_equal,
640 NULL, (GDestroyNotify)__bt_value_free);
642 value = g_new0(GValue, 1);
643 g_value_init(value, G_TYPE_STRING);
645 g_value_set_string(value, "OPP");
646 g_hash_table_insert(hash, "Target", value);
647 BT_DBG("Hash Table success");
649 __bt_free_sending_info(sending_info);
651 sending_info = g_malloc0(sizeof(bt_sending_info_t));
652 sending_info->address = g_strdup(address);
653 sending_info->request_id = request_id;
655 sending_info->file_count = file_count;
656 sending_info->file_offset = 0;
657 sending_info->file_name_array = g_new0(char *, file_count + 1);
659 for (i = 0; i < file_count; i++) {
660 sending_info->file_name_array[i] = g_strdup(file_name_array[i]);
661 BT_DBG("file[%d]: %s", i, sending_info->file_name_array[i]);
664 _bt_opp_client_event_deinit();
665 _bt_opp_client_event_init();
666 //_bt_obex_client_started(agent_path);
668 BT_DBG("Going to call CreateSession");
670 proxy_call = dbus_g_proxy_begin_call(client_proxy, "CreateSession",
671 __bt_create_session_cb, NULL, NULL,
672 G_TYPE_STRING, address,
673 dbus_g_type_get_map("GHashTable", G_TYPE_STRING, G_TYPE_VALUE),
674 hash, G_TYPE_INVALID);
676 if (proxy_call == NULL) {
677 BT_ERR("Fail to Send files");
678 g_hash_table_destroy(hash);
679 g_object_unref(client_proxy);
680 __bt_free_sending_info(sending_info);
681 _bt_opp_client_event_deinit();
683 return BLUETOOTH_ERROR_INTERNAL;
686 BT_DBG("After CreateSession");
688 sending_info->sending_proxy = proxy_call;
689 g_hash_table_destroy(hash);
693 return BLUETOOTH_ERROR_NONE;
697 int _bt_opp_client_push_files(int request_id, DBusGMethodInvocation *context,
698 bluetooth_device_address_t *remote_address,
699 char **file_path, int file_count)
702 char address[BT_ADDRESS_STRING_SIZE] = { 0 };
703 bt_sending_data_t *data;
705 GArray *out_param1 = NULL;
706 GArray *out_param2 = NULL;
708 int result = BLUETOOTH_ERROR_NONE;
711 BT_CHECK_PARAMETER(remote_address, return);
712 BT_CHECK_PARAMETER(file_path, return);
714 /* Implement the queue */
715 _bt_convert_addr_type_to_string(address, remote_address->addr);
717 if (sending_info == NULL) {
718 result = __bt_opp_client_start_sending(request_id,
719 address, file_path, file_count);
720 if (result != BLUETOOTH_ERROR_NONE)
723 /* Insert data in the queue */
724 data = g_malloc0(sizeof(bt_sending_data_t));
725 data->file_path = g_new0(char *, file_count + 1);
726 data->address = g_strdup(address);
727 data->file_count = file_count;
728 data->request_id = request_id;
730 for (i = 0; i < file_count; i++) {
731 data->file_path[i] = g_strdup(file_path[i]);
732 DBG_SECURE("file[%d]: %s", i, data->file_path[i]);
735 transfer_list = g_slist_append(transfer_list, data);
738 out_param1 = g_array_new(FALSE, FALSE, sizeof(gchar));
739 out_param2 = g_array_new(FALSE, FALSE, sizeof(gchar));
741 g_array_append_vals(out_param1, &request_id,
743 g_array_append_vals(out_param2, &result, sizeof(int));
745 dbus_g_method_return(context, out_param1, out_param2);
747 g_array_free(out_param1, TRUE);
748 g_array_free(out_param2, TRUE);
755 int _bt_opp_client_cancel_push(void)
759 DBusGConnection *g_conn;
760 DBusGProxy *client_proxy;
761 int result = BLUETOOTH_ERROR_CANCEL_BY_USER;
763 retv_if(sending_info == NULL, BLUETOOTH_ERROR_NOT_IN_OPERATION);
765 sending_info->is_canceled = TRUE;
766 sending_info->result = result;
768 if (sending_info->transfer_info) {
769 BT_DBG("calling cancel in Bluez");
770 dbus_g_proxy_call_no_reply(sending_info->transfer_info->proxy,
771 "Cancel", G_TYPE_INVALID,
774 _bt_send_event(BT_OPP_CLIENT_EVENT,
775 BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE,
776 DBUS_TYPE_INT32, &result,
777 DBUS_TYPE_STRING, &sending_info->transfer_info->file_name,
778 DBUS_TYPE_UINT64, &sending_info->transfer_info->size,
779 DBUS_TYPE_INT32, &sending_info->request_id,
782 if (result == BLUETOOTH_ERROR_CANCEL_BY_USER) {
783 BT_ERR("result is not BLUETOOTH_ERROR_NONE");
784 __bt_sending_release();
788 retv_if(sending_info->sending_proxy == NULL,
789 BLUETOOTH_ERROR_INTERNAL);
791 g_conn = _bt_get_session_gconn();
792 retv_if(g_conn == NULL, BLUETOOTH_ERROR_INTERNAL);
794 client_proxy = dbus_g_proxy_new_for_name(g_conn, BT_OBEX_SERVICE_NAME,
795 BT_OBEX_CLIENT_PATH, BT_OBEX_CLIENT_INTERFACE);
796 retv_if(client_proxy == NULL, BLUETOOTH_ERROR_INTERNAL);
798 dbus_g_proxy_cancel_call(client_proxy,
799 sending_info->sending_proxy);
801 g_idle_add(__bt_cancel_push_cb, NULL);
806 return BLUETOOTH_ERROR_NONE;
809 int _bt_opp_client_cancel_all_transfers(void)
813 g_slist_free_full(transfer_list,
814 (GDestroyNotify)__bt_free_sending_data);
816 transfer_list = NULL;
819 _bt_opp_client_cancel_push();
821 return BLUETOOTH_ERROR_NONE;
824 int _bt_opp_client_is_sending(gboolean *sending)
826 BT_CHECK_PARAMETER(sending, return);
828 *sending = sending_info ? TRUE : FALSE;
830 return BLUETOOTH_ERROR_NONE;
833 void _bt_opp_client_check_pending_transfer(const char *address)
837 int result = BLUETOOTH_ERROR_CANCEL;
839 ret_if(sending_info == NULL);
840 ret_if(sending_info->transfer_info == NULL);
842 if (g_strcmp0(sending_info->address, address) == 0) {
843 BT_INFO("Address Match.Cancel current transfer");
844 sending_info->transfer_info->transfer_status = BT_TRANSFER_STATUS_COMPLETED;
845 sending_info->result = result;
847 if (!sending_info->is_canceled) {
848 _bt_send_event(BT_OPP_CLIENT_EVENT,
849 BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE,
850 DBUS_TYPE_INT32, &result,
851 DBUS_TYPE_STRING, &sending_info->transfer_info->file_name,
852 DBUS_TYPE_UINT64, &sending_info->transfer_info->size,
853 DBUS_TYPE_INT32, &sending_info->request_id,
856 __bt_free_transfer_info(sending_info->transfer_info);
857 sending_info->transfer_info = NULL;
858 /* Reset the file offset as we will cancelled remaining files also */
862 _bt_send_event(BT_OPP_CLIENT_EVENT,
863 BLUETOOTH_EVENT_OPC_DISCONNECTED,
864 DBUS_TYPE_INT32, &sending_info->result,
865 DBUS_TYPE_STRING, &sending_info->address,
866 DBUS_TYPE_INT32, &sending_info->request_id,
869 __bt_sending_release();