Mercurial > ~mikael > mcabber > hg
comparison mcabber/mcabber/xmpp.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 | 68a4f8dda3e7 |
children | e2def760c6d0 |
comparison
equal
deleted
inserted
replaced
1905:68a4f8dda3e7 | 1906:5d37cee8c6c6 |
---|---|
1519 LmMessage *m, gpointer user_data) | 1519 LmMessage *m, gpointer user_data) |
1520 { | 1520 { |
1521 char *r; | 1521 char *r; |
1522 char *buf; | 1522 char *buf; |
1523 int newbuddy; | 1523 int newbuddy; |
1524 LmMessageSubType mstype; | |
1525 guint hook_result; | |
1524 const char *from = lm_message_get_from(m); | 1526 const char *from = lm_message_get_from(m); |
1525 LmMessageSubType mstype; | 1527 const char *msg = lm_message_node_get_child_value(m->node, "status"); |
1526 | 1528 |
1527 r = jidtodisp(from); | 1529 r = jidtodisp(from); |
1528 | 1530 |
1529 newbuddy = !roster_find(r, jidsearch, 0); | 1531 newbuddy = !roster_find(r, jidsearch, 0); |
1530 mstype = lm_message_get_sub_type(m); | 1532 mstype = lm_message_get_sub_type(m); |
1531 | 1533 |
1534 hook_result = hk_subscription(mstype, r, msg); | |
1535 | |
1532 if (mstype == LM_MESSAGE_SUB_TYPE_SUBSCRIBE) { | 1536 if (mstype == LM_MESSAGE_SUB_TYPE_SUBSCRIBE) { |
1533 /* The sender wishes to subscribe to our presence */ | 1537 /* The sender wishes to subscribe to our presence */ |
1534 const char *msg; | 1538 |
1535 | 1539 if (hook_result) { |
1536 msg = lm_message_node_get_child_value(m->node, "status"); | 1540 g_free(r); |
1541 return LM_HANDLER_RESULT_REMOVE_MESSAGE; | |
1542 } | |
1537 | 1543 |
1538 buf = g_strdup_printf("<%s> wants to subscribe to your presence updates", | 1544 buf = g_strdup_printf("<%s> wants to subscribe to your presence updates", |
1539 from); | 1545 from); |
1540 scr_WriteIncomingMessage(r, buf, 0, HBB_PREFIX_INFO, 0); | 1546 scr_WriteIncomingMessage(r, buf, 0, HBB_PREFIX_INFO, 0); |
1541 scr_LogPrint(LPRINT_LOGNORM, "%s", buf); | 1547 scr_LogPrint(LPRINT_LOGNORM, "%s", buf); |