/** * @brief This function is to get file object. * FTP Client Get File */ BT_BOOL btmtk_ftpc_get_file_obj(const U8 *local_path, const U8 *ucName, const U8 *ucNewName) { /*----------------------------------------------------------------*/ /* Local Variables */ /*----------------------------------------------------------------*/ //U32 i; goep_pull_req_struct *req; /*----------------------------------------------------------------*/ /* Code Body */ /*----------------------------------------------------------------*/ GOEP_TRACE((BT_FTP_TRC_CLASS, BT_FTPC_GET_FILE_OBJ, act_client_cntx_p->ftpc_state)); if (NULL == act_client_cntx_p) { //TODO fault error return FALSE; } if (NULL == local_path || FALSE == btmtk_goep_is_folder_exist((const U16 *) local_path)) { GOEP_Report("[ftpc] func:get_file_obj wrong foldpath parameter\n"); return FALSE; } if( NULL == ucName || 0 == ext_ucs2strlen( (const S8 *) ucName ) ){ GOEP_Report( "[ftpc] func:get_file_obj wrong filename parameter\n"); return FALSE; } // Init the statistics for received object length act_client_cntx_p->ftpc_total_len = 0; act_client_cntx_p->ftpc_reamin_len = 0; act_client_cntx_p->ftpc_data_len = 0; act_client_cntx_p->total_len_type = BT_FTPC_TOTAL_LEN_NO_FIRST_PKT; act_client_cntx_p->flag_abort_req_sent = FALSE; GOEP_Report("[FTPC] get_file_obj set default attribute = 0"); ext_ucs2ncpy((S8 *) act_client_cntx_p->push_local_path, (S8 *)local_path, sizeof(act_client_cntx_p->push_local_path)/2); if (NULL == ucNewName || 0 == ext_ucs2strlen((const S8 *) ucNewName)) { GOEP_Report("[FTPC] get_file_obj compose name"); bt_ftp_compose_path(local_path, ucName, (U8 *) act_client_cntx_p->ftpc_filepath, sizeof(act_client_cntx_p->ftpc_filepath)/2); } else { bt_ftp_compose_path(local_path, ucNewName, (U8 *) act_client_cntx_p->ftpc_filepath, sizeof(act_client_cntx_p->ftpc_filepath)/2); } GOEP_Report("[FTPC] get_file_obj set default attribute = 0"); ext_ucs2ncpy((S8 *) act_client_cntx_p->ftpc_obj_name, (S8 *) ucName, sizeof(act_client_cntx_p->ftpc_obj_name)); if (!ucName) { GOEP_Report("[ftpc][wrn] func:get_file_obj wrong param\n"); BT_FTP_ASSERT(0); return FALSE; } switch (act_client_cntx_p->ftpc_state) { case BT_FTPC_STATE_CONNECTED: BT_FTPC_STATE_TRANS(0, BT_FTPC_STATE_GETTING_OBJ); break; default: // Incorrect state, callback and return error GOEP_TRACE( (BT_FTP_TRC_CLASS, BT_FTPC_STATE_ERROR, act_client_cntx_p->ftpc_state)); return FALSE; } // send get obj req GOEP_Report("[FTPC] get_file_obj prepare msg"); req = (goep_pull_req_struct*) CONSTRUCT_LOCAL_PARAM(sizeof(goep_pull_req_struct),TD_CTRL); GOEP_MEMSET((U8 *)req, 0, sizeof(goep_pull_req_struct)); req->goep_conn_id = ftpc_cntx_p->goep_conn_id[0]; req->pkt_type = GOEP_FIRST_PKT; GOEP_MEMCPY(req->uuid, OBEX_FTP_UUID, 16); req->uuid_len = 16; ext_ucs2ncpy((S8 *) req->obj_name, (S8 *) act_client_cntx_p->ftpc_obj_name, sizeof(req->obj_name)/2 ); req->obj_name[sizeof(req->obj_name)-2] = req->obj_name[sizeof(req->obj_name)-1] = 0; bt_ftp_ucs2_htons((U8 *)req->obj_name, (U8 *)req->obj_name); bt_ftp_send_msg(MSG_ID_BT_FTPC_PULL_REQ, req,sizeof(goep_pull_req_struct)); return TRUE; }
/* * @param ucFilename ucs2 filename * @u4MaxLen bytes */ BT_BOOL btmtk_goep_get_private_filepath(U8 type, const U8 *ucFilename, U8 *ucOutFilepath, U32 u4MaxLen) { BT_BOOL l_bret = FALSE; #if defined(BTMTK_ON_WISESDK) //SDK U8 tempPath[512]; U8 l_u2RootPath[512]; btmtk_os_memset( l_u2RootPath, 0, sizeof(l_u2RootPath)); ext_chset_utf8_to_ucs2_string( l_u2RootPath, sizeof(l_u2RootPath)-2, g_bt_dir_buf); if( FALSE == btmtk_goep_is_folder_exist( (const U16*) l_u2RootPath) ) { GOEP_Report("[GOEP] btmtk_goep_get_private_filepath no root folder"); return FALSE; } /// <sdk root path>\\xxx\\@btmtk\\ folder ext_ucs2ncpy( (S8*)tempPath, l_u2RootPath, sizeof(tempPath)/2); ext_ucs2ncat( (S8*)tempPath, (const S8*)L"\\Component\\MBT\\HWAdapt\\MTK\\LIB\\@btmtk", sizeof(tempPath)/2); if( 0 != ext_ucs2strlen((const S8*)tempPath) && FALSE == btmtk_goep_is_folder_exist((const U16*)tempPath) ) { btmtk_goep_create_folder((const U16*)tempPath); } switch(type) { case 0: /// <sdk root path>\\xxx\\@btmtk\\ . ext_ucs2ncat( (S8*)tempPath, (const S8*)L"\\", sizeof(tempPath)/2); ext_ucs2ncat( (S8*)tempPath, ucFilename, sizeof(tempPath)/2); ext_ucs2ncpy((S8 *) ucOutFilepath, tempPath, u4MaxLen ); if( ext_ucs2strlen((const S8*)ucOutFilepath) == ext_ucs2strlen((const S8*)tempPath) ) { l_bret = TRUE; } break; case 1: /// <sdk root path>\\xxx\\@btmtk\\profile ext_ucs2ncpy( (S8*)tempPath, l_u2RootPath, sizeof(tempPath)/2); ext_ucs2ncat( (S8*)tempPath, (const S8*)L"\\Component\\MBT\\HWAdapt\\MTK\\LIB\\@btmtk\\profile", sizeof(tempPath)/2); if( FALSE == btmtk_goep_is_folder_exist((const U16*)tempPath) ) { btmtk_goep_create_folder((const U16*)tempPath); } ext_ucs2ncat( (S8*)tempPath, (const S8*)L"\\", sizeof(tempPath)/2); ext_ucs2ncat( (S8*)tempPath, ucFilename, sizeof(tempPath)/2); ext_ucs2ncpy((S8 *) ucOutFilepath, tempPath, u4MaxLen ); if( ext_ucs2strlen((const S8*)ucOutFilepath) == ext_ucs2strlen((const S8*)tempPath) ) { l_bret = TRUE; } break; case 2: /// <sdk root path>\\xxx\\@btmtk\\data ext_ucs2ncpy( (S8*)tempPath, l_u2RootPath, sizeof(tempPath)/2); ext_ucs2ncat( (S8*)tempPath, (const S8*)L"\\Component\\MBT\\HWAdapt\\MTK\\LIB\\@btmtk\\data", sizeof(tempPath)/2); if( FALSE == btmtk_goep_is_folder_exist((const U16*)tempPath) ) { btmtk_goep_create_folder((const U16*)tempPath); } ext_ucs2ncat( (S8*)tempPath, (const S8*)L"\\", sizeof(tempPath)/2); ext_ucs2ncat( (S8*)tempPath, ucFilename, sizeof(tempPath)/2); ext_ucs2ncpy((S8 *) ucOutFilepath, tempPath, u4MaxLen ); if( ext_ucs2strlen((const S8*)ucOutFilepath) == ext_ucs2strlen((const S8*)tempPath) ) { l_bret = TRUE; } break; default: GOEP_Report("[OBEX][Err] btmtk_goep_get_private_filepath fail param:%d"); break; } #else // Target U8 tempPath[512]; switch(type) { case 0: /// Z:\\@btmtk ext_ucs2ncpy( (S8 *) tempPath, (const S8*)L"Z:\\@btmtk", sizeof( tempPath ) ); break; case 1: /// C:\\@btmtk\\profiles ext_ucs2ncpy( (S8 *) tempPath, (const S8*)L"C:\\@btmtk\\profiles", sizeof( tempPath ) ); break; case 2: /// C:\\@btmtk\\data ext_ucs2ncpy( (S8 *) tempPath, (const S8*)L"C:\\@btmtk\\data", sizeof( tempPath ) ); break; default: break; } if( 0 != ext_ucs2strlen((const S8*)tempPath) ) { if (FALSE == btmtk_goep_is_folder_exist( (const U16*) tempPath) ) { btmtk_goep_create_folder((const U16*)tempPath); } ext_ucs2ncat( (S8*)tempPath, (const S8*)L"\\", sizeof(tempPath)/2); ext_ucs2ncat( (S8*)tempPath, (const S8*)ucFilename, sizeof(tempPath)/2); ext_ucs2ncpy( (S8 *)ucOutFilepath, (const S8*)tempPath, u4MaxLen); if( ext_ucs2strlen((const S8*)ucOutFilepath) == ext_ucs2strlen((const S8*)tempPath) ) { l_bret = TRUE; } } #endif return l_bret; }