Rename wxWebRequestEvent::GetResponseFileName() to GetDataFile()
This is shorter and doesn't imply that just the name (and not the full path) is being returned. Also rename wxWebResponse::GetFileName() to GetDataFile() for the same reasons and for consistency. And document this previously undocumented method.
This commit is contained in:
@@ -151,7 +151,7 @@ public:
|
||||
|
||||
wxString AsString() const;
|
||||
|
||||
virtual wxString GetFileName() const;
|
||||
virtual wxString GetDataFile() const;
|
||||
|
||||
protected:
|
||||
wxWebRequestImpl& m_request;
|
||||
|
@@ -111,7 +111,7 @@ public:
|
||||
|
||||
wxString AsString() const;
|
||||
|
||||
wxString GetFileName() const;
|
||||
wxString GetDataFile() const;
|
||||
|
||||
protected:
|
||||
// Ctor is used by wxWebRequest and wxWebRequestImpl.
|
||||
@@ -264,9 +264,9 @@ public:
|
||||
|
||||
const wxString& GetErrorDescription() const { return m_errorDescription; }
|
||||
|
||||
const wxString& GetResponseFileName() const { return m_responseFileName; }
|
||||
const wxString& GetDataFile() const { return m_dataFile; }
|
||||
|
||||
void SetResponseFileName(const wxString& filename) { m_responseFileName = filename; }
|
||||
void SetDataFile(const wxString& dataFile) { m_dataFile = dataFile; }
|
||||
|
||||
const void* GetDataBuffer() const { return m_data; }
|
||||
|
||||
@@ -280,7 +280,7 @@ public:
|
||||
private:
|
||||
wxWebRequest::State m_state;
|
||||
const wxWebResponse m_response; // may be invalid
|
||||
wxString m_responseFileName;
|
||||
wxString m_dataFile;
|
||||
const void* m_data;
|
||||
size_t m_dataSize;
|
||||
wxString m_errorDescription;
|
||||
|
@@ -164,7 +164,7 @@ public:
|
||||
The data is written to a file on disk as it is received.
|
||||
|
||||
This file can be later read from using wxWebResponse::GetStream()
|
||||
or otherwise processed using wxWebRequestEvent::GetResponseFileName().
|
||||
or otherwise processed using wxWebRequestEvent::GetDataFile().
|
||||
*/
|
||||
Storage_File,
|
||||
|
||||
@@ -550,6 +550,13 @@ public:
|
||||
*/
|
||||
wxString GetSuggestedFileName() const;
|
||||
|
||||
/**
|
||||
Returns the full path of the file to which data is being saved.
|
||||
|
||||
This is only valid when storage mode is @c Storage_File.
|
||||
*/
|
||||
wxString GetDataFile() const;
|
||||
|
||||
/**
|
||||
Returns all response data as a string.
|
||||
|
||||
@@ -737,7 +744,7 @@ public:
|
||||
move the file to a location of your choice if you want to process the
|
||||
contents outside the event handler.
|
||||
*/
|
||||
const wxString& GetResponseFileName() const;
|
||||
const wxString& GetDataFile() const;
|
||||
|
||||
/**
|
||||
Only for @c wxEVT_WEBREQUEST_DATA events. The buffer is only valid
|
||||
|
@@ -288,7 +288,7 @@ public:
|
||||
wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
|
||||
if ( fileDlg.ShowModal() == wxID_OK )
|
||||
{
|
||||
if ( !wxRenameFile(evt.GetResponseFileName(), fileDlg.GetPath()) )
|
||||
if ( !wxRenameFile(evt.GetDataFile(), fileDlg.GetPath()) )
|
||||
wxLogError("Could not move file");
|
||||
}
|
||||
|
||||
|
@@ -278,22 +278,22 @@ void wxWebRequestImpl::ProcessStateEvent(wxWebRequest::State state, const wxStri
|
||||
if ( !IsActiveState(state) && GetResponse() )
|
||||
GetResponse()->Finalize();
|
||||
|
||||
wxString responseFileName;
|
||||
wxString dataFile;
|
||||
|
||||
wxWebRequestEvent evt(wxEVT_WEBREQUEST_STATE, GetId(), state,
|
||||
wxWebResponse(GetResponse()), failMsg);
|
||||
if ( state == wxWebRequest::State_Completed && m_storage == wxWebRequest::Storage_File )
|
||||
{
|
||||
responseFileName = GetResponse()->GetFileName();
|
||||
evt.SetResponseFileName(responseFileName);
|
||||
dataFile = GetResponse()->GetDataFile();
|
||||
evt.SetDataFile(dataFile);
|
||||
}
|
||||
|
||||
m_handler->ProcessEvent(evt);
|
||||
|
||||
// Remove temporary file if we're using one and if it still exists: it
|
||||
// could have been deleted or moved away by the event handler.
|
||||
if ( !responseFileName.empty() && wxFileExists(responseFileName) )
|
||||
wxRemoveFile(responseFileName);
|
||||
if ( !dataFile.empty() && wxFileExists(dataFile) )
|
||||
wxRemoveFile(dataFile);
|
||||
}
|
||||
|
||||
//
|
||||
@@ -638,7 +638,7 @@ void wxWebResponseImpl::ReportDataReceived(size_t sizeReceived)
|
||||
m_readBuffer.Clear();
|
||||
}
|
||||
|
||||
wxString wxWebResponseImpl::GetFileName() const
|
||||
wxString wxWebResponseImpl::GetDataFile() const
|
||||
{
|
||||
return m_file.GetName();
|
||||
}
|
||||
@@ -740,11 +740,11 @@ wxString wxWebResponse::AsString() const
|
||||
return m_impl->AsString();
|
||||
}
|
||||
|
||||
wxString wxWebResponse::GetFileName() const
|
||||
wxString wxWebResponse::GetDataFile() const
|
||||
{
|
||||
wxCHECK_IMPL( wxString() );
|
||||
|
||||
return m_impl->GetFileName();
|
||||
return m_impl->GetDataFile();
|
||||
}
|
||||
|
||||
|
||||
|
@@ -78,7 +78,7 @@ public:
|
||||
case wxWebRequest::State_Completed:
|
||||
if ( request.GetStorage() == wxWebRequest::Storage_File )
|
||||
{
|
||||
wxFileName fn(evt.GetResponseFileName());
|
||||
wxFileName fn(evt.GetDataFile());
|
||||
REQUIRE( fn.GetSize() == expectedFileSize );
|
||||
}
|
||||
wxFALLTHROUGH;
|
||||
|
Reference in New Issue
Block a user