Mercurial > ~mikael > mcabber > hg
comparison mcabber/mcabber/hooks.c @ 1787:1f913c92c9b2
Add urgent flag to the hook-message-in hook
Small coding style update, and bump API to v6
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Sun, 14 Mar 2010 17:34:56 +0100 |
parents | 5c043358ded0 |
children | 47699a09ceb3 |
comparison
equal
deleted
inserted
replaced
1786:5311fd93ba7b | 1787:1f913c92c9b2 |
---|---|
68 { | 68 { |
69 hook_list_data_t h = { handler, 0, userdata }; | 69 hook_list_data_t h = { handler, 0, userdata }; |
70 GSList *el = g_slist_find_custom(hk_handler_queue, &h, | 70 GSList *el = g_slist_find_custom(hk_handler_queue, &h, |
71 (GCompareFunc) hk_queue_search_cb); | 71 (GCompareFunc) hk_queue_search_cb); |
72 if (el) { | 72 if (el) { |
73 g_free (el->data); | 73 g_free(el->data); |
74 hk_handler_queue = g_slist_delete_link(hk_handler_queue, el); | 74 hk_handler_queue = g_slist_delete_link(hk_handler_queue, el); |
75 } | 75 } |
76 } | 76 } |
77 #endif | 77 #endif |
78 | 78 |
93 guint rtype = ROSTER_TYPE_USER; | 93 guint rtype = ROSTER_TYPE_USER; |
94 char *wmsg = NULL, *bmsg = NULL, *mmsg = NULL; | 94 char *wmsg = NULL, *bmsg = NULL, *mmsg = NULL; |
95 GSList *roster_usr; | 95 GSList *roster_usr; |
96 unsigned mucnicklen = 0; | 96 unsigned mucnicklen = 0; |
97 const char *ename = NULL; | 97 const char *ename = NULL; |
98 gboolean urgent = FALSE; | |
98 | 99 |
99 if (encrypted == ENCRYPTED_PGP) | 100 if (encrypted == ENCRYPTED_PGP) |
100 message_flags |= HBB_PREFIX_PGPCRYPT; | 101 message_flags |= HBB_PREFIX_PGPCRYPT; |
101 else if (encrypted == ENCRYPTED_OTR) | 102 else if (encrypted == ENCRYPTED_OTR) |
102 message_flags |= HBB_PREFIX_OTRCRYPT; | 103 message_flags |= HBB_PREFIX_OTRCRYPT; |
170 if (nick) { | 171 if (nick) { |
171 // Let's see if we are the message sender, in which case we'll | 172 // Let's see if we are the message sender, in which case we'll |
172 // highlight it. | 173 // highlight it. |
173 if (resname && !strcmp(resname, nick)) { | 174 if (resname && !strcmp(resname, nick)) { |
174 message_flags |= HBB_PREFIX_HLIGHT_OUT; | 175 message_flags |= HBB_PREFIX_HLIGHT_OUT; |
175 } else if (!settings_opt_get_int("muc_disable_nick_hl")) { | 176 } else { |
176 // We're not the sender. Can we see our nick? | 177 // We're not the sender. Can we see our nick? |
177 const char *msgptr = msg; | 178 const char *msgptr = msg; |
178 while ((msgptr = strcasestr(msgptr, nick)) != NULL) { | 179 while ((msgptr = strcasestr(msgptr, nick)) != NULL) { |
179 const char *leftb, *rightb; | 180 const char *leftb, *rightb; |
180 // The message contains our nick. Let's check it's not | 181 // The message contains our nick. Let's check it's not |
189 // Check left boundary | 190 // Check left boundary |
190 if (leftb && (iswalnum(get_char(leftb)) || get_char(leftb) == '_')) | 191 if (leftb && (iswalnum(get_char(leftb)) || get_char(leftb) == '_')) |
191 continue; | 192 continue; |
192 // Check right boundary | 193 // Check right boundary |
193 if (!iswalnum(get_char(rightb)) && get_char(rightb) != '_') | 194 if (!iswalnum(get_char(rightb)) && get_char(rightb) != '_') |
195 urgent = TRUE; | |
196 if (urgent && !settings_opt_get_int("muc_disable_nick_hl")) | |
194 message_flags |= HBB_PREFIX_HLIGHT; | 197 message_flags |= HBB_PREFIX_HLIGHT; |
195 } | 198 } |
196 } | 199 } |
197 } | 200 } |
198 } | 201 } |
243 { "hook", "hook-message-in" }, | 246 { "hook", "hook-message-in" }, |
244 { "jid", bjid }, | 247 { "jid", bjid }, |
245 { "resource", resname }, | 248 { "resource", resname }, |
246 { "message", wmsg }, | 249 { "message", wmsg }, |
247 { "groupchat", is_groupchat ? "true" : "false" }, | 250 { "groupchat", is_groupchat ? "true" : "false" }, |
251 { "urgent", urgent ? "true" : "false" }, | |
248 { NULL, NULL }, | 252 { NULL, NULL }, |
249 }; | 253 }; |
250 while (h) { | 254 while (h) { |
251 hook_list_data_t *data = h->data; | 255 hook_list_data_t *data = h->data; |
252 if (data->flags & HOOK_MESSAGE_IN) | 256 if (data->flags & HOOK_MESSAGE_IN) |
253 (data->handler) (HOOK_MESSAGE_IN, args, data->userdata); | 257 (data->handler) (HOOK_MESSAGE_IN, args, data->userdata); |
254 h = g_slist_next (h); | 258 h = g_slist_next(h); |
255 } | 259 } |
256 } | 260 } |
257 } | 261 } |
258 #endif | 262 #endif |
259 | 263 |
348 }; | 352 }; |
349 while (h) { | 353 while (h) { |
350 hook_list_data_t *data = h->data; | 354 hook_list_data_t *data = h->data; |
351 if (data->flags & HOOK_MESSAGE_OUT) | 355 if (data->flags & HOOK_MESSAGE_OUT) |
352 (data->handler) (HOOK_MESSAGE_OUT, args, data->userdata); | 356 (data->handler) (HOOK_MESSAGE_OUT, args, data->userdata); |
353 h = g_slist_next (h); | 357 h = g_slist_next(h); |
354 } | 358 } |
355 } | 359 } |
356 } | 360 } |
357 #endif | 361 #endif |
358 | 362 |
446 ns[0] = imstatus2char[status]; | 450 ns[0] = imstatus2char[status]; |
447 while (h) { | 451 while (h) { |
448 hook_list_data_t *data = h->data; | 452 hook_list_data_t *data = h->data; |
449 if (data->flags & HOOK_STATUS_CHANGE) | 453 if (data->flags & HOOK_STATUS_CHANGE) |
450 (data->handler) (HOOK_STATUS_CHANGE, args, data->userdata); | 454 (data->handler) (HOOK_STATUS_CHANGE, args, data->userdata); |
451 h = g_slist_next (h); | 455 h = g_slist_next(h); |
452 } | 456 } |
453 } | 457 } |
454 } | 458 } |
455 #endif | 459 #endif |
456 | 460 |
479 ns[0] = imstatus2char[new_status]; | 483 ns[0] = imstatus2char[new_status]; |
480 while (h) { | 484 while (h) { |
481 hook_list_data_t *data = h->data; | 485 hook_list_data_t *data = h->data; |
482 if (data->flags & HOOK_MY_STATUS_CHANGE) | 486 if (data->flags & HOOK_MY_STATUS_CHANGE) |
483 (data->handler) (HOOK_MY_STATUS_CHANGE, args, data->userdata); | 487 (data->handler) (HOOK_MY_STATUS_CHANGE, args, data->userdata); |
484 h = g_slist_next (h); | 488 h = g_slist_next(h); |
485 } | 489 } |
486 } | 490 } |
487 } | 491 } |
488 #endif | 492 #endif |
489 | 493 |
505 }; | 509 }; |
506 while (h) { | 510 while (h) { |
507 hook_list_data_t *data = h->data; | 511 hook_list_data_t *data = h->data; |
508 if (data->flags & HOOK_POST_CONNECT) | 512 if (data->flags & HOOK_POST_CONNECT) |
509 (data->handler) (HOOK_POST_CONNECT, args, data->userdata); | 513 (data->handler) (HOOK_POST_CONNECT, args, data->userdata); |
510 h = g_slist_next (h); | 514 h = g_slist_next(h); |
511 } | 515 } |
512 } | 516 } |
513 } | 517 } |
514 #endif | 518 #endif |
515 | 519 |
541 }; | 545 }; |
542 while (h) { | 546 while (h) { |
543 hook_list_data_t *data = h->data; | 547 hook_list_data_t *data = h->data; |
544 if (data->flags & HOOK_PRE_DISCONNECT) | 548 if (data->flags & HOOK_PRE_DISCONNECT) |
545 (data->handler) (HOOK_PRE_DISCONNECT, args, data->userdata); | 549 (data->handler) (HOOK_PRE_DISCONNECT, args, data->userdata); |
546 h = g_slist_next (h); | 550 h = g_slist_next(h); |
547 } | 551 } |
548 } | 552 } |
549 } | 553 } |
550 #endif | 554 #endif |
551 | 555 |