gfaieta / phpdesktop

Automatically exported from code.google.com/p/phpdesktop
0 stars 0 forks source link

Handle links that use custom protocols - "mailto:" for example. #80

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Currently when you click on a "mailto:" link you will see an error:

    "Failed to load URL mailto:mail@example.com? ... with error (-302)."

It can be fixed in CefRequestHandler::OnBeforeBrowse(). In a similar way that 
external links are handled. A system default browser is launched when there is 
"external_navigation" settings.json option set to false. The call to 
ShellExecute(open) should work for the mailto links as well.

We should introduce "external_protocols" option in settings.json. This would be 
a list of protocols that will be handled by OS. For example ["mailto"] by 
default.

The fix for now would be to attach a global event listener for the "onclick" 
event using document.addEventListener(). The target element that was clicked 
should be checked whether its "href" attribute starts with a "mailto:" link. If 
so, you should handle the event and call a php script through AJAX. The php 
script should execute Windows system command to open the default email client. 
In C++ the code would look like:

    ShellExecute(NULL, L"open", "mailto:asd@asd.pl", NULL, NULL, SW_SHOWNORMAL);

Unfortunately I don't know a way to make such system call from within php. This 
doesn't work for me:

    system("mailto:asd@asd.pl")
    system("start asd@asd.pl")

Though, launching url in default browser works fine with the start command:

    system("start http://www.google.com/")

Maybe it is feasible with the use of the system() command, but that would 
require further investigation.

Original issue reported on code.google.com by czarek.t...@gmail.com on 7 Feb 2014 at 3:36

GoogleCodeExporter commented 9 years ago
Issue 79 has been merged into this issue.

Original comment by czarek.t...@gmail.com on 7 Feb 2014 at 3:40

GoogleCodeExporter commented 9 years ago
I was wrong. The system("start mailto:asd@asd.pl") seems to be working fine. It 
was a problem on my system, as I have no mail client associated. Thus I get 
such error message on Windows when launching the mailto link:

    Could not perform this operation because the default mail client
    is not properly installed.

This error message box appeared in background, so I didn't see it initially.

Original comment by czarek.t...@gmail.com on 7 Feb 2014 at 3:59

GoogleCodeExporter commented 9 years ago
On PHP you can call something like this:

shell_exec("start mailto:\"mail@example.com?subject=Mysubject&body=Mybody");

Original comment by RicardoF...@gmail.com on 7 Feb 2014 at 4:31

GoogleCodeExporter commented 9 years ago

Original comment by czarek.t...@gmail.com on 13 Oct 2014 at 6:58

GoogleCodeExporter commented 9 years ago

Original comment by czarek.t...@gmail.com on 21 Oct 2014 at 10:37