OCWebDAVClient.h 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645
  1. //
  2. // OCWebDAVClient.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. // The above copyright notice and this permission notice shall be included in
  16. // all copies or substantial portions of the Software.
  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. // Add : getNotificationServer & setNotificationServer
  27. // Add : getUserProfileServer
  28. // Add : Support for Favorite
  29. // Add : getActivityServer
  30. //
  31. // Author Marino Faggiana <m.faggiana@twsweb.it>
  32. // Copyright (c) 2017 TWS. All rights reserved.
  33. //
  34. #import "AFHTTPSessionManager.h"
  35. #import "OCHTTPRequestOperation.h"
  36. @class OCCommunication;
  37. @class OCChunkDto;
  38. /** The key for a uniform (MIME) type identifier returned from the property request methods. */
  39. extern NSString * _Nullable OCWebDAVContentTypeKey;
  40. /** The key for a unique entity identifier returned from the property request methods. */
  41. extern NSString * _Nullable OCWebDAVETagKey;
  42. /** The key for a content identifier tag returned from the property request methods. This is only supported on some servers, and usually defines whether the contents of a collection (folder) have changed. */
  43. extern NSString * _Nullable OCWebDAVCTagKey;
  44. /** The key for the creation date of an entity. */
  45. extern NSString * _Nullable OCWebDAVCreationDateKey;
  46. /** The key for last modification date of an entity. */
  47. extern NSString * _Nullable OCWebDAVModificationDateKey;
  48. @interface OCWebDAVClient : NSObject
  49. @property (readwrite, nonatomic, strong) NSMutableDictionary * _Nullable defaultHeaders;
  50. //On redirections AFNetworking lose the request method on iOS6 and set a GET, we use this as workarround
  51. @property (nonatomic, strong) NSString * _Nullable requestMethod;
  52. //We use this variable to return the url of a redirected server to detect if we receive any sesion expired on SSO server
  53. @property (nonatomic, strong) NSString * _Nullable redirectedServer;
  54. //We use this variable to get the Cookies from the storage provider
  55. @property (nonatomic, strong) NSString * _Nullable originalUrlServer;
  56. @property (nonatomic, strong) NSString * _Nullable postStringForShare;
  57. // E2E Metadata
  58. @property (nonatomic, strong) NSString * _Nullable postStringMetadata;
  59. /**
  60. Sets the "Authorization" HTTP header set in request objects made by the HTTP client to a basic authentication value with Base64-encoded username and password. This overwrites any existing value for this header.
  61. @param username The HTTP basic auth username
  62. @param password The HTTP basic auth password
  63. */
  64. - (void)setAuthorizationHeaderWithUsername:(NSString * _Nonnull)username
  65. password:(NSString * _Nonnull)password;
  66. /**
  67. Sets the "Authorization" HTTP header set in request objects made by the HTTP client to a basic authentication value with Base64-encoded username and password. This overwrites any existing value for this header.
  68. @param cookieString The HTTP token to login on SSO Servers
  69. */
  70. - (void)setAuthorizationHeaderWithCookie:(NSString * _Nonnull) cookieString;
  71. /**
  72. Sets the "Authorization" HTTP header set in request objects made by the HTTP client to a token-based authentication value, such as an OAuth access token. This overwrites any existing value for this header.
  73. @param token The authentication token
  74. */
  75. - (void)setAuthorizationHeaderWithToken:(NSString * _Nonnull)token;
  76. /**
  77. Sets the "User-Agent" HTTP header
  78. @param userAgent -> String that indentifies the client app. Ex: "iOS-ownCloud"
  79. */
  80. - (void)setUserAgent:(NSString * _Nonnull)userAgent;
  81. /**
  82. Add Header
  83. */
  84. - (void)setDefaultHeader:(NSString * _Nonnull)header value:(NSString *_Nullable)value;
  85. /**
  86. Enqueues an operation to move the object at a path to another path using a `MOVE` request.
  87. @param source The path to move.
  88. @param destination The path to move the item to.
  89. @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  90. @param success A block callback, to be fired upon successful completion, with no arguments.
  91. @param failure A block callback, to be fired upon the failure of the request, with two arguments: the request operation and the network error that occurred.
  92. */
  93. - (void)movePath:(NSString * _Nonnull)source toPath:(NSString * _Nonnull)destination
  94. onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication
  95. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull))success
  96. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull))failure;
  97. /**
  98. Enqueues an operation to delete the object at a path using a `DELETE` request.
  99. @param path The path for which to create a directory.
  100. @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  101. @param success A block callback, to be fired upon successful completion, with no arguments.
  102. @param failure A block callback, to be fired upon the failure of the request, with two arguments: the request operation and the network error that occurred.
  103. */
  104. - (void)deletePath:(NSString * _Nonnull)path
  105. onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication
  106. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull))success
  107. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull))failure;
  108. /**
  109. Enqueues a request to list the properties of a single entity using a `PROPFIND` request for the specified path.
  110. @param path The path for which to list the properties.
  111. @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  112. @param success A block callback, to be fired upon successful completion, with two arguments: the request operation and a dictionary with the properties of the entity.
  113. @param failure A block callback, to be fired upon the failure of either the request or the parsing of the request's data, with two arguments: the request operation and the network or parsing error that occurred.
  114. @see listPath:success:failure:
  115. @see recursiveListPath:success:failure:
  116. */
  117. - (void)propertiesOfPath:(NSString * _Nonnull)path
  118. onCommunication: (OCCommunication * _Nonnull)sharedOCCommunication
  119. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull))success
  120. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull))failure;
  121. /**
  122. Enqueues a request to list the contents of a single collection and
  123. the properties of each object, including the properties of the
  124. collection itself, using a `PROPFIND` request.
  125. @param path The directory for which to list the contents.
  126. @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  127. @param success A block callback, to be fired upon successful completion, with two arguments: the request operation and a dictionary with the properties of the directory and its contents.
  128. @param failure A block callback, to be fired upon the failure of either the request or the parsing of the request's data, with two arguments: the request operation and the network or parsing error that occurred.
  129. @see propertiesOfPath:success:failure:
  130. @see recursiveListPath:success:failure:
  131. */
  132. - (void)listPath:(NSString * _Nonnull)path depth:(NSString * _Nonnull)depth
  133. onCommunication: (OCCommunication * _Nonnull)sharedOCCommunication
  134. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject))success
  135. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  136. /**
  137. Enqueues a request to list the contents of a single collection and
  138. the properties of each object, including the properties of the
  139. collection itself, using a `PROPFIND` request.
  140. @param path The directory for which to list the contents.
  141. @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  142. @param token User Session token
  143. @param success A block callback, to be fired upon successful completion, with two arguments: the request operation and a dictionary with the properties of the directory and its contents.
  144. @param failure A block callback, to be fired upon the failure of either the request or the parsing of the request's data, with two arguments: the request operation and the network or parsing error that occurred.
  145. @see propertiesOfPath:success:failure:
  146. @see recursiveListPath:success:failure:
  147. */
  148. - (void)listPath:(NSString * _Nonnull)path depth:(NSString * _Nonnull)depth
  149. onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication withUserSessionToken:(NSString * _Nonnull)token
  150. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull, NSString * _Nonnull token))success
  151. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull, NSString * _Nonnull token))failure;
  152. /**
  153. */
  154. - (void)search:(NSString * _Nonnull)path folder:(NSString * _Nonnull)folder fileName:(NSString * _Nonnull)fileName depth:(NSString * _Nonnull)depth dateLastModified:(NSString * _Nonnull)dateLastModified contentType:(NSString * _Nonnull)contentType user:(NSString * _Nonnull)user userID:(NSString * _Nonnull)userID onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication withUserSessionToken:(NSString * _Nonnull)token success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull, NSString * _Nonnull token))success failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull, NSString * _Nonnull token))failure;
  155. /**
  156. */
  157. - (void)settingFavorite:(NSString * _Nonnull)path favorite:(BOOL)favorite onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication withUserSessionToken:(NSString * _Nonnull)token success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull, NSString * _Nonnull token))success failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull, NSString * _Nonnull token))failure;
  158. /**
  159. */
  160. - (void)listingFavorites:(NSString * _Nonnull)path folder:(NSString * _Nonnull)folder user:(NSString * _Nonnull)user userID:(NSString * _Nonnull)userID onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication withUserSessionToken:(NSString * _Nonnull)token success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull, NSString * _Nonnull token))success failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull, NSString * _Nonnull token))failure;
  161. /**
  162. Creates an `NSURLSessionDownloadTask` with the specified request for a local file.
  163. @param remoteSource is a string with the path of the file in the server
  164. @param localDestination is a string with the local device path for store the file
  165. @param defaultPriority is a bool with a flag to indicate if the download must be download inmediately of not.
  166. @param progress A progress object monitoring the current upload progress.
  167. @param success A block callback, to be fired upon successful completion, with NSURLResponse and string of URL of the filePath
  168. @param failure A block callback, to be fired upon the failure of either the request or the parsing of the request's data, with two arguments: the request operation and the network or parsing error that occurred.
  169. *
  170. @warning NSURLSession and NSRULSessionUploadTask only can be supported in iOS 7.
  171. */
  172. - (NSURLSessionDownloadTask * _Nonnull)downloadWithSessionPath:(NSString * _Nonnull)remoteSource toPath:(NSString * _Nonnull)localDestination defaultPriority:(BOOL)defaultPriority onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication progress:(void(^ _Nonnull)(NSProgress * _Nonnull progress))downloadProgress success:(void(^ _Nonnull)(NSURLResponse * _Nonnull response, NSURL * _Nonnull filePath))success failure:(void(^ _Nonnull)(NSURLResponse * _Nonnull response, NSError * _Nonnull error))failure;
  173. /**
  174. Enqueues a request to check the server to know the kind of authentication needed.
  175. @param path The path of the server.
  176. @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  177. @param success A block callback, to be fired upon successful completion, with no arguments.
  178. @param failure A block callback, to be fired upon the failure of the request, with two arguments: the request operation and the network error that occurred.
  179. */
  180. - (void)checkServer:(NSString * _Nonnull)path onCommunication:
  181. (OCCommunication * _Nonnull)sharedOCCommunication
  182. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull))success
  183. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull))failure;
  184. /**
  185. Enqueues a request to creates a directory using a `MKCOL` request for the specified path.
  186. @param path The path for which to create a directory.
  187. @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  188. @param success A block callback, to be fired upon successful completion, with no arguments.
  189. @param failure A block callback, to be fired upon the failure of the request, with two arguments: the request operation and the network error that occurred.
  190. */
  191. - (void)makeCollection:(NSString * _Nonnull)path
  192. onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication
  193. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull))success
  194. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull))failure;
  195. /**
  196. Creates an `NSURLSessionUploadTask` with the specified request for a local file.
  197. @param localSource is a string with the path of the file to upload
  198. @param remoteDestination A remote path, relative to the HTTP client's base URL, to write the data to.
  199. @param progress A progress object monitoring the current upload progress.
  200. @param success A block callback, to be fired upon successful completion, with NSURLResponse and string of redirected server.
  201. @param failure A block callback, to be fired upon the failure of either the request or the parsing of the request's data, with two arguments: the request operation and the network or parsing error that occurred.
  202. *
  203. @warning NSURLSession and NSRULSessionUploadTask only can be supported in iOS 7.
  204. */
  205. - (NSURLSessionUploadTask * _Nonnull)putWithSessionLocalPath:(NSString * _Nonnull)localSource atRemotePath:(NSString * _Nonnull)remoteDestination onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication progress:(void(^ _Nonnull)(NSProgress * _Nonnull progress))uploadProgress success:(void(^ _Nonnull)(NSURLResponse * _Nonnull, NSString * _Nonnull))success failure:(void(^ _Nonnull)(NSURLResponse * _Nonnull, id _Nonnull, NSError * _Nonnull))failure failureBeforeRequest:(void(^ _Nonnull)(NSError * _Nonnull)) failureBeforeRequest;
  206. ///-----------------------------------
  207. /// @name requestForUserNameByCookie
  208. ///-----------------------------------
  209. /**
  210. * Method to obtain the User name by the cookie of the session
  211. *
  212. * @param NSString the cookie of the session
  213. *
  214. */
  215. - (void) requestUserNameOfServer:(NSString * _Nonnull) path byCookie:(NSString * _Nonnull) cookieString onCommunication:
  216. (OCCommunication * _Nonnull)sharedOCCommunication success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull))success
  217. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull))failure;
  218. ///-----------------------------------
  219. /// @name Get status of the server
  220. ///-----------------------------------
  221. /**
  222. * Method to get the json of the status.php common in the ownCloud servers
  223. *
  224. * @param serverPath -> url of the server
  225. * @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  226. * @param success A block callback, to be fired upon successful completion, with two arguments: the request operation and a data with the json file.
  227. * @param failure A block callback, to be fired upon the failure of the request, with two arguments: the request operation and error.
  228. *
  229. */
  230. - (void) getStatusOfTheServer:(NSString * _Nonnull)serverPath onCommunication:
  231. (OCCommunication * _Nonnull)sharedOCCommunication success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull responseObject))success
  232. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  233. ///-----------------------------------
  234. /// @name Get All the shared files and folders of a server
  235. ///-----------------------------------
  236. /**
  237. Method to get all the shared files fo an account by the server path and api
  238. @param serverPath -> The url of the server including the path of the Share API.
  239. @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  240. @param success A block callback, to be fired upon successful completion, with two arguments: the request operation and a dictionary with the properties of the directory and its contents.
  241. @param failure A block callback, to be fired upon the failure of either the request or the parsing of the request's data, with two arguments: the request operation and the network or parsing error that occurred.
  242. */
  243. - (void)listSharedByServer:(NSString * _Nonnull)serverPath
  244. onCommunication: (OCCommunication * _Nonnull)sharedOCCommunication
  245. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull responseObject))success
  246. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  247. ///-----------------------------------
  248. /// @name Get All the shared files and folders of concrete folder
  249. ///-----------------------------------
  250. /**
  251. Method to get all the shared files fo an account by the server path and api
  252. @param serverPath -> The url of the server including the path of the Share API.
  253. @param path -> The path of the folder that we want to know the shared
  254. @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  255. @param success A block callback, to be fired upon successful completion, with two arguments: the request operation and a dictionary with the properties of the directory and its contents.
  256. @param failure A block callback, to be fired upon the failure of either the request or the parsing of the request's data, with two arguments: the request operation and the network or parsing error that occurred.
  257. */
  258. - (void)listSharedByServer:(NSString * _Nonnull)serverPath andPath:(NSString * _Nonnull) path
  259. onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication
  260. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull))success
  261. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull))failure;
  262. ///-----------------------------------
  263. /// @name shareFileOrFolderByServer
  264. ///-----------------------------------
  265. /**
  266. * Method to share a file or folder with password
  267. *
  268. * @param serverPath -> NSString: Server path where we want to share a file or folder. Ex: http://10.40.40.20/owncloud/ocs/v1.php/apps/files_sharing/api/v1/shares
  269. * @param filePath -> NSString: Path of the server where is the file. Ex: /File.pdf
  270. * @param password -> NSString: Password
  271. * @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  272. * @param success A block callback, to be fired upon successful completion, with two arguments: the request operation and a data with the json file.
  273. * @param failure A block callback, to be fired upon the failure of the request, with two arguments: the request operation and error.
  274. *
  275. */
  276. - (void)shareByLinkFileOrFolderByServer:(NSString * _Nonnull)serverPath andPath:(NSString * _Nonnull) filePath andPassword:(NSString * _Nonnull)password
  277. onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication
  278. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull))success
  279. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull))failure;
  280. ///-----------------------------------
  281. /// @name shareFileOrFolderByServer
  282. ///-----------------------------------
  283. /**
  284. * Method to share a file or folder
  285. *
  286. * @param serverPath -> NSString: Server path where we want to share a file or folder. Ex: http://10.40.40.20/owncloud/ocs/v1.php/apps/files_sharing/api/v1/shares
  287. * @param filePath -> NSString: Path of the server where is the file. Ex: /File.pdf
  288. * @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  289. * @param success A block callback, to be fired upon successful completion, with two arguments: the request operation and a data with the json file.
  290. * @param failure A block callback, to be fired upon the failure of the request, with two arguments: the request operation and error.
  291. *
  292. */
  293. - (void)shareByLinkFileOrFolderByServer:(NSString * _Nonnull)serverPath andPath:(NSString * _Nonnull) filePath
  294. onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication
  295. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull))success
  296. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull))failure;
  297. ///-----------------------------------
  298. /// @name shareWith
  299. ///-----------------------------------
  300. /**
  301. * Method to share a file or folder with user and group
  302. *
  303. * @param userOrGroup -> NSString: user or group (You can get the shares id in the calls searchUsersAndGroupsWith....)
  304. * @param shareeType -> NSInteger: to set the type of sharee (user/group/federated)
  305. * @param serverPath -> NSString: Server path where we want to share a file or folder. Ex: http://10.40.40.20/owncloud/ocs/v2.php/apps/files_sharing/api/v1/sharees?format=json
  306. * @param filePath -> NSString: Path of the server where is the file. Ex: /File.pdf
  307. * @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  308. * @param success A block callback, to be fired upon successful completion, with two arguments: the request operation and a data with the json file.
  309. * @param failure A block callback, to be fired upon the failure of the request, with two arguments: the request operation and error.
  310. *
  311. */
  312. - (void)shareWith:(NSString * _Nonnull)userOrGroup shareeType:(NSInteger)shareeType inServer:(NSString * _Nonnull) serverPath andPath:(NSString * _Nonnull) filePath andPermissions:(NSInteger) permissions onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication
  313. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull))success
  314. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull))failure;
  315. ///-----------------------------------
  316. /// @name unShareFileOrFolderByServer
  317. ///-----------------------------------
  318. /**
  319. * Method to unshare a file or folder
  320. *
  321. * @param serverPath -> NSString: Server path with the id of the file or folder that we want to unshare Ex: http://10.40.40.20/owncloud/ocs/v1.php/apps/files_sharing/api/v1/shares/44
  322. * @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  323. * @param success A block callback, to be fired upon successful completion, with two arguments: the request operation and a data with the json file.
  324. * @param failure A block callback, to be fired upon the failure of the request, with two arguments: the request operation and error.
  325. */
  326. - (void)unShareFileOrFolderByServer:(NSString * _Nonnull)serverPath
  327. onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication
  328. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull))success
  329. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull))failure;
  330. ///-----------------------------------
  331. /// @name isShareFileOrFolderByServer
  332. ///-----------------------------------
  333. /**
  334. * Method to know if a share item still shared
  335. *
  336. * @param serverPath -> NSString: Server path with the id of the file or folder that we want know if is shared Ex: http://10.40.40.20/owncloud/ocs/v1.php/apps/files_sharing/api/v1/shares/44
  337. * @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  338. * @param success A block callback, to be fired upon successful completion, with two arguments: the request operation and a data with the json file.
  339. * @param failure A block callback, to be fired upon the failure of the request, with two arguments: the request operation and error.
  340. */
  341. - (void)isShareFileOrFolderByServer:(NSString * _Nonnull)serverPath
  342. onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication
  343. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull))success
  344. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull))failure;
  345. ///-----------------------------------
  346. /// @name updateShareItem
  347. ///-----------------------------------
  348. /**
  349. * Method to update a share link
  350. *
  351. * @param shareId -> NSInterger: Share id (You can get the shares id in the calls listSharedByServer....)
  352. * @param serverPath -> NSString: Server path with the id of the file or folder that we want know if is shared Ex: http://10.40.40.20/owncloud/ocs/v1.php/apps/files_sharing/api/v1/shares/44
  353. * @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  354. * @param success A block callback, to be fired upon successful completion, with two arguments: the request operation and a data with the json file.
  355. * @param failure A block callback, to be fired upon the failure of the request, with two arguments: the request operation and error.
  356. */
  357. - (void) updateShareItem:(NSInteger)shareId ofServerPath:(NSString * _Nonnull)serverPath withPasswordProtect:(NSString * _Nonnull)password andExpirationTime:(NSString * _Nonnull)expirationTime andPermissions:(NSInteger)permissions
  358. onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication
  359. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull response))success
  360. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  361. ///-----------------------------------
  362. /// @name searchUsersAndGroupsWith
  363. ///-----------------------------------
  364. /**
  365. * Method to search users or groups
  366. *
  367. * @param searchString -> NSString: Search string
  368. * @param serverPath -> NSString: Server path with the id of the file or folder that we want know if is shared Ex: http://10.40.40.20/owncloud/ocs/v2.php/apps/files_sharing/api/v1/sharees?format=json
  369. * @param page -> NSInteger: Number of page of the results (pagination support)
  370. * @param resultsPerPage -> NSInteger: Number of results per page (pagination support)
  371. * @param sharedOCCommunication Singleton of communication to add the operation on the queue.
  372. * @param success A block callback, to be fired upon successful completion, with two arguments: the request operation and a data with the json file.
  373. * @param failure A block callback, to be fired upon the failure of the request, with two arguments: the request operation and error.
  374. */
  375. - (void) searchUsersAndGroupsWith:(NSString * _Nonnull)searchString forPage:(NSInteger)page with:(NSInteger)resultsPerPage ofServer:(NSString * _Nonnull)serverPath onCommunication:(OCCommunication * _Nonnull)sharedOCComunication
  376. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull response))success
  377. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  378. - (void) getSharePermissionsFile:(NSString * _Nonnull)fileName onCommunication:(OCCommunication * _Nonnull)sharedOCComunication success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull response))success
  379. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  380. ///-----------------------------------
  381. /// @name Get the server capabilities
  382. ///-----------------------------------
  383. /**
  384. * Method read the capabilities of the server
  385. *
  386. * @param serverPath -> NSString server
  387. * @param sharedOCCommunication -> OCCommunication Singleton of communication to add the operation on the queue.
  388. *
  389. * @return capabilities -> OCCapabilities
  390. *
  391. */
  392. - (void) getCapabilitiesOfServer:(NSString * _Nonnull)serverPath onCommunication:(OCCommunication * _Nonnull)sharedOCComunication success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull response))success
  393. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  394. #pragma mark - Remote thumbnails
  395. ///-----------------------------------
  396. /// @name Get the thumbnail for a file
  397. ///-----------------------------------
  398. /**
  399. * Method to get the remote thumbnail for a file
  400. *
  401. * @param serverPath -> NSString server
  402. * @param filePath -> NSString file path
  403. * @param fileWidth -> NSInteger with the width size
  404. * @param fileHeight -> NSInteger with the height size
  405. * @param sharedOCCommunication -> OCCommunication Singleton of communication to add the operation on the queue.
  406. *
  407. * @return nsData -> thumbnail of the file with the size requested
  408. *
  409. */
  410. - (OCHTTPRequestOperation * _Nonnull) getRemoteThumbnailByServer:(NSString * _Nonnull)serverPath ofFilePath:(NSString * _Nonnull)filePath withWidth:(NSInteger)fileWidth andHeight:(NSInteger)fileHeight onCommunication:(OCCommunication * _Nonnull)sharedOCComunication
  411. success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull response))success
  412. failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  413. #pragma mark - Notification
  414. ///-----------------------------------
  415. /// @name Get the server Notification
  416. ///-----------------------------------
  417. /**
  418. * Method read the notification of the server
  419. *
  420. * @param serverPath -> NSString server
  421. * @param sharedOCCommunication -> OCCommunication Singleton of communication to add the operation on the queue.
  422. *
  423. * @return listOfNotifications -> OCNotification
  424. *
  425. */
  426. - (void) getNotificationServer:(NSString * _Nonnull)serverPath onCommunication:(OCCommunication * _Nonnull)sharedOCComunication success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull response))success failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  427. ///-----------------------------------
  428. /// @name set server Notification
  429. ///-----------------------------------
  430. /**
  431. * Method read the notification of the server
  432. *
  433. * @param serverPath -> NSString server
  434. * @param type -> NSString "POST" "DELETE"
  435. * @param sharedOCCommunication -> OCCommunication Singleton of communication to add the operation on the queue.
  436. *
  437. */
  438. - (void)setNotificationServer:(NSString * _Nonnull)serverPath type:(NSString * _Nonnull)type onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull))success failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull))failure;
  439. ///-----------------------------------
  440. /// @name Subscribing at the Nextcloud server
  441. ///-----------------------------------
  442. /**
  443. * Method read the notification of the server
  444. *
  445. * @param serverPath -> NSString server
  446. * @param type -> NSString "POST" "DELETE"
  447. * @param sharedOCCommunication -> OCCommunication Singleton of communication to add the operation on the queue.
  448. *
  449. */
  450. - (void)subscribingNextcloudServerPush:(NSString * _Nonnull)serverPath authorizationToken:(NSString * _Nonnull)authorizationToken pushTokenHash:(NSString * _Nonnull)pushTokenHash devicePublicKey:(NSString * _Nonnull)devicePublicKey proxyServerPath:(NSString * _Nonnull)proxyServerPath onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull))success failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull))failure;
  451. - (void)subscribingPushProxy:(NSString * _Nonnull)serverPath authorizationToken:(NSString * _Nonnull)authorizationToken pushToken:(NSString * _Nonnull)pushToken deviceIdentifier:(NSString * _Nonnull)deviceIdentifier deviceIdentifierSignature:(NSString * _Nonnull)deviceIdentifierSignature userPublicKey:(NSString * _Nonnull)userPublicKey onCommunication:(OCCommunication * _Nonnull)sharedOCCommunication success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nonnull))success failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull, id _Nullable responseObject, NSError * _Nonnull))failure;
  452. ///-----------------------------------
  453. /// @name Get the server Notification
  454. ///-----------------------------------
  455. /**
  456. * Method read the notification of the server
  457. *
  458. * @param serverPath -> NSString server
  459. * @param sharedOCCommunication -> OCCommunication Singleton of communication to add the operation on the queue.
  460. *
  461. * @return listOfActivity -> OCActivity
  462. *
  463. */
  464. - (void) getActivityServer:(NSString * _Nonnull)serverPath onCommunication:(OCCommunication * _Nonnull)sharedOCComunication success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull response))success failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  465. ///-----------------------------------
  466. /// @name Get the list of External sites
  467. ///-----------------------------------
  468. /**
  469. * Method read the notification of the server
  470. *
  471. * @param serverPath -> NSString server
  472. * @param sharedOCCommunication -> OCCommunication Singleton of communication to add the operation on the queue.
  473. *
  474. * @return listOfExternalSites -> OCExternalSites
  475. *
  476. */
  477. - (void) getExternalSitesServer:(NSString * _Nonnull)serverPath onCommunication:(OCCommunication * _Nonnull)sharedOCComunication success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull response))success failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  478. ///-----------------------------------
  479. /// @name Get User Profile
  480. ///-----------------------------------
  481. /**
  482. * Method read the notification of the server
  483. *
  484. * @param serverPath -> NSString server
  485. * @param sharedOCCommunication -> OCCommunication Singleton of communication to add the operation on the queue.
  486. *
  487. * @return userProfile -> OCUserProfile
  488. *
  489. */
  490. - (void) getUserProfileServer:(NSString * _Nonnull)serverPath onCommunication:(OCCommunication * _Nonnull)sharedOCComunication success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull response))success failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  491. ///-----------------------------------
  492. /// End-to-End Encryption
  493. ///-----------------------------------
  494. - (void)getEndToEndPublicKeys:(NSString * _Nonnull)serverPath onCommunication:(OCCommunication * _Nonnull)sharedOCComunication success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull response))success failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  495. - (void)getEndToEndPrivateKeyCipher:(NSString * _Nonnull)serverPath onCommunication:(OCCommunication * _Nonnull)sharedOCComunication success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull response))success failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  496. - (void)getEndToEndServerPublicKey:(NSString * _Nonnull)serverPath onCommunication:(OCCommunication * _Nonnull)sharedOCComunication success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull response))success failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  497. - (void)signEndToEndPublicKey:(NSString * _Nonnull)serverPath onCommunication:(OCCommunication * _Nonnull)sharedOCComunication success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull response))success failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  498. - (void)storeEndToEndPrivateKeyCipher:(NSString * _Nonnull)serverPath onCommunication:(OCCommunication * _Nonnull)sharedOCComunication success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull response))success failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  499. - (void)deleteEndToEndPublicKey:(NSString * _Nonnull)serverPath onCommunication:(OCCommunication * _Nonnull)sharedOCComunication success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull response))success failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  500. - (void)deleteEndToEndPrivateKey:(NSString * _Nonnull)serverPath onCommunication:(OCCommunication * _Nonnull)sharedOCComunication success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull response))success failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  501. - (void)markEndToEndFolderEncrypted:(NSString * _Nonnull)serverPath onCommunication:(OCCommunication * _Nonnull)sharedOCComunication success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull response))success failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  502. - (void)deletemarkEndToEndFolderEncrypted:(NSString * _Nonnull)serverPath onCommunication:(OCCommunication * _Nonnull)sharedOCComunication success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull response))success failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  503. - (void)lockEndToEndFolderEncrypted:(NSString * _Nonnull)serverPath onCommunication:(OCCommunication * _Nonnull)sharedOCComunication success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull response))success failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  504. - (void)unlockEndToEndFolderEncrypted:(NSString * _Nonnull)serverPath token:(NSString * _Nonnull)token onCommunication:(OCCommunication * _Nonnull)sharedOCComunication success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull response))success failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  505. - (void)getEndToEndMetadata:(NSString * _Nonnull)serverPath onCommunication:(OCCommunication * _Nonnull)sharedOCComunication success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull response))success failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  506. - (void)storeEndToEndMetadata:(NSString * _Nonnull)serverPath metadata:(NSString * _Nonnull)metadata onCommunication:(OCCommunication * _Nonnull)sharedOCComunication success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull response))success failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  507. - (void)updateEndToEndMetadata:(NSString * _Nonnull)serverPath metadata:(NSString * _Nonnull)metadata onCommunication:(OCCommunication * _Nonnull)sharedOCComunication success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull response))success failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  508. - (void)deleteEndToEndMetadata:(NSString * _Nonnull)serverPath onCommunication:(OCCommunication * _Nonnull)sharedOCComunication success:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nonnull response))success failure:(void(^ _Nonnull)(NSHTTPURLResponse * _Nonnull operation, id _Nullable responseObject, NSError * _Nonnull error))failure;
  509. @end