OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "remoting/host/mac/me2me_preference_pane.h" | 5 #import "remoting/host/mac/me2me_preference_pane.h" |
6 | 6 |
7 #import <Cocoa/Cocoa.h> | 7 #import <Cocoa/Cocoa.h> |
8 #include <CommonCrypto/CommonHMAC.h> | 8 #include <CommonCrypto/CommonHMAC.h> |
9 #include <errno.h> | 9 #include <errno.h> |
10 #include <launch.h> | 10 #include <launch.h> |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 } | 146 } |
147 | 147 |
148 - (void)applyConfiguration:(id)sender | 148 - (void)applyConfiguration:(id)sender |
149 pin:(NSString*)pin { | 149 pin:(NSString*)pin { |
150 if (!have_new_config_) { | 150 if (!have_new_config_) { |
151 // It shouldn't be possible to hit the button if there is no config to | 151 // It shouldn't be possible to hit the button if there is no config to |
152 // apply, but check anyway just in case it happens somehow. | 152 // apply, but check anyway just in case it happens somehow. |
153 return; | 153 return; |
154 } | 154 } |
155 | 155 |
156 // Ensure the authorization token is up-to-date before using it. | 156 // Ensure the authorization token is up to date before using it. |
157 [self updateAuthorizationStatus]; | 157 [self updateAuthorizationStatus]; |
158 [self updateUI]; | 158 [self updateUI]; |
159 | 159 |
160 std::string pin_utf8 = [pin UTF8String]; | 160 std::string pin_utf8 = [pin UTF8String]; |
161 std::string host_id, host_secret_hash; | 161 std::string host_id, host_secret_hash; |
162 bool result = (config_->GetString(remoting::kHostIdConfigPath, &host_id) && | 162 bool result = (config_->GetString(remoting::kHostIdConfigPath, &host_id) && |
163 config_->GetString(remoting::kHostSecretHashConfigPath, | 163 config_->GetString(remoting::kHostSecretHashConfigPath, |
164 &host_secret_hash)); | 164 &host_secret_hash)); |
165 if (!result) { | 165 if (!result) { |
166 [self showError]; | 166 [self showError]; |
167 return; | 167 return; |
168 } | 168 } |
169 if (!remoting::VerifyHostPinHash(host_secret_hash, host_id, pin_utf8)) { | 169 if (!remoting::VerifyHostPinHash(host_secret_hash, host_id, pin_utf8)) { |
170 [self showIncorrectPinMessage]; | 170 [self showIncorrectPinMessage]; |
171 return; | 171 return; |
172 } | 172 } |
173 | 173 |
174 [self applyNewServiceConfig]; | 174 [self applyNewServiceConfig]; |
175 [self updateUI]; | 175 [self updateUI]; |
176 } | 176 } |
177 | 177 |
178 - (void)onDisable:(id)sender { | 178 - (void)onDisable:(id)sender { |
179 // Ensure the authorization token is up-to-date before using it. | 179 // Ensure the authorization token is up to date before using it. |
180 [self updateAuthorizationStatus]; | 180 [self updateAuthorizationStatus]; |
181 [self updateUI]; | 181 [self updateUI]; |
182 if (!is_pane_unlocked_) | 182 if (!is_pane_unlocked_) |
183 return; | 183 return; |
184 | 184 |
185 if (![self runHelperAsRootWithCommand:"--disable" | 185 if (![self runHelperAsRootWithCommand:"--disable" |
186 inputData:""]) { | 186 inputData:""]) { |
187 NSLog(@"Failed to run the helper tool"); | 187 NSLog(@"Failed to run the helper tool"); |
188 [self showError]; | 188 [self showError]; |
189 [self notifyPlugin:UPDATE_FAILED_NOTIFICATION_NAME]; | 189 [self notifyPlugin:UPDATE_FAILED_NOTIFICATION_NAME]; |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 NSArray* arguments = [NSArray arrayWithObjects:@"--relaunch-prefpane", nil]; | 580 NSArray* arguments = [NSArray arrayWithObjects:@"--relaunch-prefpane", nil]; |
581 [task setLaunchPath:command]; | 581 [task setLaunchPath:command]; |
582 [task setArguments:arguments]; | 582 [task setArguments:arguments]; |
583 [task setStandardInput:[NSPipe pipe]]; | 583 [task setStandardInput:[NSPipe pipe]]; |
584 [task launch]; | 584 [task launch]; |
585 [task release]; | 585 [task release]; |
586 [NSApp terminate:nil]; | 586 [NSApp terminate:nil]; |
587 } | 587 } |
588 | 588 |
589 @end | 589 @end |
OLD | NEW |