Mercurial > ~mikael > mcabber > hg
comparison mcabber/mcabber/hooks.c @ 1906:5d37cee8c6c6
Add "hook-subscription" hook and hk_subscription()
author | Mikael Berthe <mikael@lilotux.net> |
---|---|
date | Sat, 17 Apr 2010 14:03:37 +0200 |
parents | ea3f9b4f3558 |
children | 3cabdacf58df |
comparison
equal
deleted
inserted
replaced
1905:68a4f8dda3e7 | 1906:5d37cee8c6c6 |
---|---|
707 muc_unread, muc_attention); | 707 muc_unread, muc_attention); |
708 hk_ext_cmd("", 'U', (guchar)MIN(255, unread_count), str_unread); | 708 hk_ext_cmd("", 'U', (guchar)MIN(255, unread_count), str_unread); |
709 g_free(str_unread); | 709 g_free(str_unread); |
710 } | 710 } |
711 | 711 |
712 // hk_presence_subscription_request(jid, message) | |
713 // Return non-zero if mcabber should stop processing the subscription request | |
714 guint hk_subscription(LmMessageSubType mstype, const gchar *bjid, | |
715 const gchar *msg) | |
716 { | |
717 #ifdef MODULES_ENABLE | |
718 guint h_result; | |
719 const char *stype; | |
720 | |
721 if (mstype == LM_MESSAGE_SUB_TYPE_SUBSCRIBE) | |
722 stype = "subscribe"; | |
723 else if (mstype == LM_MESSAGE_SUB_TYPE_UNSUBSCRIBE) | |
724 stype = "unsubscribe"; | |
725 else if (mstype == LM_MESSAGE_SUB_TYPE_SUBSCRIBED) | |
726 stype = "subscribed"; | |
727 else if (mstype == LM_MESSAGE_SUB_TYPE_UNSUBSCRIBED) | |
728 stype = "unsubscribed"; | |
729 else return 0; // Should not happen | |
730 | |
731 { | |
732 hk_arg_t args[] = { | |
733 { "type", stype }, | |
734 { "jid", bjid }, | |
735 { "message", msg ? msg : "" }, | |
736 { NULL, NULL }, | |
737 }; | |
738 h_result = hk_run_handlers(HOOK_SUBSCRIPTION, args); | |
739 } | |
740 if (h_result != HOOK_HANDLER_RESULT_ALLOW_MORE_HANDLERS) { | |
741 scr_LogPrint(LPRINT_DEBUG, "Subscription message ignored (hook result)."); | |
742 return h_result; | |
743 } | |
744 #endif | |
745 return 0; | |
746 } | |
747 | |
712 | 748 |
713 /* External commands */ | 749 /* External commands */ |
714 | 750 |
715 // hk_ext_cmd_init() | 751 // hk_ext_cmd_init() |
716 // Initialize external command variable. | 752 // Initialize external command variable. |