Subversion Repositories userdetect2

Rev

Rev 80 | Rev 82 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 80 Rev 81
Line 6... Line 6...
6
{$LEGACYIFEND ON}
6
{$LEGACYIFEND ON}
7
{$IFEND}
7
{$IFEND}
8
 
8
 
9
{$INCLUDE 'UserDetect2.inc'}
9
{$INCLUDE 'UserDetect2.inc'}
10
 
10
 
-
 
11
{$WARN UNSAFE_CODE OFF}
-
 
12
{$WARN UNSAFE_TYPE OFF}
-
 
13
 
11
uses
14
uses
12
  Windows, SysUtils, Classes, IniFiles, Contnrs, Dialogs, UD2_PluginIntf,
15
  Windows, SysUtils, Classes, IniFiles, Contnrs, Dialogs, UD2_PluginIntf,
13
  UD2_PluginStatus;
16
  UD2_PluginStatus;
14
 
17
 
15
const
18
const
Line 65... Line 68...
65
  public
68
  public
66
    property IniFileName: string read FIniFileName;
69
    property IniFileName: string read FIniFileName;
67
    property Errors: TStrings read FErrors;
70
    property Errors: TStrings read FErrors;
68
    property LoadedPlugins: TObjectList{<TUD2Plugin>} read FLoadedPlugins;
71
    property LoadedPlugins: TObjectList{<TUD2Plugin>} read FLoadedPlugins;
69
    property IniFile: TMemIniFile read FIniFile;
72
    property IniFile: TMemIniFile read FIniFile;
-
 
73
 
-
 
74
procedure GetAllIdNames(outSL: TStrings);
-
 
75
function FulfilsEverySubterm(idTerm: WideString; slIdNames: TStrings=nil): boolean;
-
 
76
 
-
 
77
 
70
    procedure GetCommandList(ShortTaskName: string; outSL: TStrings);
78
    procedure GetCommandList(ShortTaskName: string; outSL: TStrings);
71
    procedure HandlePluginDir(APluginDir, AFileMask: string);
79
    procedure HandlePluginDir(APluginDir, AFileMask: string);
72
    procedure GetTaskListing(outSL: TStrings);
80
    procedure GetTaskListing(outSL: TStrings);
73
    constructor Create(AIniFileName: string);
81
    constructor Create(AIniFileName: string);
74
    destructor Destroy; override;
82
    destructor Destroy; override;
Line 200... Line 208...
200
  i: integer;
208
  i: integer;
201
  {$IFDEF CHECK_FOR_SAME_PLUGIN_GUID}
209
  {$IFDEF CHECK_FOR_SAME_PLUGIN_GUID}
202
  sPluginID, prevDLL: string;
210
  sPluginID, prevDLL: string;
203
  {$ENDIF}
211
  {$ENDIF}
204
  lngid: LANGID;
212
  lngid: LANGID;
205
  maskpath: string;
-
 
206
resourcestring
213
resourcestring
207
  LNG_PLUGINS_SAME_GUID = 'Attention: The plugin "%s" and the plugin "%s" have the same identification GUID. The latter will not be loaded.';
214
  LNG_PLUGINS_SAME_GUID = 'Attention: The plugin "%s" and the plugin "%s" have the same identification GUID. The latter will not be loaded.';
208
begin
215
begin
209
  tob := TObjectList.Create;
216
  tob := TObjectList.Create;
210
  try
217
  try
Line 338... Line 345...
338
        IdStr         ABC
345
        IdStr         ABC
339
        cmd:          calc.exe
346
        cmd:          calc.exe
340
 
347
 
341
*)
348
*)
342
 
349
 
343
procedure TUD2.GetCommandList(ShortTaskName: string; outSL: TStrings);
350
procedure TUD2.GetAllIdNames(outSL: TStrings);
344
var
351
var
345
  i, j: integer;
352
  i, j: integer;
346
  cmd: string;
-
 
347
  idTerm, idName: WideString;
-
 
348
  slSV, slIdNames: TStrings;
-
 
349
  x: TArrayOfString;
-
 
350
  nameVal: TArrayOfString;
-
 
351
  FulfilsEverySubterm: boolean;
-
 
352
  pl: TUD2Plugin;
353
  pl: TUD2Plugin;
353
  ude: TUD2IdentificationEntry;
354
  ude: TUD2IdentificationEntry;
354
begin
355
begin
355
  SetLength(x, 0);
-
 
356
  SetLength(nameVal, 0);
-
 
357
 
-
 
358
  slIdNames := TStringList.Create;
-
 
359
  try
-
 
360
    for i := 0 to LoadedPlugins.Count-1 do
