├── .gitignore ├── .travis.yml ├── Doc_Changelog.md ├── LICENSE ├── Migration Guide.md ├── OCCommunicationLib ├── OCCommunicationLib │ ├── ExternalLibs │ │ └── AFNetworking │ │ │ ├── AFHTTPSessionManager.h │ │ │ ├── AFHTTPSessionManager.m │ │ │ ├── AFNetworkReachabilityManager.h │ │ │ ├── AFNetworkReachabilityManager.m │ │ │ ├── AFNetworking.h │ │ │ ├── AFSecurityPolicy.h │ │ │ ├── AFSecurityPolicy.m │ │ │ ├── AFURLRequestSerialization.h │ │ │ ├── AFURLRequestSerialization.m │ │ │ ├── AFURLResponseSerialization.h │ │ │ ├── AFURLResponseSerialization.m │ │ │ ├── AFURLSessionManager.h │ │ │ └── AFURLSessionManager.m │ ├── OCCapabilities.h │ ├── OCCapabilities.m │ ├── OCCommunication.h │ ├── OCCommunication.m │ ├── OCCredentialsDto.h │ ├── OCCredentialsDto.m │ ├── OCErrorMsg.h │ ├── OCFileDto.h │ ├── OCFileDto.m │ ├── OCFrameworkConstants.h │ ├── OCOAuth2Authentication │ │ ├── OCCredentialsStorage.h │ │ ├── OCOAuth2Configuration.h │ │ ├── OCOAuth2Configuration.m │ │ ├── OCOAuth2Manager.h │ │ └── OCOAuth2Manager.m │ ├── OCServerFeatures.h │ ├── OCServerFeatures.m │ ├── OCShareUser.h │ ├── OCShareUser.m │ ├── OCSharedDto.h │ ├── OCSharedDto.m │ ├── OCTrustedCertificatesStore.h │ ├── OCWebDavClient │ │ ├── NSDate+ISO8601.h │ │ ├── NSDate+ISO8601.m │ │ ├── NSDate+RFC1123.h │ │ ├── NSDate+RFC1123.m │ │ ├── OCWebDAVClient.h │ │ ├── OCWebDAVClient.m │ │ └── Parsers │ │ │ ├── OCXMLParser.h │ │ │ ├── OCXMLParser.m │ │ │ ├── OCXMLServerErrorsParser.h │ │ │ ├── OCXMLServerErrorsParser.m │ │ │ ├── OCXMLShareByLinkParser.h │ │ │ ├── OCXMLShareByLinkParser.m │ │ │ ├── OCXMLSharedParser.h │ │ │ └── OCXMLSharedParser.m │ ├── Resources │ │ ├── test.jpeg │ │ └── video.MOV │ ├── UploadSupport │ │ ├── OCChunkDto.h │ │ ├── OCChunkDto.m │ │ ├── OCURLSessionUploadTask.h │ │ └── OCURLSessionUploadTask.m │ ├── Utils │ │ ├── NSString+Encode.h │ │ ├── NSString+Encode.m │ │ ├── OCConstants.h │ │ ├── UtilsFramework.h │ │ └── UtilsFramework.m │ └── ownCloud iOS library-Prefix.pch ├── OCCommunicationLibTests │ ├── ConfigTests.h │ ├── OCCommunicationLibTests.h │ ├── OCCommunicationLibTests.m │ ├── en.lproj │ │ └── InfoPlist.strings │ └── ownCloud iOS libraryTests-Info.plist └── ownCloud iOS library.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ └── contents.xcworkspacedata │ ├── xcshareddata │ └── xcschemes │ │ └── ownCloud iOS library.xcscheme │ └── xcuserdata │ └── Gonzalo.xcuserdatad │ ├── xcdebugger │ └── Breakpoints_v2.xcbkptlist │ └── xcschemes │ └── xcschememanagement.plist ├── OCLibraryExample ├── OCLibraryExample.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ ├── xcshareddata │ │ │ └── OCLibraryExample.xccheckout │ │ └── xcuserdata │ │ │ └── Gonzalo.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── xcuserdata │ │ └── Gonzalo.xcuserdatad │ │ └── xcschemes │ │ ├── OCLibraryExample.xcscheme │ │ └── xcschememanagement.plist ├── OCLibraryExample │ ├── .DS_Store │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Base.lproj │ │ ├── Main_iPad.storyboard │ │ └── Main_iPhone.storyboard │ ├── Images.xcassets │ │ ├── AppIcon.appiconset │ │ │ └── Contents.json │ │ └── LaunchImage.launchimage │ │ │ └── Contents.json │ ├── OCLibraryExample-Info.plist │ ├── OCLibraryExample-Prefix.pch │ ├── Resources │ │ └── image_to_upload.jpg │ ├── ViewController.h │ ├── ViewController.m │ ├── en.lproj │ │ └── InfoPlist.strings │ └── main.m └── OCLibraryExampleTests │ ├── OCLibraryExampleTests-Info.plist │ ├── OCLibraryExampleTests.m │ └── en.lproj │ └── InfoPlist.strings └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | .DS_Store 3 | */build/* 4 | _build/ 5 | *.pbxuser 6 | !default.pbxuser 7 | *.mode1v3 8 | !default.mode1v3 9 | *.mode2v3 10 | !default.mode2v3 11 | *.perspectivev3 12 | !default.perspectivev3 13 | xcuserdata 14 | profile 15 | *.moved-aside 16 | DerivedData 17 | .idea/ 18 | *.hmap 19 | *.xccheckout 20 | *.pyc 21 | xcshareddata/ 22 | 23 | #CocoaPods 24 | Pods 25 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: objective-c 2 | osx_image: xcode8.3 3 | #xcode_project: OCCommunicationLib/ownCloud iOS library.xcodeproj 4 | #xcode_scheme: ownCloud iOS library 5 | #xcode_sdk: iphonesimulator 6 | 7 | script: 8 | - set -o pipefail && xcodebuild -project 'OCCommunicationLib/ownCloud iOS library.xcodeproj' -scheme 'ownCloud iOS library' -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 7,OS=10.0' clean test build | xcpretty -c 9 | #- xctool test -project 'OCCommunicationLib/ownCloud iOS library.xcodeproj' -scheme 'ownCloud iOS library' -sdk iphonesimulator -UseSanitizedBuildSystemEnvironment=YES 10 | 11 | before_install: 12 | - brew update; brew update 13 | - echo "#define k_base_url @\"$baseUrlTravis\"" > OCCommunicationLib/OCCommunicationLibTests/ConfigTests.h 14 | - echo "#define k_webdav_base_url @\"$webdavBaseUrlTravis\"" >> OCCommunicationLib/OCCommunicationLibTests/ConfigTests.h 15 | - echo "#define k_user @\"$userTravis\"" >> OCCommunicationLib/OCCommunicationLibTests/ConfigTests.h 16 | - echo "#define k_password @\"$passwordTravis\"" >> OCCommunicationLib/OCCommunicationLibTests/ConfigTests.h 17 | - echo "#define k_path_test_folder @\"$(date +%s)\"" >> OCCommunicationLib/OCCommunicationLibTests/ConfigTests.h 18 | - echo "#define k_user_to_share @\"$userToShareTravis\"" >> OCCommunicationLib/OCCommunicationLibTests/ConfigTests.h 19 | - echo "#define k_group_to_share @\"$groupToShareTravis\"" >> OCCommunicationLib/OCCommunicationLibTests/ConfigTests.h 20 | - echo "#define k_remote_user_to_share @\"$remoteUserToShareTravis\"" >> OCCommunicationLib/OCCommunicationLibTests/ConfigTests.h 21 | -------------------------------------------------------------------------------- /Doc_Changelog.md: -------------------------------------------------------------------------------- 1 | ## What's new in 2.2.1 version 2 | - Bug fixed possible crash 3 | 4 | ## 2.2.0 version 5 | - Added OAuth2 support with automatic refresh of new tokens 6 | - Added support to new public share link option that allows you to share a folder with only the option of uploading files to it 7 | - Added methods to get user data and features supported by server 8 | - Fix updating share link permissions 9 | - Improved cookies handling 10 | - Improved OCErrors 11 | - Updated travis file 12 | 13 | 14 | ## 2.1.0 version 15 | - Added support multiple share links 16 | - Added new method to get supported server features by version 17 | - Improve error handling 18 | - Update user endpoint 19 | - Update travis file 20 | 21 | 22 | ## 2.0.3 version 23 | - Added specific error code for maintenance mode 24 | - Added specific error code for quota excess 25 | - Improved recognition of SAML expiration 26 | - Improved handling of cookies in HEAD requests 27 | 28 | ## 2.0.2 version 29 | - Updated travis validation 30 | 31 | ## 2.0.1 version 32 | - Updated Copyright, Xcode8 and iOS10 support 33 | 34 | ## 2.0.0 version 35 | 36 | - Updated AFNetworking library v3.1.0 37 | - All the network request made using NSOperation was modified to use NSURLSession 38 | - The ownCloud library it is ready to be used on Apple TV and Apple Watch 39 | - The download and upload now return the NSURLSessionTask to be canceled instead the NSOperation 40 | - Updated share parser 41 | 42 | 43 | ## 1.2.1 version 44 | 45 | - Added support to get remote thumbnails for images and videos 46 | - Added auto-complete of external users when you share (this relies on defining remote trusted servers) 47 | - Added support to allow editing permission when sharing a folder by link 48 | - Changes in AFNetworking security policy to request accept new certificate after updating it 49 | 50 | 51 | ## 1.2.0 version 52 | 53 | - Improved the search of users and groups for the internal share 54 | - Added support to share with all types of sharees (user, group, public share,federated sharing ); taking advantage of the shareType 55 | - Support to manage internal share privileges 56 | - Added the possibility to detect a redirected server on all the requests 57 | - Added support for ownCloud 9 58 | - Added new tests for share and capabilities 59 | 60 | 61 | ## 1.1.5 version 62 | 63 | - Added support to work with Sharee API (New server API from version 8.2 to manage users and groups) 64 | 65 | + Update the method "- (void) hasServerShareSupport:..." in order to get also if the server support "sharee api". Now the method is called "- (void) hasServerShareAndShareeSupport:..." and return in the block "BOOL hasShareSupport, BOOL hasShareeSupport" boolean properties. 66 | + Search users and groups. New method that return a list of "OCShareUser" objects using a search string: "- (void) searchUsersAndGroupsWith...". Used to get lists of users and group in order to share files or folders with them using the new "shareWith" method. 67 | + New object class called "OCShareUser" that it used to store users or groups. 68 | + New method share with users: "- (void)shareWith:...". Using the name property of the OCShare object you can share file or folders with users or groups. 69 | 70 | - Updated AFNetworking library v2.6.0 71 | 72 | - Modified security policy properties to fix some issues with requests that were canceled after a while using self signed servers. 73 | 74 | 75 | ## 1.1.4 version 76 | 77 | Added token support in read folder method for multiaccount. In order to differenciate the user account in the response from the server side we have added token support, for the moment only in the readFolder method. 78 | 79 | We have a method in UtilsFramework.h called "getUserSessionToken" to get a unique session id. 80 | 81 | + (NSString *) getUserSessionToken; 82 | 83 | We can use that to send as a parameter on readFolder method. Also if only we have a single account we can use "nil" 84 | 85 | - (void) readFolder: (NSString *) path withUserSessionToken:(NSString *)token 86 | onCommunication:(OCCommunication *)sharedOCCommunication 87 | successRequest:(void(^)(NSHTTPURLResponse *response, NSArray *items, NSString *redirectedServer, NSString *token)) successRequest 88 | failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *token)) failureRequest; 89 | 90 | 91 | ## 1.1.3 version 92 | 93 | From OC 8.1, the server manage the forbbiden characters except the '/'. 94 | 95 | New method to check if the server has forbidden characters support. 96 | - (void) hasServerForbiddenCharactersSupport:(NSString*) path onCommunication:(OCCommunication *)sharedOCCommunication ..... 97 | 98 | We have prepared the current createFolder and moveFileOrFolder methods for do support that. We have added a new BOOL parameter "isFCSupported" using the previews method you can know what is the value of "isFCSupported" 99 | 100 | You can see more specific in OCCommunication class. 101 | 102 | ## Previous versions 103 | 104 | 105 | # Download queue 106 | When we download a file we use a queue in order to download the files one by one. 107 | By default the queue es FIFO. We will download the files in the order that the developer add them. 108 | But if we want to use the queue as LIFO (download first the last file that we add to download) we need to call "setDownloadQueueToLIFO" method 109 | Code example 110 | ~~~~~~~~~~~~ 111 | .. code-block:: objective- c 112 | //Set the downloads with LIFO system 113 | [[AppDelegate sharedOCCommunication] setDownloadQueueToLIFO:YES]; 114 | ç 115 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017 ownCloud (http://www.owncloud.org/) 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. -------------------------------------------------------------------------------- /Migration Guide.md: -------------------------------------------------------------------------------- 1 | # Migration Guide for ownCloud Lib version 1.X to 2.X 2 | 3 | ### Introduction 4 | This document explain how to adapt your application to the new version 2.X of ownCloud Lib. Do not worry, it is too easy! 5 | The ownCloud Lib now use AFNetworking 3.0 in order to be used also on the Apple Watch and on the Apple TV. The main change it is that now we make every network operation using NSURLSession instead NSOperation. 6 | 7 | ### Network Operations 8 | The network operations are: 9 | ##### - Read file or folder 10 | ##### - Create folder 11 | ##### - Move file or folder 12 | ##### - Remove file or folder 13 | ##### - Share file or folder 14 | ##### - Read shares 15 | ##### - Read shares 16 | ##### - Get server features 17 | ##### - Get server capabilities 18 | 19 | On all those methods you just have to change the __NSHTTPURLResponse__ for __NSURLResponse__ on the response blocks. 20 | 21 | ### Downloads and Uploads Operations 22 | Here we have 2 methods for downloads and 2 methods for uploads. One of each one it is for downloades in background and the others are for downloads in foreground. 23 | 24 | The main differences are: 25 | ##### - It is not necessary send the reference of an __NSProgress__ becaue you receive the __NSProgress__ on the progress block. 26 | ##### - You get an NSURLSessionDownloadTask or __NSURLSessionUploadTask__ for background and for foreground a __NSURLSessionTask__. Are cancelable. 27 | ##### - All the parameters are exactly the same. 28 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/ExternalLibs/AFNetworking/AFNetworkReachabilityManager.h: -------------------------------------------------------------------------------- 1 | // AFNetworkReachabilityManager.h 2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | 24 | #if !TARGET_OS_WATCH 25 | #import 26 | 27 | typedef NS_ENUM(NSInteger, AFNetworkReachabilityStatus) { 28 | AFNetworkReachabilityStatusUnknown = -1, 29 | AFNetworkReachabilityStatusNotReachable = 0, 30 | AFNetworkReachabilityStatusReachableViaWWAN = 1, 31 | AFNetworkReachabilityStatusReachableViaWiFi = 2, 32 | }; 33 | 34 | NS_ASSUME_NONNULL_BEGIN 35 | 36 | /** 37 | `AFNetworkReachabilityManager` monitors the reachability of domains, and addresses for both WWAN and WiFi network interfaces. 38 | 39 | Reachability can be used to determine background information about why a network operation failed, or to trigger a network operation retrying when a connection is established. It should not be used to prevent a user from initiating a network request, as it's possible that an initial request may be required to establish reachability. 40 | 41 | See Apple's Reachability Sample Code ( https://developer.apple.com/library/ios/samplecode/reachability/ ) 42 | 43 | @warning Instances of `AFNetworkReachabilityManager` must be started with `-startMonitoring` before reachability status can be determined. 44 | */ 45 | @interface AFNetworkReachabilityManager : NSObject 46 | 47 | /** 48 | The current network reachability status. 49 | */ 50 | @property (readonly, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus; 51 | 52 | /** 53 | Whether or not the network is currently reachable. 54 | */ 55 | @property (readonly, nonatomic, assign, getter = isReachable) BOOL reachable; 56 | 57 | /** 58 | Whether or not the network is currently reachable via WWAN. 59 | */ 60 | @property (readonly, nonatomic, assign, getter = isReachableViaWWAN) BOOL reachableViaWWAN; 61 | 62 | /** 63 | Whether or not the network is currently reachable via WiFi. 64 | */ 65 | @property (readonly, nonatomic, assign, getter = isReachableViaWiFi) BOOL reachableViaWiFi; 66 | 67 | ///--------------------- 68 | /// @name Initialization 69 | ///--------------------- 70 | 71 | /** 72 | Returns the shared network reachability manager. 73 | */ 74 | + (instancetype)sharedManager; 75 | 76 | /** 77 | Creates and returns a network reachability manager with the default socket address. 78 | 79 | @return An initialized network reachability manager, actively monitoring the default socket address. 80 | */ 81 | + (instancetype)manager; 82 | 83 | /** 84 | Creates and returns a network reachability manager for the specified domain. 85 | 86 | @param domain The domain used to evaluate network reachability. 87 | 88 | @return An initialized network reachability manager, actively monitoring the specified domain. 89 | */ 90 | + (instancetype)managerForDomain:(NSString *)domain; 91 | 92 | /** 93 | Creates and returns a network reachability manager for the socket address. 94 | 95 | @param address The socket address (`sockaddr_in6`) used to evaluate network reachability. 96 | 97 | @return An initialized network reachability manager, actively monitoring the specified socket address. 98 | */ 99 | + (instancetype)managerForAddress:(const void *)address; 100 | 101 | /** 102 | Initializes an instance of a network reachability manager from the specified reachability object. 103 | 104 | @param reachability The reachability object to monitor. 105 | 106 | @return An initialized network reachability manager, actively monitoring the specified reachability. 107 | */ 108 | - (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability NS_DESIGNATED_INITIALIZER; 109 | 110 | ///-------------------------------------------------- 111 | /// @name Starting & Stopping Reachability Monitoring 112 | ///-------------------------------------------------- 113 | 114 | /** 115 | Starts monitoring for changes in network reachability status. 116 | */ 117 | - (void)startMonitoring; 118 | 119 | /** 120 | Stops monitoring for changes in network reachability status. 121 | */ 122 | - (void)stopMonitoring; 123 | 124 | ///------------------------------------------------- 125 | /// @name Getting Localized Reachability Description 126 | ///------------------------------------------------- 127 | 128 | /** 129 | Returns a localized string representation of the current network reachability status. 130 | */ 131 | - (NSString *)localizedNetworkReachabilityStatusString; 132 | 133 | ///--------------------------------------------------- 134 | /// @name Setting Network Reachability Change Callback 135 | ///--------------------------------------------------- 136 | 137 | /** 138 | Sets a callback to be executed when the network availability of the `baseURL` host changes. 139 | 140 | @param block A block object to be executed when the network availability of the `baseURL` host changes.. This block has no return value and takes a single argument which represents the various reachability states from the device to the `baseURL`. 141 | */ 142 | - (void)setReachabilityStatusChangeBlock:(nullable void (^)(AFNetworkReachabilityStatus status))block; 143 | 144 | @end 145 | 146 | ///---------------- 147 | /// @name Constants 148 | ///---------------- 149 | 150 | /** 151 | ## Network Reachability 152 | 153 | The following constants are provided by `AFNetworkReachabilityManager` as possible network reachability statuses. 154 | 155 | enum { 156 | AFNetworkReachabilityStatusUnknown, 157 | AFNetworkReachabilityStatusNotReachable, 158 | AFNetworkReachabilityStatusReachableViaWWAN, 159 | AFNetworkReachabilityStatusReachableViaWiFi, 160 | } 161 | 162 | `AFNetworkReachabilityStatusUnknown` 163 | The `baseURL` host reachability is not known. 164 | 165 | `AFNetworkReachabilityStatusNotReachable` 166 | The `baseURL` host cannot be reached. 167 | 168 | `AFNetworkReachabilityStatusReachableViaWWAN` 169 | The `baseURL` host can be reached via a cellular connection, such as EDGE or GPRS. 170 | 171 | `AFNetworkReachabilityStatusReachableViaWiFi` 172 | The `baseURL` host can be reached via a Wi-Fi connection. 173 | 174 | ### Keys for Notification UserInfo Dictionary 175 | 176 | Strings that are used as keys in a `userInfo` dictionary in a network reachability status change notification. 177 | 178 | `AFNetworkingReachabilityNotificationStatusItem` 179 | A key in the userInfo dictionary in a `AFNetworkingReachabilityDidChangeNotification` notification. 180 | The corresponding value is an `NSNumber` object representing the `AFNetworkReachabilityStatus` value for the current reachability status. 181 | */ 182 | 183 | ///-------------------- 184 | /// @name Notifications 185 | ///-------------------- 186 | 187 | /** 188 | Posted when network reachability changes. 189 | This notification assigns no notification object. The `userInfo` dictionary contains an `NSNumber` object under the `AFNetworkingReachabilityNotificationStatusItem` key, representing the `AFNetworkReachabilityStatus` value for the current network reachability. 190 | 191 | @warning In order for network reachability to be monitored, include the `SystemConfiguration` framework in the active target's "Link Binary With Library" build phase, and add `#import ` to the header prefix of the project (`Prefix.pch`). 192 | */ 193 | FOUNDATION_EXPORT NSString * const AFNetworkingReachabilityDidChangeNotification; 194 | FOUNDATION_EXPORT NSString * const AFNetworkingReachabilityNotificationStatusItem; 195 | 196 | ///-------------------- 197 | /// @name Functions 198 | ///-------------------- 199 | 200 | /** 201 | Returns a localized string representation of an `AFNetworkReachabilityStatus` value. 202 | */ 203 | FOUNDATION_EXPORT NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status); 204 | 205 | NS_ASSUME_NONNULL_END 206 | #endif 207 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/ExternalLibs/AFNetworking/AFNetworkReachabilityManager.m: -------------------------------------------------------------------------------- 1 | // AFNetworkReachabilityManager.m 2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import "AFNetworkReachabilityManager.h" 23 | #if !TARGET_OS_WATCH 24 | 25 | #import 26 | #import 27 | #import 28 | #import 29 | #import 30 | 31 | NSString * const AFNetworkingReachabilityDidChangeNotification = @"com.alamofire.networking.reachability.change"; 32 | NSString * const AFNetworkingReachabilityNotificationStatusItem = @"AFNetworkingReachabilityNotificationStatusItem"; 33 | 34 | typedef void (^AFNetworkReachabilityStatusBlock)(AFNetworkReachabilityStatus status); 35 | 36 | NSString * AFStringFromNetworkReachabilityStatus(AFNetworkReachabilityStatus status) { 37 | switch (status) { 38 | case AFNetworkReachabilityStatusNotReachable: 39 | return NSLocalizedStringFromTable(@"Not Reachable", @"AFNetworking", nil); 40 | case AFNetworkReachabilityStatusReachableViaWWAN: 41 | return NSLocalizedStringFromTable(@"Reachable via WWAN", @"AFNetworking", nil); 42 | case AFNetworkReachabilityStatusReachableViaWiFi: 43 | return NSLocalizedStringFromTable(@"Reachable via WiFi", @"AFNetworking", nil); 44 | case AFNetworkReachabilityStatusUnknown: 45 | default: 46 | return NSLocalizedStringFromTable(@"Unknown", @"AFNetworking", nil); 47 | } 48 | } 49 | 50 | static AFNetworkReachabilityStatus AFNetworkReachabilityStatusForFlags(SCNetworkReachabilityFlags flags) { 51 | BOOL isReachable = ((flags & kSCNetworkReachabilityFlagsReachable) != 0); 52 | BOOL needsConnection = ((flags & kSCNetworkReachabilityFlagsConnectionRequired) != 0); 53 | BOOL canConnectionAutomatically = (((flags & kSCNetworkReachabilityFlagsConnectionOnDemand ) != 0) || ((flags & kSCNetworkReachabilityFlagsConnectionOnTraffic) != 0)); 54 | BOOL canConnectWithoutUserInteraction = (canConnectionAutomatically && (flags & kSCNetworkReachabilityFlagsInterventionRequired) == 0); 55 | BOOL isNetworkReachable = (isReachable && (!needsConnection || canConnectWithoutUserInteraction)); 56 | 57 | AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusUnknown; 58 | if (isNetworkReachable == NO) { 59 | status = AFNetworkReachabilityStatusNotReachable; 60 | } 61 | #if TARGET_OS_IPHONE 62 | else if ((flags & kSCNetworkReachabilityFlagsIsWWAN) != 0) { 63 | status = AFNetworkReachabilityStatusReachableViaWWAN; 64 | } 65 | #endif 66 | else { 67 | status = AFNetworkReachabilityStatusReachableViaWiFi; 68 | } 69 | 70 | return status; 71 | } 72 | 73 | /** 74 | * Queue a status change notification for the main thread. 75 | * 76 | * This is done to ensure that the notifications are received in the same order 77 | * as they are sent. If notifications are sent directly, it is possible that 78 | * a queued notification (for an earlier status condition) is processed after 79 | * the later update, resulting in the listener being left in the wrong state. 80 | */ 81 | static void AFPostReachabilityStatusChange(SCNetworkReachabilityFlags flags, AFNetworkReachabilityStatusBlock block) { 82 | AFNetworkReachabilityStatus status = AFNetworkReachabilityStatusForFlags(flags); 83 | dispatch_async(dispatch_get_main_queue(), ^{ 84 | if (block) { 85 | block(status); 86 | } 87 | NSNotificationCenter *notificationCenter = [NSNotificationCenter defaultCenter]; 88 | NSDictionary *userInfo = @{ AFNetworkingReachabilityNotificationStatusItem: @(status) }; 89 | [notificationCenter postNotificationName:AFNetworkingReachabilityDidChangeNotification object:nil userInfo:userInfo]; 90 | }); 91 | } 92 | 93 | static void AFNetworkReachabilityCallback(SCNetworkReachabilityRef __unused target, SCNetworkReachabilityFlags flags, void *info) { 94 | AFPostReachabilityStatusChange(flags, (__bridge AFNetworkReachabilityStatusBlock)info); 95 | } 96 | 97 | 98 | static const void * AFNetworkReachabilityRetainCallback(const void *info) { 99 | return Block_copy(info); 100 | } 101 | 102 | static void AFNetworkReachabilityReleaseCallback(const void *info) { 103 | if (info) { 104 | Block_release(info); 105 | } 106 | } 107 | 108 | @interface AFNetworkReachabilityManager () 109 | @property (readonly, nonatomic, assign) SCNetworkReachabilityRef networkReachability; 110 | @property (readwrite, nonatomic, assign) AFNetworkReachabilityStatus networkReachabilityStatus; 111 | @property (readwrite, nonatomic, copy) AFNetworkReachabilityStatusBlock networkReachabilityStatusBlock; 112 | @end 113 | 114 | @implementation AFNetworkReachabilityManager 115 | 116 | + (instancetype)sharedManager { 117 | static AFNetworkReachabilityManager *_sharedManager = nil; 118 | static dispatch_once_t onceToken; 119 | dispatch_once(&onceToken, ^{ 120 | _sharedManager = [self manager]; 121 | }); 122 | 123 | return _sharedManager; 124 | } 125 | 126 | + (instancetype)managerForDomain:(NSString *)domain { 127 | SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithName(kCFAllocatorDefault, [domain UTF8String]); 128 | 129 | AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability]; 130 | 131 | CFRelease(reachability); 132 | 133 | return manager; 134 | } 135 | 136 | + (instancetype)managerForAddress:(const void *)address { 137 | SCNetworkReachabilityRef reachability = SCNetworkReachabilityCreateWithAddress(kCFAllocatorDefault, (const struct sockaddr *)address); 138 | AFNetworkReachabilityManager *manager = [[self alloc] initWithReachability:reachability]; 139 | 140 | CFRelease(reachability); 141 | 142 | return manager; 143 | } 144 | 145 | + (instancetype)manager 146 | { 147 | #if (defined(__IPHONE_OS_VERSION_MIN_REQUIRED) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 90000) || (defined(__MAC_OS_X_VERSION_MIN_REQUIRED) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100) 148 | struct sockaddr_in6 address; 149 | bzero(&address, sizeof(address)); 150 | address.sin6_len = sizeof(address); 151 | address.sin6_family = AF_INET6; 152 | #else 153 | struct sockaddr_in address; 154 | bzero(&address, sizeof(address)); 155 | address.sin_len = sizeof(address); 156 | address.sin_family = AF_INET; 157 | #endif 158 | return [self managerForAddress:&address]; 159 | } 160 | 161 | - (instancetype)initWithReachability:(SCNetworkReachabilityRef)reachability { 162 | self = [super init]; 163 | if (!self) { 164 | return nil; 165 | } 166 | 167 | _networkReachability = CFRetain(reachability); 168 | self.networkReachabilityStatus = AFNetworkReachabilityStatusUnknown; 169 | 170 | return self; 171 | } 172 | 173 | - (instancetype)init NS_UNAVAILABLE 174 | { 175 | return nil; 176 | } 177 | 178 | - (void)dealloc { 179 | [self stopMonitoring]; 180 | 181 | if (_networkReachability != NULL) { 182 | CFRelease(_networkReachability); 183 | } 184 | } 185 | 186 | #pragma mark - 187 | 188 | - (BOOL)isReachable { 189 | return [self isReachableViaWWAN] || [self isReachableViaWiFi]; 190 | } 191 | 192 | - (BOOL)isReachableViaWWAN { 193 | return self.networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWWAN; 194 | } 195 | 196 | - (BOOL)isReachableViaWiFi { 197 | return self.networkReachabilityStatus == AFNetworkReachabilityStatusReachableViaWiFi; 198 | } 199 | 200 | #pragma mark - 201 | 202 | - (void)startMonitoring { 203 | [self stopMonitoring]; 204 | 205 | if (!self.networkReachability) { 206 | return; 207 | } 208 | 209 | __weak __typeof(self)weakSelf = self; 210 | AFNetworkReachabilityStatusBlock callback = ^(AFNetworkReachabilityStatus status) { 211 | __strong __typeof(weakSelf)strongSelf = weakSelf; 212 | 213 | strongSelf.networkReachabilityStatus = status; 214 | if (strongSelf.networkReachabilityStatusBlock) { 215 | strongSelf.networkReachabilityStatusBlock(status); 216 | } 217 | 218 | }; 219 | 220 | SCNetworkReachabilityContext context = {0, (__bridge void *)callback, AFNetworkReachabilityRetainCallback, AFNetworkReachabilityReleaseCallback, NULL}; 221 | SCNetworkReachabilitySetCallback(self.networkReachability, AFNetworkReachabilityCallback, &context); 222 | SCNetworkReachabilityScheduleWithRunLoop(self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes); 223 | 224 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0),^{ 225 | SCNetworkReachabilityFlags flags; 226 | if (SCNetworkReachabilityGetFlags(self.networkReachability, &flags)) { 227 | AFPostReachabilityStatusChange(flags, callback); 228 | } 229 | }); 230 | } 231 | 232 | - (void)stopMonitoring { 233 | if (!self.networkReachability) { 234 | return; 235 | } 236 | 237 | SCNetworkReachabilityUnscheduleFromRunLoop(self.networkReachability, CFRunLoopGetMain(), kCFRunLoopCommonModes); 238 | } 239 | 240 | #pragma mark - 241 | 242 | - (NSString *)localizedNetworkReachabilityStatusString { 243 | return AFStringFromNetworkReachabilityStatus(self.networkReachabilityStatus); 244 | } 245 | 246 | #pragma mark - 247 | 248 | - (void)setReachabilityStatusChangeBlock:(void (^)(AFNetworkReachabilityStatus status))block { 249 | self.networkReachabilityStatusBlock = block; 250 | } 251 | 252 | #pragma mark - NSKeyValueObserving 253 | 254 | + (NSSet *)keyPathsForValuesAffectingValueForKey:(NSString *)key { 255 | if ([key isEqualToString:@"reachable"] || [key isEqualToString:@"reachableViaWWAN"] || [key isEqualToString:@"reachableViaWiFi"]) { 256 | return [NSSet setWithObject:@"networkReachabilityStatus"]; 257 | } 258 | 259 | return [super keyPathsForValuesAffectingValueForKey:key]; 260 | } 261 | 262 | @end 263 | #endif 264 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/ExternalLibs/AFNetworking/AFNetworking.h: -------------------------------------------------------------------------------- 1 | // AFNetworking.h 2 | // 3 | // Copyright (c) 2013 AFNetworking (http://afnetworking.com/) 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy 6 | // of this software and associated documentation files (the "Software"), to deal 7 | // in the Software without restriction, including without limitation the rights 8 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | // copies of the Software, and to permit persons to whom the Software is 10 | // furnished to do so, subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in 13 | // all copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | 23 | #import 24 | #import 25 | #import 26 | 27 | #ifndef _AFNETWORKING_ 28 | #define _AFNETWORKING_ 29 | 30 | #import "AFURLRequestSerialization.h" 31 | #import "AFURLResponseSerialization.h" 32 | #import "AFSecurityPolicy.h" 33 | 34 | #if !TARGET_OS_WATCH 35 | #import "AFNetworkReachabilityManager.h" 36 | #endif 37 | 38 | #import "AFURLSessionManager.h" 39 | #import "AFHTTPSessionManager.h" 40 | 41 | #endif /* _AFNETWORKING_ */ 42 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/ExternalLibs/AFNetworking/AFSecurityPolicy.h: -------------------------------------------------------------------------------- 1 | // AFSecurityPolicy.h 2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | #import 24 | 25 | typedef NS_ENUM(NSUInteger, AFSSLPinningMode) { 26 | AFSSLPinningModeNone, 27 | AFSSLPinningModePublicKey, 28 | AFSSLPinningModeCertificate, 29 | }; 30 | 31 | /** 32 | `AFSecurityPolicy` evaluates server trust against pinned X.509 certificates and public keys over secure connections. 33 | 34 | Adding pinned SSL certificates to your app helps prevent man-in-the-middle attacks and other vulnerabilities. Applications dealing with sensitive customer data or financial information are strongly encouraged to route all communication over an HTTPS connection with SSL pinning configured and enabled. 35 | */ 36 | 37 | NS_ASSUME_NONNULL_BEGIN 38 | 39 | @interface AFSecurityPolicy : NSObject 40 | 41 | /** 42 | The criteria by which server trust should be evaluated against the pinned SSL certificates. Defaults to `AFSSLPinningModeNone`. 43 | */ 44 | @property (readonly, nonatomic, assign) AFSSLPinningMode SSLPinningMode; 45 | 46 | /** 47 | The certificates used to evaluate server trust according to the SSL pinning mode. 48 | 49 | By default, this property is set to any (`.cer`) certificates included in the target compiling AFNetworking. Note that if you are using AFNetworking as embedded framework, no certificates will be pinned by default. Use `certificatesInBundle` to load certificates from your target, and then create a new policy by calling `policyWithPinningMode:withPinnedCertificates`. 50 | 51 | Note that if pinning is enabled, `evaluateServerTrust:forDomain:` will return true if any pinned certificate matches. 52 | */ 53 | @property (nonatomic, strong, nullable) NSSet *pinnedCertificates; 54 | 55 | /** 56 | Whether or not to trust servers with an invalid or expired SSL certificates. Defaults to `NO`. 57 | */ 58 | @property (nonatomic, assign) BOOL allowInvalidCertificates; 59 | 60 | /** 61 | Whether or not to validate the domain name in the certificate's CN field. Defaults to `YES`. 62 | */ 63 | @property (nonatomic, assign) BOOL validatesDomainName; 64 | 65 | ///----------------------------------------- 66 | /// @name Getting Certificates from the Bundle 67 | ///----------------------------------------- 68 | 69 | /** 70 | Returns any certificates included in the bundle. If you are using AFNetworking as an embedded framework, you must use this method to find the certificates you have included in your app bundle, and use them when creating your security policy by calling `policyWithPinningMode:withPinnedCertificates`. 71 | 72 | @return The certificates included in the given bundle. 73 | */ 74 | + (NSSet *)certificatesInBundle:(NSBundle *)bundle; 75 | 76 | ///----------------------------------------- 77 | /// @name Getting Specific Security Policies 78 | ///----------------------------------------- 79 | 80 | /** 81 | Returns the shared default security policy, which does not allow invalid certificates, validates domain name, and does not validate against pinned certificates or public keys. 82 | 83 | @return The default security policy. 84 | */ 85 | + (instancetype)defaultPolicy; 86 | 87 | ///--------------------- 88 | /// @name Initialization 89 | ///--------------------- 90 | 91 | /** 92 | Creates and returns a security policy with the specified pinning mode. 93 | 94 | @param pinningMode The SSL pinning mode. 95 | 96 | @return A new security policy. 97 | */ 98 | + (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode; 99 | 100 | /** 101 | Creates and returns a security policy with the specified pinning mode. 102 | 103 | @param pinningMode The SSL pinning mode. 104 | @param pinnedCertificates The certificates to pin against. 105 | 106 | @return A new security policy. 107 | */ 108 | + (instancetype)policyWithPinningMode:(AFSSLPinningMode)pinningMode withPinnedCertificates:(NSSet *)pinnedCertificates; 109 | 110 | ///------------------------------ 111 | /// @name Evaluating Server Trust 112 | ///------------------------------ 113 | 114 | /** 115 | Whether or not the specified server trust should be accepted, based on the security policy. 116 | 117 | This method should be used when responding to an authentication challenge from a server. 118 | 119 | @param serverTrust The X.509 certificate trust of the server. 120 | @param domain The domain of serverTrust. If `nil`, the domain will not be validated. 121 | 122 | @return Whether or not to trust the server. 123 | */ 124 | - (BOOL)evaluateServerTrust:(SecTrustRef)serverTrust 125 | forDomain:(nullable NSString *)domain; 126 | 127 | @end 128 | 129 | NS_ASSUME_NONNULL_END 130 | 131 | ///---------------- 132 | /// @name Constants 133 | ///---------------- 134 | 135 | /** 136 | ## SSL Pinning Modes 137 | 138 | The following constants are provided by `AFSSLPinningMode` as possible SSL pinning modes. 139 | 140 | enum { 141 | AFSSLPinningModeNone, 142 | AFSSLPinningModePublicKey, 143 | AFSSLPinningModeCertificate, 144 | } 145 | 146 | `AFSSLPinningModeNone` 147 | Do not used pinned certificates to validate servers. 148 | 149 | `AFSSLPinningModePublicKey` 150 | Validate host certificates against public keys of pinned certificates. 151 | 152 | `AFSSLPinningModeCertificate` 153 | Validate host certificates against pinned certificates. 154 | */ 155 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/ExternalLibs/AFNetworking/AFURLResponseSerialization.h: -------------------------------------------------------------------------------- 1 | // AFURLResponseSerialization.h 2 | // Copyright (c) 2011–2016 Alamofire Software Foundation ( http://alamofire.org/ ) 3 | // 4 | // Permission is hereby granted, free of charge, to any person obtaining a copy 5 | // of this software and associated documentation files (the "Software"), to deal 6 | // in the Software without restriction, including without limitation the rights 7 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | // copies of the Software, and to permit persons to whom the Software is 9 | // furnished to do so, subject to the following conditions: 10 | // 11 | // The above copyright notice and this permission notice shall be included in 12 | // all copies or substantial portions of the Software. 13 | // 14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | // THE SOFTWARE. 21 | 22 | #import 23 | #import 24 | 25 | NS_ASSUME_NONNULL_BEGIN 26 | 27 | /** 28 | The `AFURLResponseSerialization` protocol is adopted by an object that decodes data into a more useful object representation, according to details in the server response. Response serializers may additionally perform validation on the incoming response and data. 29 | 30 | For example, a JSON response serializer may check for an acceptable status code (`2XX` range) and content type (`application/json`), decoding a valid JSON response into an object. 31 | */ 32 | @protocol AFURLResponseSerialization 33 | 34 | /** 35 | The response object decoded from the data associated with a specified response. 36 | 37 | @param response The response to be processed. 38 | @param data The response data to be decoded. 39 | @param error The error that occurred while attempting to decode the response data. 40 | 41 | @return The object decoded from the specified response data. 42 | */ 43 | - (nullable id)responseObjectForResponse:(nullable NSURLResponse *)response 44 | data:(nullable NSData *)data 45 | error:(NSError * _Nullable __autoreleasing *)error NS_SWIFT_NOTHROW; 46 | 47 | @end 48 | 49 | #pragma mark - 50 | 51 | /** 52 | `AFHTTPResponseSerializer` conforms to the `AFURLRequestSerialization` & `AFURLResponseSerialization` protocols, offering a concrete base implementation of query string / URL form-encoded parameter serialization and default request headers, as well as response status code and content type validation. 53 | 54 | Any request or response serializer dealing with HTTP is encouraged to subclass `AFHTTPResponseSerializer` in order to ensure consistent default behavior. 55 | */ 56 | @interface AFHTTPResponseSerializer : NSObject 57 | 58 | - (instancetype)init; 59 | 60 | /** 61 | The string encoding used to serialize data received from the server, when no string encoding is specified by the response. `NSUTF8StringEncoding` by default. 62 | */ 63 | @property (nonatomic, assign) NSStringEncoding stringEncoding; 64 | 65 | /** 66 | Creates and returns a serializer with default configuration. 67 | */ 68 | + (instancetype)serializer; 69 | 70 | ///----------------------------------------- 71 | /// @name Configuring Response Serialization 72 | ///----------------------------------------- 73 | 74 | /** 75 | The acceptable HTTP status codes for responses. When non-`nil`, responses with status codes not contained by the set will result in an error during validation. 76 | 77 | See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html 78 | */ 79 | @property (nonatomic, copy, nullable) NSIndexSet *acceptableStatusCodes; 80 | 81 | /** 82 | The acceptable MIME types for responses. When non-`nil`, responses with a `Content-Type` with MIME types that do not intersect with the set will result in an error during validation. 83 | */ 84 | @property (nonatomic, copy, nullable) NSSet *acceptableContentTypes; 85 | 86 | /** 87 | Validates the specified response and data. 88 | 89 | In its base implementation, this method checks for an acceptable status code and content type. Subclasses may wish to add other domain-specific checks. 90 | 91 | @param response The response to be validated. 92 | @param data The data associated with the response. 93 | @param error The error that occurred while attempting to validate the response. 94 | 95 | @return `YES` if the response is valid, otherwise `NO`. 96 | */ 97 | - (BOOL)validateResponse:(nullable NSHTTPURLResponse *)response 98 | data:(nullable NSData *)data 99 | error:(NSError * _Nullable __autoreleasing *)error; 100 | 101 | @end 102 | 103 | #pragma mark - 104 | 105 | 106 | /** 107 | `AFJSONResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes JSON responses. 108 | 109 | By default, `AFJSONResponseSerializer` accepts the following MIME types, which includes the official standard, `application/json`, as well as other commonly-used types: 110 | 111 | - `application/json` 112 | - `text/json` 113 | - `text/javascript` 114 | */ 115 | @interface AFJSONResponseSerializer : AFHTTPResponseSerializer 116 | 117 | - (instancetype)init; 118 | 119 | /** 120 | Options for reading the response JSON data and creating the Foundation objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONReadingOptions". `0` by default. 121 | */ 122 | @property (nonatomic, assign) NSJSONReadingOptions readingOptions; 123 | 124 | /** 125 | Whether to remove keys with `NSNull` values from response JSON. Defaults to `NO`. 126 | */ 127 | @property (nonatomic, assign) BOOL removesKeysWithNullValues; 128 | 129 | /** 130 | Creates and returns a JSON serializer with specified reading and writing options. 131 | 132 | @param readingOptions The specified JSON reading options. 133 | */ 134 | + (instancetype)serializerWithReadingOptions:(NSJSONReadingOptions)readingOptions; 135 | 136 | @end 137 | 138 | #pragma mark - 139 | 140 | /** 141 | `AFXMLParserResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLParser` objects. 142 | 143 | By default, `AFXMLParserResponseSerializer` accepts the following MIME types, which includes the official standard, `application/xml`, as well as other commonly-used types: 144 | 145 | - `application/xml` 146 | - `text/xml` 147 | */ 148 | @interface AFXMLParserResponseSerializer : AFHTTPResponseSerializer 149 | 150 | @end 151 | 152 | #pragma mark - 153 | 154 | #ifdef __MAC_OS_X_VERSION_MIN_REQUIRED 155 | 156 | /** 157 | `AFXMLDocumentResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLDocument` objects. 158 | 159 | By default, `AFXMLDocumentResponseSerializer` accepts the following MIME types, which includes the official standard, `application/xml`, as well as other commonly-used types: 160 | 161 | - `application/xml` 162 | - `text/xml` 163 | */ 164 | @interface AFXMLDocumentResponseSerializer : AFHTTPResponseSerializer 165 | 166 | - (instancetype)init; 167 | 168 | /** 169 | Input and output options specifically intended for `NSXMLDocument` objects. For possible values, see the `NSJSONSerialization` documentation section "NSJSONReadingOptions". `0` by default. 170 | */ 171 | @property (nonatomic, assign) NSUInteger options; 172 | 173 | /** 174 | Creates and returns an XML document serializer with the specified options. 175 | 176 | @param mask The XML document options. 177 | */ 178 | + (instancetype)serializerWithXMLDocumentOptions:(NSUInteger)mask; 179 | 180 | @end 181 | 182 | #endif 183 | 184 | #pragma mark - 185 | 186 | /** 187 | `AFPropertyListResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes XML responses as an `NSXMLDocument` objects. 188 | 189 | By default, `AFPropertyListResponseSerializer` accepts the following MIME types: 190 | 191 | - `application/x-plist` 192 | */ 193 | @interface AFPropertyListResponseSerializer : AFHTTPResponseSerializer 194 | 195 | - (instancetype)init; 196 | 197 | /** 198 | The property list format. Possible values are described in "NSPropertyListFormat". 199 | */ 200 | @property (nonatomic, assign) NSPropertyListFormat format; 201 | 202 | /** 203 | The property list reading options. Possible values are described in "NSPropertyListMutabilityOptions." 204 | */ 205 | @property (nonatomic, assign) NSPropertyListReadOptions readOptions; 206 | 207 | /** 208 | Creates and returns a property list serializer with a specified format, read options, and write options. 209 | 210 | @param format The property list format. 211 | @param readOptions The property list reading options. 212 | */ 213 | + (instancetype)serializerWithFormat:(NSPropertyListFormat)format 214 | readOptions:(NSPropertyListReadOptions)readOptions; 215 | 216 | @end 217 | 218 | #pragma mark - 219 | 220 | /** 221 | `AFImageResponseSerializer` is a subclass of `AFHTTPResponseSerializer` that validates and decodes image responses. 222 | 223 | By default, `AFImageResponseSerializer` accepts the following MIME types, which correspond to the image formats supported by UIImage or NSImage: 224 | 225 | - `image/tiff` 226 | - `image/jpeg` 227 | - `image/gif` 228 | - `image/png` 229 | - `image/ico` 230 | - `image/x-icon` 231 | - `image/bmp` 232 | - `image/x-bmp` 233 | - `image/x-xbitmap` 234 | - `image/x-win-bitmap` 235 | */ 236 | @interface AFImageResponseSerializer : AFHTTPResponseSerializer 237 | 238 | #if TARGET_OS_IOS || TARGET_OS_TV || TARGET_OS_WATCH 239 | /** 240 | The scale factor used when interpreting the image data to construct `responseImage`. Specifying a scale factor of 1.0 results in an image whose size matches the pixel-based dimensions of the image. Applying a different scale factor changes the size of the image as reported by the size property. This is set to the value of scale of the main screen by default, which automatically scales images for retina displays, for instance. 241 | */ 242 | @property (nonatomic, assign) CGFloat imageScale; 243 | 244 | /** 245 | Whether to automatically inflate response image data for compressed formats (such as PNG or JPEG). Enabling this can significantly improve drawing performance on iOS when used with `setCompletionBlockWithSuccess:failure:`, as it allows a bitmap representation to be constructed in the background rather than on the main thread. `YES` by default. 246 | */ 247 | @property (nonatomic, assign) BOOL automaticallyInflatesResponseImage; 248 | #endif 249 | 250 | @end 251 | 252 | #pragma mark - 253 | 254 | /** 255 | `AFCompoundSerializer` is a subclass of `AFHTTPResponseSerializer` that delegates the response serialization to the first `AFHTTPResponseSerializer` object that returns an object for `responseObjectForResponse:data:error:`, falling back on the default behavior of `AFHTTPResponseSerializer`. This is useful for supporting multiple potential types and structures of server responses with a single serializer. 256 | */ 257 | @interface AFCompoundResponseSerializer : AFHTTPResponseSerializer 258 | 259 | /** 260 | The component response serializers. 261 | */ 262 | @property (readonly, nonatomic, copy) NSArray > *responseSerializers; 263 | 264 | /** 265 | Creates and returns a compound serializer comprised of the specified response serializers. 266 | 267 | @warning Each response serializer specified must be a subclass of `AFHTTPResponseSerializer`, and response to `-validateResponse:data:error:`. 268 | */ 269 | + (instancetype)compoundSerializerWithResponseSerializers:(NSArray > *)responseSerializers; 270 | 271 | @end 272 | 273 | ///---------------- 274 | /// @name Constants 275 | ///---------------- 276 | 277 | /** 278 | ## Error Domains 279 | 280 | The following error domain is predefined. 281 | 282 | - `NSString * const AFURLResponseSerializationErrorDomain` 283 | 284 | ### Constants 285 | 286 | `AFURLResponseSerializationErrorDomain` 287 | AFURLResponseSerializer errors. Error codes for `AFURLResponseSerializationErrorDomain` correspond to codes in `NSURLErrorDomain`. 288 | */ 289 | FOUNDATION_EXPORT NSString * const AFURLResponseSerializationErrorDomain; 290 | 291 | /** 292 | ## User info dictionary keys 293 | 294 | These keys may exist in the user info dictionary, in addition to those defined for NSError. 295 | 296 | - `NSString * const AFNetworkingOperationFailingURLResponseErrorKey` 297 | - `NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey` 298 | 299 | ### Constants 300 | 301 | `AFNetworkingOperationFailingURLResponseErrorKey` 302 | The corresponding value is an `NSURLResponse` containing the response of the operation associated with an error. This key is only present in the `AFURLResponseSerializationErrorDomain`. 303 | 304 | `AFNetworkingOperationFailingURLResponseDataErrorKey` 305 | The corresponding value is an `NSData` containing the original data of the operation associated with an error. This key is only present in the `AFURLResponseSerializationErrorDomain`. 306 | */ 307 | FOUNDATION_EXPORT NSString * const AFNetworkingOperationFailingURLResponseErrorKey; 308 | 309 | FOUNDATION_EXPORT NSString * const AFNetworkingOperationFailingURLResponseDataErrorKey; 310 | 311 | NS_ASSUME_NONNULL_END 312 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/OCCapabilities.h: -------------------------------------------------------------------------------- 1 | // 2 | // OCCapabilities.h 3 | // ownCloud iOS library 4 | // 5 | // Created by Gonzalo Gonzalez on 4/11/15. 6 | // 7 | // Copyright (C) 2017, ownCloud GmbH. ( http://www.owncloud.org/ ) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | 28 | #import 29 | 30 | @interface OCCapabilities : NSObject 31 | 32 | /*VERSION*/ 33 | @property (nonatomic) NSInteger versionMajor; 34 | @property (nonatomic) NSInteger versionMinor; 35 | @property (nonatomic) NSInteger versionMicro; 36 | @property (nonatomic, strong) NSString *versionString; 37 | @property (nonatomic, strong) NSString *versionEdition; 38 | 39 | /*CAPABILITIES*/ 40 | 41 | /*CORE*/ 42 | @property (nonatomic) NSInteger corePollInterval; 43 | 44 | /*FILES SHARING*/ 45 | 46 | @property (nonatomic) BOOL isFilesSharingAPIEnabled; 47 | 48 | //SHARE LINK FEATURES 49 | @property (nonatomic) BOOL isFilesSharingShareLinkEnabled; 50 | 51 | //Share Link with password 52 | @property (nonatomic) BOOL isFilesSharingPasswordEnforcedEnabled; 53 | 54 | //Share Link with expiration date 55 | @property (nonatomic) BOOL isFilesSharingExpireDateByDefaultEnabled; 56 | @property (nonatomic) BOOL isFilesSharingExpireDateEnforceEnabled; 57 | @property (nonatomic) NSInteger filesSharingExpireDateDaysNumber; 58 | 59 | //Other share link features 60 | @property (nonatomic) BOOL isFilesSharingAllowUserSendMailNotificationAboutShareLinkEnabled; 61 | @property (nonatomic) BOOL isFilesSharingAllowPublicUploadsEnabled; 62 | @property (nonatomic) BOOL isFilesSharingSupportsUploadOnlyEnabled; 63 | @property (nonatomic) BOOL isFilesSharingAllowUserCreateMultiplePublicLinksEnabled; 64 | 65 | //Other Shares Features 66 | @property (nonatomic) BOOL isFilesSharingAllowUserSendMailNotificationAboutOtherUsersEnabled; 67 | @property (nonatomic) BOOL isFilesSharingReSharingEnabled; 68 | 69 | //Federating cloud share (before called Server-to-Server sharing) 70 | @property (nonatomic) BOOL isFilesSharingAllowUserSendSharesToOtherServersEnabled; 71 | @property (nonatomic) BOOL isFilesSharingAllowUserReceiveSharesToOtherServersEnabled; 72 | 73 | 74 | /*FILES*/ 75 | @property (nonatomic) BOOL isFileBigFileChunkingEnabled; 76 | @property (nonatomic) BOOL isFileUndeleteEnabled; 77 | @property (nonatomic) BOOL isFileVersioningEnabled; 78 | 79 | - (void)encodeWithCoder:(NSCoder *)aCoder; 80 | - (id)initWithCoder:(NSCoder *)aDecoder; 81 | 82 | @end 83 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/OCCapabilities.m: -------------------------------------------------------------------------------- 1 | // 2 | // OCCapabilities.m 3 | // ownCloud iOS library 4 | // 5 | // Created by Gonzalo Gonzalez on 4/11/15. 6 | // 7 | // Copyright (C) 2017, ownCloud GmbH. ( http://www.owncloud.org/ ) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | 28 | #import "OCCapabilities.h" 29 | 30 | @implementation OCCapabilities 31 | 32 | - (id)init { 33 | self = [super init]; 34 | if (self) { 35 | self.versionMajor = 0; 36 | self.versionMinor = 0; 37 | self.versionMicro = 0; 38 | self.versionString = @""; 39 | self.versionEdition = @""; 40 | self.corePollInterval = 0; 41 | self.filesSharingExpireDateDaysNumber = 0; 42 | 43 | } 44 | return self; 45 | } 46 | 47 | #pragma mark - NSCopying 48 | 49 | -(id) copyWithZone:(NSZone *)zone { 50 | OCCapabilities *capCopy = [[OCCapabilities alloc]init]; 51 | capCopy.versionMajor = self.versionMajor; 52 | capCopy.versionMinor = self.versionMinor; 53 | capCopy.versionMicro = self.versionMicro; 54 | capCopy.versionString = self.versionString; 55 | capCopy.versionEdition = self.versionEdition; 56 | 57 | capCopy.corePollInterval = self.corePollInterval; 58 | 59 | capCopy.isFilesSharingAPIEnabled = self.isFilesSharingAPIEnabled; 60 | 61 | capCopy.isFilesSharingShareLinkEnabled = self.isFilesSharingShareLinkEnabled; 62 | 63 | capCopy.isFilesSharingPasswordEnforcedEnabled = self.isFilesSharingPasswordEnforcedEnabled; 64 | 65 | capCopy.isFilesSharingExpireDateByDefaultEnabled = self.isFilesSharingExpireDateByDefaultEnabled; 66 | capCopy.isFilesSharingExpireDateEnforceEnabled = self.isFilesSharingExpireDateEnforceEnabled; 67 | capCopy.filesSharingExpireDateDaysNumber = self.filesSharingExpireDateDaysNumber; 68 | 69 | capCopy.isFilesSharingAllowUserSendMailNotificationAboutShareLinkEnabled = self.isFilesSharingAllowUserSendMailNotificationAboutShareLinkEnabled; 70 | capCopy.isFilesSharingAllowPublicUploadsEnabled = self.isFilesSharingAllowPublicUploadsEnabled; 71 | capCopy.isFilesSharingSupportsUploadOnlyEnabled = self.isFilesSharingSupportsUploadOnlyEnabled; 72 | capCopy.isFilesSharingAllowUserCreateMultiplePublicLinksEnabled = self.isFilesSharingAllowUserCreateMultiplePublicLinksEnabled; 73 | 74 | capCopy.isFilesSharingAllowUserSendMailNotificationAboutOtherUsersEnabled = self.isFilesSharingAllowUserSendMailNotificationAboutOtherUsersEnabled; 75 | capCopy.isFilesSharingReSharingEnabled = self.isFilesSharingReSharingEnabled; 76 | 77 | capCopy.isFilesSharingAllowUserSendSharesToOtherServersEnabled = self.isFilesSharingAllowUserSendSharesToOtherServersEnabled; 78 | capCopy.isFilesSharingAllowUserReceiveSharesToOtherServersEnabled = self.isFilesSharingAllowUserReceiveSharesToOtherServersEnabled; 79 | 80 | capCopy.isFileBigFileChunkingEnabled = self.isFileBigFileChunkingEnabled; 81 | capCopy.isFileUndeleteEnabled = self.isFileUndeleteEnabled; 82 | capCopy.isFileVersioningEnabled = self.isFileVersioningEnabled; 83 | 84 | return capCopy; 85 | } 86 | 87 | #pragma mark - NSSecureCoding 88 | 89 | + (BOOL)supportsSecureCoding { 90 | return YES; 91 | } 92 | 93 | - (void)encodeWithCoder:(NSCoder *)aCoder 94 | { 95 | [aCoder encodeInteger:self.versionMajor forKey:@"versionMajor"]; 96 | [aCoder encodeInteger:self.versionMinor forKey:@"versionMinor"]; 97 | [aCoder encodeInteger:self.versionMicro forKey:@"versionMicro"]; 98 | [aCoder encodeObject:self.versionString forKey:@"versionString"]; 99 | [aCoder encodeObject:self.versionEdition forKey:@"versionEdition"]; 100 | 101 | [aCoder encodeInteger:self.corePollInterval forKey:@"corePollInterval"]; 102 | 103 | [aCoder encodeBool:self.isFilesSharingAPIEnabled forKey:@"isFilesSharingAPIEnabled"]; 104 | 105 | [aCoder encodeBool:self.isFilesSharingShareLinkEnabled forKey:@"isFilesSharingShareLinkEnabled"]; 106 | 107 | [aCoder encodeBool:self.isFilesSharingPasswordEnforcedEnabled forKey:@"isFilesSharingPasswordEnforcedEnabled"]; 108 | 109 | [aCoder encodeBool:self.isFilesSharingExpireDateByDefaultEnabled forKey:@"isFilesSharingExpireDateByDefaultEnabled"]; 110 | [aCoder encodeBool:self.isFilesSharingExpireDateEnforceEnabled forKey:@"isFilesSharingExpireDateEnforceEnabled"]; 111 | [aCoder encodeInteger:self.filesSharingExpireDateDaysNumber forKey:@"filesSharingExpireDateDaysNumber"]; 112 | 113 | [aCoder encodeBool:self.isFilesSharingAllowUserSendMailNotificationAboutShareLinkEnabled forKey:@"isFilesSharingAllowUserSendMailNotificationAboutShareLinkEnabled"]; 114 | [aCoder encodeBool:self.isFilesSharingAllowPublicUploadsEnabled forKey:@"isFilesSharingAllowPublicUploadsEnabled"]; 115 | [aCoder encodeBool:self.isFilesSharingSupportsUploadOnlyEnabled forKey:@"isFilesSharingSupportsUploadOnlyEnabled"]; 116 | [aCoder encodeBool:self.isFilesSharingAllowUserCreateMultiplePublicLinksEnabled forKey:@"isFilesSharingAllowUserCreateMultiplePublicLinksEnabled"]; 117 | 118 | [aCoder encodeBool:self.isFilesSharingAllowUserSendMailNotificationAboutOtherUsersEnabled forKey:@"isFilesSharingAllowUserSendMailNotificationAboutOtherUsersEnabled"]; 119 | [aCoder encodeBool:self.isFilesSharingReSharingEnabled forKey:@"isFilesSharingReSharingEnabled"]; 120 | 121 | [aCoder encodeBool:self.isFilesSharingAllowUserSendSharesToOtherServersEnabled forKey:@"isFilesSharingAllowUserSendSharesToOtherServersEnabled"]; 122 | [aCoder encodeBool:self.isFilesSharingAllowUserReceiveSharesToOtherServersEnabled forKey:@"isFilesSharingAllowUserReceiveSharesToOtherServersEnabled"]; 123 | 124 | [aCoder encodeBool:self.isFileBigFileChunkingEnabled forKey:@"isFileBigFileChunkingEnabled"]; 125 | [aCoder encodeBool:self.isFileUndeleteEnabled forKey:@"isFileUndeleteEnabled"]; 126 | [aCoder encodeBool:self.isFileVersioningEnabled forKey:@"isFileVersioningEnabled"]; 127 | } 128 | 129 | - (instancetype)initWithCoder:(NSCoder *)aDecoder 130 | { 131 | if (self = [self init]) { 132 | self.versionMajor = [aDecoder decodeIntegerForKey:@"versionMajor"]; 133 | self.versionMinor = [aDecoder decodeIntegerForKey:@"versionMinor"]; 134 | self.versionMicro = [aDecoder decodeIntegerForKey:@"versionMicro"]; 135 | self.versionString = [aDecoder decodeObjectForKey:@"versionString"]; 136 | self.versionEdition = [aDecoder decodeObjectForKey:@"versionEdition"]; 137 | 138 | self.corePollInterval = [aDecoder decodeIntegerForKey:@"corePollInterval"]; 139 | 140 | self.isFilesSharingAPIEnabled = [aDecoder decodeBoolForKey:@"isFilesSharingAPIEnabled"]; 141 | 142 | self.isFilesSharingShareLinkEnabled = [aDecoder decodeBoolForKey:@"isFilesSharingShareLinkEnabled"]; 143 | 144 | self.isFilesSharingPasswordEnforcedEnabled = [aDecoder decodeBoolForKey:@"isFilesSharingPasswordEnforcedEnabled"]; 145 | 146 | self.isFilesSharingExpireDateByDefaultEnabled = [aDecoder decodeBoolForKey:@"isFilesSharingExpireDateByDefaultEnabled"]; 147 | self.isFilesSharingExpireDateEnforceEnabled = [aDecoder decodeBoolForKey:@"isFilesSharingExpireDateEnforceEnabled"]; 148 | self.filesSharingExpireDateDaysNumber = [aDecoder decodeIntegerForKey:@"filesSharingExpireDateDaysNumber"]; 149 | 150 | self.isFilesSharingAllowUserSendMailNotificationAboutShareLinkEnabled = [aDecoder decodeBoolForKey:@"isFilesSharingAllowUserSendMailNotificationAboutShareLinkEnabled"]; 151 | self.isFilesSharingAllowPublicUploadsEnabled = [aDecoder decodeBoolForKey:@"isFilesSharingAllowPublicUploadsEnabled"]; 152 | self.isFilesSharingSupportsUploadOnlyEnabled = [aDecoder decodeBoolForKey:@"isFilesSharingSupportsUploadOnlyEnabled"]; 153 | self.isFilesSharingAllowUserCreateMultiplePublicLinksEnabled = [aDecoder decodeBoolForKey:@"isFilesSharingAllowUserCreateMultiplePublicLinksEnabled"]; 154 | 155 | self.isFilesSharingAllowUserSendMailNotificationAboutOtherUsersEnabled = [aDecoder decodeBoolForKey:@"isFilesSharingAllowUserSendMailNotificationAboutOtherUsersEnabled"]; 156 | self.isFilesSharingReSharingEnabled = [aDecoder decodeBoolForKey:@"isFilesSharingReSharingEnabled"]; 157 | 158 | self.isFilesSharingAllowUserSendSharesToOtherServersEnabled = [aDecoder decodeBoolForKey:@"isFilesSharingAllowUserSendSharesToOtherServersEnabled"]; 159 | self.isFilesSharingAllowUserReceiveSharesToOtherServersEnabled = [aDecoder decodeBoolForKey:@"isFilesSharingAllowUserReceiveSharesToOtherServersEnabled"]; 160 | 161 | self.isFileBigFileChunkingEnabled = [aDecoder decodeBoolForKey:@"isFilesSharingReSharingEnabled"]; 162 | self.isFileUndeleteEnabled = [aDecoder decodeBoolForKey:@"isFileUndeleteEnabled"]; 163 | self.isFileVersioningEnabled = [aDecoder decodeBoolForKey:@"isFileVersioningEnabled"]; 164 | } 165 | return self; 166 | } 167 | 168 | @end 169 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/OCCredentialsDto.h: -------------------------------------------------------------------------------- 1 | // 2 | // OCCredentialsDto.h 3 | // ownCloud iOS library 4 | // 5 | // Created by Noelia Alvarez on 27/10/14. 6 | // 7 | // Copyright (C) 2017, ownCloud GmbH. ( http://www.owncloud.org/ ) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | // 28 | 29 | #import 30 | 31 | typedef NS_ENUM (NSUInteger, AuthenticationMethod){ 32 | AuthenticationMethodUNKNOWN = 0, 33 | AuthenticationMethodNONE = 1, 34 | AuthenticationMethodBASIC_HTTP_AUTH = 2, 35 | AuthenticationMethodBEARER_TOKEN = 3, 36 | AuthenticationMethodSAML_WEB_SSO = 4, 37 | }; 38 | 39 | @interface OCCredentialsDto : NSObject 40 | 41 | @property (nonatomic, copy) NSString *userId; 42 | @property (nonatomic, copy) NSString *baseURL; 43 | @property (nonatomic, copy) NSString *userName; 44 | @property (nonatomic, copy) NSString *accessToken; // password for basic auth, cookies for SAML, access token for OAuth2... 45 | @property (nonatomic) AuthenticationMethod authenticationMethod; 46 | 47 | //optionals credentials used with oauth2 48 | @property (nonatomic, copy) NSString *refreshToken; 49 | @property (nonatomic, copy) NSString *expiresIn; 50 | @property (nonatomic, copy) NSString *tokenType; 51 | 52 | @property (nonatomic, copy) NSString *userDisplayName; 53 | 54 | 55 | - (void)encodeWithCoder:(NSCoder *)aCoder; 56 | - (id)initWithCoder:(NSCoder *)aDecoder; 57 | 58 | @end 59 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/OCCredentialsDto.m: -------------------------------------------------------------------------------- 1 | // 2 | // OCCredentialsDto.m 3 | // ownCloud iOS library 4 | // 5 | // Created by Noelia Alvarez on 27/10/14. 6 | // 7 | // Copyright (C) 2017, ownCloud GmbH. ( http://www.owncloud.org/ ) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | 28 | #import "OCCredentialsDto.h" 29 | 30 | @implementation OCCredentialsDto 31 | 32 | - (id)initWithCredentialsDto:(OCCredentialsDto *)oCredDto{ 33 | 34 | self = [super init]; 35 | if (self) { 36 | // Custom initialization 37 | _userId = oCredDto.userId; 38 | _baseURL = oCredDto.baseURL; 39 | _userName = oCredDto.userName; 40 | _accessToken = oCredDto.accessToken; 41 | _refreshToken = oCredDto.refreshToken; 42 | _expiresIn = oCredDto.expiresIn; 43 | _tokenType = oCredDto.tokenType; 44 | _authenticationMethod = oCredDto.authenticationMethod; 45 | _userDisplayName = oCredDto.userDisplayName; 46 | } 47 | 48 | return self; 49 | } 50 | 51 | 52 | #pragma mark - NSCopying 53 | 54 | -(id) copyWithZone:(NSZone *)zone { 55 | OCCredentialsDto *credDtoCopy = [[OCCredentialsDto alloc]init]; 56 | credDtoCopy.userId = self.userId; 57 | credDtoCopy.baseURL = self.baseURL; 58 | credDtoCopy.userName = self.userName; 59 | credDtoCopy.accessToken = self.accessToken; 60 | credDtoCopy.refreshToken = self.refreshToken; 61 | credDtoCopy.expiresIn = self.expiresIn; 62 | credDtoCopy.tokenType = self.tokenType; 63 | credDtoCopy.authenticationMethod = self.authenticationMethod; 64 | credDtoCopy.userDisplayName = self.userDisplayName; 65 | 66 | return credDtoCopy; 67 | } 68 | 69 | #pragma mark - NSSecureCoding 70 | 71 | + (BOOL)supportsSecureCoding { 72 | return YES; 73 | } 74 | 75 | - (void)encodeWithCoder:(NSCoder *)aCoder 76 | { 77 | [aCoder encodeObject:self.userId forKey:@"userId"]; 78 | [aCoder encodeObject:self.baseURL forKey:@"baseURL"]; 79 | [aCoder encodeObject:self.userName forKey:@"userName"]; 80 | [aCoder encodeObject:self.accessToken forKey:@"accessToken"]; 81 | [aCoder encodeObject:self.refreshToken forKey:@"refreshToken"]; 82 | [aCoder encodeObject:self.expiresIn forKey:@"expiresIn"]; 83 | [aCoder encodeObject:self.tokenType forKey:@"tokenType"]; 84 | [aCoder encodeInteger:self.authenticationMethod forKey:@"authenticationMethod"]; 85 | [aCoder encodeObject:self.userDisplayName forKey:@"userDisplayName"]; 86 | } 87 | 88 | - (instancetype)initWithCoder:(NSCoder *)aDecoder 89 | { 90 | if (self = [super init]) { 91 | self.userId = [aDecoder decodeObjectForKey:@"userId"]; 92 | self.baseURL = [aDecoder decodeObjectForKey:@"baseURL"]; 93 | self.userName = [aDecoder decodeObjectForKey:@"userName"]; 94 | self.accessToken = [aDecoder decodeObjectForKey:@"accessToken"]; 95 | self.refreshToken = [aDecoder decodeObjectForKey:@"refreshToken"]; 96 | self.expiresIn = [aDecoder decodeObjectForKey:@"tokenType"]; 97 | self.tokenType = [aDecoder decodeObjectForKey:@"tokenType"]; 98 | self.authenticationMethod = [aDecoder decodeIntegerForKey:@"authenticationMethod"]; 99 | self.userDisplayName = [aDecoder decodeObjectForKey:@"userDisplayName"]; 100 | 101 | } 102 | return self; 103 | } 104 | 105 | @end 106 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/OCErrorMsg.h: -------------------------------------------------------------------------------- 1 | // 2 | // OCErrorMsg.h 3 | // Owncloud iOs Client 4 | // 5 | // Copyright (C) 2016, ownCloud GmbH. ( http://www.owncloud.org/ ) 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | 26 | 27 | #define kOCErrorServerBadRequest 400 28 | #define kOCErrorServerUnauthorized 401 29 | #define kOCErrorServerForbidden 403 30 | #define kOCErrorServerPathNotFound 404 31 | #define kOCErrorServerMethodNotPermitted 405 32 | #define kOCErrorProxyAuth 407 33 | #define kOCErrorServerTimeout 408 34 | #define kOCErrorServerConflict 409 35 | #define kOCErrorServerInternalError 500 36 | #define kOCErrorServerNotImplemented 501 37 | #define kOCErrorServerBadGateway 502 38 | #define kOCErrorServerMaintenanceError 503 39 | #define kOCErrorServerInsufficientStorage 507 40 | 41 | #define kOCErrorSharedAPIWrong 400 42 | #define kOCSharedAPISuccessful 100 43 | #define kOCShareeAPISuccessful 200 44 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/OCFileDto.h: -------------------------------------------------------------------------------- 1 | // 2 | // OCFileDto.h 3 | // Owncloud iOs Client 4 | // 5 | // Copyright (C) 2016, ownCloud GmbH. ( http://www.owncloud.org/ ) 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | // 26 | 27 | #import 28 | 29 | @interface OCFileDto : NSObject 30 | 31 | @property (nonatomic, copy) NSString *filePath; 32 | @property (nonatomic, copy) NSString *fileName; 33 | @property BOOL isDirectory; 34 | @property long size; 35 | @property long date; 36 | @property (nonatomic, copy) NSString *etag; 37 | @property (nonatomic, copy) NSString *permissions; 38 | @property (nonatomic, copy) NSString *ocId; 39 | @property (nonatomic, copy) NSString *ocPrivatelink; 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/OCFileDto.m: -------------------------------------------------------------------------------- 1 | // 2 | // OCFileDto.m 3 | // OCCommunicationLib 4 | // 5 | // Copyright (C) 2016, ownCloud GmbH. ( http://www.owncloud.org/ ) 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | 26 | 27 | #import "OCFileDto.h" 28 | 29 | @implementation OCFileDto 30 | 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/OCFrameworkConstants.h: -------------------------------------------------------------------------------- 1 | // 2 | // OCFrameworkConstants.h 3 | // Owncloud iOs Client 4 | // 5 | // Copyright (C) 2016, ownCloud GmbH. ( http://www.owncloud.org/ ) 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | 26 | //Timeout to weddav requests 27 | #define k_timeout_webdav 30 //seconds 28 | 29 | //Timeout to upload 30 | #define k_timeout_upload 40 //seconds 31 | 32 | //Timeout for fast requests 33 | #define k_timeout_fast 5 //seconds 34 | 35 | //Chunk length 36 | #define k_OC_lenght_chunk 1048576 37 | 38 | #define k_domain_error_code @"com.owncloud" 39 | 40 | //URL for webdav 41 | //#define k_url_webdav_server @"remote.php/odav/" 42 | #define k_url_webdav_server @"remote.php/webdav/" 43 | #define k_url_webdav_server_without_last_slash @"remote.php/webdav" 44 | #define k_url_webdav_server_with_first_slash @"/remote.php/webdav/" 45 | 46 | 47 | //URL path for list of files in web interface 48 | #define k_url_path_list_of_files_in_web @"index.php/apps/files" 49 | #define k_url_files_share_link @"apps/files/" 50 | #define k_url_files_private_link @"/remote.php/dav/files/" 51 | 52 | //URL to access user data API 53 | #define k_api_user_url_json @"ocs/v1.php/cloud/user?format=json" 54 | #define k_json_ocs @"ocs" 55 | #define k_json_ocs_data @"data" 56 | #define k_json_ocs_data_display_name @"display-name" 57 | #define k_json_ocs_data_user_id @"id" 58 | 59 | //Url to access to Shared API to create 60 | #define k_url_acces_shared_api @"ocs/v1.php/apps/files_sharing/api/v1/shares" 61 | 62 | //Url to access to Remote Shared API 63 | #define k_url_acces_remote_shared_api @"ocs/v1.php/apps/files_sharing/api/v1/remote_shares" 64 | 65 | //Url to access to Sharee API 66 | #define k_url_access_sharee_api @"ocs/v2.php/apps/files_sharing/api/v1/sharees" 67 | 68 | //Url to access to Capabilities API 69 | #define k_url_capabilities @"ocs/v1.php/cloud/capabilities" 70 | 71 | //Url to access to Remote Thumbnails 72 | //api/v1/thumbnail/{x}/{y}/{file} 73 | #define k_url_thumbnails @"index.php/apps/files/api/v1/thumbnail" 74 | 75 | //Version of the server that have share API 76 | #define k_version_support_shared [NSArray arrayWithObjects: @"5", @"0", @"27", nil] 77 | 78 | //Version of the server that have sharee API 79 | #define k_version_support_sharee_api [NSArray arrayWithObjects: @"8", @"2", @"0", nil] 80 | 81 | //Version of the server that supports cookies 82 | #define k_version_support_cookies [NSArray arrayWithObjects: @"7", @"0", @"0", nil] 83 | 84 | //Version of the server that supports forbidden characters 85 | #define k_version_support_forbidden_characters [NSArray arrayWithObjects: @"8", @"1", @"0", nil] 86 | 87 | //Version of the server that supports Capabilities 88 | #define k_version_support_capabilities [NSArray arrayWithObjects: @"8", @"2", @"0", nil] 89 | 90 | //Version of the server that supports enable/disabled share privilege option for federated shares 91 | #define k_version_support_share_option_fed_share [NSArray arrayWithObjects: @"9", @"1", @"0", nil] 92 | 93 | //Version of the server that supports multiple share links and public share links with option to change the name of the link 94 | #define k_version_support_public_share_link_option_name [NSArray arrayWithObjects: @"10", @"0", @"0", nil] 95 | 96 | //Version of the server that supports enable/disabled upload only (file listing, write only) option for public links of folders 97 | #define k_version_support_public_share_link_option_upload_only [NSArray arrayWithObjects: @"10", @"0", @"1", nil] 98 | 99 | //Name of the session using for upload files with NSURLSession 100 | #define k_session_name @"com.owncloud.upload.session" 101 | 102 | //Name of the download session using for download files with NSURLSession 103 | #define k_download_session_name @"com.owncloud.download.session" 104 | 105 | //Name of the download session using for download files with NSURLSession in ownCloudExtApp 106 | #define k_download_session_name_ext_app @"com.owncloud.download.session.extApp.extension" 107 | 108 | //Name of the download session using for download files with NSURLSession 109 | #define k_download_folder_session_name @"com.owncloud.download.folder.session" 110 | 111 | //Name of the download session using for download files with NSURLSession 112 | #define k_network_operation_session_name @"com.owncloud.network.operation.session" 113 | 114 | //Name of the container to configure NSURLSessions 115 | #define k_shared_container_identifier @"group.com.owncloud.iOSmobileapp"; 116 | 117 | 118 | 119 | 120 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/OCOAuth2Authentication/OCCredentialsStorage.h: -------------------------------------------------------------------------------- 1 | // 2 | // OCCredentialsStorage.h 3 | // ownCloud iOS library 4 | // 5 | // Created by Noelia Alvarez on 30/08/2017. 6 | // 7 | // Copyright (C) 2017, ownCloud GmbH. ( http://www.owncloud.org/ ) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | 28 | #import 29 | 30 | @class OCCredentialsDto; 31 | 32 | @protocol OCCredentialsStorageDelegate 33 | 34 | 35 | - (void)saveCredentials:(OCCredentialsDto *)credDto; 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/OCOAuth2Authentication/OCOAuth2Configuration.h: -------------------------------------------------------------------------------- 1 | // 2 | // OCOAuth2Configuration.h 3 | // ownCloud iOS library 4 | // 5 | // Created by Noelia Alvarez on 28/08/2017. 6 | // 7 | // Copyright (C) 2017, ownCloud GmbH. ( http://www.owncloud.org/ ) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | 28 | #import 29 | 30 | @interface OCOAuth2Configuration : NSObject 31 | 32 | @property (nonatomic, copy) NSString *clientId; 33 | @property (nonatomic, copy) NSString *clientSecret; 34 | @property (nonatomic, copy) NSString *redirectUri; 35 | @property (nonatomic, copy) NSString *authorizationEndpoint; 36 | @property (nonatomic, copy) NSString *tokenEndpoint; 37 | 38 | - (id)initWithClientId:(NSString *)clientId clientSecret:(NSString *)clientSecret redirectUri:(NSString *)redirectUri authorizationEndpoint:(NSString *)authorizationEndpoint tokenEndpoint:(NSString *)tokenEndpoint; 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/OCOAuth2Authentication/OCOAuth2Configuration.m: -------------------------------------------------------------------------------- 1 | // 2 | // OCOAuth2Configuration.m 3 | // ownCloud iOS library 4 | // 5 | // Created by Noelia Alvarez on 28/08/2017. 6 | // 7 | // Copyright (C) 2017, ownCloud GmbH. ( http://www.owncloud.org/ ) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | 28 | #import "OCOAuth2Configuration.h" 29 | 30 | @implementation OCOAuth2Configuration 31 | 32 | 33 | - (id)initWithClientId:(NSString *)clientId clientSecret:(NSString *)clientSecret redirectUri:(NSString *)redirectUri authorizationEndpoint:(NSString *)authorizationEndpoint tokenEndpoint:(NSString *)tokenEndpoint { 34 | 35 | self = [super init]; 36 | if (self) { 37 | // Custom initialization 38 | _clientId = clientId; 39 | _clientSecret = clientSecret; 40 | _redirectUri = redirectUri; 41 | _authorizationEndpoint = authorizationEndpoint; 42 | _tokenEndpoint = tokenEndpoint; 43 | } 44 | return self; 45 | } 46 | 47 | @end 48 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/OCOAuth2Authentication/OCOAuth2Manager.h: -------------------------------------------------------------------------------- 1 | // 2 | // OCOAuth2Manager.h 3 | // ownCloud iOS library 4 | // 5 | // Created by Noelia Alvarez on 28/08/2017. 6 | // 7 | // Copyright (C) 2017, ownCloud GmbH. ( http://www.owncloud.org/ ) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | 28 | #import 29 | #import "OCCredentialsDto.h" 30 | #import "OCCommunication.h" 31 | #import "OCOAuth2Configuration.h" 32 | #import "UtilsFramework.h" 33 | #import "OCFrameworkConstants.h" 34 | #import "OCCredentialsDto.h" 35 | #import "OCTrustedCertificatesStore.h" 36 | 37 | 38 | @interface OCOAuth2Manager : NSObject 39 | 40 | 41 | @property (nonatomic, strong) id trustedCertificatesStore; 42 | 43 | 44 | - (NSURL *) getOAuth2URLToGetAuthCodeByOAuth2Configuration:(OCOAuth2Configuration *)oauth2Configuration 45 | withServerPath:(NSString *)serverPath; 46 | 47 | 48 | /** 49 | * Method to get the auth data by the auth code 50 | * 51 | * @param baseURL -> NSString with the url of the path obteined from method getOAuth2URLToGetTokenByOAuth2Configuration:withServerPath: 52 | * @param oauth2Configuration -> OCOAuth2Configuration with all the oauth parameters 53 | * @param authCode -> NSString with the auth code 54 | * @param userAgent -> NSString with the custom user agent or nil 55 | * 56 | **/ 57 | 58 | - (void) authDataByOAuth2Configuration:(OCOAuth2Configuration *)oauth2Configuration 59 | withBaseURL:(NSString *)baseURL 60 | authCode:(NSString *)authCode 61 | userAgent:(NSString *)userAgent 62 | withCompletion:(void(^)(OCCredentialsDto *userCredDto, NSError *error))completion; 63 | 64 | /** 65 | * Method to get the new auth data by the oauth refresh token 66 | * 67 | * @param baseURL -> NSString with the url of the path 68 | * Ex: http://www.myowncloudserver.com/owncloud/remote.php/webdav/Music 69 | * 70 | * @param refreshToken -> NSString with the refreshToken 71 | * @param oauth2Configuration -> OCOAuth2Configuration with all the oauth parameters 72 | * @param userAgent -> NSString with the custom user agent or nil 73 | * 74 | **/ 75 | 76 | - (void) refreshAuthDataByOAuth2Configuration:(OCOAuth2Configuration *)oauth2Configuration 77 | withBaseURL:(NSString *)baseURL 78 | refreshToken:(NSString *)refreshToken 79 | userAgent:(NSString *)userAgent 80 | success:(void(^)(OCCredentialsDto *userCredDto))success 81 | failure:(void(^)(NSError *error))failure; 82 | 83 | 84 | 85 | @end 86 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/OCServerFeatures.h: -------------------------------------------------------------------------------- 1 | // 2 | // OCServerFeatures.h 3 | // ownCloud iOS library 4 | // 5 | // Created by Noelia Alvarez on 05/04/17. 6 | // 7 | // Copyright (C) 2017, ownCloud GmbH. ( http://www.owncloud.org/ ) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | 28 | @interface OCServerFeatures : NSObject 29 | 30 | @property BOOL hasShareSupport; 31 | @property BOOL hasShareeSupport; 32 | @property BOOL hasCookiesSupport; 33 | @property BOOL hasForbiddenCharactersSupport; 34 | @property BOOL hasCapabilitiesSupport; 35 | @property BOOL hasFedSharesOptionShareSupport; 36 | @property BOOL hasPublicShareLinkOptionNameSupport; 37 | @property BOOL hasPublicShareLinkOptionUploadOnlySupport; 38 | 39 | 40 | - (id)initWithSupportForShare:(BOOL)share sharee:(BOOL)sharee cookies:(BOOL)cookies forbiddenCharacters:(BOOL)forbiddenCharacters capabilities:(BOOL)capabilites fedSharesOptionShare:(BOOL)fedSharesOptionShare publicShareLinkOptionName:(BOOL)publicShareLinkOptionName publicShareLinkOptionUploadOnlySupport:(BOOL)publicShareLinkOptionUploadOnlySupport; 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/OCServerFeatures.m: -------------------------------------------------------------------------------- 1 | // 2 | // OCServerFeatures.m 3 | // ownCloud iOS library 4 | // 5 | // Created by Noelia Alvarez on 05/04/17. 6 | // 7 | // Copyright (C) 2017, ownCloud GmbH. ( http://www.owncloud.org/ ) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | 28 | 29 | #import "OCServerFeatures.h" 30 | 31 | @implementation OCServerFeatures 32 | 33 | - (id)initWithSupportForShare:(BOOL)share sharee:(BOOL)sharee cookies:(BOOL)cookies forbiddenCharacters:(BOOL)forbiddenCharacters capabilities:(BOOL)capabilites fedSharesOptionShare:(BOOL)fedSharesOptionShare publicShareLinkOptionName:(BOOL)publicShareLinkOptionName publicShareLinkOptionUploadOnlySupport:(BOOL)publicShareLinkOptionUploadOnlySupport { 34 | 35 | self = [super init]; 36 | if (self) { 37 | // Custom initialization 38 | _hasShareSupport = share; 39 | _hasShareeSupport = sharee; 40 | _hasCookiesSupport = cookies; 41 | _hasForbiddenCharactersSupport = forbiddenCharacters; 42 | _hasCapabilitiesSupport = capabilites; 43 | _hasFedSharesOptionShareSupport = fedSharesOptionShare; 44 | _hasPublicShareLinkOptionNameSupport = publicShareLinkOptionName; 45 | _hasPublicShareLinkOptionUploadOnlySupport = publicShareLinkOptionUploadOnlySupport; 46 | 47 | } 48 | 49 | return self; 50 | } 51 | 52 | - (BOOL)isEqual:(id)other { 53 | if (other == self) 54 | return YES; 55 | if (!other || ![other isKindOfClass:[self class]]) 56 | return NO; 57 | OCServerFeatures *castedOther = (OCServerFeatures *)other; 58 | return (castedOther.hasShareSupport == self.hasShareSupport && 59 | castedOther.hasShareeSupport == self.hasShareeSupport && 60 | castedOther.hasCookiesSupport == self.hasCookiesSupport && 61 | castedOther.hasForbiddenCharactersSupport == self.hasForbiddenCharactersSupport && 62 | castedOther.hasCapabilitiesSupport == self.hasCapabilitiesSupport && 63 | castedOther.hasFedSharesOptionShareSupport == self.hasFedSharesOptionShareSupport && 64 | castedOther.hasPublicShareLinkOptionNameSupport == self.hasPublicShareLinkOptionNameSupport && 65 | castedOther.hasPublicShareLinkOptionUploadOnlySupport == self.hasPublicShareLinkOptionUploadOnlySupport 66 | ); 67 | 68 | } 69 | 70 | @end 71 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/OCShareUser.h: -------------------------------------------------------------------------------- 1 | // 2 | // OCShareUser.h 3 | // ownCloud iOS library 4 | // 5 | // Created by Gonzalo Gonzalez on 28/9/15. 6 | // 7 | // Copyright (C) 2016, ownCloud GmbH. ( http://www.owncloud.org/ ) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | // 28 | 29 | #import 30 | #import "OCSharedDto.h" 31 | 32 | @interface OCShareUser : NSObject 33 | 34 | @property (nonatomic, strong) NSString *name; 35 | @property (nonatomic, strong) NSString *displayName; 36 | @property (nonatomic, strong) NSString *server; 37 | @property BOOL isDisplayNameDuplicated; 38 | @property NSInteger shareeType; 39 | 40 | @property (nonatomic, strong) OCSharedDto * sharedDto; 41 | 42 | @end 43 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/OCShareUser.m: -------------------------------------------------------------------------------- 1 | // 2 | // OCShareUser.m 3 | // ownCloud iOS library 4 | // 5 | // Created by Gonzalo Gonzalez on 28/9/15. 6 | // 7 | // Copyright (C) 2016, ownCloud GmbH. ( http://www.owncloud.org/ ) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | // 28 | 29 | #import "OCShareUser.h" 30 | 31 | @implementation OCShareUser 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/OCSharedDto.h: -------------------------------------------------------------------------------- 1 | // 2 | // OCSharedDto.h 3 | // OCCommunicationLib 4 | // 5 | // Copyright (C) 2017, ownCloud GmbH. ( http://www.owncloud.org/ ) 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | // 26 | 27 | #import 28 | 29 | @interface OCSharedDto : NSObject 30 | 31 | typedef enum { 32 | shareTypeUser = 0, 33 | shareTypeGroup = 1, 34 | shareTypeLink = 3, 35 | shareTypeEmail = 4, 36 | shareTypeContact = 5, 37 | shareTypeRemote = 6 38 | } enumShareType; 39 | 40 | @property NSInteger idRemoteShared; 41 | @property BOOL isDirectory; 42 | @property NSInteger itemSource; 43 | @property NSInteger parent; 44 | @property NSInteger shareType; 45 | @property (nonatomic, copy) NSString *shareWith; 46 | @property NSInteger fileSource; 47 | @property (nonatomic, copy) NSString *path; 48 | @property NSInteger permissions; 49 | @property long sharedDate; 50 | @property long expirationDate; 51 | @property (nonatomic, copy) NSString *token; 52 | @property NSInteger storage; 53 | @property NSInteger mailSend; 54 | @property (nonatomic, copy) NSString *uidOwner; 55 | @property (nonatomic, copy) NSString *shareWithDisplayName; 56 | @property (nonatomic, copy) NSString *displayNameOwner; 57 | @property (nonatomic, copy) NSString *uidFileOwner; 58 | @property (nonatomic, copy) NSString *fileTarget; 59 | @property (nonatomic, copy) NSString *name; 60 | @property (nonatomic, copy) NSString *url; 61 | 62 | 63 | - (id)initWithSharedDto:(OCSharedDto *)oSharedDto; 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/OCSharedDto.m: -------------------------------------------------------------------------------- 1 | // 2 | // OCSharedDto.m 3 | // Owncloud iOs Client 4 | // 5 | // Copyright (C) 2017, ownCloud GmbH. ( http://www.owncloud.org/ ) 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | 26 | #import "OCSharedDto.h" 27 | 28 | @implementation OCSharedDto 29 | 30 | - (id)initWithSharedDto:(OCSharedDto *)oSharedDto{ 31 | 32 | self = [super init]; 33 | if (self) { 34 | // Custom initialization 35 | _idRemoteShared = oSharedDto.idRemoteShared; 36 | _isDirectory = oSharedDto.isDirectory; 37 | _itemSource = oSharedDto.itemSource; 38 | _parent = oSharedDto.parent; 39 | _shareType = oSharedDto.shareType; 40 | _shareWith = oSharedDto.shareWith; 41 | _fileSource = oSharedDto.fileSource; 42 | _path = oSharedDto.path; 43 | _permissions = oSharedDto.permissions; 44 | _sharedDate = oSharedDto.sharedDate; 45 | _expirationDate = oSharedDto.expirationDate; 46 | _token = oSharedDto.token; 47 | _storage = oSharedDto.storage; 48 | _mailSend= oSharedDto.mailSend; 49 | _uidOwner = oSharedDto.uidOwner; 50 | _shareWithDisplayName= oSharedDto.shareWithDisplayName; 51 | _displayNameOwner = oSharedDto.displayNameOwner; 52 | _uidFileOwner = oSharedDto.uidFileOwner; 53 | _fileTarget = oSharedDto.fileTarget; 54 | _name = oSharedDto.name; 55 | _url= oSharedDto.url; 56 | } 57 | 58 | return self; 59 | } 60 | 61 | @end 62 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/OCTrustedCertificatesStore.h: -------------------------------------------------------------------------------- 1 | // 2 | // OCTrustedCertificatesStore.h 3 | // ownCloud iOS library 4 | // 5 | // Created by David A. Velasco on 28/9/17. 6 | // 7 | // Copyright (C) 2017, ownCloud GmbH. ( http://www.owncloud.org/ ) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | 28 | 29 | #ifndef OCTrustedCertificatesStore_h 30 | #define OCTrustedCertificatesStore_h 31 | 32 | #import 33 | 34 | @protocol OCTrustedCertificatesStore 35 | 36 | 37 | /* 38 | * Checks if the challenge passed as a parameter corresponds to server certificate not trusted by iOS system, 39 | * and if it is trusted by the user anyway, searching for it in the app-level store of certificates that 40 | * were previously approved by her. 41 | */ 42 | - (BOOL) isTrustedServerCertificateIn:(NSURLAuthenticationChallenge *) challenge; 43 | 44 | @end 45 | 46 | #endif /* OCTrustedCertificatesStore_h */ 47 | 48 | 49 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/OCWebDavClient/NSDate+ISO8601.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSDate+ISO8601.h 3 | // OCWebDAVClient.h 4 | // 5 | // This class is based in https://github.com/zwaldowski/DZWebDAVClient. Copyright (c) 2012 Zachary Waldowski, Troy Brant, Marcus Rohrmoser, and Sam Soffes. 6 | // 7 | // Copyright (C) 2016, ownCloud GmbH. ( http://www.owncloud.org/ ) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | 28 | 29 | 30 | #import 31 | 32 | /** 33 | Provides extensions to `NSDate` for representing ISO8601-formatted strings. 34 | */ 35 | @interface NSDate (ISO8601) 36 | 37 | /** 38 | Returns a new date represented by an ISO8601 string. 39 | 40 | @param iso8601String An ISO8601 string 41 | 42 | @return Date represented by the ISO8601 string 43 | 44 | @bug [Issue #56](https://github.com/samsoffes/sstoolkit/issues/56): Currently this method doesn't work with 45 | strings that include a timezone as anything other than "Z" like this one 46 | "2011-02-01T10:57:55-08:00". 47 | */ 48 | + (NSDate *)dateFromISO8601String:(NSString *)iso8601String; 49 | 50 | /** 51 | Returns a string representation of the receiver in ISO8601 format. 52 | 53 | @return A string representation of the receiver in ISO8601 format. 54 | */ 55 | - (NSString *)ISO8601String; 56 | 57 | @end 58 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/OCWebDavClient/NSDate+ISO8601.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSDate+ISO8601.m 3 | // OCWebDAVClient 4 | // 5 | // This class is based in https://github.com/zwaldowski/DZWebDAVClient. Copyright (c) 2012 Zachary Waldowski, Troy Brant, Marcus Rohrmoser, and Sam Soffes. 6 | // 7 | // Copyright (C) 2016, ownCloud GmbH. ( http://www.owncloud.org/ ) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | 28 | 29 | #import "NSDate+ISO8601.h" 30 | #include 31 | 32 | @implementation NSDate (ISO8601) 33 | 34 | + (NSDate *)dateFromISO8601String:(NSString *)value { 35 | if (!value.length) 36 | return nil; 37 | 38 | struct tm tm; 39 | strptime(value.UTF8String, "%Y-%m-%dT%H:%M:%S%z", &tm); 40 | time_t t = mktime(&tm); 41 | 42 | return [NSDate dateWithTimeIntervalSince1970:t + [[NSTimeZone localTimeZone] secondsFromGMT]]; 43 | } 44 | 45 | 46 | - (NSString *)ISO8601String { 47 | struct tm *timeinfo; 48 | char buffer[80]; 49 | 50 | time_t rawtime = (time_t)[self timeIntervalSince1970]; 51 | timeinfo = gmtime(&rawtime); 52 | 53 | strftime(buffer, 80, "%Y-%m-%dT%H:%M:%SZ", timeinfo); 54 | 55 | return [NSString stringWithCString:buffer encoding:NSUTF8StringEncoding]; 56 | } 57 | 58 | 59 | @end 60 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/OCWebDavClient/NSDate+RFC1123.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSDate+RFC1123.h 3 | // OCWebDAVClient.h 4 | // 5 | // This class is based in https://github.com/zwaldowski/DZWebDAVClient. Copyright (c) 2012 Zachary Waldowski, Troy Brant, Marcus Rohrmoser, and Sam Soffes. 6 | // 7 | // Copyright (C) 2016, ownCloud GmbH. ( http://www.owncloud.org/ ) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | 28 | 29 | #import 30 | 31 | /** 32 | * Provides extensions to `NSDate` for representing RFC1123-formatted strings. 33 | * 34 | * Based on the [W3 specification](http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1) and ["NSDateFormatter & HTTP Header"](http://blog.mro.name/2009/08/nsdateformatter-http-header/). 35 | */ 36 | @interface NSDate (RFC1123) 37 | 38 | /** 39 | Convert a RFC1123 'Full-Date' string (http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1) into NSDate. 40 | @param value something like either @"Fri, 14 Aug 2009 14:45:31 GMT" or @"Sunday, 06-Nov-94 08:49:37 GMT" or @"Sun Nov 6 08:49:37 1994" 41 | @return nil if not parseable. 42 | */ 43 | + (NSDate *)dateFromRFC1123String:(NSString *)value; 44 | 45 | /** 46 | Convert NSDate into a RFC1123 'Full-Date' string (http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.3.1). 47 | @return something like @"Fri, 14 Aug 2009 14:45:31 GMT" 48 | */ 49 | - (NSString *)RFC1123String; 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/OCWebDavClient/NSDate+RFC1123.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSDate+RFC1123.h 3 | // OCWebDAVClient 4 | // 5 | // This class is based in https://github.com/zwaldowski/DZWebDAVClient. Copyright (c) 2012 Zachary Waldowski, Troy Brant, Marcus Rohrmoser, and Sam Soffes. 6 | // 7 | // Copyright (C) 2016, ownCloud GmbH. ( http://www.owncloud.org/ ) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | 28 | 29 | #import "NSDate+RFC1123.h" 30 | 31 | static NSDateFormatter *RFC1123Formatter(void) { 32 | static NSDateFormatter *formatter = nil; 33 | static dispatch_once_t onceToken; 34 | dispatch_once(&onceToken, ^{ 35 | formatter = [NSDateFormatter new]; 36 | formatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]; 37 | formatter.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"GMT"]; 38 | formatter.dateFormat = @"EEE',' dd MMM yyyy HH':'mm':'ss z"; 39 | }); 40 | return formatter; 41 | } 42 | 43 | static NSDateFormatter *RFC850Formatter(void) { 44 | static NSDateFormatter *formatter = nil; 45 | static dispatch_once_t onceToken; 46 | dispatch_once(&onceToken, ^{ 47 | formatter = [NSDateFormatter new]; 48 | formatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]; 49 | formatter.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"GMT"]; 50 | formatter.dateFormat = @"EEEE',' dd'-'MMM'-'yy HH':'mm':'ss z"; 51 | }); 52 | return formatter; 53 | } 54 | 55 | static NSDateFormatter *ASCTimeFormatter(void) { 56 | static NSDateFormatter *formatter = nil; 57 | static dispatch_once_t onceToken; 58 | dispatch_once(&onceToken, ^{ 59 | formatter = [NSDateFormatter new]; 60 | formatter.locale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"]; 61 | formatter.timeZone = [NSTimeZone timeZoneWithAbbreviation:@"GMT"]; 62 | formatter.dateFormat = @"EEE MMM d HH':'mm':'ss yyyy"; 63 | }); 64 | return formatter; 65 | } 66 | 67 | @implementation NSDate (RFC1123) 68 | 69 | + (NSDate *)dateFromRFC1123String:(NSString *)value { 70 | if (!value.length) 71 | return nil; 72 | 73 | return [RFC1123Formatter() dateFromString: value] ?: [RFC850Formatter() dateFromString: value] ?: [ASCTimeFormatter() dateFromString: value]; 74 | } 75 | 76 | - (NSString *)RFC1123String { 77 | return [RFC1123Formatter() stringFromDate: self]; 78 | } 79 | 80 | @end 81 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/OCWebDavClient/Parsers/OCXMLParser.h: -------------------------------------------------------------------------------- 1 | // 2 | // OCXMLParser.h 3 | // webdav 4 | // 5 | // Copyright (C) 2016, ownCloud GmbH. ( http://www.owncloud.org/ ) 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | 26 | #import 27 | #import "OCFileDto.h" 28 | 29 | 30 | @interface OCXMLParser : NSObject { 31 | 32 | NSMutableString *_xmlChars; 33 | NSMutableDictionary *_xmlBucket; 34 | NSMutableArray *_directoryList; 35 | OCFileDto *_currentFile; 36 | BOOL isNotFirstFileOfList; 37 | 38 | } 39 | 40 | @property(nonatomic,strong) NSMutableArray *directoryList; 41 | @property(nonatomic,strong) OCFileDto *currentFile; 42 | 43 | - (void)initParserWithData: (NSData*)data; 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/OCWebDavClient/Parsers/OCXMLParser.m: -------------------------------------------------------------------------------- 1 | // 2 | // OCXMLParser.m 3 | // webdav 4 | // 5 | // Copyright (C) 2016, ownCloud GmbH. ( http://www.owncloud.org/ ) 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | 26 | 27 | #import "OCXMLParser.h" 28 | #import "NSString+Encode.h" 29 | 30 | NSString *OCCWebDAVContentTypeKey = @"contenttype"; 31 | NSString *OCCWebDAVETagKey = @"etag"; 32 | NSString *OCCWebDAVHREFKey = @"href"; 33 | NSString *OCCWebDAVURIKey = @"uri"; 34 | 35 | @implementation OCXMLParser 36 | 37 | @synthesize directoryList=_directoryList; 38 | @synthesize currentFile=_currentFile; 39 | 40 | /* 41 | * Method that init the parse with the xml data from the server 42 | * @data -> XML webDav data from the owncloud server 43 | */ 44 | - (void)initParserWithData: (NSData*)data{ 45 | 46 | _directoryList = [[NSMutableArray alloc]init]; 47 | 48 | NSXMLParser *parser = [[NSXMLParser alloc] initWithData:data]; 49 | [parser setDelegate:self]; 50 | [parser parse]; 51 | 52 | } 53 | 54 | 55 | #pragma mark - XML Parser Delegate Methods 56 | 57 | 58 | /* 59 | * Method that init parse process. 60 | */ 61 | 62 | - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict { 63 | 64 | if (!_xmlChars) { 65 | _xmlChars = [NSMutableString string]; 66 | } 67 | 68 | //NSLog(@"_xmlChars: %@", _xmlChars); 69 | 70 | [_xmlChars setString:@""]; 71 | 72 | if ([elementName isEqualToString:@"d:response"]) { 73 | _xmlBucket = [NSMutableDictionary dictionary]; 74 | } 75 | } 76 | 77 | /* 78 | * Util method to make a NSDate object from a string from xml 79 | * @dateString -> Data string from xml 80 | */ 81 | + (NSDate*)parseDateString:(NSString*)dateString { 82 | //Parse the date in all the formats 83 | NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; 84 | /*In most cases the best locale to choose is "en_US_POSIX", a locale that's specifically designed to yield US English results regardless of both user and system preferences. "en_US_POSIX" is also invariant in time (if the US, at some point in the future, changes the way it formats dates, "en_US" will change to reflect the new behaviour, but "en_US_POSIX" will not). It will behave consistently for all users.*/ 85 | [dateFormatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]]; 86 | //This is the format for the concret locale used 87 | [dateFormatter setDateFormat:@"EEE, dd MMM y HH:mm:ss zzz"]; 88 | 89 | NSDate *theDate = nil; 90 | NSError *error = nil; 91 | if (![dateFormatter getObjectValue:&theDate forString:dateString range:nil error:&error]) { 92 | NSLog(@"Date '%@' could not be parsed: %@", dateString, error); 93 | } 94 | 95 | return theDate; 96 | } 97 | 98 | 99 | - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName { 100 | 101 | // NSLog(@"elementName: %@:%@", elementName,_xmlChars); 102 | 103 | if ([elementName isEqualToString:@"d:href"]) { 104 | 105 | if ([_xmlChars hasPrefix:@"http"]) { 106 | NSURL *junk = [NSURL URLWithString:_xmlChars]; 107 | BOOL trailingSlash = [_xmlChars hasSuffix:@"/"]; 108 | [_xmlChars setString:[junk path]]; 109 | if (trailingSlash) { 110 | [_xmlChars appendString:@"/"]; 111 | } 112 | } 113 | 114 | //If has lenght, there are an item 115 | if ([_xmlChars length]) { 116 | //Create FileDto 117 | _currentFile = [[OCFileDto alloc] init]; 118 | _currentFile.isDirectory = NO; 119 | [_xmlBucket setObject:[_xmlChars copy] forKey:OCCWebDAVURIKey]; 120 | 121 | NSArray *splitedUrl = [_xmlChars componentsSeparatedByString:@"/"]; 122 | 123 | //Check if the item is a folder or a file 124 | if([_xmlChars hasSuffix:@"/"]) { 125 | //It's a folder 126 | NSInteger fileNameLenght = [((NSString *)[splitedUrl objectAtIndex:[splitedUrl count]-2]) length]; 127 | 128 | if ( fileNameLenght > 0) { 129 | //FileDto filepath 130 | _currentFile.filePath = [_xmlChars substringToIndex:[_xmlChars length] - (fileNameLenght+1)]; 131 | } else { 132 | _currentFile.filePath = @"/"; 133 | } 134 | } else { 135 | //It's a file 136 | NSInteger fileNameLenght = [((NSString *)[splitedUrl objectAtIndex:[splitedUrl count]-1]) length]; 137 | if (fileNameLenght > 0) { 138 | _currentFile.filePath = [_xmlChars substringToIndex:[_xmlChars length] - fileNameLenght]; 139 | }else { 140 | _currentFile.filePath = @"/"; 141 | } 142 | } 143 | 144 | 145 | 146 | NSArray *foo = [_xmlChars componentsSeparatedByString: @"/"]; 147 | NSString *lastBit; 148 | 149 | if([_xmlChars hasSuffix:@"/"]) { 150 | lastBit = [foo objectAtIndex: [foo count]-2]; 151 | lastBit = [NSString stringWithFormat:@"%@/",lastBit]; 152 | } else { 153 | lastBit = [foo objectAtIndex: [foo count]-1]; 154 | } 155 | 156 | //NSString *lastBit = [_xmlChars substringFromIndex:_uriLength]; 157 | //NSLog(@"lastBit:- %@",lastBit); 158 | if (isNotFirstFileOfList == YES) { 159 | [_xmlBucket setObject:lastBit forKey:OCCWebDAVHREFKey]; 160 | _currentFile.fileName = lastBit; 161 | } 162 | 163 | NSString *decodedFileName = [self decodeFromPercentEscapeString:self.currentFile.fileName]; 164 | NSString *decodedFilePath = [self decodeFromPercentEscapeString:self.currentFile.filePath]; 165 | 166 | self.currentFile.fileName = [decodedFileName encodeString:NSUTF8StringEncoding]; 167 | self.currentFile.filePath = [decodedFilePath encodeString:NSUTF8StringEncoding]; 168 | 169 | isNotFirstFileOfList = YES; 170 | 171 | // //NSLog(@"1 _xmlBucked :- %@",_xmlBucket); 172 | } 173 | } else if ([elementName isEqualToString:@"d:getlastmodified"]) { 174 | //DATE 175 | // 'Thu, 30 Oct 2008 02:52:47 GMT' 176 | // Monday, 12-Jan-98 09:25:56 GMT 177 | // Value: HTTP-date ; defined in section 3.3.1 of RFC2068 178 | 179 | if ([_xmlChars length]) { 180 | NSDate *d = [[self class] parseDateString:_xmlChars]; 181 | 182 | if (d) { 183 | //FildeDto Date 184 | _currentFile.date = [d timeIntervalSince1970]; 185 | NSInteger colIdx = [elementName rangeOfString:@":"].location; 186 | [_xmlBucket setObject:d forKey:[elementName substringFromIndex:colIdx + 1]]; 187 | } 188 | 189 | else { 190 | NSLog(@"Could not parse date string '%@' for '%@'", _xmlChars, elementName); 191 | } 192 | } 193 | 194 | } else if ([elementName isEqualToString:@"oc:fileid"]) { 195 | _currentFile.ocId = _xmlChars; 196 | } else if ([elementName isEqualToString:@"oc:privatelink"]) { 197 | _currentFile.ocPrivatelink = _xmlChars; 198 | } else if ([elementName hasSuffix:@":getetag"] && [_xmlChars length]) { 199 | //ETAG 200 | #ifdef DEBUG 201 | NSLog(@"getetag: %@", _xmlChars); 202 | #endif 203 | 204 | NSString *stringClean = _xmlChars; 205 | stringClean = [_xmlChars stringByReplacingOccurrencesOfString:@"\"" withString:@""]; 206 | 207 | _currentFile.etag = [stringClean lowercaseString]; 208 | 209 | } else if ([elementName hasSuffix:@":getcontenttype"] && [_xmlChars length]) { 210 | //CONTENT TYPE 211 | [_xmlBucket setObject:[_xmlChars copy] forKey:OCCWebDAVContentTypeKey]; 212 | 213 | } else if([elementName hasSuffix:@"d:getcontentlength"] && [_xmlChars length]) { 214 | //SIZE 215 | //FileDto current size 216 | _currentFile.size = (long)[_xmlChars longLongValue]; 217 | 218 | } else if ([elementName isEqualToString:@"oc:permissions"]) { 219 | _currentFile.permissions = _xmlChars; 220 | 221 | } else if ([elementName isEqualToString:@"d:collection"]) { 222 | _currentFile.isDirectory = YES; 223 | 224 | } else if ([elementName isEqualToString:@"d:response"]) { 225 | //NSLog(@"2 _xmlBucked :- %@",_xmlBucket); 226 | 227 | //Add to directoryList 228 | [_directoryList addObject:_currentFile]; 229 | _currentFile = [[OCFileDto alloc] init]; 230 | 231 | _xmlBucket = nil; 232 | } 233 | 234 | } 235 | 236 | - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string { 237 | [_xmlChars appendString:string]; 238 | } 239 | 240 | - (void)parserDidEndDocument:(NSXMLParser *)parser{ 241 | 242 | #ifdef DEBUG 243 | NSLog(@"Finish xml directory list parse"); 244 | #endif 245 | } 246 | 247 | // Decode a percent escape encoded string. 248 | - (NSString*) decodeFromPercentEscapeString:(NSString *) string { 249 | return (__bridge NSString *) CFURLCreateStringByReplacingPercentEscapes(NULL, 250 | (__bridge CFStringRef) string, 251 | CFSTR("") 252 | ); 253 | } 254 | 255 | 256 | 257 | @end 258 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/OCWebDavClient/Parsers/OCXMLServerErrorsParser.h: -------------------------------------------------------------------------------- 1 | // 2 | // OCXMLServerErrorsParser.h 3 | // ownCloud iOS library 4 | // 5 | // Created by Gonzalo González on 1/6/15. 6 | // 7 | // Copyright (C) 2016, ownCloud GmbH. ( http://www.owncloud.org/ ) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | 28 | #import 29 | 30 | typedef void(^OCServerErrorFinishBlock)(NSError *error); 31 | 32 | 33 | @interface OCXMLServerErrorsParser : NSObject 34 | 35 | @property (nonatomic, strong) NSString *xmlString; 36 | @property (nonatomic, strong) NSMutableDictionary *resultDict; 37 | 38 | @property (nonatomic, strong) NSString *exception; 39 | @property (nonatomic, strong) NSString *message; 40 | 41 | 42 | @property (nonatomic, copy) OCServerErrorFinishBlock finishBlock; 43 | 44 | 45 | - (void) startToParseWithData:(NSData *)data withCompleteBlock: (void(^)(NSError *error)) completeBlock; 46 | 47 | 48 | @end 49 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/OCWebDavClient/Parsers/OCXMLServerErrorsParser.m: -------------------------------------------------------------------------------- 1 | // 2 | // OCXMLServerErrorsParser.m 3 | // ownCloud iOS library 4 | // 5 | // Created by Gonzalo González on 1/6/15. 6 | // 7 | 8 | // Copyright (C) 2016, ownCloud GmbH. ( http://www.owncloud.org/ ) 9 | // 10 | // Permission is hereby granted, free of charge, to any person obtaining a copy 11 | // of this software and associated documentation files (the "Software"), to deal 12 | // in the Software without restriction, including without limitation the rights 13 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | // copies of the Software, and to permit persons to whom the Software is 15 | // furnished to do so, subject to the following conditions: 16 | 17 | // The above copyright notice and this permission notice shall be included in 18 | // all copies or substantial portions of the Software. 19 | 20 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 21 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 22 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 23 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 24 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 25 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 26 | // THE SOFTWARE. 27 | // 28 | 29 | #import "OCXMLServerErrorsParser.h" 30 | #import "UtilsFramework.h" 31 | #import "OCErrorMsg.h" 32 | #import "OCCommunication.h" 33 | 34 | #define k_excepcion_element @"s:exception" 35 | #define k_message_element @"s:message" 36 | 37 | #define k_forbidden_character_error @"InvalidPath" 38 | #define k_forbidden @"Forbidden" 39 | 40 | NSString *OCErrorException = @"oc_exception"; 41 | NSString *OCErrorMessage = @"oc_message"; 42 | 43 | 44 | @implementation OCXMLServerErrorsParser 45 | 46 | 47 | - (void) startToParseWithData:(NSData *)data withCompleteBlock: (void(^)(NSError *error)) completeBlock{ 48 | 49 | self.finishBlock = ^(NSError *err) { 50 | 51 | completeBlock(err); 52 | }; 53 | 54 | if (!data) { 55 | NSError *error = nil; 56 | 57 | self.finishBlock(error); 58 | }else{ 59 | NSXMLParser *parser = [[NSXMLParser alloc] initWithData:data]; 60 | [parser setDelegate:self]; 61 | [parser parse]; 62 | 63 | if (self.resultDict.count == 0) { 64 | NSError *error = nil; 65 | self.finishBlock(error); 66 | } 67 | } 68 | 69 | 70 | } 71 | 72 | 73 | #pragma mark - XML Parser Delegate Methods 74 | 75 | - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict { 76 | 77 | if (!self.xmlString) { 78 | self.xmlString = [NSMutableString string]; 79 | } 80 | 81 | //NSLog(@"xml String: %@", self.xmlString); 82 | 83 | if (!self.resultDict) { 84 | self.resultDict = [NSMutableDictionary dictionary]; 85 | } 86 | 87 | } 88 | 89 | - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName { 90 | 91 | if ([elementName isEqualToString:k_excepcion_element]) { 92 | 93 | if (self.xmlString) { 94 | //Get the lastObject where is the exception name 95 | NSArray *splitedUrl = [self.xmlString componentsSeparatedByString:@"\\"]; 96 | [self.resultDict setObject:[splitedUrl lastObject] forKey:OCErrorException]; 97 | } 98 | } 99 | 100 | if ([elementName isEqualToString:k_message_element]) { 101 | 102 | if (self.xmlString) { 103 | [self.resultDict setObject:self.xmlString forKey:OCErrorMessage]; 104 | } 105 | } 106 | 107 | 108 | } 109 | 110 | - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string { 111 | self.xmlString = string; 112 | } 113 | 114 | - (void)parserDidEndDocument:(NSXMLParser *)parser{ 115 | 116 | //NSLog(@"Finish: %@", self.resultDict); 117 | 118 | [self checkTheResultLookingForErrors]; 119 | 120 | } 121 | 122 | //Method that check the ressult in order to find server errors 123 | 124 | - (void) checkTheResultLookingForErrors{ 125 | 126 | NSError *error = nil; 127 | NSString *errorMessage = [self.resultDict objectForKey:OCErrorMessage]; 128 | if (errorMessage != nil) { 129 | errorMessage = [errorMessage stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]]; 130 | } 131 | 132 | if ([[self.resultDict objectForKey:OCErrorException] isEqualToString:k_forbidden_character_error]) { 133 | error = [UtilsFramework getErrorByCodeId:OCErrorForbiddenCharacters]; 134 | } else if ([[self.resultDict objectForKey:OCErrorException] isEqualToString:k_forbidden] && 135 | errorMessage != nil && errorMessage.length > 0) { 136 | error = [UtilsFramework getErrorWithCode:OCErrorForbiddenWithSpecificMessage andCustomMessageFromTheServer:[self.resultDict objectForKey:OCErrorMessage]]; 137 | } else { 138 | //TODO: here we should control an status error code on the XML to know the exact error 139 | error = [UtilsFramework getErrorWithCode:OCErrorForbiddenUnknown andCustomMessageFromTheServer:errorMessage]; 140 | } 141 | 142 | self.finishBlock(error); 143 | 144 | } 145 | 146 | 147 | @end 148 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/OCWebDavClient/Parsers/OCXMLShareByLinkParser.h: -------------------------------------------------------------------------------- 1 | // 2 | // OCXMLShareByLinkParser.h 3 | // OCCommunicationLib 4 | // 5 | // Created by Javier González on 1/13/14. 6 | 7 | // Copyright (C) 2016, ownCloud GmbH. ( http://www.owncloud.org/ ) 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | 16 | // The above copyright notice and this permission notice shall be included in 17 | // all copies or substantial portions of the Software. 18 | 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | // THE SOFTWARE. 26 | // 27 | 28 | #import 29 | 30 | @interface OCXMLShareByLinkParser : NSObject 31 | 32 | @property (nonatomic, strong) NSString *token; 33 | @property (nonatomic, strong) NSString *message; 34 | @property (nonatomic, strong) NSString *url; 35 | @property (nonatomic) NSInteger remoteShareId; 36 | @property (nonatomic) NSInteger statusCode; 37 | 38 | - (void)initParserWithData: (NSData*)data; 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/OCWebDavClient/Parsers/OCXMLShareByLinkParser.m: -------------------------------------------------------------------------------- 1 | // 2 | // OCXMLShareByLinkParser.m 3 | // OCCommunicationLib 4 | // 5 | // Created by Javier González on 1/13/14. 6 | // Copyright (c) 2014 ownCloud. All rights reserved. 7 | // 8 | 9 | // Copyright (C) 2016, ownCloud GmbH. ( http://www.owncloud.org/ ) 10 | // 11 | // Permission is hereby granted, free of charge, to any person obtaining a copy 12 | // of this software and associated documentation files (the "Software"), to deal 13 | // in the Software without restriction, including without limitation the rights 14 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 15 | // copies of the Software, and to permit persons to whom the Software is 16 | // furnished to do so, subject to the following conditions: 17 | 18 | // The above copyright notice and this permission notice shall be included in 19 | // all copies or substantial portions of the Software. 20 | 21 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 22 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 24 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 26 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 27 | // THE SOFTWARE. 28 | // 29 | 30 | #import "OCXMLShareByLinkParser.h" 31 | 32 | @interface OCXMLShareByLinkParser() 33 | 34 | @property (nonatomic, strong) NSMutableString *xmlChars; 35 | @property (nonatomic, strong) NSMutableDictionary *xmlBucket; 36 | 37 | @end 38 | 39 | @implementation OCXMLShareByLinkParser 40 | 41 | /* 42 | * Method that init the parse with the xml data from the server 43 | * @data -> XML webDav data from the owncloud server 44 | */ 45 | - (void)initParserWithData: (NSData*)data{ 46 | 47 | NSXMLParser *parser = [[NSXMLParser alloc] initWithData:data]; 48 | [parser setDelegate:self]; 49 | [parser parse]; 50 | 51 | } 52 | 53 | 54 | #pragma mark - XML Parser Delegate Methods 55 | 56 | 57 | /* 58 | * Method that init parse process. 59 | */ 60 | 61 | - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict { 62 | 63 | if (!self.xmlChars) { 64 | self.xmlChars = [NSMutableString string]; 65 | } 66 | 67 | [self.xmlChars setString:@""]; 68 | 69 | if ([elementName isEqualToString:@"ocs"]) { 70 | self.xmlBucket = [NSMutableDictionary dictionary]; 71 | } 72 | } 73 | 74 | - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName { 75 | 76 | if ([elementName isEqualToString:@"statuscode"]) { 77 | self.statusCode = [self.xmlChars intValue]; 78 | } 79 | 80 | if ([elementName isEqualToString:@"token"]) { 81 | self.token = [NSString stringWithString:self.xmlChars]; 82 | } 83 | 84 | if ([elementName isEqualToString:@"message"]) { 85 | self.message = [NSString stringWithString:self.xmlChars]; 86 | } 87 | 88 | if ([elementName isEqualToString:@"url"]) { 89 | self.url = [NSString stringWithString:self.xmlChars]; 90 | } 91 | 92 | if ([elementName isEqualToString:@"url"]) { 93 | self.url = [NSString stringWithString:self.xmlChars]; 94 | } 95 | 96 | if ([elementName isEqualToString:@"id"]) { 97 | self.remoteShareId = [self.xmlChars intValue]; 98 | } 99 | } 100 | 101 | - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string { 102 | [self.xmlChars appendString:string]; 103 | } 104 | 105 | - (void)parserDidEndDocument:(NSXMLParser *)parser{ 106 | 107 | NSLog(@"Finish xml directory list parse"); 108 | } 109 | 110 | @end 111 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/OCWebDavClient/Parsers/OCXMLSharedParser.h: -------------------------------------------------------------------------------- 1 | // 2 | // OCXMLSharedParser.h 3 | // OCCommunicationLib 4 | // 5 | // Copyright (C) 2016, ownCloud GmbH. ( http://www.owncloud.org/ ) 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | // 26 | 27 | #import 28 | #import "OCSharedDto.h" 29 | 30 | @interface OCXMLSharedParser : NSObject { 31 | 32 | NSMutableString *_xmlChars; 33 | NSMutableDictionary *_xmlBucket; 34 | NSMutableArray *_shareList; 35 | OCSharedDto *_currentShared; 36 | BOOL isNotFirstFileOfList; 37 | 38 | } 39 | 40 | @property(nonatomic,strong) NSMutableArray *shareList; 41 | @property(nonatomic,strong) OCSharedDto *currentShared; 42 | 43 | - (void)initParserWithData: (NSData*)data; 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/OCWebDavClient/Parsers/OCXMLSharedParser.m: -------------------------------------------------------------------------------- 1 | // 2 | // OCXMLSharedParser.m 3 | // OCCommunicationLib 4 | // 5 | // Copyright (C) 2016, ownCloud GmbH. ( http://www.owncloud.org/ ) 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | // THE SOFTWARE. 22 | // 23 | // 24 | 25 | #import "OCXMLSharedParser.h" 26 | #import "OCSharedDto.h" 27 | 28 | #define expirationDateFormat @"YYYY-MM-dd HH:mm:ss" 29 | 30 | @implementation OCXMLSharedParser 31 | 32 | @synthesize shareList=_shareList; 33 | @synthesize currentShared=_currentShared; 34 | 35 | /* 36 | * Method that init the parse with the xml data from the server 37 | * @data -> XML webDav data from the owncloud server 38 | */ 39 | - (void)initParserWithData: (NSData*)data{ 40 | 41 | _shareList = [[NSMutableArray alloc]init]; 42 | 43 | NSXMLParser *parser = [[NSXMLParser alloc] initWithData:data]; 44 | [parser setDelegate:self]; 45 | [parser parse]; 46 | 47 | } 48 | 49 | 50 | #pragma mark - XML Parser Delegate Methods 51 | 52 | 53 | /* 54 | * Method that init parse process. 55 | */ 56 | 57 | - (void)parser:(NSXMLParser *)parser didStartElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName attributes:(NSDictionary *)attributeDict { 58 | 59 | if (!_xmlChars) { 60 | _xmlChars = [NSMutableString string]; 61 | } 62 | 63 | //NSLog(@"_xmlChars: %@", _xmlChars); 64 | 65 | [_xmlChars setString:@""]; 66 | 67 | if ([elementName isEqualToString:@"element"]) { 68 | _xmlBucket = [NSMutableDictionary dictionary]; 69 | 70 | if (_currentShared) { 71 | [_shareList addObject:_currentShared]; 72 | } 73 | } 74 | } 75 | 76 | /* 77 | * Util method to make a NSDate object from a string from xml 78 | * @dateString -> Data string from xml 79 | */ 80 | 81 | + (NSDate*)parseDateString:(NSString*)dateString { 82 | //Parse the date in all the formats 83 | NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init]; 84 | /*In most cases the best locale to choose is "en_US_POSIX", a locale that's specifically designed to yield US English results regardless of both user and system preferences. "en_US_POSIX" is also invariant in time (if the US, at some point in the future, changes the way it formats dates, "en_US" will change to reflect the new behaviour, but "en_US_POSIX" will not). It will behave consistently for all users.*/ 85 | [dateFormatter setLocale:[[NSLocale alloc] initWithLocaleIdentifier:@"en_US_POSIX"]]; 86 | [dateFormatter setDateFormat:expirationDateFormat]; 87 | 88 | NSDate *theDate = nil; 89 | NSError *error = nil; 90 | if (![dateFormatter getObjectValue:&theDate forString:dateString range:nil error:&error]) { 91 | NSLog(@"Date '%@' could not be parsed: %@", dateString, error); 92 | } 93 | 94 | return theDate; 95 | } 96 | 97 | 98 | - (void)parser:(NSXMLParser *)parser didEndElement:(NSString *)elementName namespaceURI:(NSString *)namespaceURI qualifiedName:(NSString *)qName { 99 | 100 | //NSLog(@"elementName: %@:%@", elementName,_xmlChars); 101 | 102 | if ([elementName isEqualToString:@"id"]) { 103 | 104 | _currentShared = [[OCSharedDto alloc] init]; 105 | _currentShared.idRemoteShared = [_xmlChars intValue]; 106 | 107 | } else if ([elementName isEqualToString:@"item_type"]) { 108 | 109 | if([_xmlChars isEqualToString:@"file"]) { 110 | _currentShared.isDirectory = NO; 111 | } else { 112 | _currentShared.isDirectory = YES; 113 | if (_currentShared.path) { 114 | _currentShared.path = [_currentShared.path stringByAppendingString:@"/"]; 115 | } 116 | } 117 | } else if ([elementName isEqualToString:@"item_source"]) { 118 | 119 | _currentShared.itemSource = [_xmlChars intValue]; 120 | 121 | } else if ([elementName isEqualToString:@"parent"]) { 122 | 123 | _currentShared.parent = [_xmlChars intValue]; 124 | 125 | } else if ([elementName isEqualToString:@"share_type"]) { 126 | 127 | _currentShared.shareType = [_xmlChars intValue]; 128 | 129 | } else if ([elementName isEqualToString:@"share_with"]) { 130 | 131 | _currentShared.shareWith = _xmlChars; 132 | 133 | } else if ([elementName isEqualToString:@"file_source"]) { 134 | 135 | _currentShared.fileSource = [_xmlChars intValue]; 136 | 137 | } else if ([elementName isEqualToString:@"path"]) { 138 | 139 | if (_currentShared.isDirectory) { 140 | _currentShared.path = [_xmlChars stringByAppendingString:@"/"]; 141 | } else { 142 | _currentShared.path = _xmlChars; 143 | } 144 | 145 | } else if ([elementName isEqualToString:@"permissions"]) { 146 | 147 | _currentShared.permissions = [_xmlChars intValue]; 148 | 149 | } else if ([elementName isEqualToString:@"stime"]) { 150 | 151 | _currentShared.sharedDate = (long)[_xmlChars longLongValue]; 152 | 153 | 154 | } else if ([elementName isEqualToString:@"expiration"]) { 155 | 156 | //Check expiration, is a optional field, sometimes is empty 157 | if (![_xmlChars isEqualToString:@""]) { 158 | NSDate *date = [[self class] parseDateString:_xmlChars]; 159 | _currentShared.expirationDate = [date timeIntervalSince1970]; 160 | }else{ 161 | _currentShared.expirationDate = 0.0; 162 | } 163 | 164 | } else if ([elementName isEqualToString:@"token"]) { 165 | 166 | _currentShared.token = _xmlChars; 167 | 168 | } else if ([elementName isEqualToString:@"storage"]) { 169 | 170 | _currentShared.storage = [_xmlChars intValue]; 171 | 172 | } else if ([elementName isEqualToString:@"mail_send"]) { 173 | 174 | _currentShared.mailSend = [_xmlChars intValue]; 175 | 176 | } else if ([elementName isEqualToString:@"uid_owner"]) { 177 | 178 | _currentShared.uidOwner = _xmlChars; 179 | 180 | } else if ([elementName isEqualToString:@"uid_file_owner"]) { 181 | 182 | _currentShared.uidFileOwner = _xmlChars; 183 | 184 | } else if ([elementName isEqualToString:@"share_with_displayname"]) { 185 | 186 | _currentShared.shareWithDisplayName = _xmlChars; 187 | 188 | } else if ([elementName isEqualToString:@"displayname_owner"]) { 189 | 190 | _currentShared.displayNameOwner = _xmlChars; 191 | 192 | //Last value on the XML so we add the object to the array and begin again 193 | if (!_currentShared.shareWithDisplayName) { 194 | //To not have a nil we set an empty string 195 | _currentShared.shareWithDisplayName = @""; 196 | } 197 | 198 | } else if ([elementName isEqualToString:@"name"]) { 199 | 200 | _currentShared.name = _xmlChars; 201 | 202 | } else if ([elementName isEqualToString:@"url"]) { 203 | 204 | _currentShared.url = _xmlChars; 205 | } 206 | } 207 | 208 | - (void)parser:(NSXMLParser *)parser foundCharacters:(NSString *)string { 209 | [_xmlChars appendString:string]; 210 | } 211 | 212 | - (void)parserDidEndDocument:(NSXMLParser *)parser{ 213 | 214 | //NSLog(@"Finish xml directory list parse"); 215 | 216 | if (_currentShared) { 217 | 218 | [_shareList addObject:_currentShared]; 219 | } 220 | } 221 | 222 | 223 | @end 224 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/Resources/test.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/owncloud/ios-library/2320de3fef8334964e485de298944f16d29b4ab8/OCCommunicationLib/OCCommunicationLib/Resources/test.jpeg -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/Resources/video.MOV: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/owncloud/ios-library/2320de3fef8334964e485de298944f16d29b4ab8/OCCommunicationLib/OCCommunicationLib/Resources/video.MOV -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/UploadSupport/OCChunkDto.h: -------------------------------------------------------------------------------- 1 | // 2 | // OCChunkDto.h 3 | // Owncloud iOs Client 4 | // 5 | // Copyright (C) 2016, ownCloud GmbH. ( http://www.owncloud.org/ ) 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | 26 | #import 27 | 28 | @interface OCChunkDto : NSObject 29 | 30 | @property (nonatomic, copy) NSNumber *position; 31 | @property (nonatomic, copy) NSNumber *size; 32 | @property (nonatomic, copy) NSString *remotePath; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/UploadSupport/OCChunkDto.m: -------------------------------------------------------------------------------- 1 | // 2 | // OCChunkDto.m 3 | // Owncloud iOs Client 4 | // 5 | // Copyright (C) 2016, ownCloud GmbH. ( http://www.owncloud.org/ ) 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | 26 | #import "OCChunkDto.h" 27 | 28 | @implementation OCChunkDto 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/UploadSupport/OCURLSessionUploadTask.h: -------------------------------------------------------------------------------- 1 | // 2 | // OCURLSessionUploadTask.h 3 | // ownCloud iOS library 4 | // 5 | // Created by Javier Gonzalez on 05/06/14. 6 | // Copyright (c) 2014 ownCloud. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface OCURLSessionUploadTask : NSURLSessionUploadTask 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/UploadSupport/OCURLSessionUploadTask.m: -------------------------------------------------------------------------------- 1 | // 2 | // OCURLSessionUploadTask.m 3 | // ownCloud iOS library 4 | // 5 | // Created by Javier Gonzalez on 05/06/14. 6 | // Copyright (c) 2014 ownCloud. All rights reserved. 7 | // 8 | 9 | #import "OCURLSessionUploadTask.h" 10 | 11 | @implementation OCURLSessionUploadTask 12 | 13 | @end 14 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/Utils/NSString+Encode.h: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+Encode.h 3 | // Owncloud iOs Client 4 | // 5 | // Copyright (C) 2016, ownCloud GmbH. ( http://www.owncloud.org/ ) 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | 26 | 27 | #import 28 | 29 | @interface NSString (encode) 30 | 31 | - (NSString *)encodeString:(NSStringEncoding)encoding; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/Utils/NSString+Encode.m: -------------------------------------------------------------------------------- 1 | // 2 | // NSString+Encode.m 3 | // Owncloud iOs Client 4 | // 5 | // Copyright (C) 2016, ownCloud GmbH. ( http://www.owncloud.org/ ) 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | 26 | 27 | #import "NSString+Encode.h" 28 | 29 | @implementation NSString (encode) 30 | - (NSString *)encodeString:(NSStringEncoding)encoding 31 | { 32 | 33 | CFStringRef stringRef = CFURLCreateStringByAddingPercentEscapes(NULL, (CFStringRef)self, 34 | NULL, (CFStringRef)@";?@&=$+{}<>,!'*", 35 | CFStringConvertNSStringEncodingToEncoding(encoding)); 36 | 37 | NSString *output = (NSString *)CFBridgingRelease(stringRef); 38 | 39 | 40 | 41 | 42 | int countCharactersAfterPercent = -1; 43 | 44 | for(int i = 0 ; i < [output length] ; i++) { 45 | NSString * newString = [output substringWithRange:NSMakeRange(i, 1)]; 46 | //NSLog(@"newString: %@", newString); 47 | 48 | if(countCharactersAfterPercent>=0) { 49 | 50 | //NSLog(@"newString lowercaseString: %@", [newString lowercaseString]); 51 | output = [output stringByReplacingCharactersInRange:NSMakeRange(i, 1) withString:[newString lowercaseString]]; 52 | countCharactersAfterPercent++; 53 | } 54 | 55 | if([newString isEqualToString:@"%"]) { 56 | countCharactersAfterPercent = 0; 57 | } 58 | 59 | if(countCharactersAfterPercent==2) { 60 | countCharactersAfterPercent = -1; 61 | } 62 | } 63 | 64 | // NSLog(@"output: %@", output); 65 | 66 | return output; 67 | } 68 | @end 69 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/Utils/OCConstants.h: -------------------------------------------------------------------------------- 1 | // 2 | // OCConstants.h 3 | // Owncloud iOs Client 4 | // 5 | // Copyright (C) 2016, ownCloud GmbH. ( http://www.owncloud.org/ ) 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | 26 | #define k_redirected_code_1 301 27 | #define k_redirected_code_2 302 28 | #define k_redirected_code_3 303 29 | #define k_redirected_code_7 307 30 | 31 | //The result of the sum of those values means the permissions that have a share file 32 | //permissions - (int) 1 = read; 2 = update; 4 = create; 8 = delete; 16 = share; 31 = all (default: 31, for public shares: 1) 33 | #define k_read_share_permission 1 34 | #define k_update_share_permission 2 35 | #define k_create_share_permission 4 36 | #define k_delete_share_permission 8 37 | #define k_share_share_permission 16 38 | 39 | #define k_min_file_share_permission 1 40 | #define k_max_file_share_permission 19 41 | #define k_min_folder_share_permission 1 42 | #define k_max_folder_share_permission 31 43 | #define k_default_file_remote_share_permission_no_support_share_option 3 44 | #define k_default_folder_remote_share_permission_no_support_share_option 15 45 | 46 | #define k_max_redirections_allow 5 47 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/Utils/UtilsFramework.h: -------------------------------------------------------------------------------- 1 | // 2 | // UtilsFramework.h 3 | // Owncloud iOs Client 4 | // 5 | // Copyright (C) 2016, ownCloud GmbH. ( http://www.owncloud.org/ ) 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | 26 | #import 27 | 28 | @interface UtilsFramework : NSObject 29 | 30 | 31 | /* 32 | * Method that return a unique Id. 33 | * The global ID for the process includes the host name, process ID, and a time stamp, 34 | * which ensures that the ID is unique for the network 35 | * @return -> Unique Id (token) 36 | */ 37 | + (NSString *) getUserSessionToken; 38 | 39 | 40 | /* 41 | * Method that check the file name or folder name to find forbidden characters 42 | * This is the forbidden characters in server: "\", "/","<",">",":",""","|","?","*" 43 | * @fileName -> file name 44 | * 45 | * @isFCSupported -> From ownCloud 8.1 the forbidden characters are controller by the server except the '/' 46 | */ 47 | + (BOOL) isForbiddenCharactersInFileName:(NSString*)fileName withForbiddenCharactersSupported:(BOOL)isFCSupported; 48 | 49 | /* 50 | * Get error code with the errorCode and message of the server 51 | * 52 | */ 53 | 54 | + (NSError *) getErrorWithCode:(NSInteger)errorCode andCustomMessageFromTheServer:(NSString *)message; 55 | 56 | 57 | /* 58 | * Get error for the same errors in the share api 59 | * 60 | * Statuscodes: 61 | * 100 - successful 62 | * 400 - wrong or no update parameter given 63 | * 403 - public upload disabled by the admin 64 | * 404 - couldn’t update share 65 | * 66 | */ 67 | 68 | + (NSError *) getShareAPIErrorByCode:(NSInteger)errorCode; 69 | 70 | ///----------------------------------- 71 | /// @name getErrorByCodeId 72 | ///----------------------------------- 73 | 74 | /** 75 | * Method to return a NSError based on the Error Code Enum 76 | * 77 | * @param int errorCode to Enum to identify the error code 78 | * 79 | * @return NSError 80 | */ 81 | + (NSError *) getErrorByCodeId:(int) errorCode; 82 | 83 | ///----------------------------------- 84 | /// @name getFileNameOrFolderByPath 85 | ///----------------------------------- 86 | 87 | /** 88 | * Method that return a filename from a path 89 | * 90 | * @param NSString -> path of the file (including the file) 91 | * 92 | * @return NSString -> fileName 93 | * 94 | */ 95 | + (NSString *) getFileNameOrFolderByPath:(NSString *) path; 96 | 97 | /* 98 | * Method that return a boolean that indicate if is the same url 99 | */ 100 | + (BOOL) isTheSameFileOrFolderByNewURLString:(NSString *) newURLString andOriginURLString:(NSString *) originalURLString; 101 | 102 | /* 103 | * Method that return a boolean that indicate if newUrl is under the original Url 104 | */ 105 | + (BOOL) isAFolderUnderItByNewURLString:(NSString *) newURLString andOriginURLString:(NSString *) originalURLString; 106 | 107 | /** 108 | * Method to return the size of a file by a path 109 | * 110 | * @param NSString -> path of the file 111 | * 112 | * @return long long -> size of the file in the path 113 | */ 114 | + (long long) getSizeInBytesByPath:(NSString *) path; 115 | 116 | 117 | ///----------------------------------- 118 | /// @name isURLWithSamlFragment: 119 | ///----------------------------------- 120 | 121 | /** 122 | * Method to check a url string to looking for a SAML fragment 123 | * 124 | * @param urlString -> url from redirect server 125 | * 126 | * @return BOOL -> the result about if exist the SAML fragment or not 127 | */ 128 | + (BOOL) isURLWithSamlFragment:(NSString*)urlString; 129 | 130 | ///----------------------------------- 131 | /// @name AFBase64EncodedStringFromString: 132 | ///----------------------------------- 133 | 134 | /** 135 | * Method encode a string to base64 in order to set the credentials 136 | * 137 | * @param string -> string to be encoding 138 | * 139 | * @return NSString -> the result of the encoded string 140 | */ 141 | + (NSString *) AFBase64EncodedStringFromString:(NSString *) string; 142 | 143 | //----------------------------------- 144 | /// @name addCookiesToStorageFromResponse 145 | ///----------------------------------- 146 | 147 | #pragma mark - Manage Cookies 148 | 149 | /** 150 | * Method to storage all the cookies from a response in order to use them in future requests 151 | * 152 | * @param NSHTTPURLResponse -> response 153 | * @param NSURL -> url 154 | * 155 | */ 156 | + (void) addCookiesToStorageFromResponse: (NSURLResponse *) response andPath:(NSURL *) url; 157 | //----------------------------------- 158 | /// @name getRequestWithCookiesByRequest 159 | ///----------------------------------- 160 | 161 | /** 162 | * Method to return a request with all the necessary cookies of the original url without redirection 163 | * 164 | * @param NSMutableURLRequest -> request 165 | * @param NSString -> originalUrlServer 166 | * 167 | * @return request 168 | * 169 | */ 170 | + (NSMutableURLRequest *) getRequestWithCookiesByRequest: (NSMutableURLRequest *) request andOriginalUrlServer:(NSString *) originalUrlServer; 171 | 172 | //----------------------------------- 173 | /// @name deleteAllCookies 174 | ///----------------------------------- 175 | 176 | /** 177 | * Method to clean the CookiesStorage 178 | * 179 | */ 180 | + (void) deleteAllCookies; 181 | 182 | //----------------------------------- 183 | /// @name isServerVersionHigherThanLimitVersion 184 | ///----------------------------------- 185 | 186 | /** 187 | * Method to detect if a server version is higher than a limit version. 188 | * This method is used for example to know if the server have share API or support Cookies 189 | * 190 | * @param NSString -> serverVersion 191 | * @param NSArray -> limitVersion 192 | * 193 | * @return BOOL 194 | * 195 | */ 196 | + (BOOL) isServerVersion:(NSString *) serverVersionString higherThanLimitVersion:(NSArray *) limitVersion; 197 | 198 | //----------------------------------- 199 | /// @name getPermissionsValueByCanCreate 200 | ///----------------------------------- 201 | 202 | /** 203 | * Method know the value of the permissions of a share file or folder. 204 | * This method is used to calculate the value of a permission parameter to share a file or document 205 | * 206 | * @param BOOL -> canRead 207 | * @param BOOL -> canEdit 208 | * @param BOOL -> canCreate 209 | * @param BOOL -> canChange 210 | * @param BOOL -> canDelete 211 | * @param BOOL -> canShare 212 | * @param BOOL -> isFolder 213 | * 214 | * @return NSInteger 215 | * 216 | */ 217 | + (NSInteger) getPermissionsValueByCanRead:(BOOL) canRead andCanEdit:(BOOL)canEdit andCanCreate:(BOOL)canCreate andCanChange:(BOOL)canChange andCanDelete:(BOOL)canDelete andCanShare:(BOOL)canShare andIsFolder:(BOOL) isFolder; 218 | 219 | 220 | //----------------------------------- 221 | /// @name isPermissionToCanCreate 222 | ///----------------------------------- 223 | 224 | /** 225 | * Method know if we have permission to create by the permissionValue of the OCShareDto 226 | * 227 | * @param NSInteger -> permissionValue 228 | * 229 | * @return BOOL 230 | * 231 | */ 232 | + (BOOL) isPermissionToCanCreate:(NSInteger) permissionValue; 233 | 234 | //----------------------------------- 235 | /// @name isPermissionToCanChange 236 | ///----------------------------------- 237 | 238 | /** 239 | * Method know if we have permission to Change by the permissionValue of the OCShareDto 240 | * 241 | * @param NSInteger -> permissionValue 242 | * 243 | * @return BOOL 244 | * 245 | */ 246 | + (BOOL) isPermissionToCanChange:(NSInteger) permissionValue; 247 | 248 | //----------------------------------- 249 | /// @name isPermissionToCanDelete 250 | ///----------------------------------- 251 | 252 | /** 253 | * Method know if we have permission to Delete by the permissionValue of the OCShareDto 254 | * 255 | * @param NSInteger -> permissionValue 256 | * 257 | * @return BOOL 258 | * 259 | */ 260 | + (BOOL) isPermissionToCanDelete:(NSInteger) permissionValue; 261 | 262 | //----------------------------------- 263 | /// @name isPermissionToCanShare 264 | ///----------------------------------- 265 | 266 | /** 267 | * Method know if we have permission to Share by the permissionValue of the OCShareDto 268 | * 269 | * @param NSInteger -> permissionValue 270 | * 271 | * @return BOOL 272 | * 273 | */ 274 | + (BOOL) isPermissionToCanShare:(NSInteger) permissionValue; 275 | 276 | //----------------------------------- 277 | /// @name isAnyPermissionToEdit 278 | ///----------------------------------- 279 | 280 | /** 281 | * Method to know if any permission related to edit (canCreate, canChange and canDelete) is active by the permissionValue of the OCShareDto 282 | * 283 | * @param NSInteger -> permissionValue 284 | * 285 | * @return BOOL 286 | * 287 | */ 288 | + (BOOL) isAnyPermissionToEdit:(NSInteger) permissionValue; 289 | 290 | //----------------------------------- 291 | /// @name isPermissionToRead 292 | ///----------------------------------- 293 | 294 | /** 295 | * Method to know if we have permission to Read by the permissionValue of the OCShareDto 296 | * 297 | * @param NSInteger -> permissionValue 298 | * 299 | * @return BOOL 300 | * 301 | */ 302 | 303 | + (BOOL) isPermissionToRead:(NSInteger) permissionValue; 304 | 305 | //--------------------------------------------------- 306 | /// @name isPermissionToReadCreateUpdate 307 | ///-------------------------------------------------- 308 | 309 | /** 310 | * Method to know if we have permissions to read,create and update by the permissionValue of the OCShareDto 311 | * 312 | * @param NSInteger -> permissionValue 313 | * 314 | * @return BOOL 315 | * 316 | */ 317 | + (BOOL) isPermissionToReadCreateUpdate:(NSInteger) permissionValue; 318 | 319 | @end 320 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLib/ownCloud iOS library-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #ifdef __OBJC__ 8 | #import 9 | #endif 10 | 11 | #ifndef TARGET_OS_IOS 12 | #define TARGET_OS_IOS TARGET_OS_IPHONE 13 | #endif 14 | 15 | #ifndef TARGET_OS_WATCH 16 | #define TARGET_OS_WATCH 0 17 | #endif 18 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLibTests/ConfigTests.h: -------------------------------------------------------------------------------- 1 | // 2 | // ConfigTests.h 3 | // ownCloud iOS library 4 | // 5 | // Copyright (C) 2016, ownCloud GmbH. ( http://www.owncloud.org/ ) 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | 26 | //Your entire server url. ex:https://example.owncloud.com/owncloud/ 27 | #define k_base_url @"" 28 | //Server with webdav url. ex: https://example.owncloud.com/owncloud/remote.php/webdav/ 29 | #define k_webdav_base_url @"" 30 | //Server user 31 | #define k_user @"¡" 32 | //Server password 33 | #define k_password @"" 34 | //Optional. You can change the folder of tests 35 | #define k_path_test_folder @"" 36 | //User to share 37 | #define k_user_to_share @"" 38 | //Group to share 39 | #define k_group_to_share @"" 40 | //Remote user to share as federate 41 | #define k_remote_user_to_share @"" 42 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLibTests/OCCommunicationLibTests.h: -------------------------------------------------------------------------------- 1 | // 2 | // OCCommunicationLibTests.h 3 | // 4 | // Copyright (C) 2016, ownCloud GmbH. ( http://www.owncloud.org/ ) 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | // 24 | 25 | 26 | #import 27 | 28 | @class OCCommunication; 29 | @class ConfigTests; 30 | 31 | @interface OCCommunicationLibTests : XCTestCase 32 | 33 | @property (nonatomic, strong) ConfigTests *configTests; 34 | @property (nonatomic, strong) OCCommunication *sharedOCCommunication; 35 | 36 | @end 37 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLibTests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /OCCommunicationLib/OCCommunicationLibTests/ownCloud iOS libraryTests-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 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /OCCommunicationLib/ownCloud iOS library.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /OCCommunicationLib/ownCloud iOS library.xcodeproj/xcshareddata/xcschemes/ownCloud iOS library.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 31 | 32 | 34 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 57 | 58 | 64 | 65 | 66 | 67 | 68 | 69 | 75 | 76 | 78 | 79 | 82 | 83 | 84 | -------------------------------------------------------------------------------- /OCCommunicationLib/ownCloud iOS library.xcodeproj/xcuserdata/Gonzalo.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /OCCommunicationLib/ownCloud iOS library.xcodeproj/xcuserdata/Gonzalo.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ownCloud iOS library.xcscheme 8 | 9 | orderHint 10 | 1 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | EA7CC896183E11E600B6A4B4 16 | 17 | primary 18 | 19 | 20 | EA7CC8A6183E11E600B6A4B4 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /OCLibraryExample/OCLibraryExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /OCLibraryExample/OCLibraryExample.xcodeproj/project.xcworkspace/xcshareddata/OCLibraryExample.xccheckout: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDESourceControlProjectFavoriteDictionaryKey 6 | 7 | IDESourceControlProjectIdentifier 8 | 57BF834A-A8D6-460D-9DDF-D0FDE7E0E7FB 9 | IDESourceControlProjectName 10 | OCLibraryExample 11 | IDESourceControlProjectOriginsDictionary 12 | 13 | 3DF1482C-21FF-4514-8770-3CF4FE4C0B3C 14 | ssh://github.com/owncloud/ios-library.git 15 | 4B419C9897F7942ABC1B74203B98787E82498DA2 16 | github.com:owncloud/ios-library.git 17 | 18 | IDESourceControlProjectPath 19 | OCLibraryExample/OCLibraryExample.xcodeproj 20 | IDESourceControlProjectRelativeInstallPathDictionary 21 | 22 | 3DF1482C-21FF-4514-8770-3CF4FE4C0B3C 23 | ../../../../OCCommunicationLib 24 | 4B419C9897F7942ABC1B74203B98787E82498DA2 25 | ../../.. 26 | 27 | IDESourceControlProjectURL 28 | github.com:owncloud/ios-library.git 29 | IDESourceControlProjectVersion 30 | 111 31 | IDESourceControlProjectWCCIdentifier 32 | 4B419C9897F7942ABC1B74203B98787E82498DA2 33 | IDESourceControlProjectWCConfigurations 34 | 35 | 36 | IDESourceControlRepositoryExtensionIdentifierKey 37 | public.vcs.git 38 | IDESourceControlWCCIdentifierKey 39 | 4B419C9897F7942ABC1B74203B98787E82498DA2 40 | IDESourceControlWCCName 41 | ios-library 42 | 43 | 44 | IDESourceControlRepositoryExtensionIdentifierKey 45 | public.vcs.git 46 | IDESourceControlWCCIdentifierKey 47 | 3DF1482C-21FF-4514-8770-3CF4FE4C0B3C 48 | IDESourceControlWCCName 49 | OCCommunicationLib 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /OCLibraryExample/OCLibraryExample.xcodeproj/project.xcworkspace/xcuserdata/Gonzalo.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/owncloud/ios-library/2320de3fef8334964e485de298944f16d29b4ab8/OCLibraryExample/OCLibraryExample.xcodeproj/project.xcworkspace/xcuserdata/Gonzalo.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /OCLibraryExample/OCLibraryExample.xcodeproj/xcuserdata/Gonzalo.xcuserdatad/xcschemes/OCLibraryExample.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 61 | 62 | 68 | 69 | 70 | 71 | 72 | 73 | 79 | 80 | 86 | 87 | 88 | 89 | 91 | 92 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /OCLibraryExample/OCLibraryExample.xcodeproj/xcuserdata/Gonzalo.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | OCLibraryExample.xcscheme 8 | 9 | orderHint 10 | 0 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | EA7CC940183E199B00B6A4B4 16 | 17 | primary 18 | 19 | 20 | EA7CC964183E199C00B6A4B4 21 | 22 | primary 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /OCLibraryExample/OCLibraryExample/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/owncloud/ios-library/2320de3fef8334964e485de298944f16d29b4ab8/OCLibraryExample/OCLibraryExample/.DS_Store -------------------------------------------------------------------------------- /OCLibraryExample/OCLibraryExample/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // OCLibraryExample 4 | // 5 | // Copyright (c) 2014 ownCloud (http://www.owncloud.org/) 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | 26 | 27 | #import 28 | #import "OCCommunication.h" 29 | 30 | 31 | @interface AppDelegate : UIResponder 32 | 33 | @property (strong, nonatomic) UIWindow *window; 34 | 35 | /* 36 | * Method to get a Singleton of the OCCommunication to manage all the communications 37 | */ 38 | + (OCCommunication*)sharedOCCommunication; 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /OCLibraryExample/OCLibraryExample/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // OCLibraryExample 4 | // 5 | // Copyright (c) 2014 ownCloud (http://www.owncloud.org/) 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | 26 | #import "AppDelegate.h" 27 | #import "AFSecurityPolicy.h" 28 | 29 | @implementation AppDelegate 30 | 31 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 32 | { 33 | // Override point for customization after application launch. 34 | return YES; 35 | } 36 | 37 | - (void)applicationWillResignActive:(UIApplication *)application 38 | { 39 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 40 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 41 | } 42 | 43 | - (void)applicationDidEnterBackground:(UIApplication *)application 44 | { 45 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 46 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 47 | } 48 | 49 | - (void)applicationWillEnterForeground:(UIApplication *)application 50 | { 51 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 52 | } 53 | 54 | - (void)applicationDidBecomeActive:(UIApplication *)application 55 | { 56 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 57 | } 58 | 59 | - (void)applicationWillTerminate:(UIApplication *)application 60 | { 61 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 62 | } 63 | 64 | #pragma mark - Background Fetch methods 65 | 66 | - (void)application:(UIApplication *)application handleEventsForBackgroundURLSession:(NSString *)identifier completionHandler:(void (^)())completionHandler 67 | 68 | { 69 | NSLog(@"Transfer complete"); 70 | 71 | [self presentNotification]; 72 | 73 | completionHandler(UIBackgroundFetchResultNewData); 74 | 75 | 76 | } 77 | 78 | -(void)presentNotification{ 79 | UILocalNotification* localNotification = [[UILocalNotification alloc] init]; 80 | localNotification.alertBody = @"Transfer Complete !!"; 81 | localNotification.alertAction = @"Background Transfer"; 82 | 83 | 84 | //On sound 85 | localNotification.soundName = UILocalNotificationDefaultSoundName; 86 | 87 | 88 | [[UIApplication sharedApplication] presentLocalNotificationNow:localNotification]; 89 | } 90 | 91 | 92 | #pragma mark - OCCommunication Singleton 93 | 94 | #pragma mark - OCCommunications 95 | 96 | + (OCCommunication*)sharedOCCommunication 97 | { 98 | static OCCommunication* sharedOCCommunication = nil; 99 | if (sharedOCCommunication == nil) 100 | { 101 | sharedOCCommunication = [[OCCommunication alloc] init]; 102 | 103 | AFSecurityPolicy *secPolicy = [AFSecurityPolicy defaultPolicy]; 104 | secPolicy.allowInvalidCertificates = YES; 105 | 106 | [sharedOCCommunication setSecurityPolicy:secPolicy]; 107 | } 108 | return sharedOCCommunication; 109 | } 110 | 111 | @end 112 | -------------------------------------------------------------------------------- /OCLibraryExample/OCLibraryExample/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /OCLibraryExample/OCLibraryExample/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "7.0", 8 | "scale" : "2x" 9 | }, 10 | { 11 | "orientation" : "portrait", 12 | "idiom" : "iphone", 13 | "subtype" : "retina4", 14 | "extent" : "full-screen", 15 | "minimum-system-version" : "7.0", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "orientation" : "portrait", 20 | "idiom" : "ipad", 21 | "extent" : "full-screen", 22 | "minimum-system-version" : "7.0", 23 | "scale" : "1x" 24 | }, 25 | { 26 | "orientation" : "landscape", 27 | "idiom" : "ipad", 28 | "extent" : "full-screen", 29 | "minimum-system-version" : "7.0", 30 | "scale" : "1x" 31 | }, 32 | { 33 | "orientation" : "portrait", 34 | "idiom" : "ipad", 35 | "extent" : "full-screen", 36 | "minimum-system-version" : "7.0", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "orientation" : "landscape", 41 | "idiom" : "ipad", 42 | "extent" : "full-screen", 43 | "minimum-system-version" : "7.0", 44 | "scale" : "2x" 45 | } 46 | ], 47 | "info" : { 48 | "version" : 1, 49 | "author" : "xcode" 50 | } 51 | } -------------------------------------------------------------------------------- /OCLibraryExample/OCLibraryExample/OCLibraryExample-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 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 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | NSAppTransportSecurity 28 | 29 | NSAllowsArbitraryLoads 30 | 31 | 32 | UIMainStoryboardFile 33 | Main_iPhone 34 | UIMainStoryboardFile~ipad 35 | Main_iPad 36 | UIRequiredDeviceCapabilities 37 | 38 | armv7 39 | 40 | UISupportedInterfaceOrientations 41 | 42 | UIInterfaceOrientationPortrait 43 | 44 | UISupportedInterfaceOrientations~ipad 45 | 46 | UIInterfaceOrientationPortrait 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /OCLibraryExample/OCLibraryExample/OCLibraryExample-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #import 8 | 9 | #ifndef __IPHONE_5_0 10 | #warning "This project uses features only available in iOS SDK 5.0 and later." 11 | #endif 12 | 13 | #ifdef __OBJC__ 14 | #import 15 | #import 16 | #define IS_IOS7 ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) 17 | #define IS_IPHONE (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) 18 | #endif 19 | -------------------------------------------------------------------------------- /OCLibraryExample/OCLibraryExample/Resources/image_to_upload.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/owncloud/ios-library/2320de3fef8334964e485de298944f16d29b4ab8/OCLibraryExample/OCLibraryExample/Resources/image_to_upload.jpg -------------------------------------------------------------------------------- /OCLibraryExample/OCLibraryExample/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // OCLibraryExample 4 | // 5 | // Copyright (c) 2014 ownCloud (http://www.owncloud.org/) 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | 26 | #import 27 | 28 | @interface ViewController : UIViewController 29 | 30 | 31 | //UI 32 | @property (nonatomic,strong)IBOutlet UITableView *itemsTableView; 33 | @property (nonatomic,strong)IBOutlet UILabel *goInfoLabel; 34 | @property (nonatomic,strong)IBOutlet UIButton *goButton; 35 | @property (nonatomic,strong)IBOutlet UILabel *progressLabel; 36 | @property (nonatomic,strong)IBOutlet UIButton *downloadButton; 37 | @property (nonatomic,strong)IBOutlet UIButton *deleteLocalFile; 38 | @property (nonatomic,strong)IBOutlet UIImageView *downloadedImageView; 39 | @property (nonatomic,strong)IBOutlet UILabel *uploadProgressLabel; 40 | @property (nonatomic,strong)IBOutlet UIButton *uploadButton; 41 | @property (nonatomic,strong)IBOutlet UIButton *uploadWithSessionButton; 42 | @property (nonatomic,strong)IBOutlet UIButton *deleteRemoteFile; 43 | 44 | 45 | 46 | // 47 | @property (nonatomic,strong)NSString *pathOfDownloadFile; 48 | @property (nonatomic,strong)NSArray *itemsOfPath; 49 | @property (nonatomic,strong)NSString *pathOfRemoteUploadedFile; 50 | @property (nonatomic,strong)NSString *pathOfLocalUploadedFile; 51 | 52 | //Operations 53 | @property(nonatomic,strong)NSURLSessionTask *downloadTask; 54 | @property(nonatomic,strong)NSURLSessionTask *uploadTask; 55 | 56 | //Read Folder actions 57 | - (IBAction)readFolder:(id)sender; 58 | 59 | //Download actions 60 | - (IBAction)downloadImage:(id)sender; 61 | - (IBAction)deleteDownloadedFile:(id)sender; 62 | 63 | //Upload actions 64 | - (IBAction)uploadImage:(id)sender; 65 | - (IBAction)uploadImageWithSession:(id)sender; 66 | - (IBAction)deleteUploadedFile:(id)sender; 67 | 68 | //Close View 69 | - (IBAction)closeView:(id)sender; 70 | 71 | @end 72 | -------------------------------------------------------------------------------- /OCLibraryExample/OCLibraryExample/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /OCLibraryExample/OCLibraryExample/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // OCLibraryExample 4 | // 5 | // Created by Gonzalo Gonzalez on 21/11/13. 6 | // Copyright (c) 2013 ownCloud. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | #import "AppDelegate.h" 12 | 13 | int main(int argc, char * argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /OCLibraryExample/OCLibraryExampleTests/OCLibraryExampleTests-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 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /OCLibraryExample/OCLibraryExampleTests/OCLibraryExampleTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // OCLibraryExampleTests.m 3 | // OCLibraryExampleTests 4 | // 5 | // Copyright (c) 2014 ownCloud (http://www.owncloud.org/) 6 | // 7 | // Permission is hereby granted, free of charge, to any person obtaining a copy 8 | // of this software and associated documentation files (the "Software"), to deal 9 | // in the Software without restriction, including without limitation the rights 10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | // copies of the Software, and to permit persons to whom the Software is 12 | // furnished to do so, subject to the following conditions: 13 | 14 | // The above copyright notice and this permission notice shall be included in 15 | // all copies or substantial portions of the Software. 16 | 17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | // THE SOFTWARE. 24 | // 25 | // 26 | 27 | #import 28 | 29 | @interface OCLibraryExampleTests : XCTestCase 30 | 31 | @end 32 | 33 | @implementation OCLibraryExampleTests 34 | 35 | - (void)setUp 36 | { 37 | [super setUp]; 38 | // Put setup code here. This method is called before the invocation of each test method in the class. 39 | } 40 | 41 | - (void)tearDown 42 | { 43 | // Put teardown code here. This method is called after the invocation of each test method in the class. 44 | [super tearDown]; 45 | } 46 | 47 | - (void)testExample 48 | { 49 | XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__); 50 | } 51 | 52 | @end 53 | -------------------------------------------------------------------------------- /OCLibraryExample/OCLibraryExampleTests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ownCloud iOS Library v 2.2.1 2 | 3 | ### Introduction 4 | Using ownCloud iOS library it will be the easiest way to communicate with ownCloud servers. 5 | Add this library in your project and integrate your application with ownCloud seamlessly. 6 | 7 | ### Install Library 8 | #### 2.1. Information how to get the library 9 | Get this code and compile with Xcode 8. In the repository it is not only the library project “ownCloud iOS library” but also the example project “OCLibraryExample”. Thanks to the “OCLibraryExample” you will learn how to use the library. 10 | #### 2.2. Add library to your project 11 | There are two ways of adding this library to your code: 12 | 13 | Method 1. Reference the headers and the library binary file (.a) directly. 14 | 15 | Method 2. Include the library project as a Subproject. 16 | 17 | Choosing one method or the other one just depends on your own preferences as well as whether you have the source code and the project file of the static library at your disposal. 18 | 19 | ##### Method 1: Header and library binary files 20 | __Step 1__. Compile the "ownCloud iOS library" and run the project, the libownCloudiOS.a will be generated. 21 | 22 | You need these files: 23 | 24 | __Library File__ 25 | 26 | * libownCloudiOS.a (Library) 27 | 28 | __Library Classes__ 29 | 30 | * OCComunication.h (Accesors) Import in the communication classes 31 | * OCErrorMsg.h (Error messages) Import in the communication classes 32 | * OCFileDto.h (File/Folder object) Import when you use readFolder and readFile methods 33 | * OCFileDto.m 34 | * OCFrameworkConstants.h (Customize constants) 35 | * OCSharedDto.h 36 | * OCSharedDto.m 37 | * OCShareUser.h 38 | * OCShareUser.m 39 | 40 | __Step 2.__ Add the library file in your project. Link the library file in your project target. "build phases" -> "Link binary with libraries" and tap in "+" and select the library file. 41 | 42 | 43 | __Step 3.__ Add the path of the library headers. In your project target "build settings" in the option "Header Search Paths" add the path. 44 | 45 | __Step 4.__ In your project target "build settings" add the flag "-Obj-C" to the "Other Linker Flag" option 46 | 47 | 48 | ##### Method 2: Subprojects 49 | 50 | __Step 1.__ Add the file "ownCloud iOS library.xcodeproj" to your project using drag and drop. 51 | 52 | 53 | __Step 2.__ In your project target go to "build phases" -> "Target Dependencies" and tap in "+" and select the library target. 54 | 55 | __Step 3.__ Now link the library file in your project target. "build phases" -> "Link binary with libraries" and tap in "+" and select the library file. 56 | 57 | __Step 4.__ In your project target "build settings" add the flag "-Obj-C" to the "Other Linker Flag" option 58 | 59 | __Step 5.__ And finally, add the path of the library headers. In your project target "build settings" in the option "Header Search Paths" add the path. 60 | 61 | __Source:__ 62 | 63 | RayWenderlich.com 64 | 65 | Apple.com 66 | 67 | ### Branching strategy 68 | 69 | The repository holds two main branches with an infinite lifetime: 70 | 71 | - stable 72 | - master 73 | 74 | Branch __origin/stable__ is considered the main branch where the source code of HEAD always reflects a production-ready state. 75 | 76 | Branch __origin/master__ is considered the main branch where the source code of HEAD always reflects a state with the latest delivered development changes for the next release. 77 | 78 | When the source code in the master branch reaches a stable point and is ready to be released, all of the changes should be merged back into stable somehow and then tagged with a release number. 79 | 80 | Other branches, some supporting branches are used to aid parallel development between team members, ease tracking of features, prepare for production releases and to assist in quickly fixing live production problems. Unlike the main branches, these branches always have a limited life time, since they will be removed eventually. 81 | 82 | The different types of branches we may use are: 83 | 84 | - Branch __perNewFeature__ 85 | - Branch __releaseBranches__ 86 | 87 | Both of them branch off from master and must merge back into stable branch through a Pull Request in Github. Once the PR is approved and merged, the US branch may be deleted 88 | 89 | Source: http://nvie.com/posts/a-successful-git-branching-model 90 | 91 | ### License 92 | 93 | ownCloud iOS library is available under the MIT License. 94 | 95 | Copyright (c) 2017 ownCloud (http://www.owncloud.org/) 96 | 97 | Permission is hereby granted, free of charge, to any person obtaining a copy 98 | of this software and associated documentation files (the "Software"), to deal 99 | in the Software without restriction, including without limitation the rights 100 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 101 | copies of the Software, and to permit persons to whom the Software is 102 | furnished to do so, subject to the following conditions: 103 | 104 | The above copyright notice and this permission notice shall be included in 105 | all copies or substantial portions of the Software. 106 | 107 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 108 | THE SOFTWARE. 109 | 110 | #### Third party libraries 111 | 112 | ownCloud iOS library uses AFNetworking version 3.1.0 AFNetworking is available under the MIT license. 113 | 114 | ownCloud iOS library uses some classes based in https://github.com/zwaldowski/DZWebDAVClient. Copyright (c) 2012 Zachary Waldowski, Troy Brant, Marcus Rohrmoser, and Sam Soffes under the MIT license. 115 | 116 | 117 | ### Compatibility 118 | 119 | ownCloud iOS library supports iOS 9, iOS10, iOS11 and works in Xcode 8 and Xcode 9. 120 | 121 | ownCloud iOS library supports ownCloud server from version 4.5. 122 | --------------------------------------------------------------------------------