[futurebasic] Kiosk functions for OS X 10.2 and later

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : November 2003 : Group Archive : Group : All Groups

From: Ken Shmidheiser <kshmidheiser@...>
Date: Mon, 17 Nov 2003 03:10:21 -0500
In Technical Note TN2062 Apple outlines methods 
of controlling user access in OS x 10.2 and newer 
using the new SystemUIMode API.

While the tech note is particularly targeted at 
kiosk developers, it has great potential for FB 
developers who wish to control user access to 
certain features while running an app developed 
in FB. One use that immediately comes to mind is 
in education applications where the developer 
wants student access to system functions limited.

Here is the Apple description from TN 2062:

"Developers working in certain markets need
to add kiosk features to their applications.
That is the ability to lock the user into a
certain application or disable certain
functionality normally available in the
operating system.

"This technote shows several techniques for
building kiosks or incorporating kiosk-like
behavior into an application. This technote
focuses on Mac OS X 10.2 and later because
that system introduced key APIs to support
kiosk development. The text describes which
system versions are required for each
technique."

Previous to Mac OS X 10.2 and the SystemUIMode 
API, getting much of this behavior on Mac OS X 
was not possible or was very difficult to 
accomplish.

My interest in these features came after Michael 
Evans recently asked how to disable the OS X 
"Quit" menu.

Following are a few demo functions I have written 
utilizing the SystemUIMode API:

fn AutoShowMenuBar
fn DisableAppleMenu
fn DisableProcessSwitching
fn DisableForceQuit
fn DisableShutdownLogoutRestart

A couple caveats:

1.) These functions only work as long as a user 
is in the application for which they are written. 
That is, if another application becomes frontmost 
after is called, the user interface mode 
requested will no longer be in effect. Also, if 
the application which called does at some later 
time become frontmost again, the user interface 
mode previously established will come back into 
effect.

2.) The SystemUIMode constants:

_kUIModeContentSuppressed
_kUIModeContentHidden

do not work properly in Jaguar, but are supposed to have been fixed in Panther.

Ken

p.s. Watch for e-mail line breaks and lost 
constant underscores on the Associate server.


begin enum
_kUIModeNormal            = 0
_kUIModeContentSuppressed = 1
_kUIModeContentHidden     = 2
_kUIModeAllHidden         = 3
end enum

#define SystemUIMode as UInt32

begin enum
_kUIOptionAutoShowMenuBar         = 1 << 0
_kUIOptionDisableAppleMenu        = 1 << 2
_kUIOptionDisableProcessSwitch    = 1 << 3
_kUIOptionDisableForceQuit        = 1 << 4
_kUIOptionDisableSessionTerminate = 1 << 5
end enum

#define SystemUIOptions as UInt32

toolbox fn SetSystemUIMode( SystemUIMode inMode,¬
                       SystemUIOptions inOptions ) = OSStatus

/*
The menubar will automatically show itself
when the user moves the mouse into the screen
area that would ordinarily be occupied
by the menubar.
*/
local fn AutoShowMenuBar
dim as OSStatus stat

stat = fn SetSystemUIMode( _kUIModeAllHidden,¬
                    _kUIOptionAutoShowMenuBar ) = stat

end fn

/*
Disable all items in Apple Menu
*/
local fn DisableAppleMenu
dim as OSStatus stat

stat = fn SetSystemUIMode( _kUIModeNormal,¬
               _kUIOptionDisableAppleMenu ) = stat

end fn


/*
Disables process switching using
Command-Tab and Command-Shift-Tab
keyboard equivalents. Window rotation keys
selected in the keyboard preference will also
be disabled.
*/
local fn DisableProcessSwitching
dim as OSStatus stat

stat = fn SetSystemUIMode( _kUIModeAllHidden,¬
                   _kUIOptionDisableAppleMenu ) = stat

end fn

/*
Disables the Force Quit window normally
available via Command-Option-Escape keyboard
equivalent or the Force Quit menu item in the
Apple menu.
*/
local fn DisableForceQuit
dim as OSStatus stat

stat = fn SetSystemUIMode( _kUIModeAllHidden,¬
                   _kUIOptionDisableForceQuit ) = stat

end fn

/*
Disables the Power window that comes when
the power key is pressed. Also disables
Restart, Shut Down, Log Out menu items
the Apple menu.
*/
local fn DisableShutdownLogoutRestart
dim as OSStatus stat

stat = fn SetSystemUIMode( _kUIModeAllHidden,¬
            _kUIOptionDisableSessionTerminate ) = stat

end fn