356
  for i := 0 to LoadedPlugins.Count-1 do
361
    begin
357
  begin
362
      pl := LoadedPlugins.Items[i] as TUD2Plugin;
358
    pl := LoadedPlugins.Items[i] as TUD2Plugin;
363
      for j := 0 to pl.DetectedIdentifications.Count-1 do
359
    for j := 0 to pl.DetectedIdentifications.Count-1 do
364
      begin
360
    begin
365
        ude := pl.DetectedIdentifications.Items[j] as TUD2IdentificationEntry;
361
      ude := pl.DetectedIdentifications.Items[j] as TUD2IdentificationEntry;
366
        ude.GetIdNames(slIdNames);
362
      ude.GetIdNames(outSL);
-
 
363
    end;
367
      end;
364
  end;
368
    end;
365
end;
369
 
366
 
-
 
367
function TUD2.FulfilsEverySubterm(idTerm: WideString; slIdNames: TStrings=nil): boolean;
-
 
368
var
-
 
369
  x: TArrayOfString;
-
 
370
  i: integer;
-
 
371
  idName: WideString;
370
    slSV := TStringList.Create;
372
  cleanUpStringList: boolean;
-
 
373
begin
-
 
374
  cleanUpStringList := slIdNames = nil;
371
    try
375
  try
372
      FIniFile.ReadSectionValues(ShortTaskName, slSV);
-
 
373
      for j := 0 to slSV.Count-1 do
376
    if cleanUpStringList then
374
      begin
377
    begin
375
        // We are doing the interpretation of the line ourselves, because
-
 
376
        // TStringList.Values[] would not allow multiple command lines with the
-
 
377
        // same key (idTerm)
-
 
378
        nameVal := SplitString('=', slSV.Strings[j]);
378
      slIdNames := TStringList.Create;
379
        idTerm := nameVal[0];
379
      GetAllIdNames(slIdNames);
380
        cmd    := nameVal[1];
380
    end;
381
 
381
 
-
 
382
    SetLength(x, 0);
382
        if Pos(':', idTerm) = 0 then Continue;
383
    if Pos(':', idTerm) = 0 then
-
 
384
    begin
-
 
385
      result := false;
-
 
386
      Exit;
-
 
387
    end;
383
        x := SplitString('&&', idTerm);
388
    x := SplitString('&&', idTerm);
384
        FulfilsEverySubterm := true;
389
    result := true;
385
        for i := Low(x) to High(x) do
390
    for i := Low(x) to High(x) do
386
        begin
391
    begin
387
          idName := x[i];
392
      idName := x[i];
388
 
393
 
389
          if slIdNames.IndexOf(idName) = -1 then
394
      if slIdNames.IndexOf(idName) = -1 then
390
          begin
395
      begin
391
            FulfilsEverySubterm := false;
396
        result := false;
392
            break;
397
        break;
393
          end;
398
      end;
394
        end;
399
    end;
-
 
400
  finally
-
 
401
    if cleanUpStringList and Assigned(slIdNames) then
-
 
402
      slIdNames.Free;
-
 
403
  end;
-
 
404
end;
-
 
405
 
-
 
406
procedure TUD2.GetCommandList(ShortTaskName: string; outSL: TStrings);
-
 
407
var
-
 
408
  i: integer;
-
 
409
  cmd: string;
-
 
410
  idTerm: WideString;
-
 
411
  slSV, slIdNames: TStrings;
-
 
412
  nameVal: TArrayOfString;
-
 
413
begin
-
 
414
  SetLength(nameVal, 0);
-
 
415
 
-
 
416
  slIdNames := TStringList.Create;
-
 
417
  try
-
 
418
    GetAllIdNames(slIdNames);
-
 
419
 
-
 
420
    slSV := TStringList.Create;
-
 
421
    try
-
 
422
      FIniFile.ReadSectionValues(ShortTaskName, slSV);
-
 
423
      for i := 0 to slSV.Count-1 do
-
 
424
      begin
-
 
425
        // We are doing the interpretation of the line ourselves, because
-
 
426
        // TStringList.Values[] would not allow multiple command lines with the
-
 
427
        // same key (idTerm)
-
 
428
        nameVal := SplitString('=', slSV.Strings[i]);
-
 
429
        idTerm := nameVal[0];
-
 
430
        cmd    := nameVal[1];
395
 
431
 
396
        if FulfilsEverySubterm then outSL.Add(cmd);
432
        if FulfilsEverySubterm(idTerm, slIdNames) then outSL.Add(cmd);
397
      end;
433
      end;
398
    finally
434
    finally
399
      slSV.Free;
435
      slSV.Free;
400
    end;
436
    end;
401
  finally
437
  finally