Subversion Repositories userdetect2

Rev

Rev 92 | Rev 95 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 92 Rev 94
1
unit UD2_Main;
1
unit UD2_Main;
2
 
2
 
3
interface
3
interface
4
 
4
 
5
{$IF CompilerVersion >= 25.0}
5
{$IF CompilerVersion >= 25.0}
6
{$LEGACYIFEND ON}
6
{$LEGACYIFEND ON}
7
{$IFEND}
7
{$IFEND}
8
 
8
 
9
{$INCLUDE 'UserDetect2.inc'}
9
{$INCLUDE 'UserDetect2.inc'}
10
 
10
 
11
uses
11
uses
12
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
12
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
13
  Dialogs, StdCtrls, Grids, ValEdit, UD2_Obj, ComCtrls, ImgList, ExtCtrls,
13
  Dialogs, StdCtrls, Grids, ValEdit, UD2_Obj, ComCtrls, ImgList, ExtCtrls,
14
  CommCtrl, Menus, VTSListView, VTSCompat, UD2_PluginStatus, Contnrs,
14
  CommCtrl, Menus, VTSListView, VTSCompat, UD2_PluginStatus, Contnrs,
15
  System.ImageList;
15
  System.ImageList;
16
 
16
 
17
const
17
const
18
  DefaultIniFile = 'UserDetect2.ini';
18
  DefaultIniFile = 'UserDetect2.ini';
19
  DefaultWarnIfNothingMatchesGUI = 'true';
19
  DefaultWarnIfNothingMatchesGUI = 'true';
20
  TagWarnIfNothingMatchesGUI = 'WarnIfNothingMatches.GUI';
20
  TagWarnIfNothingMatchesGUI = 'WarnIfNothingMatches.GUI';
21
  DefaultWarnIfNothingMatchesCLI = 'false';
21
  DefaultWarnIfNothingMatchesCLI = 'false';
22
  TagWarnIfNothingMatchesCLI = 'WarnIfNothingMatches.CLI';
22
  TagWarnIfNothingMatchesCLI = 'WarnIfNothingMatches.CLI';
23
  DefaultCloseAfterLaunching = 'false';
23
  DefaultCloseAfterLaunching = 'false';
24
  TagCloseAfterLaunching = 'CloseAfterLaunching';
24
  TagCloseAfterLaunching = 'CloseAfterLaunching';
25
  TagIcon = 'Icon';
25
  TagIcon = 'Icon';
26
 
26
 
27
type
27
type
28
  TUD2MainForm = class(TForm)
28
  TUD2MainForm = class(TForm)
29
    OpenDialog1: TOpenDialog;
29
    OpenDialog1: TOpenDialog;
30
    PageControl1: TPageControl;
30
    PageControl1: TPageControl;
31
    TasksTabSheet: TTabSheet;
31
    TasksTabSheet: TTabSheet;
32
    TabSheet2: TTabSheet;
32
    TabSheet2: TTabSheet;
33
    TabSheet3: TTabSheet;
33
    TabSheet3: TTabSheet;
34
    IniTemplateMemo: TMemo;
34
    IniTemplateMemo: TMemo;
35
    TabSheet4: TTabSheet;
35
    TabSheet4: TTabSheet;
36
    TasksListView: TVTSListView;
36
    TasksListView: TVTSListView;
37
    TasksImageList: TImageList;
37
    TasksImageList: TImageList;
38
    SaveDialog1: TSaveDialog;
38
    SaveDialog1: TSaveDialog;
39
    TabSheet5: TTabSheet;
39
    TabSheet5: TTabSheet;
40
    Image1: TImage;
40
    Image1: TImage;
41
    Label1: TLabel;
41
    Label1: TLabel;
42
    Label2: TLabel;
42
    Label2: TLabel;
43
    Label3: TLabel;
43
    Label3: TLabel;
44
    Label4: TLabel;
44
    Label4: TLabel;
45
    Label5: TLabel;
45
    Label5: TLabel;
46
    Label6: TLabel;
46
    Label6: TLabel;
47
    Label7: TLabel;
47
    Label7: TLabel;
48
    Label8: TLabel;
48
    Label8: TLabel;
49
    LoadedPluginsListView: TVTSListView;
49
    LoadedPluginsListView: TVTSListView;
50
    IdentificationsListView: TVTSListView;
50
    IdentificationsListView: TVTSListView;
51
    ErrorsTabSheet: TTabSheet;
51
    ErrorsTabSheet: TTabSheet;
52
    ErrorsMemo: TMemo;
52
    ErrorsMemo: TMemo;
53
    Memo1: TMemo;
53
    Memo1: TMemo;
54
    Panel1: TPanel;
54
    Panel1: TPanel;
55
    OpenTDFButton: TButton;
55
    OpenTDFButton: TButton;
56
    SaveTDFButton: TButton;
56
    SaveTDFButton: TButton;
57
    TasksPopupMenu: TPopupMenu;
57
    TasksPopupMenu: TPopupMenu;
58
    Run1: TMenuItem;
58
    Run1: TMenuItem;
59
    Properties1: TMenuItem;
59
    Properties1: TMenuItem;
60
    IdentificationsPopupMenu: TPopupMenu;
60
    IdentificationsPopupMenu: TPopupMenu;
61
    CopyTaskDefinitionExample1: TMenuItem;
61
    CopyTaskDefinitionExample1: TMenuItem;
62
    Button3: TButton;
62
    Button3: TButton;
63
    VersionLabel: TLabel;
63
    VersionLabel: TLabel;
64
    LoadedPluginsPopupMenu: TPopupMenu;
64
    LoadedPluginsPopupMenu: TPopupMenu;
65
    MenuItem1: TMenuItem;
65
    CopyStatusCodeToClipboard: TMenuItem;
66
    Panel2: TPanel;
66
    Panel2: TPanel;
67
    Image2: TImage;
67
    Image2: TImage;
68
    DynamicTestGroupbox: TGroupBox;
68
    DynamicTestGroupbox: TGroupBox;
69
    DynamicTestPluginComboBox: TComboBox;
69
    DynamicTestPluginComboBox: TComboBox;
70
    DynamicTestPluginLabel: TLabel;
70
    DynamicTestPluginLabel: TLabel;
71
    DynamicTestDataLabel: TLabel;
71
    DynamicTestDataLabel: TLabel;
72
    DynamicTestDataEdit: TEdit;
72
    DynamicTestDataEdit: TEdit;
73
    DynamicTestButton: TButton;
73
    DynamicTestButton: TButton;
74
    procedure FormDestroy(Sender: TObject);
74
    procedure FormDestroy(Sender: TObject);
75
    procedure TasksListViewDblClick(Sender: TObject);
75
    procedure TasksListViewDblClick(Sender: TObject);
76
    procedure TasksListViewKeyPress(Sender: TObject; var Key: Char);
76
    procedure TasksListViewKeyPress(Sender: TObject; var Key: Char);
77
    procedure OpenTDFButtonClick(Sender: TObject);
77
    procedure OpenTDFButtonClick(Sender: TObject);
78
    procedure SaveTDFButtonClick(Sender: TObject);
