Permalink
Browse files

Re-enable Growl notifications

Now they are optional and depend on a key from the user defaults.
  • Loading branch information...
1 parent 0202c5e commit 109996bdc96b9a32c4f0aea2abd0dc4962582d44 @eofster committed Nov 7, 2013
Showing with 50 additions and 2 deletions.
  1. +11 −0 Classes/AccountController.m
  2. +4 −0 Classes/AppController.h
  3. +23 −2 Classes/AppController.m
  4. +12 −0 Classes/CallController.m
View
11 Classes/AccountController.m
@@ -31,6 +31,7 @@
#import "AccountController.h"
#import <AddressBook/AddressBook.h>
+#import <Growl/Growl.h>
#import "AKABAddressBook+Localizing.h"
#import "AKABRecord+Querying.h"
@@ -1039,6 +1040,16 @@ - (void)SIPAccountDidReceiveCall:(AKSIPCall *)aCall {
userNotification.userInfo = @{kUserNotificationCallControllerIdentifierKey: aCallController.identifier};
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:userNotification];
+ if ([defaults boolForKey:kShowGrowlNotifications]) {
+ [GrowlApplicationBridge notifyWithTitle:notificationTitle
+ description:notificationDescription
+ notificationName:kGrowlNotificationIncomingCall
+ iconData:nil
+ priority:0
+ isSticky:NO
+ clickContext:[aCallController identifier]];
+ }
+
[[[NSApp delegate] ringtone] play];
[[NSApp delegate] startRingtoneTimer];
View
4 Classes/AppController.h
@@ -44,6 +44,10 @@ extern NSString * const kAudioDeviceBuiltIn;
/// NSUserNotification user info dictionary key containing call controller identifier.
extern NSString * const kUserNotificationCallControllerIdentifierKey;
+// Growl notification names.
+extern NSString * const kGrowlNotificationIncomingCall;
+extern NSString * const kGrowlNotificationCallEnded;
+
@class AKSIPUserAgent, PreferencesController, CallController;
@class AccountSetupController;
View
25 Classes/AppController.m
@@ -32,6 +32,7 @@
#import <CoreAudio/CoreAudio.h>
#import <SystemConfiguration/SystemConfiguration.h>
+#import <Growl/Growl.h>
#import "AKAddressBookPhonePlugIn.h"
#import "AKAddressBookSIPAddressPlugIn.h"
@@ -62,6 +63,8 @@
NSString * const kAudioDeviceBuiltIn = @"AudioDeviceBuiltIn";
NSString * const kUserNotificationCallControllerIdentifierKey = @"UserNotificationCallControllerIdentifier";
+NSString * const kGrowlNotificationIncomingCall = @"Incoming Call";
+NSString * const kGrowlNotificationCallEnded = @"Call Ended";
// Ringtone time interval.
static const NSTimeInterval kRingtoneInterval = 4.0;
@@ -86,7 +89,7 @@ static OSStatus AudioDevicesChanged(AudioObjectID objectID,
// Dynamic store callback for DNS changes.
static void NameserversChanged(SCDynamicStoreRef store, CFArrayRef changedKeys, void *info);
-@interface AppController () <NSUserNotificationCenterDelegate>
+@interface AppController () <NSUserNotificationCenterDelegate, GrowlApplicationBridgeDelegate>
// Sets selected sound IO to the user agent.
- (void)setSelectedSoundIOToUserAgent;
@@ -629,6 +632,7 @@ - (IBAction)addAccountOnFirstLaunch:(id)sender {
// [self installAddressBookPlugIns];
[NSUserNotificationCenter defaultUserNotificationCenter].delegate = self;
+ [GrowlApplicationBridge setGrowlDelegate:self];
[self installDNSChangesCallback];
}
}
@@ -1685,6 +1689,7 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// [self installAddressBookPlugIns];
[NSUserNotificationCenter defaultUserNotificationCenter].delegate = self;
+ [GrowlApplicationBridge setGrowlDelegate:self];
[self installDNSChangesCallback];
[self setShouldPresentUserAgentLaunchError:YES];
@@ -1842,13 +1847,16 @@ - (void)authenticationFailureControllerDidChangeUsernameAndPassword:(NSNotificat
}
}
-
#pragma mark - NSUserNotificationCenterDelegate
- (void)userNotificationCenter:(NSUserNotificationCenter *)center
didActivateNotification:(NSUserNotification *)notification {
NSString *identifier = notification.userInfo[kUserNotificationCallControllerIdentifierKey];
+ [self showWindowOfCallControllerWithIdentifier:identifier];
+}
+
+- (void)showWindowOfCallControllerWithIdentifier:(NSString *)identifier {
CallController *callController = [self callControllerByIdentifier:identifier];
if (![NSApp isActive]) {
[NSApp activateIgnoringOtherApps:YES];
@@ -1857,6 +1865,19 @@ - (void)userNotificationCenter:(NSUserNotificationCenter *)center
}
+
+#pragma mark -
+#pragma mark GrowlApplicationBridgeDelegate protocol
+
+- (void)growlNotificationWasClicked:(id)clickContext {
+ NSString *identifier = (NSString *)clickContext;
+ [self showWindowOfCallControllerWithIdentifier:identifier];
+}
+
+- (BOOL)hasNetworkClientEntitlement {
+ return YES;
+}
+
#pragma mark -
#pragma mark NSWorkspace notifications
View
12 Classes/CallController.m
@@ -30,6 +30,8 @@
#import "CallController.h"
+#import <Growl/Growl.h>
+
#import "AKActiveCallView.h"
#import "AKResponsiveProgressIndicator.h"
#import "AKNSString+Creating.h"
@@ -648,6 +650,16 @@ - (void)SIPCallDidDisconnect:(NSNotification *)notification {
userNotification.informativeText = self.status;
userNotification.userInfo = @{kUserNotificationCallControllerIdentifierKey: self.identifier};
[[NSUserNotificationCenter defaultUserNotificationCenter] deliverNotification:userNotification];
+
+ if ([[NSUserDefaults standardUserDefaults] boolForKey:kShowGrowlNotifications]) {
+ [GrowlApplicationBridge notifyWithTitle:notificationTitle
+ description:[self status]
+ notificationName:kGrowlNotificationCallEnded
+ iconData:nil
+ priority:0
+ isSticky:NO
+ clickContext:[self identifier]];
+ }
}
// Optionally close disconnected call window.

0 comments on commit 109996b

Please sign in to comment.