Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 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 | |
Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 11 | #import "APPRTCAppDelegate.h" |
Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 12 | #import "APPRTCViewController.h" |
Anders Carlsson | 7bca8ca | 2018-08-30 09:30:29 +0200 | [diff] [blame] | 13 | #import <WebRTC/RTCSSLAdapter.h> |
Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 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 { |
hjon | 79858f8 | 2016-03-13 22:08:26 -0700 | [diff] [blame] | 26 | RTCInitializeSSL(); |
Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 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]; |
hjon | 79858f8 | 2016-03-13 22:08:26 -0700 | [diff] [blame] | 50 | RTCCleanupSSL(); |
Donald E Curtis | a873644 | 2015-08-05 15:48:13 -0700 | [diff] [blame] | 51 | [NSApp terminate:self]; |
| 52 | } |
| 53 | |
| 54 | @end |
| 55 | |