78
    procedure SaveTDFButtonClick(Sender: TObject);
79
    procedure URLLabelClick(Sender: TObject);
79
    procedure URLLabelClick(Sender: TObject);
80
    procedure TasksPopupMenuPopup(Sender: TObject);
80
    procedure TasksPopupMenuPopup(Sender: TObject);
81
    procedure Run1Click(Sender: TObject);
81
    procedure Run1Click(Sender: TObject);
82
    procedure Properties1Click(Sender: TObject);
82
    procedure Properties1Click(Sender: TObject);
83
    procedure IdentificationsPopupMenuPopup(Sender: TObject);
83
    procedure IdentificationsPopupMenuPopup(Sender: TObject);
84
    procedure CopyTaskDefinitionExample1Click(Sender: TObject);
84
    procedure CopyTaskDefinitionExample1Click(Sender: TObject);
85
    procedure ListViewCompare(Sender: TObject; Item1, Item2: TListItem; Data: Integer; var Compare: Integer);
85
    procedure ListViewCompare(Sender: TObject; Item1, Item2: TListItem; Data: Integer; var Compare: Integer);
86
    procedure Button3Click(Sender: TObject);
86
    procedure Button3Click(Sender: TObject);
87
    procedure LoadedPluginsPopupMenuPopup(Sender: TObject);
87
    procedure LoadedPluginsPopupMenuPopup(Sender: TObject);
88
    procedure MenuItem1Click(Sender: TObject);
88
    procedure CopyStatusCodeToClipboardClick(Sender: TObject);
89
    procedure FormCreate(Sender: TObject);
89
    procedure FormCreate(Sender: TObject);
90
    procedure DynamicTestButtonClick(Sender: TObject);
90
    procedure DynamicTestButtonClick(Sender: TObject);
91
  protected
91
  protected
92
    ud2: TUD2;
92
    ud2: TUD2;
93
    procedure LoadTaskList;
93
    procedure LoadTaskList;
94
    procedure LoadDetectedIDs;
94
    procedure LoadDetectedIDs;
95
    procedure LoadINITemplate;
95
    procedure LoadINITemplate;
96
    procedure LoadLoadedPluginList;
96
    procedure LoadLoadedPluginList;
97
    procedure LoadDynamicPluginList;
97
    procedure LoadDynamicPluginList;
98
    function GetIniFileName: string;
98
    function GetIniFileName: string;
99
    procedure DoRun(ShortTaskName: string; gui: boolean);
99
    procedure DoRun(ShortTaskName: string; gui: boolean);
100
    procedure CheckForErrors;
100
    procedure CheckForErrors;
101
  public
101
  public
102
    procedure Run;
102
    procedure Run;
103
  end;
103
  end;
104
 
104
 
105
var
105
var
106
  UD2MainForm: TUD2MainForm;
106
  UD2MainForm: TUD2MainForm;
107
 
107
 
108
implementation
108
implementation
109
 
109
 
110
{$R *.dfm}
110
{$R *.dfm}
111
 
111
 
112
uses
112
uses
113
  ShellAPI, Clipbrd, Math, AlphaNumSort, UD2_Utils, UD2_TaskProperties, UD2_Parsing;
113
  ShellAPI, Clipbrd, Math, AlphaNumSort, UD2_Utils, UD2_TaskProperties, UD2_Parsing;
114
 
114
 
115
type
115
type
116
  TUD2ListViewEntry = class(TObject)
116
  TUD2ListViewEntry = class(TObject)
117
    ShortTaskName: string;
117
    ShortTaskName: string;
118
    CloseAfterLaunching: boolean;
118
    CloseAfterLaunching: boolean;
119
    TaskPropertiesForm: TForm;
119
    TaskPropertiesForm: TForm;
120
  end;
120
  end;
121
 
121
 
122
function AddIconRecToImageList(rec: TIconFileIdx; ImageList: TImageList): integer;
122
function AddIconRecToImageList(rec: TIconFileIdx; ImageList: TImageList): integer;
123
var
123
var
124
  icon: TIcon;
124
  icon: TIcon;
125
begin
125
begin
126
  icon := TIcon.Create;
126
  icon := TIcon.Create;
127
  try
127
  try
128
    icon.Handle := ExtractIcon(Application.Handle, PChar(rec.FileName), rec.IconIndex);
128
    icon.Handle := ExtractIcon(Application.Handle, PChar(rec.FileName), rec.IconIndex);
129
 
129
 
130
    // result := ImageList.AddIcon(ico);
130
    // result := ImageList.AddIcon(ico);
131
    result := AddTransparentIconToImageList(ImageList, icon);
131
    result := AddTransparentIconToImageList(ImageList, icon);
132
  finally
132
  finally
133
    icon.Free;
133
    icon.Free;
134
  end;
134
  end;
135
end;
135
end;
136
 
136
 
137
{ TUD2MainForm }
137
{ TUD2MainForm }
138
 
138
 
139
function TUD2MainForm.GetIniFileName: string;
139
function TUD2MainForm.GetIniFileName: string;
140
resourcestring
140
resourcestring
141
  LNG_FILE_NOT_FOUND = 'File "%s" not found.';
141
  LNG_FILE_NOT_FOUND = 'File "%s" not found.';
142
begin
142
begin
143
  if (ParamCount >= 1) and not CheckBoolParam(1, 'C') then
143
  if (ParamCount >= 1) and not CheckBoolParam(1, 'C') then
144
  begin
144
  begin
145
    if FileExists(ParamStr(1)) then
145
    if FileExists(ParamStr(1)) then
146
    begin
146
    begin
147
      result := ParamStr(1);
147
      result := ParamStr(1);
148
    end
148
    end
149
    else
149
    else
150
    begin
150
    begin
151
      ExitCode := EXITCODE_INI_NOT_FOUND;
151
      ExitCode := EXITCODE_INI_NOT_FOUND;
152
      MessageDlg(Format(LNG_FILE_NOT_FOUND, [ParamStr(1)]), mtError, [mbOK], 0);
152
      MessageDlg(Format(LNG_FILE_NOT_FOUND, [ParamStr(1)]), mtError, [mbOK], 0);
153
      result := '';
153
      result := '';
154
    end;
154
    end;
155
    Exit;
155
    Exit;
156
  end
156
  end
157
  else
157
  else
158
  begin
158
  begin
159
    if FileExists(DefaultIniFile) then
159
    if FileExists(DefaultIniFile) then
160
    begin
160
    begin
161
      result := DefaultIniFile;
161
      result := DefaultIniFile;
162
      Exit;
162
      Exit;
163
    end;
163
    end;
164
 
164
 
165
    if FileExists(GetOwnCmdName + '.ini') then
165
    if FileExists(GetOwnCmdName + '.ini') then
166
    begin
166
    begin
167
      result := GetOwnCmdName + '.ini';
167
      result := GetOwnCmdName + '.ini';
168
      Exit;
168
      Exit;
169
    end;
169
    end;
170
 
170
 
171
    if CompatOpenDialogExecute(OpenDialog1) then
