adium 5141:4ef1521096c4: Implemented asynchronous private key ge...

commits at adium.im commits at adium.im
Wed Oct 17 23:47:28 UTC 2012


details:	http://hg.adium.im/adium/rev/4ef1521096c4
revision:	5141:4ef1521096c4
branch:		libotr4.0.0
author:		Thijs Alkemade <thijsalkemade at gmail.com>
date:		Thu Oct 18 01:47:06 2012 +0200

Implemented asynchronous private key generation.

(This doesn't take much more than half a second on my machine, but hey, who knows, maybe people will want huge keys).

diffs (31 lines):

diff -r 6614ab49f5ea -r 4ef1521096c4 Source/AdiumOTREncryption.m
--- a/Source/AdiumOTREncryption.m	Thu Oct 18 01:31:54 2012 +0200
+++ b/Source/AdiumOTREncryption.m	Thu Oct 18 01:47:06 2012 +0200
@@ -395,12 +395,22 @@
 	[ESOTRPrivateKeyGenerationWindowController startedGeneratingForIdentifier:identifier];
 	
     /* Generate the key */
-    otrl_privkey_generate(otrg_plugin_userstate, PRIVKEY_PATH,
-						  accountname, protocol);
-    otrg_ui_update_keylist();
+	void *newkeyp;
+    otrl_privkey_generate_start(otrg_get_userstate(),
+						  accountname, protocol, &newkeyp);
 	
-    /* Mark the dialog as done. */
-	[ESOTRPrivateKeyGenerationWindowController finishedGeneratingForIdentifier:identifier];
+	dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
+		otrl_privkey_generate_calculate(newkeyp);
+		
+		dispatch_sync(dispatch_get_main_queue(), ^{
+			otrl_privkey_generate_finish(otrg_get_userstate(), newkeyp, PRIVKEY_PATH);
+			
+			otrg_ui_update_keylist();
+			
+			/* Mark the dialog as done. */
+			[ESOTRPrivateKeyGenerationWindowController finishedGeneratingForIdentifier:identifier];
+		});
+	});
 }
 
 /* Create a private key for the given accountname/protocol if




More information about the commits mailing list