#define BT_OBEX_MANAGER "org.bluez.obex.AgentManager1"
#define BT_OBEX_PATH "/org/bluez/obex"
+#define BT_OBEX_PATH_PREFIX "/opt/usr/media"
+#define BT_OBEX_DEFAULT_PATH "/opt/usr/home/owner/media"
+#define BT_OBEX_PATH_MAX_LENGTH 255
+
typedef struct {
char *filename;
return TRUE;
}
+const char *__bt_transfer_folder_path(const char *dest_path)
+{
+ const char *dst_path = (const char *)g_malloc0(BT_OBEX_PATH_MAX_LENGTH);
+ if (g_str_has_prefix(dest_path, BT_OBEX_PATH_PREFIX)) {
+ snprintf((const char *)dst_path, BT_OBEX_PATH_MAX_LENGTH, BT_OBEX_DEFAULT_PATH"%s", dest_path + strlen(BT_OBEX_PATH_PREFIX));
+ } else {
+ snprintf((const char *)dst_path, BT_OBEX_PATH_MAX_LENGTH, "%s", dest_path);
+ }
+
+ BT_INFO("obex transfed path : %s", dst_path);
+ return dst_path;
+}
+
int _bt_obex_server_allocate(char *sender, const char *dest_path, int app_pid, gboolean is_native)
{
BT_DBG("+");
- if (__bt_check_folder_path(dest_path) == FALSE)
+
+ const char *dst_path;
+ dst_path = __bt_transfer_folder_path(dest_path);
+
+ if (__bt_check_folder_path(dst_path) == FALSE) {
+ g_free(dst_path);
return BLUETOOTH_ERROR_INVALID_PARAM;
+ }
if (is_native == TRUE) {
- retv_if(agent_info.native_server,
- BLUETOOTH_ERROR_DEVICE_BUSY);
+ if (agent_info.native_server) {
+ BT_ERR("obex native server busy");
+ g_free(dst_path);
+ return BLUETOOTH_ERROR_DEVICE_BUSY;
+ }
/* Force to change the control to native */
agent_info.native_server = g_malloc0(sizeof(bt_server_info_t));
- agent_info.native_server->dest_path = g_strdup(dest_path);
+ agent_info.native_server->dest_path = g_strdup(dst_path);
agent_info.native_server->sender = g_strdup(sender);
agent_info.native_server->app_pid = app_pid;
agent_info.server_type = BT_NATIVE_SERVER;
_bt_unregister_osp_server_in_agent(BT_OBEX_SERVER, NULL);
} else {
- retv_if(agent_info.custom_server,
- BLUETOOTH_ERROR_DEVICE_BUSY);
+ if (agent_info.custom_server) {
+ BT_ERR("obex custom server busy");
+ g_free(dst_path);
+ return BLUETOOTH_ERROR_DEVICE_BUSY;
+ }
/* Force to change the control to custom */
agent_info.custom_server = g_malloc0(sizeof(bt_server_info_t));
- agent_info.custom_server->dest_path = g_strdup(dest_path);
+ agent_info.custom_server->dest_path = g_strdup(dst_path);
agent_info.custom_server->sender = g_strdup(sender);
agent_info.custom_server->app_pid = app_pid;
agent_info.server_type = BT_CUSTOM_SERVER;
_bt_register_osp_server_in_agent(BT_OBEX_SERVER, NULL, NULL, -1);
}
+
+ g_free(dst_path);
BT_DBG("-");
return BLUETOOTH_ERROR_NONE;
}
gboolean is_native)
{
bt_server_info_t *server_info;
-
BT_CHECK_PARAMETER(dest_path, return);
+ const char *dst_path;
+ dst_path = __bt_transfer_folder_path(dest_path);
+
DIR *dp = NULL;
- dp = opendir(dest_path);
+ dp = opendir(dst_path);
if (dp == NULL) {
BT_ERR("The directory does not exist");
+ g_free(dst_path);
return BLUETOOTH_ERROR_INVALID_PARAM;
}
BLUETOOTH_ERROR_AGENT_DOES_NOT_EXIST);
g_free(server_info->dest_path);
- server_info->dest_path = g_strdup(dest_path);
+ server_info->dest_path = g_strdup(dst_path);
+ g_free(dst_path);
return BLUETOOTH_ERROR_NONE;
}
BT_CHECK_PARAMETER(root, return);
- retv_if(agent_info.proxy == NULL,
- BLUETOOTH_ERROR_INTERNAL);
+ const char *dst_root;
+ dst_root = __bt_transfer_folder_path(root);
+
+ if (!agent_info.proxy) {
+ BT_ERR("obex agent_info proxy error");
+ g_free(dst_root);
+ return BLUETOOTH_ERROR_INTERNAL;
+ }
- dp = opendir(root);
+ dp = opendir(dst_root);
if (dp == NULL) {
BT_ERR("The directory does not exist");
+ g_free(dst_root);
return BLUETOOTH_ERROR_INVALID_PARAM;
}
closedir(dp);
- folder = g_variant_new_string(root);
+ folder = g_variant_new_string(dst_root);
result = g_dbus_proxy_call_sync(agent_info.proxy, "SetProperty",
g_variant_new("(sv)", string, folder),
G_DBUS_CALL_FLAGS_NONE,
if (g_error) {
BT_ERR("SetProperty Fail: %s", g_error->message);
g_error_free(g_error);
+ g_free(dst_root);
return BLUETOOTH_ERROR_INTERNAL;
}
if (result)
g_variant_unref(result);
+ g_free(dst_root);
return BLUETOOTH_ERROR_NONE;
}