Rev 94 | Go to most recent revision | Only display areas with differences | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 94 | Rev 95 | ||
---|---|---|---|
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 | CopyStatusCodeToClipboard: 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 CopyStatusCodeToClipboardClick(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 | ||
298 | with IdentificationsListView.Items.Add do |
298 | with IdentificationsListView.Items.Add do |
299 | begin |
299 | begin |
300 | Data := ude; |
300 | Data := ude; |
301 | Caption := pl.PluginName; |
301 | Caption := pl.PluginName; |
302 | if ude.DynamicDataUsed then |
302 | if ude.DynamicDataUsed then |
303 | SubItems.Add(ude.DynamicData) |
303 | SubItems.Add(ude.DynamicData) |
304 | else |
304 | else |
305 | SubItems.Add(''); |
305 | SubItems.Add(''); |
306 | SubItems.Add(pl.IdentificationMethodName); |
306 | SubItems.Add(pl.IdentificationMethodName); |
307 | SubItems.Add(ude.IdentificationString); |
307 | SubItems.Add(ude.IdentificationString); |
308 | SubItems.Add(pl.PluginGUIDString) |
308 | SubItems.Add(pl.PluginGUIDString) |
309 | end; |
309 | end; |
310 | end; |
310 | end; |
311 | end; |
311 | end; |
312 | 312 | ||
313 | for i := 0 to IdentificationsListView.Columns.Count-1 do |
313 | for i := 0 to IdentificationsListView.Columns.Count-1 do |
314 | begin |
314 | begin |
315 | IdentificationsListView.Columns.Items[i].Width := LVSCW_AUTOSIZE_USEHEADER; |
315 | IdentificationsListView.Columns.Items[i].Width := LVSCW_AUTOSIZE_USEHEADER; |
316 | end; |
316 | end; |
317 | end; |
317 | end; |
318 | 318 | ||
319 | procedure TUD2MainForm.LoadINITemplate; |
319 | procedure TUD2MainForm.LoadINITemplate; |
320 | var |
320 | var |
321 | i, j: integer; |
321 | i, j: integer; |
322 | pl: TUD2Plugin; |
322 | pl: TUD2Plugin; |
323 | ude: TUD2IdentificationEntry; |
323 | ude: TUD2IdentificationEntry; |
324 | idNames: TStringList; |
324 | idNames: TStringList; |
325 | begin |
325 | begin |
326 | IniTemplateMemo.Clear; |
326 | IniTemplateMemo.Clear; |
327 | IniTemplateMemo.Lines.Add('[ExampleTask1]'); |
327 | IniTemplateMemo.Lines.Add('[ExampleTask1]'); |
328 | IniTemplateMemo.Lines.Add('; Optional but recommended'); |
328 | IniTemplateMemo.Lines.Add('; Optional but recommended'); |
329 | IniTemplateMemo.Lines.Add(UD2_TagDescription+'=Run Task #1'); |
329 | IniTemplateMemo.Lines.Add(UD2_TagDescription+'=Run Task #1'); |
330 | IniTemplateMemo.Lines.Add('; Warns when no application was launched. Default: false.'); |
330 | IniTemplateMemo.Lines.Add('; Warns when no application was launched. Default: false.'); |
331 | IniTemplateMemo.Lines.Add(TagWarnIfNothingMatchesGUI+'='+DefaultWarnIfNothingMatchesGUI); |
331 | IniTemplateMemo.Lines.Add(TagWarnIfNothingMatchesGUI+'='+DefaultWarnIfNothingMatchesGUI); |
332 | IniTemplateMemo.Lines.Add(TagWarnIfNothingMatchesCLI+'='+DefaultWarnIfNothingMatchesCLI); |
332 | IniTemplateMemo.Lines.Add(TagWarnIfNothingMatchesCLI+'='+DefaultWarnIfNothingMatchesCLI); |
333 | IniTemplateMemo.Lines.Add('; Optional: IconDLL + IconIndex'); |
333 | IniTemplateMemo.Lines.Add('; Optional: IconDLL + IconIndex'); |
334 | IniTemplateMemo.Lines.Add(TagIcon+'=%SystemRoot%\system32\Shell32.dll,3'); |
334 | IniTemplateMemo.Lines.Add(TagIcon+'=%SystemRoot%\system32\Shell32.dll,3'); |
335 | IniTemplateMemo.Lines.Add('; Optional: Can be true or false'); |
335 | IniTemplateMemo.Lines.Add('; Optional: Can be true or false'); |
336 | IniTemplateMemo.Lines.Add(TagCloseAfterLaunching+'='+DefaultCloseAfterLaunching); |
336 | IniTemplateMemo.Lines.Add(TagCloseAfterLaunching+'='+DefaultCloseAfterLaunching); |
337 | 337 | ||
338 | for i := 0 to ud2.LoadedPlugins.Count-1 do |
338 | for i := 0 to ud2.LoadedPlugins.Count-1 do |
339 | begin |
339 | begin |
340 | pl := ud2.LoadedPlugins.Items[i] as TUD2Plugin; |
340 | pl := ud2.LoadedPlugins.Items[i] as TUD2Plugin; |
341 | for j := 0 to pl.DetectedIdentifications.Count-1 do |
341 | for j := 0 to pl.DetectedIdentifications.Count-1 do |
342 | begin |
342 | begin |
343 | ude := pl.DetectedIdentifications.Items[j] as TUD2IdentificationEntry; |
343 | ude := pl.DetectedIdentifications.Items[j] as TUD2IdentificationEntry; |
344 | IniTemplateMemo.Lines.Add(Format('; %s', [ude.Plugin.PluginName])); |
344 | IniTemplateMemo.Lines.Add(Format('; %s', [ude.Plugin.PluginName])); |
345 | 345 | ||
346 | idNames := TStringList.Create; |
346 | idNames := TStringList.Create; |
347 | try |
347 | try |
348 | ude.GetIdNames(idNames); |
348 | ude.GetIdNames(idNames); |
349 | if idNames.Count >= 1 then |
349 | if idNames.Count >= 1 then |
350 | IniTemplateMemo.Lines.Add(idNames.Strings[0]+'=calc.exe'); |
350 | IniTemplateMemo.Lines.Add(idNames.Strings[0]+'=calc.exe'); |
351 | finally |
351 | finally |
352 | idNames.Free; |
352 | idNames.Free; |
353 | end; |
353 | end; |
354 | 354 | ||
355 | end; |
355 | end; |
356 | end; |
356 | end; |
357 | end; |
357 | end; |
358 | 358 | ||
359 | procedure TUD2MainForm.LoadLoadedPluginList; |
359 | procedure TUD2MainForm.LoadLoadedPluginList; |
360 | resourcestring |
360 | resourcestring |
361 | LNG_MS = '%dms'; |
361 | LNG_MS = '%dms'; |
362 | var |
362 | var |
363 | i: integer; |
363 | i: integer; |
364 | pl: TUD2Plugin; |
364 | pl: TUD2Plugin; |
365 | begin |
365 | begin |
366 | LoadedPluginsListView.Clear; |
366 | LoadedPluginsListView.Clear; |
367 | for i := 0 to ud2.LoadedPlugins.Count-1 do |
367 | for i := 0 to ud2.LoadedPlugins.Count-1 do |
368 | begin |
368 | begin |
369 | pl := ud2.LoadedPlugins.Items[i] as TUD2Plugin; |
369 | pl := ud2.LoadedPlugins.Items[i] as TUD2Plugin; |
370 | with LoadedPluginsListView.Items.Add do |
370 | with LoadedPluginsListView.Items.Add do |
371 | begin |
371 | begin |
372 | Data := pl; |
372 | Data := pl; |
373 | Caption := pl.PluginDLL; |
373 | Caption := pl.PluginDLL; |
374 | SubItems.Add(pl.PluginVendor); |
374 | SubItems.Add(pl.PluginVendor); |
375 | SubItems.Add(pl.PluginName); |
375 | SubItems.Add(pl.PluginName); |
376 | SubItems.Add(pl.PluginVersion); |
376 | SubItems.Add(pl.PluginVersion); |
377 | SubItems.Add(pl.IdentificationMethodName); |
377 | SubItems.Add(pl.IdentificationMethodName); |
378 | if pl.AcceptsDynamicRequests then |
378 | if pl.AcceptsDynamicRequests then |
379 | SubItems.Add('Yes') |
379 | SubItems.Add('Yes') |
380 | else |
380 | else |
381 | SubItems.Add('No'); |
381 | SubItems.Add('No'); |
382 | SubItems.Add(IntToStr(pl.DetectedIdentifications.Count)); |
382 | SubItems.Add(IntToStr(pl.DetectedIdentifications.Count)); |
383 | 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 |
384 | SubItems.Add(pl.IdentificationProcedureStatusCodeDescribed); |
384 | SubItems.Add(pl.IdentificationProcedureStatusCodeDescribed); |
385 | SubItems.Add(pl.PluginGUIDString); |
385 | SubItems.Add(pl.PluginGUIDString); |
386 | end; |
386 | end; |
387 | end; |
387 | end; |
388 | 388 | ||
389 | for i := 0 to LoadedPluginsListView.Columns.Count-1 do |
389 | for i := 0 to LoadedPluginsListView.Columns.Count-1 do |
390 | begin |
390 | begin |
391 | LoadedPluginsListView.Columns.Items[i].Width := LVSCW_AUTOSIZE_USEHEADER; |
391 | LoadedPluginsListView.Columns.Items[i].Width := LVSCW_AUTOSIZE_USEHEADER; |
392 | end; |
392 | end; |
393 | end; |
393 | end; |
394 | 394 | ||
395 | procedure TUD2MainForm.TasksListViewDblClick(Sender: TObject); |
395 | procedure TUD2MainForm.TasksListViewDblClick(Sender: TObject); |
396 | var |
396 | var |
397 | obj: TUD2ListViewEntry; |
397 | obj: TUD2ListViewEntry; |
398 | begin |
398 | begin |
399 | if TasksListView.ItemIndex = -1 then exit; |
399 | if TasksListView.ItemIndex = -1 then exit; |
400 | obj := TUD2ListViewEntry(TasksListView.Selected.Data); |
400 | obj := TUD2ListViewEntry(TasksListView.Selected.Data); |
401 | DoRun(obj.ShortTaskName, true); |
401 | DoRun(obj.ShortTaskName, true); |
402 | if obj.CloseAfterLaunching then Close; |
402 | if obj.CloseAfterLaunching then Close; |
403 | end; |
403 | end; |
404 | 404 | ||
405 | procedure TUD2MainForm.TasksListViewKeyPress(Sender: TObject; var Key: Char); |
405 | procedure TUD2MainForm.TasksListViewKeyPress(Sender: TObject; var Key: Char); |
406 | begin |
406 | begin |
407 | if Key = #13 then |
407 | if Key = #13 then |
408 | begin |
408 | begin |
409 | TasksListViewDblClick(Sender); |
409 | TasksListViewDblClick(Sender); |
410 | end; |
410 | end; |
411 | end; |
411 | end; |
412 | 412 | ||
413 | procedure TUD2MainForm.OpenTDFButtonClick(Sender: TObject); |
413 | procedure TUD2MainForm.OpenTDFButtonClick(Sender: TObject); |
414 | var |
414 | var |
415 | cmd: TUD2Command; |
415 | cmd: TUD2Command; |
416 | begin |
416 | begin |
417 | cmd.executable := ud2.IniFileName; |
417 | cmd.executable := ud2.IniFileName; |
418 | cmd.runAsAdmin := false; |
418 | cmd.runAsAdmin := false; |
419 | cmd.runInOwnDirectory := false; |
419 | cmd.runInOwnDirectory := false; |
420 | cmd.windowMode := SW_NORMAL; |
420 | cmd.windowMode := SW_NORMAL; |
421 | UD2_RunCMD(cmd); |
421 | UD2_RunCMD(cmd); |
422 | end; |
422 | end; |
423 | 423 | ||
424 | procedure TUD2MainForm.SaveTDFButtonClick(Sender: TObject); |
424 | procedure TUD2MainForm.SaveTDFButtonClick(Sender: TObject); |
425 | begin |
425 | begin |
426 | if CompatSaveDialogExecute(SaveDialog1) then |
426 | if CompatSaveDialogExecute(SaveDialog1) then |
427 | begin |
427 | begin |
428 | IniTemplateMemo.Lines.SaveToFile(SaveDialog1.FileName); |
428 | IniTemplateMemo.Lines.SaveToFile(SaveDialog1.FileName); |
429 | end; |
429 | end; |
430 | end; |
430 | end; |
431 | 431 | ||
432 | procedure TUD2MainForm.URLLabelClick(Sender: TObject); |
432 | procedure TUD2MainForm.URLLabelClick(Sender: TObject); |
433 | var |
433 | var |
434 | cmd: TUD2Command; |
434 | cmd: TUD2Command; |
435 | begin |
435 | begin |
436 | cmd.executable := TLabel(Sender).Caption; |
436 | cmd.executable := TLabel(Sender).Caption; |
437 | if Pos('@', cmd.executable) > 0 then |
437 | if Pos('@', cmd.executable) > 0 then |
438 | cmd.executable := 'mailto:' + cmd.executable |
438 | cmd.executable := 'mailto:' + cmd.executable |
439 | else |
439 | else |
440 | cmd.executable := 'http://' + cmd.executable; |
440 | cmd.executable := 'http://' + cmd.executable; |
441 | 441 | ||
442 | cmd.runAsAdmin := false; |
442 | cmd.runAsAdmin := false; |
443 | cmd.runInOwnDirectory := false; |
443 | cmd.runInOwnDirectory := false; |
444 | cmd.windowMode := SW_NORMAL; |
444 | cmd.windowMode := SW_NORMAL; |
445 | 445 | ||
446 | UD2_RunCMD(cmd); |
446 | UD2_RunCMD(cmd); |
447 | end; |
447 | end; |
448 | 448 | ||
449 | procedure TUD2MainForm.TasksPopupMenuPopup(Sender: TObject); |
449 | procedure TUD2MainForm.TasksPopupMenuPopup(Sender: TObject); |
450 | begin |
450 | begin |
451 | Run1.Enabled := TasksListView.ItemIndex <> -1; |
451 | Run1.Enabled := TasksListView.ItemIndex <> -1; |
452 | Properties1.Enabled := TasksListView.ItemIndex <> -1; |
452 | Properties1.Enabled := TasksListView.ItemIndex <> -1; |
453 | end; |
453 | end; |
454 | 454 | ||
455 | procedure TUD2MainForm.Run1Click(Sender: TObject); |
455 | procedure TUD2MainForm.Run1Click(Sender: TObject); |
456 | begin |
456 | begin |
457 | TasksListViewDblClick(Sender); |
457 | TasksListViewDblClick(Sender); |
458 | end; |
458 | end; |
459 | 459 | ||
460 | procedure TUD2MainForm.Properties1Click(Sender: TObject); |
460 | procedure TUD2MainForm.Properties1Click(Sender: TObject); |
461 | var |
461 | var |
462 | obj: TUD2ListViewEntry; |
462 | obj: TUD2ListViewEntry; |
463 | begin |
463 | begin |
464 | if TasksListView.ItemIndex = -1 then exit; |
464 | if TasksListView.ItemIndex = -1 then exit; |
465 | obj := TUD2ListViewEntry(TasksListView.Selected.Data); |
465 | obj := TUD2ListViewEntry(TasksListView.Selected.Data); |
466 | if obj.TaskPropertiesForm = nil then |
466 | if obj.TaskPropertiesForm = nil then |
467 | begin |
467 | begin |
468 | obj.TaskPropertiesForm := TUD2TaskPropertiesForm.Create(Self, ud2, obj.ShortTaskName); |
468 | obj.TaskPropertiesForm := TUD2TaskPropertiesForm.Create(Self, ud2, obj.ShortTaskName); |
469 | end; |
469 | end; |
470 | obj.TaskPropertiesForm.Show; |
470 | obj.TaskPropertiesForm.Show; |
471 | end; |
471 | end; |
472 | 472 | ||
473 | procedure TUD2MainForm.IdentificationsPopupMenuPopup(Sender: TObject); |
473 | procedure TUD2MainForm.IdentificationsPopupMenuPopup(Sender: TObject); |
474 | begin |
474 | begin |
475 | CopyTaskDefinitionExample1.Enabled := IdentificationsListView.ItemIndex <> -1; |
475 | CopyTaskDefinitionExample1.Enabled := IdentificationsListView.ItemIndex <> -1; |
476 | end; |
476 | end; |
477 | 477 | ||
478 | procedure TUD2MainForm.CopyTaskDefinitionExample1Click(Sender: TObject); |
478 | procedure TUD2MainForm.CopyTaskDefinitionExample1Click(Sender: TObject); |
479 | var |
479 | var |
480 | s: string; |
480 | s: string; |
481 | ude: TUD2IdentificationEntry; |
481 | ude: TUD2IdentificationEntry; |
482 | begin |
482 | begin |
483 | if IdentificationsListView.ItemIndex = -1 then exit; |
483 | if IdentificationsListView.ItemIndex = -1 then exit; |
484 | 484 | ||
485 | ude := TUD2IdentificationEntry(IdentificationsListView.Selected.Data); |
485 | ude := TUD2IdentificationEntry(IdentificationsListView.Selected.Data); |
486 | s := '; ' + ude.Plugin.PluginName + #13#10 + |
486 | s := '; ' + ude.Plugin.PluginName + #13#10 + |
487 | UD2_CondToStr(ude.GetConditionString(false))+'=calc.exe'+#13#10+ |
487 | UD2_CondToStr(ude.GetConditionString(false))+'=calc.exe'+#13#10+ |
488 | #13#10+ |
488 | #13#10+ |
489 | '; Alternatively:'+#13#10+ |
489 | '; Alternatively:'+#13#10+ |
490 | UD2_CondToStr(ude.GetConditionString(true))+'=calc.exe'+#13#10; |
490 | UD2_CondToStr(ude.GetConditionString(true))+'=calc.exe'+#13#10; |
491 | 491 | ||
492 | Clipboard.AsText := s; |
492 | Clipboard.AsText := s; |
493 | end; |
493 | end; |
494 | 494 | ||
495 | procedure TUD2MainForm.ListViewCompare(Sender: TObject; Item1, |
495 | procedure TUD2MainForm.ListViewCompare(Sender: TObject; Item1, |
496 | Item2: TListItem; Data: Integer; var Compare: Integer); |
496 | Item2: TListItem; Data: Integer; var Compare: Integer); |
497 | var |
497 | var |
498 | ListView: TVTSListView; |
498 | ListView: TVTSListView; |
499 | begin |
499 | begin |
500 | ListView := Sender as TVTSListView; |
500 | ListView := Sender as TVTSListView; |
501 | if ListView.CurSortedColumn = 0 then |
501 | if ListView.CurSortedColumn = 0 then |
502 | begin |
502 | begin |
503 | Compare := AlphaNumCompare(Item1.Caption, Item2.Caption); |
503 | Compare := AlphaNumCompare(Item1.Caption, Item2.Caption); |
504 | end |
504 | end |
505 | else |
505 | else |
506 | begin |
506 | begin |
507 | Compare := AlphaNumCompare(Item1.SubItems[ListView.CurSortedColumn-1], |
507 | Compare := AlphaNumCompare(Item1.SubItems[ListView.CurSortedColumn-1], |
508 | Item2.SubItems[ListView.CurSortedColumn-1]); |
508 | Item2.SubItems[ListView.CurSortedColumn-1]); |
509 | end; |
509 | end; |
510 | if ListView.CurSortedDesc then Compare := -Compare; |
510 | if ListView.CurSortedDesc then Compare := -Compare; |
511 | end; |
511 | end; |
512 | 512 | ||
513 | procedure TUD2MainForm.Button3Click(Sender: TObject); |
513 | procedure TUD2MainForm.Button3Click(Sender: TObject); |
514 | begin |
514 | begin |
515 | VTS_CheckUpdates('userdetect2', VersionLabel.Caption); |
515 | VTS_CheckUpdates('userdetect2', VersionLabel.Caption); |
516 | end; |
516 | end; |
517 | 517 | ||
518 | procedure TUD2MainForm.LoadedPluginsPopupMenuPopup(Sender: TObject); |
518 | procedure TUD2MainForm.LoadedPluginsPopupMenuPopup(Sender: TObject); |
519 | begin |
519 | begin |
520 | CopyStatusCodeToClipboard.Enabled := LoadedPluginsListView.ItemIndex <> -1; |
520 | CopyStatusCodeToClipboard.Enabled := LoadedPluginsListView.ItemIndex <> -1; |
521 | end; |
521 | end; |
522 | 522 | ||
523 | procedure TUD2MainForm.CopyStatusCodeToClipboardClick(Sender: TObject); |
523 | procedure TUD2MainForm.CopyStatusCodeToClipboardClick(Sender: TObject); |
524 | var |
524 | var |
525 | s: string; |
525 | s: string; |
526 | pl: TUD2Plugin; |
526 | pl: TUD2Plugin; |
527 | begin |
527 | begin |
528 | if LoadedPluginsListView.ItemIndex = -1 then exit; |
528 | if LoadedPluginsListView.ItemIndex = -1 then exit; |
529 | pl := TUD2Plugin(LoadedPluginsListView.Selected.Data); |
529 | pl := TUD2Plugin(LoadedPluginsListView.Selected.Data); |
530 | s := (*'; ' +*) pl.IdentificationProcedureStatusCodeDescribed; |
530 | s := (*'; ' +*) pl.IdentificationProcedureStatusCodeDescribed; |
531 | Clipboard.AsText := s; |
531 | Clipboard.AsText := s; |
532 | end; |
532 | end; |
533 | 533 | ||
534 | procedure TUD2MainForm.Run; |
534 | procedure TUD2MainForm.Run; |
535 | resourcestring |
535 | resourcestring |
536 | LNG_SYNTAX = 'Syntax: %s [TaskDefinitionFile [/T TaskName] | /C IdentificationTerm [Command] | /?]'; |
536 | LNG_SYNTAX = 'Syntax: %s [TaskDefinitionFile [/T TaskName] | /C IdentificationTerm [Command] | /?]'; |
537 | var |
537 | var |
538 | LoadedIniFile: string; |
538 | LoadedIniFile: string; |
539 | begin |
539 | begin |
540 | ExitCode := EXITCODE_OK; |
540 | ExitCode := EXITCODE_OK; |
541 | 541 | ||
542 | if ((ParamCount = 1) and CheckBoolParam(1, '?')) or |
542 | if ((ParamCount = 1) and CheckBoolParam(1, '?')) or |
543 | (CheckBoolParam(2, 'T') and (ParamCount > 3)) or |
543 | (CheckBoolParam(2, 'T') and (ParamCount > 3)) or |
544 | (CheckBoolParam(1, 'C') and (ParamCount > 3)) or |
544 | (CheckBoolParam(1, 'C') and (ParamCount > 3)) or |
545 | (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 |
546 | begin |
546 | begin |
547 | ExitCode := EXITCODE_SYNTAX_ERROR; |
547 | ExitCode := EXITCODE_SYNTAX_ERROR; |
548 | MessageDlg(Format(LNG_SYNTAX, [GetOwnCmdName]), mtInformation, [mbOK], 0); |
548 | MessageDlg(Format(LNG_SYNTAX, [GetOwnCmdName]), mtInformation, [mbOK], 0); |
549 | 549 | ||
550 | Visible := false; |
550 | Visible := false; |
551 | Close; |
551 | Close; |
552 | Exit; |
552 | Exit; |
553 | end; |
553 | end; |
554 | 554 | ||
555 | LoadedIniFile := GetIniFileName; |
555 | LoadedIniFile := GetIniFileName; |
556 | if LoadedIniFile = '' then |
556 | if LoadedIniFile = '' then |
557 | begin |
557 | begin |
558 | Visible := false; |
558 | Visible := false; |
559 | Close; |
559 | Close; |
560 | Exit; |
560 | Exit; |
561 | end; |
561 | end; |
562 | ud2 := TUD2.Create(LoadedIniFile); |
562 | ud2 := TUD2.Create(LoadedIniFile); |
563 | 563 | ||
564 | ud2.HandlePluginDir('', '*.udp'); |
564 | ud2.HandlePluginDir('', '*.udp'); |
565 | ud2.HandlePluginDir('Plugins', '*.udp'); |
565 | ud2.HandlePluginDir('Plugins', '*.udp'); |
566 | ud2.HandlePluginDir('Plugins', '*.dll'); |
566 | ud2.HandlePluginDir('Plugins', '*.dll'); |
567 | 567 | ||
568 | if CheckBoolParam(1, 'C') then |
568 | if CheckBoolParam(1, 'C') then |
569 | begin |
569 | begin |
570 | if ud2.FulfilsEverySubterm(ParamStr(2)) then |
570 | if ud2.FulfilsEverySubterm(ParamStr(2)) then |
571 | begin |
571 | begin |
572 | ExitCode := EXITCODE_OK; |
572 | ExitCode := EXITCODE_OK; |
573 | 573 | ||
574 | if ParamStr(3) <> '' then |
574 | if ParamStr(3) <> '' then |
575 | begin |
575 | begin |
576 | UD2_RunCMD(UD2P_DecodeCommand(ParamStr(3))); |
576 | UD2_RunCMD(UD2P_DecodeCommand(ParamStr(3))); |
577 | end; |
577 | end; |
578 | end |
578 | end |
579 | else |
579 | else |
580 | begin |
580 | begin |
581 | ExitCode := EXITCODE_TASK_NOTHING_MATCHES; |
581 | ExitCode := EXITCODE_TASK_NOTHING_MATCHES; |
582 | end; |
582 | end; |
583 | 583 | ||
584 | Visible := false; |
584 | Visible := false; |
585 | Close; |
585 | Close; |
586 | Exit; |
586 | Exit; |
587 | end |
587 | end |
588 | else if CheckBoolParam(2, 'T') then |
588 | else if CheckBoolParam(2, 'T') then |
589 | begin |
589 | begin |
590 | DoRun(ParamStr(3), false); |
590 | DoRun(ParamStr(3), false); |
591 | 591 | ||
592 | Visible := false; |
592 | Visible := false; |
593 | Close; |
593 | Close; |
594 | Exit; |
594 | Exit; |
595 | end |
595 | end |
596 | else |
596 | else |
597 | begin |
597 | begin |
598 | LoadTaskList; |
598 | LoadTaskList; |
599 | LoadDetectedIDs; |
599 | LoadDetectedIDs; |
600 | LoadINITemplate; |
600 | LoadINITemplate; |
601 | LoadLoadedPluginList; |
601 | LoadLoadedPluginList; |
602 | LoadDynamicPluginList; |
602 | LoadDynamicPluginList; |
603 | CheckForErrors; |
603 | CheckForErrors; |
604 | 604 | ||
605 | Visible := true; |
605 | Visible := true; |
606 | Exit; |
606 | Exit; |
607 | end; |
607 | end; |
608 | end; |
608 | end; |
609 | 609 | ||
610 | procedure TUD2MainForm.FormCreate(Sender: TObject); |
610 | procedure TUD2MainForm.FormCreate(Sender: TObject); |
611 | begin |
611 | begin |
612 | // 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 |
613 | PageControl1.ActivePage := TasksTabSheet; |
613 | PageControl1.ActivePage := TasksTabSheet; |
- | 614 | ||
- | 615 | VersionLabel.Caption := GetFileVersion(ParamStr(0)); |
|
614 | end; |
616 | end; |
615 | 617 | ||
616 | procedure TUD2MainForm.DynamicTestButtonClick(Sender: TObject); |
618 | procedure TUD2MainForm.DynamicTestButtonClick(Sender: TObject); |
617 | var |
619 | var |
618 | p: TUD2Plugin; |
620 | p: TUD2Plugin; |
619 | x: TArrayOfString; |
621 | x: TArrayOfString; |
620 | newStuff: boolean; |
622 | newStuff: boolean; |
621 | errors: TStrings; |
623 | errors: TStrings; |
622 | resourcestring |
624 | resourcestring |
623 | LNG_DETECTED_DYNAMICS = 'The plugin returns following identification strings:'; |
625 | LNG_DETECTED_DYNAMICS = 'The plugin returned following identification strings:'; |
624 | LNG_NOTHING_DETECTED = 'The plugin did not send any identification strings.'; |
626 | LNG_NOTHING_DETECTED = 'The plugin did not send any identification strings.'; |
625 | LNG_STATUS_RETURNED = 'The plugin sent following status in reply to your request:'; |
627 | LNG_STATUS_RETURNED = 'The plugin sent following status in reply to your request:'; |
626 | LNG_ERROR_RETURNED = 'The dynamic plugin could not load. The plugin sent following error messages:'; |
628 | LNG_ERROR_RETURNED = 'The dynamic plugin could not load. The plugin sent following error messages:'; |
627 | begin |
629 | begin |
628 | if DynamicTestPluginComboBox.ItemIndex = -1 then |
630 | if DynamicTestPluginComboBox.ItemIndex = -1 then |
629 | begin |
631 | begin |
630 | ShowMessage('Please select a plugin that is accepting dynamic requests.'); |
632 | ShowMessage('Please select a plugin that is accepting dynamic requests.'); |
631 | Exit; |
633 | Exit; |
632 | end; |
634 | end; |
633 | 635 | ||
634 | p := DynamicTestPluginComboBox.Items.Objects[DynamicTestPluginComboBox.ItemIndex] as TUD2Plugin; |
636 | p := DynamicTestPluginComboBox.Items.Objects[DynamicTestPluginComboBox.ItemIndex] as TUD2Plugin; |
635 | 637 | ||
636 | errors := TStringList.Create; |
638 | errors := TStringList.Create; |
637 | try |
639 | try |
638 | newStuff := p.InvokeDynamicCheck(DynamicTestDataEdit.Text, errors, x); |
640 | newStuff := p.InvokeDynamicCheck(DynamicTestDataEdit.Text, errors, x); |
639 | if errors.Count > 0 then |
641 | if errors.Count > 0 then |
640 | begin |
642 | begin |
641 | ShowMessage(LNG_ERROR_RETURNED + #13#10#13#10 + errors.Text); |
643 | ShowMessage(LNG_ERROR_RETURNED + #13#10#13#10 + errors.Text); |
642 | Exit; |
644 | Exit; |
643 | end; |
645 | end; |
644 | finally |
646 | finally |
645 | FreeAndNil(errors); |
647 | FreeAndNil(errors); |
646 | end; |
648 | end; |
647 | 649 | ||
648 | if p.IdentificationProcedureStatusCode.wCategory <> UD2_STATUSCAT_SUCCESS then |
650 | if p.IdentificationProcedureStatusCode.wCategory <> UD2_STATUSCAT_SUCCESS then |
649 | begin |
651 | begin |
650 | // e.g. "Not available" because of invalid dynamic input data |
652 | // e.g. "Not available" because of invalid dynamic input data |
651 | ShowMessage(LNG_STATUS_RETURNED + #13#10#13#10 + p.IdentificationProcedureStatusCodeDescribed); |
653 | ShowMessage(LNG_STATUS_RETURNED + #13#10#13#10 + p.IdentificationProcedureStatusCodeDescribed); |
652 | Exit; |
654 | Exit; |
653 | end; |
655 | end; |
654 | 656 | ||
655 | if Length(x) > 0 then |
657 | if Length(x) > 0 then |
656 | ShowMessage(LNG_DETECTED_DYNAMICS + #13#10#13#10 + MergeString(x, #13#10)) |
658 | ShowMessage(LNG_DETECTED_DYNAMICS + #13#10#13#10 + MergeString(x, #13#10)) |
657 | else |
659 | else |
658 | ShowMessage(LNG_NOTHING_DETECTED); |
660 | ShowMessage(LNG_NOTHING_DETECTED); |
659 | 661 | ||
660 | if newStuff then |
662 | if newStuff then |
661 | begin |
663 | begin |
662 | LoadDetectedIDs; |
664 | LoadDetectedIDs; |
663 | LoadINITemplate; |
665 | LoadINITemplate; |
664 | LoadLoadedPluginList; // To update the "Detected IDs" column |
666 | LoadLoadedPluginList; // To update the "Detected IDs" column |
665 | end; |
667 | end; |
666 | end; |
668 | end; |
667 | 669 | ||
668 | procedure TUD2MainForm.LoadDynamicPluginList; |
670 | procedure TUD2MainForm.LoadDynamicPluginList; |
669 | var |
671 | var |
670 | i: integer; |
672 | i: integer; |
671 | p: TUD2Plugin; |
673 | p: TUD2Plugin; |
672 | begin |
674 | begin |
673 | DynamicTestPluginComboBox.Clear; |
675 | DynamicTestPluginComboBox.Clear; |
674 | for i := 0 to ud2.LoadedPlugins.Count-1 do |
676 | for i := 0 to ud2.LoadedPlugins.Count-1 do |
675 | begin |
677 | begin |
676 | p := ud2.LoadedPlugins.Items[i] as TUD2Plugin; |
678 | p := ud2.LoadedPlugins.Items[i] as TUD2Plugin; |
677 | if p.AcceptsDynamicRequests then |
679 | if p.AcceptsDynamicRequests then |
678 | begin |
680 | begin |
679 | // TODO: PROBLEM!! Beim Dynamic Check (Dynamic Query) wird der plugin status überschrieben!!! |
681 | // TODO: PROBLEM!! Beim Dynamic Check (Dynamic Query) wird der plugin status überschrieben!!! |
680 | DynamicTestPluginComboBox.Items.AddObject(p.PluginName, p); |
682 | DynamicTestPluginComboBox.Items.AddObject(p.PluginName, p); |
681 | end; |
683 | end; |
682 | end; |
684 | end; |
683 | end; |
685 | end; |
684 | 686 | ||
685 | end. |
687 | end. |
686 | 688 |