Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

120 columns in call controllers and views

  • Loading branch information...
commit c4b36e9dceda7ffd4774e304b0ae5e691c535620 1 parent b53c9a4
@eofster authored
View
13 Classes/AKActiveCallView.h
@@ -33,16 +33,16 @@
@protocol AKActiveCallViewDelegate;
-// The AKActiveCallView class receives DTMF digits |0123456789*#| and control
-// characters |mh| from the keyboard. It gives its delegate a chance to get
-// those DTMF digits and it sends control characters further.
+// The AKActiveCallView class receives DTMF digits |0123456789*#| and control characters |mh| from the keyboard. It
+// gives its delegate a chance to get those DTMF digits and it sends control characters further.
@interface AKActiveCallView : NSView {
- @private
- id <AKActiveCallViewDelegate> delegate_;
+ @private
+ id <AKActiveCallViewDelegate> delegate_;
}
// The receiver's delegate.
@property (nonatomic, assign) IBOutlet id <AKActiveCallViewDelegate> delegate;
+
@end
// Declares the interface that AKActiveCallView delegates must implement.
@@ -50,6 +50,5 @@
@optional
// Sent when a view receives text input from the keyboard.
// Now it handles only DTMF digits |0123456789*#|.
-- (void)activeCallView:(AKActiveCallView *)sender
- didReceiveText:(NSString *)aString;
+- (void)activeCallView:(AKActiveCallView *)sender didReceiveText:(NSString *)aString;
@end
View
51 Classes/AKActiveCallView.m
@@ -36,40 +36,37 @@ @implementation AKActiveCallView
@synthesize delegate = delegate_;
- (BOOL)acceptsFirstResponder {
- return YES;
+ return YES;
}
- (void)keyDown:(NSEvent *)theEvent {
- NSCharacterSet *DTMFCharacterSet
- = [NSCharacterSet characterSetWithCharactersInString:@"0123456789*#"];
- NSCharacterSet *commandsCharacterSet
- = [NSCharacterSet characterSetWithCharactersInString:@"mh"];
-
- unichar firstCharacter = [[theEvent characters] characterAtIndex:0];
- if ([DTMFCharacterSet characterIsMember:firstCharacter]) {
- if (![theEvent isARepeat]) {
- // We want to get DTMF string as text.
- [self interpretKeyEvents:[NSArray arrayWithObject:theEvent]];
+ NSCharacterSet *DTMFCharacterSet = [NSCharacterSet characterSetWithCharactersInString:@"0123456789*#"];
+ NSCharacterSet *commandsCharacterSet = [NSCharacterSet characterSetWithCharactersInString:@"mh"];
+
+ unichar firstCharacter = [[theEvent characters] characterAtIndex:0];
+ if ([DTMFCharacterSet characterIsMember:firstCharacter]) {
+ if (![theEvent isARepeat]) {
+ // We want to get DTMF string as text.
+ [self interpretKeyEvents:[NSArray arrayWithObject:theEvent]];
+ }
+ } else if ([commandsCharacterSet characterIsMember:firstCharacter]) {
+ if (![theEvent isARepeat]) {
+ // Pass call control commands further so that main menu will catch them.
+ // The corresponding key equivalents must be set in the main menu.
+ // We need this because we have key equivalents without modifiers,
+ // in which case NSApplication can't recognize them and can't dispatch
+ // appropriate events before we even get here.
+ [super keyDown:theEvent];
+ }
+ } else {
+ [super keyDown:theEvent];
}
- } else if ([commandsCharacterSet characterIsMember:firstCharacter]) {
- if (![theEvent isARepeat]) {
- // Pass call control commands further so that main menu will catch them.
- // The corresponding key equivalents must be set in the main menu.
- // We need this because we have key equivalents without modifiers,
- // in which case NSApplication can't recognize them and can't dispatch
- // appropriate events before we even get here.
- [super keyDown:theEvent];
- }
- } else {
- [super keyDown:theEvent];
- }
}
- (void)insertText:(id)aString {
- if ([[self delegate] respondsToSelector:
- @selector(activeCallView:didReceiveText:)]) {
- [[self delegate] activeCallView:self didReceiveText:aString];
- }
+ if ([[self delegate] respondsToSelector:@selector(activeCallView:didReceiveText:)]) {
+ [[self delegate] activeCallView:self didReceiveText:aString];
+ }
}
@end
View
9 Classes/AKResponsiveProgressIndicator.h
@@ -31,12 +31,11 @@
#import <Cocoa/Cocoa.h>
-// Allows progress indicator to send an action message to a target on mouse-up
-// events.
+// Allows progress indicator to send an action message to a target on mouse-up events.
@interface AKResponsiveProgressIndicator : NSProgressIndicator {
- @private
- id target_;
- SEL action_;
+ @private
+ id target_;
+ SEL action_;
}
// The receiver's target.
View
2  Classes/AKResponsiveProgressIndicator.m
@@ -37,7 +37,7 @@ @implementation AKResponsiveProgressIndicator
@synthesize action = action_;
- (void)mouseUp:(NSEvent *)theEvent {
- [NSApp sendAction:[self action] to:[self target] from:self];
+ [NSApp sendAction:[self action] to:[self target] from:self];
}
@end
View
49 Classes/ActiveAccountTransferViewController.m
@@ -35,38 +35,35 @@ @implementation ActiveAccountTransferViewController
- (id)initWithAccountController:(AccountController *)anAccountController
windowController:(XSWindowController *)windowController {
-
- self = [super initWithNibName:@"ActiveAccountTransferView"
- bundle:nil
- windowController:windowController];
-
- if (self != nil) {
- [self setAccountController:anAccountController];
- }
- return self;
+
+ self = [super initWithNibName:@"ActiveAccountTransferView" bundle:nil windowController:windowController];
+
+ if (self != nil) {
+ [self setAccountController:anAccountController];
+ }
+ return self;
}
- (IBAction)makeCallToTransferDestination:(id)sender {
- if ([[[self callDestinationField] objectValue] count] == 0) {
- return;
- }
-
- NSDictionary *callDestinationDict
- = [[[[self callDestinationField] objectValue] objectAtIndex:0]
- objectAtIndex:[self callDestinationURIIndex]];
-
- NSString *phoneLabel = [callDestinationDict objectForKey:kPhoneLabel];
-
- AKSIPURI *uri = [self callDestinationURI];
- if (uri != nil) {
- [[self accountController] makeCallToURI:uri
- phoneLabel:phoneLabel
- callTransferController:[[sender window] windowController]];
- }
+ if ([[[self callDestinationField] objectValue] count] == 0) {
+ return;
+ }
+
+ NSDictionary *callDestinationDict = [[[[self callDestinationField] objectValue] objectAtIndex:0]
+ objectAtIndex:[self callDestinationURIIndex]];
+
+ NSString *phoneLabel = [callDestinationDict objectForKey:kPhoneLabel];
+
+ AKSIPURI *uri = [self callDestinationURI];
+ if (uri != nil) {
+ [[self accountController] makeCallToURI:uri
+ phoneLabel:phoneLabel
+ callTransferController:[[sender window] windowController]];
+ }
}
- (IBAction)makeCall:(id)sender {
- return;
+ return;
}
@end
View
4 Classes/ActiveCallTransferViewController.h
@@ -35,8 +35,8 @@
// An active call controller of a call transfer.
@interface ActiveCallTransferViewController : ActiveCallViewController {
- @private
- NSButton *transferButton_;
+ @private
+ NSButton *transferButton_;
}
// Call transfer button.
View
32 Classes/ActiveCallTransferViewController.m
@@ -40,26 +40,26 @@ @implementation ActiveCallTransferViewController
@synthesize transferButton = transferButton_;
- (void)dealloc {
- [transferButton_ release];
- [super dealloc];
+ [transferButton_ release];
+ [super dealloc];
}
- (void)awakeFromNib {
- [super awakeFromNib];
-
- [[[self displayedNameField] cell] setBackgroundStyle:NSBackgroundStyleLight];
- [[[self statusField] cell] setBackgroundStyle:NSBackgroundStyleLight];
+ [super awakeFromNib];
+
+ [[[self displayedNameField] cell] setBackgroundStyle:NSBackgroundStyleLight];
+ [[[self statusField] cell] setBackgroundStyle:NSBackgroundStyleLight];
}
- (IBAction)transferCall:(id)sender {
- if (![[self callController] isCallOnHold]) {
- [[self callController] toggleCallHold];
- }
- [(CallTransferController *)[self callController] transferCall];
+ if (![[self callController] isCallOnHold]) {
+ [[self callController] toggleCallHold];
+ }
+ [(CallTransferController *)[self callController] transferCall];
}
- (IBAction)showCallTransferSheet:(id)sender {
- // Do nothing.
+ // Do nothing.
}
@@ -67,11 +67,11 @@ - (IBAction)showCallTransferSheet:(id)sender {
#pragma mark NSMenuValidation protocol
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem {
- if ([menuItem action] == @selector(showCallTransferSheet:)) {
- return NO;
- }
-
- return [super validateMenuItem:menuItem];
+ if ([menuItem action] == @selector(showCallTransferSheet:)) {
+ return NO;
+ }
+
+ return [super validateMenuItem:menuItem];
}
@end
View
30 Classes/ActiveCallViewController.h
@@ -37,16 +37,16 @@
@class AKResponsiveProgressIndicator, CallController;
@interface ActiveCallViewController : XSViewController <AKActiveCallViewDelegate> {
- @private
- CallController *callController_;
- NSTimer *callTimer_;
- NSMutableString *enteredDTMF_;
- NSTrackingArea *callProgressIndicatorTrackingArea_;
-
- NSTextField *displayedNameField_;
- NSTextField *statusField_;
- AKResponsiveProgressIndicator *callProgressIndicator_;
- NSButton *hangUpButton_;
+ @private
+ CallController *callController_;
+ NSTimer *callTimer_;
+ NSMutableString *enteredDTMF_;
+ NSTrackingArea *callProgressIndicatorTrackingArea_;
+
+ NSTextField *displayedNameField_;
+ NSTextField *statusField_;
+ AKResponsiveProgressIndicator *callProgressIndicator_;
+ NSButton *hangUpButton_;
}
// Call controller the receiver belongs to.
@@ -58,8 +58,8 @@
// DTMF digits entered by a user.
@property (nonatomic, retain) NSMutableString *enteredDTMF;
-// Tracking area to monitor a mouse hovering call progress indicator. When mouse
-// enters that area, progress indicator is being replaced with hang-up button.
+// Tracking area to monitor a mouse hovering call progress indicator. When mouse enters that area, progress indicator
+// is being replaced with hang-up button.
@property (nonatomic, retain) NSTrackingArea *callProgressIndicatorTrackingArea;
@@ -77,10 +77,8 @@
// Designated initializer.
-// Initializes an ActiveCallViewController object with a given nib file and call
-// controller.
-- (id)initWithNibName:(NSString *)nibName
- callController:(CallController *)callController;
+// Initializes an ActiveCallViewController object with a given nib file and call controller.
+- (id)initWithNibName:(NSString *)nibName callController:(CallController *)callController;
// Hangs up call.
- (IBAction)hangUpCall:(id)sender;
View
356 Classes/ActiveCallViewController.m
@@ -51,144 +51,133 @@ @implementation ActiveCallViewController
@synthesize callProgressIndicator = callProgressIndicator_;
@synthesize hangUpButton = hangUpButton_;
-- (id)initWithNibName:(NSString *)nibName
- callController:(CallController *)callController {
-
- self = [super initWithNibName:nibName
- bundle:nil
- windowController:callController];
-
- if (self != nil) {
- enteredDTMF_ = [[NSMutableString alloc] init];
- [self setCallController:callController];
- }
- return self;
+- (id)initWithNibName:(NSString *)nibName callController:(CallController *)callController {
+ self = [super initWithNibName:nibName bundle:nil windowController:callController];
+
+ if (self != nil) {
+ enteredDTMF_ = [[NSMutableString alloc] init];
+ [self setCallController:callController];
+ }
+ return self;
}
- (id)init {
- [self dealloc];
- NSString *reason
- = @"Initialize ActiveCallViewController with initWithCallController:";
- @throw [NSException exceptionWithName:@"AKBadInitCall"
- reason:reason
- userInfo:nil];
- return nil;
+ [self dealloc];
+ NSString *reason = @"Initialize ActiveCallViewController with initWithCallController:";
+ @throw [NSException exceptionWithName:@"AKBadInitCall" reason:reason userInfo:nil];
+ return nil;
}
- (void)dealloc {
- [enteredDTMF_ release];
- [callProgressIndicatorTrackingArea_ release];
-
- [displayedNameField_ release];
- [statusField_ release];
- [callProgressIndicator_ release];
- [hangUpButton_ release];
-
- [super dealloc];
+ [enteredDTMF_ release];
+ [callProgressIndicatorTrackingArea_ release];
+
+ [displayedNameField_ release];
+ [statusField_ release];
+ [callProgressIndicator_ release];
+ [hangUpButton_ release];
+
+ [super dealloc];
}
- (void)removeObservations {
- [[self displayedNameField] unbind:NSValueBinding];
- [[self statusField] unbind:NSValueBinding];
- [super removeObservations];
+ [[self displayedNameField] unbind:NSValueBinding];
+ [[self statusField] unbind:NSValueBinding];
+ [super removeObservations];
}
- (void)awakeFromNib {
- [[[self displayedNameField] cell] setBackgroundStyle:NSBackgroundStyleRaised];
- [[[self statusField] cell] setBackgroundStyle:NSBackgroundStyleRaised];
- [[self callProgressIndicator] startAnimation:self];
-
- // Set hang-up button origin manually.
- NSRect hangUpButtonFrame = [[self hangUpButton] frame];
- NSRect progressIndicatorFrame = [[self callProgressIndicator] frame];
- hangUpButtonFrame.origin.x = progressIndicatorFrame.origin.x + 1;
- hangUpButtonFrame.origin.y = progressIndicatorFrame.origin.y + 1;
- [[self hangUpButton] setFrame:hangUpButtonFrame];
-
- // Add mouse tracking area to switch between call progress indicator and a
- // hang-up button in the active call view.
- NSRect trackingRect = [[self callProgressIndicator] frame];
-
- NSUInteger trackingOptions
- = NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways;
-
- NSTrackingArea *trackingArea = [[[NSTrackingArea alloc]
- initWithRect:trackingRect
- options:trackingOptions
- owner:self
- userInfo:nil]
- autorelease];
-
- [[self view] addTrackingArea:trackingArea];
- [self setCallProgressIndicatorTrackingArea:trackingArea];
-
- // Add support for clicking call progress indicator to hang-up.
- [[self callProgressIndicator] setTarget:self];
- [[self callProgressIndicator] setAction:@selector(hangUpCall:)];
+ [[[self displayedNameField] cell] setBackgroundStyle:NSBackgroundStyleRaised];
+ [[[self statusField] cell] setBackgroundStyle:NSBackgroundStyleRaised];
+ [[self callProgressIndicator] startAnimation:self];
+
+ // Set hang-up button origin manually.
+ NSRect hangUpButtonFrame = [[self hangUpButton] frame];
+ NSRect progressIndicatorFrame = [[self callProgressIndicator] frame];
+ hangUpButtonFrame.origin.x = progressIndicatorFrame.origin.x + 1;
+ hangUpButtonFrame.origin.y = progressIndicatorFrame.origin.y + 1;
+ [[self hangUpButton] setFrame:hangUpButtonFrame];
+
+ // Add mouse tracking area to switch between call progress indicator and a hang-up button in the active call view.
+ NSRect trackingRect = [[self callProgressIndicator] frame];
+
+ NSUInteger trackingOptions = NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways;
+
+ NSTrackingArea *trackingArea = [[[NSTrackingArea alloc] initWithRect:trackingRect
+ options:trackingOptions
+ owner:self
+ userInfo:nil]
+ autorelease];
+
+ [[self view] addTrackingArea:trackingArea];
+ [self setCallProgressIndicatorTrackingArea:trackingArea];
+
+ // Add support for clicking call progress indicator to hang-up.
+ [[self callProgressIndicator] setTarget:self];
+ [[self callProgressIndicator] setAction:@selector(hangUpCall:)];
}
- (IBAction)hangUpCall:(id)sender {
- [[self callController] hangUpCall];
+ [[self callController] hangUpCall];
}
- (IBAction)toggleCallHold:(id)sender {
- [[self callController] toggleCallHold];
+ [[self callController] toggleCallHold];
}
- (IBAction)toggleMicrophoneMute:(id)sender {
- [[self callController] toggleMicrophoneMute];
+ [[self callController] toggleMicrophoneMute];
}
- (IBAction)showCallTransferSheet:(id)sender {
- if (![[self callController] isCallOnHold]) {
- [[self callController] toggleCallHold];
- }
-
- CallTransferController *callTransferController
- = [[self callController] callTransferController];
-
- [NSApp beginSheet:[callTransferController window]
- modalForWindow:[[self callController] window]
- modalDelegate:nil
- didEndSelector:NULL
- contextInfo:NULL];
+ if (![[self callController] isCallOnHold]) {
+ [[self callController] toggleCallHold];
+ }
+
+ CallTransferController *callTransferController = [[self callController] callTransferController];
+
+ [NSApp beginSheet:[callTransferController window]
+ modalForWindow:[[self callController] window]
+ modalDelegate:nil
+ didEndSelector:NULL
+ contextInfo:NULL];
}
- (void)startCallTimer {
- if ([self callTimer] != nil && [[self callTimer] isValid]) {
- return;
- }
-
- [self setCallTimer:
- [NSTimer scheduledTimerWithTimeInterval:0.2
- target:self
- selector:@selector(callTimerTick:)
- userInfo:nil
- repeats:YES]];
+ if ([self callTimer] != nil && [[self callTimer] isValid]) {
+ return;
+ }
+
+ [self setCallTimer:
+ [NSTimer scheduledTimerWithTimeInterval:0.2
+ target:self
+ selector:@selector(callTimerTick:)
+ userInfo:nil
+ repeats:YES]];
}
- (void)stopCallTimer {
- if ([self callTimer] != nil) {
- [[self callTimer] invalidate];
- [self setCallTimer:nil];
- }
+ if ([self callTimer] != nil) {
+ [[self callTimer] invalidate];
+ [self setCallTimer:nil];
+ }
}
- (void)callTimerTick:(NSTimer *)theTimer {
- NSTimeInterval now = [NSDate timeIntervalSinceReferenceDate];
- NSInteger seconds = (NSInteger)(now - ([[self callController] callStartTime]));
-
- if (seconds < 3600) {
- [[self callController] setStatus:[NSString stringWithFormat:@"%02d:%02d",
- (seconds / 60) % 60,
- seconds % 60]];
- } else {
- [[self callController]
- setStatus:[NSString stringWithFormat:@"%02d:%02d:%02d",
- (seconds / 3600) % 24,
- (seconds / 60) % 60,
- seconds % 60]];
- }
+ NSTimeInterval now = [NSDate timeIntervalSinceReferenceDate];
+ NSInteger seconds = (NSInteger)(now - ([[self callController] callStartTime]));
+
+ if (seconds < 3600) {
+ [[self callController] setStatus:[NSString stringWithFormat:@"%02d:%02d",
+ (seconds / 60) % 60,
+ seconds % 60]];
+ } else {
+ [[self callController]
+ setStatus:[NSString stringWithFormat:@"%02d:%02d:%02d",
+ (seconds / 3600) % 24,
+ (seconds / 60) % 60,
+ seconds % 60]];
+ }
}
@@ -196,56 +185,50 @@ - (void)callTimerTick:(NSTimer *)theTimer {
#pragma mark NSResponder overrides
- (void)mouseEntered:(NSEvent *)theEvent {
- [[self view] replaceSubview:[self callProgressIndicator]
- with:[self hangUpButton]];
+ [[self view] replaceSubview:[self callProgressIndicator]
+ with:[self hangUpButton]];
}
- (void)mouseExited:(NSEvent *)theEvent {
- [[self view] replaceSubview:[self hangUpButton]
- with:[self callProgressIndicator]];
+ [[self view] replaceSubview:[self hangUpButton]
+ with:[self callProgressIndicator]];
}
#pragma mark -
#pragma mark AKActiveCallViewDelegate protocol
-- (void)activeCallView:(AKActiveCallView *)sender
- didReceiveText:(NSString *)aString {
-
- NSCharacterSet *DTMFCharacterSet
- = [NSCharacterSet characterSetWithCharactersInString:@"0123456789*#"];
-
- BOOL isDTMFValid = YES;
- for (NSUInteger i = 0; i < [aString length]; ++i) {
- unichar digit = [aString characterAtIndex:i];
- if (![DTMFCharacterSet characterIsMember:digit]) {
- isDTMFValid = NO;
- break;
- }
- }
-
- if (isDTMFValid) {
- if ([[self enteredDTMF] length] == 0) {
- [[self enteredDTMF] appendString:aString];
- [[[self view] window] setTitle:[[self callController] displayedName]];
-
- if ([[[self displayedNameField] cell] lineBreakMode]
- != NSLineBreakByTruncatingHead) {
- [[[self displayedNameField] cell]
- setLineBreakMode:NSLineBreakByTruncatingHead];
- [[[[self callController] endedCallViewController] displayedNameField]
- setSelectable:YES];
- }
-
- [[self callController] setDisplayedName:aString];
-
- } else {
- [[self enteredDTMF] appendString:aString];
- [[self callController] setDisplayedName:[self enteredDTMF]];
+- (void)activeCallView:(AKActiveCallView *)sender didReceiveText:(NSString *)aString {
+ NSCharacterSet *DTMFCharacterSet = [NSCharacterSet characterSetWithCharactersInString:@"0123456789*#"];
+
+ BOOL isDTMFValid = YES;
+ for (NSUInteger i = 0; i < [aString length]; ++i) {
+ unichar digit = [aString characterAtIndex:i];
+ if (![DTMFCharacterSet characterIsMember:digit]) {
+ isDTMFValid = NO;
+ break;
+ }
}
- [[[self callController] call] sendDTMFDigits:aString];
- }
+ if (isDTMFValid) {
+ if ([[self enteredDTMF] length] == 0) {
+ [[self enteredDTMF] appendString:aString];
+ [[[self view] window] setTitle:[[self callController] displayedName]];
+
+ if ([[[self displayedNameField] cell] lineBreakMode]!= NSLineBreakByTruncatingHead) {
+ [[[self displayedNameField] cell] setLineBreakMode:NSLineBreakByTruncatingHead];
+ [[[[self callController] endedCallViewController] displayedNameField] setSelectable:YES];
+ }
+
+ [[self callController] setDisplayedName:aString];
+
+ } else {
+ [[self enteredDTMF] appendString:aString];
+ [[self callController] setDisplayedName:[self enteredDTMF]];
+ }
+
+ [[[self callController] call] sendDTMFDigits:aString];
+ }
}
@@ -253,50 +236,51 @@ - (void)activeCallView:(AKActiveCallView *)sender
#pragma mark NSMenuValidation protocol
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem {
- if ([menuItem action] == @selector(toggleMicrophoneMute:)) {
- if ([[[self callController] call] isMicrophoneMuted]) {
- [menuItem setTitle:NSLocalizedString(@"Unmute",
- @"Unmute. Call menu item.")];
- } else {
- [menuItem setTitle:NSLocalizedString(@"Mute", @"Mute. Call menu item.")];
- }
-
- if ([[[self callController] call] state] == kAKSIPCallConfirmedState) {
- return YES;
- } else {
- return NO;
- }
-
- } else if ([menuItem action] == @selector(toggleCallHold:)) {
- if ([[[self callController] call] state] == kAKSIPCallConfirmedState &&
- [[[self callController] call] isOnLocalHold]) {
- [menuItem setTitle:NSLocalizedString(@"Resume",
- @"Resume. Call menu item.")];
- } else {
- [menuItem setTitle:NSLocalizedString(@"Hold", @"Hold. Call menu item.")];
- }
-
- if ([[[self callController] call] state] == kAKSIPCallConfirmedState &&
- ![[[self callController] call] isOnRemoteHold]) {
- return YES;
- } else {
- return NO;
- }
-
- } else if ([menuItem action] == @selector(showCallTransferSheet:)) {
- if ([[[self callController] call] state] == kAKSIPCallConfirmedState &&
- ![[[self callController] call] isOnRemoteHold]) {
- return YES;
- } else {
- return NO;
+ if ([menuItem action] == @selector(toggleMicrophoneMute:)) {
+ if ([[[self callController] call] isMicrophoneMuted]) {
+ [menuItem setTitle:NSLocalizedString(@"Unmute", @"Unmute. Call menu item.")];
+ } else {
+ [menuItem setTitle:NSLocalizedString(@"Mute", @"Mute. Call menu item.")];
+ }
+
+ if ([[[self callController] call] state] == kAKSIPCallConfirmedState) {
+ return YES;
+ } else {
+ return NO;
+ }
+
+ } else if ([menuItem action] == @selector(toggleCallHold:)) {
+ if ([[[self callController] call] state] == kAKSIPCallConfirmedState &&
+ [[[self callController] call] isOnLocalHold]) {
+ [menuItem setTitle:NSLocalizedString(@"Resume", @"Resume. Call menu item.")];
+ } else {
+ [menuItem setTitle:NSLocalizedString(@"Hold", @"Hold. Call menu item.")];
+ }
+
+ if ([[[self callController] call] state] == kAKSIPCallConfirmedState &&
+ ![[[self callController] call] isOnRemoteHold]) {
+
+ return YES;
+
+ } else {
+ return NO;
+ }
+
+ } else if ([menuItem action] == @selector(showCallTransferSheet:)) {
+ if ([[[self callController] call] state] == kAKSIPCallConfirmedState &&
+ ![[[self callController] call] isOnRemoteHold]) {
+
+ return YES;
+
+ } else {
+ return NO;
+ }
+
+ } else if ([menuItem action] == @selector(hangUpCall:)) {
+ [menuItem setTitle:NSLocalizedString(@"End Call", @"End Call. Call menu item.")];
}
- } else if ([menuItem action] == @selector(hangUpCall:)) {
- [menuItem setTitle:NSLocalizedString(@"End Call",
- @"End Call. Call menu item.")];
- }
-
- return YES;
+ return YES;
}
@end
View
60 Classes/CallController.h
@@ -45,29 +45,29 @@ extern NSString * const AKCallWindowWillCloseNotification;
// A call controller.
@interface CallController : XSWindowController {
- @private
- NSString *identifier_;
- AKSIPCall *call_;
- AccountController *accountController_;
- CallTransferController *callTransferController_;
-
- IncomingCallViewController *incomingCallViewController_;
- @protected
- ActiveCallViewController *activeCallViewController_;
- EndedCallViewController *endedCallViewController_;
-
- @private
- NSString *displayedName_;
- NSString *status_;
- NSString *nameFromAddressBook_;
- NSString *phoneLabelFromAddressBook_;
- NSString *enteredCallDestination_;
- AKSIPURI *redialURI_;
- NSTimer *intermediateStatusTimer_;
- NSTimeInterval callStartTime_;
- BOOL callOnHold_;
- BOOL callActive_;
- BOOL callUnhandled_;
+ @private
+ NSString *identifier_;
+ AKSIPCall *call_;
+ AccountController *accountController_;
+ CallTransferController *callTransferController_;
+
+ IncomingCallViewController *incomingCallViewController_;
+ @protected
+ ActiveCallViewController *activeCallViewController_;
+ EndedCallViewController *endedCallViewController_;
+
+ @private
+ NSString *displayedName_;
+ NSString *status_;
+ NSString *nameFromAddressBook_;
+ NSString *phoneLabelFromAddressBook_;
+ NSString *enteredCallDestination_;
+ AKSIPURI *redialURI_;
+ NSTimer *intermediateStatusTimer_;
+ NSTimeInterval callStartTime_;
+ BOOL callOnHold_;
+ BOOL callActive_;
+ BOOL callUnhandled_;
}
// The receiver's identifier.
@@ -111,8 +111,8 @@ extern NSString * const AKCallWindowWillCloseNotification;
// SIP URI for the redial.
@property (nonatomic, copy) AKSIPURI *redialURI;
-// Timer to display intermediate call status. This status appears for the short
-// period of time and then is being replaced with the current call status.
+// Timer to display intermediate call status. This status appears for the short period of time and then is being
+// replaced with the current call status.
@property (nonatomic, assign) NSTimer *intermediateStatusTimer;
// Call start time.
@@ -129,10 +129,8 @@ extern NSString * const AKCallWindowWillCloseNotification;
// Designated initializer.
-// Initializes a CallController object with a given nib file and account
-// controller.
-- (id)initWithWindowNibName:(NSString *)windowNibName
- accountController:(AccountController *)anAccountController;
+// Initializes a CallController object with a given nib file and account controller.
+- (id)initWithWindowNibName:(NSString *)windowNibName accountController:(AccountController *)anAccountController;
// Accepts an incoming call.
- (void)acceptCall;
@@ -149,8 +147,8 @@ extern NSString * const AKCallWindowWillCloseNotification;
// Toggles microphone mute.
- (void)toggleMicrophoneMute;
-// Sets intermediate call status. This status appears for the short period of
-// time and then is being replaced with the current call status.
+// Sets intermediate call status. This status appears for the short period of time and then is being replaced with the
+// current call status.
- (void)setIntermediateStatus:(NSString *)newIntermediateStatus;
// Method to be called when intermediate call status timer fires.
View
1,039 Classes/CallController.m
@@ -90,342 +90,316 @@ @implementation CallController
@dynamic endedCallViewController;
- (void)setCall:(AKSIPCall *)aCall {
- if (call_ != aCall) {
- if ([[call_ delegate] isEqual:self]) {
- [call_ setDelegate:nil];
+ if (call_ != aCall) {
+ if ([[call_ delegate] isEqual:self]) {
+ [call_ setDelegate:nil];
+ }
+
+ [call_ release];
+ call_ = [aCall retain];
+
+ [call_ setDelegate:self];
}
-
- [call_ release];
- call_ = [aCall retain];
-
- [call_ setDelegate:self];
- }
}
- (void)setAccountController:(AccountController *)anAccountController {
- if (accountController_ == anAccountController) {
- return;
- }
-
- NSNotificationCenter *notificationCenter
- = [NSNotificationCenter defaultCenter];
-
- if (accountController_ != nil) {
- [notificationCenter removeObserver:accountController_ name:nil object:self];
- }
-
- if (anAccountController != nil) {
- if ([anAccountController respondsToSelector:
- @selector(callWindowWillClose:)]) {
- [notificationCenter addObserver:anAccountController
- selector:@selector(callWindowWillClose:)
- name:AKCallWindowWillCloseNotification
- object:self];
- }
- }
-
- accountController_ = anAccountController;
+ if (accountController_ == anAccountController) {
+ return;
+ }
+
+ NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter];
+
+ if (accountController_ != nil) {
+ [notificationCenter removeObserver:accountController_ name:nil object:self];
+ }
+
+ if (anAccountController != nil) {
+ if ([anAccountController respondsToSelector:@selector(callWindowWillClose:)]) {
+ [notificationCenter addObserver:anAccountController
+ selector:@selector(callWindowWillClose:)
+ name:AKCallWindowWillCloseNotification
+ object:self];
+ }
+ }
+
+ accountController_ = anAccountController;
}
- (CallTransferController *)callTransferController {
- if (callTransferController_ == nil) {
- callTransferController_
- = [[CallTransferController alloc] initWithSourceCallController:self];
- }
- return callTransferController_;
+ if (callTransferController_ == nil) {
+ callTransferController_ = [[CallTransferController alloc] initWithSourceCallController:self];
+ }
+ return callTransferController_;
}
- (IncomingCallViewController *)incomingCallViewController {
- if (incomingCallViewController_ == nil) {
- incomingCallViewController_
- = [[IncomingCallViewController alloc] initWithCallController:self];
- [incomingCallViewController_ setRepresentedObject:[self call]];
- }
- return incomingCallViewController_;
+ if (incomingCallViewController_ == nil) {
+ incomingCallViewController_ = [[IncomingCallViewController alloc] initWithCallController:self];
+ [incomingCallViewController_ setRepresentedObject:[self call]];
+ }
+ return incomingCallViewController_;
}
- (ActiveCallViewController *)activeCallViewController {
- if (activeCallViewController_ == nil) {
- activeCallViewController_
- = [[ActiveCallViewController alloc]
- initWithNibName:@"ActiveCallView" callController:self];
- [activeCallViewController_ setRepresentedObject:[self call]];
- }
- return activeCallViewController_;
+ if (activeCallViewController_ == nil) {
+ activeCallViewController_ = [[ActiveCallViewController alloc] initWithNibName:@"ActiveCallView"
+ callController:self];
+ [activeCallViewController_ setRepresentedObject:[self call]];
+ }
+ return activeCallViewController_;
}
- (EndedCallViewController *)endedCallViewController {
- if (endedCallViewController_ == nil) {
- endedCallViewController_
- = [[EndedCallViewController alloc]
- initWithNibName:@"EndedCallView" callController:self];
- [endedCallViewController_ setRepresentedObject:[self call]];
- }
- return endedCallViewController_;
+ if (endedCallViewController_ == nil) {
+ endedCallViewController_ = [[EndedCallViewController alloc] initWithNibName:@"EndedCallView"
+ callController:self];
+ [endedCallViewController_ setRepresentedObject:[self call]];
+ }
+ return endedCallViewController_;
}
-- (id)initWithWindowNibName:(NSString *)windowNibName
- accountController:(AccountController *)anAccountController {
-
- self = [super initWithWindowNibName:windowNibName];
- if (self == nil) {
- return nil;
- }
-
- [self setIdentifier:[NSString ak_uuidString]];
- [self setAccountController:anAccountController];
- [self setCallOnHold:NO];
- [self setCallActive:NO];
- [self setCallUnhandled:NO];
-
- return self;
+- (id)initWithWindowNibName:(NSString *)windowNibName accountController:(AccountController *)anAccountController {
+ self = [super initWithWindowNibName:windowNibName];
+ if (self == nil) {
+ return nil;
+ }
+
+ [self setIdentifier:[NSString ak_uuidString]];
+ [self setAccountController:anAccountController];
+ [self setCallOnHold:NO];
+ [self setCallActive:NO];
+ [self setCallUnhandled:NO];
+
+ return self;
}
- (id)init {
- return [self initWithWindowNibName:@"Call" accountController:nil];
+ return [self initWithWindowNibName:@"Call" accountController:nil];
}
- (void)dealloc {
- [identifier_ release];
-
- [self setCall:nil];
- [self setAccountController:nil];
- [callTransferController_ release];
- [incomingCallViewController_ release];
- [activeCallViewController_ release];
- [endedCallViewController_ release];
- [displayedName_ release];
- [status_ release];
- [nameFromAddressBook_ release];
- [phoneLabelFromAddressBook_ release];
- [enteredCallDestination_ release];
- [redialURI_ release];
-
- [super dealloc];
+ [identifier_ release];
+
+ [self setCall:nil];
+ [self setAccountController:nil];
+ [callTransferController_ release];
+ [incomingCallViewController_ release];
+ [activeCallViewController_ release];
+ [endedCallViewController_ release];
+ [displayedName_ release];
+ [status_ release];
+ [nameFromAddressBook_ release];
+ [phoneLabelFromAddressBook_ release];
+ [enteredCallDestination_ release];
+ [redialURI_ release];
+
+ [super dealloc];
}
- (NSString *)description {
- return [[self call] description];
+ return [[self call] description];
}
- (void)acceptCall {
- if ([[self call] isIncoming]) {
- [[NSApp delegate] stopRingtoneTimerIfNeeded];
- }
-
- [self setCallUnhandled:NO];
- [[NSApp delegate] updateDockTileBadgeLabel];
-
- [[self call] answer];
+ if ([[self call] isIncoming]) {
+ [[NSApp delegate] stopRingtoneTimerIfNeeded];
+ }
+
+ [self setCallUnhandled:NO];
+ [[NSApp delegate] updateDockTileBadgeLabel];
+
+ [[self call] answer];
}
- (void)hangUpCall {
- [self setCallActive:NO];
- [self setCallUnhandled:NO];
-
- if (activeCallViewController_ != nil) {
- [[self activeCallViewController] stopCallTimer];
- }
-
- if ([[self call] isIncoming]) {
- [[NSApp delegate] stopRingtoneTimerIfNeeded];
- }
-
- // If remote party hasn't sent back any replies, call hang-up will not happen
- // immediately. Unsubscribe from any notifications about the call state and
- // set disconnected look to the call window.
-
- if ([[[self call] delegate] isEqual:self]) {
- [[self call] setDelegate:nil];
- }
-
- [[self call] hangUp];
-
- [self setStatus:NSLocalizedString(@"call ended", @"Call ended.")];
-
- [self removeObjectFromViewControllersAtIndex:0];
- [self addViewController:[self endedCallViewController]];
- [[self window]
- ak_resizeAndSwapToContentView:[[self endedCallViewController] view]
- animate:YES];
-
- [[[self activeCallViewController] callProgressIndicator] stopAnimation:self];
- [[[self activeCallViewController] hangUpButton] setEnabled:NO];
- [[[self incomingCallViewController] acceptCallButton] setEnabled:NO];
- [[[self incomingCallViewController] declineCallButton] setEnabled:NO];
-
- [[NSApp delegate] resumeITunesIfNeeded];
- [[NSApp delegate] updateDockTileBadgeLabel];
-
- // Optionally close call window.
- if ([[NSUserDefaults standardUserDefaults] boolForKey:kAutoCloseCallWindow] &&
- ![self isKindOfClass:[CallTransferController class]]) {
- [self performSelector:@selector(closeCallWindow)
- withObject:nil
- afterDelay:kCallWindowAutoCloseTime];
- }
+ [self setCallActive:NO];
+ [self setCallUnhandled:NO];
+
+ if (activeCallViewController_ != nil) {
+ [[self activeCallViewController] stopCallTimer];
+ }
+
+ if ([[self call] isIncoming]) {
+ [[NSApp delegate] stopRingtoneTimerIfNeeded];
+ }
+
+ // If remote party hasn't sent back any replies, call hang-up will not happen immediately. Unsubscribe from any
+ // notifications about the call state and set disconnected look to the call window.
+
+ if ([[[self call] delegate] isEqual:self]) {
+ [[self call] setDelegate:nil];
+ }
+
+ [[self call] hangUp];
+
+ [self setStatus:NSLocalizedString(@"call ended", @"Call ended.")];
+
+ [self removeObjectFromViewControllersAtIndex:0];
+ [self addViewController:[self endedCallViewController]];
+ [[self window] ak_resizeAndSwapToContentView:[[self endedCallViewController] view] animate:YES];
+
+ [[[self activeCallViewController] callProgressIndicator] stopAnimation:self];
+ [[[self activeCallViewController] hangUpButton] setEnabled:NO];
+ [[[self incomingCallViewController] acceptCallButton] setEnabled:NO];
+ [[[self incomingCallViewController] declineCallButton] setEnabled:NO];
+
+ [[NSApp delegate] resumeITunesIfNeeded];
+ [[NSApp delegate] updateDockTileBadgeLabel];
+
+ // Optionally close call window.
+ if ([[NSUserDefaults standardUserDefaults] boolForKey:kAutoCloseCallWindow] &&
+ ![self isKindOfClass:[CallTransferController class]]) {
+
+ [self performSelector:@selector(closeCallWindow)
+ withObject:nil
+ afterDelay:kCallWindowAutoCloseTime];
+ }
}
- (void)redial {
- if (![[[NSApp delegate] userAgent] isStarted] ||
- ![[self accountController] isEnabled] ||
- ![[[[self accountController] window] contentView] isEqual:
- [[[self accountController] activeAccountViewController] view]] ||
- [self redialURI] == nil) {
- return;
- }
-
- // Cancel call window auto-close.
- [NSObject cancelPreviousPerformRequestsWithTarget:self
- selector:@selector(closeCallWindow)
- object:nil];
-
- // Replace plus character if needed.
- if ([[self accountController] substitutesPlusCharacter] &&
- [[[self redialURI] user] hasPrefix:@"+"]) {
- [[self redialURI] setUser:
- [[[self redialURI] user]
- stringByReplacingCharactersInRange:NSMakeRange(0, 1)
- withString:[[self accountController]
- plusCharacterSubstitution]]];
- }
-
- if (![[self objectInViewControllersAtIndex:0] isEqual:
- [self activeCallViewController]]) {
- [self removeObjectFromViewControllersAtIndex:0];
- [self addViewController:[self activeCallViewController]];
- [[self window]
- ak_resizeAndSwapToContentView:[[self activeCallViewController] view]
- animate:YES];
- }
-
- [[[self activeCallViewController] view]
- replaceSubview:[[self activeCallViewController] hangUpButton]
- with:[[self activeCallViewController] callProgressIndicator]];
-
- [[[self activeCallViewController] view] addTrackingArea:
- [[self activeCallViewController] callProgressIndicatorTrackingArea]];
-
- [[[self activeCallViewController] hangUpButton] setEnabled:YES];
-
- // Calling -display is bad style, but we have to run -makeCallTo: below
- // synchronously. And without calling -display: spinner and redial button are
- // visible at the same time.
- [[self window] display];
- [[[self activeCallViewController] callProgressIndicator] startAnimation:self];
-
- if ([[self phoneLabelFromAddressBook] length] > 0) {
- [self setStatus:
- [NSString stringWithFormat:
- NSLocalizedString(@"calling %@...",
- @"Outgoing call in progress. Calling specific phone "
- "type (mobile, home, etc)."),
- [self phoneLabelFromAddressBook]]];
-
- } else {
- [self setStatus:NSLocalizedString(@"calling...",
- @"Outgoing call in progress.")];
- }
-
- // Make actual call.
- AKSIPCall *aCall
- = [[[self accountController] account] makeCallTo:[self redialURI]];
- if (aCall != nil) {
- [self setCall:aCall];
- [self setCallActive:YES];
- if (incomingCallViewController_ != nil) {
- [incomingCallViewController_ setRepresentedObject:aCall];
+ if (![[[NSApp delegate] userAgent] isStarted] ||
+ ![[self accountController] isEnabled] ||
+ ![[[[self accountController] window] contentView] isEqual:
+ [[[self accountController] activeAccountViewController] view]] ||
+ [self redialURI] == nil) {
+
+ return;
+ }
+
+ // Cancel call window auto-close.
+ [NSObject cancelPreviousPerformRequestsWithTarget:self
+ selector:@selector(closeCallWindow)
+ object:nil];
+
+ // Replace plus character if needed.
+ if ([[self accountController] substitutesPlusCharacter] &&
+ [[[self redialURI] user] hasPrefix:@"+"]) {
+
+ [[self redialURI] setUser:[[[self redialURI] user]
+ stringByReplacingCharactersInRange:NSMakeRange(0, 1)
+ withString:[[self accountController]
+ plusCharacterSubstitution]]];
+ }
+
+ if (![[self objectInViewControllersAtIndex:0] isEqual:[self activeCallViewController]]) {
+ [self removeObjectFromViewControllersAtIndex:0];
+ [self addViewController:[self activeCallViewController]];
+ [[self window] ak_resizeAndSwapToContentView:[[self activeCallViewController] view] animate:YES];
+ }
+
+ [[[self activeCallViewController] view] replaceSubview:[[self activeCallViewController] hangUpButton]
+ with:[[self activeCallViewController] callProgressIndicator]];
+
+ [[[self activeCallViewController] view] addTrackingArea:
+ [[self activeCallViewController] callProgressIndicatorTrackingArea]];
+
+ [[[self activeCallViewController] hangUpButton] setEnabled:YES];
+
+ // Calling -display is bad style, but we have to run -makeCallTo: below synchronously. And without calling -display:
+ // spinner and redial button are visible at the same time.
+ [[self window] display];
+ [[[self activeCallViewController] callProgressIndicator] startAnimation:self];
+
+ if ([[self phoneLabelFromAddressBook] length] > 0) {
+ [self setStatus:[NSString stringWithFormat:
+ NSLocalizedString(@"calling %@...",
+ @"Outgoing call in progress. Calling specific phone "
+ "type (mobile, home, etc)."),
+ [self phoneLabelFromAddressBook]]];
+
+ } else {
+ [self setStatus:NSLocalizedString(@"calling...", @"Outgoing call in progress.")];
+ }
+
+ // Make actual call.
+ AKSIPCall *aCall = [[[self accountController] account] makeCallTo:[self redialURI]];
+ if (aCall != nil) {
+ [self setCall:aCall];
+ [self setCallActive:YES];
+ if (incomingCallViewController_ != nil) {
+ [incomingCallViewController_ setRepresentedObject:aCall];
+ }
+ if (activeCallViewController_ != nil) {
+ [activeCallViewController_ setRepresentedObject:aCall];
+ }
+ if (endedCallViewController_ != nil) {
+ [endedCallViewController_ setRepresentedObject:nil];
+ }
+ } else {
+ if (![[self objectInViewControllersAtIndex:0] isEqual:[self endedCallViewController]]) {
+ [self removeObjectFromViewControllersAtIndex:0];
+ [self addViewController:[self endedCallViewController]];
+ [[self window] ak_resizeAndSwapToContentView:[[self endedCallViewController] view] animate:YES];
+ }
+ [self setStatus:NSLocalizedString(@"Call Failed", @"Call failed.")];
+ }
+
+ if ([self isCallUnhandled]) {
+ [self setCallUnhandled:NO];
+ [[NSApp delegate] updateDockTileBadgeLabel];
}
- if (activeCallViewController_ != nil) {
- [activeCallViewController_ setRepresentedObject:aCall];
- }
- if (endedCallViewController_ != nil) {
- [endedCallViewController_ setRepresentedObject:nil];
- }
- } else {
- if (![[self objectInViewControllersAtIndex:0] isEqual:
- [self endedCallViewController]]) {
- [self removeObjectFromViewControllersAtIndex:0];
- [self addViewController:[self endedCallViewController]];
- [[self window]
- ak_resizeAndSwapToContentView:[[self endedCallViewController] view]
- animate:YES];
- }
- [self setStatus:NSLocalizedString(@"Call Failed", @"Call failed.")];
- }
-
- if ([self isCallUnhandled]) {
- [self setCallUnhandled:NO];
- [[NSApp delegate] updateDockTileBadgeLabel];
- }
}
- (void)toggleCallHold {
- if ([[self call] state] == kAKSIPCallConfirmedState &&
- ![[self call] isOnRemoteHold]) {
- [[self call] toggleHold];
- }
+ if ([[self call] state] == kAKSIPCallConfirmedState && ![[self call] isOnRemoteHold]) {
+ [[self call] toggleHold];
+ }
}
- (void)toggleMicrophoneMute {
- if ([[self call] state] != kAKSIPCallConfirmedState) {
- return;
- }
-
- [[self call] toggleMicrophoneMute];
-
- if ([[self call] isMicrophoneMuted]) {
- if (![self isCallOnHold]) {
- [[self activeCallViewController] stopCallTimer];
- [self setStatus:
- NSLocalizedString(@"mic muted", @"Microphone muted status text.")];
+ if ([[self call] state] != kAKSIPCallConfirmedState) {
+ return;
+ }
+
+ [[self call] toggleMicrophoneMute];
+
+ if ([[self call] isMicrophoneMuted]) {
+ if (![self isCallOnHold]) {
+ [[self activeCallViewController] stopCallTimer];
+ [self setStatus:NSLocalizedString(@"mic muted", @"Microphone muted status text.")];
+ } else {
+ [self setIntermediateStatus:NSLocalizedString(@"mic muted", @"Microphone muted status text.")];
+ }
} else {
- [self setIntermediateStatus:
- NSLocalizedString(@"mic muted", @"Microphone muted status text.")];
+ [self setIntermediateStatus:NSLocalizedString(@"mic unmuted", @"Microphone unmuted status text.")];
}
- } else {
- [self setIntermediateStatus:
- NSLocalizedString(@"mic unmuted", @"Microphone unmuted status text.")];
- }
}
- (void)setIntermediateStatus:(NSString *)newIntermediateStatus {
- if ([self intermediateStatusTimer] != nil) {
- [[self intermediateStatusTimer] invalidate];
- }
-
- [[self activeCallViewController] stopCallTimer];
- [self setStatus:newIntermediateStatus];
- [self setIntermediateStatusTimer:
- [NSTimer
- scheduledTimerWithTimeInterval:3.0
- target:self
- selector:@selector(intermediateStatusTimerTick:)
- userInfo:nil
- repeats:NO]];
+ if ([self intermediateStatusTimer] != nil) {
+ [[self intermediateStatusTimer] invalidate];
+ }
+
+ [[self activeCallViewController] stopCallTimer];
+ [self setStatus:newIntermediateStatus];
+ [self setIntermediateStatusTimer:
+ [NSTimer scheduledTimerWithTimeInterval:3.0
+ target:self
+ selector:@selector(intermediateStatusTimerTick:)
+ userInfo:nil
+ repeats:NO]];
}
- (void)intermediateStatusTimerTick:(NSTimer *)theTimer {
- if ([[self call] isOnLocalHold]) {
- [self setStatus:
- NSLocalizedString(@"on hold", @"Call on local hold status text.")];
- } else if ([[self call] isOnRemoteHold]) {
- [self setStatus:
- NSLocalizedString(@"on remote hold", @"Call on remote hold status text.")];
- } else if ([[self call] isMicrophoneMuted]) {
- [self setStatus:
- NSLocalizedString(@"mic muted", @"Microphone muted status text.")];
- } else if ([[self call] isActive]) {
- [[self activeCallViewController] startCallTimer];
- }
-
- [self setIntermediateStatusTimer:nil];
+ if ([[self call] isOnLocalHold]) {
+ [self setStatus:NSLocalizedString(@"on hold", @"Call on local hold status text.")];
+ } else if ([[self call] isOnRemoteHold]) {
+ [self setStatus:
+ NSLocalizedString(@"on remote hold", @"Call on remote hold status text.")];
+ } else if ([[self call] isMicrophoneMuted]) {
+ [self setStatus:
+ NSLocalizedString(@"mic muted", @"Microphone muted status text.")];
+ } else if ([[self call] isActive]) {
+ [[self activeCallViewController] startCallTimer];
+ }
+
+ [self setIntermediateStatusTimer:nil];
}
- (void)closeCallWindow {
- if ([[self window] isVisible]) {
- [[self window] performClose:self];
- }
+ if ([[self window] isVisible]) {
+ [[self window] performClose:self];
+ }
}
@@ -433,38 +407,33 @@ - (void)closeCallWindow {
#pragma mark NSWindow delegate methods
- (void)windowWillClose:(NSNotification *)notification {
- if ([XSWindowController instancesRespondToSelector:
- @selector(windowWillClose:)]) {
- // We have to call super's implementation of |windowWillClose:| via the
- // function pointer because using [super windowWillClose:notification] will
- // issue compiler warning.
- id (*superWindowWillClose)(id, SEL, ...)
- = [XSWindowController instanceMethodForSelector:_cmd];
- superWindowWillClose(self, _cmd);
- }
- if ([self isCallActive]) {
- [self setCallActive:NO];
- [[self activeCallViewController] stopCallTimer];
-
- if ([[self call] isIncoming]) {
- [[NSApp delegate] stopRingtoneTimerIfNeeded];
+ if ([XSWindowController instancesRespondToSelector:@selector(windowWillClose:)]) {
+ // We have to call super's implementation of |windowWillClose:| via the function pointer because using
+ // [super windowWillClose:notification] will issue compiler warning.
+ id (*superWindowWillClose)(id, SEL, ...) = [XSWindowController instanceMethodForSelector:_cmd];
+ superWindowWillClose(self, _cmd);
}
-
- if ([[[self call] delegate] isEqual:self]) {
- [[self call] setDelegate:nil];
+ if ([self isCallActive]) {
+ [self setCallActive:NO];
+ [[self activeCallViewController] stopCallTimer];
+
+ if ([[self call] isIncoming]) {
+ [[NSApp delegate] stopRingtoneTimerIfNeeded];
+ }
+
+ if ([[[self call] delegate] isEqual:self]) {
+ [[self call] setDelegate:nil];
+ }
+
+ [[self call] hangUp];
+
+ [[NSApp delegate] resumeITunesIfNeeded];
}
- [[self call] hangUp];
+ [self setCallUnhandled:NO];
+ [[NSApp delegate] updateDockTileBadgeLabel];
- [[NSApp delegate] resumeITunesIfNeeded];
- }
-
- [self setCallUnhandled:NO];
- [[NSApp delegate] updateDockTileBadgeLabel];
-
- [[NSNotificationCenter defaultCenter]
- postNotificationName:AKCallWindowWillCloseNotification
- object:self];
+ [[NSNotificationCenter defaultCenter] postNotificationName:AKCallWindowWillCloseNotification object:self];
}
@@ -472,277 +441,237 @@ - (void)windowWillClose:(NSNotification *)notification {
#pragma mark AKSIPCall notifications
- (void)SIPCallCalling:(NSNotification *)notification {
- if ([[self phoneLabelFromAddressBook] length] > 0) {
- [self setStatus:
- [NSString stringWithFormat:
- NSLocalizedString(@"calling %@...",
- @"Outgoing call in progress. Calling specific phone "
- "type (mobile, home, etc)."),
- [self phoneLabelFromAddressBook]]];
- } else {
- [self setStatus:NSLocalizedString(@"calling...",
- @"Outgoing call in progress.")];
- }
-
- if (![[self objectInViewControllersAtIndex:0] isEqual:
- [self activeCallViewController]]) {
- [self removeObjectFromViewControllersAtIndex:0];
- [self addViewController:[self activeCallViewController]];
- [[self window]
- ak_resizeAndSwapToContentView:[[self activeCallViewController] view]
- animate:YES];
- }
-
- [[[self activeCallViewController] hangUpButton] setEnabled:YES];
- [[[self activeCallViewController] callProgressIndicator] startAnimation:self];
+ if ([[self phoneLabelFromAddressBook] length] > 0) {
+ [self setStatus:
+ [NSString stringWithFormat:
+ NSLocalizedString(@"calling %@...",
+ @"Outgoing call in progress. Calling specific phone type (mobile, home, etc)."),
+ [self phoneLabelFromAddressBook]]];
+ } else {
+ [self setStatus:NSLocalizedString(@"calling...", @"Outgoing call in progress.")];
+ }
+
+ if (![[self objectInViewControllersAtIndex:0] isEqual:[self activeCallViewController]]) {
+ [self removeObjectFromViewControllersAtIndex:0];
+ [self addViewController:[self activeCallViewController]];
+ [[self window] ak_resizeAndSwapToContentView:[[self activeCallViewController] view] animate:YES];
+ }
+
+ [[[self activeCallViewController] hangUpButton] setEnabled:YES];
+ [[[self activeCallViewController] callProgressIndicator] startAnimation:self];
}
- (void)SIPCallEarly:(NSNotification *)notification {
- [[NSApp delegate] pauseITunes];
-
- NSNumber *sipEventCode
- = [[notification userInfo] objectForKey:@"AKSIPEventCode"];
-
- if (![[self call] isIncoming]) {
- if ([sipEventCode isEqualToNumber:
- [NSNumber numberWithInt:PJSIP_SC_RINGING]]) {
-
- [[[self activeCallViewController] callProgressIndicator]
- stopAnimation:self];
-
- [[[self activeCallViewController] view] removeTrackingArea:
- [[self activeCallViewController] callProgressIndicatorTrackingArea]];
-
- [[[self activeCallViewController] view]
- replaceSubview:[[self activeCallViewController] callProgressIndicator]
- with:[[self activeCallViewController] hangUpButton]];
-
- [self setStatus:NSLocalizedString(@"ringing", @"Remote party ringing.")];
- }
-
- if (![[self objectInViewControllersAtIndex:0] isEqual:
- [self activeCallViewController]]) {
- [self removeObjectFromViewControllersAtIndex:0];
- [self addViewController:[self activeCallViewController]];
- [[self window]
- ak_resizeAndSwapToContentView:[[self activeCallViewController] view]
- animate:YES];
- }
- }
-
- [[[self activeCallViewController] hangUpButton] setEnabled:YES];
+ [[NSApp delegate] pauseITunes];
+
+ NSNumber *sipEventCode = [[notification userInfo] objectForKey:@"AKSIPEventCode"];
+
+ if (![[self call] isIncoming]) {
+ if ([sipEventCode isEqualToNumber:[NSNumber numberWithInt:PJSIP_SC_RINGING]]) {
+ [[[self activeCallViewController] callProgressIndicator] stopAnimation:self];
+
+ [[[self activeCallViewController] view] removeTrackingArea:
+ [[self activeCallViewController] callProgressIndicatorTrackingArea]];
+
+ [[[self activeCallViewController] view]
+ replaceSubview:[[self activeCallViewController] callProgressIndicator]
+ with:[[self activeCallViewController] hangUpButton]];
+
+ [self setStatus:NSLocalizedString(@"ringing", @"Remote party ringing.")];
+ }
+
+ if (![[self objectInViewControllersAtIndex:0] isEqual:[self activeCallViewController]]) {
+ [self removeObjectFromViewControllersAtIndex:0];
+ [self addViewController:[self activeCallViewController]];
+ [[self window] ak_resizeAndSwapToContentView:[[self activeCallViewController] view] animate:YES];
+ }
+ }
+
+ [[[self activeCallViewController] hangUpButton] setEnabled:YES];
}
- (void)SIPCallDidConfirm:(NSNotification *)notification {
- [self setCallStartTime:[NSDate timeIntervalSinceReferenceDate]];
- [[NSApp delegate] pauseITunes];
-
- if ([[notification object] isIncoming]) {
- [[NSApp delegate] stopRingtoneTimerIfNeeded];
- }
-
- [[[self activeCallViewController] callProgressIndicator] stopAnimation:self];
-
- [[[self activeCallViewController] view] removeTrackingArea:
- [[self activeCallViewController] callProgressIndicatorTrackingArea]];
-
- [[[self activeCallViewController] view]
- replaceSubview:[[self activeCallViewController] callProgressIndicator]
- with:[[self activeCallViewController] hangUpButton]];
-
- [[[self activeCallViewController] hangUpButton] setEnabled:YES];
-
- [self setStatus:@"00:00"];
-
- [[self activeCallViewController] startCallTimer];
-
- if (![[self objectInViewControllersAtIndex:0] isEqual:
- [self activeCallViewController]]) {
- [self removeObjectFromViewControllersAtIndex:0];
- [self addViewController:[self activeCallViewController]];
- [[self window]
- ak_resizeAndSwapToContentView:[[self activeCallViewController] view]
- animate:YES];
- }
-
- if ([[[self activeCallViewController] view] acceptsFirstResponder]) {
- [[self window] makeFirstResponder:[[self activeCallViewController] view]];
- }
+ [self setCallStartTime:[NSDate timeIntervalSinceReferenceDate]];
+ [[NSApp delegate] pauseITunes];
+
+ if ([[notification object] isIncoming]) {
+ [[NSApp delegate] stopRingtoneTimerIfNeeded];
+ }
+
+ [[[self activeCallViewController] callProgressIndicator] stopAnimation:self];
+
+ [[[self activeCallViewController] view] removeTrackingArea:
+ [[self activeCallViewController] callProgressIndicatorTrackingArea]];
+
+ [[[self activeCallViewController] view] replaceSubview:[[self activeCallViewController] callProgressIndicator]
+ with:[[self activeCallViewController] hangUpButton]];
+
+ [[[self activeCallViewController] hangUpButton] setEnabled:YES];
+
+ [self setStatus:@"00:00"];
+
+ [[self activeCallViewController] startCallTimer];
+
+ if (![[self objectInViewControllersAtIndex:0] isEqual:[self activeCallViewController]]) {
+ [self removeObjectFromViewControllersAtIndex:0];
+ [self addViewController:[self activeCallViewController]];
+ [[self window] ak_resizeAndSwapToContentView:[[self activeCallViewController] view] animate:YES];
+ }
+
+ if ([[[self activeCallViewController] view] acceptsFirstResponder]) {
+ [[self window] makeFirstResponder:[[self activeCallViewController] view]];
+ }
}
- (void)SIPCallDidDisconnect:(NSNotification *)notification {
- [self setCallActive:NO];
- [[self activeCallViewController] stopCallTimer];
-
- if ([[notification object] isIncoming]) {
- [[NSApp delegate] stopRingtoneTimerIfNeeded];
- [[NSApp delegate] stopUserAttentionTimerIfNeeded];
- }
-
- NSString *preferredLocalization
- = [[[NSBundle mainBundle] preferredLocalizations] objectAtIndex:0];
-
- switch ([[self call] lastStatus]) {
- case PJSIP_SC_OK:
- [self setStatus:NSLocalizedString(@"call ended", @"Call ended.")];
- break;
-
- case PJSIP_SC_NOT_FOUND:
- [self setStatus:NSLocalizedString(@"Address Not Found",
- @"Address not found.")];
- break;
-
- case PJSIP_SC_REQUEST_TERMINATED:
- [self setStatus:NSLocalizedString(@"call ended", @"Call ended.")];
- break;
-
- case PJSIP_SC_BUSY_HERE:
- case PJSIP_SC_BUSY_EVERYWHERE:
- [self setStatus:NSLocalizedString(@"busy", @"Busy.")];
- break;
-
- case PJSIP_SC_DECLINE:
- [self setStatus:NSLocalizedString(@"call declined", @"Call declined.")];
- break;
-
- default:
- if ([preferredLocalization isEqualToString:@"Russian"]) {
- NSString *statusText
- = [[NSApp delegate] localizedStringForSIPResponseCode:
- [[self call] lastStatus]];
- if (statusText == nil) {
- [self setStatus:[NSString stringWithFormat:
- NSLocalizedString(@"Error %d", @"Error #."),
- [[self call] lastStatus]]];
- } else {
- [self setStatus:[[NSApp delegate] localizedStringForSIPResponseCode:
- [[self call] lastStatus]]];
- }
+ [self setCallActive:NO];
+ [[self activeCallViewController] stopCallTimer];
+
+ if ([[notification object] isIncoming]) {
+ [[NSApp delegate] stopRingtoneTimerIfNeeded];
+ [[NSApp delegate] stopUserAttentionTimerIfNeeded];
+ }
+
+ NSString *preferredLocalization = [[[NSBundle mainBundle] preferredLocalizations] objectAtIndex:0];
+
+ switch ([[self call] lastStatus]) {
+ case PJSIP_SC_OK:
+ [self setStatus:NSLocalizedString(@"call ended", @"Call ended.")];
+ break;
+
+ case PJSIP_SC_NOT_FOUND:
+ [self setStatus:NSLocalizedString(@"Address Not Found", @"Address not found.")];
+ break;
+
+ case PJSIP_SC_REQUEST_TERMINATED:
+ [self setStatus:NSLocalizedString(@"call ended", @"Call ended.")];
+ break;
+
+ case PJSIP_SC_BUSY_HERE:
+ case PJSIP_SC_BUSY_EVERYWHERE:
+ [self setStatus:NSLocalizedString(@"busy", @"Busy.")];
+ break;
+
+ case PJSIP_SC_DECLINE:
+ [self setStatus:NSLocalizedString(@"call declined", @"Call declined.")];
+ break;
+
+ default:
+ if ([preferredLocalization isEqualToString:@"Russian"]) {
+ NSString *statusText = [[NSApp delegate] localizedStringForSIPResponseCode:[[self call] lastStatus]];
+ if (statusText == nil) {
+ [self setStatus:[NSString stringWithFormat:NSLocalizedString(@"Error %d", @"Error #."),
+ [[self call] lastStatus]]];
+ } else {
+ [self setStatus:[[NSApp delegate] localizedStringForSIPResponseCode:[[self call] lastStatus]]];
+ }
+ } else {
+ [self setStatus:[[self call] lastStatusText]];
+ }
+ break;
+ }
+
+ // Disable the redial button to re-enable it after some delay to prevent accidental clicking on in instead of
+ // clicking on the hang-up button. Don't forget to re-enable it below!
+ [[[self endedCallViewController] redialButton] setEnabled:NO];
+
+ if (![[self objectInViewControllersAtIndex:0] isEqual:[self endedCallViewController]]) {
+ [self removeObjectFromViewControllersAtIndex:0];
+ [self addViewController:[self endedCallViewController]];
+ [[self window] ak_resizeAndSwapToContentView:[[self endedCallViewController] view] animate:YES];
+ }
+
+ [[[self activeCallViewController] callProgressIndicator] stopAnimation:self];
+ [[[self activeCallViewController] hangUpButton] setEnabled:NO];
+ [[[self incomingCallViewController] acceptCallButton] setEnabled:NO];
+ [[[self incomingCallViewController] declineCallButton] setEnabled:NO];
+
+ [NSTimer scheduledTimerWithTimeInterval:kRedialButtonReenableTime
+ target:[self endedCallViewController]
+ selector:@selector(enableRedialButtonTick:)
+ userInfo:nil
+ repeats:NO];
+
+ [[NSApp delegate] resumeITunesIfNeeded];
+
+ // Show Growl notification.
+
+ NSString *notificationTitle;
+
+ if ([[self nameFromAddressBook] length] > 0) {
+ notificationTitle = [self nameFromAddressBook];
+
+ } else if ([[self enteredCallDestination] length] > 0) {
+ NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+ AKTelephoneNumberFormatter *telephoneNumberFormatter = [[[AKTelephoneNumberFormatter alloc] init] autorelease];
+
+ if ([[self enteredCallDestination] ak_isTelephoneNumber] && [defaults boolForKey:kFormatTelephoneNumbers]) {
+ notificationTitle = [telephoneNumberFormatter stringForObjectValue:[self enteredCallDestination]];
} else {
- [self setStatus:[[self call] lastStatusText]];
+ notificationTitle = [self enteredCallDestination];
}
- break;
- }
-
- // Disable the redial button to re-enable it after some delay to prevent
- // accidental clicking on in instead of clicking on the hang-up button.
- // Don't forget to re-enable it below!
- [[[self endedCallViewController] redialButton] setEnabled:NO];
-
- if (![[self objectInViewControllersAtIndex:0] isEqual:
- [self endedCallViewController]]) {
- [self removeObjectFromViewControllersAtIndex:0];
- [self addViewController:[self endedCallViewController]];
- [[self window]
- ak_resizeAndSwapToContentView:[[self endedCallViewController] view]
- animate:YES];
- }
-
- [[[self activeCallViewController] callProgressIndicator] stopAnimation:self];
- [[[self activeCallViewController] hangUpButton] setEnabled:NO];
- [[[self incomingCallViewController] acceptCallButton] setEnabled:NO];
- [[[self incomingCallViewController] declineCallButton] setEnabled:NO];
-
- [NSTimer scheduledTimerWithTimeInterval:kRedialButtonReenableTime
- target:[self endedCallViewController]
- selector:@selector(enableRedialButtonTick:)
- userInfo:nil
- repeats:NO];
-
- [[NSApp delegate] resumeITunesIfNeeded];
-
- // Show Growl notification.
-
- NSString *notificationTitle;
-
- if ([[self nameFromAddressBook] length] > 0) {
- notificationTitle = [self nameFromAddressBook];
-
- } else if ([[self enteredCallDestination] length] > 0) {
- NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
- AKTelephoneNumberFormatter *telephoneNumberFormatter
- = [[[AKTelephoneNumberFormatter alloc] init] autorelease];
-
- if ([[self enteredCallDestination] ak_isTelephoneNumber] &&
- [defaults boolForKey:kFormatTelephoneNumbers]) {
- notificationTitle = [telephoneNumberFormatter stringForObjectValue:
- [self enteredCallDestination]];
} else {
- notificationTitle = [self enteredCallDestination];
+ AKSIPURIFormatter *SIPURIFormatter = [[[AKSIPURIFormatter alloc] init] autorelease];
+ NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
+ [SIPURIFormatter setFormatsTelephoneNumbers:[defaults boolForKey:kFormatTelephoneNumbers]];
+ [SIPURIFormatter setTelephoneNumberFormatterSplitsLastFourDigits:
+ [defaults boolForKey:kTelephoneNumberFormatterSplitsLastFourDigits]];
+ notificationTitle = [SIPURIFormatter stringForObjectValue:[[self call] remoteURI]];
}
- } else {
- AKSIPURIFormatter *SIPURIFormatter
- = [[[AKSIPURIFormatter alloc] init] autorelease];
+
+ if (![NSApp isActive]) {
+ [GrowlApplicationBridge notifyWithTitle:notificationTitle
+ description:[self status]
+ notificationName:kGrowlNotificationCallEnded
+ iconData:nil
+ priority:0
+ isSticky:NO
+ clickContext:[self identifier]];
+ }
+
+ // Optionally close disconnected call window.
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
- [SIPURIFormatter setFormatsTelephoneNumbers:
- [defaults boolForKey:kFormatTelephoneNumbers]];
- [SIPURIFormatter setTelephoneNumberFormatterSplitsLastFourDigits:
- [defaults boolForKey:kTelephoneNumberFormatterSplitsLastFourDigits]];
- notificationTitle
- = [SIPURIFormatter stringForObjectValue:[[self call] remoteURI]];
- }
-
- if (![NSApp isActive]) {
- [GrowlApplicationBridge notifyWithTitle:notificationTitle
- description:[self status]
- notificationName:kGrowlNotificationCallEnded
- iconData:nil
- priority:0
- isSticky:NO
- clickContext:[self identifier]];
- }
-
- // Optionally close disconnected call window.
- NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
- BOOL shouldCloseWindow = [defaults boolForKey:kAutoCloseCallWindow];
- BOOL shouldCloseMissedWindow
- = [defaults boolForKey:kAutoCloseMissedCallWindow];
- BOOL missed = [self isCallUnhandled];
-
- if (![self isKindOfClass:[CallTransferController class]]) {
- if ((!missed && shouldCloseWindow) ||
- (missed && shouldCloseWindow && shouldCloseMissedWindow)) {
- [self performSelector:@selector(closeCallWindow)
- withObject:nil
- afterDelay:kCallWindowAutoCloseTime];
- }
- }
+ BOOL shouldCloseWindow = [defaults boolForKey:kAutoCloseCallWindow];
+ BOOL shouldCloseMissedWindow = [defaults boolForKey:kAutoCloseMissedCallWindow];
+ BOOL missed = [self isCallUnhandled];
+
+ if (![self isKindOfClass:[CallTransferController class]]) {
+ if ((!missed && shouldCloseWindow) ||
+ (missed && shouldCloseWindow && shouldCloseMissedWindow)) {
+
+ [self performSelector:@selector(closeCallWindow) withObject:nil afterDelay:kCallWindowAutoCloseTime];
+ }
+ }
}
- (void)SIPCallMediaDidBecomeActive:(NSNotification *)notification {
- if ([self isCallOnHold]) { // Call is being taken off hold.
- [self setCallOnHold:NO];
-
- [self setIntermediateStatus:
- NSLocalizedString(@"off hold",
- @"Call has been taken off hold status text.")];
- }
+ if ([self isCallOnHold]) { // Call is being taken off hold.
+ [self setCallOnHold:NO];
+
+ [self setIntermediateStatus:NSLocalizedString(@"off hold", @"Call has been taken off hold status text.")];
+ }
}
- (void)SIPCallDidLocalHold:(NSNotification *)notification {
- [self setCallOnHold:YES];
- [[self activeCallViewController] stopCallTimer];
- [self setStatus:NSLocalizedString(@"on hold",
- @"Call on local hold status text.")];
+ [self setCallOnHold:YES];
+ [[self activeCallViewController] stopCallTimer];
+ [self setStatus:NSLocalizedString(@"on hold", @"Call on local hold status text.")];
}
- (void)SIPCallDidRemoteHold:(NSNotification *)notification {
- [self setCallOnHold:YES];
- [[self activeCallViewController] stopCallTimer];
- [self setStatus:NSLocalizedString(@"on remote hold",
- @"Call on remote hold status text.")];
+ [self setCallOnHold:YES];
+ [[self activeCallViewController] stopCallTimer];
+ [self setStatus:NSLocalizedString(@"on remote hold", @"Call on remote hold status text.")];
}
- (void)SIPCallTransferStatusDidChange:(NSNotification *)notification {
- NSDictionary *userInfo = [notification userInfo];
- BOOL isFinal
- = [[userInfo objectForKey:@"AKFinalTransferNotification"] boolValue];
-
- if (isFinal && [[self call] transferStatus] == PJSIP_SC_OK) {
- [self hangUpCall];
- [self setStatus:
- NSLocalizedString(@"call transferred", @"Call transferred.")];
- }
+ NSDictionary *userInfo = [notification userInfo];
+ BOOL isFinal = [[userInfo objectForKey:@"AKFinalTransferNotification"] boolValue];
+
+ if (isFinal && [[self call] transferStatus] == PJSIP_SC_OK) {
+ [self hangUpCall];
+ [self setStatus:NSLocalizedString(@"call transferred", @"Call transferred.")];
+ }
}
@end
View
8 Classes/CallTransferController.h
@@ -36,10 +36,10 @@
// Call transfer controller.
@interface CallTransferController : CallController {
- @private
- CallController *sourceCallController_;
- ActiveAccountTransferViewController *activeAccountTransferViewController_;
- BOOL sourceCallTransferred_;
+ @private
+ CallController *sourceCallController_;
+ ActiveAccountTransferViewController *activeAccountTransferViewController_;
+ BOOL sourceCallTransferred_;
}
// Designated initializer.
View
228 Classes/CallTransferController.m
@@ -59,93 +59,84 @@ @implementation CallTransferController
@synthesize sourceCallTransferred = sourceCallTransferred_;
- (void)setSourceCallController:(CallController *)callController {
- if (sourceCallController_ == callController) {
- return;
- }
-
- NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
-
- if (sourceCallController_ != nil) {
- [nc removeObserver:self
- name:AKSIPCallTransferStatusDidChangeNotification
- object:[sourceCallController_ call]];
- }
-
- if (callController != nil) {
- [nc addObserver:self
- selector:@selector(sourceCallControllerSIPCallTransferStatusDidChange:)
- name:AKSIPCallTransferStatusDidChangeNotification
- object:[callController call]];
- }
-
- [self setSourceCallTransferred:NO];
-
- sourceCallController_ = callController;
+ if (sourceCallController_ == callController) {
+ return;
+ }
+
+ NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
+
+ if (sourceCallController_ != nil) {
+ [nc removeObserver:self
+ name:AKSIPCallTransferStatusDidChangeNotification
+ object:[sourceCallController_ call]];
+ }
+
+ if (callController != nil) {
+ [nc addObserver:self
+ selector:@selector(sourceCallControllerSIPCallTransferStatusDidChange:)
+ name:AKSIPCallTransferStatusDidChangeNotification
+ object:[callController call]];
+ }
+
+ [self setSourceCallTransferred:NO];
+
+ sourceCallController_ = callController;
}
- (id)initWithSourceCallController:(CallController *)callController {
- self = [super initWithWindowNibName:@"CallTransfer"
- accountController:[callController accountController]];
- if (self != nil) {
- [self setSourceCallController:callController];
-
- AccountController *accountController
- = [[self sourceCallController] accountController];
-
- activeAccountTransferViewController_
- = [[ActiveAccountTransferViewController alloc]
- initWithAccountController:accountController
- windowController:self];
- }
- return self;
+ self = [super initWithWindowNibName:@"CallTransfer" accountController:[callController accountController]];
+ if (self != nil) {
+ [self setSourceCallController:callController];
+
+ AccountController *accountController = [[self sourceCallController] accountController];
+
+ activeAccountTransferViewController_
+ = [[ActiveAccountTransferViewController alloc] initWithAccountController:accountController
+ windowController:self];
+ }
+ return self;
}
- (void)dealloc {
- [activeAccountTransferViewController_ release];
- [super dealloc];
+ [activeAccountTransferViewController_ release];
+ [super dealloc];
}
- (void)windowDidLoad {
- [self showInitialState:self];
+ [self showInitialState:self];
}
- (void)transferCall {
- [[[self sourceCallController] call] attendedTransferToCall:[self call]];
+ [[[self sourceCallController] call] attendedTransferToCall:[self call]];
}
- (IBAction)closeSheet:(id)sender {
- if ([[self sourceCallController] isCallActive] &&
- [[self sourceCallController] isCallOnHold]) {
- [[self sourceCallController] toggleCallHold];
- }
- [NSApp endSheet:[sender window]];
- [[sender window] orderOut:sender];
+ if ([[self sourceCallController] isCallActive] && [[self sourceCallController] isCallOnHold]) {
+ [[self sourceCallController] toggleCallHold];
+ }
+ [NSApp endSheet:[sender window]];
+ [[sender window] orderOut:sender];
}
- (IBAction)showInitialState:(id)sender {
- if ([self isCallActive]) {
- [self hangUpCall];
- }
-
- if (![[self sourceCallController] isCallActive]) {
- [self closeSheet:self];
- }
-
- if ([self countOfViewControllers] > 0) {
- [[self viewControllers] removeAllObjects];
- [self patchResponderChain];
- }
- [self addViewController:[self activeAccountTransferViewController]];
- [[self window]
- ak_resizeAndSwapToContentView:[[self activeAccountTransferViewController]
- view]
- animate:YES];
-
- if ([[[self activeAccountTransferViewController] callDestinationField]
- acceptsFirstResponder]) {
- [[self window] makeFirstResponder:
- [[self activeAccountTransferViewController] callDestinationField]];
- }
+ if ([self isCallActive]) {
+ [self hangUpCall];
+ }
+
+ if (![[self sourceCallController] isCallActive]) {
+ [self closeSheet:self];
+ }
+
+ if ([self countOfViewControllers] > 0) {
+ [[self viewControllers] removeAllObjects];
+ [self patchResponderChain];
+ }
+ [self addViewController:[self activeAccountTransferViewController]];
+ [[self window] ak_resizeAndSwapToContentView:[[self activeAccountTransferViewController] view] animate:YES];
+
+ if ([[[self activeAccountTransferViewController] callDestinationField] acceptsFirstResponder]) {
+ [[self window] makeFirstResponder:[[self activeAccountTransferViewController] callDestinationField]];
+ }
}
@@ -153,37 +144,35 @@ - (IBAction)showInitialState:(id)sender {
#pragma mark CallController methods
- (CallTransferController *)callTransferController {
- return nil;
+ return nil;
}
- (IncomingCallViewController *)incomingCallViewController {
- return nil;
+ return nil;
}
// Substitutes ActiveCallTransferViewController.
- (ActiveCallViewController *)activeCallViewController {
- if (activeCallViewController_ == nil) {
- activeCallViewController_
- = [[ActiveCallTransferViewController alloc]
- initWithNibName:@"ActiveCallTransferView" callController:self];
- [activeCallViewController_ setRepresentedObject:[self call]];
- }
- return activeCallViewController_;
+ if (activeCallViewController_ == nil) {
+ activeCallViewController_
+ = [[ActiveCallTransferViewController alloc] initWithNibName:@"ActiveCallTransferView" callController:self];
+ [activeCallViewController_ setRepresentedObject:[self call]];
+ }
+ return activeCallViewController_;
}
// Substitutes EndedCallTransferViewController.
- (EndedCallViewController *)endedCallViewController {
- if (endedCallViewController_ == nil) {
- endedCallViewController_
- = [[EndedCallTransferViewController alloc]
- initWithNibName:@"EndedCallTransferView" callController:self];
- [endedCallViewController_ setRepresentedObject:[self call]];
- }
- return endedCallViewController_;
+ if (endedCallViewController_ == nil) {
+ endedCallViewController_
+ = [[EndedCallTransferViewController alloc] initWithNibName:@"EndedCallTransferView" callController:self];
+ [endedCallViewController_ setRepresentedObject:[self call]];
+ }
+ return endedCallViewController_;
}
- (void)acceptCall {
- // Do nothing.
+ // Do nothing.
}
@@ -191,45 +180,45 @@ - (void)acceptCall {
#pragma mark AKSIPCall notifications
- (void)SIPCallCalling:(NSNotification *)notification {
- [super SIPCallCalling:notification];
- ActiveCallTransferViewController *activeCallTransferViewController
- = (ActiveCallTransferViewController *)[self activeCallViewController];
- [[activeCallTransferViewController transferButton] setEnabled:NO];
+ [super SIPCallCalling:notification];
+ ActiveCallTransferViewController *activeCallTransferViewController
+ = (ActiveCallTransferViewController *)[self activeCallViewController];
+ [[activeCallTransferViewController transferButton] setEnabled:NO];
}
- (void)SIPCallEarly:(NSNotification *)notification {
- [super SIPCallEarly:notification];
- ActiveCallTransferViewController *activeCallTransferViewController
- = (ActiveCallTransferViewController *)[self activeCallViewController];
- [[activeCallTransferViewController transferButton] setEnabled:NO];
+ [super SIPCallEarly:notification];
+ ActiveCallTransferViewController *activeCallTransferViewController
+ = (ActiveCallTransferViewController *)[self activeCallViewController];
+ [[activeCallTransferViewController transferButton] setEnabled:NO];
}
- (void)SIPCallDidConfirm:(NSNotification *)notification {
- [super SIPCallDidConfirm:notification];
- ActiveCallTransferViewController *activeCallTransferViewController
- = (ActiveCallTransferViewController *)[self activeCallViewController];
- [[activeCallTransferViewController transferButton] setEnabled:YES];
+ [super SIPCallDidConfirm:notification];
+ ActiveCallTransferViewController *activeCallTransferViewController
+ = (ActiveCallTransferViewController *)[self activeCallViewController];
+ [[activeCallTransferViewController transferButton] setEnabled:YES];
}
- (void)SIPCallDidDisconnect:(NSNotification *)notification {
- [super SIPCallDidDisconnect:notification];
- if ([self sourceCallTransferred]) {
- [self closeSheet:self];
- }
+ [super SIPCallDidDisconnect:notification];
+ if ([self sourceCallTransferred]) {
+ [self closeSheet:self];
+ }
}
- (void)SIPCallMediaDidBecomeActive:(NSNotification *)notification {
- [super SIPCallMediaDidBecomeActive:notification];
- ActiveCallTransferViewController *activeCallTransferViewController
- = (ActiveCallTransferViewController *)[self activeCallViewController];
- [[activeCallTransferViewController transferButton] setEnabled:YES];
+ [super SIPCallMediaDidBecomeActive:notification];
+ ActiveCallTransferViewController *activeCallTransferViewController
+ = (ActiveCallTransferViewController *)[self activeCallViewController];
+ [[activeCallTransferViewController transferButton] setEnabled:YES];
}
- (void)SIPCallDidRemoteHold:(NSNotification *)notification {
- [super SIPCallDidRemoteHold:notification];
- ActiveCallTransferViewController *activeCallTransferViewController
- = (ActiveCallTransferViewController *)[self activeCallViewController];
- [[activeCallTransferViewController transferButton] setEnabled:NO];
+ [super SIPCallDidRemoteHold:notification];
+ ActiveCallTransferViewController *activeCallTransferViewController
+ = (ActiveCallTransferViewController *)[self activeCallViewController];
+ [[activeCallTransferViewController transferButton] setEnabled:NO];
}