summaryrefslogtreecommitdiff
path: root/plugins/!Deprecated/Actman20/i_services.inc
blob: d835c9225a0c431cb9df7c9535201642222d2e73 (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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
{Basic ActMan services}

function ActFreeList(wParam:WPARAM;lParam:LPARAM):int_ptr;cdecl;
begin
  result:=0;
  mFreeMem(PAnsiChar(lParam));
end;

function ActGetList(wParam:WPARAM;lParam:LPARAM):int_ptr;cdecl;
var
  pc:^tChain;
  p:pHKRecord;
  i,cnt:integer;
begin
  p:=@GroupList[0];
  cnt:=0;
  for i:=0 to MaxGroups-1 do
  begin
    if (p^.flags and (ACF_ASSIGNED or ACF_VOLATILE))=ACF_ASSIGNED then inc(cnt);
    inc(p);
  end;
  result:=cnt;
  if lParam=0 then exit;
  if cnt>0 then
  begin
    mGetMem(pc,cnt*SizeOf(tChain)+4);
    puint_ptr(lParam)^:=uint_ptr(pc);
//    {$IFDEF WIN64}pqword{$ELSE}pdword{$ENDIF}(lParam)^:=uint_ptr(pc);
    pdword(pc)^:=SizeOf(tChain);
    inc(PByte(pc),4);

    p:=@GroupList[0];
    for i:=0 to MaxGroups-1 do
    begin
      if (p^.flags and (ACF_ASSIGNED or ACF_VOLATILE))=ACF_ASSIGNED then
      begin
        pc^.descr:=p^.descr;
        pc^.id   :=p^.id;
        pc^.flags:=p^.flags;
        inc(pc);
      end;
      inc(p);
    end;
  end
  else
    puint_ptr(lParam)^:=0;
//    {$IFDEF WIN64}pqword{$ELSE}pdword{$ENDIF}(lParam)^:=0;
end;

function ActRun(wParam:WPARAM;lParam:LPARAM):int_ptr;cdecl;
var
  i:integer;
  p:pHKRecord;
begin
  result:=-1;
  p:=@GroupList[0];
  for i:=0 to MaxGroups-1 do
  begin
    if ((p^.flags and ACF_ASSIGNED)<>0) and (p^.id=dword(wParam)) then
    begin
      result:=p^.firstAction;
      break;
    end;
    inc(p);
  end;
  if result>0 then
    result:=ActionStarter(result,lParam,p);
end;

function ActRunGroup(wParam:WPARAM;lParam:LPARAM):int_ptr;cdecl;
var
  i:integer;
  p:pHKRecord;
begin
  result:=-1;
  p:=@GroupList[0];
  for i:=0 to MaxGroups-1 do
  begin
    if ((p^.flags and ACF_ASSIGNED)<>0) and (StrCmpW(p^.descr,pWideChar(wParam))=0) then
    begin
      result:=p^.firstAction;
      break;
    end;
    inc(p);
  end;
  if result>0 then
    result:=ActionStarter(result,lParam,p);
end;

function ActRunParam(wParam:WPARAM;lParam:LPARAM):int_ptr;cdecl;
var
  i:integer;
  p:pHKRecord;
begin
  result:=-1;
  p:=@GroupList[0];
  
  if (pAct_Param(lParam)^.flags and ACTP_BYNAME)=0 then
  begin
    for i:=0 to MaxGroups-1 do
    begin
      if ((p^.flags and ACF_ASSIGNED)<>0) and (p^.id=pAct_Param(lParam)^.Id) then
      begin
        result:=p^.firstAction;
        break;
      end;
      inc(p);
    end;
  end
  else
  begin
    for i:=0 to MaxGroups-1 do
    begin
      if ((p^.flags and ACF_ASSIGNED)<>0) and
         (StrCmpW(p^.descr,pWideChar(pAct_Param(lParam)^.Id))=0) then
      begin
        result:=p^.firstAction;
        break;
      end;
      inc(p);
    end;
  end;

  if result>0 then
  begin
    if (pAct_Param(lParam)^.flags and ACTP_WAIT)=0 then
      result:=ActionStarter    (result,pAct_Param(lParam)^.wParam,p,pAct_Param(lParam)^.lParam)
    else
      result:=ActionStarterWait(result,pAct_Param(lParam)^.wParam,p,pAct_Param(lParam)^.lParam);
  end;
end;