Skip to content

Commit

Permalink
Remove XSViewController
Browse files Browse the repository at this point in the history
Starting from OS X 10.10, NSViewController is part of a reponder
chain. XSViewController was used only for that and now can be removed.

Issue #209
  • Loading branch information
eofster committed Apr 22, 2016
1 parent af61f04 commit 5b79477
Show file tree
Hide file tree
Showing 15 changed files with 22 additions and 510 deletions.
28 changes: 0 additions & 28 deletions Telephone.xcodeproj/project.pbxproj
Expand Up @@ -222,8 +222,6 @@
AA86C86110FF928D00EF4E8A /* ActiveCallTransferViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = AA86C86010FF928D00EF4E8A /* ActiveCallTransferViewController.m */; };
AA8A5D2C0E91262500DB43C8 /* AKKeychain.m in Sources */ = {isa = PBXBuildFile; fileRef = AA8A5D2B0E91262500DB43C8 /* AKKeychain.m */; };
AA8BA7F61C04D843008839F2 /* AudioDevices.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA8BA7F51C04D843008839F2 /* AudioDevices.swift */; };
AA8FBAA410A56BD9000946F3 /* XSViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = AA8FBAA110A56BD9000946F3 /* XSViewController.m */; };
AA8FBAA510A56BD9000946F3 /* XSWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = AA8FBAA310A56BD9000946F3 /* XSWindowController.m */; };
AA92F8A41C2B02E700C378B6 /* Ringtone.swift in Sources */ = {isa = PBXBuildFile; fileRef = AA92F8A31C2B02E700C378B6 /* Ringtone.swift */; };
AA97B47610D3A2CA00FC65DA /* CallTransferController.m in Sources */ = {isa = PBXBuildFile; fileRef = AA97B47510D3A2CA00FC65DA /* CallTransferController.m */; };
AA9D081A1BFF7F700000F618 /* Domain.h in Headers */ = {isa = PBXBuildFile; fileRef = AA9D08051BFF7E6F0000F618 /* Domain.h */; settings = {ATTRIBUTES = (Public, ); }; };
Expand Down Expand Up @@ -631,10 +629,6 @@
AA8A5D2A0E91262500DB43C8 /* AKKeychain.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = AKKeychain.h; sourceTree = "<group>"; tabWidth = 4; };
AA8A5D2B0E91262500DB43C8 /* AKKeychain.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = AKKeychain.m; sourceTree = "<group>"; tabWidth = 4; };
AA8BA7F51C04D843008839F2 /* AudioDevices.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AudioDevices.swift; sourceTree = "<group>"; };
AA8FBAA010A56BD9000946F3 /* XSViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XSViewController.h; sourceTree = "<group>"; };
AA8FBAA110A56BD9000946F3 /* XSViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XSViewController.m; sourceTree = "<group>"; wrapsLines = 1; };
AA8FBAA210A56BD9000946F3 /* XSWindowController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XSWindowController.h; sourceTree = "<group>"; };
AA8FBAA310A56BD9000946F3 /* XSWindowController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = XSWindowController.m; sourceTree = "<group>"; wrapsLines = 1; };
AA90D7581BC90F9F0059CC03 /* SystemAudioDeviceRepositoryStub.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SystemAudioDeviceRepositoryStub.swift; sourceTree = "<group>"; };
AA92F8A31C2B02E700C378B6 /* Ringtone.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Ringtone.swift; sourceTree = "<group>"; };
AA97B47410D3A2CA00FC65DA /* CallTransferController.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = CallTransferController.h; sourceTree = "<group>"; tabWidth = 4; };
Expand Down Expand Up @@ -890,7 +884,6 @@
AA9D08101BFF7E6F0000F618 /* DomainTests */,
AAC4FF821C0214120060B186 /* DomainTestDoubles */,
AAF298D70F57477C007B5036 /* AddressBookPlugIns */,
AA4D48FF1BB998EC004D1D4B /* ThirdParty */,
19C28FACFE9D520D11CA2CBB /* Products */,
);
name = Telephone;
Expand Down Expand Up @@ -1065,25 +1058,6 @@
name = "Audio Devices";
sourceTree = "<group>";
};
AA4D48FF1BB998EC004D1D4B /* ThirdParty */ = {
isa = PBXGroup;
children = (
AA4D49011BB999B9004D1D4B /* XSWindowController */,
);
path = ThirdParty;
sourceTree = "<group>";
};
AA4D49011BB999B9004D1D4B /* XSWindowController */ = {
isa = PBXGroup;
children = (
AA8FBAA010A56BD9000946F3 /* XSViewController.h */,
AA8FBAA110A56BD9000946F3 /* XSViewController.m */,
AA8FBAA210A56BD9000946F3 /* XSWindowController.h */,
AA8FBAA310A56BD9000946F3 /* XSWindowController.m */,
);
path = XSWindowController;
sourceTree = "<group>";
};
AA4D490A1BB99DD6004D1D4B /* Frameworks */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -1835,8 +1809,6 @@
AAD92139107A608B00F142A4 /* EndedCallViewController.m in Sources */,
AA32F7FB1BC52A2A00FAC228 /* UserDefaultsKeys.m in Sources */,
AA3FABAB1BBC183B0064B2C3 /* SystemAudioDevices.swift in Sources */,
AA8FBAA410A56BD9000946F3 /* XSViewController.m in Sources */,
AA8FBAA510A56BD9000946F3 /* XSWindowController.m in Sources */,
8A9175991CA59D5C00354E26 /* PJSUAOnIncomingCall.m in Sources */,
AA97B47610D3A2CA00FC65DA /* CallTransferController.m in Sources */,
AA86C86110FF928D00EF4E8A /* ActiveCallTransferViewController.m in Sources */,
Expand Down
5 changes: 3 additions & 2 deletions Telephone/ActiveCallViewController.h
Expand Up @@ -19,12 +19,11 @@
#import <Cocoa/Cocoa.h>