171
    if CompatOpenDialogExecute(OpenDialog1) then
172
    begin
172
    begin
173
      result := OpenDialog1.FileName;
173
      result := OpenDialog1.FileName;
174
      Exit;
174
      Exit;
175
    end;
175
    end;
176
 
176
 
177
    result := '';
177
    result := '';
178
    Exit;
178
    Exit;
179
  end;
179
  end;
180
end;
180
end;
181
 
181
 
182
procedure TUD2MainForm.LoadTaskList;
182
procedure TUD2MainForm.LoadTaskList;
183
var
183
var
184
  sl: TStringList;
184
  sl: TStringList;
185
  i: integer;
185
  i: integer;
186
  ShortTaskName, iconString: string;
186
  ShortTaskName, iconString: string;
187
  iconIndex: integer;
187
  iconIndex: integer;
188
  obj: TUD2ListViewEntry;
188
  obj: TUD2ListViewEntry;
189
begin
189
begin
190
  for i := 0 to TasksListView.Items.Count-1 do
190
  for i := 0 to TasksListView.Items.Count-1 do
191
  begin
191
  begin
192
    TUD2ListViewEntry(TasksListView.Items.Item[i].Data).Free;
192
    TUD2ListViewEntry(TasksListView.Items.Item[i].Data).Free;
193
  end;
193
  end;
194
  TasksListView.Clear;
194
  TasksListView.Clear;
195
 
195
 
196
  sl := TStringList.Create;
196
  sl := TStringList.Create;
197
  try
197
  try
198
    ud2.GetTaskListing(sl);
198
    ud2.GetTaskListing(sl);
199
    for i := 0 to sl.Count-1 do
199
    for i := 0 to sl.Count-1 do
200
    begin
200
    begin
201
      ShortTaskName := sl.Names[i];
201
      ShortTaskName := sl.Names[i];
202
 
202
 
203
      Obj := TUD2ListViewEntry.Create;
203
      Obj := TUD2ListViewEntry.Create;
204
      Obj.ShortTaskName := ShortTaskName;
204
      Obj.ShortTaskName := ShortTaskName;
205
      Obj.CloseAfterLaunching := ud2.ReadMetatagBool(ShortTaskName, TagCloseAfterLaunching, DefaultCloseAfterLaunching);
205
      Obj.CloseAfterLaunching := ud2.ReadMetatagBool(ShortTaskName, TagCloseAfterLaunching, DefaultCloseAfterLaunching);
206
 
206
 
207
      TasksListView.AddItem(sl.Values[ShortTaskName], TObject(Obj));
207
      TasksListView.AddItem(sl.Values[ShortTaskName], TObject(Obj));
208
 
208
 
209
      iconString := ud2.ReadMetatagString(ShortTaskName, TagIcon, '');
209
      iconString := ud2.ReadMetatagString(ShortTaskName, TagIcon, '');
210
      if iconString <> '' then
210
      if iconString <> '' then
211
      begin
211
      begin
212
        iconIndex := AddIconRecToImageList(SplitIconString(iconString), TasksImageList);
212
        iconIndex := AddIconRecToImageList(SplitIconString(iconString), TasksImageList);
213
        if iconIndex <> -1 then
213
        if iconIndex <> -1 then
214
        begin
214
        begin
215
          TasksListView.Items.Item[TasksListView.Items.Count-1].ImageIndex := iconIndex;
215
          TasksListView.Items.Item[TasksListView.Items.Count-1].ImageIndex := iconIndex;
216
        end;
216
        end;
217
      end;
217
      end;
218
    end;
218
    end;
219
  finally
219
  finally
220
    sl.Free;
220
    sl.Free;
221
  end;
221
  end;
222
end;
222
end;
223
 
223
 
224
procedure TUD2MainForm.DoRun(ShortTaskName: string; gui: boolean);
224
procedure TUD2MainForm.DoRun(ShortTaskName: string; gui: boolean);
225
resourcestring
225
resourcestring
226
  LNG_TASK_NOT_EXISTS = 'The task "%s" does not exist in the INI file.';
226
  LNG_TASK_NOT_EXISTS = 'The task "%s" does not exist in the INI file.';
227
  LNG_NOTHING_MATCHES = 'No identification string matches to your environment. No application was launched. Please check the Task Definition File.';
227
  LNG_NOTHING_MATCHES = 'No identification string matches to your environment. No application was launched. Please check the Task Definition File.';
228
var
228
var
229
  i: integer;
229
  i: integer;
230
  cmds: TUD2CommandArray;
230
  cmds: TUD2CommandArray;
231
  showMismatchError: boolean;
231
  showMismatchError: boolean;
232
begin
232
begin
233
  if not ud2.TaskExists(ShortTaskName) then
233
  if not ud2.TaskExists(ShortTaskName) then
234
  begin
234
  begin
235
    // This can happen if the task name is taken from command line
235
    // This can happen if the task name is taken from command line
236
    MessageDlg(Format(LNG_TASK_NOT_EXISTS, [ShortTaskName]), mtError, [mbOK], 0);
236
    MessageDlg(Format(LNG_TASK_NOT_EXISTS, [ShortTaskName]), mtError, [mbOK], 0);
237
    ExitCode := EXITCODE_TASK_NOT_EXISTS;
237
    ExitCode := EXITCODE_TASK_NOT_EXISTS;
238
    Exit;
238
    Exit;
239
  end;
239
  end;
240
 
240
 
241
  SetLength(cmds, 0);
241
  SetLength(cmds, 0);
242
  cmds := ud2.GetCommandList(ShortTaskName); // TODO: What to do with AErrorOut (errors from dynamic queries?)
242
  cmds := ud2.GetCommandList(ShortTaskName); // TODO: What to do with AErrorOut (errors from dynamic queries?)
243
 
243
 
244
  if gui then
244
  if gui then
245
    showMismatchError := ud2.ReadMetatagBool(ShortTaskName, TagWarnIfNothingMatchesGUI, DefaultWarnIfNothingMatchesGUI)
245
    showMismatchError := ud2.ReadMetatagBool(ShortTaskName, TagWarnIfNothingMatchesGUI, DefaultWarnIfNothingMatchesGUI)
246
  else
246
  else
247
    showMismatchError := ud2.ReadMetatagBool(ShortTaskName, TagWarnIfNothingMatchesCLI, DefaultWarnIfNothingMatchesCLI);
247
    showMismatchError := ud2.ReadMetatagBool(ShortTaskName, TagWarnIfNothingMatchesCLI, DefaultWarnIfNothingMatchesCLI);
248
 
248
 
249
  if (Length(cmds) = 0) and showMismatchError then
249
  if (Length(cmds) = 0) and showMismatchError then
250
  begin
250
  begin
251
    MessageDlg(LNG_NOTHING_MATCHES, mtWarning, [mbOK], 0);
251
    MessageDlg(LNG_NOTHING_MATCHES, mtWarning, [mbOK], 0);
252
    ExitCode := EXITCODE_TASK_NOTHING_MATCHES;
252
    ExitCode := EXITCODE_TASK_NOTHING_MATCHES;
253
  end;
253
  end;
254
 
254
 
255
  for i := Low(cmds) to High(cmds) do
255
  for i := Low(cmds) to High(cmds) do
256
  begin
256
  begin
257
    UD2_RunCMD(cmds[i]);
257
    UD2_RunCMD(cmds[i]);
258
  end;
258
  end;
259
end;
259
end;
260
 
260
 
261
procedure TUD2MainForm.FormDestroy(Sender: TObject);
261
procedure TUD2MainForm.FormDestroy(Sender: TObject);
262
var
262
var
263
  i: integer;
263
  i: integer;
264
begin
264
begin
265
  if Assigned(ud2) then FreeAndNil(ud2);
265
  if Assigned(ud2) then FreeAndNil(ud2);
266
 
266
 
267
  for i := 0 to TasksListView.Items.Count-1 do
267
  for i := 0 to TasksListView.Items.Count-1 do
268
  begin
268
  begin
269
    TUD2ListViewEntry(TasksListView.Items.Item[i].Data).Free;
269
    TUD2ListViewEntry(TasksListView.Items.Item[i].Data).Free;
270
  end;
270
  end;
271
  TasksListView.Clear;
271
  TasksListView.Clear;
272
end;
272
end;
273
 
273
 
274
procedure TUD2MainForm.CheckForErrors;
274
procedure TUD2MainForm.CheckForErrors;
275
begin
275
begin
276
  ErrorsTabSheet.TabVisible := ud2.Errors.Count > 0;
276
  ErrorsTabSheet.TabVisible := ud2.Errors.Count > 0;
277
  if ErrorsTabSheet.TabVisible then
277
  if ErrorsTabSheet.TabVisible then
278
  begin
278
  begin
279
    ErrorsMemo.Lines.Assign(ud2.Errors);
279
    ErrorsMemo.Lines.Assign(ud2.Errors);
280
    PageControl1.ActivePage := ErrorsTabSheet;
280
    PageControl1.ActivePage := ErrorsTabSheet;
281
  end;
281
  end;
282
end;
282
end;
283
 
283
 
284
procedure TUD2MainForm.LoadDetectedIDs;
284
procedure TUD2MainForm.LoadDetectedIDs;
285
var
285
var
286
  i, j: integer;
286
  i, j: integer;
287
  pl: TUD2Plugin;
287
  pl: TUD2Plugin;
288
  ude: TUD2IdentificationEntry;
288
  ude: TUD2IdentificationEntry;
289
begin
289
begin
290
  IdentificationsListView.Clear;
290
  IdentificationsListView.Clear;
291
  for i := 0 to ud2.LoadedPlugins.Count-1 do
291
  for i := 0 to ud2.LoadedPlugins.Count-1 do
292
  begin
292
  begin
293
    pl := ud2.LoadedPlugins.Items[i] as TUD2Plugin;
293
    pl := ud2.LoadedPlugins.Items[i] as TUD2Plugin;
294
    for j := 0 to pl.DetectedIdentifications.Count-1 do
294
    for j := 0 to pl.DetectedIdentifications.Count-1 do
295
    begin
295
    begin
296
      ude := pl.DetectedIdentifications.Items[j] as TUD2IdentificationEntry;
296
      ude := pl.DetectedIdentifications.Items[j] as TUD2IdentificationEntry;
-
 
297
 
297
      with IdentificationsListView.Items.Add do
298
      with IdentificationsListView.Items.Add do
298
      begin
299
      begin
-
 
300
        Data := ude;
299
        Caption := pl.PluginName;
301
        Caption := pl.PluginName;
300
        if ude.DynamicDataUsed then
302
        if ude.DynamicDataUsed then
301
          SubItems.Add(ude.DynamicData)
303
          SubItems.Add(ude.DynamicData)
302
        else
304
        else
303
          SubItems.Add('');
305
          SubItems.Add('');
304
        SubItems.Add(pl.IdentificationMethodName);
306
        SubItems.Add(pl.IdentificationMethodName);
305
        SubItems.Add(ude.IdentificationString);
307
        SubItems.Add(ude.IdentificationString);
306
        SubItems.Add(pl.PluginGUIDString)
308
        SubItems.Add(pl.PluginGUIDString)
307
      end;
309
      end;
308
    end;
310
    end;
309
  end;
311
  end;
310
 
312
 
311
  for i := 0 to IdentificationsListView.Columns.Count-1 do
313
  for i := 0 to IdentificationsListView.Columns.Count-1 do
312
  begin
314
  begin
313
    IdentificationsListView.Columns.Items[i].Width := LVSCW_AUTOSIZE_USEHEADER;
315
    IdentificationsListView.Columns.Items[i].Width := LVSCW_AUTOSIZE_USEHEADER;
314
  end;
316
  end;
315
end;
317
end;
316
 
318
 
317
procedure TUD2MainForm.LoadINITemplate;
319
procedure TUD2MainForm.LoadINITemplate;
318
var
320
var
319
  i, j: integer;
321
  i, j: integer;
320
  pl: TUD2Plugin;
322
  pl: TUD2Plugin;
321
  ude: TUD2IdentificationEntry;
323
  ude: TUD2IdentificationEntry;
322
  idNames: TStringList;
324
  idNames: TStringList;
323
begin
325
begin
324
  IniTemplateMemo.Clear;
326
  IniTemplateMemo.Clear;
325
  IniTemplateMemo.Lines.Add('[ExampleTask1]');
327
  IniTemplateMemo.Lines.Add('[ExampleTask1]');
326
  IniTemplateMemo.Lines.Add('; Optional but recommended');
328
  IniTemplateMemo.Lines.Add('; Optional but recommended');
327
  IniTemplateMemo.Lines.Add(UD2_TagDescription+'=Run Task #1');
329
  IniTemplateMemo.Lines.Add(UD2_TagDescription+'=Run Task #1');
328
  IniTemplateMemo.Lines.Add('; Warns when no application was launched. Default: false.');
330
  IniTemplateMemo.Lines.Add('; Warns when no application was launched. Default: false.');
329
  IniTemplateMemo.Lines.Add(TagWarnIfNothingMatchesGUI+'='+DefaultWarnIfNothingMatchesGUI);
331
  IniTemplateMemo.Lines.Add(TagWarnIfNothingMatchesGUI+'='+DefaultWarnIfNothingMatchesGUI);
330
  IniTemplateMemo.Lines.Add(TagWarnIfNothingMatchesCLI+'='+DefaultWarnIfNothingMatchesCLI);
332
  IniTemplateMemo.Lines.Add(TagWarnIfNothingMatchesCLI+'='+DefaultWarnIfNothingMatchesCLI);
331
  IniTemplateMemo.Lines.Add('; Optional: IconDLL + IconIndex');
333
  IniTemplateMemo.Lines.Add('; Optional: IconDLL + IconIndex');
332
  IniTemplateMemo.Lines.Add(TagIcon+'=%SystemRoot%\system32\Shell32.dll,3');
334
  IniTemplateMemo.Lines.Add(TagIcon+'=%SystemRoot%\system32\Shell32.dll,3');
