MCPcopy Create free account
hub / github.com/amule-project/amule / SendFileRequest

Method SendFileRequest

src/DownloadClient.cpp:216–334  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

214
215
216void CUpDownClient::SendFileRequest()
217{
218 wxCHECK_RET(m_reqfile, "Cannot request file when no reqfile is set");
219
220 CMemFile dataFileReq(16+16);
221 dataFileReq.WriteHash(m_reqfile->GetFileHash());
222
223 if (SupportMultiPacket()) {
224 DEBUG_ONLY( wxString sent_opcodes; )
225
226 if (SupportExtMultiPacket()) {
227 dataFileReq.WriteUInt64(m_reqfile->GetFileSize());
228 }
229
230 AddDebugLogLineN(logClient, "Sending file request to client");
231
232 dataFileReq.WriteUInt8(OP_REQUESTFILENAME);
233 DEBUG_ONLY( sent_opcodes += "|RFNM|"; )
234 // Extended information
235 if (GetExtendedRequestsVersion() > 0) {
236 m_reqfile->WritePartStatus(&dataFileReq);
237 }
238 if (GetExtendedRequestsVersion() > 1) {
239 m_reqfile->WriteCompleteSourcesCount(&dataFileReq);
240 }
241 if (m_reqfile->GetPartCount() > 1) {
242 DEBUG_ONLY( sent_opcodes += "|RFID|"; )
243 dataFileReq.WriteUInt8(OP_SETREQFILEID);
244 }
245 if (IsEmuleClient()) {
246 SetRemoteQueueFull( true );
247 SetRemoteQueueRank(0);
248 }
249 if (IsSourceRequestAllowed()) {
250 if (SupportsSourceExchange2()){
251 DEBUG_ONLY( sent_opcodes += "|RSRC2|"; )
252 dataFileReq.WriteUInt8(OP_REQUESTSOURCES2);
253 dataFileReq.WriteUInt8(SOURCEEXCHANGE2_VERSION);
254 const uint16 nOptions = 0; // 16 ... Reserved
255 dataFileReq.WriteUInt16(nOptions);
256 } else {
257 DEBUG_ONLY( sent_opcodes += "|RSRC|"; )
258 dataFileReq.WriteUInt8(OP_REQUESTSOURCES);
259 }
260 m_reqfile->SetLastAnsweredTimeTimeout();
261 SetLastAskedForSources();
262 }
263 if (IsSupportingAICH()) {
264 DEBUG_ONLY( sent_opcodes += "|AFHR|"; )
265 dataFileReq.WriteUInt8(OP_AICHFILEHASHREQ);
266 }
267 CPacket* packet = new CPacket(dataFileReq, OP_EMULEPROT, (SupportExtMultiPacket() ? OP_MULTIPACKET_EXT : OP_MULTIPACKET));
268 theStats::AddUpOverheadFileRequest(packet->GetPacketSize());
269 AddDebugLogLineN(logLocalClient, CFormat("Local Client: %s (%s) to %s")
270 % (SupportExtMultiPacket() ? "OP_MULTIPACKET_EXT" : "OP_MULTIPACKET") % sent_opcodes % GetFullIP());
271 SendPacket(packet, true);
272 } else {
273 //This is extended information

Callers

nothing calls this directly

Calls 11

CFormatClass · 0.85
WriteUInt8Method · 0.80
WritePartStatusMethod · 0.80
GetPartCountMethod · 0.80
WriteUInt16Method · 0.80
GetPacketSizeMethod · 0.80
Copy16ToDataBufferMethod · 0.80
WriteHashMethod · 0.45
GetHashMethod · 0.45

Tested by

no test coverage detected