Produced by Araxis Merge on 4/16/2019 12:20:43 PM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
# | Location | File | Last Modified |
---|---|---|---|
1 | C:\AraxisMergeCompare\Pri_un\CPRS_32_P2_PCE\OR_30_405V60_SRC\10_2\508\VA 508 JAWS Framework\Source | JAWSImplementation.pas | Wed Dec 12 14:05:06 2018 UTC |
2 | C:\AraxisMergeCompare\Pri_re\CPRS v32 P2 PCE Standardization-redacted\CPRS_32_P2_PCE\OR_30_405V60_SRC\10_2\508\VA 508 JAWS Framework\Source | JAWSImplementation.pas | Fri Apr 12 13:36:10 2019 UTC |
Description | Between Files 1 and 2 |
|
---|---|---|
Text Blocks | Lines | |
Unchanged | 4 | 5414 |
Changed | 3 | 6 |
Inserted | 0 | 0 |
Removed | 0 | 0 |
Whitespace | |
---|---|
Character case | Differences in character case are significant |
Line endings | Differences in line endings (CR and LF characters) are ignored |
CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
1 | { ******** ********** ********** ********** ********** ********** ********** ********** | |
2 | { | |
3 | { JAWS FrameWork | |
4 | { | |
5 | { The fr amework ke eps the ja ws scripts updated a nd acts as a middle man to the | |
6 | { Jaws a pplication . | |
7 | { | |
8 | { | |
9 | { | |
10 | { Last m odified by : Chris Be ll | |
11 | { Last m odified: 5 /25/16 | |
12 | { Last M odified De scription: | |
13 | { Adde d splash s creen with version i nformation as well a s an updat e to the n ew log con trol | |
14 | { | |
15 | { | |
16 | { DONE - oJeremy Me rrill -c50 8 : | |
17 | Add some thing that prevents overwritin g of the s cript file s if anoth er | |
18 | app is r unning tha t's using the JAWS D LL } | |
19 | { DONE -oJ eremy Merr ill -c508 : Add chec k in here to look at script ve rsion in J SS file - | |
20 | DN S BELLC: Thi s appears to already be added. Marking a s done } | |
21 | { DONE -oJ eremy Merr ill -c508 : | |
22 | Replace registry c ommunicati on with mu ltiple win dows - sav e strings in the win dow titles | |
23 | Use Enum erateChild Windows ja ws script function i n place of the FindW indow func tion | |
24 | that's b eing used right now. - Enumerat eChildWind ows with a window ha ndle of 0 | |
25 | enumerat es all win dows on th e desktop. Will hav e to use t he first p art of the window | |
26 | title as an ID, an d the last part as t he string values. W ill need t o check fo r a maximu m | |
27 | string l enght, pro bably have to use mu ltiple win dows for l ong text. | |
28 | Will als o beed to have a glo bal window shared by muiltiple instances of the JA WS.SR DLL. } | |
29 | { DONE -oJ eremy Merr ill -c508 : | |
30 | Need to add versio n checking to TVA508 Accessibil ityManager component | |
31 | and JAWS .DLL. War ning needs to displa y just lik e JAWS.DLL and JAWS. } | |
32 | { DONE -oJ eremy Merr ill -c508 :Figure ou t why Delp hi IDE is loading th e DLL when JAWS is r unning - | |
33 | probably has somet hing to do with the VA508 pack age being installed - | |
34 | need to test for c sDesigning some plac e that we' re not tes ting for ( maybe?) } | |
35 | { DONE -oJ eremy Merr ill -c508 : | |
36 | Change A PP_DATA so that "app lication d ata" isn't used - Wi ndows Vist a | |
37 | doesn't us e this val ue - get d ata from W indows API call - DN S BELLC: | |
38 | This is no longer an issue s ince we do not call this funct ion. } | |
39 | ||
40 | { DONE -oC hris Bell -c508 : Ad d log abil ity } | |
41 | { DONE -oC hris Bell -c508 : Me rge dispat cher into DLL to cir cumvent th e UAC warn ing with w indows 7 } | |
42 | { DONE -oC hris Bell -c508 : Co rrect issu e with UIP I since Ja ws runs at a higher priority a s CPRS. Th is limits API calls. } | |
43 | { DONE -oC hris Bell -c508 : Mo dify code to accommo date for u sers lack of Admin r ights. } | |
44 | { TODO -oC hris Bell -c508 : Ma ss code cl eanup. } | |
45 | { TODO -oC hris Bell -c508 : Up date jcScr iptMerge c ode } | |
46 | { ******** ********** ********** ********** ********** ********** ********** ********** } | |
47 | ||
48 | unit JAWSI mplementat ion; | |
49 | ||
50 | interface | |
51 | ||
52 | uses | |
53 | {$IFDEF VE R180} | |
54 | Messages , | |
55 | {$ELSE} | |
56 | Winapi.M essages, | |
57 | {$ENDIF} | |
58 | SysUtils , Windows, Classes, Registry, StrUtils, Forms, Dia logs, | |
59 | ExtCtrls , VAUtils, DateUtils , PSApi, I niFiles, A ctiveX, SH Folder, | |
60 | ShellAPI , VA508Acc essibility Const, fVA 508Dispatc herHiddenW indow, U_L ogObject; | |
61 | ||
62 | {$I 'VA508 ScreenRead erDLLStand ard.inc'} | |
63 | Function F indCommand Switch(Swi tchName: s tring; var ReturnVal ue: string ) | |
64 | : Boolea n; overloa d; | |
65 | Function F indCommand Switch(Swi tchName: s tring): Bo olean; ove rload; | |
66 | ||
67 | exports In itialize, ShutDown, RegisterCu stomBehavi or, Compon entData, S peakText, | |
68 | IsRunnin g, ConfigC hangePendi ng | |
69 | {$IFDEF VE R180} | |
70 | ; | |
71 | {$ELSE} | |
72 | , FindJa ws; | |
73 | {$ENDIF} | |
74 | ||
75 | implementa tion | |
76 | ||
77 | uses fVA50 8HiddenJaw sMainWindo w, FSAPILi b_TLB, Com Obj, tlhel p32, U_Spl ashScreen, | |
78 | Vcl.Cont rols; | |
79 | ||
80 | const | |
81 | ||
82 | JAWS_COM _OBJECT_VE RSION = '8 .0.2173'; | |
83 | VA508_RE G_COMPONEN T_CAPTION = 'Caption '; | |
84 | VA508_RE G_COMPONEN T_VALUE = 'Value'; | |
85 | VA508_RE G_COMPONEN T_CONTROL_ TYPE = 'Co ntrolType' ; | |
86 | VA508_RE G_COMPONEN T_STATE = 'State'; | |
87 | VA508_RE G_COMPONEN T_INSTRUCT IONS = 'In structions '; | |
88 | VA508_RE G_COMPONEN T_ITEM_INS TRUCTIONS = 'ItemIns tructions' ; | |
89 | VA508_RE G_COMPONEN T_DATA_STA TUS = 'Dat aStatus'; | |
90 | SLASH = '\'; | |
91 | JAWS_COM MON_SCRIPT _PATH_TEXT = 'freedo m scientif ic\jaws\'; | |
92 | JAWS_REG ROOT = 'SO FTWARE\Fre edom Scien tific\JAWS '; | |
93 | JAWS_SCR IPTDIR = ' SETTINGS\e nu'; | |
94 | JAWS_INS TALL_DIREC TORY_VAR = 'Target'; | |
95 | JAWS_SHA RED_DIR = 'Shared\'; | |
96 | KEY_WOW6 4_64KEY = $0100; | |
97 | ||
98 | type | |
99 | TCompare Type = (jc Prior, jcI NI, jcLine Items, jcV ersion, jc ScriptMerg e, | |
100 | jcINIM RG, jcLine ItemsMRG); | |
101 | ||
102 | TAddFile s = record | |
103 | FileNa me: string ; | |
104 | end; | |
105 | ||
106 | TFileInf o = record | |
107 | FileNa me: string ; | |
108 | Compar eType: TCo mpareType; | |
109 | Requir ed: Boolea n; | |
110 | Compil e: Boolean ; | |
111 | Exist: Boolean; | |
112 | Add_To _Uses: arr ay of TAdd Files; | |
113 | Depend encies: ar ray of TAd dFiles; | |
114 | end; | |
115 | ||
116 | TFileInf oArray = A rray of TF ileInfo; | |
117 | ||
118 | const | |
119 | JAWS_SCR IPT_NAME = 'VA508JAW S'; | |
120 | JAWS_APP _NAME = 'V A508APP'; | |
121 | JAWS_SCR IPT_VERSIO N = 'VA508 _Script_Ve rsion'; | |
122 | JAWS_FRA MEWORK_USE S = ';VA50 8_FRAMEWOR K_USES'; | |
123 | JAWS_SCR IPT_LIST = 'VA508Scr iptList.IN I'; | |
124 | Compiled ScriptFile Extension = '.JSB'; | |
125 | ScriptFi leExtensio n = '.JSS' ; | |
126 | ScriptDo cExtension = '.JSD'; | |
127 | ConfigFi leExtensio n = '.JCF' ; | |
128 | KeyMapEx tension = '.JKM'; | |
129 | Dictiona ryFileExte nsion = '. JDF'; | |
130 | Jaws_Scr ipt_Folder = 'Jaws S cripts'; | |
131 | ||
132 | JAWS_VER SION_ERROR = ERROR_I NTRO + | |
133 | 'The A ccessibili ty Framewo rk can onl y communic ate with J AWS ' + | |
134 | JAWS_R EQUIRED_VE RSION + CR LF + | |
135 | 'or la ter versio ns. Pleas e update y our versio n of JAWS to a minim um of' + | |
136 | CRLF + JAWS_REQU IRED_VERSI ON + | |
137 | ', or preferably the most recent rel ease, to a llow the A ccessibili ty' + CRLF | |
138 | + 'Fra mework to communicat e with JAW S. If you are getti ng this me ssage' + | |
139 | CRLF + 'and you already ha ve a compa tible vers ion of JAW S, please contact yo ur' | |
140 | + CRLF + 'system administr ator, and request th at they ru n, with ad ministrato r rights,' | |
141 | + CRLF + 'the JA WSUpdate a pplication located i n the \Pro gram Files \VistA\' + | |
142 | CRLF + 'Common F iles direc tory. JAWS Update is not requir ed for JAW S' + CRLF | |
143 | + 'ver sions ' + JAWS_COM_O BJECT_VERS ION + ' an d above.' + CRLF; | |
144 | ||
145 | JAWS_FIL E_ERROR = ERROR_INTR O + | |
146 | 'The J AWS interf ace with t he Accessi bility Fra mework req uires the ability' + | |
147 | CRLF + 'to write files to the hard d isk, but t he followi ng error i s occurrin g trying t o' | |
148 | + CRLF + 'write to the dis k:' + CRLF + '%s' + CRLF + | |
149 | 'Pleas e contact your syste m administ rator in o rder to en sure that your ' + | |
150 | CRLF + 'security privilege s allow yo u to write files to the hard d isk.' + | |
151 | CRLF + 'If you a re sure yo u have the se privile ges, your hard disk may be ful l. Until' | |
152 | + CRLF + 'this p roblem is resolved, the Access ibility Fr amework wi ll not be able to' | |
153 | + CRLF + 'commun icate with JAWS.'; | |
154 | ||
155 | JAWS_USE R_MISSMATC H_ERROR = ERROR_INTR O + | |
156 | 'An er ror has be en detecte d in the s tate of JA WS that wi ll not all ow the' + | |
157 | CRLF + 'Accessib ility Fram ework to c ommunicate with JAWS until JAW S is shut' | |
158 | + CRLF + 'down a nd restart ed. Pleas e restart JAWS at th is time.'; | |
159 | ||
160 | DLL_VERS ION_ERROR = ERROR_IN TRO + | |
161 | 'The A ccessibili ty Framewo rk is at v ersion %s, but the r equired JA WS' + CRLF | |
162 | + 'sup port files are only at version %s. The new suppor t files sh ould have' | |
163 | + CRLF + 'been r eleased wi th the lat est versio n of the s oftware yo u are curr ently' | |
164 | + CRLF + 'runnin g. The Ac cessibilit y Framewor k will not be able t o communic ate' | |
165 | + CRLF + 'with J AWS until these supp ort files are instal led. Plea se contact your' | |
166 | + CRLF + 'system administr ator for a ssistance. '; | |
167 | ||
168 | JAWS_AUT O_NOT_RUNN ING = ERRO R_INTRO + | |
169 | 'The A ccessibili ty Framewo rk was una ble to ide ntify a ru nning inst ance of JA WS.' | |
170 | + ' If you are r unning JAW S ' + JAWS _REQUIRED_ VERSION + ' or later please ' | |
171 | + 'ver ify your s hortcut co ntains the JAWS exec utable nam e' + CRLF + CRLF + | |
172 | 'Examp le: /SCREA DER:JAWS A pplication Name.exe. ' + CRLF + | |
173 | 'If yo u do not h ave access to update the %s sh ortcut, pl ease conta ct your lo cal ' | |
174 | + ' su pport/help personnel .' + CRLF + | |
175 | 'This message bo x will aut omatically close aft er 30 seco nds'; | |
176 | ||
177 | JAWS_NOT _RUNNING = ERROR_INT RO + | |
178 | 'The A ccessibili ty Framewo rk was una ble to ide ntify a ru nning inst ance of JA WS.' | |
179 | + ' Th e Accessib ility Fram ework will not be ab le to comm unicate' + | |
180 | 'with JAWS until the corre ct JAWS ap plication name is pa ssed into the shortc ut for %s .' | |
181 | + CRLF + CRLF + '/SCREADER =:%s is no t running ' + CRLF + | |
182 | 'If yo u do not h ave access to update the %s sh ortcut, pl ease conta ct your lo cal ' | |
183 | + ' su pport/help personnel .' + CRLF + | |
184 | 'This message bo x will aut omatically close aft er 30 seco nds'; | |
185 | ||
186 | JAWS_ERR OR_VERSION = 1; | |
187 | JAWS_ERR OR_FILE_IO = 2; | |
188 | JAWS_ERR OR_USER_PR OBLEM = 3; | |
189 | DLL_ERRO R_VERSION = 4; | |
190 | JAWS_ERR OR_COUNT = 4; | |
191 | JAWS_REL OAD_DELAY = 500; | |
192 | MB_TIMED OUT = 3200 0; | |
193 | ||
194 | var | |
195 | JAWSErro rMessage: array [1 . . JAWS_ERR OR_COUNT] of string = ( | |
196 | JAWS_V ERSION_ERR OR, | |
197 | JAWS_F ILE_ERROR, | |
198 | JAWS_U SER_MISSMA TCH_ERROR, | |
199 | DLL_VE RSION_ERRO R | |
200 | ); | |
201 | ||
202 | JAWSErro rsShown: a rray [1 .. JAWS_ERRO R_COUNT] o f Boolean = ( | |
203 | FALSE, | |
204 | FALSE, | |
205 | FALSE, | |
206 | FALSE | |
207 | ); | |
208 | ||
209 | type | |
210 | TJAWSSay String = f unction(St ringToSpea k: PChar; Interrupt: BOOL) | |
211 | : BOOL ; stdcall; | |
212 | TJAWSRun Script = f unction(Sc riptName: PChar): BO OL; stdcal l; | |
213 | ||
214 | TStartup ID = recor d | |
215 | Handle : HWND; | |
216 | Instan ceID: Inte ger; | |
217 | MsgID: Integer; | |
218 | end; | |
219 | ||
220 | tCompile File = rec ord | |
221 | FileNa me: String ; | |
222 | Compil ed: Boolea n; | |
223 | Compil er: String ; | |
224 | Depend entFile: A rray of tC ompileFile ; | |
225 | functi on Compile File(var R tnMsg: Str ing): Bool ean; | |
226 | end; | |
227 | ||
228 | TJawsRec ord = reco rd | |
229 | Versio n: Double; | |
230 | Compil er: string ; | |
231 | Defaul tScriptDir : String; | |
232 | UserSc riptDir: S tring; | |
233 | FDicti onaryFileN ame: strin g; | |
234 | FConfi gFile: str ing; | |
235 | FKeyMa pFile: str ing; | |
236 | FKeyMa pINIFile: TINIFile; | |
237 | FKeyMa pINIFileMo dified: Bo olean; | |
238 | FAssig nedKeys: T StringList ; | |
239 | FConfi gINIFile: TINIFile; | |
240 | FConfi gINIFileMo dified: Bo olean; | |
241 | FDicti onaryFile: TStringLi st; | |
242 | FDicti onaryFileM odified: B oolean; | |
243 | end; | |
244 | ||
245 | TJAWSMan ager = cla ss | |
246 | strict p rivate | |
247 | FRequi redFilesFo und: Boole an; | |
248 | FMainF orm: TfrmV A508Hidden JawsMainWi ndow; | |
249 | FWasSh utdown: Bo olean; | |
250 | FJAWSF ileError: string; | |
251 | FHidde nJaws: TFo rm; | |
252 | // FRo otScriptFi leName: st ring; | |
253 | // FRo otScriptAp pFileName: string; | |
254 | JAWSAP I: IJawsAp i; | |
255 | private | |
256 | fCompo nentCallBa ckProc: TC omponentDa taRequestP roc; | |
257 | fScrip tFilesChan ged: Boole an; | |
258 | proced ure ShutDo wn; | |
259 | proced ure MakeFi leWritable (FileName: string); | |
260 | proced ure Launch MasterAppl ication; | |
261 | proced ure KillIN IFiles(Sen der: TObje ct); | |
262 | proced ure Reload Configurat ion; | |
263 | proced ure Ensure Window; | |
264 | public | |
265 | constr uctor Crea te; | |
266 | destru ctor Destr oy; overri de; | |
267 | class procedure ShowError( ErrorNumbe r: Integer ); overloa d; | |
268 | class procedure ShowError( ErrorNumbe r: Integer ; | |
269 | data : array of const); o verload; | |
270 | // cla ss functio n GetPathF romJAWS(Pa thID: Inte ger; | |
271 | // DoL owerCase: boolean = TRUE): str ing; | |
272 | class function G etJAWSWind ow: HWND; | |
273 | class function I sRunning(H ighVersion , LowVersi on: Word): BOOL; | |
274 | class function F indJaws(): HWND; | |
275 | functi on Initial ize(Compon entCallBac kProc: TCo mponentDat aRequestPr oc): BOOL; | |
276 | proced ure SendCo mponentDat a(WindowHa ndle: HWND ; DataStat us: LongIn t; | |
277 | Capt ion, Value , data, Co ntrolType, State, In structions , | |
278 | Item Instructio ns: PChar) ; | |
279 | proced ure SpeakT ext(Text: PChar); | |
280 | proced ure Regist erCustomBe havior(Bef ore, After : string; Action: In teger); | |
281 | class function J AWSVersion OK: Boolea n; | |
282 | class function J AWSTalking 2CurrentUs er: Boolea n; | |
283 | functi on FileErr orExists: Boolean; | |
284 | proced ure GetScr iptFiles(v ar info: T FileInfoAr ray); | |
285 | proper ty Require dFilesFoun d: Boolean read FReq uiredFiles Found; | |
286 | proper ty MainFor m: TfrmVA5 08HiddenJa wsMainWind ow read FM ainForm; | |
287 | proper ty ScriptF ilesChange d: Boolean read fScr iptFilesCh anged; | |
288 | end; | |
289 | ||
290 | function M essageBoxT imeOutW(HW ND: HWND; lpText: PW ideChar; l pCaption: PWideChar; | |
291 | uType: U INT; wLang uageId: Wo rd; dwMill iseconds: DWORD): In teger; std call; | |
292 | external user32 na me 'Messag eBoxTimeou tW'; | |
293 | function M essageBoxT imeOutA(HW ND: HWND; lpText: PC har; lpCap tion: PCha r; | |
294 | uType: U INT; wLang uageId: Wo rd; dwMill iseconds: DWORD): In teger; std call; | |
295 | external user32 na me 'Messag eBoxTimeou tA'; | |
296 | ||
297 | var | |
298 | // ***** ********** ********** ********** ********** ********** ********** * | |
299 | // Archi ved Variab le | |
300 | // ***** ********** ********** ********** ********** ********** ********** * | |
301 | // DLLMe ssageID: U INT = 0; | |
302 | ||
303 | JAWSMana ger: TJAWS Manager = nil; | |
304 | JawsReco rd: array of TJawsRe cord; | |
305 | ScriptFi les: TFile InfoArray; | |
306 | JAWSHand le: HWND = 0; | |
307 | UserSpla sh: tSplas hTaskDialo g; | |
308 | ||
309 | {$REGION ' Add export methods t o this reg ion'} | |
310 | ||
311 | // ***** ********** ********** ********** ********** ********** ********** * | |
312 | // Ensur e the JAWS manager ob ject exist | |
313 | // ***** ********** ********** ********** ********** ********** ********** * | |
314 | procedure EnsureMana ger; | |
315 | begin | |
316 | if not a ssigned(JA WSManager) then | |
317 | JAWSMa nager := T JAWSManage r.Create; | |
318 | end; | |
319 | ||
320 | // ******* ********** ********** ********** ********** ********** ********* | |
321 | // Checks to see if the screen reader is currently running | |
322 | // ******* ********** ********** ********** ********** ********** ********* | |
323 | function I sRunning(H ighVersion , LowVersi on: Word): BOOL; std call; | |
324 | begin | |
325 | EnsureMa nager; // need to pr eload the directorie s | |
326 | Result : = TJAWSMan ager.IsRun ning(HighV ersion, Lo wVersion); | |
327 | end; | |
328 | ||
329 | function F indJaws(): BOOL; std call; | |
330 | begin | |
331 | EnsureMa nager; // need to pr eload the directorie s | |
332 | JAWSHand le := TJAW SManager.F indJaws; | |
333 | Result : = (JAWSHan dle <> 0); | |
334 | end; | |
335 | ||
336 | // ******* ********** ********** ********** ********** ********** ********* | |
337 | // Execute d after Is Running re turns TRUE , when the DLL is ac cepted | |
338 | // as the screen rea der of cho ice | |
339 | // ******* ********** ********** ********** ********** ********** ********* | |
340 | function I nitializeS ub(Compone ntCallBack Proc: TCom ponentData RequestPro c): BOOL; | |
341 | begin | |
342 | EnsureMa nager; | |
343 | UserSpla sh.TaskMax Prog := (3 + Length( ScriptFile s)) * Leng th(JawsRec ord) + 1; | |
344 | Result : = JAWSMana ger.Initia lize(Compo nentCallBa ckProc); | |
345 | end; | |
346 | ||
347 | function I nitialize( ComponentC allBackPro c: TCompon entDataReq uestProc) | |
348 | : BOOL; stdcall; | |
349 | var | |
350 | VersionN um: string ; | |
351 | i, Force Num: Integ er; | |
352 | begin | |
353 | // Need to make th readed | |
354 | UserSpla sh := nil; | |
355 | ||
356 | // If no t show tas k dialog | |
357 | ForceNum := -1; | |
358 | if FindC ommandSwit ch('FORCEU PD') then | |
359 | ForceN um := 0 | |
360 | else | |
361 | begin | |
362 | for i := Low(Jaw sRecord) t o High(Jaw sRecord) d o | |
363 | begin | |
364 | Vers ionNum := FloatToStr (JawsRecor d[i].Versi on); | |
365 | if P os('.', Ve rsionNum) > 0 then | |
366 | Ve rsionNum : = Copy(Ver sionNum, 1 , Pos('.', VersionNu m) - 1); | |
367 | if F indCommand Switch('FO RCEUPD' + VersionNum ) then | |
368 | begi n | |
369 | Fo rceNum := StrToIntDe f(VersionN um, 0); | |
370 | br eak; | |
371 | end; | |
372 | end; | |
373 | end; | |
374 | ||
375 | UserSpla sh := tSpl ashTaskDia log.Create (Initializ eSub, Comp onentCallB ackProc, | |
376 | LogInt erface.Act ive, Force Num); | |
377 | try | |
378 | if Log Interface. Active the n | |
379 | User Splash.Log Path := Lo gInterface .LogFile; | |
380 | UserSp lash.Show; | |
381 | Result := UserSp lash.Retur nValue; | |
382 | if Res ult then | |
383 | begin | |
384 | JAWS Manager.En sureWindow ; | |
385 | JAWS Manager.La unchMaster Applicatio n; | |
386 | if J AWSManager .ScriptFil esChanged then | |
387 | begi n | |
388 | JA WSManager. MainForm.C onfigReloa dNeeded; | |
389 | end; | |
390 | end; | |
391 | ||
392 | finally | |
393 | FreeAn dNil(UserS plash); | |
394 | end; | |
395 | ||
396 | end; | |
397 | ||
398 | // ******* ********** ********** ********** ********** ********** ********* | |
399 | // Execute d when the DLL is un loaded or screen rea der is no longer | |
400 | // needed | |
401 | // ******* ********** ********** ********** ********** ********** ********* | |
402 | procedure ShutDown; stdcall; | |
403 | begin | |
404 | if assig ned(JAWSMa nager) the n | |
405 | begin | |
406 | JAWSMa nager.Shut Down; | |
407 | FreeAn dNil(JAWSM anager); | |
408 | end; | |
409 | end; | |
410 | ||
411 | // ******* ********** ********** ********** ********** ********** ********* | |
412 | // Determi nes if con figuration changes a re pending | |
413 | // ******* ********** ********** ********** ********** ********** ********* | |
414 | function C onfigChang ePending: Boolean; s tdcall; | |
415 | begin | |
416 | Result : = FALSE; | |
417 | if assig ned(JAWSMa nager) and assigned( JAWSManage r.MainForm ) and | |
418 | (JAWSM anager.Mai nForm.Conf igChangePe nding) the n | |
419 | Result := TRUE; | |
420 | end; | |
421 | ||
422 | // ******* ********** ********** ********** ********** ********** ********* | |
423 | // Returns Component Data as r equested b y the scre en reader | |
424 | // ******* ********** ********** ********** ********** ********** ********* | |
425 | procedure ComponentD ata(Window Handle: HW ND; DataSt atus: Long Int = DATA _NONE; | |
426 | Caption: PChar = n il; Value: PChar = n il; data: PChar = ni l; | |
427 | ControlT ype: PChar = nil; St ate: PChar = nil; In structions : PChar = nil; | |
428 | ItemInst ructions: PChar = ni l); stdcal l; | |
429 | begin | |
430 | EnsureMa nager; | |
431 | JAWSMana ger.SendCo mponentDat a(WindowHa ndle, Data Status, Ca ption, Val ue, data, | |
432 | Contro lType, Sta te, Instru ctions, It emInstruct ions); | |
433 | end; | |
434 | ||
435 | // ******* ********** ********** ********** ********** ********** ********* | |
436 | // Instruc ts the Scr een Reader to say th e specifie d text | |
437 | // ******* ********** ********** ********** ********** ********** ********* | |
438 | procedure SpeakText( Text: PCha r); stdcal l; | |
439 | begin | |
440 | EnsureMa nager; | |
441 | JAWSMana ger.SpeakT ext(Text); | |
442 | end; | |
443 | ||
444 | // ******* ********** ********** ********** ********** ********** ********* | |
445 | // Registe rs any cus tom behavi or | |
446 | // ******* ********** ********** ********** ********** ********** ********* | |
447 | procedure RegisterCu stomBehavi or(Behavio rType: Int eger; Befo re, After: PChar); | |
448 | begin | |
449 | EnsureMa nager; | |
450 | JAWSMana ger.Regist erCustomBe havior(Bef ore, After , Behavior Type); | |
451 | end; | |
452 | ||
453 | {$ENDREGIO N} | |
454 | {$REGION ' Add TJAWSM anager met hods to th is region' } | |
455 | ||
456 | // ******* ********** ********** ********** ********** ********** ********* | |
457 | // Makes a file writ able | |
458 | // ******* ********** ********** ********** ********** ********** ********* | |
459 | procedure TJAWSManag er.MakeFil eWritable( FileName: string); | |
460 | const | |
461 | {$WARNINGS OFF} // D on't care about plat form speci fic warnin g | |
462 | NON_WRIT ABLE_FILE_ ATTRIB = f aReadOnly or faHidde n; | |
463 | {$WARNINGS ON} | |
464 | WRITABLE _FILE_ATTR IB = faAny File and ( not NON_WR ITABLE_FIL E_ATTRIB); | |
465 | ||
466 | var | |
467 | Attrib: Integer; | |
468 | begin | |
469 | {$WARNINGS OFF} // D on't care about plat form speci fic warnin g | |
470 | Attrib : = FileGetA ttr(FileNa me); | |
471 | {$WARNINGS ON} | |
472 | if (Attr ib and NON _WRITABLE_ FILE_ATTRI B) <> 0 th en | |
473 | begin | |
474 | Attrib := Attrib and WRITA BLE_FILE_A TTRIB; | |
475 | {$WARNINGS OFF} // D on't care about plat form speci fic warnin g | |
476 | if Fil eSetAttr(F ileName, A ttrib) <> 0 then | |
477 | {$WARNINGS ON} | |
478 | FJAW SFileError := 'Could not chang e read-onl y attribut e of file "' + | |
479 | Fi leName + ' "'; | |
480 | ||
481 | end; | |
482 | end; | |
483 | ||
484 | // ******* ********** ********** ********** ********** ********** ********* | |
485 | // Create method for the JawsM anager | |
486 | // ******* ********** ********** ********** ********** ********** ********* | |
487 | constructo r TJAWSMan ager.Creat e; | |
488 | const | |
489 | COMPILER _FILENAME = 'scompil e.exe'; | |
490 | // JAWS_ APP_NAME = 'VA508APP '; | |
491 | ||
492 | function ContinueT oLoad(Temp SubDir: st ring): Boo lean; | |
493 | Var | |
494 | TempUS Dir, TempD SDir, Path ToCheck: S tring; | |
495 | idx1, idx2: Inte ger; | |
496 | begin | |
497 | // Def ault Scrip t | |
498 | TempDS Dir := Get SpecialFol derPath(CS IDL_COMMON _APPDATA) + | |
499 | JAWS _COMMON_SC RIPT_PATH_ TEXT + App endBackSla sh(TempSub Dir); | |
500 | ||
501 | // Use r Script | |
502 | TempUS Dir := Get SpecialFol derPath(CS IDL_APPDAT A) + | |
503 | JAWS _COMMON_SC RIPT_PATH_ TEXT + App endBackSla sh(TempSub Dir); | |
504 | ||
505 | // Scr ipt Folder | |
506 | PathTo Check := ' '; | |
507 | idx1 : = Pos(JAWS _COMMON_SC RIPT_PATH_ TEXT, Temp USDir); | |
508 | idx2 : = Pos(JAWS _COMMON_SC RIPT_PATH_ TEXT, Temp DSDir); | |
509 | ||
510 | PathTo Check := C opy(TempUS Dir, 1, id x1 - 1) + Copy(TempD SDir, idx2 , MaxInt); | |
511 | ||
512 | Result := Direct oryExists( PathToChec k); | |
513 | // Che ck to see if directo ry exist ( they have ran jaws) | |
514 | ||
515 | end; | |
516 | ||
517 | // ******* ********** ********** ********** ********** ********** ********* | |
518 | // Load th e jaws dir ectories v ia regestr ies | |
519 | // ******* ********** ********** ********** ********** ********** ********* | |
520 | procedur e LoadJaws Directorie s; | |
521 | var | |
522 | reg: T Registry; | |
523 | keys: TStringLis t; | |
524 | i: Int eger; | |
525 | key, D ir, SubDir , Version: string; | |
526 | begin | |
527 | keys : = TStringL ist.Create ; | |
528 | try | |
529 | reg := TRegist ry.Create( KEY_READ o r KEY_WOW6 4_64KEY); | |
530 | try | |
531 | re g.RootKey := HKEY_LO CAL_MACHIN E; | |
532 | re g.OpenKey( JAWS_REGRO OT, FALSE) ; | |
533 | re g.GetKeyNa mes(keys); | |
534 | fo r i := 0 t o keys.Cou nt - 1 do | |
535 | be gin | |
536 | Version := keys[i]; | |
537 | key := JAW S_REGROOT + '\' + ke ys[i] + '\ '; | |
538 | reg.CloseK ey; | |
539 | SubDir := Version + '\' + JAWS _SCRIPTDIR ; | |
540 | if reg.Ope nKey(key, FALSE) the n | |
541 | begin | |
542 | Dir := L owerCase(r eg.ReadStr ing(JAWS_I NSTALL_DIR ECTORY_VAR )); | |
543 | LogInter face.LogTe xt('Jaws F ound', 'Ve rsion: ' + Version + #13#10 + | |
544 | 'Direc tory: ' + Dir); | |
545 | ||
546 | Dir := A ppendBackS lash(Dir) + COMPILER _FILENAME; | |
547 | if FileE xists(Dir) and Conti nueToLoad( SubDir) th en | |
548 | begin | |
549 | SetLen gth(JawsRe cord, Leng th(JawsRec ord) + 1); | |
550 | JawsRe cord[high( JawsRecord )].Version := | |
551 | StrT ofloatDef( Version, - 1); | |
552 | JawsRe cord[high( JawsRecord )].Compile r := Dir; | |
553 | Dir := GetSpecia lFolderPat h(CSIDL_CO MMON_APPDA TA) + | |
554 | JAWS _COMMON_SC RIPT_PATH_ TEXT + App endBackSla sh(SubDir) ; | |
555 | JawsRe cord[high( JawsRecord )].Default ScriptDir := Dir; | |
556 | Dir := GetSpecia lFolderPat h(CSIDL_AP PDATA) + | |
557 | JAWS _COMMON_SC RIPT_PATH_ TEXT + App endBackSla sh(SubDir) ; | |
558 | JawsRe cord[high( JawsRecord )].UserScr iptDir := Dir; | |
559 | end; | |
560 | end; | |
561 | ||
562 | en d; | |
563 | fina lly | |
564 | re g.free; | |
565 | end; | |
566 | finall y | |
567 | keys .free; | |
568 | end; | |
569 | end; | |
570 | ||
571 | // ******* ********** ********** ********** ********** ********** ********* | |
572 | // Ensure all the re quired fil es are pre sent in th e vista fo lder | |
573 | // ******* ********** ********** ********** ********** ********** ********* | |
574 | procedur e FindJAWS RequiredFi les; | |
575 | var | |
576 | path: string; | |
577 | i: Int eger; | |
578 | LogTxt : string; | |
579 | begin | |
580 | SetLen gth(path, MAX_PATH); | |
581 | SetLen gth(path, GetModuleF ileName(HI nstance, P Char(path) , Length(p ath))); | |
582 | path : = ExtractF ilePath(pa th); | |
583 | path : = AppendBa ckSlash(pa th); | |
584 | // loo k for the script fil es in the same direc tory as th is DLL | |
585 | ||
586 | FRequi redFilesFo und := TRU E; | |
587 | ||
588 | // Loo k up the f iles | |
589 | if Len gth(Script Files) = 0 then | |
590 | GetS criptFiles (ScriptFil es); | |
591 | ||
592 | if Len gth(Script Files) > 0 then | |
593 | begin | |
594 | LogI nterface.L ogText(' S cripts ', | |
595 | 'F older:' + ExtractFil ePath(Scri ptFiles[0] .FileName) ) | |
596 | end | |
597 | else | |
598 | LogI nterface.L ogText(' S cripts ', | |
599 | '! ! No files to lookup !! Please check the VA508Scri ptList.INI '); | |
600 | ||
601 | // now ensure th at the req uired file s are ther e | |
602 | for i := low(Scr iptFiles) to high(Sc riptFiles) do | |
603 | begin | |
604 | LogT xt := 'Fil e Name:' + ExtractFi leName(Scr iptFiles[i ].FileName ); | |
605 | if S criptFiles [i].Requir ed then | |
606 | begi n | |
607 | Lo gTxt := Lo gTxt + #13 #10 + 'Req uired: YES '; | |
608 | if not Scrip tFiles[i]. Exist then | |
609 | be gin | |
610 | FRequiredF ilesFound := FALSE; | |
611 | LogTxt := LogTxt + # 13#10 + 'F ile Found: NO'; | |
612 | // break; | |
613 | en d | |
614 | el se | |
615 | LogTxt := LogTxt + # 13#10 + 'F ile Found: YES'; | |
616 | end | |
617 | else | |
618 | begi n | |
619 | Lo gTxt := Lo gTxt + #13 #10 + 'Req uired: NO' ; | |
620 | if not Scrip tFiles[i]. Exist then | |
621 | LogTxt := LogTxt + # 13#10 + 'F ile Found: NO' | |
622 | el se | |
623 | LogTxt := LogTxt + # 13#10 + 'F ile Found: YES'; | |
624 | ||
625 | end; | |
626 | ||
627 | LogI nterface.L ogText(Int ToStr(i + 1) + '/' + IntToStr( Length(Scr iptFiles) | |
628 | - 1), LogTxt ); | |
629 | end; | |
630 | end; | |
631 | ||
632 | begin | |
633 | SetLengt h(JawsReco rd, 0); | |
634 | LoadJaws Directorie s; | |
635 | if Lengt h(JawsReco rd) > 0 th en | |
636 | // RTC Def ect 609561 | |
637 | // Origina l code --- ---------- ---------- ---------- ---------- ---------- begin | |
638 | { | |
639 | FindJA WSRequired Files; | |
640 | if not F RequiredFi lesFound t hen | |
641 | ShowEr ror(JAWS_E RROR_FILE_ IO, ['Requ ired files missing'] ); | |
642 | } | |
643 | // Origina l code --- ---------- ---------- ---------- ---------- ---------- -- end | |
644 | // Modifie d code --- ---------- ---------- ---------- ---------- ---------- begin | |
645 | begin //: Looki ng for JAW SRequired Files only if the re gistry ent ries were found | |
646 | Find JAWSRequir edFiles; | |
647 | if n ot FRequir edFilesFou nd then | |
648 | Sh owError(JA WS_ERROR_F ILE_IO, [' Required f iles missi ng']); | |
649 | end; | |
650 | // Modifie d code --- ---------- ---------- ---------- ---------- ---------- -- end | |
651 | end; | |
652 | ||
653 | // ******* ********** ********** ********** ********** ********** ********* | |
654 | // Destroy method fo r the Jaws Manager | |
655 | // ******* ********** ********** ********** ********** ********** ********* | |
656 | destructor TJAWSMana ger.Destro y; | |
657 | begin | |
658 | SetLengt h(JawsReco rd, 0); | |
659 | ShutDown ; | |
660 | inherite d; | |
661 | end; | |
662 | ||
663 | // ******* ********** ********** ********** ********** ********** ********* | |
664 | // Returns if an err or has bee n captured | |
665 | // ******* ********** ********** ********** ********** ********** ********* | |
666 | function T JAWSManage r.FileErro rExists: B oolean; | |
667 | begin | |
668 | Result : = (FJAWSFi leError <> ''); | |
669 | end; | |
670 | ||
671 | // ******* ********** ********** ********** ********** ********** ********* | |
672 | // Fills o ut the fil e array wi th sciprts to be mov ed over | |
673 | // ******* ********** ********** ********** ********** ********** ********* | |
674 | procedure TJAWSManag er.GetScri ptFiles(va r info: TF ileInfoArr ay); | |
675 | var | |
676 | ScriptsF ile: TINIF ile; | |
677 | path, Sc riptsFileN ame, TmpSt r: string; | |
678 | Scripts: TStringLi st; | |
679 | i, X, Y: Integer; | |
680 | ||
681 | function FindScrip tFileLocat ion(aBaseP ath, aFile Name: stri ng): Strin g; | |
682 | var | |
683 | Script Dir: Strin g; | |
684 | begin | |
685 | aBaseP ath := App endBackSla sh(aBasePa th); | |
686 | Script Dir := Jaw s_Script_F older; | |
687 | Script Dir := App endBackSla sh(ScriptD ir); | |
688 | if Fil eExists(aB asePath + ScriptDir + aFileNam e) then | |
689 | Resu lt := aBas ePath + Sc riptDir | |
690 | else i f FileExis ts(aBasePa th + aFile Name) then | |
691 | Resu lt := aBas ePath | |
692 | else | |
693 | Resu lt := ''; | |
694 | end; | |
695 | ||
696 | function LoadInfoR ec(aPatchD ir, aFileN ame, Value : String): TFileInfo ; | |
697 | var | |
698 | TmpCom pare: stri ng; | |
699 | FoundP ath: Strin g; | |
700 | TmpStr Lst: TStri ngList; | |
701 | i: Int eger; | |
702 | begin | |
703 | SetLen gth(Result .Add_To_Us es, 0); | |
704 | FoundP ath := Fin dScriptFil eLocation( aPatchDir, aFileName ); | |
705 | if Fou ndPath <> '' then | |
706 | begin | |
707 | Resu lt.FileNam e := Appen dBackSlash (FoundPath ) + aFileN ame; | |
708 | Resu lt.Exist : = FileExis ts(Result. FileName); | |
709 | end | |
710 | else | |
711 | begin | |
712 | Resu lt.FileNam e := aFile Name; | |
713 | Resu lt.Exist : = FALSE; | |
714 | end; | |
715 | ||
716 | TmpCom pare := Pi ece(Value, '|', 1); | |
717 | if Upp erCase(Tmp Compare) = 'JCPRIOR' then | |
718 | Resu lt.Compare Type := jc Prior | |
719 | else i f UpperCas e(TmpCompa re) = 'JCI NI' then | |
720 | Resu lt.Compare Type := jc INI | |
721 | else i f UpperCas e(TmpCompa re) = 'JCL INEITEMS' then | |
722 | Resu lt.Compare Type := jc LineItems | |
723 | else i f UpperCas e(TmpCompa re) = 'JCV ERSION' th en | |
724 | Resu lt.Compare Type := jc Version | |
725 | else i f UpperCas e(TmpCompa re) = 'JCS CRIPTMERGE ' then | |
726 | Resu lt.Compare Type := jc ScriptMerg e | |
727 | else i f UpperCas e(TmpCompa re) = 'JCI NIMRG' the n | |
728 | Resu lt.Compare Type := jc INIMRG | |
729 | else i f UpperCas e(TmpCompa re) = 'JCL INEITEMSMR G' then | |
730 | Resu lt.Compare Type := jc LineItemsM RG; | |
731 | ||
732 | TmpCom pare := Pi ece(Value, '|', 2); | |
733 | if Upp erCase(Tmp Compare) = 'TRUE' th en | |
734 | Resu lt.Require d := TRUE | |
735 | else i f UpperCas e(TmpCompa re) = 'FAL SE' then | |
736 | Resu lt.Require d := FALSE ; | |
737 | ||
738 | TmpCom pare := Pi ece(Value, '|', 3); | |
739 | if Upp erCase(Tmp Compare) = 'TRUE' th en | |
740 | Resu lt.Compile := TRUE | |
741 | else i f UpperCas e(TmpCompa re) = 'FAL SE' then | |
742 | Resu lt.Compile := FALSE; | |
743 | ||
744 | TmpCom pare := Pi ece(Value, '|', 4); | |
745 | if Tri m(TmpCompa re) <> '' then | |
746 | begin | |
747 | TmpC ompare := Piece(TmpC ompare, '[ ', 2); | |
748 | TmpC ompare := Piece(TmpC ompare, '] ', 1); | |
749 | TmpS trLst := T StringList .Create; | |
750 | try | |
751 | Tm pStrLst.Te xt := TmpC ompare; | |
752 | fo r i := 0 t o TmpStrLs t.Count - 1 do | |
753 | be gin | |
754 | SetLength( Result.Add _To_Uses, Length(Res ult.Add_To _Uses) + 1 ); | |
755 | Result.Add _To_Uses[H igh(Result .Add_To_Us es)].FileN ame := | |
756 | TmpStrLs t.Strings[ i]; | |
757 | en d; | |
758 | fina lly | |
759 | Tm pStrLst.fr ee; | |
760 | end; | |
761 | end; | |
762 | ||
763 | end; | |
764 | ||
765 | function LoadOverW rites(Sect ionName: S tring): Bo olean; | |
766 | var | |
767 | i, X: Integer; | |
768 | FileNa me, extNam e: String; | |
769 | begin | |
770 | if Scr iptsFile.S ectionExis ts(Section Name) then | |
771 | begin | |
772 | Resu lt := TRUE ; | |
773 | Scri ptsFile.Re adSectionV alues(Sect ionName, S cripts); | |
774 | for i := 0 to Scripts.Co unt - 1 do | |
775 | begi n | |
776 | // if script is named after the app then r eplace | |
777 | Fi leName := Piece(Extr actFileNam e(Scripts. Names[i]), '.', 1); | |
778 | ex tName := P iece(Extra ctFileName (Scripts.N ames[i]), '.', 2); | |
779 | // Section n ame should be the ap plications name | |
780 | if UpperCase (FileName) = UpperCa se(Section Name) then | |
781 | be gin | |
782 | if Pos('MR G', UpperC ase(Piece( Scripts.Va lues[Scrip ts.Names[i ]], '|', | |
783 | 1))) = 0 then | |
784 | begin | |
785 | for X := Low(info) to High(i nfo) do | |
786 | begin | |
787 | if (Up perCase(Pi ece(Extrac tFileName( info[X].Fi leName), ' .', 1)) | |
788 | = Up perCase(JA WS_APP_NAM E)) and | |
789 | (Upp erCase(Pie ce(Extract FileName(i nfo[X].Fil eName), '. ', 2)) | |
790 | = Up perCase(ex tName)) th en | |
791 | begin | |
792 | // o verwrite i ts corrisp onding va5 08app file | |
793 | info [X] := Loa dInfoRec(p ath, Scrip ts.Names[i ], | |
794 | Sc ripts.Valu es[Scripts .Names[i]] ); | |
795 | brea k; | |
796 | end; | |
797 | end; | |
798 | end | |
799 | else | |
800 | begin | |
801 | SetLengt h(info, Le ngth(info) + 1); | |
802 | info[Hig h(info)] : = LoadInfo Rec(path, Scripts.Na mes[i], | |
803 | Script s.Values[S cripts.Nam es[i]]); | |
804 | end; | |
805 | en d | |
806 | el se | |
807 | be gin | |
808 | SetLength( info, Leng th(info) + 1); | |
809 | info[High( info)] := LoadInfoRe c(path, Sc ripts.Name s[i], | |
810 | Scripts. Values[Scr ipts.Names [i]]); | |
811 | en d; | |
812 | end; | |
813 | end | |
814 | else | |
815 | Resu lt := FALS E; | |
816 | end; | |
817 | ||
818 | begin | |
819 | SetLengt h(path, MA X_PATH); | |
820 | SetLengt h(path, Ge tModuleFil eName(HIns tance, PCh ar(path), Length(pat h))); | |
821 | path := ExtractFil ePath(path ); | |
822 | path := AppendBack Slash(path ); | |
823 | ScriptsF ileName := FindScrip tFileLocat ion(path, JAWS_SCRIP T_LIST); | |
824 | if Scrip tsFileName <> '' the n | |
825 | begin | |
826 | Script sFileName := AppendB ackSlash(S criptsFile Name) + JA WS_SCRIPT_ LIST; | |
827 | if Fil eExists(Sc riptsFileN ame) then | |
828 | begin | |
829 | Scri ptsFile := TINIFile. Create(Scr iptsFileNa me); | |
830 | Scri pts := TSt ringList.C reate; | |
831 | try | |
832 | Se tLength(in fo, 0); | |
833 | Sc riptsFile. ReadSectio nValues('S CRIPTS', S cripts); | |
834 | fo r i := 0 t o Scripts. Count - 1 do | |
835 | be gin | |
836 | SetLength( info, Leng th(info) + 1); | |
837 | info[High( info)] := LoadInfoRe c(path, Sc ripts.Name s[i], | |
838 | Scripts. Values[Scr ipts.Names [i]]); | |
839 | en d; | |
840 | ||
841 | // Now check for custo m overwrit es | |
842 | // first loo k for gene ral App | |
843 | Tm pStr := Pi ece(Extrac tFileName( ParamStr(0 )), '.', 1 ); | |
844 | Lo adOverWrit es(TmpStr) ; | |
845 | ||
846 | // second lo ok for a s pecific ve rsion | |
847 | Tm pStr := Tm pStr + '|' + FileVer sionValue( ParamStr(0 ), | |
848 | FILE_VER_F ILEVERSION ); | |
849 | Lo adOverWrit es(TmpStr) ; | |
850 | ||
851 | fina lly | |
852 | Sc riptsFile. free; | |
853 | end; | |
854 | end; | |
855 | end; | |
856 | ||
857 | // Now u pdate the dependenci es | |
858 | for i := Low(info) to High(i nfo) do | |
859 | begin | |
860 | if Len gth(info[i ].Add_To_U ses) > 0 t hen | |
861 | begin | |
862 | for X := Low(i nfo[i].Add _To_Uses) to High(in fo[i].Add_ To_Uses) d o | |
863 | begi n | |
864 | fo r Y := Low (info) to High(info) do | |
865 | be gin | |
866 | if UpperCa se(Extract FileName(i nfo[Y].Fil eName)) | |
867 | = UpperC ase(info[i ].Add_To_U ses[X].Fil eName) the n | |
868 | begin | |
869 | SetLengt h(info[Y]. Dependenci es, Length (info[Y].D ependencie s) + 1); | |
870 | info[Y]. Dependenci es[High(in fo[Y].Depe ndencies)] .FileName := | |
871 | Extrac tFileName( info[i].Fi leName); | |
872 | break; | |
873 | end; | |
874 | en d; | |
875 | end; | |
876 | SetL ength(info [i].Add_To _Uses, 0); | |
877 | end; | |
878 | end; | |
879 | ||
880 | end; | |
881 | ||
882 | // ******* ********** ********** ********** ********** ********** ********* | |
883 | // Return the handle of the Ja ws applica tion | |
884 | // ******* ********** ********** ********** ********** ********** ********* | |
885 | class func tion TJAWS Manager.Ge tJAWSWindo w: HWND; | |
886 | const | |
887 | VISIBLE_ WINDOW_CLA SS: PChar = 'JFWUI2' ; | |
888 | VISIBLE_ WINDOW_TIT LE: PChar = 'JAWS'; | |
889 | VISIBLE_ WINDOW_TIT LE2: PChar = 'Remote JAWS'; | |
890 | begin | |
891 | if JAWSH andle = 0 then | |
892 | begin | |
893 | JAWSHa ndle := Fi ndWindow(V ISIBLE_WIN DOW_CLASS, VISIBLE_W INDOW_TITL E); | |
894 | if JAW SHandle = 0 then | |
895 | JAWS Handle := FindWindow (VISIBLE_W INDOW_CLAS S, VISIBLE _WINDOW_TI TLE2); | |
896 | if JAW SHandle = 0 then | |
897 | JAWS Handle := FindJaws() ; | |
898 | end; | |
899 | ||
900 | Result : = JAWSHand le; | |
901 | end; | |
902 | ||
903 | // ******* ********** ********** ********** ********** ********** ********* | |
904 | // Return the handle of an app lication | |
905 | // ******* ********** ********** ********** ********** ********** ********* | |
906 | function F indHandle( exeFileNam e: string) : HWND; | |
907 | type | |
908 | TEInfo = record | |
909 | PID: D WORD; | |
910 | HWND: THandle; | |
911 | end; | |
912 | ||
913 | function CallBack( Wnd: DWORD ; var EI: TEInfo): B OOL; stdca ll; | |
914 | var | |
915 | PID: D WORD; | |
916 | begin | |
917 | GetWin dowThreadP rocessID(W nd, @PID); ; | |
918 | Result := (PID < > EI.PID) and (GetPa rent(Wnd) <> 0); | |
919 | // Res ult := (PI D <> EI.PI D) or (not IsWindowV isible(Wnd )) or | |
920 | // (no t IsWindow Enabled(Wn d)); | |
921 | if not Result th en | |
922 | EI.H WND := Wnd ; | |
923 | end; | |
924 | ||
925 | var | |
926 | Continue Loop: BOOL ; | |
927 | FSnapsho tHandle: T Handle; | |
928 | FProcess Entry32: T ProcessEnt ry32; | |
929 | EInfo: T EInfo; | |
930 | begin | |
931 | Result : = 0; | |
932 | FSnapsho tHandle := CreateToo lhelp32Sna pshot(TH32 CS_SNAPPRO CESS, 0); | |
933 | FProcess Entry32.dw Size := Si zeOf(FProc essEntry32 ); | |
934 | Continue Loop := Pr ocess32Fir st(FSnapsh otHandle, FProcessEn try32); | |
935 | ||
936 | while In teger(Cont inueLoop) <> 0 do | |
937 | begin | |
938 | if ((U pperCase(E xtractFile Name(FProc essEntry32 .szExeFile )) | |
939 | = Up perCase(ex eFileName) ) or (Uppe rCase(FPro cessEntry3 2.szExeFil e) | |
940 | = Up perCase(ex eFileName) )) then | |
941 | begin | |
942 | EInf o.PID := F ProcessEnt ry32.th32P rocessID; | |
943 | EInf o.HWND := 0; | |
944 | Enum Windows(@C allBack, I nteger(@EI nfo)); | |
945 | Resu lt := EInf o.HWND; | |
946 | end; | |
947 | Contin ueLoop := Process32N ext(FSnaps hotHandle, FProcessE ntry32); | |
948 | end; | |
949 | CloseHan dle(FSnaps hotHandle) ; | |
950 | end; | |
951 | ||
952 | // ******* ********** ********** ********** ********** ********** ********* | |
953 | // Is jaws running? and if so set the re turn var t o the hand le | |
954 | // ******* ********** ********** ********** ********** ********** ********* | |
955 | class func tion TJAWS Manager.Fi ndJaws(): HWND; | |
956 | const | |
957 | ORIGNIAL _JAWS_EXE = 'jfw.exe '; | |
958 | var | |
959 | JawsPara m, ErrMsg: String; | |
960 | reg: TRe gistry; | |
961 | CanConti nue: Boole an; | |
962 | begin | |
963 | // assum e its not running | |
964 | Result : = 0; | |
965 | ||
966 | // Allow to turn o ff jaws if not wante d | |
967 | FindComm andSwitch( 'SCREADER' , JawsPara m); | |
968 | CanConti nue := not (UpperCase (JawsParam ) = 'NONE' ); | |
969 | ||
970 | if not C anContinue then | |
971 | LogInt erface.Log Text('Jaws Run ', | |
972 | 'Jaw s Framewor k explicti ly turnded off via S CREADER pa rameter'); | |
973 | ||
974 | // check for the r egistry | |
975 | if CanCo ntinue the n | |
976 | begin | |
977 | // che ck if JAWS has been installed by looking at the re gistry | |
978 | reg := TRegistry .Create(KE Y_READ or KEY_WOW64_ 64KEY); | |
979 | try | |
980 | reg. RootKey := HKEY_LOCA L_MACHINE; | |
981 | CanC ontinue := reg.KeyEx ists(JAWS_ REGROOT); | |
982 | finall y | |
983 | reg. free; | |
984 | end; | |
985 | end; | |
986 | ||
987 | if not C anContinue then | |
988 | LogInt erface.Log Text('Jaws Run ', ' Jaws regis try not fo und'); | |
989 | ||
990 | // look for the ex e (jaws 16 and up) | |
991 | if CanCo ntinue the n | |
992 | begin | |
993 | Result := FindHa ndle(ORIGN IAL_JAWS_E XE); | |
994 | ||
995 | // can t find exp ected app running so look for paramater | |
996 | if Res ult = 0 th en | |
997 | begin | |
998 | Jaws Param := ' '; | |
999 | Find CommandSwi tch('SCREA DER', Jaws Param); | |
1000 | if T rim(JawsPa ram) <> '' then | |
1001 | begi n | |
1002 | // Look for the parama ter exe | |
1003 | Re sult := Fi ndHandle(J awsParam); | |
1004 | if Result = 0 then | |
1005 | be gin | |
1006 | // could n ot find th e paramete r exe runn ing | |
1007 | ErrMsg := Format(JAW S_NOT_RUNN ING, | |
1008 | [Extract FileName(A pplication .ExeName), JawsParam , | |
1009 | ExtractF ileName(Ap plication. ExeName)]) ; | |
1010 | {$IFDEF VE R180} | |
1011 | MessageBox TimeOutA(A pplication .Handle, P Char(ErrMs g), | |
1012 | 'JAWS Ac cessibilit y Detectio n Error', MB_OK or M B_ICONERRO R or | |
1013 | MB_TASKM ODAL or MB _TOPMOST, 0, 30000); | |
1014 | {$ELSE} | |
1015 | MessageBox TimeOutW(A pplication .Handle, P Char(ErrMs g), | |
1016 | 'JAWS Ac cessibilit y Detectio n Error', MB_OK or M B_ICONERRO R or | |
1017 | MB_TASKM ODAL or MB _TOPMOST, 0, 30000); | |
1018 | {$ENDIF} | |
1019 | LogInterfa ce.LogText ('Jaws Run ', | |
1020 | 'Instanc e Name: !! No runnin g instance s of JAWSf ound !!'); | |
1021 | ||
1022 | en d | |
1023 | el se | |
1024 | LogInterfa ce.LogText ('Jaws Run ', 'Inst ance Name: ' + JawsP aram); | |
1025 | end | |
1026 | else | |
1027 | begi n | |
1028 | // no parame ter and ex pected exe is not ru nning | |
1029 | {$IFDEF VE R180} | |
1030 | Er rMsg := Fo rmat(JAWS_ AUTO_NOT_R UNNING, | |
1031 | [ExtractFi leName(App lication.E xeName), | |
1032 | ExtractFil eName(Appl ication.Ex eName)]); | |
1033 | Me ssageBoxTi meOutA(App lication.H andle, PCh ar(ErrMsg) , | |
1034 | 'JAWS Acce ssibility Detection Error', MB _OK or MB_ ICONERROR or | |
1035 | MB_TASKMOD AL or MB_T OPMOST, 0, 30000); | |
1036 | {$ELSE} | |
1037 | Er rMsg := Fo rmat(JAWS_ AUTO_NOT_R UNNING, | |
1038 | [ExtractFi leName(App lication.E xeName), | |
1039 | ExtractFil eName(Appl ication.Ex eName)]); | |
1040 | Me ssageBoxTi meOutW(App lication.H andle, PCh ar(ErrMsg) , | |
1041 | 'JAWS Acce ssibility Detection Error', MB _OK or MB_ ICONERROR or | |
1042 | MB_TASKMOD AL or MB_T OPMOST, 0, 30000); | |
1043 | {$ENDIF} | |
1044 | end; | |
1045 | ||
1046 | // s et the glo bal and re turn | |
1047 | JAWS Handle := Result; | |
1048 | ||
1049 | end | |
1050 | else | |
1051 | LogI nterface.L ogText('Ja ws Run ', 'Instance Name: ' + ORIGNIAL_ JAWS_EXE); | |
1052 | ||
1053 | end; | |
1054 | end; | |
1055 | ||
1056 | // ******* ********** ********** ********** ********** ********** ********* | |
1057 | // Initial setup for JawsManag er | |
1058 | // ******* ********** ********** ********** ********** ********** ********* | |
1059 | function T JAWSManage r.Initiali ze(Compone ntCallBack Proc | |
1060 | : TCompo nentDataRe questProc) : BOOL; | |
1061 | var | |
1062 | DestPath , StatText , LogTxt: string; | |
1063 | ScriptFi leChanges: Boolean; | |
1064 | LastFile Updated: B oolean; | |
1065 | // Compi leCommands : TStringL ist; | |
1066 | CompileF iles: Arra y of tComp ileFile; | |
1067 | ArryCnt: Integer; | |
1068 | ||
1069 | // ***** ********** ********** ********** ********** ********** ********** * | |
1070 | // Retri eves the J AWS_SCRIPT _VERSION f rom a scri pt file | |
1071 | // ***** ********** ********** ********** ********** ********** ********** * | |
1072 | function GetVersio n(FileName : string): Integer; | |
1073 | var | |
1074 | list: TStringLis t; | |
1075 | p, i: Integer; | |
1076 | line: string; | |
1077 | workin g: Boolean ; | |
1078 | begin | |
1079 | Result := 0; | |
1080 | list : = TStringL ist.Create ; | |
1081 | try | |
1082 | list .LoadFromF ile(FileNa me); | |
1083 | i := 0; | |
1084 | work ing := TRU E; | |
1085 | whil e working and (i < l ist.Count) do | |
1086 | begi n | |
1087 | li ne := list [i]; | |
1088 | p := Pos('=' , line); | |
1089 | if p > 0 the n | |
1090 | be gin | |
1091 | if Trim(Co py(line, 1 , p - 1)) = JAWS_SCR IPT_VERSIO N then | |
1092 | begin | |
1093 | line := Trim(Copy( line, p + 1, MaxInt) ); | |
1094 | if Copy( line, Leng th(line), 1) = ',' t hen | |
1095 | delete (line, Len gth(line), 1); | |
1096 | Result : = StrToInt Def(line, 0); | |
1097 | working := FALSE; | |
1098 | end; | |
1099 | en d; | |
1100 | In c(i); | |
1101 | end; | |
1102 | finall y | |
1103 | list .free; | |
1104 | end; | |
1105 | end; | |
1106 | ||
1107 | // ******* ********** ********** ********** ********** ********** ********* | |
1108 | // Compare s versions between t wo script files | |
1109 | // ******* ********** ********** ********** ********** ********** ********* | |
1110 | function VersionDi fferent(Fr omFile, To File: stri ng): Boole an; | |
1111 | var | |
1112 | FromVe rsion, ToV ersion: In teger; | |
1113 | begin | |
1114 | FromVe rsion := G etVersion( FromFile); | |
1115 | ToVers ion := Get Version(To File); | |
1116 | Result := (FromV ersion > T oVersion); | |
1117 | end; | |
1118 | ||
1119 | // ******* ********** ********** ********** ********** ********** ********* | |
1120 | // Determi nes if a l ine From F romFile is missing i n the ToFi le | |
1121 | // ******* ********** ********** ********** ********** ********** ********* | |
1122 | function LineItemU pdateNeede d(FromFile , ToFile: string): B oolean; | |
1123 | var | |
1124 | fromLi st, toList : TStringL ist; | |
1125 | i, idx : Integer; | |
1126 | line: string; | |
1127 | begin | |
1128 | Result := FALSE; | |
1129 | fromLi st := TStr ingList.Cr eate; | |
1130 | toList := TStrin gList.Crea te; | |
1131 | try | |
1132 | from List.LoadF romFile(Fr omFile); | |
1133 | toLi st.LoadFro mFile(ToFi le); | |
1134 | for i := 0 to fromList.C ount - 1 d o | |
1135 | begi n | |
1136 | li ne := from List[i]; | |
1137 | if Trim(line ) <> '' th en | |
1138 | be gin | |
1139 | idx := toL ist.IndexO f(line); | |
1140 | if idx < 0 then | |
1141 | begin | |
1142 | Result : = TRUE; | |
1143 | break; | |
1144 | end; | |
1145 | en d; | |
1146 | end; | |
1147 | finall y | |
1148 | toLi st.free; | |
1149 | from List.free; | |
1150 | end; | |
1151 | end; | |
1152 | ||
1153 | // ******* ********** ********** ********** ********** ********** ********* | |
1154 | // Determi nes if an INI value from FromF ile is mis sing in th e ToFile | |
1155 | // ******* ********** ********** ********** ********** ********** ********* | |
1156 | function INIUpdate Needed(Fro mFile, ToF ile: strin g): Boolea n; | |
1157 | var | |
1158 | FromIN IFile, ToI NIFile: TI NIFile; | |
1159 | Sectio ns, Values : TStringL ist; | |
1160 | i, j: Integer; | |
1161 | sectio n, key, va l1, val2: string; | |
1162 | begin | |
1163 | Result := FALSE; | |
1164 | Sectio ns := TStr ingList.Cr eate; | |
1165 | Values := TStrin gList.Crea te; | |
1166 | try | |
1167 | From INIFile := TINIFile. Create(Fro mFile); | |
1168 | try | |
1169 | To INIFile := TINIFile. Create(ToF ile); | |
1170 | tr y | |
1171 | FromINIFil e.ReadSect ions(Secti ons); | |
1172 | for i := 0 to Sectio ns.Count - 1 do | |
1173 | begin | |
1174 | section := Section s[i]; | |
1175 | FromINIF ile.ReadSe ctionValue s(section, Values); | |
1176 | for j := 0 to Valu es.Count - 1 do | |
1177 | begin | |
1178 | key := Values.Na mes[j]; | |
1179 | val1 : = Values.V alueFromIn dex[j]; | |
1180 | val2 : = ToINIFil e.ReadStri ng(section , key, '') ; | |
1181 | Result := (val1 <> val2); | |
1182 | if Res ult then | |
1183 | brea k; | |
1184 | end; | |
1185 | if Resul t then | |
1186 | break; | |
1187 | end; | |
1188 | fi nally | |
1189 | ToINIFile. free; | |
1190 | en d; | |
1191 | fina lly | |
1192 | Fr omINIFile. free; | |
1193 | end; | |
1194 | finall y | |
1195 | Sect ions.free; | |
1196 | Valu es.free; | |
1197 | end; | |
1198 | end; | |
1199 | ||
1200 | {$REGION ' ********** ********** *** Archiv ed Sub Met hods ***** ********** ********'} | |
1201 | { | |
1202 | function IsUseLine (data: str ing): bool ean; | |
1203 | var | |
1204 | p: Integ er; | |
1205 | begin | |
1206 | Result : = (copy(da ta, 1, 4) = 'use '); | |
1207 | if Resul t then | |
1208 | begin | |
1209 | Result : = FALSE; | |
1210 | p := pos ('"', data ); | |
1211 | if p > 0 then | |
1212 | begin | |
1213 | p := pos EX('"', da ta, p + 1) ; | |
1214 | if p = l ength(data ) then | |
1215 | Result : = TRUE; | |
1216 | end; | |
1217 | end; | |
1218 | end; | |
1219 | ||
1220 | function IsFunctio nLine(data : string): boolean; | |
1221 | var | |
1222 | p1, p2: Integer; | |
1223 | line: st ring; | |
1224 | begin | |
1225 | Result : = FALSE; | |
1226 | line := data; | |
1227 | p1 := po s(' ', lin e); | |
1228 | if (p1 > 0) then | |
1229 | begin | |
1230 | if copy( line, 1, p 1 - 1) = ' script' th en | |
1231 | Result : = TRUE | |
1232 | else | |
1233 | begin | |
1234 | p2 := po sEX(' ', l ine, p1 + 1); | |
1235 | if p2 > 0 then | |
1236 | begin | |
1237 | line := copy(line, p1 + 1, p 2 - p1 - 1 ); | |
1238 | if (line = 'functi on') then | |
1239 | Result : = TRUE; | |
1240 | end; | |
1241 | end; | |
1242 | end; | |
1243 | end; | |
1244 | ||
1245 | function CheckForU seLineAndF unction(Fr omFile, To File: stri ng): boole an; | |
1246 | var | |
1247 | FromData : TStringL ist; | |
1248 | ToData: TStringLis t; | |
1249 | UseLine: string; | |
1250 | I: Integ er; | |
1251 | line: st ring; | |
1252 | ||
1253 | begin | |
1254 | Result : = FALSE; | |
1255 | FromData := TStrin gList.Crea te; | |
1256 | ToData : = TStringL ist.Create ; | |
1257 | try | |
1258 | UseLine := ''; | |
1259 | AppUseLi ne := ''; | |
1260 | AppStart FunctionLi ne := -1; | |
1261 | FromData .LoadFromF ile(FromFi le); | |
1262 | for I := 0 to From Data.Count - 1 do | |
1263 | begin | |
1264 | line := LowerCase( trim(FromD ata[I])); | |
1265 | if (UseL ine = '') and IsUseL ine(line) then | |
1266 | begin | |
1267 | UseLine := line; | |
1268 | AppUseLi ne := From Data[I]; | |
1269 | end | |
1270 | else if (AppStartF unctionLin e < 0) and IsFunctio nLine(line ) then | |
1271 | AppStart FunctionLi ne := I; | |
1272 | if (UseL ine <> '') and (AppS tartFuncti onLine >= 0) then | |
1273 | break; | |
1274 | end; | |
1275 | if (UseL ine = '') or (AppSta rtFunction Line < 0) then | |
1276 | exit; | |
1277 | ||
1278 | AppNeeds UseLine := TRUE; | |
1279 | AppScrip tNeedsFunc tion := TR UE; | |
1280 | ToData.L oadFromFil e(ToFile); | |
1281 | for I := 0 to ToDa ta.Count - 1 do | |
1282 | begin | |
1283 | line := LowerCase( trim(ToDat a[I])); | |
1284 | if AppNe edsUseLine and IsUse Line(line) and (line = UseLine ) then | |
1285 | AppNeeds UseLine := FALSE | |
1286 | else if AppScriptN eedsFuncti on and IsF unctionLin e(line) th en | |
1287 | AppScrip tNeedsFunc tion := FA LSE; | |
1288 | if (not AppNeedsUs eLine) and (not AppS criptNeeds Function) then | |
1289 | break; | |
1290 | end; | |
1291 | if AppNe edsUseLine or AppScr iptNeedsFu nction the n | |
1292 | Result : = TRUE; | |
1293 | finally | |
1294 | FromData .Free; | |
1295 | ToData.F ree; | |
1296 | end; | |
1297 | end; | |
1298 | ||
1299 | function DoScriptM erge(FromF ile, ToFil e, ThisCom piler: str ing): bool ean; | |
1300 | var | |
1301 | BackupFi le: string ; | |
1302 | FromData : TStringL ist; | |
1303 | ToData: TStringLis t; | |
1304 | I, idx: Integer; | |
1305 | ExitCode : Integer; | |
1306 | begin | |
1307 | Result : = TRUE; | |
1308 | BackupFi le := ToFi le + '.BAC KUP'; | |
1309 | if FileE xists(Back upFile) th en | |
1310 | begin | |
1311 | MakeFile Writable(B ackupFile) ; | |
1312 | DeleteFi le(PChar(B ackupFile) ); | |
1313 | end; | |
1314 | DeleteCo mpiledFile (ToFile); | |
1315 | CopyFile (PChar(ToF ile), PCha r(BackupFi le), FALSE ); | |
1316 | MakeFile Writable(T oFile); | |
1317 | FromData := TStrin gList.Crea te; | |
1318 | ToData : = TStringL ist.Create ; | |
1319 | try | |
1320 | ToData.L oadFromFil e(ToFile); | |
1321 | if AppNe edsUseLine then | |
1322 | ToData.I nsert(0, A ppUseLine) ; | |
1323 | if AppSc riptNeedsF unction th en | |
1324 | begin | |
1325 | FromData .LoadFromF ile(FromFi le); | |
1326 | ToData.I nsert(1, ' '); | |
1327 | idx := 2 ; | |
1328 | for I := AppStartF unctionLin e to FromD ata.Count - 1 do | |
1329 | begin | |
1330 | ToData.I nsert(idx, FromData[ I]); | |
1331 | inc(idx) ; | |
1332 | end; | |
1333 | ToData.I nsert(idx, ''); | |
1334 | end; | |
1335 | if not a ssigned(JA WSAPI) the n | |
1336 | JAWSAPI := CoJawsA pi.Create; | |
1337 | ToData.S aveToFile( ToFile); | |
1338 | ExitCode := Execut eAndWait(' "' + ThisC ompiler + '"', '"' + ToFile + '"'); | |
1339 | JAWSAPI. StopSpeech ; | |
1340 | if ExitC ode = 0 th en // comp ile succee ded! | |
1341 | ReloadCo nfiguratio n | |
1342 | else | |
1343 | Result : = FALSE; / / compile failed - j ust copy t he new one | |
1344 | finally | |
1345 | FromData .Free; | |
1346 | ToData.F ree; | |
1347 | end; | |
1348 | end; | |
1349 | ||
1350 | } | |
1351 | {$ENDREGIO N} | |
1352 | // ******* ********** ********** ********** ********** ********** ********* | |
1353 | // Fire of f the corr ect check based on t he Compare Type | |
1354 | // ******* ********** ********** ********** ********** ********** ********* | |
1355 | function UpdateNee ded(FromFi le, ToFile : string; | |
1356 | Compar eType: TCo mpareType) : Boolean; | |
1357 | begin | |
1358 | Result := TRUE; | |
1359 | try | |
1360 | case CompareTy pe of | |
1361 | jc ScriptMerg e: | |
1362 | Result := VersionDif ferent(Fro mFile, ToF ile); | |
1363 | jc Prior: | |
1364 | Result := LastFileUp dated; | |
1365 | jc Version: | |
1366 | Result := VersionDif ferent(Fro mFile, ToF ile); | |
1367 | jc INI: | |
1368 | Result := INIUpdateN eeded(From File, ToFi le); | |
1369 | jc LineItems: | |
1370 | Result := LineItemUp dateNeeded (FromFile, ToFile); | |
1371 | jc INIMRG: | |
1372 | Result := INIUpdateN eeded(From File, ToFi le); | |
1373 | jc LineItemsM RG: | |
1374 | Result := LineItemUp dateNeeded (FromFile, ToFile); | |
1375 | end; | |
1376 | except | |
1377 | on E : Exceptio n do | |
1378 | FJ AWSFileErr or := E.Me ssage; | |
1379 | end; | |
1380 | end; | |
1381 | ||
1382 | // ******* ********** ********** ********** ********** ********** ********* | |
1383 | // Update the Ini Fi le | |
1384 | // ******* ********** ********** ********** ********** ********** ********* | |
1385 | procedur e INIFileU pdate(From File, ToFi le: String ); | |
1386 | var | |
1387 | FromIN IFile, ToI NIFile: TI NIFile; | |
1388 | Sectio ns, Values : TStringL ist; | |
1389 | i, j: Integer; | |
1390 | sectio n, key, va l1, val2: string; | |
1391 | modifi ed: Boolea n; | |
1392 | begin | |
1393 | modifi ed := FALS E; | |
1394 | Sectio ns := TStr ingList.Cr eate; | |
1395 | Values := TStrin gList.Crea te; | |
1396 | try | |
1397 | From INIFile := TINIFile. Create(Fro mFile); | |
1398 | try | |
1399 | To INIFile := TINIFile. Create(ToF ile); | |
1400 | tr y | |
1401 | FromINIFil e.ReadSect ions(Secti ons); | |
1402 | for i := 0 to Sectio ns.Count - 1 do | |
1403 | begin | |
1404 | section := Section s[i]; | |
1405 | FromINIF ile.ReadSe ctionValue s(section, Values); | |
1406 | for j := 0 to Valu es.Count - 1 do | |
1407 | begin | |
1408 | key := Values.Na mes[j]; | |
1409 | val1 : = Values.V alueFromIn dex[j]; | |
1410 | val2 : = ToINIFil e.ReadStri ng(section , key, '') ; | |
1411 | if (va l1 <> val2 ) then | |
1412 | begin | |
1413 | ToIN IFile.Writ eString(se ction, key , val1); | |
1414 | modi fied := TR UE; | |
1415 | end; | |
1416 | end; | |
1417 | end; | |
1418 | fi nally | |
1419 | if modifie d then | |
1420 | ToINIFil e.UpdateFi le(); | |
1421 | ToINIFile. free; | |
1422 | en d; | |
1423 | fina lly | |
1424 | Fr omINIFile. free; | |
1425 | end; | |
1426 | finall y | |
1427 | Sect ions.free; | |
1428 | Valu es.free; | |
1429 | end; | |
1430 | end; | |
1431 | ||
1432 | // ******* ********** ********** ********** ********** ********** ********* | |
1433 | // Update the Line I tem | |
1434 | // ******* ********** ********** ********** ********** ********** ********* | |
1435 | procedur e LineItem FileUpdate (FromFile, ToFile: s tring); | |
1436 | var | |
1437 | fromLi st, toList : TStringL ist; | |
1438 | i, idx : Integer; | |
1439 | line: string; | |
1440 | modifi ed: Boolea n; | |
1441 | begin | |
1442 | modifi ed := FALS E; | |
1443 | fromLi st := TStr ingList.Cr eate; | |
1444 | toList := TStrin gList.Crea te; | |
1445 | try | |
1446 | from List.LoadF romFile(Fr omFile); | |
1447 | toLi st.LoadFro mFile(ToFi le); | |
1448 | for i := 0 to fromList.C ount - 1 d o | |
1449 | begi n | |
1450 | li ne := from List[i]; | |
1451 | if Trim(line ) <> '' th en | |
1452 | be gin | |
1453 | idx := toL ist.IndexO f(line); | |
1454 | if idx < 0 then | |
1455 | begin | |
1456 | toList.A dd(line); | |
1457 | modified := TRUE; | |
1458 | end; | |
1459 | en d; | |
1460 | end; | |
1461 | finall y | |
1462 | if m odified th en | |
1463 | to List.SaveT oFile(ToFi le); | |
1464 | toLi st.free; | |
1465 | from List.free; | |
1466 | end; | |
1467 | end; | |
1468 | ||
1469 | // ******* ********** ********** ********** ********** ********** ********* | |
1470 | // Remove a Compiled file | |
1471 | // ******* ********** ********** ********** ********** ********** ********* | |
1472 | procedur e DeleteCo mpiledFile (ToFile: s tring); | |
1473 | var | |
1474 | Compil edFile: st ring; | |
1475 | begin | |
1476 | Compil edFile := Copy(ToFil e, 1, Leng th(ToFile) - | |
1477 | Leng th(Extract FileExt(To File))); | |
1478 | Compil edFile := CompiledFi le + Compi ledScriptF ileExtensi on; | |
1479 | if Fil eExists(Co mpiledFile ) then | |
1480 | begin | |
1481 | Make FileWritab le(Compile dFile); | |
1482 | Dele teFile(PCh ar(Compile dFile)); | |
1483 | end; | |
1484 | end; | |
1485 | ||
1486 | Procedur e LoadFile IntoCompil er(ToFile: string; T hisJawsRec : TJawsRec ord); | |
1487 | var | |
1488 | FileNa me, extNam e, Depfile : String; | |
1489 | X, Y: Integer; | |
1490 | LookFo rVaApp: Bo olean; | |
1491 | begin | |
1492 | SetLen gth(Compil eFiles, Le ngth(Compi leFiles) + 1); | |
1493 | Compil eFiles[Hig h(CompileF iles)].Fil eName := T oFile; | |
1494 | Compil eFiles[Hig h(CompileF iles)].Com piled := F ALSE; | |
1495 | Compil eFiles[Hig h(CompileF iles)].Com piler := T hisJawsRec .Compiler; | |
1496 | ||
1497 | // Loa d dependen cies | |
1498 | FileNa me := Piec e(ExtractF ileName(To File), '.' , 1); | |
1499 | extNam e := Piece (ExtractFi leName(ToF ile), '.', 2); | |
1500 | LookFo rVaApp := FileName = Piece(Ext ractFileNa me(ParamSt r(0)), '.' , 1); | |
1501 | ||
1502 | // Bui ld depende ncies | |
1503 | for X := Low(Scr iptFiles) to High(Sc riptFiles) do | |
1504 | begin | |
1505 | if ( ExtractFil eName(Scri ptFiles[X] .FileName) = Extract FileName(T oFile)) or | |
1506 | (( LookForVaA pp) and | |
1507 | (U pperCase(P iece(Extra ctFileName (ScriptFil es[X].File Name), '.' , 1)) | |
1508 | = UpperCase( JAWS_APP_N AME)) and | |
1509 | (U pperCase(P iece(Extra ctFileName (ScriptFil es[X].File Name), '.' , 2)) | |
1510 | = UpperCase( extName))) then | |
1511 | begi n | |
1512 | if Length(Sc riptFiles[ X].Depende ncies) > 0 then | |
1513 | be gin | |
1514 | for Y := L ow(ScriptF iles[X].De pendencies ) | |
1515 | to High( ScriptFile s[X].Depen dencies) d o | |
1516 | begin | |
1517 | SetLengt h(CompileF iles[High( CompileFil es)].Depen dentFile, | |
1518 | Length (CompileFi les[High(C ompileFile s)].Depend entFile) + 1); | |
1519 | Depfile := Extract FilePath(T oFile); | |
1520 | Depfile := AppendB ackSlash(D epfile); | |
1521 | CompileF iles[High( CompileFil es)].Depen dentFile | |
1522 | [High( CompileFil es[High(Co mpileFiles )].Depende ntFile)].F ileName := | |
1523 | Depfil e + Script Files[X].D ependencie s[Y].FileN ame; | |
1524 | CompileF iles[High( CompileFil es)].Depen dentFile | |
1525 | [High( CompileFil es[High(Co mpileFiles )].Depende ntFile) | |
1526 | ].Comp iled := FA LSE; | |
1527 | CompileF iles[High( CompileFil es)].Depen dentFile | |
1528 | [High( CompileFil es[High(Co mpileFiles )].Depende ntFile)].C ompiler := | |
1529 | ThisJa wsRec.Comp iler; | |
1530 | end; | |
1531 | en d; | |
1532 | br eak; | |
1533 | end; | |
1534 | end; | |
1535 | end; | |
1536 | ||
1537 | // ******* ********** ********** ********** ********** ********** ********* | |
1538 | // Update the ToFile from the FromFile | |
1539 | // ******* ********** ********** ********** ********** ********** ********* | |
1540 | procedur e UpdateFi le(FromFil e, ToFile: string; T hisJawsRec : TJawsRec ord; | |
1541 | info: TFileInfo) ; | |
1542 | var | |
1543 | DoCopy : Boolean; | |
1544 | error: Boolean; | |
1545 | CheckO verwrite: Boolean; | |
1546 | Versio nNum: stri ng; | |
1547 | begin | |
1548 | DoCopy := FALSE; | |
1549 | if Fil eExists(To File) then | |
1550 | begin | |
1551 | Make FileWritab le(ToFile) ; | |
1552 | Chec kOverwrite := TRUE; | |
1553 | ||
1554 | Vers ionNum := FloatToStr (ThisJawsR ec.Version ); | |
1555 | if P os('.', Ve rsionNum) > 0 then | |
1556 | Ve rsionNum : = Copy(Ver sionNum, 1 , Pos('.', VersionNu m) - 1); | |
1557 | if F indCommand Switch('FO RCEUPD') o r | |
1558 | Fi ndCommandS witch('FOR CEUPD' + V ersionNum) then | |
1559 | begi n | |
1560 | Ch eckOverwri te := FALS E; | |
1561 | Do Copy := TR UE; | |
1562 | end | |
1563 | else | |
1564 | begi n | |
1565 | ||
1566 | tr y | |
1567 | case info. CompareTyp e of | |
1568 | jcScript Merge: | |
1569 | DoCopy := TRUE; | |
1570 | jcPrior, jcVersion : | |
1571 | DoCopy := TRUE; | |
1572 | jcINI: | |
1573 | INIFil eUpdate(Fr omFile, To File); | |
1574 | jcLineIt ems: | |
1575 | LineIt emFileUpda te(FromFil e, ToFile) ; | |
1576 | jcINIMRG : | |
1577 | INIFil eUpdate(Fr omFile, To File); | |
1578 | jcLineIt emsMRG: | |
1579 | LineIt emFileUpda te(FromFil e, ToFile) ; | |
1580 | end; | |
1581 | ex cept | |
1582 | on E: Exce ption do | |
1583 | FJAWSFil eError := E.Message; | |
1584 | en d; | |
1585 | end; | |
1586 | end | |
1587 | else | |
1588 | begin | |
1589 | Chec kOverwrite := FALSE; | |
1590 | DoCo py := TRUE ; | |
1591 | end; | |
1592 | ||
1593 | if DoC opy then | |
1594 | begin | |
1595 | erro r := FALSE ; | |
1596 | if n ot CopyFil e(PChar(Fr omFile), P Char(ToFil e), FALSE) then | |
1597 | begi n | |
1598 | er ror := TRU E; | |
1599 | Lo gTxt := Lo gTxt + #13 #10 + 'Err or copying to: "' + | |
1600 | ExtractFil ePath(ToFi le) + '" ' + CRLF + | |
1601 | '!! Error in CopyFil e method!! '; | |
1602 | if assigned( UserSplash ) then | |
1603 | UserSplash .TaskError := 'Error copying t o: "' + | |
1604 | ExtractF ilePath(To File); | |
1605 | end | |
1606 | else | |
1607 | Lo gTxt := Lo gTxt + #13 #10 + 'cop ied to: "' + | |
1608 | ExtractFil ePath(ToFi le) + '".' ; | |
1609 | ||
1610 | if ( not error) and (not FileExists (ToFile)) then | |
1611 | begi n | |
1612 | er ror := TRU E; | |
1613 | end; | |
1614 | if ( not error) and Check Overwrite and (info. CompareTyp e <> jcPri or) and | |
1615 | Up dateNeeded (FromFile, ToFile, i nfo.Compar eType) the n | |
1616 | er ror := TRU E; | |
1617 | if e rror and ( not FileEr rorExists) then | |
1618 | FJ AWSFileErr or := 'Err or copying "' + Extr actFilePat h(FromFile ) + '" to' | |
1619 | + CRLF + ' "' + Extra ctFilePath (ToFile) + '".'; | |
1620 | if ( not error) and (info .Compile) then | |
1621 | begi n | |
1622 | De leteCompil edFile(ToF ile); | |
1623 | Lo adFileInto Compiler(T oFile, Thi sJawsRec); | |
1624 | Lo gTxt := Lo gTxt + #13 #10 + 'Com pile Neede d: YES'; | |
1625 | end | |
1626 | else | |
1627 | Lo gTxt := Lo gTxt + #13 #10 + 'Com pile Neede d: NO'; | |
1628 | end; | |
1629 | end; | |
1630 | ||
1631 | Procedur e UpdateUs es(ToFile, aUpdateSt r: string) ; | |
1632 | var | |
1633 | tempSt rLst: TStr ingList; | |
1634 | i: Int eger; | |
1635 | begin | |
1636 | tempSt rLst := TS tringList. Create; | |
1637 | try | |
1638 | temp StrLst.Loa dFromFile( ToFile); | |
1639 | for i := 0 to tempStrLst .Count - 1 do | |
1640 | begi n | |
1641 | if Pos(JAWS_ FRAMEWORK_ USES, temp StrLst[i]) > 0 then | |
1642 | be gin | |
1643 | tempStrLst [i] := aUp dateStr; | |
1644 | break; | |
1645 | en d; | |
1646 | end; | |
1647 | temp StrLst.Sav eToFile(To File); | |
1648 | finall y | |
1649 | temp StrLst.fre e; | |
1650 | end; | |
1651 | end; | |
1652 | ||
1653 | // ******* ********** ********** ********** ********** ********** ********* | |
1654 | // Keeps J aws files aliged wit h the ones in Vist\C ommon File s | |
1655 | // ******* ********** ********** ********** ********** ********** ********* | |
1656 | procedur e EnsureJA WSScriptsA reUpToDate (var ThisJ awsRec: TJ awsRecord) ; | |
1657 | var | |
1658 | DestFi le, FromFi le, ToFile , AppName, Ext: stri ng; | |
1659 | idx1, idx2, i, X : Integer; | |
1660 | DoUpda te, DoUses : Boolean; | |
1661 | Versio nNum, Uses Str, UpdFi leName: St ring; | |
1662 | begin | |
1663 | AppNam e := Extra ctFileName (ParamStr( 0)); | |
1664 | Ext := ExtractFi leExt(AppN ame); | |
1665 | AppNam e := LeftS tr(AppName , Length(A ppName) - Length(Ext )); | |
1666 | DestPa th := ''; | |
1667 | idx1 : = Pos(JAWS _COMMON_SC RIPT_PATH_ TEXT, This JawsRec.Us erScriptDi r); | |
1668 | idx2 : = Pos(JAWS _COMMON_SC RIPT_PATH_ TEXT, This JawsRec.De faultScrip tDir); | |
1669 | if (id x1 > 0) an d (idx2 > 0) then | |
1670 | begin | |
1671 | Dest Path := Co py(ThisJaw sRec.UserS criptDir, 1, idx1 - 1) + | |
1672 | Co py(ThisJaw sRec.Defau ltScriptDi r, idx2, M axInt); | |
1673 | ||
1674 | Dest File := De stPath + A ppName; | |
1675 | This JawsRec.FD ictionaryF ileName := DestFile + Dictiona ryFileExte nsion; | |
1676 | This JawsRec.FC onfigFile := DestFil e + Config FileExtens ion; | |
1677 | This JawsRec.FK eyMapFile := DestFil e + KeyMap Extension; | |
1678 | Last FileUpdate d := FALSE ; | |
1679 | ||
1680 | // L ook up the files | |
1681 | if L ength(Scri ptFiles) = 0 then | |
1682 | Ge tScriptFil es(ScriptF iles); | |
1683 | ||
1684 | for i := low(S criptFiles ) to high( ScriptFile s) do | |
1685 | begi n | |
1686 | Do Uses := FA LSE; | |
1687 | // Look for dependenci es | |
1688 | if Length(Sc riptFiles[ i].Depende ncies) > 0 then | |
1689 | be gin | |
1690 | UsesStr := ''; | |
1691 | // add the compiled dependenci es to the uses | |
1692 | for X := L ow(ScriptF iles[i].De pendencies ) | |
1693 | to High( ScriptFile s[i].Depen dencies) d o | |
1694 | begin | |
1695 | UpdFileN ame := Pie ce(ScriptF iles[i].De pendencies [X].FileNa me, '.', | |
1696 | 1) + C ompiledScr iptFileExt ension; | |
1697 | UsesStr := UsesStr + 'use "' + UpdFile Name + '"' + #10#13 | |
1698 | end; | |
1699 | DoUses := TRUE; | |
1700 | en d; | |
1701 | ||
1702 | if UpperCase (Piece(Ext ractFileNa me(ScriptF iles[i].Fi leName), ' .', 1)) = JAWS_APP_N AME | |
1703 | th en | |
1704 | be gin | |
1705 | FromFile : = ScriptFi les[i].Fil eName; | |
1706 | ToFile := DestFile + ExtractFi leExt(Scri ptFiles[i] .FileName) ; | |
1707 | en d | |
1708 | el se | |
1709 | be gin | |
1710 | FromFile : = ScriptFi les[i].Fil eName; | |
1711 | ToFile := DestPath + ExtractFi leName(Scr iptFiles[i ].FileName ); | |
1712 | en d; | |
1713 | Lo gTxt := 'F ilename: ' + Extract FileName(F romFile); | |
1714 | if ScriptFil es[i].Exis t then | |
1715 | be gin | |
1716 | if FileExi sts(ToFile ) then | |
1717 | begin | |
1718 | // add f orce for r ebuild | |
1719 | VersionN um := Floa tToStr(Thi sJawsRec.V ersion); | |
1720 | if Pos(' .', Versio nNum) > 0 then | |
1721 | Versio nNum := Co py(Version Num, 1, Po s('.', Ver sionNum) - 1); | |
1722 | ||
1723 | if FindC ommandSwit ch('FORCEU PD') then | |
1724 | DoUpda te := TRUE | |
1725 | else if FindComman dSwitch('F ORCEUPD' + VersionNu m) then | |
1726 | DoUpda te := TRUE | |
1727 | else | |
1728 | DoUpda te := Upda teNeeded(F romFile, T oFile, | |
1729 | Scri ptFiles[i] .CompareTy pe); | |
1730 | if DoUpd ate then | |
1731 | begin | |
1732 | MakeFi leWritable (ToFile); | |
1733 | LogTxt := LogTxt + #13#10 + 'Update needed: YE S' | |
1734 | end | |
1735 | else | |
1736 | LogTxt := LogTxt + #13#10 + 'Update needed: NO '; | |
1737 | ||
1738 | end | |
1739 | else | |
1740 | DoUpdate := TRUE; | |
1741 | LastFileUp dated := D oUpdate; | |
1742 | if DoUpdat e and (not FileError Exists) th en | |
1743 | begin | |
1744 | UpdateFi le(FromFil e, ToFile, ThisJawsR ec, Script Files[i]); | |
1745 | if DoUse s then | |
1746 | Update Uses(ToFil e, UsesStr ); | |
1747 | ScriptFi leChanges := TRUE; | |
1748 | end; | |
1749 | ||
1750 | if FileErr orExists t hen | |
1751 | break; | |
1752 | LogInterfa ce.LogText (' Compare ', LogTx t); | |
1753 | en d; | |
1754 | Us erSplash.I ncProg; | |
1755 | end; | |
1756 | ||
1757 | end | |
1758 | else | |
1759 | FJAW SFileError := 'Unkno wn File Er ror'; | |
1760 | // sho uld never happen - c ondition c hecked pre viously | |
1761 | end; | |
1762 | ||
1763 | // ******* ********** ********** ********** ********** ********** ********* | |
1764 | // Recompi le Jaws wi th the new files | |
1765 | // ******* ********** ********** ********** ********** ********** ********* | |
1766 | procedur e DoCompil es(ThisJaw sRec: TJaw sRecord); | |
1767 | var | |
1768 | i, X, Y: Integer ; | |
1769 | RunTxt : String; | |
1770 | RunSta tus: Boole an; | |
1771 | begin | |
1772 | if not assigned( JAWSAPI) t hen | |
1773 | JAWS API := CoJ awsApi.Cre ate; | |
1774 | ||
1775 | LogInt erface.Log Text(' Com pile ', ' Compiler: ' + ThisJa wsRec.Comp iler); | |
1776 | for i := Low(Com pileFiles) to High(C ompileFile s) do | |
1777 | begin | |
1778 | if n ot Compile Files[i].C ompiled th en | |
1779 | begi n | |
1780 | if Length(Co mpileFiles [i].Depend entFile) > 0 then | |
1781 | be gin | |
1782 | for X := L ow(Compile Files[i].D ependentFi le) | |
1783 | to High( CompileFil es[i].Depe ndentFile) do | |
1784 | begin | |
1785 | if not C ompileFile s[i].Depen dentFile[X ].Compiled then | |
1786 | begin | |
1787 | try | |
1788 | RunS tatus := C ompileFile s[i].Depen dentFile[X ] | |
1789 | .C ompileFile (RunTxt); | |
1790 | if n ot RunStat us then | |
1791 | begi n | |
1792 | Lo gInterface .LogText(' ERROR ', | |
1793 | 'File: ' + ExtractFi leName(Com pileFiles[ i].Depende ntFile[X] | |
1794 | .FileName) + #13#10 + RunTxt); | |
1795 | if assigned( UserSplash ) then | |
1796 | UserSplash .TaskError := 'File: ' + | |
1797 | ExtractF ileName(Co mpileFiles [i].Depend entFile[X] .FileName) | |
1798 | + ' - ' + RunTxt; | |
1799 | end | |
1800 | else | |
1801 | Lo gInterface .LogText(' Compile ', | |
1802 | 'File: ' + ExtractFi leName(Com pileFiles[ i].Depende ntFile[X] | |
1803 | .FileName) + #13#10 + RunTxt); | |
1804 | ||
1805 | JAWS API.StopSp eech; | |
1806 | // U pdate the record | |
1807 | Comp ileFiles[i ].Dependen tFile[X].C ompiled := TRUE; | |
1808 | ||
1809 | // F ind the ma in record and mark i t as compi led | |
1810 | for Y := Low(C ompileFile s) to High (CompileFi les) do | |
1811 | begi n | |
1812 | if ExtractFi leName(Com pileFiles[ Y].FileNam e) | |
1813 | = ExtractF ileName(Co mpileFiles [i].Depend entFile[X] .FileName) | |
1814 | th en | |
1815 | be gin | |
1816 | CompileFil es[Y].Comp iled := TR UE; | |
1817 | break; | |
1818 | en d; | |
1819 | end; | |
1820 | ||
1821 | except | |
1822 | on E : Exceptio n do | |
1823 | begi n | |
1824 | Lo gInterface .LogText(' Error comp iling ' + | |
1825 | ExtractFil eName(Comp ileFiles[i ].Dependen tFile[X].F ileName), | |
1826 | E.Message) ; | |
1827 | if assigned( UserSplash ) then | |
1828 | UserSplash .TaskError := 'Error compiling ' + | |
1829 | ExtractF ileName(Co mpileFiles [i].Depend entFile[X] .FileName) | |
1830 | + ' - ' + E.Messag e; | |
1831 | end; | |
1832 | end; | |
1833 | end; | |
1834 | end; | |
1835 | en d; | |
1836 | ||
1837 | tr y | |
1838 | RunStatus := Compile Files[i].C ompileFile (RunTxt); | |
1839 | if not Run Status the n | |
1840 | begin | |
1841 | LogInter face.LogTe xt(' ERROR ', | |
1842 | 'File: ' + Extra ctFileName (CompileFi les[i].Fil eName) + # 13#10 | |
1843 | + RunT xt); | |
1844 | if assig ned(UserSp lash) then | |
1845 | UserSp lash.TaskE rror := 'F ile: ' + | |
1846 | Extr actFileNam e(CompileF iles[i].Fi leName) + ' - ' + Ru nTxt; | |
1847 | end | |
1848 | else | |
1849 | LogInter face.LogTe xt(' Compi le ', | |
1850 | 'File: ' + Extra ctFileName (CompileFi les[i].Fil eName) + # 13#10 | |
1851 | + RunT xt); | |
1852 | JAWSAPI.St opSpeech; | |
1853 | // Update the record | |
1854 | CompileFil es[i].Comp iled := TR UE; | |
1855 | ex cept | |
1856 | on E: Exce ption do | |
1857 | begin | |
1858 | LogInter face.LogTe xt('Error compiling ' + | |
1859 | Extrac tFileName( CompileFil es[i].File Name), E.M essage); | |
1860 | if assig ned(UserSp lash) then | |
1861 | UserSp lash.TaskE rror := 'E rror compi ling ' + | |
1862 | Extr actFileNam e(CompileF iles[i].Fi leName) + ' - ' + E. Message; | |
1863 | end; | |
1864 | en d; | |
1865 | ||
1866 | end; | |
1867 | end; | |
1868 | ||
1869 | Reload Configurat ion; | |
1870 | end; | |
1871 | ||
1872 | begin | |
1873 | Result : = FALSE; | |
1874 | for Arry Cnt := Low (JawsRecor d) to High (JawsRecor d) do | |
1875 | begin | |
1876 | StatTe xt := 'Pro cessing JA WS ' + Flo atToStr(Ja wsRecord[A rryCnt].Ve rsion); | |
1877 | LogInt erface.Log Text('JAWS ' + Float ToStr(Jaws Record[Arr yCnt].Vers ion), ''); | |
1878 | UserSp lash.TaskT itle := St atText; | |
1879 | Script FileChange s := FALSE ; | |
1880 | if JAW SManager.R equiredFil esFound th en | |
1881 | begin | |
1882 | FJAW SFileError := ''; | |
1883 | SetL ength(Comp ileFiles, 0); | |
1884 | try | |
1885 | Us erSplash.T askText := | |
1886 | 'Ensuring Jaws scrip t files ar e up to da te with la test versi ons'; | |
1887 | En sureJAWSSc riptsAreUp ToDate(Jaw sRecord[Ar ryCnt]); | |
1888 | Us erSplash.I ncProg; | |
1889 | ||
1890 | if Length(Co mpileFiles ) > 0 then | |
1891 | be gin | |
1892 | UserSplash .TaskText := | |
1893 | 'Jaws sc ripts upda ted. Compi ling neces sary scrip t files'; | |
1894 | DoCompiles (JawsRecor d[ArryCnt] ); | |
1895 | en d; | |
1896 | Us erSplash.I ncProg; | |
1897 | fina lly | |
1898 | Se tLength(Co mpileFiles , 0); | |
1899 | end; | |
1900 | if F ileErrorEx ists then | |
1901 | Sh owError(JA WS_ERROR_F ILE_IO, [F JAWSFileEr ror]); | |
1902 | end | |
1903 | else | |
1904 | User Splash.Inc Prog(2 + L ength(Scri ptFiles)); | |
1905 | UserSp lash.IncPr og; | |
1906 | end; | |
1907 | UserSpla sh.TaskTit le := 'Gen eral'; | |
1908 | UserSpla sh.TaskTex t := 'Veri fying User compatibi lity'; | |
1909 | UserSpla sh.IncProg ; | |
1910 | fCompone ntCallBack Proc := Co mponentCal lBackProc; | |
1911 | fScriptF ilesChange d := Scrip tFileChang es; | |
1912 | Result : = JAWSTalk ing2Curren tUser; | |
1913 | ||
1914 | end; | |
1915 | ||
1916 | // ******* ********** ********** ********** ********** ********** ********* | |
1917 | // Returns if the Ja wsManager is running | |
1918 | // ******* ********** ********** ********** ********** ********** ********* | |
1919 | class func tion TJAWS Manager.Is Running(Hi ghVersion, LowVersio n: Word): BOOL; | |
1920 | ||
1921 | function Component VersionSup ported: Bo olean; | |
1922 | var | |
1923 | Suppor tedHighVer sion, Supp ortedLowVe rsion: Int eger; | |
1924 | FileNa me, newVer sion, conv ertedVersi on, curren tVersion: string; | |
1925 | addr: Pointer; | |
1926 | ||
1927 | begin | |
1928 | addr : = @TJAWSMa nager.IsRu nning; | |
1929 | FileNa me := GetD LLFileName (addr); | |
1930 | curren tVersion : = FileVers ionValue(F ileName, F ILE_VER_FI LEVERSION) ; | |
1931 | Versio nStringSpl it(current Version, S upportedHi ghVersion, | |
1932 | Supp ortedLowVe rsion); | |
1933 | Result := FALSE; | |
1934 | if (Hi ghVersion < Supporte dHighVersi on) then | |
1935 | Resu lt := TRUE | |
1936 | else i f (HighVer sion = Sup portedHigh Version) a nd | |
1937 | (Low Version <= Supported LowVersion ) then | |
1938 | Resu lt := TRUE ; | |
1939 | if not Result th en | |
1940 | begin | |
1941 | newV ersion := IntToStr(H ighVersion ) + '.' + IntToStr(L owVersion) ; | |
1942 | conv ertedVersi on := IntT oStr(Suppo rtedHighVe rsion) + ' .' + | |
1943 | In tToStr(Sup portedLowV ersion); | |
1944 | Show Error(DLL_ ERROR_VERS ION, [newV ersion, co nvertedVer sion]); | |
1945 | end; | |
1946 | ||
1947 | if Res ult then | |
1948 | LogI nterface.L ogText('Ja ws Check', 'DLL Vers ion: ' + c urrentVers ion + | |
1949 | ' supported' ) | |
1950 | else | |
1951 | LogI nterface.L ogText('Ja ws Check', 'DLL Vers ion: ' + c urrentVers ion + | |
1952 | ' not suppor ted'); | |
1953 | end; | |
1954 | ||
1955 | begin | |
1956 | Result : = (GetJAWS Window <> 0); | |
1957 | if Resul t then | |
1958 | Result := Compon entVersion Supported; | |
1959 | if Resul t then | |
1960 | Result := JAWSVe rsionOK; | |
1961 | if Resul t then | |
1962 | begin | |
1963 | Ensure Manager; | |
1964 | with J AWSManager do | |
1965 | Resu lt := Requ iredFilesF ound; | |
1966 | end; | |
1967 | end; | |
1968 | ||
1969 | // ******* ********** ********** ********** ********** ********** ********* | |
1970 | // Verfiy jaws and a pplication are ran b y the same user | |
1971 | // ******* ********** ********** ********** ********** ********** ********* | |
1972 | class func tion TJAWS Manager.JA WSTalking2 CurrentUse r: Boolean ; | |
1973 | var | |
1974 | CurrentU serPath: s tring; | |
1975 | WhatJAWS Thinks: st ring; | |
1976 | ||
1977 | // ***** ********** ********** ********** ********** ********** ********** * | |
1978 | // Gathe rs the use rname that ran the p rocess | |
1979 | // ***** ********** ********** ********** ********** ********** ********** * | |
1980 | Function GetProces sDomainAnd User(PID: DWORD): st ring; | |
1981 | type | |
1982 | PUserT oken = ^Us erToken; | |
1983 | ||
1984 | _UserT oken = rec ord | |
1985 | User : TSIDAndA ttributes; | |
1986 | end; | |
1987 | ||
1988 | UserTo ken = _Use rToken; | |
1989 | var | |
1990 | TkHand le, PHandl e: THandle ; | |
1991 | SidUsr : SID_NAME _USE; | |
1992 | RBuf: Cardinal; | |
1993 | PUser: PUserToke n; | |
1994 | Domain Size, User Size: DWOR D; | |
1995 | Ok: Bo olean; | |
1996 | User, Domain: st ring; | |
1997 | begin | |
1998 | Result := ''; | |
1999 | PHandl e := OpenP rocess(PRO CESS_QUERY _INFORMATI ON, FALSE, PID); | |
2000 | if PHa ndle <> 0 then | |
2001 | begin | |
2002 | if O penProcess Token(PHan dle, TOKEN _QUERY, Tk Handle) th en | |
2003 | begi n | |
2004 | Ok := GetTok enInformat ion(TkHand le, TokenU ser, nil, 0, RBuf); | |
2005 | PU ser := nil ; | |
2006 | wh ile (not O k) and (Ge tLastError = ERROR_I NSUFFICIEN T_BUFFER) do | |
2007 | be gin | |
2008 | ReallocMem (PUser, RB uf); | |
2009 | Ok := GetT okenInform ation(TkHa ndle, Toke nUser, PUs er, RBuf, RBuf); | |
2010 | en d; | |
2011 | Cl oseHandle( TkHandle); | |
2012 | ||
2013 | if not Ok th en | |
2014 | be gin | |
2015 | Exit; | |
2016 | en d; | |
2017 | ||
2018 | Us erSize := 0; | |
2019 | Do mainSize : = 0; | |
2020 | Lo okupAccoun tSid(nil, PUser.User .Sid, nil, UserSize, nil, | |
2021 | DomainSize , SidUsr); | |
2022 | if (UserSize <> 0) and (DomainSi ze <> 0) t hen | |
2023 | be gin | |
2024 | SetLength( User, User Size); | |
2025 | SetLength( Domain, Do mainSize); | |
2026 | if LookupA ccountSid( nil, PUser .User.Sid, PChar(Use r), UserSi ze, | |
2027 | PChar(Do main), Dom ainSize, S idUsr) the n | |
2028 | Result : = StrPas(P Char(Domai n)) + '/' + StrPas(P Char(User) ); | |
2029 | en d; | |
2030 | ||
2031 | if Ok then | |
2032 | be gin | |
2033 | FreeMem(PU ser); | |
2034 | en d; | |
2035 | end; | |
2036 | Clos eHandle(PH andle); | |
2037 | end; | |
2038 | end; | |
2039 | ||
2040 | {$REGION ' ********** ********** *** Archiv ed Sub Met hod ****** ********** *******'} | |
2041 | { | |
2042 | procedur e Fix(var path: stri ng); | |
2043 | var | |
2044 | idx: Int eger; | |
2045 | begin | |
2046 | idx := p os(APP_DAT A, LowerCa se(path)); | |
2047 | if idx > 0 then | |
2048 | path := LeftStr(pa th, idx - 1); | |
2049 | idx := l ength(path ); | |
2050 | while (i dx > 0) an d (path[id x] <> '\') do | |
2051 | dec(idx) ; | |
2052 | delete(p ath, 1, id x); | |
2053 | end; | |
2054 | } | |
2055 | {$ENDREGIO N} | |
2056 | // ******* ********** ********** ********** ********** ********** ********* | |
2057 | // Verify same user using Jaws and Appli cation | |
2058 | // ******* ********** ********** ********** ********** ********** ********* | |
2059 | function UserProbl emExists: Boolean; | |
2060 | var | |
2061 | JAWSWi ndow: HWND ; | |
2062 | pPid: DWORD; | |
2063 | begin | |
2064 | JAWSWi ndow := Ge tJAWSWindo w; | |
2065 | pPid : = INVALID_ HANDLE_VAL UE; | |
2066 | GetWin dowThreadP rocessID(J AWSWindow, @pPid); | |
2067 | Curren tUserPath := GetProc essDomainA ndUser(Get CurrentPro cessID); | |
2068 | WhatJA WSThinks : = GetProce ssDomainAn dUser(pPid ); | |
2069 | Result := (Lower Case(Curre ntUserPath ) <> Lower Case(WhatJ AWSThinks) ); | |
2070 | end; | |
2071 | ||
2072 | begin | |
2073 | if UserP roblemExis ts then | |
2074 | begin | |
2075 | ShowEr ror(JAWS_E RROR_USER_ PROBLEM); | |
2076 | Result := FALSE; | |
2077 | end | |
2078 | else | |
2079 | Result := TRUE; | |
2080 | end; | |
2081 | ||
2082 | // ******* ********** ********** ********** ********** ********** ********* | |
2083 | // Verify the versio n of Jaws is support ed | |
2084 | // ******* ********** ********** ********** ********** ********** ********* | |
2085 | class func tion TJAWS Manager.JA WSVersionO K: Boolean ; | |
2086 | var | |
2087 | JFileVer sion: stri ng; | |
2088 | JFile: s tring; | |
2089 | i: Integ er; | |
2090 | ErrFound , Ok: Bool ean; | |
2091 | ||
2092 | // ***** ********** ********** ********** ********** ********** ********** * | |
2093 | // Try t o create t he Jaws Ap i | |
2094 | // ***** ********** ********** ********** ********** ********** ********** * | |
2095 | function OlderVers ionOKIfCOM ObjectInst alled: Boo lean; | |
2096 | var | |
2097 | api: I JawsApi; | |
2098 | begin | |
2099 | Result := Versio nOK(JAWS_R EQUIRED_VE RSION, JFi leVersion) ; | |
2100 | if Res ult then | |
2101 | begin | |
2102 | try | |
2103 | tr y | |
2104 | api := CoJ awsApi.Cre ate; | |
2105 | ex cept | |
2106 | Result := FALSE; | |
2107 | en d; | |
2108 | fina lly | |
2109 | ap i := nil; | |
2110 | end; | |
2111 | end; | |
2112 | end; | |
2113 | ||
2114 | begin | |
2115 | ErrFound := FALSE; | |
2116 | for i := Low(JawsR ecord) to High(JawsR ecord) do | |
2117 | begin | |
2118 | JFile := Extract FilePath(J awsRecord[ i].Compile r) + | |
2119 | JAWS _APPLICATI ON_FILENAM E; | |
2120 | if Fil eExists(JF ile) then | |
2121 | begin | |
2122 | JFil eVersion : = FileVers ionValue(J File, FILE _VER_FILEV ERSION); | |
2123 | Ok : = VersionO K(JAWS_COM _OBJECT_VE RSION, JFi leVersion) ; | |
2124 | if n ot Ok then | |
2125 | Ok := OlderV ersionOKIf COMObjectI nstalled; | |
2126 | end | |
2127 | else | |
2128 | begin | |
2129 | // i f file not found, th en assume a future v ersion whe re the exe was moved | |
2130 | // t o a differ ent locati on | |
2131 | Ok : = TRUE; | |
2132 | end; | |
2133 | if not Ok then | |
2134 | begin | |
2135 | ErrF ound := TR UE; | |
2136 | brea k; | |
2137 | end; | |
2138 | if Ok then | |
2139 | LogI nterface.L ogText('Ja ws Check', 'Instance Version: ' + JFileV ersion + | |
2140 | ' supported' ) | |
2141 | else | |
2142 | LogI nterface.L ogText('Ja ws Check', 'Instance Version: ' + JFileV ersion + | |
2143 | ' not suppor ted'); | |
2144 | end; | |
2145 | if ErrFo und then | |
2146 | ShowEr ror(JAWS_E RROR_VERSI ON); | |
2147 | ||
2148 | Result : = not ErrF ound; | |
2149 | ||
2150 | end; | |
2151 | ||
2152 | // ******* ********** ********** ********** ********** ********** ********* | |
2153 | // Delete Ini files | |
2154 | // ******* ********** ********** ********** ********** ********** ********* | |
2155 | procedure TJAWSManag er.KillINI Files(Send er: TObjec t); | |
2156 | var | |
2157 | i: Integ er; | |
2158 | begin | |
2159 | for i := Low(JawsR ecord) to High(JawsR ecord) do | |
2160 | begin | |
2161 | if ass igned(Jaws Record[i]. FDictionar yFile) the n | |
2162 | begin | |
2163 | if J awsRecord[ i].FDictio naryFileMo dified the n | |
2164 | begi n | |
2165 | Ma keFileWrit able(JawsR ecord[i].F Dictionary FileName); | |
2166 | Ja wsRecord[i ].FDiction aryFile.Sa veToFile | |
2167 | (JawsRecor d[i].FDict ionaryFile Name); | |
2168 | end; | |
2169 | Free AndNil(Jaw sRecord[i] .FDictiona ryFile); | |
2170 | end; | |
2171 | ||
2172 | if ass igned(Jaws Record[i]. FConfigINI File) then | |
2173 | begin | |
2174 | if J awsRecord[ i].FConfig INIFileMod ified then | |
2175 | begi n | |
2176 | Ja wsRecord[i ].FConfigI NIFile.Upd ateFile; | |
2177 | end; | |
2178 | Free AndNil(Jaw sRecord[i] .FConfigIN IFile); | |
2179 | end; | |
2180 | ||
2181 | if ass igned(Jaws Record[i]. FKeyMapINI File) then | |
2182 | begin | |
2183 | if J awsRecord[ i].FKeyMap INIFileMod ified then | |
2184 | begi n | |
2185 | Ja wsRecord[i ].FKeyMapI NIFile.Upd ateFile; | |
2186 | end; | |
2187 | Free AndNil(Jaw sRecord[i] .FKeyMapIN IFile); | |
2188 | end; | |
2189 | ||
2190 | if ass igned(Jaws Record[i]. FAssignedK eys) then | |
2191 | Free AndNil(Jaw sRecord[i] .FAssigned Keys); | |
2192 | end; | |
2193 | end; | |
2194 | ||
2195 | // ******* ********** ********** ********** ********** ********** ********* | |
2196 | // Create the dispat cher windo w | |
2197 | // ******* ********** ********** ********** ********** ********** ********* | |
2198 | procedure TJAWSManag er.LaunchM asterAppli cation; | |
2199 | begin | |
2200 | if not a ssigned(FH iddenJaws) then | |
2201 | FHidde nJaws := T frmVA508Ja wsDispatch erHiddenWi ndow.Creat e(Applicat ion); | |
2202 | end; | |
2203 | ||
2204 | procedure TJAWSManag er.Registe rCustomBeh avior(Befo re, After: string; | |
2205 | Action: Integer); | |
2206 | ||
2207 | const | |
2208 | WindowCl assesSecti on = 'Wind owClasses' ; | |
2209 | MSAAClas sesSection = 'MSAACl asses'; | |
2210 | DICT_DEL IM: char = char($2E) ; | |
2211 | CommonKe ysSection = 'Common Keys'; | |
2212 | CustomCo mmandHelpS ection = ' Custom Com mand Help' ; | |
2213 | KeyComma nd = 'VA50 8SendCusto mCommand(' ; | |
2214 | KeyComma ndLen = Le ngth(KeyCo mmand); | |
2215 | ||
2216 | var | |
2217 | modified : Boolean; | |
2218 | ||
2219 | procedur e Add2INIF ile(var IN IFile: TIN IFile; var FileModif ied: Boole an; | |
2220 | FileNa me, Sectio nName, dat a, Value: string); | |
2221 | var | |
2222 | oldVal ue: string ; | |
2223 | ||
2224 | begin | |
2225 | if not assigned( INIFile) t hen | |
2226 | begin | |
2227 | Make FileWritab le(FileNam e); | |
2228 | INIF ile := TIN IFile.Crea te(FileNam e); | |
2229 | File Modified : = FALSE; | |
2230 | end; | |
2231 | oldVal ue := INIF ile.ReadSt ring(Secti onName, da ta, ''); | |
2232 | if old Value <> V alue then | |
2233 | begin | |
2234 | INIF ile.WriteS tring(Sect ionName, d ata, Value ); | |
2235 | modi fied := TR UE; | |
2236 | File Modified : = TRUE; | |
2237 | end; | |
2238 | end; | |
2239 | ||
2240 | procedur e RemoveFr omINIFile( var INIFil e: TINIFil e; var Fil eModified: Boolean; | |
2241 | FileNa me, Sectio nName, dat a: string) ; | |
2242 | var | |
2243 | oldVal ue: string ; | |
2244 | ||
2245 | begin | |
2246 | if not assigned( INIFile) t hen | |
2247 | begin | |
2248 | Make FileWritab le(FileNam e); | |
2249 | INIF ile := TIN IFile.Crea te(FileNam e); | |
2250 | File Modified : = FALSE; | |
2251 | end; | |
2252 | oldVal ue := INIF ile.ReadSt ring(Secti onName, da ta, ''); | |
2253 | if old Value <> ' ' then | |
2254 | begin | |
2255 | INIF ile.Delete Key(Sectio nName, dat a); | |
2256 | modi fied := TR UE; | |
2257 | File Modified : = TRUE; | |
2258 | end; | |
2259 | end; | |
2260 | ||
2261 | procedur e Register CustomClas sChange; | |
2262 | Var | |
2263 | i: Int eger; | |
2264 | begin | |
2265 | for i := Low(Jaw sRecord) t o High(Jaw sRecord) d o | |
2266 | Add2 INIFile(Ja wsRecord[i ].FConfigI NIFile, | |
2267 | Ja wsRecord[i ].FConfigI NIFileModi fied, Jaws Record[i]. FConfigFil e, | |
2268 | Wi ndowClasse sSection, Before, Af ter); | |
2269 | end; | |
2270 | ||
2271 | procedur e Register MSAAClassC hange; | |
2272 | Var | |
2273 | i: Int eger; | |
2274 | begin | |
2275 | for i := Low(Jaw sRecord) t o High(Jaw sRecord) d o | |
2276 | Add2 INIFile(Ja wsRecord[i ].FConfigI NIFile, | |
2277 | Ja wsRecord[i ].FConfigI NIFileModi fied, Jaws Record[i]. FConfigFil e, | |
2278 | MS AAClassesS ection, Be fore, '1') ; | |
2279 | end; | |
2280 | ||
2281 | procedur e Register CustomKeyM apping; | |
2282 | Var | |
2283 | i: Int eger; | |
2284 | begin | |
2285 | for i := Low(Jaw sRecord) t o High(Jaw sRecord) d o | |
2286 | begin | |
2287 | Add2 INIFile(Ja wsRecord[i ].FKeyMapI NIFile, | |
2288 | Ja wsRecord[i ].FKeyMapI NIFileModi fied, Jaws Record[i]. FKeyMapFil e, | |
2289 | Co mmonKeysSe ction, Bef ore, KeyCo mmand + Af ter + ')') ; | |
2290 | if n ot assigne d(JawsReco rd[i].FAss ignedKeys) then | |
2291 | Ja wsRecord[i ].FAssigne dKeys := T StringList .Create; | |
2292 | Jaws Record[i]. FAssignedK eys.Add(Be fore); | |
2293 | end; | |
2294 | end; | |
2295 | ||
2296 | procedur e Register CustomKeyD escription ; | |
2297 | Var | |
2298 | i: Int eger; | |
2299 | begin | |
2300 | for i := Low(Jaw sRecord) t o High(Jaw sRecord) d o | |
2301 | Add2 INIFile(Ja wsRecord[i ].FConfigI NIFile, | |
2302 | Ja wsRecord[i ].FConfigI NIFileModi fied, Jaws Record[i]. FConfigFil e, | |
2303 | Cu stomComman dHelpSecti on, Before , After); | |
2304 | end; | |
2305 | ||
2306 | procedur e DecodeLi ne(line: s tring; var before1, after1: st ring); | |
2307 | var | |
2308 | i, j, Len: Integ er; | |
2309 | begin | |
2310 | before 1 := ''; | |
2311 | after1 := ''; | |
2312 | Len := Length(li ne); | |
2313 | if (Le n < 2) or (line[1] < > DICT_DEL IM) then | |
2314 | Exit ; | |
2315 | i := 2 ; | |
2316 | while (i < Len) and (line[ i] <> DICT _DELIM) do | |
2317 | Inc( i); | |
2318 | before 1 := Copy( line, 2, i - 2); | |
2319 | j := i + 1; | |
2320 | while (j <= Len) and (line [j] <> DIC T_DELIM) d o | |
2321 | Inc( j); | |
2322 | after1 := Copy(l ine, i + 1 , j - i - 1); | |
2323 | end; | |
2324 | ||
2325 | procedur e Register CustomDict ionaryChan ge; | |
2326 | var | |
2327 | i, idx , X: Integ er; | |
2328 | line, before1, a fter1: str ing; | |
2329 | Add: B oolean; | |
2330 | begin | |
2331 | for X := Low(Jaw sRecord) t o High(Jaw sRecord) d o | |
2332 | begin | |
2333 | if n ot assigne d(JawsReco rd[X].FDic tionaryFil e) then | |
2334 | begi n | |
2335 | Ja wsRecord[X ].FDiction aryFile := TStringLi st.Create; | |
2336 | Ja wsRecord[X ].FDiction aryFileMod ified := F ALSE; | |
2337 | if FileExist s(JawsReco rd[X].FDic tionaryFil eName) the n | |
2338 | JawsRecord [X].FDicti onaryFile. LoadFromFi le | |
2339 | (JawsRec ord[X].FDi ctionaryFi leName); | |
2340 | end; | |
2341 | ||
2342 | Add := TRUE; | |
2343 | idx := -1; | |
2344 | for i := 0 to JawsRecord [X].FDicti onaryFile. Count - 1 do | |
2345 | begi n | |
2346 | li ne := Jaws Record[X]. FDictionar yFile[i]; | |
2347 | De codeLine(l ine, befor e1, after1 ); | |
2348 | if (before1 = Before) then | |
2349 | be gin | |
2350 | idx := i; | |
2351 | if after1 = After th en | |
2352 | Add := F ALSE; | |
2353 | break; | |
2354 | en d; | |
2355 | end; | |
2356 | if A dd then | |
2357 | begi n | |
2358 | li ne := DICT _DELIM + B efore + DI CT_DELIM + After + D ICT_DELIM; | |
2359 | if idx < 0 t hen | |
2360 | JawsRecord [X].FDicti onaryFile. Add(line) | |
2361 | el se | |
2362 | JawsRecord [X].FDicti onaryFile[ idx] := li ne; | |
2363 | mo dified := TRUE; | |
2364 | Ja wsRecord[X ].FDiction aryFileMod ified := T RUE; | |
2365 | end; | |
2366 | end; | |
2367 | end; | |
2368 | ||
2369 | procedur e RemoveCo mponentCla ss; | |
2370 | Var | |
2371 | i: Int eger; | |
2372 | begin | |
2373 | for i := Low(Jaw sRecord) t o High(Jaw sRecord) d o | |
2374 | Remo veFromINIF ile(JawsRe cord[i].FC onfigINIFi le, | |
2375 | Ja wsRecord[i ].FConfigI NIFileModi fied, Jaws Record[i]. FConfigFil e, | |
2376 | Wi ndowClasse sSection, Before); | |
2377 | end; | |
2378 | ||
2379 | procedur e RemoveMS AAClass; | |
2380 | Var | |
2381 | i: Int eger; | |
2382 | begin | |
2383 | for i := Low(Jaw sRecord) t o High(Jaw sRecord) d o | |
2384 | Remo veFromINIF ile(JawsRe cord[i].FC onfigINIFi le, | |
2385 | Ja wsRecord[i ].FConfigI NIFileModi fied, Jaws Record[i]. FConfigFil e, | |
2386 | MS AAClassesS ection, Be fore); | |
2387 | end; | |
2388 | ||
2389 | procedur e PurgeKey Mappings; | |
2390 | var | |
2391 | i, X: Integer; | |
2392 | Name, Value: str ing; | |
2393 | keys: TStringLis t; | |
2394 | delete : Boolean; | |
2395 | begin | |
2396 | for X := Low(Jaw sRecord) t o High(Jaw sRecord) d o | |
2397 | begin | |
2398 | if n ot assigne d(JawsReco rd[X].FKey MapINIFile ) then | |
2399 | begi n | |
2400 | Ma keFileWrit able(JawsR ecord[X].F KeyMapFile ); | |
2401 | Ja wsRecord[X ].FKeyMapI NIFile := | |
2402 | TINIFile.C reate(Jaws Record[X]. FKeyMapFil e); | |
2403 | Ja wsRecord[X ].FKeyMapI NIFileModi fied := FA LSE; | |
2404 | end; | |
2405 | keys := TStrin gList.Crea te; | |
2406 | try | |
2407 | Ja wsRecord[X ].FKeyMapI NIFile.Rea dSectionVa lues(Commo nKeysSecti on, keys); | |
2408 | fo r i := key s.Count - 1 downto 0 do | |
2409 | be gin | |
2410 | Value := C opy(keys.V alueFromIn dex[i], 1, KeyComman dLen); | |
2411 | if Value = KeyComman d then | |
2412 | begin | |
2413 | name := keys.Names [i]; | |
2414 | delete : = (not ass igned(Jaws Record[X]. FAssignedK eys)); | |
2415 | if not d elete then | |
2416 | delete := (JawsR ecord[X].F AssignedKe ys.IndexOf (name) < 0 ); | |
2417 | if delet e then | |
2418 | begin | |
2419 | JawsRe cord[X].FK eyMapINIFi le.DeleteK ey(CommonK eysSection , name); | |
2420 | JawsRe cord[X].FK eyMapINIFi leModified := TRUE; | |
2421 | modifi ed := TRUE ; | |
2422 | end; | |
2423 | end; | |
2424 | en d; | |
2425 | fina lly | |
2426 | ke ys.free; | |
2427 | end; | |
2428 | end; | |
2429 | end; | |
2430 | ||
2431 | begin | |
2432 | { TODO : check fil e io error s when upd ating conf ig files } | |
2433 | modified := FALSE; | |
2434 | case Act ion of | |
2435 | BEHAVI OR_ADD_DIC TIONARY_CH ANGE: | |
2436 | Regi sterCustom Dictionary Change; | |
2437 | BEHAVI OR_ADD_COM PONENT_CLA SS: | |
2438 | Regi sterCustom ClassChang e; | |
2439 | BEHAVI OR_ADD_COM PONENT_MSA A: | |
2440 | Regi sterMSAACl assChange; | |
2441 | BEHAVI OR_ADD_CUS TOM_KEY_MA PPING: | |
2442 | Regi sterCustom KeyMapping ; | |
2443 | BEHAVI OR_ADD_CUS TOM_KEY_DE SCRIPTION: | |
2444 | Regi sterCustom KeyDescrip tion; | |
2445 | BEHAVI OR_REMOVE_ COMPONENT_ CLASS: | |
2446 | Remo veComponen tClass; | |
2447 | BEHAVI OR_REMOVE_ COMPONENT_ MSAA: | |
2448 | Remo veMSAAClas s; | |
2449 | BEHAVI OR_PURGE_U NREGISTERE D_KEY_MAPP INGS: | |
2450 | Purg eKeyMappin gs; | |
2451 | end; | |
2452 | if modif ied and as signed(FMa inForm) th en | |
2453 | begin | |
2454 | FMainF orm.ResetI NITimer(Ki llINIFiles ); | |
2455 | FMainF orm.Config ReloadNeed ed; | |
2456 | end; | |
2457 | end; | |
2458 | ||
2459 | // ******* ********** ********** ********** ********** ********** ********* | |
2460 | // Fires o ff the rel oad all co nfigs thro ugh Jaws | |
2461 | // ******* ********** ********** ********** ********** ********** ********* | |
2462 | procedure TJAWSManag er.ReloadC onfigurati on; | |
2463 | begin | |
2464 | if not a ssigned(JA WSAPI) the n | |
2465 | JAWSAP I := CoJaw sApi.Creat e; | |
2466 | JAWSAPI. RunFunctio n('ReloadA llConfigs' ); | |
2467 | end; | |
2468 | ||
2469 | // ******* ********** ********** ********** ********** ********** ********* | |
2470 | // Send ei ther data or event t o Jaws | |
2471 | // ******* ********** ********** ********** ********** ********** ********* | |
2472 | procedure TJAWSManag er.SendCom ponentData (WindowHan dle: HWND; | |
2473 | DataStat us: LongIn t; Caption , Value, d ata, Contr olType, St ate, Instr uctions, | |
2474 | ItemInst ructions: PChar); | |
2475 | ||
2476 | // ******* ********** ********** ********** ********** ********** ********* | |
2477 | // Send to dispatche r | |
2478 | // ******* ********** ********** ********** ********** ********** ********* | |
2479 | procedur e SendRequ estRespons e; | |
2480 | begin | |
2481 | FMainF orm.WriteD ata(VA508_ REG_COMPON ENT_CAPTIO N, Caption ); | |
2482 | FMainF orm.WriteD ata(VA508_ REG_COMPON ENT_VALUE, Value); | |
2483 | FMainF orm.WriteD ata(VA508_ REG_COMPON ENT_CONTRO L_TYPE, Co ntrolType) ; | |
2484 | FMainF orm.WriteD ata(VA508_ REG_COMPON ENT_STATE, State); | |
2485 | FMainF orm.WriteD ata(VA508_ REG_COMPON ENT_INSTRU CTIONS, In structions ); | |
2486 | FMainF orm.WriteD ata(VA508_ REG_COMPON ENT_ITEM_I NSTRUCTION S, | |
2487 | Item Instructio ns); | |
2488 | FMainF orm.WriteD ata(VA508_ REG_COMPON ENT_DATA_S TATUS, Int ToStr(Data Status)); | |
2489 | FMainF orm.PostDa ta; | |
2490 | end; | |
2491 | ||
2492 | // ******* ********** ********** ********** ********** ********** ********* | |
2493 | // Run the change ev ent throug h Jaws | |
2494 | // ******* ********** ********** ********** ********** ********** ********* | |
2495 | procedur e SendChan geEvent; | |
2496 | var | |
2497 | Event: WideStrin g; | |
2498 | begin | |
2499 | Event := 'VA508C hangeEvent (' + IntTo Str(Window Handle) + ',' + | |
2500 | IntT oStr(DataS tatus) + ' ,"' + StrP as(Caption ) + '","' + StrPas(V alue) + | |
2501 | '"," ' + StrPas (ControlTy pe) + '"," ' + StrPas (State) + '","' + | |
2502 | StrP as(Instruc tions) + ' ","' + Str Pas(ItemIn structions ) + '"'; | |
2503 | if not assigned( JAWSAPI) t hen | |
2504 | JAWS API := CoJ awsApi.Cre ate; | |
2505 | JAWSAP I.RunFunct ion(Event) | |
2506 | end; | |
2507 | ||
2508 | begin | |
2509 | if (data <> nil) a nd (Length (data) > 0 ) then | |
2510 | begin | |
2511 | Value := data; | |
2512 | DataSt atus := Da taStatus A ND DATA_MA SK_DATA; | |
2513 | DataSt atus := Da taStatus O R DATA_VAL UE; | |
2514 | end; | |
2515 | if (Data Status and DATA_CHAN GE_EVENT) <> 0 then | |
2516 | begin | |
2517 | DataSt atus := Da taStatus A ND DATA_MA SK_CHANGE_ EVENT; | |
2518 | SendCh angeEvent; | |
2519 | end | |
2520 | else | |
2521 | SendRe questRespo nse; | |
2522 | end; | |
2523 | ||
2524 | // ******* ********** ********** ********** ********** ********** ********* | |
2525 | // Display a certian error | |
2526 | // ******* ********** ********** ********** ********** ********** ********* | |
2527 | class proc edure TJAW SManager.S howError(E rrorNumber : Integer) ; | |
2528 | begin | |
2529 | ShowErro r(ErrorNum ber, []); | |
2530 | end; | |
2531 | ||
2532 | // ******* ********** ********** ********** ********** ********** ********* | |
2533 | // Display a certian formated error | |
2534 | // ******* ********** ********** ********** ********** ********** ********* | |
2535 | class proc edure TJAW SManager.S howError(E rrorNumber : Integer; | |
2536 | data: ar ray of con st); | |
2537 | var | |
2538 | error: s tring; | |
2539 | ||
2540 | begin | |
2541 | if not J AWSErrorsS hown[Error Number] th en | |
2542 | begin | |
2543 | error := JAWSErr orMessage[ ErrorNumbe r]; | |
2544 | if Len gth(data) > 0 then | |
2545 | erro r := Forma t(error, d ata); | |
2546 | JAWSEr rorsShown[ ErrorNumbe r] := TRUE ; | |
2547 | if ass igned(User Splash) th en | |
2548 | User Splash.Sho wSystemErr or('JAWS A ccessibili ty Compone nt Error' + CRLF + | |
2549 | PC har(error) ) | |
2550 | else | |
2551 | Mess ageBox(0, PChar(erro r), 'JAWS Accessibil ity Compon ent Error' , | |
2552 | MB _OK or MB_ ICONERROR or MB_TASK MODAL or M B_TOPMOST) ; | |
2553 | ||
2554 | end; | |
2555 | end; | |
2556 | ||
2557 | // ******* ********** ********** ********** ********** ********** ********* | |
2558 | // Clean u p files an d memory | |
2559 | // ******* ********** ********** ********** ********** ********** ********* | |
2560 | procedure TJAWSManag er.ShutDow n; | |
2561 | var | |
2562 | i: Integ er; | |
2563 | begin | |
2564 | if FWasS hutdown th en | |
2565 | Exit; | |
2566 | if assig ned(JAWSAP I) then | |
2567 | begin | |
2568 | try | |
2569 | JAWS API := nil ; // cause s access v iolation | |
2570 | except | |
2571 | end; | |
2572 | end; | |
2573 | KillINIF iles(nil); | |
2574 | if assig ned(FMainF orm) then | |
2575 | FreeAn dNil(FMain Form); | |
2576 | FWasShut down := TR UE; | |
2577 | if assig ned(FHidde nJaws) the n | |
2578 | FHidde nJaws.free ; | |
2579 | SetLengt h(JawsReco rd, 0); | |
2580 | for i := Low(Scrip tFiles) to High(Scri ptFiles) d o | |
2581 | begin | |
2582 | SetLen gth(Script Files[i].A dd_To_Uses , 0); | |
2583 | SetLen gth(Script Files[i].D ependencie s, 0); | |
2584 | end; | |
2585 | SetLengt h(ScriptFi les, 0); | |
2586 | end; | |
2587 | ||
2588 | // ******* ********** ********** ********** ********** ********** ********* | |
2589 | // Say a s pecific st ring throu gh Jaws | |
2590 | // ******* ********** ********** ********** ********** ********** ********* | |
2591 | procedure TJAWSManag er.SpeakTe xt(Text: P Char); | |
2592 | begin | |
2593 | if not a ssigned(JA WSAPI) the n | |
2594 | JAWSAP I := CoJaw sApi.Creat e; | |
2595 | JAWSAPI. SayString( Text, FALS E); | |
2596 | end; | |
2597 | ||
2598 | // ******* ********** ********** ********** ********** ********** ********* | |
2599 | // Ensure the hidden main wind ow is crea ted and re compile | |
2600 | // ******* ********** ********** ********** ********** ********** ********* | |
2601 | procedure TJAWSManag er.EnsureW indow; | |
2602 | begin | |
2603 | if not a ssigned(FM ainForm) t hen | |
2604 | FMainF orm := Tfr mVA508Hidd enJawsMain Window.Cre ate(nil); | |
2605 | FMainFor m.Componen tDataCallB ackProc := fComponen tCallBackP roc; | |
2606 | FMainFor m.ConfigRe loadProc : = ReloadCo nfiguratio n; | |
2607 | FMainFor m.HandleNe eded; | |
2608 | Applicat ion.Proces sMessages; | |
2609 | end; | |
2610 | ||
2611 | {$REGION ' ********** ********** ****** Arc hived Meth od ******* ********** ********'} | |
2612 | { | |
2613 | class fu nction TJA WSManager. GetPathFro mJAWS(Path ID: Intege r; | |
2614 | DoLowerC ase: boole an = TRUE) : string; | |
2615 | const | |
2616 | JAWS_MES SAGE_ID = 'JW_GET_FI LE_PATH'; | |
2617 | // versi on is in d irectory a fter JAWS \Freedom S cientific\ JAWS\*.*\. .. | |
2618 | JAWS_PAT H_ID_APPLI CATION = 0 ; | |
2619 | JAWS_PAT H_ID_USER_ SCRIPT_FIL ES = 1; | |
2620 | JAWS_PAT H_ID_JAWS_ DEFAULT_SC RIPT_FILES = 2; | |
2621 | // 0 = C :\Program Files\Free dom Scient ific\JAWS\ 8.0\jfw.IN I | |
2622 | // 1 = D:\ Documents and Settin gs\ DNS merrij\App lication D ata\Freedo m Scientif ic\JAWS\8. 0\USER.INI | |
2623 | // 2 = D :\Document s and Sett ings\All U sers\Appli cation Dat a\Freedom Scientific \JAWS\8.0\ Settings\e nu\DEFAULT .SBL | |
2624 | var | |
2625 | atm: ATO M; | |
2626 | len: Int eger; | |
2627 | path: st ring; | |
2628 | JAWSWind ow: HWND; | |
2629 | JAWSMsgI D: UINT = 0; | |
2630 | begin | |
2631 | JAWSWind ow := GetJ AWSWindow; | |
2632 | if JAWSM sgID = 0 t hen | |
2633 | JAWSMsgI D := Regis terWindowM essage(JAW S_MESSAGE_ ID); | |
2634 | Result : = ''; | |
2635 | atm := S endMessage (JAWSWindo w, JAWSMsg ID, PathID , 0); | |
2636 | if atm < > 0 then | |
2637 | begin | |
2638 | SetLengt h(path, MA X_PATH * 2 ); | |
2639 | len := G lobalGetAt omName(atm , PChar(pa th), MAX_P ATH * 2); | |
2640 | GlobalDe leteAtom(a tm); | |
2641 | if len > 0 then | |
2642 | begin | |
2643 | SetLengt h(path, le n); | |
2644 | Result : = ExtractF ilePath(pa th); | |
2645 | if DoLow erCase the n | |
2646 | Result : = LowerCas e(Result); | |
2647 | end; | |
2648 | end; | |
2649 | end; | |
2650 | } | |
2651 | {$ENDREGIO N} | |
2652 | {$ENDREGIO N} | |
2653 | { function tCompileF ile.Compil eFile(var RtnMsg: St ring): int eger; | |
2654 | begin | |
2655 | result : = ExecuteA ndWait('"' + Compile r + '"', R tnMsg, '"' + FileNam e + '"'); | |
2656 | end; } | |
2657 | ||
2658 | function t CompileFil e.CompileF ile(var Rt nMsg: Stri ng): Boole an; | |
2659 | var | |
2660 | RtnLst: TStringLis t; | |
2661 | begin | |
2662 | RtnLst : = TStringL ist.Create ; | |
2663 | try | |
2664 | Result := RunSil entCmd(Com piler, Fil eName, Rtn Msg); | |
2665 | RtnLst .Text := R tnMsg; | |
2666 | if Rtn Lst.Count > 1 then | |
2667 | Resu lt := FALS E; | |
2668 | ||
2669 | finally | |
2670 | RtnLst .free; | |
2671 | end; | |
2672 | ||
2673 | end; | |
2674 | ||
2675 | Function F indCommand Switch(Swi tchName: s tring; var ReturnVal ue: string ) | |
2676 | : Boolea n; | |
2677 | begin | |
2678 | {$IFDEF VE R180} | |
2679 | Result : = D2006Fin dCmdLineSw itch(Switc hName, Ret urnValue, TRUE, | |
2680 | [clstD 2006ValueA ppended]); | |
2681 | {$ELSE} | |
2682 | Result : = FindCmdL ineSwitch( SwitchName , ReturnVa lue, TRUE, | |
2683 | [clstV alueAppend ed]); | |
2684 | {$ENDIF} | |
2685 | end; | |
2686 | ||
2687 | Function F indCommand Switch(Swi tchName: s tring): Bo olean; | |
2688 | begin | |
2689 | {$IFDEF VE R180} | |
2690 | Result : = D2006Fin dCmdLineSw itch(Switc hName, ['- '], TRUE); | |
2691 | {$ELSE} | |
2692 | Result : = FindCmdL ineSwitch( SwitchName , ['-'], T RUE); | |
2693 | {$ENDIF} | |
2694 | end; | |
2695 | ||
2696 | initializa tion | |
2697 | ||
2698 | LogInterfa ce.Active := FindCom mandSwitch ('JL'); | |
2699 | ||
2700 | CoInitiali zeEx(nil, COINIT_APA RTMENTTHRE ADED); // COINIT_MUL TITHREADED ); | |
2701 | ||
2702 | Applicatio n.MainForm OnTaskbar := TRUE; | |
2703 | ||
2704 | finalizati on | |
2705 | ||
2706 | ShutDown; | |
2707 | ||
2708 | CoUninitia lize; | |
2709 | ||
2710 | end. |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.