home *** CD-ROM | disk | FTP | other *** search
- -- 2000.02.26
- -- Clive Green <clivegreen@atlas.co.uk>
-
- ------------------------------------------------------------------------------------------------------
-
- -- this is used to provide a means of driving the programme using messages received from
- -- outside the application (such as Flash 4 movies).
-
- ------------------------------------------------------------------------------------------------------
-
- -- declare properties:
- property main -- main code directory object
- property glue -- propList of recognised glue calls
- property bindings -- propList identifying the methods (& arguments) invoked by known glue calls
- property glueBindings -- active glue options
- property onlineService -- online-related functions
-
- ------------------------------------------------------------------------------------------------------
-
- on new me,L
-
- -- (1) extract and check arguments:
-
- -- check for a parameter list:
- if ilk(L) <> #propList then return [#error:#noParamListSupplied, #msg:"glueService:new"]
-
- -- a reference to the parent codebase is REQUIRED:
- main = L[#main]
- if (ilk(main) <> #instance) then return [#error:#noMainObjectSupplied, #msg:"glueService:new"]
-
- --------------------
-
- -- (2) obtain binding instructions data:
- dm = main.getDataManager()
- glue = dm.getData([#set:#glueCalls])
- bindings = dm.getData([#set:#callBindings])
-
- -- which glue calls are enabled, and what does each do? build a list:
- glueBindings = [:]
- repeat with i = 1 to count(glue)
-
- -- extract glue name and data:
- g = getPropAt(glue,i)
- L = getAt(glue,i)
-
- -- we want online options only ...
- if L[#active] <> 1 then next repeat
-
- -- what is this glue call bound to?
- b = L[#binding]
-
- -- obtain pukka bindings data:
- if not symbolP(b) then next repeat
-
- bd = bindings[b]
- if ilk(bd) <> #propList then next repeat
-
- -- add the bindingID as a member of the list bd obtained:
- bd[#binding] = b
-
- -- add validated glue call:
- glueBindings[g] = bd
-
- end repeat
-
- ------------------------
-
- -- pass my address back to the caller:
- return me
-
- ----------------------------------------------------------------------------------------------------
-
- on glue me,g
-
- -- check glue parameter:
- if voidP(g) then return [#error:#e1013]
-
- -- is glue id a symbol?
- if not symbolP(g) then return [#error:#e1014]
-
- --------------------
-
- -- obtain the bindings data for the glue id g:
- L = glueBindings[g]
-
- -- L is a proplist containing a #methodID, an instance #reference, a bindingID symbol and
- -- (optionally) a list of arguments. Its profile is:
- --
- -- [#method:<#symbol>, #objectReference:<#symbol>, #bindingID:<#symbol> {,#args[:]}]
-
- -- don't continue without a valid entry:
- if ilk(L) <> #propList then return [#error:#e1015, #msg:"glueID =" && g]
-
- --------------------
-
- -- a method name is required:
- m = L[#method]
- if voidP(m) then return [#error:#e1016]
-
- -- only allow symbol method refs:
- if not symbolP(m) then return [#error:#e1017]
-
- --------------------
-
- -- a target object reference is also required:
- o = L[#objectReference]
- if voidP(o) then return [#error:#e1018]
-
- -- only allow symbol refs:
- if not symbolP(o) then return [#error:#e1019]
-
- -- we must resolve the object #name o supplied to a known service object:
- x = main.getServiceManager().getService(o)
- if (ilk(x) <> #instance) then return [#error:#e1020]
-
- -- store the object reference obtained:
- o = x
-
- --------------------
-
- -- extract the bindingID!
- b = L[#binding]
-
- --------------------
-
- -- extract (optional) arguments:
- a = L[#args]
- if not listP(a) then a = [:]
-
- --------------------
-
- -- this option may rely on the presence of dial-up networking:
-
- -- obtain online functions manager as needed:
- if voidP(onlineService) then
-
- sm = main.getServiceManager()
- onlineService = sm.getService(#onlineService)
-
- end if
-
- -- redirect the user to the DUN warning screen as needed:
- if not onlineService.DUNbindingAvailable(b) then
-
- return me.glue(#noDUNmessage)
- exit
-
- end if
-
- --------------------
-
- -- play soundFX (if amy) associated with the glue event g:
- sm = main.getServiceManager()
- fx = sm.getService(#soundFXservice)
-
- fx.playGlueFX(g)
-
- --------------------
-
- -- finally - combine the binding elements into a Lingo expression:
- return call(m,[o],a)
-
- -- note the brackets around o in the above expression - these are used to suppress errors
- -- incurred by calling a non-existent method m within the object o.
-
- ----------------------------------------------------------------------------------------------------