adium 5866:7ce0fc2c6fc3: Add a "Refresh" option to re-negotiate ...

commits at adium.im commits at adium.im
Mon May 5 16:44:04 UTC 2014


details:	http://hg.adium.im/adium/rev/7ce0fc2c6fc3
revision:	5866:7ce0fc2c6fc3
branch:		adium-1.6
author:		Thijs Alkemade <me at thijsalkema.de>
date:		Mon May 05 18:41:39 2014 +0200

Add a "Refresh" option to re-negotiate OTR encrypted chats when needed.
Subject: adium 5867:d9a50d62b417: Fix potential problems with non-format strings being used as format strings.

details:	http://hg.adium.im/adium/rev/d9a50d62b417
revision:	5867:d9a50d62b417
branch:		adium-1.6
author:		Thijs Alkemade <me at thijsalkema.de>
date:		Mon May 05 18:43:10 2014 +0200

Fix potential problems with non-format strings being used as format strings.
Subject: adium 5868:792242009240: Remove the GaimOTR -> PidginOTR upgrade code. If you still haven't migrated, you're years behind.

details:	http://hg.adium.im/adium/rev/792242009240
revision:	5868:792242009240
branch:		adium-1.6
author:		Thijs Alkemade <me at thijsalkema.de>
date:		Mon May 05 18:43:55 2014 +0200

Remove the GaimOTR -> PidginOTR upgrade code. If you still haven't migrated, you're years behind.

diffs (359 lines):

diff -r a97833ab0faf -r 792242009240 Plugins/Secure Messaging/ESSecureMessagingPlugin.h
--- a/Plugins/Secure Messaging/ESSecureMessagingPlugin.h	Wed Apr 23 20:48:33 2014 +0200
+++ b/Plugins/Secure Messaging/ESSecureMessagingPlugin.h	Mon May 05 18:43:55 2014 +0200
@@ -26,7 +26,8 @@
 	AISecureMessagingMenu_ShowAbout,
 	AISecureMessagingMenu_VerifyManually,
 	AISecureMessagingMenu_VerifyQuestion,
-	AISecureMessagingMenu_VerifySharedSecret
+	AISecureMessagingMenu_VerifySharedSecret,
+	AISecureMessagingMenu_Refresh
 } AISecureMessagingMenuTag;
 
 @interface ESSecureMessagingPlugin : AIPlugin <AIChatObserver> {
diff -r a97833ab0faf -r 792242009240 Plugins/Secure Messaging/ESSecureMessagingPlugin.m
--- a/Plugins/Secure Messaging/ESSecureMessagingPlugin.m	Wed Apr 23 20:48:33 2014 +0200
+++ b/Plugins/Secure Messaging/ESSecureMessagingPlugin.m	Mon May 05 18:43:55 2014 +0200
@@ -38,6 +38,7 @@
 
 #define	TITLE_MAKE_SECURE		AILocalizedString(@"Initiate Encrypted OTR Chat",nil)
 #define	TITLE_MAKE_INSECURE		AILocalizedString(@"Cancel Encrypted Chat",nil)
+#define	TITLE_REFRESH_SECURE	AILocalizedString(@"Refresh Encrypted Chat",nil)
 #define TITLE_SHOW_DETAILS		[AILocalizedString(@"Show Details",nil) stringByAppendingEllipsis]
 #define TITLE_VERIFY			AILocalizedString(@"Verify",nil)
 #define TITLE_VERIFY_MANUALLY	[AILocalizedString(@"Manually",nil) stringByAppendingEllipsis]
@@ -368,13 +369,22 @@
 									inChat:chat];
 }
 
