| | 34 | #import "WCSettings.h" |
|---|
| | 35 | |
|---|
| | 36 | @interface WCConnectionController(Private) |
|---|
| | 37 | |
|---|
| | 38 | - (void)_loadWindowTemplate; |
|---|
| | 39 | - (void)_saveWindowTemplate; |
|---|
| | 40 | |
|---|
| | 41 | @end |
|---|
| | 42 | |
|---|
| | 43 | |
|---|
| | 44 | |
|---|
| | 45 | @implementation WCConnectionController(Private) |
|---|
| | 46 | |
|---|
| | 47 | - (void)_loadWindowTemplate { |
|---|
| | 48 | NSDictionary *windowTemplate; |
|---|
| | 49 | |
|---|
| | 50 | if([[self connection] bookmark]) |
|---|
| | 51 | windowTemplate = [WCSettings windowTemplateForKey:[[[self connection] bookmark] objectForKey:WCBookmarksIdentifier]]; |
|---|
| | 52 | else |
|---|
| | 53 | windowTemplate = [WCSettings windowTemplateForKey:[[[self connection] URL] hostpair]]; |
|---|
| | 54 | |
|---|
| | 55 | if(!windowTemplate) |
|---|
| | 56 | windowTemplate = [WCSettings windowTemplateForKey:WCWindowTemplatesDefault]; |
|---|
| | 57 | |
|---|
| | 58 | if(windowTemplate) |
|---|
| | 59 | _windowTemplate = [windowTemplate mutableCopy]; |
|---|
| | 60 | else |
|---|
| | 61 | _windowTemplate = [[NSMutableDictionary alloc] init]; |
|---|
| | 62 | |
|---|
| | 63 | [self windowTemplateShouldLoad:_windowTemplate]; |
|---|
| | 64 | } |
|---|
| | 65 | |
|---|
| | 66 | |
|---|
| | 67 | |
|---|
| | 68 | - (void)_saveWindowTemplate { |
|---|
| | 69 | [self windowTemplateShouldSave:_windowTemplate]; |
|---|
| | 70 | |
|---|
| | 71 | if([[self connection] bookmark]) |
|---|
| | 72 | [WCSettings setWindowTemplate:_windowTemplate forKey:[[[self connection] bookmark] objectForKey:WCBookmarksIdentifier]]; |
|---|
| | 73 | else |
|---|
| | 74 | [WCSettings setWindowTemplate:_windowTemplate forKey:[[[self connection] URL] hostpair]]; |
|---|
| | 75 | } |
|---|
| | 76 | |
|---|
| | 77 | @end |
|---|
| | 78 | |
|---|
| 37 | | - (id)initWithWindowNibName:(NSString *)windowNibName connection:(WCServerConnection *)connection { |
|---|
| 38 | | return [self initWithWindowNibName:windowNibName name:NULL connection:connection]; |
|---|
| 39 | | } |
|---|
| 40 | | |
|---|
| 41 | | |
|---|
| 42 | | |
|---|
| 43 | | - (id)initWithWindowNibName:(NSString *)windowNibName name:(NSString *)name connection:(WCServerConnection *)connection { |
|---|
| 44 | | self = [super initWithWindowNibName:windowNibName]; |
|---|
| | 82 | - (id)initWithWindowNibName:(NSString *)nibName connection:(WCServerConnection *)connection { |
|---|
| | 83 | return [self initWithWindowNibName:nibName name:NULL connection:connection]; |
|---|
| | 84 | } |
|---|
| | 85 | |
|---|
| | 86 | |
|---|
| | 87 | |
|---|
| | 88 | - (id)initWithWindowNibName:(NSString *)nibName name:(NSString *)name connection:(WCServerConnection *)connection { |
|---|
| | 89 | self = [super initWithWindowNibName:nibName]; |
|---|
| | 106 | } |
|---|
| | 107 | |
|---|
| | 108 | if([self respondsToSelector:@selector(connectionWillTerminate:)]) { |
|---|
| | 109 | [_connection addObserver:self |
|---|
| | 110 | selector:@selector(connectionWillTerminate:) |
|---|
| | 111 | name:WCConnectionWillTerminate]; |
|---|
| | 112 | } |
|---|
| | 113 | |
|---|
| | 114 | if([self respondsToSelector:@selector(connectionDidTerminate:)]) { |
|---|
| | 115 | [_connection addObserver:self |
|---|
| | 116 | selector:@selector(connectionDidTerminate:) |
|---|
| | 117 | name:WCConnectionDidTerminate]; |
|---|
| | 118 | } |
|---|
| | 119 | |
|---|
| | 120 | if([self respondsToSelector:@selector(serverConnectionLoggedIn:)]) { |
|---|
| | 121 | [_connection addObserver:self |
|---|
| | 122 | selector:@selector(serverConnectionLoggedIn:) |
|---|
| | 123 | name:WCServerConnectionLoggedIn]; |
|---|
| | 124 | } |
|---|
| | 125 | |
|---|
| | 126 | if([self respondsToSelector:@selector(serverConnectionWillReconnect:)]) { |
|---|
| | 127 | [_connection addObserver:self |
|---|
| | 128 | selector:@selector(serverConnectionWillReconnect:) |
|---|
| | 129 | name:WCServerConnectionWillReconnect]; |
|---|
| | 130 | } |
|---|
| | 131 | |
|---|
| | 132 | if([self respondsToSelector:@selector(serverConnectionServerInfoDidChange:)]) { |
|---|
| | 133 | [_connection addObserver:self |
|---|
| | 134 | selector:@selector(serverConnectionServerInfoDidChange:) |
|---|
| | 135 | name:WCServerConnectionServerInfoDidChange]; |
|---|
| | 136 | } |
|---|
| | 137 | |
|---|
| | 138 | if([self respondsToSelector:@selector(serverConnectionBannerDidChange:)]) { |
|---|
| | 139 | [_connection addObserver:self |
|---|
| | 140 | selector:@selector(serverConnectionBannerDidChange:) |
|---|
| | 141 | name:WCServerConnectionBannerDidChange]; |
|---|
| | 142 | } |
|---|
| | 143 | |
|---|
| | 144 | if([self respondsToSelector:@selector(serverConnectionPrivilegesDidChange:)]) { |
|---|
| | 145 | [_connection addObserver:self |
|---|
| | 146 | selector:@selector(serverConnectionPrivilegesDidChange:) |
|---|
| | 147 | name:WCServerConnectionPrivilegesDidChange]; |
|---|
| 65 | | if([self respondsToSelector:@selector(connectionWillTerminate:)]) { |
|---|
| 66 | | [_connection addObserver:self |
|---|
| 67 | | selector:@selector(connectionWillTerminate:) |
|---|
| 68 | | name:WCConnectionWillTerminate]; |
|---|
| 69 | | } |
|---|
| 70 | | |
|---|
| 71 | | if([self respondsToSelector:@selector(connectionDidTerminate:)]) { |
|---|
| 72 | | [_connection addObserver:self |
|---|
| 73 | | selector:@selector(connectionDidTerminate:) |
|---|
| 74 | | name:WCConnectionDidTerminate]; |
|---|
| 75 | | } |
|---|
| 76 | | |
|---|
| 77 | | if([self respondsToSelector:@selector(serverConnectionLoggedIn:)]) { |
|---|
| 78 | | [_connection addObserver:self |
|---|
| 79 | | selector:@selector(serverConnectionLoggedIn:) |
|---|
| 80 | | name:WCServerConnectionLoggedIn]; |
|---|
| 81 | | } |
|---|
| 82 | | |
|---|
| 83 | | if([self respondsToSelector:@selector(serverConnectionWillReconnect:)]) { |
|---|
| 84 | | [_connection addObserver:self |
|---|
| 85 | | selector:@selector(serverConnectionWillReconnect:) |
|---|
| 86 | | name:WCServerConnectionWillReconnect]; |
|---|
| 87 | | } |
|---|
| 88 | | |
|---|
| 89 | | if([self respondsToSelector:@selector(serverConnectionServerInfoDidChange:)]) { |
|---|
| 90 | | [_connection addObserver:self |
|---|
| 91 | | selector:@selector(serverConnectionServerInfoDidChange:) |
|---|
| 92 | | name:WCServerConnectionServerInfoDidChange]; |
|---|
| 93 | | } |
|---|
| 94 | | |
|---|
| 95 | | if([self respondsToSelector:@selector(serverConnectionBannerDidChange:)]) { |
|---|
| 96 | | [_connection addObserver:self |
|---|
| 97 | | selector:@selector(serverConnectionBannerDidChange:) |
|---|
| 98 | | name:WCServerConnectionBannerDidChange]; |
|---|
| 99 | | } |
|---|
| 100 | | |
|---|
| 101 | | if([self respondsToSelector:@selector(serverConnectionPrivilegesDidChange:)]) { |
|---|
| 102 | | [_connection addObserver:self |
|---|
| 103 | | selector:@selector(serverConnectionPrivilegesDidChange:) |
|---|
| 104 | | name:WCServerConnectionPrivilegesDidChange]; |
|---|
| 105 | | } |
|---|
| 106 | | |
|---|