make launch_url core operation use nsurl

This commit is contained in:
Vincent Sanders 2014-05-27 23:52:35 +01:00
parent 662e950e48
commit 7d02ae916a
10 changed files with 40 additions and 27 deletions

View File

@ -122,25 +122,31 @@ void ami_openurl_close(const char *scheme)
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);
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)
{
URL_OpenA((STRPTR)url,NULL);
} else {
if(launchurl = ASPrintf("URL:%s",url)) {
if(launchurl = ASPrintf("URL:%s", nsurl_access(url))) {
BPTR fptr = Open(launchurl,MODE_OLDFILE);
if(fptr) Close(fptr);
else ami_openurl_add_protocol(url);
if(fptr)
{
Close(fptr);
} else {
ami_openurl_add_protocol(nsurl_access(url));
}
FreeVec(launchurl);
}
}
}
SetProcWindow(procwin);
return NSERROR_OK;
}

View File

@ -26,6 +26,6 @@
void ami_openurl_open(void);
void ami_openurl_close(void);
void gui_launch_url(const char *url);
nserror gui_launch_url(struct nsurl *url);
#endif

View File

@ -896,12 +896,13 @@ void nsbeos_gui_view_source(struct hlcache_handle *content)
* 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;
// try to open it as an URI
BString mimeType = "application/x-vnd.Be.URL.";
BString arg(url);
BString arg(nsurl_access(url));
mimeType.Append(arg, arg.FindFirst(":"));
// 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
// if not there is likely no supporting app anyway
if (!BMimeType::IsValid(mimeType.String()))
return;
char *args[2] = { (char *)url, NULL };
return NSERROR_NO_FETCH_HANDLER;
char *args[2] = { (char *)nsurl_access(url), NULL };
status = be_roster->Launch(mimeType.String(), 1, args);
if (status < B_OK)
warn_user("Cannot launch url", strerror(status));
return NSERROR_OK;
}

View File

@ -253,9 +253,10 @@ static void gui_create_form_select_menu(struct browser_window *bw,
[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;

View File

@ -839,7 +839,7 @@ browser_window_download(struct browser_window *bw,
NULL, NULL, &l);
if (error == NSERROR_NO_FETCH_HANDLER) {
/* 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) {
LOG(("Failed to fetch download: %d", error));
} else {
@ -1932,7 +1932,7 @@ nserror browser_window_navigate(struct browser_window *bw,
case NSERROR_NO_FETCH_HANDLER: /* no handler for this type */
/** @todo does this always try and download even unverifiable content? */
guit->browser->launch_url(nsurl_access(url));
error = guit->browser->launch_url(url);
break;
default: /* report error to user */

View File

@ -475,7 +475,7 @@ struct gui_browser_table {
/**
* core has no fetcher for url
*/
void (*launch_url)(const char *url);
nserror (*launch_url)(struct nsurl *url);
/**
* create a form select menu

View File

@ -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,

View File

@ -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;
GError *error = NULL;
ok = nsgtk_show_uri(NULL, url, GDK_CURRENT_TIME, &error);
if (ok == TRUE)
return;
ok = nsgtk_show_uri(NULL, nsurl_access(url), GDK_CURRENT_TIME, &error);
if (ok == TRUE) {
return NSERROR_OK;
}
if (error) {
warn_user(messages_get("URIOpenError"), error->message);
g_error_free(error);
}
return NSERROR_NO_FETCH_HANDLER;
}
void warn_user(const char *warning, const char *detail)

View File

@ -67,10 +67,10 @@ static void monkey_quit(void)
monkey_fetch_filetype_fin();
}
static void
gui_launch_url(const char *url)
static nserror gui_launch_url(struct nsurl *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)

View File

@ -2214,10 +2214,11 @@ void ro_gui_dump_browser_window(struct browser_window *bw)
* 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 */
ro_url_broadcast(url);
/* Try ant broadcast */
ro_url_broadcast(nsurl_access(url));
return NSERROR_OK;
}