Rev 83 | Rev 85 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 83 | Rev 84 | ||
---|---|---|---|
Line 10... | Line 10... | ||
10 | 10 | ||
11 | uses |
11 | uses |
12 | Windows, SysUtils, Classes, IniFiles, Contnrs, Dialogs, UD2_PluginIntf, |
12 | Windows, SysUtils, Classes, IniFiles, Contnrs, Dialogs, UD2_PluginIntf, |
13 | UD2_PluginStatus, UD2_Utils; |
13 | UD2_PluginStatus, UD2_Utils; |
14 | 14 | ||
15 | const |
- | |
16 | cchBufferSize = 32768; |
- | |
17 | - | ||
18 | dynamicDataDelim = '|||'; |
- | |
19 | - | ||
20 | type |
15 | type |
21 | TUD2IdentificationEntry = class; |
16 | TUD2IdentificationEntry = class; |
22 | 17 | ||
23 | TUD2Plugin = class(TObject) |
18 | TUD2Plugin = class(TObject) |
24 | protected |
19 | protected |
Line 79... | Line 74... | ||
79 | public |
74 | public |
80 | property IniFileName: string read FIniFileName; |
75 | property IniFileName: string read FIniFileName; |
81 | property Errors: TStrings read FErrors; |
76 | property Errors: TStrings read FErrors; |
82 | property LoadedPlugins: TObjectList{<TUD2Plugin>} read FLoadedPlugins; |
77 | property LoadedPlugins: TObjectList{<TUD2Plugin>} read FLoadedPlugins; |
83 | property IniFile: TMemIniFile read FIniFile; |
78 | property IniFile: TMemIniFile read FIniFile; |
84 | procedure GetAllIdNames(outSL: TStrings); |
79 | procedure GetAllDetectedIDs(outSL: TStrings); |
85 | function FulfilsEverySubterm(idTerm: WideString; slIdNames: TStrings=nil): boolean; |
80 | function FulfilsEverySubterm(idTerm: WideString; slIdNames: TStrings=nil): boolean; |
86 | procedure CheckTerm(idTermAndCmd: string; commandSLout: TStrings; slIdNames: TStrings=nil); |
81 | procedure CheckTerm(idTermAndCmd: string; commandSLout: TStrings; slIdNames: TStrings=nil); |
87 | function FindPluginByMethodNameOrGuid(idMethodName: string): TUD2Plugin; |
82 | function FindPluginByMethodNameOrGuid(idMethodName: string): TUD2Plugin; |
88 | procedure GetCommandList(ShortTaskName: string; outSL: TStrings); |
83 | procedure GetCommandList(ShortTaskName: string; outSL: TStrings); |
89 | procedure HandlePluginDir(APluginDir, AFileMask: string); |
84 | procedure HandlePluginDir(APluginDir, AFileMask: string); |
Line 100... | Line 95... | ||
100 | implementation |
95 | implementation |
101 | 96 | ||
102 | uses |
97 | uses |
103 | Math; |
98 | Math; |
104 | 99 | ||
- | 100 | const |
|
- | 101 | cchBufferSize = 32768; |
|
- | 102 | ||
105 | type |
103 | type |
106 | TUD2PluginLoader = class(TThread) |
104 | TUD2PluginLoader = class(TThread) |
107 | protected |
105 | protected |
108 | dllFile: string; |
106 | dllFile: string; |
109 | lngID: LANGID; |
107 | lngID: LANGID; |
Line 253... | Line 251... | ||
253 | 251 | ||
254 | procedure TUD2IdentificationEntry.GetIdNames(sl: TStrings); |
252 | procedure TUD2IdentificationEntry.GetIdNames(sl: TStrings); |
255 | begin |
253 | begin |
256 | if DynamicDataUsed then |
254 | if DynamicDataUsed then |
257 | begin |
255 | begin |
258 | sl.Add(DynamicData+dynamicDataDelim+Plugin.IdentificationMethodName+':'+IdentificationString); |
256 | sl.Add(Plugin.IdentificationMethodName+'('+DynamicData+'):'+IdentificationString); |
259 | sl.Add(DynamicData+DynamicDataDelim+Plugin.PluginGUIDString+':'+IdentificationString); |
257 | sl.Add(Plugin.PluginGUIDString+'('+DynamicData+'):'+IdentificationString); |
260 | end |
258 | end |
261 | else |
259 | else |
262 | begin |
260 | begin |
263 | sl.Add(Plugin.IdentificationMethodName+':'+IdentificationString); |
261 | sl.Add(Plugin.IdentificationMethodName+':'+IdentificationString); |
264 | sl.Add(Plugin.PluginGUIDString+':'+IdentificationString); |
262 | sl.Add(Plugin.PluginGUIDString+':'+IdentificationString); |
Line 414... | Line 412... | ||
414 | result := BetterInterpreteBool(IniFile.ReadString(ShortTaskName, MetatagName, DefaultVal)); |
412 | result := BetterInterpreteBool(IniFile.ReadString(ShortTaskName, MetatagName, DefaultVal)); |
415 | end; |
413 | end; |
416 | 414 | ||
417 | (* |
415 | (* |
418 | 416 | ||
419 | NAMING EXAMPLE: dynXYZ|||ComputerName:ABC&&User:John=calc.exe |
417 | NAMING EXAMPLE: $CASESENSITIVE$ComputerName(dynXYZ):ABC&&User:John=calc.exe$RIOD$ |
420 | 418 | ||
421 | idTerm: dynXYZ|||ComputerName:ABC&&User:John |
419 | idTerm: ComputerName(dynXYZ):ABC&&User:John |
422 | idName: ComputerName:ABC |
420 | idName: ComputerName:ABC |
423 | IdMethodName: ComputerName |
421 | IdMethodName: ComputerName |
424 | IdStr ABC |
422 | IdStr ABC |
425 | cmd: calc.exe |
423 | cmd: calc.exe |
426 | dynamicData: dynXYZ |
424 | dynamicData: dynXYZ |
427 | 425 | ||
428 | *) |
426 | *) |
429 | 427 | ||
430 | procedure TUD2.GetAllIdNames(outSL: TStrings); |
428 | procedure TUD2.GetAllDetectedIDs(outSL: TStrings); |
431 | var |
429 | var |
432 | i, j: integer; |
430 | i, j: integer; |
433 | pl: TUD2Plugin; |
431 | pl: TUD2Plugin; |
434 | ude: TUD2IdentificationEntry; |
432 | ude: TUD2IdentificationEntry; |
435 | begin |
433 | begin |
Line 446... | Line 444... | ||
446 | 444 | ||
447 | function TUD2.FulfilsEverySubterm(idTerm: WideString; slIdNames: TStrings=nil): boolean; |
445 | function TUD2.FulfilsEverySubterm(idTerm: WideString; slIdNames: TStrings=nil): boolean; |
448 | const |
446 | const |
449 | CASE_SENSITIVE_FLAG = '$CASESENSITIVE$'; |
447 | CASE_SENSITIVE_FLAG = '$CASESENSITIVE$'; |
450 | var |
448 | var |
451 | x, y, z: TArrayOfString; |
449 | x, a, b: TArrayOfString; |
452 | i: integer; |
450 | i: integer; |
453 | p: TUD2Plugin; |
451 | p: TUD2Plugin; |
454 | idName: WideString; |
452 | idName: WideString; |
455 | cleanUpStringList: boolean; |
453 | cleanUpStringList: boolean; |
456 | caseSensitive: boolean; |
454 | caseSensitive: boolean; |
Line 460... | Line 458... | ||
460 | cleanUpStringList := slIdNames = nil; |
458 | cleanUpStringList := slIdNames = nil; |
461 | try |
459 | try |
462 | if cleanUpStringList then |
460 | if cleanUpStringList then |
463 | begin |
461 | begin |
464 | slIdNames := TStringList.Create; |
462 | slIdNames := TStringList.Create; |
465 | GetAllIdNames(slIdNames); |
463 | GetAllDetectedIDs(slIdNames); |
466 | end; |
464 | end; |
467 | 465 | ||
468 | SetLength(x, 0); |
466 | SetLength(x, 0); |
469 | if Pos(':', idTerm) = 0 then |
467 | if Pos(':', idTerm) = 0 then |
470 | begin |
468 | begin |
Line 478... | Line 476... | ||
478 | begin |
476 | begin |
479 | idName := x[i]; |
477 | idName := x[i]; |
480 | 478 | ||
481 | /// --- Start Dynamic Extension |
479 | /// --- Start Dynamic Extension |
482 | 480 | ||
483 | SetLength(y, 0); |
481 | // xxxxxx ( xxxxx ): xxxxxxxxxxxx |
484 | y := SplitString(dynamicDataDelim, idName); |
482 | // xxxxx ( xx:xx ): xxxxx:xxx(x) |
- | 483 | // xxxxxxxxxxxx : xxxxx(xxx)xx |
|
485 | 484 | ||
- | 485 | SetLength(a, 0); |
|
- | 486 | a := SplitString('(', idName); |
|
- | 487 | if (Length(a) >= 2) and (Pos(':', a[0]) = 0) then |
|
- | 488 | begin |
|
- | 489 | SetLength(b, 0); |
|
- | 490 | b := SplitString('):', a[1]); |
|
486 | if Length(y) >= 2 then |
491 | if Length(b) >= 2 then |
487 | begin |
492 | begin |
488 | dynamicData := y[0]; |
493 | dynamicData := b[0]; |
489 | - | ||
490 | SetLength(z, 0); |
- | |
491 | z := SplitString(':', y[1]); |
- | |
492 | idMethodName := z[0]; |
494 | idMethodName := a[0]; |
493 | 495 | ||
494 | p := FindPluginByMethodNameOrGuid(idMethodName); |
496 | p := FindPluginByMethodNameOrGuid(idMethodName); |
495 | if Assigned(p) then |
497 | if Assigned(p) then |
496 | begin |
498 | begin |
497 | if p.InvokeDynamicCheck(dynamicData) then |
499 | if p.InvokeDynamicCheck(dynamicData) then |
498 | begin |
500 | begin |
499 | // Reload the identifications |
501 | // Reload the identifications |
500 | slIdNames.Clear; |
502 | slIdNames.Clear; |
501 | GetAllIdNames(slIdNames); |
503 | GetAllDetectedIDs(slIdNames); |
- | 504 | end; |
|
502 | end; |
505 | end; |
503 | end; |
506 | end; |
504 | end; |
507 | end; |
505 | 508 | ||
506 | /// --- End Dynamic Extension |
509 | /// --- End Dynamic Extension |
Line 551... | Line 554... | ||
551 | i: integer; |
554 | i: integer; |
552 | slSV, slIdNames: TStrings; |
555 | slSV, slIdNames: TStrings; |
553 | begin |
556 | begin |
554 | slIdNames := TStringList.Create; |
557 | slIdNames := TStringList.Create; |
555 | try |
558 | try |
556 | GetAllIdNames(slIdNames); |
559 | GetAllDetectedIDs(slIdNames); |
557 | 560 | ||
558 | slSV := TStringList.Create; |
561 | slSV := TStringList.Create; |
559 | try |
562 | try |
560 | FIniFile.ReadSectionValues(ShortTaskName, slSV); |
563 | FIniFile.ReadSectionValues(ShortTaskName, slSV); |
561 | for i := 0 to slSV.Count-1 do |
564 | for i := 0 to slSV.Count-1 do |
Line 580... | Line 583... | ||
580 | try |
583 | try |
581 | if not Assigned(slIdNames) then |
584 | if not Assigned(slIdNames) then |
582 | begin |
585 | begin |
583 | slIdNamesCreated := true; |
586 | slIdNamesCreated := true; |
584 | slIdNames := TStringList.Create; |
587 | slIdNames := TStringList.Create; |
585 | GetAllIdNames(slIdNames); |
588 | GetAllDetectedIDs(slIdNames); |
586 | end; |
589 | end; |
587 | 590 | ||
588 | SetLength(nameVal, 0); |
591 | SetLength(nameVal, 0); |
589 | 592 | ||
590 | // We are doing the interpretation of the line ourselves, because |
593 | // We are doing the interpretation of the line ourselves, because |