CryptoPassphrase  Check-in [270f5fe473]

Overview
Comment:iOS: Fix UI operations on non-main thread
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 270f5fe47329728087a3674823c8fa37ff942549ad9f458b171d5a13c323cf60
User & Date: js on 2017-09-15 01:39:30
Other Links: manifest | tags
Context
2017-10-15
10:32
iOS: Have an icon check-in: d10e7e273e user: js tags: trunk
2017-09-15
01:39
iOS: Fix UI operations on non-main thread check-in: 270f5fe473 user: js tags: trunk
2017-08-11
20:17
Adjust to ObjFW changes check-in: 484db716a1 user: js tags: trunk
Changes

Modified iOS/ShowDetailsController.m from [07cb7c3f7e] to [1520eb22e7].

159
160
161
162
163
164
165


166
167
168
169

















170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201

202
203



204
205
206
207
208
209
210
159
160
161
162
163
164
165
166
167




168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189












190



191
192
193
194
195
196
197
198
199
200
201
202


203
204
205
206
207
208
209
210
211
212







+
+
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+





-
-
-
-
-
-
-
-
-
-
-
-

-
-
-











+
-
-
+
+
+







			clearNSMutableString(password);
		}];
	}];
}

- (void)_generateWithCallback: (void (^)(NSMutableString *))block
{
	id <PasswordGenerator> generator;
	char *passphrase;
	UIStoryboard *mainStoryboard =
	[UIStoryboard storyboardWithName: @"Main"
				  bundle: nil];
	UIViewController *activityController = [mainStoryboard
	UIStoryboard *mainStoryboard;
	UIViewController *activityController;

	if (_legacy)
		generator = [LegacyPasswordGenerator generator];
	else
		generator = [NewPasswordGenerator generator];

	generator.site = _name;
	generator.length = _length;

	passphrase = of_strdup([self.passphraseField.text UTF8String]);
	generator.passphrase = passphrase;

	mainStoryboard = [UIStoryboard storyboardWithName: @"Main"
						   bundle: nil];
	activityController = [mainStoryboard
	    instantiateViewControllerWithIdentifier: @"activityIndicator"];
	[self.navigationController.view addSubview: activityController.view];

	dispatch_async(dispatch_get_global_queue(
	    DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^ {
		id <PasswordGenerator> generator;
		char *passphrase;

		if (_legacy)
			generator = [LegacyPasswordGenerator generator];
		else
			generator = [NewPasswordGenerator generator];

		generator.site = _name;
		generator.length = _length;

		passphrase = of_strdup([self.passphraseField.text UTF8String]);
		@try {
			self.passphraseField.text = @"";
			generator.passphrase = passphrase;

			[generator derivePassword];
		} @finally {
			of_explicit_memset(passphrase, 0, strlen(passphrase));
			free(passphrase);
		}

		NSMutableString *password = [NSMutableString
		    stringWithUTF8String: (char *)generator.output];
		of_explicit_memset(generator.output, 0,
		    strlen((char *)generator.output));

		dispatch_sync(dispatch_get_main_queue(), ^ {
		activityController.view.hidden = YES;
		block(password);
			activityController.view.hidden = YES;
			block(password);
		});
	});
}

- (IBAction)remove: (id)sender
{
	UIAlertController *alert = [UIAlertController
	    alertControllerWithTitle: @"Remove Site?"