Remove useless property definitions + synthesize

This commit is contained in:
ylecollen 2015-01-21 13:26:29 +01:00
parent 2ae84ad0b9
commit 7af13a0b21
4 changed files with 34 additions and 48 deletions

View file

@ -24,21 +24,18 @@ extern NSString *const kConsoleContactMatrixIdentifierUpdateNotification;
// the contactID is provided in parameter
extern NSString *const kConsoleContactThumbnailUpdateNotification;
@interface ConsoleContact : NSObject {
UIImage* contactBookThumbnail;
UIImage* matrixThumbnail;
}
@interface ConsoleContact : NSObject
// unique identifier
@property (nonatomic, copy, readwrite) NSString * contactID;
@property (nonatomic, readonly) NSString * contactID;
// display name
@property (nonatomic, copy, readwrite) NSString *displayName;
@property (nonatomic, readonly) NSString *displayName;
// contact thumbnail
@property (nonatomic, copy, readonly) UIImage *thumbnail;
// array of ConsolePhoneNumber
@property (nonatomic, readwrite) NSArray *phoneNumbers;
@property (nonatomic, readonly) NSArray *phoneNumbers;
// array of ConsoleEmail
@property (nonatomic, readwrite) NSArray *emailAddresses;
@property (nonatomic, readonly) NSArray *emailAddresses;
// array of matrix identifiers
@property (nonatomic, readonly) NSArray* matrixIdentifiers;

View file

