Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/release-v0.6.10'
Browse files Browse the repository at this point in the history
  • Loading branch information
giomfo committed Jul 15, 2016
2 parents c0bbec4 + 971bfd9 commit 39fc3e5
Show file tree
Hide file tree
Showing 22 changed files with 973 additions and 361 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.10 (2016-07-15)
===============================================

Improvements:
* MXRestClient: Add API to add/remove a room alias.
* MXRestClient: Add API to set the room canonical alias.
* Update AFNetworking: Move to 3.1.0 version.
* SDK Tests: Update and improve tests.

Bug fixes:
* MXRoom: Read receipts can now be posted on room history visibility or guest access change.

Breaks:
* MXRestClient: uploadContent signature has been changed.

Changes in Matrix iOS SDK in 0.6.9 (2016-07-01)
===============================================

Expand Down
6 changes: 3 additions & 3 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.9"
s.version = "0.6.10"
s.summary = "The iOS SDK to build apps compatible with Matrix (http://www.matrix.org)"

s.description = <<-DESC
Expand All @@ -19,14 +19,14 @@ 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.9" }
s.source = { :git => "https://github.com/matrix-org/matrix-ios-sdk.git", :tag => "v0.6.10" }
s.source_files = "MatrixSDK", "MatrixSDK/**/*.{h,m}"
s.resources = "MatrixSDK/Data/Store/MXCoreDataStore/*.xcdatamodeld"

s.frameworks = "CoreData"

s.requires_arc = true

s.dependency 'AFNetworking', '~> 2.6.0'
s.dependency 'AFNetworking', '~> 3.1.0'

end
39 changes: 39 additions & 0 deletions MatrixSDK/Data/MXRoom.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,45 @@ FOUNDATION_EXPORT NSString *const kMXRoomDidUpdateUnreadNotification;
success:(void (^)())success
failure:(void (^)(NSError *error))failure;

/**
Add a room alias
@param roomAlias the room alias to add.
@param success A block object called when the operation succeeds.
@param failure A block object called when the operation fails.
@return a MXHTTPOperation instance.
*/
- (MXHTTPOperation*)addAlias:(NSString *)roomAlias
success:(void (^)())success
failure:(void (^)(NSError *error))failure;

/**
Remove a room alias
@param roomAlias the room alias to remove.
@param success A block object called when the operation succeeds.
@param failure A block object called when the operation fails.
@return a MXHTTPOperation instance.
*/
- (MXHTTPOperation*)removeAlias:(NSString *)roomAlias
success:(void (^)())success
failure:(void (^)(NSError *error))failure;

/**
Set the canonical alias of the room.
@param canonicalAlias the canonical alias to set.
@param success A block object called when the operation succeeds.
@param failure A block object called when the operation fails.
@return a MXHTTPOperation instance.
*/
- (MXHTTPOperation*)setCanonicalAlias:(NSString *)canonicalAlias
success:(void (^)())success
failure:(void (^)(NSError *error))failure;

