--- /dev/null
+Taesoo Jun <steve.jun@samsung.com>
+DoHyun Pyun <dh79.pyun@samsung.com>
--- /dev/null
+bt_share system::homedir rwxat- ------
+bt_share system::vconf rwxatl ------
+bt_share system::ext_storage rwxat- ------
+bt_share system::media rwxat- ------
+bt_share system::share rwxat- ------
+bt_share system::vconf_network rwxatl ------
+bt_share system::vconf_inhouse r----l ------
+bt_share system::vconf_system rw---l ------
+org.tizen.app-tray bt_share r-x--- ------
+bt_share sys-assert::core rwxat- ------
+bt_share pulseaudio rwxat- ------
+e17 bt_share -w---- ------
+bt_share ail::db rw---- ------
+bt_share aul::launch --x--- ------
+bt_share dbus rwx--- ------
+bt_share media-server -w---- ------
+bt_share notification::db rw---- ------
+bt_share power_manager -w---- ------
+bt_share ug_bluetooth r----- ------
+bt_share bt_share::db rw---- ------
+bt_share media-data::db rw---- ------
+bt_share contacts-service -wx--- ------
+bt_share contacts-service::svc -w---- ------
+bt_share calendar-service -wx--- ------
+bt_share calendar-service::svc -w---- ------
+bt_share syspopup::db rw---- ------
+bt_share deviced rwx--- ------
+bt_share data-provider-master -w---- ------
+bt_share bt-service::public -w---- ------
+bt_share bt-service rw---- ------
+bt_share e17 --x--- ------
+bt_share data-provider-master::notification -w---- ------
+bt_share data-provider-master::notification.client -w---- ------
+bt_share deviced::display rw---- ------
+bt_share app-svc::db r----l ------
+bt_share pkgmgr::db rwxatl ------
+bt_share ug-setting-call-efl::vconf r----- ------
+media-server bt_share -w---- ------
+dbus bt_share rwx--- ------
+obexd bt_share rwx--- ------
+deviced bt_share rwx--- ------
+bt-service bt_share r----- ------
--- /dev/null
+<manifest>
+ <define>
+ <domain name="bt_share"/>
+ <provide>
+ <label name="bt_share::db"/>
+ </provide>
+ </define>
+ <assign>
+ <filesystem path="/usr/share/dbus-1/services/org.bluetooth.share.service" label="_"/>
+ <filesystem path="/usr/lib/libbluetooth-share-api.so.0.1.0" label="_"/>
+ <filesystem path="/opt/usr/media/Downloads/.bluetooth" label="system::media" type="transmutable"/>
+ </assign>
+ <request>
+ <domain name="bt_share"/>
+ </request>
+</manifest>
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/lib)
+SET(PKG_MODULES
+ glib-2.0
+ bluetooth-api
+ aul
+ dbus-glib-1
+ appcore-common
+ dlog
+ vconf
+ syspopup-caller
+ capi-system-device
+ notification
+ calendar-service2
+ appsvc
+ appcore-efl
+ libprivilege-control
+ capi-appfw-application
+ capi-content-media-content
+ storage
+ db-util
+)
+
INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED glib-2.0 bluetooth-api
- aul dbus-glib-1 appcore-common
- dlog vconf syspopup-caller pmapi sysman
- notification calendar contacts-service
- appsvc appcore-efl libprivilege-control)
+pkg_check_modules(pkgs REQUIRED ${PKG_MODULES})
FOREACH(flag ${pkgs_CFLAGS})
SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
ENDFOREACH(flag)
#SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -finstrument-functions")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+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}")
ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"")
ADD_DEFINITIONS("-DFACTORYFS=\"$ENV{FACTORYFS}\"")
ADD_DEFINITIONS("-DTARGET")
+ADD_DEFINITIONS("-D_FILE_OFFSET_BITS=64")
ADD_DEFINITIONS("-DSLP_DEBUG")
ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS})
INSTALL(TARGETS ${PROJECT_NAME} DESTINATION ${BINDIR})
-
+INSTALL(FILES ${CMAKE_SOURCE_DIR}/bluetooth-share.efl DESTINATION /etc/smack/accesses.d)
INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/org.bluetooth.share.service DESTINATION share/dbus-1/services)
*
*/
-#if defined(SLP_SYSLOG_OUT) || defined(SLP_DAEMON)
-#include <syslog.h>
-#endif
#include <stdio.h>
#include <dlog.h>
-#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)
-
-#define PRT_INFO(fmt, arg...) \
- LOG(LOG_DEBUG, BT_SHARE, "%s:%d "fmt, __func__, __LINE__, ##arg)
+#undef LOG_TAG
+#define LOG_TAG "BLUETOOTH_SHARE"
-#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); \
} \
} while (0)
-#endif
-
#ifdef __cplusplus
}
#endif
extern "C" {
#endif
+#include <glib.h>
+
+/* Define Error type */
+#define BT_SHARE_FAIL -1
+#define BT_SHARE_ERROR_NONE 0
+
+#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"
+#define TXT_FILE_FORMAT BT_TMP_DIR"bluetooth_content_share%s.txt"
+#define HTML_FILE_FORMAT BT_TMP_DIR"bluetooth_content_share%s.html"
+#define HTML_FORMAT "<html><head><meta http-equiv=\"Content-Type\" content=\"text/html;charset=UTF-8\"/></head><body><a href=\"%s\">%s</a></body></html>"
+
+#define BT_CONTACT_SHARE_TMP_DIR "/opt/usr/media/Downloads/.bluetooth"
+
+typedef enum {
+ BT_HTTP_FILE,
+ BT_TXT_FILE,
+} bt_file_t;
+
typedef enum {
BT_STATUS_OFF = 0x0000,
BT_STATUS_ON = 0x0001,
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
}
#include <glib.h>
#include <dbus/dbus-glib.h>
#include <dbus/dbus-glib-lowlevel.h>
-
+#include "bluetooth-api.h"
#include "bt-share-main.h"
#define BT_ADDRESS_LENGTH_MAX 6
#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"
#define BT_IPC_STRING_SIZE 256
#define BT_ADDR_STR_LEN_MAX 18
-
-#define FILE_PATH_DELIM "?"
+#define BT_MIME_TYPE_MAX_LEN 20
#define BT_INBOUND_TABLE "inbound"
#define BT_OUTBOUND_TABLE "outbound"
typedef struct {
int file_cnt;
char addr[BLUETOOTH_ADDRESS_LENGTH];
+ char name[BLUETOOTH_DEVICE_NAME_LENGTH_MAX];
char *mode;
char **file_path;
+ char **content;
+ char **type;
+ unsigned int *size;
} opc_transfer_info_t;
typedef struct {
void _free_transfer_info(opc_transfer_info_t *node);
void _remove_transfer_info(opc_transfer_info_t *node);
int _request_file_send(opc_transfer_info_t *node);
-void _bt_send_message_to_ui(int transfer_id,
- char *name,
- int percentage,
- gboolean completed,
- int error_type);
-void _bt_create_warning_popup(int error_type);
-void _bt_update_transfer_list_view(const char *table);
+void _bt_create_warning_popup(int error_type, char *msg);
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);
+void _bt_update_transfer_list_view(char *db);
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
}
#include <glib.h>
#include <dbus/dbus-glib.h>
+#include <notification.h>
#ifndef PACKAGE_NAME
#define PACKAGE_NAME "bluetooth-share"
#endif
#define UI_PACKAGE "org.tizen.bluetooth-share-ui"
-#define UI_PKG_PATH "/opt/apps/org.tizen.bluetooth-share-ui/bin/bluetooth-share-ui"
-
-#define BT_VCONF_OPP_SERVER_INIT "memory/private/bluetooth-share/opp_server_init"
+#define UI_PKG_PATH "/usr/apps/org.tizen.bluetooth-share-ui/bin/bluetooth-share-ui"
typedef void (*bt_app_cb) (void *, void *, void *);
GSList *tr_send_list;
GSList *tr_next_data;
int current_tr_uid;
+ notification_h send_noti;
+ notification_h receive_noti;
+ notification_h opc_noti;
+ int send_noti_id;
+ int receive_noti_id;
+ int opc_noti_id;
DBusGConnection *conn;
GObject *object;
+ gboolean obex_server_init;
+ bool opp_transfer_abort;
};
+int _bt_init_obex_server(void);
-void _bt_terminate_app(void);
+void _bt_terminate_bluetooth_share(void);
#ifdef __cplusplus
}
#endif
#define STORAGE_PATH_LEN_MAX 30
+#define BT_DEFAULT_MEM_PHONE 0
+#define BT_DEFAULT_MEM_MMC 1
-
-#define BT_DOWNLOAD_PHONE_FOLDER "/opt/media/Downloads"
-#define BT_DOWNLOAD_MMC_FOLDER "/opt/storage/sdcard"
-#define BT_DOWNLOAD_MEDIA_FOLDER "/opt/media"
+#define BT_DOWNLOAD_PHONE_FOLDER "/opt/usr/media/Downloads"
+#define BT_DOWNLOAD_MMC_FOLDER "/opt/storage/sdcard/Downloads"
+#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);
+void _bt_init_vconf_notification(void *data);
+void _bt_deinit_vconf_notification(void);
#ifdef __cplusplus
}
#endif
#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
-#define QP_NO_DELETE (NOTIFICATION_PROP_DISABLE_AUTO_DELETE | NOTIFICATION_PROP_VOLATILE_DISPLAY)
-
-
#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 {
};
typedef enum {
- BT_NOTI_T = NOTIFICATION_TYPE_NOTI,
- BT_ONGOING_T = NOTIFICATION_TYPE_ONGOING,
-} bt_qp_type_t;
+ 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 id);
+notification_h _bt_insert_notification(struct bt_appdata *ad, bt_notification_type_e type);
-int _bt_insert_notification(notification_h noti,
+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 _bt_update_notification_progress(notification_h noti,
int id,
int val);
+int _bt_get_notification_priv_id(notification_h noti);
-gboolean _bt_get_notification_text(int priv_id, char *str);
-
-int _bt_delete_notification(bt_qp_type_t type, int id);
+int _bt_delete_notification(notification_h noti);
-int _bt_delete_all_notification();
int _bt_set_notification_app_launch(notification_h noti,
- bt_qp_launch_type_t type,
+ bt_notification_launch_type_e launch_type,
const char *transfer_type,
const char *filename,
- const char *progress_cnt);
-int _bt_set_notification_property(notification_h noti, int flag);
+ 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);
-
#ifdef __cplusplus
}
#endif
#include <libintl.h>
/*============== String ================= */
-#define BT_COMMON_PKG "ug-setting-bluetooth-efl"
-#define BT_COMMON_RES "/opt/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_FILE_EXSIST_MSG \
- dgettext(BT_COMMON_PKG, "IDS_BT_POP_PS_ALREADY_EXISTS_OVERWRITE_Q")
-#define BT_STR_FILE_DELETE_AUTHORIZE_MSG \
- dgettext(BT_COMMON_PKG, "Delete %s by %s ?")
-#define BT_STR_RECEIVING dgettext(BT_COMMON_PKG, "IDS_BT_POP_RECEIVING_ING")
-#define BT_STR_SENDING \
- dgettext(BT_COMMON_PKG, "IDS_BT_POP_SHARING_ING")
#define BT_STR_MEMORY_FULL \
dgettext(BT_COMMON_PKG, "IDS_BT_POP_MEMORYFULL")
-#define BT_STR_RECEIVCED \
- dgettext(BT_COMMON_PKG, "IDS_BT_BODY_RECEIVED")
-#define BT_STR_PD_FILES_RECEIVED \
- dgettext(BT_COMMON_PKG, "IDS_BT_POP_PD_FILES_RECEIVED")
#define BT_STR_UNABLE_TO_SEND \
dgettext(BT_COMMON_PKG, "IDS_BT_POP_SENDINGFAIL")
-
-#define BT_STR_SEND_NOTI "Bluetooth share: Sent"
-#define BT_STR_RECEIVED_NOTI "Bluetooth share: Received"
-#define BT_TR_STATUS "%d successful, %d failed"
+#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 "/opt/apps/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 ICONDIR"/Q02_icon_BT_transmit.png"
-#define BT_ICON_QP_RECEIVE ICONDIR"/Q02_icon_BT_receive.png"
-#define BT_ICON_QP_BT_ON ICONDIR"/Q02_QuickPanel_icon_bluetooth_noti.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
}
typedef enum {
BT_APP_EVENT_CONFIRM_MODE_REQUEST = 0x0001,
- BT_APP_EVENT_FILE_RECIEVED = 0x0002,
- BT_APP_EVENT_INFORMATION = 0x0004
+ BT_APP_EVENT_FILE_RECEIVED = 0x0002,
+ BT_APP_EVENT_INFORMATION = 0x0004,
+ BT_APP_EVENT_OVERWRITE_REQUEST = 0x0008
} bt_app_event_type_t;
typedef enum {
gboolean _bt_app_popup_memoryfull(gpointer user_data);
-//void _bt_app_obex_download_dup_file_cb(void *data, void *obj,
-// void *event_info);
-
-
#ifdef __cplusplus
}
#endif
BT_FILE_OTHER /**<OTHER*/
} bt_file_type_t;
+bt_obex_server_authorize_into_t server_auth_info;
+
+void _bt_clear_receive_noti_list(void);
+
void _bt_share_event_handler(int event, bluetooth_event_param_t *param,
void *user_data);
bluetooth_event_param_t *param,
void *user_data);
-void _bt_app_obex_download_dup_file_cb(void *data, void *obj,
- void *event_info);
-
-gboolean _bt_get_default_storage(char *storage);
+void _bt_get_default_storage(char *storage);
+void _bt_obex_cancel_transfer(void *data);
#ifdef __cplusplus
*
*/
-#include <pmapi.h>
+#include <device/power.h>
#include <glib.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <vconf.h>
+#include <Ecore_File.h>
+
#include "vconf-keys.h"
#include "applog.h"
#include "bt-share-common.h"
-#include <vconf.h>
int _bt_share_block_sleep(gboolean is_block)
{
if (is_block) {
if (block_sleep_count < 0) {
- DBG("block_sleep_count[%d] is invalid. It is set to 0.\n",
+ INFO("block_sleep_count[%d] is invalid. It is set to 0.\n",
block_sleep_count);
block_sleep_count = 0;
} else if (block_sleep_count == 0) {
- result = pm_lock_state(LCD_OFF, STAY_CUR_STATE, 0);
+ result = device_power_request_lock(POWER_LOCK_CPU, 0);
if (result != 0) {
- DBG("LCD Lock is failed with result code [%d]\n", result);
+ INFO("LCD Lock is failed with result code [%d]\n", result);
}
} else {
result = 0;
}
} else {
if (block_sleep_count <= 0) {
- DBG("block_sleep_count[%d] is invalid. It is set to 0.\n",
+ INFO("block_sleep_count[%d] is invalid. It is set to 0.\n",
block_sleep_count);
block_sleep_count = 0;
} else if (block_sleep_count == 1) {
- result = pm_unlock_state(LCD_OFF, PM_RESET_TIMER);
+ result = device_power_release_lock(POWER_LOCK_CPU);
if (result != 0) {
- DBG("LCD Unlock is failed with result code [%d]\n",
+ INFO("LCD Unlock is failed with result code [%d]\n",
result);
}
} else {
ret = vconf_get_int(VCONFKEY_BT_STATUS, (void *)&bt_device_state);
if (ret != 0) {
- DBG("Get vconf failed\n");
+ ERR("Get vconf failed\n");
return -1;
}
if(state == TRUE) {
block_cnt++;
- if(bt_device_state & BT_STATUS_TRANSFER)
- return 0;
+ retv_if(bt_device_state & BT_STATUS_OFF, 0);
+ retv_if(bt_device_state & BT_STATUS_TRANSFER, 0);
bt_device_state |= BT_STATUS_TRANSFER;
} else {
if(block_cnt > 0)
ret = vconf_set_int(VCONFKEY_BT_STATUS, bt_device_state);
if (ret != 0) {
- DBG("Set vconf failed\n");
+ ERR("Set vconf failed\n");
return -1;
}
return 0;
}
+static char *__bt_share_get_transfer_file_name(int file_type)
+{
+ int count = 0;
+ char *appendix;
+ char *file;
+ char *file_format;
+ char *file_name;
+
+ if (file_type == BT_HTTP_FILE) {
+ file_name = HTML_FILE_NAME;
+ file_format = HTML_FILE_FORMAT;
+ } else {
+ file_name = TXT_FILE_NAME;
+ file_format = TXT_FILE_FORMAT;
+ }
+
+ file = g_strdup(file_name);
+
+ /* While the file exists, increase the file name */
+ while (access(file, F_OK) == 0) {
+ g_free(file);
+
+ appendix = g_strdup_printf("_%d", count);
+ file = g_strdup_printf(file_format, appendix);
+ g_free(appendix);
+
+ count++;
+ }
+
+ return file;
+}
+
+void _bt_remove_tmp_file(char *file_path)
+{
+ if (g_str_has_prefix(file_path, BT_TMP_FILE) == TRUE) {
+ DBG_SECURE("Remove the file: %s", file_path);
+ ecore_file_remove(file_path);
+ }
+}
+
+void _bt_remove_vcf_file(char *file_path)
+{
+ if (g_str_has_prefix(file_path, BT_CONTACT_SHARE_TMP_DIR) == TRUE) {
+ DBG_SECURE("Remove the file: %s", file_path);
+ ecore_file_remove(file_path);
+ }
+}
+
+char *_bt_share_create_transfer_file(char *text)
+{
+ int fd;
+ int file_type;
+ char *file = NULL;
+ char *content;
+ char *url_sheme;
+ ssize_t write_size;
+
+ retv_if(text == NULL, NULL);
+
+ url_sheme = g_uri_parse_scheme(text);
+
+ if (url_sheme) {
+ /* HTTP file generate */
+ g_free(url_sheme);
+ file_type = BT_HTTP_FILE;
+ } else {
+ /* TXT file generate */
+ file_type = BT_TXT_FILE;
+ }
+
+ file = __bt_share_get_transfer_file_name(file_type);
+ retv_if(file == NULL, NULL);
+
+ fd = open(file, O_RDWR | O_CREAT, 0755);
+
+ if (fd < 0) {
+ ERR("Fail to open the file : %s", file);
+ goto fail;
+ }
+
+ if (file_type == BT_HTTP_FILE) {
+ content = g_strdup_printf(HTML_FORMAT, text, text);
+ } else {
+ content = g_strdup(text);
+ }
+
+ DBG_SECURE("content: \n%s", content);
+
+ write_size = write(fd, content, strlen(content));
+ g_free(content);
+ close(fd);
+
+ if (write_size < 0) {
+ ERR("Fail to write in file");
+ goto fail;
+ }
+
+ return file;
+fail:
+ g_free(file);
+ return NULL;
+}
+
#include <dbus/dbus.h>
#include <glib.h>
#include <time.h>
+#include <sys/stat.h>
#include <stdlib.h>
#include <string.h>
#include <notification.h>
-#include <sysman.h>
#include <aul.h>
+#include <vconf.h>
#include "applog.h"
-#include "bluetooth-api.h"
#include "bt-share-main.h"
#include "bt-share-ipc.h"
#include "bt-share-syspopup.h"
#include "bt-share-resource.h"
#include "obex-event-handler.h"
#include "bluetooth-share-api.h"
+#include "bt-share-common.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_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)
+static void __bt_tr_data_free(bt_tr_data_t * data)
{
retm_if(data == NULL, "Invalid param");
g_free(data->file_path);
g_free(data->dev_name);
g_free(data->addr);
+ g_free(data->type);
+ g_free(data->content);
g_free(data);
}
static void __popup_res_cb(int res)
{
- DBG("+\n");
+ DBG("+");
struct bt_appdata *ad = app_state;
if (ad->popups.syspopup_request == FALSE) {
- DBG("This event is not mine\n");
- return;
+ DBG("This event is not mine\n");
+ return;
}
- DBG(" res : %d\n", res);
+ DBG(" res : %d", res);
/* Inorder to support calling popup from callback, we have to make
* syspopup_request false here and also should not assign
* ad->popups.popup_cb = NULL */
if (NULL != ad->popups.popup_cb) {
if (res == 0)
ad->popups.popup_cb(ad->popups.popup_cb_data,
- NULL,
- (void *)POPUP_RESPONSE_OK);
+ NULL, (void *)POPUP_RESPONSE_OK);
else if (res == 1)
ad->popups.popup_cb(ad->popups.popup_cb_data,
- NULL,
- (void *)POPUP_RESPONSE_CANCEL);
+ NULL,
+ (void *)POPUP_RESPONSE_CANCEL);
else if (res == 2)
ad->popups.popup_cb(ad->popups.popup_cb_data,
- NULL,
- (void *)POPUP_RESPONSE_TIMEOUT);
+ NULL,
+ (void *)POPUP_RESPONSE_TIMEOUT);
}
- DBG("-\n");
+ DBG("-");
}
-
static opc_transfer_info_t *__add_transfer_info(DBusMessage *msg)
{
- int reserved = 0;
+ DBG("+");
+ int i = 0;
int cnt = 0;
- char *addr = NULL;
+ char addr[BLUETOOTH_ADDRESS_LENGTH] = { 0, };
+ char *name = NULL;
+ char *type = NULL;
+ char byte;
+ char *file_path = NULL;
+ char mime_type[BT_MIME_TYPE_MAX_LEN] = { 0 };
+ unsigned int file_size=0;
+ struct stat file_attr;
int len;
- char *filepath = NULL;
- char *mode = NULL;
opc_transfer_info_t *data;
- int i = 0;
- char *token = NULL;
- char *tmp = NULL;
- char *ptr = NULL;
+ struct bt_appdata *ad = app_state;
+ DBusMessageIter iter;
+ DBusMessageIter iter_addr;
+ DBusMessageIter iter_file;
+ DBusMessageIter iter_filepath;
+ GSList *list = NULL;
retv_if(msg == NULL, NULL);
- dbus_message_get_args(msg, NULL,
- DBUS_TYPE_INT32, &reserved,
- DBUS_TYPE_ARRAY, DBUS_TYPE_BYTE,
- &addr, &len,
- DBUS_TYPE_INT32, &cnt,
- DBUS_TYPE_STRING, &filepath,
- DBUS_TYPE_STRING, &mode,
- DBUS_TYPE_INVALID);
-
- retv_if(cnt <= 0, NULL);
- retv_if(addr == NULL, NULL);
- retv_if(filepath == NULL, NULL);
- DBG("reserved ( %d )\n", reserved);
- DBG("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", addr[0],
- addr[1], addr[2], addr[3], addr[4], addr[5]);
- DBG(" cnt( %d )\n", cnt);
- DBG(" filepath( %s )\n", filepath);
- DBG(" mode ( %s )\n", mode);
+ dbus_message_iter_init(msg, &iter);
+ dbus_message_iter_recurse(&iter, &iter_addr);
- data = g_new0(opc_transfer_info_t, 1);
+ while (dbus_message_iter_get_arg_type(&iter_addr) == DBUS_TYPE_BYTE) {
+ dbus_message_iter_get_basic(&iter_addr, &byte);
+ addr[i] = byte;
+ i++;
+ dbus_message_iter_next(&iter_addr);
+ }
- data->file_path = g_new0(char *, cnt + 1);
- data->file_cnt = cnt;
- memcpy(data->addr, addr, BLUETOOTH_ADDRESS_LENGTH);
+ dbus_message_iter_next(&iter);
+ dbus_message_iter_get_basic(&iter, &name);
+ dbus_message_iter_next(&iter);
+ dbus_message_iter_get_basic(&iter, &type);
+
+ dbus_message_iter_next(&iter);
+ dbus_message_iter_recurse(&iter, &iter_file);
+
+ while (dbus_message_iter_get_arg_type(&iter_file) == DBUS_TYPE_ARRAY) {
+ i = 0;
+ dbus_message_iter_recurse(&iter_file, &iter_filepath);
+ len = dbus_message_iter_get_array_len(&iter_filepath);
+ if (len <= 0)
+ continue;
+
+ file_path = g_malloc0(len + 1);
+ if (file_path == NULL) {
+ ERR("Not enough memory!");
+ return NULL;
+ }
- token = strtok_r(filepath, FILE_PATH_DELIM, &ptr);
- while ((token != NULL) && (i < cnt)) {
- len = strlen(token);
+ while (dbus_message_iter_get_arg_type(&iter_filepath) ==
+ DBUS_TYPE_BYTE) {
+ dbus_message_iter_get_basic(&iter_filepath, &byte);
+ file_path[i] = byte;
+ i++;
+ dbus_message_iter_next(&iter_filepath);
+ }
+ if (aul_get_mime_from_file(file_path, mime_type,
+ BT_MIME_TYPE_MAX_LEN) == AUL_R_OK)
+ INFO("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;
+ INFO("%d", file_size);
- tmp = g_malloc0(len + 1);
+ list = g_slist_append(list, file_path);
+ } else {
+ DBG("Invalid filepath");
+ ad->send_data.tr_fail++;
+ __bt_create_send_failed_data(file_path, name, addr,
+ mime_type, file_size);
+
+ if (ad->send_noti == NULL) {
+ ad->send_noti = _bt_insert_notification(ad, BT_SENT_NOTI);
+ } else {
+ _bt_update_notification(ad, ad->send_noti, NULL, NULL, NULL);
+ }
- g_strlcpy(tmp, token, len + 1);
- data->file_path[i] = tmp;
- DBG("File [%d] [%s]\n", i, data->file_path[i]);
- i++;
+ g_free(file_path);
+ }
+
+ dbus_message_iter_next(&iter_file);
+ }
+
+ cnt = g_slist_length(list);
+ INFO("cnt = %d", cnt);
- token = strtok_r(NULL, FILE_PATH_DELIM, &ptr);
+ if (cnt == 0) {
+ /* Show unable to send popup */
+ _bt_create_warning_popup(BLUETOOTH_ERROR_INTERNAL,
+ BT_STR_UNABLE_TO_SEND);
+ return NULL;
+ }
+
+ INFO("%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X", addr[0],
+ addr[1], addr[2], addr[3], addr[4], addr[5]);
+ INFO(" cnt( %d )", cnt);
+ DBG_SECURE(" name ( %s )", name);
+
+ data = g_new0(opc_transfer_info_t, 1);
+ data->content = g_new0(char *, cnt + 1);
+ data->file_path = g_new0(char *, cnt + 1);
+ data->file_cnt = cnt;
+ data->type = g_new0(char *, cnt + 1);
+ data->size = g_new0(unsigned int *, cnt + 1);
+ memcpy(data->addr, addr, BLUETOOTH_ADDRESS_LENGTH);
+ memcpy(data->name, name, BLUETOOTH_DEVICE_NAME_LENGTH_MAX);
+
+ for (i = 0; i < cnt; i++) {
+ char *ptr = g_slist_nth_data(list, i);
+ DBG_SECURE("%s", ptr);
+ if (g_strcmp0(type, "text") == 0)
+ data->file_path[i] = _bt_share_create_transfer_file(ptr);
+ else
+ data->file_path[i] = g_strdup(ptr);
+
+ if(aul_get_mime_from_file(data->file_path[i], mime_type,
+ BT_MIME_TYPE_MAX_LEN) == AUL_R_OK)
+ g_free(data->type);
+ data->type[i] = g_strdup(mime_type);
+
+ if (stat(data->file_path[i], &file_attr) == 0)
+ file_size = file_attr.st_size;
+ else
+ file_size = 0;
+
+ data->size[i] = file_size;
+ data->content[i] = g_strdup(ptr);
+ INFO(" type ( %s ), size (%d)", data->type[i], data->size[i]);
}
bt_transfer_list = g_slist_append(bt_transfer_list, data);
- return bt_transfer_list->data;
-}
+ g_slist_free_full(list, g_free);
+ return data;
+}
-void _free_transfer_info(opc_transfer_info_t *node)
+void _free_transfer_info(opc_transfer_info_t * node)
{
int i;
- DBG("+\n");
+ DBG("+");
ret_if(node == NULL);
for (i = 0; i < node->file_cnt; i++) {
+ //_bt_remove_tmp_file(node->file_path[i]);
g_free(node->file_path[i]);
+ g_free(node->content[i]);
+ g_free(node->type[i]);
}
g_free(node->file_path);
+ g_free(node->content);
+ g_free(node->type);
+ g_free(node->size);
g_free(node);
- DBG("-\n");
+ DBG("-");
}
-void _remove_transfer_info(opc_transfer_info_t *node)
+void _remove_transfer_info(opc_transfer_info_t * node)
{
- DBG("+\n");
+ DBG("+");
ret_if(node == NULL);
- struct bt_appdata *ad = app_state;
bt_transfer_list = g_slist_remove(bt_transfer_list, node);
_free_transfer_info(node);
- if (ad->tr_send_list) {
- bt_share_release_tr_data_list(ad->tr_send_list);
- ad->tr_send_list = NULL;
- }
-
- DBG("-\n");
+ DBG("-");
}
-int _request_file_send(opc_transfer_info_t *node)
+int _request_file_send(opc_transfer_info_t * node)
{
struct bt_appdata *ad = app_state;
int ret;
- DBG("+\n");
+ DBG("+");
retv_if(ad == NULL, BLUETOOTH_ERROR_INVALID_PARAM);
retv_if(node == NULL, BLUETOOTH_ERROR_INVALID_PARAM);
- ret = bluetooth_opc_push_files((bluetooth_device_address_t *)node->addr,
- node->file_path);
+ ret =
+ bluetooth_opc_push_files((bluetooth_device_address_t *) node->addr,
+ node->file_path);
if (ret != BLUETOOTH_ERROR_NONE) {
- DBG("bluetooth_opc_push_files failed : %d", ret);
+ ERR("bluetooth_opc_push_files failed : %d", ret);
return ret;
}
__bt_create_send_data(node);
- DBG("-\n");
+ DBG("-");
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);
-static DBusHandlerResult __event_filter(DBusConnection *sys_conn,
- DBusMessage *msg, void *data)
+ 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 *path = dbus_message_get_path(msg);
if (dbus_message_get_type(msg) != DBUS_MESSAGE_TYPE_SIGNAL)
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
member = (char *)dbus_message_get_member(msg);
- DBG("member (%s)\n", member);
+ INFO("member (%s)", member);
- if (dbus_message_is_signal(msg, BT_SYSPOPUP_INTERFACE, BT_SYSPOPUP_METHOD_RESPONSE)) {
+ if (dbus_message_is_signal
+ (msg, BT_SYSPOPUP_INTERFACE, BT_SYSPOPUP_METHOD_RESPONSE)) {
int res = 0;
dbus_message_get_args(msg, NULL,
- DBUS_TYPE_INT32, &res,
- DBUS_TYPE_INVALID);
+ DBUS_TYPE_INT32, &res, DBUS_TYPE_INVALID);
__popup_res_cb(res);
- } else if (dbus_message_is_signal(msg, BT_UG_IPC_INTERFACE, BT_UG_IPC_METHOD_SEND)) {
+ } else
+ if (dbus_message_is_signal
+ (msg, BT_UG_IPC_INTERFACE, BT_UG_IPC_METHOD_SEND)) {
opc_transfer_info_t *node;
+
node = __add_transfer_info(msg);
if (node == NULL)
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- if (bluetooth_opc_session_is_exist() == FALSE) {
- ret = _request_file_send(node);
- 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);
- g_slist_free_full(bt_transfer_list,
- (GDestroyNotify)_free_transfer_info);
- bt_transfer_list = NULL;
+ ret = _request_file_send(node);
+ if (ret == BLUETOOTH_ERROR_IN_PROGRESS) {
+ INFO("Aleady OPC progressing. Once completed previous job, will be started");
+ } else if (ret != BLUETOOTH_ERROR_NONE) {
+ _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 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;
+ }
+ 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 {
- DBG("Aleady OPC progressing. Once completed previous job, will be started\n");
+ bluetooth_obex_server_cancel_transfer(noti_id);
}
- } 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;
- if (!dbus_message_get_args(msg, NULL,
- DBUS_TYPE_STRING, &transfer_type,
- DBUS_TYPE_INT32, &transfer_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
- bluetooth_obex_server_cancel_transfer(transfer_id);
} else if (dbus_message_is_signal(msg, BT_SHARE_UI_INTERFACE,
- BT_SHARE_UI_SIGNAL_SEND_FILE)) {
+ BT_SHARE_UI_SIGNAL_SEND_FILE)) {
opc_transfer_info_t *node;
+
node = __add_transfer_info(msg);
if (node == NULL)
return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
- if (bluetooth_opc_session_is_exist() == FALSE) {
- ret = _request_file_send(node);
- 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);
- g_slist_free_full(bt_transfer_list,
- (GDestroyNotify)_free_transfer_info);
- bt_transfer_list = NULL;
- }
- } else {
- DBG("Aleady OPC progressing. Once completed"
- " previous job, will be started\n");
+ ret = _request_file_send(node);
+ if (ret == BLUETOOTH_ERROR_IN_PROGRESS) {
+ INFO("Aleady OPC progressing. Once completed previous job, will be started");
+ } else if (ret != BLUETOOTH_ERROR_NONE) {
+ _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_INFO_UPDATE)) {
+ BT_SHARE_UI_SIGNAL_INFO_UPDATE)) {
int tr_uid = 0;
int tr_type = 0;
dbus_message_get_args(msg, NULL,
- DBUS_TYPE_INT32, &tr_uid,
- DBUS_TYPE_INT32, &tr_type,
- DBUS_TYPE_INVALID);
+ DBUS_TYPE_INT32, &tr_uid,
+ DBUS_TYPE_INT32, &tr_type,
+ DBUS_TYPE_INVALID);
- DBG("tr_uid = %d, tr_type = %d \n", tr_uid, tr_type);
+ INFO("tr_uid = %d, tr_type = %d ", tr_uid, tr_type);
__bt_share_update_tr_info(tr_uid, tr_type);
} else if (dbus_message_is_signal(msg, BT_SHARE_FRWK_INTERFACE,
- BT_SHARE_FRWK_SIGNAL_DEINIT)) {
+ BT_SHARE_FRWK_SIGNAL_DEINIT)) {
/* Deinitialize the obex server */
if (bluetooth_obex_server_deinit() == BLUETOOTH_ERROR_NONE) {
- if (vconf_set_bool(BT_VCONF_OPP_SERVER_INIT, FALSE)< 0)
- ERR("Fail to set the vconf");
+ 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;
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;
}
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_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_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;
}
-void _bt_send_message_to_ui(int transfer_id, char *name, int percentage, gboolean completed, int error_type)
+void _bt_update_transfer_list_view(char *db)
{
DBusMessage *msg = NULL;
ret_if(dbus_connection == NULL);
- ret_if(name == NULL);
msg = dbus_message_new_signal(BT_SHARE_ENG_OBJECT,
- BT_SHARE_ENG_INTERFACE,
- BT_SHARE_ENG_SIGNAL_PROGRESS);
+ BT_SHARE_ENG_INTERFACE,
+ BT_SHARE_ENG_SIGNAL_UPDATE_VIEW);
if (!msg) {
- ERR("Unable to allocate memory\n");
+ ERR("Unable to allocate memory");
return;
}
+
if (!dbus_message_append_args(msg,
- DBUS_TYPE_INT32, &transfer_id,
- DBUS_TYPE_STRING, &name,
- DBUS_TYPE_INT32, &percentage,
- DBUS_TYPE_BOOLEAN, &completed,
- DBUS_TYPE_INT32, &error_type,
- DBUS_TYPE_INVALID)) {
- ERR("Event sending failed\n");
+ DBUS_TYPE_STRING, &db,
+ DBUS_TYPE_INVALID)) {
+ ERR("Event sending failed");
dbus_message_unref(msg);
return;
}
+
dbus_message_set_destination(msg, BT_SHARE_UI_INTERFACE);
dbus_connection_send(dbus_connection, msg, NULL);
dbus_message_unref(msg);
-
- return;
}
-
-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,};
- bundle *b = NULL;
- b = bundle_create();
- ret_if(b == NULL);
-
- switch(error_type) {
+ /* 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:
- snprintf(str, BT_TEXT_LEN_MAX, "%s", BT_STR_UNABLE_TO_SEND);
+ case BLUETOOTH_ERROR_CANCEL:
+ snprintf(str, BT_TEXT_LEN_MAX, "%s",
+ msg);
break;
default:
return;
}
+ b = bundle_create();
+ ret_if(b == NULL);
+
bundle_add(b, "launch-type", "warning_popup");
bundle_add(b, "message", str);
aul_launch_app(UI_PACKAGE, b);
bundle_free(b);
- }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;
- }
-
- if (!dbus_message_append_args(msg,
- DBUS_TYPE_INT32, &error_type,
- DBUS_TYPE_INVALID)) {
- DBG("Event sending failed\n");
- dbus_message_unref(msg);
- return;
- }
-
- dbus_message_set_destination(msg, BT_SHARE_UI_INTERFACE);
- dbus_connection_send(dbus_connection, msg, NULL);
- dbus_message_unref(msg);
}
-
return;
}
-void _bt_update_transfer_list_view(const char *table)
-{
- 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_UPDATE_VIEW);
- if (!msg) {
- ERR("Unable to allocate memory\n");
- return;
- }
-
- if (!dbus_message_append_args(msg,
- DBUS_TYPE_STRING, &table,
- DBUS_TYPE_INVALID)) {
- DBG("Event sending failed\n");
- dbus_message_unref(msg);
- return;
- }
-
- dbus_message_set_destination(msg, BT_SHARE_UI_INTERFACE);
- dbus_connection_send(dbus_connection, msg, NULL);
- dbus_message_unref(msg);
-}
-
static time_t __bt_get_current_timedata(void)
{
time_t t;
time(&t);
- return ((int) t);
+ return ((int)t);
}
static char *__bt_conv_addr_type_to_addr_string(char *addr)
{
- char address[BT_ADDR_STR_LEN_MAX] = {0,};
+ char address[BT_ADDR_STR_LEN_MAX] = { 0, };
retv_if(addr == NULL, NULL);
snprintf(address, BT_ADDR_STR_LEN_MAX,
- "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
- addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
+ "%2.2X:%2.2X:%2.2X:%2.2X:%2.2X:%2.2X",
+ addr[0], addr[1], addr[2], addr[3], addr[4], addr[5]);
return g_strdup(address);
}
-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)
+{
+ 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");
ret_if(node == NULL);
struct bt_appdata *ad = app_state;
- int ret = 0;
int count = 0;
- bluetooth_device_info_t devinfo;
- sqlite3 *db = NULL;
-
- ret = bluetooth_get_bonded_device(
- (bluetooth_device_address_t *)node->addr, &devinfo);
+ int session_id;
- if (ret != BLUETOOTH_ERROR_NONE) {
- ERR("bluetooth_get_bonded_device failed \n");
- return;
- }
+ sqlite3 *db = NULL;
- DBG("Name [%s]\n", devinfo.device_name.name);
+ DBG_SECURE("Name [%s]", node->name);
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);
for (count = 0; count < node->file_cnt; count++) {
bt_tr_data_t *tmp;
tmp = g_malloc0(sizeof(bt_tr_data_t));
- if (!tmp) {
- bt_share_close_db(db);
+ if(tmp == NULL)
return;
- }
tmp->tr_status = BT_TR_ONGOING;
+ tmp->sid = session_id + 1;
tmp->file_path = g_strdup(node->file_path[count]);
- tmp->dev_name = g_strdup(devinfo.device_name.name);
+ 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[count]);
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);
+ }
+ if (ad->tr_send_list) {
+ bt_share_release_tr_data_list(ad->tr_send_list);
+ ad->tr_send_list = NULL;
}
ad->tr_send_list = bt_share_get_tr_data_list_by_status(db,
- BT_DB_OUTBOUND, BT_TR_ONGOING);
+ BT_DB_OUTBOUND,
+ BT_TR_ONGOING);
bt_share_close_db(db);
if (ad->tr_send_list == NULL)
gboolean _bt_update_sent_data_status(int uid, bt_app_tr_status_t status)
{
- DBG("_bt_update_sent_data_status \n");
-
- DBG("uid = %d \n", uid);
+ INFO("uid = %d", uid);
sqlite3 *db = NULL;
bt_tr_data_t *tmp;
- tmp = g_malloc0(sizeof(bt_tr_data_t));
- if (!tmp)
- return FALSE;
db = bt_share_open_db();
- if (!db) {
- g_free(tmp);
+ if (!db)
+ return FALSE;
+
+ tmp = g_malloc0(sizeof(bt_tr_data_t));
+ if (!tmp)
return FALSE;
- }
tmp->tr_status = status;
tmp->timestamp = __bt_get_current_timedata();
}
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;
sqlite3 *db = NULL;
bt_tr_data_t *tmp;
- DBG("Name [%s]\n", device_name);
- tmp = g_malloc0(sizeof(bt_tr_data_t));
- if (!tmp)
- return FALSE;
+ DBG_SECURE("Name [%s]", device_name);
db = bt_share_open_db();
- if (!db) {
- g_free(tmp);
+ if (!db)
+ 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->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);
static void __bt_share_update_tr_info(int tr_uid, int tr_type)
{
- DBG("__bt_share_update_tr_info tr_uid = %d \n", tr_uid);
+ DBG("tr_uid = %d", tr_uid);
+
int status = -1;
struct bt_appdata *ad = app_state;
- char str[NOTIFICATION_TEXT_LEN_MAX] = { 0 };
- notification_h noti = NULL;
bt_tr_data_t *info = NULL;
sqlite3 *db = NULL;
if (tr_type == BT_TR_OUTBOUND) {
if (tr_uid == -1) {
- _bt_delete_notification(BT_NOTI_T,
- SEND_NOTI_PRIV_ID);
+ /* Click the "clear list" button in bluetooth-share-ui */
+ /* Delete all outbound db / notification info */
+ _bt_delete_notification(ad->send_noti);
+ ad->send_noti = NULL;
ad->send_data.tr_success = 0;
ad->send_data.tr_fail = 0;
- bt_share_remove_tr_data_by_notification(db, BT_DB_OUTBOUND);
+ DBG("clear all");
+ bt_share_remove_tr_data_by_notification(db,
+ BT_DB_OUTBOUND);
bt_share_close_db(db);
} else {
+ /* Delete selected outbound db / notification info */
+
info = bt_share_get_tr_data(db, BT_DB_OUTBOUND, tr_uid);
if (info != NULL) {
status = info->tr_status;
- g_free(info);
+ __bt_tr_data_free(info);
}
- bt_share_remove_tr_data_by_id(db, BT_DB_OUTBOUND, tr_uid);
+ bt_share_remove_tr_data_by_id(db, BT_DB_OUTBOUND,
+ tr_uid);
bt_share_close_db(db);
- if (status == BT_TR_SUCCESS && ad->send_data.tr_success > 0)
+ if (status == BT_TR_SUCCESS
+ && ad->send_data.tr_success > 0)
ad->send_data.tr_success--;
- else if (status == BT_TR_FAIL && ad->send_data.tr_fail > 0)
+ else if (status == BT_TR_FAIL
+ && ad->send_data.tr_fail > 0)
ad->send_data.tr_fail--;
else
return;
- _bt_delete_notification(BT_NOTI_T,
- SEND_NOTI_PRIV_ID);
-
- if ((ad->send_data.tr_success + ad->send_data.tr_fail) != 0) {
- snprintf(str, sizeof(str), BT_TR_STATUS,
- ad->send_data.tr_success, ad->send_data.tr_fail);
-
- noti = _bt_create_notification(BT_NOTI_T,
- SEND_NOTI_PRIV_ID);
- _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_SEND_NOTI, str,
- BT_ICON_QP_SEND);
+ if ((ad->send_data.tr_success +
+ ad->send_data.tr_fail) != 0) {
+ _bt_update_notification(ad, ad->send_noti, NULL, NULL, NULL);
+ } else {
+ _bt_delete_notification(ad->send_noti);
}
}
} else if (tr_type == BT_TR_INBOUND) {
if (tr_uid == -1) {
- _bt_delete_notification(BT_NOTI_T,
- RECV_NOTI_PRIV_ID);
+ /* Click the "clear list" button in bluetooth-share-ui */
+ /* Delete all inbound db / notification info */
+
+ _bt_delete_notification(ad->receive_noti);
+ ad->receive_noti = NULL;
ad->recv_data.tr_success = 0;
ad->recv_data.tr_fail = 0;
bt_share_remove_all_tr_data(db, BT_DB_INBOUND);
bt_share_close_db(db);
} else {
+ /* Delete selected outbound db / notification info */
+
info = bt_share_get_tr_data(db, BT_DB_INBOUND, tr_uid);
if (info != NULL) {
status = info->tr_status;
- g_free(info);
+ __bt_tr_data_free(info);
}
- bt_share_remove_tr_data_by_id(db, BT_DB_INBOUND, tr_uid);
+ bt_share_remove_tr_data_by_id(db, BT_DB_INBOUND,
+ tr_uid);
bt_share_close_db(db);
- if (status == BT_TR_SUCCESS && ad->recv_data.tr_success > 0)
+ if (status == BT_TR_SUCCESS
+ && ad->recv_data.tr_success > 0)
ad->recv_data.tr_success--;
- else if (status == BT_TR_FAIL && ad->recv_data.tr_fail > 0)
+ else if (status == BT_TR_FAIL
+ && ad->recv_data.tr_fail > 0)
ad->recv_data.tr_fail--;
else
return;
- _bt_delete_notification(BT_NOTI_T,
- RECV_NOTI_PRIV_ID);
- if ((ad->recv_data.tr_success + ad->recv_data.tr_fail) != 0) {
- snprintf(str, sizeof(str), BT_TR_STATUS,
- ad->recv_data.tr_success, ad->recv_data.tr_fail);
-
- noti = _bt_create_notification(BT_NOTI_T,
- RECV_NOTI_PRIV_ID);
- _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_NOTI, str,
- BT_ICON_QP_RECEIVE);
+ if ((ad->recv_data.tr_success +
+ ad->recv_data.tr_fail) != 0) {
+ _bt_update_notification(ad, ad->receive_noti, NULL, NULL, NULL);
+ } else {
+ _bt_delete_notification(ad->receive_noti);
}
}
} else {
- ERR("Invalid transfer type \n");
+ ERR("Invalid transfer type");
+ bt_share_close_db(db);
}
return;
}
-
#include "bt-share-noti-handler.h"
#include "bt-share-resource.h"
#include "bt-share-notification.h"
+#include "bt-share-common.h"
#include "bluetooth-share-api.h"
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)
{
- _bt_delete_all_notification();
+ if (ad == NULL)
+ return;
+
+ _bt_deinit_vconf_notification();
+ _bt_delete_notification(ad->opc_noti);
+ _bt_clear_receive_noti_list();
+ ad->send_noti = NULL;
+ ad->receive_noti = NULL;
+ ad->opc_noti = NULL;
bluetooth_opc_deinit();
bluetooth_obex_server_deinit();
_bt_unregister_notification_cb(ad);
- if (vconf_set_bool(BT_VCONF_OPP_SERVER_INIT, FALSE) < 0)
- ERR("Fail to set the vconf");
+ g_free(server_auth_info.filename);
+ server_auth_info.filename = NULL;
+
+ DBG("Terminating bluetooth-share daemon");
}
static void __bt_sigterm_handler(int signo)
DBG("-");
}
-static void __bt_update_notification_status_values()
+static void __bt_update_transfer_status_values(void)
{
struct bt_appdata *ad = app_state;
GSList *tr_data_list = NULL;
GSList *list_iter = NULL;
bt_tr_data_t *info = NULL;;
- char str[NOTIFICATION_TEXT_LEN_MAX] = { 0 };
- 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;
info->tr_status = BT_TR_FAIL;
bt_share_update_tr_data(db, BT_DB_OUTBOUND, info->id, info);
} else {
- ERR("Invalid status\n");
+ ERR("Invalid status");
}
list_iter = g_slist_next(list_iter);
}
- if ((ad->send_data.tr_success + ad->send_data.tr_fail) != 0) {
- snprintf(str, sizeof(str), BT_TR_STATUS,
- ad->send_data.tr_success, ad->send_data.tr_fail);
-
- noti = _bt_create_notification(BT_NOTI_T,
- SEND_NOTI_PRIV_ID);
- _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_SEND_NOTI, str,
- BT_ICON_QP_SEND);
- }
-
bt_share_release_tr_data_list(tr_data_list);
tr_data_list = NULL;
list_iter = NULL;
list_iter = g_slist_next(list_iter);
}
-
- if ((ad->recv_data.tr_success + ad->recv_data.tr_fail) != 0) {
-
- snprintf(str, sizeof(str), BT_TR_STATUS,
- ad->recv_data.tr_success, ad->recv_data.tr_fail);
- DBG("str = [%s] \n", str);
-
- _bt_delete_notification(BT_NOTI_T,
- RECV_NOTI_PRIV_ID);
-
- noti = _bt_create_notification(BT_NOTI_T,
- RECV_NOTI_PRIV_ID);
- _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_NOTI, str,
- BT_ICON_QP_RECEIVE);
- }
-
bt_share_release_tr_data_list(tr_data_list);
tr_data_list = NULL;
list_iter = NULL;
bt_share_close_db(db);
+ DBG("[Send] success %d, fail %d", ad->send_data.tr_success, ad->send_data.tr_fail);
+ DBG("[Receive] success %d, fail %d", ad->recv_data.tr_success, ad->recv_data.tr_fail);
+
return;
}
failed:
if (dbus_error_is_set(&err)) {
- ERR("D-Bus Error: %s\n", err.message);
+ ERR("D-Bus Error: %s", err.message);
dbus_error_free(&err);
}
return FALSE;
}
-void _bt_terminate_app(void)
+int _bt_init_obex_server(void)
{
- if (main_loop) {
- g_main_loop_quit(main_loop);
+ char storage[STORAGE_PATH_LEN_MAX];
+
+ _bt_get_default_storage(storage);
+ if (bluetooth_obex_server_init(storage) !=
+ BLUETOOTH_ERROR_NONE) {
+ ERR("Fail to init obex server");
+ return BT_SHARE_FAIL;
}
+
+ bluetooth_obex_server_set_root(BT_FTP_FOLDER);
+
+ return BT_SHARE_ERROR_NONE;
}
-int main(int argc, char *argv[])
+int main(void)
{
- DBG("+");
int ret;
struct bt_appdata ad;
+ INFO("Starting bluetooth-share daemon");
memset(&ad, 0, sizeof(struct bt_appdata));
app_state = &ad;
g_type_init();
if (__bt_dbus_request_name() == FALSE) {
- DBG("Aleady dbus instance existed\n");
+ INFO("Aleady dbus instance existed");
exit(0);
}
return -1;
/* Set the uid / gid to 5000 */
- control_privilege();
+ if (perm_app_set_privilege("org.tizen.bluetooth-share", NULL, NULL) !=
+ PC_OPERATION_SUCCESS)
+ ERR("Failed to set app privilege");
bluetooth_register_callback(_bt_share_event_handler, NULL);
ret = bluetooth_opc_init();
if (ret != BLUETOOTH_ERROR_NONE) {
- ERR("bluetooth_opc_init failed!!\n");
+ ERR("bluetooth_opc_init failed");
return -1;
}
- char storage[STORAGE_PATH_LEN_MAX];
- if (TRUE == _bt_get_default_storage(storage)) {
- if (bluetooth_obex_server_init(storage) ==
- BLUETOOTH_ERROR_NONE) {
- if (vconf_set_bool(BT_VCONF_OPP_SERVER_INIT, TRUE) < 0)
- ERR("Fail to set the vconf");
-
- bluetooth_obex_server_set_root(BT_FTP_FOLDER);
- }
- }
-
_bt_init_dbus_signal();
- _bt_init_vconf_notification();
- __bt_update_notification_status_values();
+ _bt_init_vconf_notification(&ad);
+ __bt_update_transfer_status_values();
_bt_register_notification_cb(&ad);
+ if (_bt_init_obex_server() == BT_SHARE_ERROR_NONE)
+ ad.obex_server_init = TRUE;
+
if (terminated == TRUE) {
__bt_release_service(&ad);
+ bluetooth_unregister_callback();
return -1;
}
g_main_loop_run(main_loop);
__bt_release_service(&ad);
+ bluetooth_unregister_callback();
- DBG("-");
return 0;
}
#include <glib.h>
#include <vconf.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <fcntl.h>
+#include <unistd.h>
#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)
{
char *root_path = NULL;
char *download_path = NULL;
- DBG("__bt_default_memory_changed_cb\n");
+ DBG("+");
ret_if (node == NULL);
- DBG("key=%s\n", vconf_keynode_get_name(node));
+ DBG_SECURE("key=%s\n", vconf_keynode_get_name(node));
if (vconf_keynode_get_type(node) == VCONF_TYPE_INT) {
/* Phone memory is 0, MMC is 1 */
default_memory = vconf_keynode_get_int(node);
- root_path = default_memory ? BT_DOWNLOAD_MMC_FOLDER : BT_DOWNLOAD_MEDIA_FOLDER;
+ root_path = default_memory ? BT_DOWNLOAD_MMC_ROOT : BT_DOWNLOAD_PHONE_ROOT;
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) {
+ ERR("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_SECURE("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_SECURE("Default Memory set to Phone");
+ }
+ }
+ }
+ }
+ DBG("-");
+}
+
+void _bt_init_vconf_notification(void *data)
{
+ retm_if(!data, "invalid param!");
+
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");
+ ERR("vconf_notify_key_changed init failed");
+ }
+
+ ret = vconf_notify_key_changed(VCONFKEY_SYSMAN_MMC_STATUS,
+ __bt_mmc_status_changed_cb, data);
+ if (ret < 0) {
+ ERR("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) {
+ ERR("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) {
+ ERR("vconf_notify_key_changed deinit failed");
+ }
}
#include <notification.h>
#include <appsvc.h>
#include <vconf.h>
+
+#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"
#define BT_PERCENT_STR_LEN 5
#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, int id)
+
+notification_h _bt_insert_notification(struct bt_appdata *ad, bt_notification_type_e type)
{
- DBG("+\n");
- DBG("+Create type : %d id : %d \n", type, id);
notification_h noti = NULL;
- noti = notification_new(type, -1, id);
+ 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;
+
+ DBG("Create notification type : %d", type);
+
+ if (type == BT_SENT_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";
+
+ 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_new\n");
+ ERR("Fail to notification_create");
return NULL;
}
- DBG("noti : %d \n", noti);
- DBG("-\n");
+
+ notification_set_text_domain(noti, BT_COMMON_PKG, BT_COMMON_RES);
+
+ if (title) {
+ 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 [%d]", ret);
+ }
+ }
+
+ if (content) {
+ 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_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 [%d]", ret);
+ }
+
+ 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_insert_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");
- if (!noti)
- return -1;
+ 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) {
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 (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\n");
+ ERR("Fail to notification_set_text [%d]", ret);
}
}
- ret = notification_insert(noti, NULL);
- if (ret != NOTIFICATION_ERROR_NONE) {
- ERR("Fail to notification_insert\n");
+ 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);
+ }
}
- ret = notification_free(noti);
+ ret = notification_update(noti);
if (ret != NOTIFICATION_ERROR_NONE) {
- ERR("Fail to notification_free\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)
{
-// DBG("id : %d percentage : %.2f\n", id, (double)val / 100);
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)
+int _bt_get_notification_priv_id(notification_h noti)
{
+ int group_id = 0;
+ int priv_id = 0;
notification_error_e ret = NOTIFICATION_ERROR_NONE;
- notification_list_h list = NULL;
- notification_h noti = NULL;
- /* Get notification information from notification detail list */
- ret = notification_get_detail_list(BT_SHARE_BIN_PATH,
- -1,
- priv_id,
- -1,
- &list);
+ ret = notification_get_id(noti, &group_id, &priv_id);
if (ret != NOTIFICATION_ERROR_NONE) {
- ERR("Fail to notification_get_text\n");
- return FALSE;
- }
-
- if (list) {
- noti = notification_list_get_data(list);
- char *text = NULL;
- notification_get_text(noti,
- NOTIFICATION_TEXT_TYPE_TITLE,
- &text);
- g_strlcpy(str, text, NOTIFICATION_TEXT_LEN_MAX);
- } else {
- return FALSE;
+ ERR("Fail to notification_get_id [%d]", ret);
}
- return TRUE;
+ return priv_id;
}
-
-int _bt_delete_notification(bt_qp_type_t type, int id)
+int _bt_delete_notification(notification_h noti)
{
- DBG("+\n");
- DBG("-Del type : %d id : %d \n", type, id);
+ retv_if(!noti, BT_SHARE_FAIL);
notification_error_e ret = NOTIFICATION_ERROR_NONE;
- /* In case daemon, give full path */
- ret = notification_delete_by_priv_id(BT_SHARE_BIN_PATH, type, id);
- if (ret != NOTIFICATION_ERROR_NONE) {
- ERR("Fail to notification_delete_by_priv_id\n");
- }
- DBG("-\n");
- return ret;
-}
+ INFO("Delete noti : %d", noti);
-int _bt_delete_all_notification()
-{
- DBG("+\n");
- notification_error_e ret = NOTIFICATION_ERROR_NONE;
- ret = notification_delete_all_by_type(NULL, BT_ONGOING_T);
- if (ret != NOTIFICATION_ERROR_NONE) {
- ERR("Fail to notification_delete_all_by_type\n");
- }
- ret = notification_delete_all_by_type(NULL, BT_NOTI_T);
+ /* In case daemon, give full path */
+ ret = notification_delete(noti);
if (ret != NOTIFICATION_ERROR_NONE) {
- ERR("Fail to notification_delete_all_by_type\n");
+ ERR("Fail to notification_delete [%d]", ret);
}
- DBG("-\n");
+
return ret;
}
-
-
int _bt_set_notification_app_launch(notification_h noti,
- bt_qp_launch_type_t type,
+ bt_notification_launch_type_e launch_type,
const char *transfer_type,
const char *filename,
- const char *progress_cnt)
+ const char *progress_cnt,
+ int transfer_id)
{
DBG("+\n");
if (!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 };
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");
}
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);
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);
return ret;
}
-
-int _bt_set_notification_property(notification_h noti, int flag)
+gboolean _bt_update_notification_status(struct bt_appdata *ad )
{
- DBG("+\n");
- if (!noti)
- return -1;
+ 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;
- notification_error_e ret = NOTIFICATION_ERROR_NONE;
+ retv_if (ad == NULL, FALSE);
- ret = notification_set_property(noti, flag);
- if (ret != NOTIFICATION_ERROR_NONE) {
- ERR("Fail to notification_set_property\n");
+ /* 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);
}
- ret = notification_set_display_applist(noti,
- NOTIFICATION_DISPLAY_APP_ALL ^
- NOTIFICATION_DISPLAY_APP_TICKER);
- if (ret != NOTIFICATION_ERROR_NONE) {
- ERR("Fail to notification_set_display_applist\n");
+ if (list_head != NULL) {
+ notification_free_list(list_head);
+ list_head = NULL;
}
- DBG("-\n");
- return ret;
-}
+ /* 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);
-static void __bt_noti_changed_cb(void *data, notification_type_e type)
+ return is_noti_existed;
+}
+
+static void __bt_notification_changed_cb(void *data, notification_type_e type, notification_op *op_list, int num_op)
{
- DBG("+\n");
+ DBG("__bt_notification_changed_cb");
+ retm_if (data == NULL, "Invalid data");
struct bt_appdata *ad = (struct bt_appdata *)data;
- if (NULL == ad)
- return;
-
+ 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 count = 0;
+ int group_id;
+ int priv_id;
sqlite3 *db = NULL;
- noti_err = notification_get_count(NOTIFICATION_TYPE_NOTI, BT_SHARE_BIN_PATH,
- NOTIFICATION_GROUP_ID_NONE, NOTIFICATION_PRIV_ID_NONE, &count);
- if (noti_err != NOTIFICATION_ERROR_NONE) {
+ 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;
- }
- /* This callback used only for clear button of notification bar. */
- /* So need to check the clear button of in/outbound list view */
- if (count >= 1)
+ if (ad->send_noti == NULL && ad->receive_noti == NULL)
return;
- ad->send_data.tr_fail = 0;
- ad->send_data.tr_success = 0;
- ad->recv_data.tr_fail = 0;
- ad->recv_data.tr_success = 0;
+ 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();
- if (!db)
- return;
-
- bt_share_remove_tr_data_by_notification(db, BT_DB_INBOUND);
- bt_share_remove_tr_data_by_notification(db, BT_DB_OUTBOUND);
- DBG("DB record of notification was removed\n");
+ 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("-\n");
+ 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);
+
}
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);
}
}
{
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);
}
}
-
#include "bt-share-resource.h"
#include "obex-event-handler.h"
-
-
-
extern struct bt_appdata *app_state;
#define BT_POPUP_SYSPOPUP_TIMEOUT_FOR_MULTIPLE_POPUPS 200
#define BT_SYSPOPUP_EVENT_LEN_MAX 50
-
-
-
static gboolean __bt_system_popup_timer_cb(gpointer user_data)
{
int ret = 0;
ERR("There is some problem with the user data..popup can not be created\n");
return FALSE;
}
- ret = syspopup_launch("bt-syspopup", b);
+ ret = syspopup_launch("bt-syspopup", b);
if (0 > ret) {
ERR("launching sys-popup failed\n");
- return TRUE;
- } else {
- DBG("Hurray Popup launched \n");
- bundle_free(b);
- return FALSE;
}
+
+ bundle_free(b);
+ return FALSE;
}
int _bt_launch_system_popup(bt_app_event_type_t event_type,
struct bt_appdata *ad = app_state;
DBG("+\n");
- if(cb == NULL)
- return -1;
b = bundle_create();
- if(b == NULL)
+ if(b == NULL) {
+ ERR("bundle_create failed");
return -1;
+ }
bundle_add(b, "title", popup_params->title);
bundle_add(b, "type", popup_params->type);
case BT_APP_EVENT_CONFIRM_MODE_REQUEST:
strncpy(event_str, "app-confirm-request", sizeof(event_str));
break;
- case BT_APP_EVENT_FILE_RECIEVED:
- strncpy(event_str, "file-recieved", sizeof(event_str));
+ 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;
}
bundle_free(b);
}
- ad->popups.popup_cb = (bt_app_cb) cb;
+ if (cb != NULL)
+ ad->popups.popup_cb = (bt_app_cb) cb;
+
ad->popups.popup_cb_data = data;
ad->popups.syspopup_request = TRUE;
#include <stdlib.h>
#include <string.h>
#include <glib.h>
+#include <app_control.h>
#include <vconf-keys.h>
+#include <calendar.h>
+#include <vconf.h>
+#include <Ecore_File.h>
+#include <bluetooth-share-api.h>
+#include <notification.h>
+#include <media_content.h>
+#include <sys/stat.h>
+#include <aul.h>
+#include <storage.h>
#include "applog.h"
#include "bluetooth-api.h"
#include "bt-share-common.h"
#include "bt-share-noti-handler.h"
-#include "bluetooth-share-api.h"
+extern struct bt_appdata *app_state;
-#include <contacts-svc.h>
-#include <calendar-svc-provider.h>
-#include <vconf.h>
-#include <Ecore_File.h>
+typedef struct {
+ void *noti_handle;
+ int transfer_id;
+ int noti_id;
+} bt_noti_data_t;
-extern struct bt_appdata *app_state;
+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;
+
+static gboolean isFirstReceivedPacket = FALSE;
+static gboolean isFirstSentPacket = FALSE;
+
+static gboolean isTransferConnectedReceived = FALSE;
-gboolean _bt_obex_writeclose(bt_obex_server_transfer_info_t *transfer_complete_info);
+
+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);
+static bt_noti_data_t *__bt_get_noti_data_by_transfer_id(int transfer_id)
+{
+ GSList *l;
+ bt_noti_data_t *data;
+
+ for (l = bt_receive_noti_list; l != NULL; l = l->next) {
+ data = l->data;
+
+ if (data == NULL)
+ continue;
+
+ if (data->transfer_id == transfer_id)
+ return data;
+ }
+
+ return NULL;
+}
+
static char *__get_file_name(int cnt, char **path)
{
char *pfilename;
if (path == NULL) {
- DBG("Path is invalid");
+ ERR("Path is invalid");
return NULL;
}
pfilename = strrchr(path[cnt], '/') + 1;
- DBG("File name[%d] : %s \n", cnt, pfilename);
+ DBG_SECURE("File name[%d] : %s", cnt, pfilename);
return pfilename;
}
+static void __delete_notification(gpointer data, gpointer user_data)
+{
+ bt_noti_data_t *noti_data = data;
+
+ if (noti_data == NULL)
+ return;
+
+ _bt_delete_notification(noti_data->noti_handle);
+ g_free(noti_data);
+}
+
+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) {
+ g_slist_foreach(bt_receive_noti_list,
+ (GFunc)__delete_notification,
+ NULL);
+ g_slist_free(bt_receive_noti_list);
+ bt_receive_noti_list = NULL;
+ }
+}
+
+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_SECURE("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);
+}
+
+static bt_file_type_t __get_file_type(char *extn)
+{
+ DBG("exten : %s", 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 gboolean __bt_scan_media_file(char *file_path)
+{
+ int ret;
+
+ ret = media_content_connect();
+ if (ret != MEDIA_CONTENT_ERROR_NONE) {
+ ERR("Fail to connect the media content: %d", ret);
+ return FALSE;
+ }
+
+ ret = media_content_scan_file(file_path);
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ ERR("Fail to scan file: %d", ret);
+
+ ret = media_content_disconnect();
+ if (ret != MEDIA_CONTENT_ERROR_NONE)
+ ERR("Fail to disconnect the media content: %d", ret);
+
+ return TRUE;
+}
void _bt_share_event_handler(int event, bluetooth_event_param_t *param,
void *user_data)
{
int ret;
- static int send_cnt = 0;
- static char *name = NULL;
- char str[NOTIFICATION_TEXT_LEN_MAX] = { 0 };
+ static int send_index = 0;
+ char *name = NULL;
char opc_cnt[NOTIFICATION_TEXT_LEN_MAX] = { 0 };
int percentage = 0;
notification_h noti = 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;
+ 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_DISABLED:
- g_free(server_auth_info.filename);
- server_auth_info.filename = NULL;
- _bt_terminate_app();
+ 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_OPC_CONNECTED:
- DBG("BLUETOOTH_EVENT_OPC_CONNECTED, result [%d] \n", param->result);
+ 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_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) {
+ ERR("info is NULL");
+ return;
+ }
- if (NULL != node && node->file_cnt > send_cnt) {
+ 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");
- _bt_delete_notification(BT_NOTI_T, SEND_NOTI_PRIV_ID);
- noti = _bt_create_notification(BT_NOTI_T,
- SEND_NOTI_PRIV_ID);
-
- snprintf(str, sizeof(str), BT_TR_STATUS,
- ad->send_data.tr_success,
- ad->send_data.tr_fail);
-
- DBG("str = [%s] \n", str);
- _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_SEND_NOTI, str,
- BT_ICON_QP_SEND);
+ if (ad->send_noti == NULL) {
+ ad->send_noti = _bt_insert_notification(ad, BT_SENT_NOTI);
+ } else {
+ _bt_update_notification(ad, ad->send_noti, NULL, NULL, NULL);
+ }
}
- send_cnt = 0;
_remove_transfer_info(node);
- _bt_update_transfer_list_view(BT_OUTBOUND_TABLE);
+ if (!ad->tr_next_data) {
+ bt_share_release_tr_data_list(ad->tr_send_list);
+ ad->tr_send_list = NULL;
+ }
+
} else {
+ ret = notification_status_message_post(BT_STR_SENDING);
+ if (ret != NOTIFICATION_ERROR_NONE)
+ ERR("notification_status_message_post() is failed : %d", ret);
+
_bt_share_block_sleep(TRUE);
_bt_set_transfer_indicator(TRUE);
}
break;
case BLUETOOTH_EVENT_OPC_TRANSFER_STARTED:
- DBG("BLUETOOTH_EVENT_OPC_TRANSFER_STARTED \n");
+ INFO("BLUETOOTH_EVENT_OPC_TRANSFER_STARTED");
+ ret_if(isFirstSentPacket == TRUE);
+ isFirstSentPacket = TRUE;
ret_if(node == NULL);
- name = __get_file_name(send_cnt++, node->file_path);
- snprintf(opc_cnt, sizeof(opc_cnt), "%d/%d",
- send_cnt, node->file_cnt);
- noti = _bt_create_notification(BT_ONGOING_T, SEND_PRIV_ID);
- _bt_set_notification_app_launch(noti, CREATE_PROGRESS,
- NOTI_TR_TYPE_OUT, name, opc_cnt);
- _bt_set_notification_property(noti, QP_NO_TICKER);
- _bt_insert_notification(noti,
- name, opc_cnt,
- BT_ICON_QP_SEND);
+ if(node->size > (100 * 1024)) {
+ if (ad->opc_noti) {
+ _bt_delete_notification(ad->opc_noti);
+ ad->opc_noti = NULL;
+ ad->opc_noti_id = 0;
+ }
+ name = __get_file_name(send_index++, node->file_path);
+ snprintf(opc_cnt, sizeof(opc_cnt), "%d/%d",
+ send_index, node->file_cnt);
+
+ noti = _bt_insert_notification(ad, BT_SENDING_NOTI);
+ 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);
+
+ ad->opc_noti = noti;
+
+ } else {
+ send_index++;
+ }
if (ad->tr_next_data == NULL) {
- ERR("ad->tr_next_data is NULL \n");
+ ERR("ad->tr_next_data is NULL");
break;
}
break;
ad->current_tr_uid = info->id;
- DBG("ad->current_tr_uid = [%d] \n", ad->current_tr_uid);
- ad->tr_next_data = g_slist_next(ad->tr_next_data);
+ INFO("ad->current_tr_uid = [%d]", 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);
+ name = strrchr(client_info->filename, '/');
+ if (name)
+ name++;
+ else
+ name = client_info->filename;
+
percentage = client_info->percentage;
+ if (ad->opc_noti && isFirstSentPacket)
+ _bt_update_notification(ad, ad->opc_noti, name, "", NULL);
+
_bt_update_notification_progress(NULL,
- SEND_PRIV_ID, percentage);
- _bt_send_message_to_ui(SEND_PRIV_ID, name, percentage,
- FALSE, BLUETOOTH_ERROR_NONE);
+ ad->opc_noti_id, percentage);
+ isFirstSentPacket = FALSE;
break;
case BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE:
- DBG("BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE \n");
+ INFO("BLUETOOTH_EVENT_OPC_TRANSFER_COMPLETE");
client_info = (bt_opc_transfer_info_t *)param->param_data;
ret_if(client_info == NULL);
- DBG("client_info->filename = [%s] \n", client_info->filename);
- DBG("ad->current_tr_uid = [%d] \n", ad->current_tr_uid);
+ DBG_SECURE("client_info->filename = [%s]", client_info->filename);
+ INFO("ad->current_tr_uid = [%d]", ad->current_tr_uid);
- _bt_send_message_to_ui(SEND_PRIV_ID, name, 100, TRUE, param->result);
+ name = strrchr(client_info->filename, '/');
+ if (name)
+ name++;
+ else
+ name = client_info->filename;
- _bt_delete_notification(BT_ONGOING_T, SEND_PRIV_ID);
- _bt_delete_notification(BT_NOTI_T, SEND_NOTI_PRIV_ID);
+ DBG("name address = [%x]", name);
- DBG("ad->send_data.tr_fail = %d, ad->send_data.tr_success= %d \n",
+ 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);
if (param->result != BLUETOOTH_ERROR_NONE)
ad->send_data.tr_fail++;
- else
+ else {
ad->send_data.tr_success++;
+ _bt_remove_tmp_file(client_info->filename);
+ _bt_remove_vcf_file(client_info->filename);
+ }
- noti = _bt_create_notification(BT_NOTI_T,
- SEND_NOTI_PRIV_ID);
-
- if (noti != NULL) {
- snprintf(str, sizeof(str), BT_TR_STATUS,
- ad->send_data.tr_success,
- ad->send_data.tr_fail);
-
- DBG("str = [%s] \n", str);
- _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_SEND_NOTI, str,
- BT_ICON_QP_SEND);
+ if (ad->send_noti == NULL) {
+ ad->send_noti = _bt_insert_notification(ad, BT_SENT_NOTI);
+ } else {
+ _bt_update_notification(ad, ad->send_noti, NULL, NULL, NULL);
}
if (param->result != BLUETOOTH_ERROR_NONE) {
_bt_update_sent_data_status(ad->current_tr_uid,
BT_TR_FAIL);
- _bt_create_warning_popup(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_SEND);
+ ad->opp_transfer_abort = FALSE;
} else {
_bt_update_sent_data_status(ad->current_tr_uid,
BT_TR_SUCCESS);
}
- _bt_update_transfer_list_view(BT_OUTBOUND_TABLE);
+
+ _bt_update_transfer_list_view("outbound");
+
+ ad->tr_next_data = g_slist_next(ad->tr_next_data);
break;
case BLUETOOTH_EVENT_OPC_DISCONNECTED:
- DBG("BLUETOOTH_EVENT_OPC_DISCONNECTED \n");
+ INFO("BLUETOOTH_EVENT_OPC_DISCONNECTED");
+ isFirstSentPacket = FALSE;
+ ret_if(node == NULL);
+
+ 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;
+ }
+
+ info = (bt_tr_data_t *)(ad->tr_next_data)->data;
+ if (info == NULL)
+ break;
+ s_id = info->sid;
+ INFO("info->sid = %d info->id = %d", info->sid, info->id);
- if (node->file_cnt > send_cnt) {
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_delete_notification(BT_NOTI_T, SEND_NOTI_PRIV_ID);
- noti = _bt_create_notification(BT_NOTI_T,
- SEND_NOTI_PRIV_ID);
-
- snprintf(str, sizeof(str), BT_TR_STATUS,
- ad->send_data.tr_success,
- ad->send_data.tr_fail);
-
- DBG("str = [%s] \n", str);
- _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_SEND_NOTI, str,
- BT_ICON_QP_SEND);
+ if (ad->send_noti == NULL) {
+ ad->send_noti = _bt_insert_notification(ad, BT_SENT_NOTI);
+ } else {
+ _bt_update_notification(ad, ad->send_noti, NULL, NULL, NULL);
+ }
}
- send_cnt = 0;
+ send_index = 0;
_bt_share_block_sleep(FALSE);
_bt_set_transfer_indicator(FALSE);
_remove_transfer_info(node);
- DBG("gList len : %d\n", g_slist_length(bt_transfer_list));
- if (g_slist_length(bt_transfer_list) > 0) {
- DBG("One more job existed !!\n");
- ret = _request_file_send(bt_transfer_list->data);
- if (ret != BLUETOOTH_ERROR_NONE) {
- g_slist_free_full(bt_transfer_list,
- (GDestroyNotify)_free_transfer_info);
- bt_transfer_list = NULL;
- }
+ if (!ad->tr_next_data) {
+ bt_share_release_tr_data_list(ad->tr_send_list);
+ ad->tr_send_list = NULL;
}
break;
+ case BLUETOOTH_EVENT_OBEX_SERVER_CONNECTION_AUTHORIZE:
+ INFO("BLUETOOTH_EVENT_OBEX_SERVER_CONNECTION_AUTHORIZE");
+ break;
case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_AUTHORIZE:
- DBG("BT_EVENT_OBEX_TRANSFER_AUTHORIZE \n");
+ INFO("BT_EVENT_OBEX_TRANSFER_AUTHORIZE");
if (param->result == BLUETOOTH_ERROR_NONE) {
g_free(server_auth_info.filename);
server_auth_info.filename = NULL;
}
break;
+ case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_CONNECTED:
+ INFO("BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_CONNECTED");
+ if (param->result == BLUETOOTH_ERROR_NONE) {
+
+ isTransferConnectedReceived = TRUE;
+ }
+ break;
case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_STARTED:
- DBG("BT_EVENT_OBEX_TRANSFER_STARTED \n");
+ INFO("BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_STARTED");
+ isFirstReceivedPacket = TRUE;
transfer_info = param->param_data;
- DBG(" %s \n", transfer_info->type);
- noti = _bt_create_notification(BT_ONGOING_T,
- transfer_info->transfer_id);
- _bt_set_notification_app_launch(noti, CREATE_PROGRESS,
- NOTI_TR_TYPE_IN, transfer_info->filename, NULL);
- _bt_set_notification_property(noti, QP_NO_TICKER);
- if (0 == g_strcmp0(transfer_info->type, TRANSFER_GET)) {
- _bt_insert_notification(noti,
- transfer_info->filename, NULL,
- BT_ICON_QP_SEND);
- _bt_update_notification_progress(NULL,
- transfer_info->transfer_id, 0);
- _bt_set_transfer_indicator(TRUE);
- } else {
- _bt_insert_notification(noti,
- transfer_info->filename, NULL,
- BT_ICON_QP_RECEIVE);
- _bt_set_transfer_indicator(TRUE);
+ 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);
+ _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);
+ _bt_set_notification_app_launch(noti, CREATE_PROGRESS,
+ NOTI_TR_TYPE_IN, transfer_info->filename, NULL,
+ transfer_info->transfer_id);
+ }
+
+ data = g_new0(bt_noti_data_t, 1);
+ data->noti_handle = noti;
+ data->noti_id = _bt_get_notification_priv_id(noti);
+
+ data->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;
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;
- if (0 == g_strcmp0(transfer_info->type,
- TRANSFER_GET)) {
- _bt_update_notification_progress(NULL,
- transfer_info->transfer_id,
- transfer_info->percentage);
- } else {
- _bt_update_notification_progress(NULL,
- transfer_info->transfer_id,
- transfer_info->percentage);
+
+ data = __bt_get_noti_data_by_transfer_id(
+ transfer_info->transfer_id);
+ if (data == NULL) {
+ DBG("Data is NULL, returning");
+ return;
}
- _bt_send_message_to_ui(transfer_info->transfer_id,
- transfer_info->filename,
- transfer_info->percentage,
- FALSE, BLUETOOTH_ERROR_NONE);
+ 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;
case BLUETOOTH_EVENT_OBEX_SERVER_TRANSFER_COMPLETED:
- DBG("BT_EVENT_OBEX_TRANSFER_COMPLETED \n");
- transfer_info = param->param_data;
- _bt_share_block_sleep(FALSE);
+ 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;
- _bt_send_message_to_ui(transfer_info->transfer_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,
- transfer_info->transfer_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);
}
- _bt_delete_notification(BT_ONGOING_T,
- transfer_info->transfer_id);
-
if (0 == g_strcmp0(transfer_info->type, TRANSFER_PUT)) {
+ INFO("TRANSFER_PUT");
+
+ file_path = __get_dest_file_path(transfer_info->file_path);
+ DBG_SECURE("Filename : %s", transfer_info->filename);
+ DBG_SECURE("File Path : %s", transfer_info->file_path);
+
+ if (aul_get_mime_from_file(file_path, mime_type,
+ BT_MIME_TYPE_MAX_LEN) == AUL_R_OK)
+ DBG_SECURE("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(
transfer_info->device_name,
- transfer_info->filename,
+ file_path,
+ mime_type, file_size,
BT_TR_SUCCESS);
}
- snprintf(str, sizeof(str), BT_TR_STATUS,
- ad->recv_data.tr_success, ad->recv_data.tr_fail);
- DBG("str = [%s] \n", str);
-
- _bt_delete_notification(BT_NOTI_T,
- RECV_NOTI_PRIV_ID);
-
- noti = _bt_create_notification(BT_NOTI_T,
- RECV_NOTI_PRIV_ID);
- _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_NOTI, str,
- BT_ICON_QP_RECEIVE);
+ _bt_update_transfer_list_view("inbound");
+
+ if (ad->receive_noti == NULL) {
+ ad->receive_noti = _bt_insert_notification(ad, BT_RECEIVED_NOTI);
+ } else {
+ _bt_update_notification(ad, ad->receive_noti, NULL, NULL, NULL);
+ }
+ }else if(0 == g_strcmp0(transfer_info->type, TRANSFER_GET)){
+ INFO("TRANSFER_GET");
}
- _bt_update_transfer_list_view(BT_INBOUND_TABLE);
+ 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 {
+ 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;
+
+ 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;
}
}
-gboolean _bt_get_default_storage(char *storage)
+void _bt_get_default_storage(char *storage)
{
- int val = -1;
- if (-1 == vconf_get_int(VCONFKEY_SETAPPL_DEFAULT_MEM_BLUETOOTH_INT, (void *)&val)) {
- DBG("vconf error\n");
- return FALSE;
+ int val;
+ char *path;
+
+ if (vconf_get_int(VCONFKEY_SETAPPL_DEFAULT_MEM_BLUETOOTH_INT,
+ (void *)&val)) {
+ ERR("vconf error");
+ val = BT_DEFAULT_MEM_PHONE;
}
- if (val == 0) /* Phone memory is 0, MMC is 1 */
- g_strlcpy(storage, BT_DOWNLOAD_PHONE_FOLDER, STORAGE_PATH_LEN_MAX);
+
+ if (val == BT_DEFAULT_MEM_MMC)
+ path = BT_DOWNLOAD_MMC_FOLDER;
else
- g_strlcpy(storage, BT_DOWNLOAD_MMC_FOLDER, STORAGE_PATH_LEN_MAX);
- DBG("Default storage : %s\n", storage);
- return TRUE;
-}
+ path = BT_DOWNLOAD_PHONE_FOLDER;
+ if (access(path, W_OK) == 0) {
+ g_strlcpy(storage, path, STORAGE_PATH_LEN_MAX);
+ DBG("Storage path = [%s]", storage);
+ return;
+ }
-void _bt_app_obex_download_dup_file_cb(void *data, void *obj,
- void *event_info)
-{
- bt_obex_server_authorize_into_t *server_auth_info = data;
+ if ((mkdir(path, 0755)) < 0) {
+ ERR("mkdir fail![%s]", path);
+ }
+
+ g_strlcpy(storage, path, STORAGE_PATH_LEN_MAX);
- DBG("response : %d\n", (int)event_info);
+ DBG("Default storage : %s", storage);
+}
- if ((int)event_info == POPUP_RESPONSE_OK) {
- DBG("OK button pressed \n");
- bluetooth_obex_server_accept_authorize(server_auth_info->filename);
- } else if ((int)event_info == POPUP_RESPONSE_CANCEL) {
- bluetooth_obex_server_reject_authorize();
+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;
+
+ return r;
}
-static gboolean __bt_get_available_memory(long *available_mem_size)
+
+static gboolean __bt_get_available_ext_memory(unsigned long long *available_mem_size)
{
struct statfs fs = {0, };
- int val = -1;
- char *default_memory = NULL;
-
- if (-1 == vconf_get_int(VCONFKEY_SETAPPL_DEFAULT_MEM_BLUETOOTH_INT,
- (void *)&val)) {
- ERR("vconf error\n");
- return FALSE;
- }
- if (val == 0) /* Phone memory is 0, MMC is 1 */
- default_memory = BT_DOWNLOAD_MEDIA_FOLDER;
- else
- default_memory = BT_DOWNLOAD_MMC_FOLDER;
- if (statfs(default_memory, &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/1024);
+ *available_mem_size = fs.f_bavail * (fs.f_bsize);
return TRUE;
}
+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);
-gboolean _bt_app_obex_openwrite_requested(bt_obex_server_authorize_into_t
- *server_auth_info)
+ /* 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, };
- FILE *fd = NULL;
- char text[BT_POPUP_TEXT_LEN] = { 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);
+ /* For vcf file type, some device send weird filename like "telecom/pb.vcf"
+ This filename should be renamed.
+ */
+
+ 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 {
+ g_free(name);
+ }
+
snprintf(temp_filename, BT_FILE_PATH_LEN_MAX, "%s/%s",
storage, server_auth_info->filename);
- fd = fopen(temp_filename, "r");
-
- if (NULL != fd) {
- 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 */
- snprintf(text,
- BT_POPUP_TEXT_LEN,
- BT_STR_FILE_EXSIST_MSG, server_auth_info->filename);
- popup_params.title = text;
- popup_params.type = "twobtn";
- _bt_launch_system_popup(BT_APP_EVENT_CONFIRM_MODE_REQUEST,
- &popup_params,
- _bt_app_obex_download_dup_file_cb,
- server_auth_info);
- if (fd != NULL) {
- fclose(fd);
- fd = NULL;
- }
- } else {
- bluetooth_obex_server_accept_authorize(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);
-static void __bt_obex_file_push_auth(bt_obex_server_authorize_into_t *server_auth_info)
+ return;
+}
+
+static void __bt_obex_file_push_auth(bt_obex_server_authorize_into_t
+ *server_auth_info)
{
- long available_mem_size = 0;
- DBG("+\n");
+ DBG("+");
- 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);
+ int val = -1;
+ gboolean ret = FALSE;
+ unsigned long long available_ext_mem_size = 0;
+ double available_int_mem_size = 0;
+
+ if (vconf_get_int(VCONFKEY_SETAPPL_DEFAULT_MEM_BLUETOOTH_INT,
+ (void *)&val)) {
+ ERR("vconf error");
goto reject;
- }
+ }
- 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);
+ 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;
+ }
+
+ __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;
-}
-
-static int __bt_vcard_handler(const char *vcard, void *data)
+static bool __bt_vcalendar_handler(calendar_record_h record, void *user_data)
{
int ret;
- ret = contacts_svc_insert_vcard(0, vcard);
- if (ret < CTS_SUCCESS) {
- ERR("CTS error : %d\n", ret);
+ ret = calendar_db_insert_record(record, NULL);
+ if (ret != CALENDAR_ERROR_NONE) {
+ ERR("calendar_db_insert_record error : %d", ret);
}
- return 0;
+ return true;
}
static gboolean __bt_save_v_object(char *file_path,
retv_if(NULL == file_path, FALSE);
int ret;
- DBG("file_path = %s, file_type = %d\n", file_path, file_type);
+ DBG_SECURE("file_path = %s, file_type = %d", file_path, file_type);
switch (file_type) {
case BT_FILE_VCARD:
{
- DBG("BT_OPP_FILE_VCARD received\n");
-
- ret = contacts_svc_connect();
- if (ret != CTS_SUCCESS) {
- ERR("[error] = %d \n", ret);
+ app_control_h service;
+ app_control_create(&service);
+ app_control_set_operation(service, "http://samsung.com/appcontrol/operation/vcard_import");
+ app_control_set_mime(service, "text/vcard");
+ if (app_control_add_extra_data(service, "account_popup", "false")
+ != APP_CONTROL_ERROR_NONE) {
+ ERR("app_control_add_extra_data failed");
+ app_control_destroy(service);
return FALSE;
}
-
- ret = contacts_svc_vcard_foreach(file_path, __bt_vcard_handler, NULL);
- if (ret != CTS_SUCCESS) {
- ERR("[error] = %d \n", ret);
- return FALSE;
- }
-
- ret = contacts_svc_disconnect();
- if (ret != CTS_SUCCESS) {
- ERR("[error] = %d \n", ret);
+ if (app_control_add_extra_data(service, "file_delete", "true")
+ != APP_CONTROL_ERROR_NONE) {
+ ERR("app_control_add_extra_data failed");
+ app_control_destroy(service);
return FALSE;
}
+ app_control_set_uri(service, file_path);
+ app_control_send_launch_request(service, NULL, NULL);
+ app_control_destroy(service);
}
break;
-
case BT_FILE_VCAL:
- {
- ret = calendar_svc_connect();
- if (ret != CAL_SUCCESS) {
- ERR("Failed to close Calendar service.\n");
- return FALSE;
- }
-
- ret = calendar_svc_calendar_import(file_path, DEFAULT_CALENDAR_ID);
- if (ret != CAL_SUCCESS) {
- ERR("Failed to import path(%s): error (%d)\n", file_path, ret);
- ret = calendar_svc_close();
- if ( ret != CAL_SUCCESS) {
- ERR("Failed to close Calendar service.\n");
- }
+ ret = calendar_connect();
+ if (ret != CALENDAR_ERROR_NONE) {
+ ERR("calendar_connect error = %d", ret);
return FALSE;
- }
- ret = calendar_svc_close();
- if (ret != CAL_SUCCESS) {
- ERR("Failed to close Calendar service.\n");
- return FALSE;
- }
- }
- break;
+ }
- default:
+ ret = calendar_vcalendar_parse_to_calendar_foreach(file_path,
+ __bt_vcalendar_handler, NULL);
+ if (ret != CALENDAR_ERROR_NONE) {
+ ERR("[error] = %d \n", ret);
+ ret = calendar_disconnect();
+ if ( ret != CALENDAR_ERROR_NONE) {
+ ERR("calendar_disconnect error = %d", ret);
+ }
+ return FALSE;
+ }
+ ret = calendar_disconnect();
+ if (ret != CALENDAR_ERROR_NONE) {
+ ERR("calendar_disconnect error = %d \n", ret);
+ return FALSE;
+ }
break;
+ default:
+ return FALSE;
}
return TRUE;
}
-gboolean _bt_obex_writeclose(bt_obex_server_transfer_info_t *transfer_complete_info)
+void *_bt_obex_writeclose(bt_file_info_t *info)
{
- retv_if(transfer_complete_info->filename == NULL, FALSE);
-
- 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, };
-
- 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);
- switch (file_type) {
- case BT_FILE_VCARD:
- case BT_FILE_VCAL:
- case BT_FILE_VBOOKMARK:
- _bt_get_default_storage(storage);
- snprintf(file_path, sizeof(file_path), "%s/%s", storage,
- transfer_complete_info->filename);
- DBG("BT_OPP_FILE_VOBJECT : file_path = %s\n", file_path);
- if (__bt_save_v_object(file_path, file_type)) {
- ecore_file_remove(file_path);
- }
- break;
- default:
- 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 FALSE;
-}
+ __free_file_info(info);
+ return NULL;
+}
+++ /dev/null
-/usr/include/bluetooth-share/*
-/usr/lib/pkgconfig/*
+++ /dev/null
-@PREFIX@/bin/*
-/opt/share/bt-ftp
-/usr/share/dbus-1/services/*.service
\ No newline at end of file
+++ /dev/null
-#!/bin/sh
-
-if [ ! -f /opt/dbspace/.bluetooth_trasnfer.db ]
-then
- sqlite3 /opt/dbspace/.bluetooth_trasnfer.db 'PRAGMA journal_mode = PERSIST;
- create table if not exists inbound (
- id INTEGER PRIMARY KEY autoincrement,
- tr_status INTEGER,
- file_path TEXT,
- dev_name TEXT,
- timestamp INTEGER default 0,
- addr TEXT
- );
- create table if not exists outbound (
- id INTEGER PRIMARY KEY autoincrement,
- tr_status INTEGER,
- file_path TEXT,
- dev_name TEXT,
- timestamp INTEGER default 0,
- addr TEXT
- );
- '
-fi
-
-# root case
-if [ ${USER} == "root" ]
-then
- # Set vconf values with -g/-u options
-
- # 5000 is inhouse user id
- # do not use relative path
-
- # For the FTP server folder
-
- if [ ! -e /opt/share/bt-ftp/Media ]
- then
- ln -s /opt/media /opt/share/bt-ftp/Media
- fi
-
- if [ ! -e /opt/share/bt-ftp/SD_External ]
- then
- ln -s /opt/storage/sdcard /opt/share/bt-ftp/SD_External
- fi
-
- vconftool set -t bool memory/private/bluetooth-share/quickpanel_clear_btn_status FALSE -g 6520 -i
- vconftool set -t bool memory/private/bluetooth-share/opp_server_init FALSE -g 6520 -i
-
- chown :5000 /opt/dbspace/.bluetooth_trasnfer.db
- chown :5000 /opt/dbspace/.bluetooth_trasnfer.db-journal
-fi
-
-chmod 660 /opt/dbspace/.bluetooth_trasnfer.db
-chmod 660 /opt/dbspace/.bluetooth_trasnfer.db-journal
+++ /dev/null
-bluetooth-share (0.0.26) unstable; urgency=low
-
- * Upload the package
- * Git: slp/pkgs/b/bluetooth-share
- * Tag: bluetooth-share_0.0.26
-
- -- DoHyun Pyun <dh79.pyun@samsung.com> Tue, 11 Sep 2012 11:05:27 +0900
-
-bluetooth-share (0.0.25) unstable; urgency=low
-
- * Upload the package
- * Git: slp/pkgs/b/bluetooth-share
- * Tag: bluetooth-share_0.0.25
-
- -- InJun Yang <injun.yang@samsung.com> Tue, 07 Aug 2012 12:38:33 +0900
-
-bluetooth-share (0.0.24) unstable; urgency=low
-
- * Fix the PLM issue abt clear button of notification bar
- * Git: slp/pkgs/b/bluetooth-share
- * Tag: bluetooth-share_0.0.24
-
- -- InJun Yang <injun.yang@samsung.com> Fri, 20 Jul 2012 18:44:33 +0900
-
-bluetooth-share (0.0.23) unstable; urgency=low
-
- * Tagging and upload the package
- * Git: slp/pkgs/b/bluetooth-share
- * Tag: bluetooth-share_0.0.23
-
- -- DoHyun Pyun <dh79.pyun@samsung.com> Fri, 20 Jul 2012 13:36:44 +0900
-
-bluetooth-share (0.0.22) unstable; urgency=low
-
- * Upload the package
- * Git: slp/pkgs/b/bluetooth-share
- * Tag: bluetooth-share_0.0.22
-
- -- DoHyun Pyun <dh79.pyun@samsung.com> Tue, 17 Jul 2012 10:27:35 +0900
-
-bluetooth-share (0.0.21) unstable; urgency=low
-
- * Upload the package
- * Git: slp/pkgs/b/bluetooth-share
- * Tag: bluetooth-share_0.0.21
-
- -- InJun Yang <injun.yang@samsung.com> Tue, 10 Jul 2012 19:26:52 +0900
-
-bluetooth-share (0.0.20) unstable; urgency=low
-
- * Upload the package
- * Git: slp/pkgs/b/bluetooth-share
- * Tag: bluetooth-share_0.0.20
-
- -- DoHyun Pyun <dh79.pyun@samsung.com> Tue, 10 Jul 2012 17:55:02 +0900
-
-bluetooth-share (0.0.19) unstable; urgency=low
-
- * Ordered by timestamp
- * Git: slp/pkgs/b/bluetooth-share
- * Tag: bluetooth-share_0.0.19
-
- -- InJun Yang <injun.yang@samsung.com> Tue, 10 Jul 2012 08:57:19 +0900
-
-bluetooth-share (0.0.18) unstable; urgency=low
-
- * Upload the package
- * Git: slp/pkgs/b/bluetooth-share
- * Tag: bluetooth-share_0.0.18
-
- -- InJun Yang <injun.yang@samsung.com> Fri, 06 Jul 2012 20:09:04 +0900
-
-bluetooth-share (0.0.17) unstable; urgency=low
-
- * Upload the package
- * Git: slp/pkgs/b/bluetooth-share
- * Tag: bluetooth-share_0.0.17
-
- -- InJun Yang <injun.yang@samsung.com> Wed, 20 Jun 2012 20:45:27 +0900
-
-bluetooth-share (0.0.16) unstable; urgency=low
-
- * Upload the package
- * Git: slp/pkgs/b/bluetooth-share
- * Tag: bluetooth-share_0.0.16
-
- -- InJun Yang <injun.yang@samsung.com> Fri, 15 Jun 2012 18:45:52 +0900
-
-bluetooth-share (0.0.15) unstable; urgency=low
-
- * Modify the sending flow as UX guideline
- * Git: slp/pkgs/b/bluetooth-share
- * Tag: bluetooth-share_0.0.15
-
- -- DoHyun Pyun <dh79.pyun@samsung.com> Mon, 04 Jun 2012 08:59:20 +0900
-
-bluetooth-share (0.0.14) unstable; urgency=low
-
- * Upload the package
- * Git: slp/pkgs/b/bluetooth-share
- * Tag: bluetooth-share_0.0.14
-
- -- InJun Yang <injun.yang@samsung.com> Tue, 29 May 2012 17:47:33 +0900
-
-bluetooth-share (0.0.13) unstable; urgency=low
-
- * Add db script to postinst file
- * Git: slp/pkgs/b/bluetooth-share
- * Tag: bluetooth-share_0.0.13
-
- -- InJun Yang <injun.yang@samsung.com> Thu, 24 May 2012 13:05:43 +0900
-
-bluetooth-share (0.0.12) unstable; urgency=low
-
- * Upload the package
- * Git: slp/pkgs/b/bluetooth-share
- * Tag: bluetooth-share_0.0.12
-
- -- DoHyun Pyun <dh79.pyun@samsung.com> Wed, 23 May 2012 12:16:47 +0900
-
-bluetooth-share (0.0.11) unstable; urgency=low
-
- * Upload the package
- * Git: slp/pkgs/b/bluetooth-share
- * Tag: bluetooth-share_0.0.11
-
- -- DoHyun Pyun <dh79.pyun@samsung.com> Tue, 22 May 2012 09:45:06 +0900
-
-bluetooth-share (0.0.10) unstable; urgency=low
-
- * Upload the package
- * Git: slp/pkgs/b/bluetooth-share
- * Tag: bluetooth-share_0.0.10
-
- -- DoHyun Pyun <dh79.pyun@samsung.com> Mon, 21 May 2012 11:06:30 +0900
-
-bluetooth-share (0.0.9) unstable; urgency=low
-
- * Fix the auto activating issue
- * Git: slp/pkgs/b/bluetooth-share
- * Tag: bluetooth-share_0.0.9
-
- -- DoHyun Pyun <dh79.pyun@samsung.com> Wed, 16 May 2012 11:36:34 +0900
-
-bluetooth-share (0.0.8) unstable; urgency=low
-
- * Upload the package
- * Git: slp/pkgs/b/bluetooth-share
- * Tag: bluetooth-share_0.0.8
-
- -- DoHyun Pyun <dh79.pyun@samsung.com> Tue, 08 May 2012 08:56:03 +0900
-
-bluetooth-share (0.0.7) unstable; urgency=low
-
- * Upload the package
- * Git: slp/pkgs/b/bluetooth-share
- * Tag: bluetooth-share_0.0.7
-
- -- InJun Yang <injun.yang@samsung.com> Thu, 22 Mar 2012 16:48:32 +0900
-
-bluetooth-share (0.0.6) unstable; urgency=low
-
- * Increase the version number to upload.
- * Git: slp/pkgs/b/bluetooth-share
- * Tag: bluetooth-share_0.0.6
-
- -- Sunil Kumar Behera <sunil.behera@samsung.com> Tue, 21 Feb 2012 14:09:43 +0530
-
-bluetooth-share (0.0.5) unstable; urgency=low
-
- * FIx the spelling of API name (sessioin -> session)
- * Git: slp/pkgs/b/bluetooth-share
- * Tag: bluetooth-share_0.0.5
-
- -- DoHyun Pyun <dh79.pyun@samsung.com> Thu, 05 Jan 2012 17:55:10 +0900
-
-bluetooth-share (0.0.4) unstable; urgency=low
-
- * Upload package
- * Git: slp/pkgs/b/bluetooth-share
- * Tag: bluetooth-share_0.0.4
-
- -- DoHyun Pyun <dh79.pyun@samsung.com> Fri, 30 Dec 2011 08:01:56 +0900
-
-bluetooth-share (0.0.3) unstable; urgency=low
-
- * Upload package
- * Git: 165.213.180.234:slp/pkgs/b/bluetooth-share
- * Tag: bluetooth-share_0.0.3
-
- -- InJun Yang <injun.yang@samsung.com> Wed, 30 Nov 2011 10:24:29 +0900
-
-bluetooth-share (0.0.2) unstable; urgency=low
-
- * Upload package
- * Git: 165.213.180.234:slp/pkgs/b/bluetooth-share
- * Tag: bluetooth-share_0.0.2
-
- -- InJun Yang <injun.yang@samsung.com> Wed, 09 Nov 2011 08:50:32 +0900
-
-bluetooth-share (0.0.1) unstable; urgency=low
-
- * initial release
- * Git: 165.213.180.234:slp/pkgs/b/bluetooth-share
- * Tag: bluetooth-share_0.0.1
-
- -- Injun Yang <injun.yang@samsung.com> Fri, 23 Sep 2011 16:17:49 +0900
+++ /dev/null
-Source: bluetooth-share
-Section: net
-Priority: extra
-Maintainer: Hocheol Seo <hocheol.seo@samsung.com>, DoHyun Pyun <dh79.pyun@samsung.com>, ChanYeol Park <chanyeol.park@samsung.com>, InJun Yang <injun.yang@samsung.com>, Seungyoun Ju <sy39.ju@samsung.com>
-Uploaders: Sunil Behera <sunil.behera@samsung.com>, Syam Sidhardhan <s.syam@samsung.com>
-Build-Depends: debhelper (>= 5), libbluetooth-frwk-dev, libglib2.0-dev, libdbus-1-dev, libdbus-glib-1-dev, libappcore-common-dev, libaul-1-dev, dlog-dev, syspopup-caller-dev, libappsvc-dev, libbundle-dev, libnotification-dev, libslp-calendar-dev, libcontacts-service-dev, libslp-pm-dev, libslp-sysman-dev, libx11-dev, libappcore-efl-dev, libslp-db-util-dev, libprivilege-control-dev
-Standards-Version: 3.7.2
-
-Package: bluetooth-share
-Section: application
-Provides:bluetooth-app-headers
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends},libbluetooth-frwk-0, libaul-1, libdlog-0
-Description: Bluetooth File Share Agent
-
-Package: bluetooth-share-dbg
-Section: debug
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}, bluetooth-share (= ${Source-Version})
-Description: Bluetooth file share Agent (unstripped)
-
-Package: libbluetooth-share
-Section: libs
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends}
-Description: Bluetooth Share library
-
-Package: libbluetooth-share-dev
-Section: devel
-Architecture: any
-Depends: ${shlibs:Depends}, ${misc:Depends},dlog-dev, libdbus-glib-1-dev, libglib2.0-dev, libbluetooth-share (= ${Source-Version})
-XB-Generate-Docs: yes
-Description: Bluetooth Share
+++ /dev/null
-/usr/include/*
-/usr/lib/pkgconfig/*
+++ /dev/null
-/usr/lib/lib*
+++ /dev/null
-#!/usr/bin/make -f
-
-# Uncomment this to turn on verbose mode.
-#export DH_VERBOSE=1
-
-PREFIX ?= /usr
-#RESDIR ?= /usr/bin/bluetooth-share/res
-#DATADIR ?= /usr/bin/bluetooth-share/data
-CFLAGS ?= -Wall -g
-LDFLAGS ?=
-
-ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
- CFLAGS += -O0
-else
- CFLAGS += -O2
-endif
-
-CFLAGS += -fpie
-LDFLAGS += -pie -Wl,--rpath=$(PREFIX)/lib -Wl,--as-needed -Wl,--unresolved-symbols=ignore-in-shared-libs
-
-configure: configure-stamp
-configure-stamp:
- dh_testdir
- # Add here commands to configure the package.
- CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \
- cmake . -DCMAKE_INSTALL_PREFIX=$(PREFIX)
- touch configure-stamp
-
-
-build: build-stamp
-
-build-stamp: configure-stamp
- dh_testdir
-
- # Add here commands to compile the package.
- $(MAKE)
- #docbook-to-man debian/bluetooth.sgml > bluetooth.1
- for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
- cat $$f > $${f%.in}; \
- sed -i -e "s#@PREFIX@#$(PREFIX)#g" $${f%.in}; \
- done
-
- touch $@
-
-clean:
- dh_testdir
- dh_testroot
- rm -f build-stamp configure-stamp
-
- # Add here commands to clean up after the build process.
- -$(MAKE) clean
-
- for f in `find $(CURDIR)/ -name "CMakeCache.txt"`; do \
- rm -f $${f}; \
- done
- for f in `find $(CURDIR)/ -name "CMakeFiles"`; do \
- rm -rf $${f}; \
- done
- for f in `find $(CURDIR)/ -name "cmake_install.cmake"`; do \
- rm -f $${f}; \
- done
- for f in `find $(CURDIR)/ -name "Makefile"`; do \
- rm -f $${f}; \
- done
- for f in `find $(CURDIR)/ -name "install_manifest.txt"`; do \
- rm -f $${f}; \
- done
- for f in `find $(CURDIR)/ -name "*.edj"`; do \
- rm -f $${f}; \
- done
- for f in `find $(CURDIR)/debian/ -name "*.in"`; do \
- rm -f $${f%.in}; \
- done
-
- dh_clean
-
-install: build
- dh_testdir
- dh_testroot
- dh_clean -k
- dh_installdirs
-
- # Add here commands to install the package into debian/tmp.
- $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install
- mkdir -p $(CURDIR)/debian/tmp/opt/share/bt-ftp
-
-# Build architecture-independent files here.
-binary-indep: build install
-# We have nothing to do by default.
-
-# Build architecture-dependent files here.
-binary-arch: build install
- dh_testdir
- dh_testroot
-# dh_installchangelogs
-# dh_installdocs
-# dh_installexamples
- dh_install --sourcedir=debian/tmp
-# dh_installman
- dh_link
- dh_strip --dbg-package=bluetooth-share-dbg
- dh_compress
- dh_fixperms
-# dh_perl
- dh_makeshlibs
- dh_installdeb
- dh_shlibdeps
- dh_gencontrol
- dh_md5sums
- dh_builddeb
-
-binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install configure
/*
- * bluetooth-share-api
+ * bluetooth-share-db
*
* Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved
*
*
*/
-#if defined(SLP_SYSLOG_OUT) || defined(SLP_DAEMON)
-#include <syslog.h>
-#endif
#include <stdio.h>
#include <dlog.h>
-#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)
-
-#define PRT_INFO(fmt, arg...) \
- LOG(LOG_DEBUG, BT_SHARE, "%s:%d "fmt, __func__, __LINE__, ##arg)
+#undef LOG_TAG
+#define LOG_TAG "BLUETOOTH_SHARE_DB"
-#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); \
} \
} while (0)
-#endif
-
#ifdef __cplusplus
}
#endif
#endif /* __APPLOG_H__ */
+
typedef struct {
unsigned int id;
+ unsigned int sid;
unsigned int tr_status;
+ int timestamp;
char *file_path;
char *dev_name;
- int timestamp;
char *addr;
+ char *type;
+ char *content;
+ unsigned int size;
}bt_tr_data_t;
BT_DB_INBOUND
} bt_tr_db_table_e;
+typedef enum {
+ BT_TRANSFER_PENDING = -1,
+ BT_TRANSFER_SUCCESS,
+ BT_TRANSFER_FAIL
+} bt_tr_status_e;
EXPORT_API sqlite3 *bt_share_open_db(void);
EXPORT_API GSList *bt_share_get_tr_data_list_by_status(sqlite3 *db, int db_table, int status);
+EXPORT_API unsigned int bt_share_get_last_session_id(sqlite3 *db, int db_table);
+
EXPORT_API int bt_share_release_tr_data_list(GSList *list);
EXPORT_API int bt_share_get_tr_data_count(sqlite3 *db, int db_table);
+EXPORT_API int bt_share_get_tr_result_count(sqlite3 *db, int db_table, int *success, int *fail);
+
EXPORT_API int bt_share_remove_tr_data_by_id(sqlite3 *db, int db_table, int id);
EXPORT_API int bt_share_remove_tr_data_by_status(sqlite3 *db, int db_table, int status);
Name: bluetooth-share-api
Description: SAMSUNG Linux platform Bluetooth share API
Version: @VERSION@
-Requires: dlog dbus-glib-1 vconf
+Requires: dlog dbus-glib-1 vconf db-util
Libs: -L${libdir} -lbluetooth-share-api
Cflags: -I${includedir} -I${includedir}/bluetooth-share-api
static int __bt_exec_query(sqlite3 *db, char *query)
{
int ret;
- char *errmsg = NULL;
+ sqlite3_stmt *stmt = NULL;
retvm_if(db == NULL, BT_SHARE_ERR_INTERNAL, "DB handler is null");
retvm_if(query == NULL, BT_SHARE_ERR_INVALID_PARAM, "Invalid param");
- ret = sqlite3_exec(db, query, NULL, 0, &errmsg);
- if (ret != SQLITE_OK) {
- DBG("Query: [%s]", query);
- ERR("SQL error: %s\n", errmsg);
- sqlite3_free(errmsg);
+ ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
+ if (ret != SQLITE_OK)
+ return BT_SHARE_ERR_INTERNAL;
+
+ ret = sqlite3_step(stmt);
+ if (ret != SQLITE_DONE)
return BT_SHARE_ERR_INTERNAL;
- }
+
+ sqlite3_finalize(stmt);
return BT_SHARE_ERR_NONE;
}
{
DBG("+\n");
int ret = 0;
- char query[BT_DB_QUERY_LEN] = {0, };
+ char *query = NULL;
sqlite3_stmt *stmt = NULL;
retvm_if(db == NULL, BT_SHARE_ERR_INTERNAL, "DB handler is null");
retvm_if(data == NULL, BT_SHARE_ERR_INTERNAL, "Insert data is null");
- snprintf(query, BT_DB_QUERY_LEN,
- "INSERT INTO %s (id, tr_status, file_path, dev_name, timestamp, addr) VALUES(?, %d, '%s', '%s', '%d', '%s');",
- TABLE(db_table), data->tr_status, data->file_path,
- data->dev_name, data->timestamp, data->addr);
+ DBG("File: %s Type: %s, Size: %d",data->file_path, data->type, data->size);
+ query = sqlite3_mprintf("INSERT INTO %s (id, sid, tr_status, file_path, dev_name, timestamp, addr, type, content, size) VALUES(?, '%d', '%d', '%q', '%q', '%d', '%q', '%q', '%q', '%d');",
+ TABLE(db_table), data->sid, data->tr_status, data->file_path,
+ data->dev_name, data->timestamp, data->addr, data->type, data->file_path, data->size);
+ if (!query)
+ return BT_SHARE_ERR_INTERNAL;
+ DBG("query : %s", query);
ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
if (ret != SQLITE_OK)
goto error;
goto error;
sqlite3_finalize(stmt);
+ sqlite3_free(query);
DBG("-\n");
return BT_SHARE_ERR_NONE;
sqlite3_finalize(stmt);
}
+ sqlite3_free(query);
+
return BT_SHARE_ERR_INTERNAL;
}
if (ret == SQLITE_ROW) {
data = g_new0(bt_tr_data_t, 1);
data->id = INT(stmt, idx++);
+ data->sid = INT(stmt, idx++);
data->tr_status = INT(stmt, idx++);
data->file_path = g_strdup(TEXT(stmt, idx++));
data->dev_name = g_strdup(TEXT(stmt, idx++));
data->timestamp = INT(stmt, idx++);
data->addr = g_strdup(TEXT(stmt, idx++));
+ data->type = g_strdup(TEXT(stmt, idx++));
+ data->content = g_strdup(TEXT(stmt, idx++));
} else {
goto error;
}
- DBG("%d, %s, %s, %d, %s\n", data->tr_status, data->file_path,
- data->dev_name, data->timestamp, data->addr);
+ DBG_SECURE("%d, %d, %s, %s, %d, %s, %d\n", data->sid, data->tr_status, data->file_path,
+ data->dev_name, data->timestamp, data->addr, data->size);
sqlite3_finalize(stmt);
}
-static GSList *__bt_db_get_record_list(sqlite3 *db, const char*query)
+static GSList *__bt_db_get_record_list(sqlite3 *db, const char *query)
{
int ret;
sqlite3_stmt *stmt = NULL;
idx = 0;
bt_tr_data_t *data = g_new0(bt_tr_data_t, 1);
data->id = INT(stmt, idx++);
+ data->sid = INT(stmt, idx++);
data->tr_status = INT(stmt, idx++);
data->file_path = g_strdup(TEXT(stmt, idx++));
data->dev_name = g_strdup(TEXT(stmt, idx++));
data->timestamp = INT(stmt, idx++);
data->addr = g_strdup(TEXT(stmt, idx++));
+ data->type = g_strdup(TEXT(stmt, idx++));
+ data->content = g_strdup(TEXT(stmt, idx++));
+ data->size = INT(stmt, idx++);
slist = g_slist_append(slist, data);
return slist;
}
+static unsigned int __bt_db_get_last_session_id(sqlite3 *db, int db_table)
+{
+ DBG("+\n");
+ int ret = 0;
+ unsigned int sid = 0;
+ char query[BT_DB_QUERY_LEN] = {0, };
+ sqlite3_stmt *stmt = NULL;
+
+ retvm_if(db == NULL, BT_SHARE_ERR_INTERNAL, "DB handler is null");
+
+ snprintf(query, BT_DB_QUERY_LEN,
+ "SELECT * FROM %s WHERE id=(SELECT MAX(id) FROM %s);",
+ TABLE(db_table), TABLE(db_table));
+
+ ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
+ if (ret != SQLITE_OK)
+ goto error;
+
+ ret = sqlite3_step(stmt);
+ if (ret == SQLITE_ROW) {
+ sid = INT(stmt, 2); /* to get the session id */
+ DBG("session_id : %u");
+ }
+ else
+ goto error;
+
+ sqlite3_finalize(stmt);
+
+ DBG("-\n");
+ return sid;
+error:
+ ERR("[ERROR] szQuery : %s", query);
+ ERR("[ERROR] SQL error msg : %s", (char *)sqlite3_errmsg(db));
+ if (stmt) {
+ sqlite3_finalize(stmt);
+ }
+
+ return 0;
+}
+
static void __bt_release_memory(bt_tr_data_t *data)
{
g_free(data->file_path);
g_free(data->dev_name);
g_free(data->addr);
+ g_free(data->type);
+ g_free(data->content);
g_free(data);
}
return BT_SHARE_ERR_NONE;
}
-static int __bt_db_get_record_count(sqlite3 *db, int db_table)
+static int __bt_db_get_record_count(sqlite3 *db, const char *query)
{
- char query[BT_DB_QUERY_LEN] = {0, };
sqlite3_stmt *stmt;
int idx;
int count = 0;
int ret = 0;
- snprintf(query, sizeof(query), "SELECT COUNT(id) FROM %s;", TABLE(db_table));
+ DBG("query : %s", query);
ret = sqlite3_prepare(db, query, -1, &stmt, NULL);
if (ret != SQLITE_OK || stmt == NULL) {
retvm_if(db == NULL, BT_SHARE_ERR_INTERNAL, "DB handler is null");
+ DBG("query : %s", query);
+
ret = sqlite3_prepare_v2(db, query, strlen(query), &stmt, NULL);
if (ret != SQLITE_OK) {
ERR("sqlite3_prepare_v2(%s) Failed(%s)", query, sqlite3_errmsg(db));
return __bt_db_get_record_list(db, query);
}
+EXPORT_API unsigned int bt_share_get_last_session_id(sqlite3 *db, int db_table)
+{
+ retvm_if(db == NULL, BT_SHARE_ERR_INTERNAL, "DB handle is NULL");
+
+ return __bt_db_get_last_session_id(db, db_table);
+}
+
EXPORT_API int bt_share_release_tr_data_list(GSList *list)
{
retvm_if(list == NULL, BT_SHARE_ERR_INVALID_PARAM, "Invalid param");
{
retvm_if(db == NULL, BT_SHARE_ERR_INTERNAL, "DB handle is NULL");
- return __bt_db_get_record_count(db, db_table);
+ char query[BT_DB_QUERY_LEN] = {0, };
+ snprintf(query, sizeof(query), "SELECT COUNT(id) FROM %s;", TABLE(db_table));
+
+ return __bt_db_get_record_count(db, query);
+}
+
+EXPORT_API int bt_share_get_tr_result_count(sqlite3 *db, int db_table, int *success, int *fail)
+{
+ retvm_if(db == NULL, BT_SHARE_ERR_INTERNAL, "DB handle is NULL");
+ retvm_if(!success || !fail, BT_SHARE_ERR_INVALID_PARAM, "Invalid parameter");
+
+ char query[BT_DB_QUERY_LEN] = {0, };
+
+ snprintf(query, sizeof(query), "SELECT COUNT(tr_status) FROM %s WHERE tr_status=%d;",
+ TABLE(db_table), BT_TRANSFER_SUCCESS);
+ *success = __bt_db_get_record_count(db, query);
+
+ snprintf(query, sizeof(query), "SELECT COUNT(tr_status) FROM %s WHERE tr_status=%d;",
+ TABLE(db_table), BT_TRANSFER_FAIL);
+ *fail = __bt_db_get_record_count(db, query);
+
+ return BT_SHARE_ERR_NONE;
}
EXPORT_API int bt_share_remove_tr_data_by_id(sqlite3 *db, int db_table, int id)
extern "C" {
#endif
-#define BT_TRANSFER_DB "/opt/dbspace/.bluetooth_trasnfer.db"
+#define BT_TRANSFER_DB "/opt/usr/dbspace/.bluetooth_trasnfer.db"
#define BT_INBOUND_TABLE "inbound"
#define BT_OUTBOUND_TABLE "outbound"
#define BT_DB_QUERY_LEN 512
Name: bluetooth-share
Summary: Bluetooth file share Agent
-Version: 0.0.26
+Version: 0.0.99
Release: 1
-Group: TO_BE/FILLED_IN
-License: TO BE FILLED IN
+Group: Application
+License: Apache-2.0
Source0: %{name}-%{version}.tar.gz
+Requires(post): vconf
+Requires(post): coreutils
+Requires(post): sqlite
+Requires(post): smack-utils
+Requires(post): sys-assert
+
+%if "%{?tizen_profile_name}" == "wearable"
+ExcludeArch: %{arm} %ix86 x86_64
+%endif
+
BuildRequires: cmake
BuildRequires: gettext-tools
BuildRequires: pkgconfig(appcore-efl)
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(aul)
BuildRequires: pkgconfig(dlog)
-BuildRequires: pkgconfig(calendar)
-BuildRequires: pkgconfig(contacts-service)
+BuildRequires: pkgconfig(calendar-service2)
+BuildRequires: pkgconfig(capi-appfw-application)
BuildRequires: pkgconfig(vconf)
BuildRequires: pkgconfig(syspopup-caller)
-BuildRequires: pkgconfig(pmapi)
-BuildRequires: pkgconfig(sysman)
+BuildRequires: pkgconfig(capi-system-device)
BuildRequires: pkgconfig(notification)
BuildRequires: pkgconfig(appsvc)
BuildRequires: pkgconfig(db-util)
BuildRequires: pkgconfig(libprivilege-control)
+BuildRequires: pkgconfig(capi-content-media-content)
+BuildRequires: pkgconfig(storage)
%description
Bluetooth File Share Agent
%setup -q
%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/lib -Wl,--as-needed -Wl,--unresolved-symbols=ignore-in-shared-libs -pie"
+
cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix}
make
rm -rf %{buildroot}
%make_install
mkdir -p %{buildroot}%{_optdir}/share/bt-ftp
+mkdir -p %{buildroot}/opt/usr/media/Downloads/.bluetooth
+
+install -D -m 0644 LICENSE %{buildroot}%{_datadir}/license/bluetooth-share
+install -D -m 0644 LICENSE %{buildroot}%{_datadir}/license/libbluetooth-share
+install -D -m 0644 LICENSE %{buildroot}%{_datadir}/license/libbluetooth-share-dev
%post
# For the FTP server folder
+if [ ! -e /opt/share/bt-ftp ]
+then
+ mkdir -p /opt/share/bt-ftp
+fi
+
if [ ! -e /opt/share/bt-ftp/Media ]
then
- ln -s /opt/media /opt/share/bt-ftp/Media
+ ln -s /opt/usr/media /opt/share/bt-ftp/Media
fi
if [ ! -e /opt/share/bt-ftp/SD_External ]
ln -s /opt/storage/sdcard /opt/share/bt-ftp/SD_External
fi
-vconftool set -t bool memory/private/bluetooth-share/quickpanel_clear_btn_status FALSE -g 6520 -i
-vconftool set -t bool memory/private/bluetooth-share/opp_server_init FALSE -g 6520 -i
+if [ ! -e /opt/usr/media/.bluetooth ]
+then
+ mkdir -p /opt/usr/media/Downloads/.bluetooth
+ chown 5000:5000 /opt/usr/media/Downloads/.bluetooth
+fi
-if [ ! -f /opt/dbspace/.bluetooth_trasnfer.db ]
+if [ ! -f /opt/usr/dbspace/.bluetooth_trasnfer.db ]
then
- sqlite3 /opt/dbspace/.bluetooth_trasnfer.db 'PRAGMA journal_mode = PERSIST;
- create table if not exists inbound (
+ sqlite3 /opt/usr/dbspace/.bluetooth_trasnfer.db 'PRAGMA journal_mode = PERSIST;
+ create table if not exists inbound (
id INTEGER PRIMARY KEY autoincrement,
+ sid INTEGER,
tr_status INTEGER,
file_path TEXT,
dev_name TEXT,
timestamp INTEGER default 0,
- addr TEXT
+ addr TEXT,
+ type TEXT,
+ content TEXT,
+ size INTEGER
);
create table if not exists outbound (
id INTEGER PRIMARY KEY autoincrement,
+ sid INTEGER,
tr_status INTEGER,
file_path TEXT,
dev_name TEXT,
timestamp INTEGER default 0,
- addr TEXT
+ addr TEXT,
+ type TEXT,
+ content TEXT,
+ size INTEGER
);
'
fi
-chown :5000 /opt/dbspace/.bluetooth_trasnfer.db
-chown :5000 /opt/dbspace/.bluetooth_trasnfer.db-journal
-chmod 660 /opt/dbspace/.bluetooth_trasnfer.db
-chmod 660 /opt/dbspace/.bluetooth_trasnfer.db-journal
+chown :5000 /opt/usr/dbspace/.bluetooth_trasnfer.db
+chown :5000 /opt/usr/dbspace/.bluetooth_trasnfer.db-journal
+chmod 660 /opt/usr/dbspace/.bluetooth_trasnfer.db
+chmod 660 /opt/usr/dbspace/.bluetooth_trasnfer.db-journal
+if [ -f /usr/lib/rpm-plugins/msm.so ]
+then
+chsmack -a 'bt_share::db' /opt/usr/dbspace/.bluetooth_trasnfer.db
+chsmack -a 'bt_share::db' /opt/usr/dbspace/.bluetooth_trasnfer.db-journal
+fi
%files
+%manifest bluetooth-share.manifest
+/etc/smack/accesses.d/bluetooth-share.efl
%defattr(-,root,root,-)
%{_bindir}/bluetooth-share
%{_datadir}/dbus-1/services/org.bluetooth.share.service
+%{_optdir}/share/bt-ftp
+%{_datadir}/license/bluetooth-share
+%{_optdir}/usr/media/Downloads/.bluetooth
%files -n libbluetooth-share
%defattr(-, root, root)
%{_libdir}/libbluetooth-share-api.so.0.*
+%{_datadir}/license/libbluetooth-share
%files -n libbluetooth-share-devel
%defattr(-, root, root)
/usr/include/bluetooth-share-api/bluetooth-share-api.h
%{_libdir}/libbluetooth-share-api.so
%{_libdir}/pkgconfig/bluetooth-share-api.pc
+%{_datadir}/license/libbluetooth-share-dev