FreeRDP
VerifyCertificateController.m
1 /*
2  Certificate verification controller
3 
4  Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
5 
6  This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7  If a copy of the MPL was not distributed with this file, You can obtain one at
8  http://mozilla.org/MPL/2.0/.
9  */
10 
11 #import "VerifyCertificateController.h"
12 #import "RDPSession.h"
13 
14 @implementation VerifyCertificateController
15 
16 - (id)initWithNibName:(NSString *)nibNameOrNil
17  bundle:(NSBundle *)nibBundleOrNil
18  session:(RDPSession *)session
19  params:(NSMutableDictionary *)params
20 {
21  self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
22  if (self)
23  {
24  _session = session;
25  _params = params;
26  [self setModalPresentationStyle:UIModalPresentationFormSheet];
27  }
28  return self;
29 }
30 
31 - (void)viewDidLoad
32 {
33  [super viewDidLoad];
34 
35  NSString *message = NSLocalizedString(
36  @"The identity of the remote computer cannot be verified. Do you want to connect anyway?",
37  @"Verify certificate view message");
38 
39  // init strings
40  [_label_message setText:message];
41  [_label_for_issuer
42  setText:NSLocalizedString(@"Issuer:", @"Verify certificate view issuer label")];
43  [_btn_accept setTitle:NSLocalizedString(@"Yes", @"Yes Button") forState:UIControlStateNormal];
44  [_btn_decline setTitle:NSLocalizedString(@"No", @"No Button") forState:UIControlStateNormal];
45 
46  [_label_issuer setText:[_params valueForKey:@"issuer"]];
47 }
48 
49 - (void)viewDidUnload
50 {
51  [super viewDidUnload];
52  // Release any retained subviews of the main view.
53 }
54 
55 - (void)viewDidDisappear:(BOOL)animated
56 {
57  [super viewDidDisappear:animated];
58 
59  // set signal
60  [[_session uiRequestCompleted] signal];
61 }
62 
63 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
64 {
65  return YES;
66 }
67 
68 #pragma mark - Action handlers
69 
70 - (IBAction)acceptPressed:(id)sender
71 {
72  [_params setValue:[NSNumber numberWithBool:YES] forKey:@"result"];
73 
74  // dismiss controller
75  [self dismissModalViewControllerAnimated:YES];
76 }
77 
78 - (IBAction)declinePressed:(id)sender
79 {
80  [_params setValue:[NSNumber numberWithBool:NO] forKey:@"result"];
81 
82  // dismiss controller
83  [self dismissModalViewControllerAnimated:YES];
84 }
85 
86 @end