Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release-v0.6.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
giomfo committed Apr 8, 2016
2 parents 5a56b14 + 8599e0d commit 69b54f2
Show file tree
Hide file tree
Showing 22 changed files with 667 additions and 161 deletions.
15 changes: 15 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
Changes in Matrix iOS SDK in 0.6.5 (2016-04-08)
===============================================

Improvements:
* MXJSONModels: Registration Support - Define MXAunthenticationSession class. This class is used to store the server response on supported flows during the login or the registration.
* MXRestClient: New email binding - validateEmail and bind3PID has been removed. add3PID and treePIDs has been added.
* MXRestClient: Registration Support - Add API to check user id availability.
* MXSession: Added roomWithAlias method.
* MXTools: Add method to validate email address.

Bug fixes:
* User profile: user settings may be modified during pagination in past timeline.
* Fixed crash in [MXFileStore saveReceipts]. There was a race condition.
* Cancel correctly pending operations.

Changes in Matrix iOS SDK in 0.6.4 (2016-03-17)
===============================================

Expand Down
4 changes: 2 additions & 2 deletions MatrixSDK.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "MatrixSDK"
s.version = "0.6.4"
s.version = "0.6.5"
s.summary = "The iOS SDK to build apps compatible with Matrix (http://www.matrix.org)"

s.description = <<-DESC
Expand All @@ -19,7 +19,7 @@ Pod::Spec.new do |s|

s.platform = :ios, "7.0"

s.source = { :git => "https://github.com/matrix-org/matrix-ios-sdk.git", :tag => "v0.6.4" }
s.source = { :git => "https://github.com/matrix-org/matrix-ios-sdk.git", :tag => "v0.6.5" }
s.source_files = "MatrixSDK", "MatrixSDK/**/*.{h,m}"
s.resources = "MatrixSDK/Data/Store/MXCoreDataStore/*.xcdatamodeld"

Expand Down
2 changes: 1 addition & 1 deletion MatrixSDK/Data/MXEventTimeline.m
Original file line number Diff line number Diff line change
Expand Up @@ -574,7 +574,7 @@ - (void)handleStateEvent:(MXEvent*)event direction:(MXTimelineDirection)directio
[_state handleStateEvent:event];

