r469 - trunk
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Fri Jan 25 03:13:13 EST 2008
Author: icculus
Date: 2008-01-25 03:13:13 -0500 (Fri, 25 Jan 2008)
New Revision: 469
Modified:
trunk/platform_beos.cpp
trunk/platform_unix.c
Log:
Completely untested BeOS code for launching a browser.
Modified: trunk/platform_beos.cpp
===================================================================
--- trunk/platform_beos.cpp 2008-01-25 07:08:25 UTC (rev 468)
+++ trunk/platform_beos.cpp 2008-01-25 08:13:13 UTC (rev 469)
@@ -14,9 +14,45 @@
#if PLATFORM_BEOS
#include <stdio.h>
+#include <string.h>
+#include <be/app/Roster.h>
#include <be/kernel/image.h>
#include <be/kernel/OS.h>
+extern "C" { int beos_launchBrowser(const char *url); }
+int beos_launchBrowser(const char *url)
+{
+ static struct { const char *prot, const char *mime } protmimemap[] =
+ {
+ { "http://", "text/html" },
+ { "https://", "text/html" },
+ { "file://", "text/html" }, // let the web browser handle this.
+ { "ftp://", "application/x-vnd.Be.URL.ftp" },
+ { "mailto:", "text/x-email" },
+ { NULL, NULL }
+ };
+
+ const char *mime = NULL;
+
+ for (int i = 0; protmimemap[i].prot != NULL; i++)
+ {
+ const char *prot = protmimemap[i].prot;
+ if (strncmp(url, prot, strlen(prot)) == 0)
+ {
+ mime = protmimemap[i].mime;
+ break;
+ } // if
+ } // for
+
+ if (mime == NULL)
+ return false; // no handler for this protocol.
+
+ // be_roster is a global object supplied by the system runtime.
+ return (be_roster->Launch(mime, 1, &url) == B_OK);
+} // beos_launchBrowser
+
+
+extern "C" { void *beos_dlopen(const char *fname, int unused); }
void *beos_dlopen(const char *fname, int unused)
{
const image_id lib = load_add_on(fname);
@@ -27,6 +63,7 @@
} // beos_dlopen
+extern "C" { void *beos_dlsym(void *lib, const char *sym); }
void *beos_dlsym(void *lib, const char *sym)
{
void *addr = NULL;
@@ -36,12 +73,14 @@
} // beos_dlsym
+extern "C" { void beos_dlclose(void *lib); }
void beos_dlclose(void *lib)
{
unload_add_on((image_id) lib);
} // beos_dlclose
+extern "C" { void beos_usleep(unsigned long microseconds); }
void beos_usleep(unsigned long microseconds)
{
snooze(microseconds);
Modified: trunk/platform_unix.c
===================================================================
--- trunk/platform_unix.c 2008-01-25 07:08:25 UTC (rev 468)
+++ trunk/platform_unix.c 2008-01-25 08:13:13 UTC (rev 469)
@@ -940,6 +940,9 @@
const OSStatus err = LSOpenCFURLRef(cfurl, NULL);
CFRelease(cfurl);
return (err == noErr);
+#elif PLATFORM_BEOS
+ extern int beos_launchBrowser(const char *url);
+ return beos_launchBrowser(url) ? true : false;
#else
return false; // !!! FIXME: write me.
#endif
More information about the mojosetup-commits
mailing list