adium 5516:88cdaeb864d1: Fix a couple of problems with Adium get...

commits at adium.im commits at adium.im
Mon May 27 22:25:26 UTC 2013


details:	http://hg.adium.im/adium/rev/88cdaeb864d1
revision:	5516:88cdaeb864d1
branch:		libotr4.0.0
author:		Thijs Alkemade <me at thijsalkema.de>
date:		Tue May 28 00:24:27 2013 +0200

Fix a couple of problems with Adium getting confused about the OTR contexts that are active. Also fixes #16290, though I'm not fully sure why.

diffs (152 lines):

diff -r 65883fb47e79 -r 88cdaeb864d1 Source/AIChatController.m
--- a/Source/AIChatController.m	Thu May 09 14:25:53 2013 +0200
+++ b/Source/AIChatController.m	Tue May 28 00:24:27 2013 +0200
@@ -367,8 +367,8 @@
 
 		//Create a new chat
 		chat = [AIChat chatForAccount:account];
-        chat.listObject = targetContact;
-		[openChats addObject:chat];
+        [openChats addObject:chat];
+		chat.listObject = targetContact;
 		AILog(@"chatWithContact: Added <<%@>> [%@]",chat,openChats);
 
 		//Inform the account of its creation
diff -r 65883fb47e79 -r 88cdaeb864d1 Source/AdiumOTREncryption.m
--- a/Source/AdiumOTREncryption.m	Thu May 09 14:25:53 2013 +0200
+++ b/Source/AdiumOTREncryption.m	Tue May 28 00:24:27 2013 +0200
@@ -77,7 +77,7 @@
 static AdiumOTREncryption	*adiumOTREncryption = nil;
 
 void otrg_ui_update_fingerprint(void);
-void update_security_details_for_chat(AIChat *chat);
+void update_security_details_for_context(ConnContext *context);
 void send_default_query_to_chat(AIChat *inChat);
 void disconnect_from_chat(AIChat *inChat);
 void disconnect_from_context(ConnContext *context);
@@ -207,9 +207,7 @@
 	Fingerprint *fprint = context->active_fingerprint;	
 
     if (!fprint || !(fprint->fingerprint)) return nil;
-    context = fprint->context;
-    if (!context) return nil;
-
+	
     TrustLevel			level = otrg_plugin_context_to_trust(context);
 	AIEncryptionStatus	encryptionStatus;
 	AIAccount			*account;
@@ -249,15 +247,13 @@
 
 	account = [adium.accountController accountWithInternalObjectID:[NSString stringWithUTF8String:context->accountname]];
 
-	securityDetailsDict = [NSDictionary dictionaryWithObjectsAndKeys:
-		[NSString stringWithUTF8String:their_hash], @"Their Fingerprint",
-		[NSString stringWithUTF8String:our_hash], @"Our Fingerprint",
-		@(encryptionStatus), @"EncryptionStatus",
-		account, @"AIAccount",
-		[NSString stringWithUTF8String:context->username], @"who",
-		[NSString stringWithUTF8String:sess1], (sess1_outgoing ? @"Outgoing SessionID" : @"Incoming SessionID"),
-		[NSString stringWithUTF8String:sess2], (sess1_outgoing ? @"Incoming SessionID" : @"Outgoing SessionID"),
-		nil];
+	securityDetailsDict = @{ @"Their Fingerprint" : [NSString stringWithUTF8String:their_hash],
+						  @"Our Fingerprint" : [NSString stringWithUTF8String:our_hash],
+						  @"EncryptionStatus": @(encryptionStatus),
+						  @"AIAccount" : account,
+						  @"who": [NSString stringWithUTF8String:context->username],
+						  (sess1_outgoing ? @"Outgoing SessionID" : @"Incoming SessionID"): [NSString stringWithUTF8String:sess1],
+						  (sess1_outgoing ? @"Incoming SessionID" : @"Outgoing SessionID"): [NSString stringWithUTF8String:sess2] };
 	
 	AILog(@"Security details: %@",securityDetailsDict);
 	
@@ -331,7 +327,7 @@
     ConnContext *context;
 	
     /* Do nothing if this isn't an IM conversation */
-    if (chat.isGroupChat) return nil;
+    if (chat.isGroupChat) return NULL;
 	
     account = chat.account;
 	accountname = [account.internalObjectID UTF8String];
@@ -342,6 +338,8 @@
 								username, accountname, proto, OTRL_INSTAG_RECENT, 0, NULL,
 								NULL, NULL);
 	
+	AILogWithSignature(@"%@ -> %p", chat, context);
+	
 	return context;
 }
 
@@ -525,9 +523,8 @@
 static void gone_secure_cb(void *opdata, ConnContext *context)
 {
 	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
-	AIChat *chat = chatForContext(context);
-
-    update_security_details_for_chat(chat);
+	
+    update_security_details_for_context(context);
 	otrg_ui_update_fingerprint();
 	
 	[pool release];
@@ -538,9 +535,7 @@
 {
 	NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
 	
-	AIChat *chat = chatForContext(context);
-
-    update_security_details_for_chat(chat);
+    update_security_details_for_context(context);
 	otrg_ui_update_fingerprint();
 	
 	[pool release];
@@ -822,14 +817,12 @@
 	
     if (!username || !originalMessage)
 		return;
-	
-	ConnContext		*context = contextForChat(inContentMessage.chat);
-	
+		
     err = otrl_message_sending(otrg_plugin_userstate, &ui_ops, /* opData */ NULL,
 							   accountname, protocol, username, OTRL_INSTAG_RECENT, originalMessage, /* tlvs */ NULL, &fullOutgoingMessage,
-							   OTRL_FRAGMENT_SEND_ALL_BUT_LAST, &context,
+							   OTRL_FRAGMENT_SEND_ALL_BUT_LAST, NULL,
 							   /* add_appdata cb */NULL, /* appdata */ NULL);
-
+	
     if (err && fullOutgoingMessage == NULL) {
 		//Be *sure* not to send out plaintext
 		[inContentMessage setEncodedMessage:nil];
@@ -849,7 +842,6 @@
 	const char *message = [inString UTF8String];
 	char *newMessage = NULL;
     OtrlTLV *tlvs = NULL;
-    OtrlTLV *tlv = NULL;
 	const char *username = [inListContact.UID UTF8String];
     const char *accountname = [inAccount.internalObjectID UTF8String];
     const char *protocol = [inAccount.service.serviceCodeUniqueID UTF8String];
@@ -970,15 +962,19 @@
 - (void)updateSecurityDetails:(NSNotification *)inNotification
 {
 	AILog(@"Updating security details for %@",[inNotification object]);
-	update_security_details_for_chat([inNotification object]);
+	AIChat *chat = [inNotification object];
+	
+	ConnContext *context = contextForChat(chat);
+	
+	update_security_details_for_context(context);
 }
 
-void update_security_details_for_chat(AIChat *inChat)
+void update_security_details_for_context(ConnContext *context)
 {
-	ConnContext *context = contextForChat(inChat);
-
+	AIChat *chat = chatForContext(context);
+	
 	[adiumOTREncryption setSecurityDetails:details_for_context(context)
-								   forChat:inChat];
+								   forChat:chat];
 }
 
 - (void)setSecurityDetails:(NSDictionary *)securityDetailsDict forChat:(AIChat *)inChat




More information about the commits mailing list