home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #19 / NN_1992_19.iso / spool / comp / sys / mac / hypercar / 3282 < prev    next >
Encoding:
Text File  |  1992-08-29  |  6.0 KB  |  189 lines

  1. Newsgroups: comp.sys.mac.hypercard
  2. Path: sparky!uunet!sun-barr!ames!agate!linus!linus.mitre.org!pacific.mitre.org!heimberg
  3. From: heimberg@pacific.mitre.org (Jeff Heimberger)
  4. Subject: Re: Preventing Script Inspections
  5. Message-ID: <1992Aug28.181637.19501@linus.mitre.org>
  6. Sender: news@linus.mitre.org (News Service)
  7. Nntp-Posting-Host: pacific.mitre.org
  8. Organization: The MITRE Corporation
  9. References: <jpugh-180892214946@90.20.3.212> <1992Aug19.150616.20954@ncar.ucar.edu> <jpugh-200892114834@wolverine.apple.com>
  10. Date: Fri, 28 Aug 1992 18:16:37 GMT
  11. Lines: 176
  12.  
  13. Hi:
  14.  
  15. As a follow-up to another question I asked earlier, I posted the
  16. following question:
  17.  
  18. >[...]
  19. >However, it helped me realize that my bigger problem is how to keep the
  20. >inquisitive user out of my scripts altogether.  I followed the other
  21. >thread on this topic, but realized that even though I do the
  22. >following...
  23. >
  24. >[makeIdiotProof script deleted]
  25. >
  26. >at every opportunity, the user can still get the menubar back merely by
  27. >clicking on the desktop to get the Finder menubar, and then clicking on
  28. >the HyperCard card.  I'm not quite sure how far the inquisitive user
  29. >can get from that small toe-hold.  But I remember seeing some stacks
  30. >seem to be able to prevent the menubar from ever coming back, even when
  31. >you click on the desktop and then on the card.  Can anybody tell me how
  32. >to do that?
  33.  
  34. Charles A. Burchill (burchil@ccu.umanitoba.ca) suggested hiding the
  35. menubar when switching stacks using the resume, suspend, openStack,
  36. closeStack, resumeStack openCard, and closeCard handlers.  He also sent
  37. along some interesting stacks.  However, my experiments on a Quadra 700
  38. under System 7.0.1 produced no messages (according the the Message
  39. Watcher window) when I clicked on the desktop, and then clicked on the
  40. card again.  Thus, the handlers above were effectively useless for a
  41. vigilant effort at keeping nosy users out of my scripts.
  42.  
  43. David G. Simmons (davids@gardener.lanl.gov) also suggested I put a call
  44. to my makeIdiotProof handler in an openCard handler, and in an
  45. openStack handler, and in a resumeStack handler...  But that didn't
  46. work either for the reason described above.
  47.  
  48. Charles also had some ideas about hiding the about stack, background,
  49. and card handlers, and capturing keydowns and the like.  This got me to
  50. thinking, and I came up with the following system.
  51.  
  52. ===== BEGIN Stack Script Handlers =====
  53.  
  54. on openStack
  55.   if the version < 2.0 then
  56.     answer "HyperCard 2.0 or greater required."
  57.     go home
  58.   end if
  59.   set the cantAbort of this stack to true
  60.   global oldUserLevel
  61.   get the userLevel
  62.   put it into oldUserLevel
  63.   set userLevel to one
  64. end openStack
  65.  
  66. on closeStack
  67.   global oldUserLevel
  68.   set userLevel to oldUserLevel
  69. end closeStack
  70.  
  71. on arrowKey
  72.   global permissionFlag
  73.   if permissionFlag is true then pass arrowKey
  74. end arrowKey
  75.  
  76. on commandKeyDown
  77.   global permissionFlag
  78.   if permissionFlag is true then pass commandKeyDown
  79. end commandKeyDown
  80.  
  81. on controlKey
  82.   global permissionFlag
  83.   if permissionFlag is true then pass controlKey
  84. end controlKey
  85.  
  86. on functionKey
  87.   global permissionFlag
  88.   if permissionFlag is true then pass functionKey
  89. end functionKey
  90.  
  91. on mw
  92.   global permissionFlag
  93.   if permissionFlag is true then pass mw
  94. end mw
  95.  
  96. on vw
  97.   global permissionFlag
  98.   if permissionFlag is true then pass vw
  99. end vw
  100.  
  101. on idle
  102.   global permissionFlag
  103.   if permissionFlag is not true then
  104.     hide message
  105.     hide menubar
  106.     set visible of window "message watcher" to false
  107.     set visible of window "variable watcher" to false
  108.   end if
  109.   pass idle
  110. end idle
  111.  
  112. ===== END Stack Script Handlers =====
  113.  
  114. The important handler is the one for idle, which, so long as
  115. permissionFlag is not true, always hides everything of use to the nosy
  116. user.  permissionFlag always starts up as false when the stack is
  117. initially opened.  How does permissionFlag ever become true, I hear you
  118. asking?  You can click a button on the intro card that sends you to a
  119. control card (with neat little functions on it) that has the following
  120. script:
  121.  
  122. ===== BEGIN Control Card Script Handlers =====
  123.  
  124. on openCard
  125.   global permissionFlag
  126.   if permissionFlag is not true then
  127.     ask "Please enter the password:"
  128.     if it is "foo" then
  129.       ask "Are you sure you want to access the control card?"
  130.       if it is "bar" then
  131.         put true into permissionFlag
  132.         set userLevel to five
  133.         show menubar
  134.         set hilite of card button "User Mode Toggle" to true
  135.       end if
  136.     end if
  137.   end if
  138.   if permissionFlag is not true then
  139.     answer "Sorry.  Permission to access the control card denied!"
  140.     go back
  141.   end if
  142. end openCard
  143.  
  144. ===== END Control Card Script Handlers =====
  145.  
  146. Now the idle handler in the stack script doesn't bother to hide all the
  147. stuff, and everything you need for debugging support is available.
  148.  
  149. The card button, "User Mode Toggle," has the following script in it:
  150.  
  151. ===== BEGIN Card Button "User Mode Toggle" Script Handlers =====
  152.  
  153. on mouseUp
  154.   global permissionFlag
  155.   if hilite of me is false then
  156.     put true into permissionFlag
  157.     set userLevel to five
  158.     show menuBar
  159.     set the cantAbort of this stack to false
  160.   else
  161.     put false into permissionFlag
  162.     set userLevel to one
  163.     set the cantAbort of this stack to true
  164.   end if
  165.   set hilite of me to not hilite of me
  166. end mouseUp
  167.  
  168. ===== END Card Button "User Mode Toggle" Script Handlers =====
  169.  
  170. This allows me to pretend I'm a user, and not have access to all the
  171. nifty stuff.  Note that the idle handler knows when permissionFlag
  172. turns false, and immediately hides all the support stuff.
  173.  
  174. My tests of all this suggest that I have no degraded performance of the
  175. stack itself, which does a lot of searching for data, jumping to
  176. various cards, etc.
  177.  
  178. Let me know if you see any flaws.
  179.  
  180. Thanks,
  181.  
  182. Jeff H...
  183.  
  184. ==============================================================================
  185. Jeffrey A. Heimberger                  "Only two things are infinite, the
  186. MITRE Software Engineering Center       universe and human stupidity, and I'm
  187. heimberg@pacific.mitre.org              not sure about the former" - Einstein
  188. ==============================================================================
  189.