333
  IniTemplateMemo.Lines.Add('; Optional: Can be true or false');
335
  IniTemplateMemo.Lines.Add('; Optional: Can be true or false');
334
  IniTemplateMemo.Lines.Add(TagCloseAfterLaunching+'='+DefaultCloseAfterLaunching);
336
  IniTemplateMemo.Lines.Add(TagCloseAfterLaunching+'='+DefaultCloseAfterLaunching);
335
 
337
 
336
  for i := 0 to ud2.LoadedPlugins.Count-1 do
338
  for i := 0 to ud2.LoadedPlugins.Count-1 do
337
  begin
339
  begin
338
    pl := ud2.LoadedPlugins.Items[i] as TUD2Plugin;
340
    pl := ud2.LoadedPlugins.Items[i] as TUD2Plugin;
339
    for j := 0 to pl.DetectedIdentifications.Count-1 do
341
    for j := 0 to pl.DetectedIdentifications.Count-1 do
340
    begin
342
    begin
341
      ude := pl.DetectedIdentifications.Items[j] as TUD2IdentificationEntry;
343
      ude := pl.DetectedIdentifications.Items[j] as TUD2IdentificationEntry;
342
      IniTemplateMemo.Lines.Add(Format('; %s', [ude.Plugin.PluginName]));
344
      IniTemplateMemo.Lines.Add(Format('; %s', [ude.Plugin.PluginName]));
343
 
345
 
344
      idNames := TStringList.Create;
346
      idNames := TStringList.Create;
345
      try
347
      try
346
        ude.GetIdNames(idNames);
348
        ude.GetIdNames(idNames);
347
        if idNames.Count >= 1 then
349
        if idNames.Count >= 1 then
348
          IniTemplateMemo.Lines.Add(idNames.Strings[0]+'=calc.exe');
350
          IniTemplateMemo.Lines.Add(idNames.Strings[0]+'=calc.exe');
349
      finally
351
      finally
350
        idNames.Free;
352
        idNames.Free;
351
      end;
353
      end;
352
 
354
 
353
    end;
355
    end;
354
  end;
356
  end;
355
end;
357
end;
356
 
358
 
357
procedure TUD2MainForm.LoadLoadedPluginList;
359
procedure TUD2MainForm.LoadLoadedPluginList;
358
resourcestring
360
resourcestring
359
  LNG_MS = '%dms';
361
  LNG_MS = '%dms';
360
var
362
var
361
  i: integer;
363
  i: integer;
362
  pl: TUD2Plugin;
364
  pl: TUD2Plugin;
363
begin
365
begin
364
  LoadedPluginsListView.Clear;
366
  LoadedPluginsListView.Clear;
365
  for i := 0 to ud2.LoadedPlugins.Count-1 do
367
  for i := 0 to ud2.LoadedPlugins.Count-1 do
366
  begin
368
  begin
367
    pl := ud2.LoadedPlugins.Items[i] as TUD2Plugin;
369
    pl := ud2.LoadedPlugins.Items[i] as TUD2Plugin;
368
    with LoadedPluginsListView.Items.Add do
370
    with LoadedPluginsListView.Items.Add do
369
    begin
371
    begin
-
 
372
      Data := pl;
370
      Caption := pl.PluginDLL;
373
      Caption := pl.PluginDLL;
371
      SubItems.Add(pl.PluginVendor);
374
      SubItems.Add(pl.PluginVendor);
372
      SubItems.Add(pl.PluginName);
375
      SubItems.Add(pl.PluginName);
373
      SubItems.Add(pl.PluginVersion);
376
      SubItems.Add(pl.PluginVersion);
374
      SubItems.Add(pl.IdentificationMethodName);
377
      SubItems.Add(pl.IdentificationMethodName);
375
      if pl.AcceptsDynamicRequests then
378
      if pl.AcceptsDynamicRequests then
376
        SubItems.Add('Yes')
379
        SubItems.Add('Yes')
377
      else
380
      else
378
        SubItems.Add('No');
381
        SubItems.Add('No');
379
      SubItems.Add(IntToStr(pl.DetectedIdentifications.Count));
382
      SubItems.Add(IntToStr(pl.DetectedIdentifications.Count));
380
      SubItems.Add(Format(LNG_MS, [Max(1,pl.LoadingTime)])); // at least show 1ms, otherwise it would look unloggical
383
      SubItems.Add(Format(LNG_MS, [Max(1,pl.LoadingTime)])); // at least show 1ms, otherwise it would look unloggical
381
      SubItems.Add(pl.IdentificationProcedureStatusCodeDescribed);
384
      SubItems.Add(pl.IdentificationProcedureStatusCodeDescribed);
382
      SubItems.Add(pl.PluginGUIDString);
385
      SubItems.Add(pl.PluginGUIDString);
383
    end;
386
    end;
384
  end;
387
  end;
385
 
388
 
386
  for i := 0 to LoadedPluginsListView.Columns.Count-1 do
389
  for i := 0 to LoadedPluginsListView.Columns.Count-1 do
387
  begin
390
  begin
388
    LoadedPluginsListView.Columns.Items[i].Width := LVSCW_AUTOSIZE_USEHEADER;
391
    LoadedPluginsListView.Columns.Items[i].Width := LVSCW_AUTOSIZE_USEHEADER;
389
  end;
392
  end;
390
end;
393
end;
391
 
394
 
392
procedure TUD2MainForm.TasksListViewDblClick(Sender: TObject);
395
procedure TUD2MainForm.TasksListViewDblClick(Sender: TObject);
393
var
396
var
394
  obj: TUD2ListViewEntry;
397
  obj: TUD2ListViewEntry;
395
begin
398
begin
396
  if TasksListView.ItemIndex = -1 then exit;
399
  if TasksListView.ItemIndex = -1 then exit;
397
  obj := TUD2ListViewEntry(TasksListView.Selected.Data);
400
  obj := TUD2ListViewEntry(TasksListView.Selected.Data);
398
  DoRun(obj.ShortTaskName, true);
401
  DoRun(obj.ShortTaskName, true);
399
  if obj.CloseAfterLaunching then Close;
402
  if obj.CloseAfterLaunching then Close;
400
end;
403
end;
401
 
404
 
402
procedure TUD2MainForm.TasksListViewKeyPress(Sender: TObject; var Key: Char);
405
procedure TUD2MainForm.TasksListViewKeyPress(Sender: TObject; var Key: Char);
403
begin
406
begin
404
  if Key = #13 then
407
  if Key = #13 then
405
  begin
408
  begin
406
    TasksListViewDblClick(Sender);
409
    TasksListViewDblClick(Sender);
407
  end;
410
  end;
408
end;
411
end;
409
 
412
 
410
procedure TUD2MainForm.OpenTDFButtonClick(Sender: TObject);
413
procedure TUD2MainForm.OpenTDFButtonClick(Sender: TObject);
411
var
414
var
412
  cmd: TUD2Command;
415
  cmd: TUD2Command;
413
begin
416
begin
414
  cmd.executable := ud2.IniFileName;
417
  cmd.executable := ud2.IniFileName;
415
  cmd.runAsAdmin := false;
