| 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/me2me_preference_pane.h" | 5 #import "remoting/host/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 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 517 const char* command = is_service_running_ ? "--save-config" : "--enable"; | 517 const char* command = is_service_running_ ? "--save-config" : "--enable"; |
| 518 if (![self runHelperAsRootWithCommand:command | 518 if (![self runHelperAsRootWithCommand:command |
| 519 inputData:serialized_config]) { | 519 inputData:serialized_config]) { |
| 520 NSLog(@"Failed to run the helper tool"); | 520 NSLog(@"Failed to run the helper tool"); |
| 521 [self showError]; | 521 [self showError]; |
| 522 return; | 522 return; |
| 523 } | 523 } |
| 524 | 524 |
| 525 have_new_config_ = NO; | 525 have_new_config_ = NO; |
| 526 | 526 |
| 527 // If the service is running, send a signal to cause it to reload its | 527 // Ensure the service is started. |
| 528 // configuration, otherwise start the service. | 528 if (!is_service_running_) { |
| 529 if (is_service_running_) { | |
| 530 pid_t job_pid = base::mac::PIDForJob(remoting::kServiceName); | |
| 531 if (job_pid > 0) { | |
| 532 kill(job_pid, SIGHUP); | |
| 533 } else { | |
| 534 NSLog(@"Failed to obtain PID of service %s", remoting::kServiceName); | |
| 535 [self showError]; | |
| 536 } | |
| 537 } else { | |
| 538 [self sendJobControlMessage:LAUNCH_KEY_STARTJOB]; | 529 [self sendJobControlMessage:LAUNCH_KEY_STARTJOB]; |
| 539 } | 530 } |
| 540 | 531 |
| 541 // Broadcast a distributed notification to inform the plugin that the | 532 // Broadcast a distributed notification to inform the plugin that the |
| 542 // configuration has been applied. | 533 // configuration has been applied. |
| 543 [self notifyPlugin:UPDATE_SUCCEEDED_NOTIFICATION_NAME]; | 534 [self notifyPlugin:UPDATE_SUCCEEDED_NOTIFICATION_NAME]; |
| 544 } | 535 } |
| 545 | 536 |
| 546 - (BOOL)runHelperAsRootWithCommand:(const char*)command | 537 - (BOOL)runHelperAsRootWithCommand:(const char*)command |
| 547 inputData:(const std::string&)input_data { | 538 inputData:(const std::string&)input_data { |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 NSArray* arguments = [NSArray arrayWithObjects:@"--relaunch-prefpane", nil]; | 746 NSArray* arguments = [NSArray arrayWithObjects:@"--relaunch-prefpane", nil]; |
| 756 [task setLaunchPath:command]; | 747 [task setLaunchPath:command]; |
| 757 [task setArguments:arguments]; | 748 [task setArguments:arguments]; |
| 758 [task setStandardInput:[NSPipe pipe]]; | 749 [task setStandardInput:[NSPipe pipe]]; |
| 759 [task launch]; | 750 [task launch]; |
| 760 [task release]; | 751 [task release]; |
| 761 [NSApp terminate:nil]; | 752 [NSApp terminate:nil]; |
| 762 } | 753 } |
| 763 | 754 |
| 764 @end | 755 @end |
| OLD | NEW |