[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-02-03 18:46:10
Message-ID: 1233686770.457450.30711.nullmailer () svn ! kde ! org
[Download RAW message or body]

SVN commit 920758 by mzanetti:

don't loose messages in a finished OTR session
BUG: 182121


 M  +1 -1      otrlchatinterface.cpp  
 M  +11 -3     otrplugin.cpp  


--- trunk/KDE/kdenetwork/kopete/plugins/otr/otrlchatinterface.cpp #920757:920758
@@ -549,7 +549,7 @@
 			/* If fragmentation is needed libotr will send out all fragments but the last \
one. */  ConnContext *context = otrl_context_find(userstate, contactId.toLocal8Bit(), \
accountId.toLocal8Bit(), protocol.toLocal8Bit(), 0, NULL, NULL, NULL);  
-			kDebug(14318) << "message to be sent out: " << newMessage;
+			//kDebug(14318) << "message to be sent out: " << newMessage;
 
 			err = otrl_message_fragment_and_send(&ui_ops, chatSession, context, newMessage,
 			OTRL_FRAGMENT_SEND_ALL_BUT_LAST, &fragment);
--- trunk/KDE/kdenetwork/kopete/plugins/otr/otrplugin.cpp #920757:920758
@@ -46,6 +46,7 @@
 #include <kopeteaccountmanager.h>
 #include <kopetemessageevent.h>
 #include <kopeteprotocol.h>
+#include <ui/kopeteview.h>
 
 
 /**
@@ -162,6 +163,8 @@
 		msg.setType(Kopete::Message::TypeNormal);
 		if( !msg.plainBody().isEmpty() ){
 			messageCache.insert( *encBody, cacheBody );
+		} else {
+			messageCache.insert( "!OTR:MsgDelByOTR", cacheBody );
 		}
 	}
 }
@@ -245,7 +248,7 @@
 		QString contactId = msg.from()->contactId();
 		int retValue = OtrlChatInterface::self()->decryptMessage( &body, accountId, \
msg.manager()->account()->protocol()->displayName(), contactId, msg.manager() );  \
                msg.setHtmlBody( body );
-		if( retValue == 2 | OtrlChatInterface::self()->shouldDiscard( msg.plainBody() ) ){
+		if( (retValue == 2) | OtrlChatInterface::self()->shouldDiscard( msg.plainBody() ) \
){  // internal OTR message
 			event->discard();
 			return;
@@ -270,6 +273,11 @@
 		// This prevents the empty message from being shown in our chatwindow
 		if( msg.plainBody().isEmpty() ){
 			event->discard();
+			if(messageCache.contains("!OTR:MsgDelByOTR")){
+				msg.setPlainBody(messageCache["!OTR:MsgDelByOTR"]);
+				msg.manager()->view()->setCurrentMessage(msg);
+				messageCache.remove("!OTR:MsgDelByOTR");
+			}
 			return;
 		}
 	}
@@ -292,7 +300,7 @@
 
 	bool noerr;
 	if ( !policy.isEmpty() && policy != "null" )
-		otrPolicyMenu->setCurrentItem( policy.toInt( &noerr, 10 ));
+		otrPolicyMenu->setCurrentItem( policy.toInt( &noerr, 10 ) + 1); // +1 because of \
the Separator  else
 		otrPolicyMenu->setCurrentItem( 0 );
 
@@ -302,7 +310,7 @@
 	kDebug(14318) << "Setting contact policy";
 	Kopete::MetaContact *metaContact = \
Kopete::ContactList::self()->selectedMetaContacts().first();  if( metaContact ){
-		metaContact->setPluginData( this, "otr_policy", QString::number( \
otrPolicyMenu->currentItem() - 1 ) ); // -1 because of the "Default" entry \
+		metaContact->setPluginData( this, "otr_policy", QString::number( \
otrPolicyMenu->currentItem() - 1 ) ); // -1 because of the Separator  }
 	kDebug(14318) << "Selected policy: " << otrPolicyMenu->currentItem();
 }


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

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