BOOL CHostBrowser::OnRead() { //CQuickLock oTransfersLock( Transfers.m_pSection ); // ED2K connections aren't handled here- they are in ED2KClient if ( m_nProtocol == PROTOCOL_ED2K || m_nProtocol == PROTOCOL_DC ) return TRUE; if ( ! IsInputExist() || ! IsOutputExist() ) return TRUE; CTransfer::OnRead(); switch ( m_nState ) { case hbsRequesting: if ( ! ReadResponseLine() ) return FALSE; if ( m_nState != hbsHeaders ) break; case hbsHeaders: if ( ! ReadHeaders() ) return FALSE; if ( m_nState != hbsContent ) break; case hbsContent: return ReadContent(); } return TRUE; }
void CHostBrowser::OnDropped() { if ( m_nProtocol != PROTOCOL_ED2K && m_nProtocol != PROTOCOL_DC ) { if ( ! IsValid() ) return; if ( m_nState == hbsConnecting ) { theApp.Message( MSG_ERROR, IDS_BROWSE_CANT_CONNECT_TO, (LPCTSTR)m_sAddress ); if ( ! m_tPushed && SendPush( TRUE ) ) return; } else { if ( m_nLength == SIZE_UNKNOWN ) { m_nLength = GetInputLength(); ReadContent(); return; } theApp.Message( MSG_ERROR, IDS_BROWSE_DROPPED, (LPCTSTR)m_sAddress ); } } Stop(); }
ReturnCode ES::ExportContentData(Context& context, u32 content_fd, u8* data, u32 data_size) { if (!context.title_import_export.valid || !context.title_import_export.content.valid || !data || data_size == 0) { CloseContent(content_fd, 0); context.title_import_export = {}; return ES_EINVAL; } std::vector<u8> buffer(data_size); const s32 read_size = ReadContent(content_fd, buffer.data(), static_cast<u32>(buffer.size()), 0); if (read_size < 0) { CloseContent(content_fd, 0); ResetTitleImportContext(&context, m_ios.GetIOSC()); return ES_SHORT_READ; } // IOS aligns the buffer to 32 bytes. Since we also need to align it to 16 bytes, // let's just follow IOS here. buffer.resize(Common::AlignUp(buffer.size(), 32)); std::vector<u8> output(buffer.size()); const ReturnCode decrypt_ret = m_ios.GetIOSC().Encrypt( context.title_import_export.key_handle, context.title_import_export.content.iv.data(), buffer.data(), buffer.size(), output.data(), PID_ES); if (decrypt_ret != IPC_SUCCESS) return decrypt_ret; std::copy(output.cbegin(), output.cend(), data); return IPC_SUCCESS; }
MessageReturnedException ChannelImpl::CreateMessageReturnedException(amqp_basic_return_t& return_method, amqp_channel_t channel) { const int reply_code = return_method.reply_code; const std::string reply_text((char*)return_method.reply_text.bytes, return_method.reply_text.len); const std::string exchange((char*)return_method.exchange.bytes, return_method.exchange.len); const std::string routing_key((char*)return_method.routing_key.bytes, return_method.routing_key.len); BasicMessage::ptr_t content = ReadContent(channel); return MessageReturnedException(content, reply_code, reply_text, exchange, routing_key); }
bool GOrgueArchiveIndex::ReadIndex(wxString& id, std::vector<GOArchiveEntry>& entries) { wxString name = GenerateIndexFilename(); if (!wxFileExists(name)) return false; if (!m_File.Open(name, wxFile::read)) { wxLogError(_("Failed to open '%s'"), name.c_str()); return false; } int magic; GOrgueHashType hash1, hash2; hash1 = GenerateHash(); if (!Read(&magic, sizeof(magic)) || !Read(&hash2, sizeof(hash2))) { m_File.Close(); wxLogError(_("Failed to read '%s'"), name.c_str()); return false; } if (magic != GRANDORGUE_INDEX_MAGIC || memcmp(&hash1, &hash2, sizeof(hash1))) { m_File.Close(); wxLogError(_("Index '%s' has bad magic - bypassing index"), name.c_str()); return false; } if (!ReadContent(id, entries)) { m_File.Close(); wxLogError(_("Failed to read '%s'"), name.c_str()); return false; } m_File.Close(); return true; }
void CHostBrowser::OnDropped(BOOL bError) { if ( m_hSocket == INVALID_SOCKET ) return; if ( m_nState == hbsConnecting ) { theApp.Message( MSG_ERROR, IDS_BROWSE_CANT_CONNECT_TO, (LPCTSTR)m_sAddress ); if ( ! m_tPushed && SendPush( TRUE ) ) return; } else { if ( m_nLength == 0xFFFFFFFF ) { m_nLength = m_pInput->m_nLength; ReadContent(); return; } theApp.Message( MSG_ERROR, IDS_BROWSE_DROPPED, (LPCTSTR)m_sAddress ); } Stop(); }
BOOL CHostBrowser::OnRead() { if ( m_pInput == NULL || m_pOutput == NULL ) return TRUE; CTransfer::OnRead(); switch ( m_nState ) { case hbsRequesting: if ( ! ReadResponseLine() ) return FALSE; if ( m_nState != hbsHeaders ) break; case hbsHeaders: if ( ! ReadHeaders() ) return FALSE; if ( m_nState != hbsContent ) break; case hbsContent: return ReadContent(); } return TRUE; }