summaryrefslogtreecommitdiff
path: root/plugins/!Deprecated/Actman20/tasks/scheduler.pas
blob: 05e9cb6a5821f676f9243320b5c5b7027e3fb802 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
unit scheduler;

interface

procedure Init;
procedure DeInit;
function AddOptionPage(var tmpl:pAnsiChar;var proc:pointer;var name:PAnsiChar):integer;

implementation

uses
  windows, commctrl, messages,
  mirutils, common, dbsettings, io, m_api, wrapper,
  global;

{$R tasks.res}

{$include m_actman.inc}

var
  hevent: THANDLE;

{$include i_task.inc}
{$include i_tconst.inc}
{$include i_options.inc}
{$include i_opt_dlg.inc}
{$include i_service.inc}

// ------------ base interface functions -------------

var
  hendis,
  hcount,
  hdel: THANDLE;

procedure Init;
begin

  if LoadTasks=0 then
  begin
    MaxTasks:=8;
    GetMem  (TaskList ,MaxTasks*SizeOf(tTaskRec));
    FillChar(TaskList^,MaxTasks*SizeOf(tTaskRec),0);
  end
  else
    SetAllTasks;

  hcount:=CreateServiceFunction(MS_ACT_TASKCOUNT ,@TaskCount);
  hendis:=CreateServiceFunction(MS_ACT_TASKENABLE,@TaskEnable);
  hdel  :=CreateServiceFunction(MS_ACT_TASKDELETE,@TaskDelete);
  hevent:=CreateHookableEvent(ME_ACT_BELL);

end;

procedure DeInit;
begin
  StopAllTasks;
  DestroyServiceFunction(hendis);
  DestroyServiceFunction(hdel);
  DestroyServiceFunction(hcount);
  ClearTasks;
end;

function AddOptionPage(var tmpl:pAnsiChar;var proc:pointer;var name:PAnsiChar):integer;
begin
  result:=0;
  tmpl:=PAnsiChar(IDD_TASKS);
  proc:=@DlgProcOpt;
  name:='Scheduler';
end;

var
  amLink:tActionLink;

procedure InitLink;
begin
  amLink.Next     :=ActionLink;
  amLink.Init     :=@Init;
  amLink.DeInit   :=@DeInit;
  amLink.AddOption:=@AddOptionPage;
  ActionLink      :=@amLink;
end;

initialization
  InitLink;
end.