equal
deleted
inserted
replaced
504 srand(now); |
504 srand(now); |
505 msg_idn += 1U + (unsigned int) (9.0 * (rand() / (RAND_MAX + 1.0))); |
505 msg_idn += 1U + (unsigned int) (9.0 * (rand() / (RAND_MAX + 1.0))); |
506 return g_strdup_printf("%u%d", msg_idn, (int)(now%10L)); |
506 return g_strdup_printf("%u%d", msg_idn, (int)(now%10L)); |
507 } |
507 } |
508 |
508 |
|
509 // jb_send_msg(jid, test, type, subject, msgid, *encrypted) |
|
510 // When encrypted is not NULL, the function set *encrypted to TRUE if the |
|
511 // message has been PGP-encrypted. |
509 void jb_send_msg(const char *jid, const char *text, int type, |
512 void jb_send_msg(const char *jid, const char *text, int type, |
510 const char *subject, const char *msgid) |
513 const char *subject, const char *msgid, guint *encrypted) |
511 { |
514 { |
512 xmlnode x; |
515 xmlnode x; |
513 gchar *strtype; |
516 gchar *strtype; |
514 #if defined HAVE_GPGME || defined JEP0022 || defined JEP0085 |
517 #if defined HAVE_GPGME || defined JEP0022 || defined JEP0085 |
515 char *rname, *barejid; |
518 char *rname, *barejid; |
520 guint use_jep85 = 0; |
523 guint use_jep85 = 0; |
521 struct jep0085 *jep85 = NULL; |
524 struct jep0085 *jep85 = NULL; |
522 #endif |
525 #endif |
523 gchar *enc = NULL; |
526 gchar *enc = NULL; |
524 |
527 |
|
528 if (encrypted) |
|
529 *encrypted = FALSE; |
|
530 |
525 if (!online) return; |
531 if (!online) return; |
526 |
532 |
527 if (type == ROSTER_TYPE_ROOM) |
533 if (type == ROSTER_TYPE_ROOM) |
528 strtype = TMSG_GROUPCHAT; |
534 strtype = TMSG_GROUPCHAT; |
529 else |
535 else |
560 if (enc) { |
566 if (enc) { |
561 xmlnode y; |
567 xmlnode y; |
562 y = xmlnode_insert_tag(x, "x"); |
568 y = xmlnode_insert_tag(x, "x"); |
563 xmlnode_put_attrib(y, "xmlns", NS_ENCRYPTED); |
569 xmlnode_put_attrib(y, "xmlns", NS_ENCRYPTED); |
564 xmlnode_insert_cdata(y, enc, (unsigned) -1); |
570 xmlnode_insert_cdata(y, enc, (unsigned) -1); |
|
571 if (encrypted) |
|
572 *encrypted = TRUE; |
565 g_free(enc); |
573 g_free(enc); |
566 } |
574 } |
567 |
575 |
568 #if defined JEP0022 || defined JEP0085 |
576 #if defined JEP0022 || defined JEP0085 |
569 // If typing notifications are disabled, we can skip all this stuff... |
577 // If typing notifications are disabled, we can skip all this stuff... |
1544 // System messages (from our server) are allowed. |
1552 // System messages (from our server) are allowed. |
1545 if (!settings_opt_get_int("block_unsubscribed") || |
1553 if (!settings_opt_get_int("block_unsubscribed") || |
1546 (roster_getsubscription(jid) & sub_from) || |
1554 (roster_getsubscription(jid) & sub_from) || |
1547 (type && strcmp(type, "chat")) || |
1555 (type && strcmp(type, "chat")) || |
1548 ((s = settings_opt_get("server")) != NULL && !strcasecmp(jid, s))) { |
1556 ((s = settings_opt_get("server")) != NULL && !strcasecmp(jid, s))) { |
1549 hk_message_in(jid, rname, timestamp, body, type); |
1557 hk_message_in(jid, rname, timestamp, body, type, |
|
1558 (decrypted ? TRUE : FALSE)); |
1550 } else { |
1559 } else { |
1551 scr_LogPrint(LPRINT_LOGNORM, "Blocked a message from <%s>", jid); |
1560 scr_LogPrint(LPRINT_LOGNORM, "Blocked a message from <%s>", jid); |
1552 } |
1561 } |
1553 g_free(jid); |
1562 g_free(jid); |
1554 g_free(decrypted); |
1563 g_free(decrypted); |