IOSAD-61 PEPIdentity as actual class IOSAD-61
authorDirk Zimmermann <dirk@pep-project.org>
Mon, 30 Oct 2017 12:35:49 +0100
branchIOSAD-61
changeset 304869358d007d8
parent 303 e85f56111494
child 305 3e0a52fec0ec
IOSAD-61 PEPIdentity as actual class
pEpObjCAdapter.xcodeproj/project.pbxproj
pEpObjCAdapter/PEPIdentity.h
pEpObjCAdapter/PEPIdentity.m
     1.1 --- a/pEpObjCAdapter.xcodeproj/project.pbxproj	Mon Oct 30 12:03:44 2017 +0100
     1.2 +++ b/pEpObjCAdapter.xcodeproj/project.pbxproj	Mon Oct 30 12:35:49 2017 +0100
     1.3 @@ -24,6 +24,7 @@
     1.4  		432FA2D41C884C5F00DDF874 /* partner2_F9D9CCD0A401311F_pub.asc in Resources */ = {isa = PBXBuildFile; fileRef = 432FA2D11C884C5F00DDF874 /* partner2_F9D9CCD0A401311F_pub.asc */; };
     1.5  		432FA2D71C884FF500DDF874 /* meATdontcare_E3BFBCA9248FC681_pub.asc in Resources */ = {isa = PBXBuildFile; fileRef = 432FA2D51C884FF500DDF874 /* meATdontcare_E3BFBCA9248FC681_pub.asc */; };
     1.6  		432FA2D81C884FF500DDF874 /* meATdontcare_E3BFBCA9248FC681_sec.asc in Resources */ = {isa = PBXBuildFile; fileRef = 432FA2D61C884FF500DDF874 /* meATdontcare_E3BFBCA9248FC681_sec.asc */; };
     1.7 +		433E28911FA741DE00E359B3 /* PEPIdentity.m in Sources */ = {isa = PBXBuildFile; fileRef = 433E28901FA741DE00E359B3 /* PEPIdentity.m */; };
     1.8  		434226811D4F60000083ED79 /* PepTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 434226801D4F60000083ED79 /* PepTests.m */; };
     1.9  		43676B661C57EA1A00233933 /* B623F674_sec.asc in Resources */ = {isa = PBXBuildFile; fileRef = 43676B641C57EA1A00233933 /* B623F674_sec.asc */; };
    1.10  		43D27DE61F5DA7B700795687 /* NSDictionary+Extension.m in Sources */ = {isa = PBXBuildFile; fileRef = 43D27DE51F5DA7B700795687 /* NSDictionary+Extension.m */; };
    1.11 @@ -139,6 +140,8 @@
    1.12  		432FA2D51C884FF500DDF874 /* meATdontcare_E3BFBCA9248FC681_pub.asc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = meATdontcare_E3BFBCA9248FC681_pub.asc; sourceTree = "<group>"; };
    1.13  		432FA2D61C884FF500DDF874 /* meATdontcare_E3BFBCA9248FC681_sec.asc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = meATdontcare_E3BFBCA9248FC681_sec.asc; sourceTree = "<group>"; };
    1.14  		433E288E1FA7342000E359B3 /* PEPSessionProtocol.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PEPSessionProtocol.h; sourceTree = "<group>"; };
    1.15 +		433E288F1FA741DE00E359B3 /* PEPIdentity.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PEPIdentity.h; sourceTree = "<group>"; };
    1.16 +		433E28901FA741DE00E359B3 /* PEPIdentity.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = PEPIdentity.m; sourceTree = "<group>"; };
    1.17  		434226801D4F60000083ED79 /* PepTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PepTests.m; sourceTree = "<group>"; };
    1.18  		43676B631C57EA1A00233933 /* 0xB623F674.asc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = 0xB623F674.asc; sourceTree = "<group>"; };
    1.19  		43676B641C57EA1A00233933 /* B623F674_sec.asc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = B623F674_sec.asc; sourceTree = "<group>"; };
    1.20 @@ -235,6 +238,8 @@
    1.21  				15206CC51F8E078B003FF880 /* PEPSession.h */,
    1.22  				15206CC61F8E078B003FF880 /* PEPSession.m */,
    1.23  				433E288E1FA7342000E359B3 /* PEPSessionProtocol.h */,
    1.24 +				433E288F1FA741DE00E359B3 /* PEPIdentity.h */,
    1.25 +				433E28901FA741DE00E359B3 /* PEPIdentity.m */,
    1.26  			);
    1.27  			path = pEpObjCAdapter;
    1.28  			sourceTree = "<group>";
    1.29 @@ -419,6 +424,7 @@
    1.30  				1508AEAF1F8792AC001D5230 /* PEPCopyableThread.m in Sources */,
    1.31  				15206CAA1F8BA183003FF880 /* PEPSessionProvider.m in Sources */,
    1.32  				43209B411ECC2DB8007E7E2E /* PEPObjCAdapter.m in Sources */,
    1.33 +				433E28911FA741DE00E359B3 /* PEPIdentity.m in Sources */,
    1.34  				43D27DE61F5DA7B700795687 /* NSDictionary+Extension.m in Sources */,
    1.35  				43209B431ECC2DC0007E7E2E /* PEPInternalSession.m in Sources */,
    1.36  				43209B3F1ECC2DB0007E7E2E /* PEPLanguage.m in Sources */,
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/pEpObjCAdapter/PEPIdentity.h	Mon Oct 30 12:35:49 2017 +0100
     2.3 @@ -0,0 +1,31 @@
     2.4 +//
     2.5 +//  PEPIdentity.h
     2.6 +//  pEpObjCAdapter
     2.7 +//
     2.8 +//  Created by Dirk Zimmermann on 30.10.17.
     2.9 +//  Copyright © 2017 p≡p. All rights reserved.
    2.10 +//
    2.11 +
    2.12 +#import <Foundation/Foundation.h>
    2.13 +
    2.14 +@interface PEPIdentity : NSObject
    2.15 +
    2.16 +/**
    2.17 + The network address of this identity
    2.18 + */
    2.19 +@property (nonatomic, nonnull) NSString *address;
    2.20 +
    2.21 +/**
    2.22 + The (optional) user name.
    2.23 + */
    2.24 +@property (nonatomic, nullable) NSString *userName;
    2.25 +
    2.26 +/**
    2.27 + Is this one of our own identities?
    2.28 + */
    2.29 +@property BOOL isOwn;
    2.30 +
    2.31 +- (id)initWithAddress:(NSString * _Nonnull)address userName:(NSString * _Nullable)userName;
    2.32 +- (id)initWithAddress:(NSString * _Nonnull)address;
    2.33 +
    2.34 +@end
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/pEpObjCAdapter/PEPIdentity.m	Mon Oct 30 12:35:49 2017 +0100
     3.3 @@ -0,0 +1,43 @@
     3.4 +//
     3.5 +//  PEPIdentity.m
     3.6 +//  pEpObjCAdapter
     3.7 +//
     3.8 +//  Created by Dirk Zimmermann on 30.10.17.
     3.9 +//  Copyright © 2017 p≡p. All rights reserved.
    3.10 +//
    3.11 +
    3.12 +#import "PEPIdentity.h"
    3.13 +
    3.14 +@implementation PEPIdentity
    3.15 +
    3.16 +- (id)initWithAddress:(NSString * _Nonnull)address userName:(NSString * _Nullable)userName
    3.17 +{
    3.18 +    if (self = [super init]) {
    3.19 +        self.address = address;
    3.20 +        self.userName = userName;
    3.21 +    }
    3.22 +    return self;
    3.23 +}
    3.24 +
    3.25 +- (id)initWithAddress:(NSString * _Nonnull)address
    3.26 +{
    3.27 +    return [self initWithAddress:address userName:nil];
    3.28 +}
    3.29 +
    3.30 +- (BOOL)isEqual:(id)other
    3.31 +{
    3.32 +    if (other == self) {
    3.33 +        return YES;
    3.34 +    } else if (![super isEqual:other]) {
    3.35 +        return NO;
    3.36 +    } else {
    3.37 +        return self.address == ((PEPIdentity *) other).address;
    3.38 +    }
    3.39 +}
    3.40 +
    3.41 +- (NSUInteger)hash
    3.42 +{
    3.43 +    return self.address.hash;
    3.44 +}
    3.45 +
    3.46 +@end