+- (IBAction)refreshSecureMessaging:(id)sender
+{
+	AIChat	*chat = adium.interfaceController.activeChat;
+	
+	[chat.account requestSecureMessaging:TRUE
+								  inChat:chat];
+}
+
 - (IBAction)showDetails:(id)sender
 {
 	NSRunInformationalAlertPanel(AILocalizedString(@"Details",nil),
-								 [[adium.interfaceController.activeChat securityDetails] objectForKey:@"Description"],
+								 @"%@",
 								 AILocalizedString(@"OK",nil),
 								 nil,
-								 nil);
+								 nil,
+								 [[adium.interfaceController.activeChat securityDetails] objectForKey:@"Description"]);
 }
 
 - (IBAction)verify:(id)sender
@@ -406,10 +416,11 @@
 	
 	if (aboutEncryption) {
 		NSRunInformationalAlertPanel(AILocalizedString(@"About Encryption",nil),
-									 aboutEncryption,
+									 @"%@",
 									 AILocalizedString(@"OK",nil),
 									 nil,
-									 nil);
+									 nil,
+									 aboutEncryption);
 	}
 }
 
@@ -497,6 +508,7 @@
 				return YES;
 				break;
 				
+			case AISecureMessagingMenu_Refresh:
 			case AISecureMessagingMenu_ShowDetails:
 			case AISecureMessagingMenu_VerifyManually:
 			case AISecureMessagingMenu_VerifyQuestion:
@@ -534,6 +546,13 @@
 		[item setTag:AISecureMessagingMenu_Toggle];
 		[_secureMessagingMenu addItem:item];
 		
