FreeRDP
GlobalDefaults.m
1 /*
2  Global default bookmark settings
3 
4  Copyright 2013 Thincast Technologies GmbH, Author: Dorian Johnson
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 "GlobalDefaults.h"
12 #import "Bookmark.h"
13 #import "ConnectionParams.h"
14 
15 @implementation GlobalDefaults
16 
17 + (GlobalDefaults *)sharedGlobalDefaults
18 {
19  static GlobalDefaults *_shared_global_defaults = nil;
20 
21  if (_shared_global_defaults == nil)
22  {
23  @synchronized(self)
24  {
25  if (_shared_global_defaults == nil)
26  _shared_global_defaults = [[GlobalDefaults alloc] init];
27  }
28  }
29 
30  return _shared_global_defaults;
31 }
32 
33 - (id)init
34 {
35  if (!(self = [super init]))
36  return nil;
37 
38  ComputerBookmark *bookmark = nil;
39  NSData *bookmark_data =
40  [[NSUserDefaults standardUserDefaults] objectForKey:@"TSXSharedGlobalDefaultBookmark"];
41 
42  if (bookmark_data && [bookmark_data length])
43  bookmark = [NSKeyedUnarchiver unarchiveObjectWithData:bookmark_data];
44 
45  if (!bookmark)
46  bookmark = [[[ComputerBookmark alloc] initWithBaseDefaultParameters] autorelease];
47 
48  _default_bookmark = [bookmark retain];
49  return self;
50 }
51 
52 - (void)dealloc
53 {
54  [_default_bookmark release];
55  [super dealloc];
56 }
57 
58 #pragma mark -
59 
60 @synthesize bookmark = _default_bookmark;
61 
62 - (ComputerBookmark *)newBookmark
63 {
64  return [[ComputerBookmark alloc] initWithConnectionParameters:[[self newParams] autorelease]];
65 }
66 
67 - (ConnectionParams *)newParams
68 {
69  ConnectionParams *param_copy = [[[self bookmark] params] copy];
70  return param_copy;
71 }
72 
73 - (ComputerBookmark *)newTestServerBookmark
74 {
75  ComputerBookmark *bm = [self newBookmark];
76  [bm setLabel:@"Test Server"];
77  [[bm params] setValue:@"testservice.ifreerdp.com" forKey:@"hostname"];
78  [[bm params] setInt:0 forKey:@"screen_resolution_type"];
79  [[bm params] setInt:1024 forKey:@"width"];
80  [[bm params] setInt:768 forKey:@"height"];
81  [[bm params] setInt:32 forKey:@"colors"];
82  [[bm params] setBool:YES forKey:@"perf_remotefx"];
83  [[bm params] setBool:YES forKey:@"perf_gfx"];
84  [[bm params] setBool:YES forKey:@"perf_h264"];
85  return bm;
86 }
87 
88 @end