void FileTransferModule_Impl::_hasOfflineRes(IN std::string& body) { IM::File::IMFileHasOfflineRsp imFileHasOfflineRsp; if (!imFileHasOfflineRsp.ParseFromString(body)) { LOG__(ERR, _T("parse failed,body:%s"), util::stringToCString(body)); return; } UINT32 nFileNum = imFileHasOfflineRsp.offline_file_list_size(); for (UINT32 i = nFileNum; i > 0; --i) { const IM::BaseDefine::OfflineFileInfo& offLineInfo = imFileHasOfflineRsp.offline_file_list(i - 1); TransferFileEntity fileInfo; fileInfo.sFromID = util::uint32ToString(offLineInfo.from_user_id()); fileInfo.sToID = module::getSysConfigModule()->userID(); fileInfo.nFileSize = offLineInfo.file_size(); fileInfo.sTaskID = offLineInfo.task_id(); fileInfo.sFileName = offLineInfo.file_name(); fileInfo.nClientMode = IM::BaseDefine::ClientFileRole::CLIENT_OFFLINE_DOWNLOAD; const IM::BaseDefine::IpAddr& ipAdd = offLineInfo.ip_addr_list(0); fileInfo.sIP = ipAdd.ip(); fileInfo.nPort = ipAdd.port(); fileInfo.time = static_cast<UInt32>(time(0)); if (TransferFileEntityManager::getInstance()->pushTransferFileEntity(fileInfo)) { LOG__(APP, _T("离线文件 sFileID = %s"), util::stringToCString(fileInfo.sTaskID)); TransferFileEntityManager::getInstance()->openFileSocketByTaskId(fileInfo.sTaskID); } } }
void hasOfflineFile(CImPdu* pPdu, uint32_t conn_uuid) { IM::File::IMFileHasOfflineReq msg; IM::File::IMFileHasOfflineRsp msgResp; if(msg.ParseFromArray(pPdu->GetBodyData(), pPdu->GetBodyLength())) { CImPdu* pPduRes = new CImPdu; uint32_t nUserId = msg.user_id(); CFileModel* pModel = CFileModel::getInstance(); list<IM::BaseDefine::OfflineFileInfo> lsOffline; pModel->getOfflineFile(nUserId, lsOffline); msgResp.set_user_id(nUserId); for (list<IM::BaseDefine::OfflineFileInfo>::iterator it=lsOffline.begin(); it != lsOffline.end(); ++it) { IM::BaseDefine::OfflineFileInfo* pInfo = msgResp.add_offline_file_list(); // *pInfo = *it; pInfo->set_from_user_id(it->from_user_id()); pInfo->set_task_id(it->task_id()); pInfo->set_file_name(it->file_name()); pInfo->set_file_size(it->file_size()); } log("userId=%u, count=%u", nUserId, msgResp.offline_file_list_size()); msgResp.set_attach_data(msg.attach_data()); pPduRes->SetPBMsg(&msgResp); pPduRes->SetSeqNum(pPdu->GetSeqNum()); pPduRes->SetServiceId(IM::BaseDefine::SID_FILE); pPduRes->SetCommandId(IM::BaseDefine::CID_FILE_HAS_OFFLINE_RES); CProxyConn::AddResponsePdu(conn_uuid, pPduRes); } else { log("parse pb failed"); } }