summaryrefslogtreecommitdiff
path: root/plugins/Actman30/ua/ua.pas
blob: 9c9554e1c04df2ed42cc3c5584acf10a71b2a1e2 (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
unit ua;

interface

implementation

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

{$R ua.res}

{$include m_actman.inc}

{$include i_uconst.inc}
{$include i_uavars.inc}

// in - Action ID, out - action (group) number
function GetUABranch(setting:pAnsiChar;id:cardinal):pAnsiChar;
var
  i:integer;
  p,p1:pAnsiChar;
begin
  result:=nil;
  p1:=StrCopyE(setting,opt_groups);
  for i:=0 to CallService(MS_ACT_GETLIST,0,0)-1 do
  begin
    p:=StrEnd(IntToStr(p1,i));
    p^:='/'; inc(p);
    StrCopy(p,opt_id);
    if DBReadDWord(0,DBBranch,setting)=id then
    begin
      p^:=#0;
      result:=p;
      break;
    end;
  end;
end;

var
  amLink:tActionLink;

{$include i_uaplaces.inc}
{$include i_options.inc}
{$include i_opt_dlg.inc}
{$include i_ua.inc}
{$include i_inoutxm.inc}

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

procedure CheckPlacesAbility;
var
  i:integer;
begin
  for i:=0 to NumTypes-1 do
  begin
    with NamesArray[i] do
    begin
      enable:=(service=nil) or (ServiceExists(service)<>0);
    end;
  end;
end;

procedure Init;
begin
  GetModuleFileNameW(hInstance,szMyPath,MAX_PATH);

  CreateServiceFunction(SERVICE_WITH_LPARAM_NAME,@ServiceCallWithLParam);
  CreateServiceFunction(TTB_SERVICE_NAME        ,@TTBServiceCall);
  CheckPlacesAbility;

  CreateUActionList;

  HookEvent(ME_TTB_MODULELOADED ,@OnTTBLoaded);
  HookEvent(ME_MSG_TOOLBARLOADED,@OnTabBBLoaded);
  HookEvent(ME_MSG_BUTTONPRESSED,@OnTabButtonPressed);
  HookEvent(ME_ACT_CHANGED      ,@ActListChange);

  HookEvent(ME_CLIST_PREBUILDMAINMENU   , PreBuildMainMenu);
  HookEvent(ME_CLIST_PREBUILDCONTACTMENU, PreBuildContactMenu);
  HookEvent(ME_CLIST_PREBUILDTRAYMENU   , PreBuildTrayMenu);

  HookEvent(ME_ACT_INOUT,@ActInOut);
end;

procedure DeInit;
var
  i:integer;
begin
  if Length(UActionList)>0 then
  begin
    for i:=HIGH(UActionList) downto 0 do
    begin
      DeleteUAction(i,false);
    end;
    SetLength(UActionList,0);
  end;
  SetLength(arMenuRec,0);
end;

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

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

initialization
  InitLink;
end.