Mercurial > hg
comparison mcabber/doc/HOWTO_modules.txt @ 1624:a75611931642
Hook handler flags updates to howto
author | Myhailo Danylenko <isbear@ukrpost.net> |
---|---|
date | Thu, 15 Oct 2009 12:50:54 +0300 |
parents | 2a82e6654c04 |
children | e3b93594ee6c |
comparison
equal
deleted
inserted
replaced
1623:b008ac166b91 | 1624:a75611931642 |
---|---|
89 typedef struct { | 89 typedef struct { |
90 const char *name; | 90 const char *name; |
91 const char *value; | 91 const char *value; |
92 } hk_arg_t; | 92 } hk_arg_t; |
93 | 93 |
94 typedef void (*hk_handler_t) (hk_arg_t *args, | 94 typedef void (*hk_handler_t) (guint32 hookid, |
95 hk_arg_t *args, | |
95 gpointer userdata); | 96 gpointer userdata); |
96 | 97 |
97 void hk_add_handler (hk_handler_t handler, | 98 void hk_add_handler (hk_handler_t handler, |
99 guint32 flags, | |
98 gpointer userdata); | 100 gpointer userdata); |
99 void hk_del_handler (hk_handler_t handler, | 101 void hk_del_handler (hk_handler_t handler, |
100 gpointer userdata); | 102 gpointer userdata); |
101 -------------------------------------------------------- | 103 -------------------------------------------------------- |
102 | 104 |
103 These functions allow your module to react to events, | 105 These functions allow your module to react to events, |
104 such as incoming and outgoing messages, buddy status | 106 such as incoming and outgoing messages, buddy status |
105 changes and sever connection establishment or breakup. | 107 changes and sever connection establishment or breakup. |
106 In fact, you specify only one handler (well, you can | 108 Flags field specifies mask of events, upon which this |
107 specify as many, as you want, but they all will be | 109 handler should be called. Flags, that comprise this |
108 called on any event, that will occur). Which event is | 110 mask can be found in hooks.h. You can specify not yet |
109 occured can be determined from args, which is a list of | 111 used flags in mask, if you need to handle all events. |
110 hk_arg_t structures, terminated with structure, whose | 112 Handler can determine, which event is occured by |
111 name field is set to NULL. Event type is specified in | 113 hookid argument and by a "hook" field in args, that |
112 the structure with name set to "hook". Usually this is | 114 may provide more precise information in some cases. |
113 the first structure of the list, however it is not | 115 Args argument is a list of hk_arg_t structures, |
114 guaranted, that this will be so forever. | 116 terminated by structure, whose name field is set to |
117 NULL. Usually the "hook" field is in the first | |
118 structure of the list, however it is not guaranted, | |
119 that this will be so forever. | |
115 | 120 |
116 Currently there are next events possible: | 121 Currently there are next events possible: |
117 - hook-message-in with parameters | 122 - hook-message-in (HOOK_MESSAGE_IN) with parameters |
118 * jid - sender of the incoming message | 123 * jid - sender of the incoming message |
119 * message - message body, converted to locale | 124 * message - message body, converted to locale |
120 charset | 125 charset |
121 * groupchat ("true" or "false") | 126 * groupchat ("true" or "false") |
122 - hook-message-out with parameters | 127 - hook-message-out (HOOK_MESSAGE_OUT) with parameters |
123 * jid - recipient of the outgoing message | 128 * jid - recipient of the outgoing message |
124 * message - message body, converted to locale | 129 * message - message body, converted to locale |
125 charset | 130 charset |
126 - hook-status-change wih parameters | 131 - hook-status-change (HOOK_STATUS_CHANGE) with |
132 parameters | |
127 * jid - buddy, whose status has changed | 133 * jid - buddy, whose status has changed |
128 * resource - resource, whose status has changed | 134 * resource - resource, whose status has changed |
129 * old_status - old status of the buddy, one-char | 135 * old_status - old status of the buddy, one-char |
130 string, representing mcabber status letter - | 136 string, representing mcabber status letter - |
131 one of 'ofdna?_'. | 137 one of 'ofdna?_'. |
132 * new_status - new buddy status. The same as | 138 * new_status - new buddy status. The same as |
133 old_status. | 139 old_status. |
134 * message - new status message. Old one should be | 140 * message - new status message. Old one should be |
135 still available to module as the current buddy's | 141 still available to module as the current buddy's |
136 message. | 142 message. |
137 - hook-my-status-change with parameters | 143 - hook-my-status-change (HOOK_MY_STATUS_CHANGE) with |
144 parameters | |
138 * new_status - user's new status, see | 145 * new_status - user's new status, see |
139 hook-status-change. Old one should still be | 146 hook-status-change. Old one should still be |
140 available as the current status of the user. | 147 available as the current status of the user. |
141 * message - new status message | 148 * message - new status message |
142 - hook-post-connect with no parameters | 149 - hook-post-connect (HOOK_INTERNAL) with no parameters |
143 - hook-pre-disconnect with no parameters | 150 - hook-pre-disconnect (HOOK_INTERNAL) with no |
144 | 151 parameters |
152 | |
153 -------------------------------------------------------- | |
145 #include "xmpp_helper.h" | 154 #include "xmpp_helper.h" |
146 | 155 |
147 void xmpp_add_feature (const char *xmlns); | 156 void xmpp_add_feature (const char *xmlns); |
148 void xmpp_del_feature (const char *xmlns); | 157 void xmpp_del_feature (const char *xmlns); |
158 -------------------------------------------------------- | |
149 | 159 |
150 These functions may be useful, if your module implements | 160 These functions may be useful, if your module implements |
151 some additional functionality to mcabber, that should be | 161 some additional functionality to mcabber, that should be |
152 advertised in a client's discovery features list. | 162 advertised in a client's discovery features list. |
153 | 163 |
365 #include "settings.h" | 375 #include "settings.h" |
366 | 376 |
367 static guint beep_cid = 0; | 377 static guint beep_cid = 0; |
368 | 378 |
369 /* Event handler */ | 379 /* Event handler */ |
370 void beep_hh (hk_arg_t *args, gpointer userdata) | 380 void beep_hh (guint32 hid, hk_arg_t *args, gpointer userdata) |
371 { | 381 { |
372 /* We are interested only in incoming | 382 /* Check if beeping is enabled */ |
373 * message events */ | 383 if (settings_opt_get_int ("beep_enable")) |
374 if (!strcmp (args[0].value, "hook-message-in")) | 384 /* *BEEP*! */ |
375 /* Check if beeping is enabled */ | 385 scr_Beep (); |
376 if (settings_opt_get_int ("beep_enable")) | |
377 /* *BEEP*! */ | |
378 scr_Beep (); | |
379 } | 386 } |
380 | 387 |
381 /* beep command handler */ | 388 /* beep command handler */ |
382 void do_beep (char *args) | 389 void do_beep (char *args) |
383 { | 390 { |
415 compl_add_category_word (beep_cid, "enable"); | 422 compl_add_category_word (beep_cid, "enable"); |
416 compl_add_category_word (beep_cid, "disable"); | 423 compl_add_category_word (beep_cid, "disable"); |
417 } | 424 } |
418 /* Add command */ | 425 /* Add command */ |
419 cmd_add ("beep", "", beep_cid, 0, do_beep, NULL); | 426 cmd_add ("beep", "", beep_cid, 0, do_beep, NULL); |
420 /* Add handler */ | 427 /* Add handler |
421 hk_add_handler (beep_hh, NULL); | 428 * We are only interested in incoming message events |
429 */ | |
430 hk_add_handler (beep_hh, HOOK_MESSAGE_IN, NULL); | |
422 return NULL; | 431 return NULL; |
423 } | 432 } |
424 | 433 |
425 /* Deinitialization */ | 434 /* Deinitialization */ |
426 void g_module_unload (GModule *module) | 435 void g_module_unload (GModule *module) |