/**
Get the visibility of the room in the current HS's room directory.
Expand Down
23 changes: 23 additions & 0 deletions MatrixSDK/Data/MXRoom.m
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ - (instancetype)init
kMXEventTypeStringRoomPowerLevels,
kMXEventTypeStringRoomAliases,
kMXEventTypeStringRoomCanonicalAlias,
kMXEventTypeStringRoomGuestAccess,
kMXEventTypeStringRoomHistoryVisibility,
kMXEventTypeStringRoomMessage,
kMXEventTypeStringRoomMessageFeedback,
kMXEventTypeStringRoomRedaction,
Expand Down Expand Up @@ -295,6 +297,27 @@ - (MXHTTPOperation*)setDirectoryVisibility:(MXRoomDirectoryVisibility)directoryV
return [mxSession.matrixRestClient setRoomDirectoryVisibility:self.state.roomId directoryVisibility:directoryVisibility success:success failure:failure];
}

- (MXHTTPOperation*)addAlias:(NSString *)roomAlias
success:(void (^)())success
failure:(void (^)(NSError *error))failure
{
return [mxSession.matrixRestClient addRoomAlias:self.state.roomId alias:roomAlias success:success failure:failure];
}

- (MXHTTPOperation*)removeAlias:(NSString *)roomAlias
success:(void (^)())success
failure:(void (^)(NSError *error))failure
{
return [mxSession.matrixRestClient removeRoomAlias:roomAlias success:success failure:failure];
}

- (MXHTTPOperation*)setCanonicalAlias:(NSString *)canonicalAlias
success:(void (^)())success
failure:(void (^)(NSError *error))failure
{
return [mxSession.matrixRestClient setRoomCanonicalAlias:self.state.roomId canonicalAlias:canonicalAlias success:success failure:failure];
}

- (MXHTTPOperation*)directoryVisibility:(void (^)(MXRoomDirectoryVisibility directoryVisibility))success
failure:(void (^)(NSError *error))failure
{
Expand Down
57 changes: 56 additions & 1 deletion MatrixSDK/MXRestClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -682,6 +682,61 @@ typedef enum : NSUInteger
success:(void (^)(MXRoomDirectoryVisibility directoryVisibility))success
failure:(void (^)(NSError *error))failure;

/**
Create a new mapping from room alias to room ID.
@param roomId the id of the room.
@param roomAlias the alias to add.
@param success A block object called when the operation succeeds.
@param failure A block object called when the operation fails.
@return a MXHTTPOperation instance.
*/
- (MXHTTPOperation*)addRoomAlias:(NSString*)roomId
alias:(NSString*)roomAlias
success:(void (^)())success
failure:(void (^)(NSError *error))failure;

/**
Remove a mapping of room alias to room ID.
@param roomAlias the alias to remove.
@param success A block object called when the operation succeeds.
@param failure A block object called when the operation fails.
@return a MXHTTPOperation instance.
*/
- (MXHTTPOperation*)removeRoomAlias:(NSString*)roomAlias
success:(void (^)())success
failure:(void (^)(NSError *error))failure;

/**
Set the canonical alias of the room.
@param roomId the id of the room.
@param canonicalAlias the canonical alias to set.
@param success A block object called when the operation succeeds.
@param failure A block object called when the operation fails.
@return a MXHTTPOperation instance.
*/
- (MXHTTPOperation*)setRoomCanonicalAlias:(NSString*)roomId
canonicalAlias:(NSString *)canonicalAlias
success:(void (^)())success
failure:(void (^)(NSError *error))failure;

/**
Get the canonical alias.
@param roomId the id of the room.
@param success A block object called when the operation succeeds. It provides the canonical alias.
@param failure A block object called when the operation fails.
@return a MXHTTPOperation instance.
*/
- (MXHTTPOperation*)canonicalAliasOfRoom:(NSString*)roomId
success:(void (^)(NSString *canonicalAlias))success
failure:(void (^)(NSError *error))failure;

