| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #if !defined(__has_feature) || !__has_feature(objc_arc) | 5 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 6 #error "This file requires ARC support." | 6 #error "This file requires ARC support." |
| 7 #endif | 7 #endif |
| 8 | 8 |
| 9 #import "remoting/ios/facade/remoting_service.h" | 9 #import "remoting/ios/facade/remoting_service.h" |
| 10 | 10 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 switch (host_status) { | 90 switch (host_status) { |
| 91 case remoting::kHostStatusOnline: | 91 case remoting::kHostStatusOnline: |
| 92 status = "ONLINE"; | 92 status = "ONLINE"; |
| 93 break; | 93 break; |
| 94 case remoting::kHostStatusOffline: | 94 case remoting::kHostStatusOffline: |
| 95 status = "OFFLINE"; | 95 status = "OFFLINE"; |
| 96 break; | 96 break; |
| 97 default: | 97 default: |
| 98 NOTREACHED(); | 98 NOTREACHED(); |
| 99 } | 99 } |
| 100 // TODO(nicholss): Not yet integrated: createdTime, hostVersion, | 100 // TODO(nicholss): Not yet integrated: createdTime, kind, |
| 101 // kind, offlineReason. Add them as the app will need this info. | 101 // offlineReason. Add them as the app will need this info. |
| 102 HostInfo* host = [[HostInfo alloc] init]; | 102 HostInfo* host = [[HostInfo alloc] init]; |
| 103 host.hostId = | 103 host.hostId = base::SysUTF8ToNSString(host_info.host_id); |
| 104 [NSString stringWithCString:host_info.host_id.c_str() | 104 host.hostName = base::SysUTF8ToNSString(host_info.host_name); |
| 105 encoding:[NSString defaultCStringEncoding]]; | 105 host.hostOs = base::SysUTF8ToNSString(host_info.host_os); |
| 106 host.hostName = | 106 host.hostOsVersion = |
| 107 [NSString stringWithCString:host_info.host_name.c_str() | 107 base::SysUTF8ToNSString(host_info.host_os_version); |
| 108 encoding:[NSString defaultCStringEncoding]]; | 108 host.hostVersion = base::SysUTF8ToNSString(host_info.host_version); |
| 109 host.jabberId = | 109 host.jabberId = base::SysUTF8ToNSString(host_info.host_jid); |
| 110 [NSString stringWithCString:host_info.host_jid.c_str() | 110 host.publicKey = base::SysUTF8ToNSString(host_info.public_key); |
| 111 encoding:[NSString defaultCStringEncoding]]; | 111 host.status = base::SysUTF8ToNSString(status); |
| 112 host.publicKey = | |
| 113 [NSString stringWithCString:host_info.public_key.c_str() | |
| 114 encoding:[NSString defaultCStringEncoding]]; | |
| 115 host.status = | |
| 116 [NSString stringWithCString:status.c_str() | |
| 117 encoding:[NSString defaultCStringEncoding]]; | |
| 118 [hosts addObject:host]; | 112 [hosts addObject:host]; |
| 119 } | 113 } |
| 120 _hosts = hosts; | 114 _hosts = hosts; |
| 121 [self hostListUpdated]; | 115 [self hostListUpdated]; |
| 122 })); | 116 })); |
| 123 } | 117 } |
| 124 | 118 |
| 125 #pragma mark - Notifications | 119 #pragma mark - Notifications |
| 126 | 120 |
| 127 - (void)hostListUpdated { | 121 - (void)hostListUpdated { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 159 } | 153 } |
| 160 | 154 |
| 161 #pragma mark - Implementation | 155 #pragma mark - Implementation |
| 162 | 156 |
| 163 - (void)requestHostListFetch { | 157 - (void)requestHostListFetch { |
| 164 [_authentication | 158 [_authentication |
| 165 callbackWithAccessToken:base::BindBlockArc(^( | 159 callbackWithAccessToken:base::BindBlockArc(^( |
| 166 remoting::OAuthTokenGetter::Status status, | 160 remoting::OAuthTokenGetter::Status status, |
| 167 const std::string& user_email, | 161 const std::string& user_email, |
| 168 const std::string& access_token) { | 162 const std::string& access_token) { |
| 169 NSString* accessToken = | 163 NSString* accessToken = base::SysUTF8ToNSString(access_token); |
| 170 [NSString stringWithCString:access_token.c_str() | |
| 171 encoding:[NSString defaultCStringEncoding]]; | |
| 172 [self startHostListFetchWith:accessToken]; | 164 [self startHostListFetchWith:accessToken]; |
| 173 })]; | 165 })]; |
| 174 } | 166 } |
| 175 | 167 |
| 176 @end | 168 @end |
| OLD | NEW |