├── .gitignore ├── LICENSE.txt ├── MatrixClient.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── MatrixClient.xcworkspace └── contents.xcworkspacedata ├── MatrixClient ├── AppDelegate.swift ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Base.lproj │ └── Main.storyboard ├── CreateRoomViewController.swift ├── ImageProvider.swift ├── Info.plist ├── JoinRoomViewController.swift ├── LoginSheet.storyboard ├── LoginViewController.swift ├── MainSplitViewController.swift ├── MainWindowController.swift ├── MatrixExtensions.swift ├── RoomManagement.storyboard ├── RoundedColorView.swift ├── SidebarController.swift ├── ViewController.swift └── WindowWithDrawer.storyboard ├── MatrixClientTests ├── Info.plist └── MatrixClientTests.swift ├── Podfile ├── Podfile.lock └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | Pods 2 | 3 | # Xcode 4 | # 5 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 6 | 7 | ## Build generated 8 | build/ 9 | DerivedData/ 10 | 11 | ## Various settings 12 | *.pbxuser 13 | !default.pbxuser 14 | *.mode1v3 15 | !default.mode1v3 16 | *.mode2v3 17 | !default.mode2v3 18 | *.perspectivev3 19 | !default.perspectivev3 20 | xcuserdata/ 21 | 22 | ## Other 23 | *.moved-aside 24 | *.xccheckout 25 | *.xcscmblueprint 26 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /MatrixClient.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 475674480C5CBA1568E879BA /* Pods_MatrixClient.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = DF77E14C4FD9A892D64EE2C0 /* Pods_MatrixClient.framework */; }; 11 | C60805811E54E6E9005387D3 /* CreateRoomViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C60805801E54E6E9005387D3 /* CreateRoomViewController.swift */; }; 12 | C60805861E551211005387D3 /* JoinRoomViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C60805841E551211005387D3 /* JoinRoomViewController.swift */; }; 13 | C64D49DA1E37D27A006D9B9B /* WindowWithDrawer.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C64D49D91E37D27A006D9B9B /* WindowWithDrawer.storyboard */; }; 14 | C67872D61E31426F00E67E5D /* SidebarController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C67872D51E31426F00E67E5D /* SidebarController.swift */; }; 15 | C683F4981E54DA3600F8D19B /* RoomManagement.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C683F4971E54DA3600F8D19B /* RoomManagement.storyboard */; }; 16 | C69051D21E354DDA0058ECFA /* LoginSheet.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C69051D11E354DDA0058ECFA /* LoginSheet.storyboard */; }; 17 | C69051D41E354F470058ECFA /* MainSplitViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C69051D31E354F470058ECFA /* MainSplitViewController.swift */; }; 18 | C6941FBE1E36A53700464DEA /* MainWindowController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6941FBD1E36A53700464DEA /* MainWindowController.swift */; }; 19 | C6CC8DC71E2A859F006C231F /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6CC8DC61E2A859F006C231F /* AppDelegate.swift */; }; 20 | C6CC8DC91E2A859F006C231F /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6CC8DC81E2A859F006C231F /* ViewController.swift */; }; 21 | C6CC8DCB1E2A859F006C231F /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C6CC8DCA1E2A859F006C231F /* Assets.xcassets */; }; 22 | C6CC8DCE1E2A859F006C231F /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C6CC8DCC1E2A859F006C231F /* Main.storyboard */; }; 23 | C6CC8DD91E2A859F006C231F /* MatrixClientTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6CC8DD81E2A859F006C231F /* MatrixClientTests.swift */; }; 24 | C6DEFE021E36E31D00E15E87 /* LoginViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6DEFE011E36E31D00E15E87 /* LoginViewController.swift */; }; 25 | C6E5BDF51E46BA8B001C24BD /* RoundedColorView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6E5BDF41E46BA8B001C24BD /* RoundedColorView.swift */; }; 26 | C6E5BDF71E4798EB001C24BD /* ImageProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6E5BDF61E4798EB001C24BD /* ImageProvider.swift */; }; 27 | C6E5BDF91E47D597001C24BD /* MatrixExtensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = C6E5BDF81E47D597001C24BD /* MatrixExtensions.swift */; }; 28 | /* End PBXBuildFile section */ 29 | 30 | /* Begin PBXContainerItemProxy section */ 31 | C6CC8DD51E2A859F006C231F /* PBXContainerItemProxy */ = { 32 | isa = PBXContainerItemProxy; 33 | containerPortal = C6CC8DBB1E2A859F006C231F /* Project object */; 34 | proxyType = 1; 35 | remoteGlobalIDString = C6CC8DC21E2A859F006C231F; 36 | remoteInfo = MatrixClient; 37 | }; 38 | /* End PBXContainerItemProxy section */ 39 | 40 | /* Begin PBXFileReference section */ 41 | 3A32E6126D9BC42DCF075D33 /* Pods_MatrixClientTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_MatrixClientTests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 42 | B7D8B8734A3DDE1AB2BD25EC /* Pods-MatrixClient.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MatrixClient.debug.xcconfig"; path = "Pods/Target Support Files/Pods-MatrixClient/Pods-MatrixClient.debug.xcconfig"; sourceTree = ""; }; 43 | B8A3B1364C5392BFC4DA538B /* Pods-MatrixClient.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-MatrixClient.release.xcconfig"; path = "Pods/Target Support Files/Pods-MatrixClient/Pods-MatrixClient.release.xcconfig"; sourceTree = ""; }; 44 | C60805801E54E6E9005387D3 /* CreateRoomViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CreateRoomViewController.swift; sourceTree = ""; }; 45 | C60805841E551211005387D3 /* JoinRoomViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JoinRoomViewController.swift; sourceTree = ""; }; 46 | C63A81F31E300B4A00F44A88 /* AFNetworking.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AFNetworking.framework; path = "../../../Library/Developer/Xcode/DerivedData/MatrixClient-bcgobsyfiagdnbbbvzdcmzffkena/Build/Products/Debug/AFNetworking/AFNetworking.framework"; sourceTree = ""; }; 47 | C63A81F41E300B4A00F44A88 /* MatrixSDK.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MatrixSDK.framework; path = "../../../Library/Developer/Xcode/DerivedData/MatrixClient-bcgobsyfiagdnbbbvzdcmzffkena/Build/Products/Debug/MatrixSDK/MatrixSDK.framework"; sourceTree = ""; }; 48 | C63A81F51E300B4A00F44A88 /* OLMKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OLMKit.framework; path = "../../../Library/Developer/Xcode/DerivedData/MatrixClient-bcgobsyfiagdnbbbvzdcmzffkena/Build/Products/Debug/OLMKit/OLMKit.framework"; sourceTree = ""; }; 49 | C63A81F61E300B4A00F44A88 /* Realm.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Realm.framework; path = "../../../Library/Developer/Xcode/DerivedData/MatrixClient-bcgobsyfiagdnbbbvzdcmzffkena/Build/Products/Debug/Realm/Realm.framework"; sourceTree = ""; }; 50 | C64D49D91E37D27A006D9B9B /* WindowWithDrawer.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = WindowWithDrawer.storyboard; sourceTree = ""; }; 51 | C67872D51E31426F00E67E5D /* SidebarController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SidebarController.swift; sourceTree = ""; }; 52 | C683F4971E54DA3600F8D19B /* RoomManagement.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = RoomManagement.storyboard; sourceTree = ""; }; 53 | C69051D11E354DDA0058ECFA /* LoginSheet.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = LoginSheet.storyboard; sourceTree = ""; }; 54 | C69051D31E354F470058ECFA /* MainSplitViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainSplitViewController.swift; sourceTree = ""; }; 55 | C6941FBD1E36A53700464DEA /* MainWindowController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MainWindowController.swift; sourceTree = ""; }; 56 | C6CC8DC31E2A859F006C231F /* MatrixClient.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MatrixClient.app; sourceTree = BUILT_PRODUCTS_DIR; }; 57 | C6CC8DC61E2A859F006C231F /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 58 | C6CC8DC81E2A859F006C231F /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 59 | C6CC8DCA1E2A859F006C231F /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 60 | C6CC8DCD1E2A859F006C231F /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 61 | C6CC8DCF1E2A859F006C231F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 62 | C6CC8DD41E2A859F006C231F /* MatrixClientTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = MatrixClientTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 63 | C6CC8DD81E2A859F006C231F /* MatrixClientTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = MatrixClientTests.swift; sourceTree = ""; }; 64 | C6CC8DDA1E2A859F006C231F /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 65 | C6DEFE011E36E31D00E15E87 /* LoginViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LoginViewController.swift; sourceTree = ""; }; 66 | C6E5BDF41E46BA8B001C24BD /* RoundedColorView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RoundedColorView.swift; sourceTree = ""; }; 67 | C6E5BDF61E4798EB001C24BD /* ImageProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageProvider.swift; sourceTree = ""; }; 68 | C6E5BDF81E47D597001C24BD /* MatrixExtensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MatrixExtensions.swift; sourceTree = ""; }; 69 | DF77E14C4FD9A892D64EE2C0 /* Pods_MatrixClient.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_MatrixClient.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 70 | /* End PBXFileReference section */ 71 | 72 | /* Begin PBXFrameworksBuildPhase section */ 73 | C6CC8DC01E2A859F006C231F /* Frameworks */ = { 74 | isa = PBXFrameworksBuildPhase; 75 | buildActionMask = 2147483647; 76 | files = ( 77 | 475674480C5CBA1568E879BA /* Pods_MatrixClient.framework in Frameworks */, 78 | ); 79 | runOnlyForDeploymentPostprocessing = 0; 80 | }; 81 | C6CC8DD11E2A859F006C231F /* Frameworks */ = { 82 | isa = PBXFrameworksBuildPhase; 83 | buildActionMask = 2147483647; 84 | files = ( 85 | ); 86 | runOnlyForDeploymentPostprocessing = 0; 87 | }; 88 | /* End PBXFrameworksBuildPhase section */ 89 | 90 | /* Begin PBXGroup section */ 91 | 1218F838DE5F4C57EDE9D77F /* Pods */ = { 92 | isa = PBXGroup; 93 | children = ( 94 | B7D8B8734A3DDE1AB2BD25EC /* Pods-MatrixClient.debug.xcconfig */, 95 | B8A3B1364C5392BFC4DA538B /* Pods-MatrixClient.release.xcconfig */, 96 | ); 97 | name = Pods; 98 | sourceTree = ""; 99 | }; 100 | 40D14E7B5393DD736CA9BEBD /* Frameworks */ = { 101 | isa = PBXGroup; 102 | children = ( 103 | C63A81F31E300B4A00F44A88 /* AFNetworking.framework */, 104 | C63A81F41E300B4A00F44A88 /* MatrixSDK.framework */, 105 | C63A81F51E300B4A00F44A88 /* OLMKit.framework */, 106 | C63A81F61E300B4A00F44A88 /* Realm.framework */, 107 | DF77E14C4FD9A892D64EE2C0 /* Pods_MatrixClient.framework */, 108 | 3A32E6126D9BC42DCF075D33 /* Pods_MatrixClientTests.framework */, 109 | ); 110 | name = Frameworks; 111 | sourceTree = ""; 112 | }; 113 | C6CC8DBA1E2A859F006C231F = { 114 | isa = PBXGroup; 115 | children = ( 116 | C6CC8DC51E2A859F006C231F /* MatrixClient */, 117 | C6CC8DD71E2A859F006C231F /* MatrixClientTests */, 118 | C6CC8DC41E2A859F006C231F /* Products */, 119 | 40D14E7B5393DD736CA9BEBD /* Frameworks */, 120 | 1218F838DE5F4C57EDE9D77F /* Pods */, 121 | ); 122 | sourceTree = ""; 123 | }; 124 | C6CC8DC41E2A859F006C231F /* Products */ = { 125 | isa = PBXGroup; 126 | children = ( 127 | C6CC8DC31E2A859F006C231F /* MatrixClient.app */, 128 | C6CC8DD41E2A859F006C231F /* MatrixClientTests.xctest */, 129 | ); 130 | name = Products; 131 | sourceTree = ""; 132 | }; 133 | C6CC8DC51E2A859F006C231F /* MatrixClient */ = { 134 | isa = PBXGroup; 135 | children = ( 136 | C6CC8DC61E2A859F006C231F /* AppDelegate.swift */, 137 | C6941FBD1E36A53700464DEA /* MainWindowController.swift */, 138 | C69051D31E354F470058ECFA /* MainSplitViewController.swift */, 139 | C6CC8DC81E2A859F006C231F /* ViewController.swift */, 140 | C6E5BDF41E46BA8B001C24BD /* RoundedColorView.swift */, 141 | C67872D51E31426F00E67E5D /* SidebarController.swift */, 142 | C6DEFE011E36E31D00E15E87 /* LoginViewController.swift */, 143 | C6E5BDF61E4798EB001C24BD /* ImageProvider.swift */, 144 | C6E5BDF81E47D597001C24BD /* MatrixExtensions.swift */, 145 | C60805801E54E6E9005387D3 /* CreateRoomViewController.swift */, 146 | C60805841E551211005387D3 /* JoinRoomViewController.swift */, 147 | C6CC8DCA1E2A859F006C231F /* Assets.xcassets */, 148 | C6CC8DCC1E2A859F006C231F /* Main.storyboard */, 149 | C683F4971E54DA3600F8D19B /* RoomManagement.storyboard */, 150 | C69051D11E354DDA0058ECFA /* LoginSheet.storyboard */, 151 | C6CC8DCF1E2A859F006C231F /* Info.plist */, 152 | C64D49D91E37D27A006D9B9B /* WindowWithDrawer.storyboard */, 153 | ); 154 | path = MatrixClient; 155 | sourceTree = ""; 156 | }; 157 | C6CC8DD71E2A859F006C231F /* MatrixClientTests */ = { 158 | isa = PBXGroup; 159 | children = ( 160 | C6CC8DD81E2A859F006C231F /* MatrixClientTests.swift */, 161 | C6CC8DDA1E2A859F006C231F /* Info.plist */, 162 | ); 163 | path = MatrixClientTests; 164 | sourceTree = ""; 165 | }; 166 | /* End PBXGroup section */ 167 | 168 | /* Begin PBXNativeTarget section */ 169 | C6CC8DC21E2A859F006C231F /* MatrixClient */ = { 170 | isa = PBXNativeTarget; 171 | buildConfigurationList = C6CC8DDD1E2A859F006C231F /* Build configuration list for PBXNativeTarget "MatrixClient" */; 172 | buildPhases = ( 173 | 666C399D95F8A2D732348891 /* [CP] Check Pods Manifest.lock */, 174 | C6CC8DBF1E2A859F006C231F /* Sources */, 175 | C6CC8DC01E2A859F006C231F /* Frameworks */, 176 | C6CC8DC11E2A859F006C231F /* Resources */, 177 | D54A2D317D83B60E84155270 /* [CP] Embed Pods Frameworks */, 178 | E56BFBFDCCC8536A81D6BDF5 /* [CP] Copy Pods Resources */, 179 | ); 180 | buildRules = ( 181 | ); 182 | dependencies = ( 183 | ); 184 | name = MatrixClient; 185 | productName = MatrixClient; 186 | productReference = C6CC8DC31E2A859F006C231F /* MatrixClient.app */; 187 | productType = "com.apple.product-type.application"; 188 | }; 189 | C6CC8DD31E2A859F006C231F /* MatrixClientTests */ = { 190 | isa = PBXNativeTarget; 191 | buildConfigurationList = C6CC8DE01E2A859F006C231F /* Build configuration list for PBXNativeTarget "MatrixClientTests" */; 192 | buildPhases = ( 193 | C6CC8DD01E2A859F006C231F /* Sources */, 194 | C6CC8DD11E2A859F006C231F /* Frameworks */, 195 | C6CC8DD21E2A859F006C231F /* Resources */, 196 | ); 197 | buildRules = ( 198 | ); 199 | dependencies = ( 200 | C6CC8DD61E2A859F006C231F /* PBXTargetDependency */, 201 | ); 202 | name = MatrixClientTests; 203 | productName = MatrixClientTests; 204 | productReference = C6CC8DD41E2A859F006C231F /* MatrixClientTests.xctest */; 205 | productType = "com.apple.product-type.bundle.unit-test"; 206 | }; 207 | /* End PBXNativeTarget section */ 208 | 209 | /* Begin PBXProject section */ 210 | C6CC8DBB1E2A859F006C231F /* Project object */ = { 211 | isa = PBXProject; 212 | attributes = { 213 | LastSwiftUpdateCheck = 0820; 214 | LastUpgradeCheck = 0820; 215 | ORGANIZATIONNAME = "Avery Pierce"; 216 | TargetAttributes = { 217 | C6CC8DC21E2A859F006C231F = { 218 | CreatedOnToolsVersion = 8.2.1; 219 | DevelopmentTeam = BU7LJXTUEW; 220 | ProvisioningStyle = Automatic; 221 | }; 222 | C6CC8DD31E2A859F006C231F = { 223 | CreatedOnToolsVersion = 8.2.1; 224 | DevelopmentTeam = BU7LJXTUEW; 225 | ProvisioningStyle = Automatic; 226 | TestTargetID = C6CC8DC21E2A859F006C231F; 227 | }; 228 | }; 229 | }; 230 | buildConfigurationList = C6CC8DBE1E2A859F006C231F /* Build configuration list for PBXProject "MatrixClient" */; 231 | compatibilityVersion = "Xcode 3.2"; 232 | developmentRegion = English; 233 | hasScannedForEncodings = 0; 234 | knownRegions = ( 235 | en, 236 | Base, 237 | ); 238 | mainGroup = C6CC8DBA1E2A859F006C231F; 239 | productRefGroup = C6CC8DC41E2A859F006C231F /* Products */; 240 | projectDirPath = ""; 241 | projectRoot = ""; 242 | targets = ( 243 | C6CC8DC21E2A859F006C231F /* MatrixClient */, 244 | C6CC8DD31E2A859F006C231F /* MatrixClientTests */, 245 | ); 246 | }; 247 | /* End PBXProject section */ 248 | 249 | /* Begin PBXResourcesBuildPhase section */ 250 | C6CC8DC11E2A859F006C231F /* Resources */ = { 251 | isa = PBXResourcesBuildPhase; 252 | buildActionMask = 2147483647; 253 | files = ( 254 | C6CC8DCB1E2A859F006C231F /* Assets.xcassets in Resources */, 255 | C6CC8DCE1E2A859F006C231F /* Main.storyboard in Resources */, 256 | C69051D21E354DDA0058ECFA /* LoginSheet.storyboard in Resources */, 257 | C683F4981E54DA3600F8D19B /* RoomManagement.storyboard in Resources */, 258 | C64D49DA1E37D27A006D9B9B /* WindowWithDrawer.storyboard in Resources */, 259 | ); 260 | runOnlyForDeploymentPostprocessing = 0; 261 | }; 262 | C6CC8DD21E2A859F006C231F /* Resources */ = { 263 | isa = PBXResourcesBuildPhase; 264 | buildActionMask = 2147483647; 265 | files = ( 266 | ); 267 | runOnlyForDeploymentPostprocessing = 0; 268 | }; 269 | /* End PBXResourcesBuildPhase section */ 270 | 271 | /* Begin PBXShellScriptBuildPhase section */ 272 | 666C399D95F8A2D732348891 /* [CP] Check Pods Manifest.lock */ = { 273 | isa = PBXShellScriptBuildPhase; 274 | buildActionMask = 2147483647; 275 | files = ( 276 | ); 277 | inputPaths = ( 278 | ); 279 | name = "[CP] Check Pods Manifest.lock"; 280 | outputPaths = ( 281 | ); 282 | runOnlyForDeploymentPostprocessing = 0; 283 | shellPath = /bin/sh; 284 | shellScript = "diff \"${PODS_ROOT}/../Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n"; 285 | showEnvVarsInLog = 0; 286 | }; 287 | D54A2D317D83B60E84155270 /* [CP] Embed Pods Frameworks */ = { 288 | isa = PBXShellScriptBuildPhase; 289 | buildActionMask = 2147483647; 290 | files = ( 291 | ); 292 | inputPaths = ( 293 | ); 294 | name = "[CP] Embed Pods Frameworks"; 295 | outputPaths = ( 296 | ); 297 | runOnlyForDeploymentPostprocessing = 0; 298 | shellPath = /bin/sh; 299 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-MatrixClient/Pods-MatrixClient-frameworks.sh\"\n"; 300 | showEnvVarsInLog = 0; 301 | }; 302 | E56BFBFDCCC8536A81D6BDF5 /* [CP] Copy Pods Resources */ = { 303 | isa = PBXShellScriptBuildPhase; 304 | buildActionMask = 2147483647; 305 | files = ( 306 | ); 307 | inputPaths = ( 308 | ); 309 | name = "[CP] Copy Pods Resources"; 310 | outputPaths = ( 311 | ); 312 | runOnlyForDeploymentPostprocessing = 0; 313 | shellPath = /bin/sh; 314 | shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-MatrixClient/Pods-MatrixClient-resources.sh\"\n"; 315 | showEnvVarsInLog = 0; 316 | }; 317 | /* End PBXShellScriptBuildPhase section */ 318 | 319 | /* Begin PBXSourcesBuildPhase section */ 320 | C6CC8DBF1E2A859F006C231F /* Sources */ = { 321 | isa = PBXSourcesBuildPhase; 322 | buildActionMask = 2147483647; 323 | files = ( 324 | C6DEFE021E36E31D00E15E87 /* LoginViewController.swift in Sources */, 325 | C6E5BDF91E47D597001C24BD /* MatrixExtensions.swift in Sources */, 326 | C60805861E551211005387D3 /* JoinRoomViewController.swift in Sources */, 327 | C6E5BDF51E46BA8B001C24BD /* RoundedColorView.swift in Sources */, 328 | C69051D41E354F470058ECFA /* MainSplitViewController.swift in Sources */, 329 | C6CC8DC91E2A859F006C231F /* ViewController.swift in Sources */, 330 | C6E5BDF71E4798EB001C24BD /* ImageProvider.swift in Sources */, 331 | C67872D61E31426F00E67E5D /* SidebarController.swift in Sources */, 332 | C6CC8DC71E2A859F006C231F /* AppDelegate.swift in Sources */, 333 | C6941FBE1E36A53700464DEA /* MainWindowController.swift in Sources */, 334 | C60805811E54E6E9005387D3 /* CreateRoomViewController.swift in Sources */, 335 | ); 336 | runOnlyForDeploymentPostprocessing = 0; 337 | }; 338 | C6CC8DD01E2A859F006C231F /* Sources */ = { 339 | isa = PBXSourcesBuildPhase; 340 | buildActionMask = 2147483647; 341 | files = ( 342 | C6CC8DD91E2A859F006C231F /* MatrixClientTests.swift in Sources */, 343 | ); 344 | runOnlyForDeploymentPostprocessing = 0; 345 | }; 346 | /* End PBXSourcesBuildPhase section */ 347 | 348 | /* Begin PBXTargetDependency section */ 349 | C6CC8DD61E2A859F006C231F /* PBXTargetDependency */ = { 350 | isa = PBXTargetDependency; 351 | target = C6CC8DC21E2A859F006C231F /* MatrixClient */; 352 | targetProxy = C6CC8DD51E2A859F006C231F /* PBXContainerItemProxy */; 353 | }; 354 | /* End PBXTargetDependency section */ 355 | 356 | /* Begin PBXVariantGroup section */ 357 | C6CC8DCC1E2A859F006C231F /* Main.storyboard */ = { 358 | isa = PBXVariantGroup; 359 | children = ( 360 | C6CC8DCD1E2A859F006C231F /* Base */, 361 | ); 362 | name = Main.storyboard; 363 | sourceTree = ""; 364 | }; 365 | /* End PBXVariantGroup section */ 366 | 367 | /* Begin XCBuildConfiguration section */ 368 | C6CC8DDB1E2A859F006C231F /* Debug */ = { 369 | isa = XCBuildConfiguration; 370 | buildSettings = { 371 | ALWAYS_SEARCH_USER_PATHS = NO; 372 | CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES; 373 | CLANG_ANALYZER_NONNULL = YES; 374 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 375 | CLANG_CXX_LIBRARY = "libc++"; 376 | CLANG_ENABLE_MODULES = YES; 377 | CLANG_ENABLE_OBJC_ARC = YES; 378 | CLANG_WARN_BOOL_CONVERSION = YES; 379 | CLANG_WARN_CONSTANT_CONVERSION = YES; 380 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 381 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 382 | CLANG_WARN_EMPTY_BODY = YES; 383 | CLANG_WARN_ENUM_CONVERSION = YES; 384 | CLANG_WARN_INFINITE_RECURSION = YES; 385 | CLANG_WARN_INT_CONVERSION = YES; 386 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 387 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 388 | CLANG_WARN_UNREACHABLE_CODE = YES; 389 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 390 | CODE_SIGN_IDENTITY = "-"; 391 | COPY_PHASE_STRIP = NO; 392 | DEBUG_INFORMATION_FORMAT = dwarf; 393 | ENABLE_STRICT_OBJC_MSGSEND = YES; 394 | ENABLE_TESTABILITY = YES; 395 | GCC_C_LANGUAGE_STANDARD = gnu99; 396 | GCC_DYNAMIC_NO_PIC = NO; 397 | GCC_NO_COMMON_BLOCKS = YES; 398 | GCC_OPTIMIZATION_LEVEL = 0; 399 | GCC_PREPROCESSOR_DEFINITIONS = ( 400 | "DEBUG=1", 401 | "$(inherited)", 402 | ); 403 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 404 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 405 | GCC_WARN_UNDECLARED_SELECTOR = YES; 406 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 407 | GCC_WARN_UNUSED_FUNCTION = YES; 408 | GCC_WARN_UNUSED_VARIABLE = YES; 409 | MACOSX_DEPLOYMENT_TARGET = 10.12; 410 | MTL_ENABLE_DEBUG_INFO = YES; 411 | ONLY_ACTIVE_ARCH = YES; 412 | SDKROOT = macosx; 413 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 414 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 415 | }; 416 | name = Debug; 417 | }; 418 | C6CC8DDC1E2A859F006C231F /* Release */ = { 419 | isa = XCBuildConfiguration; 420 | buildSettings = { 421 | ALWAYS_SEARCH_USER_PATHS = NO; 422 | CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES = YES; 423 | CLANG_ANALYZER_NONNULL = YES; 424 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 425 | CLANG_CXX_LIBRARY = "libc++"; 426 | CLANG_ENABLE_MODULES = YES; 427 | CLANG_ENABLE_OBJC_ARC = YES; 428 | CLANG_WARN_BOOL_CONVERSION = YES; 429 | CLANG_WARN_CONSTANT_CONVERSION = YES; 430 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 431 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 432 | CLANG_WARN_EMPTY_BODY = YES; 433 | CLANG_WARN_ENUM_CONVERSION = YES; 434 | CLANG_WARN_INFINITE_RECURSION = YES; 435 | CLANG_WARN_INT_CONVERSION = YES; 436 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 437 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 438 | CLANG_WARN_UNREACHABLE_CODE = YES; 439 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 440 | CODE_SIGN_IDENTITY = "-"; 441 | COPY_PHASE_STRIP = NO; 442 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 443 | ENABLE_NS_ASSERTIONS = NO; 444 | ENABLE_STRICT_OBJC_MSGSEND = YES; 445 | GCC_C_LANGUAGE_STANDARD = gnu99; 446 | GCC_NO_COMMON_BLOCKS = YES; 447 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 448 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 449 | GCC_WARN_UNDECLARED_SELECTOR = YES; 450 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 451 | GCC_WARN_UNUSED_FUNCTION = YES; 452 | GCC_WARN_UNUSED_VARIABLE = YES; 453 | MACOSX_DEPLOYMENT_TARGET = 10.12; 454 | MTL_ENABLE_DEBUG_INFO = NO; 455 | SDKROOT = macosx; 456 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 457 | }; 458 | name = Release; 459 | }; 460 | C6CC8DDE1E2A859F006C231F /* Debug */ = { 461 | isa = XCBuildConfiguration; 462 | baseConfigurationReference = B7D8B8734A3DDE1AB2BD25EC /* Pods-MatrixClient.debug.xcconfig */; 463 | buildSettings = { 464 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 465 | COMBINE_HIDPI_IMAGES = YES; 466 | DEVELOPMENT_TEAM = BU7LJXTUEW; 467 | INFOPLIST_FILE = MatrixClient/Info.plist; 468 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 469 | PRODUCT_BUNDLE_IDENTIFIER = com.averypierce.MatrixClient; 470 | PRODUCT_NAME = "$(TARGET_NAME)"; 471 | SWIFT_VERSION = 3.0; 472 | }; 473 | name = Debug; 474 | }; 475 | C6CC8DDF1E2A859F006C231F /* Release */ = { 476 | isa = XCBuildConfiguration; 477 | baseConfigurationReference = B8A3B1364C5392BFC4DA538B /* Pods-MatrixClient.release.xcconfig */; 478 | buildSettings = { 479 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 480 | COMBINE_HIDPI_IMAGES = YES; 481 | DEVELOPMENT_TEAM = BU7LJXTUEW; 482 | INFOPLIST_FILE = MatrixClient/Info.plist; 483 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks"; 484 | PRODUCT_BUNDLE_IDENTIFIER = com.averypierce.MatrixClient; 485 | PRODUCT_NAME = "$(TARGET_NAME)"; 486 | SWIFT_VERSION = 3.0; 487 | }; 488 | name = Release; 489 | }; 490 | C6CC8DE11E2A859F006C231F /* Debug */ = { 491 | isa = XCBuildConfiguration; 492 | buildSettings = { 493 | BUNDLE_LOADER = "$(TEST_HOST)"; 494 | COMBINE_HIDPI_IMAGES = YES; 495 | DEVELOPMENT_TEAM = BU7LJXTUEW; 496 | INFOPLIST_FILE = MatrixClientTests/Info.plist; 497 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; 498 | PRODUCT_BUNDLE_IDENTIFIER = com.averypierce.MatrixClientTests; 499 | PRODUCT_NAME = "$(TARGET_NAME)"; 500 | SWIFT_VERSION = 3.0; 501 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/MatrixClient.app/Contents/MacOS/MatrixClient"; 502 | }; 503 | name = Debug; 504 | }; 505 | C6CC8DE21E2A859F006C231F /* Release */ = { 506 | isa = XCBuildConfiguration; 507 | buildSettings = { 508 | BUNDLE_LOADER = "$(TEST_HOST)"; 509 | COMBINE_HIDPI_IMAGES = YES; 510 | DEVELOPMENT_TEAM = BU7LJXTUEW; 511 | INFOPLIST_FILE = MatrixClientTests/Info.plist; 512 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; 513 | PRODUCT_BUNDLE_IDENTIFIER = com.averypierce.MatrixClientTests; 514 | PRODUCT_NAME = "$(TARGET_NAME)"; 515 | SWIFT_VERSION = 3.0; 516 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/MatrixClient.app/Contents/MacOS/MatrixClient"; 517 | }; 518 | name = Release; 519 | }; 520 | /* End XCBuildConfiguration section */ 521 | 522 | /* Begin XCConfigurationList section */ 523 | C6CC8DBE1E2A859F006C231F /* Build configuration list for PBXProject "MatrixClient" */ = { 524 | isa = XCConfigurationList; 525 | buildConfigurations = ( 526 | C6CC8DDB1E2A859F006C231F /* Debug */, 527 | C6CC8DDC1E2A859F006C231F /* Release */, 528 | ); 529 | defaultConfigurationIsVisible = 0; 530 | defaultConfigurationName = Release; 531 | }; 532 | C6CC8DDD1E2A859F006C231F /* Build configuration list for PBXNativeTarget "MatrixClient" */ = { 533 | isa = XCConfigurationList; 534 | buildConfigurations = ( 535 | C6CC8DDE1E2A859F006C231F /* Debug */, 536 | C6CC8DDF1E2A859F006C231F /* Release */, 537 | ); 538 | defaultConfigurationIsVisible = 0; 539 | defaultConfigurationName = Release; 540 | }; 541 | C6CC8DE01E2A859F006C231F /* Build configuration list for PBXNativeTarget "MatrixClientTests" */ = { 542 | isa = XCConfigurationList; 543 | buildConfigurations = ( 544 | C6CC8DE11E2A859F006C231F /* Debug */, 545 | C6CC8DE21E2A859F006C231F /* Release */, 546 | ); 547 | defaultConfigurationIsVisible = 0; 548 | defaultConfigurationName = Release; 549 | }; 550 | /* End XCConfigurationList section */ 551 | }; 552 | rootObject = C6CC8DBB1E2A859F006C231F /* Project object */; 553 | } 554 | -------------------------------------------------------------------------------- /MatrixClient.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /MatrixClient.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /MatrixClient/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Avery Pierce 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | import Cocoa 18 | import SwiftMatrixSDK 19 | 20 | protocol MatrixSessionManagerDelegate { 21 | func matrixDidStart(_ session: MXSession) 22 | func matrixDidLogout() 23 | } 24 | 25 | class MatrixSessionManager { 26 | static let shared = MatrixSessionManager() 27 | 28 | static let credentialsDictionaryKey = "MatrixCredentials" 29 | 30 | enum State { 31 | case needsCredentials, notStarted, starting, started 32 | } 33 | 34 | private(set) var state: State 35 | 36 | var credentials: MXCredentials? { 37 | didSet { 38 | 39 | // Make sure to synchronize the user defaults after we're done here 40 | defer { UserDefaults.standard.synchronize() } 41 | 42 | guard 43 | let homeServer = credentials?.homeServer, 44 | let userId = credentials?.userId, 45 | let token = credentials?.accessToken 46 | else { UserDefaults.standard.removeObject(forKey: "MatrixCredentials"); return } 47 | 48 | let storedCredentials: [String: String] = [ 49 | "homeServer": homeServer, 50 | "userId": userId, 51 | "token": token 52 | ] 53 | 54 | UserDefaults.standard.set(storedCredentials, forKey: "MatrixCredentials") 55 | } 56 | } 57 | var session: MXSession? 58 | var delegate: MatrixSessionManagerDelegate? 59 | 60 | init() { 61 | 62 | // Make sure that someone is logged in. 63 | if let savedCredentials = UserDefaults.standard.dictionary(forKey: MatrixSessionManager.credentialsDictionaryKey), 64 | let homeServer = savedCredentials["homeServer"] as? String, 65 | let userId = savedCredentials["userId"] as? String, 66 | let token = savedCredentials["token"] as? String { 67 | 68 | credentials = MXCredentials(homeServer: homeServer, userId: userId, accessToken: token) 69 | state = .notStarted 70 | } else { 71 | state = .needsCredentials 72 | credentials = nil 73 | } 74 | } 75 | 76 | func start() { 77 | guard let credentials = credentials else { return } 78 | 79 | let restClient = MXRestClient(credentials: credentials, unrecognizedCertificateHandler: nil) 80 | session = MXSession(matrixRestClient: restClient) 81 | 82 | state = .starting 83 | 84 | let fileStore = MXFileStore() 85 | session?.setStore(fileStore) { response in 86 | if case .failure(let error) = response { 87 | print("An error occurred setting the store: \(error)") 88 | return 89 | } 90 | 91 | self.state = .starting 92 | self.session?.start { response in 93 | guard response.isSuccess else { return } 94 | 95 | DispatchQueue.main.async { 96 | self.state = .started 97 | self.delegate?.matrixDidStart(self.session!); 98 | } 99 | } 100 | } 101 | } 102 | 103 | func logout() { 104 | 105 | UserDefaults.standard.removeObject(forKey: MatrixSessionManager.credentialsDictionaryKey) 106 | UserDefaults.standard.synchronize() 107 | self.credentials = nil 108 | self.state = .needsCredentials 109 | 110 | session?.logout { _ in 111 | self.delegate?.matrixDidLogout() 112 | } 113 | } 114 | } 115 | 116 | 117 | @NSApplicationMain 118 | class AppDelegate: NSObject, NSApplicationDelegate, MatrixSessionManagerDelegate { 119 | 120 | func applicationDidFinishLaunching(_ aNotification: Notification) { 121 | // Insert code here to initialize your application 122 | MatrixSessionManager.shared.delegate = self 123 | } 124 | 125 | func applicationWillTerminate(_ aNotification: Notification) { 126 | // Insert code here to tear down your application 127 | } 128 | 129 | func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { 130 | return false 131 | } 132 | 133 | 134 | 135 | func matrixDidStart(_ session: MXSession) { 136 | let allViewControllers = NSApplication.shared().windows.flatMap({ return $0.descendentViewControllers }) 137 | 138 | allViewControllers.flatMap({ return $0 as? MatrixSessionManagerDelegate }).forEach { (delegate) in 139 | delegate.matrixDidStart(session) 140 | } 141 | } 142 | 143 | func matrixDidLogout() { 144 | let allViewControllers = NSApplication.shared().windows.flatMap({ return $0.descendentViewControllers }) 145 | 146 | allViewControllers.flatMap({ return $0 as? MatrixSessionManagerDelegate }).forEach { (delegate) in 147 | delegate.matrixDidLogout() 148 | } 149 | } 150 | } 151 | 152 | fileprivate extension NSWindow { 153 | var descendentViewControllers: [NSViewController] { 154 | var descendents = [NSViewController]() 155 | if let rootViewController = windowController?.contentViewController { 156 | descendents.append(rootViewController) 157 | descendents.append(contentsOf: rootViewController.descendentViewControllers) 158 | } 159 | return descendents 160 | } 161 | } 162 | 163 | fileprivate extension NSViewController { 164 | var descendentViewControllers: [NSViewController] { 165 | // Capture this view controller's children, and add their descendents 166 | var descendents = childViewControllers 167 | descendents.append(contentsOf: childViewControllers.flatMap({ return $0.descendentViewControllers })) 168 | return descendents 169 | } 170 | } 171 | -------------------------------------------------------------------------------- /MatrixClient/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "mac", 5 | "size" : "16x16", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "mac", 10 | "size" : "16x16", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "mac", 15 | "size" : "32x32", 16 | "scale" : "1x" 17 | }, 18 | { 19 | "idiom" : "mac", 20 | "size" : "32x32", 21 | "scale" : "2x" 22 | }, 23 | { 24 | "idiom" : "mac", 25 | "size" : "128x128", 26 | "scale" : "1x" 27 | }, 28 | { 29 | "idiom" : "mac", 30 | "size" : "128x128", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "idiom" : "mac", 35 | "size" : "256x256", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "mac", 40 | "size" : "256x256", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "mac", 45 | "size" : "512x512", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "mac", 50 | "size" : "512x512", 51 | "scale" : "2x" 52 | } 53 | ], 54 | "info" : { 55 | "version" : 1, 56 | "author" : "xcode" 57 | } 58 | } -------------------------------------------------------------------------------- /MatrixClient/CreateRoomViewController.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Avery Pierce 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | import Cocoa 18 | import SwiftMatrixSDK 19 | 20 | protocol CreateRoomViewControllerDelegate : class { 21 | func createRoomViewControllerDidCancel(_ sender: CreateRoomViewController) 22 | func createRoomViewControllerDidSubmit(_ sender: CreateRoomViewController) 23 | } 24 | 25 | class CreateRoomViewController: NSViewController { 26 | 27 | weak var delegate: CreateRoomViewControllerDelegate? 28 | 29 | @IBOutlet weak var nameTextField: NSTextField! 30 | @IBOutlet weak var aliasTextField: NSTextField! 31 | @IBOutlet weak var visibilityPopUpButton: NSPopUpButton! 32 | 33 | var roomName: String { return nameTextField.stringValue } 34 | var roomAlias: String { return aliasTextField.stringValue } 35 | var roomVisibility: MXRoomDirectoryVisibility { 36 | switch visibilityPopUpButton.titleOfSelectedItem ?? "" { 37 | case "Public": return .public 38 | case "Private": return .private 39 | default: return .private // This should never run... 40 | } 41 | } 42 | 43 | @IBAction func cancelButtonClicked(_ sender: NSButton) { 44 | delegate?.createRoomViewControllerDidCancel(self) 45 | } 46 | 47 | @IBAction func createButtonClicked(_ sender: NSButton) { 48 | delegate?.createRoomViewControllerDidSubmit(self) 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /MatrixClient/ImageProvider.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Avery Pierce 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | import Foundation 18 | import SwiftMatrixSDK 19 | 20 | struct UnknownError : Error { 21 | var localizedDescription: String { 22 | return "error object was unexpectedly nil" 23 | } 24 | } 25 | 26 | /// Downloads images and provides them. 27 | class ImageProvider { 28 | 29 | var semaphores: [URL: DispatchSemaphore] = [:] 30 | var cache: [URL: NSImage] = [:] 31 | 32 | func semaphore(for url: URL) -> DispatchSemaphore { 33 | if let semaphore = self.semaphores[url] { return semaphore } 34 | let newSemaphore = DispatchSemaphore(value: 1) 35 | self.semaphores[url] = newSemaphore 36 | return newSemaphore 37 | } 38 | 39 | func cachedImage(for url: URL) -> NSImage? { 40 | return cache[url] 41 | } 42 | 43 | func image(for url: URL, completion: @escaping (_ response: MXResponse) -> Void) { 44 | 45 | // Get the semaphore for this url 46 | let semaphore = self.semaphore(for: url) 47 | 48 | // This operation needs to be performed on a background thread 49 | let queue = DispatchQueue(label: "Image Provider") 50 | queue.async { 51 | 52 | // Wait until any downloads are complete 53 | semaphore.wait() 54 | 55 | // If the image already exists in the cache, return it. 56 | if let image = self.cache[url] { 57 | completion(.success(image)) 58 | semaphore.signal() 59 | return 60 | } 61 | 62 | 63 | URLSession.shared.dataTask(with: url) { (data, response, error) in 64 | 65 | // The request is complete, so make sure to signal 66 | defer { semaphore.signal() } 67 | 68 | // Create a result object from the URLSession response 69 | let result: MXResponse 70 | if let data = data, let image = NSImage(data: data) { 71 | self.cache[url] = image 72 | result = .success(image) 73 | } else if let error = error { 74 | result = .failure(error) 75 | } else { 76 | result = .failure(UnknownError()) 77 | } 78 | 79 | // Perform the completion block on the main thread. 80 | DispatchQueue.main.async { completion(result) } 81 | }.resume() 82 | } 83 | 84 | 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /MatrixClient/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleVersion 22 | 1 23 | LSApplicationCategoryType 24 | public.app-category.social-networking 25 | LSMinimumSystemVersion 26 | $(MACOSX_DEPLOYMENT_TARGET) 27 | NSHumanReadableCopyright 28 | Copyright © 2017 Avery Pierce. All rights reserved. 29 | NSMainStoryboardFile 30 | Main 31 | NSPrincipalClass 32 | NSApplication 33 | 34 | 35 | -------------------------------------------------------------------------------- /MatrixClient/JoinRoomViewController.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Avery Pierce 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | import Cocoa 18 | 19 | protocol JoinRoomViewControllerDelegate : class { 20 | func joinRoomViewControllerDidCancel(_ sender: JoinRoomViewController) 21 | func joinRoomViewControllerDidSubmit(_ sender: JoinRoomViewController) 22 | } 23 | 24 | 25 | class JoinRoomViewController: NSViewController { 26 | 27 | weak var delegate: JoinRoomViewControllerDelegate? 28 | 29 | @IBOutlet weak var nameTextField: NSTextField! 30 | 31 | var roomIdOrAlias: String { return nameTextField.stringValue } 32 | 33 | @IBAction func cancelButtonClicked(_ sender: NSButton) { 34 | delegate?.joinRoomViewControllerDidCancel(self) 35 | } 36 | 37 | @IBAction func createButtonClicked(_ sender: NSButton) { 38 | delegate?.joinRoomViewControllerDidSubmit(self) 39 | } 40 | 41 | } 42 | -------------------------------------------------------------------------------- /MatrixClient/LoginSheet.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | NSAllRomanInputSourcesLocaleIdentifier 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | -------------------------------------------------------------------------------- /MatrixClient/LoginViewController.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Avery Pierce 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | import Cocoa 18 | import SwiftMatrixSDK 19 | 20 | protocol LoginViewControllerDelegate { 21 | func loginViewController(_ sender: LoginViewController, didLoginWith credentials: MXCredentials) 22 | } 23 | 24 | class LoginViewController: NSViewController { 25 | 26 | @IBOutlet weak var addressTextField: NSTextField! 27 | @IBOutlet weak var usernameTextField: NSTextField! 28 | @IBOutlet weak var passwordTextField: NSTextField! 29 | 30 | @IBOutlet weak var progressIndicator: NSProgressIndicator! 31 | 32 | @IBOutlet weak var loginButton: NSButton! 33 | 34 | var delegate: LoginViewControllerDelegate? 35 | 36 | override func viewDidLoad() { 37 | super.viewDidLoad() 38 | // Do view setup here. 39 | 40 | } 41 | 42 | @IBAction func submitLogin(_ sender: NSButton) { 43 | let address = addressTextField.stringValue 44 | let username = usernameTextField.stringValue 45 | let password = passwordTextField.stringValue 46 | 47 | progressIndicator.startAnimation(nil) 48 | 49 | let client = MXRestClient(homeServer: URL(string: address)!, unrecognizedCertificateHandler: nil) 50 | client.login(username: username, password: password) { response in 51 | 52 | // Stop the animation 53 | self.progressIndicator.stopAnimation(nil) 54 | 55 | switch response { 56 | case .success(let credentials): 57 | self.delegate?.loginViewController(self, didLoginWith: credentials) 58 | case .failure: 59 | self.passwordTextField.stringValue = "" 60 | } 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /MatrixClient/MainSplitViewController.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Avery Pierce 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | import Cocoa 18 | import SwiftMatrixSDK 19 | 20 | class MainSplitViewController: NSSplitViewController, LoginViewControllerDelegate, MatrixSessionManagerDelegate, ConnectionLoadingViewControllerDelegate { 21 | 22 | var loginWindow: NSWindow? 23 | var loadingWindow: NSWindow? 24 | 25 | 26 | override func viewDidLoad() { 27 | super.viewDidLoad() 28 | // Do view setup here. 29 | } 30 | 31 | override func viewDidAppear() { 32 | presentLoginSheetIfNeeded() 33 | } 34 | 35 | func presentLoginSheetIfNeeded() { 36 | 37 | if MatrixSessionManager.shared.state == .notStarted { 38 | self.showLoadingWindow() 39 | MatrixSessionManager.shared.start() 40 | } else if MatrixSessionManager.shared.state == .needsCredentials, 41 | let loginWindowController = self.storyboard?.instantiateController(withIdentifier: "LoginSheet") as? NSWindowController, 42 | let loginViewController = loginWindowController.contentViewController as? LoginViewController, 43 | let loginWindow = loginWindowController.window, 44 | let mainWindow = self.view.window { 45 | 46 | loginViewController.delegate = self 47 | 48 | loginWindow.preventsApplicationTerminationWhenModal = false 49 | 50 | mainWindow.beginSheet(loginWindow, completionHandler: nil) 51 | self.loginWindow = loginWindow 52 | } 53 | } 54 | 55 | 56 | func loginViewController(_ sender: LoginViewController, didLoginWith credentials: MXCredentials) { 57 | guard let loginWindow = loginWindow else { return } 58 | view.window?.endSheet(loginWindow) 59 | 60 | MatrixSessionManager.shared.credentials = credentials 61 | self.showLoadingWindow() 62 | MatrixSessionManager.shared.start() 63 | } 64 | 65 | func logout(_ sender: Any? = nil) { 66 | MatrixSessionManager.shared.logout() 67 | } 68 | 69 | func matrixDidStart(_ session: MXSession) { 70 | self.dismissLoadingWindow() 71 | } 72 | func matrixDidLogout() { 73 | self.presentLoginSheetIfNeeded() 74 | } 75 | 76 | 77 | 78 | func showLoadingWindow() { 79 | guard 80 | let windowController = self.storyboard?.instantiateController(withIdentifier: "ConnectionLoadingWindowController") as? NSWindowController, 81 | let connectionLoadingViewController = windowController.contentViewController as? ConnectionLoadingViewController, 82 | let window = windowController.window 83 | else { return } 84 | 85 | connectionLoadingViewController.urlAddress = MatrixSessionManager.shared.credentials?.homeServer ?? "(unknown)" 86 | connectionLoadingViewController.delegate = self 87 | loadingWindow = window 88 | self.view.window?.beginSheet(window, completionHandler: nil) 89 | } 90 | 91 | func dismissLoadingWindow() { 92 | guard let loadingWindow = self.loadingWindow else { return } 93 | self.view.window?.endSheet(loadingWindow) 94 | self.loadingWindow = nil 95 | } 96 | 97 | func connectionLoadingViewControllerDidClickCancel(_ sender: ConnectionLoadingViewController) { 98 | MatrixSessionManager.shared.logout() 99 | dismissLoadingWindow() 100 | presentLoginSheetIfNeeded() 101 | } 102 | } 103 | 104 | 105 | protocol ConnectionLoadingViewControllerDelegate : class { 106 | func connectionLoadingViewControllerDidClickCancel(_ sender: ConnectionLoadingViewController) 107 | } 108 | 109 | class ConnectionLoadingViewController : NSViewController { 110 | weak var delegate: ConnectionLoadingViewControllerDelegate? 111 | 112 | var urlAddress: String = "" { 113 | didSet { urlAddressLabel?.stringValue = urlAddress } 114 | } 115 | @IBOutlet weak var urlAddressLabel: NSTextField! 116 | @IBOutlet weak var progressIndicator: NSProgressIndicator! 117 | 118 | override func viewDidLoad() { 119 | super.viewDidLoad() 120 | urlAddressLabel.stringValue = urlAddress 121 | progressIndicator.startAnimation(nil) 122 | } 123 | 124 | @IBAction func cancel(_ sender: NSButton! = nil) { 125 | delegate?.connectionLoadingViewControllerDidClickCancel(self) 126 | } 127 | } 128 | -------------------------------------------------------------------------------- /MatrixClient/MainWindowController.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Avery Pierce 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | import Cocoa 18 | 19 | class MainWindowController: NSWindowController { 20 | 21 | override func windowDidLoad() { 22 | super.windowDidLoad() 23 | 24 | // Implement this method to handle any initialization after your window controller's window has been loaded from its nib file. 25 | window?.titlebarAppearsTransparent = true; 26 | window?.titleVisibility = .hidden 27 | window?.styleMask.insert(.fullSizeContentView) 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /MatrixClient/MatrixExtensions.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Avery Pierce 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | import Foundation 18 | import SwiftMatrixSDK 19 | 20 | extension URL { 21 | func resolvingMatrixUrl() -> URL { 22 | 23 | if let urlString = MatrixSessionManager.shared.session?.matrixRestClient?.url(ofContent: self.absoluteString), 24 | let url = URL(string: urlString) { 25 | 26 | return url 27 | } else { 28 | return self 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /MatrixClient/RoomManagement.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 80 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 171 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | -------------------------------------------------------------------------------- /MatrixClient/RoundedColorView.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Avery Pierce 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | import Cocoa 18 | 19 | class RoundedColorView: RoundedCornerView { 20 | 21 | @IBInspectable public var backgroundColor: NSColor = .white 22 | 23 | override func draw(_ dirtyRect: NSRect) { 24 | super.draw(dirtyRect) 25 | 26 | // Fill the background 27 | backgroundColor.setFill() 28 | NSRectFill(dirtyRect) 29 | } 30 | } 31 | 32 | class RoundedCornerView : NSView { 33 | @IBInspectable public var borderWidth: CGFloat = 0.0 34 | @IBInspectable public var borderColor: NSColor = .black 35 | @IBInspectable public var cornerRadius: CGFloat = 0.0 36 | 37 | override func awakeFromNib() { 38 | self.wantsLayer = true 39 | self.layer?.cornerRadius = cornerRadius 40 | self.layer?.borderWidth = borderWidth 41 | self.layer?.borderColor = borderColor.cgColor 42 | } 43 | } 44 | 45 | class DropShadowView : RoundedCornerView { 46 | @IBInspectable public var shadowOffsetX: CGFloat = 0.0 47 | @IBInspectable public var shadowOffsetY: CGFloat = 0.0 48 | @IBInspectable public var shadowRadius: CGFloat = 0.0 49 | @IBInspectable public var shadowColor: NSColor = .black 50 | @IBInspectable public var shadowOpacity: Float = 0.0 51 | 52 | override func awakeFromNib() { 53 | super.awakeFromNib() 54 | 55 | self.layer?.shadowOffset = CGSize(width: shadowOffsetX, height: shadowOffsetY * -1) 56 | self.layer?.shadowRadius = shadowRadius 57 | self.layer?.shadowColor = shadowColor.cgColor 58 | self.layer?.shadowOpacity = shadowOpacity 59 | self.layer?.masksToBounds = false 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /MatrixClient/SidebarController.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Avery Pierce 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | import Cocoa 18 | import SwiftMatrixSDK 19 | 20 | class RoomCellView : NSTableCellView { 21 | @IBOutlet weak var titleTextField: NSTextField! 22 | @IBOutlet weak var detailTextField: NSTextField! 23 | @IBOutlet weak var thumbnailImageView: NSImageView? 24 | 25 | override var backgroundStyle: NSBackgroundStyle { 26 | didSet { 27 | switch backgroundStyle { 28 | case .dark: 29 | titleTextField.textColor = .white 30 | detailTextField.textColor = .white 31 | default: 32 | titleTextField.textColor = .black 33 | detailTextField.textColor = .darkGray 34 | } 35 | } 36 | } 37 | } 38 | 39 | @objc protocol RoomChangedDelegate : class { 40 | func roomChanger(_ changer: SidebarController, setRoom room: MXRoom) 41 | } 42 | 43 | class SidebarController: NSViewController, NSOutlineViewDataSource, NSOutlineViewDelegate, MatrixSessionManagerDelegate, CreateRoomViewControllerDelegate, JoinRoomViewControllerDelegate, NSMenuDelegate { 44 | 45 | @IBOutlet weak var outlineView: NSOutlineView! 46 | weak var roomChangedDelegate: RoomChangedDelegate? 47 | 48 | enum Section { 49 | case rooms 50 | } 51 | 52 | var sections: [Section] = [.rooms] 53 | var rooms: [MXRoom] = [] 54 | 55 | override func viewDidLoad() { 56 | super.viewDidLoad() 57 | // Do view setup here. 58 | 59 | self.outlineView.expandItem(Section.rooms) 60 | } 61 | 62 | 63 | func matrixDidStart(_ session: MXSession) { 64 | self.rooms = session.rooms 65 | outlineView.reloadData() 66 | } 67 | 68 | func matrixDidLogout() { 69 | self.rooms = [] 70 | outlineView.reloadData() 71 | } 72 | 73 | 74 | 75 | 76 | func outlineView(_ outlineView: NSOutlineView, numberOfChildrenOfItem item: Any?) -> Int { 77 | print("number of children") 78 | guard let section = item as? Section else { return sections.count } 79 | 80 | switch section { 81 | case .rooms: 82 | return rooms.count 83 | } 84 | } 85 | 86 | 87 | 88 | func outlineView(_ outlineView: NSOutlineView, isItemExpandable item: Any) -> Bool { 89 | // Only section items are expandable 90 | return item is Section 91 | } 92 | 93 | func outlineView(_ outlineView: NSOutlineView, child index: Int, ofItem item: Any?) -> Any { 94 | guard let section = item as? Section else { return sections[index] } 95 | 96 | switch section { 97 | case .rooms: 98 | return rooms[index] 99 | } 100 | } 101 | 102 | func outlineView(_ outlineView: NSOutlineView, viewFor tableColumn: NSTableColumn?, item: Any) -> NSView? { 103 | 104 | let cellView: NSTableCellView? 105 | 106 | switch item { 107 | case let item as Section: 108 | cellView = outlineView.make(withIdentifier: "HeaderCell", owner: self) as? NSTableCellView 109 | switch item { 110 | case .rooms: 111 | cellView?.textField?.stringValue = "ROOMS" 112 | } 113 | case let item as MXRoom: 114 | let roomCellView = outlineView.make(withIdentifier: "DataCell", owner: self) as? RoomCellView 115 | 116 | roomCellView?.detailTextField?.stringValue = item.state.canonicalAlias ?? item.state.roomId 117 | roomCellView?.titleTextField?.stringValue = item.state.name ?? item.state.canonicalAlias ?? "Unnamed Room" 118 | 119 | if let avatarString = item.state.avatar, 120 | let avatarUrl = URL(string: avatarString)?.resolvingMatrixUrl() { 121 | 122 | ImageProvider().image(for: avatarUrl, completion: { (response) in 123 | roomCellView?.thumbnailImageView?.image = response.value 124 | }) 125 | } 126 | 127 | cellView = roomCellView 128 | default: 129 | cellView = outlineView.make(withIdentifier: "DataCell", owner: item) as? NSTableCellView 130 | } 131 | 132 | return cellView 133 | } 134 | 135 | func outlineView(_ outlineView: NSOutlineView, heightOfRowByItem item: Any) -> CGFloat { 136 | switch item { 137 | case _ where item is Section: 138 | return 17 139 | case _ where item is MXRoom: 140 | return 38 141 | default: 142 | return 17 143 | } 144 | } 145 | 146 | 147 | func outlineView(_ outlineView: NSOutlineView, shouldSelectItem item: Any) -> Bool { 148 | guard let room = item as? MXRoom else { return false } 149 | roomChangedDelegate?.roomChanger(self, setRoom: room) 150 | return true 151 | } 152 | 153 | 154 | 155 | // MARK: - Create Room Sheet 156 | 157 | @IBAction func createRoom(_ sender: NSButton? = nil) { 158 | 159 | // Initialize the create room sheet, and become its delegate 160 | let roomStoryboard = NSStoryboard(name: "RoomManagement", bundle: nil) 161 | guard 162 | let parentWindow = self.view.window, 163 | let roomWindowController = roomStoryboard.instantiateController(withIdentifier: "CreateRoomWindowController") as? NSWindowController, 164 | let roomWindow = roomWindowController.window, 165 | let roomViewController = roomWindowController.contentViewController as? CreateRoomViewController 166 | else { return } 167 | roomViewController.delegate = self 168 | 169 | // Present the create room sheet 170 | parentWindow.beginSheet(roomWindow, completionHandler: nil) 171 | } 172 | 173 | 174 | func createRoomViewControllerDidCancel(_ sender: CreateRoomViewController) { 175 | if let sheetWindow = sender.view.window { 176 | self.view.window?.endSheet(sheetWindow) 177 | } 178 | } 179 | 180 | func createRoomViewControllerDidSubmit(_ sender: CreateRoomViewController) { 181 | MatrixSessionManager.shared.session?.createRoom(name: sender.roomName, visibility: sender.roomVisibility, alias: sender.roomAlias, topic: nil, preset: .publicChat) { response in 182 | switch response { 183 | case .success(let room): 184 | self.rooms.append(room) 185 | guard let index = self.rooms.index(of: room) else { return } 186 | self.outlineView.insertItems(at: IndexSet(integer: index), inParent: Section.rooms, withAnimation: NSTableViewAnimationOptions.slideLeft) 187 | default: break 188 | } 189 | 190 | if let sheetWindow = sender.view.window { 191 | self.view.window?.endSheet(sheetWindow) 192 | } 193 | } 194 | } 195 | 196 | 197 | 198 | @IBAction func leaveRoom(_ sender: Any) { 199 | guard let room = self.outlineView.item(atRow: outlineView.clickedRow) as? MXRoom else { return } 200 | MatrixSessionManager.shared.session?.leaveRoom(room.roomId) { response in 201 | guard response.isSuccess else { return } 202 | 203 | // Get the index of this room and remove it from the list 204 | guard let roomIndex = self.rooms.index(of: room) else { return } 205 | self.rooms.remove(at: roomIndex) 206 | self.outlineView.removeItems(at: IndexSet(integer: roomIndex), inParent: Section.rooms, withAnimation: .slideLeft) 207 | } 208 | } 209 | 210 | // MARK: - Join Room Sheet 211 | 212 | @IBAction func joinRoom(_ sender: NSButton? = nil) { 213 | 214 | // Initialize the join room sheet, and become its delegate 215 | let roomStoryboard = NSStoryboard(name: "RoomManagement", bundle: nil) 216 | guard 217 | let parentWindow = self.view.window, 218 | let roomWindowController = roomStoryboard.instantiateController(withIdentifier: "JoinRoomWindowController") as? NSWindowController, 219 | let roomWindow = roomWindowController.window, 220 | let roomViewController = roomWindowController.contentViewController as? JoinRoomViewController 221 | else { return } 222 | roomViewController.delegate = self 223 | 224 | // Present the create room sheet 225 | parentWindow.beginSheet(roomWindow, completionHandler: nil) 226 | 227 | } 228 | 229 | func joinRoomViewControllerDidCancel(_ sender: JoinRoomViewController) { 230 | if let sheetWindow = sender.view.window { 231 | self.view.window?.endSheet(sheetWindow) 232 | } 233 | } 234 | 235 | 236 | func joinRoomViewControllerDidSubmit(_ sender: JoinRoomViewController) { 237 | MatrixSessionManager.shared.session?.joinRoom(sender.roomIdOrAlias) { response in 238 | 239 | switch response { 240 | case .success(let room): 241 | self.rooms.append(room) 242 | guard let index = self.rooms.index(of: room) else { return } 243 | self.outlineView.insertItems(at: IndexSet(integer: index), inParent: Section.rooms, withAnimation: .slideLeft) 244 | case .failure: break 245 | } 246 | 247 | if let sheetWindow = sender.view.window { 248 | self.view.window?.endSheet(sheetWindow) 249 | } 250 | } 251 | } 252 | 253 | } 254 | -------------------------------------------------------------------------------- /MatrixClient/ViewController.swift: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright 2017 Avery Pierce 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | */ 16 | 17 | import Cocoa 18 | import SwiftMatrixSDK 19 | 20 | extension NSTextField { 21 | func height(forWidth width: CGFloat) -> CGFloat { 22 | return stringValue.height(forWidth: width, withFont: self.font) 23 | } 24 | } 25 | 26 | extension String { 27 | func height(forWidth width: CGFloat, withFont font: NSFont!) -> CGFloat { 28 | let size = CGSize(width: width, height: 0) 29 | let attributes = [NSFontAttributeName: font] 30 | let boundingRect = (self as NSString).boundingRect(with: size, options: [.usesLineFragmentOrigin, .usesFontLeading], attributes: attributes) 31 | return boundingRect.height 32 | } 33 | } 34 | 35 | 36 | extension Array { 37 | 38 | func filterDuplicates(includeElement: (_ lhs:Element, _ rhs:Element) -> Bool) -> [Element]{ 39 | var results = [Element]() 40 | 41 | forEach { (element) in 42 | let existingElements = results.filter { 43 | return includeElement(element, $0) 44 | } 45 | if existingElements.count == 0 { 46 | results.append(element) 47 | } 48 | } 49 | 50 | return results 51 | } 52 | } 53 | 54 | @objc protocol RoomFetchDelegate : class { 55 | func roomFetcher(_ fetcher: ViewController, didFetch rooms: [MXRoom]) 56 | } 57 | 58 | class MatrixMessage : NSObject { 59 | var event: MXEvent 60 | 61 | var text: String { return (event.content["body"] as? String) ?? "" } 62 | var sender: String { return event.sender } 63 | var age: UInt64 { return event.ageLocalTs } 64 | 65 | var id: String { return event.eventId } 66 | 67 | init(event: MXEvent) { 68 | self.event = event 69 | } 70 | } 71 | 72 | class MessageCellView : NSTableCellView { 73 | @IBOutlet weak var messageLabel: NSTextField! 74 | @IBOutlet weak var senderLabel: NSTextField? 75 | @IBOutlet weak var dateLabel: NSTextField! 76 | @IBOutlet weak var avatarImageView: NSImageView? 77 | 78 | override func awakeFromNib() { 79 | self.wantsLayer = true 80 | self.layer?.masksToBounds = false 81 | } 82 | } 83 | 84 | class ViewController: NSViewController, RoomChangedDelegate, MatrixSessionManagerDelegate, NSTableViewDelegate, NSTableViewDataSource, NSTextViewDelegate { 85 | 86 | @IBOutlet weak var scrollView: NSScrollView! 87 | @IBOutlet weak var tableView: NSTableView! 88 | @IBOutlet weak var messageTextView: NSTextView! 89 | @IBOutlet weak var messageTextViewVerticalSizeConstraint: NSLayoutConstraint! 90 | @IBOutlet weak var titleLabel: NSTextField! 91 | 92 | var currentRoom: MXRoom? 93 | var imageProvider: ImageProvider = ImageProvider() 94 | 95 | private var sortedRoomMessages = [MatrixMessage]() 96 | var roomMessages: [MatrixMessage] { 97 | get { return sortedRoomMessages } 98 | set { 99 | let deDupedMessages = newValue.filterDuplicates { return $0.id == $1.id } 100 | sortedRoomMessages = deDupedMessages.sorted(by: { return $0.age < $1.age }) 101 | } 102 | } 103 | 104 | 105 | override func viewDidLoad() { 106 | super.viewDidLoad() 107 | 108 | if let sideBarController = self.parent?.childViewControllers.flatMap({ return $0 as? SidebarController }).first { 109 | sideBarController.roomChangedDelegate = self 110 | } 111 | 112 | tableView.tableColumns.first?.width = tableView.bounds.width 113 | tableView.rowHeight = 60; 114 | 115 | titleLabel.stringValue = "" 116 | 117 | reloadContentInsets() 118 | } 119 | 120 | func reloadContentInsets() { 121 | tableView.enclosingScrollView?.contentInsets.bottom = messageTextViewVerticalSizeConstraint.constant + 16 122 | tableView.enclosingScrollView?.contentInsets.top = 60 123 | } 124 | 125 | 126 | func matrixDidStart(_ session: MXSession) { 127 | 128 | } 129 | 130 | func matrixDidLogout() { 131 | roomMessages = [] 132 | currentRoom?.liveTimeline.removeAllListeners() 133 | currentRoom = nil 134 | 135 | tableView.reloadData() 136 | } 137 | 138 | 139 | func roomChanger(_ changer: SidebarController, setRoom room: MXRoom) { 140 | currentRoom = room 141 | titleLabel.stringValue = room.state.name ?? room.state.canonicalAlias ?? "Unnamed Room" 142 | 143 | print("Listening to \(room.roomId)") 144 | sortedRoomMessages = [] 145 | tableView.reloadData() 146 | 147 | room.liveTimeline.resetPagination() 148 | _ = room.liveTimeline.listenToEvents([.roomMessage]) { (event, direction, roomState) in 149 | 150 | // Check to see if the scroll view is scrolled to the bottom 151 | self.roomMessages.append(MatrixMessage(event: event)) 152 | self.tableView.reloadData() 153 | self.scrollView.documentView?.scrollToEndOfDocument(self) 154 | } 155 | 156 | _ = room.liveTimeline.listenToEvents([.typing]) { (event, direction, roomState) in 157 | 158 | let typingUsers = room.typingUsers ?? [] 159 | if typingUsers.count > 0 { 160 | 161 | } else { 162 | 163 | } 164 | } 165 | 166 | _ = room.liveTimeline.listenToEvents { (event, direction, roomState) in 167 | print(event) 168 | } 169 | 170 | room.liveTimeline.paginate(10, direction: .backwards, onlyFromStore: false) { response in 171 | 172 | } 173 | 174 | room.state.members.forEach { (member) in 175 | print(member.displayname ?? member.userId) 176 | } 177 | } 178 | 179 | override var representedObject: Any? { 180 | didSet { 181 | // Update the view, if already loaded. 182 | } 183 | } 184 | 185 | 186 | 187 | 188 | 189 | func submitMessage() { 190 | guard let stringValue = messageTextView.string else { return } 191 | messageTextView.textStorage?.mutableString.setString("") 192 | 193 | guard let room = currentRoom else { return } 194 | room.mxSession.matrixRestClient.sendTextMessage(toRoom: room.roomId, text: stringValue) { (response) in 195 | switch response { 196 | case .success: 197 | print("Go") 198 | case .failure: 199 | print("Fail") 200 | } 201 | } 202 | } 203 | 204 | 205 | override func viewDidLayout() { 206 | self.tableView.reloadData() 207 | } 208 | 209 | 210 | // MARK: - NSTableViewDatasource 211 | 212 | func numberOfRows(in tableView: NSTableView) -> Int { 213 | return roomMessages.count 214 | } 215 | 216 | func tableView(_ tableView: NSTableView, objectValueFor tableColumn: NSTableColumn?, row: Int) -> Any? { 217 | return roomMessages[row] 218 | } 219 | 220 | func tableView(_ tableView: NSTableView, viewFor tableColumn: NSTableColumn?, row: Int) -> NSView? { 221 | let message = roomMessages[row] 222 | let previousMessage: MatrixMessage? = (row > 0 ? roomMessages[row-1] : nil) 223 | let myUserId = MatrixSessionManager.shared.session?.matrixRestClient?.credentials?.userId 224 | 225 | let cellIdentifier: String 226 | if message.sender == myUserId { 227 | // This message was sent by the user 228 | cellIdentifier = "SentMessageCell"; 229 | } else if message.sender == previousMessage?.sender { 230 | // This message was received, but the sender is the same as before, 231 | // so we don't need to show the username. 232 | cellIdentifier = "ReceivedMessageCell" 233 | } else { 234 | // This is a different sender from before, so show the username. 235 | cellIdentifier = "ReceivedMessageCellWithSender" 236 | } 237 | 238 | 239 | let cell = tableView.make(withIdentifier: cellIdentifier, owner: self) as? MessageCellView 240 | cell?.messageLabel?.stringValue = message.text 241 | cell?.senderLabel?.stringValue = message.sender 242 | 243 | let date = Date(timeIntervalSince1970: Double(message.age) / 1000) 244 | let dateFormatter = DateFormatter() 245 | if let previousMessage = previousMessage { 246 | let previousDate = Date(timeIntervalSince1970: Double(previousMessage.age) / 1000) 247 | 248 | // If the date changed, show the date and the time. 249 | let dateOnly = DateFormatter() 250 | dateOnly.timeStyle = .none 251 | dateOnly.dateStyle = .short 252 | 253 | let dateTime = DateFormatter() 254 | dateTime.timeStyle = .short 255 | dateTime.dateStyle = .short 256 | 257 | if (dateOnly.string(from: date) != dateOnly.string(from: previousDate)) { 258 | dateFormatter.timeStyle = .short 259 | dateFormatter.dateStyle = .short 260 | } else if (dateTime.string(from: date) != dateTime.string(from: previousDate)) { 261 | dateFormatter.timeStyle = .short 262 | dateFormatter.dateStyle = .none 263 | } else { 264 | dateFormatter.timeStyle = .none 265 | dateFormatter.dateStyle = .none 266 | } 267 | 268 | } else { 269 | dateFormatter.timeStyle = .short 270 | dateFormatter.dateStyle = .short 271 | } 272 | cell?.dateLabel?.stringValue = dateFormatter.string(from: date) 273 | 274 | if let senderUser = MatrixSessionManager.shared.session?.user(withUserId: message.sender), 275 | let avatarUrlString = senderUser.avatarUrl, 276 | let avatarUrl = URL(string: avatarUrlString)?.resolvingMatrixUrl() { 277 | 278 | if let image = imageProvider.cachedImage(for: avatarUrl) { 279 | cell?.avatarImageView?.image = image 280 | } else { 281 | imageProvider.image(for: avatarUrl) { response in 282 | switch response { 283 | case .success(let image): 284 | 285 | // The cell might have moved. Make sure we're accessing the right cell. 286 | let cell = tableView.view(atColumn: 0, row: row, makeIfNecessary: false) as? MessageCellView 287 | cell?.avatarImageView?.image = image 288 | 289 | default: break 290 | } 291 | } 292 | } 293 | } 294 | 295 | return cell 296 | } 297 | 298 | func tableView(_ tableView: NSTableView, heightOfRow row: Int) -> CGFloat { 299 | let message = roomMessages[row] 300 | let previousMessage: MatrixMessage? = (row > 0 ? roomMessages[row-1] : nil) 301 | let myUserId = MatrixSessionManager.shared.session?.matrixRestClient?.credentials?.userId 302 | 303 | let maxMessageWidth = tableView.bounds.width - 100 /* The left margin of the bubble */ - 21 /* The margin around the text */ - 3 /* ??? */; 304 | 305 | let font = NSFont.systemFont(ofSize: NSFont.systemFontSize()) 306 | let textHeight = message.text.height(forWidth: maxMessageWidth, withFont: font) 307 | 308 | let cellHeight: CGFloat 309 | if message.sender != previousMessage?.sender && message.sender != myUserId { 310 | cellHeight = textHeight + 8 + 15 311 | } else { 312 | cellHeight = textHeight + 8 313 | } 314 | 315 | return cellHeight 316 | } 317 | 318 | 319 | 320 | 321 | 322 | 323 | func textDidEndEditing(_ notification: Notification) { 324 | Swift.print("Did End editing: \(notification)") 325 | // Check to see if this was a return key press 326 | if (notification.userInfo?["NSTextMovement"] as? Int) == NSReturnTextMovement { 327 | submitMessage() 328 | messageTextView.window?.makeFirstResponder(messageTextView) 329 | } 330 | } 331 | 332 | func textDidChange(_ notification: Notification) { 333 | 334 | guard 335 | let textContainer = messageTextView.textContainer, 336 | let layoutManager = messageTextView.layoutManager 337 | else { return } 338 | 339 | let height = layoutManager.usedRect(for: textContainer).height 340 | messageTextViewVerticalSizeConstraint.constant = height 341 | reloadContentInsets() 342 | self.view.layout() 343 | } 344 | } 345 | 346 | -------------------------------------------------------------------------------- /MatrixClient/WindowWithDrawer.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /MatrixClientTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /MatrixClientTests/MatrixClientTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MatrixClientTests.swift 3 | // MatrixClientTests 4 | // 5 | // Created by Avery Pierce on 1/14/17. 6 | // Copyright © 2017 Avery Pierce. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | @testable import MatrixClient 11 | 12 | class MatrixClientTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | // Use XCTAssert and related functions to verify your tests produce the correct results. 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measure { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment the next line to define a global platform for your project 2 | # platform :ios, '9.0' 3 | 4 | target 'MatrixClient' do 5 | # Comment the next line if you're not using Swift and don't want to use dynamic frameworks 6 | use_frameworks! 7 | 8 | # Pods for MatrixClient 9 | pod 'OLMKit' 10 | pod 'Realm' 11 | # pod 'MatrixSDK', :path => '../matrix-ios-sdk' 12 | pod 'SwiftMatrixSDK', :git => 'https://github.com/aapierce0/matrix-ios-sdk.git', :commit => 'ae745701478220480a652ce1723c6c40b1c8d769' 13 | # pod 'SwiftMatrixSDK', :path => '../matrix-ios-sdk' 14 | 15 | 16 | end 17 | 18 | -------------------------------------------------------------------------------- /Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - AFNetworking (3.1.0): 3 | - AFNetworking/NSURLSession (= 3.1.0) 4 | - AFNetworking/Reachability (= 3.1.0) 5 | - AFNetworking/Security (= 3.1.0) 6 | - AFNetworking/Serialization (= 3.1.0) 7 | - AFNetworking/UIKit (= 3.1.0) 8 | - AFNetworking/NSURLSession (3.1.0): 9 | - AFNetworking/Reachability 10 | - AFNetworking/Security 11 | - AFNetworking/Serialization 12 | - AFNetworking/Reachability (3.1.0) 13 | - AFNetworking/Security (3.1.0) 14 | - AFNetworking/Serialization (3.1.0) 15 | - OLMKit (2.2.2): 16 | - OLMKit/olmc (= 2.2.2) 17 | - OLMKit/olmcpp (= 2.2.2) 18 | - OLMKit/olmc (2.2.2) 19 | - OLMKit/olmcpp (2.2.2) 20 | - Realm (2.4.4): 21 | - Realm/Headers (= 2.4.4) 22 | - Realm/Headers (2.4.4) 23 | - SwiftMatrixSDK (0.7.9): 24 | - AFNetworking (~> 3.1.0) 25 | 26 | DEPENDENCIES: 27 | - OLMKit 28 | - Realm 29 | - SwiftMatrixSDK (from `https://github.com/aapierce0/matrix-ios-sdk.git`, commit `ae745701478220480a652ce1723c6c40b1c8d769`) 30 | 31 | EXTERNAL SOURCES: 32 | SwiftMatrixSDK: 33 | :commit: ae745701478220480a652ce1723c6c40b1c8d769 34 | :git: https://github.com/aapierce0/matrix-ios-sdk.git 35 | 36 | CHECKOUT OPTIONS: 37 | SwiftMatrixSDK: 38 | :commit: ae745701478220480a652ce1723c6c40b1c8d769 39 | :git: https://github.com/aapierce0/matrix-ios-sdk.git 40 | 41 | SPEC CHECKSUMS: 42 | AFNetworking: 5e0e199f73d8626b11e79750991f5d173d1f8b67 43 | OLMKit: b9d8c0ffee9ea8c45bc0aaa9afb47f93fba7efbd 44 | Realm: 5a280a1f5a9a3c267bebf4f41ee47911137703d7 45 | SwiftMatrixSDK: 2eb7cf817445f02f5ab5bc056813d2b4a7652f75 46 | 47 | PODFILE CHECKSUM: fe48fff2ec41463c2da90c044e97fdf3c2ce410e 48 | 49 | COCOAPODS: 1.2.0 50 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Matrix Client for macOS (working title) 2 | ======================================= 3 | 4 | This application is still in very early development. 5 | 6 | ![Screenshot](http://i.imgur.com/X1AUxHa.png) 7 | 8 | Build and run 9 | ------------- 10 | 11 | 1. [Install cocoapods](https://cocoapods.org) 12 | 2. `pod install` in the project directory 13 | 3. Open the newly created `*.xcworkspace` file in Xcode 14 | 4. Product > Run (cmd-R) 15 | --------------------------------------------------------------------------------