Mercurial > ~mikael > mcabber > hg
comparison mcabber/mcabber/xmpp.c @ 1685:1342df44c814
Improved events interface
* User can pass additional arguments to event handler
* MUC invitation reject now can be supplied a reason
author | Myhailo Danylenko <isbear@ukrpost.net> |
---|---|
date | Tue, 02 Feb 2010 22:44:18 +0100 |
parents | 95df4ea512c8 |
children | 51481414ca65 |
comparison
equal
deleted
inserted
replaced
1684:95df4ea512c8 | 1685:1342df44c814 |
---|---|
1471 mstype = lm_message_get_sub_type(m); | 1471 mstype = lm_message_get_sub_type(m); |
1472 | 1472 |
1473 if (mstype == LM_MESSAGE_SUB_TYPE_SUBSCRIBE) { | 1473 if (mstype == LM_MESSAGE_SUB_TYPE_SUBSCRIBE) { |
1474 /* The sender wishes to subscribe to our presence */ | 1474 /* The sender wishes to subscribe to our presence */ |
1475 const char *msg; | 1475 const char *msg; |
1476 eviqs *evn; | |
1477 | 1476 |
1478 msg = lm_message_node_get_child_value(m->node, "status"); | 1477 msg = lm_message_node_get_child_value(m->node, "status"); |
1479 | 1478 |
1480 buf = g_strdup_printf("<%s> wants to subscribe to your presence updates", | 1479 buf = g_strdup_printf("<%s> wants to subscribe to your presence updates", |
1481 from); | 1480 from); |
1490 scr_LogPrint(LPRINT_LOGNORM, "%s", buf); | 1489 scr_LogPrint(LPRINT_LOGNORM, "%s", buf); |
1491 g_free(buf); | 1490 g_free(buf); |
1492 } | 1491 } |
1493 | 1492 |
1494 // Create a new event item | 1493 // Create a new event item |
1495 evn = evs_new(EVS_TYPE_SUBSCRIPTION, EVS_MAX_TIMEOUT); | 1494 { |
1496 if (evn) { | 1495 const char *id; |
1497 evn->callback = &evscallback_subscription; | 1496 char *desc = g_strdup_printf("<%s> wants to subscribe to your " |
1498 evn->data = g_strdup(r); | 1497 "presence updates", r); |
1499 evn->desc = g_strdup_printf("<%s> wants to subscribe to your " | 1498 |
1500 "presence updates", r); | 1499 id = evs_new(desc, NULL, 0, evscallback_subscription, g_strdup(r), |
1501 buf = g_strdup_printf("Please use /event %s accept|reject", evn->id); | 1500 (GDestroyNotify)g_free); |
1502 } else { | 1501 g_free(desc); |
1503 buf = g_strdup_printf("Unable to create a new event!"); | 1502 if (id) |
1503 buf = g_strdup_printf("Please use /event %s accept|reject", id); | |
1504 else | |
1505 buf = g_strdup_printf("Unable to create a new event!"); | |
1504 } | 1506 } |
1505 scr_WriteIncomingMessage(r, buf, 0, HBB_PREFIX_INFO, 0); | 1507 scr_WriteIncomingMessage(r, buf, 0, HBB_PREFIX_INFO, 0); |
1506 scr_LogPrint(LPRINT_LOGNORM, "%s", buf); | 1508 scr_LogPrint(LPRINT_LOGNORM, "%s", buf); |
1507 g_free(buf); | 1509 g_free(buf); |
1508 } else if (mstype == LM_MESSAGE_SUB_TYPE_UNSUBSCRIBE) { | 1510 } else if (mstype == LM_MESSAGE_SUB_TYPE_UNSUBSCRIBE) { |