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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
|
/* Triggers */
typedef struct {
int cbSize;
char *pszName; // used as identifier, must be unique
HINSTANCE hInstance; // only needed when options screen is available
DLGPROC pfnDlgProc; // only needed when options screen is available; the callback proc
char *pszTemplate; // only needed when options screen is available; must be WS_CHILD, Control parent and !visible are recommended
} TRIGGERREGISTER;
/* /Trigger/RegisterTrigger service
Register your trigger at the TriggerPlugin
wParam = 0
lParam = (LPARAM)(TRIGGERREGISTER *)&tr
If you try to register a trigger with a name that already exists, the service will fail.
Returns 0 on success, any other value on failure.
*/
#define MS_TRIGGER_REGISTERTRIGGER "/Trigger/RegisterTrigger"
/* Dialog messages
These message will be send to the options dialog, if available.
*/
/* TM_ADDTRIGGER
'OK' is pressed and a new trigger will be added. Save your settings using the given triggerID.
wParam = (WPARAM)(DWORD)triggerID
lParam = 0
*/
#define TM_ADDTRIGGER WM_USER+10
/* TM_DELTRIGGER
The trigger addociated with the given triggerID will be removed, cleanup your settings for this trigger.
wParam = (WPARAM)(DWORD)triggerID
lParam = 0
*/
#define TM_DELTRIGGER WM_USER+11
#define DF_CONTACT 0x01 // the hContact member is valid
#define DF_PROTO 0x02 // the szProto member is valid
#define DF_STATUS 0x04 // the status member is valid
#define DF_TEXT 0x08 // the szText member is valid
#define DF_LPARAM 0x10 // reserverd, lParam is valid
typedef struct {
int cbSize;
int dFlags; // DF_*
HANDLE hContact;
char *szProto;
int status;
char *szText;
LPARAM lParam;
} TRIGGERDATA;
typedef struct {
int cbSize;
DWORD triggerID;
char *pszSummary; // small summary to be shown in the options screen
TRIGGERDATA *td; // may be NULL, or only the dfFlags member set if triggerID is 0
} SPECIFICTRIGGERINFO;
/* TM_GETTRIGGERINFO
(optional) Information for a specific trigger is requested.
wParam = (WPARAM)(DWORD)triggerID
lParam = (LPARAM)(SPECIFICTRIGGERINFO **)&sti
Set *(SPECIFICTRIGGERINFO **)lParam to a (SPECIFICTRIGGERINFO *)&sti, and keep it in memory
If triggerID is 0, you may only set the dFlags member of the TRIGGERDATA struct.
*/
#define TM_GETTRIGGERINFO WM_USER+12
/* TM_ACTIONCHANGED
(optional) Notification when the user changed the action in the options dialog.
wParam = 0
lParam = (SPECIFICACTIONINFO *)&sai
*/
#define TM_ACTIONCHANGED WM_USER+13
#define TRG_PERFORM 0x01 // perform the actions associated to this trigger
#define TRG_CLEANUP 0x02 // remove all related information after the call
#define TRG_GETINFO 0x04 // retrieve the (SPECIFICATIONINFO *)&sai for this trigger (only if triggerID != 0)
typedef struct {
int cbSize;
DWORD triggerID; // triggerID of the event to trigger or 0 for all
char *pszName; // name of trigger (may be NULL if triggerID isn't 0)
int flags; // flags (TRG_*)
SPECIFICTRIGGERINFO *sti; // may be NULL
} REPORT_INFO;
/* /Trigger/ReportAction
Service to call when you trigger your event.
wParam = 0
lParam = (REPORT_INFO *)&ri
If you're trigger does not have any options, set triggerID to 0 and TriggerPlugin will call all
associated actions, but set the triggerName member in that case.
*/
#define MS_TRIGGER_REPORTACTION "/Trigger/ReportAction"
/* Actions */
typedef struct {
int cbSize;
char *pszName; // must be unique!
char *pszService; // called with wParam = flags, lParam = (SPECIFICATIONINFO *)&sai
HINSTANCE hInstance; // only needed when options screen is available
DLGPROC pfnDlgProc; // only needed when options screen is available; the callback proc
char *pszTemplate; // only needed when options screen is available; must be WS_CHILD, Control parent and !visible are recommended
} ACTIONREGISTER;
/* /Trigger/RegisterAction service
Register your action at the TriggerPlugin
wParam = 0
lParam = (LPARAM)(ACTIONREGISTER *)&ar
If you try to register an action with a name that already exists, the service will fail.
Returns 0 on success, any other value on failure.
*/
#define MS_TRIGGER_REGISTERACTION "/Trigger/RegisterAction"
/* Dialog messages
These message will be send to the options dialog, if available.
*/
/* TM_ADDACTION
'OK' is pressed and a new trigger will be added. Save your settings using the given actionID.
wParam = (WPARAM)(DWORD)actionID
lParam = 0
*/
#define TM_ADDACTION WM_USER+1
/* TM_TRIGGERCHANGED
(optional) Notification when the user changed the trigger in the options dialog.
wParam = 0
lParam = (SPECIFICTRIGGERINFO *)&sai
*/
#define TM_TRIGGERCHANGED WM_USER+2
#define ACT_PERFORM 0x01 // perform your action
#define ACT_CLEANUP 0x02 // cleanup associated settings
#define ACT_GETINFO 0x04 // return (SPECIFICACTIONINFO *)&sai
/* pszService
The service called, specified in the ACTIONREGISTER
wParam = (WPARAM)ACT_* flags
lParam = (LPARAM)SPECIFICACTIONINFO *)&sai
You can retrieve the actionID from the SPECIFICACTIONINFO. If ACT_PERFORM is set, you can retrive
additional data given by the trigger plugin from the (TRIGGERDATA *)&td member (this can be NULL).
Return 0 on success, any other on failure.
*/
typedef struct {
int cbSize;
DWORD actionID; // actionID of the info requested
char *pszSummary; // null terminating string containing a summary of the action, may be NULL
TRIGGERDATA *td; // may be NULL
} SPECIFICACTIONINFO;
/* Helpers */
#define PREFIX_ACTIONID "aid"
#define PREFIX_TRIGGERID "tid"
typedef struct {
int cbSize;
char *prefix; // prefix, defaults are PREFIX_ACTIONID for actions, PREFIX_TRIGGERID for triggers
DWORD id; // action or trigger ID of the setting to remove
char *szModule; // module where the settings are stored
HANDLE hContact; // associated contact
} REMOVETRIGGERSETTINGS;
/* /Trigger/RemoveSettings Service
wParam = 0
lParam = (LPARAM)(REMOVETRIGGERSETTINGS *)&rts
Removes settings from the database you wrote with the DBWriteAction* or DBWriteTrigger* helpers.
Returns the number of settings removed or -1 on failure.
*/
#define MS_TRIGGER_REMOVESETTINGS "/Trigger/RemoveSettings"
typedef struct {
int cbSize;
char *prefix; // prefix, defaults are PREFIX_ACTIONID for actions, PREFIX_TRIGGERID for triggers
DWORD id; // action or trigger ID of the previous setting
char *szName; // either the name of the trigger or the action, or NULL for all
char *szModule; // module where the settings are stored
HANDLE hContact; // assoicated contact
} FINDTRIGGERSETTING;
/* /Trigger/FindNextSetting Service
wParam = 0
lParam = (LPARAM)(FINDTRIGGERSETTING *)&fts
Search for a setting in the database. Set id to 0 to start from the beginning, else search is done from id+1.
Returns (DWORD)triggerID or actionID depending on prefix of the next setting in the database. Returns 0 if
no more settings are found.
*/
#define MS_TRIGGER_FINDNEXTSETTING "/Trigger/FindNextSetting"
/* Database helpers */
static int __inline DBWriteActionSettingByte(DWORD actionID, HANDLE hContact,const char *szModule,const char *szSetting,BYTE val) {
char dbSetting[128];
_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ACTIONID, actionID, szSetting);
return DBWriteContactSettingByte(hContact, szModule, dbSetting, val);
}
static int __inline DBWriteActionSettingWord(DWORD actionID, HANDLE hContact,const char *szModule,const char *szSetting,WORD val) {
char dbSetting[128];
_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ACTIONID, actionID, szSetting);
return DBWriteContactSettingWord(hContact, szModule, dbSetting, val);
}
static int __inline DBWriteActionSettingDword(DWORD actionID, HANDLE hContact,const char *szModule,const char *szSetting,DWORD val) {
char dbSetting[128];
_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ACTIONID, actionID, szSetting);
return DBWriteContactSettingDword(hContact, szModule, dbSetting, val);
}
static int __inline DBWriteActionSettingString(DWORD actionID, HANDLE hContact,const char *szModule,const char *szSetting,const char *val) {
char dbSetting[128];
_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ACTIONID, actionID, szSetting);
return DBWriteContactSettingString(hContact, szModule, dbSetting, val);
}
static BYTE __inline DBGetActionSettingByte(DWORD actionID, HANDLE hContact, const char *szModule, const char *szSetting, BYTE errorValue) {
char dbSetting[128];
_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ACTIONID, actionID, szSetting);
return (BYTE)DBGetContactSettingByte(hContact, szModule, dbSetting, errorValue);
}
static WORD __inline DBGetActionSettingWord(DWORD actionID, HANDLE hContact, const char *szModule, const char *szSetting, WORD errorValue) {
char dbSetting[128];
_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ACTIONID, actionID, szSetting);
return (WORD)DBGetContactSettingWord(hContact, szModule, dbSetting, errorValue);
}
static DWORD __inline DBGetActionSettingDword(DWORD actionID, HANDLE hContact, const char *szModule, const char *szSetting, int errorValue) {
char dbSetting[128];
_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ACTIONID, actionID, szSetting);
return DBGetContactSettingDword(hContact, szModule, dbSetting, errorValue);
}
static int __inline DBGetActionSetting(DWORD actionID, HANDLE hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv) {
char dbSetting[128];
_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ACTIONID, actionID, szSetting);
return DBGetContactSetting(hContact, szModule, dbSetting, dbv);
}
static int __inline DBDeleteActionSetting(DWORD actionID, HANDLE hContact,const char *szModule,const char *szSetting) {
char dbSetting[128];
_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_ACTIONID, actionID, szSetting);
return DBDeleteContactSetting(hContact, szModule, dbSetting);
}
/* Triggers */
static int __inline DBWriteTriggerSettingByte(DWORD triggerID, HANDLE hContact,const char *szModule,const char *szSetting,BYTE val) {
char dbSetting[128];
_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_TRIGGERID, triggerID, szSetting);
return DBWriteContactSettingByte(hContact, szModule, dbSetting, val);
}
static int __inline DBWriteTriggerSettingWord(DWORD triggerID, HANDLE hContact,const char *szModule,const char *szSetting,WORD val) {
char dbSetting[128];
_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_TRIGGERID, triggerID, szSetting);
return DBWriteContactSettingWord(hContact, szModule, dbSetting, val);
}
static int __inline DBWriteTriggerSettingDword(DWORD triggerID, HANDLE hContact,const char *szModule,const char *szSetting,DWORD val) {
char dbSetting[128];
_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_TRIGGERID, triggerID, szSetting);
return DBWriteContactSettingDword(hContact, szModule, dbSetting, val);
}
static int __inline DBWriteTriggerSettingString(DWORD triggerID, HANDLE hContact,const char *szModule,const char *szSetting,const char *val) {
char dbSetting[128];
_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_TRIGGERID, triggerID, szSetting);
return DBWriteContactSettingString(hContact, szModule, dbSetting, val);
}
static BYTE __inline DBGetTriggerSettingByte(DWORD triggerID, HANDLE hContact, const char *szModule, const char *szSetting, BYTE errorValue) {
char dbSetting[128];
_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_TRIGGERID, triggerID, szSetting);
return (BYTE)DBGetContactSettingByte(hContact, szModule, dbSetting, errorValue);
}
static WORD __inline DBGetTriggerSettingWord(DWORD triggerID, HANDLE hContact, const char *szModule, const char *szSetting, WORD errorValue) {
char dbSetting[128];
_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_TRIGGERID, triggerID, szSetting);
return (WORD)DBGetContactSettingWord(hContact, szModule, dbSetting, errorValue);
}
static DWORD __inline DBGetTriggerSettingDword(DWORD triggerID, HANDLE hContact, const char *szModule, const char *szSetting, int errorValue) {
char dbSetting[128];
_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_TRIGGERID, triggerID, szSetting);
return DBGetContactSettingDword(hContact, szModule, dbSetting, errorValue);
}
static int __inline DBGetTriggerSetting(DWORD triggerID, HANDLE hContact, const char *szModule, const char *szSetting, DBVARIANT *dbv) {
char dbSetting[128];
_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_TRIGGERID, triggerID, szSetting);
return DBGetContactSetting(hContact, szModule, dbSetting, dbv);
}
static int __inline DBDeleteTriggerSetting(DWORD triggerID, HANDLE hContact,const char *szModule,const char *szSetting) {
char dbSetting[128];
_snprintf(dbSetting, sizeof(dbSetting), "%s%u_%s", PREFIX_TRIGGERID, triggerID, szSetting);
return DBDeleteContactSetting(hContact, szModule, dbSetting);
}
|