2014-05-06 19:41:08 +02:00
|
|
|
#import <Foundation/Foundation.h>
|
2014-08-20 14:08:32 +02:00
|
|
|
#import "CollapsingFutures.h"
|
2014-05-06 19:41:08 +02:00
|
|
|
#import "Contact.h"
|
|
|
|
#import "ObservableValue.h"
|
2015-10-31 13:27:07 +01:00
|
|
|
#import <Contacts/Contacts.h>
|
2014-05-06 19:41:08 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
* ContactsManager provides access to an updated list of contacts with optional categorizations -
|
|
|
|
* such as searching and favourite-attributed contacts (favourites are also managed through this class)
|
|
|
|
* Others can subscribe for contact and/or favourite updates
|
|
|
|
* Contacts can be grouped by first letter into an NSDictionary in order to display in individual sections-
|
|
|
|
* in the ContactBrowseViewController.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2015-11-29 01:14:49 +01:00
|
|
|
#define SIGNAL_LIST_UPDATED @"Signal_AB_UPDATED"
|
|
|
|
|
2014-05-06 19:41:08 +02:00
|
|
|
typedef void(^ABAccessRequestCompletionBlock)(BOOL hasAccess);
|
|
|
|
typedef void(^ABReloadRequestCompletionBlock)(NSArray *contacts);
|
|
|
|
|
|
|
|
@interface ContactsManager : NSObject {
|
2014-08-20 14:08:32 +02:00
|
|
|
@private TOCFuture* futureAddressBook;
|
2014-05-06 19:41:08 +02:00
|
|
|
@private ObservableValueController* observableContactsController;
|
2014-11-21 14:38:37 +01:00
|
|
|
@private ObservableValueController* observableTextSecureUsersController;
|
2014-08-20 14:08:32 +02:00
|
|
|
@private TOCCancelTokenSource* life;
|
2014-05-06 19:41:08 +02:00
|
|
|
@private NSDictionary *latestContactsById;
|
|
|
|
@private NSDictionary *latestWhisperUsersById;
|
|
|
|
}
|
|
|
|
|
2015-10-31 13:27:07 +01:00
|
|
|
@property CNContactStore *contactStore;
|
|
|
|
|
2014-05-06 19:41:08 +02:00
|
|
|
-(ObservableValue *) getObservableContacts;
|
2015-11-29 01:14:49 +01:00
|
|
|
//-(ObservableValue *) getObservableRedPhoneUsers;
|
2014-11-25 17:28:42 +01:00
|
|
|
|
2014-05-06 19:41:08 +02:00
|
|
|
-(NSArray*) getContactsFromAddressBook:(ABAddressBookRef)addressBook;
|
|
|
|
-(Contact*) latestContactWithRecordId:(ABRecordID)recordId;
|
|
|
|
-(Contact*) latestContactForPhoneNumber:(PhoneNumber *)phoneNumber;
|
|
|
|
-(NSArray*) latestContactsWithSearchString:(NSString *)searchString;
|
|
|
|
|
|
|
|
+(NSDictionary *)groupContactsByFirstLetter:(NSArray *)contacts matchingSearchString:(NSString *)optionalSearchString;
|
|
|
|
|
|
|
|
+(BOOL)name:(NSString *)nameString matchesQuery:(NSString *)queryString;
|
|
|
|
+(BOOL)phoneNumber:(PhoneNumber *)phoneNumber matchesQuery:(NSString *)queryString;
|
|
|
|
|
2015-08-24 01:47:25 +02:00
|
|
|
- (void)verifyABPermission;
|
|
|
|
|
2015-11-29 01:14:49 +01:00
|
|
|
- (NSArray<Contact *> *)allContacts;
|
2015-01-31 10:01:05 +01:00
|
|
|
- (NSArray*)signalContacts;
|
2014-11-21 14:38:37 +01:00
|
|
|
- (NSArray*)textSecureContacts;
|
2014-05-06 19:41:08 +02:00
|
|
|
|
2014-11-25 17:28:42 +01:00
|
|
|
-(void)doAfterEnvironmentInitSetup;
|
2014-11-23 21:57:18 +01:00
|
|
|
|
2014-11-25 19:06:09 +01:00
|
|
|
- (NSString*)nameStringForPhoneIdentifier:(NSString*)identifier;
|
|
|
|
- (UIImage*)imageForPhoneIdentifier:(NSString*)identifier;
|
2014-11-25 17:28:42 +01:00
|
|
|
|
2015-02-17 00:14:50 +01:00
|
|
|
+ (NSComparator)contactComparator;
|
|
|
|
|
2014-05-06 19:41:08 +02:00
|
|
|
@end
|