418
  cmd.runAsAdmin := false;
416
  cmd.runInOwnDirectory := false;
419
  cmd.runInOwnDirectory := false;
417
  cmd.windowMode := SW_NORMAL;
420
  cmd.windowMode := SW_NORMAL;
418
  UD2_RunCMD(cmd);
421
  UD2_RunCMD(cmd);
419
end;
422
end;
420
 
423
 
421
procedure TUD2MainForm.SaveTDFButtonClick(Sender: TObject);
424
procedure TUD2MainForm.SaveTDFButtonClick(Sender: TObject);
422
begin
425
begin
423
  if CompatSaveDialogExecute(SaveDialog1) then
426
  if CompatSaveDialogExecute(SaveDialog1) then
424
  begin
427
  begin
425
    IniTemplateMemo.Lines.SaveToFile(SaveDialog1.FileName);
428
    IniTemplateMemo.Lines.SaveToFile(SaveDialog1.FileName);
426
  end;
429
  end;
427
end;
430
end;
428
 
431
 
429
procedure TUD2MainForm.URLLabelClick(Sender: TObject);
432
procedure TUD2MainForm.URLLabelClick(Sender: TObject);
430
var
433
var
431
  cmd: TUD2Command;
434
  cmd: TUD2Command;
432
begin
435
begin
433
  cmd.executable := TLabel(Sender).Caption;
436
  cmd.executable := TLabel(Sender).Caption;
434
  if Pos('@', cmd.executable) > 0 then
437
  if Pos('@', cmd.executable) > 0 then
435
    cmd.executable := 'mailto:' + cmd.executable
438
    cmd.executable := 'mailto:' + cmd.executable
436
  else
439
  else
437
    cmd.executable := 'http://' + cmd.executable;
440
    cmd.executable := 'http://' + cmd.executable;
438
 
441
 
439
  cmd.runAsAdmin := false;
442
  cmd.runAsAdmin := false;
440
  cmd.runInOwnDirectory := false;
443
  cmd.runInOwnDirectory := false;
441
  cmd.windowMode := SW_NORMAL;
444
  cmd.windowMode := SW_NORMAL;
442
 
445
 
443
  UD2_RunCMD(cmd);
446
  UD2_RunCMD(cmd);
444
end;
447
end;
445
 
448
 
446
procedure TUD2MainForm.TasksPopupMenuPopup(Sender: TObject);
449
procedure TUD2MainForm.TasksPopupMenuPopup(Sender: TObject);
447
begin
450
begin
448
  Run1.Enabled := TasksListView.ItemIndex <> -1;
451
  Run1.Enabled := TasksListView.ItemIndex <> -1;
449
  Properties1.Enabled := TasksListView.ItemIndex <> -1;
452
  Properties1.Enabled := TasksListView.ItemIndex <> -1;
450
end;
453
end;
451
 
454
 
452
procedure TUD2MainForm.Run1Click(Sender: TObject);
455
procedure TUD2MainForm.Run1Click(Sender: TObject);
453
begin
456
begin
454
  TasksListViewDblClick(Sender);
457
  TasksListViewDblClick(Sender);
455
end;
458
end;
456
 
459
 
457
procedure TUD2MainForm.Properties1Click(Sender: TObject);
460
procedure TUD2MainForm.Properties1Click(Sender: TObject);
458
var
461
var
459
  obj: TUD2ListViewEntry;
462
  obj: TUD2ListViewEntry;
460
begin
463
begin
461
  if TasksListView.ItemIndex = -1 then exit;
464
  if TasksListView.ItemIndex = -1 then exit;
462
  obj := TUD2ListViewEntry(TasksListView.Selected.Data);
465
  obj := TUD2ListViewEntry(TasksListView.Selected.Data);
463
  if obj.TaskPropertiesForm = nil then
466
  if obj.TaskPropertiesForm = nil then
464
  begin
467
  begin
465
    obj.TaskPropertiesForm := TUD2TaskPropertiesForm.Create(Self, ud2, obj.ShortTaskName);
468
    obj.TaskPropertiesForm := TUD2TaskPropertiesForm.Create(Self, ud2, obj.ShortTaskName);
466
  end;
469
  end;
467
  obj.TaskPropertiesForm.Show;
470
  obj.TaskPropertiesForm.Show;
468
end;
471
end;
469
 
472
 
470
procedure TUD2MainForm.IdentificationsPopupMenuPopup(Sender: TObject);
473
procedure TUD2MainForm.IdentificationsPopupMenuPopup(Sender: TObject);
471
begin
474
begin
472
  CopyTaskDefinitionExample1.Enabled := IdentificationsListView.ItemIndex <> -1;
475
  CopyTaskDefinitionExample1.Enabled := IdentificationsListView.ItemIndex <> -1;
473
end;
476
end;
474
 
477
 
475
procedure TUD2MainForm.CopyTaskDefinitionExample1Click(Sender: TObject);
478
procedure TUD2MainForm.CopyTaskDefinitionExample1Click(Sender: TObject);
476
var
479
var
477
  s: string;
480
  s: string;
-
 
481
  ude: TUD2IdentificationEntry;
478
begin
482
begin
479
  s := '; '+IdentificationsListView.Selected.Caption+#13#10+
483
  if IdentificationsListView.ItemIndex = -1 then exit;
-
 
484
 
480
       IdentificationsListView.Selected.SubItems[0] + ':' + IdentificationsListView.Selected.SubItems[1] + '=calc.exe'+#13#10+
485
  ude := TUD2IdentificationEntry(IdentificationsListView.Selected.Data);
-
 
486
  s := '; ' + ude.Plugin.PluginName + #13#10 +
-
 
487
       UD2_CondToStr(ude.GetConditionString(false))+'=calc.exe'+#13#10+
481
       #13#10+
488
       #13#10+
482
       '; Alternatively:'+#13#10+
489
       '; Alternatively:'+#13#10+
483
       IdentificationsListView.Selected.SubItems[2] + ':' + IdentificationsListView.Selected.SubItems[1] + '=calc.exe'+#13#10;
490
       UD2_CondToStr(ude.GetConditionString(true))+'=calc.exe'+#13#10;
-
 
491
 
484
  Clipboard.AsText := s;
492
  Clipboard.AsText := s;
485
end;
493
end;
486
 
494
 
487
procedure TUD2MainForm.ListViewCompare(Sender: TObject; Item1,
495
procedure TUD2MainForm.ListViewCompare(Sender: TObject; Item1,
488
  Item2: TListItem; Data: Integer; var Compare: Integer);
496
  Item2: TListItem; Data: Integer; var Compare: Integer);
489
var
497
var
490
  ListView: TVTSListView;
498
  ListView: TVTSListView;
491
begin
499
begin
492
  ListView := Sender as TVTSListView;
500
  ListView := Sender as TVTSListView;
493
  if ListView.CurSortedColumn = 0 then
501
  if ListView.CurSortedColumn = 0 then
494
  begin
502
  begin
495
    Compare := AlphaNumCompare(Item1.Caption, Item2.Caption);
503
    Compare := AlphaNumCompare(Item1.Caption, Item2.Caption);
