diff --git a/Podfile b/Podfile index 90d6bd801..87f26ab1c 100644 --- a/Podfile +++ b/Podfile @@ -23,18 +23,18 @@ $matrixKitVersion = '0.7.15' def import_MatrixKit if $matrixKitVersion == 'local' pod 'MatrixSDK', :path => '../matrix-ios-sdk/MatrixSDK.podspec' - pod 'MatrixSDK/SwiftSupport', :path => '../matrix-ios-sdk/MatrixSDK.podspec' + #pod 'MatrixSDK/SwiftSupport', :path => '../matrix-ios-sdk/MatrixSDK.podspec' pod 'MatrixSDK/JingleCallStack', :path => '../matrix-ios-sdk/MatrixSDK.podspec' pod 'MatrixKit', :path => '../matrix-ios-kit/MatrixKit.podspec' else if $matrixKitVersion == 'develop' pod 'MatrixSDK', :git => 'https://github.com/matrix-org/matrix-ios-sdk.git', :branch => 'develop' - pod 'MatrixSDK/SwiftSupport', :git => 'https://github.com/matrix-org/matrix-ios-sdk.git', :branch => 'develop' + #pod 'MatrixSDK/SwiftSupport', :git => 'https://github.com/matrix-org/matrix-ios-sdk.git', :branch => 'develop' pod 'MatrixSDK/JingleCallStack', :git => 'https://github.com/matrix-org/matrix-ios-sdk.git', :branch => 'develop' pod 'MatrixKit', :git => 'https://github.com/matrix-org/matrix-ios-kit.git', :branch => 'develop' else pod 'MatrixKit', $matrixKitVersion - pod 'MatrixSDK/SwiftSupport' + #pod 'MatrixSDK/SwiftSupport' pod 'MatrixSDK/JingleCallStack' end end @@ -44,18 +44,18 @@ end def import_MatrixKitAppExtension if $matrixKitVersion == 'local' pod 'MatrixSDK', :path => '../matrix-ios-sdk/MatrixSDK.podspec' - pod 'MatrixSDK/SwiftSupport', :path => '../matrix-ios-sdk/MatrixSDK.podspec' + #pod 'MatrixSDK/SwiftSupport', :path => '../matrix-ios-sdk/MatrixSDK.podspec' pod 'MatrixSDK/JingleCallStack', :path => '../matrix-ios-sdk/MatrixSDK.podspec' pod 'MatrixKit/AppExtension', :path => '../matrix-ios-kit/MatrixKit.podspec' else if $matrixKitVersion == 'develop' pod 'MatrixSDK', :git => 'https://github.com/matrix-org/matrix-ios-sdk.git', :branch => 'develop' - pod 'MatrixSDK/SwiftSupport', :git => 'https://github.com/matrix-org/matrix-ios-sdk.git', :branch => 'develop' + #pod 'MatrixSDK/SwiftSupport', :git => 'https://github.com/matrix-org/matrix-ios-sdk.git', :branch => 'develop' pod 'MatrixSDK/JingleCallStack', :git => 'https://github.com/matrix-org/matrix-ios-sdk.git', :branch => 'develop' pod 'MatrixKit/AppExtension', :git => 'https://github.com/matrix-org/matrix-ios-kit.git', :branch => 'develop' else pod 'MatrixKit/AppExtension', $matrixKitVersion - pod 'MatrixSDK/SwiftSupport' + #pod 'MatrixSDK/SwiftSupport' pod 'MatrixSDK/JingleCallStack' end end diff --git a/Riot.xcodeproj/project.pbxproj b/Riot.xcodeproj/project.pbxproj index c13b8c2bd..f57a97e9c 100644 --- a/Riot.xcodeproj/project.pbxproj +++ b/Riot.xcodeproj/project.pbxproj @@ -13,6 +13,7 @@ 3233F7461F3497E2006ACA81 /* JitsiMeet.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3233F7441F3497DA006ACA81 /* JitsiMeet.framework */; }; 3233F7471F3497E2006ACA81 /* JitsiMeet.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3233F7441F3497DA006ACA81 /* JitsiMeet.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 3284A35120A07C210044F922 /* postMessageAPI.js in Resources */ = {isa = PBXBuildFile; fileRef = 3284A35020A07C210044F922 /* postMessageAPI.js */; }; + 32C10340211DD1A100DFFB5D /* MatrixSDK+Swift.m in Sources */ = {isa = PBXBuildFile; fileRef = 32C1033F211DD1A100DFFB5D /* MatrixSDK+Swift.m */; }; 68A2327678CA647A9A7739C7 /* Pods_RiotPods_Riot.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B0FAA1A49F76B0CE15C5CBD8 /* Pods_RiotPods_Riot.framework */; }; 926FA53F1F4C132000F826C2 /* MXSession+Riot.m in Sources */ = {isa = PBXBuildFile; fileRef = 926FA53E1F4C132000F826C2 /* MXSession+Riot.m */; }; 92726A471F58737A004AD26F /* IntentHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 92726A461F58737A004AD26F /* IntentHandler.m */; }; @@ -383,7 +384,7 @@ 24CBEC4E1F0EAD310093EABB /* RiotShareExtension.appex */ = {isa = PBXFileReference; explicitFileType = "wrapper.app-extension"; includeInIndex = 0; path = RiotShareExtension.appex; sourceTree = BUILT_PRODUCTS_DIR; }; 3233F7441F3497DA006ACA81 /* JitsiMeet.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; path = JitsiMeet.framework; sourceTree = ""; }; 3267EFB320E379FD00FF1CAA /* CHANGES.rst */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = CHANGES.rst; sourceTree = ""; }; - 3267EFB420E379FD00FF1CAA /* Podfile */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; fileEncoding = 4; path = Podfile; sourceTree = ""; }; + 3267EFB420E379FD00FF1CAA /* Podfile */ = {isa = PBXFileReference; explicitFileType = text.script.ruby; fileEncoding = 4; path = Podfile; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.ruby; }; 3267EFB520E379FD00FF1CAA /* AUTHORS.rst */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = AUTHORS.rst; sourceTree = ""; }; 3267EFB620E379FD00FF1CAA /* README.rst */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = README.rst; sourceTree = ""; }; 3284A35020A07C210044F922 /* postMessageAPI.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; path = postMessageAPI.js; sourceTree = ""; }; @@ -393,6 +394,8 @@ 32BDC9A4211C34C90064AF51 /* sq */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = sq; path = sq.lproj/InfoPlist.strings; sourceTree = ""; }; 32BDC9A5211C34C90064AF51 /* sq */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = sq; path = sq.lproj/Localizable.strings; sourceTree = ""; }; 32BDC9A6211C34C90064AF51 /* sq */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = sq; path = sq.lproj/Vector.strings; sourceTree = ""; }; + 32C1033E211DD1A100DFFB5D /* MatrixSDK+Swift.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "MatrixSDK+Swift.h"; sourceTree = ""; }; + 32C1033F211DD1A100DFFB5D /* MatrixSDK+Swift.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "MatrixSDK+Swift.m"; sourceTree = ""; }; 33F966BE1A83B32A2DFE24CA /* Pods-RiotPods-SiriIntents.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-RiotPods-SiriIntents.release.xcconfig"; path = "Pods/Target Support Files/Pods-RiotPods-SiriIntents/Pods-RiotPods-SiriIntents.release.xcconfig"; sourceTree = ""; }; 397BCA987893439918EBF330 /* Pods-SiriIntents.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SiriIntents.debug.xcconfig"; path = "Pods/Target Support Files/Pods-SiriIntents/Pods-SiriIntents.debug.xcconfig"; sourceTree = ""; }; 4D1164C2F07EF74950DCDA7A /* Pods-SiriIntents.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-SiriIntents.release.xcconfig"; path = "Pods/Target Support Files/Pods-SiriIntents/Pods-SiriIntents.release.xcconfig"; sourceTree = ""; }; @@ -2463,6 +2466,8 @@ F083BBEC1E7009EC00A9B29C /* UIViewController+RiotSearch.m */, 926FA53D1F4C132000F826C2 /* MXSession+Riot.h */, 926FA53E1F4C132000F826C2 /* MXSession+Riot.m */, + 32C1033E211DD1A100DFFB5D /* MatrixSDK+Swift.h */, + 32C1033F211DD1A100DFFB5D /* MatrixSDK+Swift.m */, ); path = Categories; sourceTree = ""; @@ -3123,6 +3128,7 @@ B1B5590920EF768F00210D55 /* RoomEmptyBubbleCell.m in Sources */, B1B5574720EE6C4D00210D55 /* UsersDevicesViewController.m in Sources */, B1B558D220EF768F00210D55 /* RoomEncryptedDataBubbleCell.m in Sources */, + 32C10340211DD1A100DFFB5D /* MatrixSDK+Swift.m in Sources */, B1B558FA20EF768F00210D55 /* RoomMembershipBubbleCell.m in Sources */, B1B557BF20EF5B4500210D55 /* DisabledRoomInputToolbarView.m in Sources */, B1B5578620EF564900210D55 /* GroupTableViewCellWithSwitch.m in Sources */, diff --git a/Riot/Categories/MatrixSDK+Swift.h b/Riot/Categories/MatrixSDK+Swift.h new file mode 100644 index 000000000..f87280d89 --- /dev/null +++ b/Riot/Categories/MatrixSDK+Swift.h @@ -0,0 +1,47 @@ +/* + Copyright 2018 New Vector Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +#import + +/** + IMPORTANT: This file must be removed once the pod 'MatrixSDK/SwiftSupport' can + be pushed. + + Methods are redefined here to skip NS_REFINED_FOR_SWIFT defined in their declaration. + */ + +@interface MXSession (Swift) + +- (MXHTTPOperation*)createRoomFromSwift:(NSString*)name + visibility:(MXRoomDirectoryVisibility)visibility + roomAlias:(NSString*)roomAlias + topic:(NSString*)topic + invite:(NSArray*)inviteArray + invite3PID:(NSArray*)invite3PIDArray + isDirect:(BOOL)isDirect + preset:(MXRoomPreset)preset + success:(void (^)(void))success + failure:(void (^)(NSError *error))failure; + +@end + + +@interface MXRoomSummary (Swift) + +@property (nonatomic, readonly) MXMembership membershipFromSwift; + +@end + diff --git a/Riot/Categories/MatrixSDK+Swift.m b/Riot/Categories/MatrixSDK+Swift.m new file mode 100644 index 000000000..b0b03c828 --- /dev/null +++ b/Riot/Categories/MatrixSDK+Swift.m @@ -0,0 +1,52 @@ +/* + Copyright 2018 New Vector Ltd + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + */ + +#import + +#import "MatrixSDK+Swift.h" + +@implementation MXSession (Swift) + +- (MXHTTPOperation*)createRoomFromSwift:(NSString*)name + visibility:(MXRoomDirectoryVisibility)visibility + roomAlias:(NSString*)roomAlias + topic:(NSString*)topic + invite:(NSArray*)inviteArray + invite3PID:(NSArray*)invite3PIDArray + isDirect:(BOOL)isDirect + preset:(MXRoomPreset)preset + success:(void (^)(void))success + failure:(void (^)(NSError *error))failure +{ + return [self createRoom:name visibility:visibility roomAlias:roomAlias topic:topic invite:inviteArray invite3PID:invite3PIDArray isDirect:isDirect preset:preset success:^(MXRoom *room) { + + if (success) + { + success(); + } + } failure:failure]; +} + +@end + +@implementation MXRoomSummary (Swift) + +- (MXMembership)membershipFromSwift +{ + return self.membership; +} + +@end diff --git a/Riot/Managers/OnBoarding/OnBoardingManager.swift b/Riot/Managers/OnBoarding/OnBoardingManager.swift index fd17d0028..f16f70076 100644 --- a/Riot/Managers/OnBoarding/OnBoardingManager.swift +++ b/Riot/Managers/OnBoarding/OnBoardingManager.swift @@ -49,21 +49,30 @@ final public class OnBoardingManager: NSObject { return } +// // Create DM room with Riot-bot +// +// let httpOperation = self.session.createRoom(name: nil, visibility: .private, alias: nil, topic: nil, invite: [Constants.riotBotMatrixId], invite3PID: nil, isDirect: true, preset: .trustedPrivateChat) { (response) in +// +// switch response { +// case .success(_): +// success?() +// case .failure(let error): +// NSLog("[OnBoardingManager] Create chat with riot-bot failed"); +// failure?(error) +// } +// } +// +// // Make multipe tries, until we get a response +// httpOperation.maxNumberOfTries = Constants.createRiotBotDMRequestMaxNumberOfTries + + // Create DM room with Riot-bot - - let httpOperation = self.session.createRoom(name: nil, visibility: .private, alias: nil, topic: nil, invite: [Constants.riotBotMatrixId], invite3PID: nil, isDirect: true, preset: .trustedPrivateChat) { (response) in - - switch response { - case .success(_): - success?() - case .failure(let error): - NSLog("[OnBoardingManager] Create chat with riot-bot failed"); - failure?(error) - } - } - + + let httpOperation = self.session.createRoom(fromSwift: nil, visibility: kMXRoomDirectoryVisibilityPrivate, roomAlias: nil, topic: nil, invite: [Constants.riotBotMatrixId], invite3PID: nil, isDirect: true, preset: kMXRoomPresetTrustedPrivateChat, success: success, failure: nil) + + // Make multipe tries, until we get a response - httpOperation.maxNumberOfTries = Constants.createRiotBotDMRequestMaxNumberOfTries + httpOperation?.maxNumberOfTries = Constants.createRiotBotDMRequestMaxNumberOfTries } // MARK: - Private @@ -76,12 +85,13 @@ final public class OnBoardingManager: NSObject { var isUSerJoinedARoom = false for roomSummary in roomSummaries { - if case .join = roomSummary.membership { + // if case .join = roomSummary.membership { + if case __MXMembershipJoin = roomSummary.membershipFromSwift { isUSerJoinedARoom = true break } } - + return isUSerJoinedARoom } } diff --git a/Riot/SupportingFiles/Riot-Bridging-Header.h b/Riot/SupportingFiles/Riot-Bridging-Header.h index 59026bb56..02b3ba165 100644 --- a/Riot/SupportingFiles/Riot-Bridging-Header.h +++ b/Riot/SupportingFiles/Riot-Bridging-Header.h @@ -4,3 +4,4 @@ @import MatrixSDK; #import "WebViewViewController.h" +#import "MatrixSDK+Swift.h"