+		item = [[[NSMenuItem alloc] initWithTitle:TITLE_REFRESH_SECURE
+										   target:self
+										   action:@selector(refreshSecureMessaging:)
+									keyEquivalent:@""] autorelease];
+		[item setTag:AISecureMessagingMenu_Refresh];
+		[_secureMessagingMenu addItem:item];
+		
 		item = [[[NSMenuItem alloc] initWithTitle:TITLE_SHOW_DETAILS
 										   target:self
 										   action:@selector(showDetails:)
diff -r a97833ab0faf -r 792242009240 Source/AdiumOTREncryption.m
--- a/Source/AdiumOTREncryption.m	Wed Apr 23 20:48:33 2014 +0200
+++ b/Source/AdiumOTREncryption.m	Mon May 05 18:43:55 2014 +0200
@@ -116,8 +116,6 @@
 	/* Initialize the OTR library */
 	OTRL_INIT;
 
-	[self upgradeOTRIfNeeded];
-
 	/* Make our OtrlUserState; we'll only use the one. */
 	otrg_plugin_userstate = otrl_userstate_create();
 
@@ -731,7 +729,7 @@
 			break;
 		}
 		case OTRL_MSGEVENT_CONNECTION_ENDED: {
-			NSString *localizedMessage = [NSString stringWithFormat:AILocalizedStringFromTableInBundle(@"%@ is no longer using encryption; you should cancel encryption on your side.",
+			NSString *localizedMessage = [NSString stringWithFormat:AILocalizedStringFromTableInBundle(@"Your message was not sent. %@ is no longer using encryption; you should cancel or refresh encryption on your side.",
 																									   @"libotr error message", [NSBundle bundleForClass:[AdiumOTREncryption class]],
 																									   @"Message when the remote contact cancels his half of an encrypted conversation. %@ will be a name."), listContact.UID];
 			
@@ -1182,252 +1180,4 @@
 	[OTRPrefs updateFingerprintsList];
 }
 
-#pragma mark Upgrading gaim-otr --> Adium-otr
-/*!
- * @brief Construct a dictionary converting libpurple prpl names to Adium serviceIDs for the purpose of fingerprint upgrading
- */
-- (NSDictionary *)prplDict
-{
-	return [NSDictionary dictionaryWithObjectsAndKeys:
-		@"libpurple-OSCAR-AIM", @"prpl-oscar",
-		@"libpurple-Gadu-Gadu", @"prpl-gg",
-		@"libpurple-Jabber", @"prpl-jabber",
-		@"libpurple-Sametime", @"prpl-meanwhile",
-		@"libpurple-MSN", @"prpl-msn",
-		@"libpurple-GroupWise", @"prpl-novell",
-		@"libpurple-Yahoo!", @"prpl-yahoo",
-		@"libpurple-zephyr", @"prpl-zephyr", nil];
-}
-
-- (NSString *)upgradedFingerprintsFromFile:(NSString *)inPath
-{
-	NSString		*sourceFingerprints = [NSString stringWithContentsOfUTF8File:inPath];
-	
-	if (!sourceFingerprints  || ![sourceFingerprints length]) return nil;
-
-	NSScanner		*scanner = [NSScanner scannerWithString:sourceFingerprints];
-	NSMutableString *outFingerprints = [NSMutableString string];
-	NSCharacterSet	*tabAndNewlineSet = [NSCharacterSet characterSetWithCharactersInString:@"\t\n\r"];
-	
-	//Skip quotes
-	[scanner setCharactersToBeSkipped:[NSCharacterSet characterSetWithCharactersInString:@"\""]];
-	
-	NSDictionary	*prplDict = [self prplDict];
-
-	while (![scanner isAtEnd]) {
-		//username     accountname  protocol      key	trusted\n
-		NSString		*chunk;
-		NSString		*username = nil, *accountname = nil, *protocol = nil, *key = nil, *trusted = nil;
-		
-		//username
-		[scanner scanUpToCharactersFromSet:tabAndNewlineSet intoString:&username];
-		[scanner scanCharactersFromSet:tabAndNewlineSet intoString:NULL];
-		
-		//accountname
-		[scanner scanUpToCharactersFromSet:tabAndNewlineSet intoString:&accountname];
-		[scanner scanCharactersFromSet:tabAndNewlineSet intoString:NULL];
-		
-		//protocol
-		[scanner scanUpToCharactersFromSet:tabAndNewlineSet intoString:&protocol];
-		[scanner scanCharactersFromSet:tabAndNewlineSet intoString:NULL];
-		
-		//key
-		[scanner scanUpToCharactersFromSet:tabAndNewlineSet intoString:&key];
-		[scanner scanCharactersFromSet:tabAndNewlineSet intoString:&chunk];
-		
-		//We have a trusted entry
-		if ([chunk isEqualToString:@"\t"]) {
-			//key
-			[scanner scanUpToCharactersFromSet:tabAndNewlineSet intoString:&trusted];
-			[scanner scanCharactersFromSet:tabAndNewlineSet intoString:NULL];		
-		} else {
-			trusted = nil;
-		}
-		
-		if (username && accountname && protocol && key) {
-			for (AIAccount *account in adium.accountController.accounts) {
-				//Hit every possibile name for this account along the way
-				if ([[NSSet setWithObjects:account.UID,account.formattedUID,[account.UID compactedString], nil] containsObject:accountname]) {
-					if ([account.service.serviceCodeUniqueID isEqualToString:[prplDict objectForKey:protocol]]) {
-						[outFingerprints appendString:
-							[NSString stringWithFormat:@"%@\t%@\t%@\t%@", username, account.internalObjectID, account.service.serviceCodeUniqueID, key]];
-						if (trusted) {
-							[outFingerprints appendString:@"\t"];
-							[outFingerprints appendString:trusted];
-						}
-						[outFingerprints appendString:@"\n"];
-					}
-				}
-			}
-		}
-	}
-	
-	return outFingerprints;
-}
-
-- (NSString *)upgradedPrivateKeyFromFile:(NSString *)inPath
-{
-	NSMutableString	*sourcePrivateKey = [[[NSString stringWithContentsOfUTF8File:inPath] mutableCopy] autorelease];
-	AILog(@"Upgrading private keys at %@ gave %@",inPath,sourcePrivateKey);
-	if (!sourcePrivateKey || ![sourcePrivateKey length]) return nil;
-
-	/*
-	 * Gaim used the account name for the name and the prpl id for the protocol.
-	 * We will use the internalObjectID for the name and the service's uniqueID for the protocol.
-	 */
-
-	/* Remove Jabber resources... from the private key list
-	 * If you used a non-default resource, no upgrade for you.
-	 */
-	[sourcePrivateKey replaceOccurrencesOfString:@"/Adium"
-									  withString:@""
-										 options:NSLiteralSearch
-										   range:NSMakeRange(0, [sourcePrivateKey length])];
-
-	NSDictionary	*prplDict = [self prplDict];
-
-	for (AIAccount *account in adium.accountController.accounts) {
-		//Hit every possibile name for this account along the way
-		NSString		*accountInternalObjectID = [NSString stringWithFormat:@"\"%@\"",account.internalObjectID];
-
-		for (NSString *accountName in [NSSet setWithObjects:account.UID,account.formattedUID,[account.UID compactedString], nil]) {
-			NSRange			accountNameRange = NSMakeRange(0, 0);
-			NSRange			searchRange = NSMakeRange(0, [sourcePrivateKey length]);
-
-			while (accountNameRange.location != NSNotFound &&
-				   (NSMaxRange(searchRange) <= [sourcePrivateKey length])) {
-				//Find the next place this account name is located
-				accountNameRange = [sourcePrivateKey rangeOfString:accountName
-														   options:NSLiteralSearch
-															 range:searchRange];
-
-				if (accountNameRange.location != NSNotFound) {
-					//Update our search range
-					searchRange.location = NSMaxRange(accountNameRange);
-					searchRange.length = [sourcePrivateKey length] - searchRange.location;
-
-					//Make sure that this account name actually begins and finishes a name; otherwise (name TekJew2) matches (name TekJew)
-					if ((![[sourcePrivateKey substringWithRange:NSMakeRange(accountNameRange.location - 6, 6)] isEqualToString:@"(name "] &&
-						 ![[sourcePrivateKey substringWithRange:NSMakeRange(accountNameRange.location - 7, 7)] isEqualToString:@"(name \""]) ||
-						(![[sourcePrivateKey substringWithRange:NSMakeRange(NSMaxRange(accountNameRange), 1)] isEqualToString:@")"] &&
-						 ![[sourcePrivateKey substringWithRange:NSMakeRange(NSMaxRange(accountNameRange), 2)] isEqualToString:@"\")"])) {
-						continue;
-					}
-
-					/* Within that range, find the next "(protocol " which encloses
-						* a string of the form "(protocol protocol-name)"
-						*/
-					NSRange protocolRange = [sourcePrivateKey rangeOfString:@"(protocol "
-																	options:NSLiteralSearch
-																	  range:searchRange];
-					if (protocolRange.location != NSNotFound) {
-						//Update our search range
-						searchRange.location = NSMaxRange(protocolRange);
-						searchRange.length = [sourcePrivateKey length] - searchRange.location;
-
-						NSRange nextClosingParen = [sourcePrivateKey rangeOfString:@")"
-																		   options:NSLiteralSearch
-																			 range:searchRange];
-						NSRange protocolNameRange = NSMakeRange(NSMaxRange(protocolRange),
-																nextClosingParen.location - NSMaxRange(protocolRange));
-						NSString *protocolName = [sourcePrivateKey substringWithRange:protocolNameRange];
-						//Remove a trailing quote if necessary
-						if ([[protocolName substringFromIndex:([protocolName length]-1)] isEqualToString:@"\""]) {
-							protocolName = [protocolName substringToIndex:([protocolName length]-1)];
-						}
-
-						NSString *uniqueServiceID = [prplDict objectForKey:protocolName];
-
-						if ([account.service.serviceCodeUniqueID isEqualToString:uniqueServiceID]) {
-							//Replace the protocol name first
-							[sourcePrivateKey replaceCharactersInRange:protocolNameRange
-															withString:uniqueServiceID];
-
-							//Then replace the account name which was before it (so the range hasn't changed)
-							if ([sourcePrivateKey characterAtIndex:(accountNameRange.location - 1)] == '\"') {
-								accountNameRange.location -= 1;
-								accountNameRange.length += 1;
-							}
-							
-							if ([sourcePrivateKey characterAtIndex:(accountNameRange.location + accountNameRange.length + 1)] == '\"') {
-								accountNameRange.length += 1;
-							}
-							
-							[sourcePrivateKey replaceCharactersInRange:accountNameRange
-															withString:accountInternalObjectID];
-						}
-					}
-				}
-				
-				AILog(@"%@ - %@",accountName, sourcePrivateKey);
-			}
-		}			
-	}
-	
-	return sourcePrivateKey;
-}
-
-- (void)upgradeOTRIfNeeded
-{
-	if (![[adium.preferenceController preferenceForKey:@"GaimOTR_to_AdiumOTR_Update"
-												   group:@"OTR"] boolValue]) {
-		NSString	  *destinationPath = [adium.loginController userDirectory];
-		NSString	  *sourcePath = [destinationPath stringByAppendingPathComponent:@"libpurple"];
-		
-		NSString *privateKey = [self upgradedPrivateKeyFromFile:[sourcePath stringByAppendingPathComponent:@"otr.private_key"]];
-		if (privateKey && [privateKey length]) {
-			[privateKey writeToFile:[destinationPath stringByAppendingPathComponent:@"otr.private_key"]
-						 atomically:NO
-						   encoding:NSUTF8StringEncoding
-							  error:NULL];
-		}
-
-		NSString *fingerprints = [self upgradedFingerprintsFromFile:[sourcePath stringByAppendingPathComponent:@"otr.fingerprints"]];
-		if (fingerprints && [fingerprints length]) {
-			[fingerprints writeToFile:[destinationPath stringByAppendingPathComponent:@"otr.fingerprints"]
-						   atomically:NO
-							 encoding:NSUTF8StringEncoding
-								error:NULL];
-		}
-
-		[adium.preferenceController setPreference:[NSNumber numberWithBool:YES]
-											 forKey:@"GaimOTR_to_AdiumOTR_Update"
-											  group:@"OTR"];
-	}
-	
-	if (![[adium.preferenceController preferenceForKey:@"Libgaim_to_Libpurple_Update"
-												   group:@"OTR"] boolValue]) {
-		NSString	*destinationPath = [adium.loginController userDirectory];
-		
-		NSString	*privateKeyPath = [destinationPath stringByAppendingPathComponent:@"otr.private_key"];
-		NSString	*fingerprintsPath = [destinationPath stringByAppendingPathComponent:@"otr.fingerprints"];
-
-		NSMutableString *privateKeys = [[NSString stringWithContentsOfUTF8File:privateKeyPath] mutableCopy];
-		[privateKeys replaceOccurrencesOfString:@"libgaim"
-									 withString:@"libpurple"
-										options:NSLiteralSearch
-										  range:NSMakeRange(0, [privateKeys length])];
-		[privateKeys writeToFile:privateKeyPath
-					  atomically:YES
-						encoding:NSUTF8StringEncoding
-						   error:NULL];
-		[privateKeys release];
-
-		NSMutableString *fingerprints = [[NSString stringWithContentsOfUTF8File:fingerprintsPath] mutableCopy];
-		[fingerprints replaceOccurrencesOfString:@"libgaim"
-									 withString:@"libpurple"
-										options:NSLiteralSearch
-										  range:NSMakeRange(0, [fingerprints length])];
-		[fingerprints writeToFile:fingerprintsPath
-					   atomically:YES
-						 encoding:NSUTF8StringEncoding
-							error:NULL];
-		[fingerprints release];
-
-		[adium.preferenceController setPreference:[NSNumber numberWithBool:YES]
-											 forKey:@"Libgaim_to_Libpurple_Update"
-											  group:@"OTR"];
-	}
-}
-
 @end




More information about the commits mailing list