427 |
428 |
428 // Only send the packet if we're online. |
429 // Only send the packet if we're online. |
429 // (But we want to update internal status even when disconnected, |
430 // (But we want to update internal status even when disconnected, |
430 // in order to avoid some problems during network failures) |
431 // in order to avoid some problems during network failures) |
431 if (online) { |
432 if (online) { |
432 x = presnew(st, recipient, (st != invisible ? msg : NULL)); |
433 const char *s_msg = (st != invisible ? msg : NULL); |
|
434 x = presnew(st, recipient, s_msg); |
|
435 #ifdef HAVE_GPGME |
|
436 if (s_msg && *s_msg && gpg_enabled()) { |
|
437 char *signature = gpg_sign(s_msg); |
|
438 if (signature) { |
|
439 xmlnode y; |
|
440 y = xmlnode_insert_tag(x, "x"); |
|
441 xmlnode_put_attrib(y, "xmlns", NS_SIGNED); |
|
442 xmlnode_insert_cdata(y, signature, (unsigned) -1); |
|
443 g_free(signature); |
|
444 } |
|
445 } |
|
446 #endif |
433 jab_send(jc, x); |
447 jab_send(jc, x); |
434 xmlnode_free(x); |
448 xmlnode_free(x); |
435 } |
449 } |
436 |
450 |
437 // If we didn't change our _global_ status, we are done |
451 // If we didn't change our _global_ status, we are done |
1391 static void gotmessage(char *type, const char *from, const char *body, |
1405 static void gotmessage(char *type, const char *from, const char *body, |
1392 const char *enc, time_t timestamp) |
1406 const char *enc, time_t timestamp) |
1393 { |
1407 { |
1394 char *jid; |
1408 char *jid; |
1395 const char *rname, *s; |
1409 const char *rname, *s; |
|
1410 char *decrypted = NULL; |
1396 |
1411 |
1397 jid = jidtodisp(from); |
1412 jid = jidtodisp(from); |
1398 |
1413 |
1399 rname = strchr(from, JID_RESOURCE_SEPARATOR); |
1414 rname = strchr(from, JID_RESOURCE_SEPARATOR); |
1400 if (rname) rname++; |
1415 if (rname) rname++; |
|
1416 |
|
1417 #ifdef HAVE_GPGME |
|
1418 if (enc && gpg_enabled()) { |
|
1419 decrypted = gpg_decrypt(enc); |
|
1420 if (decrypted) |
|
1421 body = decrypted; |
|
1422 } |
|
1423 #endif |
1401 |
1424 |
1402 // Check for unexpected groupchat messages |
1425 // Check for unexpected groupchat messages |
1403 // If we receive a groupchat message from a room we're not a member of, |
1426 // If we receive a groupchat message from a room we're not a member of, |
1404 // this is probably a server issue and the best we can do is to send |
1427 // this is probably a server issue and the best we can do is to send |
1405 // a type unavailable. |
1428 // a type unavailable. |
1442 hk_message_in(jid, rname, timestamp, body, type); |
1466 hk_message_in(jid, rname, timestamp, body, type); |
1443 } else { |
1467 } else { |
1444 scr_LogPrint(LPRINT_LOGNORM, "Blocked a message from <%s>", jid); |
1468 scr_LogPrint(LPRINT_LOGNORM, "Blocked a message from <%s>", jid); |
1445 } |
1469 } |
1446 g_free(jid); |
1470 g_free(jid); |
|
1471 g_free(decrypted); |
1447 } |
1472 } |
1448 |
1473 |
1449 static const char *defaulterrormsg(int code) |
1474 static const char *defaulterrormsg(int code) |
1450 { |
1475 { |
1451 const char *desc; |
1476 const char *desc; |