mirror of
https://github.com/netsurf-browser/netsurf
synced 2025-01-03 17:54:33 +03:00
make launch_url core operation use nsurl
This commit is contained in:
parent
662e950e48
commit
7d02ae916a
@ -122,25 +122,31 @@ void ami_openurl_close(const char *scheme)
|
|||||||
ami_openurl_free_list(&ami_unsupportedprotocols);
|
ami_openurl_free_list(&ami_unsupportedprotocols);
|
||||||
}
|
}
|
||||||
|
|
||||||
void gui_launch_url(const char *url)
|
nserror gui_launch_url(struct nsurl *url)
|
||||||
{
|
{
|
||||||
APTR procwin = SetProcWindow((APTR)-1L);
|
APTR procwin = SetProcWindow((APTR)-1L);
|
||||||
char *launchurl = NULL;
|
char *launchurl = NULL;
|
||||||
|
|
||||||
if(ami_openurl_check_list(&ami_unsupportedprotocols, url) == FALSE)
|
if(ami_openurl_check_list(&ami_unsupportedprotocols, nsurl_access(url)) == FALSE)
|
||||||
{
|
{
|
||||||
if(IOpenURL)
|
if(IOpenURL)
|
||||||
{
|
{
|
||||||
URL_OpenA((STRPTR)url,NULL);
|
URL_OpenA((STRPTR)url,NULL);
|
||||||
} else {
|
} else {
|
||||||
if(launchurl = ASPrintf("URL:%s",url)) {
|
if(launchurl = ASPrintf("URL:%s", nsurl_access(url))) {
|
||||||
BPTR fptr = Open(launchurl,MODE_OLDFILE);
|
BPTR fptr = Open(launchurl,MODE_OLDFILE);
|
||||||
if(fptr) Close(fptr);
|
if(fptr)
|
||||||
else ami_openurl_add_protocol(url);
|
{
|
||||||
|
Close(fptr);
|
||||||
|
} else {
|
||||||
|
ami_openurl_add_protocol(nsurl_access(url));
|
||||||
|
}
|
||||||
FreeVec(launchurl);
|
FreeVec(launchurl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SetProcWindow(procwin);
|
SetProcWindow(procwin);
|
||||||
|
|
||||||
|
return NSERROR_OK;
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,6 @@
|
|||||||
void ami_openurl_open(void);
|
void ami_openurl_open(void);
|
||||||
void ami_openurl_close(void);
|
void ami_openurl_close(void);
|
||||||
|
|
||||||
void gui_launch_url(const char *url);
|
nserror gui_launch_url(struct nsurl *url);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
10
beos/gui.cpp
10
beos/gui.cpp
@ -896,12 +896,13 @@ void nsbeos_gui_view_source(struct hlcache_handle *content)
|
|||||||
* Broadcast an URL that we can't handle.
|
* Broadcast an URL that we can't handle.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void gui_launch_url(const char *url)
|
static nserror gui_launch_url(struct nsurl *url)
|
||||||
{
|
{
|
||||||
status_t status;
|
status_t status;
|
||||||
// try to open it as an URI
|
// try to open it as an URI
|
||||||
BString mimeType = "application/x-vnd.Be.URL.";
|
BString mimeType = "application/x-vnd.Be.URL.";
|
||||||
BString arg(url);
|
BString arg(nsurl_access(url));
|
||||||
|
|
||||||
mimeType.Append(arg, arg.FindFirst(":"));
|
mimeType.Append(arg, arg.FindFirst(":"));
|
||||||
|
|
||||||
// special case, text/x-email is used traditionally
|
// special case, text/x-email is used traditionally
|
||||||
@ -913,11 +914,12 @@ static void gui_launch_url(const char *url)
|
|||||||
// we just check if it's registered
|
// we just check if it's registered
|
||||||
// if not there is likely no supporting app anyway
|
// if not there is likely no supporting app anyway
|
||||||
if (!BMimeType::IsValid(mimeType.String()))
|
if (!BMimeType::IsValid(mimeType.String()))
|
||||||
return;
|
return NSERROR_NO_FETCH_HANDLER;
|
||||||
char *args[2] = { (char *)url, NULL };
|
char *args[2] = { (char *)nsurl_access(url), NULL };
|
||||||
status = be_roster->Launch(mimeType.String(), 1, args);
|
status = be_roster->Launch(mimeType.String(), 1, args);
|
||||||
if (status < B_OK)
|
if (status < B_OK)
|
||||||
warn_user("Cannot launch url", strerror(status));
|
warn_user("Cannot launch url", strerror(status));
|
||||||
|
return NSERROR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -253,9 +253,10 @@ static void gui_create_form_select_menu(struct browser_window *bw,
|
|||||||
[menu release];
|
[menu release];
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gui_launch_url(const char *url)
|
static nserror gui_launch_url(nsurl *url)
|
||||||
{
|
{
|
||||||
[[NSWorkspace sharedWorkspace] openURL: [NSURL URLWithString: [NSString stringWithUTF8String: url]]];
|
[[NSWorkspace sharedWorkspace] openURL: [NSURL URLWithString: [NSString stringWithUTF8String: nsurl_access(url)]]];
|
||||||
|
return NSERROR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct ssl_cert_info;
|
struct ssl_cert_info;
|
||||||
|
@ -839,7 +839,7 @@ browser_window_download(struct browser_window *bw,
|
|||||||
NULL, NULL, &l);
|
NULL, NULL, &l);
|
||||||
if (error == NSERROR_NO_FETCH_HANDLER) {
|
if (error == NSERROR_NO_FETCH_HANDLER) {
|
||||||
/* no internal handler for this type, call out to frontend */
|
/* no internal handler for this type, call out to frontend */
|
||||||
guit->browser->launch_url(nsurl_access(url));
|
error = guit->browser->launch_url(url);
|
||||||
} else if (error != NSERROR_OK) {
|
} else if (error != NSERROR_OK) {
|
||||||
LOG(("Failed to fetch download: %d", error));
|
LOG(("Failed to fetch download: %d", error));
|
||||||
} else {
|
} else {
|
||||||
@ -1932,7 +1932,7 @@ nserror browser_window_navigate(struct browser_window *bw,
|
|||||||
|
|
||||||
case NSERROR_NO_FETCH_HANDLER: /* no handler for this type */
|
case NSERROR_NO_FETCH_HANDLER: /* no handler for this type */
|
||||||
/** @todo does this always try and download even unverifiable content? */
|
/** @todo does this always try and download even unverifiable content? */
|
||||||
guit->browser->launch_url(nsurl_access(url));
|
error = guit->browser->launch_url(url);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default: /* report error to user */
|
default: /* report error to user */
|
||||||
|
@ -475,7 +475,7 @@ struct gui_browser_table {
|
|||||||
/**
|
/**
|
||||||
* core has no fetcher for url
|
* core has no fetcher for url
|
||||||
*/
|
*/
|
||||||
void (*launch_url)(const char *url);
|
nserror (*launch_url)(struct nsurl *url);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* create a form select menu
|
* create a form select menu
|
||||||
|
@ -515,8 +515,9 @@ static void gui_default_quit(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void gui_default_launch_url(const char *url)
|
static nserror gui_default_launch_url(struct nsurl *url)
|
||||||
{
|
{
|
||||||
|
return NSERROR_NO_FETCH_HANDLER;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gui_default_create_form_select_menu(struct browser_window *bw,
|
static void gui_default_create_form_select_menu(struct browser_window *bw,
|
||||||
|
10
gtk/gui.c
10
gtk/gui.c
@ -617,19 +617,21 @@ static void gui_create_form_select_menu(struct browser_window *bw,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gui_launch_url(const char *url)
|
static nserror gui_launch_url(struct nsurl *url)
|
||||||
{
|
{
|
||||||
gboolean ok;
|
gboolean ok;
|
||||||
GError *error = NULL;
|
GError *error = NULL;
|
||||||
|
|
||||||
ok = nsgtk_show_uri(NULL, url, GDK_CURRENT_TIME, &error);
|
ok = nsgtk_show_uri(NULL, nsurl_access(url), GDK_CURRENT_TIME, &error);
|
||||||
if (ok == TRUE)
|
if (ok == TRUE) {
|
||||||
return;
|
return NSERROR_OK;
|
||||||
|
}
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
warn_user(messages_get("URIOpenError"), error->message);
|
warn_user(messages_get("URIOpenError"), error->message);
|
||||||
g_error_free(error);
|
g_error_free(error);
|
||||||
}
|
}
|
||||||
|
return NSERROR_NO_FETCH_HANDLER;
|
||||||
}
|
}
|
||||||
|
|
||||||
void warn_user(const char *warning, const char *detail)
|
void warn_user(const char *warning, const char *detail)
|
||||||
|
@ -67,10 +67,10 @@ static void monkey_quit(void)
|
|||||||
monkey_fetch_filetype_fin();
|
monkey_fetch_filetype_fin();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static nserror gui_launch_url(struct nsurl *url)
|
||||||
gui_launch_url(const char *url)
|
|
||||||
{
|
{
|
||||||
fprintf(stdout, "GENERIC LAUNCH URL %s\n", url);
|
fprintf(stdout, "GENERIC LAUNCH URL %s\n", nsurl_access(url));
|
||||||
|
return NSERROR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void quit_handler(int argc, char **argv)
|
static void quit_handler(int argc, char **argv)
|
||||||
|
@ -2214,10 +2214,11 @@ void ro_gui_dump_browser_window(struct browser_window *bw)
|
|||||||
* Broadcast an URL that we can't handle.
|
* Broadcast an URL that we can't handle.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
static void gui_launch_url(const char *url)
|
static nserror gui_launch_url(struct nsurl *url)
|
||||||
{
|
{
|
||||||
/* Try ant broadcast first */
|
/* Try ant broadcast */
|
||||||
ro_url_broadcast(url);
|
ro_url_broadcast(nsurl_access(url));
|
||||||
|
return NSERROR_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user