comparison mcabber/src/otr.c @ 1470:a8b924b5474c

The OTR protocol expects (X)HTML messsages
author Mikael Berthe <mikael@lilotux.net>
date Sun, 13 Apr 2008 13:01:32 +0200
parents 08f641e91f94
children 6f5754f86fbb
comparison
equal deleted inserted replaced
1469:1f7990dd416b 1470:a8b924b5474c
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19 * USA 19 * USA
20 */ 20 */
21 21
22 #include <config.h> 22 #include <config.h>
23 #include <glib.h>
23 24
24 #ifdef HAVE_LIBOTR 25 #ifdef HAVE_LIBOTR
25 26
26 #include "otr.h" 27 #include "otr.h"
27 #include "logprint.h" 28 #include "logprint.h"
29 #include "jab_priv.h" 30 #include "jab_priv.h"
30 #include "roster.h" 31 #include "roster.h"
31 #include "utils.h" 32 #include "utils.h"
32 #include "screen.h" 33 #include "screen.h"
33 #include "settings.h" 34 #include "settings.h"
35 #include "nohtml.h"
34 36
35 37
36 static OtrlUserState userstate = NULL; 38 static OtrlUserState userstate = NULL;
37 static char * account = NULL; 39 static char * account = NULL;
38 static char * keyfile = NULL; 40 static char * keyfile = NULL;
377 if (ignore_message) 379 if (ignore_message)
378 *otr_data = NULL; 380 *otr_data = NULL;
379 381
380 if (!ignore_message && newmessage) { 382 if (!ignore_message && newmessage) {
381 *free_msg = 1; 383 *free_msg = 1;
382 *otr_data = g_strdup(newmessage); 384 *otr_data = html_strip(newmessage);
383 otrl_message_free(newmessage); 385 otrl_message_free(newmessage);
384 if (ctx->msgstate == OTRL_MSGSTATE_ENCRYPTED) 386 if (ctx->msgstate == OTRL_MSGSTATE_ENCRYPTED)
385 return 1; 387 return 1;
386 } 388 }
387 return 0; 389 return 0;
389 391
390 int otr_send(char **msg, const char *buddy) 392 int otr_send(char **msg, const char *buddy)
391 { 393 {
392 gcry_error_t err; 394 gcry_error_t err;
393 char *newmessage = NULL; 395 char *newmessage = NULL;
396 char *htmlmsg;
394 ConnContext * ctx = otr_get_context(buddy); 397 ConnContext * ctx = otr_get_context(buddy);
395 398
399 htmlmsg = html_escape(*msg);
400
396 err = otrl_message_sending(userstate, &ops, NULL, account, "jabber", buddy, 401 err = otrl_message_sending(userstate, &ops, NULL, account, "jabber", buddy,
397 *msg, NULL, &newmessage, NULL, NULL); 402 htmlmsg, NULL, &newmessage, NULL, NULL);
403
404 g_free(htmlmsg);
398 405
399 if (err) 406 if (err)
400 *msg = NULL; /*something went wrong, don't send the plain-message! */ 407 *msg = NULL; /*something went wrong, don't send the plain-message! */
401 408
402 if (!err && newmessage) { 409 if (!err && newmessage) {
653 * callback. */ 660 * callback. */
654 static int cb_display_otr_message(void *opdata, const char *accountname, 661 static int cb_display_otr_message(void *opdata, const char *accountname,
655 const char *protocol, const char *username, 662 const char *protocol, const char *username,
656 const char *msg) 663 const char *msg)
657 { 664 {
658 scr_WriteIncomingMessage(username, msg, 0, HBB_PREFIX_INFO, 0); 665 char *strippedmsg = html_strip(msg);
666 scr_WriteIncomingMessage(username, strippedmsg, 0, HBB_PREFIX_INFO, 0);
667 g_free(strippedmsg);
659 return 0; 668 return 0;
660 } 669 }
661 670
662 /* When the list of ConnContexts changes (including a change in 671 /* When the list of ConnContexts changes (including a change in
663 * state), this is called so the UI can be updated. */ 672 * state), this is called so the UI can be updated. */