/**
Join a room.
Expand Down Expand Up @@ -1239,7 +1294,7 @@ typedef enum : NSUInteger
timeout:(NSTimeInterval)timeoutInSeconds
success:(void (^)(NSString *url))success
failure:(void (^)(NSError *error))failure
uploadProgress:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))uploadProgress;
uploadProgress:(void (^)(NSProgress *uploadProgress))uploadProgress;

/**
Resolve a Matrix media content URI (in the form of "mxc://...") into an HTTP URL.
Expand Down
99 changes: 98 additions & 1 deletion MatrixSDK/MXRestClient.m
Original file line number Diff line number Diff line change
Expand Up @@ -1181,6 +1181,103 @@ - (MXHTTPOperation*)directoryVisibilityOfRoom:(NSString*)roomId
}];
}

- (MXHTTPOperation*)addRoomAlias:(NSString*)roomId
alias:(NSString*)roomAlias
success:(void (^)())success
failure:(void (^)(NSError *error))failure
{
// Note: characters in a room alias need to be escaped in the URL
NSString *path = [NSString stringWithFormat:@"%@/directory/room/%@", apiPathPrefix, [roomAlias stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

return [httpClient requestWithMethod:@"PUT"
path:path
parameters:@{
@"room_id": roomId
}
success:^(NSDictionary *JSONResponse) {
if (success)
{
// Use here the processing queue in order to keep the server response order
dispatch_async(processingQueue, ^{

dispatch_async(dispatch_get_main_queue(), ^{

success();

});

});
}
}
failure:^(NSError *error) {
if (failure)
{
failure(error);
}
}];
}

- (MXHTTPOperation*)removeRoomAlias:(NSString*)roomAlias
success:(void (^)())success
failure:(void (^)(NSError *error))failure
{
// Note: characters in a room alias need to be escaped in the URL
NSString *path = [NSString stringWithFormat:@"%@/directory/room/%@", apiPathPrefix, [roomAlias stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

return [httpClient requestWithMethod:@"DELETE"
path:path
parameters:nil
success:^(NSDictionary *JSONResponse) {
if (success)
{
// Use here the processing queue in order to keep the server response order
dispatch_async(processingQueue, ^{

dispatch_async(dispatch_get_main_queue(), ^{

success();

});

});
}
}
failure:^(NSError *error) {
if (failure)
{
failure(error);
}
}];
}

- (MXHTTPOperation*)setRoomCanonicalAlias:(NSString*)roomId
canonicalAlias:(NSString *)canonicalAlias
success:(void (^)())success
failure:(void (^)(NSError *error))failure
{
return [self updateStateEvent:kMXEventTypeStringRoomCanonicalAlias
withValue:@{
@"alias": canonicalAlias
}
inRoom:roomId
success:success failure:failure];
}

- (MXHTTPOperation*)canonicalAliasOfRoom:(NSString*)roomId
success:(void (^)(NSString *canonicalAlias))success
failure:(void (^)(NSError *error))failure
{
return [self valueOfStateEvent:kMXEventTypeStringRoomCanonicalAlias
inRoom:roomId
success:^(NSDictionary *JSONResponse) {

NSString * alias;
MXJSONModelSetString(alias, JSONResponse[@"alias"]);
success(alias);

} failure:failure];
}


- (MXHTTPOperation*)joinRoom:(NSString*)roomIdOrAlias
success:(void (^)(NSString *theRoomId))success
Expand Down Expand Up @@ -2433,7 +2530,7 @@ - (MXHTTPOperation*) uploadContent:(NSData *)data
timeout:(NSTimeInterval)timeoutInSeconds
success:(void (^)(NSString *url))success
failure:(void (^)(NSError *error))failure
uploadProgress:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))uploadProgress
uploadProgress:(void (^)(NSProgress *uploadProgress))uploadProgress
{
// Define an absolute path based on Matrix content respository path instead of the base url
NSString* path = [NSString stringWithFormat:@"%@/upload", kMXContentPrefixPath];
Expand Down
2 changes: 1 addition & 1 deletion MatrixSDK/MXSession.m
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

#pragma mark - Constants definitions

const NSString *MatrixSDKVersion = @"0.6.9";
const NSString *MatrixSDKVersion = @"0.6.10";
NSString *const kMXSessionStateDidChangeNotification = @"kMXSessionStateDidChangeNotification";
NSString *const kMXSessionNewRoomNotification = @"kMXSessionNewRoomNotification";
NSString *const kMXSessionWillLeaveRoomNotification = @"kMXSessionWillLeaveRoomNotification";
Expand Down
2 changes: 1 addition & 1 deletion MatrixSDK/Utils/MXHTTPClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ typedef BOOL (^MXHTTPClientOnUnrecognizedCertificate)(NSData *certificate);
data:(NSData *)data
headers:(NSDictionary*)headers
timeout:(NSTimeInterval)timeoutInSeconds
uploadProgress:(void (^)(NSUInteger bytesWritten, long long totalBytesWritten, long long totalBytesExpectedToWrite))uploadProgress
uploadProgress:(void (^)(NSProgress *uploadProgress))uploadProgress
success:(void (^)(NSDictionary *JSONResponse))success
failure:(void (^)(NSError *error))failure;

Expand Down
Loading

0 comments on commit 39fc3e5

Please sign in to comment.