496
  end
504
  end
497
  else
505
  else
498
  begin
506
  begin
499
    Compare := AlphaNumCompare(Item1.SubItems[ListView.CurSortedColumn-1],
507
    Compare := AlphaNumCompare(Item1.SubItems[ListView.CurSortedColumn-1],
500
                               Item2.SubItems[ListView.CurSortedColumn-1]);
508
                               Item2.SubItems[ListView.CurSortedColumn-1]);
501
  end;
509
  end;
502
  if ListView.CurSortedDesc then Compare := -Compare;
510
  if ListView.CurSortedDesc then Compare := -Compare;
503
end;
511
end;
504
 
512
 
505
procedure TUD2MainForm.Button3Click(Sender: TObject);
513
procedure TUD2MainForm.Button3Click(Sender: TObject);
506
begin
514
begin
507
  VTS_CheckUpdates('userdetect2', VersionLabel.Caption);
515
  VTS_CheckUpdates('userdetect2', VersionLabel.Caption);
508
end;
516
end;
509
 
517
 
510
procedure TUD2MainForm.LoadedPluginsPopupMenuPopup(Sender: TObject);
518
procedure TUD2MainForm.LoadedPluginsPopupMenuPopup(Sender: TObject);
511
begin
519
begin
512
  MenuItem1.Enabled := LoadedPluginsListView.ItemIndex <> -1;
520
  CopyStatusCodeToClipboard.Enabled := LoadedPluginsListView.ItemIndex <> -1;
513
end;
521
end;
514
 
522
 
515
procedure TUD2MainForm.MenuItem1Click(Sender: TObject);
523
procedure TUD2MainForm.CopyStatusCodeToClipboardClick(Sender: TObject);
516
var
524
var
517
  s: string;
525
  s: string;
-
 
526
  pl: TUD2Plugin;
518
begin
527
begin
-
 
528
  if LoadedPluginsListView.ItemIndex = -1 then exit;
519
  s := '; ' + LoadedPluginsListView.Selected.SubItems.Strings[6];
529
  pl := TUD2Plugin(LoadedPluginsListView.Selected.Data);
-
 
530
  s := (*'; ' +*) pl.IdentificationProcedureStatusCodeDescribed;
520
  Clipboard.AsText := s;
531
  Clipboard.AsText := s;
521
end;
532
end;
522
 
533
 
523
procedure TUD2MainForm.Run;
534
procedure TUD2MainForm.Run;
524
resourcestring
535
resourcestring
525
  LNG_SYNTAX = 'Syntax: %s [TaskDefinitionFile [/T TaskName] | /C IdentificationTerm [Command] | /?]';
536
  LNG_SYNTAX = 'Syntax: %s [TaskDefinitionFile [/T TaskName] | /C IdentificationTerm [Command] | /?]';
526
var
537
var
527
  LoadedIniFile: string;
538
  LoadedIniFile: string;
528
begin
539
begin
529
  ExitCode := EXITCODE_OK;
540
  ExitCode := EXITCODE_OK;
530
 
541
 
531
  if ((ParamCount = 1) and CheckBoolParam(1, '?')) or
542
  if ((ParamCount = 1) and CheckBoolParam(1, '?')) or
532
     (CheckBoolParam(2, 'T') and (ParamCount > 3)) or
543
     (CheckBoolParam(2, 'T') and (ParamCount > 3)) or
533
     (CheckBoolParam(1, 'C') and (ParamCount > 3)) or
544
     (CheckBoolParam(1, 'C') and (ParamCount > 3)) or
534
     (not CheckBoolParam(2, 'T') and not CheckBoolParam(1, 'C') and (ParamCount > 1)) then
545
     (not CheckBoolParam(2, 'T') and not CheckBoolParam(1, 'C') and (ParamCount > 1)) then
535
  begin
546
  begin
536
    ExitCode := EXITCODE_SYNTAX_ERROR;
547
    ExitCode := EXITCODE_SYNTAX_ERROR;
537
    MessageDlg(Format(LNG_SYNTAX, [GetOwnCmdName]), mtInformation, [mbOK], 0);
548
    MessageDlg(Format(LNG_SYNTAX, [GetOwnCmdName]), mtInformation, [mbOK], 0);
538
 
549
 
539
    Visible := false;
550
    Visible := false;
540
    Close;
551
    Close;
541
    Exit;
552
    Exit;
542
  end;
553
  end;
543
 
554
 
544
  LoadedIniFile := GetIniFileName;
555
  LoadedIniFile := GetIniFileName;
545
  if LoadedIniFile = '' then
556
  if LoadedIniFile = '' then
546
  begin
557
  begin
547
    Visible := false;
558
    Visible := false;
548
    Close;
559
    Close;
549
    Exit;
560
    Exit;
550
  end;
561
  end;
551
  ud2 := TUD2.Create(LoadedIniFile);
562
  ud2 := TUD2.Create(LoadedIniFile);
552
 
563
 
553
  ud2.HandlePluginDir('',        '*.udp');
564
  ud2.HandlePluginDir('',        '*.udp');
554
  ud2.HandlePluginDir('Plugins', '*.udp');
565
  ud2.HandlePluginDir('Plugins', '*.udp');
555
  ud2.HandlePluginDir('Plugins', '*.dll');
566
  ud2.HandlePluginDir('Plugins', '*.dll');
556
 
567
 
557
  if CheckBoolParam(1, 'C') then
568
  if CheckBoolParam(1, 'C') then
558
  begin
569
  begin
559
    if ud2.FulfilsEverySubterm(ParamStr(2)) then
570
    if ud2.FulfilsEverySubterm(ParamStr(2)) then
560
    begin
571
    begin
561
      ExitCode := EXITCODE_OK;
572
      ExitCode := EXITCODE_OK;
562
 
573
 
563
      if ParamStr(3) <> '' then
574
      if ParamStr(3) <> '' then
564
      begin
575
      begin
565
        UD2_RunCMD(UD2P_DecodeCommand(ParamStr(3)));
576
        UD2_RunCMD(UD2P_DecodeCommand(ParamStr(3)));
566
      end;
577
      end;
567
    end
578
    end
568
    else
579
    else
569
    begin
580
    begin
570
      ExitCode := EXITCODE_TASK_NOTHING_MATCHES;
581
      ExitCode := EXITCODE_TASK_NOTHING_MATCHES;
571
    end;
582
    end;
572
 
583
 
573
    Visible := false;
584
    Visible := false;
574
    Close;
585
    Close;
575
    Exit;
586
    Exit;
576
  end
587
  end
577
  else if CheckBoolParam(2, 'T') then
588
  else if CheckBoolParam(2, 'T') then
578
  begin
589
  begin
579
    DoRun(ParamStr(3), false);
590
    DoRun(ParamStr(3), false);
580
 
591
 
581
    Visible := false;
592
    Visible := false;
582
    Close;
593
    Close;
583
    Exit;
594
    Exit;
584
  end
595
  end
585
  else
596
  else
586
  begin
597
  begin
587
    LoadTaskList;
598
    LoadTaskList;
