Passing an Application to a URL
Any Brew application can request another application to handle URLs using the
ISHELL_BrowseURL or
ISHELL_PostURL functions through the Brew AEE's URL and MIME type handling registries. Using this mechanism:
- Applications that can handle specific Web protocols register their ability in their Module Information File.
- A client application requesting a service creates a URL for the specific Web protocol, embedding the arguments to the request in the URL using the standard mechanism used by Web servers handling GET requests.
- The client application invokes ISHELL_BrowseURL to launch the application associated with the desired protocol, or ISHELL_PostURL to request a service without launching the application that handles the desired protocol.
- The Brew AEE searches its registry of Web protocol and MIME handlers for a class ID that can handle the protocol in the URL you pass.
- The Brew AEE sends the URL to the handling application via either the EVT_BROWSE_URL (if you used ISHELL_BrowseURL) or the EVT_APP_POST_URL (if you used ISHELL_PostURL).
To use one of these APIs to launch the hypothetical application to the list view, you might write:
ISHELL_LaunchURL( pMe->a.m_pIShell,
"rayapp://listview" );
The application here would need to add the
rayapp protocol to the list of handled protocols in the module information file, and then use
IWEBUtil to crack the incoming URL in the event handler, like this:
case EVT_BROWSE_URL:
{
char *pszUrl = (char *)dwParam;
UrlParts sParts = {};
IWEBUTIL_ParseUrl( pMe->piwu, pszUrl, &sParts );
if ( sParts.cpcPath &&
0 == STRCMP( sParts.cpcPath, "listview" ) )
ShowListView( pMe );
else
ShowNormalView( pMe );
bHandled = TRUE;
}
break;
Of course, the URL you pass to me might have arguments, too; you could pass something like
rayapp://listview?style=fancy;items=one,two,three, and I can parse the URL arguments starting from the
UrlPart's cpcSrch pointer.
As I hinted previously, ISHELL_LaunchURL launches the registered application to the foreground; if what you want is background processing of the content, use ISHELL_PostURL instead. From there, your application can process the URL and even start itself in the foreground or background as appropriate.
URLs are excellent containers for small parcels of data like launch parameters, but sometimes you need something bigger. For this, there's IFIFO.