// Special handling for presence
if (MXEventTypeRoomMember == event.eventType)
if (_isLiveTimeline && MXEventTypeRoomMember == event.eventType)
{
// Update MXUser data
MXUser *user = [room.mxSession getOrCreateUser:event.sender];
Expand Down
7 changes: 5 additions & 2 deletions MatrixSDK/Data/Store/MXFileStore/MXFileStore.m
Original file line number Diff line number Diff line change
Expand Up @@ -951,8 +951,11 @@ - (void)saveReceipts
{
NSString *receiptsFile = [storeReceiptsPath stringByAppendingPathComponent:roomId];
NSUInteger filesize = [[[[NSFileManager defaultManager] attributesOfItemAtPath:receiptsFile error:nil] objectForKey:NSFileSize] intValue];

[NSKeyedArchiver archiveRootObject:receiptsByUserId toFile:receiptsFile];

@synchronized (receiptsByUserId)
{
[NSKeyedArchiver archiveRootObject:receiptsByUserId toFile:receiptsFile];
}

deltaCacheSize += [[[[NSFileManager defaultManager] attributesOfItemAtPath:receiptsFile error:nil] objectForKey:NSFileSize] intValue] - filesize;
}
Expand Down
5 changes: 4 additions & 1 deletion MatrixSDK/Data/Store/MXMemoryStore/MXMemoryStore.m
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,10 @@ - (BOOL)storeReceipt:(MXReceiptData*)receipt inRoom:(NSString*)roomId
// not yet defined or a new event
if (!curReceipt || (![receipt.eventId isEqualToString:curReceipt.eventId] && (receipt.ts > curReceipt.ts)))
{
[receiptsByUserId setObject:receipt forKey:receipt.userId];
@synchronized (receiptsByUserId)
{
[receiptsByUserId setObject:receipt forKey:receipt.userId];
}
return true;
}

Expand Down
69 changes: 67 additions & 2 deletions MatrixSDK/JSONModels/MXJSONModels.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,14 @@
Note: some such class can be defined in their own file (ex: MXEvent)
*/

/**
Types of third party media.
The list is not exhautive and depends on the Identity server capabilities.
*/
typedef NSString* MX3PIDMedium;
FOUNDATION_EXPORT NSString *const kMX3PIDMediumEmail;
FOUNDATION_EXPORT NSString *const kMX3PIDMediumMSISDN;

/**
`MXPublicRoom` represents a public room returned by the publicRoom request
*/
Expand Down Expand Up @@ -103,12 +111,41 @@ FOUNDATION_EXPORT NSString *const kMXLoginFlowTypeRecaptcha;
@property (nonatomic) NSString *type;

/**
The list of stages to proceed the login. This is an array of NSStrings
The list of stages to proceed the login or the registration.
*/
@property (nonatomic) NSArray *stages;
@property (nonatomic) NSArray<MXLoginFlowType> *stages;

@end

/**
`MXAuthenticationSession` represents an authentication session returned by the home server.
*/
@interface MXAuthenticationSession : MXJSONModel

/**
The list of stages the client has completed successfully.
*/
@property (nonatomic) NSArray<MXLoginFlowType> *completed;

/**
The session identifier that the client must pass back to the home server, if one is provided,
in subsequent attempts to authenticate in the same API call.
*/
@property (nonatomic) NSString *session;

/**
The list of supported flows
*/
@property (nonatomic) NSArray<MXLoginFlow*> *flows;

/**
The information that the client will need to know in order to use a given type of authentication.
For each login stage type presented, that type may be present as a key in this dictionary.
For example, the public key of reCAPTCHA stage could be given here.
*/
@property (nonatomic) NSDictionary *params;

@end

/**
`MXCredentials` represents the response to a login or a register request.
Expand Down Expand Up @@ -150,6 +187,34 @@ FOUNDATION_EXPORT NSString *const kMXLoginFlowTypeRecaptcha;
@end


/**
`MXThirdPartyIdentifier` represents the response to /account/3pid GET request.
*/
@interface MXThirdPartyIdentifier : MXJSONModel

/**
The medium of the third party identifier.
*/
@property (nonatomic) MX3PIDMedium medium;

/**
The third party identifier address.
*/
@property (nonatomic) NSString *address;

/**
The timestamp in milliseconds when this 3PID has been validated.
*/
@property (nonatomic) uint64_t validatedAt;

/**
The timestamp in milliseconds when this 3PID has been added to the user account.
*/
@property (nonatomic) uint64_t addedAt;

@end


/**
`MXCreateRoomResponse` represents the response to createRoom request.
*/
Expand Down
58 changes: 58 additions & 0 deletions MatrixSDK/JSONModels/MXJSONModels.m
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,25 @@ + (id)modelFromJSON:(NSDictionary *)JSONDictionary

@end

@implementation MXAuthenticationSession

+ (id)modelFromJSON:(NSDictionary *)JSONDictionary
{
MXAuthenticationSession *authSession = [[MXAuthenticationSession alloc] init];
if (authSession)
{
MXJSONModelSetArray(authSession.completed, JSONDictionary[@"completed"]);
MXJSONModelSetString(authSession.session, JSONDictionary[@"session"]);
MXJSONModelSetDictionary(authSession.params, JSONDictionary[@"params"]);

authSession.flows = [MXLoginFlow modelsFromJSON:JSONDictionary[@"flows"]];
}

return authSession;
}

@end

@implementation MXCredentials

+ (id)modelFromJSON:(NSDictionary *)JSONDictionary
Expand Down Expand Up @@ -120,6 +139,45 @@ - (instancetype)initWithHomeServer:(NSString *)homeServer userId:(NSString *)use

@end

@implementation MXThirdPartyIdentifier

+ (id)modelFromJSON:(NSDictionary *)JSONDictionary
{
MXThirdPartyIdentifier *thirdPartyIdentifier = [[MXThirdPartyIdentifier alloc] init];
if (thirdPartyIdentifier)
{
MXJSONModelSetString(thirdPartyIdentifier.medium, JSONDictionary[@"medium"]);
MXJSONModelSetString(thirdPartyIdentifier.address, JSONDictionary[@"address"]);
MXJSONModelSetUInt64(thirdPartyIdentifier.validatedAt, JSONDictionary[@"validated_at"]);
MXJSONModelSetUInt64(thirdPartyIdentifier.addedAt, JSONDictionary[@"added_at"]);
}

return thirdPartyIdentifier;
}

- (instancetype)initWithCoder:(NSCoder *)aDecoder
{
self = [super init];
if (self)
{
_medium = [aDecoder decodeObjectForKey:@"medium"];
_address = [aDecoder decodeObjectForKey:@"address"];
_validatedAt = [((NSNumber*)[aDecoder decodeObjectForKey:@"validatedAt"]) unsignedLongLongValue];
_addedAt = [((NSNumber*)[aDecoder decodeObjectForKey:@"addedAt"]) unsignedLongLongValue];
}
return self;
}

- (void)encodeWithCoder:(NSCoder *)aCoder
{
[aCoder encodeObject:_medium forKey:@"medium"];
[aCoder encodeObject:_address forKey:@"address"];
[aCoder encodeObject:@(_validatedAt) forKey:@"validatedAt"];
[aCoder encodeObject:@(_addedAt) forKey:@"addedAt"];
}

@end

@implementation MXCreateRoomResponse

+ (id)modelFromJSON:(NSDictionary *)JSONDictionary
Expand Down
3 changes: 3 additions & 0 deletions MatrixSDK/MXError.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ FOUNDATION_EXPORT NSString *const kMXErrCodeStringLimitExceeded;
FOUNDATION_EXPORT NSString *const kMXErrCodeStringUserInUse;
FOUNDATION_EXPORT NSString *const kMXErrCodeStringRoomInUse;
FOUNDATION_EXPORT NSString *const kMXErrCodeStringBadPagination;
FOUNDATION_EXPORT NSString *const kMXErrCodeStringUnauthorized;
FOUNDATION_EXPORT NSString *const kMXErrCodeStringLoginEmailURLNotYet;
FOUNDATION_EXPORT NSString *const kMXErrCodeStringThreePIDAuthFailed;

FOUNDATION_EXPORT NSString *const kMXErrorStringInvalidToken;

Expand Down
23 changes: 13 additions & 10 deletions MatrixSDK/MXError.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,19 @@

NSString *const kMXNSErrorDomain = @"org.matrix.sdk";

NSString *const kMXErrCodeStringForbidden = @"M_FORBIDDEN";
NSString *const kMXErrCodeStringUnknown = @"M_UNKNOWN";
NSString *const kMXErrCodeStringUnknownToken = @"M_UNKNOWN_TOKEN";
NSString *const kMXErrCodeStringBadJSON = @"M_BAD_JSON";
NSString *const kMXErrCodeStringNotJSON = @"M_NOT_JSON";
NSString *const kMXErrCodeStringNotFound = @"M_NOT_FOUND";
NSString *const kMXErrCodeStringLimitExceeded = @"M_LIMIT_EXCEEDED";
NSString *const kMXErrCodeStringUserInUse = @"M_USER_IN_USE";
NSString *const kMXErrCodeStringRoomInUse = @"M_ROOM_IN_USE";
NSString *const kMXErrCodeStringBadPagination = @"M_BAD_PAGINATION";
NSString *const kMXErrCodeStringForbidden = @"M_FORBIDDEN";
NSString *const kMXErrCodeStringUnknown = @"M_UNKNOWN";
NSString *const kMXErrCodeStringUnknownToken = @"M_UNKNOWN_TOKEN";
NSString *const kMXErrCodeStringBadJSON = @"M_BAD_JSON";
NSString *const kMXErrCodeStringNotJSON = @"M_NOT_JSON";
NSString *const kMXErrCodeStringNotFound = @"M_NOT_FOUND";
NSString *const kMXErrCodeStringLimitExceeded = @"M_LIMIT_EXCEEDED";
NSString *const kMXErrCodeStringUserInUse = @"M_USER_IN_USE";
NSString *const kMXErrCodeStringRoomInUse = @"M_ROOM_IN_USE";
NSString *const kMXErrCodeStringBadPagination = @"M_BAD_PAGINATION";
NSString *const kMXErrCodeStringUnauthorized = @"M_UNAUTHORIZED";
NSString *const kMXErrCodeStringLoginEmailURLNotYet = @"M_LOGIN_EMAIL_URL_NOT_YET";
NSString *const kMXErrCodeStringThreePIDAuthFailed = @"M_THREEPID_AUTH_FAILED";

NSString *const kMXErrorStringInvalidToken = @"Invalid token";

Expand Down
Loading

0 comments on commit 69b54f2

Please sign in to comment.