[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    KDE/kdenetwork/kopete/plugins/otr
From:       Michael Zanetti <michael_zanetti () gmx ! net>
Date:       2009-01-31 23:31:53
Message-ID: 1233444713.284032.7067.nullmailer () svn ! kde ! org
[Download RAW message or body]

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("<br>") );
+			return 0; // message is decrypted and ready to deliver
 		} else {
-			msg->replace( QString('<'), QString("&lt;") );
+			return 1; // message was a plaintext message. Better not touching it :)
 		}
-		msg->replace( QString('\n'), QString("<br>") );
 	}
-	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() ) ){


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic