1/*
2 *  Copyright 2014 The WebRTC Project Authors. All rights reserved.
3 *
4 *  Use of this source code is governed by a BSD-style license
5 *  that can be found in the LICENSE file in the root of the source
6 *  tree. An additional intellectual property rights grant can be found
7 *  in the file PATENTS.  All contributing project authors may
8 *  be found in the AUTHORS file in the root of the source tree.
9 */
10
11#import "APPRTCAppDelegate.h"
12#import "APPRTCViewController.h"
13#import <WebRTC/RTCSSLAdapter.h>
14
15@interface APPRTCAppDelegate () <NSWindowDelegate>
16@end
17
18@implementation APPRTCAppDelegate {
19  APPRTCViewController* _viewController;
20  NSWindow* _window;
21}
22
23#pragma mark - NSApplicationDelegate
24
25- (void)applicationDidFinishLaunching:(NSNotification*)notification {
26  RTCInitializeSSL();
27  NSScreen* screen = [NSScreen mainScreen];
28  NSRect visibleRect = [screen visibleFrame];
29  NSRect windowRect = NSMakeRect(NSMidX(visibleRect),
30                                 NSMidY(visibleRect),
31                                 1320,
32                                 1140);
33  NSUInteger styleMask = NSTitledWindowMask | NSClosableWindowMask;
34  _window = [[NSWindow alloc] initWithContentRect:windowRect
35                                        styleMask:styleMask
36                                          backing:NSBackingStoreBuffered
37                                            defer:NO];
38  _window.delegate = self;
39  [_window makeKeyAndOrderFront:self];
40  [_window makeMainWindow];
41  _viewController = [[APPRTCViewController alloc] initWithNibName:nil
42                                                           bundle:nil];
43  [_window setContentView:[_viewController view]];
44}
45
46#pragma mark - NSWindow
47
48- (void)windowWillClose:(NSNotification*)notification {
49  [_viewController windowWillClose:notification];
50  RTCCleanupSSL();
51  [NSApp terminate:self];
52}
53
54@end
55
56