The goal is to have them handle local content but making adressing them easier.static://
and
profile://
For example, hence the translation code for static sites:
Code: Select all
wxString Mainframe::GetStaticContent(wxString file)
{
// Choose based on language
wxString language = wxGetApp().GetSelectedLanguage();
// Construct Filename
wxFileName fname(wxGetApp().GetAppPath() + wxString("/static/") + language + wxString("/") + file + wxString(".html"));
// Return full path, which is corrected by wxWidgets
return fname.GetFullPath();
}
Now I have a class which derives from wxWebViewHandler to make this happen:static://start
Code: Select all
class WebViewHandlerStatic : public wxWebViewHandler
{
public:
WebViewHandlerStatic(const wxString& protocol, Mainframe* parent)
: wxWebViewHandler(protocol), m_parent(parent)
{
m_fs = new wxFileSystem();
}
virtual WebViewHandlerStatic::~WebViewHandlerStatic()
{
wxDELETE(m_fs);
}
virtual wxFSFile* GetFile (const wxString &uri)
{
wxString content = uri.substr(9, uri.length()).BeforeLast('/');
wxString path = m_parent->GetStaticContent(content);
if ( wxFileName::FileExists(path) && wxFileSystem::HasHandlerForPath(path) )
{
//path = wxFileSystem::FileNameToURL(path);
return m_fs->OpenFile(path);
}
else
return NULL;
}
private:
Mainframe* m_parent;
wxFileSystem* m_fs;
};
Anyone having any insight into this?
Thanks .
ps.: If I just return NULL and send path directly to the browser via LoadURL(), it works.