diff --git a/Contacts/ABAddressBook.h b/Contacts/ABAddressBook.h deleted file mode 100644 index 00f739b..0000000 --- a/Contacts/ABAddressBook.h +++ /dev/null @@ -1,95 +0,0 @@ -/* - * ABAddressBook.h - * AQToolkit - * - * Created by Jim Dovey on 5/6/2009. - * - * Copyright (c) 2009 Jim Dovey - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the project's author nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#import -#import -#import "ABRefInitialization.h" - -@class ABRecord, ABPerson, ABGroup; -@protocol ABAddressBookDelegate; - -enum -{ - ABOperationNotPermittedByStoreError = kABOperationNotPermittedByStoreError - -}; - -@interface ABAddressBook : NSObject -{ - ABAddressBookRef _ref; - id _delegate; -} - -@property (nonatomic, readonly, getter=getAddressBookRef) ABAddressBookRef addressBookRef; - -@property (nonatomic, assign) id delegate; - -- (BOOL) save: (NSError **) error; -@property (nonatomic, readonly) BOOL hasUnsavedChanges; - -- (BOOL) addRecord: (ABRecord *) record error: (NSError **) error; -- (BOOL) removeRecord: (ABRecord *) record error: (NSError **) error; - -- (NSString *) localizedStringForLabel: (NSString *) labelName; - -- (void) revert; - -@end - -@interface ABAddressBook (People) - -@property (nonatomic, readonly) NSUInteger personCount; - -- (ABPerson *) personWithRecordID: (ABRecordID) recordID; -- (NSArray *) allPeople; -- (NSArray *) allPeopleWithName: (NSString *) name; - -@end - -@interface ABAddressBook (Groups) - -@property (nonatomic, readonly) NSUInteger groupCount; - -- (ABGroup *) groupWithRecordID: (ABRecordID) recordID; -- (NSArray *) allGroups; - -@end - -@protocol ABAddressBookDelegate -- (void) addressBookDidChange: (ABAddressBook *) addressBook; -@end diff --git a/Contacts/ABAddressBook.m b/Contacts/ABAddressBook.m deleted file mode 100644 index cf03d83..0000000 --- a/Contacts/ABAddressBook.m +++ /dev/null @@ -1,245 +0,0 @@ -/* - * ABAddressBook.m - * AQToolkit - * - * Created by Jim Dovey on 5/6/2009. - * - * Copyright (c) 2009 Jim Dovey - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the project's author nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#import "ABAddressBook.h" -#import "ABPerson.h" -#import "ABGroup.h" - -NSArray * WrappedArrayOfRecords( NSArray * records, Class wrapperClass ) -{ - NSMutableArray * wrapped = [[NSMutableArray alloc] initWithCapacity: [records count]]; - for ( id record in records ) - { - id obj = [[wrapperClass alloc] initWithABRef: (CFTypeRef)record]; - [wrapped addObject: obj]; - [obj release]; - } - - NSArray * result = [wrapped copy]; - [wrapped release]; - - return ( [result autorelease] ); -} - -@interface ABAddressBook () -- (void) _handleExternalChangeCallback; -@end - -static void _ExternalChangeCallback( ABAddressBookRef bookRef, CFDictionaryRef info, void * context ) -{ - ABAddressBook * obj = (ABAddressBook *) context; - [obj _handleExternalChangeCallback]; -} - -@implementation ABAddressBook - -@synthesize addressBookRef=_ref; - -- (id) initWithABRef: (CFTypeRef) ref -{ - if ( ref == NULL ) - { - [self release]; - return ( nil ); - } - - if ( [super init] == nil ) - return ( nil ); - - // we can't to CFTypeID checking on AB types, so we have to trust the user - _ref = (ABAddressBookRef) CFRetain(ref); - - return ( self ); -} - -- (id) init -{ - if ( [super init] == nil ) - return ( nil ); - - _ref = ABAddressBookCreate(); - if ( _ref == NULL ) - { - [self release]; - return ( nil ); - } - - return ( self ); -} - -- (void) dealloc -{ - self.delegate = nil; - if ( _ref != NULL ) - CFRelease( _ref ); - [super dealloc]; -} - -- (id) delegate -{ - return ( _delegate ); -} - -- (void) setDelegate: (id) delegate -{ - if ( (_delegate == nil) && (delegate != nil) ) - ABAddressBookRegisterExternalChangeCallback( _ref, _ExternalChangeCallback, self ); - else if ( (_delegate != nil) && (delegate == nil) ) - ABAddressBookUnregisterExternalChangeCallback( _ref, _ExternalChangeCallback, self ); - - _delegate = delegate; -} - -- (BOOL) save: (NSError **) error -{ - return ( (BOOL) ABAddressBookSave(_ref, (CFErrorRef *)error) ); -} - -- (BOOL) hasUnsavedChanges -{ - return ( (BOOL) ABAddressBookHasUnsavedChanges(_ref) ); -} - -- (BOOL) addRecord: (ABRecord *) record error: (NSError **) error -{ - return ( (BOOL) ABAddressBookAddRecord(_ref, record.recordRef, (CFErrorRef *)error) ); -} - -- (BOOL) removeRecord: (ABRecord *) record error: (NSError **) error -{ - return ( (BOOL) ABAddressBookRemoveRecord(_ref, record.recordRef, (CFErrorRef *)error) ); -} - -- (NSString *) localizedStringForLabel: (NSString *) label -{ - NSString * str = (NSString *) ABAddressBookCopyLocalizedLabel( (CFStringRef)label ); - return ( [str autorelease] ); -} - -- (void) revert -{ - ABAddressBookRevert( _ref ); -} - -- (void) _handleExternalChangeCallback -{ - [_delegate addressBookDidChange: self]; -} - -@end - -@implementation ABAddressBook (People) - -- (NSUInteger) personCount -{ - return ( (NSUInteger) ABAddressBookGetPersonCount(_ref) ); -} - -- (ABPerson *) personWithRecordID: (ABRecordID) recordID -{ - ABRecordRef person = ABAddressBookGetPersonWithRecordID( _ref, recordID ); - if ( person == NULL ) - return ( nil ); - - return ( [[[ABPerson alloc] initWithABRef: person] autorelease] ); -} - -- (NSArray *) allPeople -{ - NSArray * people = (NSArray *) ABAddressBookCopyArrayOfAllPeople( _ref ); - if ( [people count] == 0 ) - { - [people release]; - return ( nil ); - } - - NSArray * result = WrappedArrayOfRecords( people, [ABPerson class] ); - [people release]; - - return ( result ); -} - -- (NSArray *) allPeopleWithName: (NSString *) name -{ - NSArray * people = (NSArray *) ABAddressBookCopyPeopleWithName( _ref, (CFStringRef)name ); - if ( [people count] == 0 ) - { - [people release]; - return ( nil ); - } - - NSArray * result = WrappedArrayOfRecords( people, [ABPerson class] ); - [people release]; - - return ( result ); -} - -@end - -@implementation ABAddressBook (Groups) - -- (NSUInteger) groupCount -{ - return ( (NSUInteger) ABAddressBookGetGroupCount(_ref) ); -} - -- (ABGroup *) groupWithRecordID: (ABRecordID) recordID -{ - ABRecordRef group = ABAddressBookGetGroupWithRecordID( _ref, recordID ); - if ( group == NULL ) - return ( nil ); - - return ( [[[ABGroup alloc] initWithABRef: group] autorelease] ); -} - -- (NSArray *) allGroups -{ - NSArray * groups = (NSArray *) ABAddressBookCopyArrayOfAllGroups( _ref ); - if ( [groups count] == 0 ) - { - [groups release]; - return ( nil ); - } - - NSArray * result = WrappedArrayOfRecords( groups, [ABGroup class] ); - [groups release]; - - return ( result ); -} - -@end diff --git a/Contacts/ABGroup.h b/Contacts/ABGroup.h deleted file mode 100644 index a9c313f..0000000 --- a/Contacts/ABGroup.h +++ /dev/null @@ -1,27 +0,0 @@ -// -// ABGroup.h -// Skydeck -// -// Created by Jim Dovey on 06/06/09. -// Copyright 2009 Morfunk, LLC. All rights reserved. -// - -#import -#import -#import "ABRecord.h" - -@class ABPerson; - -@interface ABGroup : ABRecord - -// use -init to create a new group - -- (NSArray *) allMembers; -- (NSArray *) allMembersSortedInOrder: (ABPersonSortOrdering) order; - -- (BOOL) addMember: (ABPerson *) person error: (NSError **) error; -- (BOOL) removeMember: (ABPerson *) person error: (NSError **) error; - -- (NSIndexSet *) indexSetWithAllMemberRecordIDs; - -@end diff --git a/Contacts/ABGroup.m b/Contacts/ABGroup.m deleted file mode 100644 index 9ceb2a9..0000000 --- a/Contacts/ABGroup.m +++ /dev/null @@ -1,91 +0,0 @@ -// -// ABGroup.m -// Skydeck -// -// Created by Jim Dovey on 06/06/09. -// Copyright 2009 Morfunk, LLC. All rights reserved. -// - -#import "ABGroup.h" -#import "ABPerson.h" - -extern NSArray * WrappedArrayOfRecords( NSArray * records, Class class ); - -@implementation ABGroup - -- (id) init -{ - ABRecordRef group = ABGroupCreate(); - if ( group == NULL ) - { - [self release]; - return ( nil ); - } - - return ( [self initWithABRef: group] ); -} - -- (NSArray *) allMembers -{ - NSArray * members = (NSArray *) ABGroupCopyArrayOfAllMembers( _ref ); - if ( [members count] == 0 ) - { - [members release]; - return ( nil ); - } - - NSArray * result = (NSArray *) WrappedArrayOfRecords( members, [ABPerson class] ); - [members release]; - - return ( result ); -} - -- (NSArray *) allMembersSortedInOrder: (ABPersonSortOrdering) order -{ - NSArray * members = (NSArray *) ABGroupCopyArrayOfAllMembersWithSortOrdering( _ref, order ); - if ( [members count] == 0 ) - { - [members release]; - return ( nil ); - } - - NSArray * result = (NSArray *) WrappedArrayOfRecords( members, [ABPerson class] ); - [members release]; - - return ( result ); -} - -- (BOOL) addMember: (ABPerson *) person error: (NSError **) error -{ - return ( (BOOL) ABGroupAddMember(_ref, person.recordRef, (CFErrorRef *)error) ); -} - -- (BOOL) removeMember: (ABPerson *) person error: (NSError **) error -{ - return ( (BOOL) ABGroupRemoveMember(_ref, person.recordRef, (CFErrorRef *)error) ); -} - -- (NSIndexSet *) indexSetWithAllMemberRecordIDs -{ - NSArray * members = (NSArray *) ABGroupCopyArrayOfAllMembers( _ref ); - if ( [members count] == 0 ) - { - [members release]; - return ( nil ); - } - - NSMutableIndexSet * mutable = [[NSMutableIndexSet alloc] init]; - for ( id person in members ) - { - [mutable addIndex: (NSUInteger)ABRecordGetRecordID((ABRecordRef)person)]; - } - - [members release]; - - NSIndexSet * result = [mutable copy]; - [mutable release]; - - return ( [result autorelease] ); -} - -@end diff --git a/Contacts/ABMultiValue.h b/Contacts/ABMultiValue.h deleted file mode 100644 index 21663fb..0000000 --- a/Contacts/ABMultiValue.h +++ /dev/null @@ -1,80 +0,0 @@ -/* - * ABMultiValue.h - * AQToolkit - * - * Created by Jim Dovey on 6/6/2009. - * - * Copyright (c) 2009 Jim Dovey - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the project's author nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#import -#import -#import "ABRefInitialization.h" - -@interface ABMultiValue : NSObject -{ - ABMultiValueRef _ref; -} - -@property (nonatomic, readonly, getter=getMultiValueRef) ABMultiValueRef multiValueRef; - -@property (nonatomic, readonly) ABPropertyType propertyType; -@property (nonatomic, readonly) NSUInteger count; - -- (id) valueAtIndex: (NSUInteger) index; -- (NSArray *) allValues; - -- (NSString *) labelAtIndex: (NSUInteger) index; - -- (NSUInteger) indexForIdentifier: (ABMultiValueIdentifier) identifier; -- (ABMultiValueIdentifier) identifierAtIndex: (NSUInteger) index; - -// returns the index of the first occurrence of hte specified value -- (NSUInteger) indexOfValue: (id) value; - -@end - -#pragma mark - - -@interface ABMutableMultiValue : ABMultiValue - -- (id) initWithPropertyType: (ABPropertyType) type; - -- (BOOL) addValue: (id) value withLabel: (NSString *) label identifier: (ABMultiValueIdentifier *) outIdentifier; -- (BOOL) insertValue: (id) value withLabel: (NSString *) label atIndex: (NSUInteger) index identifier: (ABMultiValueIdentifier *) outIdentifier; - -- (BOOL) removeValueAndLabelAtIndex: (NSUInteger) index; - -- (BOOL) replaceValueAtIndex: (NSUInteger) index withValue: (id) value; -- (BOOL) replaceLabelAtIndex: (NSUInteger) index withLabel: (NSString *) label; - -@end diff --git a/Contacts/ABMultiValue.m b/Contacts/ABMultiValue.m deleted file mode 100644 index c4ca652..0000000 --- a/Contacts/ABMultiValue.m +++ /dev/null @@ -1,176 +0,0 @@ -/* - * ABMultiValue.m - * AQToolkit - * - * Created by Jim Dovey on 6/6/2009. - * - * Copyright (c) 2009 Jim Dovey - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the project's author nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#import "ABMultiValue.h" - -@implementation ABMultiValue - -@synthesize multiValueRef=_ref; - -- (id) initWithABRef: (CFTypeRef) ref -{ - if ( ref == NULL ) - { - [self release]; - return ( nil ); - } - - if ( [super init] == nil ) - return ( nil ); - - _ref = (ABMultiValueRef) CFRetain(ref); - - return ( self ); -} - -- (void) dealloc -{ - if ( _ref != NULL ) - CFRelease( _ref ); - [super dealloc]; -} - -- (id) mutableCopyWithZone: (NSZone *) zone -{ - return ( [[ABMutableMultiValue allocWithZone: zone] initWithABRef: (CFTypeRef)ABMultiValueCreateMutableCopy(_ref)] ); -} - -- (ABPropertyType) propertyType -{ - return ( ABMultiValueGetPropertyType(_ref) ); -} - -- (NSUInteger) count -{ - return ( (NSUInteger) ABMultiValueGetCount(_ref) ); -} - -- (id) valueAtIndex: (NSUInteger) index -{ - id value = (id) ABMultiValueCopyValueAtIndex( _ref, (CFIndex)index ); - return ( [value autorelease] ); -} - -- (NSArray *) allValues -{ - NSArray * array = (NSArray *) ABMultiValueCopyArrayOfAllValues( _ref ); - return ( [array autorelease] ); -} - -- (NSString *) labelAtIndex: (NSUInteger) index -{ - NSString * result = (NSString *) ABMultiValueCopyLabelAtIndex( _ref, (CFIndex)index ); - return ( [result autorelease] ); -} - -- (NSUInteger) indexForIdentifier: (ABMultiValueIdentifier) identifier -{ - return ( (NSUInteger) ABMultiValueGetIndexForIdentifier(_ref, identifier) ); -} - -- (ABMultiValueIdentifier) identifierAtIndex: (NSUInteger) index -{ - return ( ABMultiValueGetIdentifierAtIndex(_ref, (CFIndex)index) ); -} - -- (NSUInteger) indexOfValue: (id) value -{ - return ( (NSUInteger) ABMultiValueGetFirstIndexOfValue(_ref, (CFTypeRef)value) ); -} - -@end - -#pragma mark - - -@implementation ABMutableMultiValue - -- (id) initWithPropertyType: (ABPropertyType) type -{ - ABMutableMultiValueRef ref = ABMultiValueCreateMutable(type); - if ( ref == NULL ) - { - [self release]; - return ( nil ); - } - - return ( [self initWithABRef: (CFTypeRef)ref] ); -} - -- (id) copyWithZone: (NSZone *) zone -{ - // no AB method to create an immutable copy, so we do a mutable copy but wrap it in an immutable class - CFTypeRef _obj = ABMultiValueCreateMutableCopy(_ref); - return ( [[ABMultiValue allocWithZone: zone] initWithABRef: _obj] ); -} - -- (ABMutableMultiValueRef) _mutableRef -{ - return ( (ABMutableMultiValueRef)_ref ); -} - -- (BOOL) addValue: (id) value - withLabel: (NSString *) label - identifier: (ABMultiValueIdentifier *) outIdentifier -{ - return ( (BOOL) ABMultiValueAddValueAndLabel([self _mutableRef], (CFTypeRef)value, (CFStringRef)label, outIdentifier) ); -} - -- (BOOL) insertValue: (id) value - withLabel: (NSString *) label - atIndex: (NSUInteger) index - identifier: (ABMultiValueIdentifier *) outIdentifier -{ - return ( (BOOL) ABMultiValueInsertValueAndLabelAtIndex([self _mutableRef], (CFTypeRef)value, (CFStringRef)label, (CFIndex)index, outIdentifier) ); -} - -- (BOOL) removeValueAndLabelAtIndex: (NSUInteger) index -{ - return ( (BOOL) ABMultiValueRemoveValueAndLabelAtIndex([self _mutableRef], (CFIndex)index) ); -} - -- (BOOL) replaceValueAtIndex: (NSUInteger) index withValue: (id) value -{ - return ( (BOOL) ABMultiValueReplaceValueAtIndex([self _mutableRef], (CFTypeRef)value, (CFIndex)index) ); -} - -- (BOOL) replaceLabelAtIndex: (NSUInteger) index withLabel: (NSString *) label -{ - return ( (BOOL) ABMultiValueReplaceLabelAtIndex([self _mutableRef], (CFStringRef)label, (CFIndex)index) ); -} - -@end diff --git a/Contacts/ABPerson.h b/Contacts/ABPerson.h deleted file mode 100644 index 40d5889..0000000 --- a/Contacts/ABPerson.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * ABPerson.h - * AQToolkit - * - * Created by Jim Dovey on 6/6/2009. - * - * Copyright (c) 2009 Jim Dovey - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the project's author nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#import -#import -#import "ABRecord.h" - -@interface ABPerson : ABRecord - -// use -init to create a new person - -+ (ABPropertyType) typeOfProperty: (ABPropertyID) property; -+ (NSString *) localizedNameOfProperty: (ABPropertyID) property; -+ (ABPersonSortOrdering) sortOrdering; -+ (ABPersonCompositeNameFormat) compositeNameFormat; - -- (BOOL) setImageData: (NSData *) imageData error: (NSError **) error; -- (NSData *) imageData; -@property (nonatomic, readonly) BOOL hasImageData; -- (BOOL) removeImageData: (NSError **) error; - -- (NSComparisonResult) compare: (ABPerson *) otherPerson; -- (NSComparisonResult) compare: (ABPerson *) otherPerson sortOrdering: (ABPersonSortOrdering) order; - -@end diff --git a/Contacts/ABPerson.m b/Contacts/ABPerson.m deleted file mode 100644 index 8fad8e8..0000000 --- a/Contacts/ABPerson.m +++ /dev/null @@ -1,107 +0,0 @@ -/* - * ABPerson.m - * AQToolkit - * - * Created by Jim Dovey on 6/6/2009. - * - * Copyright (c) 2009 Jim Dovey - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the project's author nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#import "ABPerson.h" - -@implementation ABPerson - -+ (ABPropertyType) typeOfProperty: (ABPropertyID) property -{ - return ( ABPersonGetTypeOfProperty(property) ); -} - -+ (NSString *) localizedNameOfProperty: (ABPropertyID) property -{ - NSString * name = (NSString *) ABPersonCopyLocalizedPropertyName(property); - return ( [name autorelease] ); -} - -+ (ABPersonSortOrdering) sortOrdering -{ - return ( ABPersonGetSortOrdering() ); -} - -+ (ABPersonCompositeNameFormat) compositeNameFormat -{ - return ( ABPersonGetCompositeNameFormat() ); -} - -- (id) init -{ - ABRecordRef person = ABPersonCreate(); - if ( person == NULL ) - { - [self release]; - return ( nil ); - } - - return ( [self initWithABRef: person] ); -} - -- (BOOL) setImageData: (NSData *) imageData error: (NSError **) error -{ - return ( (BOOL) ABPersonSetImageData(_ref, (CFDataRef)imageData, (CFErrorRef *)error) ); -} - -- (NSData *) imageData -{ - NSData * imageData = (NSData *) ABPersonCopyImageData( _ref ); - return ( [imageData autorelease] ); -} - -- (BOOL) hasImageData -{ - return ( (BOOL) ABPersonHasImageData(_ref) ); -} - -- (BOOL) removeImageData: (NSError **) error -{ - return ( (BOOL) ABPersonRemoveImageData(_ref, (CFErrorRef *)error) ); -} - -- (NSComparisonResult) compare: (ABPerson *) otherPerson -{ - return ( [self compare: otherPerson sortOrdering: ABPersonGetSortOrdering()] ); -} - -- (NSComparisonResult) compare: (ABPerson *) otherPerson sortOrdering: (ABPersonSortOrdering) order -{ - return ( (NSComparisonResult) ABPersonComparePeopleByName(_ref, otherPerson->_ref, order) ); -} - -@end diff --git a/Contacts/ABRecord.h b/Contacts/ABRecord.h deleted file mode 100644 index 2e8faa0..0000000 --- a/Contacts/ABRecord.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * ABRecord.h - * AQToolkit - * - * Created by Jim Dovey on 5/6/2009. - * - * Copyright (c) 2009 Jim Dovey - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the project's author nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#import -#import -#import "ABRefInitialization.h" - -@interface ABRecord : NSObject -{ - ABRecordRef _ref; -} - -@property (nonatomic, readonly, getter=getRecordRef) ABRecordRef recordRef; - -@property (nonatomic, readonly) ABRecordID recordID; -@property (nonatomic, readonly) ABRecordType recordType; - -- (id) valueForProperty: (ABPropertyID) property; -- (BOOL) setValue: (id) value forProperty: (ABPropertyID) property error: (NSError **) error; -- (BOOL) removeValueForProperty: (ABPropertyID) property error: (NSError **) error; - -@property (nonatomic, readonly) NSString * compositeName; - -@end diff --git a/Contacts/ABRecord.m b/Contacts/ABRecord.m deleted file mode 100644 index 6064e6b..0000000 --- a/Contacts/ABRecord.m +++ /dev/null @@ -1,109 +0,0 @@ -// -// ABRecord.m -// Skydeck -// -// Created by Jim Dovey on 05/06/09. -// Copyright 2009 Morfunk, LLC. All rights reserved. -// - -#import "ABRecord.h" -#import "ABMultiValue.h" - -#import - -static NSMutableIndexSet * __multiValuePropertyIDSet = nil; - -@implementation ABRecord - -@synthesize recordRef=_ref; - -+ (void) initialize -{ - if ( self != [ABRecord class] ) - return; - - __multiValuePropertyIDSet = [[NSMutableIndexSet alloc] init]; - [__multiValuePropertyIDSet addIndex: kABPersonEmailProperty]; - [__multiValuePropertyIDSet addIndex: kABPersonAddressProperty]; - [__multiValuePropertyIDSet addIndex: kABPersonDateProperty]; - [__multiValuePropertyIDSet addIndex: kABPersonPhoneProperty]; - [__multiValuePropertyIDSet addIndex: kABPersonInstantMessageProperty]; - [__multiValuePropertyIDSet addIndex: kABPersonURLProperty]; - [__multiValuePropertyIDSet addIndex: kABPersonRelatedNamesProperty]; -} - -+ (Class) wrapperClassForPropertyID: (ABPropertyID) propID -{ - if ( [__multiValuePropertyIDSet containsIndex: propID] ) - return ( [ABMultiValue class] ); - - return ( Nil ); -} - -- (id) initWithABRef: (CFTypeRef) recordRef -{ - if ( recordRef == NULL ) - { - [self release]; - return ( nil ); - } - - if ( [super init] == nil ) - return ( nil ); - - // we have to trust the user that the type is correct -- no CFTypeRef checking in AddressBook.framework - _ref = (ABRecordRef) CFRetain(recordRef); - - return ( self ); -} - -- (void) dealloc -{ - if ( _ref != NULL ) - CFRelease( _ref ); - [super dealloc]; -} - -- (ABRecordID) recordID -{ - return ( ABRecordGetRecordID(_ref) ); -} - -- (ABRecordType) recordType -{ - return ( ABRecordGetRecordType(_ref) ); -} - -- (id) valueForProperty: (ABPropertyID) property -{ - CFTypeRef value = ABRecordCopyValue( _ref, property ); - id result = nil; - - Class wrapperClass = [[self class] wrapperClassForPropertyID: property]; - if ( wrapperClass != Nil ) - result = [[wrapperClass alloc] initWithABRef: value]; - else - result = (id) value; - - return ( [result autorelease] ); -} - -- (BOOL) setValue: (id) value forProperty: (ABPropertyID) property error: (NSError **) error -{ - if ( [value isKindOfClass: [ABMultiValue class]] ) - value = (id) [value getMultiValueRef]; - return ( (BOOL) ABRecordSetValue(_ref, property, (CFTypeRef)value, (CFErrorRef *)error) ); -} - -- (BOOL) removeValueForProperty: (ABPropertyID) property error: (NSError **) error -{ - return ( (BOOL) ABRecordRemoveValue(_ref, property, (CFErrorRef *)error) ); -} - -- (NSString *) compositeName -{ - NSString * result = (NSString *) ABRecordCopyCompositeName( _ref ); - return ( [result autorelease] ); -} - -@end diff --git a/Contacts/ABRefInitialization.h b/Contacts/ABRefInitialization.h deleted file mode 100644 index 482d15d..0000000 --- a/Contacts/ABRefInitialization.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * ABRefInitialization.h - * AQToolkit - * - * Created by Jim Dovey on 6/6/2009. - * - * Copyright (c) 2009 Jim Dovey - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * - * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * Neither the name of the project's author nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED - * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#import - -@protocol ABRefInitialization -+ (id) alloc; // this keeps the compiler happy -- (id) initWithABRef: (CFTypeRef) ref; -@end