Registering a protocol with wxWebViewHandler

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Scorcher24
Earned some good credits
Earned some good credits
Posts: 128
Joined: Sat Sep 25, 2004 9:11 pm
Location: Nuremberg, Germany
Contact:

Registering a protocol with wxWebViewHandler

Post by Scorcher24 »

I am currently trying to implement an app that makes excessive use of wxWebViewControl. I use static pages as well as dynamic pages that are stored/cached on the user's pc. For the application, I require 2 own schemes/protocols:
static://

and

profile://
The goal is to have them handle local content but making adressing them easier.
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();
    }
An url to use this would look like that:
static://start
Now I have a class which derives from wxWebViewHandler to make this happen:

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;
    };
However, the problem is that if I click the link static://about or any other with that protocol, nothing happens. I tried it with and without FilenameToURL(). I also checked in the debugger, the path is valid after it's construction. But the page does not change.

Anyone having any insight into this?
Thanks :).

ps.: If I just return NULL and send path directly to the browser via LoadURL(), it works.
OS: Windows 7 Ultimate 64bit
IDE: VC++ 2008 Professional
WX: 2.9.2
My Projects
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2408
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

Re: Registering a protocol with wxWebViewHandler

Post by evstevemd »

Didi you register your handler?
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Scorcher24
Earned some good credits
Earned some good credits
Posts: 128
Joined: Sat Sep 25, 2004 9:11 pm
Location: Nuremberg, Germany
Contact:

Re: Registering a protocol with wxWebViewHandler

Post by Scorcher24 »

Yes, I did. But I got a response on StackOverflow from the Author himself, looks like we found a bug.
OS: Windows 7 Ultimate 64bit
IDE: VC++ 2008 Professional
WX: 2.9.2
My Projects
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2408
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

Re: Registering a protocol with wxWebViewHandler

Post by evstevemd »

Scorcher24 wrote:Yes, I did. But I got a response on StackOverflow from the Author himself, looks like we found a bug.
It is nice to go hunting bugs.
Could you put SO link?
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Scorcher24
Earned some good credits
Earned some good credits
Posts: 128
Joined: Sat Sep 25, 2004 9:11 pm
Location: Nuremberg, Germany
Contact:

Re: Registering a protocol with wxWebViewHandler

Post by Scorcher24 »

Of course, here ya go:
http://stackoverflow.com/questions/9068 ... iewhandler

If you can reproduce it and find out anything, please lemme know.
My whole project depends on that Control :| and I really don't want to switch to QT.
OS: Windows 7 Ultimate 64bit
IDE: VC++ 2008 Professional
WX: 2.9.2
My Projects
Scorcher24
Earned some good credits
Earned some good credits
Posts: 128
Joined: Sat Sep 25, 2004 9:11 pm
Location: Nuremberg, Germany
Contact:

Re: Registering a protocol with wxWebViewHandler

Post by Scorcher24 »

I posted a bug:
http://trac.wxwidgets.org/ticket/13907

I can't get it to work. I used svn as suggested, but I still get the same error over and over again. Visual C++ shows me a First Chance Exception when I click on the link containing my special protocol, but nothing happens.
If anyone has any insight or tipps, please share.

I also tried to use wxWebConnect, but that leaves me with minimal documentation and a memory leak when you add flash-support, which I need.
Also, the whole thing is a bit clunky imho.

If anyone has a suggestion of a good Control that let's me display advanced HTML Pages including js, lemme know.
OS: Windows 7 Ultimate 64bit
IDE: VC++ 2008 Professional
WX: 2.9.2
My Projects
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2408
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

Re: Registering a protocol with wxWebViewHandler

Post by evstevemd »

Scorcher24 wrote:I posted a bug:
http://trac.wxwidgets.org/ticket/13907

I can't get it to work. I used svn as suggested, but I still get the same error over and over again. Visual C++ shows me a First Chance Exception when I click on the link containing my special protocol, but nothing happens.
If anyone has any insight or tipps, please share.

I also tried to use wxWebConnect, but that leaves me with minimal documentation and a memory leak when you add flash-support, which I need.
Also, the whole thing is a bit clunky imho.

If anyone has a suggestion of a good Control that let's me display advanced HTML Pages including js, lemme know.
have you tried other compilers?
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Scorcher24
Earned some good credits
Earned some good credits
Posts: 128
Joined: Sat Sep 25, 2004 9:11 pm
Location: Nuremberg, Germany
Contact:

Re: Registering a protocol with wxWebViewHandler

Post by Scorcher24 »

evstevemd wrote:
Scorcher24 wrote:I posted a bug:
http://trac.wxwidgets.org/ticket/13907

I can't get it to work. I used svn as suggested, but I still get the same error over and over again. Visual C++ shows me a First Chance Exception when I click on the link containing my special protocol, but nothing happens.
If anyone has any insight or tipps, please share.

I also tried to use wxWebConnect, but that leaves me with minimal documentation and a memory leak when you add flash-support, which I need.
Also, the whole thing is a bit clunky imho.

If anyone has a suggestion of a good Control that let's me display advanced HTML Pages including js, lemme know.
have you tried other compilers?
Thanks for your answer.
No I did not, because I do not have another one set up on my system.
Also, I really want to use my VC2008 Prof. since I am very used to the Debugger.

But the Author of the Component checked it himself with the VC2008 Compiler and it went fine.
Anyone here with the VC2008 Compiler who can do a counter-check?
Example to compile is included in the ticket.
OS: Windows 7 Ultimate 64bit
IDE: VC++ 2008 Professional
WX: 2.9.2
My Projects
User avatar
evstevemd
Part Of The Furniture
Part Of The Furniture
Posts: 2408
Joined: Wed Jan 28, 2009 11:57 am
Location: United Republic of Tanzania

Re: Registering a protocol with wxWebViewHandler

Post by evstevemd »

Scorcher24 wrote:
evstevemd wrote:
Scorcher24 wrote:I posted a bug:
http://trac.wxwidgets.org/ticket/13907

I can't get it to work. I used svn as suggested, but I still get the same error over and over again. Visual C++ shows me a First Chance Exception when I click on the link containing my special protocol, but nothing happens.
If anyone has any insight or tipps, please share.

I also tried to use wxWebConnect, but that leaves me with minimal documentation and a memory leak when you add flash-support, which I need.
Also, the whole thing is a bit clunky imho.

If anyone has a suggestion of a good Control that let's me display advanced HTML Pages including js, lemme know.
have you tried other compilers?
Thanks for your answer.
No I did not, because I do not have another one set up on my system.
Also, I really want to use my VC2008 Prof. since I am very used to the Debugger.

But the Author of the Component checked it himself with the VC2008 Compiler and it went fine.
Anyone here with the VC2008 Compiler who can do a counter-check?
Example to compile is included in the ticket.
VC is known for configurations mismatch stubbornness make sure that configurations needed are ok!
Unfortunately I have almost *zero* knowledge when it comes to VC
Chief Justice: We have trouble dear citizens!
Citizens: What it is his honor?
Chief Justice:Our president is an atheist, who will he swear to?
Post Reply