Skip to content
Browse files

120 columns in plug-ins

  • Loading branch information...
1 parent 7425010 commit 324980579103ec80d34cf069902399a6a3c236c7 @eofster committed Nov 25, 2012
View
29 PlugIns/AddressBook/AKAddressBookPhonePlugIn.h
@@ -33,37 +33,32 @@
// Object: @"AddressBook".
// Keys: @"AKPhoneNumber", @"AKFullName".
-NSString * const AKAddressBookDidDialPhoneNumberNotification
- = @"AKAddressBookDidDialPhoneNumber";
+NSString * const AKAddressBookDidDialPhoneNumberNotification = @"AKAddressBookDidDialPhoneNumber";
// An Address Book plug-in to dial phone numbers with Telephone.
@interface AKAddressBookPhonePlugIn : NSObject {
- NSString *lastPhoneNumber_;
- NSString *lastFullName_;
- BOOL shouldDial_;
+ NSString *lastPhoneNumber_;
+ NSString *lastFullName_;
+ BOOL shouldDial_;
}
-// Phone number that has been dialed last. While Telephone is being launched,
-// several phone numbers can be dialed. We handle only the last one.
+// Phone number that has been dialed last. While Telephone is being launched, several phone numbers can be dialed. We
+// handle only the last one.
@property (nonatomic, copy) NSString *lastPhoneNumber;
-// Full name of the contact that has been dialed last. While Telephone is being
-// launched, several phone numbers can be dialed. We handle only the last one.
+// Full name of the contact that has been dialed last. While Telephone is being launched, several phone numbers can be
+// dialed. We handle only the last one.
@property (nonatomic, copy) NSString *lastFullName;
-// A Boolean value that determines whether a call should be made after Telephone
-// starts up.
+// A Boolean value that determines whether a call should be made after Telephone starts up.
@property (nonatomic, assign) BOOL shouldDial;
- (NSString *)actionProperty;
-- (NSString *)titleForPerson:(ABPerson *)person
- identifier:(NSString *)identifier;
+- (NSString *)titleForPerson:(ABPerson *)person identifier:(NSString *)identifier;
-- (void)performActionForPerson:(ABPerson *)person
- identifier:(NSString *)identifier;
+- (void)performActionForPerson:(ABPerson *)person identifier:(NSString *)identifier;
-- (BOOL)shouldEnableActionForPerson:(ABPerson *)person
- identifier:(NSString *)identifier;
+- (BOOL)shouldEnableActionForPerson:(ABPerson *)person identifier:(NSString *)identifier;
@end
View
143 PlugIns/AddressBook/AKAddressBookPhonePlugIn.m
@@ -40,102 +40,91 @@ @implementation AKAddressBookPhonePlugIn
@synthesize shouldDial = shouldDial_;
- (id)init {
- self = [super init];
- if (self == nil) {
- return nil;
- }
-
- [self setShouldDial:NO];
-
- NSNotificationCenter *notificationCenter
- = [[NSWorkspace sharedWorkspace] notificationCenter];
-
- [notificationCenter addObserver:self
- selector:@selector(workspaceDidLaunchApplication:)
- name:NSWorkspaceDidLaunchApplicationNotification
- object:nil];
-
- return self;
+ self = [super init];
+ if (self == nil) {
+ return nil;
+ }
+
+ [self setShouldDial:NO];
+
+ NSNotificationCenter *notificationCenter = [[NSWorkspace sharedWorkspace] notificationCenter];
+
+ [notificationCenter addObserver:self
+ selector:@selector(workspaceDidLaunchApplication:)
+ name:NSWorkspaceDidLaunchApplicationNotification
+ object:nil];
+
+ return self;
}
- (void)dealloc {
- [lastPhoneNumber_ release];
- [lastFullName_ release];
-
- [super dealloc];
+ [lastPhoneNumber_ release];
+ [lastFullName_ release];
+
+ [super dealloc];
}
// This plug-in handles phone numbers.
- (NSString *)actionProperty {
- return kABPhoneProperty;
+ return kABPhoneProperty;
}
-- (NSString *)titleForPerson:(ABPerson *)person
- identifier:(NSString *)identifier {
- NSBundle *bundle
- = [NSBundle bundleWithIdentifier:@"com.tlphn.TelephoneAddressBookPhonePlugIn"];
-
- return NSLocalizedStringFromTableInBundle(@"Dial with Telephone",
- nil, bundle,
- @"Action title.");
+- (NSString *)titleForPerson:(ABPerson *)person identifier:(NSString *)identifier {
+ NSBundle *bundle = [NSBundle bundleWithIdentifier:@"com.tlphn.TelephoneAddressBookPhonePlugIn"];
+
+ return NSLocalizedStringFromTableInBundle(@"Dial with Telephone", nil, bundle, @"Action title.");
}
-- (void)performActionForPerson:(ABPerson *)person
- identifier:(NSString *)identifier {
-
- NSArray *applications = [[NSWorkspace sharedWorkspace] runningApplications];
- NSPredicate *predicate = [NSPredicate predicateWithFormat:
- @"bundleIdentifier == 'com.tlphn.Telephone'"];
- applications = [applications filteredArrayUsingPredicate:predicate];
- BOOL isTelephoneLaunched = [applications count] > 0;
-
- ABMultiValue *phones = [person valueForProperty:[self actionProperty]];
- NSString *phoneNumber = [phones valueForIdentifier:identifier];
- NSString *fullName = [person ak_fullName];
-
- if (!isTelephoneLaunched) {
- [[NSWorkspace sharedWorkspace] launchApplication:@"Telephone"];
- [self setShouldDial:YES];
- [self setLastPhoneNumber:phoneNumber];
- [self setLastFullName:fullName];
+- (void)performActionForPerson:(ABPerson *)person identifier:(NSString *)identifier {
+ NSArray *applications = [[NSWorkspace sharedWorkspace] runningApplications];
+ NSPredicate *predicate = [NSPredicate predicateWithFormat:@"bundleIdentifier == 'com.tlphn.Telephone'"];
+ applications = [applications filteredArrayUsingPredicate:predicate];
+ BOOL isTelephoneLaunched = [applications count] > 0;
- } else {
- NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:
- phoneNumber, @"AKPhoneNumber",
- fullName, @"AKFullName",
- nil];
+ ABMultiValue *phones = [person valueForProperty:[self actionProperty]];
+ NSString *phoneNumber = [phones valueForIdentifier:identifier];
+ NSString *fullName = [person ak_fullName];
- [[NSDistributedNotificationCenter defaultCenter]
- postNotificationName:AKAddressBookDidDialPhoneNumberNotification
- object:@"AddressBook"
- userInfo:userInfo];
- }
+ if (!isTelephoneLaunched) {
+ [[NSWorkspace sharedWorkspace] launchApplication:@"Telephone"];
+ [self setShouldDial:YES];
+ [self setLastPhoneNumber:phoneNumber];
+ [self setLastFullName:fullName];
+
+ } else {
+ NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:
+ phoneNumber, @"AKPhoneNumber",
+ fullName, @"AKFullName",
+ nil];
+
+ [[NSDistributedNotificationCenter defaultCenter]
+ postNotificationName:AKAddressBookDidDialPhoneNumberNotification
+ object:@"AddressBook"
+ userInfo:userInfo];
+ }
}
-- (BOOL)shouldEnableActionForPerson:(ABPerson *)person
- identifier:(NSString *)identifier {
- return YES;
+- (BOOL)shouldEnableActionForPerson:(ABPerson *)person identifier:(NSString *)identifier {
+ return YES;
}
- (void)workspaceDidLaunchApplication:(NSNotification *)notification {
- NSRunningApplication *application
- = [[notification userInfo] objectForKey:NSWorkspaceApplicationKey];
- NSString *bundleIdentifier = [application bundleIdentifier];
-
- if ([bundleIdentifier isEqualToString:@"com.tlphn.Telephone"] &&
- [self shouldDial]) {
- [self setShouldDial:NO];
-
- NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:
- [self lastPhoneNumber], @"AKPhoneNumber",
- [self lastFullName], @"AKFullName",
- nil];
+ NSRunningApplication *application = [[notification userInfo] objectForKey:NSWorkspaceApplicationKey];
+ NSString *bundleIdentifier = [application bundleIdentifier];
- [[NSDistributedNotificationCenter defaultCenter]
- postNotificationName:AKAddressBookDidDialPhoneNumberNotification
- object:@"AddressBook"
- userInfo:userInfo];
- }
+ if ([bundleIdentifier isEqualToString:@"com.tlphn.Telephone"] && [self shouldDial]) {
+ [self setShouldDial:NO];
+
+ NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:
+ [self lastPhoneNumber], @"AKPhoneNumber",
+ [self lastFullName], @"AKFullName",
+ nil];
+
+ [[NSDistributedNotificationCenter defaultCenter]
+ postNotificationName:AKAddressBookDidDialPhoneNumberNotification
+ object:@"AddressBook"
+ userInfo:userInfo];
+ }
}
@end
View
32 PlugIns/AddressBook/AKAddressBookSIPAddressPlugIn.h
@@ -33,38 +33,32 @@
// Object: @"AddressBook".
// Keys: @"AKSIPAddress", @"AKFullName".
-NSString * const AKAddressBookDidDialSIPAddressNotification
- = @"AKAddressBookDidDialSIPAddress";
+NSString * const AKAddressBookDidDialSIPAddressNotification = @"AKAddressBookDidDialSIPAddress";
-// An address book plug-in to dial SIP addresses with Telephone. SIP addresses
-// are emails with a custom label |sip|.
+// An address book plug-in to dial SIP addresses with Telephone. SIP addresses are emails with a custom label |sip|.
@interface AKAddressBookSIPAddressPlugIn : NSObject {
- NSString *lastSIPAddress_;
- NSString *lastFullName_;
- BOOL shouldDial_;
+ NSString *lastSIPAddress_;
+ NSString *lastFullName_;
+ BOOL shouldDial_;
}
-// SIP address that has been dialed last. While Telephone is being launched,
-// several phone numbers can be dialed. We handle only the last one.
+// SIP address that has been dialed last. While Telephone is being launched, several phone numbers can be dialed. We
+// handle only the last one.
@property (nonatomic, copy) NSString *lastSIPAddress;
-// Full name of the contact that has been dialed last. While Telephone is being
-// launched, several phone numbers can be dialed. We handle only the last one.
+// Full name of the contact that has been dialed last. While Telephone is being launched, several phone numbers can be
+// dialed. We handle only the last one.
@property (nonatomic, copy) NSString *lastFullName;
-// A Boolean value that determines whether a call should be made after Telephone
-// starts up.
+// A Boolean value that determines whether a call should be made after Telephone starts up.
@property (nonatomic, assign) BOOL shouldDial;
- (NSString *)actionProperty;
-- (NSString *)titleForPerson:(ABPerson *)person
- identifier:(NSString *)identifier;
+- (NSString *)titleForPerson:(ABPerson *)person identifier:(NSString *)identifier;
-- (void)performActionForPerson:(ABPerson *)person
- identifier:(NSString *)identifier;
+- (void)performActionForPerson:(ABPerson *)person identifier:(NSString *)identifier;
-- (BOOL)shouldEnableActionForPerson:(ABPerson *)person
- identifier:(NSString *)identifier;
+- (BOOL)shouldEnableActionForPerson:(ABPerson *)person identifier:(NSString *)identifier;
@end
View
162 PlugIns/AddressBook/AKAddressBookSIPAddressPlugIn.m
@@ -40,113 +40,99 @@ @implementation AKAddressBookSIPAddressPlugIn
@synthesize shouldDial = shouldDial_;
- (id)init {
- self = [super init];
- if (self == nil) {
- return nil;
- }
-
- [self setShouldDial:NO];
-
- NSNotificationCenter *notificationCenter
- = [[NSWorkspace sharedWorkspace] notificationCenter];
-
- [notificationCenter addObserver:self
- selector:@selector(workspaceDidLaunchApplication:)
- name:NSWorkspaceDidLaunchApplicationNotification
- object:nil];
-
- return self;
+ self = [super init];
+ if (self == nil) {
+ return nil;
+ }
+
+ [self setShouldDial:NO];
+
+ NSNotificationCenter *notificationCenter = [[NSWorkspace sharedWorkspace] notificationCenter];
+
+ [notificationCenter addObserver:self
+ selector:@selector(workspaceDidLaunchApplication:)
+ name:NSWorkspaceDidLaunchApplicationNotification
+ object:nil];
+
+ return self;
}
- (void)dealloc {
- [lastSIPAddress_ release];
- [lastFullName_ release];
-
- [super dealloc];
+ [lastSIPAddress_ release];
+ [lastFullName_ release];
+
+ [super dealloc];
}
// This plug-in handles emails.
- (NSString *)actionProperty {
- return kABEmailProperty;
+ return kABEmailProperty;
}
-- (NSString *)titleForPerson:(ABPerson *)person
- identifier:(NSString *)identifier {
-
- NSBundle *bundle = [NSBundle bundleWithIdentifier:
- @"com.tlphn.TelephoneAddressBookSIPAddressPlugIn"];
-
- return NSLocalizedStringFromTableInBundle(@"Dial with Telephone",
- nil,
- bundle,
- @"Action title.");
+- (NSString *)titleForPerson:(ABPerson *)person identifier:(NSString *)identifier {
+ NSBundle *bundle = [NSBundle bundleWithIdentifier:@"com.tlphn.TelephoneAddressBookSIPAddressPlugIn"];
+
+ return NSLocalizedStringFromTableInBundle(@"Dial with Telephone", nil, bundle, @"Action title.");
}
-- (void)performActionForPerson:(ABPerson *)person
- identifier:(NSString *)identifier {
-
- NSArray *applications = [[NSWorkspace sharedWorkspace] runningApplications];
- NSPredicate *predicate = [NSPredicate predicateWithFormat:
- @"bundleIdentifier == 'com.tlphn.Telephone'"];
- applications = [applications filteredArrayUsingPredicate:predicate];
- BOOL isTelephoneLaunched = [applications count] > 0;
-
- ABMultiValue *emails = [person valueForProperty:[self actionProperty]];
- NSString *anEmail = [emails valueForIdentifier:identifier];
- NSString *fullName = [person ak_fullName];
-
- if (!isTelephoneLaunched) {
- [[NSWorkspace sharedWorkspace] launchApplication:@"Telephone"];
- [self setShouldDial:YES];
- [self setLastSIPAddress:anEmail];
- [self setLastFullName:fullName];
+- (void)performActionForPerson:(ABPerson *)person identifier:(NSString *)identifier {
+ NSArray *applications = [[NSWorkspace sharedWorkspace] runningApplications];
+ NSPredicate *predicate = [NSPredicate predicateWithFormat:@"bundleIdentifier == 'com.tlphn.Telephone'"];
+ applications = [applications filteredArrayUsingPredicate:predicate];
+ BOOL isTelephoneLaunched = [applications count] > 0;
- } else {
- NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:
- anEmail, @"AKSIPAddress",
- fullName, @"AKFullName",
- nil];
+ ABMultiValue *emails = [person valueForProperty:[self actionProperty]];
+ NSString *anEmail = [emails valueForIdentifier:identifier];
+ NSString *fullName = [person ak_fullName];
- [[NSDistributedNotificationCenter defaultCenter]
- postNotificationName:AKAddressBookDidDialSIPAddressNotification
- object:@"AddressBook"
- userInfo:userInfo];
- }
+ if (!isTelephoneLaunched) {
+ [[NSWorkspace sharedWorkspace] launchApplication:@"Telephone"];
+ [self setShouldDial:YES];
+ [self setLastSIPAddress:anEmail];
+ [self setLastFullName:fullName];
+
+ } else {
+ NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:
+ anEmail, @"AKSIPAddress",
+ fullName, @"AKFullName",
+ nil];
+
+ [[NSDistributedNotificationCenter defaultCenter]
+ postNotificationName:AKAddressBookDidDialSIPAddressNotification
+ object:@"AddressBook"
+ userInfo:userInfo];
+ }
}
-- (BOOL)shouldEnableActionForPerson:(ABPerson *)person
- identifier:(NSString *)identifier {
-
- ABMultiValue *emails = [person valueForProperty:[self actionProperty]];
- NSString *label = [emails labelForIdentifier:identifier];
-
- // Enable the action only if label is |sip|.
- if ([label caseInsensitiveCompare:@"sip"] == NSOrderedSame) {
- return YES;
- } else {
- return NO;
- }
+- (BOOL)shouldEnableActionForPerson:(ABPerson *)person identifier:(NSString *)identifier {
+ ABMultiValue *emails = [person valueForProperty:[self actionProperty]];
+ NSString *label = [emails labelForIdentifier:identifier];
+
+ // Enable the action only if label is |sip|.
+ if ([label caseInsensitiveCompare:@"sip"] == NSOrderedSame) {
+ return YES;
+ } else {
+ return NO;
+ }
}
- (void)workspaceDidLaunchApplication:(NSNotification *)notification {
- NSRunningApplication *application
- = [[notification userInfo] objectForKey:NSWorkspaceApplicationKey];
- NSString *bundleIdentifier = [application bundleIdentifier];
-
- if ([bundleIdentifier isEqualToString:@"com.tlphn.Telephone"] &&
- [self shouldDial]) {
- [self setShouldDial:NO];
-
- NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:
- [self lastSIPAddress], @"AKSIPAddress",
- [self lastFullName], @"AKFullName",
- nil];
+ NSRunningApplication *application = [[notification userInfo] objectForKey:NSWorkspaceApplicationKey];
+ NSString *bundleIdentifier = [application bundleIdentifier];
- [[NSDistributedNotificationCenter defaultCenter]
- postNotificationName:AKAddressBookDidDialSIPAddressNotification
- object:@"AddressBook"
- userInfo:userInfo];
- }
+ if ([bundleIdentifier isEqualToString:@"com.tlphn.Telephone"] && [self shouldDial]) {
+ [self setShouldDial:NO];
+
+ NSDictionary *userInfo = [NSDictionary dictionaryWithObjectsAndKeys:
+ [self lastSIPAddress], @"AKSIPAddress",
+ [self lastFullName], @"AKFullName",
+ nil];
+
+ [[NSDistributedNotificationCenter defaultCenter]
+ postNotificationName:AKAddressBookDidDialSIPAddressNotification
+ object:@"AddressBook"
+ userInfo:userInfo];
+ }
}
@end
View
8 Telephone.xcodeproj/project.pbxproj
@@ -284,12 +284,12 @@
AAECDE8E0E70703100CEAE7B /* AKNSString+Scanning.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = "AKNSString+Scanning.m"; sourceTree = "<group>"; tabWidth = 4; };
AAEE7C2F0ECD953200A7DEB4 /* AKNSWindow+Resizing.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = "AKNSWindow+Resizing.h"; sourceTree = "<group>"; tabWidth = 4; };
AAEE7C300ECD953200A7DEB4 /* AKNSWindow+Resizing.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = "AKNSWindow+Resizing.m"; sourceTree = "<group>"; tabWidth = 4; };
- AAF298D30F574744007B5036 /* AKAddressBookPhonePlugIn.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.c.h; path = AKAddressBookPhonePlugIn.h; sourceTree = "<group>"; tabWidth = 2; };
- AAF298D40F574744007B5036 /* AKAddressBookPhonePlugIn.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.c.objc; path = AKAddressBookPhonePlugIn.m; sourceTree = "<group>"; tabWidth = 2; };
+ AAF298D30F574744007B5036 /* AKAddressBookPhonePlugIn.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = AKAddressBookPhonePlugIn.h; sourceTree = "<group>"; tabWidth = 4; };
+ AAF298D40F574744007B5036 /* AKAddressBookPhonePlugIn.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = AKAddressBookPhonePlugIn.m; sourceTree = "<group>"; tabWidth = 4; };
AAF299100F575044007B5036 /* TelephoneAddressBookPhonePlugIn.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = TelephoneAddressBookPhonePlugIn.bundle; sourceTree = BUILT_PRODUCTS_DIR; };
AAF299110F575044007B5036 /* TelephoneAddressBookPhonePlugIn-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "TelephoneAddressBookPhonePlugIn-Info.plist"; sourceTree = "<group>"; };
- AAF2998C0F575549007B5036 /* AKAddressBookSIPAddressPlugIn.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.c.objc; path = AKAddressBookSIPAddressPlugIn.m; sourceTree = "<group>"; tabWidth = 2; };
- AAF2998D0F575549007B5036 /* AKAddressBookSIPAddressPlugIn.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 2; lastKnownFileType = sourcecode.c.h; path = AKAddressBookSIPAddressPlugIn.h; sourceTree = "<group>"; tabWidth = 2; };
+ AAF2998C0F575549007B5036 /* AKAddressBookSIPAddressPlugIn.m */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.objc; path = AKAddressBookSIPAddressPlugIn.m; sourceTree = "<group>"; tabWidth = 4; };
+ AAF2998D0F575549007B5036 /* AKAddressBookSIPAddressPlugIn.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 4; lastKnownFileType = sourcecode.c.h; path = AKAddressBookSIPAddressPlugIn.h; sourceTree = "<group>"; tabWidth = 4; };
AAF299970F57566B007B5036 /* TelephoneAddressBookSIPAddressPlugIn.bundle */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = TelephoneAddressBookSIPAddressPlugIn.bundle; sourceTree = BUILT_PRODUCTS_DIR; };
AAF299980F57566B007B5036 /* TelephoneAddressBookSIPAddressPlugIn-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "TelephoneAddressBookSIPAddressPlugIn-Info.plist"; sourceTree = "<group>"; };
AAF29A430F5759F7007B5036 /* English */ = {isa = PBXFileReference; fileEncoding = 10; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/Localizable.strings; sourceTree = "<group>"; };

0 comments on commit 3249805

Please sign in to comment.
Something went wrong with that request. Please try again.