#import "AKActiveCallView.h"
#import "XSViewController.h"


@class AKResponsiveProgressIndicator, CallController;

@interface ActiveCallViewController : XSViewController <AKActiveCallViewDelegate>
@interface ActiveCallViewController : NSViewController <AKActiveCallViewDelegate>

// Call controller the receiver belongs to.
@property(nonatomic, weak) CallController *callController;
Expand Down Expand Up @@ -57,6 +56,8 @@
// Initializes an ActiveCallViewController object with a given nib file and call controller.
- (instancetype)initWithNibName:(NSString *)nibName callController:(CallController *)callController;

- (void)removeObservations;

// Hangs up call.
- (IBAction)hangUpCall:(id)sender;

Expand Down
5 changes: 2 additions & 3 deletions Telephone/ActiveCallViewController.m
Expand Up @@ -30,7 +30,7 @@
@implementation ActiveCallViewController

- (instancetype)initWithNibName:(NSString *)nibName callController:(CallController *)callController {
self = [super initWithNibName:nibName bundle:nil windowController:callController];
self = [super initWithNibName:nibName bundle:nil];

if (self != nil) {
_enteredDTMF = [[NSMutableString alloc] init];
Expand All @@ -48,8 +48,7 @@ - (instancetype)init {
- (void)removeObservations {
[[self displayedNameField] unbind:NSValueBinding];
[[self statusField] unbind:NSValueBinding];
[super removeObservations];
}
}

- (void)awakeFromNib {
[[[self displayedNameField] cell] setBackgroundStyle:NSBackgroundStyleRaised];
Expand Down
2 changes: 0 additions & 2 deletions Telephone/CallController+Protected.h
Expand Up @@ -18,8 +18,6 @@

#import "CallController.h"

@class XSViewController;

@interface CallController (Protected)

- (void)setCallInfoViewResizingWindow:(NSView *)newView;
Expand Down
3 changes: 1 addition & 2 deletions Telephone/CallController.h
Expand Up @@ -19,7 +19,6 @@
#import <Cocoa/Cocoa.h>

#import "AKSIPCall.h"
#import "XSWindowController.h"

#import "CallControllerDelegate.h"

Expand All @@ -30,7 +29,7 @@
@protocol RingtonePlaybackInteractor;

// A call controller.
@interface CallController : XSWindowController <AKSIPCallDelegate> {
@interface CallController : NSWindowController <AKSIPCallDelegate> {
@protected
ActiveCallViewController *_activeCallViewController;
EndedCallViewController *_endedCallViewController;
Expand Down
28 changes: 7 additions & 21 deletions Telephone/CallController.m
Expand Up @@ -388,32 +388,21 @@ - (void)showIncomingCallView {
[self showViewController:self.incomingCallViewController];
}

- (void)showViewController:(XSViewController *)viewController {
- (void)showViewController:(NSViewController *)viewController {
if ([self shouldShowViewController:viewController]) {
[self removeCurrentViewControllerIfNeeded];
[self addViewController:viewController];
[self setCallInfoViewResizingWindow:viewController.view];
}
}

- (BOOL)shouldShowViewController:(XSViewController *)viewController {
return self.countOfViewControllers == 0 || ![[self objectInViewControllersAtIndex:0] isEqual:viewController];
}

- (void)removeCurrentViewControllerIfNeeded {
if (self.countOfViewControllers > 0) {
assert(self.countOfViewControllers == 1);
[self removeObjectFromViewControllersAtIndex:0];
}
- (BOOL)shouldShowViewController:(NSViewController *)viewController {
return ![self.callInfoView isEqual:viewController.view];
}


#pragma mark -
#pragma mark NSWindow delegate methods

- (void)windowWillClose:(NSNotification *)notification {
[super windowWillClose:notification];

if ([self isCallActive]) {
[self setCallActive:NO];
[[self activeCallViewController] stopCallTimer];
Expand All @@ -435,13 +424,10 @@ - (void)windowWillClose:(NSNotification *)notification {
[[NSApp delegate] updateDockTileBadgeLabel];

[self.delegate callControllerWillClose:self];

// View controllers must be nullified because of bindings to callController's |displayedName| and |status|. When
// this is done in -dealloc this is already too late, and KVO error about releaseing an object that is still being
// observied is issued.
_incomingCallViewController = nil;
_activeCallViewController = nil;
_endedCallViewController = nil;

[_incomingCallViewController removeObservations];
[_activeCallViewController removeObservations];
[_endedCallViewController removeObservations];
}


Expand Down
8 changes: 0 additions & 8 deletions Telephone/CallTransferController.m
Expand Up @@ -105,18 +105,10 @@ - (IBAction)showInitialState:(id)sender {
[self closeSheet:self];
}

[self removeViewControllersIfNeeded];
[self showActiveAccountTransferView];
[self makeCallDestinationFieldFirstResponder];
}

- (void)removeViewControllersIfNeeded {
if ([self countOfViewControllers] > 0) {
[[self viewControllers] removeAllObjects];
[self patchResponderChain];
}
}

- (void)showActiveAccountTransferView {
[self setCallInfoViewResizingWindow:[[self activeAccountTransferViewController] view]];
}
Expand Down
9 changes: 4 additions & 5 deletions Telephone/EndedCallViewController.h
Expand Up @@ -18,12 +18,10 @@

#import <Cocoa/Cocoa.h>

#import "XSViewController.h"


@class CallController;

@interface EndedCallViewController : XSViewController
@interface EndedCallViewController : NSViewController

// Call controller the receiver belongs to.
@property(nonatomic, weak) CallController *callController;
Expand All @@ -41,8 +39,9 @@

// Designated initializer.
// Initializes an EndedCallViewController object with a given nib file and call controller.
- (instancetype)initWithNibName:(NSString *)nibName
callController:(CallController *)callController;
- (instancetype)initWithNibName:(NSString *)nibName callController:(CallController *)callController;

- (void)removeObservations;

// Redials a call.
- (IBAction)redial:(id)sender;
Expand Down
3 changes: 1 addition & 2 deletions Telephone/EndedCallViewController.m
Expand Up @@ -24,7 +24,7 @@
@implementation EndedCallViewController

- (instancetype)initWithNibName:(NSString *)nibName callController:(CallController *)callController {
self = [super initWithNibName:nibName bundle:nil windowController:callController];
self = [super initWithNibName:nibName bundle:nil];

if (self != nil) {
[self setCallController:callController];
Expand All @@ -41,7 +41,6 @@ - (instancetype)init {
- (void)removeObservations {
[[self displayedNameField] unbind:NSValueBinding];
[[self statusField] unbind:NSValueBinding];
[super removeObservations];
}

- (void)awakeFromNib {
Expand Down
6 changes: 3 additions & 3 deletions Telephone/IncomingCallViewController.h
Expand Up @@ -18,12 +18,10 @@

#import <Cocoa/Cocoa.h>

#import "XSViewController.h"


@class CallController;

@interface IncomingCallViewController : XSViewController
@interface IncomingCallViewController : NSViewController

// Call controller the receiver belongs to.
@property(nonatomic, weak) CallController *callController;
Expand All @@ -44,6 +42,8 @@
// Initializes an IncomingCallViewController object with a given call controller.
- (instancetype)initWithCallController:(CallController *)callController;

- (void)removeObservations;

// Accepts an incoming call.
- (IBAction)acceptCall:(id)sender;

Expand Down
3 changes: 1 addition & 2 deletions Telephone/IncomingCallViewController.m
Expand Up @@ -27,7 +27,7 @@ @implementation IncomingCallViewController
@synthesize callController = callController_;

- (instancetype)initWithCallController:(CallController *)callController {
self = [super initWithNibName:@"IncomingCallView" bundle:nil windowController:callController];
self = [super initWithNibName:@"IncomingCallView" bundle:nil];

if (self != nil) {
[self setCallController:callController];
Expand All @@ -44,7 +44,6 @@ - (instancetype)init {
- (void)removeObservations {
[[self displayedNameField] unbind:NSValueBinding];
[[self statusField] unbind:NSValueBinding];
[super removeObservations];
}

- (void)awakeFromNib {
Expand Down
66 changes: 0 additions & 66 deletions ThirdParty/XSWindowController/XSViewController.h

This file was deleted.

0 comments on commit 5b79477

Please sign in to comment.