588
    LoadDetectedIDs;
599
    LoadDetectedIDs;
589
    LoadINITemplate;
600
    LoadINITemplate;
590
    LoadLoadedPluginList;
601
    LoadLoadedPluginList;
591
    LoadDynamicPluginList;
602
    LoadDynamicPluginList;
592
    CheckForErrors;
603
    CheckForErrors;
593
 
604
 
594
    Visible := true;
605
    Visible := true;
595
    Exit;
606
    Exit;
596
  end;
607
  end;
597
end;
608
end;
598
 
609
 
599
procedure TUD2MainForm.FormCreate(Sender: TObject);
610
procedure TUD2MainForm.FormCreate(Sender: TObject);
600
begin
611
begin
601
  // To avoid accidental change of the default tab from the IDE VCL Designer
612
  // To avoid accidental change of the default tab from the IDE VCL Designer
602
  PageControl1.ActivePage := TasksTabSheet;
613
  PageControl1.ActivePage := TasksTabSheet;
603
end;
614
end;
604
 
615
 
605
procedure TUD2MainForm.DynamicTestButtonClick(Sender: TObject);
616
procedure TUD2MainForm.DynamicTestButtonClick(Sender: TObject);
606
var
617
var
607
  p: TUD2Plugin;
618
  p: TUD2Plugin;
608
  x: TArrayOfString;
619
  x: TArrayOfString;
609
  newStuff: boolean;
620
  newStuff: boolean;
610
  errors: TStrings;
621
  errors: TStrings;
611
resourcestring
622
resourcestring
612
  LNG_DETECTED_DYNAMICS = 'The plugin returns following identification strings:';
623
  LNG_DETECTED_DYNAMICS = 'The plugin returns following identification strings:';
613
  LNG_NOTHING_DETECTED = 'The plugin did not send any identification strings.';
624
  LNG_NOTHING_DETECTED = 'The plugin did not send any identification strings.';
614
  LNG_STATUS_RETURNED = 'The plugin sent following status in reply to your request:';
625
  LNG_STATUS_RETURNED = 'The plugin sent following status in reply to your request:';
615
  LNG_ERROR_RETURNED = 'The dynamic plugin could not load. The plugin sent following error messages:';
626
  LNG_ERROR_RETURNED = 'The dynamic plugin could not load. The plugin sent following error messages:';
616
begin
627
begin
617
  if DynamicTestPluginComboBox.ItemIndex = -1 then
628
  if DynamicTestPluginComboBox.ItemIndex = -1 then
618
  begin
629
  begin
619
    ShowMessage('Please select a plugin that is accepting dynamic requests.');
630
    ShowMessage('Please select a plugin that is accepting dynamic requests.');
620
    Exit;
631
    Exit;
621
  end;
632
  end;
622
 
633
 
623
  p := DynamicTestPluginComboBox.Items.Objects[DynamicTestPluginComboBox.ItemIndex] as TUD2Plugin;
634
  p := DynamicTestPluginComboBox.Items.Objects[DynamicTestPluginComboBox.ItemIndex] as TUD2Plugin;
624
 
635
 
625
  errors := TStringList.Create;
636
  errors := TStringList.Create;
626
  try
637
  try
627
    newStuff := p.InvokeDynamicCheck(DynamicTestDataEdit.Text, errors, x);
638
    newStuff := p.InvokeDynamicCheck(DynamicTestDataEdit.Text, errors, x);
628
    if errors.Count > 0 then
639
    if errors.Count > 0 then
629
    begin
640
    begin
630
      ShowMessage(LNG_ERROR_RETURNED + #13#10#13#10 + errors.Text);
641
      ShowMessage(LNG_ERROR_RETURNED + #13#10#13#10 + errors.Text);
631
      Exit;
642
      Exit;
632
    end;
643
    end;
633
  finally
644
  finally
634
    FreeAndNil(errors);
645
    FreeAndNil(errors);
635
  end;
646
  end;
636
 
647
 
637
  if p.IdentificationProcedureStatusCode.wCategory <> UD2_STATUSCAT_SUCCESS then
648
  if p.IdentificationProcedureStatusCode.wCategory <> UD2_STATUSCAT_SUCCESS then
638
  begin
649
  begin
639
    // e.g. "Not available" because of invalid dynamic input data
650
    // e.g. "Not available" because of invalid dynamic input data
640
    ShowMessage(LNG_STATUS_RETURNED + #13#10#13#10 + p.IdentificationProcedureStatusCodeDescribed);
651
    ShowMessage(LNG_STATUS_RETURNED + #13#10#13#10 + p.IdentificationProcedureStatusCodeDescribed);
641
    Exit;
652
    Exit;
642
  end;
653
  end;
643
 
654
 
644
  if Length(x) > 0 then
655
  if Length(x) > 0 then
645
    ShowMessage(LNG_DETECTED_DYNAMICS + #13#10#13#10 + MergeString(x, #13#10))
656
    ShowMessage(LNG_DETECTED_DYNAMICS + #13#10#13#10 + MergeString(x, #13#10))
646
  else
657
  else
647
    ShowMessage(LNG_NOTHING_DETECTED);
658
    ShowMessage(LNG_NOTHING_DETECTED);
648
 
659
 
649
  if newStuff then
660
  if newStuff then
650
  begin
661
  begin
651
    LoadDetectedIDs;
662
    LoadDetectedIDs;
652
    LoadINITemplate;
663
    LoadINITemplate;
653
    LoadLoadedPluginList; // To update the "Detected IDs" column
664
    LoadLoadedPluginList; // To update the "Detected IDs" column
654
  end;
665
  end;
655
end;
666
end;
656
 
667
 
657
procedure TUD2MainForm.LoadDynamicPluginList;
668
procedure TUD2MainForm.LoadDynamicPluginList;
658
var
669
var
659
  i: integer;
670
  i: integer;
660
  p: TUD2Plugin;
671
  p: TUD2Plugin;
661
begin
672
begin
662
  DynamicTestPluginComboBox.Clear;
673
  DynamicTestPluginComboBox.Clear;
663
  for i := 0 to ud2.LoadedPlugins.Count-1 do
674
  for i := 0 to ud2.LoadedPlugins.Count-1 do
664
  begin
675
  begin
665
    p := ud2.LoadedPlugins.Items[i] as TUD2Plugin;
676
    p := ud2.LoadedPlugins.Items[i] as TUD2Plugin;
666
    if p.AcceptsDynamicRequests then
677
    if p.AcceptsDynamicRequests then
667
    begin
678
    begin
668
      // TODO: PROBLEM!! Beim Dynamic Check (Dynamic Query) wird der plugin status überschrieben!!!
679
      // TODO: PROBLEM!! Beim Dynamic Check (Dynamic Query) wird der plugin status überschrieben!!!
669
      DynamicTestPluginComboBox.Items.AddObject(p.PluginName, p);
680
      DynamicTestPluginComboBox.Items.AddObject(p.PluginName, p);
670
    end;
681
    end;
671
  end;
682
  end;
672
end;
683
end;
673
 
684
 
674
end.
685
end.
675
 
686