From 3275a195fc30db8325313f2394a246c92f101c96 Mon Sep 17 00:00:00 2001 From: Hyuk Lee Date: Thu, 7 Jan 2016 10:46:27 +0900 Subject: [PATCH] Sync with the Tizen 2.4 code Fix: remove the white space Change-Id: I746c12e3fdcdcffd88e148de72ffe025923a198e Signed-off-by: Hyuk Lee --- bt-share/CMakeLists.txt | 11 +- bt-share/include/bt-share-common.h | 5 +- bt-share/include/bt-share-ipc.h | 11 +- bt-share/include/bt-share-main.h | 10 +- bt-share/include/bt-share-noti-handler.h | 12 +- bt-share/include/bt-share-notification.h | 48 +- bt-share/include/bt-share-resource.h | 39 +- bt-share/include/obex-event-handler.h | 1 + bt-share/src/bt-share-common.c | 37 ++ bt-share/src/bt-share-ipc.c | 267 +++++--- bt-share/src/bt-share-main.c | 64 +- bt-share/src/bt-share-noti-handler.c | 76 ++- bt-share/src/bt-share-notification.c | 477 +++++++++++--- bt-share/src/bt-share-syspopup.c | 86 ++- bt-share/src/obex-event-handler.c | 1040 ++++++++++++++++++------------ lib/CMakeLists.txt | 6 +- lib/applog.h | 107 +-- lib/bt-share-db.h | 2 +- packaging/bluetooth-share.spec | 15 +- 19 files changed, 1550 insertions(+), 764 deletions(-) diff --git a/bt-share/CMakeLists.txt b/bt-share/CMakeLists.txt index 19b7713..1e42df5 100644 --- a/bt-share/CMakeLists.txt +++ b/bt-share/CMakeLists.txt @@ -18,12 +18,12 @@ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/lib) INCLUDE(FindPkgConfig) pkg_check_modules(pkgs REQUIRED glib-2.0 bluetooth-api - dbus-glib-1 appcore-common - dlog vconf pmapi sysman + aul dbus-glib-1 appcore-common + dlog vconf syspopup-caller pmapi sysman notification sqlite3 ecore-file - appsvc appcore-efl + appsvc appcore-efl storage capi-content-media-content - libtzplatform-config + libtzplatform-config eventsystem cynara-creds-dbus cynara-client cynara-session) pkg_check_modules(CALENDAR_SERVICE2 calendar-service2) pkg_check_modules(CONTACTS_SERVICE2 contacts-service2) @@ -36,6 +36,7 @@ ENDFOREACH(flag) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC") SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie") SET(PREFIX ${CMAKE_INSTALL_PREFIX}) +SET(BINDIR "/usr/bin") SET(EXEC_PREFIX "\${prefix}") SET(INCLUDEDIR "/usr/include") SET(VERSION 1.0) @@ -56,4 +57,4 @@ TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS} ${CALENDAR_SERVICE2_LDFLAG INSTALL(TARGETS ${PROJECT_NAME} DESTINATION bin) -INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/org.bluetooth.share.service DESTINATION share/dbus-1/system-services) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/org.bluetooth.share.service DESTINATION /usr/share/dbus-1/system-services) diff --git a/bt-share/include/bt-share-common.h b/bt-share/include/bt-share-common.h index f399306..ff01ba0 100644 --- a/bt-share/include/bt-share-common.h +++ b/bt-share/include/bt-share-common.h @@ -30,7 +30,7 @@ extern "C" { #define BT_SHARE_FAIL -1 #define BT_SHARE_ERROR_NONE 0 -#define BT_TMP_DIR "/tmp/" +#define BT_TMP_DIR "/opt/usr/media/Downloads/.bluetooth/" #define BT_TMP_FILE BT_TMP_DIR"bluetooth_content_share" #define TXT_FILE_NAME BT_TMP_DIR"bluetooth_content_share.txt" #define HTML_FILE_NAME BT_TMP_DIR"bluetooth_content_share.html" @@ -38,6 +38,8 @@ extern "C" { #define HTML_FILE_FORMAT BT_TMP_DIR"bluetooth_content_share%s.html" #define HTML_FORMAT "%s" +#define BT_CONTACT_SHARE_TMP_DIR "/opt/usr/media/Downloads/.bluetooth/" + typedef enum { BT_HTTP_FILE, BT_TXT_FILE, @@ -55,6 +57,7 @@ int _bt_share_block_sleep(gboolean is_block); int _bt_set_transfer_indicator(gboolean state); char *_bt_share_create_transfer_file(char *text); void _bt_remove_tmp_file(char *file_path); +void _bt_remove_vcf_file(char *file_path); #ifdef __cplusplus } diff --git a/bt-share/include/bt-share-ipc.h b/bt-share/include/bt-share-ipc.h index 95a5cb1..1406bad 100644 --- a/bt-share/include/bt-share-ipc.h +++ b/bt-share/include/bt-share-ipc.h @@ -27,7 +27,7 @@ extern "C" { #include #include #include - +#include "bluetooth-api.h" #include "bt-share-main.h" #define BT_ADDRESS_LENGTH_MAX 6 @@ -37,6 +37,7 @@ extern "C" { #define BT_UG_IPC_EVENT_CONNECTED "Connected" #define BT_UG_IPC_EVENT_DISCONNECTED "Disconnected" +#define BT_BLUEZ_INTERFACE "org.freedesktop.DBus" #define BT_SYSPOPUP_IPC_RESPONSE_OBJECT "/org/projectx/bt_syspopup_res" #define BT_SYSPOPUP_INTERFACE "User.Bluetooth.syspopup" #define BT_SYSPOPUP_METHOD_RESPONSE "Response" @@ -62,6 +63,7 @@ extern "C" { #define BT_IPC_STRING_SIZE 256 #define BT_ADDR_STR_LEN_MAX 18 +#define BT_MIME_TYPE_MAX_LEN 20 #define FILE_PATH_DELIM "?" @@ -108,6 +110,7 @@ typedef struct { char **file_path; char **content; char *type; + unsigned int *size; } opc_transfer_info_t; typedef struct { @@ -145,7 +148,7 @@ void _bt_send_message_to_ui(int transfer_id, int percentage, gboolean completed, int error_type); -void _bt_create_warning_popup(int error_type); +void _bt_create_warning_popup(int error_type, char *msg); void _bt_update_transfer_list_view(const char *table); gboolean _bt_update_sent_data_status(int uid, bt_app_tr_status_t status); @@ -153,8 +156,8 @@ gboolean _bt_update_sent_data_status(int uid, bt_app_tr_status_t status); void _bt_rm_all_send_data(void); void _bt_rm_all_recv_data(void); gboolean _bt_add_recv_transfer_status_data(char *device_name, - char *filepath, - int status); + char *filepath, char *type, + unsigned int size, int status); #ifdef __cplusplus } diff --git a/bt-share/include/bt-share-main.h b/bt-share/include/bt-share-main.h index eeeecdc..57d4f8e 100644 --- a/bt-share/include/bt-share-main.h +++ b/bt-share/include/bt-share-main.h @@ -34,9 +34,7 @@ extern "C" { #endif #define UI_PACKAGE "org.tizen.bluetooth-share-ui" -#define UI_PKG_PATH tzplatform_mkpath(TZ_SYS_RW_APP, \ - "org.tizen.bluetooth-share-ui/bin/bluetooth-share-ui") - +#define UI_PKG_PATH "/usr/apps/org.tizen.bluetooth-share-ui/bin/bluetooth-share-ui" typedef void (*bt_app_cb) (void *, void *, void *); typedef struct { @@ -60,16 +58,18 @@ struct bt_appdata { notification_h send_noti; notification_h receive_noti; notification_h opc_noti; + int send_noti_id; + int receive_noti_id; int opc_noti_id; int syspopup_call; DBusGConnection *conn; GObject *object; gboolean obex_server_init; + bool opp_transfer_abort; }; -void _bt_terminate_app(void); - +void _bt_terminate_bluetooth_share(void); int _bt_init_obex_server(void); #ifdef __cplusplus diff --git a/bt-share/include/bt-share-noti-handler.h b/bt-share/include/bt-share-noti-handler.h index 79ed7af..472cff3 100644 --- a/bt-share/include/bt-share-noti-handler.h +++ b/bt-share/include/bt-share-noti-handler.h @@ -28,12 +28,18 @@ extern "C" { #define BT_DEFAULT_MEM_PHONE 0 #define BT_DEFAULT_MEM_MMC 1 -#define BT_DOWNLOAD_PHONE_FOLDER tzplatform_mkpath(TZ_USER_CONTENT, "Downloads") -#define BT_DOWNLOAD_MMC_FOLDER tzplatform_mkpath(TZ_SYS_STORAGE, "sdcard") +#define BT_DOWNLOAD_PHONE_FOLDER "/opt/usr/media/Downloads" +#define BT_DOWNLOAD_MMC_FOLDER "/opt/storage/sdcard/Downloads" #define BT_DOWNLOAD_MEDIA_FOLDER tzplatform_getenv(TZ_USER_CONTENT) #define BT_FTP_FOLDER tzplatform_mkpath(TZ_SYS_SHARE, "bt-ftp") -void _bt_init_vconf_notification(void); +#define BT_DOWNLOAD_PHONE_ROOT "/opt/usr/media" +#define BT_DOWNLOAD_MMC_ROOT "/opt/storage/sdcard" +#define BT_FTP_FOLDER "/opt/share/bt-ftp" +#define BT_FTP_FOLDER_PHONE "/opt/share/bt-ftp/Media/" +#define BT_FTP_FOLDER_MMC "/opt/share/bt-ftp/SD_External/" + +void _bt_init_vconf_notification(void *data); void _bt_deinit_vconf_notification(void); #ifdef __cplusplus } diff --git a/bt-share/include/bt-share-notification.h b/bt-share/include/bt-share-notification.h index a7cd66c..5e34338 100644 --- a/bt-share/include/bt-share-notification.h +++ b/bt-share/include/bt-share-notification.h @@ -30,7 +30,7 @@ extern "C" { #include "bt-share-main.h" -#define BT_SHARE_BIN_PATH tzplatform_mkpath(TZ_SYS_BIN, "bluetooth-share") +#define BT_SHARE_BIN_PATH "/usr/bin/bluetooth-share" #define QP_NO_APP_LAUNCH NOTIFICATION_PROP_DISABLE_APP_LAUNCH #define QP_NO_TICKER NOTIFICATION_PROP_DISABLE_TICKERNOTI @@ -40,6 +40,8 @@ extern "C" { #define NOTIFICATION_TEXT_LEN_MAX 100 #define NOTI_TR_TYPE_IN "inbound" #define NOTI_TR_TYPE_OUT "outbound" +#define NOTI_OPS_APP_ID "bluetooth-share-opp-server" +#define NOTI_OPC_APP_ID "bluetooth-share-opp-client" /* Priv_id should be unique. */ enum { @@ -54,39 +56,47 @@ typedef enum { } bt_qp_type_t; typedef enum { + BT_SENT_NOTI, + BT_SENDING_NOTI, + BT_RECEIVED_NOTI, + BT_RECEIVING_NOTI, +} bt_notification_type_e; + +typedef enum { CREATE_PROGRESS, CREATE_TR_LIST -} bt_qp_launch_type_t; - +} bt_notification_launch_type_e; notification_h _bt_create_notification(bt_qp_type_t type); -int _bt_insert_notification(notification_h noti, - char *title, - char *content, - char *icon_path); +notification_h _bt_insert_notification(struct bt_appdata *ad, bt_notification_type_e type, int index, int total); -int _bt_update_notification(notification_h noti, - char *title, - char *content, - char *icon_path); +int _bt_update_notification(struct bt_appdata *ad, notification_h noti, + char *title, char *content, char *icon_path); -int _bt_update_notification_progress(void *handle, - int id, - int val); +int _bt_update_notification_progress(notification_h noti, + int id, int val); gboolean _bt_get_notification_text(int priv_id, char *str); +int _bt_get_notification_priv_id(notification_h noti); + int _bt_delete_notification(notification_h noti); -int _bt_set_notification_app_launch(notification_h noti, - bt_qp_launch_type_t type, - const char *transfer_type, - const char *filename, - const char *progress_cnt); int _bt_set_notification_property(notification_h noti, int flag); +int _bt_get_notification_priv_id(notification_h noti); + +int _bt_set_notification_app_launch(notification_h noti, + bt_notification_launch_type_e launch_type, + const char *transfer_type, + const char *filename, + const char *progress_cnt, + int transfer_id); + +gboolean _bt_update_notification_status(struct bt_appdata *ad ); + void _bt_register_notification_cb(struct bt_appdata *ad); void _bt_unregister_notification_cb(struct bt_appdata *ad); diff --git a/bt-share/include/bt-share-resource.h b/bt-share/include/bt-share-resource.h index a46a870..6fba517 100644 --- a/bt-share/include/bt-share-resource.h +++ b/bt-share/include/bt-share-resource.h @@ -28,29 +28,51 @@ extern "C" { #include /*============== String ================= */ -#define BT_COMMON_PKG "ug-setting-bluetooth-efl" -#define BT_COMMON_RES "/usr/ug/res/locale" +#define BT_COMMON_PKG "ug-bluetooth-efl" +#define BT_COMMON_RES "/usr/apps/ug-bluetooth-efl/shared/res/locale" #define BT_STR_MEMORY_FULL \ dgettext(BT_COMMON_PKG, "IDS_BT_POP_MEMORYFULL") #define BT_STR_UNABLE_TO_SEND \ dgettext(BT_COMMON_PKG, "IDS_BT_POP_SENDINGFAIL") +#define BT_STR_UNABLE_TO_RECEIVE \ + dgettext(BT_COMMON_PKG, "IDS_BT_BODY_UNABLE_TO_RECEIVE") #define BT_TR_STATUS \ dgettext(BT_COMMON_PKG, "IDS_BT_BODY_PD_SUCCESSFUL_PD_FAILED") +#define BT_TR_COPIED_STATUS \ + dgettext(BT_COMMON_PKG, "IDS_BT_MBODY_P1SD_FILES_COPIED_P2SD_FAILED_ABB") +#define BT_TR_1FILE_COPIED_STATUS \ + dgettext(BT_COMMON_PKG, "IDS_BT_MBODY_1_FILE_COPIED_PD_FAILED_ABB") +#define BT_STR_SENDING \ + dgettext(BT_COMMON_PKG, "IDS_BT_POP_SENDING_ING") +#define BT_STR_RECEIVING \ + dgettext(BT_COMMON_PKG, "IDS_BT_POP_RECEIVING_ING") #define BT_STR_RECEIVED \ dgettext(BT_COMMON_PKG, "IDS_BT_BODY_RECEIVED") #define BT_STR_SENT \ dgettext(BT_COMMON_PKG, "IDS_BT_BODY_SENT") #define BT_STR_SHARE \ dgettext(BT_COMMON_PKG, "IDS_BT_BODY_BLUETOOTH_SHARE") +#define BT_STR_RECEIVE_VIA_BLUETOOTH \ + dgettext(BT_COMMON_PKG, "IDS_BT_MBODY_RECEIVE_VIA_BLUETOOTH_ABB") +#define BT_STR_SEND_VIA_BLUETOOTH \ + dgettext(BT_COMMON_PKG, "IDS_BT_MBODY_SEND_VIA_BLUETOOTH_ABB") +#define BT_STR_PREPARING_TO_RECEIVE_FILES \ + dgettext(BT_COMMON_PKG, "IDS_BT_SBODY_PREPARING_TO_RECEIVE_FILES_ING_ABB") +#define BT_STR_PREPARING_TO_SEND_FILES \ + dgettext(BT_COMMON_PKG, "IDS_BT_SBODY_PREPARING_TO_SEND_FILES_ING_ABB") +#define BT_STR_FILES_RECEIVED_VIA_BLUETOOTH \ + dgettext(BT_COMMON_PKG, "IDS_BT_MBODY_FILES_RECEIVED_VIA_BLUETOOTH_ABB") +#define BT_STR_FILES_SENT_VIA_BLUETOOTH \ + dgettext(BT_COMMON_PKG, "IDS_BT_MBODY_FILES_SENT_VIA_BLUETOOTH_ABB") #define BT_STR_BLUETOOTH_ON \ dgettext(BT_COMMON_PKG, "IDS_BT_POP_ACTIVATED") #define BT_STR_BLUETOOTH_AVAILABLE \ dgettext(BT_COMMON_PKG, "IDS_BT_BODY_BLUETOOTH_AVAILABLE") /*============== Image ================= */ -#define ICONDIR "org.tizen.bluetooth-share-ui/res/images" - +#define ICONDIR "/usr/apps/ug-bluetooth-efl/res/images" +#define QP_PRELOAD_NOTI_ICON_PATH "/usr/apps/org.tizen.quickpanel/shared/res/noti_icons/Common" #define BT_ICON_PATH_MAX 256 #define BT_ICON_QP_SEND tzplatform_mkpath3(TZ_SYS_RW_APP, ICONDIR, \ @@ -60,6 +82,15 @@ extern "C" { #define BT_ICON_QP_BT_ON tzplatform_mkpath3(TZ_SYS_RW_APP, ICONDIR, \ "/Q02_Notification_bluetooth.png") +#define BT_ICON_NOTIFICATION_SENDING "reserved://quickpanel/ani/uploading" +#define BT_ICON_NOTIFICATION_SENDING_INDICATOR "reserved://indicator/ani/uploading" +#define BT_ICON_NOTIFICATION_SENT QP_PRELOAD_NOTI_ICON_PATH"/noti_upload_complete.png" +#define BT_ICON_NOTIFICATION_SENT_INDICATOR ICONDIR"/B03_Processing_upload_complete.png" +#define BT_ICON_NOTIFICATION_RECEIVING "reserved://quickpanel/ani/downloading" +#define BT_ICON_NOTIFICATION_RECEIVING_INDICATOR "reserved://indicator/ani/downloading" +#define BT_ICON_NOTIFICATION_RECEIVED QP_PRELOAD_NOTI_ICON_PATH"/noti_download_complete.png" +#define BT_ICON_NOTIFICATION_RECEIVED_INDICATOR ICONDIR"/B03_Processing_download_complete.png" + #ifdef __cplusplus } diff --git a/bt-share/include/obex-event-handler.h b/bt-share/include/obex-event-handler.h index 2dc04c3..ac04767 100644 --- a/bt-share/include/obex-event-handler.h +++ b/bt-share/include/obex-event-handler.h @@ -55,6 +55,7 @@ void _bt_app_obex_download_dup_file_cb(void *data, void *obj, void *event_info); void _bt_get_default_storage(char *storage); +void _bt_obex_cancel_transfer(void *data); #ifdef __cplusplus diff --git a/bt-share/src/bt-share-common.c b/bt-share/src/bt-share-common.c index 59b69aa..433a972 100644 --- a/bt-share/src/bt-share-common.c +++ b/bt-share/src/bt-share-common.c @@ -23,11 +23,31 @@ #include #include #include +#include +#include #include "vconf-keys.h" #include "applog.h" #include "bt-share-common.h" +static int __bt_eventsystem_set_value(const char *event, const char *key, const char *value) +{ + int ret; + bundle *b = NULL; + + b = bundle_create(); + + bundle_add_str(b, key, value); + + ret = eventsystem_send_system_event(event, b); + + DBG("eventsystem_send_system_event result: %d", ret); + + bundle_free(b); + + return ret; +} + int _bt_share_block_sleep(gboolean is_block) { static int block_sleep_count = 0; @@ -84,6 +104,7 @@ int _bt_set_transfer_indicator(gboolean state) int bt_device_state; static int block_cnt = 0; int ret; + const char *event_val = NULL; ret = vconf_get_int(VCONFKEY_BT_STATUS, (void *)&bt_device_state); if (ret != 0) { @@ -96,14 +117,22 @@ int _bt_set_transfer_indicator(gboolean state) if(bt_device_state & BT_STATUS_TRANSFER) return 0; bt_device_state |= BT_STATUS_TRANSFER; + event_val = EVT_VAL_BT_TRANSFERING; } else { if(block_cnt > 0) block_cnt--; if(block_cnt != 0) return 0; bt_device_state ^= BT_STATUS_TRANSFER; + event_val = EVT_VAL_BT_NON_TRANSFERING; } + DBG("event_value: %s", event_val); + + if (__bt_eventsystem_set_value(SYS_EVENT_BT_STATE, EVT_KEY_BT_TRANSFERING_STATE, + event_val) != ES_R_OK) + ERR("Fail to set value"); + ret = vconf_set_int(VCONFKEY_BT_STATUS, bt_device_state); if (ret != 0) { DBG("Set vconf failed\n"); @@ -152,6 +181,14 @@ void _bt_remove_tmp_file(char *file_path) } } +void _bt_remove_vcf_file(char *file_path) +{ + if (g_str_has_prefix(file_path, BT_CONTACT_SHARE_TMP_DIR) == TRUE) { + DBG("Remove the file: %s", file_path); + ecore_file_remove(file_path); + } +} + char *_bt_share_create_transfer_file(char *text) { int fd; diff --git a/bt-share/src/bt-share-ipc.c b/bt-share/src/bt-share-ipc.c index 2a50c05..bd50144 100644 --- a/bt-share/src/bt-share-ipc.c +++ b/bt-share/src/bt-share-ipc.c @@ -26,7 +26,9 @@ #include #include #include +#include #include +#include #include "applog.h" #include "bluetooth-api.h" @@ -40,12 +42,16 @@ #include "bt-share-common.h" #include "bt-share-cynara.h" +#define FILEPATH_LEN_MAX 4096 + GSList *bt_transfer_list = NULL; DBusConnection *dbus_connection = NULL; extern struct bt_appdata *app_state; static void __bt_create_send_data(opc_transfer_info_t *node); +static void __bt_create_send_failed_data(char *filepath, char *dev_name, + char *addr, char *type, unsigned int size); static void __bt_share_update_tr_info(int tr_uid, int tr_type); static void __bt_tr_data_free(bt_tr_data_t *data) @@ -218,11 +224,56 @@ int _request_file_send(opc_transfer_info_t *node) return BLUETOOTH_ERROR_NONE; } +static int __bt_get_owner_info(DBusMessage *msg, char **name, + char **previous, char **current) +{ + DBusMessageIter item_iter; + + dbus_message_iter_init(msg, &item_iter); + + if (dbus_message_iter_get_arg_type(&item_iter) + != DBUS_TYPE_STRING) { + ERR("This is bad format dbus\n"); + return BLUETOOTH_ERROR_INTERNAL; + } + + dbus_message_iter_get_basic(&item_iter, name); + + retv_if(*name == NULL, BLUETOOTH_ERROR_INTERNAL); + + dbus_message_iter_next(&item_iter); + + if (dbus_message_iter_get_arg_type(&item_iter) + != DBUS_TYPE_STRING) { + ERR("This is bad format dbus\n"); + return BLUETOOTH_ERROR_INTERNAL; + } + + dbus_message_iter_get_basic(&item_iter, previous); + + retv_if(*previous == NULL, BLUETOOTH_ERROR_INTERNAL); + + dbus_message_iter_next(&item_iter); + + if (dbus_message_iter_get_arg_type(&item_iter) + != DBUS_TYPE_STRING) { + ERR("This is bad format dbus\n"); + return BLUETOOTH_ERROR_INTERNAL; + } + + dbus_message_iter_get_basic(&item_iter, current); + + retv_if(*current == NULL, BLUETOOTH_ERROR_INTERNAL); + + return BLUETOOTH_ERROR_NONE; +} + static DBusHandlerResult __event_filter(DBusConnection *sys_conn, DBusMessage *msg, void *data) { int ret; char *member; + struct bt_appdata *ad = app_state; const char *sender; const char *path = dbus_message_get_path(msg); bt_share_cynara_creds sender_creds; @@ -265,29 +316,36 @@ static DBusHandlerResult __event_filter(DBusConnection *sys_conn, if (ret == BLUETOOTH_ERROR_IN_PROGRESS) { DBG("Aleady OPC progressing. Once completed previous job, will be started\n"); } else if ( ret != BLUETOOTH_ERROR_NONE) { - _bt_create_warning_popup(BLUETOOTH_ERROR_INTERNAL); + _bt_create_warning_popup(BLUETOOTH_ERROR_INTERNAL, BT_STR_UNABLE_TO_SEND); g_slist_free_full(bt_transfer_list, (GDestroyNotify)_free_transfer_info); bt_transfer_list = NULL; } } else if (dbus_message_is_signal(msg, BT_SHARE_UI_INTERFACE, BT_SHARE_UI_SIGNAL_OPPABORT)) { - const char *transfer_type = NULL; - int transfer_id = 0; - int noti_id = 0; - if (!dbus_message_get_args(msg, NULL, + const char *transfer_type = NULL; + int noti_id = 0; + + if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &transfer_type, DBUS_TYPE_INT32, ¬i_id, DBUS_TYPE_INVALID)) { - ERR("OPP abort handling failed"); - return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; - } - DBG("transfer_type = %s\n", transfer_type); - if (!g_strcmp0(transfer_type, NOTI_TR_TYPE_OUT)) { - bluetooth_opc_cancel_push(); - } else { - transfer_id = _bt_get_transfer_id_by_noti_id(noti_id); - bluetooth_obex_server_cancel_transfer(transfer_id); + ERR("OPP abort handling failed"); + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + } + ad->opp_transfer_abort = TRUE; /* Transfer aborted by user*/ + INFO("transfer_type = %s", transfer_type); + if (!g_strcmp0(transfer_type, NOTI_TR_TYPE_OUT)) { + bluetooth_opc_cancel_push(); + if (ad->opc_noti) { + ret = _bt_delete_notification(ad->opc_noti); + if (ret == NOTIFICATION_ERROR_NONE) { + ad->opc_noti = NULL; + ad->opc_noti_id = 0; + } } + } else { + bluetooth_obex_server_cancel_transfer(noti_id); + } } else if (dbus_message_is_signal(msg, BT_SHARE_UI_INTERFACE, BT_SHARE_UI_SIGNAL_SEND_FILE)) { opc_transfer_info_t *node; @@ -305,7 +363,7 @@ static DBusHandlerResult __event_filter(DBusConnection *sys_conn, if (ret == BLUETOOTH_ERROR_IN_PROGRESS) { DBG("Aleady OPC progressing. Once completed previous job, will be started\n"); } else if ( ret != BLUETOOTH_ERROR_NONE) { - _bt_create_warning_popup(BLUETOOTH_ERROR_INTERNAL); + _bt_create_warning_popup(BLUETOOTH_ERROR_INTERNAL, BT_STR_UNABLE_TO_SEND); g_slist_free_full(bt_transfer_list, (GDestroyNotify)_free_transfer_info); bt_transfer_list = NULL; @@ -327,6 +385,23 @@ static DBusHandlerResult __event_filter(DBusConnection *sys_conn, if (bluetooth_obex_server_deinit() == BLUETOOTH_ERROR_NONE) { DBG("Obex Server deinit"); } + } else if (strcasecmp(member, "NameOwnerChanged") == 0) { + char *name = NULL; + char *previous = NULL; + char *current = NULL; + + if (__bt_get_owner_info(msg, &name, &previous, ¤t)) { + ERR("Fail to get the owner info"); + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + } + + if (*current != '\0') + return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; + + if (strcasecmp(name, "org.bluez") == 0) { + INFO("Bluetoothd is terminated"); + _bt_terminate_bluetooth_share(); + } } else { return DBUS_HANDLER_RESULT_NOT_YET_HANDLED; } @@ -335,14 +410,14 @@ static DBusHandlerResult __event_filter(DBusConnection *sys_conn, gboolean _bt_init_dbus_signal(void) { - DBG("+\n"); + DBG("+"); DBusGConnection *conn; GError *err = NULL; DBusError dbus_error; conn = dbus_g_bus_get(DBUS_BUS_SYSTEM, &err); if (!conn) { - DBG(" DBUS get failed\n"); + ERR(" DBUS get failed"); g_error_free(err); return FALSE; } @@ -352,29 +427,32 @@ gboolean _bt_init_dbus_signal(void) dbus_error_init(&dbus_error); dbus_connection_add_filter(dbus_connection, __event_filter, NULL, NULL); dbus_bus_add_match(dbus_connection, - "type=signal,interface=" BT_SYSPOPUP_INTERFACE - ",member=Response", &dbus_error); + "type=signal,interface=" BT_BLUEZ_INTERFACE + ",member=NameOwnerChanged", &dbus_error); + dbus_bus_add_match(dbus_connection, + "type=signal,interface=" BT_SYSPOPUP_INTERFACE + ",member=Response", &dbus_error); dbus_bus_add_match(dbus_connection, - "type=signal,interface=" BT_UG_IPC_INTERFACE - ",member=Send", &dbus_error); + "type=signal,interface=" BT_UG_IPC_INTERFACE + ",member=Send", &dbus_error); dbus_bus_add_match(dbus_connection, - "type=signal,interface=" BT_SHARE_UI_INTERFACE - ",member=opp_abort", &dbus_error); + "type=signal,interface=" BT_SHARE_UI_INTERFACE + ",member=opp_abort", &dbus_error); dbus_bus_add_match(dbus_connection, - "type=signal,interface=" BT_SHARE_UI_INTERFACE - ",member=send_file", &dbus_error); + "type=signal,interface=" BT_SHARE_UI_INTERFACE + ",member=send_file", &dbus_error); dbus_bus_add_match(dbus_connection, - "type=signal,interface=" BT_SHARE_UI_INTERFACE - ",member=info_update", &dbus_error); + "type=signal,interface=" BT_SHARE_UI_INTERFACE + ",member=info_update", &dbus_error); dbus_bus_add_match(dbus_connection, - "type=signal,interface=" BT_SHARE_FRWK_INTERFACE - ",member=deinit", &dbus_error); + "type=signal,interface=" BT_SHARE_FRWK_INTERFACE + ",member=deinit", &dbus_error); if (dbus_error_is_set(&dbus_error)) { - ERR("Fail to add dbus filter signal\n"); + ERR("Fail to add dbus filter signal"); dbus_error_free(&dbus_error); } - DBG("-\n"); + DBG("-"); return TRUE; } @@ -413,53 +491,40 @@ void _bt_send_message_to_ui(int transfer_id, char *name, int percentage, gboolea } -void _bt_create_warning_popup(int error_type) +void _bt_create_warning_popup(int error_type, char *msg) { - /* If bluetooth-share-ui process is existed, send dbus signal. */ - /* Otherwise create the process and terminate it after popup shown */ - if (sysman_get_pid(UI_PKG_PATH) == -1) { - char str[BT_TEXT_LEN_MAX] = {0,}; - - switch(error_type) { - case BLUETOOTH_ERROR_SERVICE_NOT_FOUND: - case BLUETOOTH_ERROR_NOT_CONNECTED: - case BLUETOOTH_ERROR_ACCESS_DENIED: - case BLUETOOTH_ERROR_OUT_OF_MEMORY: - case BLUETOOTH_ERROR_INTERNAL: - snprintf(str, BT_TEXT_LEN_MAX, "%s", BT_STR_UNABLE_TO_SEND); - break; - default: - return; + /* If bluetooth-share-ui process is not running */ + /* Then create the process and terminate it after popup shown */ + if (aul_app_is_running(UI_PACKAGE) == 0) { + DBG("Creating new process for Warning Popup"); + char str[BT_TEXT_LEN_MAX] = { 0, }; + bundle *b; + + DBG("error_type: %d",error_type); + switch (error_type) { + case BLUETOOTH_ERROR_SERVICE_NOT_FOUND: + case BLUETOOTH_ERROR_NOT_CONNECTED: + case BLUETOOTH_ERROR_ACCESS_DENIED: + case BLUETOOTH_ERROR_OUT_OF_MEMORY: + case BLUETOOTH_ERROR_INTERNAL: + case BLUETOOTH_ERROR_CANCEL: + snprintf(str, BT_TEXT_LEN_MAX, "%s", + msg); + break; + default: + return; } - INFO("bt create warning popup notification"); - // TODO : display a popup + b = bundle_create(); + ret_if(b == NULL); - }else { - DBusMessage *msg = NULL; - ret_if(dbus_connection == NULL); - - msg = dbus_message_new_signal(BT_SHARE_ENG_OBJECT, - BT_SHARE_ENG_INTERFACE, - BT_SHARE_ENG_SIGNAL_ERROR); - if (!msg) { - ERR("Unable to allocate memory\n"); - return; - } + bundle_add(b, "launch-type", "warning_popup"); + bundle_add(b, "message", str); - if (!dbus_message_append_args(msg, - DBUS_TYPE_INT32, &error_type, - DBUS_TYPE_INVALID)) { - DBG("Event sending failed\n"); - dbus_message_unref(msg); - return; - } + aul_launch_app(UI_PACKAGE, b); - dbus_message_set_destination(msg, BT_SHARE_UI_INTERFACE); - dbus_connection_send(dbus_connection, msg, NULL); - dbus_message_unref(msg); + bundle_free(b); } - return; } @@ -508,6 +573,42 @@ static char *__bt_conv_addr_type_to_addr_string(char *addr) return g_strdup(address); } +static void __bt_create_send_failed_data(char *filepath, char *dev_name, + char *addr, char *type, unsigned int size) +{ + int session_id; + sqlite3 *db = NULL; + + db = bt_share_open_db(); + if (!db) + return; + + session_id = bt_share_get_last_session_id(db, BT_DB_OUTBOUND); + + INFO("Last session id = %d", session_id); + + bt_tr_data_t *tmp; + tmp = g_malloc0(sizeof(bt_tr_data_t)); + if(tmp == NULL) + return; + + tmp->tr_status = BT_TR_FAIL; + tmp->sid = session_id + 1; + tmp->file_path = g_strdup(filepath); + tmp->content = g_strdup(filepath); + tmp->dev_name = g_strdup(dev_name); + tmp->type = g_strdup(type); + tmp->timestamp = __bt_get_current_timedata(); + tmp->addr = __bt_conv_addr_type_to_addr_string(addr); + tmp->size = size; + bt_share_add_tr_data(db, BT_DB_OUTBOUND, tmp); + __bt_tr_data_free(tmp); + + bt_share_close_db(db); + + return; +} + static void __bt_create_send_data(opc_transfer_info_t *node) { DBG("__bt_create_send_data \n"); @@ -530,15 +631,20 @@ static void __bt_create_send_data(opc_transfer_info_t *node) for (count = 0; count < node->file_cnt; count++) { bt_tr_data_t *tmp; tmp = g_malloc0(sizeof(bt_tr_data_t)); + if (tmp == NULL) + return; tmp->tr_status = BT_TR_ONGOING; tmp->sid = session_id + 1; tmp->file_path = g_strdup(node->file_path[count]); + DBG("tmp->file_path : %s", tmp->file_path); + tmp->content = g_strdup(node->content[count]); tmp->dev_name = g_strdup(node->name); tmp->type = g_strdup(node->type); tmp->timestamp = __bt_get_current_timedata(); tmp->addr = __bt_conv_addr_type_to_addr_string(node->addr); + tmp->size = node->size[count]; bt_share_add_tr_data(db, BT_DB_OUTBOUND, tmp); __bt_tr_data_free(tmp); @@ -574,6 +680,8 @@ gboolean _bt_update_sent_data_status(int uid, bt_app_tr_status_t status) return FALSE; tmp = g_malloc0(sizeof(bt_tr_data_t)); + if (!tmp) + return FALSE; tmp->tr_status = status; tmp->timestamp = __bt_get_current_timedata(); @@ -585,7 +693,8 @@ gboolean _bt_update_sent_data_status(int uid, bt_app_tr_status_t status) } gboolean _bt_add_recv_transfer_status_data(char *device_name, - char *filepath, int status) + char *filepath, char *type, + unsigned int size, int status) { if (device_name == NULL || filepath == NULL) return FALSE; @@ -600,11 +709,15 @@ gboolean _bt_add_recv_transfer_status_data(char *device_name, return FALSE; tmp = g_malloc0(sizeof(bt_tr_data_t)); + if(tmp == NULL) + return FALSE; tmp->tr_status = status; tmp->file_path = g_strdup(filepath); tmp->dev_name = g_strdup(device_name); tmp->timestamp = __bt_get_current_timedata(); + tmp->type = g_strdup(type); + tmp->size = size; bt_share_add_tr_data(db, BT_DB_INBOUND, tmp); bt_share_close_db(db); __bt_tr_data_free(tmp); @@ -658,9 +771,8 @@ static void __bt_share_update_tr_info(int tr_uid, int tr_type) snprintf(str, sizeof(str), BT_TR_STATUS, ad->send_data.tr_success, ad->send_data.tr_fail); - _bt_update_notification(ad->send_noti, - BT_STR_SENT, str, - BT_ICON_QP_SEND); + _bt_update_notification(ad, ad->send_noti, + NULL, NULL, NULL); } else { _bt_delete_notification(ad->send_noti); } @@ -699,9 +811,8 @@ static void __bt_share_update_tr_info(int tr_uid, int tr_type) snprintf(str, sizeof(str), BT_TR_STATUS, ad->recv_data.tr_success, ad->recv_data.tr_fail); - _bt_update_notification(ad->receive_noti, - BT_STR_RECEIVED, str, - BT_ICON_QP_RECEIVE); + _bt_update_notification(ad, ad->receive_noti, + NULL, NULL, NULL); } else { _bt_delete_notification(ad->receive_noti); } diff --git a/bt-share/src/bt-share-main.c b/bt-share/src/bt-share-main.c index 8e789d2..b089e80 100644 --- a/bt-share/src/bt-share-main.c +++ b/bt-share/src/bt-share-main.c @@ -46,6 +46,18 @@ static gboolean terminated; GMainLoop *main_loop = NULL; struct bt_appdata *app_state = NULL; +void _bt_terminate_bluetooth_share(void) +{ + DBG("+"); + + if (main_loop) { + g_main_loop_quit(main_loop); + } else { + terminated = TRUE; + } + DBG("-"); +} + static void __bt_release_service(struct bt_appdata *ad) { if (ad == NULL) @@ -90,6 +102,13 @@ static void __bt_update_notification_status_values() notification_h noti = NULL; sqlite3 *db = NULL; + /* Update notification status durning BT off */ + if (_bt_update_notification_status(ad) == FALSE) { + DBG("Notification item is not existed."); + return; + } + + DBG("Initialize transfer information"); db = bt_share_open_db(); if (!db) return; @@ -125,13 +144,13 @@ static void __bt_update_notification_status_values() ad->send_data.tr_success, ad->send_data.tr_fail); noti = _bt_create_notification(BT_NOTI_T); - _bt_set_notification_app_launch(noti, - CREATE_TR_LIST, - NOTI_TR_TYPE_OUT, NULL, NULL); + //_bt_set_notification_app_launch(noti, + // CREATE_TR_LIST, + // NOTI_TR_TYPE_OUT, NULL, NULL); _bt_set_notification_property(noti, QP_NO_DELETE | QP_NO_TICKER); - _bt_insert_notification(noti, - BT_STR_SENT, str, - BT_ICON_QP_SEND); +// _bt_insert_notification(noti, +// BT_STR_SENT, str, +// BT_ICON_QP_SEND); ad->send_noti = noti; } @@ -164,12 +183,12 @@ static void __bt_update_notification_status_values() DBG("str = [%s] \n", str); noti = _bt_create_notification(BT_NOTI_T); - _bt_set_notification_app_launch(noti, CREATE_TR_LIST, - NOTI_TR_TYPE_IN, NULL, NULL); + //_bt_set_notification_app_launch(noti, CREATE_TR_LIST, + // NOTI_TR_TYPE_IN, NULL, NULL); _bt_set_notification_property(noti, QP_NO_DELETE | QP_NO_TICKER); - _bt_insert_notification(noti, - BT_STR_RECEIVED, str, - BT_ICON_QP_RECEIVE); +// _bt_insert_notification(noti, +// BT_STR_RECEIVED, str, +// BT_ICON_QP_RECEIVE); ad->receive_noti = noti; } @@ -208,9 +227,9 @@ static notification_h __bt_update_notification_adapter_status(void) goto failed; } - _bt_insert_notification(noti, - BT_STR_BLUETOOTH_ON, BT_STR_BLUETOOTH_AVAILABLE, - BT_ICON_QP_BT_ON); +// _bt_insert_notification(noti, +// BT_STR_BLUETOOTH_ON, BT_STR_BLUETOOTH_AVAILABLE, +// BT_ICON_QP_BT_ON); return noti; failed: @@ -220,6 +239,14 @@ failed: } +static int __bt_lang_changed_cb(void *data) +{ + if (appcore_set_i18n(BT_COMMON_PKG, BT_COMMON_RES) < 0) + return -1; + + return 0; +} + static gboolean __bt_dbus_request_name(void) { int ret_code = 0; @@ -298,6 +325,11 @@ int main(void) exit(0); } + ret = appcore_set_event_callback(APPCORE_EVENT_LANG_CHANGE, __bt_lang_changed_cb, NULL); + if(ret < 0) + DBG("Failed to excute the change of language"); + + /* init internationalization */ if (appcore_set_i18n(BT_COMMON_PKG, BT_COMMON_RES) < 0) return -1; @@ -315,7 +347,7 @@ int main(void) } _bt_init_dbus_signal(); - _bt_init_vconf_notification(); + _bt_init_vconf_notification(&ad); __bt_update_notification_status_values(); _bt_register_notification_cb(&ad); @@ -324,6 +356,7 @@ int main(void) if (terminated == TRUE) { __bt_release_service(&ad); + bluetooth_unregister_callback(); return -1; } @@ -335,6 +368,7 @@ int main(void) _bt_delete_notification(noti); __bt_release_service(&ad); + bluetooth_unregister_callback(); _bt_share_cynara_finish(); return 0; diff --git a/bt-share/src/bt-share-noti-handler.c b/bt-share/src/bt-share-noti-handler.c index fa9919a..e22c400 100644 --- a/bt-share/src/bt-share-noti-handler.c +++ b/bt-share/src/bt-share-noti-handler.c @@ -19,6 +19,7 @@ #include #include +#include /* For multi-user support */ #include @@ -26,6 +27,7 @@ #include "applog.h" #include "bluetooth-api.h" #include "bt-share-noti-handler.h" +#include "bt-share-main.h" static void __bt_default_memory_changed_cb(keynode_t *node, void *data) @@ -46,25 +48,91 @@ static void __bt_default_memory_changed_cb(keynode_t *node, void *data) root_path = default_memory ? BT_DOWNLOAD_MMC_FOLDER : BT_DOWNLOAD_MEDIA_FOLDER; download_path = default_memory ? BT_DOWNLOAD_MMC_FOLDER : BT_DOWNLOAD_PHONE_FOLDER; + if (access(download_path, W_OK) != 0) { + if (mkdir(download_path, 0755) < 0) { + DBG("mkdir fail![%s]", download_path); + } + } + bluetooth_obex_server_set_root(root_path); bluetooth_obex_server_set_destination_path(download_path); } } -void _bt_init_vconf_notification(void) +static void __bt_mmc_status_changed_cb(keynode_t *node, void *data) +{ + DBG("+"); + + int mmc_status = 0; + int default_memory = 0; + int ret = 0; + retm_if(!node || !data, "invalid param!"); + DBG("key=%s", vconf_keynode_get_name(node)); + struct bt_appdata *ad = (struct bt_appdata *)data; + + if (vconf_keynode_get_type(node) == VCONF_TYPE_INT) { + /* Phone memory is 0, MMC is 1 */ + mmc_status = vconf_keynode_get_int(node); + + if (mmc_status == VCONFKEY_SYSMAN_MMC_REMOVED || + mmc_status == VCONFKEY_SYSMAN_MMC_INSERTED_NOT_MOUNTED) { + retm_if(vconf_get_int(VCONFKEY_SETAPPL_DEFAULT_MEM_BLUETOOTH_INT, + &default_memory) != 0, + "vconf_get_int failed"); + + if (ad->opc_noti) { /* sending case */ + DBG("cancel outbound transfer"); + bluetooth_opc_cancel_push(); + ret = _bt_delete_notification(ad->opc_noti); + if (ret == NOTIFICATION_ERROR_NONE) { + ad->opc_noti = NULL; + ad->opc_noti_id = 0; + } + } else { /* receiving case */ + DBG("cancel inbound transfer"); + if (default_memory == BT_DEFAULT_MEM_MMC) { + _bt_obex_cancel_transfer(data); + retm_if(vconf_set_int( + VCONFKEY_SETAPPL_DEFAULT_MEM_BLUETOOTH_INT, + BT_DEFAULT_MEM_PHONE) != 0, "vconf_set_int failed"); + DBG("Default Memory set to Phone"); + } + } + } + } + DBG("-"); +} + +void _bt_init_vconf_notification(void *data) { int ret; + ret = vconf_notify_key_changed(VCONFKEY_SETAPPL_DEFAULT_MEM_BLUETOOTH_INT, __bt_default_memory_changed_cb, NULL); if (ret < 0) { - DBG("vconf_notify_key_changed failed\n"); + DBG("vconf_notify_key_changed init failed"); + } + + ret = vconf_notify_key_changed(VCONFKEY_SYSMAN_MMC_STATUS, + __bt_mmc_status_changed_cb, data); + if (ret < 0) { + DBG("vconf_notify_key_changed init failed"); } } void _bt_deinit_vconf_notification(void) { - vconf_ignore_key_changed(VCONFKEY_SETAPPL_DEFAULT_MEM_BLUETOOTH_INT, + int ret; + ret = vconf_ignore_key_changed(VCONFKEY_SETAPPL_DEFAULT_MEM_BLUETOOTH_INT, (vconf_callback_fn) __bt_default_memory_changed_cb); - return; + if (ret < 0) { + DBG("vconf_notify_key_changed deinit failed"); + } + + ret = vconf_ignore_key_changed(VCONFKEY_SYSMAN_MMC_STATUS, + (vconf_callback_fn) __bt_mmc_status_changed_cb); + if (ret < 0) { + DBG("vconf_notify_key_changed deinit failed"); + } } diff --git a/bt-share/src/bt-share-notification.c b/bt-share/src/bt-share-notification.c index 292e4b7..9e70171 100644 --- a/bt-share/src/bt-share-notification.c +++ b/bt-share/src/bt-share-notification.c @@ -26,6 +26,7 @@ #include "bt-share-common.h" #include "bt-share-notification.h" #include "bt-share-main.h" +#include "bt-share-ipc.h" #include "obex-event-handler.h" #include "bluetooth-share-api.h" #include "bt-share-resource.h" @@ -34,6 +35,11 @@ #define BT_PRIV_ID_STR_LEN 8 #define BT_NOTI_STR_LEN_MAX 50 +typedef enum { + CSC_DCM, + CSC_FTM, +} bt_csc_type_t; + notification_h _bt_create_notification(bt_qp_type_t type) { DBG("+\n"); @@ -49,113 +55,273 @@ notification_h _bt_create_notification(bt_qp_type_t type) return noti; } -int _bt_insert_notification(notification_h noti, - char *title, - char *content, - char *icon_path) +notification_h _bt_insert_notification(struct bt_appdata *ad, bt_notification_type_e type, int index, int total) { - DBG("+\n"); + notification_h noti = NULL; + notification_error_e ret = NOTIFICATION_ERROR_NONE; + notification_type_e noti_type = NOTIFICATION_TYPE_NONE; + char str[NOTIFICATION_TEXT_LEN_MAX] = { 0 }; + char *title = NULL; + char *content = NULL; + char *icon_path = NULL; + char *indicator_icon_path = NULL; + char *app_id = NULL; int noti_id = 0; + int flag = -1; + int success = 0; + int fail = 0; - if (!noti) - return BT_SHARE_FAIL; + DBG("Create notification type : %d", type); - DBG("Insert noti : %d \n", noti); - notification_error_e ret = NOTIFICATION_ERROR_NONE; + if (type == BT_SENT_NOTI) { + success = ad->send_data.tr_success; + fail = ad->send_data.tr_fail; - ret = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, icon_path); - if (ret != NOTIFICATION_ERROR_NONE) { - ERR("Fail to notification_set_image\n"); + if (success == 1) + content = "IDS_BT_MBODY_1_FILE_COPIED_PD_FAILED_ABB"; + else + content = "IDS_BT_MBODY_P1SD_FILES_COPIED_P2SD_FAILED_ABB"; + + title = "IDS_BT_MBODY_FILES_SENT_VIA_BLUETOOTH_ABB"; + icon_path = BT_ICON_NOTIFICATION_SENT; + indicator_icon_path = BT_ICON_NOTIFICATION_SENT_INDICATOR; + flag = NOTIFICATION_PROP_DISABLE_AUTO_DELETE; + app_id = NOTI_OPC_APP_ID; + noti_type = NOTIFICATION_TYPE_NOTI; + } else if (type == BT_RECEIVED_NOTI) { + success = ad->recv_data.tr_success; + fail = ad->recv_data.tr_fail; + + if (success == 1) + content = "IDS_BT_MBODY_1_FILE_COPIED_PD_FAILED_ABB"; + else + content = "IDS_BT_MBODY_P1SD_FILES_COPIED_P2SD_FAILED_ABB"; + + title = "IDS_BT_MBODY_FILES_RECEIVED_VIA_BLUETOOTH_ABB"; + icon_path = BT_ICON_NOTIFICATION_RECEIVED; + indicator_icon_path = BT_ICON_NOTIFICATION_RECEIVED_INDICATOR; + flag = NOTIFICATION_PROP_DISABLE_AUTO_DELETE; + app_id = NOTI_OPS_APP_ID; + noti_type = NOTIFICATION_TYPE_NOTI; + } else if (type == BT_SENDING_NOTI) { + title = "IDS_BT_MBODY_SEND_VIA_BLUETOOTH_ABB"; + content = "IDS_BT_SBODY_PREPARING_TO_SEND_FILES_ING_ABB"; + icon_path = BT_ICON_NOTIFICATION_SENDING; + indicator_icon_path = BT_ICON_NOTIFICATION_SENDING_INDICATOR; + flag = NOTIFICATION_PROP_DISABLE_TICKERNOTI; + noti_type = NOTIFICATION_TYPE_ONGOING; + } else if (type == BT_RECEIVING_NOTI) { + title = "IDS_BT_MBODY_RECEIVE_VIA_BLUETOOTH_ABB"; + content = "IDS_BT_SBODY_PREPARING_TO_RECEIVE_FILES_ING_ABB"; + icon_path = BT_ICON_NOTIFICATION_RECEIVING; + indicator_icon_path = BT_ICON_NOTIFICATION_RECEIVING_INDICATOR; + flag = NOTIFICATION_PROP_DISABLE_TICKERNOTI; + noti_type = NOTIFICATION_TYPE_ONGOING; + } + + noti = notification_create(noti_type); + if (!noti) { + ERR("Fail to notification_create"); + return NULL; + } + + notification_set_text_domain(noti, BT_COMMON_PKG, BT_COMMON_RES); + + if (total > 0) { + char *count_str = NULL; + + DBG("total : %d, index: %d", total, index); + + count_str = g_strdup_printf("[%d/%d]", index, total); + + if (count_str) { + ret = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_EVENT_COUNT, + NULL, count_str, NOTIFICATION_VARIABLE_TYPE_NONE); + if (ret != NOTIFICATION_ERROR_NONE) + ERR("Fail to notification_set_text [%d]", ret); + + g_free(count_str); + } } if (title) { ret = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, - title, NULL, NOTIFICATION_VARIABLE_TYPE_NONE); + NULL, title, + NOTIFICATION_VARIABLE_TYPE_NONE); if (ret != NOTIFICATION_ERROR_NONE) { - ERR("Fail to notification_set_text\n"); + ERR("Fail to notification_set_text [%d]", ret); } } if (content) { - ret = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, - content, NULL, NOTIFICATION_VARIABLE_TYPE_NONE); + if (type == BT_SENT_NOTI || type == BT_RECEIVED_NOTI) { + if (success == 1) + ret = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, + NULL, content, + NOTIFICATION_VARIABLE_TYPE_INT, fail, + NOTIFICATION_VARIABLE_TYPE_NONE); + else + ret = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, + NULL, content, + NOTIFICATION_VARIABLE_TYPE_INT, success, + NOTIFICATION_VARIABLE_TYPE_INT, fail, + NOTIFICATION_VARIABLE_TYPE_NONE); + } else { + ret = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, + NULL, content, NOTIFICATION_VARIABLE_TYPE_NONE); + } + + if (ret != NOTIFICATION_ERROR_NONE) { + ERR("Fail to notification_set_text [%d]", ret); + } + } + + if (icon_path) { + ret = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, icon_path); + if (ret != NOTIFICATION_ERROR_NONE) { + ERR("Fail to notification_set_image [%d]", ret); + } + } + + if (indicator_icon_path) { + ret = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON_FOR_INDICATOR, indicator_icon_path); + if (ret != NOTIFICATION_ERROR_NONE) { + ERR("Fail to notification_set_image [%d]", ret); + } + } + + if (flag != -1) { + ret = notification_set_property(noti, flag); if (ret != NOTIFICATION_ERROR_NONE) { - ERR("Fail to notification_set_text\n"); + ERR("Fail to notification_set_property [%d]", ret); } } + if (app_id) { + ret = notification_set_pkgname(noti, app_id); + if (ret != NOTIFICATION_ERROR_NONE) { + ERR("Fail to notification_set_pkgname [%d]", ret); + } + } + + ret = notification_set_display_applist(noti, + NOTIFICATION_DISPLAY_APP_NOTIFICATION_TRAY | + NOTIFICATION_DISPLAY_APP_INDICATOR); + if (ret != NOTIFICATION_ERROR_NONE) { + ERR("Fail to notification_set_display_applist [%d]", ret); + } + + if (type == BT_SENT_NOTI) { + _bt_set_notification_app_launch(noti, CREATE_TR_LIST, + NOTI_TR_TYPE_OUT, NULL, NULL, 0); + } else if (type == BT_RECEIVED_NOTI) { + _bt_set_notification_app_launch(noti, CREATE_TR_LIST, + NOTI_TR_TYPE_IN, NULL, NULL, 0); + } + ret = notification_insert(noti, ¬i_id); if (ret != NOTIFICATION_ERROR_NONE) { - ERR("Fail to notification_insert\n"); + ERR("Fail to notification_insert [%d]", ret); } - DBG("-\n"); - return noti_id; + if (type == BT_SENT_NOTI) + ad->send_noti_id = noti_id; + else if (type == BT_RECEIVED_NOTI) + ad->receive_noti_id = noti_id; + + INFO("Insert %s type: %d ", (type == BT_SENT_NOTI || type == BT_RECEIVED_NOTI) ? + "Notification" : "Ongoing", noti); + + return noti; } -int _bt_update_notification(notification_h noti, - char *title, - char *content, - char *icon_path) +int _bt_update_notification(struct bt_appdata *ad, notification_h noti, + char *title, char *content, char *icon_path) { - DBG("+\n"); - char str[BT_NOTI_STR_LEN_MAX] = {0,}; - - if (!noti) - return BT_SHARE_FAIL; + retvm_if (!noti, BT_SHARE_FAIL, "noti is NULL"); - DBG("Insert noti : %d \n", noti); + INFO("Update noti : %d", noti); notification_error_e ret = NOTIFICATION_ERROR_NONE; + char str[NOTIFICATION_TEXT_LEN_MAX] = { 0 }; + int success = 0; + int fail = 0; - ret = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, icon_path); - if (ret != NOTIFICATION_ERROR_NONE) { - ERR("Fail to notification_set_image\n"); + if (ad->send_noti == noti) { + success = ad->send_data.tr_success; + fail = ad->send_data.tr_fail; + + if (success == 1) + content = "IDS_BT_MBODY_1_FILE_COPIED_PD_FAILED_ABB"; + else + content = "IDS_BT_MBODY_P1SD_FILES_COPIED_P2SD_FAILED_ABB"; + } else if (ad->receive_noti == noti) { + success = ad->recv_data.tr_success; + fail = ad->recv_data.tr_fail; + + if (success == 1) + content = "IDS_BT_MBODY_1_FILE_COPIED_PD_FAILED_ABB"; + else + content = "IDS_BT_MBODY_P1SD_FILES_COPIED_P2SD_FAILED_ABB"; } if (title) { - snprintf(str, sizeof(str), "%s: %s", BT_STR_SHARE, title); - - ret = notification_set_text(noti, - NOTIFICATION_TEXT_TYPE_TITLE, - str, NULL, - NOTIFICATION_VARIABLE_TYPE_NONE); + ret = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_TITLE, + NULL, title, + NOTIFICATION_VARIABLE_TYPE_NONE); if (ret != NOTIFICATION_ERROR_NONE) { - ERR("Fail to notification_set_text\n"); + ERR("Fail to notification_set_text [%d]", ret); } } if (content) { - ret = notification_set_text(noti, - NOTIFICATION_TEXT_TYPE_CONTENT, - content, NULL, - NOTIFICATION_VARIABLE_TYPE_NONE); + if (noti == ad->send_noti|| noti == ad->receive_noti) { + if (success == 1) + ret = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, + NULL, content, + NOTIFICATION_VARIABLE_TYPE_INT, fail, + NOTIFICATION_VARIABLE_TYPE_NONE); + else + ret = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, + NULL, content, + NOTIFICATION_VARIABLE_TYPE_INT, success, + NOTIFICATION_VARIABLE_TYPE_INT, fail, + NOTIFICATION_VARIABLE_TYPE_NONE); + } else { + ret = notification_set_text(noti, NOTIFICATION_TEXT_TYPE_CONTENT, + NULL, content, NOTIFICATION_VARIABLE_TYPE_NONE); + } + + if (ret != NOTIFICATION_ERROR_NONE) { + ERR("Fail to notification_set_text [%d]", ret); + } + } + + if (icon_path) { + ret = notification_set_image(noti, NOTIFICATION_IMAGE_TYPE_ICON, icon_path); if (ret != NOTIFICATION_ERROR_NONE) { - ERR("Fail to notification_set_text\n"); + ERR("Fail to notification_set_image [%d]", ret); } } ret = notification_update(noti); if (ret != NOTIFICATION_ERROR_NONE) { - ERR("Fail to notification_update\n"); + ERR("Fail to notification_update [%d]", ret); } - DBG("-\n"); return ret; } -int _bt_update_notification_progress(void *handle, - int id, - int val) +int _bt_update_notification_progress(notification_h not, + int id, int val) { notification_error_e ret = NOTIFICATION_ERROR_NONE; - ret = notification_update_progress(handle, id, (double)val / 100); + ret = notification_update_progress(not, id, (double)val / 100); if (ret != NOTIFICATION_ERROR_NONE) { - ERR("Fail to notification_update_progress\n"); + ERR("Fail to notification_update_progress [%d]\n", ret); } return ret; } - gboolean _bt_get_notification_text(int priv_id, char *str) { notification_error_e ret = NOTIFICATION_ERROR_NONE; @@ -186,6 +352,19 @@ gboolean _bt_get_notification_text(int priv_id, char *str) return TRUE; } +int _bt_get_notification_priv_id(notification_h noti) +{ + int group_id = 0; + int priv_id = 0; + notification_error_e ret = NOTIFICATION_ERROR_NONE; + + ret = notification_get_id(noti, &group_id, &priv_id); + if (ret != NOTIFICATION_ERROR_NONE) { + ERR("Fail to notification_get_id [%d]", ret); + } + return priv_id; +} + int _bt_delete_notification(notification_h noti) { DBG("+\n"); @@ -205,10 +384,11 @@ int _bt_delete_notification(notification_h noti) } int _bt_set_notification_app_launch(notification_h noti, - bt_qp_launch_type_t type, - const char *transfer_type, - const char *filename, - const char *progress_cnt) + bt_notification_launch_type_e launch_type, + const char *transfer_type, + const char *filename, + const char *progress_cnt, + int transfer_id) { DBG("+\n"); if (!noti) @@ -223,9 +403,7 @@ int _bt_set_notification_app_launch(notification_h noti, if (!b) return -1; - if (type == CREATE_PROGRESS) { - int group_id = 0; - int priv_id = 0; + if (launch_type == CREATE_PROGRESS) { double percentage = 0; char progress[BT_PERCENT_STR_LEN] = { 0 }; char priv_id_str[BT_PRIV_ID_STR_LEN] = { 0 }; @@ -237,15 +415,11 @@ int _bt_set_notification_app_launch(notification_h noti, ret = notification_get_progress(noti, &percentage); if (ret != NOTIFICATION_ERROR_NONE) - ERR("Fail to notification_update_progress\n"); + ERR("Fail to notification_get_progress [%d]\n", ret); else snprintf(progress, BT_PERCENT_STR_LEN, "%d", (int)percentage); - ret = notification_get_id(noti, &group_id, &priv_id); - if (ret != NOTIFICATION_ERROR_NONE) - ERR("Fail to notification_update_progress\n"); - else - snprintf(priv_id_str, BT_PRIV_ID_STR_LEN, "%d", priv_id); + snprintf(priv_id_str, BT_PRIV_ID_STR_LEN, "%d", transfer_id); appsvc_set_pkgname(b, UI_PACKAGE); appsvc_add_data(b, "launch-type", "ongoing"); @@ -260,7 +434,7 @@ int _bt_set_notification_app_launch(notification_h noti, } appsvc_add_data(b, "progress_cnt", progress_cnt); } - } else if (type == CREATE_TR_LIST) { + } else if (launch_type == CREATE_TR_LIST) { appsvc_set_pkgname(b, UI_PACKAGE); appsvc_add_data(b, "launch-type", "transfer_list"); appsvc_add_data(b, "transfer_type", transfer_type); @@ -270,10 +444,10 @@ int _bt_set_notification_app_launch(notification_h noti, } ret = notification_set_execute_option(noti, - NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, - NULL, NULL, b); + NOTIFICATION_EXECUTE_TYPE_SINGLE_LAUNCH, + NULL, NULL, b); if (ret != NOTIFICATION_ERROR_NONE) { - ERR("Fail to notification_set_execute_option\n"); + ERR("Fail to notification_set_execute_option [%d]\n", ret); } bundle_free(b); @@ -281,7 +455,6 @@ int _bt_set_notification_app_launch(notification_h noti, return ret; } - int _bt_set_notification_property(notification_h noti, int flag) { DBG("+\n"); @@ -306,6 +479,160 @@ int _bt_set_notification_property(notification_h noti, int flag) return ret; } +gboolean _bt_update_notification_status(struct bt_appdata *ad ) +{ + notification_h noti = NULL; + notification_list_h list_head = NULL; + notification_list_h list_traverse = NULL; + char *app_id = NULL; + gboolean is_noti_existed = FALSE; + gboolean send_noti = FALSE; + gboolean receive_noti = FALSE; + sqlite3 *db = NULL; + int group_id = 0; + int priv_id = 0; + int ret; + + retv_if (ad == NULL, FALSE); + + /* When bt-share is launched, need to update notification status */ + + notification_get_list(NOTIFICATION_TYPE_NOTI, -1, &list_head); + list_traverse = list_head; + + while (list_traverse != NULL) { + noti = notification_list_get_data(list_traverse); + notification_get_pkgname(noti, &app_id); + + if (g_strcmp0(app_id, NOTI_OPS_APP_ID) == 0) { + ret = notification_clone(noti, &ad->receive_noti); + if (ret != NOTIFICATION_ERROR_NONE) { + ERR("Fail to clone notificatoin"); + } + ret = notification_get_id(noti, &group_id, &priv_id); + if (ret != NOTIFICATION_ERROR_NONE) { + ERR("Fail to get notification id"); + } + ad->receive_noti_id = priv_id; + receive_noti = TRUE; + } else if (g_strcmp0(app_id, NOTI_OPC_APP_ID) == 0) { + ret = notification_clone(noti, &ad->send_noti); + if (ret != NOTIFICATION_ERROR_NONE) { + ERR("Unable to clone notificatoin"); + } + ret = notification_get_id(noti, &group_id, &priv_id); + if (ret != NOTIFICATION_ERROR_NONE) { + ERR("Fail to get notification id"); + } + ad->send_noti_id = priv_id; + send_noti = TRUE; + } + + if (receive_noti || send_noti) { + time_t ret_time; + + /* Set notication insert_time */ + notification_get_insert_time(noti, &ret_time); + notification_set_time(noti, ret_time); + notification_update(noti); + is_noti_existed = TRUE; + } + + list_traverse = notification_list_get_next(list_traverse); + } + + if (list_head != NULL) { + notification_free_list(list_head); + list_head = NULL; + } + + /* If notification item is removed durning BT off, need to remove DB */ + db = bt_share_open_db(); + if (!db) + return is_noti_existed; + + if (!receive_noti) + bt_share_remove_all_tr_data(db, BT_DB_INBOUND); + if (!send_noti) + bt_share_remove_all_tr_data(db, BT_DB_OUTBOUND); + bt_share_close_db(db); + + return is_noti_existed; +} + +static void __bt_notification_changed_cb(void *data, notification_type_e type, notification_op *op_list, int num_op) +{ + DBG("__bt_notification_changed_cb"); + + retm_if (data == NULL, "Invalid data"); + struct bt_appdata *ad = (struct bt_appdata *)data; + gboolean is_sent_noti_exist = FALSE; + gboolean is_received_noti_exist = FALSE; + notification_h noti = NULL; + notification_list_h noti_list = NULL; + notification_error_e noti_err = NOTIFICATION_ERROR_NONE; + int group_id; + int priv_id; + sqlite3 *db = NULL; + + retm_if (op_list == NULL, "Invalid op_list"); + + if (type != NOTIFICATION_TYPE_NOTI || + (op_list->type != NOTIFICATION_OP_DELETE && + op_list->type != NOTIFICATION_OP_DELETE_ALL)) + return; + + if (ad->send_noti == NULL && ad->receive_noti == NULL) + return; + + noti_err = notification_get_list(type, -1, ¬i_list); + ret_if (noti_err != NOTIFICATION_ERROR_NONE); + + noti_list = notification_list_get_head(noti_list); + while (noti_list) { + noti = notification_list_get_data(noti_list); + noti_err = notification_get_id(noti, &group_id, &priv_id); + if (noti_err == NOTIFICATION_ERROR_NONE) { + if (ad->send_noti_id == priv_id) + is_sent_noti_exist = TRUE; + else if (ad->receive_noti_id == priv_id) + is_received_noti_exist = TRUE; + } + noti_list = notification_list_get_next(noti_list); + } + notification_free_list(noti_list); + + db = bt_share_open_db(); + retm_if(!db, "fail to open db!"); + + if (is_sent_noti_exist == FALSE) { + DBG("Not found sent notification. Delete outbound db"); + ad->send_noti = NULL; + ad->send_noti_id = 0; + if (bt_share_remove_tr_data_by_notification(db, + BT_DB_OUTBOUND) == BT_SHARE_ERR_NONE) { + ad->send_data.tr_fail = 0; + ad->send_data.tr_success = 0; + } + } + if (is_received_noti_exist == FALSE) { + DBG("Not found recv notification. Delete inbound db"); + ad->receive_noti = NULL; + ad->receive_noti_id = 0; + if (bt_share_remove_tr_data_by_notification(db, + BT_DB_INBOUND) == BT_SHARE_ERR_NONE) { + ad->recv_data.tr_fail = 0; + ad->recv_data.tr_success = 0; + } + } + + bt_share_close_db(db); + + DBG("SEND: Success[%d] Fail[%d] ||||| RECEIVE: Success[%d] Fail[%d]", + ad->send_data.tr_success, ad->send_data.tr_fail, + ad->recv_data.tr_success, ad->recv_data.tr_fail); + +} static void __bt_noti_changed_cb(void *data, notification_type_e type) { @@ -355,9 +682,9 @@ void _bt_register_notification_cb(struct bt_appdata *ad) { notification_error_e noti_err = NOTIFICATION_ERROR_NONE; - noti_err = notification_resister_changed_cb(__bt_noti_changed_cb, ad); + noti_err = notification_register_detailed_changed_cb(__bt_notification_changed_cb, ad); if (noti_err != NOTIFICATION_ERROR_NONE) { - ERR("notification_resister_changed_cb failed %d \n", noti_err); + ERR("notification_resister_changed_cb failed [%d]\n", noti_err); } } @@ -365,8 +692,8 @@ void _bt_unregister_notification_cb(struct bt_appdata *ad) { notification_error_e noti_err = NOTIFICATION_ERROR_NONE; - noti_err = notification_unresister_changed_cb(__bt_noti_changed_cb); + noti_err = notification_unregister_detailed_changed_cb(__bt_notification_changed_cb, NULL); if (noti_err != NOTIFICATION_ERROR_NONE) { - ERR("notification_unresister_changed_cb failed %d \n", noti_err); + ERR("notification_unresister_changed_cb failed [%d]\n", noti_err); } } diff --git a/bt-share/src/bt-share-syspopup.c b/bt-share/src/bt-share-syspopup.c index bdd56d4..4cb16af 100644 --- a/bt-share/src/bt-share-syspopup.c +++ b/bt-share/src/bt-share-syspopup.c @@ -20,6 +20,8 @@ #include #include #include +#include +#include #include "applog.h" #include "bluetooth-api.h" #include "bt-share-syspopup.h" @@ -34,54 +36,83 @@ extern struct bt_appdata *app_state; static gboolean __bt_system_popup_timer_cb(gpointer user_data) { - if (NULL == (void *)user_data) { + int ret = 0; + bundle *b = (bundle *) user_data; + + if (NULL == b) { ERR("There is some problem with the user data..popup can not be created\n"); return FALSE; } - INFO("bt system popup timer cb notification"); - - // TODO : display a popup + ret = syspopup_launch("bt-syspopup", b); + if (0 > ret) { + ERR("launching sys-popup failed\n"); + } + bundle_free(b); return FALSE; } int _bt_launch_system_popup(bt_app_event_type_t event_type, - bt_app_sys_popup_params_t *popup_params, - void *cb, - void *data) + bt_app_sys_popup_params_t *popup_params, + void *cb, + void *data) { + int ret = 0; + bundle *b = NULL; char event_str[BT_SYSPOPUP_EVENT_LEN_MAX] = { 0 }; struct bt_appdata *ad = app_state; DBG("+\n"); - if(cb == NULL) + + b = bundle_create(); + if(b == NULL) { + ERR("bundle_create failed"); return -1; + } + + bundle_add(b, "title", popup_params->title); + bundle_add(b, "type", popup_params->type); + bundle_add(b, "file", popup_params->file); + bundle_add(b, "device_name", popup_params->device_name); switch (event_type) { - case BT_APP_EVENT_CONFIRM_MODE_REQUEST: - strncpy(event_str, "app-confirm-request", sizeof(event_str)); - break; - case BT_APP_EVENT_FILE_RECEIVED: - strncpy(event_str, "file-received", sizeof(event_str)); - break; - case BT_APP_EVENT_INFORMATION: - strncpy(event_str, "bt-information", sizeof(event_str)); - break; - case BT_APP_EVENT_OVERWRITE_REQUEST: - strncpy(event_str, "confirm-overwrite-request", sizeof(event_str)); - break; - default: - break; + case BT_APP_EVENT_CONFIRM_MODE_REQUEST: + strncpy(event_str, "app-confirm-request", sizeof(event_str)); + break; + case BT_APP_EVENT_FILE_RECEIVED: + strncpy(event_str, "file-received", sizeof(event_str)); + break; + case BT_APP_EVENT_INFORMATION: + strncpy(event_str, "bt-information", sizeof(event_str)); + break; + case BT_APP_EVENT_OVERWRITE_REQUEST: + strncpy(event_str, "confirm-overwrite-request", sizeof(event_str)); + break; + default: + break; } - ad->syspopup_call = 0; - - INFO("bt_launch_system_popup"); + bundle_add(b, "event-type", event_str); + + /*The system popup launch function is not able to launch second popup + * if first popup is being processed still, this due to the check + * in AUL module to restrict multiple launching of syspopup, + * to solve this problem after discussion it is decided that if + * the popup launch fails then it will be retried + * after small timeout. */ + ret = syspopup_launch("bt-syspopup", b); + if (0 > ret) { + ERR("Popup launch failed...retry = %d\n", ret); + g_timeout_add(BT_POPUP_SYSPOPUP_TIMEOUT_FOR_MULTIPLE_POPUPS, + (GSourceFunc) __bt_system_popup_timer_cb, b); + } else { + bundle_free(b); + } - // TODO : display a popup + if (cb != NULL) + ad->popups.popup_cb = (bt_app_cb) cb; - ad->popups.popup_cb = (bt_app_cb) cb; ad->popups.popup_cb_data = data; ad->popups.syspopup_request = TRUE; @@ -89,7 +120,6 @@ int _bt_launch_system_popup(bt_app_event_type_t event_type, return 0; } - gboolean _bt_app_popup_memoryfull(gpointer user_data) { bt_app_sys_popup_params_t popup_params = { NULL }; diff --git a/bt-share/src/obex-event-handler.c b/bt-share/src/obex-event-handler.c index 4a8c30a..4546f24 100644 --- a/bt-share/src/obex-event-handler.c +++ b/bt-share/src/obex-event-handler.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #ifdef ENABLE_CALENDAR_SERVICE2 #include @@ -34,6 +35,9 @@ #include #include #include +#include +#include +#include /* For multi-user support */ #include @@ -58,11 +62,20 @@ typedef struct { int noti_id; } bt_noti_data_t; +typedef struct { + char *file_path; + bt_file_type_t file_type; +} bt_file_info_t; + bt_obex_server_authorize_into_t server_auth_info; extern GSList *bt_transfer_list; GSList *bt_receive_noti_list; -gboolean _bt_obex_writeclose(bt_obex_server_transfer_info_t *transfer_complete_info); +static gboolean isFirstReceivedPacket = FALSE; + +static gboolean isTransferConnectedReceived = FALSE; + +void *_bt_obex_writeclose(bt_file_info_t *info); static void __bt_obex_file_push_auth(bt_obex_server_authorize_into_t *server_auth_info); @@ -96,6 +109,21 @@ static char *__get_file_name(int cnt, char **path) return pfilename; } +static bt_file_type_t __get_file_type(char *extn) +{ + DBG("exten : %s \n", extn); + + if (NULL != extn) { + if (!strcmp(extn, "vcf")) + return BT_FILE_VCARD; + else if (!strcmp(extn, "vcs")) + return BT_FILE_VCAL; + else if (!strcmp(extn, "vbm")) + return BT_FILE_VBOOKMARK; + } + return BT_FILE_OTHER; +} + static void __delete_notification(gpointer data, gpointer user_data) { bt_noti_data_t *noti_data = data; @@ -125,6 +153,29 @@ int _bt_get_transfer_id_by_noti_id(int noti_id) return -1; } +void _bt_obex_cancel_transfer(void *data) +{ + DBG("+"); + retm_if(!data, "invalid param!"); + GSList *l = NULL; + bt_noti_data_t *noti_data = NULL; + int ret = 0; + + for (l = bt_receive_noti_list; l != NULL; l = l->next) { + noti_data = l->data; + + if (noti_data == NULL) + continue; + + DBG("noti_id : %d", noti_data->noti_id); + ret = bluetooth_obex_server_cancel_transfer(noti_data->transfer_id); + if(ret != BLUETOOTH_ERROR_NONE) { + ERR("bluetooth_obex_server_cancel_transfer[ret:%d]", ret); + } + } + DBG("-"); +} + void _bt_clear_receive_noti_list(void) { if (bt_receive_noti_list) { @@ -136,425 +187,507 @@ void _bt_clear_receive_noti_list(void) } } +char * __get_dest_file_path(const char *path) +{ + char file_path[BT_TEMP_FILE_PATH_LEN_MAX] = { 0, }; + + /* Media updation is failing if we give FTP folder path. + So we have to map the FTP folder path like below + /opt/share/bt-ftp/Media/XX -> /opt/usr/media/XX + /opt/share/bt-ftp/SD_External/XX -> /opt/storage/sdcard/XX + */ + if (g_str_has_prefix(path, BT_FTP_FOLDER_PHONE)) { + snprintf(file_path, sizeof(file_path), "%s/%s", + BT_DOWNLOAD_PHONE_ROOT, + path + strlen(BT_FTP_FOLDER_PHONE)); + } else if (g_str_has_prefix(path, BT_FTP_FOLDER_MMC)) { + snprintf(file_path, sizeof(file_path), "%s/%s", + BT_DOWNLOAD_MMC_ROOT, + path + strlen(BT_FTP_FOLDER_MMC)); + } else { + snprintf(file_path, sizeof(file_path), "%s", path); + } + + DBG("File path %s", file_path); + + return g_strdup(file_path); +} + +static void __free_file_info(bt_file_info_t *info) +{ + g_free(info->file_path); + g_free(info); +} + void _bt_share_event_handler(int event, bluetooth_event_param_t *param, - void *user_data) + void *user_data) { - int noti_id; + int ret; static int send_index = 0; - char *name = NULL; - char str[NOTIFICATION_TEXT_LEN_MAX] = { 0 }; - char opc_cnt[NOTIFICATION_TEXT_LEN_MAX] = { 0 }; int percentage = 0; + int s_id = 0; + char *name = NULL; + char opc_cnt[NOTIFICATION_TEXT_LEN_MAX] = {0, }; notification_h noti = NULL; - bt_obex_server_authorize_into_t *auth_info; - bt_obex_server_transfer_info_t *transfer_info; + bt_obex_server_authorize_into_t *auth_info = NULL; + bt_obex_server_transfer_info_t *transfer_info = NULL; opc_transfer_info_t *node = NULL; struct bt_appdata *ad = app_state; bt_tr_data_t *info = NULL; bt_opc_transfer_info_t *client_info = NULL; - bt_noti_data_t *data; - int s_id = 0; + bt_noti_data_t *data = NULL; + pthread_t thread_id; if (bt_transfer_list) node = bt_transfer_list->data; - DBG("OPC event : [0x%x] \n", event); switch (event) { - case BLUETOOTH_EVENT_ENABLED: - if (ad->obex_server_init == FALSE) { - if (_bt_init_obex_server() == BT_SHARE_ERROR_NONE) - ad->obex_server_init = TRUE; - } - break; - - case BLUETOOTH_EVENT_DISABLED: - g_free(server_auth_info.filename); - server_auth_info.filename = NULL; - _bt_terminate_app(); - break; - - case BLUETOOTH_EVENT_OPC_CONNECTED: - DBG("BLUETOOTH_EVENT_OPC_CONNECTED, result [%d] \n", param->result); - if (param->result != BLUETOOTH_ERROR_NONE) { - _bt_create_warning_popup(param->result); - if (NULL != node && node->file_cnt > send_index) { - info = (bt_tr_data_t *)(ad->tr_next_data)->data; - if (info == NULL) { - DBG("info is NULL"); - return; - } + case BLUETOOTH_EVENT_ENABLED: + if (ad->obex_server_init == FALSE) { + if (_bt_init_obex_server() == BT_SHARE_ERROR_NONE) + ad->obex_server_init = TRUE; + } + break; - s_id = info->sid; - DBG("info->sid = %d info->id = %d\n", info->sid, info->id); - while (NULL != ad->tr_next_data) { + case BLUETOOTH_EVENT_OPC_CONNECTED: + INFO("BLUETOOTH_EVENT_OPC_CONNECTED, result [%d] \n", param->result); + send_index = 0; + if (param->result != BLUETOOTH_ERROR_NONE) { + _bt_create_warning_popup(param->result, + BT_STR_UNABLE_TO_SEND); + if (NULL != node && node->file_cnt > send_index) { + if (ad->tr_next_data == NULL) { + ERR("ad->tr_next_data is NULL"); + return; + } info = (bt_tr_data_t *)(ad->tr_next_data)->data; - if (info == NULL) - break; - DBG("info->sid = %d info->id = %d\n", info->sid, info->id); - if (info->sid != s_id) { - DBG("SID did not match so break done.\n"); - break; + if (info == NULL) { + ERR("info is NULL"); + return; } - _bt_update_sent_data_status(info->id, BT_TR_FAIL); - ad->send_data.tr_fail++; - ad->tr_next_data = g_slist_next(ad->tr_next_data); - } + s_id = info->sid; + INFO("info->sid = %d info->id = %d", info->sid, info->id); + while (NULL != ad->tr_next_data) { + info = (bt_tr_data_t *)(ad->tr_next_data)->data; + if (info == NULL) + break; + INFO("info->sid = %d info->id = %d", info->sid, info->id); + if (info->sid != s_id) { + DBG("SID did not match so break done."); + break; + } + + _bt_update_sent_data_status(info->id, BT_TR_FAIL); + ad->send_data.tr_fail++; + ad->tr_next_data = g_slist_next(ad->tr_next_data); + } + _bt_update_transfer_list_view("outbound"); - snprintf(str, sizeof(str), BT_TR_STATUS, - ad->send_data.tr_success, - ad->send_data.tr_fail); + if (ad->send_noti == NULL) { + ad->send_noti = _bt_insert_notification(ad, BT_SENT_NOTI, 0, 0); + } else { + _bt_update_notification(ad, ad->send_noti, NULL, NULL, NULL); + } + } - DBG("str = [%s] \n", str); + _remove_transfer_info(node); - if (ad->send_noti == NULL) { - noti = _bt_create_notification(BT_NOTI_T); - _bt_set_notification_app_launch(noti, CREATE_TR_LIST, - NOTI_TR_TYPE_OUT, NULL, NULL); - _bt_set_notification_property(noti, QP_NO_DELETE); - _bt_insert_notification(noti, - BT_STR_SENT, str, - BT_ICON_QP_SEND); - ad->send_noti = noti; - } else { - _bt_update_notification(ad->send_noti, - BT_STR_SENT, str, - BT_ICON_QP_SEND); + if (!ad->tr_next_data) { + bt_share_release_tr_data_list(ad->tr_send_list); + ad->tr_send_list = NULL; } - } - send_index = 0; - _remove_transfer_info(node); + } else { + ret = notification_status_message_post(BT_STR_SENDING); + if (ret != NOTIFICATION_ERROR_NONE) + ERR("notification_status_message_post() is failed : %d", ret); - if (!ad->tr_next_data) { - bt_share_release_tr_data_list(ad->tr_send_list); - ad->tr_send_list = NULL; + _bt_share_block_sleep(TRUE); + _bt_set_transfer_indicator(TRUE); } + break; - _bt_update_transfer_list_view(BT_OUTBOUND_TABLE); - } else { - _bt_share_block_sleep(TRUE); - _bt_set_transfer_indicator(TRUE); - } - break; - case BLUETOOTH_EVENT_OPC_TRANSFER_STARTED: - DBG("BLUETOOTH_EVENT_OPC_TRANSFER_STARTED \n"); + case BLUETOOTH_EVENT_OPC_TRANSFER_STARTED: + INFO("BLUETOOTH_EVENT_OPC_TRANSFER_STARTED"); + ret_if(node == NULL); + + if (ad->opc_noti) { + _bt_delete_notification(ad->opc_noti); + ad->opc_noti = NULL; + ad->opc_noti_id = 0; + } - ret_if(node == NULL); - name = __get_file_name(send_index++, node->file_path); - snprintf(opc_cnt, sizeof(opc_cnt), "%d/%d", + name = __get_file_name(send_index++, node->file_path); + snprintf(opc_cnt, sizeof(opc_cnt), "%d/%d", send_index, node->file_cnt); - if (ad->opc_noti) { - _bt_delete_notification(ad->opc_noti); - ad->opc_noti = NULL; - ad->opc_noti_id = 0; - } + noti = _bt_insert_notification(ad, BT_SENDING_NOTI, send_index, node->file_cnt); + ad->opc_noti_id = _bt_get_notification_priv_id(noti); + _bt_set_notification_app_launch(noti, CREATE_PROGRESS, + NOTI_TR_TYPE_OUT, name, opc_cnt, 0); - noti = _bt_create_notification(BT_ONGOING_T); - _bt_set_notification_property(noti, QP_NO_TICKER); - ad->opc_noti_id = _bt_insert_notification(noti, - name, opc_cnt, - BT_ICON_QP_SEND); - _bt_set_notification_app_launch(noti, CREATE_PROGRESS, - NOTI_TR_TYPE_OUT, name, opc_cnt); - _bt_update_notification(noti, NULL, NULL, NULL); + ad->opc_noti = noti; - ad->opc_noti = noti; + INFO("file count %d", node->file_cnt); + _bt_update_notification(ad, ad->opc_noti, name, NULL, NULL); + _bt_update_transfer_list_view("outbound"); - if (ad->tr_next_data == NULL) { - ERR("ad->tr_next_data is NULL \n"); + if (ad->tr_next_data == NULL) { + ERR("ad->tr_next_data is NULL"); + return; + } + + info = (bt_tr_data_t *)(ad->tr_next_data)->data; + ret_if(info == NULL); + ad->current_tr_uid = info->id; + INFO("ad->current_tr_uid = [%d]", ad->current_tr_uid); break; - } - info = (bt_tr_data_t *)(ad->tr_next_data)->data; - if (info == NULL) + + case BLUETOOTH_EVENT_OPC_TRANSFER_PROGRESS: + client_info = (bt_opc_transfer_info_t *)param->param_data; + ret_if(client_info == NULL); + + name = strrchr(client_info->filename, '/'); + if (name) + name++; + else + name = client_info->filename; + + percentage = client_info->percentage; + + _bt_update_notification_progress(NULL, + ad->opc_noti_id, percentage); break; - ad->current_tr_uid = info->id; - DBG("ad->current_tr_uid = [%d] \n", ad->current_tr_uid); - break; - case BLUETOOTH_EVENT_OPC_TRANSFER_PROGRESS: - client_info = (bt_opc_transfer_info_t *)param->param_data; - ret_if(client_info == NULL); + case BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE: + INFO("BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE"); - name = strrchr(client_info->filename, '/'); - if (name) - name++; - else - name = client_info->filename; + client_info = (bt_opc_transfer_info_t *)param->param_data; + ret_if(client_info == NULL); - percentage = client_info->percentage; - _bt_update_notification_progress(NULL, - ad->opc_noti_id, percentage); - _bt_send_message_to_ui(ad->opc_noti_id, name, percentage, - FALSE, BLUETOOTH_ERROR_NONE); - break; + DBG("client_info->filename = [%s]", client_info->filename); + INFO("ad->current_tr_uid = [%d]", ad->current_tr_uid); - case BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE: - DBG("BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE \n"); - client_info = (bt_opc_transfer_info_t *)param->param_data; - ret_if(client_info == NULL); + name = strrchr(client_info->filename, '/'); + if (name) + name++; + else + name = client_info->filename; - DBG("client_info->filename = [%s] \n", client_info->filename); - DBG("ad->current_tr_uid = [%d] \n", ad->current_tr_uid); + DBG("name address = [%x]", name); - name = strrchr(client_info->filename, '/'); - if (name) - name++; - else - name = client_info->filename; - DBG("name address = [%x] \n", name); - _bt_send_message_to_ui(ad->opc_noti_id, name, 100, TRUE, param->result); + if (ad->opc_noti) { + _bt_delete_notification(ad->opc_noti); + ad->opc_noti = NULL; + ad->opc_noti_id = 0; + } + INFO("ad->send_data.tr_fail = %d, ad->send_data.tr_success= %d", + ad->send_data.tr_fail, ad->send_data.tr_success); - _bt_delete_notification(ad->opc_noti); - ad->opc_noti = NULL; - ad->opc_noti_id = 0; + if (param->result != BLUETOOTH_ERROR_NONE) + ad->send_data.tr_fail++; + else { + ad->send_data.tr_success++; + _bt_remove_tmp_file(client_info->filename); + _bt_remove_vcf_file(client_info->filename); + } - DBG("ad->send_data.tr_fail = %d, ad->send_data.tr_success= %d \n", - ad->send_data.tr_fail, ad->send_data.tr_success); + if (ad->send_noti == NULL) { + ad->send_noti = _bt_insert_notification(ad, BT_SENT_NOTI, 0, 0); + } else { + _bt_update_notification(ad, ad->send_noti, NULL, NULL, NULL); + } - if (param->result != BLUETOOTH_ERROR_NONE) - ad->send_data.tr_fail++; - else - ad->send_data.tr_success++; - - snprintf(str, sizeof(str), BT_TR_STATUS, - ad->send_data.tr_success, - ad->send_data.tr_fail); - - DBG("str = [%s] \n", str); - - if (ad->send_noti == NULL) { - noti = _bt_create_notification(BT_NOTI_T); - _bt_set_notification_app_launch(noti, CREATE_TR_LIST, - NOTI_TR_TYPE_OUT, NULL, NULL); - _bt_set_notification_property(noti, QP_NO_DELETE); - _bt_insert_notification(noti, - BT_STR_SENT, str, - BT_ICON_QP_SEND); - ad->send_noti = noti; - } else { - _bt_update_notification(ad->send_noti, - BT_STR_SENT, str, - BT_ICON_QP_SEND); - } + if (param->result != BLUETOOTH_ERROR_NONE) { + _bt_update_sent_data_status(ad->current_tr_uid, + BT_TR_FAIL); + DBG("opp_transfer_abort by user %d ", ad->opp_transfer_abort); + if (!ad->opp_transfer_abort) + _bt_create_warning_popup(param->result, + BT_STR_UNABLE_TO_SEND); + ad->opp_transfer_abort = FALSE; + } else { + _bt_update_sent_data_status(ad->current_tr_uid, + BT_TR_SUCCESS); + } - _bt_remove_tmp_file(client_info->filename); + _bt_update_transfer_list_view("outbound"); - if (param->result != BLUETOOTH_ERROR_NONE) { - _bt_update_sent_data_status(ad->current_tr_uid, - BT_TR_FAIL); - _bt_create_warning_popup(param->result); - } else { - _bt_update_sent_data_status(ad->current_tr_uid, - BT_TR_SUCCESS); - } - _bt_update_transfer_list_view(BT_OUTBOUND_TABLE); - ad->tr_next_data = g_slist_next(ad->tr_next_data); - break; + ad->tr_next_data = g_slist_next(ad->tr_next_data); + break; - case BLUETOOTH_EVENT_OPC_DISCONNECTED: - DBG("BLUETOOTH_EVENT_OPC_DISCONNECTED \n"); - ret_if(node == NULL); + case BLUETOOTH_EVENT_OPC_DISCONNECTED: + INFO("BLUETOOTH_EVENT_OPC_DISCONNECTED"); + ret_if(node == NULL); - if (node->file_cnt > send_index) { - info = (bt_tr_data_t *)(ad->tr_next_data)->data; - if (info == NULL) - break; - s_id = info->sid; - DBG("info->sid = %d info->id = %d\n", info->sid, info->id); + if (node->file_cnt > send_index) { + send_index = 0; + if (!ad) { + ERR("ad is NULL"); + break; + } + if (!ad->tr_next_data) { + ERR("ad>tr_next_data is NULL"); + break; + } - while (NULL != ad->tr_next_data) { info = (bt_tr_data_t *)(ad->tr_next_data)->data; if (info == NULL) break; - DBG("info->sid = %d info->id = %d\n", info->sid, info->id); + s_id = info->sid; + INFO("info->sid = %d info->id = %d", info->sid, info->id); - if (s_id != info->sid) { - DBG("SID did not match so break done.\n"); - break; + while (NULL != ad->tr_next_data) { + info = (bt_tr_data_t *)(ad->tr_next_data)->data; + if (info == NULL) + break; + INFO("info->sid = %d info->id = %d", info->sid, info->id); + + if (s_id != info->sid) { + DBG("SID did not match so break done."); + break; + } + + _bt_update_sent_data_status(info->id, BT_TR_FAIL); + ad->send_data.tr_fail++; + ad->tr_next_data = g_slist_next(ad->tr_next_data); } + _bt_update_transfer_list_view("outbound"); - _bt_update_sent_data_status(info->id, BT_TR_FAIL); - ad->send_data.tr_fail++; - ad->tr_next_data = g_slist_next(ad->tr_next_data); + if (ad->send_noti == NULL) { + ad->send_noti = _bt_insert_notification(ad, BT_SENT_NOTI, 0, 0); + } else { + _bt_update_notification(ad, ad->send_noti, NULL, NULL, NULL); + } } - snprintf(str, sizeof(str), BT_TR_STATUS, - ad->send_data.tr_success, - ad->send_data.tr_fail); - - DBG("str = [%s] \n", str); - if (ad->send_noti == NULL) { - noti = _bt_create_notification(BT_NOTI_T); - _bt_set_notification_app_launch(noti, CREATE_TR_LIST, - NOTI_TR_TYPE_OUT, NULL, NULL); - _bt_set_notification_property(noti, QP_NO_DELETE); - _bt_insert_notification(noti, - BT_STR_SENT, str, - BT_ICON_QP_SEND); - ad->send_noti = noti; - } else { - _bt_update_notification(ad->send_noti, - BT_STR_SENT, str, - BT_ICON_QP_SEND); + send_index = 0; + _bt_share_block_sleep(FALSE); + _bt_set_transfer_indicator(FALSE); + _remove_transfer_info(node); + if (!ad->tr_next_data) { + bt_share_release_tr_data_list(ad->tr_send_list); + ad->tr_send_list = NULL; } - } - - send_index = 0; - _bt_share_block_sleep(FALSE); - _bt_set_transfer_indicator(FALSE); - _remove_transfer_info(node); - if (!ad->tr_next_data) { - bt_share_release_tr_data_list(ad->tr_send_list); - ad->tr_send_list = NULL; - } - break; + break; - case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_AUTHORIZE: - DBG("BT_EVENT_OBEX_TRANSFER_AUTHORIZE \n"); - if (param->result == BLUETOOTH_ERROR_NONE) { - g_free(server_auth_info.filename); - server_auth_info.filename = NULL; - - auth_info = param->param_data; - server_auth_info.filename = g_strdup(auth_info->filename); - server_auth_info.length = auth_info->length; - if (server_auth_info.filename) - __bt_obex_file_push_auth(&server_auth_info); - } - break; - case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_STARTED: - DBG("BT_EVENT_OBEX_TRANSFER_STARTED \n"); - transfer_info = param->param_data; - - DBG(" %s \n", transfer_info->type); - noti = _bt_create_notification(BT_ONGOING_T); - _bt_set_notification_property(noti, QP_NO_TICKER); - if (0 == g_strcmp0(transfer_info->type, TRANSFER_GET)) { - noti_id = _bt_insert_notification(noti, - transfer_info->filename, NULL, - BT_ICON_QP_SEND); - _bt_set_notification_app_launch(noti, CREATE_PROGRESS, - NOTI_TR_TYPE_IN, transfer_info->filename, NULL); - _bt_update_notification_progress(NULL, - noti_id, 0); - _bt_update_notification(noti, NULL, NULL, NULL); - } else { - noti_id = _bt_insert_notification(noti, - transfer_info->filename, NULL, - BT_ICON_QP_RECEIVE); - _bt_set_notification_app_launch(noti, CREATE_PROGRESS, - NOTI_TR_TYPE_IN, transfer_info->filename, NULL); - _bt_update_notification(noti, NULL, NULL, NULL); - } + case BLUETOOTH_EVENT_OBEX_SERVER_CONNECTION_AUTHORIZE: + INFO("BLUETOOTH_EVENT_OBEX_SERVER_CONNECTION_AUTHORIZE"); + break; + case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_AUTHORIZE: + INFO("BT_EVENT_OBEX_TRANSFER_AUTHORIZE"); + if (param->result == BLUETOOTH_ERROR_NONE) { + g_free(server_auth_info.filename); + server_auth_info.filename = NULL; + + auth_info = param->param_data; + server_auth_info.filename = g_strdup(auth_info->filename); + server_auth_info.length = auth_info->length; + if (server_auth_info.filename) + __bt_obex_file_push_auth(&server_auth_info); + } + break; - data = g_new0(bt_noti_data_t, 1); - data->noti_handle = noti; - data->noti_id = noti_id; - data->transfer_id = transfer_info->transfer_id; + case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_CONNECTED: + INFO("BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_CONNECTED"); + if (param->result == BLUETOOTH_ERROR_NONE) { - bt_receive_noti_list = g_slist_append(bt_receive_noti_list, data); + isTransferConnectedReceived = TRUE; + } + break; + case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_STARTED: + INFO("BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_STARTED"); + isFirstReceivedPacket = TRUE; + transfer_info = param->param_data; + if(transfer_info->file_size > (100 * 1024)) { + if (0 == g_strcmp0(transfer_info->type, TRANSFER_GET)) { + /*GET request */ + noti = _bt_insert_notification(ad, BT_SENDING_NOTI, 0, 0); + + _bt_set_notification_app_launch(noti, CREATE_PROGRESS, + NOTI_TR_TYPE_OUT, transfer_info->filename, NULL, + transfer_info->transfer_id); + } else { + /*PUT Request */ + noti = _bt_insert_notification(ad, BT_RECEIVING_NOTI, 0, 0); + _bt_set_notification_app_launch(noti, CREATE_PROGRESS, + NOTI_TR_TYPE_IN, transfer_info->filename, NULL, + transfer_info->transfer_id); + } - _bt_set_transfer_indicator(TRUE); - _bt_share_block_sleep(TRUE); - break; + data = g_new0(bt_noti_data_t, 1); + data->noti_handle = noti; + data->noti_id = _bt_get_notification_priv_id(noti); - case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_PROGRESS: - DBG("BT_EVENT_OBEX_TRANSFER_PROGRESS \n"); - if (param->result == BLUETOOTH_ERROR_NONE) { - transfer_info = param->param_data; + data->transfer_id = transfer_info->transfer_id; - data = __bt_get_noti_data_by_transfer_id(transfer_info->transfer_id); + bt_receive_noti_list = g_slist_append(bt_receive_noti_list, data); + } + _bt_set_transfer_indicator(TRUE); + _bt_share_block_sleep(TRUE); + break; - _bt_update_notification_progress(NULL, - data->noti_id, - transfer_info->percentage); + case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_PROGRESS: + if (param->result == BLUETOOTH_ERROR_NONE) { + transfer_info = param->param_data; - _bt_send_message_to_ui(data->noti_id, - transfer_info->filename, - transfer_info->percentage, - FALSE, BLUETOOTH_ERROR_NONE); - } - break; + data = __bt_get_noti_data_by_transfer_id( + transfer_info->transfer_id); + if (data == NULL) { + DBG("Data is NULL, returning"); + return; + } - case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_COMPLETED: - DBG("BT_EVENT_OBEX_TRANSFER_COMPLETED \n"); - transfer_info = param->param_data; - _bt_share_block_sleep(FALSE); - _bt_set_transfer_indicator(FALSE); + if (isFirstReceivedPacket) + _bt_update_notification(ad, data->noti_handle, transfer_info->filename, "", NULL); + if(data && data->noti_id) + _bt_update_notification_progress( + data->noti_handle, + data->noti_id, + transfer_info->percentage); + else + DBG("noti_id is not exist!"); + } + isFirstReceivedPacket = FALSE; + break; - data = __bt_get_noti_data_by_transfer_id(transfer_info->transfer_id); + case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_COMPLETED: + INFO("BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_COMPLETED"); + char mime_type[BT_MIME_TYPE_MAX_LEN] = { 0 }; + unsigned int file_size = 0; + struct stat file_attr; + char *file_path = NULL; + transfer_info = param->param_data; + _bt_set_transfer_indicator(FALSE); + _bt_share_block_sleep(FALSE); + isFirstReceivedPacket = FALSE; - if (data) { - _bt_send_message_to_ui(data->noti_id, - transfer_info->filename, - transfer_info->percentage, TRUE, param->result); + data = __bt_get_noti_data_by_transfer_id(transfer_info->transfer_id); - if (param->result == BLUETOOTH_ERROR_NONE) { - _bt_obex_writeclose(param->param_data); - _bt_update_notification_progress(NULL, - data->noti_id, 100); - } else { - DBG("param->result = %d \n", param->result); - _bt_create_warning_popup(param->result); + if (data) { + _bt_delete_notification(data->noti_handle); + bt_receive_noti_list = g_slist_remove(bt_receive_noti_list, data); + g_free(data); } + if (0 == g_strcmp0(transfer_info->type, TRANSFER_PUT)) { + INFO("TRANSFER_PUT"); - _bt_delete_notification(data->noti_handle); - bt_receive_noti_list = g_slist_remove(bt_receive_noti_list, data); - g_free(data); - } + file_path = __get_dest_file_path(transfer_info->file_path); + DBG("Filename : %s", transfer_info->filename); + DBG("File Path : %s", transfer_info->file_path); - if (0 == g_strcmp0(transfer_info->type, TRANSFER_PUT)) { - if (param->result != BLUETOOTH_ERROR_NONE) { - ad->recv_data.tr_fail++; - _bt_add_recv_transfer_status_data( + if (aul_get_mime_from_file(file_path, mime_type, + BT_MIME_TYPE_MAX_LEN) == AUL_R_OK) + DBG("mime type : %s", mime_type); + + if (g_utf8_validate(file_path, -1, NULL)) { + if (stat(file_path, &file_attr) == 0) + file_size = file_attr.st_size; + else + file_size = 0; + } + + if (param->result != BLUETOOTH_ERROR_NONE) { + ad->recv_data.tr_fail++; + _bt_add_recv_transfer_status_data( transfer_info->device_name, transfer_info->filename, + mime_type, file_size, BT_TR_FAIL); - } else { - ad->recv_data.tr_success++; - _bt_add_recv_transfer_status_data( + } else { + ad->recv_data.tr_success++; + _bt_add_recv_transfer_status_data( transfer_info->device_name, - transfer_info->filename, + file_path, + mime_type, file_size, BT_TR_SUCCESS); + } + + _bt_update_transfer_list_view("inbound"); + + if (ad->receive_noti == NULL) { + ad->receive_noti = _bt_insert_notification(ad, BT_RECEIVED_NOTI, 0, 0); + } else { + _bt_update_notification(ad, ad->receive_noti, NULL, NULL, NULL); + } + }else if(0 == g_strcmp0(transfer_info->type, TRANSFER_GET)){ + INFO("TRANSFER_GET"); } - snprintf(str, sizeof(str), BT_TR_STATUS, - ad->recv_data.tr_success, ad->recv_data.tr_fail); - DBG("str = [%s] \n", str); - - if (ad->receive_noti == NULL) { - noti = _bt_create_notification(BT_NOTI_T); - _bt_set_notification_app_launch(noti, CREATE_TR_LIST, - NOTI_TR_TYPE_IN, NULL, NULL); - _bt_set_notification_property(noti, QP_NO_DELETE); - _bt_insert_notification(noti, - BT_STR_RECEIVED, str, - BT_ICON_QP_RECEIVE); - ad->receive_noti = noti; + if (param->result == BLUETOOTH_ERROR_NONE) { + bt_file_type_t file_type; + char *extn; + bt_file_info_t *info; + + transfer_info = param->param_data; + if (transfer_info->file_path == NULL) { + ERR("File path is NULL"); + break; + } + + if (!g_strcmp0(transfer_info->type, TRANSFER_GET)) { + DBG("Transfer is GET, so no need to handle"); + break; + } + + name = __get_dest_file_path(transfer_info->file_path); + + extn = strrchr(name, '.'); + if (NULL != extn) + extn++; + file_type = __get_file_type(extn); + + INFO("file type %d", file_type); + + if (transfer_info->server_type == FTP_SERVER || + file_type != BT_FILE_VCARD) { + if (file_type != BT_FILE_VCAL) + __bt_scan_media_file(name); + g_free(name); + break; + } + + info = g_new0(bt_file_info_t, 1); + info->file_path = name; + info->file_type = file_type; + + if (pthread_create(&thread_id, NULL, (void *)&_bt_obex_writeclose, + info) < 0) { + ERR("pthread_create() is failed"); + __free_file_info(info); + break; + } + if (pthread_detach(thread_id) < 0) { + ERR("pthread_detach() is failed"); + } } else { - _bt_update_notification(ad->receive_noti, - BT_STR_RECEIVED, str, - BT_ICON_QP_RECEIVE); + DBG("param->result = %d", param->result); + DBG("opp_transfer_abort by user %d ", ad->opp_transfer_abort); + if (!ad->opp_transfer_abort) + _bt_create_warning_popup(param->result, + BT_STR_UNABLE_TO_RECEIVE); + ad->opp_transfer_abort = FALSE; } - } + break; - _bt_update_transfer_list_view(BT_INBOUND_TABLE); - break; + case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_DISCONNECTED: + INFO("BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_DISCONNECTED"); + if (param->result == BLUETOOTH_ERROR_NONE) + isTransferConnectedReceived = FALSE; + break; - default: - DBG("Unhandled event %x", event); - break; + default: + break; } } @@ -623,6 +756,34 @@ void _bt_app_obex_download_dup_file_cb(void *data, void *obj, return; } +static int __bt_get_available_int_memory(double *dAvail) +{ + struct statvfs s; + int r; + + r = storage_get_internal_memory_size(&s); + if (r < 0) + ERR("ret : %d", r); + else { + INFO("total : %lf, avail : %lf", + (double)s.f_frsize*s.f_blocks, (double)s.f_bsize*s.f_bavail); + *dAvail = (double)s.f_bsize*s.f_bavail; + } + + return r; +} + +static gboolean __bt_get_available_ext_memory(unsigned long long *available_mem_size) +{ + struct statfs fs = {0, }; + if (statfs(BT_DOWNLOAD_MMC_ROOT, &fs) != 0) { + *available_mem_size = 0; + return FALSE; + } + *available_mem_size = fs.f_bavail * (fs.f_bsize); + return TRUE; +} + static gboolean __bt_get_available_memory(long *available_mem_size) { struct statfs fs = {0, }; @@ -646,82 +807,156 @@ static gboolean __bt_get_available_memory(long *available_mem_size) return TRUE; } -gboolean _bt_app_obex_openwrite_requested(bt_obex_server_authorize_into_t - *server_auth_info) +static gchar *__bt_get_unique_file_name(char *storage_path, char *filename) { + char temp_filepath[BT_FILE_PATH_LEN_MAX] = { 0, }; + char temp_filename[BT_TEMP_FILE_PATH_LEN_MAX] = { 0, }; + char *ext = NULL; + char *temp; + unsigned int seq = 1; + + temp = strrchr(filename, '.'); + + if (temp != NULL) { + ext = temp + 1; + *temp = '\0'; + } + + do { + if (ext != NULL) + snprintf(temp_filename, sizeof(temp_filename), "%s_%d.%s", + filename, seq, ext); + else + snprintf(temp_filename, sizeof(temp_filename), "%s_%d", + filename, seq); + + snprintf(temp_filepath, sizeof(temp_filepath), "%s/%s", + storage_path, temp_filename); + + /* In below code check is done for unique file name or + Max value of integer reached, in this case overwrite + the last file */ + if ((access(temp_filepath, F_OK) == 0) && (seq < 65536)) + seq++; + else + break; + + } while (1); + + return g_strdup(temp_filename); +} + +static void __bt_app_obex_openwrite_requested(bt_obex_server_authorize_into_t + *server_auth_info) +{ + ret_if(server_auth_info == NULL); + ret_if(server_auth_info->filename == NULL); + char temp_filename[BT_FILE_PATH_LEN_MAX] = { 0, }; - bt_app_sys_popup_params_t popup_params = { NULL }; char storage[STORAGE_PATH_LEN_MAX] = { 0, }; + char *name = NULL; + GRegex *regex = NULL; /* Check if file is already present */ _bt_get_default_storage(storage); - snprintf(temp_filename, BT_FILE_PATH_LEN_MAX, "%s/%s", - storage, server_auth_info->filename); + /* For vcf file type, some device send weird filename like "telecom/pb.vcf" + This filename should be renamed. + */ - if (access(temp_filename, F_OK) == 0) { - DBG("opp_info->file_info.file_name = %s is already exsist\n", - server_auth_info->filename); - - /*File exsists: Ask the user if he wants to download the file */ - popup_params.file = server_auth_info->filename; - popup_params.type = "twobtn"; - _bt_launch_system_popup(BT_APP_EVENT_OVERWRITE_REQUEST, - &popup_params, - _bt_app_obex_download_dup_file_cb, - server_auth_info); + regex = g_regex_new("[*\"<>;?|\\^:/]", 0, 0, NULL); + name = g_regex_replace(regex, server_auth_info->filename, -1, 0, "_", 0, NULL); + g_regex_unref(regex ); + if (g_strcmp0(name, server_auth_info->filename) != 0) { + g_free(server_auth_info->filename); + server_auth_info->filename = name; } else { - bluetooth_obex_server_accept_authorize(server_auth_info->filename); + g_free(name); + } + + snprintf(temp_filename, BT_FILE_PATH_LEN_MAX, "%s/%s", + storage, server_auth_info->filename); + INFO("temp_filename : %s", temp_filename); + if (access(temp_filename, F_OK) == 0) { + name = server_auth_info->filename; + + server_auth_info->filename = __bt_get_unique_file_name(storage, + name); + + g_free(name); } - return FALSE; + + bluetooth_obex_server_accept_authorize(server_auth_info->filename); + + return; } static void __bt_obex_file_push_auth(bt_obex_server_authorize_into_t *server_auth_info) { - long available_mem_size = 0; + DBG("+"); - DBG("+\n"); + int val = -1; + gboolean ret = FALSE; + unsigned long long available_ext_mem_size = 0; + double available_int_mem_size = 0; - if (__bt_get_available_memory(&available_mem_size) == FALSE) { - ERR("Unable to get available memory size\n"); - goto reject; - } - if (available_mem_size < server_auth_info->length / 1024) { - g_timeout_add(BT_APP_POPUP_LAUNCH_TIMEOUT, - (GSourceFunc)_bt_app_popup_memoryfull, - NULL); + if (vconf_get_int(VCONFKEY_SETAPPL_DEFAULT_MEM_BLUETOOTH_INT, + (void *)&val)) { + ERR("vconf error"); goto reject; - } + } + + INFO("File Length =%ld",server_auth_info->length); + + if (val == BT_DEFAULT_MEM_MMC) { + ret = __bt_get_available_ext_memory(&available_ext_mem_size); + if (ret == FALSE) { + ERR("Unable to get available memory size"); + goto reject; + } + + INFO("available_ext_mem_size =%llu", available_ext_mem_size); + if (available_ext_mem_size < server_auth_info->length) { + g_timeout_add(BT_APP_POPUP_LAUNCH_TIMEOUT, + (GSourceFunc)_bt_app_popup_memoryfull, + NULL); + goto reject; + } + } else { + if (__bt_get_available_int_memory(&available_int_mem_size) < 0) { + ERR("Unable to get available memory size"); + goto reject; + } + + INFO("available_int_mem_size =%lf", available_ext_mem_size); + if (available_int_mem_size < server_auth_info->length) { + g_timeout_add(BT_APP_POPUP_LAUNCH_TIMEOUT, + (GSourceFunc)_bt_app_popup_memoryfull, + NULL); + goto reject; + } + } + + DBG("isTransferConnectedReceived is : %d", isTransferConnectedReceived); + + if (isTransferConnectedReceived) { + if (notification_status_message_post(BT_STR_RECEIVING) != NOTIFICATION_ERROR_NONE) + ERR("notification_status_message_post() is failed"); + isTransferConnectedReceived = FALSE; + } - DBG("Check for overwrite. \n"); - /* Two popups back to back. So add a timeout */ - g_timeout_add(BT_APP_POPUP_LAUNCH_TIMEOUT, - (GSourceFunc)_bt_app_obex_openwrite_requested, - server_auth_info); + __bt_app_obex_openwrite_requested(server_auth_info); + DBG("-"); return; reject: bluetooth_obex_server_reject_authorize(); - DBG("-\n"); + DBG("-"); return; } -static bt_file_type_t __get_file_type(char *extn) -{ - DBG("exten : %s \n", extn); - - if (NULL != extn) { - if (!strcmp(extn, "vcf")) - return BT_FILE_VCARD; - else if (!strcmp(extn, "vcs")) - return BT_FILE_VCAL; - else if (!strcmp(extn, "vbm")) - return BT_FILE_VBOOKMARK; - } - return BT_FILE_OTHER; -} #ifdef ENABLE_CONTACTS_SERVICE2 static bool __bt_vcard_handler(contacts_record_h record, void *user_data) @@ -814,7 +1049,7 @@ static gboolean __bt_save_v_object(char *file_path, #endif /* ENABLE_CALENDAR_SERVICE2 */ default: - break; + return FALSE; } return TRUE; @@ -841,47 +1076,16 @@ gboolean __bt_scan_media_file(char *file_path) return TRUE; } -gboolean _bt_obex_writeclose(bt_obex_server_transfer_info_t *transfer_complete_info) +void *_bt_obex_writeclose(bt_file_info_t *info) { - char file_path[BT_TEMP_FILE_PATH_LEN_MAX] = { 0, }; - bt_file_type_t file_type = 0; - char *extn = NULL; - char storage[STORAGE_PATH_LEN_MAX] ={0, }; - - retv_if(transfer_complete_info->filename == NULL, FALSE); - - - DBG("File name[%s], File name length = [%d]\n", - transfer_complete_info->filename, - strlen(transfer_complete_info->filename)); - - extn = strrchr(transfer_complete_info->filename, '.'); - if (NULL != extn) - extn++; - DBG("====== : %s\n", extn); - file_type = __get_file_type(extn); - DBG("file type : %d\n", file_type); - - _bt_get_default_storage(storage); - snprintf(file_path, sizeof(file_path), "%s/%s", storage, - transfer_complete_info->filename); - - DBG("BT_OPP_FILE_SAVE : file_path = %s\n", file_path); - - switch (file_type) { - case BT_FILE_VCARD: - case BT_FILE_VCAL: - case BT_FILE_VBOOKMARK: - if (__bt_save_v_object(file_path, file_type) == FALSE) { - ecore_file_remove(file_path); - } else { - __bt_scan_media_file(file_path); - } - break; - default: - __bt_scan_media_file(file_path); - break; + if (__bt_save_v_object(info->file_path, info->file_type) == FALSE) { + ERR("Unable to save vObject"); + __bt_scan_media_file(info->file_path); + } else if (info->file_type == BT_FILE_VCAL) { + ecore_file_remove(info->file_path); } - return TRUE; + __free_file_info(info); + + return NULL; } diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 3ab3806..edaed7b 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -18,7 +18,7 @@ ENDFOREACH(flag) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(EXEC_PREFIX "\${prefix}") -SET(LIBDIR ${LIB_INSTALL_DIR}) +SET(LIBDIR "\${prefix}/lib") SET(INCLUDEDIR "/usr/include") SET(VERSION 1.0) @@ -28,8 +28,8 @@ TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${apipkgs_LDFLAGS}) CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc.in ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc @ONLY) -INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${LIB_INSTALL_DIR} COMPONENT RuntimeLibraries) -INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig) +INSTALL(TARGETS ${PROJECT_NAME} DESTINATION lib COMPONENT RuntimeLibraries) +INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION lib/pkgconfig) FOREACH(hfile ${HEADERS}) INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${hfile} DESTINATION include/bluetooth-share-api) diff --git a/lib/applog.h b/lib/applog.h index 1c201b8..ef1557e 100644 --- a/lib/applog.h +++ b/lib/applog.h @@ -46,115 +46,25 @@ extern "C" { * */ -#if defined(SLP_SYSLOG_OUT) || defined(SLP_DAEMON) -#include -#endif #include #include -#if defined(SLP_SYSLOG_OUT) || defined(SLP_DAEMON) -#define __LOG(prio, fmt, arg...) \ - do { syslog(prio, fmt, ##arg); } while (0) - -#define __LOGD(prio, fmt, arg...) \ - do { - syslog(prio, "[%s:%d] "fmt"\n", __FILE__, __LINE__, ##arg); - } while (0) -#else -#define __LOG(prio, fmt, arg...) do { } while (0) -#define __LOGD(prio, fmt, arg...) do { } while (0) -#endif - -#define __PRT(prio, fmt, arg...) \ - do { \ - fprintf((LOG_PRI(prio) == LOG_ERR ? stderr : stdout), \ - fmt"\n", ##arg); \ - } while (0) - -#define __PRTD(prio, fmt, arg...) \ - do { \ - fprintf((LOG_PRI(prio) == LOG_ERR ? stderr : stdout), \ - "[%s:%d] "fmt"\n", __FILE__, __LINE__, ##arg); \ - } while (0) -#define _NOUT (prio, fmt, arg...) do { } while (0) - -#ifdef SLP_DEBUG -#define _LOGD __LOGD -#define _LOG __LOGD -#define _PRTD __PRTD -#define _PRT __PRTD -#else -#define _LOGD _NOUT -#define _LOG __LOG -#define _PRTD _NOUT -#define _PRT __PRT -#endif - -#define SYSLOG_INFO(fmt, arg...) _LOG(LOG_INFO, fmt, ##arg) -#define SYSLOG_ERR(fmt, arg...) _LOG(LOG_ERR, fmt, ##arg) -#define SYSLOG_DBG(fmt, arg...) _LOGD(LOG_DEBUG, fmt, ##arg) +#undef LOG_TAG +#define LOG_TAG "BLUETOOTH_SHARE_DB" -#define PRT_INFO(fmt, arg...) \ - LOG(LOG_DEBUG, BT_SHARE, "%s:%d "fmt, __func__, __LINE__, ##arg) - -#define PRT_ERR(fmt, arg...) \ - LOG(LOG_DEBUG, BT_SHARE, "%s:%d "fmt, __func__, __LINE__, ##arg) - -#define PRT_DBG(fmt, arg...) \ - LOG(LOG_DEBUG, BT_SHARE, "%s:%d "fmt, __func__, __LINE__, ##arg) - -#define BT_SHARE "BT_SHARE" - - -#if defined(SLP_SYSLOG_OUT) || defined(SLP_DAEMON) -#define INFO SYSLOG_INFO -#define ERR SYSLOG_ERR -#define DBG SYSLOG_DBG -#else #define INFO(fmt, arg...) \ - SLOG(LOG_DEBUG, BT_SHARE, "%s:%d "fmt, __func__, __LINE__, ##arg) + SLOGI(fmt, ##arg) #define ERR(fmt, arg...) \ - SLOG(LOG_DEBUG, BT_SHARE, "%s:%d "fmt, __func__, __LINE__, ##arg) + SLOGE(fmt, ##arg) #define DBG(fmt, arg...) \ - SLOG(LOG_DEBUG, BT_SHARE, "%s:%d "fmt, __func__, __LINE__, ##arg) -#endif + SLOGD(fmt, ##arg) -#ifdef SLP_DEBUG -#define warn_if(expr, fmt, arg...) do { \ - if (expr) { \ - ERR("(%s) -> "fmt, #expr, ##arg); \ - } \ - } while (0) -#define ret_if(expr) do { \ - if (expr) { \ - ERR("(%s) -> %s() return", #expr, __FUNCTION__); \ - return; \ - } \ - } while (0) -#define retv_if(expr, val) do { \ - if (expr) { \ - ERR("(%s) -> %s() return", #expr, __FUNCTION__); \ - return (val); \ - } \ - } while (0) -#define retm_if(expr, fmt, arg...) do { \ - if (expr) { \ - ERR(fmt, ##arg); \ - ERR("(%s) -> %s() return", #expr, __FUNCTION__); \ - return; \ - } \ - } while (0) -#define retvm_if(expr, val, fmt, arg...) do { \ - if (expr) { \ - ERR(fmt, ##arg); \ - ERR("(%s) -> %s() return", #expr, __FUNCTION__); \ - return (val); \ - } \ - } while (0) +#define DBG_SECURE(fmt, args...) SECURE_SLOGD(fmt, ##args) +#define ERR_SECURE(fmt, args...) SECURE_SLOGE(fmt, ##args) +#define INFO_SECURE(fmt, args...) SECURE_SLOGI(fmt, ##args) -#else #define warn_if(expr, fmt, arg...) do { \ if (expr) { \ ERR(fmt, ##arg); \ @@ -183,7 +93,6 @@ extern "C" { } \ } while (0) -#endif #ifdef __cplusplus } diff --git a/lib/bt-share-db.h b/lib/bt-share-db.h index 604e67f..f465fd3 100644 --- a/lib/bt-share-db.h +++ b/lib/bt-share-db.h @@ -24,7 +24,7 @@ extern "C" { #endif -#define BT_TRANSFER_DB tzplatform_mkpath(TZ_USER_DB, ".bluetooth_transfer.db") +#define BT_TRANSFER_DB "/opt/usr/dbspace/.bluetooth_transfer.db" #define BT_INBOUND_TABLE "inbound" #define BT_OUTBOUND_TABLE "outbound" #define BT_DB_QUERY_LEN 512 diff --git a/packaging/bluetooth-share.spec b/packaging/bluetooth-share.spec index 75897f4..dd62b75 100644 --- a/packaging/bluetooth-share.spec +++ b/packaging/bluetooth-share.spec @@ -1,3 +1,5 @@ +%define TZ_SYS_SHARE /opt + Name: bluetooth-share Summary: Bluetooth file share Agent Version: 0.0.47 @@ -16,6 +18,7 @@ BuildRequires: gettext-tools BuildRequires: pkgconfig(appcore-efl) BuildRequires: pkgconfig(bluetooth-api) BuildRequires: pkgconfig(glib-2.0) +BuildRequires: pkgconfig(aul) BuildRequires: pkgconfig(dlog) BuildRequires: pkgconfig(sqlite3) BuildRequires: pkgconfig(ecore) @@ -26,16 +29,19 @@ BuildRequires: pkgconfig(ecore) #BuildRequires: pkgconfig(contacts-service2) #%endif BuildRequires: pkgconfig(vconf) +BuildRequires: pkgconfig(syspopup-caller) BuildRequires: pkgconfig(pmapi) BuildRequires: pkgconfig(sysman) BuildRequires: pkgconfig(notification) BuildRequires: pkgconfig(appsvc) BuildRequires: pkgconfig(db-util) BuildRequires: pkgconfig(capi-content-media-content) +BuildRequires: pkgconfig(storage) BuildRequires: pkgconfig(libtzplatform-config) BuildRequires: pkgconfig(cynara-client) BuildRequires: pkgconfig(cynara-session) BuildRequires: pkgconfig(cynara-creds-dbus) +BuildRequires: pkgconfig(eventsystem) %description Bluetooth File Share Agent @@ -61,15 +67,20 @@ Development package for libbluetooth-share cp %{SOURCE1001} %{SOURCE1002} %{SOURCE1003} . %build +export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE" +export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE" +export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE" + export CFLAGS+=" -fpie -fvisibility=hidden" -export LDFLAGS+=" -Wl,--rpath=/usr/%{_libdir} -Wl,--as-needed -Wl,--unresolved-symbols=ignore-in-shared-libs -pie" +export LDFLAGS+=" -Wl,--rpath=/usr/lib -Wl,--as-needed -Wl,--unresolved-symbols=ignore-in-shared-libs -pie" %cmake . \ - -DTZ_SYS_ETC=%{TZ_SYS_ETC} + -DCMAKE_INSTALL_PREFIX=%{_prefix} make %install %make_install + mkdir -p %{buildroot}%{TZ_SYS_SHARE}/bt-ftp install -D -m 0755 %{SOURCE1004} %{buildroot}%{TZ_SYS_SHARE}/%{name}/ressources/init_db.sh -- 2.7.4