Mercurial > ~mikael > mcabber > hg
annotate mcabber/mcabber/hooks.h @ 1795:47699a09ceb3
Rework the hook system
This hook system implementation should be more efficient and a little
more flexible.
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Sat, 20 Mar 2010 14:38:17 +0100 |
parents | 250ad919f03f |
children | 5e2db25fdb17 |
rev | line source |
---|---|
1668
41c26b7d2890
Install mcabber headers
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1658
diff
changeset
|
1 #ifndef __MCABBER_HOOKS_H__ |
41c26b7d2890
Install mcabber headers
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1658
diff
changeset
|
2 #define __MCABBER_HOOKS_H__ 1 |
113 | 3 |
4 #include <time.h> | |
1598 | 5 #include <loudmouth/loudmouth.h> |
1668
41c26b7d2890
Install mcabber headers
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1658
diff
changeset
|
6 #include <mcabber/xmpp.h> |
113 | 7 |
1484
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1425
diff
changeset
|
8 // These two defines are used by hk_message_{in,out} arguments |
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1425
diff
changeset
|
9 #define ENCRYPTED_PGP 1 |
7b36b91a4388
New UI message flag (O) when OTR is used
Mikael Berthe <mikael@lilotux.net>
parents:
1425
diff
changeset
|
10 #define ENCRYPTED_OTR 2 |
113 | 11 |
1668
41c26b7d2890
Install mcabber headers
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1658
diff
changeset
|
12 #include <mcabber/config.h> |
1607 | 13 #ifdef MODULES_ENABLE |
14 #include <glib.h> | |
15 | |
1795 | 16 // Core hooks |
17 #define HOOK_MESSAGE_IN "hook-message-in" | |
18 #define HOOK_MESSAGE_OUT "hook-message-out" | |
19 #define HOOK_STATUS_CHANGE "hook-status-change" | |
20 #define HOOK_MY_STATUS_CHANGE "hook-my-status-change" | |
21 #define HOOK_POST_CONNECT "hook-post-connect" | |
22 #define HOOK_PRE_DISCONNECT "hook-pre-disconnect" | |
23 | |
24 typedef enum { | |
25 HOOK_HANDLER_RESULT_ALLOW_MORE_HOOKS = 0, | |
26 HOOK_HANDLER_RESULT_NO_MORE_HOOK, | |
27 HOOK_HANDLER_RESULT_NO_MORE_HOOK_DROP_DATA, | |
28 } hk_handler_result; | |
1623
b008ac166b91
Flags for hook handlers
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1607
diff
changeset
|
29 |
1607 | 30 typedef struct { |
31 const char *name; | |
32 const char *value; | |
33 } hk_arg_t; | |
34 | |
1795 | 35 typedef guint (*hk_handler_t) (const gchar *hookname, hk_arg_t *args, |
36 gpointer userdata); | |
1607 | 37 |
1795 | 38 guint hk_add_handler(hk_handler_t handler, const gchar *hookname, |
39 gint priority, gpointer userdata); | |
40 void hk_del_handler(const gchar *hookname, guint hid); | |
41 guint hk_run_handlers(const gchar *hookname, hk_arg_t *args); | |
1607 | 42 #endif |
43 | |
1398
f8321420ed7a
Remove useless inline's
Mikael Berthe <mikael@lilotux.net>
parents:
1352
diff
changeset
|
44 void hk_message_in(const char *bjid, const char *resname, |
1598 | 45 time_t timestamp, const char *msg, LmMessageSubType type, |
46 guint encrypted); | |
1398
f8321420ed7a
Remove useless inline's
Mikael Berthe <mikael@lilotux.net>
parents:
1352
diff
changeset
|
47 void hk_message_out(const char *bjid, const char *nickname, |
1602 | 48 time_t timestamp, const char *msg, |
49 guint encrypted, gpointer xep184); | |
1398
f8321420ed7a
Remove useless inline's
Mikael Berthe <mikael@lilotux.net>
parents:
1352
diff
changeset
|
50 void hk_statuschange(const char *bjid, const char *resname, gchar prio, |
1598 | 51 time_t timestamp, enum imstatus status, |
52 char const *status_msg); | |
1398
f8321420ed7a
Remove useless inline's
Mikael Berthe <mikael@lilotux.net>
parents:
1352
diff
changeset
|
53 void hk_mystatuschange(time_t timestamp, |
1784
250ad919f03f
Small code cleanup in hooks.[ch]
Mikael Berthe <mikael@lilotux.net>
parents:
1683
diff
changeset
|
54 enum imstatus old_status, enum imstatus new_status, |
250ad919f03f
Small code cleanup in hooks.[ch]
Mikael Berthe <mikael@lilotux.net>
parents:
1683
diff
changeset
|
55 const char *msg); |
113 | 56 |
1683
b09f82f61745
Split HOOK_INTERNAL
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1668
diff
changeset
|
57 void hk_postconnect(void); |
b09f82f61745
Split HOOK_INTERNAL
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1668
diff
changeset
|
58 void hk_predisconnect(void); |
1352
61a54e172010
Add internal hooks support
Mikael Berthe <mikael@lilotux.net>
parents:
1058
diff
changeset
|
59 |
281
f562b9af2de7
Add "const" specifier in prototypes
Mikael Berthe <mikael@lilotux.net>
parents:
221
diff
changeset
|
60 void hk_ext_cmd_init(const char *command); |
1058 | 61 void hk_ext_cmd(const char *bjid, guchar type, guchar info, const char *data); |
160 | 62 |
1668
41c26b7d2890
Install mcabber headers
Myhailo Danylenko <isbear@ukrpost.net>
parents:
1658
diff
changeset
|
63 #endif /* __MCABBER_HOOKS_H__ */ |
576 | 64 |
580 | 65 /* vim: set expandtab cindent cinoptions=>2\:2(0: For Vim users... */ |