@ -16,6 +16,9 @@
#import "ConsoleContact.h"
#import "ConsoleEmail.h"
#import "ConsolePhoneNumber.h"
// warn when a contact has a new matrix identifier
// the contactID is provided in parameter
NSString *const kConsoleContactMatrixIdentifierUpdateNotification = @"kConsoleContactMatrixIdentifierUpdateNotification";
@ -24,27 +27,28 @@ NSString *const kConsoleContactMatrixIdentifierUpdateNotification = @"kConsoleCo
// the contactID is provided in parameter
NSString *const kConsoleContactThumbnailUpdateNotification = @"kConsoleContactThumbnailUpdateNotification";
#import "ConsoleEmail.h"
#import "ConsolePhoneNumber.h"
@interface ConsoleContact() {
UIImage* contactBookThumbnail;
UIImage* matrixThumbnail;
}
@end
@implementation ConsoleContact
@synthesize displayName, phoneNumbers, emailAddresses, contactID;
- (id) initWithABRecord:(ABRecordRef)record {
self = [super init];
if (self) {
// compute a contact ID
self.contactID = [NSString stringWithFormat:@"%d", ABRecordGetRecordID(record)];
_contactID = [NSString stringWithFormat:@"%d", ABRecordGetRecordID(record)];
// use the contact book display name
self.displayName = (__bridge NSString*) ABRecordCopyCompositeName(record);
_displayName = (__bridge NSString*) ABRecordCopyCompositeName(record);
// avoid nil display name
// the display name is used to sort contacts
if (!self.displayName) {
displayName = @"";
_displayName = @"";
}
// extract the phone numbers and their related label
@ -93,7 +97,7 @@ NSString *const kConsoleContactThumbnailUpdateNotification = @"kConsoleContactTh
}
CFRelease(multi);
phoneNumbers = pns;
_phoneNumbers = pns;
// extract the emails
multi = ABRecordCopyValue(record, kABPersonEmailProperty);
@ -145,7 +149,7 @@ NSString *const kConsoleContactThumbnailUpdateNotification = @"kConsoleContactTh
CFRelease(multi);
emailAddresses = emails;
_emailAddresses = emails;
// thumbnail/picture
// check whether the contact has a picture

View file

@ -26,17 +26,9 @@
BOOL gotMatrixID;
}
@property (nonatomic, readwrite) NSString *type;
@property (nonatomic, readwrite) NSString *emailAddress;
@property (nonatomic, readwrite) NSString *contactID;
@property (nonatomic, readwrite) NSString *matrixUserID;
@property (nonatomic, readwrite) NSString *avatarURL;
@property (nonatomic, readwrite) UIImage *avatarImage;
@end
@implementation ConsoleEmail
@synthesize type, emailAddress, contactID, matrixUserID, avatarImage, avatarURL;
- (void) commonInit {
// init statuses
@ -44,11 +36,11 @@
pendingMatrixIDRequest = NO;
// init members
self.emailAddress = nil;
self.type = nil;
self.contactID = nil;
self.matrixUserID = nil;
self.avatarURL = @"";
_emailAddress = nil;
_type = nil;
_contactID = nil;
_matrixUserID = nil;
_avatarURL = @"";
}
- (id)init {
@ -66,9 +58,9 @@
if (self) {
[self commonInit];
self.emailAddress = anEmailAddress;
self.type = aType;
self.contactID = aContactID;
_emailAddress = anEmailAddress;
_type = aType;
_contactID = aContactID;
}
return self;
@ -95,7 +87,7 @@
forMedium:@"email"
success:^(NSString *userId) {
pendingMatrixIDRequest = NO;
self.matrixUserID = userId;
_matrixUserID = userId;
gotMatrixID = YES;
if (self.matrixUserID) {
@ -138,7 +130,7 @@
MXUser* user = [mxHandler.mxSession userWithUserId:self.matrixUserID];
if (user) {
self.avatarURL = [mxHandler thumbnailURLForContent:user.avatarUrl inViewSize:avatarSize withMethod:MXThumbnailingMethodCrop];
_avatarURL = [mxHandler thumbnailURLForContent:user.avatarUrl inViewSize:avatarSize withMethod:MXThumbnailingMethodCrop];
[self downloadAvatarImage];
} else {
@ -146,7 +138,7 @@
if (mxHandler.mxRestClient) {
[mxHandler.mxRestClient avatarUrlForUser:self.matrixUserID
success:^(NSString *avatarUrl) {
self.avatarURL = [mxHandler thumbnailURLForContent:avatarUrl inViewSize:avatarSize withMethod:MXThumbnailingMethodCrop];
_avatarURL = [mxHandler thumbnailURLForContent:avatarUrl inViewSize:avatarSize withMethod:MXThumbnailingMethodCrop];
[self downloadAvatarImage];
}
failure:^(NSError *error) {
@ -167,7 +159,7 @@
if (self.avatarURL.length > 0) {
self.avatarImage = [MediaManager loadCachePictureForURL:self.avatarURL inFolder:kMediaManagerThumbnailFolder];
_avatarImage = [MediaManager loadCachePictureForURL:self.avatarURL inFolder:kMediaManagerThumbnailFolder];
// the image is already in the cache
if (self.avatarImage) {
@ -195,7 +187,7 @@
// update the image
UIImage* image = [MediaManager loadCachePictureForURL:self.avatarURL inFolder:kMediaManagerThumbnailFolder];
if (image) {
self.avatarImage = image;
_avatarImage = image;
dispatch_async(dispatch_get_main_queue(), ^{
[[NSNotificationCenter defaultCenter] postNotificationName:kConsoleContactThumbnailUpdateNotification object:self.contactID userInfo:nil];

View file

@ -16,22 +16,15 @@
#import "ConsolePhoneNumber.h"
@interface ConsolePhoneNumber()
@property (nonatomic, readwrite) NSString *type;
@property (nonatomic, readwrite) NSString *textNumber;
@property (nonatomic, readwrite) NSString *contactID;
@end
@implementation ConsolePhoneNumber
@synthesize type, textNumber, contactID;
- (id)initWithTextNumber:(NSString*)aTextNumber andType:(NSString*)aType within:(NSString*)aContactID {
self = [super init];
if (self) {
self.type = aType;
self.textNumber = aTextNumber;
self.contactID = aContactID;
_type = aType;
_textNumber = aTextNumber;
_contactID = aContactID;
}
return self;