1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #if !defined(__has_feature) || !__has_feature(objc_arc)
6 #error "This file requires ARC support."
9 #import "remoting/ios/host.h"
13 @synthesize createdTime = _createdTime;
14 @synthesize hostId = _hostId;
15 @synthesize hostName = _hostName;
16 @synthesize hostVersion = _hostVersion;
17 @synthesize jabberId = _jabberId;
18 @synthesize kind = _kind;
19 @synthesize publicKey = _publicKey;
20 @synthesize status = _status;
21 @synthesize updatedTime = _updatedTime;
23 // Parse jsonData into Host list
24 + (NSMutableArray*)parseListFromJSON:(NSMutableData*)data {
27 NSDictionary* json = [NSJSONSerialization JSONObjectWithData:data
31 NSDictionary* dataDict = [json objectForKey:@"data"];
33 NSArray* availableServers = [dataDict objectForKey:@"items"];
35 NSMutableArray* serverList = [[NSMutableArray alloc] init];
39 NSUInteger count = [availableServers count];
42 svr = [availableServers objectAtIndex:idx++];
43 Host* host = [[Host alloc] init];
44 host.createdTime = [svr objectForKey:@"createdTime"];
45 host.hostId = [svr objectForKey:@"hostId"];
46 host.hostName = [svr objectForKey:@"hostName"];
47 host.hostVersion = [svr objectForKey:@"hostVersion"];
48 host.jabberId = [svr objectForKey:@"jabberId"];
49 host.kind = [svr objectForKey:@"kind"];
50 host.publicKey = [svr objectForKey:@"publicKey"];
51 host.status = [svr objectForKey:@"status"];
52 host.updatedTime = [svr objectForKey:@"updatedTime"];
53 [serverList addObject:host];