comparison mcabber/src/jabglue.c @ 1050:ea71d31a2607

PGP: Do not sign presence messages to chatrooms We do not sign auto-away messages either.
author Mikael Berthe <mikael@lilotux.net>
date Sun, 26 Nov 2006 20:24:34 +0100
parents a3748bd3d010
children c8a8edd5c50d
comparison
equal deleted inserted replaced
1049:ad5de4d1ee56 1050:ea71d31a2607
134 { 134 {
135 if (!jc) return; 135 if (!jc) return;
136 136
137 if (online) { 137 if (online) {
138 // Announce it to everyone else 138 // Announce it to everyone else
139 jb_setstatus(offline, NULL, ""); 139 jb_setstatus(offline, NULL, "", FALSE);
140 // End the XML flow 140 // End the XML flow
141 jb_send_raw("</stream:stream>"); 141 jb_send_raw("</stream:stream>");
142 /* 142 /*
143 // Free status message 143 // Free status message
144 g_free(mystatusmsg); 144 g_free(mystatusmsg);
335 if (!jid) return; 335 if (!jid) return;
336 nickname = buddy_getnickname(room); 336 nickname = buddy_getnickname(room);
337 if (!nickname) return; 337 if (!nickname) return;
338 338
339 to = g_strdup_printf("%s/%s", jid, nickname); 339 to = g_strdup_printf("%s/%s", jid, nickname);
340 jb_setstatus(pres->st, to, pres->msg); 340 jb_setstatus(pres->st, to, pres->msg, TRUE);
341 g_free(to); 341 g_free(to);
342 } 342 }
343 343
344 // presnew(status, recipient, message) 344 // presnew(status, recipient, message)
345 // Create an xmlnode with default presence attributes 345 // Create an xmlnode with default presence attributes
401 xmlnode_insert_cdata(xmlnode_insert_tag(x, "status"), msg, (unsigned) -1); 401 xmlnode_insert_cdata(xmlnode_insert_tag(x, "status"), msg, (unsigned) -1);
402 402
403 return x; 403 return x;
404 } 404 }
405 405
406 void jb_setstatus(enum imstatus st, const char *recipient, const char *msg) 406 void jb_setstatus(enum imstatus st, const char *recipient, const char *msg,
407 int do_not_sign)
407 { 408 {
408 xmlnode x; 409 xmlnode x;
409 410
410 if (msg) { 411 if (msg) {
411 // The status message has been specified. We'll use it, unless it is 412 // The status message has been specified. We'll use it, unless it is
431 // in order to avoid some problems during network failures) 432 // in order to avoid some problems during network failures)
432 if (online) { 433 if (online) {
433 const char *s_msg = (st != invisible ? msg : NULL); 434 const char *s_msg = (st != invisible ? msg : NULL);
434 x = presnew(st, recipient, s_msg); 435 x = presnew(st, recipient, s_msg);
435 #ifdef HAVE_GPGME 436 #ifdef HAVE_GPGME
436 if (s_msg && *s_msg && gpg_enabled()) { 437 if (!do_not_sign && s_msg && *s_msg && gpg_enabled()) {
437 char *signature = gpg_sign(s_msg); 438 char *signature = gpg_sign(s_msg);
438 if (signature) { 439 if (signature) {
439 xmlnode y; 440 xmlnode y;
440 y = xmlnode_insert_tag(x, "x"); 441 y = xmlnode_insert_tag(x, "x");
441 xmlnode_put_attrib(y, "xmlns", NS_SIGNED); 442 xmlnode_put_attrib(y, "xmlns", NS_SIGNED);
486 487
487 // jb_setprevstatus() 488 // jb_setprevstatus()
488 // Set previous status. This wrapper function is used after a disconnection. 489 // Set previous status. This wrapper function is used after a disconnection.
489 inline void jb_setprevstatus(void) 490 inline void jb_setprevstatus(void)
490 { 491 {
491 jb_setstatus(mywantedstatus, NULL, mystatusmsg); 492 jb_setstatus(mywantedstatus, NULL, mystatusmsg, FALSE);
492 } 493 }
493 494
494 // new_msgid() 495 // new_msgid()
495 // Generate a new id string. The caller should free it. 496 // Generate a new id string. The caller should free it.
496 static char *new_msgid(void) 497 static char *new_msgid(void)
1523 scr_LogPrint(LPRINT_LOGNORM, "%s", mbuf); 1524 scr_LogPrint(LPRINT_LOGNORM, "%s", mbuf);
1524 scr_WriteIncomingMessage(jid, mbuf, 0, HBB_PREFIX_INFO); 1525 scr_WriteIncomingMessage(jid, mbuf, 0, HBB_PREFIX_INFO);
1525 g_free(mbuf); 1526 g_free(mbuf);
1526 1527
1527 // Send back an unavailable packet 1528 // Send back an unavailable packet
1528 jb_setstatus(offline, jid, ""); 1529 jb_setstatus(offline, jid, "", TRUE);
1529 1530
1530 // MUC 1531 // MUC
1531 // Make sure this is a room (it can be a conversion user->room) 1532 // Make sure this is a room (it can be a conversion user->room)
1532 room_elt = roster_find(jid, jidsearch, 0); 1533 room_elt = roster_find(jid, jidsearch, 0);
1533 if (!room_elt) { 1534 if (!room_elt) {
1802 1803
1803 scr_LogPrint(LPRINT_LOGNORM, "%s", mbuf); 1804 scr_LogPrint(LPRINT_LOGNORM, "%s", mbuf);
1804 scr_WriteIncomingMessage(roomjid, mbuf, 0, HBB_PREFIX_INFO); 1805 scr_WriteIncomingMessage(roomjid, mbuf, 0, HBB_PREFIX_INFO);
1805 g_free(mbuf); 1806 g_free(mbuf);
1806 // Send back an unavailable packet 1807 // Send back an unavailable packet
1807 jb_setstatus(offline, roomjid, ""); 1808 jb_setstatus(offline, roomjid, "", TRUE);
1808 scr_DrawRoster(); 1809 scr_DrawRoster();
1809 return; 1810 return;
1810 } 1811 }
1811 1812
1812 // Get the status code 1813 // Get the status code