From kde-commits Sat Jan 31 23:31:53 2009 From: Michael Zanetti Date: Sat, 31 Jan 2009 23:31:53 +0000 To: kde-commits Subject: KDE/kdenetwork/kopete/plugins/otr Message-Id: <1233444713.284032.7067.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=123344472314441 SVN commit 919430 by mzanetti: Do not alter plaintext messages. BUG: 182114 M +4 -3 otrlchatinterface.cpp M +7 -2 otrplugin.cpp --- trunk/KDE/kdenetwork/kopete/plugins/otr/otrlchatinterface.cpp #919429:919430 @@ -522,12 +522,13 @@ if( newMessage != NULL ){ *msg = QString::fromUtf8(newMessage); otrl_message_free( newMessage ); + msg->replace( QString('\n'), QString("
") ); + return 0; // message is decrypted and ready to deliver } else { - msg->replace( QString('<'), QString("<") ); + return 1; // message was a plaintext message. Better not touching it :) } - msg->replace( QString('\n'), QString("
") ); } - return ignoremessage; + return 2; // internal OTR message. Ignore it. } KDE_EXPORT QString *OtrlChatInterface::encryptMessage( QString *msg, const QString &accountId, --- trunk/KDE/kdenetwork/kopete/plugins/otr/otrplugin.cpp #919429:919430 @@ -243,11 +243,16 @@ QString body = msg.plainBody(); QString accountId = msg.manager()->account()->accountId(); QString contactId = msg.from()->contactId(); - int ignoremessage = OtrlChatInterface::self()->decryptMessage( &body, accountId, msg.manager()->account()->protocol()->displayName(), contactId, msg.manager() ); + int retValue = OtrlChatInterface::self()->decryptMessage( &body, accountId, msg.manager()->account()->protocol()->displayName(), contactId, msg.manager() ); msg.setHtmlBody( body ); - if( ignoremessage | OtrlChatInterface::self()->shouldDiscard( msg.plainBody() ) ){ + if( retValue == 2 | OtrlChatInterface::self()->shouldDiscard( msg.plainBody() ) ){ + // internal OTR message event->discard(); return; + } else if(retValue == 1){ + // plaintext message. Proceed with next plugin + MessageHandler::handleMessage( event ); + return; } } else if( msg.direction() == Kopete::Message::Outbound ){ if( messageCache.contains( msg.plainBody() ) ){