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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
|
{
Miranda IM: the free IM client for Microsoft* Windows*
Copyright 2000-2003 Miranda ICQ/IM project,
all portions of this codebase are copyrighted to the people
listed in contributors.txt.
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
}
{$A+,H+}
{$IFNDEF VER130} // skip for delphi 5
{$IFDEF WIN32}{$A4}{$ENDIF}
{$IFDEF WIN64}{$A8}{$ENDIF}
{$ENDIF}
{$UNDEF AllowInline}
unit m_api;
interface
{$IFDEF FPC}
{$DEFINE AllowInline}
{$ELSE}
{$IFDEF ConditionalExpressions}
// CompilerVersion defined in SYSTEM module, need to use not earlier
{$IF CompilerVersion >= 22}
{$DEFINE AllowInline}
{$IFEND}
{$ENDIF}
{$ENDIF}
uses
Windows,CommCtrl,Messages;//, FreeImage;
// often used
const
strCList:PAnsiChar = 'CList';
const
NM_FIRST = 0; // from CommCtrl
// RichEdit definitions
type
PCHARRANGE = ^TCHARRANGE;
TCHARRANGE = record
cpMin:integer;
cpMax:integer;
end;
CHARRANGE = TCHARRANGE;
// C translations
type
{$IFNDEF FPC}
{$IFDEF WIN32}
// delphi 64 must have these types anyway
int_ptr = integer;
uint_ptr = cardinal;
{$ENDIF}
long = longint;
plong = ^long;
{$IFDEF VER150}
UnicodeString = WideString;
ULONG_PTR = longword;
{$ENDIF}
DWORD_PTR = ULONG_PTR;
size_t = ULONG_PTR;
{$ENDIF}
pint_ptr = ^int_ptr;
puint_ptr = ^uint_ptr;
time_t = ulong;
int = integer;
// uint = Cardinal;
// pint = ^int;
// WPARAM = integer;
// LPARAM = integer;
TLPARAM = LPARAM;
TWPARAM = WPARAM;
// My definitions
TWNDPROC = function (Dialog:HWND; hMessage:uint; wParam:WPARAM;lParam:LPARAM):LRESULT; stdcall;
type
PTChar = ^TChar;
TChar = record
case boolean of
false: (a:PAnsiChar); // ANSI or UTF8
true: (w:PWideChar); // Unicode
end;
{$include m_core.inc}
{$include m_system.inc}
{-- start newpluginapi --}
const
UNICODE_AWARE = 1;
STATIC_PLUGIN = 2;
// The UUID structure below is used to for plugin UUID's and module type definitions
type
PMUUID = ^TMUUID;
MUUID = System.TGUID;
TMUUID = MUUID;
{
MUUID = record
a:cardinal;
b:word;
c:word;
d:array [0..7] of byte;
end;
}
{$include interfaces.inc}
type
PPLUGININFOEX = ^TPLUGININFOEX;
TPLUGININFOEX = record
cbSize :int;
shortName :PAnsiChar;
version :dword;
description:PAnsiChar;
author :PAnsiChar;
copyright :PAnsiChar;
homepage :PAnsiChar;
flags :byte; // right now the only flag, UNICODE_AWARE, is recognized here
case boolean of
false: (dummy:longword);
true : (uuid :MUUID); // plugin's unique identifier
end;
type
PCMPlugin = ^CMPlugin;
CMPlugin = record
vft : pointer; // virtual function table
m_hInst : THANDLE;
m_szModule : PAnsiChar;
m_pInfo : PPLUGININFOEX;
m_hLogger : THANDLE;
m_hLang : int;
end;
//----- Fork enchancement -----
{
Miranda/System/LoadModule event
called when a plugin is being loaded dynamically
wParam=PLUGININFOEX*
//lParam=HINSTANCE of the loaded plugin
}
const
ME_SYSTEM_MODULELOAD:PAnsiChar = 'Miranda/System/LoadModule';
{
Miranda/System/UnloadModule event
called when a plugin is being unloaded dynamically
wParam=PLUGININFOEX*
lParam=HINSTANCE of the loaded plugin
}
ME_SYSTEM_MODULEUNLOAD:PAnsiChar = 'Miranda/System/UnloadModule';
{
Each service mode plugin must implement MS_SERVICEMODE_LAUNCH
This service might return one of the following values:
SERVICE_CONTINUE - load Miranda normally, like there's no service plugins at all
SERVICE_ONLYDB - load database and then execute service plugin only
SERVICE_MONOPOLY - execute only service plugin, even without database
SERVICE_FAILED - terminate Miranda execution
}
const
SERVICE_CONTINUE = 0;
SERVICE_ONLYDB = 1;
SERVICE_MONOPOLY = 2;
SERVICE_FAILED = (-1);
MS_SERVICEMODE_LAUNCH:PansiChar = 'ServiceMode/Launch';
{-- end newpluginapi --}
var
{ has to be returned via MirandaPluginInfo and has to be statically allocated,
this means only one module can return info, you shouldn't be merging them anyway! }
PluginInfo: TPLUGININFOEX;
g_plugin: CMPlugin;
{$include m_clist.inc}
{$include m_genmenu.inc}
{$include m_protosvc.inc}
{$include m_protocols.inc}
{$include m_acc.inc}
{$include m_addcontact.inc}
{$include m_avatars.inc}
{$include m_awaymsg.inc}
{$include m_button.inc}
{$include m_button_int.inc}
{$include m_clc.inc}
{$include m_clistint.inc}
{$include m_cluiframes.inc}
{$include m_contacts.inc}
{$include m_crypto.inc}
{$include m_database.inc}
{$include m_descbutton.inc}
{$include m_email.inc}
{$include m_extraicons.inc}
{$include m_file.inc}
{$include m_findadd.inc}
{$include m_fontservice.inc}
{$include m_history.inc}
{$include m_hotkeys.inc}
{$include m_icolib.inc}
{$include m_iconheader.inc}
{$include m_ignore.inc}
{$include m_imgsrvc.inc}
{$include m_json.inc}
{$include m_langpack.inc}
{$include m_message.inc}
{$include m_metacontacts.inc}
{$include m_netlib.inc}
{$include m_options.inc}
{$include m_pluginupdater.inc}
{$include m_popup.inc}
{$include m_protomod.inc}
{$include m_skin.inc}
{$include m_ssl.inc}
{$include statusmodes.inc}
{$include m_timezones.inc}
{$include m_userinfo.inc}
{$include m_utils.inc}
{$include m_xstatus.inc}
{$include m_zlib.inc}
{$include custom_api.inc}
{$define M_API_UNIT}
{$include m_helpers.inc}
implementation
{$undef M_API_UNIT}
{$include m_helpers.inc}
initialization
g_plugin.m_hInst := hInstance;
g_plugin.m_pInfo := @PluginInfo;
RegisterPlugin(g_plugin);
finalization
UnregisterPlugin(g_plugin);
end.
|