we honor safe modes for GL addons too. maybe this should end somewhere in libbe and a userland safemode.h

git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25333 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval 2008-05-06 21:58:07 +00:00
parent 5abf416fd0
commit 7a58a3ed3d
3 changed files with 44 additions and 5 deletions

View File

@ -5,9 +5,11 @@
* Authors:
*/
#include <image.h>
#include <safemode.h>
#include <Directory.h>
#include <FindDirectory.h>
#include <image.h>
#include <Path.h>
#include <String.h>
#include "GLDispatcher.h"
@ -17,13 +19,49 @@
#include <string.h>
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
extern "C" status_t _kern_get_safemode_option(const char *parameter,
char *buffer, size_t *_bufferSize);
#else
extern "C" status_t _kget_safemode_option_(const char *parameter,
char *buffer, size_t *_bufferSize);
#endif
GLRendererRoster::GLRendererRoster(BGLView *view, ulong options)
: fNextID(0),
fView(view),
fOptions(options)
fOptions(options),
fSafeMode(false)
{
AddDefaultPaths();
char parameter[32];
size_t parameterLength = sizeof(parameter);
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
if (_kern_get_safemode_option(B_SAFEMODE_SAFE_MODE, parameter, &parameterLength) == B_OK)
#else
if (_kget_safemode_option_(B_SAFEMODE_SAFE_MODE, parameter, &parameterLength) == B_OK)
#endif
{
if (!strcasecmp(parameter, "enabled") || !strcasecmp(parameter, "on")
|| !strcasecmp(parameter, "true") || !strcasecmp(parameter, "yes")
|| !strcasecmp(parameter, "enable") || !strcmp(parameter, "1"))
fSafeMode = true;
}
#ifdef HAIKU_TARGET_PLATFORM_HAIKU
if (_kern_get_safemode_option(B_SAFEMODE_DISABLE_USER_ADD_ONS, parameter, &parameterLength) == B_OK)
#else
if (_kget_safemode_option_(B_SAFEMODE_DISABLE_USER_ADD_ONS, parameter, &parameterLength) == B_OK)
#endif
{
if (!strcasecmp(parameter, "enabled") || !strcasecmp(parameter, "on")
|| !strcasecmp(parameter, "true") || !strcasecmp(parameter, "yes")
|| !strcasecmp(parameter, "enable") || !strcmp(parameter, "1"))
fSafeMode = true;
}
AddDefaultPaths();
}
@ -55,7 +93,7 @@ GLRendererRoster::AddDefaultPaths()
B_BEOS_ADDONS_DIRECTORY,
};
for (uint32 i = 0; i < sizeof(paths) / sizeof(paths[0]); i++) {
for (uint32 i = fSafeMode ? 2 : 0; i < sizeof(paths) / sizeof(paths[0]); i++) {
BPath path;
status_t status = find_directory(paths[i], &path, true);
if (status == B_OK && path.Append("opengl") == B_OK)

View File

@ -35,6 +35,7 @@ class GLRendererRoster {
int32 fNextID;
BGLView *fView;
ulong fOptions;
bool fSafeMode;
};
#endif /* _GLRENDERER_ROSTER_H */

View File

@ -2,7 +2,7 @@ SubDir HAIKU_TOP src kits opengl ;
SetSubDirSupportedPlatformsBeOSCompatible ;
UsePrivateHeaders opengl ;
UsePrivateHeaders kernel opengl ;
if $(TARGET_PLATFORM) != haiku {
UseHeaders [ FDirName $(HAIKU_TOP) headers os opengl ] : true ;