Mercurial > ~mikael > mcabber > hg
comparison mcabber/src/hooks.c @ 1447:ba706e97d6ec
Add option 'eventcmd_use_nickname'
This is based on a patch from "bebebe".
When this option is set, a nickname is passed to the event script in
place of the JID.
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Fri, 21 Mar 2008 19:49:27 +0100 |
parents | 3bf11085c6a5 |
children | 844410b9b4cc |
comparison
equal
deleted
inserted
replaced
1446:49c8be874344 | 1447:ba706e97d6ec |
---|---|
71 int message_flags = 0; | 71 int message_flags = 0; |
72 guint rtype = ROSTER_TYPE_USER; | 72 guint rtype = ROSTER_TYPE_USER; |
73 char *wmsg = NULL, *bmsg = NULL, *mmsg = NULL; | 73 char *wmsg = NULL, *bmsg = NULL, *mmsg = NULL; |
74 GSList *roster_usr; | 74 GSList *roster_usr; |
75 unsigned mucnicklen = 0; | 75 unsigned mucnicklen = 0; |
76 const char *name = NULL; | |
76 | 77 |
77 if (encrypted) | 78 if (encrypted) |
78 message_flags |= HBB_PREFIX_PGPCRYPT; | 79 message_flags |= HBB_PREFIX_PGPCRYPT; |
79 | 80 |
80 if (type && !strcmp(type, "groupchat")) { | 81 if (type && !strcmp(type, "groupchat")) { |
204 if (cjid && !strcasecmp(cjid, bjid)) | 205 if (cjid && !strcasecmp(cjid, bjid)) |
205 active_window = TRUE; | 206 active_window = TRUE; |
206 } | 207 } |
207 } | 208 } |
208 | 209 |
210 if (settings_opt_get_int("eventcmd_use_nickname")) | |
211 name = roster_getname(bjid); | |
212 | |
209 // External command | 213 // External command |
210 // - We do not call hk_ext_cmd() for history lines in MUC | 214 // - We do not call hk_ext_cmd() for history lines in MUC |
211 // - We do call hk_ext_cmd() for private messages in a room | 215 // - We do call hk_ext_cmd() for private messages in a room |
212 // - We do call hk_ext_cmd() for messages to the current window | 216 // - We do call hk_ext_cmd() for messages to the current window |
213 if (!active_window && ((is_groupchat && !timestamp) || !is_groupchat)) | 217 if (!active_window && ((is_groupchat && !timestamp) || !is_groupchat)) |
214 hk_ext_cmd(bjid, (is_groupchat ? 'G' : 'M'), 'R', wmsg); | 218 hk_ext_cmd(name ? name : bjid, (is_groupchat ? 'G' : 'M'), 'R', wmsg); |
215 | 219 |
216 // Display the sender in the log window | 220 // Display the sender in the log window |
217 if ((!is_groupchat) && !(message_flags & HBB_PREFIX_ERR) && | 221 if ((!is_groupchat) && !(message_flags & HBB_PREFIX_ERR) && |
218 settings_opt_get_int("log_display_sender")) { | 222 settings_opt_get_int("log_display_sender")) { |
219 const char *name = roster_getname(bjid); | |
220 if (!name) name = ""; | 223 if (!name) name = ""; |
221 scr_LogPrint(LPRINT_NORMAL, "Message received from %s <%s/%s>", | 224 scr_LogPrint(LPRINT_NORMAL, "Message received from %s <%s/%s>", |
222 name, bjid, (resname ? resname : "")); | 225 name, bjid, (resname ? resname : "")); |
223 } | 226 } |
224 | 227 |
293 int st_in_buf; | 296 int st_in_buf; |
294 enum imstatus oldstat; | 297 enum imstatus oldstat; |
295 char *bn = NULL; | 298 char *bn = NULL; |
296 char *logsmsg; | 299 char *logsmsg; |
297 const char *rn = (resname ? resname : ""); | 300 const char *rn = (resname ? resname : ""); |
301 const char *name = NULL; | |
302 | |
303 if (settings_opt_get_int("eventcmd_use_nickname")) | |
304 name = roster_getname(bjid); | |
298 | 305 |
299 st_in_buf = settings_opt_get_int("show_status_in_buffer"); | 306 st_in_buf = settings_opt_get_int("show_status_in_buffer"); |
300 buddy_format = settings_opt_get_int("buddy_format"); | 307 buddy_format = settings_opt_get_int("buddy_format"); |
301 if (buddy_format) { | 308 if (buddy_format) { |
302 const char *name = roster_getname(bjid); | |
303 if (name && strcmp(name, bjid)) { | 309 if (name && strcmp(name, bjid)) { |
304 if (buddy_format == 1) | 310 if (buddy_format == 1) |
305 bn = g_strdup_printf("%s <%s/%s>", name, bjid, rn); | 311 bn = g_strdup_printf("%s <%s/%s>", name, bjid, rn); |
306 else if (buddy_format == 2) | 312 else if (buddy_format == 2) |
307 bn = g_strdup_printf("%s/%s", name, rn); | 313 bn = g_strdup_printf("%s/%s", name, rn); |
340 role_none, affil_none, NULL); | 346 role_none, affil_none, NULL); |
341 buddylist_build(); | 347 buddylist_build(); |
342 scr_DrawRoster(); | 348 scr_DrawRoster(); |
343 hlog_write_status(bjid, timestamp, status, status_msg); | 349 hlog_write_status(bjid, timestamp, status, status_msg); |
344 // External command | 350 // External command |
345 hk_ext_cmd(bjid, 'S', imstatus2char[status], NULL); | 351 hk_ext_cmd(name ? name : bjid, 'S', imstatus2char[status], NULL); |
346 } | 352 } |
347 | 353 |
348 void hk_mystatuschange(time_t timestamp, enum imstatus old_status, | 354 void hk_mystatuschange(time_t timestamp, enum imstatus old_status, |
349 enum imstatus new_status, const char *msg) | 355 enum imstatus new_status, const char *msg) |
350 { | 356 { |