home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.sys.mac.hypercard
- Path: sparky!uunet!sun-barr!ames!agate!linus!linus.mitre.org!pacific.mitre.org!heimberg
- From: heimberg@pacific.mitre.org (Jeff Heimberger)
- Subject: Re: Preventing Script Inspections
- Message-ID: <1992Aug28.181637.19501@linus.mitre.org>
- Sender: news@linus.mitre.org (News Service)
- Nntp-Posting-Host: pacific.mitre.org
- Organization: The MITRE Corporation
- References: <jpugh-180892214946@90.20.3.212> <1992Aug19.150616.20954@ncar.ucar.edu> <jpugh-200892114834@wolverine.apple.com>
- Date: Fri, 28 Aug 1992 18:16:37 GMT
- Lines: 176
-
- Hi:
-
- As a follow-up to another question I asked earlier, I posted the
- following question:
-
- >[...]
- >However, it helped me realize that my bigger problem is how to keep the
- >inquisitive user out of my scripts altogether. I followed the other
- >thread on this topic, but realized that even though I do the
- >following...
- >
- >[makeIdiotProof script deleted]
- >
- >at every opportunity, the user can still get the menubar back merely by
- >clicking on the desktop to get the Finder menubar, and then clicking on
- >the HyperCard card. I'm not quite sure how far the inquisitive user
- >can get from that small toe-hold. But I remember seeing some stacks
- >seem to be able to prevent the menubar from ever coming back, even when
- >you click on the desktop and then on the card. Can anybody tell me how
- >to do that?
-
- Charles A. Burchill (burchil@ccu.umanitoba.ca) suggested hiding the
- menubar when switching stacks using the resume, suspend, openStack,
- closeStack, resumeStack openCard, and closeCard handlers. He also sent
- along some interesting stacks. However, my experiments on a Quadra 700
- under System 7.0.1 produced no messages (according the the Message
- Watcher window) when I clicked on the desktop, and then clicked on the
- card again. Thus, the handlers above were effectively useless for a
- vigilant effort at keeping nosy users out of my scripts.
-
- David G. Simmons (davids@gardener.lanl.gov) also suggested I put a call
- to my makeIdiotProof handler in an openCard handler, and in an
- openStack handler, and in a resumeStack handler... But that didn't
- work either for the reason described above.
-
- Charles also had some ideas about hiding the about stack, background,
- and card handlers, and capturing keydowns and the like. This got me to
- thinking, and I came up with the following system.
-
- ===== BEGIN Stack Script Handlers =====
-
- on openStack
- if the version < 2.0 then
- answer "HyperCard 2.0 or greater required."
- go home
- end if
- set the cantAbort of this stack to true
- global oldUserLevel
- get the userLevel
- put it into oldUserLevel
- set userLevel to one
- end openStack
-
- on closeStack
- global oldUserLevel
- set userLevel to oldUserLevel
- end closeStack
-
- on arrowKey
- global permissionFlag
- if permissionFlag is true then pass arrowKey
- end arrowKey
-
- on commandKeyDown
- global permissionFlag
- if permissionFlag is true then pass commandKeyDown
- end commandKeyDown
-
- on controlKey
- global permissionFlag
- if permissionFlag is true then pass controlKey
- end controlKey
-
- on functionKey
- global permissionFlag
- if permissionFlag is true then pass functionKey
- end functionKey
-
- on mw
- global permissionFlag
- if permissionFlag is true then pass mw
- end mw
-
- on vw
- global permissionFlag
- if permissionFlag is true then pass vw
- end vw
-
- on idle
- global permissionFlag
- if permissionFlag is not true then
- hide message
- hide menubar
- set visible of window "message watcher" to false
- set visible of window "variable watcher" to false
- end if
- pass idle
- end idle
-
- ===== END Stack Script Handlers =====
-
- The important handler is the one for idle, which, so long as
- permissionFlag is not true, always hides everything of use to the nosy
- user. permissionFlag always starts up as false when the stack is
- initially opened. How does permissionFlag ever become true, I hear you
- asking? You can click a button on the intro card that sends you to a
- control card (with neat little functions on it) that has the following
- script:
-
- ===== BEGIN Control Card Script Handlers =====
-
- on openCard
- global permissionFlag
- if permissionFlag is not true then
- ask "Please enter the password:"
- if it is "foo" then
- ask "Are you sure you want to access the control card?"
- if it is "bar" then
- put true into permissionFlag
- set userLevel to five
- show menubar
- set hilite of card button "User Mode Toggle" to true
- end if
- end if
- end if
- if permissionFlag is not true then
- answer "Sorry. Permission to access the control card denied!"
- go back
- end if
- end openCard
-
- ===== END Control Card Script Handlers =====
-
- Now the idle handler in the stack script doesn't bother to hide all the
- stuff, and everything you need for debugging support is available.
-
- The card button, "User Mode Toggle," has the following script in it:
-
- ===== BEGIN Card Button "User Mode Toggle" Script Handlers =====
-
- on mouseUp
- global permissionFlag
- if hilite of me is false then
- put true into permissionFlag
- set userLevel to five
- show menuBar
- set the cantAbort of this stack to false
- else
- put false into permissionFlag
- set userLevel to one
- set the cantAbort of this stack to true
- end if
- set hilite of me to not hilite of me
- end mouseUp
-
- ===== END Card Button "User Mode Toggle" Script Handlers =====
-
- This allows me to pretend I'm a user, and not have access to all the
- nifty stuff. Note that the idle handler knows when permissionFlag
- turns false, and immediately hides all the support stuff.
-
- My tests of all this suggest that I have no degraded performance of the
- stack itself, which does a lot of searching for data, jumping to
- various cards, etc.
-
- Let me know if you see any flaws.
-
- Thanks,
-
- Jeff H...
-
- ==============================================================================
- Jeffrey A. Heimberger "Only two things are infinite, the
- MITRE Software Engineering Center universe and human stupidity, and I'm
- heimberg@pacific.mitre.org not sure about the former" - Einstein
- ==============================================================================
-